Portrait rotation in android - correct way?

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.
Post Reply
ThERAt
Prole
Posts: 3
Joined: Wed Oct 13, 2021 9:13 am

Portrait rotation in android - correct way?

Post 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?
Attachments
conf.lua
(134 Bytes) Downloaded 149 times
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: Portrait rotation in android - correct way?

Post 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.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
User avatar
darkfrei
Party member
Posts: 1168
Joined: Sat Feb 08, 2020 11:09 pm

Re: Portrait rotation in android - correct way?

Post by darkfrei »

You can switch two parameters just as:

Code: Select all

t.window.height, t.window.width = t.window.width, t.window.height
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
ThERAt
Prole
Posts: 3
Joined: Wed Oct 13, 2021 9:13 am

Re: Portrait rotation in android - correct way?

Post 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!
ThERAt
Prole
Posts: 3
Joined: Wed Oct 13, 2021 9:13 am

Re: Portrait rotation in android - correct way?

Post 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
User avatar
darkfrei
Party member
Posts: 1168
Joined: Sat Feb 08, 2020 11:09 pm

Re: Portrait rotation in android - correct way?

Post 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
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 15 guests