Can Someone Give Me A Simple COcos2d-X Particle Example?

David Small picture David Small · Oct 12, 2012 · Viewed 10.8k times · Source

I just want to make a CCParticleExplsion using Cocos2d-x and C++, but can't seem to find it after searching all over. ObjC example:

CCParticleSystem *firework = [[CCParticleExplosion alloc] initWithTotalParticles:200];
[self addChild:firework];
[firework setTexture:[[CCTextureCache sharedTextureCache] addImage:@"star.png"]];

Answer

m.ding picture m.ding · Oct 12, 2012

In most cases, the ParticleTexture comes with the plist file, and the whole plist file is from the particle designer. Usually, we use

CCParticleSystemQuad* p = CCParticleSystemQuad::create("whatever_particle.plist");
this->addChild(p);

but if you wanna use the particles comes with cocos2d-x, you can check how to use them in the Test Cases that comes with the cocos2d-x framework. the file name is ParticleTest.cpp