1
Graphics / TransformToGlobal and Rect::Intersects
« on: March 29, 2011, 07:27:14 pm »
Thanks for a quick reply!
I changed
to
and now the left and upper borders do work, but the right and bottom borders still don't work. I'm guessing there's something wrong with the part with Intersects(), since hit detection isn't working either and I've done that basically the same way.
I remember seeing somewhere something about the center of the sprite related to TransfromToGlobal, but I'm not sure.
EDIT:
I checked that when going diagonally towards upper boundry, the Rect-hitbox has these values when the corner of the hitbox has passed the edge: 210.823, -1.96116, 184.11, 123.352. That seems to me that it should intersect with rectUp (0, -5, 800, 0), but it doesn't. What's going on?
EDIT2:
I noticed that if the Rect is not straight as in /_/ , then Intersect will not work, but if it has not turned very much, then it does work.
I changed
Code: [Select]
B.x = sprite_.GetSize().x;
B.y = sprite_.GetSize().y;
to
Code: [Select]
B.x = sprite_.GetSubRect().GetWidth().x;
B.y = sprite_.GetSubRect().GetHeight().y;
and now the left and upper borders do work, but the right and bottom borders still don't work. I'm guessing there's something wrong with the part with Intersects(), since hit detection isn't working either and I've done that basically the same way.
I remember seeing somewhere something about the center of the sprite related to TransfromToGlobal, but I'm not sure.
EDIT:
I checked that when going diagonally towards upper boundry, the Rect-hitbox has these values when the corner of the hitbox has passed the edge: 210.823, -1.96116, 184.11, 123.352. That seems to me that it should intersect with rectUp (0, -5, 800, 0), but it doesn't. What's going on?
EDIT2:
I noticed that if the Rect is not straight as in /_/ , then Intersect will not work, but if it has not turned very much, then it does work.