File tree Expand file tree Collapse file tree
src/gameobjects/components Expand file tree Collapse file tree Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments