Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Sf::Text goes to left  (Read 1392 times)

0 Members and 1 Guest are viewing this topic.

anttton

  • Newbie
  • *
  • Posts: 17
    • View Profile
    • Email
Sf::Text goes to left
« on: October 29, 2017, 08:41:44 pm »
Hello guys!
I have a problem when it comes to the text. The text goes to the left side when I type longer
sentences and I want it to the right side instead.
sf::Text::setPosition(this->window->getSize().x / 2 - sf::Text::getGlobalBounds().width / 2 - 30, this->window->getSize().y - sf::Sprite::getGlobalBounds().height - 280);


If you see the picture you will probably understand what the problem is :P

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Sf::Text goes to left
« Reply #1 on: October 29, 2017, 09:02:34 pm »
Text starts at its X position. If it goes to the left, then it means that you decrease this X position somehow in your code -- so don't do it ;)
Laurent Gomila - SFML developer

Hapax

  • Hero Member
  • *****
  • Posts: 3364
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Sf::Text goes to left
« Reply #2 on: October 29, 2017, 10:37:38 pm »
Are you using un-instanced method calls for sf::Text and sf::Sprite or is this a typing error?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

anttton

  • Newbie
  • *
  • Posts: 17
    • View Profile
    • Email
Re: Sf::Text goes to left
« Reply #3 on: November 04, 2017, 05:42:57 pm »
Sorry for late reply, Thanks for the help but the only problem was that I delete the X pos of the text by sf::Sprite::getGlobalBounds()  ;D