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

Author Topic: Converting INT to STRING.  (Read 1354 times)

0 Members and 1 Guest are viewing this topic.

tyrenzo

  • Newbie
  • *
  • Posts: 1
    • View Profile
Converting INT to STRING.
« on: May 19, 2012, 02:13:54 pm »
Hello,
Ran into some problems converting int to string before, it compiles and runs fine but doesn't actually display.

Heres the code:


sf::String Text_score;                                          // create a string of text to display
         std::stringstream Score;
         Score << "Score " << ScoreNumber;
         Text_score.SetText(Score.str());
         Text_score.SetFont(Cheeseburger);
         Text_score.SetSize(35);
         Text_score.SetColor(sf::Color::White);
         Text_score.SetPosition(150.f, 200.f);

          App.Draw(Text_score);


Can anyone shed any light on it?

Cheers

iHope

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Converting INT to STRING.
« Reply #1 on: May 19, 2012, 08:12:09 pm »
Hi, I used very similar score system in my Pong! - game. I'm not going to give you a hint, just the code.

Note: This is SFML 1.6 version code!
Code: [Select]

#include <sstream>

...

App.clear();

std::ostringstream oss;
oss << points;
sf::String ret;
ret.SetFont(Fontti);
ret.SetPosition(20.f, 10.f);
ret.SetSize(25);
ret.SetColor(sf::Color::White);
ret.SetText(oss.str());

....

App.draw(ret);