Hi,guys:
I’m testing analogListener and actionListener on mouse axis.
Problem is :
When applied an actionListener on mouse axis, once you move the mouse you always got a TRUE for ever. any explanation?
Could you post the code and show how you’re determining it’s always true?
1 Like
Couldn’t post all, these are relative parts:
private ActionListener actionListenerc = new ActionListener() { //ActionListener is a listener INTERFACE!
@Override
public void onAction(String name, boolean keyPressed, float tpf) {
keys[Integer.parseInt(name)] =keyPressed;
if (name.equals("16") && !keyPressed ) isplaying= !isplaying;
}
};
2
private void initKeys(){
// Add the names to the action listener
inputManager.addListener(actionListenerc,new String[]{"16","37","38","39",
"40","1","19", "4","23","17","5","18","6","26","24","41","12","201","202",
"203","45","46","47","48","204","205","206","207","208","209"});
};
3
inputManager.addMapping("204", new MouseAxisTrigger(MouseInput.AXIS_X, true));
inputManager.addMapping("205", new MouseAxisTrigger(MouseInput.AXIS_X, false));
inputManager.addMapping("206", new MouseAxisTrigger(MouseInput.AXIS_Y, true));
inputManager.addMapping("207", new MouseAxisTrigger(MouseInput.AXIS_Y, false));
inputManager.addMapping("208", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true));//向后滚
inputManager.addMapping("209", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));//向前滚
4
keys =new Boolean[256];
for(int a = 0; a<=255;a++ ) {
keys[a]=false;
}
Hm, can you make a small test case.
I would look into this, if you posted a TestCase.java
with a main(String[] args)
.
It’s easy to copy-paste it and run it then.
It’s not easy with only the four pieces of code.