cocos2d-x 3.9 multi-touch iOS monitoring is invalid (only single-touch can be monitored)

The implementation method is directly on the code:

    virtual void onTouchesBegan(const std::vector<Touch*>& touches, Event *unused_event) override;
    virtual void onTouchesMoved(const std::vector<Touch*>& touches, Event *unused_event) override;
    virtual void onTouchesEnded(const std::vector<Touch*>& touches, Event *unused_event) override;
    virtual void onTouchesCancelled(const std::vector<Touch*>&touches, Event *unused_event) override;
Inherit the code in Layer's MyNode init:
    this->setTouchMode(Touch::DispatchMode::ALL_AT_ONCE);
    
    EventDispatcher* eventDispatcher = Director::getInstance()->getEventDispatcher();

    auto listener = EventListenerTouchAllAtOnce::create();
    listener->onTouchesBegan = CC_CALLBACK_2(RockerNode::onTouchesBegan, this);
    listener->onTouchesMoved = CC_CALLBACK_2(RockerNode::onTouchesMoved, this);
    listener->onTouchesEnded = CC_CALLBACK_2(RockerNode::onTouchesEnded, this);
    listener->onTouchesCancelled = CC_CALLBACK_2(RockerNode::onTouchesCancelled, this);
    eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);

void MyNode::onTouchesBegan(const std::vector<Touch*>& touches, Event *unused_event)
{
    CCLOG("onTouchesBegan");
    for (auto &item: touches)      
    {
        auto touch = item;
        auto location = touch->getLocation();
        CCLOG("==%d,(%f,%f)",(int)this->getRockerID(),location.x,location.y);
        }

    }
}

void MyNode::onTouchesMoved(const std::vector<Touch*>& touches, Event *unused_event)
{
    CCLOG("onTouchesMoved");
}

void MyNode::onTouchesEnded(const std::vector<Touch*>& touches, Event *unused_event)
{
    CCLOG("onTouchesEnded");
}


void MyNode::onTouchesCancelled(const std::vector<Touch*>&touches, Event *unused_event)
{
    CCLOG("onTouchesCancelled");
}

Use the following methods to check whether the monitoring is valid:

CCLOG("====%d",listener->checkAvailable());
The result of printing is "====0", congratulations, it is saved, open AppController.mm, and find:
[eaglView setMultipleTouchEnabled:NO];
Do you understand now? ! Just change NO to YES

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326644990&siteId=291194637