Note that there are some explanatory texts on larger screens.

plurals
  1. POThe method toggleKey(int, boolean) is undefined for the type InputHandler
    text
    copied!<p>I was wandering if anyone could help, basically im following a tuorial on some input handling and the tutorial reguires me to create a new class and write this code.</p> <pre><code>package net.pinkeye.JavaGame; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.util.ArrayList; import java.util.List; public class InputHandler implements KeyListener{ public InputHandler(Game game) { game.addKeyListener(this); } public class Key { public boolean pressed = false; public boolean isPressed(){ return pressed; } public void toggle(boolean isPressed) { pressed = isPressed; } } public Key up = new Key(); public Key down = new Key(); public Key left = new Key(); public Key right = new Key(); public void keyPressed(KeyEvent e) { toggleKey(e.getKeyCode(),true); } public void keyReleased(KeyEvent e) { toggleKey(e.getKeyCode(),false); } public void keyTyped(KeyEvent e) { } public void toggle (int keyCode, boolean isPressed) { if(keyCode == KeyEvent.VK_W){ up.toggle(isPressed); } if(keyCode == KeyEvent.VK_S){ down.toggle(isPressed); } if(keyCode == KeyEvent.VK_A){ left.toggle(isPressed); } if(keyCode == KeyEvent.VK_D){ right.toggle(isPressed); } } } </code></pre> <p>however where it says</p> <pre><code> public void keyPressed(KeyEvent e) { toggleKey(e.getKeyCode(),true); } public void keyReleased(KeyEvent e) { toggleKey(e.getKeyCode(),false); } </code></pre> <p>eclipse tells me The method toggleKey(int, boolean) is undefined for the type InputHandler</p> <p>ive followed this tutorial word for wrd and checked multiple times but i can't find my mistake.</p> <p>Any help would be great</p> <p>Btw here is thwe tuorial if this helps: <a href="http://www.youtube.com/watch?v=Vv7G5GMOre8" rel="nofollow">http://www.youtube.com/watch?v=Vv7G5GMOre8</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload