Game Development Community

Pausing the game.

by AzraelK · in Torque Game Builder · 09/18/2006 (1:27 pm) · 4 replies

Simple question, how can I pause a game in progress while being able to move through a gui menu?

#1
09/19/2006 (4:44 am)
I recently had to do this for a game, where when you collide with an enemy, it pops up a dialog where you deal with it, then the gui goes away, and the game picks up where it left off.

If your game is all running off of the physics engine (giving things velocities and whatnot), then I just call:
$timeScale = 0.0;

If you have trouble with things still firing collision events while your game is paused (this came up for me every now and again), then I just arrange my collision code like so:

function enemyClass::onCollision(%srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts)
{
	if (%dstObj.class $= "playerClass")
	{
		// Turn off collisions to get rid of the wierd gravitational bug.
		%srcObj.setCollisionActiveReceive(false);
		// Schedule to turn collision back on for this object in one second (this will take effect after the game is un-paused, but schedules don't run while the TimeScale is set to 0)
		%srcObj.schedule(1000, "setCollisionActiveReceive", true);

		// Do all of my enemy collision code down here where I display the GUI and whatnot
	}
}

I hope that answered your question!

--clint
#2
09/19/2006 (12:40 pm)
You could also just do [your scenegraph].setScenePause( true ). =)
#3
09/20/2006 (2:07 pm)
Thomas, that method sounds like what Im looking for.. but how do I get my current sceneGraph?
#4
09/20/2006 (2:51 pm)
Scenewindow2d.getSceneGraph() will work unless you've renamed your scenewindow control from default.