Phaser API Documentation

  Version: 
add(config)

Description:

Create a Tween and add it to this Tween Manager by passing a Tween Configuration object.

Example, run from within a Scene:

const logo = this.add.image(100, 100, 'logo');

this.tweens.add({
  targets: logo,
  x: 600,
  ease: 'Power1',
  duration: 2000
});

See the TweenBuilderConfig for all of the options you have available.

Playback will start immediately unless the tween has been configured to be paused.

Please note that a Tween will not manipulate any target property that begins with an underscore.

Tweens are designed to be 'fire-and-forget'. They automatically destroy themselves once playback is complete, to free-up memory and resources. If you wish to keep a tween after playback, i.e. to play it again at a later time, then you should set the persist property to true in the config. However, doing so means it's entirely up to you to destroy the tween when you're finished with it, otherwise it will linger in memory forever.

If you wish to chain Tweens together for sequential playback, see the TweenManager.chain method.

Parameters:

name type description
config Phaser.Tweens.Tween | Phaser.Tweens.TweenChain | Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenChainBuilderConfig

A Tween Configuration object, or a Tween or TweenChain instance.

Returns:
Description:

The created Tween.

Since: 3.0.0