Class: Tween

Phaser.Tweens. Tween

[description]


new Tween(parent, data, targets)

Parameters:
Name Type Description
parent Phaser.Tweens.TweenManager | Phaser.Tweens.Timeline

[description]

data Array.<Phaser.Tweens.TweenDataConfig>

[description]

targets array

[description]

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 12)

Members


calculatedOffset :number

Set only if this Tween is part of a Timeline. The calculated offset amount.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/tweens/tween/Tween.js (Line 167)

callbacks :object

An object containing the various Tween callback references.

Type:
  • object
Since: 3.0.0
Default Value:
  • 0
Source: src/tweens/tween/Tween.js (Line 266)

completeDelay :number

Time in ms/frames before the 'onComplete' event fires. This never fires if loop = -1 (as it never completes)

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/tweens/tween/Tween.js (Line 137)

countdown :number

Countdown timer (used by timeline offset, loopDelay and completeDelay)

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/tweens/tween/Tween.js (Line 147)

data :Array.<Phaser.Tweens.TweenDataConfig>

An array of TweenData objects, each containing a unique property and target being tweened.

Type:
Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 49)

duration :number

Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/tweens/tween/Tween.js (Line 226)

elapsed :number

Elapsed time in ms/frames of this run through the Tween.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/tweens/tween/Tween.js (Line 206)

loop :number

Loop this tween? Can be -1 for an infinite loop, or an integer.
When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD)

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/tweens/tween/Tween.js (Line 106)

loopCounter :number

How many loops are left to run?

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/tweens/tween/Tween.js (Line 127)

loopDelay :number

Time in ms/frames before the tween loops.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/tweens/tween/Tween.js (Line 117)

offset :number

Set only if this Tween is part of a Timeline.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/tweens/tween/Tween.js (Line 157)

parent :Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline

[description]

Type:
Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 31)

parentIsTimeline :boolean

Is the parent of this Tween a Timeline?

Type:
  • boolean
Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 40)

paused :boolean

Does the Tween start off paused? (if so it needs to be started with Tween.play)

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/tweens/tween/Tween.js (Line 196)

progress :number

Value between 0 and 1. The amount through the Tween, excluding loops.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/tweens/tween/Tween.js (Line 236)

state :integer

The current state of the tween

Type:
  • integer
Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 177)

targets :Array.<object>

An array of references to the target/s this Tween is operating on

Type:
  • Array.<object>
Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 67)

timeScale :number

Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on.
Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only.

Type:
  • number
Since: 3.0.0
Default Value:
  • 1
Source: src/tweens/tween/Tween.js (Line 95)

totalData :integer

data array doesn't change, so we can cache the length

Type:
  • integer
Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 58)

totalDuration :number

Time in ms/frames for the Tween to complete (including looping)

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/tweens/tween/Tween.js (Line 246)

totalElapsed :number

Total elapsed time in ms/frames of the entire Tween, including looping.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/tweens/tween/Tween.js (Line 216)

totalProgress :number

Value between 0 and 1. The amount through the entire Tween, including looping.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/tweens/tween/Tween.js (Line 256)

totalTargets :integer

Cached target total (not necessarily the same as the data total)

Type:
  • integer
Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 76)

useFrames :boolean

If true then duration, delay, etc values are all frame totals.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/tweens/tween/Tween.js (Line 85)

Methods


calcDuration()

[description]

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 424)

complete( [delay])

Flags the Tween as being complete, whatever stage of progress it is at.

If an onComplete callback has been defined it will automatically invoke it, unless a delay
argument is provided, in which case the Tween will delay for that period of time before calling the callback.

If you don't need a delay, or have an onComplete callback, then call Tween.stop instead.

Parameters:
Name Type Argument Default Description
delay number <optional>
0

The time to wait before invoking the complete callback. If zero it will fire immediately.

Since: 3.2.0
Source: src/tweens/tween/Tween.js (Line 845)

getTimeScale()

[description]

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 316)
Returns:

[description]

Type
number

getValue()

[description]

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 286)
Returns:

[description]

Type
number

hasTarget(target)

[description]

Parameters:
Name Type Description
target object

[description]

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 355)
Returns:

[description]

Type
boolean

init()

Called by TweenManager.preUpdate as part of its loop to check pending and active tweens.
Should not be called directly.

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 485)
Returns:

Returns true if this Tween should be moved from the pending list to the active list by the Tween Manager.

Type
boolean

isPaused()

Checks if the Tween is currently paused.

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 342)
Returns:

true if the Tween is paused, otherwise false.

Type
boolean

isPlaying()

Checks if the Tween is currently active.

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 329)
Returns:

true if the Tween is active, otherwise false.

Type
boolean

nextState()

[description]

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 535)

pause()

[description]

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 590)
Returns:

This Tween object.

Type
Phaser.Tweens.Tween

play(resetFromTimeline)

[description]

Parameters:
Name Type Description
resetFromTimeline boolean

[description]

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 614)

resetTweenData(resetFromLoop)

[description]

Parameters:
Name Type Description
resetFromLoop boolean

[description]

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 682)

restart()

[description]

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 404)

resume()

Resumes the playback of a previously paused Tween.

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 725)
Returns:

This Tween object.

Type
Phaser.Tweens.Tween

seek(toPosition)

[description]

Parameters:
Name Type Description
toPosition number

A value between 0 and 1.

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 749)

setCallback(type, callback [, params] [, scope])

[description]

Parameters:
Name Type Argument Description
type string

[description]

callback function

[description]

params array <optional>

[description]

scope object <optional>

[description]

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 825)
Returns:

This Tween object.

Type
Phaser.Tweens.Tween

setStateFromEnd(tween, tweenData, diff)

[description]

Parameters:
Name Type Description
tween Phaser.Tweens.Tween

[description]

tweenData Phaser.Tweens.TweenDataConfig

[description]

diff number

[description]

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 1018)
Returns:

The state of this Tween.

Type
integer

setStateFromStart(tween, tweenData, diff)

Was PLAYING_BACKWARD and has hit the start.

Parameters:
Name Type Description
tween Phaser.Tweens.Tween

[description]

tweenData Phaser.Tweens.TweenDataConfig

[description]

diff number

[description]

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 1122)
Returns:

The state of this Tween.

Type
integer

setTimeScale(value)

[description]

Parameters:
Name Type Description
value number

[description]

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 299)
Returns:

This Tween object.

Type
Phaser.Tweens.Tween

stop( [resetTo])

Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager.

Parameters:
Name Type Argument Description
resetTo number <optional>

A value between 0 and 1.

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 882)

update(timestamp, delta)

[description]

Parameters:
Name Type Description
timestamp number

[description]

delta number

The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate.

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 912)
Returns:

Returns true if this Tween has finished and should be removed from the Tween Manager, otherwise returns false.

Type
boolean

updateTo(key, value, startToCurrent)

[description]

Parameters:
Name Type Description
key string

[description]

value *

[description]

startToCurrent boolean

[description]

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 370)
Returns:

This Tween object.

Type
Phaser.Tweens.Tween

updateTweenData(tween, tweenData, delta)

[description]

Parameters:
Name Type Description
tween Phaser.Tweens.Tween

[description]

tweenData Phaser.Tweens.TweenDataConfig

[description]

delta number

Either a value in ms, or 1 if Tween.useFrames is true

Since: 3.0.0
Source: src/tweens/tween/Tween.js (Line 1187)
Returns:

[description]

Type
boolean