I have a platform game I am building. It has 5 frames. Each frame has physics objects on it. When I goto the next frame, the new scene loads up with new objects. While leaving frame 1, I destroy all the bodies and MC's attached to the bodies in a for loop, and then hit frame 2 and build new bodies and MC's. Problem is, I don't think they are truly destroyed, or are in cache somewhere, because the FPS drops dramatically.
I need the simplest way to completely destroy the world if you will, and have it not sit in cache anywhere, so it goes to garbage collection in AS3. Can I destroy the entire world, and build a new one on each frame? Anyone know the best way about this, or is there a way to destroy everything within the world and have the objects really gone and not sitting around anywhere?
Here is the code I use to destroy the bodies:
testNow and testNow2 are arrays. When I built the bodies, I pushed them into those arrays. testNow = bodies, and testNow2 = movieclips attached to bodies.
I appreciate your time!! Thank you.
I need the simplest way to completely destroy the world if you will, and have it not sit in cache anywhere, so it goes to garbage collection in AS3. Can I destroy the entire world, and build a new one on each frame? Anyone know the best way about this, or is there a way to destroy everything within the world and have the objects really gone and not sitting around anywhere?
Here is the code I use to destroy the bodies:
Code:
for (var i:int=0; i<testNow.length; i++){
m_world.DestroyBody(testNow[i]);
removeChild(testNow2[i]);
}
m_world.DestroyBody(testNow[i]);
removeChild(testNow2[i]);
}
testNow and testNow2 are arrays. When I built the bodies, I pushed them into those arrays. testNow = bodies, and testNow2 = movieclips attached to bodies.
I appreciate your time!! Thank you.