如何使用C#和XNA进行双跳?

如何使用C#和XNA进行双跳?,c#,xna,C#,Xna,这是我当前的单次跳转代码,用户的输入将跳转设置为true,单次跳转没有错误,但是我无法为我的游戏生成第二次空中跳转。我必须在没有团结的情况下为学校做这件事,所以它只是在使用矩形 if (jumping) //only run when jump has been initiated by space or A { rect.Y = centreY - (int)(Math.Sin(angle) * range); //move player up to a maximum of rang

这是我当前的单次跳转代码,用户的输入将跳转设置为true,单次跳转没有错误,但是我无法为我的游戏生成第二次空中跳转。我必须在没有团结的情况下为学校做这件事,所以它只是在使用矩形

if (jumping) //only run when jump has been initiated by space or A
{
    rect.Y = centreY - (int)(Math.Sin(angle) * range); //move player up to a maximum of range's value

    angle += speedY; //gradually reduce player's y by reducing angle's value

    newCentreY = rect.Y;

    if (angle > Math.PI) //reset player to not jumping when angle is greater than 3.14
    {
        angle = 0;
        jumping = false;
    }
}
以下是跳转的输入处理程序:

if (userControl.Buttons.A == ButtonState.Pressed || keystate.IsKeyDown(Keys.Space)) //jump when A or space is pressed 
{ 
    jumping = true; 
} 
Jump(userControl, keystate); //jump method

我想你应该把你的
角度
设置为
0
才能继续跳下去

if (doubleJumping)
{
    angle = 0;
    doubleJumping = false;
}
if (jumping) //only run when jump has been initiated by space or A
{
    rect.Y = centreY - (int)(Math.Sin(angle) * range); //move player up to a maximum of range's value

    angle += speedY; //gradually reduce player's y by reducing angle's value

    newCentreY = rect.Y;

    if (angle > Math.PI) //reset player to not jumping when angle is greater than 3.14
    {
        angle = 0;
        jumping = false;
    }
 }

这是一种有趣的基于圆的跳跃方式,我喜欢。不过,我不确定用这种方法进行双跳有多可行。介意发布跳转的输入处理代码吗?我使用这个:if(userControl.Buttons.A==ButtonState.Pressed | | keystate.IsKeyDown(Keys.Space))//当按下或空格时跳转{jumping=true;}跳转(userControl,keystate)//跳转方法将
doubleJumping
设置为true的行应该在哪里?@Steven您应该检查是否再次按下跳转按钮,并将变量设置为
true