Files
phaser/SpecialFX/Camera/Border.ts
T

62 lines
1.7 KiB
TypeScript

/// <reference path="../../Phaser/Game.d.ts" />
/// <reference path="../../Phaser/system/Camera.d.ts" />
/// <reference path="../../Phaser/FXManager.d.ts" />
/**
* Phaser - FX - Camera - Border
*
* Creates a border around a camera.
*/
module Phaser.FX.Camera {
export class Border {
constructor(game: Game, parent: Camera) {
this._game = game;
this._parent = parent;
}
private _game: Game;
private _parent: Camera;
/**
* Whether render border of this camera or not. (default is false)
* @type {boolean}
*/
public showBorder: bool = false;
/**
* Color of border of this camera. (in css color string)
* @type {string}
*/
public borderColor: string = 'rgb(255,255,255)';
/**
* You can name the function that starts the effect whatever you like, but we used 'start' in our effects.
*/
public start() {
}
/**
* Post-render is called during the objects render cycle, after the children/image data has been rendered.
* It happens directly BEFORE a canvas context.restore has happened if added to a Camera.
*/
public postRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
if (this.showBorder == true)
{
this._game.stage.context.strokeStyle = this.borderColor;
this._game.stage.context.lineWidth = 1;
this._game.stage.context.rect(this._sx, this._sy, this.worldView.width, this.worldView.height);
this._game.stage.context.stroke();
}
}
}
}