本文整理汇总了C++中UILabel::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ UILabel::getPosition方法的具体用法?C++ UILabel::getPosition怎么用?C++ UILabel::getPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UILabel
的用法示例。
在下文中一共展示了UILabel::getPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: refreshPvAILayer
//.........这里部分代码省略.........
//排名
stringstream otherPlayerRankStream;
otherPlayerRankStream << "pvaiOtherPlayerRank" << i+1;
string otherPlayerRankStr = otherPlayerRankStream.str();
UILabel *otherPlayerRankLabel = pvaiLayout->FindChildObjectByName<UILabel>(otherPlayerRankStr);
int playerRank = aiPlayerVec[i].rank;
string rankText = Localizatioin::getLocalization("M_PVAI_RANK2");
stringstream rankStream;
rankStream << rankText << playerRank;
string rankStr = rankStream.str();
otherPlayerRankLabel->setString(rankStr.c_str());
}
//最近日志列表
float fontSize = GameFontManager::smallFontSize();
int logCount = aiLogInfoVec.size();
int minLogCount = min(logCount, 4);
//隐藏多余项目
for (int i = minLogCount; i < 4; i++)
{
stringstream attackTextStream;
attackTextStream << "pvaiChallenge" << i+1;
string attackTextStr = attackTextStream.str();
UILabel *attackOrgLabel = pvaiLayout->FindChildObjectByName<UILabel>(attackTextStr);
attackOrgLabel->setVisible(false);
stringstream resultStream;
resultStream << "pvaiChallengeResult" << i+1;
string resultStr = resultStream.str();
UILabel *resultLabel = pvaiLayout->FindChildObjectByName<UILabel>(resultStr);
resultLabel->setVisible(false);
}
for (int i = 0; i < minLogCount; i++)
{
float factor = UIManager::sharedManager()->getScaleFactor();
stringstream attackTextStream;
attackTextStream << "pvaiChallenge" << i+1;
string attackTextStr = attackTextStream.str();
UILabel *attackOrgLabel = pvaiLayout->FindChildObjectByName<UILabel>(attackTextStr);
UIContainer * container = pvaiLayout->FindChildObjectByName<UIContainer>("pvaiLayerContainer");
attackOrgLabel->setVisible(false);
CCPoint orgPos = attackOrgLabel->getPosition();
CCPoint orgLeftPos = ccp(orgPos.x - attackOrgLabel->getLabelTTF()->getContentSize().width * factor / 2, orgPos.y);
//挑战方向
if (aiLogInfoVec[i].direct)
{
//主动攻击
string attackText = Localizatioin::getLocalization("M_PVAI_FIGHT1");
string attackName = aiLogInfoVec[i].name;
UILabelTTF * attackTextLabel = UILabelTTF::create(attackText.c_str(), KJLinXin, fontSize * factor, CCSizeZero,kCCTextAlignmentLeft,kCCVerticalTextAlignmentBottom);
UILabelTTF * attackNameLabel = UILabelTTF::create(attackName.c_str(), KJLinXin, fontSize * factor, CCSizeZero,kCCTextAlignmentLeft,kCCVerticalTextAlignmentBottom);
attackTextLabel->setPosition(ccp(orgLeftPos.x + attackTextLabel->getContentSize().width / 2, orgLeftPos.y));
attackNameLabel->setPosition(ccp(orgLeftPos.x + attackTextLabel->getContentSize().width + attackNameLabel->getContentSize().width/ 2, orgLeftPos.y));
UILabel * aTextLabel = new UILabel(attackTextLabel, container->getCurrentNode());
UILabel * aNameLabel = new UILabel(attackNameLabel, container->getCurrentNode());
aNameLabel->setColor(KAILogNameColor);
}
else
{
//被攻击
string defenceName = aiLogInfoVec[i].name;
string defenceText = Localizatioin::getLocalization("M_PVAI_FIGHT2");
UILabelTTF * defenceTextLabel = UILabelTTF::create(defenceText.c_str(), KJLinXin, fontSize, CCSizeZero,kCCTextAlignmentLeft,kCCVerticalTextAlignmentBottom);
UILabelTTF * defenceNameLabel = UILabelTTF::create(defenceName.c_str(), KJLinXin, fontSize, CCSizeZero,kCCTextAlignmentLeft,kCCVerticalTextAlignmentBottom);
defenceNameLabel->setPosition(ccp(orgLeftPos.x + defenceNameLabel->getContentSize().width / 2, orgLeftPos.y));
defenceTextLabel->setPosition(ccp(orgLeftPos.x + defenceNameLabel->getContentSize().width + defenceTextLabel->getContentSize().width / 2, orgLeftPos.y));
UILabel * aTextLabel = new UILabel(defenceTextLabel, container->getCurrentNode());
UILabel * aNameLabel = new UILabel(defenceNameLabel, container->getCurrentNode());
aNameLabel->setColor(KAILogNameColor);
}
//挑战结果
stringstream resultStream;
resultStream << "pvaiChallengeResult" << i+1;
string resultStr = resultStream.str();
UILabel *resultLabel = pvaiLayout->FindChildObjectByName<UILabel>(resultStr);
if (aiLogInfoVec[i].win == aiLogInfoVec[i].direct)
{
string resultText = Localizatioin::getLocalization("M_PVAI_WIN");
resultLabel->setString(resultText.c_str());
resultLabel->setColor(ccYELLOW);
}
else
{
string resultText = Localizatioin::getLocalization("M_PVAI_LOST");
resultLabel->setString(resultText.c_str());
resultLabel->setColor(ccRED);
}
}
}
}