You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Below is an example of my own utility I ended up making which might be useful to others.
Perhaps the exact behavior I needed is not important, but the isOverlapping() helper wouldn't work for me.
I did JUST notice the isIntersecting() helper though ... maybe that's good enough. I could just specify the same position for the start and end parameters...
/** * Checks if a position is inside a rect. * Important that it doesn't generously accept points on the far edges. * This is so that engine objects can belong to exactly 1 sector, even though they may overlap multiple. * So points will match on the lower end, but not the upper end. */exportfunctionposInRect(pos: Vector2,rectPos: Vector2,rectSize: Vector2){constbottomLeft=rectPos.subtract(rectSize.scale(0.5));consttopRight=rectPos.add(rectSize.scale(0.5));if(pos.x>=bottomLeft.x&&pos.y>=bottomLeft.y&&pos.x<topRight.x&&pos.y<topRight.y){returntrue;}returnfalse;}
The text was updated successfully, but these errors were encountered:
So is the it the edge cases that are important? Maybe we can refactor isOverlapping to work more like this. Just really redefining how the edge cases work.
The edge cases were important for my personal use case.
I'm not sure how important they might be for other people.
I think the main reason I opened this issue was because I couldn't find a helper to check if a rect contained a point.
I thought that would be something everyone might want.
I'm new to game math though, maybe it's a trivial calculations with one of the other helpers or something that I missed.
... oh I see. maybe isOverlapping() pulls double duty here with smart usage of arguments.
If that's the case then maybe we should just close this.
Below is an example of my own utility I ended up making which might be useful to others.
Perhaps the exact behavior I needed is not important, but the
isOverlapping()
helper wouldn't work for me.I did JUST notice the
isIntersecting()
helper though ... maybe that's good enough. I could just specify the same position for the start and end parameters...The text was updated successfully, but these errors were encountered: