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

Author Topic: sf::String->SetAlign()?  (Read 1206 times)

0 Members and 1 Guest are viewing this topic.

Dinocool

  • Newbie
  • *
  • Posts: 24
    • View Profile
sf::String->SetAlign()?
« on: May 26, 2009, 07:53:37 am »
I don't know if this is a feature request but anyways, i recently just upgraded my engine from HGE to SFML :D and was wondering if anyone had a piece of code to align the text to the center, all i have so far is

Code: [Select]

        //center
if (align == 2)
string.SetCenter((strlen(text.c_str())*size)/2,0);
        //right
if (align == 1)
string.SetCenter((strlen(text.c_str())*size),0);


But it doesn't work the way it should... any advice???

Dinocool

  • Newbie
  • *
  • Posts: 24
    • View Profile
sf::String->SetAlign()?
« Reply #1 on: May 26, 2009, 07:55:54 am »
wait, nm figured it out :D

Code: [Select]

if (align == 2)
string.SetCenter(string.GetRect().GetWidth()/2,0);
if (align == 1)
string.SetCenter(string.GetRect().GetWidth(),0);


for all those who were wondering

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4328
    • View Profile
    • Email
sf::String->SetAlign()?
« Reply #2 on: May 26, 2009, 04:51:54 pm »
Code: [Select]
strlen(text.c_str())  :shock:
Better C++ usage :
Code: [Select]
text.size() :wink:
SFML / OS X developer