Game Development Community

About function schedule

by Shek Siu Hang · in Torque Game Builder · 02/18/2010 (10:17 am) · 4 replies

I have a question about function "schedule".
I wanna make a flash effect by calling schedule.

Object appear at the tilemap, wait one second, and then disappear.
(Appear => disappear => appear => dosappear),by using recursion.

How come it will not wait one second to execte the function?

function lost_life_effect(%seq,%clear,%column,%row)
{
echo(%seq);
if (%seq >=0)
{
if (%clear == 1)
{
%seq--;
%clear = 0;
$Board.clearTile(%column, %row);
$Board.schedule( 1000, 0,lost_life_effect(%seq,%clear,%column,%row));
}
else
{
%seq--;
%clear = 1;

$Board.setStaticTile(%column, %row, ImageMap);
$Board.schedule( 1000,0, lost_life_effect(%seq,%clear,%column,%row));
}
}
}

#1
02/18/2010 (10:35 am)
Because you're using the method form of the schedule function. It's calling $board.lost_life_effect() which doesn't exist. You want the global function of schedule, that's at least one of your problems.
#2
02/18/2010 (12:26 pm)

You need to pass the function name and the arguments to schedule so that it calls the function for you. The way you do it, you are calling the function immediately.

So it should be:

schedule( 1000, 0, "lost_life_effect", %seq, %clear, %column, %row );
#3
02/18/2010 (12:35 pm)
Thanks a lot! It's work :)
#4
02/18/2010 (3:05 pm)
Wow two people quick on the draw with answers :) Like your Avatar btw, Chrono Trigger is one of my favorite games.