What's the purpose of anims.chain?

The command seems to skip the ‘run’ command.

sprite.anims.play('run').anims.chain('walk');

I’m trying to do three different animations one followed by the other from a single sprite sheet. The above code is inside sprite.once('animationcomplete', ()=>{ }); so I can’t use animationcomplete again because ‘sprite’ already completed the first time. I tried creating a new sprite with a unique name (like sprite2) but it just makes things messy and confusing.

Never-mind. I think I figured it out. The first animation’s repeat is on…

After double checking, all my animations are set to 0 repeat. I still don’t know how this works.

Doesn’t seem to work if there is more than one chain? Paste here

var config = {
    type: Phaser.AUTO,
    parent: 'phaser-example',
    pixelArt: true,
    width: 800,
    height: 600,
    scene: {
        preload: preload,
        create: create
    }
};

var game = new Phaser.Game(config);

function preload ()
{
    this.load.atlas('gems', 'assets/tests/columns/gems.png', 'assets/tests/columns/gems.json');
}

function create ()
{
    this.anims.create({ key: 'diamond', frames: this.anims.generateFrameNames('gems', { prefix: 'diamond_', end: 15, zeroPad: 4 }), repeat: 0 });
    this.anims.create({ key: 'ruby', frames: this.anims.generateFrameNames('gems', { prefix: 'ruby_', end: 6, zeroPad: 4 }), repeat: 2 });
    this.anims.create({ key: 'prism', frames: this.anims.generateFrameNames('gems', { prefix: 'prism_', end: 6, zeroPad: 4 }), repeat: 0 });

    var gem = this.add.sprite(400, 300, 'gems').setScale(4);

    //  Play the diamond animation (which repeats 4 times)
    gem.play('diamond');

    //  When it completes, play the ruby animation
    gem.anims.chain('prism');
    gem.anims.chain('ruby');
}

You can’t chain more than one. Only the last one counts.

Thanks. I found out how to use a custom sequence of frames instead. I knew there had to be a way to do that. https://phaser.io/examples/v3/view/animation/generate-frames