Constructor
new BoundingBox(x, y, width, height)
Creates a new bounding box
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The x position of the top left corner |
y |
number | The y position of the top left corner |
width |
number | The width of the box |
height |
number | The height of the box |
Extends
Members
height
Get the height value
width
Get the width value
x
Gets the x coordinate of this point
y
Gets the x coordinate of this point
Methods
collides(box) → {boolean}
Performs a simple collision check on another boundingBox.
Parameters:
Name | Type | Description |
---|---|---|
box |
Object | The BoundingBox to check for intersection |
Returns:
true if colliding
- Type
- boolean
contains(box) → {boolean}
Checks the entire boundingBox passed is inside this one.
Parameters:
Name | Type | Description |
---|---|---|
box |
Object | The box to check |
Returns:
True/False whether the box passed is contained within this one
- Type
- boolean
copy(box)
Copies the values of another BoundingBox to this one
Parameters:
Name | Type | Description |
---|---|---|
box |
Object | the BoundingBox to copy |
- Overrides:
- Source:
distanceTo(point) → {number}
Calculates the distance between two points
Parameters:
Name | Type | Description |
---|---|---|
point |
Object | The point to measure distance to |
- Overrides:
- Source:
Returns:
The distance between this point and the one passed
- Type
- number
inBounds(x, y) → {boolean}
Checks whether the x,y coordinate passed is within the box boundary
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The x coordinate |
y |
number | The y coordinate |
Returns:
true if the point is inside this box, otherwise false
- Type
- boolean
intersects(box) → {Object}
Performs a comprehensive collision test that checks where the two boxes are
overlapping and indicates the closest point to move them out of collision.
Parameters:
Name | Type | Description |
---|---|---|
box |
Object | The BoundingBox to check for intersection |
Returns:
a dictionary with side: axis of intersection and
pos: closest point of non-intersection
- Type
- Object
pointInBounds(point) → {boolean}
Checks whether the point is within the box boundary
Parameters:
Name | Type | Description |
---|---|---|
point |
Object | The Point2D cordinates to check |
Returns:
true if the point is inside this box, otherwise false
- Type
- boolean