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

Author Topic: Display a value *Solved*  (Read 4328 times)

0 Members and 1 Guest are viewing this topic.

Heero

  • Newbie
  • *
  • Posts: 3
    • View Profile
Display a value *Solved*
« on: October 19, 2007, 01:24:06 pm »
Is it possible to display a value in a window?
I want you display the mouse position in a window, but String can only handle std::strings.
Must I convert my float value to string to be able to display the text?

Heero

*Solved*

It now works, i use this code to display a value in the window.

Code: [Select]
_itoa(Sprite.GetRotation(), buffer, 10);
String.SetText(buffer);

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Display a value *Solved*
« Reply #1 on: October 20, 2007, 06:42:38 am »
A better way in C++ is to use stringstreams :
Code: [Select]
#include <sstream>

std::ostringstream oss;
oss << Sprite.GetRotation();
String.SetText(oss.str());
Laurent Gomila - SFML developer

Heero

  • Newbie
  • *
  • Posts: 3
    • View Profile
Display a value *Solved*
« Reply #2 on: October 20, 2007, 02:44:31 pm »
Thanks Laurent, thats looks much better :)