Fix move & stop player
This commit is contained in:
parent
ab70b28bb3
commit
b391ee271a
@ -24,11 +24,14 @@ export class PlayableCaracter extends Phaser.Physics.Arcade.Sprite {
|
|||||||
//todo improve animations to better account for diagonal movement
|
//todo improve animations to better account for diagonal movement
|
||||||
if (this.body.velocity.x > 0) { //moving right
|
if (this.body.velocity.x > 0) { //moving right
|
||||||
this.play(PlayerAnimationNames.WalkRight, true);
|
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);
|
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);
|
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);
|
this.play(PlayerAnimationNames.WalkDown, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +40,11 @@ export class PlayableCaracter extends Phaser.Physics.Arcade.Sprite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stop(){
|
||||||
|
this.setVelocity(0, 0);
|
||||||
|
this.play(PlayerAnimationNames.None, true);
|
||||||
|
}
|
||||||
|
|
||||||
say(text: string) {
|
say(text: string) {
|
||||||
if (this.bubble) return;
|
if (this.bubble) return;
|
||||||
this.bubble = new SpeechBubble(this.scene, this, text)
|
this.bubble = new SpeechBubble(this.scene, this, text)
|
||||||
|
@ -95,7 +95,7 @@ export class Player extends PlayableCaracter implements CurrentGamerInterface, G
|
|||||||
}
|
}
|
||||||
if (!haveMove) {
|
if (!haveMove) {
|
||||||
direction = PlayerAnimationNames.None;
|
direction = PlayerAnimationNames.None;
|
||||||
this.move(0, 0)
|
this.stop();
|
||||||
}
|
}
|
||||||
this.sharePosition(direction);
|
this.sharePosition(direction);
|
||||||
this.CameraManager.moveCamera(this);
|
this.CameraManager.moveCamera(this);
|
||||||
|
Loading…
Reference in New Issue
Block a user