public void paint (Graphics g)
{
bufferGraphics.setColor (Color.black);
bufferGraphics.clearRect (0, 0, dim.width, dim.width);
while (input != KeyEvent.VK_SPACE)
{
bufferGraphics.fillRect (0, 0, dim.width, dim.height);
}
bufferGraphics.drawImage (track, 0, 0, dim.width, dim.height, this);
bufferGraphics.setFont (new Font ("Calibri", Font.PLAIN, 25));
bufferGraphics.drawString ("Level: " + level, 30, 30);
bufferGraphics.drawImage (car, 620, myCarY, 70, 120, this);
bufferGraphics.drawImage (opponent, 415, oppCarY, 70, 120, this);
move();
這是現在的代碼。執行時,我會得到一個甚至無法關閉的凍結空白窗口。重要聽衆不能使用
您是否打算將「false」的值分配給「run」? – Glenn
是的,我是一個初學者,對不起 –
只需嘗試:while(!run){...}語句「run = false」將值「false」賦值給「run」。 – Glenn