Schedule Problems
by Richard Pettyjohn · in Torque Game Builder · 06/16/2007 (8:07 pm) · 7 replies
I have I function I want to happen over and over.
I set it up like this:
Basically, I wan't more and more guards to spawn.
Unfortunately, it doesn't work. What am I doing wrong?
I set it up like this:
function enemyGuardSpawner::spawnEnemyGuard(%this)
{
%this.enemyGuard = new t2dStaticSprite()
{
scenegraph = %this.scenegraph;
layer = %this.layer+1;
class = enemyGuard;
};
%this.enemyGuard.fire();
schedule(100, 0, "%this.spawnEnemyGuard");
}Basically, I wan't more and more guards to spawn.
Unfortunately, it doesn't work. What am I doing wrong?
About the author
#2
The time is in milliseconds, not seconds.
06/16/2007 (11:47 pm)
Keep in mind that once you start that schedule, you will get an enemy guard every 10th of a second, unending.The time is in milliseconds, not seconds.
#3
06/17/2007 (10:45 am)
Or you may use a simSet to have a specific guards number...
#4
06/17/2007 (11:15 am)
Thanks for the help.
#5
06/17/2007 (11:07 pm)
Quote:Keep in mind that once you start that schedule, you will get an enemy guard every 10th of a second, unending.I can't agree with it. You should call schedule() again and again to get the next time callback (inside 'spawnEnemyGuard' for example).
#6
Greg
06/18/2007 (5:25 pm)
Igor is correct. Don't confuse timer() with schedule(). Though now that I see who wrote that, of course it is unlikely that you have confused anything. Greg
#7
Which then spawns a guard, and calls the function 100 milliseconds later.
Which then spawns a guard...
My only comment was to point out that the time argument sent to schedule is in milliseconds, not seconds.
06/18/2007 (7:06 pm)
He has a function that spawns an enemy guard, and then schedules a call to that function 100 milliseconds (1/10th of a second) later.Which then spawns a guard, and calls the function 100 milliseconds later.
Which then spawns a guard...
My only comment was to point out that the time argument sent to schedule is in milliseconds, not seconds.
Torque Owner DragonSix