johnnyboy5566 johnnyboy5566 - 1 year ago 80
JSON Question

Libgdx json file initial game values

Quick question.

In my code I have the storing of my game values to Json. How would I do something where the first time they enter the game it sets the players values to the default base values. I have a method that has these values set that I can call and then use my save method? But I need a method that checks if its the first time the game has been run.. And if its the first time somehow create the json file to save to later.

Answer Source

For Libgdx you should use FileHandle:

FileHandle valuesFile = Gdx.files.internal("values.json");
if (!valuesFile.exists()) {

I would suggest you to check(and create) it prior the actual game starts, for example, during the loading screen setup.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download