Advertisement

Java2D Movement Stutter on windows mode

Started by August 14, 2020 11:09 AM
0 comments, last by ultorian 4 years, 3 months ago

I’ve been getting movement stutter ( moving the camera) No screen tearing, just choppy movement, almost as if it wobbles, yet the fps remains to be a solid 60.

This only occurs in windows mode, and it appears to be random (smooth more often than not).
I print to canvas using a BufferStrategy(2).
I have tried various gameloop timers. None of them fix the issue.
Every time I try to fix this. The “wobbles” go away but then come back several runs later.
Curiously, when I activate something that makes an impact on fps, It seems to actually fix the stutter.
I’ve commented my gameloop out, and still get these stutters while moving a sprite across the canvas.

Trying this on another machine (fresh win10) gave me constant interval stutter. And only in Window mode.

Ive noticed the same stutter in a fresh LibGDX project. (moving the badlogics logo x+=8)
I’m using JDK 8

  public void run() {
        createBufferStrategy(2);
        long inititalTime = System.nanoTime();
        final double ns = 1000000000 / 60.0;
        double delta = 0;

        while (running) {
            long now = System.nanoTime();
            delta += (now - inititalTime) / ns;
            inititalTime = now;
            if (delta >= 1) {

                update();
                delta--;
            }
        }
    }

Thank you.

This topic is closed to new replies.

Advertisement