Tell me more ×
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
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

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.