Game Development Community

Override Quit()?

by Kevin James · in Torque Game Builder · 06/18/2010 (7:56 am) · 1 replies

With the 175 executable, instead of a blank opening screen we get a snapshot of the game when the player quit. I fixed it with an ending splash screen but this only works if the player uses the "quit game" button. If the player X's out the window, my code gets skipped. It still gets to endGame() in game.cs but it bypasses my code to show the ending splash screen:

game.cs -
function endGame()
{
   if (!$gameended){
      glMain.CleanUpQuadrant();
      glMain.showEndScreen();
      glMain.schedule(2000,"endGameNow");
   }
}

glMain -

function GlobalLevel::showEndScreen(%this)
{
   %this.InitMenuInterface();
   %this.clearDesc();
   %this.openAllBoxes(false);
   MainMenu.showMenu(false);
   closeBuildWindow.Visible=false;
   closeResWindow.Visible=false;
   hudWindow.Visible=false;
   mmWindow.Visible=false;
   indyWindow.Visible=false;
  
   endScreen.showMenu(true);
   moveMap.unbind(keyboard, "escape");
}

function GlobalLevel::endGameNow(%this)
{
   sceneWindow2D.endLevel();
   moveMap.pop();
   moveMap.delete();
   $gameended=true;
   quit();//the game hangs without this
}

Is there a way to override Quit or rewrite it?

About the author

Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/


#1
06/18/2010 (2:47 pm)
You could use a package:
package QuitOverride
{
    function Quit()
    {
        // ...
        
        // Actually quit.
        Parent::Quit();
    }
};
ActivatePackage( QuiteOverride );