SFML community forums
Help => General => Topic started by: neml on May 03, 2015, 08:50:27 pm
-
Hi guys! :)
I'm starting to develop my first game, and I need the user to enter his/her age before the game itself starts, as I need the age to calculate other game parameters.
The numbers entered are being stored in an sf::String, so that they can be displayed, but I don't know how to convert them from sf::String to int.
At first I thought about using an std::string and then converting to int with atoi, but I'm not sure I can display text if it's not of type sf::String :-\ .
Any ideas?
-
Converting your string into an int doesn't mean you can't keep it for display purpose.
You can have a string variable AND an integer variable.
-
sf::String is implicitly convertible to std::string. Then the std::string to int conversion is a trivial thing in C++, that you can easily learn to do with the help of Google.
-
sf::String is implicitly convertible to std::string. Then the std::string to int conversion is a trivial thing in C++, that you can easily learn to do with the help of Google.
Thank you! I hadn't realized sf::String was convertible to std::string