Hi , this is my first post here ! I’ve been playing with jMonkey for some time, it’s great by the way, and I have some questions concerning saving and loading of games using the Savable system:
I’ve checked this thread , this page of the wiki and this template, but…
Say I got:
class BigBox implements Savable {
private SmallBox aField = new SmallBox();
public void write(JmeExporter ex) throws IOException {
OutputCapsule capsule = ex.getCapsule(this);
capsule.write(aField, “aField”, new SmallBox());
}
public void read(JmeImporter im) throws IOException { InputCapsule capsule = im.getCapsule(this); aField = capsule.readSavable("aField", new SmallBox() ); }
}
class SmallBox{
String colour = “red”;
}
- Does SmallBox needs to implements savable ?
- If so, to load my game, do I need to call read() on both my objects for the whole thing(a small red box in the big box) to be complete ? If so, is there a specific order in which to do so ?
- Is there a way to iterate through my saved game to instantiate all the objects it contains ? For example, I save 100 instances of BigBox to one file, then I want to re-create as many instances of BigBox as there is saved (knowing that each BigBox has different value in it’s fields and that ) ?
I know this might be a bit basic, but if you could point me in the right direction that would be very cool. Sorry for the long post & thanks for any help…