Improvements to orientation locking on Android

grant

Member
CX Code Contributor
3rd Party Module Dev
Joined
Nov 19, 2019
Messages
81
When locking the orientation to landscape or portrait we should let the player also use landscape flipped and portrait flipped. Sometimes it's nice depending on where the headphone jack is or side buttons.

We could change the suggested orientations from "portrait" and "landscape" to "userPortrait" and "userLandscape"

But since this requires API level 18 we should add backwards compatibility in Java. (Note: We still want to lock the orientation in the manifest too, because that gives it a better launch animation.)

Also I noticed there seems to be what may be a copy/paste error where onStart, onRestart, and onStop all call super.onResume(), so I changed that.

 

grant

Member
CX Code Contributor
3rd Party Module Dev
Joined
Nov 19, 2019
Messages
81
Yes, they require a newer version be targeted every year when releasing on Google Play. Cerberus-X currently targets 28 and requires 16 by default, but I didn't do any changes on that.
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
924
They update so damn quickly that you can't even get the time to read a book about one of the versions before another one is released!
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,168
Yup, if I had a say, I would drop that and the ios target :) To much effort.
 

SLotman

Active member
3rd Party Module Dev
Joined
Jul 3, 2017
Messages
174
On Android you can simply use sensorPortrait or sensorLandscape. The view is locked into portrait/landscape but if you rotate the phone the view will also rotate.

It is what I have used in all my games :)
 

grant

Member
CX Code Contributor
3rd Party Module Dev
Joined
Nov 19, 2019
Messages
81
According to the docs for Android "The sensor is used even if the user has locked sensor-based rotation."

I'm a perfectionist, so that is why I like using "user" instead.
 
Top Bottom