1、先说雪花特效。去年冬天看过一款游戏,叫部落啥的,它的地图界面一直都有雪花飘来飘去,那时候觉得真TM高端大气上档次,现在我就呵呵了。
演示效果...自己去想象吧。
如果想控制产生场景中雪花的数量,可以使用下面这个接口,下面几个例子也是一样:
2、烟火效果
3、下雨效果
4、烟雾
5、爆炸
6、螺旋
7、流星(用彗星来描述会更贴切一点,因为它拖着一条长长的尾巴)
8、星云
9、太阳( 日 )
10、火焰
1.
ParticleSystem* ps = ParticleSnow::create();
2.
//因为偷懒,我直接用helloWorld里的close 图片当雪花
3.
ps->setTexture(Director::getInstance()->getTextureCache()->addImage("CloseSelected.png"));
4.
ps->setPosition(Point(200,200));//生成的雪花从这个坐标往下落
5.
this->addChild(ps,10);
如果想控制产生场景中雪花的数量,可以使用下面这个接口,下面几个例子也是一样:
1.
static ParticleSnow* createWithTotalParticles(int numberOfParticles);//参数即是雪花的数量
1.
ParticleSystem* ps = ParticleFireworks::create();
2.
ps->setTexture(Director::getInstance()->getTextureCache()->addImage("CloseSelected.png"));
3.
ps->setPosition(Point(200,200));
4.
this->addChild(ps,10);
1.
ParticleSystem* ps = ParticleRain::create();
2.
ps->setTexture(Director::getInstance()->getTextureCache()->addImage("CloseSelected.png"));
3.
ps->setPosition(Point(200,200));
4.
this->addChild(ps,10);
1.
ParticleSystem* ps = ParticleSmoke::create();//效果实在不咋地
2.
ps->setTexture(Director::getInstance()->getTextureCache()->addImage("CloseSelected.png"));
3.
ps->setPosition(Point(200,200));
4.
this->addChild(ps,10);
1.
ParticleSystem* ps = ParticleExplosion::create();
2.
ps->setTexture(Director::getInstance()->getTextureCache()->addImage("CloseSelected.png"));
3.
ps->setPosition(Point(200,200));
4.
this->addChild(ps,10);
1.
ParticleSystem* ps = ParticleSpiral::create();
2.
ps->setTexture(Director::getInstance()->getTextureCache()->addImage("CloseSelected.png"));
3.
ps->setPosition(Point(200,200));
4.
this->addChild(ps,10);
1.
ParticleSystem* ps = ParticleMeteor::create();
2.
ps->setTexture(Director::getInstance()->getTextureCache()->addImage("CloseSelected.png"));
3.
ps->setPosition(Point(200,200));
4.
this->addChild(ps,10);
1.
ParticleSystem* ps = ParticleGalaxy::create();
2.
ps->setTexture(Director::getInstance()->getTextureCache()->addImage("CloseSelected.png"));
3.
ps->setPosition(Point(200,200));
4.
this->addChild(ps,10);
1.
ParticleSystem* ps = ParticleSun::create();
2.
ps->setTexture(Director::getInstance()->getTextureCache()->addImage("CloseSelected.png"));
3.
ps->setPosition(Point(200,200));
4.
this->addChild(ps,10);
1.
ParticleSystem* ps = ParticleFire::create();
2.
ps->setTexture(Director::getInstance()->getTextureCache()->addImage("CloseSelected.png"));
3.
ps->setPosition(Point(200,200));
4.
this->addChild(ps,10);
本文介绍了使用粒子系统实现游戏中的雪花、烟火、下雨、烟雾等特效的方法,并提供了代码示例。涵盖了从创建粒子系统到设置纹理、位置和添加到场景的全过程。
2万+

被折叠的 条评论
为什么被折叠?



