ld-56/components/Menu/menu.gd
2024-10-06 04:22:46 -04:00

41 lines
1 KiB
GDScript

extends Base
@onready var animation_player: AnimationPlayer = $CanvasLayer/MainMenu/AnimationPlayer
@onready var credits: Control = $CanvasLayer/MainMenu/Credits
var menu_state = "start"
func _process(delta: float) -> void:
if menu_state == "start" and Input.is_action_just_pressed("left_click"):
menu_state = "main"
animation_player.play("show_main")
if Input.is_action_just_pressed("escape"):
match menu_state:
"main":
menu_state = "start"
animation_player.play("hide_main")
"credits":
menu_state = "main"
animation_player.play("hide_credits")
credits.hide_credits()
func _on_play_button_clicked() -> void:
if _data:
get_tree().change_scene_to_packed(load(_data.data.metadata.start_scene))
else:
_error("No start scene defined")
func _on_options_button_clicked() -> void:
pass # Replace with function body.
func _on_credits_button_clicked() -> void:
menu_state = "credits"
animation_player.play("show_credits")
credits.show_credits()
func _on_quit_button_clicked() -> void:
get_tree().quit()