How Do You Resize Physics Bodies?

Is there any way to resize physics bodys with a sort of xScale/yScale factor? I’m trying to implement pinch to zoom in my game and the images/level is resizing correctly, but the physics is not.

Thanks! [import]uid: 49205 topic_id: 9536 reply_id: 309536[/import]

Nope, sorry… at least at this current point it’s not possible. However, you might be able to delete the current physics body upon “first touch” then when the user has finished zooming or pinching, you re-assign a new body based on the resulting scale. Of course, if you have dozens or hundreds of objects that must ALL be zoomed or pinched simultaneously (like zooming out a whole physical world), this could be a real complicated scenario.
[import]uid: 9747 topic_id: 9536 reply_id: 34851[/import]

Yeah. That’s what I was afraid of. I guess removing/creating new bodies is the only way to go for now.

Thanks! [import]uid: 49205 topic_id: 9536 reply_id: 34852[/import]

Just an update. Apparently the physics bodies are dynamically resizing themselves. physics.setDrawMode(“hybrid”) shows the bodies incorrectly when they are resized but the collisions are working correctly. [import]uid: 49205 topic_id: 9536 reply_id: 34858[/import]

Wow, cool! I stand corrected then. I think this was a “bug” a few months ago; I wasn’t aware that Ansca fixed it. Or maybe the bug I remember was in regards to using different screen zoom settings (in config.lua) and the physical bodies would not re-adjust properly. That probably still is a bug, but not really a crucial one that can’t be worked around.

Anyway, good to know that scaling objects also scales the physics bodies. :slight_smile: [import]uid: 9747 topic_id: 9536 reply_id: 34861[/import]

Not true for build 484 because when you scale the object it changes the image size but not the physics size. If this problem has been fixed already in later builds please let me know.

Glenn [import]uid: 38820 topic_id: 9536 reply_id: 34872[/import]

I’m using build 484. The physics bodies are resizing on my Samsung Captivate. [import]uid: 49205 topic_id: 9536 reply_id: 34873[/import]

Nope physic bodies do not resize when using object:scale(2.0,2.0). I have a Captivate too and only the images are scaling not the physics bodies. [import]uid: 38820 topic_id: 9536 reply_id: 34944[/import]

I’m using the code from: http://developer.anscamobile.com/content/pinch-zoom-gesture

I don’t know what to say besides that it’s working for me. [import]uid: 49205 topic_id: 9536 reply_id: 35036[/import]