Skip to content

Commit 2373681

Browse files
committed
Added Camera.setAlpha method
1 parent 51468fd commit 2373681

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/cameras/2d/Camera.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ var Camera = new Class({
314314
this.backgroundColor = ValueToColor('rgba(0,0,0,0)');
315315

316316
/**
317-
* The Camera alpha value.
317+
* The Camera alpha value. Setting this property impacts every single object that this Camera
318+
* renders. You can either set the property directly, i.e. via a Tween, to fade a Camera in or out,
319+
* or via the chainable `setAlpha` method instead.
318320
*
319321
* @name Phaser.Cameras.Scene2D.Camera#alpha
320322
* @type {number}
@@ -510,6 +512,26 @@ var Camera = new Class({
510512
this._follow = null;
511513
},
512514

515+
/**
516+
* Set the Alpha level of this Camera. The alpha controls the opacity of the Camera as it renders.
517+
* Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque.
518+
*
519+
* @method Phaser.GameObjects.Components.Origin#setAlpha
520+
* @since 3.11.0
521+
*
522+
* @param {number} [value=1] - The Camera alpha value.
523+
*
524+
* @return {this} This Camera instance.
525+
*/
526+
setAlpha: function (value)
527+
{
528+
if (value === undefined) { value = 1; }
529+
530+
this.alpha = value;
531+
532+
return this;
533+
},
534+
513535
/**
514536
* Sets the rotation origin of this Camera.
515537
*

0 commit comments

Comments
 (0)