I have a set of sprites, each one implementing InputProcessor, and registered to an InputMultiplexer, when a sprite is touched, everyone fires the touchDown event.

Ok, so I can get the touch coordinates, unproject, and compare with the sprite bounds to know if it was touched, but it wasn't what I had in mind when I implemented InputProcessor into my sprites, I thought only the touched one would fire.

Don't even know if it is a problem, I'm planning to have about 80 sprites reacting to touch. Is this the best solution?

Is there a way to fire an event only for the touched sprite?

I'm not using scene2d or actors.


2 Answers 2


Ok, so I can get the touch coordinates, unproject, and compare with the sprite bounds to know if it was touched

This is how I would proceed, especially for only 80 sprites. How is the InputProcessor to know to fire only when certain geometry is touched? There's no concept of geometry for an InputProcessor. I recently implemented a similar model with 10,000 sprites - each with their own InputProcessor (a GestureDetector, actually). While this worked just fine on PC, Android had significant (perhaps 1 second) lag between touch and full render.

The other way this is commonly done is to have just one input processor, and 'find' the sprite under the touched area in that context (perhaps by drawing a ray from the camera's plane at the x,y of the touch event, and using an Intersector to find the intersecting object).


When your actor get touched it fires a method touchDown/touchUp in the listener class, where it supplies an Event object which you can use to get the listening actor and you can use it to compare with other actors

Actor actor 1, actor2;

actor1 = new actor () ;

actor2=new actor () ;

actor1.addinputListener(new yourInputListener()) 

actor2.addinputListener(new yourInputListener())

In your input listener class

touchDown(Event event,........) {


    //do something 

You must log in to answer this question.

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