Game Development Reference
In-Depth Information
be as cool as an augmented reality game, but it should help to pave the way for other developers.
Figure 8-9 shows the accelerometer example being run.
Figure 8-9. Multiple screen of accelerometer demo
In Figure 8-9 , we see several screenshots of this example superimposed. In this example, the
location of the Viper is based on the X and Y accelerometer values, so when the iPhone is flat on its
back, the spaceship should be in the center of the game area. When the device is tilted to the left,
the ship moves to the left. When the device is tilted up, the ship will move up, and so on. Figure 8-9
highlights how jumpy the accelerometer data are. These were all taken while I was trying to hold
the device flat (though I was trying to take screenshots at the same time). For a real application, the
accelerometer data would need to be massaged.
The class responsible for our example is the class AccelermoterController , the header of which is
shown in Listing 8-34.
 
Search WWH ::




Custom Search