CCAction* CCActionManager::getActionByTag(unsigned int tag, CAObject *pTarget) { CCAssert((int)tag != kCCActionTagInvalid, ""); tHashElement *pElement = NULL; HASH_FIND_INT(m_pTargets, &pTarget, pElement); if (pElement) { if (pElement->actions != NULL) { unsigned int limit = pElement->actions->num; for (unsigned int i = 0; i < limit; ++i) { CCAction *pAction = (CCAction*)pElement->actions->arr[i]; if (pAction->getTag() == (int)tag) { return pAction; } } } CCLOG("CrossApp : getActionByTag(tag = %d): Action not found", tag); } else { // CCLOG("CrossApp : getActionByTag: Target not found"); } return NULL; }
void CCActionManager::removeActionByTag(int tag, CCObject *pTarget) { assert(tag != kCCActionTagInvalid); assert(pTarget != NULL); tHashElement *pElement = NULL; HASH_FIND_INT(m_pTargets, &pTarget, pElement); if (pElement) { unsigned int limit = pElement->actions->num; for (unsigned int i = 0; i < limit; ++i) { CCAction *pAction = (CCAction*)pElement->actions->arr[i]; if (pAction->getTag() == tag && pAction->getOriginalTarget() == pTarget) { return removeActionAtIndex(i, pElement); } } CCLOG("cocos2d: removeActionByTag: Action not found!"); } else { CCLOG("cocos2d: removeActionByTag: Target not found!"); } }
CCAction* CCActionManager::getActionByTag(int tag, NSObject *pTarget) { assert(tag != kCCActionTagInvalid); tHashElement *pElement = NULL; HASH_FIND_INT(m_pTargets, &pTarget, pElement); if (pElement) { if (pElement->actions != NULL) { unsigned int limit = pElement->actions->num; for (unsigned int i = 0; i < limit; ++i) { CCAction *pAction = (CCAction*)pElement->actions->arr[i]; if (pAction->getTag() == tag) { return pAction; } } } CCLOG("cocos2d : getActionByTag: Action not found"); } else { CCLOG("cocos2d : getActionByTag: Target not found"); } return NULL; }
void CCActionManager::removeActionByTag(unsigned int tag, CAObject *pTarget) { CCAssert((int)tag != kCCActionTagInvalid, ""); CCAssert(pTarget != NULL, ""); tHashElement *pElement = NULL; HASH_FIND_INT(m_pTargets, &pTarget, pElement); if (pElement) { unsigned int limit = pElement->actions->num; for (unsigned int i = 0; i < limit; ++i) { CCAction *pAction = (CCAction*)pElement->actions->arr[i]; if (pAction->getTag() == (int)tag && pAction->getOriginalTarget() == pTarget) { removeActionAtIndex(i, pElement); break; } } } }