SFML community forums

Help => Graphics => Topic started by: Dinocool on May 26, 2009, 07:53:37 am

Title: sf::String->SetAlign()?
Post by: Dinocool 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???
Title: sf::String->SetAlign()?
Post by: Dinocool 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
Title: sf::String->SetAlign()?
Post by: Hiura on May 26, 2009, 04:51:54 pm
Code: [Select]
strlen(text.c_str())  :shock:
Better C++ usage :
Code: [Select]
text.size() :wink: