Animation onDown auto update

Hi,

Hope someone can help

if I try to do a key press my animation stops until I let go of the key. (keys a and d) to move left and right - is there a way for the key press .onDown to be used once or an alterantive way to have my animation play when the key is held down, I’ve tried using the docs but can’t seem to find a solution

eg demo below

http://html5gamer.mobi/2019/

code snippet when pressing d

if (this.keyRight.isDown){

                   this.player.anims.play('walkProper');

this.player.flipX = false;

this.player.setVelocityX(150);

}

Thanks in advance

Eric

There’s a second parameter for that call ignoreIfPlaying. There’s also a shortcut for play on Sprite. So you can just do this.player.play('walkProper', true).
There are also events for key up/down though, if you want to implement it that way.

2 Likes

thank you so much ! your help is greatly appreciated

Eric