collision
namespace collision
Collision detection (and projection-based collision response) of 2D shapes.
Based on the Separating Axis Theorem and supports detecting collisions between simple Axis-Aligned Boxes, convex polygons and circles based shapes.
Summary
Properties from collision
number |
|
number |
|
Methods from collision
Array<Renderable> |
|
Public Properties
static maxChildren: number = 8
number
The maximum number of children that a quadtree node can contain before it is split into sub-nodes.
static maxDepth: number = 4
number
The maximum number of levels that the quadtree will create.
Public Methods
rayCast(line: Line, result: Array<Renderable>) → {Array<Renderable>}
Checks for object colliding with the given line
// define a line accross the viewport
let ray = new me.Line(
// absolute position of the line
0, 0, [
// starting point relative to the initial position
new me.Vector2d(0, 0),
// ending point
new me.Vector2d(me.game.viewport.width, me.game.viewport.height)
]);
// check for collition
result = me.collision.rayCast(ray);
if (result.length > 0) {
// ...
}
Name | Type | Attributes | Description |
---|---|---|---|
line | Line |
line to be tested for collision |
|
result | Array<Renderable> |
<optional> |
a user defined array that will be populated with intersecting physic objects. |
Type | Description |
---|---|
Array<Renderable> |
an array of intersecting physic objects |