egret之moveclip 序列帧动画
废话不多说,直接上代码:
private addEffect(name, x: number, y: number, act?: string) { let data = RES.getRes(name + "_json"); let txtr = RES.getRes(name + "_png"); let mcFanctory: egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data, txtr); let mv: egret.MovieClip = new egret.MovieClip(mcFanctory.generateMovieClipData(name)); mv.x = x; mv.y = y; let scale = this.itemImg.width / 234; mv.scaleX = mv.scaleY = scale; this.effectGroup.addChild(mv); mv.play(num); return mv; }
注意,用moveclip 序列帧时,如果美术给你的资源时gif,那你可能会遇到麻烦,所以建议大家使用swf格式的素材。