Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Design > Adobe Creative Suite

  • Print
  • + Share This
Like this article? We recommend

Get Ready to be Paddled

To test this out, add a paddle to the game, as shown in Figure 2. You'll be able to control the movement of the paddle with your arrow keys. The paddle will hit the ball and bounce it off the walls. You will need to name the paddle movie clip thePaddle (see Figure 2).

Figure 2Figure 2 The paddle enables you to hit the ball as it falls down. This uses the hitTest method.


The following script adds the paddle movement:

   for(thisPad=0;thisPad<2;thisPad++){
     var thePaddle = ThePlayer[thisPad];
     if (this.MovieClip.hitTest(thePaddle) && this.deltaY > 0) {
        this.paddleHit(thePaddle);
     }
   }

Here, the movie clip method hitTest is used to allow an object to physically collide with another. In this case, the ball can collide with the paddle. After a collision has occurred, an event can be triggered. In this instance, the value to the variable deltaY is triggered, causing the ball to be sent back up the screen.

  • + Share This
  • 🔖 Save To Your Account