Howdy guys,
I was wondering if anyone can give me some tips about how to create a decent method for saving and loading the sate of my game. I thought about making all the classes in the game implement the Serializable interface and then output all of the objects to a file.
No no no bad bad bad. This kind of midless Serialization leads to performance disasters on load and save.
Serialization *can* be useful but you need to think carefully about what you really want to save and only Serialize that.
The properties I want to store are things like the position, velocity and orientation of all the objects in the game as well as a few game properties such as the players' scores. Somehow I need to store all of these properties into a single object and also be able to restore all the properties when loading the game. What solutions to this problem are there?
Either well isolate just those thinsg in small number of seperate classes and use Transient to make absolutely sure you arent pulling in otther refernced objects and their data OR just open a DataOutputStream aroudna FileOutputStream for writing it out and a DataInputStream around a FIleInput Stream for reading abck and write logic to ull the values out/create obejcta s necessary when reading back.
TANSTAAFL