SFML community forums

Help => Graphics => Topic started by: runizgozilla on June 22, 2014, 11:20:36 pm

Title: Updating a sprite sheet animation
Post by: runizgozilla on June 22, 2014, 11:20:36 pm
I'm updating my animation with this line:
Code: [Select]
animation.setTextureRect(IntRect((frame-1)*16, 0, 16, 16));Where frame is a number between 0 and 9 and 16 is the width and height of an individual frame of my sprite sheet.

This gives me the first frame and not anything else.

Why doesn't this work?
Title: Re: Updating a sprite sheet animation
Post by: runizgozilla on June 22, 2014, 11:26:02 pm
Through experimentation I can now definitely say that if you initialize a texture at the first frame nothing else will be loaded.  Sorry for wasting everyone's time the second time in just under 24 hours.
Title: Re: Updating a sprite sheet animation
Post by: Mutoh on June 24, 2014, 10:27:02 pm
Ever considered Thor (http://en.sfml-dev.org/forums/index.php?topic=7329.0)? :D Its animation modules already take care of all this for you, and it's built on top of SFML.
Title: Re: Updating a sprite sheet animation
Post by: Hapax on June 29, 2014, 03:37:47 pm
If the range of frame is 0-9, I don't think you should be subtracting 1 from it.