Page 1 of 2

screen rotation

Posted: Tue Mar 14, 2023 5:08 pm
by soytak111
How can I make that the phone screen dont rotate.I don't want to dissable it manually.

Re: screen rotation

Posted: Tue Mar 14, 2023 6:41 pm
by darkfrei

Re: screen rotation

Posted: Tue Mar 14, 2023 8:06 pm
by soytak111
Yea but what I want is that it does'nt flip at all.

Re: screen rotation

Posted: Tue Mar 14, 2023 8:51 pm
by Bigfoot71
How do you generate your APK? (unless it's on iOS and there I couldn't help)

This is declared in the application manifest and will be locked in the one indicated, you can even declare it simply in the graddle.properties if you use the repo of löve-android.

Can you give more information on how you do to launch your game on the phone?

Because the way to do it varies and if you use the version of Löve on PlayStore I think that locking the orientation of your phone is the only solution, you will then have to compile your own version of Löve Android (with your game embed or not)

Correct me if what I say is wrong about the PlayStore version, I don't use it, I'm just basing it on the info given.

Re: screen rotation

Posted: Tue Mar 14, 2023 9:16 pm
by soytak111
i just use the löve2D of the app store. All my lua file are in the lovegame folder at the root of the storage.I need to lock the game in landscape mode(which by default is set to) and that it don't flip because my app use the accelometerjoystick.

Re: screen rotation

Posted: Tue Mar 14, 2023 10:52 pm
by Bigfoot71
AppStore so iOS? There is Löve2d on the AppStore, I couldn't find it.

Regardless, I understand better, it's about preventing detection of up and down rotation when using the accelerometer.
In this case, whether for iOS or Android, you will have to compile your own version of the app.

For Android, editing the manifest will not be enough you will have to add code, I found this answer on stackoverflow (other searches could give others). You can compile it with this repository, everything is explained there: https://github.com/love2d/love-android

Regarding iOS not having a Mac I have never made an App for this platform, I can only guide you to the wiki page or this repository (which guides a bit in the readme) to compile your version and advise you to do your own research on how which would be possible.

Since I'm still not sure of your platform I still tell you not to hesitate if you have trouble compiling on Android or you're a little lost, if you're on iOS then I really hope someone someone working with Apple can advise you, then UP!

Otherwise in the meantime block screen rotation, it doesn't take much as long as it's not to be released ^^

Edit: However I don't have time now to try but I'm pretty sure darkfrei put you on the right track, there must be some way to do something with love.displayrotated and love.window.getDisplayOrientation

Give it a try anyway, I personally would.

Re: screen rotation

Posted: Tue Mar 14, 2023 11:23 pm
by soytak111
I'm on android( I always say app store even its not the name XD).In what love-android would help to dissable flipping/rotate the screen rotation? And love-android is a modification of love2D or an addon

Re: screen rotation

Posted: Wed Mar 15, 2023 12:29 am
by Bigfoot71
The love-android GitHub repo is basically the source of the app available on the playstore, you can modify the code so that the app doesn't try to turn itself when you use the accelerator, but it's may be a bit too advanced as a method for you.

A less technical solution would be to use the love.displayrotated function by doing something like this (not tested on Android):

Code: Select all

local rotGame = false

function love.displayrotated(display, orientation)
    rotGame = (orientation == "landscapeflipped")
end

function love.draw()

    if rotGame then
        love.graphics.push()
        love.graphics.rotate(math.pi)   -- PI is 180° in radians
        love.graphics.translate(love.graphics.getWidth(), love.graphics.getHeight())
    end

    -- DRAW THE GAME --

    if rotGame then
        love.graphics.pop()
    end

end
Android's screen flipping animation would still be present but the display should still be player-facing. You can also do it with the love.window.getDisplayOrientation function but at least the example I presented doesn't call a function on every update.

If a better solution exists using only the löve functions someone should tell you, otherwise consider that these are the only two best solutions for now.

Otherwise, by the way, this repo (love-android) can be useful if you want to publish your game on the PlayStore. You can compile it with your game embedded in it.

Edit (again): I just noticed that the version of Löve2D on the PlayStore is 11.3 and the wiki page on love.displayrotated says this:
Prior to 11.4, the orientation value was boolean instead of one of valid DisplayOrientation values! See below for workaround.
The workaround is this:

Code: Select all

function love.displayrotated(index, orientation)
    orientation = love.window.getDisplayOrientation(index)
    -- The rest of your code goes here.
end
Otherwise you should be able to get the 11.4 APK here: https://github.com/love2d/love-android/ ... s/tag/11.4

Re: screen rotation

Posted: Wed Mar 15, 2023 12:46 am
by soytak111
the thing its thats its super annoying the animation,and my game would often flip

Re: screen rotation

Posted: Wed Mar 15, 2023 12:49 am
by Bigfoot71
So the best solution in my opinion would be to add conditions in the love-android code to prevent this behavior.
Try if it's up your alley or wait until tomorrow if others have solutions.

Let us know if you have found a solution or not, if not I will try to implement this solution for you and share it.