mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-04 23:10:08 +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).
26 lines
769 B
GDScript
26 lines
769 B
GDScript
class_name Game
|
|
extends Node
|
|
|
|
|
|
@onready var _pause_menu := $InterfaceLayer/PauseMenu as PauseMenu
|
|
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
if event.is_action_pressed(&"toggle_fullscreen"):
|
|
var mode := DisplayServer.window_get_mode()
|
|
if mode == DisplayServer.WINDOW_MODE_FULLSCREEN or \
|
|
mode == DisplayServer.WINDOW_MODE_EXCLUSIVE_FULLSCREEN:
|
|
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
|
|
else:
|
|
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
|
get_tree().root.set_input_as_handled()
|
|
|
|
elif event.is_action_pressed(&"toggle_pause"):
|
|
var tree := get_tree()
|
|
tree.paused = not tree.paused
|
|
if tree.paused:
|
|
_pause_menu.open()
|
|
else:
|
|
_pause_menu.close()
|
|
get_tree().root.set_input_as_handled()
|