-
How would I go about displaying a variable to the string, like a score or something?
-
Convert to string with std::to_string (http://en.cppreference.com/w/cpp/string/basic_string/to_string) then draw as sf::Text (http://www.sfml-dev.org/documentation/2.3/classsf_1_1Text.php).
-
sf::Text DisplayedScore;
std::string Score_str = std::to_string(DisplayedScore);//like this?
-
Have you considered trying?
But no. Not quite like that. Please read the documentation I linked to carefully.
-
well, no I haven't I will though, 1 sec
-
ok so I have done this, what am I doing wrong?
std::string Score_str = std::to_string(Score);
DisplayedScore.setString(Score);//I get an error saying more than one constructo applies to
//convert int to string
-
Check the name of variable you're passing to setString.
-
Dude you should really get a c++ book and actually read it before getting into SFML.
DisplayedScore.setString(Score_str);
-
hey don't hate, I've only been at this stuff for a little while now, I know what I'm doing, and getting more and more stuff learned everyday, so just don't hate m8.
-
You don't seem to know what you're doing. ???
-
hey don't hate, I've only been at this stuff for a little while now, I know what I'm doing, and getting more and more stuff learned everyday, so just don't hate m8.
Nobody is hating. Just stating plain and simple that you don't seem to know what you are doing. And I personally agree. You are asking very basic and simple questions that clearly show you don't have a strong grasp of C++. I'd advice reading a few good books and doing some simple practice programs.
Also, your questions tend to have little to do with SFML and more to do with your lack of C++ knowledge, so they are not really all that relevant on this forum (IMHO).
Not hating. Just stating facts as I see them.
-
well I decided I was sick of looking at a console window, so I decided to learn SFML, I know I don't know C++ all too well, but its my first language, so please Understand I don't always know what I'm doing I understand a lot more than when I started (a few months ago).
-
You are resetting the timer every time ResetPosition() is called. So if it is called more than once every second the value that restart() returns will always be less than a second.
Also. You are not modifying "elapsed" so it will never change its value.
-
You are resetting the timer every time ResetPosition() is called. So if it is called more than once every second the value that restart() returns will always be less than a second.
Also. You are not modifying "elapsed" so it will never change its value.
I made a new topic over this
-
If you want some gui, try QT or MFC or any other high level gui toolkit.