Game Development Community

Playing and stopping a sequence

by Matthew Jones · in Torque Game Engine · 01/08/2003 (10:12 am) · 2 replies

I have been fooling around with this for a couple of days. I search the forums and found nothing on the stopThread action.
I have a thread I want to play through 1 time then stop and reset (to get ready to play again). The animation is one second long. I wrote this for a function.
function move(%val) 
{ 
	if (!%val) {
        $player.playThread(1,"forward");
        $player.stopThread("forward");
	echo(playing);
	$mvForwardAction = 1; 
	schedule(300,0,"stopmovement",1);	
	}
}
The thread starts playing but it doesn't stop. Anybody know whats missing?
Thanks
Matt

#1
01/09/2003 (5:15 am)
It should be...
function move(%val) 
{ 
	if (!%val) {
        $player.playThread(1,"forward");
        $player.stopThread(1);
	echo(playing);
	$mvForwardAction = 1; 
	schedule(300,0,"stopmovement",1);	
	}
}

When playing a thread you assign a slot for the animation in this case you assingned it to "1" so in order to stop it you have to tell it the slot you used. This also applies the the playAudio function. Also you can reverse the direction of the animation with setThreadDir(index, true|false); index being the slot number, true = forward and false = reverse.

Good luck and hope this clears it up..

Sam
#2
01/09/2003 (6:54 am)
Works great
Thanks alot Sam

Matt