@Jicehel, you could have cited your source and indicated the origin of this post in the first place:
Besides, this little piece of code is not a tutorial but only outlines the guidelines for animating a sprite.
Finally, I think it’s much more interesting to give a link to the full tutorial, which deals with the subject in a much more extensive way: