From: gparant Date: Sun, 10 May 2020 12:49:49 +0000 (+0200) Subject: Correct feedback @moufmouf X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=029a7a9a64a6a68022777199237fb909ad622b79;p=libreadventure.git Correct feedback @moufmouf --- diff --git a/README.md b/README.md index c36aac6..8fdee4e 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,12 @@ A few things to notice: ![](doc/images/tiled_screenshot_1.png) +If you have exit scene +- You must create layer "exit". The layer have cases where the gamer can switch to the next scene. +- In layer properties, you must add "exitSceneKey" property. It represent a key map of the next scene. Be careful, if you want that the next map will be correctly loaded, you must check that the map exists in the list of the maps application. The variable that represents maps in the application is "ROOMS" constant variable. + +![](doc/images/exit_layer_map.png) + ### MacOS developers, your environment with Vagrant If you are using MacOS, you can increase Docker performance using Vagrant. If you want more explanations, you can read [this medium article](https://medium.com/better-programming/vagrant-to-increase-docker-performance-with-macos-25b354b0c65c). diff --git a/doc/images/exit_layer_map.png b/doc/images/exit_layer_map.png new file mode 100644 index 0000000..122610c Binary files /dev/null and b/doc/images/exit_layer_map.png differ diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 09bf38f..26c2fc3 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -108,7 +108,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface, Creat this.addLayer(this.Map.createStaticLayer(layer.name, this.Terrains, 0, 0).setDepth(depth)); } if (layer.type === 'tilelayer' && layer.name === "exit") { - this.loadNextGame(layer); + this.loadNextGame(layer, this.map.width, this.map.tilewidth, this.map.tileheight); } if (layer.type === 'tilelayer' && layer.name === "start") { this.startUser(layer); @@ -155,15 +155,19 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface, Creat } /** - * @param layer : ITiledMapLayer + * + * @param layer + * @param mapWidth + * @param tileWidth + * @param tileHeight */ - private loadNextGame(layer: ITiledMapLayer){ + private loadNextGame(layer: ITiledMapLayer, mapWidth: number, tileWidth: number, tileHeight: number){ let properties : any = layer.properties; let nextSceneKey = properties.find((property:any) => property.name === "exitSceneKey"); let nextMap : MapObject = gameManager.Maps.find((map: MapObject) => map.key === nextSceneKey.value); let gameIndex = this.scene.getIndex(nextMap.key); - let game = null; + let game : Phaser.Scene = null; if(gameIndex === -1){ game = new GameScene(nextMap.key, `${API_URL}${nextMap.url}`); this.scene.add(nextSceneKey, game, false); @@ -173,20 +177,20 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface, Creat if(!game){ return; } - let tiles : any = layer.data; tiles.forEach((objectKey : number, key: number) => { if(objectKey === 0){ return; } - let y = (key / 45); - y = parseInt(`${y}`); - let x = key - (y * 46); + //key + 1 because the start x = 0; + let y : number = parseInt(((key + 1) / mapWidth).toString()); + let x : number = key - (y * mapWidth); + //push and save switching case this.PositionNextScene.push({ - xStart: (x * 32), - yStart: (y * 32), - xEnd: ((x +1) * 32), - yEnd: ((y + 1) * 32), + xStart: (x * tileWidth), + yStart: (y * tileWidth), + xEnd: ((x +1) * tileHeight), + yEnd: ((y + 1) * tileHeight), key: nextMap.key }) });