Camera.fade has a new argument alpha to control the alpha level of the effect (thanks @rgk #2493)

Camera.flash has a new argument `alpha` to control the alpha level of the effect (thanks @rgk #2493)
This commit is contained in:
Richard Davey 2016-09-27 01:07:40 +01:00
parent 2bc9c73838
commit 811c347cc3
3 changed files with 12 additions and 6 deletions

View file

@ -330,6 +330,8 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
* 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.
* 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.
* Math.between has been strengthened and the docs improved (thanks @JTronLabs #2760)
* Camera.fade has a new argument `alpha` to control the alpha level of the effect (thanks @rgk #2493)
* Camera.flash has a new argument `alpha` to control the alpha level of the effect (thanks @rgk #2493)
### Bug Fixes

View file

@ -410,13 +410,15 @@ Phaser.Camera.prototype = {
* @param {numer} [color=0xffffff] - The color of the flash effect. I.e. 0xffffff for white, 0xff0000 for red, etc.
* @param {number} [duration=500] - The duration of the flash effect in milliseconds.
* @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.
* @param {numer} [alpha=1] - The alpha value of the color applied to the flash effect.
* @return {boolean} True if the effect was started, otherwise false.
*/
flash: function (color, duration, force) {
flash: function (color, duration, force, alpha) {
if (color === undefined) { color = 0xffffff; }
if (duration === undefined) { duration = 500; }
if (force === undefined) { force = false; }
if (alpha === undefined) { alpha = 1; }
if (!this.fx || (!force && this._fxDuration > 0))
{
@ -425,7 +427,7 @@ Phaser.Camera.prototype = {
this.fx.clear();
this.fx.beginFill(color);
this.fx.beginFill(color, alpha);
this.fx.drawRect(0, 0, this.width, this.height);
this.fx.endFill();
@ -455,13 +457,15 @@ Phaser.Camera.prototype = {
* @param {numer} [color=0x000000] - The color the game will fade to. I.e. 0x000000 for black, 0xff0000 for red, etc.
* @param {number} [duration=500] - The duration of the fade in milliseconds.
* @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.
* @param {numer} [alpha=1] - The alpha value of the color applied to the fade effect.
* @return {boolean} True if the effect was started, otherwise false.
*/
fade: function (color, duration, force) {
fade: function (color, duration, force, alpha) {
if (color === undefined) { color = 0x000000; }
if (duration === undefined) { duration = 500; }
if (force === undefined) { force = false; }
if (alpha === undefined) { alpha = 1; }
if (!this.fx || (!force && this._fxDuration > 0))
{
@ -470,7 +474,7 @@ Phaser.Camera.prototype = {
this.fx.clear();
this.fx.beginFill(color);
this.fx.beginFill(color, alpha);
this.fx.drawRect(0, 0, this.width, this.height);
this.fx.endFill();

View file

@ -663,8 +663,8 @@ declare module Phaser {
y: number;
checkBounds(): void;
fade(color?: number, duration?: number, force?: boolean): boolean;
flash(color?: number, duration?: number, force?: boolean): boolean;
fade(color?: number, duration?: number, force?: boolean, alpha?: number): boolean;
flash(color?: number, duration?: number, force?: boolean, alpha?: number): boolean;
focusOn(displayObject: PIXI.DisplayObject): void;
focusOnXY(x: number, y: number): void;
follow(target: Phaser.Sprite, style?: number, lerpX?: number, lerpY?: number): void;