How can I get my character to come back down even if the user still has the button pressed?

Started by
10 comments, last by rubsnick 11 years, 4 months ago

*** snip ***

Thats best solved the same way though, except you allow for acceleration to continue for a fixed amount of time after the jump started.


I'd also set that fixed amount of time to 0 when the button in released and reset it once you hit the ground to guarantee smooth movement when mashing the jump button.
Advertisement
Thanks everyone for your responses I've been working on it for a while and I just cannot seem to get past my problem. He stays up in the air regardless of what I do. :/ Here is my code What the hell am I doing wrong...


[source lang="java"] if(Gdx.input.isKeyPressed(Keys.SPACE)&&man.y<=150&&AllowJump==true)
{


stateTime += Gdx.graphics.getDeltaTime(); // #15
currentFrame = walkAnimation.getKeyFrame(stateTime, true);


man.y += 450 * Gdx.graphics.getDeltaTime();

if(man.y>150)
{
AllowJump=false;
}


}

//This is my Release

if(!Gdx.input.isKeyPressed(Keys.SPACE))
{
if(man.y>=50)
{
man.y -= 350 * Gdx.graphics.getDeltaTime();
}
if(man.y<=50)
{
AllowJump=true;
}
}[/source]

This topic is closed to new replies.

Advertisement