I am trying to make a keyboard and everything works fine. I just want to break the loop between clicks to stop repetitiveness. I don't want to use a Boolean because user can enter same character more than once. This is the image listener
a = new Image(new Texture("Sprites/Keyboard/a.png"));
a.addListener(new InputListener(){
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
apressed = true;
return true;
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
apressed= false;
}
});
And this is what i have in my update inside the activity or state.
if (keyboard.apressed) {
builder.append('A');
currentWord = builder.toString();
//break; here doesn't work. says its outside the loop.
}
So in theory this is what i want but can't use because im guessing its to much work for every char?
if (keyboard.apressed) {
builder.append('A');
currentWord = builder.toString();
try {
TimeUnit.MILLISECONDS.sleep(400);
} catch (Exception e) {
System.out.println("error");
}
}
any ideas? thanks in advance.
Aucun commentaire:
Enregistrer un commentaire