Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
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: