iOS applications also have another form of input: the accelerometer. This measures the orientation of the iOS device on the X, Y, and Z planes. Device orientation is a dynamic (if slightly delayed) input mechanism with a variety of uses. One of these uses is steering in racing video games.
Execute the following code:
@implementation Ch2_AccelerometerSteering -(CCLayer*) runRecipe { //Enable the accelerometer and set its updateInterval self.isAccelerometerEnabled = YES; [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / 60)]; //Init car background CCSprite *bg = [CCSprite spriteWithFile:@"car_dash.jpg"]; bg.position = ccp(240,160); bg.opacity = 200; [self addChild:bg z:0]; //Init steeringWheel sprite steeringWheel = [CCSprite spriteWithFile:@"car_steering_wheel.png"]; steeringWheel.position = ccp(230,170);...