//
第一种:系统封装好提供的
11
种粒子系统
不需要导入头文件
- ParticleExplosion 爆炸粒子
- ParticleFire 火焰粒子
- ParticleFireworks 烟花粒子
- ParticleFlower 花束粒子
- ParticleGalaxy 星系粒子
- ParticleMeteor 流星粒子
- ParticleRain 下雨粒子
- ParticleSmoke 烟雾粒子
- ParticleSnow 雪花粒子
- ParticleSpiral 漩涡粒子
- ParticleSun 太阳粒子
auto
snowParticle =
ParticleSnow
::
create
();
snowParticle-> setPosition ( Vec2 (visibleSize. width / 2 , visibleSize. height / 2 ));
// Director::getInstance()->getTextureCache()
snowParticle-> setTexture ( Director :: getInstance ()-> getTextureCache ()-> addImage ( "snow.png" ));
snowParticle-> setPosition ( Vec2 (visibleSize. width / 2 , visibleSize. height / 2 ));
// Director::getInstance()->getTextureCache()
snowParticle-> setTexture ( Director :: getInstance ()-> getTextureCache ()-> addImage ( "snow.png" ));
addChild(snowParticle);
//
第二种:自定义粒子,可以在系统封装好提供的
11
种粒子系统基础上修改相关参数
参考CCParticleSystem.h CCParticleSystem.cpp
粒子发射器的发射方式有两种:重力型模式,辐射型(半径型)模式
重力型模式:有方向,径向加速度,切向加速度。 每个粒子都受到一个方向上的力,比如雨雪粒子
辐射型(半径型)模式:每个粒子都受到一个点的力,粒子在不同的位置会有不同方向力的作用,比如旋转粒子
//
第三种:粒子编辑器
OSX系统:71squared公司开发的particledesigner
https://71squared.com/particledesigner
Glyph Designer Particle Designer
save as输入名字—File Format 选择cocos2d(plist) 勾选Embed texture就没有图片 不勾选就有图片
embed in:嵌入
WIN系统:Warren使用QT专门为cocos2d使用的粒子编辑器 cocos2d particle Builder
//
创建粒子
auto myparticle = ParticleSystemQuad :: create ( "myparticle.plist" );
myparticle-> setPosition ( Vec2 (visibleSize. width / 2 , visibleSize. height / 2 ));
// 注意:纹理图片用粒子编辑器产生的,也可以用自定义的图片
myparticle-> setTexture ( Director :: getInstance ()-> getTextureCache ()-> addImage ( "myparticle.png" ));
auto myparticle = ParticleSystemQuad :: create ( "myparticle.plist" );
myparticle-> setPosition ( Vec2 (visibleSize. width / 2 , visibleSize. height / 2 ));
// 注意:纹理图片用粒子编辑器产生的,也可以用自定义的图片
myparticle-> setTexture ( Director :: getInstance ()-> getTextureCache ()-> addImage ( "myparticle.png" ));
addChild(myparticle);