本文整理汇总了C++中CCMenuItemFont::setPositionX方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemFont::setPositionX方法的具体用法?C++ CCMenuItemFont::setPositionX怎么用?C++ CCMenuItemFont::setPositionX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemFont
的用法示例。
在下文中一共展示了CCMenuItemFont::setPositionX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool MainMenu::init()
{
if ( !CCLayerColor::initWithColor(ccc4(0, 0, 0, 200)) )
{
return false;
}
CCLabelTTF *title = CCLabelTTF::create("Rabbit Run", FONT_NAME, 70);
title->setPosition(ccp(SCREEN_CX, SCREEN_HEIGHT - 80));
this->addChild(title);
CCMenuItemFont::setFontName(FONT_NAME);
CCMenuItemFont::setFontSize(50);
char* text[] = {"Score", "Power", "Effect",
"+10", "+20%", "--",
"+20", "+40%", "grow up",
"+10", "+0", "lose weight",
"+0", "+0","hiding"};
for(int i = 0; i < 15; i++)
{
CCLabelTTF *label = CCLabelTTF::create(text[i], FONT_NAME, 50);
label->setPosition(ccp(400 + i%3*300, 550 - i/3*85));
this->addChild(label);
}
char* img[] = {"cabbage.png", "carrot.png", "carrot_ice.png", "carrot_sterlth.png"};
for(int i = 0; i < 4; i++)
{
CCSprite *sprite = CCSprite::create(img[i]);
sprite->setScale(0.2f);
sprite->setPosition(ccp(250, 450 - i*80));
this->addChild(sprite);
}
CCMenuItemFont *startGame = CCMenuItemFont::create("Play", this, menu_selector(MainMenu::startGame));
startGame->setColor(ccc3(0, 255,51));
startGame->setPositionX(-90);
CCMenuItemFont *exitGame = CCMenuItemFont::create("Exit", this, menu_selector(MainMenu::exitGame));
exitGame->setColor(ccc3(255, 0, 0));
exitGame->setPositionX(110);
CCMenu *menu = CCMenu::create(startGame, exitGame, NULL);
menu->setPositionY(120);
menu->setTouchPriority(-201);
this->addChild(menu);
CCLabelTTF *powerBy = CCLabelTTF::create("Power by cocos2d-x", FONT_NAME, 50);
powerBy->setAnchorPoint(ccp(1, 0));
powerBy->setPosition(ccp(SCREEN_WIDTH, 0));
this->addChild(powerBy);
this->setTouchPriority(-200);
this->setTouchMode(kCCTouchesOneByOne);
this->setTouchEnabled(true);
return true;
}