本文整理汇总了C++中CCLabelTTF::getTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLabelTTF::getTexture方法的具体用法?C++ CCLabelTTF::getTexture怎么用?C++ CCLabelTTF::getTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLabelTTF
的用法示例。
在下文中一共展示了CCLabelTTF::getTexture方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addChatInfo
void ChatWidget::addChatInfo(UiMsgEv::ChatInfo *info,int group)
{
int type = info->m_chatType;
if(type == UiMsgEv::MsgToUserPrivate && info->m_revId != m_userId){
//this is not for me
return;
}
float fontSize = 30;
float headWidth = 80;
float rowHeight = 40;
ccColor3B fHeadCC3,pHeadCC3,fContentCC3,pContentCC3;
fHeadCC3 = ccGREEN;
pHeadCC3 = ccWHITE;
fContentCC3 = ccGREEN;
pContentCC3 = ccBLUE;
ccColor3B headColor,contentColor;
if(type == UiMsgEv::MsgToUserPrivate)
headColor = fHeadCC3;
else
headColor = pHeadCC3;
if(type == UiMsgEv::MsgToUserPrivate)
contentColor = fContentCC3;
else
contentColor = pContentCC3;
float singleCharWidth = 16;
float multiCharWidth = 30;
float vscrollWidth = 10;
float faceWidth = 60;
float faceHeight = 60;
float scrollWidth,scrollHeight;
VerScrollWidget *scrollWidget = m_scrollWidgets[group];
scrollWidget->getAnchorSize(scrollWidth,scrollHeight);
//16 is for ver scroll bar
ChatWidgetLayer *layer = new ChatWidgetLayer(scrollWidth - 16);
std::string head;
head = info->m_senderNickName;
if(head.empty()){
mailToNickName(info->m_senderMail,head);
if(head.empty())
head = "Guest";
}
head.insert(0,"["); /* blank for text edge */
head.append("]:");
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID)
CCLabelTTF *headLabel = CCLabelTTF::create(head.data(),getSystemFont(),fontSize
,CCSizeMake(0,rowHeight),kCCTextAlignmentCenter);
#else
//android if width ==0 && height != 0 lead to crash,fixed in cc 3.0
CCLabelTTF *headLabel = CCLabelTTF::create(head.data(),getSystemFont(),fontSize
,CCSizeMake(0,0),kCCTextAlignmentCenter);
#endif
headLabel->setColor(headColor);
FSizeLabelDelegate *headDele = new FSizeLabelDelegate(headLabel,
CCSizeMake(headLabel->getTexture()->getContentSize().width,rowHeight));
layer->setHeadWidget(headDele);
layer->setHeadWidth(headWidth);
if(m_headCanClicked){
headDele->setCanTouch(true);
headDele->setClickCB(this,callfuncND_selector(ChatWidget::onHeadClicked));
ChaterInfo *chater = new ChaterInfo;
chater->m_id = info->m_senderId;
chater->m_mail = info->m_senderMail;
chater->m_nick = info->m_senderNickName;
m_chaterMap.insert(std::make_pair(headDele->getName(),chater));
}
std::string content = info->m_chatContent;
std::vector<ChatInfoFmt> chats;
chatStringSplit(content,chats);
std::string labelcontent;
//need detract ver scroll width
scrollWidth -= vscrollWidth;
float spaceLeft = scrollWidth - headLabel->getTexture()->getContentSize().width;
for(unsigned int i = 0;i < chats.size();i++){
ChatInfoFmt &info = chats[i];
if(info.m_type == TypeChar){
if((spaceLeft - singleCharWidth) > 0){
labelcontent.append(info.m_str);
spaceLeft -= singleCharWidth;
}else{
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID)
CCLabelTTF *cLabel = CCLabelTTF::create(labelcontent.data(),getSystemFont(),fontSize,
CCSizeMake(0,rowHeight),kCCTextAlignmentCenter);
#else
CCLabelTTF *cLabel = CCLabelTTF::create(labelcontent.data(),getSystemFont(),fontSize,
CCSizeMake(0,0),kCCTextAlignmentCenter);
#endif
cLabel->setColor(contentColor);
FSizeLabelDelegate *deleLabel = new FSizeLabelDelegate(cLabel,cLabel->getTexture()->getContentSize());
layer->addContentWidget(deleLabel);
spaceLeft = scrollWidth - headWidth;
labelcontent.clear();
}
}else if(info.m_type == TypeUtfChar){
if((spaceLeft - multiCharWidth) > 0){
labelcontent.append(info.m_str);
spaceLeft -= multiCharWidth;
//.........这里部分代码省略.........