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

Author Topic: SFML 2.0 sf::Rect usage.  (Read 1619 times)

0 Members and 1 Guest are viewing this topic.

sec_goat

  • Newbie
  • *
  • Posts: 17
    • View Profile
SFML 2.0 sf::Rect usage.
« on: November 18, 2011, 09:13:16 pm »
Are sf::Rects attached or managed by another class like sf::Sprite or are they self managed?
For instance if sf::Rect is part of sf::Sprite, does sf::Sprite update the sf::Rect position so we can easily do the sf::Rect< T >::Intersects,
or do I have to create and manage  sf::Rect objects manually?
   
I am looking into the documentation but I am not seeing anything that directly answers this question, so I will assume I need to create and manage rect locations manually.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2.0 sf::Rect usage.
« Reply #1 on: November 18, 2011, 09:27:32 pm »
Why would a sprite update its subrect position? The subrect is the area of the texture that the sprite displays, it mustn't move.

If you want to get the bounding rectangle of your sprite in the 2D scene, you must compute it yourself. There are some threads on this forum that explain how to do this.
Laurent Gomila - SFML developer

sec_goat

  • Newbie
  • *
  • Posts: 17
    • View Profile
SFML 2.0 sf::Rect usage.
« Reply #2 on: November 18, 2011, 09:39:11 pm »
Quote from: "Laurent"
Why would a sprite update its subrect position? The subrect is the area of the texture that the sprite displays, it mustn't move.

If you want to get the bounding rectangle of your sprite in the 2D scene, you must compute it yourself. There are some threads on this forum that explain how to do this.


I appreciate it, I believe I have some pretty sound logic on how to compute that, I was just not sure if that was needed.
I am coming to C++ and SFML from Python and Pygame. Pygame had a rect object attached to sprite or something similar so yo could always call sprite.rect to find the area it filled.

Thanks for the point in the right direction, I will get on it!  :D