Maintaining aspect ratio

My game is in portrait format (480 x 720).
When maximising the game window or running full-screen, everything except GUI elements are stretched to fit the screen.

Is there a way to maintain the aspect ratio so the game is display in the middle of the screen?

Use a render script / input correction like in this example https://github.com/britzl/publicexamples/tree/master/examples/fixed_aspect_ratio

Thanks - that works in part.

I’m getting a lot of overdraw and GUI text is being drawn in the wrong place (above or below where it should be) - everything should be within the blue background.

Any further ideas appreciated! It’s a weird one I know.

I’m thinking about actually doing a more indepth tutorial for this subject as it is something that many wonders about and even struggle with. There are of course no single solution but more of a “case to case” thing depending on how you want to different ratios to be handled but I might show some of the more common solutions.

10 Likes

Yep, I think that would be appreciated by a lot of people :slight_smile:

Andreas_Jirenius, tutorial for differend aspect AND different screen resolution please.

2 Likes