I'd like to include support for an 'upside down' mode in my latest game, which will be played vertically. It sounds like what I'm after is pretty close to the Accessibility / Upside Down mode option in Settings, but personally I think it would be nice to have this kind of option as something you can choose per game. For example, I'm a left hander so there are certain games where playing in upside-down mode would be better for me, but any game where I'd need to use the A / B buttons regularly would be a pain.
Is there any way to set Upside-Down mode from within an app, which would reset after the app is quit?
Yes, it is possible to implement an "upside-down" mode in your game that can be toggled within the game and will reset when the game is quit. To do this, you can use the accelerometer in the device to detect the orientation of the phone and then adjust the game's graphics and controls accordingly.
In order to use the accelerometer, you will need to add the necessary code to your game's programming. You can do this by using a library or framework that provides access to the accelerometer, such as the Core Motion framework on iOS or the SensorManager class on Android.
Once you have access to the accelerometer data, you can use it to determine the orientation of the device and adjust the game's graphics and controls accordingly. For example, if the device is upside down, you can flip the graphics and swap the functions of the A and B buttons so that they are more accessible for left-handed players.
I just implemented a feature like this in my game. It uses setFlipped to rotate the screen. The only downside is that the controls are unaffected, so I have to reverse the d-pad buttons myself when this mode is activated.