コード例 #1
0
 private void Form1_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right || e.KeyCode == Keys.Down || e.KeyCode == Keys.Up)
     {
         mainPlayer.Image = Properties.Resources.cowboy;
         if (e.KeyCode == Keys.Left)
         {
             LeftMoveTimer.Stop();
         }
         if (e.KeyCode == Keys.Right)
         {
             RightMoveTimer.Stop();
         }
         if (e.KeyCode == Keys.Up)
         {
             UpMoveTimer.Stop();
         }
         if (e.KeyCode == Keys.Down)
         {
             DownMoveTimer.Stop();
         }
     }
     if (e.KeyCode == Keys.Space)
     {
         ShootingTimer.Stop();
     }
 }
コード例 #2
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right || e.KeyCode == Keys.Down || e.KeyCode == Keys.Up)
     {
         mainPlayer.Image = Properties.Resources.cowboy_run;
         if (e.KeyCode == Keys.Left)
         {
             LeftMoveTimer.Start();
         }
         if (e.KeyCode == Keys.Right)
         {
             RightMoveTimer.Start();
         }
         if (e.KeyCode == Keys.Up)
         {
             UpMoveTimer.Start();
         }
         if (e.KeyCode == Keys.Down)
         {
             DownMoveTimer.Start();
         }
     }
     if (e.KeyCode == Keys.Space)
     {
         ShootingTimer.Start();
     }
     if (e.KeyCode == Keys.Escape)
     {
         Process.GetCurrentProcess().Kill();
     }
 }