Switch statement not going through all cases

You must add a “break;” statement in each case!

Edit your code to this:

switch(code) {
        case KeyEvent.VK_DOWN:
            y+=15;
            break;
        case KeyEvent.VK_UP:
            y-=15;
            break;
        case KeyEvent.VK_RIGHT:
            x+=15;
            break;
        case KeyEvent.VK_LEFT:
            x-=15;
            break;
    }

Browse More Popular Posts

Leave a Comment