Chapter 12. Simple Animations and Video Playback
WHAT YOU WILL LEARN IN THIS CHAPTER
How to use the NSTimer class to create timers that call methods at regular intervals
How to perform simple animations using the NSTimer class
How to perform affine transformation on an Image View
How to animate a series of images using Image View
How to play back videos in your iPhone application
Up to this point, the applications you have written have all made use of the standard views provided by the iPhone SDK. As Apple has reiterated, the iPhone is not just for serious work; it is also a gaming platform.
In this chapter, you have some fun creating something visual. You learn how to perform some simple animations using a timer object and then perform some transformations on a view. Although it is beyond the scope of this book to show you how to create animations using OpenGL ES, this chapter does demonstrate some interesting techniques that you can use to make your applications come alive. In addition, you will also learn how to play back a video in your iPhone application.
Using the NSTimer Class
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 an image at regular time intervals, thereby creating an 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 ...