I just started using Box2d and libgdx. I followed this tutorial, https://github.com/libgdx/libgdx/wiki/Box2d And a ball would bounce if I run the following code I took from the tutorial.

// ...omit the rest of code
World world = new World(new Vector2(0, -10), true); 
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.DynamicBody;
bodyDef.position.set(100, 300);
Body body = world.createBody(bodyDef);
CircleShape circle = new CircleShape();
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = circle;
fixtureDef.density = 0.5f; 
fixtureDef.friction = 0.4f;
fixtureDef.restitution = 0.6f; // Make it bounce a little bit
Fixture fixture = body.createFixture(fixtureDef);
// ...omit the rest of code

I'm wondering how I can make the ball bounce like a basketball or volleyball? It's like the ball movement is in a space, move so slowly. I changed some properties such as density or friction, but it seems box2d doesn't care of air friction, so nothing changed at all. Could you tell me how I can make the ball movement to be a basketball or such stuff?


2 Answers 2


I now understand how box2d works. It is 1 pixel = 1 meter and my screen size is 480 * 320. That means 480m * 320m in box2d! It is so huge. So I just needed to convert default positions of box2d Bodies something like 1/32, then box2d worlds would be like 15m * 10m. To confirm things going well, I needed to put some sprites to draw in actual size which is 480 * 320. I multiplied box2d bodies position with 32.


Best way to do this is by damping factor. LinearDamping and AngularDamping factor can be modified according to your requirement. Just try and manipulate these two parameter according to your choices.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .