Skip to content

Commit 68ebce0

Browse files
committed
Add Camera#centerX, Camera#centerY
1 parent 9875318 commit 68ebce0

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

src/cameras/2d/Camera.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,40 @@ var Camera = new Class({
12841284
this._bounds = null;
12851285

12861286
this.scene = null;
1287+
},
1288+
1289+
/**
1290+
* The x position of the center of the Camera's viewport, relative to the top-left of the game canvas.
1291+
*
1292+
* @name Phaser.Cameras.Scene2D.Camera#centerX
1293+
* @type {number}
1294+
* @readOnly
1295+
* @since 3.10.0
1296+
*/
1297+
centerX: {
1298+
1299+
get: function ()
1300+
{
1301+
return this.x + (0.5 * this.width);
1302+
}
1303+
1304+
},
1305+
1306+
/**
1307+
* The y position of the center of the Camera's viewport, relative to the top-left of the game canvas.
1308+
*
1309+
* @name Phaser.Cameras.Scene2D.Camera#centerY
1310+
* @type {number}
1311+
* @readOnly
1312+
* @since 3.10.0
1313+
*/
1314+
centerY: {
1315+
1316+
get: function ()
1317+
{
1318+
return this.y + (0.5 * this.height);
1319+
}
1320+
12871321
}
12881322

12891323
});

0 commit comments

Comments
 (0)