Skip to content

Commit 9327373

Browse files
committed
Added centerOn argument to setBounds and bumped Camera id to be public
1 parent 53cf7d8 commit 9327373

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

src/cameras/2d/Camera.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ var Camera = new Class({
9494
*/
9595
this.scene;
9696

97+
/**
98+
* The Camera ID. Assigned by the Camera Manager and used to handle camera exclusion.
99+
*
100+
* @name Phaser.Cameras.Scene2D.Camera#id
101+
* @type {integer}
102+
* @readOnly
103+
* @since 3.11.0
104+
*/
105+
this.id = 0;
106+
97107
/**
98108
* The name of the Camera. This is left empty for your own use.
99109
*
@@ -487,17 +497,6 @@ var Camera = new Class({
487497
* @since 3.0.0
488498
*/
489499
this._follow = null;
490-
491-
/**
492-
* Internal camera ID. Assigned by the Camera Manager and used in the camera pool.
493-
*
494-
* @name Phaser.Cameras.Scene2D.Camera#_id
495-
* @type {integer}
496-
* @private
497-
* @default 0
498-
* @since 3.0.0
499-
*/
500-
this._id = 0;
501500
},
502501

503502
/**
@@ -1329,15 +1328,21 @@ var Camera = new Class({
13291328
* @param {integer} y - The top-left y coordinate of the bounds.
13301329
* @param {integer} width - The width of the bounds, in pixels.
13311330
* @param {integer} height - The height of the bounds, in pixels.
1331+
* @param {boolean} [centerOn] - If `true` the Camera will automatically be centered on the new bounds.
13321332
*
13331333
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
13341334
*/
1335-
setBounds: function (x, y, width, height)
1335+
setBounds: function (x, y, width, height, centerOn)
13361336
{
13371337
this._bounds.setTo(x, y, width, height);
13381338

13391339
this.useBounds = true;
13401340

1341+
if (centerOn)
1342+
{
1343+
this.centerToBounds();
1344+
}
1345+
13411346
return this;
13421347
},
13431348

0 commit comments

Comments
 (0)