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

Author Topic: sf::Sprite has no member named GetSize  (Read 12056 times)

0 Members and 1 Guest are viewing this topic.

N1ghtly

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
sf::Sprite has no member named GetSize
« on: January 08, 2012, 08:05:15 pm »
Hello all,

I'm trying to get sfml up and running on linux. I downloaded the latest Git snapshot and compiled. I link correctly to the libs, yet I keep getting the error stated in the title.

Any suggestions?

texus

  • Sr. Member
  • ****
  • Posts: 499
    • View Profile
    • TGUI
    • Email
sf::Sprite has no member named GetSize
« Reply #1 on: January 08, 2012, 08:15:45 pm »
You are probably calling Sprite.GetSize() somewhere, but this function doesn't exist.
You probably found the function in the sfml 1.6 tutorial, but it seems to be removed in sfml2.

After a quick look in Sprite.hpp I think you will need GetTextureRect.
This function is a little bit different (it returns a rect instead of the size), but I think it will give you the same result.

Otherwise you can call Texture.GetWidth() and Texture.GetHeight() to find out what the size of the texture is.
TGUI: C++ SFML GUI

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::Sprite has no member named GetSize
« Reply #2 on: January 08, 2012, 08:30:11 pm »
TextureRect doesn't take the scale in account. The correct replacement is sprite.GetGlobalBounds(), which returns the bounding rectangle. You can then extract its width/height.
Laurent Gomila - SFML developer

N1ghtly

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
sf::Sprite has no member named GetSize
« Reply #3 on: January 09, 2012, 08:40:47 pm »
Thanks, I wasn't aware these functions had been removed. I used an older version of SFML 2 before this.

 

anything