Пример #1
0
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))));

}
Пример #2
0
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);
}
Пример #3
0
/*
 *  开场动画
 */
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)));
}
Пример #4
0
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));
}
Пример #5
0
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));
        }
    }
}
Пример #6
0
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
}
Пример #7
0
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) );
}
Пример #8
0
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;
}
Пример #9
0
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();
}
Пример #10
0
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;
	}
Пример #11
0
//----------------------------------------------------------
//
//
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 );

}
Пример #12
0
//--------------------------------------------------------------
//
//
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 );
}
Пример #13
0
//-----------------------------------------------------------
//
//
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);
	}
}
Пример #14
0
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);

}
Пример #15
0
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);
}
Пример #16
0
bool CurrentGroupLayer::onTextFieldDetachWithIME(CCTextFieldTTF * pSender)
{
    if (m_bAction)
    {
        m_pTextField->stopAction(m_pTextFieldAction);
        m_pTextField->setOpacity(255);
        m_bAction = false;
        
        float adjustVert;// = CCRect::CCRectGetMaxY(info.end) - CCRect::CCRectGetMinY(rectTracked);
        adjustVert = 100.0f;
        CCLOG("TextInputTest:needAdjustVerticalPosition(%f)", adjustVert);
        CCActionInterval* ai_move = CCEaseBounceOut::actionWithAction(CCMoveBy::actionWithDuration(1.0f, ccp(0,-adjustVert)));
        //move all the children node of KeyboardNotificationLayer
        CCArray * children = ((CCLayer*)m_pTextField->getParent())->getChildren();
        CCNode * node = 0;
        int count = children->count();
        CCPoint pos;
        for (int i = 0; i < count; ++i)
        {
            node = (CCNode*)children->objectAtIndex(i);
            //pos = node->getPosition();
            //pos.y -= adjustVert;
            //node->setPosition(pos);
            node->runAction((CCActionInterval*)ai_move->copy()->autorelease());
        }
    }
    return false;
}
Пример #17
0
//------------------------------------------------------------------
//
// Effect2
//
//------------------------------------------------------------------
void Effect2::onEnter()
{
	EffectAdvanceTextLayer::onEnter();

	CCNode* target = getChildByTag(kTagBackground);
	
	// To reuse a grid the grid size and the grid type must be the same.
	// in this case:
	//     ShakyTiles is TiledGrid3D and it's size is (15,10)
	//     Shuffletiles is TiledGrid3D and it's size is (15,10)
	//	   TurnOfftiles is TiledGrid3D and it's size is (15,10)
	CCActionInterval* shaky = CCShakyTiles3D::actionWithRange(4, false, ccg(15,10), 5);
	CCActionInterval* shuffle = CCShuffleTiles::actionWithSeed(0, ccg(15,10), 3);
	CCActionInterval* turnoff = CCTurnOffTiles::actionWithSeed(0, ccg(15,10), 3);
	CCActionInterval* turnon = turnoff->reverse();
	
	// reuse 2 times:
	//   1 for shuffle
	//   2 for turn off
	//   turnon tiles will use a new grid
	CCFiniteTimeAction* reuse = CCReuseGrid::actionWithTimes(2);

	CCActionInterval* delay = CCDelayTime::actionWithDuration(1);
	
//	id orbit = [OrbitCamera::actionWithDuration:5 radius:1 deltaRadius:2 angleZ:0 deltaAngleZ:180 angleX:0 deltaAngleX:-90];
//	id orbit_back = [orbit reverse];
//
//	[target runAction: [RepeatForever::actionWithAction: [Sequence actions: orbit, orbit_back, nil]]];
	target->runAction( (CCActionInterval *)(CCSequence::actions( shaky, delay, reuse, shuffle, delay->copy()->autorelease(), turnoff, turnon, NULL) ) );
}
Пример #18
0
void GamePan::Attack(int direct)
{
	CCNode* fieldNode = m_pCcbNode->getChildByTag(kTagGamePanField);
	for(int i =0;i<fieldNode->getChildrenCount();i++)
	{
		fieldNode->getChildByTag(i);
	}
	
	std::string pinyinStr = Utils::getPinyinStr(answer);//GET_STRING(TEXT_JUQING_SPLASH_BEGIN2);
	std::string answerPinyin = Utils::getPinyinLetter(pinyinStr);
	vector<string> answerArr = Utils::split(answerPinyin);
	vector<string> pinyinArr = Utils::split(_pinyinStr);
	for(int i =0;i<pinyinArr.size();i++)
	{
		string letter = pinyinArr.at(i);
		int pos = -1;
		for(int j =0;j<answerArr.size();j++)
		{
			string tmp = answerArr.at(j);
			if(tmp.compare(letter) == 0)
			{
				pos = i;
			}
		}
		if(i>0 && pos>0)
		{
			CCNode* bar = fieldNode->getChildByTag(i);
			CCMoveTo* moveTo = NULL;
			switch (direct)
			{
			case NPC_ATTACK:
				{
					moveTo = CCMoveTo::create(0.3f,ccp(bar->getPositionX(),bar->getPositionY()-MOVE_STEP));
				}
				break;
			case PLAYER_ATTACK:
				{
					moveTo = CCMoveTo::create(0.3f,ccp(bar->getPositionX(),bar->getPositionY()+MOVE_STEP));
				}
				break;
			}
			bool isMoveAble = true;
			float dis = bar->getPositionY();
			if(dis>=MAX_DISTANCE)
			{
				isMoveAble = false;
			}
			else if(dis<= -MAX_DISTANCE)
			{
				isMoveAble = false;
			}
			if(isMoveAble)
			{
				bar->runAction(moveTo);
			}
		}
	}
	this->runAction(CCSequence::create(CCDelayTime::create(0.35f),CCCallFunc::create(this,callfunc_selector(GamePan::checkWhoWin)),NULL));
	
}
Пример #19
0
void GameMenuLayer::onEnter()
{
    CCLayer::onEnter();
    CCNode *mainMenu = this->getChildByTag(3);
    mainMenu->setScale(0);
    mainMenu->runAction(CCSequence::create(CCScaleTo::create(0.5f, 1),CCCallFunc::create(this, callfunc_selector(GameMenuLayer::menuEnter)),NULL));
}
Пример #20
0
void NestedTest::setup()
{
    static int depth = 9;
    
    CCNode *parent = this;
    
    for (int i = 0; i < depth; i++) {
                
        int size = 225 - i * (225 / (depth * 2));

        CCClippingNode *clipper = CCClippingNode::create();
        clipper->setContentSize(CCSizeMake(size, size));
        clipper->setAnchorPoint(ccp(0.5, 0.5));
        clipper->setPosition( ccp(parent->getContentSize().width / 2, parent->getContentSize().height / 2) );
        clipper->setAlphaThreshold(0.05f);
        clipper->runAction(CCRepeatForever::create(CCRotateBy::create(i % 3 ? 1.33 : 1.66, i % 2 ? 90 : -90)));
        parent->addChild(clipper);
        
        CCNode *stencil = CCSprite::create(s_pPathGrossini);
        stencil->setScale( 2.5 - (i * (2.5 / depth)) );
        stencil->setAnchorPoint( ccp(0.5, 0.5) );
        stencil->setPosition( ccp(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2) );
        stencil->setVisible(false);
        stencil->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(i), CCShow::create()));
        clipper->setStencil(stencil);

        clipper->addChild(stencil);
        
        parent = clipper;
    }

}
Пример #21
0
void NDKHelper::HandleMessage(json_t *methodName, json_t* methodParams)
{
    if (methodName == NULL)
        return;
    
    const char *methodNameStr = json_string_value(methodName);
    
    for (unsigned int i = 0; i < NDKHelper::selectorList.size(); ++i)
    {
        if (NDKHelper::selectorList[i].getName().compare(methodNameStr) == 0)
        {
            CCObject *dataToPass = NDKHelper::GetCCObjectFromJson(methodParams);
            
            if (dataToPass != NULL)
                dataToPass->retain();
            
            SEL_CallFuncND sel = NDKHelper::selectorList[i].getSelector();
            CCNode *target = NDKHelper::selectorList[i].getTarget();
            
            CCFiniteTimeAction* action = CCSequence::create(CCCallFuncND::create(target, sel, (void*)dataToPass), NULL);
            
            target->runAction(action);
            
            if (dataToPass != NULL)
                dataToPass->autorelease();
            break;
        }
    }
}
Пример #22
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 );
}
Пример #23
0
void GameScene::removeBlock( list<int> blockTags, kBlock blockType )
{
    bool first = true;

    list<int>::iterator it = blockTags.begin();
    while( it != blockTags.end() ) {
        m_blockTags[blockType].remove( *it );
        CCNode* block = m_background->getChildByTag( *it );
        if ( block ) {
            CCScaleTo* scale = CCScaleTo::create( REMOVE_TIME, 0 );
            CCCallFuncN* func = CCCallFuncN::create( this, callfuncN_selector( GameScene::removingBlock ));
            CCFiniteTimeAction* sequence = CCSequence::create( scale, func, NULL );
            CCFiniteTimeAction* action;
            if ( first ) {
                CCPlaySE* playSe = CCPlaySE::create( MP3_REMOVE_BLOCK );
                action = CCSpawn::create( sequence, playSe, NULL );
                first = false;
            } else {
                action = sequence;
            }

            block->runAction( action );
        }
        it++;
    }
    SimpleAudioEngine::sharedEngine()->playEffect( MP3_REMOVE_BLOCK );
}
Пример #24
0
void ActionNode::runAction()
{
	CCNode* cNode = this->getActionNode();
	if (cNode != NULL && m_action != NULL)
	{
		cNode->runAction(m_action);
	}
}
Пример #25
0
void MainMenu::onEnter()
{
	CCLayer::onEnter();

	CCNode* mainMenu = this->getChildByTag(MAIN_MENU_TAG);
	mainMenu->setScale(0);
	mainMenu->runAction(CCSequence::create(CCScaleTo::create(0.5, 1), CCCallFunc::create(this, callfunc_selector(MainMenu::menuEnter)), NULL));
}
Пример #26
0
int Player::move(PUD pud) {
	CCLog("Player::move ->  player.spriteFlag:%d:",spriteFlag);
	CCNode* s = pLayer->getChildByTag(spriteFlag);
	s->stopAllActions();
	CCLog("Player::CCMoveTo:(%d,%d)",pud.x2,pud.y2);
	s->runAction(CCMoveTo::create(1, ccp(pud.x2,pud.y2)) );
	return 0;
}
Пример #27
0
void HSGameShopLayer::Shop_FlyOut( CCNode& shop_frame,CCPoint& frame_Position )
{
	if(&shop_frame)
	{
		CCActionInterval* actionFlyOut =CCMoveTo::create(0.3f,ccp(frame_Position.x,-frame_Position.y));
		CCCallFunc* pCallFunc = CCCallFunc::create(this,callfunc_selector(HSGameShopLayer::Shop_FlyOutFinish));
		shop_frame.runAction(CCSequence::create(actionFlyOut,pCallFunc,NULL));
	}
}
Пример #28
0
void TutorialNode::nextTutorial() {
  {
    CCNode* oldTextLabel = getChildByTag(TAG_TUTORIAL);
    CCFadeOut* textMoveOutEase = CCFadeOut::actionWithDuration(FADE_TIME);
    CCCallFuncND* removeText = CCCallFuncND::actionWithTarget(this, callfuncND_selector(TutorialNode::removeNode), oldTextLabel);
    CCFiniteTimeAction* textSequence = CCSequence::actions(textMoveOutEase, removeText, 0);
    oldTextLabel->runAction(textSequence);
  }
  
  {
    CCNode* oldContinueLabel = getChildByTag(TAG_TUTORIAL_CONTINUE);
    CCFadeOut* tapMoveOutEase = CCFadeOut::actionWithDuration(FADE_TIME);
    CCCallFunc* nextText = CCCallFunc::actionWithTarget(this, callfunc_selector(TutorialNode::showTutorial));
    CCCallFuncND* removeTap = CCCallFuncND::actionWithTarget(this, callfuncND_selector(TutorialNode::removeNode), oldContinueLabel);
    CCFiniteTimeAction* tapSequence = CCSequence::actions(tapMoveOutEase, removeTap, nextText, 0);
    oldContinueLabel->runAction(tapSequence);
  }
}
Пример #29
0
void HeadUpDisplay::hideMessage(){

	/* Applying animation to hide message elements.  */
	CCNode* acceptButton = this->getChildByTag(_acceptButtonTag);
	acceptButton->setVisible(false);

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

	CCNode* bubbleTalk = this->getChildByTag(_bubbleTalkTag);
	bubbleTalk->stopAllActions();
	bubbleTalk->runAction(CCScaleTo::create(.5f, 1.50f, 0.0f));

	CCNode* message = bubbleTalk->getChildByTag(_messageTag);
	message->stopAllActions();
	message->runAction(CCFadeTo::create(.5f, 0));
}
Пример #30
0
void VVPageBaseTimeLine::timeLineController(ccTime dt)
{
	elapsedTime += dt;

	if (isEndTimeSet && elapsedTime > endTime) 
	{
		pauseTimeLine();
		resumeAfterStopActions();
		//sprPause.visible = false;
		//sprPlay.visible = false;
		//isControlBtnEnabled = false;
	}
	
	if( timeLineAni->count() > 0 )
	{
		int count = timeLineAni->count();
		for( unsigned int i = 0; i < count; i++)
		{
			TimeLineAniEntity *entity = timeLineAni->getObjectAtIndex(i);
			if( entity->getTime() < elapsedTime )
			{
				CCNode *targetSymbol = entity->getObject();
				targetSymbol->runAction( entity->getAction() );
				timeLineAni->removeObjectAtIndex(i);
				i--; //하나 지워서 오브젝트들이 당겨졌으므로 i값은 그대로 돌려놓음
				count--;
			}
		}
	}
	if( timeLineSound->count() > 0 )
	{
		int count = timeLineSound->count();
		for( int i = 0; i < count; i++)
		{
			TimeLineSoundEntity *entity = timeLineSound->getObjectAtIndex(i);
			if( entity->getTime() < elapsedTime )
			{
				
				//안드로이드 버그 주의: 이렇게하면 안드로이드에서 stlport로 컴파일시 쓰레기 문자열이 들어간다
				//const char* path = entity->getPath().c_str();
				//CCLog(path);
				
				//효과음/목소리 재생
				if (entity->getType() == kAudio_Effect) 
					ap->playEffect( entity->getPath().c_str() );
				else if (entity->getType() == kAudio_Voice) 
					ap->playVoice( entity->getPath().c_str() );	
				else 
					ap->playBackgroundMusic(entity->getPath().c_str() );
				
				timeLineSound->removeObjectAtIndex(i);
				i--; //하나 지워서 오브젝트들이 당겨졌으므로 i값은 그대로 돌려놓음
				count--;
			}
		}
	}
}