简体   繁体   English

如何正确调整窗口大小(libGDX)?

[英]How to resize a window correctly (libGDX)?

I'm trying to create the main menu screen from my game.我正在尝试从我的游戏中创建主菜单屏幕。 I added a table with some buttons and labels on it.我添加了一个表格,上面有一些按钮和标签。 When I'm resizing to windowed mode, the inputs don't work anymore (they work when I don't resize the window).当我调整到窗口模式时,输入不再起作用(当我不调整窗口大小时它们起作用)。

I'm trying to figure a correct way out, how I scale my window correctly, but nothing seems to be working.我正在尝试找出正确的出路,如何正确缩放窗口,但似乎没有任何效果。

I scaled the stage with the following code:我使用以下代码缩放舞台:

stage.getCamera().position.set(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2, 0);

java resize(int width, int height) is empty. java resize(int width, int height)为空。

Just took a ruff overview.只是做了一个粗暴的概述。 I think the problem is that the game doesn't update it's layout with the set buttons etc.. Try to add this snippet of code:我认为问题在于游戏没有使用设置按钮等更新其布局。尝试添加以下代码片段:

stage.getViewport().update(width, height, true);

For further explanations take a look at this documentation .有关进一步的解释,请查看此文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM