Merge pull request #1057 from thecodingmachine/physics_flag
Making sure Physics is not enabled several times
This commit is contained in:
commit
2ea731beeb
@ -186,6 +186,7 @@ export class GameScene extends DirtyScene implements CenterListener {
|
|||||||
private popUpElements : Map<number, DOMElement> = new Map<number, Phaser.GameObjects.DOMElement>();
|
private popUpElements : Map<number, DOMElement> = new Map<number, Phaser.GameObjects.DOMElement>();
|
||||||
private originalMapUrl: string|undefined;
|
private originalMapUrl: string|undefined;
|
||||||
private pinchManager: PinchManager|undefined;
|
private pinchManager: PinchManager|undefined;
|
||||||
|
private physicsEnabled: boolean = true;
|
||||||
private mapTransitioning: boolean = false; //used to prevent transitions happenning at the same time.
|
private mapTransitioning: boolean = false; //used to prevent transitions happenning at the same time.
|
||||||
private onVisibilityChangeCallback: () => void;
|
private onVisibilityChangeCallback: () => void;
|
||||||
|
|
||||||
@ -1088,6 +1089,7 @@ ${escapedMessage}
|
|||||||
|
|
||||||
createCollisionWithPlayer() {
|
createCollisionWithPlayer() {
|
||||||
this.physics.disableUpdate();
|
this.physics.disableUpdate();
|
||||||
|
this.physicsEnabled = false;
|
||||||
//add collision layer
|
//add collision layer
|
||||||
this.Layers.forEach((Layer: Phaser.Tilemaps.TilemapLayer) => {
|
this.Layers.forEach((Layer: Phaser.Tilemaps.TilemapLayer) => {
|
||||||
this.physics.add.collider(this.CurrentPlayer, Layer, (object1: GameObject, object2: GameObject) => {
|
this.physics.add.collider(this.CurrentPlayer, Layer, (object1: GameObject, object2: GameObject) => {
|
||||||
@ -1227,12 +1229,15 @@ ${escapedMessage}
|
|||||||
this.CurrentPlayer.moveUser(delta);
|
this.CurrentPlayer.moveUser(delta);
|
||||||
if (this.CurrentPlayer.isMoving()) {
|
if (this.CurrentPlayer.isMoving()) {
|
||||||
this.dirty = true;
|
this.dirty = true;
|
||||||
this.physics.enableUpdate();
|
if (!this.physicsEnabled) {
|
||||||
} else {
|
this.physics.enableUpdate();
|
||||||
|
this.physicsEnabled = true;
|
||||||
|
}
|
||||||
|
} else if (this.physicsEnabled) {
|
||||||
this.physics.disableUpdate();
|
this.physics.disableUpdate();
|
||||||
|
this.physicsEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Let's handle all events
|
// Let's handle all events
|
||||||
while (this.pendingEvents.length !== 0) {
|
while (this.pendingEvents.length !== 0) {
|
||||||
this.dirty = true;
|
this.dirty = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user