Exemple #1
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));
	
}
void MainLayerHerosBaseBody::disableAllTouchBegin()
{
	mTableView->setTouchEnabled(false);
	int cellNum = numberOfCellsInTableView(mTableView);
	for (int i=0;i<cellNum;i++)
	{
		CCTableViewCell* cell = mTableView->cellAtIndex(i);
		if (cell)
		{
			CCNode* bg = cell->getChildByTag(TAG_BaseBody_TABLE_ITEM);
			if (bg)
			{
				CCMenu* menu = (CCMenu*)bg->getChildByTag(TAG_BaseBody_TABLE_HERO_IMG);
				if (menu)
				{
					menu->setEnabled(false);
				}
				menu = (CCMenu*)bg->getChildByTag(TAG_Menu);
				if(menu)
				{
					menu->setEnabled(false);
				}
			}
		}
	}

}
Exemple #3
0
 void Helm::inactivateHeml(){
     CCSprite* black = (CCSprite *) this->getChildByTag(1);
     CCSprite* heml = (CCSprite *) this->getChildByTag(2);
     CCNode* vMenuWin = (CCNode *) this->getChildByTag(3);
     CCNode* vMenuGold = (CCNode *) this->getChildByTag(4);
     CCNode* vMenuLost = (CCNode *) this->getChildByTag(5);
     CCNode* vMenuPause = (CCNode *) this->getChildByTag(6);
     heml->setOpacity(0);
     black->setOpacity(0);
     CCSprite* item1 = (CCSprite*)vMenuWin->getChildByTag(1);
     item1->setOpacity(0);
     CCSprite* item2 = (CCSprite*)vMenuWin->getChildByTag(2);
     item2->setOpacity(0);
     CCSprite* item3 = (CCSprite*)vMenuWin->getChildByTag(3);
     item3->setOpacity(0);
     vMenuWin->setPosition( CCPoint(-Config::sharedConfig()->SCREEN_WIDTH, -Config::sharedConfig()->SCREEN_HEIGHT) );
     CCSprite* item4 = (CCSprite*)vMenuGold->getChildByTag(1);
     item4->setOpacity(0);
     CCSprite* item5 = (CCSprite*)vMenuGold->getChildByTag(2);
     item5->setOpacity(0);
     CCSprite* item6 = (CCSprite*)vMenuGold->getChildByTag(3);
     item6->setOpacity(0);
     vMenuGold->setPosition( CCPoint(-Config::sharedConfig()->SCREEN_WIDTH, -Config::sharedConfig()->SCREEN_HEIGHT) );
     CCSprite* item7 = (CCSprite*)vMenuLost->getChildByTag(1);
     item7->setOpacity(0);
     CCSprite* item8 = (CCSprite*)vMenuLost->getChildByTag(2);
     item8->setOpacity(0);
     vMenuLost->setPosition( CCPoint(-Config::sharedConfig()->SCREEN_WIDTH, -Config::sharedConfig()->SCREEN_HEIGHT) );
     CCSprite* item9 = (CCSprite*)vMenuPause->getChildByTag(1);
     item9->setOpacity(0);
     CCSprite* item10 = (CCSprite*)vMenuPause->getChildByTag(2);
     item10->setOpacity(0);
     vMenuPause->setPosition( CCPoint(-Config::sharedConfig()->SCREEN_WIDTH, -Config::sharedConfig()->SCREEN_HEIGHT) );
 }
Exemple #4
0
bool GamePan::checkAnswer(std::string pAnswer)
{
	if(pAnswer.empty())
	{
		CCNode* pBaseNode = m_pCcbNode->getChildByTag(kTagGamePanWordPan);
		CCNode* itemNode = pBaseNode->getChildByTag(kTagGamePanWordPanItemBase);
		vector<string> arr = Utils::split(_answerStr);

		answer = "";
		for(int i = 0 ;i <arr.size();i++)
		{
			int id = atoi((arr.at(i).c_str()));
			CCLabelTTF* text = dynamic_cast<CCLabelTTF*>(itemNode->getChildByTag(id));
			answer += text->getString();
		}
	}
	else
	{
		answer = pAnswer;
	}
	string dbResult = DBManager::sharedDBManager()->checkWordExist(answer);
	if(!dbResult.empty())
	{
		MainGameScene* scene = dynamic_cast<MainGameScene*>(CCDirector::sharedDirector()->getRunningScene());
		if(scene)
			scene->openTipGame(dbResult+Utils::getPinyinLetter(Utils::getPinyinStr(dbResult)));
		return true;
	}
	else
		return false;
	
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback));
    
	pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
                                origin.y + pCloseItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

    /////////////////////////////
    // 3. add your codes below...
    CCNode* gameScene = SceneReader::sharedSceneReader()->createNodeWithSceneFile("DemoCowboy.json");
    addChild(gameScene);
    
    //Create player
    CCNode* playerNode = gameScene->getChildByTag(10004);
    player = new Player(playerNode);
    
    //Assign callbacks to the buttons
    CCNode* uiNode = gameScene->getChildByTag(10005);
    UILayer* ui = (UILayer*)uiNode->getComponent("GUIComponent")->getNode();
    
    UIButton* btnLeft = (UIButton*)ui->getWidgetByName("LeftButton");
    btnLeft->addTouchEventListener(this, toucheventselector(HelloWorld::onMoveLeft));
    
    UIButton* btnRight = (UIButton*)ui->getWidgetByName("RightButton");
    btnRight->addTouchEventListener(this, toucheventselector(HelloWorld::onMoveRight));
    
    UIButton* btnFire = (UIButton*)ui->getWidgetByName("FireButton");
//    btnFire->addReleaseEvent(this, coco_releaseselector(HelloWorld::onFire));
    btnFire->addTouchEventListener(this, toucheventselector(HelloWorld::onFire));
    
    //Enable update loop
    this->scheduleUpdate();
    
    return true;
}
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));
}
Exemple #7
0
void GamePan::update(float delta)
{
	CCNode* pBaseNode = m_pCcbNode->getChildByTag(kTagGamePanWordPan);
	CCNode* tabNode = pBaseNode->getChildByTag(kTagGamePanWordPanTabBase);
	CCNode* itemNode = pBaseNode->getChildByTag(kTagGamePanWordPanItemBase);
	vector<string> arr = Utils::split(_answerStr);
	
	string answer;
	for(int i = 0 ;i <arr.size();i++)
	{
		int id = atoi((arr.at(i).c_str()));
		CCLabelTTF* text = dynamic_cast<CCLabelTTF*>(itemNode->getChildByTag(id));
		answer += text->getString();
	}
	//CCLog(("###############   "+answer).c_str());
}
void MainLayerZhuangBeiBaseBody::disableAllTouchEnd()
{
    mTableView->setTouchEnabled(true);

    int cellNum = numberOfCellsInTableView(mTableView);
    for (int i=0; i<cellNum; i++)
    {
        CCTableViewCell* cell = mTableView->cellAtIndex(i);
        if (cell)
        {
            CCNode* bg = cell->getChildByTag(TAG_EquipBaseBody_TABLE_ITEM);
            if (bg)
            {
                CCMenu* menu = (CCMenu*)bg->getChildByTag(TAG_BaseBody_MENU);
                if (menu)
                {
                    menu->setEnabled(true);
                }
            }
        }
    }

    CCPoint beg = mTableView->getContentOffset();
    if (mOffset.y < beg.y) mOffset.y = beg.y;
    if (mOffset.y > tableCellSizeForIndex(mTableView,0).height*3) mOffset.y = tableCellSizeForIndex(mTableView,0).height*3;
    mTableView->setContentOffset(mOffset);
}
Exemple #9
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
}
Exemple #10
0
void GamePan::checkWhoWin()
{
	if(isCheckWin)
		return;
	if(!isCheckWin)
		isCheckWin = true;
	CCNode* fieldNode = m_pCcbNode->getChildByTag(kTagGamePanField);
	bool isWin = false;
	for(int i =kTagGamePanFieldLeft ;i<=kTagGamePanFieldRight;i++)
	{
		CCNode* bar = fieldNode->getChildByTag(i);
		float dis = bar->getPositionY();
		if(dis>=MAX_DISTANCE||dis<= -MAX_DISTANCE)
			isWin = true;
		else
		{
			isWin = false;
			break;
		}
	}
	if(isWin)
	{
		showResult();
	}
	else
	{
		createNextPuzzle();
		_isPlayer = !_isPlayer;
		changeSide();
	}
}
Exemple #11
0
void GamePan::showResult()
{
	CCNode* pBaseNode = m_pCcbNode->getChildByTag(kTagGamePanResultPad);
	pBaseNode->setVisible(true);
	CCLabelTTF* title = dynamic_cast<CCLabelTTF*>(pBaseNode->getChildByTag(kTagGamePanResultPadText));
	if(_isPlayer)
		title->setString("PLAYER WIN");
	else
		title->setString("NPC WIN");
	CCNode* pMenu = pBaseNode->getChildByTag(kTagGamePanResultPadMenu);
	if(pMenu)
	{
		CCMenuItemImage* btn = dynamic_cast<CCMenuItemImage*>(pMenu->getChildByTag(0));
		btn->setTarget(this,menu_selector(GamePan::ResultBtnCallBack));
	}
}
Exemple #12
0
void CMainCityUI::updateOpenState(CityData *cityData)
{ 
	int size = cityData->cityList.size();
	for (int i = 0; i <size; i++)
	{
		CCity *city = &cityData->cityList.at(i);
		//是否刚打开功
		bool justOpen = false;
		if (city->cityId>20)
		{
			justOpen = CMainCityControl::getInstance()->isJustOpen(city);
		}
		if ((city->cityId>20&&!city->isOpen)||justOpen)
		{
			CCNode *child = m_ui->getChildByTag(city->cityId-20);
			if (child)
			{
				CButton *btn = dynamic_cast<CButton*>(child->getChildByTag(city->cityId-20));
				if (btn)
				{
					//btn->setEnabled(false);
					btn->getNormalImage()->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
					btn->getSelectedImage()->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
				}	
			}
		}
		m_cityMap[city->cityId] = *city;
	}
}
Exemple #13
0
bool CStrengthenItem::autoRoll()
{
	if(!m_bAutoRoll)
	{
		return false;
	}

	for(unsigned int i=0; i<m_tableView->getCountOfCell(); i++)
	{
		CItem &item =  *(m_itemList.at(i));// m_itemData.itemList.at(uIdx);
		if(item.armor.hero == m_toHero)
		{
			int iGap = m_tableView->getCountOfCell()-i;
			float fOff = m_tableView->getContentSize().height-iGap*m_tableView->getSizeOfCell().height;
			fOff = fOff>0?0:fOff;
			m_tableView->reloadData();
			m_tableView->setContentOffset(ccp(0, fOff));
			CCNode* pCell = m_tableView->getContainer()->getChildByTag(i);
			if(pCell)
			{
				CButton* pButton = (CButton*)pCell->getChildByTag(1);
				if(pButton)
				{
					onTouchItem(pButton);
					return true;
				}
			}
			break;
		}
	}

	return false;
}
void IPadSprite::ccTouchEnded(CCTouch* touch, CCEvent* event)
{
	CCNode* pNode = this->getParent();
	CCNode* pNode1 = this;
	while(pNode->getParent() != NULL)
	{
		pNode1 = pNode;
		pNode = pNode->getParent();
	}
	MainScene* pScene = dynamic_cast<MainScene*>(pNode1);
	if(pScene)
	{
		pScene->hideMenu();
	}
	
	MS5Layer* pLayer = dynamic_cast<MS5Layer*>(this->getParent());
	if(pLayer)
		pLayer->hidePopupPanel();
		
	this->setIsVisible(false);
	pNode = this->getParent();
	pNode = pNode->getParent();
	
	if(pNode->getChildByTag(TAG_IPAD_BIG) == NULL)
	{
		ScaleSprite* pSprite = ScaleSprite::scaleSpriteWithFile("ipad_big.png");
		pSprite->setTag(TAG_IPAD_BIG);
		pSprite->setScale(0.24f);
		pSprite->setPosition( ccp(855, 420) );
		pNode->addChild(pSprite, 2);
		pSprite->startScale();
	}
} 
void FMUIWorldMap::updateGoogleLoginBtn( int islogined )
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    if( SNSFunction_getPackageType() == PT_GOOGLE_EN_FACEBOOK){
        CCNode *root = m_ccbNode->getChildByTag(0);
        CCNode *gameCenter = root ? root->getChildByTag(100) : NULL;
        if( gameCenter){
            //bool islogin = (islogined == -1 ? SNSFunction_isGooglePlayLogin() : islogined);
            gameCenter->setVisible(true);
            CCNode *btnGoogle = gameCenter->getChildByTag(1);
            CCNode *btnArchievement = gameCenter->getChildByTag(2);
            if( btnGoogle ) btnGoogle->setVisible(true);
            if( btnArchievement ) btnArchievement->setVisible(false);
        }
    }
#endif
}
Exemple #16
0
void GamePan::refreshWorldPad()
{
	CCNode* pBaseNode = m_pCcbNode->getChildByTag(kTagGamePanWordPan);
	CCNode* tabNode = pBaseNode->getChildByTag(kTagGamePanWordPanTabBase);
	CCNode* itemNode = pBaseNode->getChildByTag(kTagGamePanWordPanItemBase);
	CCLabelTTF* itemTemp = dynamic_cast<CCLabelTTF*>(itemNode->getChildByTag(kTagGamePanWordPanItemTitle));
	CCControlButton* tabItem = dynamic_cast<CCControlButton*>(tabNode->getChildByTag(kTagGamePanWordPanTabBaseItem));
	float itemWidth = tabItem->getContentSize().width+ITEM_SPACE;
	float itemHeight = tabItem->getContentSize().height+ITEM_SPACE;
	for(int i =0;i<MAX_LINE;i++)
	{
		for(int j =0;j<MAX_ROW;j++)
		{
			CCControlButton* item = CCControlButton::create();
			Utils::copyCCControlButton(item,tabItem);
			item->setPosition(ccp(tabItem->getPositionX()+j*itemWidth,tabItem->getPositionY()-i*itemHeight));
			item->setTag(j+i*MAX_ROW);
			tabNode->addChild(item);

			CCLabelTTF* title = Utils::copyCCLabelTTF(itemTemp);
			title->setPosition(item->getPosition());
			title->setTag(j+i*MAX_ROW);
			itemNode->addChild(title);
			CCString* str = (CCString*)_wordList->randomObject();
			title->setString(str->getCString());
			_wordList->removeObject(str);
		}
	}

	for(int i =0;i<MAX_LINE;i++)
	{
		for(int j =0;j<MAX_ROW;j++)
		{
			CCControlButton* item = dynamic_cast<CCControlButton*>(tabNode->getChildByTag(j+i*MAX_ROW));
			XCheckBox* pCheckBox = XCheckBox::create(item);
			pCheckBox->setTag(item->getTag());
			pCheckBox->setToggle(false);
			pCheckBox->setTarget(this, cccontrol_selector(GamePan::wordSelectCallbackCCControl));
			tabNode->addChild(pCheckBox);
			item->removeFromParent();
		}
	}
	itemTemp->removeFromParent();
	tabItem->removeFromParent();
	refreshLetter();
}
Exemple #17
0
void ScrollViewDemo::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
    if (!m_bScrolling) return;
	CCTouch *touch = (CCTouch*)pTouches->anyObject();
    CCNode *clipper = this->getChildByTag(kTagClipperNode);
    CCPoint point = clipper->convertToNodeSpace(CCDirector::sharedDirector()->convertToGL(touch->getLocationInView()));
	CCPoint diff = ccpSub(point, m_lastPoint);
    CCNode *content = clipper->getChildByTag(kTagContentNode);
    content->setPosition( ccpAdd(content->getPosition(), diff) );
    m_lastPoint = point;
}
Exemple #18
0
void GamePan::refreshLetter()
{
	vector<string> arr = Utils::split(_pinyinStr);
	string pubLetter = arr.at(0);
	CCNode* pBaseNode = m_pCcbNode->getChildByTag(kTagGamePanPublic);
	CCSprite* pItem = dynamic_cast<CCSprite*>(pBaseNode->getChildByTag(0)->getChildByTag(0));
	pItem->initWithSpriteFrameName((pubLetter+".png").c_str());
	pBaseNode = m_pCcbNode->getChildByTag(kTagGamePanField);
	for(int i =kTagGamePanFieldLeft;i<=kTagGamePanFieldRight;i++)
	{
		string pubLetter = arr.at(i);
		CCSprite* pItem = dynamic_cast<CCSprite*>(pBaseNode->getChildByTag(i)->getChildByTag(0));
		CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName((pubLetter+".png").c_str());
		if(frame)
			pItem->initWithSpriteFrame(frame);
		else
		{
			//CClog((pubLetter+".png no found").c_str());
			pItem->setVisible(false);
		}
	}
}
int LotteryAct2ShowView::hasTouchNode(cocos2d::CCTouch *pTouch)
{
    CCNode* node = NULL;
    for (int i = 0; i < m_aniListNode->getChildrenCount(); i++)
    {
        node = m_aniListNode->getChildByTag(i);
        if (isTouchInside(node->getChildByTag(0), pTouch))
        {
            return i;
        }
    }
    return -1;
}
// on "init" you need to initialize your instance
bool ComponentsTestLayer::init()
{
	bool bRet = false;
	do 
	{
        CC_BREAK_IF(! CCLayerColor::initWithColor( ccc4(255,255,255,255) ) );
        
        CCNode *root = createGameScene();
        CC_BREAK_IF(!root);
        this->addChild(root, 0, 1);

        root->getChildByTag(1)->addComponent(CCComAudio::create());
        root->getChildByTag(1)->addComponent(PlayerController::create());  
        
        root->addComponent(CCComAudio::create());
        root->addComponent(CCComAttribute::create());
        root->addComponent(SceneController::create());

		bRet = true;
	} while (0);

	return bRet;
}
Exemple #21
0
void GamePan::updateTimer(float delta)
{
	_curTime-=1;
	if(_curTime<0)
	{
		unschedule(schedule_selector(GamePan::updateTimer));
		_isPlayer = !_isPlayer;
		changeSide();
	}
	CCNode* pBaseNode = m_pCcbNode->getChildByTag(kTagGamePanBg);
	CCLabelBMFont* timerTxt = dynamic_cast<CCLabelBMFont*>(pBaseNode->getChildByTag(kTagGamePanBgTimer));
	int timeStr = (int)_curTime;
	timerTxt->setString(Utils::itos(timeStr).c_str());
}
Exemple #22
0
void GamePan::ResultBtnCallBack(CCObject* pSender)
{
	_isPlayer = true;
	_pinyinStr = "";
	_answerStr = "";
	createNextPuzzle();
	changeSide();
	hideResult();
	CCNode* fieldNode = m_pCcbNode->getChildByTag(kTagGamePanField);
	for(int i =kTagGamePanFieldLeft ;i<=kTagGamePanFieldRight;i++)
	{
		CCNode* bar = fieldNode->getChildByTag(i);
		bar->setPositionY(0);
	}
}
Exemple #23
0
void GamePan::resetGamePan()
{
	CCNode* pBaseNode = m_pCcbNode->getChildByTag(kTagGamePanWordPan);
	CCNode* tabNode = pBaseNode->getChildByTag(kTagGamePanWordPanTabBase);
	CCNode* itemNode = pBaseNode->getChildByTag(kTagGamePanWordPanItemBase);
	for(int i =0;i<MAX_LINE;i++)
	{
		for(int j =0;j<MAX_ROW;j++)
		{
			XCheckBox* pCheckBox = dynamic_cast<XCheckBox*>(tabNode->getChildByTag(j+i*MAX_ROW));
			if(pCheckBox)
				pCheckBox->setToggle(false);

			CCLabelTTF* title = dynamic_cast<CCLabelTTF*>(itemNode->getChildByTag(j+i*MAX_ROW));
			if(title)
			{
				CCString* str = (CCString*)_wordList->randomObject();
				title->setString(str->getCString());
				_wordList->removeObject(str);
			}
		}
	}
	refreshLetter();
}
void CCEDEVUpgradeScene::update(float v)
{
    CCEScene::update(v);

    CCEUpgradeManager* m = CCEUpgradeManager::sharedUpgradeManager();
    UpgradeInfo info;
    m->queryInfo(&info);

    if(m_lastInfo.end==info.end
            && m_lastInfo.fail==info.fail
            && m_lastInfo.finishWork==info.finishWork
            && m_lastInfo.message.compare(info.message)==0
            && m_lastInfo.totalWork==info.totalWork)
    {
        return;
    }

    CCNode* layer = getChildByTag(1);
    CCLabelTTF* l1 = (CCLabelTTF*) layer->getChildByTag(1);
    CCLabelTTF* l2 = (CCLabelTTF*) layer->getChildByTag(2);

    std::string s1;
    if(m->isProcessing() || info.end) {
        s1 = StringUtil::format("Status: %s", info.end?(info.fail?"fail":"done"):"processing");
        if(info.message.size()>0) {
            s1 += " - ";
            s1 += info.message;
        }
    } else {
        s1 = "Status: not start";
    }
    l1->setString(s1.c_str());

    std::string s2;
    if(!m->isProcessing() || info.totalWork==0) {
        s2 = "Progress: -- ";
    } else {
        s2 = StringUtil::format("Progress: %2.2f", info.finishWork*100.0f/info.totalWork);
    }
    l2->setString(s2.c_str());

    m_lastInfo.end = info.end;
    m_lastInfo.fail = info.fail;
    m_lastInfo.finishWork = info.finishWork;
    m_lastInfo.totalWork = info.totalWork;
    m_lastInfo.message = info.message;
}
//------------------------------------------------------------------
//
// Effect3
//
//------------------------------------------------------------------
void Effect3::onEnter()
{
	EffectAdvanceTextLayer::onEnter();

	CCNode* bg = getChildByTag(kTagBackground);
	CCNode* target1 = bg->getChildByTag(kTagSprite1);
	CCNode* target2 = bg->getChildByTag(kTagSprite2);	
	
	CCActionInterval* waves = CCWaves::actionWithWaves(5, 20, true, false, ccg(15,10), 5);
	CCActionInterval* shaky = CCShaky3D::actionWithRange(4, false, ccg(15,10), 5);
	
	target1->runAction( CCRepeatForever::actionWithAction( waves ) );
	target2->runAction( CCRepeatForever::actionWithAction( shaky ) );
	
	// moving background. Testing issue #244
	CCActionInterval* move = CCMoveBy::actionWithDuration(3, ccp(200,0) );
	bg->runAction(CCRepeatForever::actionWithAction( (CCActionInterval *)(CCSequence::actions(move, move->reverse(), NULL) ) ) );	
}
//------------------------------------------------------------------
//
// Effect3
//
//------------------------------------------------------------------
void Effect3::onEnter()
{
    EffectAdvanceTextLayer::onEnter();

    CCNode* bg = getChildByTag(kTagBackground);
    CCNode* target1 = bg->getChildByTag(kTagSprite1);
    CCNode* target2 = bg->getChildByTag(kTagSprite2);    
    
    CCActionInterval* waves = CCWaves::create(5, CCSizeMake(15,10), 5, 20, true, false);
    CCActionInterval* shaky = CCShaky3D::create(5, CCSizeMake(15,10), 4, false);
    
    target1->runAction( CCRepeatForever::create( waves ) );
    target2->runAction( CCRepeatForever::create( shaky ) );
    
    // moving background. Testing issue #244
    CCActionInterval* move = CCMoveBy::create(3, ccp(200,0) );
    bg->runAction(CCRepeatForever::create( CCSequence::create(move, move->reverse(), NULL) ));    
}
Exemple #27
0
void CMainCityUI::updateFuctionOpen(const TMessage& tMsg)
{
	int tag = tMsg.nMsg;
	if (tag>20)
	{	
		CCNode *child = m_ui->getChildByTag(tag-20);
		if (child)
		{
			CButton *btn = dynamic_cast<CButton*>(child->getChildByTag(tag-20));
			if (btn)
			{
				btn->setEnabled(true);
				btn->getNormalImage()->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderDefault));
				btn->getSelectedImage()->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderDefault));
			}	
		}
	}
}
Exemple #28
0
void LayerMenu::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
{
	if (isClick(pTouch))
	{
		CCNode* node = _view->getContainer();
		CCPoint ptInNode = node->convertTouchToNodeSpace(pTouch);
		for (int i = 0; i < 8; ++i)
		{
			CCSprite* sprite = (CCSprite*)node->getChildByTag(1000 + i);
			if (sprite->boundingBox().containsPoint(ptInNode))
			{
				//进入游戏场景
				CCDirector::sharedDirector()->replaceScene(Common::scene(LayerGame::create(i)));
				break;
			}
		}
	}
}
Exemple #29
0
void GameLayer::resetBarrierNode(CCNode *node, int nodeTag)
{
    // window size
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    // get batchnode
    CCSpriteBatchNode *batchNode = (CCSpriteBatchNode *)node->getChildByTag(MapBatchNodeTag);
    
    CCNode *mapNode = this->getChildByTag(nodeTag - MapBarrierStartTag + MapStartTag);
    CCSpriteBatchNode *mapBatchNode = (CCSpriteBatchNode *)mapNode->getChildByTag(MapBatchNodeTag);
    CCSprite *riverSprite = (CCSprite *)mapBatchNode->getChildByTag(MapRiverTag);
    
    // reset barrier position
    CCSprite *barrierSprite = (CCSprite *)batchNode->getChildByTag(MapBarrierTag);
    float iptr = winSize.height;
    float positionY = modff((CCRANDOM_0_1() * 100 + 50 + riverSprite->getPosition().y), &iptr);
    barrierSprite->setPosition(ccp(winSize.width/2.f, positionY));
}
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));
}