Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML 1.6 Sprite Animation?  (Read 2496 times)

0 Members and 1 Guest are viewing this topic.

xwolf1337

  • Newbie
  • *
  • Posts: 1
    • View Profile
SFML 1.6 Sprite Animation?
« on: July 10, 2012, 05:35:15 am »
I have searched all over Google and was not able to find any tutorials so can anyone explain it to me? I have a sprite sheet if thats what SFML uses.

thePyro_13

  • Full Member
  • ***
  • Posts: 156
    • View Profile
Re: SFML 1.6 Sprite Animation?
« Reply #1 on: July 10, 2012, 08:16:00 am »
SFML doesn't directly support animations, but you can build the functionallity yourself quite easily or use the example code from the Wiki. Such as this article from the old wiki.

If you move across to SFML2 then you could use Thor's animation library.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Re: SFML 1.6 Sprite Animation?
« Reply #2 on: July 11, 2012, 05:21:38 pm »
If you move across to SFML2 then you could use Thor's animation library.

... which you most defenetly should do!

FYI an animation is nothing else than a fast change of images. Or eyes can't really see a difference above 60 images (aka frames) per second, but the animating effect already works with 24 fps or it event works with 12 fps when you just repeate every image twice. Animations with a lower rate as 12 fps will most likely seem to stutter pretty badly.

No to implement such a thing you need a sprite sheet (check :P), then you load that into an image (in SFML 2 texture [way faster]) and then just change the subrect to fit one sprite and move to the next one every update call. In the update loop or if you use a class for animation within the class itself, you have to make sure to call the update function for the animation at the wanted rate (60 fps, 24 fps, 12 fps, ...).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/