Frames won't play when character jumps


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

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);‘jump’, true);

Any help will be appreciated.


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.


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

1 Like