Skip to main content
Bold doesn't need to be used for code
Source Link
House
  • 73.3k
  • 17
  • 185
  • 273

That's an OK way to do it. The way I do is that I have a ScreenManagerScreenManager which "loads" screens, those screens are implementing the IScreenIScreen interface and has different methods like LoadContentLoadContent, UnloadContentUnloadContent and InitializeInitialize.

 

For instance, when I press the PLAY button in the main menu, the ScreenManager'sScreenManager's addScreenaddScreen function runs, sets the oldScreenoldScreen variable's value to the newScreen'snewScreen's value(in this example the main menu screen is becoming the oldScreenoldScreen) 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 LoadContentLoadContent sets the ScreenManager'sScreenManager's state to DONE, the ScreenManagerScreenManager is waiting for the user's input (press any key to continue). When it finally gets the input, the ScreenManagerScreenManager intializes the newScreennewScreen and removes the loading graphics.

 

Edit:

In In my ScreenManagerScreenManager, restarting is nothing else but calling the addScreenaddScreen function of my ScreenManagerScreenManager.

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.

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.

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

Source Link
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.