O'Reilly logo

Learning Cocos2d-x Game Development by Siddharth Shekar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding hero controls

In the previous chapter, we added a small button in the screen where if the player tapped on that button, the hero created a bullet. That's quite good, but what we want is that whenever the player taps on the right-hand side of the screen, the rocket should fire. This is because the button is too small and the player wouldn't have much time to see where the button is located for him/her to tap on. We will also add a button on the left-hand side of the screen to boost the hero up whenever the button is tapped.

For this, let's make some changes to the HelloWorldScene.h and HelloWorldScene.cpp files. In the .h file, remove void menuCloseCallback(CCObject* pSender); and add a function named fireRocket() under the spawnEnemy(float ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required