API Documentation for: 0.11.8
Show:

platypus.CollisionData Class

Module: platypus

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.

Constructor

platypus.CollisionData

(
  • occurredOrData
  • direction
  • position
  • deltaMovement
  • aABB
  • thisShape
  • thatShape
  • vector
  • stuck
)
platypus.CollisionData

Parameters:

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

platypus.CollisionData:

Returns the new CollisionData object.

Methods

CollisionData.recycle

(
  • collisionData
)

Defined in CollisionData.recycle:87

Available since 0.8.7

Returns a collisionData back to the cache.

Parameters:

CollisionData.setUp

() platypus.CollisionData

Defined in CollisionData.setUp:80

Available since 0.8.7

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

Returns:

platypus.CollisionData:

The instantiated CollisionData.

copy

(
  • dataToCopy
)

Defined in copy:62

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

Parameters:

  • dataToCopy CollisionData

    The object values to copy.

recycle

()

Defined in recycle:94

Available since 0.8.7

Relinquishes properties of the collisionData and recycles it.

set

(
  • occurred
  • direction
  • position
  • deltaMovement
  • aABB
  • thisShape
  • thatShape
  • vector
  • stuck
)

Defined in set:35

Available since 0.8.7

Sets all of the properties of the CollisionData.

Parameters:

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