Libgdx - 将垂直组对齐到舞台中心?

Libgdx - align vertical group to center of the stage?

这似乎是一个非常简单的问题,但我似乎找不到简单的答案。我只是想将一个 VerticalGroup 放在舞台中央。大多数容器似乎自然而然地做到这一点,但这个却没有。默认情况下,它只是在视图的顶部对齐。它也不响应设置 "align.bottom",只是左右。有什么想法吗?

        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);

希望对你有所帮助