mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-04 15:00:09 +01:00
This leads to code that is easier to understand and runs faster thanks to GDScript's typed instructions. The untyped declaration warning is now enabled on all projects where type hints were added. All projects currently run without any untyped declration warnings. Dodge the Creeps and Squash the Creeps demos intentionally don't use type hints to match the documentation, where type hints haven't been adopted yet (given its beginner focus).
19 lines
550 B
GDScript
19 lines
550 B
GDScript
extends Button
|
|
|
|
func _ready() -> void:
|
|
# 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.
|
|
process_mode = Node.PROCESS_MODE_ALWAYS
|
|
|
|
|
|
func _toggled(is_button_pressed: bool) -> void:
|
|
# Pause or unpause the SceneTree based on whether the button is
|
|
# toggled on or off.
|
|
get_tree().paused = is_button_pressed
|
|
if is_button_pressed:
|
|
text = "Unpause"
|
|
else:
|
|
text = "Pause"
|