if you change your scenes with change_scene
methods then you can't save previous scene easily. But you can implement your own scene switching algorithm:
1. Make Main
node that will act as scenes container.
2. Load your scene using load
, instance
and add_child
methods to Main
node.
3. When next scene is required, you can remove your scene from Main
node using remove_child
method and then repeat step 2 to get new scene going. This way you still have reference to previous room and can do anything you want with it. But always remember to queue_free
nodes when you don't need them anymore, otherwise, if you lose reference to it, it will result into memory leak.
Note that this is just one of the many ways of implementing scene switching algorithms and optimal solution depends on your game.
Loading rooms into Singleton class (autoloading variable) can be very bad solution. I suggest you to avoid this approach.