[3.0] EventDispatcherTouch on Sprite

Hi all,
Brand new to cocos2dx and figured I’d get started with 3.0. So that said, I may be completely misunderstanding the point of the per-node event listener introduced in 3.0. Documentation still seems sparse.

So I basically have a layer with a single sprite. I attach the sprite to a listener but even when I click outside of the sprite the event still fires. The sprite is 50x50 but as you can see from the log the event fires no matter where I click on the screen.

[edit] My expectation was that adding a listener to a sprite would only fire if I touch that specific sprite. Then any touches outside that sprite would flow up the chain, starting at BoardLayer (which doesn’t have any handlers in this case) and thus be discarded.

Thanks,

bool BoardLayer::init()
{
    if (!Layer::init())
        return false;

    auto number1Sprite = Sprite::createWithSpriteFrameName("number1.png");
    number1Sprite->setPosition(Point(0, 0));
    this->addChild(number1Sprite, 1);

    // add touch handlers
    auto listener = EventListenerTouchOneByOne::create();
    listener->setSwallowTouches(true);
    listener->onTouchBegan = [](Touch* touch, Event* event) {
        CCLOG("onTouchBegan for sprite @ (%f, %f)", touch->getLocation().x, touch->getLocation().y);
        return true;
    };
    this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, number1Sprite);

    return true;
}

cocos2d: onTouchBegan for sprite @ (287.011871, 507.946167)
cocos2d: onTouchBegan for sprite @ (101.346001, 284.376892)
cocos2d: onTouchBegan for sprite @ (395.802124, 228.343491)
cocos2d: onTouchBegan for sprite @ (506.529480, 206.461411)
cocos2d: onTouchBegan for sprite @ (412.720215, 188.428970)
cocos2d: onTouchBegan for sprite @ (488.690430, 513.824219)
cocos2d: onTouchBegan for sprite @ (473.878815, 731.805176)
cocos2d: onTouchBegan for sprite @ (283.070099, 766.682007)
cocos2d: onTouchBegan for sprite @ (150.152878, 806.628113)
cocos2d: onTouchBegan for sprite @ (69.246735, 792.636841)
cocos2d: onTouchBegan for sprite @ (51.281078, 651.654785)
cocos2d: onTouchBegan for sprite @ (66.280289, 488.893097)

Yep, you should do `hitTest` in the `onTouchBegan` callback by yourself.
You could imagine that if an object without a content size will not be abled to get the touch response.
`hitTest` needs to be done by developer himself.