phaser/wip/CameraFX/Border.ts
2013-09-13 16:24:01 +01:00

49 lines
1.2 KiB
TypeScript

/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/core/Plugin.ts" />
/**
* Phaser - Plugins - Camera FX - Border
*
* Creates a border around a camera.
*/
module Phaser.Plugins.CameraFX {
export class Border extends Phaser.Plugin {
constructor(game: Phaser.Game, parent) {
super(game, parent);
this.camera = parent;
}
public camera: Phaser.Camera;
/**
* Whether render border of this camera or not. (default is true)
* @type {bool}
*/
public showBorder: bool = true;
/**
* Color of border of this camera. (in css color string)
* @type {string}
*/
public borderColor: string = 'rgb(255,255,255)';
public postRender() {
if (this.showBorder == true)
{
this.game.stage.context.strokeStyle = this.borderColor;
this.game.stage.context.lineWidth = 1;
this.game.stage.context.rect(this.camera.x, this.camera.y, this.camera.width, this.camera.height);
this.game.stage.context.stroke();
}
}
}
}