rizvanhaider Posted November 18, 2014 Share Posted November 18, 2014 I am making kids ABC learning game in phaser. I used jquery to read json file and used data in my game successfully but when I run that game on android the data was not shown there... because I think JQuery is server dependent and there is no server for mobile.. so know I want to read and also want to write (I want to write data to change application images and colors as user chose...) or update json data in separate file .. how can I do that.. my json data is like. [{ "letter": "A", "lfor": "Apple", "ref":"Assets/Limages/1.png"}, { "letter": "B", "lfor": "Banana", "ref":"Assets/Limages/2.png" },.......] Link to comment Share on other sites More sharing options...
lewster32 Posted November 18, 2014 Share Posted November 18, 2014 The JSON file only needs to be downloadable like any other asset, and it should load and be parsed correctly. If all else fails, you can simply paste your JSON into your JavaScript as a variable (or load it as a separate script file like you do Phaser itself) as JSON is valid JavaScript:var JSONData = [{ "letter": "A", "lfor": "Apple", "ref":"Assets/Limages/1.png"}, { "letter": "B", "lfor": "Banana", "ref":"Assets/Limages/2.png" },.......];Will result in JSONData[0].letter == "A" and so on. Link to comment Share on other sites More sharing options...
rizvanhaider Posted November 20, 2014 Author Share Posted November 20, 2014 And what to do for updating json objects? Link to comment Share on other sites More sharing options...
lewster32 Posted November 20, 2014 Share Posted November 20, 2014 You can't write to files without some server-side code just via normal HTML and JavaScript. I imagine on Android if packaging it as an app it provides some file system access so you can write files but that's beyond my expertise. If you have a browser environment available you do have things such as Local Storage however, which you can write to and have it persist between sessions. rizvanhaider 1 Link to comment Share on other sites More sharing options...
Recommended Posts