本文整理汇总了C++中LabelTTF::getPositionX方法的典型用法代码示例。如果您正苦于以下问题:C++ LabelTTF::getPositionX方法的具体用法?C++ LabelTTF::getPositionX怎么用?C++ LabelTTF::getPositionX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LabelTTF
的用法示例。
在下文中一共展示了LabelTTF::getPositionX方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
//.........这里部分代码省略.........
+ paddingX * (i % 3));
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());
示例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);
}