Hi,
I have been looking into scaling a physics object and realise that it is currently not possible…
I have read in a few posts that this effect can be achieved by removing the physics body and recreating it… In the following code I have added a touch listener to an object that sets the isTouch flag when touched. I then have a “enterFrame” listener in my main code that triggers the following piece of code. My problem is that when I set the gravity “physics.setGravity(0, 9.8)” the object just skips up the screen (if I set the gravity to 0 then it works perfectly but is stationary), it does not matter what I set the density too.
Thanks
[lua]
function balloon:newFrame()
physics.removeBody( self.balloonImage )
local scaleValue
if self.isTouch == true then – check if object is being touched
scaleValue = 1.025
else
scaleValue = .99
end
self.balloonRadius = self.balloonRadius * scaleValue
physics.addBody( self.balloonImage, “dynamic”, { density=.5, friction=2, bounce=0.9, radius=self.balloonRadius} )
self.balloonImage:scale(scaleValue,scaleValue)
end
[/lua]