Skip to content

Commit

Permalink
[fix] boostcampwm-2022#200 제자리 걸음 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
JJongBin committed Dec 14, 2022
1 parent 0db697c commit 01987bb
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions frontend/src/component/Game/Phaser/Player/myPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class MyPlayer extends Player {

update() {
const prevState = this.state;
const prevPos = { x: this.x, y: this.y };

if (!this.isCanMove) {
this.state = 'wait';
Expand Down Expand Up @@ -112,12 +113,15 @@ export class MyPlayer extends Player {
if (prevState !== this.state) changeState(this);

if (prevState !== this.state || this.heldDirection.length) {
this.socket.emit('move', {
state: this.state,
direction: this.direction,
x: this.x,
y: this.y,
});
this.socket.emit(
prevPos.x !== this.x || prevPos.y !== this.y ? 'move' : 'motion',
{
state: this.state,
direction: this.direction,
x: this.x,
y: this.y,
}
);
}
}
}

0 comments on commit 01987bb

Please sign in to comment.