diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 7b968615..977c6f3b 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -186,6 +186,7 @@ export class GameScene extends DirtyScene implements CenterListener { private popUpElements : Map = new Map(); private originalMapUrl: string|undefined; private pinchManager: PinchManager|undefined; + private physicsEnabled: boolean = true; private mapTransitioning: boolean = false; //used to prevent transitions happenning at the same time. private onVisibilityChangeCallback: () => void; @@ -1088,6 +1089,7 @@ ${escapedMessage} createCollisionWithPlayer() { this.physics.disableUpdate(); + this.physicsEnabled = false; //add collision layer this.Layers.forEach((Layer: Phaser.Tilemaps.TilemapLayer) => { this.physics.add.collider(this.CurrentPlayer, Layer, (object1: GameObject, object2: GameObject) => { @@ -1227,12 +1229,15 @@ ${escapedMessage} this.CurrentPlayer.moveUser(delta); if (this.CurrentPlayer.isMoving()) { this.dirty = true; - this.physics.enableUpdate(); - } else { + if (!this.physicsEnabled) { + this.physics.enableUpdate(); + this.physicsEnabled = true; + } + } else if (this.physicsEnabled) { this.physics.disableUpdate(); + this.physicsEnabled = false; } - // Let's handle all events while (this.pendingEvents.length !== 0) { this.dirty = true;