1. 程式人生 > >Egret之粒子系統

Egret之粒子系統

egret 粒子

使用Egret土特產Egret Feather粒子編輯器 。 導出流星粒子特效如下如下:

技術分享

導出2個文件 :

技術分享

一 , 準備工作 :加入粒子模塊 , 粒子系統在第三方庫裏面。所以需要下載第三方庫加入到項目裏面

①:下載第三方庫

技術分享

②:加入到項目(這裏我只是將庫放在與項目平級的目錄裏面,而且我只是取出了)

技術分享

③:在egretProperties.json的配置

技術分享

④:使用egret build -e命令

技術分享


關於粒子核心

module app {
 export class ParticleView extends eui.Component implements eui.UIComponent{
  private particleSys : particle.GravityParticleSystem;
  public constructor() {
   super();
   this.skinName = "resource/eui_skins/ParticleE.exml";
  }
  protected partAdded(partName : string , instance : any):void{
   super.partAdded(partName , instance);
  }
  protected childrenCreated():void{
   super.childrenCreated();
   this.startSyncLoadLizi();
  }
  private startSyncLoadLizi() : void{
   this.syncLoadLizi("plizi_json");
  }
  private syncLoadLizi( resName : string ) : void{
   var self = this;
            RES.getResAsync(resName,
                function(data: any,key: string): void {
                    if(key == "plizi_json") {
                        self.syncLoadLizi("plizi_png");
                    }
                    else if(key == "plizi_png") {
                        this.initParticle();
                    }
                },
                this);
  }
  /**
   * 初始化例子系統
   */
  private initParticle() : void{
   var texture = RES.getRes("plizi_png");
   var config = RES.getRes("plizi_json");
   this.particleSys = new particle.GravityParticleSystem(texture, config);
   this.addChild( this.particleSys );
   this.particleSys.start();
  }
  
 }
}

核心::::

var texture = RES.getRes("plizi_png");
var config = RES.getRes("plizi_json");
this.particleSys = new particle.GravityParticleSystem(texture, config);
this.addChild( this.particleSys );
this.particleSys.start();


效果:

技術分享



Good 。。


本文出自 “Better_Power_Wisdom” 博客,請務必保留此出處http://aonaufly.blog.51cto.com/3554853/1970362

Egret之粒子系統