给egret loading增加loading动态效果

官方的剧中做的不好,也顺便调整了一下

class LoadingUI extends egret.Sprite implements RES.PromiseTaskReporter {

    private textField: egret.TextField;
    private poolLoadingBar:egret.Shape[]=[];
    private poolId:number=0;

    public constructor() {
        super();
        // this.createView();
        this.once(egret.Event.ADDED_TO_STAGE,this.createView,this);
        this.once(egret.Event.REMOVED_FROM_STAGE,this.onRemoved,this);
    }

    private onRemoved(){
        for(let i=0;i{
                this.poolId++;
                if(this.poolId>this.poolLoadingBar.length-1){
                    this.poolId=0;
                }
                this.loopLoadingBar();
            },this)
            .to({alpha:0},500)
    }


    public onProgress(current: number, total: number): void {
        this.textField.text = `Loading...${current}/${total}`;
    }
}

你可能感兴趣的:(给egret loading增加loading动态效果)