From 82ef6d4aeb18265e05368fa14f8e083856f8a353 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Wed, 16 Jul 2014 19:50:58 +0100 Subject: [PATCH] If you add a Tween to the TweenManager and then immediately stop it, it will still exist in the TweenManager (thanks @gilangcp #1032) --- README.md | 1 + src/tween/TweenManager.js | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bc518c2100..c8e6b4e788 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ Version 2.0.7 - "Amadicia" - -in development- * Group.create was not creating with p2 debug flag (thanks @Dumtard #1014) * World.wrap when using the bounds of the object wouldn't adjust the bounds correctly, meaning wrapping outside the camera failed (thanks @jackrugile #1020) * Pixi updated worldTransform from an Array to an Object and Phaser Image, BitmapText, Text and Graphics were still using array access to populate the world property, giving it incorrect results (thanks @alvinsight) +* If you add a Tween to the TweenManager and then immediately stop it, it will still exist in the TweenManager (thanks @gilangcp #1032) diff --git a/src/tween/TweenManager.js b/src/tween/TweenManager.js index b76c787882..5dc2943ed6 100644 --- a/src/tween/TweenManager.js +++ b/src/tween/TweenManager.js @@ -113,6 +113,15 @@ Phaser.TweenManager.prototype = { { this._tweens[i].pendingDelete = true; } + else + { + i = this._add.indexOf(tween); + + if (i !== -1) + { + this._add[i].pendingDelete = true; + } + } }, @@ -124,13 +133,15 @@ Phaser.TweenManager.prototype = { */ update: function () { - if (this._tweens.length === 0 && this._add.length === 0) + var addTweens = this._add.length; + var numTweens = this._tweens.length; + + if (numTweens === 0 && addTweens === 0) { return false; } var i = 0; - var numTweens = this._tweens.length; while (i < numTweens) { @@ -147,7 +158,7 @@ Phaser.TweenManager.prototype = { } // If there are any new tweens to be added, do so now - otherwise they can be spliced out of the array before ever running - if (this._add.length > 0) + if (addTweens > 0) { this._tweens = this._tweens.concat(this._add); this._add.length = 0;