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

On to the game world


You already set the environment up in the last two sections. Now we need to code in some gameplay. So we add towers that the dragon must dodge and add some gravity as well as touch controls. All this action happens in our second scene, which goes by the name GameWorld and is defined in the gameworld.js file. The following are the member variables of gameworld.js:

// variables
screenSize:null,
spriteBatchNode:null,
score:0,
scoreLabel:null,
mustAddScore:false,
tutorialSprite:null,
popup:null,
castleRoof:0,
hasGameStarted:false,
// managers
towerManager:null,
dragonManager:null,
fairytaleManager:null,

You might remember some of the variables declared in the preceding code from the previous chapter. In addition, you can see some variables that record the position of the castle roof, if the game has started and if a score needs to be added. Finally, you will find three variables that will reference our respective managers.

In our first game, we coded all the game logic straight...