Hi,
I am trying to use these options to switch from the Menu to Options, however, on the first time I press it, it flicks to options and back again really quick, but after that it works fine?
private void select() {
if(currentChoice == 0) {
Game.state = State.RAND;
}
else if(currentChoice == 1) {
Game.state = State.OPTIONS;
}
else if(currentChoice == 2) {
Display.destroy();
System.exit(0);
AL.destroy();
}
}
private boolean wasDown = false;
private boolean wasUp = false;
private boolean wasEnter = false;
public void handleInput() {
//checks if the key is down and executes once
boolean up = Keyboard.isKeyDown(Keyboard.KEY_UP);
if (!wasUp && up) {
if(currentChoice > 0) {
currentChoice--;
}
}
wasUp = up;
//checks if the key is down and executes once
boolean down = Keyboard.isKeyDown(Keyboard.KEY_DOWN);
if (!wasDown && down) {
if(currentChoice < options.length - 1) {
currentChoice++;
}
}
wasDown = down;
boolean enter = Keyboard.isKeyDown(Keyboard.KEY_RETURN);
if (!wasEnter && enter) {
select();
}
wasEnter = enter;
}
Any ideas why this might be happening?
Thanks,
- Dan