From 1df4661487904deb92246ba31865180f79eab6ad Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 8 Oct 2020 11:07:21 +0100 Subject: [PATCH] Camera.roundPixels now rounds worldView matrix --- src/cameras/2d/Camera.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/cameras/2d/Camera.js b/src/cameras/2d/Camera.js index e62887f24..29cae98d9 100644 --- a/src/cameras/2d/Camera.js +++ b/src/cameras/2d/Camera.js @@ -816,6 +816,9 @@ var Camera = new Class({ { originX = Math.round(originX); originY = Math.round(originY); + + sx = Math.round(sx); + sy = Math.round(sy); } // Values are in pixels and not impacted by zooming the Camera @@ -832,12 +835,16 @@ var Camera = new Class({ var displayWidth = width / zoom; var displayHeight = height / zoom; - this.worldView.setTo( - midX - (displayWidth / 2), - midY - (displayHeight / 2), - displayWidth, - displayHeight - ); + var vwx = midX - (displayWidth / 2); + var vwy = midY - (displayHeight / 2); + + if (this.roundPixels) + { + vwx = Math.round(vwx); + vwy = Math.round(vwy); + } + + this.worldView.setTo(vwx, vwy, displayWidth, displayHeight); matrix.applyITRS(this.x + originX, this.y + originY, this.rotation, zoom, zoom); matrix.translate(-originX, -originY);