AlanSmithee Posted April 18, 2015 Share Posted April 18, 2015 Hello. I am trying to use a tilemap (which is not persisted to any form of database or file) over several states by using the cache. STATE ONE// Creating the tilemap..var map = this.game.add.tilemap();map.addTilesetImage('ground_1x1'); map.create('level1', 40, 40, 32, 32);map.setLayer(0);// In this state I am editing the map by adding / removing tiles from the layers// I then add it to the cachethis.game.cache.addTilemap('test', map);// Then when changin state, I'm clearing world but keeping cache:this.state.start('LevelTwo', true, false);STATE TWO// I am loading the map from the cachethis.game.load.tilemap('test', this.game.cache.getTilemapData('test').url, null, Phaser.Tilemap.CSV); // And adding it back to the gamethis.game.add.tilemap('test');But this doean't work.. I have tried to use my cached map as both the url and/or data argument when loading it back to the game, but nothing seems to work. It is possible that this is conceptually wrong, and that there is some much easier way to do this then to use the cache like I am trying to - if so please tell me! I do not, however, want to keep world between states since most of the world related information is not shared between states. I am also wondering how to get the actual map data from a map, since i would like to persist it at a later point.. as i inspect my map, I notice that the data field is empty, is there something that needs to be done to generate this? Thanks in advance! / AS Link to comment Share on other sites More sharing options...
P4nch0 Posted December 19, 2015 Share Posted December 19, 2015 hi, do You found solution of problem? i need use cache to save the map too. Maybe anyone can tell how to use cache to map? Link to comment Share on other sites More sharing options...
drhayes Posted December 21, 2015 Share Posted December 21, 2015 Do you need to save it in the cache specifically? The third parameter to "load.tilemap" can be the JSON data object itself. Link to comment Share on other sites More sharing options...
Recommended Posts