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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Demian

Pages: 1 [2]
16
Graphics / sf::string Text using as sprintf?
« on: April 09, 2010, 10:22:04 pm »
Hello

I want to use the sf::string class to print a variable, just as printf and sprintf in DOS.
I tried something like this:

Code: [Select]

//...
sf::Image Image;
    sf::Font MyFont;
    if (!Image.LoadFromFile("Bubbles.png") ||
        !MyFont.LoadFromFile("arial.ttf", 50))
           return EXIT_FAILURE;

    sf::String Hello;
    Hello.SetText("Pos y : %f Pos x : %f " ,Posy, Posx);
    Hello.SetFont(MyFont);
    Hello.SetColor(sf::Color(0, 128, 128));
    Hello.SetPosition(100.f, 100.f);
    Hello.SetRotation(15.f);
    Hello.SetSize(50.f);


The coordinates ought to show the point of the picture, but it didnt work.
I figured out "SetText" can only contain a naked text without variables.
Code: [Select]
C:\...\main.cpp|34|error: no matching function for call to `sf::String::SetText(float&)'|

Now I wonder if there is any way to pass out a variable to the window with SFML.
In case I ignored something in the tuts don't be mean to me, please!
(I really was searching for the answer!)

Thank you : )

Pages: 1 [2]