Well I presume it's the act of closing down the applet, as in closing the window. It's only an (un?)educated guess as everything is fine when it's running!
I'm just checking if there is anything else I should be doing. Below is my game loop code, which is pretty similar to tutorials and other posts on this board. I've never seen any examples of putting the drawing code in a try block and was wondering if there was a reason for it and if the IllegalStateException is common when exiting. The exception might not even be an issue since I'm closing it down anyway, but I've only been playing with BufferStrategy for the last week so I'm very green!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| while(t == gameloop) { threadDelay = GAME_FRAME_DELAY - (System.currentTimeMillis() - lastloop); try { Thread.sleep(threadDelay); } catch (InterruptedException e) { }
gameUpdate();
do{ do{ Graphics2D g = (Graphics2D)strategy.getDrawGraphics();
render(g);
g.dispose(); }while(strategy.contentsRestored());
strategy.show(); Toolkit.getDefaultToolkit().sync(); } while(strategy.contentsLost()); lastloop = System.currentTimeMillis(); } } |