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

Methods from collision

Array<Renderable>
rayCast(line: Line, result: Array<Renderable>)

Public Properties


maxChildren collision.js:11
static maxChildren: number = 8

number

The maximum number of children that a quadtree node can contain before it is split into sub-nodes.

See: game.world.broadphase
maxDepth collision.js:22
static maxDepth: number = 4

number

The maximum number of levels that the quadtree will create.

See: game.world.broadphase

Public Methods


rayCast collision.js:94
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) {
        // ...
    }
Parameters:
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.

Returns:
Type Description
Array<Renderable>

an array of intersecting physic objects


Powered by webdoc!