Fixing "none" animation does not exist log
authorDavid Négrier <d.negrier@thecodingmachine.com>
Thu, 7 May 2020 21:33:21 +0000 (23:33 +0200)
committerDavid Négrier <d.negrier@thecodingmachine.com>
Thu, 7 May 2020 21:33:21 +0000 (23:33 +0200)
front/src/Phaser/Player/Animation.ts

index 46c0515452e84f2c1e285e055bf8a4e1b11d68e1..1c555ad9024b689164df0bd67c74a8ecacfeb30d 100644 (file)
@@ -50,9 +50,10 @@ export const getPlayerAnimations = (name: string = Textures.Player): AnimationDa
 };
 
 export const playAnimation = (Player : Phaser.GameObjects.Sprite, direction : string) => {
-    if (!Player.anims.currentAnim || Player.anims.currentAnim.key !== direction) {
+    if (direction !== PlayerAnimationNames.None && (!Player.anims.currentAnim || Player.anims.currentAnim.key !== direction)) {
         Player.anims.play(direction);
     } else if (direction === PlayerAnimationNames.None && Player.anims.currentAnim) {
-        Player.anims.currentAnim.destroy();
+        //Player.anims.currentAnim.destroy();
+        Player.anims.stop();
     }
 }