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

Android [SOLVED] Viewport Unwantedly Stretching to Fill Screen

E

etbunce

Guest
Hey y'all,

Just trying to change the viewport size to maintain correct aspect ratio with the camera and leave some space for GUI elements, but the view always stretches to fill the whole screen, no matter the size. That's undesired.

I don't want to maintain a fixed aspect ratio for the game, because screen space on a phone is very important and could not be fully utilized that way.

I've tried changing the viewport size directly in the room editor, using view_wport or view_hport = blah, and also view_set_wport but none of these methods shrink the size. Using a debug message indeed shows that the viewport is the size I want, but the screen still doesn't think so.

I thought the whole purpose of viewports was to do stuff like this, so hopefully there is a simple solution. Help would be much appreciated. Thanks!
 
Last edited by a moderator:

Nocturne

Friendly Tyrant
Forum Staff
Admin
Might be a silly question, but do you have "Fixed aspect ratio" checked in the Game options? That should maintain the game aspect ratio regardless of the device by adding black bars to the sides...
 
E

etbunce

Guest
Might be a silly question, but do you have "Fixed aspect ratio" checked in the Game options? That should maintain the game aspect ratio regardless of the device by adding black bars to the sides...
I have it purposefully disabled so that the game window can resize to different phone sizes. Turning on keep aspect ratio is kind of a last resort.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
I'm not sure I see the issue then...? :( What you describe is what would happen when you check keep aspect ratio, so if that's not what you want, then I'm not sure I get it. If you don't check Keep Aspect Ratio then the viewport will always be stretched to fit the screen, so you want to either adapt the view port to suit the screen size, or maybe use two views (one for the display size and one for the size you want to run the game at). But two views would open up another can of worms...
 
E

etbunce

Guest
If you don't check Keep Aspect Ratio then the viewport will always be stretched to fit the screen
This answers my question. Turns out that checking keep aspect ratio produces a closer behavior to what I want than going full scale! Yeah I'm still figuring this out.

It seems keeping the aspect ratio still expands the viewport to fill the screen while keeping the aspect ratio (go figure) instead of stretching. This can be dealt with no problem, but I do need to change the viewport size during the game and not just at the beginning, which apparently isn't possible without using two views. Unless you know a way to change viewport size during the game (using window_set_size() doesn't seem to work) without two views, I guess I'll be back if that can of worms ends up being too nasty.

Thanks!
 
Top