2019-10-08 02:19:13 +02:00
|
|
|
extends Button
|
|
|
|
|
|
|
|
func _ready():
|
2020-02-02 09:48:07 +01:00
|
|
|
# This ensures that this Node won't be paused, allowing it to
|
|
|
|
# process even when the SceneTree is paused. Without that it would
|
|
|
|
# not be able to unpause the game. Note that you can set this through
|
|
|
|
# the inspector as well.
|
2022-03-26 11:00:50 +01:00
|
|
|
process_mode = Node.PROCESS_MODE_ALWAYS
|
2019-10-08 02:19:13 +02:00
|
|
|
|
|
|
|
|
2022-04-03 07:16:28 +02:00
|
|
|
func _toggled(is_button_pressed):
|
2020-02-02 09:48:07 +01:00
|
|
|
# Pause or unpause the SceneTree based on whether the button is
|
|
|
|
# toggled on or off.
|
2022-04-03 07:16:28 +02:00
|
|
|
get_tree().paused = is_button_pressed
|
|
|
|
if is_button_pressed:
|
2019-10-08 02:19:13 +02:00
|
|
|
text = "Unpause"
|
|
|
|
else:
|
|
|
|
text = "Pause"
|