cutterslade Posted May 3, 2014 Share Posted May 3, 2014 Hi guys! First post here, still getting my feet wet with Phaser, and loving it so far! I'm trying to port an existing RPG engine I have working on iOS, and I've managed to convert and load my tilemaps from JSON files exported by Tiled. One thing that bothers me though is that in every tilemap sample I've seen the tileset is manually preloaded, separately from the tilemap file. I'm my case that would be a pain because pretty much every map has its own tileset, and it would be better it there was a way for Phaser to automatically load the tileset from the image specified within the JSON file. I've searched around this forum and the docs, but found nothing like that, is that possible? The only way I can see to do that would be for my own code to "pre-parse" the JSON file and get the name of the image file, but that is inconvenient and defeats the whole concept of Phaser's States preloading the necessary resources (as these map files can get quite large). Thanks in advance! Link to comment Share on other sites More sharing options...
sleekdigital Posted May 4, 2014 Share Posted May 4, 2014 It may be a little inconvenient, but I think that is exactly what you need to do. I don't think it defeats the concept of phaser's states at all, It just means you need multiple preload states. Link to comment Share on other sites More sharing options...
rich Posted May 5, 2014 Share Posted May 5, 2014 There are two reasons I didn't do this: 1) The main reason was that it allowed you to easily use a variety of tilesets with 1 set of map data, by just swapping the image being used. 2) The image paths in the json are usually a right mess. Sometimes relative, often with local file systems included. Knowing where to actually load it from would have to be pure guess work, I could strip everything other than the filename maybe, but if you've got your images stored in a sub-folder it would break that, and I can't know at what point the path is correct. So I'd have to find a way for you to tell the parser "this bit is correct, this isn't", etc and frankly it's a bit of a mess. So sorry, but in this instance you need to roll your own solution I'm afraid. Link to comment Share on other sites More sharing options...
cutterslade Posted May 5, 2014 Author Share Posted May 5, 2014 No problem at all, every reason you stated makes complete sense! Now to start planning how my pre-preload would work Thanks for the replies! Link to comment Share on other sites More sharing options...
Recommended Posts