我试图使用Libgdx在屏幕上“调整”我的游戏视图。 实际上我需要在屏幕的底部和左侧放一个黑条。 因此,如果您使用MS Paint或Gimp调整大小,我希望在游戏阶段这样做。 (我试图上传一个数字来设置我的问题更清楚,但显然Stackoverflow禁止它为我)
我想我正在混合舞台大小,相机大小和视口。 任何建议将不胜感激 !
I am trying to "resize" my game view within the screen using Libgdx. Indeed I need to let a black bar on the bottom and the left side of the screen. So as if you resize a square using your MS Paint or Gimp, I would like to do so with my game stage. (I've tried to upload a figure to set my issue clearer but apparently Stackoverflow forbids it for me)
I think I am mixing things up with Stage size, the Camera size and the Viewport. Any advice would be greatly appreciated !
最满意答案
如果您正在使用舞台,那么您可以尝试将自己的相机视图替换为其他视口尺寸。
Camera newCamera = new OrthographicCamera(300, 200); //... here is some other camera initialization code newCamera.update();//recalculate camera matrices stage.setCamera(newCamera); //after that you may need to update sprite batch projection matrix _gameStage.getSpriteBatch().setProjectionMatrix(newCamera.combined);If you are using stage then you can try to replace camera view your own with other viewport dimensions.
Camera newCamera = new OrthographicCamera(300, 200); //... here is some other camera initialization code newCamera.update();//recalculate camera matrices stage.setCamera(newCamera); //after that you may need to update sprite batch projection matrix _gameStage.getSpriteBatch().setProjectionMatrix(newCamera.combined);更多推荐
发布评论