私のゲームでは、異なるネットサイズの隕石が降っています。私は、大きな隕石に触れると、それが(アレイから)削除され、小さな隕石オブジェクトが、大きなものが取り除かれたのと同じ場所に置かれるように、作ろうとしました。画面に触れたときのオブジェクトの産出に関する問題[LibGDX]
私が持っている問題は、大きな隕石に触れると、それが取り除かれ、最小のものになり完全に消えてしまうまで、他のすべての隕石の種類を通過するということです。私は明らかにそれを望んでいません。この問題の解決方法も不明です。ここで
は、入力を処理するコードです:
private void handleInput() {
Iterator<FallingItem> iter = items.meteorites.iterator();
while (iter.hasNext()) {
FallingItem item = iter.next();
if (Gdx.input.justTouched()) {
gameCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));
if (item.getClass() == SmallMeteorite.class && item.getBounds().contains(touchPoint.x, touchPoint.y)) {
meteoriteDestroyed.play(0.5f); //play sound
iter.remove(); //removes item from array when it's no longer needed
item.dispose(); //dispose meteorite texture to clear up memory
score += 20; //add to score
} else if (item.getClass() == MediumMeteorite.class && item.getBounds().contains(touchPoint.x, touchPoint.y)) {
meteoriteDestroyed.play(0.5f);
iter.remove();
item.dispose();
score += 10;
items.meteorites.add(new SmallMeteorite(item.getBounds().getX(), item.getBounds().getY()));
} else if (item.getClass() == LargeMeteorite.class && item.getBounds().contains(touchPoint.x, touchPoint.y)) {
meteoriteDestroyed.play(0.5f);
iter.remove();
item.dispose();
score += 10;
items.meteorites.add(new MediumMeteorite(item.getBounds().getX(), item.getBounds().getY()));
}
}
}
}
申し訳ありませんが、答えに感謝します。あなたは私が調べるいくつかの良い点を作った。 –