January 2012
Beginner
655 pages
16h 35m
English
One of the easiest ways to get started with animation is to use the NSTimer class. The NSTimer class creates timer objects, which enable you to call a method at a regular time interval. Using an NSTimer object, you can update the position of an image at regular time intervals, thereby creating the impression that it is being animated.
In the following Try It Out, you learn how to display a bouncing ball on the screen using the NSTimer class. When the ball touches the sides of the screen, it bounces off in the opposite direction. You also learn how to control the frequency with which the ball animates. Download the code files indicated for this and other Try It Out features within this chapter.
TRY IT OUT: Animating a Ball
![]()

FIGURE 13-1