예제 #1
0
void ActionManager::removeActionsByFlags(unsigned int flags, Node *target)
{
    if (flags == 0)
    {
        return;
    }
    CCASSERT(target != nullptr, "target can't be nullptr!");
    if (target == nullptr)
    {
        return;
    }

    tHashElement *element = nullptr;
    HASH_FIND_PTR(_targets, &target, element);

    if (element)
    {
        auto limit = element->actions->num;
        for (int i = 0; i < limit;)
        {
            Action *action = (Action*)element->actions->arr[i];

            if ((action->getFlags() & flags) != 0 && action->getOriginalTarget() == target)
            {
                removeActionAtIndex(i, element);
                --limit;
            }
            else
            {
                ++i;
            }
        }
    }
}
예제 #2
0
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!");
	}
}
예제 #3
0
void ActionManager::removeAllActionsByTag(int tag, Node *target)
{
    CCASSERT(tag != Action::INVALID_TAG, "Invalid tag value!");
    CCASSERT(target != nullptr, "target can't be nullptr!");
    if (target == nullptr)
    {
        return;
    }
    
    tHashElement *element = nullptr;
    HASH_FIND_PTR(_targets, &target, element);
    
    if (element)
    {
        auto limit = element->actions->num;
        for (int i = 0; i < limit;)
        {
            Action *action = (Action*)element->actions->arr[i];
            
            if (action->getTag() == (int)tag && action->getOriginalTarget() == target)
            {
                removeActionAtIndex(i, element);
                --limit;
            }
            else
            {
                ++i;
            }
        }
    }
}
예제 #4
0
void CCActionManager::removeAction(CCAction *pAction)
{
    // explicit null handling
    // 确定处理, null
    if (pAction == NULL)
    {
        return;
    }

    tHashElement *pElement = NULL;
    CCObject *pTarget = pAction->getOriginalTarget();
    HASH_FIND_INT(m_pTargets, &pTarget, pElement);
    if (pElement)
    {
        unsigned int i = ccArrayGetIndexOfObject(pElement->actions, pAction);
        if (UINT_MAX != i)
        {
            removeActionAtIndex(i, pElement);
        }
    }
    else
    {
        CCLOG("cocos2d: removeAction: Target not found");
    }
}
예제 #5
0
void ActionManager::removeAction(Action *action)
{
    // explicit null handling
    if (action == nullptr)
    {
        return;
    }

    tHashElement *element = nullptr;
    Ref *target = action->getOriginalTarget();
    HASH_FIND_PTR(_targets, &target, element);
    if (element)
    {
        auto i = ccArrayGetIndexOfObject(element->actions, action);
        if (i != CC_INVALID_INDEX)
        {
            removeActionAtIndex(i, element);
        }
    }
}
예제 #6
0
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;
            }
        }
    }
}
예제 #7
0
void ActionManager::removeActionByTag(int tag, Node *target)
{
    CCASSERT(tag != Action::INVALID_TAG, "");
    CCASSERT(target != nullptr, "");

    tHashElement *element = nullptr;
    HASH_FIND_PTR(_targets, &target, element);

    if (element)
    {
        auto limit = element->actions->num;
        for (int i = 0; i < limit; ++i)
        {
            Action *action = (Action*)element->actions->arr[i];

            if (action->getTag() == (int)tag && action->getOriginalTarget() == target)
            {
                removeActionAtIndex(i, element);
                break;
            }
        }
    }
}
void ActionManager::removeActionByTag(int tag, Object *target)
{
    CCASSERT(tag != Action::INVALID_TAG, "");
    CCASSERT(target != NULL, "");

    tHashElement *element = NULL;
    HASH_FIND_PTR(m_pTargets, &target, element);

    if (element)
    {
        long limit = element->actions->num;
        for (long i = 0; i < limit; ++i)
        {
            Action *action = (Action*)element->actions->arr[i];

            if (action->getTag() == (int)tag && action->getOriginalTarget() == target)
            {
                removeActionAtIndex(i, element);
                break;
            }
        }
    }
}
void ActionManager::removeAction(Action *action)
{
    // explicit null handling
    if (action == NULL)
    {
        return;
    }

    tHashElement *element = NULL;
    Object *target = action->getOriginalTarget();
    HASH_FIND_PTR(m_pTargets, &target, element);
    if (element)
    {
        long i = ccArrayGetIndexOfObject(element->actions, action);
        if (i != CC_INVALID_INDEX)
        {
            removeActionAtIndex(i, element);
        }
    }
    else
    {
        CCLOG("cocos2d: removeAction: Target not found");
    }
}