Scene2d:InputListener不调用touchUp

时间:2016-05-30 14:24:42

标签: java libgdx scene2d

我尝试在Actor上使用InputListener,但似乎没有调用touchUp。其他每种方法都适用于我。

stage = new Stage(new ScreenViewport());

Widget actor = new Widget();
actor.setFillParent(true);
actor.addListener(new InputListener() {
    public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
        Gdx.app.log("", "");
    }
});
stage.addActor(actor);
Gdx.input.setInputProcessor(stage);

1 个答案:

答案 0 :(得分:2)

    stage = new Stage(new ScreenViewport());

    Widget actor = new Widget();
    actor.setFillParent(true);
    actor.addListener(new InputListener() {

        @Override
        public void touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            Gdx.app.log("", "");
        }
    });
    stage.addActor(actor);


    Gdx.input.setInputProcessor(stage);