You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A TweenData wouldn't take into account the repeatDelay property when repeating the tween, but now does. A TweenData also has a new property yoyoDelay which controls the delay before the yoyo will start, allowing you to set both independently (thanks @DreadKnightphaserjs#1469)
Tween.updateTweenData allows you to set a property to the given value across one or all of the current tweens. All of the Tween methods like Tween.delay and Tween.repeat have been updated to use this.
Tween.repeat has a new parameter `repeatDelay` which allows you to set the delay (in ms) before a tween will repeat itself.
Tween.yoyo has a new parameter `yoyoDelay` which allows you to set the delay (in ms) before a tween will start a yoyo.
Tween.interpolation has a new parameter `context` which allows you to define the context in which the interpolation function will run.
Copy file name to clipboardExpand all lines: README.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -153,6 +153,10 @@ We've also removed functions and properties from Pixi classes that Phaser doesn'
153
153
* If you load an image and provide a key that was already in-use in the Cache, then the old image is now destroyed (via `Cache.removeImage`) and the new image takes its place.
154
154
* BitmapText has a new `maxWidth` property that will attempt to wrap the text if it exceeds the width specified.
155
155
* Group.cursorIndex is the index of the item the Group cursor points to. This replaces Group._cache[8].
156
+
* Tween.updateTweenData allows you to set a property to the given value across one or all of the current tweens. All of the Tween methods like Tween.delay and Tween.repeat have been updated to use this.
157
+
* Tween.repeat has a new parameter `repeatDelay` which allows you to set the delay (in ms) before a tween will repeat itself.
158
+
* Tween.yoyo has a new parameter `yoyoDelay` which allows you to set the delay (in ms) before a tween will start a yoyo.
159
+
* Tween.interpolation has a new parameter `context` which allows you to define the context in which the interpolation function will run.
156
160
157
161
### Bug Fixes
158
162
@@ -180,8 +184,9 @@ We've also removed functions and properties from Pixi classes that Phaser doesn'
180
184
* World.setBounds if called after you had already started P2 Physics would incorrectly create a new collision group for the wall objects. P2.World now remembers the settings you provide for each wall and the collision group, and re-applies these settings should the world dimensions ever change (thanks @nextht#1455)
181
185
* InputHandler was using the wrong property in `checkBoundsSprite` when fixedToCamera (thanks @yig#1613)
182
186
* Tween.to now correctly accepts arrays are destination values, which makes the Tween interpolate through each value specified in the array using the defined Tween.interpolation method (see new example, thanks @FridayMarch26th#1619)
183
-
* Tween.interpolationFunction was using the incorrect context to invoke the function. This is now defined in `TweenData.interpolationFunctionContext` and defaults to `Phaser.Math`. If you provide your own interpolation function then please adjust the context accordingly (thanks @FridayMarch26th#1618)
187
+
* Tween.interpolationFunction was using the incorrect context to invoke the function. This is now defined in `TweenData.interpolationContext` and defaults to `Phaser.Math`. If you provide your own interpolation function then please adjust the context accordingly (thanks @FridayMarch26th#1618)
184
188
* Graphics.drawEllipse method was missing (thanks @jackrugile#1574)
189
+
* A TweenData wouldn't take into account the `repeatDelay` property when repeating the tween, but now does. A TweenData also has a new property `yoyoDelay` which controls the delay before the yoyo will start, allowing you to set both independently (thanks @DreadKnight#1469)
185
190
186
191
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
* @property {number} repeatDelay - The amount of time in ms between repeats of this tween and any child tweens.
67
-
*/
68
-
this.repeatDelay=0;
69
-
70
65
/**
71
66
* @property {boolean} pendingDelete - True if this Tween is ready to be deleted by the TweenManager.
72
67
* @default
@@ -357,17 +352,17 @@ Phaser.Tween.prototype = {
357
352
},
358
353
359
354
/**
360
-
* Sets the delay in milliseconds before this tween will start. If there are child tweens it sets the delay before the first child starts.
361
-
* The delay is invoked as soon as you call `Tween.start`. If the tween is already running this method doesn't do anything for the current active tween.
362
-
* If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to delay.
363
-
* If you have child tweens and pass -1 as the index value it sets the delay across all of them.
355
+
* Updates either a single TweenData or all TweenData objects properties to the given value.
356
+
* Used internally by methods like Tween.delay, Tween.yoyo, etc. but can also be called directly if you know which property you want to tweak.
357
+
* The property is not checked, so if you pass an invalid one you'll generate a run-time error.
364
358
*
365
-
* @method Phaser.Tween#delay
366
-
* @param {number} duration - The amount of time in ms that the Tween should wait until it begins once started is called. Set to zero to remove any active delay.
359
+
* @method Phaser.Tween#updateTweenData
360
+
* @param {string} property - The property to update.
361
+
* @param {number|function} value - The value to set the property to.
367
362
* @param {number} [index=0] - If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the delay on all the children.
368
363
* @return {Phaser.Tween} This tween. Useful for method chaining.
369
364
*/
370
-
delay: function(duration,index){
365
+
updateTweenData: function(property,value,index){
371
366
372
367
if(this.timeline.length===0){returnthis;}
373
368
@@ -377,18 +372,35 @@ Phaser.Tween.prototype = {
377
372
{
378
373
for(vari=0;i<this.timeline.length;i++)
379
374
{
380
-
this.timeline[i].delay=duration;
375
+
this.timeline[i][property]=value;
381
376
}
382
377
}
383
378
else
384
379
{
385
-
this.timeline[index].delay=duration;
380
+
this.timeline[index][property]=value;
386
381
}
387
382
388
383
returnthis;
389
384
390
385
},
391
386
387
+
/**
388
+
* Sets the delay in milliseconds before this tween will start. If there are child tweens it sets the delay before the first child starts.
389
+
* The delay is invoked as soon as you call `Tween.start`. If the tween is already running this method doesn't do anything for the current active tween.
390
+
* If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to delay.
391
+
* If you have child tweens and pass -1 as the index value it sets the delay across all of them.
392
+
*
393
+
* @method Phaser.Tween#delay
394
+
* @param {number} duration - The amount of time in ms that the Tween should wait until it begins once started is called. Set to zero to remove any active delay.
395
+
* @param {number} [index=0] - If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the delay on all the children.
396
+
* @return {Phaser.Tween} This tween. Useful for method chaining.
* Sets the number of times this tween will repeat.
394
406
* If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to repeat.
@@ -397,28 +409,34 @@ Phaser.Tween.prototype = {
397
409
*
398
410
* @method Phaser.Tween#repeat
399
411
* @param {number} total - How many times a tween should repeat before completing. Set to zero to remove an active repeat. Set to -1 to repeat forever.
412
+
* @param {number} [repeat=0] - This is the amount of time to pause (in ms) before the repeat will start.
400
413
* @param {number} [index=0] - If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the repeat value on all the children.
401
414
* @return {Phaser.Tween} This tween. Useful for method chaining.
* Sets the delay in milliseconds before this tween will repeat itself.
428
+
* The repeatDelay is invoked as soon as you call `Tween.start`. If the tween is already running this method doesn't do anything for the current active tween.
429
+
* If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to set repeatDelay on.
430
+
* If you have child tweens and pass -1 as the index value it sets the repeatDelay across all of them.
431
+
*
432
+
* @method Phaser.Tween#repeatDelay
433
+
* @param {number} duration - The amount of time in ms that the Tween should wait until it repeats or yoyos once start is called. Set to zero to remove any active repeatDelay.
434
+
* @param {number} [index=0] - If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the repeatDelay on all the children.
435
+
* @return {Phaser.Tween} This tween. Useful for method chaining.
* @param {boolean} enable - Set to true to yoyo this tween, or false to disable an already active yoyo.
452
+
* @param {number} [yoyoDelay=0] - This is the amount of time to pause (in ms) before the yoyo will start.
434
453
* @param {number} [index=0] - If this tween has more than one child this allows you to target a specific child. If set to -1 it will set yoyo on all the children.
435
454
* @return {Phaser.Tween} This tween. Useful for method chaining.
* Sets the delay in milliseconds before this tween will run a yoyo (only applies if yoyo is enabled).
468
+
* The repeatDelay is invoked as soon as you call `Tween.start`. If the tween is already running this method doesn't do anything for the current active tween.
469
+
* If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to set repeatDelay on.
470
+
* If you have child tweens and pass -1 as the index value it sets the repeatDelay across all of them.
471
+
*
472
+
* @method Phaser.Tween#yoyoDelay
473
+
* @param {number} duration - The amount of time in ms that the Tween should wait until it repeats or yoyos once start is called. Set to zero to remove any active yoyoDelay.
474
+
* @param {number} [index=0] - If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the yoyoDelay on all the children.
475
+
* @return {Phaser.Tween} This tween. Useful for method chaining.
* @param {function} interpolation - The interpolation function to use (Phaser.Math.linearInterpolation by default)
513
+
* @param {object} [context] - The context under which the interpolation function will be run.
503
514
* @param {number} [index=0] - If this tween has more than one child this allows you to target a specific child. If set to -1 it will set the interpolation function on all children.
504
515
* @return {Phaser.Tween} This tween. Useful for method chaining.
* @property {object} interpolationFunctionContext - The interpolation function context used for the Tween.
132
+
* @property {object} interpolationContext - The interpolation function context used for the Tween.
128
133
* @default Phaser.Math
129
134
*/
130
-
this.interpolationFunctionContext=Phaser.Math;
135
+
this.interpolationContext=Phaser.Math;
131
136
132
137
/**
133
138
* @property {boolean} isRunning - If the tween is running this is set to `true`. Unless Phaser.Tween a TweenData that is waiting for a delay to expire is *not* considered as running.
0 commit comments