diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 1b53b0a5c9..a35dbba089 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -85,7 +85,7 @@ bool nodeComparisonLess(Object* p1, Object* p2) // XXX: Yes, nodes might have a sort problem once every 15 days if the game runs at 60 FPS and each frame sprites are reordered. static int s_globalOrderOfArrival = 1; -static int _globalEventPriorityIndex = 0; +int Node::_globalEventPriorityIndex = 0; Node::Node(void) : _rotationX(0.0f) @@ -826,7 +826,7 @@ void Node::visit() } // self draw this->draw(); - this->updateEventPriorityIndex(); + _eventPriority = ++_globalEventPriorityIndex; for( ; i < _children->count(); i++ ) { @@ -838,7 +838,7 @@ void Node::visit() else { this->draw(); - this->updateEventPriorityIndex(); + _eventPriority = ++_globalEventPriorityIndex; } // reset for next frame @@ -1296,11 +1296,6 @@ void Node::resetEventPriorityIndex() _globalEventPriorityIndex = 0; } -void Node::updateEventPriorityIndex() -{ - _eventPriority = ++_globalEventPriorityIndex; -} - void Node::associateEventListener(EventListener* listener) { _eventlisteners.insert(listener); diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index abaa0741f7..77e0d94c96 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -1381,7 +1381,7 @@ private: protected: - void updateEventPriorityIndex(); + inline void updateEventPriorityIndex() { _eventPriority = ++_globalEventPriorityIndex; }; /// lazy allocs void childrenAlloc(void); @@ -1461,6 +1461,7 @@ protected: ComponentContainer *_componentContainer; ///< Dictionary of components int _eventPriority; + static int _globalEventPriorityIndex; }; //#pragma mark - NodeRGBA