Book Image

Cocos2d-X Game Development Blueprints

By : Karan Sequeira
Book Image

Cocos2d-X Game Development Blueprints

By: Karan Sequeira

Overview of this book

Table of Contents (17 chapters)
Cocos2d-x Game Development Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The Enemy class


The Enemy class inherits from CCSprite just like the Tower class and will contain all the properties of the struct named EnemyData. The Enemy class defines the functionalities to make the enemy walk along the path dictated by the level, do damage if it reaches the end of the path, take damage from a tower, and die. Let's take a look at the class declaration in the Enemy.h file:

class Enemy: public CCSprite
{
public:
  Enemy();
  virtual ~Enemy();
 
  static Enemy* create(GameWorld* game_world, int type);
 
  virtual bool init(GameWorld* game_world, int type);
  // copy data within the enemy library inside GameGlobals
  virtual void SetEnemyProperties();
 
  // create & update the progress bar showing health left
  void CreateHealthBar();
  void UpdateHealthBar();
 
  // basic enemy behaviour functions
  void StartWalking();
  void FinishWalking();
  void DoDamage();
  void TakeDamage(CCObject* object);
  void Die();
  void TakeSpeedDamage(float speed_damage, 
    float...