How to force rotation in Android

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
Dangerous beetle
Prole
Posts: 15
Joined: Sat Aug 13, 2022 7:25 am

How to force rotation in Android

Post by Dangerous beetle »

Hi guys, I have a problem, I want to force the rotation of the screen to just one side, I am not talking about orientation, I am using 11.3a version and fortunately I didn't have any problems with the orientation, the only problem is that when in landscape mode, when I open the screen and then rotate it to 180°(rotate not flip), then the landscape mode also rotates to that side.
Those who didn't understand, If I opened the game engine, while my charging port(it is located in the bottom of my phone) was facing right, If I rotate the screen and the charging ports gets to the left side, the screen rotates too in that direction, and I don't want that. :(
I hope you understood what I meant to say, If you guys got any solution, kindly tell me I will be very thankful :)
Andlac028
Party member
Posts: 174
Joined: Fri Dec 14, 2018 2:27 pm
Location: Slovakia

Re: How to force rotation in Android

Post by Andlac028 »

There was discuttion recently, I think you can change it in manifest, forcing display orientation to landscape and then compile love-android
Dangerous beetle
Prole
Posts: 15
Joined: Sat Aug 13, 2022 7:25 am

Re: How to force rotation in Android

Post by Dangerous beetle »

Sorry sir/ma'am, I didn't understand it well, I'm just a noob and I am making the game in a tablet and I don't have any computer, kindly make it more clear
Andlac028
Party member
Posts: 174
Joined: Fri Dec 14, 2018 2:27 pm
Location: Slovakia

Re: How to force rotation in Android

Post by Andlac028 »

It's that you have to compile love apk yourself and change some code to be able to change orientation (to deny reverse landscape). I may try to compile it for you, but I cannot guarantee the result will work as expected, but you will also need to compile the apk and add .love file to it in compilation process, if you would want to distribute your apk as game.

But if you want only to not flip the screen for you, try to lock screen orientation in your phone settings.
Dangerous beetle
Prole
Posts: 15
Joined: Sat Aug 13, 2022 7:25 am

Re: How to force rotation in Android

Post by Dangerous beetle »

So, it can't be done :( . Anyways, thanks a lot for helping me, Nothing can be done for this, because I don't have a computer to do compiling, messing with the source code and all and android as a devtool is really problematic. Thanks again. Have a nice day.
Andlac028
Party member
Posts: 174
Joined: Fri Dec 14, 2018 2:27 pm
Location: Slovakia

Re: How to force rotation in Android

Post by Andlac028 »

I actually tried to build the apk (however I didn’t tested it), let me know, if you want to try it.
Dangerous beetle
Prole
Posts: 15
Joined: Sat Aug 13, 2022 7:25 am

Re: How to force rotation in Android

Post by Dangerous beetle »

Yes sure! I'd love to try it out :).
Andlac028
Party member
Posts: 174
Joined: Fri Dec 14, 2018 2:27 pm
Location: Slovakia

Re: How to force rotation in Android

Post by Andlac028 »

Here you go, please let me know, if it worked (I changed display orientation to landscape in AndroidManifest.xml and added some code snippet from Stack overflow to GameActivity.java: to be more precise, I added setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); to onCreate method)

Also note, that I used some slightly modified version of love, and I forgot, what I changed, so I hope, there wouldn't be any significant differences (I think, I removed love logo somehow), but if it will work, I can try it with fresh copy of love2d-android
Attachments
app-normal-noRecord-universal-release-unsigned.zip
(7.93 MiB) Downloaded 441 times
Dangerous beetle
Prole
Posts: 15
Joined: Sat Aug 13, 2022 7:25 am

Re: How to force rotation in Android

Post by Dangerous beetle »

It's showing: "You can't download the apk in your device"....do you know why??
User avatar
Popolon
Prole
Posts: 25
Joined: Mon Nov 07, 2016 11:03 am
Location: France/Paris

Re: How to force rotation in Android

Post by Popolon »

Also look at this functions that could help you to draw the application depending on screen orientation:
* https://love2d.org/wiki/love.window.get ... rientation
* https://love2d.org/wiki/DisplayOrientation

Locking rotation, would be interesting also for me on GNU/Linux phone. Hope it will be implemented by default in futur version of LÖVE.
Post Reply

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 17 guests