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);
  • 2
    \$\begingroup\$ 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... \$\endgroup\$ – RandyGaul May 5 '14 at 19:32
  • \$\begingroup\$ You say it is not giving the desired result - what result is it having? \$\endgroup\$ – Steven Jan 5 '15 at 21:47

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);


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.