Game Development Community

Making a GUI Window appear from Left to Right...

by Corin · in Torque Game Engine · 05/19/2005 (4:25 am) · 6 replies


#1
05/19/2005 (4:25 am)
Every GuiControl has a script property: position, which takes two integer values.
E.g.
MyWindow.position = "100 100";

This should position the window at screen position (100, 100);

Try to animate the x-position in a loop, e.g.
%x = 0;
for(%i=0; %i<10; %i++)
   %x+=10;

%screenspos = %x SPC "100";

MyWindow.position = %screenpos;
which will make your UI stall, since there are no mouse events between the window animation,

or use the schedule() method, to do the x-pos animation.

-- Markus
#2
05/19/2005 (4:33 am)
I don't think your loop will do anything, short of moving the gui control to the final position of (100, 100)

For one, your for loop doesn't include setting hte position... For 2, you have to exit the function before it will render the gui (don't you?)

I could be wrong, but I highly doubt that will work.

Something like this might... Though I think I got the Schedule syntax wrong.

function moveIt(%dist)
{
     MyWindow.position += 1;

     if (%dist > 0)
     {
           schedule(20,moveIt,0,%dist - 1); // This might not be the right syntax
     }
}
#3
05/20/2005 (4:03 pm)
You gotta do some coding, buddy. We built GuiAnimatedCtrl for our projects. It isn't perfect, but it's suitable for what you want, but I need to get some authorization before checking it in as a resource or posting it up.
#4
05/26/2005 (2:30 pm)
Instead of this
MyWindow.position += 1;
try
%pos = MyWindow.position;
 %posx = getWord(%pos, 0);
 %posy = getWord(%pos, 1);
 %posx += 1;
 %newpos = %posx SPC %posy;
MyWindow.position =  %newpos;
//might see if there is a MyWindow.setPostion(%newpos);
#5
05/26/2005 (2:40 pm)
After looking at guicontrol.h/.cc

note this little console function
/// Changes the size and/or position of this control
    /// @param   newPosition   New position of this control
    /// @param   newExtent   New size of this control
    virtual void resize(const Point2I &newPosition, const Point2I &newExtent);
ConsoleMethod( GuiControl, resize, void, 6, 6, "(int x, int y, int w, int h)")
{
}
#6
06/26/2009 (1:36 am)
I did not understan what this code does in Gui?