Pages

Coco2d-x particle system

I use ParticleCreator for Macos to create particle effects for Cocos2d.  I'm now using Coco2dx - problem ParticleCreator creates objective-c rather than C++.  Here's some particle code converted to C++


 CCParticleSystem*  particle =  new  CCParticleSystemQuad ();
 particle->retain();
 particle-> initWithTotalParticles (700);

 CCTexture2D* tex = CCTextureCache::sharedTextureCache()->addImage("ex.png");
 particle->setTexture(tex);

 particle->setEmissionRate(7000.00);
 particle->setAngle(90.0);
 particle->setAngleVar(360.0);
 ccBlendFunc blendFunc={GL_ONE,GL_ONE_MINUS_SRC_ALPHA};
 particle->setBlendFunc(blendFunc);
 particle->setDuration(0.10);
 particle->setEmitterMode(kCCParticleModeGravity);
 ccColor4F startColor = {1.00,1.00,1.00,1.00};
 particle->setStartColor(startColor);
 ccColor4F startColorVar = {0.00,0.00,0.00,0.00};
 particle->setStartColorVar(startColorVar);
 ccColor4F endColor = {1.00,1.00,1.00,0.00};
 particle->setEndColor(endColor);
 ccColor4F endColorVar = {0.00,0.00,0.00,0.00};
 particle->setEndColorVar(endColorVar);
 particle->setStartSize(5.00);
 particle->setStartSizeVar(0.00);
 particle->setEndSize(2.00);
 particle->setEndSizeVar(0.00);
 particle->setGravity(ccp(0.00,0.00));
 particle->setRadialAccel(0.00);
 particle->setRadialAccelVar(0.00);
 particle->setSpeed(127);
 particle->setSpeedVar(180);
 particle->setTangentialAccel(0);
 particle->setTangentialAccelVar(0);
 particle->setTotalParticles(700);
 particle->setLife(5.00);
 particle->setLifeVar(2.00);
 particle->setStartSpin(0.00);
 particle->setStartSpinVar(0.00);
 particle->setEndSpin(0.00);
 particle->setEndSpinVar(0.00);
 particle->setPosition(ship->getPosition());

 particle->setPosVar(ccp(0.00,0.00));

No comments:

Post a comment