fixed a bug where the puase menu couldnt be closed by pressing the pause button again

This commit is contained in:
JHDev2006
2025-09-28 21:52:14 +01:00
parent c0f2044a1e
commit 1711402a6a
4 changed files with 36 additions and 22 deletions

View File

@@ -14,6 +14,8 @@ signal option_2_selected
signal option_3_selected
signal option_4_selected
signal closed
func _process(_delta: float) -> void:
if active:
handle_inputs()
@@ -28,6 +30,8 @@ func handle_inputs() -> void:
selected_index = clamp(selected_index, 0, options.size() - 1)
if Input.is_action_just_pressed("ui_accept"):
option_selected()
elif Input.is_action_just_pressed("pause") or Input.is_action_just_pressed("ui_back"):
close()
func option_selected() -> void:
emit_signal("option_" + str(selected_index + 1) + "_selected")
@@ -51,6 +55,7 @@ func close() -> void:
active = false
selected_index = 0
hide()
closed.emit()
for i in 2:
await get_tree().physics_frame
Global.game_paused = false