Initializing the game
In the code files of this chapter, you will find DefenseTheTower_init.zip
, which includes an initial project that we will use as the basis for the rest of the chapter.
If you open the project in Xcode, you will find the following classes in the Classes group: AppDelegate
, Defense
, and GameScene
.
The first one is similar to the delegates we used in our previous games, so we don't need to go into deeper detail.
Open Defense.h
and you will see the definition of the DefenseLevel
enumeration:
typedef enum { levelOne = 0, levelTwo, levelThree } DefenseLevel;
It contains the three different levels a defense object can be.
This header class also declares a property for the defense level, the sprite that will give it a visual representation, and the damage it deals to enemies:
// Property for defense level @property (readwrite, nonatomic) DefenseLevel *defenseLevel; // Property for the sprite @property (readwrite, nonatomic) CCSprite *defenseSprite; // Property for the...