当前位置: 首页>>代码示例>>C++>>正文


C++ LabelTTF::setAnchorPoint方法代码示例

本文整理汇总了C++中LabelTTF::setAnchorPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ LabelTTF::setAnchorPoint方法的具体用法?C++ LabelTTF::setAnchorPoint怎么用?C++ LabelTTF::setAnchorPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LabelTTF的用法示例。


在下文中一共展示了LabelTTF::setAnchorPoint方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createRow

Node* TopRankScene::createRow(int rank, int score, std::string name){

	Node* row = Node::create();

	Size visibleSize = Director::getInstance()->getVisibleSize();

	char _rank[2];
	itoa(rank, _rank, 10);
	LabelTTF* labelRank = LabelTTF::create(_rank, "AppleGothic", 20);
	char _score[10];
	itoa(score, _score, 10);
	LabelTTF* labelScore = LabelTTF::create(_score, "AppleGothic", 20); 
	LabelTTF* labelName = LabelTTF::create(name, "AppleGothic", 20);


	labelRank->setAnchorPoint(Point(0, 0));
	labelRank->setPosition(visibleSize.width / 4 + 10, visibleSize.height / 20 * (5 - rank) + 10);
	labelScore->setAnchorPoint(Point(0, 0));
	labelScore->setPosition(visibleSize.width / 4 * 3 + 10, visibleSize.height / 20 * (5 - rank) + 10);
	labelName->setAnchorPoint(Point(0, 0));
	labelName->setPosition(visibleSize.width / 4 * 2 + 10, visibleSize.height / 20 * (5 - rank) + 10);

	row->addChild(labelName);
	row->addChild(labelRank);
	row->addChild(labelScore);

	row->setAnchorPoint(Point(0, 0));
	row->setPosition(0, visibleSize.height / 20 * (5 - rank));
	return row;
}
开发者ID:madxlover,项目名称:crazyShootGame,代码行数:30,代码来源:TopRankScene.cpp

示例2: createFirstRow

Node* TopRankScene::createFirstRow(){
	Node* row = Node::create();

	Size visibleSize = Director::getInstance()->getVisibleSize();

	
	LabelTTF* labelRank = LabelTTF::create("排名", "AppleGothic", 20);
	LabelTTF* labelScore = LabelTTF::create("分数", "AppleGothic", 20);
	LabelTTF* labelName = LabelTTF::create("姓名", "AppleGothic", 20);


	labelRank->setAnchorPoint(Point(0, 0));
	labelRank->setPosition(visibleSize.width / 4, visibleSize.height / 20 * 5 + 10);
	labelScore->setAnchorPoint(Point(0, 0));
	labelScore->setPosition(visibleSize.width / 4 * 3 + 10, visibleSize.height / 20 * 5  + 10);
	labelName->setAnchorPoint(Point(0, 0));
	labelName->setPosition(visibleSize.width / 4 * 2 + 10, visibleSize.height / 20 * 5 + 10);

	row->addChild(labelName);
	row->addChild(labelRank);
	row->addChild(labelScore);

	row->setAnchorPoint(Point(0, 0));
	row->setPosition(0, visibleSize.height / 20 * 5+ 10);
	return row;
}
开发者ID:madxlover,项目名称:crazyShootGame,代码行数:26,代码来源:TopRankScene.cpp

示例3: setChatVector

void ChatLayer::setChatVector(std::vector<std::string> textVector ,
                   std::vector<std::string> senderNameVector,std::vector<int> senderId) {
    
    std::reverse(textVector.begin(), textVector.end());
    std::reverse(senderNameVector.begin(), senderNameVector.end());
    std::reverse(senderId.begin(), senderId.end());
    
    this->textVector = textVector;
    this->senderNameVector = senderNameVector;
    this->senderId = senderId;
    int i = 0;

    CCLOG("__________ Message __________");
    
    for (std::vector<std::string>::iterator it = this->textVector.begin() ; it != this->textVector.end(); ++it) {
        
        std::string message;
        LabelTTF* searchLabel = NULL;
        int count = 0;
        
        if (this->senderId.at(i) == UserDefault::getInstance()->getIntegerForKey("Player_ID")) {
            message = "Me: " + this->textVector.at(i);
            
            count = (message.length()/CHARACTER_IN_LINE)+1;
            searchLabel = LabelTTF::create(message.c_str(), "helvetica", 24,Size(275,LINE_HEIGHT*count), TextHAlignment::LEFT,TextVAlignment::TOP);
            searchLabel->setAnchorPoint(Point(0,1));
            searchLabel->setPosition(10,700 - (numberOfLines * LINE_HEIGHT) - (numberOfMessages * LINE_HEIGHT/2));
        }
        else {
            message = this->senderNameVector.at(i) + ": "+ this->textVector.at(i);
            
            count = (message.length()/CHARACTER_IN_LINE)+1;
            searchLabel = LabelTTF::create(message.c_str(), "helvetica", 24,Size(275,LINE_HEIGHT*count), TextHAlignment::LEFT,TextVAlignment::TOP);
            searchLabel->setAnchorPoint(Point(0,1));
            searchLabel->setPosition(10,700 - (numberOfLines * LINE_HEIGHT) - (numberOfMessages * LINE_HEIGHT/2));
        }
        
        searchLabel->setColor(Color3B(255, 0, 0));
        chatNode->addChild(searchLabel);
        
        numberOfLines = numberOfLines + count;
        numberOfMessages = numberOfMessages + 1;
        
        CCLOG("Count :: %d Message :: %s",count,message.c_str());

        i++;
    }
    
    stopWaitingAnim();
}
开发者ID:MishMick,项目名称:Scrabble,代码行数:50,代码来源:ChatLayer.cpp

示例4: tableCellAtIndex

TableViewCell* TableViewTestLayer::tableCellAtIndex(TableView *table, unsigned int idx)
{
    String *string = String::createWithFormat("%d", idx);
    TableViewCell *cell = table->dequeueCell();
    if (!cell) {
        cell = new CustomTableViewCell();
        cell->autorelease();
        Sprite *sprite = Sprite::create("Images/Icon.png");
        sprite->setAnchorPoint(Point::ZERO);
        sprite->setPosition(Point(0, 0));
        cell->addChild(sprite);

        LabelTTF *label = LabelTTF::create(string->getCString(), "Helvetica", 20.0);
        label->setPosition(Point::ZERO);
		label->setAnchorPoint(Point::ZERO);
        label->setTag(123);
        cell->addChild(label);
    }
    else
    {
        LabelTTF *label = (LabelTTF*)cell->getChildByTag(123);
        label->setString(string->getCString());
    }


    return cell;
}
开发者ID:aberaud,项目名称:cocos2d-x,代码行数:27,代码来源:TableViewTestScene.cpp

示例5: standardButtonWithTitle

ControlButton* standardButtonWithTitle( const char * bgname, const char * bgseledname, const char * title){

	//Creates and return a button with a default background and title color.
//    Scale9Sprite *backgroundButton = Scale9Sprite::create(bgname);//按下前
//    Scale9Sprite *backgroundHighlightedButton = Scale9Sprite::create(bgseledname);//按下后
	

	ControlButton* btn = ControlButton::create();
	btn->setPreferredSize(Size(522, 88));

	Scale9Sprite*	normal = Scale9Sprite::create(bgname);
	Scale9Sprite*	select = Scale9Sprite::create(bgseledname);
	Scale9Sprite* hightlight = Scale9Sprite::create(bgseledname);
	Scale9Sprite* disable = Scale9Sprite::create(bgname);
	
	btn->setBackgroundSpriteForState(normal, Control::State::NORMAL);
	btn->setBackgroundSpriteForState(select, Control::State::SELECTED);
	btn->setBackgroundSpriteForState(hightlight, Control::State::HIGH_LIGHTED);
	btn->setBackgroundSpriteForState(disable, Control::State::DISABLED);
	
	
    LabelTTF *titleButton = LabelTTF::create(title, "AmericanTypewriter", 30);//添加文字
	titleButton->setAnchorPoint(Point(0.5f, 0.5f));
	titleButton->setPosition(Point(btn->getContentSize().width/2, btn->getContentSize().height/2));
	titleButton->setColor(Color3B::BLACK);//设置文字点击前的颜色
	titleButton->setTag(1000);
	btn->addChild(titleButton);

    return btn;
}
开发者ID:jiangchao1987,项目名称:crazyvideo,代码行数:30,代码来源:Tools.cpp

示例6: onEnter

void TestUseMutiplePicture::onEnter()
{
    ArmatureTestLayer::onEnter();
    setTouchEnabled(true);

    displayIndex = 0;

    armature = Armature::create("Knight_f/Knight");
    armature->getAnimation()->playByIndex(0);
    armature->setPosition(Point(VisibleRect::center().x, VisibleRect::left().y));
    armature->setScale(1.2f);
    addChild(armature);

    std::string weapon[] = {"weapon_f-sword.png", "weapon_f-sword2.png", "weapon_f-sword3.png", "weapon_f-sword4.png", "weapon_f-sword5.png", "weapon_f-knife.png", "weapon_f-hammer.png"};

    for (int i = 0; i < 7; i++)
    {
        Skin *skin = Skin::createWithSpriteFrameName(weapon[i].c_str());
        armature->getBone("weapon")->addDisplay(skin, i);
    }

    // 	CCSpriteDisplayData displayData;
    // 	for (int i = 0; i < 7; i++)
    // 	{
    // 		displayData.setParam(weapon[i].c_str());
    // 		armature->getBone("weapon")->addDisplay(&displayData, i);
    // 	}

    LabelTTF *l = LabelTTF::create("This is a weapon!", "Arial", 18);
    l->setAnchorPoint(Point(0.2f, 0.5f));
    armature->getBone("weapon")->addDisplay(l, 7);
}
开发者ID:csouls,项目名称:nyangame-v3,代码行数:32,代码来源:ArmatureScene.cpp

示例7: pintoPalabra

void Akuerdate::pintoPalabra(){
    
    LabelTTF *texto = CCLabelTTF::create(gProfesion->obtenerPalabraElemento(tagActual)->getCString(), "HVD_Comic_Serif_Pro.ttf",100,Size(panelPalabras->getContentSize().width-margenPanelPalabrasInterno,130), TextHAlignment::CENTER);
    texto->setColor(Color3B(228,70,106));
    texto->setVerticalAlignment(TextVAlignment::CENTER);
    texto->setAnchorPoint(Vec2(1,1));
    texto->setPosition(panelPalabras->getContentSize().width+margenPanelPalabrasInterno,panelPalabras->getContentSize().height-((panelPalabras->getChildrenCount()*(100+margenPanelPalabrasInterno))+(margenPanelPalabrasInterno*5)));
    //texto->setPosition(0,0);
    panelPalabras->addChild(texto);
    
}
开发者ID:si2info,项目名称:info.si2.mostrosity,代码行数:11,代码来源:Akuerdate.cpp

示例8: addMessageFromOpponent

void ChatLayer::addMessageFromOpponent(std::string message) {
    std::string msg = "Parth: " + message;
    LabelTTF* searchLabel = NULL;
    
    int count = (msg.length()/CHARACTER_IN_LINE)+1;
    
    searchLabel = LabelTTF::create(msg.c_str(), "helvetica", 24,Size(275,LINE_HEIGHT*count), TextHAlignment::LEFT,TextVAlignment::TOP);
    searchLabel->setAnchorPoint(Point(0,1));
    searchLabel->setPosition(10,700 - (numberOfLines * LINE_HEIGHT) - (numberOfMessages * LINE_HEIGHT/2));
    
    searchLabel->setColor(Color3B(255, 0, 0));
    chatNode->addChild(searchLabel);
    
    numberOfLines = numberOfLines + count;
    numberOfMessages = numberOfMessages + 1;
}
开发者ID:MishMick,项目名称:Scrabble,代码行数:16,代码来源:ChatLayer.cpp

示例9: tableCellAtIndex

TableViewCell* HelloWorld::tableCellAtIndex(cocos2d::extension::TableView *table, ssize_t idx){
    
    TableViewCell *cell = table->dequeueCell();
    LabelTTF *label;
    
    if(cell == NULL){
        cell = TableViewCell::create();
        label = LabelTTF::create();
        label->setTag(2);
        cell->addChild(label);
        label->setFontSize(30);
        label->setAnchorPoint(Point(0,0));
    }
    else {
        label = (LabelTTF*)cell->getChildByTag(2);
    }
    
    label->setString(StringUtils::format("Label %ld",idx));
    
    return cell;
};
开发者ID:rsrzrcj,项目名称:Cocos2dxLessons20150910,代码行数:21,代码来源:HelloWorldScene.cpp

示例10: setUpView

void PopUpBombLayer::setUpView(){
	Size winSize = Director::getInstance()->getWinSize();
    Point pCenter = Point(winSize.width / 2, winSize.height / 2);
	
	std::vector<std::string> imgs;
	imgs.push_back(std::string("play_dialog_bg.png"));//bg

	imgs.push_back(std::string("play_dialog_button_long.png")); //close b n
	imgs.push_back(std::string("play_dialog_button_long_selected.png")); //close b s
	
	bgLay = Layer::create();
	
	
	LabelTTF * tip = LabelTTF::create("提示", "AmericanTypewriter", 30);//添加文字
	tip->setAnchorPoint(Point(0.5f, 0.5f));
	tip->setColor(Color3B::YELLOW);
	tip->setPosition(Point(pCenter.x, pCenter.y + 40));
	bgLay->addChild(tip, 2);
	
	LabelTTF *label = LabelTTF::create("确认花费20枚金币,\n去掉一个错误答案么?", "AmericanTypewriter", 40);//添加文字
	label->setAnchorPoint(Point(0.5f, 0.5f));
	label->setColor(Color3B::WHITE);
	label->setPosition(Point(pCenter.x, pCenter.y - 60));
	bgLay->addChild(label, 2);
	

	Sprite* bg = Sprite::create( imgs.at(0));
	auto menuItem1 = MenuItemImage::create(
										   imgs.at(1),
										   imgs.at(2),
										   CC_CALLBACK_1(PopUpBombLayer::bombUse, this));
	auto menuItem2 = MenuItemImage::create(
										   imgs.at(1),
										   imgs.at(2),
										   CC_CALLBACK_1(PopUpBombLayer::bombNotUse, this));
	
	bg->setAnchorPoint(Point(0.5f, 0.5f));
	menuItem1->setAnchorPoint(Point(0.5f, 0.5f));
	menuItem2->setAnchorPoint(Point(0.5f, 0.5f));
	
	// create menu, it's an autorelease object
    auto menu = Menu::create(menuItem1, menuItem2, NULL);
    menu->setPosition(Point::ZERO);
	
	menuItem1->setPosition(Point(pCenter.x - 120,  pCenter.y - 180));
	menuItem2->setPosition(Point(pCenter.x + 120 ,  pCenter.y - 180));
	
	LabelTTF *label1 = LabelTTF::create("好的", "AmericanTypewriter", 30);//添加文字

	label1->setColor(Color3B::WHITE);
	label1->setPosition(menuItem1->getPosition());
	bgLay->addChild(label1, 2);
	
	LabelTTF *label2 = LabelTTF::create("忍着不用", "AmericanTypewriter", 30);//添加文字

	label2->setColor(Color3B::WHITE);
	label2->setPosition(menuItem2->getPosition());
	bgLay->addChild(label2,2);
	
	bg->setPosition(Point(pCenter.x, pCenter.y + 20));
	
	bgLay->setContentSize(winSize);
	bgLay->addChild(bg);
    bgLay->addChild(menu, 1);
	//	bgLay->addChild(title,2);
	
	this->addChild(bgLay);
}
开发者ID:jiangchao1987,项目名称:crazyvideo,代码行数:68,代码来源:PopUpBombLayer.cpp

示例11:

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);
}
开发者ID:kanon1109,项目名称:RotationBrid,代码行数:68,代码来源:FailScene.cpp

示例12: init

bool ChatScene::init()
{
    if(!Layer::init())
    {
        return false;
    }
    Rect visibleRect = VisibleRect::getVisibleRect();
    m_tBeginPoint = Vec2(0, VisibleRect::top().y-50);
    auto backLabel = LabelTTF::create("Back", "Arial", 25);
    MenuItem* pBackMenuItem = MenuItemLabel::create(backLabel, std::bind(&ChatScene::backCallback, this, std::placeholders::_1));
    Menu* pBackMenu = Menu::create(pBackMenuItem, NULL);
    pBackMenu->setAnchorPoint(Point::ZERO);
    pBackMenu->setPosition(Vec2(VisibleRect::right().x+35, VisibleRect::top().y-20));
    this->addChild(pBackMenu, 10);
    
    auto pUserLabel = LabelTTF::create("Users", "Arial", 25);
    MenuItemLabel* pUserMenuItem = MenuItemLabel::create(pUserLabel, std::bind(&ChatScene::userCallback, this, std::placeholders::_1));
    Menu* pUserMenu = Menu::create(pUserMenuItem, NULL);
    pUserMenu->setAnchorPoint(Vec2::ZERO);
    pUserMenu->setPosition(Vec2(VisibleRect::right().x -40,VisibleRect::top().y -20));
    this->addChild(pUserMenu, 10);
    
    auto pSendLabel = LabelTTF::create("Send", "Arial", 25);
    MenuItemLabel* pSendMenuItem = MenuItemLabel::create(pSendLabel, std::bind(&ChatScene::sendCallback, this, std::placeholders::_1));
    Menu* pSendMenu = Menu::create(pSendMenuItem, NULL);
    pSendMenu->setAnchorPoint(Vec2::ZERO);
    pSendMenu->setPosition(Vec2(VisibleRect::right().x-45, 25));
    addChild(pSendMenu,10);
    
    this->m_pChannelText = LabelTTF::create(s_channel.c_str(), "Arial", 25);
    this->m_pChannelText->setPosition(Vec2(VisibleRect::center().x, VisibleRect::top().y - 20));
    addChild(this->m_pChannelText, 10);
    
    m_layer = Layer::create();
    
    for (int i = 0; i<visibleRect.size.height/LINE_SPACE; ++i) {
        LabelTTF* pLabel;
        if(i<TESTS_COUNT)
        {
            pLabel = LabelTTF::create(global_text[i].c_str(), "Arial", 23);
            pLabel->setDimensions(Size(visibleRect.size.width, 50));
        }
        else
        {
            pLabel = LabelTTF::create("", "Arial", 23);
            pLabel->setDimensions(Size(visibleRect.size.width, 50));
        }
        pLabel->setColor(Color3B(32, 32, 32));
        pLabel->setAnchorPoint(Vec2(0, 0));
        pLabel->setPosition(Vec2(VisibleRect::left().x+10, (m_tBeginPoint.y-(i+1)*LINE_SPACE)));
        m_layer->addChild(pLabel, 10, i);
    }
    
    m_layer->setContentSize(Size(Vec2(VisibleRect::getVisibleRect().size.width-30, (TESTS_COUNT+1)*(LINE_SPACE))));
    m_layer->setPosition(s_tCurPos);
    addChild(m_layer,2);
    
    LayerColor* pLayer1 = LayerColor::create(Color4B(255, 255, 255, 255), visibleRect.size.width, visibleRect.size.height);
    pLayer1->setCascadeColorEnabled(false);
    pLayer1->setPosition(Vec2(0,0));
    addChild(pLayer1,1);
    
    LayerColor* pLayer2 = LayerColor::create(Color4B(0, 0, 0, 255), visibleRect.size.width, 40);
    pLayer2->setCascadeColorEnabled(false);
    pLayer2->setPosition(Vec2(0, VisibleRect::top().y-40));
    addChild(pLayer2,8);
    
    LayerColor* pLayer3 = LayerColor::create(Color4B(72, 72, 72, 255), visibleRect.size.width, 50);
    pLayer3->setCascadeColorEnabled(false);
    pLayer3->setPosition(Vec2(0, 0));
    addChild(pLayer3,8);
    
    m_pTextField = TextFieldTTF::textFieldWithPlaceHolder("", FONT_NAME, FONT_SIZE);
    m_pTextField->setAnchorPoint(Vec2::ZERO);
    m_pTextField->setPosition(VisibleRect::left().x+10,5);
    //m_pTextField->setColorSpaceHolder(Color3B(255,0,0));
    m_pTextField->setString("1111111111111111111111111111111111111111111111111111111111");
    addChild(m_pTextField,12);
    
    m_pTextField->setDelegate(this);
    
    return true;
}
开发者ID:visualcshape,项目名称:chatofpomelo_cocos2d-x3.2rc0,代码行数:83,代码来源:ChatScene.cpp

示例13: updateLayout

void Dialog::updateLayout()
{
    Size content_size = this->getContentSize();

    Menu* menu = Menu::create();
    menu->setPosition(15.0f, 10.0f);
    menu->setContentSize(Size(240.0f, 27.0f));

    float button_size = (240.0f - 1.0f * (m_list_button.size() - 1)) / m_list_button.size();
    int i = 0;

    for(auto it = m_list_button.begin(); it != m_list_button.end(); it++, i++) {
        if(it != m_list_button.begin()) {
            DrawObject* draw_line = DrawObject::create();
            draw_line->setPosition(button_size + 1.0f * (i - 1), 1.0f);
            draw_line->setContentSize(Size(1.0f, 25.0f));
            draw_line->setOnDraw([=] () {
                DrawPrimitives::setDrawColor4B(127, 127, 127, 255);
                DrawPrimitives::drawLine(Point(0.0f, 0.0f), Point(0.0f, draw_line->getContentSize().height));
            });
            draw_line->setAnchorPoint(Point(0.0f, 0.0f));

            menu->addChild(draw_line);
        }

        LabelTTF* label = LabelTTF::create(it->first, FourCard::DEFAULT_FONT, 20.0f, Size(button_size, 27.0f), TextHAlignment::CENTER, TextVAlignment::CENTER);
        label->setColor(Color3B(127, 127, 127));
        label->setAnchorPoint(Point(0.0f, 0.0f));

        MenuItemLabel* menuItem = MenuItemLabel::create(label, [=] (Object* pSender) {
            it->second();
        });
        menuItem->setAnchorPoint(Point(0.0f, 0.0f));
        menuItem->setPosition(button_size * i + 1.0f * i, 0.0f);

        menu->addChild(menuItem);
    }

    m_dialog->addChild(menu);

    DrawObject* draw_line_message = DrawObject::create();
    draw_line_message->setPosition(15.0f, 47.0f);
    draw_line_message->setContentSize(Size(240.0f, 1.0f));
    draw_line_message->setOnDraw([=] () {
        DrawPrimitives::setDrawColor4B(127, 127, 127, 255);
        DrawPrimitives::drawLine(Point(0.0f, 0.0f), Point(draw_line_message->getContentSize().width, 0.0f));
    });
    draw_line_message->setAnchorPoint(Point(0.0f, 0.0f));

    m_dialog->addChild(draw_line_message);

    if(m_layer != nullptr) {
        m_layer->setPosition(15.0f + (240.0f - m_layer->getContentSize().width) / 2, 48.0f);
        m_dialog->addChild(m_layer);
    }

    LabelTTF* label_message = LabelTTF::create(m_message, FourCard::DEFAULT_FONT, 15.0f, Size(240.0f, 0.0f), TextHAlignment::CENTER);
    label_message->setPosition(15.0f, 63.0f + ((m_layer != nullptr) ? m_layer->getContentSize().height : 0));
    label_message->setColor(Color3B(60, 60, 60));
    label_message->setAnchorPoint(Point(0.0f, 0.0f));

    m_dialog->addChild(label_message);

    DrawObject* draw_line_title = DrawObject::create();
    draw_line_title->setPosition(15.0f, 59.0f + ((m_layer != nullptr) ? m_layer->getContentSize().height : 0) + label_message->getContentSize().height + 15.0f);
    draw_line_title->setContentSize(Size(240.0f, 1.0f));
    draw_line_title->setOnDraw([=] () {
        DrawPrimitives::setDrawColor4B(127, 127, 127, 255);
        DrawPrimitives::drawLine(Point(0.0f, 0.0f), Point(draw_line_title->getContentSize().width, 0.0f));
    });
    draw_line_title->setAnchorPoint(Point(0.0f, 0.0f));

    m_dialog->addChild(draw_line_title);

    LabelTTF* label_title = LabelTTF::create(m_title, FourCard::DEFAULT_FONT, 20.0f, Size(240.0f, 27.0f), TextHAlignment::LEFT, TextVAlignment::CENTER);
    label_title->setPosition(15.0f, 74.0f + ((m_layer != nullptr) ? m_layer->getContentSize().height : 0) + label_message->getContentSize().height + 1.0f + 10.0f);
    label_title->setColor(Color3B(60, 60, 60));
    label_title->setAnchorPoint(Point(0.0f, 0.0f));

    m_dialog->addChild(label_title);

    m_dialog->setContentSize(Size(270.0f, 124.0f + ((m_layer != nullptr) ? m_layer->getContentSize().height : 0) + label_message->getContentSize().height));
    m_dialog->setPosition((content_size.width - m_dialog->getContentSize().width) / 2, (content_size.height - m_dialog->getContentSize().height) / 2);

    Scale9Sprite* sprite_background = Scale9Sprite::create(Rect(10, 10, 1, 1), "sprites/dialog/background.png");
    sprite_background->setContentSize(m_dialog->getContentSize());
    sprite_background->setAnchorPoint(Point(0.0f, 0.0f));

    m_dialog->addChild(sprite_background, -1);
}
开发者ID:nam921,项目名称:FourCard,代码行数:90,代码来源:Dialog.cpp


注:本文中的LabelTTF::setAnchorPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。