Namespace: Builders

Phaser.Tweens. Builders

Methods


<static> GetBoolean(source, key, defaultValue)

Retrieves the value of the given key from an object.

Parameters:
Name Type Description
source object

The object to retrieve the value from.

key string

The key to look for in the source object.

defaultValue *

The default value to return if the key doesn't exist or if no source object is provided.

Since: 3.0.0
Source: src/tweens/builders/GetBoolean.js (Line 7)
Returns:

The retrieved value.

Type
*

<static> GetEaseFunction(ease [, easeParams])

This internal function is used to return the correct ease function for a Tween.

It can take a variety of input, including an EaseMap based string, or a custom function.

Parameters:
Name Type Argument Description
ease string | function

The ease to find. This can be either a string from the EaseMap, or a custom function.

easeParams Array.<number> <optional>

An optional array of ease parameters to go with the ease.

Since: 3.0.0
Source: src/tweens/builders/GetEaseFunction.js (Line 10)
Returns:

The ease function.

Type
function

<static> GetNewValue(source, key, defaultValue)

Internal function used by the Tween Builder to create a function that will return the given value from the source.

Parameters:
Name Type Description
source any

The source object to get the value from.

key string

The property to get from the source.

defaultValue any

A default value to return should the source not have the property set.

Since: 3.0.0
Source: src/tweens/builders/GetNewValue.js (Line 7)
Returns:

A function which when called will return the property value from the source.

Type
function

<static> GetProps(config)

Internal function used by the Tween Builder to return an array of properties that the Tween will be operating on. It takes a tween configuration object and then checks that none of the props entries start with an underscore, or that none of the direct properties are on the Reserved list.

Parameters:
Name Type Description
config Phaser.Types.Tweens.TweenBuilderConfig

The configuration object of the Tween to get the properties from.

Since: 3.0.0
Source: src/tweens/builders/GetProps.js (Line 9)
Returns:

An array of all the properties the tween will operate on.

Type
Array.<string>

<static> GetTargets(config)

Extracts an array of targets from a Tween configuration object.

The targets will be looked for in a targets property. If it's a function, its return value will be used as the result.

Parameters:
Name Type Description
config object

The configuration object to use.

Since: 3.0.0
Source: src/tweens/builders/GetTargets.js (Line 9)
Returns:

An array of targets (may contain only one element), or null if no targets were specified.

Type
array

<static> GetTweens(config)

Internal function used by the Timeline Builder.

It returns an array of all tweens in the given timeline config.

Parameters:
Name Type Description
config Phaser.Types.Tweens.TimelineBuilderConfig

The configuration object for the Timeline.

Since: 3.0.0
Source: src/tweens/builders/GetTweens.js (Line 9)
Returns:

An array of Tween instances that the Timeline will manage.

Type
Array.<Phaser.Tweens.Tween>

<static> GetValueOp(key, propertyValue)

Returns getActive, getStart and getEnd functions for a TweenData based on a target property and end value.

getActive if not null, is invoked immediately as soon as the TweenData is running, and is set on the target property. getEnd is invoked once any start delays have expired and returns what the value should tween to. getStart is invoked when the tween reaches the end and needs to either repeat or yoyo, it returns the value to go back to.

If the end value is a number, it will be treated as an absolute value and the property will be tweened to it. A string can be provided to specify a relative end value which consists of an operation (+= to add to the current value, -= to subtract from the current value, *= to multiply the current value, or /= to divide the current value) followed by its operand.

A function can be provided to allow greater control over the end value; it will receive the target object being tweened, the name of the property being tweened, and the current value of the property as its arguments.

If both the starting and the ending values need to be controlled, an object with getStart and getEnd callbacks, which will receive the same arguments, can be provided instead. If an object with a value property is provided, the property will be used as the effective value under the same rules described here.

Parameters:
Name Type Description
key string

The name of the property to modify.

propertyValue *

The ending value of the property, as described above.

Since: 3.0.0
Source: src/tweens/builders/GetValueOp.js (Line 39)
Returns:

An array of functions, getActive, getStart and getEnd, which return the starting and the ending value of the property based on the provided value.

Type
function

<static> NumberTweenBuilder(parent, config, defaults)

Creates a new Number Tween.

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

The owner of the new Tween.

config Phaser.Types.Tweens.NumberTweenBuilderConfig

Configuration for the new Tween.

defaults Phaser.Types.Tweens.TweenConfigDefaults

Tween configuration defaults.

Since: 3.0.0
Source: src/tweens/builders/NumberTweenBuilder.js (Line 17)
Returns:

The new tween.

Type
Phaser.Tweens.Tween

<static> StaggerBuilder(value [, config])

Creates a Stagger function to be used by a Tween property.

The stagger function will allow you to stagger changes to the value of the property across all targets of the tween.

This is only worth using if the tween has multiple targets.

The following will stagger the delay by 100ms across all targets of the tween, causing them to scale down to 0.2 over the duration specified:

this.tweens.add({
    targets: [ ... ],
    scale: 0.2,
    ease: 'linear',
    duration: 1000,
    delay: this.tweens.stagger(100)
});

The following will stagger the delay by 500ms across all targets of the tween using a 10 x 6 grid, staggering from the center out, using a cubic ease.

this.tweens.add({
    targets: [ ... ],
    scale: 0.2,
    ease: 'linear',
    duration: 1000,
    delay: this.tweens.stagger(500, { grid: [ 10, 6 ], from: 'center', ease: 'cubic.out' })
});
Parameters:
Name Type Argument Description
value number | Array.<number>

The amount to stagger by, or an array containing two elements representing the min and max values to stagger between.

config Phaser.Types.Tweens.StaggerConfig <optional>

A Stagger Configuration object.

Since: 3.19.0
Source: src/tweens/builders/StaggerBuilder.js (Line 10)
Returns:

The stagger function.

Type
function

<static> TimelineBuilder(manager, config)

Builds a Timeline of Tweens based on a configuration object.

Parameters:
Name Type Description
manager Phaser.Tweens.TweenManager

The Tween Manager to which the Timeline will belong.

config Phaser.Types.Tweens.TimelineBuilderConfig

The configuration object for the Timeline.

Since: 3.0.0
Source: src/tweens/builders/TimelineBuilder.js (Line 19)
Returns:

The created Timeline.

Type
Phaser.Tweens.Timeline

<static> TweenBuilder(parent, config, defaults)

Creates a new Tween.

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

The owner of the new Tween.

config Phaser.Types.Tweens.TweenBuilderConfig | object

Configuration for the new Tween.

defaults Phaser.Types.Tweens.TweenConfigDefaults

Tween configuration defaults.

Since: 3.0.0
Source: src/tweens/builders/TweenBuilder.js (Line 19)
Returns:

The new tween.

Type
Phaser.Tweens.Tween