저는 일부 Java 프로그래밍을 가지고 놀고 있기 때문에 키를 누를 때 화면을 돌아 다니며 그림을 원했습니다. 어떻게 지금까지 내가 말하는 메시지 얻을 "목 6월 14일 동부 서머 타임 13시 14분 23초 2012 정보 : 사용할 수없는 컨트롤러"이것은 내가 그런 식으로 그것을 실행하는 데 있다면 지금 내가이 페이지isKeyDown이 Java에서 작동하지 않습니다.
public class Menu extends BasicGameState
{
Image sun;
int sunX = 200;
int sunY = 200;
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException
{
sun = new Image("res/sun.png");
}
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException
{
g.drawImage(sun, sunX, sunY);
}
public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException
{
Input input = gc.getInput();
if(input.isKeyDown(Input.KEY_UP)); {sunY -= 1;}
if(input.isKeyDown(Input.KEY_DOWN)); {sunY += 1;}
if(input.isKeyDown(Input.KEY_LEFT)); {sunX -= 1;}
if(input.isKeyDown(Input.KEY_RIGHT)); {sunX += 1;}
}
}
에 대해 가지고있는 코드입니다 물체는 같은 지점에서 말할 것입니다. 그러나 만약 if 문 중 하나만 가지고 있다면 객체가 int를 움직여서 키를 누를 것입니다. 그래서 앱이 시작되자 마자 if(input.isKeyDown(Input.KEY_UP)); {sunY -= 1;}
이 뜨면 화면에서 태양이 움직입니다. 이 일이 내가 잘못 한 것은 무엇입니까? 이 if(input.isKeyDown(Input.KEY_UP)); {sunY -= 1;}
이로 변경
는이 [SSCCE] (http://sscce.org/)을 게시 할 수 있습니다. –