AABB

platypus. AABB

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]].

Source:
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.

Returns:
Type:
platypus.AABB

Returns the new aabb object.

Methods

(static) recycle(aabb)

Returns a AABB back to the cache.

Source:
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.

Source:
Returns:
Type:
platypus.AABB

The instantiated AABB.

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.

Source:
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.

Source:
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.

Source:
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.

Source:
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.

Source:
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.

Source:
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.

Source:
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.

Source:
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.

Source:
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.

Source:
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.

Source:
Parameters:
Name Type Description
x number

The new x position of the AABB.

moveXBy(deltaX)

Moves the AABB to the specified location.

Source:
Parameters:
Name Type Description
deltaX number

The change in x position of the AABB.

moveY(y)

Moves the AABB to the specified location.

Source:
Parameters:
Name Type Description
y number

The new y position of the AABB.

moveYBy(deltaY)

Moves the AABB to the specified location.

Source:
Parameters:
Name Type Description
deltaY number

The change in y position of the AABB.

recycle()

Relinquishes properties of the AABB and recycles it.

Source:

reset()

Resets all the values in the AABB so that the AABB can be reused.

Source:

resize(width, height)

Resizes the AABB.

Source:
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.

Source:
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.

Source:
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.

Source:
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.

toString()

Returns a string listing AABB dimensions.

Source:
Returns:

String