Module gamejs/mask
Image masks. Usefull for pixel perfect collision detection.
Mask
(dimensions)
Parameters
| Array |
dimensions |
[width, height] |
Mask.prototype.getAt
(x, y)
Mask.prototype.getSize
()
Returns
| Array |
the dimensions of the map |
Mask.prototype.invert
()
Flip the bits in this map.
Mask.prototype.overlap
(otherMask, offset)
Parameters
| Mask |
otherMask |
|
| Array |
offset |
|
Returns
|
True if the otherMask overlaps with this map. |
Mask.prototype.overlapArea
(otherMask, offset)
Parameters
| gamejs.mask.Mask |
otherMask |
|
| Array |
offset |
[x,y] |
Returns
|
the number of overlapping pixels |
Mask.prototype.overlapMask
(otherMask, offset)
Parameters
| gamejs.mask.Mask |
otherMask |
|
| Array |
offset |
[x,y] |
Returns
|
a mask of the overlapping pixels |
Mask.prototype.overlapRect
(otherMask, offset)
Parameters
| gamejs.mask.Mask |
otherMask |
|
| Array |
offset |
[x,y] |
Returns
|
the overlapping rectangle or null if there is no overlap; |
Mask.prototype.setAt
(x, y)
Creates an image mask from the given Surface. The alpha of each pixel is checked
to see if it is greater than the given threshold. If it is greater then
that pixel is set as non-colliding.
Parameters
| gamejs.Surface |
surface |
|
| Number |
threshold |
0 to 255. defaults to: 255, fully transparent |