0

誰かが私がこのコードで間違っていたことを教えてくれますか...キーボードの左矢印が押されるたびにスプライトを移動しようとしています。しかし、コードを実行すると、ゲーム ウィンドウが開き、prtty がすぐにオフになります

public class Sprite
{
    private Texture2D texture;
    private Vector2 position;

    public Sprite(Texture2D texture, Vector2 position)
    {
        // TODO: Complete member initialization
        this.texture = texture;
        this.position = position;
    }

    public void Draw(SpriteBatch spriteBatch)
    {
        spriteBatch.Draw(texture, position, Color.White);
    }

    void Update(KeyboardState keyboardstate, GameTime gameTime)
    {
        // throw new NotImplementedException();
        if (keyboardstate.IsKeyDown(Keys.Left))
        {
            Velocity = new Vector2(-1, 0);
            position+= ((Velocity) *(float) gameTime.ElapsedGameTime.TotalSeconds);
        }
    }

   public Vector2 Velocity { get; set; }

}
4

0 に答える 0