本文整理汇总了C++中MenuItemSprite::setScale方法的典型用法代码示例。如果您正苦于以下问题:C++ MenuItemSprite::setScale方法的具体用法?C++ MenuItemSprite::setScale怎么用?C++ MenuItemSprite::setScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItemSprite
的用法示例。
在下文中一共展示了MenuItemSprite::setScale方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
// on "init" you need to initialize your instance
bool MainMenu::init()
{
if ( !Layer::init() )
{
return false;
}
Sprite* background = Sprite::create("mainbg.jpg");
background->setPosition(SCREEN_SIZE.width/2, SCREEN_SIZE.height/2);
setScale(SCREEN_SIZE.width/background->getContentSize().width,
SCREEN_SIZE.height/background->getContentSize().height);
addChild(background);
Sprite* normalS = Sprite::create("startButton.png");
Sprite* selectedS = Sprite::create("startButton.png");
selectedS->setColor(Color3B::GRAY);
MenuItemSprite* start = MenuItemSprite::create(normalS,
selectedS,
CC_CALLBACK_1(MainMenu::goToStartScene, this));
Point posStart = Point(SCREEN_SIZE.width/2, SCREEN_SIZE.height/4 + 10);
start->setPosition(posStart);
start->setScale(0.5f);
Sprite* normalE = Sprite::create("emergencyButton.png");
normalE->setColor(Color3B::RED);
Sprite* selectedE = Sprite::create("emergencyButton.png");
selectedE->setColor(Color3B::GRAY);
MenuItemSprite* emergency = MenuItemSprite::create(normalE,
selectedE,
CC_CALLBACK_1(MainMenu::goToStartScene, this));
Point posEmer = Point(SCREEN_SIZE.width/3 + 10, SCREEN_SIZE.height/4 + 10);
emergency->setPosition(posEmer);
emergency->setScale(0.5f);
Sprite* normalSe = Sprite::create("settingButton.png");
Sprite* selectedSe = Sprite::create("settingButton.png");
selectedSe->setColor(Color3B::GRAY);
MenuItemSprite* settings = MenuItemSprite::create(normalSe,
selectedSe,
CC_CALLBACK_1(MainMenu::goToStartScene, this));
Point posSe = Point(2 * SCREEN_SIZE.width/3 - 10, SCREEN_SIZE.height/4 + 10);
settings->setPosition(posSe);
settings->setScale(0.5f);
Menu* menu = Menu::create(start, emergency, settings, NULL);
menu->setPosition(Point::ZERO);
addChild(menu, 1);
return true;
}