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

Author Topic: Can't change sprite image  (Read 8603 times)

0 Members and 1 Guest are viewing this topic.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Can't change sprite image
« Reply #15 on: August 15, 2009, 06:42:27 pm »
Quote from: "forrestcupp"

In the meantime, you can just call
Code: [Select]
sprite.SetImage(sf::Image());before you set it with the new image, and it will clear the old subrect settings along with everything else from the old image.

That sounds like using a sledge-hammer to crack a nut. Why don't you just set the SubRect?!

forrestcupp

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Can't change sprite image
« Reply #16 on: August 15, 2009, 10:51:07 pm »
I never could get that to work properly.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Can't change sprite image
« Reply #17 on: August 16, 2009, 10:37:55 pm »
Code: [Select]
sf::Image   img( 32, 32, sf::Color( 255, 255, 255 ) );
sf::Sprite  spr( img );

img.Create( 64, 64, sf::Color( 255, 0, 0 ) );
spr.SetSubRect( sf::IntRect( 0, 0, 64, 64 ) );


Works like a charm. ;)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Can't change sprite image
« Reply #18 on: August 16, 2009, 11:37:15 pm »
Instead of writing this again and again, create the function I mentioned earlier.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything