Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Tweener

Provides interpolation functionality for various values and easing types.

Hierarchy

  • Tweener

Index

Constructors

Properties

paused: boolean
playing: boolean
returns

true if Tweener has active transition.

stopped: boolean

Methods

  • onFinish(callback: (() => void)): void
  • Creates a handler that triggers when this Tweener completes.

    Note: This handler is disposed when a new handler is defined. A Tweener with iterations = 0 does not finish.

    Parameters

    • callback: (() => void)

      function to call when Tweener completes.

        • (): void
        • Returns void

    Returns void

  • pause(): void
  • Pauses this Tweener.

    Returns void

  • play(): void
  • Plays this Tweener.

    Returns void

  • setEase(floatFunction: ((x: number) => number)): Tweener
  • Defines an easingFunction for this Tweener.

    Easing functions allow you to control interpolation behavior during the duration of a tween.

    You can pass pre-defined templates from Easing as easingFunction.

    Example

    //Applies the "easeInOutQuint" easing function to this Tweener
    myTweener.setEase(Easing.easeInOutQuint)

    Parameters

    • floatFunction: ((x: number) => number)

      function to use for interpolation of values.

        • (x: number): number
        • Parameters

          • x: number

          Returns number

    Returns Tweener

  • setIterations(iterations: number): Tweener
  • Defines how many iterations this Tweener should perform.

    Setting this value to 0 creates an infinite loop.

    Parameters

    • iterations: number

      amount of tweening iterations.

    Returns Tweener

  • setLoop(lType: "restart" | "yo_yo" | "additive"): Tweener
  • Defines the loopType of this Tweener.

    Parameters

    • lType: "restart" | "yo_yo" | "additive"

      type to use.

    Returns Tweener

  • stop(): void
  • Stops this Tweener.

    Tweener starts from the beginning with next play call.

    Returns void

  • Creates a custom Tweener. For shorthand definitions, use BaseItem.transition.

    Example

    //Creates a tween between two Vector3 values over 3 seconds
    let startPoint = Vector3.zero
    let endPoint = new Vector3(0,0,3)
    let duration = 3

    Tweener.tweenTo(
    val => { Debug.log(`Remaining distance is ${val.dist(endPoint)}`)},
    startPoint,
    endPoint,
    duration
    )

    Parameters

    • setter: ((t: Vector3) => void)

      Function to call every frame during the tween. Contains interpolated value.

    • startValue: Vector3

      Start value of this Tweener.

    • endValue: Vector3

      End value of this Tweener.

    • duration: number

      Duration of this Tweener.

    Returns Tweener

    created Tweener.

  • Creates a custom Tweener. For shorthand definitions, use BaseItem.transition.

    Parameters

    • setter: ((t: number) => void)

      Function to call every frame during the tween. Contains interpolated value.

        • (t: number): void
        • Parameters

          • t: number

          Returns void

    • startValue: number

      Start value of this Tweener.

    • endValue: number

      End value of this Tweener.

    • duration: number

      Duration of this Tweener.

    Returns Tweener

    created Tweener.

  • Creates a custom Tweener. For shorthand definitions, use BaseItem.transition.

    Parameters

    • setter: ((t: Color) => void)

      Function to call every frame during the tween. Contains interpolated value.

    • startValue: Color

      Start value of this Tweener.

    • endValue: Color

      End value of this Tweener.

    • duration: number

      Duration of this Tweener.

    Returns Tweener

    created Tweener.

  • Creates a custom Tweener. For shorthand definitions, use BaseItem.transition.

    Parameters

    • setter: ((t: Vector2) => void)

      Function to call every frame during the tween. Contains interpolated value.

    • startValue: Vector2

      Start value of this Tweener.

    • endValue: Vector2

      End value of this Tweener.

    • duration: number

      Duration of this Tweener.

    Returns Tweener

    created Tweener.

  • Creates a custom Tweener. For shorthand definitions, use BaseItem.transition.

    Parameters

    • setter: ((t: Quat) => void)

      Function to call every frame during the tween. Contains interpolated value.

        • Parameters

          Returns void

    • startValue: Quat

      Start value of this Tweener.

    • endValue: Quat

      End value of this Tweener.

    • duration: number

      Duration of this Tweener.

    Returns Tweener

    created Tweener.