Predefining defensive positions
To defend our tower from the attack of the robots, we will be able to set some defenses, which will be placed in predefined positions, as we want the scenario to look neat.
These positions have been defined in a .plist
file that we need to load, so follow these steps:
In the project navigator, right-click the Resources group and select Add Files to "DefenseTheTower"….
Look for the
DefensePositions.plist
files in theResources
folder.Be sure that Copy items into destination group's folder (if needed) is selected and click on Add.
In GameScene.m
, add the following constant definition:
// Number of defenses const int kNUM_DEFENSES = 30;
This is the maximum number of defenses and hence the maximum number of predefined positions.
Declare the following array that will contain the list of predefined positions:
// Declare array of defense positions NSMutableArray *_defensePositions;
And call the following method at the end of init
just before return self:
// Load defense...