これは何が起こるかです:
あなたが鍵を握ります。
機能は、現在のY
をチェックおよび/または調整します。
この機能は、キーを押すと現在のY
を更新します。
現在のY
が画面に表示されます。
キーを放します。
機能は、現在のY
をチェックおよび/または調整します。
修正された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);
}