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

Author Topic: SetImage  (Read 3091 times)

0 Members and 1 Guest are viewing this topic.

bobbyport

  • Newbie
  • *
  • Posts: 4
    • View Profile
SetImage
« 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?

bobbyport

  • Newbie
  • *
  • Posts: 4
    • View Profile
SetImage
« Reply #1 on: June 28, 2009, 05:28:48 am »
Nevermind, I guess I must set manually with: sprite::SetSubRect()

K-Bal

  • Full Member
  • ***
  • Posts: 104
    • View Profile
    • pencilcase.bandcamp.com
    • Email
SetImage
« Reply #2 on: June 28, 2009, 10:12:21 am »
Quote from: "bobbyport"
Nevermind, I guess I must set manually with: sprite::SetSubRect()


Thats how it is ;)
Listen to my band: pencilcase.bandcamp.com

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
SetImage
« Reply #3 on: July 06, 2009, 11:10:10 pm »
I also hated that  :lol:

You can also do a
Code: [Select]
spr.SetImage(Image());
spr.SetImage(theImage);

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: SetImage
« Reply #4 on: July 07, 2009, 11:09:07 am »
Quote from: "bobbyport"
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. ;)

Code: [Select]
void AdaptImage(sf::Sprite& Sprite, const sf::Image& NewImage)
{
    Sprite.SetImage(NewImage);
    Sprite.SetSubRect(sf::IntRect(0, 0, NewImage.GetWidth(), NewImage.GetHeight()));
}
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: