I use a group to store some images and draw them in SpriteBatch. Now I want to determine which image was clicked. For this reason, I am adding an InputListener to the group to receive an event on touch. The incoming InputEvent received a method (getTarget) that returns a reference to the pressed Actor.
If I click on the transparent area of ββthe actor, I want to ignore the incoming event. And if the actor is behind him, I want to use it instead. I thought of something like this:
myGroup.addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { Actor targetActor = event.getTarget();
Is this the right thing to do? I thought that returning false for the touchDown method would continue to propagate for the event, and also let me also get touchDown events for other participants in the same position. But this seems like a misunderstanding ...
UPDATE
PTs answer solves the problem of getting the right event. Now I am having a problem with detecting pixel transparency. It seems to me that to get access I need an image in the form of a Pixmap. But I do not know how to convert the image to Pixmap. I also wonder if this is a good solution in terms of performance and memory usage.
Luca hofmann
source share