码迷,mamicode.com
首页 > 其他好文 > 详细

egret 添加帧动画

时间:2018-07-28 16:43:19      阅读:629      评论:0      收藏:0      [点我收藏+]

标签:动画   url   break   帧动画   str   get   sse   assets   targe   

private showEffect(): void {
//加载本地的帧动画资源
RES.getResByUrlNoCache("resource/assets/shenqi_eff.json", this.onNameLoadOk, this);
RES.getResByUrlNoCache("resource/assets/shenqi_eff.png", this.onTextLoadOk, this);
}
jsonData;
private onNameLoadOk(data, url): void {
if (data) {
this.jsonData = data;
this.onComplete();
} else {
console.log(`配置加载失败`);
}
}
texture;
private onTextLoadOk(data, url): void {
if (data) {
this.texture = data;
this.onComplete();
} else {
console.log(`图片加载失败`);
}
}
onComplete(){
if(this.texture&&this.jsonData){
var mc1:egret.MovieClip = new egret.MovieClip();
/**方法1 */
let movieClipDatas = new egret.MovieClipData();
let movieClipName;
for (let key in this.jsonData.mc) {
movieClipName = this.jsonData.mc[key];
break;
}
movieClipDatas.$init(movieClipName,this.jsonData.res, this.texture ? new egret.SpriteSheet(this.texture) : null)
mc1.movieClipData = movieClipDatas;
/**方法2 */
// var mcFactory:egret.MovieClipDataFactory = new egret.MovieClipDataFactory( this.jsonData, this.texture );
// var mc1:egret.MovieClip = new egret.MovieClip( mcFactory.generateMovieClipData( "水电费" ) );
this.addChild( mc1 );
mc1.addEventListener(egret.Event.LOOP_COMPLETE, (e:egret.Event)=>{
if(e.target.parent)e.target.parent.removeChild(e.target);
RES.destroyRes("resource/assets/shenqi_eff.json");//去缓存
RES.destroyRes("resource/assets/shenqi_eff.png");
}, this);
mc1.play(3);
this.texture = null;
this.jsonData = null;
}
}

egret 添加帧动画

标签:动画   url   break   帧动画   str   get   sse   assets   targe   

原文地址:https://www.cnblogs.com/jiajunjie/p/9382367.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!