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 – adding a World class

To implement our World class, we need to use the following steps:

  1. Add a new Objective-C class called World, which is derived from NSObject.
  2. To add a level property from the int type, do the following:
    • Add a static variable called level in World.h, as shown in the following line of code:
      static int level;
    • Add a static getter with the same name that returns the static variable, as shown in the following line of code:
      +(int) level;
    • Add a static setter (setLevel) that sets the static variable, as shown in the following line of code:
      +(void) setLevel:(int)value;
  3. Repeat step 2 for the properties gold, hitpoints, and damage.
  4. We also need a levelMax property, but this one does not have a setter.
  5. We need to import the Assets.h ...

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