Godot Version
<Godot version 4.2.2>
Question
I’m trying to setup a toggle function that will show my pause menu and pause the game and when the InputEvent is pressed again it will hide and resume the game.
Currently everything but the hide menu and resume game function is working. I can’t seem to wrap my head around why.
pause_menu.gd script:
“”"
“”"
func _on_game_manager_toggle_game_paused(is_paused: bool):
if (is_paused):
show()
else:
“currently not hiding the menu and resuming game”
hide()
“”"
“”"
func _on_resume_pressed():
game_manager.paused_menu = false
“”"
“”"
func _on_quit_pressed():
get_tree().paused = false # Ensure the game is not paused when transitioning to the main menu
get_tree().change_scene(“res://Scenes/Menus/StartScreen/start.tscn”)
menu_manager.gd script:
class_name GameManager
signal toggle_pause_menu(is_paused : bool)
“”"
“”"
var paused_menu: bool = false:
get:
return paused_menu
set(value):
paused_menu = value
get_tree().paused = paused_menu
emit_signal(“toggle_pause_menu”, paused_menu)
“”"
“”"
func _input(event : InputEvent):
if event.is_action_pressed(“pause”):
paused_menu = !paused_menu
“”"
“”"
func resume_game():
get_tree().paused = false
emit_signal(“toggle_pause_menu”, paused_menu)