Fix move & stop player
authorgparant <g.parant@thecodingmachine.com>
Mon, 13 Apr 2020 13:41:11 +0000 (15:41 +0200)
committergparant <g.parant@thecodingmachine.com>
Mon, 13 Apr 2020 13:41:11 +0000 (15:41 +0200)
front/src/Phaser/Entity/PlayableCaracter.ts
front/src/Phaser/Player/Player.ts

index d2a72b1451518ddfc1e08c84fd6c805d6a9a1af5..66ddd57999c1d4f32e7b2d0acfcfc7e4dce753d3 100644 (file)
@@ -24,11 +24,14 @@ export class PlayableCaracter extends Phaser.Physics.Arcade.Sprite {
         //todo improve animations to better account for diagonal movement
         if (this.body.velocity.x > 0) { //moving right
             this.play(PlayerAnimationNames.WalkRight, true);
-        } else if (this.body.velocity.x < 0) { //moving left
+        }
+        if (this.body.velocity.x < 0) { //moving left
             this.anims.playReverse(PlayerAnimationNames.WalkLeft, true);
-        } else if (this.body.velocity.y < 0) { //moving up
+        }
+        if (this.body.velocity.y < 0) { //moving up
             this.play(PlayerAnimationNames.WalkUp, true);
-        } else if (this.body.velocity.y > 0) { //moving down
+        }
+        if (this.body.velocity.y > 0) { //moving down
             this.play(PlayerAnimationNames.WalkDown, true);
         }
 
@@ -36,6 +39,11 @@ export class PlayableCaracter extends Phaser.Physics.Arcade.Sprite {
             this.bubble.moveBubble(this.x, this.y);
         }
     }
+
+    stop(){
+        this.setVelocity(0, 0);
+        this.play(PlayerAnimationNames.None, true);
+    }
     
     say(text: string) {
         if (this.bubble) return;
index d426b3d20a4a6371c135fae542e919123b73bfce..d0169297f7b850bb7ff22259d45b81e0cfd3aaa1 100644 (file)
@@ -95,7 +95,7 @@ export class Player extends PlayableCaracter implements CurrentGamerInterface, G
         }
         if (!haveMove) {
             direction = PlayerAnimationNames.None;
-            this.move(0, 0)
+            this.stop();
         }
         this.sharePosition(direction);
         this.CameraManager.moveCamera(this);