您好,我有一个用ScreenOrientation.LANDSCAPE_SENSOR创建的andengine应用程序:
@Override
public EngineOptions onCreateEngineOptions() {
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
CAMERA_WIDTH = displaymetrics.widthPixels;
CAMERA_HEIGHT = displaymetrics.heightPixels;
camera = new ZoomCamera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_SENSOR, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera);
engineOptions.getAudioOptions().setNeedsSound(true);但是当我旋转我已经尝试添加的设备时,什么也没有发生
android:configChanges="orientation"
android:screenOrientation="sensor"像这样
<activity
android:name=".activities.AquaActivity"
android:configChanges="orientation"
android:screenOrientation="sensor"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>它似乎能识别start上的方向,但在运行应用程序时方向不会改变
我必须做一些特殊的事情才能让它工作吗?
发布于 2013-06-05 23:06:54
您不需要XML设置,也不需要做任何特殊的事情。我使用的是LANDSCAPE_SENSOR,清单中没有额外的代码行。你的代码也没有明显的错误。
如果你的应用程序运行正常(场景显示正确,一切都在移动等),而其他应用程序/游戏正确地旋转屏幕,那么我脑海中浮现的最后一件事是,你可能正在使用比GingerBread (API9级)更旧的Android SDK版本,这是LANDSCAPE_SENSOR工作所必需的。
https://stackoverflow.com/questions/16904416
复制相似问题