Page 1 of 1

Portrait rotation in android - correct way?

Posted: Wed Oct 13, 2021 9:29 am
by ThERAt
So I'm trying recreate the flappy bird game for android but flappy bird was made for portrait mode and the android version of love2d seems to start with landscape mode.

I've tried to fix this by interchanging the screen width and height of my window in the conf.lua file, like so

Code: Select all

-- conf.lua file
function love.conf(t)

t.window.fullscreen = false

-- a temporary variable 
tval = t.window.width

-- Interchanging window width and height 
t.window.width = t.window.height
t.window.height = tval

end
But I was wondering if there was a better way to do this?

Re: Portrait rotation in android - correct way?

Posted: Wed Oct 13, 2021 4:24 pm
by ReFreezed
All that's needed for portrait mode is for the height to be larger than the width. Even this should work:
t.window.width = 1
t.window.height = 2

Because you cannot change the actual screen resolution on Android, the width and height is only used by LÖVE to determine the wanted aspect ratio and whether landscape or portrait mode fits the ratio better. There's currently no other way to tell LÖVE what orientation you want.

Re: Portrait rotation in android - correct way?

Posted: Wed Oct 13, 2021 5:31 pm
by darkfrei
You can switch two parameters just as:

Code: Select all

t.window.height, t.window.width = t.window.width, t.window.height

Re: Portrait rotation in android - correct way?

Posted: Thu Oct 14, 2021 8:33 am
by ThERAt
ReFreezed wrote: Wed Oct 13, 2021 4:24 pm
Because you cannot change the actual screen resolution on Android, the width and height is only used by LÖVE to determine the wanted aspect ratio and whether landscape or portrait mode fits the ratio better.
Ohhh is that why love.graphics.getDimensions() still gives me landscape dimensions?

That's really help tho, thanks!

Re: Portrait rotation in android - correct way?

Posted: Thu Oct 14, 2021 8:34 am
by ThERAt
darkfrei wrote: Wed Oct 13, 2021 5:31 pm You can switch two parameters just as:

Code: Select all

t.window.height, t.window.width = t.window.width, t.window.height
Neat! Ty

Re: Portrait rotation in android - correct way?

Posted: Thu Oct 14, 2021 8:58 am
by darkfrei
ThERAt wrote: Thu Oct 14, 2021 8:33 am
ReFreezed wrote: Wed Oct 13, 2021 4:24 pm
Because you cannot change the actual screen resolution on Android, the width and height is only used by LÖVE to determine the wanted aspect ratio and whether landscape or portrait mode fits the ratio better.
Ohhh is that why love.graphics.getDimensions() still gives me landscape dimensions?

That's really help tho, thanks!
You are need to wait for it, print the getDimensions in the love.draw