我不想问,但我真的找不到答案。 我是C#的新手(来自C ++),我想编写一个有点愚蠢的游戏。 到目前为止一切都有效。但现在我想用wasd键移动一个对象。 问题是,它移动了,但它只是迈出了一小步,等待片刻,然后像我想要的那样移动。比如当你写东西时拿着钥匙。 这是代码
private void Form1_KeyDown(object sender, KeyEventArgs e) // Steuerung
{
collision.PlayerCollisionAgainstWall(this, player);
if (e.KeyCode == Keys.Up) player.pos_y += player.r_speed_y;
if (e.KeyCode == Keys.Down) player.pos_y += player.speed_y;
if (e.KeyCode == Keys.Left) player.pos_x += player.r_speed_x;
if (e.KeyCode == Keys.Right) player.pos_x += player.speed_x;
}
r_speed是-10 速度是10 但我认为那不重要
我也尝试过使用KeyPress事件。
编辑:我刚刚制作了一个正常的Windows表单应用程序