Skip to content

Commit 25a93cf

Browse files
committed
AnimationManager.play will now call Animation.stop on the current animation before switching to the new one (thanks @nihakue, phaserjs#713)
1 parent 5d0ea64 commit 25a93cf

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Version 2.0.4 - "Mos Shirare" - in development
6363
* Timer has removed all use of local temporary vars in the core update loop.
6464
* The Input.reset `hard` reset parameter is now passed down to the Keyboard and Key reset methods.
6565
* AnimationManager.destroy now iterates through child animations calling destroy on all of them, avoiding a memory leak (thanks stauzs)
66+
* AnimationManager.play will now call Animation.stop on the current animation before switching to the new one (thanks @nihakue, #713)
6667

6768

6869
### New Features

src/animation/AnimationManager.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ Phaser.AnimationManager.prototype = {
195195

196196
if (this._anims[name])
197197
{
198-
if (this.currentAnim == this._anims[name])
198+
if (this.currentAnim === this._anims[name])
199199
{
200200
if (this.currentAnim.isPlaying === false)
201201
{
@@ -205,6 +205,11 @@ Phaser.AnimationManager.prototype = {
205205
}
206206
else
207207
{
208+
if (this.currentAnim && this.currentAnim.isPlaying)
209+
{
210+
this.currentAnim.stop();
211+
}
212+
208213
this.currentAnim = this._anims[name];
209214
this.currentAnim.paused = false;
210215
return this.currentAnim.play(frameRate, loop, killOnComplete);

0 commit comments

Comments
 (0)