当前位置: 首页>>代码示例>>C++>>正文


C++ CCMenuItemFont::setFontName方法代码示例

本文整理汇总了C++中CCMenuItemFont::setFontName方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemFont::setFontName方法的具体用法?C++ CCMenuItemFont::setFontName怎么用?C++ CCMenuItemFont::setFontName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCMenuItemFont的用法示例。


在下文中一共展示了CCMenuItemFont::setFontName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:crazyboymx,项目名称:games,代码行数:35,代码来源:GameOverLayer.cpp

示例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);
         
      }
   }
}
开发者ID:NonlinearIdeas,项目名称:SlidingMenuDemo,代码行数:56,代码来源:MainScene.cpp

示例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;
}
开发者ID:897290110,项目名称:MoonWarriors,代码行数:52,代码来源:Options.cpp


注:本文中的CCMenuItemFont::setFontName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。