1

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"]];
David Small
  • 581
  • 1
  • 10
  • 25

3 Answers3

2

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

m.ding
  • 3,172
  • 19
  • 27
1

CCParticleExplosion is declared in cocos2dx/particle_nodes/CCParticleExamples.h.

Here's the C++ equivalent of your Objective C code:

CCTexture2D* texture = CCTextureCache::sharedTextureCache()->textureForKey("star.png");
CCParticleExplosion* firework = CCParticleExplosion::create();
firework->setTexture(texture);
Nathanael Weiss
  • 737
  • 1
  • 10
  • 23
0

see the tests folder in the cocos2d-x root folder.