1
粒子
演示样例
2
类图关系
3
系统原生粒子
CCParticleSystem |
全部粒子系统的父类 |
CCParticleSystemPoint、 CCParticleSystemQuad |
点粒子和方形粒子系统,都继承了CCParticleSystem的全部属性 |
CCParticleExplosion |
爆炸粒子效果 |
CCParticleFireworks |
烟花粒子效果 |
CCParticleFire |
火焰粒子效果 |
CCParticleMetepr |
流行粒子效果 |
CCParticleSpiral |
漩涡粒子效果 |
CCParticleSnow |
雪粒子效果 |
CCParticleSmoke |
烟粒子效果 |
CCParticleSun |
太阳粒子效果 |
CCParticleRain |
雨粒子效果 |
4
代码
//CCParticleExplosion * particle = CCParticleExplosion::create(); //CCParticleFireworks * particle = CCParticleFireworks::create(); //CCParticleFire * particle = CCParticleFire::create(); //CCParticleMeteor * particle = CCParticleMeteor::create(); //CCParticleSpiral * particle = CCParticleSpiral::create(); //CCParticleSnow * particle = CCParticleSnow::create(); //CCParticleSmoke * particle = CCParticleSmoke::create(); //CCParticleSun * particle = CCParticleSun::create(); CCParticleRain * particle = CCParticleRain::create(); particle->setPosition(ccp(240, 160)); addChild(particle); |
5
手动制作粒子系统
粒子编译器软件
编辑好后生成xx.plist文件
CCParticleSystemQuad * particle = CCParticleSystemQuad::create("ring.plist"); particle->setPosition(ccp(240, 160)); addChild(particle); particle->setDuration(4); |
6
案例
爆炸粒子效果 |
T21Particle.h |
#ifndef #define #include #include USING_NS_CC; class { public: static CREATE_FUNC(T21Particle); bool }; #endif |
T21Particle.cpp |
#include #include CCScene * { CCScene * T21Particle * scene->addChild(layer); return } bool { TBack::init(); //爆炸粒子效果 CCParticleExplosion * addChild(particle); return } |
执行效果: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdG90b3R1enVvcXVhbg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt=""> |
烟花效果 |
#include #include CCScene * { CCScene * T21Particle * scene->addChild(layer); return } bool { TBack::init(); //烟花效果 CCParticleFireworks * //设置位置显示位置 particle->setPosition(ccp(winSize.width //设置时间间隔 particle->setDuration(20); addChild(particle); return } |
执行结果: |
火焰效果: |
#include #include CCScene * { CCScene * T21Particle * scene->addChild(layer); return } bool { TBack::init(); //火焰效果 CCParticleFire * //设置位置显示位置 particle->setPosition(ccp(winSize.width //设置时间间隔 particle->setDuration(20); addChild(particle); return } |
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdG90b3R1enVvcXVhbg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt=""> |
流星效果: |
#include #include CCScene * { CCScene * T21Particle * scene->addChild(layer); return } bool { TBack::init(); //流星粒子效果 CCParticleMeteor * //设置位置显示位置 particle->setPosition(ccp(winSize.width //设置时间间隔 particle->setDuration(20); addChild(particle); return } |
执行效果: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdG90b3R1enVvcXVhbg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt=""> |
漩涡粒子效果 |
#include #include CCScene * { CCScene * T21Particle * scene->addChild(layer); return } bool { TBack::init(); //流行粒子效果 CCParticleSpiral * //设置位置显示位置 particle->setPosition(ccp(winSize.width //设置时间间隔 particle->setDuration(20); addChild(particle); return } |
执行效果: |
雪花效果: |
#include #include CCScene * { CCScene * T21Particle * scene->addChild(layer); return } bool { TBack::init(); //雪花效果 CCParticleSnow * //设置位置显示位置 particle->setPosition(ccp(winSize.width //设置时间间隔 particle->setDuration(20); addChild(particle); return } |
执行效果: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdG90b3R1enVvcXVhbg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt=""> |
烟雾效果: |
#include #include CCScene * { CCScene * T21Particle * scene->addChild(layer); return } bool { TBack::init(); //烟雾效果 CCParticleSmoke * //设置位置显示位置 particle->setPosition(ccp(winSize.width //设置时间间隔 particle->setDuration(20); addChild(particle); return } |
执行结果: |
太阳效果 |
#include #include CCScene * { CCScene * T21Particle * scene->addChild(layer); return } bool { TBack::init(); //太阳效果 CCParticleSun * //设置位置显示位置 particle->setPosition(ccp(winSize.width //设置时间间隔 particle->setDuration(20); addChild(particle); return } |
执行效果: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdG90b3R1enVvcXVhbg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt=""> |
下雨效果 |
#include #include CCScene * { CCScene * T21Particle * scene->addChild(layer); return } bool { TBack::init(); //细雨效果 CCParticleRain * //particle->setRotation(90); //设置位置显示位置 particle->setPosition(ccp(winSize.width //设置时间间隔 particle->setDuration(20); addChild(particle); return } |
执行结果: |
7
通过自己定义的.plist文件作出粒子效果
案例:
环形效果 |
#include #include CCScene * { CCScene * T21Particle * scene->addChild(layer); return } bool { TBack::init(); CCParticleSystemQuad * //设置位置显示位置 particle->setPosition(ccp(winSize.width //设置时间间隔 particle->setDuration(20); addChild(particle); return } |
执行结果: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdG90b3R1enVvcXVhbg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt=""> |