Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func update_anim():
- var lastMove = get_last_motion()
- if velocity.x > 0:
- sprite.texture = sprite_run
- sprite.flip_h = true
- anim.play("RUN_LEFT-RIGHT")
- elif velocity.x < 0:
- sprite.texture = sprite_run
- sprite.flip_h = false
- anim.play("RUN_LEFT-RIGHT")
- elif velocity.y > 0:
- sprite.texture = sprite_run
- anim.play("RUN_DOWN")
- elif velocity.y < 0:
- sprite.texture = sprite_run
- anim.play("RUN_UP")
- if velocity.y >= 0 && lastMove.is_equal_approx(Vector2(0, 1)):
- sprite.texture = sprite_idle
- anim.play("IDLE_DOWN")
- elif velocity.y <= 0 && lastMove.is_equal_approx(Vector2(0, -1)):
- sprite.texture = sprite_idle
- anim.play("IDLE_UP")
- elif velocity.x <=0 && lastMove.is_equal_approx(Vector2(-1, 0)):
- sprite.texture = sprite_idle
- sprite.flip_h = true
- anim.play("IDLE_LEFT-RIGHT")
- elif velocity.x >= 0 && lastMove.is_equal_approx(Vector2(1, 0)):
- sprite.texture = sprite_idle
- sprite.flip_h = false
- anim.play("IDLE_LEFT-RIGHT")
- print(lastMove)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement