-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to stop tween in certain cases #1032
Comments
Thank you for the clear test case. However could you give me a situation where you would ever create a tween that has |
Sometimes you create something is a function and you do it a generic way:
But then you need something special:
Anyway, it's unexpected behavior. |
It's a pretty unexpected developer behaviour too. Anyway, resolved. |
Sorry for the late reply , glad that the problem has been resolved., thank you :) well , in my case :
its something like this (not the actual code): var sprite = this.game.add(...); |
Hi.
Problem :
Cannot stop tween just after the tween created .
Example case :
Create tween -> suddenly event to stop the tween triggered ( Either by user input / game logic) -> the tween still there .
Example Code :
t.stop();
Why the problem happened :
it seems that every new tween is added to _add array, processed and moved to another array called _tweens in update method which is processed per frame time. The tween is still in _add array when stop() method called .
Solution :
check _add array for tween in stop() method.
line 40165 ( Phaser 2.0.6)
/**
* Remove a tween from this manager.
*
* @method Phaser.TweenManager#remove
* @param {Phaser.Tween} tween - The tween object you want to remove.
*/
remove: function (tween) {
var i = this._tweens.indexOf(tween);
if (i !== -1) {
this._tweens[i].pendingDelete = true;
} else {
var j = this._add.indexOf(tween);
if (j !== -1) { // <== Add Here
this._add[j].pendingDelete = true;
} // <== Until Here
}
},
Sorry for my bad english , I'm not native english speaker
The text was updated successfully, but these errors were encountered: