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

Author Topic: How to get size of the scaled sprite texture  (Read 10661 times)

0 Members and 1 Guest are viewing this topic.

Putarda

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
How to get size of the scaled sprite texture
« on: September 10, 2016, 11:38:23 pm »
As title says how can i get size of the scaled sprite texture?
« Last Edit: September 11, 2016, 12:24:48 am by Putarda »

Putarda

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Re: How to get size of the scaled sprite texture
« Reply #1 on: September 11, 2016, 10:26:08 am »
Fixed by calling sprite.getGlobalBounds()

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: How to get size of the scaled sprite texture
« Reply #2 on: September 12, 2016, 03:02:08 pm »
Note that getGlobalBounds will most likely not give you the desired result if the sprite is rotated.

You can, though, use something like this:
const sf::Vector2f spriteSize(
    sprite.getTexture()->getSize().x * sprite.getScale().x,
    sprite.getTexture()->getSize().y * sprite.getScale().y);
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*