# Change the shape of body dynamically

I have a problem where i have a ballon which i need to continuously inflate and defalte in update method, I have tried to used setScaleCenter but it is not giving desired result. Below is a code i am trying to make work

    scale += (float) ((dist-lastDist)/lastDist);
Log.d("pinch","scale is "+scale);
Log.d("pinch","change in scale is "+(float) ((lastDist-dist)/lastDist));
player.setScaleCenter(scale, scale);
player.setScale(scale);

• I don't think this is a thing that Box2D does very well. If you're a confident programmer you can look into Maciej Matyka soft bodies and make something yourself... – RandyGaul May 5 '14 at 19:32
• You say it is not giving the desired result - what result is it having? – Steven Jan 5 '15 at 21:47

## 1 Answer

I'll assume that player is of type Sprite. You are changing the sprite size and center of the scaling. That has no effect on the physics body.

You can try using the setRadius() method from the Shape class. Not sure if that works for every Shape, but it does work for circle shapes. If you are creating circle bodies like this:

Body b = PhysicsFactory(physicsWorld, player, bodyType, fixture);


Try:

b.getFixtureList().get(0).getShape().setRadius(newRadius);