What? Posted December 11, 2014 Share Posted December 11, 2014 In my game I want a single tilemap loaded for each room as the player enters them. I made a function that loads a tilemap, where the name of it is the parameter:new_room: function(name) { this.load.tilemap(name, 'assets/tile/' + name + '.json', null, Phaser.Tilemap.TILED_JSON); map = this.game.add.tilemap(name); foreground = map.createLayer('foreground'); map.setCollisionBetween(1, 100000, true, 'foreground'); },The name of the tilemap I'm trying to load is "second", but it's not working:"Phaser.Cache.getTilemapData: Invalid key: "second"" phaser.min.js:16"Phaser.TilemapParser.parse - No map data found for key second" phaser.min.js:20I feel like there could be some feature in Phaser that does what I'm trying to do. I'm not familiar with dynamically loading things. Ashish 1 Link to comment Share on other sites More sharing options...
Ashish Posted September 19, 2016 Share Posted September 19, 2016 Hi . I am getting the same error . Can you tell me that how you solved this problem? Link to comment Share on other sites More sharing options...
What? Posted September 19, 2016 Author Share Posted September 19, 2016 49 minutes ago, Ashish said: Hi . I am getting the same error . Can you tell me that how you solved this problem? I think the problem was that I was trying to add the tilemap before it finished loading. The solution was using the "onLoadComplete" event to add the tilemap after it was loaded in. You also need to start the loading with "load.start()" to make it load in the first place. Link to comment Share on other sites More sharing options...
Recommended Posts