Exemplo n.º 1
0
void ActorLayer::ActorEndCast(flownet::ActorID invokerActorID, flownet::SpellType spellType, flownet::POINT destination)
{
    Actor* actor = GameClient::Instance().GetClientStage()->FindActor(invokerActorID);
    ActorNode* invokerObject = this->FindPlayerNode(invokerActorID);
    
    SpellInfo spellInfo = SpellDictionary::Instance().FindSpellInfoBySpellType(spellType);
    
    if(!actor)
    {
        ASSERT_DEBUG(actor);
        return;
    }
    
    if( !actor->IsAlive() )
    {
        CCLOG("ActorLayer::ActorEndCast >> ignore fire spell request. player is dead");
        return;
    }
    
    this->UpdateActorLookingDirection(actor, invokerObject->getPosition(), PointConverter::Convert(destination));
    invokerObject->StopAnimationActions();
    CCFiniteTimeAction* animateFire = CCCallFunc::create(invokerObject, callfunc_selector(ActorNode::AnimateFire));
    CCFiniteTimeAction* timeDuration = CCDelayTime::create(Player_Fire_Duration);
    CCFiniteTimeAction* animateFireDone = CCCallFunc::create(invokerObject, callfunc_selector(ActorNode::AnimateIdle));
    CCAction* sequence = CCSequence::create(animateFire, timeDuration, animateFireDone, NULL);
    sequence->setTag(ActionType_Animation);
    invokerObject->runAction(sequence);
    
    
    this->RemoveSpellGuideLine(invokerActorID);
    
    this->FireSpell(invokerActorID, destination, spellInfo);
}
Exemplo n.º 2
0
void ActorLayer::ActorAttacked(flownet::ActorID attackedActorID, flownet::ActorID attackerActorID)
{
    Actor* actor = GameClient::Instance().GetClientStage()->FindActor(attackedActorID);
    
    if(!actor)
    {    
        return;
    }
    
    if( !actor->IsAlive() )
    {
        CCLOG("ActorLayer::ActorAttacked >> ignore player attacked request. player is dead");
        return;
    }

    if(actor->GetActorState() == ActorState_Idle)
    {
        ActorNode* attackedObject = this->FindActorNode(attackedActorID);
        attackedObject->StopAnimationActions();
        CCFiniteTimeAction* animateAttacked = CCCallFunc::create(attackedObject, callfunc_selector(ActorNode::AnimateAttacked));
        CCFiniteTimeAction* timeDuration = CCDelayTime::create(Player_Stiff_Duration);
        CCFiniteTimeAction* animateAttackedDone = CCCallFunc::create(attackedObject, callfunc_selector(ActorNode::AnimateIdle));
        CCAction* sequence = CCSequence::create(animateAttacked, timeDuration, animateAttackedDone, NULL);
        sequence->setTag(ActionType_Animation);
        attackedObject->runAction(sequence);
    }
}
Exemplo n.º 3
0
void ActorLayer::ActorAttack(flownet::ActorID attackerActorID, flownet::ActorID targetActorID)
{
    Actor* actor = GameClient::Instance().GetClientStage()->FindActor(attackerActorID);
    ActorNode* attackingObject = this->FindActorNode(attackerActorID);
    ActorNode* targetObject = this->FindActorNode(targetActorID);
    
    if(!actor)
    {
        return;
    }
    
    ASSERT_DEBUG(attackingObject);
    ASSERT_DEBUG(targetObject);
    
    if( !actor->IsAlive() )
    {
        CCLOG("ActorLayer::ActorAttack >> ignore actor's attack request. actor is dead");
        return;
    }

    ASSERT_DEBUG(actor->GetAttackSpeed() != 0);

    float attackDuration = 1 / actor->GetAttackSpeed();

    attackingObject->StopAnimationActions();
    this->UpdateActorLookingDirection(actor, attackingObject->getPosition(), targetObject->getPosition());
    CCFiniteTimeAction* animateAttack = CCCallFunc::create(attackingObject, callfunc_selector(ActorNode::AnimateAttacking));
    CCFiniteTimeAction* timeDuration = CCDelayTime::create(attackDuration);
    CCFiniteTimeAction* animateIdle = CCCallFunc::create(attackingObject, callfunc_selector(ActorNode::AnimateIdle));
    CCFiniteTimeAction* changeToIdleState = CCCallFuncN::create(this, callfuncN_selector(ActorLayer::ChangeActorStateToIdle));
    CCAction* sequence = CCSequence::create(animateAttack, timeDuration, animateIdle, changeToIdleState, NULL);
    sequence->setTag(ActionType_Animation);
    attackingObject->runAction(sequence);
}
Exemplo n.º 4
0
void GameLayer::playerJump()
{
    // check whether can jump
    CCSprite *playerSprite = (CCSprite *)this->getChildByTag(PlayerTag);
    if (playerSprite->getActionByTag(PlayerChangeRoadTag)) {
        return;
    }
    if (playerSprite->getActionByTag(PlayerJumppingTag)) {
        // already jump
        return;
    }
    
    CCScaleTo *scaleTo = CCScaleTo::create(0.2, 1.2);
    CCDelayTime *delay = CCDelayTime::create(0.6);
    CCScaleTo *scaleBack = CCScaleTo::create(0.2, 1.0);
    CCAction *action = CCSequence::create(scaleTo, delay, scaleBack, CCCallFunc::create(this, callfunc_selector(GameLayer::playerRun)), NULL);
    action->setTag(PlayerJumppingTag);
    
    if (isSliding) {
        playerSprite->stopActionByTag(PlayerSlidingTag);
        isSliding = false;
    }
    isJumpping = true;
    playerSprite->runAction(action);
}
Exemplo n.º 5
0
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;
}
Exemplo n.º 6
0
//------------------------------------------------------------------
//
// Test5
//
//------------------------------------------------------------------
Test5::Test5()
{
	CCSprite* sp1 = CCSprite::spriteWithFile(s_pPathSister1);
	CCSprite* sp2 = CCSprite::spriteWithFile(s_pPathSister2);
	
	sp1->setPosition(CCPointMake(100,160));
	sp2->setPosition(CCPointMake(380,160));

	CCRotateBy* rot = CCRotateBy::actionWithDuration(2, 360);
	CCActionInterval* rot_back = rot->reverse();
	CCAction* forever = CCRepeatForever::actionWithAction(
													(CCActionInterval*)(CCSequence::actions(rot, rot_back, NULL)) 
												);
	CCAction* forever2 = (CCAction*)(forever->copy()->autorelease());
	forever->setTag(101);
	forever2->setTag(102);
												  
	addChild(sp1, 0, kTagSprite1);
	addChild(sp2, 0, kTagSprite2);
			
	sp1->runAction(forever);
	sp2->runAction(forever2);
	
	schedule( schedule_selector(Test5::addAndRemove), 2.0f);
}
Exemplo n.º 7
0
void ActorLayer::MoveActor(flownet::ActorID actorID, flownet::POINT currentPosition, flownet::POINT destinationPosition)
{
    Actor* actor = GameClient::Instance().GetClientStage()->FindActor(actorID);
    ASSERT_DEBUG(actor);
    ActorNode* movingObject = this->FindActorNode(actorID);
    ASSERT_DEBUG(movingObject);
    
    if( !actor->IsAlive() )
    {
        CCLOG("ActorLayer::MoveActor >> ignore actor move request. actor is dead");
        return;
    }
    
    float distance = destinationPosition.DistanceTo(currentPosition); // NOTE : using cocos2d object point because of distance is a bit diffence with server's
    
    ASSERT_DEBUG(actor->GetMovingSpeed() != 0);
    float duration = distance / actor->GetMovingSpeed();
    
    this->UpdateActorLookingDirection(actor, movingObject->getPosition(), PointConverter::Convert(destinationPosition));
    movingObject->StopAnimationActions();
    
    CCFiniteTimeAction* animateMove = CCCallFunc::create(movingObject, callfunc_selector(ActorNode::AnimateMoving));
    CCFiniteTimeAction* actionMove = CCMoveTo::create(duration, PointConverter::Convert(destinationPosition));
    CCFiniteTimeAction* actionMoveDone = CCCallFunc::create( movingObject, callfunc_selector(ActorNode::AnimateIdle));
    CCFiniteTimeAction* changeToIdleState = CCCallFuncN::create(this, callfuncN_selector(ActorLayer::ChangeActorStateToIdle));
    CCAction* sequence = CCSequence::create(animateMove, actionMove, actionMoveDone, changeToIdleState, NULL);
    
    // TO DO : show moving point
    sequence->setTag(ActionType_Animation);
    movingObject->runAction(sequence);
}
Exemplo n.º 8
0
void MainLayer::createNewRole()
{
	CCSize vsize = CCDirector::sharedDirector()->getVisibleSize();
	float width = vsize.width / 2;
	float height = vsize.height / 2;
	CCSprite *left = CCSprite::createWithSpriteFrameName("ultraman_big_1.png");
	CCSprite *right = CCSprite::createWithSpriteFrameName("dragon_big_1.png");
	if (CCRANDOM_0_1() < 0.5)
	{
		left->setScale(0.5f);
	}
	else
	{
		right->setScale(0.5f);
	}
	left->setPosition(ccp(-width, -height + 230));
	left->setAnchorPoint(ccp(0, 0));
	this->addChild(left, 3, TAG_LEFT);
	right->setPosition(ccp(width, -height + 230));
	right->setAnchorPoint(ccp(1, 0));
	this->addChild(right, 3, TAG_RIGHT);
	CCAction *leftMoving = CCMoveBy::create(speed, ccp(2 * width, 0));
	CCAction *rightMoving = CCMoveBy::create(speed, ccp(-2 * width, 0));
	leftMoving->setTag(TAG_ACTION_MOVE);
	rightMoving->setTag(TAG_ACTION_MOVE);

	left->runAction(leftMoving);
	right->runAction(rightMoving);
	disappearing = false;

	/*-- 走路动画 --*/
	playRunAnimation();
}
Exemplo n.º 9
0
void SpriteEase::onEnter()
{
    EaseSpriteDemo::onEnter();
    
    CCActionInterval* move = CCMoveBy::create(3, ccp(VisibleRect::right().x-130,0));
    CCActionInterval* move_back = move->reverse();
    
    CCActionInterval* move_ease_in = CCEaseIn::create((CCActionInterval*)(move->copy()->autorelease()), 2.5f);
    CCActionInterval* move_ease_in_back = move_ease_in->reverse();
    
    CCActionInterval* move_ease_out = CCEaseOut::create((CCActionInterval*)(move->copy()->autorelease()), 2.5f);
    CCActionInterval* move_ease_out_back = move_ease_out->reverse();
    
    CCDelayTime *delay = CCDelayTime::create(0.25f);
    
    CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL);
    CCSequence* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL);
    CCSequence* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL);
    
    
    CCAction *a2 = m_grossini->runAction(CCRepeatForever::create(seq1));
    a2->setTag(1);

    CCAction *a1 = m_tamara->runAction(CCRepeatForever::create(seq2));
    a1->setTag(1);

    CCAction *a = m_kathia->runAction(CCRepeatForever::create(seq3));
    a->setTag(1);

    schedule(schedule_selector(SpriteEase::testStopAction), 6.25f);
}
Exemplo n.º 10
0
void HFViewport::scrollToSmooth(const CCPoint& targetPoint, CCCallFunc* callbackFunc,float time)
{
    unscheduleAll();
    mIsProcessingScroll = true;
    do
    {
        this->mTouchMode = TouchMode_Fling;
        CCPoint curPos = this->m_TargetNode->getPosition();
        CCPoint targetPos = targetPoint;
        CCSize winsize = CCDirector::sharedDirector()->getWinSize();
        if (targetPos.x >0.0f) {
            targetPos.x = curPos.x;
        }
        if (targetPos.x <winsize.width-MAP_WIDTH*this->m_TargetNode->getScaleX()){
            targetPos.x = winsize.width-MAP_WIDTH*this->m_TargetNode->getScaleX();
        }
        if (targetPos.y >0.0f) {
            targetPos.y = curPos.y;
        }
        if (targetPos.y <winsize.height-MAP_HEIGHT*this->m_TargetNode->getScaleY()){
            targetPos.y =winsize.height-MAP_HEIGHT*this->m_TargetNode->getScaleY();
        }
        CCMoveTo* move = CCMoveTo::create(time, targetPos);
        CCAction* action = CCSequence::create(move,callbackFunc,NULL);
        action->setTag(FLINGACTION_TAG);
        this->m_TargetNode->runAction(action);
    }
    while(0);
    mIsProcessingScroll = false;
}
Exemplo n.º 11
0
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;
}
//------------------------------------------------------------------
//
// SpriteEase
//
//------------------------------------------------------------------
KDvoid SpriteEase::onEnter ( KDvoid )
{
	TestEaseActions::onEnter ( );
	
    const CCSize&  s = this->getContentSize ( );
    
    CCActionInterval* move = CCMoveBy::create(3, ccp(s.cx-130,0 ) );
    CCActionInterval* move_back = move->reverse();
    
    CCActionInterval* move_ease_in = CCEaseIn::create ( CCCA ( move ), 2.5f);
    CCActionInterval* move_ease_in_back = move_ease_in->reverse();
    
    CCActionInterval* move_ease_out = CCEaseOut::create ( CCCA ( move ), 2.5f);
    CCActionInterval* move_ease_out_back = move_ease_out->reverse();
    
    CCDelayTime *delay = CCDelayTime::create(0.25f);
    
    CCSequence* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), KD_NULL);
    CCSequence* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), KD_NULL);
    CCSequence* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), KD_NULL);
    
    
    CCAction *a2 = m_grossini->runAction(CCRepeatForever::create ( seq1 ) );
    a2->setTag(1);

    CCAction *a1 = m_tamara->runAction(CCRepeatForever::create ( seq2 ) );
    a1->setTag(1);

    CCAction *a = m_kathia->runAction(CCRepeatForever::create ( seq3 ) );
    a->setTag(1);

    schedule(schedule_selector(SpriteEase::testStopAction), 6.25f);

}
Exemplo n.º 13
0
void GameLayer::playerChangeRoad(PlayerMoveDirection direction)
{
    // check wether player can move to the new road
    CCSprite *playerSprite = (CCSprite *)this->getChildByTag(PlayerTag);
    CCPoint playerPos = playerSprite->getPosition();
    
    if (direction == PlayerMoveLeft && playerPos.x < kGameMapSecondRoad) {
        // already move to left
        return;
    }
    if (direction == PlayerMoveRight && playerPos.x > kGameMapSecondRoad) {
        // already move to right
        return;
    }
    if (playerSprite->getActionByTag(PlayerChangeRoadTag)) {
        return;
    }
    
    float distanceX = kGameMapRoadSpace;
    CCGameMoveBy *moveBy = CCGameMoveBy::create(kPlayerChangeRoadDuration, ccp((direction == PlayerMoveLeft ? - distanceX : distanceX), kPlayerChangeRoadDuration * kPlayerRunSpeed));
    CCAction *action = CCSequence::createWithTwoActions(moveBy, CCCallFunc::create(this, callfunc_selector(GameLayer::playerRun)));
    action->setTag(PlayerChangeRoadTag);
    
    if (isSliding) {
        playerSprite->stopActionByTag(PlayerSlidingTag);
        isSliding = false;
    }
    if (isJumpping) {
        playerSprite->stopActionByTag(PlayerJumppingTag);
        isJumpping = false;
    }
    isRunning = true;
    playerSprite->runAction(action);
}
Exemplo n.º 14
0
void ActorLayer::TeleportActor(flownet::ActorID actorID, flownet::POINT currentPosition, flownet::POINT destinationPosition)
{
    Actor* actor = GameClient::Instance().GetClientStage()->FindActor(actorID);
    ASSERT_DEBUG(actor);
    ActorNode* movingObject = this->FindActorNode(actorID);
    ASSERT_DEBUG(movingObject);
    
    if( !actor->IsAlive() )
    {
        CCLOG("ActorLayer::MoveActor >> ignore actor move request. actor is dead");
        return;
    }
    
    this->UpdateActorLookingDirection(actor, movingObject->getPosition(), PointConverter::Convert(destinationPosition));
    movingObject->StopAnimationActions();
    
    // NOTE : 자신한테 텔레포트 이펙트를 붙인채 싱크에 맞춰 이동할 수 있도록 한다
    // NOTE : teleport effect node는 자동 소멸 할 수 있도록 플래그를 켠다
    SpellEffectNode* effectNode = SpellEffectNode::create(actorID, SpellEffectType_Teleport);
    this->addChild(effectNode);
    
    CCFiniteTimeAction* animateMove = CCCallFunc::create(movingObject, callfunc_selector(ActorNode::AnimateMoving));
    CCDelayTime* beforeDelay = CCDelayTime::create(0.1);
    CCFiniteTimeAction* actionMove = CCMoveTo::create(0, PointConverter::Convert(destinationPosition));
    CCDelayTime* afterDelay = CCDelayTime::create(0.1);
    CCFiniteTimeAction* actionMoveDone = CCCallFunc::create( movingObject, callfunc_selector(ActorNode::AnimateIdle));
    CCFiniteTimeAction* changeToIdleState = CCCallFuncN::create(this, callfuncN_selector(ActorLayer::ChangeActorStateToIdle));
    CCAction* sequence = CCSequence::create(animateMove, beforeDelay, actionMove, afterDelay, actionMoveDone, changeToIdleState, NULL);
    
    // TO DO : show moving point
    sequence->setTag(ActionType_Animation);
    movingObject->runAction(sequence);
}
Exemplo n.º 15
0
void SpriteEase::onEnter()
{
	EaseSpriteDemo::onEnter();
	
	CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0) );
	CCActionInterval* move_back = move->reverse();
	
	CCActionInterval* move_ease_in = (CCActionInterval*)CCEaseIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 3.0f);
	CCActionInterval* move_ease_in_back = move_ease_in->reverse();
	
	CCActionInterval* move_ease_out = CCEaseOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 3.0f);
	CCActionInterval* move_ease_out_back = move_ease_out->reverse();
	
	
	CCFiniteTimeAction* seq1 = CCSequence::actions(move, move_back, NULL);
	CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_in, move_ease_in_back, NULL);
	CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_out, move_ease_out_back, NULL);
	
	
	CCAction *a2 = m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1) );
	a2->setTag(1);

	CCAction *a1 = m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2) );
	a1->setTag(1);

	CCAction *a = m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3) );
	a->setTag(1);

	schedule(schedule_selector(SpriteEase::testStopAction), 6);
}
Exemplo n.º 16
0
void SpriteEase::onEnter()
{
    EaseSpriteDemo::onEnter();
    
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    
    CCActionInterval* move = CCMoveBy::create(3, CCPointMake(s.width-130,0));
    CCActionInterval* move_back = move->reverse();
    
    CCActionInterval* move_ease_in = CCEaseIn::create((CCActionInterval*)(move->copy()->autorelease()), 2.5f);
    CCActionInterval* move_ease_in_back = move_ease_in->reverse();
    
    CCActionInterval* move_ease_out = CCEaseOut::create((CCActionInterval*)(move->copy()->autorelease()), 2.5f);
    CCActionInterval* move_ease_out_back = move_ease_out->reverse();
    
    CCDelayTime *delay = CCDelayTime::create(0.25f);
    
    CCFiniteTimeAction* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL);
    CCFiniteTimeAction* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL);
    CCFiniteTimeAction* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL);
    
    
    CCAction *a2 = m_grossini->runAction(CCRepeatForever::create((CCActionInterval*)seq1));
    a2->setTag(1);

    CCAction *a1 = m_tamara->runAction(CCRepeatForever::create((CCActionInterval*)seq2));
    a1->setTag(1);

    CCAction *a = m_kathia->runAction(CCRepeatForever::create((CCActionInterval*)seq3));
    a->setTag(1);

    schedule(schedule_selector(SpriteEase::testStopAction), 6.25f);
}
Exemplo n.º 17
0
void GameScene::addPig()
{
    const static int fameCount = 3;
    const static float animationDuration = 0.15f;

    CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache();
    cache->addSpriteFramesWithFile("pigs.plist");

    m_pPig = CCSprite::createWithSpriteFrameName("pig1");
    m_pPig->retain();
    m_pPig->setScale(0.7f);
    m_pPig->setZOrder(1);
    m_pPig->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width / 3, m_VisibleOrigin.y + m_VisibleSize.height / 2));
    addChild(m_pPig);

    CCArray *animFrames = CCArray::createWithCapacity(fameCount);
    for(int i = 1; i <= fameCount; i++)
    {
        CCSpriteFrame* frame = cache->spriteFrameByName(CCString::createWithFormat("pig%d", i)->getCString());
        animFrames->addObject(frame);
    }

    CCAction *action = CCRepeatForever::create(CCAnimate::create(CCAnimation::createWithSpriteFrames(animFrames, animationDuration)));
    action->setTag(kTagFlutter);
    m_pPig->runAction(action);
}
Exemplo n.º 18
0
// When activated, scale the parent CCNode by the value of the activatedScale property.
// The current scale value of the parent is cached again, in case that scale had been
// changed since this adornment was added to the parent. We do not simply use a deactivation
// scale of 1 / activationScale in case the activation scaling is interrupted by the
// deactivation, and has not fully scaled up at the time the deactivation starts.
// The action is tagged so that it can be easily found if it needs to be cancelled.
void CCNodeAdornmentScaler::activate()
{
	CCNode* p = getParent();
	if ( p == NULL )
		return;

	CCAction* currAction = p->getActionByTag( kScaleActionTag );
	if ( currAction ) 
	{
		// if we already have an active action, cancel it
		p->stopAction( currAction );
	} 
	else
	{
		// only cache scale if a scaling action is not active
		// because otherwise scale will be evolvin and we'll cache something halfway
		setOriginalScaleFromParent();
	}
	// use scaleTo instead of scaleBy so that final size is deterministic in the case
	// where we have interrupted an active scaling action above
	float finalScaleX = _originalScale.width * _activatedScale.width;
	float finalScaleY = _originalScale.height * _activatedScale.height;
	CCAction* scaleAction = CCActionScaleTo::create( getActionDuration(), finalScaleX, finalScaleY );
	scaleAction->setTag( kScaleActionTag );
	p->runAction( scaleAction );
}
Exemplo n.º 19
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!");
	}
}
Exemplo n.º 20
0
void CCControlButton::setHighlighted(bool enabled)
{
    if (enabled == true)
    {
        m_eState = CCControlStateHighlighted;
    }
    else
    {
        m_eState = CCControlStateNormal;
    }
    
    CCControl::setHighlighted(enabled);

    CCAction *action = getActionByTag(kZoomActionTag);
    if (action)
    {
        stopAction(action);        
    }
    needsLayout();
    if( m_zoomOnTouchDown )
    {
        float scaleValue = (isHighlighted() && isEnabled() && !isSelected()) ? 1.1f : 1.0f;
        CCAction *zoomAction = CCScaleTo::create(0.05f, scaleValue);
        zoomAction->setTag(kZoomActionTag);
        runAction(zoomAction);
    }
}
Exemplo n.º 21
0
void ToTextLayer::RegistAA(){
	if(e_layerstate == 1) return;
	e_layerstate = 3;
	CCLOG(">RegistAA");
	stopActionByTag(AUTO_ACTION_TAG);
	CCAction* au = CCSequence::create(CCDelayTime::create(m_fTAuto),CCCallFunc::create(this,callfunc_selector(ToTextLayer::AutoNext)),NULL);
	au->setTag(AUTO_ACTION_TAG);
	runAction(au);
}
Exemplo n.º 22
0
void CCRookieGuide::enableRegionCheckAfter(float seconds) {
    // ensure previous action is stopped
    stopActionByTag(TAG_ENABLE_REGION_CHECK);
    
    // now run a new action
    setShouldCheckRegion(false);
    CCAction* a = CCSequence::createWithTwoActions(CCDelayTime::create(seconds),
                                                   CCCallFunc::create(this, callfunc_selector(CCRookieGuide::markShouldCheckRegion)));
    a->setTag(TAG_ENABLE_REGION_CHECK);
    runAction(a);
}
Exemplo n.º 23
0
// When activated, scale the parent CCNode back to its original scale.
// The action is tagged so that it can be easily found if it needs to be cancelled.
void CCNodeAdornmentScaler::deactivate()
{
	CCNode* p = getParent();
	if ( p == NULL )
		return;

	p->stopActionByTag( kScaleActionTag );		// Cancel any existing scaling action
	CCAction* scaleAction = CCActionScaleTo::create( getActionDuration(), _originalScale.width, _originalScale.height );
	scaleAction->setTag( kScaleActionTag );
	p->runAction( scaleAction );
}
Exemplo n.º 24
0
void ActionNode::easingToFrame(float duration,float delayTime,ActionFrame* srcFrame,ActionFrame* destFrame)
{
	CCAction* cAction = destFrame->getAction(duration,srcFrame);
	CCNode* cNode = this->getActionNode();
	if (cAction == NULL || cNode == NULL)
	{
		return;
	}	
	cAction->startWithTarget(cNode);
	cAction->update(delayTime);
}
Exemplo n.º 25
0
	void CCMenuItemLabel::unselected()
	{
		// subclass to change the default action
		if(m_bIsEnabled)
		{
			CCMenuItem::unselected();
			this->stopActionByTag(kZoomActionTag);
			CCAction *zoomAction = CCScaleTo::actionWithDuration(0.1f, m_fOriginalScale);
			zoomAction->setTag(kZoomActionTag);
			this->runAction(zoomAction);
		}
	}
Exemplo n.º 26
0
// When activated, make the adornment node visible and establish an action
// to fade it in up to the peak opacity. The action is tagged so that it
// can be easily found if it needs to be cancelled.
void CCNodeAdornmentOverlayFader::activate()
{
	if ( _sprite )
	{
		_sprite->stopActionByTag( kFadeActionTag );	// Cancel any existing fade action
	
		CCAction* fadeAction = CCActionFadeTo::create( getActionDuration(), _peakOpacity );
		fadeAction->setTag( kFadeActionTag );
		_sprite->setVisible( true );
		_sprite->runAction( fadeAction );
	}
}
Exemplo n.º 27
0
void GameMenuItem::unselected()
{
	// subclass to change the default action
	if (m_bIsEnabled)
	{
		CCMenuItem::unselected();
		this->stopActionByTag(kZoomActionTag);
		CCAction *zoomAction = CCEaseElasticOut::create(CCScaleTo::create(0.5f, m_fOriginalScale));
		zoomAction->setTag(kZoomActionTag);
		this->runAction(zoomAction);
	}
}
Exemplo n.º 28
0
void SpriteButton::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent)
{
    if(m_state == kSpriteStateGrabbed)
    {
        float scaleValue = 1.0f * scale;
        CCAction *zoomAction = CCScaleTo::create(0.05f, scaleValue);
        zoomAction->setTag(kZoomActionTag);
        runAction(zoomAction);
        
        m_state = kSpriteStateUngrabbed;
    };
}
Exemplo n.º 29
0
CCAction* SectionGuide::createClickAct_retain()
{
    string frames[] = {
        ResManager::getManager()->getSharedFilePath("finger.png"),
        ResManager::getManager()->getSharedFilePath("finger-Press.png"),
        ResManager::getManager()->getSharedFilePath("finger.png"),
        ResManager::getManager()->getSharedFilePath("finger-Press.png"),
        ResManager::getManager()->getSharedFilePath("finger.png")
    };
    CCAction* act = (CCFiniteTimeAction*)SpriteHelper::createAction(frames, 5, 0.5f,false);
    act->retain();
    return act;
}
Exemplo n.º 30
0
void MyMenuItem::selected()
{
    // subclass to change the default action
    if(isEnabled()) {
        SimpleAudioEngine::sharedEngine()->playEffect(MENU_ITEM);//moon

        CCMenuItem::selected();
        scx = getScaleX();
        scy = getScaleY();
        stopActionByTag(kDefaultActionTag);
        stopActionByTag(kZoomActionTag);
        CCAction *zoomAction = CCScaleTo::create(0.1f, scx*0.8f);
        zoomAction->setTag(kZoomActionTag);
        this->runAction(zoomAction);
    }
}