Correct feedback @moufmouf
This commit is contained in:
parent
bdea7e49d1
commit
029a7a9a64
@ -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).
|
||||
|
BIN
doc/images/exit_layer_map.png
Normal file
BIN
doc/images/exit_layer_map.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 335 KiB |
@ -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
|
||||
})
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user