• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 25. Storyboarding to Finished Pr... > Clicking the Island to Move the Tank

Clicking the Island to Move the Tank

To control where the tanks can move, I used Flash 5’s new built-in hitTest() function, which checks to see whether a movie clip overlaps with specific coordinates or another movie clip. The function’s third argument is a Boolean value that specifies whether to evaluate only the actual area occupied by the symbol rather than the symbol’s rectangular bounding box. I created a new Player 1 target button that was slightly smaller than the left half of the island. The Player1 target button had to be smaller than the area where the tank was allowed to move because it is the center point (rather than the edges) of the tank symbol that is moved to where the player clicks the mouse. I moved the shape into the Hit frame for the button so that it would be invisible. The hitTest() function could not find the Player 1 target symbol because it did not have an instance name. I changed it to a movie clip and set the variable name to player1target. To hide the target, I moved the targets layer below the islands layer.

To check whether the mouse pointer is on top of the player1target movie clip when the mouse is clicked, I placed the following code onto the player1tank movie clip:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint