本文整理汇总了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;
}
示例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;
}