2015-03-01 07:00:17 +00:00
|
|
|
/**
|
2015-03-23 23:27:14 +00:00
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2016-04-04 21:15:01 +00:00
|
|
|
* @copyright 2016 Photon Storm Ltd.
|
2015-03-23 23:27:14 +00:00
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Bounds component contains properties related to the bounds of the Game Object.
|
2015-03-01 07:00:17 +00:00
|
|
|
*
|
|
|
|
* @class
|
|
|
|
*/
|
2015-02-17 05:15:04 +00:00
|
|
|
Phaser.Component.Bounds = function () {};
|
|
|
|
|
|
|
|
Phaser.Component.Bounds.prototype = {
|
|
|
|
|
|
|
|
/**
|
2015-03-23 23:27:14 +00:00
|
|
|
* The amount the Game Object is visually offset from its x coordinate.
|
|
|
|
* This is the same as `width * anchor.x`.
|
|
|
|
* It will only be > 0 if anchor.x is not equal to zero.
|
2015-02-17 05:15:04 +00:00
|
|
|
*
|
2015-03-23 23:27:14 +00:00
|
|
|
* @property {number} offsetX
|
2015-02-17 05:15:04 +00:00
|
|
|
* @readOnly
|
|
|
|
*/
|
|
|
|
offsetX: {
|
|
|
|
|
|
|
|
get: function () {
|
|
|
|
|
|
|
|
return this.anchor.x * this.width;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2015-03-23 23:27:14 +00:00
|
|
|
* The amount the Game Object is visually offset from its y coordinate.
|
|
|
|
* This is the same as `height * anchor.y`.
|
|
|
|
* It will only be > 0 if anchor.y is not equal to zero.
|
2015-02-17 05:15:04 +00:00
|
|
|
*
|
2015-03-23 23:27:14 +00:00
|
|
|
* @property {number} offsetY
|
2015-02-17 05:15:04 +00:00
|
|
|
* @readOnly
|
|
|
|
*/
|
|
|
|
offsetY: {
|
|
|
|
|
|
|
|
get: function () {
|
|
|
|
|
|
|
|
return this.anchor.y * this.height;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2015-03-23 23:27:14 +00:00
|
|
|
* The left coordinate of the Game Object.
|
|
|
|
* This is the same as `x - offsetX`.
|
2015-02-17 05:15:04 +00:00
|
|
|
*
|
2015-03-23 23:27:14 +00:00
|
|
|
* @property {number} left
|
2015-02-17 05:15:04 +00:00
|
|
|
*/
|
|
|
|
left: {
|
|
|
|
|
|
|
|
get: function () {
|
|
|
|
|
|
|
|
return this.x - this.offsetX;
|
|
|
|
|
2016-06-15 23:33:48 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value) {
|
|
|
|
|
|
|
|
this.x = value + this.offsetX;
|
|
|
|
|
2015-02-17 05:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2015-03-23 23:27:14 +00:00
|
|
|
* The right coordinate of the Game Object.
|
|
|
|
* This is the same as `x + width - offsetX`.
|
2015-02-17 05:15:04 +00:00
|
|
|
*
|
2015-03-23 23:27:14 +00:00
|
|
|
* @property {number} right
|
2015-02-17 05:15:04 +00:00
|
|
|
*/
|
|
|
|
right: {
|
|
|
|
|
|
|
|
get: function () {
|
|
|
|
|
|
|
|
return (this.x + this.width) - this.offsetX;
|
|
|
|
|
2016-06-15 23:33:48 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value) {
|
|
|
|
|
|
|
|
this.x = value - (this.width) + this.offsetX;
|
|
|
|
|
2015-02-17 05:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2015-03-23 23:27:14 +00:00
|
|
|
* The y coordinate of the Game Object.
|
|
|
|
* This is the same as `y - offsetY`.
|
2015-02-17 05:15:04 +00:00
|
|
|
*
|
2015-03-23 23:27:14 +00:00
|
|
|
* @property {number} top
|
2015-02-17 05:15:04 +00:00
|
|
|
*/
|
|
|
|
top: {
|
|
|
|
|
|
|
|
get: function () {
|
|
|
|
|
|
|
|
return this.y - this.offsetY;
|
|
|
|
|
2016-06-15 23:33:48 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value) {
|
|
|
|
|
|
|
|
this.y = value + this.offsetY;
|
|
|
|
|
2015-02-17 05:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2015-03-23 23:27:14 +00:00
|
|
|
* The sum of the y and height properties.
|
|
|
|
* This is the same as `y + height - offsetY`.
|
2015-02-17 05:15:04 +00:00
|
|
|
*
|
2015-03-23 23:27:14 +00:00
|
|
|
* @property {number} bottom
|
2015-02-17 05:15:04 +00:00
|
|
|
*/
|
|
|
|
bottom: {
|
|
|
|
|
|
|
|
get: function () {
|
|
|
|
|
|
|
|
return (this.y + this.height) - this.offsetY;
|
|
|
|
|
2016-06-15 23:33:48 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value) {
|
|
|
|
|
|
|
|
this.y = value - (this.height) + this.offsetY;
|
|
|
|
|
2015-02-17 05:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|