本文整理汇总了C++中CCMenu::setTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenu::setTag方法的具体用法?C++ CCMenu::setTag怎么用?C++ CCMenu::setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenu
的用法示例。
在下文中一共展示了CCMenu::setTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addChild
//------------------------------------------------------------------
//
// MenuLayer2
//
//------------------------------------------------------------------
MenuLayer2::MenuLayer2()
{
for( int i=0;i < 2;i++ )
{
CCMenuItemImage* item1 = CCMenuItemImage::create(s_PlayNormal, s_PlaySelect, this, menu_selector(MenuLayer2::menuCallback));
CCMenuItemImage* item2 = CCMenuItemImage::create(s_HighNormal, s_HighSelect, this, menu_selector(MenuLayer2::menuCallbackOpacity) );
CCMenuItemImage* item3 = CCMenuItemImage::create(s_AboutNormal, s_AboutSelect, this, menu_selector(MenuLayer2::menuCallbackAlign) );
item1->setScaleX( 1.5f );
item2->setScaleX( 0.5f );
item3->setScaleX( 0.5f );
CCMenu* menu = CCMenu::create(item1, item2, item3, NULL);
CCSize s = CCDirector::sharedDirector()->getWinSize();
menu->setPosition(ccp(s.width/2, s.height/2));
menu->setTag( kTagMenu );
addChild(menu, 0, 100+i);
m_centeredMenu = menu->getPosition();
}
m_alignedH = true;
alignMenusH();
}
示例2: leafletChoiceHandler
void StoryWorld::leafletChoiceHandler(CCObject *sender) {
int choice = ((CCNode *)sender)->getTag();
switch (choice) {
case fChoice: {
removeChildByTag(2);
removeChildByTag(3);
CCSprite *blackBG = CCSprite::create(LEAFLET_IMG_PATH);
blackBG->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/2));
blackBG->setScale(1);
blackBG->setTag(21);
addChild(blackBG, 2);
CCMenuItemImage *start = CCMenuItemImage::create(LEAFLET_CLOSE_IMG_PATH, LEAFLET_CLOSE_IMG_PATH, this, menu_selector(StoryWorld::menuLeafletsCloseCallback));
start->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width-40, CCDirector::sharedDirector()->getVisibleSize().height-40));
CCMenu* pMenu = CCMenu::create(start, NULL);
pMenu->setPosition(CCPointZero);
pMenu->setTag(23);
addChild(pMenu, 4);
}
return;
case sChoice:
default:{
specialPartSwitchCase('1');
}
return;
}
}
示例3: showMainMenu
void RPGStartSceneLayer::showMainMenu()
{
CCMenu *mainMenu = CCMenu::create();
mainMenu->setAnchorPoint(CCPointZero);
mainMenu->setPosition(CCPointZero);
mainMenu->setTag(kRPGStartSceneLayerTagMainMenu);
this->addChild(mainMenu);
CCString *menuStartStr = (CCString*)this->m_stringList->objectForKey("mainmenu_start");
CCLabelTTF *menuStartLabel = CCLabelTTF::create(OzgCCUtility::generalString(menuStartStr->getCString()).c_str(), "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
CCString *menuRestartStr = (CCString*)this->m_stringList->objectForKey("mainmenu_restart");
CCLabelTTF *menuRestartLabel = CCLabelTTF::create(OzgCCUtility::generalString(menuRestartStr->getCString()).c_str(), "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
CCString *menuSettingsStr = (CCString*)this->m_stringList->objectForKey("mainmenu_settings");
CCLabelTTF *menuSettingsLabel = CCLabelTTF::create(OzgCCUtility::generalString(menuSettingsStr->getCString()).c_str(), "FZCuYuan-M03S", 28, CCSizeMake(120, 40), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
CCMenuItemLabel *menuStart = CCMenuItemLabel::create(menuStartLabel, this, menu_selector(RPGStartSceneLayer::onMenu));
menuStart->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, 230));
menuStart->setTag(kRPGStartSceneLayerTagMainMenuItemStart);
mainMenu->addChild(menuStart);
CCMenuItemLabel *menuRestart = CCMenuItemLabel::create(menuRestartLabel, this, menu_selector(RPGStartSceneLayer::onMenu));
menuRestart->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, 170));
menuRestart->setTag(kRPGStartSceneLayerTagMainMenuItemRestart);
mainMenu->addChild(menuRestart);
CCMenuItemLabel *menuSettings = CCMenuItemLabel::create(menuSettingsLabel, this, menu_selector(RPGStartSceneLayer::onMenu));
menuSettings->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, 110));
menuSettings->setTag(kRPGStartSceneLayerTagMainMenuItemSettings);
mainMenu->addChild(menuSettings);
}
示例4: createPlayAgainButton
void GameOverLayer::createPlayAgainButton()
{
// Create the startButton
CCSprite *playAgainButtonSpriteUp = CCSprite::createWithSpriteFrameName("playagain_button.png");
CCSprite *playAgainButtonSpriteDown = CCSprite::createWithSpriteFrameName("playagain_button.png");
// Scale the down to 90% so that it looks like the button was pressed
playAgainButtonSpriteDown->setScale(0.9f);
CCMenuItemSprite *playAgainButton = CCMenuItemSprite::create(playAgainButtonSpriteUp, playAgainButtonSpriteDown, this, menu_selector(GameOverLayer::playAgainButtonTouched));
playAgainButton->setPositionX(-playAgainButton->getContentSize().width/1.2);
playAgainButton->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCScaleTo::create(1.0f, 1.2f), CCScaleTo::create(1.0f, 1.0f))));
// Create the mainButton
CCSprite *mainButtonSpriteUp = CCSprite::createWithSpriteFrameName("main_button.png");
CCSprite *mainButtonSpriteDown = CCSprite::createWithSpriteFrameName("main_button.png");
// Scale the down to 90% so that it looks like the button was pressed
mainButtonSpriteDown->setScale(0.9f);
CCMenuItemSprite *mainButton = CCMenuItemSprite::create(mainButtonSpriteUp, mainButtonSpriteDown, this, menu_selector(GameOverLayer::mainButtonTouched));
mainButton->setPositionX(mainButton->getContentSize().width/1.2);
// Create the start game menu
CCMenu *gameMenu = CCMenu::create(playAgainButton, mainButton, NULL);
// Set the initial position off screen
gameMenu->setPosition(ccp(SCREEN_WIDTH/2, -SCREEN_HEIGHT));
// Set the tag of the start menu so that we can refer to it later using getChildByTag(...)
gameMenu->setTag(kGameOverLayer_PlayAgainMenu);
// Create and run an animation that will slide the start game menu in from below the screen to its intended location
CCActionInterval *moveAction = CCMoveTo::create(0.3f, ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.15));
CCFiniteTimeAction *easeIn = CCEaseIn::create(moveAction, 0.2f);
gameMenu->runAction(easeIn);
// Add the start menu to the layer
this->addChild(gameMenu);
}
示例5: onEnter
//--------------------------------------------------------------
//
//
void COption::onEnter()
{
CCXMLLayer::onEnter();
LoadPlist("option.plist");
const char *MenuButton[] =
{
"button_back", "button_delsave",
};
for( int i = 0; i < 2; i++ )
{
CCSprite *pSprite= (CCSprite*)GetXMLNodeFromKey( MenuButton[i] );
CCMenu *pMenu = CreatGameUIWithSprite( pSprite, menu_selector(COption::menuCallback), i, this, pSprite->getPosition() );
addChild( pMenu, pSprite->getZOrder() );
pMenu->setTag( i );
removeChild( pSprite, true );
}
const char *MenuButton2[] =
{
"button_close1", "button_close2", "button_open1", "button_open2"
};
for( int i = 0; i < 4; i++ )
{
CCSprite *pSprite= (CCSprite*)GetXMLNodeFromKey( MenuButton2[i] );
CCMenu *pMenu = CreatGameUIWithSprite( pSprite, menu_selector(COption::menuSound), i%2, this, pSprite->getPosition() );
addChild( pMenu, pSprite->getZOrder() );
pMenu->setTag( i );
pMenu->setIsVisible( false );
removeChild( pSprite, true );
m_pControlMenu[i] = pMenu;
}
//CCUserDefault::sharedUserDefault()->setBoolForKey("music", true );
//CCUserDefault::sharedUserDefault()->setBoolForKey("sound", true );
schedule( schedule_selector( COption::UpData ), 0.1f );
}
示例6: createBlock
CCMenuItemImage* HelloWorld::createBlock(int posX, int posY, float sizeY, int tag)
{
CCMenu* menu = CCMenu::create();
CCMenuItemImage* block = CCMenuItemImage::create("/block.png","/block.png",this,menu_selector(HelloWorld::selectBlock));
block->setScale(float(0.3));
block->setPosition(ccp(posX,posY));
block->setScaleX(sizeY);
block->setTag(tag);
menu->setTag(tag);
menu->addChild(block);
this->addChild(menu);
return block;
}
示例7: createPillar
CCMenuItemImage* HelloWorld::createPillar(int posX, int tag)
{
CCMenu* menu = CCMenu::create();
CCMenuItemImage* pillar = CCMenuItemImage::create("/pillar.png","/pillar.png",this,menu_selector(HelloWorld::selectPillar));
pillar->setScaleX(float(0.2));
pillar->setScaleY(float(0.4));
pillar->setPosition(ccp(posX,-75));
pillar->setTag(tag);
pillar->setEnabled(false);
menu->setTag(tag);
menu->addChild(pillar);
this->addChild(menu);
return pillar;
}
示例8: specialPartSwitchCase
void StoryWorld::specialPartSwitchCase(int code) {
switch (code) {
case '1':{
setTouchEnabled(false);
CCSprite *back = CCSprite::create(CONFIRM_BACKGROUND_IMG_PATH);
back->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/2));
back->setTag(3);
addChild(back, 3);
CCLabelTTF *nextPlaceName = CCLabelTTF::create("", "Heiti SC", 48);
nextPlaceName->setString(dialog+5);
nextPlaceName->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 3.1));
back->addChild(nextPlaceName);
CCMenuItemImage *confirmBtn = CCMenuItemImage::create(CONFIRM_BUTTOM_IMG_PATH, CONFIRM_BUTTOM_IMG_PATH, this, menu_selector(StoryWorld::confirmButtonHandler));
confirmBtn->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/5 * 2));
CCMenu *menu = CCMenu::create(confirmBtn, NULL);
menu->setPosition(CCPointZero);
menu->setTag(2);
addChild(menu, 3);
}
break;
case '2':{
setTouchEnabled(false);
CCSprite* staff_bg = CCSprite::create(STAFFBG_IMG_PATH);
staff_bg->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2 + CCDirector::sharedDirector()->getVisibleOrigin().x, CCDirector::sharedDirector()->getVisibleSize().height/2 + CCDirector::sharedDirector()->getVisibleOrigin().y));
addChild(staff_bg, 4);
CCSprite* staff = CCSprite::create(STAFF_IMG_PATH);
staff->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, -CCDirector::sharedDirector()->getVisibleSize().height/2));
addChild(staff, 5);
CCActionInterval * moveTo = CCMoveTo::create(10,ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height*3/2));
CCFiniteTimeAction* sequneceAction = CCSequence::create(moveTo, CCCallFunc::create(this, callfunc_selector(StoryWorld::gameOverAndBackToWelcome)), NULL);
staff->runAction(sequneceAction);
}
break;
case '3':{
CCSprite *black = CCSprite::create(BLACK_IMG_PATH);
black->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/2));
black->setOpacity(0);
addChild(black, 4);
black->runAction(CCSequence::create(CCFadeIn::create(0.5), CCFadeOut::create(0.5), NULL));
}
break;
default:
break;
}
}
示例9: initButton
void MarketScene::initButton()
{
CCMenuItemImage *pMenuItem = CCMenuItemImage::create(s_pMenuItemBack.charMapFile, s_pMenuItemBack.charMapFilePress, this, menu_selector(MarketScene::buttonCallback));
if (NULL != pMenuItem)
{
pMenuItem->setAnchorPoint(ccp(1,1));
pMenuItem->setPosition(SCREEN);
pMenuItem->setTag(BTN_CLOSE);
}
CCMenu *pMenu = CCMenu::create(pMenuItem, NULL);
if (NULL != pMenu)
{
pMenu->setPosition(CCPointZero);
addChild(pMenu);
pMenu->setTag(TAG_MENU);
}
pMenuItem = CCMenuItemImage::create(s_pMenuItemBuy.charMapFile, s_pMenuItemBuy.charMapFilePress, s_pBuyDisable, this, menu_selector(MarketScene::buttonCallback));
pMenuItem->setAnchorPoint(ccp(0.5f, 0.5f));
pMenuItem->setPosition(ccp(CENTER.x, 120));
pMenuItem->setTag(BTN_BUY);
pMenu->addChild(pMenuItem);
char szFileName[32] = { 0 };
char szFileName2[32] = { 0 };
char szFileName3[32] = { 0 };
for (int i = 0; i < CARD_COUNT; i++)
{
sprintf(szFileName, s_pathCard.charMapFile, i);
sprintf(szFileName2, s_pathCard.charMapFilePress, i);
sprintf(szFileName3, s_pathCardDisable, i);
CCMenuItemImage *pItem0 = CCMenuItemImage::create(szFileName, szFileName2, szFileName3);
CCMenuItemImage *pItem1 = CCMenuItemImage::create(szFileName2, szFileName);
CCMenuItemToggle *pToggle = CCMenuItemToggle::createWithTarget(this, menu_selector(MarketScene::buttonCallback), pItem0, pItem1, NULL);
pToggle->setPosition(ccp(120 * i + s_pathCard.m_Position.x, s_pathCard.m_Position.y));
pToggle->setTag(BTN_CARD + i);
if (g_Control.cards[i] > 0)
{
CCSprite *sprite = CCSprite::create(s_pathCardbuy.m_strPath);
sprite->setPosition(s_pathCardbuy.m_Position);
pToggle->addChild(sprite, TAG_CARD_BUY, TAG_CARD_BUY);
}
pMenu->addChild(pToggle);
}
checkCard(BTN_CARD);
}
示例10: makeRetryButton
void MainGameScene::makeRetryButton()
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCMenuItemImage* retryItem = CCMenuItemImage::create("menu_waku.png","menu_waku.png" ,this, menu_selector(MainGameScene::showResumeDialog));
retryItem->setScale(0.5);
CCSize pRetryItemSize = retryItem->getContentSize();
retryItem->setPosition(ccp( pRetryItemSize.width * 0.4, winSize.height - pRetryItemSize.height * 0.4));
CCMenu* retryButton = CCMenu::create(retryItem,NULL);
retryButton->setPosition(CCPointZero);
retryButton->setTag(tagRetryButton);
retryButton->setEnabled(false);
this->addChild(retryButton);
}
示例11: 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;
}
示例12: makeClearDaialog
void MainGameScene::makeClearDaialog()
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCMenuItemImage* titleItem = CCMenuItemImage::create("logo_menu.png","logo_menu.png" ,this, menu_selector(MainGameScene::tapTitleButton));
titleItem->setPosition(ccp(winSize.width * 0.3, winSize.height * 0.3));
CCMenuItemImage* retryItem = CCMenuItemImage::create("logo_restart.png","logo_restart.png" ,this, menu_selector(MainGameScene::tapRetryButton));
retryItem->setPosition(ccp(winSize.width * 0.8, winSize.height * 0.3));
CCMenu* clearDialog = CCMenu::create(titleItem,retryItem,NULL);
clearDialog->setPosition(CCPointZero);
clearDialog->setTag(tagClearDialog);
clearDialog->setOpacity(0);
clearDialog->setEnabled(false);
this->addChild(clearDialog);
}
示例13: initCommons
//private
void RPGDialogLayer::initCommons(string titleStr)
{
CCTMXTiledMap *mainBg = CCTMXTiledMap::create("alert_style1.tmx");
float x = (CCDirector::sharedDirector()->getWinSize().width - mainBg->getContentSize().width) / 2.0f;
float y = (CCDirector::sharedDirector()->getWinSize().height - mainBg->getContentSize().height) / 2.0f;
mainBg->setPosition(ccp(x, y));
mainBg->setTag(kRPGDialogLayerBg);
this->addChild(mainBg);
CCLabelTTF *titleLab = CCLabelTTF::create(titleStr.c_str(), "Arial", 25, CCSizeMake(mainBg->getContentSize().width, 25), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
titleLab->setPosition(ccp(190, 135));
titleLab->setColor(ccc3(255, 255, 255));
mainBg->addChild(titleLab);
CCMenu *menu = CCMenu::create();
menu->setAnchorPoint(CCPointZero);
menu->setPosition(CCPointZero);
menu->setTag(kRPGDialogLayerBgMenu);
mainBg->addChild(menu);
}
示例14: showStartInfo
void MainGameScene::showStartInfo()
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCMenuItemImage* pStartItem;
pStartItem = CCMenuItemImage::create("logo_Info2.png", "logo_Info2.png",this,menu_selector(MainGameScene::startGame));
pStartItem->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.5));
pStartItem->setScale(0.7);
CCSize pStartItemSize = pStartItem->getContentSize();
CCLabelTTF* startLabel1;
startLabel1 = CCLabelTTF::create("Let's Arrows", "Copperplate", 60.0);
startLabel1->setColor(ccc3(0, 0, 0));
startLabel1->setPosition(ccp(pStartItemSize.width * 0.5 ,pStartItemSize.height * 0.7));
pStartItem->addChild(startLabel1);
CCString* levelStr = CCString::createWithFormat("Lv:%d",m_level);
CCLabelTTF* levelLabel;
levelLabel = CCLabelTTF::create(levelStr->getCString(), "Copperplate", 60.0);
levelLabel->setColor(ccc3(0, 0, 0));
levelLabel->setPosition(ccp(pStartItemSize.width * 0.5 ,pStartItemSize.height * 0.5));
pStartItem->addChild(levelLabel);
CCString* minCountString = CCString::createWithFormat("MIN %d TOUCH",minimamCount);
CCLabelTTF* startLabel2;
startLabel2 = CCLabelTTF::create(minCountString->getCString(), "Copperplate", 50.0);
startLabel2->setColor(ccc3(0, 0, 0));
startLabel2->setPosition(ccp(pStartItemSize.width * 0.5 ,pStartItemSize.height * 0.2));
pStartItem->addChild(startLabel2);
CCMenu* pMenu = CCMenu::create(pStartItem,NULL);
pMenu->setPosition(CCPointZero);
pMenu->setTag(tagStartInfo);
this->addChild(pMenu);
}
示例15: freeToGetFubi
void MenuScene::freeToGetFubi()
{
//添加免费领取富币的背景,非0为第一次登录,测试显示,0为第一次登录
CCLog("-------MenuScene:您第一次登陆,获得富币--------");
this->setMenuButtonTouchFasle();
//背景框
CCSprite *acceptFreeFubiImage = CCSprite::create("ZF_Shoot_MenuScene_background_freeFubi.png");
acceptFreeFubiImage->setPosition(CCPointMake(size.width/2, size.height/2));
acceptFreeFubiImage->setTag(111);
this->addChild(acceptFreeFubiImage, 1,111);
//确认或者拒绝
CCMenuItemImage *yes = CCMenuItemImage::create("ZF_Shoot_MenuScene_background_freeFubi_confirm1.png", "ZF_Shoot_MenuScene_background_freeFubi_confirm1.png", this, menu_selector(MenuScene::menuCallAcceptFubiYes));
yes->setContentSize(CCSizeMake(200, 100));
yes->setPosition(CCPointMake(acceptFreeFubiImage->getContentSize().width/2+50, acceptFreeFubiImage->getContentSize().height*0.4));
CCMenu *menu = CCMenu::create(yes,NULL);
menu->setPosition(CCPointZero);
menu->setTag(112);
acceptFreeFubiImage->addChild(menu, 1,112);
}