Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


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

Chapter 6. Making Things Move > Changing direction

6.5. Changing direction

So far we've covered how to animate, but we haven't really focused on how to control the way a shape animates. I';m not sure about you, but I'd get pretty bored of animating shapes in a straight line all the time.

You already know about animating a shape to the right (by increasing the x value), but what about if you want to change the speed, or change the direction of the animation? It's easy; you just change the amount that you increase (or decrease) the x and y values by. If you use the same code from the previous example, you can easily cause the shapes to animate diagonally down to the right by swapping tmpShape.x++ for the following:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint