+4 votes

I have a program that has 10 scenes (grids) that are preloaded. I have code that changes scenes when a button is pressed. The code works and I am able to draw on what ever grid I want. The problem comes from the fact that the code, change scene(), seems to free the previous scene. For example, if I draw on the first grid, change to the second grid, then change back to the first, everything will be gone. I have been looking at ways to switch to multiple grids, but it has yet to work. I have found something called reload scene from path(), and save scene(). This is the link to where I have found it.

http://docs.godotengine.org/en/3.0/classes/class_editorinterface.html?highlight=reload%20scene#class-editorinterface-reload-scene-from-path

My question is, will any of those methods work? All I need to do is have the scene not be freed when I change the scene. I appreciate any help.

in Engine by (20 points)

1 Answer

+1 vote

While I'm actually have the opposite problem, queue_free is *supposed* to dump the previously loaded scene.

What you want is to merge your scenes together into one bigger tree.

I suggest create another scene (the trunk!), and which loads your other 10 into itself. You can do this in the Scene panel in Godot, or you can load it with script code with

onready var scene_loader = preload("res://OneOfYourTenScenes.tscn")

var s = sceneloader.instance()
add
child(s)

if you are running a Node2D setup, you can shuffle the z_index to flip the one you want to the front.
If you are running a Spacial setup, I would just move the camera to the one you want to work with.

by (325 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.