所以我有2个屏幕:一个水平选择屏幕,使用分辨率为720 x 405的FitViewport,然后是一个使用FillViewport的分辨率为480 x 270的游戏屏幕,按每米像素的数量进行缩放(/ 100)。
完成某个级别后,我想返回级别选择屏幕。然而,在返回时它似乎完全放大了。
Here is how it should look, and how it looks when first launched
Here is how it looks after coming out of the game
以下是关卡代码:
public LevelScreen(CrossplatformApp game) {
this.game = game;
this.camera = new OrthographicCamera();
this.levelstage = new Stage(new FitViewport(Constants.WIDTH, Constants.HEIGHT, camera));
this.background = new Texture("Screens/LevelScreen/LevelSelection.png");
this.backbutton = new Texture("Screens/BackButton.png");
this.level1texture = new Texture("Screens/LevelScreen/Button1.png");
this.level2texture = new Texture("Screens/LevelScreen/Button2.png");
this.level3texture = new Texture("Screens/LevelScreen/Button3.png");
}
@Override
public void resize(int width, int height) {
levelstage.getViewport().update(width, height, true);
}
游戏画面:
this.game = gameFile;
this.camera = new OrthographicCamera();
this.viewport = new FillViewport(Constants.V_WIDTH / Constants.PPM, Constants.V_HEIGHT / Constants.PPM, camera);
this.levelHUD = new HUD(gameFile.batch, WorldPicker.getWorldName(playerMemory.player.worldAndLevelData.getCurrentWorld(), playerMemory.player.worldAndLevelData.getCurrentLevel()));
答案 0 :(得分:0)
更改视口时,您需要在绘图之前应用视口:
this.viewport.apply();