I have a ui::ScrollView containing a number of sprites.
I have created each sprite and added a touch listener to each sprite by doing something like:
for(int i=0; i < 5; i++){
Sprite* foo = Sprite::createWithSpriteFrameName("foo");
myScrollView->addChild(foo);
auto listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = [this,somestring](Touch* touch, Event* event){
......some code
};
listener->onTouchMoved = [foo,this,somestring](Touch* touch, Event* event){
......some code
};
listener->onTouchEnded = [foo,this,somestring](Touch* touch, Event* event){
......some code
};
foo->getEventDispatcher->addEventListenerWithSceneGraphPriority(listener1,foo);
}
The problem is, if I click ANYWHERE on screen, it seems to trigger the touch events of ALL the sprites created in the loop. Is there something incorrect in how I am creating the listener, or does it have to do with some conflict with touches in a ui::ScrollView ?
I am using v 3.10