SFML community forums

Help => Graphics => Topic started by: dverg on February 12, 2013, 09:03:11 pm

Title: setTextureRect() or setTexture()
Post by: dverg on February 12, 2013, 09:03:11 pm
Hi

sorry, if this question is already answered, but I got a database error while using the search function...

I'm just switched to SFML 2 and currently I'm reading through the documentation. The new way to use sf::Sprite with sf::Texture instead of sf::Image seems very interesting to me.

But here is my question:
If I want to implement an animation, would it be better have several sf::Texture's and switch the images from the animation with sf::Sprite::setTexture().
Or is the better way to have one large sf::Texture containing all the animation images and then, each time the image should change, calling the function sf::Sprite::setTextureRect().

thanks and I apologize for my bad english :)
Title: Re: setTextureRect() or setTexture()
Post by: masskiller on February 12, 2013, 09:46:55 pm
setTextureRect(), constantly binding new textures is slow and painful.

Thor has some animation classes and there's also class for that in the wiki if you don't want to reinvent the wheel.
Title: Re: setTextureRect() or setTexture()
Post by: Laurent on February 12, 2013, 10:12:12 pm
Quote
setTextureRect(), constantly binding new textures is slow and painful.
This argument is relevant only if you only have one texture in your whole game, otherwise it doesn't make any difference ;)
Title: Re: setTextureRect() or setTexture()
Post by: masskiller on February 13, 2013, 02:53:15 am
Quote
setTextureRect(), constantly binding new textures is slow and painful.
This argument is relevant only if you only have one texture in your whole game, otherwise it doesn't make any difference ;)

True, I didn't express myself as well as I should have.