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 human enemies class


We need a new class to keep the information on each human enemy, who will try to search and kill the zombie before dying. In this section, you will understand how we're going to implement all of this behavior. Perform the following steps:

  1. First of all, 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 Human, and click on Create.

Once the class has been created, open Human.h and replace its contents with the following lines:

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

typedef enum {
    humanStateStill = 0, humanStateWalking, humanStateHitting,
    humanStateDamaged
} HumanStates;
typedef enum {
    grandma = 0, businessman
} HumanType;
typedef enum {
    humanDecisionStill = 0, humanDecisionWalk, humanStateRun
} HumanDecisions;

@class Human;
// Protocol to implement the human behavior
@protocol HumanDelegate...