mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 21:53:59 +00:00
Merge pull request #3727 from samme/feature/camera-centerXY
Add Camera#centerX, Camera#centerY
This commit is contained in:
commit
e8964dc789
1 changed files with 34 additions and 0 deletions
|
@ -1284,6 +1284,40 @@ var Camera = new Class({
|
||||||
this._bounds = null;
|
this._bounds = null;
|
||||||
|
|
||||||
this.scene = null;
|
this.scene = null;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The x position of the center of the Camera's viewport, relative to the top-left of the game canvas.
|
||||||
|
*
|
||||||
|
* @name Phaser.Cameras.Scene2D.Camera#centerX
|
||||||
|
* @type {number}
|
||||||
|
* @readOnly
|
||||||
|
* @since 3.10.0
|
||||||
|
*/
|
||||||
|
centerX: {
|
||||||
|
|
||||||
|
get: function ()
|
||||||
|
{
|
||||||
|
return this.x + (0.5 * this.width);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The y position of the center of the Camera's viewport, relative to the top-left of the game canvas.
|
||||||
|
*
|
||||||
|
* @name Phaser.Cameras.Scene2D.Camera#centerY
|
||||||
|
* @type {number}
|
||||||
|
* @readOnly
|
||||||
|
* @since 3.10.0
|
||||||
|
*/
|
||||||
|
centerY: {
|
||||||
|
|
||||||
|
get: function ()
|
||||||
|
{
|
||||||
|
return this.y + (0.5 * this.height);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue