本文整理汇总了C++中CCMenuItem::getTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItem::getTag方法的具体用法?C++ CCMenuItem::getTag怎么用?C++ CCMenuItem::getTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItem
的用法示例。
在下文中一共展示了CCMenuItem::getTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onSelected
void DropDownListSprite:: onSelected(CCObject * sender)
{
CCMenuItem * item = dynamic_cast<CCMenuItem *>(sender);
if (item)
{
m_lastSelectedIndex = item->getTag();
m_showLabel->setString(m_selectLabels[item->getTag()]->getString());
}
onClose();
}
示例2: menuCallback
void CardListScene::menuCallback(CCObject* pSender)
{
CCMenuItem *menuItem = (CCMenuItem *)pSender;
int tag=menuItem->getTag();
if (menuItem->getTag()==TAG_MENU_BACK) {
S_DR->replaceScene(CardShelfScene::scene());
}else{
S_AE->playEffect("E4.mp3");
XieziCoverLayer* xieziCoverLayer=XieziCoverLayer::create(tag,NULL);
xieziCoverLayer->setDelegate(this);
this->addChild(xieziCoverLayer,INT_MAX);
}
}
示例3:
void COxCJ4UILayer::OnTouchJetton(CCObject* pObject)
{
CCMenuItem * pItem = dynamic_cast<CCMenuItem *>(pObject);
if (pItem == NULL)
return ;
int nTag = pItem->getTag();
if (nTag < m_nJetBeginTag || nTag >= (int)(m_nJetBeginTag + CountArray(m_pBtnJetton)))
{
CC_ASSERT(false);
return ;
}
for (BYTE i = 0; i < CountArray(m_pBtnJetton); ++i)
{
if (m_pBtnJetton[i])
m_pBtnJetton[i]->setVisible(false);
}
nTag -= m_nJetBeginTag;
if (m_pJettonValue[nTag] == NULL)
return ;
if (m_pGameLayer->GetGameStatus() != GS_TK_SCORE)
return ;
LONGLONG lScore = 0;
sscanf(m_pJettonValue[nTag]->getString(), "%lld", &lScore);
m_pGameLayer->MePlaceJetton(lScore);
}
示例4: onButtonClick
void LayerMoney::onButtonClick(CCObject* pSender)
{
CCMenuItem* mnu = (CCMenuItem*)pSender;
int tag = mnu->getTag();
if( currTag == tag )
return;
//
switch (tag) {
case tag_ChargeDisable:
currTag = tag_ChargeEnable;
gotoChargeMoney();
break;
case tag_HistoryDisable:
currTag = tag_HistoryEnable;
gotoHistory();
break;
case tag_TransferDisable:
currTag = tag_TransferEnable;
gotoTransfer("");
break;
case tag_LoanDisable:
currTag = tag_LoanEnable;
gotoBorrow();
break;
case tag_ExchangeDisable:
currTag = tag_ExchangeEnable;
gotoExchange();
break;
}
disableTabs(currTag);
CCLOG("onButtonClick with tag: %d", tag);}
示例5: onMenu
void RPGMapItemsMenuLayer::onMenu(cocos2d::CCObject *pObject)
{
CCMenuItem *menuItem = (CCMenuItem*)pObject;
SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
switch (menuItem->getTag())
{
case kRPGMapItemsMenuLayerTagMainMenuBack:
{
// CCLog("后退");
//因为动态获取地图的大小会导致了菜单层显示错位,所以定死了
float width = 960;
float height = 640;
RPGMapMenuLayer *menuLayer = menuLayer = RPGMapMenuLayer::create(this->m_stringList, this->m_db, width, height);
menuLayer->setPosition(ccp((CCDirector::sharedDirector()->getWinSize().width - width) / 2.0, (CCDirector::sharedDirector()->getWinSize().height - height) / 2.0));
menuLayer->setTag(kRPGMapSceneLayerTagMenuLayer);
this->getParent()->addChild(menuLayer);
this->removeFromParentAndCleanup(true);
}
break;
default:
break;
}
}
示例6: onDialog
void RPGStartSceneLayer::onDialog(cocos2d::CCObject *pObject)
{
SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
CCMenuItem *menuItem = (CCMenuItem*)pObject;
switch (menuItem->getTag())
{
case kRPGStartSceneLayerTagDialogCancel:
{
this->removeChildByTag(kRPGStartSceneLayerTagDialog, true);
CCMenu *mainMenu = (CCMenu*)this->getChildByTag(kRPGStartSceneLayerTagMainMenu);
mainMenu->setEnabled(true);
}
break;
default:
{
//kRPGStartSceneLayerTagMenuItemDialogOK
//清除数据
this->m_db.execDML("delete from save_data");
this->m_db.execDML("delete from items_existing");
this->m_db.execDML(GAME_INIT_SQL);
//默认设置
CCUserDefault::sharedUserDefault()->setStringForKey(GAME_STYLE, this->m_styleData[1].first);
this->goToMapScene();
}
break;
}
}
示例7: onButtonClick
void LayerFriend::onButtonClick(CCObject* pSender)
{
CCMenuItem* mnu = (CCMenuItem*)pSender;
int tag = mnu->getTag();
if( currTag == tag )
return;
//
switch (tag) {
case tag_friendInfoDisable:
currTag = tag_friendInfoEnable;
gotoFriendDetails();
//
break;
case tag_inviteDisable:
// CCNodeLoaderLibrary* ccNodeLoaderLibrary = SceneManager::getSingleton().getNodeLoaderLibrary();
// CCBReader* ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
// ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
// LayerInviteFriends* mLayer;
// if (ccbReader)
// {
// mLayer = (LayerInviteFriends *)ccbReader->readNodeGraphFromFile( "LayerInviteFriends.ccbi" );
// this->addChild(mLayer, 1, 1);
// ccbReader->release();
// }
//
gotoInviteFriends();
//return;
currTag = tag_inviteEnable;
break;
}
disableTabs(currTag);
CCLOG("onButtonClick with tag: %d", tag);}
示例8: selectButtonPressed
void Senario::selectButtonPressed(CCObject* pSender)
{
CCMenuItem* pMenuItem = (CCMenuItem *)(pSender);
int index = pMenuItem->getTag();
Slide* slide = (Slide*)slidesList->objectAtIndex(curSlide);
CCArray* elementArray = slide->elementList;
Element* ele = (Element*)elementArray->objectAtIndex(index);
if(ele->outcome)
{
GameScene::getThis()->globalOutcomeModifier->banditsModifier = ele->banditsModifier;
GameScene::getThis()->globalOutcomeModifier->refugeesModifier = ele->refugeeModifier;
GameScene::getThis()->globalOutcomeModifier->goldModifier = ele->goldModifier;
GameScene::getThis()->globalOutcomeModifier->foodModifier = ele->foodModifier;
GameScene::getThis()->globalOutcomeModifier->populationModifier = ele->populationModifier;
}
string fileName = ele->nextFile;
slidesList->removeAllObjects();
CC_SAFE_RELEASE(slidesList);
SenarioManager* sm = new SenarioManager();
sm->parseXMLFile(fileName.c_str());
slidesList = sm->slidesList;
delete sm;
inOption = false;
curSlide = 0;
if(!constructSenarioStage(false)){
buttonSelect();
}
}
示例9: menuCallback_Selet
void MovieMenu::menuCallback_Selet(CCObject* pSender)
{
setKeypadEnabled(false);
CCDirector::sharedDirector()->purgeCachedData();
CCMenuItem *item = (CCMenuItem*)pSender;
bool bCallCamera = false;
if ( PROJECT_TYPE == TYPE_BABYPRESIDENT )
{
CCLog ("MovieMenu menuCallback_Selet - item->getTag() : %d", item->getTag());
bool bUserImgIndex = false;
switch(item->getTag())
{
case USER_IMG_1ST:
bUserImgIndex = CCUserDefault::sharedUserDefault()->getBoolForKey("have_userImg", false);
if ( false == bUserImgIndex )
bCallCamera = true;
break;
case USER_IMG_2ND:
bUserImgIndex = CCUserDefault::sharedUserDefault()->getBoolForKey("have_userImg2", false);
if ( false == bUserImgIndex )
bCallCamera = true;
break;
case USER_IMG_3TH:
bUserImgIndex = CCUserDefault::sharedUserDefault()->getBoolForKey("have_userImg3", false);
if ( false == bUserImgIndex )
bCallCamera = true;
break;
}
}
else
{
SELECT_GAME game;
game.nLevel = m_nGameLevel;
game.nImgIndex = item->getTag();
CCScene *pScene = JS_Main::scene(game);
// CCDirector::sharedDirector()->pushScene(CCTransitionFade::create( 0.3f, pScene ) );
CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create( 0.3f, pScene ) );
}
}
示例10: LetterBtnClick
void CChooseLetterWindow::LetterBtnClick(Object* sender)
{
if(!m_ChoosenLetter)
{
return;
}
CCMenuItem * button = (CCMenuItem*) sender;
m_ChoosenLetter->SetLetter((char)button->getTag());
Hide();
}
示例11: newGame
void BoxMenu::newGame(CCObject* pSender)
{
Score *scoreInstance = Score::GetInstance();
CCMenuItem *menuItem = (CCMenuItem *)pSender;
scoreInstance->teamTag = menuItem->getTag();
std::cout << "get tag:" << scoreInstance->teamTag << std::endl;
CCDirector::sharedDirector()->replaceScene(GameScene::sceneWithStage(0));
}
示例12: gymnasticControlCallBack
void GymnasticGameScene::gymnasticControlCallBack(CCObject* pSender) {
CCMenuItem *item = (CCMenuItem*) pSender;
int tag = item->getTag();
if(tag==1)
{
_player->setRotation(_player->getRotation()+5);
}else
{
_player->setRotation(_player->getRotation()-5);
}
}
示例13: upgrade
void Tower::upgrade(CCObject *sender) {
if (sender) {
CCMenuItem *item = (CCMenuItem *)sender;
TowerType type = (TowerType)item->getTag();
setArchitecture(Architecture::getArchitectureForType(type));
GameModel::instance()->getPopupMenu()->closeMenu();
GameModel::instance()->getGamePlayScene()->removeChildByTag(kTowerDescriptionTag, true);
}
}
示例14: MenuCallback
void MainScene::MenuCallback(CCObject* sender)
{
// This is a very contrived example
// for handling the menu items.
// -1 ==> Left Arrow
// -2 ==> Right Arrow
// Anything else is a selection
CCMenuItem* pMenuItem = (CCMenuItem*)sender;
switch(pMenuItem->getTag())
{
case ARROW_LEFT:
PageLeft();
break;
case ARROW_RIGHT:
PageRight();
break;
default:
CCLOG("Got Item %d Pressed",pMenuItem->getTag());
break;
}
}
示例15: menuCallback
void TestController::menuCallback(cocos2d::CCObject *pSender)
{
CCMenuItem* pMenuItem = (CCMenuItem *)(pSender);
int nIdx = pMenuItem->getTag() - 10000;
CCLOG("click menu index = %d", nIdx);
// create the test scene and run it
TestBaseLayer* layer = CreateTestScene(nIdx);
if (layer)
{
layer->runThisLayer();
}
}