Frames won't play when character jumps

#1

I want the dino change frames when he’s jumping, not to use the same frame as when he’s standing.

Github repo Lines 67-72 and 104-107

this.anims.create({
key: ‘jump’,
frames: this.anims.generateFrameNumbers(‘dino’, { start: 5, end: 6 }),
frameRate: 10,
repeat: -1
});

Then in the update function

if (cursors.up.isDown && dino.body.touching.down){
dino.setVelocityY(-330);
dino.anims.play(‘jump’, true);
}

Any help will be appreciated.

#2

The problem seems to be, that you switch between animations every update.
You have play(“stand”) in the update function which is always called.
This overwrites the “jump” animation instantly.

You will have to implement the code in a way that you only call play for one animation each update, so that this animation has a chance to play.

#3

That really helped. Thanks. Also I checked your work. I really liked the bird game.

1 Like