Skip to content

Commit 811c347

Browse files
committed
Camera.fade has a new argument alpha to control the alpha level of the effect (thanks @rgk phaserjs#2493)
Camera.flash has a new argument `alpha` to control the alpha level of the effect (thanks @rgk phaserjs#2493)
1 parent 2bc9c73 commit 811c347

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
330330
* Updated the pointer check code in the Device class, to get rid of the message `Navigator.pointerEnabled is a non-standard API added for experiments only. It will be removed in near future.` in Chrome.
331331
* The P2 Physics library has been updated to 0.7.1. This is still quite out of date, but as soon as they release their latest build (hopefully soon) we'll update to that.
332332
* Math.between has been strengthened and the docs improved (thanks @JTronLabs #2760)
333+
* Camera.fade has a new argument `alpha` to control the alpha level of the effect (thanks @rgk #2493)
334+
* Camera.flash has a new argument `alpha` to control the alpha level of the effect (thanks @rgk #2493)
333335

334336
### Bug Fixes
335337

src/core/Camera.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,13 +410,15 @@ Phaser.Camera.prototype = {
410410
* @param {numer} [color=0xffffff] - The color of the flash effect. I.e. 0xffffff for white, 0xff0000 for red, etc.
411411
* @param {number} [duration=500] - The duration of the flash effect in milliseconds.
412412
* @param {boolean} [force=false] - If a camera flash or fade effect is already running and force is true it will replace the previous effect, resetting the duration.
413+
* @param {numer} [alpha=1] - The alpha value of the color applied to the flash effect.
413414
* @return {boolean} True if the effect was started, otherwise false.
414415
*/
415-
flash: function (color, duration, force) {
416+
flash: function (color, duration, force, alpha) {
416417

417418
if (color === undefined) { color = 0xffffff; }
418419
if (duration === undefined) { duration = 500; }
419420
if (force === undefined) { force = false; }
421+
if (alpha === undefined) { alpha = 1; }
420422

421423
if (!this.fx || (!force && this._fxDuration > 0))
422424
{
@@ -425,7 +427,7 @@ Phaser.Camera.prototype = {
425427

426428
this.fx.clear();
427429

428-
this.fx.beginFill(color);
430+
this.fx.beginFill(color, alpha);
429431
this.fx.drawRect(0, 0, this.width, this.height);
430432
this.fx.endFill();
431433

@@ -455,13 +457,15 @@ Phaser.Camera.prototype = {
455457
* @param {numer} [color=0x000000] - The color the game will fade to. I.e. 0x000000 for black, 0xff0000 for red, etc.
456458
* @param {number} [duration=500] - The duration of the fade in milliseconds.
457459
* @param {boolean} [force=false] - If a camera flash or fade effect is already running and force is true it will replace the previous effect, resetting the duration.
460+
* @param {numer} [alpha=1] - The alpha value of the color applied to the fade effect.
458461
* @return {boolean} True if the effect was started, otherwise false.
459462
*/
460-
fade: function (color, duration, force) {
463+
fade: function (color, duration, force, alpha) {
461464

462465
if (color === undefined) { color = 0x000000; }
463466
if (duration === undefined) { duration = 500; }
464467
if (force === undefined) { force = false; }
468+
if (alpha === undefined) { alpha = 1; }
465469

466470
if (!this.fx || (!force && this._fxDuration > 0))
467471
{
@@ -470,7 +474,7 @@ Phaser.Camera.prototype = {
470474

471475
this.fx.clear();
472476

473-
this.fx.beginFill(color);
477+
this.fx.beginFill(color, alpha);
474478
this.fx.drawRect(0, 0, this.width, this.height);
475479
this.fx.endFill();
476480

typescript/phaser.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,8 @@ declare module Phaser {
663663
y: number;
664664

665665
checkBounds(): void;
666-
fade(color?: number, duration?: number, force?: boolean): boolean;
667-
flash(color?: number, duration?: number, force?: boolean): boolean;
666+
fade(color?: number, duration?: number, force?: boolean, alpha?: number): boolean;
667+
flash(color?: number, duration?: number, force?: boolean, alpha?: number): boolean;
668668
focusOn(displayObject: PIXI.DisplayObject): void;
669669
focusOnXY(x: number, y: number): void;
670670
follow(target: Phaser.Sprite, style?: number, lerpX?: number, lerpY?: number): void;

0 commit comments

Comments
 (0)