第一种方法:自定义
-
-
CCParticleSystem* pParticleSystem=new CCParticleSystemQuad();
-
-
pParticleSystem->initWithTotalParticles(300);
-
-
pParticleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("yezi.png"));
-
-
pParticleSystem->setDuration(-1);
-
-
pParticleSystem->setGravity(CCPointZero);
-
-
pParticleSystem->setAngle(0);
-
pParticleSystem->setAngleVar(360);
-
-
pParticleSystem->setSpeed(50);
-
pParticleSystem->setSpeedVar(10);
-
-
pParticleSystem->setRadialAccel(70);
-
pParticleSystem->setRadialAccelVar(10);
-
-
pParticleSystem->setTangentialAccel(80);
-
pParticleSystem->setTangentialAccelVar(0);
-
-
pParticleSystem->setPosition(mSize.width/2,mSize.height/2);
-
pParticleSystem->setPosVar(ccp(100,100));
-
-
pParticleSystem->setLife(2);
-
pParticleSystem->setLifeVar(0.3);
-
-
ccColor4F cccStart={0.5,0.5,0.5,1.0};
-
pParticleSystem->setStartColor(cccStart);
-
pParticleSystem->setStartColorVar(cccStart);
-
-
ccColor4F cccEnd={0.5,0.5,0.5,1.0};
-
pParticleSystem->setStartColor(cccEnd);
-
pParticleSystem->setStartColorVar(cccEnd);
-
-
pParticleSystem->setStartSize(10);
-
pParticleSystem->setStartSizeVar(20);
-
-
pParticleSystem->setStartSize(12);
-
pParticleSystem->setStartSizeVar(12);
-
-
pParticleSystem->setEmissionRate(pParticleSystem->getTotalParticles()/pParticleSystem->getLife());
-
-
this->addChild(pParticleSystem,1);
效果图:

第二种方法:使用系统自带的
-
CCParticleSystem* m_emitter;
-
m_emitter = CCParticleFireworks::create();
-
m_emitter->retain();
-
this->addChild(m_emitter, 10);
-
m_emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage("yezi.png") );
-
m_emitter->setPosition(ccp(300,320));
效果图:

其他:
-
-- CCParticleSystem(所有粒子系统的父类)
-
-- CCParticleSystemPoint、CCParticleSystemQuad 点粒子和方形粒子系统
-
-- CCParticleExplosion (爆炸粒子效果)
-
-- CCParticleFireworks (烟花粒子效果)
-
-- CCParticleFire (火焰粒子效果)
-
-- CCParticleFlower (花束粒子效果)
-
-- CCParticleGalaxy (星系粒子效果)
-
-- CCParticleMeteor (流星粒子效果)
-
-- CCParticleSpiral (漩涡粒子效果)
-
-- CCParticleSnow (雪粒子效果)
-
-- CCParticleSmoke (烟粒子效果)
-
-- CCParticleSun (太阳粒子效果)
-
-- CCParticleRain (雨粒子效果)
第三种:使用plist文件
-
CCParticleSystemQuad *system = CCParticleSystemQuad::create("lizi.plist");
-
system->setPosition(ccp(mSize.width/2, mSize.height/2));
-
this->addChild(system, 1);
Cocos2d 粒子效果
原文:http://blog.csdn.net/zhenyu5211314/article/details/39611589