欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Animation

程序员文章站 2024-01-19 13:46:58
...
    //精灵帧动画
    cc.spriteFrameCache.addSpriteFrames(res.Sushi_plist, res.Sushi_png);
    var size = cc.winSize;

    var sprite = new cc.Sprite("#sushi_1n_0.png");
    sprite.x = size.width / 2;
    sprite.y = size.height / 2;
    this.addChild(sprite);

    var spriteFrames = [];
    for (var i = 0; i < 10; i++){
        var frames = cc.spriteFrameCache.getSpriteFrame("sushi_1n_" + i + ".png");
        spriteFrames.push(frames);
    }
    cc.log(spriteFrames);
    var animation1 = new cc.Animation.create(spriteFrames, 0.1, 10);
    var action = cc.animate(animation1);
    sprite.runAction(action);