CollisionData

platypus. CollisionData

new CollisionData(occurredOrData, direction, position, deltaMovement, aABB, thisShape, thatShape, vector, stuck) → {platypus.CollisionData}

CollisionData holds collision data passed to entities during collisions with other entities. This class is primarily used by the "HandlerCollision" Component to trigger messages on child entities as collision occur.

Source:
Parameters:
Name Type Description
occurredOrData Boolean | CollisionData

Whether this represents an actual collision between two shapes. If a CollisionData instance is provided, the instance's full set of values are copied.

direction Number

1 or -1 to define the direction of the collision.

position Number

A positive number describing position along the line of collision direction.

deltaMovement Number

A positive number describing the magnitude of overlap.

aABB platypus.AABB

An AABB of the colliding shape.

thisShape platypus.Shape

The moving shape.

thatShape platypus.Shape

The stationary shape being collided with.

vector platypus.Vector

The vector describing the contact point.

stuck Number

The amount of unwarranted overlap if shapes start in a collided position before moving.

Returns:
Type:
platypus.CollisionData

Returns the new CollisionData object.

Methods

(static) recycle(collisionData)

Returns a collisionData back to the cache.

Source:
Parameters:
Name Type Description
collisionData platypus.CollisionData

The collisionData to be recycled.

(static) setUp() → {platypus.CollisionData}

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

Source:
Returns:
Type:
platypus.CollisionData

The instantiated CollisionData.

copy(dataToCopy)

Sets all of the properties of the CollisionData to match those of the provided CollisionData object.

Source:
Parameters:
Name Type Description
dataToCopy CollisionData

The object values to copy.

recycle()

Relinquishes properties of the collisionData and recycles it.

Source:

set(occurred, direction, position, deltaMovement, aABB, thisShape, thatShape, vector, stuck)

Sets all of the properties of the CollisionData.

Source:
Parameters:
Name Type Description
occurred Boolean

Whether this represents an actual collision between two shapes.

direction Number

1 or -1 to define the direction of the collision.

position Number

A positive number describing position along the line of collision direction.

deltaMovement Number

A positive number describing the magnitude of overlap.

aABB platypus.AABB

An AABB of the colliding shape.

thisShape platypus.Shape

The moving shape.

thatShape platypus.Shape

The stationary shape being collided with.

vector platypus.Vector

The vector describing the contact point.

stuck Number

The amount of unwarranted overlap if shapes start in a collided position before moving.