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...


We have a lot of work to do, so let's quickly list the main tasks at hand:

  • Create

    • Create the level by parsing an XML file containing level data

    • Create the player

    • Create the HUD

  • Move the enemies

  • Update

    • Fire player and enemy bullets

    • Collision detection

    • Level completion and game over conditions

However, before we complete all these tasks, we need to define the classes for our three major game play entities: player, enemy, and brick.

The Player class

Our Player entity inherits from CustomSprite and can die and come back to life, but only twice. The third time it dies, the game is over! Let's take a look at the significant functions that make our Player entity brave and enduring:

void Player::Enter()
{
  // initially position the player below the screen
  setPosition(ccp(SCREEN_SIZE.width * 0.5, SCREEN_SIZE.height * -0.1));

  // animate the move into the screen
  CCActionInterval* movement = CCEaseBackOut::create(CCMoveTo::create(
  1.0f, ccp(SCREEN_SIZE.width * 0.5, SCREEN_SIZE.height...