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

Author Topic: How to write text on screen - SFML2  (Read 3846 times)

0 Members and 1 Guest are viewing this topic.

prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
How to write text on screen - SFML2
« 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?

WitchD0ctor

  • Full Member
  • ***
  • Posts: 100
    • View Profile
    • http://www.teleforce-blogspot.com
How to write text on screen - SFML2
« Reply #1 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
John Carmack can Divide by zer0.

prchakal

  • Full Member
  • ***
  • Posts: 142
    • View Profile
How to write text on screen - SFML2
« Reply #2 on: February 26, 2011, 04:06:55 pm »
And aboout custom fonts?

lakunar

  • Newbie
  • *
  • Posts: 20
    • View Profile
How to write text on screen - SFML2
« Reply #3 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