Custom bounding boxes / collision masks

New releases and general discussions.

Post » Tue Feb 03, 2009 11:39 pm

I mentioned this in a help thread, thought it wise to move the discussion here. Original link: viewtopic.php?f=3&t=2612&start=0#p20467

Currently, if you want collisions based on anything other than pixel perfect or full bounding box, you have to create another sprite to do the job and link the two together with an always event.

I propose two possible solutions to this problem:

Firstly, the ability to define custom bounding boxes that would be calculated relative to the hotspot. You would need variables for width, height, x-offset and y-offset, which could be added somewhere in the properties panel. For example, if the hotspot was in the centre of a 32*32 sprite, the bounding box could be defined as W:16, H:32, XO:-8, YO: -16, in order to place a tall, thin bounding box in the middle of the sprite.

Secondly, for more complex collisions, you could offer the ability to define a custom collision mask, editable in the image editor. This could function in the same way as the multiple animations found on a single sprite. If present, this mask would be used for collisions instead of the currently displayed sprite.

Any thoughts?
B
2
S
2
G
3
Posts: 105
Reputation: 1,510

Post » Wed Feb 04, 2009 8:19 am

One thing - an inverse collision mask that would function as some sort of 'tunnel' within the sprite. A simple toggle should set the mask to inverse and back...
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Wed Feb 04, 2009 1:50 pm

Stumbled upon this article for rotated 2d rectangle collision algorithms:
http://www.gamedev.net/reference/progra ... Collision/

The maths blew my heads up, but it all makes sense to me.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 0 guests