Dealing with save files?



  • Hi guys,

    I'm trying to make a save that works beetwen sessions, but when I close and then open my game again, it doesnt load the old save data (using Flxsave).

    To maintain data between sessions, do you guys write to a file using Sys.io.File or use Flxsave? Maybe I'm doing something wrong.

    Thanks!



  • I think i fixed it using Flxsave. It's a serialization on an object class that was causing the issue. I'll post a solution tomorrow, so people that have the same problem can use it.

    Thank you.



  • Maybe forgot to call .flush() on FlxSave



  • Thank you for replying. I figured out the problem, it was a two part:

    1. Correctly check if there's data already on the Flxsave slot (that was pretty dumb on my part, i skipped that).
    2. You can't push a class into the save file like this:
    _save.data.MyVar.push(MyClass);
    

    That gave me a trace overflow issue in flashdevelop, so i figured:

    _save.data.MyVar.push( Type.getClassName(Type.getClass(MyClass)) );
    

    Works fine because it stores it as a string. When loading you can get you class by doing Type.resolveClass().

    That resolves the issue, hopefully it helps someone in the future. It wasnt clearly documented in the haxeflixel docs.

    Thanks again for replying.


Log in to reply
 

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.