本文整理汇总了C++中CCMenuItemImage::setTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemImage::setTag方法的具体用法?C++ CCMenuItemImage::setTag怎么用?C++ CCMenuItemImage::setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemImage
的用法示例。
在下文中一共展示了CCMenuItemImage::setTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateMenu
bool RS_Main::CreateMenu()
{
bool bRet = false;
do
{
s = CCDirector::sharedDirector()->getWinSize();
// 뒤로가기 버튼
CCMenuItemImage* pBackItem = CCMenuItemImage::create("common/back_btn_2.png", "common/back_pressed_btn_2.png", this, menu_selector(RS_Main::menuClickCallback));
pBackItem->setTag(1);
// 다시하기 버튼
CCMenuItemImage* pRetryItem = CCMenuItemImage::create("common/again_btn_2.png", "common/again_pressed_btn_2.png", this, menu_selector(RS_Main::menuClickCallback));
pRetryItem->setTag(2);
CCMenu* pMenu = CCMenu::create();
pMenu->addChild(pBackItem);
pMenu->addChild(pRetryItem);
pMenu->setPosition(ccp(19 + pBackItem->getContentSize().width , s.height - 40));
pMenu->alignItemsHorizontally();
this->addChild(pMenu, 100);
bRet = true;
} while(0);
return bRet;
}
示例2: init
bool MainScene::init()
{
if (!CCLayer::init())
{
return false;
}
CCSize size = CCDirector::sharedDirector()->getWinSize();
//GameFeat起動
CCMenuItemImage* gamefeatButton = CCMenuItemImage::create("GameFeatButton1.png", "GameFeatButton2.png", this, menu_selector(MainScene::pushMenu));
gamefeatButton->setPosition(ccp(size.width/2, size.height*2/3));
gamefeatButton->setTag(tag_gamefeat);
//画面移動
CCMenuItemImage* nextButton = CCMenuItemImage::create("bGameFeat1.png", "bGameFeat2.png", this, menu_selector(MainScene::pushMenu));
nextButton->setPosition(ccp(size.width/2, size.height/2));
nextButton->setTag(tag_next);
CCMenu* menu = CCMenu::create(gamefeatButton,nextButton,NULL);
menu->setPosition(CCPointZero);
this->addChild(menu);
//アイコン型GameFeat表示
NativeBridge::showIconGameFeat();
return true;
}
示例3: 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);
}
示例4: init
bool LoseGame::init()
{
bool bRet = false;
do
{
CC_BREAK_IF(! CCLayer::init());
CCSprite* pSprite5 = CCSprite::create("losebg.png");
CC_BREAK_IF(!pSprite5);
CCSize size = CCDirector::sharedDirector()->getWinSize();
pSprite5->setPosition(ccp(size.width/2, size.height/2));
this->addChild(pSprite5);
char a[20];
labelText1 = CCLabelTTF ::create();
labelText1->setFontName("Calibri");
labelText1->setFontSize(20);
labelText1->setString(itoa(GameScore,a,10));
labelText1->setPosition(ccp(481,100));
this->addChild(labelText1);
CCMenuItemImage *pTryItem = CCMenuItemImage::create("try.png","try.png",this,menu_selector(LoseGame::menuCloseCallback));
pTryItem->setTag(1);
pTryItem->setPosition(ccp(398,28));
auto menu = CCMenu::create(pTryItem, NULL);
menu->setPosition(CCPointZero);
this->addChild(menu);
bRet = true;
} while (0);
return bRet;
}
示例5: init
bool SelectLevel::init()
{
//背景网格
CCSprite* bg = CCSprite::create("LevelSelect.png");
//位置以图片中心为准
bg->setPosition(ccp(400,240));
this->addChild(bg);
CCMenuItemImage *Level1 = CCMenuItemImage::create("Level1.png","Level1.png",this,menu_selector(SelectLevel::menuCloseCallback));
Level1->setTag(1);
Level1->setPosition(ccp(90,413));
CCMenuItemImage *Level2 = CCMenuItemImage::create("Level2.png","Level2.png",this,menu_selector(SelectLevel::menuCloseCallback));
Level2->setTag(2);
Level2->setPosition(ccp(194,415));
CCMenuItemImage *Level3 = CCMenuItemImage::create("Level3.png","Level3.png",this,menu_selector(SelectLevel::menuCloseCallback));
Level3->setTag(3);
Level3->setPosition(ccp(298,416));
CCMenuItemImage *LevelBack = CCMenuItemImage::create("LevelBack.png","LevelBack.png",this,menu_selector(SelectLevel::menuCloseCallback));
LevelBack->setTag(123);
LevelBack->setPosition(ccp(92,40));
auto menu = CCMenu::create(Level1,Level2,Level3,LevelBack, NULL);
menu->setPosition(CCPointZero);
this->addChild(menu);
return true;
}
示例6: init
bool GuideScene::init()
{
if (!CCLayer::init()) {
return false;
}
CCLOG("/**~~~~~~~~~~~~~~~~GuideScene:init()~~~~~~~~~~~~~~~~~");
//取出主屏幕的尺寸,以及初始化数据
size = CCDirector::sharedDirector()->getVisibleSize();
// CCSprite* whiteBg = CCSprite::create("ZF_Shoot_whiteBg.png",CCRectMake(0,0,size.width,size.height));
// whiteBg->setPosition(ccp(size.width*0.5,size.height*0.5));
// whiteBg->setContentSize(size);
// this->addChild(whiteBg,0);
CCSprite* helpBg = CCSprite::create("ZF_Shoot_help.png");
helpBg->setAnchorPoint(ccp(0.5,0.5));
helpBg->setPosition(ccp(size.width*0.5,size.height*0.5));
this->addChild(helpBg,0);
//1.create a container
CCLayer* container = CCLayer::create();
CCSprite* guide = CCSprite::create("ZF_Shoot_guide.png");
guide->setAnchorPoint(ccp(0.5,1));
guide->setPosition(ccp(size.width*0.5,size.height));
container->addChild(guide,1);
container->setContentSize(size);
//2.create a scrollView
CCScrollView* scrollView = CCScrollView::create(CCSizeMake(size.width*0.5, size.height*3));
addChild(scrollView);
scrollView->setAnchorPoint(ccp(0.5,0.5));
scrollView->setPosition(ccp(10,size.height*0.23));
//3.setOption
scrollView->setBounceable(true);
scrollView->setViewSize(CCSizeMake(size.width, size.height*0.55));
scrollView->setContainer(container);
scrollView->setDirection(kCCScrollViewDirectionVertical);
scrollView->setTouchEnabled(true);
scrollView->setDelegate(this);
scrollView->unscheduleAllSelectors();
//4.closeMenu
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"ZF_Shoot_button_coinList_back2.png",
"ZF_Shoot_button_coinList_back1.png",
this,
menu_selector(GuideScene::menuCloseCallBack) );
pCloseItem->setPosition( CCPointMake(size.width*0.5-235 , size.height*0.92) );
pCloseItem->setTag(5);
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
addChild(pMenu);
return true;
}
示例7: updateUserPhoto
//更新玩家头像
void MenuScene::updateUserPhoto()
{
CCMenuItemImage *headProtrait = CCMenuItemImage::create("ZF_Shoot_MenuScene_touxiang.png", "ZF_Shoot_MenuScene_touxiang.png",this,menu_selector(MenuScene::menuCloseCallBack));
headProtrait->setPosition(ccp(70, size.height-52));
headProtrait->setTag(6);
headMenu = CCMenu::create(headProtrait,NULL);
headMenu->setPosition(CCPointZero);
this->addChild(headMenu,1,12);
}
示例8: initSceneChoose
//添加3个选关按钮
void MenuScene::initSceneChoose()
{
float pngWidth = 362.0;
float xSpace = (size.width - pngWidth*3)/4;
//添加练习场菜单项
CCActionInterval* scaleToex1 = CCScaleTo::create(kScaleDuration1, kScaleRitio, kScaleRitio-0.03);
CCActionInterval* scaleToex2 = CCScaleTo::create(kScaleDuration1, kScaleRitio-0.02, kScaleRitio);
CCSequence* sequence1 = CCSequence::create(scaleToex1,scaleToex2,NULL);
CCActionInterval* rotate1 = CCRepeatForever::create(sequence1);
CCMenuItemImage *exersize = CCMenuItemImage::create("ZF_Shoot_Button_lxc.png", "ZF_Shoot_Button_lxc.png", this, menu_selector(MenuScene::menuChoseScene));
exersize->setPosition(ccp(xSpace+pngWidth/2, size.height/2));
exersize->setScale(kScaleRitio);
exersize->setTag(kExserciseTag);
exersize->runAction(rotate1);
//添加平民场菜单项
CCActionInterval* scaleTope1 = CCScaleTo::create(kScaleDuration1, kScaleRitio, kScaleRitio-0.03);
CCActionInterval* scaleTope2 = CCScaleTo::create(kScaleDuration1, kScaleRitio-0.02, kScaleRitio);
CCSequence* sequence2 = CCSequence::create(scaleTope1,scaleTope2,NULL);
CCActionInterval* rotate2 = CCRepeatForever::create(sequence2);
CCMenuItemImage *people = CCMenuItemImage::create("ZF_Shoot_Button_pmc.png", "ZF_Shoot_Button_pmc.png", this, menu_selector(MenuScene::menuChoseScene));
people->setPosition(ccp(xSpace*2+pngWidth*1.5, size.height/2));
people->setScale(kScaleRitio);
people->setTag(kPeopleTag);
people->runAction(rotate2);
//添加富豪场菜单项
CCActionInterval* scaleTori1 = CCScaleTo::create(kScaleDuration1, kScaleRitio, kScaleRitio-0.03);
CCActionInterval* scaleTori2 = CCScaleTo::create(kScaleDuration1, kScaleRitio-0.02, kScaleRitio);
CCSequence* sequence3 = CCSequence::create(scaleTori1,scaleTori2,NULL);
CCActionInterval* rotate3 = CCRepeatForever::create(sequence3);
CCMenuItemImage *rich = CCMenuItemImage::create("ZF_Shoot_Button_hhc.png", "ZF_Shoot_Button_hhc.png", this, menu_selector(MenuScene::menuChoseScene));
rich->setPosition(ccp(xSpace*3+pngWidth*2.5, size.height/2));
rich->setScale(kScaleRitio);
rich->setTag(kRichTag);
rich->runAction(rotate3);
//集成到菜单容器
richMenu = CCMenu::create(rich,people,exersize,NULL);
richMenu->setPosition(CCPointZero);
this->addChild(richMenu,1);
}
示例9: createMenu
bool SP_Main::createMenu()
{
bool bRet = false;
do
{
s = CCDirector::sharedDirector()->getWinSize();
// 뒤로가기 버튼
CCMenuItemImage* pBackItem = CCMenuItemImage::create("common/back_btn_2.png", "common/back_pressed_btn_2.png", this, menu_selector(SP_Main::menuClickCallback));
pBackItem->setTag(1);
// 다시하기 버튼
CCMenuItemImage* pRetryItem = CCMenuItemImage::create("common/again_btn_2.png", "common/again_pressed_btn_2.png", this, menu_selector(SP_Main::menuClickCallback));
pRetryItem->setTag(2);
CCMenu* pMenu = CCMenu::create();
pMenu->addChild(pBackItem);
pMenu->addChild(pRetryItem);
pMenu->setPosition(ccp(19 + pBackItem->getContentSize().width , s.height - 40));
pMenu->alignItemsHorizontally();
this->addChild(pMenu, 100);
// 숫자, 알파벳 보기
m_pShowNItem = CCMenuItemImage::create("common/game/sliding/number_btn.png", "common/game/sliding/number_btn_pressed.png", this, menu_selector(SP_Main::menuShow));
m_pShowAItem = CCMenuItemImage::create("common/game/sliding/alphabet_btn.png", "common/game/sliding/alphabet_btn_pressed.png", this, menu_selector(SP_Main::menuShow));
m_pShowNItem->setTag(0);
m_pShowAItem->setTag(1);
CCMenu* pMenuShow = CCMenu::create();
pMenuShow->addChild(m_pShowNItem);
pMenuShow->addChild(m_pShowAItem);
pMenuShow->alignItemsHorizontallyWithPadding(5);
pMenuShow->setPosition(SHOWMENU_XY);
this->addChild(pMenuShow, 1);
bRet = true;
} while(0);
return bRet;
}
示例10: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
if ( !CCLayer::init() )
{
return false;
}
CCMenuItemImage *pCloseItem = CCMenuItemImage::create("CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 60, 60) );
pCloseItem->setTag(1);
pCloseItem->setScale(2.5f);
CCMenuItemImage *pCloseItem1 = CCMenuItemImage::create("CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem1->setPosition( ccp(60, 60) );
pCloseItem1->setTag(2);
pCloseItem1->setScale(2.5f);
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem, pCloseItem1, NULL);
pMenu->setPosition( CCPointZero );
this->addChild(pMenu, 1);
pSprite = CCSprite::create("CloseNormal.png");
pSprite->setPosition( ccp(600, 700) );
pSprite->setTag(-1);
this->addChild(pSprite, 0);
lines = (Line *)malloc(sizeof(Line) * COUNT);
lines[0].p1 = ccp(100, 100);
lines[0].p2 = ccp(400, 100);
lines[1].p1 = ccp(500, 600);
lines[1].p2 = ccp(700, 600);
lines[2].p1 = ccp(400, 400);
lines[2].p2 = ccp(600, 500);
lines[3].p1 = ccp(500, 200);
lines[3].p2 = ccp(1000, 200);
speedX = 0;
speedY = 0;
this->scheduleUpdate();
return true;
}
示例11: 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;
}
示例12: setStyle
void FSAlertLayer::setStyle(const char* message, cocos2d::CCObject *target, cocos2d::SEL_CallFuncN okSelector, cocos2d::SEL_CallFuncN ngSelector)
{
this->target = target;
this->okSelector = okSelector;
this->ngSelector = ngSelector;
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
// message
CCLabelTTF *pMsg = CCLabelTTF::create(message, "", 42);
pMsg->setPosition(ccp(visibleSize.width / 2 +100, visibleSize.height/2+36));
this->addChild(pMsg);
// OK Button
CCMenuItemImage *pNGItem = CCMenuItemImage::create("images/retray_button_cancel.png", "images/retray_button_canel.png", this, menu_selector(FSAlertLayer::menuAlertClose));
int btnHeight = visibleSize.height / 2 - this->getChildByTag(FSAlertLayerTagFrame)->getContentSize().height / 2 + pNGItem->getContentSize().height / 2 + 10;
pNGItem->setTag(FSAlertLayerTagNG);
pNGItem->setPosition(ccp(visibleSize.width / 2, btnHeight));
CCMenu* pMenu = CCMenu::create(pNGItem, NULL);
pMenu->setPosition(CCPointZero);
pMenu->setTag(FSAlertLayerTagMenu);
this->addChild(pMenu);
// set as 2 buttons
if (okSelector) {
pNGItem->setPosition(ccp(visibleSize.width / 2 - pNGItem->getContentSize().width / 2-10, btnHeight +10));
// NG btn
CCMenuItemImage* pOKItem = CCMenuItemImage::create("images/retray_button_ok.png",
"images/retray_button_ok.png", this, menu_selector(FSAlertLayer::menuAlertOK));
pOKItem->setTag(FSAlertLayerTagOK);
pOKItem->setPosition(ccp(visibleSize.width / 2 + pOKItem->getContentSize().width / 2+10, btnHeight +10));
pMenu->addChild(pOKItem);
}
}
示例13: setStyle
void FSAlertLayer::setStyle(const char* message, CCObject *target, SEL_CallFuncN okSelector, SEL_CallFuncN ngSelector)
{
this->target = target;
this->okSelector = okSelector;
this->ngSelector = ngSelector;
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
// Label
CCLabelTTF *pMsg = CCLabelTTF::create(message, "", 40);
pMsg->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2 + 50));
pMsg->setColor(ccc3(0,0,0));
this->addChild(pMsg);
// OK Button
CCMenuItemImage *pOKItem = CCMenuItemImage::create("send_mail_btm.png", "send_mail_btm.png", this, menu_selector(FSAlertLayer::menuAlertOK));
int btnHeight = visibleSize.height / 2 - this->getChildByTag(FSAlertLayerTagFrame)->getContentSize().height / 2 + pOKItem->getContentSize().height / 2 + 10;
pOKItem->setTag(FSAlertLayerTagOK);
pOKItem->setPosition(ccp(visibleSize.width / 2 , btnHeight +10));
CCMenu* pMenu = CCMenu::create(pOKItem, NULL);
pMenu->setPosition(CCPointZero);
pMenu->setTag(FSAlertLayerTagMenu);
this->addChild(pMenu);
// Set Cancel button
if (ngSelector) {
CCMenuItemImage* pNGItem = CCMenuItemImage::create("close_btn.png", "close_btn.png", this, menu_selector(FSAlertLayer::menuAlertClose));
pNGItem->setTag(FSAlertLayerTagNG);
int cancelWidth = visibleSize.width/2 + this->getChildByTag(FSAlertLayerTagFrame)->getContentSize().width/2;
int cancelHeight = visibleSize.height/2 + this->getChildByTag(FSAlertLayerTagFrame)->getContentSize().height/2;
//pNGItem->setPosition(ccp(visibleSize.width / 2 + pOKItem->getContentSize().width, btnHeight +10));
CCLog("cancelPosition ===> %i",cancelWidth);
CCLog("cancelPosition ===> %i",cancelHeight);
pNGItem->setPosition(ccp(cancelWidth,cancelHeight));
pMenu->addChild(pNGItem);
}
}
示例14: initButton
//添加顶部按钮
void MenuScene::initButton()
{
//免费富币
CCMenuItemImage *freeImage = CCMenuItemImage::create("ZF_Shoot_Button_coin.png", "ZF_Shoot_Button_coin1.png",this,menu_selector(MenuScene::menuCloseCallBack));
freeImage->setPosition(ccp(size.width/2, size.height-55));
freeImage->setTag(1);
CCActionInterval* scaleTofree1 = CCScaleTo::create(kScaleDuration, 1, 0.95);
CCActionInterval* scaleTofree2 = CCScaleTo::create(kScaleDuration, 0.96, 1);
CCSequence* sequence1 = CCSequence::create(scaleTofree1,scaleTofree2,NULL);
CCActionInterval* rotate1 = CCRepeatForever::create(sequence1);
freeImage->runAction(rotate1);
//商城
CCMenuItemImage *buyImage = CCMenuItemImage::create("ZF_Shoot_Button_shop.png", "ZF_Shoot_Button_shop1.png",this,menu_selector(MenuScene::menuCloseCallBack));
buyImage->setPosition(ccp(size.width/2+205, size.height-55));
buyImage->setTag(2);
CCActionInterval* scaleTobuy1 = CCScaleTo::create(kScaleDuration, 1, 0.95);
CCActionInterval* scaleTobuy2 = CCScaleTo::create(kScaleDuration, 0.96, 1);
CCSequence* sequence2 = CCSequence::create(scaleTobuy1,scaleTobuy2,NULL);
CCActionInterval* rotate2 = CCRepeatForever::create(sequence2);
buyImage->runAction(rotate2);
//玩家指南
CCMenuItemImage *guideIamge = CCMenuItemImage::create("ZF_Shoot_Button_help.png", "ZF_Shoot_Button_help1.png",this,menu_selector(MenuScene::menuCloseCallBack));
guideIamge->setPosition(ccp(size.width/2+405, size.height-55));
guideIamge->setTag(4);
CCActionInterval* scaleTopl1 = CCScaleTo::create(kScaleDuration, 1, 0.95);
CCActionInterval* scaleTopl2 = CCScaleTo::create(kScaleDuration, 0.96, 1);
CCSequence* sequence4 = CCSequence::create(scaleTopl1,scaleTopl2,NULL);
CCActionInterval* rotate4 = CCRepeatForever::create(sequence4);
guideIamge->runAction(rotate4);
sceneMenu = CCMenu::create(freeImage,buyImage,guideIamge,NULL);
sceneMenu->setPosition(CCPointZero);
this->addChild(sceneMenu, 1);
}
示例15: 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;
}