Hello guys, I have a weird behaviour on a keypress and was wondering if this is normal.
I overrided the function keypress in a BasicGameState class like this :
Code:
public void keyPressed(int key, char c) {
System.out.println("here"+key+"---"+c);
}
It goes ok, when i press right for example i can see on the console : here205---
When i put some code like this :
Code:
public void keyPressed(int key, char c) {
System.out.println("here"+key+"---"+c);
if (index == 0){
index = mylist.size()-1;
}
else{
index--;
}
if (mylist.size() > 0){
mycomponent = new MyComponent(thisgc,null,300,100);
}
else{
mycomponent = null;
}
}
The code not even testing on the input or anything event related, the function goes berserk and outputs indefinetly :here205---
When i consume the event : thisgc.getInput().consumeEvent();
It's working as it should.
I don't understand why i have to use this workaround, and why the event is fired again and again (i only press the key once)