You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Camera.flash is a new function that makes the camera 'flash' over the top of your game. It works by filling the game with the solid fill color specified, and then fading it away to alpha 0 over the duration given. This is great for things like hit effects. You can listen for the Camera.onflashComplete Signal.
Camera.fade is a new function that makes the camera fade to the color given, over the course of the duration specified. This is great for things like transitioning from one State to another. You can listen for the Camera.onFadeComplete Signal.
Camera.resetFX resets any active FX, such as a fade or flash and immediately clears it. Useful to calling after a fade in order to remove the fade from the Stage.
Phaser.Camera.ENABLE_FX is a const that controls if the Camera FX are available or not. It's `true` by default, but if you set it to `false` before boot then it won't create the Graphics object required to process the effects.
Copy file name to clipboardExpand all lines: README.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -332,6 +332,10 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
332
332
* You can now pass a TilemapLayer as a Texture to a TileSprite. A limitation of this is that if you pass it to a TileSprite it will make a fill pattern from the TilemapLayer at that instant it's passed, and it won't keep track of the layer in future should it update (thanks @jdnichollsc#1989)
333
333
* Camera has a new property: `lerp`. This is a Point object, that allows you to control the amount of horizontal and vertical smoothing to be applied to the camera when it tracks a Sprite. It works both with and without deadzones, and is turned off by default. Set it to low values such as 0.1 for really smooth motion tracking (thanks to @WombatTurkey for the idea of adding this)
334
334
* Camera.shake is a new function that creates a camera shake effect. You can specify the intensity, duration and direction of the effect. You can also set if it should shake the camera out of bounds or not.
335
+
* Camera.flash is a new function that makes the camera 'flash' over the top of your game. It works by filling the game with the solid fill color specified, and then fading it away to alpha 0 over the duration given. This is great for things like hit effects. You can listen for the Camera.onflashComplete Signal.
336
+
* Camera.fade is a new function that makes the camera fade to the color given, over the course of the duration specified. This is great for things like transitioning from one State to another. You can listen for the Camera.onFadeComplete Signal.
337
+
* Camera.resetFX resets any active FX, such as a fade or flash and immediately clears it. Useful to calling after a fade in order to remove the fade from the Stage.
338
+
* Phaser.Camera.ENABLE_FX is a const that controls if the Camera FX are available or not. It's `true` by default, but if you set it to `false` before boot then it won't create the Graphics object required to process the effects.
* Camera preUpdate. Sets the total view counter to zero.
198
260
*
@@ -298,7 +360,7 @@ Phaser.Camera.prototype = {
298
360
* spacing on the x and y axis each frame. You can control the intensity and duration
299
361
* of the effect, and if it should effect both axis or just one.
300
362
*
301
-
* When the shake effect ends the signal Camera.shakeOnComplete is dispatched.
363
+
* When the shake effect ends the signal Camera.onShakeComplete is dispatched.
302
364
*
303
365
* @method Phaser.Camera#shake
304
366
* @param {float} [intensity=0.05] - The intensity of the camera shake. Given as a percentage of the camera size representing the maximum distance that the camera can move while shaking.
@@ -336,6 +398,91 @@ Phaser.Camera.prototype = {
336
398
337
399
},
338
400
401
+
/**
402
+
* This creates a camera flash effect. It works by filling the game with the solid fill
403
+
* color specified, and then fading it away to alpha 0 over the duration given.
404
+
*
405
+
* You can use this for things such as hit feedback effects.
406
+
*
407
+
* When the effect ends the signal Camera.onFlashComplete is dispatched.
408
+
*
409
+
* @method Phaser.Camera#flash
410
+
* @param {numer} [color=0xffffff] - The color of the flash effect. I.e. 0xffffff for white, 0xff0000 for red, etc.
411
+
* @param {number} [duration=500] - The duration of the flash effect in milliseconds.
412
+
* @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
+
* @return {boolean} True if the effect was started, otherwise false.
414
+
*/
415
+
flash: function(color,duration,force){
416
+
417
+
if(color===undefined){color=0xffffff;}
418
+
if(duration===undefined){duration=500;}
419
+
if(force===undefined){force=false;}
420
+
421
+
if(!this.fx||(!force&&this._fxDuration>0))
422
+
{
423
+
returnfalse;
424
+
}
425
+
426
+
this.fx.clear();
427
+
428
+
this.fx.beginFill(color);
429
+
this.fx.drawRect(0,0,this.width,this.height);
430
+
this.fx.endFill();
431
+
432
+
this.fx.alpha=1;
433
+
434
+
this._fxDuration=duration;
435
+
this._fxType=0;
436
+
437
+
returntrue;
438
+
439
+
},
440
+
441
+
/**
442
+
* This creates a camera fade effect. It works by filling the game with the
443
+
* color specified, over the duration given, ending with a solid fill.
444
+
*
445
+
* You can use this for things such as transitioning to a new scene.
446
+
*
447
+
* The game will be left 'filled' at the end of this effect, likely obscuring
448
+
* everything. In order to reset it you can call `Camera.resetFX` and it will clear the
449
+
* fade. Or you can call `Camera.flash` with the same color as the fade, and it will
450
+
* reverse the process, bringing the game back into view again.
451
+
*
452
+
* When the effect ends the signal Camera.onFadeComplete is dispatched.
453
+
*
454
+
* @method Phaser.Camera#fade
455
+
* @param {numer} [color=0x000000] - The color the game will fade to. I.e. 0x000000 for black, 0xff0000 for red, etc.
456
+
* @param {number} [duration=500] - The duration of the fade in milliseconds.
457
+
* @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.
458
+
* @return {boolean} True if the effect was started, otherwise false.
459
+
*/
460
+
fade: function(color,duration,force){
461
+
462
+
if(color===undefined){color=0x000000;}
463
+
if(duration===undefined){duration=500;}
464
+
if(force===undefined){force=false;}
465
+
466
+
if(!this.fx||(!force&&this._fxDuration>0))
467
+
{
468
+
returnfalse;
469
+
}
470
+
471
+
this.fx.clear();
472
+
473
+
this.fx.beginFill(color);
474
+
this.fx.drawRect(0,0,this.width,this.height);
475
+
this.fx.endFill();
476
+
477
+
this.fx.alpha=0;
478
+
479
+
this._fxDuration=duration;
480
+
this._fxType=1;
481
+
482
+
returntrue;
483
+
484
+
},
485
+
339
486
/**
340
487
* The camera update loop. This is called automatically by the core game loop.
0 commit comments