Adding an explosion particle system

From the resources provided for the chapter, add the smoke.plist, smoke.png, dusts.plist, and dust.png files to the resources folder in the game.

Now, in the GameplayLayer.cpp file, add the following lines of code in the player rocket and enemy collision check right under where we increment the score:

CCParticleSystemQuad * smokeParticle = CCParticleSystemQuad::create("smoke.plist");
smokeParticle->setPosition(en->getPosition());
this->addChild(smokeParticle);   
smokeParticle->setAutoRemoveOnFinish(true);

                  
CCParticleSystemQuad  * dustParticle = CCParticleSystemQuad::create("dusts.plist");
dustParticle->setPosition(en->getPosition());
this->addChild(dustParticle);   
dustParticle->setAutoRemoveOnFinish(true);

Here, we ...

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.