Skip to content

Commit

Permalink
Removed the FX project as it's no longer needed and tidied up the bui…
Browse files Browse the repository at this point in the history
…ld folder.
  • Loading branch information
photonstorm committed Aug 6, 2013
1 parent 1195481 commit a7873a3
Show file tree
Hide file tree
Showing 50 changed files with 580 additions and 76,519 deletions.
32 changes: 0 additions & 32 deletions GruntFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,6 @@ module.exports = function (grunt) {
comments: true
}
},
//tests: {
// src: ['Tests/**/*.ts'],
// options: {
// target: 'ES5',
// declaration: true,
// comments: true
// }
// }
//fx: {
// src: ['SpecialFX/**/*.ts'],
// dest: 'build/phaser-fx.js',
// options: {
// target: 'ES5',
// declaration: true,
// comments: true
// }
//}
},
copy: {
main: {
Expand All @@ -76,12 +59,6 @@ module.exports = function (grunt) {
dest: 'Tests/phaser.js'
}]
},
fx: {
files: [{
src: 'build/phaser-fx.js',
dest: 'Tests/phaser-fx.js'
}]
},
mainAmd: {
files: [{
src: 'build/phaser.js',
Expand All @@ -91,15 +68,6 @@ module.exports = function (grunt) {
processContent: wrapPhaserInUmd
}
},
fxAmd: {
files: [{
src: 'build/phaser-fx.js',
dest: 'build/phaser-fx.amd.js'
}],
options: {
processContent: wrapAddonInUmd
}
}
},
watch: {
files: '**/*.ts',
Expand Down
48 changes: 48 additions & 0 deletions Plugins/CameraFX/Border.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
var __extends = this.__extends || function (d, b) {
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Phaser;
(function (Phaser) {
(function (Plugins) {
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/core/Plugin.ts" />
/**
* Phaser - Plugins - Camera FX - Border
*
* Creates a border around a camera.
*/
(function (CameraFX) {
var Border = (function (_super) {
__extends(Border, _super);
function Border(game, parent) {
_super.call(this, game, parent);
/**
* Whether render border of this camera or not. (default is false)
* @type {boolean}
*/
this.showBorder = false;
/**
* Color of border of this camera. (in css color string)
* @type {string}
*/
this.borderColor = 'rgb(255,255,255)';
this.camera = parent;
}
Border.prototype.postRender = function () {
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();
}
};
return Border;
})(Phaser.Plugin);
CameraFX.Border = Border;
})(Plugins.CameraFX || (Plugins.CameraFX = {}));
var CameraFX = Plugins.CameraFX;
})(Phaser.Plugins || (Phaser.Plugins = {}));
var Plugins = Phaser.Plugins;
})(Phaser || (Phaser = {}));
49 changes: 49 additions & 0 deletions Plugins/CameraFX/Border.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/// <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 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)';

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();
}

}

}

}
80 changes: 80 additions & 0 deletions Plugins/CameraFX/Fade.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
var __extends = this.__extends || function (d, b) {
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Phaser;
(function (Phaser) {
(function (Plugins) {
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/core/Plugin.ts" />
/**
* Phaser - Plugins - Camera FX - Fade
*
* The camera is filled with the given color and returns to normal at the given duration.
*/
(function (CameraFX) {
var Fade = (function (_super) {
__extends(Fade, _super);
function Fade(game, parent) {
_super.call(this, game, parent);
this._fxFadeComplete = null;
this._fxFadeDuration = 0;
this._fxFadeAlpha = 0;
this.camera = parent;
}
Fade.prototype.start = /**
* The camera is gradually filled with this color.
*
* @param Color The color you want to use in 0xRRGGBB format, i.e. 0xffffff for white.
* @param Duration How long it takes for the flash to fade.
* @param OnComplete An optional function you want to run when the flash finishes. Set to null for no callback.
* @param Force Force an already running flash effect to reset.
*/
function (color, duration, onComplete, force) {
if (typeof color === "undefined") { color = 0x000000; }
if (typeof duration === "undefined") { duration = 1; }
if (typeof onComplete === "undefined") { onComplete = null; }
if (typeof force === "undefined") { force = false; }
if(force === false && this._fxFadeAlpha > 0) {
// You can't fade again unless you force it
return;
}
if(duration <= 0) {
duration = 1;
}
var red = color >> 16 & 0xFF;
var green = color >> 8 & 0xFF;
var blue = color & 0xFF;
this._fxFadeColor = 'rgba(' + red + ',' + green + ',' + blue + ',';
this._fxFadeDuration = duration;
this._fxFadeAlpha = 0.01;
this._fxFadeComplete = onComplete;
};
Fade.prototype.postUpdate = function () {
// Update the Fade effect
if(this._fxFadeAlpha > 0) {
this._fxFadeAlpha += this.game.time.elapsed / this._fxFadeDuration;
if(this.game.math.roundTo(this._fxFadeAlpha, -2) >= 1) {
this._fxFadeAlpha = 1;
if(this._fxFadeComplete !== null) {
this._fxFadeComplete();
}
}
}
};
Fade.prototype.postRender = function () {
// "Fade" FX
if(this._fxFadeAlpha > 0) {
this.game.stage.context.fillStyle = this._fxFadeColor + this._fxFadeAlpha + ')';
this.game.stage.context.fillRect(this.camera.screenView.x, this.camera.screenView.y, this.camera.width, this.camera.height);
}
};
return Fade;
})(Phaser.Plugin);
CameraFX.Fade = Fade;
})(Plugins.CameraFX || (Plugins.CameraFX = {}));
var CameraFX = Plugins.CameraFX;
})(Phaser.Plugins || (Phaser.Plugins = {}));
var Plugins = Phaser.Plugins;
})(Phaser || (Phaser = {}));
26 changes: 14 additions & 12 deletions SpecialFX/Camera/Fade.ts → Plugins/CameraFX/Fade.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
/// <reference path="../../build/phaser.d.ts" />
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/core/Plugin.ts" />

/**
* Phaser - FX - Camera - Fade
* Phaser - Plugins - Camera FX - Fade
*
* The camera is filled with the given color and returns to normal at the given duration.
*/

module Phaser.FX.Camera {
module Phaser.Plugins.CameraFX {

export class Fade {
export class Fade extends Phaser.Plugin {

constructor(game: Game) {
constructor(game: Phaser.Game, parent) {

this._game = game;
super(game, parent);
this.camera = parent;

}

private _game: Game;
public camera: Phaser.Camera;

private _fxFadeColor: string;
private _fxFadeComplete = null;
Expand Down Expand Up @@ -60,9 +62,9 @@ module Phaser.FX.Camera {
// Update the Fade effect
if (this._fxFadeAlpha > 0)
{
this._fxFadeAlpha += this._game.time.elapsed / this._fxFadeDuration;
this._fxFadeAlpha += this.game.time.elapsed / this._fxFadeDuration;

if (this._game.math.roundTo(this._fxFadeAlpha, -2) >= 1)
if (this.game.math.roundTo(this._fxFadeAlpha, -2) >= 1)
{
this._fxFadeAlpha = 1;

Expand All @@ -75,13 +77,13 @@ module Phaser.FX.Camera {

}

public postRender(camera: Phaser.Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
public postRender() {

// "Fade" FX
if (this._fxFadeAlpha > 0)
{
this._game.stage.context.fillStyle = this._fxFadeColor + this._fxFadeAlpha + ')';
this._game.stage.context.fillRect(cameraX, cameraY, cameraWidth, cameraHeight);
this.game.stage.context.fillStyle = this._fxFadeColor + this._fxFadeAlpha + ')';
this.game.stage.context.fillRect(this.camera.screenView.x, this.camera.screenView.y, this.camera.width, this.camera.height);
}

}
Expand Down
79 changes: 79 additions & 0 deletions Plugins/CameraFX/Flash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
var __extends = this.__extends || function (d, b) {
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Phaser;
(function (Phaser) {
(function (Plugins) {
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/core/Plugin.ts" />
/**
* Phaser - Plugins - Camera FX - Flash
*
* The camera is filled with the given color and returns to normal at the given duration.
*/
(function (CameraFX) {
var Flash = (function (_super) {
__extends(Flash, _super);
function Flash(game, parent) {
_super.call(this, game, parent);
this._fxFlashComplete = null;
this._fxFlashDuration = 0;
this._fxFlashAlpha = 0;
this.camera = parent;
}
Flash.prototype.start = /**
* The camera is filled with this color and returns to normal at the given duration.
*
* @param Color The color you want to use in 0xRRGGBB format, i.e. 0xffffff for white.
* @param Duration How long it takes for the flash to fade.
* @param OnComplete An optional function you want to run when the flash finishes. Set to null for no callback.
* @param Force Force an already running flash effect to reset.
*/
function (color, duration, onComplete, force) {
if (typeof color === "undefined") { color = 0xffffff; }
if (typeof duration === "undefined") { duration = 1; }
if (typeof onComplete === "undefined") { onComplete = null; }
if (typeof force === "undefined") { force = false; }
if(force === false && this._fxFlashAlpha > 0) {
// You can't flash again unless you force it
return;
}
if(duration <= 0) {
duration = 1;
}
var red = color >> 16 & 0xFF;
var green = color >> 8 & 0xFF;
var blue = color & 0xFF;
this._fxFlashColor = 'rgba(' + red + ',' + green + ',' + blue + ',';
this._fxFlashDuration = duration;
this._fxFlashAlpha = 1;
this._fxFlashComplete = onComplete;
};
Flash.prototype.postUpdate = function () {
// Update the Flash effect
if(this._fxFlashAlpha > 0) {
this._fxFlashAlpha -= this.game.time.elapsed / this._fxFlashDuration;
if(this.game.math.roundTo(this._fxFlashAlpha, -2) <= 0) {
this._fxFlashAlpha = 0;
if(this._fxFlashComplete !== null) {
this._fxFlashComplete();
}
}
}
};
Flash.prototype.postRender = function () {
if(this._fxFlashAlpha > 0) {
this.game.stage.context.fillStyle = this._fxFlashColor + this._fxFlashAlpha + ')';
this.game.stage.context.fillRect(this.camera.screenView.x, this.camera.screenView.y, this.camera.width, this.camera.height);
}
};
return Flash;
})(Phaser.Plugin);
CameraFX.Flash = Flash;
})(Plugins.CameraFX || (Plugins.CameraFX = {}));
var CameraFX = Plugins.CameraFX;
})(Phaser.Plugins || (Phaser.Plugins = {}));
var Plugins = Phaser.Plugins;
})(Phaser || (Phaser = {}));
Loading

0 comments on commit a7873a3

Please sign in to comment.