Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions scripts/tsgen/test/src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,49 @@ class BootScene extends Phaser.Scene {
loop: 2
});

// Tween configs support custom tween properties without an object fallback
this.tweens.create({
targets: sprite,
customValue: 100
});

this.tweens.addMultiple([
{ targets: sprite, customValue: 200 },
tween,
chain
]);

this.tweens.create({
targets: sprite,
tweens: [
{ customValue: 300 }
]
});

this.tweens.chain({
tweens: [
{ targets: sprite, customValue: 400 },
tween
],
customChainOption: true
});

this.tweens.create(chain);
this.tweens.chain(chain);
chain.add([ tween ]);

// @ts-expect-error Invalid primitives are not Tween configuration objects
this.tweens.create([1]);

// @ts-expect-error Arbitrary objects are not Tween configuration objects
this.tweens.create({ unexpected: true });

// @ts-expect-error Tween chain configurations require the typed config shape
this.tweens.chain({});

// @ts-expect-error Invalid primitives are not Tween configuration objects
this.tweens.addMultiple([1]);

// Number tween
let counter = this.tweens.addCounter({
from: 0,
Expand Down
10 changes: 5 additions & 5 deletions src/tweens/TweenManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ var TweenManager = new Class({
* @method Phaser.Tweens.TweenManager#create
* @since 3.0.0
*
* @param {Phaser.Types.Tweens.TweenBuilderConfig|Phaser.Types.Tweens.TweenBuilderConfig[]|object|object[]} config - A Tween Configuration object. Or an array of Tween Configuration objects.
* @param {Phaser.Types.Tweens.TweenBuilderConfig|Phaser.Types.Tweens.TweenChainBuilderConfig|Phaser.Tweens.Tween|Phaser.Tweens.TweenChain|Array.<(Phaser.Types.Tweens.TweenBuilderConfig|Phaser.Types.Tweens.TweenChainBuilderConfig|Phaser.Tweens.Tween|Phaser.Tweens.TweenChain)>} config - A Tween Configuration object, a Tween or TweenChain instance, or an array of them.
*
* @return {Phaser.Tweens.Tween|Phaser.Tweens.Tween[]} The created Tween, or an array of Tweens if an array of tween configs was provided.
* @return {Phaser.Tweens.Tween|Phaser.Tweens.TweenChain|Array.<(Phaser.Tweens.Tween|Phaser.Tweens.TweenChain)>} The created Tween or TweenChain, or an array of them if an array was provided.
*/
create: function (config)
{
Expand Down Expand Up @@ -376,9 +376,9 @@ var TweenManager = new Class({
* @method Phaser.Tweens.TweenManager#addMultiple
* @since 3.60.0
*
* @param {Phaser.Types.Tweens.TweenBuilderConfig[]|object[]} configs - An array of Tween Configuration objects.
* @param {Array.<(Phaser.Types.Tweens.TweenBuilderConfig|Phaser.Types.Tweens.TweenChainBuilderConfig|Phaser.Tweens.Tween|Phaser.Tweens.TweenChain)>} configs - An array of Tween Configuration objects, Tweens or TweenChains.
*
* @return {Phaser.Tweens.Tween[]} An array of created Tweens.
* @return {Array.<(Phaser.Tweens.Tween|Phaser.Tweens.TweenChain)>} An array of created Tweens and TweenChains.
*/
addMultiple: function (configs)
{
Expand Down Expand Up @@ -429,7 +429,7 @@ var TweenManager = new Class({
* @method Phaser.Tweens.TweenManager#chain
* @since 3.60.0
*
* @param {Phaser.Types.Tweens.TweenChainBuilderConfig|object} tweens - A Tween Chain configuration object.
* @param {Phaser.Types.Tweens.TweenChainBuilderConfig|Phaser.Tweens.TweenChain} config - A Tween Chain configuration object or TweenChain instance.
*
* @return {Phaser.Tweens.TweenChain} The Tween Chain instance.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/tweens/builders/TweenBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var Tween = require('../tween/Tween');
* @since 3.0.0
*
* @param {Phaser.Tweens.TweenManager} parent - The owner of the new Tween.
* @param {Phaser.Types.Tweens.TweenBuilderConfig|object} config - Configuration for the new Tween.
* @param {Phaser.Types.Tweens.TweenBuilderConfig|Phaser.Tweens.Tween} config - Configuration for the new Tween, or an existing Tween instance.
* @param {Phaser.Types.Tweens.TweenConfigDefaults} defaults - Tween configuration defaults.
*
* @return {Phaser.Tweens.Tween} The new tween.
Expand Down
2 changes: 1 addition & 1 deletion src/tweens/builders/TweenChainBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var TweenChain = require('../tween/TweenChain');
* @since 3.60.0
*
* @param {Phaser.Tweens.TweenManager} parent - The owner of the new Tween.
* @param {Phaser.Types.Tweens.TweenChainBuilderConfig|object} config - Configuration for the new Tween.
* @param {Phaser.Types.Tweens.TweenChainBuilderConfig|Phaser.Tweens.TweenChain} config - Configuration for the new Tween Chain, or an existing TweenChain instance.
*
* @return {Phaser.Tweens.TweenChain} The new Tween Chain.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/tweens/tween/TweenChain.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ var TweenChain = new Class({
* @method Phaser.Tweens.TweenChain#add
* @since 3.60.0
*
* @param {Phaser.Types.Tweens.TweenBuilderConfig[]|object[]} tweens - An array of Tween configuration objects for the Tweens in this chain.
* @param {Array.<(Phaser.Types.Tweens.TweenBuilderConfig|Phaser.Types.Tweens.TweenChainBuilderConfig|Phaser.Tweens.Tween|Phaser.Tweens.TweenChain)>} tweens - An array of Tween configuration objects, Tweens or TweenChains.
*
* @return {this} This TweenChain instance.
*/
Expand Down Expand Up @@ -544,7 +544,7 @@ var TweenChain = new Class({
* @method Phaser.GameObjects.GameObjectFactory#tweenchain
* @since 3.60.0
*
* @param {Phaser.Types.Tweens.TweenBuilderConfig|object} config - The TweenChain configuration.
* @param {Phaser.Types.Tweens.TweenChainBuilderConfig|Phaser.Tweens.TweenChain} config - The TweenChain configuration or an existing TweenChain instance.
*
* @return {Phaser.Tweens.TweenChain} The TweenChain that was created.
*/
Expand All @@ -561,7 +561,7 @@ GameObjectFactory.register('tweenchain', function (config)
* @method Phaser.GameObjects.GameObjectCreator#tweenchain
* @since 3.60.0
*
* @param {Phaser.Types.Tweens.TweenBuilderConfig|object} config - The TweenChain configuration.
* @param {Phaser.Types.Tweens.TweenChainBuilderConfig|Phaser.Tweens.TweenChain} config - The TweenChain configuration or an existing TweenChain instance.
*
* @return {Phaser.Tweens.TweenChain} The TweenChain that was created.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/tweens/typedefs/TweenChainBuilderConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* @extends object
* @since 3.60.0
*
* @property {any} targets - The object, or an array of objects, to run each tween on.
* @property {any} [targets] - The object, or an array of objects, to run each tween on.
* @property {(number|function)} [delay=0] - The number of milliseconds to delay before the chain will start.
* @property {string|number|function|object|array} [completeDelay=0] - The time the chain will wait before the onComplete event is dispatched once it has completed, in ms.
* @property {string|number|function|object|array} [loop=0] - The number of times the chain will repeat. (A value of 1 means the chain will play twice, as it repeated once.) The first loop starts after every tween has completed once.
* @property {string|number|function|object|array} [loopDelay=0] - The time the chain will pause before returning to the start for a repeat.
* @property {boolean} [paused=false] - Does the chain start in a paused state (true) or playing (false)?
* @property {Phaser.Types.Tweens.TweenBuilderConfig[]} [tweens] - The tweens to chain together.
* @property {Array.<(Partial.<Phaser.Types.Tweens.TweenBuilderConfig>|Phaser.Tweens.Tween)>} tweens - The tweens to chain together. Each Tween configuration can inherit targets from this Tween Chain.
* @property {any} [callbackScope] - The scope (or context) for all of the callbacks. The default scope is the chain.
* @property {Phaser.Types.Tweens.TweenOnCompleteCallback} [onComplete] - A function to call when the chain completes.
* @property {array} [onCompleteParams] - Additional parameters to pass to `onComplete`.
Expand Down