SpineboyInput.cs 844 B

123456789101112131415161718192021222324252627282930313233
  1. using Godot;
  2. using System;
  3. public partial class SpineboyInput : SpineSprite
  4. {
  5. // Called when the node enters the scene tree for the first time.
  6. public override void _Ready()
  7. {
  8. GetAnimationState().SetAnimation("idle", true, 0);
  9. }
  10. // Called every frame. 'delta' is the elapsed time since the previous frame.
  11. public override void _Process(double delta)
  12. {
  13. if (Input.IsActionJustPressed("ui_left"))
  14. {
  15. GetAnimationState().SetAnimation("run", true, 0);
  16. GetSkeleton().SetScaleX(-1);
  17. }
  18. if (Input.IsActionJustReleased("ui_left"))
  19. GetAnimationState().SetAnimation("idle", true, 0);
  20. if (Input.IsActionJustPressed("ui_right"))
  21. {
  22. GetAnimationState().SetAnimation("run", true, 0);
  23. GetSkeleton().SetScaleX(1);
  24. }
  25. if (Input.IsActionJustReleased("ui_right"))
  26. GetAnimationState().SetAnimation("idle", true, 0);
  27. }
  28. }