本文整理汇总了C++中CCMenuItemFont::setFontSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemFont::setFontSize方法的具体用法?C++ CCMenuItemFont::setFontSize怎么用?C++ CCMenuItemFont::setFontSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemFont
的用法示例。
在下文中一共展示了CCMenuItemFont::setFontSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
}
}
示例3: addChild
bool Options::init()
{
if (!CCLayer::init()) {
return false;
}
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCSprite *sp = CCSprite::create(s_loading);
sp->setAnchorPoint(CCPointZero);
addChild(sp, 0, 1);
CCTexture2D *imageCache = CCTextureCache::sharedTextureCache()->addImage(s_menuTitle);
CCSprite *title = CCSprite::createWithTexture(imageCache, CCRectMake(0, 0, 134, 34));
title->setPosition(ccp(winSize.width/2, winSize.height - 60));
addChild(title);
CCMenuItemFont *menuTitle = CCMenuItemFont::create("Sound");
menuTitle->setFontName("Arial");
menuTitle->setFontSize(18);
menuTitle->setEnabled(false);
CCMenuItemFont::setFontName("Arial");
CCMenuItemFont::setFontSize(26);
CCMenuItemToggle *toggle = CCMenuItemToggle::createWithTarget(this, menu_selector(Options::setOptions), CCMenuItemFont::create("On"),CCMenuItemFont::create("Off"), NULL);
int selectId = Config::sharedConfig()->getAudioState()? 0 : 1;
toggle->setSelectedIndex(selectId);
CCLabelBMFont *backLb = CCLabelBMFont::create("Go Back", s_font);
CCMenuItemLabel *goBack = CCMenuItemLabel::create(backLb, this, menu_selector(Options::goBack));
goBack->setScale(0.6);
CCActionInterval *fadeIn = CCFadeTo::create(1, 80);
CCActionInterval *fadeOut = CCFadeTo::create(1, 255);
CCEaseSineInOut *ease1 = CCEaseSineInOut::create(fadeIn);
CCEaseSineInOut *ease2 = CCEaseSineInOut::create(fadeOut);
CCFiniteTimeAction *seq = CCSequence::create(ease1, ease2, NULL);
// 这里也是,参数必须强转,否则NDK编译不过
goBack->runAction(CCRepeatForever::create((CCActionInterval*)seq));
CCMenu *menu = CCMenu::create( menuTitle, toggle, goBack, NULL);
menu->alignItemsInColumns(2,1);
addChild(menu);
CCPoint pos = goBack->getPosition();
pos.y -= 50;
goBack->setPosition(pos);
return true;
}
示例4: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
//initPhysic();
//addPhysicSprite();
_inputGrid = NULL;
//此处开启单点触摸,需要重写ccTouchBegan,ccTouchEnded
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,0,true);
//此处开启多点触摸
//this->setTouchEnabled(true);
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
//g_logger->Log(WStrToUTF8(L"你好").c_str());
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
s_BtnCloseNormal,
s_BtnCloseSelected,
this,
menu_selector(HelloWorld::menuCloseCallback));
pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
origin.y + pCloseItem->getContentSize().height/2));
CCMenuItemFont *pMenuItem = CCMenuItemFont::create("Main",this,menu_selector(HelloWorld::menuGotoMainMenu));
pMenuItem->setFontSize(10);
pMenuItem->setColor(ccc3(0,0,0));
pMenuItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
origin.y + pCloseItem->getContentSize().height/2+30));
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem,pMenuItem, NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu, 1);
/////////////////////////////
// 3. add your codes below...
_background = CCSprite::create(s_BackGround);
_background->setVisible(true);
// position the sprite on the center of the screen
_background->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
// add the sprite as a child to this layer
this->addChild(_background, Z_BACKGROUND);
_background->setScale(1.0);
int i = 0;
CCTexture2D* gridTexture = CCTextureCache::sharedTextureCache()->addImage(s_Grid);
g_gridSize = gridTexture->getContentSize();
CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache();
cache->addSpriteFramesWithFile("Images/ccbDefaultImages.plist");
CCLOG("grid size width:%0.1f,height:%0.1f",g_gridSize.width,g_gridSize.height);
CCPoint gridOrigin(ccp(O_GRID_X,O_GRID_Y));
g_pad = InputPad::create();
g_pad->setAnchorPoint(ccp(0,0));
g_pad->setVisible(false);
g_pad->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
this->addChild(g_pad,Z_INPUTPAD);
CCLOG("g_pad width:%0.1f,height:%0.1f",g_pad->getContentSize().width,g_pad->getContentSize().height);
XAXA::LevelMap* level_map = XAXA::LevelMgr::instance()->get_level_map(XAXA::LevelMgr::instance()->get_curr_level());
XAXA::SudokuLevelMap* sudoku = dynamic_cast<XAXA::SudokuLevelMap*>(level_map);
int* level = sudoku->get_level();
for(i=0;i<SUDOKU_GRID;i++) {
for(int j=0;j<SUDOKU_GRID;j++) {
bool isStatic = (level[i*SUDOKU_GRID+j] !=255);
Grid* pGrid = Grid::GridWithTexture(gridTexture,level[i*SUDOKU_GRID+j],isStatic);
pGrid->GetNode()->setPosition(ccp(gridOrigin.x+j*(g_gridSize.width+2),
gridOrigin.y+(i+1)*(g_gridSize.height+2)));
this->addChild(pGrid->GetNode(), Z_GRID_NUMBER);
g_GridList[i*SUDOKU_GRID+j] = pGrid;
}
}
return true;
}