Save - Rombusevil/flixel-gdx GitHub Wiki

Flixel includes a simple way to save data locally, and the FlxSave object allows you to interface with it. This system is not ideal for all things; for example, if you are doing online high scores, this won’t really work. If you want players to be able to move and trade save game files, this isn’t a good fit either. However, for fast and simple saving of local data, especially things like unlocked progress or user preferences, FlxSave is an easy and built-in option.

Save usage

FlxSave save = new FlxSave();
save.bind("YOUR GAME");

A "YOUR GAME" file will be created if it doesn’t exists. It will hook the file to the save object that is just created. For Windows 7 you can find the save file in C:\Users\Username\.prefs

Save the data.

save.data.put("progress", 1);

Get the data. You've to point out what kind of class it is.

save.data.get("progress", Integer.class);

Saves and keep the object open.

save.flush();

Saves and close the save object. You won't be able to write data to the save object anymore.

save.close();

Example: