九 手游开发神器 cocos2d-x editor 之粒子效果(ParticleEditor)

下雪,烟花,火焰用图片绘制不是很容易,而使用粒子效果则会事半功倍;这一节我要实现小怪物头顶有光环粒子,背景有瀑布粒子

 

先展示效果:

 

 

代码下载地址:http://www.kuaipan.cn/file/id_25348935635744695.htm?source=1

 

 

在Resources新建一个package目录particles,右击新建粒子flower;

 

 

把flower.png也放置在particles目录下面,把图片拖动到黑色区域,小颗粒变成了五角星

 

右边是参数调节面板,根据英语意思应该可以看明白,如果不了解可以百度一下 ParticleEditor,和它的类似,最终我调节成下面的样色

 

同理新建一个pipe粒子,和瀑布有点像,调节参数如下:

 

 

两个粒子都创建好了,现在我们到代码里面使用,打开MainLayer.js,编辑加入下面代码:

 

[javascript]  view plain copy 在CODE上查看代码片 派生到我的代码片
 
  1. var flowerParticle = cc.ParticleSystem.create("Resources/particles/flower.plist");  
  2. flowerParticle.setAnchorPoint(cc.p(0.5, 0.5));  
  3. flowerParticle.setPosition(cc.p(60, 160));  
  4. flowerParticle.setPositionType(1);  
  5. this.monster.addChild(flowerParticle);  
  6.   
  7. var piperParticle = cc.ParticleSystem.create("Resources/particles/pipe.plist");  
  8. piperParticle.setAnchorPoint(cc.p(0.5, 0.5));  
  9. piperParticle.setPosition(cc.p(10, 800));  
  10. piperParticle.setPositionType(1);  
  11. this.rootNode.addChild(piperParticle);  


运行你会看到小怪物头顶一直跟随着星星,背景还有瀑布的效果

 

 

 

 

下一篇文章 我会介绍cocos2d-x  editor的粒子效果       笔者(李元友)

猜你喜欢

转载自makeapp628.iteye.com/blog/2020197
今日推荐