Do i need to set addEventListenerWithSceneGraphPriority for each sprite i want to detect ?

i want to detect if sprite has touched.
if i do :

auto listener = EventListenerTouchOneByOne::create(); listener->setSwallowTouches(true); listener->onTouchBegan = CC_CALLBACK_2(HelloWorld::onTouchBegan, this); listener->onTouchMoved = CC_CALLBACK_2(HelloWorld::onTouchMoved, this); listener->onTouchEnded = CC_CALLBACK_2(HelloWorld::onTouchEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener->clone(), mySprite);

and then in my tuch method i do
bool HelloWorld::onTouchBegan(Touch* touch, Event* event) auto spriteBlock = static_cast<Block*>(event->getCurrentTarget());

the sprite is detected fine.

the problem is i have like 20 sprites on the layer and i need to be able to detect them all
do i need to set
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener->clone(), mySprite);

for each sprite?

You could wrap a new class for your custom sprite. And adding touch listener in the constructor of that class.