Need Assistance With My GUI Fly-In Code
by Orion the Hunter · in Torque Game Builder · 07/22/2013 (8:09 pm) · 3 replies
So, I've been working on a GUI Fly-In code that makes any GUI object fly from left to right and stop at a desired position. I thought it might spice up GUIs, because who doesn't love windows drifting about? You just designate the object (%obj), the X destination for the object, (%destPos), and the amount of time that elapses between each pixel movement (%speed). Here's the code:
However, it doesn't seem to be responding quite well. It just won't budge the way it's supposed to. I adapted the code from this other thing I have:
function guiFlyIn(%Obj, %destPos, %speed)
{
if(!$GFINextRun)
{
%Obj.position.X = -1 * %Obj.Extent.X;
$GFINextRun = 1;
error("First Run!");
}
error("GMFI - " @ %Obj SPC %DestPos SPC %Speed);
if( !%Obj.Position.X = %DestPos )
{
$GIFINextRun = 1;
%Obj.Position.X += 1;
schedule(%speed, 0, "GuiFlyIn", %obj, %destPos, %speed);
}
else
{
%newPos = %Obj.Position.X;
echo("Finished! GuiFlyIn - " @ %newPos);
$GIFINextRun = 1;
}
}However, it doesn't seem to be responding quite well. It just won't budge the way it's supposed to. I adapted the code from this other thing I have:
function BlurbOpsGui::onWake(%this)
{
OptWin.Position.X = -352;
%InitPos = OptWin.position.X;
echo(%this @ "::onWake - " @ %initPos);
OptWinMoveToPos();
playSound(Prompt);
}
function OptWinMoveToPos()
{
if( OptWin.position.X != 0 )
{
//echo("Move #" @ $num + 1);
OptWin.Position.X += 1;
schedule(1, 0, "OptWinMoveToPos");
}
else
{
%newPos = OptWin.Position.X;
echo(%this @ "::moveToPos - " @ %newPos);
}
}
function BlurbOpsGui::onSleep(%this)
{
OptWin.position.X = -352;
} That works just great. Notice I'm not using any "for" statements. This is because I have no idea how to use them... so thus, I use the repeating function method. Now, if one of you could replace my function loop with a "for" statement, that would be terrific, but up until now, my method has worked just fine. Does anyone know what's the problem here? Thanks!
#2
It probably has to do with the variables, %obj, %destPos, %speed. Any tips?
07/25/2013 (1:24 pm)
Thanks for the input, that's what I thought. I'm guessing the problem lies with this: schedule(%speed, 0, "GuiFlyIn", %obj, %destPos, %speed);
It probably has to do with the variables, %obj, %destPos, %speed. Any tips?
#3
if( !%Obj.Position.X = %DestPos ) <-- This is also probably an issue...
Pretty sure it needs to use != or !(%Obj.Position.X == %DestPos ).
07/27/2013 (6:44 am)
What sort of behavior are you seeing from it? Is it just not moving? if( !%Obj.Position.X = %DestPos ) <-- This is also probably an issue...
Pretty sure it needs to use != or !(%Obj.Position.X == %DestPos ).
Torque 3D Owner Harry Durnan