TheRegge Posted July 29, 2014 Share Posted July 29, 2014 I am making a relatively simple game using Phaser.Tilemap... I need to save the tilemap data to a sql database. Any idea how to go about that? I am aware of localstorage, but I need a permanent data save that can be share across sessions and users... Also, when I try to use:myTileMapName.dump();also,I get hundreds of '.' characters printed to the console... nothing else... I am confused. Any help very appreciated. Link to comment Share on other sites More sharing options...
Heppell08 Posted July 29, 2014 Share Posted July 29, 2014 I've had some experience using mySQL and can safely say it is not my favourite environment to code in. I do however know this is possible. CSV Storage - http://www.mysqltutorial.org/import-csv-file-mysql-table/ JSON Storage - http://stackoverflow.com/questions/12165456/import-json-file-into-mysql-database-with-php Link to comment Share on other sites More sharing options...
TheRegge Posted July 29, 2014 Author Share Posted July 29, 2014 Thank you Heppell08.Any idea how to get the data of a tilemap (after I destroyed some tiles in game) ? or why mytilemap.dump() only outputs hundreds of '.' characters to the console? Link to comment Share on other sites More sharing options...
Heppell08 Posted July 29, 2014 Share Posted July 29, 2014 Have you tried:(function() { console.dump = function(myTilemap) { if (window.JSON && window.JSON.stringify) console.log(JSON.stringify(myTilemap)); else console.log(myTilemap); };})();Just as a means for testing it ffor outputting the correct data. Link to comment Share on other sites More sharing options...
freddynoe Posted August 5, 2014 Share Posted August 5, 2014 Just extract the JSON, then upload it to json-csv.com - that will give you CSV which you can easily import into MySQL using: LOAD DATA INFILE 'filepath/your_csv_file.csv' INTO TABLE tablename; Link to comment Share on other sites More sharing options...
Recommended Posts