本文整理汇总了C++中LabelTTF::setPositionY方法的典型用法代码示例。如果您正苦于以下问题:C++ LabelTTF::setPositionY方法的具体用法?C++ LabelTTF::setPositionY怎么用?C++ LabelTTF::setPositionY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LabelTTF
的用法示例。
在下文中一共展示了LabelTTF::setPositionY方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gameOver
void GamePlay::gameOver(float dt) {
// Director::getInstance()->pause();
gameState = End;
//invisible frame ready
if (frameReady != NULL) {
for (int i = 0; i < SUM_NUM; i++)
frameReady[i]->setVisible(false);
}
boardWin = Sprite::create("board.png");
boardWin->setPosition(Vec2(-visibleSize.width / 4, visibleSize.height / 2));
boardWin->setZOrder(30);
this->addChild(boardWin);
float haflHeight = boardWin->getContentSize().height / 2;
float haflWidth = boardWin->getContentSize().width / 2;
auto jumpto = JumpTo::create(0.5,
Vec2(visibleSize.width / 2, visibleSize.height / 2 - 3 * PADDING),
PADDING * 3, 4);
boardWin->runAction(jumpto);
updatehightestRecord();
if (onSound)
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(
"sound/music_win.ogg");
//congratulation
Sprite* congratulation = Sprite::create("congratulation.png");
congratulation->setPosition(
Vec2(haflWidth,
haflHeight * 2 - 3 * PADDING
- congratulation->getContentSize().height));
congratulation->setZOrder(40);
boardWin->addChild(congratulation);
//highscore
Sprite* newhighscore = Sprite::create("newhighscore.png");
newhighscore->setPosition(
Vec2(haflWidth,
congratulation->getPositionY()
- congratulation->getContentSize().height / 2
- newhighscore->getContentSize().height / 2
- 2 * PADDING));
newhighscore->setZOrder(40);
boardWin->addChild(newhighscore);
//TODO
if (timeplay > 0)
NativeUtils::submitScore(
getLeaderBoard(GamePlay::instance()->getLevel()),
timeplay * 1000);
if (timeplay > highScore) {
newhighscore->setVisible(false);
} else {
newhighscore->setVisible(true);
}
//gameover text
Sprite* gameovertext = Sprite::create("gameovertext.png");
gameovertext->setPosition(
Vec2(4 * PADDING + gameovertext->getContentSize().width / 2,
newhighscore->getPositionY()
- newhighscore->getContentSize().height / 2
- gameovertext->getContentSize().height / 2
- 2 * PADDING));
gameovertext->setZOrder(40);
boardWin->addChild(gameovertext);
float sizewidth = gameovertext->getContentSize().width;
float sizeheight = gameovertext->getContentSize().height;
//show score
LabelTTF *currentscore = LabelTTF::create("00:00", "fonts/hlvgchac.ttf",
40);
currentscore->setZOrder(50);
currentscore->setColor(Color3B(Color3B::BLUE));
showTextTime(currentscore, timeplay);
currentscore->setPositionX(
sizewidth + PADDING + currentscore->getContentSize().width / 2);
currentscore->setPositionY(sizeheight / 2);
gameovertext->addChild(currentscore);
LabelTTF *highscore = LabelTTF::create("00:00", "fonts/hlvgchac.ttf", 40);
highscore->setZOrder(50);
highscore->setColor(Color3B(Color3B::BLUE));
showTextTime(highscore, highScore);
highscore->setPositionX(
sizewidth + PADDING + currentscore->getContentSize().width / 2);
highscore->setPositionY(highscore->getContentSize().height / 2);
gameovertext->addChild(highscore);
std::string miniModeSprite = getLevelString(
GamePlay::instance()->getLevel());
Sprite* miniMode = Sprite::create("mini" + miniModeSprite + ".png");
miniMode->setPosition(
Vec2(
haflWidth * 2 - miniMode->getContentSize().width / 2
- 3 * PADDING,
gameovertext->getPositionY()
+ miniMode->getContentSize().height / 2
+ 2 * PADDING));
//.........这里部分代码省略.........
示例2:
FailScene::FailScene(void)
{
Vec2 points[] = { Vec2(0, 0),
Vec2(0, 140),
Vec2(400, 140),
Vec2(400, 0) };
DrawNode* draw = DrawNode::create();
//±³¾°
draw->drawPolygon(points, 4, ColorUtil::getColor4F(0x00 , 0xAD , 0xFF, 0xFF),
0, ColorUtil::getColor4F(0x00, 0xDA, 0xFF, 0xFF));
this->addChild(draw);
draw->setAnchorPoint(Point(.5, .5));
draw->setPositionX(ScreenUtil::getCenter().x - 200);
draw->setPositionY(ScreenUtil::getCenter().y - 140);
Vec2 points2[] = { Vec2(0, 0),
Vec2(0, 150),
Vec2(230, 150),
Vec2(230, 0) };
DrawNode* draw2 = DrawNode::create();
//±³¾°
draw2->drawPolygon(points2, 4, ColorUtil::getColor4F(0x00 , 0xAD , 0xFF, 0xFF),
0, ColorUtil::getColor4F(0x00, 0xDA, 0xFF, 0xFF));
this->addChild(draw2);
draw2->setAnchorPoint(Point(.5, .5));
draw2->setPositionX(ScreenUtil::getCenter().x - 115);
draw2->setPositionY(ScreenUtil::getCenter().y + 40);
LabelTTF* scoreTxt = LabelTTF::create("Score:", "Arial", 45);
scoreTxt->setAnchorPoint(Point(0, .5));
scoreTxt->setPosition(Point(draw2->getPositionX() + 10,
draw2->getPositionY() + 110));
this->addChild(scoreTxt);
LabelTTF* bestScoreTxt = LabelTTF::create("Best:", "Arial", 45);
bestScoreTxt->setAnchorPoint(Point(0, .5));
bestScoreTxt->setPosition(Point(scoreTxt->getPositionX(),
draw2->getPositionY() + 50));
this->addChild(bestScoreTxt);
LabelTTF* scoreValTxt = LabelTTF::create("0", "Arial", 45);
scoreValTxt->setPositionX(scoreTxt->getPositionX() + scoreTxt->getContentSize().width + 25);
scoreValTxt->setPositionY(scoreTxt->getPositionY());
scoreValTxt->setTag(scoreValTxtTag);
this->addChild(scoreValTxt);
LabelTTF* bestScoreValTxt = LabelTTF::create("0", "Arial", 45);
bestScoreValTxt->setPositionX(scoreValTxt->getPositionX());
bestScoreValTxt->setPositionY(bestScoreTxt->getPositionY());
bestScoreValTxt->setTag(bestScoreValTxtTag);
this->addChild(bestScoreValTxt);
LabelTTF* replayTxt = LabelTTF::create("Replay", "Arial", 45);
MenuItemLabel* replayBtn = MenuItemLabel::create(replayTxt);
replayBtn->setTag(replayBtnTag);
LabelTTF* shareTxt = LabelTTF::create("Share", "Arial", 45);
MenuItemLabel* shareBtn = MenuItemLabel::create(shareTxt);
Menu* menu = Menu::create(replayBtn, shareBtn, NULL);
menu->setPositionX(ScreenUtil::getCenter().x);
menu->setPositionY(ScreenUtil::getCenter().y - 70);
menu->alignItemsHorizontallyWithPadding(50);
menu->setTag(menuTag);
this->addChild(menu);
}