SFML community forums

Help => General => Topic started by: wooshj on June 22, 2017, 01:21:40 pm

Title: Using multiple sprite images for movement
Post by: wooshj on June 22, 2017, 01:21:40 pm
Using a spritesheet what is the best way to show a character moving? Is loading in each different image the best way to do it? For example if I click the W key it shows the image of character facing up, then if the I press S it clears the screen and draws the sprite of the character facing down. Is this the best way to do it? Reason I ask is because I saw a video of a guy who cropped the image using setTextureRect and just cropping the spriteSheet right in the game.
Title: Re: Using multiple sprite images for movement
Post by: eXpl0it3r on June 22, 2017, 05:25:07 pm
Use one texture and change the texture rect to get the correct animation frame.

And you need to clear, draw, display every frame. Don't try to just "update" the screen when needed.
Title: Re: Using multiple sprite images for movement
Post by: wooshj on June 22, 2017, 06:39:18 pm
Alright thanks. For some reason the way i was thinking about it was you would load the spritesheet onto the screen then cut it out and hide that spritesheet lol, now it makes a lot more sense.