API Docs for:
Show:

Movable Class

A component class which holds variables related to the dynamics of an entity.

Constructor

Movable

(
  • mass
  • dragCoefficient
  • fastObject
  • initialVelocityX
  • initialVelocityY
)

Parameters:

  • mass Number
  • dragCoefficient Number
  • fastObject Boolean

    Specifies whether the object is fast or not. A fast object gets updated multiple times per frame which should prevent it from passing through other objects.

  • initialVelocityX Number

    The x component of the initial velocity vector.

  • initialVelocityY Number

    The y component of the initial velocity vector.

Methods

applyForce

(
  • force
)

Parameters:

  • force Vector2D

    Vector representing the force to be applied.

applyImpulse

(
  • impulse
)

Parameters:

  • impulse Vector2D

    Vector representing the impulse to be applied.

clearForces

()

Clears all forces that were applied to the component between now and the last physics system update.

clearImpulses

()

Clears all impulses that were applied to the component between now and the last physics system update.

getDragCoefficient

() Number

Returns:

Number:

getFastObject

() Boolean

Returns:

Boolean:

getMass

() Number

Returns:

Number:

getVelocity

(
  • vector
)

Parameters:

  • vector Vector2D

    Vector to which the velocity will be copied.

setDragCoefficient

(
  • dragCoefficient
)

Parameters:

  • dragCoefficient Number

setFastObject

(
  • fastObject
)

Sets whether the object is fast or not. A fast object gets updated multiple times per frame which should prevent it from passing through other objects.

Parameters:

  • fastObject Boolean

setMass

(
  • mass
)

Parameters:

  • mass Number

    Mass needs to be a positive number. For infinite masses use Number.POSITIVE_INFINITY.

setVelocity

(
  • x
  • y
)

Parameters:

  • x Number

    The x component of the new velocity.

  • y Number

    The y component of the new velocity.