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


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

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


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

示例2: init

bool GameMenu::init()
{
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    
    
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    CCMenuItemFont *pCloseItem = CCMenuItemFont::create("Quit Game",
                                                        this,
                                                        menu_selector(GameMenu::menuCloseCallback) );
    pCloseItem->setPosition( ccp(size.width/2, size.height/8) );
    pCloseItem->setFontSizeObj(25);
    pCloseItem->setFontNameObj("Georgia-Bold");

    CCMenuItemFont* pStartItem = CCMenuItemFont::create("Start Game",
                                                        this,
                                                        menu_selector(GameMenu::menuStartCallback) );
    pStartItem->setPosition(ccp(size.width/2,size.height/4));
    pStartItem->setFontSizeObj(40);
    pStartItem->setFontNameObj("Georgia-Bold");
    
    
    
    CCMenuItemFont* pNextItem = CCMenuItemFont::create(">",
                                                        this,
                                                        menu_selector(GameMenu::selectNext) );
    pNextItem->setPosition(ccp(size.width/3*2,size.height/5*2));
    pNextItem->setFontSizeObj(80);
    pNextItem->setFontNameObj("Georgia-Bold");
    
    CCMenuItemFont* pBackItem = CCMenuItemFont::create("<",
                                                       this,
                                                       menu_selector(GameMenu::selectBack) );
    pBackItem->setPosition(ccp(size.width/3,size.height/5*2));
    pBackItem->setFontSizeObj(80);
    pBackItem->setFontNameObj("Georgia-Bold");
    
    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, pStartItem, pNextItem, pBackItem, NULL);
    pMenu->setPosition( CCPointZero );
    this->addChild(pMenu, 1);
    
    
    CCSprite* pGameName = CCSprite::create("BattleCity.png");
    pGameName->setScale(2.0f);
    pGameName->setPosition(ccp(size.width/2,size.height/3*2));
    this->addChild(pGameName,1);
    
    CCLabelTTF *LevelLabel = CCLabelTTF::create("Level 1", "Georgia-Bold", 55);
    LevelLabel->setString(CCString::createWithFormat("Level %d", m_level)->getCString());
    LevelLabel->setPosition(ccp(size.width/2,size.height/5*2));
    this->addChild(LevelLabel,2,888);
    
    return true;
}
开发者ID:lyzz0612,项目名称:Game,代码行数:58,代码来源:GameMenu.cpp


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