Home / Articles / Adobe Flash / Collision Detection with Flash MX

Collision Detection with Flash MX

Article Description

Collision detection is all about detecting objects and boundaries on the stage. Matthew David illustrates how to use collision detection in an arcade-style game.

Like this article? We recommend

Macromedia Flash MX Game Design Demystified

Macromedia Flash MX Game Design Demystified

$49.99

Life Is Short

Some more script can be added to remove a life from the player who misses the ball with the paddle. That script is shown here:

   if (this.MovieClip._y>(GamePlayArea[3]+20)) {
     theBallsList[this.name] = 0;
     removeMovieClip(this.MovieClip);
     CurrentBallNum--;
     if (CurrentBallNum<=0) {
        ballsLeft--;
        if (ballsLeft<0) {
          ballsLeft = 0;
          gameOn = 0;
          gotoAndStop (5);
        } else {
        addNewBall();
        }
     }
   }

In this script, Flash looks for the current position of the ball in relationship to GamePlayArea. If the ball falls below a specific point, such as the bottom of the screen, the player automatically loses a life.

5. Hitting the Blocks | Next Section Previous Section