Page 1 of 1
Changing the Android Orientation In-game?
Posted: Sun Feb 13, 2022 10:41 pm
by Jackkel Dragon
Is there any means by which a Ren'Py game running on an Android device could change the AndroidManifest.xml's orientation property? Right now, I have a few games that are set to use the device's sensor to determine where to orient the screen, but this can lead to odd behavior if the device is held at an angle. Therefore, I'd like to lock the screen into a sensible position while still allowing the player to pick which orientation to use. Is this possible, or does that value get baked-in once it's compiled into binary code to package the APK?
Re: Changing the Android Orientation In-game?
Posted: Mon Feb 14, 2022 1:19 am
by Ocelot
You can usually disable automatic orientation on Android phones in Notification Panel. Applications should respect that property. This is what generally used to lock screen in certain orientation.
Re: Changing the Android Orientation In-game?
Posted: Mon Feb 14, 2022 4:59 pm
by Jackkel Dragon
That doesn't seem to be how Samsung Galaxy phones work, in my experience. Even when playing games that are exclusively in landscape mode with the orientation locked, the phone will try to swap between the two potential landscape orientations if it thinks the phone is "upside-down". I'm starting to get the impression that there are multiple roadblocks to offering multiple orientation layouts in an Android game, Ren'Py or otherwise...
As for Ren'Py itself, I currently have the game with the issue using "autoSensor", which always picks based on the phone's gyroscope and not which in-game layout is being used. The only alternative I can think of is to try to make one layout rotate 90 degrees so I can lock the orientation...
Re: Changing the Android Orientation In-game?
Posted: Fri Feb 18, 2022 12:41 am
by PyTom
Ren'Py doesn't do anything special, other than react to the changes in screen size reported to it by Android. I don't know how to accomplish what you want, but it might be possible to do so using pyjnius to access the Activity. (Which is available as the mActivity field on the org.renpy.android.PythonSDLActivity class. It might also be possible to do something with the AndroidManifest.xml file to accomplish this.
Normally, all of these files are overwritten when an Android project is created. There is an option to prevent this in the configuration if you want to update the files yourself.
Re: Changing the Android Orientation In-game?
Posted: Fri Feb 18, 2022 4:42 pm
by Jackkel Dragon
Would it be possible to edit the screenOrientation field on the activity class mid-game, using pyjnius? If so, that may be just what I need. I'll also take a look myself, if the documentation mentions how to affect attributes of the activity class...