Backporting master changes
authorDavid Négrier <d.negrier@thecodingmachine.com>
Wed, 15 Apr 2020 21:57:36 +0000 (23:57 +0200)
committerDavid Négrier <d.negrier@thecodingmachine.com>
Wed, 15 Apr 2020 21:57:36 +0000 (23:57 +0200)
1  2 
front/src/Phaser/Game/GameScene.ts

index 6bd261901ad50ad505e8fbb8f6d3c0dc9a55d56a,36054b4ec19964dfd5bddab182c743320ee56429..a08c8fd2f34f33e86c97dbcb67f2a10cf47980f4
@@@ -3,7 -3,7 +3,8 @@@ import {MessageUserPositionInterface} f
  import {CurrentGamerInterface, GamerInterface, Player} from "../Player/Player";
  import {DEBUG_MODE, RESOLUTION, ZOOM_LEVEL} from "../../Enum/EnvironmentVariable";
  import Tile = Phaser.Tilemaps.Tile;
+ import {ITiledMap, ITiledTileSet} from "../Map/ITiledMap";
 +import {cypressAsserter} from "../../Cypress/CypressAsserter";
  
  export enum Textures {
      Rock = 'rock',
@@@ -40,9 -42,17 +43,18 @@@ export class GameScene extends Phaser.S
  
      //hook preload scene
      preload(): void {
-         this.load.image(Textures.Tiles, 'maps/tiles.png');
-         this.load.tilemapTiledJSON(Textures.Map, 'maps/map2.json');
 +        cypressAsserter.preloadStarted();
+         let mapUrl = 'maps/map2.json';
+         this.load.on('filecomplete-tilemapJSON-'+Textures.Map, (key: string, type: string, data: any) => {
+             // Triggered when the map is loaded
+             // Load tiles attached to the map recursively
+             this.map = data.data;
+             this.map.tilesets.forEach((tileset) => {
+                 let path = mapUrl.substr(0, mapUrl.lastIndexOf('/'));
+                 this.load.image(tileset.name, path + '/' + tileset.image);
+             })
+         });
+         this.load.tilemapTiledJSON(Textures.Map, mapUrl);
          this.load.image(Textures.Rock, 'resources/objects/rockSprite.png');
          this.load.spritesheet(Textures.Player,
              'resources/characters/pipoya/Male 01-1.png',