I want to make a battle simulator. In a mani menu I will give the user options to adjust armies size, terrain, etc.
Then I want to launch a fight (in a separate battle scene).
So the battle scene have to be heavily modified before it is loaded.
I found two ways to change scenes, and both have problems.
First one is to use something like
However, this way I cannot modify the scene before it is loaded, as it is stored in a file.
Alternatively, I loaded a packed scene and modified it somehow:
PackedScene batllescene_packed = (PackedScene)GD.Load("res://BattleScene.tscn");
battle_scene = (BattleScene)batllescene_packed.Instance();
//modify the scene somehow
Now I have to switch the scenes; I do it with
However, when I do it, the menu scene is still visible underneath the new one!
I guess I have to unload it, but when I do it, the program exits. I tried to unload the menu in two ways:
And, more complicated:
MainMenu main_menu = (MainMenu)GetTree().Root.GetNode("MainMenu");
I have been stuck on this problem for hours; what is the correct way to solve this? Much thx.