如果一个类中同时注册两个监听事件,
例如注册按键监听事件_eventDispatcher,代码如下:
auto listener = EventListenerKeyboard::create();
listener->onKeyPressed = [=](cocos2d::EventKeyboard::KeyCode keyCode, Event* event) {
keys[keyCode] = true;
};
listener->onKeyReleased = [=](cocos2d::EventKeyboard::KeyCode keyCode, Event* event) {
keys[keyCode] = false;
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
以及注册鼠标监听事件_eventDispatcher_3,代码如下:
this->_mouseListener_3->onMouseDown = CC_CALLBACK_1(first::onMouseDown, this);
this->_mouseListener_3->onMouseUp = CC_CALLBACK_1(first::onMouseUp, this);
this->_mouseListener_3->onMouseMove = CC_CALLBACK_1(first::onMouseMove, this);
_eventDispatcher_3->addEventListenerWithSceneGraphPriority(_mouseListener_3, this);
结果按下鼠标后按键就无法响应。该如何解决?