Skip to content

Commit 82ef6d4

Browse files
committed
If you add a Tween to the TweenManager and then immediately stop it, it will still exist in the TweenManager (thanks @gilangcp phaserjs#1032)
1 parent fc047c5 commit 82ef6d4

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Version 2.0.7 - "Amadicia" - -in development-
7979
* Group.create was not creating with p2 debug flag (thanks @Dumtard #1014)
8080
* World.wrap when using the bounds of the object wouldn't adjust the bounds correctly, meaning wrapping outside the camera failed (thanks @jackrugile #1020)
8181
* 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)
82+
* If you add a Tween to the TweenManager and then immediately stop it, it will still exist in the TweenManager (thanks @gilangcp #1032)
8283

8384

8485

src/tween/TweenManager.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,15 @@ Phaser.TweenManager.prototype = {
113113
{
114114
this._tweens[i].pendingDelete = true;
115115
}
116+
else
117+
{
118+
i = this._add.indexOf(tween);
119+
120+
if (i !== -1)
121+
{
122+
this._add[i].pendingDelete = true;
123+
}
124+
}
116125

117126
},
118127

@@ -124,13 +133,15 @@ Phaser.TweenManager.prototype = {
124133
*/
125134
update: function () {
126135

127-
if (this._tweens.length === 0 && this._add.length === 0)
136+
var addTweens = this._add.length;
137+
var numTweens = this._tweens.length;
138+
139+
if (numTweens === 0 && addTweens === 0)
128140
{
129141
return false;
130142
}
131143

132144
var i = 0;
133-
var numTweens = this._tweens.length;
134145

135146
while (i < numTweens)
136147
{
@@ -147,7 +158,7 @@ Phaser.TweenManager.prototype = {
147158
}
148159

149160
// If there are any new tweens to be added, do so now - otherwise they can be spliced out of the array before ever running
150-
if (this._add.length > 0)
161+
if (addTweens > 0)
151162
{
152163
this._tweens = this._tweens.concat(this._add);
153164
this._add.length = 0;

0 commit comments

Comments
 (0)