本文整理汇总了C++中LabelTTF::setZOrder方法的典型用法代码示例。如果您正苦于以下问题:C++ LabelTTF::setZOrder方法的具体用法?C++ LabelTTF::setZOrder怎么用?C++ LabelTTF::setZOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LabelTTF
的用法示例。
在下文中一共展示了LabelTTF::setZOrder方法的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: init
//.........这里部分代码省略.........
float baseY = frameReady[0]->getPositionY();
if (i % 3 == 0)
paddingY = paddingX * ((int) i / 3 + 1);
framePlay[i]->setPositionY(baseY - paddingY);
framePlay[i]->score = 0;
framePlay[i]->isFixed = false;
for (int j = 0; j < GamePlay::instance()->getLevel(); j++) {
if (arrNum[i] == arrayLevel[j]) {
framePlay[i]->score = arrNum[i];
//TODO
framePlay[i]->isFixed = true;
framePlay[i]->setDisplayFrame(
SpriteFrame::create(
"frame" + std::to_string(arrNum[i]) + ".png",
framePlay[i]->getTextureRect()));
}
}
// CCLog("frameplay[%d] = %d", i, framePlay[i]->score);
this->addChild(framePlay[i]);
}
//load number button
//TODO
std::string name = "number";
MoveTo* actionBy;
int k = 0;
for (int i = 0; i < SUM_NUM; i++) {
numberBtn[i] = TouchSprite::create(
name + std::to_string(i + 1) + ".png");
numberBtn[i]->setTag(TAG_NUMBER + i);
numberBtn[i]->setPositionY(visibleSize.height + 3 * PADDING);
numberBtn[i]->setPositionX(frameReady[i]->getPositionX());
numberBtn[i]->setZOrder(10);
numberBtn[i]->isHidden = false;
this->addChild(numberBtn[i]);
actionBy = MoveTo::create(0.4, frameReady[i]->getPosition());
auto easeAction = EaseBounceInOut::create(actionBy);
for (int j = 0; j < GamePlay::instance()->getLevel(); j++) {
if ((i + 1) == arrayLevel[j]) {
numberBtn[i]->isHidden = true;
numberBtn[i]->setVisible(false);
}
}
if (numberBtn[i]->isHidden == false) {
auto delay = DelayTime::create(0.2 * (k + 1));
auto sequence = Sequence::create(delay, easeAction, nullptr);
numberBtn[i]->runAction(sequence);
k++;
}
}
if (frameReady != NULL) {
for (int i = 0; i < SUM_NUM; i++)
frameReady[i]->setVisible(false);
}
//create result frame and equal character
Sprite* frameEqual[SUM_COM / 2];
Sprite* characterEqual[SUM_COM / 2];
for (int i = 0; i < SUM_COM / 2; i++) {
characterEqual[i] = Sprite::create("icon_equal.png");
frameEqual[i] = Sprite::createWithTexture(frameReady[i]->getTexture());
frameEqual[i]->setTag(TAG_FRAME_EQUAL + i);