本文整理汇总了C++中sf::Text::setScale方法的典型用法代码示例。如果您正苦于以下问题:C++ Text::setScale方法的具体用法?C++ Text::setScale怎么用?C++ Text::setScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Text
的用法示例。
在下文中一共展示了Text::setScale方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void Item::Draw(sf::RenderWindow& renderWindow, sf::Text &text)
{
TextureManager *t = Resources::getTextureManager("tileMap");
sf::Sprite s;
sf::Vector2f item_pos = GetPosition();
t->generateSprite(id, item_pos, s, sf::Vector2f(GetWidth(),GetHeight()));
renderWindow.draw(s);
sf::Vector2f test_pos = GetPosition();
text.setPosition(test_pos.x, test_pos.y);
text.setScale(sf::Vector2f(1.5,1.5));
renderWindow.draw(text);
//renderWindow.draw(_sprite);
/*if(amount >0){
char c[10];
sprintf(c, "%i", amount);
std::string string(c);
sf::String str(string);
text.setString(str);
text.setPosition(GetPosition().x, GetPosition().y);
renderWindow.draw(text);
}*/
}
示例2: resize
void resize(sf::Text& text, float width, float height)
{
int local_width = text.getLocalBounds().width;
int local_height = text.getLocalBounds().height;
if ((local_width > 0) && (local_height > 0))
text.setScale(width / local_width, height / local_height);
}
示例3: transformSprite
void GraphicEngine::transformSprite(sf::Text& sprite, const Transformation& t, const Color& color)
{
if (t.hasPosition())
sprite.setPosition((float)t.getX(), (float)t.getY());
if (t.hasRotation())
sprite.rotate(t.getRotation());
if (color.isUsed())
sprite.setColor(sf::Color(color.getColor()));
if (t.hasScale())
sprite.setScale(t.getScaleX(), t.getScaleY());
}
示例4:
GameEnd(sf::String message, float durationParam = 1.0f) :
timer(0.0f),
duration(durationParam),
color(0xff, 0, 0, 0)
{
text.setFont(font);
text.setCharacterSize(64);
text.setScale(0.002f, 0.002f);
text.setString(message);
}
示例5: Run
int PlayerConnection::Run(sf::RenderWindow &mainWin, int screen)
{
if (!this->font.loadFromFile("resources/fonts/" + DEFAULT_FONT))
{
std::cerr << "Error loading the font " + DEFAULT_FONT << std::endl;
system("pause");
return (-1);
}
this->initializeItems();
sf::Event Event;
//Boucler tant que la fenêtre n'est pas fermée
while (true)
{
bool usernameIsValid = username.size() > 3;
//Vérifier les événements
while (mainWin.pollEvent(Event))
{
if (Event.type == sf::Event::Closed)
{
return (-1);
}
if (Event.type == sf::Event::TextEntered) //On veut seulement les caracteres ASCII
{
bool isANumber = (Event.text.unicode >= 48 && Event.text.unicode <= 57);
bool isALetter = (Event.text.unicode >= 65 && Event.text.unicode <= 90) || (Event.text.unicode >= 97 && Event.text.unicode <= 122);
if (username.size() < 13 && (isANumber || isALetter))
{
username += static_cast<char>(Event.text.unicode);
}
}
if (Event.type == sf::Event::KeyReleased && Event.key.code == sf::Keyboard::BackSpace)
{
username = "";
}
if (Event.type == sf::Event::MouseButtonReleased)
{
sf::Vector2f mouse_coords = sf::Vector2f(Event.mouseButton.x, Event.mouseButton.y);
if (intersects(mouse_coords, start.getGlobalBounds()) && usernameIsValid)
{
return (MENU);
}
else if (intersects(mouse_coords, nameContainer.getGlobalBounds()))
{
username = "";
}
}
if (Event.type == sf::Event::MouseMoved)
{
sf::Vector2f mouse_coords = sf::Vector2f(Event.mouseMove.x, Event.mouseMove.y);
if (intersects(mouse_coords, start.getGlobalBounds()))
{
start.setColor(sf::Color::Red);
start.setScale(1.05, 1.05);
}
else
{
start.setColor(sf::Color::White);
start.setScale(1,1);
}
}
nameDisplay.setString(username);
}
mainWin.clear();
mainWin.draw(spriteLogo);
mainWin.draw(text);
if (!usernameIsValid)
{
nameContainer.setOutlineColor(sf::Color::Red);
}
else
{
nameContainer.setOutlineColor(sf::Color::White);
}
mainWin.draw(nameContainer);
mainWin.draw(nameDisplay);
mainWin.draw(start);
mainWin.display();
}
//On ne devrait jamais se rendre jusqu'à ce point, mais juste au cas, on ferme l'application.
//.........这里部分代码省略.........
示例6: setnbAttempTextScale
inline void ManageLevel::setnbAttempTextScale(sf::Vector2f _pos)
{
m_nbAttemp.setScale(_pos);
};
示例7: Text
inline Text(Ctx& mCtx, const Vec2f& mPos)
: Base{mCtx, mPos}, impl{"", *Assets::get().liberationSans, 30}
{
impl.setScale(0.f, 0.f);
impl.setColor(sf::Color::White);
}