Must include <spriteLoq>:dispose()?

I seem to be having memory issues related to whether or not I use when I am cleaning up a scene. I read that we didn't need to include this for spriteloq sprites, but in some cases if I don't include it, my app will crash right away. If I do include it, I get random crashes. What is the best practice for using :dispose?

Thanks!

I use Spriteloq and Director, and I add the following code when I'm cleaning up a scene (i.e., right before the director changes the scene):

1
2
spriteFactory:dispose();
spriteFactory = nil;

Naomi's usage is correct.

You call SpriteFactory's dispose method to unload the sprite sheets from memory when you're done with them and want to reclaim memory.

Be careful not to load the same spritesheet again too quickly after a dispose since that will cause an error.

Implementation note ignore if you don't want to know the finer details:

Internally, the actual spritesheet dispose happens with a timer.performWithDelay because if you call removeSelf on sprites then immediately call dispose on a spritesheet an error will occur since the spritesheet will attempt to remove the sprites again.

If you're getting crashes try to narrow down what code is crashing with a log to a text file, so at least you have some record of where it might be happening.

views:1439 update:2011/10/29 17:13:10
corona forums © 2003-2011