[Basic Objects] Particle

Adding A Particle

Drag a Particle from the Basic Objects section onto the middle canvas.

258

Selecting The Particle

You can select the particle if it isn't already selected from the Animation Editor at the bottom. The particle doesn't appear in the resources as it's part of the Scene or other object that you are using.

252

Changing The Particle

You can change the particle by selecting another particle from your computer. You can use the website below to create particles for free.

http://particle2dx.com/

355

Accessing The Particle In Code

Particles can be accessed via their Name or Tag which can be set in the Properties section.

356

To access the particle from a scene for example, in code it is simple. You either access it as a Node or cast it to a Particle allowing you to use Particle methods along with Node methods.

Node *rootNode = CSLoader::createNode( "Filepath to .csb file" );
this->addChild( rootNode );

// particle accessed as a node using it's name
Node *particle = rootNode->getChildByName( "Name set in Cocos Studio" );

// particle cast to a particle using it's name
ParticleSystem *particle = ( ParticleSystem * )rootNode->getChildByName( "Name set in Cocos Studio" );

// particle accessed as a node using it's tag
Node *particle = rootNode->getChildByTag( 5 );

// particle cast to a particle using it's tag
ParticleSystem *particle = ( ParticleSystem * )rootNode->getChildByTag( 5 );
var rootNode = ccs.load( "Filepath to .json file" );
this.addChild( rootNode.node );

// get the particle by name
var particle = rootNode.node.getChildByName( "Name set in Cocos Studio" );

// get the particle by tag
var particle = rootNode.node.getChildByTag( 5 );

Note: Cocos2d-JS doesn't require casting to use particle methods.