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

Resize room for different resolutions? iOS/Android

B

bigtunacan

Guest
I have my game mostly working at this point, it runs on mobile, but with black bars on the sides since it is not the correct resolution. I have tried the "Full scale" option in the device settings and this does work, but the result is not good since it changes the aspect ratio.

What I would like to do instead is use the "Scaling - Keep aspect ratio" and then manually set the room size based on the device resolution.

I'm not clear on how to do this, but I tried the following two things and they did not work.

Code:
aspect_ratio = window_get_width() / room_width;
room_width = window_get_width();
room_height = room_height * aspect_ratio;
and

Code:
aspect_ratio = window_get_width() / room_width;
window_set_size(window_get_width(), room_height * aspect_ratio);
 
J

Jordan Robinson

Guest
I have my game mostly working at this point, it runs on mobile, but with black bars on the sides since it is not the correct resolution. I have tried the "Full scale" option in the device settings and this does work, but the result is not good since it changes the aspect ratio.

What I would like to do instead is use the "Scaling - Keep aspect ratio" and then manually set the room size based on the device resolution.

I'm not clear on how to do this, but I tried the following two things and they did not work.

Code:
aspect_ratio = window_get_width() / room_width;
room_width = window_get_width();
room_height = room_height * aspect_ratio;
and

Code:
aspect_ratio = window_get_width() / room_width;
window_set_size(window_get_width(), room_height * aspect_ratio);
What your missing is that you need to also update the size of the View and View Port in your room. You can read more about views here. It will be necessary to restart the room before the changes take effect. Alternatively if you set up all of these values in a "initialization room" and then go to the first game room it would also work. That seems to be the most common method.


EDIT: Forgot to add that the reason for this is gamemaker automatically sets the view port to the size of the first room in your game.
 
Top