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 ship to shoot cannonballs

Let's allow the pirate ship to shoot cannonballs by following these steps:

  1. Open the Ship.h file.
  2. Add a read-only property called isShooting, which has an instance variable counterpart called _isShooting, as shown in the following code:
    @property (readonly) BOOL isShooting;
  3. Add a cannonball for the left-hand side and the right-hand side of the ship. Both of them are pointers to SPImage, as shown in the following code:
    @property SPImage *cannonBallLeft;
    @property SPImage *cannonBallRight;
  4. Switch to the Ship.m file.
  5. Inside the initWithType method, set the _isShooting instance variable to NO at the top of the method.
  6. Inside the initWithType method, create both cannonballs with the cannonball.png image, ...

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