Game Development Community

Resetting the extent of sub-windows SOLVED

by Eero Karvonen · in Torque 2D Beginner · 05/24/2014 (2:48 pm) · 2 replies

Hi!

As there doesn't seem to be a method to reset the actual extent of SceneWindows on the run, I'm wondering how I should proceed.

function RootWindow::onExtentChange(%this, %posX, %posX, %resoX, %resoY)
{
	// Obviously, the root window's extent has already changed since we're here...

	// But this parallax window is a child of it. And it should fill the whole room now...
	$ParallaxWindow....
}

I don't quite follow why there is no corresponding set-method for .getWindowExtents()?
How is this supposed to be done?

#1
05/25/2014 (4:21 am)
First up, most projects (including the Sandbox example) will add the SceneWindow via the Canvas.setcontent method.

This makes the Guicontrol (Scenewindow) indistinct from the Canvas and the game's main window. As such, you won't be able to directly resize the Scenewindow if it is setup in this way.

If however, you add the SceneWindow to the Canvas or to another GuiControl, you should be able to resize is using [SceneWindow.setExtent(width, height);

One way to do it is to define a new blank GuiControl, which is sized to your program's window size, then Canvas.setContent(MyGuiControl);.

This GuiControl should then have a child SceneWindow, which would allow you to resize and reposition it at will.

btw, setExtent is defined for GuiControl. As such, all objects extended from GuiControl (all Gui controls in the engine) have this function exposed as well.
#2
05/25/2014 (5:07 am)
@Simon, I already had it implemented precisely as you describe there. The only problem being it wouldn't work...

And the cause is here,
function RootWindow::onExtentChange(%this, %posX, %posX, %resoX, %resoY)
{
   ...
while it should read,
function RootWindow::onExtentChange(%this, %XYWH)
{
   %x = %XYWH._0;
   %y = %XYWH._1;
   %w = %XYWH._2;
   %h = %XYWH._3;
   ...
because only the first argument will contain all the arguments (*banging my head to a wall*).

Thanks for pointing out the right track. :)