core-egret.DropShadowFilter

egret.DropShadowFilter 陰影濾鏡範例


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 給你最乾淨的程式碼, 從這行以下開始寫喔 ---

        // 繪製 100x100 紅色區塊, 並套上陰影濾鏡
        const s = new egret.Shape;
        s.graphics.beginFill(0xFF0000);
        s.graphics.drawRect(0, 0, 100, 100);
        s.graphics.endFill();
        s.x = 50;
        s.y = 50;
        s.filters = [new egret.DropShadowFilter(0, 0, 0x330000, 1, 50, 50)]
        this.addChild(s);
    }

}

spacer

沒有留言:

張貼留言