core-egret.CapsStyle

egret.CapsStyle 範例


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 shape1 = new egret.Shape;
        // 線條頭尾圓角
        shape1.graphics.lineStyle(20,0,1,null,null,egret.CapsStyle.ROUND);
        shape1.graphics.moveTo(20,20);
        shape1.graphics.lineTo(100,100);
        // 線條頭尾方角
        shape1.graphics.lineStyle(20,0x330000,1,null,null,egret.CapsStyle.SQUARE);
        shape1.graphics.moveTo(20,70);
        shape1.graphics.lineTo(100,150);
        // 線條頭尾無角
        shape1.graphics.lineStyle(20,0x003300,1,null,null,egret.CapsStyle.NONE);
        shape1.graphics.moveTo(20,120);
        shape1.graphics.lineTo(100,200);
        this.addChild(shape1);
    }

}

spacer

沒有留言:

張貼留言