OnTimer() enhancement
by Alex Rice · in Torque Game Builder · 10/02/2006 (9:34 pm) · 4 replies
I am adding this to every onTimer callback that I am implementing
function Myt2dSceneObject::onTimer( %this )
{
if( $LevelEditorActive )
{
%this.setTimerOff();
return;
}
// ...
}About the author
#2
The problem is I am calling setTimerOn in onLevelLoaded() then test my level and I click the stop button to return to the level builder, yet my timers keep firing causing a strange game state, various errors, so I have to quit out of TGB.
Seems like a lot of your typical TGB users might run into the same problem. I am just speculating though.
10/03/2006 (10:49 pm)
Thomas, OK that makes sense- I didn't think of extensibility of the level builder.The problem is I am calling setTimerOn in onLevelLoaded() then test my level and I click the stop button to return to the level builder, yet my timers keep firing causing a strange game state, various errors, so I have to quit out of TGB.
Seems like a lot of your typical TGB users might run into the same problem. I am just speculating though.
#3
Also you could do something like this...
10/03/2006 (10:54 pm)
Two additional ways It seems you could do it... onLevelEnded() you could setTimerOff()...Also you could do something like this...
function t2dSceneObject::onTimer(%this)
{
echo("t2dSceneObject::onTimer()");
}
function classOne::onTimer(%this)
{
Parent::onTimer(%this);
}
#4
10/03/2006 (10:57 pm)
OnLevelEnded(). Thanks I didn't realize there was such a callback- I will just use that instead.
Torque Owner Thomas Buscaglia
There is probably an easier way to disable it, though. I assme you're calling setTimerOn in an onAdd callback. If onLevelLoaded won't do it for you, you could just check if you're in the level builder before you call setTimerOn.