I've created a game that is working well in desktop mode. But when I run it in mobile, it runs in landscape mode only. How can I make the game work successfully in both portrait and landscape mode?
Set the screenOrientation to fullSensor in the AndroidManifest.xml file:
android:screenOrientation="fullSensor"
This will detect the orientation of the device and rotate the screen automatically. Also ViewPorts in LibGDX are used to determine how your program will handle the width and height changes when the screen rotates. https://github.com/libgdx/libgdx/wiki/Viewports
Open AndroidManifest.xml located in Android project and find the entry that says:
android:screenOrientation="landscape"
Change "landscape" to "portrait" to make it look like this:
android:screenOrientation="portrait"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With