Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17070

Event stopPropagation() and isStopped()

$
0
0

@uid4o wrote:

Hi there,

I'm having two partially overlapping sprites, each having its own eventListenerTouchOneByOne with fixed priority set to PositionY and setSwallowTouch(false) and I need to stop the second sprite from executing onTouchEnded. So I've decided to stopPropagation of the event in the onTouchEnded method and check with isStopped if the event is stopped from propagation but isStopped() keep returning false?

    myListener = EventListenerTouchOneByOne::create();
    myListener->setSwallowTouches(false);
    myListener->onTouchBegan = [&](Touch *touch, Event *event)
    {
         .....
    };

    myListener->onTouchMoved = [&](Touch *touch, Event *event)
    {
         ....
    };

    myListener->onTouchEnded = [&](Touch *touch, Event *event)
    {
         if(!event->isStopped())
         {
             ......
             event->stopPropagation();
         }
        else
        {
            ......
        }
   };
    Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(myListener, this->getPositionY());

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 17070

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>