Book Image

Cocos2d Game Development Blueprints

By : Jorge Jordán
Book Image

Cocos2d Game Development Blueprints

By: Jorge Jordán

Overview of this book

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

Creating the zombie class


As our zombie is going to perform several movements such as walk, run, or hit and it will have some attributes as the life points, we will create a class for it. Follow these steps:

  1. Right-click on the Classes group in the project navigator and select New File….

  2. Click on iOS | cocos2d v3.x | CCNode class.

  3. Make this class a subclass of CCNode, call it Zombie, and click on Create.

Replace the contents of Zombie.h with:

#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "CCAnimation.h"

typedef enum {
    stateStill = 0,
    stateWalking,
    stateRunning,
    stateHitting
} ZombieStates;

@interface Zombie : CCNode {
}

@property (readwrite, nonatomic) int lifePoints;
@property (readwrite, nonatomic) ZombieStates *state;
@property (readwrite, nonatomic) CCSprite *zombieSprite;
@property (readonly, nonatomic) CCActionAnimate *actionStill;
@property (readonly, nonatomic) CCActionRepeatForever *actionWalk;
@property (readonly, nonatomic) CCActionRepeatForever...