phaser - v4.0.0-rc.4
    Preparing search index...

    The TweenData is a class that contains a single target and property that is being tweened.

    Tweens create TweenData instances when they are created, with one TweenData instance per target, per property. A Tween can own multiple TweenData instances, but a TweenData only ever belongs to a single Tween.

    You should not typically create these yourself, but rather use the TweenBuilder, or the Tween.add method.

    Prior to Phaser 3.60 the TweenData was just an object, but was refactored to a class, to make it responsible for its own state and updating.

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • tween: Tween

        The tween this TweenData instance belongs to.

      • targetIndex: number

        The target index within the Tween targets array.

      • key: string

        The property of the target to tween.

      • getEnd: GetEndCallback

        What the property will be at the END of the Tween.

      • getStart: GetStartCallback

        What the property will be at the START of the Tween.

      • getActive: GetActiveCallback

        If not null, is invoked immediately as soon as the TweenData is running, and is set on the target property.

      • ease: Function

        The ease function this tween uses.

      • delay: Function

        Function that returns the time in milliseconds before tween will start.

      • duration: number

        The duration of the tween in milliseconds.

      • yoyo: boolean

        Determines whether the tween should return back to its start value after hold has expired.

      • hold: number

        Function that returns the time in milliseconds the tween will pause before repeating or returning to its starting value if yoyo is set to true.

      • repeat: number

        Function that returns the number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice.

      • repeatDelay: number

        Function that returns the time in milliseconds before the repeat will start.

      • flipX: boolean

        Should toggleFlipX be called when yoyo or repeat happens?

      • flipY: boolean

        Should toggleFlipY be called when yoyo or repeat happens?

      • interpolation: Function

        The interpolation function to be used for arrays of data. Defaults to 'null'.

      • interpolationData: number[]

        The array of interpolation data to be set. Defaults to 'null'.

      Returns TweenData

    Properties

    current: number

    The targets current value, as recorded in the most recent step.

    delay: number

    The time, in milliseconds, before this tween will start playing.

    This value is generated by the getDelay function.

    duration: number

    The duration of the tween in milliseconds, excluding any time required for yoyo or repeats. A tween can never have a duration of zero, so this will be set to 0.01 if the value is incorrectly less than or equal to zero.

    ease: Function

    The ease function this Tween uses to calculate the target value.

    elapsed: number

    The amount of time, in milliseconds, that has elapsed since this TweenData was made active.

    end: number

    The targets ending value, as returned by getEndValue.

    flipX: boolean

    If true this Tween will call toggleFlipX on the Tween target whenever it yoyo's or repeats. It will only be called if the target has a function matching this name, like most Phaser GameObjects do.

    flipY: boolean

    If true this Tween will call toggleFlipY on the Tween target whenever it yoyo's or repeats. It will only be called if the target has a function matching this name, like most Phaser GameObjects do.

    getActiveValue: GetActiveCallback

    A function that returns what to set the target property to, the moment the TweenData is invoked.

    This is called when this TweenData is initialised or reset.

    getDelay: Function

    This function returns the value to be used for TweenData.delay.

    getEndValue: GetEndCallback

    A function that returns what to set the target property to at the end of the tween.

    This is called when the tween starts playing, after any initial start delay, or if the tween is reset, or is set to repeat.

    getStartValue: GetStartCallback

    A function that returns what to set the target property to at the start of the tween.

    This is called when the tween starts playing, after any initial start delay, or if the tween is reset, or is set to repeat.

    hold: number

    The time, in milliseconds, before this tween will start a yoyo to repeat.

    interpolation: Function

    The interpolation function to be used for arrays of data.

    interpolationData: number[]

    The array of data to interpolate, if interpolation is being used.

    isCountdown: boolean

    Is this Tween Data currently waiting for a countdown to elapse, or not?

    key: string

    The property of the target to be tweened.

    previous: number

    The target value from the previous step.

    progress: number

    A value between 0 and 1 holding the progress of this TweenData.

    repeat: number

    The number of times this tween will repeat.

    The tween will always run once regardless of this value, so a repeat value of '1' will play the tween twice: I.e. the original play-through and then it repeats that once (1).

    If this value is set to -1 this tween will repeat forever.

    repeatCounter: number

    How many repeats are left to run?

    repeatDelay: number

    The time, in milliseconds, before the repeat will start.

    start: number

    The targets starting value, as returned by getStartValue.

    state: States

    The state of this TweenData.

    targetIndex: number

    The index of the target within the Tween targets array.

    totalDuration: number

    The total calculated duration, in milliseconds, of this TweenData. Factoring in the duration, repeats, delays and yoyos.

    tween: Tween

    A reference to the Tween that this TweenData instance belongs to.

    yoyo: boolean

    Will the Tween ease back to its starting values, after reaching the end and any hold value that may be set?

    Methods

    • Internal method that will emit a TweenData based Event on the parent Tween and also invoke the given callback, if provided.

      Parameters

      • event: string

        The Event to be dispatched.

      • Optionalcallback: TweenCallbackTypes

        The name of the callback to be invoked. Can be null or undefined to skip invocation.

      Returns void

    • Internal method that handles repeating or yoyo'ing this TweenData.

      Called automatically by setStateFromStart and setStateFromEnd.

      Parameters

      • diff: number

        Any extra time that needs to be accounted for in the elapsed and progress values.

      • setStart: boolean

        Set the TweenData start values?

      • isYoyo: boolean

        Is this call a Yoyo check?

      Returns void

    • Internal method that resets this Tween Data entirely, including the progress and elapsed values.

      Called automatically by the parent Tween. Should not be called directly.

      Parameters

      • OptionalisSeeking: boolean

        Is the Tween Data being reset as part of a Tween seek? Default false.

      Returns void

    • Internal method used as part of the playback process that checks if this TweenData should yoyo, repeat, or has completed.

      Parameters

      • diff: number

        Any extra time that needs to be accounted for in the elapsed and progress values.

      Returns void

    • Internal method used as part of the playback process that checks if this TweenData should repeat or has completed.

      Parameters

      • diff: number

        Any extra time that needs to be accounted for in the elapsed and progress values.

      Returns void

    • Sets this TweenData's target object property to be the given value.

      Parameters

      • Optionalvalue: number

        The value to set on the target. If not given, sets it to the last current value.

      Returns void

    • Internal method that advances this TweenData based on the delta value given.

      Parameters

      • delta: number

        The elapsed delta time in ms.

      Returns boolean