• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GUI Issues with Keep Aspect Ratio

Y

YCCCM7

Guest
Using gamemaker studio 1.4.1763 here.

Anyways, when one goes to windows > display settings for a game, there are "keep aspect ratio" and "full scale" as options for how certain things should scale. The issue is, when in fullscreen mode, trying to keep aspect ratio (which is key for looking good on a variety of display sizes, in my opinion) seems to invoke large volumes errors in the aftermath.

These include, that I can confirm:
-device_mouse_raw_x() returning a value that is incorrect by almost exactly 1/6th of the length of one of the black bars on the sides of the screen.
-display_get_gui_width() returning a value that is overshot by exactly the sum of the width (in pixels) of the black bars on the sides of the screen.
-calls for place_meeting() that check for the position of the mouse (and other GUI elements) being wrong by exactly 82% of the width of one black bar on the side of the screen.

So my question is, mostly, whether or not there's anything one needs to adjust or a method to calibrate for these odd errors, assuming they are known errors. I've attempted to set GUI size, but that causes even more errors than it would (theoretically) solve.

For reference, I can confirm that these issues are for certain not occurring in windowed mode, as I've tested extensively. I can get screenshots if this may help, but long story short, black bars seems to be invoking massive errors and it's requiring me to either go with wrong aspect ratio (which looks awful) or rewrite some of the most fundamental code in my game.

Thanks for your time, either way.
 
Okay, so let's go through these:

device_mouse_raw and it's brother will return the position of the cursor RELATIVE TO THE DISPLAY. This is not what you want. You want the cursor relative to your game's application surface (which is the area inside the black bars), which is device_mouse_x/y.

So your gui size automatically resizes to match your game window UNLESS you set it at least once. I recommend setting it, using display_set_gui_size(), to your base resolution. This will keep the pixel size of your game and your gui consistent, and keep your coordinates consistent.

If your buttons are being drawn in a gui event, then you need to use the device_mouse_x_to_gui and it's brother to do collision checking.
 
Top