pause_button.gd 516 B

123456789101112131415161718
  1. extends Button
  2. func _ready():
  3. # This ensures that this Node won't be paused, allowing it to
  4. # process even when the SceneTree is paused. Without that it would
  5. # not be able to unpause the game. Note that you can set this through
  6. # the inspector as well.
  7. pause_mode = Node.PAUSE_MODE_PROCESS
  8. func _toggled(button_pressed):
  9. # Pause or unpause the SceneTree based on whether the button is
  10. # toggled on or off.
  11. get_tree().paused = button_pressed
  12. if button_pressed:
  13. text = "Unpause"
  14. else:
  15. text = "Pause"