Phaser API Documentation

  Version: 

Member of: Phaser.Tweens.Tween

seek([amount], [delta], [emit])

Description:

Seeks to a specific point in the Tween.

The given amount is a value in milliseconds that represents how far into the Tween you wish to seek, based on the start of the Tween.

Note that the seek amount takes the entire duration of the Tween into account, including delays, loops and repeats. For example, a Tween that lasts for 2 seconds, but that loops 3 times, would have a total duration of 6 seconds, so seeking to 3000 ms would seek to the Tweens half-way point based on its entire duration.

Prior to Phaser 3.60 this value was given as a number between 0 and 1 and didn't work for Tweens had an infinite repeat. This new method works for all Tweens.

Seeking works by resetting the Tween to its initial values and then iterating through the Tween at delta jumps per step. The longer the Tween, the longer this can take. If you need more precision you can reduce the delta value. If you need a faster seek, you can increase it. When the Tween is reset it will refresh the starting and ending values. If these are coming from a dynamic function, or a random array, it will be called for each seek.

While seeking the Tween will not emit any of its events or callbacks unless the 3rd parameter is set to true.

If this Tween is paused, seeking will not change this fact. It will advance the Tween to the desired point and then pause it again.

Parameters:

name type arguments Default description
amount number <optional> 0

The number of milliseconds to seek into the Tween from the beginning.

delta number <optional> 16.6

The size of each step when seeking through the Tween. A higher value completes faster but at the cost of less precision.

emit boolean <optional> false

While seeking, should the Tween emit any of its events or callbacks? The default is 'false', i.e. to seek silently.

Returns:
Description:

This Tween instance.

Since: 3.0.0