Using Room class to load GameScene
This commit is contained in:
parent
aee06da7f9
commit
ec93891c6b
3 changed files with 13 additions and 6 deletions
|
@ -17,8 +17,7 @@ export class GameManager {
|
|||
|
||||
public async init(scenePlugin: Phaser.Scenes.ScenePlugin) {
|
||||
this.startRoom = await connectionManager.initGameConnexion();
|
||||
const url = await this.startRoom.getMapUrl();
|
||||
this.loadMap(url, this.startRoom.id, scenePlugin);
|
||||
await this.loadMap(this.startRoom, scenePlugin);
|
||||
}
|
||||
|
||||
public setPlayerName(name: string): void {
|
||||
|
@ -42,8 +41,11 @@ export class GameManager {
|
|||
}
|
||||
|
||||
|
||||
public loadMap(mapUrl: string, roomID: string, scenePlugin: Phaser.Scenes.ScenePlugin): void {
|
||||
public async loadMap(room: Room, scenePlugin: Phaser.Scenes.ScenePlugin): Promise<void> {
|
||||
const roomID = room.id;
|
||||
const mapUrl = await room.getMapUrl();
|
||||
console.log('Loading map '+roomID+' at url '+mapUrl);
|
||||
|
||||
const gameIndex = scenePlugin.getIndex(mapUrl);
|
||||
if(gameIndex === -1){
|
||||
const game : Phaser.Scene = GameScene.createFromUrl(mapUrl, roomID);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue