出于某种原因,每当他们渲染游戏时,每个人都会在他们的画布中将BufferStrategy设置为BufferStrategy。
BufferStrategy bs;
Graphics2D g;
private void render() {
bs = window.getCanvas().getBufferStrategy();
if (bs == null) {
window.getCanvas().createBufferStrategy(3);
return;
}
g = (Graphics2D) bs.getDrawGraphics();
bs.show();
g.dispose();
}
// When thread starts
public void run() {
while (running) {
//Game loop stuff here.
render();
}
}
你可以只设置一次而不是每次游戏重新渲染吗?