本文整理汇总了C++中LayerColor::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ LayerColor::setPosition方法的具体用法?C++ LayerColor::setPosition怎么用?C++ LayerColor::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayerColor
的用法示例。
在下文中一共展示了LayerColor::setPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool SnakeLayer::init()
{
maximumLength = 100;
itemsPicked = 0;
score = 0;
bonus = 0;
direction = Point::ZERO;
speed = 180;
LayerColor* lc = LayerColor::create(Color4B(0, 0, 0, 210), PX(1.0f), PY(0.8f));
lc->setPosition(CP(0.5f, 0.5f));
lc->setAnchorPoint(Point(0.5f, 0.5f));
lc->ignoreAnchorPointForPosition(false);
addChild(lc);
bounds = lc->getBoundingBox();
LayerColor* scorebg = LayerColor::create(Color4B::BLACK, PX(1.0f), PY(0.1f));
scorebg->setPosition(Point::ZERO);
addChild(scorebg);
addChild(lineGroup = Node::create());
addChild(bonusGroup = Node::create());
addChild(itemGroup = Node::create());
LineNode* line = LineNode::create(CP(0.5f, 0.5f), CP(0.5f, 0.5f));
lineGroup->addChild(line);
schedule(schedule_selector(SnakeLayer::considerSpawningBonus), 5.0f);
scheduleUpdate();
lblScore = Label::createWithTTF(LS("ScoreColon") + " 0", NORMAL_TTF, 42.0f);
lblScore->setColor(Color3B::WHITE);
lblScore->setPosition(CP(0.5f, 0.05f));
//lblScore->enableGlow(Color4B::BLACK);
//lblScore->enableShadow(Color4B::BLACK, Size::ZERO, 4);
addChild(lblScore);
string instruction = LS("SNAKE_INSTRUCTIONS");
lblInstruction = Label::createWithTTF(instruction, NORMAL_TTF, 48.0f);
lblInstruction->setPosition(CP(0.5f, 0.5f));
lblInstruction->setHorizontalAlignment(TextHAlignment::CENTER);
lblInstruction->setColor(Color3B::WHITE);
lblInstruction->enableGlow(Color4B::RED);
lblInstruction->runAction(RepeatForever::create(
Sequence::createWithTwoActions(ScaleTo::create(1.0f, 1.1f),
ScaleTo::create(1.0f, 1.0f))));
addChild(lblInstruction);
instructionVisible = true;
return true;
}
示例2: createLayer
LayerColor* GameLayer::createLayer(const Size& size, Color4B color, Vec2 position){
LayerColor* layerColor = LayerColor::create(color, size.width, size.height);
layerColor->setAnchorPoint(Vec2(0.5, 0.5));
layerColor->ignoreAnchorPointForPosition(false);
layerColor->setPosition(position);
return layerColor;
}
示例3: init
bool SkillTableView::init()
{
if (!Node::init())
return false;
LayerColor* bg = LayerColor::create(Color4B(255, 255, 255, 127), 450, 500);
bg->setPosition(bg->getContentSize()/-2);
this->addChild(bg, -1);
CCLabelTTF* title = CCLabelTTF::create("技能列表", "fonts/Marker Felt.ttf", 40);
title->setPosition(Point(bg->getContentSize().width/2, bg->getContentSize().height-30));
bg->addChild(title);
ControlButton* button = ControlButton::create(Scale9Sprite::create("ui/closed_normal.png"));
button->setBackgroundSpriteForState(Scale9Sprite::create("ui/closed_selected.png"), Control::State::HIGH_LIGHTED);
button->setPreferredSize(Size(57, 58));
button->setPosition(ccpSub(ccpAdd(bg->getPosition(), bg->getContentSize()), button->getContentSize()/2));
this->addChild(button);
button->addTargetWithActionForControlEvents(GAME_UILAYER, cccontrol_selector(GameInfoUIController::removeSmallMenuAndButton), Control::EventType::TOUCH_UP_INSIDE);
// button->setTouchPriority(0);
m_skillTableView = TableView::create(this, Size(420, 420));
m_skillTableView->setPosition(Point(15, 15));
// m_skillTableView->setDirection(kCCScrollViewDirectionVertical);
m_skillTableView->setDelegate(this);
// m_skillTableView->setVerticalFillOrder(kCCTableViewFillTopDown);
bg->addChild(m_skillTableView);
m_skillTableView->reloadData();
return true;
}
示例4: testColor
void TDDHelperTest::testColor(Ref *sender)
{
LayerColor *layer;
float width = 100;
float height = 100;
float x = 5;
float y = 50;
const int numColor = 5;
Color3B colors[numColor] = {
TDD_COLOR_BLACK,
TDD_COLOR_WHITE,
TDD_COLOR_BLUE1,
TDD_COLOR_BLUE2,
TDD_COLOR_GREEN1,
};
// layer = LayerColor::create
for(int i=0; i<numColor; i++) {
Color3B color3B = colors[i];
Color4B color = Color4B(color3B);
layer = LayerColor::create(color, width, height);
layer->setPosition(x, y);
addChild(layer);
x += width;
}
}
示例5: initFondoTemp
void Ajustes::initFondoTemp(){
LayerColor *capaFondo = LayerColor::create(Color4B(25,78,121,255), visibleSize.width, visibleSize.height);
capaFondo->setPosition(0,0);
this->addChild(capaFondo,-1);
fondoTemp = Sprite::create("mostrosity_dientes_d.png");
fondoTemp->setScale(escala);
fondoTemp->setAnchorPoint(Vec2(0,0.5));
fondoTemp->setPosition(visibleSize.width/2,visibleSize.height/2);
this->addChild(fondoTemp);
fondoTemp = Sprite::create("mostrosity_dientes_d.png");
fondoTemp->setScale(escala);
fondoTemp->setAnchorPoint(Vec2(1,0.5));
fondoTemp->setPosition(visibleSize.width/2,visibleSize.height/2);
this->addChild(fondoTemp);
altoIndividalCuadroJuego = visibleSize.height-((espacioBordesCuadro*2*escala));
anchoIndividualCuadroJuego = anchoNoLateralCE-(espacioBordesCuadro*2*escala);
cuadroJuego = LayerGradient::create(Color4B(174,209,240,255),Color4B(174,209,240,255));
cuadroJuego->setContentSize(Size(anchoIndividualCuadroJuego,altoIndividalCuadroJuego));
cuadroJuego->setPosition(anchoLateralCE+(espacioBordesCuadro*escala),(espacioBordesCuadro*escala));
cuadroJuego->setZOrder(1);
this->addChild(cuadroJuego);
}
示例6: init
bool StageLayer::init()
{
LayerColor* shadow = LayerColor::create(Color4B(0,0,0,128));
shadow->setPosition(-540,-960);
this->addChild(shadow,-2);
bg = Sprite::create("dialog_background.png");
bg->setPositionY(100);
this->addChild(bg);
auto title = Sprite::create("situ_title.png");
title->setPositionY(350);
this->addChild(title);
list = MyListView::create();
list->stagelayer = this;
for(int i=0;i<20;i++)
{
char str[100];
sprintf(str,"scoll%d",i+1);
list->add_option(StringData::getInstance()->get_string(str));
}
list->page = -1;
this->addChild(list);
back_btn = Sprite::create("chess_go_back.png");
back_btn->setPosition(-2600,350);
this->addChild(back_btn);
this->setPosition(540,960);
auto dispatcher = Director::getInstance()->getEventDispatcher();
auto touchListener = EventListenerTouchOneByOne::create();
touchListener->setSwallowTouches(true);
touchListener->onTouchBegan = CC_CALLBACK_2(StageLayer::onTouchBegan,this);
touchListener->onTouchMoved = CC_CALLBACK_2(StageLayer::onTouchMoved,this);
touchListener->onTouchEnded = CC_CALLBACK_2(StageLayer::onTouchEnded, this);
dispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
auto keyListener = EventListenerKeyboard::create();
keyListener->onKeyReleased = CC_CALLBACK_2(StageLayer::onKeyReleased, this);
dispatcher->addEventListenerWithSceneGraphPriority(keyListener, this);
return true;
}
示例7: createBottomBar
//TODO 屏蔽事件穿透
void BattleScene::createBottomBar()
{
LayerColor *bottom = LayerColor::create(Color4B(0, 0, 100, 100));
bottom->setContentSize(Size(WINSIZE.width, 120));
bottom->setPosition(Point(0, 0));
addChild(bottom);
int totalCount = 11;
int index = 0;
Vector<MenuItem *> items;
auto soldierInCamp = BattleData::getInstance()->getAttackSoldierInCamp();
map<int, vector<DSoldier *>>::iterator it;
for(it=soldierInCamp.begin(); it!=soldierInCamp.end(); it++)
{
MenuItemImage *item = MenuItemImage::create("ui/616.0.png", "ui/617.0.png", "ui/618.0.png", CC_CALLBACK_1(BattleScene::selectArmy, this));
item->setTag(it->first);
items.pushBack(item);
index++;
//head
Size size = item->getContentSize();
char img[20];
sprintf(img, "ui/%d.png", it->first / 100);
auto head = Sprite::create(img);
head->setAnchorPoint(Point(0.5, 0.5));
head->setPosition(size.width/2, size.height/2);
item->addChild(head);
char text[20];
sprintf(text, "X %d", it->second.size());
TTFConfig config("fonts/tahoma.ttf",16);
auto count = Label::createWithTTF(config, text, TextHAlignment::LEFT);
count->setPosition(size.width/2, size.height - count->getContentSize().height);
item->addChild(count);
//初始化为第一个兵种
if (m_selectedSoldierType <= 0)
{
m_selectedSoldierType = it->first;
}
}
for (int i = index; i < totalCount; i++)
{
MenuItemImage *item = MenuItemImage::create("ui/616.0.png", "ui/617.0.png", "ui/618.0.png", CC_CALLBACK_1(BattleScene::selectArmy, this));
item->setEnabled(false);
items.pushBack(item);
}
Size bottomSize = bottom->getContentSize();
Sprite *spItem = Sprite::create("ui/618.0.png");
Size itemSize = spItem->getContentSize();
float padding = (bottomSize.width - itemSize.width * totalCount) / (totalCount + 1);
UIRadioButton *radio = UIRadioButton::createWithArray(items);
radio->alignItemsHorizontallyWithPadding(padding);
radio->setPosition(Point(bottomSize.width / 2, bottomSize.height / 2));
radio->setSelectedIndex(0);
bottom->addChild(radio);
}
示例8: createBackgroundTile
LayerColor* GameLayer::createBackgroundTile(float x, float y, Size size, Color4B color) {
LayerColor* layerColor = LayerColor::create(color, size.width, size.height);
layerColor->ignoreAnchorPointForPosition(false);
layerColor->setAnchorPoint(Vec2(0.5, 0.5));
layerColor->setPosition(getTilePosition(x, y));
return layerColor;
}
示例9: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
/**/
// add "HelloWorld" splash screen"
auto sprite = Sprite::create("bkq.png");
// position the sprite on the center of the screen
sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
// add the sprite as a child to this layer
// this->addChild(sprite, 0);
sprite->setTag(1024);
//scheduleUpdate();
//schedule(schedule_selector(HelloWorld::updateTest), 1.0f, kRepeatForever,5.0f);
/**/
//color4b rgbA LayerColorĬÈÏêµã0,0
LayerColor* redLayer = LayerColor::create(Color4B(255, 0, 0, 255), visibleSize.width / 2, visibleSize.height / 2);
redLayer->ignoreAnchorPointForPosition(false);
redLayer->setPosition(visibleSize / 2);
redLayer->setAnchorPoint(Vec2(0.5, 0.5));
this->addChild(redLayer);
LayerColor* blueLayer = LayerColor::create(Color4B(0, 0, 255, 255), visibleSize.width / 6, visibleSize.height / 6);
blueLayer->ignoreAnchorPointForPosition(false);
blueLayer->setAnchorPoint(Vec2(1, 1));
redLayer->addChild(blueLayer);
/*
DrawNode * rect = DrawNode::create();
addChild(rect);
rect->setZOrder(10);
rect->drawSolidRect(Vec2(100,100),Vec2(300,300),Color4F(1,0,0,1));
DrawNode * rect2 = DrawNode::create();
addChild(rect2);
rect2->drawSolidRect(Vec2(150, 150), Vec2(350, 350), Color4F(0, 1, 0, 1));
DrawNode * rect3 = DrawNode::create();
addChild(rect3);
rect3->drawSolidRect(Vec2(200, 200), Vec2(400, 400), Color4F(0, 0, 1, 1));
*/
return true;
}
示例10: createNumCard
void Game2048::initUI()
{
//scene -> gameLayer -> root / uiNode
LayerColor *gameLayer = LayerColor::create(Color4B(0xff, 0xff, 0xf0, 0xff));
this->addChild(gameLayer);
Node *root = Node::create();
gameLayer->addChild(root);
Node *uiNode = Node::create();
gameLayer->addChild(uiNode);
lblScore = Label::createWithTTF("", "fonts/Marker Felt.ttf", 24);
lblScore->setPosition(Vec2(DISPLAY_CX, DISPLAY_HEIGHT * 4 / 5));
uiNode->addChild(lblScore);
//root -> bg
bgSize = DISPLAY_WIDTH - offsetW;
LayerColor *bgLayer = LayerColor::create(Color4B(0xcd, 0xba, 0x96, 0xff), bgSize, bgSize);
bgLayer->setPosition(Point(DISPLAY_CX,DISPLAY_CY));
bgLayer->setAnchorPoint(Point(0.5, 0.5));
bgLayer->ignoreAnchorPointForPosition(false);
root->addChild(bgLayer);
//NumNode
numSize = (bgSize - offsetW) / s_row ;
for (int i = 0; i < s_row; i++)
{
for (int j = 0; j < s_row; j++)
{
int numberX = numSize*(i+0.5) + DISPLAY_CX - bgSize/2 + offsetW/2 ;
int numberY = numSize*(j+0.5) + DISPLAY_CY - bgSize/2 + offsetW/2;
Node *numNode = Node::create();
numNode->setPosition(Point(numberX, numberY));
root->addChild(numNode);
//bg
LayerColor *numBg = LayerColor::create(Color4B(200, 190, 180, 0xff), numSize-offsetW/2, numSize-offsetW/2);
numBg->setAnchorPoint(Point(0.5, 0.5));
numBg->ignoreAnchorPointForPosition(false);
numNode->addChild(numBg);
//card
cardNumbers[i][j] = 0;
Node *cardNode = createNumCard(cardNumbers[i][j]);
cardNodes[i][j] = cardNode;
numNode->addChild(cardNode);
}
}
randomCreateNum();
randomCreateNum();
}
示例11: setupHeader
void TDDSubMenu::setupHeader(const Color4B &headerColor)
{
GLfloat parentH = this->getContentSize().height;
GLfloat width = this->getContentSize().width;
GLfloat height = kHeaderHeight;
LayerColor *headerLayer = LayerColor::create(headerColor, width, height);
Point pos = Point(0, parentH - height);
headerLayer->setPosition(pos);
this->addChild(headerLayer);
// Setting Buttons
float scale = TDDHelper::getBestScale();
// Size screenSize = TDDHelper::getScreenSize();
int midY = height/2;
int buttonW = (int)(scale * 50);
int buttonH = height;
int leftButtonX = buttonW / 2;
int rightButtonX = width - leftButtonX;
int midX = width/2;
Size size = Size(buttonW, buttonH);
ControlButton *button;
pos.x = leftButtonX;
pos.y = midY;
button = createButton("back", kActionTagBack, pos, size);
headerLayer->addChild(button);
mBackButton = button;
pos.x = rightButtonX;
pos.y = midY;
button = createButton("hide", kActionTagToggle, pos, size);
headerLayer->addChild(button);
button->addTargetWithActionForControlEvents(this,
cccontrol_selector(TDDSubMenu::touchUpInsideAction),
Control::EventType::TOUCH_UP_INSIDE);
mToggleButton = button;
// Label
Label *title = Label::createWithSystemFont("MENU", "Arial", 15);
title->setColor(Color3B::WHITE);
title->setPosition(Point(midX, midY));
headerLayer->addChild(title);
//
mHeaderLayer = headerLayer;
}
示例12: initTitulo
void Ajustes::initTitulo(){
LayerColor *capaPosTitulo = LayerColor::create(Color4B(23, 70, 108, 210), cuadroJuego->getContentSize().width-(espacioBordesCuadro*escala*2), 200*escala);
capaPosTitulo->setAnchorPoint(Vec2(0,1));
capaPosTitulo->setPosition(anchoLateralCE+(espacioSuperiorBtAtras*escala),visibleSize.height-(200*escala)-(espacioSuperiorBtAtras*escala));
capaPosTitulo->setZOrder(1);
this->addChild(capaPosTitulo);
tituloEscena = CCLabelTTF::create(LanguageManager::getInstance()->getString("AjustesLbTitulo"), "HVD_Comic_Serif_Pro.ttf", 130*escala,CCSizeMake(anchoNoLateralCE, capaPosTitulo->getContentSize().height), TextHAlignment::CENTER);
tituloEscena->setColor(Color3B(216,254,51));
tituloEscena->setVerticalAlignment(TextVAlignment::CENTER);
tituloEscena->setAnchorPoint(Vec2(0, 0));
tituloEscena->setPosition(anchoLateralCE,capaPosTitulo->getPositionY());
tituloEscena->setZOrder(10);
this->addChild(tituloEscena, 1);
tituloEscena->retain();
}
示例13: addHorizontalGrids
void TTTBoard::addHorizontalGrids()
{
Color4B color = TTT_LINE_COLOR;
int numLine = mGrid - 1;
float lineThick = 6;
float lineWidth = getContentSize().width;
float y = (mGridSize - lineThick/2);
Point pos = Point(0, y);
for(int i=0; i<numLine; i++) {
LayerColor *line = LayerColor::create(color, lineWidth, lineThick);
line->setPosition(pos);
addChild(line);
pos.y += mGridSize;
}
}
示例14: addVerticalGrids
void TTTBoard::addVerticalGrids()
{
Color4B color = TTT_LINE_COLOR;
int numLine = mGrid - 1;
float lineThick = 6;
float lineHeight = getContentSize().height;
float x = (mGridSize - lineThick/2);
Point pos = Point(x, 0);
for(int i=0; i<numLine; i++) {
LayerColor *line = LayerColor::create(color, lineThick, lineHeight);
line->setPosition(pos);
addChild(line);
pos.x += mGridSize;
}
}
示例15: addChild
// on "init" you need to initialize your instance
bool Bug914Layer::init()
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super" return value
if (BugsTestBaseLayer::init())
{
auto listener = EventListenerTouchAllAtOnce::create();
listener->onTouchesBegan = CC_CALLBACK_2(Bug914Layer::onTouchesBegan, this);
listener->onTouchesMoved = CC_CALLBACK_2(Bug914Layer::onTouchesMoved, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
// ask director the the window size
auto size = Director::getInstance()->getWinSize();
LayerColor *layer;
for( int i=0;i < 5;i++)
{
layer = LayerColor::create(Color4B(i*20, i*20, i*20,255));
layer->setContentSize(Size(i*100, i*100));
layer->setPosition(Vec2(size.width/2, size.height/2));
layer->setAnchorPoint(Vec2(0.5f, 0.5f));
layer->ignoreAnchorPointForPosition(false);
addChild(layer, -1-i);
}
// create and initialize a Label
auto label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 64.0f);
auto item1 = MenuItemFont::create("restart", CC_CALLBACK_1(Bug914Layer::restart, this));
auto menu = Menu::create(item1, nullptr);
menu->alignItemsVertically();
menu->setPosition(Vec2(size.width/2, 100));
addChild(menu);
// position the label on the center of the screen
label->setPosition(Vec2( size.width /2 , size.height/2 ));
// add the label as a child to this Layer
addChild(label);
return true;
}
return false;
}