public void buttons(){ int c = WHEN_IN_FOCUSED_WINDOW; Action right = new AbstractAction() { public void actionPerformed(ActionEvent e) { player.setVX(2); } }; Action stop = new AbstractAction() { public void actionPerformed(ActionEvent e) { player.setVX(0); player.setVY(0); } }; Action up = new AbstractAction() { public void actionPerformed(ActionEvent e) { player.setVY(-2); } }; getInputMap(c).put(KeyStroke.getKeyStroke("D"), "pressed"); getActionMap().put("pressed", right); getInputMap(c).put(KeyStroke.getKeyStroke("released D"), "released"); getActionMap().put("released", stop); getInputMap(c).put(KeyStroke.getKeyStroke("W"), "pressed"); getActionMap().put("pressed", up); getInputMap(c).put(KeyStroke.getKeyStroke("released W"), "released"); getActionMap().put("released", stop); }
Why is that when I press W or D it goes up...
What is the problem?
D should go right