Game Development Community

endGame() not working [SOLVED]

by Andrew H · in Torque Game Builder · 09/28/2011 (10:46 am) · 2 replies

I'm using an exit button to call the endGame() function, but it doesn't end the game. It just closes the level, leaving the window and GUI open. Why is this happening? Here's the code for the exit button:

new GuiBitmapButtonCtrl(exitButton) {
      canSaveDynamicFields = "0";
      isContainer = "0";
      Profile = "GuiDefaultProfile";
      HorizSizing = "right";
      VertSizing = "bottom";
      Position = "320 339";
      Extent = "104 39";
      MinExtent = "8 2";
      canSave = "1";
      Visible = "1";
      Command = "endGame();";
      hovertime = "1000";
      groupNum = "-1";
      buttonType = "PushButton";
      useMouseEvents = "0";
      bitmap = "~/data/images/Main Menu/exitButton/exitButton";
   };

And here's the endGame() function (it's found by default in game.cs under game/gameScripts, but here it is anyway):

function endGame()
{
   sceneWindow2D.endLevel();
   moveMap.pop();
   moveMap.delete();
}

#1
09/28/2011 (10:54 am)
That's what endGame does, it ends the game that is in progress so that then you could go back to your main menu or whatever else you'd like to go to from there. If you are wanting the button to shut everything down and exit to the desktop then quit() is the function you want.
#2
09/28/2011 (12:40 pm)
Oh. *laughs* Okay - shows you how much I know.