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


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

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


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

示例1: ReadLgCell

void RWLViewDBSource::ReadLgCell(std::string asHead, LogicCell* algc)
{
	if(0 == algc->miType){
		CCLabelTTF* tlt = CCLabelTTF::create((asHead+algc->msText).c_str(), FNT_UI_LABEL, 24,CCSize(rw,0), kCCTextAlignmentLeft);
		tlt->retain();
		m_plength.push_back(tlt->getContentSize().height);
		CCLog("+++++++%f", tlt->getContentSize().height);
		m_height += tlt->getContentSize().height;
		data->addObject(tlt);		

		asHead += " ";
		return;
	}


	for(std::vector<LogicCell*>::iterator it = algc->mvChilds.begin(); it != algc->mvChilds.end(); ++it){
		if((*it)->miType == 0){
			asHead += " ";
			break;
		}
	}

	for(std::vector<LogicCell*>::iterator it = algc->mvChilds.begin(); it != algc->mvChilds.end(); ++it){
		ReadLgCell(asHead.c_str(), *it);
	}

}
开发者ID:steinkrausls,项目名称:cocotd,代码行数:27,代码来源:RWLViewDBSource.cpp

示例2: 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

示例3: 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


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