mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 07:01:20 +00:00
Added Camera.roundPixels support, plus argument to 'follow' and setRoundPixels() method.
This commit is contained in:
parent
812197744f
commit
8b630c66b3
2 changed files with 27 additions and 7 deletions
|
@ -8,7 +8,9 @@ var Camera = function (x, y, width, height)
|
|||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
this.roundPixels = false;
|
||||
this.useBounds = false;
|
||||
|
||||
this._bounds = new Rectangle();
|
||||
|
||||
this.scrollX = 0.0;
|
||||
|
@ -129,7 +131,7 @@ Camera.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
startFollow: function (gameObjectOrPoint)
|
||||
startFollow: function (gameObjectOrPoint, roundPx)
|
||||
{
|
||||
if (this._follow !== null)
|
||||
{
|
||||
|
@ -137,6 +139,11 @@ Camera.prototype = {
|
|||
}
|
||||
|
||||
this._follow = gameObjectOrPoint;
|
||||
|
||||
if (roundPx !== undefined)
|
||||
{
|
||||
this.roundPixels = roundPx;
|
||||
}
|
||||
},
|
||||
|
||||
stopFollow: function ()
|
||||
|
@ -145,6 +152,13 @@ Camera.prototype = {
|
|||
this._follow = null;
|
||||
},
|
||||
|
||||
setRoundPixels: function (value)
|
||||
{
|
||||
this.roundPixels = value;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
flash: function (duration, red, green, blue, force)
|
||||
{
|
||||
if (!force && this._flashAlpha > 0.0)
|
||||
|
@ -218,7 +232,7 @@ Camera.prototype = {
|
|||
var originY = height / 2;
|
||||
var follow = this._follow;
|
||||
|
||||
if (follow != null)
|
||||
if (follow !== null)
|
||||
{
|
||||
originX = follow.x;
|
||||
originY = follow.y;
|
||||
|
@ -235,18 +249,18 @@ Camera.prototype = {
|
|||
var boundsR = Math.max(bounds.right - width, width);
|
||||
var boundsB = Math.max(bounds.bottom - height, height);
|
||||
|
||||
if (this.scrollX < bounds.x)
|
||||
if (this.scrollX < boundsX)
|
||||
{
|
||||
this.scrollX = bounds.x;
|
||||
this.scrollX = boundsX;
|
||||
}
|
||||
if (this.scrollX > boundsR)
|
||||
{
|
||||
this.scrollX = boundsR;
|
||||
}
|
||||
|
||||
if (this.scrollY < bounds.y)
|
||||
if (this.scrollY < boundsY)
|
||||
{
|
||||
this.scrollY = bounds.y;
|
||||
this.scrollY = boundsY;
|
||||
}
|
||||
if (this.scrollY > boundsB)
|
||||
{
|
||||
|
@ -254,6 +268,12 @@ Camera.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
if (this.roundPixels)
|
||||
{
|
||||
this.scrollX = Math.round(this.scrollX);
|
||||
this.scrollY = Math.round(this.scrollY);
|
||||
}
|
||||
|
||||
matrix.loadIdentity();
|
||||
matrix.translate(this.x + originX, this.y + originY);
|
||||
matrix.rotate(this.rotation);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var CHECKSUM = {
|
||||
build: '541299d0-5a78-11e7-bceb-fd404c07e0b9'
|
||||
build: 'adb03e70-5a7d-11e7-8ee9-f7ee67d93c13'
|
||||
};
|
||||
module.exports = CHECKSUM;
|
Loading…
Reference in a new issue