Advertisement
thatenbykiki

update_anim func

Apr 13th, 2024
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. func update_anim():
  2.    
  3.     var lastMove = get_last_motion()
  4.    
  5.     if velocity.x > 0:
  6.         sprite.texture = sprite_run
  7.         sprite.flip_h = true
  8.         anim.play("RUN_LEFT-RIGHT")
  9.     elif velocity.x < 0:
  10.         sprite.texture = sprite_run
  11.         sprite.flip_h = false
  12.         anim.play("RUN_LEFT-RIGHT")
  13.     elif velocity.y > 0:
  14.         sprite.texture = sprite_run
  15.         anim.play("RUN_DOWN")
  16.     elif velocity.y < 0:
  17.         sprite.texture = sprite_run
  18.         anim.play("RUN_UP")
  19.    
  20.     if velocity.y >= 0 && lastMove.is_equal_approx(Vector2(0, 1)):
  21.         sprite.texture = sprite_idle
  22.         anim.play("IDLE_DOWN") 
  23.     elif velocity.y <= 0 && lastMove.is_equal_approx(Vector2(0, -1)):
  24.         sprite.texture = sprite_idle
  25.         anim.play("IDLE_UP")   
  26.     elif velocity.x <=0 && lastMove.is_equal_approx(Vector2(-1, 0)):
  27.         sprite.texture = sprite_idle
  28.         sprite.flip_h = true
  29.         anim.play("IDLE_LEFT-RIGHT")   
  30.     elif velocity.x >= 0 && lastMove.is_equal_approx(Vector2(1, 0)):
  31.         sprite.texture = sprite_idle
  32.         sprite.flip_h = false
  33.         anim.play("IDLE_LEFT-RIGHT")   
  34.  
  35.     print(lastMove)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement