mirror of
https://github.com/photonstorm/phaser
synced 2024-12-23 19:43:28 +00:00
Allow setting alpha for 2D camera flash effect
* Allow the overriding of `this.alpha` value for the camera flash effect
This commit is contained in:
parent
af27284202
commit
6861a93a82
1 changed files with 15 additions and 4 deletions
|
@ -104,10 +104,9 @@ var Flash = new Class({
|
||||||
*
|
*
|
||||||
* @name Phaser.Cameras.Scene2D.Effects.Flash#alpha
|
* @name Phaser.Cameras.Scene2D.Effects.Flash#alpha
|
||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
|
||||||
* @since 3.5.0
|
* @since 3.5.0
|
||||||
*/
|
*/
|
||||||
this.alpha = 0;
|
this.alpha = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this effect is running this holds the current percentage of the progress, a value between 0 and 1.
|
* If this effect is running this holds the current percentage of the progress, a value between 0 and 1.
|
||||||
|
@ -128,6 +127,17 @@ var Flash = new Class({
|
||||||
*/
|
*/
|
||||||
this._elapsed = 0;
|
this._elapsed = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an internal copy of the initial value of `this.alpha`, used to calculate the current alpha value of the fade effect.
|
||||||
|
*
|
||||||
|
* @name Phaser.Cameras.Scene2D.Effects.Flash#_alpha
|
||||||
|
* @type {number}
|
||||||
|
* @private
|
||||||
|
* @readonly
|
||||||
|
* @since 3.50.0
|
||||||
|
*/
|
||||||
|
this._alpha;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This callback is invoked every frame for the duration of the effect.
|
* This callback is invoked every frame for the duration of the effect.
|
||||||
*
|
*
|
||||||
|
@ -191,8 +201,8 @@ var Flash = new Class({
|
||||||
this.red = red;
|
this.red = red;
|
||||||
this.green = green;
|
this.green = green;
|
||||||
this.blue = blue;
|
this.blue = blue;
|
||||||
this.alpha = 1;
|
|
||||||
|
|
||||||
|
this._alpha = this.alpha;
|
||||||
this._elapsed = 0;
|
this._elapsed = 0;
|
||||||
|
|
||||||
this._onUpdate = callback;
|
this._onUpdate = callback;
|
||||||
|
@ -230,7 +240,7 @@ var Flash = new Class({
|
||||||
|
|
||||||
if (this._elapsed < this.duration)
|
if (this._elapsed < this.duration)
|
||||||
{
|
{
|
||||||
this.alpha = 1 - this.progress;
|
this.alpha = this._alpha * (1 - this.progress);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -304,6 +314,7 @@ var Flash = new Class({
|
||||||
*/
|
*/
|
||||||
effectComplete: function ()
|
effectComplete: function ()
|
||||||
{
|
{
|
||||||
|
this._alpha = this.alpha
|
||||||
this._onUpdate = null;
|
this._onUpdate = null;
|
||||||
this._onUpdateScope = null;
|
this._onUpdateScope = null;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue