Game Development Reference
EnemyTypeUFO = 0,
@interface Enemy : CCSprite
@property (readonly, nonatomic) int initialHitPoints;
@property (readonly, nonatomic) int hitPoints;
There is nothing too exciting here. The EnemyTypes enum is used to differentiate
between the three different types of enemies currently supported, with
EnemyType_MAX used as the upper limit for loops, as you'll soon see. The Enemy
class has a member variable that stores the type so that you can use switch state-
ments to branch the code depending on the type of enemy as needed.
The implementation of Enemy contains a lot of code I'd like to discuss, so I'll split the
discussion into several topics and present only the relevant code, beginning with the
initWithType method in Listing 8-8 .
Listing 8-8. Initializing an Enemy with a Type