Touch end don't works

Hi, I have converted my game to cocos3.5… but I have a problem with the input;
I have created this:

_listener = EventListenerTouchOneByOne::create();
_listener->setSwallowTouches(true);

_listener->onTouchBegan = [this](Touch* touch, Event* event){
    
    this->TouchBegan(touch, event);
    
    return false;
};

_listener->onTouchMoved = [this](Touch* touch, Event* event){
    
    this->TouchMoved(touch, event);
    
    return;
};

_listener->onTouchEnded = [this](Touch* touch, Event* event){
    
    this->TouchEnded(touch, event);
    
    return;
};

_listener->onTouchCancelled = [this](Touch* touch, Event* event){
    
    this->TouchCancelled(touch, event);
    
    return;
};

Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_listener, 1000);

The system, call correctly onTouchBegan but onTouchEnded don’t works… where I wrong?

Thanks!

When using TouchOneByOne functionality, the return value of onTouchBegan tells cocos whether you want to consider the touch. A value of true will ‘register’ this listener for subsequent calls regarding this touch, where as false (as you have it) will mean the listener will receive no more calls regarding the touch. This is done to minimise redundant calls in complex UI (e.g. if touch down wasn’t in my area, I don’t need to know anything more about this touch).

Hope this helps.

1 Like

Thanks! I have resolved!