Game Development Community

Saving Timers

by Stephen Triche · in Torque Game Builder · 07/12/2006 (1:05 pm) · 1 replies

I have an event that happens ever level at a regular time and am using setTimerOn() and onTimer() for this.

However, when the player pauses the game I do not want the event to continue and setScenePause(), apparently, does not stop these timer actions. At the moment what I am doing is adding a setTimerOff() and setTimerOn() to a pause/unpause function to start and stop these events when the player pauses the game.

Of course, there's the issue that the player can now postpone the timer event indefinitely by continuing to pause and unpause, since the timer isn't saved between On()s and Off()s. Is there a way to store this information, or, a better way in general to pause timer events?

#1
07/12/2006 (2:17 pm)
Do [scenegraph].getSceneTime() when you setTimerOn and store the scene time in a variable. When the player pauses do setTimerOff. When the player unpauses get the scene time again and do:

%timeElapsed = %newSceneTime - %this.firstSceneTime;
%thing.setTimerOn(%fullTimerTime - %timeElapsed);

That should do the trick.