Why do we suddenly have such an influx of users from CodingMadeEasy?
His tutorials are not good at all, lots of mistakes, bad C++, bad and wrong explanations - see
here and
here.
The code piece here shows this as well... I'm not sure what his logic behind this really is, but it's not such a good way imho. It's way more helpful to work with "animation frames per second".
The code here uses a random speed factor then multiplies that with the frametime (I think) and adds it up. Once the counter has reached another random number (switchFrame), the if condition will be met and I guess the frame gets updated?
There's a nice AnimatedSprite class on the
SFML Wiki. And as alternative, you can also take a look at
Thor's animation module.