且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Egret之粒子系统

更新时间:2022-09-03 22:20:31

使用Egret土特产Egret Feather粒子编辑器 。 导出流星粒子特效如下如下:

Egret之粒子系统

导出2个文件 :

Egret之粒子系统

一 , 准备工作 :加入粒子模块 , 粒子系统在第三方库里面。所以需要下载第三方库加入到项目里面

①:下载第三方库

Egret之粒子系统

②:加入到项目(这里我只是将库放在与项目平级的目录里面,而且我只是取出了)

Egret之粒子系统

③:在egretProperties.json的配置

Egret之粒子系统

④:使用egret build -e命令

Egret之粒子系统


关于粒子核心

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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();


效果:

Egret之粒子系统



Good 。。



















本文转自Aonaufly51CTO博客,原文链接:http://blog.51cto.com/aonaufly/1970362 ,如需转载请自行联系原作者