SFML community forums

Help => Graphics => Topic started by: koolgraph on February 17, 2011, 04:05:16 pm

Title: SetSubRect or Multiple Sprites ?
Post by: koolgraph on February 17, 2011, 04:05:16 pm
What should be done, getting some SetSubRect for Animating a sprite, or, giving the impression of animating it by replacing it with another sprite ?

I think it should be better to load more sprite since it takes a bit more memory, but i guess it saves some CPU.
Title: SetSubRect or Multiple Sprites ?
Post by: Grimshaw on February 17, 2011, 04:19:28 pm
In my opinion, creating many sprites is not a good option at all.

A good choice is to have one Sprite, and assign multiple images as you need them.

A even better way, is to have one sprite and one image, and use SubRect for changing the texcoords only :)

Spritesheets exist for a reason :)
Title: SetSubRect or Multiple Sprites ?
Post by: Laurent on February 17, 2011, 04:41:40 pm
SetSubRect is almost free, all it does is storing the sf::IntRect that you pass. It consumes no CPU.
Title: SetSubRect or Multiple Sprites ?
Post by: koolgraph on February 17, 2011, 05:12:33 pm
i was planning using a spritesheet, i'm not that dumb XD that's why i asked for SetSubRect()

thanks Laurent, so i'll set up a list of rect.