こんにちはハングマンゲームで作業していて、ほぼ終了しました。私の最後の問題は、仮想キーボードを1回だけクリック可能にすることです。私は後にループを破るかどうかは、文字をtrueまたはfalseをチェックし、それが動作しますが、単語が同じ文字の場合でも、それは1つの文字を返します。またはループを開いたままにして、マウスがクリックした回数に応じて4〜5回の試行を返します。私はInputlistnerだけワンクリックを登録することができます?? ..ここでは画像とそのリストの後、ここに入力リスナーで1回だけ画像をクリック
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;
}
});
と私のplaystateでcallメソッドです...私はループの後に虚偽のブール値を返すようにしようとしましたしかし、まだそれがループを終了する前に、あまりにも多くのクリックを登録する...問題を解決するために
if (tries < 100) {
if (keyboard.apressed && abpressed == true) {
for (int i = 0; i < randomWordtoGuess.length; i++) {
if (a == randomWordtoGuess[i]) {
playerGuess[i] = a;
currentWord = new String(playerGuess);
keyboard.a.setColor(0, 1, 0, 1);
abpressed = false;
}
if (a != randomWordtoGuess[i]) {
keyboard.a.setColor(1, 0, 0, 1);
tries++;
System.out.print(tries);
abpressed = false;
}
else{
}
// if i place a break; here it solves the problem
// but doesnt return more than one letter in the word..
// for example Concrete it will only show first C.
}
}
}
別の方法は、単にint型に1を追加することです++ではなく試行「しようと」..しかし、私それはできないと思う?
doesntの仕事:(..しかし、私はウルは、それがダウンしてアプリを遅らせ..もやろうとか理解 – Joe