خرید بک لینک

Vote count: 0

Will keep this short and simple:

I have a 2D game with a movable character, and I have written some code to allow my player to jump, like so:

if (Keyboard.GetState().IsKeyDown(Keys.Space) && hasJumped == false)
{
    sound.Play(volume, pitch, pan); // plays jumping sound
    position.Y -= 5f;               // position of jump
    velocity.Y = -10.5f;            // velocity of jump 
    hasJumped = true;
}

However when I hold down the Space Bar , my player will continue to jump when he lands back to the ground, however I want my player to only jump once during the duration of holding down the Space Bar , then having to press it again to jump.

I appreciate any help given.

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 12 ارديبهشت 1395 ساعت: 8:13

صفحه بندی