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??

[import]uid: 97420 topic_id: 17552 reply_id: 317552[/import]

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 [import]uid: 96411 topic_id: 17552 reply_id: 66724[/import]

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 [import]uid: 97420 topic_id: 17552 reply_id: 66842[/import]

Moved to Developer Support.

Bug forum is for suspected Corona bugs only :wink:

Thanks,
Peach :slight_smile: [import]uid: 52491 topic_id: 17552 reply_id: 66892[/import]

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

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

[import]uid: 97420 topic_id: 17552 reply_id: 66894[/import]

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;

[lua]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)[/lua]

Peach :slight_smile: [import]uid: 52491 topic_id: 17552 reply_id: 66945[/import]

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
[import]uid: 97420 topic_id: 17552 reply_id: 67100[/import]

Are you stopping physics or pausing it?

Are all collisions resolved when you do so? [import]uid: 52491 topic_id: 17552 reply_id: 67105[/import]

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. [import]uid: 97420 topic_id: 17552 reply_id: 67125[/import]

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? [import]uid: 52491 topic_id: 17552 reply_id: 67134[/import]