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); ...

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.