자바 게임을 만들고 사용자가 일부 키를 누르면 스프라이트가 그 방향으로 이동하고 스프라이트가 일치하도록 변경됩니다 사용자가 입력하고있는 방향 이 웹 사이트에 현재 게임, 머리를보고 싶다면 :스프라이트 이동하기, 마지막으로 이동 한 위치에 스프라이트가 있어야합니다.
int x_posI = (int) x_pos;
int y_posI = (int) y_pos;
if (downPressed && leftPressed) {
g.drawImage(hero225, x_posI, y_posI, this);
spr270 = false;
} else if (downPressed && rightPressed) {
spr270 = false;
g.drawImage(hero135, x_posI, y_posI, this);
} else if (upPressed && rightPressed) {
spr270 = false;
g.drawImage(hero45, x_posI, y_posI, this);
} else if (upPressed && leftPressed) {
g.drawImage(hero315, x_posI, y_posI, this);
spr270 = false;
} else if (leftPressed == true) {
g.drawImage(hero270, x_posI, y_posI, this);
spr270 = true;
} else if (rightPressed == true) {
g.drawImage(hero90, x_posI, y_posI, this);
spr270 = false;
} else if (upPressed == true) {
g.drawImage(hero, x_posI, y_posI, this);
spr270 = false;
} else if (downPressed == true) {
g.drawImage(hero180, x_posI, y_posI, this);
spr270 = false;
}
else{
g.drawImage(hero, x_posI, y_posI, this);
}
if(spr270) {
g.drawImage(hero270, x_posI, y_posI, this);
}
나는 왼쪽을 누르면, 이런 것입니다 : 여기 http://thetutspace.org/acropolis/beta/
을 내가 사용하는 코드입니다 i.stack .imgur은 [점] 내가 가게되면, 이것이 COM/owT3z.png
내가 무슨 : i.stack.imgur.com/2Wrjr[dot]png
어떻게 그래서 그것을 만들 수 있습니다 캐릭터가 왼쪽을 향하고 있습니까?
: 왜'경우 (foo는 == true)를 {'있나요? 왜''if (foo) {'? –
나는 그것을 생각하지 않았다. 고마워. – Derek
이제 당신의 현재 문제에 관해서, 나는 당신의 문제가 무엇인지 혼란스러워합니다. 문제의 세부 사항을 설명하는 원본 게시물에 대한 설명의 단락이나 두 개 또는 해결하려고 할 때 작동하지 않는 부분이 필요할 수 있습니다. –