Use sf::Clock
(doc).
Declare your clock along with your other variables before your main loop, this also starts the clock automatically. In your loop, check for the time elapsed and reset the clock if it exceeds what you want. Example :
sf::Clock myClock; // starts the clock
bool showCursor = false;
// ...
wnd.draw(myTxt);
if(clock.getElapsedTime() >= sf::milliseconds(500))
{
clock.restart();
showCursor = !showCursor;
if(showCursor)
myTxt.setString("Hello World!_");
else
myTxt.setString("Hello World!");
}
// ...
This should give you a cursor blinking by 0.5 second.
By the way, why are you using std::if()
instead of a plain if
that is included in the language ?