SFML community forums

Help => Graphics => Topic started by: Sazabi02 on January 09, 2009, 01:06:18 pm

Title: Center-aligned texts using sf::string
Post by: Sazabi02 on January 09, 2009, 01:06:18 pm
I've been trying so hard to make this work for a button class that I made so that the text would be in the middle but somehow I can't find anyway to do it.

I tried doing:
Code: [Select]

sf::String text;
text.Move( x + buttonWidth / 2 - text.GetRect().GetWidth() / 2, y + buttonHeight / 2 - GetRect().GetHeight());
App.Draw(text);


Can anyone help please? I'm kinda stumped here. Whenever I do that code the bounding rectangle turns out a little bit closer to the top left side instead of being at the center.