• 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!

GameMaker Scaling GUI object placement

Erayd

Member
I have a theory I'm wondering if anyone passing by here can confirm or not.

My gui layer is set to the resolution of the player's monitor so as to have the highest resolution for certain graphics. Before I built that function in, I had been setting all my element's locations by static values like x= 50, y = 120. The obvious problem with that is that after resizing the gui layer, 50 x 120 is no longer where I wanted it to be, so my whole gui was still visually the same size.

One answer is to have different resolution options the player can choose and then adapt the gui based on that choice, however, I'm wondering if I can instead just use ratio values to place all of my objects on the gui layer?

Example: (where gui_width is recorded when the gui layer changes, in this case, display_get_gui_width())
Code:
    var picked_x = gui_width/15;
    var picked_y = gui_height - picked_item_back_height - gui_height/10;
    
    //Background
    draw_sprite_ext(picked_item_back, -1, picked_x, picked_y, 1, 1, 0, c_white, picked_item_a);
I don't have a bunch of monitors to test this on, plus its still just a theory. If nobody has any ideas then I could just adjust the gui size to several different common monitor sizes and see what happens. Just throwing it out there for now. My hope is that by using ratios, the sprite objects always render in the same location since the game view will be the size of the display but a small scale resolution and the gui layer will also be the same size as the display, but a much higher resolution.
 

dialgpalkia

Member
It sounds like a good idea but you’d need to be able to determine the monitor in uses’ resolution. Say for example your game runs mainly on a 640x480 view. You have a monitor that has resolution 1900x1280 for example, if you could detect that manually, you could just scale the placements of all objects by a factor of (1900/640)x(1280/480).
 

Erayd

Member
display_get_width() and display_get_height() would be that detection your talking about. That gets the monitor resolution width and height.
 

dialgpalkia

Member
That’s right, it’s been a while since I used them.
If you get that and multiply by the ratios it would work, at least theoretically. You’d have to do some testing though.
 
Top