mirror of
https://github.com/photonstorm/phaser
synced 2024-11-21 20:23:19 +00:00
Updated rounding to use Math.floor + 0.5
This commit is contained in:
parent
45db4b91e7
commit
a3470a08e5
2 changed files with 19 additions and 19 deletions
|
@ -555,8 +555,8 @@ var Camera = new Class({
|
|||
|
||||
if (this.roundPixels)
|
||||
{
|
||||
sx = Math.floor(sx);
|
||||
sy = Math.floor(sy);
|
||||
sx = Math.floor(sx + 0.5);
|
||||
sy = Math.floor(sy + 0.5);
|
||||
}
|
||||
|
||||
if (this.useBounds)
|
||||
|
@ -569,22 +569,22 @@ var Camera = new Class({
|
|||
this.scrollX = sx;
|
||||
this.scrollY = sy;
|
||||
|
||||
var midX = Math.floor(sx + halfWidth);
|
||||
var midY = Math.floor(sy + halfHeight);
|
||||
var midX = Math.floor((sx + halfWidth) + 0.5);
|
||||
var midY = Math.floor((sy + halfHeight) + 0.5);
|
||||
|
||||
// The center of the camera, in world space, so taking zoom into account
|
||||
// Basically the pixel value of what it's looking at in the middle of the cam
|
||||
this.midPoint.set(midX, midY);
|
||||
|
||||
var displayWidth = Math.floor(width / zoomX);
|
||||
var displayHeight = Math.floor(height / zoomY);
|
||||
var displayWidth = Math.floor((width / zoomX) + 0.5);
|
||||
var displayHeight = Math.floor((height / zoomY) + 0.5);
|
||||
|
||||
var vwx = Math.floor(midX - (displayWidth / 2));
|
||||
var vwy = Math.floor(midY - (displayHeight / 2));
|
||||
var vwx = Math.floor((midX - (displayWidth / 2)) + 0.5);
|
||||
var vwy = Math.floor((midY - (displayHeight / 2)) + 0.5);
|
||||
|
||||
this.worldView.setTo(vwx, vwy, displayWidth, displayHeight);
|
||||
|
||||
matrix.applyITRS(Math.floor(this.x + originX), Math.floor(this.y + originY), this.rotation, zoomX, zoomY);
|
||||
matrix.applyITRS(Math.floor(this.x + originX + 0.5), Math.floor(this.y + originY + 0.5), this.rotation, zoomX, zoomY);
|
||||
|
||||
matrix.translate(-originX, -originY);
|
||||
|
||||
|
|
|
@ -938,17 +938,17 @@ var TransformMatrix = new Class({
|
|||
|
||||
if (roundPixels)
|
||||
{
|
||||
quad[0] = Math.floor(x * a + y * c + e);
|
||||
quad[1] = Math.floor(x * b + y * d + f);
|
||||
quad[0] = Math.floor((x * a + y * c + e) + 0.5);
|
||||
quad[1] = Math.floor((x * b + y * d + f) + 0.5);
|
||||
|
||||
quad[2] = Math.floor(x * a + yh * c + e);
|
||||
quad[3] = Math.floor(x * b + yh * d + f);
|
||||
quad[2] = Math.floor((x * a + yh * c + e) + 0.5);
|
||||
quad[3] = Math.floor((x * b + yh * d + f) + 0.5);
|
||||
|
||||
quad[4] = Math.floor(xw * a + yh * c + e);
|
||||
quad[5] = Math.floor(xw * b + yh * d + f);
|
||||
quad[4] = Math.floor((xw * a + yh * c + e) + 0.5);
|
||||
quad[5] = Math.floor((xw * b + yh * d + f) + 0.5);
|
||||
|
||||
quad[6] = Math.floor(xw * a + y * c + e);
|
||||
quad[7] = Math.floor(xw * b + y * d + f);
|
||||
quad[6] = Math.floor((xw * a + y * c + e) + 0.5);
|
||||
quad[7] = Math.floor((xw * b + y * d + f) + 0.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1022,7 +1022,7 @@ var TransformMatrix = new Class({
|
|||
|
||||
if (round)
|
||||
{
|
||||
v = Math.round(v);
|
||||
v = Math.floor(v + 0.5);
|
||||
}
|
||||
|
||||
return v;
|
||||
|
@ -1048,7 +1048,7 @@ var TransformMatrix = new Class({
|
|||
|
||||
if (round)
|
||||
{
|
||||
v = Math.round(v);
|
||||
v = Math.floor(v + 0.5);
|
||||
}
|
||||
|
||||
return v;
|
||||
|
|
Loading…
Reference in a new issue