s4m_ur4i Posted November 21, 2015 Share Posted November 21, 2015 Hello everyone,Using Phaser for about 2 year, my old account seems to be deactivated-so this is a new one, I'm not new to Phaser. I started to create a kind of "strategy" game, it's more a "build" game. So I want to save my data which is generated at runtime. After 2 Nights of no sleep I've got a nice solution using nwjs which enables me to use nodejs modules at frontend usage. So I can create files at clicking "s" for example. And this by running a Phaser game, loading a file works fine too.Now the issue I am running in:I edit a map like in the Phaser example by changing tiles etc.> http://phaser.io/examples/v2/tilemaps/blank-tilemap <Those tiles have different collide options and events and I need to save all those data, so that a player can save a generated "map" and load it. Saving the whole map object doesn't work and I think it is not the right way: (map = game.add.tilemap() since I only need something like a JSON-File similar to something that tiled (editor) exports?First of all you can not create a file and writing the map object in it, ...that would be too easy. And forget to use JSON.stringify / parse on it, I've got this to work but it hold references to the game etc, that need to be re-run on "load". So I need another solution, maybe someone knows a better point to start? If I am right I don't need to save all those objects, if I can save the tilemap data (JSON like tile editor does) it would work. So on load I can attach all those events to the map generated from the JSON like file. But I do not know any way to generate such a file from a PhaserJS tilemap..So were we are:- I can load / save files in my phasergame (native OS process)- I run the game as a desktop application with complete support of OS UI and behavior- need to save tilemaps (or if you have a better solution for maps, JSON like tile editor does) that can be created, edited and loaded in PhaserJS. Link to comment Share on other sites More sharing options...
s4m_ur4i Posted December 13, 2015 Author Share Posted December 13, 2015 So I've managed it by writing a specific saving function which gets each necessary positioned Tile, takes all properties which are needed and stores them through a JSON like architecture.Was a lot of work and trouble but finally I can load and save self created maps by the user and load them, share them etc. There is no code that I could provide since this is too specific to your code and game. Maybe there is a better way so I do not mark this post as answered. Link to comment Share on other sites More sharing options...
Recommended Posts