Cocos2dx 小技巧(九)现成的粒子特效

代码在cocos2dx 3.1.1 c++项目测试过,使用正常.

下面上个图吧,各种效果都集成在里面了.

包含 雪花 烟火 下雨 烟雾  螺旋 流星  星云  太阳  火焰

哈哈哈...因为效果太多,,,所以,,,简直是群魔乱舞,不看入目!!



以下转自http://blog.csdn.net/star530/article/details/23552641

___________________________

这篇讲的是粒子,其实我对粒子这一块没什么研究,因为当初刚开始接粗cocos2dx时,总经理和我说粒子这块可以暂时不去了解,因为还用不到。他的这话也导致我很长时间都有意无意的去避开粒子这一块知识。所以说啊,我也是个菜鸟啊,还有很多东西不懂。虽然博客写的还比较多,但水平也就尔尔吧,有的人叫我大神,大侠啥的,请千万别“诅咒”我啊~~~。因为知识从懵懂到理解的过程是痛苦而又快乐的,每次一学到一个新的知识点后我就想赶紧分享到博客上来,一方面是可以加深自己对该知识点的理解,另一方面我也想让更多人知道这个知识点,少走些弯路...

如果你觉得我要讲解粒子的原理啥的,那就大错特错了。毕竟技巧性的文章讲究的就是短小但是可以旋转嘛。我就直接将一些可以用的现成粒子特效拉出来扯扯虎皮。下面开始扯:
1、先说雪花特效。去年冬天看过一款游戏,叫部落啥的,它的地图界面一直都有雪花飘来飘去,那时候觉得真TM高端大气上档次,现在我就呵呵了。

[cpp]  view plain copy 在CODE上查看代码片 派生到我的代码片
  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);  
演示效果...自己去想象吧。
如果想控制产生场景中雪花的数量,可以使用下面这个接口,下面几个例子也是一样:
[cpp]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. static ParticleSnow* createWithTotalParticles(int numberOfParticles);//参数即是雪花的数量<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"> </span>  
2、烟火效果
[cpp]  view plain copy 在CODE上查看代码片 派生到我的代码片
  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);  
3、下雨效果
[cpp]  view plain copy 在CODE上查看代码片 派生到我的代码片
  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);  
4、烟雾
[cpp]  view plain copy 在CODE上查看代码片 派生到我的代码片
  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);  
5、爆炸
[cpp]  view plain copy 在CODE上查看代码片 派生到我的代码片
  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);  
6、螺旋
[cpp]  view plain copy 在CODE上查看代码片 派生到我的代码片
  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);  
7、流星(用彗星来描述会更贴切一点,因为它拖着一条长长的尾巴)
[cpp]  view plain copy 在CODE上查看代码片 派生到我的代码片
  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);  
8、星云
[cpp]  view plain copy 在CODE上查看代码片 派生到我的代码片
  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);  
9、太阳( 日 )
[cpp]  view plain copy 在CODE上查看代码片 派生到我的代码片
  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);  
10、火焰
[cpp]  view plain copy 在CODE上查看代码片 派生到我的代码片
  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);  

哈哈,写完了。多久没写过这种复制粘贴的博客了。嘿嘿。

尊重原创,转载请注明来源:http://blog.csdn.net/star530/article/details/23552641

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值