GUI resizing and repositioning for different resolutions? [SOLVED]
by Andrew H · in Torque Game Builder · 10/06/2011 (5:11 pm) · 11 replies
In my game, I am allowing the user to make the game fullscreen, and I cannot do this without letting them change resolutions as well (to accommodate for different size screens).
So, I am wondering - since there is no feasible way to make different changes for all the different resolutions existing, is there a way I can just have it automatically reposition and resize (but I think I can do OK without the resizing) so that it isn't just all in a corner when you make it a higher resolution?
So, I am wondering - since there is no feasible way to make different changes for all the different resolutions existing, is there a way I can just have it automatically reposition and resize (but I think I can do OK without the resizing) so that it isn't just all in a corner when you make it a higher resolution?
About the author
I do everything for my game company. Including the legal stuff.
#2
10/07/2011 (5:27 pm)
Just make sure you've got your GUIs set to be relative and the engine takes care of it for you. There are some best practices to keep in mind though. Be mindful of the resolution your GUI is set in when you're working on it and be sure to design it in the lowest resolution you plan to support.
#3
10/07/2011 (6:27 pm)
Okay - that resolution would be 800X600. Done and done, that's what I design it in. Now, please clarify - how exactly do I set the GUIs to be relative? This is what I was asking.
#4
To make a GUI relative set the HorizSizing and VertSizing of a GuiControl's properties to relative.
10/08/2011 (10:34 am)
Sorry about that, got called away before I wrote that line and just hit post when I got back to my desk thinking I had.To make a GUI relative set the HorizSizing and VertSizing of a GuiControl's properties to relative.
#5
If I wanted it to be relative, I would do this?
10/08/2011 (10:50 am)
Okay - so for this:new GuiTextCtrl(Welcome) {
canSaveDynamicFields = "0";
isContainer = "0";
Profile = "AntivirusLargeTextProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = "295 26";
Extent = "486 71";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
text = "Welcome, " @ $playerName @ "!";
maxLength = "1024";If I wanted it to be relative, I would do this?
new GuiTextCtrl(Welcome) {
canSaveDynamicFields = "0";
isContainer = "0";
Profile = "AntivirusLargeTextProfile";
HorizSizing = "relative";
VertSizing = "relative";
Position = "295 26";
Extent = "486 71";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
text = "Welcome, " @ $playerName @ "!";
maxLength = "1024";
#6
10/09/2011 (11:13 am)
Right? That's how I'd do it?
#7
size = getRes(); <-- returns the resolution
%x = getWord(%size,0); <-- pull out the X value
%y = getWord(%size,1); <-- Pull out the Y value
<ui Item>.Position = %x/2 - 100@" "@ %y/4; (or whatever calculations you want to use to put it on a part of the screen.)
10/11/2011 (5:36 am)
Um, I believe what he meant is use variable values, and calculate out where you want them to be on the screen. I know, all the 2d Text and Images have coordinate values that automatically re-size, so I'm not sure why the GUI system doesn't. What I did was something like:size = getRes(); <-- returns the resolution
%x = getWord(%size,0); <-- pull out the X value
%y = getWord(%size,1); <-- Pull out the Y value
<ui Item>.Position = %x/2 - 100@" "@ %y/4; (or whatever calculations you want to use to put it on a part of the screen.)
#8
10/12/2011 (12:44 pm)
So, I have to do that for all of the GUI items? Okay...
#9
10/12/2011 (2:23 pm)
No, he actually meant to set it to relative. I didn't know it, but there's a 'relative' setting for them.
#10
10/12/2011 (8:06 pm)
Ah, good to know. Might come in handy.
#11
10/13/2011 (3:16 pm)
I imagine it would.
Torque Owner Andrew H