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;
}
}
相关文章
- 02-28用SWF来代替传统的帧动画
- 02-28通过添加名字产生动画效果
- 02-28是否可以在Android消息中添加动画表情符号
- 02-28Android学习笔记 之逐帧动画
- 02-28让蔡徐坤来教你实现游戏中的帧动画(中)
- 02-28JQuery插件 aos.js-添加动画效果
- 02-28WPF 添加提示动画
- 02-28Android动画之帧动画,74道高级Android面试合集
- 02-28博客园给文章标题添加下划线动画
- 02-28Andriod动画效果总结以及帧动画实现