当前位置: 首页>>代码示例>>C++>>正文


C++ CCAction::setTag方法代码示例

本文整理汇总了C++中CCAction::setTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CCAction::setTag方法的具体用法?C++ CCAction::setTag怎么用?C++ CCAction::setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCAction的用法示例。


在下文中一共展示了CCAction::setTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createNewRole

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();
}
开发者ID:beforeeight,项目名称:bump,代码行数:33,代码来源:MainLayer.cpp

示例2: activate

// 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 );
}
开发者ID:ClAndHHL,项目名称:cocos3d-x,代码行数:32,代码来源:CCNodeAdornments.cpp

示例3: onEnter

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);
}
开发者ID:645286681,项目名称:cocos2d-x,代码行数:31,代码来源:ActionsEaseTest.cpp

示例4: setHighlighted

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);
    }
}
开发者ID:keyor,项目名称:Nanhua,代码行数:27,代码来源:CCControlButton.cpp

示例5: playerJump

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);
}
开发者ID:cqnature,项目名称:testrungame,代码行数:25,代码来源:GameLayer.cpp

示例6:

//------------------------------------------------------------------
//
// 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);
}
开发者ID:issamux,项目名称:WebGame,代码行数:30,代码来源:CocosNodeTest.cpp

示例7: onEnter

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);
}
开发者ID:ccjimmy,项目名称:TweeJump4wp8,代码行数:30,代码来源:EaseActionsTest.cpp

示例8: playerChangeRoad

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);
}
开发者ID:cqnature,项目名称:testrungame,代码行数:34,代码来源:GameLayer.cpp

示例9: addPig

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);
}
开发者ID:studio501,项目名称:fiypig,代码行数:26,代码来源:GameScene.cpp

示例10: onEnter

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);
}
开发者ID:csdnnet,项目名称:hiygame,代码行数:33,代码来源:ActionsEaseTest.cpp

示例11: scrollToSmooth

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;
}
开发者ID:ourgames,项目名称:dc208,代码行数:30,代码来源:HFViewport.cpp

示例12: onEnter

//------------------------------------------------------------------
//
// 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);

}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:39,代码来源:TestEaseActions.cpp

示例13: RegistAA

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);
}
开发者ID:steinkrausls,项目名称:cocotd,代码行数:9,代码来源:TextLayer.cpp

示例14: deactivate

// 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 );
}
开发者ID:ClAndHHL,项目名称:cocos3d-x,代码行数:13,代码来源:CCNodeAdornments.cpp

示例15: enableRegionCheckAfter

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);
}
开发者ID:cfpt,项目名称:cocos2dx-common,代码行数:11,代码来源:CCRookieGuide.cpp


注:本文中的CCAction::setTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。