cocos2d-js创建帧动画

 //方式一,通过多张图片来创建
        this.dragon = new cc.Sprite("res/player_animation/action1.png");
        this.dragon.setPosition(cc.p(cc.winSize.width*0.3, cc.winSize.height/2));
        this.addChild(this.dragon);

        //创建帧动画序列,名词形式
        var animation = new cc.Animation();
        for (var i = 1; i <= 4; i++)
        {
            animation.addSpriteFrameWithFile("res/player_animation/action"+ i +".png");
        }
        //设置帧动画属性
        animation.setDelayPerUnit(2.0 / 4);       //每一帧停留的时间
        animation.setRestoreOriginalFrame(true);   //播放完后回到第一帧
        var animate = new cc.Animate(animation);
        this.dragon.runAction(new cc.RepeatForever(animate));

你可能感兴趣的:(cocos2d-js创建帧动画)