本文整理汇总了C++中LabelTTF::getPositionY方法的典型用法代码示例。如果您正苦于以下问题:C++ LabelTTF::getPositionY方法的具体用法?C++ LabelTTF::getPositionY怎么用?C++ LabelTTF::getPositionY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LabelTTF
的用法示例。
在下文中一共展示了LabelTTF::getPositionY方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool GamePlay::init() {
if (!Layer::init()) {
return false;
}
gameState = Ready;
visibleSize = Director::getInstance()->getVisibleSize();
getSoundMusic();
//load game AI
//init array number and computation
int ARRAY_NUMBER[9] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
arrNum = gameAI->randomNumber(ARRAY_NUMBER, SUM_NUM);
for (int i = 0; i < SUM_NUM; i++) {
arrNUM[i] = arrNum[i];
}
char s[SUM_COM] = "";
//TODO change level
// arrCOM = gameAI->randomComputation(s, SUM_COM,
// GamePlay::instance()->getLevel() >= 2 ? 2 : 3);
arrCOM = gameAI->randomComputation(s, SUM_COM, 2);
for (int i = 0; i < SUM_COM; i++) {
arrCOMPUTATE[i] = arrCOM[i];
}
for (int i = 0; i < SUM_COM / 2; i++) {
tempResult[i] = INIT_FRAME;
}
int arr[GamePlay::instance()->getLevel()];
int* arrayLevel = gameAI->randomLessNumber(arr,
GamePlay::instance()->getLevel());
//load background
auto bg = Sprite::create("background.png");
bg->setAnchorPoint(Vec2(0, 0));
bg->setPosition(Vec2(0, 0));
this->addChild(bg, -1);
float rX = visibleSize.width / bg->getContentSize().width;
float rY = visibleSize.height / bg->getContentSize().height;
bg->setScaleX(rX);
bg->setScaleY(rY);
//show logo game
Sprite *logoGame = Sprite::create("smalllogo.png");
logoGame->setAnchorPoint(Vec2(0.0, 1.0));
logoGame->setPosition(Vec2(PADDING, visibleSize.height - PADDING));
logoGame->setTag(TAG_LOGO);
logoGame->setScale(0.6f);
this->addChild(logoGame);
//load frame ready
float baseY = logoGame->getPositionY()
- logoGame->getBoundingBox().size.height - PADDING;
float baseX = PADDING / 2;
for (int i = 0; i < SUM_NUM; i++) {
frameReady[i] = Sprite::create("frame.png");
float width = frameReady[i]->getContentSize().width;
float height = frameReady[i]->getContentSize().height;
frameReady[i]->setTag(TAG_START_READY_POINT + i);
frameReady[i]->setPositionX(baseX + 5.0 / 8.0 * i * width + width / 2);
if (i % 2 == 0) {
frameReady[i]->setPositionY(baseY - height / 2);
} else {
frameReady[i]->setPositionY(baseY - height);
}
this->addChild(frameReady[i]);
}
//create frame play
float paddingY = 0;
float paddingX = 0;
for (int i = 0; i < SUM_NUM; i++) {
float baseX = PADDING;
framePlay[i] = TouchSprite::create("frame.png");
framePlay[i]->setTag(TAG_FRAME_PLAY + i);
paddingX = (visibleSize.width - PADDING * 4
- framePlay[i]->getContentSize().width) / 3.0;
framePlay[i]->setPositionX(
PADDING + framePlay[i]->getContentSize().width / 2
+ 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]);
//.........这里部分代码省略.........
示例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);
}