本文整理汇总了C++中MenuItemFont::setFontName方法的典型用法代码示例。如果您正苦于以下问题:C++ MenuItemFont::setFontName方法的具体用法?C++ MenuItemFont::setFontName怎么用?C++ MenuItemFont::setFontName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItemFont
的用法示例。
在下文中一共展示了MenuItemFont::setFontName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initNavigator
void GamePlayScene::initNavigator() {
MenuItemFont *menuTitle = MenuItemFont::create(Constant::MENU_PLAY, CC_CALLBACK_1(GamePlayScene::navigatorCallback, this));
menuTitle->setFontName(Constant::FONT);
menuTitle->setFontSize(64);
menuTitle->setVisible(false);
MenuItemFont *back = MenuItemFont::create(Constant::MENU_BACK, CC_CALLBACK_1(GamePlayScene::navigatorCallback, this));
back->setFontName(Constant::FONT);
back->setFontSize(64);
back->setTag(Constant::MENU_BACK_TAG);
MenuItemFont *start = MenuItemFont::create(Constant::MENU_START, CC_CALLBACK_1(GamePlayScene::navigatorCallback, this));
start->setFontName(Constant::FONT);
start->setFontSize(64);
start->setTag(Constant::MENU_START_TAG);
Menu *menu = Menu::create(back, start, NULL);
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
back->setPosition(Vec2(origin.x + visibleSize.width - back->getContentSize().width / 2,
origin.y + back->getContentSize().height / 2));
start->setPosition(Vec2(origin.x + start->getContentSize().width / 2,
origin.y + back->getContentSize().height / 2));
menu->setPosition(Vec2::ZERO);
addChild(menu);
}
示例2: gameOver
// Menus
void GameLevelLayer::gameOver(bool playerDidWin)
{
m_isGameOver = true;
std::string gameText;
if (playerDidWin)
{
gameText = "You Won!";
}
else
{
gameText = "You have Died!";
CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("hurt.wav");
}
Menu* pMenu = CCMenu::create();
pMenu->setPosition(Vec2(240, -100));
MenuItemFont *diedLabel = MenuItemFont::create(gameText);
diedLabel->setFontName("Marker Felt");
diedLabel->setFontSize(24);
diedLabel->setPosition(Vec2(240, 200));
pMenu->addChild(diedLabel);
MoveBy *slideIn = MoveBy::create(1.0, Vec2(0,250));
MenuItemImage *replay = MenuItemImage::create("replay.png", "replay.png", "replay.png");
replay->setPosition(Point::ZERO);
replay->setCallback(CC_CALLBACK_1(GameLevelLayer::replayButtonCallback, this));
pMenu->addChild(replay);
this->addChild(pMenu, 1);
pMenu->runAction(slideIn);
}
示例3: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
cocos2d::Vector<MenuItem*> menuItems;
/////////////////////////////
// 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
MenuItemFont* gameItem = MenuItemFont::create( "Start", this, menu_selector( HelloWorld::OnMenuGameStart ) );
gameItem->setFontSize(25);
gameItem->setFontName("Arial");
menuItems.pushBack( gameItem );
MenuItemFont* gameItem1 = MenuItemFont::create( "Start1", this, menu_selector( HelloWorld::OnMenuGameStart1 ) );
gameItem1->setFontSize(25);
gameItem1->setFontName("Arial");
menuItems.pushBack( gameItem1 );
MenuItemFont* gameItem2 = MenuItemFont::create( "Blocks", this, menu_selector( HelloWorld::OnMenuGameBlocksStart ) );
gameItem1->setFontSize(25);
gameItem1->setFontName("Arial");
menuItems.pushBack( gameItem2 );
MenuItemFont* gameItem3 = MenuItemFont::create( "Soomla Store Test", this, menu_selector( HelloWorld::OnMenuSoomlaStoreTest) );
gameItem1->setFontSize(25);
gameItem1->setFontName("Arial");
menuItems.pushBack( gameItem3 );
MenuItemFont* gameItem4 = MenuItemFont::create( "Soomla Level Test", this, menu_selector( HelloWorld::OnMenuSoomlaLevelTest ) );
gameItem1->setFontSize(25);
gameItem1->setFontName("Arial");
menuItems.pushBack( gameItem4 );
MenuItemFont* optionsItem = MenuItemFont::create( "Options", this, menu_selector( HelloWorld::OnMenuOptions ) );
optionsItem->setFontSize(25);
optionsItem->setFontName("Arial");
menuItems.pushBack( optionsItem );
MenuItemFont* closeItem = MenuItemFont::create( "Exit", this, menu_selector( HelloWorld::menuCloseCallback ) );
menuItems.pushBack( closeItem );
//closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 , origin.y + closeItem->getContentSize().height/2));
//closeItem->setPosition(Vec2::ANCHOR_MIDDLE);
// create menu, it's an autorelease object
auto menu = Menu::createWithArray(menuItems);
this->addChild(menu, 1);
menu->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height/2));
menu->alignItemsVerticallyWithPadding( 10 );
/////////////////////////////
// 3. add your codes below...
// add a label shows "Hello World"
// create and initialize a label
auto label = LabelTTF::create("Hello World", "Arial", 24);
// position the label on the center of the screen
label->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height - label->getContentSize().height));
//label->setPosition(Vec2::ANCHOR_MIDDLE);
// add the label as a child to this layer
this->addChild(label, 1);
// add "HelloWorld" splash screen"
auto sprite = Sprite::create("HelloWorld.png");
// position the sprite on the center of the screen
sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
// add the sprite as a child to this layer
//this->addChild(sprite, 0);
return true;
}