SFML community forums
Help => Graphics => Topic started by: bobbyport on June 28, 2009, 04:49:18 am
-
When I .SetImage()
It seems the sprite's width and height remain the same.... Must I manually change the dimensions to match the new image, or is there a way for automation?
-
Nevermind, I guess I must set manually with: sprite::SetSubRect()
-
Nevermind, I guess I must set manually with: sprite::SetSubRect()
Thats how it is ;)
-
I also hated that :lol:
You can also do a
spr.SetImage(Image());
spr.SetImage(theImage);
-
Must I manually change the dimensions to match the new image, or is there a way for automation?
There is always a way for automation. ;)
void AdaptImage(sf::Sprite& Sprite, const sf::Image& NewImage)
{
Sprite.SetImage(NewImage);
Sprite.SetSubRect(sf::IntRect(0, 0, NewImage.GetWidth(), NewImage.GetHeight()));
}