本文整理汇总了C++中CCMenu::getChildByTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenu::getChildByTag方法的具体用法?C++ CCMenu::getChildByTag怎么用?C++ CCMenu::getChildByTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenu
的用法示例。
在下文中一共展示了CCMenu::getChildByTag方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void LevelGame05::musicCallback(CCObject *pSender)
{
CCMenu *pmenu=(CCMenu *)getChildByTag(101);
pmenu->setEnabled(true);
CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
CCLayerColor *layer=( CCLayerColor *)getChildByTag(80);
if(isMusic == true)
{
isMusic = false;
/*CCDirector::sharedDirector()->end();*/
CCMenu* pMenu = (CCMenu *)layer->getChildByTag(128);
CCMenuItemImage *Item = (CCMenuItemImage *)pMenu->getChildByTag(127);
Item->setNormalSpriteFrame(cache->spriteFrameByName("close-pause-music.png"));
if(flagMusic == true)
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
else
{
isMusic =true;
CCMenu* pMenu = (CCMenu *)layer->getChildByTag(128);
CCMenuItemImage *Item = (CCMenuItemImage *)pMenu->getChildByTag(127);
Item->setNormalSpriteFrame(cache->spriteFrameByName("pause-music.png"));
if(flagMusic == true)
{
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}
else
{
SimpleAudioEngine::sharedEngine()->playBackgroundMusic("back2.mp3",true);
flagMusic = true;
}
}
//removeChildByTag(80);
}
示例2: makeSelectSpriteButton
void NovelScene::makeSelectSpriteButton(string str1, int next1Id, string str2, int next2Id)
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCMenu* pMenu = (CCMenu*) this->getChildByTag(kTag_MenuSelect);
if (pMenu)
{
pMenu->setVisible(true);
MenuItemSelectLabelSprite* menuSprite1 = (MenuItemSelectLabelSprite*) pMenu->getChildByTag(kTag_MenuSelect1);
menuSprite1->setNovelText(str1.c_str(), next1Id);
MenuItemSelectLabelSprite* menuSprite2 = (MenuItemSelectLabelSprite*) pMenu->getChildByTag(kTag_MenuSelect2);
menuSprite2->setNovelText(str2.c_str(), next2Id);
}
else
{
//선택지1
MenuItemSelectLabelSprite* menuSprite1 = MenuItemSelectLabelSprite::createWithLabelSprite("menu_button.png", str1.c_str(), "Arial", BASE_FONT_SIZE, ccBLACK, ccBLUE, ccRED, next1Id, this, menu_selector(NovelScene::menuSelectCallback));
menuSprite1->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.55));
menuSprite1->setTag(kTag_MenuSelect1);
menuSprite1->setZOrder(kZOrder_MenuSelect);
//선택지2
MenuItemSelectLabelSprite* menuSprite2 = MenuItemSelectLabelSprite::createWithLabelSprite("menu_button.png", str2.c_str(), "Arial", BASE_FONT_SIZE, ccBLACK, ccBLUE, ccRED, next2Id, this, menu_selector(NovelScene::menuSelectCallback));
menuSprite2->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.45));
menuSprite2->setTag(kTag_MenuSelect2);
menuSprite2->setZOrder(kZOrder_MenuSelect);
//메뉴 작성
pMenu = CCMenu::create(menuSprite1, menuSprite2, NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu, kZOrder_MenuSelect, kTag_MenuSelect);
}
}
示例3: checkCard
void MarketScene::checkCard(int index)
{
CCMenu *pMenu = (CCMenu *)this->getChildByTag(TAG_MENU);
char szFileName[32] = { 0 };
for (int i = 0; i < CARD_COUNT; i++)
{
int tag = BTN_CARD + i;
CCMenuItemToggle *pToggle = (CCMenuItemToggle *)pMenu->getChildByTag(tag);
if (tag == index)
{
selectedIndex = index;
pToggle->setSelectedIndex(1);
pToggle->setEnabled(false);
sprintf(szFileName, s_pathCardInfo.m_strPath, i);
int price = getPrice(tag);
updateLabelAtlas(price, LabelAtlas_PRICE);
CCMenuItemImage *pMenuItem = (CCMenuItemImage *)pMenu->getChildByTag(BTN_BUY);
if (g_Control.cards[i] <= 0 && g_Control.m_nCoin > price)
{
pMenuItem->setEnabled(true);
}
else
{
pMenuItem->setEnabled(false);
}
}
else
{
pToggle->setSelectedIndex(0);
pToggle->setEnabled(true);
}
}
this->removeChildByTag(CARD_INFO);
CCSprite *pcdSprite = CCSprite::create(szFileName);
pcdSprite->setPosition(s_pathCardInfo.m_Position);
pcdSprite->setTag(CARD_INFO);
this->addChild(pcdSprite);
pcdSprite->runAction(CCSequence::create(CCSpawn::create(CCScaleTo::create(0.2f, 1.0f), CCFadeTo::create(0.2f, 255), NULL), NULL));
}
示例4: updateMe
void LayerGoods::updateMe()
{
UserInfo *user_info = Topwo::getInstance()->getTopwoData()->getUserInfo();
CCMenu* menu = static_cast<CCMenu*>(this->getChildByTag(0));
//体魄
int goods_level = 0;
CCMenuItemSprite* item = NULL;
CCSprite* sprite = NULL;
CCLabelAtlas* la = NULL;
for (int i = 1; i <= 5; i++)
{
if (i == 1)
{
goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelTiPo());
}
else if (i == 2)
{
goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelMeiLi());
}
else if (i == 3)
{
goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelZhiLi());
}
else if (i == 4)
{
goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelEQ());
}
else if (i == 5)
{
goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelGanXing());
}
item = static_cast<CCMenuItemSprite*>(menu->getChildByTag(i));
if (goods_level >= 9)
{
item->setEnabled(false);
item->setColor(ccc3(128, 128, 128));
}
sprite = static_cast<CCSprite*>(this->getChildByTag(i));
la = static_cast<CCLabelAtlas*>(sprite->getChildByTag(0));
la->setString(CCString::createWithFormat("%d", goods_level)->getCString());
la = static_cast<CCLabelAtlas*>(sprite->getChildByTag(1));
la->setString(CCString::createWithFormat("%d", getGoodsBonus(goods_level))->getCString());
la = static_cast<CCLabelAtlas*>(sprite->getChildByTag(2));
la->setString(CCString::createWithFormat("%d", getGoodsPrice(goods_level))->getCString());
}
SceneMain* scene_main = static_cast<SceneMain*>(CCDirector::sharedDirector()->getRunningScene()->getChildByTag(0));
scene_main->updateMe();
}
示例5: init
bool RPGMapItemsMenuLayer::init(cocos2d::CCDictionary *stringList, CppSQLite3DB *db, float width, float height)
{
if(CCLayerColor::initWithColor(ccc4(0, 0, 0, 200), width, height))
{
this->m_stringList = stringList;
this->m_stringList->retain();
this->m_db = db;
this->m_itemsList = new CCArray();
this->m_itemsList->init();
CCTMXTiledMap *mainBg = CCTMXTiledMap::create(CCString::createWithFormat("map_menu3_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString());
mainBg->setPosition(CCPointZero);
mainBg->setTag(kRPGMapItemsMenuLayerTagBg);
this->addChild(mainBg);
CCMenu *mainMenu = CCMenu::create();
mainMenu->setTag(kRPGMapItemsMenuLayerTagMainMenu);
mainMenu->setAnchorPoint(CCPointZero);
mainMenu->setPosition(CCPointZero);
this->addChild(mainMenu);
CCMenuItemSprite *menuBack = (CCMenuItemSprite*)mainMenu->getChildByTag(kRPGMapItemsMenuLayerTagMainMenuBack);
if(!menuBack)
{
menuBack = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGMapItemsMenuLayer::onMenu));
menuBack->setPosition(ccp(40, 600));
menuBack->setTag(kRPGMapItemsMenuLayerTagMainMenuBack);
menuBack->setScale(0.5);
mainMenu->addChild(menuBack);
}
CCTableView *tableView = CCTableView::create(this, CCSizeMake(900, 570));
tableView->setDirection(kCCScrollViewDirectionVertical);
tableView->setPosition(ccp(80, 30));
tableView->setDelegate(this);
tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
tableView->setTag(kRPGMapItemsMenuLayerTagItemListTable);
this->addChild(tableView);
this->loadItemsData();
return true;
}
return false;
}
示例6: buyCard
void MarketScene::buyCard(CCNode * pNode)
{
int price = getPrice(selectedIndex);
if (g_Control.m_nCoin >= price)
{
CCMenuItemImage *pItem = (CCMenuItemImage *)pNode;
pItem->setEnabled(false);
//¹´Ñ¡ÒÑÂòÏî
CCMenu *pMenu = (CCMenu *)this->getChildByTag(TAG_MENU);
CCMenuItemToggle *pToggle = (CCMenuItemToggle *)pMenu->getChildByTag(selectedIndex);
CCSprite *sprite = CCSprite::create(s_pathCardbuy.m_strPath);
sprite->setPosition(s_pathCardbuy.m_Position);
pToggle->addChild(sprite, TAG_CARD_BUY, TAG_CARD_BUY);
//¿ÛÇ®
g_Control.m_nCoin -= price;
updateLabelAtlas(g_Control.m_nCoin, LabelAtlas_COIN);
g_Control.cards[selectedIndex - BTN_CARD] = 1;
g_Control.save();
}
}
示例7: update
void CNFRockerLayer::update( float delta )
{
do
{
//得到主角
CNFProtagonist * pPro = dynamic_cast<CNFProtagonist *>(m_p3DLayer->getChildByTag(enTagProtagonist));
if (pPro!=NULL)
{
//得到摇杆
CCSprite * pRockerBg = dynamic_cast<CCSprite *>(getChildByTag(enTagRockerBg));
CC_BREAK_IF(pRockerBg==NULL);
CCSprite * pRocker = dynamic_cast<CCSprite *>(getChildByTag(enTagRocker));
CC_BREAK_IF(pRocker==NULL);
//若正在触摸
if (m_bIsTouching==true)
{
pRocker->setOpacity(255.f);
pRockerBg->setOpacity(255.f);
//触摸点与摇杆背景的距离
float fRockerDisX = m_ptTouching.x - pRockerBg->getPositionX();
float fRockerDisY = m_ptTouching.y - pRockerBg->getPositionY();
float fLen = sqrt(pow(fRockerDisX,2)+pow(fRockerDisY,2));
//触摸点与摇杆背景的角度
float fRate = (float)CC_RADIANS_TO_DEGREES( atanf(fRockerDisX/fRockerDisY) );
if(fRockerDisY<0) fRate += 180.f;
else if(fRockerDisX<0) fRate += 360.f;
//触摸点的实际位置
CCPoint ptRockerMoveTo;
if (fLen >= m_fRockerMaxDis) fLen = m_fRockerMaxDis;
ptRockerMoveTo.x = sin(fRate/180*3.1415)*fLen + pRockerBg->getPositionX();
ptRockerMoveTo.y = cos(fRate/180*3.1415)*fLen + pRockerBg->getPositionY();
//触摸点与摇杆的距离
float fDisX = ptRockerMoveTo.x - pRocker->getPositionX();
float fDisY = ptRockerMoveTo.y - pRocker->getPositionY();
float fLength = sqrt(pow(fDisX,2)+pow(fDisY,2));
//出发每次移动的条件:距离至少大于速度。 防止颤动
if (fLength > m_fRockerSpeed)
{
//触摸点与摇杆的角度
float fRateRocker = (float)CC_RADIANS_TO_DEGREES( atanf(fDisX/fDisY) );
if(fDisY<0) fRateRocker += 180.f;
else if(fDisX<0) fRateRocker += 360.f;
ptRockerMoveTo.x = sin(fRateRocker/180*3.1415)*m_fRockerSpeed + pRocker->getPositionX();
ptRockerMoveTo.y = cos(fRateRocker/180*3.1415)*m_fRockerSpeed + pRocker->getPositionY();
pRocker->setPosition(ptRockerMoveTo);
}
else //距离小于速度,则直接命中
{
pRocker->setPosition(ptRockerMoveTo);
}
//主角移动
pPro->OnCtrlMoveByRotation(fRate);
}
//若触摸结束
else
{
pRocker->setOpacity(100.f);
pRockerBg->setOpacity(100.f);
pPro->OnCtrlStop();
//移动距离
float fDisX = pRockerBg->getPositionX() - pRocker->getPositionX();
float fDisY = pRockerBg->getPositionY() - pRocker->getPositionY();
float fLen = sqrt(pow(fDisX,2)+pow(fDisY,2));
//若距离大于速度,则移动
if (fLen > m_fRockerSpeed)
{
float at = (float)CC_RADIANS_TO_DEGREES( atanf(fDisX/fDisY) );
if(fDisY<0) at += 180.f;
else if(fDisX<0) at += 360.f;
CCPoint ptRockerMoveTo;
ptRockerMoveTo.x = sin(at/180*3.1415)*m_fRockerSpeed + pRocker->getPositionX();
ptRockerMoveTo.y = cos(at/180*3.1415)*m_fRockerSpeed + pRocker->getPositionY();
pRocker->setPosition(ptRockerMoveTo);
}
else //若距离小雨速度,则直接命中
{
pRocker->setPosition(pRockerBg->getPosition());
}
}
//若为副本,则执行按钮逻辑
if (m_nStageID >= _NF_TOWN_OR_BATTLE_ID_ && m_nStageID <_NF_TOWN_FB_ID_)
{
//得到菜单
CCMenu * pMenu = dynamic_cast<CCMenu *>(getChildByTag(enTagMenu));
CC_BREAK_IF(pMenu==NULL);
//.........这里部分代码省略.........
示例8: tableCellAtIndex
CCTableViewCell* MailListScene::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
CCString *string = (CCString *)mArrayList->objectAtIndex(idx);
CCSize size = this->tableCellSizeForIndex(table, idx);
CCTableViewCell *cell = table->dequeueCell();
if (!cell) {
cell = new CCTableViewCell();
cell->autorelease();
CCSprite *sState = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("mail_state_read.png"));
sState->setAnchorPoint(CCPointMake(0, 0.5));
sState->setPosition(ccp(10,size.height * 0.5));
sState->setTag(120);
cell->addChild(sState);
CCLabelTTF *lblName = CCLabelTTF::create(string->getCString(), "Arial", 14.0);
lblName->setPosition(ccp(65,size.height * 0.5));
lblName->setColor(ccc3(255, 255, 204));
//lblName->enableStroke(ccc3(51, 0, 0), 0.6);
lblName->setTag(121);
lblName->setHorizontalAlignment(kCCTextAlignmentLeft);
lblName->setString(string->getCString());
cell->addChild(lblName);
CCLabelTTF *lblSubject = CCLabelTTF::create("100", "Arial", 14.0);
lblSubject->setPosition(ccp(130,size.height * 0.5));
lblSubject->setColor(ccc3(255, 255, 204));
//lblSubject->enableStroke(ccc3(51, 0, 0), 0.6);
lblSubject->setTag(122);
lblSubject->setString(string->getCString());
cell->addChild(lblSubject);
CCScale9Sprite *sline = CCScale9Sprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("mail_line.png"));
sline->setPreferredSize(CCSizeMake(310, 1));
sline->setPosition(ccp(0,size.height-2));
sline->setAnchorPoint(CCPointZero);
cell->addChild(sline);
CCMenu *menuCheck = this->generateCheckBox();
cell->addChild(menuCheck);
CCMenuItemToggle *toggle= (CCMenuItemToggle *)menuCheck->getChildByTag(1);
toggle->setUserData(&vUserData[idx]);
if (vUserData[idx] == 1) {
toggle->setSelectedIndex(1);
} else {
toggle->setSelectedIndex(0);
}
menuCheck->setTag(123);
menuCheck->setAnchorPoint(CCPointMake(0, 0.5));
menuCheck->setPosition(CCPointMake(280, size.height * 0.5));
}
else
{
CCLabelTTF *lblName = (CCLabelTTF*)cell->getChildByTag(121);
lblName->setString(string->getCString());
CCLabelTTF *lblSubject = (CCLabelTTF*)cell->getChildByTag(122);
lblSubject->setString(string->getCString());
CCMenu *menuCheck = (CCMenu *)cell->getChildByTag(123);
CCMenuItemToggle *toggle= (CCMenuItemToggle *)menuCheck->getChildByTag(1);
toggle->setUserData(&vUserData[idx]);
if (vUserData[idx] == 1) {
toggle->setSelectedIndex(1);
} else {
toggle->setSelectedIndex(0);
}
}
return cell;
}