2
\$\begingroup\$

I'm making a game for Android with AndEngine.

It's going quite well, but now I'm stuck on something. My main character has a elasticity set in its fixturedef so it bounces around throughout the game. Now i want the user to be able to not let the player bounce when he does a control.

So my question: how can I modify the elasticity of my character? Because I saw you can adjust the setDensity and setFriction, but I cant see the setElasticity....

Thanks in advance!

\$\endgroup\$
  • \$\begingroup\$ I also up vote your question because I also have to search for this thing. \$\endgroup\$ – Siddharth Jun 9 '13 at 4:11
1
\$\begingroup\$

Following way you can change the restitution or elasticity of any body in box2d.

ArrayList<Fixture> fixtureList = body.getFixtureList();
    for (Fixture fixture : fixtureList)
        fixture.setRestitution(0.5f);
\$\endgroup\$
0
\$\begingroup\$

This is because elasticity is expressed as a coeficient of restitution. Look for setRestitution (float restitution).

\$\endgroup\$

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.