OK, I’m hoping I’ve done something stupid that will eat five minutes and a good chunk of ego. I’ve got an input manager with various forms of input (see code), including the spacebar, and an input listener. For some reason, only lifting the spacebar registers. Pressing the spacebar gets no result.
[java]
public void setUpKeys()
{
inputManager.addMapping(“Foreward”, new KeyTrigger(KeyInput.KEY_W));
inputManager.addMapping(“Left”, new KeyTrigger(KeyInput.KEY_A));
inputManager.addMapping(“Right”, new KeyTrigger(KeyInput.KEY_D));
inputManager.addMapping(“Back”, new KeyTrigger(KeyInput.KEY_S));
inputManager.addMapping(“Jump”, new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping(“Shoot”, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addMapping(“Remove”, new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
inputManager.addListener(keyboardActions, "Remove");
inputManager.addListener(keyboardActions, "Foreward");
inputManager.addListener(keyboardActions, "Left");
inputManager.addListener(keyboardActions, "Right");
inputManager.addListener(keyboardActions, "Back");
inputManager.addListener(keyboardActions, "Jump");
inputManager.addListener(keyboardActions, "Shoot");
}
private ActionListener keyboardActions = new ActionListener()
{
public void onAction(String name, boolean keyPressed, float tpf)
{
if(name.equals("Foreward"))
{
up = keyPressed;
}
if(name.equals("Left"))
{
left = keyPressed;
}
if(name.equals("Right"))
{
right = keyPressed;
}
if(name.equals("Back"))
{
down = keyPressed;
}
if(name.equals("Jump"))
{
player.jump();
System.out.println(keyPressed);
}
};
[/java]
Basically, my output goes like this:
false
false
false
false
if I hi the spacebar four times.
Any ideas?