1592 auto origin = Director::getInstance()->getVisibleOrigin();
1593 auto size = Director::getInstance()->getVisibleSize();
1594 static bool nodesAdded =
false;
1598 _listener = getEventDispatcher()->addCustomEventListener(Director::EVENT_AFTER_UPDATE, [
this](cocos2d::EventCustom *event){
1602 getEventDispatcher()->dispatchCustomEvent(
"Issue8194");
1605 getEventDispatcher()->removeCustomEventListeners(
"Issue8194");
1606 removeChildByTag(
tagA);
1607 removeChildByTag(
tagB);
1614 auto menuItem = MenuItemFont::create(
"Dispatch Custom Event", [
this](Ref *sender) {
1616 auto nodeA = Node::create();
1617 addChild(nodeA, 1,
tagA);
1619 cocos2d::EventListenerCustom* listenerA = cocos2d::EventListenerCustom::create(
"Issue8194", [&](cocos2d::EventCustom *event){
1621 event->stopPropagation();
1623 getEventDispatcher()->addEventListenerWithSceneGraphPriority(listenerA, nodeA);
1626 auto nodeB = Node::create();
1627 addChild(nodeB, -1,
tagB);
1629 cocos2d::EventListenerCustom* listenerB = cocos2d::EventListenerCustom::create(
"Issue8194", [&](cocos2d::EventCustom *event){
1631 event->stopPropagation();
1633 getEventDispatcher()->addEventListenerWithSceneGraphPriority(listenerB, nodeB);
1638 menuItem->setPosition(origin.x + size.width/2, origin.y + size.height/2);
1639 auto menu = Menu::create(menuItem,
nullptr);
1640 menu->setPosition(Vec2::ZERO);
cocos2d::EventListenerCustom * _listener
cocos2d::Label * _subtitleLabel