mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 15:14:47 +00:00
Camera.updateTarget has had a make-over and now is a lot smoother under certain conditions (thanks @tjkopena, fix #966)
This commit is contained in:
parent
336cd8b76c
commit
92dbabb2df
2 changed files with 16 additions and 20 deletions
|
@ -122,6 +122,7 @@ Version 2.0.6 - "Jornhill" - -in development-
|
|||
* Group.removeBetween has a new optional boolean parameter: `silent`. If set to `true` the children will not dispatch their `onRemovedFromGroup` events.
|
||||
* Group.removeAll has a new optional boolean parameter: `silent`. If set to `true` the children will not dispatch their `onRemovedFromGroup` events.
|
||||
* Internal child movements in Group (such as bringToTop) now uses the new `silent` parameter to avoid the child emitting incorrect Group addition and deletion events.
|
||||
* Camera.updateTarget has had a make-over and now is a lot smoother under certain conditions (thanks @tjkopena, fix #966)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
|
|
@ -58,7 +58,7 @@ Phaser.Camera = function (game, id, x, y, width, height) {
|
|||
this.bounds = new Phaser.Rectangle(x, y, width, height);
|
||||
|
||||
/**
|
||||
* @property {Phaser.Rectangle} deadzone - Moving inside this Rectangle will not cause camera moving.
|
||||
* @property {Phaser.Rectangle} deadzone - Moving inside this Rectangle will not cause the camera to move.
|
||||
*/
|
||||
this.deadzone = null;
|
||||
|
||||
|
@ -231,37 +231,32 @@ Phaser.Camera.prototype = {
|
|||
|
||||
if (this.deadzone)
|
||||
{
|
||||
this._edge = this.target.x - this.deadzone.x;
|
||||
this._edge = this.target.x - this.view.x;
|
||||
|
||||
if (this.view.x > this._edge)
|
||||
if (this._edge < this.deadzone.left)
|
||||
{
|
||||
this.view.x = this._edge;
|
||||
this.view.x = this.target.x - this.deadzone.left;
|
||||
}
|
||||
else if (this._edge > this.deadzone.right)
|
||||
{
|
||||
this.view.x = this.target.x - this.deadzone.right;
|
||||
}
|
||||
|
||||
this._edge = this.target.x + this.target.width - this.deadzone.x - this.deadzone.width;
|
||||
this._edge = this.target.y - this.view.y;
|
||||
|
||||
if (this.view.x < this._edge)
|
||||
if (this._edge < this.deadzone.top)
|
||||
{
|
||||
this.view.x = this._edge;
|
||||
this.view.y = this.target.y - this.deadzone.top;
|
||||
}
|
||||
|
||||
this._edge = this.target.y - this.deadzone.y;
|
||||
|
||||
if (this.view.y > this._edge)
|
||||
else if (this._edge > this.deadzone.bottom)
|
||||
{
|
||||
this.view.y = this._edge;
|
||||
}
|
||||
|
||||
this._edge = this.target.y + this.target.height - this.deadzone.y - this.deadzone.height;
|
||||
|
||||
if (this.view.y < this._edge)
|
||||
{
|
||||
this.view.y = this._edge;
|
||||
this.view.y = this.target.y - this.deadzone.bottom;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.focusOnXY(this.target.x, this.target.y);
|
||||
this.view.x = this.target.x - this.view.halfWidth;
|
||||
this.view.y = this.target.y - this.view.halfHeight;
|
||||
}
|
||||
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue