Understanding CADisplayLink and NSRunLoop

In general, to create a smooth looking animation, a picture has to be updated at least 25 times a second to avoid the eye seeing each individual frame. That means our game must find a way to call updateScene at 25 times a second to achieve a smooth animation. This could be done by creating an NSTimer that calls updateScene at any rate we choose. If we do that, however, our code that updates the scene will not necessarily be in sync with the hardware's native refresh rate of the screen. The framework Core Animation provides a class specifically designed for creating the type of animation we are trying to create: CADisplayLink.

In Listing 5–3, we created a CADisplayLink, specifying that it should call ...

Get Beginning iOS 5 Games Development: Using the iOS 5 SDK for iPad, iPhone, and iPod Touch now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.