Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have been playing with box2d in libgdx and have made a falling ball.

Once the ball lands on the ground I want to be able to reset it to the top with the space-bar key

I have done this:

if (Gdx.input.isKeyPressed(Keys.SPACE))
    {

        ball.setTransform(200f, 447f, 0f);
        ball.setLinearVelocity(0f,0f);
        ball.setLinearDamping(0f);
        ball.setAwake(true);
    }

this seems to work fine except for one thing: the ball falls with a much higher velocity then it does the first time (when the application opens).

I have set the LinearVelocity to 0 so I don't get why it behaves differently to the ball on the start of the app?

Am I missing something?

Thanks for the help, Jason

share|improve this question

closed as off-topic by Anko, Seth Battin, Josh Petrie Feb 26 at 4:05

  • This question does not appear to be about game development within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Ran the C++ analog of your code snippet, but the ball appears to fall at the same speed regardless. I see nothing wrong with your code either. Does it have 0 damping to start with? It may be getting set to something else in the default constructor. –  Clairvoire Sep 17 '11 at 2:39
1  
@Clairvoire: Hmm interesting.. I suppose it's a bug in libgdx then. I will open a bug report on libgdx. Thanks for your time. –  Jason Sep 17 '11 at 8:29
2  
This question appears to be off-topic because it is about a Libgdx bug best discussed with the Libgdx developers. –  Anko Feb 25 at 0:21
add comment

Browse other questions tagged or ask your own question.