Merge pull request #506 from thecodingmachine/fixreconnect

Fixing reconnection
This commit is contained in:
David Négrier 2020-12-18 16:28:19 +01:00 committed by GitHub
commit 4940e7db98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -155,9 +155,9 @@ export class GameScene extends ResizableScene implements CenterListener {
private playerName!: string;
private characterLayers!: string[];
constructor(private room: Room, MapUrlFile: string) {
constructor(private room: Room, MapUrlFile: string, customKey?: string|undefined) {
super({
key: room.id
key: customKey ?? room.id
});
this.Terrains = [];
this.groups = new Map<number, Sprite>();
@ -517,7 +517,7 @@ export class GameScene extends ResizableScene implements CenterListener {
this.simplePeer.unregister();
const gameSceneKey = 'somekey' + Math.round(Math.random() * 10000);
const game: Phaser.Scene = new GameScene(this.room, this.MapUrlFile);
const game: Phaser.Scene = new GameScene(this.room, this.MapUrlFile, gameSceneKey);
this.scene.add(gameSceneKey, game, true,
{
initPosition: {
@ -580,7 +580,7 @@ export class GameScene extends ResizableScene implements CenterListener {
this.scene.wake();
this.scene.sleep(ReconnectingSceneName);
this.scene.stop(ReconnectingSceneName);
//init user position and play trigger to check layers properties
this.gameMap.setPosition(this.CurrentPlayer.x, this.CurrentPlayer.y);