At 5/1/13 12:00 PM, PSvils wrote:
The GenericScreen has functions initScreen(), loadScreen(), unloadScreen(), disposeScreen(). initScreen() gets called as soon as it's added to the stage, loadScreen() is called when the transition is finished, then unload screen is called as the next screen's initScreen() is being called, and dispose when the out-transition is finished.
I did something like this for the C++ closure engine... hell I even called them "screens". If I do another C++ game engine again (I will) I'm calling them GameState or State instead, cause it makes a bit more sense
the base screen class had the following functions
preload (preload was never used)
a main manager class kept track of all the screens, you would tell the manager class to swap to a new screen and it would take care of calling unload and kill (with some safety stuff there so it couldn't unload or kill a screen that was never initiated or loaded)
the manager also kept track of 2 special screen types, the pause screen, and the transition screen
if the game was paused, the manager would stop calling update on the main screen and instead call update on the pause screen, it would then call render on the main screen, then render on the pause screen (so its overlayed on top of the game)
if the transition screen was active, the game would update and render both the main screen and the transition screen, the transition screen reports back when there's an appropriate frame to make the internal transition (main screen gets swapped). We were gonna play around with fancier transition animations, but ran out of time, so this was just used for a quick fade to black and back.