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\$
1
  • \$\begingroup\$ I also up vote your question because I also have to search for this thing. \$\endgroup\$
    – Siddharth
    Jun 9, 2013 at 4:11

2 Answers 2

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\$

You must log in to answer this question.

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