【cocos-js开发】加载帧动画

        var anim = new cc.Animation();
        anim.setDelayPerUnit(0.1);
        for (var i = 8; i <= 57; i++)
        {
            anim.addSpriteFrameWithFile("res/help/bg/cm88y-ak8kr_"+i+".PNG")
        }
        //设置帧动画属性
        //anim.setDelayPerUnit(2.0 / 4);       //每一帧停留的时间
        anim.setRestoreOriginalFrame(true);   //播放完后回到第一帧
        var animate = new cc.Animate(anim);
        var sp = new cc.Sprite();
        sp.setPosition(cc.winSize.width/2,cc.winSize.height/2);
        sp.setScale(2)
        this.addChild(sp);
        sp.runAction(new cc.RepeatForever(animate));

直接通过一系列的png图片来创建帧动画

猜你喜欢

转载自blog.csdn.net/qq_35503380/article/details/85062345