Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Learning Cocos2d-x Game Development
  • Toc
  • feedback
Learning Cocos2d-x Game Development

Learning Cocos2d-x Game Development

By : Siddharth Shekar
3 (1)
close
Learning Cocos2d-x Game Development

Learning Cocos2d-x Game Development

3 (1)
By: Siddharth Shekar

Overview of this book

If you are a hobbyist, novice game developer, or programmer who wants to learn about developing games/apps using Cocos2d-x, this book is ideal for you.
Table of Contents (13 chapters)
close
12
Index

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

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete