2012-04-28 17 views
0

http://pastebin.com/YTiNw7rXこの "パドルジャンプ"の不具合をコードで修正するにはどうすればよいですか?

あなたはすべての方法、画面の最上部までのパドルを押し、アウトコードをテストし、それを手放す場合は、パドルは、いくつかのピクセルを下にジャンプします。そして、私はこれを修正する方法を理解しているように見えることはできません。私はそれがテクスチャと関係があると思います。

編集:おかげ

答えて

1

これは何が起こるかです:

  1. あなたが鍵を握ります。

  2. 機能は、現在のYをチェックおよび/または調整します。

  3. この機能は、キーを押すと現在のYを更新します。

  4. 現在のYが画面に表示されます。

  5. キーを放します。

  6. 機能は、現在のYをチェックおよび/または調整します。

  7. 修正されたYが画面に表示され、前のYからのジャンプが発生します。

だから、あなたはありません、それの後に、あなたの現在のY前にチェックを更新することになるでしょう。

protected override void Update(GameTime gameTime) 
{ 
    // Allow the game to exit. 
    if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) 
     this.Exit(); 

    // Update the paddles according to the keyboard. 
    if (Keyboard.GetState().IsKeyDown(Keys.Up)) 
     PongPaddle1.Y -= paddleSpeed; 

    if (Keyboard.GetState().IsKeyDown(Keys.Down)) 
     PongPaddle1.Y += paddleSpeed; 

    // Update the paddles according to the safe bounds. 
    var safeTop = safeBounds.Top - 30; 
    var safeBottom = safeBounds.Bottom - 70; 

    PongPaddle1.Y = MathHelper.Clamp(PongPaddle1.Y, safeTop, safeBottom); 
    PongPaddle2.Y = MathHelper.Clamp(PongPaddle2.Y, safeTop, safeBottom); 

    // Allow the base to update. 
    base.Update(gameTime); 
} 
関連する問題