Skip to content

Commit ccf50ff

Browse files
committed
Added Camera.visible property and setter.
1 parent bf2af95 commit ccf50ff

1 file changed

Lines changed: 38 additions & 3 deletions

File tree

src/cameras/2d/Camera.js

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,19 @@ var Camera = new Class({
149149
*/
150150
this.roundPixels = false;
151151

152+
/**
153+
* Is this Camera visible or not?
154+
*
155+
* A visible camera will render and perform input tests.
156+
* An invisible camera will not render anything and will skip input tests.
157+
*
158+
* @name Phaser.Cameras.Scene2D.Camera#visible
159+
* @type {boolean}
160+
* @default true
161+
* @since 3.10.0
162+
*/
163+
this.visible = true;
164+
152165
/**
153166
* Is this Camera using a bounds to restrict scrolling movement?
154167
* Set this property along with the bounds via `Camera.setBounds`.
@@ -1107,6 +1120,25 @@ var Camera = new Class({
11071120
return this;
11081121
},
11091122

1123+
/**
1124+
* Sets the visibility of this Camera.
1125+
*
1126+
* An invisible Camera will skip rendering and input tests of everything it can see.
1127+
*
1128+
* @method Phaser.Cameras.Scene2D.Camera#setVisible
1129+
* @since 3.10.0
1130+
*
1131+
* @param {boolean} value - The visible state of the Camera.
1132+
*
1133+
* @return {this} This Camera instance.
1134+
*/
1135+
setVisible: function (value)
1136+
{
1137+
this.visible = value;
1138+
1139+
return this;
1140+
},
1141+
11101142
/**
11111143
* Sets the Camera to follow a Game Object.
11121144
*
@@ -1245,9 +1277,12 @@ var Camera = new Class({
12451277
*/
12461278
update: function (time, delta)
12471279
{
1248-
this.shakeEffect.update(time, delta);
1249-
this.flashEffect.update(time, delta);
1250-
this.fadeEffect.update(time, delta);
1280+
if (this.visible)
1281+
{
1282+
this.shakeEffect.update(time, delta);
1283+
this.flashEffect.update(time, delta);
1284+
this.fadeEffect.update(time, delta);
1285+
}
12511286
},
12521287

12531288
/**

0 commit comments

Comments
 (0)