Search code examples
javalibgdx

Why doesn`t touchUp method trigger?


table.setPosition(0, 0);
table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
table.setTouchable(Touchable.enabled);
table.addListener(new ClickListener(){
    @Override
    public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
        System.out.println("me working");
        nextPhrase();
    }
});
stage.addActor(table);

The touchUp method doesn`t trigger. Table contains an Image and a Label and fills the screen. I need nextPhrase() method to trigger whenever screen is touched. What should I do?


Solution

  • I don't know your full code but I assumed you have forgotten to update your Stage. If yes put this on your render/update method. What this do is to update all your Actors inside your Stage.

    stage.act();
    

    Also, don't forget to set your input processor to read input from the user.

    Gdx.input.setInputProcessor(stage);