mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
GetBounds getTopLeft
, getTopRight
, getBottomLeft
and getBottomRight
all have a new optional argument includeParent
which will factor in all ancestor transforms to the returned point.
This commit is contained in:
parent
2e722b0a92
commit
1802f8b30b
2 changed files with 45 additions and 8 deletions
|
@ -47,6 +47,7 @@
|
|||
* TransformMatrix.destroy is a new method that will clear out the array and object used by a Matrix internally.
|
||||
* BaseSound, and by extension WebAudioSound and HTMLAudioSound, will now emit a `destroy` event when they are destroyed (thanks @rexrainbow)
|
||||
* A new property was added to the Scene config: `mapAdd` which is used to extend the default injection map of a scene instead of overwriting it (thanks @sebashwa)
|
||||
* GetBounds `getTopLeft`, `getTopRight`, `getBottomLeft` and `getBottomRight` all have a new optional argument `includeParent` which will factor in all ancestor transforms to the returned point.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -51,12 +51,14 @@ var GetBounds = {
|
|||
* @generic {Phaser.Math.Vector2} O - [output,$return]
|
||||
*
|
||||
* @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created.
|
||||
* @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector?
|
||||
*
|
||||
* @return {(Phaser.Math.Vector2|object)} The values stored in the output object.
|
||||
*/
|
||||
getTopLeft: function (output)
|
||||
getTopLeft: function (output, includeParent)
|
||||
{
|
||||
if (output === undefined) { output = new Vector2(); }
|
||||
if (!output) { output = new Vector2(); }
|
||||
if (includeParent === undefined) { includeParent = false; }
|
||||
|
||||
output.x = this.x - (this.displayWidth * this.originX);
|
||||
output.y = this.y - (this.displayHeight * this.originY);
|
||||
|
@ -66,6 +68,13 @@ var GetBounds = {
|
|||
RotateAround(output, this.x, this.y, this.rotation);
|
||||
}
|
||||
|
||||
if (includeParent && this.parentContainer)
|
||||
{
|
||||
var parentMatrix = this.parentContainer.getBoundsTransformMatrix();
|
||||
|
||||
parentMatrix.transformPoint(output.x, output.y, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
@ -79,12 +88,14 @@ var GetBounds = {
|
|||
* @generic {Phaser.Math.Vector2} O - [output,$return]
|
||||
*
|
||||
* @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created.
|
||||
* @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector?
|
||||
*
|
||||
* @return {(Phaser.Math.Vector2|object)} The values stored in the output object.
|
||||
*/
|
||||
getTopRight: function (output)
|
||||
getTopRight: function (output, includeParent)
|
||||
{
|
||||
if (output === undefined) { output = new Vector2(); }
|
||||
if (!output) { output = new Vector2(); }
|
||||
if (includeParent === undefined) { includeParent = false; }
|
||||
|
||||
output.x = (this.x - (this.displayWidth * this.originX)) + this.displayWidth;
|
||||
output.y = this.y - (this.displayHeight * this.originY);
|
||||
|
@ -94,6 +105,13 @@ var GetBounds = {
|
|||
RotateAround(output, this.x, this.y, this.rotation);
|
||||
}
|
||||
|
||||
if (includeParent && this.parentContainer)
|
||||
{
|
||||
var parentMatrix = this.parentContainer.getBoundsTransformMatrix();
|
||||
|
||||
parentMatrix.transformPoint(output.x, output.y, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
@ -107,12 +125,14 @@ var GetBounds = {
|
|||
* @generic {Phaser.Math.Vector2} O - [output,$return]
|
||||
*
|
||||
* @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created.
|
||||
* @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector?
|
||||
*
|
||||
* @return {(Phaser.Math.Vector2|object)} The values stored in the output object.
|
||||
*/
|
||||
getBottomLeft: function (output)
|
||||
getBottomLeft: function (output, includeParent)
|
||||
{
|
||||
if (output === undefined) { output = new Vector2(); }
|
||||
if (!output) { output = new Vector2(); }
|
||||
if (includeParent === undefined) { includeParent = false; }
|
||||
|
||||
output.x = this.x - (this.displayWidth * this.originX);
|
||||
output.y = (this.y - (this.displayHeight * this.originY)) + this.displayHeight;
|
||||
|
@ -122,6 +142,13 @@ var GetBounds = {
|
|||
RotateAround(output, this.x, this.y, this.rotation);
|
||||
}
|
||||
|
||||
if (includeParent && this.parentContainer)
|
||||
{
|
||||
var parentMatrix = this.parentContainer.getBoundsTransformMatrix();
|
||||
|
||||
parentMatrix.transformPoint(output.x, output.y, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
@ -135,12 +162,14 @@ var GetBounds = {
|
|||
* @generic {Phaser.Math.Vector2} O - [output,$return]
|
||||
*
|
||||
* @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created.
|
||||
* @param {boolean} [includeParent=false] - If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector?
|
||||
*
|
||||
* @return {(Phaser.Math.Vector2|object)} The values stored in the output object.
|
||||
*/
|
||||
getBottomRight: function (output)
|
||||
getBottomRight: function (output, includeParent)
|
||||
{
|
||||
if (output === undefined) { output = new Vector2(); }
|
||||
if (!output) { output = new Vector2(); }
|
||||
if (includeParent === undefined) { includeParent = false; }
|
||||
|
||||
output.x = (this.x - (this.displayWidth * this.originX)) + this.displayWidth;
|
||||
output.y = (this.y - (this.displayHeight * this.originY)) + this.displayHeight;
|
||||
|
@ -150,6 +179,13 @@ var GetBounds = {
|
|||
RotateAround(output, this.x, this.y, this.rotation);
|
||||
}
|
||||
|
||||
if (includeParent && this.parentContainer)
|
||||
{
|
||||
var parentMatrix = this.parentContainer.getBoundsTransformMatrix();
|
||||
|
||||
parentMatrix.transformPoint(output.x, output.y, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue