keep aspect ratio in several resolutions

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
brunuu
Prole
Posts: 8
Joined: Mon Apr 02, 2018 11:51 pm

keep aspect ratio in several resolutions

Post by brunuu »

I'm trying to find a way for my game to always keep the same ratio regardless of the resolution on android, so far I have not figured out a functional way

What's the best way to do this?
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: keep aspect ratio in several resolutions

Post by zorg »

Hi and welcome to the forums;

Depends on which of the two solutions you prefer, black boxes or the screen being cut off.

You'll have to have an "internal" resolution that has the aspect ratio you want, then you can either adjust the screen to the smallest (if you want vertial/horizontal black boxes) or the largest (if you want the screen to be cut off) of the two dimensions the user's screen has.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
brunuu
Prole
Posts: 8
Joined: Mon Apr 02, 2018 11:51 pm

Re: keep aspect ratio in several resolutions

Post by brunuu »

the screen and the objects can not be resized?
edit---


Does this solve the problem?

love.window.setFullscreen (true, "desktop")
Last edited by brunuu on Tue Apr 03, 2018 9:42 am, edited 1 time in total.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: keep aspect ratio in several resolutions

Post by zorg »

If my google translate is correct, you can resize the screen and scale the drawn objects as well, but it's way more cumbersome to calculate such things than to stick with one resolution, and scale THAT once.

(And i don't think any fullscreen mode on handhelds would do anything with the display in the way you would want it to)
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
brunuu
Prole
Posts: 8
Joined: Mon Apr 02, 2018 11:51 pm

Re: keep aspect ratio in several resolutions

Post by brunuu »

zorg wrote: Tue Apr 03, 2018 9:04 am If my google translate is correct, you can resize the screen and scale the drawn objects as well, but it's way more cumbersome to calculate such things than to stick with one resolution, and scale THAT once.

(And i don't think any fullscreen mode on handhelds would do anything with the display in the way you would want it to)
Sorry, I have no idea why I started writing on another language, I'm still sleeping


The problem I'm facing is that I need the game to fit any resolution, more specifically on Android.

I can not use black bars or crop the screen
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: keep aspect ratio in several resolutions

Post by zorg »

If you don't want to use black bars OR crop the screen, then you only have two other methods to choose from:
Stretch the contents, or show more/less depending on the width and height.

Do choose one of those and i'll try to write a short code block on how to implement that.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
brunuu
Prole
Posts: 8
Joined: Mon Apr 02, 2018 11:51 pm

Re: keep aspect ratio in several resolutions

Post by brunuu »

Stretching would be better, I guess
is for a smartphone screen after all
User avatar
NotARaptor
Citizen
Posts: 59
Joined: Thu Feb 22, 2018 3:15 pm

Re: keep aspect ratio in several resolutions

Post by NotARaptor »

Stretching would probably look bad. What sort of game are you trying to make?
brunuu
Prole
Posts: 8
Joined: Mon Apr 02, 2018 11:51 pm

Re: keep aspect ratio in several resolutions

Post by brunuu »

NotARaptor wrote: Tue Apr 03, 2018 12:31 pm Stretching would probably look bad. What sort of game are you trying to make?
is a strategy game with some GUI-like elements
User avatar
NotARaptor
Citizen
Posts: 59
Joined: Thu Feb 22, 2018 3:15 pm

Re: keep aspect ratio in several resolutions

Post by NotARaptor »

Divide the "stuff to draw" into two main lists - the world and the GUI.

The world... well you'll just have to draw a smaller portion of it for smaller screens.

For the GUI, position everything relative to the general borders of the screen - i.e. "20 pixels from the right border, 10 pixels from the top border", then test it in every resolution you can to make sure things don't overlap or go strange.

I would definitely advise against stretching (that's when the things are drawn with uneven scaling on X/Y - they end up looking really tall and skinny, or short and wide... even a little bit is noticeable)
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests