CandyMan

Hi. I'm trying to figure out how to slow down a jump animation. What I want to do is once I press the upkey and then release the up key my sprite will move up by 50f, two times and then stop. It will keep doing this each time I press and then release the up key. My problem is each time I start the game my sprite automatically starts moving up by 50f. If anyone can help it would be appreciated.

Thanks.

In my Update method I have:

if (p1keyboard.IsKeyDown(Keys.Up))

{

CheckKeyPress();

}

if (p1keyboard.IsKeyUp(Keys.Up) && upKey == true)

{

time_last_frame += (float)gameTime.ElapsedRealTime.Milliseconds / 500.0f;

if (time_last_frame >= time_between_frame)

{

time_last_frame = 0f;

if (number_of_the_frame == 0)

{

p1Postion.Y -= 50f;

number_of_the_frame = 1;

}

else if(number_of_the_frame == 1)

{

p1Postion.Y -= 50f;

number_of_the_frame = 0;

}

}

upKey = false;

}

In my keyPress method I have:

private void CheckKeyPress()

{

upKey = true;

}

P.S. upKey is a bool.



Re: XNA Game Studio Express Jump Animation

deejay169

It's probably worth reading this page, it seems to cover what you're after.

http://javacooperation.gmxhome.de/PlatformGameBasicsEng.html

Cheers,

Dave J