每次游戏提出好主意时都设置BufferStrategy吗?

时间:2018-04-25 04:22:52

标签: java graphics render bufferstrategy

出于某种原因,每当他们渲染游戏时,每个人都会在他们的画布中将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();
      }
    }

你可以只设置一次而不是每次游戏重新渲染吗?

0 个答案:

没有答案