Skip to main content
1 of 2
Zhafur
  • 169
  • 3
  • 13

That's an OK way to do it. The way I do is that I have a ScreenManager which "loads" screens, those screens are implementing the IScreen interface and has different methods like LoadContent, UnloadContent and Initialize.

For instance, when I press the PLAY button in the main menu, the ScreenManager's addScreen function runs, sets the oldScreen variable's value to the newScreen's value(in this example the main menu screen is becoming the oldScreen) and creates, loads the new screen whilst "Unloading" the previous one. (Note that I am using a loading screen)

The when the unloading is done, and the LoadContent sets the ScreenManager's state to DONE, the ScreenManager is waiting for the user's input (press any key to continue). When it finally gets the input, the ScreenManager intializes the newScreen and removes the loading graphics.

Edit:

In my ScreenManager, restarting is nothing else but calling the addScreen function of my ScreenManager.

Zhafur
  • 169
  • 3
  • 13