Menu scene as singleton

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nick888

I have a menu scene with a Control Node and one button (Load game) as a singleton.The button is a child of Control node. The Load Game button sends a signal to the Control node:

extends Control
func _on_Button_pressed():

var fortosi=load("res://World.tscn")
var ins=fortosi.instance()
add_child(ins)
visible= not visible
pass

When i press the button then opens the basic scene of my game (World.tscn), but the problem is that i can see the Load Game button still in the game scene (World.tscn)

Any help please?
Thank you.

You’re adding the World scene to the Menu? And maybe some of your nodes in World have a Z Index < 0. I don’t recommend autoload for a Menu scene, just normal scene changing back and fort. Unless you got a reason for doing so?

Dlean Jeans | 2019-07-01 04:31

Thank you about your reply.

You mean to use this : get_tree().change_scene(res://World.tscn") instead adding the scene?

Nick888 | 2019-07-01 04:42

I assume that you mean to create a menu scene but no as a singleton and also using this:

gettree().changescene(res://World.tscn")

Nick888 | 2019-07-01 04:49

Yes, that’s the one:

get_tree().change_scene("res://World.tscn")

or

get_tree().change_scene_to(load("res://World.tscn"))

Dlean Jeans | 2019-07-01 05:42

Thank you very much!

Nick888 | 2019-07-01 05:52