The Armor Games website will be down for maintenance on Monday 10/7/2024
starting at 10:00 AM Pacific time. We apologize for the inconvenience.

ForumsProgramming Forumas3 Hittest Help

1 3935
alsage
offline
alsage
132 posts
Nomad

So I am trying to get one object to get my paddle_MC to hittest my ball_MC WHILE inside the Ball_MC .as script. I was able to get this to work in my main stage .as file but I want it in my ball_mc as.


package {

import flash.display.MovieClip;
import flash.events.Event;
import flash.display.Stage;


public class Ball extends MovieClip {
public var BALL_SPEEDX:Number = 10;
public var BALL_SPEEDY:Number = 10;

public function Ball() {
stage.addEventListener(Event.ENTER_FRAME, BallHitPaddle);
}

private function BallHitPaddle(e:Event)
{

if(this.hitTestObject(stage.Paddle_MC))
{
BALL_SPEEDX *= -1;
BALL_SPEEDY *= -1;
}

}
}

}
  • 1 Reply
alsage
offline
alsage
132 posts
Nomad

Never mind I figured it out.

Showing 1-1 of 1