熱門文章
Ⓔeui.Watcher 用法
監視場景開關
MainUI.ts
MainUI.ts
namespace edwin {
export class MainUI extends eui.Component {
protected createChildren(): void {
super.createChildren();
this.percentWidth = this.percentHeight = 100;
eui.Watcher.watch(this, ['visible'], (e) => this.do(e), this);
this.visible = false; // 停止遊戲動畫
this.visible = true; // 播放遊戲動畫
}
private do(visible: boolean): void {
if (visible) {
console.log('播放遊戲動畫');
} else {
console.log('停止遊戲動畫');
}
}
}
}
Ⓔeui.UILayer 用法
UILayer 跟普通容器一樣,允許創建多個實例,但通常都將它作為 UI 顯示列表的根節點使用. Main.ts 的 Main 類別就是 eui.UILayer. 特色是寬高會跟隨 stage.stageWidth 跟 stage.stageHeight
Ⓔeui.UIEvent 用法
Panel UIEvent 註冊
MainUISkin.exml
MainUISkin.exml
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="edwin.MainUISkin" xmlns:e="http://ns.egret.com/eui">
<e:Rect fillColor="0x000000" width="100%" height="100%" />
<e:Group horizontalCenter="0" verticalCenter="0">
<e:Panel id="panel" title="test" />
</e:Group>
</e:Skin>
MainUI.tsnamespace edwin {
export class MainUI extends eui.Component {
private panel: eui.Panel;
protected createChildren(): void {
super.createChildren();
this.percentWidth = this.percentHeight = 100;
this.panel.addEventListener(eui.UIEvent.CLOSING, this.onUIEventHandler, this);
this.panel.addEventListener(eui.UIEvent.MOVE, this.onUIEventHandler, this);
}
private onUIEventHandler(e: eui.UIEvent): void {
egret.log("eui.UIEvent:", e.type);
}
}
}
訂閱:
意見 (Atom)