Time for action – allowing the player to pause and resume
To allow the player to pause and resume the game, we need to follow these steps:
Open the
Ship.h
file.Add an instance variable called
_juggler
that is a pointer toSPJuggler
, as shown in the following line of code:SPJuggler *_juggler;
Declare a property called
paused
, which is of the typeBOOL
, as shown in the following line of code:@property (nonatomic) BOOL paused;
Declare a method called
advanceTime
, as shown in the following line of code:-(void) advanceTime:(double)seconds;
Switch to the
Ship.m
file.Inside the initializer, set the
paused
property toNO
using its instance variable, as shown in the following code:_isShooting = NO; _paused = NO; SPTextureAtlas *atlas = (type == ShipPirate) ? [Assets textureAtlas:@"ship_pirate_small_cannon.xml"] : [Assets textureAtlas:@"ship_small_cannon.xml"];
Initialize the
_juggler
instance variable inside the initializer with the following line of code:_juggler = [SPJuggler juggler];
Update all references...