mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 05:33:35 +00:00
fixed top, bottom, left, right, centerX and centerY to use the updated getBounds and compute their values depending on the parent local coordinate space. I think this is better than using the global getBounds and a lot more convenient because it makes total sense x and centerX for example to be from the same coordinate space and also with this change now these values would be working when the group is a top level display object and also when it is parented by something else. So this loosens the global only getBounds restriction. Also it doesn't really makes sense to align objects with totally different parents but if that is the case separate calculations could be made.
This commit is contained in:
parent
aad2ab398a
commit
64a02ddef4
1 changed files with 12 additions and 42 deletions
|
@ -2711,11 +2711,6 @@ Object.defineProperty(Phaser.Group.prototype, "angle", {
|
|||
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
|
||||
* visible children.
|
||||
*
|
||||
* Note that no ancestors are factored into the result, meaning that if this Group is
|
||||
* nested within another Group, with heavy transforms on it, the result of this property
|
||||
* is likely to be incorrect. It is safe to get and set this property if the Group is a
|
||||
* top-level descendant of Phaser.World, or untransformed parents.
|
||||
*
|
||||
* @name Phaser.Group#centerX
|
||||
* @property {number} centerX
|
||||
*/
|
||||
|
@ -2723,13 +2718,13 @@ Object.defineProperty(Phaser.Group.prototype, "centerX", {
|
|||
|
||||
get: function () {
|
||||
|
||||
return this.getBounds().centerX;
|
||||
return this.getBounds(this.parent).centerX;
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
var r = this.getBounds();
|
||||
var r = this.getBounds(this.parent);
|
||||
var offset = this.x - r.x;
|
||||
|
||||
this.x = (value + offset) - r.halfWidth;
|
||||
|
@ -2744,11 +2739,6 @@ Object.defineProperty(Phaser.Group.prototype, "centerX", {
|
|||
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
|
||||
* visible children.
|
||||
*
|
||||
* Note that no ancestors are factored into the result, meaning that if this Group is
|
||||
* nested within another Group, with heavy transforms on it, the result of this property
|
||||
* is likely to be incorrect. It is safe to get and set this property if the Group is a
|
||||
* top-level descendant of Phaser.World, or untransformed parents.
|
||||
*
|
||||
* @name Phaser.Group#centerY
|
||||
* @property {number} centerY
|
||||
*/
|
||||
|
@ -2756,13 +2746,13 @@ Object.defineProperty(Phaser.Group.prototype, "centerY", {
|
|||
|
||||
get: function () {
|
||||
|
||||
return this.getBounds().centerY;
|
||||
return this.getBounds(this.parent).centerY;
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
var r = this.getBounds();
|
||||
var r = this.getBounds(this.parent);
|
||||
var offset = this.y - r.y;
|
||||
|
||||
this.y = (value + offset) - r.halfHeight;
|
||||
|
@ -2777,11 +2767,6 @@ Object.defineProperty(Phaser.Group.prototype, "centerY", {
|
|||
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
|
||||
* visible children.
|
||||
*
|
||||
* Note that no ancestors are factored into the result, meaning that if this Group is
|
||||
* nested within another Group, with heavy transforms on it, the result of this property
|
||||
* is likely to be incorrect. It is safe to get and set this property if the Group is a
|
||||
* top-level descendant of Phaser.World, or untransformed parents.
|
||||
*
|
||||
* @name Phaser.Group#left
|
||||
* @property {number} left
|
||||
*/
|
||||
|
@ -2789,13 +2774,13 @@ Object.defineProperty(Phaser.Group.prototype, "left", {
|
|||
|
||||
get: function () {
|
||||
|
||||
return this.getBounds().left;
|
||||
return this.getBounds(this.parent).left;
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
var r = this.getBounds();
|
||||
var r = this.getBounds(this.parent);
|
||||
var offset = this.x - r.x;
|
||||
|
||||
this.x = value + offset;
|
||||
|
@ -2809,11 +2794,6 @@ Object.defineProperty(Phaser.Group.prototype, "left", {
|
|||
*
|
||||
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
|
||||
* visible children.
|
||||
*
|
||||
* Note that no ancestors are factored into the result, meaning that if this Group is
|
||||
* nested within another Group, with heavy transforms on it, the result of this property
|
||||
* is likely to be incorrect. It is safe to get and set this property if the Group is a
|
||||
* top-level descendant of Phaser.World, or untransformed parents.
|
||||
*
|
||||
* @name Phaser.Group#right
|
||||
* @property {number} right
|
||||
|
@ -2822,13 +2802,13 @@ Object.defineProperty(Phaser.Group.prototype, "right", {
|
|||
|
||||
get: function () {
|
||||
|
||||
return this.getBounds().right;
|
||||
return this.getBounds(this.parent).right;
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
var r = this.getBounds();
|
||||
var r = this.getBounds(this.parent);
|
||||
var offset = this.x - r.x;
|
||||
|
||||
this.x = (value + offset) - r.width;
|
||||
|
@ -2842,11 +2822,6 @@ Object.defineProperty(Phaser.Group.prototype, "right", {
|
|||
*
|
||||
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
|
||||
* visible children.
|
||||
*
|
||||
* Note that no ancestors are factored into the result, meaning that if this Group is
|
||||
* nested within another Group, with heavy transforms on it, the result of this property
|
||||
* is likely to be incorrect. It is safe to get and set this property if the Group is a
|
||||
* top-level descendant of Phaser.World, or untransformed parents.
|
||||
*
|
||||
* @name Phaser.Group#top
|
||||
* @property {number} top
|
||||
|
@ -2855,13 +2830,13 @@ Object.defineProperty(Phaser.Group.prototype, "top", {
|
|||
|
||||
get: function () {
|
||||
|
||||
return this.getBounds().top;
|
||||
return this.getBounds(this.parent).top;
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
var r = this.getBounds();
|
||||
var r = this.getBounds(this.parent);
|
||||
var offset = this.y - r.y;
|
||||
|
||||
this.y = (value + offset);
|
||||
|
@ -2876,11 +2851,6 @@ Object.defineProperty(Phaser.Group.prototype, "top", {
|
|||
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
|
||||
* visible children.
|
||||
*
|
||||
* Note that no ancestors are factored into the result, meaning that if this Group is
|
||||
* nested within another Group, with heavy transforms on it, the result of this property
|
||||
* is likely to be incorrect. It is safe to get and set this property if the Group is a
|
||||
* top-level descendant of Phaser.World, or untransformed parents.
|
||||
*
|
||||
* @name Phaser.Group#bottom
|
||||
* @property {number} bottom
|
||||
*/
|
||||
|
@ -2888,13 +2858,13 @@ Object.defineProperty(Phaser.Group.prototype, "bottom", {
|
|||
|
||||
get: function () {
|
||||
|
||||
return this.getBounds().bottom;
|
||||
return this.getBounds(this.parent).bottom;
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
var r = this.getBounds();
|
||||
var r = this.getBounds(this.parent);
|
||||
var offset = this.y - r.y;
|
||||
|
||||
this.y = (value + offset) - r.height;
|
||||
|
|
Loading…
Reference in a new issue