API Docs for:
Show:

AnchoredSpringGenerator Class

This generator simulates a spring with one end attached to a fixed point in space and the other to an entity.

Constructor

AnchoredSpringGenerator

(
  • anchorPointX
  • anchorPointY
  • restLength
  • stiffness
)

Parameters:

  • anchorPointX Number

    The x component of the fixed point.

  • anchorPointY Number

    The y component of the fixed point.

  • restLength Number
  • stiffness Number

Methods

applyForce

(
  • entity
)

Parameters:

  • entity Entity

    The entity the spring force should be applied to. It's required that the entity has the Movable and Position components.

getAnchorPoint

(
  • vector
)

Retrieves the position of the anchor point.

Parameters:

  • vector Vector2D

    The vector to which the anchor point's position will be copied.

getRestLength

() Number

Returns:

Number:

getStiffness

() Number

Returns:

Number:

setAnchorPoint

(
  • anchorPointX
  • anchorPointY
)

Sets a new position for the anchor point.

Parameters:

  • anchorPointX Number

    The x component of the new anchor point.

  • anchorPointY Number

    The y component of the new anchor point.

setRestLength

(
  • restLength
)

Parameters:

  • restLength Number

setStiffness

(
  • stiffness
)

Parameters:

  • stiffness Number