Scene2d 在 table 之上添加演员

Scene2d adding actors on top of table

我有一个可滚动的 table,其中包含我的菜单、按钮、标题等的所有主要功能。现在我想要一个 "hud" 在此之上,它不会滚动,就像在 facebook 中一样信使。带有 "friends" 和 "settings" 等选项卡。问题是当我尝试在 table 定位关闭后向舞台添加其他内容时,我尝试添加另一个舞台但是然后输入不起作用,我尝试添加另一个 table 但随后定位关闭(但输入有效)

当前代码:

        //table.top();
        table.add(heading).colspan(2);
        table.getCell(heading).spaceBottom(100);
        table.row();
        table.add(buttonPlay).colspan(2);
        table.getCell(buttonPlay).spaceBottom(100);
        table.row();
        table.add(buttonExit).colspan(2);
        table.getCell(buttonExit).spaceBottom(1000); //large spacing to test so scrolling works fine
        table.row();
        table.add(buttonFriends);
        table.add(buttonSettings);
        hudTable.add(buttonHud);
        hudTable.debug();
        stage.addActor(container);
        stage.addActor(hudTable);

给出如下所示的结果:

所有这一切都有效,主要 table 滚动,HUD 在我滚动时保持静止并且输入有效,但定位已关闭,我不知道如何解决这个问题,所以 HUD 是在上面。有任何想法吗?我是不是用错了方法?

正如我在评论中提到的,您可以使用 InputMultiplexer class 来处理多个阶段。

InputMultiplexer 中有一个名为 addProcessor() 的方法,它接受任何实现 InputProcessor 的对象并允许处理您的输入。

阶段 class 已经实现 InputProcessor 请参阅 Javadocs http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Stage.html

假设你有两个阶段

Stage stage1 = new Stage();
Stage stage2 = new Stage();

现在你所要做的就是

InputMultiplexer multiPlexer = new InputMultiplexer();
multiPlexer.addProcessor(stage1);
multiPlexer.addProcessor(stage2);

编辑

仅供参考,这是我使用 1 个阶段的方法

public class BattleScreen extends Table {
    private BattleActionScreen battleActionScreen;
    private BattlePokemonScreen battlePokemonScreen;
}

这个 table 的私有成员也是 table。 在我的游戏中,我在舞台内添加 BattleScreen

编辑 这是展示相同内容的图片