disable multi-element body elements - ball with multiple radius

Hi, 

What I’m trying to accomplish is overtime the ball bounces, it visibly reduces in size (changing  the xScale and yScale ) and trying to get the body physics to also match the new size.  When I try dropping the current body and adding a new one, I lose the physical traits such as velocity and angle plus there is a moment of pause while I’m doing this.  I’ve read through he forums and Brent Sorrentino’s article on multi-element bodies using the selfElement property, but my problem is with overlapping body shapes.   Is this possible?

Here’s sample code illustrating my issue

local physics = require( "physics" ) physics.start() local function preCollide( event ) print( event.selfElement ) if event.selfElement == event.target.currentSize then -- do something to "authorize" the event end end local function postCollide( event ) if event.force \>= .01 and event.target.currentSize \> 0 then event.target.xScale = event.target.xScale \* .9 event.target.yScale = event.target.yScale \* .9 event.target.currentSize = event.target.currentSize - 1 end end local ground = display.newRect( display.contentCenterX, display.contentHeight, display.contentWidth, 50 ) ground.id = "ground" physics.addBody( ground, "static" ) local ball = display.newCircle( display.contentCenterX, display.contentCenterY, 100 ) ball.id = "ball" ball.currentSize = 2 physics.addBody( ball, { radius = 100 }, { radius = 90 }, { radius = 81 }, { radius = 72 } ) ball:addEventListener( "preCollision", preCollide ) ball:addEventListener( "postCollision", postCollide)

Thanks for any help!

Box2D doesn’t like doing things like changing size. I recommend using multiple bodies, attached to each other, and shifting their position relative to a central point. For example, a ball could be made from multiple balls all joined together and moved inwards over time.

Box2D doesn’t like doing things like changing size. I recommend using multiple bodies, attached to each other, and shifting their position relative to a central point. For example, a ball could be made from multiple balls all joined together and moved inwards over time.