Skip to content

Commit

Permalink
If you add a Tween to the TweenManager and then immediately stop it, …
Browse files Browse the repository at this point in the history
…it will still exist in the TweenManager (thanks @gilangcp phaserjs#1032)
  • Loading branch information
photonstorm committed Jul 16, 2014
1 parent fc047c5 commit 82ef6d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down
17 changes: 14 additions & 3 deletions src/tween/TweenManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

},

Expand All @@ -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)
{
Expand All @@ -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;
Expand Down

0 comments on commit 82ef6d4

Please sign in to comment.