[英]Viewport changing in libgdx viewport
因此,我有2个屏幕:一个级别选择屏幕,该屏幕使用分辨率为720 x 405的FitViewport,然后是一个游戏屏幕,其使用分辨率为480 x 270的FillViewport(按每米像素数(/ 100)缩放)。
完成某个级别后,我想返回到级别选择屏幕。 但是,返回时似乎已完全放大。
这是关卡屏幕代码:
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()));
更改视口时,需要在使用以下方法进行绘制之前应用视口:
this.viewport.apply();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.