내 문제는, 나는 괴물을 치고 몬스터를 치고 죽었는지 결정하기 위해 if 문을 사용할 때 wierd 사운드 문제를 일으킨다. . 고전적인 마리오 논리를 사용하여, 내가 위에 얹어 놓으면 나는 살고, 그렇지 않다면 나는 죽는다. 두 개의 다른 if 문을 추가 할 때까지는 문제가 없었습니다. 더 많은 정보가 필요하시면 알려주세요. 내 문제는 if 문을 사용하는 방법이라고 생각합니다.android 만약 else 문을
if (hero.position.y < ghost.position.y) {
if (OverlapTester.overlapRectangles(ghost.bounds, hero.bounds))
hero.hitGhost();
listener.hit();
}
주 최초의 if
조건이 만족 될 경우, listener.hit()
항상 라는 것을 의미 내부if
문에 대한 괄호의 부족 : 나는 의심
private void checkGhostCollisions() {
int len = ghosts.size();
for (int i = 0; i < len; i++) {
Ghost ghost = ghosts.get(i);
if (hero.position.y < ghost.position.y) {
if (OverlapTester.overlapRectangles(ghost.bounds, hero.bounds))
hero.hitGhost();
listener.hit();
} else {
if(hero.position.y > ghost.position.y)
if (OverlapTester.overlapRectangles(hero.bounds, ghost.bounds)) {
hero.hitGhostJump();
listener.jump();
break;
}
}
}
}
hero.position == ghost.position이란 무엇입니까? – Blundell