我有3个图片盒(boardTop,boardCenter,boardBottom)。按下向上箭头或向下箭头键时,我希望这三个图片框一起移动。
private void PingPong_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Up)
{
boardUp.Location = new Point(boardUp.Location.X, boardUp.Location.Y - 1);
boardLeft.Location = new Point(boardUp.Location.X, boardUp.Location.Y - 1);
boardDown.Location = new Point(boardUp.Location.X, boardUp.Location.Y - 1);
Kup = true;
}
else if (e.KeyCode == Keys.Down)
{
boardUp.Location = new Point(boardUp.Location.X, boardUp.Location.Y + 1);
boardLeft.Location = new Point(boardUp.Location.X, boardUp.Location.Y + 1);
boardDown.Location = new Point(boardUp.Location.X, boardUp.Location.Y + 1);
Kdown = true;
}
}