forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScanlines.ts
38 lines (25 loc) · 896 Bytes
/
Scanlines.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/core/Plugin.ts" />
/**
* Phaser - Plugins - Camera FX - Scanlines
*
* Give your game that classic retro feel!
*/
module Phaser.Plugins.CameraFX {
export class Scanlines extends Phaser.Plugin {
constructor(game: Phaser.Game, parent) {
super(game, parent);
this.camera = parent;
}
public camera: Phaser.Camera;
public spacing: number = 4;
public color: string = 'rgba(0, 0, 0, 0.3)';
public postRender() {
this.game.stage.context.fillStyle = this.color;
for (var y = this.camera.screenView.y; y < this.camera.screenView.height; y += this.spacing)
{
this.game.stage.context.fillRect(this.camera.screenView.x, y, this.camera.screenView.width, 1);
}
}
}
}