Math help

I have an physics object. Also, I have it set up where you press once it gets bigger, removes physics then adds back again. My problem is when new physics body being added the radius stays the same as it was. I'm trying to figure out a formula where the radius will be according to new size.
Any help?
Thanks

The image, is it a circle or a square? If it's a circle you can grab its radius or if it is a square shape (but you want a circle body) you could set the new body radius to obj.width/2.

EG;

1
2
3
4
5
6
7
8
9
10
display.setStatusBar (display.HiddenStatusBar)
 
-- Set up physics
require ( "physics" )
physics.start()
physics.setGravity( 0, 0 )
physics.setDrawMode ( "hybrid" )
 
local box = display.newRect( 100, 100, 40, 40 )
physics.addBody(box, {radius=box.width/2})

Thank you so much! The solution is so simple. lol
I have spend few days on this trying to figure out. Thanks you saved me bunch of time.

Not a problem - glad I could save you some time :)

views:2262 update:2012/2/13 9:11:28
corona forums © 2003-2011