Skip to content

帧动画

帧动画是指通过多张图片的切换来实现动画效果。

详情

typescript
export class FrameAnimScene extends LM.Scene {
    init(){
        // 动画数组
        const imgs = [];
        for(let i = 0; i < 25; i++){
            imgs.push(`graphics/yinghuochong/${i}.png`);
        }
        // 创建动画
        let anim = new LM.FrameAnimation();
        // 设置动画每帧间隔时间,默认是16ms
        anim.interval =  100;
        // 设置动画数组
        anim.setFrame(imgs);
        // 播放动画
        anim.play();
        // 添加到场景
        this.addChild(anim);
    }
}