SFML community forums
Help => Graphics => Topic started 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
//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???
-
wait, nm figured it out :D
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
-
strlen(text.c_str())
:shock:
Better C++ usage :
text.size()
:wink: