Skip to content

Commit 90e04c7

Browse files
authored
Merge pull request phaserjs#4563 from samme/types/tween-configs
Add types for tween configs
2 parents df0b474 + 7a98fe6 commit 90e04c7

14 files changed

Lines changed: 163 additions & 44 deletions

src/gameobjects/components/PathFollower.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ var PathFollower = {
108108
* @since 3.0.0
109109
*
110110
* @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time.
111-
* @param {Phaser.Types.GameObjects.PathFollower.PathConfig} [config] - Settings for the PathFollower.
111+
* @param {(number|Phaser.Types.GameObjects.PathFollower.PathConfig|Phaser.Types.Tweens.NumberTweenBuilderConfig)} [config] - Settings for the PathFollower.
112112
*
113113
* @return {Phaser.GameObjects.PathFollower} This Game Object.
114114
*/
@@ -178,7 +178,7 @@ var PathFollower = {
178178
* @method Phaser.GameObjects.Components.PathFollower#startFollow
179179
* @since 3.3.0
180180
*
181-
* @param {(number|Phaser.Types.GameObjects.PathFollower.PathConfig)} [config={}] - The duration of the follow, or a PathFollower config object.
181+
* @param {(number|Phaser.Types.GameObjects.PathFollower.PathConfig|Phaser.Types.Tweens.NumberTweenBuilderConfig)} [config={}] - The duration of the follow, or a PathFollower config object.
182182
* @param {number} [startAt=0] - Optional start position of the follow, between 0 and 1.
183183
*
184184
* @return {Phaser.GameObjects.PathFollower} This Game Object.

src/gameobjects/pathfollower/typedefs/PathConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @typedef {object} Phaser.Types.GameObjects.PathFollower.PathConfig
55
* @since 3.0.0
66
*
7-
* @property {number} duration - The duration of the path follow in ms. Must be `> 0`.
7+
* @property {number} [duration=1000] - The duration of the path follow in ms. Must be `> 0`.
88
* @property {number} [from=0] - The start position of the path follow, between 0 and 1. Must be less than `to`.
99
* @property {number} [to=1] - The end position of the path follow, between 0 and 1. Must be more than `from`.
1010
* @property {boolean} [positionOnPath=false] - Whether to position the PathFollower on the Path using its path offset.

src/tweens/TweenManager.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ var TweenManager = new Class({
193193
* @method Phaser.Tweens.TweenManager#create
194194
* @since 3.0.0
195195
*
196-
* @param {object} config - The configuration object for the Tween as per {@link Phaser.Tweens.Builders.TweenBuilder}.
196+
* @param {Phaser.Types.Tweens.TweenBuilderConfig|object} config - The configuration object for the Tween.
197197
*
198198
* @return {Phaser.Tweens.Tween} The created Tween object.
199199
*/
@@ -208,7 +208,7 @@ var TweenManager = new Class({
208208
* @method Phaser.Tweens.TweenManager#add
209209
* @since 3.0.0
210210
*
211-
* @param {object} config - The configuration object for the Tween as per the {@link Phaser.Tweens.Builders.TweenBuilder}.
211+
* @param {Phaser.Types.Tweens.TweenBuilderConfig|object} config - The configuration object for the Tween.
212212
*
213213
* @return {Phaser.Tweens.Tween} The created Tween.
214214
*/
@@ -243,12 +243,12 @@ var TweenManager = new Class({
243243
},
244244

245245
/**
246-
* Create a Tween and add it to the active Tween list.
246+
* Create a Number Tween and add it to the active Tween list.
247247
*
248248
* @method Phaser.Tweens.TweenManager#addCounter
249249
* @since 3.0.0
250250
*
251-
* @param {object} config - The configuration object for the Number Tween as per the {@link Phaser.Tweens.Builders.NumberTweenBuilder}.
251+
* @param {Phaser.Types.Tweens.NumberTweenBuilderConfig} config - The configuration object for the Number Tween.
252252
*
253253
* @return {Phaser.Tweens.Tween} The created Number Tween.
254254
*/

src/tweens/builders/NumberTweenBuilder.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ var Tween = require('../tween/Tween');
1515
var TweenData = require('../tween/TweenData');
1616

1717
/**
18-
* [description]
18+
* Creates a new Number Tween.
1919
*
2020
* @function Phaser.Tweens.Builders.NumberTweenBuilder
2121
* @since 3.0.0
2222
*
23-
* @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description]
24-
* @param {object} config - [description]
25-
* @param {Phaser.Types.Tweens.TweenConfigDefaults} defaults - [description]
23+
* @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - The owner of the new Tween.
24+
* @param {Phaser.Types.Tweens.NumberTweenBuilderConfig} config - Configuration for the new Tween.
25+
* @param {Phaser.Types.Tweens.TweenConfigDefaults} defaults - Tween configuration defaults.
2626
*
27-
* @return {Phaser.Tweens.Tween} [description]
27+
* @return {Phaser.Tweens.Tween} The new tween.
2828
*/
2929
var NumberTweenBuilder = function (parent, config, defaults)
3030
{

src/tweens/builders/TweenBuilder.js

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,16 @@ var Tween = require('../tween/Tween');
1717
var TweenData = require('../tween/TweenData');
1818

1919
/**
20-
* [description]
20+
* Creates a new Tween.
2121
*
2222
* @function Phaser.Tweens.Builders.TweenBuilder
2323
* @since 3.0.0
2424
*
25-
* @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description]
26-
* @param {object} config - [description]
25+
* @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - The owner of the new Tween.
26+
* @param {Phaser.Types.Tweens.TweenBuilderConfig|object} config - Configuration for the new Tween.
2727
* @param {Phaser.Types.Tweens.TweenConfigDefaults} defaults - Tween configuration defaults.
28-
`
29-
* @property {(object|object[])} targets - The object, or an array of objects, to run the tween on.
30-
* @property {number} [delay=0] - The number of milliseconds to delay before the tween will start.
31-
* @property {number} [duration=1000] - The duration of the tween in milliseconds.
32-
* @property {string} [ease='Power0'] - The easing equation to use for the tween.
33-
* @property {array} [easeParams] - Optional easing parameters.
34-
* @property {number} [hold=0] - The number of milliseconds to hold the tween for before yoyo'ing.
35-
* @property {number} [repeat=0] - The number of times to repeat the tween.
36-
* @property {number} [repeatDelay=0] - The number of milliseconds to pause before a tween will repeat.
37-
* @property {boolean} [yoyo=false] - Should the tween complete, then reverse the values incrementally to get back to the starting tween values? The reverse tweening will also take `duration` milliseconds to complete.
38-
* @property {boolean} [flipX=false] - Horizontally flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipX` property.
39-
* @property {boolean} [flipY=false] - Vertically flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipY` property.
40-
`
41-
{
42-
targets: null,
43-
delay: 0,
44-
duration: 1000,
45-
ease: 'Power0',
46-
easeParams: null,
47-
hold: 0,
48-
repeat: 0,
49-
repeatDelay: 0,
50-
yoyo: false,
51-
flipX: false,
52-
flipY: false
53-
};
5428
*
55-
* @return {Phaser.Tweens.Tween} [description]
29+
* @return {Phaser.Tweens.Tween} The new tween.
5630
*/
5731
var TweenBuilder = function (parent, config, defaults)
5832
{

src/tweens/tween/Tween.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ Tween.TYPES = [
14231423
* @method Phaser.GameObjects.GameObjectFactory#tween
14241424
* @since 3.0.0
14251425
*
1426-
* @param {object} config - The Tween configuration.
1426+
* @param {Phaser.Types.Tweens.TweenBuilderConfig|object} config - The Tween configuration.
14271427
*
14281428
* @return {Phaser.Tweens.Tween} The Tween that was created.
14291429
*/
@@ -1448,7 +1448,7 @@ GameObjectFactory.register('tween', function (config)
14481448
* @method Phaser.GameObjects.GameObjectCreator#tween
14491449
* @since 3.0.0
14501450
*
1451-
* @param {object} config - The Tween configuration.
1451+
* @param {Phaser.Types.Tweens.TweenBuilderConfig|object} config - The Tween configuration.
14521452
*
14531453
* @return {Phaser.Tweens.Tween} The Tween that was created.
14541454
*/
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* @typedef {object} Phaser.Types.Tweens.NumberTweenBuilderConfig
3+
* @since 3.18.0
4+
*
5+
* @property {number} [from=0] - The start number.
6+
* @property {number} [to=1] - The end number.
7+
* @property {number} [delay=0] - The number of milliseconds to delay before the tween will start.
8+
* @property {number} [duration=1000] - The duration of the tween in milliseconds.
9+
* @property {string} [ease='Power0'] - The easing equation to use for the tween.
10+
* @property {array} [easeParams] - Optional easing parameters.
11+
* @property {number} [hold=0] - The number of milliseconds to hold the tween for before yoyo'ing.
12+
* @property {number} [repeat=0] - The number of times to repeat the tween.
13+
* @property {number} [repeatDelay=0] - The number of milliseconds to pause before a tween will repeat.
14+
* @property {boolean} [yoyo=false] - Should the tween complete, then reverse the values incrementally to get back to the starting tween values? The reverse tweening will also take `duration` milliseconds to complete.
15+
* @property {number|function|object|array} [offset=null] - Used when the Tween is part of a Timeline.
16+
* @property {number|function|object|array} [completeDelay=0] - The time the tween will wait before the onComplete event is dispatched once it has completed, in ms.
17+
* @property {number|function|object|array} [loop=0] - The number of times the tween will repeat. (A value of 1 means the tween will play twice, as it repeated once.) The first loop starts after every property tween has completed once.
18+
* @property {number|function|object|array} [loopDelay=0] - The time the tween will pause before starting either a yoyo or returning to the start for a repeat.
19+
* @property {boolean} [paused=false] - Does the tween start in a paused state (true) or playing (false)?
20+
* @property {boolean} [useFrames=false] - Use frames or milliseconds?
21+
* @property {any} [callbackScope] - Scope (this) for the callbacks. The default scope is the tween.
22+
* @property {Phaser.Types.Tweens.TweenOnCompleteCallback} [onComplete] - A function to call when the tween completes.
23+
* @property {array} [onCompleteParams] - Additional parameters to pass to `onComplete`.
24+
* @property {any} [onCompleteScope] - Scope (this) for `onComplete`.
25+
* @property {Phaser.Types.Tweens.TweenOnLoopCallback} [onLoop] - A function to call each time the tween loops.
26+
* @property {array} [onLoopParams] - Additional parameters to pass to `onLoop`.
27+
* @property {any} [onLoopScope] - Scope (this) for `onLoop`.
28+
* @property {Phaser.Types.Tweens.TweenOnRepeatCallback} [onRepeat] - A function to call each time the tween repeats. Called once per property per target.
29+
* @property {array} [onRepeatParams] - Additional parameters to pass to `onRepeat`.
30+
* @property {any} [onRepeatScope] - Scope (this) for `onRepeat`.
31+
* @property {Phaser.Types.Tweens.TweenOnStartCallback} [onStart] - A function to call when the tween starts.
32+
* @property {array} [onStartParams] - Additional parameters to pass to `onStart`.
33+
* @property {any} [onStartScope] - Scope (this) for `onStart`.
34+
* @property {Phaser.Types.Tweens.TweenOnUpdateCallback} [onUpdate] - A function to call each time the tween steps. Called once per property per target.
35+
* @property {array} [onUpdateParams] - Additional parameters to pass to `onUpdate`.
36+
* @property {any} [onUpdateScope] - Scope (this) for `onUpdate`.
37+
* @property {Phaser.Types.Tweens.TweenOnYoyoCallback} [onYoyo] - A function to call each time the tween yoyos. Called once per property per target.
38+
* @property {array} [onYoyoParams] - Additional parameters to pass to `onYoyo`.
39+
* @property {any} [onYoyoScope] - Scope (this) for `onYoyo`.
40+
*/
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* @typedef {object} Phaser.Types.Tweens.TweenBuilderConfig
3+
* @since 3.18.0
4+
*
5+
* @property {any} targets - The object, or an array of objects, to run the tween on.
6+
* @property {number} [delay=0] - The number of milliseconds to delay before the tween will start.
7+
* @property {number} [duration=1000] - The duration of the tween in milliseconds.
8+
* @property {string} [ease='Power0'] - The easing equation to use for the tween.
9+
* @property {array} [easeParams] - Optional easing parameters.
10+
* @property {number} [hold=0] - The number of milliseconds to hold the tween for before yoyo'ing.
11+
* @property {number} [repeat=0] - The number of times each property tween repeats.
12+
* @property {number} [repeatDelay=0] - The number of milliseconds to pause before a repeat.
13+
* @property {boolean} [yoyo=false] - Should the tween complete, then reverse the values incrementally to get back to the starting tween values? The reverse tweening will also take `duration` milliseconds to complete.
14+
* @property {boolean} [flipX=false] - Horizontally flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipX` property.
15+
* @property {boolean} [flipY=false] - Vertically flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipY` property.
16+
* @property {number|function|object|array} [offset=null] - Used when the Tween is part of a Timeline.
17+
* @property {number|function|object|array} [completeDelay=0] - The time the tween will wait before the onComplete event is dispatched once it has completed, in ms.
18+
* @property {number|function|object|array} [loop=0] - The number of times the tween will repeat. (A value of 1 means the tween will play twice, as it repeated once.) The first loop starts after every property tween has completed once.
19+
* @property {number|function|object|array} [loopDelay=0] - The time the tween will pause before starting either a yoyo or returning to the start for a repeat.
20+
* @property {boolean} [paused=false] - Does the tween start in a paused state (true) or playing (false)?
21+
* @property {object} [props] - The properties to tween.
22+
* @property {boolean} [useFrames=false] - Use frames or milliseconds?
23+
* @property {any} [callbackScope] - Scope (this) for the callbacks. The default scope is the tween.
24+
* @property {Phaser.Types.Tweens.TweenOnCompleteCallback} [onComplete] - A function to call when the tween completes.
25+
* @property {array} [onCompleteParams] - Additional parameters to pass to `onComplete`.
26+
* @property {any} [onCompleteScope] - Scope (this) for `onComplete`.
27+
* @property {Phaser.Types.Tweens.TweenOnLoopCallback} [onLoop] - A function to call each time the tween loops.
28+
* @property {array} [onLoopParams] - Additional parameters to pass to `onLoop`.
29+
* @property {any} [onLoopScope] - Scope (this) for `onLoop`.
30+
* @property {Phaser.Types.Tweens.TweenOnRepeatCallback} [onRepeat] - A function to call each time the tween repeats. Called once per property per target.
31+
* @property {array} [onRepeatParams] - Additional parameters to pass to `onRepeat`.
32+
* @property {any} [onRepeatScope] - Scope (this) for `onRepeat`.
33+
* @property {Phaser.Types.Tweens.TweenOnStartCallback} [onStart] - A function to call when the tween starts.
34+
* @property {array} [onStartParams] - Additional parameters to pass to `onStart`.
35+
* @property {any} [onStartScope] - Scope (this) for `onStart`.
36+
* @property {Phaser.Types.Tweens.TweenOnUpdateCallback} [onUpdate] - A function to call each time the tween steps. Called once per property per target.
37+
* @property {array} [onUpdateParams] - Additional parameters to pass to `onUpdate`.
38+
* @property {any} [onUpdateScope] - Scope (this) for `onUpdate`.
39+
* @property {Phaser.Types.Tweens.TweenOnYoyoCallback} [onYoyo] - A function to call each time the tween yoyos. Called once per property per target.
40+
* @property {array} [onYoyoParams] - Additional parameters to pass to `onYoyo`.
41+
* @property {any} [onYoyoScope] - Scope (this) for `onYoyo`.
42+
*
43+
* @example
44+
* {
45+
* targets: null,
46+
* delay: 0,
47+
* duration: 1000,
48+
* ease: 'Power0',
49+
* easeParams: null,
50+
* hold: 0,
51+
* repeat: 0,
52+
* repeatDelay: 0,
53+
* yoyo: false,
54+
* flipX: false,
55+
* flipY: false
56+
* };
57+
*/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @callback Phaser.Types.Tweens.TweenOnCompleteCallback
3+
* @since 3.18.0
4+
*
5+
* @param {Phaser.Tweens.Tween} tween - The tween.
6+
* @param {array} targets - The tween targets.
7+
* @param {...any} param - Any value passed in `onCompleteParams`.
8+
*/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @callback Phaser.Types.Tweens.TweenOnLoopCallback
3+
* @since 3.18.0
4+
*
5+
* @param {Phaser.Tweens.Tween} tween - The tween.
6+
* @param {array} targets - The tween targets.
7+
* @param {...any} param - Any value passed in `onLoopParams`.
8+
*/

0 commit comments

Comments
 (0)