Scene manager
So now we have a basic scene graph. The only problem is switching between scenes. If we want to switch between the 2D and 3D scene, we need to change a lot of code in our game class. And that's only with two scenes; games tend to have a lot more. It would be a lot simpler to be able to add multiple scenes to our game and just select an active one. It's time we did just that.
The GameScene
If we want to create a scene manager, we first need a class that will represent a scene.
Properties
Let us start by identifying the properties of a scene. A scene should have a name, along with a list of 2D game objects and a list of 3D game objects.
public string SceneName { get; private set; } public List<GameObject2D> SceneObjects2D { get; private set; } public List<GameObject3D> SceneObjects3D { get; private set; }
Constructor
The constructor will have one argument of type string, being the name of the scene. In the body, we will set the name, and create new containers for our game...