Open PalladiumPeet opened 2 years ago
@PalladiumPeet I know your post is old, but I"m looking through things while trying to understand my own question and figured I'd take a stab at giving a response.
I'm just a user like you, but to me, I don't understand why you have negative width and height values? How can you draw something that has no width, or rather, has inverted width?
At the bottom, I've linked to what appear to be the code for this RectangleF, but again, I don't think this is a bug, to me, a 2D object would never have a negative width. If you want to "flip" the image, that's not default rectangle behavior. An inverted (negative) width or height would basically be impossible in normal 2D environment.
Possible work-around: You could make a Helper method, or Create your own Rectangle class that uses RectangleF, or create an Extension Method to add some sort of "AdjustForNegativeDistances". Whichever you end use choosing, you'd take X, Y, Width, Height, and then you could "re-calculate" the X as being the MIN (clamp?) of X or X + Width, and Y being the MIN of Y or Y + Height. Then depending on which it is, you'd set the real width and height. One quick way would be.
Hello, i came across an issue with negative Width and Height while drawing RectangleF or using it for Collision Detection. For example, when the shooting direction is to the upperleft corner starting by the player position, there will be a negative direction.
this draws to this:
and for Collision if have this example, which is always false
and when adding a ICollsionActor-Class with such a RectangleF with negative Width or Height to the CollisionComponent, i will never collide with anything.
I have looked through the other open issues and through the MG-Forum, but couldn't find anything of help on this topic. Please excuse me, if this isn't an issue (and i'm too stupid) or someone already knows about it.
Thanks in advance
Edit: Formatting Edit2: Have inserted the wrong code before, corrected it