...
public lbTest:eui.Label;
...
lbTest.textFlow=[
{text:"hello",style:{size:12,textColor:oxffffff}},
{text:"hello",style:{size:16,textColor:oxffff00}}
]
加载:
let dragonebonesData = RES.getRes(<*.json>);
let textureData = RES.getRes(<*_ske.json>);
let texture = RES.getRes(<*.png>);
let factory:dragonBones.EgretFactory = new dragonBones.EgretFactory();
factory.addDragonBonesData(dragonBones.DataParser.parseDragonBonesData(dragonebonesData));
factory.addTextureAtlas(new dragonBones.EgretTextureAtlas(texture , textureData));
var armature:dragonBones.FastArmature = factory.buildFastArmature(armatureName);
armature.enableAnimationCache(30);
...
替换控件,方法为dragonBones.Slot.setDisplay(dispaly:any)
,但是并不是每一次都能成功设置上,display也并不是一直有值,以下提供一种方式参考,并不一定对哈:
private testGroup:eui.Group;//参考点
...
armature.addEventListener(dragonBones.AnimationEvent.START, function(){
egret.setTimeout(function(){
let group = this.testGroup;
let slot: dragonBones.Slot = armature.getSlot("<骨骼名称>");
let cell = new <控件类>();
cell.width =group.width;
cell.height = group.height;
cell.anchorOffsetX = group.width / 2;
cell.anchorOffsetY = group.height / 2;
slot.setDisplay(cell);
},this,200);
},this);
按钮点击事件
private btnTest:eui.Button;
...
btnTest.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onTouch,this);
...
private onTouch(event){
switch(event.target){
case this.btnTest:{
//TODO
}
}
}
控件加入和移除事件:
this.addEventListener(egret.Event.ADDED_TO_STAGE...
this.addEventListener(egret.Event.REMOVED_FROM_STAGE...
定时执行
...
let timer:egret.Timer = new egret.Timer(RETRY_INTERVALS[this._retries], 1);
timer.addEventListener(egret.TimerEvent.TIMER,this.text, this);
timer.start();
...
private test(event){
//TODO
}
class TestLayer eui.Component implements eui.UIComponent{
...
this.skin.currentState = this.skin.states[0].name;
...
}
...
let date = Date.now()
...