How can one change the screen orientation with code?
In my game there’s a certain mode in which the player has to switch from landscape to portrait and I want avoid that the player has to hold the phone in another orientation than the ‘real’ orientation.
If the orientation of the OS is portrait but the player holds the device in landscape, he might accidentally issue a rotation.
As you can see in the next image you can force the user to use only one orientation. (TARGET SETTINGS)
Also, you can make your landscape layout as normal and then
layout->setRotation(90.0f);
It is a dirty fix, but hope it can help you.
Thank you, I know this is possible but also not a good fix and it also takes away the functionality of being able to actually rotate by 180 degrees.
Another problem is that the notification center is on the wrong side of the screen then too, so people might get irritated by that.
Ideally I’d love to just change the real orientation programmatically and then change it back.