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 ...
Get Learning Cocos2d-x Game Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.