API Documentation for: 0.11.8
Show:

platypus.AABB Class

Defined in: platypus.AABB:1
Module: platypus

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

Constructor

platypus.AABB

(
  • x
  • y
  • width
  • height
)
platypus.AABB

Defined in platypus.AABB:1

Parameters:

  • 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:

platypus.AABB:

Returns the new aabb object.

Methods

AABB.recycle

(
  • aabb
)

Defined in AABB.recycle:423

Available since 0.7.3

Returns a AABB back to the cache.

Parameters:

AABB.setUp

() platypus.AABB

Defined in AABB.setUp:416

Available since 0.7.3

Returns an AABB from cache or creates a new one if none are available.

Returns:

platypus.AABB:

The instantiated AABB.

collides

(
  • aabb
)
Boolean

Defined in collides:362

Available since 0.7.4

Expresses whether this AABB collides with the given AABB. This is similar to intersects but returns true for overlapping or touching edges.

Parameters:

Returns:

Boolean:

Returns true if this AABB collides with the other AABB.

collidesPoint

(
  • x
  • y
)
Boolean

Defined in collidesPoint:374

Available since 0.11.0

Expresses whether this AABB collides with the given point. This is an exclusive version of containsPoint.

Parameters:

Returns:

Boolean:

Returns true if this AABB collides with the point.

contains

(
  • aabb
)
Boolean

Defined in contains:327

Expresses whether this AABB contains the given AABB.

Parameters:

Returns:

Boolean:

Returns true if this AABB contains the other AABB.

containsPoint

(
  • x
  • y
)
Boolean

Defined in containsPoint:349

Available since 0.7.5

Expresses whether this AABB contains the given point.

Parameters:

Returns:

Boolean:

Returns true if this AABB contains the point.

containsVector

(
  • vector
)
Boolean

Defined in containsVector:338

Expresses whether this AABB contains the given point.

Parameters:

Returns:

Boolean:

Returns true if this AABB contains the vector.

equals

(
  • aabb
)
Boolean

Defined in equals:315

Available since 0.7.5

Expresses whether this AABB matches the provided AABB.

Parameters:

Returns:

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:

  • aabb AABB

    The AABB this AABB intersects with.

Returns:

Number:

Returns the area of the intersected AABB's.

include

(
  • aabb
)
chainable

Defined in include:216

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:

  • aabb platypus.AABB

    The AABB whose area will be included in the area of the current AABB.

intersects

(
  • aabb
)
Boolean

Defined in intersects:387

Expresses whether this AABB intersects the given AABB. This is similar to collides but returns true for overlapping only, not touching edges.

Parameters:

Returns:

Boolean:

Returns true if this AABB intersects the other AABB.

move

(
  • x
  • y
)
chainable

Defined in move:251

Moves the AABB to the specified location.

Parameters:

  • x Number

    The new x position of the AABB.

  • y Number

    The new y position of the AABB.

moveX

(
  • x
)
chainable

Defined in moveX:265

Moves the AABB to the specified location.

Parameters:

  • x Number

    The new x position of the AABB.

moveXBy

(
  • deltaX
)
chainable

Defined in moveXBy:293

Moves the AABB to the specified location.

Parameters:

  • deltaX Number

    The change in x position of the AABB.

moveY

(
  • y
)
chainable

Defined in moveY:279

Moves the AABB to the specified location.

Parameters:

  • y Number

    The new y position of the AABB.

moveYBy

(
  • deltaY
)
chainable

Defined in moveYBy:304

Moves the AABB to the specified location.

Parameters:

  • deltaY Number

    The change in y position of the AABB.

recycle

()

Defined in recycle:430

Available since 0.7.3

Relinquishes properties of the AABB and recycles it.

reset

() chainable

Defined in reset:172

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

resize

(
  • width
  • height
)
chainable

Defined in resize:183

Resizes the AABB.

Parameters:

  • width Number

    The new width of the AABB

  • height Number

    The new height of the AABB

set

(
  • aabb
)
chainable

Defined in set:63

Sets the AABB values to those of the provided AABB.

Parameters:

setAll

(
  • x
  • y
  • width
  • height
)
chainable

Defined in setAll:27

Sets all of the properties of the AABB.

Parameters:

  • 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
)
chainable

Defined in setBounds:45

Sets bounds of the AABB.

Parameters:

  • 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

()

Defined in toString:162

Returns a string listing AABB dimensions.

Returns:

String

Properties

bottom

Number

Defined in bottom:151

The y-position of the bottom edge of the AABB.

empty

Boolean

Defined in empty:71

Whether the AABB encloses a valid space.

halfHeight

Number

Defined in halfHeight:119

Half the height of the AABB.

halfWidth

Number

Defined in halfWidth:111

Half the width of the AABB.

height

Number

Defined in height:103

The height of the AABB.

left

Number

Defined in left:127

The x-position of the left edge of the AABB.

right

Number

Defined in right:135

The x-position of the right edge of the AABB.

top

Number

Defined in top:143

The y-position of the top edge of the AABB.

width

Number

Defined in width:95

The width of the AABB.

x

Number

Defined in x:79

The x position of the AABB. The x is always located in the center of the object.

y

Number

Defined in y:87

The y position of the AABB. The y is always located in the center of the object.