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 create new instances of CCParticleSystemQuads
named smokeParticle
and dustParticle
. We then give the Plist of the particle that we want to create, in this case, we give smoke.plist
and dusts.plist
....