Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | noodlelou |
Hello, I have been creating a “Scene Switcher” recently, which works for the most part. Everything in the code works, however in the new instanced scene I can’t click on any options in the pause menu, but I can open and close the menu with the key I’ve mapped to it. I also have a checkbox in the new scene which I can’t click as well. I’m very close to having this work, but the scene is essentially frozen. Not sure what to fix, any help would be greatly appreciated. Here’s the code:
change_scene (autoloaded scene):
func change_scene(node, delay = 0.5):
var pause_menu = preload("res://Scenes//PauseMenu.tscn").instance()
var n = ResourceLoader.load(node)
get_tree().create_timer(delay)
animation_player.play("fade")
yield(animation_player, "animation_finished")
get_tree().get_root().get_node("Main").queue_free()
var new_scene = n.instance()
get_tree().get_root().add_child(new_scene)
#get_tree().set_current_scene(new_scene)
animation_player.play_backwards("fade")
yield(animation_player, "animation_finished")
get_tree().get_root().add_child(pause_menu)
emit_signal("scene_changed")
The PauseMenu (separate scene):
func _ready():
$VBoxContainer/Map.grab_focus()
func _physics_process(delta):
if $VBoxContainer/Map.is_hovered() == true:
$VBoxContainer/Map.grab_focus()
if $VBoxContainer/Options.is_hovered() == true:
$VBoxContainer/Options.grab_focus()
if $VBoxContainer/Quit.is_hovered() == true:
$VBoxContainer/Quit.grab_focus()
func _input(event):
if event.is_action_pressed("PauseMenu"):
$VBoxContainer/Map.grab_focus()
get_tree().paused = not get_tree().paused
visible = not visible
func _on_Resume_pressed():
get_tree().paused = not get_tree().paused
visible = not visible
func _on_Quit_pressed():
get_tree().quit()