How to remove body from physics to get back original

in my game
player/user draws a bridge (set of rectangles)between two points
and turns on physics to check strength of bridge (which changes shape of original drawing).
user can turn-off physics at any time
once physics is turned off how to get back all the objects/sprites/rectangles to its original shape??

First you probably want to pause and resume physics rather than turn it on/off. Keep your bridge beams in a table with the dimensions of x, y, width, height and center point. You may also want to store the dimensions for the physics shape and pivot joints too.

Just a thought,

-David

Thanks David for your thought

player may want to redesign whole bridge again, so i have to stop
i can't keep partial bridge in out of shape while designing it

Moved to Developer Support.

Bug forum is for suspected Corona bugs only ;)

Thanks,
Peach :)

so Peach,
this is not a bug, it is a limitation that you can't get back original once add objects to physics?? :)

why corona is not releasing memory even after i stopped physics and removed all drawn rectangles with removeSelf() and made to nil

To make sure I understand you properly, you wish to remove the physics bodies but not the images?

Your question about memory, removing all rectangles and memory not releasing - is there no change at all or is it just not as great as you'd expect?

Please use the below function and let me know results from before rectangles are removed and then again from after they have been removed;

1
2
3
4
5
6
7
8
9
10
local function monitorMem(event)
     collectgarbage("collect")
     
   print( "\nMemUsage: " .. (collectgarbage("count")/1000) .. " MB")
   print("Texture Usage " .. system.getInfo( "textureMemoryUsed" ) / 1000000)
       
   return true
end
 
Runtime:addEventListener("enterFrame", monitorMem)

Peach, i'll give this information later
now i'm facing other serious problem like this one below
http://developer.anscamobile.com/forum/2011/03/21/random-crashes-after-i-started-using-physics

Are you stopping physics or pausing it?

Are all collisions resolved when you do so?

i'm pausing it, then i'm clearing all physics bodies with removeBody (i read about it in forum, couldn't find in documentation though)
i'm not handling any collisions. i left it to physics engine, because i have no functionality for collisions.
i only need to break bridge if any joint reached max weight thresh hold.

If the memory usage isn't decreasing then the bodies aren't being removed which may very well be connected to this issue.

Can you please post plug and play sample code?

views:1575 update:2011/11/14 9:16:56
corona forums © 2003-2011