Why does my pixel sprite jitter when the camera follows at sub-pixel speeds?

Quelly
Sun, 26 Apr 2026 06:14:15 +0000

Wait, check your ctx. translate(. . . ) state too — I’ve seen “mystery jitter” come from a fractional translate sticking around between frames because nobody reset the transform. Even if your cx/cy are integers, a leftover 0. 5px translate means everything lands between pixels and shimmers. If you’re doing any camera translate, make sure you reset the transform at the start of every frame before drawing:

// start of frame
ctx.setTransform(1, 0, 0, 1, 0, 0); // or ctx.resetTransform() where supported

// then apply camera
ctx.translate(-cameraX, -cameraY);

// draw world...