mirror of
https://github.com/photonstorm/phaser
synced 2024-11-26 06:30:38 +00:00
Merge pull request #3424 from pixelscripter/master
Added callback methods to Camera2D effects: Shake, Fade and Flash
This commit is contained in:
commit
efc5a12f75
1 changed files with 86 additions and 31 deletions
|
@ -290,6 +290,17 @@ var Camera = new Class({
|
|||
*/
|
||||
this._shakeOffsetY = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Camera#_shakeCallback
|
||||
* @type {function}
|
||||
* @private
|
||||
* @default null
|
||||
* @since 3.3.0
|
||||
*/
|
||||
this._shakeCallback = null;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -345,6 +356,17 @@ var Camera = new Class({
|
|||
*/
|
||||
this._fadeAlpha = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Camera#_fadeCallback
|
||||
* @type {function}
|
||||
* @private
|
||||
* @default null
|
||||
* @since 3.3.0
|
||||
*/
|
||||
this._fadeCallback = null;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -400,6 +422,17 @@ var Camera = new Class({
|
|||
*/
|
||||
this._flashAlpha = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Cameras.Scene2D.Camera#_flashCallback
|
||||
* @type {function}
|
||||
* @private
|
||||
* @default null
|
||||
* @since 3.3.0
|
||||
*/
|
||||
this._flashCallback = null;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -685,10 +718,11 @@ var Camera = new Class({
|
|||
* @param {number} green - [description]
|
||||
* @param {number} blue - [description]
|
||||
* @param {number} force - [description]
|
||||
* @param {function} callback - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
fade: function (duration, red, green, blue, force)
|
||||
fade: function (duration, red, green, blue, force, callback)
|
||||
{
|
||||
if (red === undefined) { red = 0; }
|
||||
if (green === undefined) { green = 0; }
|
||||
|
@ -702,6 +736,7 @@ var Camera = new Class({
|
|||
this._fadeRed = red;
|
||||
this._fadeGreen = green;
|
||||
this._fadeBlue = blue;
|
||||
this._fadeCallback = callback || null;
|
||||
|
||||
if (duration <= 0)
|
||||
{
|
||||
|
@ -725,10 +760,11 @@ var Camera = new Class({
|
|||
* @param {number} green - [description]
|
||||
* @param {number} blue - [description]
|
||||
* @param {number} force - [description]
|
||||
* @param {function} callback - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
flash: function (duration, red, green, blue, force)
|
||||
flash: function (duration, red, green, blue, force, callback)
|
||||
{
|
||||
if (!force && this._flashAlpha > 0.0)
|
||||
{
|
||||
|
@ -742,6 +778,7 @@ var Camera = new Class({
|
|||
this._flashRed = red;
|
||||
this._flashGreen = green;
|
||||
this._flashBlue = blue;
|
||||
this._flashCallback = callback || null;
|
||||
|
||||
if (duration <= 0)
|
||||
{
|
||||
|
@ -754,6 +791,37 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#shake
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} duration - [description]
|
||||
* @param {number} intensity - [description]
|
||||
* @param {number} force - [description]
|
||||
* @param {function} callback - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
shake: function (duration, intensity, force, callback)
|
||||
{
|
||||
if (intensity === undefined) { intensity = 0.05; }
|
||||
|
||||
if (!force && (this._shakeOffsetX !== 0 || this._shakeOffsetY !== 0))
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
this._shakeDuration = duration;
|
||||
this._shakeIntensity = intensity;
|
||||
this._shakeOffsetX = 0;
|
||||
this._shakeOffsetY = 0;
|
||||
this._shakeCallback = callback || null;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -1170,35 +1238,6 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#shake
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} duration - [description]
|
||||
* @param {number} intensity - [description]
|
||||
* @param {number} force - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
shake: function (duration, intensity, force)
|
||||
{
|
||||
if (intensity === undefined) { intensity = 0.05; }
|
||||
|
||||
if (!force && (this._shakeOffsetX !== 0 || this._shakeOffsetY !== 0))
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
this._shakeDuration = duration;
|
||||
this._shakeIntensity = intensity;
|
||||
this._shakeOffsetX = 0;
|
||||
this._shakeOffsetY = 0;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -1313,6 +1352,11 @@ var Camera = new Class({
|
|||
{
|
||||
this._flashAlpha = 0.0;
|
||||
}
|
||||
if (this._flashCallback !== null && this._flashAlpha === 0.0)
|
||||
{
|
||||
this._flashCallback();
|
||||
this._flashCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (this._fadeAlpha > 0.0 && this._fadeAlpha < 1.0)
|
||||
|
@ -1323,6 +1367,11 @@ var Camera = new Class({
|
|||
{
|
||||
this._fadeAlpha = 1.0;
|
||||
}
|
||||
if (this._fadeCallback !== null && this._fadeAlpha === 1.0)
|
||||
{
|
||||
this._fadeCallback();
|
||||
this._fadeCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (this._shakeDuration > 0.0)
|
||||
|
@ -1335,6 +1384,12 @@ var Camera = new Class({
|
|||
{
|
||||
this._shakeOffsetX = 0.0;
|
||||
this._shakeOffsetY = 0.0;
|
||||
|
||||
if (this._shakeCallback !== null)
|
||||
{
|
||||
this._shakeCallback();
|
||||
this._shakeCallback = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue