九 手遊開發神器 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,編輯加入下面代碼:

    var flowerParticle = cc.ParticleSystem.create("Resources/particles/flower.plist");
    flowerParticle.setAnchorPoint(cc.p(0.5, 0.5));
    flowerParticle.setPosition(cc.p(60, 160));
    flowerParticle.setPositionType(1);
    this.monster.addChild(flowerParticle);

    var piperParticle = cc.ParticleSystem.create("Resources/particles/pipe.plist");
    piperParticle.setAnchorPoint(cc.p(0.5, 0.5));
    piperParticle.setPosition(cc.p(10, 800));
    piperParticle.setPositionType(1);
    this.rootNode.addChild(piperParticle);

運行你會看到小怪物頭頂一直跟隨着星星,背景還有瀑布的效果



下一篇文章 我會介紹cocos2d-x  editor的粒子效果       筆者(李元友)

資料來源:cocos2d-x  editor


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章