I would like to know how I can add an overlay (loading screen) before calling logic.replace to switch the scene.
Desired order of events:
request from player to load map
add load overlay screen
remove load scene
Despite the fact that I’m calling scene.addScene before doing logic.replace, the overlay is not being added until the scene has loaded. So when I click on a button, the menu screen freezes, the load screen will then show when the new scene has loaded and the load screen finishes at the end of my loading script as desired.
So, everything else is working as desired, I just can’t get the overlay scene to show before doing doing all the loading.
from bge import logicimport Rasterizer scene = logic.getCurrentScene() cont = logic.getCurrentController() def LoadMap(LevelToLoad): logic.globalDict['LevelToLoad'] = LevelToLoad logic.saveGlobalDict() Rasterizer.showMouse(False) scene.replace('LevelPlaceHolder') L_Click = cont.sensors['L_Click'] mouseOver = cont.sensors['mouseOver'] hitObject = mouseOver.hitObject if L_Click.positive and mouseOver.positive: if hitObject.name == "Button_Level_OverGrowth": logic.addScene('Overlay_LevelLoading') LoadMap('Level_OverGrowth') if hitObject.name == "Button_Level_MaglevControl": logic.addScene('Overlay_LevelLoading') LoadMap('Level_MaglevControl') if hitObject.name == "Button_Exit": cont.activate(cont.actuators['ExitGame'])