Game Development Reference
In-Depth Information
In Figure 5-1 , we see a spaceship dodging some asteroids. You will learn how to animate the
different items in the scene, move the ship based on user input, and detect the collisions between
the ship and asteroids.
There are many different technologies that have been used over the years to create these types of
games. These different technologies concern themselves with how content is drawn on the screen.
An example is OpenGL, which provides low-level access to a display. The classes provided by UIKit
( UIView and the like) are perfectly suited for these types of games as well. Regardless of which
technology is used to update the screen, these types of games generally work in the same way, by
creating the loop shown in Figure 5-2 .
Process User
Events
Setup
Update game
State
Update Scene
No
Is Game
Over
Start/Stop
Yes
Figure 5-2. Typical frame-by-frame application loop
In Figure 5-2 , we see that, after the application is set up, a loop is created that is responsible for
processing user events, updating the game state, updating the scene on the screen, and, finally,
checking if the game is over. When creating an application on iOS that functions this way, we don't
have to explicitly create a loop—the application is already running a loop very similar to the one
described in Figure 5-1 . Let's take a closer look at how we set up an iOS application to accomplish
frame-by-frame animations.
Setting Up Your First Frame-by-Frame Animation
The sample code accompanying this chapter is a collection of three examples. Each example builds
on the last to illustrate different concepts. When you run the sample code you will see a screen
similar to Figure 5-3 .
 
 
Search WWH ::




Custom Search