eui-eui.Direction

eui.Direction 使用範例


class Main extends eui.UILayer {

    protected createChildren(): void {
        super.createChildren();
        egret.lifecycle.onPause = () => egret.ticker.pause();
        egret.lifecycle.onResume = () => egret.ticker.resume();
        egret.registerImplementation('eui.IAssetAdapter', new AssetAdapter());
        egret.registerImplementation('eui.IThemeAdapter', new ThemeAdapter());
        this.runGame();
    }

    private async loadResource() {
        let loadingView = this.stage.addChild(new LoadingUI()) as LoadingUI;
        await RES.loadConfig('resource/default.res.json', 'resource/');
        await new Promise(resolve => new eui.Theme('resource/default.thm.json', this.stage).once(eui.UIEvent.COMPLETE, resolve, this));
        await RES.loadGroup('preload', 0, loadingView);
        this.stage.removeChild(loadingView);
    }

    private async runGame() {
        await this.loadResource();
        // --- Edwin 給你最乾淨的程式碼, 從這行以下開始寫喔 ---

        const pbLTR = new eui.ProgressBar;
        pbLTR.direction = eui.Direction.LTR; // 進度條由左往右長, 一般遊戲讀取條會使用這個方向
        pbLTR.width = 200;
        this.addChild(pbLTR);
        egret.Tween.get(pbLTR).set({ value: 0 }).to({ value: 100 }, 1000);

        const pbRTL = new eui.ProgressBar;
        pbRTL.direction = eui.Direction.RTL; // 進度條由右往左長
        pbRTL.width = 200;
        this.addChild(pbRTL).y = 50;
        egret.Tween.get(pbRTL).set({ value: 0 }).to({ value: 100 }, 1000);

        const pbBTT = new eui.ProgressBar;
        pbBTT.direction = eui.Direction.BTT; // 進度條由下往上長
        pbBTT.height = 200;
        this.addChild(pbBTT).y = 100;
        egret.Tween.get(pbBTT).set({ value: 0 }).to({ value: 100 }, 1000);

        const pbTTB = new eui.ProgressBar;
        pbTTB.direction = eui.Direction.TTB; // 進度條由上往下長
        pbTTB.height = 200;
        this.addChild(pbTTB).y = 350;
        egret.Tween.get(pbTTB).set({ value: 0 }).to({ value: 100 }, 1000);

    }

}

spacer

沒有留言:

張貼留言