Different actor images for idle and walk

I've read other similiar threads,followed the answers and made this.
It works as it intended to be,but it has bugs,such as keeping the walking image when bumping into a wall/object.
If anyone knows,how can this be done better?
What are you trying to accomplish? Would a custom walk sprite sheet do this for you?
Why are you doing all the checks for what button is pressed? What happens if the player is moving because of a move route in a cutscene and not because the player is pressing any buttons?

Unless you want to use a different spritesheet for different directions, you have 2 options - the player is moving, or they're not. So have your isMoving test, and give it an Else branch, so you can say what to do if they're NOT moving.

You will also find this will probably cause your game to lag the way you have it, as it's going to change the player image every single frame - 60 times a second - because you're not checking what the last status was before changing the image.

I suggest you also allocate a switch to represent "walking sprite". Then do something like this:
Code:
If player is moving
  If Walking Sprite switch is OFF
    Change player sprite to walking sprite
    Turn on Walking Sprite switch
  End
Else
  If Walking Sprite switch is ON
    Change player sprite to idle sprite
    Turn off Walking Sprite switch
  End
End

This means it will only change the player sprite when you start walking or stop walking, not the entire time you're walking or are idle.

In the database, set the player sprite to the idle sprite. When you start your game, the player will not be walking, the switch will be off, and the idle sprite will be used.
Why are you doing all the checks for what button is pressed? What happens if the player is moving because of a move route in a cutscene and not because the player is pressing any buttons?

Unless you want to use a different spritesheet for different directions, you have 2 options - the player is moving, or they're not. So have your isMoving test, and give it an Else branch, so you can say what to do if they're NOT moving.

You will also find this will probably cause your game to lag the way you have it, as it's going to change the player image every single frame - 60 times a second - because you're not checking what the last status was before changing the image.

I suggest you also allocate a switch to represent "walking sprite". Then do something like this:
Code:
If player is moving
  If Walking Sprite switch is OFF
    Change player sprite to walking sprite
    Turn on Walking Sprite switch
  End
Else
  If Walking Sprite switch is ON
    Change player sprite to idle sprite
    Turn off Walking Sprite switch
  End
End

This means it will only change the player sprite when you start walking or stop walking, not the entire time you're walking or are idle.

In the database, set the player sprite to the idle sprite. When you start your game, the player will not be walking, the switch will be off, and the idle sprite will be used.
Thanks!

Original thread: https://forums.rpgmakerweb.com/threads/different-actor-images-for-idle-and-walk.143986/