如何使用Libgdx调整窗口内的舞台大小(How to resize the stage inside of my window using Libgdx)

编程入门 行业动态 更新时间:2024-10-27 06:19:38
如何使用Libgdx调整窗口内的舞台大小(How to resize the stage inside of my window using Libgdx)

我试图使用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);

更多推荐

本文发布于:2023-07-07 09:05:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1061406.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   舞台   大小   窗口   Libgdx

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!