Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Tween<T>

Type parameters

Hierarchy

  • Tween

Index

Constructors

constructor

Properties

_object

_object: T

Methods

chain

  • Things get more interesting when you sequence different tweens in order, i.e. setup one tween to start once a previous one has finished. We call this chaining tweens, and it’s done with the chain method. Thus, to make tweenB start after tweenA finishes:

    tweenA.chain(tweenB)
    // Or, for an infinite chain, set tweenA to start once tweenB finishes:
    tweenA.chain(tweenB)
    tweenB.chain(tweenA)

    // In other cases, you may want to chain multiple tweens to another tween in a way that they (the chained tweens) all start animating at the same time:
    tweenA.chain(tweenB, tweenC)

    Parameters

    Returns I3JS.Tween<T>

    chain

delay

  • More complex arrangements might require delaying a tween before it actually starts running. You can do that using the delay method:

    tween.delay(1000)
    tween.start()
    // will start executing 1 second after the start method has been called.

    Parameters

    • Optional amount: number

    Returns I3JS.Tween<T>

    delay

duration

easing

  • Tween.js will perform the interpolation between values (i.e. the easing) in a linear manner, so the change will be directly proportional to the elapsed time. This is predictable but also quite uninteresting visually wise. Worry not–this behaviour can be easily changed using the easing method. For example:

    tween.easing(TWEEN.Easing.Quadratic.In)
    

    Parameters

    Returns I3JS.Tween<T>

    easing

end

getId

  • getId(): number

group

interpolation

  • For example, when the tween has just started (progress is 0), the interpolation function will return the first value in the array. When the tween is halfway, the interpolation function will return a value approximately in the middle of the array, and when the tween is at the end, the interpolation function will return the last value.

    Parameters

    Returns I3JS.Tween<T>

    interpolation

isPaused

  • isPaused(): boolean

isPlaying

  • isPlaying(): boolean

onComplete

  • onComplete(callback?: (object: T) => void): I3JS.Tween<T>
  • Executed when a tween is finished normally (i.e. not stopped). The tweened object is passed in as the first parameter.

    Parameters

    • Optional callback: (object: T) => void
        • (object: T): void
        • Parameters

          • object: T

          Returns void

    Returns I3JS.Tween<T>

    complete

onEveryStart

  • onEveryStart(callback?: (object: T) => void): I3JS.Tween<T>

onRepeat

  • onRepeat(callback?: (object: T) => void): I3JS.Tween<T>
  • Executed whenever a tween has just finished one repetition and will begin another. The tweened object is passed in as the first parameter.

    Parameters

    • Optional callback: (object: T) => void
        • (object: T): void
        • Parameters

          • object: T

          Returns void

    Returns I3JS.Tween<T>

    repeat

onStart

  • onStart(callback?: (object: T) => void): I3JS.Tween<T>
  • Executed right before the tween starts animating, after any delay time specified by the delay method. This will be executed only once per tween, i.e. it will not be run when the tween is repeated via repeat().

    Parameters

    • Optional callback: (object: T) => void
        • (object: T): void
        • Parameters

          • object: T

          Returns void

    Returns I3JS.Tween<T>

    start

onStop

  • onStop(callback?: (object: T) => void): I3JS.Tween<T>
  • Executed when a tween is explicitly stopped via stop(), but not when it is completed normally, and before stopping any possible chained tween.

    Parameters

    • Optional callback: (object: T) => void
        • (object: T): void
        • Parameters

          • object: T

          Returns void

    Returns I3JS.Tween<T>

    stop

onUpdate

  • onUpdate(callback?: (object: T, elapsed: number) => void): I3JS.Tween<T>
  • Executed each time the tween is updated, after the values have been actually updated. The tweened object is passed in as the first parameter.

    Parameters

    • Optional callback: (object: T, elapsed: number) => void
        • (object: T, elapsed: number): void
        • Parameters

          • object: T
          • elapsed: number

          Returns void

    Returns I3JS.Tween<T>

    update

pause

repeat

  • If you wanted a tween to repeat forever you could chain it to itself, but a better way is to use the repeat method. It accepts a parameter that describes how many repetitions you want after the first tween is completed:

    tween.repeat(10) // repeats 10 times after the first tween and stops
    tween.repeat(Infinity) // repeats forever

    Parameters

    • Optional times: number

    Returns I3JS.Tween<T>

    repeat

repeatDelay

  • Normally the delay time is applied between repetitions of a tween, but if a value is provided to the repeatDelay function then that value will determine the total time elapsed between repetitions of a tween.

    tween.delay(1000)
    tween.repeatDelay(500)
    tween.start()
    // The first iteration of the tween will happen after one second, the second iteration will happen a half second after the first iteration ends, the third iteration will happen a half second after the second iteration ends, etc. If you want to delay the initial iteration but you don’t want any delay between iterations, then make sure to call tween.repeatDelay(0).

    Parameters

    • Optional amount: number

    Returns I3JS.Tween<T>

    delay

resume

start

stop

  • So far we’ve learnt about the Tween.start method, but there are more methods that control individual tweens. Probably the most important one is the start counterpart: stop. If you want to cancel a tween, just call this method over an individual tween:

    Returns I3JS.Tween<T>

    stop

stopChainedTweens

to

  • to(properties: T, duration?: number): I3JS.Tween<T>

update

  • update(time?: number, autoStart?: boolean): boolean
  • Parameters

    • Optional time: number
    • Optional autoStart: boolean

    Returns boolean

    true if the tween is still playing after the update, false otherwise (calling update on a paused tween still returns true because it is still playing, just paused).

yoyo

  • This function only has effect if used along with repeat. When active, the behaviour of the tween will be like a yoyo, i.e. it will bounce to and from the start and end values, instead of just repeating the same sequence from the beginning.

    Parameters

    • Optional yoyo: boolean

    Returns I3JS.Tween<T>

    yoyo

Generated using TypeDoc