animation-player.gd 887 B

123456789101112131415161718192021222324252627282930313233
  1. extends Node2D
  2. @onready var player = $AnimationPlayer
  3. @onready var spineboy = $Spineboy
  4. var speed = 400;
  5. var velocity_x = 0;
  6. func _ready():
  7. player.play("cutscene")
  8. pass
  9. func _process(delta):
  10. if (!player.is_playing()):
  11. if Input.is_action_just_released("ui_left"):
  12. spineboy.get_animation_state().set_animation("idle", true, 0)
  13. velocity_x = 0
  14. if Input.is_action_just_released("ui_right"):
  15. spineboy.get_animation_state().set_animation("idle", true, 0)
  16. velocity_x = 0
  17. if (Input.is_action_just_pressed("ui_right")):
  18. spineboy.get_animation_state().set_animation("run", true, 0)
  19. spineboy.get_skeleton().set_scale_x(1)
  20. velocity_x = 1
  21. if Input.is_action_just_pressed("ui_left"):
  22. spineboy.get_animation_state().set_animation("run", true, 0)
  23. spineboy.get_skeleton().set_scale_x(-1)
  24. velocity_x = -1
  25. spineboy.position.x += velocity_x * speed * delta