Skip to main content

ElasticToActorStrategy

Using Hook's law, elastically move the camera towards the target actor.

Implements

Index

Constructors

constructor

  • If cameraElasticity < cameraFriction < 1.0, the behavior will be a dampened spring that will slowly end at the target without bouncing If cameraFriction < cameraElasticity < 1.0, the behavior will be an oscillating spring that will over correct and bounce around the target


    Parameters

    • target: Actor

      Target actor to elastically follow

    • cameraElasticity: number

      [0 - 1.0] The higher the elasticity the more force that will drive the camera towards the target

    • cameraFriction: number

      [0 - 1.0] The higher the friction the more that the camera will resist motion towards the target

    Returns ElasticToActorStrategy

Properties

publiccameraElasticity

cameraElasticity: number

[0 - 1.0] The higher the elasticity the more force that will drive the camera towards the target

publiccameraFriction

cameraFriction: number

[0 - 1.0] The higher the friction the more that the camera will resist motion towards the target

publictarget

target: Actor

Target actor to elastically follow

Methods

publicaction

  • Camera strategies perform an action to calculate a new focus returned out of the strategy


    Parameters

    • target: Actor

      The target object to apply this camera strategy (if any)

    • cam: Camera

      The current camera implementation in excalibur running the game

    • _eng: Engine<any>

      The current engine running the game

    • elapsedMs: number

      The elapsed time in milliseconds since the last frame

    Returns Vector