Monday, January 31, 2011

Save Files Are Kicking My Ass

So I thought to myself, "Hey, I'm getting tired of slogging through the new game menus every time I want to test something, lets get the saving/loading functionality into the game."  And apparently the tiny bit I know about OOP in actionscript isn't working with the tiny bit I know about save files.  Blech.

Does anyone know the commands to save/load an array without having to break it into little pieces and mess with it one by one?

EDIT:  Hotkeys are in and done.  Fuck the save system for now.

2 comments:

  1. talk to daisystrike they just solved this issue for otherworld not to long ago. http://daisystrikesdk.blogspot.com if you don't know it already.

    ReplyDelete
  2. It would help if you gave some more detail on what exactly the problem is. ;)

    I'm guessing the problem is that the saved data array points to the same set of data as the array used in the game. So, to fix that...When you save the game, you need to copy the data from the game array into the saved array. Then, when you load the game, you need to copy the data from the saved array into the game array.

    There are a couple of ways to do this. If you really only have an array:


    function clone(p_source:Object):*
    {
    var newobj:Object = new Object();
    for (var ts:String in p_source)
    newobj[ts] = p_source[ts];
    return newobj;
    }

    Here's a much more general function:

    function clone(p_source:Object):*
    {
    var copier:ByteArray = new ByteArray();
    copier.writeObject(p_source);
    copier.position = 0;
    return(copier.readObject());
    }

    ReplyDelete