Android 图像上的Libgdx修补不工作

Android 图像上的Libgdx修补不工作,android,libgdx,Android,Libgdx,我有一个图像,我想注册触摸,这样它只会在用户触摸后将手指抬离屏幕时激活(前提是它的stil位于同一区域)…而不是立即单击它。我试图像文件上说的那样使用润色,但没有用 large_jackpot.addListener(new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { Gdx.app.lo

我有一个图像,我想注册触摸,这样它只会在用户触摸后将手指抬离屏幕时激活(前提是它的stil位于同一区域)…而不是立即单击它。我试图像文件上说的那样使用润色,但没有用

large_jackpot.addListener(new InputListener() {

        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            Gdx.app.log("Example", "touch started at (" + x + ", " + y + ")");

            return true;
        }

        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            Gdx.app.log("Example", "touch done at (" + x + ", " + y + ")");

            app.setScreen(app.loadingScreen);
        }

    });

你的听众很好。我猜你们的问题出在事件系统中。可能是图像类以上的内容正在捕获修补事件,或者您没有设置InputProcessor。此代码在libGDX生成的项目上按预期工作:

stage = new Stage();
Gdx.input.setInputProcessor(stage);
image = new Image(img);
image.addListener(new InputListener() {
    @Override
    public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
        Gdx.app.log("Image","touchDown");
        return true;
    }

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

如果它对您没有帮助,请提供更多代码。

您的听众没有问题。我猜你们的问题出在事件系统中。可能是图像类以上的内容正在捕获修补事件,或者您没有设置InputProcessor。此代码在libGDX生成的项目上按预期工作:

stage = new Stage();
Gdx.input.setInputProcessor(stage);
image = new Image(img);
image.addListener(new InputListener() {
    @Override
    public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
        Gdx.app.log("Image","touchDown");
        return true;
    }

    @Override
    public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
        Gdx.app.log("Image","touchUp");
    }
});
stage.addActor(image);
如果没有帮助,请提供更多代码