add companion only on local player
This commit is contained in:
parent
5a91e15580
commit
2ad712807b
3 changed files with 53 additions and 28 deletions
|
@ -27,6 +27,8 @@ export class Player extends Character implements CurrentGamerInterface {
|
|||
|
||||
//the current player model should be push away by other players to prevent conflict
|
||||
this.getBody().setImmovable(false);
|
||||
|
||||
this.addCompanion();
|
||||
}
|
||||
|
||||
moveUser(delta: number): void {
|
||||
|
@ -58,6 +60,11 @@ export class Player extends Character implements CurrentGamerInterface {
|
|||
direction = PlayerAnimationDirections.Right;
|
||||
moving = true;
|
||||
}
|
||||
|
||||
if (this.companion) {
|
||||
this.companion.step(delta);
|
||||
}
|
||||
|
||||
if (x !== 0 || y !== 0) {
|
||||
this.move(x, y);
|
||||
this.emit(hasMovedEventName, {moving, direction, x: this.x, y: this.y});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue