熱門文章

Ⓔeui.Theme 用法

Main.ts
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/");
        // 注意:皮膚主題是一次性設置的替代值,並不能運行時切換所有組件替換皮膚。切換皮膚您可以自行對Component.skinName賦值進行修改。
        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();
        this.addChild(new edwin.MainUI());
    }

}

沒有留言:

張貼留言