二楼贴代码:
private void fGame_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.W:
case Keys.NumPad8:
case Keys.Up:
snack.Diversion = 1;
break;
case Keys.S:
case Keys.NumPad2:
case Keys.Down:
snack.Diversion = 2;
break;
case Keys.A:
case Keys.NumPad4:
case Keys.Left:
snack.Diversion = 3;
break;
case Keys.D:
case Keys.NumPad6:
case Keys.Right:
snack.Diversion = 4;
break;
case Keys.Space:
if (timer1.Enabled)
timer1.Stop();
else
timer1.Start();
break;
default:
return;
}
}
private void fGame_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.W:
case Keys.NumPad8:
case Keys.Up:
snack.Diversion = 1;
break;
case Keys.S:
case Keys.NumPad2:
case Keys.Down:
snack.Diversion = 2;
break;
case Keys.A:
case Keys.NumPad4:
case Keys.Left:
snack.Diversion = 3;
break;
case Keys.D:
case Keys.NumPad6:
case Keys.Right:
snack.Diversion = 4;
break;
case Keys.Space:
if (timer1.Enabled)
timer1.Stop();
else
timer1.Start();
break;
default:
return;
}
}