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


C++ CCNode::runAction方法代码示例

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


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

示例1: onEnter

void GameAbout::onEnter()
{
	CCLayer::onEnter();
	CCSize size = CCDirector::sharedDirector()->getWinSize();

	CCNode* menu  = this->getChildByTag(4);
	menu->setPositionX(-100);
	menu->runAction(CCEaseSineIn::create(CCMoveBy::create(0.5,ccp(100,0))));

	CCNode* moon = this->getChildByTag(1);
	moon->setPosition(ccp(size.width/3*2,0));
	moon->runAction(CCEaseSineIn::create(CCMoveBy::create(0.5,ccp(-size.width/3,0))));

	CCNode* aboutTitle = this->getChildByTag(3);
	aboutTitle->setPositionY(size.height+20);
	aboutTitle->runAction(CCEaseSineIn::create(CCMoveBy::create(0.5,ccp(0,-40))));

	CCNode* tb = this->getChildByTag(2);
	tb->setPositionX(-200);
	tb->runAction(CCEaseSineIn::create(CCMoveTo::create(0.5,ccp(size.width/2,size.height/2))));

	CCNode* info = this->getChildByTag(5);
	info->setPositionX(-200);
	info->runAction(CCEaseSineIn::create(CCMoveTo::create(0.5,ccp(size.width/2,size.height/2+20))));

}
开发者ID:xuzekun,项目名称:MeowStarBattle,代码行数:26,代码来源:GameAboutScene.cpp

示例2: EnterOption

void HelloWorld::EnterOption()
{
    float fduration = 0.5;
    // title out
    CCNode *pTitle = (CCNode *)getChildByTag(TAG_TITLE);
    CCActionInterval*  actiontitle = CCMoveTo::create(fduration, titlepos(POS_OUT));
    pTitle->runAction(actiontitle);
    // mainmenu out
    CCNode *pMainmenu = (CCNode *)getChildByTag(TAG_MAINMENU);
    CCActionInterval*  actionmainmenu = CCMoveTo::create(fduration, mainmenupos(POS_OUT));
    pMainmenu->runAction(actionmainmenu);
    // game out
    CCNode *pgame = (CCNode *)getChildByTag(TAG_GAMELAYER);
    CCActionInterval*  actiongame = CCMoveTo::create(fduration, gamelayerpos(POS_OUT));
    pgame->runAction(actiongame);
    // toolbar in
    toolbar *pToolbar = (toolbar *)getChildByTag(TAG_TOOLBAR);
    CCActionInterval*  actiontoolbar = CCMoveTo::create(fduration, toolbarpos(POS_IN));
    pToolbar->runAction(actiontoolbar);
    pToolbar->setTitle(LOCATE::GetString(STR_MENU_OPTION));

    // tops out
    CCNode *ptops = (CCNode *)getChildByTag(TAG_TOPS);
    CCActionInterval*  actiontops = CCMoveTo::create(fduration, topspos(POS_OUT));
    ptops->runAction(actiontops);
    // option out
    CCNode *poption = (CCNode *)getChildByTag(TAG_OPTION);
    CCActionInterval*  actionoption = CCMoveTo::create(fduration, optionpos(POS_IN));
    poption->runAction(actionoption);
}
开发者ID:zlm731,项目名称:ibubblebreaker,代码行数:30,代码来源:HelloWorldScene.cpp

示例3: openningAni

/*
 *  开场动画
 */
void OptionLayer::openningAni() {
    float oldY = 0.0f;
    float oldX = 0.0f;
    //左tipMenu
    CCNode* pLNode = (CCNode*)this->getChildByTag(LL_MENU_TAG);
    oldY = pLNode->getPosition().y;
    //CCLog("sssss%f",oldY);
    pLNode->setPosition(ccp(-123.0f, oldY));
    pLNode->runAction(CCMoveBy::create(OPENNING_ANI_DURING, CCPointMake(123.0f, 0.0f)));
    //中间
    CCNode* pMNode = (CCNode*)this->getChildByTag(MID_MENU_TAG);
    oldX = pMNode->getPosition().x;
    oldY = pMNode->getPosition().y;
    pMNode->setPosition(ccp(oldX, oldY + 150.0f));
    pMNode->runAction(CCMoveBy::create(OPENNING_ANI_DURING, CCPointMake(oldX, -150.0f)));
    //右边
    CCNode* pRNode = (CCNode*)this->getChildByTag(RR_MENU_TAG);
    oldY = pRNode->getPosition().y;
    oldX = pRNode->getPosition().x;
    pRNode->setPosition(ccp(oldX + 123.0f, oldY));
    pRNode->runAction(CCMoveBy::create(OPENNING_ANI_DURING, CCPointMake(-123.0f, 0.0f)));
    //层的移动
    CCNode* pLayer = (CCNode*)this->getChildByTag(CONTAINER);
    oldX = pLayer->getPosition().x;
    oldY = pLayer->getPosition().y;
    pLayer->setPosition(ccp(oldX, oldY - 835.0f));
    pLayer->runAction(CCMoveBy::create(OPENNING_ANI_DURING, CCPointMake(oldX, 835.0f)));
}
开发者ID:qjsy,项目名称:QjGit,代码行数:31,代码来源:OptionLayer.cpp

示例4: showMessage

void HeadUpDisplay::showMessage(){

	/* A visible MenuItem is enabled as a button, so in order to no repeat
	 * the action of this method, we check if the accept button was enabled. */
	CCNode* acceptButton = this->getChildByTag(_acceptButtonTag);
	if(acceptButton->isVisible())
		return;


	/* Applying animation to show message elements.  */
	acceptButton->setVisible(true);

	CCNode* mesh = this->getChildByTag(_meshTag);
	mesh->stopAllActions();
	mesh->runAction(CCFadeTo::create(.25f, 255 * .5f));

	CCNode* bubbleTalk = this->getChildByTag(_bubbleTalkTag);
	bubbleTalk->stopAllActions();
	bubbleTalk->runAction(
			CCSequence::create(
				CCScaleTo::create(.25f, 0.75f, 1.25f),
				CCScaleTo::create(.25f, 1.00f, 1.00f),
				NULL
			)
	);

	CCNode* message = bubbleTalk->getChildByTag(_messageTag);
	message->stopAllActions();
	message->runAction(CCFadeTo::create(.5f, 255));
}
开发者ID:marcochavezf,项目名称:cocos2dx-test,代码行数:30,代码来源:HeadUpDisplay.cpp

示例5: expandAvatars

void FMMapAvatarNode::expandAvatars(bool flag)
{
    m_isExpand = flag;
    int index = 1;
    if (m_includeSelf) {
        FMMainScene * mainScene = (FMMainScene *)FMDataManager::sharedManager()->getUI(kUI_MainScene);
        FMWorldMapNode* wd = (FMWorldMapNode*)mainScene->getNode(kWorldMapNode);
        wd->setAvatarEnable(flag);
        
        index = 0;
    }
    
    float time = 0.1f;
    int t = 0;
    for (int i = index; i < m_avatarList->count(); i++) {
        t++;
        CCNode * n = (CCNode *)m_avatarList->objectAtIndex(i);
        if (m_isExpand) {
            float x = t%2;
            float y = t/2;
            CCPoint end = ccp(x * expandAvatarx, y * expandAvatary);
            n->runAction(CCMoveTo::create(time, end));
        }else{
            CCPoint end = ccp(t * avatarDiffx, t * avatarDiffy);
            n->runAction(CCMoveTo::create(time, end));
        }
    }
}
开发者ID:rockingdice,项目名称:IceCreamJam,代码行数:28,代码来源:FMMapAvatarNode.cpp

示例6: unselected

void CCMenuItem::unselected()
{
    m_bSelected = false;
    // #HLP_BEGIN
    CCNode *p;
    if(mIsMoveDownWhenSelected || mFadeAnim)
        p = getParent2();
    
    if(mIsMoveDownWhenSelected){
        
        CCFiniteTimeAction *move = CCMoveTo::create(0.5f, mParentOriginalPos);
        p->stopAllActions();
        move = CCEaseExponentialOut::create((CCActionInterval*)move);
        p->runAction(CCSequence::create(move, NULL));
        
        CCFiniteTimeAction *tint = CCTintTo::create(0.5f, mNormalTint.r, mNormalTint.g, mNormalTint.b);
        tint = CCEaseExponentialOut::create((CCActionInterval*)tint);
        p->runAction(CCSequence::create(tint, NULL));
    }
    
    if(mFadeAnim){
        CCNode *n = p->getChildByTag(LAYER_FADE_TAG);
        if(n){
            CCFiniteTimeAction *fade = CCFadeTo::create(0.5f, 0);
            fade = CCEaseExponentialOut::create((CCActionInterval*)fade);
            n->runAction(CCSequence::create(fade, NULL));
        }
    }

    // #HLP_END
}
开发者ID:saranpol,项目名称:cocos2d-x,代码行数:31,代码来源:CCMenuItem.cpp

示例7: ccTouchesEnded

void MainLayer::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)
{
    CCSetIterator it = pTouches->begin();
	CCTouch* touch = (CCTouch*)(*it);
	
	CCPoint location = touch->locationInView( touch->view() );
	CCPoint convertedLocation = CCDirector::sharedDirector()->convertToGL(location);

	CCNode* s = getChildByTag(kTagSprite);
	s->stopAllActions();
	s->runAction( CCMoveTo::actionWithDuration(1, CCPointMake(convertedLocation.x, convertedLocation.y) ) );
	float o = convertedLocation.x - s->getPosition().x;
	float a = convertedLocation.y - s->getPosition().y;
	float at = (float) CC_RADIANS_TO_DEGREES( atanf( o/a) );
	
	if( a < 0 ) 
	{
		if(  o < 0 )
			at = 180 + fabs(at);
		else
			at = 180 - fabs(at);	
	}
	
	s->runAction( CCRotateTo::actionWithDuration(1, at) );
}
开发者ID:Bahamut,项目名称:cocos2d-x,代码行数:25,代码来源:ClickAndMoveTest.cpp

示例8: ccTouchBegan

bool GameScene::ccTouchBegan(CCTouch* pTouch,CCEvent* pEvent)
{
	if( CCLayer* rankingLayer = (CCLayer*) this->getChildByTag(kTagRankingLayer) ){
		if( rankingLayer->numberOfRunningActions() != 0 )
			return true;
		if( ! rankingLayer->boundingBox().containsPoint(pTouch->getLocation()) ){
			CCNode* rankingLayer = this->getChildByTag(kTagRankingLayer);
			rankingLayer->setScale(0.5f);
			rankingLayer->runAction(
				CCSequence::createWithTwoActions(
					CCScaleTo::create(0.2f,0),
					CCCallFuncN::create(this, callfuncN_selector(GameScene::removeObject))
				)
			);

			CCNode* rankingLayerB = this->getChildByTag(kTagRankingLayerBack);
			rankingLayerB->setScale(0.5f);
			rankingLayerB->runAction(
				CCSequence::createWithTwoActions(
					CCScaleTo::create(0.2f,0),
					CCCallFuncN::create(this, callfuncN_selector(GameScene::removeObject))
				)
			);

			this->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.2f),CCCallFunc::create(this,callfunc_selector(GameScene::enableMenu))));
		}
	}

	m_pBattery->setTouchPos(pTouch->getLocation());
	m_pBattery->start();

	return true;
}
开发者ID:yoroyorokun,项目名称:SpaceShoot,代码行数:33,代码来源:GameScene.cpp

示例9: scrollTo

void GUISpinView::scrollTo(int rowIndex)
{
    
    m_targetRow = rowIndex;
    if (m_targetRow >= m_itemCount || m_targetRow < 0) {
        return;
    }
    CCNode * node = m_mainNode->getChildByTag(m_targetRow);
    float h = node->getPosition().y;
    float dis = -h - (kMoveRound * m_itemCount * m_itemHeight);
    int th = m_itemHeight;
    float r = rand()% (th-10);
    r -= (th-10) * 0.5f;
    CCArray * array = m_mainNode->getChildren();
    if (array) {
        for (int i = 0; i < array->count(); i++) {
            CCNode * node = (CCNode *)array->objectAtIndex(i);
            CCMoveBy * move = CCMoveBy::create(kMoveTime, CCPoint(0, dis + r));
            CCEaseSineOut * easeout = CCEaseSineOut::create(move);
            CCDelayTime * delay = CCDelayTime::create(0.2f);
            CCMoveBy * move2 = CCMoveBy::create(0.2f, ccp(0, -r));
            CCSequence * seq = CCSequence::create(easeout,delay,move2,NULL);
            if (node->getTag() == m_targetRow) {
                node->runAction(CCSequence::create(seq,CCDelayTime::create(0.2f),CCCallFunc::create(this, callfunc_selector(GUISpinView::scrollFinish)), NULL));
            }else{
                node->runAction(seq);
            }
        }
    }
    scheduleUpdate();
}
开发者ID:rockingdice,项目名称:IceCreamJam,代码行数:31,代码来源:GUISpinView.cpp

示例10: init

bool GameOverLayer::init()
{
	if ( CCLayerColor::initWithColor( ccc4(255,255,255,255) ) )
	{
		// Get window size and place the label upper. 
		CCSize size = CCDirector::sharedDirector()->getWinSize();

		// 3. Add add a splash screen, show the cocos2d splash image.
		CCSprite* pSprite = CCSprite::create("IntroScene.png");
		if(!pSprite)
			return false;

		// Place the sprite on the center of the screen
		pSprite->setPosition(ccp(size.width/2, size.height/2));

		// Add the sprite to HelloWorld layer as a child layer.
		this->addChild(pSprite, 0);

		//Add the menu choice
		CCMenuItemFont::setFontSize( 100 );
		CCMenuItemFont::setFontName("Courier New");
		CCLabelBMFont* labelNew = CCLabelBMFont::create("Restart Game!", "bitmapFontTest3.fnt");
		CCMenuItemLabel* itemNew = CCMenuItemLabel::create(labelNew, this, menu_selector(GameOverLayer::menuRestartCallback));

		CCLabelBMFont* labelQuit = CCLabelBMFont::create("Quit", "bitmapFontTest3.fnt");
		CCMenuItemLabel* itemQuit = CCMenuItemLabel::create(labelQuit, this, menu_selector(GameOverLayer::menuCloseCallback));

		CCMenu* menu = CCMenu::create( itemNew, itemQuit, NULL);
		menu->alignItemsVerticallyWithPadding(50);

		int i=0;
		CCNode* child;
		CCArray * pArray = menu->getChildren();
		CCObject* pObject = NULL;
		CCARRAY_FOREACH(pArray, pObject)
		{
			if(pObject == NULL)
				break;

			child = (CCNode*)pObject;

			CCPoint dstPoint = child->getPosition();
			int offset = (int) (size.width/2 + 50);
			if( i % 2 == 0)
				offset = -offset;

			child->setPosition( ccp( dstPoint.x + offset, dstPoint.y) );
			child->runAction( 
				CCEaseElasticOut::create(CCMoveBy::create(2, ccp(dstPoint.x - offset,0)), 0.35f) 
				);
			i++;
		}

		addChild(menu);
		menu->setPosition(ccp(size.width/2, size.height/2));

		EntityManager::GetInstance()->SetGameOver(false);

		return true;
	}
开发者ID:darioslave1,项目名称:Cyber_Hackman,代码行数:60,代码来源:GameOverScene.cpp

示例11: addSkillExp

//----------------------------------------------------------
//
//
void PetDatablock::addSkillExp( int skillExp, CCPoint pos )
{
	petskillexppond += skillExp;
	if( petskillexppond >= MAX_SKILL_EXP )
	{
		petskillexppond = MAX_SKILL_EXP;
	}

	CCNode *pNode = CCNode::node();
	
	string path = GetGameImagesPath();
    path = path + "upskillexp.png";
	CCSprite* pSpriteBG = CCSprite::spriteWithFile( path.c_str() );
	pSpriteBG->setPosition( pos );

	pNode->addChild( pSpriteBG, 100 );

	char buffer[128];
	sprintf( buffer,"+%d", skillExp );
	CCLabelTTF *pLabelTTF = CCLabelTTF::labelWithString( buffer, kFontSystem[FONT_MED].fontName, kFontSystem[FONT_MED].fontSize );
	pLabelTTF->setPosition( ccp( pSpriteBG->getPosition().x + pSpriteBG->getTextureRect().size.width / 2, pSpriteBG->getPosition().y )  );
	pLabelTTF->setAnchorPoint( ccp( 0,0.5 ) );
	pNode->addChild( pLabelTTF,100 );

	CCDirector::sharedDirector()->getRunningScene()->addChild( pNode, 100 );

	pSpriteBG->runAction(CCFadeOut::actionWithDuration(3.0));
	pLabelTTF->runAction(CCFadeOut::actionWithDuration(3.0));
	CCMoveBy *pMoveBy = CCMoveBy::actionWithDuration( 2.0, ccp( 0, CCDirector::sharedDirector()->getWinSize().height / 3 ) );
    pNode->runAction( pMoveBy );

}
开发者ID:JoeHu,项目名称:magicpet,代码行数:35,代码来源:CPet.cpp

示例12: addPlayerMoney

//--------------------------------------------------------------
//
//
void PetDatablock::addPlayerMoney( int data, CCPoint pos )
{
	playershoppingmallmoney += data;

	CCNode *pNode = CCNode::node();
	
	string path = GetGameImagesPath();
    path = path + "upPlayerMoney.png";
	CCSprite* pSpriteBG = CCSprite::spriteWithFile( path.c_str() );
	pSpriteBG->setPosition( pos );

	pNode->addChild( pSpriteBG, 100 );

	char buffer[128];
	sprintf( buffer,"+%d", data );
	CCLabelTTF *pLabelTTF = CCLabelTTF::labelWithString( buffer, kFontSystem[FONT_MED].fontName, kFontSystem[FONT_MED].fontSize );
	pLabelTTF->setPosition( ccp( pSpriteBG->getPosition().x + pSpriteBG->getTextureRect().size.width / 2, pSpriteBG->getPosition().y )  );
	pLabelTTF->setAnchorPoint( ccp( 0,0.5 ) );
	pNode->addChild( pLabelTTF,100 );

	CCDirector::sharedDirector()->getRunningScene()->addChild( pNode, 100 );

	pSpriteBG->runAction(CCFadeOut::actionWithDuration(3.0));
	pLabelTTF->runAction(CCFadeOut::actionWithDuration(3.0));

	CCMoveBy *pMoveBy = CCMoveBy::actionWithDuration( 2.0, ccp( 0, CCDirector::sharedDirector()->getWinSize().height / 3 ) );
    pNode->runAction( pMoveBy );
}
开发者ID:JoeHu,项目名称:magicpet,代码行数:31,代码来源:CPet.cpp

示例13: addPetMoney

//-----------------------------------------------------------
//
//
void PetDatablock::addPetMoney( int data, CCPoint pos )
{
	petmoney += data;

	CCNode *pNode = CCNode::node();
	
	string path = GetGameImagesPath();
    path = path + "upmoney.png";
	CCSprite* pSpriteBG = CCSprite::spriteWithFile( path.c_str() );
	pSpriteBG->setPosition( pos );

	pNode->addChild( pSpriteBG, 100 );

	char buffer[128];
	sprintf( buffer,"+%d", data );
	CCLabelTTF *pLabelTTF = CCLabelTTF::labelWithString( buffer, kFontSystem[FONT_MED].fontName, kFontSystem[FONT_MED].fontSize );
	pLabelTTF->setPosition( ccp( pSpriteBG->getPosition().x + pSpriteBG->getTextureRect().size.width / 2, pSpriteBG->getPosition().y )  );
	pLabelTTF->setAnchorPoint( ccp( 0,0.5 ) );
	pNode->addChild( pLabelTTF,100 );

	CCDirector::sharedDirector()->getRunningScene()->addChild( pNode, 100 );

	pSpriteBG->runAction(CCFadeOut::actionWithDuration(3.0));
	pLabelTTF->runAction(CCFadeOut::actionWithDuration(3.0));

	CCMoveBy *pMoveBy = CCMoveBy::actionWithDuration( 2.0, ccp( 0, CCDirector::sharedDirector()->getWinSize().height / 3 ) );
    pNode->runAction( pMoveBy );

	if( CCUserDefault::sharedUserDefault()->getBoolForKey( "sound" ) )
	{
		CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("data/audio/money.mp3", false);
	}
}
开发者ID:JoeHu,项目名称:magicpet,代码行数:36,代码来源:CPet.cpp

示例14: initMenuList

void BaseMenuLayer::initMenuList(CCArray* pArrayOfItems)
{
    CC_RETURN_IF_FAIL(!m_pItemMenu);
    m_pItemMenu = CCMenu::createWithArray(pArrayOfItems);
    m_pItemMenu->alignItemsVertically();

    CCObject* pObject = NULL;
    int i=0;
    CCNode* child = NULL;
    CCSize s = CCDirector::sharedDirector()->getWinSize();

    CCARRAY_FOREACH(pArrayOfItems, pObject)
    {
        if(pObject == NULL)
            break;

        child = (CCNode*)pObject;

        CCPoint dstPoint = child->getPosition();
        int offset = (int) (s.width/2 + 50);
        if( i % 2 == 0)
            offset = -offset;

        child->setPosition( ccp( dstPoint.x + offset, dstPoint.y) );
        child->runAction(
                          CCEaseElasticOut::create(CCMoveBy::create(2, ccp(dstPoint.x - offset,0)), 0.35f)
                        );
        i++;
    }

    addChild(m_pItemMenu);
    m_pItemMenu->setPosition(ccp(s.width/2, s.height/2));
    CC_SAFE_RELEASE(pArrayOfItems);

}
开发者ID:MrHantLP,项目名称:Renju,代码行数:35,代码来源:BaseLayer.cpp

示例15: doKeyboardHideAction

void CCtrlEdit::doKeyboardHideAction()
{
	if (!isVisible())
	{
		return;
	}

	CCPoint destPos = getPosition();

	if (fabs(m_infoIMEKeyboardNotification.end.size.height) < (destPos.y - m_nHeight))
	{
		return;
	}
	
	DLG_HANDLE hHandleDlg = GetTopParent();
	CCMyWndObject* pWndObject = g_objUIMgr.GetWndObj(hHandleDlg);
	if (NULL == pWndObject)
	{
		return;
	}
    
	CCNode *pHandleNode = dynamic_cast<CCNode*>(pWndObject);
	if (NULL == pHandleNode)
	{
		return;
	}

	CCMoveTo* moveTo = CCMoveTo::create(m_infoIMEKeyboardNotification.duration, m_RecordPos);
	pHandleNode->runAction(moveTo);
}
开发者ID:twkevin,项目名称:ddz,代码行数:30,代码来源:CtrlEdit.cpp


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