Skip to content

Commit 1bf9be5

Browse files
committed
Animation.stop guard.
1 parent ffd217d commit 1bf9be5

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/gameobjects/components/Animation.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,8 @@ var Animation = new Class({
882882
/**
883883
* Immediately stops the current animation from playing and dispatches the `animationcomplete` event.
884884
*
885+
* If no animation is set, no event will be dispatched.
886+
*
885887
* If there is another animation queued (via the `chain` method) then it will start playing immediately.
886888
*
887889
* @method Phaser.GameObjects.Components.Animation#stop
@@ -900,11 +902,14 @@ var Animation = new Class({
900902
var anim = this.currentAnim;
901903
var frame = this.currentFrame;
902904

903-
anim.emit('complete', anim, frame);
904-
905-
gameObject.emit('animationcomplete-' + anim.key, anim, frame, gameObject);
905+
if (anim)
906+
{
907+
anim.emit('complete', anim, frame);
906908

907-
gameObject.emit('animationcomplete', anim, frame, gameObject);
909+
gameObject.emit('animationcomplete-' + anim.key, anim, frame, gameObject);
910+
911+
gameObject.emit('animationcomplete', anim, frame, gameObject);
912+
}
908913

909914
if (this.nextAnim)
910915
{

0 commit comments

Comments
 (0)