步骤解释可参考http://blog.youkuaiyun.com/agroupofruffian/article/details/77700338,本示例即按照该步骤而来;
主场景皮肤:
单块皮肤
主场景皮肤:
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="aStarWin" width="800" height="600" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Rect width="800" height="600"/>
<e:Rect width="600" height="600" horizontalCenter="0" verticalCenter="0" fillColor="0x53ea09"/>
<e:ToggleButton id="btnSetTag" label="设置障碍" x="700" y="0"/>
<e:ToggleButton id="btnStartPos" label="设置起点" x="700" y="60"/>
<e:ToggleButton id="btnSetEndPos" label="设置终点" x="700" y="120"/>
<e:ToggleButton id="btnFindWay" label="开始寻路" x="700" y="180"/>
<e:ToggleButton id="btnReset" label="重置" x="700" y="240"/>
<e:Group id="blockGroup" width="600" height="600" horizontalCenter="0" verticalCenter="0">
<e:layout>
<e:TileLayout requestedRowCount="10" requestedColumnCount="10" horizontalGap="0" verticalGap="0"/>
</e:layout>
</e:Group>
</e:Skin>
-------------------------------分割线-------------------------------
单块皮肤
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="block" width="60" height="60" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Rect id="rectBG" width="50" height="50" x="5" y="5" fillColor="0x096BE8"/>
<e:Label id="lbX" text="Label" size="15" horizontalCenter="0.5" verticalCenter="-16.5" touchEnabled="false"/>
<e:Label id="lbY" text="Label" size="15" horizontalCenter="0.5" verticalCenter="3.5" touchEnabled="false"/>
<e:Label id="lbCode" text="Label" y="41" size="15" horizontalCenter="0"/>
</e:Skin>
-------------------------------分割线-------------------------------
块类
module ui {
export class Block extends eui.Component {
private rectBG: eui.Rect;
private lbX: eui.Label;
private lbY: eui.Label;
private lbCode: eui.Label;
public data: BlockData = null;
public lastBlcok: ui.Block = null;
constructor(data: ui.BlockData) {
super();
this.data = data;
this.addEventListener(eui.UIEvent.COMPLETE, this.uiComplete, this);
this.addEventListener(egret.Event.ADDED_TO_STAGE, this.addToStage, this);
this.skinName = "resource/ui/block.exml