public void keyReleased(KeyEvent e){
int key = e.getKeyCode();
for(GameObject tempObject : handler.object){
if(tempObject.getID() == ObjectID.Player){
if(key == KeyEvent.VK_D){ tempObject.setVelX(0); }
if(key == KeyEvent.VK_A){ tempObject.setVelX(0); }
if(key == KeyEvent.VK_S){ tempObject.setVelY(0); }
if(key == KeyEvent.VK_W){ tempObject.setVelY(0); }
}
}
if(Game.getChat().isWorking()){
Game.getChat().passText(e.getKeyChar(e.getKey));
//.replaceAll("Space", " ").replaceAll("Period", ".").replaceAll("Backspace","").replaceAll("Shift","Shift").replaceAll("Slash","/").replaceAll("comma",",")
}
}
}
此代码基本上检查用户何时在我的游戏的聊天框中键入内容时释放密钥。然后它将它传递给一个方法,该方法基本上将要在游戏中呈现的文本设置为该方法。这真的无所谓,问题是:
正如你所看到的那样,那些烦人的盒子只有在我释放轮班时才会出现。
更多代码: KeyInput: http://pastebin.com/BM8yZ1i6 游戏类: http://pastebin.com/vViQ23pS 静态聊天: http :(斜线斜杠)pastebin(点)com / CgQE7SgN ChatManager: http :(斜线斜杠)pastebin(dot)com / yVM5rdUs
其他信息: 当我输出正在键入的文本时,框不是框,而是问号。