Skip to content

Commit 00a3f71

Browse files
committed
Modified camera effect durations and prevented callbacks from being overwritten
1 parent 490aa28 commit 00a3f71

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

src/cameras/2d/Camera.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ var Camera = new Class({
724724
*/
725725
fade: function (duration, red, green, blue, force, callback)
726726
{
727-
if (!duration) { duration = 0; }
727+
if (!duration) { duration = Number.MIN_VALUE; }
728728
if (red === undefined) { red = 0; }
729729
if (green === undefined) { green = 0; }
730730
if (blue === undefined) { blue = 0; }
@@ -741,7 +741,7 @@ var Camera = new Class({
741741
this._fadeBlue = blue;
742742
this._fadeCallback = callback;
743743
this._fadeDuration = duration;
744-
this._fadeAlpha = 0;
744+
this._fadeAlpha = Number.MIN_VALUE;
745745

746746
return this;
747747
},
@@ -763,7 +763,7 @@ var Camera = new Class({
763763
*/
764764
flash: function (duration, red, green, blue, force, callback)
765765
{
766-
if (!duration) { duration = 0; }
766+
if (!duration) { duration = Number.MIN_VALUE; }
767767
if (red === undefined) { red = 1; }
768768
if (green === undefined) { green = 1; }
769769
if (blue === undefined) { blue = 1; }
@@ -800,7 +800,7 @@ var Camera = new Class({
800800
*/
801801
shake: function (duration, intensity, force, callback)
802802
{
803-
if (!duration) { duration = 0; }
803+
if (!duration) { duration = Number.MIN_VALUE; }
804804
if (intensity === undefined) { intensity = 0.05; }
805805
if (force === undefined) { force = false; }
806806
if (callback === undefined) { callback = null; }
@@ -1350,9 +1350,12 @@ var Camera = new Class({
13501350

13511351
if (this._flashCallback)
13521352
{
1353-
this._flashCallback(this);
1353+
// Do this in case the callback flashes again (otherwise we'd overwrite the new callback)
1354+
var flashCallback = this._flashCallback;
13541355

13551356
this._flashCallback = null;
1357+
1358+
flashCallback(this);
13561359
}
13571360
}
13581361
}
@@ -1367,9 +1370,12 @@ var Camera = new Class({
13671370

13681371
if (this._fadeCallback)
13691372
{
1370-
this._fadeCallback(this);
1373+
// Do this in case the callback flashes again (otherwise we'd overwrite the new callback)
1374+
var fadeCallback = this._fadeCallback;
13711375

13721376
this._fadeCallback = null;
1377+
1378+
fadeCallback(this);
13731379
}
13741380
}
13751381
}
@@ -1387,9 +1393,12 @@ var Camera = new Class({
13871393

13881394
if (this._shakeCallback)
13891395
{
1390-
this._shakeCallback(this);
1396+
// Do this in case the callback flashes again (otherwise we'd overwrite the new callback)
1397+
var shakeCallback = this._shakeCallback;
13911398

13921399
this._shakeCallback = null;
1400+
1401+
shakeCallback(this);
13931402
}
13941403
}
13951404
else

0 commit comments

Comments
 (0)