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

Author Topic: SetSubRect or Multiple Sprites ?  (Read 2208 times)

0 Members and 1 Guest are viewing this topic.

koolgraph

  • Newbie
  • *
  • Posts: 48
    • View Profile
SetSubRect or Multiple Sprites ?
« 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.

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
SetSubRect or Multiple Sprites ?
« Reply #1 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 :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SetSubRect or Multiple Sprites ?
« Reply #2 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.
Laurent Gomila - SFML developer

koolgraph

  • Newbie
  • *
  • Posts: 48
    • View Profile
SetSubRect or Multiple Sprites ?
« Reply #3 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.