if (currentKBState.IsKeyDown(Keys.Space) == true)
{
Jump(gameTime);
charPosition.Y -= jumpHeight;
jumpHeight++;
if (jumpHeight == 20)
{
jumpHeight = 0;
}
}
Jump(gameTime) just takes care of switching the animation.
When I press space, the sprite with jump but it doesn't fall. It just keeps going up. And if I change my code to this
if (currentKBState.IsKeyDown(Keys.Space) == true)
{
Jump(gameTime);
charPosition.Y -= jumpHeight;
jumpHeight++;
if (jumpHeight == 20)
{
charPosition.Y += jumpHeight;
jumpHeight--;
}
}
it will fall but continues to fall until I let go of space. However it won't go up again if I press spacebar. So if anyone could help me, that'd be great. Also, how would I got about making it so that the spacebar only has to be pressed to jump instead of being held down?

New Topic/Question
Reply



MultiQuote







|