本文整理汇总了C++中DrawNode::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ DrawNode::getPosition方法的具体用法?C++ DrawNode::getPosition怎么用?C++ DrawNode::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DrawNode
的用法示例。
在下文中一共展示了DrawNode::getPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addMapBg
void GameLayer::addMapBg()
{
float width = _visibleSize.width;
DrawNode *mapBg = DrawNode::create();
mapBg->drawSolidRect( Vec2::ZERO , Vec2(width, width), Color4F(Color3B(190,173,158)));
mapBg->setAnchorPoint(Vec2::ZERO);
this->addChild(mapBg);
Vec2 mapOrigin = mapBg->getPosition();
float gap = width/33;
float tileWidth = (width-5*gap)/4;
g_tileSize = tileWidth;
g_mapBg = mapBg;
g_gap = gap;
for(int i = 0; i < MAP_SIZE; i++)
{
for(int j = 0; j < MAP_SIZE; j++)
{
DrawNode* tileBg = DrawNode::create();
tileBg->drawSolidRect(Vec2::ZERO, Vec2(tileWidth, tileWidth) , Color4F( Color3B(208,193,179) ));
tileBg->setPositionX((j+1)*gap+ j*tileWidth);
tileBg->setPositionY((i+1)*gap+ i*tileWidth);
_map->setTilePos(3-i, j, tileBg->getPosition() + Vec2(g_tileSize/2 , g_tileSize/2));
mapBg->addChild(tileBg);
}
}
_map->initStart2();
}
示例2: addScore
void GameLayer::addScore()
{
// label2048
Label *_2048 = Label::createWithTTF("2048", "fonts/ClearSans-Bold.ttf", _visibleSize.width/5.9);
_2048->setColor(Color3B(121,110,100) );
_2048->setAnchorPoint(Vec2( 0, 0.5 ));
_2048->setPosition(Vec2( 0, _visibleSize.height-_2048->getContentSize().height/2) );
this->addChild(_2048);
// best score
DrawNode *bestscoreback = DrawNode::create();
bestscoreback->drawSolidRect( Vec2(-_visibleSize.width/6 ,-g_tileSize/3), Vec2(_visibleSize.width/6 ,g_tileSize/3), Color4F(Color3B(190,173,158)) );
bestscoreback->setPosition( Vec2(_visibleSize.width - _visibleSize.width/6-10 , _2048->getPositionY()-10 ) );
this->addChild(bestscoreback);
Label *best = Label::createWithTTF("BEST", "fonts/ClearSans-Bold.ttf", _visibleSize.width/25);
best->setColor(Color3B(240,228,216));
best->setPositionY(g_tileSize/6.5 );
bestscoreback->addChild(best);
sprintf(buff, "%d", Score::getInstance()->getTopScore());
bestscore = Label::createWithTTF(buff, "fonts/ClearSans-Bold.ttf", _visibleSize.width/15);
bestscore->setPositionY( -g_tileSize/7.5);
bestscoreback->addChild(bestscore);
//score
DrawNode *scoreback = DrawNode::create();
scoreback->drawSolidRect( Vec2(-_visibleSize.width/6 ,-g_tileSize/3), Vec2(_visibleSize.width/6 ,g_tileSize/3), Color4F(Color3B(190,173,158)) );
scoreback->setPosition( Vec2(_visibleSize.width - _visibleSize.width/6-10 , _2048->getPositionY() - g_tileSize/1 ) );
this->addChild(scoreback);
Label *sco = Label::createWithTTF("SCORE", "fonts/ClearSans-Bold.ttf", _visibleSize.width/25);
sco->setColor(Color3B(240,228,216));
sco->setPositionY(g_tileSize/6.5 );
scoreback->addChild(sco);
sprintf(buff, "%d", 0);
score = Label::createWithTTF(buff, "fonts/ClearSans-Bold.ttf", _visibleSize.width/15);
score->setPositionY( -g_tileSize/7.5);
scoreback->addChild(score);
// new game
DrawNode *newGame = DrawNode::create();
newGame->drawSolidRect( Vec2(-_visibleSize.width/6 ,-g_tileSize/4), Vec2(_visibleSize.width/6 ,g_tileSize/4), Color4F(Color3B(147,122,98)) );
newGame->setPosition( Vec2(_visibleSize.width/5.5 , _2048->getPositionY() - g_tileSize/1 ) );
this->addChild(newGame);
Label *ngame = Label::createWithTTF("New Game", "fonts/ClearSans-Bold.ttf", _visibleSize.width/17);
ngame->setColor(Color3B(250,246,241));
//newGame->addChild(ngame);
// ai
DrawNode *aiback = DrawNode::create();
aiback->drawSolidRect( Vec2(-_visibleSize.width/15 ,-g_tileSize/4), Vec2(_visibleSize.width/15 ,g_tileSize/4), Color4F(Color3B(147,122,98)) );
aiback->setPosition( Vec2(_visibleSize.width/2.3 , _2048->getPositionY() - g_tileSize/1 ) );
this->addChild(aiback);
Label *ai = Label::createWithTTF("AI", "fonts/ClearSans-Bold.ttf", _visibleSize.width/17);
ai->setColor(Color3B(250,246,241));
//aiback->addChild(ai);
MenuItemLabel *newgamelabel = MenuItemLabel::create(ngame, CC_CALLBACK_1(GameLayer::startNewGame, this));
newgamelabel->setPosition(newGame->getPosition());
ailable = MenuItemLabel::create(ai, CC_CALLBACK_1(GameLayer::startAi, this));
ailable->setPosition(aiback->getPosition());
Menu *menu = Menu::create(newgamelabel,ailable, NULL);
menu->setPosition(Vec2::ZERO);
this->addChild(menu);
}