Skip to content

Commit

Permalink
Camera.preRender will no longer round the origin, follow coordinate…
Browse files Browse the repository at this point in the history
…s or scrollX/Y coordinates. It will still round the World view.
  • Loading branch information
photonstorm committed Nov 7, 2023
1 parent df846bd commit 7590600
Showing 1 changed file with 3 additions and 26 deletions.
29 changes: 3 additions & 26 deletions src/cameras/2d/Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,25 +516,13 @@ var Camera = new Class({

var emitFollowEvent = false;

if (this.roundPixels)
{
originX = Math.floor(originX);
originY = Math.floor(originY);
}

if (follow && !this.panEffect.isRunning)
{
var lerp = this.lerp;

var fx = follow.x - this.followOffset.x;
var fy = follow.y - this.followOffset.y;

if (this.roundPixels)
{
fx = Math.floor(fx);
fy = Math.floor(fy);
}

if (deadzone)
{
if (fx < deadzone.x)
Expand Down Expand Up @@ -570,12 +558,6 @@ var Camera = new Class({
sy = this.clampY(sy);
}

if (this.roundPixels)
{
sx = Math.floor(sx);
sy = Math.floor(sy);
}

// Values are in pixels and not impacted by zooming the Camera
this.scrollX = sx;
this.scrollY = sy;
Expand All @@ -590,18 +572,13 @@ var Camera = new Class({
var displayWidth = width / zoom;
var displayHeight = height / zoom;

var vwx = midX - (displayWidth / 2);
var vwy = midY - (displayHeight / 2);

if (this.roundPixels)
{
vwx = Math.floor(vwx);
vwy = Math.floor(vwy);
}
var vwx = Math.floor(midX - (displayWidth / 2));
var vwy = Math.floor(midY - (displayHeight / 2));

this.worldView.setTo(vwx, vwy, displayWidth, displayHeight);

matrix.applyITRS(Math.floor(this.x + originX), Math.floor(this.y + originY), this.rotation, zoom, zoom);

matrix.translate(-originX, -originY);

this.shakeEffect.preRender();
Expand Down

0 comments on commit 7590600

Please sign in to comment.