how do I change a physics property during game?

If i’ve intially declared a body set of properties such as:

local body1 = { density=1.2, friction=0.2, bounce=0.2, radius=28 }

and have used this for a physics object such as:

local ball = display.newImage( “ballImage.png” )
physics.addBody( ball, “static”, body1 )
then how do I later when the physics is running change the density of
my ‘ball’?

would it be something like:

body1.density = 2

I basically want to make it ‘heavier’ when it reaches a certain region.

thanks!!
[import]uid: 13568 topic_id: 8943 reply_id: 308943[/import]

Try this…
body1 = { density=?, friction=0.2, bounce=0.2, radius=28 }
That should work, let me know if it doesn’t.

–Chris [import]uid: 17138 topic_id: 8943 reply_id: 32719[/import]

I have the same question.

Let’s say I wanted to change the bounce of “trampoline”. Here’s how I’d figure you’d be able to do that…

This is where trampoline is originally defined.

trampolinebounce = 10
trampoline1 = { density = 1.0, friction = 0.1, bounce = trampolinebounce }
local trampoline = display.newRect(110,300, 100, 10)
physics.addBody(trampoline, “static” , trampoline1 )

Here’s my function where I’d like to change the bounce of trampoline.

function makelessbouncy ( event )
trampolinebounce = 1
end

trampoline:addEventListener( “touch”, makelessbouncy )

However, this doesn’t work. Changes to trampoline1 after the physics have been defined don’t appear to have any effect… [import]uid: 56516 topic_id: 8943 reply_id: 35307[/import]