vendredi 8 septembre 2017

Why am i not able to move the picture box if i have a checkbox in my form

I've started creating a game and i ran into a problem: I cant place check boxes because it somehow stops the "players" movement. I'm moving my "player" using arrow keys.

    private void Form1_KeyDown(object sender, KeyEventArgs e)
    {
        if(e.KeyCode == Keys.Left)
        {
            left = true;
        }

        if (e.KeyCode == Keys.Right)
        {
            right = true;
        }

        if (e.KeyCode == Keys.Up)
        {
            up = true;
        }

        if (e.KeyCode == Keys.Down)
        {
            down = true;
        }
    }

And to reset the controls:

    private void Form1_KeyUp(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Left)
        {
            left = false;
        }

        if (e.KeyCode == Keys.Right)
        {
            right = false;
        }

        if (e.KeyCode == Keys.Up)
        {
            up = false;
        }

        if (e.KeyCode == Keys.Down)
        {
            down = false;
        }
    }

So how can i place a check box and still control my "player"?

The game working without the check box: http://ift.tt/2vKS0HM

Then i put the check box and not being able to move the "player": http://ift.tt/2gQL21z




Aucun commentaire:

Enregistrer un commentaire