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

Chapter 25. Storyboarding to Finished Project > Animating the Tank Movement

Animating the Tank Movement

To calculate the distance that the tanks needed to move, I added the following at the end of the code inside the first if statement on the player1tank symbol:

// Calculate distance tank should move 
deltaXsq = Math.pow(Math.abs(deltaX), 2); 
deltaYsq = Math.pow(Math.abs(deltaY), 2); 
distance = Math.sqrt(deltaXsq+deltaYsq); 
// Calculate the distance to move per frame 
perframe = distance/frames; 
// Activate the rotation below 
rotation = true; 


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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