GodotCourse/week6/example/UIDemo/scripts/uicontrols.gd

30 lines
1.1 KiB
GDScript3
Raw Permalink Normal View History

2024-08-12 21:45:20 +00:00
extends CenterContainer
@onready var new_game_button = $PanelContainer/VBoxContainer/NewGameButton as Button
@onready var continue_button = $PanelContainer/VBoxContainer/ContinueButton as Button
@onready var settings_button = $PanelContainer/VBoxContainer/SettingsButton as Button
@onready var quit_button = $PanelContainer/VBoxContainer/QuitButton as Button
@onready var animated_sprite_2d = $PanelContainer/VBoxContainer/Control/Node2D/AnimatedSprite2D
# Called when the node enters the scene tree for the first time.
func _ready():
new_game_button.button_down.connect(on_button_down)
new_game_button.mouse_entered.connect(on_button_entered)
new_game_button.mouse_exited.connect(on_button_exited)
continue_button.button_down.connect(on_button_down)
settings_button.button_down.connect(on_button_down)
quit_button.button_down.connect(on_exit_pressed)
func on_button_down():
print("button pressed down ")
func on_button_entered():
animated_sprite_2d.play("run")
func on_button_exited():
animated_sprite_2d.play("idle")
func on_exit_pressed():
print("attempting to quit game")
get_tree().quit()