本文整理汇总了C++中CCNode::getChildByTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CCNode::getChildByTag方法的具体用法?C++ CCNode::getChildByTag怎么用?C++ CCNode::getChildByTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCNode
的用法示例。
在下文中一共展示了CCNode::getChildByTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Attack
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));
}
示例2: disableAllTouchBegin
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);
}
}
}
}
}
示例3: inactivateHeml
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) );
}
示例4: checkAnswer
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;
}
示例5: init
// 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;
}
示例6: 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));
}
示例7: update
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());
}
示例8: disableAllTouchEnd
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);
}
示例9: 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
}
示例10: checkWhoWin
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();
}
}
示例11: showResult
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));
}
}
示例12: updateOpenState
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;
}
}
示例13: autoRoll
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;
}
示例14: ccTouchEnded
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();
}
}
示例15: updateGoogleLoginBtn
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
}