v0.3.3: added the ability to flip the screen in landscape/portrait

This commit is contained in:
Evan Debenham 2015-12-18 02:23:16 -05:00
parent 078de8d91d
commit aff724c8d5
2 changed files with 10 additions and 4 deletions

View File

@ -29,7 +29,7 @@
android:label="@string/app_name" android:label="@string/app_name"
android:name=".ShatteredPixelDungeon" android:name=".ShatteredPixelDungeon"
android:configChanges="keyboardHidden|orientation|screenSize" android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"> android:screenOrientation="sensorPortrait">
<intent-filter > <intent-filter >
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />

View File

@ -207,9 +207,15 @@ public class ShatteredPixelDungeon extends Game {
*/ */
public static void landscape( boolean value ) { public static void landscape( boolean value ) {
Game.instance.setRequestedOrientation( value ? if (android.os.Build.VERSION.SDK_INT >= 9) {
Game.instance.setRequestedOrientation(value ?
ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE :
ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
} else {
Game.instance.setRequestedOrientation(value ?
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE :
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ); ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
Preferences.INSTANCE.put( Preferences.KEY_LANDSCAPE, value ); Preferences.INSTANCE.put( Preferences.KEY_LANDSCAPE, value );
} }