We are going to add a particle system to our game to simulate the explosions each time the player touches a bomb. In the interest of doing this, we are going to use the Vector
class located in the Cocos2d-x framework to create a collection of all the bomb objects created in our game, so that when the player touches the screen, we are going to traverse this collection to verify if the player has touched any of the bombs.
If the player touches any bomb, we are going to:
Show an explosion at the location where the bomb sprite was
Make the bomb invisible
Remove the bomb from the screen by using the inherited
removeChild
method, and finallyRemove the bomb object from the collection, so that the next time we traverse the vector, it is disregarded
For this matter, we are going to add the bomb collection to our HelloWorldScene.h
definition file as follows:
cocos2d::Vector<cocos2d::Sprite*> _bombs;
Be aware that we are specifying that we want to use the...