diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 79516d6f8a..220bbe564e 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -126,6 +126,8 @@ Node::Node(void) , _isTransitionFinished(false) , _updateScriptHandler(0) , _componentContainer(NULL) +, _eventPriority(0) +, _oldEventPriority(0) { // set default scheduler and actionManager Director *director = Director::getInstance(); @@ -1307,9 +1309,11 @@ void Node::dissociateEventListener(EventListener* listener) void Node::removeAllEventListeners() { + auto dispatcher = EventDispatcher::getInstance(); + for (auto& listener : _eventlisteners) { - EventDispatcher::getInstance()->removeEventListener(listener); + dispatcher->removeEventListener(listener); } } diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index 66f503878d..8c7032675d 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -1464,8 +1464,9 @@ protected: ComponentContainer *_componentContainer; ///< Dictionary of components - int _eventPriority; - static int _globalEventPriorityIndex; + int _eventPriority; ///< The scene graph based priority of event listener. + int _oldEventPriority; ///< The old scene graph based priority of event listener. + static int _globalEventPriorityIndex; ///< The index of global event priority. }; //#pragma mark - NodeRGBA