* Camera.preRender will now apply Math.floor instead of Math.round to the values, keeping it consistent with the Renderer when following a sprite.

This commit is contained in:
Richard Davey 2022-09-29 22:10:29 +01:00
parent e2c9838896
commit f136a796fa

View file

@ -517,12 +517,25 @@ var Camera = new Class({
var emitFollowEvent = false;
if (this.roundPixels)
{
originX = Math.floor(originX);
originY = Math.floor(originY);
}
if (follow && !this.panEffect.isRunning)
{
var fx = (follow.x - this.followOffset.x);
var fy = (follow.y - this.followOffset.y);
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)
@ -560,11 +573,8 @@ var Camera = new Class({
if (this.roundPixels)
{
originX = Math.round(originX);
originY = Math.round(originY);
sx = Math.round(sx);
sy = Math.round(sy);
sx = Math.floor(sx);
sy = Math.floor(sy);
}
// Values are in pixels and not impacted by zooming the Camera
@ -586,13 +596,13 @@ var Camera = new Class({
if (this.roundPixels)
{
vwx = Math.round(vwx);
vwy = Math.round(vwy);
vwx = Math.floor(vwx);
vwy = Math.floor(vwy);
}
this.worldView.setTo(vwx, vwy, displayWidth, displayHeight);
matrix.applyITRS(this.x + originX, this.y + originY, this.rotation, zoom, zoom);
matrix.applyITRS(Math.floor(this.x + originX), Math.floor(this.y + originY), this.rotation, zoom, zoom);
matrix.translate(-originX, -originY);
this.shakeEffect.preRender();