序列帧动画

//序列帧动画
let sprite = new cc.Sprite(arr_frame[0]);
this.addChild(sprite);

for(let i = 0;i < arr_frame.length; i++){
ani.addSpriteFrameWithFile(arr_frame[i]);//依次把帧加进去
}
ani.setDelayPerUnit(0.5);//播放帧的间隔
ani.setRestoreOriginalFrame(true);//是否每次播完都会到第一个帧

sprite.runAction(cc.Animate(ani).repeat(times));//借助此sprite来做帧动画

猜你喜欢

转载自www.cnblogs.com/guomengkai/p/12307317.html