Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my game, I want to change density of my body object when it collide with other objects. I found something like following to change density but further I could not able to find any hint for this. So someone please help.

Fixture fixture = goldenBoxArrayList.get(i)

After setting fixture data I could not able to set it to the body.

EDIT : I want to change my object body density when physics world in simulation

share|improve this question
What are you trying to do? Why do you need to change the density of an object? – knight666 Jun 13 '12 at 12:22
How to ask questions the smart way: ask the goal, not the step. – doppelgreener Jun 13 '12 at 12:25
up vote 4 down vote accepted

I'm not sure about AndEngine but in Box2D you can call the following functions:

fixture->SetDensity(5.0f); //this fixture is attached to body below
body->ResetMassData(); //must call this after changing density

AndEngine's physics is just a JNI wrapper around Box2D so it should support all or a subset of Box2D features.

Also check 7.4 Using a Body of Box2D manual, its possible to override mass data calculated from fixtures on a body using:

void SetMassData(const b2MassData* data);
share|improve this answer
Yes that I want. Your consideration work perfectly. – Siddharth Jun 14 '12 at 5:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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