O'Reilly logo

Sparrow iOS Game Framework Beginner's Guide by Johannes Stein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. Open the Ship.h file.
  2. Add an instance variable called _juggler that is a pointer to SPJuggler, as shown in the following line of code:
    SPJuggler *_juggler;
  3. Declare a property called paused, which is of the type BOOL, as shown in the following line of code:
    @property (nonatomic) BOOL paused;
  4. Declare a method called advanceTime, as shown in the following line of code:
    -(void) advanceTime:(double)seconds;
  5. Switch to the Ship.m file.
  6. Inside the initializer, set the paused property to NO using its instance variable, as shown in the following code:
    _isShooting = NO;
    _paused = NO; SPTextureAtlas *atlas = (type == ShipPirate) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required