EventListener for variable number of sprites [SOLVED]

Hello,

I am using cocos2d-x-3.0beta2.

I am currently developing a game that requires a variable number of listeners for sprites. The sprites are all of the same image, but the user should only be able to move the sprite they are touching.

The problem I am facing is that the dispatcher is triggering the event multiple times and it is causing all the sprites to change and if I setSwallowTrue, then the graph priority causes only one of the sprites to move or change at all.

How do I check for each sprite individually without affecting the other sprites?

The code is located at https://github.com/tuxagon/alphafirefly

I have been experimenting and I found a nifty little function that is part of the Event class. The function stopPropagation() solved the issue by preventing the layer from looking any further at sprites on the same layer. I just tossed this function in the onTouchBegan function that is part of the event listener and it solved all the issues. I believe this is the correct way to do it as well. :slight_smile: