我正在使用Libgdx开发一款Android游戏应用程序。由于我非常新手,所以在渲染/调整屏幕大小后恢复时遇到了问题。
虽然调整大小后屏幕效果良好,但并非总是如此。有时它会将屏幕调整到几乎一半的大小。
我无法找出问题所在。我已经在Google上搜索过,找到了一些解决方案,但它们并没有帮助我。
//This is my manifest in the project.
<activity
android:name="com.tll.game.android.AndroidLauncher"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
//Resize function in Game class
@Override
public void resize(int width, int height) {
viewport.update(width, height, true);
camera.update();
}
//i commented the resize function in Screen class, but it didn't work
@Override
public void resize(int width, int height) {
//viewPort.update(width, height, true);
//camera.update();
}
//EDIT: ViewPort And Camera
protected static final int VIRTUAL_WIDTH = 800, VIRTUAL_HEIGHT = 480;
protected Camera camera = new OrthographicCamera(VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
protected Viewport viewPort = new ScalingViewport(Scaling.fill,VIRTUAL_WIDTH, VIRTUAL_HEIGHT, camera);