Enemy类没什么内容,就create和init方法,根据参数来创建不同的敌机,头文件代码如下:

 1 //飞机的类型
 2 enum planeType {smallPlane, midPlane, bigPlane};
 3 
 4 class Enemy : public CCSprite
 5 {
 6 
 7 public:
 8 
 9     void loseLife();
10     
11     CC_SYNTHESIZE(float, m_speed, Speed);
12     CC_SYNTHESIZE(int, m_life, Life);
13     CC_SYNTHESIZE(int, m_score, Score);
14     CC_SYNTHESIZE(planeType, m_type, Type);
15 
16     ~Enemy();
17     virtual bool init(planeType type, CCTexture2D* texture);
18     static Enemy* create(planeType type, CCTexture2D* texture);
19 
20 };
View Code

相关文章: