Kobaltic Posted July 26, 2014 Share Posted July 26, 2014 I am trying to access the array that is in the tilemap. Either the json or csv file is fine. I tried map.tiles, in csv it is blank and in json it gives me a super array that has an array of numbers just not the original ones that were used. Thanks. Link to comment Share on other sites More sharing options...
lewster32 Posted July 26, 2014 Share Posted July 26, 2014 You should be able to retrieve the data from the cache:game.cache.getTilemapData(key); Link to comment Share on other sites More sharing options...
Kobaltic Posted July 26, 2014 Author Share Posted July 26, 2014 That returns the object but i can't figure the property for the array. Link to comment Share on other sites More sharing options...
lewster32 Posted July 26, 2014 Share Posted July 26, 2014 The raw layer data is found inside that object:game.cache.getTilemapData('mario').data.layers[0].dataWill give you a 2D array of all of the tile indices for the first layer. Link to comment Share on other sites More sharing options...
Kobaltic Posted July 26, 2014 Author Share Posted July 26, 2014 While I was waiting I found this Object.getOwnPropertyNames(obj) ; and I used that and found this map.layers[0].data[1][0].index. This gives me the actual values too. Link to comment Share on other sites More sharing options...
lewster32 Posted July 26, 2014 Share Posted July 26, 2014 You can easily traverse objects by using console.log(object) in a modern browser and looking in the developer tools console - it will show you the object and all of its properties, and let you browse through it at will. See attached. Link to comment Share on other sites More sharing options...
Kobaltic Posted July 26, 2014 Author Share Posted July 26, 2014 Cool thanks that should be even easier to work with. Good to know. Link to comment Share on other sites More sharing options...
Recommended Posts