Hello
What you would have to do (the easiest way) is to store the image (the sprite sheet) to a Texture, then supposedly you would have and index into your main character's draw method or function that you pass to the vector or matrix which contains the data of each rectangle that contains every sub picture that your character may display at each frame. Your character, so as the other STAFF in your game may be in different attitudes, such as walking, jumping, swimming, dying, etc. That logic in your code will decide, appart from the location on the screen and other circumstances, which of all the sub pictures from the character's sprite sheet will be drawn at each frame.
You would need to open your sprite sheet file in your picture Editor, and see for every sub picture in the sheet, its left, top, width, and height.
Then you can have a matrix like this in your character class:
int matrix[][] = new int[][] { new int[] { x1, y1, w1, h1 }, new int[] { x2, y2, w2, h2}, ... };
with so many vectors as subpictures are in your sprite sheet
And into your method or function (texture contains your sprite sheet):
Sprite hero = new Sprite(texture);
hero.TextureRect = new IntRect(matrix[index][0], matrix[index][1], matrix[index][2], matrix[index][3]);
hero.Position = new Vector2f(yourX, yourY);
window.Draw(hero);
Maybe your index (int) variable could be from 1 to 4 while the hero is walking (this means 4 sub pictures of the hero walking), 0 while it is stopped, 5 when it jumps, etc, depending on your input, or other cases such as if you are beaten, or you collide with a wall or a ceiling.
You can have a variable for the state (walking, jumping, etc), and another for the progress of each of them. For example, state = States.Walk and step = 1 (to 4) for each of the sub pictures that shape the walking animation
if (state == States.Stop)
{
index = 0;
}
else if (state == States.Walk)
{
index = step / 5 + 1; // + 1 because it goes from 1 to 4, remember 0 is the index for stopped
step++;
if (step == 20)
step = 0;
}
// before, when you (suppose) "land"
state = States.Walk;
step = 0;
You can scan in my poor Super Mario source code the logic for animation. (I hope, because it's not the most tidy in the world)
https://www.dropbox.com/s/hfkxetoxs5iv10i/My%20New%20Super%20Mario%20Bros%20Folder.rar?dl=0Please let me know if you progress or if you have any more doubts