Is there a simpler way to check if a point is overlapping a bounding box?

0 favourites
  • 7 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • I know how to check by comparing with bboxleft/right/top/bottom, But that seems to be so many conditions, epecially as I use this very frequently.

    Thank you!

  • Use image point as overlapping testing in 4 corner. Loop the checking points by using 'for' loop.

  • thank you alextro but wouldn't this just test if the corners are overlapping?

    some more information:

    I want to check if a sprite is overlapping with a tilemap object (even if there is no tile at the given position). With the tilemap object I can only set imagepoints and collison polygons per tile.

    (I guess the best way is to add an invisible spirte that is behind the whole tilemap objects for checking overlaps?)

  • Is the object needs to checking surroundings in 4 directions? Test overlapping at offset probably the way to go. Anyway here an example with "Surroundings" treated as solid:

    dropbox.com/s/qh0q46fggf1qo0r/bounding_box_alternative.capx

  • So you want to see if two object bounding boxes overlap?

    You can do that with two compares

    Compare: (sprite.bboxright>tilemap.bboxleft) & (sprite.bboxleft<tilemap.bboxright) =1

    Compare: (sprite.bboxbottom>tilemap.bboxtop) & (sprite.bboxtop<tilemap.bboxbottom) =1

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • just if a point is overlapping the bounding box...

    oh interesting yea I'm currently using 4 compares, that would definitly makes it a bit cleaner!

    I didn't even know you could do compares like that.

    then I could even do one compare like:

    (sprite.bboxright>tilemap.bboxleft)+(sprite.bboxleft<tilemap.bboxright)+(sprite.bboxbottom>tilemap.bboxtop)+(sprite.bboxtop<tilemap.bboxbottom) = 4

    thanks alot, at least it looks cleaner in the event view :D

  • alextro Thanks for your help!

    I checked your example, but I want to check if the player is overlapping the bounding box of the tileset even if there is no tile at the position of overlap.

    So checking for bbox left, right, top, bottom works that's not the problem.

    It just felt like I was missing a "is overlapping bbox condition" and was writing an unnecessary amount of events, visually cluttering the event sheet.

    but I think with the help of rojohound I found a tidier way to check for overlap of bounding boxes

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)