前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >egret知(填)识(坑)点集

egret知(填)识(坑)点集

作者头像
陨石坠灭
发布2018-10-19 15:18:17
1K0
发布2018-10-19 15:18:17
举报
文章被收录于专栏:全栈之路
1. egret.Label 富文本用法
代码语言:javascript
复制
...
public lbTest:eui.Label;
...

lbTest.textFlow=[
  {text:"hello",style:{size:12,textColor:oxffffff}},
   {text:"hello",style:{size:16,textColor:oxffff00}}
]
2. 骨骼动画

加载:

代码语言:javascript
复制
 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也并不是一直有值,以下提供一种方式参考,并不一定对哈:

代码语言:javascript
复制
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);  
3. 事件

按钮点击事件

代码语言:javascript
复制
private btnTest:eui.Button;
...
btnTest.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onTouch,this);
...
private onTouch(event){
  switch(event.target){
     case this.btnTest:{
        //TODO
      }
  }
}

控件加入和移除事件:

代码语言:javascript
复制
this.addEventListener(egret.Event.ADDED_TO_STAGE...
this.addEventListener(egret.Event.REMOVED_FROM_STAGE...

定时执行

代码语言:javascript
复制
...
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
}
4. 控件状态替换
代码语言:javascript
复制
class TestLayer eui.Component implements  eui.UIComponent{
...
this.skin.currentState = this.skin.states[0].name;
...
}
5.获取时间的方式
代码语言:javascript
复制
...
let date = Date.now()
...
6.http请求

http://edn.egret.com/cn/article/index/id/589

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018/09/02,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1. egret.Label 富文本用法
  • 2. 骨骼动画
  • 3. 事件
  • 4. 控件状态替换
  • 5.获取时间的方式
  • 6.http请求
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档