mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 15:14:47 +00:00
Camera.centerToBounds
didn't take the bounds offset into account, so bounds at non-zero positions wouldn't center properly. All bounds now center correctly. Fix #3706
This commit is contained in:
parent
3e3b0d6397
commit
2ff6845360
2 changed files with 58 additions and 5 deletions
|
@ -26,6 +26,7 @@
|
|||
* The Arcade Body `blocked.none` property is now set to `false` after separation with static bodies or tiles. Previously, the blocked direction was set correctly, but the `none` remained `true` (thanks @samme)
|
||||
* The Camera bounds didn't factor in the camera zoom properly, meaning you would often not be able to reach the corners of a camera bound world at a zoom level other than 1. The bounds are now calculated each frame to ensure they match the zoom level and it will no longer allow you to scroll off the edge of the bounds. Fix #3547 (thanks @nkholski)
|
||||
* `Bob.setFrame` didn't actually set the frame on the Bob, now it does. Fix #3774 (thanks @NokFrt)
|
||||
* `Camera.centerToBounds` didn't take the bounds offset into account, so bounds at non-zero positions wouldn't center properly. All bounds now center correctly. Fix #3706 (thanks @cyantree)
|
||||
|
||||
### Examples, Documentation and TypeScript
|
||||
|
||||
|
|
|
@ -366,6 +366,32 @@ var Camera = new Class({
|
|||
*/
|
||||
this.midPoint = new Vector2(width / 2, height / 2);
|
||||
|
||||
/**
|
||||
* The horizontal origin of this Game Object.
|
||||
* The origin maps the relationship between the size and position of the Game Object.
|
||||
* The default value is 0.5, meaning all Game Objects are positioned based on their center.
|
||||
* Setting the value to 0 means the position now relates to the left of the Game Object.
|
||||
*
|
||||
* @name Phaser.GameObjects.Components.Origin#originX
|
||||
* @type {float}
|
||||
* @default 0.5
|
||||
* @since 3.11.0
|
||||
*/
|
||||
this.originX = 0.5;
|
||||
|
||||
/**
|
||||
* The vertical origin of this Game Object.
|
||||
* The origin maps the relationship between the size and position of the Game Object.
|
||||
* The default value is 0.5, meaning all Game Objects are positioned based on their center.
|
||||
* Setting the value to 0 means the position now relates to the top of the Game Object.
|
||||
*
|
||||
* @name Phaser.GameObjects.Components.Origin#originY
|
||||
* @type {float}
|
||||
* @default 0.5
|
||||
* @since 3.11.0
|
||||
*/
|
||||
this.originY = 0.5;
|
||||
|
||||
/**
|
||||
* The Camera dead zone.
|
||||
*
|
||||
|
@ -417,6 +443,30 @@ var Camera = new Class({
|
|||
this._zoomInversed = 1;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the rotation origin of this Camera.
|
||||
*
|
||||
* The values are given in the range 0 to 1 and are only used when calculating Camera rotation.
|
||||
*
|
||||
* @method Phaser.GameObjects.Components.Origin#setOrigin
|
||||
* @since 3.11.0
|
||||
*
|
||||
* @param {number} [x=0.5] - The horizontal origin value.
|
||||
* @param {number} [y=x] - The vertical origin value. If not defined it will be set to the value of `x`.
|
||||
*
|
||||
* @return {this} This Camera instance.
|
||||
*/
|
||||
setOrigin: function (x, y)
|
||||
{
|
||||
if (x === undefined) { x = 0.5; }
|
||||
if (y === undefined) { y = x; }
|
||||
|
||||
this.originX = x;
|
||||
this.originY = y;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the Camera dead zone.
|
||||
*
|
||||
|
@ -491,8 +541,10 @@ var Camera = new Class({
|
|||
{
|
||||
if (this.useBounds)
|
||||
{
|
||||
this.scrollX = (this._bounds.width * 0.5) - (this.width * 0.5);
|
||||
this.scrollY = (this._bounds.height * 0.5) - (this.height * 0.5);
|
||||
var bounds = this._bounds;
|
||||
|
||||
this.scrollX = bounds.centerX - (this.width * 0.5);
|
||||
this.scrollY = bounds.centerY - (this.height * 0.5);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
@ -835,8 +887,8 @@ var Camera = new Class({
|
|||
var height = this.height;
|
||||
var zoom = this._zoom * baseScale;
|
||||
var matrix = this.matrix;
|
||||
var originX = width / 2;
|
||||
var originY = height / 2;
|
||||
var originX = width * this.originX;
|
||||
var originY = height * this.originY;
|
||||
var follow = this._follow;
|
||||
var deadzone = this.deadzone;
|
||||
var sx = this.scrollX;
|
||||
|
@ -891,7 +943,7 @@ var Camera = new Class({
|
|||
var bw = Math.max(bx, bx + bounds.width - dw);
|
||||
var bh = Math.max(by, by + bounds.height - dh);
|
||||
|
||||
this._tb = new Rectangle(bx, by, bw, bh);
|
||||
// this._tb = new Rectangle(bx, by, bw, bh);
|
||||
|
||||
if (sx < bx)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue