core-egret.JointStyle

egret.JointStyle 使用範例


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

        let s = new egret.Sprite();
        s.x = s.y = 50;
        // 關節處設置圓角
        s.graphics.lineStyle(30, 0xFF0000, 1, true, null, egret.CapsStyle.NONE, egret.JointStyle.ROUND);
        s.graphics.moveTo(0, 0);
        s.graphics.lineTo(100, 100);
        s.graphics.lineTo(200, 0);
        // 關節處設置斜角
        s.graphics.lineStyle(30, 0x00FF00, 1, true, null, egret.CapsStyle.NONE, egret.JointStyle.BEVEL);
        s.graphics.moveTo(0, 60);
        s.graphics.lineTo(100, 160);
        s.graphics.lineTo(200, 60);
        // 關節處設置尖角
        s.graphics.lineStyle(30, 0x0000FF, 1, true, null, egret.CapsStyle.NONE, egret.JointStyle.MITER);
        s.graphics.moveTo(0, 120);
        s.graphics.lineTo(100, 220);
        s.graphics.lineTo(200, 120);
        this.addChild(s);

    }

}

spacer

沒有留言:

張貼留言