extends VBoxContainer @onready var fps_label: Label = $FPS_Label func _ready() -> void: toggle_hud() # This should hide the HUD by default fps_label.reparent.call_deferred(get_parent()) func _process(_delta: float) -> void: if Input.is_action_just_pressed("ui_cancel"): toggle_hud() fps_label.text = "FPS: %d" % Engine.get_frames_per_second() func toggle_hud() -> void: var should_show = Input.mouse_mode == Input.MOUSE_MODE_CAPTURED if should_show: Input.mouse_mode = Input.MOUSE_MODE_VISIBLE show() else: Input.mouse_mode = Input.MOUSE_MODE_CAPTURED hide() func _on_menu_button_pressed() -> void: var err = get_tree().change_scene_to_file("res://menu.tscn") if err != OK: print("Failed to switch scenes: ", error_string(err))