Libgdx:如何检测单独舞台演员的触摸?

时间:2016-11-28 07:57:56

标签: java libgdx

我试图创建一个类似这样的游戏:

游戏区域 - 未使用舞台(scene2D)。 在游戏区域中,在渲染方法中:

b2dr.render(world, b2dcam.combined); // main camera
sb.setProjectionMatrix(hud.stage.getCamera().combined);
hud.stage.draw(); // draws HUD over screen

我在游戏区域中触摸了touchDown / touchUp / touchDragged事件并且它们运行良好。在HUD内部,我正在使用舞台和桌子来正确显示它。

现在让我们说我在HUD上有一个按钮,我想要接收点击事件。我怎么做?我在我的HUD课程中试过这个但没有成功:

myBtn.addListener(new InputListener()
        {
            @Override
            public boolean touchDown (InputEvent event, float x, float y, int pointer, int button)
            {
                System.out.println("touchdown");
                return true;
            }
            @Override
            public void touchUp (InputEvent event, float x, float y, int pointer, int button)
            {
                System.out.println("touchup");
            }
        });

0 个答案:

没有答案
相关问题