I am creating a game using libgdx.

In the same each level has a class. I have stage as a member variable of the class. To this stage, I add actors.

Inside the levels class, I have attaced the input processor to the stage like below.

stage = new Stage();
sviewPort = new StretchViewport(OSR_Constants.VIEWPORT_WIDTH, OSR_Constants.VIEWPORT_HEIGHT);
OrthographicCamera camera = new OrthographicCamera(OSR_Constants.VIEWPORT_WIDTH, OSR_Constants.VIEWPORT_HEIGHT);
camera.position.set(0, 0, 0);


The level object is instantiated in another class known as GameScreen. GameScreen implements the Screen interface.

I am unable to detect touch events on my actors in the stage. Each actor has also been given bounds as per the world coordinates. I have added the following code on each actor to detect touch

this.addListener(new InputListener(){
     public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
          System.out.println("touchdown at " + x + " " + y);
          return true;
  • \$\begingroup\$ You should disable InputProcessor on Stage when it is not required to kick start your Actor's InputProcessor. Use Gdx.input.setInputProcessor(null); \$\endgroup\$
    – kingAm
    Jan 28, 2015 at 4:27
  • \$\begingroup\$ Really late to answer this, but I just want to give a suggestion to make sure to call stage.draw() and stage.act() methods in render() \$\endgroup\$
    – Neerkoli
    Jan 22, 2016 at 7:02

1 Answer 1


You shouldn't create new InputListener, but you need to use one that you register in Gdx.input.setInputProcessor


Didn't test.

  • \$\begingroup\$ every actor can have their own inputlistener to handle touch events differently \$\endgroup\$
    – rrd
    Jan 27, 2015 at 4:12
  • \$\begingroup\$ but if you create new InputListener, you need to register it on "Gdx.input.setInputProcessor(input_listener);" without it you don't get event to this listener. \$\endgroup\$
    – admund
    Jan 27, 2015 at 11:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .