diff --git a/cocos2dx/actions/CCAction.cpp b/cocos2dx/actions/CCAction.cpp index 78b60dafae..515aa53f14 100644 --- a/cocos2dx/actions/CCAction.cpp +++ b/cocos2dx/actions/CCAction.cpp @@ -37,7 +37,7 @@ NS_CC_BEGIN Action::Action() :_originalTarget(NULL) ,_target(NULL) -,_tag(kActionTagInvalid) +,_tag(Action::INVALID_TAG) { } diff --git a/cocos2dx/actions/CCAction.h b/cocos2dx/actions/CCAction.h index 222cf853b8..ad5459a2f5 100644 --- a/cocos2dx/actions/CCAction.h +++ b/cocos2dx/actions/CCAction.h @@ -33,11 +33,6 @@ THE SOFTWARE. NS_CC_BEGIN -enum { - //! Default tag - kActionTagInvalid = -1, -}; - /** * @addtogroup actions * @{ @@ -49,6 +44,9 @@ enum { class CC_DLL Action : public Object, public Clonable { public: + /// Default tag used for all the actions + static const int INVALID_TAG = -1; + Action(void); virtual ~Action(void); diff --git a/cocos2dx/actions/CCActionManager.cpp b/cocos2dx/actions/CCActionManager.cpp index 55e87d637b..3b85f8dd87 100644 --- a/cocos2dx/actions/CCActionManager.cpp +++ b/cocos2dx/actions/CCActionManager.cpp @@ -265,9 +265,9 @@ void ActionManager::removeAction(Action *pAction) } } -void ActionManager::removeActionByTag(unsigned int tag, Object *target) +void ActionManager::removeActionByTag(int tag, Object *target) { - CCASSERT((int)tag != kActionTagInvalid, ""); + CCASSERT(tag != Action::INVALID_TAG, ""); CCASSERT(target != NULL, ""); tHashElement *pElement = NULL; @@ -293,9 +293,9 @@ void ActionManager::removeActionByTag(unsigned int tag, Object *target) // XXX: Passing "const O *" instead of "const O&" because HASH_FIND_IT requries the address of a pointer // and, it is not possible to get the address of a reference -Action* ActionManager::getActionByTag(unsigned int tag, const Object *target) const +Action* ActionManager::getActionByTag(int tag, const Object *target) const { - CCASSERT((int)tag != kActionTagInvalid, ""); + CCASSERT(tag != Action::INVALID_TAG, ""); tHashElement *pElement = NULL; HASH_FIND_INT(_targets, &target, pElement); diff --git a/cocos2dx/actions/CCActionManager.h b/cocos2dx/actions/CCActionManager.h index 2929fc27ad..607cc9b9d7 100644 --- a/cocos2dx/actions/CCActionManager.h +++ b/cocos2dx/actions/CCActionManager.h @@ -83,12 +83,12 @@ public: void removeAction(Action *pAction); /** Removes an action given its tag and the target */ - void removeActionByTag(unsigned int tag, Object *target); + void removeActionByTag(int tag, Object *target); /** Gets an action given its tag an a target @return the Action the with the given tag */ - Action* getActionByTag(unsigned int tag, const Object *target) const; + Action* getActionByTag(int tag, const Object *target) const; /** Returns the numbers of actions that are running in a certain target. * Composable actions are counted as 1 action. Example: diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 69fabed44d..d441eab31c 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -83,7 +83,7 @@ Node::Node(void) , _children(NULL) , _parent(NULL) // "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true -, _tag(kNodeTagInvalid) +, _tag(Node::INVALID_TAG) // userData is always inited as nil , _userData(NULL) , _userObject(NULL) @@ -530,7 +530,7 @@ void Node::childrenAlloc(void) Node* Node::getChildByTag(int aTag) { - CCASSERT( aTag != kNodeTagInvalid, "Invalid tag"); + CCASSERT( aTag != Node::INVALID_TAG, "Invalid tag"); if(_children && _children->count() > 0) { @@ -625,7 +625,7 @@ void Node::removeChild(Node* child, bool cleanup /* = true */) void Node::removeChildByTag(int tag, bool cleanup/* = true */) { - CCASSERT( tag != kNodeTagInvalid, "Invalid tag"); + CCASSERT( tag != Node::INVALID_TAG, "Invalid tag"); Node *child = this->getChildByTag(tag); @@ -976,13 +976,13 @@ void Node::stopAction(Action* action) void Node::stopActionByTag(int tag) { - CCASSERT( tag != kActionTagInvalid, "Invalid tag"); + CCASSERT( tag != Action::INVALID_TAG, "Invalid tag"); _actionManager->removeActionByTag(tag, this); } Action * Node::getActionByTag(int tag) { - CCASSERT( tag != kActionTagInvalid, "Invalid tag"); + CCASSERT( tag != Action::INVALID_TAG, "Invalid tag"); return _actionManager->getActionByTag(tag, this); } diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index bfd830d72e..875375bd7b 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -58,10 +58,6 @@ class ComponentContainer; * @{ */ -enum { - kNodeTagInvalid = -1, -}; - enum { kNodeOnEnter, kNodeOnExit, @@ -128,6 +124,9 @@ enum { class CC_DLL Node : public Object { public: + /// Default tag used for all the nodes + static const int INVALID_TAG = -1; + /// @{ /// @name Constructor, Distructor and Initializers diff --git a/cocos2dx/include/CCDeprecated.h b/cocos2dx/include/CCDeprecated.h index ee31c2829a..df5a23a510 100644 --- a/cocos2dx/include/CCDeprecated.h +++ b/cocos2dx/include/CCDeprecated.h @@ -936,8 +936,8 @@ CC_DEPRECATED_ATTRIBUTE typedef TransitionScene::Orientation tOrientation; CC_DEPRECATED_ATTRIBUTE const int kCCPrioritySystem = Scheduler::PRIORITY_SYSTEM; CC_DEPRECATED_ATTRIBUTE const int kCCPriorityNonSystemMin = Scheduler::PRIORITY_NON_SYSTEM_MIN; -CC_DEPRECATED_ATTRIBUTE const int kCCActionTagInvalid = kActionTagInvalid; -CC_DEPRECATED_ATTRIBUTE const int kCCNodeTagInvalid = kNodeTagInvalid; +CC_DEPRECATED_ATTRIBUTE const int kCCActionTagInvalid = Action::INVALID_TAG; +CC_DEPRECATED_ATTRIBUTE const int kCCNodeTagInvalid = Node::INVALID_TAG; CC_DEPRECATED_ATTRIBUTE const int kCCNodeOnEnter = kNodeOnEnter; CC_DEPRECATED_ATTRIBUTE const int kCCNodeOnExit = kNodeOnExit;