Cant figure this out.....involving schedule()
by Westwood College Ohare (#0001) · in Torque Game Builder · 05/20/2006 (1:24 pm) · 4 replies
Function playerUp()
{
// Set the player moving up.
$Player.setLinearVelocityY( -10 );
if($Player.setImageMap == mback1ImageMap)
$Player.setImageMap(mback2ImageMap);
else if($Player.setImageMap == mback2ImageMap)
$Player.setImageMap(mback3ImageMap);
else if($Player.setImageMap == mback3ImageMap)
$Player.setImageMap(mback1ImageMap);
//schedule(1000, 0, 0); //need to schedule each image map to only exist for 1 sec then move on to the next image map.
}
im not sure how to do this with the schedule function. Im tryin to make an image appear to walk by switchin each image after 1 sec of pressin the "w" key to move up. Ive tried different variations but cant seem to make it work. can ne1 help? thx.
{
// Set the player moving up.
$Player.setLinearVelocityY( -10 );
if($Player.setImageMap == mback1ImageMap)
$Player.setImageMap(mback2ImageMap);
else if($Player.setImageMap == mback2ImageMap)
$Player.setImageMap(mback3ImageMap);
else if($Player.setImageMap == mback3ImageMap)
$Player.setImageMap(mback1ImageMap);
//schedule(1000, 0, 0); //need to schedule each image map to only exist for 1 sec then move on to the next image map.
}
im not sure how to do this with the schedule function. Im tryin to make an image appear to walk by switchin each image after 1 sec of pressin the "w" key to move up. Ive tried different variations but cant seem to make it work. can ne1 help? thx.
About the author
Recent Threads
#2
1st, create an ANIMATION in level Builder. Say "UpAnimation", there you'll describe how long the animation will take and what frames it will contain.
Then your function will be something like this :
05/20/2006 (8:02 pm)
That's not how you'll acomplish what you want to do.1st, create an ANIMATION in level Builder. Say "UpAnimation", there you'll describe how long the animation will take and what frames it will contain.
Then your function will be something like this :
function playerUp()
{
// Set the player moving up.
$player.setLinearVelocityY( -10 );
$player.PlayAnimation(upAnimation);
}
#3
but neways...where would i place schedule(1000, 0, "playerUp); ... ive tried using this exact line in where i bind my keys but it doesnt seem to work.
05/20/2006 (9:11 pm)
..ok so upAnimation will automatically move along to the next cell? but what if they are individual images. Ive had problems using cell images...so i just break them apart individually. When i do make cell images they tend to cut out images...or skip images on the cell. but neways...where would i place schedule(1000, 0, "playerUp); ... ive tried using this exact line in where i bind my keys but it doesnt seem to work.
#4
The scroller tutorial show exactly how this is done. The only difference will be the $player.playAnimation() call.
I would strongly recomend using the engine animation functions. The engine is already optimized for that. If you use a schedule command you'll be inserting more (unnecessary) overhead in it's processing.
05/21/2006 (8:39 am)
You don't need to use the schedule function. When you set the player LinearVelocity it will continuously move up until, the playerUp key is released and the playerStop function is called. The scroller tutorial show exactly how this is done. The only difference will be the $player.playAnimation() call.
I would strongly recomend using the engine animation functions. The engine is already optimized for that. If you use a schedule command you'll be inserting more (unnecessary) overhead in it's processing.
Torque 3D Owner Matthew Langley
Torque
// time in MS (this is one second), linked object (use 0 if you don't know), funciton to schedule ("playerUp" for playerUp()) schedule(1000, 0, "playerUp");