Libgdx 将垂直组和舞台中心对齐?
这似乎是一个非常简单的问题,但我似乎找不到一个简单的答案。我只是想把一个垂直组放在舞台中央。大多数容器似乎很自然地做到了这一点,但这一个没有。默认情况下,它只是在视图顶部对齐。它也不响应“align.bottom”设置,只响应左侧和右侧。有什么想法吗Libgdx 将垂直组和舞台中心对齐?,libgdx,Libgdx,这似乎是一个非常简单的问题,但我似乎找不到一个简单的答案。我只是想把一个垂直组放在舞台中央。大多数容器似乎很自然地做到了这一点,但这一个没有。默认情况下,它只是在视图顶部对齐。它也不响应“align.bottom”设置,只响应左侧和右侧。有什么想法吗 stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false, spriteBatch); //VericalGroup the butt
stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false, spriteBatch);
//VericalGroup the buttons and the label
VerticalGroup group = new VerticalGroup();
group.setFillParent(true);
group.addActor(pennyLabel);
group.addActor(table);
stage.addActor(group);
试试这个简单的测试:
group.setOrigin(group.getWidth() /2,
group.getHeight()/2);
group.setPosition(Gdx.graphics.getWidth() /2 - (group.getWidth() /2),
Gdx.graphics.getHeight()/2 - (group.getHeight()/2));
stage.addActor(group);
我希望这能帮助您尝试这个简单的测试:
group.setOrigin(group.getWidth() /2,
group.getHeight()/2);
group.setPosition(Gdx.graphics.getWidth() /2 - (group.getWidth() /2),
Gdx.graphics.getHeight()/2 - (group.getHeight()/2));
stage.addActor(group);
我希望这能帮助您这看起来是一个不错的解决方案!最后,我把它放在根表中,结果它成功了。谢谢你的帮助,这看起来是个不错的解决方案!最后,我把它放在根表中,结果它成功了。谢谢你的帮助