Adding particles for jetpack when a player moves upwards
Similar to how we created the explosion effect, we will create the flame particle effect. However, as we require the player's position at all times, we will create a global CCParticleSystemQuad
instance named flameParticle
in the HelloWorldScene.h
file.
Import the jetBoost.plist
and jetBoost.png
files from the resources folder for the chapter and place them in the resources folder of the game.
Next, right under where we added the hudLayer
in the init
function in HelloWorldScene.cpp
file, add the following lines of the code:
flameParticle = CCParticleSystemQuad::create("jetBoost.plist"); flameParticle->setPosition(ccpAdd(hero->getPosition(), ccp(-hero->getContentSize().width * 0.25, 0))); this->addChild(flameParticle);
Here, we create a new CCParticleSystemQuad
instance with the jetBoost.plist
file, and then, we give the position from where we want the particle to be created. We give the hero's position and subtract the hero...