Name
Collision -- check if two objects collide (V2.0)
Synopsis
bool = Collision(type, ...)
bool = Collision(#BOX, x1, y1, width1, height1, x2, y2, width2, height2)
bool = Collision(#BRUSH, id1, x1, y1, id2, x2, y2)
bool = Collision(#LAYER, id1, id2)
bool = Collision(#SPRITE, id1, id2)
bool = Collision(#BRUSH_VS_BOX, id, x, y, x2, y2, width2, height2) (V4.5)
bool = Collision(#LAYER_VS_BOX, id, x, y, width, height) (V4.5)
bool = Collision(#SPRITE_VS_BOX, id, x, y, width, height) (V4.5)
bool = Collision(#SPRITE_VS_BRUSH, id1, id2, x, y) (V7.1)
Function
This function checks if two objects collide. There are several possibilities how you can use this function depending on the type you specify.

The following collision types are currently supported:

#BOX:
You have to specify the position and size of two rectangles and this function will determine if they collide or not. This is a quick calculation but is probably not exact enough for some purposes.

#BRUSH:
Checks if the two brushes specified by id1 and id2 would collide if they were shown at x1 and y1 and x2 and y2, respectively. Transparent areas (mask or alpha channel) of the brushes will be fully respected so that you get an exact result if pixels collide or not.

#LAYER:
Checks if the two layers specified by id1 and id2 collide. If the layers have transparent areas, they will be respected. If you use this type, layers must be enabled of course.

#SPRITE:
Checks if the two sprites specified by id1 and id2 collide. If the sprites have transparent areas, they will be respected.

#BRUSH_VS_BOX:
Checks if the specified brush collides with the specified rectangular area. If the brush has transparent areas, they will be taken into account. (V4.5)

#LAYER_VS_BOX:
Checks if the specified layer collides with the specified rectangular area. If the layer has transparent areas, they will be taken into account. (V4.5)

#SPRITE_VS_BOX:
Checks if the specified sprite collides with the specified rectangular area. If the sprite has transparent areas, they will be taken into account. (V4.5)

#SPRITE_VS_BRUSH:
Checks if the sprite specified by id1 collides with the brush specified by id2 in case the brush was displayed at the position specified by x and y. (V7.1)

Inputs
type
either #BOX, #BRUSH, #SPRITE, #LAYER, #BRUSH_VS_BOX, #LAYER_VS_BOX, #SPRITE_VS_BOX, or #SPRITE_VS_BRUSH (see above)
...
optional arguments depend on the type specified (see above)
Results
bool
True for collision, False otherwise
Example
Box(10, 10, 100, 100, #RED)
Box(70, 70, 100, 100, #BLUE)
b = Collision(#BOX, 10, 10, 100, 100, 70, 70, 100, 100)
This returns True because the rectangles collide.

Show TOC