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


C++ CCLabelTTF::boundingBox方法代码示例

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


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

示例1: init

// on "init" you need to initialize your instance
bool StoreBScene::init()
{
	//////////////////////////////
	// 1. super init first
	if ( !CCLayerColor::initWithColor(ccc4(255,255,255,255)))
	{
		return false;
	}

	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
	CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

	CCLabelTTF* pLabelTitleTest = CCLabelTTF::create("Soomla Test Store", "GoodDog.otf", 34);
	pLabelTitleTest->setColor(ccc3(255,0,0));
	pLabelTitleTest->setPosition(ccp(pLabelTitleTest->boundingBox().size.width/2 + origin.x + 20, visibleSize.height - 30 + origin.y));
	this->addChild(pLabelTitleTest, 1);

	CCLabelTTF* pLabelTitle = CCLabelTTF::create("Virtual Currency Packs", "GoodDog.otf", 54);
	pLabelTitle->setColor(ccc3(0,0,0));
	pLabelTitle->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height - 100 + origin.y));
	this->addChild(pLabelTitle, 1);


	CCSprite* pSpriteMuffin = CCSprite::create("muffin.png");
	pSpriteMuffin->setScale(0.5f);
	pSpriteMuffin->setPosition(ccp(origin.x + visibleSize.width - 90, visibleSize.height + origin.y - 50));
	this->addChild(pSpriteMuffin, 0);

	pLabelBalance = CCLabelTTF::create("24", "GoodDog.otf", 34);
	pLabelBalance->setColor(ccc3(0,255,255));
	pLabelBalance->setPosition(ccp(origin.x + visibleSize.width - 40, visibleSize.height + origin.y - 50));
	this->addChild(pLabelBalance, 1);
	setCurrencyBalanceLabel();


	GameMenuItem* backItem = GameMenuItem::itemWithLabel(
		CCSprite::create("back.png"),
		this,
		menu_selector(StoreBScene::menuBackCallback));

	backItem->setPosition(ccp(origin.x + visibleSize.width/2 , 110));

	// In Game Menu
	CCMenu* menu = CCMenu::create(backItem, NULL);

	createListViewItem(origin, menu, visibleSize, 0, "no_ads.png");
	createListViewItem(origin, menu, visibleSize, 1, "muffins01.png");
	createListViewItem(origin, menu, visibleSize, 2, "muffins02.png");
	createListViewItem(origin, menu, visibleSize, 3, "muffins03.png");
	createListViewItem(origin, menu, visibleSize, 4, "muffins04.png");

	menu->setPosition(CCPointZero);
	this->addChild(menu);

	this->setKeypadEnabled(true);

	return true;
}
开发者ID:Hyacinth,项目名称:cocos2dx-store,代码行数:59,代码来源:StoreBScene.cpp

示例2: createListViewItem

void StoreAScene::createListViewItem(CCPoint& origin, CCMenu* menu, CCSize& visibleSize, int tag, const char* img) {
	GameMenuItem *pChooseItem = GameMenuItem::itemWithLabel(
		CCSprite::create("button.png"),
					this,
					menu_selector(StoreAScene::menuChooseCallback));

	string itemId = itemIdFromTag(tag);
	
	// TODO: exception handling ..
    string nameS = cocos2dx_StoreInfo::getGoodName(itemId.c_str());
	string infoS = cocos2dx_StoreInfo::getGoodDescription(itemId.c_str());
	int price = cocos2dx_StoreInfo::getGoodPriceForCurrency(itemId.c_str(), "currency_muffin");
	int balance = 0;
	const char * name = nameS.c_str();
	const char * info = infoS.c_str();
	
	float yOffset = - 200;

	pChooseItem->setPosition(ccp(origin.x + visibleSize.width/2, yOffset + origin.y + visibleSize.height - 100 - (tag * pChooseItem->boundingBox().size.height)));
	pChooseItem->setTag(tag);


	CCSprite* pSpritePic = CCSprite::create(img);
	pSpritePic->setPosition(ccp(pSpritePic->boundingBox().size.width/2 + 20, pChooseItem->boundingBox().size.height/2));
	pChooseItem->addChild(pSpritePic, 0);


	CCLabelTTF* pLabelName = CCLabelTTF::create(name, "GoodDog.otf", 44);
	pLabelName->setColor(ccc3(0,0,0));
	pLabelName->setPosition(ccp(pSpritePic->getPositionX() + (pSpritePic->boundingBox().size.width / 2) + (pLabelName->boundingBox().size.width / 2) + 20 , pChooseItem->boundingBox().size.height/2));
	pChooseItem->addChild(pLabelName);


	CCLabelTTF* pLabelInfo = CCLabelTTF::create(info, "GoodDog.otf", 20);
	pLabelInfo->setColor(ccc3(50,50,50));
	pLabelInfo->setPosition(ccp(pSpritePic->getPositionX() + (pSpritePic->boundingBox().size.width / 2) + (pLabelInfo->boundingBox().size.width / 2) + 20 , -50 + (pChooseItem->boundingBox().size.height/2)));
	pChooseItem->addChild(pLabelInfo);


	CCLabelTTF* pLabelClickToBuy = CCLabelTTF::create("Click to Buy", "GoodDog.otf", 24);
	pLabelClickToBuy->setColor(ccc3(0,255,255));
	pLabelClickToBuy->setPosition(ccp(pChooseItem->boundingBox().size.width - (pLabelClickToBuy->boundingBox().size.width / 2) - 20 , 60 + pChooseItem->boundingBox().size.height/2));
	pChooseItem->addChild(pLabelClickToBuy);

	char buffer[512];

	snprintf(buffer, sizeof(buffer), "price: %d blanace: %d",  price, balance);

	goodsPriceBalanceLabels[tag] = CCLabelTTF::create(buffer, "GoodDog.otf", 24);
	goodsPriceBalanceLabels[tag]->setColor(ccc3(0,255,255));
	goodsPriceBalanceLabels[tag]->setPosition(ccp(pChooseItem->boundingBox().size.width - (goodsPriceBalanceLabels[tag]->boundingBox().size.width / 2) - 20 , 60));
	pChooseItem->addChild(goodsPriceBalanceLabels[tag]);

	menu->addChild(pChooseItem, 1);
	
	setPriceBalanceLabel(itemId.c_str());
}
开发者ID:Obg1,项目名称:cocos2dx-store,代码行数:57,代码来源:StoreAScene.cpp

示例3: initControls

/*
 * Control initialization
 */
void OptionsLayer::initControls()
{
	int xPos = 100;
	int fontSize = 35;

	CCSize visibleSize = CCEGLView::sharedOpenGLView()->getVisibleSize();
    
	//Labels
	CCLabelTTF* lblName = sgl_ControlFactory.createTTFLabel("Name:", ccp(xPos, 500));
    this->addChild(lblName);

	CCLabelTTF* lblGoal = sgl_ControlFactory.createTTFLabel("Goals:", ccp(xPos, 400));
	this->addChild(lblGoal);

	CCLabelTTF* lblColor = sgl_ControlFactory.createTTFLabel("Time:", ccp(xPos, 300));
	this->addChild(lblColor);

	//Controls
	int controlLimit = xPos + lblGoal->boundingBox().size.width + 20;

    std::string userName = CCUserDefault::sharedUserDefault()->getStringForKey(USER_DATA_NAME);
    if (userName.empty())
    {
        userName = "anonymus";
    }
    
	CCSize editBoxSize = CCSizeMake(visibleSize.width * 0.2f, 50);
	CCScale9Sprite* sp = CCScale9Sprite::create("textbg.png");
	
	_txtName = CCEditBox::create(editBoxSize, sp);
    _txtName->setPosition(ccp(controlLimit+10, 480));
	_txtName->setFontName(S_F_TYPE.c_str());
	_txtName->setFontSize(fontSize);
    _txtName->setFontColor(ccRED);
	_txtName->setPlaceHolder(userName.c_str());
    _txtName->setPlaceholderFontColor(ccWHITE);
    _txtName->setMaxLength(15);
    _txtName->setReturnType(kKeyboardReturnTypeDone);
    _txtName->setDelegate(this);
	_txtName->setZOrder(1);
    _txtName->setAnchorPoint(ccp(0,0));
	
	addChild(_txtName);

	int goals = CCUserDefault::sharedUserDefault()->getIntegerForKey(GOALS_DATA_NAME);
	if (goals < 1) goals = 10;

	_goalNoSlider = CCControlSlider::create("sliderTrack.png", "sliderProgress.png", "sliderThumb.png");
    
    _goalNoSlider->setTouchEnabled(true);
    _goalNoSlider->setMinimumValue(1.0f); // Sets the min value of range
    _goalNoSlider->setMaximumValue(goals); // Sets the max value of range
    _goalNoSlider->setPosition(ccp(controlLimit+100, 400));
	_goalNoSlider->setAnchorPoint(ccp(0,0));
	_goalNoSlider->addTargetWithActionForControlEvents(this, cccontrol_selector(OptionsLayer::sliderEvent), CCControlEventValueChanged);
	_goalNoSlider->setTag(goalTag);

	_lblGoalSelection = sgl_ControlFactory.createTTFLabel("", ccp(controlLimit+_goalNoSlider->boundingBox().size.width+100, 400));
    this->addChild(_lblGoalSelection);

	_timeSlider = CCControlSlider::create("sliderTrack.png", "sliderProgress.png", "sliderThumb.png");
    
    _timeSlider->setTouchEnabled(true);
    _timeSlider->setPosition(ccp(controlLimit+100, 300));
	_timeSlider->setAnchorPoint(ccp(0,0));
	_timeSlider->addTargetWithActionForControlEvents(this, cccontrol_selector(OptionsLayer::sliderEvent), CCControlEventValueChanged);
	_timeSlider->setTag(timerTag);

    addChild(_goalNoSlider);
	addChild(_timeSlider);
}
开发者ID:koboldul,项目名称:Football,代码行数:74,代码来源:OptionsLayer.cpp

示例4: playObjective


//.........这里部分代码省略.........
        ss << obj->title;
        ss1 << obj->content;
        ss2 << obj->progress;
    }
    else
    {
        ss << "OBJECTIVE";
        ss1 << "There is no objectives currently!";
        ss2 << "";
        progressNumber = -1;
    }
    
    GameHUD::getThis()->objectiveTitle->setString(ss.str().c_str());
    GameHUD::getThis()->objectiveProgress->setString(ss2.str().c_str());
    
    string objectiveDescription = ss1.str();
    vector<string> objectiveDescriptionTokens = GlobalHelper::split(objectiveDescription, ' ');
    
    CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
    ccColor3B colorWhite = ccc3(255, 255, 255);
    
    float startX = screenSize.width * 0.11f;
    float startY = screenSize.height - 510;
    float offX = 0;
    float offY = 0;
    float limit = 700;
    
    
    string tempString = "";
    string previousString = "";
    for (int i = 0; i < objectiveDescriptionTokens.size(); i++)
    {
        previousString = tempString;
        string temp = objectiveDescriptionTokens.at(i);
        if (i > 0)
        {
            tempString = tempString + " ";
        }
        tempString = tempString + temp;
        CCLabelTTF* tempLabel = CCLabelTTF::create(tempString.c_str(), "Shojumaru-Regular", 28);
        tempLabel->retain();
        if(startX + tempLabel->boundingBox().size.width > limit)
        {
            CCLabelTTF* theLabel = CCLabelTTF::create(previousString.c_str(), "Shojumaru-Regular", 28);
            theLabel->setAnchorPoint(ccp(0, 1));
            theLabel->setPosition(ccp(startX + offX, startY + offY));
            theLabel->setColor(colorWhite);
            GameHUD::getThis()->objectiveDescriptions->addObject(theLabel);
            GameHUD::getThis()->objectiveMenu->addChild(theLabel);
            tempString = temp;
            offY -= 25;
        }
        CC_SAFE_RELEASE(tempLabel);
    }
    
    CCLabelTTF* tempLabel = CCLabelTTF::create(tempString.c_str(), "Shojumaru-Regular", 28);
    tempLabel->setAnchorPoint(ccp(0, 1));
    tempLabel->setPosition(ccp(startX + offX, startY + offY));
    tempLabel->setColor(colorWhite);
    GameHUD::getThis()->objectiveDescriptions->addObject(tempLabel);
    GameHUD::getThis()->objectiveMenu->addChild(tempLabel);
    
    currID = obj->oid;
    nextID = obj->nid;
    
    if(obj->timeLimit > 0)
    {
        ss.str(std::string());
        if(obj->timeLimit < 10)
        {
            ss << "0";
        }
        ss << obj->timeLimit << ":" << "00";
        
        GameHUD::getThis()->objectiveTime->setString(ss.str().c_str());
        GameHUD::getThis()->objectiveTime->setVisible(true);
        GameHUD::getThis()->targetTime = obj->timeLimit * 60.0f;
        GameHUD::getThis()->currentTime = 0;
        GameHUD::getThis()->hasTimer = true;
    }
    else
    {
        GameHUD::getThis()->objectiveTime->setVisible(false);
    }
    
    stringstream sss;
    sss << "You receive a new objective!";
    GameHUD::getThis()->addNewNotification(sss.str());
    
    if(showNotification)
    {
        GameHUD::getThis()->scheduleShowNewObjectiveNotification();
    }
    
    if(obj->scheduleScenario)
    {
        GameHUD::getThis()->hasScenario = true;
        GameHUD::getThis()->scenarioTime = obj->scenarioTime;
    }
}
开发者ID:larryPersonal,项目名称:Nanhua,代码行数:101,代码来源:ObjectiveHandler.cpp

示例5:

CCMenuItemImage* Objects2dFactory::textButton(CCNode* scene, CCMenu* menu, string value, string normalImagePath, string selectedImagePath, string disabledImagePath, 
	float positionX, float positionY, float width, float height, SEL_MenuHandler selector, void* selectorArg, AlignX alignX, AlignY alignY, ccColor3B textColor, int zOrder)
{
	// Check arguments validity
	if(scene == NULL ||menu == NULL || !selector)
		return NULL;

	// Create a button menu item
    CCMenuItemImage *button = CCMenuItemImage::create(
        normalImagePath.c_str(),
        selectedImagePath.c_str(),
		disabledImagePath.c_str(),
        scene,
        selector);
    if(!button)
		return NULL;

	if (selectorArg != NULL)
	{
		button->setUserData(selectorArg);
	}

    // Place the menu item in the given position
    button->setPosition(ccp(positionX, positionY));

	// Set menu item anchor
	button->setAnchorPoint(ccp(Constants::getAnchorValue(alignX), Constants::getAnchorValue(alignY)));
	
	// Set menu item height
	float buttonHeight = button->boundingBox().size.height;
	float buttonPosScaleHeight = buttonHeight;
	if (height > 0) // if height is defined, it is setted
	{
		button->setScaleY(height / buttonHeight);
		buttonPosScaleHeight = height;
	}
	
    // Create a label and initialize with the given string
	CCLabelTTF* pLabel = CCLabelTTF::create(value.c_str(), "Arial"/*string(Constants::getResourcesPath() + "SOResources/Fonts/AlphaFridgeMagnetsAllCap.ttf").c_str()*/, 
		buttonPosScaleHeight * 0.6f);
    if(!pLabel)
		return NULL;
	
    // Set color
    pLabel->setColor(textColor);
	
	// Set menu item width
	float buttonWidth = button->boundingBox().size.width;
	float buttonPosScaleWidth = buttonWidth;
	if (width > 0) // if width is defined, it is setted
	{
		button->setScaleX(width / buttonWidth);
		buttonPosScaleWidth = width;
	}
	else // otherwise, we will compare the text width with the button width
	{
		float textWidth = pLabel->boundingBox().size.width;
		if (textWidth * 1.25 > buttonWidth) // if the width adapted to the text is bigger than the button width, adapted width must be setted, otherwise, button width must stay as it was
		{
			button->setScaleX(textWidth * 1.25f / buttonWidth);
			buttonPosScaleWidth = textWidth * 1.25f;
		}
	}
	
    // Place the label; must be in the center of the button
	pLabel->setPosition(ccp(buttonPosScaleWidth * 0.5f * 1/button->getScaleX(), buttonPosScaleHeight * 0.5f * 1/button->getScaleY()));
	
	// Set label centered anchor
	pLabel->setAnchorPoint(ccp(Constants::getAnchorValue(Centered), Constants::getAnchorValue(Middle)));
	
	// Add label to button
	button->addChild(pLabel);

	// Set label scale; the inverse of button scale, so label can be as it would be if it was a child of scene
	pLabel->setScaleY(1/button->getScaleY());
	pLabel->setScaleX(1/button->getScaleX());

	// If label is larger than button
	if (pLabel->boundingBox().size.width * button->getScaleX() > button->boundingBox().size.width)
	{
		// Label must be rescaled
		float newScale = button->boundingBox().size.width / (pLabel->boundingBox().size.width * button->getScaleX());
		pLabel->setScaleX(pLabel->getScaleX() * newScale);
	}

	// Add button to the menu
	menu->addChild(button, zOrder);
	
	return button;
}
开发者ID:Cnotinfor,项目名称:TopQX_2D,代码行数:90,代码来源:Objects2dFactory.cpp

示例6: displayTexts

void Senario::displayTexts(std::string str, float startX, float startY, string font, float fontSize, ccColor3B color, float limitX)
{
    vector<std::string> tokens = GlobalHelper::split(str, ' ');
    float offX = 0;
    float offY = 0;
    float flashTimeGap = 0.05f;
    int flashGapCount = 0;
    
    for (int i = 0; i < tokens.size(); i++)
    {
        std::string tokenStr = tokens.at(i);
        
        bool hasChinese = false;
        for (int j = 0; j < tokenStr.length(); j++)
        {
            if(tokenStr.at(j) == '^')
            {
                hasChinese = true;
                break;
            }
        }
        
        if (hasChinese)
        {
            int startIndex = 0;
            for (int j = 0; j < tokenStr.length(); j++)
            {
                if(tokenStr.at(j) == '^')
                {
                    string str = tokenStr.substr(startIndex, j - startIndex);
                    
                    CCLabelTTF* tempLabel = CCLabelTTF::create(str.c_str(), font.c_str(), fontSize);
                    tempLabel->retain();
                    
                    if (startX + offX + tempLabel->boundingBox().size.width > limitX)
                    {
                        offY = offY + 35.0f;
                        offX = 0;
                    }
                    
                    CC_SAFE_RELEASE(tempLabel);
                    
                    AnimatedString* as = AnimatedString::create(str, flashTimeGap * flashGapCount, font, fontSize, 80.0f);
                    as->getLabel()->setColor(color);
                    as->getLabel()->setAnchorPoint(ccp(0, 1));
                    
                    as->getLabel()->setPosition(ccp(startX + offX, startY - offY));
                    offX += as->label->boundingBox().size.width;
                    
                    this->addChild(as->getLabel(), 20);
                    animatedStringList->addObject(as);
                    
                    flashGapCount += 1;
                    
                    startIndex = j + 1;
                }
            }
            
            string str = tokenStr.substr(startIndex, tokenStr.length() - startIndex);
            AnimatedString* as = AnimatedString::create(str, flashTimeGap * flashGapCount, font, fontSize, 80.0f);
            as->getLabel()->setColor(color);
            as->getLabel()->setAnchorPoint(ccp(0, 1));
            
            as->getLabel()->setPosition(ccp(startX + offX, startY - offY));
            offX += as->label->boundingBox().size.width;
            
            this->addChild(as->getLabel(), 20);
            animatedStringList->addObject(as);
            
            flashGapCount += 1;
            
            offX += 10;
        }
        else
        {
            CCLabelTTF* tempLabel = CCLabelTTF::create(tokenStr.c_str(), font.c_str(), fontSize);
            tempLabel->retain();
            
            if (startX + offX + tempLabel->boundingBox().size.width > limitX)
            {
                offY = offY + 35.0f;
                offX = 0;
            }
            
            CC_SAFE_RELEASE(tempLabel);
            
            for (int j = 0; j < tokenStr.length(); j++)
            {
                string tempStr = tokenStr.substr(j, 1);
                AnimatedString* as = AnimatedString::create(tempStr, flashTimeGap * (j + flashGapCount), font, fontSize, 80.0f);
                as->getLabel()->setColor(color);
                as->getLabel()->setAnchorPoint(ccp(0, 1));
                
                as->getLabel()->setPosition(ccp(startX + offX, startY - offY));
                offX += as->label->boundingBox().size.width;
                
                this->addChild(as->getLabel(), 20);
                animatedStringList->addObject(as);
            }
            
//.........这里部分代码省略.........
开发者ID:keyor,项目名称:Nanhua,代码行数:101,代码来源:Senario.cpp

示例7: createListViewItem

void StoreBScene::createListViewItem(CCPoint& origin, CCMenu* menu, CCSize& visibleSize, int tag, const char* img) {
	GameMenuItem *pChooseItem = GameMenuItem::itemWithLabel(
		CCSprite::create("button.png"),
					this,
					menu_selector(StoreBScene::menuChooseCallback));

	string itemId = itemIdFromTag(tag);

	char name[512];
	char info[512];
	double price = 0;
	int balance = 0;
	if (itemId == "ERROR") {
		snprintf(name, sizeof(name), "Remove Ads!");
		snprintf(info, sizeof(info), "Test purchase of MANAGED item.");
		price = 5.99f;
	}
	else {
		// TODO: exception handling ..
	    string nameS = cocos2dx_StoreInfo::getItemName(itemId.c_str());
		string infoS = cocos2dx_StoreInfo::getItemDescription(itemId.c_str());
		price = cocos2dx_StoreInfo::getItemPrice(itemId.c_str());

		snprintf(name, sizeof(name), nameS.c_str());
		snprintf(info, sizeof(info), infoS.c_str());
	}

	float yOffset = - 200;

	pChooseItem->setPosition(ccp(origin.x + visibleSize.width/2, yOffset + origin.y + visibleSize.height - 100 - (tag * pChooseItem->boundingBox().size.height)));
	pChooseItem->setTag(tag);


	CCSprite* pSpritePic = CCSprite::create(img);
	pSpritePic->setPosition(ccp(pSpritePic->boundingBox().size.width/2 + 20, pChooseItem->boundingBox().size.height/2));
	pChooseItem->addChild(pSpritePic, 0);


	CCLabelTTF* pLabelName = CCLabelTTF::create(name, "GoodDog.otf", 44);
	pLabelName->setColor(ccc3(0,0,0));
	pLabelName->setPosition(ccp(pSpritePic->getPositionX() + (pSpritePic->boundingBox().size.width / 2) + (pLabelName->boundingBox().size.width / 2) + 20 , pChooseItem->boundingBox().size.height/2));
	pChooseItem->addChild(pLabelName);


	CCLabelTTF* pLabelInfo = CCLabelTTF::create(info, "GoodDog.otf", 20);
	pLabelInfo->setColor(ccc3(50,50,50));
	pLabelInfo->setPosition(ccp(pSpritePic->getPositionX() + (pSpritePic->boundingBox().size.width / 2) + (pLabelInfo->boundingBox().size.width / 2) + 20 , -50 + (pChooseItem->boundingBox().size.height/2)));
	pChooseItem->addChild(pLabelInfo);


	CCLabelTTF* pLabelClickToBuy = CCLabelTTF::create("Click to Buy", "GoodDog.otf", 24);
	pLabelClickToBuy->setColor(ccc3(0,255,255));
	pLabelClickToBuy->setPosition(ccp(pChooseItem->boundingBox().size.width - (pLabelClickToBuy->boundingBox().size.width / 2) - 20 , 60 + pChooseItem->boundingBox().size.height/2));
	pChooseItem->addChild(pLabelClickToBuy);

	char buffer[512];

	snprintf(buffer, sizeof(buffer), "price: $%.2f",  price);

	CCLabelTTF* pLabelPriceBalance = CCLabelTTF::create(buffer, "GoodDog.otf", 24);
	pLabelPriceBalance->setColor(ccc3(0,255,255));
	pLabelPriceBalance->setPosition(ccp(pChooseItem->boundingBox().size.width - (pLabelPriceBalance->boundingBox().size.width / 2) - 20 , 60));
	pChooseItem->addChild(pLabelPriceBalance);

	menu->addChild(pChooseItem, 1);
}
开发者ID:Hyacinth,项目名称:cocos2dx-store,代码行数:66,代码来源:StoreBScene.cpp

示例8: init

// on "init" you need to initialize your instance
bool StoreAScene::init()
{
	cocos2dx_StoreController::storeOpening();
		
	//////////////////////////////
	// 1. super init first
	if ( !CCLayerColor::initWithColor(ccc4(255,255,255,255)))
	{
		return false;
	}

	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
	CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

	CCLabelTTF* pLabelTitleTest = CCLabelTTF::create("Soomla Test Store", "GoodDog.otf", 34);
	pLabelTitleTest->setColor(ccc3(255,0,0));
	pLabelTitleTest->setPosition(ccp(pLabelTitleTest->boundingBox().size.width/2 + origin.x + 20, visibleSize.height - 30 + origin.y));
	this->addChild(pLabelTitleTest, 1);

	CCLabelTTF* pLabelTitle = CCLabelTTF::create("Virtual Goods", "GoodDog.otf", 54);
	pLabelTitle->setColor(ccc3(0,0,0));
	pLabelTitle->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height - 100 + origin.y));
	this->addChild(pLabelTitle, 1);


	CCSprite* pSpriteMuffin = CCSprite::create("muffin.png");
	pSpriteMuffin->setScale(0.5f);
	pSpriteMuffin->setPosition(ccp(origin.x + visibleSize.width - 90, visibleSize.height + origin.y - 50));
	this->addChild(pSpriteMuffin, 0);
	
	pLabelBalance = CCLabelTTF::create("0", "GoodDog.otf", 34);
	pLabelBalance->setColor(ccc3(0,255,255));
	pLabelBalance->setPosition(ccp(origin.x + visibleSize.width - 40, visibleSize.height + origin.y - 50));
	this->addChild(pLabelBalance, 1);
	setCurrencyBalanceLabel();

	GameMenuItem* getMoreItem = GameMenuItem::itemWithLabel(
		CCSprite::create("get_more.png"),
		this,
		menu_selector(StoreAScene::menuGetMoreCallback));

	getMoreItem->setPosition(ccp(origin.x + visibleSize.width/2 + (getMoreItem->boundingBox().size.width /2) + 10, 110));


	GameMenuItem* backItem = GameMenuItem::itemWithLabel(
		CCSprite::create("back.png"),
		this,
		menu_selector(StoreAScene::menuBackCallback));

	backItem->setPosition(ccp(origin.x + visibleSize.width/2 - (backItem->boundingBox().size.width /2) - 10 , 110));

	// In Game Menu
	CCMenu* menu = CCMenu::create(getMoreItem, backItem, NULL);

	createListViewItem(origin, menu, visibleSize, 0, "fruit_cake.png");
	createListViewItem(origin, menu, visibleSize, 1, "pavlova.png");
	createListViewItem(origin, menu, visibleSize, 2, "cream_cup.png");
	createListViewItem(origin, menu, visibleSize, 3, "chocolate_cake.png");
	
	menu->setPosition(CCPointZero);
	this->addChild(menu);

	this->setKeypadEnabled(true);

	return true;
}
开发者ID:Obg1,项目名称:cocos2dx-store,代码行数:67,代码来源:StoreAScene.cpp


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