SFML community forums

Help => General => Topic started by: prchakal on February 26, 2011, 05:10:15 am

Title: How to write text on screen - SFML2
Post by: prchakal on February 26, 2011, 05:10:15 am
Hi,

When i use SFML 1.6, i use the following code to write text to screen:

Code: [Select]

sf::String textBullets( "Bullets: " + StringConverter::toString(GameObjects::bullets->size()) );
textBullets.SetPosition(5, 25);
textBullets.SetSize(13);

App.Draw(textBullets);


But i get error when use SFML2, the methods SetPosition doesnt exists and Add.Draw doesnt work with sf::String.

What i need do?

And how to use custom fonts?
Title: How to write text on screen - SFML2
Post by: WitchD0ctor on February 26, 2011, 07:04:20 am
its been renamed, all you need to change is,

sf::String to sf::Text,


and change .SetSize to .SetCharacterSize,
and it should work as expected
Title: How to write text on screen - SFML2
Post by: prchakal on February 26, 2011, 04:06:55 pm
And aboout custom fonts?
Title: How to write text on screen - SFML2
Post by: lakunar on February 26, 2011, 04:09:38 pm
Code: [Select]

sf::Font    font;
sf::Text    text;
if(!font.LoadFromFile("verdana.ttf")){
    //error
}
text.SetFont(font);


All about text:
http://www.sfml-dev.org/documentation/2.0/classsf_1_1Text.htm