From bfdc2a0efec227cd966c9f75b4053d7c937100cc Mon Sep 17 00:00:00 2001 From: James Chen Date: Sun, 15 Sep 2013 18:25:44 +0800 Subject: [PATCH] [dispatcher] Adding argument for whether to sort listeners when dispatching events. --- cocos2dx/event_dispatcher/CCEventDispatcher.cpp | 5 +++-- cocos2dx/event_dispatcher/CCEventDispatcher.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cocos2dx/event_dispatcher/CCEventDispatcher.cpp b/cocos2dx/event_dispatcher/CCEventDispatcher.cpp index 3ecaabe91c..a0a6880c67 100644 --- a/cocos2dx/event_dispatcher/CCEventDispatcher.cpp +++ b/cocos2dx/event_dispatcher/CCEventDispatcher.cpp @@ -217,12 +217,13 @@ void EventDispatcher::setPriorityWithFixedValue(EventListener* listener, int fix } } -void EventDispatcher::dispatchEvent(Event* event) +void EventDispatcher::dispatchEvent(Event* event, bool toSortListeners) { if (_listeners == nullptr || !_isEnabled) return; - sortAllEventListenerItemsForType(event->_type); + if (toSortListeners) + sortAllEventListenerItemsForType(event->_type); DispatchGuard guard(_inDispatch); diff --git a/cocos2dx/event_dispatcher/CCEventDispatcher.h b/cocos2dx/event_dispatcher/CCEventDispatcher.h index 8a1748da88..cb0cf75684 100644 --- a/cocos2dx/event_dispatcher/CCEventDispatcher.h +++ b/cocos2dx/event_dispatcher/CCEventDispatcher.h @@ -91,7 +91,7 @@ public: * Also removes all EventListeners marked for deletion from the * event dispatcher list. */ - void dispatchEvent(Event* event); + void dispatchEvent(Event* event, bool toSortListeners = true); public: /** Destructor of EventDispatcher */