-- Initialise variables obj = 0; pausemenu =0; function onInit(objID) obj = objID; --sky.print("Scene Script Acitve"); sky.print("Key Esc to enter paused state and distplay ingame menu"); -- Press escape to enter ingame menu (displayed in the console). sky.exitEnable(0); -- Disable the system from exiting when escape is pressed gui.workSpace("Mainmenu/"); -- Directory under the projects GUI dir (GUI workspace) pausemenu = gui.load("pausemenu.rml",0,0); -- Load the gui rml file into variable gui.hide(pausemenu,pausemenu); -- Hide this screen for now (if you dont do this it will be shown) end function onKeyDown( key ) -- Function that is called when the Escape key is pushed. if(key == "esc") then sky.setGameState(enum.GS_GamePaused()); -- go into game paused game state end end function PauseMenuButtonEvent(PsBtn) -- Pause menu GUI buttons if (PsBtn == "1") then sky.loadScene("MainMenu"); -- If condition for buttons that pass 1, 2 or 3 argument, then end -- rather load a new scene, continue the game or exit to desctop if (PsBtn == "2") then gui.hide("pausemenu","pausemenu"); -- sky.setGameState(enum.GS_GameMain()); -- You could change this to save, load, continue game, exit to main menu end -- and exit to desktop with ease. if (PsBtn == "3") then sky.exitGame(); end end function onEnter( ) sky.lprint("Main Entered"); end function onEnter_GamePaused( ) -- When you enter the paused game state do this..... sky.lprint("Paused Entered"); -- for debugging gui.show("pausemenu","pausemenu"); -- Show the Gui that is loaded in teh pausemenu variable gui.showCursor(); -- Show the cursor. end function onExit( ) -- exit the main game state sky.lprint("Main Exit"); -- For debugging only end function onExit_GamePaused( ) -- On exiting the paused game state sky.lprint("Exit Paused "); -- For debugging only gui.hide("pausemenu","pausemenu"); -- Hide the GUI gui.hideCursor(); -- Hide the cursor end