input keyboard werkt niet

Status
Niet open voor verdere reacties.

savant11

Gebruiker
Lid geworden
7 jan 2008
Berichten
153
Heb dit:

PHP:
private void Form1_KeyDown(Object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
                //Application.Exit();
                MessageBox.Show("Escape was pressed");
            if(gameOver)
                if (e.KeyCode == Keys.S)
                {
                    if (gameOver == true)
                    {
                        //ResetGame();
                        if (gameTimer.Enabled)
                            gameTimer.Stop();
                    }
                    return; 
                }
            if (e.KeyCode == Keys.Space)
                game.FireShot();
            if (keysPressed.Contains(e.KeyCode))
                keysPressed.Remove(e.KeyCode);
            keysPressed.Add(e.KeyCode);
        }//End method

Maar als ik dan escap druk gebeurt er niks??

THx for helping
 
Je zou beter XNA kunnen proberen, zoek het maar eens op. C# forms application is niet echt bedoelt voor games.
 
Van de volgende site:http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keydown.aspx

To handle keyboard events only at the form level and not enable other controls to receive keyboard events, set the KeyPressEventArgs.Handled property in your form's KeyPress event-handling method to true. Certain keys, such as the TAB, RETURN, ESC, and arrow keys are handled by controls automatically. To have these keys raise the KeyDown event, you must override the IsInputKey method in each control on your form. The code for the override of the IsInputKey would need to determine if one of the special keys is pressed and return a value of true. Instead of overriding the IsInputKey method, you can handle the PreviewKeyDown event and set the IsInputKey property to true. For a code example, see the PreviewKeyDown event.
 
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan