Added a sound effect when a menu option is hovered
This commit is contained in:
@@ -2,6 +2,9 @@ extends CanvasLayer
|
||||
|
||||
@onready var pause_menu = $Control
|
||||
|
||||
func _ready() -> void:
|
||||
_register_focus_sounds()
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
if get_tree().paused:
|
||||
@@ -22,3 +25,21 @@ func _on_quit_button_pressed():
|
||||
|
||||
func _on_continue_button_pressed():
|
||||
resume_game()
|
||||
|
||||
func _register_focus_sounds() -> void:
|
||||
if pause_menu == null:
|
||||
return
|
||||
var vbox := pause_menu.get_node_or_null("VBoxContainer")
|
||||
if vbox == null:
|
||||
return
|
||||
for child in vbox.get_children():
|
||||
if child is BaseButton:
|
||||
var button: BaseButton = child
|
||||
if not button.is_connected("focus_entered", Callable(self, "_on_menu_item_focus")):
|
||||
button.focus_entered.connect(_on_menu_item_focus)
|
||||
if not button.is_connected("mouse_entered", Callable(self, "_on_menu_item_focus")):
|
||||
button.mouse_entered.connect(_on_menu_item_focus)
|
||||
|
||||
func _on_menu_item_focus() -> void:
|
||||
if MenuSfx:
|
||||
MenuSfx.play_hover()
|
||||
|
||||
Reference in New Issue
Block a user