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

Author Topic: [SFML 2] Sprite Vertices' Coordinates  (Read 1256 times)

0 Members and 1 Guest are viewing this topic.

tschaei

  • Newbie
  • *
  • Posts: 5
    • View Profile
[SFML 2] Sprite Vertices' Coordinates
« on: May 21, 2012, 01:53:48 am »
I'm trying to implement collision detection for rotated rectangles. I found the following for SFML 1.6:
Quote from: Laurent
The points in local coordinates are:
- (0, 0)
- (0, sprite.GetSubRect().GetHeight())
- (sprite.GetSubRect().GetWidth(), 0)
- (sprite.GetSubRect().GetWidth(), sprite.GetSubRect().GetHeight())

The points in global coordinates are:
- sprite.TransformToGlobal(px)
where px is one of the local points.

How do I get the local coordinates in SFML 2? Via getLocalBounds() or via getTextureRect()?

Edit: An additional question just came to my mind. Does changing the origin of a sprite change the way I have to calculate those local coordinates?
« Last Edit: May 21, 2012, 02:34:50 am by tschaei »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: [SFML 2] Sprite Vertices' Coordinates
« Reply #1 on: May 21, 2012, 08:05:49 am »
getGlobalBounds() directly gives you what you're looking for.

Quote
Does changing the origin of a sprite change the way I have to calculate those local coordinates?
Not if you use getGlobalBounds.
Laurent Gomila - SFML developer