Saving world state using b2dJson
Posted: Mon Jun 10, 2013 9:57 am
I'm trying to save my game's state using the json tools in TouchJSON, which are used in RUBELayer.
I'm attempting to save my world to a file (now that's how poetry should react to a changing culture!) by using this code, basically taken from BasicRubeLayer but using the write instead of the read:
NSString* filename = @"newWorld.json";
NSString* fullpath = [CCFileUtils fullPathFromRelativePath:filename];
b2dJson json;
bool wroteFile = json.writeToFile(_world, [fullpath UTF8String]);
printf("wrote %i \n", wroteFile);
The wroteFile returns good, and I've followed the code all the way to jsoncpp.cpp's StyledStreamWriter::writeValue( const Value &value )
and I'm seeing what looks like values from the world seemingly accessed and written. But my newWorld.json file stays empty.
Any ideas why is that? I added the file to the project, and it's in the same directory from where my rube scene's json is being read for loading my subclass of RubeLayer. I also chmod'd newWorld.json to have write permissions. So I'm not sure what am I missing here.
I'm attempting to save my world to a file (now that's how poetry should react to a changing culture!) by using this code, basically taken from BasicRubeLayer but using the write instead of the read:
NSString* filename = @"newWorld.json";
NSString* fullpath = [CCFileUtils fullPathFromRelativePath:filename];
b2dJson json;
bool wroteFile = json.writeToFile(_world, [fullpath UTF8String]);
printf("wrote %i \n", wroteFile);
The wroteFile returns good, and I've followed the code all the way to jsoncpp.cpp's StyledStreamWriter::writeValue( const Value &value )
and I'm seeing what looks like values from the world seemingly accessed and written. But my newWorld.json file stays empty.
Any ideas why is that? I added the file to the project, and it's in the same directory from where my rube scene's json is being read for loading my subclass of RubeLayer. I also chmod'd newWorld.json to have write permissions. So I'm not sure what am I missing here.