Merge pull request #3727 from samme/feature/camera-centerXY

Add Camera#centerX, Camera#centerY
This commit is contained in:
Richard Davey 2018-06-03 21:02:51 +01:00 committed by GitHub
commit e8964dc789
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);
}
} }
}); });