本文整理汇总了C++中LabelBMFont::setScale方法的典型用法代码示例。如果您正苦于以下问题:C++ LabelBMFont::setScale方法的具体用法?C++ LabelBMFont::setScale怎么用?C++ LabelBMFont::setScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LabelBMFont
的用法示例。
在下文中一共展示了LabelBMFont::setScale方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: endScene
void HelloWorld::endScene(EndReason endReason) {
if (_gameOver)
return;
_gameOver = true;
//存储分数
setHighestHistorySorce();
gScore = 0;
auto winSize = Director::getInstance()->getWinSize();
char message[10] = "You Win";
if (endReason == KENDREASONLOSE)
strcpy(message, "You Lose");
LabelBMFont * label;
label = LabelBMFont::create(message,"fonts/Arial.fnt");
label->setScale(0.1);
label->setPosition(Point(winSize.width / 2, winSize.height*0.6));
this->addChild(label);
LabelBMFont * restartLabel;
restartLabel = LabelBMFont::create("Restart", "fonts/Arial.fnt");
auto *restartItem = MenuItemLabel::create(restartLabel,CC_CALLBACK_1(HelloWorld::restartTapped,this));
restartItem->setScale(0.1);
restartItem->setPosition(Point(winSize.width / 2, winSize.height*0.4));
Menu *menu = Menu::create(restartItem, NULL);
menu->setPosition(Point::ZERO);
this->addChild(menu);
// clear label and menu
restartItem->runAction(ScaleTo::create(0.5, 1.0));
label->runAction(ScaleTo::create(0.5, 1.0));
// Terminate update callback
this->unscheduleUpdate();
}
示例2: showRestartMenu
void HelloWorld::showRestartMenu()
{
Size winSize = Director::getInstance()->getWinSize();
const char *message;
if (_won)
{
message = "You win!";
}
else
{
message = "You lose!";
}
LabelBMFont *label = LabelBMFont::create(message, "Arial.fnt");
label->setScale(0.1f);
label->setPosition(winSize.width / 2, winSize.height * 0.6f);
this->addChild(label);
LabelBMFont *restartLabel = LabelBMFont::create("Restart", "Arial.fnt");
MenuItemLabel *restartItem = MenuItemLabel::create(restartLabel, [](Object *sender){
Director::getInstance()->replaceScene(TransitionZoomFlipX::create(0.5f, HelloWorld::createScene()));
});
restartItem->setScale(0.1f);
restartItem->setPosition(winSize.width / 2, winSize.height * 0.4f);
Menu *menu = Menu::createWithItem(restartItem);
menu->setPosition(Point::ZERO);
this->addChild(menu);
restartItem->runAction(ScaleTo::create(0.5f, 1.0f));
label->runAction(ScaleTo::create(0.5f, 1.0f));
}
示例3: createWithNumber
BallSprite* BallSprite::createWithNumber(kBallNumber number)
{
BallSprite *ballSprite = new BallSprite();
ballSprite->setNumber(number);
if(ballSprite && ballSprite->initWithFile(PNG_BALL))
{
//ボールの数字をラベルとして付ける
const char* numberString = CCString::createWithFormat("%d", number)->getCString();
LabelBMFont* numberLabel = CCLabelBMFont::create(numberString, FONT_NUMBER);
numberLabel->setPosition(Point(ballSprite->getContentSize().width / 2,ballSprite->getContentSize().height / 2));
numberLabel->setScale(1.8);
ballSprite->addChild(numberLabel, kZOrderNumber, kTagNumber);
//ボールのメモリを自動消去
ballSprite->autorelease();
//作ったSpriteを返す
return ballSprite;
} else {
CC_SAFE_DELETE(ballSprite);
return nullptr;
}
}