本文整理汇总了C++中CCMenuItemFont::setTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemFont::setTag方法的具体用法?C++ CCMenuItemFont::setTag怎么用?C++ CCMenuItemFont::setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemFont
的用法示例。
在下文中一共展示了CCMenuItemFont::setTag方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool GameOverLayer::init()
{
do
{
CC_BREAK_IF(!CCLayer::init());
CCLayerColor* backgroundLayer = CCLayerColor::create(
ccc4(255, 255, 255, 128));
addChild(backgroundLayer);
CCSize screenSize = CocosUtils::getScreenSize();
CCMenuItemFont* nextLevel = CCMenuItemFont::create("Next", this,
menu_selector(GameOverLayer::menuCallback));
nextLevel->setTag(MENU_ITEM_NEXT_LEVEL);
nextLevel->setFontName("Consola");
nextLevel->setFontSize(36);
CCMenuItemFont* replay = CCMenuItemFont::create("Replay", this,
menu_selector(GameOverLayer::menuCallback));
replay->setTag(MENU_ITEM_REPLAY);
replay->setFontName("Consola");
replay->setFontSize(36);
CCMenu* menu = CCMenu::create(nextLevel, replay, NULL);
menu->alignItemsVertically();
menu->setPosition(screenSize.width/2, screenSize.height/2);
addChild(menu);
return true;
} while (false);
return false;
}
示例2: init
bool Campaign::init()
{
if ( !SelectSave::init() )
{
return false;
}
stageNum = stageTag0;
SelectStage *stages = SelectStage::create();
addChild(stages);
stages->setTag(campTag_SelectStage);
CCMenuItemFont *start = CCMenuItemFont::create("START",this,menu_selector(Campaign::menuCloseCallback));
CCMenuItemFont *soldiers = CCMenuItemFont::create("SOLDIERS",this,menu_selector(Campaign::menuCloseCallback));
CCMenuItemFont *mainMenu = CCMenuItemFont::create("mainMenu",this,menu_selector(Campaign::menuCloseCallback));
start->setTag(campTag_start);
soldiers->setTag(campTag_soldiers);
mainMenu->setTag(campTag_mainMenu);
CCMenu *menu = CCMenu::create(start,soldiers,mainMenu,NULL);
addChild(menu,10);
menu->setPosition(CCPointZero);
menu->alignItemsVertically();
CCSize size = menu->getContentSize();
CCLOG("%f %f",size.width,size.height);
menu->setPosition(ccp(size.width/6, size.height/6));
// menu->setScale(0.5f);
return true;
}
示例3: CreateMenu
void MainScene::CreateMenu()
{
if(_menu == NULL)
{
CCSize scrSize = CCDirector::sharedDirector()->getWinSize();
_menu = CCMenu::create();
_menu->setPosition(ccp(0,0));
addChild(_menu);
CCMenuItemFont* pItem;
CCPoint position;
// Create the next/back menu items.
for(int page = 0; page < MENU_PAGES; page++)
{
// Create the Back/Forward buttons for the page.
// Back arrow if there is a previous page.
if(page > 0)
{
pItem = CCMenuItemFont::create("Back", this, menu_selector(MainScene::MenuCallback));
pItem->setTag(ARROW_LEFT);
position = ccp(page*scrSize.width + scrSize.width*0.1,scrSize.height*0.1);
pItem->setPosition(position);
pItem->setFontSize(35);
pItem->setFontName("Arial");
_menu->addChild(pItem);
}
if(page < (MENU_PAGES-1))
{
pItem = CCMenuItemFont::create("Next", this, menu_selector(MainScene::MenuCallback));
pItem->setTag(ARROW_RIGHT);
position = ccp(page*scrSize.width + scrSize.width*0.9,scrSize.height*0.1);
pItem->setPosition(position);
pItem->setFontSize(35);
pItem->setFontName("Arial");
_menu->addChild(pItem);
}
}
// Create the actual items
for(int idx = 0; idx < MENU_ITEMS_TOTAL; idx++)
{
char buffer[256];
sprintf(buffer,"Item #%d",idx);
pItem = CCMenuItemFont::create(buffer, this, menu_selector(MainScene::MenuCallback));
pItem->setFontSize(35);
pItem->setFontName("Arial");
pItem->setTag(idx);
position = CalculatePosition(idx);
pItem->setPosition(position);
_menu->addChild(pItem);
}
}
}
示例4: init
bool HelloWorld::init()
{
if ( !CCLayerColor::initWithColor(ccc4(255, 255, 255, 255)) ) {
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
CCSprite* bg = CCSprite::create("bg.png");
bg->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2));
this->addChild(bg, 0, 0);
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));
CCMenuItemFont* sBtn = CCMenuItemFont::create("", this, menu_selector(HelloWorld::btnCB));
sBtn->setTag(SBTNTAG);
sBtn->setAnchorPoint(CCPointZero);
sBtn->setPosition(50, 200);
sBtn->setColor(ccRED);
CCMenuItemFont* rbtn = CCMenuItemFont::create("", this, menu_selector(HelloWorld::btnCB));
rbtn->setTag(RTBTNTAG);
rbtn->setAnchorPoint(CCPointZero);
rbtn->setPosition(50, 300);
rbtn->setColor(ccGREEN);
// create menu, it's an autorelease object
pMenu = CCMenu::create(pCloseItem, sBtn, rbtn, NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu, 1);
// show filter node
this->setAnchorPoint(CCPointZero);
fnode = GaussianBlur::screenBlurNodeInstance();
fnode->reset(this);
this->addChild(fnode);
updateBtn(SBTNTAG);
updateBtn(RTBTNTAG);
return true;
}
示例5: init
// on "init" you need to initialize your instance
bool TestLayer::init()
{
bool bRet = false;
do
{
//////////////////////////////////////////////////////////////////////////
// super init first
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// add your codes below...
//////////////////////////////////////////////////////////////////////////
this->setTouchEnabled(true);
CCArray* itemsArray = CCArray::create();
CCMenuItemFont* item = CCMenuItemFont::create("Back", this,
menu_selector(TestLayer::menuCallback));
item->setTag(1);
itemsArray->addObject(item);
CCMenu* menu = CCMenu::createWithArray(itemsArray);
menu->alignItemsVertically();
this->addChild(menu);
// menu->setPosition(item->getContentSize().width, CCDirector::sharedDirector()->getWinSize().height - item->getContentSize().height/2);
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
menu->setPosition(20, winSize.height - 50);
std::string message = this->initTest();
CCSize s = CCDirector::sharedDirector()->getWinSize();
float fontSize = 14;
if(s.height > 1024)
{
fontSize = 34;
}
CCLabelTTF* label = CCLabelTTF::create(message.c_str(), "Arial", fontSize);
CCSize labelSize = label->getContentSize();
label->setPosition(ccp(s.width/2, labelSize.height));
this->addChild(label, -2);
bRet = true;
} while (0);
return bRet;
}
示例6: actionOption
/* Action option callback */
void LuaDecisionTree::actionOption(CCString* str) {
CCMenuItemFont::setFontName("Arial");
CCMenuItemFont::setFontSize(16);
optionsOnScreen += 1;
//Add action option to screen
CCString *optionStr = CCString::createWithFormat("[%s)", str);
CCMenuItemFont *optionItem = CCMenuItemFont::create(str->getCString() , this , menu_selector(LuaDecisionTree::selectOption));
optionItem->setTag(optionsOnScreen);
optionItem->setPosition(ccp(10,135 - optionsOnScreen*20));
optionItem->setAnchorPoint(ccp(0,1));
CCMenu *menu = CCMenu::createWithItem(optionItem);
menu->setPosition(ccp(0,0));
optionsNode->addChild(menu);
}
示例7: onLoadScene
void MenuScene::onLoadScene()
{
m_vMenuItems.push_back("Basic Test");
CCSize tContainerSize = CCSize(700, 100 * m_vMenuItems.size());
CCLayer* pScrollViewContainer = CCLayer::create();
pScrollViewContainer->setPosition(CCPointZero);
pScrollViewContainer->setContentSize(tContainerSize);
m_pScrollView = CCScrollView::create(CCSize(700, 640));
m_pScrollView->setDirection(kCCScrollViewDirectionVertical);
m_pScrollView->ignoreAnchorPointForPosition(false);
m_pScrollView->setPosition(CCPoint(480, 320));
m_pScrollView->setContainer(pScrollViewContainer);
addChild(m_pScrollView);
CCArray* pArray = CCArray::create();
float height = tContainerSize.height;
unsigned int i = 0;
unsigned int end = m_vMenuItems.size();
for(; i < end; ++i )
{
CCMenuItemFont* pFont = CCMenuItemFont::create(m_vMenuItems[i].c_str());
pFont->setTarget(this, menu_selector(MenuScene::onClick));
pFont->setFontSizeObj(45.0f);
pFont->setPosition(ccp(700 / 2, height - 100 / 2));
pFont->setTag(i + 1);
pArray->addObject(pFont);
height -= 100;
}
CCMenu* pMenu = CCMenu::createWithArray(pArray);
pMenu->setPosition(ccp(0,0));
pScrollViewContainer->addChild(pMenu);
m_pScrollView->setContentOffset(ccp(0, -(tContainerSize.height - 640)));
}
示例8: createPauseMenu
cocos2d::CCMenu* BYGameScene::createPauseMenu() { /// creates autorelease object
CCMenuItemFont* continueItem = CCMenuItemFont::create("Continue",
this,
menu_selector(BYGameScene::continueGame));
continueItem->setTag(GUI_PauseMenu_Continue);
CCMenuItemFont* reItem = CCMenuItemFont::create("Restart",
this,
menu_selector(BYGameScene::resetGame));
CCMenuItemFont* quitItem = CCMenuItemFont::create("Quit",
this,
menu_selector(BYGameScene::quitGame));
CCMenu* menu = CCMenu::create(continueItem, reItem, quitItem, NULL);
menu->alignItemsVerticallyWithPadding(5);
CCSize s = CCDirector::sharedDirector()->getWinSize();
menu->setPosition(CCPointMake(s.width / 2, s.height / 2));
menu->setTag(GUI_PauseMenu);
return menu;
}
示例9:
CCMenu *BoxMenu::getBoxMenu()
{
CCSize size = CCDirector::sharedDirector()->getWinSize();
Score *scoreInstance = Score::GetInstance();
scoreInstance->makeNameScore();
TEAM_S *pstTeamScore = scoreInstance->teamScore;
CCMenuItemFont *ljxTeam = CCMenuItemFont::create(pstTeamScore[0].nameScore, this, menu_selector(BoxMenu::newGame));
CCMenuItemFont *xxxTeam = CCMenuItemFont::create(pstTeamScore[1].nameScore, this, menu_selector(BoxMenu::newGame));
CCMenuItemFont *birdTeam = CCMenuItemFont::create(pstTeamScore[2].nameScore, this, NULL);
CCMenuItemFont *oooTeam = CCMenuItemFont::create(pstTeamScore[3].nameScore, this, menu_selector(BoxMenu::newGame));
CCMenuItemFont *threeTeam = CCMenuItemFont::create(pstTeamScore[4].nameScore, this, menu_selector(BoxMenu::newGame));
CCMenuItemFont *pigTeam = CCMenuItemFont::create(pstTeamScore[5].nameScore, this, menu_selector(BoxMenu::newGame));
CCMenuItemFont *fngngTeam = CCMenuItemFont::create(pstTeamScore[6].nameScore, this, menu_selector(BoxMenu::newGame));
/*
ljxTeam->setColor(ccBLACK);
xxxTeam->setColor(ccBLACK);
birdTeam->setColor(ccBLACK);
oooTeam->setColor(ccBLACK);
threeTeam->setColor(ccBLACK);
pigTeam->setColor(ccBLACK);
fngngTeam->setColor(ccBLACK);
*/
ljxTeam->setTag(TeamLJX);
xxxTeam->setTag(TeamXXX);
birdTeam->setTag(TeamBird);
oooTeam->setTag(TeamOOO);
threeTeam->setTag(TeamThree);
pigTeam->setTag(TeamPig);
fngngTeam->setTag(TeamFngng);
CCMenu *menu = CCMenu::create(ljxTeam, xxxTeam, birdTeam, oooTeam, threeTeam, pigTeam, fngngTeam, NULL);
menu->alignItemsVertically();
return menu;
}
示例10: initWithSubTest
////////////////////////////////////////////////////////
//
// ParticleMainScene
//
////////////////////////////////////////////////////////
void ParticleMainScene::initWithSubTest(int asubtest, int particles)
{
//srandom(0);
subtestNumber = asubtest;
CCSize s = CCDirector::sharedDirector()->getWinSize();
lastRenderedCount = 0;
quantityParticles = particles;
CCMenuItemFont::setFontSize(65);
CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(ParticleMainScene::onDecrease));
decrease->setColor(ccc3(0,200,20));
CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(ParticleMainScene::onIncrease));
increase->setColor(ccc3(0,200,20));
CCMenu *menu = CCMenu::create(decrease, increase, NULL);
menu->alignItemsHorizontally();
menu->setPosition(ccp(s.width/2, s.height/2+15));
addChild(menu, 1);
CCLabelTTF *infoLabel = CCLabelTTF::create("0 nodes", "Marker Felt", 30);
infoLabel->setColor(ccc3(0,200,20));
infoLabel->setPosition(ccp(s.width/2, s.height - 90));
addChild(infoLabel, 1, kTagInfoLayer);
// particles on stage
CCLabelAtlas *labelAtlas = CCLabelAtlas::create("0000", "fps_images.png", 12, 32, '.');
addChild(labelAtlas, 0, kTagLabelAtlas);
labelAtlas->setPosition(ccp(s.width-66,50));
// Next Prev Test
ParticleMenuLayer* pMenu = new ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx);
addChild(pMenu, 1, kTagMenuLayer);
pMenu->release();
// Sub Tests
CCMenuItemFont::setFontSize(40);
CCMenu* pSubMenu = CCMenu::create();
for (int i = 1; i <= 6; ++i)
{
char str[10] = {0};
sprintf(str, "%d ", i);
CCMenuItemFont* itemFont = CCMenuItemFont::create(str, this, menu_selector(ParticleMainScene::testNCallback));
itemFont->setTag(i);
pSubMenu->addChild(itemFont, 10);
if (i <= 3)
{
itemFont->setColor(ccc3(200,20,20));
}
else
{
itemFont->setColor(ccc3(0,200,20));
}
}
pSubMenu->alignItemsHorizontally();
pSubMenu->setPosition(ccp(s.width/2, 80));
addChild(pSubMenu, 2);
CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 40);
addChild(label, 1);
label->setPosition(ccp(s.width/2, s.height-32));
label->setColor(ccc3(255,255,40));
updateQuantityLabel();
createParticleSystem();
schedule(schedule_selector(ParticleMainScene::step));
}
示例11:
BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment()
{
this->setTouchEnabled(true);
// ask director the the window size
CCSize size = CCDirector::sharedDirector()->getWinSize();
// create and initialize a Label
this->m_pLabelShouldRetain = CCLabelBMFont::create(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, kCCTextAlignmentCenter);
this->m_pLabelShouldRetain->retain();
this->m_pArrowsBarShouldRetain = CCSprite::create("Images/arrowsBar.png");
this->m_pArrowsBarShouldRetain->retain();
this->m_pArrowsShouldRetain = CCSprite::create("Images/arrows.png");
this->m_pArrowsShouldRetain->retain();
CCMenuItemFont::setFontSize(20);
CCMenuItemFont *longSentences = CCMenuItemFont::create("Long Flowing Sentences", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged));
CCMenuItemFont *lineBreaks = CCMenuItemFont::create("Short Sentences With Intentional Line Breaks", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged));
CCMenuItemFont *mixed = CCMenuItemFont::create("Long Sentences Mixed With Intentional Line Breaks", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged));
CCMenu *stringMenu = CCMenu::create(longSentences, lineBreaks, mixed, NULL);
stringMenu->alignItemsVertically();
longSentences->setColor(ccRED);
m_pLastSentenceItem = longSentences;
longSentences->setTag(LongSentences);
lineBreaks->setTag(LineBreaks);
mixed->setTag(Mixed);
CCMenuItemFont::setFontSize(30);
CCMenuItemFont *left = CCMenuItemFont::create("Left", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged));
CCMenuItemFont *center = CCMenuItemFont::create("Center", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged));
CCMenuItemFont *right = CCMenuItemFont::create("Right", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged));
CCMenu *alignmentMenu = CCMenu::create(left, center, right, NULL);
alignmentMenu->alignItemsHorizontallyWithPadding(alignmentItemPadding);
center->setColor(ccRED);
m_pLastAlignmentItem = center;
left->setTag(LeftAlign);
center->setTag(CenterAlign);
right->setTag(RightAlign);
// position the label on the center of the screen
this->m_pLabelShouldRetain->setPosition(ccp(size.width/2, size.height/2));
this->m_pArrowsBarShouldRetain->setVisible(false);
float arrowsWidth = (ArrowsMax - ArrowsMin) * size.width;
this->m_pArrowsBarShouldRetain->setScaleX(arrowsWidth / this->m_pArrowsBarShouldRetain->getContentSize().width);
this->m_pArrowsBarShouldRetain->setPosition(ccp(((ArrowsMax + ArrowsMin) / 2) * size.width, this->m_pLabelShouldRetain->getPosition().y));
this->snapArrowsToEdge();
stringMenu->setPosition(ccp(size.width/2, size.height - menuItemPaddingCenter));
alignmentMenu->setPosition(ccp(size.width/2, menuItemPaddingCenter+15));
this->addChild(this->m_pLabelShouldRetain);
this->addChild(this->m_pArrowsBarShouldRetain);
this->addChild(this->m_pArrowsShouldRetain);
this->addChild(stringMenu);
this->addChild(alignmentMenu);
}
示例12: initWithSubTest
////////////////////////////////////////////////////////
//
// SpriteMainScene
//
////////////////////////////////////////////////////////
void SpriteMainScene::initWithSubTest(int asubtest, int nNodes)
{
//srandom(0);
subtestNumber = asubtest;
m_pSubTest = new SubTest;
m_pSubTest->initWithSubTest(asubtest, this);
CCSize s = CCDirector::sharedDirector()->getWinSize();
lastRenderedCount = 0;
quantityNodes = 0;
CCMenuItemFont::setFontSize(65);
CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(SpriteMainScene::onDecrease));
decrease->setColor(ccc3(0,200,20));
CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(SpriteMainScene::onIncrease));
increase->setColor(ccc3(0,200,20));
CCMenu *menu = CCMenu::create(decrease, increase, NULL);
menu->alignItemsHorizontally();
menu->setPosition(ccp(s.width/2, s.height-65));
addChild(menu, 1);
CCLabelTTF *infoLabel = CCLabelTTF::create("0 nodes", "Marker Felt", 30);
infoLabel->setColor(ccc3(0,200,20));
infoLabel->setPosition(ccp(s.width/2, s.height-90));
addChild(infoLabel, 1, kTagInfoLayer);
// add menu
SpriteMenuLayer* pMenu = new SpriteMenuLayer(true, TEST_COUNT, s_nSpriteCurCase);
addChild(pMenu, 1, kTagMenuLayer);
pMenu->release();
// Sub Tests
CCMenuItemFont::setFontSize(32);
CCMenu* pSubMenu = CCMenu::create();
for (int i = 1; i <= 9; ++i)
{
char str[10] = {0};
sprintf(str, "%d ", i);
CCMenuItemFont* itemFont = CCMenuItemFont::create(str, this, menu_selector(SpriteMainScene::testNCallback));
itemFont->setTag(i);
pSubMenu->addChild(itemFont, 10);
if( i<= 3)
itemFont->setColor(ccc3(200,20,20));
else if(i <= 6)
itemFont->setColor(ccc3(0,200,20));
else
itemFont->setColor(ccc3(0,20,200));
}
pSubMenu->alignItemsHorizontally();
pSubMenu->setPosition(ccp(s.width/2, 80));
addChild(pSubMenu, 2);
// add title label
CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 40);
addChild(label, 1);
label->setPosition(ccp(s.width/2, s.height-32));
label->setColor(ccc3(255,255,40));
while(quantityNodes < nNodes)
onIncrease(this);
}