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

Author Topic: setTextureRect() or setTexture()  (Read 4853 times)

0 Members and 1 Guest are viewing this topic.

dverg

  • Newbie
  • *
  • Posts: 1
    • View Profile
setTextureRect() or setTexture()
« 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 :)

masskiller

  • Sr. Member
  • ****
  • Posts: 284
  • Pointers to Functions rock!
    • MSN Messenger - kyogre_jb@hotmail.com
    • View Profile
    • Email
Re: setTextureRect() or setTexture()
« Reply #1 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.
Programmer, Artist, Composer and Storyline/Script Writer of "Origin of Magic". If all goes well this could turn into a commercial project!

Finally back into the programming world!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: setTextureRect() or setTexture()
« Reply #2 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 ;)
Laurent Gomila - SFML developer

masskiller

  • Sr. Member
  • ****
  • Posts: 284
  • Pointers to Functions rock!
    • MSN Messenger - kyogre_jb@hotmail.com
    • View Profile
    • Email
Re: setTextureRect() or setTexture()
« Reply #3 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.
Programmer, Artist, Composer and Storyline/Script Writer of "Origin of Magic". If all goes well this could turn into a commercial project!

Finally back into the programming world!

 

anything