本文整理汇总了C++中Label::CenterText方法的典型用法代码示例。如果您正苦于以下问题:C++ Label::CenterText方法的具体用法?C++ Label::CenterText怎么用?C++ Label::CenterText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Label
的用法示例。
在下文中一共展示了Label::CenterText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetOrgin
void RClickMenu::SetOrgin(Orgins orgin){
for(int x = 0; x < labels.size(); x++){
Label* tempLabel = labels[x];
sf::Sprite* tempSprite = tempLabel->GetSprite();
sf::Vector2f halfSize = sf::Vector2f(tempLabel->GetSize().x / 2,tempLabel->GetSize().y / 2);
sf::Text* tempText = tempLabel->GetText();
switch(orgin){
case(TopLeft):
tempLabel->SetOrgin(0,0);
tempLabel->CenterText();
break;
case(TopRight):
tempLabel->SetOrgin(halfSize.x * 2,0);
tempLabel->CenterText();
break;
case(BottomLeft):
tempLabel->SetOrgin(0,halfSize.y * 2);
tempLabel->CenterText();
break;
case(BottomRight):
tempLabel->SetOrgin(halfSize.x * 2,halfSize.y * 2);
tempLabel->CenterText();
break;
}
}
};
示例2: SetUpItemMap
void StatsPanel::SetUpItemMap(){
int labelsPosX[] = {5,155,5,165,5,135};
int labelsPosY[] = {160,160,230,230,300,300};
std::string labelsString[] = {"Strength","Endure","Technique","Speed","Mining","Woodcutting"};
for (int x = 0; x < 6; x++){
Label* element = new Label(labelsPosX[x],labelsPosY[x],"blank.png",Label::Fonts::Game,labelsString[x] + ":");
Label* valueElement = new Label(labelsPosX[x] + element->GetText()->getLocalBounds().width + 15,labelsPosY[x],"blank.png",Label::Fonts::Game,"null");
AddItemElement(MyPair(std::to_string(x), element));
AddItemElement(MyPair(labelsString[x] + "Value",valueElement));
}
Button* tempButton = new Button(127.5,15,"attacktextures/background.png","attacktextures/default.png");
tempButton->SetTarget(this);
tempButton->SetFunction("none");
tempButton->CenterForeground();
AddItemElement(MyPair("Image",tempButton));
Label* label = new Label(103,110,120,"menubackground.png",Label::Fonts::Game,"null");
label->CenterText();
AddItemElement(MyPair("Name",label));
Drawn* barPlaceHolder = new Drawn("blank.png");
barPlaceHolder->SetPosition(sf::Vector2f(0,0));
barPlaceHolder->texturePart.height = 35;
barPlaceHolder->texturePart.width = GetSize().x;
barPlaceHolder->SetRotation(0);
barPlaceHolder->SetZ(2);
itemMap.insert(MyPair("barPlaceHolder",barPlaceHolder));
};