yuidoc scripts added. Tidied up the Docs folder. Added back in the Emitter and fixed the Tests that weren't compiling.

This commit is contained in:
Richard Davey
2013-08-09 05:08:54 +01:00
parent 9bf7d070f5
commit 2d49a31ecd
182 changed files with 8444 additions and 991 deletions
+4 -3
View File
@@ -1,4 +1,5 @@
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
@@ -17,7 +18,7 @@ var Phaser;
var Border = (function (_super) {
__extends(Border, _super);
function Border(game, parent) {
_super.call(this, game, parent);
_super.call(this, game, parent);
/**
* Whether render border of this camera or not. (default is true)
* @type {boolean}
@@ -31,7 +32,7 @@ var Phaser;
this.camera = parent;
}
Border.prototype.postRender = function () {
if(this.showBorder == true) {
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);
@@ -40,7 +41,7 @@ var Phaser;
};
return Border;
})(Phaser.Plugin);
CameraFX.Border = Border;
CameraFX.Border = Border;
})(Plugins.CameraFX || (Plugins.CameraFX = {}));
var CameraFX = Plugins.CameraFX;
})(Phaser.Plugins || (Phaser.Plugins = {}));
+18 -12
View File
@@ -1,4 +1,5 @@
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
@@ -17,13 +18,13 @@ var Phaser;
var Fade = (function (_super) {
__extends(Fade, _super);
function Fade(game, parent) {
_super.call(this, 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.
@@ -31,48 +32,53 @@ var Phaser;
* @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) {
Fade.prototype.start = 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) {
if (force === false && this._fxFadeAlpha > 0) {
// You can't fade again unless you force it
return;
}
if(duration <= 0) {
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) {
if (this._fxFadeAlpha > 0) {
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;
if(this._fxFadeComplete !== null) {
if (this._fxFadeComplete !== null) {
this._fxFadeComplete();
}
}
}
};
Fade.prototype.postRender = function () {
// "Fade" FX
if(this._fxFadeAlpha > 0) {
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;
CameraFX.Fade = Fade;
})(Plugins.CameraFX || (Plugins.CameraFX = {}));
var CameraFX = Plugins.CameraFX;
})(Phaser.Plugins || (Phaser.Plugins = {}));
+18 -11
View File
@@ -1,4 +1,5 @@
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
@@ -17,13 +18,13 @@ var Phaser;
var Flash = (function (_super) {
__extends(Flash, _super);
function Flash(game, parent) {
_super.call(this, 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.
@@ -31,47 +32,53 @@ var Phaser;
* @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) {
Flash.prototype.start = 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) {
if (force === false && this._fxFlashAlpha > 0) {
// You can't flash again unless you force it
return;
}
if(duration <= 0) {
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) {
if (this._fxFlashAlpha > 0) {
this._fxFlashAlpha -= this.game.time.elapsed / this._fxFlashDuration;
if(this.game.math.roundTo(this._fxFlashAlpha, -2) <= 0) {
if (this.game.math.roundTo(this._fxFlashAlpha, -2) <= 0) {
this._fxFlashAlpha = 0;
if(this._fxFlashComplete !== null) {
if (this._fxFlashComplete !== null) {
this._fxFlashComplete();
}
}
}
};
Flash.prototype.postRender = function () {
if(this._fxFlashAlpha > 0) {
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;
CameraFX.Flash = Flash;
})(Plugins.CameraFX || (Plugins.CameraFX = {}));
var CameraFX = Plugins.CameraFX;
})(Phaser.Plugins || (Phaser.Plugins = {}));
+24 -13
View File
@@ -1,4 +1,5 @@
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
@@ -17,66 +18,76 @@ var Phaser;
var Mirror = (function (_super) {
__extends(Mirror, _super);
function Mirror(game, parent) {
_super.call(this, game, parent);
_super.call(this, game, parent);
this._mirrorColor = null;
this.flipX = false;
this.flipY = true;
this.cls = false;
this.camera = parent;
this._canvas = document.createElement('canvas');
this._canvas.width = parent.width;
this._canvas.height = parent.height;
this._context = this._canvas.getContext('2d');
}
Mirror.prototype.start = /**
/**
* This is the rectangular region to grab from the Camera used in the Mirror effect
* It is rendered to the Stage at Mirror.x/y (note the use of Stage coordinates, not World coordinates)
*/
function (x, y, region, fillColor) {
Mirror.prototype.start = function (x, y, region, fillColor) {
if (typeof fillColor === "undefined") { fillColor = 'rgba(0, 0, 100, 0.5)'; }
this.x = x;
this.y = y;
this._mirrorX = region.x;
this._mirrorY = region.y;
this._mirrorWidth = region.width;
this._mirrorHeight = region.height;
if(fillColor) {
if (fillColor) {
this._mirrorColor = fillColor;
this._context.fillStyle = this._mirrorColor;
}
};
Mirror.prototype.postRender = function () {
this._sx = this.camera.screenView.x + this._mirrorX;
this._sy = this.camera.screenView.y + this._mirrorY;
if(this.flipX == true && this.flipY == false) {
if (this.flipX == true && this.flipY == false) {
this._sx = 0;
} else if(this.flipY == true && this.flipX == false) {
} else if (this.flipY == true && this.flipX == false) {
this._sy = 0;
}
this._context.drawImage(this.game.stage.canvas, this._sx, this._sy, this._mirrorWidth, this._mirrorHeight, 0, 0, this._mirrorWidth, this._mirrorHeight);
if(this._mirrorColor) {
if (this._mirrorColor) {
this._context.fillRect(0, 0, this._mirrorWidth, this._mirrorHeight);
}
if(this.flipX || this.flipY) {
if (this.flipX || this.flipY) {
this.game.stage.context.save();
}
if(this.flipX && this.flipY) {
if (this.flipX && this.flipY) {
this.game.stage.context.transform(-1, 0, 0, -1, this._mirrorWidth, this._mirrorHeight);
this.game.stage.context.drawImage(this._canvas, -this.x, -this.y);
} else if(this.flipX) {
} else if (this.flipX) {
this.game.stage.context.transform(-1, 0, 0, 1, this._mirrorWidth, 0);
this.game.stage.context.drawImage(this._canvas, -this.x, this.y);
} else if(this.flipY) {
} else if (this.flipY) {
this.game.stage.context.transform(1, 0, 0, -1, 0, this._mirrorHeight);
this.game.stage.context.drawImage(this._canvas, this.x, -this.y);
}
if(this.flipX || this.flipY) {
if (this.flipX || this.flipY) {
this.game.stage.context.restore();
}
};
return Mirror;
})(Phaser.Plugin);
CameraFX.Mirror = Mirror;
CameraFX.Mirror = Mirror;
})(Plugins.CameraFX || (Plugins.CameraFX = {}));
var CameraFX = Plugins.CameraFX;
})(Phaser.Plugins || (Phaser.Plugins = {}));
+5 -3
View File
@@ -1,4 +1,5 @@
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
@@ -17,20 +18,21 @@ var Phaser;
var Scanlines = (function (_super) {
__extends(Scanlines, _super);
function Scanlines(game, parent) {
_super.call(this, game, parent);
_super.call(this, game, parent);
this.spacing = 4;
this.color = 'rgba(0, 0, 0, 0.3)';
this.camera = parent;
}
Scanlines.prototype.postRender = function () {
this.game.stage.context.fillStyle = this.color;
for(var y = this.camera.screenView.y; y < this.camera.screenView.height; y += this.spacing) {
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);
}
};
return Scanlines;
})(Phaser.Plugin);
CameraFX.Scanlines = Scanlines;
CameraFX.Scanlines = Scanlines;
})(Plugins.CameraFX || (Plugins.CameraFX = {}));
var CameraFX = Plugins.CameraFX;
})(Phaser.Plugins || (Phaser.Plugins = {}));
+10 -10
View File
@@ -1,4 +1,5 @@
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
@@ -17,7 +18,7 @@ var Phaser;
var Shadow = (function (_super) {
__extends(Shadow, _super);
function Shadow(game, parent) {
_super.call(this, game, parent);
_super.call(this, game, parent);
/**
* Render camera shadow or not. (default is false)
* @type {boolean}
@@ -40,25 +41,24 @@ var Phaser;
this.shadowOffset = new Phaser.Point(4, 4);
this.camera = parent;
}
Shadow.prototype.preRender = /**
/**
* Pre-render is called at the start of the object render cycle, before any transforms have taken place.
* It happens directly AFTER a canvas context.save has happened if added to a Camera.
*/
function () {
// Shadow
if(this.showShadow == true) {
Shadow.prototype.preRender = function () {
if (this.showShadow == true) {
this.game.stage.context.shadowColor = this.shadowColor;
this.game.stage.context.shadowBlur = this.shadowBlur;
this.game.stage.context.shadowOffsetX = this.shadowOffset.x;
this.game.stage.context.shadowOffsetY = this.shadowOffset.y;
}
};
Shadow.prototype.render = /**
/**
* render is called during the objects render cycle, right after all transforms have finished, but before any children/image data is rendered.
*/
function () {
// Shadow off
if(this.showShadow == true) {
Shadow.prototype.render = function () {
if (this.showShadow == true) {
this.game.stage.context.shadowBlur = 0;
this.game.stage.context.shadowOffsetX = 0;
this.game.stage.context.shadowOffsetY = 0;
@@ -66,7 +66,7 @@ var Phaser;
};
return Shadow;
})(Phaser.Plugin);
CameraFX.Shadow = Shadow;
CameraFX.Shadow = Shadow;
})(Plugins.CameraFX || (Plugins.CameraFX = {}));
var CameraFX = Plugins.CameraFX;
})(Phaser.Plugins || (Phaser.Plugins = {}));
+23 -17
View File
@@ -1,4 +1,5 @@
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
@@ -17,7 +18,7 @@ var Phaser;
var Shake = (function (_super) {
__extends(Shake, _super);
function Shake(game, parent) {
_super.call(this, game, parent);
_super.call(this, game, parent);
this._fxShakeIntensity = 0;
this._fxShakeDuration = 0;
this._fxShakeComplete = null;
@@ -27,10 +28,7 @@ var Phaser;
this._fxShakePrevY = 0;
this.camera = parent;
}
Shake.SHAKE_BOTH_AXES = 0;
Shake.SHAKE_HORIZONTAL_ONLY = 1;
Shake.SHAKE_VERTICAL_ONLY = 2;
Shake.prototype.start = /**
/**
* A simple camera shake effect.
*
* @param Intensity Percentage of screen size representing the maximum distance that the screen can move while shaking.
@@ -39,57 +37,65 @@ var Phaser;
* @param Force Force the effect to reset (default = true, unlike flash() and fade()!).
* @param Direction Whether to shake on both axes, just up and down, or just side to side (use class constants SHAKE_BOTH_AXES, SHAKE_VERTICAL_ONLY, or SHAKE_HORIZONTAL_ONLY).
*/
function (intensity, duration, onComplete, force, direction) {
Shake.prototype.start = function (intensity, duration, onComplete, force, direction) {
if (typeof intensity === "undefined") { intensity = 0.05; }
if (typeof duration === "undefined") { duration = 0.5; }
if (typeof onComplete === "undefined") { onComplete = null; }
if (typeof force === "undefined") { force = true; }
if (typeof direction === "undefined") { direction = Shake.SHAKE_BOTH_AXES; }
if(!force && ((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0))) {
if (!force && ((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0))) {
return;
}
// If a shake is not already running we need to store the offsets here
if(this._fxShakeOffset.x == 0 && this._fxShakeOffset.y == 0) {
if (this._fxShakeOffset.x == 0 && this._fxShakeOffset.y == 0) {
this._fxShakePrevX = this.camera.x;
this._fxShakePrevY = this.camera.y;
}
this._fxShakeIntensity = intensity;
this._fxShakeDuration = duration;
this._fxShakeComplete = onComplete;
this._fxShakeDirection = direction;
this._fxShakeOffset.setTo(0, 0);
};
Shake.prototype.postUpdate = function () {
// Update the "shake" special effect
if(this._fxShakeDuration > 0) {
if (this._fxShakeDuration > 0) {
this._fxShakeDuration -= this.game.time.elapsed;
if(this.game.math.roundTo(this._fxShakeDuration, -2) <= 0) {
if (this.game.math.roundTo(this._fxShakeDuration, -2) <= 0) {
this._fxShakeDuration = 0;
this._fxShakeOffset.setTo(0, 0);
this.camera.x = this._fxShakePrevX;
this.camera.y = this._fxShakePrevY;
if(this._fxShakeComplete != null) {
if (this._fxShakeComplete != null) {
this._fxShakeComplete();
}
} else {
if((this._fxShakeDirection == Shake.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Shake.SHAKE_HORIZONTAL_ONLY)) {
if ((this._fxShakeDirection == Shake.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Shake.SHAKE_HORIZONTAL_ONLY)) {
this._fxShakeOffset.x = (this.game.rnd.integer * this._fxShakeIntensity * this.camera.worldView.width * 2 - this._fxShakeIntensity * this.camera.worldView.width);
}
if((this._fxShakeDirection == Shake.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Shake.SHAKE_VERTICAL_ONLY)) {
if ((this._fxShakeDirection == Shake.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Shake.SHAKE_VERTICAL_ONLY)) {
this._fxShakeOffset.y = (this.game.rnd.integer * this._fxShakeIntensity * this.camera.worldView.height * 2 - this._fxShakeIntensity * this.camera.worldView.height);
}
}
}
};
Shake.prototype.preRender = function () {
if((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0)) {
if ((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0)) {
this.camera.x = this._fxShakePrevX + this._fxShakeOffset.x;
this.camera.y = this._fxShakePrevY + this._fxShakeOffset.y;
}
};
Shake.SHAKE_BOTH_AXES = 0;
Shake.SHAKE_HORIZONTAL_ONLY = 1;
Shake.SHAKE_VERTICAL_ONLY = 2;
return Shake;
})(Phaser.Plugin);
CameraFX.Shake = Shake;
CameraFX.Shake = Shake;
})(Plugins.CameraFX || (Plugins.CameraFX = {}));
var CameraFX = Plugins.CameraFX;
})(Phaser.Plugins || (Phaser.Plugins = {}));
+23 -14
View File
@@ -1,4 +1,5 @@
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
@@ -14,55 +15,63 @@ var Phaser;
var Example = (function (_super) {
__extends(Example, _super);
function Example(game, parent) {
_super.call(this, game, parent);
_super.call(this, game, parent);
this.active = true;
this.visible = true;
this.hasPreUpdate = false;
this.hasUpdate = false;
this.hasPostUpdate = false;
this.hasPreRender = false;
this.hasRender = false;
this.hasPostRender = false;
}
Example.prototype.preUpdate = /**
/**
* Pre-update is called at the start of the update cycle, before any other updates have taken place.
* It is only called if active is set to true.
*/
function () {
Example.prototype.preUpdate = function () {
};
Example.prototype.update = /**
/**
* Pre-update is called at the start of the update cycle, after all the core system updates have taken place, but before the world update.
* It is only called if active is set to true.
*/
function () {
Example.prototype.update = function () {
};
Example.prototype.postUpdate = /**
/**
* Post-update is called at the end of the objects update cycle, after other update logic has taken place.
* It is only called if active is set to true.
*/
function () {
Example.prototype.postUpdate = function () {
};
Example.prototype.preRender = /**
/**
* Pre-render is called right before the Game Renderer starts and before any custom preRender callbacks have been run.
* It is only called if visible is set to true.
*/
function () {
Example.prototype.preRender = function () {
};
Example.prototype.render = /**
/**
* Pre-render is called right before the Game Renderer starts and before any custom preRender callbacks have been run.
* It is only called if visible is set to true.
*/
function () {
Example.prototype.render = function () {
};
Example.prototype.postRender = /**
/**
* Post-render is called after every camera and game object has been rendered, also after any custom postRender callbacks have been run.
* It is only called if visible is set to true.
*/
function () {
Example.prototype.postRender = function () {
};
return Example;
})(Phaser.Plugin);
Plugins.Example = Example;
Plugins.Example = Example;
})(Phaser.Plugins || (Phaser.Plugins = {}));
var Plugins = Phaser.Plugins;
})(Phaser || (Phaser = {}));