Class: TweenData

Phaser. TweenData

new TweenData(parent)

A Phaser.Tween contains at least one TweenData object. It contains all of the tween data values, such as the starting and ending values, the ease function, interpolation and duration. The Tween acts as a timeline manager for TweenData objects and can contain multiple TweenData objects.

Parameters:
Name Type Description
parent Phaser.Tween

The Tween that owns this TweenData object.

Source:
src/tween/TweenData.js line 16

Members

<static, constant> COMPLETE : number

Type:
  • number
Source:
src/tween/TweenData.js line 179

<static, constant> LOOPED : number

Type:
  • number
Source:
src/tween/TweenData.js line 173

<static, constant> PENDING : number

Type:
  • number
Source:
src/tween/TweenData.js line 161

<static, constant> RUNNING : number

Type:
  • number
Source:
src/tween/TweenData.js line 167

delay : number

The amount to delay by until the Tween starts (in ms). Only applies to the start, use repeatDelay to handle repeats.

Type:
  • number
Source:
src/tween/TweenData.js line 114

dt : number

Current time value.

Type:
  • number
Source:
src/tween/TweenData.js line 119

duration : number

The duration of the tween in ms.

Type:
  • number
Default Value:
  • 1000
Source:
src/tween/TweenData.js line 56

easingFunction : function

The easing function used for the Tween.

Type:
  • function
Default Value:
  • Phaser.Easing.Default
Source:
src/tween/TweenData.js line 130

game : Phaser.Game

A reference to the currently running Game.

Type:
Source:
src/tween/TweenData.js line 26

inReverse : boolean

When a Tween is yoyoing this value holds if it's currently playing forwards (false) or in reverse (true).

Type:
  • boolean
Source:
src/tween/TweenData.js line 108

interpolate : boolean

True if the Tween will use interpolation (i.e. is an Array to Array tween)

Type:
  • boolean
Source:
src/tween/TweenData.js line 91
To Do:
  • Appears unused.

interpolationContext : object

The interpolation function context used for the Tween.

Type:
  • object
Default Value:
  • Phaser.Math
Source:
src/tween/TweenData.js line 142

interpolationFunction : function

The interpolation function used for Array-based Tween.

Type:
  • function
Default Value:
  • Phaser.Math.linearInterpolation
Source:
src/tween/TweenData.js line 136

isFrom : boolean

Is this a from tween or a to tween?

Type:
  • boolean
Source:
src/tween/TweenData.js line 154

isRunning : boolean

If the tween is running this is set to true. Unless Phaser.Tween a TweenData that is waiting for a delay to expire is not considered as running.

Type:
  • boolean
Source:
src/tween/TweenData.js line 148

parent : Phaser.Tween

The Tween which owns this TweenData.

Type:
Source:
src/tween/TweenData.js line 21

<readonly> percent : number

A value between 0 and 1 that represents how far through the duration this tween is.

Type:
  • number
Source:
src/tween/TweenData.js line 62

repeatCounter : number

If the Tween is set to repeat this is the number of repeats remaining (and repeatTotal - repeatCounter is the number of repeats completed).

Type:
  • number
Source:
src/tween/TweenData.js line 73

repeatDelay : number

The amount of time in ms between repeats of this tween.

Type:
  • number
Source:
src/tween/TweenData.js line 78

<readonly> repeatTotal : number

The total number of times this Tween will repeat.

Type:
  • number
Source:
src/tween/TweenData.js line 84

startTime : number

The time the Tween started or null if it hasn't yet started.

Type:
  • number
Source:
src/tween/TweenData.js line 124

<readonly> value : number

The output of the easing function for the current percent. Depending on the easing function, this will be within [0, 1] or a slightly larger range (e.g., Bounce). When easing is Linear, this will be identical to percent.

Type:
  • number
Source:
src/tween/TweenData.js line 68

yoyo : boolean

True if the Tween is set to yoyo, otherwise false.

Type:
  • boolean
Source:
src/tween/TweenData.js line 97

yoyoDelay : number

The amount of time in ms between yoyos of this tween.

Type:
  • number
Source:
src/tween/TweenData.js line 102

Methods

from(properties [, duration] [, ease] [, delay] [, repeat] [, yoyo])

Sets this tween to be a from tween on the properties given. A from tween sets the target to the destination value and tweens to its current value. For example a Sprite with an x coordinate of 100 tweened from x 500 would be set to x 500 and then tweened to x 100 by giving a properties object of { x: 500 }.

Parameters:
Name Type Argument Default Description
properties object

The properties you want to tween, such as Sprite.x or Sound.volume. Given as a JavaScript object.

duration number <optional>
1000

Duration of this tween in ms.

ease function <optional>
null

Easing function. If not set it will default to Phaser.Easing.Default, which is Phaser.Easing.Linear.None by default but can be over-ridden at will.

delay number <optional>
0

Delay before this tween will start, defaults to 0 (no delay). Value given is in ms.

repeat number <optional>
0

Should the tween automatically restart once complete? If you want it to run forever set as -1. This ignores any chained tweens.

yoyo boolean <optional>
false

A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead.

Source:
src/tween/TweenData.js line 210
Returns:

This Tween object.

Type
Phaser.TweenData

generateData( [frameRate])

This will generate an array populated with the tweened object values from start to end. It works by running the tween simulation at the given frame rate based on the values set-up in Tween.to and Tween.from. Just one play through of the tween data is returned, including yoyo if set.

Parameters:
Name Type Argument Default Description
frameRate number <optional>
60

The speed in frames per second that the data should be generated at. The higher the value, the larger the array it creates.

Source:
src/tween/TweenData.js line 407
Returns:

An array of tweened values.

Type
array

start()

Starts the Tween running.

Source:
src/tween/TweenData.js line 237
Returns:

This Tween object.

Type
Phaser.TweenData

to(properties [, duration] [, ease] [, delay] [, repeat] [, yoyo])

Sets this tween to be a to tween on the properties given. A to tween starts at the current value and tweens to the destination value given. For example a Sprite with an x coordinate of 100 could be tweened to x 200 by giving a properties object of { x: 200 }.

Parameters:
Name Type Argument Default Description
properties object

The properties you want to tween, such as Sprite.x or Sound.volume. Given as a JavaScript object.

duration number <optional>
1000

Duration of this tween in ms.

ease function <optional>
null

Easing function. If not set it will default to Phaser.Easing.Default, which is Phaser.Easing.Linear.None by default but can be over-ridden at will.

delay number <optional>
0

Delay before this tween will start, defaults to 0 (no delay). Value given is in ms.

repeat number <optional>
0

Should the tween automatically restart once complete? If you want it to run forever set as -1. This ignores any chained tweens.

yoyo boolean <optional>
false

A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead.

Source:
src/tween/TweenData.js line 183
Returns:

This Tween object.

Type
Phaser.TweenData

<protected> update(time)

Updates this Tween. This is called automatically by Phaser.Tween.

Parameters:
Name Type Description
time number

A timestamp passed in by the Tween parent.

Source:
src/tween/TweenData.js line 337
Returns:

The current status of this Tween. One of the Phaser.TweenData constants: PENDING, RUNNING, LOOPED or COMPLETE.

Type
number

phaser-ce@2.20.1 is on GitHub and NPM

Documentation generated by JSDoc 3.6.11 on 2024-10-05 using Tomorrow.