How do I use BBox as a collision alternative?

Get help using Construct 2

Post » Mon Feb 29, 2016 12:17 pm

I'm already using a collision polygon but would also like to use the common expression BBoxLeft, BBoxRight, BBoxTop, BBoxBottom for some custom collision detection using the BBox of a Sprite.

What I'm trying to do is making a check if any sprite BBox in SpritegroupGroup1, overlaps any Sprite BBox in SpriteGroup2.

Would something like this work to return true? and how would i go about making it true for every instance of the object?
Sprite1.BBoxLeft > Sprite2.BBoxRight

Any idea how i would go about to create some events for this custom collisions using BBox of a sprite?

Any help Appreciated.
Follow my progress on Twitter
or in this thread Archer Devlog
B
38
S
15
G
17
Posts: 949
Reputation: 12,320

Post » Mon Feb 29, 2016 1:58 pm

Hmmm. In order for it to detect a collision or overlap i guess i would need 2 At least 2 BBox values intersecting with 2 BBox values of another Sprite.

Condition1 - Sprite1.BBoxLeft & Sprite1.BBoxTop (X and Y of Top left corner of the first sprite) < Sprite2.BBoxRight & Sprite1.BBoxBottom (Lower right corner of Sprite2) if true, that would indicate that the two Sprites BBoxes are intersecting on at least one corner?

Maybe it would be good to add a X & Y instance variable for each corner of a Sprite BBox. I guess i would get values like this for a 100pixel square box.

BoxCornerTopleftX =100
BoxCornerTopleftY =100
BoxCornerToprightX =200
BoxCornerToprightY =100
BoxCornerBottomleftX =100
BoxCornerBottomleftY =200
BoxCornerBottomrightX =200
BoxCornerBottomrightY =200

Then it would be pretty easy to check if there is any intersections with any other sprite.

Continuing my experimentations, think I'm getting there.
Follow my progress on Twitter
or in this thread Archer Devlog
B
38
S
15
G
17
Posts: 949
Reputation: 12,320


Return to How do I....?

Who is online

Users browsing this forum: zenox98 and 13 guests