本文整理汇总了C++中CCMenuItemLabel::setColor方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemLabel::setColor方法的具体用法?C++ CCMenuItemLabel::setColor怎么用?C++ CCMenuItemLabel::setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemLabel
的用法示例。
在下文中一共展示了CCMenuItemLabel::setColor方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
// on "init" you need to initialize your instance
bool Title::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
srand(time(NULL));
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("panels.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("title.plist");
SimpleAudioEngine::sharedEngine()->preloadEffect("menu.wav");
SimpleAudioEngine::sharedEngine()->preloadEffect("pon.wav");
SimpleAudioEngine::sharedEngine()->preloadEffect("shupiin.wav");
//CCLabelTTF* titleLabel = CCLabelTTF::create("Hello", "arial", 20);
//titleLabel->setPosition(CCPoint(visibleSize.width / 2, visibleSize.height / 2));
//this->addChild(titleLabel);
CCSprite* titleBackground = CCSprite::createWithSpriteFrameName("title.png");
titleBackground->setAnchorPoint(CCPoint(0.5, 0.5));
titleBackground->setScale(visibleSize.width / 640);
titleBackground->setPosition(CCPoint(visibleSize.width / 2, visibleSize.height / 2));
this->addChild(titleBackground, 1);
CCMenuItemFont* gameMainFont = CCMenuItemFont::create("GAME START", this, menu_selector(Title::gameMainAction));
gameMainFont->setFontNameObj(MISAKI_FONT);
CCMenuItemLabel *gameMainButton = gameMainFont;
gameMainButton->setColor(ccBLACK);
CCMenuItemFont* rankingFont = CCMenuItemFont::create("RANKING", this, menu_selector(Title::rankingAction));
rankingFont->setFontNameObj(MISAKI_FONT);
CCMenuItemLabel *rankingButton =rankingFont;
rankingButton->setColor(ccBLACK);
//CCMenuItemLabel *gamecenterButton = CCMenuItemFont::create("GameCenterLogin", this, menu_selector(Title::login));
CCMenuItemFont* creditFont = CCMenuItemFont::create("CREDIT", this, menu_selector(Title::creditAction));
creditFont->setFontNameObj(MISAKI_FONT);
CCMenuItemLabel *creditButton =creditFont;
creditButton->setColor(ccBLACK);
//CCMenu *menu = CCMenu::createWithItems(gameMainButton, NULL);
CCMenu *menu = CCMenu::create(gameMainButton, rankingButton, creditButton, NULL);
menu->setPosition(ccp(visibleSize.width/2, visibleSize.height/4));
menu->alignItemsVertically();
this->addChild(menu, 2);
CCGATracker::sendView("Title");
setTouchEnabled(true);
this->schedule(schedule_selector(Title::update));
return true;
}
示例2: init
// Initialize the menu items, background, and overall setup of the main menu
//
// return - false if there was an error in initializing, true otherwise
bool MainMenu::init()
{
CCLabelTTF* labelSinglePlayer; // the text for single player menu item
CCLabelTTF* labelMultiplayer; // the text for multiplayer menu item
CCLabelTTF* labelOptions; // the text for options menu item
CCMenuItemLabel* itemSinglePlayer; // menu item for starting single player game
CCMenuItemLabel* itemMultiplayer; // menu item for starting multiplayer game
CCMenuItemLabel* itemOptions; // menu item for opening up options
CCMenu* menu; // menu to contain the menu items
CCSize size; // the size of the window
CCSprite* background; // the background splashscreen
if(!CCLayer::init())
{
return false;
}
// get the window size from the director
size = CCDirector::sharedDirector()->getWinSize();
// create the text for the menu items
labelSinglePlayer = CCLabelTTF::create("Start Single Player", FONT_STYLE, Font_Size_Default);
labelMultiplayer = CCLabelTTF::create("Start Multiplayer", FONT_STYLE, Font_Size_Default);
labelOptions = CCLabelTTF::create("Options", FONT_STYLE, Font_Size_Default);
// add shadows to the labels, so they will be easier to read against the background
labelSinglePlayer->enableShadow(FONT_SHADOW_OFFSET, FONT_SHADOW_OPACITY, FONT_SHADOW_BLUR);
labelMultiplayer->enableShadow(FONT_SHADOW_OFFSET, FONT_SHADOW_OPACITY, FONT_SHADOW_BLUR);
labelOptions->enableShadow(FONT_SHADOW_OFFSET, FONT_SHADOW_OPACITY, FONT_SHADOW_BLUR);
// create the items for the menu
itemSinglePlayer = CCMenuItemLabel::create(labelSinglePlayer, this, menu_selector(MainMenu::HandleSinglePlayerPressed));
itemMultiplayer = CCMenuItemLabel::create(labelMultiplayer, this, menu_selector(MainMenu::HandleMultiplayerPressed));
itemOptions = CCMenuItemLabel::create(labelOptions, this, menu_selector(MainMenu::HandleOptionsPressed));
// set the color of the menu items
itemSinglePlayer->setColor(MENU_COLOR);
itemMultiplayer->setColor(MENU_COLOR);
itemOptions->setColor(MENU_COLOR);
// create menu to contain the menu items
menu = CCMenu::create(itemSinglePlayer, itemMultiplayer, itemOptions, NULL);
menu->alignItemsVerticallyWithPadding(MENU_ITEM_PADDING);
menu->setPosition(size.width * POS_HALF_SCREEN, size.height * POS_HALF_SCREEN);
addChild(menu, 1);
// add splash screen as a sprite on the center of the screen
background = CCSprite::create(BACKGROUND_IMAGE);
background->setScale(size.height / background->boundingBox().size.height);
background->setPosition( ccp(size.width * POS_HALF_SCREEN, size.height * POS_HALF_SCREEN) );
addChild(background, 0);
return true;
}
示例3: Prepare
void UserInterface::Prepare() {
CCLabelTTF *label = CCLabelTTF::create("Light ON/OFF", "HelveticaNeue-Bold", 25);
CCMenuItemLabel *labelItem = CCMenuItemLabel::create(label, (CCObject *)engine, menu_selector(TEEngine::switchLight));
ccColor3B color = {255, 255, 255};
labelItem->setColor(color);
labelItem->setPosition(CCPointZero);
labelItem->setAnchorPoint(CCPointZero);
CCMenu *menu = CCMenu::create(labelItem, nullptr);
menu->setPosition(CCPoint(00, 560));
menu->setTouchEnabled(true);
_guiNodes->addObject(menu);
}
示例4: init
// Initialize the UI for the main game scene
//
// return - false if there was an error in initializing, true otherwise
bool UILayer::init()
{
CCLabelTTF* labelPause; // the text for pause menu item
CCMenuItemLabel* itemPause; // menu item for opening the pause menu
CCMenu* menu; // menu to contain the menu item
CCSize size; // the size of the window
if(!CCLayer::init())
{
return false;
}
// get the window size from the director
size = CCDirector::sharedDirector()->getWinSize();
// create the pause menu item, and add an outline around it to make it readable
labelPause = CCLabelTTF::create("Pause", FONT_STYLE, Font_Size_Default);
labelPause->enableStroke(FONT_STROKE_COLOR, FONT_STROKE_THICK);
// Set up for single player or not
if(Is_Single_Player)
{
SetUpSinglePlayer(size);
}
else
{
SetUpMultiPlayer(size);
}
itemPause = CCMenuItemLabel::create(labelPause, this, menu_selector(UILayer::HandlePausePressed));
itemPause->setColor(MENU_COLOR);
itemPause->setPosition(ccp(size.width * PAUSE_WIDTH_POS, size.height * PAUSE_HEIGHT_POS));
// create the menu containing the pause item
menu = CCMenu::create(itemPause, NULL);
menu->setPosition(CCPointZero);
this->addChild(m_scoreLabel, 1);
this->addChild(menu, 1);
return true;
}
示例5: ccp
TestController::TestController()
: m_tBeginPos(CCPointZero)
{
// add close menu
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(s_pPathClose, s_pPathClose, this, menu_selector(TestController::closeCallback) );
CCMenu* pMenu =CCMenu::create(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
pCloseItem->setPosition(ccp( VisibleRect::right().x - 30, VisibleRect::top().y - 30));
// add menu items for tests
m_pItemMenu = CCMenu::create();
for (int i = 0; i < TESTS_COUNT; ++i)
{
// #if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
// CCLabelBMFont* label = CCLabelBMFont::create(g_aTestNames[i].c_str(), "fonts/arial16.fnt");
// #else
CCLabelTTF* label = CCLabelTTF::create(g_aTestNames[i].c_str(), "Arial", 24);
// #endif
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(TestController::menuCallback));
m_pItemMenu->addChild(pMenuItem, i + 10000);
pMenuItem->setPosition( ccp( VisibleRect::center().x, (VisibleRect::top().y - (i + 1) * LINE_SPACE) ));
if (!isTestDemoEnabled(i))
{
pMenuItem->setColor(ccGRAY);
pMenuItem->setEnabled(false);
}
}
m_pItemMenu->setContentSize(CCSizeMake(VisibleRect::getVisibleRect().size.width, (TESTS_COUNT + 1) * (LINE_SPACE)));
m_pItemMenu->setPosition(s_tCurPos);
addChild(m_pItemMenu);
setTouchEnabled(true);
addChild(pMenu, 1);
}
示例6: init
// Initialize the menu items, background, and overall setup of the music selection menu
//
// return - false if there was an error in initializing, true otherwise
bool MusicSelect::init()
{
CCLabelTTF* labelFirstSong; // the text for the first song menu item
CCLabelTTF* labelSecondSong; // the text for the second song menu item
CCLabelTTF* labelThirdSong; // the text for the third song menu item
CCLabelTTF* labelYourMusic; // the text for your music menu item
CCLabelTTF* labelPlay; // the text for play menu item
CCLabelTTF* labelBack; // the text for back menu item
CCMenuItemLabel* itemFirstSong; // menu item for choosing the first song
CCMenuItemLabel* itemSecondSong; // menu item for choosing the second song
CCMenuItemLabel* itemThirdSong; // menu item for choosing the third song
CCMenuItemLabel* itemYourMusic; // menu item for opening your music selection
CCMenuItemLabel* itemBack; // menu item for going back to character select
CCMenu* menu; // menu to contain the menu items
CCSize size; // the size of the window
if(!CCLayer::init())
{
return false;
}
// get the window size from the director
size = CCDirector::sharedDirector()->getWinSize();
// create the header for the scene
m_header = CCLabelTTF::create("Choose a song", FONT_STYLE, Font_Size_Small);
m_header->setPosition( ccp(size.width * POS_HALF_SCREEN, size.height * POS_HEADER_HEIGHT) );
m_header->setColor(MENU_COLOR);
this->addChild(m_header, 1);
// create the text for the menu items
labelFirstSong = CCLabelTTF::create("Letting Go - UltraMax", FONT_STYLE, Font_Size_Default);
labelSecondSong = CCLabelTTF::create("The Call of Stars - UltraMax", FONT_STYLE, Font_Size_Default);
labelThirdSong = CCLabelTTF::create("Waiting - UltraMax", FONT_STYLE, Font_Size_Default);
labelYourMusic = CCLabelTTF::create("Select from SD card", FONT_STYLE, Font_Size_Default);
labelBack = CCLabelTTF::create("Back", FONT_STYLE, Font_Size_Default);
labelPlay = CCLabelTTF::create("Play", FONT_STYLE, Font_Size_Default);
// create the items for the menu
itemFirstSong = CCMenuItemLabel::create(labelFirstSong, this, menu_selector(MusicSelect::HandleFirstSongPressed));
itemSecondSong = CCMenuItemLabel::create(labelSecondSong, this, menu_selector(MusicSelect::HandleSecondSongPressed));
itemThirdSong = CCMenuItemLabel::create(labelThirdSong, this, menu_selector(MusicSelect::HandleThirdSongPressed));
itemYourMusic = CCMenuItemLabel::create(labelYourMusic, this, menu_selector(MusicSelect::HandleYourMusicPressed));
itemBack = CCMenuItemLabel::create(labelBack, this, menu_selector(MusicSelect::HandleBackPressed));
m_itemPlay = CCMenuItemLabel::create(labelPlay, this, menu_selector(MusicSelect::HandlePlayPressed));
// set the color of the menu items
itemFirstSong->setColor(FONT_COLOR);
itemSecondSong->setColor(FONT_COLOR);
itemThirdSong->setColor(FONT_COLOR);
itemYourMusic->setColor(FONT_COLOR);
itemBack->setColor(FONT_COLOR);
m_itemPlay->setColor(FONT_COLOR);
// disable the play menu item, because user needs to pick a song first
m_itemPlay->setVisible(false);
m_itemPlay->setEnabled(false);
// create menu to contain the menu items
menu = CCMenu::create(itemFirstSong, itemSecondSong, itemThirdSong, itemYourMusic, m_itemPlay, itemBack, NULL);
menu->alignItemsVerticallyWithPadding(MENU_PADDING);
menu->setPosition(size.width * POS_HALF_SCREEN, size.height * MENU_POS_HEIGHT);
this->addChild(menu, 1);
// initialize the booleans
m_choseUserMusic = false;
m_haveJniData = false;
m_songSelected = false;
return true;
}
示例7: init
bool MapControlLayer::init()
{
if ( !CCLayerColor::init() )
{
return false;
}
removeAllChildrenWithCleanup(true);
CCSize screenSize = GameParams::getInstanse()->screenSize;
sizeHeight = 200;
showed = false;
layersCnt_ = 0;
m_bTouchEnabled = true;
CCLabelTTF * mapLabel = CCLabelTTF::create("Карта", "Marker Felt", 22);
mapLabel->setAnchorPoint(ccp(0,1));
mapLabel->setPosition(ccp(25,sizeHeight-5));
CCLabelTTF * layers = CCLabelTTF::create("Слои", "Marker Felt", 18);
layers->setAnchorPoint(ccp(0,1));
layers->setPosition(ccp(25,sizeHeight-35));
CCMenuItemLabel* layersPlus = CCMenuItemLabel::create(CCLabelTTF::create("+", "Marker Felt", 18),this,menu_selector(MapControlLayer::plusLayers));
layersPlus->setAnchorPoint(ccp(0,1));
layersPlus->setPosition(ccp(135,sizeHeight-35));
CCMenuItemLabel* layersMinus = CCMenuItemLabel::create(CCLabelTTF::create("-", "Marker Felt", 18),this,menu_selector(MapControlLayer::minusLayers));
layersMinus->setAnchorPoint(ccp(0,1));
layersMinus->setPosition(ccp(95,sizeHeight-35));
layersCnt = CCLabelTTF::create("1", "Marker Felt", 18);
layersCnt->setAnchorPoint(ccp(0,1));
layersCnt->setPosition(ccp(110,sizeHeight-35));
CCLabelTTF * tileset = CCLabelTTF::create("Тайлсет", "Marker Felt", 18);
tileset->setAnchorPoint(ccp(0,1));
tileset->setPosition(ccp(25,sizeHeight-65));
CCMenuItemLabel* tilesetPlus = CCMenuItemLabel::create(CCLabelTTF::create("+", "Marker Felt", 18),this,menu_selector(MapControlLayer::plusTileset));
tilesetPlus->setAnchorPoint(ccp(0,1));
tilesetPlus->setPosition(ccp(135,sizeHeight-65));
CCMenuItemLabel* tilesetMinus = CCMenuItemLabel::create(CCLabelTTF::create("-", "Marker Felt", 18),this,menu_selector(MapControlLayer::minusTileset));
tilesetMinus->setAnchorPoint(ccp(0,1));
tilesetMinus->setPosition(ccp(95,sizeHeight-65));
tilesetCnt = CCLabelTTF::create("1", "Marker Felt", 18);
tilesetCnt->setAnchorPoint(ccp(0,1));
tilesetCnt->setPosition(ccp(110,sizeHeight-65));
CCMenuItemLabel* SaveMap = CCMenuItemLabel::create(CCLabelTTF::create("Сохранить!", "Marker Felt", 22),this,menu_selector(MapControlLayer::SaveMap));
SaveMap->setColor(ccc3(20, 200, 20));
SaveMap->setAnchorPoint(ccp(0,1));
SaveMap->setPosition(ccp(35,sizeHeight-95));
CCMenuItemLabel* closeMap = CCMenuItemLabel::create(CCLabelTTF::create("Закрыть", "Marker Felt", 22),this,menu_selector(MapControlLayer::CloseMap));
closeMap->setColor(ccc3(20, 20, 200));
closeMap->setAnchorPoint(ccp(0,1));
closeMap->setPosition(ccp(35,sizeHeight-125));
CCMenuItemLabel* deleteMap = CCMenuItemLabel::create(CCLabelTTF::create("Удалить", "Marker Felt", 22),this,menu_selector(MapControlLayer::DeleteMap));
deleteMap->setColor(ccc3(200, 20, 20));
deleteMap->setAnchorPoint(ccp(0,1));
deleteMap->setPosition(ccp(35,sizeHeight-155));
setColor(ccc3(144,144,144));
setOpacity(220);
setContentSize(CCSizeMake(screenSize.width-GameParams::getInstanse()->programLayerWidth,sizeHeight));
arrow = CCMenuItemImage::create("System/down.png", "System/down.png",this, menu_selector(MapControlLayer::showLayer));
CCMenu * menu = CCMenu::create(arrow, SaveMap, closeMap, deleteMap, layersPlus, layersMinus, tilesetPlus, tilesetMinus, NULL);
arrow->setAnchorPoint(ccp(0.5,1));
arrow->setPosition(ccp((screenSize.width-GameParams::getInstanse()->programLayerWidth)/2,0));
menu->setPosition(CCPointZero);
menu->retain();
addChild(menu,2);
addChild(mapLabel,2);
addChild(layers,2);
addChild(tileset,2);
addChild(layersCnt,2);
addChild(tilesetCnt,2);
// robots
robotsPrefs = RobotPrefsScrolLayer::getInstanse();
robotsPrefs->setContentSize(CCSizeMake(screenSize.width-GameParams::getInstanse()->programLayerWidth - 200,sizeHeight));
robotsPrefs->setPosition(ccp(200,0));
robotsPrefs->frame = CCRectMake(200, 0, screenSize.width-GameParams::getInstanse()->programLayerWidth - 200, sizeHeight);
// Robot4Edit * robot4Edit = Robot4Edit::create();
//.........这里部分代码省略.........