new AABB(x, y, width, height) → {platypus.AABB}
This class defines an axis-aligned bounding box (AABB) which is used during the collision process to determine if two objects are colliding. This is used in a few places including CollisionBasic and [[Collision-Shape]].
Parameters:
Name | Type | Description |
---|---|---|
x |
number
|
The x position of the AABB. The x is always located in the center of the object. |
y |
number
|
The y position of the AABB. The y is always located in the center of the object. |
width |
number
|
The width of the AABB. |
height |
number
|
The height of the AABB. |
Methods
(static) recycle(aabb)
Returns a AABB back to the cache.
Parameters:
Name | Type | Description |
---|---|---|
aabb |
platypus.AABB
|
The AABB to be recycled. |
(static) setUp() → {platypus.AABB}
Returns an AABB from cache or creates a new one if none are available.
collides(aabb) → {boolean}
Expresses whether this AABB collides with the given AABB. This is similar to intersects
but returns true for overlapping only, not touching edges.
Parameters:
Name | Type | Description |
---|---|---|
aabb |
platypus.AABB
|
The AABB to check against |
Returns:
- Type:
-
boolean
Returns true
if this AABB collides with the other AABB.
collidesPoint(x, y) → {boolean}
Expresses whether this AABB collides with the given point. This is an exclusive version of containsPoint.
Parameters:
Name | Type | Description |
---|---|---|
x |
number
|
The x-axis value. |
y |
number
|
The y-axis value. |
Returns:
- Type:
-
boolean
Returns true
if this AABB collides with the point.
contains(aabb) → {boolean}
Expresses whether this AABB contains the given AABB.
Parameters:
Name | Type | Description |
---|---|---|
aabb |
platypus.AABB
|
The AABB to check against |
Returns:
- Type:
-
boolean
Returns true
if this AABB contains the other AABB.
containsPoint(x, y) → {boolean}
Expresses whether this AABB contains the given point.
Parameters:
Name | Type | Description |
---|---|---|
x |
number
|
The x-axis value. |
y |
number
|
The y-axis value. |
Returns:
- Type:
-
boolean
Returns true
if this AABB contains the point.
containsVector(vector) → {boolean}
Expresses whether this AABB contains the given point.
Parameters:
Name | Type | Description |
---|---|---|
vector |
platypus.Vector
|
The vector to check. |
Returns:
- Type:
-
boolean
Returns true
if this AABB contains the vector.
equals(aabb) → {Boolean}
Expresses whether this AABB matches the provided AABB.
Parameters:
Name | Type | Description |
---|---|---|
aabb |
platypus.AABB
|
The AABB to check against. |
Returns:
- Type:
-
Boolean
Returns true
if the AABB's match.
getIntersectionArea(aabb) → {Number}
Returns the area of the intersection. If the AABB's do not intersect, 0
is returned.
Parameters:
Name | Type | Description |
---|---|---|
aabb |
AABB
|
The AABB this AABB intersects with. |
Returns:
- Type:
-
Number
Returns the area of the intersected AABB's.
include(aabb)
Changes the size and position of the bounding box so that it contains the current area and the area described in the incoming AABB.
Parameters:
Name | Type | Description |
---|---|---|
aabb |
platypus.AABB
|
The AABB whose area will be included in the area of the current AABB. |
intersects(aabb) → {boolean}
Expresses whether this AABB intersects the given AABB. This is similar to collides
but returns true for overlapping or touching edges.
Parameters:
Name | Type | Description |
---|---|---|
aabb |
platypus.AABB
|
The AABB to check against |
Returns:
- Type:
-
boolean
Returns true
if this AABB intersects the other AABB.
move(x, y)
Moves the AABB to the specified location.
Parameters:
Name | Type | Description |
---|---|---|
x |
number
|
The new x position of the AABB. |
y |
number
|
The new y position of the AABB. |
moveX(x)
Moves the AABB to the specified location.
Parameters:
Name | Type | Description |
---|---|---|
x |
number
|
The new x position of the AABB. |
moveXBy(deltaX)
Moves the AABB to the specified location.
Parameters:
Name | Type | Description |
---|---|---|
deltaX |
number
|
The change in x position of the AABB. |
moveY(y)
Moves the AABB to the specified location.
Parameters:
Name | Type | Description |
---|---|---|
y |
number
|
The new y position of the AABB. |
moveYBy(deltaY)
Moves the AABB to the specified location.
Parameters:
Name | Type | Description |
---|---|---|
deltaY |
number
|
The change in y position of the AABB. |
resize(width, height)
Resizes the AABB.
Parameters:
Name | Type | Description |
---|---|---|
width |
number
|
The new width of the AABB |
height |
number
|
The new height of the AABB |
set(aabb)
Sets the AABB values to those of the provided AABB.
Parameters:
Name | Type | Description |
---|---|---|
aabb |
platypus.AABB
|
The AABB to copy values. |
setAll(x, y, width, height)
Sets all of the properties of the AABB.
Parameters:
Name | Type | Description |
---|---|---|
x |
number
|
The x position of the AABB. The x is always located in the center of the object. |
y |
number
|
The y position of the AABB. The y is always located in the center of the object. |
width |
number
|
The width of the AABB. |
height |
number
|
The height of the AABB. |
setBounds(left, top, right, bottom)
Sets bounds of the AABB.
Parameters:
Name | Type | Description |
---|---|---|
left |
number
|
The left side of the AABB. |
top |
number
|
The top side of the AABB. |
right |
number
|
The right side of the AABB. |
bottom |
number
|
The bottom side of the AABB. |