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?
keep aspect ratio in several resolutions
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: keep aspect ratio in several resolutions
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.
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 True 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.
Re: keep aspect ratio in several resolutions
the screen and the objects can not be resized?
edit---
Does this solve the problem?
love.window.setFullscreen (true, "desktop")
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.
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: keep aspect ratio in several resolutions
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)
(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 True 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.
Re: keep aspect ratio in several resolutions
Sorry, I have no idea why I started writing on another language, I'm still sleepingzorg 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)
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
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: keep aspect ratio in several resolutions
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.
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 True 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.
Re: keep aspect ratio in several resolutions
Stretching would be better, I guess
is for a smartphone screen after all
is for a smartphone screen after all
- NotARaptor
- Citizen
- Posts: 59
- Joined: Thu Feb 22, 2018 3:15 pm
Re: keep aspect ratio in several resolutions
Stretching would probably look bad. What sort of game are you trying to make?
Re: keep aspect ratio in several resolutions
is a strategy game with some GUI-like elementsNotARaptor wrote: ↑Tue Apr 03, 2018 12:31 pm Stretching would probably look bad. What sort of game are you trying to make?
- NotARaptor
- Citizen
- Posts: 59
- Joined: Thu Feb 22, 2018 3:15 pm
Re: keep aspect ratio in several resolutions
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)
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)
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 2 guests