Skip to content

Commit 92f2742

Browse files
committed
When reusing a Tween created with an array of properties the values would get exponentially added to the TweenData internal array each time the tween was re-run (thanks @SBCGames phaserjs#1747)
1 parent 6a9fd4d commit 92f2742

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ Version 2.4 - "Katar" - in dev
413413
* TileSprite now fully supports animation again, having been broken for several versions due to a Pixi upgrade. We've updated the way TileSprites generate their textures internally considerably and animation support is back across both Canvas and WebGL as a result (#1653)
414414
* Setting mute to false on Sound that was never muted caused its volume to be set to zero (thanks @brianbunch #1870)
415415
* P2.Body.createGroupCallback incorrectly referenced the `_groupCallbackContext` when deleting it (thanks @Langerz82 #1886)
416+
* When reusing a Tween created with an array of properties the values would get exponentially added to the TweenData internal array each time the tween was re-run (thanks @SBCGames #1747)
416417

417418
### Deprecated
418419

src/core/Group.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ Phaser.Group.prototype.addAt = function (child, index, silent) {
437437
*
438438
* @method Phaser.Group#getAt
439439
* @param {integer} index - The index to return the child from.
440-
* @return {DisplayObject} The child that was found at the given index, or -1 for an invalid index.
440+
* @return {DisplayObject|integer} The child that was found at the given index, or -1 for an invalid index.
441441
*/
442442
Phaser.Group.prototype.getAt = function (index) {
443443

src/tween/TweenData.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Phaser.TweenData = function (parent) {
4444
this.vEnd = {};
4545

4646
/**
47-
* @property {object} vEnd - Cached ending values.
47+
* @property {object} vEndCache - Cached ending values.
4848
* @private
4949
*/
5050
this.vEndCache = {};
@@ -298,8 +298,12 @@ Phaser.TweenData.prototype = {
298298
continue;
299299
}
300300

301-
// Create a local copy of the Array with the start value at the front
302-
this.vEnd[property] = [this.vStart[property]].concat(this.vEnd[property]);
301+
if (this.percent === 0)
302+
{
303+
// Put the start value at the beginning of the array
304+
// but we only want to do this once, if the Tween hasn't run before
305+
this.vEnd[property] = [this.vStart[property]].concat(this.vEnd[property]);
306+
}
303307
}
304308

305309
if (typeof this.vEnd[property] !== 'undefined')

0 commit comments

Comments
 (0)