我只是在玩一些java编程,所以当我按下某个键时,我想要一张图片在屏幕上移动。我怎么会收到一条消息,说“Thu Jun 14 13:14:23 EDT 2012信息:控制器不可用”这是我对这个页面的代码
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语句对象将会按照方向移动,并且按下某个键,所以如果我在应用程序中有了if(input.isKeyDown(Input.KEY_UP)); {sunY -= 1;}开始太阳升起和离开屏幕。我为此发生了什么错误?