Page 1 of 1

Loading saved world slow?

Posted: Tue Jul 02, 2013 1:59 pm
by Eddy8555
I'm using the Cocos2d sample loader for saving a world, and reloading it. The code is straightforward:

Code: Select all

-(void) loadSavedFile: (id) sender {
    NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
    NSString *fileName = [NSString stringWithFormat:@"%@/newWorld.json", documentsDirectory];
    [super loadWorld:nil andJsonFile:fileName];    
}
This works fine, but I'm noticing that when I have many bodies in the world (maybe over 50) it slows down, even considerably, and can take several seconds to reload.

Is there any rule of thumb for doing this right? Is it related to the size of the images? Anything else I should look for? Going over my code I can't see anything obvious, like calling it several times or something like that. It all looks clean. But slow :)

Re: Loading saved world slow?

Posted: Tue Jul 02, 2013 6:17 pm
by iforce2d
50 bodies is not many really. How large/many are the images? What if you load the same scene without the images? You can turn off image exporting in the scene settings dialog for a quick check. You could also probably comment out something in the loading code, but I don't have it on me to check where that would be.