Game Development Community

GUI Objects don't resize with window

by Andy Hawkins · in Torque Game Engine · 04/26/2008 (7:39 pm) · 6 replies

I set up my GUI objects on a 1024 x 768 screen but if the user resizes the screen they are going to be in the wrong spot. How do I make the GUI objects like radar and gauges move to suit the screen size?

#1
04/26/2008 (7:58 pm)
You just gotta change the horizontal and vertical sizing options. Another thing that will help a lot is to always edit your gui on the smallest screen setting, as it will make everything show up better when the screen is resized. If you're wanting the objects to actually "scale" with the window being reset you need to set the sizings to relative. Note though that if you do this with bitmap or png images they're going to look horribly stretched.
#2
05/01/2008 (9:27 am)
Andy - There are a number of ways to approach this, using relative positioning, using variables to position the items or writing a function to move things when the resolution changes to name a few. You should have a look at the TDN article tdn.garagegames.com/wiki/GUI/Tips1_5 which talks a bit more about it and should be very useful for you.
#3
05/01/2008 (11:12 am)
Hi. I was also looking into this today. Last night I was getting frustrated making a simple gui. I started with the smallest 640x480 and everytime I switch resolutions it messed up everything. Using the relative setting didn't help either.

What I'd like to do is write a script that checks the resolution and then displays the correct gui for that size. I'm gonna try this when I get home from work. Hopefully it should be easy. I had to do this before when coding a half-life mod years ago.
#4
05/01/2008 (3:50 pm)
MB, you may be having the problem I had when I first started. I was centering objects over a background image, but when the background image resized no matter how I placed the items or what settings i set, they always messed up. One option that someone pointed out to me is to set the items I didn't want to move or to resize into a parent gui object, I typically set them inside another guibitmapctrl.

However for very delicate and precise needs setting functions to place gui objects wouldn't be a bad idea, but what I said has worked 100% of the time for me.
#5
05/02/2008 (6:26 am)
Thanks Rich, I'll try that out as well. Last night I wrote a script that changes which GUI to use depending on the users screensize. I ran into a couple bugs that I eventually worked out (I lost control of my mouse and keyboard, but I fixed that). I still have one remaining bug.. I lost the use of the ESC key. Not sure why, lol, but I'll fix it up. If anyone wants that code I'll post a little tutorial. I like being able to have different GUI's for different screensizes. It could also allow the user to choose from a list of GUI's, (say A, B, or C each with a different setup) whichever they like best and use that in-game.
#6
05/02/2008 (7:20 am)
Great tips thanks guys. This will really help me.