bool MyLayer::init()
{
if ( !Layer::init() )
{
return false;
}
//设置为多点响应
setTouchMode(Touch::DispatchMode::ALL_AT_ONCE);
addTouchEvent();
return true;
}
void MyLayer::addTouchEvent()
{
//多点触摸事件
auto multiTouchListener = EventListenerTouchAllAtOnce::create();
multiTouchListener->setEnabled(true);
multiTouchListener->onTouchesBegan = =](const std::vector<Touch*>& touches, Event *event) {
CCLOG("onTouchesBegan");
};
multiTouchListener->onTouchesMoved = =](const std::vector<Touch*>& touches, Event *event) {
CCLOG("touch count is %ld", touches.size());
};
multiTouchListener->onTouchesEnded = =](const std::vector<Touch*>& touches, Event *event) {
};
multiTouchListener->onTouchesCancelled = =](const std::vector<Touch*>& touches, Event *event) {
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(multiTouchListener, this);
}
上面的代码,onTouchesMoved事件中输出的touches.size()总是1,各种修改调试都是1,怀疑是不是3.1.1引擎有bug?