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

Spawning the towers


To spawn a tower, the player must first tap somewhere on the map to select the location where they want the tower placed. Once an area of the map has been tapped, the following tower selection menu will be shown:

As you can see in the previous screenshot, the player is shown an arrow for each tower. This indicates the direction in which the player must swipe in order to spawn the tower at the specified location. The player can swipe anywhere on the screen and the respective tower will be spawned at the location.

The class responsible for creating that menu, as well as the tower upgrade menu, is defined in the TowerMenu.h and TowerMenu.cpp files. I will skip discussing this class, since it is quite a straightforward class that I'm sure you will be able to wrap your head around with ease.

Now, the tower selection menu shows up when the player taps on the map. Tap gestures are forwarded to the HandleTap function of the GameWorld class:

void GameWorld::HandleTap(CCPoint position...