3b33
June 29, 2020, 11:40pm
1
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.
3b33
June 29, 2020, 11:43pm
2
Never-mind. I think I figured it out. The first animation’s repeat is on…
3b33
June 29, 2020, 11:58pm
3
After double checking, all my animations are set to 0 repeat. I still don’t know how this works.
3b33
June 30, 2020, 12:38am
4
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');
}
samme
June 30, 2020, 10:20pm
5
You can’t chain more than one. Only the last one counts.
3b33
July 1, 2020, 3:49pm
6
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