diff --git a/GruntFile.js b/GruntFile.js index 8750641e..f21c25df 100644 --- a/GruntFile.js +++ b/GruntFile.js @@ -2,7 +2,7 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-typescript'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-copy'); - + grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), typescript: { @@ -14,18 +14,45 @@ module.exports = function (grunt) { } } }, - copy: { - main: { - files: [ - {src: 'build/phaser.js', dest: 'Tests/phaser.js'} - ]} - }, - watch: { + copy: { + main: { + files: [{ + src: 'build/phaser.js', + dest: 'Tests/phaser.js' + }] + }, + amd: { + files: [{ + src: 'build/phaser.js', + dest: 'build/phaser.amd.js' + }], + options: { + processContent: function(content) { + var replacement = [ + '(function (root, factory) {', + ' if (typeof exports === \'object\') {', + ' module.exports = factory();', + ' } else if (typeof define === \'function\' && define.amd) {', + ' define(factory);', + ' } else {', + ' root.Phaser = factory();', + ' }', + '}(this, function () {', + content, + 'return Phaser;', + '}));' + ]; + return replacement.join('\n'); + } + } + } + }, + watch: { files: '**/*.ts', tasks: ['typescript', 'copy'] } }); - + grunt.registerTask('default', ['watch']); - + } diff --git a/Phaser/Collision.ts b/Phaser/Collision.ts index aac18b85..ff1788c2 100644 --- a/Phaser/Collision.ts +++ b/Phaser/Collision.ts @@ -1,6 +1,7 @@ /// /// /// +/// /// /// /// @@ -16,76 +17,124 @@ module Phaser { export class Collision { + /** + * Collision constructor + * @param game A reference to the current Game + */ constructor(game: Game) { this._game = game; } + /** + * Local private reference to Game + */ private _game: Game; + /** + * Flag used to allow GameObjects to collide on their left side + * @type {number} + */ public static LEFT: number = 0x0001; + + /** + * Flag used to allow GameObjects to collide on their right side + * @type {number} + */ public static RIGHT: number = 0x0010; + + /** + * Flag used to allow GameObjects to collide on their top side + * @type {number} + */ public static UP: number = 0x0100; + + /** + * Flag used to allow GameObjects to collide on their bottom side + * @type {number} + */ public static DOWN: number = 0x1000; + + /** + * Flag used with GameObjects to disable collision + * @type {number} + */ public static NONE: number = 0; + + /** + * Flag used to allow GameObjects to collide with a ceiling + * @type {number} + */ public static CEILING: number = Collision.UP; + + /** + * Flag used to allow GameObjects to collide with a floor + * @type {number} + */ public static FLOOR: number = Collision.DOWN; + + /** + * Flag used to allow GameObjects to collide with a wall (same as LEFT+RIGHT) + * @type {number} + */ public static WALL: number = Collision.LEFT | Collision.RIGHT; + + /** + * Flag used to allow GameObjects to collide on any face + * @type {number} + */ public static ANY: number = Collision.LEFT | Collision.RIGHT | Collision.UP | Collision.DOWN; + + /** + * The overlap bias is used when calculating hull overlap before separation - change it if you have especially small or large GameObjects + * @type {number} + */ public static OVERLAP_BIAS: number = 4; - /** - * ------------------------------------------------------------------------------------------- - * Lines - * ------------------------------------------------------------------------------------------- - **/ /** - * Check if the two given Line objects intersect - * @method lineToLine - * @param {Phaser.Line} The first line object to check - * @param {Phaser.Line} The second line object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y - **/ + * Checks for Line to Line intersection and returns an IntersectResult object containing the results of the intersection. + * @param line1 The first Line object to check + * @param line2 The second Line object to check + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ public static lineToLine(line1: Line, line2: Line, output?: IntersectResult = new IntersectResult): IntersectResult { - var denom = (line1.x1 - line1.x2) * (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * (line2.x1 - line2.x2); + var denominator = (line1.x1 - line1.x2) * (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * (line2.x1 - line2.x2); - if (denom !== 0) + if (denominator !== 0) { output.result = true; - output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (line2.x1 - line2.x2) - (line1.x1 - line1.x2) * (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denom; - output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denom; + output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (line2.x1 - line2.x2) - (line1.x1 - line1.x2) * (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denominator; + output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denominator; } return output; } /** - * Check if the Line and Line Segment intersects - * @method lineToLineSegment - * @param {Phaser.Line} The line object to check - * @param {Phaser.Line} The line segment object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y - **/ - public static lineToLineSegment(line1: Line, seg: Line, output?: IntersectResult = new IntersectResult): IntersectResult { + * Checks for Line to Line Segment intersection and returns an IntersectResult object containing the results of the intersection. + * @param line The Line object to check + * @param seg The Line segment object to check + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ + public static lineToLineSegment(line: Line, seg: Line, output?: IntersectResult = new IntersectResult): IntersectResult { - var denom = (line1.x1 - line1.x2) * (seg.y1 - seg.y2) - (line1.y1 - line1.y2) * (seg.x1 - seg.x2); + var denominator = (line.x1 - line.x2) * (seg.y1 - seg.y2) - (line.y1 - line.y2) * (seg.x1 - seg.x2); - if (denom !== 0) + if (denominator !== 0) { - output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (seg.x1 - seg.x2) - (line1.x1 - line1.x2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denom; - output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (seg.y1 - seg.y2) - (line1.y1 - line1.y2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denom; + output.x = ((line.x1 * line.y2 - line.y1 * line.x2) * (seg.x1 - seg.x2) - (line.x1 - line.x2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denominator; + output.y = ((line.x1 * line.y2 - line.y1 * line.x2) * (seg.y1 - seg.y2) - (line.y1 - line.y2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denominator; var maxX = Math.max(seg.x1, seg.x2); var minX = Math.min(seg.x1, seg.x2); var maxY = Math.max(seg.y1, seg.y2); var minY = Math.min(seg.y1, seg.y2); - //if (!(output.x <= maxX && output.x >= minX) || !(output.y <= maxY && output.y >= minY)) if ((output.x <= maxX && output.x >= minX) === true || (output.y <= maxY && output.y >= minY) === true) { output.result = true; @@ -98,24 +147,23 @@ module Phaser { } /** - * Check if the Line and Line Segment intersects - * @method lineToLineSegment - * @param {Phaser.Line} The line object to check - * @param {number} The x1 value - * @param {number} The y1 value - * @param {number} The x2 value - * @param {number} The y2 value - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y - **/ + * Checks for Line to Raw Line Segment intersection and returns the result in the IntersectResult object. + * @param line The Line object to check + * @param x1 The start x coordinate of the raw segment + * @param y1 The start y coordinate of the raw segment + * @param x2 The end x coordinate of the raw segment + * @param y2 The end y coordinate of the raw segment + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ public static lineToRawSegment(line: Line, x1: number, y1: number, x2: number, y2: number, output?: IntersectResult = new IntersectResult): IntersectResult { - var denom = (line.x1 - line.x2) * (y1 - y2) - (line.y1 - line.y2) * (x1 - x2); + var denominator = (line.x1 - line.x2) * (y1 - y2) - (line.y1 - line.y2) * (x1 - x2); - if (denom !== 0) + if (denominator !== 0) { - output.x = ((line.x1 * line.y2 - line.y1 * line.x2) * (x1 - x2) - (line.x1 - line.x2) * (x1 * y2 - y1 * x2)) / denom; - output.y = ((line.x1 * line.y2 - line.y1 * line.x2) * (y1 - y2) - (line.y1 - line.y2) * (x1 * y2 - y1 * x2)) / denom; + output.x = ((line.x1 * line.y2 - line.y1 * line.x2) * (x1 - x2) - (line.x1 - line.x2) * (x1 * y2 - y1 * x2)) / denominator; + output.y = ((line.x1 * line.y2 - line.y1 * line.x2) * (y1 - y2) - (line.y1 - line.y2) * (x1 * y2 - y1 * x2)) / denominator; var maxX = Math.max(x1, x2); var minX = Math.min(x1, x2); @@ -134,21 +182,20 @@ module Phaser { } /** - * Check if the Line and Ray intersects - * @method lineToRay - * @param {Phaser.Line} The Line object to check - * @param {Phaser.Line} The Ray object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y - **/ + * Checks for Line to Ray intersection and returns the result in an IntersectResult object. + * @param line1 The Line object to check + * @param ray The Ray object to check + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ public static lineToRay(line1: Line, ray: Line, output?: IntersectResult = new IntersectResult): IntersectResult { - var denom = (line1.x1 - line1.x2) * (ray.y1 - ray.y2) - (line1.y1 - line1.y2) * (ray.x1 - ray.x2); + var denominator = (line1.x1 - line1.x2) * (ray.y1 - ray.y2) - (line1.y1 - line1.y2) * (ray.x1 - ray.x2); - if (denom !== 0) + if (denominator !== 0) { - output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (ray.x1 - ray.x2) - (line1.x1 - line1.x2) * (ray.x1 * ray.y2 - ray.y1 * ray.x2)) / denom; - output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (ray.y1 - ray.y2) - (line1.y1 - line1.y2) * (ray.x1 * ray.y2 - ray.y1 * ray.x2)) / denom; + output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (ray.x1 - ray.x2) - (line1.x1 - line1.x2) * (ray.x1 * ray.y2 - ray.y1 * ray.x2)) / denominator; + output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (ray.y1 - ray.y2) - (line1.y1 - line1.y2) * (ray.x1 * ray.y2 - ray.y1 * ray.x2)) / denominator; output.result = true; // true unless either of the 2 following conditions are met if (!(ray.x1 >= ray.x2) && output.x < ray.x1) @@ -166,14 +213,14 @@ module Phaser { } + /** - * Check if the Line and Circle intersects - * @method lineToCircle - * @param {Phaser.Line} The Line object to check - * @param {Phaser.Circle} The Circle object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection - **/ + * Check if the Line and Circle objects intersect + * @param line The Line object to check + * @param circle The Circle object to check + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ public static lineToCircle(line: Line, circle: Circle, output?: IntersectResult = new IntersectResult): IntersectResult { // Get a perpendicular line running to the center of the circle @@ -187,17 +234,16 @@ module Phaser { } /** - * Check if the Line intersects each side of the Rectangle - * @method lineToRectangle - * @param {Phaser.Line} The Line object to check - * @param {Phaser.Rectangle} The Rectangle object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection - **/ + * Check if the Line intersects each side of the Rectangle + * @param line The Line object to check + * @param rect The Rectangle object to check + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ public static lineToRectangle(line: Line, rect: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult { // Top of the Rectangle vs the Line - this.lineToRawSegment(line, rect.x, rect.y, rect.right, rect.y, output); + Collision.lineToRawSegment(line, rect.x, rect.y, rect.right, rect.y, output); if (output.result === true) { @@ -205,7 +251,7 @@ module Phaser { } // Left of the Rectangle vs the Line - this.lineToRawSegment(line, rect.x, rect.y, rect.x, rect.bottom, output); + Collision.lineToRawSegment(line, rect.x, rect.y, rect.x, rect.bottom, output); if (output.result === true) { @@ -213,7 +259,7 @@ module Phaser { } // Bottom of the Rectangle vs the Line - this.lineToRawSegment(line, rect.x, rect.bottom, rect.right, rect.bottom, output); + Collision.lineToRawSegment(line, rect.x, rect.bottom, rect.right, rect.bottom, output); if (output.result === true) { @@ -221,29 +267,22 @@ module Phaser { } // Right of the Rectangle vs the Line - this.lineToRawSegment(line, rect.right, rect.y, rect.right, rect.bottom, output); + Collision.lineToRawSegment(line, rect.right, rect.y, rect.right, rect.bottom, output); return output; } /** - * ------------------------------------------------------------------------------------------- - * Line Segment - * ------------------------------------------------------------------------------------------- - **/ - - /** - * Check if Line1 intersects with Line2 - * @method lineSegmentToLineSegment - * @param {Phaser.Line} The first line object to check - * @param {Phaser.Line} The second line object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y - **/ + * Check if the two Line Segments intersect and returns the result in an IntersectResult object. + * @param line1 The first Line Segment to check + * @param line2 The second Line Segment to check + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ public static lineSegmentToLineSegment(line1: Line, line2: Line, output?: IntersectResult = new IntersectResult): IntersectResult { - this.lineToLineSegment(line1, line2, output); + Collision.lineToLineSegment(line1, line2); if (output.result === true) { @@ -258,21 +297,20 @@ module Phaser { } /** - * Check if the Line Segment intersects with the Ray - * @method lineSegmentToRay - * @param {Phaser.Line} The Line object to check - * @param {Phaser.Line} The Line Ray object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y - **/ - public static lineSegmentToRay(line1: Line, ray: Line, output?: IntersectResult = new IntersectResult): IntersectResult { + * Check if the Line Segment intersects with the Ray and returns the result in an IntersectResult object. + * @param line The Line Segment to check. + * @param ray The Ray to check. + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ + public static lineSegmentToRay(line: Line, ray: Line, output?: IntersectResult = new IntersectResult): IntersectResult { - this.lineToRay(line1, ray, output); + Collision.lineToRay(line, ray, output); if (output.result === true) { - if (!(output.x >= Math.min(line1.x1, line1.x2) && output.x <= Math.max(line1.x1, line1.x2) - && output.y >= Math.min(line1.y1, line1.y2) && output.y <= Math.max(line1.y1, line1.y2))) + if (!(output.x >= Math.min(line.x1, line.x2) && output.x <= Math.max(line.x1, line.x2) + && output.y >= Math.min(line.y1, line.y2) && output.y <= Math.max(line.y1, line.y2))) { output.result = false; } @@ -283,13 +321,12 @@ module Phaser { } /** - * Check if the Line Segment intersects with the Circle - * @method lineSegmentToCircle - * @param {Phaser.Line} The Line object to check - * @param {Phaser.Circle} The Circle object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y - **/ + * Check if the Line Segment intersects with the Circle and returns the result in an IntersectResult object. + * @param seg The Line Segment to check. + * @param circle The Circle to check + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ public static lineSegmentToCircle(seg: Line, circle: Circle, output?: IntersectResult = new IntersectResult): IntersectResult { var perp = seg.perp(circle.x, circle.y); @@ -309,7 +346,7 @@ module Phaser { else { // Worst case - segment doesn't traverse center, so no perpendicular connection. - if (this.circleContainsPoint(circle, { x: seg.x1, y: seg.y1 }) || this.circleContainsPoint(circle, { x: seg.x2, y: seg.y2 })) + if (Collision.circleContainsPoint(circle, { x: seg.x1, y: seg.y1 }) || Collision.circleContainsPoint(circle, { x: seg.x2, y: seg.y2 })) { output.result = true; } @@ -321,13 +358,12 @@ module Phaser { } /** - * Check if the Line Segment intersects with the Rectangle - * @method lineSegmentToCircle - * @param {Phaser.Line} The Line object to check - * @param {Phaser.Circle} The Circle object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y - **/ + * Check if the Line Segment intersects with the Rectangle and returns the result in an IntersectResult object. + * @param seg The Line Segment to check. + * @param rect The Rectangle to check. + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ public static lineSegmentToRectangle(seg: Line, rect: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult { if (rect.contains(seg.x1, seg.y1) && rect.contains(seg.x2, seg.y2)) @@ -337,7 +373,7 @@ module Phaser { else { // Top of the Rectangle vs the Line - this.lineToRawSegment(seg, rect.x, rect.y, rect.right, rect.bottom, output); + Collision.lineToRawSegment(seg, rect.x, rect.y, rect.right, rect.bottom, output); if (output.result === true) { @@ -345,7 +381,7 @@ module Phaser { } // Left of the Rectangle vs the Line - this.lineToRawSegment(seg, rect.x, rect.y, rect.x, rect.bottom, output); + Collision.lineToRawSegment(seg, rect.x, rect.y, rect.x, rect.bottom, output); if (output.result === true) { @@ -353,7 +389,7 @@ module Phaser { } // Bottom of the Rectangle vs the Line - this.lineToRawSegment(seg, rect.x, rect.bottom, rect.right, rect.bottom, output); + Collision.lineToRawSegment(seg, rect.x, rect.bottom, rect.right, rect.bottom, output); if (output.result === true) { @@ -361,7 +397,7 @@ module Phaser { } // Right of the Rectangle vs the Line - this.lineToRawSegment(seg, rect.right, rect.y, rect.right, rect.bottom, output); + Collision.lineToRawSegment(seg, rect.right, rect.y, rect.right, rect.bottom, output); return output; @@ -372,63 +408,58 @@ module Phaser { } /** - * ------------------------------------------------------------------------------------------- - * Ray - * ------------------------------------------------------------------------------------------- - **/ - - /** - * Check if the two given Circle objects intersect - * @method circleToCircle - * @param {Phaser.Circle} The first circle object to check - * @param {Phaser.Circle} The second circle object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection - **/ + * Check for Ray to Rectangle intersection and returns the result in an IntersectResult object. + * @param ray The Ray to check. + * @param rect The Rectangle to check. + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ public static rayToRectangle(ray: Line, rect: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult { // Currently just finds first intersection - might not be closest to ray pt1 - this.lineToRectangle(ray, rect, output); + Collision.lineToRectangle(ray, rect, output); return output; } - /** - * Check whether a ray intersects a line segment, returns the parametric value where the intersection occurs. - * @method rayToLineSegment - * @static - * @param {Number} rayx1. The origin x of the ray. - * @param {Number} rayy1. The origin y of the ray. - * @param {Number} rayx2. The direction x of the ray. - * @param {Number} rayy2. The direction y of the ray. - * @param {Number} linex1. The x of the first point of the line segment. - * @param {Number} liney1. The y of the first point of the line segment. - * @param {Number} linex2. The x of the second point of the line segment. - * @param {Number} liney2. The y of the second point of the line segment. - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection stored in x - **/ - public static rayToLineSegment(rayx1, rayy1, rayx2, rayy2, linex1, liney1, linex2, liney2, output?: IntersectResult = new IntersectResult): IntersectResult { - var r, s, d; + /** + * Check whether a Ray intersects a Line segment and returns the parametric value where the intersection occurs in an IntersectResult object. + * @param rayX1 + * @param rayY1 + * @param rayX2 + * @param rayY2 + * @param lineX1 + * @param lineY1 + * @param lineX2 + * @param lineY2 + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ + public static rayToLineSegment(rayX1, rayY1, rayX2, rayY2, lineX1, lineY1, lineX2, lineY2, output?: IntersectResult = new IntersectResult): IntersectResult { + + var r:number; + var s:number; + var d:number; // Check lines are not parallel - if ((rayy2 - rayy1) / (rayx2 - rayx1) != (liney2 - liney1) / (linex2 - linex1)) + if ((rayY2 - rayY1) / (rayX2 - rayX1) != (lineY2 - lineY1) / (lineX2 - lineX1)) { - d = (((rayx2 - rayx1) * (liney2 - liney1)) - (rayy2 - rayy1) * (linex2 - linex1)); + d = (((rayX2 - rayX1) * (lineY2 - lineY1)) - (rayY2 - rayY1) * (lineX2 - lineX1)); if (d != 0) { - r = (((rayy1 - liney1) * (linex2 - linex1)) - (rayx1 - linex1) * (liney2 - liney1)) / d; - s = (((rayy1 - liney1) * (rayx2 - rayx1)) - (rayx1 - linex1) * (rayy2 - rayy1)) / d; + r = (((rayY1 - lineY1) * (lineX2 - lineX1)) - (rayX1 - lineX1) * (lineY2 - lineY1)) / d; + s = (((rayY1 - lineY1) * (rayX2 - rayX1)) - (rayX1 - lineX1) * (rayY2 - rayY1)) / d; if (r >= 0) { if (s >= 0 && s <= 1) { output.result = true; - output.x = rayx1 + r * (rayx2 - rayx1), rayy1 + r * (rayy2 - rayy1); + output.x = rayX1 + r * (rayX2 - rayX1); + output.y = rayY1 + r * (rayY2 - rayY1); } } } @@ -439,19 +470,13 @@ module Phaser { } /** - * ------------------------------------------------------------------------------------------- - * Rectangles - * ------------------------------------------------------------------------------------------- - **/ - - /** - * Determines whether the specified point is contained within the rectangular region defined by the Rectangle object. - * @method pointToRectangle - * @param {Point} point The point object being checked. - * @param {Rectangle} rect The rectangle object being checked. - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y/result - **/ - public static pointToRectangle(point: Point, rect: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult { + * Determines whether the specified point is contained within the rectangular region defined by the Rectangle object and returns the result in an IntersectResult object. + * @param point The Point or MicroPoint object to check, or any object with x and y properties. + * @param rect The Rectangle object to check the point against + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ + public static pointToRectangle(point, rect: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult { output.setTo(point.x, point.y); @@ -462,13 +487,12 @@ module Phaser { } /** - * Check whether two axis aligned rectangles intersect. Return the intersecting rectangle dimensions if they do. - * @method rectangleToRectangle - * @param {Phaser.Rectangle} The first Rectangle object - * @param {Phaser.Rectangle} The second Rectangle object - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y/width/height - **/ + * Check whether two axis aligned Rectangles intersect and returns the intersecting rectangle dimensions in an IntersectResult object if they do. + * @param rect1 The first Rectangle object. + * @param rect2 The second Rectangle object. + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ public static rectangleToRectangle(rect1: Rectangle, rect2: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult { var leftX = Math.max(rect1.x, rect2.x); @@ -490,42 +514,41 @@ module Phaser { } + /** + * Checks if the Rectangle and Circle objects intersect and returns the result in an IntersectResult object. + * @param rect The Rectangle object to check + * @param circle The Circle object to check + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ public static rectangleToCircle(rect: Rectangle, circle: Circle, output?: IntersectResult = new IntersectResult): IntersectResult { - return this.circleToRectangle(circle, rect, output); + return Collision.circleToRectangle(circle, rect, output); } /** - * ------------------------------------------------------------------------------------------- - * Circle - * ------------------------------------------------------------------------------------------- - **/ - - /** - * Check if the two given Circle objects intersect - * @method circleToCircle - * @param {Phaser.Circle} The first circle object to check - * @param {Phaser.Circle} The second circle object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection - **/ + * Checks if the two Circle objects intersect and returns the result in an IntersectResult object. + * @param circle1 The first Circle object to check + * @param circle2 The second Circle object to check + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ public static circleToCircle(circle1: Circle, circle2: Circle, output?: IntersectResult = new IntersectResult): IntersectResult { - output.result = ((circle1.radius + circle2.radius) * (circle1.radius + circle2.radius)) >= this.distanceSquared(circle1.x, circle1.y, circle2.x, circle2.y); + output.result = ((circle1.radius + circle2.radius) * (circle1.radius + circle2.radius)) >= Collision.distanceSquared(circle1.x, circle1.y, circle2.x, circle2.y); return output; } /** - * Check if the given Rectangle intersects with the given Circle - * @method circleToRectangle - * @param {Phaser.Circle} The circle object to check - * @param {Phaser.Rectangle} The Rectangle object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection - **/ + * Checks if the Circle object intersects with the Rectangle and returns the result in an IntersectResult object. + * @param circle The Circle object to check + * @param rect The Rectangle object to check + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ public static circleToRectangle(circle: Circle, rect: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult { var inflatedRect: Rectangle = rect.clone(); @@ -539,59 +562,46 @@ module Phaser { } /** - * Check if the given Point is found within the given Circle - * @method circleContainsPoint - * @param {Phaser.Circle} The circle object to check - * @param {Phaser.Point} The point object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection - **/ - public static circleContainsPoint(circle: Circle, point: Point, output?: IntersectResult = new IntersectResult): IntersectResult { + * Checks if the Point object is contained within the Circle and returns the result in an IntersectResult object. + * @param circle The Circle object to check + * @param point A Point or MicroPoint object to check, or any object with x and y properties + * @param output An optional IntersectResult object to store the intersection values in. One is created if none given. + * @returns {IntersectResult=} An IntersectResult object containing the results of the intersection + */ + public static circleContainsPoint(circle: Circle, point, output?: IntersectResult = new IntersectResult): IntersectResult { - output.result = circle.radius * circle.radius >= this.distanceSquared(circle.x, circle.y, point.x, point.y); + output.result = circle.radius * circle.radius >= Collision.distanceSquared(circle.x, circle.y, point.x, point.y); return output; } /** - * ------------------------------------------------------------------------------------------- - * Game Object Collision - * ------------------------------------------------------------------------------------------- - **/ + * Checks for overlaps between two objects using the world QuadTree. Can be GameObject vs. GameObject, GameObject vs. Group or Group vs. Group. + * Note: Does not take the objects scrollFactor into account. All overlaps are check in world space. + * @param object1 The first GameObject or Group to check. If null the world.group is used. + * @param object2 The second GameObject or Group to check. + * @param notifyCallback A callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you passed them to Collision.overlap. + * @param processCallback A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then notifyCallback will only be called if processCallback returns true. + * @returns {boolean} true if the objects overlap, otherwise false. + */ + public overlap(object1: Basic = null, object2: Basic = null, notifyCallback = null, processCallback = null): bool { - /** - * Call this function to see if one GameObject overlaps another. - * Can be called with one object and one group, or two groups, or two objects, - * whatever floats your boat! For maximum performance try bundling a lot of objects - * together using a Group (or even bundling groups together!). - * - *

NOTE: does NOT take objects' scrollfactor into account, all overlaps are checked in world space.

- * - * @param ObjectOrGroup1 The first object or group you want to check. - * @param ObjectOrGroup2 The second object or group you want to check. If it is the same as the first it knows to just do a comparison within that group. - * @param NotifyCallback A function with two GameObject parameters - e.g. myOverlapFunction(Object1:GameObject,Object2:GameObject) - that is called if those two objects overlap. - * @param ProcessCallback A function with two GameObject parameters - e.g. myOverlapFunction(Object1:GameObject,Object2:GameObject) - that is called if those two objects overlap. If a ProcessCallback is provided, then NotifyCallback will only be called if ProcessCallback returns true for those objects! - * - * @return Whether any overlaps were detected. - */ - public overlap(ObjectOrGroup1: Basic = null, ObjectOrGroup2: Basic = null, NotifyCallback = null, ProcessCallback = null): bool { - - if (ObjectOrGroup1 == null) + if (object1 == null) { - ObjectOrGroup1 = this._game.world.group; + object1 = this._game.world.group; } - if (ObjectOrGroup2 == ObjectOrGroup1) + if (object2 == object1) { - ObjectOrGroup2 = null; + object2 = null; } QuadTree.divisions = this._game.world.worldDivisions; var quadTree: QuadTree = new QuadTree(this._game.world.bounds.x, this._game.world.bounds.y, this._game.world.bounds.width, this._game.world.bounds.height); - quadTree.load(ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, ProcessCallback); + quadTree.load(object1, object2, notifyCallback, processCallback); var result: bool = quadTree.execute(); @@ -604,98 +614,91 @@ module Phaser { } /** - * The main collision resolution in flixel. - * - * @param Object1 Any Sprite. - * @param Object2 Any other Sprite. - * - * @return Whether the objects in fact touched and were separated. + * The core Collision separation function used by Collision.overlap. + * @param object1 The first GameObject to separate + * @param object2 The second GameObject to separate + * @returns {boolean} Returns true if the objects were separated, otherwise false. */ - public static separate(Object1, Object2): bool { + public static separate(object1, object2): bool { - var separatedX: bool = Collision.separateX(Object1, Object2); - var separatedY: bool = Collision.separateY(Object1, Object2); + var separatedX: bool = Collision.separateX(object1, object2); + var separatedY: bool = Collision.separateY(object1, object2); return separatedX || separatedY; } /** - * The X-axis component of the object separation process. - * - * @param Object1 Any Sprite. - * @param Object2 Any other Sprite. - * - * @return Whether the objects in fact touched and were separated along the X axis. + * Collision resolution specifically for GameObjects vs. Tiles. + * @param object The GameObject to separate + * @param tile The Tile to separate + * @returns {boolean} Whether the objects in fact touched and were separated */ - public static separateX(Object1, Object2): bool { + public static separateTile(object:GameObject, tile): bool { - //can't separate two immovable objects - var obj1immovable: bool = Object1.immovable; - var obj2immovable: bool = Object2.immovable; + var separatedX: bool = Collision.separateTileX(object, tile); + var separatedY: bool = Collision.separateTileY(object, tile); - if (obj1immovable && obj2immovable) + return separatedX || separatedY; + + } + + /** + * Separates the two objects on their x axis + * @param object The GameObject to separate + * @param tile The Tile to separate + * @returns {boolean} Whether the objects in fact touched and were separated along the X axis. + */ + public static separateTileX(object, tile): bool { + + // Can't separate two immovable objects + if (object.immovable && tile.immovable) { return false; } - //If one of the objects is a tilemap, just pass it off. - /* - if (typeof Object1 === 'Tilemap') - { - return Object1.overlapsWithCallback(Object2, separateX); - } - - if (typeof Object2 === 'Tilemap') - { - return Object2.overlapsWithCallback(Object1, separateX, true); - } - */ - - //First, get the two object deltas + // First, get the two object deltas var overlap: number = 0; - var obj1delta: number = Object1.x - Object1.last.x; - var obj2delta: number = Object2.x - Object2.last.x; + var objDelta: number = object.x - object.last.x; + var tileDelta: number = 0; - if (obj1delta != obj2delta) + if (objDelta != tileDelta) { - //Check if the X hulls actually overlap - var obj1deltaAbs: number = (obj1delta > 0) ? obj1delta : -obj1delta; - var obj2deltaAbs: number = (obj2delta > 0) ? obj2delta : -obj2delta; - var obj1rect: Rectangle = new Rectangle(Object1.x - ((obj1delta > 0) ? obj1delta : 0), Object1.last.y, Object1.width + ((obj1delta > 0) ? obj1delta : -obj1delta), Object1.height); - var obj2rect: Rectangle = new Rectangle(Object2.x - ((obj2delta > 0) ? obj2delta : 0), Object2.last.y, Object2.width + ((obj2delta > 0) ? obj2delta : -obj2delta), Object2.height); + // Check if the X hulls actually overlap + var objDeltaAbs: number = (objDelta > 0) ? objDelta : -objDelta; + var tileDeltaAbs: number = (tileDelta > 0) ? tileDelta : -tileDelta; + var objBounds: Quad = new Quad(object.x - ((objDelta > 0) ? objDelta : 0), object.last.y, object.width + ((objDelta > 0) ? objDelta : -objDelta), object.height); + var tileBounds: Quad = new Quad(tile.x - ((tileDelta > 0) ? tileDelta : 0), tile.y, tile.width + ((tileDelta > 0) ? tileDelta : -tileDelta), tile.height); - if ((obj1rect.x + obj1rect.width > obj2rect.x) && (obj1rect.x < obj2rect.x + obj2rect.width) && (obj1rect.y + obj1rect.height > obj2rect.y) && (obj1rect.y < obj2rect.y + obj2rect.height)) + if ((objBounds.x + objBounds.width > tileBounds.x) && (objBounds.x < tileBounds.x + tileBounds.width) && (objBounds.y + objBounds.height > tileBounds.y) && (objBounds.y < tileBounds.y + tileBounds.height)) { - var maxOverlap: number = obj1deltaAbs + obj2deltaAbs + Collision.OVERLAP_BIAS; + var maxOverlap: number = objDeltaAbs + tileDeltaAbs + Collision.OVERLAP_BIAS; - //If they did overlap (and can), figure out by how much and flip the corresponding flags - if (obj1delta > obj2delta) + // If they did overlap (and can), figure out by how much and flip the corresponding flags + if (objDelta > tileDelta) { - overlap = Object1.x + Object1.width - Object2.x; + overlap = object.x + object.width - tile.x; - if ((overlap > maxOverlap) || !(Object1.allowCollisions & Collision.RIGHT) || !(Object2.allowCollisions & Collision.LEFT)) + if ((overlap > maxOverlap) || !(object.allowCollisions & Collision.RIGHT) || !(tile.allowCollisions & Collision.LEFT)) { overlap = 0; } else { - Object1.touching |= Collision.RIGHT; - Object2.touching |= Collision.LEFT; + object.touching |= Collision.RIGHT; } } - else if (obj1delta < obj2delta) - { - overlap = Object1.x - Object2.width - Object2.x; + else if (objDelta < tileDelta) + { + overlap = object.x - tile.width - tile.x; - if ((-overlap > maxOverlap) || !(Object1.allowCollisions & Collision.LEFT) || !(Object2.allowCollisions & Collision.RIGHT)) + if ((-overlap > maxOverlap) || !(object.allowCollisions & Collision.LEFT) || !(tile.allowCollisions & Collision.RIGHT)) { overlap = 0; } else { - Object1.touching |= Collision.LEFT; - Object2.touching |= Collision.RIGHT; + object.touching |= Collision.LEFT; } } @@ -703,35 +706,27 @@ module Phaser { } } - //Then adjust their positions and velocities accordingly (if there was any overlap) + // Then adjust their positions and velocities accordingly (if there was any overlap) if (overlap != 0) { - var obj1v: number = Object1.velocity.x; - var obj2v: number = Object2.velocity.x; + var objVelocity: number = object.velocity.x; + var tileVelocity: number = 0; - if (!obj1immovable && !obj2immovable) + if (!object.immovable && !tile.immovable) { overlap *= 0.5; - Object1.x = Object1.x - overlap; - Object2.x += overlap; + object.x = object.x - overlap; - var obj1velocity: number = Math.sqrt((obj2v * obj2v * Object2.mass) / Object1.mass) * ((obj2v > 0) ? 1 : -1); - var obj2velocity: number = Math.sqrt((obj1v * obj1v * Object1.mass) / Object2.mass) * ((obj1v > 0) ? 1 : -1); - var average: number = (obj1velocity + obj2velocity) * 0.5; - obj1velocity -= average; - obj2velocity -= average; - Object1.velocity.x = average + obj1velocity * Object1.elasticity; - Object2.velocity.x = average + obj2velocity * Object2.elasticity; + var objNewVelocity: number = Math.sqrt((tileVelocity * tileVelocity * tile.mass) / object.mass) * ((tileVelocity > 0) ? 1 : -1); + var tileNewVelocity: number = Math.sqrt((objVelocity * objVelocity * object.mass) / tile.mass) * ((objVelocity > 0) ? 1 : -1); + var average: number = (objNewVelocity + tileNewVelocity) * 0.5; + objNewVelocity -= average; + object.velocity.x = average + objNewVelocity * object.elasticity; } - else if (!obj1immovable) - { - Object1.x = Object1.x - overlap; - Object1.velocity.x = obj2v - obj1v * Object1.elasticity; - } - else if (!obj2immovable) - { - Object2.x += overlap; - Object2.velocity.x = obj1v - obj2v * Object2.elasticity; + else if (!object.immovable) + { + object.x = object.x - overlap; + object.velocity.x = tileVelocity - objVelocity * object.elasticity; } return true; @@ -744,123 +739,98 @@ module Phaser { } /** - * The Y-axis component of the object separation process. - * - * @param Object1 Any Sprite. - * @param Object2 Any other Sprite. - * - * @return Whether the objects in fact touched and were separated along the Y axis. + * Separates the two objects on their y axis + * @param object The first GameObject to separate + * @param tile The second GameObject to separate + * @returns {boolean} Whether the objects in fact touched and were separated along the Y axis. */ - public static separateY(Object1, Object2): bool { + public static separateTileY(object, tile): bool { - //can't separate two immovable objects - - var obj1immovable: bool = Object1.immovable; - var obj2immovable: bool = Object2.immovable; - - if (obj1immovable && obj2immovable) + // Can't separate two immovable objects + if (object.immovable && tile.immovable) { return false; - - //If one of the objects is a tilemap, just pass it off. - /* - if (typeof Object1 === 'Tilemap') - { - return Object1.overlapsWithCallback(Object2, separateY); } - - if (typeof Object2 === 'Tilemap') - { - return Object2.overlapsWithCallback(Object1, separateY, true); - } - */ - //First, get the two object deltas + // First, get the two object deltas var overlap: number = 0; - var obj1delta: number = Object1.y - Object1.last.y; - var obj2delta: number = Object2.y - Object2.last.y; + var objDelta: number = object.y - object.last.y; + var tileDelta: number = 0; - if (obj1delta != obj2delta) + if (objDelta != tileDelta) { - //Check if the Y hulls actually overlap - var obj1deltaAbs: number = (obj1delta > 0) ? obj1delta : -obj1delta; - var obj2deltaAbs: number = (obj2delta > 0) ? obj2delta : -obj2delta; - var obj1rect: Rectangle = new Rectangle(Object1.x, Object1.y - ((obj1delta > 0) ? obj1delta : 0), Object1.width, Object1.height + obj1deltaAbs); - var obj2rect: Rectangle = new Rectangle(Object2.x, Object2.y - ((obj2delta > 0) ? obj2delta : 0), Object2.width, Object2.height + obj2deltaAbs); + // Check if the Y hulls actually overlap + var objDeltaAbs: number = (objDelta > 0) ? objDelta : -objDelta; + var tileDeltaAbs: number = (tileDelta > 0) ? tileDelta : -tileDelta; + var objBounds: Quad = new Quad(object.x, object.y - ((objDelta > 0) ? objDelta : 0), object.width, object.height + objDeltaAbs); + var tileBounds: Quad = new Quad(tile.x, tile.y - ((tileDelta > 0) ? tileDelta : 0), tile.width, tile.height + tileDeltaAbs); - if ((obj1rect.x + obj1rect.width > obj2rect.x) && (obj1rect.x < obj2rect.x + obj2rect.width) && (obj1rect.y + obj1rect.height > obj2rect.y) && (obj1rect.y < obj2rect.y + obj2rect.height)) + if ((objBounds.x + objBounds.width > tileBounds.x) && (objBounds.x < tileBounds.x + tileBounds.width) && (objBounds.y + objBounds.height > tileBounds.y) && (objBounds.y < tileBounds.y + tileBounds.height)) { - var maxOverlap: number = obj1deltaAbs + obj2deltaAbs + Collision.OVERLAP_BIAS; + var maxOverlap: number = objDeltaAbs + tileDeltaAbs + Collision.OVERLAP_BIAS; - //If they did overlap (and can), figure out by how much and flip the corresponding flags - if (obj1delta > obj2delta) + // If they did overlap (and can), figure out by how much and flip the corresponding flags + if (objDelta > tileDelta) { - overlap = Object1.y + Object1.height - Object2.y; + overlap = object.y + object.height - tile.y; - if ((overlap > maxOverlap) || !(Object1.allowCollisions & Collision.DOWN) || !(Object2.allowCollisions & Collision.UP)) + if ((overlap > maxOverlap) || !(object.allowCollisions & Collision.DOWN) || !(tile.allowCollisions & Collision.UP)) { overlap = 0; } else { - Object1.touching |= Collision.DOWN; - Object2.touching |= Collision.UP; + object.touching |= Collision.DOWN; + //tile.touching |= Collision.UP; } } - else if (obj1delta < obj2delta) - { - overlap = Object1.y - Object2.height - Object2.y; + else if (objDelta < tileDelta) + { + overlap = object.y - tile.height - tile.y; - if ((-overlap > maxOverlap) || !(Object1.allowCollisions & Collision.UP) || !(Object2.allowCollisions & Collision.DOWN)) + if ((-overlap > maxOverlap) || !(object.allowCollisions & Collision.UP) || !(tile.allowCollisions & Collision.DOWN)) { overlap = 0; } else { - Object1.touching |= Collision.UP; - Object2.touching |= Collision.DOWN; + object.touching |= Collision.UP; + //tile.touching |= Collision.DOWN; } } } } - //Then adjust their positions and velocities accordingly (if there was any overlap) + // TODO - with super low velocities you get lots of stuttering, set some kind of base minimum here + + // Then adjust their positions and velocities accordingly (if there was any overlap) if (overlap != 0) { - var obj1v: number = Object1.velocity.y; - var obj2v: number = Object2.velocity.y; + var objVelocity: number = object.velocity.y; + var tileVelocity: number = 0; - if (!obj1immovable && !obj2immovable) + if (!object.immovable && !tile.immovable) { overlap *= 0.5; - Object1.y = Object1.y - overlap; - Object2.y += overlap; + object.y = object.y - overlap; + //tile.y += overlap; - var obj1velocity: number = Math.sqrt((obj2v * obj2v * Object2.mass) / Object1.mass) * ((obj2v > 0) ? 1 : -1); - var obj2velocity: number = Math.sqrt((obj1v * obj1v * Object1.mass) / Object2.mass) * ((obj1v > 0) ? 1 : -1); - var average: number = (obj1velocity + obj2velocity) * 0.5; - obj1velocity -= average; - obj2velocity -= average; - Object1.velocity.y = average + obj1velocity * Object1.elasticity; - Object2.velocity.y = average + obj2velocity * Object2.elasticity; + var objNewVelocity: number = Math.sqrt((tileVelocity * tileVelocity * tile.mass) / object.mass) * ((tileVelocity > 0) ? 1 : -1); + var tileNewVelocity: number = Math.sqrt((objVelocity * objVelocity * object.mass) / tile.mass) * ((objVelocity > 0) ? 1 : -1); + var average: number = (objNewVelocity + tileNewVelocity) * 0.5; + objNewVelocity -= average; + //tileNewVelocity -= average; + object.velocity.y = average + objNewVelocity * object.elasticity; + //tile.velocity.y = average + tileNewVelocity * tile.elasticity; } - else if (!obj1immovable) + else if (!object.immovable) + { + //console.log('y sep', overlap, object.y); + object.y = object.y - overlap; + object.velocity.y = tileVelocity - objVelocity * object.elasticity; + // This is special case code that handles things like horizontal moving platforms you can ride + if (tile.active && tile.moves && (objDelta > tileDelta)) { - Object1.y = Object1.y - overlap; - Object1.velocity.y = obj2v - obj1v * Object1.elasticity; - //This is special case code that handles cases like horizontal moving platforms you can ride - if (Object2.active && Object2.moves && (obj1delta > obj2delta)) - { - Object1.x += Object2.x - Object2.last.x; - } - } - else if (!obj2immovable) - { - Object2.y += overlap; - Object2.velocity.y = obj1v - obj2v * Object2.elasticity; - //This is special case code that handles cases like horizontal moving platforms you can ride - if (Object1.active && Object1.moves && (obj1delta < obj2delta)) - { - Object2.x += Object1.x - Object1.last.x; + //object.x += tile.x - tile.x; } } @@ -872,22 +842,246 @@ module Phaser { } } + /** + * Separates the two objects on their x axis + * @param object1 The first GameObject to separate + * @param object2 The second GameObject to separate + * @returns {boolean} Whether the objects in fact touched and were separated along the X axis. + */ + public static separateX(object1, object2): bool { + + // Can't separate two immovable objects + if (object1.immovable && object2.immovable) + { + return false; + } + + // First, get the two object deltas + var overlap: number = 0; + var obj1Delta: number = object1.x - object1.last.x; + var obj2Delta: number = object2.x - object2.last.x; + + if (obj1Delta != obj2Delta) + { + // Check if the X hulls actually overlap + var obj1DeltaAbs: number = (obj1Delta > 0) ? obj1Delta : -obj1Delta; + var obj2DeltaAbs: number = (obj2Delta > 0) ? obj2Delta : -obj2Delta; + var obj1Bounds: Quad = new Quad(object1.x - ((obj1Delta > 0) ? obj1Delta : 0), object1.last.y, object1.width + ((obj1Delta > 0) ? obj1Delta : -obj1Delta), object1.height); + var obj2Bounds: Quad = new Quad(object2.x - ((obj2Delta > 0) ? obj2Delta : 0), object2.last.y, object2.width + ((obj2Delta > 0) ? obj2Delta : -obj2Delta), object2.height); + + if ((obj1Bounds.x + obj1Bounds.width > obj2Bounds.x) && (obj1Bounds.x < obj2Bounds.x + obj2Bounds.width) && (obj1Bounds.y + obj1Bounds.height > obj2Bounds.y) && (obj1Bounds.y < obj2Bounds.y + obj2Bounds.height)) + { + var maxOverlap: number = obj1DeltaAbs + obj2DeltaAbs + Collision.OVERLAP_BIAS; + + // If they did overlap (and can), figure out by how much and flip the corresponding flags + if (obj1Delta > obj2Delta) + { + overlap = object1.x + object1.width - object2.x; + + if ((overlap > maxOverlap) || !(object1.allowCollisions & Collision.RIGHT) || !(object2.allowCollisions & Collision.LEFT)) + { + overlap = 0; + } + else + { + object1.touching |= Collision.RIGHT; + object2.touching |= Collision.LEFT; + } + } + else if (obj1Delta < obj2Delta) + { + overlap = object1.x - object2.width - object2.x; + + if ((-overlap > maxOverlap) || !(object1.allowCollisions & Collision.LEFT) || !(object2.allowCollisions & Collision.RIGHT)) + { + overlap = 0; + } + else + { + object1.touching |= Collision.LEFT; + object2.touching |= Collision.RIGHT; + } + + } + + } + } + + // Then adjust their positions and velocities accordingly (if there was any overlap) + if (overlap != 0) + { + var obj1Velocity: number = object1.velocity.x; + var obj2Velocity: number = object2.velocity.x; + + if (!object1.immovable && !object2.immovable) + { + overlap *= 0.5; + object1.x = object1.x - overlap; + object2.x += overlap; + + var obj1NewVelocity: number = Math.sqrt((obj2Velocity * obj2Velocity * object2.mass) / object1.mass) * ((obj2Velocity > 0) ? 1 : -1); + var obj2NewVelocity: number = Math.sqrt((obj1Velocity * obj1Velocity * object1.mass) / object2.mass) * ((obj1Velocity > 0) ? 1 : -1); + var average: number = (obj1NewVelocity + obj2NewVelocity) * 0.5; + obj1NewVelocity -= average; + obj2NewVelocity -= average; + object1.velocity.x = average + obj1NewVelocity * object1.elasticity; + object2.velocity.x = average + obj2NewVelocity * object2.elasticity; + } + else if (!object1.immovable) + { + object1.x = object1.x - overlap; + object1.velocity.x = obj2Velocity - obj1Velocity * object1.elasticity; + } + else if (!object2.immovable) + { + object2.x += overlap; + object2.velocity.x = obj1Velocity - obj2Velocity * object2.elasticity; + } + + return true; + } + else + { + return false; + } + + } /** - * ------------------------------------------------------------------------------------------- - * Distance - * ------------------------------------------------------------------------------------------- - **/ + * Separates the two objects on their y axis + * @param object1 The first GameObject to separate + * @param object2 The second GameObject to separate + * @returns {boolean} Whether the objects in fact touched and were separated along the Y axis. + */ + public static separateY(object1, object2): bool { + // Can't separate two immovable objects + if (object1.immovable && object2.immovable) { + return false; + } + + // First, get the two object deltas + var overlap: number = 0; + var obj1Delta: number = object1.y - object1.last.y; + var obj2Delta: number = object2.y - object2.last.y; + + if (obj1Delta != obj2Delta) + { + // Check if the Y hulls actually overlap + var obj1DeltaAbs: number = (obj1Delta > 0) ? obj1Delta : -obj1Delta; + var obj2DeltaAbs: number = (obj2Delta > 0) ? obj2Delta : -obj2Delta; + var obj1Bounds: Quad = new Quad(object1.x, object1.y - ((obj1Delta > 0) ? obj1Delta : 0), object1.width, object1.height + obj1DeltaAbs); + var obj2Bounds: Quad = new Quad(object2.x, object2.y - ((obj2Delta > 0) ? obj2Delta : 0), object2.width, object2.height + obj2DeltaAbs); + + if ((obj1Bounds.x + obj1Bounds.width > obj2Bounds.x) && (obj1Bounds.x < obj2Bounds.x + obj2Bounds.width) && (obj1Bounds.y + obj1Bounds.height > obj2Bounds.y) && (obj1Bounds.y < obj2Bounds.y + obj2Bounds.height)) + { + var maxOverlap: number = obj1DeltaAbs + obj2DeltaAbs + Collision.OVERLAP_BIAS; + + // If they did overlap (and can), figure out by how much and flip the corresponding flags + if (obj1Delta > obj2Delta) + { + overlap = object1.y + object1.height - object2.y; + + if ((overlap > maxOverlap) || !(object1.allowCollisions & Collision.DOWN) || !(object2.allowCollisions & Collision.UP)) + { + overlap = 0; + } + else + { + object1.touching |= Collision.DOWN; + object2.touching |= Collision.UP; + } + } + else if (obj1Delta < obj2Delta) + { + overlap = object1.y - object2.height - object2.y; + + if ((-overlap > maxOverlap) || !(object1.allowCollisions & Collision.UP) || !(object2.allowCollisions & Collision.DOWN)) + { + overlap = 0; + } + else + { + object1.touching |= Collision.UP; + object2.touching |= Collision.DOWN; + } + } + } + } + + // Then adjust their positions and velocities accordingly (if there was any overlap) + if (overlap != 0) + { + var obj1Velocity: number = object1.velocity.y; + var obj2Velocity: number = object2.velocity.y; + + if (!object1.immovable && !object2.immovable) + { + overlap *= 0.5; + object1.y = object1.y - overlap; + object2.y += overlap; + + var obj1NewVelocity: number = Math.sqrt((obj2Velocity * obj2Velocity * object2.mass) / object1.mass) * ((obj2Velocity > 0) ? 1 : -1); + var obj2NewVelocity: number = Math.sqrt((obj1Velocity * obj1Velocity * object1.mass) / object2.mass) * ((obj1Velocity > 0) ? 1 : -1); + var average: number = (obj1NewVelocity + obj2NewVelocity) * 0.5; + obj1NewVelocity -= average; + obj2NewVelocity -= average; + object1.velocity.y = average + obj1NewVelocity * object1.elasticity; + object2.velocity.y = average + obj2NewVelocity * object2.elasticity; + } + else if (!object1.immovable) + { + object1.y = object1.y - overlap; + object1.velocity.y = obj2Velocity - obj1Velocity * object1.elasticity; + // This is special case code that handles things like horizontal moving platforms you can ride + if (object2.active && object2.moves && (obj1Delta > obj2Delta)) + { + object1.x += object2.x - object2.last.x; + } + } + else if (!object2.immovable) + { + object2.y += overlap; + object2.velocity.y = obj1Velocity - obj2Velocity * object2.elasticity; + // This is special case code that handles things like horizontal moving platforms you can ride + if (object1.active && object1.moves && (obj1Delta < obj2Delta)) + { + object2.x += object1.x - object1.last.x; + } + } + + return true; + } + else + { + return false; + } + } + + /** + * Returns the distance between the two given coordinates. + * @param x1 The X value of the first coordinate + * @param y1 The Y value of the first coordinate + * @param x2 The X value of the second coordinate + * @param y2 The Y value of the second coordinate + * @returns {number} The distance between the two coordinates + */ public static distance(x1: number, y1: number, x2: number, y2: number) { return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); } + /** + * Returns the distanced squared between the two given coordinates. + * @param x1 The X value of the first coordinate + * @param y1 The Y value of the first coordinate + * @param x2 The X value of the second coordinate + * @param y2 The Y value of the second coordinate + * @returns {number} The distance between the two coordinates + */ public static distanceSquared(x1: number, y1: number, x2: number, y2: number) { return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1); } - } } \ No newline at end of file diff --git a/Phaser/Game.ts b/Phaser/Game.ts index ef780a4f..3c60d426 100644 --- a/Phaser/Game.ts +++ b/Phaser/Game.ts @@ -35,6 +35,9 @@ * * This is where the magic happens. The Game object is the heart of your game, * providing quick access to common functions and handling the boot process. +* +* "Hell, there are no rules here - we're trying to accomplish something." +* Thomas A. Edison */ module Phaser { @@ -313,8 +316,7 @@ module Phaser { } else { - throw Error("Invalid State object given. Must contain at least a create or update function."); - return; + throw new Error("Invalid State object given. Must contain at least a create or update function."); } } @@ -416,8 +418,8 @@ module Phaser { return this.tweens.create(obj); } - public collide(ObjectOrGroup1: Basic = null, ObjectOrGroup2: Basic = null, NotifyCallback = null): bool { - return this.collision.overlap(ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, Collision.separate); + public collide(objectOrGroup1: Basic = null, objectOrGroup2: Basic = null, notifyCallback = null): bool { + return this.collision.overlap(objectOrGroup1, objectOrGroup2, notifyCallback, Collision.separate); } } diff --git a/Phaser/Group.ts b/Phaser/Group.ts index a436baa8..81459a62 100644 --- a/Phaser/Group.ts +++ b/Phaser/Group.ts @@ -450,7 +450,7 @@ module Phaser { } } - public forEach(callback, Recurse: bool = false) { + public forEach(callback, recursive: bool = false) { var basic; var i: number = 0; @@ -461,7 +461,7 @@ module Phaser { if (basic != null) { - if (Recurse && (basic.isGroup == true)) + if (recursive && (basic.isGroup == true)) { basic.forEach(callback, true); } @@ -474,6 +474,30 @@ module Phaser { } + public forEachAlive(callback, recursive: bool = false) { + + var basic; + var i: number = 0; + + while (i < this.length) + { + basic = this.members[i++]; + + if (basic != null && basic.alive) + { + if (recursive && (basic.isGroup == true)) + { + basic.forEachAlive(callback, true); + } + else + { + callback.call(this, basic); + } + } + } + + } + /** * Call this function to retrieve the first object with exists == false in the group. * This is handy for recycling in general, e.g. respawning enemies. diff --git a/Phaser/Phaser.ts b/Phaser/Phaser.ts index 8fca2aee..7434f78c 100644 --- a/Phaser/Phaser.ts +++ b/Phaser/Phaser.ts @@ -1,7 +1,7 @@ /** * Phaser * -* v0.9.3 - April 24th 2013 +* v0.9.4 - April 24th 2013 * * A small and feature-packed 2D canvas game framework born from the firey pits of Flixel and Kiwi. * @@ -16,6 +16,6 @@ module Phaser { - export var VERSION: string = 'Phaser version 0.9.3'; + export var VERSION: string = 'Phaser version 0.9.4'; } diff --git a/Phaser/Stage.ts b/Phaser/Stage.ts index 6b85f1ef..5606b144 100644 --- a/Phaser/Stage.ts +++ b/Phaser/Stage.ts @@ -43,8 +43,8 @@ module Phaser { this.scaleMode = StageScaleMode.NO_SCALE; this.scale = new StageScaleMode(this._game); - //document.addEventListener('visibilitychange', (event) => this.visibilityChange(event), false); - //document.addEventListener('webkitvisibilitychange', (event) => this.visibilityChange(event), false); + document.addEventListener('visibilitychange', (event) => this.visibilityChange(event), false); + document.addEventListener('webkitvisibilitychange', (event) => this.visibilityChange(event), false); window.onblur = (event) => this.visibilityChange(event); window.onfocus = (event) => this.visibilityChange(event); @@ -96,6 +96,8 @@ module Phaser { //if (document['hidden'] === true || document['webkitHidden'] === true) private visibilityChange(event) { + //console.log(event); + if (this.disablePauseScreen) { return; diff --git a/Phaser/gameobjects/GameObject.ts b/Phaser/gameobjects/GameObject.ts index 5b578181..e942cf72 100644 --- a/Phaser/gameobjects/GameObject.ts +++ b/Phaser/gameobjects/GameObject.ts @@ -89,6 +89,8 @@ module Phaser { // rotationOffset to 90 and it would correspond correctly with Phasers rotation system public rotationOffset: number = 0; + public renderRotation: bool = true; + // Physics properties public immovable: bool; diff --git a/Phaser/gameobjects/Sprite.ts b/Phaser/gameobjects/Sprite.ts index ba849c3a..106226b4 100644 --- a/Phaser/gameobjects/Sprite.ts +++ b/Phaser/gameobjects/Sprite.ts @@ -229,7 +229,7 @@ module Phaser { this._game.stage.context.save(); this._game.stage.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2)); - if (this.angle !== 0 || this.rotationOffset !== 0) + if (this.renderRotation == true && (this.angle !== 0 || this.rotationOffset !== 0)) { this._game.stage.context.rotate((this.rotationOffset + this.angle) * (Math.PI / 180)); } diff --git a/Phaser/gameobjects/Tilemap.ts b/Phaser/gameobjects/Tilemap.ts index 526d1aea..9fc3ae3f 100644 --- a/Phaser/gameobjects/Tilemap.ts +++ b/Phaser/gameobjects/Tilemap.ts @@ -1,6 +1,7 @@ /// /// /// +/// /** * Phaser - Tilemap @@ -19,7 +20,8 @@ module Phaser { this.isGroup = false; - this._layers = []; + this.tiles = []; + this.layers = []; this.mapFormat = format; @@ -41,11 +43,11 @@ module Phaser { } - private _layers : TilemapLayer[]; - public static FORMAT_CSV: number = 0; public static FORMAT_TILED_JSON: number = 1; + public tiles : Tile[]; + public layers : TilemapLayer[]; public currentLayer: TilemapLayer; public mapFormat: number; @@ -57,9 +59,9 @@ module Phaser { if (this.cameraBlacklist.indexOf(camera.ID) == -1) { // Loop through the layers - for (var i = 0; i < this._layers.length; i++) + for (var i = 0; i < this.layers.length; i++) { - this._layers[i].render(camera, cameraOffsetX, cameraOffsetY); + this.layers[i].render(camera, cameraOffsetX, cameraOffsetY); } } @@ -67,7 +69,7 @@ module Phaser { private parseCSV(data: string, key: string, tileWidth: number, tileHeight: number) { - var layer: TilemapLayer = new TilemapLayer(this._game, key, Tilemap.FORMAT_CSV, 'TileLayerCSV' + this._layers.length.toString(), tileWidth, tileHeight); + var layer: TilemapLayer = new TilemapLayer(this._game, this, key, Tilemap.FORMAT_CSV, 'TileLayerCSV' + this.layers.length.toString(), tileWidth, tileHeight); // Trim any rogue whitespace from the data data = data.trim(); @@ -85,10 +87,13 @@ module Phaser { } layer.updateBounds(); + var tileQuantity = layer.parseTileOffsets(); this.currentLayer = layer; - this._layers.push(layer); + this.layers.push(layer); + + this.generateTiles(tileQuantity); } @@ -101,10 +106,12 @@ module Phaser { for (var i = 0; i < json.layers.length; i++) { - var layer: TilemapLayer = new TilemapLayer(this._game, key, Tilemap.FORMAT_TILED_JSON, json.layers[i].name, json.tilewidth, json.tileheight); + var layer: TilemapLayer = new TilemapLayer(this._game, this, key, Tilemap.FORMAT_TILED_JSON, json.layers[i].name, json.tilewidth, json.tileheight); layer.alpha = json.layers[i].opacity; layer.visible = json.layers[i].visible; + layer.tileMargin = json.tilesets[0].margin; + layer.tileSpacing = json.tilesets[0].spacing; var c = 0; var row; @@ -129,12 +136,25 @@ module Phaser { layer.updateBounds(); + var tileQuantity = layer.parseTileOffsets(); + this.currentLayer = layer; - this._layers.push(layer); + this.layers.push(layer); } + this.generateTiles(tileQuantity); + + } + + private generateTiles(qty:number) { + + for (var i = 0; i < qty; i++) + { + this.tiles.push(new Tile(this._game, this, i, this.currentLayer.tileWidth, this.currentLayer.tileHeight)); + } + } public get widthInPixels(): number { @@ -145,9 +165,81 @@ module Phaser { return this.currentLayer.heightInPixels; } + // Tile Collision + + public setCollisionRange(start: number, end: number, collision?:number = Collision.ANY) { + + for (var i = start; i < end; i++) + { + this.tiles[i].allowCollisions = collision; + } + + } + + public setCollisionByIndex(values:number[], collision?:number = Collision.ANY) { + + for (var i = 0; i < values.length; i++) + { + this.tiles[values[i]].allowCollisions = collision; + } + + } + + // Tile Management + + public getTile(x: number, y: number, layer?: number = 0):Tile { + + return this.tiles[this.layers[layer].getTileIndex(x, y)]; + + } + + public getTileFromWorldXY(x: number, y: number, layer?: number = 0):Tile { + + return this.tiles[this.layers[layer].getTileFromWorldXY(x, y)]; + + } + + public getTileFromInputXY(layer?: number = 0):Tile { + + return this.tiles[this.layers[layer].getTileFromWorldXY(this._game.input.worldX, this._game.input.worldY)]; + + } + + public getTileOverlaps(object: GameObject) { + + return this.currentLayer.getTileOverlaps(object); + + } + + // COLLIDE + public collide(objectOrGroup = null, callback = null): bool { + + if (objectOrGroup == null) + { + objectOrGroup = this._game.world.group; + } + + // Group? + if (objectOrGroup.isGroup == false) + { + if (objectOrGroup.exists && objectOrGroup.allowCollisions != Collision.NONE) + { + this.currentLayer.getTileOverlaps(objectOrGroup); + } + } + else + { + // todo + objectOrGroup.forEachAlive(this.currentLayer.getTileOverlaps); + } + + return true; + + } + + // Set current layer // Set layer order? - // Get tile from x/y // Get block of tiles // Swap tiles around // Delete tiles of certain type diff --git a/Phaser/geom/Quad.ts b/Phaser/geom/Quad.ts index 88adc41d..bfad11db 100644 --- a/Phaser/geom/Quad.ts +++ b/Phaser/geom/Quad.ts @@ -72,11 +72,11 @@ module Phaser { * Determines whether the object specified intersects (overlaps) with this Quad object. * This method checks the x, y, width, and height properties of the specified Quad object to see if it intersects with this Quad object. * @method intersects - * @param {Quad} q The Quad to compare against to see if it intersects with this Quad. + * @param {Object} q The object to check for intersection with this Quad. Must have left/right/top/bottom properties (Rectangle, Quad). * @param {Number} t A tolerance value to allow for an intersection test with padding, default to 0 * @return {Boolean} A value of true if the specified object intersects with this Quad; otherwise false. **/ - public intersects(q: Quad, t?: number = 0): bool { + public intersects(q, t?: number = 0): bool { return !(q.left > this.right + t || q.right < this.left - t || q.top > this.bottom + t || q.bottom < this.top - t); diff --git a/Phaser/node_modules/grunt/.npmignore b/Phaser/node_modules/grunt/.npmignore new file mode 100644 index 00000000..032c58e0 --- /dev/null +++ b/Phaser/node_modules/grunt/.npmignore @@ -0,0 +1,3 @@ +node_modules +.npm-debug.log +tmp diff --git a/Phaser/node_modules/grunt/.travis.yml b/Phaser/node_modules/grunt/.travis.yml new file mode 100644 index 00000000..b30fcb75 --- /dev/null +++ b/Phaser/node_modules/grunt/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - 0.8 +before_script: + - npm install -g grunt-cli diff --git a/Phaser/node_modules/grunt/AUTHORS b/Phaser/node_modules/grunt/AUTHORS new file mode 100644 index 00000000..d9cace84 --- /dev/null +++ b/Phaser/node_modules/grunt/AUTHORS @@ -0,0 +1,4 @@ +"Cowboy" Ben Alman (http://benalman.com/) +Kyle Robinson Young (http://dontkry.com/) +Tyler Kellen (http://goingslowly.com) +Sindre Sorhus (http://sindresorhus.com) diff --git a/Phaser/node_modules/grunt/CHANGELOG b/Phaser/node_modules/grunt/CHANGELOG new file mode 100644 index 00000000..81e937bd --- /dev/null +++ b/Phaser/node_modules/grunt/CHANGELOG @@ -0,0 +1,23 @@ +v0.4.1: + date: 2013-03-13 + changes: + - Fix path.join thrown errors with expandMapping rename. Closes gh-725. + - Update copyright date to 2013. Closes gh-660. + - Remove some side effects from manually requiring Grunt. Closes gh-605. + - grunt.log: add formatting support and implicitly cast msg to a string. Closes gh-703. + - Update js-yaml to version 2. Closes gh-683. + - The grunt.util.spawn method now falls back to stdout when the `grunt` option is set. Closes gh-691. + - Making --verbose "Files:" warnings less scary. Closes gh-657. + - Fixing typo: the grunt.fatal method now defaults to FATAL_ERROR. Closes gh-656, gh-707. + - Removed a duplicate line. Closes gh-702. + - Gruntfile name should no longer be case sensitive. Closes gh-685. + - The grunt.file.delete method warns and returns false if file doesn't exist. Closes gh-635, gh-714. + - The grunt.package property is now resolved via require(). Closes gh-704. + - The grunt.util.spawn method no longer breaks on multibyte stdio. Closes gh-710. + - Fix "path.join arguments must be strings" error in file.expand/recurse when options.cwd is not set. Closes gh-722. + - Adding a fairly relevant keyword to package.json (task). +v0.4.0: + date: 2013-02-18 + changes: + - Initial release of 0.4.0. + - See http://gruntjs.com/upgrading-from-0.3-to-0.4 for a list of changes / migration guide. diff --git a/Phaser/node_modules/grunt/CONTRIBUTING.md b/Phaser/node_modules/grunt/CONTRIBUTING.md new file mode 100644 index 00000000..5d08cc38 --- /dev/null +++ b/Phaser/node_modules/grunt/CONTRIBUTING.md @@ -0,0 +1 @@ +Please see the [Contributing to grunt](http://gruntjs.com/contributing) guide for information on contributing to this project. diff --git a/Phaser/node_modules/grunt/LICENSE-MIT b/Phaser/node_modules/grunt/LICENSE-MIT new file mode 100644 index 00000000..bb2aad6d --- /dev/null +++ b/Phaser/node_modules/grunt/LICENSE-MIT @@ -0,0 +1,22 @@ +Copyright (c) 2013 "Cowboy" Ben Alman + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/README.md b/Phaser/node_modules/grunt/README.md new file mode 100644 index 00000000..e0d0f4a0 --- /dev/null +++ b/Phaser/node_modules/grunt/README.md @@ -0,0 +1,13 @@ +# Grunt: The JavaScript Task Runner [![Build Status](https://secure.travis-ci.org/gruntjs/grunt.png?branch=master)](http://travis-ci.org/gruntjs/grunt) + +### Documentation + +Visit the [gruntjs.com](http://gruntjs.com/) website for all the things. + +### Support / Contributing +Before you make an issue, please read our [Contributing](http://gruntjs.com/contributing) guide. + +You can find the grunt team in [#grunt on irc.freenode.net](irc://irc.freenode.net/#grunt). + +### Release History +See the [CHANGELOG](CHANGELOG). diff --git a/Phaser/node_modules/grunt/docs/README.md b/Phaser/node_modules/grunt/docs/README.md new file mode 100644 index 00000000..bf485150 --- /dev/null +++ b/Phaser/node_modules/grunt/docs/README.md @@ -0,0 +1 @@ +Visit the [gruntjs.com](http://gruntjs.com/) website for all the things. \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/.bin/cake b/Phaser/node_modules/grunt/node_modules/.bin/cake new file mode 120000 index 00000000..d95f32af --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/.bin/cake @@ -0,0 +1 @@ +../coffee-script/bin/cake \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/.bin/coffee b/Phaser/node_modules/grunt/node_modules/.bin/coffee new file mode 120000 index 00000000..b57f275d --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/.bin/coffee @@ -0,0 +1 @@ +../coffee-script/bin/coffee \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/.bin/js-yaml b/Phaser/node_modules/grunt/node_modules/.bin/js-yaml new file mode 120000 index 00000000..9dbd010d --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/.bin/js-yaml @@ -0,0 +1 @@ +../js-yaml/bin/js-yaml.js \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/.bin/lodash b/Phaser/node_modules/grunt/node_modules/.bin/lodash new file mode 120000 index 00000000..24deae28 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/.bin/lodash @@ -0,0 +1 @@ +../lodash/build.js \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/.bin/nopt b/Phaser/node_modules/grunt/node_modules/.bin/nopt new file mode 120000 index 00000000..6b6566ea --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/.bin/nopt @@ -0,0 +1 @@ +../nopt/bin/nopt.js \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/.bin/which b/Phaser/node_modules/grunt/node_modules/.bin/which new file mode 120000 index 00000000..f62471c8 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/.bin/which @@ -0,0 +1 @@ +../which/bin/which \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/async/.gitmodules b/Phaser/node_modules/grunt/node_modules/async/.gitmodules new file mode 100644 index 00000000..a9aae984 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/async/.gitmodules @@ -0,0 +1,9 @@ +[submodule "deps/nodeunit"] + path = deps/nodeunit + url = git://github.com/caolan/nodeunit.git +[submodule "deps/UglifyJS"] + path = deps/UglifyJS + url = https://github.com/mishoo/UglifyJS.git +[submodule "deps/nodelint"] + path = deps/nodelint + url = https://github.com/tav/nodelint.git diff --git a/Phaser/node_modules/grunt/node_modules/async/.npmignore b/Phaser/node_modules/grunt/node_modules/async/.npmignore new file mode 100644 index 00000000..9bdfc97c --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/async/.npmignore @@ -0,0 +1,4 @@ +deps +dist +test +nodelint.cfg \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/async/LICENSE b/Phaser/node_modules/grunt/node_modules/async/LICENSE new file mode 100644 index 00000000..b7f9d500 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/async/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2010 Caolan McMahon + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/async/Makefile b/Phaser/node_modules/grunt/node_modules/async/Makefile new file mode 100644 index 00000000..bad647c6 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/async/Makefile @@ -0,0 +1,25 @@ +PACKAGE = asyncjs +NODEJS = $(if $(shell test -f /usr/bin/nodejs && echo "true"),nodejs,node) +CWD := $(shell pwd) +NODEUNIT = $(CWD)/node_modules/nodeunit/bin/nodeunit +UGLIFY = $(CWD)/node_modules/uglify-js/bin/uglifyjs +NODELINT = $(CWD)/node_modules/nodelint/nodelint + +BUILDDIR = dist + +all: clean test build + +build: $(wildcard lib/*.js) + mkdir -p $(BUILDDIR) + $(UGLIFY) lib/async.js > $(BUILDDIR)/async.min.js + +test: + $(NODEUNIT) test + +clean: + rm -rf $(BUILDDIR) + +lint: + $(NODELINT) --config nodelint.cfg lib/async.js + +.PHONY: test build all diff --git a/Phaser/node_modules/grunt/node_modules/async/README.md b/Phaser/node_modules/grunt/node_modules/async/README.md new file mode 100644 index 00000000..1bbbc477 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/async/README.md @@ -0,0 +1,1021 @@ +# Async.js + +Async is a utility module which provides straight-forward, powerful functions +for working with asynchronous JavaScript. Although originally designed for +use with [node.js](http://nodejs.org), it can also be used directly in the +browser. + +Async provides around 20 functions that include the usual 'functional' +suspects (map, reduce, filter, forEach…) as well as some common patterns +for asynchronous control flow (parallel, series, waterfall…). All these +functions assume you follow the node.js convention of providing a single +callback as the last argument of your async function. + + +## Quick Examples + + async.map(['file1','file2','file3'], fs.stat, function(err, results){ + // results is now an array of stats for each file + }); + + async.filter(['file1','file2','file3'], path.exists, function(results){ + // results now equals an array of the existing files + }); + + async.parallel([ + function(){ ... }, + function(){ ... } + ], callback); + + async.series([ + function(){ ... }, + function(){ ... } + ]); + +There are many more functions available so take a look at the docs below for a +full list. This module aims to be comprehensive, so if you feel anything is +missing please create a GitHub issue for it. + + +## Download + +Releases are available for download from +[GitHub](http://github.com/caolan/async/downloads). +Alternatively, you can install using Node Package Manager (npm): + + npm install async + + +__Development:__ [async.js](https://github.com/caolan/async/raw/master/lib/async.js) - 17.5kb Uncompressed + +__Production:__ [async.min.js](https://github.com/caolan/async/raw/master/dist/async.min.js) - 1.7kb Packed and Gzipped + + +## In the Browser + +So far its been tested in IE6, IE7, IE8, FF3.6 and Chrome 5. Usage: + + + + + +## Documentation + +### Collections + +* [forEach](#forEach) +* [map](#map) +* [filter](#filter) +* [reject](#reject) +* [reduce](#reduce) +* [detect](#detect) +* [sortBy](#sortBy) +* [some](#some) +* [every](#every) +* [concat](#concat) + +### Control Flow + +* [series](#series) +* [parallel](#parallel) +* [whilst](#whilst) +* [until](#until) +* [waterfall](#waterfall) +* [queue](#queue) +* [auto](#auto) +* [iterator](#iterator) +* [apply](#apply) +* [nextTick](#nextTick) + +### Utils + +* [memoize](#memoize) +* [unmemoize](#unmemoize) +* [log](#log) +* [dir](#dir) +* [noConflict](#noConflict) + + +## Collections + + +### forEach(arr, iterator, callback) + +Applies an iterator function to each item in an array, in parallel. +The iterator is called with an item from the list and a callback for when it +has finished. If the iterator passes an error to this callback, the main +callback for the forEach function is immediately called with the error. + +Note, that since this function applies the iterator to each item in parallel +there is no guarantee that the iterator functions will complete in order. + +__Arguments__ + +* arr - An array to iterate over. +* iterator(item, callback) - A function to apply to each item in the array. + The iterator is passed a callback which must be called once it has completed. +* callback(err) - A callback which is called after all the iterator functions + have finished, or an error has occurred. + +__Example__ + + // assuming openFiles is an array of file names and saveFile is a function + // to save the modified contents of that file: + + async.forEach(openFiles, saveFile, function(err){ + // if any of the saves produced an error, err would equal that error + }); + +--------------------------------------- + + +### forEachSeries(arr, iterator, callback) + +The same as forEach only the iterator is applied to each item in the array in +series. The next iterator is only called once the current one has completed +processing. This means the iterator functions will complete in order. + + +--------------------------------------- + + +### forEachLimit(arr, limit, iterator, callback) + +The same as forEach only the iterator is applied to batches of items in the +array, in series. The next batch of iterators is only called once the current +one has completed processing. + +__Arguments__ + +* arr - An array to iterate over. +* limit - How many items should be in each batch. +* iterator(item, callback) - A function to apply to each item in the array. + The iterator is passed a callback which must be called once it has completed. +* callback(err) - A callback which is called after all the iterator functions + have finished, or an error has occurred. + +__Example__ + + // Assume documents is an array of JSON objects and requestApi is a + // function that interacts with a rate-limited REST api. + + async.forEachLimit(documents, 20, requestApi, function(err){ + // if any of the saves produced an error, err would equal that error + }); +--------------------------------------- + + +### map(arr, iterator, callback) + +Produces a new array of values by mapping each value in the given array through +the iterator function. The iterator is called with an item from the array and a +callback for when it has finished processing. The callback takes 2 arguments, +an error and the transformed item from the array. If the iterator passes an +error to this callback, the main callback for the map function is immediately +called with the error. + +Note, that since this function applies the iterator to each item in parallel +there is no guarantee that the iterator functions will complete in order, however +the results array will be in the same order as the original array. + +__Arguments__ + +* arr - An array to iterate over. +* iterator(item, callback) - A function to apply to each item in the array. + The iterator is passed a callback which must be called once it has completed + with an error (which can be null) and a transformed item. +* callback(err, results) - A callback which is called after all the iterator + functions have finished, or an error has occurred. Results is an array of the + transformed items from the original array. + +__Example__ + + async.map(['file1','file2','file3'], fs.stat, function(err, results){ + // results is now an array of stats for each file + }); + +--------------------------------------- + + +### mapSeries(arr, iterator, callback) + +The same as map only the iterator is applied to each item in the array in +series. The next iterator is only called once the current one has completed +processing. The results array will be in the same order as the original. + + +--------------------------------------- + + +### filter(arr, iterator, callback) + +__Alias:__ select + +Returns a new array of all the values which pass an async truth test. +_The callback for each iterator call only accepts a single argument of true or +false, it does not accept an error argument first!_ This is in-line with the +way node libraries work with truth tests like path.exists. This operation is +performed in parallel, but the results array will be in the same order as the +original. + +__Arguments__ + +* arr - An array to iterate over. +* iterator(item, callback) - A truth test to apply to each item in the array. + The iterator is passed a callback which must be called once it has completed. +* callback(results) - A callback which is called after all the iterator + functions have finished. + +__Example__ + + async.filter(['file1','file2','file3'], path.exists, function(results){ + // results now equals an array of the existing files + }); + +--------------------------------------- + + +### filterSeries(arr, iterator, callback) + +__alias:__ selectSeries + +The same as filter only the iterator is applied to each item in the array in +series. The next iterator is only called once the current one has completed +processing. The results array will be in the same order as the original. + +--------------------------------------- + + +### reject(arr, iterator, callback) + +The opposite of filter. Removes values that pass an async truth test. + +--------------------------------------- + + +### rejectSeries(arr, iterator, callback) + +The same as filter, only the iterator is applied to each item in the array +in series. + + +--------------------------------------- + + +### reduce(arr, memo, iterator, callback) + +__aliases:__ inject, foldl + +Reduces a list of values into a single value using an async iterator to return +each successive step. Memo is the initial state of the reduction. This +function only operates in series. For performance reasons, it may make sense to +split a call to this function into a parallel map, then use the normal +Array.prototype.reduce on the results. This function is for situations where +each step in the reduction needs to be async, if you can get the data before +reducing it then its probably a good idea to do so. + +__Arguments__ + +* arr - An array to iterate over. +* memo - The initial state of the reduction. +* iterator(memo, item, callback) - A function applied to each item in the + array to produce the next step in the reduction. The iterator is passed a + callback which accepts an optional error as its first argument, and the state + of the reduction as the second. If an error is passed to the callback, the + reduction is stopped and the main callback is immediately called with the + error. +* callback(err, result) - A callback which is called after all the iterator + functions have finished. Result is the reduced value. + +__Example__ + + async.reduce([1,2,3], 0, function(memo, item, callback){ + // pointless async: + process.nextTick(function(){ + callback(null, memo + item) + }); + }, function(err, result){ + // result is now equal to the last value of memo, which is 6 + }); + +--------------------------------------- + + +### reduceRight(arr, memo, iterator, callback) + +__Alias:__ foldr + +Same as reduce, only operates on the items in the array in reverse order. + + +--------------------------------------- + + +### detect(arr, iterator, callback) + +Returns the first value in a list that passes an async truth test. The +iterator is applied in parallel, meaning the first iterator to return true will +fire the detect callback with that result. That means the result might not be +the first item in the original array (in terms of order) that passes the test. + +If order within the original array is important then look at detectSeries. + +__Arguments__ + +* arr - An array to iterate over. +* iterator(item, callback) - A truth test to apply to each item in the array. + The iterator is passed a callback which must be called once it has completed. +* callback(result) - A callback which is called as soon as any iterator returns + true, or after all the iterator functions have finished. Result will be + the first item in the array that passes the truth test (iterator) or the + value undefined if none passed. + +__Example__ + + async.detect(['file1','file2','file3'], path.exists, function(result){ + // result now equals the first file in the list that exists + }); + +--------------------------------------- + + +### detectSeries(arr, iterator, callback) + +The same as detect, only the iterator is applied to each item in the array +in series. This means the result is always the first in the original array (in +terms of array order) that passes the truth test. + + +--------------------------------------- + + +### sortBy(arr, iterator, callback) + +Sorts a list by the results of running each value through an async iterator. + +__Arguments__ + +* arr - An array to iterate over. +* iterator(item, callback) - A function to apply to each item in the array. + The iterator is passed a callback which must be called once it has completed + with an error (which can be null) and a value to use as the sort criteria. +* callback(err, results) - A callback which is called after all the iterator + functions have finished, or an error has occurred. Results is the items from + the original array sorted by the values returned by the iterator calls. + +__Example__ + + async.sortBy(['file1','file2','file3'], function(file, callback){ + fs.stat(file, function(err, stats){ + callback(err, stats.mtime); + }); + }, function(err, results){ + // results is now the original array of files sorted by + // modified date + }); + + +--------------------------------------- + + +### some(arr, iterator, callback) + +__Alias:__ any + +Returns true if at least one element in the array satisfies an async test. +_The callback for each iterator call only accepts a single argument of true or +false, it does not accept an error argument first!_ This is in-line with the +way node libraries work with truth tests like path.exists. Once any iterator +call returns true, the main callback is immediately called. + +__Arguments__ + +* arr - An array to iterate over. +* iterator(item, callback) - A truth test to apply to each item in the array. + The iterator is passed a callback which must be called once it has completed. +* callback(result) - A callback which is called as soon as any iterator returns + true, or after all the iterator functions have finished. Result will be + either true or false depending on the values of the async tests. + +__Example__ + + async.some(['file1','file2','file3'], path.exists, function(result){ + // if result is true then at least one of the files exists + }); + +--------------------------------------- + + +### every(arr, iterator, callback) + +__Alias:__ all + +Returns true if every element in the array satisfies an async test. +_The callback for each iterator call only accepts a single argument of true or +false, it does not accept an error argument first!_ This is in-line with the +way node libraries work with truth tests like path.exists. + +__Arguments__ + +* arr - An array to iterate over. +* iterator(item, callback) - A truth test to apply to each item in the array. + The iterator is passed a callback which must be called once it has completed. +* callback(result) - A callback which is called after all the iterator + functions have finished. Result will be either true or false depending on + the values of the async tests. + +__Example__ + + async.every(['file1','file2','file3'], path.exists, function(result){ + // if result is true then every file exists + }); + +--------------------------------------- + + +### concat(arr, iterator, callback) + +Applies an iterator to each item in a list, concatenating the results. Returns the +concatenated list. The iterators are called in parallel, and the results are +concatenated as they return. There is no guarantee that the results array will +be returned in the original order of the arguments passed to the iterator function. + +__Arguments__ + +* arr - An array to iterate over +* iterator(item, callback) - A function to apply to each item in the array. + The iterator is passed a callback which must be called once it has completed + with an error (which can be null) and an array of results. +* callback(err, results) - A callback which is called after all the iterator + functions have finished, or an error has occurred. Results is an array containing + the concatenated results of the iterator function. + +__Example__ + + async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files){ + // files is now a list of filenames that exist in the 3 directories + }); + +--------------------------------------- + + +### concatSeries(arr, iterator, callback) + +Same as async.concat, but executes in series instead of parallel. + + +## Control Flow + + +### series(tasks, [callback]) + +Run an array of functions in series, each one running once the previous +function has completed. If any functions in the series pass an error to its +callback, no more functions are run and the callback for the series is +immediately called with the value of the error. Once the tasks have completed, +the results are passed to the final callback as an array. + +It is also possible to use an object instead of an array. Each property will be +run as a function and the results will be passed to the final callback as an object +instead of an array. This can be a more readable way of handling results from +async.series. + + +__Arguments__ + +* tasks - An array or object containing functions to run, each function is passed + a callback it must call on completion. +* callback(err, results) - An optional callback to run once all the functions + have completed. This function gets an array of all the arguments passed to + the callbacks used in the array. + +__Example__ + + async.series([ + function(callback){ + // do some stuff ... + callback(null, 'one'); + }, + function(callback){ + // do some more stuff ... + callback(null, 'two'); + }, + ], + // optional callback + function(err, results){ + // results is now equal to ['one', 'two'] + }); + + + // an example using an object instead of an array + async.series({ + one: function(callback){ + setTimeout(function(){ + callback(null, 1); + }, 200); + }, + two: function(callback){ + setTimeout(function(){ + callback(null, 2); + }, 100); + }, + }, + function(err, results) { + // results is now equal to: {one: 1, two: 2} + }); + + +--------------------------------------- + + +### parallel(tasks, [callback]) + +Run an array of functions in parallel, without waiting until the previous +function has completed. If any of the functions pass an error to its +callback, the main callback is immediately called with the value of the error. +Once the tasks have completed, the results are passed to the final callback as an +array. + +It is also possible to use an object instead of an array. Each property will be +run as a function and the results will be passed to the final callback as an object +instead of an array. This can be a more readable way of handling results from +async.parallel. + + +__Arguments__ + +* tasks - An array or object containing functions to run, each function is passed a + callback it must call on completion. +* callback(err, results) - An optional callback to run once all the functions + have completed. This function gets an array of all the arguments passed to + the callbacks used in the array. + +__Example__ + + async.parallel([ + function(callback){ + setTimeout(function(){ + callback(null, 'one'); + }, 200); + }, + function(callback){ + setTimeout(function(){ + callback(null, 'two'); + }, 100); + }, + ], + // optional callback + function(err, results){ + // the results array will equal ['one','two'] even though + // the second function had a shorter timeout. + }); + + + // an example using an object instead of an array + async.parallel({ + one: function(callback){ + setTimeout(function(){ + callback(null, 1); + }, 200); + }, + two: function(callback){ + setTimeout(function(){ + callback(null, 2); + }, 100); + }, + }, + function(err, results) { + // results is now equals to: {one: 1, two: 2} + }); + + +--------------------------------------- + + +### whilst(test, fn, callback) + +Repeatedly call fn, while test returns true. Calls the callback when stopped, +or an error occurs. + +__Arguments__ + +* test() - synchronous truth test to perform before each execution of fn. +* fn(callback) - A function to call each time the test passes. The function is + passed a callback which must be called once it has completed with an optional + error as the first argument. +* callback(err) - A callback which is called after the test fails and repeated + execution of fn has stopped. + +__Example__ + + var count = 0; + + async.whilst( + function () { return count < 5; }, + function (callback) { + count++; + setTimeout(callback, 1000); + }, + function (err) { + // 5 seconds have passed + } + ); + + +--------------------------------------- + + +### until(test, fn, callback) + +Repeatedly call fn, until test returns true. Calls the callback when stopped, +or an error occurs. + +The inverse of async.whilst. + + +--------------------------------------- + + +### waterfall(tasks, [callback]) + +Runs an array of functions in series, each passing their results to the next in +the array. However, if any of the functions pass an error to the callback, the +next function is not executed and the main callback is immediately called with +the error. + +__Arguments__ + +* tasks - An array of functions to run, each function is passed a callback it + must call on completion. +* callback(err, [results]) - An optional callback to run once all the functions + have completed. This will be passed the results of the last task's callback. + + + +__Example__ + + async.waterfall([ + function(callback){ + callback(null, 'one', 'two'); + }, + function(arg1, arg2, callback){ + callback(null, 'three'); + }, + function(arg1, callback){ + // arg1 now equals 'three' + callback(null, 'done'); + } + ], function (err, result) { + // result now equals 'done' + }); + + +--------------------------------------- + + +### queue(worker, concurrency) + +Creates a queue object with the specified concurrency. Tasks added to the +queue will be processed in parallel (up to the concurrency limit). If all +workers are in progress, the task is queued until one is available. Once +a worker has completed a task, the task's callback is called. + +__Arguments__ + +* worker(task, callback) - An asynchronous function for processing a queued + task. +* concurrency - An integer for determining how many worker functions should be + run in parallel. + +__Queue objects__ + +The queue object returned by this function has the following properties and +methods: + +* length() - a function returning the number of items waiting to be processed. +* concurrency - an integer for determining how many worker functions should be + run in parallel. This property can be changed after a queue is created to + alter the concurrency on-the-fly. +* push(task, [callback]) - add a new task to the queue, the callback is called + once the worker has finished processing the task. + instead of a single task, an array of tasks can be submitted. the respective callback is used for every task in the list. +* saturated - a callback that is called when the queue length hits the concurrency and further tasks will be queued +* empty - a callback that is called when the last item from the queue is given to a worker +* drain - a callback that is called when the last item from the queue has returned from the worker + +__Example__ + + // create a queue object with concurrency 2 + + var q = async.queue(function (task, callback) { + console.log('hello ' + task.name); + callback(); + }, 2); + + + // assign a callback + q.drain = function() { + console.log('all items have been processed'); + } + + // add some items to the queue + + q.push({name: 'foo'}, function (err) { + console.log('finished processing foo'); + }); + q.push({name: 'bar'}, function (err) { + console.log('finished processing bar'); + }); + + // add some items to the queue (batch-wise) + + q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function (err) { + console.log('finished processing bar'); + }); + + +--------------------------------------- + + +### auto(tasks, [callback]) + +Determines the best order for running functions based on their requirements. +Each function can optionally depend on other functions being completed first, +and each function is run as soon as its requirements are satisfied. If any of +the functions pass an error to their callback, that function will not complete +(so any other functions depending on it will not run) and the main callback +will be called immediately with the error. Functions also receive an object +containing the results of functions which have completed so far. + +__Arguments__ + +* tasks - An object literal containing named functions or an array of + requirements, with the function itself the last item in the array. The key + used for each function or array is used when specifying requirements. The + syntax is easier to understand by looking at the example. +* callback(err, results) - An optional callback which is called when all the + tasks have been completed. The callback will receive an error as an argument + if any tasks pass an error to their callback. If all tasks complete + successfully, it will receive an object containing their results. + +__Example__ + + async.auto({ + get_data: function(callback){ + // async code to get some data + }, + make_folder: function(callback){ + // async code to create a directory to store a file in + // this is run at the same time as getting the data + }, + write_file: ['get_data', 'make_folder', function(callback){ + // once there is some data and the directory exists, + // write the data to a file in the directory + callback(null, filename); + }], + email_link: ['write_file', function(callback, results){ + // once the file is written let's email a link to it... + // results.write_file contains the filename returned by write_file. + }] + }); + +This is a fairly trivial example, but to do this using the basic parallel and +series functions would look like this: + + async.parallel([ + function(callback){ + // async code to get some data + }, + function(callback){ + // async code to create a directory to store a file in + // this is run at the same time as getting the data + } + ], + function(results){ + async.series([ + function(callback){ + // once there is some data and the directory exists, + // write the data to a file in the directory + }, + email_link: function(callback){ + // once the file is written let's email a link to it... + } + ]); + }); + +For a complicated series of async tasks using the auto function makes adding +new tasks much easier and makes the code more readable. + + +--------------------------------------- + + +### iterator(tasks) + +Creates an iterator function which calls the next function in the array, +returning a continuation to call the next one after that. Its also possible to +'peek' the next iterator by doing iterator.next(). + +This function is used internally by the async module but can be useful when +you want to manually control the flow of functions in series. + +__Arguments__ + +* tasks - An array of functions to run, each function is passed a callback it + must call on completion. + +__Example__ + + var iterator = async.iterator([ + function(){ sys.p('one'); }, + function(){ sys.p('two'); }, + function(){ sys.p('three'); } + ]); + + node> var iterator2 = iterator(); + 'one' + node> var iterator3 = iterator2(); + 'two' + node> iterator3(); + 'three' + node> var nextfn = iterator2.next(); + node> nextfn(); + 'three' + + +--------------------------------------- + + +### apply(function, arguments..) + +Creates a continuation function with some arguments already applied, a useful +shorthand when combined with other control flow functions. Any arguments +passed to the returned function are added to the arguments originally passed +to apply. + +__Arguments__ + +* function - The function you want to eventually apply all arguments to. +* arguments... - Any number of arguments to automatically apply when the + continuation is called. + +__Example__ + + // using apply + + async.parallel([ + async.apply(fs.writeFile, 'testfile1', 'test1'), + async.apply(fs.writeFile, 'testfile2', 'test2'), + ]); + + + // the same process without using apply + + async.parallel([ + function(callback){ + fs.writeFile('testfile1', 'test1', callback); + }, + function(callback){ + fs.writeFile('testfile2', 'test2', callback); + }, + ]); + +It's possible to pass any number of additional arguments when calling the +continuation: + + node> var fn = async.apply(sys.puts, 'one'); + node> fn('two', 'three'); + one + two + three + +--------------------------------------- + + +### nextTick(callback) + +Calls the callback on a later loop around the event loop. In node.js this just +calls process.nextTick, in the browser it falls back to setTimeout(callback, 0), +which means other higher priority events may precede the execution of the callback. + +This is used internally for browser-compatibility purposes. + +__Arguments__ + +* callback - The function to call on a later loop around the event loop. + +__Example__ + + var call_order = []; + async.nextTick(function(){ + call_order.push('two'); + // call_order now equals ['one','two] + }); + call_order.push('one') + + +## Utils + + +### memoize(fn, [hasher]) + +Caches the results of an async function. When creating a hash to store function +results against, the callback is omitted from the hash and an optional hash +function can be used. + +__Arguments__ + +* fn - the function you to proxy and cache results from. +* hasher - an optional function for generating a custom hash for storing + results, it has all the arguments applied to it apart from the callback, and + must be synchronous. + +__Example__ + + var slow_fn = function (name, callback) { + // do something + callback(null, result); + }; + var fn = async.memoize(slow_fn); + + // fn can now be used as if it were slow_fn + fn('some name', function () { + // callback + }); + + +### unmemoize(fn) + +Undoes a memoized function, reverting it to the original, unmemoized +form. Comes handy in tests. + +__Arguments__ + +* fn - the memoized function + + +### log(function, arguments) + +Logs the result of an async function to the console. Only works in node.js or +in browsers that support console.log and console.error (such as FF and Chrome). +If multiple arguments are returned from the async function, console.log is +called on each argument in order. + +__Arguments__ + +* function - The function you want to eventually apply all arguments to. +* arguments... - Any number of arguments to apply to the function. + +__Example__ + + var hello = function(name, callback){ + setTimeout(function(){ + callback(null, 'hello ' + name); + }, 1000); + }; + + node> async.log(hello, 'world'); + 'hello world' + + +--------------------------------------- + + +### dir(function, arguments) + +Logs the result of an async function to the console using console.dir to +display the properties of the resulting object. Only works in node.js or +in browsers that support console.dir and console.error (such as FF and Chrome). +If multiple arguments are returned from the async function, console.dir is +called on each argument in order. + +__Arguments__ + +* function - The function you want to eventually apply all arguments to. +* arguments... - Any number of arguments to apply to the function. + +__Example__ + + var hello = function(name, callback){ + setTimeout(function(){ + callback(null, {hello: name}); + }, 1000); + }; + + node> async.dir(hello, 'world'); + {hello: 'world'} + + +--------------------------------------- + + +### noConflict() + +Changes the value of async back to its original value, returning a reference to the +async object. diff --git a/Phaser/node_modules/grunt/node_modules/async/package.json b/Phaser/node_modules/grunt/node_modules/async/package.json new file mode 100644 index 00000000..8fbed48a --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/async/package.json @@ -0,0 +1,35 @@ +{ + "name": "async", + "description": "Higher-order functions and common patterns for asynchronous code", + "main": "./index", + "author": { + "name": "Caolan McMahon" + }, + "version": "0.1.22", + "repository": { + "type": "git", + "url": "http://github.com/caolan/async.git" + }, + "bugs": { + "url": "http://github.com/caolan/async/issues" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://github.com/caolan/async/raw/master/LICENSE" + } + ], + "devDependencies": { + "nodeunit": ">0.0.0", + "uglify-js": "1.2.x", + "nodelint": ">0.0.0" + }, + "readme": "# Async.js\n\nAsync is a utility module which provides straight-forward, powerful functions\nfor working with asynchronous JavaScript. Although originally designed for\nuse with [node.js](http://nodejs.org), it can also be used directly in the\nbrowser.\n\nAsync provides around 20 functions that include the usual 'functional'\nsuspects (map, reduce, filter, forEach…) as well as some common patterns\nfor asynchronous control flow (parallel, series, waterfall…). All these\nfunctions assume you follow the node.js convention of providing a single\ncallback as the last argument of your async function.\n\n\n## Quick Examples\n\n async.map(['file1','file2','file3'], fs.stat, function(err, results){\n // results is now an array of stats for each file\n });\n\n async.filter(['file1','file2','file3'], path.exists, function(results){\n // results now equals an array of the existing files\n });\n\n async.parallel([\n function(){ ... },\n function(){ ... }\n ], callback);\n\n async.series([\n function(){ ... },\n function(){ ... }\n ]);\n\nThere are many more functions available so take a look at the docs below for a\nfull list. This module aims to be comprehensive, so if you feel anything is\nmissing please create a GitHub issue for it.\n\n\n## Download\n\nReleases are available for download from\n[GitHub](http://github.com/caolan/async/downloads).\nAlternatively, you can install using Node Package Manager (npm):\n\n npm install async\n\n\n__Development:__ [async.js](https://github.com/caolan/async/raw/master/lib/async.js) - 17.5kb Uncompressed\n\n__Production:__ [async.min.js](https://github.com/caolan/async/raw/master/dist/async.min.js) - 1.7kb Packed and Gzipped\n\n\n## In the Browser\n\nSo far its been tested in IE6, IE7, IE8, FF3.6 and Chrome 5. Usage:\n\n \n \n\n\n## Documentation\n\n### Collections\n\n* [forEach](#forEach)\n* [map](#map)\n* [filter](#filter)\n* [reject](#reject)\n* [reduce](#reduce)\n* [detect](#detect)\n* [sortBy](#sortBy)\n* [some](#some)\n* [every](#every)\n* [concat](#concat)\n\n### Control Flow\n\n* [series](#series)\n* [parallel](#parallel)\n* [whilst](#whilst)\n* [until](#until)\n* [waterfall](#waterfall)\n* [queue](#queue)\n* [auto](#auto)\n* [iterator](#iterator)\n* [apply](#apply)\n* [nextTick](#nextTick)\n\n### Utils\n\n* [memoize](#memoize)\n* [unmemoize](#unmemoize)\n* [log](#log)\n* [dir](#dir)\n* [noConflict](#noConflict)\n\n\n## Collections\n\n\n### forEach(arr, iterator, callback)\n\nApplies an iterator function to each item in an array, in parallel.\nThe iterator is called with an item from the list and a callback for when it\nhas finished. If the iterator passes an error to this callback, the main\ncallback for the forEach function is immediately called with the error.\n\nNote, that since this function applies the iterator to each item in parallel\nthere is no guarantee that the iterator functions will complete in order.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A function to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed.\n* callback(err) - A callback which is called after all the iterator functions\n have finished, or an error has occurred.\n\n__Example__\n\n // assuming openFiles is an array of file names and saveFile is a function\n // to save the modified contents of that file:\n\n async.forEach(openFiles, saveFile, function(err){\n // if any of the saves produced an error, err would equal that error\n });\n\n---------------------------------------\n\n\n### forEachSeries(arr, iterator, callback)\n\nThe same as forEach only the iterator is applied to each item in the array in\nseries. The next iterator is only called once the current one has completed\nprocessing. This means the iterator functions will complete in order.\n\n\n---------------------------------------\n\n\n### forEachLimit(arr, limit, iterator, callback)\n\nThe same as forEach only the iterator is applied to batches of items in the\narray, in series. The next batch of iterators is only called once the current\none has completed processing.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* limit - How many items should be in each batch.\n* iterator(item, callback) - A function to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed.\n* callback(err) - A callback which is called after all the iterator functions\n have finished, or an error has occurred.\n\n__Example__\n\n // Assume documents is an array of JSON objects and requestApi is a\n // function that interacts with a rate-limited REST api.\n\n async.forEachLimit(documents, 20, requestApi, function(err){\n // if any of the saves produced an error, err would equal that error\n });\n---------------------------------------\n\n\n### map(arr, iterator, callback)\n\nProduces a new array of values by mapping each value in the given array through\nthe iterator function. The iterator is called with an item from the array and a\ncallback for when it has finished processing. The callback takes 2 arguments, \nan error and the transformed item from the array. If the iterator passes an\nerror to this callback, the main callback for the map function is immediately\ncalled with the error.\n\nNote, that since this function applies the iterator to each item in parallel\nthere is no guarantee that the iterator functions will complete in order, however\nthe results array will be in the same order as the original array.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A function to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed\n with an error (which can be null) and a transformed item.\n* callback(err, results) - A callback which is called after all the iterator\n functions have finished, or an error has occurred. Results is an array of the\n transformed items from the original array.\n\n__Example__\n\n async.map(['file1','file2','file3'], fs.stat, function(err, results){\n // results is now an array of stats for each file\n });\n\n---------------------------------------\n\n\n### mapSeries(arr, iterator, callback)\n\nThe same as map only the iterator is applied to each item in the array in\nseries. The next iterator is only called once the current one has completed\nprocessing. The results array will be in the same order as the original.\n\n\n---------------------------------------\n\n\n### filter(arr, iterator, callback)\n\n__Alias:__ select\n\nReturns a new array of all the values which pass an async truth test.\n_The callback for each iterator call only accepts a single argument of true or\nfalse, it does not accept an error argument first!_ This is in-line with the\nway node libraries work with truth tests like path.exists. This operation is\nperformed in parallel, but the results array will be in the same order as the\noriginal.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A truth test to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed.\n* callback(results) - A callback which is called after all the iterator\n functions have finished.\n\n__Example__\n\n async.filter(['file1','file2','file3'], path.exists, function(results){\n // results now equals an array of the existing files\n });\n\n---------------------------------------\n\n\n### filterSeries(arr, iterator, callback)\n\n__alias:__ selectSeries\n\nThe same as filter only the iterator is applied to each item in the array in\nseries. The next iterator is only called once the current one has completed\nprocessing. The results array will be in the same order as the original.\n\n---------------------------------------\n\n\n### reject(arr, iterator, callback)\n\nThe opposite of filter. Removes values that pass an async truth test.\n\n---------------------------------------\n\n\n### rejectSeries(arr, iterator, callback)\n\nThe same as filter, only the iterator is applied to each item in the array\nin series.\n\n\n---------------------------------------\n\n\n### reduce(arr, memo, iterator, callback)\n\n__aliases:__ inject, foldl\n\nReduces a list of values into a single value using an async iterator to return\neach successive step. Memo is the initial state of the reduction. This\nfunction only operates in series. For performance reasons, it may make sense to\nsplit a call to this function into a parallel map, then use the normal\nArray.prototype.reduce on the results. This function is for situations where\neach step in the reduction needs to be async, if you can get the data before\nreducing it then its probably a good idea to do so.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* memo - The initial state of the reduction.\n* iterator(memo, item, callback) - A function applied to each item in the\n array to produce the next step in the reduction. The iterator is passed a\n callback which accepts an optional error as its first argument, and the state\n of the reduction as the second. If an error is passed to the callback, the\n reduction is stopped and the main callback is immediately called with the\n error.\n* callback(err, result) - A callback which is called after all the iterator\n functions have finished. Result is the reduced value.\n\n__Example__\n\n async.reduce([1,2,3], 0, function(memo, item, callback){\n // pointless async:\n process.nextTick(function(){\n callback(null, memo + item)\n });\n }, function(err, result){\n // result is now equal to the last value of memo, which is 6\n });\n\n---------------------------------------\n\n\n### reduceRight(arr, memo, iterator, callback)\n\n__Alias:__ foldr\n\nSame as reduce, only operates on the items in the array in reverse order.\n\n\n---------------------------------------\n\n\n### detect(arr, iterator, callback)\n\nReturns the first value in a list that passes an async truth test. The\niterator is applied in parallel, meaning the first iterator to return true will\nfire the detect callback with that result. That means the result might not be\nthe first item in the original array (in terms of order) that passes the test.\n\nIf order within the original array is important then look at detectSeries.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A truth test to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed.\n* callback(result) - A callback which is called as soon as any iterator returns\n true, or after all the iterator functions have finished. Result will be\n the first item in the array that passes the truth test (iterator) or the\n value undefined if none passed.\n\n__Example__\n\n async.detect(['file1','file2','file3'], path.exists, function(result){\n // result now equals the first file in the list that exists\n });\n\n---------------------------------------\n\n\n### detectSeries(arr, iterator, callback)\n\nThe same as detect, only the iterator is applied to each item in the array\nin series. This means the result is always the first in the original array (in\nterms of array order) that passes the truth test.\n\n\n---------------------------------------\n\n\n### sortBy(arr, iterator, callback)\n\nSorts a list by the results of running each value through an async iterator.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A function to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed\n with an error (which can be null) and a value to use as the sort criteria.\n* callback(err, results) - A callback which is called after all the iterator\n functions have finished, or an error has occurred. Results is the items from\n the original array sorted by the values returned by the iterator calls.\n\n__Example__\n\n async.sortBy(['file1','file2','file3'], function(file, callback){\n fs.stat(file, function(err, stats){\n callback(err, stats.mtime);\n });\n }, function(err, results){\n // results is now the original array of files sorted by\n // modified date\n });\n\n\n---------------------------------------\n\n\n### some(arr, iterator, callback)\n\n__Alias:__ any\n\nReturns true if at least one element in the array satisfies an async test.\n_The callback for each iterator call only accepts a single argument of true or\nfalse, it does not accept an error argument first!_ This is in-line with the\nway node libraries work with truth tests like path.exists. Once any iterator\ncall returns true, the main callback is immediately called.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A truth test to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed.\n* callback(result) - A callback which is called as soon as any iterator returns\n true, or after all the iterator functions have finished. Result will be\n either true or false depending on the values of the async tests.\n\n__Example__\n\n async.some(['file1','file2','file3'], path.exists, function(result){\n // if result is true then at least one of the files exists\n });\n\n---------------------------------------\n\n\n### every(arr, iterator, callback)\n\n__Alias:__ all\n\nReturns true if every element in the array satisfies an async test.\n_The callback for each iterator call only accepts a single argument of true or\nfalse, it does not accept an error argument first!_ This is in-line with the\nway node libraries work with truth tests like path.exists.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A truth test to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed.\n* callback(result) - A callback which is called after all the iterator\n functions have finished. Result will be either true or false depending on\n the values of the async tests.\n\n__Example__\n\n async.every(['file1','file2','file3'], path.exists, function(result){\n // if result is true then every file exists\n });\n\n---------------------------------------\n\n\n### concat(arr, iterator, callback)\n\nApplies an iterator to each item in a list, concatenating the results. Returns the\nconcatenated list. The iterators are called in parallel, and the results are\nconcatenated as they return. There is no guarantee that the results array will\nbe returned in the original order of the arguments passed to the iterator function.\n\n__Arguments__\n\n* arr - An array to iterate over\n* iterator(item, callback) - A function to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed\n with an error (which can be null) and an array of results.\n* callback(err, results) - A callback which is called after all the iterator\n functions have finished, or an error has occurred. Results is an array containing\n the concatenated results of the iterator function.\n\n__Example__\n\n async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files){\n // files is now a list of filenames that exist in the 3 directories\n });\n\n---------------------------------------\n\n\n### concatSeries(arr, iterator, callback)\n\nSame as async.concat, but executes in series instead of parallel.\n\n\n## Control Flow\n\n\n### series(tasks, [callback])\n\nRun an array of functions in series, each one running once the previous\nfunction has completed. If any functions in the series pass an error to its\ncallback, no more functions are run and the callback for the series is\nimmediately called with the value of the error. Once the tasks have completed,\nthe results are passed to the final callback as an array.\n\nIt is also possible to use an object instead of an array. Each property will be\nrun as a function and the results will be passed to the final callback as an object\ninstead of an array. This can be a more readable way of handling results from\nasync.series.\n\n\n__Arguments__\n\n* tasks - An array or object containing functions to run, each function is passed\n a callback it must call on completion.\n* callback(err, results) - An optional callback to run once all the functions\n have completed. This function gets an array of all the arguments passed to\n the callbacks used in the array.\n\n__Example__\n\n async.series([\n function(callback){\n // do some stuff ...\n callback(null, 'one');\n },\n function(callback){\n // do some more stuff ...\n callback(null, 'two');\n },\n ],\n // optional callback\n function(err, results){\n // results is now equal to ['one', 'two']\n });\n\n\n // an example using an object instead of an array\n async.series({\n one: function(callback){\n setTimeout(function(){\n callback(null, 1);\n }, 200);\n },\n two: function(callback){\n setTimeout(function(){\n callback(null, 2);\n }, 100);\n },\n },\n function(err, results) {\n // results is now equal to: {one: 1, two: 2}\n });\n\n\n---------------------------------------\n\n\n### parallel(tasks, [callback])\n\nRun an array of functions in parallel, without waiting until the previous\nfunction has completed. If any of the functions pass an error to its\ncallback, the main callback is immediately called with the value of the error.\nOnce the tasks have completed, the results are passed to the final callback as an\narray.\n\nIt is also possible to use an object instead of an array. Each property will be\nrun as a function and the results will be passed to the final callback as an object\ninstead of an array. This can be a more readable way of handling results from\nasync.parallel.\n\n\n__Arguments__\n\n* tasks - An array or object containing functions to run, each function is passed a\n callback it must call on completion.\n* callback(err, results) - An optional callback to run once all the functions\n have completed. This function gets an array of all the arguments passed to\n the callbacks used in the array.\n\n__Example__\n\n async.parallel([\n function(callback){\n setTimeout(function(){\n callback(null, 'one');\n }, 200);\n },\n function(callback){\n setTimeout(function(){\n callback(null, 'two');\n }, 100);\n },\n ],\n // optional callback\n function(err, results){\n // the results array will equal ['one','two'] even though\n // the second function had a shorter timeout.\n });\n\n\n // an example using an object instead of an array\n async.parallel({\n one: function(callback){\n setTimeout(function(){\n callback(null, 1);\n }, 200);\n },\n two: function(callback){\n setTimeout(function(){\n callback(null, 2);\n }, 100);\n },\n },\n function(err, results) {\n // results is now equals to: {one: 1, two: 2}\n });\n\n\n---------------------------------------\n\n\n### whilst(test, fn, callback)\n\nRepeatedly call fn, while test returns true. Calls the callback when stopped,\nor an error occurs.\n\n__Arguments__\n\n* test() - synchronous truth test to perform before each execution of fn.\n* fn(callback) - A function to call each time the test passes. The function is\n passed a callback which must be called once it has completed with an optional\n error as the first argument.\n* callback(err) - A callback which is called after the test fails and repeated\n execution of fn has stopped.\n\n__Example__\n\n var count = 0;\n\n async.whilst(\n function () { return count < 5; },\n function (callback) {\n count++;\n setTimeout(callback, 1000);\n },\n function (err) {\n // 5 seconds have passed\n }\n );\n\n\n---------------------------------------\n\n\n### until(test, fn, callback)\n\nRepeatedly call fn, until test returns true. Calls the callback when stopped,\nor an error occurs.\n\nThe inverse of async.whilst.\n\n\n---------------------------------------\n\n\n### waterfall(tasks, [callback])\n\nRuns an array of functions in series, each passing their results to the next in\nthe array. However, if any of the functions pass an error to the callback, the\nnext function is not executed and the main callback is immediately called with\nthe error.\n\n__Arguments__\n\n* tasks - An array of functions to run, each function is passed a callback it\n must call on completion.\n* callback(err, [results]) - An optional callback to run once all the functions\n have completed. This will be passed the results of the last task's callback.\n\n\n\n__Example__\n\n async.waterfall([\n function(callback){\n callback(null, 'one', 'two');\n },\n function(arg1, arg2, callback){\n callback(null, 'three');\n },\n function(arg1, callback){\n // arg1 now equals 'three'\n callback(null, 'done');\n }\n ], function (err, result) {\n // result now equals 'done' \n });\n\n\n---------------------------------------\n\n\n### queue(worker, concurrency)\n\nCreates a queue object with the specified concurrency. Tasks added to the\nqueue will be processed in parallel (up to the concurrency limit). If all\nworkers are in progress, the task is queued until one is available. Once\na worker has completed a task, the task's callback is called.\n\n__Arguments__\n\n* worker(task, callback) - An asynchronous function for processing a queued\n task.\n* concurrency - An integer for determining how many worker functions should be\n run in parallel.\n\n__Queue objects__\n\nThe queue object returned by this function has the following properties and\nmethods:\n\n* length() - a function returning the number of items waiting to be processed.\n* concurrency - an integer for determining how many worker functions should be\n run in parallel. This property can be changed after a queue is created to\n alter the concurrency on-the-fly.\n* push(task, [callback]) - add a new task to the queue, the callback is called\n once the worker has finished processing the task.\n instead of a single task, an array of tasks can be submitted. the respective callback is used for every task in the list.\n* saturated - a callback that is called when the queue length hits the concurrency and further tasks will be queued\n* empty - a callback that is called when the last item from the queue is given to a worker\n* drain - a callback that is called when the last item from the queue has returned from the worker\n\n__Example__\n\n // create a queue object with concurrency 2\n\n var q = async.queue(function (task, callback) {\n console.log('hello ' + task.name);\n callback();\n }, 2);\n\n\n // assign a callback\n q.drain = function() {\n console.log('all items have been processed');\n }\n\n // add some items to the queue\n\n q.push({name: 'foo'}, function (err) {\n console.log('finished processing foo');\n });\n q.push({name: 'bar'}, function (err) {\n console.log('finished processing bar');\n });\n\n // add some items to the queue (batch-wise)\n\n q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function (err) {\n console.log('finished processing bar');\n });\n\n\n---------------------------------------\n\n\n### auto(tasks, [callback])\n\nDetermines the best order for running functions based on their requirements.\nEach function can optionally depend on other functions being completed first,\nand each function is run as soon as its requirements are satisfied. If any of\nthe functions pass an error to their callback, that function will not complete\n(so any other functions depending on it will not run) and the main callback\nwill be called immediately with the error. Functions also receive an object\ncontaining the results of functions which have completed so far.\n\n__Arguments__\n\n* tasks - An object literal containing named functions or an array of\n requirements, with the function itself the last item in the array. The key\n used for each function or array is used when specifying requirements. The\n syntax is easier to understand by looking at the example.\n* callback(err, results) - An optional callback which is called when all the\n tasks have been completed. The callback will receive an error as an argument\n if any tasks pass an error to their callback. If all tasks complete\n successfully, it will receive an object containing their results.\n\n__Example__\n\n async.auto({\n get_data: function(callback){\n // async code to get some data\n },\n make_folder: function(callback){\n // async code to create a directory to store a file in\n // this is run at the same time as getting the data\n },\n write_file: ['get_data', 'make_folder', function(callback){\n // once there is some data and the directory exists,\n // write the data to a file in the directory\n callback(null, filename);\n }],\n email_link: ['write_file', function(callback, results){\n // once the file is written let's email a link to it...\n // results.write_file contains the filename returned by write_file.\n }]\n });\n\nThis is a fairly trivial example, but to do this using the basic parallel and\nseries functions would look like this:\n\n async.parallel([\n function(callback){\n // async code to get some data\n },\n function(callback){\n // async code to create a directory to store a file in\n // this is run at the same time as getting the data\n }\n ],\n function(results){\n async.series([\n function(callback){\n // once there is some data and the directory exists,\n // write the data to a file in the directory\n },\n email_link: function(callback){\n // once the file is written let's email a link to it...\n }\n ]);\n });\n\nFor a complicated series of async tasks using the auto function makes adding\nnew tasks much easier and makes the code more readable.\n\n\n---------------------------------------\n\n\n### iterator(tasks)\n\nCreates an iterator function which calls the next function in the array,\nreturning a continuation to call the next one after that. Its also possible to\n'peek' the next iterator by doing iterator.next().\n\nThis function is used internally by the async module but can be useful when\nyou want to manually control the flow of functions in series.\n\n__Arguments__\n\n* tasks - An array of functions to run, each function is passed a callback it\n must call on completion.\n\n__Example__\n\n var iterator = async.iterator([\n function(){ sys.p('one'); },\n function(){ sys.p('two'); },\n function(){ sys.p('three'); }\n ]);\n\n node> var iterator2 = iterator();\n 'one'\n node> var iterator3 = iterator2();\n 'two'\n node> iterator3();\n 'three'\n node> var nextfn = iterator2.next();\n node> nextfn();\n 'three'\n\n\n---------------------------------------\n\n\n### apply(function, arguments..)\n\nCreates a continuation function with some arguments already applied, a useful\nshorthand when combined with other control flow functions. Any arguments\npassed to the returned function are added to the arguments originally passed\nto apply.\n\n__Arguments__\n\n* function - The function you want to eventually apply all arguments to.\n* arguments... - Any number of arguments to automatically apply when the\n continuation is called.\n\n__Example__\n\n // using apply\n\n async.parallel([\n async.apply(fs.writeFile, 'testfile1', 'test1'),\n async.apply(fs.writeFile, 'testfile2', 'test2'),\n ]);\n\n\n // the same process without using apply\n\n async.parallel([\n function(callback){\n fs.writeFile('testfile1', 'test1', callback);\n },\n function(callback){\n fs.writeFile('testfile2', 'test2', callback);\n },\n ]);\n\nIt's possible to pass any number of additional arguments when calling the\ncontinuation:\n\n node> var fn = async.apply(sys.puts, 'one');\n node> fn('two', 'three');\n one\n two\n three\n\n---------------------------------------\n\n\n### nextTick(callback)\n\nCalls the callback on a later loop around the event loop. In node.js this just\ncalls process.nextTick, in the browser it falls back to setTimeout(callback, 0),\nwhich means other higher priority events may precede the execution of the callback.\n\nThis is used internally for browser-compatibility purposes.\n\n__Arguments__\n\n* callback - The function to call on a later loop around the event loop.\n\n__Example__\n\n var call_order = [];\n async.nextTick(function(){\n call_order.push('two');\n // call_order now equals ['one','two]\n });\n call_order.push('one')\n\n\n## Utils\n\n\n### memoize(fn, [hasher])\n\nCaches the results of an async function. When creating a hash to store function\nresults against, the callback is omitted from the hash and an optional hash\nfunction can be used.\n\n__Arguments__\n\n* fn - the function you to proxy and cache results from.\n* hasher - an optional function for generating a custom hash for storing\n results, it has all the arguments applied to it apart from the callback, and\n must be synchronous.\n\n__Example__\n\n var slow_fn = function (name, callback) {\n // do something\n callback(null, result);\n };\n var fn = async.memoize(slow_fn);\n\n // fn can now be used as if it were slow_fn\n fn('some name', function () {\n // callback\n });\n\n\n### unmemoize(fn)\n\nUndoes a memoized function, reverting it to the original, unmemoized\nform. Comes handy in tests.\n\n__Arguments__\n\n* fn - the memoized function\n\n\n### log(function, arguments)\n\nLogs the result of an async function to the console. Only works in node.js or\nin browsers that support console.log and console.error (such as FF and Chrome).\nIf multiple arguments are returned from the async function, console.log is\ncalled on each argument in order.\n\n__Arguments__\n\n* function - The function you want to eventually apply all arguments to.\n* arguments... - Any number of arguments to apply to the function.\n\n__Example__\n\n var hello = function(name, callback){\n setTimeout(function(){\n callback(null, 'hello ' + name);\n }, 1000);\n };\n\n node> async.log(hello, 'world');\n 'hello world'\n\n\n---------------------------------------\n\n\n### dir(function, arguments)\n\nLogs the result of an async function to the console using console.dir to\ndisplay the properties of the resulting object. Only works in node.js or\nin browsers that support console.dir and console.error (such as FF and Chrome).\nIf multiple arguments are returned from the async function, console.dir is\ncalled on each argument in order.\n\n__Arguments__\n\n* function - The function you want to eventually apply all arguments to.\n* arguments... - Any number of arguments to apply to the function.\n\n__Example__\n\n var hello = function(name, callback){\n setTimeout(function(){\n callback(null, {hello: name});\n }, 1000);\n };\n\n node> async.dir(hello, 'world');\n {hello: 'world'}\n\n\n---------------------------------------\n\n\n### noConflict()\n\nChanges the value of async back to its original value, returning a reference to the\nasync object.\n", + "readmeFilename": "README.md", + "_id": "async@0.1.22", + "dist": { + "shasum": "3b270eedc0419d6f92a664444ce98e0f59a8fef7" + }, + "_from": "async@~0.1.22", + "_resolved": "https://registry.npmjs.org/async/-/async-0.1.22.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/coffee-script/.npmignore b/Phaser/node_modules/grunt/node_modules/coffee-script/.npmignore new file mode 100644 index 00000000..21e430d2 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/coffee-script/.npmignore @@ -0,0 +1,11 @@ +*.coffee +*.html +.DS_Store +.git* +Cakefile +documentation/ +examples/ +extras/coffee-script.js +raw/ +src/ +test/ diff --git a/Phaser/node_modules/grunt/node_modules/coffee-script/CNAME b/Phaser/node_modules/grunt/node_modules/coffee-script/CNAME new file mode 100644 index 00000000..faadabe5 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/coffee-script/CNAME @@ -0,0 +1 @@ +coffeescript.org \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/coffee-script/LICENSE b/Phaser/node_modules/grunt/node_modules/coffee-script/LICENSE new file mode 100644 index 00000000..dbe6b4e3 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/coffee-script/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2009-2012 Jeremy Ashkenas + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/coffee-script/README b/Phaser/node_modules/grunt/node_modules/coffee-script/README new file mode 100644 index 00000000..69ee6f43 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/coffee-script/README @@ -0,0 +1,51 @@ + + { + } } { + { { } } + } }{ { + { }{ } } _____ __ __ + ( }{ }{ { ) / ____| / _|/ _| + .- { { } { }} -. | | ___ | |_| |_ ___ ___ + ( ( } { } { } } ) | | / _ \| _| _/ _ \/ _ \ + |`-..________ ..-'| | |___| (_) | | | || __/ __/ + | | \_____\___/|_| |_| \___|\___| + | ;--. + | (__ \ _____ _ _ + | | ) ) / ____| (_) | | + | |/ / | (___ ___ _ __ _ _ __ | |_ + | ( / \___ \ / __| '__| | '_ \| __| + | |/ ____) | (__| | | | |_) | |_ + | | |_____/ \___|_| |_| .__/ \__| + `-.._________..-' | | + |_| + + + CoffeeScript is a little language that compiles into JavaScript. + + Install Node.js, and then the CoffeeScript compiler: + sudo bin/cake install + + Or, if you have the Node Package Manager installed: + npm install -g coffee-script + (Leave off the -g if you don't wish to install globally.) + + Execute a script: + coffee /path/to/script.coffee + + Compile a script: + coffee -c /path/to/script.coffee + + For documentation, usage, and examples, see: + http://coffeescript.org/ + + To suggest a feature, report a bug, or general discussion: + http://github.com/jashkenas/coffee-script/issues/ + + If you'd like to chat, drop by #coffeescript on Freenode IRC, + or on webchat.freenode.net. + + The source repository: + git://github.com/jashkenas/coffee-script.git + + All contributors are listed here: + http://github.com/jashkenas/coffee-script/contributors diff --git a/Phaser/node_modules/grunt/node_modules/coffee-script/Rakefile b/Phaser/node_modules/grunt/node_modules/coffee-script/Rakefile new file mode 100644 index 00000000..dfb85dab --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/coffee-script/Rakefile @@ -0,0 +1,78 @@ +require 'rubygems' +require 'erb' +require 'fileutils' +require 'rake/testtask' +require 'json' + +desc "Build the documentation page" +task :doc do + source = 'documentation/index.html.erb' + child = fork { exec "bin/coffee -bcw -o documentation/js documentation/coffee/*.coffee" } + at_exit { Process.kill("INT", child) } + Signal.trap("INT") { exit } + loop do + mtime = File.stat(source).mtime + if !@mtime || mtime > @mtime + rendered = ERB.new(File.read(source)).result(binding) + File.open('index.html', 'w+') {|f| f.write(rendered) } + end + @mtime = mtime + sleep 1 + end +end + +desc "Build coffee-script-source gem" +task :gem do + require 'rubygems' + require 'rubygems/package' + + gemspec = Gem::Specification.new do |s| + s.name = 'coffee-script-source' + s.version = JSON.parse(File.read('package.json'))["version"] + s.date = Time.now.strftime("%Y-%m-%d") + + s.homepage = "http://jashkenas.github.com/coffee-script/" + s.summary = "The CoffeeScript Compiler" + s.description = <<-EOS + CoffeeScript is a little language that compiles into JavaScript. + Underneath all of those embarrassing braces and semicolons, + JavaScript has always had a gorgeous object model at its heart. + CoffeeScript is an attempt to expose the good parts of JavaScript + in a simple way. + EOS + + s.files = [ + 'lib/coffee_script/coffee-script.js', + 'lib/coffee_script/source.rb' + ] + + s.authors = ['Jeremy Ashkenas'] + s.email = 'jashkenas@gmail.com' + s.rubyforge_project = 'coffee-script-source' + end + + file = File.open("coffee-script-source.gem", "w") + Gem::Package.open(file, 'w') do |pkg| + pkg.metadata = gemspec.to_yaml + + path = "lib/coffee_script/source.rb" + contents = <<-ERUBY +module CoffeeScript + module Source + def self.bundled_path + File.expand_path("../coffee-script.js", __FILE__) + end + end +end + ERUBY + pkg.add_file_simple(path, 0644, contents.size) do |tar_io| + tar_io.write(contents) + end + + contents = File.read("extras/coffee-script.js") + path = "lib/coffee_script/coffee-script.js" + pkg.add_file_simple(path, 0644, contents.size) do |tar_io| + tar_io.write(contents) + end + end +end diff --git a/Phaser/node_modules/grunt/node_modules/coffee-script/extras/jsl.conf b/Phaser/node_modules/grunt/node_modules/coffee-script/extras/jsl.conf new file mode 100644 index 00000000..1190da52 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/coffee-script/extras/jsl.conf @@ -0,0 +1,44 @@ +# JavaScriptLint configuration file for CoffeeScript. + ++no_return_value # function {0} does not always return a value ++duplicate_formal # duplicate formal argument {0} +-equal_as_assign # test for equality (==) mistyped as assignment (=)?{0} ++var_hides_arg # variable {0} hides argument ++redeclared_var # redeclaration of {0} {1} +-anon_no_return_value # anonymous function does not always return a value ++missing_semicolon # missing semicolon ++meaningless_block # meaningless block; curly braces have no impact +-comma_separated_stmts # multiple statements separated by commas (use semicolons?) ++unreachable_code # unreachable code ++missing_break # missing break statement +-missing_break_for_last_case # missing break statement for last case in switch +-comparison_type_conv # comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==) +-inc_dec_within_stmt # increment (++) and decrement (--) operators used as part of greater statement +-useless_void # use of the void type may be unnecessary (void is always undefined) ++multiple_plus_minus # unknown order of operations for successive plus (e.g. x+++y) or minus (e.g. x---y) signs ++use_of_label # use of label +-block_without_braces # block statement without curly braces ++leading_decimal_point # leading decimal point may indicate a number or an object member ++trailing_decimal_point # trailing decimal point may indicate a number or an object member ++octal_number # leading zeros make an octal number ++nested_comment # nested comment ++misplaced_regex # regular expressions should be preceded by a left parenthesis, assignment, colon, or comma ++ambiguous_newline # unexpected end of line; it is ambiguous whether these lines are part of the same statement ++empty_statement # empty statement or extra semicolon +-missing_option_explicit # the "option explicit" control comment is missing ++partial_option_explicit # the "option explicit" control comment, if used, must be in the first script tag ++dup_option_explicit # duplicate "option explicit" control comment ++useless_assign # useless assignment ++ambiguous_nested_stmt # block statements containing block statements should use curly braces to resolve ambiguity ++ambiguous_else_stmt # the else statement could be matched with one of multiple if statements (use curly braces to indicate intent) +-missing_default_case # missing default case in switch statement ++duplicate_case_in_switch # duplicate case in switch statements ++default_not_at_end # the default case is not at the end of the switch statement ++legacy_cc_not_understood # couldn't understand control comment using /*@keyword@*/ syntax ++jsl_cc_not_understood # couldn't understand control comment using /*jsl:keyword*/ syntax ++useless_comparison # useless comparison; comparing identical expressions ++with_statement # with statement hides undeclared variables; use temporary variable instead ++trailing_comma_in_array # extra comma is not recommended in array initializers ++assign_to_function_call # assignment to a function call ++parseint_missing_radix # parseInt missing radix parameter ++lambda_assign_requires_semicolon diff --git a/Phaser/node_modules/grunt/node_modules/coffee-script/package.json b/Phaser/node_modules/grunt/node_modules/coffee-script/package.json new file mode 100644 index 00000000..aaf03a02 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/coffee-script/package.json @@ -0,0 +1,49 @@ +{ + "name": "coffee-script", + "description": "Unfancy JavaScript", + "keywords": [ + "javascript", + "language", + "coffeescript", + "compiler" + ], + "author": { + "name": "Jeremy Ashkenas" + }, + "version": "1.3.3", + "licenses": [ + { + "type": "MIT", + "url": "https://raw.github.com/jashkenas/coffee-script/master/LICENSE" + } + ], + "engines": { + "node": ">=0.4.0" + }, + "directories": { + "lib": "./lib/coffee-script" + }, + "main": "./lib/coffee-script/coffee-script", + "bin": { + "coffee": "./bin/coffee", + "cake": "./bin/cake" + }, + "homepage": "http://coffeescript.org", + "bugs": "https://github.com/jashkenas/coffee-script/issues", + "repository": { + "type": "git", + "url": "git://github.com/jashkenas/coffee-script.git" + }, + "devDependencies": { + "uglify-js": ">=1.0.0", + "jison": ">=0.2.0" + }, + "readme": "\n {\n } } {\n { { } }\n } }{ {\n { }{ } } _____ __ __\n ( }{ }{ { ) / ____| / _|/ _|\n .- { { } { }} -. | | ___ | |_| |_ ___ ___\n ( ( } { } { } } ) | | / _ \\| _| _/ _ \\/ _ \\\n |`-..________ ..-'| | |___| (_) | | | || __/ __/\n | | \\_____\\___/|_| |_| \\___|\\___|\n | ;--.\n | (__ \\ _____ _ _\n | | ) ) / ____| (_) | |\n | |/ / | (___ ___ _ __ _ _ __ | |_\n | ( / \\___ \\ / __| '__| | '_ \\| __|\n | |/ ____) | (__| | | | |_) | |_\n | | |_____/ \\___|_| |_| .__/ \\__|\n `-.._________..-' | |\n |_|\n\n\n CoffeeScript is a little language that compiles into JavaScript.\n\n Install Node.js, and then the CoffeeScript compiler:\n sudo bin/cake install\n\n Or, if you have the Node Package Manager installed:\n npm install -g coffee-script\n (Leave off the -g if you don't wish to install globally.)\n\n Execute a script:\n coffee /path/to/script.coffee\n\n Compile a script:\n coffee -c /path/to/script.coffee\n\n For documentation, usage, and examples, see:\n http://coffeescript.org/\n\n To suggest a feature, report a bug, or general discussion:\n http://github.com/jashkenas/coffee-script/issues/\n\n If you'd like to chat, drop by #coffeescript on Freenode IRC,\n or on webchat.freenode.net.\n\n The source repository:\n git://github.com/jashkenas/coffee-script.git\n\n All contributors are listed here:\n http://github.com/jashkenas/coffee-script/contributors\n", + "readmeFilename": "README", + "_id": "coffee-script@1.3.3", + "dist": { + "shasum": "d41e076292bcf98fbb2753e76e1a07a8be5db9b7" + }, + "_from": "coffee-script@~1.3.3", + "_resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.3.3.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/colors/MIT-LICENSE.txt b/Phaser/node_modules/grunt/node_modules/colors/MIT-LICENSE.txt new file mode 100644 index 00000000..7dca1070 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/colors/MIT-LICENSE.txt @@ -0,0 +1,22 @@ +Copyright (c) 2010 + +Marak Squires +Alexis Sellier (cloudhead) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/colors/ReadMe.md b/Phaser/node_modules/grunt/node_modules/colors/ReadMe.md new file mode 100644 index 00000000..1c6b0d07 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/colors/ReadMe.md @@ -0,0 +1,77 @@ +# colors.js - get color and style in your node.js console ( and browser ) like what + + + + +## Installation + + npm install colors + +## colors and styles! + +- bold +- italic +- underline +- inverse +- yellow +- cyan +- white +- magenta +- green +- red +- grey +- blue +- rainbow +- zebra +- random + +## Usage + +``` js +var colors = require('./colors'); + +console.log('hello'.green); // outputs green text +console.log('i like cake and pies'.underline.red) // outputs red underlined text +console.log('inverse the color'.inverse); // inverses the color +console.log('OMG Rainbows!'.rainbow); // rainbow (ignores spaces) +``` + +# Creating Custom themes + +```js + +var require('colors'); + +colors.setTheme({ + silly: 'rainbow', + input: 'grey', + verbose: 'cyan', + prompt: 'grey', + info: 'green', + data: 'grey', + help: 'cyan', + warn: 'yellow', + debug: 'blue', + error: 'red' +}); + +// outputs red text +console.log("this is an error".error); + +// outputs yellow text +console.log("this is a warning".warn); +``` + + +### Contributors + +Marak (Marak Squires) +Alexis Sellier (cloudhead) +mmalecki (Maciej Małecki) +nicoreed (Nico Reed) +morganrallen (Morgan Allen) +JustinCampbell (Justin Campbell) +ded (Dustin Diaz) + + +#### , Marak Squires , Justin Campbell, Dustin Diaz (@ded) diff --git a/Phaser/node_modules/grunt/node_modules/colors/example.html b/Phaser/node_modules/grunt/node_modules/colors/example.html new file mode 100644 index 00000000..ab956494 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/colors/example.html @@ -0,0 +1,74 @@ + + + + + Colors Example + + + + + + \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/colors/package.json b/Phaser/node_modules/grunt/node_modules/colors/package.json new file mode 100644 index 00000000..b4b9612c --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/colors/package.json @@ -0,0 +1,24 @@ +{ + "name": "colors", + "description": "get colors in your node.js console like what", + "version": "0.6.0-1", + "author": { + "name": "Marak Squires" + }, + "repository": { + "type": "git", + "url": "http://github.com/Marak/colors.js.git" + }, + "engines": { + "node": ">=0.1.90" + }, + "main": "colors", + "readme": "# colors.js - get color and style in your node.js console ( and browser ) like what\n\n\n\n\n## Installation\n\n npm install colors\n\n## colors and styles!\n\n- bold\n- italic\n- underline\n- inverse\n- yellow\n- cyan\n- white\n- magenta\n- green\n- red\n- grey\n- blue\n- rainbow\n- zebra\n- random\n\n## Usage\n\n``` js\nvar colors = require('./colors');\n\nconsole.log('hello'.green); // outputs green text\nconsole.log('i like cake and pies'.underline.red) // outputs red underlined text\nconsole.log('inverse the color'.inverse); // inverses the color\nconsole.log('OMG Rainbows!'.rainbow); // rainbow (ignores spaces)\n```\n\n# Creating Custom themes\n\n```js\n\nvar require('colors');\n\ncolors.setTheme({\n silly: 'rainbow',\n input: 'grey',\n verbose: 'cyan',\n prompt: 'grey',\n info: 'green',\n data: 'grey',\n help: 'cyan',\n warn: 'yellow',\n debug: 'blue',\n error: 'red'\n});\n\n// outputs red text\nconsole.log(\"this is an error\".error);\n\n// outputs yellow text\nconsole.log(\"this is a warning\".warn);\n```\n\n\n### Contributors \n\nMarak (Marak Squires)\nAlexis Sellier (cloudhead)\nmmalecki (Maciej Małecki)\nnicoreed (Nico Reed)\nmorganrallen (Morgan Allen)\nJustinCampbell (Justin Campbell)\nded (Dustin Diaz)\n\n\n#### , Marak Squires , Justin Campbell, Dustin Diaz (@ded)\n", + "readmeFilename": "ReadMe.md", + "_id": "colors@0.6.0-1", + "dist": { + "shasum": "322d52c6f629babb21b1713e6365d1b6ec1937bd" + }, + "_from": "colors@~0.6.0-1", + "_resolved": "https://registry.npmjs.org/colors/-/colors-0.6.0-1.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/dateformat/Readme.md b/Phaser/node_modules/grunt/node_modules/dateformat/Readme.md new file mode 100644 index 00000000..d469e6d7 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/dateformat/Readme.md @@ -0,0 +1,67 @@ +# node-dateformat + +A node.js package for Steven Levithan's excellent [dateFormat()][dateformat] function. + +## Modifications + +* Removed the `Date.prototype.format` method. Sorry folks, but extending native prototypes is for suckers. +* Added a `module.exports = dateFormat;` statement at the bottom + +## Usage + +As taken from Steven's post, modified to match the Modifications listed above: + + var dateFormat = require('dateformat'); + var now = new Date(); + + // Basic usage + dateFormat(now, "dddd, mmmm dS, yyyy, h:MM:ss TT"); + // Saturday, June 9th, 2007, 5:46:21 PM + + // You can use one of several named masks + dateFormat(now, "isoDateTime"); + // 2007-06-09T17:46:21 + + // ...Or add your own + dateFormat.masks.hammerTime = 'HH:MM! "Can\'t touch this!"'; + dateFormat(now, "hammerTime"); + // 17:46! Can't touch this! + + // When using the standalone dateFormat function, + // you can also provide the date as a string + dateFormat("Jun 9 2007", "fullDate"); + // Saturday, June 9, 2007 + + // Note that if you don't include the mask argument, + // dateFormat.masks.default is used + dateFormat(now); + // Sat Jun 09 2007 17:46:21 + + // And if you don't include the date argument, + // the current date and time is used + dateFormat(); + // Sat Jun 09 2007 17:46:22 + + // You can also skip the date argument (as long as your mask doesn't + // contain any numbers), in which case the current date/time is used + dateFormat("longTime"); + // 5:46:22 PM EST + + // And finally, you can convert local time to UTC time. Simply pass in + // true as an additional argument (no argument skipping allowed in this case): + dateFormat(now, "longTime", true); + // 10:46:21 PM UTC + + // ...Or add the prefix "UTC:" to your mask. + dateFormat(now, "UTC:h:MM:ss TT Z"); + // 10:46:21 PM UTC + + // You can also get the ISO 8601 week of the year: + dateFormat(now, "W"); + // 42 +## License + +(c) 2007-2009 Steven Levithan [stevenlevithan.com][stevenlevithan], MIT license. + +[dateformat]: http://blog.stevenlevithan.com/archives/date-time-format +[stevenlevithan]: http://stevenlevithan.com/ diff --git a/Phaser/node_modules/grunt/node_modules/dateformat/package.json b/Phaser/node_modules/grunt/node_modules/dateformat/package.json new file mode 100644 index 00000000..91a795a0 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/dateformat/package.json @@ -0,0 +1,24 @@ +{ + "name": "dateformat", + "description": "A node.js package for Steven Levithan's excellent dateFormat() function.", + "maintainers": "Felix Geisendörfer ", + "homepage": "https://github.com/felixge/node-dateformat", + "author": { + "name": "Steven Levithan" + }, + "version": "1.0.2-1.2.3", + "main": "./lib/dateformat", + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": "*" + }, + "readme": "# node-dateformat\n\nA node.js package for Steven Levithan's excellent [dateFormat()][dateformat] function.\n\n## Modifications\n\n* Removed the `Date.prototype.format` method. Sorry folks, but extending native prototypes is for suckers.\n* Added a `module.exports = dateFormat;` statement at the bottom\n\n## Usage\n\nAs taken from Steven's post, modified to match the Modifications listed above:\n\n var dateFormat = require('dateformat');\n var now = new Date();\n\n // Basic usage\n dateFormat(now, \"dddd, mmmm dS, yyyy, h:MM:ss TT\");\n // Saturday, June 9th, 2007, 5:46:21 PM\n\n // You can use one of several named masks\n dateFormat(now, \"isoDateTime\");\n // 2007-06-09T17:46:21\n\n // ...Or add your own\n dateFormat.masks.hammerTime = 'HH:MM! \"Can\\'t touch this!\"';\n dateFormat(now, \"hammerTime\");\n // 17:46! Can't touch this!\n\n // When using the standalone dateFormat function,\n // you can also provide the date as a string\n dateFormat(\"Jun 9 2007\", \"fullDate\");\n // Saturday, June 9, 2007\n\n // Note that if you don't include the mask argument,\n // dateFormat.masks.default is used\n dateFormat(now);\n // Sat Jun 09 2007 17:46:21\n\n // And if you don't include the date argument,\n // the current date and time is used\n dateFormat();\n // Sat Jun 09 2007 17:46:22\n\n // You can also skip the date argument (as long as your mask doesn't\n // contain any numbers), in which case the current date/time is used\n dateFormat(\"longTime\");\n // 5:46:22 PM EST\n\n // And finally, you can convert local time to UTC time. Simply pass in\n // true as an additional argument (no argument skipping allowed in this case):\n dateFormat(now, \"longTime\", true);\n // 10:46:21 PM UTC\n\n // ...Or add the prefix \"UTC:\" to your mask.\n dateFormat(now, \"UTC:h:MM:ss TT Z\");\n // 10:46:21 PM UTC\n\n // You can also get the ISO 8601 week of the year:\n dateFormat(now, \"W\");\n // 42\n## License\n\n(c) 2007-2009 Steven Levithan [stevenlevithan.com][stevenlevithan], MIT license.\n\n[dateformat]: http://blog.stevenlevithan.com/archives/date-time-format\n[stevenlevithan]: http://stevenlevithan.com/\n", + "readmeFilename": "Readme.md", + "_id": "dateformat@1.0.2-1.2.3", + "dist": { + "shasum": "692290ea53102d50a82968882eab448a048a7f23" + }, + "_from": "dateformat@1.0.2-1.2.3", + "_resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.2-1.2.3.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/dateformat/test/test_weekofyear.sh b/Phaser/node_modules/grunt/node_modules/dateformat/test/test_weekofyear.sh new file mode 100644 index 00000000..3c3e69b3 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/dateformat/test/test_weekofyear.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# this just takes php's date() function as a reference to check if week of year +# is calculated correctly in the range from 1970 .. 2038 by brute force... + +SEQ="seq" +SYSTEM=`uname` +if [ "$SYSTEM" = "Darwin" ]; then + SEQ="jot" +fi + +for YEAR in {1970..2038}; do + for MONTH in {1..12}; do + DAYS=$(cal $MONTH $YEAR | egrep "28|29|30|31" |tail -1 |awk '{print $NF}') + for DAY in $( $SEQ $DAYS ); do + DATE=$YEAR-$MONTH-$DAY + echo -n $DATE ... + NODEVAL=$(node test_weekofyear.js $DATE) + PHPVAL=$(php -r "echo intval(date('W', strtotime('$DATE')));") + if [ "$NODEVAL" -ne "$PHPVAL" ]; then + echo "MISMATCH: node: $NODEVAL vs php: $PHPVAL for date $DATE" + else + echo " OK" + fi + done + done +done diff --git a/Phaser/node_modules/grunt/node_modules/eventemitter2/.npmignore b/Phaser/node_modules/grunt/node_modules/eventemitter2/.npmignore new file mode 100644 index 00000000..dbed6714 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/eventemitter2/.npmignore @@ -0,0 +1,13 @@ +#ignore these files +*.swp +*~ +*.lock +*.DS_Store +node_modules +npm-debug.log +*.out +*.o +*.tmp + + + diff --git a/Phaser/node_modules/grunt/node_modules/eventemitter2/README.md b/Phaser/node_modules/grunt/node_modules/eventemitter2/README.md new file mode 100644 index 00000000..e0c2aa84 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/eventemitter2/README.md @@ -0,0 +1,212 @@ +# EventEmitter2 + +EventEmitter2 is a an implementation of the EventEmitter found in Node.js + +## Features + + - Namespaces/Wildcards. + - Times To Listen (TTL), extends the `once` concept with `many`. + - Browser environment compatibility. + - Demonstrates good performance in benchmarks + +``` +EventEmitterHeatUp x 3,728,965 ops/sec \302\2610.68% (60 runs sampled) +EventEmitter x 2,822,904 ops/sec \302\2610.74% (63 runs sampled) +EventEmitter2 x 7,251,227 ops/sec \302\2610.55% (58 runs sampled) +EventEmitter2 (wild) x 3,220,268 ops/sec \302\2610.44% (65 runs sampled) +Fastest is EventEmitter2 +``` + +## Differences (Non breaking, compatible with existing EventEmitter) + + - The constructor takes a configuration object. + +```javascript + var EventEmitter2 = require('eventemitter2').EventEmitter2; + var server = new EventEmitter2({ + wildcard: true, // should the event emitter use wildcards. + delimiter: '::', // the delimiter used to segment namespaces, defaults to `.`. + newListener: false, // if you want to emit the newListener event set to true. + maxListeners: 20, // the max number of listeners that can be assigned to an event, defaults to 10. + }); +``` + + - Getting the actual event that fired. + +```javascript + server.on('foo.*', function(value1, value2) { + console.log(this.event, value1, value2); + }); +``` + + - Fire an event N times and then remove it, an extension of the `once` concept. + +```javascript + server.many('foo', 4, function() { + console.log('hello'); + }); +``` + + - Pass in a namespaced event as an array rather than a delimited string. + +```javascript + server.many(['foo', 'bar', 'bazz'], function() { + console.log('hello'); + }); +``` + + +## API + +When an `EventEmitter` instance experiences an error, the typical action is +to emit an `error` event. Error events are treated as a special case. +If there is no listener for it, then the default action is to print a stack +trace and exit the program. + +All EventEmitters emit the event `newListener` when new listeners are +added. + + +**Namespaces** with **Wildcards** +To use namespaces/wildcards, pass the `wildcard` option into the EventEmitter constructor. +When namespaces/wildcards are enabled, events can either be strings (`foo.bar`) separated +by a delimiter or arrays (`['foo', 'bar']`). The delimiter is also configurable as a +constructor option. + +An event name passed to any event emitter method can contain a wild card (the `*` character). +If the event name is a string, a wildcard may appear as `foo.*`. If the event name is an array, +the wildcard may appear as `['foo', '*']`. + +If either of the above described events were passed to the `on` method, subsequent emits such +as the following would be observed... + +```javascript + emitter.emit('foo.bazz'); + emitter.emit(['foo', 'bar']); +``` + + +#### emitter.addListener(event, listener) +#### emitter.on(event, listener) + +Adds a listener to the end of the listeners array for the specified event. + +```javascript + server.on('data', function(value1, value2, value3 /* accepts any number of expected values... */) { + console.log('The event was raised!'); + }); +``` + +```javascript + server.on('data', function(value) { + console.log('The event was raised!'); + }); +``` + +#### emitter.onAny(listener) + +Adds a listener that will be fired when any event is emitted. + +```javascript + server.onAny(function(value) { + console.log('All events trigger this.'); + }); +``` + +#### emitter.offAny(listener) + +Removes the listener that will be fired when any event is emitted. + +```javascript + server.offAny(function(value) { + console.log('The event was raised!'); + }); +``` + +#### emitter.once(event, listener) + +Adds a **one time** listener for the event. The listener is invoked only the first time the event is fired, after which it is removed. + +```javascript + server.once('get', function (value) { + console.log('Ah, we have our first value!'); + }); +``` + +#### emitter.many(event, timesToListen, listener) + +Adds a listener that will execute **n times** for the event before being removed. The listener is invoked only the first time the event is fired, after which it is removed. + +```javascript + server.many('get', 4, function (value) { + console.log('This event will be listened to exactly four times.'); + }); +``` + + +#### emitter.removeListener(event, listener) +#### emitter.off(event, listener) + +Remove a listener from the listener array for the specified event. **Caution**: changes array indices in the listener array behind the listener. + +```javascript + var callback = function(value) { + console.log('someone connected!'); + }; + server.on('get', callback); + // ... + server.removeListener('get', callback); +``` + + +#### emitter.removeAllListeners([event]) + +Removes all listeners, or those of the specified event. + + +#### emitter.setMaxListeners(n) + +By default EventEmitters will print a warning if more than 10 listeners are added to it. This is a useful default which helps finding memory leaks. Obviously not all Emitters should be limited to 10. This function allows that to be increased. Set to zero for unlimited. + + +#### emitter.listeners(event) + +Returns an array of listeners for the specified event. This array can be manipulated, e.g. to remove listeners. + +```javascript + server.on('get', function(value) { + console.log('someone connected!'); + }); + console.log(console.log(server.listeners('get')); // [ [Function] ] +``` + +#### emitter.listenersAny() + +Returns an array of listeners that are listening for any event that is specified. This array can be manipulated, e.g. to remove listeners. + +```javascript + server.onAny(function(value) { + console.log('someone connected!'); + }); + console.log(console.log(server.listenersAny()[0]); // [ [Function] ] // someone connected! +``` + +#### emitter.emit(event, [arg1], [arg2], [...]) + +Execute each of the listeners that may be listening for the specified event name in order with the list of arguments. + +## Test coverage + +There is a test suite that tries to cover each use case, it can be found here. + +## Licence + +(The MIT License) + +Copyright (c) 2011 hij1nx + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/eventemitter2/package.json b/Phaser/node_modules/grunt/node_modules/eventemitter2/package.json new file mode 100644 index 00000000..9a721ee2 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/eventemitter2/package.json @@ -0,0 +1,78 @@ +{ + "name": "eventemitter2", + "version": "0.4.11", + "description": "A Node.js event emitter implementation with namespaces, wildcards, TTL and browser support.", + "keywords": [ + "event", + "events", + "emitter", + "eventemitter" + ], + "author": { + "name": "hij1nx", + "email": "hij1nx@nodejitsu.com" + }, + "maintainers": [ + { + "name": "hij1nx", + "email": "hij1nx@nodejitsu.com" + }, + { + "name": "jameson", + "email": "jameson@nodejitsu.com" + } + ], + "contributors": [ + { + "name": "Eric Elliott" + }, + { + "name": "Charlie Robbins", + "email": "charlie@nodejitsu.com" + }, + { + "name": "Jameson Lee", + "email": "jameson@nodejitsu.com" + }, + { + "name": "Jeroen van Duffelen", + "email": "jvduf@nodejitsu.com" + }, + { + "name": "Fedor Indutny", + "email": "fedor.indutny@gmail.com" + } + ], + "licenses": [ + { + "type": "MIT" + } + ], + "homepage": "https://github.com/hij1nx/EventEmitter2", + "repositories": [ + { + "type": "git", + "url": "git://github.com/hij1nx/EventEmitter2.git" + } + ], + "devDependencies": { + "nodeunit": "*", + "benchmark": ">= 0.2.2" + }, + "engines": [ + "node" + ], + "main": "./lib/eventemitter2.js", + "scripts": { + "test": "nodeunit test/simple/* && nodeunit test/wildcardEvents/*", + "benchmark": "node test/perf/benchmark.js" + }, + "readme": "# EventEmitter2\n\nEventEmitter2 is a an implementation of the EventEmitter found in Node.js\n\n## Features\n\n - Namespaces/Wildcards.\n - Times To Listen (TTL), extends the `once` concept with `many`.\n - Browser environment compatibility.\n - Demonstrates good performance in benchmarks\n\n```\nEventEmitterHeatUp x 3,728,965 ops/sec \\302\\2610.68% (60 runs sampled)\nEventEmitter x 2,822,904 ops/sec \\302\\2610.74% (63 runs sampled)\nEventEmitter2 x 7,251,227 ops/sec \\302\\2610.55% (58 runs sampled)\nEventEmitter2 (wild) x 3,220,268 ops/sec \\302\\2610.44% (65 runs sampled)\nFastest is EventEmitter2\n```\n\n## Differences (Non breaking, compatible with existing EventEmitter)\n\n - The constructor takes a configuration object.\n \n```javascript\n var EventEmitter2 = require('eventemitter2').EventEmitter2;\n var server = new EventEmitter2({\n wildcard: true, // should the event emitter use wildcards.\n delimiter: '::', // the delimiter used to segment namespaces, defaults to `.`.\n newListener: false, // if you want to emit the newListener event set to true.\n maxListeners: 20, // the max number of listeners that can be assigned to an event, defaults to 10.\n });\n```\n\n - Getting the actual event that fired.\n\n```javascript\n server.on('foo.*', function(value1, value2) {\n console.log(this.event, value1, value2);\n });\n```\n\n - Fire an event N times and then remove it, an extension of the `once` concept.\n\n```javascript\n server.many('foo', 4, function() {\n console.log('hello');\n });\n```\n\n - Pass in a namespaced event as an array rather than a delimited string.\n\n```javascript\n server.many(['foo', 'bar', 'bazz'], function() {\n console.log('hello');\n });\n```\n\n\n## API\n\nWhen an `EventEmitter` instance experiences an error, the typical action is\nto emit an `error` event. Error events are treated as a special case.\nIf there is no listener for it, then the default action is to print a stack\ntrace and exit the program.\n\nAll EventEmitters emit the event `newListener` when new listeners are\nadded.\n\n\n**Namespaces** with **Wildcards**\nTo use namespaces/wildcards, pass the `wildcard` option into the EventEmitter constructor.\nWhen namespaces/wildcards are enabled, events can either be strings (`foo.bar`) separated\nby a delimiter or arrays (`['foo', 'bar']`). The delimiter is also configurable as a \nconstructor option.\n\nAn event name passed to any event emitter method can contain a wild card (the `*` character).\nIf the event name is a string, a wildcard may appear as `foo.*`. If the event name is an array, \nthe wildcard may appear as `['foo', '*']`.\n\nIf either of the above described events were passed to the `on` method, subsequent emits such \nas the following would be observed...\n\n```javascript\n emitter.emit('foo.bazz');\n emitter.emit(['foo', 'bar']);\n```\n\n\n#### emitter.addListener(event, listener)\n#### emitter.on(event, listener)\n\nAdds a listener to the end of the listeners array for the specified event.\n\n```javascript\n server.on('data', function(value1, value2, value3 /* accepts any number of expected values... */) {\n console.log('The event was raised!');\n });\n```\n\n```javascript\n server.on('data', function(value) {\n console.log('The event was raised!');\n });\n```\n\n#### emitter.onAny(listener)\n\nAdds a listener that will be fired when any event is emitted.\n\n```javascript\n server.onAny(function(value) {\n console.log('All events trigger this.');\n });\n```\n\n#### emitter.offAny(listener)\n\nRemoves the listener that will be fired when any event is emitted.\n\n```javascript\n server.offAny(function(value) {\n console.log('The event was raised!');\n });\n```\n\n#### emitter.once(event, listener)\n\nAdds a **one time** listener for the event. The listener is invoked only the first time the event is fired, after which it is removed.\n\n```javascript\n server.once('get', function (value) {\n console.log('Ah, we have our first value!');\n });\n```\n\n#### emitter.many(event, timesToListen, listener)\n\nAdds a listener that will execute **n times** for the event before being removed. The listener is invoked only the first time the event is fired, after which it is removed.\n\n```javascript\n server.many('get', 4, function (value) {\n console.log('This event will be listened to exactly four times.');\n });\n```\n\n\n#### emitter.removeListener(event, listener)\n#### emitter.off(event, listener)\n\nRemove a listener from the listener array for the specified event. **Caution**: changes array indices in the listener array behind the listener.\n\n```javascript\n var callback = function(value) {\n console.log('someone connected!');\n };\n server.on('get', callback);\n // ...\n server.removeListener('get', callback);\n```\n\n\n#### emitter.removeAllListeners([event])\n\nRemoves all listeners, or those of the specified event.\n\n\n#### emitter.setMaxListeners(n)\n\nBy default EventEmitters will print a warning if more than 10 listeners are added to it. This is a useful default which helps finding memory leaks. Obviously not all Emitters should be limited to 10. This function allows that to be increased. Set to zero for unlimited.\n\n\n#### emitter.listeners(event)\n\nReturns an array of listeners for the specified event. This array can be manipulated, e.g. to remove listeners.\n\n```javascript\n server.on('get', function(value) {\n console.log('someone connected!');\n });\n console.log(console.log(server.listeners('get')); // [ [Function] ]\n```\n\n#### emitter.listenersAny()\n\nReturns an array of listeners that are listening for any event that is specified. This array can be manipulated, e.g. to remove listeners.\n\n```javascript\n server.onAny(function(value) {\n console.log('someone connected!');\n });\n console.log(console.log(server.listenersAny()[0]); // [ [Function] ] // someone connected!\n```\n\n#### emitter.emit(event, [arg1], [arg2], [...])\n\nExecute each of the listeners that may be listening for the specified event name in order with the list of arguments.\n\n## Test coverage\n\nThere is a test suite that tries to cover each use case, it can be found here.\n\n## Licence\n\n(The MIT License)\n\nCopyright (c) 2011 hij1nx \n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", + "readmeFilename": "README.md", + "_id": "eventemitter2@0.4.11", + "dist": { + "shasum": "8bbf2b6ac7b31e2eea0c8d8f533ef41f849a9e2c" + }, + "_from": "eventemitter2@~0.4.9", + "_resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.11.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/.jshintrc b/Phaser/node_modules/grunt/node_modules/findup-sync/.jshintrc new file mode 100644 index 00000000..6d171b89 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/.jshintrc @@ -0,0 +1,16 @@ +{ + "loopfunc": true, + "curly": true, + "eqeqeq": true, + "immed": true, + "latedef": true, + "newcap": true, + "noarg": true, + "sub": true, + "undef": true, + "unused": true, + "boss": true, + "eqnull": true, + "node": true, + "es5": true +} diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/.npmignore b/Phaser/node_modules/grunt/node_modules/findup-sync/.npmignore new file mode 100644 index 00000000..e69de29b diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/LICENSE-MIT b/Phaser/node_modules/grunt/node_modules/findup-sync/LICENSE-MIT new file mode 100644 index 00000000..bb2aad6d --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/LICENSE-MIT @@ -0,0 +1,22 @@ +Copyright (c) 2013 "Cowboy" Ben Alman + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/README.md b/Phaser/node_modules/grunt/node_modules/findup-sync/README.md new file mode 100644 index 00000000..3b08b4e0 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/README.md @@ -0,0 +1,44 @@ +# findup-sync + +Find the first file matching a given pattern in the current directory or the nearest ancestor directory. + +## Getting Started +Install the module with: `npm install findup-sync` + +```js +var findup = require('findup-sync'); + +// Start looking in the CWD. +var filepath1 = findup('{a,b}*.txt'); + +// Start looking somewhere else, and ignore case (probably a good idea). +var filepath2 = findup('{a,b}*.txt', {cwd: '/some/path', nocase: true}); +``` + +## Usage + +```js +findup(patternOrPatterns [, minimatchOptions]) +``` + +### patternOrPatterns +Type: `String` or `Array` +Default: none + +One or more wildcard glob patterns. Or just filenames. + +### minimatchOptions +Type: `Object` +Default: `{}` + +Options to be passed to [minimatch](https://github.com/isaacs/minimatch). + +Note that if you want to start in a different directory than the current working directory, specify a `cwd` property here. + +## Contributing +In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/). + +## Release History +2013-03-08 - v0.1.2 - Updated dependencies. Fixed a Node 0.9.x bug. Updated unit tests to work cross-platform. +2012-11-15 - v0.1.1 - Now works without an options object. +2012-11-01 - v0.1.0 - Initial release. diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/.bin/lodash b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/.bin/lodash new file mode 120000 index 00000000..24deae28 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/.bin/lodash @@ -0,0 +1 @@ +../lodash/build.js \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/LICENSE.txt b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/LICENSE.txt new file mode 100644 index 00000000..cc082396 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright 2012-2013 The Dojo Foundation +Based on Underscore.js 1.4.3, copyright 2009-2013 Jeremy Ashkenas, +DocumentCloud Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/README.md b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/README.md new file mode 100644 index 00000000..6181c779 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/README.md @@ -0,0 +1,276 @@ +# Lo-Dash v1.0.1 +[![build status](https://secure.travis-ci.org/bestiejs/lodash.png)](http://travis-ci.org/bestiejs/lodash) + +An alternative to Underscore.js, delivering consistency, [customization](https://github.com/bestiejs/lodash#custom-builds), [performance](http://lodash.com/benchmarks), and [extra features](https://github.com/bestiejs/lodash#features). + +## Download + +* Lo-Dash builds (for modern environments):
+[Development](https://raw.github.com/bestiejs/lodash/v1.0.1/dist/lodash.js) and +[Production](https://raw.github.com/bestiejs/lodash/v1.0.1/dist/lodash.min.js) + +* Lo-Dash compatibility builds (for legacy and modern environments):
+[Development](https://raw.github.com/bestiejs/lodash/v1.0.1/dist/lodash.compat.js) and +[Production](https://raw.github.com/bestiejs/lodash/v1.0.1/dist/lodash.compat.min.js) + +* Underscore compatibility builds:
+[Development](https://raw.github.com/bestiejs/lodash/v1.0.1/dist/lodash.underscore.js) and +[Production](https://raw.github.com/bestiejs/lodash/v1.0.1/dist/lodash.underscore.min.js) + +* CDN copies of ≤ v1.0.1’s builds are available on [cdnjs](http://cdnjs.com/) thanks to [CloudFlare](http://www.cloudflare.com/):
+[Lo-Dash dev](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.js), +[Lo-Dash prod](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.min.js),
+[Lo-Dash compat-dev](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.compat.js), +[Lo-Dash compat-prod](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.compat.min.js),
+[Underscore compat-dev](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.underscore.js), and +[Underscore compat-prod](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.underscore.min.js) + +* For optimal file size, [create a custom build](https://github.com/bestiejs/lodash#custom-builds) with only the features you need + +## Dive in + +We’ve got [API docs](http://lodash.com/docs), [benchmarks](http://lodash.com/benchmarks), and [unit tests](http://lodash.com/tests). + +For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/lodash/wiki/Roadmap). + +## Resources + +For more information check out these articles, screencasts, and other videos over Lo-Dash: + + * Posts + - [Say “Hello†to Lo-Dash](http://kitcambridge.be/blog/say-hello-to-lo-dash/) + + * Videos + - [Introducing Lo-Dash](https://vimeo.com/44154599) + - [Lo-Dash optimizations and custom builds](https://vimeo.com/44154601) + - [Lo-Dash’s origin and why it’s a better utility belt](https://vimeo.com/44154600) + - [Unit testing in Lo-Dash](https://vimeo.com/45865290) + - [Lo-Dash’s approach to native method use](https://vimeo.com/48576012) + - [CascadiaJS: Lo-Dash for a better utility belt](http://www.youtube.com/watch?v=dpPy4f_SeEk) + +## Features + + * AMD loader support ([RequireJS](http://requirejs.org/), [curl.js](https://github.com/cujojs/curl), etc.) + * [_(…)](http://lodash.com/docs#_) supports intuitive chaining + * [_.at](http://lodash.com/docs#at) for cherry-picking collection values + * [_.bindKey](http://lodash.com/docs#bindKey) for binding [*“lazyâ€* defined](http://michaux.ca/articles/lazy-function-definition-pattern) methods + * [_.cloneDeep](http://lodash.com/docs#cloneDeep) for deep cloning arrays and objects + * [_.contains](http://lodash.com/docs#contains) accepts a `fromIndex` argument + * [_.forEach](http://lodash.com/docs#forEach) is chainable and supports exiting iteration early + * [_.forIn](http://lodash.com/docs#forIn) for iterating over an object’s own and inherited properties + * [_.forOwn](http://lodash.com/docs#forOwn) for iterating over an object’s own properties + * [_.isPlainObject](http://lodash.com/docs#isPlainObject) checks if values are created by the `Object` constructor + * [_.merge](http://lodash.com/docs#merge) for a deep [_.extend](http://lodash.com/docs#extend) + * [_.partial](http://lodash.com/docs#partial) and [_.partialRight](http://lodash.com/docs#partialRight) for partial application without `this` binding + * [_.template](http://lodash.com/docs#template) supports [*“importsâ€* options](http://lodash.com/docs#templateSettings_imports), [ES6 template delimiters](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6), and [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) + * [_.where](http://lodash.com/docs#where) supports deep object comparisons + * [_.clone](http://lodash.com/docs#clone), [_.omit](http://lodash.com/docs#omit), [_.pick](http://lodash.com/docs#pick), + [and more…](http://lodash.com/docs "_.assign, _.cloneDeep, _.first, _.initial, _.isEqual, _.last, _.merge, _.rest") accept `callback` and `thisArg` arguments + * [_.contains](http://lodash.com/docs#contains), [_.size](http://lodash.com/docs#size), [_.toArray](http://lodash.com/docs#toArray), + [and more…](http://lodash.com/docs "_.at, _.countBy, _.every, _.filter, _.find, _.forEach, _.groupBy, _.invoke, _.map, _.max, _.min, _.pluck, _.reduce, _.reduceRight, _.reject, _.shuffle, _.some, _.sortBy, _.where") accept strings + * [_.filter](http://lodash.com/docs#filter), [_.find](http://lodash.com/docs#find), [_.map](http://lodash.com/docs#map), + [and more…](http://lodash.com/docs "_.countBy, _.every, _.first, _.groupBy, _.initial, _.last, _.max, _.min, _.reject, _.rest, _.some, _.sortBy, _.sortedIndex, _.uniq") support *“_.pluckâ€* and *“_.whereâ€* `callback` shorthands + +## Support + +Lo-Dash has been tested in at least Chrome 5~24, Firefox 1~18, IE 6-10, Opera 9.25-12, Safari 3-6, Node.js 0.4.8-0.8.20, Narwhal 0.3.2, PhantomJS 1.8.1, RingoJS 0.9, and Rhino 1.7RC5. + +## Custom builds + +Custom builds make it easy to create lightweight versions of Lo-Dash containing only the methods you need. +To top it off, we handle all method dependency and alias mapping for you. + + * Backbone builds, with only methods required by Backbone, may be created using the `backbone` modifier argument. +```bash +lodash backbone +``` + + * CSP builds, supporting default [Content Security Policy](https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html) restrictions, may be created using the `csp` modifier argument. + The `csp` modifier is an alais of the `mobile` modifier. Lo-Dash may be used in Chrome extensions by using either the `csp`, `mobile`, or `underscore` build and using precompiled templates, or loading Lo-Dash in a [sandbox](http://developer.chrome.com/stable/extensions/sandboxingEval.html). +```bash +lodash csp +``` + + * Legacy builds, tailored for older environments without [ES5 support](http://es5.github.com/), may be created using the `legacy` modifier argument. +```bash +lodash legacy +``` + + * Modern builds, tailored for newer environments with ES5 support, may be created using the `modern` modifier argument. +```bash +lodash modern +``` + + * Mobile builds, without method compilation and most bug fixes for old browsers, may be created using the `mobile` modifier argument. +```bash +lodash mobile +``` + + * Strict builds, with `_.bindAll`, `_.defaults`, and `_.extend` in [strict mode](http://es5.github.com/#C), may be created using the `strict` modifier argument. +```bash +lodash strict +``` + + * Underscore builds, tailored for projects already using Underscore, may be created using the `underscore` modifier argument. +```bash +lodash underscore +``` + +Custom builds may be created using the following commands: + + * Use the `category` argument to pass comma separated categories of methods to include in the build.
+ Valid categories (case-insensitive) are *“arraysâ€*, *“chainingâ€*, *“collectionsâ€*, *“functionsâ€*, *“objectsâ€*, and *“utilitiesâ€*. +```bash +lodash category=collections,functions +lodash category="collections, functions" +``` + + * Use the `exports` argument to pass comma separated names of ways to export the `LoDash` function.
+ Valid exports are *“amdâ€*, *“commonjsâ€*, *“globalâ€*, *“nodeâ€*, and *“noneâ€*. +```bash +lodash exports=amd,commonjs,node +lodash exports="amd, commonjs, node" +``` + + * Use the `iife` argument to specify code to replace the immediately-invoked function expression that wraps Lo-Dash. +```bash +lodash iife="!function(window,undefined){%output%}(this)" +``` + + * Use the `include` argument to pass comma separated method/category names to include in the build. +```bash +lodash include=each,filter,map +lodash include="each, filter, map" +``` + + * Use the `minus` argument to pass comma separated method/category names to remove from those included in the build. +```bash +lodash underscore minus=result,shuffle +lodash underscore minus="result, shuffle" +``` + + * Use the `plus` argument to pass comma separated method/category names to add to those included in the build. +```bash +lodash backbone plus=random,template +lodash backbone plus="random, template" +``` + + * Use the `template` argument to pass the file path pattern used to match template files to precompile. +```bash +lodash template="./*.jst" +``` + + * Use the `settings` argument to pass the template settings used when precompiling templates. +```bash +lodash settings="{interpolate:/\{\{([\s\S]+?)\}\}/g}" +``` + + * Use the `moduleId` argument to specify the AMD module ID of Lo-Dash, which defaults to “lodashâ€, used by precompiled templates. +```bash +lodash moduleId="underscore" +``` + +All arguments, except `legacy` with `csp`, `mobile`, `modern`, or `underscore`, may be combined.
+Unless specified by `-o` or `--output`, all files created are saved to the current working directory. + +The following options are also supported: + + * `-c`, `--stdout` ......... Write output to standard output + * `-d`, `--debug` ........... Write only the non-minified development output + * `-h`, `--help` ............. Display help information + * `-m`, `--minify` ......... Write only the minified production output + * `-o`, `--output` ......... Write output to a given path/filename + * `-p`, `--source-map` .. Generate a source map for the minified output, using an optional source map URL + * `-s`, `--silent` ......... Skip status updates normally logged to the console + * `-V`, `--version` ....... Output current version of Lo-Dash + +The `lodash` command-line utility is available when Lo-Dash is installed as a global package (i.e. `npm install -g lodash`). + +## Installation and usage + +In browsers: + +```html + +``` + +Using [`npm`](http://npmjs.org/): + +```bash +npm install lodash + +npm install -g lodash +npm link lodash +``` + +To avoid potential issues, update `npm` before installing Lo-Dash: + +```bash +npm install npm -g +``` + +In [Node.js](http://nodejs.org/) and [RingoJS v0.8.0+](http://ringojs.org/): + +```js +var _ = require('lodash'); + +// or as a drop-in replacement for Underscore +var _ = require('lodash/lodash.underscore'); +``` + +**Note:** If Lo-Dash is installed globally, run [`npm link lodash`](http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/) in your project’s root directory before requiring it. + +In [RingoJS v0.7.0-](http://ringojs.org/): + +```js +var _ = require('lodash')._; +``` + +In [Rhino](http://www.mozilla.org/rhino/): + +```js +load('lodash.js'); +``` + +In an AMD loader like [RequireJS](http://requirejs.org/): + +```js +require({ + 'paths': { + 'underscore': 'path/to/lodash' + } +}, +['underscore'], function(_) { + console.log(_.VERSION); +}); +``` + +## Release Notes + +### v1.0.1 + + * Add support for specifying source map URLs in `-p`/`--source-map` build options + * Ensured the second argument passed to `_.assign` is not treated as a `callback` + * Ensured `-p`/`--source-map` build options correctly set the `sourceMappingURL` + * Made `-p`/`--source-map` build options set source map *“sourcesâ€* keys based on the builds performed + * Made `_.defer` use `setImmediate`, in Node.js, when available + * Made `_.where` search arrays for values regardless of their index position + * Removed dead code from `_.template` + +The full changelog is available [here](https://github.com/bestiejs/lodash/wiki/Changelog). + +## BestieJS + +Lo-Dash is part of the BestieJS *“Best in Classâ€* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation. + +## Author + +* [John-David Dalton](http://allyoucanleet.com/) + [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton "Follow @jdalton on Twitter") + +## Contributors + +* [Kit Cambridge](http://kitcambridge.github.com/) + [![twitter/kitcambridge](http://gravatar.com/avatar/6662a1d02f351b5ef2f8b4d815804661?s=70)](https://twitter.com/kitcambridge "Follow @kitcambridge on Twitter") +* [Mathias Bynens](http://mathiasbynens.be/) + [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/doc/README.md b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/doc/README.md new file mode 100644 index 00000000..8e22b33a --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/doc/README.md @@ -0,0 +1,3590 @@ +# Lo-Dash v1.0.1 + + + + + + +## `Arrays` +* [`_.compact`](#_compactarray) +* [`_.difference`](#_differencearray--array1-array2-) +* [`_.drop`](#_restarray--callbackn1-thisarg) +* [`_.first`](#_firstarray--callbackn-thisarg) +* [`_.flatten`](#_flattenarray-shallow) +* [`_.head`](#_firstarray--callbackn-thisarg) +* [`_.indexOf`](#_indexofarray-value--fromindex0) +* [`_.initial`](#_initialarray--callbackn1-thisarg) +* [`_.intersection`](#_intersectionarray1-array2-) +* [`_.last`](#_lastarray--callbackn-thisarg) +* [`_.lastIndexOf`](#_lastindexofarray-value--fromindexarraylength-1) +* [`_.object`](#_objectkeys--values) +* [`_.range`](#_rangestart0-end--step1) +* [`_.rest`](#_restarray--callbackn1-thisarg) +* [`_.sortedIndex`](#_sortedindexarray-value--callbackidentity-thisarg) +* [`_.tail`](#_restarray--callbackn1-thisarg) +* [`_.take`](#_firstarray--callbackn-thisarg) +* [`_.union`](#_unionarray1-array2-) +* [`_.uniq`](#_uniqarray--issortedfalse-callbackidentity-thisarg) +* [`_.unique`](#_uniqarray--issortedfalse-callbackidentity-thisarg) +* [`_.without`](#_withoutarray--value1-value2-) +* [`_.zip`](#_ziparray1-array2-) + + + + + + +## `Chaining` +* [`_`](#_value) +* [`_.tap`](#_tapvalue-interceptor) +* [`_.prototype.toString`](#_prototypetostring) +* [`_.prototype.value`](#_prototypevalueof) +* [`_.prototype.valueOf`](#_prototypevalueof) + + + + + + +## `Collections` +* [`_.all`](#_everycollection--callbackidentity-thisarg) +* [`_.any`](#_somecollection--callbackidentity-thisarg) +* [`_.at`](#_atcollection--index1-index2-) +* [`_.collect`](#_mapcollection--callbackidentity-thisarg) +* [`_.contains`](#_containscollection-target--fromindex0) +* [`_.countBy`](#_countbycollection--callbackidentity-thisarg) +* [`_.detect`](#_findcollection--callbackidentity-thisarg) +* [`_.each`](#_foreachcollection--callbackidentity-thisarg) +* [`_.every`](#_everycollection--callbackidentity-thisarg) +* [`_.filter`](#_filtercollection--callbackidentity-thisarg) +* [`_.find`](#_findcollection--callbackidentity-thisarg) +* [`_.foldl`](#_reducecollection--callbackidentity-accumulator-thisarg) +* [`_.foldr`](#_reducerightcollection--callbackidentity-accumulator-thisarg) +* [`_.forEach`](#_foreachcollection--callbackidentity-thisarg) +* [`_.groupBy`](#_groupbycollection--callbackidentity-thisarg) +* [`_.include`](#_containscollection-target--fromindex0) +* [`_.inject`](#_reducecollection--callbackidentity-accumulator-thisarg) +* [`_.invoke`](#_invokecollection-methodname--arg1-arg2-) +* [`_.map`](#_mapcollection--callbackidentity-thisarg) +* [`_.max`](#_maxcollection--callbackidentity-thisarg) +* [`_.min`](#_mincollection--callbackidentity-thisarg) +* [`_.pluck`](#_pluckcollection-property) +* [`_.reduce`](#_reducecollection--callbackidentity-accumulator-thisarg) +* [`_.reduceRight`](#_reducerightcollection--callbackidentity-accumulator-thisarg) +* [`_.reject`](#_rejectcollection--callbackidentity-thisarg) +* [`_.select`](#_filtercollection--callbackidentity-thisarg) +* [`_.shuffle`](#_shufflecollection) +* [`_.size`](#_sizecollection) +* [`_.some`](#_somecollection--callbackidentity-thisarg) +* [`_.sortBy`](#_sortbycollection--callbackidentity-thisarg) +* [`_.toArray`](#_toarraycollection) +* [`_.where`](#_wherecollection-properties) + + + + + + +## `Functions` +* [`_.after`](#_aftern-func) +* [`_.bind`](#_bindfunc--thisarg-arg1-arg2-) +* [`_.bindAll`](#_bindallobject--methodname1-methodname2-) +* [`_.bindKey`](#_bindkeyobject-key--arg1-arg2-) +* [`_.compose`](#_composefunc1-func2-) +* [`_.debounce`](#_debouncefunc-wait-immediate) +* [`_.defer`](#_deferfunc--arg1-arg2-) +* [`_.delay`](#_delayfunc-wait--arg1-arg2-) +* [`_.memoize`](#_memoizefunc--resolver) +* [`_.once`](#_oncefunc) +* [`_.partial`](#_partialfunc--arg1-arg2-) +* [`_.partialRight`](#_partialrightfunc--arg1-arg2-) +* [`_.throttle`](#_throttlefunc-wait) +* [`_.wrap`](#_wrapvalue-wrapper) + + + + + + +## `Objects` +* [`_.assign`](#_assignobject--source1-source2--callback-thisarg) +* [`_.clone`](#_clonevalue--deepfalse-callback-thisarg) +* [`_.cloneDeep`](#_clonedeepvalue--callback-thisarg) +* [`_.defaults`](#_defaultsobject--source1-source2-) +* [`_.extend`](#_assignobject--source1-source2--callback-thisarg) +* [`_.forIn`](#_forinobject--callbackidentity-thisarg) +* [`_.forOwn`](#_forownobject--callbackidentity-thisarg) +* [`_.functions`](#_functionsobject) +* [`_.has`](#_hasobject-property) +* [`_.invert`](#_invertobject) +* [`_.isArguments`](#_isargumentsvalue) +* [`_.isArray`](#_isarrayvalue) +* [`_.isBoolean`](#_isbooleanvalue) +* [`_.isDate`](#_isdatevalue) +* [`_.isElement`](#_iselementvalue) +* [`_.isEmpty`](#_isemptyvalue) +* [`_.isEqual`](#_isequala-b--callback-thisarg) +* [`_.isFinite`](#_isfinitevalue) +* [`_.isFunction`](#_isfunctionvalue) +* [`_.isNaN`](#_isnanvalue) +* [`_.isNull`](#_isnullvalue) +* [`_.isNumber`](#_isnumbervalue) +* [`_.isObject`](#_isobjectvalue) +* [`_.isPlainObject`](#_isplainobjectvalue) +* [`_.isRegExp`](#_isregexpvalue) +* [`_.isString`](#_isstringvalue) +* [`_.isUndefined`](#_isundefinedvalue) +* [`_.keys`](#_keysobject) +* [`_.merge`](#_mergeobject--source1-source2--callback-thisarg) +* [`_.methods`](#_functionsobject) +* [`_.omit`](#_omitobject-callback-prop1-prop2--thisarg) +* [`_.pairs`](#_pairsobject) +* [`_.pick`](#_pickobject-callback-prop1-prop2--thisarg) +* [`_.values`](#_valuesobject) + + + + + + +## `Utilities` +* [`_.escape`](#_escapestring) +* [`_.identity`](#_identityvalue) +* [`_.mixin`](#_mixinobject) +* [`_.noConflict`](#_noconflict) +* [`_.random`](#_randommin0-max1) +* [`_.result`](#_resultobject-property) +* [`_.template`](#_templatetext-data-options) +* [`_.times`](#_timesn-callback--thisarg) +* [`_.unescape`](#_unescapestring) +* [`_.uniqueId`](#_uniqueidprefix) + + + + + + +## `Methods` +* [`_.templateSettings.imports._`](#_templatesettingsimports_) + + + + + + +## `Properties` +* [`_.VERSION`](#_version) +* [`_.templateSettings`](#_templatesettings) +* [`_.templateSettings.escape`](#_templatesettingsescape) +* [`_.templateSettings.evaluate`](#_templatesettingsevaluate) +* [`_.templateSettings.interpolate`](#_templatesettingsinterpolate) +* [`_.templateSettings.variable`](#_templatesettingsvariable) +* [`_.templateSettings.imports`](#_templatesettingsimports) + + + + + + + + + + + + +## `“Arrays†Methods` + + + +### `_.compact(array)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3166 "View in source") [Ⓣ][1] + +Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. + +#### Arguments +1. `array` *(Array)*: The array to compact. + +#### Returns +*(Array)*: Returns a new filtered array. + +#### Example +```js +_.compact([0, 1, false, 2, '', 3]); +// => [1, 2, 3] +``` + +* * * + + + + + + +### `_.difference(array [, array1, array2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3196 "View in source") [Ⓣ][1] + +Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. + +#### Arguments +1. `array` *(Array)*: The array to process. +2. `[array1, array2, ...]` *(Array)*: Arrays to check. + +#### Returns +*(Array)*: Returns a new array of `array` elements not present in the other arrays. + +#### Example +```js +_.difference([1, 2, 3, 4, 5], [5, 2, 10]); +// => [1, 3, 4] +``` + +* * * + + + + + + +### `_.first(array [, callback|n, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3268 "View in source") [Ⓣ][1] + +Gets the first element of the `array`. If a number `n` is passed, the first `n` elements of the `array` are returned. If a `callback` function is passed, the first elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. + +If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`. + +#### Aliases +*head, take* + +#### Arguments +1. `array` *(Array)*: The array to query. +2. `[callback|n]` *(Function|Object|Number|String)*: The function called per element or the number of elements to return. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Mixed)*: Returns the first element(s) of `array`. + +#### Example +```js +_.first([1, 2, 3]); +// => 1 + +_.first([1, 2, 3], 2); +// => [1, 2] + +_.first([1, 2, 3], function(num) { + return num < 3; +}); +// => [1, 2] + +var food = [ + { 'name': 'banana', 'organic': true }, + { 'name': 'beet', 'organic': false }, +]; + +// using "_.pluck" callback shorthand +_.first(food, 'organic'); +// => [{ 'name': 'banana', 'organic': true }] + +var food = [ + { 'name': 'apple', 'type': 'fruit' }, + { 'name': 'banana', 'type': 'fruit' }, + { 'name': 'beet', 'type': 'vegetable' } +]; + +// using "_.where" callback shorthand +_.first(food, { 'type': 'fruit' }); +// => [{ 'name': 'apple', 'type': 'fruit' }, { 'name': 'banana', 'type': 'fruit' }] +``` + +* * * + + + + + + +### `_.flatten(array, shallow)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3307 "View in source") [Ⓣ][1] + +Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. + +#### Arguments +1. `array` *(Array)*: The array to compact. +2. `shallow` *(Boolean)*: A flag to indicate only flattening a single level. + +#### Returns +*(Array)*: Returns a new flattened array. + +#### Example +```js +_.flatten([1, [2], [3, [[4]]]]); +// => [1, 2, 3, 4]; + +_.flatten([1, [2], [3, [[4]]]], true); +// => [1, 2, 3, [[4]]]; +``` + +* * * + + + + + + +### `_.indexOf(array, value [, fromIndex=0])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3349 "View in source") [Ⓣ][1] + +Gets the index at which the first occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `fromIndex` will run a faster binary search. + +#### Arguments +1. `array` *(Array)*: The array to search. +2. `value` *(Mixed)*: The value to search for. +3. `[fromIndex=0]` *(Boolean|Number)*: The index to search from or `true` to perform a binary search on a sorted `array`. + +#### Returns +*(Number)*: Returns the index of the matched value or `-1`. + +#### Example +```js +_.indexOf([1, 2, 3, 1, 2, 3], 2); +// => 1 + +_.indexOf([1, 2, 3, 1, 2, 3], 2, 3); +// => 4 + +_.indexOf([1, 1, 2, 2, 3, 3], 2, true); +// => 2 +``` + +* * * + + + + + + +### `_.initial(array [, callback|n=1, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3423 "View in source") [Ⓣ][1] + +Gets all but the last element of `array`. If a number `n` is passed, the last `n` elements are excluded from the result. If a `callback` function is passed, the last elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. + +If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`. + +#### Arguments +1. `array` *(Array)*: The array to query. +2. `[callback|n=1]` *(Function|Object|Number|String)*: The function called per element or the number of elements to exclude. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Array)*: Returns a slice of `array`. + +#### Example +```js +_.initial([1, 2, 3]); +// => [1, 2] + +_.initial([1, 2, 3], 2); +// => [1] + +_.initial([1, 2, 3], function(num) { + return num > 1; +}); +// => [1] + +var food = [ + { 'name': 'beet', 'organic': false }, + { 'name': 'carrot', 'organic': true } +]; + +// using "_.pluck" callback shorthand +_.initial(food, 'organic'); +// => [{ 'name': 'beet', 'organic': false }] + +var food = [ + { 'name': 'banana', 'type': 'fruit' }, + { 'name': 'beet', 'type': 'vegetable' }, + { 'name': 'carrot', 'type': 'vegetable' } +]; + +// using "_.where" callback shorthand +_.initial(food, { 'type': 'vegetable' }); +// => [{ 'name': 'banana', 'type': 'fruit' }] +``` + +* * * + + + + + + +### `_.intersection([array1, array2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3457 "View in source") [Ⓣ][1] + +Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. + +#### Arguments +1. `[array1, array2, ...]` *(Array)*: Arrays to process. + +#### Returns +*(Array)*: Returns a new array of unique elements that are present in **all** of the arrays. + +#### Example +```js +_.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); +// => [1, 2] +``` + +* * * + + + + + + +### `_.last(array [, callback|n, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3548 "View in source") [Ⓣ][1] + +Gets the last element of the `array`. If a number `n` is passed, the last `n` elements of the `array` are returned. If a `callback` function is passed, the last elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. + + If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`. + +#### Arguments +1. `array` *(Array)*: The array to query. +2. `[callback|n]` *(Function|Object|Number|String)*: The function called per element or the number of elements to return. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Mixed)*: Returns the last element(s) of `array`. + +#### Example +```js +_.last([1, 2, 3]); +// => 3 + +_.last([1, 2, 3], 2); +// => [2, 3] + +_.last([1, 2, 3], function(num) { + return num > 1; +}); +// => [2, 3] + +var food = [ + { 'name': 'beet', 'organic': false }, + { 'name': 'carrot', 'organic': true } +]; + +// using "_.pluck" callback shorthand +_.last(food, 'organic'); +// => [{ 'name': 'carrot', 'organic': true }] + +var food = [ + { 'name': 'banana', 'type': 'fruit' }, + { 'name': 'beet', 'type': 'vegetable' }, + { 'name': 'carrot', 'type': 'vegetable' } +]; + +// using "_.where" callback shorthand +_.last(food, { 'type': 'vegetable' }); +// => [{ 'name': 'beet', 'type': 'vegetable' }, { 'name': 'carrot', 'type': 'vegetable' }] +``` + +* * * + + + + + + +### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3589 "View in source") [Ⓣ][1] + +Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. + +#### Arguments +1. `array` *(Array)*: The array to search. +2. `value` *(Mixed)*: The value to search for. +3. `[fromIndex=array.length-1]` *(Number)*: The index to search from. + +#### Returns +*(Number)*: Returns the index of the matched value or `-1`. + +#### Example +```js +_.lastIndexOf([1, 2, 3, 1, 2, 3], 2); +// => 4 + +_.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); +// => 1 +``` + +* * * + + + + + + +### `_.object(keys [, values=[]])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3619 "View in source") [Ⓣ][1] + +Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. + +#### Arguments +1. `keys` *(Array)*: The array of keys. +2. `[values=[]]` *(Array)*: The array of values. + +#### Returns +*(Object)*: Returns an object composed of the given keys and corresponding values. + +#### Example +```js +_.object(['moe', 'larry'], [30, 40]); +// => { 'moe': 30, 'larry': 40 } +``` + +* * * + + + + + + +### `_.range([start=0], end [, step=1])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3663 "View in source") [Ⓣ][1] + +Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. + +#### Arguments +1. `[start=0]` *(Number)*: The start of the range. +2. `end` *(Number)*: The end of the range. +3. `[step=1]` *(Number)*: The value to increment or descrement by. + +#### Returns +*(Array)*: Returns a new range array. + +#### Example +```js +_.range(10); +// => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + +_.range(1, 11); +// => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + +_.range(0, 30, 5); +// => [0, 5, 10, 15, 20, 25] + +_.range(0, -10, -1); +// => [0, -1, -2, -3, -4, -5, -6, -7, -8, -9] + +_.range(0); +// => [] +``` + +* * * + + + + + + +### `_.rest(array [, callback|n=1, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3741 "View in source") [Ⓣ][1] + +The opposite of `_.initial`, this method gets all but the first value of `array`. If a number `n` is passed, the first `n` values are excluded from the result. If a `callback` function is passed, the first elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. + +If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`. + +#### Aliases +*drop, tail* + +#### Arguments +1. `array` *(Array)*: The array to query. +2. `[callback|n=1]` *(Function|Object|Number|String)*: The function called per element or the number of elements to exclude. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Array)*: Returns a slice of `array`. + +#### Example +```js +_.rest([1, 2, 3]); +// => [2, 3] + +_.rest([1, 2, 3], 2); +// => [3] + +_.rest([1, 2, 3], function(num) { + return num < 3; +}); +// => [3] + +var food = [ + { 'name': 'banana', 'organic': true }, + { 'name': 'beet', 'organic': false }, +]; + +// using "_.pluck" callback shorthand +_.rest(food, 'organic'); +// => [{ 'name': 'beet', 'organic': false }] + +var food = [ + { 'name': 'apple', 'type': 'fruit' }, + { 'name': 'banana', 'type': 'fruit' }, + { 'name': 'beet', 'type': 'vegetable' } +]; + +// using "_.where" callback shorthand +_.rest(food, { 'type': 'fruit' }); +// => [{ 'name': 'beet', 'type': 'vegetable' }] +``` + +* * * + + + + + + +### `_.sortedIndex(array, value [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3805 "View in source") [Ⓣ][1] + +Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. + +If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`. + +#### Arguments +1. `array` *(Array)*: The array to iterate over. +2. `value` *(Mixed)*: The value to evaluate. +3. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Number)*: Returns the index at which the value should be inserted into `array`. + +#### Example +```js +_.sortedIndex([20, 30, 50], 40); +// => 2 + +// using "_.pluck" callback shorthand +_.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); +// => 2 + +var dict = { + 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 } +}; + +_.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { + return dict.wordToNumber[word]; +}); +// => 2 + +_.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { + return this.wordToNumber[word]; +}, dict); +// => 2 +``` + +* * * + + + + + + +### `_.union([array1, array2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3837 "View in source") [Ⓣ][1] + +Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. + +#### Arguments +1. `[array1, array2, ...]` *(Array)*: Arrays to process. + +#### Returns +*(Array)*: Returns a new array of unique values, in order, that are present in one or more of the arrays. + +#### Example +```js +_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); +// => [1, 2, 3, 101, 10] +``` + +* * * + + + + + + +### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3884 "View in source") [Ⓣ][1] + +Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. + +If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`. + +#### Aliases +*unique* + +#### Arguments +1. `array` *(Array)*: The array to process. +2. `[isSorted=false]` *(Boolean)*: A flag to indicate that the `array` is already sorted. +3. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Array)*: Returns a duplicate-value-free array. + +#### Example +```js +_.uniq([1, 2, 1, 3, 1]); +// => [1, 2, 3] + +_.uniq([1, 1, 2, 2, 3], true); +// => [1, 2, 3] + +_.uniq([1, 2, 1.5, 3, 2.5], function(num) { return Math.floor(num); }); +// => [1, 2, 3] + +_.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); +// => [1, 2, 3] + +// using "_.pluck" callback shorthand +_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); +// => [{ 'x': 1 }, { 'x': 2 }] +``` + +* * * + + + + + + +### `_.without(array [, value1, value2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3943 "View in source") [Ⓣ][1] + +Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. + +#### Arguments +1. `array` *(Array)*: The array to filter. +2. `[value1, value2, ...]` *(Mixed)*: Values to remove. + +#### Returns +*(Array)*: Returns a new filtered array. + +#### Example +```js +_.without([1, 2, 1, 0, 3, 1, 4], 0, 1); +// => [2, 3, 4] +``` + +* * * + + + + + + +### `_.zip([array1, array2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3974 "View in source") [Ⓣ][1] + +Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. + +#### Arguments +1. `[array1, array2, ...]` *(Array)*: Arrays to process. + +#### Returns +*(Array)*: Returns a new array of grouped elements. + +#### Example +```js +_.zip(['moe', 'larry'], [30, 40], [true, false]); +// => [['moe', 30, true], ['larry', 40, false]] +``` + +* * * + + + + + + + + + +## `“Chaining†Methods` + + + +### `_(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L272 "View in source") [Ⓣ][1] + +Creates a `lodash` object, that wraps the given `value`, to enable method chaining. + +In addition to Lo-Dash methods, wrappers also have the following `Array` methods:
+`concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, and `unshift` + +The chainable wrapper functions are:
+`after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `concat`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `values`, `where`, `without`, `wrap`, and `zip` + +The non-chainable wrapper functions are:
+`clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId` + +The wrapper functions `first` and `last` return wrapped values when `n` is passed, otherwise they return unwrapped values. + +#### Arguments +1. `value` *(Mixed)*: The value to wrap in a `lodash` instance. + +#### Returns +*(Object)*: Returns a `lodash` instance. + +* * * + + + + + + +### `_.tap(value, interceptor)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4874 "View in source") [Ⓣ][1] + +Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. + +#### Arguments +1. `value` *(Mixed)*: The value to pass to `interceptor`. +2. `interceptor` *(Function)*: The function to invoke. + +#### Returns +*(Mixed)*: Returns `value`. + +#### Example +```js +_([1, 2, 3, 4]) + .filter(function(num) { return num % 2 == 0; }) + .tap(alert) + .map(function(num) { return num * num; }) + .value(); +// => // [2, 4] (alerted) +// => [4, 16] +``` + +* * * + + + + + + +### `_.prototype.toString()` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4891 "View in source") [Ⓣ][1] + +Produces the `toString` result of the wrapped value. + +#### Returns +*(String)*: Returns the string result. + +#### Example +```js +_([1, 2, 3]).toString(); +// => '1,2,3' +``` + +* * * + + + + + + +### `_.prototype.valueOf()` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4908 "View in source") [Ⓣ][1] + +Extracts the wrapped value. + +#### Aliases +*value* + +#### Returns +*(Mixed)*: Returns the wrapped value. + +#### Example +```js +_([1, 2, 3]).valueOf(); +// => [1, 2, 3] +``` + +* * * + + + + + + + + + +## `“Collections†Methods` + + + +### `_.at(collection [, index1, index2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2167 "View in source") [Ⓣ][1] + +Creates an array of elements from the specified indexes, or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[index1, index2, ...]` *(Array|Number|String)*: The indexes of `collection` to retrieve, either as individual arguments or arrays. + +#### Returns +*(Array)*: Returns a new array of elements corresponding to the provided indexes. + +#### Example +```js +_.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]); +// => ['a', 'c', 'e'] + +_.at(['moe', 'larry', 'curly'], 0, 2); +// => ['moe', 'curly'] +``` + +* * * + + + + + + +### `_.contains(collection, target [, fromIndex=0])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2209 "View in source") [Ⓣ][1] + +Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. + +#### Aliases +*include* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `target` *(Mixed)*: The value to check for. +3. `[fromIndex=0]` *(Number)*: The index to search from. + +#### Returns +*(Boolean)*: Returns `true` if the `target` element is found, else `false`. + +#### Example +```js +_.contains([1, 2, 3], 1); +// => true + +_.contains([1, 2, 3], 1, 2); +// => false + +_.contains({ 'name': 'moe', 'age': 40 }, 'moe'); +// => true + +_.contains('curly', 'ur'); +// => true +``` + +* * * + + + + + + +### `_.countBy(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2263 "View in source") [Ⓣ][1] + +Creates an object composed of keys returned from running each element of the `collection` through the given `callback`. The corresponding value of each key is the number of times the key was returned by the `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. + +If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Object)*: Returns the composed aggregate object. + +#### Example +```js +_.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); }); +// => { '4': 1, '6': 2 } + +_.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math); +// => { '4': 1, '6': 2 } + +_.countBy(['one', 'two', 'three'], 'length'); +// => { '3': 2, '5': 1 } +``` + +* * * + + + + + + +### `_.every(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2315 "View in source") [Ⓣ][1] + +Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. + +If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`. + +#### Aliases +*all* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Boolean)*: Returns `true` if all elements pass the callback check, else `false`. + +#### Example +```js +_.every([true, 1, null, 'yes'], Boolean); +// => false + +var stooges = [ + { 'name': 'moe', 'age': 40 }, + { 'name': 'larry', 'age': 50 } +]; + +// using "_.pluck" callback shorthand +_.every(stooges, 'age'); +// => true + +// using "_.where" callback shorthand +_.every(stooges, { 'age': 50 }); +// => false +``` + +* * * + + + + + + +### `_.filter(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2376 "View in source") [Ⓣ][1] + +Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. + +If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`. + +#### Aliases +*select* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Array)*: Returns a new array of elements that passed the callback check. + +#### Example +```js +var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); +// => [2, 4, 6] + +var food = [ + { 'name': 'apple', 'organic': false, 'type': 'fruit' }, + { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } +]; + +// using "_.pluck" callback shorthand +_.filter(food, 'organic'); +// => [{ 'name': 'carrot', 'organic': true, 'type': 'vegetable' }] + +// using "_.where" callback shorthand +_.filter(food, { 'type': 'fruit' }); +// => [{ 'name': 'apple', 'organic': false, 'type': 'fruit' }] +``` + +* * * + + + + + + +### `_.find(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2443 "View in source") [Ⓣ][1] + +Examines each element in a `collection`, returning the first that the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. + +If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`. + +#### Aliases +*detect* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Mixed)*: Returns the element that passed the callback check, else `undefined`. + +#### Example +```js +var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); +// => 2 + +var food = [ + { 'name': 'apple', 'organic': false, 'type': 'fruit' }, + { 'name': 'banana', 'organic': true, 'type': 'fruit' }, + { 'name': 'beet', 'organic': false, 'type': 'vegetable' }, + { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } +]; + +// using "_.where" callback shorthand +var veggie = _.find(food, { 'type': 'vegetable' }); +// => { 'name': 'beet', 'organic': false, 'type': 'vegetable' } + +// using "_.pluck" callback shorthand +var healthy = _.find(food, 'organic'); +// => { 'name': 'banana', 'organic': true, 'type': 'fruit' } +``` + +* * * + + + + + + +### `_.forEach(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2478 "View in source") [Ⓣ][1] + +Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. + +#### Aliases +*each* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function)*: The function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Array, Object, String)*: Returns `collection`. + +#### Example +```js +_([1, 2, 3]).forEach(alert).join(','); +// => alerts each number and returns '1,2,3' + +_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); +// => alerts each number value (order is not guaranteed) +``` + +* * * + + + + + + +### `_.groupBy(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2528 "View in source") [Ⓣ][1] + +Creates an object composed of keys returned from running each element of the `collection` through the `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. + +If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false` + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Object)*: Returns the composed aggregate object. + +#### Example +```js +_.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); }); +// => { '4': [4.2], '6': [6.1, 6.4] } + +_.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math); +// => { '4': [4.2], '6': [6.1, 6.4] } + +// using "_.pluck" callback shorthand +_.groupBy(['one', 'two', 'three'], 'length'); +// => { '3': ['one', 'two'], '5': ['three'] } +``` + +* * * + + + + + + +### `_.invoke(collection, methodName [, arg1, arg2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2561 "View in source") [Ⓣ][1] + +Invokes the method named by `methodName` on each element in the `collection`, returning an array of the results of each invoked method. Additional arguments will be passed to each invoked method. If `methodName` is a function, it will be invoked for, and `this` bound to, each element in the `collection`. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `methodName` *(Function|String)*: The name of the method to invoke or the function invoked per iteration. +3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the method with. + +#### Returns +*(Array)*: Returns a new array of the results of each invoked method. + +#### Example +```js +_.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); +// => [[1, 5, 7], [1, 2, 3]] + +_.invoke([123, 456], String.prototype.split, ''); +// => [['1', '2', '3'], ['4', '5', '6']] +``` + +* * * + + + + + + +### `_.map(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2613 "View in source") [Ⓣ][1] + +Creates an array of values by running each element in the `collection` through the `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. + +If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`. + +#### Aliases +*collect* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Array)*: Returns a new array of the results of each `callback` execution. + +#### Example +```js +_.map([1, 2, 3], function(num) { return num * 3; }); +// => [3, 6, 9] + +_.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); +// => [3, 6, 9] (order is not guaranteed) + +var stooges = [ + { 'name': 'moe', 'age': 40 }, + { 'name': 'larry', 'age': 50 } +]; + +// using "_.pluck" callback shorthand +_.map(stooges, 'name'); +// => ['moe', 'larry'] +``` + +* * * + + + + + + +### `_.max(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2670 "View in source") [Ⓣ][1] + +Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. + +If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Mixed)*: Returns the maximum value. + +#### Example +```js +_.max([4, 2, 8, 6]); +// => 8 + +var stooges = [ + { 'name': 'moe', 'age': 40 }, + { 'name': 'larry', 'age': 50 } +]; + +_.max(stooges, function(stooge) { return stooge.age; }); +// => { 'name': 'larry', 'age': 50 }; + +// using "_.pluck" callback shorthand +_.max(stooges, 'age'); +// => { 'name': 'larry', 'age': 50 }; +``` + +* * * + + + + + + +### `_.min(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2739 "View in source") [Ⓣ][1] + +Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. + +If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Mixed)*: Returns the minimum value. + +#### Example +```js +_.min([4, 2, 8, 6]); +// => 2 + +var stooges = [ + { 'name': 'moe', 'age': 40 }, + { 'name': 'larry', 'age': 50 } +]; + +_.min(stooges, function(stooge) { return stooge.age; }); +// => { 'name': 'moe', 'age': 40 }; + +// using "_.pluck" callback shorthand +_.min(stooges, 'age'); +// => { 'name': 'moe', 'age': 40 }; +``` + +* * * + + + + + + +### `_.pluck(collection, property)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2789 "View in source") [Ⓣ][1] + +Retrieves the value of a specified property from all elements in the `collection`. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `property` *(String)*: The property to pluck. + +#### Returns +*(Array)*: Returns a new array of property values. + +#### Example +```js +var stooges = [ + { 'name': 'moe', 'age': 40 }, + { 'name': 'larry', 'age': 50 } +]; + +_.pluck(stooges, 'name'); +// => ['moe', 'larry'] +``` + +* * * + + + + + + +### `_.reduce(collection [, callback=identity, accumulator, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2821 "View in source") [Ⓣ][1] + +Reduces a `collection` to a value that is the accumulated result of running each element in the `collection` through the `callback`, where each successive `callback` execution consumes the return value of the previous execution. If `accumulator` is not passed, the first element of the `collection` will be used as the initial `accumulator` value. The `callback` is bound to `thisArg` and invoked with four arguments; *(accumulator, value, index|key, collection)*. + +#### Aliases +*foldl, inject* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function)*: The function called per iteration. +3. `[accumulator]` *(Mixed)*: Initial value of the accumulator. +4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Mixed)*: Returns the accumulated value. + +#### Example +```js +var sum = _.reduce([1, 2, 3], function(sum, num) { + return sum + num; +}); +// => 6 + +var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { + result[key] = num * 3; + return result; +}, {}); +// => { 'a': 3, 'b': 6, 'c': 9 } +``` + +* * * + + + + + + +### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2864 "View in source") [Ⓣ][1] + +This method is similar to `_.reduce`, except that it iterates over a `collection` from right to left. + +#### Aliases +*foldr* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function)*: The function called per iteration. +3. `[accumulator]` *(Mixed)*: Initial value of the accumulator. +4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Mixed)*: Returns the accumulated value. + +#### Example +```js +var list = [[0, 1], [2, 3], [4, 5]]; +var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); +// => [4, 5, 2, 3, 0, 1] +``` + +* * * + + + + + + +### `_.reject(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2924 "View in source") [Ⓣ][1] + +The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. + +If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Array)*: Returns a new array of elements that did **not** pass the callback check. + +#### Example +```js +var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); +// => [1, 3, 5] + +var food = [ + { 'name': 'apple', 'organic': false, 'type': 'fruit' }, + { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } +]; + +// using "_.pluck" callback shorthand +_.reject(food, 'organic'); +// => [{ 'name': 'apple', 'organic': false, 'type': 'fruit' }] + +// using "_.where" callback shorthand +_.reject(food, { 'type': 'fruit' }); +// => [{ 'name': 'carrot', 'organic': true, 'type': 'vegetable' }] +``` + +* * * + + + + + + +### `_.shuffle(collection)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2945 "View in source") [Ⓣ][1] + +Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to shuffle. + +#### Returns +*(Array)*: Returns a new shuffled collection. + +#### Example +```js +_.shuffle([1, 2, 3, 4, 5, 6]); +// => [4, 1, 6, 3, 5, 2] +``` + +* * * + + + + + + +### `_.size(collection)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2978 "View in source") [Ⓣ][1] + +Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to inspect. + +#### Returns +*(Number)*: Returns `collection.length` or number of own enumerable properties. + +#### Example +```js +_.size([1, 2]); +// => 2 + +_.size({ 'one': 1, 'two': 2, 'three': 3 }); +// => 3 + +_.size('curly'); +// => 5 +``` + +* * * + + + + + + +### `_.some(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3025 "View in source") [Ⓣ][1] + +Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. + +If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`. + +#### Aliases +*any* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Boolean)*: Returns `true` if any element passes the callback check, else `false`. + +#### Example +```js +_.some([null, 0, 'yes', false], Boolean); +// => true + +var food = [ + { 'name': 'apple', 'organic': false, 'type': 'fruit' }, + { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } +]; + +// using "_.pluck" callback shorthand +_.some(food, 'organic'); +// => true + +// using "_.where" callback shorthand +_.some(food, { 'type': 'meat' }); +// => false +``` + +* * * + + + + + + +### `_.sortBy(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3081 "View in source") [Ⓣ][1] + +Creates an array of elements, sorted in ascending order by the results of running each element in the `collection` through the `callback`. This method performs a stable sort, that is, it will preserve the original sort order of equal elements. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. + +If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the propeties of the given object, else `false`. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Array)*: Returns a new array of sorted elements. + +#### Example +```js +_.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); +// => [3, 1, 2] + +_.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); +// => [3, 1, 2] + +// using "_.pluck" callback shorthand +_.sortBy(['banana', 'strawberry', 'apple'], 'length'); +// => ['apple', 'banana', 'strawberry'] +``` + +* * * + + + + + + +### `_.toArray(collection)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3116 "View in source") [Ⓣ][1] + +Converts the `collection` to an array. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to convert. + +#### Returns +*(Array)*: Returns the new converted array. + +#### Example +```js +(function() { return _.toArray(arguments).slice(1); })(1, 2, 3, 4); +// => [2, 3, 4] +``` + +* * * + + + + + + +### `_.where(collection, properties)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3148 "View in source") [Ⓣ][1] + +Examines each element in a `collection`, returning an array of all elements that have the given `properties`. When checking `properties`, this method performs a deep comparison between values to determine if they are equivalent to each other. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `properties` *(Object)*: The object of property values to filter by. + +#### Returns +*(Array)*: Returns a new array of elements that have the given `properties`. + +#### Example +```js +var stooges = [ + { 'name': 'moe', 'age': 40 }, + { 'name': 'larry', 'age': 50 } +]; + +_.where(stooges, { 'age': 40 }); +// => [{ 'name': 'moe', 'age': 40 }] +``` + +* * * + + + + + + + + + +## `“Functions†Methods` + + + +### `_.after(n, func)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4007 "View in source") [Ⓣ][1] + +Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. + +#### Arguments +1. `n` *(Number)*: The number of times the function must be called before it is executed. +2. `func` *(Function)*: The function to restrict. + +#### Returns +*(Function)*: Returns the new restricted function. + +#### Example +```js +var renderNotes = _.after(notes.length, render); +_.forEach(notes, function(note) { + note.asyncSave({ 'success': renderNotes }); +}); +// `renderNotes` is run once, after all notes have saved +``` + +* * * + + + + + + +### `_.bind(func [, thisArg, arg1, arg2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4040 "View in source") [Ⓣ][1] + +Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. + +#### Arguments +1. `func` *(Function)*: The function to bind. +2. `[thisArg]` *(Mixed)*: The `this` binding of `func`. +3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to be partially applied. + +#### Returns +*(Function)*: Returns the new bound function. + +#### Example +```js +var func = function(greeting) { + return greeting + ' ' + this.name; +}; + +func = _.bind(func, { 'name': 'moe' }, 'hi'); +func(); +// => 'hi moe' +``` + +* * * + + + + + + +### `_.bindAll(object [, methodName1, methodName2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4071 "View in source") [Ⓣ][1] + +Binds methods on `object` to `object`, overwriting the existing method. Method names may be specified as individual arguments or as arrays of method names. If no method names are provided, all the function properties of `object` will be bound. + +#### Arguments +1. `object` *(Object)*: The object to bind and assign the bound methods to. +2. `[methodName1, methodName2, ...]` *(String)*: Method names on the object to bind. + +#### Returns +*(Object)*: Returns `object`. + +#### Example +```js +var view = { + 'label': 'docs', + 'onClick': function() { alert('clicked ' + this.label); } +}; + +_.bindAll(view); +jQuery('#docs').on('click', view.onClick); +// => alerts 'clicked docs', when the button is clicked +``` + +* * * + + + + + + +### `_.bindKey(object, key [, arg1, arg2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4117 "View in source") [Ⓣ][1] + +Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed to the bound function. This method differs from `_.bind` by allowing bound functions to reference methods that will be redefined or don't yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern. + +#### Arguments +1. `object` *(Object)*: The object the method belongs to. +2. `key` *(String)*: The key of the method. +3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to be partially applied. + +#### Returns +*(Function)*: Returns the new bound function. + +#### Example +```js +var object = { + 'name': 'moe', + 'greet': function(greeting) { + return greeting + ' ' + this.name; + } +}; + +var func = _.bindKey(object, 'greet', 'hi'); +func(); +// => 'hi moe' + +object.greet = function(greeting) { + return greeting + ', ' + this.name + '!'; +}; + +func(); +// => 'hi, moe!' +``` + +* * * + + + + + + +### `_.compose([func1, func2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4140 "View in source") [Ⓣ][1] + +Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. + +#### Arguments +1. `[func1, func2, ...]` *(Function)*: Functions to compose. + +#### Returns +*(Function)*: Returns the new composed function. + +#### Example +```js +var greet = function(name) { return 'hi ' + name; }; +var exclaim = function(statement) { return statement + '!'; }; +var welcome = _.compose(exclaim, greet); +welcome('moe'); +// => 'hi moe!' +``` + +* * * + + + + + + +### `_.debounce(func, wait, immediate)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4173 "View in source") [Ⓣ][1] + +Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. + +#### Arguments +1. `func` *(Function)*: The function to debounce. +2. `wait` *(Number)*: The number of milliseconds to delay. +3. `immediate` *(Boolean)*: A flag to indicate execution is on the leading edge of the timeout. + +#### Returns +*(Function)*: Returns the new debounced function. + +#### Example +```js +var lazyLayout = _.debounce(calculateLayout, 300); +jQuery(window).on('resize', lazyLayout); +``` + +* * * + + + + + + +### `_.defer(func [, arg1, arg2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4237 "View in source") [Ⓣ][1] + +Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. + +#### Arguments +1. `func` *(Function)*: The function to defer. +2. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the function with. + +#### Returns +*(Number)*: Returns the `setTimeout` timeout id. + +#### Example +```js +_.defer(function() { alert('deferred'); }); +// returns from the function before `alert` is called +``` + +* * * + + + + + + +### `_.delay(func, wait [, arg1, arg2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4217 "View in source") [Ⓣ][1] + +Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. + +#### Arguments +1. `func` *(Function)*: The function to delay. +2. `wait` *(Number)*: The number of milliseconds to delay execution. +3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the function with. + +#### Returns +*(Number)*: Returns the `setTimeout` timeout id. + +#### Example +```js +var log = _.bind(console.log, console); +_.delay(log, 1000, 'logged later'); +// => 'logged later' (Appears after one second.) +``` + +* * * + + + + + + +### `_.memoize(func [, resolver])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4265 "View in source") [Ⓣ][1] + +Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. + +#### Arguments +1. `func` *(Function)*: The function to have its output memoized. +2. `[resolver]` *(Function)*: A function used to resolve the cache key. + +#### Returns +*(Function)*: Returns the new memoizing function. + +#### Example +```js +var fibonacci = _.memoize(function(n) { + return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); +}); +``` + +* * * + + + + + + +### `_.once(func)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4292 "View in source") [Ⓣ][1] + +Creates a function that is restricted to execute `func` once. Repeat calls to the function will return the value of the first call. The `func` is executed with the `this` binding of the created function. + +#### Arguments +1. `func` *(Function)*: The function to restrict. + +#### Returns +*(Function)*: Returns the new restricted function. + +#### Example +```js +var initialize = _.once(createApplication); +initialize(); +initialize(); +// `initialize` executes `createApplication` once +``` + +* * * + + + + + + +### `_.partial(func [, arg1, arg2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4327 "View in source") [Ⓣ][1] + +Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `_.bind`, except it does **not** alter the `this` binding. + +#### Arguments +1. `func` *(Function)*: The function to partially apply arguments to. +2. `[arg1, arg2, ...]` *(Mixed)*: Arguments to be partially applied. + +#### Returns +*(Function)*: Returns the new partially applied function. + +#### Example +```js +var greet = function(greeting, name) { return greeting + ' ' + name; }; +var hi = _.partial(greet, 'hi'); +hi('moe'); +// => 'hi moe' +``` + +* * * + + + + + + +### `_.partialRight(func [, arg1, arg2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4358 "View in source") [Ⓣ][1] + +This method is similar to `_.partial`, except that `partial` arguments are appended to those passed to the new function. + +#### Arguments +1. `func` *(Function)*: The function to partially apply arguments to. +2. `[arg1, arg2, ...]` *(Mixed)*: Arguments to be partially applied. + +#### Returns +*(Function)*: Returns the new partially applied function. + +#### Example +```js +var defaultsDeep = _.partialRight(_.merge, _.defaults); + +var options = { + 'variable': 'data', + 'imports': { 'jq': $ } +}; + +defaultsDeep(options, _.templateSettings); + +options.variable +// => 'data' + +options.imports +// => { '_': _, 'jq': $ } +``` + +* * * + + + + + + +### `_.throttle(func, wait)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4380 "View in source") [Ⓣ][1] + +Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. + +#### Arguments +1. `func` *(Function)*: The function to throttle. +2. `wait` *(Number)*: The number of milliseconds to throttle executions to. + +#### Returns +*(Function)*: Returns the new throttled function. + +#### Example +```js +var throttled = _.throttle(updatePosition, 100); +jQuery(window).on('scroll', throttled); +``` + +* * * + + + + + + +### `_.wrap(value, wrapper)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4433 "View in source") [Ⓣ][1] + +Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. + +#### Arguments +1. `value` *(Mixed)*: The value to wrap. +2. `wrapper` *(Function)*: The wrapper function. + +#### Returns +*(Function)*: Returns the new function. + +#### Example +```js +var hello = function(name) { return 'hello ' + name; }; +hello = _.wrap(hello, function(func) { + return 'before, ' + func('moe') + ', after'; +}); +hello(); +// => 'before, hello moe, after' +``` + +* * * + + + + + + + + + +## `“Objects†Methods` + + + +### `_.assign(object [, source1, source2, ..., callback, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1062 "View in source") [Ⓣ][1] + +Assigns own enumerable properties of source object(s) to the destination object. Subsequent sources will overwrite propery assignments of previous sources. If a `callback` function is passed, it will be executed to produce the assigned values. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. + +#### Aliases +*extend* + +#### Arguments +1. `object` *(Object)*: The destination object. +2. `[source1, source2, ...]` *(Object)*: The source objects. +3. `[callback]` *(Function)*: The function to customize assigning values. +4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Object)*: Returns the destination object. + +#### Example +```js +_.assign({ 'name': 'moe' }, { 'age': 40 }); +// => { 'name': 'moe', 'age': 40 } + +var defaults = _.partialRight(_.assign, function(a, b) { + return typeof a == 'undefined' ? b : a; +}); + +var food = { 'name': 'apple' }; +defaults(food, { 'name': 'banana', 'type': 'fruit' }); +// => { 'name': 'apple', 'type': 'fruit' } +``` + +* * * + + + + + + +### `_.clone(value [, deep=false, callback, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1117 "View in source") [Ⓣ][1] + +Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. If a `callback` function is passed, it will be executed to produce the cloned values. If `callback` returns `undefined`, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. + +#### Arguments +1. `value` *(Mixed)*: The value to clone. +2. `[deep=false]` *(Boolean)*: A flag to indicate a deep clone. +3. `[callback]` *(Function)*: The function to customize cloning values. +4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Mixed)*: Returns the cloned `value`. + +#### Example +```js +var stooges = [ + { 'name': 'moe', 'age': 40 }, + { 'name': 'larry', 'age': 50 } +]; + +var shallow = _.clone(stooges); +shallow[0] === stooges[0]; +// => true + +var deep = _.clone(stooges, true); +deep[0] === stooges[0]; +// => false + +_.mixin({ + 'clone': _.partialRight(_.clone, function(value) { + return _.isElement(value) ? value.cloneNode(false) : undefined; + }) +}); + +var clone = _.clone(document.body); +clone.childNodes.length; +// => 0 +``` + +* * * + + + + + + +### `_.cloneDeep(value [, callback, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1242 "View in source") [Ⓣ][1] + +Creates a deep clone of `value`. If a `callback` function is passed, it will be executed to produce the cloned values. If `callback` returns the value it was passed, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. + +Note: This function is loosely based on the structured clone algorithm. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. See http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm. + +#### Arguments +1. `value` *(Mixed)*: The value to deep clone. +2. `[callback]` *(Function)*: The function to customize cloning values. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Mixed)*: Returns the deep cloned `value`. + +#### Example +```js +var stooges = [ + { 'name': 'moe', 'age': 40 }, + { 'name': 'larry', 'age': 50 } +]; + +var deep = _.cloneDeep(stooges); +deep[0] === stooges[0]; +// => false + +var view = { + 'label': 'docs', + 'node': element +}; + +var clone = _.cloneDeep(view, function(value) { + return _.isElement(value) ? value.cloneNode(true) : value; +}); + +clone.node == view.node; +// => false +``` + +* * * + + + + + + +### `_.defaults(object [, source1, source2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1266 "View in source") [Ⓣ][1] + +Assigns own enumerable properties of source object(s) to the destination object for all destination properties that resolve to `undefined`. Once a property is set, additional defaults of the same property will be ignored. + +#### Arguments +1. `object` *(Object)*: The destination object. +2. `[source1, source2, ...]` *(Object)*: The source objects. + +#### Returns +*(Object)*: Returns the destination object. + +#### Example +```js +var food = { 'name': 'apple' }; +_.defaults(food, { 'name': 'banana', 'type': 'fruit' }); +// => { 'name': 'apple', 'type': 'fruit' } +``` + +* * * + + + + + + +### `_.forIn(object [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L882 "View in source") [Ⓣ][1] + +Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. + +#### Arguments +1. `object` *(Object)*: The object to iterate over. +2. `[callback=identity]` *(Function)*: The function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Object)*: Returns `object`. + +#### Example +```js +function Dog(name) { + this.name = name; +} + +Dog.prototype.bark = function() { + alert('Woof, woof!'); +}; + +_.forIn(new Dog('Dagny'), function(value, key) { + alert(key); +}); +// => alerts 'name' and 'bark' (order is not guaranteed) +``` + +* * * + + + + + + +### `_.forOwn(object [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L907 "View in source") [Ⓣ][1] + +Iterates over an object's own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. + +#### Arguments +1. `object` *(Object)*: The object to iterate over. +2. `[callback=identity]` *(Function)*: The function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Object)*: Returns `object`. + +#### Example +```js +_.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { + alert(key); +}); +// => alerts '0', '1', and 'length' (order is not guaranteed) +``` + +* * * + + + + + + +### `_.functions(object)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1283 "View in source") [Ⓣ][1] + +Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. + +#### Aliases +*methods* + +#### Arguments +1. `object` *(Object)*: The object to inspect. + +#### Returns +*(Array)*: Returns a new array of property names that have function values. + +#### Example +```js +_.functions(_); +// => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...] +``` + +* * * + + + + + + +### `_.has(object, property)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1308 "View in source") [Ⓣ][1] + +Checks if the specified object `property` exists and is a direct property, instead of an inherited property. + +#### Arguments +1. `object` *(Object)*: The object to check. +2. `property` *(String)*: The property to check for. + +#### Returns +*(Boolean)*: Returns `true` if key is a direct property, else `false`. + +#### Example +```js +_.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); +// => true +``` + +* * * + + + + + + +### `_.invert(object)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1325 "View in source") [Ⓣ][1] + +Creates an object composed of the inverted keys and values of the given `object`. + +#### Arguments +1. `object` *(Object)*: The object to invert. + +#### Returns +*(Object)*: Returns the created inverted object. + +#### Example +```js +_.invert({ 'first': 'moe', 'second': 'larry' }); +// => { 'moe': 'first', 'larry': 'second' } (order is not guaranteed) +``` + +* * * + + + + + + +### `_.isArguments(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L843 "View in source") [Ⓣ][1] + +Checks if `value` is an `arguments` object. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true`, if the `value` is an `arguments` object, else `false`. + +#### Example +```js +(function() { return _.isArguments(arguments); })(1, 2, 3); +// => true + +_.isArguments([1, 2, 3]); +// => false +``` + +* * * + + + + + + +### `_.isArray(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L925 "View in source") [Ⓣ][1] + +Checks if `value` is an array. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true`, if the `value` is an array, else `false`. + +#### Example +```js +(function() { return _.isArray(arguments); })(); +// => false + +_.isArray([1, 2, 3]); +// => true +``` + +* * * + + + + + + +### `_.isBoolean(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1351 "View in source") [Ⓣ][1] + +Checks if `value` is a boolean value. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true`, if the `value` is a boolean value, else `false`. + +#### Example +```js +_.isBoolean(null); +// => false +``` + +* * * + + + + + + +### `_.isDate(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1368 "View in source") [Ⓣ][1] + +Checks if `value` is a date. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true`, if the `value` is a date, else `false`. + +#### Example +```js +_.isDate(new Date); +// => true +``` + +* * * + + + + + + +### `_.isElement(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1385 "View in source") [Ⓣ][1] + +Checks if `value` is a DOM element. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true`, if the `value` is a DOM element, else `false`. + +#### Example +```js +_.isElement(document.body); +// => true +``` + +* * * + + + + + + +### `_.isEmpty(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1410 "View in source") [Ⓣ][1] + +Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". + +#### Arguments +1. `value` *(Array|Object|String)*: The value to inspect. + +#### Returns +*(Boolean)*: Returns `true`, if the `value` is empty, else `false`. + +#### Example +```js +_.isEmpty([1, 2, 3]); +// => false + +_.isEmpty({}); +// => true + +_.isEmpty(''); +// => true +``` + +* * * + + + + + + +### `_.isEqual(a, b [, callback, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1469 "View in source") [Ⓣ][1] + +Performs a deep comparison between two values to determine if they are equivalent to each other. If `callback` is passed, it will be executed to compare values. If `callback` returns `undefined`, comparisons will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(a, b)*. + +#### Arguments +1. `a` *(Mixed)*: The value to compare. +2. `b` *(Mixed)*: The other value to compare. +3. `[callback]` *(Function)*: The function to customize comparing values. +4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Boolean)*: Returns `true`, if the values are equvalent, else `false`. + +#### Example +```js +var moe = { 'name': 'moe', 'age': 40 }; +var copy = { 'name': 'moe', 'age': 40 }; + +moe == copy; +// => false + +_.isEqual(moe, copy); +// => true + +var words = ['hello', 'goodbye']; +var otherWords = ['hi', 'goodbye']; + +_.isEqual(words, otherWords, function(a, b) { + var reGreet = /^(?:hello|hi)$/i, + aGreet = _.isString(a) && reGreet.test(a), + bGreet = _.isString(b) && reGreet.test(b); + + return (aGreet || bGreet) ? (aGreet == bGreet) : undefined; +}); +// => true +``` + +* * * + + + + + + +### `_.isFinite(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1650 "View in source") [Ⓣ][1] + +Checks if `value` is, or can be coerced to, a finite number. + +Note: This is not the same as native `isFinite`, which will return true for booleans and empty strings. See http://es5.github.com/#x15.1.2.5. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true`, if the `value` is finite, else `false`. + +#### Example +```js +_.isFinite(-101); +// => true + +_.isFinite('10'); +// => true + +_.isFinite(true); +// => false + +_.isFinite(''); +// => false + +_.isFinite(Infinity); +// => false +``` + +* * * + + + + + + +### `_.isFunction(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1667 "View in source") [Ⓣ][1] + +Checks if `value` is a function. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true`, if the `value` is a function, else `false`. + +#### Example +```js +_.isFunction(_); +// => true +``` + +* * * + + + + + + +### `_.isNaN(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1730 "View in source") [Ⓣ][1] + +Checks if `value` is `NaN`. + +Note: This is not the same as native `isNaN`, which will return `true` for `undefined` and other values. See http://es5.github.com/#x15.1.2.4. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true`, if the `value` is `NaN`, else `false`. + +#### Example +```js +_.isNaN(NaN); +// => true + +_.isNaN(new Number(NaN)); +// => true + +isNaN(undefined); +// => true + +_.isNaN(undefined); +// => false +``` + +* * * + + + + + + +### `_.isNull(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1752 "View in source") [Ⓣ][1] + +Checks if `value` is `null`. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true`, if the `value` is `null`, else `false`. + +#### Example +```js +_.isNull(null); +// => true + +_.isNull(undefined); +// => false +``` + +* * * + + + + + + +### `_.isNumber(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1769 "View in source") [Ⓣ][1] + +Checks if `value` is a number. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true`, if the `value` is a number, else `false`. + +#### Example +```js +_.isNumber(8.4 * 5); +// => true +``` + +* * * + + + + + + +### `_.isObject(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1697 "View in source") [Ⓣ][1] + +Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true`, if the `value` is an object, else `false`. + +#### Example +```js +_.isObject({}); +// => true + +_.isObject([1, 2, 3]); +// => true + +_.isObject(1); +// => false +``` + +* * * + + + + + + +### `_.isPlainObject(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1797 "View in source") [Ⓣ][1] + +Checks if a given `value` is an object created by the `Object` constructor. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true`, if `value` is a plain object, else `false`. + +#### Example +```js +function Stooge(name, age) { + this.name = name; + this.age = age; +} + +_.isPlainObject(new Stooge('moe', 40)); +// => false + +_.isPlainObject([1, 2, 3]); +// => false + +_.isPlainObject({ 'name': 'moe', 'age': 40 }); +// => true +``` + +* * * + + + + + + +### `_.isRegExp(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1822 "View in source") [Ⓣ][1] + +Checks if `value` is a regular expression. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true`, if the `value` is a regular expression, else `false`. + +#### Example +```js +_.isRegExp(/moe/); +// => true +``` + +* * * + + + + + + +### `_.isString(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1839 "View in source") [Ⓣ][1] + +Checks if `value` is a string. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true`, if the `value` is a string, else `false`. + +#### Example +```js +_.isString('moe'); +// => true +``` + +* * * + + + + + + +### `_.isUndefined(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1856 "View in source") [Ⓣ][1] + +Checks if `value` is `undefined`. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true`, if the `value` is `undefined`, else `false`. + +#### Example +```js +_.isUndefined(void 0); +// => true +``` + +* * * + + + + + + +### `_.keys(object)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L944 "View in source") [Ⓣ][1] + +Creates an array composed of the own enumerable property names of `object`. + +#### Arguments +1. `object` *(Object)*: The object to inspect. + +#### Returns +*(Array)*: Returns a new array of property names. + +#### Example +```js +_.keys({ 'one': 1, 'two': 2, 'three': 3 }); +// => ['one', 'two', 'three'] (order is not guaranteed) +``` + +* * * + + + + + + +### `_.merge(object [, source1, source2, ..., callback, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1916 "View in source") [Ⓣ][1] + +Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the destination object. Subsequent sources will overwrite propery assignments of previous sources. If a `callback` function is passed, it will be executed to produce the merged values of the destination and source properties. If `callback` returns `undefined`, merging will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. + +#### Arguments +1. `object` *(Object)*: The destination object. +2. `[source1, source2, ...]` *(Object)*: The source objects. +3. `[callback]` *(Function)*: The function to customize merging properties. +4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Object)*: Returns the destination object. + +#### Example +```js +var names = { + 'stooges': [ + { 'name': 'moe' }, + { 'name': 'larry' } + ] +}; + +var ages = { + 'stooges': [ + { 'age': 40 }, + { 'age': 50 } + ] +}; + +_.merge(names, ages); +// => { 'stooges': [{ 'name': 'moe', 'age': 40 }, { 'name': 'larry', 'age': 50 }] } + +var food = { + 'fruits': ['apple'], + 'vegetables': ['beet'] +}; + +var otherFood = { + 'fruits': ['banana'], + 'vegetables': ['carrot'] +}; + +_.merge(food, otherFood, function(a, b) { + return _.isArray(a) ? a.concat(b) : undefined; +}); +// => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot] } +``` + +* * * + + + + + + +### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2023 "View in source") [Ⓣ][1] + +Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. If a `callback` function is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. + +#### Arguments +1. `object` *(Object)*: The source object. +2. `callback|[prop1, prop2, ...]` *(Function|String)*: The properties to omit or the function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Object)*: Returns an object without the omitted properties. + +#### Example +```js +_.omit({ 'name': 'moe', 'age': 40 }, 'age'); +// => { 'name': 'moe' } + +_.omit({ 'name': 'moe', 'age': 40 }, function(value) { + return typeof value == 'number'; +}); +// => { 'name': 'moe' } +``` + +* * * + + + + + + +### `_.pairs(object)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2057 "View in source") [Ⓣ][1] + +Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. + +#### Arguments +1. `object` *(Object)*: The object to inspect. + +#### Returns +*(Array)*: Returns new array of key-value pairs. + +#### Example +```js +_.pairs({ 'moe': 30, 'larry': 40 }); +// => [['moe', 30], ['larry', 40]] (order is not guaranteed) +``` + +* * * + + + + + + +### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2095 "View in source") [Ⓣ][1] + +Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. If `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. + +#### Arguments +1. `object` *(Object)*: The source object. +2. `callback|[prop1, prop2, ...]` *(Array|Function|String)*: The function called per iteration or properties to pick, either as individual arguments or arrays. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Object)*: Returns an object composed of the picked properties. + +#### Example +```js +_.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name'); +// => { 'name': 'moe' } + +_.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { + return key.charAt(0) != '_'; +}); +// => { 'name': 'moe' } +``` + +* * * + + + + + + +### `_.values(object)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2132 "View in source") [Ⓣ][1] + +Creates an array composed of the own enumerable property values of `object`. + +#### Arguments +1. `object` *(Object)*: The object to inspect. + +#### Returns +*(Array)*: Returns a new array of property values. + +#### Example +```js +_.values({ 'one': 1, 'two': 2, 'three': 3 }); +// => [1, 2, 3] +``` + +* * * + + + + + + + + + +## `“Utilities†Methods` + + + +### `_.escape(string)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4457 "View in source") [Ⓣ][1] + +Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. + +#### Arguments +1. `string` *(String)*: The string to escape. + +#### Returns +*(String)*: Returns the escaped string. + +#### Example +```js +_.escape('Moe, Larry & Curly'); +// => 'Moe, Larry & Curly' +``` + +* * * + + + + + + +### `_.identity(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4475 "View in source") [Ⓣ][1] + +This function returns the first argument passed to it. + +#### Arguments +1. `value` *(Mixed)*: Any value. + +#### Returns +*(Mixed)*: Returns `value`. + +#### Example +```js +var moe = { 'name': 'moe' }; +moe === _.identity(moe); +// => true +``` + +* * * + + + + + + +### `_.mixin(object)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4501 "View in source") [Ⓣ][1] + +Adds functions properties of `object` to the `lodash` function and chainable wrapper. + +#### Arguments +1. `object` *(Object)*: The object of function properties to add to `lodash`. + +#### Example +```js +_.mixin({ + 'capitalize': function(string) { + return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); + } +}); + +_.capitalize('moe'); +// => 'Moe' + +_('moe').capitalize(); +// => 'Moe' +``` + +* * * + + + + + + +### `_.noConflict()` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4525 "View in source") [Ⓣ][1] + +Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. + +#### Returns +*(Function)*: Returns the `lodash` function. + +#### Example +```js +var lodash = _.noConflict(); +``` + +* * * + + + + + + +### `_.random([min=0, max=1])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4548 "View in source") [Ⓣ][1] + +Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. + +#### Arguments +1. `[min=0]` *(Number)*: The minimum possible value. +2. `[max=1]` *(Number)*: The maximum possible value. + +#### Returns +*(Number)*: Returns a random number. + +#### Example +```js +_.random(0, 5); +// => a number between 0 and 5 + +_.random(5); +// => also a number between 0 and 5 +``` + +* * * + + + + + + +### `_.result(object, property)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4586 "View in source") [Ⓣ][1] + +Resolves the value of `property` on `object`. If `property` is a function, it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. + +#### Arguments +1. `object` *(Object)*: The object to inspect. +2. `property` *(String)*: The property to get the value of. + +#### Returns +*(Mixed)*: Returns the resolved value. + +#### Example +```js +var object = { + 'cheese': 'crumpets', + 'stuff': function() { + return 'nonsense'; + } +}; + +_.result(object, 'cheese'); +// => 'crumpets' + +_.result(object, 'stuff'); +// => 'nonsense' +``` + +* * * + + + + + + +### `_.template(text, data, options)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4674 "View in source") [Ⓣ][1] + +A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. + +Note: In the development build, `_.template` utilizes sourceURLs for easier debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl + +Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp` build and using precompiled templates, or loading Lo-Dash in a sandbox. + +For more information on precompiling templates see:
+http://lodash.com/#custom-builds + +For more information on Chrome extension sandboxes see:
+http://developer.chrome.com/stable/extensions/sandboxingEval.html + +#### Arguments +1. `text` *(String)*: The template text. +2. `data` *(Obect)*: The data object used to populate the text. +3. `options` *(Object)*: The options object. escape - The "escape" delimiter regexp. evaluate - The "evaluate" delimiter regexp. interpolate - The "interpolate" delimiter regexp. sourceURL - The sourceURL of the template's compiled source. variable - The data object variable name. + +#### Returns +*(Function, String)*: Returns a compiled function when no `data` object is given, else it returns the interpolated text. + +#### Example +```js +// using a compiled template +var compiled = _.template('hello <%= name %>'); +compiled({ 'name': 'moe' }); +// => 'hello moe' + +var list = '<% _.forEach(people, function(name) { %>
  • <%= name %>
  • <% }); %>'; +_.template(list, { 'people': ['moe', 'larry'] }); +// => '
  • moe
  • larry
  • ' + +// using the "escape" delimiter to escape HTML in data property values +_.template('<%- value %>', { 'value': '\n```\n\nUsing [`npm`](http://npmjs.org/):\n\n```bash\nnpm install lodash\n\nnpm install -g lodash\nnpm link lodash\n```\n\nTo avoid potential issues, update `npm` before installing Lo-Dash:\n\n```bash\nnpm install npm -g\n```\n\nIn [Node.js](http://nodejs.org/) and [RingoJS v0.8.0+](http://ringojs.org/):\n\n```js\nvar _ = require('lodash');\n\n// or as a drop-in replacement for Underscore\nvar _ = require('lodash/lodash.underscore');\n```\n\n**Note:** If Lo-Dash is installed globally, run [`npm link lodash`](http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/) in your project’s root directory before requiring it.\n\nIn [RingoJS v0.7.0-](http://ringojs.org/):\n\n```js\nvar _ = require('lodash')._;\n```\n\nIn [Rhino](http://www.mozilla.org/rhino/):\n\n```js\nload('lodash.js');\n```\n\nIn an AMD loader like [RequireJS](http://requirejs.org/):\n\n```js\nrequire({\n 'paths': {\n 'underscore': 'path/to/lodash'\n }\n},\n['underscore'], function(_) {\n console.log(_.VERSION);\n});\n```\n\n## Release Notes\n\n### v1.0.1\n\n * Add support for specifying source map URLs in `-p`/`--source-map` build options\n * Ensured the second argument passed to `_.assign` is not treated as a `callback`\n * Ensured `-p`/`--source-map` build options correctly set the `sourceMappingURL`\n * Made `-p`/`--source-map` build options set source map *“sourcesâ€* keys based on the builds performed\n * Made `_.defer` use `setImmediate`, in Node.js, when available\n * Made `_.where` search arrays for values regardless of their index position\n * Removed dead code from `_.template`\n\nThe full changelog is available [here](https://github.com/bestiejs/lodash/wiki/Changelog).\n\n## BestieJS\n\nLo-Dash is part of the BestieJS *“Best in Classâ€* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation.\n\n## Author\n\n* [John-David Dalton](http://allyoucanleet.com/)\n [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton \"Follow @jdalton on Twitter\")\n\n## Contributors\n\n* [Kit Cambridge](http://kitcambridge.github.com/)\n [![twitter/kitcambridge](http://gravatar.com/avatar/6662a1d02f351b5ef2f8b4d815804661?s=70)](https://twitter.com/kitcambridge \"Follow @kitcambridge on Twitter\")\n* [Mathias Bynens](http://mathiasbynens.be/)\n [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias \"Follow @mathias on Twitter\")\n", + "readmeFilename": "README.md", + "_id": "lodash@1.0.1", + "dist": { + "shasum": "bbb6614d7fe68155d6f1cf8b3e2fb65b010dfaed" + }, + "_from": "lodash@~1.0.1", + "_resolved": "https://registry.npmjs.org/lodash/-/lodash-1.0.1.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/test/template/a.jst b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/test/template/a.jst new file mode 100644 index 00000000..cca541d8 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/test/template/a.jst @@ -0,0 +1,3 @@ +
      +<% _.forEach(people, function(name) { %>
    • <%- name %>
    • <% }); %> +
    \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/test/template/b.jst b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/test/template/b.jst new file mode 100644 index 00000000..cad081d1 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/test/template/b.jst @@ -0,0 +1 @@ +<% print("Hello " + epithet); %>. \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/test/template/c.jst b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/test/template/c.jst new file mode 100644 index 00000000..f9267990 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/test/template/c.jst @@ -0,0 +1 @@ +Hello ${ name }! \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/test/template/d.tpl b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/test/template/d.tpl new file mode 100644 index 00000000..c7a43bc1 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/test/template/d.tpl @@ -0,0 +1 @@ +Hello {{ name }}! \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/qunit-clib/LICENSE.txt b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/qunit-clib/LICENSE.txt new file mode 100644 index 00000000..a7501f98 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/qunit-clib/LICENSE.txt @@ -0,0 +1,20 @@ +Copyright 2011-2013 John-David Dalton + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/qunit-clib/README.md b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/qunit-clib/README.md new file mode 100644 index 00000000..7c2edfa8 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/qunit-clib/README.md @@ -0,0 +1,58 @@ +# QUnit CLIB v1.2.0 +## command-line interface boilerplate + +QUnit CLIB helps extend QUnit's CLI support to many common CLI environments. + +## Screenshot + +![QUnit CLIB brings QUnit to your favorite shell.](http://i.imgur.com/jpu9l.png) + +## Support + +QUnit CLIB has been tested in at least Node.js 0.4.8-0.8.19, Narwhal v0.3.2, PhantomJS 1.8.1, RingoJS v0.9, and Rhino v1.7RC5. + +## Usage + +```js +(function(window) { + + // use a single "load" function + var load = typeof require == 'function' ? require : window.load; + + // load QUnit and CLIB if needed + var QUnit = + window.QUnit || ( + window.addEventListener || (window.addEventListener = Function.prototype), + window.setTimeout || (window.setTimeout = Function.prototype), + window.QUnit = load('path/to/qunit.js') || window.QUnit, + load('path/to/qunit-clib.js'), + window.addEventListener === Function.prototype && delete window.addEventListener, + window.QUnit + ); + + // explicitly call `QUnit.module()` instead of `module()` + // in case we are in a CLI environment + QUnit.module('A Test Module'); + + test('A Test', function() { + // ... + }); + + // must call `QUnit.start()` if using QUnit < 1.3.0 with Node.js or any + // version of QUnit with Narwhal, PhantomJS, Rhino, or RingoJS + if (!window.document) { + QUnit.start(); + } +}(typeof global == 'object' && global || this)); +``` + +## Footnotes + + 1. QUnit v1.3.0 does not work with Narwhal or Ringo < v0.8.0 + + 2. Rhino v1.7RC4 does not support timeout fallbacks `clearTimeout` and `setTimeout` + +## Author + +* [John-David Dalton](http://allyoucanleet.com/) + [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton "Follow @jdalton on Twitter") diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/qunit/README.md b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/qunit/README.md new file mode 100644 index 00000000..6ab73f57 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/qunit/README.md @@ -0,0 +1,62 @@ +[QUnit](http://qunitjs.com) - A JavaScript Unit Testing framework. +================================ + +QUnit is a powerful, easy-to-use, JavaScript test suite. It's used by the jQuery +project to test its code and plugins but is capable of testing any generic +JavaScript code (and even capable of testing JavaScript code on the server-side). + +QUnit is especially useful for regression testing: Whenever a bug is reported, +write a test that asserts the existence of that particular bug. Then fix it and +commit both. Every time you work on the code again, run the tests. If the bug +comes up again - a regression - you'll spot it immediately and know how to fix +it, because you know what code you just changed. + +Having good unit test coverage makes safe refactoring easy and cheap. You can +run the tests after each small refactoring step and always know what change +broke something. + +QUnit is similar to other unit testing frameworks like JUnit, but makes use of +the features JavaScript provides and helps with testing code in the browser, e.g. +with its stop/start facilities for testing asynchronous code. + +If you are interested in helping developing QUnit, you are in the right place. +For related discussions, visit the +[QUnit and Testing forum](http://forum.jquery.com/qunit-and-testing). + +Development +----------- + +To submit patches, fork the repository, create a branch for the change. Then implement +the change, run `grunt` to lint and test it, then commit, push and create a pull request. + +Include some background for the change in the commit message and `Fixes #nnn`, referring +to the issue number you're addressing. + +To run `grunt`, you need `node` and `npm`, then `npm install grunt -g`. That gives you a global +grunt binary. For additional grunt tasks, also run `npm install`. + +Releases +-------- + +Install git-extras and run `git changelog` to update History.md. +Update qunit/qunit.js|css and package.json to the release version, commit and +tag, update them again to the next version, commit and push commits and tags +(`git push --tags origin master`). + +Put the 'v' in front of the tag, e.g. `v1.8.0`. Clean up the changelog, removing merge commits +or whitespace cleanups. + +To upload to code.jquery.com (replace $version accordingly), ssh to code.origin.jquery.com: + + cp qunit/qunit.js /var/www/html/code.jquery.com/qunit/qunit-$version.js + cp qunit/qunit.css /var/www/html/code.jquery.com/qunit/qunit-$version.css + +Then update /var/www/html/code.jquery.com/index.html and purge it with: + + curl -s http://code.origin.jquery.com/?reload + +Update web-base-template to link to those files for qunitjs.com. + +Publish to npm via + + npm publish diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/README.md b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/README.md new file mode 100644 index 00000000..7cfe3bbc --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/README.md @@ -0,0 +1,50 @@ +# node-tar + +Tar for Node.js. + +## Goals of this project + +1. Be able to parse and reasonably extract the contents of any tar file + created by any program that creates tar files, period. + + At least, this includes every version of: + + * bsdtar + * gnutar + * solaris posix tar + * Joerg Schilling's star ("Schilly tar") + +2. Create tar files that can be extracted by any of the following tar + programs: + + * bsdtar/libarchive version 2.6.2 + * gnutar 1.15 and above + * SunOS Posix tar + * Joerg Schilling's star ("Schilly tar") + +3. 100% test coverage. Speed is important. Correctness is slightly + more important. + +4. Create the kind of tar interface that Node users would want to use. + +5. Satisfy npm's needs for a portable tar implementation with a + JavaScript interface. + +6. No excuses. No complaining. No tolerance for failure. + +## But isn't there already a tar.js? + +Yes, there are a few. This one is going to be better, and it will be +fanatically maintained, because npm will depend on it. + +That's why I need to write it from scratch. Creating and extracting +tarballs is such a large part of what npm does, I simply can't have it +be a black box any longer. + +## Didn't you have something already? Where'd it go? + +It's in the "old" folder. It's not functional. Don't use it. + +It was a useful exploration to learn the issues involved, but like most +software of any reasonable complexity, node-tar won't be useful until +it's been written at least 3 times. diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/block-stream/LICENCE b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/block-stream/LICENCE new file mode 100644 index 00000000..74489e2e --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/block-stream/LICENCE @@ -0,0 +1,25 @@ +Copyright (c) Isaac Z. Schlueter +All rights reserved. + +The BSD License + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/block-stream/README.md b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/block-stream/README.md new file mode 100644 index 00000000..c16e9c46 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/block-stream/README.md @@ -0,0 +1,14 @@ +# block-stream + +A stream of blocks. + +Write data into it, and it'll output data in buffer blocks the size you +specify, padding with zeroes if necessary. + +```javascript +var block = new BlockStream(512) +fs.createReadStream("some-file").pipe(block) +block.pipe(fs.createWriteStream("block-file")) +``` + +When `.end()` or `.flush()` is called, it'll pad the block with zeroes. diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/fstream/LICENCE b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/fstream/LICENCE new file mode 100644 index 00000000..74489e2e --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/fstream/LICENCE @@ -0,0 +1,25 @@ +Copyright (c) Isaac Z. Schlueter +All rights reserved. + +The BSD License + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/fstream/README.md b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/fstream/README.md new file mode 100644 index 00000000..9d8cb77e --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/fstream/README.md @@ -0,0 +1,76 @@ +Like FS streams, but with stat on them, and supporting directories and +symbolic links, as well as normal files. Also, you can use this to set +the stats on a file, even if you don't change its contents, or to create +a symlink, etc. + +So, for example, you can "write" a directory, and it'll call `mkdir`. You +can specify a uid and gid, and it'll call `chown`. You can specify a +`mtime` and `atime`, and it'll call `utimes`. You can call it a symlink +and provide a `linkpath` and it'll call `symlink`. + +Note that it won't automatically resolve symbolic links. So, if you +call `fstream.Reader('/some/symlink')` then you'll get an object +that stats and then ends immediately (since it has no data). To follow +symbolic links, do this: `fstream.Reader({path:'/some/symlink', follow: +true })`. + +There are various checks to make sure that the bytes emitted are the +same as the intended size, if the size is set. + +## Examples + +```javascript +fstream + .Writer({ path: "path/to/file" + , mode: 0755 + , size: 6 + }) + .write("hello\n") + .end() +``` + +This will create the directories if they're missing, and then write +`hello\n` into the file, chmod it to 0755, and assert that 6 bytes have +been written when it's done. + +```javascript +fstream + .Writer({ path: "path/to/file" + , mode: 0755 + , size: 6 + , flags: "a" + }) + .write("hello\n") + .end() +``` + +You can pass flags in, if you want to append to a file. + +```javascript +fstream + .Writer({ path: "path/to/symlink" + , linkpath: "./file" + , SymbolicLink: true + , mode: "0755" // octal strings supported + }) + .end() +``` + +If isSymbolicLink is a function, it'll be called, and if it returns +true, then it'll treat it as a symlink. If it's not a function, then +any truish value will make a symlink, or you can set `type: +'SymbolicLink'`, which does the same thing. + +Note that the linkpath is relative to the symbolic link location, not +the parent dir or cwd. + +```javascript +fstream + .Reader("path/to/dir") + .pipe(fstream.Writer("path/to/other/dir")) +``` + +This will do like `cp -Rp path/to/dir path/to/other/dir`. If the other +dir exists and isn't a directory, then it'll emit an error. It'll also +set the uid, gid, mode, etc. to be identical. In this way, it's more +like `rsync -a` than simply a copy. diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/graceful-fs/LICENSE b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/graceful-fs/LICENSE new file mode 100644 index 00000000..05a40109 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/graceful-fs/LICENSE @@ -0,0 +1,23 @@ +Copyright 2009, 2010, 2011 Isaac Z. Schlueter. +All rights reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/graceful-fs/README.md b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/graceful-fs/README.md new file mode 100644 index 00000000..7d2e681e --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/graceful-fs/README.md @@ -0,0 +1,5 @@ +Just like node's `fs` module, but it does an incremental back-off when +EMFILE is encountered. + +Useful in asynchronous situations where one needs to try to open lots +and lots of files. diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/inherits/README.md b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/inherits/README.md new file mode 100644 index 00000000..b2beaed9 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/inherits/README.md @@ -0,0 +1,51 @@ +A dead simple way to do inheritance in JS. + + var inherits = require("inherits") + + function Animal () { + this.alive = true + } + Animal.prototype.say = function (what) { + console.log(what) + } + + inherits(Dog, Animal) + function Dog () { + Dog.super.apply(this) + } + Dog.prototype.sniff = function () { + this.say("sniff sniff") + } + Dog.prototype.bark = function () { + this.say("woof woof") + } + + inherits(Chihuahua, Dog) + function Chihuahua () { + Chihuahua.super.apply(this) + } + Chihuahua.prototype.bark = function () { + this.say("yip yip") + } + + // also works + function Cat () { + Cat.super.apply(this) + } + Cat.prototype.hiss = function () { + this.say("CHSKKSS!!") + } + inherits(Cat, Animal, { + meow: function () { this.say("miao miao") } + }) + Cat.prototype.purr = function () { + this.say("purr purr") + } + + + var c = new Chihuahua + assert(c instanceof Chihuahua) + assert(c instanceof Dog) + assert(c instanceof Animal) + +The actual function is laughably small. 10-lines small. diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/mkdirp/LICENSE b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/mkdirp/LICENSE new file mode 100644 index 00000000..432d1aeb --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/mkdirp/LICENSE @@ -0,0 +1,21 @@ +Copyright 2010 James Halliday (mail@substack.net) + +This project is free software released under the MIT/X11 license: + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/mkdirp/README.markdown b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/mkdirp/README.markdown new file mode 100644 index 00000000..40de04f7 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/mkdirp/README.markdown @@ -0,0 +1,61 @@ +mkdirp +====== + +Like `mkdir -p`, but in node.js! + +[![build status](https://secure.travis-ci.org/substack/node-mkdirp.png)](http://travis-ci.org/substack/node-mkdirp) + +example +======= + +pow.js +------ + var mkdirp = require('mkdirp'); + + mkdirp('/tmp/foo/bar/baz', function (err) { + if (err) console.error(err) + else console.log('pow!') + }); + +Output + pow! + +And now /tmp/foo/bar/baz exists, huzzah! + +methods +======= + +var mkdirp = require('mkdirp'); + +mkdirp(dir, mode, cb) +--------------------- + +Create a new directory and any necessary subdirectories at `dir` with octal +permission string `mode`. + +If `mode` isn't specified, it defaults to `0777 & (~process.umask())`. + +`cb(err, made)` fires with the error or the first directory `made` +that had to be created, if any. + +mkdirp.sync(dir, mode) +---------------------- + +Synchronously create a new directory and any necessary subdirectories at `dir` +with octal permission string `mode`. + +If `mode` isn't specified, it defaults to `0777 & (~process.umask())`. + +Returns the first directory that had to be created, if any. + +install +======= + +With [npm](http://npmjs.org) do: + + npm install mkdirp + +license +======= + +MIT/X11 diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/rimraf/AUTHORS b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/rimraf/AUTHORS new file mode 100644 index 00000000..247b7543 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/rimraf/AUTHORS @@ -0,0 +1,6 @@ +# Authors sorted by whether or not they're me. +Isaac Z. Schlueter (http://blog.izs.me) +Wayne Larsen (http://github.com/wvl) +ritch +Marcel Laverdet +Yosef Dinerstein diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/rimraf/LICENSE b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/rimraf/LICENSE new file mode 100644 index 00000000..05a40109 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/rimraf/LICENSE @@ -0,0 +1,23 @@ +Copyright 2009, 2010, 2011 Isaac Z. Schlueter. +All rights reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/rimraf/README.md b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/rimraf/README.md new file mode 100644 index 00000000..96ce9b2a --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/tar/vendor/rimraf/README.md @@ -0,0 +1,21 @@ +A `rm -rf` for node. + +Install with `npm install rimraf`, or just drop rimraf.js somewhere. + +## API + +`rimraf(f, callback)` + +The callback will be called with an error if there is one. Certain +errors are handled for you: + +* `EBUSY` - rimraf will back off a maximum of opts.maxBusyTries times + before giving up. +* `EMFILE` - If too many file descriptors get opened, rimraf will + patiently wait until more become available. + + +## rimraf.sync + +It can remove stuff synchronously, too. But that's not so good. Use +the async API. It's better. diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/underscore/LICENSE b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/underscore/LICENSE new file mode 100644 index 00000000..0d8dbe40 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/underscore/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2009-2013 Jeremy Ashkenas, DocumentCloud + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/underscore/README.md b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/underscore/README.md new file mode 100644 index 00000000..b1f3e50a --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/node_modules/lodash/vendor/underscore/README.md @@ -0,0 +1,19 @@ + __ + /\ \ __ + __ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____ + /\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\ + \ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\ + \ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/ + \/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/ + \ \____/ + \/___/ + +Underscore.js is a utility-belt library for JavaScript that provides +support for the usual functional suspects (each, map, reduce, filter...) +without extending any core JavaScript objects. + +For Docs, License, Tests, and pre-packed downloads, see: +http://underscorejs.org + +Many thanks to our contributors: +https://github.com/documentcloud/underscore/contributors diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/package.json b/Phaser/node_modules/grunt/node_modules/findup-sync/package.json new file mode 100644 index 00000000..e6210ecc --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/findup-sync/package.json @@ -0,0 +1,52 @@ +{ + "name": "findup-sync", + "description": "Find the first file matching a given pattern in the current directory or the nearest ancestor directory.", + "version": "0.1.2", + "homepage": "https://github.com/cowboy/node-findup-sync", + "author": { + "name": "\"Cowboy\" Ben Alman", + "url": "http://benalman.com/" + }, + "repository": { + "type": "git", + "url": "git://github.com/cowboy/node-findup-sync.git" + }, + "bugs": { + "url": "https://github.com/cowboy/node-findup-sync/issues" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://github.com/cowboy/node-findup-sync/blob/master/LICENSE-MIT" + } + ], + "main": "lib/findup-sync", + "engines": { + "node": ">= 0.6.0" + }, + "scripts": { + "test": "grunt nodeunit" + }, + "dependencies": { + "glob": "~3.1.21", + "lodash": "~1.0.1" + }, + "devDependencies": { + "grunt": "~0.4.0", + "grunt-contrib-jshint": "~0.2.0", + "grunt-contrib-nodeunit": "~0.1.2" + }, + "keywords": [ + "find", + "glob", + "file" + ], + "readme": "# findup-sync\n\nFind the first file matching a given pattern in the current directory or the nearest ancestor directory.\n\n## Getting Started\nInstall the module with: `npm install findup-sync`\n\n```js\nvar findup = require('findup-sync');\n\n// Start looking in the CWD.\nvar filepath1 = findup('{a,b}*.txt');\n\n// Start looking somewhere else, and ignore case (probably a good idea).\nvar filepath2 = findup('{a,b}*.txt', {cwd: '/some/path', nocase: true});\n```\n\n## Usage\n\n```js\nfindup(patternOrPatterns [, minimatchOptions])\n```\n\n### patternOrPatterns\nType: `String` or `Array` \nDefault: none\n\nOne or more wildcard glob patterns. Or just filenames.\n\n### minimatchOptions\nType: `Object` \nDefault: `{}`\n\nOptions to be passed to [minimatch](https://github.com/isaacs/minimatch).\n\nNote that if you want to start in a different directory than the current working directory, specify a `cwd` property here.\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n## Release History\n2013-03-08 - v0.1.2 - Updated dependencies. Fixed a Node 0.9.x bug. Updated unit tests to work cross-platform. \n2012-11-15 - v0.1.1 - Now works without an options object. \n2012-11-01 - v0.1.0 - Initial release.\n", + "readmeFilename": "README.md", + "_id": "findup-sync@0.1.2", + "dist": { + "shasum": "ca92407e195dd57f027db19332844c783d94312c" + }, + "_from": "findup-sync@~0.1.0", + "_resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.1.2.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/test/fixtures/a.txt b/Phaser/node_modules/grunt/node_modules/findup-sync/test/fixtures/a.txt new file mode 100644 index 00000000..e69de29b diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/test/fixtures/a/b/bar.txt b/Phaser/node_modules/grunt/node_modules/findup-sync/test/fixtures/a/b/bar.txt new file mode 100644 index 00000000..e69de29b diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/test/fixtures/a/foo.txt b/Phaser/node_modules/grunt/node_modules/findup-sync/test/fixtures/a/foo.txt new file mode 100644 index 00000000..e69de29b diff --git a/Phaser/node_modules/grunt/node_modules/findup-sync/test/fixtures/aaa.txt b/Phaser/node_modules/grunt/node_modules/findup-sync/test/fixtures/aaa.txt new file mode 100644 index 00000000..e69de29b diff --git a/Phaser/node_modules/grunt/node_modules/glob/.npmignore b/Phaser/node_modules/grunt/node_modules/glob/.npmignore new file mode 100644 index 00000000..2af4b71c --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/glob/.npmignore @@ -0,0 +1,2 @@ +.*.swp +test/a/ diff --git a/Phaser/node_modules/grunt/node_modules/glob/.travis.yml b/Phaser/node_modules/grunt/node_modules/glob/.travis.yml new file mode 100644 index 00000000..baa0031d --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/glob/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - 0.8 diff --git a/Phaser/node_modules/grunt/node_modules/glob/LICENSE b/Phaser/node_modules/grunt/node_modules/glob/LICENSE new file mode 100644 index 00000000..0c44ae71 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/glob/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) Isaac Z. Schlueter ("Author") +All rights reserved. + +The BSD License + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Phaser/node_modules/grunt/node_modules/glob/README.md b/Phaser/node_modules/grunt/node_modules/glob/README.md new file mode 100644 index 00000000..6e27df62 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/glob/README.md @@ -0,0 +1,233 @@ +# Glob + +This is a glob implementation in JavaScript. It uses the `minimatch` +library to do its matching. + +## Attention: node-glob users! + +The API has changed dramatically between 2.x and 3.x. This library is +now 100% JavaScript, and the integer flags have been replaced with an +options object. + +Also, there's an event emitter class, proper tests, and all the other +things you've come to expect from node modules. + +And best of all, no compilation! + +## Usage + +```javascript +var glob = require("glob") + +// options is optional +glob("**/*.js", options, function (er, files) { + // files is an array of filenames. + // If the `nonull` option is set, and nothing + // was found, then files is ["**/*.js"] + // er is an error object or null. +}) +``` + +## Features + +Please see the [minimatch +documentation](https://github.com/isaacs/minimatch) for more details. + +Supports these glob features: + +* Brace Expansion +* Extended glob matching +* "Globstar" `**` matching + +See: + +* `man sh` +* `man bash` +* `man 3 fnmatch` +* `man 5 gitignore` +* [minimatch documentation](https://github.com/isaacs/minimatch) + +## glob(pattern, [options], cb) + +* `pattern` {String} Pattern to be matched +* `options` {Object} +* `cb` {Function} + * `err` {Error | null} + * `matches` {Array} filenames found matching the pattern + +Perform an asynchronous glob search. + +## glob.sync(pattern, [options] + +* `pattern` {String} Pattern to be matched +* `options` {Object} +* return: {Array} filenames found matching the pattern + +Perform a synchronous glob search. + +## Class: glob.Glob + +Create a Glob object by instanting the `glob.Glob` class. + +```javascript +var Glob = require("glob").Glob +var mg = new Glob(pattern, options, cb) +``` + +It's an EventEmitter, and starts walking the filesystem to find matches +immediately. + +### new glob.Glob(pattern, [options], [cb]) + +* `pattern` {String} pattern to search for +* `options` {Object} +* `cb` {Function} Called when an error occurs, or matches are found + * `err` {Error | null} + * `matches` {Array} filenames found matching the pattern + +Note that if the `sync` flag is set in the options, then matches will +be immediately available on the `g.found` member. + +### Properties + +* `minimatch` The minimatch object that the glob uses. +* `options` The options object passed in. +* `error` The error encountered. When an error is encountered, the + glob object is in an undefined state, and should be discarded. +* `aborted` Boolean which is set to true when calling `abort()`. There + is no way at this time to continue a glob search after aborting, but + you can re-use the statCache to avoid having to duplicate syscalls. + +### Events + +* `end` When the matching is finished, this is emitted with all the + matches found. If the `nonull` option is set, and no match was found, + then the `matches` list contains the original pattern. The matches + are sorted, unless the `nosort` flag is set. +* `match` Every time a match is found, this is emitted with the matched. +* `error` Emitted when an unexpected error is encountered, or whenever + any fs error occurs if `options.strict` is set. +* `abort` When `abort()` is called, this event is raised. + +### Methods + +* `abort` Stop the search. + +### Options + +All the options that can be passed to Minimatch can also be passed to +Glob to change pattern matching behavior. Also, some have been added, +or have glob-specific ramifications. + +All options are false by default, unless otherwise noted. + +All options are added to the glob object, as well. + +* `cwd` The current working directory in which to search. Defaults + to `process.cwd()`. +* `root` The place where patterns starting with `/` will be mounted + onto. Defaults to `path.resolve(options.cwd, "/")` (`/` on Unix + systems, and `C:\` or some such on Windows.) +* `nomount` By default, a pattern starting with a forward-slash will be + "mounted" onto the root setting, so that a valid filesystem path is + returned. Set this flag to disable that behavior. +* `mark` Add a `/` character to directory matches. Note that this + requires additional stat calls. +* `nosort` Don't sort the results. +* `stat` Set to true to stat *all* results. This reduces performance + somewhat, and is completely unnecessary, unless `readdir` is presumed + to be an untrustworthy indicator of file existence. It will cause + ELOOP to be triggered one level sooner in the case of cyclical + symbolic links. +* `silent` When an unusual error is encountered + when attempting to read a directory, a warning will be printed to + stderr. Set the `silent` option to true to suppress these warnings. +* `strict` When an unusual error is encountered + when attempting to read a directory, the process will just continue on + in search of other matches. Set the `strict` option to raise an error + in these cases. +* `statCache` A cache of results of filesystem information, to prevent + unnecessary stat calls. While it should not normally be necessary to + set this, you may pass the statCache from one glob() call to the + options object of another, if you know that the filesystem will not + change between calls. (See "Race Conditions" below.) +* `sync` Perform a synchronous glob search. +* `nounique` In some cases, brace-expanded patterns can result in the + same file showing up multiple times in the result set. By default, + this implementation prevents duplicates in the result set. + Set this flag to disable that behavior. +* `nonull` Set to never return an empty set, instead returning a set + containing the pattern itself. This is the default in glob(3). +* `nocase` Perform a case-insensitive match. Note that case-insensitive + filesystems will sometimes result in glob returning results that are + case-insensitively matched anyway, since readdir and stat will not + raise an error. +* `debug` Set to enable debug logging in minimatch and glob. +* `globDebug` Set to enable debug logging in glob, but not minimatch. + +## Comparisons to other fnmatch/glob implementations + +While strict compliance with the existing standards is a worthwhile +goal, some discrepancies exist between node-glob and other +implementations, and are intentional. + +If the pattern starts with a `!` character, then it is negated. Set the +`nonegate` flag to suppress this behavior, and treat leading `!` +characters normally. This is perhaps relevant if you wish to start the +pattern with a negative extglob pattern like `!(a|B)`. Multiple `!` +characters at the start of a pattern will negate the pattern multiple +times. + +If a pattern starts with `#`, then it is treated as a comment, and +will not match anything. Use `\#` to match a literal `#` at the +start of a line, or set the `nocomment` flag to suppress this behavior. + +The double-star character `**` is supported by default, unless the +`noglobstar` flag is set. This is supported in the manner of bsdglob +and bash 4.1, where `**` only has special significance if it is the only +thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but +`a/**b` will not. **Note that this is different from the way that `**` is +handled by ruby's `Dir` class.** + +If an escaped pattern has no matches, and the `nonull` flag is set, +then glob returns the pattern as-provided, rather than +interpreting the character escapes. For example, +`glob.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than +`"*a?"`. This is akin to setting the `nullglob` option in bash, except +that it does not resolve escaped pattern characters. + +If brace expansion is not disabled, then it is performed before any +other interpretation of the glob pattern. Thus, a pattern like +`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded +**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are +checked for validity. Since those two are valid, matching proceeds. + +## Windows + +**Please only use forward-slashes in glob expressions.** + +Though windows uses either `/` or `\` as its path separator, only `/` +characters are used by this glob implementation. You must use +forward-slashes **only** in glob expressions. Back-slashes will always +be interpreted as escape characters, not path separators. + +Results from absolute patterns such as `/foo/*` are mounted onto the +root setting using `path.join`. On windows, this will by default result +in `/foo/*` matching `C:\foo\bar.txt`. + +## Race Conditions + +Glob searching, by its very nature, is susceptible to race conditions, +since it relies on directory walking and such. + +As a result, it is possible that a file that exists when glob looks for +it may have been deleted or modified by the time it returns the result. + +As part of its internal implementation, this program caches all stat +and readdir calls that it makes, in order to cut down on system +overhead. However, this also makes it even more susceptible to races, +especially if the statCache object is reused between glob calls. + +Users are thus advised not to use a glob result as a +guarantee of filesystem state in the face of rapid changes. +For the vast majority of operations, this is never a problem. diff --git a/Phaser/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/.npmignore b/Phaser/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/.npmignore new file mode 100644 index 00000000..c2658d7d --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/.npmignore @@ -0,0 +1 @@ +node_modules/ diff --git a/Phaser/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/LICENSE b/Phaser/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/LICENSE new file mode 100644 index 00000000..05a40109 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/LICENSE @@ -0,0 +1,23 @@ +Copyright 2009, 2010, 2011 Isaac Z. Schlueter. +All rights reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/README.md b/Phaser/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/README.md new file mode 100644 index 00000000..7d2e681e --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/README.md @@ -0,0 +1,5 @@ +Just like node's `fs` module, but it does an incremental back-off when +EMFILE is encountered. + +Useful in asynchronous situations where one needs to try to open lots +and lots of files. diff --git a/Phaser/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/package.json b/Phaser/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/package.json new file mode 100644 index 00000000..a798ef13 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/glob/node_modules/graceful-fs/package.json @@ -0,0 +1,40 @@ +{ + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me" + }, + "name": "graceful-fs", + "description": "fs monkey-patching to avoid EMFILE and other problems", + "version": "1.2.0", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/node-graceful-fs.git" + }, + "main": "graceful-fs.js", + "engines": { + "node": ">=0.4.0" + }, + "directories": { + "test": "test" + }, + "scripts": { + "test": "tap test/*.js" + }, + "keywords": [ + "fs", + "EMFILE", + "error", + "handling", + "monkeypatch" + ], + "license": "BSD", + "readme": "Just like node's `fs` module, but it does an incremental back-off when\nEMFILE is encountered.\n\nUseful in asynchronous situations where one needs to try to open lots\nand lots of files.\n", + "readmeFilename": "README.md", + "_id": "graceful-fs@1.2.0", + "dist": { + "shasum": "3e88cb0b86a44728092d4a9ecea898b7e1d7def5" + }, + "_from": "graceful-fs@~1.2.0", + "_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.0.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/glob/node_modules/inherits/README.md b/Phaser/node_modules/grunt/node_modules/glob/node_modules/inherits/README.md new file mode 100644 index 00000000..b2beaed9 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/glob/node_modules/inherits/README.md @@ -0,0 +1,51 @@ +A dead simple way to do inheritance in JS. + + var inherits = require("inherits") + + function Animal () { + this.alive = true + } + Animal.prototype.say = function (what) { + console.log(what) + } + + inherits(Dog, Animal) + function Dog () { + Dog.super.apply(this) + } + Dog.prototype.sniff = function () { + this.say("sniff sniff") + } + Dog.prototype.bark = function () { + this.say("woof woof") + } + + inherits(Chihuahua, Dog) + function Chihuahua () { + Chihuahua.super.apply(this) + } + Chihuahua.prototype.bark = function () { + this.say("yip yip") + } + + // also works + function Cat () { + Cat.super.apply(this) + } + Cat.prototype.hiss = function () { + this.say("CHSKKSS!!") + } + inherits(Cat, Animal, { + meow: function () { this.say("miao miao") } + }) + Cat.prototype.purr = function () { + this.say("purr purr") + } + + + var c = new Chihuahua + assert(c instanceof Chihuahua) + assert(c instanceof Dog) + assert(c instanceof Animal) + +The actual function is laughably small. 10-lines small. diff --git a/Phaser/node_modules/grunt/node_modules/glob/node_modules/inherits/package.json b/Phaser/node_modules/grunt/node_modules/glob/node_modules/inherits/package.json new file mode 100644 index 00000000..a9521755 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/glob/node_modules/inherits/package.json @@ -0,0 +1,30 @@ +{ + "name": "inherits", + "description": "A tiny simple way to do classic inheritance in js", + "version": "1.0.0", + "keywords": [ + "inheritance", + "class", + "klass", + "oop", + "object-oriented" + ], + "main": "./inherits.js", + "repository": { + "type": "git", + "url": "https://github.com/isaacs/inherits" + }, + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "readme": "A dead simple way to do inheritance in JS.\n\n var inherits = require(\"inherits\")\n\n function Animal () {\n this.alive = true\n }\n Animal.prototype.say = function (what) {\n console.log(what)\n }\n\n inherits(Dog, Animal)\n function Dog () {\n Dog.super.apply(this)\n }\n Dog.prototype.sniff = function () {\n this.say(\"sniff sniff\")\n }\n Dog.prototype.bark = function () {\n this.say(\"woof woof\")\n }\n\n inherits(Chihuahua, Dog)\n function Chihuahua () {\n Chihuahua.super.apply(this)\n }\n Chihuahua.prototype.bark = function () {\n this.say(\"yip yip\")\n }\n\n // also works\n function Cat () {\n Cat.super.apply(this)\n }\n Cat.prototype.hiss = function () {\n this.say(\"CHSKKSS!!\")\n }\n inherits(Cat, Animal, {\n meow: function () { this.say(\"miao miao\") }\n })\n Cat.prototype.purr = function () {\n this.say(\"purr purr\")\n }\n\n\n var c = new Chihuahua\n assert(c instanceof Chihuahua)\n assert(c instanceof Dog)\n assert(c instanceof Animal)\n\nThe actual function is laughably small. 10-lines small.\n", + "readmeFilename": "README.md", + "_id": "inherits@1.0.0", + "dist": { + "shasum": "f31c29ca5d0348508c1fb08655aa94e483a0c53e" + }, + "_from": "inherits@1", + "_resolved": "https://registry.npmjs.org/inherits/-/inherits-1.0.0.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/glob/package.json b/Phaser/node_modules/grunt/node_modules/glob/package.json new file mode 100644 index 00000000..52b6dc61 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/glob/package.json @@ -0,0 +1,40 @@ +{ + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "name": "glob", + "description": "a little globber", + "version": "3.1.21", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/node-glob.git" + }, + "main": "glob.js", + "engines": { + "node": "*" + }, + "dependencies": { + "minimatch": "~0.2.11", + "graceful-fs": "~1.2.0", + "inherits": "1" + }, + "devDependencies": { + "tap": "~0.4.0", + "mkdirp": "0", + "rimraf": "1" + }, + "scripts": { + "test": "tap test/*.js" + }, + "license": "BSD", + "readme": "# Glob\n\nThis is a glob implementation in JavaScript. It uses the `minimatch`\nlibrary to do its matching.\n\n## Attention: node-glob users!\n\nThe API has changed dramatically between 2.x and 3.x. This library is\nnow 100% JavaScript, and the integer flags have been replaced with an\noptions object.\n\nAlso, there's an event emitter class, proper tests, and all the other\nthings you've come to expect from node modules.\n\nAnd best of all, no compilation!\n\n## Usage\n\n```javascript\nvar glob = require(\"glob\")\n\n// options is optional\nglob(\"**/*.js\", options, function (er, files) {\n // files is an array of filenames.\n // If the `nonull` option is set, and nothing\n // was found, then files is [\"**/*.js\"]\n // er is an error object or null.\n})\n```\n\n## Features\n\nPlease see the [minimatch\ndocumentation](https://github.com/isaacs/minimatch) for more details.\n\nSupports these glob features:\n\n* Brace Expansion\n* Extended glob matching\n* \"Globstar\" `**` matching\n\nSee:\n\n* `man sh`\n* `man bash`\n* `man 3 fnmatch`\n* `man 5 gitignore`\n* [minimatch documentation](https://github.com/isaacs/minimatch)\n\n## glob(pattern, [options], cb)\n\n* `pattern` {String} Pattern to be matched\n* `options` {Object}\n* `cb` {Function}\n * `err` {Error | null}\n * `matches` {Array} filenames found matching the pattern\n\nPerform an asynchronous glob search.\n\n## glob.sync(pattern, [options]\n\n* `pattern` {String} Pattern to be matched\n* `options` {Object}\n* return: {Array} filenames found matching the pattern\n\nPerform a synchronous glob search.\n\n## Class: glob.Glob\n\nCreate a Glob object by instanting the `glob.Glob` class.\n\n```javascript\nvar Glob = require(\"glob\").Glob\nvar mg = new Glob(pattern, options, cb)\n```\n\nIt's an EventEmitter, and starts walking the filesystem to find matches\nimmediately.\n\n### new glob.Glob(pattern, [options], [cb])\n\n* `pattern` {String} pattern to search for\n* `options` {Object}\n* `cb` {Function} Called when an error occurs, or matches are found\n * `err` {Error | null}\n * `matches` {Array} filenames found matching the pattern\n\nNote that if the `sync` flag is set in the options, then matches will\nbe immediately available on the `g.found` member.\n\n### Properties\n\n* `minimatch` The minimatch object that the glob uses.\n* `options` The options object passed in.\n* `error` The error encountered. When an error is encountered, the\n glob object is in an undefined state, and should be discarded.\n* `aborted` Boolean which is set to true when calling `abort()`. There\n is no way at this time to continue a glob search after aborting, but\n you can re-use the statCache to avoid having to duplicate syscalls.\n\n### Events\n\n* `end` When the matching is finished, this is emitted with all the\n matches found. If the `nonull` option is set, and no match was found,\n then the `matches` list contains the original pattern. The matches\n are sorted, unless the `nosort` flag is set.\n* `match` Every time a match is found, this is emitted with the matched.\n* `error` Emitted when an unexpected error is encountered, or whenever\n any fs error occurs if `options.strict` is set.\n* `abort` When `abort()` is called, this event is raised.\n\n### Methods\n\n* `abort` Stop the search.\n\n### Options\n\nAll the options that can be passed to Minimatch can also be passed to\nGlob to change pattern matching behavior. Also, some have been added,\nor have glob-specific ramifications.\n\nAll options are false by default, unless otherwise noted.\n\nAll options are added to the glob object, as well.\n\n* `cwd` The current working directory in which to search. Defaults\n to `process.cwd()`.\n* `root` The place where patterns starting with `/` will be mounted\n onto. Defaults to `path.resolve(options.cwd, \"/\")` (`/` on Unix\n systems, and `C:\\` or some such on Windows.)\n* `nomount` By default, a pattern starting with a forward-slash will be\n \"mounted\" onto the root setting, so that a valid filesystem path is\n returned. Set this flag to disable that behavior.\n* `mark` Add a `/` character to directory matches. Note that this\n requires additional stat calls.\n* `nosort` Don't sort the results.\n* `stat` Set to true to stat *all* results. This reduces performance\n somewhat, and is completely unnecessary, unless `readdir` is presumed\n to be an untrustworthy indicator of file existence. It will cause\n ELOOP to be triggered one level sooner in the case of cyclical\n symbolic links.\n* `silent` When an unusual error is encountered\n when attempting to read a directory, a warning will be printed to\n stderr. Set the `silent` option to true to suppress these warnings.\n* `strict` When an unusual error is encountered\n when attempting to read a directory, the process will just continue on\n in search of other matches. Set the `strict` option to raise an error\n in these cases.\n* `statCache` A cache of results of filesystem information, to prevent\n unnecessary stat calls. While it should not normally be necessary to\n set this, you may pass the statCache from one glob() call to the\n options object of another, if you know that the filesystem will not\n change between calls. (See \"Race Conditions\" below.)\n* `sync` Perform a synchronous glob search.\n* `nounique` In some cases, brace-expanded patterns can result in the\n same file showing up multiple times in the result set. By default,\n this implementation prevents duplicates in the result set.\n Set this flag to disable that behavior.\n* `nonull` Set to never return an empty set, instead returning a set\n containing the pattern itself. This is the default in glob(3).\n* `nocase` Perform a case-insensitive match. Note that case-insensitive\n filesystems will sometimes result in glob returning results that are\n case-insensitively matched anyway, since readdir and stat will not\n raise an error.\n* `debug` Set to enable debug logging in minimatch and glob.\n* `globDebug` Set to enable debug logging in glob, but not minimatch.\n\n## Comparisons to other fnmatch/glob implementations\n\nWhile strict compliance with the existing standards is a worthwhile\ngoal, some discrepancies exist between node-glob and other\nimplementations, and are intentional.\n\nIf the pattern starts with a `!` character, then it is negated. Set the\n`nonegate` flag to suppress this behavior, and treat leading `!`\ncharacters normally. This is perhaps relevant if you wish to start the\npattern with a negative extglob pattern like `!(a|B)`. Multiple `!`\ncharacters at the start of a pattern will negate the pattern multiple\ntimes.\n\nIf a pattern starts with `#`, then it is treated as a comment, and\nwill not match anything. Use `\\#` to match a literal `#` at the\nstart of a line, or set the `nocomment` flag to suppress this behavior.\n\nThe double-star character `**` is supported by default, unless the\n`noglobstar` flag is set. This is supported in the manner of bsdglob\nand bash 4.1, where `**` only has special significance if it is the only\nthing in a path part. That is, `a/**/b` will match `a/x/y/b`, but\n`a/**b` will not. **Note that this is different from the way that `**` is\nhandled by ruby's `Dir` class.**\n\nIf an escaped pattern has no matches, and the `nonull` flag is set,\nthen glob returns the pattern as-provided, rather than\ninterpreting the character escapes. For example,\n`glob.match([], \"\\\\*a\\\\?\")` will return `\"\\\\*a\\\\?\"` rather than\n`\"*a?\"`. This is akin to setting the `nullglob` option in bash, except\nthat it does not resolve escaped pattern characters.\n\nIf brace expansion is not disabled, then it is performed before any\nother interpretation of the glob pattern. Thus, a pattern like\n`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded\n**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are\nchecked for validity. Since those two are valid, matching proceeds.\n\n## Windows\n\n**Please only use forward-slashes in glob expressions.**\n\nThough windows uses either `/` or `\\` as its path separator, only `/`\ncharacters are used by this glob implementation. You must use\nforward-slashes **only** in glob expressions. Back-slashes will always\nbe interpreted as escape characters, not path separators.\n\nResults from absolute patterns such as `/foo/*` are mounted onto the\nroot setting using `path.join`. On windows, this will by default result\nin `/foo/*` matching `C:\\foo\\bar.txt`.\n\n## Race Conditions\n\nGlob searching, by its very nature, is susceptible to race conditions,\nsince it relies on directory walking and such.\n\nAs a result, it is possible that a file that exists when glob looks for\nit may have been deleted or modified by the time it returns the result.\n\nAs part of its internal implementation, this program caches all stat\nand readdir calls that it makes, in order to cut down on system\noverhead. However, this also makes it even more susceptible to races,\nespecially if the statCache object is reused between glob calls.\n\nUsers are thus advised not to use a glob result as a\nguarantee of filesystem state in the face of rapid changes.\nFor the vast majority of operations, this is never a problem.\n", + "readmeFilename": "README.md", + "_id": "glob@3.1.21", + "dist": { + "shasum": "3e571d3685492f79bbfbac81a61416dec97b2998" + }, + "_from": "glob@~3.1.21", + "_resolved": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/glob/test/bash-results.json b/Phaser/node_modules/grunt/node_modules/glob/test/bash-results.json new file mode 100644 index 00000000..c227449b --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/glob/test/bash-results.json @@ -0,0 +1,348 @@ +{ + "test/a/*/+(c|g)/./d": [ + "test/a/b/c/./d" + ], + "test/a/**/[cg]/../[cg]": [ + "test/a/abcdef/g/../g", + "test/a/abcfed/g/../g", + "test/a/b/c/../c", + "test/a/c/../c", + "test/a/c/d/c/../c", + "test/a/symlink/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c" + ], + "test/a/{b,c,d,e,f}/**/g": [], + "test/a/b/**": [ + "test/a/b", + "test/a/b/c", + "test/a/b/c/d" + ], + "test/**/g": [ + "test/a/abcdef/g", + "test/a/abcfed/g" + ], + "test/a/abc{fed,def}/g/h": [ + "test/a/abcdef/g/h", + "test/a/abcfed/g/h" + ], + "test/a/abc{fed/g,def}/**/": [ + "test/a/abcdef", + "test/a/abcdef/g", + "test/a/abcfed/g" + ], + "test/a/abc{fed/g,def}/**///**/": [ + "test/a/abcdef", + "test/a/abcdef/g", + "test/a/abcfed/g" + ], + "test/**/a/**/": [ + "test/a", + "test/a/abcdef", + "test/a/abcdef/g", + "test/a/abcfed", + "test/a/abcfed/g", + "test/a/b", + "test/a/b/c", + "test/a/bc", + "test/a/bc/e", + "test/a/c", + "test/a/c/d", + "test/a/c/d/c", + "test/a/cb", + "test/a/cb/e", + "test/a/symlink", + "test/a/symlink/a", + "test/a/symlink/a/b", + "test/a/symlink/a/b/c", + "test/a/symlink/a/b/c/a", + "test/a/symlink/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b" + ], + "test/+(a|b|c)/a{/,bc*}/**": [ + "test/a/abcdef", + "test/a/abcdef/g", + "test/a/abcdef/g/h", + "test/a/abcfed", + "test/a/abcfed/g", + "test/a/abcfed/g/h" + ], + "test/*/*/*/f": [ + "test/a/bc/e/f", + "test/a/cb/e/f" + ], + "test/**/f": [ + "test/a/bc/e/f", + "test/a/cb/e/f" + ], + "test/a/symlink/a/b/c/a/b/c/a/b/c//a/b/c////a/b/c/**/b/c/**": [ + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c" + ], + "{./*/*,/tmp/glob-test/*}": [ + "./examples/g.js", + "./examples/usr-local.js", + "./node_modules/graceful-fs", + "./node_modules/inherits", + "./node_modules/minimatch", + "./node_modules/mkdirp", + "./node_modules/rimraf", + "./node_modules/tap", + "./test/00-setup.js", + "./test/a", + "./test/bash-comparison.js", + "./test/bash-results.json", + "./test/cwd-test.js", + "./test/mark.js", + "./test/nocase-nomagic.js", + "./test/pause-resume.js", + "./test/root-nomount.js", + "./test/root.js", + "./test/zz-cleanup.js", + "/tmp/glob-test/asdf", + "/tmp/glob-test/bar", + "/tmp/glob-test/baz", + "/tmp/glob-test/foo", + "/tmp/glob-test/quux", + "/tmp/glob-test/qwer", + "/tmp/glob-test/rewq" + ], + "{/tmp/glob-test/*,*}": [ + "/tmp/glob-test/asdf", + "/tmp/glob-test/bar", + "/tmp/glob-test/baz", + "/tmp/glob-test/foo", + "/tmp/glob-test/quux", + "/tmp/glob-test/qwer", + "/tmp/glob-test/rewq", + "examples", + "glob.js", + "LICENSE", + "node_modules", + "package.json", + "README.md", + "test" + ], + "test/a/!(symlink)/**": [ + "test/a/abcdef", + "test/a/abcdef/g", + "test/a/abcdef/g/h", + "test/a/abcfed", + "test/a/abcfed/g", + "test/a/abcfed/g/h", + "test/a/b", + "test/a/b/c", + "test/a/b/c/d", + "test/a/bc", + "test/a/bc/e", + "test/a/bc/e/f", + "test/a/c", + "test/a/c/d", + "test/a/c/d/c", + "test/a/c/d/c/b", + "test/a/cb", + "test/a/cb/e", + "test/a/cb/e/f" + ] +} diff --git a/Phaser/node_modules/grunt/node_modules/hooker/LICENSE-MIT b/Phaser/node_modules/grunt/node_modules/hooker/LICENSE-MIT new file mode 100644 index 00000000..90c336c3 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/hooker/LICENSE-MIT @@ -0,0 +1,22 @@ +Copyright (c) 2012 "Cowboy" Ben Alman + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/hooker/README.md b/Phaser/node_modules/grunt/node_modules/hooker/README.md new file mode 100644 index 00000000..138943a2 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/hooker/README.md @@ -0,0 +1,186 @@ +# JavaScript Hooker + +Monkey-patch (hook) functions for debugging and stuff. + +## Getting Started + +This code should work just fine in Node.js: + +First, install the module with: `npm install hooker` + +```javascript +var hooker = require('hooker'); +hooker.hook(Math, "max", function() { + console.log(arguments.length + " arguments passed"); +}); +Math.max(5, 6, 7) // logs: "3 arguments passed", returns 7 +``` + +Or in the browser: + +```html + + +``` + +In the browser, you can attach Hooker's methods to any object. + +```html + + + +``` + +## Documentation + +### hooker.hook +Monkey-patch (hook) one or more methods of an object. +#### Signature: +`hooker.hook(object, [ props, ] [options | prehookFunction])` +#### `props` +The optional `props` argument can be a method name, array of method names or null. If null (or omitted), all enumerable methods of `object` will be hooked. +#### `options` +* `pre` - (Function) a pre-hook function to be executed before the original function. Arguments passed into the method will be passed into the pre-hook function as well. +* `post` - (Function) a post-hook function to be executed after the original function. The original function's result is passed into the post-hook function as its first argument, followed by the method arguments. +* `once` - (Boolean) if true, auto-unhook the function after the first execution. +* `passName` - (Boolean) if true, pass the name of the method into the pre-hook function as its first arg (preceding all other arguments), and into the post-hook function as the second arg (after result but preceding all other arguments). + +#### Returns: +An array of hooked method names. + +### hooker.unhook +Un-monkey-patch (unhook) one or more methods of an object. +#### Signature: +`hooker.unhook(object [, props ])` +#### `props` +The optional `props` argument can be a method name, array of method names or null. If null (or omitted), all methods of `object` will be unhooked. +#### Returns: +An array of unhooked method names. + +### hooker.orig +Get a reference to the original method from a hooked function. +#### Signature: +`hooker.orig(object, props)` + +### hooker.override +When a pre- or post-hook returns the result of this function, the value +passed will be used in place of the original function's return value. Any +post-hook override value will take precedence over a pre-hook override value. +#### Signature: +`hooker.override(value)` + +### hooker.preempt +When a pre-hook returns the result of this function, the value passed will +be used in place of the original function's return value, and the original +function will NOT be executed. +#### Signature: +`hooker.preempt(value)` + +### hooker.filter +When a pre-hook returns the result of this function, the context and +arguments passed will be applied into the original function. +#### Signature: +`hooker.filter(context, arguments)` + + +## Examples +See the unit tests for more examples. + +```javascript +var hooker = require('hooker'); +// Simple logging. +hooker.hook(Math, "max", function() { + console.log(arguments.length + " arguments passed"); +}); +Math.max(5, 6, 7) // logs: "3 arguments passed", returns 7 + +hooker.unhook(Math, "max"); // (This is assumed between all further examples) +Math.max(5, 6, 7) // 7 + +// Returning hooker.override(value) overrides the original value. +hooker.hook(Math, "max", function() { + if (arguments.length === 0) { + return hooker.override(9000); + } +}); +Math.max(5, 6, 7) // 7 +Math.max() // 9000 + +// Auto-unhook after one execution. +hooker.hook(Math, "max", { + once: true, + pre: function() { + console.log("Init something here"); + } +}); +Math.max(5, 6, 7) // logs: "Init something here", returns 7 +Math.max(5, 6, 7) // 7 + +// Filter `this` and arguments through a pre-hook function. +hooker.hook(Math, "max", { + pre: function() { + var args = [].map.call(arguments, function(num) { + return num * 2; + }); + return hooker.filter(this, args); // thisValue, arguments + } +}); +Math.max(5, 6, 7) // 14 + +// Modify the original function's result with a post-hook function. +hooker.hook(Math, "max", { + post: function(result) { + return hooker.override(result * 100); + } +}); +Math.max(5, 6, 7) // 700 + +// Hook every Math method. Note: if Math's methods were enumerable, the second +// argument could be omitted. Since they aren't, an array of properties to hook +// must be explicitly passed. Non-method properties will be skipped. +// See a more generic example here: http://bit.ly/vvJlrS +hooker.hook(Math, Object.getOwnPropertyNames(Math), { + passName: true, + pre: function(name) { + console.log("=> Math." + name, [].slice.call(arguments, 1)); + }, + post: function(result, name) { + console.log("<= Math." + name, result); + } +}); + +var result = Math.max(5, 6, 7); +// => Math.max [ 5, 6, 7 ] +// <= Math.max 7 +result // 7 + +result = Math.ceil(3.456); +// => Math.ceil [ 3.456 ] +// <= Math.ceil 4 +result // 4 +``` + +## Contributing +In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt](https://github.com/cowboy/grunt). + +_Also, please don't edit files in the "dist" subdirectory as they are generated via grunt. You'll find source code in the "lib" subdirectory!_ + +## Release History +2012/01/09 - v0.2.3 - First official release. + +## License +Copyright (c) 2012 "Cowboy" Ben Alman +Licensed under the MIT license. + diff --git a/Phaser/node_modules/grunt/node_modules/hooker/package.json b/Phaser/node_modules/grunt/node_modules/hooker/package.json new file mode 100644 index 00000000..7025ae51 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/hooker/package.json @@ -0,0 +1,49 @@ +{ + "name": "hooker", + "description": "Monkey-patch (hook) functions for debugging and stuff.", + "version": "0.2.3", + "homepage": "http://github.com/cowboy/javascript-hooker", + "author": { + "name": "\"Cowboy\" Ben Alman", + "url": "http://benalman.com/" + }, + "repository": { + "type": "git", + "url": "git://github.com/cowboy/javascript-hooker.git" + }, + "bugs": { + "url": "https://github.com/cowboy/javascript-hooker/issues" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://github.com/cowboy/javascript-hooker/blob/master/LICENSE-MIT" + } + ], + "dependencies": {}, + "devDependencies": { + "grunt": "~0.2.1" + }, + "keywords": [ + "patch", + "hook", + "function", + "debug", + "aop" + ], + "engines": { + "node": "*" + }, + "main": "lib/hooker", + "scripts": { + "test": "grunt test" + }, + "readme": "# JavaScript Hooker\n\nMonkey-patch (hook) functions for debugging and stuff.\n\n## Getting Started\n\nThis code should work just fine in Node.js:\n\nFirst, install the module with: `npm install hooker`\n\n```javascript\nvar hooker = require('hooker');\nhooker.hook(Math, \"max\", function() {\n console.log(arguments.length + \" arguments passed\");\n});\nMath.max(5, 6, 7) // logs: \"3 arguments passed\", returns 7\n```\n\nOr in the browser:\n\n```html\n\n\n```\n\nIn the browser, you can attach Hooker's methods to any object.\n\n```html\n\n\n\n```\n\n## Documentation\n\n### hooker.hook\nMonkey-patch (hook) one or more methods of an object.\n#### Signature:\n`hooker.hook(object, [ props, ] [options | prehookFunction])`\n#### `props`\nThe optional `props` argument can be a method name, array of method names or null. If null (or omitted), all enumerable methods of `object` will be hooked.\n#### `options`\n* `pre` - (Function) a pre-hook function to be executed before the original function. Arguments passed into the method will be passed into the pre-hook function as well.\n* `post` - (Function) a post-hook function to be executed after the original function. The original function's result is passed into the post-hook function as its first argument, followed by the method arguments.\n* `once` - (Boolean) if true, auto-unhook the function after the first execution.\n* `passName` - (Boolean) if true, pass the name of the method into the pre-hook function as its first arg (preceding all other arguments), and into the post-hook function as the second arg (after result but preceding all other arguments).\n\n#### Returns:\nAn array of hooked method names.\n\n### hooker.unhook\nUn-monkey-patch (unhook) one or more methods of an object.\n#### Signature:\n`hooker.unhook(object [, props ])`\n#### `props`\nThe optional `props` argument can be a method name, array of method names or null. If null (or omitted), all methods of `object` will be unhooked.\n#### Returns:\nAn array of unhooked method names.\n\n### hooker.orig\nGet a reference to the original method from a hooked function.\n#### Signature:\n`hooker.orig(object, props)`\n\n### hooker.override\nWhen a pre- or post-hook returns the result of this function, the value\npassed will be used in place of the original function's return value. Any\npost-hook override value will take precedence over a pre-hook override value.\n#### Signature:\n`hooker.override(value)`\n\n### hooker.preempt\nWhen a pre-hook returns the result of this function, the value passed will\nbe used in place of the original function's return value, and the original\nfunction will NOT be executed.\n#### Signature:\n`hooker.preempt(value)`\n\n### hooker.filter\nWhen a pre-hook returns the result of this function, the context and\narguments passed will be applied into the original function.\n#### Signature:\n`hooker.filter(context, arguments)`\n\n\n## Examples\nSee the unit tests for more examples.\n\n```javascript\nvar hooker = require('hooker');\n// Simple logging.\nhooker.hook(Math, \"max\", function() {\n console.log(arguments.length + \" arguments passed\");\n});\nMath.max(5, 6, 7) // logs: \"3 arguments passed\", returns 7\n\nhooker.unhook(Math, \"max\"); // (This is assumed between all further examples)\nMath.max(5, 6, 7) // 7\n\n// Returning hooker.override(value) overrides the original value.\nhooker.hook(Math, \"max\", function() {\n if (arguments.length === 0) {\n return hooker.override(9000);\n }\n});\nMath.max(5, 6, 7) // 7\nMath.max() // 9000\n\n// Auto-unhook after one execution.\nhooker.hook(Math, \"max\", {\n once: true,\n pre: function() {\n console.log(\"Init something here\");\n }\n});\nMath.max(5, 6, 7) // logs: \"Init something here\", returns 7\nMath.max(5, 6, 7) // 7\n\n// Filter `this` and arguments through a pre-hook function.\nhooker.hook(Math, \"max\", {\n pre: function() {\n var args = [].map.call(arguments, function(num) {\n return num * 2;\n });\n return hooker.filter(this, args); // thisValue, arguments\n }\n});\nMath.max(5, 6, 7) // 14\n\n// Modify the original function's result with a post-hook function.\nhooker.hook(Math, \"max\", {\n post: function(result) {\n return hooker.override(result * 100);\n }\n});\nMath.max(5, 6, 7) // 700\n\n// Hook every Math method. Note: if Math's methods were enumerable, the second\n// argument could be omitted. Since they aren't, an array of properties to hook\n// must be explicitly passed. Non-method properties will be skipped.\n// See a more generic example here: http://bit.ly/vvJlrS\nhooker.hook(Math, Object.getOwnPropertyNames(Math), {\n passName: true,\n pre: function(name) {\n console.log(\"=> Math.\" + name, [].slice.call(arguments, 1));\n },\n post: function(result, name) {\n console.log(\"<= Math.\" + name, result);\n }\n});\n\nvar result = Math.max(5, 6, 7);\n// => Math.max [ 5, 6, 7 ]\n// <= Math.max 7\nresult // 7\n\nresult = Math.ceil(3.456);\n// => Math.ceil [ 3.456 ]\n// <= Math.ceil 4\nresult // 4\n```\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt](https://github.com/cowboy/grunt).\n\n_Also, please don't edit files in the \"dist\" subdirectory as they are generated via grunt. You'll find source code in the \"lib\" subdirectory!_\n\n## Release History\n2012/01/09 - v0.2.3 - First official release.\n\n## License\nCopyright (c) 2012 \"Cowboy\" Ben Alman \nLicensed under the MIT license. \n\n", + "readmeFilename": "README.md", + "_id": "hooker@0.2.3", + "dist": { + "shasum": "42604c7eaa578b96b26e57a598b5a2b18dfaa4e2" + }, + "_from": "hooker@~0.2.3", + "_resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/iconv-lite/.npmignore b/Phaser/node_modules/grunt/node_modules/iconv-lite/.npmignore new file mode 100644 index 00000000..fe46877a --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/iconv-lite/.npmignore @@ -0,0 +1,3 @@ +node_modules +*~ +*sublime-* diff --git a/Phaser/node_modules/grunt/node_modules/iconv-lite/.travis.yml b/Phaser/node_modules/grunt/node_modules/iconv-lite/.travis.yml new file mode 100644 index 00000000..0bab9cd8 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/iconv-lite/.travis.yml @@ -0,0 +1,5 @@ + language: node_js + node_js: + - 0.4 + - 0.6 + - 0.8 diff --git a/Phaser/node_modules/grunt/node_modules/iconv-lite/LICENSE b/Phaser/node_modules/grunt/node_modules/iconv-lite/LICENSE new file mode 100644 index 00000000..d518d837 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/iconv-lite/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) 2011 Alexander Shtuchkin + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/Phaser/node_modules/grunt/node_modules/iconv-lite/README.md b/Phaser/node_modules/grunt/node_modules/iconv-lite/README.md new file mode 100644 index 00000000..66de64e9 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/iconv-lite/README.md @@ -0,0 +1,67 @@ +iconv-lite - pure javascript character encoding conversion +====================================================================== + +[![Build Status](https://secure.travis-ci.org/ashtuchkin/iconv-lite.png?branch=master)](http://travis-ci.org/ashtuchkin/iconv-lite) + +## Features + +* Pure javascript. Doesn't need native code compilation. +* Easy API. +* Works on Windows and in sandboxed environments like [Cloud9](http://c9.io). +* Encoding is much faster than node-iconv (see below for performance comparison). + +## Usage + + var iconv = require('iconv-lite'); + + // Convert from an encoded buffer to string. + str = iconv.decode(buf, 'win1251'); + + // Convert from string to an encoded buffer. + buf = iconv.encode("Sample input string", 'win1251'); + +## Supported encodings + +* All node.js native encodings: 'utf8', 'ucs2', 'ascii', 'binary', 'base64' +* All widespread single byte encodings: Windows 125x family, ISO-8859 family, + IBM/DOS codepages, Macintosh family, KOI8 family. + Aliases like 'latin1', 'us-ascii' also supported. +* Multibyte encodings: 'gbk', 'gb2313', 'Big5', 'cp950'. + +Others are easy to add, see the source. Please, participate. +Most encodings are generated from node-iconv. Thank you Ben Noordhuis and iconv authors! + +Not supported yet: EUC family, Shift_JIS. + + +## Encoding/decoding speed + +Comparison with node-iconv module (1000x256kb, on Ubuntu 12.04, Core i5/2.5 GHz, Node v0.8.7). +Note: your results may vary, so please always check on your hardware. + + operation iconv@1.2.4 iconv-lite@0.2.4 + ---------------------------------------------------------- + encode('win1251') ~115 Mb/s ~230 Mb/s + decode('win1251') ~95 Mb/s ~130 Mb/s + + +## Notes + +Untranslatable characters are set to � or ?. No transliteration is currently supported, pull requests are welcome. + +## Testing + + git clone git@github.com:ashtuchkin/iconv-lite.git + cd iconv-lite + npm install + npm test + + # To view performance: + node test/performance.js + +## TODO + +* Support streaming character conversion, something like util.pipe(req, iconv.fromEncodingStream('latin1')). +* Add more encodings. +* Add transliteration (best fit char). +* Add tests and correct support of variable-byte encodings (currently work is delegated to node). diff --git a/Phaser/node_modules/grunt/node_modules/iconv-lite/README.md~ b/Phaser/node_modules/grunt/node_modules/iconv-lite/README.md~ new file mode 100644 index 00000000..5f575615 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/iconv-lite/README.md~ @@ -0,0 +1,54 @@ +iconv-lite - native javascript conversion between character encodings. +====================================================================== + +## Usage + + var iconv = require('iconv-lite'); + + // Convert from an encoded buffer to string. + str = iconv.fromEncoding(buf, 'win-1251'); + // Or + str = iconv.decode(buf, 'win-1251'); + + // Convert from string to an encoded buffer. + buf = iconv.toEncoding("Sample input string", 'win-1251'); + // Or + buf = iconv.encode("Sample input string", 'win-1251'); + +## Supported encodings + +Currently only a small part of encodings supported: + +* All node.js native encodings: 'utf8', 'ucs2', 'ascii', 'binary', 'base64'. +* 'latin1' +* Cyrillic encodings: 'windows-1251', 'koi8-r', 'iso 8859-5'. + +Other encodings are easy to add, see the source. Please, participate. + + +## Encoding/decoding speed + +Comparison with iconv module (1000 times 256kb, on Core i5/2.5 GHz). + + Operation\module iconv iconv-lite (this) + toEncoding('win1251') 19.57 mb/s 49.04 mb/s + fromEncoding('win1251') 16.39 mb/s 24.11 mb/s + + +## Notes + +This module is JavaScript-only, thus can be used in a sandboxed environment like [Cloud9](http://c9.io). + +Untranslatable characters are set to '?'. No transliteration is currently supported, pull requests are welcome. + +## Testing + + npm install --dev iconv-lite + vows + +## TODO + +* Support streaming character conversion, something like util.pipe(req, iconv.fromEncodingStream('latin1')). +* Add more encodings. +* Add transliteration (best fit char). +* Add tests and correct support of variable-byte encodings (currently work is delegated to node). diff --git a/Phaser/node_modules/grunt/node_modules/iconv-lite/package.json b/Phaser/node_modules/grunt/node_modules/iconv-lite/package.json new file mode 100644 index 00000000..274530fc --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/iconv-lite/package.json @@ -0,0 +1,72 @@ +{ + "name": "iconv-lite", + "description": "Convert character encodings in pure javascript.", + "version": "0.2.8", + "keywords": [ + "iconv", + "convert", + "charset" + ], + "author": { + "name": "Alexander Shtuchkin", + "email": "ashtuchkin@gmail.com" + }, + "contributors": [ + { + "name": "Jinwu Zhan", + "url": "https://github.com/jenkinv" + }, + { + "name": "Adamansky Anton", + "url": "https://github.com/adamansky" + }, + { + "name": "George Stagas", + "url": "https://github.com/stagas" + }, + { + "name": "Mike D Pilsbury", + "url": "https://github.com/pekim" + }, + { + "name": "Niggler", + "url": "https://github.com/Niggler" + }, + { + "name": "wychi", + "url": "https://github.com/wychi" + }, + { + "name": "David Kuo", + "url": "https://github.com/david50407" + }, + { + "name": "ChangZhuo Chen", + "url": "https://github.com/czchen" + } + ], + "main": "index.js", + "homepage": "https://github.com/ashtuchkin/iconv-lite", + "repository": { + "type": "git", + "url": "git://github.com/ashtuchkin/iconv-lite.git" + }, + "engines": { + "node": ">=0.4.0" + }, + "scripts": { + "test": "vows --spec" + }, + "devDependencies": { + "vows": "", + "iconv": ">=1.1" + }, + "readme": "iconv-lite - pure javascript character encoding conversion\n======================================================================\n\n[![Build Status](https://secure.travis-ci.org/ashtuchkin/iconv-lite.png?branch=master)](http://travis-ci.org/ashtuchkin/iconv-lite)\n\n## Features\n\n* Pure javascript. Doesn't need native code compilation.\n* Easy API.\n* Works on Windows and in sandboxed environments like [Cloud9](http://c9.io).\n* Encoding is much faster than node-iconv (see below for performance comparison).\n\n## Usage\n\n var iconv = require('iconv-lite');\n \n // Convert from an encoded buffer to string.\n str = iconv.decode(buf, 'win1251');\n \n // Convert from string to an encoded buffer.\n buf = iconv.encode(\"Sample input string\", 'win1251');\n\n## Supported encodings\n\n* All node.js native encodings: 'utf8', 'ucs2', 'ascii', 'binary', 'base64'\n* All widespread single byte encodings: Windows 125x family, ISO-8859 family, \n IBM/DOS codepages, Macintosh family, KOI8 family. \n Aliases like 'latin1', 'us-ascii' also supported.\n* Multibyte encodings: 'gbk', 'gb2313', 'Big5', 'cp950'.\n\nOthers are easy to add, see the source. Please, participate.\nMost encodings are generated from node-iconv. Thank you Ben Noordhuis and iconv authors!\n\nNot supported yet: EUC family, Shift_JIS.\n\n\n## Encoding/decoding speed\n\nComparison with node-iconv module (1000x256kb, on Ubuntu 12.04, Core i5/2.5 GHz, Node v0.8.7). \nNote: your results may vary, so please always check on your hardware.\n\n operation iconv@1.2.4 iconv-lite@0.2.4 \n ----------------------------------------------------------\n encode('win1251') ~115 Mb/s ~230 Mb/s\n decode('win1251') ~95 Mb/s ~130 Mb/s\n\n\n## Notes\n\nUntranslatable characters are set to � or ?. No transliteration is currently supported, pull requests are welcome.\n\n## Testing\n\n git clone git@github.com:ashtuchkin/iconv-lite.git\n cd iconv-lite\n npm install\n npm test\n \n # To view performance:\n node test/performance.js\n\n## TODO\n\n* Support streaming character conversion, something like util.pipe(req, iconv.fromEncodingStream('latin1')).\n* Add more encodings.\n* Add transliteration (best fit char).\n* Add tests and correct support of variable-byte encodings (currently work is delegated to node).\n", + "readmeFilename": "README.md", + "_id": "iconv-lite@0.2.8", + "dist": { + "shasum": "30302bd7ab6a9733502fd42405709d43a705bb28" + }, + "_from": "iconv-lite@~0.2.5", + "_resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.2.8.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/iconv-lite/test/big5File.txt b/Phaser/node_modules/grunt/node_modules/iconv-lite/test/big5File.txt new file mode 100644 index 00000000..9c13042c --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/iconv-lite/test/big5File.txt @@ -0,0 +1,13 @@ + + + meta ¼ÐÅÒªº¨Ï¥Î¡G¤¤¤åºô­¶ + + + + +³o¬O¤@­ÓÁcÅ餤¤åºô­¶¡I
    +(This page uses big5 character set.)
    +charset=big5 + + + \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/iconv-lite/test/gbkFile.txt b/Phaser/node_modules/grunt/node_modules/iconv-lite/test/gbkFile.txt new file mode 100644 index 00000000..345b5d09 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/iconv-lite/test/gbkFile.txt @@ -0,0 +1,14 @@ +°Ù¶Èһϣ¬Äã¾ÍÖªµÀ + + + + + + + + + + + \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/HISTORY.md b/Phaser/node_modules/grunt/node_modules/js-yaml/HISTORY.md new file mode 100644 index 00000000..71205e96 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/HISTORY.md @@ -0,0 +1,148 @@ +2.0.4 / 2013-04-08 +------------------ + +* Updated .npmignore to reduce package size + + +2.0.3 / 2013-02-26 +------------------ + +* Fixed dumping of empty arrays ans objects. ([] and {} instead of null) + + +2.0.2 / 2013-02-15 +------------------ + +* Fixed input validation: tabs are printable characters. + + +2.0.1 / 2013-02-09 +------------------ + +* Fixed error, when options not passed to function cass + + +2.0.0 / 2013-02-09 +------------------ + +* Full rewrite. New architecture. Fast one-stage parsing. +* Changed custom types API. +* Added YAML dumper. + + +1.0.3 / 2012-11-05 +------------------ + +* Fixed utf-8 files loading. + + +1.0.2 / 2012-08-02 +------------------ + +* Pull out hand-written shims. Use ES5-Shims for old browsers support. See #44. +* Fix timstamps incorectly parsed in local time when no time part specified. + + +1.0.1 / 2012-07-07 +------------------ + +* Fixes `TypeError: 'undefined' is not an object` under Safari. Thanks Phuong. +* Fix timestamps incorrectly parsed in local time. Thanks @caolan. Closes #46. + + +1.0.0 / 2012-07-01 +------------------ + +* `y`, `yes`, `n`, `no`, `on`, `off` are not converted to Booleans anymore. + Fixes #42. +* `require(filename)` now returns a single document and throws an Error if + file contains more than one document. +* CLI was merged back from js-yaml.bin + + +0.3.7 / 2012-02-28 +------------------ + +* Fix export of `addConstructor()`. Closes #39. + + +0.3.6 / 2012-02-22 +------------------ + +* Removed AMD parts - too buggy to use. Need help to rewrite from scratch +* Removed YUI compressor warning (renamed `double` variable). Closes #40. + + +0.3.5 / 2012-01-10 +------------------ + +* Workagound for .npmignore fuckup under windows. Thanks to airportyh. + + +0.3.4 / 2011-12-24 +------------------ + +* Fixes str[] for oldIEs support. +* Adds better has change support for browserified demo. +* improves compact output of Error. Closes #33. + + +0.3.3 / 2011-12-20 +------------------ + +* jsyaml executable moved to separate module. +* adds `compact` stringification of Errors. + + +0.3.2 / 2011-12-16 +------------------ + +* Fixes ug with block style scalars. Closes #26. +* All sources are passing JSLint now. +* Fixes bug in Safari. Closes #28. +* Fixes bug in Opers. Closes #29. +* Improves browser support. Closes #20. +* Added jsyaml executable. +* Added !!js/function support. Closes #12. + + +0.3.1 / 2011-11-18 +------------------ + +* Added AMD support for browserified version. +* Wrapped browserified js-yaml into closure. +* Fixed the resolvement of non-specific tags. Closes #17. +* Added permalinks for online demo YAML snippets. Now we have YPaste service, lol. +* Added !!js/regexp and !!js/undefined types. Partially solves #12. +* Fixed !!set mapping. +* Fixed month parse in dates. Closes #19. + + +0.3.0 / 2011-11-09 +------------------ + +* Removed JS.Class dependency. Closes #3. +* Added browserified version. Closes #13. +* Added live demo of browserified version. +* Ported some of the PyYAML tests. See #14. +* Fixed timestamp bug when fraction was given. + + +0.2.2 / 2011-11-06 +------------------ + +* Fixed crash on docs without ---. Closes #8. +* Fixed miltiline string parse +* Fixed tests/comments for using array as key + + +0.2.1 / 2011-11-02 +------------------ + +* Fixed short file read (<4k). Closes #9. + + +0.2.0 / 2011-11-02 +------------------ + +* First public release diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/LICENSE b/Phaser/node_modules/grunt/node_modules/js-yaml/LICENSE new file mode 100644 index 00000000..0f16ee95 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/LICENSE @@ -0,0 +1,21 @@ +(The MIT License) + +Copyright (C) 2011, 2013 by Vitaly Puzrin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/README.md b/Phaser/node_modules/grunt/node_modules/js-yaml/README.md new file mode 100644 index 00000000..e326d602 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/README.md @@ -0,0 +1,249 @@ +JS-YAML - YAML 1.2 parser and serializer for JavaScript +======================================================= + +[![Build Status](https://secure.travis-ci.org/nodeca/js-yaml.png)](http://travis-ci.org/nodeca/js-yaml) + +[Online Demo](http://nodeca.github.com/js-yaml/) + + +This is an implementation of [YAML](http://yaml.org/), a human friendly data +serialization language. Started as [PyYAML](http://pyyaml.org/) port, it was +completely rewritten from scratch. Now it's very fast, and supports 1.2 spec. + + +Breaking changes in 1.x.x -> 2.0.x +---------------------------------- + +If your have not used __custom__ tags or loader classes - no changes needed. Just +upgrade library and enjoy high parse speed. + +In other case, you should rewrite your tag constructors and custom loader +classes, to conform new schema-based API. See +[examples](https://github.com/nodeca/js-yaml/tree/master/examples) and +[wiki](https://github.com/nodeca/js-yaml/wiki) for details. +Note, that parser internals were completely rewritten. + + +Installation +------------ + +### YAML module for node.js + +``` +npm install js-yaml +``` + + +### CLI executable + +If you want to inspect your YAML files from CLI, install js-yaml globally: + +``` +npm install js-yaml -g +``` + +#### Usage + +``` +usage: js-yaml [-h] [-v] [-c] [-j] [-t] file + +Positional arguments: + file File with YAML document(s) + +Optional arguments: + -h, --help Show this help message and exit. + -v, --version Show program's version number and exit. + -c, --compact Display errors in compact mode + -j, --to-json Output a non-funky boring JSON + -t, --trace Show stack trace on error +``` + + +### Bundled YAML library for browsers + +``` html + + +``` + +Browser support was done mostly for online demo. If you find any errors - feel +free to send pull requests with fixes. Also note, that IE and other old browsers +needs [es5-shims](https://github.com/kriskowal/es5-shim) to operate. + + +API +--- + +Here we cover the most 'useful' methods. If you need advanced details (creating +your own tags), see [wiki](https://github.com/nodeca/js-yaml/wiki) and +[examples](https://github.com/nodeca/js-yaml/tree/master/examples) for more +info. + +In node.js JS-YAML automatically registers handlers for `.yml` and `.yaml` +files. You can load them just with `require`. That's mostly equivalent to +calling `load()` on fetched content of a file. Just with one string! + +``` javascript +require('js-yaml'); + +// Get document, or throw exception on error +try { + var doc = require('/home/ixti/example.yml'); + console.log(doc); +} catch (e) { + console.log(e); +} +``` + + +### load (string [ , options ]) + +Parses `string` as single YAML document. Returns a JavaScript object or throws +`YAMLException` on error. + +NOTE: This function **does not** understands multi-document sources, it throws +exception on those. + +options: + +- `filename` _(default: null)_ - string to be used as a file path in + error/warning messages. +- `strict` _(default - false)_ makes the loader to throw errors instead of + warnings. +- `schema` _(default: `DEFAULT_SCHEMA`)_ - specifies a schema to use. + + +### loadAll (string, iterator [ , options ]) + +Same as `load()`, but understands multi-document sources and apply `iterator` to +each document. + +``` javascript +var yaml = require('js-yaml'); + +yaml.loadAll(data, function (doc) { + console.log(doc); +}); +``` + + +### safeLoad (string [ , options ]) + +Same as `load()` but uses `SAFE_SCHEMA` by default - only recommended tags of +YAML specification (no JavaScript-specific tags, e.g. `!!js/regexp`). + + +### safeLoadAll (string, iterator [ , options ]) + +Same as `loadAll()` but uses `SAFE_SCHEMA` by default - only recommended tags of +YAML specification (no JavaScript-specific tags, e.g. `!!js/regexp`). + + +### dump (object [ , options ]) + +Serializes `object` as YAML document. + +options: + +- `indent` _(default: 2)_ - indentation width to use (in spaces). +- `flowLevel` (default: -1) - specifies level of nesting, when to switch from + block to flow style for collections. -1 means block style everwhere +- `styles` - "tag" => "style" map. Each tag may have own set of styles. +- `schema` _(default: `DEFAULT_SCHEMA`)_ specifies a schema to use. + +styles: + +``` none +!!null + "canonical" => "~" + +!!int + "binary" => "0b1", "0b101010", "0b1110001111010" + "octal" => "01", "052", "016172" + "decimal" => "1", "42", "7290" + "hexadecimal" => "0x1", "0x2A", "0x1C7A" + +!!null, !!bool, !!float + "lowercase" => "null", "true", "false", ".nan", '.inf' + "uppercase" => "NULL", "TRUE", "FALSE", ".NAN", '.INF' + "camelcase" => "Null", "True", "False", ".NaN", '.Inf' +``` + +By default, !!int uses `decimal`, and !!null, !!bool, !!float use `lowercase`. + + +### safeDump (object [ , options ]) + +Same as `dump()` but uses `SAFE_SCHEMA` by default - only recommended tags of +YAML specification (no JavaScript-specific tags, e.g. `!!js/regexp`). + + +Supported YAML types +-------------------- + +The list of standard YAML tags and corresponding JavaScipt types. See also +[YAML tag discussion](http://pyyaml.org/wiki/YAMLTagDiscussion) and +[YAML types repository](http://yaml.org/type/). + +``` +!!null '' # null +!!bool 'yes' # bool +!!int '3...' # number +!!float '3.14...' # number +!!binary '...base64...' # buffer +!!timestamp 'YYYY-...' # date +!!omap [ ... ] # array of key-value pairs +!!pairs [ ... ] # array or array pairs +!!set { ... } # array of objects with given keys and null values +!!str '...' # string +!!seq [ ... ] # array +!!map { ... } # object +``` + +**JavaScript-specific tags** + +``` +!!js/regexp /pattern/gim # RegExp +!!js/undefined '' # Undefined +!!js/function 'function () {...}' # Function +``` + + + + +## Caveats + +Note, that you use arrays or objects as key in JS-YAML. JS do not allows objects +or array as keys, and stringifies (by calling .toString method) them at the +moment of adding them. + +``` yaml +--- +? [ foo, bar ] +: - baz +? { foo: bar } +: - baz + - baz +``` + +``` javascript +{ "foo,bar": ["baz"], "[object Object]": ["baz", "baz"] } +``` + +Also, reading of properties on implicit block mapping keys is not supported yet. +So, the following YAML document cannot be loaded. + +``` yaml +&anchor foo: + foo: bar + *anchor: duplicate key + baz: bat + *anchor: duplicate key +``` + +## License + +View the [LICENSE](https://github.com/nodeca/js-yaml/blob/master/LICENSE) file +(MIT). diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/examples/custom_types.yaml b/Phaser/node_modules/grunt/node_modules/js-yaml/examples/custom_types.yaml new file mode 100644 index 00000000..033134f5 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/examples/custom_types.yaml @@ -0,0 +1,18 @@ +subject: Custom types in JS-YAML +spaces: +- !space + height: 1000 + width: 1000 + points: + - !point [ 10, 43, 23 ] + - !point [ 165, 0, 50 ] + - !point [ 100, 100, 100 ] + +- !space + height: 64 + width: 128 + points: + - !point [ 12, 43, 0 ] + - !point [ 1, 4, 90 ] + +- !space {} # An empty space diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/examples/dumper.json b/Phaser/node_modules/grunt/node_modules/js-yaml/examples/dumper.json new file mode 100644 index 00000000..9f54c053 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/examples/dumper.json @@ -0,0 +1,22 @@ +{ + "name" : "Wizzard", + "level" : 17, + "sanity" : null, + "inventory" : [ + { + "name" : "Hat", + "features" : [ "magic", "pointed" ], + "traits" : {} + }, + { + "name" : "Staff", + "features" : [], + "traits" : { "damage" : 10 } + }, + { + "name" : "Cloak", + "features" : [ "old" ], + "traits" : { "defence" : 0, "comfort" : 3 } + } + ] +} diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/examples/sample_document.yaml b/Phaser/node_modules/grunt/node_modules/js-yaml/examples/sample_document.yaml new file mode 100644 index 00000000..4479ee9c --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/examples/sample_document.yaml @@ -0,0 +1,197 @@ +--- +# Collection Types ############################################################# +################################################################################ + +# http://yaml.org/type/map.html -----------------------------------------------# + +map: + # Unordered set of key: value pairs. + Block style: !!map + Clark : Evans + Ingy : döt Net + Oren : Ben-Kiki + Flow style: !!map { Clark: Evans, Ingy: döt Net, Oren: Ben-Kiki } + +# http://yaml.org/type/omap.html ----------------------------------------------# + +omap: + # Explicitly typed ordered map (dictionary). + Bestiary: !!omap + - aardvark: African pig-like ant eater. Ugly. + - anteater: South-American ant eater. Two species. + - anaconda: South-American constrictor snake. Scaly. + # Etc. + # Flow style + Numbers: !!omap [ one: 1, two: 2, three : 3 ] + +# http://yaml.org/type/pairs.html ---------------------------------------------# + +pairs: + # Explicitly typed pairs. + Block tasks: !!pairs + - meeting: with team. + - meeting: with boss. + - break: lunch. + - meeting: with client. + Flow tasks: !!pairs [ meeting: with team, meeting: with boss ] + +# http://yaml.org/type/set.html -----------------------------------------------# + +set: + # Explicitly typed set. + baseball players: !!set + ? Mark McGwire + ? Sammy Sosa + ? Ken Griffey + # Flow style + baseball teams: !!set { Boston Red Sox, Detroit Tigers, New York Yankees } + +# http://yaml.org/type/seq.html -----------------------------------------------# + +seq: + # Ordered sequence of nodes + Block style: !!seq + - Mercury # Rotates - no light/dark sides. + - Venus # Deadliest. Aptly named. + - Earth # Mostly dirt. + - Mars # Seems empty. + - Jupiter # The king. + - Saturn # Pretty. + - Uranus # Where the sun hardly shines. + - Neptune # Boring. No rings. + - Pluto # You call this a planet? + Flow style: !!seq [ Mercury, Venus, Earth, Mars, # Rocks + Jupiter, Saturn, Uranus, Neptune, # Gas + Pluto ] # Overrated + + +# Scalar Types ################################################################# +################################################################################ + +# http://yaml.org/type/binary.html --------------------------------------------# + +binary: + canonical: !!binary "\ + R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\ + OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\ + +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\ + AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=" + generic: !!binary | + R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5 + OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+ + +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC + AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs= + description: + The binary value above is a tiny arrow encoded as a gif image. + +# http://yaml.org/type/bool.html ----------------------------------------------# + +bool: + - true + - True + - TRUE + - false + - False + - FALSE + +# http://yaml.org/type/float.html ---------------------------------------------# + +float: + canonical: 6.8523015e+5 + exponentioal: 685.230_15e+03 + fixed: 685_230.15 + sexagesimal: 190:20:30.15 + negative infinity: -.inf + not a number: .NaN + +# http://yaml.org/type/int.html -----------------------------------------------# + +int: + canonical: 685230 + decimal: +685_230 + octal: 02472256 + hexadecimal: 0x_0A_74_AE + binary: 0b1010_0111_0100_1010_1110 + sexagesimal: 190:20:30 + +# http://yaml.org/type/merge.html ---------------------------------------------# + +merge: + - &CENTER { x: 1, y: 2 } + - &LEFT { x: 0, y: 2 } + - &BIG { r: 10 } + - &SMALL { r: 1 } + + # All the following maps are equal: + + - # Explicit keys + x: 1 + y: 2 + r: 10 + label: nothing + + - # Merge one map + << : *CENTER + r: 10 + label: center + + - # Merge multiple maps + << : [ *CENTER, *BIG ] + label: center/big + + - # Override + << : [ *BIG, *LEFT, *SMALL ] + x: 1 + label: big/left/small + +# http://yaml.org/type/null.html ----------------------------------------------# + +null: + # This mapping has four keys, + # one has a value. + empty: + canonical: ~ + english: null + ~: null key + # This sequence has five + # entries, two have values. + sparse: + - ~ + - 2nd entry + - + - 4th entry + - Null + +# http://yaml.org/type/str.html -----------------------------------------------# + +string: abcd + +# http://yaml.org/type/timestamp.html -----------------------------------------# + +timestamp: + canonical: 2001-12-15T02:59:43.1Z + valid iso8601: 2001-12-14t21:59:43.10-05:00 + space separated: 2001-12-14 21:59:43.10 -5 + no time zone (Z): 2001-12-15 2:59:43.10 + date (00:00:00Z): 2002-12-14 + + +# JavaScript Specific Types #################################################### +################################################################################ + +# https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp + +regexp: + simple: !!js/regexp foobar + modifiers: !!js/regexp /foobar/mi + +# https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined + +undefined: !!js/undefined ~ + +# https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function + +function: !!js/function > + function foobar() { + return 'Wow! JS-YAML Rocks!'; + } diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/HISTORY.md b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/HISTORY.md new file mode 100644 index 00000000..e8d79ced --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/HISTORY.md @@ -0,0 +1,97 @@ +0.1.13 / 2013-05-08 +------------------- + +* Added `.npmignore` to reduce package size + + +0.1.12 / 2013-02-10 +------------------- + +* Fixed conflictHandler (#46), @hpaulj + + +0.1.11 / 2013-02-07 +------------------- + +* Multiple bugfixes, @hpaulj +* Added 70+ tests (ported from python), @hpaulj +* Added conflictHandler, @applepicke +* Added fromfilePrefixChar, @hpaulj + + +0.1.10 / 2012-12-30 +------------------- + +* Added [mutual exclusion](http://docs.python.org/dev/library/argparse.html#mutual-exclusion) + support, thanks to @hpaulj +* Fixed options check for `storeConst` & `appendConst` actions, thanks to @hpaulj + + +0.1.9 / 2012-12-27 +------------------ + +* Fixed option dest interferens with other options (issue #23), thanks to @hpaulj +* Fixed default value behavior with `*` positionals, thanks to @hpaulj +* Improve `getDefault()` behavior, thanks to @hpaulj +* Imrove negative argument parsing, thanks to @hpaulj + + +0.1.8 / 2012-12-01 +------------------ + +* Fixed parser parents (issue #19), thanks to @hpaulj +* Fixed negative argument parse (issue #20), thanks to @hpaulj + + +0.1.7 / 2012-10-14 +------------------ + +* Fixed 'choices' argument parse (issue #16) +* Fixed stderr output (issue #15) + + +0.1.6 / 2012-09-09 +------------------ + +* Fixed check for conflict of options (thanks to @tomxtobin) + + +0.1.5 / 2012-09-03 +------------------ + +* Fix parser #setDefaults method (thanks to @tomxtobin) + + +0.1.4 / 2012-07-30 +------------------ + +* Fixed pseudo-argument support (thanks to @CGamesPlay) +* Fixed addHelp default (should be true), if not set (thanks to @benblank) + + +0.1.3 / 2012-06-27 +------------------ + +* Fixed formatter api name: Formatter -> HelpFormatter + + +0.1.2 / 2012-05-29 +------------------ + +* Added basic tests +* Removed excess whitespace in help +* Fixed error reporting, when parcer with subcommands + called with empty arguments + + +0.1.1 / 2012-05-23 +------------------ + +* Fixed line wrapping in help formatter +* Added better error reporting on invalid arguments + + +0.1.0 / 2012-05-16 +------------------ + +* First release. diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/LICENSE b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/LICENSE new file mode 100644 index 00000000..1afdae55 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/LICENSE @@ -0,0 +1,21 @@ +(The MIT License) + +Copyright (C) 2012 by Vitaly Puzrin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/README.md b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/README.md new file mode 100644 index 00000000..f20e0c1f --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/README.md @@ -0,0 +1,239 @@ +argparse +======== + +[![Build Status](https://secure.travis-ci.org/nodeca/argparse.png?branch=master)](http://travis-ci.org/nodeca/argparse) + +CLI arguments parser for node.js. Javascript port of python's +[argparse](http://docs.python.org/dev/library/argparse.html) module +(original version 3.2). That's a full port, except some very rare options, +recorded in issue tracker. + +**NB.** Method names changed to camelCase. See [generated docs](http://nodeca.github.com/argparse/). + + +Example +======= + +test.js file: + +```javascript +#!/usr/bin/env node +'use strict'; + +var ArgumentParser = require('../lib/argparse').ArgumentParser; +var parser = new ArgumentParser({ + version: '0.0.1', + addHelp:true, + description: 'Argparse example' +}); +parser.addArgument( + [ '-f', '--foo' ], + { + help: 'foo bar' + } +); +parser.addArgument( + [ '-b', '--bar' ], + { + help: 'bar foo' + } +); +var args = parser.parseArgs(); +console.dir(args); +``` + +Display help: + +``` +$ ./test.js -h +usage: example.js [-h] [-v] [-f FOO] [-b BAR] + +Argparse example + +Optional arguments: + -h, --help Show this help message and exit. + -v, --version Show program's version number and exit. + -f FOO, --foo FOO foo bar + -b BAR, --bar BAR bar foo +``` + +Parse arguments: + +``` +$ ./test.js -f=3 --bar=4 +{ foo: '3', bar: '4' } +``` + +More [examples](https://github.com/nodeca/argparse/tree/master/examples). + + +ArgumentParser objects +====================== + +``` +new ArgumentParser({paramters hash}); +``` + +Creates a new ArgumentParser object. + +**Supported params:** + +- ```description``` - Text to display before the argument help. +- ```epilog``` - Text to display after the argument help. +- ```addHelp``` - Add a -h/–help option to the parser. (default: True) +- ```argumentDefault``` - Set the global default value for arguments. (default: None) +- ```parents``` - A list of ArgumentParser objects whose arguments should also be included. +- ```prefixChars``` - The set of characters that prefix optional arguments. (default: ‘-‘) +- ```formatterClass``` - A class for customizing the help output. +- ```prog``` - The name of the program (default: sys.argv[0]) +- ```usage``` - The string describing the program usage (default: generated) +- ```conflictHandler``` - Usually unnecessary, defines strategy for resolving conflicting optionals. + +**Not supportied yet** + +- ```fromfilePrefixChars``` - The set of characters that prefix files from which additional arguments should be read. + + +Details in [original ArgumentParser guide](http://docs.python.org/dev/library/argparse.html#argumentparser-objects) + + +addArgument() method +==================== + +``` +ArgumentParser.addArgument([names or flags], {options}) +``` + +Defines how a single command-line argument should be parsed. + +- ```name or flags``` - Either a name or a list of option strings, e.g. foo or -f, --foo. + +Options: + +- ```action``` - The basic type of action to be taken when this argument is encountered at the command line. +- ```nargs```- The number of command-line arguments that should be consumed. +- ```constant``` - A constant value required by some action and nargs selections. +- ```defaultValue``` - The value produced if the argument is absent from the command line. +- ```type``` - The type to which the command-line argument should be converted. +- ```choices``` - A container of the allowable values for the argument. +- ```required``` - Whether or not the command-line option may be omitted (optionals only). +- ```help``` - A brief description of what the argument does. +- ```metavar``` - A name for the argument in usage messages. +- ```dest``` - The name of the attribute to be added to the object returned by parseArgs(). + +Details in [original add_argument guide](http://docs.python.org/dev/library/argparse.html#the-add-argument-method) + + +Action (some details) +================ + +ArgumentParser objects associate command-line arguments with actions. +These actions can do just about anything with the command-line arguments associated +with them, though most actions simply add an attribute to the object returned by +parseArgs(). The action keyword argument specifies how the command-line arguments +should be handled. The supported actions are: + +- ```store``` - Just stores the argument’s value. This is the default action. +- ```storeConst``` - Stores value, specified by the const keyword argument. + (Note that the const keyword argument defaults to the rather unhelpful None.) + The 'storeConst' action is most commonly used with optional arguments, that + specify some sort of flag. +- ```storeTrue``` and ```storeFalse``` - Stores values True and False + respectively. These are special cases of 'storeConst'. +- ```append``` - Stores a list, and appends each argument value to the list. + This is useful to allow an option to be specified multiple times. +- ```appendConst``` - Stores a list, and appends value, specified by the + const keyword argument to the list. (Note, that the const keyword argument defaults + is None.) The 'appendConst' action is typically used when multiple arguments need + to store constants to the same list. +- ```count``` - Counts the number of times a keyword argument occurs. For example, + used for increasing verbosity levels. +- ```help``` - Prints a complete help message for all the options in the current + parser and then exits. By default a help action is automatically added to the parser. + See ArgumentParser for details of how the output is created. +- ```version``` - Prints version information and exit. Expects a `version=` + keyword argument in the addArgument() call. + +Details in [original action guide](http://docs.python.org/dev/library/argparse.html#action) + + +Sub-commands +============ + +ArgumentParser.addSubparsers() + +Many programs split their functionality into a number of sub-commands, for +example, the svn program can invoke sub-commands like `svn checkout`, `svn update`, +and `svn commit`. Splitting up functionality this way can be a particularly good +idea when a program performs several different functions which require different +kinds of command-line arguments. `ArgumentParser` supports creation of such +sub-commands with `addSubparsers()` method. The `addSubparsers()` method is +normally called with no arguments and returns an special action object. +This object has a single method `addParser()`, which takes a command name and +any `ArgumentParser` constructor arguments, and returns an `ArgumentParser` object +that can be modified as usual. + +Example: + +sub_commands.js +```javascript +#!/usr/bin/env node +'use strict'; + +var ArgumentParser = require('../lib/argparse').ArgumentParser; +var parser = new ArgumentParser({ + version: '0.0.1', + addHelp:true, + description: 'Argparse examples: sub-commands', +}); + +var subparsers = parser.addSubparsers({ + title:'subcommands', + dest:"subcommand_name" +}); + +var bar = subparsers.addParser('c1', {addHelp:true}); +bar.addArgument( + [ '-f', '--foo' ], + { + action: 'store', + help: 'foo3 bar3' + } +); +var bar = subparsers.addParser( + 'c2', + {aliases:['co'], addHelp:true} +); +bar.addArgument( + [ '-b', '--bar' ], + { + action: 'store', + type: 'int', + help: 'foo3 bar3' + } +); + +var args = parser.parseArgs(); +console.dir(args); + +``` + +Details in [original sub-commands guide](http://docs.python.org/dev/library/argparse.html#sub-commands) + + +Contributors +============ + +- [Eugene Shkuropat](https://github.com/shkuropat) +- [Paul Jacobson](https://github.com/hpaulj) + +[others](https://github.com/nodeca/argparse/graphs/contributors) + +License +======= + +Copyright (c) 2012 [Vitaly Puzrin](https://github.com/puzrin). +Released under the MIT license. See +[LICENSE](https://github.com/nodeca/argparse/blob/master/LICENSE) for details. + + diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/.travis.yml b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/.travis.yml new file mode 100644 index 00000000..ab27b29b --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/.travis.yml @@ -0,0 +1,8 @@ +language: ruby +rvm: + - 1.9.3 + +before_script: + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" + - sleep 2 \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/Gemfile b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/Gemfile new file mode 100644 index 00000000..8ebff7ec --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/Gemfile @@ -0,0 +1,4 @@ +source :rubygems + +gem 'uglifier' +gem 'rake' \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/Gemfile.lock b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/Gemfile.lock new file mode 100644 index 00000000..c41e4a73 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/Gemfile.lock @@ -0,0 +1,17 @@ +GEM + remote: http://rubygems.org/ + specs: + execjs (1.4.0) + multi_json (~> 1.0) + multi_json (1.3.6) + rake (0.9.2.2) + uglifier (1.3.0) + execjs (>= 0.3.0) + multi_json (~> 1.0, >= 1.0.2) + +PLATFORMS + ruby + +DEPENDENCIES + rake + uglifier diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/README.markdown b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/README.markdown new file mode 100644 index 00000000..fc884984 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/README.markdown @@ -0,0 +1,744 @@ +# Underscore.string [![Build Status](https://secure.travis-ci.org/epeli/underscore.string.png?branch=master)](http://travis-ci.org/epeli/underscore.string) # + + + +Javascript lacks complete string manipulation operations. +This an attempt to fill that gap. List of build-in methods can be found +for example from [Dive Into JavaScript][d]. + +[d]: http://www.diveintojavascript.com/core-javascript-reference/the-string-object + + +As name states this an extension for [Underscore.js][u], but it can be used +independently from **_s**-global variable. But with Underscore.js you can +use Object-Oriented style and chaining: + +[u]: http://documentcloud.github.com/underscore/ + +```javascript +_(" epeli ").chain().trim().capitalize().value() +=> "Epeli" +``` + +## Download ## + + * [Development version](https://raw.github.com/epeli/underscore.string/master/lib/underscore.string.js) *Uncompressed with Comments 18kb* + * [Production version](https://github.com/epeli/underscore.string/raw/master/dist/underscore.string.min.js) *Minified 7kb* + + +## Node.js installation ## + +**npm package** + + npm install underscore.string + +**Standalone usage**: + +```javascript +var _s = require('underscore.string'); +``` + +**Integrate with Underscore.js**: + +```javascript +var _ = require('underscore'); + +// Import Underscore.string to separate object, because there are conflict functions (include, reverse, contains) +_.str = require('underscore.string'); + +// Mix in non-conflict functions to Underscore namespace if you want +_.mixin(_.str.exports()); + +// All functions, include conflict, will be available through _.str object +_.str.include('Underscore.string', 'string'); // => true +``` + +## String Functions ## + +For availability of functions in this way you need to mix in Underscore.string functions: + +```javascript +_.mixin(_.string.exports()); +``` + +otherwise functions from examples will be available through _.string or _.str objects: + +```javascript +_.str.capitalize('epeli') +=> "Epeli" +``` + +**numberFormat** _.numberFormat(number, [ decimals=0, decimalSeparator='.', orderSeparator=',']) + +Formats the numbers. + +```javascript +_.numberFormat(1000, 2) +=> "1,000.00" + +_.numberFormat(123456789.123, 5, '.', ',') +=> "123,456,789.12300" +``` + + +**levenshtein** _.levenshtein(string1, string2) + +Calculates [Levenshtein distance][ld] between two strings. +[ld]: http://en.wikipedia.org/wiki/Levenshtein_distance + +```javascript +_.levenshtein('kitten', 'kittah') +=> 2 +``` + +**capitalize** _.capitalize(string) + +Converts first letter of the string to uppercase. + +```javascript +_.capitalize("foo Bar") +=> "Foo Bar" +``` + +**chop** _.chop(string, step) + +```javascript +_.chop('whitespace', 3) +=> ['whi','tes','pac','e'] +``` + +**clean** _.clean(str) + +Compress some whitespaces to one. + +```javascript +_.clean(" foo bar ") +=> 'foo bar' +``` + +**chars** _.chars(str) + +```javascript +_.chars('Hello') +=> ['H','e','l','l','o'] +``` + +**swapCase** _.swapCase(str) + +Returns a copy of the string in which all the case-based characters have had their case swapped. + +```javascript +_.swapCase('hELLO') +=> 'Hello' +``` + +**include** available only through _.str object, because Underscore has function with the same name. + +```javascript +_.str.include("foobar", "ob") +=> true +``` + +(removed) **includes** _.includes(string, substring) + +Tests if string contains a substring. + +```javascript +_.includes("foobar", "ob") +=> true +``` + +**includes** function was removed + +But you can create it in this way, for compatibility with previous versions: + +```javascript +_.includes = _.str.include +``` + +**count** _.count(string, substring) + +```javascript +_('Hello world').count('l') +=> 3 +``` + +**escapeHTML** _.escapeHTML(string) + +Converts HTML special characters to their entity equivalents. + +```javascript +_('
    Blah blah blah
    ').escapeHTML(); +=> '<div>Blah blah blah</div>' +``` + +**unescapeHTML** _.unescapeHTML(string) + +Converts entity characters to HTML equivalents. + +```javascript +_('<div>Blah blah blah</div>').unescapeHTML(); +=> '
    Blah blah blah
    ' +``` + +**insert** _.insert(string, index, substing) + +```javascript +_('Hello ').insert(6, 'world') +=> 'Hello world' +``` + +**isBlank** _.isBlank(string) + +```javascript +_('').isBlank(); // => true +_('\n').isBlank(); // => true +_(' ').isBlank(); // => true +_('a').isBlank(); // => false +``` + +**join** _.join(separator, *strings) + +Joins strings together with given separator + +```javascript +_.join(" ", "foo", "bar") +=> "foo bar" +``` + +**lines** _.lines(str) + +```javascript +_.lines("Hello\nWorld") +=> ["Hello", "World"] +``` + +**reverse** available only through _.str object, because Underscore has function with the same name. + +Return reversed string: + +```javascript +_.str.reverse("foobar") +=> 'raboof' +``` + +**splice** _.splice(string, index, howmany, substring) + +Like a array splice. + +```javascript +_('https://edtsech@bitbucket.org/edtsech/underscore.strings').splice(30, 7, 'epeli') +=> 'https://edtsech@bitbucket.org/epeli/underscore.strings' +``` + +**startsWith** _.startsWith(string, starts) + +This method checks whether string starts with starts. + +```javascript +_("image.gif").startsWith("image") +=> true +``` + +**endsWith** _.endsWith(string, ends) + +This method checks whether string ends with ends. + +```javascript +_("image.gif").endsWith("gif") +=> true +``` + +**succ** _.succ(str) + +Returns the successor to str. + +```javascript +_('a').succ() +=> 'b' + +_('A').succ() +=> 'B' +``` + +**supplant** + +Supplant function was removed, use Underscore.js [template function][p]. + +[p]: http://documentcloud.github.com/underscore/#template + +**strip** alias for *trim* + +**lstrip** alias for *ltrim* + +**rstrip** alias for *rtrim* + +**titleize** _.titleize(string) + +```javascript +_('my name is epeli').titleize() +=> 'My Name Is Epeli' +``` + +**camelize** _.camelize(string) + +Converts underscored or dasherized string to a camelized one + +```javascript +_('-moz-transform').camelize() +=> 'MozTransform' +``` + +**classify** _.classify(string) + +Converts string to camelized class name + +```javascript +_('some_class_name').classify() +=> 'SomeClassName' +``` + +**underscored** _.underscored(string) + +Converts a camelized or dasherized string into an underscored one + +```javascript +_('MozTransform').underscored() +=> 'moz_transform' +``` + +**dasherize** _.dasherize(string) + +Converts a underscored or camelized string into an dasherized one + +```javascript +_('MozTransform').dasherize() +=> '-moz-transform' +``` + +**humanize** _.humanize(string) + +Converts an underscored, camelized, or dasherized string into a humanized one. +Also removes beginning and ending whitespace, and removes the postfix '_id'. + +```javascript +_(' capitalize dash-CamelCase_underscore trim ').humanize() +=> 'Capitalize dash camel case underscore trim' +``` + +**trim** _.trim(string, [characters]) + +trims defined characters from begining and ending of the string. +Defaults to whitespace characters. + +```javascript +_.trim(" foobar ") +=> "foobar" + +_.trim("_-foobar-_", "_-") +=> "foobar" +``` + + +**ltrim** _.ltrim(string, [characters]) + +Left trim. Similar to trim, but only for left side. + + +**rtrim** _.rtrim(string, [characters]) + +Right trim. Similar to trim, but only for right side. + +**truncate** _.truncate(string, length, truncateString) + +```javascript +_('Hello world').truncate(5) +=> 'Hello...' + +_('Hello').truncate(10) +=> 'Hello' +``` + +**prune** _.prune(string, length, pruneString) + +Elegant version of truncate. +Makes sure the pruned string does not exceed the original length. +Avoid half-chopped words when truncating. + +```javascript +_('Hello, world').prune(5) +=> 'Hello...' + +_('Hello, world').prune(8) +=> 'Hello...' + +_('Hello, world').prune(5, ' (read a lot more)') +=> 'Hello, world' (as adding "(read a lot more)" would be longer than the original string) + +_('Hello, cruel world').prune(15) +=> 'Hello, cruel...' + +_('Hello').prune(10) +=> 'Hello' +``` + +**words** _.words(str, delimiter=/\s+/) + +Split string by delimiter (String or RegExp), /\s+/ by default. + +```javascript +_.words(" I love you ") +=> ["I","love","you"] + +_.words("I_love_you", "_") +=> ["I","love","you"] + +_.words("I-love-you", /-/) +=> ["I","love","you"] + +_.words(" ") +=> [] +``` + +**sprintf** _.sprintf(string format, *arguments) + +C like string formatting. +Credits goes to [Alexandru Marasteanu][o]. +For more detailed documentation, see the [original page][o]. + +[o]: http://www.diveintojavascript.com/projects/sprintf-for-javascript + +```javascript +_.sprintf("%.1f", 1.17) +"1.2" +``` + +**pad** _.pad(str, length, [padStr, type]) + +pads the `str` with characters until the total string length is equal to the passed `length` parameter. By default, pads on the **left** with the space char (`" "`). `padStr` is truncated to a single character if necessary. + +```javascript +_.pad("1", 8) +-> " 1"; + +_.pad("1", 8, '0') +-> "00000001"; + +_.pad("1", 8, '0', 'right') +-> "10000000"; + +_.pad("1", 8, '0', 'both') +-> "00001000"; + +_.pad("1", 8, 'bleepblorp', 'both') +-> "bbbb1bbb"; +``` + +**lpad** _.lpad(str, length, [padStr]) + +left-pad a string. Alias for `pad(str, length, padStr, 'left')` + +```javascript +_.lpad("1", 8, '0') +-> "00000001"; +``` + +**rpad** _.rpad(str, length, [padStr]) + +right-pad a string. Alias for `pad(str, length, padStr, 'right')` + +```javascript +_.rpad("1", 8, '0') +-> "10000000"; +``` + +**lrpad** _.lrpad(str, length, [padStr]) + +left/right-pad a string. Alias for `pad(str, length, padStr, 'both')` + +```javascript +_.lrpad("1", 8, '0') +-> "00001000"; +``` + +**center** alias for **lrpad** + +**ljust** alias for *rpad* + +**rjust** alias for *lpad* + +**toNumber** _.toNumber(string, [decimals]) + +Parse string to number. Returns NaN if string can't be parsed to number. + +```javascript +_('2.556').toNumber() +=> 3 + +_('2.556').toNumber(1) +=> 2.6 +``` + +**strRight** _.strRight(string, pattern) + +Searches a string from left to right for a pattern and returns a substring consisting of the characters in the string that are to the right of the pattern or all string if no match found. + +```javascript +_('This_is_a_test_string').strRight('_') +=> "is_a_test_string"; +``` + +**strRightBack** _.strRightBack(string, pattern) + +Searches a string from right to left for a pattern and returns a substring consisting of the characters in the string that are to the right of the pattern or all string if no match found. + +```javascript +_('This_is_a_test_string').strRightBack('_') +=> "string"; +``` + +**strLeft** _.strLeft(string, pattern) + +Searches a string from left to right for a pattern and returns a substring consisting of the characters in the string that are to the left of the pattern or all string if no match found. + +```javascript +_('This_is_a_test_string').strLeft('_') +=> "This"; +``` + +**strLeftBack** _.strLeftBack(string, pattern) + +Searches a string from right to left for a pattern and returns a substring consisting of the characters in the string that are to the left of the pattern or all string if no match found. + +```javascript +_('This_is_a_test_string').strLeftBack('_') +=> "This_is_a_test"; +``` + +**stripTags** + +Removes all html tags from string. + +```javascript +_('a link').stripTags() +=> 'a link' + +_('a link').stripTags() +=> 'a linkalert("hello world!")' +``` + +**toSentence** _.toSentence(array, [delimiter, lastDelimiter]) + +Join an array into a human readable sentence. + +```javascript +_.toSentence(['jQuery', 'Mootools', 'Prototype']) +=> 'jQuery, Mootools and Prototype'; + +_.toSentence(['jQuery', 'Mootools', 'Prototype'], ', ', ' unt ') +=> 'jQuery, Mootools unt Prototype'; +``` + +**toSentenceSerial** _.toSentenceSerial(array, [delimiter, lastDelimiter]) + +The same as `toSentence`, but adjusts delimeters to use [Serial comma](http://en.wikipedia.org/wiki/Serial_comma). + +```javascript +_.toSentenceSerial(['jQuery', 'Mootools']) +=> 'jQuery and Mootools'; + +_.toSentenceSerial(['jQuery', 'Mootools', 'Prototype']) +=> 'jQuery, Mootools, and Prototype' + +_.toSentenceSerial(['jQuery', 'Mootools', 'Prototype'], ', ', ' unt '); +=> 'jQuery, Mootools, unt Prototype'; +``` + +**repeat** _.repeat(string, count, [separator]) + +Repeats a string count times. + +```javascript +_.repeat("foo", 3) +=> 'foofoofoo'; + +_.repeat("foo", 3, "bar") +=> 'foobarfoobarfoo' +``` + +**surround** _.surround(string, wrap) + +Surround a string with another string. + +```javascript +_.surround("foo", "ab") +=> 'abfooab'; +``` + +**quote** _.quote(string) or _.q(string) + +Quotes a string. + +```javascript +_.quote('foo') +=> '"foo"'; +``` + + +**slugify** _.slugify(string) + +Transform text into a URL slug. Replaces whitespaces, accentuated, and special characters with a dash. + +```javascript +_.slugify("Un éléphant à l'orée du bois") +=> 'un-elephant-a-loree-du-bois'; +``` + +***Caution: this function is charset dependent*** + +## Roadmap ## + +Any suggestions or bug reports are welcome. Just email me or more preferably open an issue. + +#### Problems + +We lose two things for `include` and `reverse` methods from `_.string`: + +* Calls like `_('foobar').include('bar')` aren't available; +* Chaining isn't available too. + +But if you need this functionality you can create aliases for conflict functions which will be convenient for you: + +```javascript +_.mixin({ + includeString: _.str.include, + reverseString: _.str.reverse +}) + +// Now wrapper calls and chaining are available. +_('foobar').chain().reverseString().includeString('rab').value() +``` + +#### Standalone Usage + +If you are using Underscore.string without Underscore. You also have `_.string` namespace for it and `_.str` alias +But of course you can just reassign `_` variable with `_.string` + +```javascript +_ = _.string +``` + +## Changelog ## + +### 2.3.1 ### + +* Changed integration logic, now trying everything in order +* Fixed classify method to chew some unexpected input +* Fixed toNumber method failing to recognize '0.0' as a proper number + + +### 2.3.0 ### + +* Added `numberformat` method +* Added `levenshtein` method (Levenshtein distance calculation) +* Added `swapCase` method +* Changed default behavior of `words` method +* Added `toSentenceSerial` method +* Added `surround` and `quote` methods + +### 2.2.0 ### + +* Capitalize method behavior changed +* Various perfomance tweaks + +### 2.1.1### + +* Fixed words method bug +* Added classify method + +### 2.1.0 ### + +* AMD support +* Added toSentence method +* Added slugify method +* Lots of speed optimizations + +### 2.0.0 ### + +* Added prune, humanize functions +* Added _.string (_.str) namespace for Underscore.string library +* Removed includes function + +For upgrading to this version you need to mix in Underscore.string library to Underscore object: + +```javascript +_.mixin(_.string.exports()); +``` + +and all non-conflict Underscore.string functions will be available through Underscore object. +Also function `includes` has been removed, you should replace this function by `_.str.include` +or create alias `_.includes = _.str.include` and all your code will work fine. + +### 1.1.6 ### + +* Fixed reverse and truncate +* Added isBlank, stripTags, inlude(alias for includes) +* Added uglifier compression + +### 1.1.5 ### + +* Added strRight, strRightBack, strLeft, strLeftBack + +### 1.1.4 ### + +* Added pad, lpad, rpad, lrpad methods and aliases center, ljust, rjust +* Integration with Underscore 1.1.6 + +### 1.1.3 ### + +* Added methods: underscored, camelize, dasherize +* Support newer version of npm + +### 1.1.2 ### + +* Created functions: lines, chars, words functions + +### 1.0.2 ### + +* Created integration test suite with underscore.js 1.1.4 (now it's absolutely compatible) +* Removed 'reverse' function, because this function override underscore.js 'reverse' + +## Contribute ## + +* Fork & pull request. Don't forget about tests. +* If you planning add some feature please create issue before. + +Otherwise changes will be rejected. + +## Contributors list ## +[Can be found here](https://github.com/epeli/underscore.string/graphs/contributors). + + +## Licence ## + +The MIT License + +Copyright (c) 2011 Esa-Matti Suuronen esa-matti@suuronen.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/Rakefile b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/Rakefile new file mode 100644 index 00000000..587c81b7 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/Rakefile @@ -0,0 +1,23 @@ +# encoding: utf-8 +task default: :test + +desc 'Use UglifyJS to compress Underscore.string' +task :build do + require 'uglifier' + source = File.read('lib/underscore.string.js') + compressed = Uglifier.compile(source, copyright: false) + File.open('dist/underscore.string.min.js', 'w'){ |f| f.write compressed } + compression_rate = compressed.length.to_f/source.length + puts "compressed dist/underscore.string.min.js: #{compressed.length}/#{source.length} #{(compression_rate * 100).round}%" +end + +desc 'Run tests' +task :test do + puts "Running underscore.string test suite." + result1 = system %{phantomjs ./test/run-qunit.js "test/test.html"} + + puts "Running Underscore test suite." + result2 = system %{phantomjs ./test/run-qunit.js "test/test_underscore/index.html"} + + exit(result1 && result2 ? 0 : 1) +end \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/package.json b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/package.json new file mode 100644 index 00000000..51f52829 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/package.json @@ -0,0 +1,77 @@ +{ + "name": "underscore.string", + "version": "2.3.1", + "description": "String manipulation extensions for Underscore.js javascript library.", + "homepage": "http://epeli.github.com/underscore.string/", + "contributors": [ + { + "name": "Esa-Matti Suuronen", + "email": "esa-matti@suuronen.org", + "url": "http://esa-matti.suuronen.org/" + }, + { + "name": "Edward Tsech", + "email": "edtsech@gmail.com" + }, + { + "name": "Pavel Pravosud", + "email": "pavel@pravosud.com", + "url": "" + }, + { + "name": "Sasha Koss", + "email": "kossnocorp@gmail.com", + "url": "http://koss.nocorp.me/" + }, + { + "name": "Vladimir Dronnikov", + "email": "dronnikov@gmail.com" + }, + { + "name": "Pete Kruckenberg", + "email": "https://github.com/kruckenb", + "url": "" + }, + { + "name": "Paul Chavard", + "email": "paul@chavard.net", + "url": "" + }, + { + "name": "Ed Finkler", + "email": "coj@funkatron.com", + "url": "" + } + ], + "keywords": [ + "underscore", + "string" + ], + "main": "./lib/underscore.string", + "directories": { + "lib": "./lib" + }, + "engines": { + "node": "*" + }, + "repository": { + "type": "git", + "url": "https://github.com/epeli/underscore.string.git" + }, + "bugs": { + "url": "https://github.com/epeli/underscore.string/issues" + }, + "licenses": [ + { + "type": "MIT" + } + ], + "readme": "# Underscore.string [![Build Status](https://secure.travis-ci.org/epeli/underscore.string.png?branch=master)](http://travis-ci.org/epeli/underscore.string) #\n\n\n\nJavascript lacks complete string manipulation operations.\nThis an attempt to fill that gap. List of build-in methods can be found\nfor example from [Dive Into JavaScript][d].\n\n[d]: http://www.diveintojavascript.com/core-javascript-reference/the-string-object\n\n\nAs name states this an extension for [Underscore.js][u], but it can be used\nindependently from **_s**-global variable. But with Underscore.js you can\nuse Object-Oriented style and chaining:\n\n[u]: http://documentcloud.github.com/underscore/\n\n```javascript\n_(\" epeli \").chain().trim().capitalize().value()\n=> \"Epeli\"\n```\n\n## Download ##\n\n * [Development version](https://raw.github.com/epeli/underscore.string/master/lib/underscore.string.js) *Uncompressed with Comments 18kb*\n * [Production version](https://github.com/epeli/underscore.string/raw/master/dist/underscore.string.min.js) *Minified 7kb*\n\n\n## Node.js installation ##\n\n**npm package**\n\n npm install underscore.string\n\n**Standalone usage**:\n\n```javascript\nvar _s = require('underscore.string');\n```\n\n**Integrate with Underscore.js**:\n\n```javascript\nvar _ = require('underscore');\n\n// Import Underscore.string to separate object, because there are conflict functions (include, reverse, contains)\n_.str = require('underscore.string');\n\n// Mix in non-conflict functions to Underscore namespace if you want\n_.mixin(_.str.exports());\n\n// All functions, include conflict, will be available through _.str object\n_.str.include('Underscore.string', 'string'); // => true\n```\n\n## String Functions ##\n\nFor availability of functions in this way you need to mix in Underscore.string functions:\n\n```javascript\n_.mixin(_.string.exports());\n```\n\notherwise functions from examples will be available through _.string or _.str objects:\n\n```javascript\n_.str.capitalize('epeli')\n=> \"Epeli\"\n```\n\n**numberFormat** _.numberFormat(number, [ decimals=0, decimalSeparator='.', orderSeparator=','])\n\nFormats the numbers.\n\n```javascript\n_.numberFormat(1000, 2)\n=> \"1,000.00\"\n\n_.numberFormat(123456789.123, 5, '.', ',')\n=> \"123,456,789.12300\"\n```\n\n\n**levenshtein** _.levenshtein(string1, string2)\n\nCalculates [Levenshtein distance][ld] between two strings.\n[ld]: http://en.wikipedia.org/wiki/Levenshtein_distance\n\n```javascript\n_.levenshtein('kitten', 'kittah')\n=> 2\n```\n\n**capitalize** _.capitalize(string)\n\nConverts first letter of the string to uppercase.\n\n```javascript\n_.capitalize(\"foo Bar\")\n=> \"Foo Bar\"\n```\n\n**chop** _.chop(string, step)\n\n```javascript\n_.chop('whitespace', 3)\n=> ['whi','tes','pac','e']\n```\n\n**clean** _.clean(str)\n\nCompress some whitespaces to one.\n\n```javascript\n_.clean(\" foo bar \")\n=> 'foo bar'\n```\n\n**chars** _.chars(str)\n\n```javascript\n_.chars('Hello')\n=> ['H','e','l','l','o']\n```\n\n**swapCase** _.swapCase(str)\n\nReturns a copy of the string in which all the case-based characters have had their case swapped.\n\n```javascript\n_.swapCase('hELLO')\n=> 'Hello'\n```\n\n**include** available only through _.str object, because Underscore has function with the same name.\n\n```javascript\n_.str.include(\"foobar\", \"ob\")\n=> true\n```\n\n(removed) **includes** _.includes(string, substring)\n\nTests if string contains a substring.\n\n```javascript\n_.includes(\"foobar\", \"ob\")\n=> true\n```\n\n**includes** function was removed\n\nBut you can create it in this way, for compatibility with previous versions:\n\n```javascript\n_.includes = _.str.include\n```\n\n**count** _.count(string, substring)\n\n```javascript\n_('Hello world').count('l')\n=> 3\n```\n\n**escapeHTML** _.escapeHTML(string)\n\nConverts HTML special characters to their entity equivalents.\n\n```javascript\n_('
    Blah blah blah
    ').escapeHTML();\n=> '<div>Blah blah blah</div>'\n```\n\n**unescapeHTML** _.unescapeHTML(string)\n\nConverts entity characters to HTML equivalents.\n\n```javascript\n_('<div>Blah blah blah</div>').unescapeHTML();\n=> '
    Blah blah blah
    '\n```\n\n**insert** _.insert(string, index, substing)\n\n```javascript\n_('Hello ').insert(6, 'world')\n=> 'Hello world'\n```\n\n**isBlank** _.isBlank(string)\n\n```javascript\n_('').isBlank(); // => true\n_('\\n').isBlank(); // => true\n_(' ').isBlank(); // => true\n_('a').isBlank(); // => false\n```\n\n**join** _.join(separator, *strings)\n\nJoins strings together with given separator\n\n```javascript\n_.join(\" \", \"foo\", \"bar\")\n=> \"foo bar\"\n```\n\n**lines** _.lines(str)\n\n```javascript\n_.lines(\"Hello\\nWorld\")\n=> [\"Hello\", \"World\"]\n```\n\n**reverse** available only through _.str object, because Underscore has function with the same name.\n\nReturn reversed string:\n\n```javascript\n_.str.reverse(\"foobar\")\n=> 'raboof'\n```\n\n**splice** _.splice(string, index, howmany, substring)\n\nLike a array splice.\n\n```javascript\n_('https://edtsech@bitbucket.org/edtsech/underscore.strings').splice(30, 7, 'epeli')\n=> 'https://edtsech@bitbucket.org/epeli/underscore.strings'\n```\n\n**startsWith** _.startsWith(string, starts)\n\nThis method checks whether string starts with starts.\n\n```javascript\n_(\"image.gif\").startsWith(\"image\")\n=> true\n```\n\n**endsWith** _.endsWith(string, ends)\n\nThis method checks whether string ends with ends.\n\n```javascript\n_(\"image.gif\").endsWith(\"gif\")\n=> true\n```\n\n**succ** _.succ(str)\n\nReturns the successor to str.\n\n```javascript\n_('a').succ()\n=> 'b'\n\n_('A').succ()\n=> 'B'\n```\n\n**supplant**\n\nSupplant function was removed, use Underscore.js [template function][p].\n\n[p]: http://documentcloud.github.com/underscore/#template\n\n**strip** alias for *trim*\n\n**lstrip** alias for *ltrim*\n\n**rstrip** alias for *rtrim*\n\n**titleize** _.titleize(string)\n\n```javascript\n_('my name is epeli').titleize()\n=> 'My Name Is Epeli'\n```\n\n**camelize** _.camelize(string)\n\nConverts underscored or dasherized string to a camelized one\n\n```javascript\n_('-moz-transform').camelize()\n=> 'MozTransform'\n```\n\n**classify** _.classify(string)\n\nConverts string to camelized class name\n\n```javascript\n_('some_class_name').classify()\n=> 'SomeClassName'\n```\n\n**underscored** _.underscored(string)\n\nConverts a camelized or dasherized string into an underscored one\n\n```javascript\n_('MozTransform').underscored()\n=> 'moz_transform'\n```\n\n**dasherize** _.dasherize(string)\n\nConverts a underscored or camelized string into an dasherized one\n\n```javascript\n_('MozTransform').dasherize()\n=> '-moz-transform'\n```\n\n**humanize** _.humanize(string)\n\nConverts an underscored, camelized, or dasherized string into a humanized one.\nAlso removes beginning and ending whitespace, and removes the postfix '_id'.\n\n```javascript\n_(' capitalize dash-CamelCase_underscore trim ').humanize()\n=> 'Capitalize dash camel case underscore trim'\n```\n\n**trim** _.trim(string, [characters])\n\ntrims defined characters from begining and ending of the string.\nDefaults to whitespace characters.\n\n```javascript\n_.trim(\" foobar \")\n=> \"foobar\"\n\n_.trim(\"_-foobar-_\", \"_-\")\n=> \"foobar\"\n```\n\n\n**ltrim** _.ltrim(string, [characters])\n\nLeft trim. Similar to trim, but only for left side.\n\n\n**rtrim** _.rtrim(string, [characters])\n\nRight trim. Similar to trim, but only for right side.\n\n**truncate** _.truncate(string, length, truncateString)\n\n```javascript\n_('Hello world').truncate(5)\n=> 'Hello...'\n\n_('Hello').truncate(10)\n=> 'Hello'\n```\n\n**prune** _.prune(string, length, pruneString)\n\nElegant version of truncate.\nMakes sure the pruned string does not exceed the original length.\nAvoid half-chopped words when truncating.\n\n```javascript\n_('Hello, world').prune(5)\n=> 'Hello...'\n\n_('Hello, world').prune(8)\n=> 'Hello...'\n\n_('Hello, world').prune(5, ' (read a lot more)')\n=> 'Hello, world' (as adding \"(read a lot more)\" would be longer than the original string)\n\n_('Hello, cruel world').prune(15)\n=> 'Hello, cruel...'\n\n_('Hello').prune(10)\n=> 'Hello'\n```\n\n**words** _.words(str, delimiter=/\\s+/)\n\nSplit string by delimiter (String or RegExp), /\\s+/ by default.\n\n```javascript\n_.words(\" I love you \")\n=> [\"I\",\"love\",\"you\"]\n\n_.words(\"I_love_you\", \"_\")\n=> [\"I\",\"love\",\"you\"]\n\n_.words(\"I-love-you\", /-/)\n=> [\"I\",\"love\",\"you\"]\n\n_.words(\" \")\n=> []\n```\n\n**sprintf** _.sprintf(string format, *arguments)\n\nC like string formatting.\nCredits goes to [Alexandru Marasteanu][o].\nFor more detailed documentation, see the [original page][o].\n\n[o]: http://www.diveintojavascript.com/projects/sprintf-for-javascript\n\n```javascript\n_.sprintf(\"%.1f\", 1.17)\n\"1.2\"\n```\n\n**pad** _.pad(str, length, [padStr, type])\n\npads the `str` with characters until the total string length is equal to the passed `length` parameter. By default, pads on the **left** with the space char (`\" \"`). `padStr` is truncated to a single character if necessary.\n\n```javascript\n_.pad(\"1\", 8)\n-> \" 1\";\n\n_.pad(\"1\", 8, '0')\n-> \"00000001\";\n\n_.pad(\"1\", 8, '0', 'right')\n-> \"10000000\";\n\n_.pad(\"1\", 8, '0', 'both')\n-> \"00001000\";\n\n_.pad(\"1\", 8, 'bleepblorp', 'both')\n-> \"bbbb1bbb\";\n```\n\n**lpad** _.lpad(str, length, [padStr])\n\nleft-pad a string. Alias for `pad(str, length, padStr, 'left')`\n\n```javascript\n_.lpad(\"1\", 8, '0')\n-> \"00000001\";\n```\n\n**rpad** _.rpad(str, length, [padStr])\n\nright-pad a string. Alias for `pad(str, length, padStr, 'right')`\n\n```javascript\n_.rpad(\"1\", 8, '0')\n-> \"10000000\";\n```\n\n**lrpad** _.lrpad(str, length, [padStr])\n\nleft/right-pad a string. Alias for `pad(str, length, padStr, 'both')`\n\n```javascript\n_.lrpad(\"1\", 8, '0')\n-> \"00001000\";\n```\n\n**center** alias for **lrpad**\n\n**ljust** alias for *rpad*\n\n**rjust** alias for *lpad*\n\n**toNumber** _.toNumber(string, [decimals])\n\nParse string to number. Returns NaN if string can't be parsed to number.\n\n```javascript\n_('2.556').toNumber()\n=> 3\n\n_('2.556').toNumber(1)\n=> 2.6\n```\n\n**strRight** _.strRight(string, pattern)\n\nSearches a string from left to right for a pattern and returns a substring consisting of the characters in the string that are to the right of the pattern or all string if no match found.\n\n```javascript\n_('This_is_a_test_string').strRight('_')\n=> \"is_a_test_string\";\n```\n\n**strRightBack** _.strRightBack(string, pattern)\n\nSearches a string from right to left for a pattern and returns a substring consisting of the characters in the string that are to the right of the pattern or all string if no match found.\n\n```javascript\n_('This_is_a_test_string').strRightBack('_')\n=> \"string\";\n```\n\n**strLeft** _.strLeft(string, pattern)\n\nSearches a string from left to right for a pattern and returns a substring consisting of the characters in the string that are to the left of the pattern or all string if no match found.\n\n```javascript\n_('This_is_a_test_string').strLeft('_')\n=> \"This\";\n```\n\n**strLeftBack** _.strLeftBack(string, pattern)\n\nSearches a string from right to left for a pattern and returns a substring consisting of the characters in the string that are to the left of the pattern or all string if no match found.\n\n```javascript\n_('This_is_a_test_string').strLeftBack('_')\n=> \"This_is_a_test\";\n```\n\n**stripTags**\n\nRemoves all html tags from string.\n\n```javascript\n_('a link').stripTags()\n=> 'a link'\n\n_('a link').stripTags()\n=> 'a linkalert(\"hello world!\")'\n```\n\n**toSentence** _.toSentence(array, [delimiter, lastDelimiter])\n\nJoin an array into a human readable sentence.\n\n```javascript\n_.toSentence(['jQuery', 'Mootools', 'Prototype'])\n=> 'jQuery, Mootools and Prototype';\n\n_.toSentence(['jQuery', 'Mootools', 'Prototype'], ', ', ' unt ')\n=> 'jQuery, Mootools unt Prototype';\n```\n\n**toSentenceSerial** _.toSentenceSerial(array, [delimiter, lastDelimiter])\n\nThe same as `toSentence`, but adjusts delimeters to use [Serial comma](http://en.wikipedia.org/wiki/Serial_comma).\n\n```javascript\n_.toSentenceSerial(['jQuery', 'Mootools'])\n=> 'jQuery and Mootools';\n\n_.toSentenceSerial(['jQuery', 'Mootools', 'Prototype'])\n=> 'jQuery, Mootools, and Prototype'\n\n_.toSentenceSerial(['jQuery', 'Mootools', 'Prototype'], ', ', ' unt ');\n=> 'jQuery, Mootools, unt Prototype';\n```\n\n**repeat** _.repeat(string, count, [separator])\n\nRepeats a string count times.\n\n```javascript\n_.repeat(\"foo\", 3)\n=> 'foofoofoo';\n\n_.repeat(\"foo\", 3, \"bar\")\n=> 'foobarfoobarfoo'\n```\n\n**surround** _.surround(string, wrap)\n\nSurround a string with another string.\n\n```javascript\n_.surround(\"foo\", \"ab\")\n=> 'abfooab';\n```\n\n**quote** _.quote(string) or _.q(string)\n\nQuotes a string.\n\n```javascript\n_.quote('foo')\n=> '\"foo\"';\n```\n\n\n**slugify** _.slugify(string)\n\nTransform text into a URL slug. Replaces whitespaces, accentuated, and special characters with a dash.\n\n```javascript\n_.slugify(\"Un éléphant à l'orée du bois\")\n=> 'un-elephant-a-loree-du-bois';\n```\n\n***Caution: this function is charset dependent***\n\n## Roadmap ##\n\nAny suggestions or bug reports are welcome. Just email me or more preferably open an issue.\n\n#### Problems\n\nWe lose two things for `include` and `reverse` methods from `_.string`:\n\n* Calls like `_('foobar').include('bar')` aren't available;\n* Chaining isn't available too.\n\nBut if you need this functionality you can create aliases for conflict functions which will be convenient for you:\n\n```javascript\n_.mixin({\n includeString: _.str.include,\n reverseString: _.str.reverse\n})\n\n// Now wrapper calls and chaining are available.\n_('foobar').chain().reverseString().includeString('rab').value()\n```\n\n#### Standalone Usage\n\nIf you are using Underscore.string without Underscore. You also have `_.string` namespace for it and `_.str` alias\nBut of course you can just reassign `_` variable with `_.string`\n\n```javascript\n_ = _.string\n```\n\n## Changelog ##\n\n### 2.3.1 ###\n\n* Changed integration logic, now trying everything in order\n* Fixed classify method to chew some unexpected input\n* Fixed toNumber method failing to recognize '0.0' as a proper number\n\n\n### 2.3.0 ###\n\n* Added `numberformat` method\n* Added `levenshtein` method (Levenshtein distance calculation)\n* Added `swapCase` method\n* Changed default behavior of `words` method\n* Added `toSentenceSerial` method\n* Added `surround` and `quote` methods\n\n### 2.2.0 ###\n\n* Capitalize method behavior changed\n* Various perfomance tweaks\n\n### 2.1.1###\n\n* Fixed words method bug\n* Added classify method\n\n### 2.1.0 ###\n\n* AMD support\n* Added toSentence method\n* Added slugify method\n* Lots of speed optimizations\n\n### 2.0.0 ###\n\n* Added prune, humanize functions\n* Added _.string (_.str) namespace for Underscore.string library\n* Removed includes function\n\nFor upgrading to this version you need to mix in Underscore.string library to Underscore object:\n\n```javascript\n_.mixin(_.string.exports());\n```\n\nand all non-conflict Underscore.string functions will be available through Underscore object.\nAlso function `includes` has been removed, you should replace this function by `_.str.include`\nor create alias `_.includes = _.str.include` and all your code will work fine.\n\n### 1.1.6 ###\n\n* Fixed reverse and truncate\n* Added isBlank, stripTags, inlude(alias for includes)\n* Added uglifier compression\n\n### 1.1.5 ###\n\n* Added strRight, strRightBack, strLeft, strLeftBack\n\n### 1.1.4 ###\n\n* Added pad, lpad, rpad, lrpad methods and aliases center, ljust, rjust\n* Integration with Underscore 1.1.6\n\n### 1.1.3 ###\n\n* Added methods: underscored, camelize, dasherize\n* Support newer version of npm\n\n### 1.1.2 ###\n\n* Created functions: lines, chars, words functions\n\n### 1.0.2 ###\n\n* Created integration test suite with underscore.js 1.1.4 (now it's absolutely compatible)\n* Removed 'reverse' function, because this function override underscore.js 'reverse'\n\n## Contribute ##\n\n* Fork & pull request. Don't forget about tests.\n* If you planning add some feature please create issue before.\n\nOtherwise changes will be rejected.\n\n## Contributors list ##\n[Can be found here](https://github.com/epeli/underscore.string/graphs/contributors).\n\n\n## Licence ##\n\nThe MIT License\n\nCopyright (c) 2011 Esa-Matti Suuronen esa-matti@suuronen.org\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n", + "readmeFilename": "README.markdown", + "_id": "underscore.string@2.3.1", + "dist": { + "shasum": "deb7588dfa2f252ee47e4516edafbef4ff97ec22" + }, + "_from": "underscore.string@~2.3.1", + "_resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.3.1.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test.html b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test.html new file mode 100644 index 00000000..c959a3a3 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test.html @@ -0,0 +1,31 @@ + + + + + Underscore.strings Test Suite + + + + + + + + + + +

    Underscore.string Test Suite

    +

    +

    +
      +
      +

      Underscore.string Speed Suite

      + +
      + + diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_standalone.html b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_standalone.html new file mode 100644 index 00000000..9854c171 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_standalone.html @@ -0,0 +1,18 @@ + + + + Underscore.strings Test Suite + + + + + + + + +

      Underscore.string Test Suite

      +

      +

      +
        + + diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/index.html b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/index.html new file mode 100644 index 00000000..064fa986 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/index.html @@ -0,0 +1,45 @@ + + + + Underscore Test Suite + + + + + + + + + + + + + + + + +
        +
        +
        +
        +
        +
        +
        +
        +

        Underscore Speed Suite

        +

        + A representative sample of the functions are benchmarked here, to provide + a sense of how fast they might run in different browsers. + Each iteration runs on an array of 1000 elements.

        + For example, the 'intersection' test measures the number of times you can + find the intersection of two thousand-element arrays in one second. +

        +
        + + + diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/vendor/qunit.css b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/vendor/qunit.css new file mode 100644 index 00000000..55970e00 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/test/test_underscore/vendor/qunit.css @@ -0,0 +1,235 @@ +/** + * QUnit v1.10.0 - A JavaScript Unit Testing Framework + * + * http://qunitjs.com + * + * Copyright 2012 jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ + +/** Font Family and Sizes */ + +#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult { + font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif; +} + +#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; } +#qunit-tests { font-size: smaller; } + + +/** Resets */ + +#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter { + margin: 0; + padding: 0; +} + + +/** Header */ + +#qunit-header { + padding: 0.5em 0 0.5em 1em; + + color: #8699a4; + background-color: #0d3349; + + font-size: 1.5em; + line-height: 1em; + font-weight: normal; + + border-radius: 5px 5px 0 0; + -moz-border-radius: 5px 5px 0 0; + -webkit-border-top-right-radius: 5px; + -webkit-border-top-left-radius: 5px; +} + +#qunit-header a { + text-decoration: none; + color: #c2ccd1; +} + +#qunit-header a:hover, +#qunit-header a:focus { + color: #fff; +} + +#qunit-testrunner-toolbar label { + display: inline-block; + padding: 0 .5em 0 .1em; +} + +#qunit-banner { + height: 5px; +} + +#qunit-testrunner-toolbar { + padding: 0.5em 0 0.5em 2em; + color: #5E740B; + background-color: #eee; + overflow: hidden; +} + +#qunit-userAgent { + padding: 0.5em 0 0.5em 2.5em; + background-color: #2b81af; + color: #fff; + text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px; +} + +#qunit-modulefilter-container { + float: right; +} + +/** Tests: Pass/Fail */ + +#qunit-tests { + list-style-position: inside; +} + +#qunit-tests li { + padding: 0.4em 0.5em 0.4em 2.5em; + border-bottom: 1px solid #fff; + list-style-position: inside; +} + +#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running { + display: none; +} + +#qunit-tests li strong { + cursor: pointer; +} + +#qunit-tests li a { + padding: 0.5em; + color: #c2ccd1; + text-decoration: none; +} +#qunit-tests li a:hover, +#qunit-tests li a:focus { + color: #000; +} + +#qunit-tests ol { + margin-top: 0.5em; + padding: 0.5em; + + background-color: #fff; + + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; +} + +#qunit-tests table { + border-collapse: collapse; + margin-top: .2em; +} + +#qunit-tests th { + text-align: right; + vertical-align: top; + padding: 0 .5em 0 0; +} + +#qunit-tests td { + vertical-align: top; +} + +#qunit-tests pre { + margin: 0; + white-space: pre-wrap; + word-wrap: break-word; +} + +#qunit-tests del { + background-color: #e0f2be; + color: #374e0c; + text-decoration: none; +} + +#qunit-tests ins { + background-color: #ffcaca; + color: #500; + text-decoration: none; +} + +/*** Test Counts */ + +#qunit-tests b.counts { color: black; } +#qunit-tests b.passed { color: #5E740B; } +#qunit-tests b.failed { color: #710909; } + +#qunit-tests li li { + padding: 5px; + background-color: #fff; + border-bottom: none; + list-style-position: inside; +} + +/*** Passing Styles */ + +#qunit-tests li li.pass { + color: #3c510c; + background-color: #fff; + border-left: 10px solid #C6E746; +} + +#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; } +#qunit-tests .pass .test-name { color: #366097; } + +#qunit-tests .pass .test-actual, +#qunit-tests .pass .test-expected { color: #999999; } + +#qunit-banner.qunit-pass { background-color: #C6E746; } + +/*** Failing Styles */ + +#qunit-tests li li.fail { + color: #710909; + background-color: #fff; + border-left: 10px solid #EE5757; + white-space: pre; +} + +#qunit-tests > li:last-child { + border-radius: 0 0 5px 5px; + -moz-border-radius: 0 0 5px 5px; + -webkit-border-bottom-right-radius: 5px; + -webkit-border-bottom-left-radius: 5px; +} + +#qunit-tests .fail { color: #000000; background-color: #EE5757; } +#qunit-tests .fail .test-name, +#qunit-tests .fail .module-name { color: #000000; } + +#qunit-tests .fail .test-actual { color: #EE5757; } +#qunit-tests .fail .test-expected { color: green; } + +#qunit-banner.qunit-fail { background-color: #EE5757; } + + +/** Result */ + +#qunit-testresult { + padding: 0.5em 0.5em 0.5em 2.5em; + + color: #2b81af; + background-color: #D2E0E6; + + border-bottom: 1px solid white; +} +#qunit-testresult .module-name { + font-weight: bold; +} + +/** Fixture */ + +#qunit-fixture { + position: absolute; + top: -10000px; + left: -10000px; + width: 1000px; + height: 1000px; +} diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/.npmignore b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/.npmignore new file mode 100644 index 00000000..4e5886de --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/.npmignore @@ -0,0 +1,4 @@ +test/ +Rakefile +docs/ +raw/ diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/.travis.yml b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/.travis.yml new file mode 100644 index 00000000..99dc7712 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - 0.8 +notifications: + email: false diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/CNAME b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/CNAME new file mode 100644 index 00000000..a007e65c --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/CNAME @@ -0,0 +1 @@ +underscorejs.org diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/CONTRIBUTING.md b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/CONTRIBUTING.md new file mode 100644 index 00000000..de5d5626 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/CONTRIBUTING.md @@ -0,0 +1,9 @@ +## How to contribute to Underscore.js + +* Before you open a ticket or send a pull request, [search](https://github.com/documentcloud/underscore/issues) for previous discussions about the same feature or issue. Add to the earlier ticket if you find one. + +* Before sending a pull request for a feature, be sure to have [tests](http://underscorejs.org/test/). + +* Use the same coding style as the rest of the [codebase](https://github.com/documentcloud/underscore/blob/master/underscore.js). + +* In your pull request, do not add documentation or re-build the minified `underscore-min.js` file. We'll do those things before cutting a new release. diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/LICENSE b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/LICENSE new file mode 100644 index 00000000..0d8dbe40 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2009-2013 Jeremy Ashkenas, DocumentCloud + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/README.md b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/README.md new file mode 100644 index 00000000..b1f3e50a --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/README.md @@ -0,0 +1,19 @@ + __ + /\ \ __ + __ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____ + /\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\ + \ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\ + \ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/ + \/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/ + \ \____/ + \/___/ + +Underscore.js is a utility-belt library for JavaScript that provides +support for the usual functional suspects (each, map, reduce, filter...) +without extending any core JavaScript objects. + +For Docs, License, Tests, and pre-packed downloads, see: +http://underscorejs.org + +Many thanks to our contributors: +https://github.com/documentcloud/underscore/contributors diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/favicon.ico b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/favicon.ico new file mode 100644 index 00000000..03049683 Binary files /dev/null and b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/favicon.ico differ diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/index.html b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/index.html new file mode 100644 index 00000000..8c5793ab --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/index.html @@ -0,0 +1,2467 @@ + + + + + + + + + Underscore.js + + + + + + +
        + +

        + +

        + +

        + Underscore is a + utility-belt library for JavaScript that provides a lot of the + functional programming support that you would expect in + Prototype.js + (or Ruby), + but without extending any of the built-in JavaScript objects. It's the + tie to go along with jQuery's tux, + and Backbone.js's suspenders. +

        + +

        + Underscore provides 80-odd functions that support both the usual + functional suspects: map, select, invoke — + as well as more specialized helpers: function binding, javascript + templating, deep equality testing, and so on. It delegates to built-in + functions, if present, so modern browsers will use the + native implementations of forEach, map, reduce, + filter, every, some and indexOf. +

        + +

        + A complete Test & Benchmark Suite + is included for your perusal. +

        + +

        + You may also read through the annotated source code. +

        + +

        + The project is + hosted on GitHub. + You can report bugs and discuss features on the + issues page, + on Freenode in the #documentcloud channel, + or send tweets to @documentcloud. +

        + +

        + Underscore is an open-source component of DocumentCloud. +

        + +

        Downloads (Right-click, and use "Save As")

        + + + + + + + + + + + + + + + + + +
        Development Version (1.4.4)40kb, Uncompressed with Plentiful Comments
        Production Version (1.4.4)4kb, Minified and Gzipped
        Edge VersionUnreleased, current master, use at your own risk
        + +
        + +

        Collection Functions (Arrays or Objects)

        + +

        + each_.each(list, iterator, [context]) + Alias: forEach +
        + Iterates over a list of elements, yielding each in turn to an iterator + function. The iterator is bound to the context object, if one is + passed. Each invocation of iterator is called with three arguments: + (element, index, list). If list is a JavaScript object, iterator's + arguments will be (value, key, list). Delegates to the native + forEach function if it exists. +

        +
        +_.each([1, 2, 3], alert);
        +=> alerts each number in turn...
        +_.each({one : 1, two : 2, three : 3}, alert);
        +=> alerts each number value in turn...
        + +

        + map_.map(list, iterator, [context]) + Alias: collect +
        + Produces a new array of values by mapping each value in list + through a transformation function (iterator). If the native map method + exists, it will be used instead. If list is a JavaScript object, + iterator's arguments will be (value, key, list). +

        +
        +_.map([1, 2, 3], function(num){ return num * 3; });
        +=> [3, 6, 9]
        +_.map({one : 1, two : 2, three : 3}, function(num, key){ return num * 3; });
        +=> [3, 6, 9]
        + +

        + reduce_.reduce(list, iterator, memo, [context]) + Aliases: inject, foldl +
        + Also known as inject and foldl, reduce boils down a + list of values into a single value. Memo is the initial state + of the reduction, and each successive step of it should be returned by + iterator. The iterator is passed four arguments: the memo, + then the value and index (or key) of the iteration, + and finally a reference to the entire list. +

        +
        +var sum = _.reduce([1, 2, 3], function(memo, num){ return memo + num; }, 0);
        +=> 6
        +
        + +

        + reduceRight_.reduceRight(list, iterator, memo, [context]) + Alias: foldr +
        + The right-associative version of reduce. Delegates to the + JavaScript 1.8 version of reduceRight, if it exists. Foldr + is not as useful in JavaScript as it would be in a language with lazy + evaluation. +

        +
        +var list = [[0, 1], [2, 3], [4, 5]];
        +var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);
        +=> [4, 5, 2, 3, 0, 1]
        +
        + +

        + find_.find(list, iterator, [context]) + Alias: detect +
        + Looks through each value in the list, returning the first one that + passes a truth test (iterator). The function returns as + soon as it finds an acceptable element, and doesn't traverse the + entire list. +

        +
        +var even = _.find([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
        +=> 2
        +
        + +

        + filter_.filter(list, iterator, [context]) + Alias: select +
        + Looks through each value in the list, returning an array of all + the values that pass a truth test (iterator). Delegates to the + native filter method, if it exists. +

        +
        +var evens = _.filter([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
        +=> [2, 4, 6]
        +
        + +

        + where_.where(list, properties) +
        + Looks through each value in the list, returning an array of all + the values that contain all of the key-value pairs listed in properties. +

        +
        +_.where(listOfPlays, {author: "Shakespeare", year: 1611});
        +=> [{title: "Cymbeline", author: "Shakespeare", year: 1611},
        +    {title: "The Tempest", author: "Shakespeare", year: 1611}]
        +
        + +

        + findWhere_.findWhere(list, properties) +
        + Looks through the list and returns the first value that matches + all of the key-value pairs listed in properties. +

        +
        +_.findWhere(publicServicePulitzers, {newsroom: "The New York Times"});
        +=> {year: 1918, newsroom: "The New York Times",
        +  reason: "For its public service in publishing in full so many official reports,
        +  documents and speeches by European statesmen relating to the progress and
        +  conduct of the war."}
        +
        + +

        + reject_.reject(list, iterator, [context]) +
        + Returns the values in list without the elements that the truth + test (iterator) passes. The opposite of filter. +

        +
        +var odds = _.reject([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
        +=> [1, 3, 5]
        +
        + +

        + every_.every(list, iterator, [context]) + Alias: all +
        + Returns true if all of the values in the list pass the iterator + truth test. Delegates to the native method every, if present. +

        +
        +_.every([true, 1, null, 'yes'], _.identity);
        +=> false
        +
        + +

        + some_.some(list, [iterator], [context]) + Alias: any +
        + Returns true if any of the values in the list pass the + iterator truth test. Short-circuits and stops traversing the list + if a true element is found. Delegates to the native method some, + if present. +

        +
        +_.some([null, 0, 'yes', false]);
        +=> true
        +
        + +

        + contains_.contains(list, value) + Alias: include +
        + Returns true if the value is present in the list. + Uses indexOf internally, if list is an Array. +

        +
        +_.contains([1, 2, 3], 3);
        +=> true
        +
        + +

        + invoke_.invoke(list, methodName, [*arguments]) +
        + Calls the method named by methodName on each value in the list. + Any extra arguments passed to invoke will be forwarded on to the + method invocation. +

        +
        +_.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
        +=> [[1, 5, 7], [1, 2, 3]]
        +
        + +

        + pluck_.pluck(list, propertyName) +
        + A convenient version of what is perhaps the most common use-case for + map: extracting a list of property values. +

        +
        +var stooges = [{name : 'moe', age : 40}, {name : 'larry', age : 50}, {name : 'curly', age : 60}];
        +_.pluck(stooges, 'name');
        +=> ["moe", "larry", "curly"]
        +
        + +

        + max_.max(list, [iterator], [context]) +
        + Returns the maximum value in list. If iterator is passed, + it will be used on each value to generate the criterion by which the + value is ranked. +

        +
        +var stooges = [{name : 'moe', age : 40}, {name : 'larry', age : 50}, {name : 'curly', age : 60}];
        +_.max(stooges, function(stooge){ return stooge.age; });
        +=> {name : 'curly', age : 60};
        +
        + +

        + min_.min(list, [iterator], [context]) +
        + Returns the minimum value in list. If iterator is passed, + it will be used on each value to generate the criterion by which the + value is ranked. +

        +
        +var numbers = [10, 5, 100, 2, 1000];
        +_.min(numbers);
        +=> 2
        +
        + +

        + sortBy_.sortBy(list, iterator, [context]) +
        + Returns a sorted copy of list, ranked in ascending order by the + results of running each value through iterator. Iterator may + also be the string name of the property to sort by (eg. length). +

        +
        +_.sortBy([1, 2, 3, 4, 5, 6], function(num){ return Math.sin(num); });
        +=> [5, 4, 6, 3, 1, 2]
        +
        + +

        + groupBy_.groupBy(list, iterator, [context]) +
        + Splits a collection into sets, grouped by the result of running each + value through iterator. If iterator is a string instead of + a function, groups by the property named by iterator on each of + the values. +

        +
        +_.groupBy([1.3, 2.1, 2.4], function(num){ return Math.floor(num); });
        +=> {1: [1.3], 2: [2.1, 2.4]}
        +
        +_.groupBy(['one', 'two', 'three'], 'length');
        +=> {3: ["one", "two"], 5: ["three"]}
        +
        + +

        + countBy_.countBy(list, iterator, [context]) +
        + Sorts a list into groups and returns a count for the number of objects + in each group. + Similar to groupBy, but instead of returning a list of values, + returns a count for the number of values in that group. +

        +
        +_.countBy([1, 2, 3, 4, 5], function(num) {
        +  return num % 2 == 0 ? 'even' : 'odd';
        +});
        +=> {odd: 3, even: 2}
        +
        + +

        + shuffle_.shuffle(list) +
        + Returns a shuffled copy of the list, using a version of the + Fisher-Yates shuffle. +

        +
        +_.shuffle([1, 2, 3, 4, 5, 6]);
        +=> [4, 1, 6, 3, 5, 2]
        +
        + +

        + toArray_.toArray(list) +
        + Converts the list (anything that can be iterated over), into a + real Array. Useful for transmuting the arguments object. +

        +
        +(function(){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
        +=> [2, 3, 4]
        +
        + +

        + size_.size(list) +
        + Return the number of values in the list. +

        +
        +_.size({one : 1, two : 2, three : 3});
        +=> 3
        +
        + +

        Array Functions

        + +

        + + Note: All array functions will also work on the arguments object. + However, Underscore functions are not designed to work on "sparse" arrays. + +

        + +

        + first_.first(array, [n]) + Alias: head, take +
        + Returns the first element of an array. Passing n will + return the first n elements of the array. +

        +
        +_.first([5, 4, 3, 2, 1]);
        +=> 5
        +
        + +

        + initial_.initial(array, [n]) +
        + Returns everything but the last entry of the array. Especially useful on + the arguments object. Pass n to exclude the last n elements + from the result. +

        +
        +_.initial([5, 4, 3, 2, 1]);
        +=> [5, 4, 3, 2]
        +
        + +

        + last_.last(array, [n]) +
        + Returns the last element of an array. Passing n will return + the last n elements of the array. +

        +
        +_.last([5, 4, 3, 2, 1]);
        +=> 1
        +
        + +

        + rest_.rest(array, [index]) + Alias: tail, drop +
        + Returns the rest of the elements in an array. Pass an index + to return the values of the array from that index onward. +

        +
        +_.rest([5, 4, 3, 2, 1]);
        +=> [4, 3, 2, 1]
        +
        + +

        + compact_.compact(array) +
        + Returns a copy of the array with all falsy values removed. + In JavaScript, false, null, 0, "", + undefined and NaN are all falsy. +

        +
        +_.compact([0, 1, false, 2, '', 3]);
        +=> [1, 2, 3]
        +
        + +

        + flatten_.flatten(array, [shallow]) +
        + Flattens a nested array (the nesting can be to any depth). If you + pass shallow, the array will only be flattened a single level. +

        +
        +_.flatten([1, [2], [3, [[4]]]]);
        +=> [1, 2, 3, 4];
        +
        +_.flatten([1, [2], [3, [[4]]]], true);
        +=> [1, 2, 3, [[4]]];
        +
        + +

        + without_.without(array, [*values]) +
        + Returns a copy of the array with all instances of the values + removed. +

        +
        +_.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
        +=> [2, 3, 4]
        +
        + +

        + union_.union(*arrays) +
        + Computes the union of the passed-in arrays: the list of unique items, + in order, that are present in one or more of the arrays. +

        +
        +_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
        +=> [1, 2, 3, 101, 10]
        +
        + +

        + intersection_.intersection(*arrays) +
        + Computes the list of values that are the intersection of all the arrays. + Each value in the result is present in each of the arrays. +

        +
        +_.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
        +=> [1, 2]
        +
        + +

        + difference_.difference(array, *others) +
        + Similar to without, but returns the values from array that + are not present in the other arrays. +

        +
        +_.difference([1, 2, 3, 4, 5], [5, 2, 10]);
        +=> [1, 3, 4]
        +
        + +

        + uniq_.uniq(array, [isSorted], [iterator]) + Alias: unique +
        + Produces a duplicate-free version of the array, using === to test + object equality. If you know in advance that the array is sorted, + passing true for isSorted will run a much faster algorithm. + If you want to compute unique items based on a transformation, pass an + iterator function. +

        +
        +_.uniq([1, 2, 1, 3, 1, 4]);
        +=> [1, 2, 3, 4]
        +
        + +

        + zip_.zip(*arrays) +
        + Merges together the values of each of the arrays with the + values at the corresponding position. Useful when you have separate + data sources that are coordinated through matching array indexes. + If you're working with a matrix of nested arrays, zip.apply + can transpose the matrix in a similar fashion. +

        +
        +_.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]);
        +=> [["moe", 30, true], ["larry", 40, false], ["curly", 50, false]]
        +
        + +

        + object_.object(list, [values]) +
        + Converts arrays into objects. Pass either a single list of + [key, value] pairs, or a list of keys, and a list of values. +

        +
        +_.object(['moe', 'larry', 'curly'], [30, 40, 50]);
        +=> {moe: 30, larry: 40, curly: 50}
        +
        +_.object([['moe', 30], ['larry', 40], ['curly', 50]]);
        +=> {moe: 30, larry: 40, curly: 50}
        +
        + +

        + indexOf_.indexOf(array, value, [isSorted]) +
        + Returns the index at which value can be found in the array, + or -1 if value is not present in the array. Uses the native + indexOf function unless it's missing. If you're working with a + large array, and you know that the array is already sorted, pass true + for isSorted to use a faster binary search ... or, pass a number as + the third argument in order to look for the first matching value in the + array after the given index. +

        +
        +_.indexOf([1, 2, 3], 2);
        +=> 1
        +
        + +

        + lastIndexOf_.lastIndexOf(array, value, [fromIndex]) +
        + Returns the index of the last occurrence of value in the array, + or -1 if value is not present. Uses the native lastIndexOf + function if possible. Pass fromIndex to start your search at a + given index. +

        +
        +_.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
        +=> 4
        +
        + +

        + sortedIndex_.sortedIndex(list, value, [iterator], [context]) +
        + Uses a binary search to determine the index at which the value + should be inserted into the list in order to maintain the list's + sorted order. If an iterator is passed, it will be used to compute + the sort ranking of each value, including the value you pass. +

        +
        +_.sortedIndex([10, 20, 30, 40, 50], 35);
        +=> 3
        +
        + +

        + range_.range([start], stop, [step]) +
        + A function to create flexibly-numbered lists of integers, handy for + each and map loops. start, if omitted, defaults + to 0; step defaults to 1. Returns a list of integers + from start to stop, incremented (or decremented) by step, + exclusive. +

        +
        +_.range(10);
        +=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
        +_.range(1, 11);
        +=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
        +_.range(0, 30, 5);
        +=> [0, 5, 10, 15, 20, 25]
        +_.range(0, -10, -1);
        +=> [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
        +_.range(0);
        +=> []
        +
        + +

        Function (uh, ahem) Functions

        + +

        + bind_.bind(function, object, [*arguments]) +
        + Bind a function to an object, meaning that whenever + the function is called, the value of this will be the object. + Optionally, pass arguments to the function to pre-fill them, + also known as partial application. +

        +
        +var func = function(greeting){ return greeting + ': ' + this.name };
        +func = _.bind(func, {name : 'moe'}, 'hi');
        +func();
        +=> 'hi: moe'
        +
        + +

        + bindAll_.bindAll(object, [*methodNames]) +
        + Binds a number of methods on the object, specified by + methodNames, to be run in the context of that object whenever they + are invoked. Very handy for binding functions that are going to be used + as event handlers, which would otherwise be invoked with a fairly useless + this. If no methodNames are provided, all of the object's + function properties will be bound to it. +

        +
        +var buttonView = {
        +  label   : 'underscore',
        +  onClick : function(){ alert('clicked: ' + this.label); },
        +  onHover : function(){ console.log('hovering: ' + this.label); }
        +};
        +_.bindAll(buttonView);
        +jQuery('#underscore_button').bind('click', buttonView.onClick);
        +=> When the button is clicked, this.label will have the correct value...
        +
        + +

        + partial_.partial(function, [*arguments]) +
        + Partially apply a function by filling in any number of its arguments, + without changing its dynamic this value. A close cousin + of bind. +

        +
        +var add = function(a, b) { return a + b; };
        +add5 = _.partial(add, 5);
        +add5(10);
        +=> 15
        +
        + +

        + memoize_.memoize(function, [hashFunction]) +
        + Memoizes a given function by caching the computed result. Useful + for speeding up slow-running computations. If passed an optional + hashFunction, it will be used to compute the hash key for storing + the result, based on the arguments to the original function. The default + hashFunction just uses the first argument to the memoized function + as the key. +

        +
        +var fibonacci = _.memoize(function(n) {
        +  return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);
        +});
        +
        + +

        + delay_.delay(function, wait, [*arguments]) +
        + Much like setTimeout, invokes function after wait + milliseconds. If you pass the optional arguments, they will be + forwarded on to the function when it is invoked. +

        +
        +var log = _.bind(console.log, console);
        +_.delay(log, 1000, 'logged later');
        +=> 'logged later' // Appears after one second.
        +
        + +

        + defer_.defer(function, [*arguments]) +
        + Defers invoking the function until the current call stack has cleared, + similar to using setTimeout with a delay of 0. Useful for performing + expensive computations or HTML rendering in chunks without blocking the UI thread + from updating. If you pass the optional arguments, they will be + forwarded on to the function when it is invoked. +

        +
        +_.defer(function(){ alert('deferred'); });
        +// Returns from the function before the alert runs.
        +
        + +

        + throttle_.throttle(function, wait) +
        + Creates and returns a new, throttled version of the passed function, + that, when invoked repeatedly, will only actually call the original function + at most once per every wait + milliseconds. Useful for rate-limiting events that occur faster than you + can keep up with. +

        +
        +var throttled = _.throttle(updatePosition, 100);
        +$(window).scroll(throttled);
        +
        + +

        + debounce_.debounce(function, wait, [immediate]) +
        + Creates and returns a new debounced version of the passed function that + will postpone its execution until after + wait milliseconds have elapsed since the last time it + was invoked. Useful for implementing behavior that should only happen + after the input has stopped arriving. For example: rendering a + preview of a Markdown comment, recalculating a layout after the window + has stopped being resized, and so on. +

        + +

        + Pass true for the immediate parameter to cause + debounce to trigger the function on the leading instead of the + trailing edge of the wait interval. Useful in circumstances like + preventing accidental double-clicks on a "submit" button from firing a + second time. +

        + +
        +var lazyLayout = _.debounce(calculateLayout, 300);
        +$(window).resize(lazyLayout);
        +
        + +

        + once_.once(function) +
        + Creates a version of the function that can only be called one time. + Repeated calls to the modified function will have no effect, returning + the value from the original call. Useful for initialization functions, + instead of having to set a boolean flag and then check it later. +

        +
        +var initialize = _.once(createApplication);
        +initialize();
        +initialize();
        +// Application is only created once.
        +
        + +

        + after_.after(count, function) +
        + Creates a version of the function that will only be run after first + being called count times. Useful for grouping asynchronous responses, + where you want to be sure that all the async calls have finished, before + proceeding. +

        +
        +var renderNotes = _.after(notes.length, render);
        +_.each(notes, function(note) {
        +  note.asyncSave({success: renderNotes});
        +});
        +// renderNotes is run once, after all notes have saved.
        +
        + +

        + wrap_.wrap(function, wrapper) +
        + Wraps the first function inside of the wrapper function, + passing it as the first argument. This allows the wrapper to + execute code before and after the function runs, adjust the arguments, + and execute it conditionally. +

        +
        +var hello = function(name) { return "hello: " + name; };
        +hello = _.wrap(hello, function(func) {
        +  return "before, " + func("moe") + ", after";
        +});
        +hello();
        +=> 'before, hello: moe, after'
        +
        + +

        + compose_.compose(*functions) +
        + Returns the composition of a list of functions, where each function + consumes the return value of the function that follows. In math terms, + composing the functions f(), g(), and h() produces + f(g(h())). +

        +
        +var greet    = function(name){ return "hi: " + name; };
        +var exclaim  = function(statement){ return statement + "!"; };
        +var welcome = _.compose(exclaim, greet);
        +welcome('moe');
        +=> 'hi: moe!'
        +
        + +

        Object Functions

        + +

        + keys_.keys(object) +
        + Retrieve all the names of the object's properties. +

        +
        +_.keys({one : 1, two : 2, three : 3});
        +=> ["one", "two", "three"]
        +
        + +

        + values_.values(object) +
        + Return all of the values of the object's properties. +

        +
        +_.values({one : 1, two : 2, three : 3});
        +=> [1, 2, 3]
        +
        + +

        + pairs_.pairs(object) +
        + Convert an object into a list of [key, value] pairs. +

        +
        +_.pairs({one: 1, two: 2, three: 3});
        +=> [["one", 1], ["two", 2], ["three", 3]]
        +
        + +

        + invert_.invert(object) +
        + Returns a copy of the object where the keys have become the values + and the values the keys. For this to work, all of your object's values + should be unique and string serializable. +

        +
        +_.invert({Moe: "Moses", Larry: "Louis", Curly: "Jerome"});
        +=> {Moses: "Moe", Louis: "Larry", Jerome: "Curly"};
        +
        + +

        + functions_.functions(object) + Alias: methods +
        + Returns a sorted list of the names of every method in an object — + that is to say, the name of every function property of the object. +

        +
        +_.functions(_);
        +=> ["all", "any", "bind", "bindAll", "clone", "compact", "compose" ...
        +
        + +

        + extend_.extend(destination, *sources) +
        + Copy all of the properties in the source objects over to the + destination object, and return the destination object. + It's in-order, so the last source will override properties of the same + name in previous arguments. +

        +
        +_.extend({name : 'moe'}, {age : 50});
        +=> {name : 'moe', age : 50}
        +
        + +

        + pick_.pick(object, *keys) +
        + Return a copy of the object, filtered to only have values for + the whitelisted keys (or array of valid keys). +

        +
        +_.pick({name : 'moe', age: 50, userid : 'moe1'}, 'name', 'age');
        +=> {name : 'moe', age : 50}
        +
        + +

        + omit_.omit(object, *keys) +
        + Return a copy of the object, filtered to omit the blacklisted + keys (or array of keys). +

        +
        +_.omit({name : 'moe', age : 50, userid : 'moe1'}, 'userid');
        +=> {name : 'moe', age : 50}
        +
        + +

        + defaults_.defaults(object, *defaults) +
        + Fill in null and undefined properties in object with values from the + defaults objects, and return the object. As soon as the + property is filled, further defaults will have no effect. +

        +
        +var iceCream = {flavor : "chocolate"};
        +_.defaults(iceCream, {flavor : "vanilla", sprinkles : "lots"});
        +=> {flavor : "chocolate", sprinkles : "lots"}
        +
        + +

        + clone_.clone(object) +
        + Create a shallow-copied clone of the object. Any nested objects + or arrays will be copied by reference, not duplicated. +

        +
        +_.clone({name : 'moe'});
        +=> {name : 'moe'};
        +
        + +

        + tap_.tap(object, interceptor) +
        + Invokes interceptor with the object, and then returns object. + The primary purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. +

        +
        +_.chain([1,2,3,200])
        +  .filter(function(num) { return num % 2 == 0; })
        +  .tap(alert)
        +  .map(function(num) { return num * num })
        +  .value();
        +=> // [2, 200] (alerted)
        +=> [4, 40000]
        +
        + +

        + has_.has(object, key) +
        + Does the object contain the given key? Identical to + object.hasOwnProperty(key), but uses a safe reference to the + hasOwnProperty function, in case it's been + overridden accidentally. +

        +
        +_.has({a: 1, b: 2, c: 3}, "b");
        +=> true
        +
        + +

        + isEqual_.isEqual(object, other) +
        + Performs an optimized deep comparison between the two objects, to determine + if they should be considered equal. +

        +
        +var moe   = {name : 'moe', luckyNumbers : [13, 27, 34]};
        +var clone = {name : 'moe', luckyNumbers : [13, 27, 34]};
        +moe == clone;
        +=> false
        +_.isEqual(moe, clone);
        +=> true
        +
        + +

        + isEmpty_.isEmpty(object) +
        + Returns true if object contains no values. +

        +
        +_.isEmpty([1, 2, 3]);
        +=> false
        +_.isEmpty({});
        +=> true
        +
        + +

        + isElement_.isElement(object) +
        + Returns true if object is a DOM element. +

        +
        +_.isElement(jQuery('body')[0]);
        +=> true
        +
        + +

        + isArray_.isArray(object) +
        + Returns true if object is an Array. +

        +
        +(function(){ return _.isArray(arguments); })();
        +=> false
        +_.isArray([1,2,3]);
        +=> true
        +
        + +

        + isObject_.isObject(value) +
        + Returns true if value is an Object. Note that JavaScript + arrays and functions are objects, while (normal) strings and numbers are not. +

        +
        +_.isObject({});
        +=> true
        +_.isObject(1);
        +=> false
        +
        + +

        + isArguments_.isArguments(object) +
        + Returns true if object is an Arguments object. +

        +
        +(function(){ return _.isArguments(arguments); })(1, 2, 3);
        +=> true
        +_.isArguments([1,2,3]);
        +=> false
        +
        + +

        + isFunction_.isFunction(object) +
        + Returns true if object is a Function. +

        +
        +_.isFunction(alert);
        +=> true
        +
        + +

        + isString_.isString(object) +
        + Returns true if object is a String. +

        +
        +_.isString("moe");
        +=> true
        +
        + +

        + isNumber_.isNumber(object) +
        + Returns true if object is a Number (including NaN). +

        +
        +_.isNumber(8.4 * 5);
        +=> true
        +
        + +

        + isFinite_.isFinite(object) +
        + Returns true if object is a finite Number. +

        +
        +_.isFinite(-101);
        +=> true
        +
        +_.isFinite(-Infinity);
        +=> false
        +
        + +

        + isBoolean_.isBoolean(object) +
        + Returns true if object is either true or false. +

        +
        +_.isBoolean(null);
        +=> false
        +
        + +

        + isDate_.isDate(object) +
        + Returns true if object is a Date. +

        +
        +_.isDate(new Date());
        +=> true
        +
        + +

        + isRegExp_.isRegExp(object) +
        + Returns true if object is a RegExp. +

        +
        +_.isRegExp(/moe/);
        +=> true
        +
        + +

        + isNaN_.isNaN(object) +
        + Returns true if object is NaN.
        Note: this is not + the same as the native isNaN function, which will also return + true if the variable is undefined. +

        +
        +_.isNaN(NaN);
        +=> true
        +isNaN(undefined);
        +=> true
        +_.isNaN(undefined);
        +=> false
        +
        + +

        + isNull_.isNull(object) +
        + Returns true if the value of object is null. +

        +
        +_.isNull(null);
        +=> true
        +_.isNull(undefined);
        +=> false
        +
        + +

        + isUndefined_.isUndefined(value) +
        + Returns true if value is undefined. +

        +
        +_.isUndefined(window.missingVariable);
        +=> true
        +
        + +

        Utility Functions

        + +

        + noConflict_.noConflict() +
        + Give control of the "_" variable back to its previous owner. Returns + a reference to the Underscore object. +

        +
        +var underscore = _.noConflict();
        + +

        + identity_.identity(value) +
        + Returns the same value that is used as the argument. In math: + f(x) = x
        + This function looks useless, but is used throughout Underscore as + a default iterator. +

        +
        +var moe = {name : 'moe'};
        +moe === _.identity(moe);
        +=> true
        + +

        + times_.times(n, iterator, [context]) +
        + Invokes the given iterator function n times. Each invocation of + iterator is called with an index argument. +
        + Note: this example uses the chaining syntax. +

        +
        +_(3).times(function(n){ genie.grantWishNumber(n); });
        + +

        + random_.random(min, max) +
        + Returns a random integer between min and max, inclusive. + If you only pass one argument, it will return a number between 0 + and that number. +

        +
        +_.random(0, 100);
        +=> 42
        + +

        + mixin_.mixin(object) +
        + Allows you to extend Underscore with your own utility functions. Pass + a hash of {name: function} definitions to have your functions + added to the Underscore object, as well as the OOP wrapper. +

        +
        +_.mixin({
        +  capitalize : function(string) {
        +    return string.charAt(0).toUpperCase() + string.substring(1).toLowerCase();
        +  }
        +});
        +_("fabio").capitalize();
        +=> "Fabio"
        +
        + +

        + uniqueId_.uniqueId([prefix]) +
        + Generate a globally-unique id for client-side models or DOM elements + that need one. If prefix is passed, the id will be appended to it. +

        +
        +_.uniqueId('contact_');
        +=> 'contact_104'
        + +

        + escape_.escape(string) +
        + Escapes a string for insertion into HTML, replacing + &, <, >, ", ', and / characters. +

        +
        +_.escape('Curly, Larry & Moe');
        +=> "Curly, Larry &amp; Moe"
        + +

        + unescape_.unescape(string) +
        + The opposite of escape, replaces + &amp;, &lt;, &gt;, + &quot;, &#x27;, and &#x2F; + with their unescaped counterparts. +

        +
        +_.unescape('Curly, Larry &amp; Moe');
        +=> "Curly, Larry & Moe"
        + +

        + result_.result(object, property) +
        + If the value of the named property is a function then invoke it; otherwise, return it. +

        +
        +var object = {cheese: 'crumpets', stuff: function(){ return 'nonsense'; }};
        +_.result(object, 'cheese');
        +=> "crumpets"
        +_.result(object, 'stuff');
        +=> "nonsense"
        + +

        + template_.template(templateString, [data], [settings]) +
        + Compiles JavaScript templates into functions that can be evaluated + for rendering. Useful for rendering complicated bits of HTML from JSON + data sources. Template functions can both interpolate variables, using + <%= … %>, as well as execute arbitrary JavaScript code, with + <% … %>. If you wish to interpolate a value, and have + it be HTML-escaped, use <%- … %> When you evaluate a template function, pass in a + data object that has properties corresponding to the template's free + variables. If you're writing a one-off, you can pass the data + object as the second parameter to template in order to render + immediately instead of returning a template function. The settings argument + should be a hash containing any _.templateSettings that should be overridden. +

        + +
        +var compiled = _.template("hello: <%= name %>");
        +compiled({name : 'moe'});
        +=> "hello: moe"
        +
        +var list = "<% _.each(people, function(name) { %> <li><%= name %></li> <% }); %>";
        +_.template(list, {people : ['moe', 'curly', 'larry']});
        +=> "<li>moe</li><li>curly</li><li>larry</li>"
        +
        +var template = _.template("<b><%- value %></b>");
        +template({value : '<script>'});
        +=> "<b>&lt;script&gt;</b>"
        + +

        + You can also use print from within JavaScript code. This is + sometimes more convenient than using <%= ... %>. +

        + +
        +var compiled = _.template("<% print('Hello ' + epithet); %>");
        +compiled({epithet: "stooge"});
        +=> "Hello stooge."
        + +

        + If ERB-style delimiters aren't your cup of tea, you can change Underscore's + template settings to use different symbols to set off interpolated code. + Define an interpolate regex to match expressions that should be + interpolated verbatim, an escape regex to match expressions that should + be inserted after being HTML escaped, and an evaluate regex to match + expressions that should be evaluated without insertion into the resulting + string. You may define or omit any combination of the three. + For example, to perform + Mustache.js + style templating: +

        + +
        +_.templateSettings = {
        +  interpolate : /\{\{(.+?)\}\}/g
        +};
        +
        +var template = _.template("Hello {{ name }}!");
        +template({name : "Mustache"});
        +=> "Hello Mustache!"
        + +

        + By default, template places the values from your data in the local scope + via the with statement. However, you can specify a single variable name + with the variable setting. This can significantly improve the speed + at which a template is able to render. +

        + +
        +_.template("Using 'with': <%= data.answer %>", {answer: 'no'}, {variable: 'data'});
        +=> "Using 'with': no"
        + +

        + Precompiling your templates can be a big help when debugging errors you can't + reproduce. This is because precompiled templates can provide line numbers and + a stack trace, something that is not possible when compiling templates on the client. + The source property is available on the compiled template + function for easy precompilation. +

        + +
        <script>
        +  JST.project = <%= _.template(jstText).source %>;
        +</script>
        + + +

        Chaining

        + +

        + You can use Underscore in either an object-oriented or a functional style, + depending on your preference. The following two lines of code are + identical ways to double a list of numbers. +

        + +
        +_.map([1, 2, 3], function(n){ return n * 2; });
        +_([1, 2, 3]).map(function(n){ return n * 2; });
        + +

        + Calling chain will cause all future method calls to return + wrapped objects. When you've finished the computation, use + value to retrieve the final value. Here's an example of chaining + together a map/flatten/reduce, in order to get the word count of + every word in a song. +

        + +
        +var lyrics = [
        +  {line : 1, words : "I'm a lumberjack and I'm okay"},
        +  {line : 2, words : "I sleep all night and I work all day"},
        +  {line : 3, words : "He's a lumberjack and he's okay"},
        +  {line : 4, words : "He sleeps all night and he works all day"}
        +];
        +
        +_.chain(lyrics)
        +  .map(function(line) { return line.words.split(' '); })
        +  .flatten()
        +  .reduce(function(counts, word) {
        +    counts[word] = (counts[word] || 0) + 1;
        +    return counts;
        +  }, {})
        +  .value();
        +
        +=> {lumberjack : 2, all : 4, night : 2 ... }
        + +

        + In addition, the + Array prototype's methods + are proxied through the chained Underscore object, so you can slip a + reverse or a push into your chain, and continue to + modify the array. +

        + +

        + chain_.chain(obj) +
        + Returns a wrapped object. Calling methods on this object will continue + to return wrapped objects until value is used. +

        +
        +var stooges = [{name : 'curly', age : 25}, {name : 'moe', age : 21}, {name : 'larry', age : 23}];
        +var youngest = _.chain(stooges)
        +  .sortBy(function(stooge){ return stooge.age; })
        +  .map(function(stooge){ return stooge.name + ' is ' + stooge.age; })
        +  .first()
        +  .value();
        +=> "moe is 21"
        +
        + +

        + value_(obj).value() +
        + Extracts the value of a wrapped object. +

        +
        +_([1, 2, 3]).value();
        +=> [1, 2, 3]
        +
        + + + +

        + The Underscore documentation is also available in + Simplified Chinese. +

        + +

        + Underscore.lua, + a Lua port of the functions that are applicable in both languages. + Includes OOP-wrapping and chaining. + (source) +

        + +

        + Underscore.m, an Objective-C port + of many of the Underscore.js functions, using a syntax that encourages + chaining. + (source) +

        + +

        + _.m, an alternative + Objective-C port that tries to stick a little closer to the original + Underscore.js API. + (source) +

        + +

        + Underscore.php, + a PHP port of the functions that are applicable in both languages. + Includes OOP-wrapping and chaining. + (source) +

        + +

        + Underscore-perl, + a Perl port of many of the Underscore.js functions, + aimed at on Perl hashes and arrays. + (source) +

        + +

        + Underscore.cfc, + a Coldfusion port of many of the Underscore.js functions. + (source) +

        + +

        + Underscore.string, + an Underscore extension that adds functions for string-manipulation: + trim, startsWith, contains, capitalize, + reverse, sprintf, and more. +

        + +

        + Ruby's Enumerable module. +

        + +

        + Prototype.js, which provides + JavaScript with collection functions in the manner closest to Ruby's Enumerable. +

        + +

        + Oliver Steele's + Functional JavaScript, + which includes comprehensive higher-order function support as well as string lambdas. +

        + +

        + Michael Aufreiter's Data.js, + a data manipulation + persistence library for JavaScript. +

        + +

        + Python's itertools. +

        + +

        Change Log

        + +

        + 1.4.4Jan. 30, 2013Diff
        +

          +
        • + Added _.findWhere, for finding the first element in a list + that matches a particular set of keys and values. +
        • +
        • + Added _.partial, for partially applying a function without + changing its dynamic reference to this. +
        • +
        • + Simplified bind by removing some edge cases involving + constructor functions. In short: don't _.bind your + constructors. +
        • +
        • + A minor optimization to invoke. +
        • +
        • + Fix bug in the minified version due to the minifier incorrectly + optimizing-away isFunction. +
        • +
        +

        + +

        + 1.4.3Dec. 4, 2012Diff
        +

          +
        • + Improved Underscore compatibility with Adobe's JS engine that can be + used to script Illustrator, Photoshop, and friends. +
        • +
        • + Added a default _.identity iterator to countBy and + groupBy. +
        • +
        • + The uniq function can now take array, iterator, context + as the argument list. +
        • +
        • + The times function now returns the mapped array of iterator + results. +
        • +
        • + Simplified and fixed bugs in throttle. +
        • +
        +

        + +

        + 1.4.2Oct. 1, 2012Diff
        +

          +
        • + For backwards compatibility, returned to pre-1.4.0 behavior when + passing null to iteration functions. They now become no-ops + again. +
        • +
        +

        + +

        + 1.4.1Oct. 1, 2012Diff
        +

          +
        • + Fixed a 1.4.0 regression in the lastIndexOf function. +
        • +
        +

        + +

        + 1.4.0Sept. 27, 2012Diff
        +

          +
        • + Added a pairs function, for turning a JavaScript object + into [key, value] pairs ... as well as an object + function, for converting an array of [key, value] pairs + into an object. +
        • +
        • + Added a countBy function, for counting the number of objects + in a list that match a certain criteria. +
        • +
        • + Added an invert function, for performing a simple inversion + of the keys and values in an object. +
        • +
        • + Added a where function, for easy cases of filtering a list + for objects with specific values. +
        • +
        • + Added an omit function, for filtering an object to remove + certain keys. +
        • +
        • + Added a random function, to return a random number in a + given range. +
        • +
        • + _.debounce'd functions now return their last updated value, + just like _.throttle'd functions do. +
        • +
        • + The sortBy function now runs a stable sort algorithm. +
        • +
        • + Added the optional fromIndex option to indexOf and + lastIndexOf. +
        • +
        • + "Sparse" arrays are no longer supported in Underscore iteration + functions. Use a for loop instead (or better yet, an object). +
        • +
        • + The min and max functions may now be called on + very large arrays. +
        • +
        • + Interpolation in templates now represents null and + undefined as the empty string. +
        • +
        • + Underscore iteration functions no longer accept null values + as a no-op argument. You'll get an early error instead. +
        • +
        • + A number of edge-cases fixes and tweaks, which you can spot in the + diff. + Depending on how you're using Underscore, 1.4.0 may be more + backwards-incompatible than usual — please test when you upgrade. +
        • +
        +

        + +

        + 1.3.3April 10, 2012
        +

          +
        • + Many improvements to _.template, which now provides the + source of the template function as a property, for potentially + even more efficient pre-compilation on the server-side. You may now + also set the variable option when creating a template, + which will cause your passed-in data to be made available under the + variable you named, instead of using a with statement — + significantly improving the speed of rendering the template. +
        • +
        • + Added the pick function, which allows you to filter an + object literal with a whitelist of allowed property names. +
        • +
        • + Added the result function, for convenience when working + with APIs that allow either functions or raw properties. +
        • +
        • + Added the isFinite function, because sometimes knowing that + a value is a number just ain't quite enough. +
        • +
        • + The sortBy function may now also be passed the string name + of a property to use as the sort order on each object. +
        • +
        • + Fixed uniq to work with sparse arrays. +
        • +
        • + The difference function now performs a shallow flatten + instead of a deep one when computing array differences. +
        • +
        • + The debounce function now takes an immediate + parameter, which will cause the callback to fire on the leading + instead of the trailing edge. +
        • +
        +

        + +

        + 1.3.1Jan. 23, 2012
        +

          +
        • + Added an _.has function, as a safer way to use hasOwnProperty. +
        • +
        • + Added _.collect as an alias for _.map. Smalltalkers, rejoice. +
        • +
        • + Reverted an old change so that _.extend will correctly copy + over keys with undefined values again. +
        • +
        • + Bugfix to stop escaping slashes within interpolations in _.template. +
        • +
        +

        + +

        + 1.3.0Jan. 11, 2012
        +

          +
        • + Removed AMD (RequireJS) support from Underscore. If you'd like to use + Underscore with RequireJS, you can load it as a normal script, wrap + or patch your copy, or download a forked version. +
        • +
        +

        + +

        + 1.2.4Jan. 4, 2012
        +

          +
        • + You now can (and probably should, as it's simpler) + write _.chain(list) + instead of _(list).chain(). +
        • +
        • + Fix for escaped characters in Underscore templates, and for supporting + customizations of _.templateSettings that only define one or + two of the required regexes. +
        • +
        • + Fix for passing an array as the first argument to an _.wrap'd function. +
        • +
        • + Improved compatibility with ClojureScript, which adds a call + function to String.prototype. +
        • +
        +

        + +

        + 1.2.3Dec. 7, 2011
        +

          +
        • + Dynamic scope is now preserved for compiled _.template functions, + so you can use the value of this if you like. +
        • +
        • + Sparse array support of _.indexOf, _.lastIndexOf. +
        • +
        • + Both _.reduce and _.reduceRight can now be passed an + explicitly undefined value. (There's no reason why you'd + want to do this.) +
        • +
        +

        + +

        + 1.2.2Nov. 14, 2011
        +

          +
        • + Continued tweaks to _.isEqual semantics. Now JS primitives are + considered equivalent to their wrapped versions, and arrays are compared + by their numeric properties only (#351). +
        • +
        • + _.escape no longer tries to be smart about not double-escaping + already-escaped HTML entities. Now it just escapes regardless (#350). +
        • +
        • + In _.template, you may now leave semicolons out of evaluated + statements if you wish: <% }) %> (#369). +
        • +
        • + _.after(callback, 0) will now trigger the callback immediately, + making "after" easier to use with asynchronous APIs (#366). +
        • +
        +

        + +

        + 1.2.1Oct. 24, 2011
        +

          +
        • + Several important bug fixes for _.isEqual, which should now + do better on mutated Arrays, and on non-Array objects with + length properties. (#329) +
        • +
        • + jrburke contributed Underscore exporting for AMD module loaders, + and tonylukasavage for Appcelerator Titanium. + (#335, #338) +
        • +
        • + You can now _.groupBy(list, 'property') as a shortcut for + grouping values by a particular common property. +
        • +
        • + _.throttle'd functions now fire immediately upon invocation, + and are rate-limited thereafter (#170, #266). +
        • +
        • + Most of the _.is[Type] checks no longer ducktype. +
        • +
        • + The _.bind function now also works on constructors, a-la + ES5 ... but you would never want to use _.bind on a + constructor function. +
        • +
        • + _.clone no longer wraps non-object types in Objects. +
        • +
        • + _.find and _.filter are now the preferred names for + _.detect and _.select. +
        • +
        +

        + +

        + 1.2.0Oct. 5, 2011
        +

          +
        • + The _.isEqual function now + supports true deep equality comparisons, with checks for cyclic structures, + thanks to Kit Cambridge. +
        • +
        • + Underscore templates now support HTML escaping interpolations, using + <%- ... %> syntax. +
        • +
        • + Ryan Tenney contributed _.shuffle, which uses a modified + Fisher-Yates to give you a shuffled copy of an array. +
        • +
        • + _.uniq can now be passed an optional iterator, to determine by + what criteria an object should be considered unique. +
        • +
        • + _.last now takes an optional argument which will return the last + N elements of the list. +
        • +
        • + A new _.initial function was added, as a mirror of _.rest, + which returns all the initial values of a list (except the last N). +
        • +
        +

        + +

        + 1.1.7July 13, 2011
        + Added _.groupBy, which aggregates a collection into groups of like items. + Added _.union and _.difference, to complement the + (re-named) _.intersection. + Various improvements for support of sparse arrays. + _.toArray now returns a clone, if directly passed an array. + _.functions now also returns the names of functions that are present + in the prototype chain. +

        + +

        + 1.1.6April 18, 2011
        + Added _.after, which will return a function that only runs after + first being called a specified number of times. + _.invoke can now take a direct function reference. + _.every now requires an iterator function to be passed, which + mirrors the ECMA5 API. + _.extend no longer copies keys when the value is undefined. + _.bind now errors when trying to bind an undefined value. +

        + +

        + 1.1.5Mar 20, 2011
        + Added an _.defaults function, for use merging together JS objects + representing default options. + Added an _.once function, for manufacturing functions that should + only ever execute a single time. + _.bind now delegates to the native ECMAScript 5 version, + where available. + _.keys now throws an error when used on non-Object values, as in + ECMAScript 5. + Fixed a bug with _.keys when used over sparse arrays. +

        + +

        + 1.1.4Jan 9, 2011
        + Improved compliance with ES5's Array methods when passing null + as a value. _.wrap now correctly sets this for the + wrapped function. _.indexOf now takes an optional flag for + finding the insertion index in an array that is guaranteed to already + be sorted. Avoiding the use of .callee, to allow _.isArray + to work properly in ES5's strict mode. +

        + +

        + 1.1.3Dec 1, 2010
        + In CommonJS, Underscore may now be required with just:
        + var _ = require("underscore"). + Added _.throttle and _.debounce functions. + Removed _.breakLoop, in favor of an ECMA5-style un-break-able + each implementation — this removes the try/catch, and you'll now have + better stack traces for exceptions that are thrown within an Underscore iterator. + Improved the isType family of functions for better interoperability + with Internet Explorer host objects. + _.template now correctly escapes backslashes in templates. + Improved _.reduce compatibility with the ECMA5 version: + if you don't pass an initial value, the first item in the collection is used. + _.each no longer returns the iterated collection, for improved + consistency with ES5's forEach. +

        + +

        + 1.1.2
        + Fixed _.contains, which was mistakenly pointing at + _.intersect instead of _.include, like it should + have been. Added _.unique as an alias for _.uniq. +

        + +

        + 1.1.1
        + Improved the speed of _.template, and its handling of multiline + interpolations. Ryan Tenney contributed optimizations to many Underscore + functions. An annotated version of the source code is now available. +

        + +

        + 1.1.0
        + The method signature of _.reduce has been changed to match + the ECMAScript 5 signature, instead of the Ruby/Prototype.js version. + This is a backwards-incompatible change. _.template may now be + called with no arguments, and preserves whitespace. _.contains + is a new alias for _.include. +

        + +

        + 1.0.4
        + Andri Möll contributed the _.memoize + function, which can be used to speed up expensive repeated computations + by caching the results. +

        + +

        + 1.0.3
        + Patch that makes _.isEqual return false if any property + of the compared object has a NaN value. Technically the correct + thing to do, but of questionable semantics. Watch out for NaN comparisons. +

        + +

        + 1.0.2
        + Fixes _.isArguments in recent versions of Opera, which have + arguments objects as real Arrays. +

        + +

        + 1.0.1
        + Bugfix for _.isEqual, when comparing two objects with the same + number of undefined keys, but with different names. +

        + +

        + 1.0.0
        + Things have been stable for many months now, so Underscore is now + considered to be out of beta, at 1.0. Improvements since 0.6 + include _.isBoolean, and the ability to have _.extend + take multiple source objects. +

        + +

        + 0.6.0
        + Major release. Incorporates a number of + Mile Frawley's refactors for + safer duck-typing on collection functions, and cleaner internals. A new + _.mixin method that allows you to extend Underscore with utility + functions of your own. Added _.times, which works the same as in + Ruby or Prototype.js. Native support for ECMAScript 5's Array.isArray, + and Object.keys. +

        + +

        + 0.5.8
        + Fixed Underscore's collection functions to work on + NodeLists and + HTMLCollections + once more, thanks to + Justin Tulloss. +

        + +

        + 0.5.7
        + A safer implementation of _.isArguments, and a + faster _.isNumber,
        thanks to + Jed Schmidt. +

        + +

        + 0.5.6
        + Customizable delimiters for _.template, contributed by + Noah Sloan. +

        + +

        + 0.5.5
        + Fix for a bug in MobileSafari's OOP-wrapper, with the arguments object. +

        + +

        + 0.5.4
        + Fix for multiple single quotes within a template string for + _.template. See: + Rick Strahl's blog post. +

        + +

        + 0.5.2
        + New implementations of isArray, isDate, isFunction, + isNumber, isRegExp, and isString, thanks to + a suggestion from + Robert Kieffer. + Instead of doing Object#toString + comparisons, they now check for expected properties, which is less safe, + but more than an order of magnitude faster. Most other Underscore + functions saw minor speed improvements as a result. + Evgeniy Dolzhenko + contributed _.tap, + similar to Ruby 1.9's, + which is handy for injecting side effects (like logging) into chained calls. +

        + +

        + 0.5.1
        + Added an _.isArguments function. Lots of little safety checks + and optimizations contributed by + Noah Sloan and + Andri Möll. +

        + +

        + 0.5.0
        + [API Changes] _.bindAll now takes the context object as + its first parameter. If no method names are passed, all of the context + object's methods are bound to it, enabling chaining and easier binding. + _.functions now takes a single argument and returns the names + of its Function properties. Calling _.functions(_) will get you + the previous behavior. + Added _.isRegExp so that isEqual can now test for RegExp equality. + All of the "is" functions have been shrunk down into a single definition. + Karl Guertin contributed patches. +

        + +

        + 0.4.7
        + Added isDate, isNaN, and isNull, for completeness. + Optimizations for isEqual when checking equality between Arrays + or Dates. _.keys is now 25%–2X faster (depending on your + browser) which speeds up the functions that rely on it, such as _.each. +

        + +

        + 0.4.6
        + Added the range function, a port of the + Python + function of the same name, for generating flexibly-numbered lists + of integers. Original patch contributed by + Kirill Ishanov. +

        + +

        + 0.4.5
        + Added rest for Arrays and arguments objects, and aliased + first as head, and rest as tail, + thanks to Luke Sutton's patches. + Added tests ensuring that all Underscore Array functions also work on + arguments objects. +

        + +

        + 0.4.4
        + Added isString, and isNumber, for consistency. Fixed + _.isEqual(NaN, NaN) to return true (which is debatable). +

        + +

        + 0.4.3
        + Started using the native StopIteration object in browsers that support it. + Fixed Underscore setup for CommonJS environments. +

        + +

        + 0.4.2
        + Renamed the unwrapping function to value, for clarity. +

        + +

        + 0.4.1
        + Chained Underscore objects now support the Array prototype methods, so + that you can perform the full range of operations on a wrapped array + without having to break your chain. Added a breakLoop method + to break in the middle of any Underscore iteration. Added an + isEmpty function that works on arrays and objects. +

        + +

        + 0.4.0
        + All Underscore functions can now be called in an object-oriented style, + like so: _([1, 2, 3]).map(...);. Original patch provided by + Marc-André Cournoyer. + Wrapped objects can be chained through multiple + method invocations. A functions method + was added, providing a sorted list of all the functions in Underscore. +

        + +

        + 0.3.3
        + Added the JavaScript 1.8 function reduceRight. Aliased it + as foldr, and aliased reduce as foldl. +

        + +

        + 0.3.2
        + Now runs on stock Rhino + interpreters with: load("underscore.js"). + Added identity as a utility function. +

        + +

        + 0.3.1
        + All iterators are now passed in the original collection as their third + argument, the same as JavaScript 1.6's forEach. Iterating over + objects is now called with (value, key, collection), for details + see _.each. +

        + +

        + 0.3.0
        + Added Dmitry Baranovskiy's + comprehensive optimizations, merged in + Kris Kowal's patches to make Underscore + CommonJS and + Narwhal compliant. +

        + +

        + 0.2.0
        + Added compose and lastIndexOf, renamed inject to + reduce, added aliases for inject, filter, + every, some, and forEach. +

        + +

        + 0.1.1
        + Added noConflict, so that the "Underscore" object can be assigned to + other variables. +

        + +

        + 0.1.0
        + Initial release of Underscore.js. +

        + +

        + + A DocumentCloud Project + +

        + +
        + +
        + + + + + + diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/package.json b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/package.json new file mode 100644 index 00000000..8d6d7955 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/package.json @@ -0,0 +1,36 @@ +{ + "name": "underscore", + "description": "JavaScript's functional programming helper library.", + "homepage": "http://underscorejs.org", + "keywords": [ + "util", + "functional", + "server", + "client", + "browser" + ], + "author": { + "name": "Jeremy Ashkenas", + "email": "jeremy@documentcloud.org" + }, + "repository": { + "type": "git", + "url": "git://github.com/documentcloud/underscore.git" + }, + "main": "underscore.js", + "version": "1.4.4", + "devDependencies": { + "phantomjs": "0.2.2" + }, + "scripts": { + "test": "phantomjs test/vendor/runner.js test/index.html?noglobals=true" + }, + "readme": " __\n /\\ \\ __\n __ __ ___ \\_\\ \\ __ _ __ ____ ___ ___ _ __ __ /\\_\\ ____\n /\\ \\/\\ \\ /' _ `\\ /'_ \\ /'__`\\/\\ __\\/ ,__\\ / ___\\ / __`\\/\\ __\\/'__`\\ \\/\\ \\ /',__\\\n \\ \\ \\_\\ \\/\\ \\/\\ \\/\\ \\ \\ \\/\\ __/\\ \\ \\//\\__, `\\/\\ \\__//\\ \\ \\ \\ \\ \\//\\ __/ __ \\ \\ \\/\\__, `\\\n \\ \\____/\\ \\_\\ \\_\\ \\___,_\\ \\____\\\\ \\_\\\\/\\____/\\ \\____\\ \\____/\\ \\_\\\\ \\____\\/\\_\\ _\\ \\ \\/\\____/\n \\/___/ \\/_/\\/_/\\/__,_ /\\/____/ \\/_/ \\/___/ \\/____/\\/___/ \\/_/ \\/____/\\/_//\\ \\_\\ \\/___/\n \\ \\____/\n \\/___/\n\nUnderscore.js is a utility-belt library for JavaScript that provides\nsupport for the usual functional suspects (each, map, reduce, filter...)\nwithout extending any core JavaScript objects.\n\nFor Docs, License, Tests, and pre-packed downloads, see:\nhttp://underscorejs.org\n\nMany thanks to our contributors:\nhttps://github.com/documentcloud/underscore/contributors\n", + "readmeFilename": "README.md", + "_id": "underscore@1.4.4", + "dist": { + "shasum": "401fc6bfa46b28a658d6e3ad7593aa91b0123f14" + }, + "_from": "underscore@~1.4.3", + "_resolved": "https://registry.npmjs.org/underscore/-/underscore-1.4.4.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/package.json b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/package.json new file mode 100644 index 00000000..b25fe8fc --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/node_modules/argparse/package.json @@ -0,0 +1,54 @@ +{ + "name": "argparse", + "description": "Very powerful CLI arguments parser. Native port of argparse - python's options parsing library", + "version": "0.1.13", + "keywords": [ + "cli", + "parser", + "argparse", + "option", + "args" + ], + "homepage": "https://github.com/nodeca/argparse", + "contributors": [ + { + "name": "Eugene Shkuropat" + }, + { + "name": "Paul Jacobson" + } + ], + "bugs": { + "url": "https://github.com/nodeca/argparse/issues" + }, + "license": { + "type": "MIT", + "url": "https://github.com/nodeca/argparse/blob/master/LICENSE" + }, + "repository": { + "type": "git", + "url": "git://github.com/nodeca/argparse.git" + }, + "main": "./index.js", + "scripts": { + "test": "make test" + }, + "dependencies": { + "underscore": "~1.4.3", + "underscore.string": "~2.3.1" + }, + "devDependencies": { + "mocha": "*" + }, + "engines": { + "node": ">= 0.6.0" + }, + "readme": "argparse\n========\n\n[![Build Status](https://secure.travis-ci.org/nodeca/argparse.png?branch=master)](http://travis-ci.org/nodeca/argparse)\n\nCLI arguments parser for node.js. Javascript port of python's\n[argparse](http://docs.python.org/dev/library/argparse.html) module\n(original version 3.2). That's a full port, except some very rare options,\nrecorded in issue tracker.\n\n**NB.** Method names changed to camelCase. See [generated docs](http://nodeca.github.com/argparse/).\n\n\nExample\n=======\n\ntest.js file:\n\n```javascript\n#!/usr/bin/env node\n'use strict';\n\nvar ArgumentParser = require('../lib/argparse').ArgumentParser;\nvar parser = new ArgumentParser({\n version: '0.0.1',\n addHelp:true,\n description: 'Argparse example'\n});\nparser.addArgument(\n [ '-f', '--foo' ],\n {\n help: 'foo bar'\n }\n);\nparser.addArgument(\n [ '-b', '--bar' ],\n {\n help: 'bar foo'\n }\n);\nvar args = parser.parseArgs();\nconsole.dir(args);\n```\n\nDisplay help:\n\n```\n$ ./test.js -h\nusage: example.js [-h] [-v] [-f FOO] [-b BAR]\n\nArgparse example\n\nOptional arguments:\n -h, --help Show this help message and exit.\n -v, --version Show program's version number and exit.\n -f FOO, --foo FOO foo bar\n -b BAR, --bar BAR bar foo\n```\n\nParse arguments:\n\n```\n$ ./test.js -f=3 --bar=4\n{ foo: '3', bar: '4' }\n```\n\nMore [examples](https://github.com/nodeca/argparse/tree/master/examples).\n\n\nArgumentParser objects\n======================\n\n```\nnew ArgumentParser({paramters hash});\n```\n\nCreates a new ArgumentParser object.\n\n**Supported params:**\n\n- ```description``` - Text to display before the argument help.\n- ```epilog``` - Text to display after the argument help.\n- ```addHelp``` - Add a -h/–help option to the parser. (default: True)\n- ```argumentDefault``` - Set the global default value for arguments. (default: None)\n- ```parents``` - A list of ArgumentParser objects whose arguments should also be included.\n- ```prefixChars``` - The set of characters that prefix optional arguments. (default: ‘-‘)\n- ```formatterClass``` - A class for customizing the help output.\n- ```prog``` - The name of the program (default: sys.argv[0])\n- ```usage``` - The string describing the program usage (default: generated)\n- ```conflictHandler``` - Usually unnecessary, defines strategy for resolving conflicting optionals.\n\n**Not supportied yet**\n\n- ```fromfilePrefixChars``` - The set of characters that prefix files from which additional arguments should be read.\n\n\nDetails in [original ArgumentParser guide](http://docs.python.org/dev/library/argparse.html#argumentparser-objects)\n\n\naddArgument() method\n====================\n\n```\nArgumentParser.addArgument([names or flags], {options})\n```\n\nDefines how a single command-line argument should be parsed.\n\n- ```name or flags``` - Either a name or a list of option strings, e.g. foo or -f, --foo.\n\nOptions:\n\n- ```action``` - The basic type of action to be taken when this argument is encountered at the command line.\n- ```nargs```- The number of command-line arguments that should be consumed.\n- ```constant``` - A constant value required by some action and nargs selections.\n- ```defaultValue``` - The value produced if the argument is absent from the command line.\n- ```type``` - The type to which the command-line argument should be converted.\n- ```choices``` - A container of the allowable values for the argument.\n- ```required``` - Whether or not the command-line option may be omitted (optionals only).\n- ```help``` - A brief description of what the argument does.\n- ```metavar``` - A name for the argument in usage messages.\n- ```dest``` - The name of the attribute to be added to the object returned by parseArgs().\n\nDetails in [original add_argument guide](http://docs.python.org/dev/library/argparse.html#the-add-argument-method)\n\n\nAction (some details)\n================\n\nArgumentParser objects associate command-line arguments with actions.\nThese actions can do just about anything with the command-line arguments associated\nwith them, though most actions simply add an attribute to the object returned by\nparseArgs(). The action keyword argument specifies how the command-line arguments\nshould be handled. The supported actions are:\n\n- ```store``` - Just stores the argument’s value. This is the default action.\n- ```storeConst``` - Stores value, specified by the const keyword argument.\n (Note that the const keyword argument defaults to the rather unhelpful None.)\n The 'storeConst' action is most commonly used with optional arguments, that\n specify some sort of flag.\n- ```storeTrue``` and ```storeFalse``` - Stores values True and False\n respectively. These are special cases of 'storeConst'.\n- ```append``` - Stores a list, and appends each argument value to the list.\n This is useful to allow an option to be specified multiple times.\n- ```appendConst``` - Stores a list, and appends value, specified by the\n const keyword argument to the list. (Note, that the const keyword argument defaults\n is None.) The 'appendConst' action is typically used when multiple arguments need\n to store constants to the same list.\n- ```count``` - Counts the number of times a keyword argument occurs. For example,\n used for increasing verbosity levels.\n- ```help``` - Prints a complete help message for all the options in the current\n parser and then exits. By default a help action is automatically added to the parser.\n See ArgumentParser for details of how the output is created.\n- ```version``` - Prints version information and exit. Expects a `version=`\n keyword argument in the addArgument() call.\n\nDetails in [original action guide](http://docs.python.org/dev/library/argparse.html#action)\n\n\nSub-commands\n============\n\nArgumentParser.addSubparsers()\n\nMany programs split their functionality into a number of sub-commands, for\nexample, the svn program can invoke sub-commands like `svn checkout`, `svn update`,\nand `svn commit`. Splitting up functionality this way can be a particularly good\nidea when a program performs several different functions which require different\nkinds of command-line arguments. `ArgumentParser` supports creation of such\nsub-commands with `addSubparsers()` method. The `addSubparsers()` method is\nnormally called with no arguments and returns an special action object.\nThis object has a single method `addParser()`, which takes a command name and\nany `ArgumentParser` constructor arguments, and returns an `ArgumentParser` object\nthat can be modified as usual.\n\nExample:\n\nsub_commands.js\n```javascript\n#!/usr/bin/env node\n'use strict';\n\nvar ArgumentParser = require('../lib/argparse').ArgumentParser;\nvar parser = new ArgumentParser({\n version: '0.0.1',\n addHelp:true,\n description: 'Argparse examples: sub-commands',\n});\n\nvar subparsers = parser.addSubparsers({\n title:'subcommands',\n dest:\"subcommand_name\"\n});\n\nvar bar = subparsers.addParser('c1', {addHelp:true});\nbar.addArgument(\n [ '-f', '--foo' ],\n {\n action: 'store',\n help: 'foo3 bar3'\n }\n);\nvar bar = subparsers.addParser(\n 'c2',\n {aliases:['co'], addHelp:true}\n);\nbar.addArgument(\n [ '-b', '--bar' ],\n {\n action: 'store',\n type: 'int',\n help: 'foo3 bar3'\n }\n);\n\nvar args = parser.parseArgs();\nconsole.dir(args);\n\n```\n\nDetails in [original sub-commands guide](http://docs.python.org/dev/library/argparse.html#sub-commands)\n\n\nContributors\n============\n\n- [Eugene Shkuropat](https://github.com/shkuropat)\n- [Paul Jacobson](https://github.com/hpaulj)\n\n[others](https://github.com/nodeca/argparse/graphs/contributors)\n\nLicense\n=======\n\nCopyright (c) 2012 [Vitaly Puzrin](https://github.com/puzrin).\nReleased under the MIT license. See\n[LICENSE](https://github.com/nodeca/argparse/blob/master/LICENSE) for details.\n\n\n", + "readmeFilename": "README.md", + "_id": "argparse@0.1.13", + "dist": { + "shasum": "645c024a7b8ed80970450c2185c9864f79f8ada0" + }, + "_from": "argparse@~ 0.1.11", + "_resolved": "https://registry.npmjs.org/argparse/-/argparse-0.1.13.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/js-yaml/package.json b/Phaser/node_modules/grunt/node_modules/js-yaml/package.json new file mode 100644 index 00000000..3343344c --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/js-yaml/package.json @@ -0,0 +1,63 @@ +{ + "name": "js-yaml", + "version": "2.0.4", + "description": "YAML 1.2 parser and serializer", + "keywords": [ + "yaml", + "parser", + "serializer", + "pyyaml" + ], + "homepage": "https://github.com/nodeca/js-yaml", + "author": { + "name": "Dervus Grim", + "email": "dervus@lavabit.com" + }, + "contributors": [ + { + "name": "Aleksey V Zapparov", + "email": "ixti@member.fsf.org", + "url": "http://www.ixti.net/" + }, + { + "name": "Martin Grenfell", + "email": "martin.grenfell@gmail.com", + "url": "http://got-ravings.blogspot.com" + } + ], + "bugs": { + "url": "https://github.com/nodeca/js-yaml/issues" + }, + "license": { + "type": "MIT", + "url": "https://github.com/nodeca/js-yaml/blob/master/LICENSE" + }, + "repository": { + "type": "git", + "url": "git://github.com/nodeca/js-yaml.git" + }, + "main": "./index.js", + "bin": { + "js-yaml": "bin/js-yaml.js" + }, + "scripts": { + "test": "make test" + }, + "dependencies": { + "argparse": "~ 0.1.11" + }, + "devDependencies": { + "mocha": "*" + }, + "engines": { + "node": ">= 0.6.0" + }, + "readme": "JS-YAML - YAML 1.2 parser and serializer for JavaScript\n=======================================================\n\n[![Build Status](https://secure.travis-ci.org/nodeca/js-yaml.png)](http://travis-ci.org/nodeca/js-yaml)\n\n[Online Demo](http://nodeca.github.com/js-yaml/)\n\n\nThis is an implementation of [YAML](http://yaml.org/), a human friendly data\nserialization language. Started as [PyYAML](http://pyyaml.org/) port, it was\ncompletely rewritten from scratch. Now it's very fast, and supports 1.2 spec.\n\n\nBreaking changes in 1.x.x -> 2.0.x\n----------------------------------\n\nIf your have not used __custom__ tags or loader classes - no changes needed. Just\nupgrade library and enjoy high parse speed.\n\nIn other case, you should rewrite your tag constructors and custom loader\nclasses, to conform new schema-based API. See\n[examples](https://github.com/nodeca/js-yaml/tree/master/examples) and\n[wiki](https://github.com/nodeca/js-yaml/wiki) for details.\nNote, that parser internals were completely rewritten.\n\n\nInstallation\n------------\n\n### YAML module for node.js\n\n```\nnpm install js-yaml\n```\n\n\n### CLI executable\n\nIf you want to inspect your YAML files from CLI, install js-yaml globally:\n\n```\nnpm install js-yaml -g\n```\n\n#### Usage\n\n```\nusage: js-yaml [-h] [-v] [-c] [-j] [-t] file\n\nPositional arguments:\n file File with YAML document(s)\n\nOptional arguments:\n -h, --help Show this help message and exit.\n -v, --version Show program's version number and exit.\n -c, --compact Display errors in compact mode\n -j, --to-json Output a non-funky boring JSON\n -t, --trace Show stack trace on error\n```\n\n\n### Bundled YAML library for browsers\n\n``` html\n\n\n```\n\nBrowser support was done mostly for online demo. If you find any errors - feel\nfree to send pull requests with fixes. Also note, that IE and other old browsers\nneeds [es5-shims](https://github.com/kriskowal/es5-shim) to operate.\n\n\nAPI\n---\n\nHere we cover the most 'useful' methods. If you need advanced details (creating\nyour own tags), see [wiki](https://github.com/nodeca/js-yaml/wiki) and\n[examples](https://github.com/nodeca/js-yaml/tree/master/examples) for more\ninfo.\n\nIn node.js JS-YAML automatically registers handlers for `.yml` and `.yaml`\nfiles. You can load them just with `require`. That's mostly equivalent to\ncalling `load()` on fetched content of a file. Just with one string!\n\n``` javascript\nrequire('js-yaml');\n\n// Get document, or throw exception on error\ntry {\n var doc = require('/home/ixti/example.yml');\n console.log(doc);\n} catch (e) {\n console.log(e);\n}\n```\n\n\n### load (string [ , options ])\n\nParses `string` as single YAML document. Returns a JavaScript object or throws\n`YAMLException` on error.\n\nNOTE: This function **does not** understands multi-document sources, it throws\nexception on those.\n\noptions:\n\n- `filename` _(default: null)_ - string to be used as a file path in\n error/warning messages.\n- `strict` _(default - false)_ makes the loader to throw errors instead of\n warnings.\n- `schema` _(default: `DEFAULT_SCHEMA`)_ - specifies a schema to use.\n\n\n### loadAll (string, iterator [ , options ])\n\nSame as `load()`, but understands multi-document sources and apply `iterator` to\neach document.\n\n``` javascript\nvar yaml = require('js-yaml');\n\nyaml.loadAll(data, function (doc) {\n console.log(doc);\n});\n```\n\n\n### safeLoad (string [ , options ])\n\nSame as `load()` but uses `SAFE_SCHEMA` by default - only recommended tags of\nYAML specification (no JavaScript-specific tags, e.g. `!!js/regexp`).\n\n\n### safeLoadAll (string, iterator [ , options ])\n\nSame as `loadAll()` but uses `SAFE_SCHEMA` by default - only recommended tags of\nYAML specification (no JavaScript-specific tags, e.g. `!!js/regexp`).\n\n\n### dump (object [ , options ])\n\nSerializes `object` as YAML document.\n\noptions:\n\n- `indent` _(default: 2)_ - indentation width to use (in spaces).\n- `flowLevel` (default: -1) - specifies level of nesting, when to switch from\n block to flow style for collections. -1 means block style everwhere\n- `styles` - \"tag\" => \"style\" map. Each tag may have own set of styles.\n- `schema` _(default: `DEFAULT_SCHEMA`)_ specifies a schema to use.\n\nstyles:\n\n``` none\n!!null\n \"canonical\" => \"~\"\n\n!!int\n \"binary\" => \"0b1\", \"0b101010\", \"0b1110001111010\"\n \"octal\" => \"01\", \"052\", \"016172\"\n \"decimal\" => \"1\", \"42\", \"7290\"\n \"hexadecimal\" => \"0x1\", \"0x2A\", \"0x1C7A\"\n\n!!null, !!bool, !!float\n \"lowercase\" => \"null\", \"true\", \"false\", \".nan\", '.inf'\n \"uppercase\" => \"NULL\", \"TRUE\", \"FALSE\", \".NAN\", '.INF'\n \"camelcase\" => \"Null\", \"True\", \"False\", \".NaN\", '.Inf'\n```\n\nBy default, !!int uses `decimal`, and !!null, !!bool, !!float use `lowercase`.\n\n\n### safeDump (object [ , options ])\n\nSame as `dump()` but uses `SAFE_SCHEMA` by default - only recommended tags of\nYAML specification (no JavaScript-specific tags, e.g. `!!js/regexp`).\n\n\nSupported YAML types\n--------------------\n\nThe list of standard YAML tags and corresponding JavaScipt types. See also\n[YAML tag discussion](http://pyyaml.org/wiki/YAMLTagDiscussion) and\n[YAML types repository](http://yaml.org/type/).\n\n```\n!!null '' # null\n!!bool 'yes' # bool\n!!int '3...' # number\n!!float '3.14...' # number\n!!binary '...base64...' # buffer\n!!timestamp 'YYYY-...' # date\n!!omap [ ... ] # array of key-value pairs\n!!pairs [ ... ] # array or array pairs\n!!set { ... } # array of objects with given keys and null values\n!!str '...' # string\n!!seq [ ... ] # array\n!!map { ... } # object\n```\n\n**JavaScript-specific tags**\n\n```\n!!js/regexp /pattern/gim # RegExp\n!!js/undefined '' # Undefined\n!!js/function 'function () {...}' # Function\n```\n\n\n\n\n## Caveats\n\nNote, that you use arrays or objects as key in JS-YAML. JS do not allows objects\nor array as keys, and stringifies (by calling .toString method) them at the\nmoment of adding them.\n\n``` yaml\n---\n? [ foo, bar ]\n: - baz\n? { foo: bar }\n: - baz\n - baz\n```\n\n``` javascript\n{ \"foo,bar\": [\"baz\"], \"[object Object]\": [\"baz\", \"baz\"] }\n```\n\nAlso, reading of properties on implicit block mapping keys is not supported yet.\nSo, the following YAML document cannot be loaded.\n\n``` yaml\n&anchor foo:\n foo: bar\n *anchor: duplicate key\n baz: bat\n *anchor: duplicate key\n```\n\n## License\n\nView the [LICENSE](https://github.com/nodeca/js-yaml/blob/master/LICENSE) file\n(MIT).\n", + "readmeFilename": "README.md", + "_id": "js-yaml@2.0.4", + "dist": { + "shasum": "791f932f9c2267b6038d84784d3b8760e0120329" + }, + "_from": "js-yaml@~2.0.2", + "_resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-2.0.4.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/lodash/LICENSE.txt b/Phaser/node_modules/grunt/node_modules/lodash/LICENSE.txt new file mode 100644 index 00000000..b194ad1d --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright 2012 John-David Dalton +Based on Underscore.js 1.3.3, copyright 2009-2012 Jeremy Ashkenas, +DocumentCloud Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/lodash/README.md b/Phaser/node_modules/grunt/node_modules/lodash/README.md new file mode 100644 index 00000000..cde0ebb9 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/README.md @@ -0,0 +1,247 @@ +# Lo-Dash v0.9.2 +[![build status](https://secure.travis-ci.org/bestiejs/lodash.png)](http://travis-ci.org/bestiejs/lodash) + +A drop-in replacement[*](https://github.com/bestiejs/lodash/wiki/Drop-in-Disclaimer) for Underscore.js, from the devs behind [jsPerf.com](http://jsperf.com), delivering [performance](http://lodash.com/benchmarks), [bug fixes](https://github.com/bestiejs/lodash#resolved-underscorejs-issues), and [additional features](http://lodash.com/#features). + +Lo-Dash’s performance is gained by avoiding slower native methods, instead opting for simplified non-ES5 compliant methods optimized for common usage, and by leveraging function compilation to reduce the number of overall function calls. + +## Download + + * [Development build](https://raw.github.com/bestiejs/lodash/v0.9.2/lodash.js) + * [Production build](https://raw.github.com/bestiejs/lodash/v0.9.2/lodash.min.js) + * [Underscore build](https://raw.github.com/bestiejs/lodash/v0.9.2/lodash.underscore.min.js) tailored for projects already using Underscore + * CDN copies of ≤ v0.9.2’s [Production](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.9.2/lodash.min.js), [Underscore](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.9.2/lodash.underscore.min.js), and [Development](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.9.2/lodash.js) builds are available on [cdnjs](http://cdnjs.com/) thanks to [CloudFlare](http://www.cloudflare.com/) + * For optimal file size, [create a custom build](https://github.com/bestiejs/lodash#custom-builds) with only the features you need + +## Dive in + +We’ve got [API docs](http://lodash.com/docs), [benchmarks](http://lodash.com/benchmarks), and [unit tests](http://lodash.com/tests). + +Create your own benchmarks at [jsPerf](http://jsperf.com), or [search](http://jsperf.com/search?q=lodash) for existing ones. + +For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/lodash/wiki/Roadmap). + +## Screencasts + +For more information check out these screencasts over Lo-Dash: + + * [Introducing Lo-Dash](https://vimeo.com/44154599) + * [Lo-Dash optimizations and custom builds](https://vimeo.com/44154601) + * [Lo-Dash’s origin and why it’s a better utility belt](https://vimeo.com/44154600) + * [Unit testing in Lo-Dash](https://vimeo.com/45865290) + * [Lo-Dash’s approach to native method use](https://vimeo.com/48576012) + +## Features + + * AMD loader support ([RequireJS](http://requirejs.org/), [curl.js](https://github.com/cujojs/curl), etc.) + * [_.clone](http://lodash.com/docs#clone) supports *“deepâ€* cloning + * [_.contains](http://lodash.com/docs#contains) accepts a `fromIndex` argument + * [_.forEach](http://lodash.com/docs#forEach) is chainable and supports exiting iteration early + * [_.forIn](http://lodash.com/docs#forIn) for iterating over an object’s own and inherited properties + * [_.forOwn](http://lodash.com/docs#forOwn) for iterating over an object’s own properties + * [_.isPlainObject](http://lodash.com/docs#isPlainObject) checks if values are created by the `Object` constructor + * [_.lateBind](http://lodash.com/docs#lateBind) for late binding + * [_.merge](http://lodash.com/docs#merge) for a *“deepâ€* [_.extend](http://lodash.com/docs#extend) + * [_.partial](http://lodash.com/docs#partial) for partial application without `this` binding + * [_.pick](http://lodash.com/docs#pick) and [_.omit](http://lodash.com/docs#omit) accepts `callback` and `thisArg` arguments + * [_.template](http://lodash.com/docs#template) supports [ES6 delimiters](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6) and utilizes [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) for easier debugging + * [_.contains](http://lodash.com/docs#contains), [_.size](http://lodash.com/docs#size), [_.toArray](http://lodash.com/docs#toArray), + [and more…](http://lodash.com/docs "_.countBy, _.every, _.filter, _.find, _.forEach, _.groupBy, _.invoke, _.map, _.max, _.min, _.pluck, _.reduce, _.reduceRight, _.reject, _.shuffle, _.some, _.sortBy, _.where") accept strings + +## Support + +Lo-Dash has been tested in at least Chrome 5~23, Firefox 1~16, IE 6-10, Opera 9.25-12, Safari 3-6, Node.js 0.4.8-0.8.14, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC5. + +## Custom builds + +Custom builds make it easy to create lightweight versions of Lo-Dash containing only the methods you need. +To top it off, we handle all method dependency and alias mapping for you. + + * Backbone builds, with only methods required by Backbone, may be created using the `backbone` modifier argument. +```bash +lodash backbone +``` + + * CSP builds, supporting default Content Security Policy restrictions, may be created using the `csp` modifier argument. +```bash +lodash csp +``` + + * Legacy builds, tailored for older browsers without [ES5 support](http://es5.github.com/), may be created using the `legacy` modifier argument. +```bash +lodash legacy +``` + + * Mobile builds, with IE < 9 bug fixes and method compilation removed, may be created using the `mobile` modifier argument. +```bash +lodash mobile +``` + + * Strict builds, with `_.bindAll`, `_.defaults`, and `_.extend` in [strict mode](http://es5.github.com/#C), may be created using the `strict` modifier argument. +```bash +lodash strict +``` + + * Underscore builds, tailored for projects already using Underscore, may be created using the `underscore` modifier argument. +```bash +lodash underscore +``` + +Custom builds may be created using the following commands: + + * Use the `category` argument to pass comma separated categories of methods to include in the build.
        + Valid categories (case-insensitive) are *“arraysâ€*, *“chainingâ€*, *“collectionsâ€*, *“functionsâ€*, *“objectsâ€*, and *“utilitiesâ€*. +```bash +lodash category=collections,functions +lodash category="collections, functions" +``` + + * Use the `exports` argument to pass comma separated names of ways to export the `LoDash` function.
        + Valid exports are *“amdâ€*, *“commonjsâ€*, *“globalâ€*, *“nodeâ€*, and *“noneâ€*. +```bash +lodash exports=amd,commonjs,node +lodash exports="amd, commonjs, node" +``` + + * Use the `iife` argument to specify code to replace the immediately-invoked function expression that wraps Lo-Dash. +```bash +lodash iife="!function(window,undefined){%output%}(this)" +``` + + * Use the `include` argument to pass comma separated method/category names to include in the build. +```bash +lodash include=each,filter,map +lodash include="each, filter, map" +``` + + * Use the `minus` argument to pass comma separated method/category names to remove from those included in the build. +```bash +lodash underscore minus=result,shuffle +lodash underscore minus="result, shuffle" +``` + + * Use the `plus` argument to pass comma separated method/category names to add to those included in the build. +```bash +lodash backbone plus=random,template +lodash backbone plus="random, template" +``` + + * Use the `template` argument to pass the file path pattern used to match template files to precompile. +```bash +lodash template="./*.jst" +``` + + * Use the `settings` argument to pass the template settings used when precompiling templates. +```bash +lodash settings="{interpolate:/\\{\\{([\\s\\S]+?)\\}\\}/g}" +``` + + * Use the `moduleId` argument to specify the AMD module ID of Lo-Dash, which defaults to “lodashâ€, used by precompiled templates. +```bash +lodash moduleId="underscore" +``` + +All arguments, except `legacy` with `csp` or `mobile`, may be combined.
        +Unless specified by `-o` or `--output`, all files created are saved to the current working directory. + +The following options are also supported: + + * `-c`, `--stdout`     Write output to standard output + * `-d`, `--debug`       Write only the debug output + * `-h`, `--help`         Display help information + * `-m`, `--minify`     Write only the minified output + * `-o`, `--output`     Write output to a given path/filename + * `-s`, `--silent`     Skip status updates normally logged to the console + * `-V`, `--version`   Output current version of Lo-Dash + +The `lodash` command-line utility is available when Lo-Dash is installed as a global package (i.e. `npm install -g lodash`). + +## Installation and usage + +In browsers: + +```html + +``` + +Using [npm](http://npmjs.org/): + +```bash +npm install lodash + +npm install -g lodash +npm link lodash +``` + +In [Node.js](http://nodejs.org/) and [RingoJS v0.8.0+](http://ringojs.org/): + +```js +var _ = require('lodash'); +``` + +**Note:** If Lo-Dash is installed globally, [run `npm link lodash`](http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/) in your project’s root directory before requiring it. + +In [RingoJS v0.7.0-](http://ringojs.org/): + +```js +var _ = require('lodash')._; +``` + +In [Rhino](http://www.mozilla.org/rhino/): + +```js +load('lodash.js'); +``` + +In an AMD loader like [RequireJS](http://requirejs.org/): + +```js +require({ + 'paths': { + 'underscore': 'path/to/lodash' + } +}, +['underscore'], function(_) { + console.log(_.VERSION); +}); +``` + +## Resolved Underscore.js issues + + * Allow iteration of objects with a `length` property [[#799](https://github.com/documentcloud/underscore/pull/799), [test](https://github.com/bestiejs/lodash/blob/v0.9.2/test/test.js#L545-551)] + * Fix cross-browser object iteration bugs [[#60](https://github.com/documentcloud/underscore/issues/60), [#376](https://github.com/documentcloud/underscore/issues/376), [test](https://github.com/bestiejs/lodash/blob/v0.9.2/test/test.js#L558-582)] + * Methods should work on pages with incorrectly shimmed native methods [[#7](https://github.com/documentcloud/underscore/issues/7), [#742](https://github.com/documentcloud/underscore/issues/742), [test](https://github.com/bestiejs/lodash/blob/v0.9.2/test/test.js#L140-146)] + * `_.isEmpty` should support jQuery/MooTools DOM query collections [[#690](https://github.com/documentcloud/underscore/pull/690), [test](https://github.com/bestiejs/lodash/blob/v0.9.2/test/test.js#L747-752)] + * `_.isObject` should avoid V8 bug [#2291](http://code.google.com/p/v8/issues/detail?id=2291) [[#605](https://github.com/documentcloud/underscore/issues/605), [test](https://github.com/bestiejs/lodash/blob/v0.9.2/test/test.js#L828-840)] + * `_.keys` should work with `arguments` objects cross-browser [[#396](https://github.com/documentcloud/underscore/issues/396), [test](https://github.com/bestiejs/lodash/blob/v0.9.2/test/test.js#L921-923)] + * `_.range` should coerce arguments to numbers [[#634](https://github.com/documentcloud/underscore/issues/634), [#683](https://github.com/documentcloud/underscore/issues/683), [test](https://github.com/bestiejs/lodash/blob/v0.9.2/test/test.js#L1337-1340)] + +## Release Notes + +### v0.9.2 + + * Added `fromIndex` argument to `_.contains` + * Added `moduleId` build option + * Added Closure Compiler *“simpleâ€* optimizations to the build process + * Added support for strings in `_.max` and `_.min` + * Added support for ES6 template delimiters to `_.template` + * Ensured re-minification of Lo-Dash by third parties avoids Closure Compiler bugs + * Optimized `_.every`, `_.find`, `_.some`, and `_.uniq` + +The full changelog is available [here](https://github.com/bestiejs/lodash/wiki/Changelog). + +## BestieJS + +Lo-Dash is part of the BestieJS *“Best in Classâ€* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation. + +## Author + +* [John-David Dalton](http://allyoucanleet.com/) + [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton "Follow @jdalton on Twitter") + +## Contributors + +* [Kit Cambridge](http://kitcambridge.github.com/) + [![twitter/kitcambridge](http://gravatar.com/avatar/6662a1d02f351b5ef2f8b4d815804661?s=70)](https://twitter.com/kitcambridge "Follow @kitcambridge on Twitter") +* [Mathias Bynens](http://mathiasbynens.be/) + [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") diff --git a/Phaser/node_modules/grunt/node_modules/lodash/doc/README.md b/Phaser/node_modules/grunt/node_modules/lodash/doc/README.md new file mode 100644 index 00000000..8ad38fb4 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/doc/README.md @@ -0,0 +1,3095 @@ +# Lo-Dash v0.9.2 + + + + + + +## `Arrays` +* [`_.compact`](#_compactarray) +* [`_.difference`](#_differencearray--array1-array2-) +* [`_.drop`](#_restarray--n1) +* [`_.first`](#_firstarray--n) +* [`_.flatten`](#_flattenarray-shallow) +* [`_.head`](#_firstarray--n) +* [`_.indexOf`](#_indexofarray-value--fromindex0) +* [`_.initial`](#_initialarray--n1) +* [`_.intersection`](#_intersectionarray1-array2-) +* [`_.last`](#_lastarray--n) +* [`_.lastIndexOf`](#_lastindexofarray-value--fromindexarraylength-1) +* [`_.object`](#_objectkeys--values) +* [`_.range`](#_rangestart0-end--step1) +* [`_.rest`](#_restarray--n1) +* [`_.sortedIndex`](#_sortedindexarray-value--callbackidentityproperty-thisarg) +* [`_.tail`](#_restarray--n1) +* [`_.take`](#_firstarray--n) +* [`_.union`](#_unionarray1-array2-) +* [`_.uniq`](#_uniqarray--issortedfalse-callbackidentity-thisarg) +* [`_.unique`](#_uniqarray--issortedfalse-callbackidentity-thisarg) +* [`_.without`](#_withoutarray--value1-value2-) +* [`_.zip`](#_ziparray1-array2-) + + + + + + +## `Chaining` +* [`_`](#_value) +* [`_.chain`](#_chainvalue) +* [`_.tap`](#_tapvalue-interceptor) +* [`_.prototype.chain`](#_prototypechain) +* [`_.prototype.value`](#_prototypevalue) + + + + + + +## `Collections` +* [`_.all`](#_everycollection--callbackidentity-thisarg) +* [`_.any`](#_somecollection--callbackidentity-thisarg) +* [`_.collect`](#_mapcollection--callbackidentity-thisarg) +* [`_.contains`](#_containscollection-target--fromindex0) +* [`_.countBy`](#_countbycollection-callbackproperty--thisarg) +* [`_.detect`](#_findcollection-callback--thisarg) +* [`_.each`](#_foreachcollection-callback--thisarg) +* [`_.every`](#_everycollection--callbackidentity-thisarg) +* [`_.filter`](#_filtercollection--callbackidentity-thisarg) +* [`_.find`](#_findcollection-callback--thisarg) +* [`_.foldl`](#_reducecollection-callback--accumulator-thisarg) +* [`_.foldr`](#_reducerightcollection-callback--accumulator-thisarg) +* [`_.forEach`](#_foreachcollection-callback--thisarg) +* [`_.groupBy`](#_groupbycollection-callbackproperty--thisarg) +* [`_.include`](#_containscollection-target--fromindex0) +* [`_.inject`](#_reducecollection-callback--accumulator-thisarg) +* [`_.invoke`](#_invokecollection-methodname--arg1-arg2-) +* [`_.map`](#_mapcollection--callbackidentity-thisarg) +* [`_.max`](#_maxcollection--callback-thisarg) +* [`_.min`](#_mincollection--callback-thisarg) +* [`_.pluck`](#_pluckcollection-property) +* [`_.reduce`](#_reducecollection-callback--accumulator-thisarg) +* [`_.reduceRight`](#_reducerightcollection-callback--accumulator-thisarg) +* [`_.reject`](#_rejectcollection--callbackidentity-thisarg) +* [`_.select`](#_filtercollection--callbackidentity-thisarg) +* [`_.shuffle`](#_shufflecollection) +* [`_.size`](#_sizecollection) +* [`_.some`](#_somecollection--callbackidentity-thisarg) +* [`_.sortBy`](#_sortbycollection-callbackproperty--thisarg) +* [`_.toArray`](#_toarraycollection) +* [`_.where`](#_wherecollection-properties) + + + + + + +## `Functions` +* [`_.after`](#_aftern-func) +* [`_.bind`](#_bindfunc--thisarg-arg1-arg2-) +* [`_.bindAll`](#_bindallobject--methodname1-methodname2-) +* [`_.compose`](#_composefunc1-func2-) +* [`_.debounce`](#_debouncefunc-wait-immediate) +* [`_.defer`](#_deferfunc--arg1-arg2-) +* [`_.delay`](#_delayfunc-wait--arg1-arg2-) +* [`_.lateBind`](#_latebindobject-methodname--arg1-arg2-) +* [`_.memoize`](#_memoizefunc--resolver) +* [`_.once`](#_oncefunc) +* [`_.partial`](#_partialfunc--arg1-arg2-) +* [`_.throttle`](#_throttlefunc-wait) +* [`_.wrap`](#_wrapvalue-wrapper) + + + + + + +## `Objects` +* [`_.clone`](#_clonevalue-deep) +* [`_.defaults`](#_defaultsobject--default1-default2-) +* [`_.extend`](#_extendobject--source1-source2-) +* [`_.forIn`](#_forinobject-callback--thisarg) +* [`_.forOwn`](#_forownobject-callback--thisarg) +* [`_.functions`](#_functionsobject) +* [`_.has`](#_hasobject-property) +* [`_.invert`](#_invertobject) +* [`_.isArguments`](#_isargumentsvalue) +* [`_.isArray`](#_isarrayvalue) +* [`_.isBoolean`](#_isbooleanvalue) +* [`_.isDate`](#_isdatevalue) +* [`_.isElement`](#_iselementvalue) +* [`_.isEmpty`](#_isemptyvalue) +* [`_.isEqual`](#_isequala-b) +* [`_.isFinite`](#_isfinitevalue) +* [`_.isFunction`](#_isfunctionvalue) +* [`_.isNaN`](#_isnanvalue) +* [`_.isNull`](#_isnullvalue) +* [`_.isNumber`](#_isnumbervalue) +* [`_.isObject`](#_isobjectvalue) +* [`_.isPlainObject`](#_isplainobjectvalue) +* [`_.isRegExp`](#_isregexpvalue) +* [`_.isString`](#_isstringvalue) +* [`_.isUndefined`](#_isundefinedvalue) +* [`_.keys`](#_keysobject) +* [`_.merge`](#_mergeobject--source1-source2-) +* [`_.methods`](#_functionsobject) +* [`_.omit`](#_omitobject-callback-prop1-prop2--thisarg) +* [`_.pairs`](#_pairsobject) +* [`_.pick`](#_pickobject-callback-prop1-prop2--thisarg) +* [`_.values`](#_valuesobject) + + + + + + +## `Utilities` +* [`_.escape`](#_escapestring) +* [`_.identity`](#_identityvalue) +* [`_.mixin`](#_mixinobject) +* [`_.noConflict`](#_noconflict) +* [`_.random`](#_randommin0-max1) +* [`_.result`](#_resultobject-property) +* [`_.template`](#_templatetext-data-options) +* [`_.times`](#_timesn-callback--thisarg) +* [`_.unescape`](#_unescapestring) +* [`_.uniqueId`](#_uniqueidprefix) + + + + + + +## `Properties` +* [`_.VERSION`](#_version) +* [`_.templateSettings`](#_templatesettings) +* [`_.templateSettings.escape`](#_templatesettingsescape) +* [`_.templateSettings.evaluate`](#_templatesettingsevaluate) +* [`_.templateSettings.interpolate`](#_templatesettingsinterpolate) +* [`_.templateSettings.variable`](#_templatesettingsvariable) + + + + + + + + + + + + +## `“Arrays†Methods` + + + +### `_.compact(array)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2554 "View in source") [Ⓣ][1] + +Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. + +#### Arguments +1. `array` *(Array)*: The array to compact. + +#### Returns +*(Array)*: Returns a new filtered array. + +#### Example +```js +_.compact([0, 1, false, 2, '', 3]); +// => [1, 2, 3] +``` + +* * * + + + + + + +### `_.difference(array [, array1, array2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2584 "View in source") [Ⓣ][1] + +Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. + +#### Arguments +1. `array` *(Array)*: The array to process. +2. `[array1, array2, ...]` *(Array)*: Arrays to check. + +#### Returns +*(Array)*: Returns a new array of `array` elements not present in the other arrays. + +#### Example +```js +_.difference([1, 2, 3, 4, 5], [5, 2, 10]); +// => [1, 3, 4] +``` + +* * * + + + + + + +### `_.first(array [, n])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2619 "View in source") [Ⓣ][1] + +Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. + +#### Aliases +*head, take* + +#### Arguments +1. `array` *(Array)*: The array to query. +2. `[n]` *(Number)*: The number of elements to return. + +#### Returns +*(Mixed)*: Returns the first element or an array of the first `n` elements of `array`. + +#### Example +```js +_.first([5, 4, 3, 2, 1]); +// => 5 +``` + +* * * + + + + + + +### `_.flatten(array, shallow)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2643 "View in source") [Ⓣ][1] + +Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. + +#### Arguments +1. `array` *(Array)*: The array to compact. +2. `shallow` *(Boolean)*: A flag to indicate only flattening a single level. + +#### Returns +*(Array)*: Returns a new flattened array. + +#### Example +```js +_.flatten([1, [2], [3, [[4]]]]); +// => [1, 2, 3, 4]; + +_.flatten([1, [2], [3, [[4]]]], true); +// => [1, 2, 3, [[4]]]; +``` + +* * * + + + + + + +### `_.indexOf(array, value [, fromIndex=0])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2685 "View in source") [Ⓣ][1] + +Gets the index at which the first occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `fromIndex` will run a faster binary search. + +#### Arguments +1. `array` *(Array)*: The array to search. +2. `value` *(Mixed)*: The value to search for. +3. `[fromIndex=0]` *(Boolean|Number)*: The index to search from or `true` to perform a binary search on a sorted `array`. + +#### Returns +*(Number)*: Returns the index of the matched value or `-1`. + +#### Example +```js +_.indexOf([1, 2, 3, 1, 2, 3], 2); +// => 1 + +_.indexOf([1, 2, 3, 1, 2, 3], 2, 3); +// => 4 + +_.indexOf([1, 1, 2, 2, 3, 3], 2, true); +// => 2 +``` + +* * * + + + + + + +### `_.initial(array [, n=1])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2720 "View in source") [Ⓣ][1] + +Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. + +#### Arguments +1. `array` *(Array)*: The array to query. +2. `[n=1]` *(Number)*: The number of elements to exclude. + +#### Returns +*(Array)*: Returns all but the last element or `n` elements of `array`. + +#### Example +```js +_.initial([3, 2, 1]); +// => [3, 2] +``` + +* * * + + + + + + +### `_.intersection([array1, array2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2741 "View in source") [Ⓣ][1] + +Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. + +#### Arguments +1. `[array1, array2, ...]` *(Array)*: Arrays to process. + +#### Returns +*(Array)*: Returns a new array of unique elements, in order, that are present in **all** of the arrays. + +#### Example +```js +_.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); +// => [1, 2] +``` + +* * * + + + + + + +### `_.last(array [, n])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2779 "View in source") [Ⓣ][1] + +Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. + +#### Arguments +1. `array` *(Array)*: The array to query. +2. `[n]` *(Number)*: The number of elements to return. + +#### Returns +*(Mixed)*: Returns the last element or an array of the last `n` elements of `array`. + +#### Example +```js +_.last([3, 2, 1]); +// => 1 +``` + +* * * + + + + + + +### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2806 "View in source") [Ⓣ][1] + +Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. + +#### Arguments +1. `array` *(Array)*: The array to search. +2. `value` *(Mixed)*: The value to search for. +3. `[fromIndex=array.length-1]` *(Number)*: The index to search from. + +#### Returns +*(Number)*: Returns the index of the matched value or `-1`. + +#### Example +```js +_.lastIndexOf([1, 2, 3, 1, 2, 3], 2); +// => 4 + +_.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); +// => 1 +``` + +* * * + + + + + + +### `_.object(keys [, values=[]])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2836 "View in source") [Ⓣ][1] + +Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. + +#### Arguments +1. `keys` *(Array)*: The array of keys. +2. `[values=[]]` *(Array)*: The array of values. + +#### Returns +*(Object)*: Returns an object composed of the given keys and corresponding values. + +#### Example +```js +_.object(['moe', 'larry', 'curly'], [30, 40, 50]); +// => { 'moe': 30, 'larry': 40, 'curly': 50 } +``` + +* * * + + + + + + +### `_.range([start=0], end [, step=1])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2881 "View in source") [Ⓣ][1] + +Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. + +#### Arguments +1. `[start=0]` *(Number)*: The start of the range. +2. `end` *(Number)*: The end of the range. +3. `[step=1]` *(Number)*: The value to increment or descrement by. + +#### Returns +*(Array)*: Returns a new range array. + +#### Example +```js +_.range(10); +// => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + +_.range(1, 11); +// => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + +_.range(0, 30, 5); +// => [0, 5, 10, 15, 20, 25] + +_.range(0, -10, -1); +// => [0, -1, -2, -3, -4, -5, -6, -7, -8, -9] + +_.range(0); +// => [] +``` + +* * * + + + + + + +### `_.rest(array [, n=1])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2920 "View in source") [Ⓣ][1] + +The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. + +#### Aliases +*drop, tail* + +#### Arguments +1. `array` *(Array)*: The array to query. +2. `[n=1]` *(Number)*: The number of elements to exclude. + +#### Returns +*(Array)*: Returns all but the first value or `n` values of `array`. + +#### Example +```js +_.rest([3, 2, 1]); +// => [2, 1] +``` + +* * * + + + + + + +### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2966 "View in source") [Ⓣ][1] + +Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. + +#### Arguments +1. `array` *(Array)*: The array to iterate over. +2. `value` *(Mixed)*: The value to evaluate. +3. `[callback=identity|property]` *(Function|String)*: The function called per iteration or property name to order by. +4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Number)*: Returns the index at which the value should be inserted into `array`. + +#### Example +```js +_.sortedIndex([20, 30, 50], 40); +// => 2 + +_.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); +// => 2 + +var dict = { + 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 } +}; + +_.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { + return dict.wordToNumber[word]; +}); +// => 2 + +_.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { + return this.wordToNumber[word]; +}, dict); +// => 2 +``` + +* * * + + + + + + +### `_.union([array1, array2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2997 "View in source") [Ⓣ][1] + +Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. + +#### Arguments +1. `[array1, array2, ...]` *(Array)*: Arrays to process. + +#### Returns +*(Array)*: Returns a new array of unique values, in order, that are present in one or more of the arrays. + +#### Example +```js +_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); +// => [1, 2, 3, 101, 10] +``` + +* * * + + + + + + +### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3031 "View in source") [Ⓣ][1] + +Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. + +#### Aliases +*unique* + +#### Arguments +1. `array` *(Array)*: The array to process. +2. `[isSorted=false]` *(Boolean)*: A flag to indicate that the `array` is already sorted. +3. `[callback=identity]` *(Function)*: The function called per iteration. +4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Array)*: Returns a duplicate-value-free array. + +#### Example +```js +_.uniq([1, 2, 1, 3, 1]); +// => [1, 2, 3] + +_.uniq([1, 1, 2, 2, 3], true); +// => [1, 2, 3] + +_.uniq([1, 2, 1.5, 3, 2.5], function(num) { return Math.floor(num); }); +// => [1, 2, 3] + +_.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); +// => [1, 2, 3] +``` + +* * * + + + + + + +### `_.without(array [, value1, value2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3089 "View in source") [Ⓣ][1] + +Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. + +#### Arguments +1. `array` *(Array)*: The array to filter. +2. `[value1, value2, ...]` *(Mixed)*: Values to remove. + +#### Returns +*(Array)*: Returns a new filtered array. + +#### Example +```js +_.without([1, 2, 1, 0, 3, 1, 4], 0, 1); +// => [2, 3, 4] +``` + +* * * + + + + + + +### `_.zip([array1, array2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3120 "View in source") [Ⓣ][1] + +Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. + +#### Arguments +1. `[array1, array2, ...]` *(Array)*: Arrays to process. + +#### Returns +*(Array)*: Returns a new array of grouped elements. + +#### Example +```js +_.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); +// => [['moe', 30, true], ['larry', 40, false], ['curly', 50, false]] +``` + +* * * + + + + + + + + + +## `“Chaining†Methods` + + + +### `_(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L242 "View in source") [Ⓣ][1] + +The `lodash` function. + +#### Arguments +1. `value` *(Mixed)*: The value to wrap in a `lodash` instance. + +#### Returns +*(Object)*: Returns a `lodash` instance. + +* * * + + + + + + +### `_.chain(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3985 "View in source") [Ⓣ][1] + +Wraps the value in a `lodash` wrapper object. + +#### Arguments +1. `value` *(Mixed)*: The value to wrap. + +#### Returns +*(Object)*: Returns the wrapper object. + +#### Example +```js +var stooges = [ + { 'name': 'moe', 'age': 40 }, + { 'name': 'larry', 'age': 50 }, + { 'name': 'curly', 'age': 60 } +]; + +var youngest = _.chain(stooges) + .sortBy(function(stooge) { return stooge.age; }) + .map(function(stooge) { return stooge.name + ' is ' + stooge.age; }) + .first() + .value(); +// => 'moe is 40' +``` + +* * * + + + + + + +### `_.tap(value, interceptor)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4012 "View in source") [Ⓣ][1] + +Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. + +#### Arguments +1. `value` *(Mixed)*: The value to pass to `interceptor`. +2. `interceptor` *(Function)*: The function to invoke. + +#### Returns +*(Mixed)*: Returns `value`. + +#### Example +```js +_.chain([1, 2, 3, 200]) + .filter(function(num) { return num % 2 == 0; }) + .tap(alert) + .map(function(num) { return num * num }) + .value(); +// => // [2, 200] (alerted) +// => [4, 40000] +``` + +* * * + + + + + + +### `_.prototype.chain()` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4030 "View in source") [Ⓣ][1] + +Enables method chaining on the wrapper object. + +#### Returns +*(Mixed)*: Returns the wrapper object. + +#### Example +```js +_([1, 2, 3]).value(); +// => [1, 2, 3] +``` + +* * * + + + + + + +### `_.prototype.value()` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4047 "View in source") [Ⓣ][1] + +Extracts the wrapped value. + +#### Returns +*(Mixed)*: Returns the wrapped value. + +#### Example +```js +_([1, 2, 3]).value(); +// => [1, 2, 3] +``` + +* * * + + + + + + + + + +## `“Collections†Methods` + + + +### `_.contains(collection, target [, fromIndex=0])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1837 "View in source") [Ⓣ][1] + +Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. + +#### Aliases +*include* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `target` *(Mixed)*: The value to check for. +3. `[fromIndex=0]` *(Number)*: The index to search from. + +#### Returns +*(Boolean)*: Returns `true` if the `target` element is found, else `false`. + +#### Example +```js +_.contains([1, 2, 3], 1); +// => true + +_.contains([1, 2, 3], 1, 2); +// => false + +_.contains({ 'name': 'moe', 'age': 40 }, 'moe'); +// => true + +_.contains('curly', 'ur'); +// => true +``` + +* * * + + + + + + +### `_.countBy(collection, callback|property [, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1879 "View in source") [Ⓣ][1] + +Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `callback|property` *(Function|String)*: The function called per iteration or property name to count by. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Object)*: Returns the composed aggregate object. + +#### Example +```js +_.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); }); +// => { '4': 1, '6': 2 } + +_.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math); +// => { '4': 1, '6': 2 } + +_.countBy(['one', 'two', 'three'], 'length'); +// => { '3': 2, '5': 1 } +``` + +* * * + + + + + + +### `_.every(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1908 "View in source") [Ⓣ][1] + +Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. + +#### Aliases +*all* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function)*: The function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Boolean)*: Returns `true` if all elements pass the callback check, else `false`. + +#### Example +```js +_.every([true, 1, null, 'yes'], Boolean); +// => false +``` + +* * * + + + + + + +### `_.filter(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1947 "View in source") [Ⓣ][1] + +Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. + +#### Aliases +*select* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function)*: The function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Array)*: Returns a new array of elements that passed the callback check. + +#### Example +```js +var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); +// => [2, 4, 6] +``` + +* * * + + + + + + +### `_.find(collection, callback [, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1978 "View in source") [Ⓣ][1] + +Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. + +#### Aliases +*detect* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `callback` *(Function)*: The function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Mixed)*: Returns the element that passed the callback check, else `undefined`. + +#### Example +```js +var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); +// => 2 +``` + +* * * + + + + + + +### `_.forEach(collection, callback [, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2012 "View in source") [Ⓣ][1] + +Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. + +#### Aliases +*each* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `callback` *(Function)*: The function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Array, Object, String)*: Returns `collection`. + +#### Example +```js +_([1, 2, 3]).forEach(alert).join(','); +// => alerts each number and returns '1,2,3' + +_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); +// => alerts each number (order is not guaranteed) +``` + +* * * + + + + + + +### `_.groupBy(collection, callback|property [, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2040 "View in source") [Ⓣ][1] + +Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `callback|property` *(Function|String)*: The function called per iteration or property name to group by. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Object)*: Returns the composed aggregate object. + +#### Example +```js +_.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); }); +// => { '4': [4.2], '6': [6.1, 6.4] } + +_.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math); +// => { '4': [4.2], '6': [6.1, 6.4] } + +_.groupBy(['one', 'two', 'three'], 'length'); +// => { '3': ['one', 'two'], '5': ['three'] } +``` + +* * * + + + + + + +### `_.invoke(collection, methodName [, arg1, arg2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2072 "View in source") [Ⓣ][1] + +Invokes the method named by `methodName` on each element in the `collection`, returning an array of the results of each invoked method. Additional arguments will be passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `methodName` *(Function|String)*: The name of the method to invoke or the function invoked per iteration. +3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the method with. + +#### Returns +*(Array)*: Returns a new array of the results of each invoked method. + +#### Example +```js +_.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); +// => [[1, 5, 7], [1, 2, 3]] + +_.invoke([123, 456], String.prototype.split, ''); +// => [['1', '2', '3'], ['4', '5', '6']] +``` + +* * * + + + + + + +### `_.map(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2104 "View in source") [Ⓣ][1] + +Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. + +#### Aliases +*collect* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function)*: The function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Array)*: Returns a new array of the results of each `callback` execution. + +#### Example +```js +_.map([1, 2, 3], function(num) { return num * 3; }); +// => [3, 6, 9] + +_.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); +// => [3, 6, 9] (order is not guaranteed) +``` + +* * * + + + + + + +### `_.max(collection [, callback, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2146 "View in source") [Ⓣ][1] + +Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback]` *(Function)*: The function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Mixed)*: Returns the maximum value. + +#### Example +```js +var stooges = [ + { 'name': 'moe', 'age': 40 }, + { 'name': 'larry', 'age': 50 }, + { 'name': 'curly', 'age': 60 } +]; + +_.max(stooges, function(stooge) { return stooge.age; }); +// => { 'name': 'curly', 'age': 60 }; +``` + +* * * + + + + + + +### `_.min(collection [, callback, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2192 "View in source") [Ⓣ][1] + +Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback]` *(Function)*: The function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Mixed)*: Returns the minimum value. + +#### Example +```js +_.min([10, 5, 100, 2, 1000]); +// => 2 +``` + +* * * + + + + + + +### `_.pluck(collection, property)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2241 "View in source") [Ⓣ][1] + +Retrieves the value of a specified property from all elements in the `collection`. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `property` *(String)*: The property to pluck. + +#### Returns +*(Array)*: Returns a new array of property values. + +#### Example +```js +var stooges = [ + { 'name': 'moe', 'age': 40 }, + { 'name': 'larry', 'age': 50 }, + { 'name': 'curly', 'age': 60 } +]; + +_.pluck(stooges, 'name'); +// => ['moe', 'larry', 'curly'] +``` + +* * * + + + + + + +### `_.reduce(collection, callback [, accumulator, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2269 "View in source") [Ⓣ][1] + +Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*. + +#### Aliases +*foldl, inject* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `callback` *(Function)*: The function called per iteration. +3. `[accumulator]` *(Mixed)*: Initial value of the accumulator. +4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Mixed)*: Returns the accumulated value. + +#### Example +```js +var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); +// => 6 +``` + +* * * + + + + + + +### `_.reduceRight(collection, callback [, accumulator, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2298 "View in source") [Ⓣ][1] + +The right-associative version of `_.reduce`. + +#### Aliases +*foldr* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `callback` *(Function)*: The function called per iteration. +3. `[accumulator]` *(Mixed)*: Initial value of the accumulator. +4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Mixed)*: Returns the accumulated value. + +#### Example +```js +var list = [[0, 1], [2, 3], [4, 5]]; +var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); +// => [4, 5, 2, 3, 0, 1] +``` + +* * * + + + + + + +### `_.reject(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2335 "View in source") [Ⓣ][1] + +The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function)*: The function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Array)*: Returns a new array of elements that did **not** pass the callback check. + +#### Example +```js +var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); +// => [1, 3, 5] +``` + +* * * + + + + + + +### `_.shuffle(collection)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2356 "View in source") [Ⓣ][1] + +Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to shuffle. + +#### Returns +*(Array)*: Returns a new shuffled collection. + +#### Example +```js +_.shuffle([1, 2, 3, 4, 5, 6]); +// => [4, 1, 6, 3, 5, 2] +``` + +* * * + + + + + + +### `_.size(collection)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2388 "View in source") [Ⓣ][1] + +Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to inspect. + +#### Returns +*(Number)*: Returns `collection.length` or number of own enumerable properties. + +#### Example +```js +_.size([1, 2]); +// => 2 + +_.size({ 'one': 1, 'two': 2, 'three': 3 }); +// => 3 + +_.size('curly'); +// => 5 +``` + +* * * + + + + + + +### `_.some(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2413 "View in source") [Ⓣ][1] + +Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. + +#### Aliases +*any* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function)*: The function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Boolean)*: Returns `true` if any element passes the callback check, else `false`. + +#### Example +```js +_.some([null, 0, 'yes', false]); +// => true +``` + +* * * + + + + + + +### `_.sortBy(collection, callback|property [, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2459 "View in source") [Ⓣ][1] + +Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `callback|property` *(Function|String)*: The function called per iteration or property name to sort by. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Array)*: Returns a new array of sorted elements. + +#### Example +```js +_.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); +// => [3, 1, 2] + +_.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); +// => [3, 1, 2] + +_.sortBy(['larry', 'brendan', 'moe'], 'length'); +// => ['moe', 'larry', 'brendan'] +``` + +* * * + + + + + + +### `_.toArray(collection)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2491 "View in source") [Ⓣ][1] + +Converts the `collection`, to an array. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to convert. + +#### Returns +*(Array)*: Returns the new converted array. + +#### Example +```js +(function() { return _.toArray(arguments).slice(1); })(1, 2, 3, 4); +// => [2, 3, 4] +``` + +* * * + + + + + + +### `_.where(collection, properties)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2521 "View in source") [Ⓣ][1] + +Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `properties` *(Object)*: The object of property values to filter by. + +#### Returns +*(Array)*: Returns a new array of elements that contain the given `properties`. + +#### Example +```js +var stooges = [ + { 'name': 'moe', 'age': 40 }, + { 'name': 'larry', 'age': 50 }, + { 'name': 'curly', 'age': 60 } +]; + +_.where(stooges, { 'age': 40 }); +// => [{ 'name': 'moe', 'age': 40 }] +``` + +* * * + + + + + + + + + +## `“Functions†Methods` + + + +### `_.after(n, func)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3153 "View in source") [Ⓣ][1] + +Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. + +#### Arguments +1. `n` *(Number)*: The number of times the function must be called before it is executed. +2. `func` *(Function)*: The function to restrict. + +#### Returns +*(Function)*: Returns the new restricted function. + +#### Example +```js +var renderNotes = _.after(notes.length, render); +_.forEach(notes, function(note) { + note.asyncSave({ 'success': renderNotes }); +}); +// `renderNotes` is run once, after all notes have saved +``` + +* * * + + + + + + +### `_.bind(func [, thisArg, arg1, arg2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3186 "View in source") [Ⓣ][1] + +Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. + +#### Arguments +1. `func` *(Function)*: The function to bind. +2. `[thisArg]` *(Mixed)*: The `this` binding of `func`. +3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to be partially applied. + +#### Returns +*(Function)*: Returns the new bound function. + +#### Example +```js +var func = function(greeting) { + return greeting + ' ' + this.name; +}; + +func = _.bind(func, { 'name': 'moe' }, 'hi'); +func(); +// => 'hi moe' +``` + +* * * + + + + + + +### `_.bindAll(object [, methodName1, methodName2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3216 "View in source") [Ⓣ][1] + +Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. + +#### Arguments +1. `object` *(Object)*: The object to bind and assign the bound methods to. +2. `[methodName1, methodName2, ...]` *(String)*: Method names on the object to bind. + +#### Returns +*(Object)*: Returns `object`. + +#### Example +```js +var buttonView = { + 'label': 'lodash', + 'onClick': function() { alert('clicked: ' + this.label); } +}; + +_.bindAll(buttonView); +jQuery('#lodash_button').on('click', buttonView.onClick); +// => When the button is clicked, `this.label` will have the correct value +``` + +* * * + + + + + + +### `_.compose([func1, func2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3247 "View in source") [Ⓣ][1] + +Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. + +#### Arguments +1. `[func1, func2, ...]` *(Function)*: Functions to compose. + +#### Returns +*(Function)*: Returns the new composed function. + +#### Example +```js +var greet = function(name) { return 'hi: ' + name; }; +var exclaim = function(statement) { return statement + '!'; }; +var welcome = _.compose(exclaim, greet); +welcome('moe'); +// => 'hi: moe!' +``` + +* * * + + + + + + +### `_.debounce(func, wait, immediate)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3280 "View in source") [Ⓣ][1] + +Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. + +#### Arguments +1. `func` *(Function)*: The function to debounce. +2. `wait` *(Number)*: The number of milliseconds to delay. +3. `immediate` *(Boolean)*: A flag to indicate execution is on the leading edge of the timeout. + +#### Returns +*(Function)*: Returns the new debounced function. + +#### Example +```js +var lazyLayout = _.debounce(calculateLayout, 300); +jQuery(window).on('resize', lazyLayout); +``` + +* * * + + + + + + +### `_.defer(func [, arg1, arg2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3344 "View in source") [Ⓣ][1] + +Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. + +#### Arguments +1. `func` *(Function)*: The function to defer. +2. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the function with. + +#### Returns +*(Number)*: Returns the `setTimeout` timeout id. + +#### Example +```js +_.defer(function() { alert('deferred'); }); +// returns from the function before `alert` is called +``` + +* * * + + + + + + +### `_.delay(func, wait [, arg1, arg2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3324 "View in source") [Ⓣ][1] + +Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. + +#### Arguments +1. `func` *(Function)*: The function to delay. +2. `wait` *(Number)*: The number of milliseconds to delay execution. +3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the function with. + +#### Returns +*(Number)*: Returns the `setTimeout` timeout id. + +#### Example +```js +var log = _.bind(console.log, console); +_.delay(log, 1000, 'logged later'); +// => 'logged later' (Appears after one second.) +``` + +* * * + + + + + + +### `_.lateBind(object, methodName [, arg1, arg2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3382 "View in source") [Ⓣ][1] + +Creates a function that, when called, invokes `object[methodName]` and prepends any additional `lateBind` arguments to those passed to the bound function. This method differs from `_.bind` by allowing bound functions to reference methods that will be redefined or don't yet exist. + +#### Arguments +1. `object` *(Object)*: The object the method belongs to. +2. `methodName` *(String)*: The method name. +3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to be partially applied. + +#### Returns +*(Function)*: Returns the new bound function. + +#### Example +```js +var object = { + 'name': 'moe', + 'greet': function(greeting) { + return greeting + ' ' + this.name; + } +}; + +var func = _.lateBind(object, 'greet', 'hi'); +func(); +// => 'hi moe' + +object.greet = function(greeting) { + return greeting + ', ' + this.name + '!'; +}; + +func(); +// => 'hi, moe!' +``` + +* * * + + + + + + +### `_.memoize(func [, resolver])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3405 "View in source") [Ⓣ][1] + +Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. + +#### Arguments +1. `func` *(Function)*: The function to have its output memoized. +2. `[resolver]` *(Function)*: A function used to resolve the cache key. + +#### Returns +*(Function)*: Returns the new memoizing function. + +#### Example +```js +var fibonacci = _.memoize(function(n) { + return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); +}); +``` + +* * * + + + + + + +### `_.once(func)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3432 "View in source") [Ⓣ][1] + +Creates a function that is restricted to execute `func` once. Repeat calls to the function will return the value of the first call. The `func` is executed with the `this` binding of the created function. + +#### Arguments +1. `func` *(Function)*: The function to restrict. + +#### Returns +*(Function)*: Returns the new restricted function. + +#### Example +```js +var initialize = _.once(createApplication); +initialize(); +initialize(); +// Application is only created once. +``` + +* * * + + + + + + +### `_.partial(func [, arg1, arg2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3467 "View in source") [Ⓣ][1] + +Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. + +#### Arguments +1. `func` *(Function)*: The function to partially apply arguments to. +2. `[arg1, arg2, ...]` *(Mixed)*: Arguments to be partially applied. + +#### Returns +*(Function)*: Returns the new partially applied function. + +#### Example +```js +var greet = function(greeting, name) { return greeting + ': ' + name; }; +var hi = _.partial(greet, 'hi'); +hi('moe'); +// => 'hi: moe' +``` + +* * * + + + + + + +### `_.throttle(func, wait)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3489 "View in source") [Ⓣ][1] + +Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. + +#### Arguments +1. `func` *(Function)*: The function to throttle. +2. `wait` *(Number)*: The number of milliseconds to throttle executions to. + +#### Returns +*(Function)*: Returns the new throttled function. + +#### Example +```js +var throttled = _.throttle(updatePosition, 100); +jQuery(window).on('scroll', throttled); +``` + +* * * + + + + + + +### `_.wrap(value, wrapper)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3541 "View in source") [Ⓣ][1] + +Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. + +#### Arguments +1. `value` *(Mixed)*: The value to wrap. +2. `wrapper` *(Function)*: The wrapper function. + +#### Returns +*(Function)*: Returns the new function. + +#### Example +```js +var hello = function(name) { return 'hello ' + name; }; +hello = _.wrap(hello, function(func) { + return 'before, ' + func('moe') + ', after'; +}); +hello(); +// => 'before, hello moe, after' +``` + +* * * + + + + + + + + + +## `“Objects†Methods` + + + +### `_.clone(value, deep)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L896 "View in source") [Ⓣ][1] + +Creates a clone of `value`. If `deep` is `true`, all nested objects will also be cloned otherwise they will be assigned by reference. Functions, DOM nodes, `arguments` objects, and objects created by constructors other than `Object` are **not** cloned. + +#### Arguments +1. `value` *(Mixed)*: The value to clone. +2. `deep` *(Boolean)*: A flag to indicate a deep clone. + +#### Returns +*(Mixed)*: Returns the cloned `value`. + +#### Example +```js +var stooges = [ + { 'name': 'moe', 'age': 40 }, + { 'name': 'larry', 'age': 50 }, + { 'name': 'curly', 'age': 60 } +]; + +_.clone({ 'name': 'moe' }); +// => { 'name': 'moe' } + +var shallow = _.clone(stooges); +shallow[0] === stooges[0]; +// => true + +var deep = _.clone(stooges, true); +shallow[0] === stooges[0]; +// => false +``` + +* * * + + + + + + +### `_.defaults(object [, default1, default2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L979 "View in source") [Ⓣ][1] + +Assigns enumerable properties of the default object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. + +#### Arguments +1. `object` *(Object)*: The destination object. +2. `[default1, default2, ...]` *(Object)*: The default objects. + +#### Returns +*(Object)*: Returns the destination object. + +#### Example +```js +var iceCream = { 'flavor': 'chocolate' }; +_.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); +// => { 'flavor': 'chocolate', 'sprinkles': 'rainbow' } +``` + +* * * + + + + + + +### `_.extend(object [, source1, source2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L999 "View in source") [Ⓣ][1] + +Assigns enumerable properties of the source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. + +#### Arguments +1. `object` *(Object)*: The destination object. +2. `[source1, source2, ...]` *(Object)*: The source objects. + +#### Returns +*(Object)*: Returns the destination object. + +#### Example +```js +_.extend({ 'name': 'moe' }, { 'age': 40 }); +// => { 'name': 'moe', 'age': 40 } +``` + +* * * + + + + + + +### `_.forIn(object, callback [, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L754 "View in source") [Ⓣ][1] + +Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. + +#### Arguments +1. `object` *(Object)*: The object to iterate over. +2. `callback` *(Function)*: The function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Object)*: Returns `object`. + +#### Example +```js +function Dog(name) { + this.name = name; +} + +Dog.prototype.bark = function() { + alert('Woof, woof!'); +}; + +_.forIn(new Dog('Dagny'), function(value, key) { + alert(key); +}); +// => alerts 'name' and 'bark' (order is not guaranteed) +``` + +* * * + + + + + + +### `_.forOwn(object, callback [, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L778 "View in source") [Ⓣ][1] + +Iterates over `object`'s own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. + +#### Arguments +1. `object` *(Object)*: The object to iterate over. +2. `callback` *(Function)*: The function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Object)*: Returns `object`. + +#### Example +```js +_.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { + alert(key); +}); +// => alerts '0', '1', and 'length' (order is not guaranteed) +``` + +* * * + + + + + + +### `_.functions(object)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1016 "View in source") [Ⓣ][1] + +Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. + +#### Aliases +*methods* + +#### Arguments +1. `object` *(Object)*: The object to inspect. + +#### Returns +*(Array)*: Returns a new array of property names that have function values. + +#### Example +```js +_.functions(_); +// => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...] +``` + +* * * + + + + + + +### `_.has(object, property)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1041 "View in source") [Ⓣ][1] + +Checks if the specified object `property` exists and is a direct property, instead of an inherited property. + +#### Arguments +1. `object` *(Object)*: The object to check. +2. `property` *(String)*: The property to check for. + +#### Returns +*(Boolean)*: Returns `true` if key is a direct property, else `false`. + +#### Example +```js +_.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); +// => true +``` + +* * * + + + + + + +### `_.invert(object)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1058 "View in source") [Ⓣ][1] + +Creates an object composed of the inverted keys and values of the given `object`. + +#### Arguments +1. `object` *(Object)*: The object to invert. + +#### Returns +*(Object)*: Returns the created inverted object. + +#### Example +```js +_.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' }); +// => { 'Moe': 'first', 'Larry': 'second', 'Curly': 'third' } (order is not guaranteed) +``` + +* * * + + + + + + +### `_.isArguments(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L716 "View in source") [Ⓣ][1] + +Checks if `value` is an `arguments` object. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true` if the `value` is an `arguments` object, else `false`. + +#### Example +```js +(function() { return _.isArguments(arguments); })(1, 2, 3); +// => true + +_.isArguments([1, 2, 3]); +// => false +``` + +* * * + + + + + + +### `_.isArray(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1082 "View in source") [Ⓣ][1] + +Checks if `value` is an array. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true` if the `value` is an array, else `false`. + +#### Example +```js +(function() { return _.isArray(arguments); })(); +// => false + +_.isArray([1, 2, 3]); +// => true +``` + +* * * + + + + + + +### `_.isBoolean(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1099 "View in source") [Ⓣ][1] + +Checks if `value` is a boolean *(`true` or `false`)* value. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true` if the `value` is a boolean value, else `false`. + +#### Example +```js +_.isBoolean(null); +// => false +``` + +* * * + + + + + + +### `_.isDate(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1116 "View in source") [Ⓣ][1] + +Checks if `value` is a date. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true` if the `value` is a date, else `false`. + +#### Example +```js +_.isDate(new Date); +// => true +``` + +* * * + + + + + + +### `_.isElement(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1133 "View in source") [Ⓣ][1] + +Checks if `value` is a DOM element. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true` if the `value` is a DOM element, else `false`. + +#### Example +```js +_.isElement(document.body); +// => true +``` + +* * * + + + + + + +### `_.isEmpty(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1158 "View in source") [Ⓣ][1] + +Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". + +#### Arguments +1. `value` *(Array|Object|String)*: The value to inspect. + +#### Returns +*(Boolean)*: Returns `true` if the `value` is empty, else `false`. + +#### Example +```js +_.isEmpty([1, 2, 3]); +// => false + +_.isEmpty({}); +// => true + +_.isEmpty(''); +// => true +``` + +* * * + + + + + + +### `_.isEqual(a, b)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1200 "View in source") [Ⓣ][1] + +Performs a deep comparison between two values to determine if they are equivalent to each other. + +#### Arguments +1. `a` *(Mixed)*: The value to compare. +2. `b` *(Mixed)*: The other value to compare. + +#### Returns +*(Boolean)*: Returns `true` if the values are equvalent, else `false`. + +#### Example +```js +var moe = { 'name': 'moe', 'luckyNumbers': [13, 27, 34] }; +var clone = { 'name': 'moe', 'luckyNumbers': [13, 27, 34] }; + +moe == clone; +// => false + +_.isEqual(moe, clone); +// => true +``` + +* * * + + + + + + +### `_.isFinite(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1362 "View in source") [Ⓣ][1] + +Checks if `value` is, or can be coerced to, a finite number. Note: This is not the same as native `isFinite`, which will return true for booleans and empty strings. See http://es5.github.com/#x15.1.2.5. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true` if the `value` is a finite number, else `false`. + +#### Example +```js +_.isFinite(-101); +// => true + +_.isFinite('10'); +// => true + +_.isFinite(true); +// => false + +_.isFinite(''); +// => false + +_.isFinite(Infinity); +// => false +``` + +* * * + + + + + + +### `_.isFunction(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1379 "View in source") [Ⓣ][1] + +Checks if `value` is a function. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true` if the `value` is a function, else `false`. + +#### Example +```js +_.isFunction(_); +// => true +``` + +* * * + + + + + + +### `_.isNaN(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1443 "View in source") [Ⓣ][1] + +Checks if `value` is `NaN`. Note: This is not the same as native `isNaN`, which will return true for `undefined` and other values. See http://es5.github.com/#x15.1.2.4. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true` if the `value` is `NaN`, else `false`. + +#### Example +```js +_.isNaN(NaN); +// => true + +_.isNaN(new Number(NaN)); +// => true + +isNaN(undefined); +// => true + +_.isNaN(undefined); +// => false +``` + +* * * + + + + + + +### `_.isNull(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1466 "View in source") [Ⓣ][1] + +Checks if `value` is `null`. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true` if the `value` is `null`, else `false`. + +#### Example +```js +_.isNull(null); +// => true + +_.isNull(undefined); +// => false +``` + +* * * + + + + + + +### `_.isNumber(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1483 "View in source") [Ⓣ][1] + +Checks if `value` is a number. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true` if the `value` is a number, else `false`. + +#### Example +```js +_.isNumber(8.4 * 5); +// => true +``` + +* * * + + + + + + +### `_.isObject(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1409 "View in source") [Ⓣ][1] + +Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true` if the `value` is an object, else `false`. + +#### Example +```js +_.isObject({}); +// => true + +_.isObject([1, 2, 3]); +// => true + +_.isObject(1); +// => false +``` + +* * * + + + + + + +### `_.isPlainObject(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1511 "View in source") [Ⓣ][1] + +Checks if a given `value` is an object created by the `Object` constructor. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true` if `value` is a plain object, else `false`. + +#### Example +```js +function Stooge(name, age) { + this.name = name; + this.age = age; +} + +_.isPlainObject(new Stooge('moe', 40)); +// => false + +_.isPlainObject([1, 2, 3]); +// => false + +_.isPlainObject({ 'name': 'moe', 'age': 40 }); +// => true +``` + +* * * + + + + + + +### `_.isRegExp(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1536 "View in source") [Ⓣ][1] + +Checks if `value` is a regular expression. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true` if the `value` is a regular expression, else `false`. + +#### Example +```js +_.isRegExp(/moe/); +// => true +``` + +* * * + + + + + + +### `_.isString(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1553 "View in source") [Ⓣ][1] + +Checks if `value` is a string. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true` if the `value` is a string, else `false`. + +#### Example +```js +_.isString('moe'); +// => true +``` + +* * * + + + + + + +### `_.isUndefined(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1571 "View in source") [Ⓣ][1] + +Checks if `value` is `undefined`. + +#### Arguments +1. `value` *(Mixed)*: The value to check. + +#### Returns +*(Boolean)*: Returns `true` if the `value` is `undefined`, else `false`. + +#### Example +```js +_.isUndefined(void 0); +// => true +``` + +* * * + + + + + + +### `_.keys(object)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1588 "View in source") [Ⓣ][1] + +Creates an array composed of the own enumerable property names of `object`. + +#### Arguments +1. `object` *(Object)*: The object to inspect. + +#### Returns +*(Array)*: Returns a new array of property names. + +#### Example +```js +_.keys({ 'one': 1, 'two': 2, 'three': 3 }); +// => ['one', 'two', 'three'] (order is not guaranteed) +``` + +* * * + + + + + + +### `_.merge(object [, source1, source2, ...])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1626 "View in source") [Ⓣ][1] + +Merges enumerable properties of the source object(s) into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. + +#### Arguments +1. `object` *(Object)*: The destination object. +2. `[source1, source2, ...]` *(Object)*: The source objects. + +#### Returns +*(Object)*: Returns the destination object. + +#### Example +```js +var stooges = [ + { 'name': 'moe' }, + { 'name': 'larry' } +]; + +var ages = [ + { 'age': 40 }, + { 'age': 50 } +]; + +_.merge(stooges, ages); +// => [{ 'name': 'moe', 'age': 40 }, { 'name': 'larry', 'age': 50 }] +``` + +* * * + + + + + + +### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1696 "View in source") [Ⓣ][1] + +Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. If `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. + +#### Arguments +1. `object` *(Object)*: The source object. +2. `callback|[prop1, prop2, ...]` *(Function|String)*: The properties to omit or the function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Object)*: Returns an object without the omitted properties. + +#### Example +```js +_.omit({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'userid'); +// => { 'name': 'moe', 'age': 40 } + +_.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(value, key) { + return key.charAt(0) == '_'; +}); +// => { 'name': 'moe' } +``` + +* * * + + + + + + +### `_.pairs(object)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1730 "View in source") [Ⓣ][1] + +Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. + +#### Arguments +1. `object` *(Object)*: The object to inspect. + +#### Returns +*(Array)*: Returns new array of key-value pairs. + +#### Example +```js +_.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); +// => [['moe', 30], ['larry', 40], ['curly', 50]] (order is not guaranteed) +``` + +* * * + + + + + + +### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1763 "View in source") [Ⓣ][1] + +Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. If `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. + +#### Arguments +1. `object` *(Object)*: The source object. +2. `callback|[prop1, prop2, ...]` *(Function|String)*: The properties to pick or the function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Object)*: Returns an object composed of the picked properties. + +#### Example +```js +_.pick({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'name', 'age'); +// => { 'name': 'moe', 'age': 40 } + +_.pick({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(value, key) { + return key.charAt(0) != '_'; +}); +// => { 'name': 'moe' } +``` + +* * * + + + + + + +### `_.values(object)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1800 "View in source") [Ⓣ][1] + +Creates an array composed of the own enumerable property values of `object`. + +#### Arguments +1. `object` *(Object)*: The object to inspect. + +#### Returns +*(Array)*: Returns a new array of property values. + +#### Example +```js +_.values({ 'one': 1, 'two': 2, 'three': 3 }); +// => [1, 2, 3] +``` + +* * * + + + + + + + + + +## `“Utilities†Methods` + + + +### `_.escape(string)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3565 "View in source") [Ⓣ][1] + +Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. + +#### Arguments +1. `string` *(String)*: The string to escape. + +#### Returns +*(String)*: Returns the escaped string. + +#### Example +```js +_.escape('Moe, Larry & Curly'); +// => "Moe, Larry & Curly" +``` + +* * * + + + + + + +### `_.identity(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3585 "View in source") [Ⓣ][1] + +This function returns the first argument passed to it. Note: It is used throughout Lo-Dash as a default callback. + +#### Arguments +1. `value` *(Mixed)*: Any value. + +#### Returns +*(Mixed)*: Returns `value`. + +#### Example +```js +var moe = { 'name': 'moe' }; +moe === _.identity(moe); +// => true +``` + +* * * + + + + + + +### `_.mixin(object)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3611 "View in source") [Ⓣ][1] + +Adds functions properties of `object` to the `lodash` function and chainable wrapper. + +#### Arguments +1. `object` *(Object)*: The object of function properties to add to `lodash`. + +#### Example +```js +_.mixin({ + 'capitalize': function(string) { + return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); + } +}); + +_.capitalize('larry'); +// => 'Larry' + +_('curly').capitalize(); +// => 'Curly' +``` + +* * * + + + + + + +### `_.noConflict()` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3641 "View in source") [Ⓣ][1] + +Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. + +#### Returns +*(Function)*: Returns the `lodash` function. + +#### Example +```js +var lodash = _.noConflict(); +``` + +* * * + + + + + + +### `_.random([min=0, max=1])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3664 "View in source") [Ⓣ][1] + +Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. + +#### Arguments +1. `[min=0]` *(Number)*: The minimum possible value. +2. `[max=1]` *(Number)*: The maximum possible value. + +#### Returns +*(Number)*: Returns a random number. + +#### Example +```js +_.random(0, 5); +// => a number between 1 and 5 + +_.random(5); +// => also a number between 1 and 5 +``` + +* * * + + + + + + +### `_.result(object, property)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3703 "View in source") [Ⓣ][1] + +Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. + +#### Arguments +1. `object` *(Object)*: The object to inspect. +2. `property` *(String)*: The property to get the value of. + +#### Returns +*(Mixed)*: Returns the resolved value. + +#### Example +```js +var object = { + 'cheese': 'crumpets', + 'stuff': function() { + return 'nonsense'; + } +}; + +_.result(object, 'cheese'); +// => 'crumpets' + +_.result(object, 'stuff'); +// => 'nonsense' +``` + +* * * + + + + + + +### `_.template(text, data, options)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3788 "View in source") [Ⓣ][1] + +A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. Note: In the development build `_.template` utilizes sourceURLs for easier debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp` build and avoiding `_.template` use, or loading Lo-Dash in a sandboxed page. See http://developer.chrome.com/trunk/extensions/sandboxingEval.html + +#### Arguments +1. `text` *(String)*: The template text. +2. `data` *(Obect)*: The data object used to populate the text. +3. `options` *(Object)*: The options object. escape - The "escape" delimiter regexp. evaluate - The "evaluate" delimiter regexp. interpolate - The "interpolate" delimiter regexp. sourceURL - The sourceURL of the template's compiled source. variable - The data object variable name. + +#### Returns +*(Function, String)*: Returns a compiled function when no `data` object is given, else it returns the interpolated text. + +#### Example +```js +// using a compiled template +var compiled = _.template('hello <%= name %>'); +compiled({ 'name': 'moe' }); +// => 'hello moe' + +var list = '<% _.forEach(people, function(name) { %>
      1. <%= name %>
      2. <% }); %>'; +_.template(list, { 'people': ['moe', 'larry', 'curly'] }); +// => '
      3. moe
      4. larry
      5. curly
      6. ' + +// using the "escape" delimiter to escape HTML in data property values +_.template('<%- value %>', { 'value': '\n```\n\nUsing [npm](http://npmjs.org/):\n\n```bash\nnpm install lodash\n\nnpm install -g lodash\nnpm link lodash\n```\n\nIn [Node.js](http://nodejs.org/) and [RingoJS v0.8.0+](http://ringojs.org/):\n\n```js\nvar _ = require('lodash');\n```\n\n**Note:** If Lo-Dash is installed globally, [run `npm link lodash`](http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/) in your project’s root directory before requiring it.\n\nIn [RingoJS v0.7.0-](http://ringojs.org/):\n\n```js\nvar _ = require('lodash')._;\n```\n\nIn [Rhino](http://www.mozilla.org/rhino/):\n\n```js\nload('lodash.js');\n```\n\nIn an AMD loader like [RequireJS](http://requirejs.org/):\n\n```js\nrequire({\n 'paths': {\n 'underscore': 'path/to/lodash'\n }\n},\n['underscore'], function(_) {\n console.log(_.VERSION);\n});\n```\n\n## Resolved Underscore.js issues\n\n * Allow iteration of objects with a `length` property [[#799](https://github.com/documentcloud/underscore/pull/799), [test](https://github.com/bestiejs/lodash/blob/v0.9.2/test/test.js#L545-551)]\n * Fix cross-browser object iteration bugs [[#60](https://github.com/documentcloud/underscore/issues/60), [#376](https://github.com/documentcloud/underscore/issues/376), [test](https://github.com/bestiejs/lodash/blob/v0.9.2/test/test.js#L558-582)]\n * Methods should work on pages with incorrectly shimmed native methods [[#7](https://github.com/documentcloud/underscore/issues/7), [#742](https://github.com/documentcloud/underscore/issues/742), [test](https://github.com/bestiejs/lodash/blob/v0.9.2/test/test.js#L140-146)]\n * `_.isEmpty` should support jQuery/MooTools DOM query collections [[#690](https://github.com/documentcloud/underscore/pull/690), [test](https://github.com/bestiejs/lodash/blob/v0.9.2/test/test.js#L747-752)]\n * `_.isObject` should avoid V8 bug [#2291](http://code.google.com/p/v8/issues/detail?id=2291) [[#605](https://github.com/documentcloud/underscore/issues/605), [test](https://github.com/bestiejs/lodash/blob/v0.9.2/test/test.js#L828-840)]\n * `_.keys` should work with `arguments` objects cross-browser [[#396](https://github.com/documentcloud/underscore/issues/396), [test](https://github.com/bestiejs/lodash/blob/v0.9.2/test/test.js#L921-923)]\n * `_.range` should coerce arguments to numbers [[#634](https://github.com/documentcloud/underscore/issues/634), [#683](https://github.com/documentcloud/underscore/issues/683), [test](https://github.com/bestiejs/lodash/blob/v0.9.2/test/test.js#L1337-1340)]\n\n## Release Notes\n\n### v0.9.2\n\n * Added `fromIndex` argument to `_.contains`\n * Added `moduleId` build option\n * Added Closure Compiler *“simpleâ€* optimizations to the build process\n * Added support for strings in `_.max` and `_.min`\n * Added support for ES6 template delimiters to `_.template`\n * Ensured re-minification of Lo-Dash by third parties avoids Closure Compiler bugs\n * Optimized `_.every`, `_.find`, `_.some`, and `_.uniq`\n\nThe full changelog is available [here](https://github.com/bestiejs/lodash/wiki/Changelog).\n\n## BestieJS\n\nLo-Dash is part of the BestieJS *“Best in Classâ€* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation.\n\n## Author\n\n* [John-David Dalton](http://allyoucanleet.com/)\n [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton \"Follow @jdalton on Twitter\")\n\n## Contributors\n\n* [Kit Cambridge](http://kitcambridge.github.com/)\n [![twitter/kitcambridge](http://gravatar.com/avatar/6662a1d02f351b5ef2f8b4d815804661?s=70)](https://twitter.com/kitcambridge \"Follow @kitcambridge on Twitter\")\n* [Mathias Bynens](http://mathiasbynens.be/)\n [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias \"Follow @mathias on Twitter\")\n", + "readmeFilename": "README.md", + "_id": "lodash@0.9.2", + "dist": { + "shasum": "06c33f4a57ff688efc7dbf08c42cf01e6bee0880" + }, + "_from": "lodash@~0.9.0", + "_resolved": "https://registry.npmjs.org/lodash/-/lodash-0.9.2.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/lodash/test/template/a.jst b/Phaser/node_modules/grunt/node_modules/lodash/test/template/a.jst new file mode 100644 index 00000000..a2a8b6e0 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/test/template/a.jst @@ -0,0 +1,3 @@ +
          +<% _.forEach(people, function(name) { %>
        • <%= name %>
        • <% }); %> +
        \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/lodash/test/template/b.jst b/Phaser/node_modules/grunt/node_modules/lodash/test/template/b.jst new file mode 100644 index 00000000..cad081d1 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/test/template/b.jst @@ -0,0 +1 @@ +<% print("Hello " + epithet); %>. \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/lodash/test/template/c.tpl b/Phaser/node_modules/grunt/node_modules/lodash/test/template/c.tpl new file mode 100644 index 00000000..c7a43bc1 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/test/template/c.tpl @@ -0,0 +1 @@ +Hello {{ name }}! \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/qunit-clib/LICENSE.txt b/Phaser/node_modules/grunt/node_modules/lodash/vendor/qunit-clib/LICENSE.txt new file mode 100644 index 00000000..dadad22f --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/qunit-clib/LICENSE.txt @@ -0,0 +1,20 @@ +Copyright 2011-2012 John-David Dalton + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/qunit-clib/README.md b/Phaser/node_modules/grunt/node_modules/lodash/vendor/qunit-clib/README.md new file mode 100644 index 00000000..b84a21c9 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/qunit-clib/README.md @@ -0,0 +1,57 @@ +# QUnit CLIB v1.0.0 +## command-line interface boilerplate + +QUnit CLIB helps extend QUnit's CLI support to many common CLI environments. + +## Screenshot + +![QUnit CLIB brings QUnit to your favorite shell.](http://i.imgur.com/jpu9l.png) + +## Support + +QUnit CLIB has been tested in at least Node.js 0.4.8-0.8.6, Narwhal v0.3.2, RingoJS v0.8.0, and Rhino v1.7RC3-RC5. + +## Usage + +```js +(function(window) { + + // use a single load function + var load = typeof require == 'function' ? require : window.load; + + // load QUnit and CLIB if needed + var QUnit = + window.QUnit || ( + window.setTimeout || (window.addEventListener = window.setTimeout = / /), + window.QUnit = load('path/to/qunit.js') || window.QUnit, + load('path/to/qunit-clib.js'), + (window.addEventListener || 0).test && delete window.addEventListener, + window.QUnit + ); + + // explicitly call `QUnit.module()` instead of `module()` + // in case we are in a CLI environment + QUnit.module('A Test Module'); + + test('A Test', function() { + // ... + }); + + // must call `QUnit.start()` if using QUnit < 1.3.0 with Node.js or any + // version of QUnit with Narwhal, Rhino, or RingoJS + if (!window.document) { + QUnit.start(); + } +}(typeof global == 'object' && global || this)); +``` + +## Footnotes + + 1. QUnit v1.3.0 does not work with Narwhal or Ringo < v0.8.0 + + 2. Rhino v1.7RC4 does not support timeout fallbacks `clearTimeout` and `setTimeout` + +## Author + +* [John-David Dalton](http://allyoucanleet.com/) + [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton "Follow @jdalton on Twitter") diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/qunit/README.md b/Phaser/node_modules/grunt/node_modules/lodash/vendor/qunit/README.md new file mode 100644 index 00000000..57ff29e1 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/qunit/README.md @@ -0,0 +1,59 @@ +[QUnit](http://qunitjs.com) - A JavaScript Unit Testing framework. +================================ + +QUnit is a powerful, easy-to-use, JavaScript test suite. It's used by the jQuery +project to test its code and plugins but is capable of testing any generic +JavaScript code (and even capable of testing JavaScript code on the server-side). + +QUnit is especially useful for regression testing: Whenever a bug is reported, +write a test that asserts the existence of that particular bug. Then fix it and +commit both. Every time you work on the code again, run the tests. If the bug +comes up again - a regression - you'll spot it immediately and know how to fix +it, because you know what code you just changed. + +Having good unit test coverage makes safe refactoring easy and cheap. You can +run the tests after each small refactoring step and always know what change +broke something. + +QUnit is similar to other unit testing frameworks like JUnit, but makes use of +the features JavaScript provides and helps with testing code in the browser, e.g. +with its stop/start facilities for testing asynchronous code. + +If you are interested in helping developing QUnit, you are in the right place. +For related discussions, visit the +[QUnit and Testing forum](http://forum.jquery.com/qunit-and-testing). + +Planning for a qunitjs.com site and other testing tools related work now happens +on the [jQuery Testing Team planning wiki](http://jquerytesting.pbworks.com/w/page/41556026/FrontPage). + +Development +----------- + +To submit patches, fork the repository, create a branch for the change. Then implement +the change, run `grunt` to lint and test it, then commit, push and create a pull request. + +Include some background for the change in the commit message and `Fixes #nnn`, referring +to the issue number you're addressing. + +To run `grunt`, you need `node` and `npm`, then `npm install grunt -g`. That gives you a global +grunt binary. For additional grunt tasks, also run `npm install`. + +Releases +-------- + +Install git-extras and run `git changelog` to update History.md. +Update qunit/qunit.js|css and package.json to the release version, commit and +tag, update them again to the next version, commit and push commits and tags +(`git push --tags origin master`). + +Put the 'v' in front of the tag, e.g. `v1.8.0`. Clean up the changelog, removing merge commits +or whitespace cleanups. + +To upload to code.jquery.com (replace $version accordingly): + + scp -q qunit/qunit.js jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/qunit/qunit-$version.js + scp -q qunit/qunit.css jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/qunit/qunit-$version.css + +Then update /var/www/html/code.jquery.com/index.html and purge it with: + + curl -s http://code.origin.jquery.com/?reload \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/LICENCE b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/LICENCE new file mode 100644 index 00000000..74489e2e --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/LICENCE @@ -0,0 +1,25 @@ +Copyright (c) Isaac Z. Schlueter +All rights reserved. + +The BSD License + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/README.md b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/README.md new file mode 100644 index 00000000..7cfe3bbc --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/README.md @@ -0,0 +1,50 @@ +# node-tar + +Tar for Node.js. + +## Goals of this project + +1. Be able to parse and reasonably extract the contents of any tar file + created by any program that creates tar files, period. + + At least, this includes every version of: + + * bsdtar + * gnutar + * solaris posix tar + * Joerg Schilling's star ("Schilly tar") + +2. Create tar files that can be extracted by any of the following tar + programs: + + * bsdtar/libarchive version 2.6.2 + * gnutar 1.15 and above + * SunOS Posix tar + * Joerg Schilling's star ("Schilly tar") + +3. 100% test coverage. Speed is important. Correctness is slightly + more important. + +4. Create the kind of tar interface that Node users would want to use. + +5. Satisfy npm's needs for a portable tar implementation with a + JavaScript interface. + +6. No excuses. No complaining. No tolerance for failure. + +## But isn't there already a tar.js? + +Yes, there are a few. This one is going to be better, and it will be +fanatically maintained, because npm will depend on it. + +That's why I need to write it from scratch. Creating and extracting +tarballs is such a large part of what npm does, I simply can't have it +be a black box any longer. + +## Didn't you have something already? Where'd it go? + +It's in the "old" folder. It's not functional. Don't use it. + +It was a useful exploration to learn the issues involved, but like most +software of any reasonable complexity, node-tar won't be useful until +it's been written at least 3 times. diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/block-stream/LICENCE b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/block-stream/LICENCE new file mode 100644 index 00000000..74489e2e --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/block-stream/LICENCE @@ -0,0 +1,25 @@ +Copyright (c) Isaac Z. Schlueter +All rights reserved. + +The BSD License + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/block-stream/README.md b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/block-stream/README.md new file mode 100644 index 00000000..c16e9c46 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/block-stream/README.md @@ -0,0 +1,14 @@ +# block-stream + +A stream of blocks. + +Write data into it, and it'll output data in buffer blocks the size you +specify, padding with zeroes if necessary. + +```javascript +var block = new BlockStream(512) +fs.createReadStream("some-file").pipe(block) +block.pipe(fs.createWriteStream("block-file")) +``` + +When `.end()` or `.flush()` is called, it'll pad the block with zeroes. diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/fstream/LICENSE b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/fstream/LICENSE new file mode 100644 index 00000000..0c44ae71 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/fstream/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) Isaac Z. Schlueter ("Author") +All rights reserved. + +The BSD License + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/fstream/README.md b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/fstream/README.md new file mode 100644 index 00000000..9d8cb77e --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/fstream/README.md @@ -0,0 +1,76 @@ +Like FS streams, but with stat on them, and supporting directories and +symbolic links, as well as normal files. Also, you can use this to set +the stats on a file, even if you don't change its contents, or to create +a symlink, etc. + +So, for example, you can "write" a directory, and it'll call `mkdir`. You +can specify a uid and gid, and it'll call `chown`. You can specify a +`mtime` and `atime`, and it'll call `utimes`. You can call it a symlink +and provide a `linkpath` and it'll call `symlink`. + +Note that it won't automatically resolve symbolic links. So, if you +call `fstream.Reader('/some/symlink')` then you'll get an object +that stats and then ends immediately (since it has no data). To follow +symbolic links, do this: `fstream.Reader({path:'/some/symlink', follow: +true })`. + +There are various checks to make sure that the bytes emitted are the +same as the intended size, if the size is set. + +## Examples + +```javascript +fstream + .Writer({ path: "path/to/file" + , mode: 0755 + , size: 6 + }) + .write("hello\n") + .end() +``` + +This will create the directories if they're missing, and then write +`hello\n` into the file, chmod it to 0755, and assert that 6 bytes have +been written when it's done. + +```javascript +fstream + .Writer({ path: "path/to/file" + , mode: 0755 + , size: 6 + , flags: "a" + }) + .write("hello\n") + .end() +``` + +You can pass flags in, if you want to append to a file. + +```javascript +fstream + .Writer({ path: "path/to/symlink" + , linkpath: "./file" + , SymbolicLink: true + , mode: "0755" // octal strings supported + }) + .end() +``` + +If isSymbolicLink is a function, it'll be called, and if it returns +true, then it'll treat it as a symlink. If it's not a function, then +any truish value will make a symlink, or you can set `type: +'SymbolicLink'`, which does the same thing. + +Note that the linkpath is relative to the symbolic link location, not +the parent dir or cwd. + +```javascript +fstream + .Reader("path/to/dir") + .pipe(fstream.Writer("path/to/other/dir")) +``` + +This will do like `cp -Rp path/to/dir path/to/other/dir`. If the other +dir exists and isn't a directory, then it'll emit an error. It'll also +set the uid, gid, mode, etc. to be identical. In this way, it's more +like `rsync -a` than simply a copy. diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/graceful-fs/LICENSE b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/graceful-fs/LICENSE new file mode 100644 index 00000000..05a40109 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/graceful-fs/LICENSE @@ -0,0 +1,23 @@ +Copyright 2009, 2010, 2011 Isaac Z. Schlueter. +All rights reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/graceful-fs/README.md b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/graceful-fs/README.md new file mode 100644 index 00000000..7d2e681e --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/graceful-fs/README.md @@ -0,0 +1,5 @@ +Just like node's `fs` module, but it does an incremental back-off when +EMFILE is encountered. + +Useful in asynchronous situations where one needs to try to open lots +and lots of files. diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/inherits/README.md b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/inherits/README.md new file mode 100644 index 00000000..b2beaed9 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/inherits/README.md @@ -0,0 +1,51 @@ +A dead simple way to do inheritance in JS. + + var inherits = require("inherits") + + function Animal () { + this.alive = true + } + Animal.prototype.say = function (what) { + console.log(what) + } + + inherits(Dog, Animal) + function Dog () { + Dog.super.apply(this) + } + Dog.prototype.sniff = function () { + this.say("sniff sniff") + } + Dog.prototype.bark = function () { + this.say("woof woof") + } + + inherits(Chihuahua, Dog) + function Chihuahua () { + Chihuahua.super.apply(this) + } + Chihuahua.prototype.bark = function () { + this.say("yip yip") + } + + // also works + function Cat () { + Cat.super.apply(this) + } + Cat.prototype.hiss = function () { + this.say("CHSKKSS!!") + } + inherits(Cat, Animal, { + meow: function () { this.say("miao miao") } + }) + Cat.prototype.purr = function () { + this.say("purr purr") + } + + + var c = new Chihuahua + assert(c instanceof Chihuahua) + assert(c instanceof Dog) + assert(c instanceof Animal) + +The actual function is laughably small. 10-lines small. diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/mkdirp/LICENSE b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/mkdirp/LICENSE new file mode 100644 index 00000000..432d1aeb --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/mkdirp/LICENSE @@ -0,0 +1,21 @@ +Copyright 2010 James Halliday (mail@substack.net) + +This project is free software released under the MIT/X11 license: + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/mkdirp/readme.markdown b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/mkdirp/readme.markdown new file mode 100644 index 00000000..83b0216a --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/mkdirp/readme.markdown @@ -0,0 +1,63 @@ +# mkdirp + +Like `mkdir -p`, but in node.js! + +[![build status](https://secure.travis-ci.org/substack/node-mkdirp.png)](http://travis-ci.org/substack/node-mkdirp) + +# example + +## pow.js + +```js +var mkdirp = require('mkdirp'); + +mkdirp('/tmp/foo/bar/baz', function (err) { + if (err) console.error(err) + else console.log('pow!') +}); +``` + +Output + +``` +pow! +``` + +And now /tmp/foo/bar/baz exists, huzzah! + +# methods + +```js +var mkdirp = require('mkdirp'); +``` + +## mkdirp(dir, mode, cb) + +Create a new directory and any necessary subdirectories at `dir` with octal +permission string `mode`. + +If `mode` isn't specified, it defaults to `0777 & (~process.umask())`. + +`cb(err, made)` fires with the error or the first directory `made` +that had to be created, if any. + +## mkdirp.sync(dir, mode) + +Synchronously create a new directory and any necessary subdirectories at `dir` +with octal permission string `mode`. + +If `mode` isn't specified, it defaults to `0777 & (~process.umask())`. + +Returns the first directory that had to be created, if any. + +# install + +With [npm](http://npmjs.org) do: + +``` +npm install mkdirp +``` + +# license + +MIT diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/rimraf/AUTHORS b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/rimraf/AUTHORS new file mode 100644 index 00000000..247b7543 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/rimraf/AUTHORS @@ -0,0 +1,6 @@ +# Authors sorted by whether or not they're me. +Isaac Z. Schlueter (http://blog.izs.me) +Wayne Larsen (http://github.com/wvl) +ritch +Marcel Laverdet +Yosef Dinerstein diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/rimraf/LICENSE b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/rimraf/LICENSE new file mode 100644 index 00000000..05a40109 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/rimraf/LICENSE @@ -0,0 +1,23 @@ +Copyright 2009, 2010, 2011 Isaac Z. Schlueter. +All rights reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/rimraf/README.md b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/rimraf/README.md new file mode 100644 index 00000000..96ce9b2a --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/tar/vendor/rimraf/README.md @@ -0,0 +1,21 @@ +A `rm -rf` for node. + +Install with `npm install rimraf`, or just drop rimraf.js somewhere. + +## API + +`rimraf(f, callback)` + +The callback will be called with an error if there is one. Certain +errors are handled for you: + +* `EBUSY` - rimraf will back off a maximum of opts.maxBusyTries times + before giving up. +* `EMFILE` - If too many file descriptors get opened, rimraf will + patiently wait until more become available. + + +## rimraf.sync + +It can remove stuff synchronously, too. But that's not so good. Use +the async API. It's better. diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/underscore/LICENSE b/Phaser/node_modules/grunt/node_modules/lodash/vendor/underscore/LICENSE new file mode 100644 index 00000000..61d28c08 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/underscore/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2009-2012 Jeremy Ashkenas, DocumentCloud + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/lodash/vendor/underscore/README.md b/Phaser/node_modules/grunt/node_modules/lodash/vendor/underscore/README.md new file mode 100644 index 00000000..b1f3e50a --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/lodash/vendor/underscore/README.md @@ -0,0 +1,19 @@ + __ + /\ \ __ + __ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____ + /\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\ + \ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\ + \ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/ + \/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/ + \ \____/ + \/___/ + +Underscore.js is a utility-belt library for JavaScript that provides +support for the usual functional suspects (each, map, reduce, filter...) +without extending any core JavaScript objects. + +For Docs, License, Tests, and pre-packed downloads, see: +http://underscorejs.org + +Many thanks to our contributors: +https://github.com/documentcloud/underscore/contributors diff --git a/Phaser/node_modules/grunt/node_modules/minimatch/LICENSE b/Phaser/node_modules/grunt/node_modules/minimatch/LICENSE new file mode 100644 index 00000000..05a40109 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/minimatch/LICENSE @@ -0,0 +1,23 @@ +Copyright 2009, 2010, 2011 Isaac Z. Schlueter. +All rights reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/minimatch/README.md b/Phaser/node_modules/grunt/node_modules/minimatch/README.md new file mode 100644 index 00000000..6fd07d2e --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/minimatch/README.md @@ -0,0 +1,218 @@ +# minimatch + +A minimal matching utility. + +[![Build Status](https://secure.travis-ci.org/isaacs/minimatch.png)](http://travis-ci.org/isaacs/minimatch) + + +This is the matching library used internally by npm. + +Eventually, it will replace the C binding in node-glob. + +It works by converting glob expressions into JavaScript `RegExp` +objects. + +## Usage + +```javascript +var minimatch = require("minimatch") + +minimatch("bar.foo", "*.foo") // true! +minimatch("bar.foo", "*.bar") // false! +``` + +## Features + +Supports these glob features: + +* Brace Expansion +* Extended glob matching +* "Globstar" `**` matching + +See: + +* `man sh` +* `man bash` +* `man 3 fnmatch` +* `man 5 gitignore` + +### Comparisons to other fnmatch/glob implementations + +While strict compliance with the existing standards is a worthwhile +goal, some discrepancies exist between minimatch and other +implementations, and are intentional. + +If the pattern starts with a `!` character, then it is negated. Set the +`nonegate` flag to suppress this behavior, and treat leading `!` +characters normally. This is perhaps relevant if you wish to start the +pattern with a negative extglob pattern like `!(a|B)`. Multiple `!` +characters at the start of a pattern will negate the pattern multiple +times. + +If a pattern starts with `#`, then it is treated as a comment, and +will not match anything. Use `\#` to match a literal `#` at the +start of a line, or set the `nocomment` flag to suppress this behavior. + +The double-star character `**` is supported by default, unless the +`noglobstar` flag is set. This is supported in the manner of bsdglob +and bash 4.1, where `**` only has special significance if it is the only +thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but +`a/**b` will not. **Note that this is different from the way that `**` is +handled by ruby's `Dir` class.** + +If an escaped pattern has no matches, and the `nonull` flag is set, +then minimatch.match returns the pattern as-provided, rather than +interpreting the character escapes. For example, +`minimatch.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than +`"*a?"`. This is akin to setting the `nullglob` option in bash, except +that it does not resolve escaped pattern characters. + +If brace expansion is not disabled, then it is performed before any +other interpretation of the glob pattern. Thus, a pattern like +`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded +**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are +checked for validity. Since those two are valid, matching proceeds. + + +## Minimatch Class + +Create a minimatch object by instanting the `minimatch.Minimatch` class. + +```javascript +var Minimatch = require("minimatch").Minimatch +var mm = new Minimatch(pattern, options) +``` + +### Properties + +* `pattern` The original pattern the minimatch object represents. +* `options` The options supplied to the constructor. +* `set` A 2-dimensional array of regexp or string expressions. + Each row in the + array corresponds to a brace-expanded pattern. Each item in the row + corresponds to a single path-part. For example, the pattern + `{a,b/c}/d` would expand to a set of patterns like: + + [ [ a, d ] + , [ b, c, d ] ] + + If a portion of the pattern doesn't have any "magic" in it + (that is, it's something like `"foo"` rather than `fo*o?`), then it + will be left as a string rather than converted to a regular + expression. + +* `regexp` Created by the `makeRe` method. A single regular expression + expressing the entire pattern. This is useful in cases where you wish + to use the pattern somewhat like `fnmatch(3)` with `FNM_PATH` enabled. +* `negate` True if the pattern is negated. +* `comment` True if the pattern is a comment. +* `empty` True if the pattern is `""`. + +### Methods + +* `makeRe` Generate the `regexp` member if necessary, and return it. + Will return `false` if the pattern is invalid. +* `match(fname)` Return true if the filename matches the pattern, or + false otherwise. +* `matchOne(fileArray, patternArray, partial)` Take a `/`-split + filename, and match it against a single row in the `regExpSet`. This + method is mainly for internal use, but is exposed so that it can be + used by a glob-walker that needs to avoid excessive filesystem calls. + +All other methods are internal, and will be called as necessary. + +## Functions + +The top-level exported function has a `cache` property, which is an LRU +cache set to store 100 items. So, calling these methods repeatedly +with the same pattern and options will use the same Minimatch object, +saving the cost of parsing it multiple times. + +### minimatch(path, pattern, options) + +Main export. Tests a path against the pattern using the options. + +```javascript +var isJS = minimatch(file, "*.js", { matchBase: true }) +``` + +### minimatch.filter(pattern, options) + +Returns a function that tests its +supplied argument, suitable for use with `Array.filter`. Example: + +```javascript +var javascripts = fileList.filter(minimatch.filter("*.js", {matchBase: true})) +``` + +### minimatch.match(list, pattern, options) + +Match against the list of +files, in the style of fnmatch or glob. If nothing is matched, and +options.nonull is set, then return a list containing the pattern itself. + +```javascript +var javascripts = minimatch.match(fileList, "*.js", {matchBase: true})) +``` + +### minimatch.makeRe(pattern, options) + +Make a regular expression object from the pattern. + +## Options + +All options are `false` by default. + +### debug + +Dump a ton of stuff to stderr. + +### nobrace + +Do not expand `{a,b}` and `{1..3}` brace sets. + +### noglobstar + +Disable `**` matching against multiple folder names. + +### dot + +Allow patterns to match filenames starting with a period, even if +the pattern does not explicitly have a period in that spot. + +Note that by default, `a/**/b` will **not** match `a/.d/b`, unless `dot` +is set. + +### noext + +Disable "extglob" style patterns like `+(a|b)`. + +### nocase + +Perform a case-insensitive match. + +### nonull + +When a match is not found by `minimatch.match`, return a list containing +the pattern itself. When set, an empty list is returned if there are +no matches. + +### matchBase + +If set, then patterns without slashes will be matched +against the basename of the path if it contains slashes. For example, +`a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`. + +### nocomment + +Suppress the behavior of treating `#` at the start of a pattern as a +comment. + +### nonegate + +Suppress the behavior of treating a leading `!` character as negation. + +### flipNegate + +Returns from negate expressions the same as if they were not negated. +(Ie, true on a hit, false on a miss.) diff --git a/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/.npmignore b/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/.npmignore new file mode 100644 index 00000000..07e6e472 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/.npmignore @@ -0,0 +1 @@ +/node_modules diff --git a/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/AUTHORS b/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/AUTHORS new file mode 100644 index 00000000..016d7fbe --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/AUTHORS @@ -0,0 +1,8 @@ +# Authors, sorted by whether or not they are me +Isaac Z. Schlueter +Carlos Brito Lage +Marko Mikulicic +Trent Mick +Kevin O'Hara +Marco Rogers +Jesse Dailey diff --git a/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/LICENSE b/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/LICENSE new file mode 100644 index 00000000..05a40109 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/LICENSE @@ -0,0 +1,23 @@ +Copyright 2009, 2010, 2011 Isaac Z. Schlueter. +All rights reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/README.md b/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/README.md new file mode 100644 index 00000000..03ee0f98 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/README.md @@ -0,0 +1,97 @@ +# lru cache + +A cache object that deletes the least-recently-used items. + +## Usage: + +```javascript +var LRU = require("lru-cache") + , options = { max: 500 + , length: function (n) { return n * 2 } + , dispose: function (key, n) { n.close() } + , maxAge: 1000 * 60 * 60 } + , cache = LRU(options) + , otherCache = LRU(50) // sets just the max size + +cache.set("key", "value") +cache.get("key") // "value" + +cache.reset() // empty the cache +``` + +If you put more stuff in it, then items will fall out. + +If you try to put an oversized thing in it, then it'll fall out right +away. + +## Options + +* `max` The maximum size of the cache, checked by applying the length + function to all values in the cache. Not setting this is kind of + silly, since that's the whole purpose of this lib, but it defaults + to `Infinity`. +* `maxAge` Maximum age in ms. Items are not pro-actively pruned out + as they age, but if you try to get an item that is too old, it'll + drop it and return undefined instead of giving it to you. +* `length` Function that is used to calculate the length of stored + items. If you're storing strings or buffers, then you probably want + to do something like `function(n){return n.length}`. The default is + `function(n){return 1}`, which is fine if you want to store `n` + like-sized things. +* `dispose` Function that is called on items when they are dropped + from the cache. This can be handy if you want to close file + descriptors or do other cleanup tasks when items are no longer + accessible. Called with `key, value`. It's called *before* + actually removing the item from the internal cache, so if you want + to immediately put it back in, you'll have to do that in a + `nextTick` or `setTimeout` callback or it won't do anything. +* `stale` By default, if you set a `maxAge`, it'll only actually pull + stale items out of the cache when you `get(key)`. (That is, it's + not pre-emptively doing a `setTimeout` or anything.) If you set + `stale:true`, it'll return the stale value before deleting it. If + you don't set this, then it'll return `undefined` when you try to + get a stale entry, as if it had already been deleted. + +## API + +* `set(key, value)` +* `get(key) => value` + + Both of these will update the "recently used"-ness of the key. + They do what you think. + +* `peek(key)` + + Returns the key value (or `undefined` if not found) without + updating the "recently used"-ness of the key. + + (If you find yourself using this a lot, you *might* be using the + wrong sort of data structure, but there are some use cases where + it's handy.) + +* `del(key)` + + Deletes a key out of the cache. + +* `reset()` + + Clear the cache entirely, throwing away all values. + +* `has(key)` + + Check if a key is in the cache, without updating the recent-ness + or deleting it for being stale. + +* `forEach(function(value,key,cache), [thisp])` + + Just like `Array.prototype.forEach`. Iterates over all the keys + in the cache, in order of recent-ness. (Ie, more recently used + items are iterated over first.) + +* `keys()` + + Return an array of the keys in the cache. + +* `values()` + + Return an array of the values in the cache. diff --git a/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/package.json b/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/package.json new file mode 100644 index 00000000..81e7c67c --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/lru-cache/package.json @@ -0,0 +1,63 @@ +{ + "name": "lru-cache", + "description": "A cache object that deletes the least-recently-used items.", + "version": "2.3.0", + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me" + }, + "scripts": { + "test": "tap test --gc" + }, + "main": "lib/lru-cache.js", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/node-lru-cache.git" + }, + "devDependencies": { + "tap": "", + "weak": "" + }, + "license": { + "type": "MIT", + "url": "http://github.com/isaacs/node-lru-cache/raw/master/LICENSE" + }, + "contributors": [ + { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me" + }, + { + "name": "Carlos Brito Lage", + "email": "carlos@carloslage.net" + }, + { + "name": "Marko Mikulicic", + "email": "marko.mikulicic@isti.cnr.it" + }, + { + "name": "Trent Mick", + "email": "trentm@gmail.com" + }, + { + "name": "Kevin O'Hara", + "email": "kevinohara80@gmail.com" + }, + { + "name": "Marco Rogers", + "email": "marco.rogers@gmail.com" + }, + { + "name": "Jesse Dailey", + "email": "jesse.dailey@gmail.com" + } + ], + "readme": "# lru cache\n\nA cache object that deletes the least-recently-used items.\n\n## Usage:\n\n```javascript\nvar LRU = require(\"lru-cache\")\n , options = { max: 500\n , length: function (n) { return n * 2 }\n , dispose: function (key, n) { n.close() }\n , maxAge: 1000 * 60 * 60 }\n , cache = LRU(options)\n , otherCache = LRU(50) // sets just the max size\n\ncache.set(\"key\", \"value\")\ncache.get(\"key\") // \"value\"\n\ncache.reset() // empty the cache\n```\n\nIf you put more stuff in it, then items will fall out.\n\nIf you try to put an oversized thing in it, then it'll fall out right\naway.\n\n## Options\n\n* `max` The maximum size of the cache, checked by applying the length\n function to all values in the cache. Not setting this is kind of\n silly, since that's the whole purpose of this lib, but it defaults\n to `Infinity`.\n* `maxAge` Maximum age in ms. Items are not pro-actively pruned out\n as they age, but if you try to get an item that is too old, it'll\n drop it and return undefined instead of giving it to you.\n* `length` Function that is used to calculate the length of stored\n items. If you're storing strings or buffers, then you probably want\n to do something like `function(n){return n.length}`. The default is\n `function(n){return 1}`, which is fine if you want to store `n`\n like-sized things.\n* `dispose` Function that is called on items when they are dropped\n from the cache. This can be handy if you want to close file\n descriptors or do other cleanup tasks when items are no longer\n accessible. Called with `key, value`. It's called *before*\n actually removing the item from the internal cache, so if you want\n to immediately put it back in, you'll have to do that in a\n `nextTick` or `setTimeout` callback or it won't do anything.\n* `stale` By default, if you set a `maxAge`, it'll only actually pull\n stale items out of the cache when you `get(key)`. (That is, it's\n not pre-emptively doing a `setTimeout` or anything.) If you set\n `stale:true`, it'll return the stale value before deleting it. If\n you don't set this, then it'll return `undefined` when you try to\n get a stale entry, as if it had already been deleted.\n\n## API\n\n* `set(key, value)`\n* `get(key) => value`\n\n Both of these will update the \"recently used\"-ness of the key.\n They do what you think.\n\n* `peek(key)`\n\n Returns the key value (or `undefined` if not found) without\n updating the \"recently used\"-ness of the key.\n\n (If you find yourself using this a lot, you *might* be using the\n wrong sort of data structure, but there are some use cases where\n it's handy.)\n\n* `del(key)`\n\n Deletes a key out of the cache.\n\n* `reset()`\n\n Clear the cache entirely, throwing away all values.\n\n* `has(key)`\n\n Check if a key is in the cache, without updating the recent-ness\n or deleting it for being stale.\n\n* `forEach(function(value,key,cache), [thisp])`\n\n Just like `Array.prototype.forEach`. Iterates over all the keys\n in the cache, in order of recent-ness. (Ie, more recently used\n items are iterated over first.)\n\n* `keys()`\n\n Return an array of the keys in the cache.\n\n* `values()`\n\n Return an array of the values in the cache.\n", + "readmeFilename": "README.md", + "_id": "lru-cache@2.3.0", + "dist": { + "shasum": "faa4f57cb4b8920c3505f420bddfdd882a3abaac" + }, + "_from": "lru-cache@2", + "_resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.3.0.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/sigmund/LICENSE b/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/sigmund/LICENSE new file mode 100644 index 00000000..0c44ae71 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/sigmund/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) Isaac Z. Schlueter ("Author") +All rights reserved. + +The BSD License + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/sigmund/README.md b/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/sigmund/README.md new file mode 100644 index 00000000..7e365129 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/sigmund/README.md @@ -0,0 +1,53 @@ +# sigmund + +Quick and dirty signatures for Objects. + +This is like a much faster `deepEquals` comparison, which returns a +string key suitable for caches and the like. + +## Usage + +```javascript +function doSomething (someObj) { + var key = sigmund(someObj, maxDepth) // max depth defaults to 10 + var cached = cache.get(key) + if (cached) return cached) + + var result = expensiveCalculation(someObj) + cache.set(key, result) + return result +} +``` + +The resulting key will be as unique and reproducible as calling +`JSON.stringify` or `util.inspect` on the object, but is much faster. +In order to achieve this speed, some differences are glossed over. +For example, the object `{0:'foo'}` will be treated identically to the +array `['foo']`. + +Also, just as there is no way to summon the soul from the scribblings +of a cocain-addled psychoanalyst, there is no way to revive the object +from the signature string that sigmund gives you. In fact, it's +barely even readable. + +As with `sys.inspect` and `JSON.stringify`, larger objects will +produce larger signature strings. + +Because sigmund is a bit less strict than the more thorough +alternatives, the strings will be shorter, and also there is a +slightly higher chance for collisions. For example, these objects +have the same signature: + + var obj1 = {a:'b',c:/def/,g:['h','i',{j:'',k:'l'}]} + var obj2 = {a:'b',c:'/def/',g:['h','i','{jkl']} + +Like a good Freudian, sigmund is most effective when you already have +some understanding of what you're looking for. It can help you help +yourself, but you must be willing to do some work as well. + +Cycles are handled, and cyclical objects are silently omitted (though +the key is included in the signature output.) + +The second argument is the maximum depth, which defaults to 10, +because that is the maximum object traversal depth covered by most +insurance carriers. diff --git a/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/sigmund/package.json b/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/sigmund/package.json new file mode 100644 index 00000000..fcd0daf1 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/minimatch/node_modules/sigmund/package.json @@ -0,0 +1,42 @@ +{ + "name": "sigmund", + "version": "1.0.0", + "description": "Quick and dirty signatures for Objects.", + "main": "sigmund.js", + "directories": { + "test": "test" + }, + "dependencies": {}, + "devDependencies": { + "tap": "~0.3.0" + }, + "scripts": { + "test": "tap test/*.js", + "bench": "node bench.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/isaacs/sigmund" + }, + "keywords": [ + "object", + "signature", + "key", + "data", + "psychoanalysis" + ], + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "license": "BSD", + "readme": "# sigmund\n\nQuick and dirty signatures for Objects.\n\nThis is like a much faster `deepEquals` comparison, which returns a\nstring key suitable for caches and the like.\n\n## Usage\n\n```javascript\nfunction doSomething (someObj) {\n var key = sigmund(someObj, maxDepth) // max depth defaults to 10\n var cached = cache.get(key)\n if (cached) return cached)\n\n var result = expensiveCalculation(someObj)\n cache.set(key, result)\n return result\n}\n```\n\nThe resulting key will be as unique and reproducible as calling\n`JSON.stringify` or `util.inspect` on the object, but is much faster.\nIn order to achieve this speed, some differences are glossed over.\nFor example, the object `{0:'foo'}` will be treated identically to the\narray `['foo']`.\n\nAlso, just as there is no way to summon the soul from the scribblings\nof a cocain-addled psychoanalyst, there is no way to revive the object\nfrom the signature string that sigmund gives you. In fact, it's\nbarely even readable.\n\nAs with `sys.inspect` and `JSON.stringify`, larger objects will\nproduce larger signature strings.\n\nBecause sigmund is a bit less strict than the more thorough\nalternatives, the strings will be shorter, and also there is a\nslightly higher chance for collisions. For example, these objects\nhave the same signature:\n\n var obj1 = {a:'b',c:/def/,g:['h','i',{j:'',k:'l'}]}\n var obj2 = {a:'b',c:'/def/',g:['h','i','{jkl']}\n\nLike a good Freudian, sigmund is most effective when you already have\nsome understanding of what you're looking for. It can help you help\nyourself, but you must be willing to do some work as well.\n\nCycles are handled, and cyclical objects are silently omitted (though\nthe key is included in the signature output.)\n\nThe second argument is the maximum depth, which defaults to 10,\nbecause that is the maximum object traversal depth covered by most\ninsurance carriers.\n", + "readmeFilename": "README.md", + "_id": "sigmund@1.0.0", + "dist": { + "shasum": "8b342a413c9a7c2c3b82a0f2ea4c56343bc4cb13" + }, + "_from": "sigmund@~1.0.0", + "_resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.0.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/minimatch/package.json b/Phaser/node_modules/grunt/node_modules/minimatch/package.json new file mode 100644 index 00000000..c1fa6237 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/minimatch/package.json @@ -0,0 +1,40 @@ +{ + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me" + }, + "name": "minimatch", + "description": "a glob matcher in javascript", + "version": "0.2.12", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/minimatch.git" + }, + "main": "minimatch.js", + "scripts": { + "test": "tap test" + }, + "engines": { + "node": "*" + }, + "dependencies": { + "lru-cache": "2", + "sigmund": "~1.0.0" + }, + "devDependencies": { + "tap": "" + }, + "license": { + "type": "MIT", + "url": "http://github.com/isaacs/minimatch/raw/master/LICENSE" + }, + "readme": "# minimatch\n\nA minimal matching utility.\n\n[![Build Status](https://secure.travis-ci.org/isaacs/minimatch.png)](http://travis-ci.org/isaacs/minimatch)\n\n\nThis is the matching library used internally by npm.\n\nEventually, it will replace the C binding in node-glob.\n\nIt works by converting glob expressions into JavaScript `RegExp`\nobjects.\n\n## Usage\n\n```javascript\nvar minimatch = require(\"minimatch\")\n\nminimatch(\"bar.foo\", \"*.foo\") // true!\nminimatch(\"bar.foo\", \"*.bar\") // false!\n```\n\n## Features\n\nSupports these glob features:\n\n* Brace Expansion\n* Extended glob matching\n* \"Globstar\" `**` matching\n\nSee:\n\n* `man sh`\n* `man bash`\n* `man 3 fnmatch`\n* `man 5 gitignore`\n\n### Comparisons to other fnmatch/glob implementations\n\nWhile strict compliance with the existing standards is a worthwhile\ngoal, some discrepancies exist between minimatch and other\nimplementations, and are intentional.\n\nIf the pattern starts with a `!` character, then it is negated. Set the\n`nonegate` flag to suppress this behavior, and treat leading `!`\ncharacters normally. This is perhaps relevant if you wish to start the\npattern with a negative extglob pattern like `!(a|B)`. Multiple `!`\ncharacters at the start of a pattern will negate the pattern multiple\ntimes.\n\nIf a pattern starts with `#`, then it is treated as a comment, and\nwill not match anything. Use `\\#` to match a literal `#` at the\nstart of a line, or set the `nocomment` flag to suppress this behavior.\n\nThe double-star character `**` is supported by default, unless the\n`noglobstar` flag is set. This is supported in the manner of bsdglob\nand bash 4.1, where `**` only has special significance if it is the only\nthing in a path part. That is, `a/**/b` will match `a/x/y/b`, but\n`a/**b` will not. **Note that this is different from the way that `**` is\nhandled by ruby's `Dir` class.**\n\nIf an escaped pattern has no matches, and the `nonull` flag is set,\nthen minimatch.match returns the pattern as-provided, rather than\ninterpreting the character escapes. For example,\n`minimatch.match([], \"\\\\*a\\\\?\")` will return `\"\\\\*a\\\\?\"` rather than\n`\"*a?\"`. This is akin to setting the `nullglob` option in bash, except\nthat it does not resolve escaped pattern characters.\n\nIf brace expansion is not disabled, then it is performed before any\nother interpretation of the glob pattern. Thus, a pattern like\n`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded\n**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are\nchecked for validity. Since those two are valid, matching proceeds.\n\n\n## Minimatch Class\n\nCreate a minimatch object by instanting the `minimatch.Minimatch` class.\n\n```javascript\nvar Minimatch = require(\"minimatch\").Minimatch\nvar mm = new Minimatch(pattern, options)\n```\n\n### Properties\n\n* `pattern` The original pattern the minimatch object represents.\n* `options` The options supplied to the constructor.\n* `set` A 2-dimensional array of regexp or string expressions.\n Each row in the\n array corresponds to a brace-expanded pattern. Each item in the row\n corresponds to a single path-part. For example, the pattern\n `{a,b/c}/d` would expand to a set of patterns like:\n\n [ [ a, d ]\n , [ b, c, d ] ]\n\n If a portion of the pattern doesn't have any \"magic\" in it\n (that is, it's something like `\"foo\"` rather than `fo*o?`), then it\n will be left as a string rather than converted to a regular\n expression.\n\n* `regexp` Created by the `makeRe` method. A single regular expression\n expressing the entire pattern. This is useful in cases where you wish\n to use the pattern somewhat like `fnmatch(3)` with `FNM_PATH` enabled.\n* `negate` True if the pattern is negated.\n* `comment` True if the pattern is a comment.\n* `empty` True if the pattern is `\"\"`.\n\n### Methods\n\n* `makeRe` Generate the `regexp` member if necessary, and return it.\n Will return `false` if the pattern is invalid.\n* `match(fname)` Return true if the filename matches the pattern, or\n false otherwise.\n* `matchOne(fileArray, patternArray, partial)` Take a `/`-split\n filename, and match it against a single row in the `regExpSet`. This\n method is mainly for internal use, but is exposed so that it can be\n used by a glob-walker that needs to avoid excessive filesystem calls.\n\nAll other methods are internal, and will be called as necessary.\n\n## Functions\n\nThe top-level exported function has a `cache` property, which is an LRU\ncache set to store 100 items. So, calling these methods repeatedly\nwith the same pattern and options will use the same Minimatch object,\nsaving the cost of parsing it multiple times.\n\n### minimatch(path, pattern, options)\n\nMain export. Tests a path against the pattern using the options.\n\n```javascript\nvar isJS = minimatch(file, \"*.js\", { matchBase: true })\n```\n\n### minimatch.filter(pattern, options)\n\nReturns a function that tests its\nsupplied argument, suitable for use with `Array.filter`. Example:\n\n```javascript\nvar javascripts = fileList.filter(minimatch.filter(\"*.js\", {matchBase: true}))\n```\n\n### minimatch.match(list, pattern, options)\n\nMatch against the list of\nfiles, in the style of fnmatch or glob. If nothing is matched, and\noptions.nonull is set, then return a list containing the pattern itself.\n\n```javascript\nvar javascripts = minimatch.match(fileList, \"*.js\", {matchBase: true}))\n```\n\n### minimatch.makeRe(pattern, options)\n\nMake a regular expression object from the pattern.\n\n## Options\n\nAll options are `false` by default.\n\n### debug\n\nDump a ton of stuff to stderr.\n\n### nobrace\n\nDo not expand `{a,b}` and `{1..3}` brace sets.\n\n### noglobstar\n\nDisable `**` matching against multiple folder names.\n\n### dot\n\nAllow patterns to match filenames starting with a period, even if\nthe pattern does not explicitly have a period in that spot.\n\nNote that by default, `a/**/b` will **not** match `a/.d/b`, unless `dot`\nis set.\n\n### noext\n\nDisable \"extglob\" style patterns like `+(a|b)`.\n\n### nocase\n\nPerform a case-insensitive match.\n\n### nonull\n\nWhen a match is not found by `minimatch.match`, return a list containing\nthe pattern itself. When set, an empty list is returned if there are\nno matches.\n\n### matchBase\n\nIf set, then patterns without slashes will be matched\nagainst the basename of the path if it contains slashes. For example,\n`a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`.\n\n### nocomment\n\nSuppress the behavior of treating `#` at the start of a pattern as a\ncomment.\n\n### nonegate\n\nSuppress the behavior of treating a leading `!` character as negation.\n\n### flipNegate\n\nReturns from negate expressions the same as if they were not negated.\n(Ie, true on a hit, false on a miss.)\n", + "readmeFilename": "README.md", + "_id": "minimatch@0.2.12", + "dist": { + "shasum": "308fb5bc9d1aabe4a0477f812ec820ee5fa8e25d" + }, + "_from": "minimatch@~0.2.6", + "_resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.12.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/nopt/.npmignore b/Phaser/node_modules/grunt/node_modules/nopt/.npmignore new file mode 100644 index 00000000..e69de29b diff --git a/Phaser/node_modules/grunt/node_modules/nopt/LICENSE b/Phaser/node_modules/grunt/node_modules/nopt/LICENSE new file mode 100644 index 00000000..05a40109 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/nopt/LICENSE @@ -0,0 +1,23 @@ +Copyright 2009, 2010, 2011 Isaac Z. Schlueter. +All rights reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/nopt/README.md b/Phaser/node_modules/grunt/node_modules/nopt/README.md new file mode 100644 index 00000000..eeddfd4f --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/nopt/README.md @@ -0,0 +1,208 @@ +If you want to write an option parser, and have it be good, there are +two ways to do it. The Right Way, and the Wrong Way. + +The Wrong Way is to sit down and write an option parser. We've all done +that. + +The Right Way is to write some complex configurable program with so many +options that you go half-insane just trying to manage them all, and put +it off with duct-tape solutions until you see exactly to the core of the +problem, and finally snap and write an awesome option parser. + +If you want to write an option parser, don't write an option parser. +Write a package manager, or a source control system, or a service +restarter, or an operating system. You probably won't end up with a +good one of those, but if you don't give up, and you are relentless and +diligent enough in your procrastination, you may just end up with a very +nice option parser. + +## USAGE + + // my-program.js + var nopt = require("nopt") + , Stream = require("stream").Stream + , path = require("path") + , knownOpts = { "foo" : [String, null] + , "bar" : [Stream, Number] + , "baz" : path + , "bloo" : [ "big", "medium", "small" ] + , "flag" : Boolean + , "pick" : Boolean + , "many" : [String, Array] + } + , shortHands = { "foofoo" : ["--foo", "Mr. Foo"] + , "b7" : ["--bar", "7"] + , "m" : ["--bloo", "medium"] + , "p" : ["--pick"] + , "f" : ["--flag"] + } + // everything is optional. + // knownOpts and shorthands default to {} + // arg list defaults to process.argv + // slice defaults to 2 + , parsed = nopt(knownOpts, shortHands, process.argv, 2) + console.log(parsed) + +This would give you support for any of the following: + +```bash +$ node my-program.js --foo "blerp" --no-flag +{ "foo" : "blerp", "flag" : false } + +$ node my-program.js ---bar 7 --foo "Mr. Hand" --flag +{ bar: 7, foo: "Mr. Hand", flag: true } + +$ node my-program.js --foo "blerp" -f -----p +{ foo: "blerp", flag: true, pick: true } + +$ node my-program.js -fp --foofoo +{ foo: "Mr. Foo", flag: true, pick: true } + +$ node my-program.js --foofoo -- -fp # -- stops the flag parsing. +{ foo: "Mr. Foo", argv: { remain: ["-fp"] } } + +$ node my-program.js --blatzk 1000 -fp # unknown opts are ok. +{ blatzk: 1000, flag: true, pick: true } + +$ node my-program.js --blatzk true -fp # but they need a value +{ blatzk: true, flag: true, pick: true } + +$ node my-program.js --no-blatzk -fp # unless they start with "no-" +{ blatzk: false, flag: true, pick: true } + +$ node my-program.js --baz b/a/z # known paths are resolved. +{ baz: "/Users/isaacs/b/a/z" } + +# if Array is one of the types, then it can take many +# values, and will always be an array. The other types provided +# specify what types are allowed in the list. + +$ node my-program.js --many 1 --many null --many foo +{ many: ["1", "null", "foo"] } + +$ node my-program.js --many foo +{ many: ["foo"] } +``` + +Read the tests at the bottom of `lib/nopt.js` for more examples of +what this puppy can do. + +## Types + +The following types are supported, and defined on `nopt.typeDefs` + +* String: A normal string. No parsing is done. +* path: A file system path. Gets resolved against cwd if not absolute. +* url: A url. If it doesn't parse, it isn't accepted. +* Number: Must be numeric. +* Date: Must parse as a date. If it does, and `Date` is one of the options, + then it will return a Date object, not a string. +* Boolean: Must be either `true` or `false`. If an option is a boolean, + then it does not need a value, and its presence will imply `true` as + the value. To negate boolean flags, do `--no-whatever` or `--whatever + false` +* NaN: Means that the option is strictly not allowed. Any value will + fail. +* Stream: An object matching the "Stream" class in node. Valuable + for use when validating programmatically. (npm uses this to let you + supply any WriteStream on the `outfd` and `logfd` config options.) +* Array: If `Array` is specified as one of the types, then the value + will be parsed as a list of options. This means that multiple values + can be specified, and that the value will always be an array. + +If a type is an array of values not on this list, then those are +considered valid values. For instance, in the example above, the +`--bloo` option can only be one of `"big"`, `"medium"`, or `"small"`, +and any other value will be rejected. + +When parsing unknown fields, `"true"`, `"false"`, and `"null"` will be +interpreted as their JavaScript equivalents, and numeric values will be +interpreted as a number. + +You can also mix types and values, or multiple types, in a list. For +instance `{ blah: [Number, null] }` would allow a value to be set to +either a Number or null. + +To define a new type, add it to `nopt.typeDefs`. Each item in that +hash is an object with a `type` member and a `validate` method. The +`type` member is an object that matches what goes in the type list. The +`validate` method is a function that gets called with `validate(data, +key, val)`. Validate methods should assign `data[key]` to the valid +value of `val` if it can be handled properly, or return boolean +`false` if it cannot. + +You can also call `nopt.clean(data, types, typeDefs)` to clean up a +config object and remove its invalid properties. + +## Error Handling + +By default, nopt outputs a warning to standard error when invalid +options are found. You can change this behavior by assigning a method +to `nopt.invalidHandler`. This method will be called with +the offending `nopt.invalidHandler(key, val, types)`. + +If no `nopt.invalidHandler` is assigned, then it will console.error +its whining. If it is assigned to boolean `false` then the warning is +suppressed. + +## Abbreviations + +Yes, they are supported. If you define options like this: + +```javascript +{ "foolhardyelephants" : Boolean +, "pileofmonkeys" : Boolean } +``` + +Then this will work: + +```bash +node program.js --foolhar --pil +node program.js --no-f --pileofmon +# etc. +``` + +## Shorthands + +Shorthands are a hash of shorter option names to a snippet of args that +they expand to. + +If multiple one-character shorthands are all combined, and the +combination does not unambiguously match any other option or shorthand, +then they will be broken up into their constituent parts. For example: + +```json +{ "s" : ["--loglevel", "silent"] +, "g" : "--global" +, "f" : "--force" +, "p" : "--parseable" +, "l" : "--long" +} +``` + +```bash +npm ls -sgflp +# just like doing this: +npm ls --loglevel silent --global --force --long --parseable +``` + +## The Rest of the args + +The config object returned by nopt is given a special member called +`argv`, which is an object with the following fields: + +* `remain`: The remaining args after all the parsing has occurred. +* `original`: The args as they originally appeared. +* `cooked`: The args after flags and shorthands are expanded. + +## Slicing + +Node programs are called with more or less the exact argv as it appears +in C land, after the v8 and node-specific options have been plucked off. +As such, `argv[0]` is always `node` and `argv[1]` is always the +JavaScript program being run. + +That's usually not very useful to you. So they're sliced off by +default. If you want them, then you can pass in `0` as the last +argument, or any other number that you'd like to slice off the start of +the list. diff --git a/Phaser/node_modules/grunt/node_modules/nopt/node_modules/abbrev/LICENSE b/Phaser/node_modules/grunt/node_modules/nopt/node_modules/abbrev/LICENSE new file mode 100644 index 00000000..05a40109 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/nopt/node_modules/abbrev/LICENSE @@ -0,0 +1,23 @@ +Copyright 2009, 2010, 2011 Isaac Z. Schlueter. +All rights reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/nopt/node_modules/abbrev/README.md b/Phaser/node_modules/grunt/node_modules/nopt/node_modules/abbrev/README.md new file mode 100644 index 00000000..99746fe6 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/nopt/node_modules/abbrev/README.md @@ -0,0 +1,23 @@ +# abbrev-js + +Just like [ruby's Abbrev](http://apidock.com/ruby/Abbrev). + +Usage: + + var abbrev = require("abbrev"); + abbrev("foo", "fool", "folding", "flop"); + + // returns: + { fl: 'flop' + , flo: 'flop' + , flop: 'flop' + , fol: 'folding' + , fold: 'folding' + , foldi: 'folding' + , foldin: 'folding' + , folding: 'folding' + , foo: 'foo' + , fool: 'fool' + } + +This is handy for command-line scripts, or other cases where you want to be able to accept shorthands. diff --git a/Phaser/node_modules/grunt/node_modules/nopt/node_modules/abbrev/package.json b/Phaser/node_modules/grunt/node_modules/nopt/node_modules/abbrev/package.json new file mode 100644 index 00000000..a61f44fb --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/nopt/node_modules/abbrev/package.json @@ -0,0 +1,29 @@ +{ + "name": "abbrev", + "version": "1.0.4", + "description": "Like ruby's abbrev module, but in js", + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me" + }, + "main": "./lib/abbrev.js", + "scripts": { + "test": "node lib/abbrev.js" + }, + "repository": { + "type": "git", + "url": "http://github.com/isaacs/abbrev-js" + }, + "license": { + "type": "MIT", + "url": "https://github.com/isaacs/abbrev-js/raw/master/LICENSE" + }, + "readme": "# abbrev-js\n\nJust like [ruby's Abbrev](http://apidock.com/ruby/Abbrev).\n\nUsage:\n\n var abbrev = require(\"abbrev\");\n abbrev(\"foo\", \"fool\", \"folding\", \"flop\");\n \n // returns:\n { fl: 'flop'\n , flo: 'flop'\n , flop: 'flop'\n , fol: 'folding'\n , fold: 'folding'\n , foldi: 'folding'\n , foldin: 'folding'\n , folding: 'folding'\n , foo: 'foo'\n , fool: 'fool'\n }\n\nThis is handy for command-line scripts, or other cases where you want to be able to accept shorthands.\n", + "readmeFilename": "README.md", + "_id": "abbrev@1.0.4", + "dist": { + "shasum": "6a06399d0bddc97d51996c0a87936b866771ff38" + }, + "_from": "abbrev@1", + "_resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/nopt/package.json b/Phaser/node_modules/grunt/node_modules/nopt/package.json new file mode 100644 index 00000000..747a1f80 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/nopt/package.json @@ -0,0 +1,36 @@ +{ + "name": "nopt", + "version": "1.0.10", + "description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.", + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "main": "lib/nopt.js", + "scripts": { + "test": "node lib/nopt.js" + }, + "repository": { + "type": "git", + "url": "http://github.com/isaacs/nopt" + }, + "bin": { + "nopt": "./bin/nopt.js" + }, + "license": { + "type": "MIT", + "url": "https://github.com/isaacs/nopt/raw/master/LICENSE" + }, + "dependencies": { + "abbrev": "1" + }, + "readme": "If you want to write an option parser, and have it be good, there are\ntwo ways to do it. The Right Way, and the Wrong Way.\n\nThe Wrong Way is to sit down and write an option parser. We've all done\nthat.\n\nThe Right Way is to write some complex configurable program with so many\noptions that you go half-insane just trying to manage them all, and put\nit off with duct-tape solutions until you see exactly to the core of the\nproblem, and finally snap and write an awesome option parser.\n\nIf you want to write an option parser, don't write an option parser.\nWrite a package manager, or a source control system, or a service\nrestarter, or an operating system. You probably won't end up with a\ngood one of those, but if you don't give up, and you are relentless and\ndiligent enough in your procrastination, you may just end up with a very\nnice option parser.\n\n## USAGE\n\n // my-program.js\n var nopt = require(\"nopt\")\n , Stream = require(\"stream\").Stream\n , path = require(\"path\")\n , knownOpts = { \"foo\" : [String, null]\n , \"bar\" : [Stream, Number]\n , \"baz\" : path\n , \"bloo\" : [ \"big\", \"medium\", \"small\" ]\n , \"flag\" : Boolean\n , \"pick\" : Boolean\n , \"many\" : [String, Array]\n }\n , shortHands = { \"foofoo\" : [\"--foo\", \"Mr. Foo\"]\n , \"b7\" : [\"--bar\", \"7\"]\n , \"m\" : [\"--bloo\", \"medium\"]\n , \"p\" : [\"--pick\"]\n , \"f\" : [\"--flag\"]\n }\n // everything is optional.\n // knownOpts and shorthands default to {}\n // arg list defaults to process.argv\n // slice defaults to 2\n , parsed = nopt(knownOpts, shortHands, process.argv, 2)\n console.log(parsed)\n\nThis would give you support for any of the following:\n\n```bash\n$ node my-program.js --foo \"blerp\" --no-flag\n{ \"foo\" : \"blerp\", \"flag\" : false }\n\n$ node my-program.js ---bar 7 --foo \"Mr. Hand\" --flag\n{ bar: 7, foo: \"Mr. Hand\", flag: true }\n\n$ node my-program.js --foo \"blerp\" -f -----p\n{ foo: \"blerp\", flag: true, pick: true }\n\n$ node my-program.js -fp --foofoo\n{ foo: \"Mr. Foo\", flag: true, pick: true }\n\n$ node my-program.js --foofoo -- -fp # -- stops the flag parsing.\n{ foo: \"Mr. Foo\", argv: { remain: [\"-fp\"] } }\n\n$ node my-program.js --blatzk 1000 -fp # unknown opts are ok.\n{ blatzk: 1000, flag: true, pick: true }\n\n$ node my-program.js --blatzk true -fp # but they need a value\n{ blatzk: true, flag: true, pick: true }\n\n$ node my-program.js --no-blatzk -fp # unless they start with \"no-\"\n{ blatzk: false, flag: true, pick: true }\n\n$ node my-program.js --baz b/a/z # known paths are resolved.\n{ baz: \"/Users/isaacs/b/a/z\" }\n\n# if Array is one of the types, then it can take many\n# values, and will always be an array. The other types provided\n# specify what types are allowed in the list.\n\n$ node my-program.js --many 1 --many null --many foo\n{ many: [\"1\", \"null\", \"foo\"] }\n\n$ node my-program.js --many foo\n{ many: [\"foo\"] }\n```\n\nRead the tests at the bottom of `lib/nopt.js` for more examples of\nwhat this puppy can do.\n\n## Types\n\nThe following types are supported, and defined on `nopt.typeDefs`\n\n* String: A normal string. No parsing is done.\n* path: A file system path. Gets resolved against cwd if not absolute.\n* url: A url. If it doesn't parse, it isn't accepted.\n* Number: Must be numeric.\n* Date: Must parse as a date. If it does, and `Date` is one of the options,\n then it will return a Date object, not a string.\n* Boolean: Must be either `true` or `false`. If an option is a boolean,\n then it does not need a value, and its presence will imply `true` as\n the value. To negate boolean flags, do `--no-whatever` or `--whatever\n false`\n* NaN: Means that the option is strictly not allowed. Any value will\n fail.\n* Stream: An object matching the \"Stream\" class in node. Valuable\n for use when validating programmatically. (npm uses this to let you\n supply any WriteStream on the `outfd` and `logfd` config options.)\n* Array: If `Array` is specified as one of the types, then the value\n will be parsed as a list of options. This means that multiple values\n can be specified, and that the value will always be an array.\n\nIf a type is an array of values not on this list, then those are\nconsidered valid values. For instance, in the example above, the\n`--bloo` option can only be one of `\"big\"`, `\"medium\"`, or `\"small\"`,\nand any other value will be rejected.\n\nWhen parsing unknown fields, `\"true\"`, `\"false\"`, and `\"null\"` will be\ninterpreted as their JavaScript equivalents, and numeric values will be\ninterpreted as a number.\n\nYou can also mix types and values, or multiple types, in a list. For\ninstance `{ blah: [Number, null] }` would allow a value to be set to\neither a Number or null.\n\nTo define a new type, add it to `nopt.typeDefs`. Each item in that\nhash is an object with a `type` member and a `validate` method. The\n`type` member is an object that matches what goes in the type list. The\n`validate` method is a function that gets called with `validate(data,\nkey, val)`. Validate methods should assign `data[key]` to the valid\nvalue of `val` if it can be handled properly, or return boolean\n`false` if it cannot.\n\nYou can also call `nopt.clean(data, types, typeDefs)` to clean up a\nconfig object and remove its invalid properties.\n\n## Error Handling\n\nBy default, nopt outputs a warning to standard error when invalid\noptions are found. You can change this behavior by assigning a method\nto `nopt.invalidHandler`. This method will be called with\nthe offending `nopt.invalidHandler(key, val, types)`.\n\nIf no `nopt.invalidHandler` is assigned, then it will console.error\nits whining. If it is assigned to boolean `false` then the warning is\nsuppressed.\n\n## Abbreviations\n\nYes, they are supported. If you define options like this:\n\n```javascript\n{ \"foolhardyelephants\" : Boolean\n, \"pileofmonkeys\" : Boolean }\n```\n\nThen this will work:\n\n```bash\nnode program.js --foolhar --pil\nnode program.js --no-f --pileofmon\n# etc.\n```\n\n## Shorthands\n\nShorthands are a hash of shorter option names to a snippet of args that\nthey expand to.\n\nIf multiple one-character shorthands are all combined, and the\ncombination does not unambiguously match any other option or shorthand,\nthen they will be broken up into their constituent parts. For example:\n\n```json\n{ \"s\" : [\"--loglevel\", \"silent\"]\n, \"g\" : \"--global\"\n, \"f\" : \"--force\"\n, \"p\" : \"--parseable\"\n, \"l\" : \"--long\"\n}\n```\n\n```bash\nnpm ls -sgflp\n# just like doing this:\nnpm ls --loglevel silent --global --force --long --parseable\n```\n\n## The Rest of the args\n\nThe config object returned by nopt is given a special member called\n`argv`, which is an object with the following fields:\n\n* `remain`: The remaining args after all the parsing has occurred.\n* `original`: The args as they originally appeared.\n* `cooked`: The args after flags and shorthands are expanded.\n\n## Slicing\n\nNode programs are called with more or less the exact argv as it appears\nin C land, after the v8 and node-specific options have been plucked off.\nAs such, `argv[0]` is always `node` and `argv[1]` is always the\nJavaScript program being run.\n\nThat's usually not very useful to you. So they're sliced off by\ndefault. If you want them, then you can pass in `0` as the last\nargument, or any other number that you'd like to slice off the start of\nthe list.\n", + "readmeFilename": "README.md", + "_id": "nopt@1.0.10", + "dist": { + "shasum": "82a43cbb79f29795a93f031ffa093819515ed248" + }, + "_from": "nopt@~1.0.10", + "_resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/rimraf/AUTHORS b/Phaser/node_modules/grunt/node_modules/rimraf/AUTHORS new file mode 100644 index 00000000..247b7543 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/rimraf/AUTHORS @@ -0,0 +1,6 @@ +# Authors sorted by whether or not they're me. +Isaac Z. Schlueter (http://blog.izs.me) +Wayne Larsen (http://github.com/wvl) +ritch +Marcel Laverdet +Yosef Dinerstein diff --git a/Phaser/node_modules/grunt/node_modules/rimraf/LICENSE b/Phaser/node_modules/grunt/node_modules/rimraf/LICENSE new file mode 100644 index 00000000..05a40109 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/rimraf/LICENSE @@ -0,0 +1,23 @@ +Copyright 2009, 2010, 2011 Isaac Z. Schlueter. +All rights reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/rimraf/README.md b/Phaser/node_modules/grunt/node_modules/rimraf/README.md new file mode 100644 index 00000000..96ce9b2a --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/rimraf/README.md @@ -0,0 +1,21 @@ +A `rm -rf` for node. + +Install with `npm install rimraf`, or just drop rimraf.js somewhere. + +## API + +`rimraf(f, callback)` + +The callback will be called with an error if there is one. Certain +errors are handled for you: + +* `EBUSY` - rimraf will back off a maximum of opts.maxBusyTries times + before giving up. +* `EMFILE` - If too many file descriptors get opened, rimraf will + patiently wait until more become available. + + +## rimraf.sync + +It can remove stuff synchronously, too. But that's not so good. Use +the async API. It's better. diff --git a/Phaser/node_modules/grunt/node_modules/rimraf/node_modules/graceful-fs/.npmignore b/Phaser/node_modules/grunt/node_modules/rimraf/node_modules/graceful-fs/.npmignore new file mode 100644 index 00000000..c2658d7d --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/rimraf/node_modules/graceful-fs/.npmignore @@ -0,0 +1 @@ +node_modules/ diff --git a/Phaser/node_modules/grunt/node_modules/rimraf/node_modules/graceful-fs/LICENSE b/Phaser/node_modules/grunt/node_modules/rimraf/node_modules/graceful-fs/LICENSE new file mode 100644 index 00000000..05a40109 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/rimraf/node_modules/graceful-fs/LICENSE @@ -0,0 +1,23 @@ +Copyright 2009, 2010, 2011 Isaac Z. Schlueter. +All rights reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/rimraf/node_modules/graceful-fs/README.md b/Phaser/node_modules/grunt/node_modules/rimraf/node_modules/graceful-fs/README.md new file mode 100644 index 00000000..7d2e681e --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/rimraf/node_modules/graceful-fs/README.md @@ -0,0 +1,5 @@ +Just like node's `fs` module, but it does an incremental back-off when +EMFILE is encountered. + +Useful in asynchronous situations where one needs to try to open lots +and lots of files. diff --git a/Phaser/node_modules/grunt/node_modules/rimraf/node_modules/graceful-fs/package.json b/Phaser/node_modules/grunt/node_modules/rimraf/node_modules/graceful-fs/package.json new file mode 100644 index 00000000..050d3e51 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/rimraf/node_modules/graceful-fs/package.json @@ -0,0 +1,40 @@ +{ + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me" + }, + "name": "graceful-fs", + "description": "fs monkey-patching to avoid EMFILE and other problems", + "version": "1.1.14", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/node-graceful-fs.git" + }, + "main": "graceful-fs.js", + "engines": { + "node": ">=0.4.0" + }, + "directories": { + "test": "test" + }, + "scripts": { + "test": "tap test/*.js" + }, + "keywords": [ + "fs", + "EMFILE", + "error", + "handling", + "monkeypatch" + ], + "license": "BSD", + "readme": "Just like node's `fs` module, but it does an incremental back-off when\nEMFILE is encountered.\n\nUseful in asynchronous situations where one needs to try to open lots\nand lots of files.\n", + "readmeFilename": "README.md", + "_id": "graceful-fs@1.1.14", + "dist": { + "shasum": "6876c83c31424763e36d1498a9157eff859e9c22" + }, + "_from": "graceful-fs@~1.1", + "_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.1.14.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/rimraf/package.json b/Phaser/node_modules/grunt/node_modules/rimraf/package.json new file mode 100644 index 00000000..43865083 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/rimraf/package.json @@ -0,0 +1,59 @@ +{ + "name": "rimraf", + "version": "2.0.3", + "main": "rimraf.js", + "description": "A deep deletion module for node (like `rm -rf`)", + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "license": { + "type": "MIT", + "url": "https://github.com/isaacs/rimraf/raw/master/LICENSE" + }, + "optionalDependencies": { + "graceful-fs": "~1.1" + }, + "repository": { + "type": "git", + "url": "git://github.com/isaacs/rimraf.git" + }, + "scripts": { + "test": "cd test && bash run.sh" + }, + "contributors": [ + { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me" + }, + { + "name": "Wayne Larsen", + "email": "wayne@larsen.st", + "url": "http://github.com/wvl" + }, + { + "name": "ritch", + "email": "skawful@gmail.com" + }, + { + "name": "Marcel Laverdet" + }, + { + "name": "Yosef Dinerstein", + "email": "yosefd@microsoft.com" + } + ], + "readme": "A `rm -rf` for node.\n\nInstall with `npm install rimraf`, or just drop rimraf.js somewhere.\n\n## API\n\n`rimraf(f, callback)`\n\nThe callback will be called with an error if there is one. Certain\nerrors are handled for you:\n\n* `EBUSY` - rimraf will back off a maximum of opts.maxBusyTries times\n before giving up.\n* `EMFILE` - If too many file descriptors get opened, rimraf will\n patiently wait until more become available.\n\n\n## rimraf.sync\n\nIt can remove stuff synchronously, too. But that's not so good. Use\nthe async API. It's better.\n", + "readmeFilename": "README.md", + "_id": "rimraf@2.0.3", + "dependencies": { + "graceful-fs": "~1.1" + }, + "dist": { + "shasum": "9c0d52e7f19c281e490308a405abaa81175d038e" + }, + "_from": "rimraf@~2.0.2", + "_resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.0.3.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/rimraf/test/run.sh b/Phaser/node_modules/grunt/node_modules/rimraf/test/run.sh new file mode 100644 index 00000000..598f0163 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/rimraf/test/run.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e +for i in test-*.js; do + echo -n $i ... + bash setup.sh + node $i + ! [ -d target ] + echo "pass" +done +rm -rf target diff --git a/Phaser/node_modules/grunt/node_modules/rimraf/test/setup.sh b/Phaser/node_modules/grunt/node_modules/rimraf/test/setup.sh new file mode 100644 index 00000000..2602e631 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/rimraf/test/setup.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +set -e + +files=10 +folders=2 +depth=4 +target="$PWD/target" + +rm -rf target + +fill () { + local depth=$1 + local files=$2 + local folders=$3 + local target=$4 + + if ! [ -d $target ]; then + mkdir -p $target + fi + + local f + + f=$files + while [ $f -gt 0 ]; do + touch "$target/f-$depth-$f" + let f-- + done + + let depth-- + + if [ $depth -le 0 ]; then + return 0 + fi + + f=$folders + while [ $f -gt 0 ]; do + mkdir "$target/folder-$depth-$f" + fill $depth $files $folders "$target/d-$depth-$f" + let f-- + done +} + +fill $depth $files $folders $target + +# sanity assert +[ -d $target ] diff --git a/Phaser/node_modules/grunt/node_modules/underscore.string/.travis.yml b/Phaser/node_modules/grunt/node_modules/underscore.string/.travis.yml new file mode 100644 index 00000000..ab27b29b --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/underscore.string/.travis.yml @@ -0,0 +1,8 @@ +language: ruby +rvm: + - 1.9.3 + +before_script: + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" + - sleep 2 \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/underscore.string/Gemfile b/Phaser/node_modules/grunt/node_modules/underscore.string/Gemfile new file mode 100644 index 00000000..f0248273 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/underscore.string/Gemfile @@ -0,0 +1,5 @@ +source :rubygems + +gem 'serve' +gem 'uglifier' +gem 'rake' \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/underscore.string/Gemfile.lock b/Phaser/node_modules/grunt/node_modules/underscore.string/Gemfile.lock new file mode 100644 index 00000000..a6bb1e73 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/underscore.string/Gemfile.lock @@ -0,0 +1,34 @@ +GEM + remote: http://rubygems.org/ + specs: + activesupport (3.2.3) + i18n (~> 0.6) + multi_json (~> 1.0) + execjs (1.3.0) + multi_json (~> 1.0) + i18n (0.6.0) + multi_json (1.2.0) + rack (1.4.1) + rack-test (0.6.1) + rack (>= 1.0) + rake (0.9.2.2) + serve (1.5.1) + activesupport (~> 3.0) + i18n + rack (~> 1.2) + rack-test (~> 0.5) + tilt (~> 1.3) + tzinfo + tilt (1.3.3) + tzinfo (0.3.33) + uglifier (1.2.4) + execjs (>= 0.3.0) + multi_json (>= 1.0.2) + +PLATFORMS + ruby + +DEPENDENCIES + rake + serve + uglifier diff --git a/Phaser/node_modules/grunt/node_modules/underscore.string/README.markdown b/Phaser/node_modules/grunt/node_modules/underscore.string/README.markdown new file mode 100644 index 00000000..d2244b57 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/underscore.string/README.markdown @@ -0,0 +1,668 @@ +# Underscore.string [![Build Status](https://secure.travis-ci.org/epeli/underscore.string.png?branch=master)](http://travis-ci.org/epeli/underscore.string) # + + + +Javascript lacks complete string manipulation operations. +This an attempt to fill that gap. List of build-in methods can be found +for example from [Dive Into JavaScript][d]. + +[d]: http://www.diveintojavascript.com/core-javascript-reference/the-string-object + + +As name states this an extension for [Underscore.js][u], but it can be used +independently from **_s**-global variable. But with Underscore.js you can +use Object-Oriented style and chaining: + +[u]: http://documentcloud.github.com/underscore/ + +```javascript +_(" epeli ").chain().trim().capitalize().value() +=> "Epeli" +``` + +## Download ## + + * [Development version](https://raw.github.com/epeli/underscore.string/master/lib/underscore.string.js) *Uncompressed with Comments 18kb* + * [Production version](https://github.com/epeli/underscore.string/raw/master/dist/underscore.string.min.js) *Minified 7kb* + + +## Node.js installation ## + +**npm package** + + npm install underscore.string + +**Standalone usage**: + +```javascript +var _s = require('underscore.string'); +``` + +**Integrate with Underscore.js**: + +```javascript +var _ = require('underscore'); + +// Import Underscore.string to separate object, because there are conflict functions (include, reverse, contains) +_.str = require('underscore.string'); + +// Mix in non-conflict functions to Underscore namespace if you want +_.mixin(_.str.exports()); + +// All functions, include conflict, will be available through _.str object +_.str.include('Underscore.string', 'string'); // => true +``` + +## String Functions ## + +For availability of functions in this way you need to mix in Underscore.string functions: + +```javascript +_.mixin(_.string.exports()); +``` + +otherwise functions from examples will be available through _.string or _.str objects: + +```javascript +_.str.capitalize('epeli') +=> "Epeli" +``` + +**capitalize** _.capitalize(string) + +Converts first letter of the string to uppercase. + +```javascript +_.capitalize("foo Bar") +=> "Foo Bar" +``` + +**chop** _.chop(string, step) + +```javascript +_.chop('whitespace', 3) +=> ['whi','tes','pac','e'] +``` + +**clean** _.clean(str) + +Compress some whitespaces to one. + +```javascript +_.clean(" foo bar ") +=> 'foo bar' +``` + +**chars** _.chars(str) + +```javascript +_.chars('Hello') +=> ['H','e','l','l','o'] +``` + +**includes** _.includes(string, substring) + +Tests if string contains a substring. + +```javascript +_.includes("foobar", "ob") +=> true +``` + +**include** available only through _.str object, because Underscore has function with the same name. + +```javascript +_.str.include("foobar", "ob") +=> true +``` + +**includes** function was removed + +But you can create it in this way, for compatibility with previous versions: + +```javascript +_.includes = _.str.include +``` + +**count** _.count(string, substring) + +```javascript +_('Hello world').count('l') +=> 3 +``` + +**escapeHTML** _.escapeHTML(string) + +Converts HTML special characters to their entity equivalents. + +```javascript +_('
        Blah blah blah
        ').escapeHTML(); +=> '<div>Blah blah blah</div>' +``` + +**unescapeHTML** _.unescapeHTML(string) + +Converts entity characters to HTML equivalents. + +```javascript +_('<div>Blah blah blah</div>').unescapeHTML(); +=> '
        Blah blah blah
        ' +``` + +**insert** _.insert(string, index, substing) + +```javascript +_('Hello ').insert(6, 'world') +=> 'Hello world' +``` + +**isBlank** _.isBlank(string) + +```javascript +_('').isBlank(); // => true +_('\n').isBlank(); // => true +_(' ').isBlank(); // => true +_('a').isBlank(); // => false +``` + +**join** _.join(separator, *strings) + +Joins strings together with given separator + +```javascript +_.join(" ", "foo", "bar") +=> "foo bar" +``` + +**lines** _.lines(str) + +```javascript +_.lines("Hello\nWorld") +=> ["Hello", "World"] +``` + +**reverse** available only through _.str object, because Underscore has function with the same name. + +Return reversed string: + +```javascript +_.str.reverse("foobar") +=> 'raboof' +``` + +**splice** _.splice(string, index, howmany, substring) + +Like a array splice. + +```javascript +_('https://edtsech@bitbucket.org/edtsech/underscore.strings').splice(30, 7, 'epeli') +=> 'https://edtsech@bitbucket.org/epeli/underscore.strings' +``` + +**startsWith** _.startsWith(string, starts) + +This method checks whether string starts with starts. + +```javascript +_("image.gif").startsWith("image") +=> true +``` + +**endsWith** _.endsWith(string, ends) + +This method checks whether string ends with ends. + +```javascript +_("image.gif").endsWith("gif") +=> true +``` + +**succ** _.succ(str) + +Returns the successor to str. + +```javascript +_('a').succ() +=> 'b' + +_('A').succ() +=> 'B' +``` + +**supplant** + +Supplant function was removed, use Underscore.js [template function][p]. + +[p]: http://documentcloud.github.com/underscore/#template + +**strip** alias for *trim* + +**lstrip** alias for *ltrim* + +**rstrip** alias for *rtrim* + +**titleize** _.titleize(string) + +```javascript +_('my name is epeli').titleize() +=> 'My Name Is Epeli' +``` + +**camelize** _.camelize(string) + +Converts underscored or dasherized string to a camelized one + +```javascript +_('-moz-transform').camelize() +=> 'MozTransform' +``` + +**classify** _.classify(string) + +Converts string to camelized class name + +```javascript +_('some_class_name').classify() +=> 'SomeClassName' +``` + +**underscored** _.underscored(string) + +Converts a camelized or dasherized string into an underscored one + +```javascript +_('MozTransform').underscored() +=> 'moz_transform' +``` + +**dasherize** _.dasherize(string) + +Converts a underscored or camelized string into an dasherized one + +```javascript +_('MozTransform').dasherize() +=> '-moz-transform' +``` + +**humanize** _.humanize(string) + +Converts an underscored, camelized, or dasherized string into a humanized one. +Also removes beginning and ending whitespace, and removes the postfix '_id'. + +```javascript +_(' capitalize dash-CamelCase_underscore trim ').humanize() +=> 'Capitalize dash camel case underscore trim' +``` + +**trim** _.trim(string, [characters]) + +trims defined characters from begining and ending of the string. +Defaults to whitespace characters. + +```javascript +_.trim(" foobar ") +=> "foobar" + +_.trim("_-foobar-_", "_-") +=> "foobar" +``` + + +**ltrim** _.ltrim(string, [characters]) + +Left trim. Similar to trim, but only for left side. + + +**rtrim** _.rtrim(string, [characters]) + +Right trim. Similar to trim, but only for right side. + +**truncate** _.truncate(string, length, truncateString) + +```javascript +_('Hello world').truncate(5) +=> 'Hello...' + +_('Hello').truncate(10) +=> 'Hello' +``` + +**prune** _.prune(string, length, pruneString) + +Elegant version of truncate. +Makes sure the pruned string does not exceed the original length. +Avoid half-chopped words when truncating. + +```javascript +_('Hello, world').prune(5) +=> 'Hello...' + +_('Hello, world').prune(8) +=> 'Hello...' + +_('Hello, world').prune(5, ' (read a lot more)') +=> 'Hello, world' (as adding "(read a lot more)" would be longer than the original string) + +_('Hello, cruel world').prune(15) +=> 'Hello, cruel...' + +_('Hello').prune(10) +=> 'Hello' +``` + +**words** _.words(str, delimiter=" ") + +Split string by delimiter (String or RegExp), ' ' by default. + +```javascript +_.words("I love you") +=> ["I","love","you"] + +_.words("I_love_you", "_") +=> ["I","love","you"] + +_.words("I-love-you", /-/) +=> ["I","love","you"] +``` + +**sprintf** _.sprintf(string format, *arguments) + +C like string formatting. +Credits goes to [Alexandru Marasteanu][o]. +For more detailed documentation, see the [original page][o]. + +[o]: http://www.diveintojavascript.com/projects/sprintf-for-javascript + +```javascript +_.sprintf("%.1f", 1.17) +"1.2" +``` + +**pad** _.pad(str, length, [padStr, type]) + +pads the `str` with characters until the total string length is equal to the passed `length` parameter. By default, pads on the **left** with the space char (`" "`). `padStr` is truncated to a single character if necessary. + +```javascript +_.pad("1", 8) +-> " 1"; + +_.pad("1", 8, '0') +-> "00000001"; + +_.pad("1", 8, '0', 'right') +-> "10000000"; + +_.pad("1", 8, '0', 'both') +-> "00001000"; + +_.pad("1", 8, 'bleepblorp', 'both') +-> "bbbb1bbb"; +``` + +**lpad** _.lpad(str, length, [padStr]) + +left-pad a string. Alias for `pad(str, length, padStr, 'left')` + +```javascript +_.lpad("1", 8, '0') +-> "00000001"; +``` + +**rpad** _.rpad(str, length, [padStr]) + +right-pad a string. Alias for `pad(str, length, padStr, 'right')` + +```javascript +_.rpad("1", 8, '0') +-> "10000000"; +``` + +**lrpad** _.lrpad(str, length, [padStr]) + +left/right-pad a string. Alias for `pad(str, length, padStr, 'both')` + +```javascript +_.lrpad("1", 8, '0') +-> "00001000"; +``` + +**center** alias for **lrpad** + +**ljust** alias for *rpad* + +**rjust** alias for *lpad* + +**toNumber** _.toNumber(string, [decimals]) + +Parse string to number. Returns NaN if string can't be parsed to number. + +```javascript +_('2.556').toNumber() +=> 3 + +_('2.556').toNumber(1) +=> 2.6 +``` + +**strRight** _.strRight(string, pattern) + +Searches a string from left to right for a pattern and returns a substring consisting of the characters in the string that are to the right of the pattern or all string if no match found. + +```javascript +_('This_is_a_test_string').strRight('_') +=> "is_a_test_string"; +``` + +**strRightBack** _.strRightBack(string, pattern) + +Searches a string from right to left for a pattern and returns a substring consisting of the characters in the string that are to the right of the pattern or all string if no match found. + +```javascript +_('This_is_a_test_string').strRightBack('_') +=> "string"; +``` + +**strLeft** _.strLeft(string, pattern) + +Searches a string from left to right for a pattern and returns a substring consisting of the characters in the string that are to the left of the pattern or all string if no match found. + +```javascript +_('This_is_a_test_string').strLeft('_') +=> "This"; +``` + +**strLeftBack** _.strLeftBack(string, pattern) + +Searches a string from right to left for a pattern and returns a substring consisting of the characters in the string that are to the left of the pattern or all string if no match found. + +```javascript +_('This_is_a_test_string').strLeftBack('_') +=> "This_is_a_test"; +``` + +**stripTags** + +Removes all html tags from string. + +```javascript +_('a link').stripTags() +=> 'a link' + +_('a link').stripTags() +=> 'a linkalert("hello world!")' +``` + +**toSentence** _.toSentence(array, [delimiter, lastDelimiter]) + +Join an array into a human readable sentence. + +```javascript +_.toSentence(['jQuery', 'Mootools', 'Prototype']) +=> 'jQuery, Mootools and Prototype'; + +_.toSentence(['jQuery', 'Mootools', 'Prototype'], ', ', ' unt ') +=> 'jQuery, Mootools unt Prototype'; +``` + +**repeat** _.repeat(string, count, [separator]) + +Repeats a string count times. + +```javascript +_.repeat("foo", 3) +=> 'foofoofoo'; + +_.repeat("foo", 3, "bar") +=> 'foobarfoobarfoo' +``` + +**slugify** _.slugify(string) + +Transform text into a URL slug. Replaces whitespaces, accentuated, and special characters with a dash. + +```javascript +_.slugify("Un éléphant à l'orée du bois") +=> 'un-elephant-a-loree-du-bois'; +``` + +***Caution: this function is charset dependent*** + +## Roadmap ## + +Any suggestions or bug reports are welcome. Just email me or more preferably open an issue. + +## Changelog ## + +### 2.0.0 ### + +* Added prune, humanize functions +* Added _.string (_.str) namespace for Underscore.string library +* Removed includes function + +#### Problems + +We lose two things for `include` and `reverse` methods from `_.string`: + +* Calls like `_('foobar').include('bar')` aren't available; +* Chaining isn't available too. + +But if you need this functionality you can create aliases for conflict functions which will be convenient for you: + +```javascript +_.mixin({ + includeString: _.str.include, + reverseString: _.str.reverse +}) + +// Now wrapper calls and chaining are available. +_('foobar').chain().reverseString().includeString('rab').value() +``` + +#### Standalone Usage + +If you are using Underscore.string without Underscore. You also have `_.string` namespace for it and `_.str` alias +But of course you can just reassign `_` variable with `_.string` + +```javascript +_ = _.string +``` +### 2.2.0 ### + +* Capitalize method behavior changed +* Various perfomance tweaks + +### 2.1.1### + +* Fixed words method bug +* Added classify method + +### 2.1.0 ### + +* AMD support +* Added toSentence method +* Added slugify method +* Lots of speed optimizations + +### 2.0.0 ### + +For upgrading to this version you need to mix in Underscore.string library to Underscore object: + +```javascript +_.mixin(_.string.exports()); +``` + +and all non-conflict Underscore.string functions will be available through Underscore object. +Also function `includes` has been removed, you should replace this function by `_.str.include` +or create alias `_.includes = _.str.include` and all your code will work fine. + +### 1.1.6 ### + +* Fixed reverse and truncate +* Added isBlank, stripTags, inlude(alias for includes) +* Added uglifier compression + +### 1.1.5 ### + +* Added strRight, strRightBack, strLeft, strLeftBack + +### 1.1.4 ### + +* Added pad, lpad, rpad, lrpad methods and aliases center, ljust, rjust +* Integration with Underscore 1.1.6 + +### 1.1.3 ### + +* Added methods: underscored, camelize, dasherize +* Support newer version of npm + +### 1.1.2 ### + +* Created functions: lines, chars, words functions + +### 1.0.2 ### + +* Created integration test suite with underscore.js 1.1.4 (now it's absolutely compatible) +* Removed 'reverse' function, because this function override underscore.js 'reverse' + +## Contribute ## + +* Fork & pull request. Don't forget about tests. +* If you planning add some feature please create issue before. + +Otherwise changes will be rejected. + +## Contributors list ## + +* Esa-Matti Suuronen (), +* Edward Tsech , +* Sasha Koss (), +* Vladimir Dronnikov , +* Pete Kruckenberg (), +* Paul Chavard (), +* Ed Finkler () +* Pavel Pravosud +* Anton Lindqvist () + +## Licence ## + +The MIT License + +Copyright (c) 2011 Esa-Matti Suuronen esa-matti@suuronen.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/underscore.string/Rakefile b/Phaser/node_modules/grunt/node_modules/underscore.string/Rakefile new file mode 100644 index 00000000..baa164cd --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/underscore.string/Rakefile @@ -0,0 +1,28 @@ +# encoding: utf-8 +task default: :test + +desc 'Use UglifyJS to compress Underscore.string' +task :build do + require 'uglifier' + source = File.read('lib/underscore.string.js') + compressed = Uglifier.compile(source, copyright: false) + File.open('dist/underscore.string.min.js', 'w'){ |f| f.write compressed } + compression_rate = compressed.length.to_f/source.length + puts "compressed dist/underscore.string.min.js: #{compressed.length}/#{source.length} #{(compression_rate * 100).round}%" +end + +desc 'Run tests' +task :test do + pid = spawn('bundle exec serve', err: '/dev/null') + sleep 2 + + puts "Running underscore.string test suite." + result1 = system %{phantomjs ./test/run-qunit.js "http://localhost:4000/test/test.html"} + + puts "Running Underscore test suite." + result2 = system %{phantomjs ./test/run-qunit.js "http://localhost:4000/test/test_underscore/test.html"} + + Process.kill 'INT', pid + + exit(result1 && result2 ? 0 : 1) +end \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/underscore.string/package.json b/Phaser/node_modules/grunt/node_modules/underscore.string/package.json new file mode 100644 index 00000000..790c8306 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/underscore.string/package.json @@ -0,0 +1,76 @@ +{ + "name": "underscore.string", + "version": "2.2.0rc", + "description": "String manipulation extensions for Underscore.js javascript library.", + "homepage": "http://epeli.github.com/underscore.string/", + "contributors": [ + { + "name": "Esa-Matti Suuronen", + "email": "esa-matti@suuronen.org", + "url": "http://esa-matti.suuronen.org/" + }, + { + "name": "Edward Tsech", + "email": "edtsech@gmail.com" + }, + { + "name": "Sasha Koss", + "email": "kossnocorp@gmail.com", + "url": "http://koss.nocorp.me/" + }, + { + "name": "Vladimir Dronnikov", + "email": "dronnikov@gmail.com" + }, + { + "name": "Pete Kruckenberg", + "email": "https://github.com/kruckenb", + "url": "" + }, + { + "name": "Paul Chavard", + "email": "paul@chavard.net", + "url": "" + }, + { + "name": "Ed Finkler", + "email": "coj@funkatron.com", + "url": "" + }, + { + "name": "Pavel Pravosud", + "email": "rwz@duckroll.ru" + } + ], + "keywords": [ + "underscore", + "string" + ], + "main": "./lib/underscore.string", + "directories": { + "lib": "./lib" + }, + "engines": { + "node": "*" + }, + "repository": { + "type": "git", + "url": "https://github.com/epeli/underscore.string.git" + }, + "bugs": { + "url": "https://github.com/epeli/underscore.string/issues" + }, + "licenses": [ + { + "type": "MIT" + } + ], + "readme": "# Underscore.string [![Build Status](https://secure.travis-ci.org/epeli/underscore.string.png?branch=master)](http://travis-ci.org/epeli/underscore.string) #\n\n\n\nJavascript lacks complete string manipulation operations.\nThis an attempt to fill that gap. List of build-in methods can be found\nfor example from [Dive Into JavaScript][d].\n\n[d]: http://www.diveintojavascript.com/core-javascript-reference/the-string-object\n\n\nAs name states this an extension for [Underscore.js][u], but it can be used\nindependently from **_s**-global variable. But with Underscore.js you can\nuse Object-Oriented style and chaining:\n\n[u]: http://documentcloud.github.com/underscore/\n\n```javascript\n_(\" epeli \").chain().trim().capitalize().value()\n=> \"Epeli\"\n```\n\n## Download ##\n\n * [Development version](https://raw.github.com/epeli/underscore.string/master/lib/underscore.string.js) *Uncompressed with Comments 18kb*\n * [Production version](https://github.com/epeli/underscore.string/raw/master/dist/underscore.string.min.js) *Minified 7kb*\n\n\n## Node.js installation ##\n\n**npm package**\n\n npm install underscore.string\n\n**Standalone usage**:\n\n```javascript\nvar _s = require('underscore.string');\n```\n\n**Integrate with Underscore.js**:\n\n```javascript\nvar _ = require('underscore');\n\n// Import Underscore.string to separate object, because there are conflict functions (include, reverse, contains)\n_.str = require('underscore.string');\n\n// Mix in non-conflict functions to Underscore namespace if you want\n_.mixin(_.str.exports());\n\n// All functions, include conflict, will be available through _.str object\n_.str.include('Underscore.string', 'string'); // => true\n```\n\n## String Functions ##\n\nFor availability of functions in this way you need to mix in Underscore.string functions:\n\n```javascript\n_.mixin(_.string.exports());\n```\n\notherwise functions from examples will be available through _.string or _.str objects:\n\n```javascript\n_.str.capitalize('epeli')\n=> \"Epeli\"\n```\n\n**capitalize** _.capitalize(string)\n\nConverts first letter of the string to uppercase.\n\n```javascript\n_.capitalize(\"foo Bar\")\n=> \"Foo Bar\"\n```\n\n**chop** _.chop(string, step)\n\n```javascript\n_.chop('whitespace', 3)\n=> ['whi','tes','pac','e']\n```\n\n**clean** _.clean(str)\n\nCompress some whitespaces to one.\n\n```javascript\n_.clean(\" foo bar \")\n=> 'foo bar'\n```\n\n**chars** _.chars(str)\n\n```javascript\n_.chars('Hello')\n=> ['H','e','l','l','o']\n```\n\n**includes** _.includes(string, substring)\n\nTests if string contains a substring.\n\n```javascript\n_.includes(\"foobar\", \"ob\")\n=> true\n```\n\n**include** available only through _.str object, because Underscore has function with the same name.\n\n```javascript\n_.str.include(\"foobar\", \"ob\")\n=> true\n```\n\n**includes** function was removed\n\nBut you can create it in this way, for compatibility with previous versions:\n\n```javascript\n_.includes = _.str.include\n```\n\n**count** _.count(string, substring)\n\n```javascript\n_('Hello world').count('l')\n=> 3\n```\n\n**escapeHTML** _.escapeHTML(string)\n\nConverts HTML special characters to their entity equivalents.\n\n```javascript\n_('
        Blah blah blah
        ').escapeHTML();\n=> '<div>Blah blah blah</div>'\n```\n\n**unescapeHTML** _.unescapeHTML(string)\n\nConverts entity characters to HTML equivalents.\n\n```javascript\n_('<div>Blah blah blah</div>').unescapeHTML();\n=> '
        Blah blah blah
        '\n```\n\n**insert** _.insert(string, index, substing)\n\n```javascript\n_('Hello ').insert(6, 'world')\n=> 'Hello world'\n```\n\n**isBlank** _.isBlank(string)\n\n```javascript\n_('').isBlank(); // => true\n_('\\n').isBlank(); // => true\n_(' ').isBlank(); // => true\n_('a').isBlank(); // => false\n```\n\n**join** _.join(separator, *strings)\n\nJoins strings together with given separator\n\n```javascript\n_.join(\" \", \"foo\", \"bar\")\n=> \"foo bar\"\n```\n\n**lines** _.lines(str)\n\n```javascript\n_.lines(\"Hello\\nWorld\")\n=> [\"Hello\", \"World\"]\n```\n\n**reverse** available only through _.str object, because Underscore has function with the same name.\n\nReturn reversed string:\n\n```javascript\n_.str.reverse(\"foobar\")\n=> 'raboof'\n```\n\n**splice** _.splice(string, index, howmany, substring)\n\nLike a array splice.\n\n```javascript\n_('https://edtsech@bitbucket.org/edtsech/underscore.strings').splice(30, 7, 'epeli')\n=> 'https://edtsech@bitbucket.org/epeli/underscore.strings'\n```\n\n**startsWith** _.startsWith(string, starts)\n\nThis method checks whether string starts with starts.\n\n```javascript\n_(\"image.gif\").startsWith(\"image\")\n=> true\n```\n\n**endsWith** _.endsWith(string, ends)\n\nThis method checks whether string ends with ends.\n\n```javascript\n_(\"image.gif\").endsWith(\"gif\")\n=> true\n```\n\n**succ** _.succ(str)\n\nReturns the successor to str.\n\n```javascript\n_('a').succ()\n=> 'b'\n\n_('A').succ()\n=> 'B'\n```\n\n**supplant**\n\nSupplant function was removed, use Underscore.js [template function][p].\n\n[p]: http://documentcloud.github.com/underscore/#template\n\n**strip** alias for *trim*\n\n**lstrip** alias for *ltrim*\n\n**rstrip** alias for *rtrim*\n\n**titleize** _.titleize(string)\n\n```javascript\n_('my name is epeli').titleize()\n=> 'My Name Is Epeli'\n```\n\n**camelize** _.camelize(string)\n\nConverts underscored or dasherized string to a camelized one\n\n```javascript\n_('-moz-transform').camelize()\n=> 'MozTransform'\n```\n\n**classify** _.classify(string)\n\nConverts string to camelized class name\n\n```javascript\n_('some_class_name').classify()\n=> 'SomeClassName'\n```\n\n**underscored** _.underscored(string)\n\nConverts a camelized or dasherized string into an underscored one\n\n```javascript\n_('MozTransform').underscored()\n=> 'moz_transform'\n```\n\n**dasherize** _.dasherize(string)\n\nConverts a underscored or camelized string into an dasherized one\n\n```javascript\n_('MozTransform').dasherize()\n=> '-moz-transform'\n```\n\n**humanize** _.humanize(string)\n\nConverts an underscored, camelized, or dasherized string into a humanized one.\nAlso removes beginning and ending whitespace, and removes the postfix '_id'.\n\n```javascript\n_(' capitalize dash-CamelCase_underscore trim ').humanize()\n=> 'Capitalize dash camel case underscore trim'\n```\n\n**trim** _.trim(string, [characters])\n\ntrims defined characters from begining and ending of the string.\nDefaults to whitespace characters.\n\n```javascript\n_.trim(\" foobar \")\n=> \"foobar\"\n\n_.trim(\"_-foobar-_\", \"_-\")\n=> \"foobar\"\n```\n\n\n**ltrim** _.ltrim(string, [characters])\n\nLeft trim. Similar to trim, but only for left side.\n\n\n**rtrim** _.rtrim(string, [characters])\n\nRight trim. Similar to trim, but only for right side.\n\n**truncate** _.truncate(string, length, truncateString)\n\n```javascript\n_('Hello world').truncate(5)\n=> 'Hello...'\n\n_('Hello').truncate(10)\n=> 'Hello'\n```\n\n**prune** _.prune(string, length, pruneString)\n\nElegant version of truncate.\nMakes sure the pruned string does not exceed the original length.\nAvoid half-chopped words when truncating.\n\n```javascript\n_('Hello, world').prune(5)\n=> 'Hello...'\n\n_('Hello, world').prune(8)\n=> 'Hello...'\n\n_('Hello, world').prune(5, ' (read a lot more)')\n=> 'Hello, world' (as adding \"(read a lot more)\" would be longer than the original string)\n\n_('Hello, cruel world').prune(15)\n=> 'Hello, cruel...'\n\n_('Hello').prune(10)\n=> 'Hello'\n```\n\n**words** _.words(str, delimiter=\" \")\n\nSplit string by delimiter (String or RegExp), ' ' by default.\n\n```javascript\n_.words(\"I love you\")\n=> [\"I\",\"love\",\"you\"]\n\n_.words(\"I_love_you\", \"_\")\n=> [\"I\",\"love\",\"you\"]\n\n_.words(\"I-love-you\", /-/)\n=> [\"I\",\"love\",\"you\"]\n```\n\n**sprintf** _.sprintf(string format, *arguments)\n\nC like string formatting.\nCredits goes to [Alexandru Marasteanu][o].\nFor more detailed documentation, see the [original page][o].\n\n[o]: http://www.diveintojavascript.com/projects/sprintf-for-javascript\n\n```javascript\n_.sprintf(\"%.1f\", 1.17)\n\"1.2\"\n```\n\n**pad** _.pad(str, length, [padStr, type])\n\npads the `str` with characters until the total string length is equal to the passed `length` parameter. By default, pads on the **left** with the space char (`\" \"`). `padStr` is truncated to a single character if necessary.\n\n```javascript\n_.pad(\"1\", 8)\n-> \" 1\";\n\n_.pad(\"1\", 8, '0')\n-> \"00000001\";\n\n_.pad(\"1\", 8, '0', 'right')\n-> \"10000000\";\n\n_.pad(\"1\", 8, '0', 'both')\n-> \"00001000\";\n\n_.pad(\"1\", 8, 'bleepblorp', 'both')\n-> \"bbbb1bbb\";\n```\n\n**lpad** _.lpad(str, length, [padStr])\n\nleft-pad a string. Alias for `pad(str, length, padStr, 'left')`\n\n```javascript\n_.lpad(\"1\", 8, '0')\n-> \"00000001\";\n```\n\n**rpad** _.rpad(str, length, [padStr])\n\nright-pad a string. Alias for `pad(str, length, padStr, 'right')`\n\n```javascript\n_.rpad(\"1\", 8, '0')\n-> \"10000000\";\n```\n\n**lrpad** _.lrpad(str, length, [padStr])\n\nleft/right-pad a string. Alias for `pad(str, length, padStr, 'both')`\n\n```javascript\n_.lrpad(\"1\", 8, '0')\n-> \"00001000\";\n```\n\n**center** alias for **lrpad**\n\n**ljust** alias for *rpad*\n\n**rjust** alias for *lpad*\n\n**toNumber** _.toNumber(string, [decimals])\n\nParse string to number. Returns NaN if string can't be parsed to number.\n\n```javascript\n_('2.556').toNumber()\n=> 3\n\n_('2.556').toNumber(1)\n=> 2.6\n```\n\n**strRight** _.strRight(string, pattern)\n\nSearches a string from left to right for a pattern and returns a substring consisting of the characters in the string that are to the right of the pattern or all string if no match found.\n\n```javascript\n_('This_is_a_test_string').strRight('_')\n=> \"is_a_test_string\";\n```\n\n**strRightBack** _.strRightBack(string, pattern)\n\nSearches a string from right to left for a pattern and returns a substring consisting of the characters in the string that are to the right of the pattern or all string if no match found.\n\n```javascript\n_('This_is_a_test_string').strRightBack('_')\n=> \"string\";\n```\n\n**strLeft** _.strLeft(string, pattern)\n\nSearches a string from left to right for a pattern and returns a substring consisting of the characters in the string that are to the left of the pattern or all string if no match found.\n\n```javascript\n_('This_is_a_test_string').strLeft('_')\n=> \"This\";\n```\n\n**strLeftBack** _.strLeftBack(string, pattern)\n\nSearches a string from right to left for a pattern and returns a substring consisting of the characters in the string that are to the left of the pattern or all string if no match found.\n\n```javascript\n_('This_is_a_test_string').strLeftBack('_')\n=> \"This_is_a_test\";\n```\n\n**stripTags**\n\nRemoves all html tags from string.\n\n```javascript\n_('a link').stripTags()\n=> 'a link'\n\n_('a link').stripTags()\n=> 'a linkalert(\"hello world!\")'\n```\n\n**toSentence** _.toSentence(array, [delimiter, lastDelimiter])\n\nJoin an array into a human readable sentence.\n\n```javascript\n_.toSentence(['jQuery', 'Mootools', 'Prototype'])\n=> 'jQuery, Mootools and Prototype';\n\n_.toSentence(['jQuery', 'Mootools', 'Prototype'], ', ', ' unt ')\n=> 'jQuery, Mootools unt Prototype';\n```\n\n**repeat** _.repeat(string, count, [separator])\n\nRepeats a string count times.\n\n```javascript\n_.repeat(\"foo\", 3)\n=> 'foofoofoo';\n\n_.repeat(\"foo\", 3, \"bar\")\n=> 'foobarfoobarfoo'\n```\n\n**slugify** _.slugify(string)\n\nTransform text into a URL slug. Replaces whitespaces, accentuated, and special characters with a dash.\n\n```javascript\n_.slugify(\"Un éléphant à l'orée du bois\")\n=> 'un-elephant-a-loree-du-bois';\n```\n\n***Caution: this function is charset dependent***\n\n## Roadmap ##\n\nAny suggestions or bug reports are welcome. Just email me or more preferably open an issue.\n\n## Changelog ##\n\n### 2.0.0 ###\n\n* Added prune, humanize functions\n* Added _.string (_.str) namespace for Underscore.string library\n* Removed includes function\n\n#### Problems\n\nWe lose two things for `include` and `reverse` methods from `_.string`:\n\n* Calls like `_('foobar').include('bar')` aren't available;\n* Chaining isn't available too.\n\nBut if you need this functionality you can create aliases for conflict functions which will be convenient for you:\n\n```javascript\n_.mixin({\n includeString: _.str.include,\n reverseString: _.str.reverse\n})\n\n// Now wrapper calls and chaining are available.\n_('foobar').chain().reverseString().includeString('rab').value()\n```\n\n#### Standalone Usage\n\nIf you are using Underscore.string without Underscore. You also have `_.string` namespace for it and `_.str` alias\nBut of course you can just reassign `_` variable with `_.string`\n\n```javascript\n_ = _.string\n```\n### 2.2.0 ###\n\n* Capitalize method behavior changed\n* Various perfomance tweaks\n\n### 2.1.1###\n\n* Fixed words method bug\n* Added classify method\n\n### 2.1.0 ###\n\n* AMD support\n* Added toSentence method\n* Added slugify method\n* Lots of speed optimizations\n\n### 2.0.0 ###\n\nFor upgrading to this version you need to mix in Underscore.string library to Underscore object:\n\n```javascript\n_.mixin(_.string.exports());\n```\n\nand all non-conflict Underscore.string functions will be available through Underscore object.\nAlso function `includes` has been removed, you should replace this function by `_.str.include`\nor create alias `_.includes = _.str.include` and all your code will work fine.\n\n### 1.1.6 ###\n\n* Fixed reverse and truncate\n* Added isBlank, stripTags, inlude(alias for includes)\n* Added uglifier compression\n\n### 1.1.5 ###\n\n* Added strRight, strRightBack, strLeft, strLeftBack\n\n### 1.1.4 ###\n\n* Added pad, lpad, rpad, lrpad methods and aliases center, ljust, rjust\n* Integration with Underscore 1.1.6\n\n### 1.1.3 ###\n\n* Added methods: underscored, camelize, dasherize\n* Support newer version of npm\n\n### 1.1.2 ###\n\n* Created functions: lines, chars, words functions\n\n### 1.0.2 ###\n\n* Created integration test suite with underscore.js 1.1.4 (now it's absolutely compatible)\n* Removed 'reverse' function, because this function override underscore.js 'reverse'\n\n## Contribute ##\n\n* Fork & pull request. Don't forget about tests.\n* If you planning add some feature please create issue before.\n\nOtherwise changes will be rejected.\n\n## Contributors list ##\n\n* Esa-Matti Suuronen (),\n* Edward Tsech ,\n* Sasha Koss (),\n* Vladimir Dronnikov ,\n* Pete Kruckenberg (),\n* Paul Chavard (),\n* Ed Finkler ()\n* Pavel Pravosud \n* Anton Lindqvist ()\n\n## Licence ##\n\nThe MIT License\n\nCopyright (c) 2011 Esa-Matti Suuronen esa-matti@suuronen.org\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n", + "readmeFilename": "README.markdown", + "_id": "underscore.string@2.2.0rc", + "dist": { + "shasum": "d7435955bf01537dc506d3ef49f0b3f4a6388a31" + }, + "_from": "underscore.string@~2.2.0rc", + "_resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.2.0rc.tgz" +} diff --git a/Phaser/node_modules/grunt/node_modules/underscore.string/test/test.html b/Phaser/node_modules/grunt/node_modules/underscore.string/test/test.html new file mode 100644 index 00000000..c959a3a3 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/underscore.string/test/test.html @@ -0,0 +1,31 @@ + + + + + Underscore.strings Test Suite + + + + + + + + + + +

        Underscore.string Test Suite

        +

        +

        +
          +
          +

          Underscore.string Speed Suite

          + +
          + + diff --git a/Phaser/node_modules/grunt/node_modules/underscore.string/test/test_standalone.html b/Phaser/node_modules/grunt/node_modules/underscore.string/test/test_standalone.html new file mode 100644 index 00000000..9854c171 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/underscore.string/test/test_standalone.html @@ -0,0 +1,18 @@ + + + + Underscore.strings Test Suite + + + + + + + + +

          Underscore.string Test Suite

          +

          +

          +
            + + diff --git a/Phaser/node_modules/grunt/node_modules/underscore.string/test/test_underscore/temp_tests.html b/Phaser/node_modules/grunt/node_modules/underscore.string/test/test_underscore/temp_tests.html new file mode 100644 index 00000000..bd34f9dd --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/underscore.string/test/test_underscore/temp_tests.html @@ -0,0 +1,19 @@ + + + + Underscore Temporary Tests + + + + + + + +

            Underscore Temporary Tests

            +

            + A page for temporary speed tests, used for developing faster implementations + of existing Underscore methods. +

            +
            + + diff --git a/Phaser/node_modules/grunt/node_modules/underscore.string/test/test_underscore/test.html b/Phaser/node_modules/grunt/node_modules/underscore.string/test/test_underscore/test.html new file mode 100644 index 00000000..77f2f3a2 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/underscore.string/test/test_underscore/test.html @@ -0,0 +1,43 @@ + + + + Underscore Test Suite + + + + + + + + + + + + + + + +
            +

            Underscore Test Suite

            +

            +

            +
              +
              +

              Underscore Speed Suite

              +

              + A representative sample of the functions are benchmarked here, to provide + a sense of how fast they might run in different browsers. + Each iteration runs on an array of 1000 elements.

              + For example, the 'intersect' test measures the number of times you can + find the intersection of two thousand-element arrays in one second. +

              +
              + + +
              + + diff --git a/Phaser/node_modules/grunt/node_modules/underscore.string/test/test_underscore/vendor/qunit.css b/Phaser/node_modules/grunt/node_modules/underscore.string/test/test_underscore/vendor/qunit.css new file mode 100644 index 00000000..8d0d3a24 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/underscore.string/test/test_underscore/vendor/qunit.css @@ -0,0 +1,196 @@ +/** Font Family and Sizes */ + +#qunit-tests, #qunit-header, .qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult { + font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial; +} + +#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; } +#qunit-tests { font-size: smaller; } + + +/** Resets */ + +#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult { + margin: 0; + padding: 0; +} + + +/** Header */ + +#qunit-header, .qunit-header { + padding: 0.5em 0 0.5em 1em; + + color: #8699a4; + background-color: #0d3349; + + font-size: 1.5em; + line-height: 1em; + font-weight: normal; + + border-radius: 15px 15px 0 0; + -moz-border-radius: 15px 15px 0 0; + -webkit-border-top-right-radius: 15px; + -webkit-border-top-left-radius: 15px; +} + +#qunit-header a { + text-decoration: none; + color: #c2ccd1; +} + +#qunit-header a:hover, +#qunit-header a:focus { + color: #fff; +} + +#qunit-banner { + height: 5px; +} + +#qunit-testrunner-toolbar { + padding: 0em 0 0.5em 2em; +} + +#qunit-userAgent { + padding: 0.5em 0 0.5em 2.5em; + background-color: #2b81af; + color: #fff; + text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px; +} + + +/** Tests: Pass/Fail */ + +#qunit-tests { + list-style-position: inside; +} + +#qunit-tests li { + padding: 0.4em 0.5em 0.4em 2.5em; + border-bottom: 1px solid #fff; + list-style-position: inside; +} + +#qunit-tests li strong { + cursor: pointer; +} + +#qunit-tests ol { + margin-top: 0.5em; + padding: 0.5em; + + background-color: #fff; + + border-radius: 15px; + -moz-border-radius: 15px; + -webkit-border-radius: 15px; + + box-shadow: inset 0px 2px 13px #999; + -moz-box-shadow: inset 0px 2px 13px #999; + -webkit-box-shadow: inset 0px 2px 13px #999; +} + +#qunit-tests table { + border-collapse: collapse; + margin-top: .2em; +} + +#qunit-tests th { + text-align: right; + vertical-align: top; + padding: 0 .5em 0 0; +} + +#qunit-tests td { + vertical-align: top; +} + +#qunit-tests pre { + margin: 0; + white-space: pre-wrap; + word-wrap: break-word; +} + +#qunit-tests del { + background-color: #e0f2be; + color: #374e0c; + text-decoration: none; +} + +#qunit-tests ins { + background-color: #ffcaca; + color: #500; + text-decoration: none; +} + +/*** Test Counts */ + +#qunit-tests b.counts { color: black; } +#qunit-tests b.passed { color: #5E740B; } +#qunit-tests b.failed { color: #710909; } + +#qunit-tests li li { + margin: 0.5em; + padding: 0.4em 0.5em 0.4em 0.5em; + background-color: #fff; + border-bottom: none; + list-style-position: inside; +} + +/*** Passing Styles */ + +#qunit-tests li li.pass { + color: #5E740B; + background-color: #fff; + border-left: 26px solid #C6E746; +} + +#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; } +#qunit-tests .pass .test-name { color: #366097; } + +#qunit-tests .pass .test-actual, +#qunit-tests .pass .test-expected { color: #999999; } + +#qunit-banner.qunit-pass { background-color: #C6E746; } + +/*** Failing Styles */ + +#qunit-tests li li.fail { + color: #710909; + background-color: #fff; + border-left: 26px solid #EE5757; +} + +#qunit-tests .fail { color: #000000; background-color: #EE5757; } +#qunit-tests .fail .test-name, +#qunit-tests .fail .module-name { color: #000000; } + +#qunit-tests .fail .test-actual { color: #EE5757; } +#qunit-tests .fail .test-expected { color: green; } + +#qunit-banner.qunit-fail, +#qunit-testrunner-toolbar { background-color: #EE5757; } + + +/** Footer */ + +#qunit-testresult { + padding: 0.5em 0.5em 0.5em 2.5em; + + color: #2b81af; + background-color: #D2E0E6; + + border-radius: 0 0 15px 15px; + -moz-border-radius: 0 0 15px 15px; + -webkit-border-bottom-right-radius: 15px; + -webkit-border-bottom-left-radius: 15px; +} + +/** Fixture */ + +#qunit-fixture { + position: absolute; + top: -10000px; + left: -10000px; +} \ No newline at end of file diff --git a/Phaser/node_modules/grunt/node_modules/which/LICENSE b/Phaser/node_modules/grunt/node_modules/which/LICENSE new file mode 100644 index 00000000..05a40109 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/which/LICENSE @@ -0,0 +1,23 @@ +Copyright 2009, 2010, 2011 Isaac Z. Schlueter. +All rights reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Phaser/node_modules/grunt/node_modules/which/README.md b/Phaser/node_modules/grunt/node_modules/which/README.md new file mode 100644 index 00000000..ff1eb531 --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/which/README.md @@ -0,0 +1,5 @@ +The "which" util from npm's guts. + +Finds the first instance of a specified executable in the PATH +environment variable. Does not cache the results, so `hash -r` is not +needed when the PATH changes. diff --git a/Phaser/node_modules/grunt/node_modules/which/package.json b/Phaser/node_modules/grunt/node_modules/which/package.json new file mode 100644 index 00000000..4854ed2b --- /dev/null +++ b/Phaser/node_modules/grunt/node_modules/which/package.json @@ -0,0 +1,31 @@ +{ + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me" + }, + "name": "which", + "description": "Like which(1) unix command. Find the first instance of an executable in the PATH.", + "version": "1.0.5", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/node-which.git" + }, + "main": "which.js", + "bin": { + "which": "./bin/which" + }, + "engines": { + "node": "*" + }, + "dependencies": {}, + "devDependencies": {}, + "readme": "The \"which\" util from npm's guts.\n\nFinds the first instance of a specified executable in the PATH\nenvironment variable. Does not cache the results, so `hash -r` is not\nneeded when the PATH changes.\n", + "readmeFilename": "README.md", + "_id": "which@1.0.5", + "dist": { + "shasum": "195619a6ad7e8fefd0aa76445a6d4c8d370a322c" + }, + "_from": "which@~1.0.5", + "_resolved": "https://registry.npmjs.org/which/-/which-1.0.5.tgz" +} diff --git a/Phaser/node_modules/grunt/package.json b/Phaser/node_modules/grunt/package.json new file mode 100644 index 00000000..e59635f1 --- /dev/null +++ b/Phaser/node_modules/grunt/package.json @@ -0,0 +1,100 @@ +{ + "name": "grunt", + "description": "The JavaScript Task Runner", + "version": "0.4.1", + "author": { + "name": "\"Cowboy\" Ben Alman", + "url": "http://benalman.com/" + }, + "homepage": "http://gruntjs.com/", + "repository": { + "type": "git", + "url": "git://github.com/gruntjs/grunt.git" + }, + "bugs": { + "url": "http://github.com/gruntjs/grunt/issues" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT" + } + ], + "main": "lib/grunt", + "scripts": { + "test": "grunt test" + }, + "engines": { + "node": ">= 0.8.0" + }, + "keywords": [ + "task", + "async", + "cli", + "minify", + "uglify", + "build", + "lodash", + "unit", + "test", + "qunit", + "nodeunit", + "server", + "init", + "scaffold", + "make", + "jake", + "tool" + ], + "dependencies": { + "async": "~0.1.22", + "coffee-script": "~1.3.3", + "colors": "~0.6.0-1", + "dateformat": "1.0.2-1.2.3", + "eventemitter2": "~0.4.9", + "findup-sync": "~0.1.0", + "glob": "~3.1.21", + "hooker": "~0.2.3", + "iconv-lite": "~0.2.5", + "minimatch": "~0.2.6", + "nopt": "~1.0.10", + "rimraf": "~2.0.2", + "lodash": "~0.9.0", + "underscore.string": "~2.2.0rc", + "which": "~1.0.5", + "js-yaml": "~2.0.2" + }, + "devDependencies": { + "temporary": "~0.0.4", + "grunt-contrib-jshint": "~0.1.1", + "grunt-contrib-nodeunit": "~0.1.2", + "grunt-contrib-watch": "~0.2.0", + "difflet": "~0.2.3" + }, + "contributors": [ + { + "name": "\"Cowboy\" Ben Alman", + "url": "http://benalman.com/" + }, + { + "name": "Kyle Robinson Young", + "url": "http://dontkry.com/" + }, + { + "name": "Tyler Kellen", + "url": "http://goingslowly.com" + }, + { + "name": "Sindre Sorhus", + "url": "http://sindresorhus.com" + } + ], + "readme": "# Grunt: The JavaScript Task Runner [![Build Status](https://secure.travis-ci.org/gruntjs/grunt.png?branch=master)](http://travis-ci.org/gruntjs/grunt)\n\n### Documentation\n\nVisit the [gruntjs.com](http://gruntjs.com/) website for all the things.\n\n### Support / Contributing\nBefore you make an issue, please read our [Contributing](http://gruntjs.com/contributing) guide.\n\nYou can find the grunt team in [#grunt on irc.freenode.net](irc://irc.freenode.net/#grunt).\n\n### Release History\nSee the [CHANGELOG](CHANGELOG).\n", + "readmeFilename": "README.md", + "_id": "grunt@0.4.1", + "dist": { + "shasum": "e8de3620333cbd39d1156a1d21d11d6c03b2f500" + }, + "_from": "grunt@", + "_resolved": "https://registry.npmjs.org/grunt/-/grunt-0.4.1.tgz" +} diff --git a/Phaser/node_modules/grunt/test/fixtures/BOM.txt b/Phaser/node_modules/grunt/test/fixtures/BOM.txt new file mode 100644 index 00000000..e1fde783 --- /dev/null +++ b/Phaser/node_modules/grunt/test/fixtures/BOM.txt @@ -0,0 +1 @@ +foo \ No newline at end of file diff --git a/Phaser/node_modules/grunt/test/fixtures/exec.cmd b/Phaser/node_modules/grunt/test/fixtures/exec.cmd new file mode 100755 index 00000000..6e4a52bb --- /dev/null +++ b/Phaser/node_modules/grunt/test/fixtures/exec.cmd @@ -0,0 +1 @@ +@echo done diff --git a/Phaser/node_modules/grunt/test/fixtures/exec.sh b/Phaser/node_modules/grunt/test/fixtures/exec.sh new file mode 100755 index 00000000..88907997 --- /dev/null +++ b/Phaser/node_modules/grunt/test/fixtures/exec.sh @@ -0,0 +1,2 @@ +#!/bin/bash +echo "done" diff --git a/Phaser/node_modules/grunt/test/fixtures/expand-mapping-ext/dir.ectory/file-no-extension b/Phaser/node_modules/grunt/test/fixtures/expand-mapping-ext/dir.ectory/file-no-extension new file mode 100644 index 00000000..e69de29b diff --git a/Phaser/node_modules/grunt/test/fixtures/expand-mapping-ext/dir.ectory/sub.dir.ectory/file.ext.ension b/Phaser/node_modules/grunt/test/fixtures/expand-mapping-ext/dir.ectory/sub.dir.ectory/file.ext.ension new file mode 100644 index 00000000..e69de29b diff --git a/Phaser/node_modules/grunt/test/fixtures/expand-mapping-ext/file.ext.ension b/Phaser/node_modules/grunt/test/fixtures/expand-mapping-ext/file.ext.ension new file mode 100644 index 00000000..e69de29b diff --git a/Phaser/node_modules/grunt/test/fixtures/expand/README.md b/Phaser/node_modules/grunt/test/fixtures/expand/README.md new file mode 100644 index 00000000..e69de29b diff --git a/Phaser/node_modules/grunt/test/fixtures/expand/css/baz.css b/Phaser/node_modules/grunt/test/fixtures/expand/css/baz.css new file mode 100644 index 00000000..e69de29b diff --git a/Phaser/node_modules/grunt/test/fixtures/expand/css/qux.css b/Phaser/node_modules/grunt/test/fixtures/expand/css/qux.css new file mode 100644 index 00000000..e69de29b diff --git a/Phaser/node_modules/grunt/test/fixtures/expand/deep/deep.txt b/Phaser/node_modules/grunt/test/fixtures/expand/deep/deep.txt new file mode 100644 index 00000000..e69de29b diff --git a/Phaser/node_modules/grunt/test/fixtures/expand/deep/deeper/deeper.txt b/Phaser/node_modules/grunt/test/fixtures/expand/deep/deeper/deeper.txt new file mode 100644 index 00000000..e69de29b diff --git a/Phaser/node_modules/grunt/test/fixtures/expand/deep/deeper/deepest/deepest.txt b/Phaser/node_modules/grunt/test/fixtures/expand/deep/deeper/deepest/deepest.txt new file mode 100644 index 00000000..e69de29b diff --git a/Phaser/node_modules/grunt/test/fixtures/iso-8859-1.json b/Phaser/node_modules/grunt/test/fixtures/iso-8859-1.json new file mode 100644 index 00000000..31e1dc34 --- /dev/null +++ b/Phaser/node_modules/grunt/test/fixtures/iso-8859-1.json @@ -0,0 +1,4 @@ +{ + "foo": "Ação é isso aí", + "bar": ["ømg", "pønies"] +} diff --git a/Phaser/node_modules/grunt/test/fixtures/iso-8859-1.txt b/Phaser/node_modules/grunt/test/fixtures/iso-8859-1.txt new file mode 100644 index 00000000..c4a16844 --- /dev/null +++ b/Phaser/node_modules/grunt/test/fixtures/iso-8859-1.txt @@ -0,0 +1 @@ +Ação é isso aí diff --git a/Phaser/node_modules/grunt/test/fixtures/iso-8859-1.yaml b/Phaser/node_modules/grunt/test/fixtures/iso-8859-1.yaml new file mode 100644 index 00000000..b869cc12 --- /dev/null +++ b/Phaser/node_modules/grunt/test/fixtures/iso-8859-1.yaml @@ -0,0 +1,4 @@ +foo: Ação é isso aí +bar: + - ømg + - pønies diff --git a/Phaser/node_modules/grunt/test/fixtures/lint.txt b/Phaser/node_modules/grunt/test/fixtures/lint.txt new file mode 100644 index 00000000..62b11566 Binary files /dev/null and b/Phaser/node_modules/grunt/test/fixtures/lint.txt differ diff --git a/Phaser/node_modules/grunt/test/fixtures/no_BOM.txt b/Phaser/node_modules/grunt/test/fixtures/no_BOM.txt new file mode 100644 index 00000000..19102815 --- /dev/null +++ b/Phaser/node_modules/grunt/test/fixtures/no_BOM.txt @@ -0,0 +1 @@ +foo \ No newline at end of file diff --git a/Phaser/node_modules/grunt/test/fixtures/octocat.png b/Phaser/node_modules/grunt/test/fixtures/octocat.png new file mode 100644 index 00000000..0b68cf0d Binary files /dev/null and b/Phaser/node_modules/grunt/test/fixtures/octocat.png differ diff --git a/Phaser/node_modules/grunt/test/fixtures/template.txt b/Phaser/node_modules/grunt/test/fixtures/template.txt new file mode 100644 index 00000000..99342d67 --- /dev/null +++ b/Phaser/node_modules/grunt/test/fixtures/template.txt @@ -0,0 +1 @@ +Version: <%= grunt.version %>, today: <%= grunt.template.today("yyyy-mm-dd") %>. \ No newline at end of file diff --git a/Phaser/node_modules/grunt/test/fixtures/test.json b/Phaser/node_modules/grunt/test/fixtures/test.json new file mode 100644 index 00000000..098e7b84 --- /dev/null +++ b/Phaser/node_modules/grunt/test/fixtures/test.json @@ -0,0 +1,4 @@ +{ + "foo": "bar", + "baz": [1, 2, 3] +} diff --git a/Phaser/node_modules/grunt/test/fixtures/utf8.json b/Phaser/node_modules/grunt/test/fixtures/utf8.json new file mode 100644 index 00000000..d10e9753 --- /dev/null +++ b/Phaser/node_modules/grunt/test/fixtures/utf8.json @@ -0,0 +1,4 @@ +{ + "foo": "Ação é isso aí", + "bar": ["ømg", "pønies"] +} diff --git a/Phaser/node_modules/grunt/test/fixtures/utf8.txt b/Phaser/node_modules/grunt/test/fixtures/utf8.txt new file mode 100644 index 00000000..eadbdb40 --- /dev/null +++ b/Phaser/node_modules/grunt/test/fixtures/utf8.txt @@ -0,0 +1 @@ +Ação é isso aí diff --git a/Phaser/node_modules/grunt/test/fixtures/utf8.yaml b/Phaser/node_modules/grunt/test/fixtures/utf8.yaml new file mode 100644 index 00000000..7eb7321c --- /dev/null +++ b/Phaser/node_modules/grunt/test/fixtures/utf8.yaml @@ -0,0 +1,4 @@ +foo: Ação é isso aí +bar: + - ømg + - pønies diff --git a/Phaser/phaser.js b/Phaser/phaser.js index 2d2a57e4..b2d7ffdb 100644 --- a/Phaser/phaser.js +++ b/Phaser/phaser.js @@ -1,7 +1,7 @@ /** * Phaser * -* v0.9.3 - April 24th 2013 +* v0.9.4 - April 24th 2013 * * A small and feature-packed 2D canvas game framework born from the firey pits of Flixel and Kiwi. * @@ -15,5 +15,5 @@ */ var Phaser; (function (Phaser) { - Phaser.VERSION = 'Phaser version 0.9.3'; + Phaser.VERSION = 'Phaser version 0.9.4'; })(Phaser || (Phaser = {})); diff --git a/Phaser/system/Camera.ts b/Phaser/system/Camera.ts index e05e3e71..d43a3ac4 100644 --- a/Phaser/system/Camera.ts +++ b/Phaser/system/Camera.ts @@ -269,23 +269,21 @@ module Phaser { /** * Specify the boundaries of the world or where the camera is allowed to move. * - * @param X The smallest X value of your world (usually 0). - * @param Y The smallest Y value of your world (usually 0). - * @param Width The largest X value of your world (usually the world width). - * @param Height The largest Y value of your world (usually the world height). - * @param UpdateWorld Whether the global quad-tree's dimensions should be updated to match (default: false). + * @param x The smallest X value of your world (usually 0). + * @param y The smallest Y value of your world (usually 0). + * @param width The largest X value of your world (usually the world width). + * @param height The largest Y value of your world (usually the world height). */ - public setBounds(X: number = 0, Y: number = 0, Width: number = 0, Height: number = 0, UpdateWorld: bool = false) { + public setBounds(x: number = 0, y: number = 0, width: number = 0, height: number = 0) { if (this.bounds == null) { this.bounds = new Rectangle(); } - this.bounds.setTo(X, Y, Width, Height); - - //if(UpdateWorld) - // G.worldBounds.copyFrom(bounds); + this.bounds.setTo(x, y, width, height); + this.worldView.setTo(x, y, width, height); + this.scroll.setTo(0, 0); this.update(); } @@ -345,7 +343,7 @@ module Phaser { if (this.scroll.x > this.bounds.right - this.width) { - this.scroll.x = this.bounds.right - this.width; + this.scroll.x = (this.bounds.right - this.width) + 1; } if (this.scroll.y < this.bounds.top) @@ -355,7 +353,7 @@ module Phaser { if (this.scroll.y > this.bounds.bottom - this.height) { - this.scroll.y = this.bounds.bottom - this.height; + this.scroll.y = (this.bounds.bottom - this.height) + 1; } } diff --git a/Phaser/system/QuadTree.ts b/Phaser/system/QuadTree.ts index e157fb8c..0e799c58 100644 --- a/Phaser/system/QuadTree.ts +++ b/Phaser/system/QuadTree.ts @@ -704,8 +704,6 @@ module Phaser { */ private overlapNode(): bool { - //console.log('overlapNode'); - //Walk the list and check for overlaps var overlapProcessed: bool = false; var checkObject; diff --git a/Phaser/system/Tile.ts b/Phaser/system/Tile.ts index 5505a6db..ec0c7f87 100644 --- a/Phaser/system/Tile.ts +++ b/Phaser/system/Tile.ts @@ -3,55 +3,35 @@ /** * Phaser - Tile * -* A simple helper object for Tilemap that helps expand collision opportunities and control. +* A Tile is a single representation of a tile within a Tilemap */ module Phaser { - export class Tile extends GameObject { + export class Tile { - /** - * Instantiate this new tile object. This is usually called from Tilemap.loadMap(). - * - * @param Tilemap A reference to the tilemap object creating the tile. - * @param Index The actual core map data index for this tile type. - * @param Width The width of the tile. - * @param Height The height of the tile. - * @param Visible Whether the tile is visible or not. - * @param AllowCollisions The collision flags for the object. By default this value is ANY or NONE depending on the parameters sent to loadMap(). - */ - constructor(game: Game, Tilemap: Tilemap, Index: number, Width: number, Height: number, Visible: bool, AllowCollisions: number) { + constructor(game: Game, tilemap: Tilemap, index: number, width: number, height: number) { - super(game, 0, 0, Width, Height); + this._game = game; + this.tilemap = tilemap; + this.index = index; - this.immovable = true; - this.moves = false; - this.callback = null; - this.filter = null; - - this.tilemap = Tilemap; - this.index = Index; - this.visible = Visible; - this.allowCollisions = AllowCollisions; - - this.mapIndex = 0; + this.width = width; + this.height = height; + this.allowCollisions = Collision.NONE; } - /** - * This function is called whenever an object hits a tile of this type. - * This function should take the form myFunction(Tile:Tile,Object:Object). - * Defaults to null, set through Tilemap.setTileProperties(). - */ - public callback; + private _game: Game; - /** - * Each tile can store its own filter class for their callback functions. - * That is, the callback will only be triggered if an object with a class - * type matching the filter touched it. - * Defaults to null, set through Tilemap.setTileProperties(). - */ - public filter; + // You can give this Tile a friendly name to help with debugging. Never used internally. + public name: string; + + public width: number; + + public height: number; + + public allowCollisions: number; /** * A reference to the tilemap this tile object belongs to. @@ -65,24 +45,26 @@ module Phaser { */ public index: number; - /** - * The current map index of this tile object at this moment. - * You can think of tile objects as moving around the tilemap helping with collisions. - * This value is only reliable and useful if used from the callback function. - */ - public mapIndex: number; - /** * Clean up memory. */ public destroy() { - super.destroy(); - this.callback = null; this.tilemap = null; } + /** + * Returns a string representation of this object. + * @method toString + * @return {string} a string representation of the object. + **/ + public toString(): string { + + return "[{Tiled (index=" + this.index + " collisions=" + this.allowCollisions + " width=" + this.width + " height=" + this.height + ")}]"; + + } + } } \ No newline at end of file diff --git a/Phaser/system/TilemapLayer.ts b/Phaser/system/TilemapLayer.ts index 4309d028..aa6d7453 100644 --- a/Phaser/system/TilemapLayer.ts +++ b/Phaser/system/TilemapLayer.ts @@ -10,9 +10,10 @@ module Phaser { export class TilemapLayer { - constructor(game: Game, key: string, mapFormat: number, name: string, tileWidth: number, tileHeight: number) { + constructor(game: Game, parent:Tilemap, key: string, mapFormat: number, name: string, tileWidth: number, tileHeight: number) { this._game = game; + this._parent = parent; this.name = name; this.mapFormat = mapFormat; @@ -24,11 +25,10 @@ module Phaser { this.mapData = []; this._texture = this._game.cache.getImage(key); - this.parseTileOffsets(); - } private _game: Game; + private _parent: Tilemap; private _texture; private _tileOffsets; private _startX: number = 0; @@ -45,6 +45,7 @@ module Phaser { public name: string; public alpha: number = 1; + public exists: bool = true; public visible: bool = true; //public scrollFactor: MicroPoint; public orientation: string; @@ -63,6 +64,119 @@ module Phaser { public widthInPixels: number = 0; public heightInPixels: number = 0; + public tileMargin: number = 0; + public tileSpacing: number = 0; + + public getTileFromWorldXY(x: number, y: number): number { + + x = this._game.math.snapToFloor(x, this.tileWidth) / this.tileWidth; + y = this._game.math.snapToFloor(y, this.tileHeight) / this.tileHeight; + + return this.getTileIndex(x, y); + + } + + public getTileOverlaps(object: GameObject) { + + //var result: bool = false; + //var x: number = object.x; + //var y: number = object.y; + + // What tiles do we need to check against? + var mapX:number = this._game.math.snapToFloor(object.bounds.x, this.tileWidth); + var mapY:number = this._game.math.snapToFloor(object.bounds.y, this.tileHeight); + var mapW:number = this._game.math.snapToCeil(object.bounds.width, this.tileWidth) + this.tileWidth; + var mapH:number = this._game.math.snapToCeil(object.bounds.height, this.tileHeight) + this.tileHeight; + + var tileX = mapX / this.tileWidth; + var tileY = mapY / this.tileHeight; + var tileW = mapW / this.tileWidth; + var tileH = mapH / this.tileHeight; + + if (tileX < 0) + { + tileX = 0; + } + + if (tileY < 0) + { + tileY = 0; + } + + if (tileW > this.widthInTiles) + { + tileW = this.widthInTiles; + } + + if (tileH > this.heightInTiles) + { + tileH = this.heightInTiles; + } + + // Loop through the tiles we've got and check overlaps accordingly + var tiles = this.getTileBlock(tileX, tileY, tileW, tileH); + + var result = []; + var tempBounds = new Quad(); + + for (var r = 0; r < tiles.length; r++) + { + if (tiles[r].tile.allowCollisions != Collision.NONE) + { + tempBounds.setTo(tiles[r].x * this.tileWidth, tiles[r].y * this.tileHeight, this.tileWidth, this.tileHeight); + + if (tempBounds.intersects(object.bounds)) + { + result.push(Collision.separateTile(object, { x: tempBounds.x, y: tempBounds.y, width: tempBounds.width, height: tempBounds.height, mass: 1.0, immovable: true, allowCollisions: Collision.ANY })); + } + else + { + result.push(false); + } + } + else + { + result.push(false); + } + } + + //return { x: mapX, y: mapY, w: mapW, h: mapH, collision: result }; + return { x: tileX, y: tileY, w: tileW, h: tileH, collision: result }; + + } + + //public checkTileOverlap(object:GameObject, + + public getTileBlock(x: number, y: number, width: number, height: number) { + + var output = []; + + for (var ty = y; ty < y + height; ty++) + { + for (var tx = x; tx < x + width; tx++) + { + output.push({ x: tx, y: ty, tile: this._parent.tiles[this.mapData[ty][tx]] }); + } + } + + return output; + + } + + public getTileIndex(x: number, y: number): number { + + if (y >= 0 && y < this.mapData.length) + { + if (x >= 0 && x < this.mapData[y].length) + { + return this.mapData[y][x]; + } + } + + return null; + + } + public addColumn(column) { var data = []; @@ -89,9 +203,11 @@ module Phaser { this.boundsInTiles.setTo(0, 0, this.widthInTiles, this.heightInTiles); + console.log('layer bounds', this.boundsInTiles); + } - private parseTileOffsets() { + public parseTileOffsets():number { this._tileOffsets = []; @@ -104,15 +220,17 @@ module Phaser { i = 1; } - for (var ty = 0; ty < this._texture.height; ty += this.tileHeight) + for (var ty = this.tileMargin; ty < this._texture.height; ty += (this.tileHeight + this.tileSpacing)) { - for (var tx = 0; tx < this._texture.width; tx += this.tileWidth) + for (var tx = this.tileMargin; tx < this._texture.width; tx += (this.tileWidth + this.tileSpacing)) { this._tileOffsets[i] = { x: tx, y: ty }; i++; } } + return this._tileOffsets.length; + } public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') { @@ -151,6 +269,16 @@ module Phaser { this._startY = 0; } + if (this._maxX > this.widthInTiles) + { + this._maxX = this.widthInTiles; + } + + if (this._maxY > this.heightInTiles) + { + this._maxY = this.heightInTiles; + } + if (this._startX + this._maxX > this.widthInTiles) { this._startX = this.widthInTiles - this._maxX; diff --git a/Phaser/system/input/Input.ts b/Phaser/system/input/Input.ts index f27c4719..bde9380c 100644 --- a/Phaser/system/input/Input.ts +++ b/Phaser/system/input/Input.ts @@ -77,6 +77,7 @@ module Phaser { public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') { + this._game.stage.context.font = '14px Courier'; this._game.stage.context.fillStyle = color; this._game.stage.context.fillText('Input', x, y); this._game.stage.context.fillText('Screen X: ' + this.x + ' Screen Y: ' + this.y, x, y + 14); diff --git a/Phaser/system/input/Keyboard.ts b/Phaser/system/input/Keyboard.ts index 332806f4..e3415304 100644 --- a/Phaser/system/input/Keyboard.ts +++ b/Phaser/system/input/Keyboard.ts @@ -32,11 +32,11 @@ module Phaser { public addKeyCapture(keycode) { - if (typeof keycode == 'array') + if (typeof keycode === 'object') { - for (var code in keycode) + for (var i:number = 0; i < keycode.length; i++) { - this._capture[code] = true; + this._capture[keycode[i]] = true; } } else diff --git a/README.md b/README.md index cac21f39..80fe561c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ Phaser ====== -Version 0.9.3 - -24th April 2013 +Version: 0.9.4 Released: XX April 2013 By Richard Davey, [Photon Storm](http://www.photonstorm.com) @@ -20,23 +18,13 @@ Try out the [Phaser Test Suite](http://gametest.mobi/phaser/) Latest Update ------------- -V0.9.3 +V0.9.4 + +* Fixed Tilemap bounds check if map was smaller than game dimensions +* Added Tilemap.getTile, getTileFromWorldXY, getTileFromInputXY +* Added Tilemap.setCollisionByIndex and setCollisionByRange +* Added GameObject.renderRotation boolean to control if the sprite will visually rotate or not (useful when angle needs to change but graphics don't) -* Added the new ScrollZone game object. Endlessly useful but especially for scrolling backdrops. Created 6 example tests. -* Added GameObject.hideFromCamera(cameraID) to stop an object rendering to specific cameras (also showToCamera and clearCameraList) -* Added GameObject.setBounds() to confine a game object to a specific area within the world (useful for stopping them going off the edges) -* Added GameObject.outOfBoundsAction, can be either OUT OF BOUNDS STOP which stops the object moving, or OUT OF BOUNDS KILL which kills it. -* Added GameObject.rotationOffset. Useful if your graphics need to rotate but weren't drawn facing zero degrees (to the right). -* Added shiftSinTable and shiftCosTable to the GameMath class to allow for quick iteration through the data tables. -* Added more robust frame checking into AnimationManager -* Re-built Tilemap handling from scratch to allow for proper layered maps (as exported from Tiled / Mappy) -* Tilemap no longer requires a buffer per Camera (in prep for WebGL support) -* Fixed issues with Group not adding reference to Game to newly created objects (thanks JesseFreeman) -* Fixed a potential race condition issue in Game.boot (thanks Hackmaniac) -* Fixed issue with showing frame zero of a texture atlas before the animation started playing (thanks JesseFreeman) -* Fixed a bug where Camera.visible = false would still render -* Removed the need for DynamicTextures to require a key property and updated test cases. -* You can now pass an array or a single value to Input.Keyboard.addKeyCapture(). Requirements ------------ @@ -171,6 +159,24 @@ Please add them to the [Issue Tracker][1] with as much info as possible. Change Log ---------- +V0.9.3 + +* Added the new ScrollZone game object. Endlessly useful but especially for scrolling backdrops. Created 6 example tests. +* Added GameObject.hideFromCamera(cameraID) to stop an object rendering to specific cameras (also showToCamera and clearCameraList) +* Added GameObject.setBounds() to confine a game object to a specific area within the world (useful for stopping them going off the edges) +* Added GameObject.outOfBoundsAction, can be either OUT OF BOUNDS STOP which stops the object moving, or OUT OF BOUNDS KILL which kills it. +* Added GameObject.rotationOffset. Useful if your graphics need to rotate but weren't drawn facing zero degrees (to the right). +* Added shiftSinTable and shiftCosTable to the GameMath class to allow for quick iteration through the data tables. +* Added more robust frame checking into AnimationManager +* Re-built Tilemap handling from scratch to allow for proper layered maps (as exported from Tiled / Mappy) +* Tilemap no longer requires a buffer per Camera (in prep for WebGL support) +* Fixed issues with Group not adding reference to Game to newly created objects (thanks JesseFreeman) +* Fixed a potential race condition issue in Game.boot (thanks Hackmaniac) +* Fixed issue with showing frame zero of a texture atlas before the animation started playing (thanks JesseFreeman) +* Fixed a bug where Camera.visible = false would still render +* Removed the need for DynamicTextures to require a key property and updated test cases. +* You can now pass an array or a single value to Input.Keyboard.addKeyCapture(). + V0.9.2 * Fixed issue with create not being called if there was an empty init method. diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index fdceaa9e..700bd89b 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -133,6 +133,14 @@ flipped.ts + + + + collision.ts + + + get tile.ts + small map.ts diff --git a/Tests/assets/maps/desert.json b/Tests/assets/maps/desert.json new file mode 100644 index 00000000..f13fc5e6 --- /dev/null +++ b/Tests/assets/maps/desert.json @@ -0,0 +1,39 @@ +{ "height":40, + "layers":[ + { + "data":[30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 14, 15, 16, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 46, 30, 30, 30, 30, 30, 30, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 46, 14, 15, 16, 30, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 14, 15, 16, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 30, 30, 30, 30, 30, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, 22, 23, 24, 30, 30, 30, 30, 30, 30, 30, 30, 32, 30, 30, 32, 30, 30, 30, 30, 30, 30, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 1, 3, 30, 30, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 30, 9, 11, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 30, 9, 11, 30, 30, 30, 30, 6, 7, 7, 7, 8, 30, 46, 30, 30, 30, 30, 30, 30, 30, 30, 40, 30, 30, 30, 30, 33, 34, 36, 42, 37, 34, 34, 34, 34, 34, 34, 34, 35, 30, 9, 11, 30, 30, 30, 30, 14, 15, 15, 15, 16, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 33, 34, 35, 30, 33, 34, 34, 34, 34, 34, 34, 34, 35, 30, 9, 11, 30, 30, 30, 30, 14, 15, 15, 15, 12, 8, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 38, 30, 30, 33, 34, 35, 31, 33, 34, 34, 34, 34, 34, 34, 34, 35, 30, 9, 11, 30, 30, 30, 30, 22, 23, 5, 15, 15, 16, 30, 30, 30, 30, 30, 30, 30, 30, 48, 38, 30, 30, 30, 30, 33, 34, 44, 26, 45, 34, 34, 34, 34, 34, 34, 34, 35, 30, 9, 11, 30, 30, 30, 30, 30, 30, 14, 15, 15, 16, 30, 30, 30, 30, 30, 30, 40, 30, 30, 30, 40, 30, 30, 30, 33, 34, 34, 34, 34, 34, 34, 34, 36, 42, 37, 34, 35, 30, 9, 11, 30, 30, 30, 30, 30, 31, 22, 23, 23, 24, 30, 30, 30, 40, 30, 30, 30, 30, 40, 38, 30, 30, 38, 30, 41, 42, 42, 42, 42, 37, 34, 34, 44, 26, 45, 34, 35, 30, 9, 11, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 39, 30, 30, 30, 38, 30, 40, 30, 30, 30, 30, 30, 30, 30, 30, 41, 42, 42, 42, 42, 42, 42, 43, 30, 9, 11, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 39, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 9, 11, 30, 30, 30, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 7, 7, 8, 1, 2, 2, 2, 2, 2, 3, 30, 30, 30, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 29, 11, 30, 30, 30, 30, 31, 30, 31, 30, 30, 30, 30, 30, 30, 15, 15, 16, 9, 10, 10, 10, 10, 10, 11, 30, 30, 30, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 30, 30, 30, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 23, 23, 24, 17, 18, 18, 18, 18, 18, 19, 30, 30, 30, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 30, 30, 30, 30, 30, 30, 32, 30, 30, 30, 30, 30, 30, 30, 30, 39, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 30, 30, 30, 30, 30, 30, 30, 30, 32, 31, 30, 30, 30, 30, 39, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 39, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 30, 30, 30, 30, 30, 30, 30, 30, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 46, 30, 33, 34, 34, 34, 34, 34, 34, 34, 34, 36, 42, 37, 35, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 33, 34, 34, 34, 34, 34, 34, 34, 34, 35, 48, 33, 35, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 30, 30, 30, 30, 30, 30, 30, 47, 33, 34, 34, 34, 34, 34, 34, 34, 34, 35, 48, 33, 35, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 39, 30, 30, 30, 33, 34, 34, 34, 34, 34, 34, 34, 34, 35, 48, 33, 35, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 33, 34, 34, 34, 34, 34, 34, 34, 34, 44, 26, 45, 35, 30, 30, 30, 30, 30, 30, 39, 30, 39, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 47, 30, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 48, 30, 30, 30, 30, 30, 39, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43, 30, 30, 30, 38, 30, 38, 30, 30, 30, 30, 32, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 38, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 40, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 30, 30, 30, 30, 30, 30, 38, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 40, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 40, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 30, 30, 30, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 6, 7, 7, 7, 7, 8, 30, 30, 30, 30, 30, 30, 30, 40, 30, 40, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 30, 30, 26, 26, 26, 26, 26, 26, 26, 45, 34, 34, 34, 34, 44, 27, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 30, 30, 30, 30, 40, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 30, 30, 30, 32, 30, 30, 30, 30, 30, 30, 30, 30, 32, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], + "height":40, + "name":"Ground", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":40, + "x":0, + "y":0 + }], + "orientation":"orthogonal", + "properties": + { + + }, + "tileheight":32, + "tilesets":[ + { + "firstgid":1, + "image":"C:\/Program Files (x86)\/Tiled\/examples\/tmw_desert_spacing.png", + "imageheight":199, + "imagewidth":265, + "margin":1, + "name":"Desert", + "properties": + { + + }, + "spacing":1, + "tileheight":32, + "tilewidth":32 + }], + "tilewidth":32, + "version":1, + "width":40 +} \ No newline at end of file diff --git a/Tests/assets/maps/desert2.json b/Tests/assets/maps/desert2.json new file mode 100644 index 00000000..55664747 --- /dev/null +++ b/Tests/assets/maps/desert2.json @@ -0,0 +1,54 @@ +{ "height":40, + "layers":[ + { + "data":[30, 49, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 14, 15, 16, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 46, 14, 15, 16, 30, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 14, 15, 16, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, 22, 23, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 1, 2, 3, 30, 30, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 9, 10, 11, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 9, 10, 11, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 40, 30, 30, 30, 30, 33, 34, 36, 42, 37, 34, 34, 34, 34, 34, 34, 34, 35, 9, 10, 11, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 33, 34, 35, 30, 33, 34, 34, 34, 34, 34, 34, 34, 35, 9, 10, 11, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 38, 30, 30, 33, 34, 35, 30, 33, 34, 34, 34, 34, 34, 34, 34, 35, 9, 10, 11, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 48, 38, 30, 30, 30, 30, 33, 34, 44, 26, 45, 34, 34, 34, 34, 34, 34, 34, 35, 9, 10, 11, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 40, 30, 30, 30, 40, 30, 30, 30, 33, 34, 34, 34, 34, 34, 34, 34, 36, 42, 37, 34, 35, 9, 10, 11, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 40, 30, 30, 30, 30, 40, 38, 30, 30, 38, 30, 33, 34, 34, 34, 34, 34, 34, 34, 44, 26, 45, 34, 35, 9, 10, 11, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 39, 30, 30, 30, 38, 30, 40, 30, 30, 30, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 9, 10, 11, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 39, 30, 30, 30, 30, 30, 30, 30, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43, 9, 10, 11, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 7, 7, 8, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 29, 10, 11, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 15, 15, 16, 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 23, 23, 24, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 39, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 31, 30, 30, 30, 30, 39, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 39, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 46, 30, 33, 34, 34, 34, 34, 34, 34, 34, 34, 36, 42, 37, 35, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 33, 34, 34, 34, 34, 34, 34, 34, 34, 35, 48, 33, 35, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 47, 33, 34, 34, 34, 34, 34, 34, 34, 34, 35, 48, 33, 35, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 39, 30, 30, 30, 33, 34, 34, 34, 34, 34, 34, 34, 34, 35, 48, 33, 35, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 33, 34, 34, 34, 34, 34, 34, 34, 34, 44, 26, 45, 35, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 47, 30, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 48, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 30, 30, 30, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], + "height":40, + "name":"Ground", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":40, + "x":0, + "y":0 + }], + "orientation":"orthogonal", + "properties": + { + + }, + "tileheight":32, + "tilesets":[ + { + "firstgid":1, + "image":"C:\/Program Files (x86)\/Tiled\/examples\/tmw_desert_spacing.png", + "imageheight":199, + "imagewidth":265, + "margin":1, + "name":"Desert", + "properties": + { + + }, + "spacing":1, + "tileheight":32, + "tilewidth":32 + }, + { + "firstgid":49, + "image":"..\/..\/..\/..\/kiwi-lite\/Test Suite\/assets\/tiles\/catastrophi_tiles_16.png", + "imageheight":80, + "imagewidth":448, + "margin":0, + "name":"catastrophi_tiles_16", + "properties": + { + + }, + "spacing":0, + "tileheight":16, + "tilewidth":16 + }], + "tilewidth":32, + "version":1, + "width":40 +} \ No newline at end of file diff --git a/Tests/assets/maps/platform-test-1.json b/Tests/assets/maps/platform-test-1.json new file mode 100644 index 00000000..eeb0528a --- /dev/null +++ b/Tests/assets/maps/platform-test-1.json @@ -0,0 +1,39 @@ +{ "height":40, + "layers":[ + { + "data":[21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 105, 106, 106, 107, 108, 18, 0, 0, 0, 0, 0, 0, 0, 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 17, 105, 106, 106, 107, 108, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 21, 21, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 105, 106, 106, 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 15, 1, 1, 0, 0, 0, 0, 0, 0, 17, 105, 106, 106, 107, 108, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 17, 105, 106, 106, 107, 108, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 108, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 105, 106, 106, 107, 108, 18, 0, 0, 0, 0, 0, 17, 105, 106, 106, 107, 108, 18, 0, 0, 0, 0, 0, 0, 17, 105, 106, 106, 107, 108, 18, 0, 0, 0, 0, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 0, 0, 17, 105, 106, 106, 107, 108, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 105, 106, 106, 107, 108, 18, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 105, 106, 106, 107, 108, 18, 0, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 105, 106, 106, 107, 108, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 45, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 50, 45, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 50, 45, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 21, 21, 16, 1, 1, 1, 1, 16, 1, 1, 1, 45, 48, 45, 45, 1, 1, 1, 1, 1, 1, 1, 14, 16, 1, 1, 1, 16, 1, 1, 1, 1, 16, 1, 1, 1, 45, 48, 45, 45, 1, 1, 1, 1, 1, 1, 1, 14, 16, 1, 21, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 3, 1, 1, 1, 2, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 3, 1, 1, 1, 2, 41, 41, 41, 41, 41, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 59, 59, 59, 59, 59, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 59, 59, 59, 59, 59, 60, 60, 60, 60, 60, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 78, 78, 78, 78, 78, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 78, 78, 78, 78, 78, 79, 79, 79, 79, 79, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78], + "height":40, + "name":"Tile Layer 1", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":50, + "x":0, + "y":0 + }], + "orientation":"orthogonal", + "properties": + { + + }, + "tileheight":16, + "tilesets":[ + { + "firstgid":1, + "image":"..\/..\/..\/..\/kiwi-lite\/Test Suite\/assets\/tiles\/platformer_tiles.png", + "imageheight":96, + "imagewidth":304, + "margin":0, + "name":"platformer_tiles", + "properties": + { + + }, + "spacing":0, + "tileheight":16, + "tilewidth":16 + }], + "tilewidth":16, + "version":1, + "width":50 +} \ No newline at end of file diff --git a/Tests/assets/tiles/tmw_desert_spacing.png b/Tests/assets/tiles/tmw_desert_spacing.png new file mode 100644 index 00000000..4e9995c0 Binary files /dev/null and b/Tests/assets/tiles/tmw_desert_spacing.png differ diff --git a/Tests/phaser.js b/Tests/phaser.js index 305a170f..f5cd76bc 100644 --- a/Tests/phaser.js +++ b/Tests/phaser.js @@ -1,20 +1,7 @@ -/// -/** -* Phaser - Basic -* -* A useful "generic" object on which all GameObjects and Groups are based. -* It has no size, position or graphical data. -*/ var Phaser; (function (Phaser) { var Basic = (function () { - /** - * Instantiate the basic object. - */ function Basic(game) { - /** - * Allows you to give this object a name. Useful for debugging, but not actually used internally. - */ this.name = ''; this._game = game; this.ID = -1; @@ -25,2109 +12,31 @@ var Phaser; this.isGroup = false; this.ignoreDrawDebug = false; } - Basic.prototype.destroy = /** - * Override this to null out iables or manually call - * destroy() on class members if necessary. - * Don't forget to call super.destroy()! - */ - function () { + Basic.prototype.destroy = function () { }; - Basic.prototype.preUpdate = /** - * Pre-update is called right before update() on each object in the game loop. - */ - function () { + Basic.prototype.preUpdate = function () { }; - Basic.prototype.update = /** - * Override this to update your class's position and appearance. - * This is where most of your game rules and behavioral code will go. - */ - function () { + Basic.prototype.update = function () { }; - Basic.prototype.postUpdate = /** - * Post-update is called right after update() on each object in the game loop. - */ - function () { + Basic.prototype.postUpdate = function () { }; Basic.prototype.render = function (camera, cameraOffsetX, cameraOffsetY) { }; - Basic.prototype.kill = /** - * Handy for "killing" game objects. - * Default behavior is to flag them as nonexistent AND dead. - * However, if you want the "corpse" to remain in the game, - * like to animate an effect or whatever, you should override this, - * setting only alive to false, and leaving exists true. - */ - function () { + Basic.prototype.kill = function () { this.alive = false; this.exists = false; }; - Basic.prototype.revive = /** - * Handy for bringing game objects "back to life". Just sets alive and exists back to true. - * In practice, this is most often called by Object.reset(). - */ - function () { + Basic.prototype.revive = function () { this.alive = true; this.exists = true; }; - Basic.prototype.toString = /** - * Convert object to readable string name. Useful for debugging, save games, etc. - */ - function () { + Basic.prototype.toString = function () { return ""; }; return Basic; })(); Phaser.Basic = Basic; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - SignalBinding -* -* An object that represents a binding between a Signal and a listener function. -* Based on JS Signals by Miller Medeiros. Converted by TypeScript by Richard Davey. -* Released under the MIT license -* http://millermedeiros.github.com/js-signals/ -*/ -var Phaser; -(function (Phaser) { - var SignalBinding = (function () { - /** - * Object that represents a binding between a Signal and a listener function. - *
              - This is an internal constructor and shouldn't be called by regular users. - *
              - inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes. - * @author Miller Medeiros - * @constructor - * @internal - * @name SignalBinding - * @param {Signal} signal Reference to Signal object that listener is currently bound to. - * @param {Function} listener Handler function bound to the signal. - * @param {boolean} isOnce If binding should be executed just once. - * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). - * @param {Number} [priority] The priority level of the event listener. (default = 0). - */ - function SignalBinding(signal, listener, isOnce, listenerContext, priority) { - if (typeof priority === "undefined") { priority = 0; } - /** - * If binding is active and should be executed. - * @type boolean - */ - this.active = true; - /** - * Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute`. (curried parameters) - * @type Array|null - */ - this.params = null; - this._listener = listener; - this._isOnce = isOnce; - this.context = listenerContext; - this._signal = signal; - this.priority = priority || 0; - } - SignalBinding.prototype.execute = /** - * Call listener passing arbitrary parameters. - *

              If binding was added using `Signal.addOnce()` it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch.

              - * @param {Array} [paramsArr] Array of parameters that should be passed to the listener - * @return {*} Value returned by the listener. - */ - function (paramsArr) { - var handlerReturn; - var params; - if(this.active && !!this._listener) { - params = this.params ? this.params.concat(paramsArr) : paramsArr; - handlerReturn = this._listener.apply(this.context, params); - if(this._isOnce) { - this.detach(); - } - } - return handlerReturn; - }; - SignalBinding.prototype.detach = /** - * Detach binding from signal. - * - alias to: mySignal.remove(myBinding.getListener()); - * @return {Function|null} Handler function bound to the signal or `null` if binding was previously detached. - */ - function () { - return this.isBound() ? this._signal.remove(this._listener, this.context) : null; - }; - SignalBinding.prototype.isBound = /** - * @return {Boolean} `true` if binding is still bound to the signal and have a listener. - */ - function () { - return (!!this._signal && !!this._listener); - }; - SignalBinding.prototype.isOnce = /** - * @return {boolean} If SignalBinding will only be executed once. - */ - function () { - return this._isOnce; - }; - SignalBinding.prototype.getListener = /** - * @return {Function} Handler function bound to the signal. - */ - function () { - return this._listener; - }; - SignalBinding.prototype.getSignal = /** - * @return {Signal} Signal that listener is currently bound to. - */ - function () { - return this._signal; - }; - SignalBinding.prototype._destroy = /** - * Delete instance properties - * @private - */ - function () { - delete this._signal; - delete this._listener; - delete this.context; - }; - SignalBinding.prototype.toString = /** - * @return {string} String representation of the object. - */ - function () { - return '[SignalBinding isOnce:' + this._isOnce + ', isBound:' + this.isBound() + ', active:' + this.active + ']'; - }; - return SignalBinding; - })(); - Phaser.SignalBinding = SignalBinding; -})(Phaser || (Phaser = {})); -/// -/** -* Phaser - Signal -* -* A Signal is used for object communication via a custom broadcaster instead of Events. -* Based on JS Signals by Miller Medeiros. Converted by TypeScript by Richard Davey. -* Released under the MIT license -* http://millermedeiros.github.com/js-signals/ -*/ -var Phaser; -(function (Phaser) { - var Signal = (function () { - function Signal() { - /** - * - * @property _bindings - * @type Array - * @private - */ - this._bindings = []; - /** - * - * @property _prevParams - * @type Any - * @private - */ - this._prevParams = null; - /** - * If Signal should keep record of previously dispatched parameters and - * automatically execute listener during `add()`/`addOnce()` if Signal was - * already dispatched before. - * @type boolean - */ - this.memorize = false; - /** - * @type boolean - * @private - */ - this._shouldPropagate = true; - /** - * If Signal is active and should broadcast events. - *

              IMPORTANT: Setting this property during a dispatch will only affect the next dispatch, if you want to stop the propagation of a signal use `halt()` instead.

              - * @type boolean - */ - this.active = true; - } - Signal.VERSION = '1.0.0'; - Signal.prototype.validateListener = /** - * - * @method validateListener - * @param {Any} listener - * @param {Any} fnName - */ - function (listener, fnName) { - if(typeof listener !== 'function') { - throw new Error('listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName)); - } - }; - Signal.prototype._registerListener = /** - * @param {Function} listener - * @param {boolean} isOnce - * @param {Object} [listenerContext] - * @param {Number} [priority] - * @return {SignalBinding} - * @private - */ - function (listener, isOnce, listenerContext, priority) { - var prevIndex = this._indexOfListener(listener, listenerContext); - var binding; - if(prevIndex !== -1) { - binding = this._bindings[prevIndex]; - if(binding.isOnce() !== isOnce) { - throw new Error('You cannot add' + (isOnce ? '' : 'Once') + '() then add' + (!isOnce ? '' : 'Once') + '() the same listener without removing the relationship first.'); - } - } else { - binding = new Phaser.SignalBinding(this, listener, isOnce, listenerContext, priority); - this._addBinding(binding); - } - if(this.memorize && this._prevParams) { - binding.execute(this._prevParams); - } - return binding; - }; - Signal.prototype._addBinding = /** - * - * @method _addBinding - * @param {SignalBinding} binding - * @private - */ - function (binding) { - //simplified insertion sort - var n = this._bindings.length; - do { - --n; - }while(this._bindings[n] && binding.priority <= this._bindings[n].priority); - this._bindings.splice(n + 1, 0, binding); - }; - Signal.prototype._indexOfListener = /** - * - * @method _indexOfListener - * @param {Function} listener - * @return {number} - * @private - */ - function (listener, context) { - var n = this._bindings.length; - var cur; - while(n--) { - cur = this._bindings[n]; - if(cur.getListener() === listener && cur.context === context) { - return n; - } - } - return -1; - }; - Signal.prototype.has = /** - * Check if listener was attached to Signal. - * @param {Function} listener - * @param {Object} [context] - * @return {boolean} if Signal has the specified listener. - */ - function (listener, context) { - if (typeof context === "undefined") { context = null; } - return this._indexOfListener(listener, context) !== -1; - }; - Signal.prototype.add = /** - * Add a listener to the signal. - * @param {Function} listener Signal handler function. - * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). - * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0) - * @return {SignalBinding} An Object representing the binding between the Signal and listener. - */ - function (listener, listenerContext, priority) { - if (typeof listenerContext === "undefined") { listenerContext = null; } - if (typeof priority === "undefined") { priority = 0; } - this.validateListener(listener, 'add'); - return this._registerListener(listener, false, listenerContext, priority); - }; - Signal.prototype.addOnce = /** - * Add listener to the signal that should be removed after first execution (will be executed only once). - * @param {Function} listener Signal handler function. - * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). - * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0) - * @return {SignalBinding} An Object representing the binding between the Signal and listener. - */ - function (listener, listenerContext, priority) { - if (typeof listenerContext === "undefined") { listenerContext = null; } - if (typeof priority === "undefined") { priority = 0; } - this.validateListener(listener, 'addOnce'); - return this._registerListener(listener, true, listenerContext, priority); - }; - Signal.prototype.remove = /** - * Remove a single listener from the dispatch queue. - * @param {Function} listener Handler function that should be removed. - * @param {Object} [context] Execution context (since you can add the same handler multiple times if executing in a different context). - * @return {Function} Listener handler function. - */ - function (listener, context) { - if (typeof context === "undefined") { context = null; } - this.validateListener(listener, 'remove'); - var i = this._indexOfListener(listener, context); - if(i !== -1) { - this._bindings[i]._destroy()//no reason to a SignalBinding exist if it isn't attached to a signal - ; - this._bindings.splice(i, 1); - } - return listener; - }; - Signal.prototype.removeAll = /** - * Remove all listeners from the Signal. - */ - function () { - var n = this._bindings.length; - while(n--) { - this._bindings[n]._destroy(); - } - this._bindings.length = 0; - }; - Signal.prototype.getNumListeners = /** - * @return {number} Number of listeners attached to the Signal. - */ - function () { - return this._bindings.length; - }; - Signal.prototype.halt = /** - * Stop propagation of the event, blocking the dispatch to next listeners on the queue. - *

              IMPORTANT: should be called only during signal dispatch, calling it before/after dispatch won't affect signal broadcast.

              - * @see Signal.prototype.disable - */ - function () { - this._shouldPropagate = false; - }; - Signal.prototype.dispatch = /** - * Dispatch/Broadcast Signal to all listeners added to the queue. - * @param {...*} [params] Parameters that should be passed to each handler. - */ - function () { - var paramsArr = []; - for (var _i = 0; _i < (arguments.length - 0); _i++) { - paramsArr[_i] = arguments[_i + 0]; - } - if(!this.active) { - return; - } - var n = this._bindings.length; - var bindings; - if(this.memorize) { - this._prevParams = paramsArr; - } - if(!n) { - //should come after memorize - return; - } - bindings = this._bindings.slice(0)//clone array in case add/remove items during dispatch - ; - this._shouldPropagate = true//in case `halt` was called before dispatch or during the previous dispatch. - ; - //execute all callbacks until end of the list or until a callback returns `false` or stops propagation - //reverse loop since listeners with higher priority will be added at the end of the list - do { - n--; - }while(bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false); - }; - Signal.prototype.forget = /** - * Forget memorized arguments. - * @see Signal.memorize - */ - function () { - this._prevParams = null; - }; - Signal.prototype.dispose = /** - * Remove all bindings from signal and destroy any reference to external objects (destroy Signal object). - *

              IMPORTANT: calling any method on the signal instance after calling dispose will throw errors.

              - */ - function () { - this.removeAll(); - delete this._bindings; - delete this._prevParams; - }; - Signal.prototype.toString = /** - * @return {string} String representation of the object. - */ - function () { - return '[Signal active:' + this.active + ' numListeners:' + this.getNumListeners() + ']'; - }; - return Signal; - })(); - Phaser.Signal = Signal; -})(Phaser || (Phaser = {})); -var __extends = this.__extends || function (d, b) { - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -/// -/// -/// -/** -* Phaser - GameObject -* -* This is the base GameObject on which all other game objects are derived. It contains all the logic required for position, -* motion, size, collision and input. -*/ -var Phaser; -(function (Phaser) { - var GameObject = (function (_super) { - __extends(GameObject, _super); - function GameObject(game, x, y, width, height) { - if (typeof x === "undefined") { x = 0; } - if (typeof y === "undefined") { y = 0; } - if (typeof width === "undefined") { width = 16; } - if (typeof height === "undefined") { height = 16; } - _super.call(this, game); - this._angle = 0; - this.outOfBoundsAction = 0; - this.z = 0; - // This value is added to the angle of the GameObject. - // For example if you had a sprite drawn facing straight up then you could set - // rotationOffset to 90 and it would correspond correctly with Phasers rotation system - this.rotationOffset = 0; - this.moves = true; - // Input - this.inputEnabled = false; - this._inputOver = false; - this.bounds = new Phaser.Rectangle(x, y, width, height); - this.exists = true; - this.active = true; - this.visible = true; - this.alive = true; - this.isGroup = false; - this.alpha = 1; - this.scale = new Phaser.MicroPoint(1, 1); - this.last = new Phaser.MicroPoint(x, y); - this.origin = new Phaser.MicroPoint(this.bounds.halfWidth, this.bounds.halfHeight); - this.align = GameObject.ALIGN_TOP_LEFT; - this.mass = 1.0; - this.elasticity = 0.0; - this.health = 1; - this.immovable = false; - this.moves = true; - this.worldBounds = null; - this.touching = Phaser.Collision.NONE; - this.wasTouching = Phaser.Collision.NONE; - this.allowCollisions = Phaser.Collision.ANY; - this.velocity = new Phaser.MicroPoint(); - this.acceleration = new Phaser.MicroPoint(); - this.drag = new Phaser.MicroPoint(); - this.maxVelocity = new Phaser.MicroPoint(10000, 10000); - this.angle = 0; - this.angularVelocity = 0; - this.angularAcceleration = 0; - this.angularDrag = 0; - this.maxAngular = 10000; - this.cameraBlacklist = []; - this.scrollFactor = new Phaser.MicroPoint(1.0, 1.0); - } - GameObject.ALIGN_TOP_LEFT = 0; - GameObject.ALIGN_TOP_CENTER = 1; - GameObject.ALIGN_TOP_RIGHT = 2; - GameObject.ALIGN_CENTER_LEFT = 3; - GameObject.ALIGN_CENTER = 4; - GameObject.ALIGN_CENTER_RIGHT = 5; - GameObject.ALIGN_BOTTOM_LEFT = 6; - GameObject.ALIGN_BOTTOM_CENTER = 7; - GameObject.ALIGN_BOTTOM_RIGHT = 8; - GameObject.OUT_OF_BOUNDS_STOP = 0; - GameObject.OUT_OF_BOUNDS_KILL = 1; - GameObject.prototype.preUpdate = function () { - // flicker time - this.last.x = this.bounds.x; - this.last.y = this.bounds.y; - }; - GameObject.prototype.update = function () { - }; - GameObject.prototype.postUpdate = function () { - if(this.moves) { - this.updateMotion(); - } - if(this.worldBounds != null) { - if(this.outOfBoundsAction == GameObject.OUT_OF_BOUNDS_KILL) { - if(this.x < this.worldBounds.x || this.x > this.worldBounds.right || this.y < this.worldBounds.y || this.y > this.worldBounds.bottom) { - this.kill(); - } - } else { - if(this.x < this.worldBounds.x) { - this.x = this.worldBounds.x; - } else if(this.x > this.worldBounds.right) { - this.x = this.worldBounds.right; - } - if(this.y < this.worldBounds.y) { - this.y = this.worldBounds.y; - } else if(this.y > this.worldBounds.bottom) { - this.y = this.worldBounds.bottom; - } - } - } - if(this.inputEnabled) { - this.updateInput(); - } - this.wasTouching = this.touching; - this.touching = Phaser.Collision.NONE; - }; - GameObject.prototype.updateInput = function () { - }; - GameObject.prototype.updateMotion = function () { - var delta; - var velocityDelta; - velocityDelta = (this._game.motion.computeVelocity(this.angularVelocity, this.angularAcceleration, this.angularDrag, this.maxAngular) - this.angularVelocity) / 2; - this.angularVelocity += velocityDelta; - this._angle += this.angularVelocity * this._game.time.elapsed; - this.angularVelocity += velocityDelta; - velocityDelta = (this._game.motion.computeVelocity(this.velocity.x, this.acceleration.x, this.drag.x, this.maxVelocity.x) - this.velocity.x) / 2; - this.velocity.x += velocityDelta; - delta = this.velocity.x * this._game.time.elapsed; - this.velocity.x += velocityDelta; - this.bounds.x += delta; - velocityDelta = (this._game.motion.computeVelocity(this.velocity.y, this.acceleration.y, this.drag.y, this.maxVelocity.y) - this.velocity.y) / 2; - this.velocity.y += velocityDelta; - delta = this.velocity.y * this._game.time.elapsed; - this.velocity.y += velocityDelta; - this.bounds.y += delta; - }; - GameObject.prototype.overlaps = /** - * Checks to see if some GameObject overlaps this GameObject or Group. - * If the group has a LOT of things in it, it might be faster to use Collision.overlaps(). - * WARNING: Currently tilemaps do NOT support screen space overlap checks! - * - * @param ObjectOrGroup The object or group being tested. - * @param InScreenSpace Whether to take scroll factors numbero account when checking for overlap. Default is false, or "only compare in world space." - * @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera. - * - * @return Whether or not the two objects overlap. - */ - function (ObjectOrGroup, InScreenSpace, Camera) { - if (typeof InScreenSpace === "undefined") { InScreenSpace = false; } - if (typeof Camera === "undefined") { Camera = null; } - if(ObjectOrGroup.isGroup) { - var results = false; - var i = 0; - var members = ObjectOrGroup.members; - while(i < length) { - if(this.overlaps(members[i++], InScreenSpace, Camera)) { - results = true; - } - } - return results; - } - /* - if (typeof ObjectOrGroup === 'Tilemap') - { - //Since tilemap's have to be the caller, not the target, to do proper tile-based collisions, - // we redirect the call to the tilemap overlap here. - return ObjectOrGroup.overlaps(this, InScreenSpace, Camera); - } - */ - //var object: GameObject = ObjectOrGroup; - if(!InScreenSpace) { - return (ObjectOrGroup.x + ObjectOrGroup.width > this.x) && (ObjectOrGroup.x < this.x + this.width) && (ObjectOrGroup.y + ObjectOrGroup.height > this.y) && (ObjectOrGroup.y < this.y + this.height); - } - if(Camera == null) { - Camera = this._game.camera; - } - var objectScreenPos = ObjectOrGroup.getScreenXY(null, Camera); - this.getScreenXY(this._point, Camera); - return (objectScreenPos.x + ObjectOrGroup.width > this._point.x) && (objectScreenPos.x < this._point.x + this.width) && (objectScreenPos.y + ObjectOrGroup.height > this._point.y) && (objectScreenPos.y < this._point.y + this.height); - }; - GameObject.prototype.overlapsAt = /** - * Checks to see if this GameObject were located at the given position, would it overlap the GameObject or Group? - * This is distinct from overlapsPoint(), which just checks that point, rather than taking the object's size numbero account. - * WARNING: Currently tilemaps do NOT support screen space overlap checks! - * - * @param X The X position you want to check. Pretends this object (the caller, not the parameter) is located here. - * @param Y The Y position you want to check. Pretends this object (the caller, not the parameter) is located here. - * @param ObjectOrGroup The object or group being tested. - * @param InScreenSpace Whether to take scroll factors numbero account when checking for overlap. Default is false, or "only compare in world space." - * @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera. - * - * @return Whether or not the two objects overlap. - */ - function (X, Y, ObjectOrGroup, InScreenSpace, Camera) { - if (typeof InScreenSpace === "undefined") { InScreenSpace = false; } - if (typeof Camera === "undefined") { Camera = null; } - if(ObjectOrGroup.isGroup) { - var results = false; - var basic; - var i = 0; - var members = ObjectOrGroup.members; - while(i < length) { - if(this.overlapsAt(X, Y, members[i++], InScreenSpace, Camera)) { - results = true; - } - } - return results; - } - /* - if (typeof ObjectOrGroup === 'Tilemap') - { - //Since tilemap's have to be the caller, not the target, to do proper tile-based collisions, - // we redirect the call to the tilemap overlap here. - //However, since this is overlapsAt(), we also have to invent the appropriate position for the tilemap. - //So we calculate the offset between the player and the requested position, and subtract that from the tilemap. - var tilemap: Tilemap = ObjectOrGroup; - return tilemap.overlapsAt(tilemap.x - (X - this.x), tilemap.y - (Y - this.y), this, InScreenSpace, Camera); - } - */ - //var object: GameObject = ObjectOrGroup; - if(!InScreenSpace) { - return (ObjectOrGroup.x + ObjectOrGroup.width > X) && (ObjectOrGroup.x < X + this.width) && (ObjectOrGroup.y + ObjectOrGroup.height > Y) && (ObjectOrGroup.y < Y + this.height); - } - if(Camera == null) { - Camera = this._game.camera; - } - var objectScreenPos = ObjectOrGroup.getScreenXY(null, Camera); - this._point.x = X - Camera.scroll.x * this.scrollFactor.x//copied from getScreenXY() - ; - this._point.y = Y - Camera.scroll.y * this.scrollFactor.y; - this._point.x += (this._point.x > 0) ? 0.0000001 : -0.0000001; - this._point.y += (this._point.y > 0) ? 0.0000001 : -0.0000001; - return (objectScreenPos.x + ObjectOrGroup.width > this._point.x) && (objectScreenPos.x < this._point.x + this.width) && (objectScreenPos.y + ObjectOrGroup.height > this._point.y) && (objectScreenPos.y < this._point.y + this.height); - }; - GameObject.prototype.overlapsPoint = /** - * Checks to see if a point in 2D world space overlaps this GameObject. - * - * @param Point The point in world space you want to check. - * @param InScreenSpace Whether to take scroll factors numbero account when checking for overlap. - * @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera. - * - * @return Whether or not the point overlaps this object. - */ - function (point, InScreenSpace, Camera) { - if (typeof InScreenSpace === "undefined") { InScreenSpace = false; } - if (typeof Camera === "undefined") { Camera = null; } - if(!InScreenSpace) { - return (point.x > this.x) && (point.x < this.x + this.width) && (point.y > this.y) && (point.y < this.y + this.height); - } - if(Camera == null) { - Camera = this._game.camera; - } - var X = point.x - Camera.scroll.x; - var Y = point.y - Camera.scroll.y; - this.getScreenXY(this._point, Camera); - return (X > this._point.x) && (X < this._point.x + this.width) && (Y > this._point.y) && (Y < this._point.y + this.height); - }; - GameObject.prototype.onScreen = /** - * Check and see if this object is currently on screen. - * - * @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera. - * - * @return Whether the object is on screen or not. - */ - function (Camera) { - if (typeof Camera === "undefined") { Camera = null; } - if(Camera == null) { - Camera = this._game.camera; - } - this.getScreenXY(this._point, Camera); - return (this._point.x + this.width > 0) && (this._point.x < Camera.width) && (this._point.y + this.height > 0) && (this._point.y < Camera.height); - }; - GameObject.prototype.getScreenXY = /** - * Call this to figure out the on-screen position of the object. - * - * @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera. - * @param Point Takes a MicroPoint object and assigns the post-scrolled X and Y values of this object to it. - * - * @return The MicroPoint you passed in, or a new Point if you didn't pass one, containing the screen X and Y position of this object. - */ - function (point, Camera) { - if (typeof point === "undefined") { point = null; } - if (typeof Camera === "undefined") { Camera = null; } - if(point == null) { - point = new Phaser.MicroPoint(); - } - if(Camera == null) { - Camera = this._game.camera; - } - point.x = this.x - Camera.scroll.x * this.scrollFactor.x; - point.y = this.y - Camera.scroll.y * this.scrollFactor.y; - point.x += (point.x > 0) ? 0.0000001 : -0.0000001; - point.y += (point.y > 0) ? 0.0000001 : -0.0000001; - return point; - }; - Object.defineProperty(GameObject.prototype, "solid", { - get: /** - * Whether the object collides or not. For more control over what directions - * the object will collide from, use collision constants (like LEFT, FLOOR, etc) - * to set the value of allowCollisions directly. - */ - function () { - return (this.allowCollisions & Phaser.Collision.ANY) > Phaser.Collision.NONE; - }, - set: /** - * @private - */ - function (Solid) { - if(Solid) { - this.allowCollisions = Phaser.Collision.ANY; - } else { - this.allowCollisions = Phaser.Collision.NONE; - } - }, - enumerable: true, - configurable: true - }); - GameObject.prototype.getMidpoint = /** - * Retrieve the midpoint of this object in world coordinates. - * - * @Point Allows you to pass in an existing Point object if you're so inclined. Otherwise a new one is created. - * - * @return A Point object containing the midpoint of this object in world coordinates. - */ - function (point) { - if (typeof point === "undefined") { point = null; } - if(point == null) { - point = new Phaser.MicroPoint(); - } - point.copyFrom(this.bounds.center); - return point; - }; - GameObject.prototype.reset = /** - * Handy for reviving game objects. - * Resets their existence flags and position. - * - * @param X The new X position of this object. - * @param Y The new Y position of this object. - */ - function (X, Y) { - this.revive(); - this.touching = Phaser.Collision.NONE; - this.wasTouching = Phaser.Collision.NONE; - this.x = X; - this.y = Y; - this.last.x = X; - this.last.y = Y; - this.velocity.x = 0; - this.velocity.y = 0; - }; - GameObject.prototype.isTouching = /** - * Handy for checking if this object is touching a particular surface. - * For slightly better performance you can just & the value directly numbero touching. - * However, this method is good for readability and accessibility. - * - * @param Direction Any of the collision flags (e.g. LEFT, FLOOR, etc). - * - * @return Whether the object is touching an object in (any of) the specified direction(s) this frame. - */ - function (Direction) { - return (this.touching & Direction) > Phaser.Collision.NONE; - }; - GameObject.prototype.justTouched = /** - * Handy for checking if this object is just landed on a particular surface. - * - * @param Direction Any of the collision flags (e.g. LEFT, FLOOR, etc). - * - * @return Whether the object just landed on (any of) the specified surface(s) this frame. - */ - function (Direction) { - return ((this.touching & Direction) > Phaser.Collision.NONE) && ((this.wasTouching & Direction) <= Phaser.Collision.NONE); - }; - GameObject.prototype.hurt = /** - * Reduces the "health" variable of this sprite by the amount specified in Damage. - * Calls kill() if health drops to or below zero. - * - * @param Damage How much health to take away (use a negative number to give a health bonus). - */ - function (Damage) { - this.health = this.health - Damage; - if(this.health <= 0) { - this.kill(); - } - }; - GameObject.prototype.setBounds = /** - * Set the world bounds that this GameObject can exist within. By default a GameObject can exist anywhere - * in the world. But by setting the bounds (which are given in world dimensions, not screen dimensions) - * it can be stopped from leaving the world, or a section of it. - */ - function (x, y, width, height) { - this.worldBounds = new Phaser.Quad(x, y, width, height); - }; - GameObject.prototype.hideFromCamera = /** - * If you do not wish this object to be visible to a specific camera, pass the camera here. - */ - function (camera) { - if(this.cameraBlacklist.indexOf(camera.ID) == -1) { - this.cameraBlacklist.push(camera.ID); - } - }; - GameObject.prototype.showToCamera = function (camera) { - if(this.cameraBlacklist.indexOf(camera.ID) !== -1) { - this.cameraBlacklist.slice(this.cameraBlacklist.indexOf(camera.ID), 1); - } - }; - GameObject.prototype.clearCameraList = function () { - this.cameraBlacklist.length = 0; - }; - GameObject.prototype.destroy = function () { - }; - Object.defineProperty(GameObject.prototype, "x", { - get: function () { - return this.bounds.x; - }, - set: function (value) { - this.bounds.x = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GameObject.prototype, "y", { - get: function () { - return this.bounds.y; - }, - set: function (value) { - this.bounds.y = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GameObject.prototype, "rotation", { - get: function () { - return this._angle; - }, - set: function (value) { - this._angle = this._game.math.wrap(value, 360, 0); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GameObject.prototype, "angle", { - get: function () { - return this._angle; - }, - set: function (value) { - this._angle = this._game.math.wrap(value, 360, 0); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GameObject.prototype, "width", { - get: function () { - return this.bounds.width; - }, - set: function (value) { - this.bounds.width = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GameObject.prototype, "height", { - get: function () { - return this.bounds.height; - }, - set: function (value) { - this.bounds.height = value; - }, - enumerable: true, - configurable: true - }); - return GameObject; - })(Phaser.Basic); - Phaser.GameObject = GameObject; -})(Phaser || (Phaser = {})); -/// -/// -/** -* Phaser - Camera -* -* A Camera is your view into the game world. It has a position, size, scale and rotation and renders only those objects -* within its field of view. The game automatically creates a single Stage sized camera on boot, but it can be changed and -* additional cameras created via the CameraManager. -*/ -var Phaser; -(function (Phaser) { - var Camera = (function () { - /** - * Instantiates a new camera at the specified location, with the specified size and zoom level. - * - * @param X X location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom. - * @param Y Y location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom. - * @param Width The width of the camera display in pixels. - * @param Height The height of the camera display in pixels. - * @param Zoom The initial zoom level of the camera. A zoom level of 2 will make all pixels display at 2x resolution. - */ - function Camera(game, id, x, y, width, height) { - this._clip = false; - this._rotation = 0; - this._target = null; - this._sx = 0; - this._sy = 0; - this._fxFlashComplete = null; - this._fxFlashDuration = 0; - this._fxFlashAlpha = 0; - this._fxFadeComplete = null; - this._fxFadeDuration = 0; - this._fxFadeAlpha = 0; - this._fxShakeIntensity = 0; - this._fxShakeDuration = 0; - this._fxShakeComplete = null; - this._fxShakeOffset = new Phaser.Point(0, 0); - this._fxShakeDirection = 0; - this._fxShakePrevX = 0; - this._fxShakePrevY = 0; - this.scale = new Phaser.Point(1, 1); - this.scroll = new Phaser.Point(0, 0); - this.bounds = null; - this.deadzone = null; - // Camera Border - this.showBorder = false; - this.borderColor = 'rgb(255,255,255)'; - // Camera Background Color - this.opaque = true; - this._bgColor = 'rgb(0,0,0)'; - this._bgTextureRepeat = 'repeat'; - // Camera Shadow - this.showShadow = false; - this.shadowColor = 'rgb(0,0,0)'; - this.shadowBlur = 10; - this.shadowOffset = new Phaser.Point(4, 4); - this.visible = true; - this.alpha = 1; - // The x/y position of the current input event in world coordinates - this.inputX = 0; - this.inputY = 0; - this._game = game; - this.ID = id; - this._stageX = x; - this._stageY = y; - // The view into the world canvas we wish to render - this.worldView = new Phaser.Rectangle(0, 0, width, height); - this.checkClip(); - } - Camera.STYLE_LOCKON = 0; - Camera.STYLE_PLATFORMER = 1; - Camera.STYLE_TOPDOWN = 2; - Camera.STYLE_TOPDOWN_TIGHT = 3; - Camera.SHAKE_BOTH_AXES = 0; - Camera.SHAKE_HORIZONTAL_ONLY = 1; - Camera.SHAKE_VERTICAL_ONLY = 2; - Camera.prototype.flash = /** - * 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; - }; - Camera.prototype.fade = /** - * 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; - }; - Camera.prototype.shake = /** - * A simple screen-shake effect. - * - * @param Intensity Percentage of screen size representing the maximum distance that the screen can move while shaking. - * @param Duration The length in seconds that the shaking effect should last. - * @param OnComplete A function you want to run when the shake effect finishes. - * @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) { - 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 = Camera.SHAKE_BOTH_AXES; } - 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) { - this._fxShakePrevX = this._stageX; - this._fxShakePrevY = this._stageY; - } - this._fxShakeIntensity = intensity; - this._fxShakeDuration = duration; - this._fxShakeComplete = onComplete; - this._fxShakeDirection = direction; - this._fxShakeOffset.setTo(0, 0); - }; - Camera.prototype.stopFX = /** - * Just turns off all the camera effects instantly. - */ - function () { - this._fxFlashAlpha = 0; - this._fxFadeAlpha = 0; - if(this._fxShakeDuration !== 0) { - this._fxShakeDuration = 0; - this._fxShakeOffset.setTo(0, 0); - this._stageX = this._fxShakePrevX; - this._stageY = this._fxShakePrevY; - } - }; - Camera.prototype.follow = function (target, style) { - if (typeof style === "undefined") { style = Camera.STYLE_LOCKON; } - this._target = target; - var helper; - switch(style) { - case Camera.STYLE_PLATFORMER: - var w = this.width / 8; - var h = this.height / 3; - this.deadzone = new Phaser.Rectangle((this.width - w) / 2, (this.height - h) / 2 - h * 0.25, w, h); - break; - case Camera.STYLE_TOPDOWN: - helper = Math.max(this.width, this.height) / 4; - this.deadzone = new Phaser.Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper); - break; - case Camera.STYLE_TOPDOWN_TIGHT: - helper = Math.max(this.width, this.height) / 8; - this.deadzone = new Phaser.Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper); - break; - case Camera.STYLE_LOCKON: - default: - this.deadzone = null; - break; - } - }; - Camera.prototype.focusOnXY = function (x, y) { - x += (x > 0) ? 0.0000001 : -0.0000001; - y += (y > 0) ? 0.0000001 : -0.0000001; - this.scroll.x = Math.round(x - this.worldView.halfWidth); - this.scroll.y = Math.round(y - this.worldView.halfHeight); - }; - Camera.prototype.focusOn = function (point) { - point.x += (point.x > 0) ? 0.0000001 : -0.0000001; - point.y += (point.y > 0) ? 0.0000001 : -0.0000001; - this.scroll.x = Math.round(point.x - this.worldView.halfWidth); - this.scroll.y = Math.round(point.y - this.worldView.halfHeight); - }; - Camera.prototype.setBounds = /** - * Specify the boundaries of the world or where the camera is allowed to move. - * - * @param X The smallest X value of your world (usually 0). - * @param Y The smallest Y value of your world (usually 0). - * @param Width The largest X value of your world (usually the world width). - * @param Height The largest Y value of your world (usually the world height). - * @param UpdateWorld Whether the global quad-tree's dimensions should be updated to match (default: false). - */ - function (X, Y, Width, Height, UpdateWorld) { - if (typeof X === "undefined") { X = 0; } - if (typeof Y === "undefined") { Y = 0; } - if (typeof Width === "undefined") { Width = 0; } - if (typeof Height === "undefined") { Height = 0; } - if (typeof UpdateWorld === "undefined") { UpdateWorld = false; } - if(this.bounds == null) { - this.bounds = new Phaser.Rectangle(); - } - this.bounds.setTo(X, Y, Width, Height); - //if(UpdateWorld) - // G.worldBounds.copyFrom(bounds); - this.update(); - }; - Camera.prototype.update = function () { - if(this._target !== null) { - if(this.deadzone == null) { - this.focusOnXY(this._target.x + this._target.origin.x, this._target.y + this._target.origin.y); - } else { - var edge; - var targetX = this._target.x + ((this._target.x > 0) ? 0.0000001 : -0.0000001); - var targetY = this._target.y + ((this._target.y > 0) ? 0.0000001 : -0.0000001); - edge = targetX - this.deadzone.x; - if(this.scroll.x > edge) { - this.scroll.x = edge; - } - edge = targetX + this._target.width - this.deadzone.x - this.deadzone.width; - if(this.scroll.x < edge) { - this.scroll.x = edge; - } - edge = targetY - this.deadzone.y; - if(this.scroll.y > edge) { - this.scroll.y = edge; - } - edge = targetY + this._target.height - this.deadzone.y - this.deadzone.height; - if(this.scroll.y < edge) { - this.scroll.y = edge; - } - } - } - // Make sure we didn't go outside the camera's bounds - if(this.bounds !== null) { - if(this.scroll.x < this.bounds.left) { - this.scroll.x = this.bounds.left; - } - if(this.scroll.x > this.bounds.right - this.width) { - this.scroll.x = this.bounds.right - this.width; - } - if(this.scroll.y < this.bounds.top) { - this.scroll.y = this.bounds.top; - } - if(this.scroll.y > this.bounds.bottom - this.height) { - this.scroll.y = this.bounds.bottom - this.height; - } - } - this.worldView.x = this.scroll.x; - this.worldView.y = this.scroll.y; - // Input values - this.inputX = this.worldView.x + this._game.input.x; - this.inputY = this.worldView.y + this._game.input.y; - // Update the Flash effect - if(this._fxFlashAlpha > 0) { - this._fxFlashAlpha -= this._game.time.elapsed / this._fxFlashDuration; - this._fxFlashAlpha = this._game.math.roundTo(this._fxFlashAlpha, -2); - if(this._fxFlashAlpha <= 0) { - this._fxFlashAlpha = 0; - if(this._fxFlashComplete !== null) { - this._fxFlashComplete(); - } - } - } - // Update the Fade effect - if(this._fxFadeAlpha > 0) { - this._fxFadeAlpha += this._game.time.elapsed / this._fxFadeDuration; - this._fxFadeAlpha = this._game.math.roundTo(this._fxFadeAlpha, -2); - if(this._fxFadeAlpha >= 1) { - this._fxFadeAlpha = 1; - if(this._fxFadeComplete !== null) { - this._fxFadeComplete(); - } - } - } - // Update the "shake" special effect - if(this._fxShakeDuration > 0) { - this._fxShakeDuration -= this._game.time.elapsed; - this._fxShakeDuration = this._game.math.roundTo(this._fxShakeDuration, -2); - if(this._fxShakeDuration <= 0) { - this._fxShakeDuration = 0; - this._fxShakeOffset.setTo(0, 0); - this._stageX = this._fxShakePrevX; - this._stageY = this._fxShakePrevY; - if(this._fxShakeComplete != null) { - this._fxShakeComplete(); - } - } else { - if((this._fxShakeDirection == Camera.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Camera.SHAKE_HORIZONTAL_ONLY)) { - //this._fxShakeOffset.x = ((this._game.math.random() * this._fxShakeIntensity * this.worldView.width * 2 - this._fxShakeIntensity * this.worldView.width) * this._zoom; - this._fxShakeOffset.x = (this._game.math.random() * this._fxShakeIntensity * this.worldView.width * 2 - this._fxShakeIntensity * this.worldView.width); - } - if((this._fxShakeDirection == Camera.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Camera.SHAKE_VERTICAL_ONLY)) { - //this._fxShakeOffset.y = (this._game.math.random() * this._fxShakeIntensity * this.worldView.height * 2 - this._fxShakeIntensity * this.worldView.height) * this._zoom; - this._fxShakeOffset.y = (this._game.math.random() * this._fxShakeIntensity * this.worldView.height * 2 - this._fxShakeIntensity * this.worldView.height); - } - } - } - }; - Camera.prototype.render = function () { - if(this.visible === false || this.alpha < 0.1) { - return; - } - if((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0)) { - //this._stageX = this._fxShakePrevX + (this.worldView.halfWidth * this._zoom) + this._fxShakeOffset.x; - //this._stageY = this._fxShakePrevY + (this.worldView.halfHeight * this._zoom) + this._fxShakeOffset.y; - this._stageX = this._fxShakePrevX + (this.worldView.halfWidth) + this._fxShakeOffset.x; - this._stageY = this._fxShakePrevY + (this.worldView.halfHeight) + this._fxShakeOffset.y; - //console.log('shake', this._fxShakeDuration, this._fxShakeIntensity, this._fxShakeOffset.x, this._fxShakeOffset.y); - } - //if (this._rotation !== 0 || this._clip || this.scale.x !== 1 || this.scale.y !== 1) - //{ - //this._game.stage.context.save(); - //} - // It may be safe/quicker to just save the context every frame regardless - this._game.stage.context.save(); - if(this.alpha !== 1) { - this._game.stage.context.globalAlpha = this.alpha; - } - this._sx = this._stageX; - this._sy = this._stageY; - // Shadow - if(this.showShadow) { - 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; - } - // Scale on - if(this.scale.x !== 1 || this.scale.y !== 1) { - this._game.stage.context.scale(this.scale.x, this.scale.y); - this._sx = this._sx / this.scale.x; - this._sy = this._sy / this.scale.y; - } - // Rotation - translate to the mid-point of the camera - if(this._rotation !== 0) { - this._game.stage.context.translate(this._sx + this.worldView.halfWidth, this._sy + this.worldView.halfHeight); - this._game.stage.context.rotate(this._rotation * (Math.PI / 180)); - // now shift back to where that should actually render - this._game.stage.context.translate(-(this._sx + this.worldView.halfWidth), -(this._sy + this.worldView.halfHeight)); - } - // Background - if(this.opaque == true) { - if(this._bgTexture) { - this._game.stage.context.fillStyle = this._bgTexture; - this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height); - } else { - this._game.stage.context.fillStyle = this._bgColor; - this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height); - } - } - // Shadow off - if(this.showShadow) { - this._game.stage.context.shadowBlur = 0; - this._game.stage.context.shadowOffsetX = 0; - this._game.stage.context.shadowOffsetY = 0; - } - // Clip the camera so we don't get sprites appearing outside the edges - if(this._clip) { - this._game.stage.context.beginPath(); - this._game.stage.context.rect(this._sx, this._sy, this.worldView.width, this.worldView.height); - this._game.stage.context.closePath(); - this._game.stage.context.clip(); - } - this._game.world.group.render(this, this._sx, this._sy); - if(this.showBorder) { - 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(); - } - // "Flash" FX - if(this._fxFlashAlpha > 0) { - this._game.stage.context.fillStyle = this._fxFlashColor + this._fxFlashAlpha + ')'; - this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height); - } - // "Fade" FX - if(this._fxFadeAlpha > 0) { - this._game.stage.context.fillStyle = this._fxFadeColor + this._fxFadeAlpha + ')'; - this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height); - } - // Scale off - if(this.scale.x !== 1 || this.scale.y !== 1) { - this._game.stage.context.scale(1, 1); - } - if(this._rotation !== 0 || this._clip) { - this._game.stage.context.translate(0, 0); - //this._game.stage.context.restore(); - } - // maybe just do this every frame regardless? - this._game.stage.context.restore(); - if(this.alpha !== 1) { - this._game.stage.context.globalAlpha = 1; - } - }; - Object.defineProperty(Camera.prototype, "backgroundColor", { - get: function () { - return this._bgColor; - }, - set: function (color) { - this._bgColor = color; - }, - enumerable: true, - configurable: true - }); - Camera.prototype.setTexture = function (key, repeat) { - if (typeof repeat === "undefined") { repeat = 'repeat'; } - this._bgTexture = this._game.stage.context.createPattern(this._game.cache.getImage(key), repeat); - this._bgTextureRepeat = repeat; - }; - Camera.prototype.setPosition = function (x, y) { - this._stageX = x; - this._stageY = y; - this.checkClip(); - }; - Camera.prototype.setSize = function (width, height) { - this.worldView.width = width; - this.worldView.height = height; - this.checkClip(); - }; - Camera.prototype.renderDebugInfo = function (x, y, color) { - if (typeof color === "undefined") { color = 'rgb(255,255,255)'; } - this._game.stage.context.fillStyle = color; - this._game.stage.context.fillText('Camera ID: ' + this.ID + ' (' + this.worldView.width + ' x ' + this.worldView.height + ')', x, y); - this._game.stage.context.fillText('X: ' + this._stageX + ' Y: ' + this._stageY + ' Rotation: ' + this._rotation, x, y + 14); - this._game.stage.context.fillText('World X: ' + this.scroll.x.toFixed(1) + ' World Y: ' + this.scroll.y.toFixed(1), x, y + 28); - if(this.bounds) { - this._game.stage.context.fillText('Bounds: ' + this.bounds.width + ' x ' + this.bounds.height, x, y + 56); - } - }; - Object.defineProperty(Camera.prototype, "x", { - get: function () { - return this._stageX; - }, - set: function (value) { - this._stageX = value; - this.checkClip(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "y", { - get: function () { - return this._stageY; - }, - set: function (value) { - this._stageY = value; - this.checkClip(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "width", { - get: function () { - return this.worldView.width; - }, - set: function (value) { - this.worldView.width = value; - this.checkClip(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "height", { - get: function () { - return this.worldView.height; - }, - set: function (value) { - this.worldView.height = value; - this.checkClip(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "rotation", { - get: function () { - return this._rotation; - }, - set: function (value) { - this._rotation = this._game.math.wrap(value, 360, 0); - }, - enumerable: true, - configurable: true - }); - Camera.prototype.checkClip = function () { - if(this._stageX !== 0 || this._stageY !== 0 || this.worldView.width < this._game.stage.width || this.worldView.height < this._game.stage.height) { - this._clip = true; - } else { - this._clip = false; - } - }; - return Camera; - })(); - Phaser.Camera = Camera; -})(Phaser || (Phaser = {})); -/// -/// -/// -/// -/** -* Phaser - Sprite -* -* The Sprite GameObject is an extension of the core GameObject that includes support for animation and dynamic textures. -* It's probably the most used GameObject of all. -*/ -var Phaser; -(function (Phaser) { - var Sprite = (function (_super) { - __extends(Sprite, _super); - function Sprite(game, x, y, key) { - if (typeof x === "undefined") { x = 0; } - if (typeof y === "undefined") { y = 0; } - if (typeof key === "undefined") { key = null; } - _super.call(this, game, x, y); - this._dynamicTexture = false; - // local rendering related temp vars to help avoid gc spikes - this._sx = 0; - this._sy = 0; - this._sw = 0; - this._sh = 0; - this._dx = 0; - this._dy = 0; - this._dw = 0; - this._dh = 0; - this.renderDebug = false; - this.renderDebugColor = 'rgba(0,255,0,0.5)'; - this.renderDebugPointColor = 'rgba(255,255,255,1)'; - this.flipped = false; - this._texture = null; - this.animations = new Phaser.AnimationManager(this._game, this); - if(key !== null) { - this.loadGraphic(key); - } else { - this.bounds.width = 16; - this.bounds.height = 16; - } - } - Sprite.prototype.loadGraphic = function (key) { - if(this._game.cache.getImage(key) !== null) { - if(this._game.cache.isSpriteSheet(key) == false) { - this._texture = this._game.cache.getImage(key); - this.bounds.width = this._texture.width; - this.bounds.height = this._texture.height; - } else { - this._texture = this._game.cache.getImage(key); - this.animations.loadFrameData(this._game.cache.getFrameData(key)); - } - this._dynamicTexture = false; - } - return this; - }; - Sprite.prototype.loadDynamicTexture = function (texture) { - this._texture = texture; - this.bounds.width = this._texture.width; - this.bounds.height = this._texture.height; - this._dynamicTexture = true; - return this; - }; - Sprite.prototype.makeGraphic = function (width, height, color) { - if (typeof color === "undefined") { color = 0xffffffff; } - this._texture = null; - this.width = width; - this.height = height; - this._dynamicTexture = false; - return this; - }; - Sprite.prototype.inCamera = function (camera) { - if(this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0) { - this._dx = this.bounds.x - (camera.x * this.scrollFactor.x); - this._dy = this.bounds.y - (camera.y * this.scrollFactor.x); - this._dw = this.bounds.width * this.scale.x; - this._dh = this.bounds.height * this.scale.y; - return (camera.right > this._dx) && (camera.x < this._dx + this._dw) && (camera.bottom > this._dy) && (camera.y < this._dy + this._dh); - } else { - return camera.intersects(this.bounds, this.bounds.length); - } - }; - Sprite.prototype.postUpdate = function () { - this.animations.update(); - _super.prototype.postUpdate.call(this); - }; - Object.defineProperty(Sprite.prototype, "frame", { - get: function () { - return this.animations.frame; - }, - set: function (value) { - this.animations.frame = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Sprite.prototype, "frameName", { - get: function () { - return this.animations.frameName; - }, - set: function (value) { - this.animations.frameName = value; - }, - enumerable: true, - configurable: true - }); - Sprite.prototype.render = function (camera, cameraOffsetX, cameraOffsetY) { - // Render checks - if(this.visible == false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1 || this.cameraBlacklist.indexOf(camera.ID) !== -1 || this.inCamera(camera.worldView) == false) { - return false; - } - // Alpha - if(this.alpha !== 1) { - var globalAlpha = this._game.stage.context.globalAlpha; - this._game.stage.context.globalAlpha = this.alpha; - } - this._sx = 0; - this._sy = 0; - this._sw = this.bounds.width; - this._sh = this.bounds.height; - this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x); - this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y); - this._dw = this.bounds.width * this.scale.x; - this._dh = this.bounds.height * this.scale.y; - if(this.align == Phaser.GameObject.ALIGN_TOP_CENTER) { - this._dx -= this.bounds.halfWidth * this.scale.x; - } else if(this.align == Phaser.GameObject.ALIGN_TOP_RIGHT) { - this._dx -= this.bounds.width * this.scale.x; - } else if(this.align == Phaser.GameObject.ALIGN_CENTER_LEFT) { - this._dy -= this.bounds.halfHeight * this.scale.y; - } else if(this.align == Phaser.GameObject.ALIGN_CENTER) { - this._dx -= this.bounds.halfWidth * this.scale.x; - this._dy -= this.bounds.halfHeight * this.scale.y; - } else if(this.align == Phaser.GameObject.ALIGN_CENTER_RIGHT) { - this._dx -= this.bounds.width * this.scale.x; - this._dy -= this.bounds.halfHeight * this.scale.y; - } else if(this.align == Phaser.GameObject.ALIGN_BOTTOM_LEFT) { - this._dy -= this.bounds.height * this.scale.y; - } else if(this.align == Phaser.GameObject.ALIGN_BOTTOM_CENTER) { - this._dx -= this.bounds.halfWidth * this.scale.x; - this._dy -= this.bounds.height * this.scale.y; - } else if(this.align == Phaser.GameObject.ALIGN_BOTTOM_RIGHT) { - this._dx -= this.bounds.width * this.scale.x; - this._dy -= this.bounds.height * this.scale.y; - } - if(this._dynamicTexture == false && this.animations.currentFrame !== null) { - this._sx = this.animations.currentFrame.x; - this._sy = this.animations.currentFrame.y; - if(this.animations.currentFrame.trimmed) { - this._dx += this.animations.currentFrame.spriteSourceSizeX; - this._dy += this.animations.currentFrame.spriteSourceSizeY; - } - } - // Apply camera difference - if(this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0) { - this._dx -= (camera.worldView.x * this.scrollFactor.x); - this._dy -= (camera.worldView.y * this.scrollFactor.y); - } - // Rotation - needs to work from origin point really, but for now from center - if(this.angle !== 0 || this.rotationOffset !== 0 || this.flipped == true) { - this._game.stage.context.save(); - this._game.stage.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2)); - if(this.angle !== 0 || this.rotationOffset !== 0) { - this._game.stage.context.rotate((this.rotationOffset + this.angle) * (Math.PI / 180)); - } - this._dx = -(this._dw / 2); - this._dy = -(this._dh / 2); - if(this.flipped == true) { - this._game.stage.context.scale(-1, 1); - } - } - this._sx = Math.round(this._sx); - this._sy = Math.round(this._sy); - this._sw = Math.round(this._sw); - this._sh = Math.round(this._sh); - this._dx = Math.round(this._dx); - this._dy = Math.round(this._dy); - this._dw = Math.round(this._dw); - this._dh = Math.round(this._dh); - if(this._texture != null) { - if(this._dynamicTexture) { - this._game.stage.context.drawImage(this._texture.canvas, // Source Image - this._sx, // Source X (location within the source image) - this._sy, // Source Y - this._sw, // Source Width - this._sh, // Source Height - this._dx, // Destination X (where on the canvas it'll be drawn) - this._dy, // Destination Y - this._dw, // Destination Width (always same as Source Width unless scaled) - this._dh); - // Destination Height (always same as Source Height unless scaled) - } else { - this._game.stage.context.drawImage(this._texture, // Source Image - this._sx, // Source X (location within the source image) - this._sy, // Source Y - this._sw, // Source Width - this._sh, // Source Height - this._dx, // Destination X (where on the canvas it'll be drawn) - this._dy, // Destination Y - this._dw, // Destination Width (always same as Source Width unless scaled) - this._dh); - // Destination Height (always same as Source Height unless scaled) - } - } else { - this._game.stage.context.fillStyle = 'rgb(255,255,255)'; - this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh); - } - if(this.flipped === true || this.rotation !== 0 || this.rotationOffset !== 0) { - //this._game.stage.context.translate(0, 0); - this._game.stage.context.restore(); - } - if(this.renderDebug) { - this.renderBounds(camera, cameraOffsetX, cameraOffsetY); - } - if(globalAlpha > -1) { - this._game.stage.context.globalAlpha = globalAlpha; - } - return true; - }; - Sprite.prototype.renderBounds = // Renders the bounding box around this Sprite and the contact points. Useful for visually debugging. - function (camera, cameraOffsetX, cameraOffsetY) { - this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x); - this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y); - this._game.stage.context.fillStyle = this.renderDebugColor; - this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh); - this._game.stage.context.fillStyle = this.renderDebugPointColor; - var hw = this.bounds.halfWidth * this.scale.x; - var hh = this.bounds.halfHeight * this.scale.y; - var sw = (this.bounds.width * this.scale.x) - 1; - var sh = (this.bounds.height * this.scale.y) - 1; - this._game.stage.context.fillRect(this._dx, this._dy, 1, 1)// top left - ; - this._game.stage.context.fillRect(this._dx + hw, this._dy, 1, 1)// top center - ; - this._game.stage.context.fillRect(this._dx + sw, this._dy, 1, 1)// top right - ; - this._game.stage.context.fillRect(this._dx, this._dy + hh, 1, 1)// left center - ; - this._game.stage.context.fillRect(this._dx + hw, this._dy + hh, 1, 1)// center - ; - this._game.stage.context.fillRect(this._dx + sw, this._dy + hh, 1, 1)// right center - ; - this._game.stage.context.fillRect(this._dx, this._dy + sh, 1, 1)// bottom left - ; - this._game.stage.context.fillRect(this._dx + hw, this._dy + sh, 1, 1)// bottom center - ; - this._game.stage.context.fillRect(this._dx + sw, this._dy + sh, 1, 1)// bottom right - ; - }; - Sprite.prototype.renderDebugInfo = function (x, y, color) { - if (typeof color === "undefined") { color = 'rgb(255,255,255)'; } - this._game.stage.context.fillStyle = color; - this._game.stage.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y); - this._game.stage.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14); - this._game.stage.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28); - this._game.stage.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42); - }; - return Sprite; - })(Phaser.GameObject); - Phaser.Sprite = Sprite; -})(Phaser || (Phaser = {})); -/// -/** -* Phaser - Animation -* -* An Animation is a single animation. It is created by the AnimationManager and belongs to Sprite objects. -*/ -var Phaser; -(function (Phaser) { - var Animation = (function () { - function Animation(game, parent, frameData, name, frames, delay, looped) { - this._game = game; - this._parent = parent; - this._frames = frames; - this._frameData = frameData; - this.name = name; - this.delay = 1000 / delay; - this.looped = looped; - this.isFinished = false; - this.isPlaying = false; - this._frameIndex = 0; - this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); - } - Object.defineProperty(Animation.prototype, "frameTotal", { - get: function () { - return this._frames.length; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "frame", { - get: function () { - return this._frameIndex; - }, - set: function (value) { - this.currentFrame = this._frameData.getFrame(value); - if(this.currentFrame !== null) { - this._parent.bounds.width = this.currentFrame.width; - this._parent.bounds.height = this.currentFrame.height; - this._frameIndex = value; - } - }, - enumerable: true, - configurable: true - }); - Animation.prototype.play = function (frameRate, loop) { - if (typeof frameRate === "undefined") { frameRate = null; } - if(frameRate !== null) { - this.delay = 1000 / frameRate; - } - if(loop !== undefined) { - this.looped = loop; - } - this.isPlaying = true; - this.isFinished = false; - this._timeLastFrame = this._game.time.now; - this._timeNextFrame = this._game.time.now + this.delay; - this._frameIndex = 0; - this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); - }; - Animation.prototype.restart = function () { - this.isPlaying = true; - this.isFinished = false; - this._timeLastFrame = this._game.time.now; - this._timeNextFrame = this._game.time.now + this.delay; - this._frameIndex = 0; - this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); - }; - Animation.prototype.stop = function () { - this.isPlaying = false; - this.isFinished = true; - }; - Animation.prototype.update = function () { - if(this.isPlaying == true && this._game.time.now >= this._timeNextFrame) { - this._frameIndex++; - if(this._frameIndex == this._frames.length) { - if(this.looped) { - this._frameIndex = 0; - this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); - } else { - this.onComplete(); - } - } else { - this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); - } - this._timeLastFrame = this._game.time.now; - this._timeNextFrame = this._game.time.now + this.delay; - return true; - } - return false; - }; - Animation.prototype.destroy = function () { - this._game = null; - this._parent = null; - this._frames = null; - this._frameData = null; - this.currentFrame = null; - this.isPlaying = false; - }; - Animation.prototype.onComplete = function () { - this.isPlaying = false; - this.isFinished = true; - // callback - }; - return Animation; - })(); - Phaser.Animation = Animation; -})(Phaser || (Phaser = {})); -/// -/** -* Phaser - AnimationLoader -* -* Responsible for parsing sprite sheet and JSON data into the internal FrameData format that Phaser uses for animations. -*/ -var Phaser; -(function (Phaser) { - var AnimationLoader = (function () { - function AnimationLoader() { } - AnimationLoader.parseSpriteSheet = function parseSpriteSheet(game, key, frameWidth, frameHeight, frameMax) { - // How big is our image? - var img = game.cache.getImage(key); - if(img == null) { - return null; - } - var width = img.width; - var height = img.height; - var row = Math.round(width / frameWidth); - var column = Math.round(height / frameHeight); - var total = row * column; - if(frameMax !== -1) { - total = frameMax; - } - // Zero or smaller than frame sizes? - if(width == 0 || height == 0 || width < frameWidth || height < frameHeight || total === 0) { - return null; - } - // Let's create some frames then - var data = new Phaser.FrameData(); - var x = 0; - var y = 0; - for(var i = 0; i < total; i++) { - data.addFrame(new Phaser.Frame(x, y, frameWidth, frameHeight, '')); - x += frameWidth; - if(x === width) { - x = 0; - y += frameHeight; - } - } - return data; - }; - AnimationLoader.parseJSONData = function parseJSONData(game, json) { - // Let's create some frames then - var data = new Phaser.FrameData(); - // By this stage frames is a fully parsed array - var frames = json; - var newFrame; - for(var i = 0; i < frames.length; i++) { - newFrame = data.addFrame(new Phaser.Frame(frames[i].frame.x, frames[i].frame.y, frames[i].frame.w, frames[i].frame.h, frames[i].filename)); - newFrame.setTrim(frames[i].trimmed, frames[i].sourceSize.w, frames[i].sourceSize.h, frames[i].spriteSourceSize.x, frames[i].spriteSourceSize.y, frames[i].spriteSourceSize.w, frames[i].spriteSourceSize.h); - } - return data; - }; - return AnimationLoader; - })(); - Phaser.AnimationLoader = AnimationLoader; -})(Phaser || (Phaser = {})); -/// -/** -* Phaser - Frame -* -* A Frame is a single frame of an animation and is part of a FrameData collection. -*/ -var Phaser; -(function (Phaser) { - var Frame = (function () { - function Frame(x, y, width, height, name) { - // Useful for Texture Atlas files (is set to the filename value) - this.name = ''; - // Rotated? (not yet implemented) - this.rotated = false; - // Either cw or ccw, rotation is always 90 degrees - this.rotationDirection = 'cw'; - this.x = x; - this.y = y; - this.width = width; - this.height = height; - this.name = name; - this.rotated = false; - this.trimmed = false; - } - Frame.prototype.setRotation = function (rotated, rotationDirection) { - // Not yet supported - }; - Frame.prototype.setTrim = function (trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight) { - this.trimmed = trimmed; - this.sourceSizeW = actualWidth; - this.sourceSizeH = actualHeight; - this.spriteSourceSizeX = destX; - this.spriteSourceSizeY = destY; - this.spriteSourceSizeW = destWidth; - this.spriteSourceSizeH = destHeight; - }; - return Frame; - })(); - Phaser.Frame = Frame; -})(Phaser || (Phaser = {})); -/// -/** -* Phaser - FrameData -* -* FrameData is a container for Frame objects, the internal representation of animation data in Phaser. -*/ -var Phaser; -(function (Phaser) { - var FrameData = (function () { - function FrameData() { - this._frames = []; - this._frameNames = []; - } - Object.defineProperty(FrameData.prototype, "total", { - get: function () { - return this._frames.length; - }, - enumerable: true, - configurable: true - }); - FrameData.prototype.addFrame = function (frame) { - frame.index = this._frames.length; - this._frames.push(frame); - if(frame.name !== '') { - this._frameNames[frame.name] = frame.index; - } - return frame; - }; - FrameData.prototype.getFrame = function (index) { - if(this._frames[index]) { - return this._frames[index]; - } - return null; - }; - FrameData.prototype.getFrameByName = function (name) { - if(this._frameNames[name] >= 0) { - return this._frames[this._frameNames[name]]; - } - return null; - }; - FrameData.prototype.checkFrameName = function (name) { - if(this._frameNames[name] >= 0) { - return true; - } - return false; - }; - FrameData.prototype.getFrameRange = function (start, end, output) { - if (typeof output === "undefined") { output = []; } - for(var i = start; i <= end; i++) { - output.push(this._frames[i]); - } - return output; - }; - FrameData.prototype.getFrameIndexes = function (output) { - if (typeof output === "undefined") { output = []; } - output.length = 0; - for(var i = 0; i < this._frames.length; i++) { - output.push(i); - } - return output; - }; - FrameData.prototype.getFrameIndexesByName = function (input) { - var output = []; - for(var i = 0; i < input.length; i++) { - if(this.getFrameByName(input[i])) { - output.push(this.getFrameByName(input[i]).index); - } - } - return output; - }; - FrameData.prototype.getAllFrames = function () { - return this._frames; - }; - FrameData.prototype.getFrames = function (range) { - var output = []; - for(var i = 0; i < range.length; i++) { - output.push(this._frames[i]); - } - return output; - }; - return FrameData; - })(); - Phaser.FrameData = FrameData; -})(Phaser || (Phaser = {})); -/// -/// -/// -/// -/// -/// -/** -* Phaser - AnimationManager -* -* Any Sprite that has animation contains an instance of the AnimationManager, which is used to add, play and update -* sprite specific animations. -*/ -var Phaser; -(function (Phaser) { - var AnimationManager = (function () { - function AnimationManager(game, parent) { - this._frameData = null; - this.currentFrame = null; - this._game = game; - this._parent = parent; - this._anims = { - }; - } - AnimationManager.prototype.loadFrameData = function (frameData) { - this._frameData = frameData; - this.frame = 0; - }; - AnimationManager.prototype.add = function (name, frames, frameRate, loop, useNumericIndex) { - if (typeof frames === "undefined") { frames = null; } - if (typeof frameRate === "undefined") { frameRate = 60; } - if (typeof loop === "undefined") { loop = false; } - if (typeof useNumericIndex === "undefined") { useNumericIndex = true; } - if(this._frameData == null) { - return; - } - if(frames == null) { - frames = this._frameData.getFrameIndexes(); - } else { - if(this.validateFrames(frames, useNumericIndex) == false) { - throw Error('Invalid frames given to Animation ' + name); - return; - } - } - if(useNumericIndex == false) { - frames = this._frameData.getFrameIndexesByName(frames); - } - this._anims[name] = new Phaser.Animation(this._game, this._parent, this._frameData, name, frames, frameRate, loop); - this.currentAnim = this._anims[name]; - this.currentFrame = this.currentAnim.currentFrame; - }; - AnimationManager.prototype.validateFrames = function (frames, useNumericIndex) { - for(var i = 0; i < frames.length; i++) { - if(useNumericIndex == true) { - if(frames[i] > this._frameData.total) { - return false; - } - } else { - if(this._frameData.checkFrameName(frames[i]) == false) { - return false; - } - } - } - return true; - }; - AnimationManager.prototype.play = function (name, frameRate, loop) { - if (typeof frameRate === "undefined") { frameRate = null; } - if(this._anims[name]) { - if(this.currentAnim == this._anims[name]) { - if(this.currentAnim.isPlaying == false) { - this.currentAnim.play(frameRate, loop); - } - } else { - this.currentAnim = this._anims[name]; - this.currentAnim.play(frameRate, loop); - } - } - }; - AnimationManager.prototype.stop = function (name) { - if(this._anims[name]) { - this.currentAnim = this._anims[name]; - this.currentAnim.stop(); - } - }; - AnimationManager.prototype.update = function () { - if(this.currentAnim && this.currentAnim.update() == true) { - this.currentFrame = this.currentAnim.currentFrame; - this._parent.bounds.width = this.currentFrame.width; - this._parent.bounds.height = this.currentFrame.height; - } - }; - Object.defineProperty(AnimationManager.prototype, "frameData", { - get: function () { - return this._frameData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationManager.prototype, "frameTotal", { - get: function () { - return this._frameData.total; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationManager.prototype, "frame", { - get: function () { - return this._frameIndex; - }, - set: function (value) { - if(this._frameData.getFrame(value) !== null) { - this.currentFrame = this._frameData.getFrame(value); - this._parent.bounds.width = this.currentFrame.width; - this._parent.bounds.height = this.currentFrame.height; - this._frameIndex = value; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationManager.prototype, "frameName", { - get: function () { - return this.currentFrame.name; - }, - set: function (value) { - if(this._frameData.getFrameByName(value) !== null) { - this.currentFrame = this._frameData.getFrameByName(value); - this._parent.bounds.width = this.currentFrame.width; - this._parent.bounds.height = this.currentFrame.height; - this._frameIndex = this.currentFrame.index; - } - }, - enumerable: true, - configurable: true - }); - return AnimationManager; - })(); - Phaser.AnimationManager = AnimationManager; -})(Phaser || (Phaser = {})); -/// -/** -* Phaser - Cache -* -* A game only has one instance of a Cache and it is used to store all externally loaded assets such -* as images, sounds and data files as a result of Loader calls. Cache items use string based keys for look-up. -*/ var Phaser; (function (Phaser) { var Cache = (function () { @@ -2248,17 +157,1168 @@ var Phaser; })(); Phaser.Cache = Cache; })(Phaser || (Phaser = {})); -/// -/// -/** -* Phaser - CameraManager -* -* Your game only has one CameraManager instance and it's responsible for looking after, creating and destroying -* all of the cameras in the world. -* -* TODO: If the Camera is larger than the Stage size then the rotation offset isn't correct -* TODO: Texture Repeat doesn't scroll, because it's part of the camera not the world, need to think about this more -*/ +var Phaser; +(function (Phaser) { + var SignalBinding = (function () { + function SignalBinding(signal, listener, isOnce, listenerContext, priority) { + if (typeof priority === "undefined") { priority = 0; } + this.active = true; + this.params = null; + this._listener = listener; + this._isOnce = isOnce; + this.context = listenerContext; + this._signal = signal; + this.priority = priority || 0; + } + SignalBinding.prototype.execute = function (paramsArr) { + var handlerReturn; + var params; + if(this.active && !!this._listener) { + params = this.params ? this.params.concat(paramsArr) : paramsArr; + handlerReturn = this._listener.apply(this.context, params); + if(this._isOnce) { + this.detach(); + } + } + return handlerReturn; + }; + SignalBinding.prototype.detach = function () { + return this.isBound() ? this._signal.remove(this._listener, this.context) : null; + }; + SignalBinding.prototype.isBound = function () { + return (!!this._signal && !!this._listener); + }; + SignalBinding.prototype.isOnce = function () { + return this._isOnce; + }; + SignalBinding.prototype.getListener = function () { + return this._listener; + }; + SignalBinding.prototype.getSignal = function () { + return this._signal; + }; + SignalBinding.prototype._destroy = function () { + delete this._signal; + delete this._listener; + delete this.context; + }; + SignalBinding.prototype.toString = function () { + return '[SignalBinding isOnce:' + this._isOnce + ', isBound:' + this.isBound() + ', active:' + this.active + ']'; + }; + return SignalBinding; + })(); + Phaser.SignalBinding = SignalBinding; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Signal = (function () { + function Signal() { + this._bindings = []; + this._prevParams = null; + this.memorize = false; + this._shouldPropagate = true; + this.active = true; + } + Signal.VERSION = '1.0.0'; + Signal.prototype.validateListener = function (listener, fnName) { + if(typeof listener !== 'function') { + throw new Error('listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName)); + } + }; + Signal.prototype._registerListener = function (listener, isOnce, listenerContext, priority) { + var prevIndex = this._indexOfListener(listener, listenerContext); + var binding; + if(prevIndex !== -1) { + binding = this._bindings[prevIndex]; + if(binding.isOnce() !== isOnce) { + throw new Error('You cannot add' + (isOnce ? '' : 'Once') + '() then add' + (!isOnce ? '' : 'Once') + '() the same listener without removing the relationship first.'); + } + } else { + binding = new Phaser.SignalBinding(this, listener, isOnce, listenerContext, priority); + this._addBinding(binding); + } + if(this.memorize && this._prevParams) { + binding.execute(this._prevParams); + } + return binding; + }; + Signal.prototype._addBinding = function (binding) { + var n = this._bindings.length; + do { + --n; + }while(this._bindings[n] && binding.priority <= this._bindings[n].priority); + this._bindings.splice(n + 1, 0, binding); + }; + Signal.prototype._indexOfListener = function (listener, context) { + var n = this._bindings.length; + var cur; + while(n--) { + cur = this._bindings[n]; + if(cur.getListener() === listener && cur.context === context) { + return n; + } + } + return -1; + }; + Signal.prototype.has = function (listener, context) { + if (typeof context === "undefined") { context = null; } + return this._indexOfListener(listener, context) !== -1; + }; + Signal.prototype.add = function (listener, listenerContext, priority) { + if (typeof listenerContext === "undefined") { listenerContext = null; } + if (typeof priority === "undefined") { priority = 0; } + this.validateListener(listener, 'add'); + return this._registerListener(listener, false, listenerContext, priority); + }; + Signal.prototype.addOnce = function (listener, listenerContext, priority) { + if (typeof listenerContext === "undefined") { listenerContext = null; } + if (typeof priority === "undefined") { priority = 0; } + this.validateListener(listener, 'addOnce'); + return this._registerListener(listener, true, listenerContext, priority); + }; + Signal.prototype.remove = function (listener, context) { + if (typeof context === "undefined") { context = null; } + this.validateListener(listener, 'remove'); + var i = this._indexOfListener(listener, context); + if(i !== -1) { + this._bindings[i]._destroy(); + this._bindings.splice(i, 1); + } + return listener; + }; + Signal.prototype.removeAll = function () { + var n = this._bindings.length; + while(n--) { + this._bindings[n]._destroy(); + } + this._bindings.length = 0; + }; + Signal.prototype.getNumListeners = function () { + return this._bindings.length; + }; + Signal.prototype.halt = function () { + this._shouldPropagate = false; + }; + Signal.prototype.dispatch = function () { + var paramsArr = []; + for (var _i = 0; _i < (arguments.length - 0); _i++) { + paramsArr[_i] = arguments[_i + 0]; + } + if(!this.active) { + return; + } + var n = this._bindings.length; + var bindings; + if(this.memorize) { + this._prevParams = paramsArr; + } + if(!n) { + return; + } + bindings = this._bindings.slice(0); + this._shouldPropagate = true; + do { + n--; + }while(bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false); + }; + Signal.prototype.forget = function () { + this._prevParams = null; + }; + Signal.prototype.dispose = function () { + this.removeAll(); + delete this._bindings; + delete this._prevParams; + }; + Signal.prototype.toString = function () { + return '[Signal active:' + this.active + ' numListeners:' + this.getNumListeners() + ']'; + }; + return Signal; + })(); + Phaser.Signal = Signal; +})(Phaser || (Phaser = {})); +var __extends = this.__extends || function (d, b) { + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var Phaser; +(function (Phaser) { + var GameObject = (function (_super) { + __extends(GameObject, _super); + function GameObject(game, x, y, width, height) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof width === "undefined") { width = 16; } + if (typeof height === "undefined") { height = 16; } + _super.call(this, game); + this._angle = 0; + this.outOfBoundsAction = 0; + this.z = 0; + this.rotationOffset = 0; + this.renderRotation = true; + this.moves = true; + this.inputEnabled = false; + this._inputOver = false; + this.bounds = new Phaser.Rectangle(x, y, width, height); + this.exists = true; + this.active = true; + this.visible = true; + this.alive = true; + this.isGroup = false; + this.alpha = 1; + this.scale = new Phaser.MicroPoint(1, 1); + this.last = new Phaser.MicroPoint(x, y); + this.origin = new Phaser.MicroPoint(this.bounds.halfWidth, this.bounds.halfHeight); + this.align = GameObject.ALIGN_TOP_LEFT; + this.mass = 1.0; + this.elasticity = 0.0; + this.health = 1; + this.immovable = false; + this.moves = true; + this.worldBounds = null; + this.touching = Phaser.Collision.NONE; + this.wasTouching = Phaser.Collision.NONE; + this.allowCollisions = Phaser.Collision.ANY; + this.velocity = new Phaser.MicroPoint(); + this.acceleration = new Phaser.MicroPoint(); + this.drag = new Phaser.MicroPoint(); + this.maxVelocity = new Phaser.MicroPoint(10000, 10000); + this.angle = 0; + this.angularVelocity = 0; + this.angularAcceleration = 0; + this.angularDrag = 0; + this.maxAngular = 10000; + this.cameraBlacklist = []; + this.scrollFactor = new Phaser.MicroPoint(1.0, 1.0); + } + GameObject.ALIGN_TOP_LEFT = 0; + GameObject.ALIGN_TOP_CENTER = 1; + GameObject.ALIGN_TOP_RIGHT = 2; + GameObject.ALIGN_CENTER_LEFT = 3; + GameObject.ALIGN_CENTER = 4; + GameObject.ALIGN_CENTER_RIGHT = 5; + GameObject.ALIGN_BOTTOM_LEFT = 6; + GameObject.ALIGN_BOTTOM_CENTER = 7; + GameObject.ALIGN_BOTTOM_RIGHT = 8; + GameObject.OUT_OF_BOUNDS_STOP = 0; + GameObject.OUT_OF_BOUNDS_KILL = 1; + GameObject.prototype.preUpdate = function () { + this.last.x = this.bounds.x; + this.last.y = this.bounds.y; + }; + GameObject.prototype.update = function () { + }; + GameObject.prototype.postUpdate = function () { + if(this.moves) { + this.updateMotion(); + } + if(this.worldBounds != null) { + if(this.outOfBoundsAction == GameObject.OUT_OF_BOUNDS_KILL) { + if(this.x < this.worldBounds.x || this.x > this.worldBounds.right || this.y < this.worldBounds.y || this.y > this.worldBounds.bottom) { + this.kill(); + } + } else { + if(this.x < this.worldBounds.x) { + this.x = this.worldBounds.x; + } else if(this.x > this.worldBounds.right) { + this.x = this.worldBounds.right; + } + if(this.y < this.worldBounds.y) { + this.y = this.worldBounds.y; + } else if(this.y > this.worldBounds.bottom) { + this.y = this.worldBounds.bottom; + } + } + } + if(this.inputEnabled) { + this.updateInput(); + } + this.wasTouching = this.touching; + this.touching = Phaser.Collision.NONE; + }; + GameObject.prototype.updateInput = function () { + }; + GameObject.prototype.updateMotion = function () { + var delta; + var velocityDelta; + velocityDelta = (this._game.motion.computeVelocity(this.angularVelocity, this.angularAcceleration, this.angularDrag, this.maxAngular) - this.angularVelocity) / 2; + this.angularVelocity += velocityDelta; + this._angle += this.angularVelocity * this._game.time.elapsed; + this.angularVelocity += velocityDelta; + velocityDelta = (this._game.motion.computeVelocity(this.velocity.x, this.acceleration.x, this.drag.x, this.maxVelocity.x) - this.velocity.x) / 2; + this.velocity.x += velocityDelta; + delta = this.velocity.x * this._game.time.elapsed; + this.velocity.x += velocityDelta; + this.bounds.x += delta; + velocityDelta = (this._game.motion.computeVelocity(this.velocity.y, this.acceleration.y, this.drag.y, this.maxVelocity.y) - this.velocity.y) / 2; + this.velocity.y += velocityDelta; + delta = this.velocity.y * this._game.time.elapsed; + this.velocity.y += velocityDelta; + this.bounds.y += delta; + }; + GameObject.prototype.overlaps = function (ObjectOrGroup, InScreenSpace, Camera) { + if (typeof InScreenSpace === "undefined") { InScreenSpace = false; } + if (typeof Camera === "undefined") { Camera = null; } + if(ObjectOrGroup.isGroup) { + var results = false; + var i = 0; + var members = ObjectOrGroup.members; + while(i < length) { + if(this.overlaps(members[i++], InScreenSpace, Camera)) { + results = true; + } + } + return results; + } + if(!InScreenSpace) { + return (ObjectOrGroup.x + ObjectOrGroup.width > this.x) && (ObjectOrGroup.x < this.x + this.width) && (ObjectOrGroup.y + ObjectOrGroup.height > this.y) && (ObjectOrGroup.y < this.y + this.height); + } + if(Camera == null) { + Camera = this._game.camera; + } + var objectScreenPos = ObjectOrGroup.getScreenXY(null, Camera); + this.getScreenXY(this._point, Camera); + return (objectScreenPos.x + ObjectOrGroup.width > this._point.x) && (objectScreenPos.x < this._point.x + this.width) && (objectScreenPos.y + ObjectOrGroup.height > this._point.y) && (objectScreenPos.y < this._point.y + this.height); + }; + GameObject.prototype.overlapsAt = function (X, Y, ObjectOrGroup, InScreenSpace, Camera) { + if (typeof InScreenSpace === "undefined") { InScreenSpace = false; } + if (typeof Camera === "undefined") { Camera = null; } + if(ObjectOrGroup.isGroup) { + var results = false; + var basic; + var i = 0; + var members = ObjectOrGroup.members; + while(i < length) { + if(this.overlapsAt(X, Y, members[i++], InScreenSpace, Camera)) { + results = true; + } + } + return results; + } + if(!InScreenSpace) { + return (ObjectOrGroup.x + ObjectOrGroup.width > X) && (ObjectOrGroup.x < X + this.width) && (ObjectOrGroup.y + ObjectOrGroup.height > Y) && (ObjectOrGroup.y < Y + this.height); + } + if(Camera == null) { + Camera = this._game.camera; + } + var objectScreenPos = ObjectOrGroup.getScreenXY(null, Camera); + this._point.x = X - Camera.scroll.x * this.scrollFactor.x; + this._point.y = Y - Camera.scroll.y * this.scrollFactor.y; + this._point.x += (this._point.x > 0) ? 0.0000001 : -0.0000001; + this._point.y += (this._point.y > 0) ? 0.0000001 : -0.0000001; + return (objectScreenPos.x + ObjectOrGroup.width > this._point.x) && (objectScreenPos.x < this._point.x + this.width) && (objectScreenPos.y + ObjectOrGroup.height > this._point.y) && (objectScreenPos.y < this._point.y + this.height); + }; + GameObject.prototype.overlapsPoint = function (point, InScreenSpace, Camera) { + if (typeof InScreenSpace === "undefined") { InScreenSpace = false; } + if (typeof Camera === "undefined") { Camera = null; } + if(!InScreenSpace) { + return (point.x > this.x) && (point.x < this.x + this.width) && (point.y > this.y) && (point.y < this.y + this.height); + } + if(Camera == null) { + Camera = this._game.camera; + } + var X = point.x - Camera.scroll.x; + var Y = point.y - Camera.scroll.y; + this.getScreenXY(this._point, Camera); + return (X > this._point.x) && (X < this._point.x + this.width) && (Y > this._point.y) && (Y < this._point.y + this.height); + }; + GameObject.prototype.onScreen = function (Camera) { + if (typeof Camera === "undefined") { Camera = null; } + if(Camera == null) { + Camera = this._game.camera; + } + this.getScreenXY(this._point, Camera); + return (this._point.x + this.width > 0) && (this._point.x < Camera.width) && (this._point.y + this.height > 0) && (this._point.y < Camera.height); + }; + GameObject.prototype.getScreenXY = function (point, Camera) { + if (typeof point === "undefined") { point = null; } + if (typeof Camera === "undefined") { Camera = null; } + if(point == null) { + point = new Phaser.MicroPoint(); + } + if(Camera == null) { + Camera = this._game.camera; + } + point.x = this.x - Camera.scroll.x * this.scrollFactor.x; + point.y = this.y - Camera.scroll.y * this.scrollFactor.y; + point.x += (point.x > 0) ? 0.0000001 : -0.0000001; + point.y += (point.y > 0) ? 0.0000001 : -0.0000001; + return point; + }; + Object.defineProperty(GameObject.prototype, "solid", { + get: function () { + return (this.allowCollisions & Phaser.Collision.ANY) > Phaser.Collision.NONE; + }, + set: function (Solid) { + if(Solid) { + this.allowCollisions = Phaser.Collision.ANY; + } else { + this.allowCollisions = Phaser.Collision.NONE; + } + }, + enumerable: true, + configurable: true + }); + GameObject.prototype.getMidpoint = function (point) { + if (typeof point === "undefined") { point = null; } + if(point == null) { + point = new Phaser.MicroPoint(); + } + point.copyFrom(this.bounds.center); + return point; + }; + GameObject.prototype.reset = function (X, Y) { + this.revive(); + this.touching = Phaser.Collision.NONE; + this.wasTouching = Phaser.Collision.NONE; + this.x = X; + this.y = Y; + this.last.x = X; + this.last.y = Y; + this.velocity.x = 0; + this.velocity.y = 0; + }; + GameObject.prototype.isTouching = function (Direction) { + return (this.touching & Direction) > Phaser.Collision.NONE; + }; + GameObject.prototype.justTouched = function (Direction) { + return ((this.touching & Direction) > Phaser.Collision.NONE) && ((this.wasTouching & Direction) <= Phaser.Collision.NONE); + }; + GameObject.prototype.hurt = function (Damage) { + this.health = this.health - Damage; + if(this.health <= 0) { + this.kill(); + } + }; + GameObject.prototype.setBounds = function (x, y, width, height) { + this.worldBounds = new Phaser.Quad(x, y, width, height); + }; + GameObject.prototype.hideFromCamera = function (camera) { + if(this.cameraBlacklist.indexOf(camera.ID) == -1) { + this.cameraBlacklist.push(camera.ID); + } + }; + GameObject.prototype.showToCamera = function (camera) { + if(this.cameraBlacklist.indexOf(camera.ID) !== -1) { + this.cameraBlacklist.slice(this.cameraBlacklist.indexOf(camera.ID), 1); + } + }; + GameObject.prototype.clearCameraList = function () { + this.cameraBlacklist.length = 0; + }; + GameObject.prototype.destroy = function () { + }; + Object.defineProperty(GameObject.prototype, "x", { + get: function () { + return this.bounds.x; + }, + set: function (value) { + this.bounds.x = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(GameObject.prototype, "y", { + get: function () { + return this.bounds.y; + }, + set: function (value) { + this.bounds.y = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(GameObject.prototype, "rotation", { + get: function () { + return this._angle; + }, + set: function (value) { + this._angle = this._game.math.wrap(value, 360, 0); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(GameObject.prototype, "angle", { + get: function () { + return this._angle; + }, + set: function (value) { + this._angle = this._game.math.wrap(value, 360, 0); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(GameObject.prototype, "width", { + get: function () { + return this.bounds.width; + }, + set: function (value) { + this.bounds.width = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(GameObject.prototype, "height", { + get: function () { + return this.bounds.height; + }, + set: function (value) { + this.bounds.height = value; + }, + enumerable: true, + configurable: true + }); + return GameObject; + })(Phaser.Basic); + Phaser.GameObject = GameObject; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Sprite = (function (_super) { + __extends(Sprite, _super); + function Sprite(game, x, y, key) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof key === "undefined") { key = null; } + _super.call(this, game, x, y); + this._dynamicTexture = false; + this._sx = 0; + this._sy = 0; + this._sw = 0; + this._sh = 0; + this._dx = 0; + this._dy = 0; + this._dw = 0; + this._dh = 0; + this.renderDebug = false; + this.renderDebugColor = 'rgba(0,255,0,0.5)'; + this.renderDebugPointColor = 'rgba(255,255,255,1)'; + this.flipped = false; + this._texture = null; + this.animations = new Phaser.AnimationManager(this._game, this); + if(key !== null) { + this.loadGraphic(key); + } else { + this.bounds.width = 16; + this.bounds.height = 16; + } + } + Sprite.prototype.loadGraphic = function (key) { + if(this._game.cache.getImage(key) !== null) { + if(this._game.cache.isSpriteSheet(key) == false) { + this._texture = this._game.cache.getImage(key); + this.bounds.width = this._texture.width; + this.bounds.height = this._texture.height; + } else { + this._texture = this._game.cache.getImage(key); + this.animations.loadFrameData(this._game.cache.getFrameData(key)); + } + this._dynamicTexture = false; + } + return this; + }; + Sprite.prototype.loadDynamicTexture = function (texture) { + this._texture = texture; + this.bounds.width = this._texture.width; + this.bounds.height = this._texture.height; + this._dynamicTexture = true; + return this; + }; + Sprite.prototype.makeGraphic = function (width, height, color) { + if (typeof color === "undefined") { color = 0xffffffff; } + this._texture = null; + this.width = width; + this.height = height; + this._dynamicTexture = false; + return this; + }; + Sprite.prototype.inCamera = function (camera) { + if(this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0) { + this._dx = this.bounds.x - (camera.x * this.scrollFactor.x); + this._dy = this.bounds.y - (camera.y * this.scrollFactor.x); + this._dw = this.bounds.width * this.scale.x; + this._dh = this.bounds.height * this.scale.y; + return (camera.right > this._dx) && (camera.x < this._dx + this._dw) && (camera.bottom > this._dy) && (camera.y < this._dy + this._dh); + } else { + return camera.intersects(this.bounds, this.bounds.length); + } + }; + Sprite.prototype.postUpdate = function () { + this.animations.update(); + _super.prototype.postUpdate.call(this); + }; + Object.defineProperty(Sprite.prototype, "frame", { + get: function () { + return this.animations.frame; + }, + set: function (value) { + this.animations.frame = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Sprite.prototype, "frameName", { + get: function () { + return this.animations.frameName; + }, + set: function (value) { + this.animations.frameName = value; + }, + enumerable: true, + configurable: true + }); + Sprite.prototype.render = function (camera, cameraOffsetX, cameraOffsetY) { + if(this.visible == false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1 || this.cameraBlacklist.indexOf(camera.ID) !== -1 || this.inCamera(camera.worldView) == false) { + return false; + } + if(this.alpha !== 1) { + var globalAlpha = this._game.stage.context.globalAlpha; + this._game.stage.context.globalAlpha = this.alpha; + } + this._sx = 0; + this._sy = 0; + this._sw = this.bounds.width; + this._sh = this.bounds.height; + this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x); + this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y); + this._dw = this.bounds.width * this.scale.x; + this._dh = this.bounds.height * this.scale.y; + if(this.align == Phaser.GameObject.ALIGN_TOP_CENTER) { + this._dx -= this.bounds.halfWidth * this.scale.x; + } else if(this.align == Phaser.GameObject.ALIGN_TOP_RIGHT) { + this._dx -= this.bounds.width * this.scale.x; + } else if(this.align == Phaser.GameObject.ALIGN_CENTER_LEFT) { + this._dy -= this.bounds.halfHeight * this.scale.y; + } else if(this.align == Phaser.GameObject.ALIGN_CENTER) { + this._dx -= this.bounds.halfWidth * this.scale.x; + this._dy -= this.bounds.halfHeight * this.scale.y; + } else if(this.align == Phaser.GameObject.ALIGN_CENTER_RIGHT) { + this._dx -= this.bounds.width * this.scale.x; + this._dy -= this.bounds.halfHeight * this.scale.y; + } else if(this.align == Phaser.GameObject.ALIGN_BOTTOM_LEFT) { + this._dy -= this.bounds.height * this.scale.y; + } else if(this.align == Phaser.GameObject.ALIGN_BOTTOM_CENTER) { + this._dx -= this.bounds.halfWidth * this.scale.x; + this._dy -= this.bounds.height * this.scale.y; + } else if(this.align == Phaser.GameObject.ALIGN_BOTTOM_RIGHT) { + this._dx -= this.bounds.width * this.scale.x; + this._dy -= this.bounds.height * this.scale.y; + } + if(this._dynamicTexture == false && this.animations.currentFrame !== null) { + this._sx = this.animations.currentFrame.x; + this._sy = this.animations.currentFrame.y; + if(this.animations.currentFrame.trimmed) { + this._dx += this.animations.currentFrame.spriteSourceSizeX; + this._dy += this.animations.currentFrame.spriteSourceSizeY; + } + } + if(this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0) { + this._dx -= (camera.worldView.x * this.scrollFactor.x); + this._dy -= (camera.worldView.y * this.scrollFactor.y); + } + if(this.angle !== 0 || this.rotationOffset !== 0 || this.flipped == true) { + this._game.stage.context.save(); + this._game.stage.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2)); + if(this.renderRotation == true && (this.angle !== 0 || this.rotationOffset !== 0)) { + this._game.stage.context.rotate((this.rotationOffset + this.angle) * (Math.PI / 180)); + } + this._dx = -(this._dw / 2); + this._dy = -(this._dh / 2); + if(this.flipped == true) { + this._game.stage.context.scale(-1, 1); + } + } + this._sx = Math.round(this._sx); + this._sy = Math.round(this._sy); + this._sw = Math.round(this._sw); + this._sh = Math.round(this._sh); + this._dx = Math.round(this._dx); + this._dy = Math.round(this._dy); + this._dw = Math.round(this._dw); + this._dh = Math.round(this._dh); + if(this._texture != null) { + if(this._dynamicTexture) { + this._game.stage.context.drawImage(this._texture.canvas, this._sx, this._sy, this._sw, this._sh, this._dx, this._dy, this._dw, this._dh); + } else { + this._game.stage.context.drawImage(this._texture, this._sx, this._sy, this._sw, this._sh, this._dx, this._dy, this._dw, this._dh); + } + } else { + this._game.stage.context.fillStyle = 'rgb(255,255,255)'; + this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh); + } + if(this.flipped === true || this.rotation !== 0 || this.rotationOffset !== 0) { + this._game.stage.context.restore(); + } + if(this.renderDebug) { + this.renderBounds(camera, cameraOffsetX, cameraOffsetY); + } + if(globalAlpha > -1) { + this._game.stage.context.globalAlpha = globalAlpha; + } + return true; + }; + Sprite.prototype.renderBounds = function (camera, cameraOffsetX, cameraOffsetY) { + this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x); + this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y); + this._game.stage.context.fillStyle = this.renderDebugColor; + this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh); + this._game.stage.context.fillStyle = this.renderDebugPointColor; + var hw = this.bounds.halfWidth * this.scale.x; + var hh = this.bounds.halfHeight * this.scale.y; + var sw = (this.bounds.width * this.scale.x) - 1; + var sh = (this.bounds.height * this.scale.y) - 1; + this._game.stage.context.fillRect(this._dx, this._dy, 1, 1); + this._game.stage.context.fillRect(this._dx + hw, this._dy, 1, 1); + this._game.stage.context.fillRect(this._dx + sw, this._dy, 1, 1); + this._game.stage.context.fillRect(this._dx, this._dy + hh, 1, 1); + this._game.stage.context.fillRect(this._dx + hw, this._dy + hh, 1, 1); + this._game.stage.context.fillRect(this._dx + sw, this._dy + hh, 1, 1); + this._game.stage.context.fillRect(this._dx, this._dy + sh, 1, 1); + this._game.stage.context.fillRect(this._dx + hw, this._dy + sh, 1, 1); + this._game.stage.context.fillRect(this._dx + sw, this._dy + sh, 1, 1); + }; + Sprite.prototype.renderDebugInfo = function (x, y, color) { + if (typeof color === "undefined") { color = 'rgb(255,255,255)'; } + this._game.stage.context.fillStyle = color; + this._game.stage.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y); + this._game.stage.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14); + this._game.stage.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28); + this._game.stage.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42); + }; + return Sprite; + })(Phaser.GameObject); + Phaser.Sprite = Sprite; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Camera = (function () { + function Camera(game, id, x, y, width, height) { + this._clip = false; + this._rotation = 0; + this._target = null; + this._sx = 0; + this._sy = 0; + this._fxFlashComplete = null; + this._fxFlashDuration = 0; + this._fxFlashAlpha = 0; + this._fxFadeComplete = null; + this._fxFadeDuration = 0; + this._fxFadeAlpha = 0; + this._fxShakeIntensity = 0; + this._fxShakeDuration = 0; + this._fxShakeComplete = null; + this._fxShakeOffset = new Phaser.Point(0, 0); + this._fxShakeDirection = 0; + this._fxShakePrevX = 0; + this._fxShakePrevY = 0; + this.scale = new Phaser.Point(1, 1); + this.scroll = new Phaser.Point(0, 0); + this.bounds = null; + this.deadzone = null; + this.showBorder = false; + this.borderColor = 'rgb(255,255,255)'; + this.opaque = true; + this._bgColor = 'rgb(0,0,0)'; + this._bgTextureRepeat = 'repeat'; + this.showShadow = false; + this.shadowColor = 'rgb(0,0,0)'; + this.shadowBlur = 10; + this.shadowOffset = new Phaser.Point(4, 4); + this.visible = true; + this.alpha = 1; + this.inputX = 0; + this.inputY = 0; + this._game = game; + this.ID = id; + this._stageX = x; + this._stageY = y; + this.worldView = new Phaser.Rectangle(0, 0, width, height); + this.checkClip(); + } + Camera.STYLE_LOCKON = 0; + Camera.STYLE_PLATFORMER = 1; + Camera.STYLE_TOPDOWN = 2; + Camera.STYLE_TOPDOWN_TIGHT = 3; + Camera.SHAKE_BOTH_AXES = 0; + Camera.SHAKE_HORIZONTAL_ONLY = 1; + Camera.SHAKE_VERTICAL_ONLY = 2; + Camera.prototype.flash = 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) { + 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; + }; + Camera.prototype.fade = 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) { + 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; + }; + Camera.prototype.shake = 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 = Camera.SHAKE_BOTH_AXES; } + if(!force && ((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0))) { + return; + } + if(this._fxShakeOffset.x == 0 && this._fxShakeOffset.y == 0) { + this._fxShakePrevX = this._stageX; + this._fxShakePrevY = this._stageY; + } + this._fxShakeIntensity = intensity; + this._fxShakeDuration = duration; + this._fxShakeComplete = onComplete; + this._fxShakeDirection = direction; + this._fxShakeOffset.setTo(0, 0); + }; + Camera.prototype.stopFX = function () { + this._fxFlashAlpha = 0; + this._fxFadeAlpha = 0; + if(this._fxShakeDuration !== 0) { + this._fxShakeDuration = 0; + this._fxShakeOffset.setTo(0, 0); + this._stageX = this._fxShakePrevX; + this._stageY = this._fxShakePrevY; + } + }; + Camera.prototype.follow = function (target, style) { + if (typeof style === "undefined") { style = Camera.STYLE_LOCKON; } + this._target = target; + var helper; + switch(style) { + case Camera.STYLE_PLATFORMER: + var w = this.width / 8; + var h = this.height / 3; + this.deadzone = new Phaser.Rectangle((this.width - w) / 2, (this.height - h) / 2 - h * 0.25, w, h); + break; + case Camera.STYLE_TOPDOWN: + helper = Math.max(this.width, this.height) / 4; + this.deadzone = new Phaser.Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper); + break; + case Camera.STYLE_TOPDOWN_TIGHT: + helper = Math.max(this.width, this.height) / 8; + this.deadzone = new Phaser.Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper); + break; + case Camera.STYLE_LOCKON: + default: + this.deadzone = null; + break; + } + }; + Camera.prototype.focusOnXY = function (x, y) { + x += (x > 0) ? 0.0000001 : -0.0000001; + y += (y > 0) ? 0.0000001 : -0.0000001; + this.scroll.x = Math.round(x - this.worldView.halfWidth); + this.scroll.y = Math.round(y - this.worldView.halfHeight); + }; + Camera.prototype.focusOn = function (point) { + point.x += (point.x > 0) ? 0.0000001 : -0.0000001; + point.y += (point.y > 0) ? 0.0000001 : -0.0000001; + this.scroll.x = Math.round(point.x - this.worldView.halfWidth); + this.scroll.y = Math.round(point.y - this.worldView.halfHeight); + }; + Camera.prototype.setBounds = function (x, y, width, height) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof width === "undefined") { width = 0; } + if (typeof height === "undefined") { height = 0; } + if(this.bounds == null) { + this.bounds = new Phaser.Rectangle(); + } + this.bounds.setTo(x, y, width, height); + this.worldView.setTo(x, y, width, height); + this.scroll.setTo(0, 0); + this.update(); + }; + Camera.prototype.update = function () { + if(this._target !== null) { + if(this.deadzone == null) { + this.focusOnXY(this._target.x + this._target.origin.x, this._target.y + this._target.origin.y); + } else { + var edge; + var targetX = this._target.x + ((this._target.x > 0) ? 0.0000001 : -0.0000001); + var targetY = this._target.y + ((this._target.y > 0) ? 0.0000001 : -0.0000001); + edge = targetX - this.deadzone.x; + if(this.scroll.x > edge) { + this.scroll.x = edge; + } + edge = targetX + this._target.width - this.deadzone.x - this.deadzone.width; + if(this.scroll.x < edge) { + this.scroll.x = edge; + } + edge = targetY - this.deadzone.y; + if(this.scroll.y > edge) { + this.scroll.y = edge; + } + edge = targetY + this._target.height - this.deadzone.y - this.deadzone.height; + if(this.scroll.y < edge) { + this.scroll.y = edge; + } + } + } + if(this.bounds !== null) { + if(this.scroll.x < this.bounds.left) { + this.scroll.x = this.bounds.left; + } + if(this.scroll.x > this.bounds.right - this.width) { + this.scroll.x = (this.bounds.right - this.width) + 1; + } + if(this.scroll.y < this.bounds.top) { + this.scroll.y = this.bounds.top; + } + if(this.scroll.y > this.bounds.bottom - this.height) { + this.scroll.y = (this.bounds.bottom - this.height) + 1; + } + } + this.worldView.x = this.scroll.x; + this.worldView.y = this.scroll.y; + this.inputX = this.worldView.x + this._game.input.x; + this.inputY = this.worldView.y + this._game.input.y; + if(this._fxFlashAlpha > 0) { + this._fxFlashAlpha -= this._game.time.elapsed / this._fxFlashDuration; + this._fxFlashAlpha = this._game.math.roundTo(this._fxFlashAlpha, -2); + if(this._fxFlashAlpha <= 0) { + this._fxFlashAlpha = 0; + if(this._fxFlashComplete !== null) { + this._fxFlashComplete(); + } + } + } + if(this._fxFadeAlpha > 0) { + this._fxFadeAlpha += this._game.time.elapsed / this._fxFadeDuration; + this._fxFadeAlpha = this._game.math.roundTo(this._fxFadeAlpha, -2); + if(this._fxFadeAlpha >= 1) { + this._fxFadeAlpha = 1; + if(this._fxFadeComplete !== null) { + this._fxFadeComplete(); + } + } + } + if(this._fxShakeDuration > 0) { + this._fxShakeDuration -= this._game.time.elapsed; + this._fxShakeDuration = this._game.math.roundTo(this._fxShakeDuration, -2); + if(this._fxShakeDuration <= 0) { + this._fxShakeDuration = 0; + this._fxShakeOffset.setTo(0, 0); + this._stageX = this._fxShakePrevX; + this._stageY = this._fxShakePrevY; + if(this._fxShakeComplete != null) { + this._fxShakeComplete(); + } + } else { + if((this._fxShakeDirection == Camera.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Camera.SHAKE_HORIZONTAL_ONLY)) { + this._fxShakeOffset.x = (this._game.math.random() * this._fxShakeIntensity * this.worldView.width * 2 - this._fxShakeIntensity * this.worldView.width); + } + if((this._fxShakeDirection == Camera.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Camera.SHAKE_VERTICAL_ONLY)) { + this._fxShakeOffset.y = (this._game.math.random() * this._fxShakeIntensity * this.worldView.height * 2 - this._fxShakeIntensity * this.worldView.height); + } + } + } + }; + Camera.prototype.render = function () { + if(this.visible === false || this.alpha < 0.1) { + return; + } + if((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0)) { + this._stageX = this._fxShakePrevX + (this.worldView.halfWidth) + this._fxShakeOffset.x; + this._stageY = this._fxShakePrevY + (this.worldView.halfHeight) + this._fxShakeOffset.y; + } + this._game.stage.context.save(); + if(this.alpha !== 1) { + this._game.stage.context.globalAlpha = this.alpha; + } + this._sx = this._stageX; + this._sy = this._stageY; + if(this.showShadow) { + 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; + } + if(this.scale.x !== 1 || this.scale.y !== 1) { + this._game.stage.context.scale(this.scale.x, this.scale.y); + this._sx = this._sx / this.scale.x; + this._sy = this._sy / this.scale.y; + } + if(this._rotation !== 0) { + this._game.stage.context.translate(this._sx + this.worldView.halfWidth, this._sy + this.worldView.halfHeight); + this._game.stage.context.rotate(this._rotation * (Math.PI / 180)); + this._game.stage.context.translate(-(this._sx + this.worldView.halfWidth), -(this._sy + this.worldView.halfHeight)); + } + if(this.opaque == true) { + if(this._bgTexture) { + this._game.stage.context.fillStyle = this._bgTexture; + this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height); + } else { + this._game.stage.context.fillStyle = this._bgColor; + this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height); + } + } + if(this.showShadow) { + this._game.stage.context.shadowBlur = 0; + this._game.stage.context.shadowOffsetX = 0; + this._game.stage.context.shadowOffsetY = 0; + } + if(this._clip) { + this._game.stage.context.beginPath(); + this._game.stage.context.rect(this._sx, this._sy, this.worldView.width, this.worldView.height); + this._game.stage.context.closePath(); + this._game.stage.context.clip(); + } + this._game.world.group.render(this, this._sx, this._sy); + if(this.showBorder) { + 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(); + } + if(this._fxFlashAlpha > 0) { + this._game.stage.context.fillStyle = this._fxFlashColor + this._fxFlashAlpha + ')'; + this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height); + } + if(this._fxFadeAlpha > 0) { + this._game.stage.context.fillStyle = this._fxFadeColor + this._fxFadeAlpha + ')'; + this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height); + } + if(this.scale.x !== 1 || this.scale.y !== 1) { + this._game.stage.context.scale(1, 1); + } + if(this._rotation !== 0 || this._clip) { + this._game.stage.context.translate(0, 0); + } + this._game.stage.context.restore(); + if(this.alpha !== 1) { + this._game.stage.context.globalAlpha = 1; + } + }; + Object.defineProperty(Camera.prototype, "backgroundColor", { + get: function () { + return this._bgColor; + }, + set: function (color) { + this._bgColor = color; + }, + enumerable: true, + configurable: true + }); + Camera.prototype.setTexture = function (key, repeat) { + if (typeof repeat === "undefined") { repeat = 'repeat'; } + this._bgTexture = this._game.stage.context.createPattern(this._game.cache.getImage(key), repeat); + this._bgTextureRepeat = repeat; + }; + Camera.prototype.setPosition = function (x, y) { + this._stageX = x; + this._stageY = y; + this.checkClip(); + }; + Camera.prototype.setSize = function (width, height) { + this.worldView.width = width; + this.worldView.height = height; + this.checkClip(); + }; + Camera.prototype.renderDebugInfo = function (x, y, color) { + if (typeof color === "undefined") { color = 'rgb(255,255,255)'; } + this._game.stage.context.fillStyle = color; + this._game.stage.context.fillText('Camera ID: ' + this.ID + ' (' + this.worldView.width + ' x ' + this.worldView.height + ')', x, y); + this._game.stage.context.fillText('X: ' + this._stageX + ' Y: ' + this._stageY + ' Rotation: ' + this._rotation, x, y + 14); + this._game.stage.context.fillText('World X: ' + this.scroll.x.toFixed(1) + ' World Y: ' + this.scroll.y.toFixed(1), x, y + 28); + if(this.bounds) { + this._game.stage.context.fillText('Bounds: ' + this.bounds.width + ' x ' + this.bounds.height, x, y + 56); + } + }; + Object.defineProperty(Camera.prototype, "x", { + get: function () { + return this._stageX; + }, + set: function (value) { + this._stageX = value; + this.checkClip(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Camera.prototype, "y", { + get: function () { + return this._stageY; + }, + set: function (value) { + this._stageY = value; + this.checkClip(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Camera.prototype, "width", { + get: function () { + return this.worldView.width; + }, + set: function (value) { + this.worldView.width = value; + this.checkClip(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Camera.prototype, "height", { + get: function () { + return this.worldView.height; + }, + set: function (value) { + this.worldView.height = value; + this.checkClip(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Camera.prototype, "rotation", { + get: function () { + return this._rotation; + }, + set: function (value) { + this._rotation = this._game.math.wrap(value, 360, 0); + }, + enumerable: true, + configurable: true + }); + Camera.prototype.checkClip = function () { + if(this._stageX !== 0 || this._stageY !== 0 || this.worldView.width < this._game.stage.width || this.worldView.height < this._game.stage.height) { + this._clip = true; + } else { + this._clip = false; + } + }; + return Camera; + })(); + Phaser.Camera = Camera; +})(Phaser || (Phaser = {})); var Phaser; (function (Phaser) { var CameraManager = (function () { @@ -2307,140 +1367,56 @@ var Phaser; })(); Phaser.CameraManager = CameraManager; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - Point -* -* The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis. -*/ var Phaser; (function (Phaser) { var Point = (function () { - /** - * Creates a new point. If you pass no parameters to this method, a point is created at (0,0). - * @class Point - * @constructor - * @param {Number} x The horizontal position of this point (default 0) - * @param {Number} y The vertical position of this point (default 0) - **/ function Point(x, y) { if (typeof x === "undefined") { x = 0; } if (typeof y === "undefined") { y = 0; } this.setTo(x, y); } - Point.prototype.add = /** - * Adds the coordinates of another point to the coordinates of this point to create a new point. - * @method add - * @param {Point} point - The point to be added. - * @return {Point} The new Point object. - **/ - function (toAdd, output) { + Point.prototype.add = function (toAdd, output) { if (typeof output === "undefined") { output = new Point(); } return output.setTo(this.x + toAdd.x, this.y + toAdd.y); }; - Point.prototype.addTo = /** - * Adds the given values to the coordinates of this point and returns it - * @method addTo - * @param {Number} x - The amount to add to the x value of the point - * @param {Number} y - The amount to add to the x value of the point - * @return {Point} This Point object. - **/ - function (x, y) { + Point.prototype.addTo = function (x, y) { if (typeof x === "undefined") { x = 0; } if (typeof y === "undefined") { y = 0; } return this.setTo(this.x + x, this.y + y); }; - Point.prototype.subtractFrom = /** - * Adds the given values to the coordinates of this point and returns it - * @method addTo - * @param {Number} x - The amount to add to the x value of the point - * @param {Number} y - The amount to add to the x value of the point - * @return {Point} This Point object. - **/ - function (x, y) { + Point.prototype.subtractFrom = function (x, y) { if (typeof x === "undefined") { x = 0; } if (typeof y === "undefined") { y = 0; } return this.setTo(this.x - x, this.y - y); }; - Point.prototype.invert = /** - * Inverts the x and y values of this point - * @method invert - * @return {Point} This Point object. - **/ - function () { + Point.prototype.invert = function () { return this.setTo(this.y, this.x); }; - Point.prototype.clamp = /** - * Clamps this Point object to be between the given min and max - * @method clamp - * @param {number} The minimum value to clamp this Point to - * @param {number} The maximum value to clamp this Point to - * @return {Point} This Point object. - **/ - function (min, max) { + Point.prototype.clamp = function (min, max) { this.clampX(min, max); this.clampY(min, max); return this; }; - Point.prototype.clampX = /** - * Clamps the x value of this Point object to be between the given min and max - * @method clampX - * @param {number} The minimum value to clamp this Point to - * @param {number} The maximum value to clamp this Point to - * @return {Point} This Point object. - **/ - function (min, max) { + Point.prototype.clampX = function (min, max) { this.x = Math.max(Math.min(this.x, max), min); return this; }; - Point.prototype.clampY = /** - * Clamps the y value of this Point object to be between the given min and max - * @method clampY - * @param {number} The minimum value to clamp this Point to - * @param {number} The maximum value to clamp this Point to - * @return {Point} This Point object. - **/ - function (min, max) { + Point.prototype.clampY = function (min, max) { this.x = Math.max(Math.min(this.x, max), min); this.y = Math.max(Math.min(this.y, max), min); return this; }; - Point.prototype.clone = /** - * Creates a copy of this Point. - * @method clone - * @param {Point} output Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned. - * @return {Point} The new Point object. - **/ - function (output) { + Point.prototype.clone = function (output) { if (typeof output === "undefined") { output = new Point(); } return output.setTo(this.x, this.y); }; - Point.prototype.copyFrom = /** - * Copies the point data from the source Point object into this Point object. - * @method copyFrom - * @param {Point} source - The point to copy from. - * @return {Point} This Point object. Useful for chaining method calls. - **/ - function (source) { + Point.prototype.copyFrom = function (source) { return this.setTo(source.x, source.y); }; - Point.prototype.copyTo = /** - * Copies the point data from this Point object to the given target Point object. - * @method copyTo - * @param {Point} target - The point to copy to. - * @return {Point} The target Point object. - **/ - function (target) { + Point.prototype.copyTo = function (target) { return target.setTo(this.x, this.y); }; - Point.prototype.distanceTo = /** - * Returns the distance from this Point object to the given Point object. - * @method distanceFrom - * @param {Point} target - The destination Point object. - * @param {Boolean} round - Round the distance to the nearest integer (default false) - * @return {Number} The distance between this Point object and the destination Point object. - **/ - function (target, round) { + Point.prototype.distanceTo = function (target, round) { if (typeof round === "undefined") { round = false; } var dx = this.x - target.x; var dy = this.y - target.y; @@ -2450,15 +1426,7 @@ var Phaser; return Math.sqrt(dx * dx + dy * dy); } }; - Point.distanceBetween = /** - * Returns the distance between the two Point objects. - * @method distanceBetween - * @param {Point} pointA - The first Point object. - * @param {Point} pointB - The second Point object. - * @param {Boolean} round - Round the distance to the nearest integer (default false) - * @return {Number} The distance between the two Point objects. - **/ - function distanceBetween(pointA, pointB, round) { + Point.distanceBetween = function distanceBetween(pointA, pointB, round) { if (typeof round === "undefined") { round = false; } var dx = pointA.x - pointB.x; var dy = pointA.y - pointB.y; @@ -2468,121 +1436,48 @@ var Phaser; return Math.sqrt(dx * dx + dy * dy); } }; - Point.prototype.distanceCompare = /** - * Returns true if the distance between this point and a target point is greater than or equal a specified distance. - * This avoids using a costly square root operation - * @method distanceCompare - * @param {Point} target - The Point object to use for comparison. - * @param {Number} distance - The distance to use for comparison. - * @return {Boolena} True if distance is >= specified distance. - **/ - function (target, distance) { + Point.prototype.distanceCompare = function (target, distance) { if(this.distanceTo(target) >= distance) { return true; } else { return false; } }; - Point.prototype.equals = /** - * Determines whether this Point object and the given point object are equal. They are equal if they have the same x and y values. - * @method equals - * @param {Point} point - The point to compare against. - * @return {Boolean} A value of true if the object is equal to this Point object; false if it is not equal. - **/ - function (toCompare) { + Point.prototype.equals = function (toCompare) { if(this.x === toCompare.x && this.y === toCompare.y) { return true; } else { return false; } }; - Point.prototype.interpolate = /** - * Determines a point between two specified points. The parameter f determines where the new interpolated point is located relative to the two end points specified by parameters pt1 and pt2. - * The closer the value of the parameter f is to 1.0, the closer the interpolated point is to the first point (parameter pt1). The closer the value of the parameter f is to 0, the closer the interpolated point is to the second point (parameter pt2). - * @method interpolate - * @param {Point} pointA - The first Point object. - * @param {Point} pointB - The second Point object. - * @param {Number} f - The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned. - * @return {Point} The new interpolated Point object. - **/ - function (pointA, pointB, f) { + Point.prototype.interpolate = function (pointA, pointB, f) { }; - Point.prototype.offset = /** - * Offsets the Point object by the specified amount. The value of dx is added to the original value of x to create the new x value. - * The value of dy is added to the original value of y to create the new y value. - * @method offset - * @param {Number} dx - The amount by which to offset the horizontal coordinate, x. - * @param {Number} dy - The amount by which to offset the vertical coordinate, y. - * @return {Point} This Point object. Useful for chaining method calls. - **/ - function (dx, dy) { + Point.prototype.offset = function (dx, dy) { this.x += dx; this.y += dy; return this; }; - Point.prototype.polar = /** - * Converts a pair of polar coordinates to a Cartesian point coordinate. - * @method polar - * @param {Number} length - The length coordinate of the polar pair. - * @param {Number} angle - The angle, in radians, of the polar pair. - * @return {Point} The new Cartesian Point object. - **/ - function (length, angle) { + Point.prototype.polar = function (length, angle) { }; - Point.prototype.setTo = /** - * Sets the x and y values of this Point object to the given coordinates. - * @method setTo - * @param {Number} x - The horizontal position of this point. - * @param {Number} y - The vertical position of this point. - * @return {Point} This Point object. Useful for chaining method calls. - **/ - function (x, y) { + Point.prototype.setTo = function (x, y) { this.x = x; this.y = y; return this; }; - Point.prototype.subtract = /** - * Subtracts the coordinates of another point from the coordinates of this point to create a new point. - * @method subtract - * @param {Point} point - The point to be subtracted. - * @param {Point} output Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned. - * @return {Point} The new Point object. - **/ - function (point, output) { + Point.prototype.subtract = function (point, output) { if (typeof output === "undefined") { output = new Point(); } return output.setTo(this.x - point.x, this.y - point.y); }; - Point.prototype.toString = /** - * Returns a string representation of this object. - * @method toString - * @return {string} a string representation of the instance. - **/ - function () { + Point.prototype.toString = function () { return '[{Point (x=' + this.x + ' y=' + this.y + ')}]'; }; return Point; })(); Phaser.Point = Point; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - MicroPoint -* -* The MicroPoint object represents a location in a two-dimensional coordinate system, -* where x represents the horizontal axis and y represents the vertical axis. -* It is different to the Point class in that it doesn't contain any of the help methods like add/substract/distanceTo, etc. -* Use a MicroPoint when all you literally need is a solid container for x and y (such as in the Rectangle class). -*/ var Phaser; (function (Phaser) { var MicroPoint = (function () { - /** - * Creates a new point. If you pass no parameters to this method, a point is created at (0,0). - * @class MicroPoint - * @constructor - * @param {Number} x The horizontal position of this point (default 0) - * @param {Number} y The vertical position of this point (default 0) - **/ function MicroPoint(x, y, parent) { if (typeof x === "undefined") { x = 0; } if (typeof y === "undefined") { y = 0; } @@ -2592,20 +1487,10 @@ var Phaser; this.parent = parent; } Object.defineProperty(MicroPoint.prototype, "x", { - get: /** - * The x coordinate of the top-left corner of the rectangle - * @property x - * @type Number - **/ - function () { + get: function () { return this._x; }, - set: /** - * The x coordinate of the top-left corner of the rectangle - * @property x - * @type Number - **/ - function (value) { + set: function (value) { this._x = value; if(this.parent) { this.parent.updateBounds(); @@ -2615,20 +1500,10 @@ var Phaser; configurable: true }); Object.defineProperty(MicroPoint.prototype, "y", { - get: /** - * The y coordinate of the top-left corner of the rectangle - * @property y - * @type Number - **/ - function () { + get: function () { return this._y; }, - set: /** - * The y coordinate of the top-left corner of the rectangle - * @property y - * @type Number - **/ - function (value) { + set: function (value) { this._y = value; if(this.parent) { this.parent.updateBounds(); @@ -2637,34 +1512,15 @@ var Phaser; enumerable: true, configurable: true }); - MicroPoint.prototype.copyFrom = /** - * Copies the x and y values from any given object to this MicroPoint. - * @method copyFrom - * @param {any} source - The object to copy from. - * @return {MicroPoint} This MicroPoint object. Useful for chaining method calls. - **/ - function (source) { + MicroPoint.prototype.copyFrom = function (source) { return this.setTo(source.x, source.y); }; - MicroPoint.prototype.copyTo = /** - * Copies the x and y values from this MicroPoint to any given object. - * @method copyTo - * @param {any} target - The object to copy to. - * @return {any} The target object. - **/ - function (target) { + MicroPoint.prototype.copyTo = function (target) { target.x = this._x; target.y = this._y; return target; }; - MicroPoint.prototype.setTo = /** - * Sets the x and y values of this MicroPoint object to the given coordinates. - * @method setTo - * @param {Number} x - The horizontal position of this point. - * @param {Number} y - The vertical position of this point. - * @return {MicroPoint} This MicroPoint object. Useful for chaining method calls. - **/ - function (x, y, callParent) { + MicroPoint.prototype.setTo = function (x, y, callParent) { if (typeof callParent === "undefined") { callParent = true; } this._x = x; this._y = y; @@ -2673,52 +1529,23 @@ var Phaser; } return this; }; - MicroPoint.prototype.equals = /** - * Determines whether this MicroPoint object and the given object are equal. They are equal if they have the same x and y values. - * @method equals - * @param {any} point - The object to compare against. Must have x and y properties. - * @return {Boolean} A value of true if the object is equal to this MicroPoin object; false if it is not equal. - **/ - function (toCompare) { + MicroPoint.prototype.equals = function (toCompare) { if(this._x === toCompare.x && this._y === toCompare.y) { return true; } else { return false; } }; - MicroPoint.prototype.toString = /** - * Returns a string representation of this object. - * @method toString - * @return {string} a string representation of the instance. - **/ - function () { + MicroPoint.prototype.toString = function () { return '[{MicroPoint (x=' + this._x + ' y=' + this._y + ')}]'; }; return MicroPoint; })(); Phaser.MicroPoint = MicroPoint; })(Phaser || (Phaser = {})); -/// -/// -/** -* Phaser - Rectangle -* -* A Rectangle object is an area defined by its position, as indicated by its top-left corner (x,y) and width and height. -*/ var Phaser; (function (Phaser) { var Rectangle = (function () { - /** - * Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified width and height parameters. - * If you call this function without parameters, a rectangle with x, y, width, and height properties set to 0 is created. - * @class Rectangle - * @constructor - * @param {Number} x The x coordinate of the top-left corner of the rectangle. - * @param {Number} y The y coordinate of the top-left corner of the rectangle. - * @param {Number} width The width of the rectangle. - * @param {Number} height The height of the rectangle. - * @return {Rectangle} This rectangle object - **/ function Rectangle(x, y, width, height) { if (typeof x === "undefined") { x = 0; } if (typeof y === "undefined") { y = 0; } @@ -2728,35 +1555,10 @@ var Phaser; this._tempY = null; this._tempWidth = null; this._tempHeight = null; - /** - * The width of the rectangle - * @property width - * @type Number - **/ this._width = 0; - /** - * The height of the rectangle - * @property height - * @type Number - **/ this._height = 0; - /** - * Half of the width of the rectangle - * @property halfWidth - * @type Number - **/ this._halfWidth = 0; - /** - * Half of the height of the rectangle - * @property halfHeight - * @type Number - **/ this._halfHeight = 0; - /** - * The size of the longest side (width or height) - * @property length - * @type Number - **/ this.length = 0; this._width = width; if(width > 0) { @@ -2778,50 +1580,26 @@ var Phaser; this.bottomRight = new Phaser.MicroPoint(x + this._width - 1, y + this._height - 1, this); } Object.defineProperty(Rectangle.prototype, "x", { - get: /** - * The x coordinate of the top-left corner of the rectangle - * @property x - * @type Number - **/ - function () { + get: function () { return this.topLeft.x; }, - set: /** - * The x coordinate of the top-left corner of the rectangle - * @property x - * @type Number - **/ - function (value) { + set: function (value) { this.topLeft.x = value; }, enumerable: true, configurable: true }); Object.defineProperty(Rectangle.prototype, "y", { - get: /** - * The y coordinate of the top-left corner of the rectangle - * @property y - * @type Number - **/ - function () { + get: function () { return this.topLeft.y; }, - set: /** - * The y coordinate of the top-left corner of the rectangle - * @property y - * @type Number - **/ - function (value) { + set: function (value) { this.topLeft.y = value; }, enumerable: true, configurable: true }); - Rectangle.prototype.updateBounds = /** - * Updates all of the MicroPoints based on the values of width and height. - * You should not normally call this directly. - **/ - function () { + Rectangle.prototype.updateBounds = function () { if(this._tempWidth !== null) { this._width = this._tempWidth; this._halfWidth = 0; @@ -2860,20 +1638,10 @@ var Phaser; this._tempHeight = null; }; Object.defineProperty(Rectangle.prototype, "width", { - get: /** - * The width of the rectangle - * @property width - * @type Number - **/ - function () { + get: function () { return this._width; }, - set: /** - * The width of the rectangle - * @property width - * @type Number - **/ - function (value) { + set: function (value) { this._width = value; this._halfWidth = Math.round(value / 2); this.updateBounds(); @@ -2882,20 +1650,10 @@ var Phaser; configurable: true }); Object.defineProperty(Rectangle.prototype, "height", { - get: /** - * The height of the rectangle - * @property height - * @type Number - **/ - function () { + get: function () { return this._height; }, - set: /** - * The height of the rectangle - * @property height - * @type Number - **/ - function (value) { + set: function (value) { this._height = value; this._halfHeight = Math.round(value / 2); this.updateBounds(); @@ -2904,46 +1662,24 @@ var Phaser; configurable: true }); Object.defineProperty(Rectangle.prototype, "halfWidth", { - get: /** - * Half of the width of the rectangle - * @property halfWidth - * @type Number - **/ - function () { + get: function () { return this._halfWidth; }, enumerable: true, configurable: true }); Object.defineProperty(Rectangle.prototype, "halfHeight", { - get: /** - * Half of the height of the rectangle - * @property halfHeight - * @type Number - **/ - function () { + get: function () { return this._halfHeight; }, enumerable: true, configurable: true }); Object.defineProperty(Rectangle.prototype, "bottom", { - get: /** - * The sum of the y and height properties. - * Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. - * @method bottom - * @return {Number} - **/ - function () { + get: function () { return this.bottomCenter.y; }, - set: /** - * The sum of the y and height properties. - * Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. - * @method bottom - * @param {Number} value - **/ - function (value) { + set: function (value) { if(value < this.y) { this._tempHeight = 0; } else { @@ -2955,24 +1691,10 @@ var Phaser; configurable: true }); Object.defineProperty(Rectangle.prototype, "left", { - get: /** - * The x coordinate of the top-left corner of the rectangle. - * Changing the left property of a Rectangle object has no effect on the y and height properties. - * However it does affect the width property, whereas changing the x value does not affect the width property. - * @method left - * @ return {number} - **/ - function () { + get: function () { return this.x; }, - set: /** - * The x coordinate of the top-left corner of the rectangle. - * Changing the left property of a Rectangle object has no effect on the y and height properties. - * However it does affect the width property, whereas changing the x value does not affect the width property. - * @method left - * @param {Number} value - **/ - function (value) { + set: function (value) { var diff = this.x - value; if(this._width + diff < 0) { this._tempWidth = 0; @@ -2987,24 +1709,10 @@ var Phaser; configurable: true }); Object.defineProperty(Rectangle.prototype, "right", { - get: /** - * The sum of the x and width properties. - * Changing the right property of a Rectangle object has no effect on the x, y and height properties. - * However it does affect the width property. - * @method right - * @return {Number} - **/ - function () { + get: function () { return this.rightCenter.x; }, - set: /** - * The sum of the x and width properties. - * Changing the right property of a Rectangle object has no effect on the x, y and height properties. - * However it does affect the width property. - * @method right - * @param {Number} value - **/ - function (value) { + set: function (value) { if(value < this.topLeft.x) { this._tempWidth = 0; } else { @@ -3015,59 +1723,29 @@ var Phaser; enumerable: true, configurable: true }); - Rectangle.prototype.size = /** - * The size of the Rectangle object, expressed as a Point object with the values of the width and height properties. - * @method size - * @param {Point} output Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned. - * @return {Point} The size of the Rectangle object - **/ - function (output) { + Rectangle.prototype.size = function (output) { if (typeof output === "undefined") { output = new Phaser.Point(); } return output.setTo(this._width, this._height); }; Object.defineProperty(Rectangle.prototype, "volume", { - get: /** - * The volume of the Rectangle object in pixels, derived from width * height - * @method volume - * @return {Number} - **/ - function () { + get: function () { return this._width * this._height; }, enumerable: true, configurable: true }); Object.defineProperty(Rectangle.prototype, "perimeter", { - get: /** - * The perimeter size of the Rectangle object in pixels. This is the sum of all 4 sides. - * @method perimeter - * @return {Number} - **/ - function () { + get: function () { return (this._width * 2) + (this._height * 2); }, enumerable: true, configurable: true }); Object.defineProperty(Rectangle.prototype, "top", { - get: /** - * The y coordinate of the top-left corner of the rectangle. - * Changing the top property of a Rectangle object has no effect on the x and width properties. - * However it does affect the height property, whereas changing the y value does not affect the height property. - * @method top - * @return {Number} - **/ - function () { + get: function () { return this.topCenter.y; }, - set: /** - * The y coordinate of the top-left corner of the rectangle. - * Changing the top property of a Rectangle object has no effect on the x and width properties. - * However it does affect the height property, whereas changing the y value does not affect the height property. - * @method top - * @param {Number} value - **/ - function (value) { + set: function (value) { var diff = this.topCenter.y - value; if(this._height + diff < 0) { this._tempHeight = 0; @@ -3081,48 +1759,20 @@ var Phaser; enumerable: true, configurable: true }); - Rectangle.prototype.clone = /** - * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. - * @method clone - * @param {Rectangle} output Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned. - * @return {Rectangle} - **/ - function (output) { + Rectangle.prototype.clone = function (output) { if (typeof output === "undefined") { output = new Rectangle(); } return output.setTo(this.x, this.y, this.width, this.height); }; - Rectangle.prototype.contains = /** - * Determines whether the specified coordinates are contained within the region defined by this Rectangle object. - * @method contains - * @param {Number} x The x coordinate of the point to test. - * @param {Number} y The y coordinate of the point to test. - * @return {Boolean} A value of true if the Rectangle object contains the specified point; otherwise false. - **/ - function (x, y) { + Rectangle.prototype.contains = function (x, y) { if(x >= this.topLeft.x && x <= this.topRight.x && y >= this.topLeft.y && y <= this.bottomRight.y) { return true; } return false; }; - Rectangle.prototype.containsPoint = /** - * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. - * This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter. - * @method containsPoint - * @param {Point} point The point object being checked. Can be Point or any object with .x and .y values. - * @return {Boolean} A value of true if the Rectangle object contains the specified point; otherwise false. - **/ - function (point) { + Rectangle.prototype.containsPoint = function (point) { return this.contains(point.x, point.y); }; - Rectangle.prototype.containsRect = /** - * Determines whether the Rectangle object specified by the rect parameter is contained within this Rectangle object. - * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first. - * @method containsRect - * @param {Rectangle} rect The rectangle object being checked. - * @return {Boolean} A value of true if the Rectangle object contains the specified point; otherwise false. - **/ - function (rect) { - // If the given rect has a larger volume than this one then it can never contain it + Rectangle.prototype.containsRect = function (rect) { if(rect.volume > this.volume) { return false; } @@ -3131,47 +1781,19 @@ var Phaser; } return false; }; - Rectangle.prototype.copyFrom = /** - * Copies all of rectangle data from the source Rectangle object into the calling Rectangle object. - * @method copyFrom - * @param {Rectangle} rect The source rectangle object to copy from - * @return {Rectangle} This rectangle object - **/ - function (source) { + Rectangle.prototype.copyFrom = function (source) { return this.setTo(source.x, source.y, source.width, source.height); }; - Rectangle.prototype.copyTo = /** - * Copies all the rectangle data from this Rectangle object into the destination Rectangle object. - * @method copyTo - * @param {Rectangle} rect The destination rectangle object to copy in to - * @return {Rectangle} The destination rectangle object - **/ - function (target) { + Rectangle.prototype.copyTo = function (target) { return target.copyFrom(this); }; - Rectangle.prototype.equals = /** - * Determines whether the object specified in the toCompare parameter is equal to this Rectangle object. - * This method compares the x, y, width, and height properties of an object against the same properties of this Rectangle object. - * @method equals - * @param {Rectangle} toCompare The rectangle to compare to this Rectangle object. - * @return {Boolean} A value of true if the object has exactly the same values for the x, y, width, and height properties as this Rectangle object; otherwise false. - **/ - function (toCompare) { + Rectangle.prototype.equals = function (toCompare) { if(this.topLeft.equals(toCompare.topLeft) && this.bottomRight.equals(toCompare.bottomRight)) { return true; } return false; }; - Rectangle.prototype.inflate = /** - * Increases the size of the Rectangle object by the specified amounts. - * The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, - * and to the top and the bottom by the dy value. - * @method inflate - * @param {Number} dx The amount to be added to the left side of this Rectangle. - * @param {Number} dy The amount to be added to the bottom side of this Rectangle. - * @return {Rectangle} This Rectangle object. - **/ - function (dx, dy) { + Rectangle.prototype.inflate = function (dx, dy) { this._tempX = this.topLeft.x - dx; this._tempWidth = this._width + (2 * dx); this._tempY = this.topLeft.y - dy; @@ -3179,26 +1801,10 @@ var Phaser; this.updateBounds(); return this; }; - Rectangle.prototype.inflatePoint = /** - * Increases the size of the Rectangle object. - * This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter. - * @method inflatePoint - * @param {Point} point The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object. - * @return {Rectangle} This Rectangle object. - **/ - function (point) { + Rectangle.prototype.inflatePoint = function (point) { return this.inflate(point.x, point.y); }; - Rectangle.prototype.intersection = /** - * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, - * returns the area of intersection as a Rectangle object. If the rectangles do not intersect, this method - * returns an empty Rectangle object with its properties set to 0. - * @method intersection - * @param {Rectangle} toIntersect The Rectangle object to compare against to see if it intersects with this Rectangle object. - * @param {Rectangle} output Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned. - * @return {Rectangle} A Rectangle object that equals the area of intersection. If the rectangles do not intersect, this method returns an empty Rectangle object; that is, a rectangle with its x, y, width, and height properties set to 0. - **/ - function (toIntersect, output) { + Rectangle.prototype.intersection = function (toIntersect, output) { if (typeof output === "undefined") { output = new Rectangle(); } if(this.intersects(toIntersect) === true) { output.x = Math.max(toIntersect.topLeft.x, this.topLeft.x); @@ -3208,25 +1814,12 @@ var Phaser; } return output; }; - Rectangle.prototype.intersects = /** - * Determines whether the object specified intersects (overlaps) with this Rectangle object. - * This method checks the x, y, width, and height properties of the specified Rectangle object to see if it intersects with this Rectangle object. - * @method intersects - * @param {Rectangle} r2 The Rectangle object to compare against to see if it intersects with this Rectangle object. - * @param {Number} t A tolerance value to allow for an intersection test with padding, default to 0 - * @return {Boolean} A value of true if the specified object intersects with this Rectangle object; otherwise false. - **/ - function (r2, t) { + Rectangle.prototype.intersects = function (r2, t) { if (typeof t === "undefined") { t = 0; } return !(r2.left > this.right + t || r2.right < this.left - t || r2.top > this.bottom + t || r2.bottom < this.top - t); }; Object.defineProperty(Rectangle.prototype, "isEmpty", { - get: /** - * Determines whether or not this Rectangle object is empty. - * @method isEmpty - * @return {Boolean} A value of true if the Rectangle object's width or height is less than or equal to 0; otherwise false. - **/ - function () { + get: function () { if(this.width < 1 || this.height < 1) { return true; } @@ -3235,47 +1828,20 @@ var Phaser; enumerable: true, configurable: true }); - Rectangle.prototype.offset = /** - * Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts. - * @method offset - * @param {Number} dx Moves the x value of the Rectangle object by this amount. - * @param {Number} dy Moves the y value of the Rectangle object by this amount. - * @return {Rectangle} This Rectangle object. - **/ - function (dx, dy) { + Rectangle.prototype.offset = function (dx, dy) { if(!isNaN(dx) && !isNaN(dy)) { this.x += dx; this.y += dy; } return this; }; - Rectangle.prototype.offsetPoint = /** - * Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter. - * @method offsetPoint - * @param {Point} point A Point object to use to offset this Rectangle object. - * @return {Rectangle} This Rectangle object. - **/ - function (point) { + Rectangle.prototype.offsetPoint = function (point) { return this.offset(point.x, point.y); }; - Rectangle.prototype.setEmpty = /** - * Sets all of the Rectangle object's properties to 0. A Rectangle object is empty if its width or height is less than or equal to 0. - * @method setEmpty - * @return {Rectangle} This rectangle object - **/ - function () { + Rectangle.prototype.setEmpty = function () { return this.setTo(0, 0, 0, 0); }; - Rectangle.prototype.setTo = /** - * Sets the members of Rectangle to the specified values. - * @method setTo - * @param {Number} x The x coordinate of the top-left corner of the rectangle. - * @param {Number} y The y coordinate of the top-left corner of the rectangle. - * @param {Number} width The width of the rectangle in pixels. - * @param {Number} height The height of the rectangle in pixels. - * @return {Rectangle} This rectangle object - **/ - function (x, y, width, height) { + Rectangle.prototype.setTo = function (x, y, width, height) { this._tempX = x; this._tempY = y; this._tempWidth = width; @@ -3283,81 +1849,91 @@ var Phaser; this.updateBounds(); return this; }; - Rectangle.prototype.union = /** - * Adds two rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two rectangles. - * @method union - * @param {Rectangle} toUnion A Rectangle object to add to this Rectangle object. - * @param {Rectangle} output Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned. - * @return {Rectangle} A Rectangle object that is the union of the two rectangles. - **/ - function (toUnion, output) { + Rectangle.prototype.union = function (toUnion, output) { if (typeof output === "undefined") { output = new Rectangle(); } return output.setTo(Math.min(toUnion.x, this.x), Math.min(toUnion.y, this.y), Math.max(toUnion.right, this.right), Math.max(toUnion.bottom, this.bottom)); }; - Rectangle.prototype.toString = /** - * Returns a string representation of this object. - * @method toString - * @return {string} a string representation of the instance. - **/ - function () { + Rectangle.prototype.toString = function () { return "[{Rectangle (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + " empty=" + this.isEmpty + ")}]"; }; return Rectangle; })(); Phaser.Rectangle = Rectangle; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - Circle -* -* A Circle object is an area defined by its position, as indicated by its center point (x,y) and diameter. -*/ +var Phaser; +(function (Phaser) { + var Quad = (function () { + function Quad(x, y, width, height) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof width === "undefined") { width = 0; } + if (typeof height === "undefined") { height = 0; } + this.setTo(x, y, width, height); + } + Quad.prototype.setTo = function (x, y, width, height) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + return this; + }; + Object.defineProperty(Quad.prototype, "left", { + get: function () { + return this.x; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Quad.prototype, "right", { + get: function () { + return this.x + this.width; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Quad.prototype, "top", { + get: function () { + return this.y; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Quad.prototype, "bottom", { + get: function () { + return this.y + this.height; + }, + enumerable: true, + configurable: true + }); + Quad.prototype.intersects = function (q, t) { + if (typeof t === "undefined") { t = 0; } + return !(q.left > this.right + t || q.right < this.left - t || q.top > this.bottom + t || q.bottom < this.top - t); + }; + Quad.prototype.toString = function () { + return "[{Quad (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + ")}]"; + }; + return Quad; + })(); + Phaser.Quad = Quad; +})(Phaser || (Phaser = {})); var Phaser; (function (Phaser) { var Circle = (function () { - /** - * Creates a new Circle object with the center coordinate specified by the x and y parameters and the diameter specified by the diameter parameter. If you call this function without parameters, a circle with x, y, diameter and radius properties set to 0 is created. - * @class Circle - * @constructor - * @param {Number} x The x coordinate of the center of the circle. - * @param {Number} y The y coordinate of the center of the circle. - * @return {Circle} This circle object - **/ function Circle(x, y, diameter) { if (typeof x === "undefined") { x = 0; } if (typeof y === "undefined") { y = 0; } if (typeof diameter === "undefined") { diameter = 0; } this._diameter = 0; this._radius = 0; - /** - * The x coordinate of the center of the circle - * @property x - * @type Number - **/ this.x = 0; - /** - * The y coordinate of the center of the circle - * @property y - * @type Number - **/ this.y = 0; this.setTo(x, y, diameter); } Object.defineProperty(Circle.prototype, "diameter", { - get: /** - * The diameter of the circle. The largest distance between any two points on the circle. The same as the radius * 2. - * @method diameter - * @return {Number} - **/ - function () { + get: function () { return this._diameter; }, - set: /** - * The diameter of the circle. The largest distance between any two points on the circle. The same as the radius * 2. - * @method diameter - * @param {Number} The diameter of the circle. - **/ - function (value) { + set: function (value) { if(value > 0) { this._diameter = value; this._radius = value * 0.5; @@ -3367,20 +1943,10 @@ var Phaser; configurable: true }); Object.defineProperty(Circle.prototype, "radius", { - get: /** - * The radius of the circle. The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter. - * @method radius - * @return {Number} - **/ - function () { + get: function () { return this._radius; }, - set: /** - * The radius of the circle. The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter. - * @method radius - * @param {Number} The radius of the circle. - **/ - function (value) { + set: function (value) { if(value > 0) { this._radius = value; this._diameter = value * 2; @@ -3389,29 +1955,14 @@ var Phaser; enumerable: true, configurable: true }); - Circle.prototype.circumference = /** - * The circumference of the circle. - * @method circumference - * @return {Number} - **/ - function () { + Circle.prototype.circumference = function () { return 2 * (Math.PI * this._radius); }; Object.defineProperty(Circle.prototype, "bottom", { - get: /** - * The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter. - * @method bottom - * @return {Number} - **/ - function () { + get: function () { return this.y + this._radius; }, - set: /** - * The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter. - * @method bottom - * @param {Number} The value to adjust the height of the circle by. - **/ - function (value) { + set: function (value) { if(!isNaN(value)) { if(value < this.y) { this._radius = 0; @@ -3425,20 +1976,10 @@ var Phaser; configurable: true }); Object.defineProperty(Circle.prototype, "left", { - get: /** - * The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. - * @method left - * @return {Number} The x coordinate of the leftmost point of the circle. - **/ - function () { + get: function () { return this.x - this._radius; }, - set: /** - * The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. - * @method left - * @param {Number} The value to adjust the position of the leftmost point of the circle by. - **/ - function (value) { + set: function (value) { if(!isNaN(value)) { if(value < this.x) { this.radius = this.x - value; @@ -3452,20 +1993,10 @@ var Phaser; configurable: true }); Object.defineProperty(Circle.prototype, "right", { - get: /** - * The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. - * @method right - * @return {Number} - **/ - function () { + get: function () { return this.x + this._radius; }, - set: /** - * The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. - * @method right - * @param {Number} The amount to adjust the diameter of the circle by. - **/ - function (value) { + set: function (value) { if(!isNaN(value)) { if(value > this.x) { this.radius = value - this.x; @@ -3479,20 +2010,10 @@ var Phaser; configurable: true }); Object.defineProperty(Circle.prototype, "top", { - get: /** - * The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter. - * @method bottom - * @return {Number} - **/ - function () { + get: function () { return this.y - this._radius; }, - set: /** - * The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter. - * @method bottom - * @param {Number} The amount to adjust the height of the circle by. - **/ - function (value) { + set: function (value) { if(!isNaN(value)) { if(value > this.y) { this._radius = 0; @@ -3506,12 +2027,7 @@ var Phaser; configurable: true }); Object.defineProperty(Circle.prototype, "area", { - get: /** - * Gets the area of this Circle. - * @method area - * @return {Number} This area of this circle. - **/ - function () { + get: function () { if(this._radius > 0) { return Math.PI * this._radius * this._radius; } else { @@ -3522,12 +2038,7 @@ var Phaser; configurable: true }); Object.defineProperty(Circle.prototype, "isEmpty", { - get: /** - * Determines whether or not this Circle object is empty. - * @method isEmpty - * @return {Boolean} A value of true if the Circle objects diameter is less than or equal to 0; otherwise false. - **/ - function () { + get: function () { if(this._diameter < 1) { return true; } @@ -3536,86 +2047,32 @@ var Phaser; enumerable: true, configurable: true }); - Circle.prototype.intersectCircleLine = /** - * Whether the circle intersects with a line. Checks against infinite line defined by the two points on the line, not the line segment. - * If you need details about the intersection then use Collision.lineToCircle instead. - * @method intersectCircleLine - * @param {Object} the line object to check. - * @return {Boolean} - **/ - function (line) { + Circle.prototype.intersectCircleLine = function (line) { return Phaser.Collision.lineToCircle(line, this).result; }; - Circle.prototype.clone = /** - * Returns a new Circle object with the same values for the x, y, width, and height properties as the original Circle object. - * @method clone - * @param {Circle} output Optional Circle object. If given the values will be set into the object, otherwise a brand new Circle object will be created and returned. - * @return {Phaser.Circle} - **/ - function (output) { + Circle.prototype.clone = function (output) { if (typeof output === "undefined") { output = new Circle(); } return output.setTo(this.x, this.y, this._diameter); }; - Circle.prototype.contains = /** - * Return true if the given x/y coordinates are within this Circle object. - * If you need details about the intersection then use Phaser.Intersect.circleContainsPoint instead. - * @method contains - * @param {Number} The X value of the coordinate to test. - * @param {Number} The Y value of the coordinate to test. - * @return {Boolean} True if the coordinates are within this circle, otherwise false. - **/ - function (x, y) { + Circle.prototype.contains = function (x, y) { return Phaser.Collision.circleContainsPoint(this, { x: x, y: y }).result; }; - Circle.prototype.containsPoint = /** - * Return true if the coordinates of the given Point object are within this Circle object. - * If you need details about the intersection then use Phaser.Intersect.circleContainsPoint instead. - * @method containsPoint - * @param {Phaser.Point} The Point object to test. - * @return {Boolean} True if the coordinates are within this circle, otherwise false. - **/ - function (point) { + Circle.prototype.containsPoint = function (point) { return Phaser.Collision.circleContainsPoint(this, point).result; }; - Circle.prototype.containsCircle = /** - * Return true if the given Circle is contained entirely within this Circle object. - * If you need details about the intersection then use Phaser.Intersect.circleToCircle instead. - * @method containsCircle - * @param {Phaser.Circle} The Circle object to test. - * @return {Boolean} True if the coordinates are within this circle, otherwise false. - **/ - function (circle) { + Circle.prototype.containsCircle = function (circle) { return Phaser.Collision.circleToCircle(this, circle).result; }; - Circle.prototype.copyFrom = /** - * Copies all of circle data from the source Circle object into the calling Circle object. - * @method copyFrom - * @param {Circle} rect The source circle object to copy from - * @return {Circle} This circle object - **/ - function (source) { + Circle.prototype.copyFrom = function (source) { return this.setTo(source.x, source.y, source.diameter); }; - Circle.prototype.copyTo = /** - * Copies all of circle data from this Circle object into the destination Circle object. - * @method copyTo - * @param {Circle} circle The destination circle object to copy in to - * @return {Circle} The destination circle object - **/ - function (target) { + Circle.prototype.copyTo = function (target) { return target.copyFrom(this); }; - Circle.prototype.distanceTo = /** - * Returns the distance from the center of this Circle object to the given object (can be Circle, Point or anything with x/y values) - * @method distanceFrom - * @param {Circle/Point} target - The destination Point object. - * @param {Boolean} round - Round the distance to the nearest integer (default false) - * @return {Number} The distance between this Point object and the destination Point object. - **/ - function (target, round) { + Circle.prototype.distanceTo = function (target, round) { if (typeof round === "undefined") { round = false; } var dx = this.x - target.x; var dy = this.y - target.y; @@ -3625,39 +2082,19 @@ var Phaser; return Math.sqrt(dx * dx + dy * dy); } }; - Circle.prototype.equals = /** - * Determines whether the object specified in the toCompare parameter is equal to this Circle object. This method compares the x, y and diameter properties of an object against the same properties of this Circle object. - * @method equals - * @param {Circle} toCompare The circle to compare to this Circle object. - * @return {Boolean} A value of true if the object has exactly the same values for the x, y and diameter properties as this Circle object; otherwise false. - **/ - function (toCompare) { + Circle.prototype.equals = function (toCompare) { if(this.x === toCompare.x && this.y === toCompare.y && this.diameter === toCompare.diameter) { return true; } return false; }; - Circle.prototype.intersects = /** - * Determines whether the Circle object specified in the toIntersect parameter intersects with this Circle object. This method checks the radius distances between the two Circle objects to see if they intersect. - * @method intersects - * @param {Circle} toIntersect The Circle object to compare against to see if it intersects with this Circle object. - * @return {Boolean} A value of true if the specified object intersects with this Circle object; otherwise false. - **/ - function (toIntersect) { + Circle.prototype.intersects = function (toIntersect) { if(this.distanceTo(toIntersect, false) < (this._radius + toIntersect._radius)) { return true; } return false; }; - Circle.prototype.circumferencePoint = /** - * Returns a Point object containing the coordinates of a point on the circumference of this Circle based on the given angle. - * @method circumferencePoint - * @param {Number} The angle in radians (unless asDegrees is true) to return the point from. - * @param {Boolean} Is the given angle in radians (false) or degrees (true)? - * @param {Phaser.Point} An optional Point object to put the result in to. If none specified a new Point object will be created. - * @return {Phaser.Point} The Point object holding the result. - **/ - function (angle, asDegrees, output) { + Circle.prototype.circumferencePoint = function (angle, asDegrees, output) { if (typeof asDegrees === "undefined") { asDegrees = false; } if (typeof output === "undefined") { output = new Phaser.Point(); } if(asDegrees === true) { @@ -3667,143 +2104,55 @@ var Phaser; output.y = this.y + this._radius * Math.sin(angle); return output; }; - Circle.prototype.offset = /** - * Adjusts the location of the Circle object, as determined by its center coordinate, by the specified amounts. - * @method offset - * @param {Number} dx Moves the x value of the Circle object by this amount. - * @param {Number} dy Moves the y value of the Circle object by this amount. - * @return {Circle} This Circle object. - **/ - function (dx, dy) { + Circle.prototype.offset = function (dx, dy) { if(!isNaN(dx) && !isNaN(dy)) { this.x += dx; this.y += dy; } return this; }; - Circle.prototype.offsetPoint = /** - * Adjusts the location of the Circle object using a Point object as a parameter. This method is similar to the Circle.offset() method, except that it takes a Point object as a parameter. - * @method offsetPoint - * @param {Point} point A Point object to use to offset this Circle object. - * @return {Circle} This Circle object. - **/ - function (point) { + Circle.prototype.offsetPoint = function (point) { return this.offset(point.x, point.y); }; - Circle.prototype.setTo = /** - * Sets the members of Circle to the specified values. - * @method setTo - * @param {Number} x The x coordinate of the center of the circle. - * @param {Number} y The y coordinate of the center of the circle. - * @param {Number} diameter The diameter of the circle in pixels. - * @return {Circle} This circle object - **/ - function (x, y, diameter) { + Circle.prototype.setTo = function (x, y, diameter) { this.x = x; this.y = y; this._diameter = diameter; this._radius = diameter * 0.5; return this; }; - Circle.prototype.toString = /** - * Returns a string representation of this object. - * @method toString - * @return {string} a string representation of the instance. - **/ - function () { + Circle.prototype.toString = function () { return "[{Circle (x=" + this.x + " y=" + this.y + " diameter=" + this.diameter + " radius=" + this.radius + ")}]"; }; return Circle; })(); Phaser.Circle = Circle; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - Line -* -* A Line object is an infinte line through space. The two sets of x/y coordinates define the Line Segment. -*/ var Phaser; (function (Phaser) { var Line = (function () { - /** - * - * @constructor - * @param {Number} x1 - * @param {Number} y1 - * @param {Number} x2 - * @param {Number} y2 - * @return {Phaser.Line} This Object - */ function Line(x1, y1, x2, y2) { if (typeof x1 === "undefined") { x1 = 0; } if (typeof y1 === "undefined") { y1 = 0; } if (typeof x2 === "undefined") { x2 = 0; } if (typeof y2 === "undefined") { y2 = 0; } - /** - * - * @property x1 - * @type Number - */ this.x1 = 0; - /** - * - * @property y1 - * @type Number - */ this.y1 = 0; - /** - * - * @property x2 - * @type Number - */ this.x2 = 0; - /** - * - * @property y2 - * @type Number - */ this.y2 = 0; this.setTo(x1, y1, x2, y2); } - Line.prototype.clone = /** - * - * @method clone - * @param {Phaser.Line} [output] - * @return {Phaser.Line} - */ - function (output) { + Line.prototype.clone = function (output) { if (typeof output === "undefined") { output = new Line(); } return output.setTo(this.x1, this.y1, this.x2, this.y2); }; - Line.prototype.copyFrom = /** - * - * @method copyFrom - * @param {Phaser.Line} source - * @return {Phaser.Line} - */ - function (source) { + Line.prototype.copyFrom = function (source) { return this.setTo(source.x1, source.y1, source.x2, source.y2); }; - Line.prototype.copyTo = /** - * - * @method copyTo - * @param {Phaser.Line} target - * @return {Phaser.Line} - */ - function (target) { + Line.prototype.copyTo = function (target) { return target.copyFrom(this); }; - Line.prototype.setTo = /** - * - * @method setTo - * @param {Number} x1 - * @param {Number} y1 - * @param {Number} x2 - * @param {Number} y2 - * @return {Phaser.Line} - */ - function (x1, y1, x2, y2) { + Line.prototype.setTo = function (x1, y1, x2, y2) { if (typeof x1 === "undefined") { x1 = 0; } if (typeof y1 === "undefined") { y1 = 0; } if (typeof x2 === "undefined") { x2 = 0; } @@ -3829,96 +2178,51 @@ var Phaser; configurable: true }); Object.defineProperty(Line.prototype, "length", { - get: /** - * - * @method length - * @return {Number} - */ - function () { + get: function () { return Math.sqrt((this.x2 - this.x1) * (this.x2 - this.x1) + (this.y2 - this.y1) * (this.y2 - this.y1)); }, enumerable: true, configurable: true }); - Line.prototype.getY = /** - * - * @method getY - * @param {Number} x - * @return {Number} - */ - function (x) { + Line.prototype.getY = function (x) { return this.slope * x + this.yIntercept; }; Object.defineProperty(Line.prototype, "angle", { - get: /** - * - * @method angle - * @return {Number} - */ - function () { + get: function () { return Math.atan2(this.x2 - this.x1, this.y2 - this.y1); }, enumerable: true, configurable: true }); Object.defineProperty(Line.prototype, "slope", { - get: /** - * - * @method slope - * @return {Number} - */ - function () { + get: function () { return (this.y2 - this.y1) / (this.x2 - this.x1); }, enumerable: true, configurable: true }); Object.defineProperty(Line.prototype, "perpSlope", { - get: /** - * - * @method perpSlope - * @return {Number} - */ - function () { + get: function () { return -((this.x2 - this.x1) / (this.y2 - this.y1)); }, enumerable: true, configurable: true }); Object.defineProperty(Line.prototype, "yIntercept", { - get: /** - * - * @method yIntercept - * @return {Number} - */ - function () { + get: function () { return (this.y1 - this.slope * this.x1); }, enumerable: true, configurable: true }); - Line.prototype.isPointOnLine = /** - * - * @method isPointOnLine - * @param {Number} x - * @param {Number} y - * @return {Boolean} - */ - function (x, y) { + Line.prototype.isPointOnLine = function (x, y) { if((x - this.x1) * (this.y2 - this.y1) === (this.x2 - this.x1) * (y - this.y1)) { return true; } else { return false; } }; - Line.prototype.isPointOnLineSegment = /** - * - * @method isPointOnLineSegment - * @param {Number} x - * @param {Number} y - * @return {Boolean} - */ - function (x, y) { + Line.prototype.isPointOnLineSegment = function (x, y) { var xMin = Math.min(this.x1, this.x2); var xMax = Math.max(this.x1, this.x2); var yMin = Math.min(this.y1, this.y2); @@ -3929,24 +2233,9 @@ var Phaser; return false; } }; - Line.prototype.intersectLineLine = /** - * - * @method intersectLineLine - * @param {Any} line - * @return {Any} - */ - function (line) { - //return Phaser.intersectLineLine(this,line); - }; - Line.prototype.perp = /** - * - * @method perp - * @param {Number} x - * @param {Number} y - * @param {Phaser.Line} [output] - * @return {Phaser.Line} - */ - function (x, y, output) { + Line.prototype.intersectLineLine = function (line) { + }; + Line.prototype.perp = function (x, y, output) { if(this.y1 === this.y2) { if(output) { output.setTo(x, y, x, this.y1); @@ -3967,54 +2256,20 @@ var Phaser; return new Line(x, y, pt.x, pt.y); } }; - Line.prototype.toString = /* - intersectLineCircle (circle:Circle) - { - var perp = this.perp() - return Phaser.intersectLineCircle(this,circle); - - } - */ - /** - * - * @method toString - * @return {String} - */ - function () { + Line.prototype.toString = function () { return "[{Line (x1=" + this.x1 + " y1=" + this.y1 + " x2=" + this.x2 + " y2=" + this.y2 + ")}]"; }; return Line; })(); Phaser.Line = Line; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - IntersectResult -* -* A light-weight result object to hold the results of an intersection. For when you need more than just true/false. -*/ var Phaser; (function (Phaser) { var IntersectResult = (function () { function IntersectResult() { - /** - * Did they intersect or not? - * @property result - * @type Boolean - */ this.result = false; } - IntersectResult.prototype.setTo = /** - * - * @method setTo - * @param {Number} x1 - * @param {Number} y1 - * @param {Number} [x2] - * @param {Number} [y2] - * @param {Number} [width] - * @param {Number} [height] - */ - function (x1, y1, x2, y2, width, height) { + IntersectResult.prototype.setTo = function (x1, y1, x2, y2, width, height) { if (typeof x2 === "undefined") { x2 = 0; } if (typeof y2 === "undefined") { y2 = 0; } if (typeof width === "undefined") { width = 0; } @@ -4032,26 +2287,14 @@ var Phaser; })(); Phaser.IntersectResult = IntersectResult; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - LinkedList -* -* A miniature linked list class. Useful for optimizing time-critical or highly repetitive tasks! -*/ var Phaser; (function (Phaser) { var LinkedList = (function () { - /** - * Creates a new link, and sets object and next to null. - */ function LinkedList() { this.object = null; this.next = null; } - LinkedList.prototype.destroy = /** - * Clean up memory. - */ - function () { + LinkedList.prototype.destroy = function () { this.object = null; if(this.next != null) { this.next.destroy(); @@ -4062,42 +2305,20 @@ var Phaser; })(); Phaser.LinkedList = LinkedList; })(Phaser || (Phaser = {})); -/// -/// -/** -* Phaser - QuadTree -* -* A fairly generic quad tree structure for rapid overlap checks. QuadTree is also configured for single or dual list operation. -* You can add items either to its A list or its B list. When you do an overlap check, you can compare the A list to itself, -* or the A list against the B list. Handy for different things! -*/ var Phaser; (function (Phaser) { var QuadTree = (function (_super) { __extends(QuadTree, _super); - /** - * Instantiate a new Quad Tree node. - * - * @param X The X-coordinate of the point in space. - * @param Y The Y-coordinate of the point in space. - * @param Width Desired width of this node. - * @param Height Desired height of this node. - * @param Parent The parent branch or node. Pass null to create a root. - */ function QuadTree(X, Y, Width, Height, Parent) { if (typeof Parent === "undefined") { Parent = null; } _super.call(this, X, Y, Width, Height); - //console.log('-------- QuadTree',X,Y,Width,Height); this._headA = this._tailA = new Phaser.LinkedList(); this._headB = this._tailB = new Phaser.LinkedList(); - //Copy the parent's children (if there are any) if(Parent != null) { - //console.log('Parent not null'); var iterator; var ot; if(Parent._headA.object != null) { iterator = Parent._headA; - //console.log('iterator set to parent headA'); while(iterator != null) { if(this._tailA.object != null) { ot = this._tailA; @@ -4110,7 +2331,6 @@ var Phaser; } if(Parent._headB.object != null) { iterator = Parent._headB; - //console.log('iterator set to parent headB'); while(iterator != null) { if(this._tailB.object != null) { ot = this._tailB; @@ -4125,8 +2345,6 @@ var Phaser; QuadTree._min = (this.width + this.height) / (2 * QuadTree.divisions); } this._canSubdivide = (this.width > QuadTree._min) || (this.height > QuadTree._min); - //console.log('canSubdivided', this._canSubdivide); - //Set up comparison/sort helpers this._northWestTree = null; this._northEastTree = null; this._southEastTree = null; @@ -4142,10 +2360,7 @@ var Phaser; } QuadTree.A_LIST = 0; QuadTree.B_LIST = 1; - QuadTree.prototype.destroy = /** - * Clean up memory. - */ - function () { + QuadTree.prototype.destroy = function () { this._tailA.destroy(); this._tailB.destroy(); this._headA.destroy(); @@ -4174,19 +2389,10 @@ var Phaser; QuadTree._processingCallback = null; QuadTree._notifyCallback = null; }; - QuadTree.prototype.load = /** - * Load objects and/or groups into the quad tree, and register notify and processing callbacks. - * - * @param ObjectOrGroup1 Any object that is or extends GameObject or Group. - * @param ObjectOrGroup2 Any object that is or extends GameObject or Group. If null, the first parameter will be checked against itself. - * @param NotifyCallback A function with the form myFunction(Object1:GameObject,Object2:GameObject) that is called whenever two objects are found to overlap in world space, and either no ProcessCallback is specified, or the ProcessCallback returns true. - * @param ProcessCallback A function with the form myFunction(Object1:GameObject,Object2:GameObject):bool that is called whenever two objects are found to overlap in world space. The NotifyCallback is only called if this function returns true. See GameObject.separate(). - */ - function (ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, ProcessCallback) { + QuadTree.prototype.load = function (ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, ProcessCallback) { if (typeof ObjectOrGroup2 === "undefined") { ObjectOrGroup2 = null; } if (typeof NotifyCallback === "undefined") { NotifyCallback = null; } if (typeof ProcessCallback === "undefined") { ProcessCallback = null; } - //console.log('quadtree load', QuadTree.divisions, ObjectOrGroup1, ObjectOrGroup2); this.add(ObjectOrGroup1, QuadTree.A_LIST); if(ObjectOrGroup2 != null) { this.add(ObjectOrGroup2, QuadTree.B_LIST); @@ -4196,18 +2402,8 @@ var Phaser; } QuadTree._notifyCallback = NotifyCallback; QuadTree._processingCallback = ProcessCallback; - //console.log('use both', QuadTree._useBothLists); - //console.log('------------ end of load'); - }; - QuadTree.prototype.add = /** - * Call this function to add an object to the root of the tree. - * This function will recursively add all group members, but - * not the groups themselves. - * - * @param ObjectOrGroup GameObjects are just added, Groups are recursed and their applicable members added accordingly. - * @param List A uint flag indicating the list to which you want to add the objects. Options are QuadTree.A_LIST and QuadTree.B_LIST. - */ - function (ObjectOrGroup, List) { + }; + QuadTree.prototype.add = function (ObjectOrGroup, List) { QuadTree._list = List; if(ObjectOrGroup.isGroup == true) { var i = 0; @@ -4233,33 +2429,22 @@ var Phaser; } } else { QuadTree._object = ObjectOrGroup; - //console.log('add - not group:', ObjectOrGroup.name); if(QuadTree._object.exists && QuadTree._object.allowCollisions) { QuadTree._objectLeftEdge = QuadTree._object.x; QuadTree._objectTopEdge = QuadTree._object.y; QuadTree._objectRightEdge = QuadTree._object.x + QuadTree._object.width; QuadTree._objectBottomEdge = QuadTree._object.y + QuadTree._object.height; - //console.log('object properties', QuadTree._objectLeftEdge, QuadTree._objectTopEdge, QuadTree._objectRightEdge, QuadTree._objectBottomEdge); this.addObject(); } } }; - QuadTree.prototype.addObject = /** - * Internal function for recursively navigating and creating the tree - * while adding objects to the appropriate nodes. - */ - function () { - //console.log('addObject'); - //If this quad (not its children) lies entirely inside this object, add it here + QuadTree.prototype.addObject = function () { if(!this._canSubdivide || ((this._leftEdge >= QuadTree._objectLeftEdge) && (this._rightEdge <= QuadTree._objectRightEdge) && (this._topEdge >= QuadTree._objectTopEdge) && (this._bottomEdge <= QuadTree._objectBottomEdge))) { - //console.log('add To List'); this.addToList(); return; } - //See if the selected object fits completely inside any of the quadrants if((QuadTree._objectLeftEdge > this._leftEdge) && (QuadTree._objectRightEdge < this._midpointX)) { if((QuadTree._objectTopEdge > this._topEdge) && (QuadTree._objectBottomEdge < this._midpointY)) { - //console.log('Adding NW tree'); if(this._northWestTree == null) { this._northWestTree = new QuadTree(this._leftEdge, this._topEdge, this._halfWidth, this._halfHeight, this); } @@ -4267,7 +2452,6 @@ var Phaser; return; } if((QuadTree._objectTopEdge > this._midpointY) && (QuadTree._objectBottomEdge < this._bottomEdge)) { - //console.log('Adding SW tree'); if(this._southWestTree == null) { this._southWestTree = new QuadTree(this._leftEdge, this._midpointY, this._halfWidth, this._halfHeight, this); } @@ -4277,7 +2461,6 @@ var Phaser; } if((QuadTree._objectLeftEdge > this._midpointX) && (QuadTree._objectRightEdge < this._rightEdge)) { if((QuadTree._objectTopEdge > this._topEdge) && (QuadTree._objectBottomEdge < this._midpointY)) { - //console.log('Adding NE tree'); if(this._northEastTree == null) { this._northEastTree = new QuadTree(this._midpointX, this._topEdge, this._halfWidth, this._halfHeight, this); } @@ -4285,7 +2468,6 @@ var Phaser; return; } if((QuadTree._objectTopEdge > this._midpointY) && (QuadTree._objectBottomEdge < this._bottomEdge)) { - //console.log('Adding SE tree'); if(this._southEastTree == null) { this._southEastTree = new QuadTree(this._midpointX, this._midpointY, this._halfWidth, this._halfHeight, this); } @@ -4293,44 +2475,34 @@ var Phaser; return; } } - //If it wasn't completely contained we have to check out the partial overlaps if((QuadTree._objectRightEdge > this._leftEdge) && (QuadTree._objectLeftEdge < this._midpointX) && (QuadTree._objectBottomEdge > this._topEdge) && (QuadTree._objectTopEdge < this._midpointY)) { if(this._northWestTree == null) { this._northWestTree = new QuadTree(this._leftEdge, this._topEdge, this._halfWidth, this._halfHeight, this); } - //console.log('added to north west partial tree'); this._northWestTree.addObject(); } if((QuadTree._objectRightEdge > this._midpointX) && (QuadTree._objectLeftEdge < this._rightEdge) && (QuadTree._objectBottomEdge > this._topEdge) && (QuadTree._objectTopEdge < this._midpointY)) { if(this._northEastTree == null) { this._northEastTree = new QuadTree(this._midpointX, this._topEdge, this._halfWidth, this._halfHeight, this); } - //console.log('added to north east partial tree'); this._northEastTree.addObject(); } if((QuadTree._objectRightEdge > this._midpointX) && (QuadTree._objectLeftEdge < this._rightEdge) && (QuadTree._objectBottomEdge > this._midpointY) && (QuadTree._objectTopEdge < this._bottomEdge)) { if(this._southEastTree == null) { this._southEastTree = new QuadTree(this._midpointX, this._midpointY, this._halfWidth, this._halfHeight, this); } - //console.log('added to south east partial tree'); this._southEastTree.addObject(); } if((QuadTree._objectRightEdge > this._leftEdge) && (QuadTree._objectLeftEdge < this._midpointX) && (QuadTree._objectBottomEdge > this._midpointY) && (QuadTree._objectTopEdge < this._bottomEdge)) { if(this._southWestTree == null) { this._southWestTree = new QuadTree(this._leftEdge, this._midpointY, this._halfWidth, this._halfHeight, this); } - //console.log('added to south west partial tree'); this._southWestTree.addObject(); } }; - QuadTree.prototype.addToList = /** - * Internal function for recursively adding objects to leaf lists. - */ - function () { - //console.log('Adding to List'); + QuadTree.prototype.addToList = function () { var ot; if(QuadTree._list == QuadTree.A_LIST) { - //console.log('A LIST'); if(this._tailA.object != null) { ot = this._tailA; this._tailA = new Phaser.LinkedList(); @@ -4338,7 +2510,6 @@ var Phaser; } this._tailA.object = QuadTree._object; } else { - //console.log('B LIST'); if(this._tailB.object != null) { ot = this._tailB; this._tailB = new Phaser.LinkedList(); @@ -4362,19 +2533,10 @@ var Phaser; this._southWestTree.addToList(); } }; - QuadTree.prototype.execute = /** - * QuadTree's other main function. Call this after adding objects - * using QuadTree.load() to compare the objects that you loaded. - * - * @return Whether or not any overlaps were found. - */ - function () { - //console.log('quadtree execute'); + QuadTree.prototype.execute = function () { var overlapProcessed = false; var iterator; if(this._headA.object != null) { - //console.log('---------------------------------------------------'); - //console.log('headA iterator'); iterator = this._headA; while(iterator != null) { QuadTree._object = iterator.object; @@ -4384,70 +2546,50 @@ var Phaser; QuadTree._iterator = iterator.next; } if(QuadTree._object.exists && (QuadTree._object.allowCollisions > 0) && (QuadTree._iterator != null) && (QuadTree._iterator.object != null) && QuadTree._iterator.object.exists && this.overlapNode()) { - //console.log('headA iterator overlapped true'); overlapProcessed = true; } iterator = iterator.next; } } - //Advance through the tree by calling overlap on each child if((this._northWestTree != null) && this._northWestTree.execute()) { - //console.log('NW quadtree execute'); overlapProcessed = true; } if((this._northEastTree != null) && this._northEastTree.execute()) { - //console.log('NE quadtree execute'); overlapProcessed = true; } if((this._southEastTree != null) && this._southEastTree.execute()) { - //console.log('SE quadtree execute'); overlapProcessed = true; } if((this._southWestTree != null) && this._southWestTree.execute()) { - //console.log('SW quadtree execute'); overlapProcessed = true; } return overlapProcessed; }; - QuadTree.prototype.overlapNode = /** - * An private for comparing an object against the contents of a node. - * - * @return Whether or not any overlaps were found. - */ - function () { - //console.log('overlapNode'); - //Walk the list and check for overlaps + QuadTree.prototype.overlapNode = function () { var overlapProcessed = false; var checkObject; while(QuadTree._iterator != null) { if(!QuadTree._object.exists || (QuadTree._object.allowCollisions <= 0)) { - //console.log('break 1'); break; } checkObject = QuadTree._iterator.object; if((QuadTree._object === checkObject) || !checkObject.exists || (checkObject.allowCollisions <= 0)) { - //console.log('break 2'); QuadTree._iterator = QuadTree._iterator.next; continue; } - //calculate bulk hull for QuadTree._object QuadTree._objectHullX = (QuadTree._object.x < QuadTree._object.last.x) ? QuadTree._object.x : QuadTree._object.last.x; QuadTree._objectHullY = (QuadTree._object.y < QuadTree._object.last.y) ? QuadTree._object.y : QuadTree._object.last.y; QuadTree._objectHullWidth = QuadTree._object.x - QuadTree._object.last.x; QuadTree._objectHullWidth = QuadTree._object.width + ((QuadTree._objectHullWidth > 0) ? QuadTree._objectHullWidth : -QuadTree._objectHullWidth); QuadTree._objectHullHeight = QuadTree._object.y - QuadTree._object.last.y; QuadTree._objectHullHeight = QuadTree._object.height + ((QuadTree._objectHullHeight > 0) ? QuadTree._objectHullHeight : -QuadTree._objectHullHeight); - //calculate bulk hull for checkObject QuadTree._checkObjectHullX = (checkObject.x < checkObject.last.x) ? checkObject.x : checkObject.last.x; QuadTree._checkObjectHullY = (checkObject.y < checkObject.last.y) ? checkObject.y : checkObject.last.y; QuadTree._checkObjectHullWidth = checkObject.x - checkObject.last.x; QuadTree._checkObjectHullWidth = checkObject.width + ((QuadTree._checkObjectHullWidth > 0) ? QuadTree._checkObjectHullWidth : -QuadTree._checkObjectHullWidth); QuadTree._checkObjectHullHeight = checkObject.y - checkObject.last.y; QuadTree._checkObjectHullHeight = checkObject.height + ((QuadTree._checkObjectHullHeight > 0) ? QuadTree._checkObjectHullHeight : -QuadTree._checkObjectHullHeight); - //check for intersection of the two hulls if((QuadTree._objectHullX + QuadTree._objectHullWidth > QuadTree._checkObjectHullX) && (QuadTree._objectHullX < QuadTree._checkObjectHullX + QuadTree._checkObjectHullWidth) && (QuadTree._objectHullY + QuadTree._objectHullHeight > QuadTree._checkObjectHullY) && (QuadTree._objectHullY < QuadTree._checkObjectHullY + QuadTree._checkObjectHullHeight)) { - //console.log('intersection!'); - //Execute callback functions if they exist if((QuadTree._processingCallback == null) || QuadTree._processingCallback(QuadTree._object, checkObject)) { overlapProcessed = true; } @@ -4463,18 +2605,6 @@ var Phaser; })(Phaser.Rectangle); Phaser.QuadTree = QuadTree; })(Phaser || (Phaser = {})); -/// -/// -/// -/// -/// -/// -/// -/** -* Phaser - Collision -* -* A set of extremely useful collision and geometry intersection functions. -*/ var Phaser; (function (Phaser) { var Collision = (function () { @@ -4491,71 +2621,38 @@ var Phaser; Collision.WALL = Collision.LEFT | Collision.RIGHT; Collision.ANY = Collision.LEFT | Collision.RIGHT | Collision.UP | Collision.DOWN; Collision.OVERLAP_BIAS = 4; - Collision.lineToLine = /** - * ------------------------------------------------------------------------------------------- - * Lines - * ------------------------------------------------------------------------------------------- - **/ - /** - * Check if the two given Line objects intersect - * @method lineToLine - * @param {Phaser.Line} The first line object to check - * @param {Phaser.Line} The second line object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y - **/ - function lineToLine(line1, line2, output) { + Collision.lineToLine = function lineToLine(line1, line2, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } - var denom = (line1.x1 - line1.x2) * (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * (line2.x1 - line2.x2); - if(denom !== 0) { + var denominator = (line1.x1 - line1.x2) * (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * (line2.x1 - line2.x2); + if(denominator !== 0) { output.result = true; - output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (line2.x1 - line2.x2) - (line1.x1 - line1.x2) * (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denom; - output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denom; + output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (line2.x1 - line2.x2) - (line1.x1 - line1.x2) * (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denominator; + output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denominator; } return output; }; - Collision.lineToLineSegment = /** - * Check if the Line and Line Segment intersects - * @method lineToLineSegment - * @param {Phaser.Line} The line object to check - * @param {Phaser.Line} The line segment object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y - **/ - function lineToLineSegment(line1, seg, output) { + Collision.lineToLineSegment = function lineToLineSegment(line, seg, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } - var denom = (line1.x1 - line1.x2) * (seg.y1 - seg.y2) - (line1.y1 - line1.y2) * (seg.x1 - seg.x2); - if(denom !== 0) { - output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (seg.x1 - seg.x2) - (line1.x1 - line1.x2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denom; - output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (seg.y1 - seg.y2) - (line1.y1 - line1.y2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denom; + var denominator = (line.x1 - line.x2) * (seg.y1 - seg.y2) - (line.y1 - line.y2) * (seg.x1 - seg.x2); + if(denominator !== 0) { + output.x = ((line.x1 * line.y2 - line.y1 * line.x2) * (seg.x1 - seg.x2) - (line.x1 - line.x2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denominator; + output.y = ((line.x1 * line.y2 - line.y1 * line.x2) * (seg.y1 - seg.y2) - (line.y1 - line.y2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denominator; var maxX = Math.max(seg.x1, seg.x2); var minX = Math.min(seg.x1, seg.x2); var maxY = Math.max(seg.y1, seg.y2); var minY = Math.min(seg.y1, seg.y2); - //if (!(output.x <= maxX && output.x >= minX) || !(output.y <= maxY && output.y >= minY)) if((output.x <= maxX && output.x >= minX) === true || (output.y <= maxY && output.y >= minY) === true) { output.result = true; } } return output; }; - Collision.lineToRawSegment = /** - * Check if the Line and Line Segment intersects - * @method lineToLineSegment - * @param {Phaser.Line} The line object to check - * @param {number} The x1 value - * @param {number} The y1 value - * @param {number} The x2 value - * @param {number} The y2 value - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y - **/ - function lineToRawSegment(line, x1, y1, x2, y2, output) { + Collision.lineToRawSegment = function lineToRawSegment(line, x1, y1, x2, y2, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } - var denom = (line.x1 - line.x2) * (y1 - y2) - (line.y1 - line.y2) * (x1 - x2); - if(denom !== 0) { - output.x = ((line.x1 * line.y2 - line.y1 * line.x2) * (x1 - x2) - (line.x1 - line.x2) * (x1 * y2 - y1 * x2)) / denom; - output.y = ((line.x1 * line.y2 - line.y1 * line.x2) * (y1 - y2) - (line.y1 - line.y2) * (x1 * y2 - y1 * x2)) / denom; + var denominator = (line.x1 - line.x2) * (y1 - y2) - (line.y1 - line.y2) * (x1 - x2); + if(denominator !== 0) { + output.x = ((line.x1 * line.y2 - line.y1 * line.x2) * (x1 - x2) - (line.x1 - line.x2) * (x1 * y2 - y1 * x2)) / denominator; + output.y = ((line.x1 * line.y2 - line.y1 * line.x2) * (y1 - y2) - (line.y1 - line.y2) * (x1 * y2 - y1 * x2)) / denominator; var maxX = Math.max(x1, x2); var minX = Math.min(x1, x2); var maxY = Math.max(y1, y2); @@ -4566,22 +2663,13 @@ var Phaser; } return output; }; - Collision.lineToRay = /** - * Check if the Line and Ray intersects - * @method lineToRay - * @param {Phaser.Line} The Line object to check - * @param {Phaser.Line} The Ray object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y - **/ - function lineToRay(line1, ray, output) { + Collision.lineToRay = function lineToRay(line1, ray, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } - var denom = (line1.x1 - line1.x2) * (ray.y1 - ray.y2) - (line1.y1 - line1.y2) * (ray.x1 - ray.x2); - if(denom !== 0) { - output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (ray.x1 - ray.x2) - (line1.x1 - line1.x2) * (ray.x1 * ray.y2 - ray.y1 * ray.x2)) / denom; - output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (ray.y1 - ray.y2) - (line1.y1 - line1.y2) * (ray.x1 * ray.y2 - ray.y1 * ray.x2)) / denom; - output.result = true// true unless either of the 2 following conditions are met - ; + var denominator = (line1.x1 - line1.x2) * (ray.y1 - ray.y2) - (line1.y1 - line1.y2) * (ray.x1 - ray.x2); + if(denominator !== 0) { + output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (ray.x1 - ray.x2) - (line1.x1 - line1.x2) * (ray.x1 * ray.y2 - ray.y1 * ray.x2)) / denominator; + output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (ray.y1 - ray.y2) - (line1.y1 - line1.y2) * (ray.x1 * ray.y2 - ray.y1 * ray.x2)) / denominator; + output.result = true; if(!(ray.x1 >= ray.x2) && output.x < ray.x1) { output.result = false; } @@ -4591,67 +2679,33 @@ var Phaser; } return output; }; - Collision.lineToCircle = /** - * Check if the Line and Circle intersects - * @method lineToCircle - * @param {Phaser.Line} The Line object to check - * @param {Phaser.Circle} The Circle object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection - **/ - function lineToCircle(line, circle, output) { + Collision.lineToCircle = function lineToCircle(line, circle, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } - // Get a perpendicular line running to the center of the circle if(line.perp(circle.x, circle.y).length <= circle.radius) { output.result = true; } return output; }; - Collision.lineToRectangle = /** - * Check if the Line intersects each side of the Rectangle - * @method lineToRectangle - * @param {Phaser.Line} The Line object to check - * @param {Phaser.Rectangle} The Rectangle object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection - **/ - function lineToRectangle(line, rect, output) { + Collision.lineToRectangle = function lineToRectangle(line, rect, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } - // Top of the Rectangle vs the Line - this.lineToRawSegment(line, rect.x, rect.y, rect.right, rect.y, output); + Collision.lineToRawSegment(line, rect.x, rect.y, rect.right, rect.y, output); if(output.result === true) { return output; } - // Left of the Rectangle vs the Line - this.lineToRawSegment(line, rect.x, rect.y, rect.x, rect.bottom, output); + Collision.lineToRawSegment(line, rect.x, rect.y, rect.x, rect.bottom, output); if(output.result === true) { return output; } - // Bottom of the Rectangle vs the Line - this.lineToRawSegment(line, rect.x, rect.bottom, rect.right, rect.bottom, output); + Collision.lineToRawSegment(line, rect.x, rect.bottom, rect.right, rect.bottom, output); if(output.result === true) { return output; } - // Right of the Rectangle vs the Line - this.lineToRawSegment(line, rect.right, rect.y, rect.right, rect.bottom, output); + Collision.lineToRawSegment(line, rect.right, rect.y, rect.right, rect.bottom, output); return output; }; - Collision.lineSegmentToLineSegment = /** - * ------------------------------------------------------------------------------------------- - * Line Segment - * ------------------------------------------------------------------------------------------- - **/ - /** - * Check if Line1 intersects with Line2 - * @method lineSegmentToLineSegment - * @param {Phaser.Line} The first line object to check - * @param {Phaser.Line} The second line object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y - **/ - function lineSegmentToLineSegment(line1, line2, output) { + Collision.lineSegmentToLineSegment = function lineSegmentToLineSegment(line1, line2, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } - this.lineToLineSegment(line1, line2, output); + Collision.lineToLineSegment(line1, line2); if(output.result === true) { if(!(output.x >= Math.min(line1.x1, line1.x2) && output.x <= Math.max(line1.x1, line1.x2) && output.y >= Math.min(line1.y1, line1.y2) && output.y <= Math.max(line1.y1, line1.y2))) { output.result = false; @@ -4659,37 +2713,20 @@ var Phaser; } return output; }; - Collision.lineSegmentToRay = /** - * Check if the Line Segment intersects with the Ray - * @method lineSegmentToRay - * @param {Phaser.Line} The Line object to check - * @param {Phaser.Line} The Line Ray object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y - **/ - function lineSegmentToRay(line1, ray, output) { + Collision.lineSegmentToRay = function lineSegmentToRay(line, ray, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } - this.lineToRay(line1, ray, output); + Collision.lineToRay(line, ray, output); if(output.result === true) { - if(!(output.x >= Math.min(line1.x1, line1.x2) && output.x <= Math.max(line1.x1, line1.x2) && output.y >= Math.min(line1.y1, line1.y2) && output.y <= Math.max(line1.y1, line1.y2))) { + if(!(output.x >= Math.min(line.x1, line.x2) && output.x <= Math.max(line.x1, line.x2) && output.y >= Math.min(line.y1, line.y2) && output.y <= Math.max(line.y1, line.y2))) { output.result = false; } } return output; }; - Collision.lineSegmentToCircle = /** - * Check if the Line Segment intersects with the Circle - * @method lineSegmentToCircle - * @param {Phaser.Line} The Line object to check - * @param {Phaser.Circle} The Circle object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y - **/ - function lineSegmentToCircle(seg, circle, output) { + Collision.lineSegmentToCircle = function lineSegmentToCircle(seg, circle, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } var perp = seg.perp(circle.x, circle.y); if(perp.length <= circle.radius) { - // Line intersects circle - check if segment does var maxX = Math.max(seg.x1, seg.x2); var minX = Math.min(seg.x1, seg.x2); var maxY = Math.max(seg.y1, seg.y2); @@ -4697,11 +2734,10 @@ var Phaser; if((perp.x2 <= maxX && perp.x2 >= minX) && (perp.y2 <= maxY && perp.y2 >= minY)) { output.result = true; } else { - // Worst case - segment doesn't traverse center, so no perpendicular connection. - if(this.circleContainsPoint(circle, { + if(Collision.circleContainsPoint(circle, { x: seg.x1, y: seg.y1 - }) || this.circleContainsPoint(circle, { + }) || Collision.circleContainsPoint(circle, { x: seg.x2, y: seg.y2 })) { @@ -4711,120 +2747,61 @@ var Phaser; } return output; }; - Collision.lineSegmentToRectangle = /** - * Check if the Line Segment intersects with the Rectangle - * @method lineSegmentToCircle - * @param {Phaser.Line} The Line object to check - * @param {Phaser.Circle} The Circle object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y - **/ - function lineSegmentToRectangle(seg, rect, output) { + Collision.lineSegmentToRectangle = function lineSegmentToRectangle(seg, rect, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } if(rect.contains(seg.x1, seg.y1) && rect.contains(seg.x2, seg.y2)) { output.result = true; } else { - // Top of the Rectangle vs the Line - this.lineToRawSegment(seg, rect.x, rect.y, rect.right, rect.bottom, output); + Collision.lineToRawSegment(seg, rect.x, rect.y, rect.right, rect.bottom, output); if(output.result === true) { return output; } - // Left of the Rectangle vs the Line - this.lineToRawSegment(seg, rect.x, rect.y, rect.x, rect.bottom, output); + Collision.lineToRawSegment(seg, rect.x, rect.y, rect.x, rect.bottom, output); if(output.result === true) { return output; } - // Bottom of the Rectangle vs the Line - this.lineToRawSegment(seg, rect.x, rect.bottom, rect.right, rect.bottom, output); + Collision.lineToRawSegment(seg, rect.x, rect.bottom, rect.right, rect.bottom, output); if(output.result === true) { return output; } - // Right of the Rectangle vs the Line - this.lineToRawSegment(seg, rect.right, rect.y, rect.right, rect.bottom, output); + Collision.lineToRawSegment(seg, rect.right, rect.y, rect.right, rect.bottom, output); return output; } return output; }; - Collision.rayToRectangle = /** - * ------------------------------------------------------------------------------------------- - * Ray - * ------------------------------------------------------------------------------------------- - **/ - /** - * Check if the two given Circle objects intersect - * @method circleToCircle - * @param {Phaser.Circle} The first circle object to check - * @param {Phaser.Circle} The second circle object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection - **/ - function rayToRectangle(ray, rect, output) { + Collision.rayToRectangle = function rayToRectangle(ray, rect, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } - // Currently just finds first intersection - might not be closest to ray pt1 - this.lineToRectangle(ray, rect, output); + Collision.lineToRectangle(ray, rect, output); return output; }; - Collision.rayToLineSegment = /** - * Check whether a ray intersects a line segment, returns the parametric value where the intersection occurs. - * @method rayToLineSegment - * @static - * @param {Number} rayx1. The origin x of the ray. - * @param {Number} rayy1. The origin y of the ray. - * @param {Number} rayx2. The direction x of the ray. - * @param {Number} rayy2. The direction y of the ray. - * @param {Number} linex1. The x of the first point of the line segment. - * @param {Number} liney1. The y of the first point of the line segment. - * @param {Number} linex2. The x of the second point of the line segment. - * @param {Number} liney2. The y of the second point of the line segment. - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection stored in x - **/ - function rayToLineSegment(rayx1, rayy1, rayx2, rayy2, linex1, liney1, linex2, liney2, output) { + Collision.rayToLineSegment = function rayToLineSegment(rayX1, rayY1, rayX2, rayY2, lineX1, lineY1, lineX2, lineY2, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } - var r, s, d; - // Check lines are not parallel - if((rayy2 - rayy1) / (rayx2 - rayx1) != (liney2 - liney1) / (linex2 - linex1)) { - d = (((rayx2 - rayx1) * (liney2 - liney1)) - (rayy2 - rayy1) * (linex2 - linex1)); + var r; + var s; + var d; + if((rayY2 - rayY1) / (rayX2 - rayX1) != (lineY2 - lineY1) / (lineX2 - lineX1)) { + d = (((rayX2 - rayX1) * (lineY2 - lineY1)) - (rayY2 - rayY1) * (lineX2 - lineX1)); if(d != 0) { - r = (((rayy1 - liney1) * (linex2 - linex1)) - (rayx1 - linex1) * (liney2 - liney1)) / d; - s = (((rayy1 - liney1) * (rayx2 - rayx1)) - (rayx1 - linex1) * (rayy2 - rayy1)) / d; + r = (((rayY1 - lineY1) * (lineX2 - lineX1)) - (rayX1 - lineX1) * (lineY2 - lineY1)) / d; + s = (((rayY1 - lineY1) * (rayX2 - rayX1)) - (rayX1 - lineX1) * (rayY2 - rayY1)) / d; if(r >= 0) { if(s >= 0 && s <= 1) { output.result = true; - output.x = rayx1 + r * (rayx2 - rayx1) , rayy1 + r * (rayy2 - rayy1); + output.x = rayX1 + r * (rayX2 - rayX1); + output.y = rayY1 + r * (rayY2 - rayY1); } } } } return output; }; - Collision.pointToRectangle = /** - * ------------------------------------------------------------------------------------------- - * Rectangles - * ------------------------------------------------------------------------------------------- - **/ - /** - * Determines whether the specified point is contained within the rectangular region defined by the Rectangle object. - * @method pointToRectangle - * @param {Point} point The point object being checked. - * @param {Rectangle} rect The rectangle object being checked. - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y/result - **/ - function pointToRectangle(point, rect, output) { + Collision.pointToRectangle = function pointToRectangle(point, rect, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } output.setTo(point.x, point.y); output.result = rect.containsPoint(point); return output; }; - Collision.rectangleToRectangle = /** - * Check whether two axis aligned rectangles intersect. Return the intersecting rectangle dimensions if they do. - * @method rectangleToRectangle - * @param {Phaser.Rectangle} The first Rectangle object - * @param {Phaser.Rectangle} The second Rectangle object - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y/width/height - **/ - function rectangleToRectangle(rect1, rect2, output) { + Collision.rectangleToRectangle = function rectangleToRectangle(rect1, rect2, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } var leftX = Math.max(rect1.x, rect2.x); var rightX = Math.min(rect1.right, rect2.right); @@ -4840,279 +2817,151 @@ var Phaser; }; Collision.rectangleToCircle = function rectangleToCircle(rect, circle, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } - return this.circleToRectangle(circle, rect, output); + return Collision.circleToRectangle(circle, rect, output); }; - Collision.circleToCircle = /** - * ------------------------------------------------------------------------------------------- - * Circle - * ------------------------------------------------------------------------------------------- - **/ - /** - * Check if the two given Circle objects intersect - * @method circleToCircle - * @param {Phaser.Circle} The first circle object to check - * @param {Phaser.Circle} The second circle object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection - **/ - function circleToCircle(circle1, circle2, output) { + Collision.circleToCircle = function circleToCircle(circle1, circle2, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } - output.result = ((circle1.radius + circle2.radius) * (circle1.radius + circle2.radius)) >= this.distanceSquared(circle1.x, circle1.y, circle2.x, circle2.y); + output.result = ((circle1.radius + circle2.radius) * (circle1.radius + circle2.radius)) >= Collision.distanceSquared(circle1.x, circle1.y, circle2.x, circle2.y); return output; }; - Collision.circleToRectangle = /** - * Check if the given Rectangle intersects with the given Circle - * @method circleToRectangle - * @param {Phaser.Circle} The circle object to check - * @param {Phaser.Rectangle} The Rectangle object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection - **/ - function circleToRectangle(circle, rect, output) { + Collision.circleToRectangle = function circleToRectangle(circle, rect, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } var inflatedRect = rect.clone(); inflatedRect.inflate(circle.radius, circle.radius); output.result = inflatedRect.contains(circle.x, circle.y); return output; }; - Collision.circleContainsPoint = /** - * Check if the given Point is found within the given Circle - * @method circleContainsPoint - * @param {Phaser.Circle} The circle object to check - * @param {Phaser.Point} The point object to check - * @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given) - * @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection - **/ - function circleContainsPoint(circle, point, output) { + Collision.circleContainsPoint = function circleContainsPoint(circle, point, output) { if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } - output.result = circle.radius * circle.radius >= this.distanceSquared(circle.x, circle.y, point.x, point.y); + output.result = circle.radius * circle.radius >= Collision.distanceSquared(circle.x, circle.y, point.x, point.y); return output; }; - Collision.prototype.overlap = /** - * ------------------------------------------------------------------------------------------- - * Game Object Collision - * ------------------------------------------------------------------------------------------- - **/ - /** - * Call this function to see if one GameObject overlaps another. - * Can be called with one object and one group, or two groups, or two objects, - * whatever floats your boat! For maximum performance try bundling a lot of objects - * together using a Group (or even bundling groups together!). - * - *

              NOTE: does NOT take objects' scrollfactor into account, all overlaps are checked in world space.

              - * - * @param ObjectOrGroup1 The first object or group you want to check. - * @param ObjectOrGroup2 The second object or group you want to check. If it is the same as the first it knows to just do a comparison within that group. - * @param NotifyCallback A function with two GameObject parameters - e.g. myOverlapFunction(Object1:GameObject,Object2:GameObject) - that is called if those two objects overlap. - * @param ProcessCallback A function with two GameObject parameters - e.g. myOverlapFunction(Object1:GameObject,Object2:GameObject) - that is called if those two objects overlap. If a ProcessCallback is provided, then NotifyCallback will only be called if ProcessCallback returns true for those objects! - * - * @return Whether any overlaps were detected. - */ - function (ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, ProcessCallback) { - if (typeof ObjectOrGroup1 === "undefined") { ObjectOrGroup1 = null; } - if (typeof ObjectOrGroup2 === "undefined") { ObjectOrGroup2 = null; } - if (typeof NotifyCallback === "undefined") { NotifyCallback = null; } - if (typeof ProcessCallback === "undefined") { ProcessCallback = null; } - if(ObjectOrGroup1 == null) { - ObjectOrGroup1 = this._game.world.group; + Collision.prototype.overlap = function (object1, object2, notifyCallback, processCallback) { + if (typeof object1 === "undefined") { object1 = null; } + if (typeof object2 === "undefined") { object2 = null; } + if (typeof notifyCallback === "undefined") { notifyCallback = null; } + if (typeof processCallback === "undefined") { processCallback = null; } + if(object1 == null) { + object1 = this._game.world.group; } - if(ObjectOrGroup2 == ObjectOrGroup1) { - ObjectOrGroup2 = null; + if(object2 == object1) { + object2 = null; } Phaser.QuadTree.divisions = this._game.world.worldDivisions; var quadTree = new Phaser.QuadTree(this._game.world.bounds.x, this._game.world.bounds.y, this._game.world.bounds.width, this._game.world.bounds.height); - quadTree.load(ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, ProcessCallback); + quadTree.load(object1, object2, notifyCallback, processCallback); var result = quadTree.execute(); quadTree.destroy(); quadTree = null; return result; }; - Collision.separate = /** - * The main collision resolution in flixel. - * - * @param Object1 Any Sprite. - * @param Object2 Any other Sprite. - * - * @return Whether the objects in fact touched and were separated. - */ - function separate(Object1, Object2) { - var separatedX = Collision.separateX(Object1, Object2); - var separatedY = Collision.separateY(Object1, Object2); + Collision.separate = function separate(object1, object2) { + var separatedX = Collision.separateX(object1, object2); + var separatedY = Collision.separateY(object1, object2); return separatedX || separatedY; }; - Collision.separateX = /** - * The X-axis component of the object separation process. - * - * @param Object1 Any Sprite. - * @param Object2 Any other Sprite. - * - * @return Whether the objects in fact touched and were separated along the X axis. - */ - function separateX(Object1, Object2) { - //can't separate two immovable objects - var obj1immovable = Object1.immovable; - var obj2immovable = Object2.immovable; - if(obj1immovable && obj2immovable) { + Collision.separateTile = function separateTile(object, tile) { + var separatedX = Collision.separateTileX(object, tile); + var separatedY = Collision.separateTileY(object, tile); + return separatedX || separatedY; + }; + Collision.separateTileX = function separateTileX(object, tile) { + if(object.immovable && tile.immovable) { return false; } - //If one of the objects is a tilemap, just pass it off. - /* - if (typeof Object1 === 'Tilemap') - { - return Object1.overlapsWithCallback(Object2, separateX); - } - - if (typeof Object2 === 'Tilemap') - { - return Object2.overlapsWithCallback(Object1, separateX, true); - } - */ - //First, get the two object deltas var overlap = 0; - var obj1delta = Object1.x - Object1.last.x; - var obj2delta = Object2.x - Object2.last.x; - if(obj1delta != obj2delta) { - //Check if the X hulls actually overlap - var obj1deltaAbs = (obj1delta > 0) ? obj1delta : -obj1delta; - var obj2deltaAbs = (obj2delta > 0) ? obj2delta : -obj2delta; - var obj1rect = new Phaser.Rectangle(Object1.x - ((obj1delta > 0) ? obj1delta : 0), Object1.last.y, Object1.width + ((obj1delta > 0) ? obj1delta : -obj1delta), Object1.height); - var obj2rect = new Phaser.Rectangle(Object2.x - ((obj2delta > 0) ? obj2delta : 0), Object2.last.y, Object2.width + ((obj2delta > 0) ? obj2delta : -obj2delta), Object2.height); - if((obj1rect.x + obj1rect.width > obj2rect.x) && (obj1rect.x < obj2rect.x + obj2rect.width) && (obj1rect.y + obj1rect.height > obj2rect.y) && (obj1rect.y < obj2rect.y + obj2rect.height)) { - var maxOverlap = obj1deltaAbs + obj2deltaAbs + Collision.OVERLAP_BIAS; - //If they did overlap (and can), figure out by how much and flip the corresponding flags - if(obj1delta > obj2delta) { - overlap = Object1.x + Object1.width - Object2.x; - if((overlap > maxOverlap) || !(Object1.allowCollisions & Collision.RIGHT) || !(Object2.allowCollisions & Collision.LEFT)) { + var objDelta = object.x - object.last.x; + var tileDelta = 0; + if(objDelta != tileDelta) { + var objDeltaAbs = (objDelta > 0) ? objDelta : -objDelta; + var tileDeltaAbs = (tileDelta > 0) ? tileDelta : -tileDelta; + var objBounds = new Phaser.Quad(object.x - ((objDelta > 0) ? objDelta : 0), object.last.y, object.width + ((objDelta > 0) ? objDelta : -objDelta), object.height); + var tileBounds = new Phaser.Quad(tile.x - ((tileDelta > 0) ? tileDelta : 0), tile.y, tile.width + ((tileDelta > 0) ? tileDelta : -tileDelta), tile.height); + if((objBounds.x + objBounds.width > tileBounds.x) && (objBounds.x < tileBounds.x + tileBounds.width) && (objBounds.y + objBounds.height > tileBounds.y) && (objBounds.y < tileBounds.y + tileBounds.height)) { + var maxOverlap = objDeltaAbs + tileDeltaAbs + Collision.OVERLAP_BIAS; + if(objDelta > tileDelta) { + overlap = object.x + object.width - tile.x; + if((overlap > maxOverlap) || !(object.allowCollisions & Collision.RIGHT) || !(tile.allowCollisions & Collision.LEFT)) { overlap = 0; } else { - Object1.touching |= Collision.RIGHT; - Object2.touching |= Collision.LEFT; + object.touching |= Collision.RIGHT; } - } else if(obj1delta < obj2delta) { - overlap = Object1.x - Object2.width - Object2.x; - if((-overlap > maxOverlap) || !(Object1.allowCollisions & Collision.LEFT) || !(Object2.allowCollisions & Collision.RIGHT)) { + } else if(objDelta < tileDelta) { + overlap = object.x - tile.width - tile.x; + if((-overlap > maxOverlap) || !(object.allowCollisions & Collision.LEFT) || !(tile.allowCollisions & Collision.RIGHT)) { overlap = 0; } else { - Object1.touching |= Collision.LEFT; - Object2.touching |= Collision.RIGHT; + object.touching |= Collision.LEFT; } } } } - //Then adjust their positions and velocities accordingly (if there was any overlap) if(overlap != 0) { - var obj1v = Object1.velocity.x; - var obj2v = Object2.velocity.x; - if(!obj1immovable && !obj2immovable) { + var objVelocity = object.velocity.x; + var tileVelocity = 0; + if(!object.immovable && !tile.immovable) { overlap *= 0.5; - Object1.x = Object1.x - overlap; - Object2.x += overlap; - var obj1velocity = Math.sqrt((obj2v * obj2v * Object2.mass) / Object1.mass) * ((obj2v > 0) ? 1 : -1); - var obj2velocity = Math.sqrt((obj1v * obj1v * Object1.mass) / Object2.mass) * ((obj1v > 0) ? 1 : -1); - var average = (obj1velocity + obj2velocity) * 0.5; - obj1velocity -= average; - obj2velocity -= average; - Object1.velocity.x = average + obj1velocity * Object1.elasticity; - Object2.velocity.x = average + obj2velocity * Object2.elasticity; - } else if(!obj1immovable) { - Object1.x = Object1.x - overlap; - Object1.velocity.x = obj2v - obj1v * Object1.elasticity; - } else if(!obj2immovable) { - Object2.x += overlap; - Object2.velocity.x = obj1v - obj2v * Object2.elasticity; + object.x = object.x - overlap; + var objNewVelocity = Math.sqrt((tileVelocity * tileVelocity * tile.mass) / object.mass) * ((tileVelocity > 0) ? 1 : -1); + var tileNewVelocity = Math.sqrt((objVelocity * objVelocity * object.mass) / tile.mass) * ((objVelocity > 0) ? 1 : -1); + var average = (objNewVelocity + tileNewVelocity) * 0.5; + objNewVelocity -= average; + object.velocity.x = average + objNewVelocity * object.elasticity; + } else if(!object.immovable) { + object.x = object.x - overlap; + object.velocity.x = tileVelocity - objVelocity * object.elasticity; } return true; } else { return false; } }; - Collision.separateY = /** - * The Y-axis component of the object separation process. - * - * @param Object1 Any Sprite. - * @param Object2 Any other Sprite. - * - * @return Whether the objects in fact touched and were separated along the Y axis. - */ - function separateY(Object1, Object2) { - //can't separate two immovable objects - var obj1immovable = Object1.immovable; - var obj2immovable = Object2.immovable; - if(obj1immovable && obj2immovable) { + Collision.separateTileY = function separateTileY(object, tile) { + if(object.immovable && tile.immovable) { return false; } - //If one of the objects is a tilemap, just pass it off. - /* - if (typeof Object1 === 'Tilemap') - { - return Object1.overlapsWithCallback(Object2, separateY); - } - - if (typeof Object2 === 'Tilemap') - { - return Object2.overlapsWithCallback(Object1, separateY, true); - } - */ - //First, get the two object deltas var overlap = 0; - var obj1delta = Object1.y - Object1.last.y; - var obj2delta = Object2.y - Object2.last.y; - if(obj1delta != obj2delta) { - //Check if the Y hulls actually overlap - var obj1deltaAbs = (obj1delta > 0) ? obj1delta : -obj1delta; - var obj2deltaAbs = (obj2delta > 0) ? obj2delta : -obj2delta; - var obj1rect = new Phaser.Rectangle(Object1.x, Object1.y - ((obj1delta > 0) ? obj1delta : 0), Object1.width, Object1.height + obj1deltaAbs); - var obj2rect = new Phaser.Rectangle(Object2.x, Object2.y - ((obj2delta > 0) ? obj2delta : 0), Object2.width, Object2.height + obj2deltaAbs); - if((obj1rect.x + obj1rect.width > obj2rect.x) && (obj1rect.x < obj2rect.x + obj2rect.width) && (obj1rect.y + obj1rect.height > obj2rect.y) && (obj1rect.y < obj2rect.y + obj2rect.height)) { - var maxOverlap = obj1deltaAbs + obj2deltaAbs + Collision.OVERLAP_BIAS; - //If they did overlap (and can), figure out by how much and flip the corresponding flags - if(obj1delta > obj2delta) { - overlap = Object1.y + Object1.height - Object2.y; - if((overlap > maxOverlap) || !(Object1.allowCollisions & Collision.DOWN) || !(Object2.allowCollisions & Collision.UP)) { + var objDelta = object.y - object.last.y; + var tileDelta = 0; + if(objDelta != tileDelta) { + var objDeltaAbs = (objDelta > 0) ? objDelta : -objDelta; + var tileDeltaAbs = (tileDelta > 0) ? tileDelta : -tileDelta; + var objBounds = new Phaser.Quad(object.x, object.y - ((objDelta > 0) ? objDelta : 0), object.width, object.height + objDeltaAbs); + var tileBounds = new Phaser.Quad(tile.x, tile.y - ((tileDelta > 0) ? tileDelta : 0), tile.width, tile.height + tileDeltaAbs); + if((objBounds.x + objBounds.width > tileBounds.x) && (objBounds.x < tileBounds.x + tileBounds.width) && (objBounds.y + objBounds.height > tileBounds.y) && (objBounds.y < tileBounds.y + tileBounds.height)) { + var maxOverlap = objDeltaAbs + tileDeltaAbs + Collision.OVERLAP_BIAS; + if(objDelta > tileDelta) { + overlap = object.y + object.height - tile.y; + if((overlap > maxOverlap) || !(object.allowCollisions & Collision.DOWN) || !(tile.allowCollisions & Collision.UP)) { overlap = 0; } else { - Object1.touching |= Collision.DOWN; - Object2.touching |= Collision.UP; + object.touching |= Collision.DOWN; } - } else if(obj1delta < obj2delta) { - overlap = Object1.y - Object2.height - Object2.y; - if((-overlap > maxOverlap) || !(Object1.allowCollisions & Collision.UP) || !(Object2.allowCollisions & Collision.DOWN)) { + } else if(objDelta < tileDelta) { + overlap = object.y - tile.height - tile.y; + if((-overlap > maxOverlap) || !(object.allowCollisions & Collision.UP) || !(tile.allowCollisions & Collision.DOWN)) { overlap = 0; } else { - Object1.touching |= Collision.UP; - Object2.touching |= Collision.DOWN; + object.touching |= Collision.UP; } } } } - //Then adjust their positions and velocities accordingly (if there was any overlap) if(overlap != 0) { - var obj1v = Object1.velocity.y; - var obj2v = Object2.velocity.y; - if(!obj1immovable && !obj2immovable) { + var objVelocity = object.velocity.y; + var tileVelocity = 0; + if(!object.immovable && !tile.immovable) { overlap *= 0.5; - Object1.y = Object1.y - overlap; - Object2.y += overlap; - var obj1velocity = Math.sqrt((obj2v * obj2v * Object2.mass) / Object1.mass) * ((obj2v > 0) ? 1 : -1); - var obj2velocity = Math.sqrt((obj1v * obj1v * Object1.mass) / Object2.mass) * ((obj1v > 0) ? 1 : -1); - var average = (obj1velocity + obj2velocity) * 0.5; - obj1velocity -= average; - obj2velocity -= average; - Object1.velocity.y = average + obj1velocity * Object1.elasticity; - Object2.velocity.y = average + obj2velocity * Object2.elasticity; - } else if(!obj1immovable) { - Object1.y = Object1.y - overlap; - Object1.velocity.y = obj2v - obj1v * Object1.elasticity; - //This is special case code that handles cases like horizontal moving platforms you can ride - if(Object2.active && Object2.moves && (obj1delta > obj2delta)) { - Object1.x += Object2.x - Object2.last.x; - } - } else if(!obj2immovable) { - Object2.y += overlap; - Object2.velocity.y = obj1v - obj2v * Object2.elasticity; - //This is special case code that handles cases like horizontal moving platforms you can ride - if(Object1.active && Object1.moves && (obj1delta < obj2delta)) { - Object2.x += Object1.x - Object1.last.x; + object.y = object.y - overlap; + var objNewVelocity = Math.sqrt((tileVelocity * tileVelocity * tile.mass) / object.mass) * ((tileVelocity > 0) ? 1 : -1); + var tileNewVelocity = Math.sqrt((objVelocity * objVelocity * object.mass) / tile.mass) * ((objVelocity > 0) ? 1 : -1); + var average = (objNewVelocity + tileNewVelocity) * 0.5; + objNewVelocity -= average; + object.velocity.y = average + objNewVelocity * object.elasticity; + } else if(!object.immovable) { + object.y = object.y - overlap; + object.velocity.y = tileVelocity - objVelocity * object.elasticity; + if(tile.active && tile.moves && (objDelta > tileDelta)) { } } return true; @@ -5120,12 +2969,131 @@ var Phaser; return false; } }; - Collision.distance = /** - * ------------------------------------------------------------------------------------------- - * Distance - * ------------------------------------------------------------------------------------------- - **/ - function distance(x1, y1, x2, y2) { + Collision.separateX = function separateX(object1, object2) { + if(object1.immovable && object2.immovable) { + return false; + } + var overlap = 0; + var obj1Delta = object1.x - object1.last.x; + var obj2Delta = object2.x - object2.last.x; + if(obj1Delta != obj2Delta) { + var obj1DeltaAbs = (obj1Delta > 0) ? obj1Delta : -obj1Delta; + var obj2DeltaAbs = (obj2Delta > 0) ? obj2Delta : -obj2Delta; + var obj1Bounds = new Phaser.Quad(object1.x - ((obj1Delta > 0) ? obj1Delta : 0), object1.last.y, object1.width + ((obj1Delta > 0) ? obj1Delta : -obj1Delta), object1.height); + var obj2Bounds = new Phaser.Quad(object2.x - ((obj2Delta > 0) ? obj2Delta : 0), object2.last.y, object2.width + ((obj2Delta > 0) ? obj2Delta : -obj2Delta), object2.height); + if((obj1Bounds.x + obj1Bounds.width > obj2Bounds.x) && (obj1Bounds.x < obj2Bounds.x + obj2Bounds.width) && (obj1Bounds.y + obj1Bounds.height > obj2Bounds.y) && (obj1Bounds.y < obj2Bounds.y + obj2Bounds.height)) { + var maxOverlap = obj1DeltaAbs + obj2DeltaAbs + Collision.OVERLAP_BIAS; + if(obj1Delta > obj2Delta) { + overlap = object1.x + object1.width - object2.x; + if((overlap > maxOverlap) || !(object1.allowCollisions & Collision.RIGHT) || !(object2.allowCollisions & Collision.LEFT)) { + overlap = 0; + } else { + object1.touching |= Collision.RIGHT; + object2.touching |= Collision.LEFT; + } + } else if(obj1Delta < obj2Delta) { + overlap = object1.x - object2.width - object2.x; + if((-overlap > maxOverlap) || !(object1.allowCollisions & Collision.LEFT) || !(object2.allowCollisions & Collision.RIGHT)) { + overlap = 0; + } else { + object1.touching |= Collision.LEFT; + object2.touching |= Collision.RIGHT; + } + } + } + } + if(overlap != 0) { + var obj1Velocity = object1.velocity.x; + var obj2Velocity = object2.velocity.x; + if(!object1.immovable && !object2.immovable) { + overlap *= 0.5; + object1.x = object1.x - overlap; + object2.x += overlap; + var obj1NewVelocity = Math.sqrt((obj2Velocity * obj2Velocity * object2.mass) / object1.mass) * ((obj2Velocity > 0) ? 1 : -1); + var obj2NewVelocity = Math.sqrt((obj1Velocity * obj1Velocity * object1.mass) / object2.mass) * ((obj1Velocity > 0) ? 1 : -1); + var average = (obj1NewVelocity + obj2NewVelocity) * 0.5; + obj1NewVelocity -= average; + obj2NewVelocity -= average; + object1.velocity.x = average + obj1NewVelocity * object1.elasticity; + object2.velocity.x = average + obj2NewVelocity * object2.elasticity; + } else if(!object1.immovable) { + object1.x = object1.x - overlap; + object1.velocity.x = obj2Velocity - obj1Velocity * object1.elasticity; + } else if(!object2.immovable) { + object2.x += overlap; + object2.velocity.x = obj1Velocity - obj2Velocity * object2.elasticity; + } + return true; + } else { + return false; + } + }; + Collision.separateY = function separateY(object1, object2) { + if(object1.immovable && object2.immovable) { + return false; + } + var overlap = 0; + var obj1Delta = object1.y - object1.last.y; + var obj2Delta = object2.y - object2.last.y; + if(obj1Delta != obj2Delta) { + var obj1DeltaAbs = (obj1Delta > 0) ? obj1Delta : -obj1Delta; + var obj2DeltaAbs = (obj2Delta > 0) ? obj2Delta : -obj2Delta; + var obj1Bounds = new Phaser.Quad(object1.x, object1.y - ((obj1Delta > 0) ? obj1Delta : 0), object1.width, object1.height + obj1DeltaAbs); + var obj2Bounds = new Phaser.Quad(object2.x, object2.y - ((obj2Delta > 0) ? obj2Delta : 0), object2.width, object2.height + obj2DeltaAbs); + if((obj1Bounds.x + obj1Bounds.width > obj2Bounds.x) && (obj1Bounds.x < obj2Bounds.x + obj2Bounds.width) && (obj1Bounds.y + obj1Bounds.height > obj2Bounds.y) && (obj1Bounds.y < obj2Bounds.y + obj2Bounds.height)) { + var maxOverlap = obj1DeltaAbs + obj2DeltaAbs + Collision.OVERLAP_BIAS; + if(obj1Delta > obj2Delta) { + overlap = object1.y + object1.height - object2.y; + if((overlap > maxOverlap) || !(object1.allowCollisions & Collision.DOWN) || !(object2.allowCollisions & Collision.UP)) { + overlap = 0; + } else { + object1.touching |= Collision.DOWN; + object2.touching |= Collision.UP; + } + } else if(obj1Delta < obj2Delta) { + overlap = object1.y - object2.height - object2.y; + if((-overlap > maxOverlap) || !(object1.allowCollisions & Collision.UP) || !(object2.allowCollisions & Collision.DOWN)) { + overlap = 0; + } else { + object1.touching |= Collision.UP; + object2.touching |= Collision.DOWN; + } + } + } + } + if(overlap != 0) { + var obj1Velocity = object1.velocity.y; + var obj2Velocity = object2.velocity.y; + if(!object1.immovable && !object2.immovable) { + overlap *= 0.5; + object1.y = object1.y - overlap; + object2.y += overlap; + var obj1NewVelocity = Math.sqrt((obj2Velocity * obj2Velocity * object2.mass) / object1.mass) * ((obj2Velocity > 0) ? 1 : -1); + var obj2NewVelocity = Math.sqrt((obj1Velocity * obj1Velocity * object1.mass) / object2.mass) * ((obj1Velocity > 0) ? 1 : -1); + var average = (obj1NewVelocity + obj2NewVelocity) * 0.5; + obj1NewVelocity -= average; + obj2NewVelocity -= average; + object1.velocity.y = average + obj1NewVelocity * object1.elasticity; + object2.velocity.y = average + obj2NewVelocity * object2.elasticity; + } else if(!object1.immovable) { + object1.y = object1.y - overlap; + object1.velocity.y = obj2Velocity - obj1Velocity * object1.elasticity; + if(object2.active && object2.moves && (obj1Delta > obj2Delta)) { + object1.x += object2.x - object2.last.x; + } + } else if(!object2.immovable) { + object2.y += overlap; + object2.velocity.y = obj1Velocity - obj2Velocity * object2.elasticity; + if(object1.active && object1.moves && (obj1Delta < obj2Delta)) { + object2.x += object1.x - object1.last.x; + } + } + return true; + } else { + return false; + } + }; + Collision.distance = function distance(x1, y1, x2, y2) { return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); }; Collision.distanceSquared = function distanceSquared(x1, y1, x2, y2) { @@ -5135,15 +3103,6 @@ var Phaser; })(); Phaser.Collision = Collision; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - DynamicTexture -* -* A DynamicTexture can be thought of as a mini canvas into which you can draw anything. -* Game Objects can be assigned a DynamicTexture, so when they render in the world they do so -* based on the contents of the texture at the time. This allows you to create powerful effects -* once and have them replicated across as many game objects as you like. -*/ var Phaser; (function (Phaser) { var DynamicTexture = (function () { @@ -5164,10 +3123,6 @@ var Phaser; this.bounds = new Phaser.Rectangle(0, 0, width, height); } DynamicTexture.prototype.getPixel = function (x, y) { - //r = imageData.data[0]; - //g = imageData.data[1]; - //b = imageData.data[2]; - //a = imageData.data[3]; var imageData = this.context.getImageData(x, y, 1, 1); return this.getColor(imageData.data[0], imageData.data[1], imageData.data[2]); }; @@ -5175,8 +3130,7 @@ var Phaser; var imageData = this.context.getImageData(x, y, 1, 1); return this.getColor32(imageData.data[3], imageData.data[0], imageData.data[1], imageData.data[2]); }; - DynamicTexture.prototype.getPixels = // Returns a CanvasPixelArray - function (rect) { + DynamicTexture.prototype.getPixels = function (rect) { return this.context.getImageData(rect.x, rect.y, rect.width, rect.height); }; DynamicTexture.prototype.setPixel = function (x, y, color) { @@ -5206,14 +3160,8 @@ var Phaser; this._sy = 0; this._dx = destX; this._dy = destY; - // TODO - Load a frame from a sprite sheet, otherwise we'll draw the whole lot if(frame > -1) { - //if (this._game.cache.isSpriteSheet(key)) - //{ - // texture = this._game.cache.getImage(key); - //this.animations.loadFrameData(this._game.cache.getFrameData(key)); - //} - } else { + } else { texture = this._game.cache.getImage(key); this._sw = texture.width; this._sh = texture.height; @@ -5227,21 +3175,10 @@ var Phaser; this._dh = destHeight; } if(texture != null) { - this.context.drawImage(texture, // Source Image - this._sx, // Source X (location within the source image) - this._sy, // Source Y - this._sw, // Source Width - this._sh, // Source Height - this._dx, // Destination X (where on the canvas it'll be drawn) - this._dy, // Destination Y - this._dw, // Destination Width (always same as Source Width unless scaled) - this._dh); - // Destination Height (always same as Source Height unless scaled) - } + this.context.drawImage(texture, this._sx, this._sy, this._sw, this._sh, this._dx, this._dy, this._dw, this._dh); + } }; - DynamicTexture.prototype.copyPixels = // TODO - Add in support for: alphaBitmapData: BitmapData = null, alphaPoint: Point = null, mergeAlpha: bool = false - function (sourceTexture, sourceRect, destPoint) { - // Swap for drawImage if the sourceRect is the same size as the sourceTexture to avoid a costly getImageData call + DynamicTexture.prototype.copyPixels = function (sourceTexture, sourceRect, destPoint) { if(sourceRect.equals(this.bounds) == true) { this.context.drawImage(sourceTexture.canvas, destPoint.x, destPoint.y); } else { @@ -5265,52 +3202,22 @@ var Phaser; enumerable: true, configurable: true }); - DynamicTexture.prototype.getColor32 = /** - * Given an alpha and 3 color values this will return an integer representation of it - * - * @param alpha The Alpha value (between 0 and 255) - * @param red The Red channel value (between 0 and 255) - * @param green The Green channel value (between 0 and 255) - * @param blue The Blue channel value (between 0 and 255) - * - * @return A native color value integer (format: 0xAARRGGBB) - */ - function (alpha, red, green, blue) { + DynamicTexture.prototype.getColor32 = function (alpha, red, green, blue) { return alpha << 24 | red << 16 | green << 8 | blue; }; - DynamicTexture.prototype.getColor = /** - * Given 3 color values this will return an integer representation of it - * - * @param red The Red channel value (between 0 and 255) - * @param green The Green channel value (between 0 and 255) - * @param blue The Blue channel value (between 0 and 255) - * - * @return A native color value integer (format: 0xRRGGBB) - */ - function (red, green, blue) { + DynamicTexture.prototype.getColor = function (red, green, blue) { return red << 16 | green << 8 | blue; }; return DynamicTexture; })(); Phaser.DynamicTexture = DynamicTexture; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - GameMath -* -* Adds a set of extra Math functions used through-out Phaser. -* Includes methods written by Dylan Engelman and Adam Saltsman. -*/ var Phaser; (function (Phaser) { var GameMath = (function () { function GameMath(game) { - //arbitrary 8 digit epsilon this.cosTable = []; this.sinTable = []; - /** - * The global random number generator seed (for deterministic behavior in recordings and saves). - */ this.globalSeed = Math.random(); this._game = game; } @@ -5383,10 +3290,7 @@ var Phaser; if (typeof epsilon === "undefined") { epsilon = 0.0001; } return (Math.abs(value - target) < epsilon) ? target : value; }; - GameMath.prototype.percentageMinMax = /** - * ratio of value to a range - */ - function (val, max, min) { + GameMath.prototype.percentageMinMax = function (val, max, min) { if (typeof min === "undefined") { min = 0; } val -= min; max -= min; @@ -5396,11 +3300,7 @@ var Phaser; return val / max; } }; - GameMath.prototype.sign = /** - * a value representing the sign of the value. - * -1 for negative, +1 for positive, 0 if value is 0 - */ - function (n) { + GameMath.prototype.sign = function (n) { if(n) { return n / Math.abs(n); } else { @@ -5413,10 +3313,7 @@ var Phaser; GameMath.prototype.shear = function (n) { return n % 1; }; - GameMath.prototype.wrap = /** - * wrap a value around a range, similar to modulus with a floating minimum - */ - function (val, max, min) { + GameMath.prototype.wrap = function (val, max, min) { if (typeof min === "undefined") { min = 0; } val -= min; max -= min; @@ -5430,10 +3327,7 @@ var Phaser; } return val; }; - GameMath.prototype.arithWrap = /** - * arithmetic version of wrap... need to decide which is more efficient - */ - function (value, max, min) { + GameMath.prototype.arithWrap = function (value, max, min) { if (typeof min === "undefined") { min = 0; } max -= min; if(max == 0) { @@ -5441,25 +3335,11 @@ var Phaser; } return value - max * Math.floor((value - min) / max); }; - GameMath.prototype.clamp = /** - * force a value within the boundaries of two values - * - * if max < min, min is returned - */ - function (input, max, min) { + GameMath.prototype.clamp = function (input, max, min) { if (typeof min === "undefined") { min = 0; } return Math.max(min, Math.min(max, input)); }; - GameMath.prototype.snapTo = /** - * Snap a value to nearest grid slice, using rounding. - * - * example if you have an interval gap of 5 and a position of 12... you will snap to 10. Where as 14 will snap to 15 - * - * @param input - the value to snap - * @param gap - the interval gap of the grid - * @param start - optional starting offset for gap - */ - function (input, gap, start) { + GameMath.prototype.snapTo = function (input, gap, start) { if (typeof start === "undefined") { start = 0; } if(gap == 0) { return input; @@ -5468,16 +3348,7 @@ var Phaser; input = gap * Math.round(input / gap); return start + input; }; - GameMath.prototype.snapToFloor = /** - * Snap a value to nearest grid slice, using floor. - * - * example if you have an interval gap of 5 and a position of 12... you will snap to 10. As will 14 snap to 10... but 16 will snap to 15 - * - * @param input - the value to snap - * @param gap - the interval gap of the grid - * @param start - optional starting offset for gap - */ - function (input, gap, start) { + GameMath.prototype.snapToFloor = function (input, gap, start) { if (typeof start === "undefined") { start = 0; } if(gap == 0) { return input; @@ -5486,16 +3357,7 @@ var Phaser; input = gap * Math.floor(input / gap); return start + input; }; - GameMath.prototype.snapToCeil = /** - * Snap a value to nearest grid slice, using ceil. - * - * example if you have an interval gap of 5 and a position of 12... you will snap to 15. As will 14 will snap to 15... but 16 will snap to 20 - * - * @param input - the value to snap - * @param gap - the interval gap of the grid - * @param start - optional starting offset for gap - */ - function (input, gap, start) { + GameMath.prototype.snapToCeil = function (input, gap, start) { if (typeof start === "undefined") { start = 0; } if(gap == 0) { return input; @@ -5504,10 +3366,7 @@ var Phaser; input = gap * Math.ceil(input / gap); return start + input; }; - GameMath.prototype.snapToInArray = /** - * Snaps a value to the nearest value in an array. - */ - function (input, arr, sort) { + GameMath.prototype.snapToInArray = function (input, arr, sort) { if (typeof sort === "undefined") { sort = true; } if(sort) { arr.sort(); @@ -5523,43 +3382,7 @@ var Phaser; var high = (i < arr.length) ? arr[i] : Number.POSITIVE_INFINITY; return ((high - input) <= (input - low)) ? high : low; }; - GameMath.prototype.roundTo = /** - * roundTo some place comparative to a 'base', default is 10 for decimal place - * - * 'place' is represented by the power applied to 'base' to get that place - * - * @param value - the value to round - * @param place - the place to round to - * @param base - the base to round in... default is 10 for decimal - * - * e.g. - * - * 2000/7 ~= 285.714285714285714285714 ~= (bin)100011101.1011011011011011 - * - * roundTo(2000/7,3) == 0 - * roundTo(2000/7,2) == 300 - * roundTo(2000/7,1) == 290 - * roundTo(2000/7,0) == 286 - * roundTo(2000/7,-1) == 285.7 - * roundTo(2000/7,-2) == 285.71 - * roundTo(2000/7,-3) == 285.714 - * roundTo(2000/7,-4) == 285.7143 - * roundTo(2000/7,-5) == 285.71429 - * - * roundTo(2000/7,3,2) == 288 -- 100100000 - * roundTo(2000/7,2,2) == 284 -- 100011100 - * roundTo(2000/7,1,2) == 286 -- 100011110 - * roundTo(2000/7,0,2) == 286 -- 100011110 - * roundTo(2000/7,-1,2) == 285.5 -- 100011101.1 - * roundTo(2000/7,-2,2) == 285.75 -- 100011101.11 - * roundTo(2000/7,-3,2) == 285.75 -- 100011101.11 - * roundTo(2000/7,-4,2) == 285.6875 -- 100011101.1011 - * roundTo(2000/7,-5,2) == 285.71875 -- 100011101.10111 - * - * note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed - * because we are rounding 100011.1011011011011011 which rounds up. - */ - function (value, place, base) { + GameMath.prototype.roundTo = function (value, place, base) { if (typeof place === "undefined") { place = 0; } if (typeof base === "undefined") { base = 10; } var p = Math.pow(base, -place); @@ -5577,43 +3400,24 @@ var Phaser; var p = Math.pow(base, -place); return Math.ceil(value * p) / p; }; - GameMath.prototype.interpolateFloat = /** - * a one dimensional linear interpolation of a value. - */ - function (a, b, weight) { + GameMath.prototype.interpolateFloat = function (a, b, weight) { return (b - a) * weight + a; }; - GameMath.prototype.radiansToDegrees = /** - * convert radians to degrees - */ - function (angle) { + GameMath.prototype.radiansToDegrees = function (angle) { return angle * GameMath.RAD_TO_DEG; }; - GameMath.prototype.degreesToRadians = /** - * convert degrees to radians - */ - function (angle) { + GameMath.prototype.degreesToRadians = function (angle) { return angle * GameMath.DEG_TO_RAD; }; - GameMath.prototype.angleBetween = /** - * Find the angle of a segment from (x1, y1) -> (x2, y2 ) - */ - function (x1, y1, x2, y2) { + GameMath.prototype.angleBetween = function (x1, y1, x2, y2) { return Math.atan2(y2 - y1, x2 - x1); }; - GameMath.prototype.normalizeAngle = /** - * set an angle with in the bounds of -PI to PI - */ - function (angle, radians) { + GameMath.prototype.normalizeAngle = function (angle, radians) { if (typeof radians === "undefined") { radians = true; } var rd = (radians) ? GameMath.PI : 180; return this.wrap(angle, rd, -rd); }; - GameMath.prototype.nearestAngleBetween = /** - * closest angle between two angles from a1 to a2 - * absolute value the return for exact angle - */ - function (a1, a2, radians) { + GameMath.prototype.nearestAngleBetween = function (a1, a2, radians) { if (typeof radians === "undefined") { radians = true; } var rd = (radians) ? GameMath.PI : 180; a1 = this.normalizeAngle(a1, radians); @@ -5626,78 +3430,39 @@ var Phaser; } return a2 - a1; }; - GameMath.prototype.normalizeAngleToAnother = /** - * normalizes independent and then sets dep to the nearest value respective to independent - * - * for instance if dep=-170 and ind=170 then 190 will be returned as an alternative to -170 - */ - function (dep, ind, radians) { + GameMath.prototype.normalizeAngleToAnother = function (dep, ind, radians) { if (typeof radians === "undefined") { radians = true; } return ind + this.nearestAngleBetween(ind, dep, radians); }; - GameMath.prototype.normalizeAngleAfterAnother = /** - * normalize independent and dependent and then set dependent to an angle relative to 'after/clockwise' independent - * - * for instance dep=-170 and ind=170, then 190 will be reutrned as alternative to -170 - */ - function (dep, ind, radians) { + GameMath.prototype.normalizeAngleAfterAnother = function (dep, ind, radians) { if (typeof radians === "undefined") { radians = true; } dep = this.normalizeAngle(dep - ind, radians); return ind + dep; }; - GameMath.prototype.normalizeAngleBeforeAnother = /** - * normalizes indendent and dependent and then sets dependent to an angle relative to 'before/counterclockwise' independent - * - * for instance dep = 190 and ind = 170, then -170 will be returned as an alternative to 190 - */ - function (dep, ind, radians) { + GameMath.prototype.normalizeAngleBeforeAnother = function (dep, ind, radians) { if (typeof radians === "undefined") { radians = true; } dep = this.normalizeAngle(ind - dep, radians); return ind - dep; }; - GameMath.prototype.interpolateAngles = /** - * interpolate across the shortest arc between two angles - */ - function (a1, a2, weight, radians, ease) { + GameMath.prototype.interpolateAngles = function (a1, a2, weight, radians, ease) { if (typeof radians === "undefined") { radians = true; } if (typeof ease === "undefined") { ease = null; } a1 = this.normalizeAngle(a1, radians); a2 = this.normalizeAngleToAnother(a2, a1, radians); return (typeof ease === 'function') ? ease(weight, a1, a2 - a1, 1) : this.interpolateFloat(a1, a2, weight); }; - GameMath.prototype.logBaseOf = /** - * Compute the logarithm of any value of any base - * - * a logarithm is the exponent that some constant (base) would have to be raised to - * to be equal to value. - * - * i.e. - * 4 ^ x = 16 - * can be rewritten as to solve for x - * logB4(16) = x - * which with this function would be - * LoDMath.logBaseOf(16,4) - * - * which would return 2, because 4^2 = 16 - */ - function (value, base) { + GameMath.prototype.logBaseOf = function (value, base) { return Math.log(value) / Math.log(base); }; - GameMath.prototype.GCD = /** - * Greatest Common Denominator using Euclid's algorithm - */ - function (m, n) { + GameMath.prototype.GCD = function (m, n) { var r; - //make sure positive, GCD is always positive m = Math.abs(m); n = Math.abs(n); - //m must be >= n if(m < n) { r = m; m = n; n = r; } - //now start loop while(true) { r = m % n; if(!r) { @@ -5708,21 +3473,10 @@ var Phaser; } return 1; }; - GameMath.prototype.LCM = /** - * Lowest Common Multiple - */ - function (m, n) { + GameMath.prototype.LCM = function (m, n) { return (m * n) / this.GCD(m, n); }; - GameMath.prototype.factorial = /** - * Factorial - N! - * - * simple product series - * - * by definition: - * 0! == 1 - */ - function (value) { + GameMath.prototype.factorial = function (value) { if(value == 0) { return 1; } @@ -5732,65 +3486,22 @@ var Phaser; } return res; }; - GameMath.prototype.gammaFunction = /** - * gamma function - * - * defined: gamma(N) == (N - 1)! - */ - function (value) { + GameMath.prototype.gammaFunction = function (value) { return this.factorial(value - 1); }; - GameMath.prototype.fallingFactorial = /** - * falling factorial - * - * defined: (N)! / (N - x)! - * - * written subscript: (N)x OR (base)exp - */ - function (base, exp) { + GameMath.prototype.fallingFactorial = function (base, exp) { return this.factorial(base) / this.factorial(base - exp); }; - GameMath.prototype.risingFactorial = /** - * rising factorial - * - * defined: (N + x - 1)! / (N - 1)! - * - * written superscript N^(x) OR base^(exp) - */ - function (base, exp) { - //expanded from gammaFunction for speed + GameMath.prototype.risingFactorial = function (base, exp) { return this.factorial(base + exp - 1) / this.factorial(base - 1); }; - GameMath.prototype.binCoef = /** - * binomial coefficient - * - * defined: N! / (k!(N-k)!) - * reduced: N! / (N-k)! == (N)k (fallingfactorial) - * reduced: (N)k / k! - */ - function (n, k) { + GameMath.prototype.binCoef = function (n, k) { return this.fallingFactorial(n, k) / this.factorial(k); }; - GameMath.prototype.risingBinCoef = /** - * rising binomial coefficient - * - * as one can notice in the analysis of binCoef(...) that - * binCoef is the (N)k divided by k!. Similarly rising binCoef - * is merely N^(k) / k! - */ - function (n, k) { + GameMath.prototype.risingBinCoef = function (n, k) { return this.risingFactorial(n, k) / this.factorial(k); }; - GameMath.prototype.chanceRoll = /** - * Generate a random boolean result based on the chance value - *

              - * Returns true or false based on the chance value (default 50%). For example if you wanted a player to have a 30% chance - * of getting a bonus, call chanceRoll(30) - true means the chance passed, false means it failed. - *

              - * @param chance The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%) - * @return true if the roll passed, or false - */ - function (chance) { + GameMath.prototype.chanceRoll = function (chance) { if (typeof chance === "undefined") { chance = 50; } if(chance <= 0) { return false; @@ -5804,46 +3515,21 @@ var Phaser; } } }; - GameMath.prototype.maxAdd = /** - * Adds the given amount to the value, but never lets the value go over the specified maximum - * - * @param value The value to add the amount to - * @param amount The amount to add to the value - * @param max The maximum the value is allowed to be - * @return The new value - */ - function (value, amount, max) { + GameMath.prototype.maxAdd = function (value, amount, max) { value += amount; if(value > max) { value = max; } return value; }; - GameMath.prototype.minSub = /** - * Subtracts the given amount from the value, but never lets the value go below the specified minimum - * - * @param value The base value - * @param amount The amount to subtract from the base value - * @param min The minimum the value is allowed to be - * @return The new value - */ - function (value, amount, min) { + GameMath.prototype.minSub = function (value, amount, min) { value -= amount; if(value < min) { value = min; } return value; }; - GameMath.prototype.wrapValue = /** - * Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around. - *

              Values must be positive integers, and are passed through Math.abs

              - * - * @param value The value to add the amount to - * @param amount The amount to add to the value - * @param max The maximum the value is allowed to be - * @return The wrapped value - */ - function (value, amount, max) { + GameMath.prototype.wrapValue = function (value, amount, max) { var diff; value = Math.abs(value); amount = Math.abs(amount); @@ -5851,73 +3537,35 @@ var Phaser; diff = (value + amount) % max; return diff; }; - GameMath.prototype.randomSign = /** - * Randomly returns either a 1 or -1 - * - * @return 1 or -1 - */ - function () { + GameMath.prototype.randomSign = function () { return (Math.random() > 0.5) ? 1 : -1; }; - GameMath.prototype.isOdd = /** - * Returns true if the number given is odd. - * - * @param n The number to check - * - * @return True if the given number is odd. False if the given number is even. - */ - function (n) { + GameMath.prototype.isOdd = function (n) { if(n & 1) { return true; } else { return false; } }; - GameMath.prototype.isEven = /** - * Returns true if the number given is even. - * - * @param n The number to check - * - * @return True if the given number is even. False if the given number is odd. - */ - function (n) { + GameMath.prototype.isEven = function (n) { if(n & 1) { return false; } else { return true; } }; - GameMath.prototype.wrapAngle = /** - * Keeps an angle value between -180 and +180
              - * Should be called whenever the angle is updated on the Sprite to stop it from going insane. - * - * @param angle The angle value to check - * - * @return The new angle value, returns the same as the input angle if it was within bounds - */ - function (angle) { + GameMath.prototype.wrapAngle = function (angle) { var result = angle; - // Nothing needs to change if(angle >= -180 && angle <= 180) { return angle; } - // Else normalise it to -180, 180 result = (angle + 180) % 360; if(result < 0) { result += 360; } return result - 180; }; - GameMath.prototype.angleLimit = /** - * Keeps an angle value between the given min and max values - * - * @param angle The angle value to check. Must be between -180 and +180 - * @param min The minimum angle that is allowed (must be -180 or greater) - * @param max The maximum angle that is allowed (must be 180 or less) - * - * @return The new angle value, returns the same as the input angle if it was within bounds - */ - function (angle, min, max) { + GameMath.prototype.angleLimit = function (angle, min, max) { var result = angle; if(angle > max) { result = max; @@ -5926,13 +3574,7 @@ var Phaser; } return result; }; - GameMath.prototype.linearInterpolation = /** - * @method linear - * @param {Any} v - * @param {Any} k - * @static - */ - function (v, k) { + GameMath.prototype.linearInterpolation = function (v, k) { var m = v.length - 1; var f = m * k; var i = Math.floor(f); @@ -5944,13 +3586,7 @@ var Phaser; } return this.linear(v[i], v[i + 1 > m ? m : i + 1], f - i); }; - GameMath.prototype.bezierInterpolation = /** - * @method Bezier - * @param {Any} v - * @param {Any} k - * @static - */ - function (v, k) { + GameMath.prototype.bezierInterpolation = function (v, k) { var b = 0; var n = v.length - 1; for(var i = 0; i <= n; i++) { @@ -5958,13 +3594,7 @@ var Phaser; } return b; }; - GameMath.prototype.catmullRomInterpolation = /** - * @method CatmullRom - * @param {Any} v - * @param {Any} k - * @static - */ - function (v, k) { + GameMath.prototype.catmullRomInterpolation = function (v, k) { var m = v.length - 1; var f = m * k; var i = Math.floor(f); @@ -5983,73 +3613,26 @@ var Phaser; return this.catmullRom(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i); } }; - GameMath.prototype.linear = /** - * @method Linear - * @param {Any} p0 - * @param {Any} p1 - * @param {Any} t - * @static - */ - function (p0, p1, t) { + GameMath.prototype.linear = function (p0, p1, t) { return (p1 - p0) * t + p0; }; - GameMath.prototype.bernstein = /** - * @method Bernstein - * @param {Any} n - * @param {Any} i - * @static - */ - function (n, i) { + GameMath.prototype.bernstein = function (n, i) { return this.factorial(n) / this.factorial(i) / this.factorial(n - i); }; - GameMath.prototype.catmullRom = /** - * @method CatmullRom - * @param {Any} p0 - * @param {Any} p1 - * @param {Any} p2 - * @param {Any} p3 - * @param {Any} t - * @static - */ - function (p0, p1, p2, p3, t) { + GameMath.prototype.catmullRom = function (p0, p1, p2, p3, t) { var v0 = (p2 - p0) * 0.5, v1 = (p3 - p1) * 0.5, t2 = t * t, t3 = t * t2; return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; }; GameMath.prototype.difference = function (a, b) { return Math.abs(a - b); }; - GameMath.prototype.random = /** - * Generates a random number. Deterministic, meaning safe - * to use if you want to record replays in random environments. - * - * @return A Number between 0 and 1. - */ - function () { + GameMath.prototype.random = function () { return this.globalSeed = this.srand(this.globalSeed); }; - GameMath.prototype.srand = /** - * Generates a random number based on the seed provided. - * - * @param Seed A number between 0 and 1, used to generate a predictable random number (very optional). - * - * @return A Number between 0 and 1. - */ - function (Seed) { + GameMath.prototype.srand = function (Seed) { return ((69621 * (Seed * 0x7FFFFFFF)) % 0x7FFFFFFF) / 0x7FFFFFFF; }; - GameMath.prototype.getRandom = /** - * Fetch a random entry from the given array. - * Will return null if random selection is missing, or array has no entries. - * G.getRandom() is deterministic and safe for use with replays/recordings. - * HOWEVER, U.getRandom() is NOT deterministic and unsafe for use with replays/recordings. - * - * @param Objects An array of objects. - * @param StartIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array. - * @param Length Optional restriction on the number of values you want to randomly select from. - * - * @return The random object that was selected. - */ - function (Objects, StartIndex, Length) { + GameMath.prototype.getRandom = function (Objects, StartIndex, Length) { if (typeof StartIndex === "undefined") { StartIndex = 0; } if (typeof Length === "undefined") { Length = 0; } if(Objects != null) { @@ -6063,43 +3646,15 @@ var Phaser; } return null; }; - GameMath.prototype.floor = /** - * Round down to the next whole number. E.g. floor(1.7) == 1, and floor(-2.7) == -2. - * - * @param Value Any number. - * - * @return The rounded value of that number. - */ - function (Value) { + GameMath.prototype.floor = function (Value) { var n = Value | 0; return (Value > 0) ? (n) : ((n != Value) ? (n - 1) : (n)); }; - GameMath.prototype.ceil = /** - * Round up to the next whole number. E.g. ceil(1.3) == 2, and ceil(-2.3) == -3. - * - * @param Value Any number. - * - * @return The rounded value of that number. - */ - function (Value) { + GameMath.prototype.ceil = function (Value) { var n = Value | 0; return (Value > 0) ? ((n != Value) ? (n + 1) : (n)) : (n); }; - GameMath.prototype.sinCosGenerator = /** - * Generate a sine and cosine table simultaneously and extremely quickly. Based on research by Franky of scene.at - *

              - * The parameters allow you to specify the length, amplitude and frequency of the wave. Once you have called this function - * you should get the results via getSinTable() and getCosTable(). This generator is fast enough to be used in real-time. - *

              - * @param length The length of the wave - * @param sinAmplitude The amplitude to apply to the sine table (default 1.0) if you need values between say -+ 125 then give 125 as the value - * @param cosAmplitude The amplitude to apply to the cosine table (default 1.0) if you need values between say -+ 125 then give 125 as the value - * @param frequency The frequency of the sine and cosine table data - * @return Returns the sine table - * @see getSinTable - * @see getCosTable - */ - function (length, sinAmplitude, cosAmplitude, frequency) { + GameMath.prototype.sinCosGenerator = function (length, sinAmplitude, cosAmplitude, frequency) { if (typeof sinAmplitude === "undefined") { sinAmplitude = 1.0; } if (typeof cosAmplitude === "undefined") { cosAmplitude = 1.0; } if (typeof frequency === "undefined") { frequency = 1.0; } @@ -6116,66 +3671,30 @@ var Phaser; } return this.sinTable; }; - GameMath.prototype.shiftSinTable = /** - * Shifts through the sin table data by one value and returns it. - * This effectively moves the position of the data from the start to the end of the table. - * @return The sin value. - */ - function () { + GameMath.prototype.shiftSinTable = function () { if(this.sinTable) { var s = this.sinTable.shift(); this.sinTable.push(s); return s; } }; - GameMath.prototype.shiftCosTable = /** - * Shifts through the cos table data by one value and returns it. - * This effectively moves the position of the data from the start to the end of the table. - * @return The cos value. - */ - function () { + GameMath.prototype.shiftCosTable = function () { if(this.cosTable) { var s = this.cosTable.shift(); this.cosTable.push(s); return s; } }; - GameMath.prototype.vectorLength = /** - * Finds the length of the given vector - * - * @param dx - * @param dy - * - * @return - */ - function (dx, dy) { + GameMath.prototype.vectorLength = function (dx, dy) { return Math.sqrt(dx * dx + dy * dy); }; - GameMath.prototype.dotProduct = /** - * Finds the dot product value of two vectors - * - * @param ax Vector X - * @param ay Vector Y - * @param bx Vector X - * @param by Vector Y - * - * @return Dot product - */ - function (ax, ay, bx, by) { + GameMath.prototype.dotProduct = function (ax, ay, bx, by) { return ax * bx + ay * by; }; return GameMath; })(); Phaser.GameMath = GameMath; })(Phaser || (Phaser = {})); -/// -/// -/** -* Phaser - Group -* -* This class is used for organising, updating and sorting game objects. -* -*/ var Phaser; (function (Phaser) { var Group = (function (_super) { @@ -6192,11 +3711,7 @@ var Phaser; } Group.ASCENDING = -1; Group.DESCENDING = 1; - Group.prototype.destroy = /** - * Override this function to handle any deleting or "shutdown" type operations you might need, - * such as removing traditional Flash children like Basic objects. - */ - function () { + Group.prototype.destroy = function () { if(this.members != null) { var basic; var i = 0; @@ -6210,10 +3725,7 @@ var Phaser; } this._sortIndex = null; }; - Group.prototype.update = /** - * Automatically goes through and calls update on everything you added. - */ - function () { + Group.prototype.update = function () { var basic; var i = 0; while(i < this.length) { @@ -6225,10 +3737,7 @@ var Phaser; } } }; - Group.prototype.render = /** - * Automatically goes through and calls render on everything you added. - */ - function (camera, cameraOffsetX, cameraOffsetY) { + Group.prototype.render = function (camera, cameraOffsetX, cameraOffsetY) { var basic; var i = 0; while(i < this.length) { @@ -6239,16 +3748,10 @@ var Phaser; } }; Object.defineProperty(Group.prototype, "maxSize", { - get: /** - * The maximum capacity of this group. Default is 0, meaning no max capacity, and the group can just grow. - */ - function () { + get: function () { return this._maxSize; }, - set: /** - * @private - */ - function (Size) { + set: function (Size) { this._maxSize = Size; if(this._marker >= this._maxSize) { this._marker = 0; @@ -6256,7 +3759,6 @@ var Phaser; if((this._maxSize == 0) || (this.members == null) || (this._maxSize >= this.members.length)) { return; } - //If the max size has shrunk, we need to get rid of some objects var basic; var i = this._maxSize; var l = this.members.length; @@ -6271,25 +3773,10 @@ var Phaser; enumerable: true, configurable: true }); - Group.prototype.add = /** - * Adds a new Basic subclass (Basic, Basic, Enemy, etc) to the group. - * Group will try to replace a null member of the array first. - * Failing that, Group will add it to the end of the member array, - * assuming there is room for it, and doubling the size of the array if necessary. - * - *

              WARNING: If the group has a maxSize that has already been met, - * the object will NOT be added to the group!

              - * - * @param Object The object you want to add to the group. - * - * @return The same Basic object that was passed in. - */ - function (Object) { - //Don't bother adding an object twice. + Group.prototype.add = function (Object) { if(this.members.indexOf(Object) >= 0) { return Object; } - //First, look for a null entry where we can add the object. var i = 0; var l = this.members.length; while(i < l) { @@ -6302,7 +3789,6 @@ var Phaser; } i++; } - //Failing that, expand the array (if we can) and add the object. if(this._maxSize > 0) { if(this.members.length >= this._maxSize) { return Object; @@ -6314,36 +3800,11 @@ var Phaser; } else { this.members.length *= 2; } - //If we made it this far, then we successfully grew the group, - //and we can go ahead and add the object at the first open slot. this.members[i] = Object; this.length = i + 1; return Object; }; - Group.prototype.recycle = /** - * Recycling is designed to help you reuse game objects without always re-allocating or "newing" them. - * - *

              If you specified a maximum size for this group (like in Emitter), - * then recycle will employ what we're calling "rotating" recycling. - * Recycle() will first check to see if the group is at capacity yet. - * If group is not yet at capacity, recycle() returns a new object. - * If the group IS at capacity, then recycle() just returns the next object in line.

              - * - *

              If you did NOT specify a maximum size for this group, - * then recycle() will employ what we're calling "grow-style" recycling. - * Recycle() will return either the first object with exists == false, - * or, finding none, add a new object to the array, - * doubling the size of the array if necessary.

              - * - *

              WARNING: If this function needs to create a new object, - * and no object class was provided, it will return null - * instead of a valid object!

              - * - * @param ObjectClass The class type you want to recycle (e.g. Basic, EvilRobot, etc). Do NOT "new" the class in the parameter! - * - * @return A reference to the object that was created. Don't forget to cast it back to the Class you want (e.g. myObject = myGroup.recycle(myObjectClass) as myObjectClass;). - */ - function (ObjectClass) { + Group.prototype.recycle = function (ObjectClass) { if (typeof ObjectClass === "undefined") { ObjectClass = null; } var basic; if(this._maxSize > 0) { @@ -6370,15 +3831,7 @@ var Phaser; return this.add(new ObjectClass(this._game)); } }; - Group.prototype.remove = /** - * Removes an object from the group. - * - * @param Object The Basic you want to remove. - * @param Splice Whether the object should be cut from the array entirely or not. - * - * @return The removed object. - */ - function (Object, Splice) { + Group.prototype.remove = function (Object, Splice) { if (typeof Splice === "undefined") { Splice = false; } var index = this.members.indexOf(Object); if((index < 0) || (index >= this.members.length)) { @@ -6392,15 +3845,7 @@ var Phaser; } return Object; }; - Group.prototype.replace = /** - * Replaces an existing Basic with a new one. - * - * @param OldObject The object you want to replace. - * @param NewObject The new object you want to use instead. - * - * @return The new object. - */ - function (OldObject, NewObject) { + Group.prototype.replace = function (OldObject, NewObject) { var index = this.members.indexOf(OldObject); if((index < 0) || (index >= this.members.length)) { return null; @@ -6408,31 +3853,14 @@ var Phaser; this.members[index] = NewObject; return NewObject; }; - Group.prototype.sort = /** - * Call this function to sort the group according to a particular value and order. - * For example, to sort game objects for Zelda-style overlaps you might call - * myGroup.sort("y",Group.ASCENDING) at the bottom of your - * State.update() override. To sort all existing objects after - * a big explosion or bomb attack, you might call myGroup.sort("exists",Group.DESCENDING). - * - * @param Index The string name of the member variable you want to sort on. Default value is "y". - * @param Order A Group constant that defines the sort order. Possible values are Group.ASCENDING and Group.DESCENDING. Default value is Group.ASCENDING. - */ - function (Index, Order) { + Group.prototype.sort = function (Index, Order) { if (typeof Index === "undefined") { Index = "y"; } if (typeof Order === "undefined") { Order = Group.ASCENDING; } this._sortIndex = Index; this._sortOrder = Order; this.members.sort(this.sortHandler); }; - Group.prototype.setAll = /** - * Go through and set the specified variable to the specified value on all members of the group. - * - * @param VariableName The string representation of the variable name you want to modify, for example "visible" or "scrollFactor". - * @param Value The value you want to assign to that variable. - * @param Recurse Default value is true, meaning if setAll() encounters a member that is a group, it will call setAll() on that group rather than modifying its variable. - */ - function (VariableName, Value, Recurse) { + Group.prototype.setAll = function (VariableName, Value, Recurse) { if (typeof Recurse === "undefined") { Recurse = true; } var basic; var i = 0; @@ -6447,14 +3875,7 @@ var Phaser; } } }; - Group.prototype.callAll = /** - * Go through and call the specified function on all members of the group. - * Currently only works on functions that have no required parameters. - * - * @param FunctionName The string representation of the function you want to call on each object, for example "kill()" or "init()". - * @param Recurse Default value is true, meaning if callAll() encounters a member that is a group, it will call callAll() on that group rather than calling the group's function. - */ - function (FunctionName, Recurse) { + Group.prototype.callAll = function (FunctionName, Recurse) { if (typeof Recurse === "undefined") { Recurse = true; } var basic; var i = 0; @@ -6469,14 +3890,14 @@ var Phaser; } } }; - Group.prototype.forEach = function (callback, Recurse) { - if (typeof Recurse === "undefined") { Recurse = false; } + Group.prototype.forEach = function (callback, recursive) { + if (typeof recursive === "undefined") { recursive = false; } var basic; var i = 0; while(i < this.length) { basic = this.members[i++]; if(basic != null) { - if(Recurse && (basic.isGroup == true)) { + if(recursive && (basic.isGroup == true)) { basic.forEach(callback, true); } else { callback.call(this, basic); @@ -6484,15 +3905,22 @@ var Phaser; } } }; - Group.prototype.getFirstAvailable = /** - * Call this function to retrieve the first object with exists == false in the group. - * This is handy for recycling in general, e.g. respawning enemies. - * - * @param ObjectClass An optional parameter that lets you narrow the results to instances of this particular class. - * - * @return A Basic currently flagged as not existing. - */ - function (ObjectClass) { + Group.prototype.forEachAlive = function (callback, recursive) { + if (typeof recursive === "undefined") { recursive = false; } + var basic; + var i = 0; + while(i < this.length) { + basic = this.members[i++]; + if(basic != null && basic.alive) { + if(recursive && (basic.isGroup == true)) { + basic.forEachAlive(callback, true); + } else { + callback.call(this, basic); + } + } + } + }; + Group.prototype.getFirstAvailable = function (ObjectClass) { if (typeof ObjectClass === "undefined") { ObjectClass = null; } var basic; var i = 0; @@ -6504,13 +3932,7 @@ var Phaser; } return null; }; - Group.prototype.getFirstNull = /** - * Call this function to retrieve the first index set to 'null'. - * Returns -1 if no index stores a null object. - * - * @return An int indicating the first null slot in the group. - */ - function () { + Group.prototype.getFirstNull = function () { var basic; var i = 0; var l = this.members.length; @@ -6523,13 +3945,7 @@ var Phaser; } return -1; }; - Group.prototype.getFirstExtant = /** - * Call this function to retrieve the first object with exists == true in the group. - * This is handy for checking if everything's wiped out, or choosing a squad leader, etc. - * - * @return A Basic currently flagged as existing. - */ - function () { + Group.prototype.getFirstExtant = function () { var basic; var i = 0; while(i < length) { @@ -6540,13 +3956,7 @@ var Phaser; } return null; }; - Group.prototype.getFirstAlive = /** - * Call this function to retrieve the first object with dead == false in the group. - * This is handy for checking if everything's wiped out, or choosing a squad leader, etc. - * - * @return A Basic currently flagged as not dead. - */ - function () { + Group.prototype.getFirstAlive = function () { var basic; var i = 0; while(i < this.length) { @@ -6557,13 +3967,7 @@ var Phaser; } return null; }; - Group.prototype.getFirstDead = /** - * Call this function to retrieve the first object with dead == true in the group. - * This is handy for checking if everything's wiped out, or choosing a squad leader, etc. - * - * @return A Basic currently flagged as dead. - */ - function () { + Group.prototype.getFirstDead = function () { var basic; var i = 0; while(i < this.length) { @@ -6574,12 +3978,7 @@ var Phaser; } return null; }; - Group.prototype.countLiving = /** - * Call this function to find out how many members of the group are not dead. - * - * @return The number of Basics flagged as not dead. Returns -1 if group is empty. - */ - function () { + Group.prototype.countLiving = function () { var count = -1; var basic; var i = 0; @@ -6596,12 +3995,7 @@ var Phaser; } return count; }; - Group.prototype.countDead = /** - * Call this function to find out how many members of the group are dead. - * - * @return The number of Basics flagged as dead. Returns -1 if group is empty. - */ - function () { + Group.prototype.countDead = function () { var count = -1; var basic; var i = 0; @@ -6618,15 +4012,7 @@ var Phaser; } return count; }; - Group.prototype.getRandom = /** - * Returns a member at random from the group. - * - * @param StartIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array. - * @param Length Optional restriction on the number of values you want to randomly select from. - * - * @return A Basic from the members list. - */ - function (StartIndex, Length) { + Group.prototype.getRandom = function (StartIndex, Length) { if (typeof StartIndex === "undefined") { StartIndex = 0; } if (typeof Length === "undefined") { Length = 0; } if(Length == 0) { @@ -6634,17 +4020,10 @@ var Phaser; } return this._game.math.getRandom(this.members, StartIndex, Length); }; - Group.prototype.clear = /** - * Remove all instances of Basic subclass (Basic, Block, etc) from the list. - * WARNING: does not destroy() or kill() any of these objects! - */ - function () { + Group.prototype.clear = function () { this.length = this.members.length = 0; }; - Group.prototype.kill = /** - * Calls kill on the group's members and then on the group itself. - */ - function () { + Group.prototype.kill = function () { var basic; var i = 0; while(i < this.length) { @@ -6654,15 +4033,7 @@ var Phaser; } } }; - Group.prototype.sortHandler = /** - * Helper function for the sort process. - * - * @param Obj1 The first object being sorted. - * @param Obj2 The second object being sorted. - * - * @return An integer value: -1 (Obj1 before Obj2), 0 (same), or 1 (Obj1 after Obj2). - */ - function (Obj1, Obj2) { + Group.prototype.sortHandler = function (Obj1, Obj2) { if(Obj1[this._sortIndex] < Obj2[this._sortIndex]) { return this._sortOrder; } else if(Obj1[this._sortIndex] > Obj2[this._sortIndex]) { @@ -6674,13 +4045,6 @@ var Phaser; })(Phaser.Basic); Phaser.Group = Group; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - Loader -* -* The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files. -* It uses a combination of Image() loading and xhr and provides for progress and completion callbacks. -*/ var Phaser; (function (Phaser) { var Loader = (function () { @@ -6740,7 +4104,6 @@ var Phaser; if (typeof jsonData === "undefined") { jsonData = null; } if(this.checkKeyExists(key) === false) { if(jsonURL !== null) { - // A URL to a json file has been given this._queueSize++; this._fileList[key] = { type: 'textureatlas', @@ -6754,10 +4117,8 @@ var Phaser; }; this._keys.push(key); } else { - // A json string or object has been given if(typeof jsonData === 'string') { var data = JSON.parse(jsonData); - // Malformed? if(data['frames']) { this._queueSize++; this._fileList[key] = { @@ -6773,7 +4134,6 @@ var Phaser; this._keys.push(key); } } else { - // Malformed? if(jsonData['frames']) { this._queueSize++; this._fileList[key] = { @@ -6853,7 +4213,6 @@ var Phaser; Loader.prototype.loadFile = function () { var _this = this; var file = this._fileList[this._keys.pop()]; - // Image or Data? switch(file.type) { case 'image': case 'spritesheet': @@ -6913,7 +4272,6 @@ var Phaser; if(file.jsonURL == null) { this._game.cache.addTextureAtlas(file.key, file.url, file.data, file.jsonData); } else { - // Load the JSON before carrying on with the next file loadNext = false; this._xhr.open("GET", file.jsonURL, true); this._xhr.responseType = "text"; @@ -6941,7 +4299,6 @@ var Phaser; }; Loader.prototype.jsonLoadComplete = function (key) { var data = JSON.parse(this._xhr.response); - // Malformed? if(data['frames']) { var file = this._fileList[key]; this._game.cache.addTextureAtlas(file.key, file.url, file.data, data['frames']); @@ -6983,30 +4340,13 @@ var Phaser; })(); Phaser.Loader = Loader; })(Phaser || (Phaser = {})); -/// -/// -/** -* Phaser - Motion -* -* The Motion class contains lots of useful functions for moving game objects around in world space. -*/ var Phaser; (function (Phaser) { var Motion = (function () { function Motion(game) { this._game = game; } - Motion.prototype.computeVelocity = /** - * A tween-like function that takes a starting velocity and some other factors and returns an altered velocity. - * - * @param Velocity Any component of velocity (e.g. 20). - * @param Acceleration Rate at which the velocity is changing. - * @param Drag Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set. - * @param Max An absolute value cap for the velocity. - * - * @return The altered Velocity value. - */ - function (Velocity, Acceleration, Drag, Max) { + Motion.prototype.computeVelocity = function (Velocity, Acceleration, Drag, Max) { if (typeof Acceleration === "undefined") { Acceleration = 0; } if (typeof Drag === "undefined") { Drag = 0; } if (typeof Max === "undefined") { Max = 10000; } @@ -7031,58 +4371,25 @@ var Phaser; } return Velocity; }; - Motion.prototype.velocityFromAngle = /** - * Given the angle and speed calculate the velocity and return it as a Point - * - * @param angle The angle (in degrees) calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * @param speed The speed it will move, in pixels per second sq - * - * @return A Point where Point.x contains the velocity x value and Point.y contains the velocity y value - */ - function (angle, speed) { + Motion.prototype.velocityFromAngle = function (angle, speed) { if(isNaN(speed)) { speed = 0; } var a = this._game.math.degreesToRadians(angle); return new Phaser.Point((Math.cos(a) * speed), (Math.sin(a) * speed)); }; - Motion.prototype.moveTowardsObject = /** - * Sets the source Sprite x/y velocity so it will move directly towards the destination Sprite at the speed given (in pixels per second)
              - * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.
              - * Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.
              - * The source object doesn't stop moving automatically should it ever reach the destination coordinates.
              - * If you need the object to accelerate, see accelerateTowardsObject() instead - * Note: Doesn't take into account acceleration, maxVelocity or drag (if you set drag or acceleration too high this object may not move at all) - * - * @param source The Sprite on which the velocity will be set - * @param dest The Sprite where the source object will move to - * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) - * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms - */ - function (source, dest, speed, maxTime) { + Motion.prototype.moveTowardsObject = function (source, dest, speed, maxTime) { if (typeof speed === "undefined") { speed = 60; } if (typeof maxTime === "undefined") { maxTime = 0; } var a = this.angleBetween(source, dest); if(maxTime > 0) { var d = this.distanceBetween(source, dest); - // We know how many pixels we need to move, but how fast? speed = d / (maxTime / 1000); } source.velocity.x = Math.cos(a) * speed; source.velocity.y = Math.sin(a) * speed; }; - Motion.prototype.accelerateTowardsObject = /** - * Sets the x/y acceleration on the source Sprite so it will move towards the destination Sprite at the speed given (in pixels per second)
              - * You must give a maximum speed value, beyond which the Sprite won't go any faster.
              - * If you don't need acceleration look at moveTowardsObject() instead. - * - * @param source The Sprite on which the acceleration will be set - * @param dest The Sprite where the source object will move towards - * @param speed The speed it will accelerate in pixels per second - * @param xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally - * @param ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically - */ - function (source, dest, speed, xSpeedMax, ySpeedMax) { + Motion.prototype.accelerateTowardsObject = function (source, dest, speed, xSpeedMax, ySpeedMax) { var a = this.angleBetween(source, dest); source.velocity.x = 0; source.velocity.y = 0; @@ -7091,39 +4398,18 @@ var Phaser; source.maxVelocity.x = xSpeedMax; source.maxVelocity.y = ySpeedMax; }; - Motion.prototype.moveTowardsMouse = /** - * Move the given Sprite towards the mouse pointer coordinates at a steady velocity - * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.
              - * Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.
              - * The source object doesn't stop moving automatically should it ever reach the destination coordinates.
              - * - * @param source The Sprite to move - * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) - * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms - */ - function (source, speed, maxTime) { + Motion.prototype.moveTowardsMouse = function (source, speed, maxTime) { if (typeof speed === "undefined") { speed = 60; } if (typeof maxTime === "undefined") { maxTime = 0; } var a = this.angleBetweenMouse(source); if(maxTime > 0) { var d = this.distanceToMouse(source); - // We know how many pixels we need to move, but how fast? speed = d / (maxTime / 1000); } source.velocity.x = Math.cos(a) * speed; source.velocity.y = Math.sin(a) * speed; }; - Motion.prototype.accelerateTowardsMouse = /** - * Sets the x/y acceleration on the source Sprite so it will move towards the mouse coordinates at the speed given (in pixels per second)
              - * You must give a maximum speed value, beyond which the Sprite won't go any faster.
              - * If you don't need acceleration look at moveTowardsMouse() instead. - * - * @param source The Sprite on which the acceleration will be set - * @param speed The speed it will accelerate in pixels per second - * @param xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally - * @param ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically - */ - function (source, speed, xSpeedMax, ySpeedMax) { + Motion.prototype.accelerateTowardsMouse = function (source, speed, xSpeedMax, ySpeedMax) { var a = this.angleBetweenMouse(source); source.velocity.x = 0; source.velocity.y = 0; @@ -7132,41 +4418,18 @@ var Phaser; source.maxVelocity.x = xSpeedMax; source.maxVelocity.y = ySpeedMax; }; - Motion.prototype.moveTowardsPoint = /** - * Sets the x/y velocity on the source Sprite so it will move towards the target coordinates at the speed given (in pixels per second)
              - * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.
              - * Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.
              - * The source object doesn't stop moving automatically should it ever reach the destination coordinates.
              - * - * @param source The Sprite to move - * @param target The Point coordinates to move the source Sprite towards - * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) - * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms - */ - function (source, target, speed, maxTime) { + Motion.prototype.moveTowardsPoint = function (source, target, speed, maxTime) { if (typeof speed === "undefined") { speed = 60; } if (typeof maxTime === "undefined") { maxTime = 0; } var a = this.angleBetweenPoint(source, target); if(maxTime > 0) { var d = this.distanceToPoint(source, target); - // We know how many pixels we need to move, but how fast? speed = d / (maxTime / 1000); } source.velocity.x = Math.cos(a) * speed; source.velocity.y = Math.sin(a) * speed; }; - Motion.prototype.accelerateTowardsPoint = /** - * Sets the x/y acceleration on the source Sprite so it will move towards the target coordinates at the speed given (in pixels per second)
              - * You must give a maximum speed value, beyond which the Sprite won't go any faster.
              - * If you don't need acceleration look at moveTowardsPoint() instead. - * - * @param source The Sprite on which the acceleration will be set - * @param target The Point coordinates to move the source Sprite towards - * @param speed The speed it will accelerate in pixels per second - * @param xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally - * @param ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically - */ - function (source, target, speed, xSpeedMax, ySpeedMax) { + Motion.prototype.accelerateTowardsPoint = function (source, target, speed, xSpeedMax, ySpeedMax) { var a = this.angleBetweenPoint(source, target); source.velocity.x = 0; source.velocity.y = 0; @@ -7175,52 +4438,22 @@ var Phaser; source.maxVelocity.x = xSpeedMax; source.maxVelocity.y = ySpeedMax; }; - Motion.prototype.distanceBetween = /** - * Find the distance (in pixels, rounded) between two Sprites, taking their origin into account - * - * @param a The first Sprite - * @param b The second Sprite - * @return int Distance (in pixels) - */ - function (a, b) { + Motion.prototype.distanceBetween = function (a, b) { var dx = (a.x + a.origin.x) - (b.x + b.origin.x); var dy = (a.y + a.origin.y) - (b.y + b.origin.y); return this._game.math.vectorLength(dx, dy); }; - Motion.prototype.distanceToPoint = /** - * Find the distance (in pixels, rounded) from an Sprite to the given Point, taking the source origin into account - * - * @param a The Sprite - * @param target The Point - * @return int Distance (in pixels) - */ - function (a, target) { + Motion.prototype.distanceToPoint = function (a, target) { var dx = (a.x + a.origin.x) - (target.x); var dy = (a.y + a.origin.y) - (target.y); return this._game.math.vectorLength(dx, dy); }; - Motion.prototype.distanceToMouse = /** - * Find the distance (in pixels, rounded) from the object x/y and the mouse x/y - * - * @param a The Sprite to test against - * @return int The distance between the given sprite and the mouse coordinates - */ - function (a) { + Motion.prototype.distanceToMouse = function (a) { var dx = (a.x + a.origin.x) - this._game.input.x; var dy = (a.y + a.origin.y) - this._game.input.y; return this._game.math.vectorLength(dx, dy); }; - Motion.prototype.angleBetweenPoint = /** - * Find the angle (in radians) between an Sprite and an Point. The source sprite takes its x/y and origin into account. - * The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * - * @param a The Sprite to test from - * @param target The Point to angle the Sprite towards - * @param asDegrees If you need the value in degrees instead of radians, set to true - * - * @return Number The angle (in radians unless asDegrees is true) - */ - function (a, target, asDegrees) { + Motion.prototype.angleBetweenPoint = function (a, target, asDegrees) { if (typeof asDegrees === "undefined") { asDegrees = false; } var dx = (target.x) - (a.x + a.origin.x); var dy = (target.y) - (a.y + a.origin.y); @@ -7230,17 +4463,7 @@ var Phaser; return Math.atan2(dy, dx); } }; - Motion.prototype.angleBetween = /** - * Find the angle (in radians) between the two Sprite, taking their x/y and origin into account. - * The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * - * @param a The Sprite to test from - * @param b The Sprite to test to - * @param asDegrees If you need the value in degrees instead of radians, set to true - * - * @return Number The angle (in radians unless asDegrees is true) - */ - function (a, b, asDegrees) { + Motion.prototype.angleBetween = function (a, b, asDegrees) { if (typeof asDegrees === "undefined") { asDegrees = false; } var dx = (b.x + b.origin.x) - (a.x + a.origin.x); var dy = (b.y + b.origin.y) - (a.y + a.origin.y); @@ -7250,15 +4473,7 @@ var Phaser; return Math.atan2(dy, dx); } }; - Motion.prototype.velocityFromFacing = /** - * Given the GameObject and speed calculate the velocity and return it as an Point based on the direction the sprite is facing - * - * @param parent The Sprite to get the facing value from - * @param speed The speed it will move, in pixels per second sq - * - * @return An Point where Point.x contains the velocity x value and Point.y contains the velocity y value - */ - function (parent, speed) { + Motion.prototype.velocityFromFacing = function (parent, speed) { var a; if(parent.facing == Phaser.Collision.LEFT) { a = this._game.math.degreesToRadians(180); @@ -7271,18 +4486,8 @@ var Phaser; } return new Phaser.Point(Math.cos(a) * speed, Math.sin(a) * speed); }; - Motion.prototype.angleBetweenMouse = /** - * Find the angle (in radians) between an Sprite and the mouse, taking their x/y and origin into account. - * The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * - * @param a The Object to test from - * @param asDegrees If you need the value in degrees instead of radians, set to true - * - * @return Number The angle (in radians unless asDegrees is true) - */ - function (a, asDegrees) { + Motion.prototype.angleBetweenMouse = function (a, asDegrees) { if (typeof asDegrees === "undefined") { asDegrees = false; } - // In order to get the angle between the object and mouse, we need the objects screen coordinates (rather than world coordinates) var p = a.getScreenXY(); var dx = a._game.input.x - p.x; var dy = a._game.input.y - p.y; @@ -7296,13 +4501,6 @@ var Phaser; })(); Phaser.Motion = Motion; })(Phaser || (Phaser = {})); -/// -/// -/** -* Phaser - Sound -* -* A Sound file, used by the Game.SoundManager for playback. -*/ var Phaser; (function (Phaser) { var Sound = (function () { @@ -7317,7 +4515,6 @@ var Phaser; this._buffer = data; this._volume = volume; this.loop = loop; - // Local volume control if(this._context !== null) { this._localGainNode = this._context.createGainNode(); this._localGainNode.connect(this._gainNode); @@ -7344,8 +4541,7 @@ var Phaser; if(this.loop) { this._sound.loop = true; } - this._sound.noteOn(0)// the zero is vitally important, crashes iOS6 without it - ; + this._sound.noteOn(0); this.duration = this._sound.buffer.duration; this.isPlaying = true; }; @@ -7376,13 +4572,6 @@ var Phaser; })(); Phaser.Sound = Sound; })(Phaser || (Phaser = {})); -/// -/// -/** -* Phaser - SoundManager -* -* This is an embroyonic web audio sound management class. There is a lot of work still to do here. -*/ var Phaser; (function (Phaser) { var SoundManager = (function () { @@ -7445,12 +4634,10 @@ var Phaser; } var soundData = this._game.cache.getSound(key); if(soundData) { - // Does the sound need decoding? if(this._game.cache.isSoundDecoded(key) === true) { return new Phaser.Sound(this._context, this._gainNode, soundData, volume, loop); } else { var tempSound = new Phaser.Sound(this._context, this._gainNode, null, volume, loop); - // this is an async process, so we can return the Sound object anyway, it just won't be playing yet this.decode(key, function () { return _this.play(key); }, tempSound); @@ -7462,33 +4649,10 @@ var Phaser; })(); Phaser.SoundManager = SoundManager; })(Phaser || (Phaser = {})); -/** -* Phaser -* -* v0.9.3 - April 24th 2013 -* -* A small and feature-packed 2D canvas game framework born from the firey pits of Flixel and Kiwi. -* -* Richard Davey (@photonstorm) -* -* Many thanks to Adam Saltsman (@ADAMATOMIC) for the original Flixel AS3 code on which Phaser is based. -* -* "If you want your children to be intelligent, read them fairy tales." -* "If you want them to be more intelligent, read them more fairy tales." -* -- Albert Einstein -*/ var Phaser; (function (Phaser) { - Phaser.VERSION = 'Phaser version 0.9.3'; + Phaser.VERSION = 'Phaser version 0.9.4'; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - StageScaleMode -* -* This class controls the scaling of your game. On mobile devices it will also remove the URL bar and allow -* you to maintain proportion and aspect ratio. -* It is based on a technique taken from Viewporter v2.0 by Zynga Inc. http://github.com/zynga/viewporter -*/ var Phaser; (function (Phaser) { var StageScaleMode = (function () { @@ -7526,7 +4690,6 @@ var Phaser; }; StageScaleMode.prototype.refresh = function () { var _this = this; - // We can't do anything about the status bars in iPads, web apps or desktops if(this._game.device.iPad == false && this._game.device.webApp == false && this._game.device.desktop == false) { document.documentElement.style.minHeight = '5000px'; this._startHeight = window.innerHeight; @@ -7553,7 +4716,6 @@ var Phaser; } this._iterations--; if(window.innerHeight > this._startHeight || this._iterations < 0) { - // Set minimum height of content to new window height document.documentElement.style.minHeight = window.innerHeight + 'px'; if(this._game.stage.scaleMode == StageScaleMode.EXACT_FIT) { if(this._game.stage.maxScaleX && window.innerWidth > this._game.stage.maxScaleX) { @@ -7589,15 +4751,6 @@ var Phaser; })(); Phaser.StageScaleMode = StageScaleMode; })(Phaser || (Phaser = {})); -/// -/// -/// -/** -* Phaser - Stage -* -* The Stage is the canvas on which everything is displayed. This class handles display within the web browser, focus handling, -* resizing, scaling and pause/boot screens. -*/ var Phaser; (function (Phaser) { var Stage = (function () { @@ -7620,7 +4773,6 @@ var Phaser; } else { document.body.appendChild(this.canvas); } - // Consume default actions on the canvas this.canvas.style.msTouchAction = 'none'; this.canvas.style['touch-action'] = 'none'; this.context = this.canvas.getContext('2d'); @@ -7629,8 +4781,12 @@ var Phaser; this.aspectRatio = width / height; this.scaleMode = Phaser.StageScaleMode.NO_SCALE; this.scale = new Phaser.StageScaleMode(this._game); - //document.addEventListener('visibilitychange', (event) => this.visibilityChange(event), false); - //document.addEventListener('webkitvisibilitychange', (event) => this.visibilityChange(event), false); + document.addEventListener('visibilitychange', function (event) { + return _this.visibilityChange(event); + }, false); + document.addEventListener('webkitvisibilitychange', function (event) { + return _this.visibilityChange(event); + }, false); window.onblur = function (event) { return _this.visibilityChange(event); }; @@ -7643,7 +4799,6 @@ var Phaser; Stage.prototype.update = function () { this.scale.update(); if(this.clear) { - // implement dirty rect? could take up more cpu time than it saves. needs benching. this.context.clearRect(0, 0, this.width, this.height); } }; @@ -7653,8 +4808,7 @@ var Phaser; this.context.fillText('Game Size: ' + this.width + ' x ' + this.height, 10, 40); this.context.fillText('x: ' + this.x + ' y: ' + this.y, 10, 60); }; - Stage.prototype.visibilityChange = //if (document['hidden'] === true || document['webkitHidden'] === true) - function (event) { + Stage.prototype.visibilityChange = function (event) { if(this.disablePauseScreen) { return; } @@ -7688,7 +4842,6 @@ var Phaser; this.saveCanvasValues(); this.context.fillStyle = 'rgba(0, 0, 0, 0.4)'; this.context.fillRect(0, 0, this.width, this.height); - // Draw a 'play' arrow var arrowWidth = Math.round(this.width / 2); var arrowHeight = Math.round(this.height / 2); var sx = this.centerX - arrowWidth / 2; @@ -7790,35 +4943,14 @@ var Phaser; })(); Phaser.Stage = Stage; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - Time -* -* This is the game clock and it manages elapsed time and calculation of delta values, used for game object motion. -*/ var Phaser; (function (Phaser) { var Time = (function () { function Time(game) { this.timeScale = 1.0; this.elapsed = 0; - /** - * - * @property time - * @type Number - */ this.time = 0; - /** - * - * @property now - * @type Number - */ this.now = 0; - /** - * - * @property delta - * @type Number - */ this.delta = 0; this.fps = 0; this.fpsMin = 1000; @@ -7832,27 +4964,15 @@ var Phaser; this.time = this._started; } Object.defineProperty(Time.prototype, "totalElapsedSeconds", { - get: /** - * - * @method totalElapsedSeconds - * @return {Number} - */ - function () { + get: function () { return (this.now - this._started) * 0.001; }, enumerable: true, configurable: true }); - Time.prototype.update = /** - * - * @method update - */ - function () { - // Can we use performance.now() ? - this.now = Date.now()// mark - ; - this.delta = this.now - this.time// elapsedMS - ; + Time.prototype.update = function () { + this.now = Date.now(); + this.delta = this.now - this.time; this.msMin = Math.min(this.msMin, this.delta); this.msMax = Math.max(this.msMax, this.delta); this.frames++; @@ -7863,37 +4983,15 @@ var Phaser; this._timeLastSecond = this.now; this.frames = 0; } - this.time = this.now// _total - ; - //// Lock the delta at 0.1 to minimise fps tunneling - //if (this.delta > 0.1) - //{ - // this.delta = 0.1; - //} - }; - Time.prototype.elapsedSince = /** - * - * @method elapsedSince - * @param {Number} since - * @return {Number} - */ - function (since) { + this.time = this.now; + }; + Time.prototype.elapsedSince = function (since) { return this.now - since; }; - Time.prototype.elapsedSecondsSince = /** - * - * @method elapsedSecondsSince - * @param {Number} since - * @return {Number} - */ - function (since) { + Time.prototype.elapsedSecondsSince = function (since) { return (this.now - since) * 0.001; }; - Time.prototype.reset = /** - * - * @method reset - */ - function () { + Time.prototype.reset = function () { this._started = this.now; }; return Time; @@ -7902,12 +5000,6 @@ var Phaser; })(Phaser || (Phaser = {})); var Phaser; (function (Phaser) { - /// - /** - * Phaser - Easing - Back - * - * For use with Phaser.Tween - */ (function (Easing) { var Back = (function () { function Back() { } @@ -7934,12 +5026,6 @@ var Phaser; })(Phaser || (Phaser = {})); var Phaser; (function (Phaser) { - /// - /** - * Phaser - Easing - Bounce - * - * For use with Phaser.Tween - */ (function (Easing) { var Bounce = (function () { function Bounce() { } @@ -7971,12 +5057,6 @@ var Phaser; })(Phaser || (Phaser = {})); var Phaser; (function (Phaser) { - /// - /** - * Phaser - Easing - Circular - * - * For use with Phaser.Tween - */ (function (Easing) { var Circular = (function () { function Circular() { } @@ -8000,12 +5080,6 @@ var Phaser; })(Phaser || (Phaser = {})); var Phaser; (function (Phaser) { - /// - /** - * Phaser - Easing - Cubic - * - * For use with Phaser.Tween - */ (function (Easing) { var Cubic = (function () { function Cubic() { } @@ -8029,12 +5103,6 @@ var Phaser; })(Phaser || (Phaser = {})); var Phaser; (function (Phaser) { - /// - /** - * Phaser - Easing - Elastic - * - * For use with Phaser.Tween - */ (function (Easing) { var Elastic = (function () { function Elastic() { } @@ -8097,12 +5165,6 @@ var Phaser; })(Phaser || (Phaser = {})); var Phaser; (function (Phaser) { - /// - /** - * Phaser - Easing - Exponential - * - * For use with Phaser.Tween - */ (function (Easing) { var Exponential = (function () { function Exponential() { } @@ -8132,12 +5194,6 @@ var Phaser; })(Phaser || (Phaser = {})); var Phaser; (function (Phaser) { - /// - /** - * Phaser - Easing - Linear - * - * For use with Phaser.Tween - */ (function (Easing) { var Linear = (function () { function Linear() { } @@ -8152,12 +5208,6 @@ var Phaser; })(Phaser || (Phaser = {})); var Phaser; (function (Phaser) { - /// - /** - * Phaser - Easing - Quadratic - * - * For use with Phaser.Tween - */ (function (Easing) { var Quadratic = (function () { function Quadratic() { } @@ -8181,12 +5231,6 @@ var Phaser; })(Phaser || (Phaser = {})); var Phaser; (function (Phaser) { - /// - /** - * Phaser - Easing - Quartic - * - * For use with Phaser.Tween - */ (function (Easing) { var Quartic = (function () { function Quartic() { } @@ -8210,12 +5254,6 @@ var Phaser; })(Phaser || (Phaser = {})); var Phaser; (function (Phaser) { - /// - /** - * Phaser - Easing - Quintic - * - * For use with Phaser.Tween - */ (function (Easing) { var Quintic = (function () { function Quintic() { } @@ -8239,12 +5277,6 @@ var Phaser; })(Phaser || (Phaser = {})); var Phaser; (function (Phaser) { - /// - /** - * Phaser - Easing - Sinusoidal - * - * For use with Phaser.Tween - */ (function (Easing) { var Sinusoidal = (function () { function Sinusoidal() { } @@ -8263,23 +5295,6 @@ var Phaser; })(Phaser.Easing || (Phaser.Easing = {})); var Easing = Phaser.Easing; })(Phaser || (Phaser = {})); -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/** -* Phaser - Tween -* -* Based heavily on tween.js by sole (https://github.com/sole/tween.js) converted to TypeScript and integrated into Phaser -*/ var Phaser; (function (Phaser) { var Tween = (function () { @@ -8308,7 +5323,6 @@ var Phaser; if (typeof ease === "undefined") { ease = null; } if (typeof autoStart === "undefined") { autoStart = false; } this._duration = duration; - // If properties isn't an object this will fail, sanity check it here somehow? this._valuesEnd = properties; if(ease !== null) { this._easingFunction = ease; @@ -8327,17 +5341,14 @@ var Phaser; this.onStart.dispatch(this._object); this._startTime = this._game.time.now + this._delayTime; for(var property in this._valuesEnd) { - // This prevents the interpolation of null values or of non-existing properties if(this._object[property] === null || !(property in this._object)) { throw Error('Phaser.Tween interpolation of null value of non-existing property'); continue; } - // check if an Array was provided as property value if(this._valuesEnd[property] instanceof Array) { if(this._valuesEnd[property].length === 0) { continue; } - // create a local copy of the Array with the start value at the front this._valuesEnd[property] = [ this._object[property] ].concat(this._valuesEnd[property]); @@ -8400,7 +5411,6 @@ var Phaser; this._pausedTime = time; } } else { - // Ok we aren't paused, but was there some time gained? if(this._pausedTime > 0) { this._startTime += (time - this._pausedTime); this._pausedTime = 0; @@ -8413,7 +5423,6 @@ var Phaser; elapsed = elapsed > 1 ? 1 : elapsed; var value = this._easingFunction(elapsed); for(var property in this._valuesStart) { - // Add checks for object, array, numeric up front if(this._valuesEnd[property] instanceof Array) { this._object[property] = this._interpolationFunction(this._valuesEnd[property], value); } else { @@ -8434,17 +5443,6 @@ var Phaser; })(); Phaser.Tween = Tween; })(Phaser || (Phaser = {})); -/// -/// -/** -* Phaser - TweenManager -* -* The Game has a single instance of the TweenManager through which all Tween objects are created and updated. -* Tweens are hooked into the game clock and pause system, adjusting based on the game state. -* TweenManager is based heavily on tween.js by sole (http://soledadpenades.com). -* I converted it to TypeScript, swapped the callbacks for signals and patched a few issues with regard -* to properties and completion errors. Please see https://github.com/sole/tween.js for a full list of contributors. -*/ var Phaser; (function (Phaser) { var TweenManager = (function () { @@ -8492,14 +5490,6 @@ var Phaser; })(); Phaser.TweenManager = TweenManager; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - World -* -* A game has only one world. The world is an abstract place in which all game objects live. It is not bound -* by stage limits and can be any size or dimension. You look into the world via cameras and all game objects -* live within the world at world-based coordinates. By default a world is created the same size as your Stage. -*/ var Phaser; (function (Phaser) { var World = (function () { @@ -8518,15 +5508,13 @@ var Phaser; this._cameras.update(); }; World.prototype.render = function () { - // Unlike in flixel our render process is camera driven, not group driven this._cameras.render(); }; World.prototype.destroy = function () { this.group.destroy(); this._cameras.destroy(); }; - World.prototype.setSize = // World methods - function (width, height, updateCameraBounds) { + World.prototype.setSize = function (width, height, updateCameraBounds) { if (typeof updateCameraBounds === "undefined") { updateCameraBounds = true; } this.bounds.width = width; this.bounds.height = height; @@ -8582,8 +5570,7 @@ var Phaser; enumerable: true, configurable: true }); - World.prototype.createCamera = // Cameras - function (x, y, width, height) { + World.prototype.createCamera = function (x, y, width, height) { return this._cameras.addCamera(x, y, width, height); }; World.prototype.removeCamera = function (id) { @@ -8592,8 +5579,7 @@ var Phaser; World.prototype.getAllCameras = function () { return this._cameras.getAll(); }; - World.prototype.createSprite = // Game Objects - function (x, y, key) { + World.prototype.createSprite = function (x, y, key) { if (typeof key === "undefined") { key = ''; } return this.group.add(new Phaser.Sprite(this._game, x, y, key)); }; @@ -8633,232 +5619,45 @@ var Phaser; })(); Phaser.World = World; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - Device -* -* Detects device support capabilities. Using some elements from System.js by MrDoob and Modernizr -* https://github.com/Modernizr/Modernizr/blob/master/feature-detects/audio.js -*/ var Phaser; (function (Phaser) { var Device = (function () { - /** - * - * @constructor - * @return {Device} This Object - */ function Device() { - // Operating System this.desktop = false; - /** - * - * @property iOS - * @type Boolean - */ this.iOS = false; - /** - * - * @property android - * @type Boolean - */ this.android = false; - /** - * - * @property chromeOS - * @type Boolean - */ this.chromeOS = false; - /** - * - * @property linux - * @type Boolean - */ this.linux = false; - /** - * - * @property maxOS - * @type Boolean - */ this.macOS = false; - /** - * - * @property windows - * @type Boolean - */ this.windows = false; - // Features - /** - * - * @property canvas - * @type Boolean - */ this.canvas = false; - /** - * - * @property file - * @type Boolean - */ this.file = false; - /** - * - * @property fileSystem - * @type Boolean - */ this.fileSystem = false; - /** - * - * @property localStorage - * @type Boolean - */ this.localStorage = false; - /** - * - * @property webGL - * @type Boolean - */ this.webGL = false; - /** - * - * @property worker - * @type Boolean - */ this.worker = false; - /** - * - * @property touch - * @type Boolean - */ this.touch = false; - /** - * - * @property css3D - * @type Boolean - */ this.css3D = false; - // Browser - /** - * - * @property arora - * @type Boolean - */ this.arora = false; - /** - * - * @property chrome - * @type Boolean - */ this.chrome = false; - /** - * - * @property epiphany - * @type Boolean - */ this.epiphany = false; - /** - * - * @property firefox - * @type Boolean - */ this.firefox = false; - /** - * - * @property ie - * @type Boolean - */ this.ie = false; - /** - * - * @property ieVersion - * @type Number - */ this.ieVersion = 0; - /** - * - * @property mobileSafari - * @type Boolean - */ this.mobileSafari = false; - /** - * - * @property midori - * @type Boolean - */ this.midori = false; - /** - * - * @property opera - * @type Boolean - */ this.opera = false; - /** - * - * @property safari - * @type Boolean - */ this.safari = false; this.webApp = false; - // Audio - /** - * - * @property audioData - * @type Boolean - */ this.audioData = false; - /** - * - * @property webaudio - * @type Boolean - */ this.webaudio = false; - /** - * - * @property ogg - * @type Boolean - */ this.ogg = false; - /** - * - * @property mp3 - * @type Boolean - */ this.mp3 = false; - /** - * - * @property wav - * @type Boolean - */ this.wav = false; - /** - * - * @property m4a - * @type Boolean - */ this.m4a = false; - // Device - /** - * - * @property iPhone - * @type Boolean - */ this.iPhone = false; - /** - * - * @property iPhone4 - * @type Boolean - */ this.iPhone4 = false; - /** - * - * @property iPad - * @type Boolean - */ this.iPad = false; - /** - * - * @property pixelRatio - * @type Number - */ this.pixelRatio = 0; this._checkAudio(); this._checkBrowser(); @@ -8867,12 +5666,7 @@ var Phaser; this._checkFeatures(); this._checkOS(); } - Device.prototype._checkOS = /** - * - * @method _checkOS - * @private - */ - function () { + Device.prototype._checkOS = function () { var ua = navigator.userAgent; if(/Android/.test(ua)) { this.android = true; @@ -8891,12 +5685,7 @@ var Phaser; this.desktop = true; } }; - Device.prototype._checkFeatures = /** - * - * @method _checkFeatures - * @private - */ - function () { + Device.prototype._checkFeatures = function () { this.canvas = !!window['CanvasRenderingContext2D']; try { this.localStorage = !!localStorage.getItem; @@ -8911,12 +5700,7 @@ var Phaser; this.touch = true; } }; - Device.prototype._checkBrowser = /** - * - * @method _checkBrowser - * @private - */ - function () { + Device.prototype._checkBrowser = function () { var ua = navigator.userAgent; if(/Arora/.test(ua)) { this.arora = true; @@ -8938,17 +5722,11 @@ var Phaser; } else if(/Safari/.test(ua)) { this.safari = true; } - // WebApp mode in iOS if(navigator['standalone']) { this.webApp = true; } }; - Device.prototype._checkAudio = /** - * - * @method _checkAudio - * @private - */ - function () { + Device.prototype._checkAudio = function () { this.audioData = !!(window['Audio']); this.webaudio = !!(window['webkitAudioContext'] || window['AudioContext']); var audioElement = document.createElement('audio'); @@ -8961,9 +5739,6 @@ var Phaser; if(audioElement.canPlayType('audio/mpeg;').replace(/^no$/, '')) { this.mp3 = true; } - // Mimetypes accepted: - // developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements - // bit.ly/iphoneoscodecs if(audioElement.canPlayType('audio/wav; codecs="1"').replace(/^no$/, '')) { this.wav = true; } @@ -8974,23 +5749,13 @@ var Phaser; } catch (e) { } }; - Device.prototype._checkDevice = /** - * - * @method _checkDevice - * @private - */ - function () { + Device.prototype._checkDevice = function () { this.pixelRatio = window['devicePixelRatio'] || 1; this.iPhone = navigator.userAgent.toLowerCase().indexOf('iphone') != -1; this.iPhone4 = (this.pixelRatio == 2 && this.iPhone); this.iPad = navigator.userAgent.toLowerCase().indexOf('ipad') != -1; }; - Device.prototype._checkCSS3D = /** - * - * @method _checkCSS3D - * @private - */ - function () { + Device.prototype._checkCSS3D = function () { var el = document.createElement('p'); var has3d; var transforms = { @@ -9000,7 +5765,6 @@ var Phaser; 'MozTransform': '-moz-transform', 'transform': 'transform' }; - // Add it to the body to get the computed style. document.body.insertBefore(el, null); for(var t in transforms) { if(el.style[t] !== undefined) { @@ -9011,12 +5775,7 @@ var Phaser; document.body.removeChild(el); this.css3D = (has3d !== undefined && has3d.length > 0 && has3d !== "none"); }; - Device.prototype.getAll = /** - * - * @method getAll - * @return {String} - */ - function () { + Device.prototype.getAll = function () { var output = ''; output = output.concat('Device\n'); output = output.concat('iPhone : ' + this.iPhone + '\n'); @@ -9065,68 +5824,29 @@ var Phaser; })(); Phaser.Device = Device; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - RandomDataGenerator -* -* An extremely useful repeatable random data generator. Access it via Game.rnd -* Based on Nonsense by Josh Faul https://github.com/jocafa/Nonsense -* Random number generator from http://baagoe.org/en/wiki/Better_random_numbers_for_javascript -*/ var Phaser; (function (Phaser) { var RandomDataGenerator = (function () { - /** - * @constructor - * @param {Array} seeds - * @return {Phaser.RandomDataGenerator} - */ function RandomDataGenerator(seeds) { if (typeof seeds === "undefined") { seeds = []; } - /** - * @property c - * @type Number - * @private - */ this.c = 1; this.sow(seeds); } - RandomDataGenerator.prototype.uint32 = /** - * @method uint32 - * @private - */ - function () { - return this.rnd.apply(this) * 0x100000000;// 2^32 - + RandomDataGenerator.prototype.uint32 = function () { + return this.rnd.apply(this) * 0x100000000; }; - RandomDataGenerator.prototype.fract32 = /** - * @method fract32 - * @private - */ - function () { - return this.rnd.apply(this) + (this.rnd.apply(this) * 0x200000 | 0) * 1.1102230246251565e-16;// 2^-53 - + RandomDataGenerator.prototype.fract32 = function () { + return this.rnd.apply(this) + (this.rnd.apply(this) * 0x200000 | 0) * 1.1102230246251565e-16; }; - RandomDataGenerator.prototype.rnd = // private random helper - /** - * @method rnd - * @private - */ - function () { - var t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10;// 2^-32 - + RandomDataGenerator.prototype.rnd = function () { + var t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10; this.c = t | 0; this.s0 = this.s1; this.s1 = this.s2; this.s2 = t - this.c; return this.s2; }; - RandomDataGenerator.prototype.hash = /** - * @method hash - * @param {Any} data - * @private - */ - function (data) { + RandomDataGenerator.prototype.hash = function (data) { var h, i, n; n = 0xefc8249d; data = data.toString(); @@ -9138,18 +5858,11 @@ var Phaser; h *= n; n = h >>> 0; h -= n; - n += h * 0x100000000// 2^32 - ; + n += h * 0x100000000; } - return (n >>> 0) * 2.3283064365386963e-10;// 2^-32 - + return (n >>> 0) * 2.3283064365386963e-10; }; - RandomDataGenerator.prototype.sow = /** - * Reset the seed of the random data generator - * @method sow - * @param {Array} seeds - */ - function (seeds) { + RandomDataGenerator.prototype.sow = function (seeds) { if (typeof seeds === "undefined") { seeds = []; } this.s0 = this.hash(' '); this.s1 = this.hash(this.s0); @@ -9165,82 +5878,43 @@ var Phaser; } }; Object.defineProperty(RandomDataGenerator.prototype, "integer", { - get: /** - * Returns a random integer between 0 and 2^32 - * @method integer - * @return {Number} - */ - function () { + get: function () { return this.uint32(); }, enumerable: true, configurable: true }); Object.defineProperty(RandomDataGenerator.prototype, "frac", { - get: /** - * Returns a random real number between 0 and 1 - * @method frac - * @return {Number} - */ - function () { + get: function () { return this.fract32(); }, enumerable: true, configurable: true }); Object.defineProperty(RandomDataGenerator.prototype, "real", { - get: /** - * Returns a random real number between 0 and 2^32 - * @method real - * @return {Number} - */ - function () { + get: function () { return this.uint32() + this.fract32(); }, enumerable: true, configurable: true }); - RandomDataGenerator.prototype.integerInRange = /** - * Returns a random integer between min and max - * @method integerInRange - * @param {Number} min - * @param {Number} max - * @return {Number} - */ - function (min, max) { + RandomDataGenerator.prototype.integerInRange = function (min, max) { return Math.floor(this.realInRange(min, max)); }; - RandomDataGenerator.prototype.realInRange = /** - * Returns a random real number between min and max - * @method realInRange - * @param {Number} min - * @param {Number} max - * @return {Number} - */ - function (min, max) { + RandomDataGenerator.prototype.realInRange = function (min, max) { min = min || 0; max = max || 0; return this.frac * (max - min) + min; }; Object.defineProperty(RandomDataGenerator.prototype, "normal", { - get: /** - * Returns a random real number between -1 and 1 - * @method normal - * @return {Number} - */ - function () { + get: function () { return 1 - 2 * this.frac; }, enumerable: true, configurable: true }); Object.defineProperty(RandomDataGenerator.prototype, "uuid", { - get: /** - * Returns a valid v4 UUID hex string (from https://gist.github.com/1308368) - * @method uuid - * @return {String} - */ - function () { + get: function () { var a, b; for(b = a = ''; a++ < 36; b += ~a % 5 | a * 3 & 4 ? (a ^ 15 ? 8 ^ this.frac * (a ^ 20 ? 16 : 4) : 4).toString(16) : '-') { ; @@ -9250,39 +5924,19 @@ var Phaser; enumerable: true, configurable: true }); - RandomDataGenerator.prototype.pick = /** - * Returns a random member of `array` - * @method pick - * @param {Any} array - */ - function (array) { + RandomDataGenerator.prototype.pick = function (array) { return array[this.integerInRange(0, array.length)]; }; - RandomDataGenerator.prototype.weightedPick = /** - * Returns a random member of `array`, favoring the earlier entries - * @method weightedPick - * @param {Any} array - */ - function (array) { + RandomDataGenerator.prototype.weightedPick = function (array) { return array[~~(Math.pow(this.frac, 2) * array.length)]; }; - RandomDataGenerator.prototype.timestamp = /** - * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified - * @method timestamp - * @param {Number} min - * @param {Number} max - */ - function (min, max) { + RandomDataGenerator.prototype.timestamp = function (min, max) { if (typeof min === "undefined") { min = 946684800000; } if (typeof max === "undefined") { max = 1577862000000; } return this.realInRange(min, max); }; Object.defineProperty(RandomDataGenerator.prototype, "angle", { - get: /** - * Returns a random angle between -180 and 180 - * @method angle - */ - function () { + get: function () { return this.integerInRange(-180, 180); }, enumerable: true, @@ -9292,45 +5946,13 @@ var Phaser; })(); Phaser.RandomDataGenerator = RandomDataGenerator; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - RequestAnimationFrame -* -* Abstracts away the use of RAF or setTimeOut for the core game update loop. The callback can be re-mapped on the fly. -*/ var Phaser; (function (Phaser) { var RequestAnimationFrame = (function () { - /** - * Constructor - * @param {Any} callback - * @return {RequestAnimationFrame} This object. - */ function RequestAnimationFrame(callback, callbackContext) { - /** - * - * @property _isSetTimeOut - * @type Boolean - * @private - **/ this._isSetTimeOut = false; - /** - * - * @property lastTime - * @type Number - **/ this.lastTime = 0; - /** - * - * @property currentTime - * @type Number - **/ this.currentTime = 0; - /** - * - * @property isRunning - * @type Boolean - **/ this.isRunning = false; this._callback = callback; this._callbackContext = callbackContext; @@ -9346,40 +5968,20 @@ var Phaser; } this.start(); } - RequestAnimationFrame.prototype.setCallback = /** - * - * @method callback - * @param {Any} callback - **/ - function (callback) { + RequestAnimationFrame.prototype.setCallback = function (callback) { this._callback = callback; }; - RequestAnimationFrame.prototype.isUsingSetTimeOut = /** - * - * @method usingSetTimeOut - * @return Boolean - **/ - function () { + RequestAnimationFrame.prototype.isUsingSetTimeOut = function () { return this._isSetTimeOut; }; - RequestAnimationFrame.prototype.isUsingRAF = /** - * - * @method usingRAF - * @return Boolean - **/ - function () { + RequestAnimationFrame.prototype.isUsingRAF = function () { if(this._isSetTimeOut === true) { return false; } else { return true; } }; - RequestAnimationFrame.prototype.start = /** - * - * @method start - * @param {Any} [callback] - **/ - function (callback) { + RequestAnimationFrame.prototype.start = function (callback) { if (typeof callback === "undefined") { callback = null; } var _this = this; if(callback) { @@ -9398,11 +6000,7 @@ var Phaser; } this.isRunning = true; }; - RequestAnimationFrame.prototype.stop = /** - * - * @method stop - **/ - function () { + RequestAnimationFrame.prototype.stop = function () { if(this._isSetTimeOut) { clearTimeout(this._timeOutID); } else { @@ -9412,7 +6010,6 @@ var Phaser; }; RequestAnimationFrame.prototype.RAFUpdate = function () { var _this = this; - // Not in IE8 (but neither is RAF) also doesn't use a high performance timer (window.performance.now) this.currentTime = Date.now(); if(this._callback) { this._callback.call(this._callbackContext); @@ -9423,13 +6020,8 @@ var Phaser; }); this.lastTime = this.currentTime + timeToCall; }; - RequestAnimationFrame.prototype.SetTimeoutUpdate = /** - * - * @method SetTimeoutUpdate - **/ - function () { + RequestAnimationFrame.prototype.SetTimeoutUpdate = function () { var _this = this; - // Not in IE8 this.currentTime = Date.now(); if(this._callback) { this._callback.call(this._callbackContext); @@ -9444,13 +6036,6 @@ var Phaser; })(); Phaser.RequestAnimationFrame = RequestAnimationFrame; })(Phaser || (Phaser = {})); -/// -/// -/** -* Phaser - Input -* -* A game specific Input manager that looks after the mouse, keyboard and touch objects. This is updated by the core game loop. -*/ var Phaser; (function (Phaser) { var Input = (function () { @@ -9491,6 +6076,7 @@ var Phaser; }; Input.prototype.renderDebugInfo = function (x, y, color) { if (typeof color === "undefined") { color = 'rgb(255,255,255)'; } + this._game.stage.context.font = '14px Courier'; this._game.stage.context.fillStyle = color; this._game.stage.context.fillText('Input', x, y); this._game.stage.context.fillText('Screen X: ' + this.x + ' Screen Y: ' + this.y, x, y + 14); @@ -9501,14 +6087,6 @@ var Phaser; })(); Phaser.Input = Input; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - Keyboard -* -* The Keyboard class handles keyboard interactions with the game and the resulting events. -* The avoid stealing all browser input we don't use event.preventDefault. If you would like to trap a specific key however -* then use the addKeyCapture() method. -*/ var Phaser; (function (Phaser) { var Keyboard = (function () { @@ -9530,9 +6108,9 @@ var Phaser; }, false); }; Keyboard.prototype.addKeyCapture = function (keycode) { - if(typeof keycode == 'array') { - for(var code in keycode) { - this._capture[code] = true; + if(typeof keycode === 'object') { + for(var i = 0; i < keycode.length; i++) { + this._capture[keycode[i]] = true; } } else { this._capture[keycode] = true; @@ -9705,12 +6283,6 @@ var Phaser; })(); Phaser.Keyboard = Keyboard; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - Mouse -* -* The Mouse class handles mouse interactions with the game and the resulting events. -*/ var Phaser; (function (Phaser) { var Mouse = (function () { @@ -9756,8 +6328,6 @@ var Phaser; this._game.input.onDown.dispatch(this._game.input.x, this._game.input.y, this.timeDown); }; Mouse.prototype.update = function () { - //this._game.input.x = this._x * this._game.input.scaleX; - //this._game.input.y = this._y * this._game.input.scaleY; if(this.isDown) { this.duration = this._game.time.now - this.timeDown; } @@ -9785,143 +6355,34 @@ var Phaser; })(); Phaser.Mouse = Mouse; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - Finger -* -* A Finger object is used by the Touch manager and represents a single finger on the touch screen. -*/ var Phaser; (function (Phaser) { var Finger = (function () { - /** - * Constructor - * @param {Phaser.Game} game. - * @return {Phaser.Finger} This object. - */ function Finger(game) { - /** - * - * @property point - * @type Point - **/ this.point = null; - /** - * - * @property circle - * @type Circle - **/ this.circle = null; - /** - * - * @property withinGame - * @type Boolean - */ this.withinGame = false; - /** - * The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset - * @property clientX - * @type Number - */ this.clientX = -1; - // - /** - * The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset - * @property clientY - * @type Number - */ this.clientY = -1; - // - /** - * The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset - * @property pageX - * @type Number - */ this.pageX = -1; - /** - * The vertical coordinate of point relative to the viewport in pixels, including any scroll offset - * @property pageY - * @type Number - */ this.pageY = -1; - /** - * The horizontal coordinate of point relative to the screen in pixels - * @property screenX - * @type Number - */ this.screenX = -1; - /** - * The vertical coordinate of point relative to the screen in pixels - * @property screenY - * @type Number - */ this.screenY = -1; - /** - * The horizontal coordinate of point relative to the game element - * @property x - * @type Number - */ this.x = -1; - /** - * The vertical coordinate of point relative to the game element - * @property y - * @type Number - */ this.y = -1; - /** - * - * @property isDown - * @type Boolean - **/ this.isDown = false; - /** - * - * @property isUp - * @type Boolean - **/ this.isUp = false; - /** - * - * @property timeDown - * @type Number - **/ this.timeDown = 0; - /** - * - * @property duration - * @type Number - **/ this.duration = 0; - /** - * - * @property timeUp - * @type Number - **/ this.timeUp = 0; - /** - * - * @property justPressedRate - * @type Number - **/ this.justPressedRate = 200; - /** - * - * @property justReleasedRate - * @type Number - **/ this.justReleasedRate = 200; this._game = game; this.active = false; } - Finger.prototype.start = /** - * - * @method start - * @param {Any} event - */ - function (event) { + Finger.prototype.start = function (event) { this.identifier = event.identifier; this.target = event.target; - // populate geom objects if(this.point === null) { this.point = new Phaser.Point(); } @@ -9935,12 +6396,7 @@ var Phaser; this.isUp = false; this.timeDown = this._game.time.now; }; - Finger.prototype.move = /** - * - * @method move - * @param {Any} event - */ - function (event) { + Finger.prototype.move = function (event) { this.clientX = event.clientX; this.clientY = event.clientY; this.pageX = event.pageX; @@ -9951,24 +6407,13 @@ var Phaser; this.y = this.pageY - this._game.stage.offset.y; this.point.setTo(this.x, this.y); this.circle.setTo(this.x, this.y, 44); - // Droppings history (used for gestures and motion tracking) this.duration = this._game.time.now - this.timeDown; }; - Finger.prototype.leave = /** - * - * @method leave - * @param {Any} event - */ - function (event) { + Finger.prototype.leave = function (event) { this.withinGame = false; this.move(event); }; - Finger.prototype.stop = /** - * - * @method stop - * @param {Any} event - */ - function (event) { + Finger.prototype.stop = function (event) { this.active = false; this.withinGame = false; this.isDown = false; @@ -9976,13 +6421,7 @@ var Phaser; this.timeUp = this._game.time.now; this.duration = this.timeUp - this.timeDown; }; - Finger.prototype.justPressed = /** - * - * @method justPressed - * @param {Number} [duration]. - * @return {Boolean} - */ - function (duration) { + Finger.prototype.justPressed = function (duration) { if (typeof duration === "undefined") { duration = this.justPressedRate; } if(this.isDown === true && (this.timeDown + duration) > this._game.time.now) { return true; @@ -9990,13 +6429,7 @@ var Phaser; return false; } }; - Finger.prototype.justReleased = /** - * - * @method justReleased - * @param {Number} [duration]. - * @return {Boolean} - */ - function (duration) { + Finger.prototype.justReleased = function (duration) { if (typeof duration === "undefined") { duration = this.justReleasedRate; } if(this.isUp === true && (this.timeUp + duration) > this._game.time.now) { return true; @@ -10004,67 +6437,20 @@ var Phaser; return false; } }; - Finger.prototype.toString = /** - * Returns a string representation of this object. - * @method toString - * @return {string} a string representation of the instance. - **/ - function () { + Finger.prototype.toString = function () { return "[{Finger (identifer=" + this.identifier + " active=" + this.active + " duration=" + this.duration + " withinGame=" + this.withinGame + " x=" + this.x + " y=" + this.y + " clientX=" + this.clientX + " clientY=" + this.clientY + " screenX=" + this.screenX + " screenY=" + this.screenY + " pageX=" + this.pageX + " pageY=" + this.pageY + ")}]"; }; return Finger; })(); Phaser.Finger = Finger; })(Phaser || (Phaser = {})); -/// -/// -/** -* Phaser - Touch -* -* The Touch class handles touch interactions with the game and the resulting Finger objects. -* http://www.w3.org/TR/touch-events/ -* https://developer.mozilla.org/en-US/docs/DOM/TouchList -* http://www.html5rocks.com/en/mobile/touchandmouse/ -* Note: Android 2.x only supports 1 touch event at once, no multi-touch -* -* @todo Try and resolve update lag in Chrome/Android -* Gestures (pinch, zoom, swipe) -* GameObject Touch -* Touch point within GameObject -* Input Zones (mouse and touch) - lock entities within them + axis aligned drags -*/ var Phaser; (function (Phaser) { var Touch = (function () { - /** - * Constructor - * @param {Game} game. - * @return {Touch} This object. - */ function Touch(game) { - /** - * - * @property x - * @type Number - **/ this.x = 0; - /** - * - * @property y - * @type Number - **/ this.y = 0; - /** - * - * @property isDown - * @type Boolean - **/ this.isDown = false; - /** - * - * @property isUp - * @type Boolean - **/ this.isUp = true; this._game = game; this.finger1 = new Phaser.Finger(this._game); @@ -10093,11 +6479,7 @@ var Phaser; this.touchUp = new Phaser.Signal(); this.start(); } - Touch.prototype.start = /** - * - * @method start - */ - function () { + Touch.prototype.start = function () { var _this = this; this._game.stage.canvas.addEventListener('touchstart', function (event) { return _this.onTouchStart(event); @@ -10121,26 +6503,11 @@ var Phaser; return _this.consumeTouchMove(event); }, false); }; - Touch.prototype.consumeTouchMove = /** - * Prevent iOS bounce-back (doesn't work?) - * @method consumeTouchMove - * @param {Any} event - **/ - function (event) { + Touch.prototype.consumeTouchMove = function (event) { event.preventDefault(); }; - Touch.prototype.onTouchStart = /** - * - * @method onTouchStart - * @param {Any} event - **/ - function (event) { + Touch.prototype.onTouchStart = function (event) { event.preventDefault(); - // A list of all the touch points that BECAME active with the current event - // https://developer.mozilla.org/en-US/docs/DOM/TouchList - // event.targetTouches = list of all touches on the TARGET ELEMENT (i.e. game dom element) - // event.touches = list of all touches on the ENTIRE DOCUMENT, not just the target element - // event.changedTouches = the touches that CHANGED in this event, not the total number of them for(var i = 0; i < event.changedTouches.length; i++) { for(var f = 0; f < this._fingers.length; f++) { if(this._fingers[f].active === false) { @@ -10158,16 +6525,8 @@ var Phaser; } } }; - Touch.prototype.onTouchCancel = /** - * Doesn't appear to be supported by most browsers yet - * @method onTouchCancel - * @param {Any} event - **/ - function (event) { + Touch.prototype.onTouchCancel = function (event) { event.preventDefault(); - // Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome) - // http://www.w3.org/TR/touch-events/#dfn-touchcancel - // event.changedTouches = the touches that CHANGED in this event, not the total number of them for(var i = 0; i < event.changedTouches.length; i++) { for(var f = 0; f < this._fingers.length; f++) { if(this._fingers[f].identifier === event.changedTouches[i].identifier) { @@ -10177,17 +6536,8 @@ var Phaser; } } }; - Touch.prototype.onTouchEnter = /** - * Doesn't appear to be supported by most browsers yet - * @method onTouchEnter - * @param {Any} event - **/ - function (event) { + Touch.prototype.onTouchEnter = function (event) { event.preventDefault(); - // For touch enter and leave its a list of the touch points that have entered or left the target - // event.targetTouches = list of all touches on the TARGET ELEMENT (i.e. game dom element) - // event.touches = list of all touches on the ENTIRE DOCUMENT, not just the target element - // event.changedTouches = the touches that CHANGED in this event, not the total number of them for(var i = 0; i < event.changedTouches.length; i++) { for(var f = 0; f < this._fingers.length; f++) { if(this._fingers[f].active === false) { @@ -10197,15 +6547,8 @@ var Phaser; } } }; - Touch.prototype.onTouchLeave = /** - * Doesn't appear to be supported by most browsers yet - * @method onTouchLeave - * @param {Any} event - **/ - function (event) { + Touch.prototype.onTouchLeave = function (event) { event.preventDefault(); - // For touch enter and leave its a list of the touch points that have entered or left the target - // event.changedTouches = the touches that CHANGED in this event, not the total number of them for(var i = 0; i < event.changedTouches.length; i++) { for(var f = 0; f < this._fingers.length; f++) { if(this._fingers[f].identifier === event.changedTouches[i].identifier) { @@ -10215,16 +6558,8 @@ var Phaser; } } }; - Touch.prototype.onTouchMove = /** - * - * @method onTouchMove - * @param {Any} event - **/ - function (event) { + Touch.prototype.onTouchMove = function (event) { event.preventDefault(); - // event.targetTouches = list of all touches on the TARGET ELEMENT (i.e. game dom element) - // event.touches = list of all touches on the ENTIRE DOCUMENT, not just the target element - // event.changedTouches = the touches that CHANGED in this event, not the total number of them for(var i = 0; i < event.changedTouches.length; i++) { for(var f = 0; f < this._fingers.length; f++) { if(this._fingers[f].identifier === event.changedTouches[i].identifier) { @@ -10238,16 +6573,8 @@ var Phaser; } } }; - Touch.prototype.onTouchEnd = /** - * - * @method onTouchEnd - * @param {Any} event - **/ - function (event) { + Touch.prototype.onTouchEnd = function (event) { event.preventDefault(); - // For touch end its a list of the touch points that have been removed from the surface - // https://developer.mozilla.org/en-US/docs/DOM/TouchList - // event.changedTouches = the touches that CHANGED in this event, not the total number of them for(var i = 0; i < event.changedTouches.length; i++) { for(var f = 0; f < this._fingers.length; f++) { if(this._fingers[f].identifier === event.changedTouches[i].identifier) { @@ -10265,53 +6592,17 @@ var Phaser; } } }; - Touch.prototype.calculateDistance = /** - * - * @method calculateDistance - * @param {Finger} finger1 - * @param {Finger} finger2 - **/ - function (finger1, finger2) { + Touch.prototype.calculateDistance = function (finger1, finger2) { }; - Touch.prototype.calculateAngle = /** - * - * @method calculateAngle - * @param {Finger} finger1 - * @param {Finger} finger2 - **/ - function (finger1, finger2) { + Touch.prototype.calculateAngle = function (finger1, finger2) { }; - Touch.prototype.checkOverlap = /** - * - * @method checkOverlap - * @param {Finger} finger1 - * @param {Finger} finger2 - **/ - function (finger1, finger2) { + Touch.prototype.checkOverlap = function (finger1, finger2) { }; - Touch.prototype.update = /** - * - * @method update - */ - function () { + Touch.prototype.update = function () { }; - Touch.prototype.stop = /** - * - * @method stop - */ - function () { - //this._domElement.addEventListener('touchstart', (event) => this.onTouchStart(event), false); - //this._domElement.addEventListener('touchmove', (event) => this.onTouchMove(event), false); - //this._domElement.addEventListener('touchend', (event) => this.onTouchEnd(event), false); - //this._domElement.addEventListener('touchenter', (event) => this.onTouchEnter(event), false); - //this._domElement.addEventListener('touchleave', (event) => this.onTouchLeave(event), false); - //this._domElement.addEventListener('touchcancel', (event) => this.onTouchCancel(event), false); - }; - Touch.prototype.reset = /** - * - * @method reset - **/ - function () { + Touch.prototype.stop = function () { + }; + Touch.prototype.reset = function () { this.isDown = false; this.isUp = false; }; @@ -10319,27 +6610,10 @@ var Phaser; })(); Phaser.Touch = Touch; })(Phaser || (Phaser = {})); -/// -/// -/** -* Phaser - Emitter -* -* Emitter is a lightweight particle emitter. It can be used for one-time explosions or for -* continuous effects like rain and fire. All it really does is launch Particle objects out -* at set intervals, and fixes their positions and velocities accorindgly. -*/ var Phaser; (function (Phaser) { var Emitter = (function (_super) { __extends(Emitter, _super); - /** - * Creates a new Emitter object at a specific position. - * Does NOT automatically generate or attach particles! - * - * @param X The X position of the emitter. - * @param Y The Y position of the emitter. - * @param Size Optional, specifies a maximum capacity for this emitter. - */ function Emitter(game, X, Y, Size) { if (typeof X === "undefined") { X = 0; } if (typeof Y === "undefined") { Y = 0; } @@ -10365,10 +6639,7 @@ var Phaser; this.on = false; this._point = new Phaser.Point(); } - Emitter.prototype.destroy = /** - * Clean up memory. - */ - function () { + Emitter.prototype.destroy = function () { this.minParticleSpeed = null; this.maxParticleSpeed = null; this.particleDrag = null; @@ -10376,33 +6647,13 @@ var Phaser; this._point = null; _super.prototype.destroy.call(this); }; - Emitter.prototype.makeParticles = /** - * This function generates a new array of particle sprites to attach to the emitter. - * - * @param Graphics If you opted to not pre-configure an array of Sprite objects, you can simply pass in a particle image or sprite sheet. - * @param Quantity The number of particles to generate when using the "create from image" option. - * @param BakedRotations How many frames of baked rotation to use (boosts performance). Set to zero to not use baked rotations. - * @param Multiple Whether the image in the Graphics param is a single particle or a bunch of particles (if it's a bunch, they need to be square!). - * @param Collide Whether the particles should be flagged as not 'dead' (non-colliding particles are higher performance). 0 means no collisions, 0-1 controls scale of particle's bounding box. - * - * @return This Emitter instance (nice for chaining stuff together, if you're into that). - */ - function (Graphics, Quantity, BakedRotations, Multiple, Collide) { + Emitter.prototype.makeParticles = function (Graphics, Quantity, BakedRotations, Multiple, Collide) { if (typeof Quantity === "undefined") { Quantity = 50; } if (typeof BakedRotations === "undefined") { BakedRotations = 16; } if (typeof Multiple === "undefined") { Multiple = false; } if (typeof Collide === "undefined") { Collide = 0.8; } this.maxSize = Quantity; var totalFrames = 1; - /* - if(Multiple) - { - var sprite:Sprite = new Sprite(this._game); - sprite.loadGraphic(Graphics,true); - totalFrames = sprite.frames; - sprite.destroy(); - } - */ var randomFrame; var particle; var i = 0; @@ -10413,23 +6664,7 @@ var Phaser; particle = new this.particleClass(this._game); } if(Multiple) { - /* - randomFrame = this._game.math.random()*totalFrames; - if(BakedRotations > 0) - particle.loadRotatedGraphic(Graphics,BakedRotations,randomFrame); - else - { - particle.loadGraphic(Graphics,true); - particle.frame = randomFrame; - } - */ - } else { - /* - if (BakedRotations > 0) - particle.loadRotatedGraphic(Graphics,BakedRotations); - else - particle.loadGraphic(Graphics); - */ + } else { if(Graphics) { particle.loadGraphic(Graphics); } @@ -10437,8 +6672,7 @@ var Phaser; if(Collide > 0) { particle.width *= Collide; particle.height *= Collide; - //particle.centerOffsets(); - } else { + } else { particle.allowCollisions = Phaser.Collision.NONE; } particle.exists = false; @@ -10447,10 +6681,7 @@ var Phaser; } return this; }; - Emitter.prototype.update = /** - * Called automatically by the game loop, decides when to launch particles and when to "die". - */ - function () { + Emitter.prototype.update = function () { if(this.on) { if(this._explode) { this.on = false; @@ -10478,22 +6709,11 @@ var Phaser; } _super.prototype.update.call(this); }; - Emitter.prototype.kill = /** - * Call this function to turn off all the particles and the emitter. - */ - function () { + Emitter.prototype.kill = function () { this.on = false; _super.prototype.kill.call(this); }; - Emitter.prototype.start = /** - * Call this function to start emitting particles. - * - * @param Explode Whether the particles should all burst out at once. - * @param Lifespan How long each particle lives once emitted. 0 = forever. - * @param Frequency Ignored if Explode is set to true. Frequency is how often to emit a particle. 0 = never emit, 0.1 = 1 particle every 0.1 seconds, 5 = 1 particle every 5 seconds. - * @param Quantity How many particles to launch. 0 = "all of the particles". - */ - function (Explode, Lifespan, Frequency, Quantity) { + Emitter.prototype.start = function (Explode, Lifespan, Frequency, Quantity) { if (typeof Explode === "undefined") { Explode = true; } if (typeof Lifespan === "undefined") { Lifespan = 0; } if (typeof Frequency === "undefined") { Frequency = 0.1; } @@ -10508,10 +6728,7 @@ var Phaser; this._counter = 0; this._timer = 0; }; - Emitter.prototype.emitParticle = /** - * This function can be used both internally and externally to emit the next particle. - */ - function () { + Emitter.prototype.emitParticle = function () { var particle = this.recycle(Phaser.Particle); particle.lifespan = this.lifespan; particle.elasticity = this.bounce; @@ -10540,58 +6757,29 @@ var Phaser; particle.drag.y = this.particleDrag.y; particle.onEmit(); }; - Emitter.prototype.setSize = /** - * A more compact way of setting the width and height of the emitter. - * - * @param Width The desired width of the emitter (particles are spawned randomly within these dimensions). - * @param Height The desired height of the emitter. - */ - function (Width, Height) { + Emitter.prototype.setSize = function (Width, Height) { this.width = Width; this.height = Height; }; - Emitter.prototype.setXSpeed = /** - * A more compact way of setting the X velocity range of the emitter. - * - * @param Min The minimum value for this range. - * @param Max The maximum value for this range. - */ - function (Min, Max) { + Emitter.prototype.setXSpeed = function (Min, Max) { if (typeof Min === "undefined") { Min = 0; } if (typeof Max === "undefined") { Max = 0; } this.minParticleSpeed.x = Min; this.maxParticleSpeed.x = Max; }; - Emitter.prototype.setYSpeed = /** - * A more compact way of setting the Y velocity range of the emitter. - * - * @param Min The minimum value for this range. - * @param Max The maximum value for this range. - */ - function (Min, Max) { + Emitter.prototype.setYSpeed = function (Min, Max) { if (typeof Min === "undefined") { Min = 0; } if (typeof Max === "undefined") { Max = 0; } this.minParticleSpeed.y = Min; this.maxParticleSpeed.y = Max; }; - Emitter.prototype.setRotation = /** - * A more compact way of setting the angular velocity constraints of the emitter. - * - * @param Min The minimum value for this range. - * @param Max The maximum value for this range. - */ - function (Min, Max) { + Emitter.prototype.setRotation = function (Min, Max) { if (typeof Min === "undefined") { Min = 0; } if (typeof Max === "undefined") { Max = 0; } this.minRotation = Min; this.maxRotation = Max; }; - Emitter.prototype.at = /** - * Change the emitter's midpoint to match the midpoint of a Object. - * - * @param Object The Object that you want to sync up with. - */ - function (Object) { + Emitter.prototype.at = function (Object) { Object.getMidpoint(this._point); this.x = this._point.x - (this.width >> 1); this.y = this._point.y - (this.height >> 1); @@ -10600,14 +6788,6 @@ var Phaser; })(Phaser.Group); Phaser.Emitter = Emitter; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - GeomSprite -* -* A GeomSprite is a special kind of GameObject that contains a base geometry class (Circle, Line, Point, Rectangle). -* They can be rendered in the game and used for collision just like any other game object. Display of them is controlled -* via the lineWidth / lineColor / fillColor and renderOutline / renderFill properties. -*/ var Phaser; (function (Phaser) { var GeomSprite = (function (_super) { @@ -10616,7 +6796,6 @@ var Phaser; if (typeof x === "undefined") { x = 0; } if (typeof y === "undefined") { y = 0; } _super.call(this, game, x, y); - // local rendering related temp vars to help avoid gc spikes this._dx = 0; this._dy = 0; this._dw = 0; @@ -10695,7 +6874,6 @@ var Phaser; this.rect = null; }; GeomSprite.prototype.update = function () { - // Update bounds and position? if(this.type == GeomSprite.UNASSIGNED) { return; } else if(this.type == GeomSprite.CIRCLE) { @@ -10728,11 +6906,9 @@ var Phaser; } }; GeomSprite.prototype.render = function (camera, cameraOffsetX, cameraOffsetY) { - // Render checks if(this.type == GeomSprite.UNASSIGNED || this.visible === false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1 || this.cameraBlacklist.indexOf(camera.ID) !== -1 || this.inCamera(camera.worldView) == false) { return false; } - // Alpha if(this.alpha !== 1) { var globalAlpha = this._game.stage.context.globalAlpha; this._game.stage.context.globalAlpha = this.alpha; @@ -10741,41 +6917,24 @@ var Phaser; this._dy = cameraOffsetY + (this.bounds.y - camera.worldView.y); this._dw = this.bounds.width * this.scale.x; this._dh = this.bounds.height * this.scale.y; - // Circles are drawn center based if(this.type == GeomSprite.CIRCLE) { this._dx += this.circle.radius; this._dy += this.circle.radius; } - // Apply camera difference if(this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0) { this._dx -= (camera.worldView.x * this.scrollFactor.x); this._dy -= (camera.worldView.y * this.scrollFactor.y); } - // Rotation is disabled for now as I don't want it to be misleading re: collision - /* - if (this.angle !== 0) - { - this._game.stage.context.save(); - this._game.stage.context.translate(this._dx + (this._dw / 2) - this.origin.x, this._dy + (this._dh / 2) - this.origin.y); - this._game.stage.context.rotate(this.angle * (Math.PI / 180)); - this._dx = -(this._dw / 2); - this._dy = -(this._dh / 2); - } - */ this._dx = Math.round(this._dx); this._dy = Math.round(this._dy); this._dw = Math.round(this._dw); this._dh = Math.round(this._dh); this._game.stage.saveCanvasValues(); - // Debug - //this._game.stage.context.fillStyle = 'rgba(255,0,0,0.5)'; - //this._game.stage.context.fillRect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height); this._game.stage.context.lineWidth = this.lineWidth; this._game.stage.context.strokeStyle = this.lineColor; this._game.stage.context.fillStyle = this.fillColor; if(this._game.stage.fillStyle !== this.fillColor) { } - // Primitive Renderer if(this.type == GeomSprite.CIRCLE) { this._game.stage.context.beginPath(); this._game.stage.context.arc(this._dx, this._dy, this.circle.radius, 0, Math.PI * 2); @@ -10793,7 +6952,6 @@ var Phaser; } else if(this.type == GeomSprite.POINT) { this._game.stage.context.fillRect(this._dx, this._dy, 2, 2); } else if(this.type == GeomSprite.RECTANGLE) { - // We can use the faster fillRect if we don't need the outline if(this.renderOutline == false) { this._game.stage.context.fillRect(this._dx, this._dy, this.rect.width, this.rect.height); } else { @@ -10805,7 +6963,6 @@ var Phaser; } this._game.stage.context.closePath(); } - // And now the edge points this._game.stage.context.fillStyle = 'rgb(255,255,255)'; this.renderPoint(this._dx, this._dy, this.rect.topLeft, 2); this.renderPoint(this._dx, this._dy, this.rect.topCenter, 2); @@ -10834,76 +6991,53 @@ var Phaser; }; GeomSprite.prototype.renderDebugInfo = function (x, y, color) { if (typeof color === "undefined") { color = 'rgb(255,255,255)'; } - //this._game.stage.context.fillStyle = color; - //this._game.stage.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y); - //this._game.stage.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14); - //this._game.stage.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28); - //this._game.stage.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42); - }; - GeomSprite.prototype.collide = // Gives a basic boolean response to a geometric collision. - // If you need the details of the collision use the Collision functions instead and inspect the IntersectResult object. - function (source) { - // Circle vs. Circle + }; + GeomSprite.prototype.collide = function (source) { if(this.type == GeomSprite.CIRCLE && source.type == GeomSprite.CIRCLE) { return Phaser.Collision.circleToCircle(this.circle, source.circle).result; } - // Circle vs. Rect if(this.type == GeomSprite.CIRCLE && source.type == GeomSprite.RECTANGLE) { return Phaser.Collision.circleToRectangle(this.circle, source.rect).result; } - // Circle vs. Point if(this.type == GeomSprite.CIRCLE && source.type == GeomSprite.POINT) { return Phaser.Collision.circleContainsPoint(this.circle, source.point).result; } - // Circle vs. Line if(this.type == GeomSprite.CIRCLE && source.type == GeomSprite.LINE) { return Phaser.Collision.lineToCircle(source.line, this.circle).result; } - // Rect vs. Rect if(this.type == GeomSprite.RECTANGLE && source.type == GeomSprite.RECTANGLE) { return Phaser.Collision.rectangleToRectangle(this.rect, source.rect).result; } - // Rect vs. Circle if(this.type == GeomSprite.RECTANGLE && source.type == GeomSprite.CIRCLE) { return Phaser.Collision.circleToRectangle(source.circle, this.rect).result; } - // Rect vs. Point if(this.type == GeomSprite.RECTANGLE && source.type == GeomSprite.POINT) { return Phaser.Collision.pointToRectangle(source.point, this.rect).result; } - // Rect vs. Line if(this.type == GeomSprite.RECTANGLE && source.type == GeomSprite.LINE) { return Phaser.Collision.lineToRectangle(source.line, this.rect).result; } - // Point vs. Point if(this.type == GeomSprite.POINT && source.type == GeomSprite.POINT) { return this.point.equals(source.point); } - // Point vs. Circle if(this.type == GeomSprite.POINT && source.type == GeomSprite.CIRCLE) { return Phaser.Collision.circleContainsPoint(source.circle, this.point).result; } - // Point vs. Rect if(this.type == GeomSprite.POINT && source.type == GeomSprite.RECTANGLE) { return Phaser.Collision.pointToRectangle(this.point, source.rect).result; } - // Point vs. Line if(this.type == GeomSprite.POINT && source.type == GeomSprite.LINE) { return source.line.isPointOnLine(this.point.x, this.point.y); } - // Line vs. Line if(this.type == GeomSprite.LINE && source.type == GeomSprite.LINE) { return Phaser.Collision.lineSegmentToLineSegment(this.line, source.line).result; } - // Line vs. Circle if(this.type == GeomSprite.LINE && source.type == GeomSprite.CIRCLE) { return Phaser.Collision.lineToCircle(this.line, source.circle).result; } - // Line vs. Rect if(this.type == GeomSprite.LINE && source.type == GeomSprite.RECTANGLE) { return Phaser.Collision.lineSegmentToRectangle(this.line, source.rect).result; } - // Line vs. Point if(this.type == GeomSprite.LINE && source.type == GeomSprite.POINT) { return this.line.isPointOnLine(source.point.x, source.point.y); } @@ -10913,33 +7047,16 @@ var Phaser; })(Phaser.GameObject); Phaser.GeomSprite = GeomSprite; })(Phaser || (Phaser = {})); -/// -/// -/** -* Phaser - Particle -* -* This is a simple particle class that extends a Sprite to have a slightly more -* specialised behaviour. It is used exclusively by the Emitter class and can be extended as required. -*/ var Phaser; (function (Phaser) { var Particle = (function (_super) { __extends(Particle, _super); - /** - * Instantiate a new particle. Like Sprite, all meaningful creation - * happens during loadGraphic() or makeGraphic() or whatever. - */ function Particle(game) { _super.call(this, game); this.lifespan = 0; this.friction = 500; } - Particle.prototype.update = /** - * The particle's main update logic. Basically it checks to see if it should - * be dead yet, and then has some special bounce behavior if there is some gravity on it. - */ - function () { - //lifespan behavior + Particle.prototype.update = function () { if(this.lifespan <= 0) { return; } @@ -10947,14 +7064,12 @@ var Phaser; if(this.lifespan <= 0) { this.kill(); } - //simpler bounce/spin behavior for now if(this.touching) { if(this.angularVelocity != 0) { this.angularVelocity = -this.angularVelocity; } } - if(this.acceleration.y > 0)//special behavior for particles with gravity - { + if(this.acceleration.y > 0) { if(this.touching & Phaser.Collision.FLOOR) { this.drag.x = this.friction; if(!(this.wasTouching & Phaser.Collision.FLOOR)) { @@ -10972,26 +7087,16 @@ var Phaser; } } }; - Particle.prototype.onEmit = /** - * Triggered whenever this object is launched by a Emitter. - * You can override this to add custom behavior like a sound or AI or something. - */ - function () { + Particle.prototype.onEmit = function () { }; return Particle; })(Phaser.Sprite); Phaser.Particle = Particle; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - TilemapLayer -* -* A Tilemap Layer. Tiled format maps can have multiple overlapping layers. -*/ var Phaser; (function (Phaser) { var TilemapLayer = (function () { - function TilemapLayer(game, key, mapFormat, name, tileWidth, tileHeight) { + function TilemapLayer(game, parent, key, mapFormat, name, tileWidth, tileHeight) { this._startX = 0; this._startY = 0; this._maxX = 0; @@ -11003,22 +7108,102 @@ var Phaser; this._oldCameraX = 0; this._oldCameraY = 0; this.alpha = 1; + this.exists = true; this.visible = true; this.widthInTiles = 0; this.heightInTiles = 0; this.widthInPixels = 0; this.heightInPixels = 0; + this.tileMargin = 0; + this.tileSpacing = 0; this._game = game; + this._parent = parent; this.name = name; this.mapFormat = mapFormat; this.tileWidth = tileWidth; this.tileHeight = tileHeight; this.boundsInTiles = new Phaser.Rectangle(); - //this.scrollFactor = new MicroPoint(1, 1); this.mapData = []; this._texture = this._game.cache.getImage(key); - this.parseTileOffsets(); } + TilemapLayer.prototype.getTileFromWorldXY = function (x, y) { + x = this._game.math.snapToFloor(x, this.tileWidth) / this.tileWidth; + y = this._game.math.snapToFloor(y, this.tileHeight) / this.tileHeight; + return this.getTileIndex(x, y); + }; + TilemapLayer.prototype.getTileOverlaps = function (object) { + var mapX = this._game.math.snapToFloor(object.bounds.x, this.tileWidth); + var mapY = this._game.math.snapToFloor(object.bounds.y, this.tileHeight); + var mapW = this._game.math.snapToCeil(object.bounds.width, this.tileWidth) + this.tileWidth; + var mapH = this._game.math.snapToCeil(object.bounds.height, this.tileHeight) + this.tileHeight; + var tileX = mapX / this.tileWidth; + var tileY = mapY / this.tileHeight; + var tileW = mapW / this.tileWidth; + var tileH = mapH / this.tileHeight; + if(tileX < 0) { + tileX = 0; + } + if(tileY < 0) { + tileY = 0; + } + if(tileW > this.widthInTiles) { + tileW = this.widthInTiles; + } + if(tileH > this.heightInTiles) { + tileH = this.heightInTiles; + } + var tiles = this.getTileBlock(tileX, tileY, tileW, tileH); + var result = []; + var tempBounds = new Phaser.Quad(); + for(var r = 0; r < tiles.length; r++) { + if(tiles[r].tile.allowCollisions != Phaser.Collision.NONE) { + tempBounds.setTo(tiles[r].x * this.tileWidth, tiles[r].y * this.tileHeight, this.tileWidth, this.tileHeight); + if(tempBounds.intersects(object.bounds)) { + result.push(Phaser.Collision.separateTile(object, { + x: tempBounds.x, + y: tempBounds.y, + width: tempBounds.width, + height: tempBounds.height, + mass: 1.0, + immovable: true, + allowCollisions: Phaser.Collision.ANY + })); + } else { + result.push(false); + } + } else { + result.push(false); + } + } + return { + x: tileX, + y: tileY, + w: tileW, + h: tileH, + collision: result + }; + }; + TilemapLayer.prototype.getTileBlock = function (x, y, width, height) { + var output = []; + for(var ty = y; ty < y + height; ty++) { + for(var tx = x; tx < x + width; tx++) { + output.push({ + x: tx, + y: ty, + tile: this._parent.tiles[this.mapData[ty][tx]] + }); + } + } + return output; + }; + TilemapLayer.prototype.getTileIndex = function (x, y) { + if(y >= 0 && y < this.mapData.length) { + if(x >= 0 && x < this.mapData[y].length) { + return this.mapData[y][x]; + } + } + return null; + }; TilemapLayer.prototype.addColumn = function (column) { var data = []; for(var c = 0; c < column.length; c++) { @@ -11034,17 +7219,17 @@ var Phaser; }; TilemapLayer.prototype.updateBounds = function () { this.boundsInTiles.setTo(0, 0, this.widthInTiles, this.heightInTiles); + console.log('layer bounds', this.boundsInTiles); }; TilemapLayer.prototype.parseTileOffsets = function () { this._tileOffsets = []; var i = 0; if(this.mapFormat == Phaser.Tilemap.FORMAT_TILED_JSON) { - // For some reason Tiled counts from 1 not 0 this._tileOffsets[0] = null; i = 1; } - for(var ty = 0; ty < this._texture.height; ty += this.tileHeight) { - for(var tx = 0; tx < this._texture.width; tx += this.tileWidth) { + for(var ty = this.tileMargin; ty < this._texture.height; ty += (this.tileHeight + this.tileSpacing)) { + for(var tx = this.tileMargin; tx < this._texture.width; tx += (this.tileWidth + this.tileSpacing)) { this._tileOffsets[i] = { x: tx, y: ty @@ -11052,6 +7237,7 @@ var Phaser; i++; } } + return this._tileOffsets.length; }; TilemapLayer.prototype.renderDebugInfo = function (x, y, color) { if (typeof color === "undefined") { color = 'rgb(255,255,255)'; } @@ -11065,41 +7251,34 @@ var Phaser; if(this.visible === false || this.alpha < 0.1) { return false; } - // Work out how many tiles we can fit into our camera and round it up for the edges this._maxX = this._game.math.ceil(camera.width / this.tileWidth) + 1; this._maxY = this._game.math.ceil(camera.height / this.tileHeight) + 1; - // And now work out where in the tilemap the camera actually is this._startX = this._game.math.floor(camera.worldView.x / this.tileWidth); this._startY = this._game.math.floor(camera.worldView.y / this.tileHeight); - // Tilemap bounds check if(this._startX < 0) { this._startX = 0; } if(this._startY < 0) { this._startY = 0; } + if(this._maxX > this.widthInTiles) { + this._maxX = this.widthInTiles; + } + if(this._maxY > this.heightInTiles) { + this._maxY = this.heightInTiles; + } if(this._startX + this._maxX > this.widthInTiles) { this._startX = this.widthInTiles - this._maxX; } if(this._startY + this._maxY > this.heightInTiles) { this._startY = this.heightInTiles - this._maxY; } - // Finally get the offset to avoid the blocky movement this._dx = dx; this._dy = dy; this._dx += -(camera.worldView.x - (this._startX * this.tileWidth)); this._dy += -(camera.worldView.y - (this._startY * this.tileHeight)); this._tx = this._dx; this._ty = this._dy; - // Apply camera difference - /* - if (this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0) - { - this._dx -= (camera.worldView.x * this.scrollFactor.x); - this._dy -= (camera.worldView.y * this.scrollFactor.y); - } - */ - // Alpha if(this.alpha !== 1) { var globalAlpha = this._game.stage.context.globalAlpha; this._game.stage.context.globalAlpha = this.alpha; @@ -11108,17 +7287,8 @@ var Phaser; this._columnData = this.mapData[row]; for(var tile = this._startX; tile < this._startX + this._maxX; tile++) { if(this._tileOffsets[this._columnData[tile]]) { - this._game.stage.context.drawImage(this._texture, // Source Image - this._tileOffsets[this._columnData[tile]].x, // Source X (location within the source image) - this._tileOffsets[this._columnData[tile]].y, // Source Y - this.tileWidth, // Source Width - this.tileHeight, // Source Height - this._tx, // Destination X (where on the canvas it'll be drawn) - this._ty, // Destination Y - this.tileWidth, // Destination Width (always same as Source Width unless scaled) - this.tileHeight); - // Destination Height (always same as Source Height unless scaled) - } + this._game.stage.context.drawImage(this._texture, this._tileOffsets[this._columnData[tile]].x, this._tileOffsets[this._columnData[tile]].y, this.tileWidth, this.tileHeight, this._tx, this._ty, this.tileWidth, this.tileHeight); + } this._tx += this.tileWidth; } this._tx = this._dx; @@ -11133,15 +7303,27 @@ var Phaser; })(); Phaser.TilemapLayer = TilemapLayer; })(Phaser || (Phaser = {})); -/// -/// -/// -/** -* Phaser - Tilemap -* -* This GameObject allows for the display of a tilemap within the game world. Tile maps consist of an image, tile data and a size. -* Internally it creates a TilemapLayer for each layer in the tilemap. -*/ +var Phaser; +(function (Phaser) { + var Tile = (function () { + function Tile(game, tilemap, index, width, height) { + this._game = game; + this.tilemap = tilemap; + this.index = index; + this.width = width; + this.height = height; + this.allowCollisions = Phaser.Collision.NONE; + } + Tile.prototype.destroy = function () { + this.tilemap = null; + }; + Tile.prototype.toString = function () { + return "[{Tiled (index=" + this.index + " collisions=" + this.allowCollisions + " width=" + this.width + " height=" + this.height + ")}]"; + }; + return Tile; + })(); + Phaser.Tile = Tile; +})(Phaser || (Phaser = {})); var Phaser; (function (Phaser) { var Tilemap = (function (_super) { @@ -11152,7 +7334,8 @@ var Phaser; if (typeof tileHeight === "undefined") { tileHeight = 0; } _super.call(this, game); this.isGroup = false; - this._layers = []; + this.tiles = []; + this.layers = []; this.mapFormat = format; switch(format) { case Tilemap.FORMAT_CSV: @@ -11172,15 +7355,13 @@ var Phaser; }; Tilemap.prototype.render = function (camera, cameraOffsetX, cameraOffsetY) { if(this.cameraBlacklist.indexOf(camera.ID) == -1) { - // Loop through the layers - for(var i = 0; i < this._layers.length; i++) { - this._layers[i].render(camera, cameraOffsetX, cameraOffsetY); + for(var i = 0; i < this.layers.length; i++) { + this.layers[i].render(camera, cameraOffsetX, cameraOffsetY); } } }; Tilemap.prototype.parseCSV = function (data, key, tileWidth, tileHeight) { - var layer = new Phaser.TilemapLayer(this._game, key, Tilemap.FORMAT_CSV, 'TileLayerCSV' + this._layers.length.toString(), tileWidth, tileHeight); - // Trim any rogue whitespace from the data + var layer = new Phaser.TilemapLayer(this._game, this, key, Tilemap.FORMAT_CSV, 'TileLayerCSV' + this.layers.length.toString(), tileWidth, tileHeight); data = data.trim(); var rows = data.split("\n"); for(var i = 0; i < rows.length; i++) { @@ -11190,17 +7371,20 @@ var Phaser; } } layer.updateBounds(); + var tileQuantity = layer.parseTileOffsets(); this.currentLayer = layer; - this._layers.push(layer); + this.layers.push(layer); + this.generateTiles(tileQuantity); }; Tilemap.prototype.parseTiledJSON = function (data, key) { - // Trim any rogue whitespace from the data data = data.trim(); var json = JSON.parse(data); for(var i = 0; i < json.layers.length; i++) { - var layer = new Phaser.TilemapLayer(this._game, key, Tilemap.FORMAT_TILED_JSON, json.layers[i].name, json.tilewidth, json.tileheight); + var layer = new Phaser.TilemapLayer(this._game, this, key, Tilemap.FORMAT_TILED_JSON, json.layers[i].name, json.tilewidth, json.tileheight); layer.alpha = json.layers[i].opacity; layer.visible = json.layers[i].visible; + layer.tileMargin = json.tilesets[0].margin; + layer.tileSpacing = json.tilesets[0].spacing; var c = 0; var row; for(var t = 0; t < json.layers[i].data.length; t++) { @@ -11215,8 +7399,15 @@ var Phaser; } } layer.updateBounds(); + var tileQuantity = layer.parseTileOffsets(); this.currentLayer = layer; - this._layers.push(layer); + this.layers.push(layer); + } + this.generateTiles(tileQuantity); + }; + Tilemap.prototype.generateTiles = function (qty) { + for(var i = 0; i < qty; i++) { + this.tiles.push(new Phaser.Tile(this._game, this, i, this.currentLayer.tileWidth, this.currentLayer.tileHeight)); } }; Object.defineProperty(Tilemap.prototype, "widthInPixels", { @@ -11233,54 +7424,258 @@ var Phaser; enumerable: true, configurable: true }); + Tilemap.prototype.setCollisionRange = function (start, end, collision) { + if (typeof collision === "undefined") { collision = Phaser.Collision.ANY; } + for(var i = start; i < end; i++) { + this.tiles[i].allowCollisions = collision; + } + }; + Tilemap.prototype.setCollisionByIndex = function (values, collision) { + if (typeof collision === "undefined") { collision = Phaser.Collision.ANY; } + for(var i = 0; i < values.length; i++) { + this.tiles[values[i]].allowCollisions = collision; + } + }; + Tilemap.prototype.getTile = function (x, y, layer) { + if (typeof layer === "undefined") { layer = 0; } + return this.tiles[this.layers[layer].getTileIndex(x, y)]; + }; + Tilemap.prototype.getTileFromWorldXY = function (x, y, layer) { + if (typeof layer === "undefined") { layer = 0; } + return this.tiles[this.layers[layer].getTileFromWorldXY(x, y)]; + }; + Tilemap.prototype.getTileFromInputXY = function (layer) { + if (typeof layer === "undefined") { layer = 0; } + return this.tiles[this.layers[layer].getTileFromWorldXY(this._game.input.worldX, this._game.input.worldY)]; + }; + Tilemap.prototype.getTileOverlaps = function (object) { + return this.currentLayer.getTileOverlaps(object); + }; + Tilemap.prototype.collide = function (objectOrGroup, callback) { + if (typeof objectOrGroup === "undefined") { objectOrGroup = null; } + if (typeof callback === "undefined") { callback = null; } + if(objectOrGroup == null) { + objectOrGroup = this._game.world.group; + } + if(objectOrGroup.isGroup == false) { + if(objectOrGroup.exists && objectOrGroup.allowCollisions != Phaser.Collision.NONE) { + this.currentLayer.getTileOverlaps(objectOrGroup); + } + } else { + objectOrGroup.forEachAlive(this.currentLayer.getTileOverlaps); + } + return true; + }; return Tilemap; })(Phaser.GameObject); Phaser.Tilemap = Tilemap; - // Set current layer - // Set layer order? - // Get tile from x/y - // Get block of tiles - // Swap tiles around - // Delete tiles of certain type - // Erase tiles - })(Phaser || (Phaser = {})); -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/** -* Phaser - Game -* -* This is where the magic happens. The Game object is the heart of your game, -* providing quick access to common functions and handling the boot process. -*/ +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var ScrollRegion = (function () { + function ScrollRegion(x, y, width, height, speedX, speedY) { + this._anchorWidth = 0; + this._anchorHeight = 0; + this._inverseWidth = 0; + this._inverseHeight = 0; + this.visible = true; + this._A = new Phaser.Quad(x, y, width, height); + this._B = new Phaser.Quad(x, y, width, height); + this._C = new Phaser.Quad(x, y, width, height); + this._D = new Phaser.Quad(x, y, width, height); + this._scroll = new Phaser.MicroPoint(); + this._bounds = new Phaser.Quad(x, y, width, height); + this.scrollSpeed = new Phaser.MicroPoint(speedX, speedY); + } + ScrollRegion.prototype.update = function (delta) { + this._scroll.x += this.scrollSpeed.x; + this._scroll.y += this.scrollSpeed.y; + if(this._scroll.x > this._bounds.right) { + this._scroll.x = this._bounds.x; + } + if(this._scroll.x < this._bounds.x) { + this._scroll.x = this._bounds.right; + } + if(this._scroll.y > this._bounds.bottom) { + this._scroll.y = this._bounds.y; + } + if(this._scroll.y < this._bounds.y) { + this._scroll.y = this._bounds.bottom; + } + this._anchorWidth = (this._bounds.width - this._scroll.x) + this._bounds.x; + this._anchorHeight = (this._bounds.height - this._scroll.y) + this._bounds.y; + if(this._anchorWidth > this._bounds.width) { + this._anchorWidth = this._bounds.width; + } + if(this._anchorHeight > this._bounds.height) { + this._anchorHeight = this._bounds.height; + } + this._inverseWidth = this._bounds.width - this._anchorWidth; + this._inverseHeight = this._bounds.height - this._anchorHeight; + this._A.setTo(this._scroll.x, this._scroll.y, this._anchorWidth, this._anchorHeight); + this._B.y = this._scroll.y; + this._B.width = this._inverseWidth; + this._B.height = this._anchorHeight; + this._C.x = this._scroll.x; + this._C.width = this._anchorWidth; + this._C.height = this._inverseHeight; + this._D.width = this._inverseWidth; + this._D.height = this._inverseHeight; + }; + ScrollRegion.prototype.render = function (context, texture, dx, dy, dw, dh) { + if(this.visible == false) { + return; + } + this.crop(context, texture, this._A.x, this._A.y, this._A.width, this._A.height, dx, dy, dw, dh, 0, 0); + this.crop(context, texture, this._B.x, this._B.y, this._B.width, this._B.height, dx, dy, dw, dh, this._A.width, 0); + this.crop(context, texture, this._C.x, this._C.y, this._C.width, this._C.height, dx, dy, dw, dh, 0, this._A.height); + this.crop(context, texture, this._D.x, this._D.y, this._D.width, this._D.height, dx, dy, dw, dh, this._C.width, this._A.height); + }; + ScrollRegion.prototype.crop = function (context, texture, srcX, srcY, srcW, srcH, destX, destY, destW, destH, offsetX, offsetY) { + offsetX += destX; + offsetY += destY; + if(srcW > (destX + destW) - offsetX) { + srcW = (destX + destW) - offsetX; + } + if(srcH > (destY + destH) - offsetY) { + srcH = (destY + destH) - offsetY; + } + srcX = Math.floor(srcX); + srcY = Math.floor(srcY); + srcW = Math.floor(srcW); + srcH = Math.floor(srcH); + offsetX = Math.floor(offsetX + this._bounds.x); + offsetY = Math.floor(offsetY + this._bounds.y); + if(srcW > 0 && srcH > 0) { + context.drawImage(texture, srcX, srcY, srcW, srcH, offsetX, offsetY, srcW, srcH); + } + }; + return ScrollRegion; + })(); + Phaser.ScrollRegion = ScrollRegion; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var ScrollZone = (function (_super) { + __extends(ScrollZone, _super); + function ScrollZone(game, key, x, y, width, height) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof width === "undefined") { width = 0; } + if (typeof height === "undefined") { height = 0; } + _super.call(this, game, x, y, width, height); + this._dynamicTexture = null; + this._dx = 0; + this._dy = 0; + this._dw = 0; + this._dh = 0; + this.flipped = false; + this.regions = []; + if(this._game.cache.getImage(key)) { + this._texture = this._game.cache.getImage(key); + this.width = this._texture.width; + this.height = this._texture.height; + if(width > this._texture.width || height > this._texture.height) { + this.createRepeatingTexture(width, height); + this.width = width; + this.height = height; + } + this.addRegion(0, 0, this.width, this.height); + if((width < this._texture.width || height < this._texture.height) && width !== 0 && height !== 0) { + this.width = width; + this.height = height; + } + } + } + ScrollZone.prototype.addRegion = function (x, y, width, height, speedX, speedY) { + if (typeof speedX === "undefined") { speedX = 0; } + if (typeof speedY === "undefined") { speedY = 0; } + if(x > this.width || y > this.height || x < 0 || y < 0 || (x + width) > this.width || (y + height) > this.height) { + throw Error('Invalid ScrollRegion defined. Cannot be larger than parent ScrollZone'); + return; + } + this.currentRegion = new Phaser.ScrollRegion(x, y, width, height, speedX, speedY); + this.regions.push(this.currentRegion); + return this.currentRegion; + }; + ScrollZone.prototype.setSpeed = function (x, y) { + if(this.currentRegion) { + this.currentRegion.scrollSpeed.setTo(x, y); + } + return this; + }; + ScrollZone.prototype.update = function () { + for(var i = 0; i < this.regions.length; i++) { + this.regions[i].update(this._game.time.delta); + } + }; + ScrollZone.prototype.inCamera = function (camera) { + if(this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0) { + this._dx = this.bounds.x - (camera.x * this.scrollFactor.x); + this._dy = this.bounds.y - (camera.y * this.scrollFactor.x); + this._dw = this.bounds.width * this.scale.x; + this._dh = this.bounds.height * this.scale.y; + return (camera.right > this._dx) && (camera.x < this._dx + this._dw) && (camera.bottom > this._dy) && (camera.y < this._dy + this._dh); + } else { + return camera.intersects(this.bounds, this.bounds.length); + } + }; + ScrollZone.prototype.render = function (camera, cameraOffsetX, cameraOffsetY) { + if(this.visible == false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1 || this.cameraBlacklist.indexOf(camera.ID) !== -1 || this.inCamera(camera.worldView) == false) { + return false; + } + if(this.alpha !== 1) { + var globalAlpha = this._game.stage.context.globalAlpha; + this._game.stage.context.globalAlpha = this.alpha; + } + this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x); + this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y); + this._dw = this.bounds.width * this.scale.x; + this._dh = this.bounds.height * this.scale.y; + if(this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0) { + this._dx -= (camera.worldView.x * this.scrollFactor.x); + this._dy -= (camera.worldView.y * this.scrollFactor.y); + } + if(this.angle !== 0 || this.flipped == true) { + this._game.stage.context.save(); + this._game.stage.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2)); + if(this.angle !== 0) { + this._game.stage.context.rotate(this.angle * (Math.PI / 180)); + } + this._dx = -(this._dw / 2); + this._dy = -(this._dh / 2); + if(this.flipped == true) { + this._game.stage.context.scale(-1, 1); + } + } + this._dx = Math.round(this._dx); + this._dy = Math.round(this._dy); + this._dw = Math.round(this._dw); + this._dh = Math.round(this._dh); + for(var i = 0; i < this.regions.length; i++) { + if(this._dynamicTexture) { + this.regions[i].render(this._game.stage.context, this._dynamicTexture.canvas, this._dx, this._dy, this._dw, this._dh); + } else { + this.regions[i].render(this._game.stage.context, this._texture, this._dx, this._dy, this._dw, this._dh); + } + } + if(globalAlpha > -1) { + this._game.stage.context.globalAlpha = globalAlpha; + } + return true; + }; + ScrollZone.prototype.createRepeatingTexture = function (regionWidth, regionHeight) { + var tileWidth = Math.ceil(this._texture.width / regionWidth) * regionWidth; + var tileHeight = Math.ceil(this._texture.height / regionHeight) * regionHeight; + this._dynamicTexture = new Phaser.DynamicTexture(this._game, tileWidth, tileHeight); + this._dynamicTexture.context.rect(0, 0, tileWidth, tileHeight); + this._dynamicTexture.context.fillStyle = this._dynamicTexture.context.createPattern(this._texture, "repeat"); + this._dynamicTexture.context.fill(); + }; + return ScrollZone; + })(Phaser.GameObject); + Phaser.ScrollZone = ScrollZone; +})(Phaser || (Phaser = {})); var Phaser; (function (Phaser) { var Game = (function () { @@ -11349,7 +7744,6 @@ var Phaser; (Date.now() * Math.random()).toString() ]); this.framerate = 60; - // Display the default game screen? if(this.onInitCallback == null && this.onCreateCallback == null && this.onUpdateCallback == null && this.onRenderCallback == null && this._pendingState == null) { this.isBooted = false; this.stage.drawInitScreen(); @@ -11366,7 +7760,6 @@ var Phaser; } }; Game.prototype.loadComplete = function () { - // Called when the loader has finished after init was run this._loadComplete = true; }; Game.prototype.loop = function () { @@ -11401,7 +7794,6 @@ var Phaser; if(this.onInitCallback !== null) { this.loader.reset(); this.onInitCallback.call(this.callbackContext); - // Is the loader empty? if(this.loader.queueSize == 0) { if(this.onCreateCallback !== null) { this.onCreateCallback.call(this.callbackContext); @@ -11409,7 +7801,6 @@ var Phaser; this._loadComplete = true; } } else { - // No init? Then there was nothing to load either if(this.onCreateCallback !== null) { this.onCreateCallback.call(this.callbackContext); } @@ -11433,11 +7824,9 @@ var Phaser; this._pendingState = state; return; } - // Prototype? if(typeof state === 'function') { state = new state(this); } - // Ok, have we got the right functions? if(state['create'] || state['update']) { this.callbackContext = state; this.onInitCallback = null; @@ -11445,7 +7834,6 @@ var Phaser; this.onUpdateCallback = null; this.onRenderCallback = null; this.onPausedCallback = null; - // Bingo, let's set them up if(state['init']) { this.onInitCallback = state['init']; } @@ -11470,12 +7858,10 @@ var Phaser; this._loadComplete = false; this.startState(); } else { - throw Error("Invalid State object given. Must contain at least a create or update function."); - return; + throw new Error("Invalid State object given. Must contain at least a create or update function."); } }; - Game.prototype.destroy = // Nuke the whole game from orbit - function () { + Game.prototype.destroy = function () { this.callbackContext = null; this.onInitCallback = null; this.onCreateCallback = null; @@ -11521,8 +7907,7 @@ var Phaser; enumerable: true, configurable: true }); - Game.prototype.createCamera = // Handy Proxy methods - function (x, y, width, height) { + Game.prototype.createCamera = function (x, y, width, height) { return this.world.createCamera(x, y, width, height); }; Game.prototype.createGeomSprite = function (x, y) { @@ -11564,409 +7949,397 @@ var Phaser; Game.prototype.createTween = function (obj) { return this.tweens.create(obj); }; - Game.prototype.collide = function (ObjectOrGroup1, ObjectOrGroup2, NotifyCallback) { - if (typeof ObjectOrGroup1 === "undefined") { ObjectOrGroup1 = null; } - if (typeof ObjectOrGroup2 === "undefined") { ObjectOrGroup2 = null; } - if (typeof NotifyCallback === "undefined") { NotifyCallback = null; } - return this.collision.overlap(ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, Phaser.Collision.separate); + Game.prototype.collide = function (objectOrGroup1, objectOrGroup2, notifyCallback) { + if (typeof objectOrGroup1 === "undefined") { objectOrGroup1 = null; } + if (typeof objectOrGroup2 === "undefined") { objectOrGroup2 = null; } + if (typeof notifyCallback === "undefined") { notifyCallback = null; } + return this.collision.overlap(objectOrGroup1, objectOrGroup2, notifyCallback, Phaser.Collision.separate); }; return Game; })(); Phaser.Game = Game; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - Quad -* -* A Quad object is an area defined by its position, as indicated by its top-left corner (x,y) and width and height. -* Very much like a Rectangle only without all of the additional methods and properties of that class. -*/ var Phaser; (function (Phaser) { - var Quad = (function () { - /** - * Creates a new Quad object with the top-left corner specified by the x and y parameters and with the specified width and height parameters. If you call this function without parameters, a rectangle with x, y, width, and height properties set to 0 is created. - * @class Quad - * @constructor - * @param {Number} x The x coordinate of the top-left corner of the quad. - * @param {Number} y The y coordinate of the top-left corner of the quad. - * @param {Number} width The width of the quad. - * @param {Number} height The height of the quad. - * @return {Quad } This object - **/ - function Quad(x, y, width, height) { - if (typeof x === "undefined") { x = 0; } - if (typeof y === "undefined") { y = 0; } - if (typeof width === "undefined") { width = 0; } - if (typeof height === "undefined") { height = 0; } - this.setTo(x, y, width, height); + var Animation = (function () { + function Animation(game, parent, frameData, name, frames, delay, looped) { + this._game = game; + this._parent = parent; + this._frames = frames; + this._frameData = frameData; + this.name = name; + this.delay = 1000 / delay; + this.looped = looped; + this.isFinished = false; + this.isPlaying = false; + this._frameIndex = 0; + this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); } - Quad.prototype.setTo = /** - * Sets the Quad to the specified size. - * @method setTo - * @param {Number} x The x coordinate of the top-left corner of the quad. - * @param {Number} y The y coordinate of the top-left corner of the quad. - * @param {Number} width The width of the quad. - * @param {Number} height The height of the quad. - * @return {Quad} This object - **/ - function (x, y, width, height) { + Object.defineProperty(Animation.prototype, "frameTotal", { + get: function () { + return this._frames.length; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "frame", { + get: function () { + return this._frameIndex; + }, + set: function (value) { + this.currentFrame = this._frameData.getFrame(value); + if(this.currentFrame !== null) { + this._parent.bounds.width = this.currentFrame.width; + this._parent.bounds.height = this.currentFrame.height; + this._frameIndex = value; + } + }, + enumerable: true, + configurable: true + }); + Animation.prototype.play = function (frameRate, loop) { + if (typeof frameRate === "undefined") { frameRate = null; } + if(frameRate !== null) { + this.delay = 1000 / frameRate; + } + if(loop !== undefined) { + this.looped = loop; + } + this.isPlaying = true; + this.isFinished = false; + this._timeLastFrame = this._game.time.now; + this._timeNextFrame = this._game.time.now + this.delay; + this._frameIndex = 0; + this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); + }; + Animation.prototype.restart = function () { + this.isPlaying = true; + this.isFinished = false; + this._timeLastFrame = this._game.time.now; + this._timeNextFrame = this._game.time.now + this.delay; + this._frameIndex = 0; + this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); + }; + Animation.prototype.stop = function () { + this.isPlaying = false; + this.isFinished = true; + }; + Animation.prototype.update = function () { + if(this.isPlaying == true && this._game.time.now >= this._timeNextFrame) { + this._frameIndex++; + if(this._frameIndex == this._frames.length) { + if(this.looped) { + this._frameIndex = 0; + this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); + } else { + this.onComplete(); + } + } else { + this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); + } + this._timeLastFrame = this._game.time.now; + this._timeNextFrame = this._game.time.now + this.delay; + return true; + } + return false; + }; + Animation.prototype.destroy = function () { + this._game = null; + this._parent = null; + this._frames = null; + this._frameData = null; + this.currentFrame = null; + this.isPlaying = false; + }; + Animation.prototype.onComplete = function () { + this.isPlaying = false; + this.isFinished = true; + }; + return Animation; + })(); + Phaser.Animation = Animation; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var AnimationLoader = (function () { + function AnimationLoader() { } + AnimationLoader.parseSpriteSheet = function parseSpriteSheet(game, key, frameWidth, frameHeight, frameMax) { + var img = game.cache.getImage(key); + if(img == null) { + return null; + } + var width = img.width; + var height = img.height; + var row = Math.round(width / frameWidth); + var column = Math.round(height / frameHeight); + var total = row * column; + if(frameMax !== -1) { + total = frameMax; + } + if(width == 0 || height == 0 || width < frameWidth || height < frameHeight || total === 0) { + return null; + } + var data = new Phaser.FrameData(); + var x = 0; + var y = 0; + for(var i = 0; i < total; i++) { + data.addFrame(new Phaser.Frame(x, y, frameWidth, frameHeight, '')); + x += frameWidth; + if(x === width) { + x = 0; + y += frameHeight; + } + } + return data; + }; + AnimationLoader.parseJSONData = function parseJSONData(game, json) { + var data = new Phaser.FrameData(); + var frames = json; + var newFrame; + for(var i = 0; i < frames.length; i++) { + newFrame = data.addFrame(new Phaser.Frame(frames[i].frame.x, frames[i].frame.y, frames[i].frame.w, frames[i].frame.h, frames[i].filename)); + newFrame.setTrim(frames[i].trimmed, frames[i].sourceSize.w, frames[i].sourceSize.h, frames[i].spriteSourceSize.x, frames[i].spriteSourceSize.y, frames[i].spriteSourceSize.w, frames[i].spriteSourceSize.h); + } + return data; + }; + return AnimationLoader; + })(); + Phaser.AnimationLoader = AnimationLoader; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Frame = (function () { + function Frame(x, y, width, height, name) { + this.name = ''; + this.rotated = false; + this.rotationDirection = 'cw'; this.x = x; this.y = y; this.width = width; this.height = height; - return this; + this.name = name; + this.rotated = false; + this.trimmed = false; + } + Frame.prototype.setRotation = function (rotated, rotationDirection) { }; - Object.defineProperty(Quad.prototype, "left", { - get: function () { - return this.x; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Quad.prototype, "right", { - get: function () { - return this.x + this.width; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Quad.prototype, "top", { - get: function () { - return this.y; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Quad.prototype, "bottom", { - get: function () { - return this.y + this.height; - }, - enumerable: true, - configurable: true - }); - Quad.prototype.intersects = /** - * Determines whether the object specified intersects (overlaps) with this Quad object. - * This method checks the x, y, width, and height properties of the specified Quad object to see if it intersects with this Quad object. - * @method intersects - * @param {Quad} q The Quad to compare against to see if it intersects with this Quad. - * @param {Number} t A tolerance value to allow for an intersection test with padding, default to 0 - * @return {Boolean} A value of true if the specified object intersects with this Quad; otherwise false. - **/ - function (q, t) { - if (typeof t === "undefined") { t = 0; } - return !(q.left > this.right + t || q.right < this.left - t || q.top > this.bottom + t || q.bottom < this.top - t); + Frame.prototype.setTrim = function (trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight) { + this.trimmed = trimmed; + this.sourceSizeW = actualWidth; + this.sourceSizeH = actualHeight; + this.spriteSourceSizeX = destX; + this.spriteSourceSizeY = destY; + this.spriteSourceSizeW = destWidth; + this.spriteSourceSizeH = destHeight; }; - Quad.prototype.toString = /** - * Returns a string representation of this object. - * @method toString - * @return {string} a string representation of the object. - **/ - function () { - return "[{Quad (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + ")}]"; - }; - return Quad; + return Frame; })(); - Phaser.Quad = Quad; + Phaser.Frame = Frame; })(Phaser || (Phaser = {})); -/// -/// -/** -* Phaser - ScrollRegion -* -* Creates a scrolling region within a ScrollZone. -* It is scrolled via the scrollSpeed.x/y properties. -*/ var Phaser; (function (Phaser) { - var ScrollRegion = (function () { - function ScrollRegion(x, y, width, height, speedX, speedY) { - this._anchorWidth = 0; - this._anchorHeight = 0; - this._inverseWidth = 0; - this._inverseHeight = 0; - this.visible = true; - // Our seamless scrolling quads - this._A = new Phaser.Quad(x, y, width, height); - this._B = new Phaser.Quad(x, y, width, height); - this._C = new Phaser.Quad(x, y, width, height); - this._D = new Phaser.Quad(x, y, width, height); - this._scroll = new Phaser.MicroPoint(); - this._bounds = new Phaser.Quad(x, y, width, height); - this.scrollSpeed = new Phaser.MicroPoint(speedX, speedY); + var FrameData = (function () { + function FrameData() { + this._frames = []; + this._frameNames = []; } - ScrollRegion.prototype.update = function (delta) { - this._scroll.x += this.scrollSpeed.x; - this._scroll.y += this.scrollSpeed.y; - if(this._scroll.x > this._bounds.right) { - this._scroll.x = this._bounds.x; + Object.defineProperty(FrameData.prototype, "total", { + get: function () { + return this._frames.length; + }, + enumerable: true, + configurable: true + }); + FrameData.prototype.addFrame = function (frame) { + frame.index = this._frames.length; + this._frames.push(frame); + if(frame.name !== '') { + this._frameNames[frame.name] = frame.index; } - if(this._scroll.x < this._bounds.x) { - this._scroll.x = this._bounds.right; - } - if(this._scroll.y > this._bounds.bottom) { - this._scroll.y = this._bounds.y; - } - if(this._scroll.y < this._bounds.y) { - this._scroll.y = this._bounds.bottom; - } - // Anchor Dimensions - this._anchorWidth = (this._bounds.width - this._scroll.x) + this._bounds.x; - this._anchorHeight = (this._bounds.height - this._scroll.y) + this._bounds.y; - if(this._anchorWidth > this._bounds.width) { - this._anchorWidth = this._bounds.width; - } - if(this._anchorHeight > this._bounds.height) { - this._anchorHeight = this._bounds.height; - } - this._inverseWidth = this._bounds.width - this._anchorWidth; - this._inverseHeight = this._bounds.height - this._anchorHeight; - // Quad A - this._A.setTo(this._scroll.x, this._scroll.y, this._anchorWidth, this._anchorHeight); - // Quad B - this._B.y = this._scroll.y; - this._B.width = this._inverseWidth; - this._B.height = this._anchorHeight; - // Quad C - this._C.x = this._scroll.x; - this._C.width = this._anchorWidth; - this._C.height = this._inverseHeight; - // Quad D - this._D.width = this._inverseWidth; - this._D.height = this._inverseHeight; + return frame; }; - ScrollRegion.prototype.render = function (context, texture, dx, dy, dw, dh) { - if(this.visible == false) { - return; - } - // dx/dy are the world coordinates to render the FULL ScrollZone into. - // This ScrollRegion may be smaller than that and offset from the dx/dy coordinates. - this.crop(context, texture, this._A.x, this._A.y, this._A.width, this._A.height, dx, dy, dw, dh, 0, 0); - this.crop(context, texture, this._B.x, this._B.y, this._B.width, this._B.height, dx, dy, dw, dh, this._A.width, 0); - this.crop(context, texture, this._C.x, this._C.y, this._C.width, this._C.height, dx, dy, dw, dh, 0, this._A.height); - this.crop(context, texture, this._D.x, this._D.y, this._D.width, this._D.height, dx, dy, dw, dh, this._C.width, this._A.height); - //context.fillStyle = 'rgb(255,255,255)'; - //context.font = '18px Arial'; - //context.fillText('QuadA: ' + this._A.toString(), 32, 450); - //context.fillText('QuadB: ' + this._B.toString(), 32, 480); - //context.fillText('QuadC: ' + this._C.toString(), 32, 510); - //context.fillText('QuadD: ' + this._D.toString(), 32, 540); - }; - ScrollRegion.prototype.crop = function (context, texture, srcX, srcY, srcW, srcH, destX, destY, destW, destH, offsetX, offsetY) { - offsetX += destX; - offsetY += destY; - if(srcW > (destX + destW) - offsetX) { - srcW = (destX + destW) - offsetX; - } - if(srcH > (destY + destH) - offsetY) { - srcH = (destY + destH) - offsetY; - } - srcX = Math.floor(srcX); - srcY = Math.floor(srcY); - srcW = Math.floor(srcW); - srcH = Math.floor(srcH); - offsetX = Math.floor(offsetX + this._bounds.x); - offsetY = Math.floor(offsetY + this._bounds.y); - if(srcW > 0 && srcH > 0) { - context.drawImage(texture, srcX, srcY, srcW, srcH, offsetX, offsetY, srcW, srcH); + FrameData.prototype.getFrame = function (index) { + if(this._frames[index]) { + return this._frames[index]; } + return null; }; - return ScrollRegion; + FrameData.prototype.getFrameByName = function (name) { + if(this._frameNames[name] >= 0) { + return this._frames[this._frameNames[name]]; + } + return null; + }; + FrameData.prototype.checkFrameName = function (name) { + if(this._frameNames[name] >= 0) { + return true; + } + return false; + }; + FrameData.prototype.getFrameRange = function (start, end, output) { + if (typeof output === "undefined") { output = []; } + for(var i = start; i <= end; i++) { + output.push(this._frames[i]); + } + return output; + }; + FrameData.prototype.getFrameIndexes = function (output) { + if (typeof output === "undefined") { output = []; } + output.length = 0; + for(var i = 0; i < this._frames.length; i++) { + output.push(i); + } + return output; + }; + FrameData.prototype.getFrameIndexesByName = function (input) { + var output = []; + for(var i = 0; i < input.length; i++) { + if(this.getFrameByName(input[i])) { + output.push(this.getFrameByName(input[i]).index); + } + } + return output; + }; + FrameData.prototype.getAllFrames = function () { + return this._frames; + }; + FrameData.prototype.getFrames = function (range) { + var output = []; + for(var i = 0; i < range.length; i++) { + output.push(this._frames[i]); + } + return output; + }; + return FrameData; })(); - Phaser.ScrollRegion = ScrollRegion; + Phaser.FrameData = FrameData; })(Phaser || (Phaser = {})); -/// -/// -/// -/** -* Phaser - ScrollZone -* -* Creates a scrolling region of the given width and height from an image in the cache. -* The ScrollZone can be positioned anywhere in-world like a normal game object, re-act to physics, collision, etc. -* The image within it is scrolled via ScrollRegions and their scrollSpeed.x/y properties. -* If you create a scroll zone larger than the given source image it will create a DynamicTexture and fill it with a pattern of the source image. -*/ var Phaser; (function (Phaser) { - var ScrollZone = (function (_super) { - __extends(ScrollZone, _super); - function ScrollZone(game, key, x, y, width, height) { - if (typeof x === "undefined") { x = 0; } - if (typeof y === "undefined") { y = 0; } - if (typeof width === "undefined") { width = 0; } - if (typeof height === "undefined") { height = 0; } - _super.call(this, game, x, y, width, height); - this._dynamicTexture = null; - // local rendering related temp vars to help avoid gc spikes - this._dx = 0; - this._dy = 0; - this._dw = 0; - this._dh = 0; - this.flipped = false; - this.regions = []; - if(this._game.cache.getImage(key)) { - this._texture = this._game.cache.getImage(key); - this.width = this._texture.width; - this.height = this._texture.height; - if(width > this._texture.width || height > this._texture.height) { - // Create our repeating texture (as the source image wasn't large enough for the requested size) - this.createRepeatingTexture(width, height); - this.width = width; - this.height = height; - } - // Create a default ScrollRegion at the requested size - this.addRegion(0, 0, this.width, this.height); - // If the zone is smaller than the image itself then shrink the bounds - if((width < this._texture.width || height < this._texture.height) && width !== 0 && height !== 0) { - this.width = width; - this.height = height; - } - } + var AnimationManager = (function () { + function AnimationManager(game, parent) { + this._frameData = null; + this.currentFrame = null; + this._game = game; + this._parent = parent; + this._anims = { + }; } - ScrollZone.prototype.addRegion = function (x, y, width, height, speedX, speedY) { - if (typeof speedX === "undefined") { speedX = 0; } - if (typeof speedY === "undefined") { speedY = 0; } - if(x > this.width || y > this.height || x < 0 || y < 0 || (x + width) > this.width || (y + height) > this.height) { - throw Error('Invalid ScrollRegion defined. Cannot be larger than parent ScrollZone'); + AnimationManager.prototype.loadFrameData = function (frameData) { + this._frameData = frameData; + this.frame = 0; + }; + AnimationManager.prototype.add = function (name, frames, frameRate, loop, useNumericIndex) { + if (typeof frames === "undefined") { frames = null; } + if (typeof frameRate === "undefined") { frameRate = 60; } + if (typeof loop === "undefined") { loop = false; } + if (typeof useNumericIndex === "undefined") { useNumericIndex = true; } + if(this._frameData == null) { return; } - this.currentRegion = new Phaser.ScrollRegion(x, y, width, height, speedX, speedY); - this.regions.push(this.currentRegion); - return this.currentRegion; - }; - ScrollZone.prototype.setSpeed = function (x, y) { - if(this.currentRegion) { - this.currentRegion.scrollSpeed.setTo(x, y); - } - return this; - }; - ScrollZone.prototype.update = function () { - for(var i = 0; i < this.regions.length; i++) { - this.regions[i].update(this._game.time.delta); - } - }; - ScrollZone.prototype.inCamera = function (camera) { - if(this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0) { - this._dx = this.bounds.x - (camera.x * this.scrollFactor.x); - this._dy = this.bounds.y - (camera.y * this.scrollFactor.x); - this._dw = this.bounds.width * this.scale.x; - this._dh = this.bounds.height * this.scale.y; - return (camera.right > this._dx) && (camera.x < this._dx + this._dw) && (camera.bottom > this._dy) && (camera.y < this._dy + this._dh); + if(frames == null) { + frames = this._frameData.getFrameIndexes(); } else { - return camera.intersects(this.bounds, this.bounds.length); + if(this.validateFrames(frames, useNumericIndex) == false) { + throw Error('Invalid frames given to Animation ' + name); + return; + } } + if(useNumericIndex == false) { + frames = this._frameData.getFrameIndexesByName(frames); + } + this._anims[name] = new Phaser.Animation(this._game, this._parent, this._frameData, name, frames, frameRate, loop); + this.currentAnim = this._anims[name]; + this.currentFrame = this.currentAnim.currentFrame; }; - ScrollZone.prototype.render = function (camera, cameraOffsetX, cameraOffsetY) { - // Render checks - if(this.visible == false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1 || this.cameraBlacklist.indexOf(camera.ID) !== -1 || this.inCamera(camera.worldView) == false) { - return false; - } - // Alpha - if(this.alpha !== 1) { - var globalAlpha = this._game.stage.context.globalAlpha; - this._game.stage.context.globalAlpha = this.alpha; - } - this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x); - this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y); - this._dw = this.bounds.width * this.scale.x; - this._dh = this.bounds.height * this.scale.y; - // Apply camera difference - if(this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0) { - this._dx -= (camera.worldView.x * this.scrollFactor.x); - this._dy -= (camera.worldView.y * this.scrollFactor.y); - } - // Rotation - needs to work from origin point really, but for now from center - if(this.angle !== 0 || this.flipped == true) { - this._game.stage.context.save(); - this._game.stage.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2)); - if(this.angle !== 0) { - this._game.stage.context.rotate(this.angle * (Math.PI / 180)); - } - this._dx = -(this._dw / 2); - this._dy = -(this._dh / 2); - if(this.flipped == true) { - this._game.stage.context.scale(-1, 1); - } - } - this._dx = Math.round(this._dx); - this._dy = Math.round(this._dy); - this._dw = Math.round(this._dw); - this._dh = Math.round(this._dh); - for(var i = 0; i < this.regions.length; i++) { - if(this._dynamicTexture) { - this.regions[i].render(this._game.stage.context, this._dynamicTexture.canvas, this._dx, this._dy, this._dw, this._dh); + AnimationManager.prototype.validateFrames = function (frames, useNumericIndex) { + for(var i = 0; i < frames.length; i++) { + if(useNumericIndex == true) { + if(frames[i] > this._frameData.total) { + return false; + } } else { - this.regions[i].render(this._game.stage.context, this._texture, this._dx, this._dy, this._dw, this._dh); + if(this._frameData.checkFrameName(frames[i]) == false) { + return false; + } } } - if(globalAlpha > -1) { - this._game.stage.context.globalAlpha = globalAlpha; - } return true; }; - ScrollZone.prototype.createRepeatingTexture = function (regionWidth, regionHeight) { - // Work out how many we'll need of the source image to make it tile properly - var tileWidth = Math.ceil(this._texture.width / regionWidth) * regionWidth; - var tileHeight = Math.ceil(this._texture.height / regionHeight) * regionHeight; - this._dynamicTexture = new Phaser.DynamicTexture(this._game, tileWidth, tileHeight); - this._dynamicTexture.context.rect(0, 0, tileWidth, tileHeight); - this._dynamicTexture.context.fillStyle = this._dynamicTexture.context.createPattern(this._texture, "repeat"); - this._dynamicTexture.context.fill(); + AnimationManager.prototype.play = function (name, frameRate, loop) { + if (typeof frameRate === "undefined") { frameRate = null; } + if(this._anims[name]) { + if(this.currentAnim == this._anims[name]) { + if(this.currentAnim.isPlaying == false) { + this.currentAnim.play(frameRate, loop); + } + } else { + this.currentAnim = this._anims[name]; + this.currentAnim.play(frameRate, loop); + } + } }; - return ScrollZone; - })(Phaser.GameObject); - Phaser.ScrollZone = ScrollZone; -})(Phaser || (Phaser = {})); -/// -/** -* Phaser - Tile -* -* A simple helper object for Tilemap that helps expand collision opportunities and control. -*/ -var Phaser; -(function (Phaser) { - var Tile = (function (_super) { - __extends(Tile, _super); - /** - * Instantiate this new tile object. This is usually called from Tilemap.loadMap(). - * - * @param Tilemap A reference to the tilemap object creating the tile. - * @param Index The actual core map data index for this tile type. - * @param Width The width of the tile. - * @param Height The height of the tile. - * @param Visible Whether the tile is visible or not. - * @param AllowCollisions The collision flags for the object. By default this value is ANY or NONE depending on the parameters sent to loadMap(). - */ - function Tile(game, Tilemap, Index, Width, Height, Visible, AllowCollisions) { - _super.call(this, game, 0, 0, Width, Height); - this.immovable = true; - this.moves = false; - this.callback = null; - this.filter = null; - this.tilemap = Tilemap; - this.index = Index; - this.visible = Visible; - this.allowCollisions = AllowCollisions; - this.mapIndex = 0; - } - Tile.prototype.destroy = /** - * Clean up memory. - */ - function () { - _super.prototype.destroy.call(this); - this.callback = null; - this.tilemap = null; + AnimationManager.prototype.stop = function (name) { + if(this._anims[name]) { + this.currentAnim = this._anims[name]; + this.currentAnim.stop(); + } }; - return Tile; - })(Phaser.GameObject); - Phaser.Tile = Tile; + AnimationManager.prototype.update = function () { + if(this.currentAnim && this.currentAnim.update() == true) { + this.currentFrame = this.currentAnim.currentFrame; + this._parent.bounds.width = this.currentFrame.width; + this._parent.bounds.height = this.currentFrame.height; + } + }; + Object.defineProperty(AnimationManager.prototype, "frameData", { + get: function () { + return this._frameData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationManager.prototype, "frameTotal", { + get: function () { + return this._frameData.total; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationManager.prototype, "frame", { + get: function () { + return this._frameIndex; + }, + set: function (value) { + if(this._frameData.getFrame(value) !== null) { + this.currentFrame = this._frameData.getFrame(value); + this._parent.bounds.width = this.currentFrame.width; + this._parent.bounds.height = this.currentFrame.height; + this._frameIndex = value; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationManager.prototype, "frameName", { + get: function () { + return this.currentFrame.name; + }, + set: function (value) { + if(this._frameData.getFrameByName(value) !== null) { + this.currentFrame = this._frameData.getFrameByName(value); + this._parent.bounds.width = this.currentFrame.width; + this._parent.bounds.height = this.currentFrame.height; + this._frameIndex = this.currentFrame.index; + } + }, + enumerable: true, + configurable: true + }); + return AnimationManager; + })(); + Phaser.AnimationManager = AnimationManager; })(Phaser || (Phaser = {})); -/// -/** -* Phaser - State -* -* This is a base State class which can be extended if you are creating your game using TypeScript. -*/ var Phaser; (function (Phaser) { var State = (function () { @@ -11985,8 +8358,7 @@ var Phaser; this.tweens = game.tweens; this.world = game.world; } - State.prototype.init = // Overload these in your own States - function () { + State.prototype.init = function () { }; State.prototype.create = function () { }; @@ -11996,8 +8368,7 @@ var Phaser; }; State.prototype.paused = function () { }; - State.prototype.createCamera = // Handy Proxy methods - function (x, y, width, height) { + State.prototype.createCamera = function (x, y, width, height) { return this.game.world.createCamera(x, y, width, height); }; State.prototype.createGeomSprite = function (x, y) { diff --git a/Tests/tilemap/collision.js b/Tests/tilemap/collision.js new file mode 100644 index 00000000..f01a3058 --- /dev/null +++ b/Tests/tilemap/collision.js @@ -0,0 +1,90 @@ +/// +/// +(function () { + var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update); + function init() { + myGame.loader.addTextFile('platform', 'assets/maps/platform-test-1.json'); + myGame.loader.addImageFile('tiles', 'assets/tiles/platformer_tiles.png'); + myGame.loader.addImageFile('ufo', 'assets/sprites/ufo.png'); + myGame.loader.addImageFile('ilkke', 'assets/sprites/ilkke.png'); + myGame.loader.addImageFile('chunk', 'assets/sprites/chunk.png'); + myGame.loader.addImageFile('healthbar', 'assets/sprites/healthbar.png'); + myGame.loader.load(); + } + var map; + var car; + var marker; + var tile; + var emitter; + var mo; + function create() { + map = myGame.createTilemap('tiles', 'platform', Phaser.Tilemap.FORMAT_TILED_JSON); + map.setCollisionRange(21, 53); + map.setCollisionRange(105, 109); + myGame.camera.backgroundColor = 'rgb(47,154,204)'; + myGame.input.keyboard.addKeyCapture([ + Phaser.Keyboard.LEFT, + Phaser.Keyboard.RIGHT, + Phaser.Keyboard.UP, + Phaser.Keyboard.DOWN + ]); + emitter = myGame.createEmitter(32, 32); + emitter.width = 700; + emitter.makeParticles(null, 50, 0, false, 0); + emitter.gravity = 100; + emitter.setRotation(0, 0); + emitter.start(false); + car = myGame.createSprite(250, 64, 'ufo'); + car.renderRotation = false; + //car.renderDebug = true; + car.setBounds(0, 0, map.widthInPixels - 32, map.heightInPixels - 32); + //car.velocity.y = 10; + marker = myGame.createGeomSprite(0, 0); + marker.createRectangle(16, 16); + marker.renderFill = false; + marker.visible = false; + //myGame.onRenderCallback = render; + } + function update() { + marker.x = myGame.math.snapToFloor(myGame.input.worldX, 16); + marker.y = myGame.math.snapToFloor(myGame.input.worldY, 16); + //myGame.collide(car, map.currentLayer); + car.velocity.x = 0; + car.velocity.y = 0; + if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) { + car.velocity.x = -200; + } else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) { + car.velocity.x = 200; + } + if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) { + car.velocity.y = -200; + } else if(myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN)) { + car.velocity.y = 200; + } + mo = map.collide(car); + //map.getTileOverlaps() + } + function render() { + tile = map.getTileFromInputXY(); + //var b = map.getTileOverlaps(car); + myGame.stage.context.font = '18px Arial'; + myGame.stage.context.fillStyle = 'rgb(255,255,255)'; + //myGame.stage.context.fillText(tile.toString(), 32, 32); + myGame.input.renderDebugInfo(32, 64, 'rgb(255,255,255)'); + myGame.stage.context.fillStyle = 'rgb(255,255,255)'; + myGame.stage.context.fillText(mo.x + ' ' + mo.y + ' ' + mo.w + ' ' + mo.h, 32, 200); + myGame.stage.context.fillText(car.bounds.x + ' ' + car.bounds.y + ' ' + car.bounds.width + ' ' + car.bounds.height, 32, 232); + var i = 0; + for(var y = mo.y; y < mo.y + mo.h; y++) { + for(var x = mo.x; x < mo.x + mo.w; x++) { + if(mo.collision[i] == true) { + myGame.stage.context.fillStyle = 'rgba(255,0,0,0.5)'; + } else { + myGame.stage.context.fillStyle = 'rgba(0,255,0,0.5)'; + } + myGame.stage.context.fillRect(x * 16, y * 16, 16, 16); + i++; + } + } + } +})(); diff --git a/Tests/tilemap/collision.ts b/Tests/tilemap/collision.ts new file mode 100644 index 00000000..8a3c341f --- /dev/null +++ b/Tests/tilemap/collision.ts @@ -0,0 +1,134 @@ +/// +/// + +(function () { + + var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update); + + function init() { + + myGame.loader.addTextFile('platform', 'assets/maps/platform-test-1.json'); + myGame.loader.addImageFile('tiles', 'assets/tiles/platformer_tiles.png'); + myGame.loader.addImageFile('ufo', 'assets/sprites/ufo.png'); + myGame.loader.addImageFile('ilkke', 'assets/sprites/ilkke.png'); + myGame.loader.addImageFile('chunk', 'assets/sprites/chunk.png'); + myGame.loader.addImageFile('healthbar', 'assets/sprites/healthbar.png'); + + myGame.loader.load(); + + } + + var map: Phaser.Tilemap; + var car: Phaser.Sprite; + var marker: Phaser.GeomSprite; + var tile: Phaser.Tile; + var emitter: Phaser.Emitter; + + var mo; + + function create() { + + map = myGame.createTilemap('tiles', 'platform', Phaser.Tilemap.FORMAT_TILED_JSON); + map.setCollisionRange(21,53); + map.setCollisionRange(105,109); + + myGame.camera.backgroundColor = 'rgb(47,154,204)'; + + myGame.input.keyboard.addKeyCapture([Phaser.Keyboard.LEFT, Phaser.Keyboard.RIGHT, Phaser.Keyboard.UP, Phaser.Keyboard.DOWN]); + + emitter = myGame.createEmitter(32, 32); + emitter.width = 700; + emitter.makeParticles(null, 50, 0, false, 0); + emitter.gravity = 100; + emitter.setRotation(0,0); + emitter.start(false); + + car = myGame.createSprite(250, 64, 'ufo'); + car.renderRotation = false; + //car.renderDebug = true; + + car.setBounds(0, 0, map.widthInPixels - 32, map.heightInPixels - 32); + //car.velocity.y = 10; + + marker = myGame.createGeomSprite(0, 0); + marker.createRectangle(16, 16); + marker.renderFill = false; + marker.visible = false; + + //myGame.onRenderCallback = render; + + } + + function update() { + + marker.x = myGame.math.snapToFloor(myGame.input.worldX, 16); + marker.y = myGame.math.snapToFloor(myGame.input.worldY, 16); + + //myGame.collide(car, map.currentLayer); + + + + car.velocity.x = 0; + car.velocity.y = 0; + + if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) + { + car.velocity.x = -200; + } + else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) + { + car.velocity.x = 200; + } + + if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) + { + car.velocity.y = -200; + } + else if (myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN)) + { + car.velocity.y = 200; + } + + mo = map.collide(car); + //map.getTileOverlaps() + + } + + function render() { + + tile = map.getTileFromInputXY(); + + //var b = map.getTileOverlaps(car); + + myGame.stage.context.font = '18px Arial'; + myGame.stage.context.fillStyle = 'rgb(255,255,255)'; + //myGame.stage.context.fillText(tile.toString(), 32, 32); + myGame.input.renderDebugInfo(32, 64, 'rgb(255,255,255)'); + myGame.stage.context.fillStyle = 'rgb(255,255,255)'; + myGame.stage.context.fillText(mo.x + ' ' + mo.y + ' ' + mo.w + ' ' + mo.h, 32, 200); + myGame.stage.context.fillText(car.bounds.x + ' ' + car.bounds.y + ' ' + car.bounds.width + ' ' + car.bounds.height, 32, 232); + + + var i = 0; + + for (var y = mo.y; y < mo.y + mo.h; y++) + { + for (var x = mo.x; x < mo.x + mo.w; x++) + { + if (mo.collision[i] == true) + { + myGame.stage.context.fillStyle = 'rgba(255,0,0,0.5)'; + } + else + { + myGame.stage.context.fillStyle = 'rgba(0,255,0,0.5)'; + } + + myGame.stage.context.fillRect(x * 16, y * 16, 16, 16); + i++; + } + } + + } + +})(); diff --git a/Tests/tilemap/get tile.js b/Tests/tilemap/get tile.js new file mode 100644 index 00000000..ff0a3c65 --- /dev/null +++ b/Tests/tilemap/get tile.js @@ -0,0 +1,49 @@ +/// +/// +/// +(function () { + var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update); + function init() { + myGame.loader.addTextFile('desert', 'assets/maps/desert.json'); + myGame.loader.addImageFile('tiles', 'assets/tiles/tmw_desert_spacing.png'); + myGame.loader.addImageFile('car', 'assets/sprites/car90.png'); + myGame.loader.load(); + } + var map; + var car; + var marker; + var tile; + function create() { + map = myGame.createTilemap('tiles', 'desert', Phaser.Tilemap.FORMAT_TILED_JSON); + car = myGame.createSprite(250, 200, 'car'); + car.setBounds(0, 0, map.widthInPixels - 32, map.heightInPixels - 32); + marker = myGame.createGeomSprite(0, 0); + marker.createRectangle(32, 32); + marker.renderFill = false; + marker.lineColor = 'rgb(0,0,0)'; + myGame.camera.follow(car); + myGame.onRenderCallback = render; + } + function update() { + marker.x = myGame.math.snapToFloor(myGame.input.worldX, 32); + marker.y = myGame.math.snapToFloor(myGame.input.worldY, 32); + car.velocity.x = 0; + car.velocity.y = 0; + car.angularVelocity = 0; + if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) { + car.angularVelocity = -200; + } else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) { + car.angularVelocity = 200; + } + if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) { + car.velocity.copyFrom(myGame.motion.velocityFromAngle(car.angle, 300)); + } + } + function render() { + tile = map.getTileFromInputXY(); + myGame.stage.context.font = '18px Arial'; + myGame.stage.context.fillStyle = 'rgb(0,0,0)'; + myGame.stage.context.fillText(tile.toString(), 32, 32); + myGame.input.renderDebugInfo(32, 64, 'rgb(0,0,0)'); + } +})(); diff --git a/Tests/tilemap/get tile.ts b/Tests/tilemap/get tile.ts new file mode 100644 index 00000000..462118cc --- /dev/null +++ b/Tests/tilemap/get tile.ts @@ -0,0 +1,78 @@ +/// +/// +/// + +(function () { + + var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update); + + function init() { + + myGame.loader.addTextFile('desert', 'assets/maps/desert.json'); + myGame.loader.addImageFile('tiles', 'assets/tiles/tmw_desert_spacing.png'); + myGame.loader.addImageFile('car', 'assets/sprites/car90.png'); + + myGame.loader.load(); + + } + + var map: Phaser.Tilemap; + var car: Phaser.Sprite; + var marker: Phaser.GeomSprite; + var tile: Phaser.Tile; + + function create() { + + map = myGame.createTilemap('tiles', 'desert', Phaser.Tilemap.FORMAT_TILED_JSON); + + car = myGame.createSprite(250, 200, 'car'); + car.setBounds(0, 0, map.widthInPixels - 32, map.heightInPixels - 32); + + marker = myGame.createGeomSprite(0, 0); + marker.createRectangle(32, 32); + marker.renderFill = false; + marker.lineColor = 'rgb(0,0,0)'; + + myGame.camera.follow(car); + myGame.onRenderCallback = render; + + } + + function update() { + + marker.x = myGame.math.snapToFloor(myGame.input.worldX, 32); + marker.y = myGame.math.snapToFloor(myGame.input.worldY, 32); + + car.velocity.x = 0; + car.velocity.y = 0; + car.angularVelocity = 0; + + if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) + { + car.angularVelocity = -200; + } + else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) + { + car.angularVelocity = 200; + } + + if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) + { + car.velocity.copyFrom(myGame.motion.velocityFromAngle(car.angle, 300)); + } + + } + + function render { + + tile = map.getTileFromInputXY(); + + myGame.stage.context.font = '18px Arial'; + myGame.stage.context.fillStyle = 'rgb(0,0,0)'; + myGame.stage.context.fillText(tile.toString(), 32, 32); + + myGame.input.renderDebugInfo(32, 64, 'rgb(0,0,0)'); + + } + +})(); diff --git a/build/phaser.js b/build/phaser.js new file mode 100644 index 00000000..f5cd76bc --- /dev/null +++ b/build/phaser.js @@ -0,0 +1,8422 @@ +var Phaser; +(function (Phaser) { + var Basic = (function () { + function Basic(game) { + this.name = ''; + this._game = game; + this.ID = -1; + this.exists = true; + this.active = true; + this.visible = true; + this.alive = true; + this.isGroup = false; + this.ignoreDrawDebug = false; + } + Basic.prototype.destroy = function () { + }; + Basic.prototype.preUpdate = function () { + }; + Basic.prototype.update = function () { + }; + Basic.prototype.postUpdate = function () { + }; + Basic.prototype.render = function (camera, cameraOffsetX, cameraOffsetY) { + }; + Basic.prototype.kill = function () { + this.alive = false; + this.exists = false; + }; + Basic.prototype.revive = function () { + this.alive = true; + this.exists = true; + }; + Basic.prototype.toString = function () { + return ""; + }; + return Basic; + })(); + Phaser.Basic = Basic; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Cache = (function () { + function Cache(game) { + this._game = game; + this._canvases = { + }; + this._images = { + }; + this._sounds = { + }; + this._text = { + }; + } + Cache.prototype.addCanvas = function (key, canvas, context) { + this._canvases[key] = { + canvas: canvas, + context: context + }; + }; + Cache.prototype.addSpriteSheet = function (key, url, data, frameWidth, frameHeight, frameMax) { + this._images[key] = { + url: url, + data: data, + spriteSheet: true, + frameWidth: frameWidth, + frameHeight: frameHeight + }; + this._images[key].frameData = Phaser.AnimationLoader.parseSpriteSheet(this._game, key, frameWidth, frameHeight, frameMax); + }; + Cache.prototype.addTextureAtlas = function (key, url, data, jsonData) { + this._images[key] = { + url: url, + data: data, + spriteSheet: true + }; + this._images[key].frameData = Phaser.AnimationLoader.parseJSONData(this._game, jsonData); + }; + Cache.prototype.addImage = function (key, url, data) { + this._images[key] = { + url: url, + data: data, + spriteSheet: false + }; + }; + Cache.prototype.addSound = function (key, url, data) { + this._sounds[key] = { + url: url, + data: data, + decoded: false + }; + }; + Cache.prototype.decodedSound = function (key, data) { + this._sounds[key].data = data; + this._sounds[key].decoded = true; + }; + Cache.prototype.addText = function (key, url, data) { + this._text[key] = { + url: url, + data: data + }; + }; + Cache.prototype.getCanvas = function (key) { + if(this._canvases[key]) { + return this._canvases[key].canvas; + } + return null; + }; + Cache.prototype.getImage = function (key) { + if(this._images[key]) { + return this._images[key].data; + } + return null; + }; + Cache.prototype.getFrameData = function (key) { + if(this._images[key] && this._images[key].spriteSheet == true) { + return this._images[key].frameData; + } + return null; + }; + Cache.prototype.getSound = function (key) { + if(this._sounds[key]) { + return this._sounds[key].data; + } + return null; + }; + Cache.prototype.isSoundDecoded = function (key) { + if(this._sounds[key]) { + return this._sounds[key].decoded; + } + }; + Cache.prototype.isSpriteSheet = function (key) { + if(this._images[key]) { + return this._images[key].spriteSheet; + } + }; + Cache.prototype.getText = function (key) { + if(this._text[key]) { + return this._text[key].data; + } + return null; + }; + Cache.prototype.destroy = function () { + for(var item in this._canvases) { + delete this._canvases[item['key']]; + } + for(var item in this._images) { + delete this._images[item['key']]; + } + for(var item in this._sounds) { + delete this._sounds[item['key']]; + } + for(var item in this._text) { + delete this._text[item['key']]; + } + }; + return Cache; + })(); + Phaser.Cache = Cache; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var SignalBinding = (function () { + function SignalBinding(signal, listener, isOnce, listenerContext, priority) { + if (typeof priority === "undefined") { priority = 0; } + this.active = true; + this.params = null; + this._listener = listener; + this._isOnce = isOnce; + this.context = listenerContext; + this._signal = signal; + this.priority = priority || 0; + } + SignalBinding.prototype.execute = function (paramsArr) { + var handlerReturn; + var params; + if(this.active && !!this._listener) { + params = this.params ? this.params.concat(paramsArr) : paramsArr; + handlerReturn = this._listener.apply(this.context, params); + if(this._isOnce) { + this.detach(); + } + } + return handlerReturn; + }; + SignalBinding.prototype.detach = function () { + return this.isBound() ? this._signal.remove(this._listener, this.context) : null; + }; + SignalBinding.prototype.isBound = function () { + return (!!this._signal && !!this._listener); + }; + SignalBinding.prototype.isOnce = function () { + return this._isOnce; + }; + SignalBinding.prototype.getListener = function () { + return this._listener; + }; + SignalBinding.prototype.getSignal = function () { + return this._signal; + }; + SignalBinding.prototype._destroy = function () { + delete this._signal; + delete this._listener; + delete this.context; + }; + SignalBinding.prototype.toString = function () { + return '[SignalBinding isOnce:' + this._isOnce + ', isBound:' + this.isBound() + ', active:' + this.active + ']'; + }; + return SignalBinding; + })(); + Phaser.SignalBinding = SignalBinding; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Signal = (function () { + function Signal() { + this._bindings = []; + this._prevParams = null; + this.memorize = false; + this._shouldPropagate = true; + this.active = true; + } + Signal.VERSION = '1.0.0'; + Signal.prototype.validateListener = function (listener, fnName) { + if(typeof listener !== 'function') { + throw new Error('listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName)); + } + }; + Signal.prototype._registerListener = function (listener, isOnce, listenerContext, priority) { + var prevIndex = this._indexOfListener(listener, listenerContext); + var binding; + if(prevIndex !== -1) { + binding = this._bindings[prevIndex]; + if(binding.isOnce() !== isOnce) { + throw new Error('You cannot add' + (isOnce ? '' : 'Once') + '() then add' + (!isOnce ? '' : 'Once') + '() the same listener without removing the relationship first.'); + } + } else { + binding = new Phaser.SignalBinding(this, listener, isOnce, listenerContext, priority); + this._addBinding(binding); + } + if(this.memorize && this._prevParams) { + binding.execute(this._prevParams); + } + return binding; + }; + Signal.prototype._addBinding = function (binding) { + var n = this._bindings.length; + do { + --n; + }while(this._bindings[n] && binding.priority <= this._bindings[n].priority); + this._bindings.splice(n + 1, 0, binding); + }; + Signal.prototype._indexOfListener = function (listener, context) { + var n = this._bindings.length; + var cur; + while(n--) { + cur = this._bindings[n]; + if(cur.getListener() === listener && cur.context === context) { + return n; + } + } + return -1; + }; + Signal.prototype.has = function (listener, context) { + if (typeof context === "undefined") { context = null; } + return this._indexOfListener(listener, context) !== -1; + }; + Signal.prototype.add = function (listener, listenerContext, priority) { + if (typeof listenerContext === "undefined") { listenerContext = null; } + if (typeof priority === "undefined") { priority = 0; } + this.validateListener(listener, 'add'); + return this._registerListener(listener, false, listenerContext, priority); + }; + Signal.prototype.addOnce = function (listener, listenerContext, priority) { + if (typeof listenerContext === "undefined") { listenerContext = null; } + if (typeof priority === "undefined") { priority = 0; } + this.validateListener(listener, 'addOnce'); + return this._registerListener(listener, true, listenerContext, priority); + }; + Signal.prototype.remove = function (listener, context) { + if (typeof context === "undefined") { context = null; } + this.validateListener(listener, 'remove'); + var i = this._indexOfListener(listener, context); + if(i !== -1) { + this._bindings[i]._destroy(); + this._bindings.splice(i, 1); + } + return listener; + }; + Signal.prototype.removeAll = function () { + var n = this._bindings.length; + while(n--) { + this._bindings[n]._destroy(); + } + this._bindings.length = 0; + }; + Signal.prototype.getNumListeners = function () { + return this._bindings.length; + }; + Signal.prototype.halt = function () { + this._shouldPropagate = false; + }; + Signal.prototype.dispatch = function () { + var paramsArr = []; + for (var _i = 0; _i < (arguments.length - 0); _i++) { + paramsArr[_i] = arguments[_i + 0]; + } + if(!this.active) { + return; + } + var n = this._bindings.length; + var bindings; + if(this.memorize) { + this._prevParams = paramsArr; + } + if(!n) { + return; + } + bindings = this._bindings.slice(0); + this._shouldPropagate = true; + do { + n--; + }while(bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false); + }; + Signal.prototype.forget = function () { + this._prevParams = null; + }; + Signal.prototype.dispose = function () { + this.removeAll(); + delete this._bindings; + delete this._prevParams; + }; + Signal.prototype.toString = function () { + return '[Signal active:' + this.active + ' numListeners:' + this.getNumListeners() + ']'; + }; + return Signal; + })(); + Phaser.Signal = Signal; +})(Phaser || (Phaser = {})); +var __extends = this.__extends || function (d, b) { + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var Phaser; +(function (Phaser) { + var GameObject = (function (_super) { + __extends(GameObject, _super); + function GameObject(game, x, y, width, height) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof width === "undefined") { width = 16; } + if (typeof height === "undefined") { height = 16; } + _super.call(this, game); + this._angle = 0; + this.outOfBoundsAction = 0; + this.z = 0; + this.rotationOffset = 0; + this.renderRotation = true; + this.moves = true; + this.inputEnabled = false; + this._inputOver = false; + this.bounds = new Phaser.Rectangle(x, y, width, height); + this.exists = true; + this.active = true; + this.visible = true; + this.alive = true; + this.isGroup = false; + this.alpha = 1; + this.scale = new Phaser.MicroPoint(1, 1); + this.last = new Phaser.MicroPoint(x, y); + this.origin = new Phaser.MicroPoint(this.bounds.halfWidth, this.bounds.halfHeight); + this.align = GameObject.ALIGN_TOP_LEFT; + this.mass = 1.0; + this.elasticity = 0.0; + this.health = 1; + this.immovable = false; + this.moves = true; + this.worldBounds = null; + this.touching = Phaser.Collision.NONE; + this.wasTouching = Phaser.Collision.NONE; + this.allowCollisions = Phaser.Collision.ANY; + this.velocity = new Phaser.MicroPoint(); + this.acceleration = new Phaser.MicroPoint(); + this.drag = new Phaser.MicroPoint(); + this.maxVelocity = new Phaser.MicroPoint(10000, 10000); + this.angle = 0; + this.angularVelocity = 0; + this.angularAcceleration = 0; + this.angularDrag = 0; + this.maxAngular = 10000; + this.cameraBlacklist = []; + this.scrollFactor = new Phaser.MicroPoint(1.0, 1.0); + } + GameObject.ALIGN_TOP_LEFT = 0; + GameObject.ALIGN_TOP_CENTER = 1; + GameObject.ALIGN_TOP_RIGHT = 2; + GameObject.ALIGN_CENTER_LEFT = 3; + GameObject.ALIGN_CENTER = 4; + GameObject.ALIGN_CENTER_RIGHT = 5; + GameObject.ALIGN_BOTTOM_LEFT = 6; + GameObject.ALIGN_BOTTOM_CENTER = 7; + GameObject.ALIGN_BOTTOM_RIGHT = 8; + GameObject.OUT_OF_BOUNDS_STOP = 0; + GameObject.OUT_OF_BOUNDS_KILL = 1; + GameObject.prototype.preUpdate = function () { + this.last.x = this.bounds.x; + this.last.y = this.bounds.y; + }; + GameObject.prototype.update = function () { + }; + GameObject.prototype.postUpdate = function () { + if(this.moves) { + this.updateMotion(); + } + if(this.worldBounds != null) { + if(this.outOfBoundsAction == GameObject.OUT_OF_BOUNDS_KILL) { + if(this.x < this.worldBounds.x || this.x > this.worldBounds.right || this.y < this.worldBounds.y || this.y > this.worldBounds.bottom) { + this.kill(); + } + } else { + if(this.x < this.worldBounds.x) { + this.x = this.worldBounds.x; + } else if(this.x > this.worldBounds.right) { + this.x = this.worldBounds.right; + } + if(this.y < this.worldBounds.y) { + this.y = this.worldBounds.y; + } else if(this.y > this.worldBounds.bottom) { + this.y = this.worldBounds.bottom; + } + } + } + if(this.inputEnabled) { + this.updateInput(); + } + this.wasTouching = this.touching; + this.touching = Phaser.Collision.NONE; + }; + GameObject.prototype.updateInput = function () { + }; + GameObject.prototype.updateMotion = function () { + var delta; + var velocityDelta; + velocityDelta = (this._game.motion.computeVelocity(this.angularVelocity, this.angularAcceleration, this.angularDrag, this.maxAngular) - this.angularVelocity) / 2; + this.angularVelocity += velocityDelta; + this._angle += this.angularVelocity * this._game.time.elapsed; + this.angularVelocity += velocityDelta; + velocityDelta = (this._game.motion.computeVelocity(this.velocity.x, this.acceleration.x, this.drag.x, this.maxVelocity.x) - this.velocity.x) / 2; + this.velocity.x += velocityDelta; + delta = this.velocity.x * this._game.time.elapsed; + this.velocity.x += velocityDelta; + this.bounds.x += delta; + velocityDelta = (this._game.motion.computeVelocity(this.velocity.y, this.acceleration.y, this.drag.y, this.maxVelocity.y) - this.velocity.y) / 2; + this.velocity.y += velocityDelta; + delta = this.velocity.y * this._game.time.elapsed; + this.velocity.y += velocityDelta; + this.bounds.y += delta; + }; + GameObject.prototype.overlaps = function (ObjectOrGroup, InScreenSpace, Camera) { + if (typeof InScreenSpace === "undefined") { InScreenSpace = false; } + if (typeof Camera === "undefined") { Camera = null; } + if(ObjectOrGroup.isGroup) { + var results = false; + var i = 0; + var members = ObjectOrGroup.members; + while(i < length) { + if(this.overlaps(members[i++], InScreenSpace, Camera)) { + results = true; + } + } + return results; + } + if(!InScreenSpace) { + return (ObjectOrGroup.x + ObjectOrGroup.width > this.x) && (ObjectOrGroup.x < this.x + this.width) && (ObjectOrGroup.y + ObjectOrGroup.height > this.y) && (ObjectOrGroup.y < this.y + this.height); + } + if(Camera == null) { + Camera = this._game.camera; + } + var objectScreenPos = ObjectOrGroup.getScreenXY(null, Camera); + this.getScreenXY(this._point, Camera); + return (objectScreenPos.x + ObjectOrGroup.width > this._point.x) && (objectScreenPos.x < this._point.x + this.width) && (objectScreenPos.y + ObjectOrGroup.height > this._point.y) && (objectScreenPos.y < this._point.y + this.height); + }; + GameObject.prototype.overlapsAt = function (X, Y, ObjectOrGroup, InScreenSpace, Camera) { + if (typeof InScreenSpace === "undefined") { InScreenSpace = false; } + if (typeof Camera === "undefined") { Camera = null; } + if(ObjectOrGroup.isGroup) { + var results = false; + var basic; + var i = 0; + var members = ObjectOrGroup.members; + while(i < length) { + if(this.overlapsAt(X, Y, members[i++], InScreenSpace, Camera)) { + results = true; + } + } + return results; + } + if(!InScreenSpace) { + return (ObjectOrGroup.x + ObjectOrGroup.width > X) && (ObjectOrGroup.x < X + this.width) && (ObjectOrGroup.y + ObjectOrGroup.height > Y) && (ObjectOrGroup.y < Y + this.height); + } + if(Camera == null) { + Camera = this._game.camera; + } + var objectScreenPos = ObjectOrGroup.getScreenXY(null, Camera); + this._point.x = X - Camera.scroll.x * this.scrollFactor.x; + this._point.y = Y - Camera.scroll.y * this.scrollFactor.y; + this._point.x += (this._point.x > 0) ? 0.0000001 : -0.0000001; + this._point.y += (this._point.y > 0) ? 0.0000001 : -0.0000001; + return (objectScreenPos.x + ObjectOrGroup.width > this._point.x) && (objectScreenPos.x < this._point.x + this.width) && (objectScreenPos.y + ObjectOrGroup.height > this._point.y) && (objectScreenPos.y < this._point.y + this.height); + }; + GameObject.prototype.overlapsPoint = function (point, InScreenSpace, Camera) { + if (typeof InScreenSpace === "undefined") { InScreenSpace = false; } + if (typeof Camera === "undefined") { Camera = null; } + if(!InScreenSpace) { + return (point.x > this.x) && (point.x < this.x + this.width) && (point.y > this.y) && (point.y < this.y + this.height); + } + if(Camera == null) { + Camera = this._game.camera; + } + var X = point.x - Camera.scroll.x; + var Y = point.y - Camera.scroll.y; + this.getScreenXY(this._point, Camera); + return (X > this._point.x) && (X < this._point.x + this.width) && (Y > this._point.y) && (Y < this._point.y + this.height); + }; + GameObject.prototype.onScreen = function (Camera) { + if (typeof Camera === "undefined") { Camera = null; } + if(Camera == null) { + Camera = this._game.camera; + } + this.getScreenXY(this._point, Camera); + return (this._point.x + this.width > 0) && (this._point.x < Camera.width) && (this._point.y + this.height > 0) && (this._point.y < Camera.height); + }; + GameObject.prototype.getScreenXY = function (point, Camera) { + if (typeof point === "undefined") { point = null; } + if (typeof Camera === "undefined") { Camera = null; } + if(point == null) { + point = new Phaser.MicroPoint(); + } + if(Camera == null) { + Camera = this._game.camera; + } + point.x = this.x - Camera.scroll.x * this.scrollFactor.x; + point.y = this.y - Camera.scroll.y * this.scrollFactor.y; + point.x += (point.x > 0) ? 0.0000001 : -0.0000001; + point.y += (point.y > 0) ? 0.0000001 : -0.0000001; + return point; + }; + Object.defineProperty(GameObject.prototype, "solid", { + get: function () { + return (this.allowCollisions & Phaser.Collision.ANY) > Phaser.Collision.NONE; + }, + set: function (Solid) { + if(Solid) { + this.allowCollisions = Phaser.Collision.ANY; + } else { + this.allowCollisions = Phaser.Collision.NONE; + } + }, + enumerable: true, + configurable: true + }); + GameObject.prototype.getMidpoint = function (point) { + if (typeof point === "undefined") { point = null; } + if(point == null) { + point = new Phaser.MicroPoint(); + } + point.copyFrom(this.bounds.center); + return point; + }; + GameObject.prototype.reset = function (X, Y) { + this.revive(); + this.touching = Phaser.Collision.NONE; + this.wasTouching = Phaser.Collision.NONE; + this.x = X; + this.y = Y; + this.last.x = X; + this.last.y = Y; + this.velocity.x = 0; + this.velocity.y = 0; + }; + GameObject.prototype.isTouching = function (Direction) { + return (this.touching & Direction) > Phaser.Collision.NONE; + }; + GameObject.prototype.justTouched = function (Direction) { + return ((this.touching & Direction) > Phaser.Collision.NONE) && ((this.wasTouching & Direction) <= Phaser.Collision.NONE); + }; + GameObject.prototype.hurt = function (Damage) { + this.health = this.health - Damage; + if(this.health <= 0) { + this.kill(); + } + }; + GameObject.prototype.setBounds = function (x, y, width, height) { + this.worldBounds = new Phaser.Quad(x, y, width, height); + }; + GameObject.prototype.hideFromCamera = function (camera) { + if(this.cameraBlacklist.indexOf(camera.ID) == -1) { + this.cameraBlacklist.push(camera.ID); + } + }; + GameObject.prototype.showToCamera = function (camera) { + if(this.cameraBlacklist.indexOf(camera.ID) !== -1) { + this.cameraBlacklist.slice(this.cameraBlacklist.indexOf(camera.ID), 1); + } + }; + GameObject.prototype.clearCameraList = function () { + this.cameraBlacklist.length = 0; + }; + GameObject.prototype.destroy = function () { + }; + Object.defineProperty(GameObject.prototype, "x", { + get: function () { + return this.bounds.x; + }, + set: function (value) { + this.bounds.x = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(GameObject.prototype, "y", { + get: function () { + return this.bounds.y; + }, + set: function (value) { + this.bounds.y = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(GameObject.prototype, "rotation", { + get: function () { + return this._angle; + }, + set: function (value) { + this._angle = this._game.math.wrap(value, 360, 0); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(GameObject.prototype, "angle", { + get: function () { + return this._angle; + }, + set: function (value) { + this._angle = this._game.math.wrap(value, 360, 0); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(GameObject.prototype, "width", { + get: function () { + return this.bounds.width; + }, + set: function (value) { + this.bounds.width = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(GameObject.prototype, "height", { + get: function () { + return this.bounds.height; + }, + set: function (value) { + this.bounds.height = value; + }, + enumerable: true, + configurable: true + }); + return GameObject; + })(Phaser.Basic); + Phaser.GameObject = GameObject; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Sprite = (function (_super) { + __extends(Sprite, _super); + function Sprite(game, x, y, key) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof key === "undefined") { key = null; } + _super.call(this, game, x, y); + this._dynamicTexture = false; + this._sx = 0; + this._sy = 0; + this._sw = 0; + this._sh = 0; + this._dx = 0; + this._dy = 0; + this._dw = 0; + this._dh = 0; + this.renderDebug = false; + this.renderDebugColor = 'rgba(0,255,0,0.5)'; + this.renderDebugPointColor = 'rgba(255,255,255,1)'; + this.flipped = false; + this._texture = null; + this.animations = new Phaser.AnimationManager(this._game, this); + if(key !== null) { + this.loadGraphic(key); + } else { + this.bounds.width = 16; + this.bounds.height = 16; + } + } + Sprite.prototype.loadGraphic = function (key) { + if(this._game.cache.getImage(key) !== null) { + if(this._game.cache.isSpriteSheet(key) == false) { + this._texture = this._game.cache.getImage(key); + this.bounds.width = this._texture.width; + this.bounds.height = this._texture.height; + } else { + this._texture = this._game.cache.getImage(key); + this.animations.loadFrameData(this._game.cache.getFrameData(key)); + } + this._dynamicTexture = false; + } + return this; + }; + Sprite.prototype.loadDynamicTexture = function (texture) { + this._texture = texture; + this.bounds.width = this._texture.width; + this.bounds.height = this._texture.height; + this._dynamicTexture = true; + return this; + }; + Sprite.prototype.makeGraphic = function (width, height, color) { + if (typeof color === "undefined") { color = 0xffffffff; } + this._texture = null; + this.width = width; + this.height = height; + this._dynamicTexture = false; + return this; + }; + Sprite.prototype.inCamera = function (camera) { + if(this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0) { + this._dx = this.bounds.x - (camera.x * this.scrollFactor.x); + this._dy = this.bounds.y - (camera.y * this.scrollFactor.x); + this._dw = this.bounds.width * this.scale.x; + this._dh = this.bounds.height * this.scale.y; + return (camera.right > this._dx) && (camera.x < this._dx + this._dw) && (camera.bottom > this._dy) && (camera.y < this._dy + this._dh); + } else { + return camera.intersects(this.bounds, this.bounds.length); + } + }; + Sprite.prototype.postUpdate = function () { + this.animations.update(); + _super.prototype.postUpdate.call(this); + }; + Object.defineProperty(Sprite.prototype, "frame", { + get: function () { + return this.animations.frame; + }, + set: function (value) { + this.animations.frame = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Sprite.prototype, "frameName", { + get: function () { + return this.animations.frameName; + }, + set: function (value) { + this.animations.frameName = value; + }, + enumerable: true, + configurable: true + }); + Sprite.prototype.render = function (camera, cameraOffsetX, cameraOffsetY) { + if(this.visible == false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1 || this.cameraBlacklist.indexOf(camera.ID) !== -1 || this.inCamera(camera.worldView) == false) { + return false; + } + if(this.alpha !== 1) { + var globalAlpha = this._game.stage.context.globalAlpha; + this._game.stage.context.globalAlpha = this.alpha; + } + this._sx = 0; + this._sy = 0; + this._sw = this.bounds.width; + this._sh = this.bounds.height; + this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x); + this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y); + this._dw = this.bounds.width * this.scale.x; + this._dh = this.bounds.height * this.scale.y; + if(this.align == Phaser.GameObject.ALIGN_TOP_CENTER) { + this._dx -= this.bounds.halfWidth * this.scale.x; + } else if(this.align == Phaser.GameObject.ALIGN_TOP_RIGHT) { + this._dx -= this.bounds.width * this.scale.x; + } else if(this.align == Phaser.GameObject.ALIGN_CENTER_LEFT) { + this._dy -= this.bounds.halfHeight * this.scale.y; + } else if(this.align == Phaser.GameObject.ALIGN_CENTER) { + this._dx -= this.bounds.halfWidth * this.scale.x; + this._dy -= this.bounds.halfHeight * this.scale.y; + } else if(this.align == Phaser.GameObject.ALIGN_CENTER_RIGHT) { + this._dx -= this.bounds.width * this.scale.x; + this._dy -= this.bounds.halfHeight * this.scale.y; + } else if(this.align == Phaser.GameObject.ALIGN_BOTTOM_LEFT) { + this._dy -= this.bounds.height * this.scale.y; + } else if(this.align == Phaser.GameObject.ALIGN_BOTTOM_CENTER) { + this._dx -= this.bounds.halfWidth * this.scale.x; + this._dy -= this.bounds.height * this.scale.y; + } else if(this.align == Phaser.GameObject.ALIGN_BOTTOM_RIGHT) { + this._dx -= this.bounds.width * this.scale.x; + this._dy -= this.bounds.height * this.scale.y; + } + if(this._dynamicTexture == false && this.animations.currentFrame !== null) { + this._sx = this.animations.currentFrame.x; + this._sy = this.animations.currentFrame.y; + if(this.animations.currentFrame.trimmed) { + this._dx += this.animations.currentFrame.spriteSourceSizeX; + this._dy += this.animations.currentFrame.spriteSourceSizeY; + } + } + if(this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0) { + this._dx -= (camera.worldView.x * this.scrollFactor.x); + this._dy -= (camera.worldView.y * this.scrollFactor.y); + } + if(this.angle !== 0 || this.rotationOffset !== 0 || this.flipped == true) { + this._game.stage.context.save(); + this._game.stage.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2)); + if(this.renderRotation == true && (this.angle !== 0 || this.rotationOffset !== 0)) { + this._game.stage.context.rotate((this.rotationOffset + this.angle) * (Math.PI / 180)); + } + this._dx = -(this._dw / 2); + this._dy = -(this._dh / 2); + if(this.flipped == true) { + this._game.stage.context.scale(-1, 1); + } + } + this._sx = Math.round(this._sx); + this._sy = Math.round(this._sy); + this._sw = Math.round(this._sw); + this._sh = Math.round(this._sh); + this._dx = Math.round(this._dx); + this._dy = Math.round(this._dy); + this._dw = Math.round(this._dw); + this._dh = Math.round(this._dh); + if(this._texture != null) { + if(this._dynamicTexture) { + this._game.stage.context.drawImage(this._texture.canvas, this._sx, this._sy, this._sw, this._sh, this._dx, this._dy, this._dw, this._dh); + } else { + this._game.stage.context.drawImage(this._texture, this._sx, this._sy, this._sw, this._sh, this._dx, this._dy, this._dw, this._dh); + } + } else { + this._game.stage.context.fillStyle = 'rgb(255,255,255)'; + this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh); + } + if(this.flipped === true || this.rotation !== 0 || this.rotationOffset !== 0) { + this._game.stage.context.restore(); + } + if(this.renderDebug) { + this.renderBounds(camera, cameraOffsetX, cameraOffsetY); + } + if(globalAlpha > -1) { + this._game.stage.context.globalAlpha = globalAlpha; + } + return true; + }; + Sprite.prototype.renderBounds = function (camera, cameraOffsetX, cameraOffsetY) { + this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x); + this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y); + this._game.stage.context.fillStyle = this.renderDebugColor; + this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh); + this._game.stage.context.fillStyle = this.renderDebugPointColor; + var hw = this.bounds.halfWidth * this.scale.x; + var hh = this.bounds.halfHeight * this.scale.y; + var sw = (this.bounds.width * this.scale.x) - 1; + var sh = (this.bounds.height * this.scale.y) - 1; + this._game.stage.context.fillRect(this._dx, this._dy, 1, 1); + this._game.stage.context.fillRect(this._dx + hw, this._dy, 1, 1); + this._game.stage.context.fillRect(this._dx + sw, this._dy, 1, 1); + this._game.stage.context.fillRect(this._dx, this._dy + hh, 1, 1); + this._game.stage.context.fillRect(this._dx + hw, this._dy + hh, 1, 1); + this._game.stage.context.fillRect(this._dx + sw, this._dy + hh, 1, 1); + this._game.stage.context.fillRect(this._dx, this._dy + sh, 1, 1); + this._game.stage.context.fillRect(this._dx + hw, this._dy + sh, 1, 1); + this._game.stage.context.fillRect(this._dx + sw, this._dy + sh, 1, 1); + }; + Sprite.prototype.renderDebugInfo = function (x, y, color) { + if (typeof color === "undefined") { color = 'rgb(255,255,255)'; } + this._game.stage.context.fillStyle = color; + this._game.stage.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y); + this._game.stage.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14); + this._game.stage.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28); + this._game.stage.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42); + }; + return Sprite; + })(Phaser.GameObject); + Phaser.Sprite = Sprite; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Camera = (function () { + function Camera(game, id, x, y, width, height) { + this._clip = false; + this._rotation = 0; + this._target = null; + this._sx = 0; + this._sy = 0; + this._fxFlashComplete = null; + this._fxFlashDuration = 0; + this._fxFlashAlpha = 0; + this._fxFadeComplete = null; + this._fxFadeDuration = 0; + this._fxFadeAlpha = 0; + this._fxShakeIntensity = 0; + this._fxShakeDuration = 0; + this._fxShakeComplete = null; + this._fxShakeOffset = new Phaser.Point(0, 0); + this._fxShakeDirection = 0; + this._fxShakePrevX = 0; + this._fxShakePrevY = 0; + this.scale = new Phaser.Point(1, 1); + this.scroll = new Phaser.Point(0, 0); + this.bounds = null; + this.deadzone = null; + this.showBorder = false; + this.borderColor = 'rgb(255,255,255)'; + this.opaque = true; + this._bgColor = 'rgb(0,0,0)'; + this._bgTextureRepeat = 'repeat'; + this.showShadow = false; + this.shadowColor = 'rgb(0,0,0)'; + this.shadowBlur = 10; + this.shadowOffset = new Phaser.Point(4, 4); + this.visible = true; + this.alpha = 1; + this.inputX = 0; + this.inputY = 0; + this._game = game; + this.ID = id; + this._stageX = x; + this._stageY = y; + this.worldView = new Phaser.Rectangle(0, 0, width, height); + this.checkClip(); + } + Camera.STYLE_LOCKON = 0; + Camera.STYLE_PLATFORMER = 1; + Camera.STYLE_TOPDOWN = 2; + Camera.STYLE_TOPDOWN_TIGHT = 3; + Camera.SHAKE_BOTH_AXES = 0; + Camera.SHAKE_HORIZONTAL_ONLY = 1; + Camera.SHAKE_VERTICAL_ONLY = 2; + Camera.prototype.flash = 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) { + 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; + }; + Camera.prototype.fade = 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) { + 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; + }; + Camera.prototype.shake = 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 = Camera.SHAKE_BOTH_AXES; } + if(!force && ((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0))) { + return; + } + if(this._fxShakeOffset.x == 0 && this._fxShakeOffset.y == 0) { + this._fxShakePrevX = this._stageX; + this._fxShakePrevY = this._stageY; + } + this._fxShakeIntensity = intensity; + this._fxShakeDuration = duration; + this._fxShakeComplete = onComplete; + this._fxShakeDirection = direction; + this._fxShakeOffset.setTo(0, 0); + }; + Camera.prototype.stopFX = function () { + this._fxFlashAlpha = 0; + this._fxFadeAlpha = 0; + if(this._fxShakeDuration !== 0) { + this._fxShakeDuration = 0; + this._fxShakeOffset.setTo(0, 0); + this._stageX = this._fxShakePrevX; + this._stageY = this._fxShakePrevY; + } + }; + Camera.prototype.follow = function (target, style) { + if (typeof style === "undefined") { style = Camera.STYLE_LOCKON; } + this._target = target; + var helper; + switch(style) { + case Camera.STYLE_PLATFORMER: + var w = this.width / 8; + var h = this.height / 3; + this.deadzone = new Phaser.Rectangle((this.width - w) / 2, (this.height - h) / 2 - h * 0.25, w, h); + break; + case Camera.STYLE_TOPDOWN: + helper = Math.max(this.width, this.height) / 4; + this.deadzone = new Phaser.Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper); + break; + case Camera.STYLE_TOPDOWN_TIGHT: + helper = Math.max(this.width, this.height) / 8; + this.deadzone = new Phaser.Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper); + break; + case Camera.STYLE_LOCKON: + default: + this.deadzone = null; + break; + } + }; + Camera.prototype.focusOnXY = function (x, y) { + x += (x > 0) ? 0.0000001 : -0.0000001; + y += (y > 0) ? 0.0000001 : -0.0000001; + this.scroll.x = Math.round(x - this.worldView.halfWidth); + this.scroll.y = Math.round(y - this.worldView.halfHeight); + }; + Camera.prototype.focusOn = function (point) { + point.x += (point.x > 0) ? 0.0000001 : -0.0000001; + point.y += (point.y > 0) ? 0.0000001 : -0.0000001; + this.scroll.x = Math.round(point.x - this.worldView.halfWidth); + this.scroll.y = Math.round(point.y - this.worldView.halfHeight); + }; + Camera.prototype.setBounds = function (x, y, width, height) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof width === "undefined") { width = 0; } + if (typeof height === "undefined") { height = 0; } + if(this.bounds == null) { + this.bounds = new Phaser.Rectangle(); + } + this.bounds.setTo(x, y, width, height); + this.worldView.setTo(x, y, width, height); + this.scroll.setTo(0, 0); + this.update(); + }; + Camera.prototype.update = function () { + if(this._target !== null) { + if(this.deadzone == null) { + this.focusOnXY(this._target.x + this._target.origin.x, this._target.y + this._target.origin.y); + } else { + var edge; + var targetX = this._target.x + ((this._target.x > 0) ? 0.0000001 : -0.0000001); + var targetY = this._target.y + ((this._target.y > 0) ? 0.0000001 : -0.0000001); + edge = targetX - this.deadzone.x; + if(this.scroll.x > edge) { + this.scroll.x = edge; + } + edge = targetX + this._target.width - this.deadzone.x - this.deadzone.width; + if(this.scroll.x < edge) { + this.scroll.x = edge; + } + edge = targetY - this.deadzone.y; + if(this.scroll.y > edge) { + this.scroll.y = edge; + } + edge = targetY + this._target.height - this.deadzone.y - this.deadzone.height; + if(this.scroll.y < edge) { + this.scroll.y = edge; + } + } + } + if(this.bounds !== null) { + if(this.scroll.x < this.bounds.left) { + this.scroll.x = this.bounds.left; + } + if(this.scroll.x > this.bounds.right - this.width) { + this.scroll.x = (this.bounds.right - this.width) + 1; + } + if(this.scroll.y < this.bounds.top) { + this.scroll.y = this.bounds.top; + } + if(this.scroll.y > this.bounds.bottom - this.height) { + this.scroll.y = (this.bounds.bottom - this.height) + 1; + } + } + this.worldView.x = this.scroll.x; + this.worldView.y = this.scroll.y; + this.inputX = this.worldView.x + this._game.input.x; + this.inputY = this.worldView.y + this._game.input.y; + if(this._fxFlashAlpha > 0) { + this._fxFlashAlpha -= this._game.time.elapsed / this._fxFlashDuration; + this._fxFlashAlpha = this._game.math.roundTo(this._fxFlashAlpha, -2); + if(this._fxFlashAlpha <= 0) { + this._fxFlashAlpha = 0; + if(this._fxFlashComplete !== null) { + this._fxFlashComplete(); + } + } + } + if(this._fxFadeAlpha > 0) { + this._fxFadeAlpha += this._game.time.elapsed / this._fxFadeDuration; + this._fxFadeAlpha = this._game.math.roundTo(this._fxFadeAlpha, -2); + if(this._fxFadeAlpha >= 1) { + this._fxFadeAlpha = 1; + if(this._fxFadeComplete !== null) { + this._fxFadeComplete(); + } + } + } + if(this._fxShakeDuration > 0) { + this._fxShakeDuration -= this._game.time.elapsed; + this._fxShakeDuration = this._game.math.roundTo(this._fxShakeDuration, -2); + if(this._fxShakeDuration <= 0) { + this._fxShakeDuration = 0; + this._fxShakeOffset.setTo(0, 0); + this._stageX = this._fxShakePrevX; + this._stageY = this._fxShakePrevY; + if(this._fxShakeComplete != null) { + this._fxShakeComplete(); + } + } else { + if((this._fxShakeDirection == Camera.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Camera.SHAKE_HORIZONTAL_ONLY)) { + this._fxShakeOffset.x = (this._game.math.random() * this._fxShakeIntensity * this.worldView.width * 2 - this._fxShakeIntensity * this.worldView.width); + } + if((this._fxShakeDirection == Camera.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Camera.SHAKE_VERTICAL_ONLY)) { + this._fxShakeOffset.y = (this._game.math.random() * this._fxShakeIntensity * this.worldView.height * 2 - this._fxShakeIntensity * this.worldView.height); + } + } + } + }; + Camera.prototype.render = function () { + if(this.visible === false || this.alpha < 0.1) { + return; + } + if((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0)) { + this._stageX = this._fxShakePrevX + (this.worldView.halfWidth) + this._fxShakeOffset.x; + this._stageY = this._fxShakePrevY + (this.worldView.halfHeight) + this._fxShakeOffset.y; + } + this._game.stage.context.save(); + if(this.alpha !== 1) { + this._game.stage.context.globalAlpha = this.alpha; + } + this._sx = this._stageX; + this._sy = this._stageY; + if(this.showShadow) { + 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; + } + if(this.scale.x !== 1 || this.scale.y !== 1) { + this._game.stage.context.scale(this.scale.x, this.scale.y); + this._sx = this._sx / this.scale.x; + this._sy = this._sy / this.scale.y; + } + if(this._rotation !== 0) { + this._game.stage.context.translate(this._sx + this.worldView.halfWidth, this._sy + this.worldView.halfHeight); + this._game.stage.context.rotate(this._rotation * (Math.PI / 180)); + this._game.stage.context.translate(-(this._sx + this.worldView.halfWidth), -(this._sy + this.worldView.halfHeight)); + } + if(this.opaque == true) { + if(this._bgTexture) { + this._game.stage.context.fillStyle = this._bgTexture; + this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height); + } else { + this._game.stage.context.fillStyle = this._bgColor; + this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height); + } + } + if(this.showShadow) { + this._game.stage.context.shadowBlur = 0; + this._game.stage.context.shadowOffsetX = 0; + this._game.stage.context.shadowOffsetY = 0; + } + if(this._clip) { + this._game.stage.context.beginPath(); + this._game.stage.context.rect(this._sx, this._sy, this.worldView.width, this.worldView.height); + this._game.stage.context.closePath(); + this._game.stage.context.clip(); + } + this._game.world.group.render(this, this._sx, this._sy); + if(this.showBorder) { + 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(); + } + if(this._fxFlashAlpha > 0) { + this._game.stage.context.fillStyle = this._fxFlashColor + this._fxFlashAlpha + ')'; + this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height); + } + if(this._fxFadeAlpha > 0) { + this._game.stage.context.fillStyle = this._fxFadeColor + this._fxFadeAlpha + ')'; + this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height); + } + if(this.scale.x !== 1 || this.scale.y !== 1) { + this._game.stage.context.scale(1, 1); + } + if(this._rotation !== 0 || this._clip) { + this._game.stage.context.translate(0, 0); + } + this._game.stage.context.restore(); + if(this.alpha !== 1) { + this._game.stage.context.globalAlpha = 1; + } + }; + Object.defineProperty(Camera.prototype, "backgroundColor", { + get: function () { + return this._bgColor; + }, + set: function (color) { + this._bgColor = color; + }, + enumerable: true, + configurable: true + }); + Camera.prototype.setTexture = function (key, repeat) { + if (typeof repeat === "undefined") { repeat = 'repeat'; } + this._bgTexture = this._game.stage.context.createPattern(this._game.cache.getImage(key), repeat); + this._bgTextureRepeat = repeat; + }; + Camera.prototype.setPosition = function (x, y) { + this._stageX = x; + this._stageY = y; + this.checkClip(); + }; + Camera.prototype.setSize = function (width, height) { + this.worldView.width = width; + this.worldView.height = height; + this.checkClip(); + }; + Camera.prototype.renderDebugInfo = function (x, y, color) { + if (typeof color === "undefined") { color = 'rgb(255,255,255)'; } + this._game.stage.context.fillStyle = color; + this._game.stage.context.fillText('Camera ID: ' + this.ID + ' (' + this.worldView.width + ' x ' + this.worldView.height + ')', x, y); + this._game.stage.context.fillText('X: ' + this._stageX + ' Y: ' + this._stageY + ' Rotation: ' + this._rotation, x, y + 14); + this._game.stage.context.fillText('World X: ' + this.scroll.x.toFixed(1) + ' World Y: ' + this.scroll.y.toFixed(1), x, y + 28); + if(this.bounds) { + this._game.stage.context.fillText('Bounds: ' + this.bounds.width + ' x ' + this.bounds.height, x, y + 56); + } + }; + Object.defineProperty(Camera.prototype, "x", { + get: function () { + return this._stageX; + }, + set: function (value) { + this._stageX = value; + this.checkClip(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Camera.prototype, "y", { + get: function () { + return this._stageY; + }, + set: function (value) { + this._stageY = value; + this.checkClip(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Camera.prototype, "width", { + get: function () { + return this.worldView.width; + }, + set: function (value) { + this.worldView.width = value; + this.checkClip(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Camera.prototype, "height", { + get: function () { + return this.worldView.height; + }, + set: function (value) { + this.worldView.height = value; + this.checkClip(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Camera.prototype, "rotation", { + get: function () { + return this._rotation; + }, + set: function (value) { + this._rotation = this._game.math.wrap(value, 360, 0); + }, + enumerable: true, + configurable: true + }); + Camera.prototype.checkClip = function () { + if(this._stageX !== 0 || this._stageY !== 0 || this.worldView.width < this._game.stage.width || this.worldView.height < this._game.stage.height) { + this._clip = true; + } else { + this._clip = false; + } + }; + return Camera; + })(); + Phaser.Camera = Camera; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var CameraManager = (function () { + function CameraManager(game, x, y, width, height) { + this._cameraInstance = 0; + this._game = game; + this._cameras = []; + this.current = this.addCamera(x, y, width, height); + } + CameraManager.prototype.getAll = function () { + return this._cameras; + }; + CameraManager.prototype.update = function () { + this._cameras.forEach(function (camera) { + return camera.update(); + }); + }; + CameraManager.prototype.render = function () { + this._cameras.forEach(function (camera) { + return camera.render(); + }); + }; + CameraManager.prototype.addCamera = function (x, y, width, height) { + var newCam = new Phaser.Camera(this._game, this._cameraInstance, x, y, width, height); + this._cameras.push(newCam); + this._cameraInstance++; + return newCam; + }; + CameraManager.prototype.removeCamera = function (id) { + for(var c = 0; c < this._cameras.length; c++) { + if(this._cameras[c].ID == id) { + if(this.current.ID === this._cameras[c].ID) { + this.current = null; + } + this._cameras.splice(c, 1); + return true; + } + } + return false; + }; + CameraManager.prototype.destroy = function () { + this._cameras.length = 0; + this.current = this.addCamera(0, 0, this._game.stage.width, this._game.stage.height); + }; + return CameraManager; + })(); + Phaser.CameraManager = CameraManager; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Point = (function () { + function Point(x, y) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + this.setTo(x, y); + } + Point.prototype.add = function (toAdd, output) { + if (typeof output === "undefined") { output = new Point(); } + return output.setTo(this.x + toAdd.x, this.y + toAdd.y); + }; + Point.prototype.addTo = function (x, y) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + return this.setTo(this.x + x, this.y + y); + }; + Point.prototype.subtractFrom = function (x, y) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + return this.setTo(this.x - x, this.y - y); + }; + Point.prototype.invert = function () { + return this.setTo(this.y, this.x); + }; + Point.prototype.clamp = function (min, max) { + this.clampX(min, max); + this.clampY(min, max); + return this; + }; + Point.prototype.clampX = function (min, max) { + this.x = Math.max(Math.min(this.x, max), min); + return this; + }; + Point.prototype.clampY = function (min, max) { + this.x = Math.max(Math.min(this.x, max), min); + this.y = Math.max(Math.min(this.y, max), min); + return this; + }; + Point.prototype.clone = function (output) { + if (typeof output === "undefined") { output = new Point(); } + return output.setTo(this.x, this.y); + }; + Point.prototype.copyFrom = function (source) { + return this.setTo(source.x, source.y); + }; + Point.prototype.copyTo = function (target) { + return target.setTo(this.x, this.y); + }; + Point.prototype.distanceTo = function (target, round) { + if (typeof round === "undefined") { round = false; } + var dx = this.x - target.x; + var dy = this.y - target.y; + if(round === true) { + return Math.round(Math.sqrt(dx * dx + dy * dy)); + } else { + return Math.sqrt(dx * dx + dy * dy); + } + }; + Point.distanceBetween = function distanceBetween(pointA, pointB, round) { + if (typeof round === "undefined") { round = false; } + var dx = pointA.x - pointB.x; + var dy = pointA.y - pointB.y; + if(round === true) { + return Math.round(Math.sqrt(dx * dx + dy * dy)); + } else { + return Math.sqrt(dx * dx + dy * dy); + } + }; + Point.prototype.distanceCompare = function (target, distance) { + if(this.distanceTo(target) >= distance) { + return true; + } else { + return false; + } + }; + Point.prototype.equals = function (toCompare) { + if(this.x === toCompare.x && this.y === toCompare.y) { + return true; + } else { + return false; + } + }; + Point.prototype.interpolate = function (pointA, pointB, f) { + }; + Point.prototype.offset = function (dx, dy) { + this.x += dx; + this.y += dy; + return this; + }; + Point.prototype.polar = function (length, angle) { + }; + Point.prototype.setTo = function (x, y) { + this.x = x; + this.y = y; + return this; + }; + Point.prototype.subtract = function (point, output) { + if (typeof output === "undefined") { output = new Point(); } + return output.setTo(this.x - point.x, this.y - point.y); + }; + Point.prototype.toString = function () { + return '[{Point (x=' + this.x + ' y=' + this.y + ')}]'; + }; + return Point; + })(); + Phaser.Point = Point; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var MicroPoint = (function () { + function MicroPoint(x, y, parent) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof parent === "undefined") { parent = null; } + this._x = x; + this._y = y; + this.parent = parent; + } + Object.defineProperty(MicroPoint.prototype, "x", { + get: function () { + return this._x; + }, + set: function (value) { + this._x = value; + if(this.parent) { + this.parent.updateBounds(); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(MicroPoint.prototype, "y", { + get: function () { + return this._y; + }, + set: function (value) { + this._y = value; + if(this.parent) { + this.parent.updateBounds(); + } + }, + enumerable: true, + configurable: true + }); + MicroPoint.prototype.copyFrom = function (source) { + return this.setTo(source.x, source.y); + }; + MicroPoint.prototype.copyTo = function (target) { + target.x = this._x; + target.y = this._y; + return target; + }; + MicroPoint.prototype.setTo = function (x, y, callParent) { + if (typeof callParent === "undefined") { callParent = true; } + this._x = x; + this._y = y; + if(this.parent != null && callParent == true) { + this.parent.updateBounds(); + } + return this; + }; + MicroPoint.prototype.equals = function (toCompare) { + if(this._x === toCompare.x && this._y === toCompare.y) { + return true; + } else { + return false; + } + }; + MicroPoint.prototype.toString = function () { + return '[{MicroPoint (x=' + this._x + ' y=' + this._y + ')}]'; + }; + return MicroPoint; + })(); + Phaser.MicroPoint = MicroPoint; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Rectangle = (function () { + function Rectangle(x, y, width, height) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof width === "undefined") { width = 0; } + if (typeof height === "undefined") { height = 0; } + this._tempX = null; + this._tempY = null; + this._tempWidth = null; + this._tempHeight = null; + this._width = 0; + this._height = 0; + this._halfWidth = 0; + this._halfHeight = 0; + this.length = 0; + this._width = width; + if(width > 0) { + this._halfWidth = Math.round(width / 2); + } + this._height = height; + if(height > 0) { + this._halfHeight = Math.round(height / 2); + } + this.length = Math.max(this._width, this._height); + this.topLeft = new Phaser.MicroPoint(x, y, this); + this.topCenter = new Phaser.MicroPoint(x + this._halfWidth, y, this); + this.topRight = new Phaser.MicroPoint(x + this._width - 1, y, this); + this.leftCenter = new Phaser.MicroPoint(x, y + this._halfHeight, this); + this.center = new Phaser.MicroPoint(x + this._halfWidth, y + this._halfHeight, this); + this.rightCenter = new Phaser.MicroPoint(x + this._width - 1, y + this._halfHeight, this); + this.bottomLeft = new Phaser.MicroPoint(x, y + this._height - 1, this); + this.bottomCenter = new Phaser.MicroPoint(x + this._halfWidth, y + this._height - 1, this); + this.bottomRight = new Phaser.MicroPoint(x + this._width - 1, y + this._height - 1, this); + } + Object.defineProperty(Rectangle.prototype, "x", { + get: function () { + return this.topLeft.x; + }, + set: function (value) { + this.topLeft.x = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Rectangle.prototype, "y", { + get: function () { + return this.topLeft.y; + }, + set: function (value) { + this.topLeft.y = value; + }, + enumerable: true, + configurable: true + }); + Rectangle.prototype.updateBounds = function () { + if(this._tempWidth !== null) { + this._width = this._tempWidth; + this._halfWidth = 0; + if(this._width > 0) { + this._halfWidth = Math.round(this._width / 2); + } + } + if(this._tempHeight !== null) { + this._height = this._tempHeight; + this._halfHeight = 0; + if(this._height > 0) { + this._halfHeight = Math.round(this._height / 2); + } + } + this.length = Math.max(this._width, this._height); + if(this._tempX !== null && this._tempY !== null) { + this.topLeft.setTo(this._tempX, this._tempY, false); + } else if(this._tempX !== null && this._tempY == null) { + this.topLeft.setTo(this._tempX, this.topLeft.y, false); + } else if(this._tempX == null && this._tempY !== null) { + this.topLeft.setTo(this.topLeft.x, this._tempY, false); + } else { + this.topLeft.setTo(this.x, this.y, false); + } + this.topCenter.setTo(this.x + this._halfWidth, this.y, false); + this.topRight.setTo(this.x + this._width - 1, this.y, false); + this.leftCenter.setTo(this.x, this.y + this._halfHeight, false); + this.center.setTo(this.x + this._halfWidth, this.y + this._halfHeight, false); + this.rightCenter.setTo(this.x + this._width - 1, this.y + this._halfHeight, false); + this.bottomLeft.setTo(this.x, this.y + this._height - 1, false); + this.bottomCenter.setTo(this.x + this._halfWidth, this.y + this._height - 1, false); + this.bottomRight.setTo(this.x + this._width - 1, this.y + this._height - 1, false); + this._tempX = null; + this._tempY = null; + this._tempWidth = null; + this._tempHeight = null; + }; + Object.defineProperty(Rectangle.prototype, "width", { + get: function () { + return this._width; + }, + set: function (value) { + this._width = value; + this._halfWidth = Math.round(value / 2); + this.updateBounds(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Rectangle.prototype, "height", { + get: function () { + return this._height; + }, + set: function (value) { + this._height = value; + this._halfHeight = Math.round(value / 2); + this.updateBounds(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Rectangle.prototype, "halfWidth", { + get: function () { + return this._halfWidth; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Rectangle.prototype, "halfHeight", { + get: function () { + return this._halfHeight; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Rectangle.prototype, "bottom", { + get: function () { + return this.bottomCenter.y; + }, + set: function (value) { + if(value < this.y) { + this._tempHeight = 0; + } else { + this._tempHeight = this.y + value; + } + this.updateBounds(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Rectangle.prototype, "left", { + get: function () { + return this.x; + }, + set: function (value) { + var diff = this.x - value; + if(this._width + diff < 0) { + this._tempWidth = 0; + this._tempX = value; + } else { + this._tempWidth = this._width + diff; + this._tempX = value; + } + this.updateBounds(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Rectangle.prototype, "right", { + get: function () { + return this.rightCenter.x; + }, + set: function (value) { + if(value < this.topLeft.x) { + this._tempWidth = 0; + } else { + this._tempWidth = (value - this.topLeft.x); + } + this.updateBounds(); + }, + enumerable: true, + configurable: true + }); + Rectangle.prototype.size = function (output) { + if (typeof output === "undefined") { output = new Phaser.Point(); } + return output.setTo(this._width, this._height); + }; + Object.defineProperty(Rectangle.prototype, "volume", { + get: function () { + return this._width * this._height; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Rectangle.prototype, "perimeter", { + get: function () { + return (this._width * 2) + (this._height * 2); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Rectangle.prototype, "top", { + get: function () { + return this.topCenter.y; + }, + set: function (value) { + var diff = this.topCenter.y - value; + if(this._height + diff < 0) { + this._tempHeight = 0; + this._tempY = value; + } else { + this._tempHeight = this._height + diff; + this._tempY = value; + } + this.updateBounds(); + }, + enumerable: true, + configurable: true + }); + Rectangle.prototype.clone = function (output) { + if (typeof output === "undefined") { output = new Rectangle(); } + return output.setTo(this.x, this.y, this.width, this.height); + }; + Rectangle.prototype.contains = function (x, y) { + if(x >= this.topLeft.x && x <= this.topRight.x && y >= this.topLeft.y && y <= this.bottomRight.y) { + return true; + } + return false; + }; + Rectangle.prototype.containsPoint = function (point) { + return this.contains(point.x, point.y); + }; + Rectangle.prototype.containsRect = function (rect) { + if(rect.volume > this.volume) { + return false; + } + if(rect.x >= this.topLeft.x && rect.y >= this.topLeft.y && rect.rightCenter.x <= this.rightCenter.x && rect.bottomCenter.y <= this.bottomCenter.y) { + return true; + } + return false; + }; + Rectangle.prototype.copyFrom = function (source) { + return this.setTo(source.x, source.y, source.width, source.height); + }; + Rectangle.prototype.copyTo = function (target) { + return target.copyFrom(this); + }; + Rectangle.prototype.equals = function (toCompare) { + if(this.topLeft.equals(toCompare.topLeft) && this.bottomRight.equals(toCompare.bottomRight)) { + return true; + } + return false; + }; + Rectangle.prototype.inflate = function (dx, dy) { + this._tempX = this.topLeft.x - dx; + this._tempWidth = this._width + (2 * dx); + this._tempY = this.topLeft.y - dy; + this._tempHeight = this._height + (2 * dy); + this.updateBounds(); + return this; + }; + Rectangle.prototype.inflatePoint = function (point) { + return this.inflate(point.x, point.y); + }; + Rectangle.prototype.intersection = function (toIntersect, output) { + if (typeof output === "undefined") { output = new Rectangle(); } + if(this.intersects(toIntersect) === true) { + output.x = Math.max(toIntersect.topLeft.x, this.topLeft.x); + output.y = Math.max(toIntersect.topLeft.y, this.topLeft.y); + output.width = Math.min(toIntersect.rightCenter.x, this.rightCenter.x) - output.x; + output.height = Math.min(toIntersect.bottomCenter.y, this.bottomCenter.y) - output.y; + } + return output; + }; + Rectangle.prototype.intersects = function (r2, t) { + if (typeof t === "undefined") { t = 0; } + return !(r2.left > this.right + t || r2.right < this.left - t || r2.top > this.bottom + t || r2.bottom < this.top - t); + }; + Object.defineProperty(Rectangle.prototype, "isEmpty", { + get: function () { + if(this.width < 1 || this.height < 1) { + return true; + } + return false; + }, + enumerable: true, + configurable: true + }); + Rectangle.prototype.offset = function (dx, dy) { + if(!isNaN(dx) && !isNaN(dy)) { + this.x += dx; + this.y += dy; + } + return this; + }; + Rectangle.prototype.offsetPoint = function (point) { + return this.offset(point.x, point.y); + }; + Rectangle.prototype.setEmpty = function () { + return this.setTo(0, 0, 0, 0); + }; + Rectangle.prototype.setTo = function (x, y, width, height) { + this._tempX = x; + this._tempY = y; + this._tempWidth = width; + this._tempHeight = height; + this.updateBounds(); + return this; + }; + Rectangle.prototype.union = function (toUnion, output) { + if (typeof output === "undefined") { output = new Rectangle(); } + return output.setTo(Math.min(toUnion.x, this.x), Math.min(toUnion.y, this.y), Math.max(toUnion.right, this.right), Math.max(toUnion.bottom, this.bottom)); + }; + Rectangle.prototype.toString = function () { + return "[{Rectangle (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + " empty=" + this.isEmpty + ")}]"; + }; + return Rectangle; + })(); + Phaser.Rectangle = Rectangle; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Quad = (function () { + function Quad(x, y, width, height) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof width === "undefined") { width = 0; } + if (typeof height === "undefined") { height = 0; } + this.setTo(x, y, width, height); + } + Quad.prototype.setTo = function (x, y, width, height) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + return this; + }; + Object.defineProperty(Quad.prototype, "left", { + get: function () { + return this.x; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Quad.prototype, "right", { + get: function () { + return this.x + this.width; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Quad.prototype, "top", { + get: function () { + return this.y; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Quad.prototype, "bottom", { + get: function () { + return this.y + this.height; + }, + enumerable: true, + configurable: true + }); + Quad.prototype.intersects = function (q, t) { + if (typeof t === "undefined") { t = 0; } + return !(q.left > this.right + t || q.right < this.left - t || q.top > this.bottom + t || q.bottom < this.top - t); + }; + Quad.prototype.toString = function () { + return "[{Quad (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + ")}]"; + }; + return Quad; + })(); + Phaser.Quad = Quad; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Circle = (function () { + function Circle(x, y, diameter) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof diameter === "undefined") { diameter = 0; } + this._diameter = 0; + this._radius = 0; + this.x = 0; + this.y = 0; + this.setTo(x, y, diameter); + } + Object.defineProperty(Circle.prototype, "diameter", { + get: function () { + return this._diameter; + }, + set: function (value) { + if(value > 0) { + this._diameter = value; + this._radius = value * 0.5; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Circle.prototype, "radius", { + get: function () { + return this._radius; + }, + set: function (value) { + if(value > 0) { + this._radius = value; + this._diameter = value * 2; + } + }, + enumerable: true, + configurable: true + }); + Circle.prototype.circumference = function () { + return 2 * (Math.PI * this._radius); + }; + Object.defineProperty(Circle.prototype, "bottom", { + get: function () { + return this.y + this._radius; + }, + set: function (value) { + if(!isNaN(value)) { + if(value < this.y) { + this._radius = 0; + this._diameter = 0; + } else { + this.radius = value - this.y; + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Circle.prototype, "left", { + get: function () { + return this.x - this._radius; + }, + set: function (value) { + if(!isNaN(value)) { + if(value < this.x) { + this.radius = this.x - value; + } else { + this._radius = 0; + this._diameter = 0; + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Circle.prototype, "right", { + get: function () { + return this.x + this._radius; + }, + set: function (value) { + if(!isNaN(value)) { + if(value > this.x) { + this.radius = value - this.x; + } else { + this._radius = 0; + this._diameter = 0; + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Circle.prototype, "top", { + get: function () { + return this.y - this._radius; + }, + set: function (value) { + if(!isNaN(value)) { + if(value > this.y) { + this._radius = 0; + this._diameter = 0; + } else { + this.radius = this.y - value; + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Circle.prototype, "area", { + get: function () { + if(this._radius > 0) { + return Math.PI * this._radius * this._radius; + } else { + return 0; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Circle.prototype, "isEmpty", { + get: function () { + if(this._diameter < 1) { + return true; + } + return false; + }, + enumerable: true, + configurable: true + }); + Circle.prototype.intersectCircleLine = function (line) { + return Phaser.Collision.lineToCircle(line, this).result; + }; + Circle.prototype.clone = function (output) { + if (typeof output === "undefined") { output = new Circle(); } + return output.setTo(this.x, this.y, this._diameter); + }; + Circle.prototype.contains = function (x, y) { + return Phaser.Collision.circleContainsPoint(this, { + x: x, + y: y + }).result; + }; + Circle.prototype.containsPoint = function (point) { + return Phaser.Collision.circleContainsPoint(this, point).result; + }; + Circle.prototype.containsCircle = function (circle) { + return Phaser.Collision.circleToCircle(this, circle).result; + }; + Circle.prototype.copyFrom = function (source) { + return this.setTo(source.x, source.y, source.diameter); + }; + Circle.prototype.copyTo = function (target) { + return target.copyFrom(this); + }; + Circle.prototype.distanceTo = function (target, round) { + if (typeof round === "undefined") { round = false; } + var dx = this.x - target.x; + var dy = this.y - target.y; + if(round === true) { + return Math.round(Math.sqrt(dx * dx + dy * dy)); + } else { + return Math.sqrt(dx * dx + dy * dy); + } + }; + Circle.prototype.equals = function (toCompare) { + if(this.x === toCompare.x && this.y === toCompare.y && this.diameter === toCompare.diameter) { + return true; + } + return false; + }; + Circle.prototype.intersects = function (toIntersect) { + if(this.distanceTo(toIntersect, false) < (this._radius + toIntersect._radius)) { + return true; + } + return false; + }; + Circle.prototype.circumferencePoint = function (angle, asDegrees, output) { + if (typeof asDegrees === "undefined") { asDegrees = false; } + if (typeof output === "undefined") { output = new Phaser.Point(); } + if(asDegrees === true) { + angle = angle * Phaser.GameMath.DEG_TO_RAD; + } + output.x = this.x + this._radius * Math.cos(angle); + output.y = this.y + this._radius * Math.sin(angle); + return output; + }; + Circle.prototype.offset = function (dx, dy) { + if(!isNaN(dx) && !isNaN(dy)) { + this.x += dx; + this.y += dy; + } + return this; + }; + Circle.prototype.offsetPoint = function (point) { + return this.offset(point.x, point.y); + }; + Circle.prototype.setTo = function (x, y, diameter) { + this.x = x; + this.y = y; + this._diameter = diameter; + this._radius = diameter * 0.5; + return this; + }; + Circle.prototype.toString = function () { + return "[{Circle (x=" + this.x + " y=" + this.y + " diameter=" + this.diameter + " radius=" + this.radius + ")}]"; + }; + return Circle; + })(); + Phaser.Circle = Circle; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Line = (function () { + function Line(x1, y1, x2, y2) { + if (typeof x1 === "undefined") { x1 = 0; } + if (typeof y1 === "undefined") { y1 = 0; } + if (typeof x2 === "undefined") { x2 = 0; } + if (typeof y2 === "undefined") { y2 = 0; } + this.x1 = 0; + this.y1 = 0; + this.x2 = 0; + this.y2 = 0; + this.setTo(x1, y1, x2, y2); + } + Line.prototype.clone = function (output) { + if (typeof output === "undefined") { output = new Line(); } + return output.setTo(this.x1, this.y1, this.x2, this.y2); + }; + Line.prototype.copyFrom = function (source) { + return this.setTo(source.x1, source.y1, source.x2, source.y2); + }; + Line.prototype.copyTo = function (target) { + return target.copyFrom(this); + }; + Line.prototype.setTo = function (x1, y1, x2, y2) { + if (typeof x1 === "undefined") { x1 = 0; } + if (typeof y1 === "undefined") { y1 = 0; } + if (typeof x2 === "undefined") { x2 = 0; } + if (typeof y2 === "undefined") { y2 = 0; } + this.x1 = x1; + this.y1 = y1; + this.x2 = x2; + this.y2 = y2; + return this; + }; + Object.defineProperty(Line.prototype, "width", { + get: function () { + return Math.max(this.x1, this.x2) - Math.min(this.x1, this.x2); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Line.prototype, "height", { + get: function () { + return Math.max(this.y1, this.y2) - Math.min(this.y1, this.y2); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Line.prototype, "length", { + get: function () { + return Math.sqrt((this.x2 - this.x1) * (this.x2 - this.x1) + (this.y2 - this.y1) * (this.y2 - this.y1)); + }, + enumerable: true, + configurable: true + }); + Line.prototype.getY = function (x) { + return this.slope * x + this.yIntercept; + }; + Object.defineProperty(Line.prototype, "angle", { + get: function () { + return Math.atan2(this.x2 - this.x1, this.y2 - this.y1); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Line.prototype, "slope", { + get: function () { + return (this.y2 - this.y1) / (this.x2 - this.x1); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Line.prototype, "perpSlope", { + get: function () { + return -((this.x2 - this.x1) / (this.y2 - this.y1)); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Line.prototype, "yIntercept", { + get: function () { + return (this.y1 - this.slope * this.x1); + }, + enumerable: true, + configurable: true + }); + Line.prototype.isPointOnLine = function (x, y) { + if((x - this.x1) * (this.y2 - this.y1) === (this.x2 - this.x1) * (y - this.y1)) { + return true; + } else { + return false; + } + }; + Line.prototype.isPointOnLineSegment = function (x, y) { + var xMin = Math.min(this.x1, this.x2); + var xMax = Math.max(this.x1, this.x2); + var yMin = Math.min(this.y1, this.y2); + var yMax = Math.max(this.y1, this.y2); + if(this.isPointOnLine(x, y) && (x >= xMin && x <= xMax) && (y >= yMin && y <= yMax)) { + return true; + } else { + return false; + } + }; + Line.prototype.intersectLineLine = function (line) { + }; + Line.prototype.perp = function (x, y, output) { + if(this.y1 === this.y2) { + if(output) { + output.setTo(x, y, x, this.y1); + } else { + return new Line(x, y, x, this.y1); + } + } + var yInt = (y - this.perpSlope * x); + var pt = this.intersectLineLine({ + x1: x, + y1: y, + x2: 0, + y2: yInt + }); + if(output) { + output.setTo(x, y, pt.x, pt.y); + } else { + return new Line(x, y, pt.x, pt.y); + } + }; + Line.prototype.toString = function () { + return "[{Line (x1=" + this.x1 + " y1=" + this.y1 + " x2=" + this.x2 + " y2=" + this.y2 + ")}]"; + }; + return Line; + })(); + Phaser.Line = Line; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var IntersectResult = (function () { + function IntersectResult() { + this.result = false; + } + IntersectResult.prototype.setTo = function (x1, y1, x2, y2, width, height) { + if (typeof x2 === "undefined") { x2 = 0; } + if (typeof y2 === "undefined") { y2 = 0; } + if (typeof width === "undefined") { width = 0; } + if (typeof height === "undefined") { height = 0; } + this.x = x1; + this.y = y1; + this.x1 = x1; + this.y1 = y1; + this.x2 = x2; + this.y2 = y2; + this.width = width; + this.height = height; + }; + return IntersectResult; + })(); + Phaser.IntersectResult = IntersectResult; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var LinkedList = (function () { + function LinkedList() { + this.object = null; + this.next = null; + } + LinkedList.prototype.destroy = function () { + this.object = null; + if(this.next != null) { + this.next.destroy(); + } + this.next = null; + }; + return LinkedList; + })(); + Phaser.LinkedList = LinkedList; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var QuadTree = (function (_super) { + __extends(QuadTree, _super); + function QuadTree(X, Y, Width, Height, Parent) { + if (typeof Parent === "undefined") { Parent = null; } + _super.call(this, X, Y, Width, Height); + this._headA = this._tailA = new Phaser.LinkedList(); + this._headB = this._tailB = new Phaser.LinkedList(); + if(Parent != null) { + var iterator; + var ot; + if(Parent._headA.object != null) { + iterator = Parent._headA; + while(iterator != null) { + if(this._tailA.object != null) { + ot = this._tailA; + this._tailA = new Phaser.LinkedList(); + ot.next = this._tailA; + } + this._tailA.object = iterator.object; + iterator = iterator.next; + } + } + if(Parent._headB.object != null) { + iterator = Parent._headB; + while(iterator != null) { + if(this._tailB.object != null) { + ot = this._tailB; + this._tailB = new Phaser.LinkedList(); + ot.next = this._tailB; + } + this._tailB.object = iterator.object; + iterator = iterator.next; + } + } + } else { + QuadTree._min = (this.width + this.height) / (2 * QuadTree.divisions); + } + this._canSubdivide = (this.width > QuadTree._min) || (this.height > QuadTree._min); + this._northWestTree = null; + this._northEastTree = null; + this._southEastTree = null; + this._southWestTree = null; + this._leftEdge = this.x; + this._rightEdge = this.x + this.width; + this._halfWidth = this.width / 2; + this._midpointX = this._leftEdge + this._halfWidth; + this._topEdge = this.y; + this._bottomEdge = this.y + this.height; + this._halfHeight = this.height / 2; + this._midpointY = this._topEdge + this._halfHeight; + } + QuadTree.A_LIST = 0; + QuadTree.B_LIST = 1; + QuadTree.prototype.destroy = function () { + this._tailA.destroy(); + this._tailB.destroy(); + this._headA.destroy(); + this._headB.destroy(); + this._tailA = null; + this._tailB = null; + this._headA = null; + this._headB = null; + if(this._northWestTree != null) { + this._northWestTree.destroy(); + } + if(this._northEastTree != null) { + this._northEastTree.destroy(); + } + if(this._southEastTree != null) { + this._southEastTree.destroy(); + } + if(this._southWestTree != null) { + this._southWestTree.destroy(); + } + this._northWestTree = null; + this._northEastTree = null; + this._southEastTree = null; + this._southWestTree = null; + QuadTree._object = null; + QuadTree._processingCallback = null; + QuadTree._notifyCallback = null; + }; + QuadTree.prototype.load = function (ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, ProcessCallback) { + if (typeof ObjectOrGroup2 === "undefined") { ObjectOrGroup2 = null; } + if (typeof NotifyCallback === "undefined") { NotifyCallback = null; } + if (typeof ProcessCallback === "undefined") { ProcessCallback = null; } + this.add(ObjectOrGroup1, QuadTree.A_LIST); + if(ObjectOrGroup2 != null) { + this.add(ObjectOrGroup2, QuadTree.B_LIST); + QuadTree._useBothLists = true; + } else { + QuadTree._useBothLists = false; + } + QuadTree._notifyCallback = NotifyCallback; + QuadTree._processingCallback = ProcessCallback; + }; + QuadTree.prototype.add = function (ObjectOrGroup, List) { + QuadTree._list = List; + if(ObjectOrGroup.isGroup == true) { + var i = 0; + var basic; + var members = ObjectOrGroup['members']; + var l = ObjectOrGroup['length']; + while(i < l) { + basic = members[i++]; + if((basic != null) && basic.exists) { + if(basic.isGroup) { + this.add(basic, List); + } else { + QuadTree._object = basic; + if(QuadTree._object.exists && QuadTree._object.allowCollisions) { + QuadTree._objectLeftEdge = QuadTree._object.x; + QuadTree._objectTopEdge = QuadTree._object.y; + QuadTree._objectRightEdge = QuadTree._object.x + QuadTree._object.width; + QuadTree._objectBottomEdge = QuadTree._object.y + QuadTree._object.height; + this.addObject(); + } + } + } + } + } else { + QuadTree._object = ObjectOrGroup; + if(QuadTree._object.exists && QuadTree._object.allowCollisions) { + QuadTree._objectLeftEdge = QuadTree._object.x; + QuadTree._objectTopEdge = QuadTree._object.y; + QuadTree._objectRightEdge = QuadTree._object.x + QuadTree._object.width; + QuadTree._objectBottomEdge = QuadTree._object.y + QuadTree._object.height; + this.addObject(); + } + } + }; + QuadTree.prototype.addObject = function () { + if(!this._canSubdivide || ((this._leftEdge >= QuadTree._objectLeftEdge) && (this._rightEdge <= QuadTree._objectRightEdge) && (this._topEdge >= QuadTree._objectTopEdge) && (this._bottomEdge <= QuadTree._objectBottomEdge))) { + this.addToList(); + return; + } + if((QuadTree._objectLeftEdge > this._leftEdge) && (QuadTree._objectRightEdge < this._midpointX)) { + if((QuadTree._objectTopEdge > this._topEdge) && (QuadTree._objectBottomEdge < this._midpointY)) { + if(this._northWestTree == null) { + this._northWestTree = new QuadTree(this._leftEdge, this._topEdge, this._halfWidth, this._halfHeight, this); + } + this._northWestTree.addObject(); + return; + } + if((QuadTree._objectTopEdge > this._midpointY) && (QuadTree._objectBottomEdge < this._bottomEdge)) { + if(this._southWestTree == null) { + this._southWestTree = new QuadTree(this._leftEdge, this._midpointY, this._halfWidth, this._halfHeight, this); + } + this._southWestTree.addObject(); + return; + } + } + if((QuadTree._objectLeftEdge > this._midpointX) && (QuadTree._objectRightEdge < this._rightEdge)) { + if((QuadTree._objectTopEdge > this._topEdge) && (QuadTree._objectBottomEdge < this._midpointY)) { + if(this._northEastTree == null) { + this._northEastTree = new QuadTree(this._midpointX, this._topEdge, this._halfWidth, this._halfHeight, this); + } + this._northEastTree.addObject(); + return; + } + if((QuadTree._objectTopEdge > this._midpointY) && (QuadTree._objectBottomEdge < this._bottomEdge)) { + if(this._southEastTree == null) { + this._southEastTree = new QuadTree(this._midpointX, this._midpointY, this._halfWidth, this._halfHeight, this); + } + this._southEastTree.addObject(); + return; + } + } + if((QuadTree._objectRightEdge > this._leftEdge) && (QuadTree._objectLeftEdge < this._midpointX) && (QuadTree._objectBottomEdge > this._topEdge) && (QuadTree._objectTopEdge < this._midpointY)) { + if(this._northWestTree == null) { + this._northWestTree = new QuadTree(this._leftEdge, this._topEdge, this._halfWidth, this._halfHeight, this); + } + this._northWestTree.addObject(); + } + if((QuadTree._objectRightEdge > this._midpointX) && (QuadTree._objectLeftEdge < this._rightEdge) && (QuadTree._objectBottomEdge > this._topEdge) && (QuadTree._objectTopEdge < this._midpointY)) { + if(this._northEastTree == null) { + this._northEastTree = new QuadTree(this._midpointX, this._topEdge, this._halfWidth, this._halfHeight, this); + } + this._northEastTree.addObject(); + } + if((QuadTree._objectRightEdge > this._midpointX) && (QuadTree._objectLeftEdge < this._rightEdge) && (QuadTree._objectBottomEdge > this._midpointY) && (QuadTree._objectTopEdge < this._bottomEdge)) { + if(this._southEastTree == null) { + this._southEastTree = new QuadTree(this._midpointX, this._midpointY, this._halfWidth, this._halfHeight, this); + } + this._southEastTree.addObject(); + } + if((QuadTree._objectRightEdge > this._leftEdge) && (QuadTree._objectLeftEdge < this._midpointX) && (QuadTree._objectBottomEdge > this._midpointY) && (QuadTree._objectTopEdge < this._bottomEdge)) { + if(this._southWestTree == null) { + this._southWestTree = new QuadTree(this._leftEdge, this._midpointY, this._halfWidth, this._halfHeight, this); + } + this._southWestTree.addObject(); + } + }; + QuadTree.prototype.addToList = function () { + var ot; + if(QuadTree._list == QuadTree.A_LIST) { + if(this._tailA.object != null) { + ot = this._tailA; + this._tailA = new Phaser.LinkedList(); + ot.next = this._tailA; + } + this._tailA.object = QuadTree._object; + } else { + if(this._tailB.object != null) { + ot = this._tailB; + this._tailB = new Phaser.LinkedList(); + ot.next = this._tailB; + } + this._tailB.object = QuadTree._object; + } + if(!this._canSubdivide) { + return; + } + if(this._northWestTree != null) { + this._northWestTree.addToList(); + } + if(this._northEastTree != null) { + this._northEastTree.addToList(); + } + if(this._southEastTree != null) { + this._southEastTree.addToList(); + } + if(this._southWestTree != null) { + this._southWestTree.addToList(); + } + }; + QuadTree.prototype.execute = function () { + var overlapProcessed = false; + var iterator; + if(this._headA.object != null) { + iterator = this._headA; + while(iterator != null) { + QuadTree._object = iterator.object; + if(QuadTree._useBothLists) { + QuadTree._iterator = this._headB; + } else { + QuadTree._iterator = iterator.next; + } + if(QuadTree._object.exists && (QuadTree._object.allowCollisions > 0) && (QuadTree._iterator != null) && (QuadTree._iterator.object != null) && QuadTree._iterator.object.exists && this.overlapNode()) { + overlapProcessed = true; + } + iterator = iterator.next; + } + } + if((this._northWestTree != null) && this._northWestTree.execute()) { + overlapProcessed = true; + } + if((this._northEastTree != null) && this._northEastTree.execute()) { + overlapProcessed = true; + } + if((this._southEastTree != null) && this._southEastTree.execute()) { + overlapProcessed = true; + } + if((this._southWestTree != null) && this._southWestTree.execute()) { + overlapProcessed = true; + } + return overlapProcessed; + }; + QuadTree.prototype.overlapNode = function () { + var overlapProcessed = false; + var checkObject; + while(QuadTree._iterator != null) { + if(!QuadTree._object.exists || (QuadTree._object.allowCollisions <= 0)) { + break; + } + checkObject = QuadTree._iterator.object; + if((QuadTree._object === checkObject) || !checkObject.exists || (checkObject.allowCollisions <= 0)) { + QuadTree._iterator = QuadTree._iterator.next; + continue; + } + QuadTree._objectHullX = (QuadTree._object.x < QuadTree._object.last.x) ? QuadTree._object.x : QuadTree._object.last.x; + QuadTree._objectHullY = (QuadTree._object.y < QuadTree._object.last.y) ? QuadTree._object.y : QuadTree._object.last.y; + QuadTree._objectHullWidth = QuadTree._object.x - QuadTree._object.last.x; + QuadTree._objectHullWidth = QuadTree._object.width + ((QuadTree._objectHullWidth > 0) ? QuadTree._objectHullWidth : -QuadTree._objectHullWidth); + QuadTree._objectHullHeight = QuadTree._object.y - QuadTree._object.last.y; + QuadTree._objectHullHeight = QuadTree._object.height + ((QuadTree._objectHullHeight > 0) ? QuadTree._objectHullHeight : -QuadTree._objectHullHeight); + QuadTree._checkObjectHullX = (checkObject.x < checkObject.last.x) ? checkObject.x : checkObject.last.x; + QuadTree._checkObjectHullY = (checkObject.y < checkObject.last.y) ? checkObject.y : checkObject.last.y; + QuadTree._checkObjectHullWidth = checkObject.x - checkObject.last.x; + QuadTree._checkObjectHullWidth = checkObject.width + ((QuadTree._checkObjectHullWidth > 0) ? QuadTree._checkObjectHullWidth : -QuadTree._checkObjectHullWidth); + QuadTree._checkObjectHullHeight = checkObject.y - checkObject.last.y; + QuadTree._checkObjectHullHeight = checkObject.height + ((QuadTree._checkObjectHullHeight > 0) ? QuadTree._checkObjectHullHeight : -QuadTree._checkObjectHullHeight); + if((QuadTree._objectHullX + QuadTree._objectHullWidth > QuadTree._checkObjectHullX) && (QuadTree._objectHullX < QuadTree._checkObjectHullX + QuadTree._checkObjectHullWidth) && (QuadTree._objectHullY + QuadTree._objectHullHeight > QuadTree._checkObjectHullY) && (QuadTree._objectHullY < QuadTree._checkObjectHullY + QuadTree._checkObjectHullHeight)) { + if((QuadTree._processingCallback == null) || QuadTree._processingCallback(QuadTree._object, checkObject)) { + overlapProcessed = true; + } + if(overlapProcessed && (QuadTree._notifyCallback != null)) { + QuadTree._notifyCallback(QuadTree._object, checkObject); + } + } + QuadTree._iterator = QuadTree._iterator.next; + } + return overlapProcessed; + }; + return QuadTree; + })(Phaser.Rectangle); + Phaser.QuadTree = QuadTree; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Collision = (function () { + function Collision(game) { + this._game = game; + } + Collision.LEFT = 0x0001; + Collision.RIGHT = 0x0010; + Collision.UP = 0x0100; + Collision.DOWN = 0x1000; + Collision.NONE = 0; + Collision.CEILING = Collision.UP; + Collision.FLOOR = Collision.DOWN; + Collision.WALL = Collision.LEFT | Collision.RIGHT; + Collision.ANY = Collision.LEFT | Collision.RIGHT | Collision.UP | Collision.DOWN; + Collision.OVERLAP_BIAS = 4; + Collision.lineToLine = function lineToLine(line1, line2, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + var denominator = (line1.x1 - line1.x2) * (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * (line2.x1 - line2.x2); + if(denominator !== 0) { + output.result = true; + output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (line2.x1 - line2.x2) - (line1.x1 - line1.x2) * (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denominator; + output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denominator; + } + return output; + }; + Collision.lineToLineSegment = function lineToLineSegment(line, seg, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + var denominator = (line.x1 - line.x2) * (seg.y1 - seg.y2) - (line.y1 - line.y2) * (seg.x1 - seg.x2); + if(denominator !== 0) { + output.x = ((line.x1 * line.y2 - line.y1 * line.x2) * (seg.x1 - seg.x2) - (line.x1 - line.x2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denominator; + output.y = ((line.x1 * line.y2 - line.y1 * line.x2) * (seg.y1 - seg.y2) - (line.y1 - line.y2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denominator; + var maxX = Math.max(seg.x1, seg.x2); + var minX = Math.min(seg.x1, seg.x2); + var maxY = Math.max(seg.y1, seg.y2); + var minY = Math.min(seg.y1, seg.y2); + if((output.x <= maxX && output.x >= minX) === true || (output.y <= maxY && output.y >= minY) === true) { + output.result = true; + } + } + return output; + }; + Collision.lineToRawSegment = function lineToRawSegment(line, x1, y1, x2, y2, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + var denominator = (line.x1 - line.x2) * (y1 - y2) - (line.y1 - line.y2) * (x1 - x2); + if(denominator !== 0) { + output.x = ((line.x1 * line.y2 - line.y1 * line.x2) * (x1 - x2) - (line.x1 - line.x2) * (x1 * y2 - y1 * x2)) / denominator; + output.y = ((line.x1 * line.y2 - line.y1 * line.x2) * (y1 - y2) - (line.y1 - line.y2) * (x1 * y2 - y1 * x2)) / denominator; + var maxX = Math.max(x1, x2); + var minX = Math.min(x1, x2); + var maxY = Math.max(y1, y2); + var minY = Math.min(y1, y2); + if((output.x <= maxX && output.x >= minX) === true || (output.y <= maxY && output.y >= minY) === true) { + output.result = true; + } + } + return output; + }; + Collision.lineToRay = function lineToRay(line1, ray, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + var denominator = (line1.x1 - line1.x2) * (ray.y1 - ray.y2) - (line1.y1 - line1.y2) * (ray.x1 - ray.x2); + if(denominator !== 0) { + output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (ray.x1 - ray.x2) - (line1.x1 - line1.x2) * (ray.x1 * ray.y2 - ray.y1 * ray.x2)) / denominator; + output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (ray.y1 - ray.y2) - (line1.y1 - line1.y2) * (ray.x1 * ray.y2 - ray.y1 * ray.x2)) / denominator; + output.result = true; + if(!(ray.x1 >= ray.x2) && output.x < ray.x1) { + output.result = false; + } + if(!(ray.y1 >= ray.y2) && output.y < ray.y1) { + output.result = false; + } + } + return output; + }; + Collision.lineToCircle = function lineToCircle(line, circle, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + if(line.perp(circle.x, circle.y).length <= circle.radius) { + output.result = true; + } + return output; + }; + Collision.lineToRectangle = function lineToRectangle(line, rect, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + Collision.lineToRawSegment(line, rect.x, rect.y, rect.right, rect.y, output); + if(output.result === true) { + return output; + } + Collision.lineToRawSegment(line, rect.x, rect.y, rect.x, rect.bottom, output); + if(output.result === true) { + return output; + } + Collision.lineToRawSegment(line, rect.x, rect.bottom, rect.right, rect.bottom, output); + if(output.result === true) { + return output; + } + Collision.lineToRawSegment(line, rect.right, rect.y, rect.right, rect.bottom, output); + return output; + }; + Collision.lineSegmentToLineSegment = function lineSegmentToLineSegment(line1, line2, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + Collision.lineToLineSegment(line1, line2); + if(output.result === true) { + if(!(output.x >= Math.min(line1.x1, line1.x2) && output.x <= Math.max(line1.x1, line1.x2) && output.y >= Math.min(line1.y1, line1.y2) && output.y <= Math.max(line1.y1, line1.y2))) { + output.result = false; + } + } + return output; + }; + Collision.lineSegmentToRay = function lineSegmentToRay(line, ray, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + Collision.lineToRay(line, ray, output); + if(output.result === true) { + if(!(output.x >= Math.min(line.x1, line.x2) && output.x <= Math.max(line.x1, line.x2) && output.y >= Math.min(line.y1, line.y2) && output.y <= Math.max(line.y1, line.y2))) { + output.result = false; + } + } + return output; + }; + Collision.lineSegmentToCircle = function lineSegmentToCircle(seg, circle, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + var perp = seg.perp(circle.x, circle.y); + if(perp.length <= circle.radius) { + var maxX = Math.max(seg.x1, seg.x2); + var minX = Math.min(seg.x1, seg.x2); + var maxY = Math.max(seg.y1, seg.y2); + var minY = Math.min(seg.y1, seg.y2); + if((perp.x2 <= maxX && perp.x2 >= minX) && (perp.y2 <= maxY && perp.y2 >= minY)) { + output.result = true; + } else { + if(Collision.circleContainsPoint(circle, { + x: seg.x1, + y: seg.y1 + }) || Collision.circleContainsPoint(circle, { + x: seg.x2, + y: seg.y2 + })) { + output.result = true; + } + } + } + return output; + }; + Collision.lineSegmentToRectangle = function lineSegmentToRectangle(seg, rect, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + if(rect.contains(seg.x1, seg.y1) && rect.contains(seg.x2, seg.y2)) { + output.result = true; + } else { + Collision.lineToRawSegment(seg, rect.x, rect.y, rect.right, rect.bottom, output); + if(output.result === true) { + return output; + } + Collision.lineToRawSegment(seg, rect.x, rect.y, rect.x, rect.bottom, output); + if(output.result === true) { + return output; + } + Collision.lineToRawSegment(seg, rect.x, rect.bottom, rect.right, rect.bottom, output); + if(output.result === true) { + return output; + } + Collision.lineToRawSegment(seg, rect.right, rect.y, rect.right, rect.bottom, output); + return output; + } + return output; + }; + Collision.rayToRectangle = function rayToRectangle(ray, rect, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + Collision.lineToRectangle(ray, rect, output); + return output; + }; + Collision.rayToLineSegment = function rayToLineSegment(rayX1, rayY1, rayX2, rayY2, lineX1, lineY1, lineX2, lineY2, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + var r; + var s; + var d; + if((rayY2 - rayY1) / (rayX2 - rayX1) != (lineY2 - lineY1) / (lineX2 - lineX1)) { + d = (((rayX2 - rayX1) * (lineY2 - lineY1)) - (rayY2 - rayY1) * (lineX2 - lineX1)); + if(d != 0) { + r = (((rayY1 - lineY1) * (lineX2 - lineX1)) - (rayX1 - lineX1) * (lineY2 - lineY1)) / d; + s = (((rayY1 - lineY1) * (rayX2 - rayX1)) - (rayX1 - lineX1) * (rayY2 - rayY1)) / d; + if(r >= 0) { + if(s >= 0 && s <= 1) { + output.result = true; + output.x = rayX1 + r * (rayX2 - rayX1); + output.y = rayY1 + r * (rayY2 - rayY1); + } + } + } + } + return output; + }; + Collision.pointToRectangle = function pointToRectangle(point, rect, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + output.setTo(point.x, point.y); + output.result = rect.containsPoint(point); + return output; + }; + Collision.rectangleToRectangle = function rectangleToRectangle(rect1, rect2, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + var leftX = Math.max(rect1.x, rect2.x); + var rightX = Math.min(rect1.right, rect2.right); + var topY = Math.max(rect1.y, rect2.y); + var bottomY = Math.min(rect1.bottom, rect2.bottom); + output.setTo(leftX, topY, rightX - leftX, bottomY - topY, rightX - leftX, bottomY - topY); + var cx = output.x + output.width * .5; + var cy = output.y + output.height * .5; + if((cx > rect1.x && cx < rect1.right) && (cy > rect1.y && cy < rect1.bottom)) { + output.result = true; + } + return output; + }; + Collision.rectangleToCircle = function rectangleToCircle(rect, circle, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + return Collision.circleToRectangle(circle, rect, output); + }; + Collision.circleToCircle = function circleToCircle(circle1, circle2, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + output.result = ((circle1.radius + circle2.radius) * (circle1.radius + circle2.radius)) >= Collision.distanceSquared(circle1.x, circle1.y, circle2.x, circle2.y); + return output; + }; + Collision.circleToRectangle = function circleToRectangle(circle, rect, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + var inflatedRect = rect.clone(); + inflatedRect.inflate(circle.radius, circle.radius); + output.result = inflatedRect.contains(circle.x, circle.y); + return output; + }; + Collision.circleContainsPoint = function circleContainsPoint(circle, point, output) { + if (typeof output === "undefined") { output = new Phaser.IntersectResult(); } + output.result = circle.radius * circle.radius >= Collision.distanceSquared(circle.x, circle.y, point.x, point.y); + return output; + }; + Collision.prototype.overlap = function (object1, object2, notifyCallback, processCallback) { + if (typeof object1 === "undefined") { object1 = null; } + if (typeof object2 === "undefined") { object2 = null; } + if (typeof notifyCallback === "undefined") { notifyCallback = null; } + if (typeof processCallback === "undefined") { processCallback = null; } + if(object1 == null) { + object1 = this._game.world.group; + } + if(object2 == object1) { + object2 = null; + } + Phaser.QuadTree.divisions = this._game.world.worldDivisions; + var quadTree = new Phaser.QuadTree(this._game.world.bounds.x, this._game.world.bounds.y, this._game.world.bounds.width, this._game.world.bounds.height); + quadTree.load(object1, object2, notifyCallback, processCallback); + var result = quadTree.execute(); + quadTree.destroy(); + quadTree = null; + return result; + }; + Collision.separate = function separate(object1, object2) { + var separatedX = Collision.separateX(object1, object2); + var separatedY = Collision.separateY(object1, object2); + return separatedX || separatedY; + }; + Collision.separateTile = function separateTile(object, tile) { + var separatedX = Collision.separateTileX(object, tile); + var separatedY = Collision.separateTileY(object, tile); + return separatedX || separatedY; + }; + Collision.separateTileX = function separateTileX(object, tile) { + if(object.immovable && tile.immovable) { + return false; + } + var overlap = 0; + var objDelta = object.x - object.last.x; + var tileDelta = 0; + if(objDelta != tileDelta) { + var objDeltaAbs = (objDelta > 0) ? objDelta : -objDelta; + var tileDeltaAbs = (tileDelta > 0) ? tileDelta : -tileDelta; + var objBounds = new Phaser.Quad(object.x - ((objDelta > 0) ? objDelta : 0), object.last.y, object.width + ((objDelta > 0) ? objDelta : -objDelta), object.height); + var tileBounds = new Phaser.Quad(tile.x - ((tileDelta > 0) ? tileDelta : 0), tile.y, tile.width + ((tileDelta > 0) ? tileDelta : -tileDelta), tile.height); + if((objBounds.x + objBounds.width > tileBounds.x) && (objBounds.x < tileBounds.x + tileBounds.width) && (objBounds.y + objBounds.height > tileBounds.y) && (objBounds.y < tileBounds.y + tileBounds.height)) { + var maxOverlap = objDeltaAbs + tileDeltaAbs + Collision.OVERLAP_BIAS; + if(objDelta > tileDelta) { + overlap = object.x + object.width - tile.x; + if((overlap > maxOverlap) || !(object.allowCollisions & Collision.RIGHT) || !(tile.allowCollisions & Collision.LEFT)) { + overlap = 0; + } else { + object.touching |= Collision.RIGHT; + } + } else if(objDelta < tileDelta) { + overlap = object.x - tile.width - tile.x; + if((-overlap > maxOverlap) || !(object.allowCollisions & Collision.LEFT) || !(tile.allowCollisions & Collision.RIGHT)) { + overlap = 0; + } else { + object.touching |= Collision.LEFT; + } + } + } + } + if(overlap != 0) { + var objVelocity = object.velocity.x; + var tileVelocity = 0; + if(!object.immovable && !tile.immovable) { + overlap *= 0.5; + object.x = object.x - overlap; + var objNewVelocity = Math.sqrt((tileVelocity * tileVelocity * tile.mass) / object.mass) * ((tileVelocity > 0) ? 1 : -1); + var tileNewVelocity = Math.sqrt((objVelocity * objVelocity * object.mass) / tile.mass) * ((objVelocity > 0) ? 1 : -1); + var average = (objNewVelocity + tileNewVelocity) * 0.5; + objNewVelocity -= average; + object.velocity.x = average + objNewVelocity * object.elasticity; + } else if(!object.immovable) { + object.x = object.x - overlap; + object.velocity.x = tileVelocity - objVelocity * object.elasticity; + } + return true; + } else { + return false; + } + }; + Collision.separateTileY = function separateTileY(object, tile) { + if(object.immovable && tile.immovable) { + return false; + } + var overlap = 0; + var objDelta = object.y - object.last.y; + var tileDelta = 0; + if(objDelta != tileDelta) { + var objDeltaAbs = (objDelta > 0) ? objDelta : -objDelta; + var tileDeltaAbs = (tileDelta > 0) ? tileDelta : -tileDelta; + var objBounds = new Phaser.Quad(object.x, object.y - ((objDelta > 0) ? objDelta : 0), object.width, object.height + objDeltaAbs); + var tileBounds = new Phaser.Quad(tile.x, tile.y - ((tileDelta > 0) ? tileDelta : 0), tile.width, tile.height + tileDeltaAbs); + if((objBounds.x + objBounds.width > tileBounds.x) && (objBounds.x < tileBounds.x + tileBounds.width) && (objBounds.y + objBounds.height > tileBounds.y) && (objBounds.y < tileBounds.y + tileBounds.height)) { + var maxOverlap = objDeltaAbs + tileDeltaAbs + Collision.OVERLAP_BIAS; + if(objDelta > tileDelta) { + overlap = object.y + object.height - tile.y; + if((overlap > maxOverlap) || !(object.allowCollisions & Collision.DOWN) || !(tile.allowCollisions & Collision.UP)) { + overlap = 0; + } else { + object.touching |= Collision.DOWN; + } + } else if(objDelta < tileDelta) { + overlap = object.y - tile.height - tile.y; + if((-overlap > maxOverlap) || !(object.allowCollisions & Collision.UP) || !(tile.allowCollisions & Collision.DOWN)) { + overlap = 0; + } else { + object.touching |= Collision.UP; + } + } + } + } + if(overlap != 0) { + var objVelocity = object.velocity.y; + var tileVelocity = 0; + if(!object.immovable && !tile.immovable) { + overlap *= 0.5; + object.y = object.y - overlap; + var objNewVelocity = Math.sqrt((tileVelocity * tileVelocity * tile.mass) / object.mass) * ((tileVelocity > 0) ? 1 : -1); + var tileNewVelocity = Math.sqrt((objVelocity * objVelocity * object.mass) / tile.mass) * ((objVelocity > 0) ? 1 : -1); + var average = (objNewVelocity + tileNewVelocity) * 0.5; + objNewVelocity -= average; + object.velocity.y = average + objNewVelocity * object.elasticity; + } else if(!object.immovable) { + object.y = object.y - overlap; + object.velocity.y = tileVelocity - objVelocity * object.elasticity; + if(tile.active && tile.moves && (objDelta > tileDelta)) { + } + } + return true; + } else { + return false; + } + }; + Collision.separateX = function separateX(object1, object2) { + if(object1.immovable && object2.immovable) { + return false; + } + var overlap = 0; + var obj1Delta = object1.x - object1.last.x; + var obj2Delta = object2.x - object2.last.x; + if(obj1Delta != obj2Delta) { + var obj1DeltaAbs = (obj1Delta > 0) ? obj1Delta : -obj1Delta; + var obj2DeltaAbs = (obj2Delta > 0) ? obj2Delta : -obj2Delta; + var obj1Bounds = new Phaser.Quad(object1.x - ((obj1Delta > 0) ? obj1Delta : 0), object1.last.y, object1.width + ((obj1Delta > 0) ? obj1Delta : -obj1Delta), object1.height); + var obj2Bounds = new Phaser.Quad(object2.x - ((obj2Delta > 0) ? obj2Delta : 0), object2.last.y, object2.width + ((obj2Delta > 0) ? obj2Delta : -obj2Delta), object2.height); + if((obj1Bounds.x + obj1Bounds.width > obj2Bounds.x) && (obj1Bounds.x < obj2Bounds.x + obj2Bounds.width) && (obj1Bounds.y + obj1Bounds.height > obj2Bounds.y) && (obj1Bounds.y < obj2Bounds.y + obj2Bounds.height)) { + var maxOverlap = obj1DeltaAbs + obj2DeltaAbs + Collision.OVERLAP_BIAS; + if(obj1Delta > obj2Delta) { + overlap = object1.x + object1.width - object2.x; + if((overlap > maxOverlap) || !(object1.allowCollisions & Collision.RIGHT) || !(object2.allowCollisions & Collision.LEFT)) { + overlap = 0; + } else { + object1.touching |= Collision.RIGHT; + object2.touching |= Collision.LEFT; + } + } else if(obj1Delta < obj2Delta) { + overlap = object1.x - object2.width - object2.x; + if((-overlap > maxOverlap) || !(object1.allowCollisions & Collision.LEFT) || !(object2.allowCollisions & Collision.RIGHT)) { + overlap = 0; + } else { + object1.touching |= Collision.LEFT; + object2.touching |= Collision.RIGHT; + } + } + } + } + if(overlap != 0) { + var obj1Velocity = object1.velocity.x; + var obj2Velocity = object2.velocity.x; + if(!object1.immovable && !object2.immovable) { + overlap *= 0.5; + object1.x = object1.x - overlap; + object2.x += overlap; + var obj1NewVelocity = Math.sqrt((obj2Velocity * obj2Velocity * object2.mass) / object1.mass) * ((obj2Velocity > 0) ? 1 : -1); + var obj2NewVelocity = Math.sqrt((obj1Velocity * obj1Velocity * object1.mass) / object2.mass) * ((obj1Velocity > 0) ? 1 : -1); + var average = (obj1NewVelocity + obj2NewVelocity) * 0.5; + obj1NewVelocity -= average; + obj2NewVelocity -= average; + object1.velocity.x = average + obj1NewVelocity * object1.elasticity; + object2.velocity.x = average + obj2NewVelocity * object2.elasticity; + } else if(!object1.immovable) { + object1.x = object1.x - overlap; + object1.velocity.x = obj2Velocity - obj1Velocity * object1.elasticity; + } else if(!object2.immovable) { + object2.x += overlap; + object2.velocity.x = obj1Velocity - obj2Velocity * object2.elasticity; + } + return true; + } else { + return false; + } + }; + Collision.separateY = function separateY(object1, object2) { + if(object1.immovable && object2.immovable) { + return false; + } + var overlap = 0; + var obj1Delta = object1.y - object1.last.y; + var obj2Delta = object2.y - object2.last.y; + if(obj1Delta != obj2Delta) { + var obj1DeltaAbs = (obj1Delta > 0) ? obj1Delta : -obj1Delta; + var obj2DeltaAbs = (obj2Delta > 0) ? obj2Delta : -obj2Delta; + var obj1Bounds = new Phaser.Quad(object1.x, object1.y - ((obj1Delta > 0) ? obj1Delta : 0), object1.width, object1.height + obj1DeltaAbs); + var obj2Bounds = new Phaser.Quad(object2.x, object2.y - ((obj2Delta > 0) ? obj2Delta : 0), object2.width, object2.height + obj2DeltaAbs); + if((obj1Bounds.x + obj1Bounds.width > obj2Bounds.x) && (obj1Bounds.x < obj2Bounds.x + obj2Bounds.width) && (obj1Bounds.y + obj1Bounds.height > obj2Bounds.y) && (obj1Bounds.y < obj2Bounds.y + obj2Bounds.height)) { + var maxOverlap = obj1DeltaAbs + obj2DeltaAbs + Collision.OVERLAP_BIAS; + if(obj1Delta > obj2Delta) { + overlap = object1.y + object1.height - object2.y; + if((overlap > maxOverlap) || !(object1.allowCollisions & Collision.DOWN) || !(object2.allowCollisions & Collision.UP)) { + overlap = 0; + } else { + object1.touching |= Collision.DOWN; + object2.touching |= Collision.UP; + } + } else if(obj1Delta < obj2Delta) { + overlap = object1.y - object2.height - object2.y; + if((-overlap > maxOverlap) || !(object1.allowCollisions & Collision.UP) || !(object2.allowCollisions & Collision.DOWN)) { + overlap = 0; + } else { + object1.touching |= Collision.UP; + object2.touching |= Collision.DOWN; + } + } + } + } + if(overlap != 0) { + var obj1Velocity = object1.velocity.y; + var obj2Velocity = object2.velocity.y; + if(!object1.immovable && !object2.immovable) { + overlap *= 0.5; + object1.y = object1.y - overlap; + object2.y += overlap; + var obj1NewVelocity = Math.sqrt((obj2Velocity * obj2Velocity * object2.mass) / object1.mass) * ((obj2Velocity > 0) ? 1 : -1); + var obj2NewVelocity = Math.sqrt((obj1Velocity * obj1Velocity * object1.mass) / object2.mass) * ((obj1Velocity > 0) ? 1 : -1); + var average = (obj1NewVelocity + obj2NewVelocity) * 0.5; + obj1NewVelocity -= average; + obj2NewVelocity -= average; + object1.velocity.y = average + obj1NewVelocity * object1.elasticity; + object2.velocity.y = average + obj2NewVelocity * object2.elasticity; + } else if(!object1.immovable) { + object1.y = object1.y - overlap; + object1.velocity.y = obj2Velocity - obj1Velocity * object1.elasticity; + if(object2.active && object2.moves && (obj1Delta > obj2Delta)) { + object1.x += object2.x - object2.last.x; + } + } else if(!object2.immovable) { + object2.y += overlap; + object2.velocity.y = obj1Velocity - obj2Velocity * object2.elasticity; + if(object1.active && object1.moves && (obj1Delta < obj2Delta)) { + object2.x += object1.x - object1.last.x; + } + } + return true; + } else { + return false; + } + }; + Collision.distance = function distance(x1, y1, x2, y2) { + return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); + }; + Collision.distanceSquared = function distanceSquared(x1, y1, x2, y2) { + return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1); + }; + return Collision; + })(); + Phaser.Collision = Collision; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var DynamicTexture = (function () { + function DynamicTexture(game, width, height) { + this._sx = 0; + this._sy = 0; + this._sw = 0; + this._sh = 0; + this._dx = 0; + this._dy = 0; + this._dw = 0; + this._dh = 0; + this._game = game; + this.canvas = document.createElement('canvas'); + this.canvas.width = width; + this.canvas.height = height; + this.context = this.canvas.getContext('2d'); + this.bounds = new Phaser.Rectangle(0, 0, width, height); + } + DynamicTexture.prototype.getPixel = function (x, y) { + var imageData = this.context.getImageData(x, y, 1, 1); + return this.getColor(imageData.data[0], imageData.data[1], imageData.data[2]); + }; + DynamicTexture.prototype.getPixel32 = function (x, y) { + var imageData = this.context.getImageData(x, y, 1, 1); + return this.getColor32(imageData.data[3], imageData.data[0], imageData.data[1], imageData.data[2]); + }; + DynamicTexture.prototype.getPixels = function (rect) { + return this.context.getImageData(rect.x, rect.y, rect.width, rect.height); + }; + DynamicTexture.prototype.setPixel = function (x, y, color) { + this.context.fillStyle = color; + this.context.fillRect(x, y, 1, 1); + }; + DynamicTexture.prototype.setPixel32 = function (x, y, color) { + this.context.fillStyle = color; + this.context.fillRect(x, y, 1, 1); + }; + DynamicTexture.prototype.setPixels = function (rect, input) { + this.context.putImageData(input, rect.x, rect.y); + }; + DynamicTexture.prototype.fillRect = function (rect, color) { + this.context.fillStyle = color; + this.context.fillRect(rect.x, rect.y, rect.width, rect.height); + }; + DynamicTexture.prototype.pasteImage = function (key, frame, destX, destY, destWidth, destHeight) { + if (typeof frame === "undefined") { frame = -1; } + if (typeof destX === "undefined") { destX = 0; } + if (typeof destY === "undefined") { destY = 0; } + if (typeof destWidth === "undefined") { destWidth = null; } + if (typeof destHeight === "undefined") { destHeight = null; } + var texture = null; + var frameData; + this._sx = 0; + this._sy = 0; + this._dx = destX; + this._dy = destY; + if(frame > -1) { + } else { + texture = this._game.cache.getImage(key); + this._sw = texture.width; + this._sh = texture.height; + this._dw = texture.width; + this._dh = texture.height; + } + if(destWidth !== null) { + this._dw = destWidth; + } + if(destHeight !== null) { + this._dh = destHeight; + } + if(texture != null) { + this.context.drawImage(texture, this._sx, this._sy, this._sw, this._sh, this._dx, this._dy, this._dw, this._dh); + } + }; + DynamicTexture.prototype.copyPixels = function (sourceTexture, sourceRect, destPoint) { + if(sourceRect.equals(this.bounds) == true) { + this.context.drawImage(sourceTexture.canvas, destPoint.x, destPoint.y); + } else { + this.context.putImageData(sourceTexture.getPixels(sourceRect), destPoint.x, destPoint.y); + } + }; + DynamicTexture.prototype.clear = function () { + this.context.clearRect(0, 0, this.bounds.width, this.bounds.height); + }; + Object.defineProperty(DynamicTexture.prototype, "width", { + get: function () { + return this.bounds.width; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DynamicTexture.prototype, "height", { + get: function () { + return this.bounds.height; + }, + enumerable: true, + configurable: true + }); + DynamicTexture.prototype.getColor32 = function (alpha, red, green, blue) { + return alpha << 24 | red << 16 | green << 8 | blue; + }; + DynamicTexture.prototype.getColor = function (red, green, blue) { + return red << 16 | green << 8 | blue; + }; + return DynamicTexture; + })(); + Phaser.DynamicTexture = DynamicTexture; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var GameMath = (function () { + function GameMath(game) { + this.cosTable = []; + this.sinTable = []; + this.globalSeed = Math.random(); + this._game = game; + } + GameMath.PI = 3.141592653589793; + GameMath.PI_2 = 1.5707963267948965; + GameMath.PI_4 = 0.7853981633974483; + GameMath.PI_8 = 0.39269908169872413; + GameMath.PI_16 = 0.19634954084936206; + GameMath.TWO_PI = 6.283185307179586; + GameMath.THREE_PI_2 = 4.7123889803846895; + GameMath.E = 2.71828182845905; + GameMath.LN10 = 2.302585092994046; + GameMath.LN2 = 0.6931471805599453; + GameMath.LOG10E = 0.4342944819032518; + GameMath.LOG2E = 1.442695040888963387; + GameMath.SQRT1_2 = 0.7071067811865476; + GameMath.SQRT2 = 1.4142135623730951; + GameMath.DEG_TO_RAD = 0.017453292519943294444444444444444; + GameMath.RAD_TO_DEG = 57.295779513082325225835265587527; + GameMath.B_16 = 65536; + GameMath.B_31 = 2147483648; + GameMath.B_32 = 4294967296; + GameMath.B_48 = 281474976710656; + GameMath.B_53 = 9007199254740992; + GameMath.B_64 = 18446744073709551616; + GameMath.ONE_THIRD = 0.333333333333333333333333333333333; + GameMath.TWO_THIRDS = 0.666666666666666666666666666666666; + GameMath.ONE_SIXTH = 0.166666666666666666666666666666666; + GameMath.COS_PI_3 = 0.86602540378443864676372317075294; + GameMath.SIN_2PI_3 = 0.03654595; + GameMath.CIRCLE_ALPHA = 0.5522847498307933984022516322796; + GameMath.ON = true; + GameMath.OFF = false; + GameMath.SHORT_EPSILON = 0.1; + GameMath.PERC_EPSILON = 0.001; + GameMath.EPSILON = 0.0001; + GameMath.LONG_EPSILON = 0.00000001; + GameMath.prototype.fuzzyEqual = function (a, b, epsilon) { + if (typeof epsilon === "undefined") { epsilon = 0.0001; } + return Math.abs(a - b) < epsilon; + }; + GameMath.prototype.fuzzyLessThan = function (a, b, epsilon) { + if (typeof epsilon === "undefined") { epsilon = 0.0001; } + return a < b + epsilon; + }; + GameMath.prototype.fuzzyGreaterThan = function (a, b, epsilon) { + if (typeof epsilon === "undefined") { epsilon = 0.0001; } + return a > b - epsilon; + }; + GameMath.prototype.fuzzyCeil = function (val, epsilon) { + if (typeof epsilon === "undefined") { epsilon = 0.0001; } + return Math.ceil(val - epsilon); + }; + GameMath.prototype.fuzzyFloor = function (val, epsilon) { + if (typeof epsilon === "undefined") { epsilon = 0.0001; } + return Math.floor(val + epsilon); + }; + GameMath.prototype.average = function () { + var args = []; + for (var _i = 0; _i < (arguments.length - 0); _i++) { + args[_i] = arguments[_i + 0]; + } + var avg = 0; + for(var i = 0; i < args.length; i++) { + avg += args[i]; + } + return avg / args.length; + }; + GameMath.prototype.slam = function (value, target, epsilon) { + if (typeof epsilon === "undefined") { epsilon = 0.0001; } + return (Math.abs(value - target) < epsilon) ? target : value; + }; + GameMath.prototype.percentageMinMax = function (val, max, min) { + if (typeof min === "undefined") { min = 0; } + val -= min; + max -= min; + if(!max) { + return 0; + } else { + return val / max; + } + }; + GameMath.prototype.sign = function (n) { + if(n) { + return n / Math.abs(n); + } else { + return 0; + } + }; + GameMath.prototype.truncate = function (n) { + return (n > 0) ? Math.floor(n) : Math.ceil(n); + }; + GameMath.prototype.shear = function (n) { + return n % 1; + }; + GameMath.prototype.wrap = function (val, max, min) { + if (typeof min === "undefined") { min = 0; } + val -= min; + max -= min; + if(max == 0) { + return min; + } + val %= max; + val += min; + while(val < min) { + val += max; + } + return val; + }; + GameMath.prototype.arithWrap = function (value, max, min) { + if (typeof min === "undefined") { min = 0; } + max -= min; + if(max == 0) { + return min; + } + return value - max * Math.floor((value - min) / max); + }; + GameMath.prototype.clamp = function (input, max, min) { + if (typeof min === "undefined") { min = 0; } + return Math.max(min, Math.min(max, input)); + }; + GameMath.prototype.snapTo = function (input, gap, start) { + if (typeof start === "undefined") { start = 0; } + if(gap == 0) { + return input; + } + input -= start; + input = gap * Math.round(input / gap); + return start + input; + }; + GameMath.prototype.snapToFloor = function (input, gap, start) { + if (typeof start === "undefined") { start = 0; } + if(gap == 0) { + return input; + } + input -= start; + input = gap * Math.floor(input / gap); + return start + input; + }; + GameMath.prototype.snapToCeil = function (input, gap, start) { + if (typeof start === "undefined") { start = 0; } + if(gap == 0) { + return input; + } + input -= start; + input = gap * Math.ceil(input / gap); + return start + input; + }; + GameMath.prototype.snapToInArray = function (input, arr, sort) { + if (typeof sort === "undefined") { sort = true; } + if(sort) { + arr.sort(); + } + if(input < arr[0]) { + return arr[0]; + } + var i = 1; + while(arr[i] < input) { + i++; + } + var low = arr[i - 1]; + var high = (i < arr.length) ? arr[i] : Number.POSITIVE_INFINITY; + return ((high - input) <= (input - low)) ? high : low; + }; + GameMath.prototype.roundTo = function (value, place, base) { + if (typeof place === "undefined") { place = 0; } + if (typeof base === "undefined") { base = 10; } + var p = Math.pow(base, -place); + return Math.round(value * p) / p; + }; + GameMath.prototype.floorTo = function (value, place, base) { + if (typeof place === "undefined") { place = 0; } + if (typeof base === "undefined") { base = 10; } + var p = Math.pow(base, -place); + return Math.floor(value * p) / p; + }; + GameMath.prototype.ceilTo = function (value, place, base) { + if (typeof place === "undefined") { place = 0; } + if (typeof base === "undefined") { base = 10; } + var p = Math.pow(base, -place); + return Math.ceil(value * p) / p; + }; + GameMath.prototype.interpolateFloat = function (a, b, weight) { + return (b - a) * weight + a; + }; + GameMath.prototype.radiansToDegrees = function (angle) { + return angle * GameMath.RAD_TO_DEG; + }; + GameMath.prototype.degreesToRadians = function (angle) { + return angle * GameMath.DEG_TO_RAD; + }; + GameMath.prototype.angleBetween = function (x1, y1, x2, y2) { + return Math.atan2(y2 - y1, x2 - x1); + }; + GameMath.prototype.normalizeAngle = function (angle, radians) { + if (typeof radians === "undefined") { radians = true; } + var rd = (radians) ? GameMath.PI : 180; + return this.wrap(angle, rd, -rd); + }; + GameMath.prototype.nearestAngleBetween = function (a1, a2, radians) { + if (typeof radians === "undefined") { radians = true; } + var rd = (radians) ? GameMath.PI : 180; + a1 = this.normalizeAngle(a1, radians); + a2 = this.normalizeAngle(a2, radians); + if(a1 < -rd / 2 && a2 > rd / 2) { + a1 += rd * 2; + } + if(a2 < -rd / 2 && a1 > rd / 2) { + a2 += rd * 2; + } + return a2 - a1; + }; + GameMath.prototype.normalizeAngleToAnother = function (dep, ind, radians) { + if (typeof radians === "undefined") { radians = true; } + return ind + this.nearestAngleBetween(ind, dep, radians); + }; + GameMath.prototype.normalizeAngleAfterAnother = function (dep, ind, radians) { + if (typeof radians === "undefined") { radians = true; } + dep = this.normalizeAngle(dep - ind, radians); + return ind + dep; + }; + GameMath.prototype.normalizeAngleBeforeAnother = function (dep, ind, radians) { + if (typeof radians === "undefined") { radians = true; } + dep = this.normalizeAngle(ind - dep, radians); + return ind - dep; + }; + GameMath.prototype.interpolateAngles = function (a1, a2, weight, radians, ease) { + if (typeof radians === "undefined") { radians = true; } + if (typeof ease === "undefined") { ease = null; } + a1 = this.normalizeAngle(a1, radians); + a2 = this.normalizeAngleToAnother(a2, a1, radians); + return (typeof ease === 'function') ? ease(weight, a1, a2 - a1, 1) : this.interpolateFloat(a1, a2, weight); + }; + GameMath.prototype.logBaseOf = function (value, base) { + return Math.log(value) / Math.log(base); + }; + GameMath.prototype.GCD = function (m, n) { + var r; + m = Math.abs(m); + n = Math.abs(n); + if(m < n) { + r = m; + m = n; + n = r; + } + while(true) { + r = m % n; + if(!r) { + return n; + } + m = n; + n = r; + } + return 1; + }; + GameMath.prototype.LCM = function (m, n) { + return (m * n) / this.GCD(m, n); + }; + GameMath.prototype.factorial = function (value) { + if(value == 0) { + return 1; + } + var res = value; + while(--value) { + res *= value; + } + return res; + }; + GameMath.prototype.gammaFunction = function (value) { + return this.factorial(value - 1); + }; + GameMath.prototype.fallingFactorial = function (base, exp) { + return this.factorial(base) / this.factorial(base - exp); + }; + GameMath.prototype.risingFactorial = function (base, exp) { + return this.factorial(base + exp - 1) / this.factorial(base - 1); + }; + GameMath.prototype.binCoef = function (n, k) { + return this.fallingFactorial(n, k) / this.factorial(k); + }; + GameMath.prototype.risingBinCoef = function (n, k) { + return this.risingFactorial(n, k) / this.factorial(k); + }; + GameMath.prototype.chanceRoll = function (chance) { + if (typeof chance === "undefined") { chance = 50; } + if(chance <= 0) { + return false; + } else if(chance >= 100) { + return true; + } else { + if(Math.random() * 100 >= chance) { + return false; + } else { + return true; + } + } + }; + GameMath.prototype.maxAdd = function (value, amount, max) { + value += amount; + if(value > max) { + value = max; + } + return value; + }; + GameMath.prototype.minSub = function (value, amount, min) { + value -= amount; + if(value < min) { + value = min; + } + return value; + }; + GameMath.prototype.wrapValue = function (value, amount, max) { + var diff; + value = Math.abs(value); + amount = Math.abs(amount); + max = Math.abs(max); + diff = (value + amount) % max; + return diff; + }; + GameMath.prototype.randomSign = function () { + return (Math.random() > 0.5) ? 1 : -1; + }; + GameMath.prototype.isOdd = function (n) { + if(n & 1) { + return true; + } else { + return false; + } + }; + GameMath.prototype.isEven = function (n) { + if(n & 1) { + return false; + } else { + return true; + } + }; + GameMath.prototype.wrapAngle = function (angle) { + var result = angle; + if(angle >= -180 && angle <= 180) { + return angle; + } + result = (angle + 180) % 360; + if(result < 0) { + result += 360; + } + return result - 180; + }; + GameMath.prototype.angleLimit = function (angle, min, max) { + var result = angle; + if(angle > max) { + result = max; + } else if(angle < min) { + result = min; + } + return result; + }; + GameMath.prototype.linearInterpolation = function (v, k) { + var m = v.length - 1; + var f = m * k; + var i = Math.floor(f); + if(k < 0) { + return this.linear(v[0], v[1], f); + } + if(k > 1) { + return this.linear(v[m], v[m - 1], m - f); + } + return this.linear(v[i], v[i + 1 > m ? m : i + 1], f - i); + }; + GameMath.prototype.bezierInterpolation = function (v, k) { + var b = 0; + var n = v.length - 1; + for(var i = 0; i <= n; i++) { + b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * this.bernstein(n, i); + } + return b; + }; + GameMath.prototype.catmullRomInterpolation = function (v, k) { + var m = v.length - 1; + var f = m * k; + var i = Math.floor(f); + if(v[0] === v[m]) { + if(k < 0) { + i = Math.floor(f = m * (1 + k)); + } + return this.catmullRom(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); + } else { + if(k < 0) { + return v[0] - (this.catmullRom(v[0], v[0], v[1], v[1], -f) - v[0]); + } + if(k > 1) { + return v[m] - (this.catmullRom(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); + } + return this.catmullRom(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i); + } + }; + GameMath.prototype.linear = function (p0, p1, t) { + return (p1 - p0) * t + p0; + }; + GameMath.prototype.bernstein = function (n, i) { + return this.factorial(n) / this.factorial(i) / this.factorial(n - i); + }; + GameMath.prototype.catmullRom = function (p0, p1, p2, p3, t) { + var v0 = (p2 - p0) * 0.5, v1 = (p3 - p1) * 0.5, t2 = t * t, t3 = t * t2; + return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; + }; + GameMath.prototype.difference = function (a, b) { + return Math.abs(a - b); + }; + GameMath.prototype.random = function () { + return this.globalSeed = this.srand(this.globalSeed); + }; + GameMath.prototype.srand = function (Seed) { + return ((69621 * (Seed * 0x7FFFFFFF)) % 0x7FFFFFFF) / 0x7FFFFFFF; + }; + GameMath.prototype.getRandom = function (Objects, StartIndex, Length) { + if (typeof StartIndex === "undefined") { StartIndex = 0; } + if (typeof Length === "undefined") { Length = 0; } + if(Objects != null) { + var l = Length; + if((l == 0) || (l > Objects.length - StartIndex)) { + l = Objects.length - StartIndex; + } + if(l > 0) { + return Objects[StartIndex + Math.floor(Math.random() * l)]; + } + } + return null; + }; + GameMath.prototype.floor = function (Value) { + var n = Value | 0; + return (Value > 0) ? (n) : ((n != Value) ? (n - 1) : (n)); + }; + GameMath.prototype.ceil = function (Value) { + var n = Value | 0; + return (Value > 0) ? ((n != Value) ? (n + 1) : (n)) : (n); + }; + GameMath.prototype.sinCosGenerator = function (length, sinAmplitude, cosAmplitude, frequency) { + if (typeof sinAmplitude === "undefined") { sinAmplitude = 1.0; } + if (typeof cosAmplitude === "undefined") { cosAmplitude = 1.0; } + if (typeof frequency === "undefined") { frequency = 1.0; } + var sin = sinAmplitude; + var cos = cosAmplitude; + var frq = frequency * Math.PI / length; + this.cosTable = []; + this.sinTable = []; + for(var c = 0; c < length; c++) { + cos -= sin * frq; + sin += cos * frq; + this.cosTable[c] = cos; + this.sinTable[c] = sin; + } + return this.sinTable; + }; + GameMath.prototype.shiftSinTable = function () { + if(this.sinTable) { + var s = this.sinTable.shift(); + this.sinTable.push(s); + return s; + } + }; + GameMath.prototype.shiftCosTable = function () { + if(this.cosTable) { + var s = this.cosTable.shift(); + this.cosTable.push(s); + return s; + } + }; + GameMath.prototype.vectorLength = function (dx, dy) { + return Math.sqrt(dx * dx + dy * dy); + }; + GameMath.prototype.dotProduct = function (ax, ay, bx, by) { + return ax * bx + ay * by; + }; + return GameMath; + })(); + Phaser.GameMath = GameMath; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Group = (function (_super) { + __extends(Group, _super); + function Group(game, MaxSize) { + if (typeof MaxSize === "undefined") { MaxSize = 0; } + _super.call(this, game); + this.isGroup = true; + this.members = []; + this.length = 0; + this._maxSize = MaxSize; + this._marker = 0; + this._sortIndex = null; + } + Group.ASCENDING = -1; + Group.DESCENDING = 1; + Group.prototype.destroy = function () { + if(this.members != null) { + var basic; + var i = 0; + while(i < this.length) { + basic = this.members[i++]; + if(basic != null) { + basic.destroy(); + } + } + this.members.length = 0; + } + this._sortIndex = null; + }; + Group.prototype.update = function () { + var basic; + var i = 0; + while(i < this.length) { + basic = this.members[i++]; + if((basic != null) && basic.exists && basic.active) { + basic.preUpdate(); + basic.update(); + basic.postUpdate(); + } + } + }; + Group.prototype.render = function (camera, cameraOffsetX, cameraOffsetY) { + var basic; + var i = 0; + while(i < this.length) { + basic = this.members[i++]; + if((basic != null) && basic.exists && basic.visible) { + basic.render(camera, cameraOffsetX, cameraOffsetY); + } + } + }; + Object.defineProperty(Group.prototype, "maxSize", { + get: function () { + return this._maxSize; + }, + set: function (Size) { + this._maxSize = Size; + if(this._marker >= this._maxSize) { + this._marker = 0; + } + if((this._maxSize == 0) || (this.members == null) || (this._maxSize >= this.members.length)) { + return; + } + var basic; + var i = this._maxSize; + var l = this.members.length; + while(i < l) { + basic = this.members[i++]; + if(basic != null) { + basic.destroy(); + } + } + this.length = this.members.length = this._maxSize; + }, + enumerable: true, + configurable: true + }); + Group.prototype.add = function (Object) { + if(this.members.indexOf(Object) >= 0) { + return Object; + } + var i = 0; + var l = this.members.length; + while(i < l) { + if(this.members[i] == null) { + this.members[i] = Object; + if(i >= this.length) { + this.length = i + 1; + } + return Object; + } + i++; + } + if(this._maxSize > 0) { + if(this.members.length >= this._maxSize) { + return Object; + } else if(this.members.length * 2 <= this._maxSize) { + this.members.length *= 2; + } else { + this.members.length = this._maxSize; + } + } else { + this.members.length *= 2; + } + this.members[i] = Object; + this.length = i + 1; + return Object; + }; + Group.prototype.recycle = function (ObjectClass) { + if (typeof ObjectClass === "undefined") { ObjectClass = null; } + var basic; + if(this._maxSize > 0) { + if(this.length < this._maxSize) { + if(ObjectClass == null) { + return null; + } + return this.add(new ObjectClass(this._game)); + } else { + basic = this.members[this._marker++]; + if(this._marker >= this._maxSize) { + this._marker = 0; + } + return basic; + } + } else { + basic = this.getFirstAvailable(ObjectClass); + if(basic != null) { + return basic; + } + if(ObjectClass == null) { + return null; + } + return this.add(new ObjectClass(this._game)); + } + }; + Group.prototype.remove = function (Object, Splice) { + if (typeof Splice === "undefined") { Splice = false; } + var index = this.members.indexOf(Object); + if((index < 0) || (index >= this.members.length)) { + return null; + } + if(Splice) { + this.members.splice(index, 1); + this.length--; + } else { + this.members[index] = null; + } + return Object; + }; + Group.prototype.replace = function (OldObject, NewObject) { + var index = this.members.indexOf(OldObject); + if((index < 0) || (index >= this.members.length)) { + return null; + } + this.members[index] = NewObject; + return NewObject; + }; + Group.prototype.sort = function (Index, Order) { + if (typeof Index === "undefined") { Index = "y"; } + if (typeof Order === "undefined") { Order = Group.ASCENDING; } + this._sortIndex = Index; + this._sortOrder = Order; + this.members.sort(this.sortHandler); + }; + Group.prototype.setAll = function (VariableName, Value, Recurse) { + if (typeof Recurse === "undefined") { Recurse = true; } + var basic; + var i = 0; + while(i < length) { + basic = this.members[i++]; + if(basic != null) { + if(Recurse && (basic.isGroup == true)) { + basic['setAll'](VariableName, Value, Recurse); + } else { + basic[VariableName] = Value; + } + } + } + }; + Group.prototype.callAll = function (FunctionName, Recurse) { + if (typeof Recurse === "undefined") { Recurse = true; } + var basic; + var i = 0; + while(i < this.length) { + basic = this.members[i++]; + if(basic != null) { + if(Recurse && (basic.isGroup == true)) { + basic['callAll'](FunctionName, Recurse); + } else { + basic[FunctionName](); + } + } + } + }; + Group.prototype.forEach = function (callback, recursive) { + if (typeof recursive === "undefined") { recursive = false; } + var basic; + var i = 0; + while(i < this.length) { + basic = this.members[i++]; + if(basic != null) { + if(recursive && (basic.isGroup == true)) { + basic.forEach(callback, true); + } else { + callback.call(this, basic); + } + } + } + }; + Group.prototype.forEachAlive = function (callback, recursive) { + if (typeof recursive === "undefined") { recursive = false; } + var basic; + var i = 0; + while(i < this.length) { + basic = this.members[i++]; + if(basic != null && basic.alive) { + if(recursive && (basic.isGroup == true)) { + basic.forEachAlive(callback, true); + } else { + callback.call(this, basic); + } + } + } + }; + Group.prototype.getFirstAvailable = function (ObjectClass) { + if (typeof ObjectClass === "undefined") { ObjectClass = null; } + var basic; + var i = 0; + while(i < this.length) { + basic = this.members[i++]; + if((basic != null) && !basic.exists && ((ObjectClass == null) || (typeof basic === ObjectClass))) { + return basic; + } + } + return null; + }; + Group.prototype.getFirstNull = function () { + var basic; + var i = 0; + var l = this.members.length; + while(i < l) { + if(this.members[i] == null) { + return i; + } else { + i++; + } + } + return -1; + }; + Group.prototype.getFirstExtant = function () { + var basic; + var i = 0; + while(i < length) { + basic = this.members[i++]; + if((basic != null) && basic.exists) { + return basic; + } + } + return null; + }; + Group.prototype.getFirstAlive = function () { + var basic; + var i = 0; + while(i < this.length) { + basic = this.members[i++]; + if((basic != null) && basic.exists && basic.alive) { + return basic; + } + } + return null; + }; + Group.prototype.getFirstDead = function () { + var basic; + var i = 0; + while(i < this.length) { + basic = this.members[i++]; + if((basic != null) && !basic.alive) { + return basic; + } + } + return null; + }; + Group.prototype.countLiving = function () { + var count = -1; + var basic; + var i = 0; + while(i < this.length) { + basic = this.members[i++]; + if(basic != null) { + if(count < 0) { + count = 0; + } + if(basic.exists && basic.alive) { + count++; + } + } + } + return count; + }; + Group.prototype.countDead = function () { + var count = -1; + var basic; + var i = 0; + while(i < this.length) { + basic = this.members[i++]; + if(basic != null) { + if(count < 0) { + count = 0; + } + if(!basic.alive) { + count++; + } + } + } + return count; + }; + Group.prototype.getRandom = function (StartIndex, Length) { + if (typeof StartIndex === "undefined") { StartIndex = 0; } + if (typeof Length === "undefined") { Length = 0; } + if(Length == 0) { + Length = this.length; + } + return this._game.math.getRandom(this.members, StartIndex, Length); + }; + Group.prototype.clear = function () { + this.length = this.members.length = 0; + }; + Group.prototype.kill = function () { + var basic; + var i = 0; + while(i < this.length) { + basic = this.members[i++]; + if((basic != null) && basic.exists) { + basic.kill(); + } + } + }; + Group.prototype.sortHandler = function (Obj1, Obj2) { + if(Obj1[this._sortIndex] < Obj2[this._sortIndex]) { + return this._sortOrder; + } else if(Obj1[this._sortIndex] > Obj2[this._sortIndex]) { + return -this._sortOrder; + } + return 0; + }; + return Group; + })(Phaser.Basic); + Phaser.Group = Group; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Loader = (function () { + function Loader(game, callback) { + this._game = game; + this._gameCreateComplete = callback; + this._keys = []; + this._fileList = { + }; + this._xhr = new XMLHttpRequest(); + this._queueSize = 0; + } + Loader.prototype.reset = function () { + this._queueSize = 0; + }; + Object.defineProperty(Loader.prototype, "queueSize", { + get: function () { + return this._queueSize; + }, + enumerable: true, + configurable: true + }); + Loader.prototype.addImageFile = function (key, url) { + if(this.checkKeyExists(key) === false) { + this._queueSize++; + this._fileList[key] = { + type: 'image', + key: key, + url: url, + data: null, + error: false, + loaded: false + }; + this._keys.push(key); + } + }; + Loader.prototype.addSpriteSheet = function (key, url, frameWidth, frameHeight, frameMax) { + if (typeof frameMax === "undefined") { frameMax = -1; } + if(this.checkKeyExists(key) === false) { + this._queueSize++; + this._fileList[key] = { + type: 'spritesheet', + key: key, + url: url, + data: null, + frameWidth: frameWidth, + frameHeight: frameHeight, + frameMax: frameMax, + error: false, + loaded: false + }; + this._keys.push(key); + } + }; + Loader.prototype.addTextureAtlas = function (key, url, jsonURL, jsonData) { + if (typeof jsonURL === "undefined") { jsonURL = null; } + if (typeof jsonData === "undefined") { jsonData = null; } + if(this.checkKeyExists(key) === false) { + if(jsonURL !== null) { + this._queueSize++; + this._fileList[key] = { + type: 'textureatlas', + key: key, + url: url, + data: null, + jsonURL: jsonURL, + jsonData: null, + error: false, + loaded: false + }; + this._keys.push(key); + } else { + if(typeof jsonData === 'string') { + var data = JSON.parse(jsonData); + if(data['frames']) { + this._queueSize++; + this._fileList[key] = { + type: 'textureatlas', + key: key, + url: url, + data: null, + jsonURL: null, + jsonData: data['frames'], + error: false, + loaded: false + }; + this._keys.push(key); + } + } else { + if(jsonData['frames']) { + this._queueSize++; + this._fileList[key] = { + type: 'textureatlas', + key: key, + url: url, + data: null, + jsonURL: null, + jsonData: jsonData['frames'], + error: false, + loaded: false + }; + this._keys.push(key); + } + } + } + } + }; + Loader.prototype.addAudioFile = function (key, url) { + if(this.checkKeyExists(key) === false) { + this._queueSize++; + this._fileList[key] = { + type: 'audio', + key: key, + url: url, + data: null, + buffer: null, + error: false, + loaded: false + }; + this._keys.push(key); + } + }; + Loader.prototype.addTextFile = function (key, url) { + if(this.checkKeyExists(key) === false) { + this._queueSize++; + this._fileList[key] = { + type: 'text', + key: key, + url: url, + data: null, + error: false, + loaded: false + }; + this._keys.push(key); + } + }; + Loader.prototype.removeFile = function (key) { + delete this._fileList[key]; + }; + Loader.prototype.removeAll = function () { + this._fileList = { + }; + }; + Loader.prototype.load = function (onFileLoadCallback, onCompleteCallback) { + if (typeof onFileLoadCallback === "undefined") { onFileLoadCallback = null; } + if (typeof onCompleteCallback === "undefined") { onCompleteCallback = null; } + this.progress = 0; + this.hasLoaded = false; + this._onComplete = onCompleteCallback; + if(onCompleteCallback == null) { + this._onComplete = this._game.onCreateCallback; + } + this._onFileLoad = onFileLoadCallback; + if(this._keys.length > 0) { + this._progressChunk = 100 / this._keys.length; + this.loadFile(); + } else { + this.progress = 1; + this.hasLoaded = true; + this._gameCreateComplete.call(this._game); + if(this._onComplete !== null) { + this._onComplete.call(this._game.callbackContext); + } + } + }; + Loader.prototype.loadFile = function () { + var _this = this; + var file = this._fileList[this._keys.pop()]; + switch(file.type) { + case 'image': + case 'spritesheet': + case 'textureatlas': + file.data = new Image(); + file.data.name = file.key; + file.data.onload = function () { + return _this.fileComplete(file.key); + }; + file.data.onerror = function () { + return _this.fileError(file.key); + }; + file.data.src = file.url; + break; + case 'audio': + this._xhr.open("GET", file.url, true); + this._xhr.responseType = "arraybuffer"; + this._xhr.onload = function () { + return _this.fileComplete(file.key); + }; + this._xhr.onerror = function () { + return _this.fileError(file.key); + }; + this._xhr.send(); + break; + case 'text': + this._xhr.open("GET", file.url, true); + this._xhr.responseType = "text"; + this._xhr.onload = function () { + return _this.fileComplete(file.key); + }; + this._xhr.onerror = function () { + return _this.fileError(file.key); + }; + this._xhr.send(); + break; + } + }; + Loader.prototype.fileError = function (key) { + this._fileList[key].loaded = true; + this._fileList[key].error = true; + this.nextFile(key, false); + }; + Loader.prototype.fileComplete = function (key) { + var _this = this; + this._fileList[key].loaded = true; + var file = this._fileList[key]; + var loadNext = true; + switch(file.type) { + case 'image': + this._game.cache.addImage(file.key, file.url, file.data); + break; + case 'spritesheet': + this._game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax); + break; + case 'textureatlas': + if(file.jsonURL == null) { + this._game.cache.addTextureAtlas(file.key, file.url, file.data, file.jsonData); + } else { + loadNext = false; + this._xhr.open("GET", file.jsonURL, true); + this._xhr.responseType = "text"; + this._xhr.onload = function () { + return _this.jsonLoadComplete(file.key); + }; + this._xhr.onerror = function () { + return _this.jsonLoadError(file.key); + }; + this._xhr.send(); + } + break; + case 'audio': + file.data = this._xhr.response; + this._game.cache.addSound(file.key, file.url, file.data); + break; + case 'text': + file.data = this._xhr.response; + this._game.cache.addText(file.key, file.url, file.data); + break; + } + if(loadNext) { + this.nextFile(key, true); + } + }; + Loader.prototype.jsonLoadComplete = function (key) { + var data = JSON.parse(this._xhr.response); + if(data['frames']) { + var file = this._fileList[key]; + this._game.cache.addTextureAtlas(file.key, file.url, file.data, data['frames']); + } + this.nextFile(key, true); + }; + Loader.prototype.jsonLoadError = function (key) { + var file = this._fileList[key]; + file.error = true; + this.nextFile(key, true); + }; + Loader.prototype.nextFile = function (previousKey, success) { + this.progress = Math.round(this.progress + this._progressChunk); + if(this.progress > 1) { + this.progress = 1; + } + if(this._onFileLoad) { + this._onFileLoad.call(this._game.callbackContext, this.progress, previousKey, success); + } + if(this._keys.length > 0) { + this.loadFile(); + } else { + this.hasLoaded = true; + this.removeAll(); + this._gameCreateComplete.call(this._game); + if(this._onComplete !== null) { + this._onComplete.call(this._game.callbackContext); + } + } + }; + Loader.prototype.checkKeyExists = function (key) { + if(this._fileList[key]) { + return true; + } else { + return false; + } + }; + return Loader; + })(); + Phaser.Loader = Loader; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Motion = (function () { + function Motion(game) { + this._game = game; + } + Motion.prototype.computeVelocity = function (Velocity, Acceleration, Drag, Max) { + if (typeof Acceleration === "undefined") { Acceleration = 0; } + if (typeof Drag === "undefined") { Drag = 0; } + if (typeof Max === "undefined") { Max = 10000; } + if(Acceleration !== 0) { + Velocity += Acceleration * this._game.time.elapsed; + } else if(Drag !== 0) { + var drag = Drag * this._game.time.elapsed; + if(Velocity - drag > 0) { + Velocity = Velocity - drag; + } else if(Velocity + drag < 0) { + Velocity += drag; + } else { + Velocity = 0; + } + } + if((Velocity != 0) && (Max != 10000)) { + if(Velocity > Max) { + Velocity = Max; + } else if(Velocity < -Max) { + Velocity = -Max; + } + } + return Velocity; + }; + Motion.prototype.velocityFromAngle = function (angle, speed) { + if(isNaN(speed)) { + speed = 0; + } + var a = this._game.math.degreesToRadians(angle); + return new Phaser.Point((Math.cos(a) * speed), (Math.sin(a) * speed)); + }; + Motion.prototype.moveTowardsObject = function (source, dest, speed, maxTime) { + if (typeof speed === "undefined") { speed = 60; } + if (typeof maxTime === "undefined") { maxTime = 0; } + var a = this.angleBetween(source, dest); + if(maxTime > 0) { + var d = this.distanceBetween(source, dest); + speed = d / (maxTime / 1000); + } + source.velocity.x = Math.cos(a) * speed; + source.velocity.y = Math.sin(a) * speed; + }; + Motion.prototype.accelerateTowardsObject = function (source, dest, speed, xSpeedMax, ySpeedMax) { + var a = this.angleBetween(source, dest); + source.velocity.x = 0; + source.velocity.y = 0; + source.acceleration.x = Math.cos(a) * speed; + source.acceleration.y = Math.sin(a) * speed; + source.maxVelocity.x = xSpeedMax; + source.maxVelocity.y = ySpeedMax; + }; + Motion.prototype.moveTowardsMouse = function (source, speed, maxTime) { + if (typeof speed === "undefined") { speed = 60; } + if (typeof maxTime === "undefined") { maxTime = 0; } + var a = this.angleBetweenMouse(source); + if(maxTime > 0) { + var d = this.distanceToMouse(source); + speed = d / (maxTime / 1000); + } + source.velocity.x = Math.cos(a) * speed; + source.velocity.y = Math.sin(a) * speed; + }; + Motion.prototype.accelerateTowardsMouse = function (source, speed, xSpeedMax, ySpeedMax) { + var a = this.angleBetweenMouse(source); + source.velocity.x = 0; + source.velocity.y = 0; + source.acceleration.x = Math.cos(a) * speed; + source.acceleration.y = Math.sin(a) * speed; + source.maxVelocity.x = xSpeedMax; + source.maxVelocity.y = ySpeedMax; + }; + Motion.prototype.moveTowardsPoint = function (source, target, speed, maxTime) { + if (typeof speed === "undefined") { speed = 60; } + if (typeof maxTime === "undefined") { maxTime = 0; } + var a = this.angleBetweenPoint(source, target); + if(maxTime > 0) { + var d = this.distanceToPoint(source, target); + speed = d / (maxTime / 1000); + } + source.velocity.x = Math.cos(a) * speed; + source.velocity.y = Math.sin(a) * speed; + }; + Motion.prototype.accelerateTowardsPoint = function (source, target, speed, xSpeedMax, ySpeedMax) { + var a = this.angleBetweenPoint(source, target); + source.velocity.x = 0; + source.velocity.y = 0; + source.acceleration.x = Math.cos(a) * speed; + source.acceleration.y = Math.sin(a) * speed; + source.maxVelocity.x = xSpeedMax; + source.maxVelocity.y = ySpeedMax; + }; + Motion.prototype.distanceBetween = function (a, b) { + var dx = (a.x + a.origin.x) - (b.x + b.origin.x); + var dy = (a.y + a.origin.y) - (b.y + b.origin.y); + return this._game.math.vectorLength(dx, dy); + }; + Motion.prototype.distanceToPoint = function (a, target) { + var dx = (a.x + a.origin.x) - (target.x); + var dy = (a.y + a.origin.y) - (target.y); + return this._game.math.vectorLength(dx, dy); + }; + Motion.prototype.distanceToMouse = function (a) { + var dx = (a.x + a.origin.x) - this._game.input.x; + var dy = (a.y + a.origin.y) - this._game.input.y; + return this._game.math.vectorLength(dx, dy); + }; + Motion.prototype.angleBetweenPoint = function (a, target, asDegrees) { + if (typeof asDegrees === "undefined") { asDegrees = false; } + var dx = (target.x) - (a.x + a.origin.x); + var dy = (target.y) - (a.y + a.origin.y); + if(asDegrees) { + return this._game.math.radiansToDegrees(Math.atan2(dy, dx)); + } else { + return Math.atan2(dy, dx); + } + }; + Motion.prototype.angleBetween = function (a, b, asDegrees) { + if (typeof asDegrees === "undefined") { asDegrees = false; } + var dx = (b.x + b.origin.x) - (a.x + a.origin.x); + var dy = (b.y + b.origin.y) - (a.y + a.origin.y); + if(asDegrees) { + return this._game.math.radiansToDegrees(Math.atan2(dy, dx)); + } else { + return Math.atan2(dy, dx); + } + }; + Motion.prototype.velocityFromFacing = function (parent, speed) { + var a; + if(parent.facing == Phaser.Collision.LEFT) { + a = this._game.math.degreesToRadians(180); + } else if(parent.facing == Phaser.Collision.RIGHT) { + a = this._game.math.degreesToRadians(0); + } else if(parent.facing == Phaser.Collision.UP) { + a = this._game.math.degreesToRadians(-90); + } else if(parent.facing == Phaser.Collision.DOWN) { + a = this._game.math.degreesToRadians(90); + } + return new Phaser.Point(Math.cos(a) * speed, Math.sin(a) * speed); + }; + Motion.prototype.angleBetweenMouse = function (a, asDegrees) { + if (typeof asDegrees === "undefined") { asDegrees = false; } + var p = a.getScreenXY(); + var dx = a._game.input.x - p.x; + var dy = a._game.input.y - p.y; + if(asDegrees) { + return this._game.math.radiansToDegrees(Math.atan2(dy, dx)); + } else { + return Math.atan2(dy, dx); + } + }; + return Motion; + })(); + Phaser.Motion = Motion; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Sound = (function () { + function Sound(context, gainNode, data, volume, loop) { + if (typeof volume === "undefined") { volume = 1; } + if (typeof loop === "undefined") { loop = false; } + this.loop = false; + this.isPlaying = false; + this.isDecoding = false; + this._context = context; + this._gainNode = gainNode; + this._buffer = data; + this._volume = volume; + this.loop = loop; + if(this._context !== null) { + this._localGainNode = this._context.createGainNode(); + this._localGainNode.connect(this._gainNode); + this._localGainNode.gain.value = this._volume; + } + if(this._buffer === null) { + this.isDecoding = true; + } else { + this.play(); + } + } + Sound.prototype.setDecodedBuffer = function (data) { + this._buffer = data; + this.isDecoding = false; + this.play(); + }; + Sound.prototype.play = function () { + if(this._buffer === null || this.isDecoding === true) { + return; + } + this._sound = this._context.createBufferSource(); + this._sound.buffer = this._buffer; + this._sound.connect(this._localGainNode); + if(this.loop) { + this._sound.loop = true; + } + this._sound.noteOn(0); + this.duration = this._sound.buffer.duration; + this.isPlaying = true; + }; + Sound.prototype.stop = function () { + if(this.isPlaying === true) { + this.isPlaying = false; + this._sound.noteOff(0); + } + }; + Sound.prototype.mute = function () { + this._localGainNode.gain.value = 0; + }; + Sound.prototype.unmute = function () { + this._localGainNode.gain.value = this._volume; + }; + Object.defineProperty(Sound.prototype, "volume", { + get: function () { + return this._volume; + }, + set: function (value) { + this._volume = value; + this._localGainNode.gain.value = this._volume; + }, + enumerable: true, + configurable: true + }); + return Sound; + })(); + Phaser.Sound = Sound; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var SoundManager = (function () { + function SoundManager(game) { + this._context = null; + this._game = game; + if(game.device.webaudio == true) { + if(!!window['AudioContext']) { + this._context = new window['AudioContext'](); + } else if(!!window['webkitAudioContext']) { + this._context = new window['webkitAudioContext'](); + } + if(this._context !== null) { + this._gainNode = this._context.createGainNode(); + this._gainNode.connect(this._context.destination); + this._volume = 1; + } + } + } + SoundManager.prototype.mute = function () { + this._gainNode.gain.value = 0; + }; + SoundManager.prototype.unmute = function () { + this._gainNode.gain.value = this._volume; + }; + Object.defineProperty(SoundManager.prototype, "volume", { + get: function () { + return this._volume; + }, + set: function (value) { + this._volume = value; + this._gainNode.gain.value = this._volume; + }, + enumerable: true, + configurable: true + }); + SoundManager.prototype.decode = function (key, callback, sound) { + if (typeof callback === "undefined") { callback = null; } + if (typeof sound === "undefined") { sound = null; } + var soundData = this._game.cache.getSound(key); + if(soundData) { + if(this._game.cache.isSoundDecoded(key) === false) { + var that = this; + this._context.decodeAudioData(soundData, function (buffer) { + that._game.cache.decodedSound(key, buffer); + if(sound) { + sound.setDecodedBuffer(buffer); + } + callback(); + }); + } + } + }; + SoundManager.prototype.play = function (key, volume, loop) { + if (typeof volume === "undefined") { volume = 1; } + if (typeof loop === "undefined") { loop = false; } + var _this = this; + if(this._context === null) { + return; + } + var soundData = this._game.cache.getSound(key); + if(soundData) { + if(this._game.cache.isSoundDecoded(key) === true) { + return new Phaser.Sound(this._context, this._gainNode, soundData, volume, loop); + } else { + var tempSound = new Phaser.Sound(this._context, this._gainNode, null, volume, loop); + this.decode(key, function () { + return _this.play(key); + }, tempSound); + return tempSound; + } + } + }; + return SoundManager; + })(); + Phaser.SoundManager = SoundManager; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + Phaser.VERSION = 'Phaser version 0.9.4'; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var StageScaleMode = (function () { + function StageScaleMode(game) { + var _this = this; + this._startHeight = 0; + this.width = 0; + this.height = 0; + this._game = game; + this.orientation = window['orientation']; + window.addEventListener('orientationchange', function (event) { + return _this.checkOrientation(event); + }, false); + } + StageScaleMode.EXACT_FIT = 0; + StageScaleMode.NO_SCALE = 1; + StageScaleMode.SHOW_ALL = 2; + StageScaleMode.prototype.update = function () { + if(this._game.stage.scaleMode !== StageScaleMode.NO_SCALE && (window.innerWidth !== this.width || window.innerHeight !== this.height)) { + this.refresh(); + } + }; + Object.defineProperty(StageScaleMode.prototype, "isLandscape", { + get: function () { + return window['orientation'] === 90 || window['orientation'] === -90; + }, + enumerable: true, + configurable: true + }); + StageScaleMode.prototype.checkOrientation = function (event) { + if(window['orientation'] !== this.orientation) { + this.refresh(); + this.orientation = window['orientation']; + } + }; + StageScaleMode.prototype.refresh = function () { + var _this = this; + if(this._game.device.iPad == false && this._game.device.webApp == false && this._game.device.desktop == false) { + document.documentElement.style.minHeight = '5000px'; + this._startHeight = window.innerHeight; + if(this._game.device.android && this._game.device.chrome == false) { + window.scrollTo(0, 1); + } else { + window.scrollTo(0, 0); + } + } + if(this._check == null) { + this._iterations = 40; + this._check = window.setInterval(function () { + return _this.setScreenSize(); + }, 10); + } + }; + StageScaleMode.prototype.setScreenSize = function () { + if(this._game.device.iPad == false && this._game.device.webApp == false && this._game.device.desktop == false) { + if(this._game.device.android && this._game.device.chrome == false) { + window.scrollTo(0, 1); + } else { + window.scrollTo(0, 0); + } + } + this._iterations--; + if(window.innerHeight > this._startHeight || this._iterations < 0) { + document.documentElement.style.minHeight = window.innerHeight + 'px'; + if(this._game.stage.scaleMode == StageScaleMode.EXACT_FIT) { + if(this._game.stage.maxScaleX && window.innerWidth > this._game.stage.maxScaleX) { + this.width = this._game.stage.maxScaleX; + } else { + this.width = window.innerWidth; + } + if(this._game.stage.maxScaleY && window.innerHeight > this._game.stage.maxScaleY) { + this.height = this._game.stage.maxScaleY; + } else { + this.height = window.innerHeight; + } + } else if(this._game.stage.scaleMode == StageScaleMode.SHOW_ALL) { + var multiplier = Math.min((window.innerHeight / this._game.stage.height), (window.innerWidth / this._game.stage.width)); + this.width = Math.round(this._game.stage.width * multiplier); + this.height = Math.round(this._game.stage.height * multiplier); + if(this._game.stage.maxScaleX && this.width > this._game.stage.maxScaleX) { + this.width = this._game.stage.maxScaleX; + } + if(this._game.stage.maxScaleY && this.height > this._game.stage.maxScaleY) { + this.height = this._game.stage.maxScaleY; + } + } + this._game.stage.canvas.style.width = this.width + 'px'; + this._game.stage.canvas.style.height = this.height + 'px'; + this._game.input.scaleX = this._game.stage.width / this.width; + this._game.input.scaleY = this._game.stage.height / this.height; + clearInterval(this._check); + this._check = null; + } + }; + return StageScaleMode; + })(); + Phaser.StageScaleMode = StageScaleMode; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Stage = (function () { + function Stage(game, parent, width, height) { + var _this = this; + this.clear = true; + this.disablePauseScreen = false; + this.minScaleX = null; + this.maxScaleX = null; + this.minScaleY = null; + this.maxScaleY = null; + this._logo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAO1JREFUeNpi/P//PwM6YGRkxBQEAqBaRnQxFmwa10d6MAjrMqMofHv5L1we2SBGmAtAktg0ogOQQYHLd8ANYYFpPtTmzUAMAFmwnsEDrAdkCAvMZlIAsiFMMAEYsKvaSrQhIMCELkGsV2AAbIC8gCQYgwKIUABiNYBf9yoYH7n7n6CzN274g2IYEyFbsNmKLIaSkHpP7WSwUfbA0ASzFQRslBlxp0RcAF0TRhggA3zhAJIDpUKU5A9KyshpHDkjFZu5g2nJMFcwXVJSgqIGnBKx5bKenh4w/XzVbgbPtlIUcVgSxuoCUgHIIIAAAwArtXwJBABO6QAAAABJRU5ErkJggg=="; + this._game = game; + this.canvas = document.createElement('canvas'); + this.canvas.width = width; + this.canvas.height = height; + if(document.getElementById(parent)) { + document.getElementById(parent).appendChild(this.canvas); + document.getElementById(parent).style.overflow = 'hidden'; + } else { + document.body.appendChild(this.canvas); + } + this.canvas.style.msTouchAction = 'none'; + this.canvas.style['touch-action'] = 'none'; + this.context = this.canvas.getContext('2d'); + this.offset = this.getOffset(this.canvas); + this.bounds = new Phaser.Rectangle(this.offset.x, this.offset.y, width, height); + this.aspectRatio = width / height; + this.scaleMode = Phaser.StageScaleMode.NO_SCALE; + this.scale = new Phaser.StageScaleMode(this._game); + document.addEventListener('visibilitychange', function (event) { + return _this.visibilityChange(event); + }, false); + document.addEventListener('webkitvisibilitychange', function (event) { + return _this.visibilityChange(event); + }, false); + window.onblur = function (event) { + return _this.visibilityChange(event); + }; + window.onfocus = function (event) { + return _this.visibilityChange(event); + }; + } + Stage.ORIENTATION_LANDSCAPE = 0; + Stage.ORIENTATION_PORTRAIT = 1; + Stage.prototype.update = function () { + this.scale.update(); + if(this.clear) { + this.context.clearRect(0, 0, this.width, this.height); + } + }; + Stage.prototype.renderDebugInfo = function () { + this.context.fillStyle = 'rgb(255,255,255)'; + this.context.fillText(Phaser.VERSION, 10, 20); + this.context.fillText('Game Size: ' + this.width + ' x ' + this.height, 10, 40); + this.context.fillText('x: ' + this.x + ' y: ' + this.y, 10, 60); + }; + Stage.prototype.visibilityChange = function (event) { + if(this.disablePauseScreen) { + return; + } + if(event.type == 'blur' && this._game.paused == false && this._game.isBooted == true) { + this._game.paused = true; + this.drawPauseScreen(); + } else if(event.type == 'focus') { + this._game.paused = false; + } + }; + Stage.prototype.drawInitScreen = function () { + this.context.fillStyle = 'rgb(40, 40, 40)'; + this.context.fillRect(0, 0, this.width, this.height); + this.context.fillStyle = 'rgb(255,255,255)'; + this.context.font = 'bold 18px Arial'; + this.context.textBaseline = 'top'; + this.context.fillText(Phaser.VERSION, 54, 32); + this.context.fillText('Game Size: ' + this.width + ' x ' + this.height, 32, 64); + this.context.fillText('www.photonstorm.com', 32, 96); + this.context.font = '16px Arial'; + this.context.fillText('You are seeing this screen because you didn\'t specify any default', 32, 160); + this.context.fillText('functions in the Game constructor, or use Game.loadState()', 32, 184); + var image = new Image(); + var that = this; + image.onload = function () { + that.context.drawImage(image, 32, 32); + }; + image.src = this._logo; + }; + Stage.prototype.drawPauseScreen = function () { + this.saveCanvasValues(); + this.context.fillStyle = 'rgba(0, 0, 0, 0.4)'; + this.context.fillRect(0, 0, this.width, this.height); + var arrowWidth = Math.round(this.width / 2); + var arrowHeight = Math.round(this.height / 2); + var sx = this.centerX - arrowWidth / 2; + var sy = this.centerY - arrowHeight / 2; + this.context.beginPath(); + this.context.moveTo(sx, sy); + this.context.lineTo(sx, sy + arrowHeight); + this.context.lineTo(sx + arrowWidth, this.centerY); + this.context.fillStyle = 'rgba(255, 255, 255, 0.8)'; + this.context.fill(); + this.context.closePath(); + this.restoreCanvasValues(); + }; + Stage.prototype.getOffset = function (element) { + var box = element.getBoundingClientRect(); + var clientTop = element.clientTop || document.body.clientTop || 0; + var clientLeft = element.clientLeft || document.body.clientLeft || 0; + var scrollTop = window.pageYOffset || element.scrollTop || document.body.scrollTop; + var scrollLeft = window.pageXOffset || element.scrollLeft || document.body.scrollLeft; + return new Phaser.Point(box.left + scrollLeft - clientLeft, box.top + scrollTop - clientTop); + }; + Stage.prototype.saveCanvasValues = function () { + this.strokeStyle = this.context.strokeStyle; + this.lineWidth = this.context.lineWidth; + this.fillStyle = this.context.fillStyle; + }; + Stage.prototype.restoreCanvasValues = function () { + this.context.strokeStyle = this.strokeStyle; + this.context.lineWidth = this.lineWidth; + this.context.fillStyle = this.fillStyle; + }; + Object.defineProperty(Stage.prototype, "backgroundColor", { + get: function () { + return this._bgColor; + }, + set: function (color) { + this.canvas.style.backgroundColor = color; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Stage.prototype, "x", { + get: function () { + return this.bounds.x; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Stage.prototype, "y", { + get: function () { + return this.bounds.y; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Stage.prototype, "width", { + get: function () { + return this.bounds.width; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Stage.prototype, "height", { + get: function () { + return this.bounds.height; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Stage.prototype, "centerX", { + get: function () { + return this.bounds.halfWidth; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Stage.prototype, "centerY", { + get: function () { + return this.bounds.halfHeight; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Stage.prototype, "randomX", { + get: function () { + return Math.round(Math.random() * this.bounds.width); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Stage.prototype, "randomY", { + get: function () { + return Math.round(Math.random() * this.bounds.height); + }, + enumerable: true, + configurable: true + }); + return Stage; + })(); + Phaser.Stage = Stage; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Time = (function () { + function Time(game) { + this.timeScale = 1.0; + this.elapsed = 0; + this.time = 0; + this.now = 0; + this.delta = 0; + this.fps = 0; + this.fpsMin = 1000; + this.fpsMax = 0; + this.msMin = 1000; + this.msMax = 0; + this.frames = 0; + this._timeLastSecond = 0; + this._started = Date.now(); + this._timeLastSecond = this._started; + this.time = this._started; + } + Object.defineProperty(Time.prototype, "totalElapsedSeconds", { + get: function () { + return (this.now - this._started) * 0.001; + }, + enumerable: true, + configurable: true + }); + Time.prototype.update = function () { + this.now = Date.now(); + this.delta = this.now - this.time; + this.msMin = Math.min(this.msMin, this.delta); + this.msMax = Math.max(this.msMax, this.delta); + this.frames++; + if(this.now > this._timeLastSecond + 1000) { + this.fps = Math.round((this.frames * 1000) / (this.now - this._timeLastSecond)); + this.fpsMin = Math.min(this.fpsMin, this.fps); + this.fpsMax = Math.max(this.fpsMax, this.fps); + this._timeLastSecond = this.now; + this.frames = 0; + } + this.time = this.now; + }; + Time.prototype.elapsedSince = function (since) { + return this.now - since; + }; + Time.prototype.elapsedSecondsSince = function (since) { + return (this.now - since) * 0.001; + }; + Time.prototype.reset = function () { + this._started = this.now; + }; + return Time; + })(); + Phaser.Time = Time; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + (function (Easing) { + var Back = (function () { + function Back() { } + Back.In = function In(k) { + var s = 1.70158; + return k * k * ((s + 1) * k - s); + }; + Back.Out = function Out(k) { + var s = 1.70158; + return --k * k * ((s + 1) * k + s) + 1; + }; + Back.InOut = function InOut(k) { + var s = 1.70158 * 1.525; + if((k *= 2) < 1) { + return 0.5 * (k * k * ((s + 1) * k - s)); + } + return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); + }; + return Back; + })(); + Easing.Back = Back; + })(Phaser.Easing || (Phaser.Easing = {})); + var Easing = Phaser.Easing; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + (function (Easing) { + var Bounce = (function () { + function Bounce() { } + Bounce.In = function In(k) { + return 1 - Phaser.Easing.Bounce.Out(1 - k); + }; + Bounce.Out = function Out(k) { + if(k < (1 / 2.75)) { + return 7.5625 * k * k; + } else if(k < (2 / 2.75)) { + return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75; + } else if(k < (2.5 / 2.75)) { + return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375; + } else { + return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375; + } + }; + Bounce.InOut = function InOut(k) { + if(k < 0.5) { + return Phaser.Easing.Bounce.In(k * 2) * 0.5; + } + return Phaser.Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5; + }; + return Bounce; + })(); + Easing.Bounce = Bounce; + })(Phaser.Easing || (Phaser.Easing = {})); + var Easing = Phaser.Easing; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + (function (Easing) { + var Circular = (function () { + function Circular() { } + Circular.In = function In(k) { + return 1 - Math.sqrt(1 - k * k); + }; + Circular.Out = function Out(k) { + return Math.sqrt(1 - (--k * k)); + }; + Circular.InOut = function InOut(k) { + if((k *= 2) < 1) { + return -0.5 * (Math.sqrt(1 - k * k) - 1); + } + return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); + }; + return Circular; + })(); + Easing.Circular = Circular; + })(Phaser.Easing || (Phaser.Easing = {})); + var Easing = Phaser.Easing; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + (function (Easing) { + var Cubic = (function () { + function Cubic() { } + Cubic.In = function In(k) { + return k * k * k; + }; + Cubic.Out = function Out(k) { + return --k * k * k + 1; + }; + Cubic.InOut = function InOut(k) { + if((k *= 2) < 1) { + return 0.5 * k * k * k; + } + return 0.5 * ((k -= 2) * k * k + 2); + }; + return Cubic; + })(); + Easing.Cubic = Cubic; + })(Phaser.Easing || (Phaser.Easing = {})); + var Easing = Phaser.Easing; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + (function (Easing) { + var Elastic = (function () { + function Elastic() { } + Elastic.In = function In(k) { + var s, a = 0.1, p = 0.4; + if(k === 0) { + return 0; + } + if(k === 1) { + return 1; + } + if(!a || a < 1) { + a = 1; + s = p / 4; + } else { + s = p * Math.asin(1 / a) / (2 * Math.PI); + } + return -(a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p)); + }; + Elastic.Out = function Out(k) { + var s, a = 0.1, p = 0.4; + if(k === 0) { + return 0; + } + if(k === 1) { + return 1; + } + if(!a || a < 1) { + a = 1; + s = p / 4; + } else { + s = p * Math.asin(1 / a) / (2 * Math.PI); + } + return (a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1); + }; + Elastic.InOut = function InOut(k) { + var s, a = 0.1, p = 0.4; + if(k === 0) { + return 0; + } + if(k === 1) { + return 1; + } + if(!a || a < 1) { + a = 1; + s = p / 4; + } else { + s = p * Math.asin(1 / a) / (2 * Math.PI); + } + if((k *= 2) < 1) { + return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p)); + } + return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1; + }; + return Elastic; + })(); + Easing.Elastic = Elastic; + })(Phaser.Easing || (Phaser.Easing = {})); + var Easing = Phaser.Easing; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + (function (Easing) { + var Exponential = (function () { + function Exponential() { } + Exponential.In = function In(k) { + return k === 0 ? 0 : Math.pow(1024, k - 1); + }; + Exponential.Out = function Out(k) { + return k === 1 ? 1 : 1 - Math.pow(2, -10 * k); + }; + Exponential.InOut = function InOut(k) { + if(k === 0) { + return 0; + } + if(k === 1) { + return 1; + } + if((k *= 2) < 1) { + return 0.5 * Math.pow(1024, k - 1); + } + return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2); + }; + return Exponential; + })(); + Easing.Exponential = Exponential; + })(Phaser.Easing || (Phaser.Easing = {})); + var Easing = Phaser.Easing; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + (function (Easing) { + var Linear = (function () { + function Linear() { } + Linear.None = function None(k) { + return k; + }; + return Linear; + })(); + Easing.Linear = Linear; + })(Phaser.Easing || (Phaser.Easing = {})); + var Easing = Phaser.Easing; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + (function (Easing) { + var Quadratic = (function () { + function Quadratic() { } + Quadratic.In = function In(k) { + return k * k; + }; + Quadratic.Out = function Out(k) { + return k * (2 - k); + }; + Quadratic.InOut = function InOut(k) { + if((k *= 2) < 1) { + return 0.5 * k * k; + } + return -0.5 * (--k * (k - 2) - 1); + }; + return Quadratic; + })(); + Easing.Quadratic = Quadratic; + })(Phaser.Easing || (Phaser.Easing = {})); + var Easing = Phaser.Easing; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + (function (Easing) { + var Quartic = (function () { + function Quartic() { } + Quartic.In = function In(k) { + return k * k * k * k; + }; + Quartic.Out = function Out(k) { + return 1 - (--k * k * k * k); + }; + Quartic.InOut = function InOut(k) { + if((k *= 2) < 1) { + return 0.5 * k * k * k * k; + } + return -0.5 * ((k -= 2) * k * k * k - 2); + }; + return Quartic; + })(); + Easing.Quartic = Quartic; + })(Phaser.Easing || (Phaser.Easing = {})); + var Easing = Phaser.Easing; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + (function (Easing) { + var Quintic = (function () { + function Quintic() { } + Quintic.In = function In(k) { + return k * k * k * k * k; + }; + Quintic.Out = function Out(k) { + return --k * k * k * k * k + 1; + }; + Quintic.InOut = function InOut(k) { + if((k *= 2) < 1) { + return 0.5 * k * k * k * k * k; + } + return 0.5 * ((k -= 2) * k * k * k * k + 2); + }; + return Quintic; + })(); + Easing.Quintic = Quintic; + })(Phaser.Easing || (Phaser.Easing = {})); + var Easing = Phaser.Easing; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + (function (Easing) { + var Sinusoidal = (function () { + function Sinusoidal() { } + Sinusoidal.In = function In(k) { + return 1 - Math.cos(k * Math.PI / 2); + }; + Sinusoidal.Out = function Out(k) { + return Math.sin(k * Math.PI / 2); + }; + Sinusoidal.InOut = function InOut(k) { + return 0.5 * (1 - Math.cos(Math.PI * k)); + }; + return Sinusoidal; + })(); + Easing.Sinusoidal = Sinusoidal; + })(Phaser.Easing || (Phaser.Easing = {})); + var Easing = Phaser.Easing; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Tween = (function () { + function Tween(object, game) { + this._object = null; + this._pausedTime = 0; + this._valuesStart = { + }; + this._valuesEnd = { + }; + this._duration = 1000; + this._delayTime = 0; + this._startTime = null; + this._chainedTweens = []; + this._object = object; + this._game = game; + this._manager = this._game.tweens; + this._interpolationFunction = this._game.math.linearInterpolation; + this._easingFunction = Phaser.Easing.Linear.None; + this.onStart = new Phaser.Signal(); + this.onUpdate = new Phaser.Signal(); + this.onComplete = new Phaser.Signal(); + } + Tween.prototype.to = function (properties, duration, ease, autoStart) { + if (typeof duration === "undefined") { duration = 1000; } + if (typeof ease === "undefined") { ease = null; } + if (typeof autoStart === "undefined") { autoStart = false; } + this._duration = duration; + this._valuesEnd = properties; + if(ease !== null) { + this._easingFunction = ease; + } + if(autoStart === true) { + return this.start(); + } else { + return this; + } + }; + Tween.prototype.start = function () { + if(this._game === null || this._object === null) { + return; + } + this._manager.add(this); + this.onStart.dispatch(this._object); + this._startTime = this._game.time.now + this._delayTime; + for(var property in this._valuesEnd) { + if(this._object[property] === null || !(property in this._object)) { + throw Error('Phaser.Tween interpolation of null value of non-existing property'); + continue; + } + if(this._valuesEnd[property] instanceof Array) { + if(this._valuesEnd[property].length === 0) { + continue; + } + this._valuesEnd[property] = [ + this._object[property] + ].concat(this._valuesEnd[property]); + } + this._valuesStart[property] = this._object[property]; + } + return this; + }; + Tween.prototype.stop = function () { + if(this._manager !== null) { + this._manager.remove(this); + } + return this; + }; + Object.defineProperty(Tween.prototype, "parent", { + set: function (value) { + this._game = value; + this._manager = this._game.tweens; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Tween.prototype, "delay", { + get: function () { + return this._delayTime; + }, + set: function (amount) { + this._delayTime = amount; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Tween.prototype, "easing", { + get: function () { + return this._easingFunction; + }, + set: function (easing) { + this._easingFunction = easing; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Tween.prototype, "interpolation", { + get: function () { + return this._interpolationFunction; + }, + set: function (interpolation) { + this._interpolationFunction = interpolation; + }, + enumerable: true, + configurable: true + }); + Tween.prototype.chain = function (tween) { + this._chainedTweens.push(tween); + return this; + }; + Tween.prototype.update = function (time) { + if(this._game.paused == true) { + if(this._pausedTime == 0) { + this._pausedTime = time; + } + } else { + if(this._pausedTime > 0) { + this._startTime += (time - this._pausedTime); + this._pausedTime = 0; + } + } + if(time < this._startTime) { + return true; + } + var elapsed = (time - this._startTime) / this._duration; + elapsed = elapsed > 1 ? 1 : elapsed; + var value = this._easingFunction(elapsed); + for(var property in this._valuesStart) { + if(this._valuesEnd[property] instanceof Array) { + this._object[property] = this._interpolationFunction(this._valuesEnd[property], value); + } else { + this._object[property] = this._valuesStart[property] + (this._valuesEnd[property] - this._valuesStart[property]) * value; + } + } + this.onUpdate.dispatch(this._object, value); + if(elapsed == 1) { + this.onComplete.dispatch(this._object); + for(var i = 0; i < this._chainedTweens.length; i++) { + this._chainedTweens[i].start(); + } + return false; + } + return true; + }; + return Tween; + })(); + Phaser.Tween = Tween; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var TweenManager = (function () { + function TweenManager(game) { + this._game = game; + this._tweens = []; + } + TweenManager.prototype.getAll = function () { + return this._tweens; + }; + TweenManager.prototype.removeAll = function () { + this._tweens.length = 0; + }; + TweenManager.prototype.create = function (object) { + return new Phaser.Tween(object, this._game); + }; + TweenManager.prototype.add = function (tween) { + tween.parent = this._game; + this._tweens.push(tween); + return tween; + }; + TweenManager.prototype.remove = function (tween) { + var i = this._tweens.indexOf(tween); + if(i !== -1) { + this._tweens.splice(i, 1); + } + }; + TweenManager.prototype.update = function () { + if(this._tweens.length === 0) { + return false; + } + var i = 0; + var numTweens = this._tweens.length; + while(i < numTweens) { + if(this._tweens[i].update(this._game.time.now)) { + i++; + } else { + this._tweens.splice(i, 1); + numTweens--; + } + } + return true; + }; + return TweenManager; + })(); + Phaser.TweenManager = TweenManager; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var World = (function () { + function World(game, width, height) { + this._game = game; + this._cameras = new Phaser.CameraManager(this._game, 0, 0, width, height); + this._game.camera = this._cameras.current; + this.group = new Phaser.Group(this._game, 0); + this.bounds = new Phaser.Rectangle(0, 0, width, height); + this.worldDivisions = 6; + } + World.prototype.update = function () { + this.group.preUpdate(); + this.group.update(); + this.group.postUpdate(); + this._cameras.update(); + }; + World.prototype.render = function () { + this._cameras.render(); + }; + World.prototype.destroy = function () { + this.group.destroy(); + this._cameras.destroy(); + }; + World.prototype.setSize = function (width, height, updateCameraBounds) { + if (typeof updateCameraBounds === "undefined") { updateCameraBounds = true; } + this.bounds.width = width; + this.bounds.height = height; + if(updateCameraBounds == true) { + this._game.camera.setBounds(0, 0, width, height); + } + }; + Object.defineProperty(World.prototype, "width", { + get: function () { + return this.bounds.width; + }, + set: function (value) { + this.bounds.width = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(World.prototype, "height", { + get: function () { + return this.bounds.height; + }, + set: function (value) { + this.bounds.height = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(World.prototype, "centerX", { + get: function () { + return this.bounds.halfWidth; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(World.prototype, "centerY", { + get: function () { + return this.bounds.halfHeight; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(World.prototype, "randomX", { + get: function () { + return Math.round(Math.random() * this.bounds.width); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(World.prototype, "randomY", { + get: function () { + return Math.round(Math.random() * this.bounds.height); + }, + enumerable: true, + configurable: true + }); + World.prototype.createCamera = function (x, y, width, height) { + return this._cameras.addCamera(x, y, width, height); + }; + World.prototype.removeCamera = function (id) { + return this._cameras.removeCamera(id); + }; + World.prototype.getAllCameras = function () { + return this._cameras.getAll(); + }; + World.prototype.createSprite = function (x, y, key) { + if (typeof key === "undefined") { key = ''; } + return this.group.add(new Phaser.Sprite(this._game, x, y, key)); + }; + World.prototype.createGeomSprite = function (x, y) { + return this.group.add(new Phaser.GeomSprite(this._game, x, y)); + }; + World.prototype.createDynamicTexture = function (width, height) { + return new Phaser.DynamicTexture(this._game, width, height); + }; + World.prototype.createGroup = function (MaxSize) { + if (typeof MaxSize === "undefined") { MaxSize = 0; } + return this.group.add(new Phaser.Group(this._game, MaxSize)); + }; + World.prototype.createScrollZone = function (key, x, y, width, height) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof width === "undefined") { width = 0; } + if (typeof height === "undefined") { height = 0; } + return this.group.add(new Phaser.ScrollZone(this._game, key, x, y, width, height)); + }; + World.prototype.createTilemap = function (key, mapData, format, resizeWorld, tileWidth, tileHeight) { + if (typeof resizeWorld === "undefined") { resizeWorld = true; } + if (typeof tileWidth === "undefined") { tileWidth = 0; } + if (typeof tileHeight === "undefined") { tileHeight = 0; } + return this.group.add(new Phaser.Tilemap(this._game, key, mapData, format, resizeWorld, tileWidth, tileHeight)); + }; + World.prototype.createParticle = function () { + return new Phaser.Particle(this._game); + }; + World.prototype.createEmitter = function (x, y, size) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof size === "undefined") { size = 0; } + return this.group.add(new Phaser.Emitter(this._game, x, y, size)); + }; + return World; + })(); + Phaser.World = World; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Device = (function () { + function Device() { + this.desktop = false; + this.iOS = false; + this.android = false; + this.chromeOS = false; + this.linux = false; + this.macOS = false; + this.windows = false; + this.canvas = false; + this.file = false; + this.fileSystem = false; + this.localStorage = false; + this.webGL = false; + this.worker = false; + this.touch = false; + this.css3D = false; + this.arora = false; + this.chrome = false; + this.epiphany = false; + this.firefox = false; + this.ie = false; + this.ieVersion = 0; + this.mobileSafari = false; + this.midori = false; + this.opera = false; + this.safari = false; + this.webApp = false; + this.audioData = false; + this.webaudio = false; + this.ogg = false; + this.mp3 = false; + this.wav = false; + this.m4a = false; + this.iPhone = false; + this.iPhone4 = false; + this.iPad = false; + this.pixelRatio = 0; + this._checkAudio(); + this._checkBrowser(); + this._checkCSS3D(); + this._checkDevice(); + this._checkFeatures(); + this._checkOS(); + } + Device.prototype._checkOS = function () { + var ua = navigator.userAgent; + if(/Android/.test(ua)) { + this.android = true; + } else if(/CrOS/.test(ua)) { + this.chromeOS = true; + } else if(/iP[ao]d|iPhone/i.test(ua)) { + this.iOS = true; + } else if(/Linux/.test(ua)) { + this.linux = true; + } else if(/Mac OS/.test(ua)) { + this.macOS = true; + } else if(/Windows/.test(ua)) { + this.windows = true; + } + if(this.windows || this.macOS || this.linux) { + this.desktop = true; + } + }; + Device.prototype._checkFeatures = function () { + this.canvas = !!window['CanvasRenderingContext2D']; + try { + this.localStorage = !!localStorage.getItem; + } catch (error) { + this.localStorage = false; + } + this.file = !!window['File'] && !!window['FileReader'] && !!window['FileList'] && !!window['Blob']; + this.fileSystem = !!window['requestFileSystem']; + this.webGL = !!window['WebGLRenderingContext']; + this.worker = !!window['Worker']; + if('ontouchstart' in document.documentElement || window.navigator.msPointerEnabled) { + this.touch = true; + } + }; + Device.prototype._checkBrowser = function () { + var ua = navigator.userAgent; + if(/Arora/.test(ua)) { + this.arora = true; + } else if(/Chrome/.test(ua)) { + this.chrome = true; + } else if(/Epiphany/.test(ua)) { + this.epiphany = true; + } else if(/Firefox/.test(ua)) { + this.firefox = true; + } else if(/Mobile Safari/.test(ua)) { + this.mobileSafari = true; + } else if(/MSIE (\d+\.\d+);/.test(ua)) { + this.ie = true; + this.ieVersion = parseInt(RegExp.$1); + } else if(/Midori/.test(ua)) { + this.midori = true; + } else if(/Opera/.test(ua)) { + this.opera = true; + } else if(/Safari/.test(ua)) { + this.safari = true; + } + if(navigator['standalone']) { + this.webApp = true; + } + }; + Device.prototype._checkAudio = function () { + this.audioData = !!(window['Audio']); + this.webaudio = !!(window['webkitAudioContext'] || window['AudioContext']); + var audioElement = document.createElement('audio'); + var result = false; + try { + if(result = !!audioElement.canPlayType) { + if(audioElement.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) { + this.ogg = true; + } + if(audioElement.canPlayType('audio/mpeg;').replace(/^no$/, '')) { + this.mp3 = true; + } + if(audioElement.canPlayType('audio/wav; codecs="1"').replace(/^no$/, '')) { + this.wav = true; + } + if(audioElement.canPlayType('audio/x-m4a;') || audioElement.canPlayType('audio/aac;').replace(/^no$/, '')) { + this.m4a = true; + } + } + } catch (e) { + } + }; + Device.prototype._checkDevice = function () { + this.pixelRatio = window['devicePixelRatio'] || 1; + this.iPhone = navigator.userAgent.toLowerCase().indexOf('iphone') != -1; + this.iPhone4 = (this.pixelRatio == 2 && this.iPhone); + this.iPad = navigator.userAgent.toLowerCase().indexOf('ipad') != -1; + }; + Device.prototype._checkCSS3D = function () { + var el = document.createElement('p'); + var has3d; + var transforms = { + 'webkitTransform': '-webkit-transform', + 'OTransform': '-o-transform', + 'msTransform': '-ms-transform', + 'MozTransform': '-moz-transform', + 'transform': 'transform' + }; + document.body.insertBefore(el, null); + for(var t in transforms) { + if(el.style[t] !== undefined) { + el.style[t] = "translate3d(1px,1px,1px)"; + has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]); + } + } + document.body.removeChild(el); + this.css3D = (has3d !== undefined && has3d.length > 0 && has3d !== "none"); + }; + Device.prototype.getAll = function () { + var output = ''; + output = output.concat('Device\n'); + output = output.concat('iPhone : ' + this.iPhone + '\n'); + output = output.concat('iPhone4 : ' + this.iPhone4 + '\n'); + output = output.concat('iPad : ' + this.iPad + '\n'); + output = output.concat('\n'); + output = output.concat('Operating System\n'); + output = output.concat('iOS: ' + this.iOS + '\n'); + output = output.concat('Android: ' + this.android + '\n'); + output = output.concat('ChromeOS: ' + this.chromeOS + '\n'); + output = output.concat('Linux: ' + this.linux + '\n'); + output = output.concat('MacOS: ' + this.macOS + '\n'); + output = output.concat('Windows: ' + this.windows + '\n'); + output = output.concat('\n'); + output = output.concat('Browser\n'); + output = output.concat('Arora: ' + this.arora + '\n'); + output = output.concat('Chrome: ' + this.chrome + '\n'); + output = output.concat('Epiphany: ' + this.epiphany + '\n'); + output = output.concat('Firefox: ' + this.firefox + '\n'); + output = output.concat('Internet Explorer: ' + this.ie + ' (' + this.ieVersion + ')\n'); + output = output.concat('Mobile Safari: ' + this.mobileSafari + '\n'); + output = output.concat('Midori: ' + this.midori + '\n'); + output = output.concat('Opera: ' + this.opera + '\n'); + output = output.concat('Safari: ' + this.safari + '\n'); + output = output.concat('\n'); + output = output.concat('Features\n'); + output = output.concat('Canvas: ' + this.canvas + '\n'); + output = output.concat('File: ' + this.file + '\n'); + output = output.concat('FileSystem: ' + this.fileSystem + '\n'); + output = output.concat('LocalStorage: ' + this.localStorage + '\n'); + output = output.concat('WebGL: ' + this.webGL + '\n'); + output = output.concat('Worker: ' + this.worker + '\n'); + output = output.concat('Touch: ' + this.touch + '\n'); + output = output.concat('CSS 3D: ' + this.css3D + '\n'); + output = output.concat('\n'); + output = output.concat('Audio\n'); + output = output.concat('Audio Data: ' + this.canvas + '\n'); + output = output.concat('Web Audio: ' + this.canvas + '\n'); + output = output.concat('Can play OGG: ' + this.canvas + '\n'); + output = output.concat('Can play MP3: ' + this.canvas + '\n'); + output = output.concat('Can play M4A: ' + this.canvas + '\n'); + output = output.concat('Can play WAV: ' + this.canvas + '\n'); + return output; + }; + return Device; + })(); + Phaser.Device = Device; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var RandomDataGenerator = (function () { + function RandomDataGenerator(seeds) { + if (typeof seeds === "undefined") { seeds = []; } + this.c = 1; + this.sow(seeds); + } + RandomDataGenerator.prototype.uint32 = function () { + return this.rnd.apply(this) * 0x100000000; + }; + RandomDataGenerator.prototype.fract32 = function () { + return this.rnd.apply(this) + (this.rnd.apply(this) * 0x200000 | 0) * 1.1102230246251565e-16; + }; + RandomDataGenerator.prototype.rnd = function () { + var t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10; + this.c = t | 0; + this.s0 = this.s1; + this.s1 = this.s2; + this.s2 = t - this.c; + return this.s2; + }; + RandomDataGenerator.prototype.hash = function (data) { + var h, i, n; + n = 0xefc8249d; + data = data.toString(); + for(i = 0; i < data.length; i++) { + n += data.charCodeAt(i); + h = 0.02519603282416938 * n; + n = h >>> 0; + h -= n; + h *= n; + n = h >>> 0; + h -= n; + n += h * 0x100000000; + } + return (n >>> 0) * 2.3283064365386963e-10; + }; + RandomDataGenerator.prototype.sow = function (seeds) { + if (typeof seeds === "undefined") { seeds = []; } + this.s0 = this.hash(' '); + this.s1 = this.hash(this.s0); + this.s2 = this.hash(this.s1); + var seed; + for(var i = 0; seed = seeds[i++]; ) { + this.s0 -= this.hash(seed); + this.s0 += ~~(this.s0 < 0); + this.s1 -= this.hash(seed); + this.s1 += ~~(this.s1 < 0); + this.s2 -= this.hash(seed); + this.s2 += ~~(this.s2 < 0); + } + }; + Object.defineProperty(RandomDataGenerator.prototype, "integer", { + get: function () { + return this.uint32(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RandomDataGenerator.prototype, "frac", { + get: function () { + return this.fract32(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RandomDataGenerator.prototype, "real", { + get: function () { + return this.uint32() + this.fract32(); + }, + enumerable: true, + configurable: true + }); + RandomDataGenerator.prototype.integerInRange = function (min, max) { + return Math.floor(this.realInRange(min, max)); + }; + RandomDataGenerator.prototype.realInRange = function (min, max) { + min = min || 0; + max = max || 0; + return this.frac * (max - min) + min; + }; + Object.defineProperty(RandomDataGenerator.prototype, "normal", { + get: function () { + return 1 - 2 * this.frac; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RandomDataGenerator.prototype, "uuid", { + get: function () { + var a, b; + for(b = a = ''; a++ < 36; b += ~a % 5 | a * 3 & 4 ? (a ^ 15 ? 8 ^ this.frac * (a ^ 20 ? 16 : 4) : 4).toString(16) : '-') { + ; + } + return b; + }, + enumerable: true, + configurable: true + }); + RandomDataGenerator.prototype.pick = function (array) { + return array[this.integerInRange(0, array.length)]; + }; + RandomDataGenerator.prototype.weightedPick = function (array) { + return array[~~(Math.pow(this.frac, 2) * array.length)]; + }; + RandomDataGenerator.prototype.timestamp = function (min, max) { + if (typeof min === "undefined") { min = 946684800000; } + if (typeof max === "undefined") { max = 1577862000000; } + return this.realInRange(min, max); + }; + Object.defineProperty(RandomDataGenerator.prototype, "angle", { + get: function () { + return this.integerInRange(-180, 180); + }, + enumerable: true, + configurable: true + }); + return RandomDataGenerator; + })(); + Phaser.RandomDataGenerator = RandomDataGenerator; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var RequestAnimationFrame = (function () { + function RequestAnimationFrame(callback, callbackContext) { + this._isSetTimeOut = false; + this.lastTime = 0; + this.currentTime = 0; + this.isRunning = false; + this._callback = callback; + this._callbackContext = callbackContext; + var vendors = [ + 'ms', + 'moz', + 'webkit', + 'o' + ]; + for(var x = 0; x < vendors.length && !window.requestAnimationFrame; x++) { + window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; + window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame']; + } + this.start(); + } + RequestAnimationFrame.prototype.setCallback = function (callback) { + this._callback = callback; + }; + RequestAnimationFrame.prototype.isUsingSetTimeOut = function () { + return this._isSetTimeOut; + }; + RequestAnimationFrame.prototype.isUsingRAF = function () { + if(this._isSetTimeOut === true) { + return false; + } else { + return true; + } + }; + RequestAnimationFrame.prototype.start = function (callback) { + if (typeof callback === "undefined") { callback = null; } + var _this = this; + if(callback) { + this._callback = callback; + } + if(!window.requestAnimationFrame) { + this._isSetTimeOut = true; + this._timeOutID = window.setTimeout(function () { + return _this.SetTimeoutUpdate(); + }, 0); + } else { + this._isSetTimeOut = false; + window.requestAnimationFrame(function () { + return _this.RAFUpdate(); + }); + } + this.isRunning = true; + }; + RequestAnimationFrame.prototype.stop = function () { + if(this._isSetTimeOut) { + clearTimeout(this._timeOutID); + } else { + window.cancelAnimationFrame; + } + this.isRunning = false; + }; + RequestAnimationFrame.prototype.RAFUpdate = function () { + var _this = this; + this.currentTime = Date.now(); + if(this._callback) { + this._callback.call(this._callbackContext); + } + var timeToCall = Math.max(0, 16 - (this.currentTime - this.lastTime)); + window.requestAnimationFrame(function () { + return _this.RAFUpdate(); + }); + this.lastTime = this.currentTime + timeToCall; + }; + RequestAnimationFrame.prototype.SetTimeoutUpdate = function () { + var _this = this; + this.currentTime = Date.now(); + if(this._callback) { + this._callback.call(this._callbackContext); + } + var timeToCall = Math.max(0, 16 - (this.currentTime - this.lastTime)); + this._timeOutID = window.setTimeout(function () { + return _this.SetTimeoutUpdate(); + }, timeToCall); + this.lastTime = this.currentTime + timeToCall; + }; + return RequestAnimationFrame; + })(); + Phaser.RequestAnimationFrame = RequestAnimationFrame; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Input = (function () { + function Input(game) { + this.x = 0; + this.y = 0; + this.scaleX = 1; + this.scaleY = 1; + this.worldX = 0; + this.worldY = 0; + this._game = game; + this.mouse = new Phaser.Mouse(this._game); + this.keyboard = new Phaser.Keyboard(this._game); + this.touch = new Phaser.Touch(this._game); + this.onDown = new Phaser.Signal(); + this.onUp = new Phaser.Signal(); + } + Input.prototype.update = function () { + this.x = Math.round(this.x); + this.y = Math.round(this.y); + this.worldX = this._game.camera.worldView.x + this.x; + this.worldY = this._game.camera.worldView.y + this.y; + this.mouse.update(); + this.touch.update(); + }; + Input.prototype.reset = function () { + this.mouse.reset(); + this.keyboard.reset(); + this.touch.reset(); + }; + Input.prototype.getWorldX = function (camera) { + if (typeof camera === "undefined") { camera = this._game.camera; } + return camera.worldView.x + this.x; + }; + Input.prototype.getWorldY = function (camera) { + if (typeof camera === "undefined") { camera = this._game.camera; } + return camera.worldView.y + this.y; + }; + Input.prototype.renderDebugInfo = function (x, y, color) { + if (typeof color === "undefined") { color = 'rgb(255,255,255)'; } + this._game.stage.context.font = '14px Courier'; + this._game.stage.context.fillStyle = color; + this._game.stage.context.fillText('Input', x, y); + this._game.stage.context.fillText('Screen X: ' + this.x + ' Screen Y: ' + this.y, x, y + 14); + this._game.stage.context.fillText('World X: ' + this.worldX + ' World Y: ' + this.worldY, x, y + 28); + this._game.stage.context.fillText('Scale X: ' + this.scaleX.toFixed(1) + ' Scale Y: ' + this.scaleY.toFixed(1), x, y + 42); + }; + return Input; + })(); + Phaser.Input = Input; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Keyboard = (function () { + function Keyboard(game) { + this._keys = { + }; + this._capture = { + }; + this._game = game; + this.start(); + } + Keyboard.prototype.start = function () { + var _this = this; + document.body.addEventListener('keydown', function (event) { + return _this.onKeyDown(event); + }, false); + document.body.addEventListener('keyup', function (event) { + return _this.onKeyUp(event); + }, false); + }; + Keyboard.prototype.addKeyCapture = function (keycode) { + if(typeof keycode === 'object') { + for(var i = 0; i < keycode.length; i++) { + this._capture[keycode[i]] = true; + } + } else { + this._capture[keycode] = true; + } + }; + Keyboard.prototype.removeKeyCapture = function (keycode) { + delete this._capture[keycode]; + }; + Keyboard.prototype.clearCaptures = function () { + this._capture = { + }; + }; + Keyboard.prototype.onKeyDown = function (event) { + if(this._capture[event.keyCode]) { + event.preventDefault(); + } + if(!this._keys[event.keyCode]) { + this._keys[event.keyCode] = { + isDown: true, + timeDown: this._game.time.now, + timeUp: 0 + }; + } else { + this._keys[event.keyCode].isDown = true; + this._keys[event.keyCode].timeDown = this._game.time.now; + } + }; + Keyboard.prototype.onKeyUp = function (event) { + if(this._capture[event.keyCode]) { + event.preventDefault(); + } + if(!this._keys[event.keyCode]) { + this._keys[event.keyCode] = { + isDown: false, + timeDown: 0, + timeUp: this._game.time.now + }; + } else { + this._keys[event.keyCode].isDown = false; + this._keys[event.keyCode].timeUp = this._game.time.now; + } + }; + Keyboard.prototype.reset = function () { + for(var key in this._keys) { + this._keys[key].isDown = false; + } + }; + Keyboard.prototype.justPressed = function (keycode, duration) { + if (typeof duration === "undefined") { duration = 250; } + if(this._keys[keycode] && this._keys[keycode].isDown === true && (this._game.time.now - this._keys[keycode].timeDown < duration)) { + return true; + } else { + return false; + } + }; + Keyboard.prototype.justReleased = function (keycode, duration) { + if (typeof duration === "undefined") { duration = 250; } + if(this._keys[keycode] && this._keys[keycode].isDown === false && (this._game.time.now - this._keys[keycode].timeUp < duration)) { + return true; + } else { + return false; + } + }; + Keyboard.prototype.isDown = function (keycode) { + if(this._keys[keycode]) { + return this._keys[keycode].isDown; + } else { + return false; + } + }; + Keyboard.A = "A".charCodeAt(0); + Keyboard.B = "B".charCodeAt(0); + Keyboard.C = "C".charCodeAt(0); + Keyboard.D = "D".charCodeAt(0); + Keyboard.E = "E".charCodeAt(0); + Keyboard.F = "F".charCodeAt(0); + Keyboard.G = "G".charCodeAt(0); + Keyboard.H = "H".charCodeAt(0); + Keyboard.I = "I".charCodeAt(0); + Keyboard.J = "J".charCodeAt(0); + Keyboard.K = "K".charCodeAt(0); + Keyboard.L = "L".charCodeAt(0); + Keyboard.M = "M".charCodeAt(0); + Keyboard.N = "N".charCodeAt(0); + Keyboard.O = "O".charCodeAt(0); + Keyboard.P = "P".charCodeAt(0); + Keyboard.Q = "Q".charCodeAt(0); + Keyboard.R = "R".charCodeAt(0); + Keyboard.S = "S".charCodeAt(0); + Keyboard.T = "T".charCodeAt(0); + Keyboard.U = "U".charCodeAt(0); + Keyboard.V = "V".charCodeAt(0); + Keyboard.W = "W".charCodeAt(0); + Keyboard.X = "X".charCodeAt(0); + Keyboard.Y = "Y".charCodeAt(0); + Keyboard.Z = "Z".charCodeAt(0); + Keyboard.ZERO = "0".charCodeAt(0); + Keyboard.ONE = "1".charCodeAt(0); + Keyboard.TWO = "2".charCodeAt(0); + Keyboard.THREE = "3".charCodeAt(0); + Keyboard.FOUR = "4".charCodeAt(0); + Keyboard.FIVE = "5".charCodeAt(0); + Keyboard.SIX = "6".charCodeAt(0); + Keyboard.SEVEN = "7".charCodeAt(0); + Keyboard.EIGHT = "8".charCodeAt(0); + Keyboard.NINE = "9".charCodeAt(0); + Keyboard.NUMPAD_0 = 96; + Keyboard.NUMPAD_1 = 97; + Keyboard.NUMPAD_2 = 98; + Keyboard.NUMPAD_3 = 99; + Keyboard.NUMPAD_4 = 100; + Keyboard.NUMPAD_5 = 101; + Keyboard.NUMPAD_6 = 102; + Keyboard.NUMPAD_7 = 103; + Keyboard.NUMPAD_8 = 104; + Keyboard.NUMPAD_9 = 105; + Keyboard.NUMPAD_MULTIPLY = 106; + Keyboard.NUMPAD_ADD = 107; + Keyboard.NUMPAD_ENTER = 108; + Keyboard.NUMPAD_SUBTRACT = 109; + Keyboard.NUMPAD_DECIMAL = 110; + Keyboard.NUMPAD_DIVIDE = 111; + Keyboard.F1 = 112; + Keyboard.F2 = 113; + Keyboard.F3 = 114; + Keyboard.F4 = 115; + Keyboard.F5 = 116; + Keyboard.F6 = 117; + Keyboard.F7 = 118; + Keyboard.F8 = 119; + Keyboard.F9 = 120; + Keyboard.F10 = 121; + Keyboard.F11 = 122; + Keyboard.F12 = 123; + Keyboard.F13 = 124; + Keyboard.F14 = 125; + Keyboard.F15 = 126; + Keyboard.COLON = 186; + Keyboard.EQUALS = 187; + Keyboard.UNDERSCORE = 189; + Keyboard.QUESTION_MARK = 191; + Keyboard.TILDE = 192; + Keyboard.OPEN_BRACKET = 219; + Keyboard.BACKWARD_SLASH = 220; + Keyboard.CLOSED_BRACKET = 221; + Keyboard.QUOTES = 222; + Keyboard.BACKSPACE = 8; + Keyboard.TAB = 9; + Keyboard.CLEAR = 12; + Keyboard.ENTER = 13; + Keyboard.SHIFT = 16; + Keyboard.CONTROL = 17; + Keyboard.ALT = 18; + Keyboard.CAPS_LOCK = 20; + Keyboard.ESC = 27; + Keyboard.SPACEBAR = 32; + Keyboard.PAGE_UP = 33; + Keyboard.PAGE_DOWN = 34; + Keyboard.END = 35; + Keyboard.HOME = 36; + Keyboard.LEFT = 37; + Keyboard.UP = 38; + Keyboard.RIGHT = 39; + Keyboard.DOWN = 40; + Keyboard.INSERT = 45; + Keyboard.DELETE = 46; + Keyboard.HELP = 47; + Keyboard.NUM_LOCK = 144; + return Keyboard; + })(); + Phaser.Keyboard = Keyboard; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Mouse = (function () { + function Mouse(game) { + this._x = 0; + this._y = 0; + this.isDown = false; + this.isUp = true; + this.timeDown = 0; + this.duration = 0; + this.timeUp = 0; + this._game = game; + this.start(); + } + Mouse.LEFT_BUTTON = 0; + Mouse.MIDDLE_BUTTON = 1; + Mouse.RIGHT_BUTTON = 2; + Mouse.prototype.start = function () { + var _this = this; + this._game.stage.canvas.addEventListener('mousedown', function (event) { + return _this.onMouseDown(event); + }, true); + this._game.stage.canvas.addEventListener('mousemove', function (event) { + return _this.onMouseMove(event); + }, true); + this._game.stage.canvas.addEventListener('mouseup', function (event) { + return _this.onMouseUp(event); + }, true); + }; + Mouse.prototype.reset = function () { + this.isDown = false; + this.isUp = true; + }; + Mouse.prototype.onMouseDown = function (event) { + this.button = event.button; + this._x = event.clientX - this._game.stage.x; + this._y = event.clientY - this._game.stage.y; + this._game.input.x = this._x * this._game.input.scaleX; + this._game.input.y = this._y * this._game.input.scaleY; + this.isDown = true; + this.isUp = false; + this.timeDown = this._game.time.now; + this._game.input.onDown.dispatch(this._game.input.x, this._game.input.y, this.timeDown); + }; + Mouse.prototype.update = function () { + if(this.isDown) { + this.duration = this._game.time.now - this.timeDown; + } + }; + Mouse.prototype.onMouseMove = function (event) { + this.button = event.button; + this._x = event.clientX - this._game.stage.x; + this._y = event.clientY - this._game.stage.y; + this._game.input.x = this._x * this._game.input.scaleX; + this._game.input.y = this._y * this._game.input.scaleY; + }; + Mouse.prototype.onMouseUp = function (event) { + this.button = event.button; + this.isDown = false; + this.isUp = true; + this.timeUp = this._game.time.now; + this.duration = this.timeUp - this.timeDown; + this._x = event.clientX - this._game.stage.x; + this._y = event.clientY - this._game.stage.y; + this._game.input.x = this._x * this._game.input.scaleX; + this._game.input.y = this._y * this._game.input.scaleY; + this._game.input.onUp.dispatch(this._game.input.x, this._game.input.y, this.timeDown); + }; + return Mouse; + })(); + Phaser.Mouse = Mouse; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Finger = (function () { + function Finger(game) { + this.point = null; + this.circle = null; + this.withinGame = false; + this.clientX = -1; + this.clientY = -1; + this.pageX = -1; + this.pageY = -1; + this.screenX = -1; + this.screenY = -1; + this.x = -1; + this.y = -1; + this.isDown = false; + this.isUp = false; + this.timeDown = 0; + this.duration = 0; + this.timeUp = 0; + this.justPressedRate = 200; + this.justReleasedRate = 200; + this._game = game; + this.active = false; + } + Finger.prototype.start = function (event) { + this.identifier = event.identifier; + this.target = event.target; + if(this.point === null) { + this.point = new Phaser.Point(); + } + if(this.circle === null) { + this.circle = new Phaser.Circle(0, 0, 44); + } + this.move(event); + this.active = true; + this.withinGame = true; + this.isDown = true; + this.isUp = false; + this.timeDown = this._game.time.now; + }; + Finger.prototype.move = function (event) { + this.clientX = event.clientX; + this.clientY = event.clientY; + this.pageX = event.pageX; + this.pageY = event.pageY; + this.screenX = event.screenX; + this.screenY = event.screenY; + this.x = this.pageX - this._game.stage.offset.x; + this.y = this.pageY - this._game.stage.offset.y; + this.point.setTo(this.x, this.y); + this.circle.setTo(this.x, this.y, 44); + this.duration = this._game.time.now - this.timeDown; + }; + Finger.prototype.leave = function (event) { + this.withinGame = false; + this.move(event); + }; + Finger.prototype.stop = function (event) { + this.active = false; + this.withinGame = false; + this.isDown = false; + this.isUp = true; + this.timeUp = this._game.time.now; + this.duration = this.timeUp - this.timeDown; + }; + Finger.prototype.justPressed = function (duration) { + if (typeof duration === "undefined") { duration = this.justPressedRate; } + if(this.isDown === true && (this.timeDown + duration) > this._game.time.now) { + return true; + } else { + return false; + } + }; + Finger.prototype.justReleased = function (duration) { + if (typeof duration === "undefined") { duration = this.justReleasedRate; } + if(this.isUp === true && (this.timeUp + duration) > this._game.time.now) { + return true; + } else { + return false; + } + }; + Finger.prototype.toString = function () { + return "[{Finger (identifer=" + this.identifier + " active=" + this.active + " duration=" + this.duration + " withinGame=" + this.withinGame + " x=" + this.x + " y=" + this.y + " clientX=" + this.clientX + " clientY=" + this.clientY + " screenX=" + this.screenX + " screenY=" + this.screenY + " pageX=" + this.pageX + " pageY=" + this.pageY + ")}]"; + }; + return Finger; + })(); + Phaser.Finger = Finger; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Touch = (function () { + function Touch(game) { + this.x = 0; + this.y = 0; + this.isDown = false; + this.isUp = true; + this._game = game; + this.finger1 = new Phaser.Finger(this._game); + this.finger2 = new Phaser.Finger(this._game); + this.finger3 = new Phaser.Finger(this._game); + this.finger4 = new Phaser.Finger(this._game); + this.finger5 = new Phaser.Finger(this._game); + this.finger6 = new Phaser.Finger(this._game); + this.finger7 = new Phaser.Finger(this._game); + this.finger8 = new Phaser.Finger(this._game); + this.finger9 = new Phaser.Finger(this._game); + this.finger10 = new Phaser.Finger(this._game); + this._fingers = [ + this.finger1, + this.finger2, + this.finger3, + this.finger4, + this.finger5, + this.finger6, + this.finger7, + this.finger8, + this.finger9, + this.finger10 + ]; + this.touchDown = new Phaser.Signal(); + this.touchUp = new Phaser.Signal(); + this.start(); + } + Touch.prototype.start = function () { + var _this = this; + this._game.stage.canvas.addEventListener('touchstart', function (event) { + return _this.onTouchStart(event); + }, false); + this._game.stage.canvas.addEventListener('touchmove', function (event) { + return _this.onTouchMove(event); + }, false); + this._game.stage.canvas.addEventListener('touchend', function (event) { + return _this.onTouchEnd(event); + }, false); + this._game.stage.canvas.addEventListener('touchenter', function (event) { + return _this.onTouchEnter(event); + }, false); + this._game.stage.canvas.addEventListener('touchleave', function (event) { + return _this.onTouchLeave(event); + }, false); + this._game.stage.canvas.addEventListener('touchcancel', function (event) { + return _this.onTouchCancel(event); + }, false); + document.addEventListener('touchmove', function (event) { + return _this.consumeTouchMove(event); + }, false); + }; + Touch.prototype.consumeTouchMove = function (event) { + event.preventDefault(); + }; + Touch.prototype.onTouchStart = function (event) { + event.preventDefault(); + for(var i = 0; i < event.changedTouches.length; i++) { + for(var f = 0; f < this._fingers.length; f++) { + if(this._fingers[f].active === false) { + this._fingers[f].start(event.changedTouches[i]); + this.x = this._fingers[f].x; + this.y = this._fingers[f].y; + this._game.input.x = this.x * this._game.input.scaleX; + this._game.input.y = this.y * this._game.input.scaleY; + this.touchDown.dispatch(this._fingers[f].x, this._fingers[f].y, this._fingers[f].timeDown, this._fingers[f].timeUp, this._fingers[f].duration); + this._game.input.onDown.dispatch(this._game.input.x, this._game.input.y, this._fingers[f].timeDown); + this.isDown = true; + this.isUp = false; + break; + } + } + } + }; + Touch.prototype.onTouchCancel = function (event) { + event.preventDefault(); + for(var i = 0; i < event.changedTouches.length; i++) { + for(var f = 0; f < this._fingers.length; f++) { + if(this._fingers[f].identifier === event.changedTouches[i].identifier) { + this._fingers[f].stop(event.changedTouches[i]); + break; + } + } + } + }; + Touch.prototype.onTouchEnter = function (event) { + event.preventDefault(); + for(var i = 0; i < event.changedTouches.length; i++) { + for(var f = 0; f < this._fingers.length; f++) { + if(this._fingers[f].active === false) { + this._fingers[f].start(event.changedTouches[i]); + break; + } + } + } + }; + Touch.prototype.onTouchLeave = function (event) { + event.preventDefault(); + for(var i = 0; i < event.changedTouches.length; i++) { + for(var f = 0; f < this._fingers.length; f++) { + if(this._fingers[f].identifier === event.changedTouches[i].identifier) { + this._fingers[f].leave(event.changedTouches[i]); + break; + } + } + } + }; + Touch.prototype.onTouchMove = function (event) { + event.preventDefault(); + for(var i = 0; i < event.changedTouches.length; i++) { + for(var f = 0; f < this._fingers.length; f++) { + if(this._fingers[f].identifier === event.changedTouches[i].identifier) { + this._fingers[f].move(event.changedTouches[i]); + this.x = this._fingers[f].x; + this.y = this._fingers[f].y; + this._game.input.x = this.x * this._game.input.scaleX; + this._game.input.y = this.y * this._game.input.scaleY; + break; + } + } + } + }; + Touch.prototype.onTouchEnd = function (event) { + event.preventDefault(); + for(var i = 0; i < event.changedTouches.length; i++) { + for(var f = 0; f < this._fingers.length; f++) { + if(this._fingers[f].identifier === event.changedTouches[i].identifier) { + this._fingers[f].stop(event.changedTouches[i]); + this.x = this._fingers[f].x; + this.y = this._fingers[f].y; + this._game.input.x = this.x * this._game.input.scaleX; + this._game.input.y = this.y * this._game.input.scaleY; + this.touchUp.dispatch(this._fingers[f].x, this._fingers[f].y, this._fingers[f].timeDown, this._fingers[f].timeUp, this._fingers[f].duration); + this._game.input.onUp.dispatch(this._game.input.x, this._game.input.y, this._fingers[f].timeUp); + this.isDown = false; + this.isUp = true; + break; + } + } + } + }; + Touch.prototype.calculateDistance = function (finger1, finger2) { + }; + Touch.prototype.calculateAngle = function (finger1, finger2) { + }; + Touch.prototype.checkOverlap = function (finger1, finger2) { + }; + Touch.prototype.update = function () { + }; + Touch.prototype.stop = function () { + }; + Touch.prototype.reset = function () { + this.isDown = false; + this.isUp = false; + }; + return Touch; + })(); + Phaser.Touch = Touch; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Emitter = (function (_super) { + __extends(Emitter, _super); + function Emitter(game, X, Y, Size) { + if (typeof X === "undefined") { X = 0; } + if (typeof Y === "undefined") { Y = 0; } + if (typeof Size === "undefined") { Size = 0; } + _super.call(this, game, Size); + this.x = X; + this.y = Y; + this.width = 0; + this.height = 0; + this.minParticleSpeed = new Phaser.Point(-100, -100); + this.maxParticleSpeed = new Phaser.Point(100, 100); + this.minRotation = -360; + this.maxRotation = 360; + this.gravity = 0; + this.particleClass = null; + this.particleDrag = new Phaser.Point(); + this.frequency = 0.1; + this.lifespan = 3; + this.bounce = 0; + this._quantity = 0; + this._counter = 0; + this._explode = true; + this.on = false; + this._point = new Phaser.Point(); + } + Emitter.prototype.destroy = function () { + this.minParticleSpeed = null; + this.maxParticleSpeed = null; + this.particleDrag = null; + this.particleClass = null; + this._point = null; + _super.prototype.destroy.call(this); + }; + Emitter.prototype.makeParticles = function (Graphics, Quantity, BakedRotations, Multiple, Collide) { + if (typeof Quantity === "undefined") { Quantity = 50; } + if (typeof BakedRotations === "undefined") { BakedRotations = 16; } + if (typeof Multiple === "undefined") { Multiple = false; } + if (typeof Collide === "undefined") { Collide = 0.8; } + this.maxSize = Quantity; + var totalFrames = 1; + var randomFrame; + var particle; + var i = 0; + while(i < Quantity) { + if(this.particleClass == null) { + particle = new Phaser.Particle(this._game); + } else { + particle = new this.particleClass(this._game); + } + if(Multiple) { + } else { + if(Graphics) { + particle.loadGraphic(Graphics); + } + } + if(Collide > 0) { + particle.width *= Collide; + particle.height *= Collide; + } else { + particle.allowCollisions = Phaser.Collision.NONE; + } + particle.exists = false; + this.add(particle); + i++; + } + return this; + }; + Emitter.prototype.update = function () { + if(this.on) { + if(this._explode) { + this.on = false; + var i = 0; + var l = this._quantity; + if((l <= 0) || (l > this.length)) { + l = this.length; + } + while(i < l) { + this.emitParticle(); + i++; + } + this._quantity = 0; + } else { + this._timer += this._game.time.elapsed; + while((this.frequency > 0) && (this._timer > this.frequency) && this.on) { + this._timer -= this.frequency; + this.emitParticle(); + if((this._quantity > 0) && (++this._counter >= this._quantity)) { + this.on = false; + this._quantity = 0; + } + } + } + } + _super.prototype.update.call(this); + }; + Emitter.prototype.kill = function () { + this.on = false; + _super.prototype.kill.call(this); + }; + Emitter.prototype.start = function (Explode, Lifespan, Frequency, Quantity) { + if (typeof Explode === "undefined") { Explode = true; } + if (typeof Lifespan === "undefined") { Lifespan = 0; } + if (typeof Frequency === "undefined") { Frequency = 0.1; } + if (typeof Quantity === "undefined") { Quantity = 0; } + this.revive(); + this.visible = true; + this.on = true; + this._explode = Explode; + this.lifespan = Lifespan; + this.frequency = Frequency; + this._quantity += Quantity; + this._counter = 0; + this._timer = 0; + }; + Emitter.prototype.emitParticle = function () { + var particle = this.recycle(Phaser.Particle); + particle.lifespan = this.lifespan; + particle.elasticity = this.bounce; + particle.reset(this.x - (particle.width >> 1) + this._game.math.random() * this.width, this.y - (particle.height >> 1) + this._game.math.random() * this.height); + particle.visible = true; + if(this.minParticleSpeed.x != this.maxParticleSpeed.x) { + particle.velocity.x = this.minParticleSpeed.x + this._game.math.random() * (this.maxParticleSpeed.x - this.minParticleSpeed.x); + } else { + particle.velocity.x = this.minParticleSpeed.x; + } + if(this.minParticleSpeed.y != this.maxParticleSpeed.y) { + particle.velocity.y = this.minParticleSpeed.y + this._game.math.random() * (this.maxParticleSpeed.y - this.minParticleSpeed.y); + } else { + particle.velocity.y = this.minParticleSpeed.y; + } + particle.acceleration.y = this.gravity; + if(this.minRotation != this.maxRotation && this.minRotation !== 0 && this.maxRotation !== 0) { + particle.angularVelocity = this.minRotation + this._game.math.random() * (this.maxRotation - this.minRotation); + } else { + particle.angularVelocity = this.minRotation; + } + if(particle.angularVelocity != 0) { + particle.angle = this._game.math.random() * 360 - 180; + } + particle.drag.x = this.particleDrag.x; + particle.drag.y = this.particleDrag.y; + particle.onEmit(); + }; + Emitter.prototype.setSize = function (Width, Height) { + this.width = Width; + this.height = Height; + }; + Emitter.prototype.setXSpeed = function (Min, Max) { + if (typeof Min === "undefined") { Min = 0; } + if (typeof Max === "undefined") { Max = 0; } + this.minParticleSpeed.x = Min; + this.maxParticleSpeed.x = Max; + }; + Emitter.prototype.setYSpeed = function (Min, Max) { + if (typeof Min === "undefined") { Min = 0; } + if (typeof Max === "undefined") { Max = 0; } + this.minParticleSpeed.y = Min; + this.maxParticleSpeed.y = Max; + }; + Emitter.prototype.setRotation = function (Min, Max) { + if (typeof Min === "undefined") { Min = 0; } + if (typeof Max === "undefined") { Max = 0; } + this.minRotation = Min; + this.maxRotation = Max; + }; + Emitter.prototype.at = function (Object) { + Object.getMidpoint(this._point); + this.x = this._point.x - (this.width >> 1); + this.y = this._point.y - (this.height >> 1); + }; + return Emitter; + })(Phaser.Group); + Phaser.Emitter = Emitter; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var GeomSprite = (function (_super) { + __extends(GeomSprite, _super); + function GeomSprite(game, x, y) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + _super.call(this, game, x, y); + this._dx = 0; + this._dy = 0; + this._dw = 0; + this._dh = 0; + this.type = 0; + this.renderOutline = true; + this.renderFill = true; + this.lineWidth = 1; + this.lineColor = 'rgb(0,255,0)'; + this.fillColor = 'rgb(0,100,0)'; + this.type = GeomSprite.UNASSIGNED; + return this; + } + GeomSprite.UNASSIGNED = 0; + GeomSprite.CIRCLE = 1; + GeomSprite.LINE = 2; + GeomSprite.POINT = 3; + GeomSprite.RECTANGLE = 4; + GeomSprite.prototype.loadCircle = function (circle) { + this.refresh(); + this.circle = circle; + this.type = GeomSprite.CIRCLE; + return this; + }; + GeomSprite.prototype.loadLine = function (line) { + this.refresh(); + this.line = line; + this.type = GeomSprite.LINE; + return this; + }; + GeomSprite.prototype.loadPoint = function (point) { + this.refresh(); + this.point = point; + this.type = GeomSprite.POINT; + return this; + }; + GeomSprite.prototype.loadRectangle = function (rect) { + this.refresh(); + this.rect = rect; + this.type = GeomSprite.RECTANGLE; + return this; + }; + GeomSprite.prototype.createCircle = function (diameter) { + this.refresh(); + this.circle = new Phaser.Circle(this.x, this.y, diameter); + this.type = GeomSprite.CIRCLE; + this.bounds.setTo(this.circle.x - this.circle.radius, this.circle.y - this.circle.radius, this.circle.diameter, this.circle.diameter); + return this; + }; + GeomSprite.prototype.createLine = function (x, y) { + this.refresh(); + this.line = new Phaser.Line(this.x, this.y, x, y); + this.type = GeomSprite.LINE; + this.bounds.setTo(this.x, this.y, this.line.width, this.line.height); + return this; + }; + GeomSprite.prototype.createPoint = function () { + this.refresh(); + this.point = new Phaser.Point(this.x, this.y); + this.type = GeomSprite.POINT; + this.bounds.width = 1; + this.bounds.height = 1; + return this; + }; + GeomSprite.prototype.createRectangle = function (width, height) { + this.refresh(); + this.rect = new Phaser.Rectangle(this.x, this.y, width, height); + this.type = GeomSprite.RECTANGLE; + this.bounds.copyFrom(this.rect); + return this; + }; + GeomSprite.prototype.refresh = function () { + this.circle = null; + this.line = null; + this.point = null; + this.rect = null; + }; + GeomSprite.prototype.update = function () { + if(this.type == GeomSprite.UNASSIGNED) { + return; + } else if(this.type == GeomSprite.CIRCLE) { + this.circle.x = this.x; + this.circle.y = this.y; + this.bounds.width = this.circle.diameter; + this.bounds.height = this.circle.diameter; + } else if(this.type == GeomSprite.LINE) { + this.line.x1 = this.x; + this.line.y1 = this.y; + this.bounds.setTo(this.x, this.y, this.line.width, this.line.height); + } else if(this.type == GeomSprite.POINT) { + this.point.x = this.x; + this.point.y = this.y; + } else if(this.type == GeomSprite.RECTANGLE) { + this.rect.x = this.x; + this.rect.y = this.y; + this.bounds.copyFrom(this.rect); + } + }; + GeomSprite.prototype.inCamera = function (camera) { + if(this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0) { + this._dx = this.bounds.x - (camera.x * this.scrollFactor.x); + this._dy = this.bounds.y - (camera.y * this.scrollFactor.x); + this._dw = this.bounds.width * this.scale.x; + this._dh = this.bounds.height * this.scale.y; + return (camera.right > this._dx) && (camera.x < this._dx + this._dw) && (camera.bottom > this._dy) && (camera.y < this._dy + this._dh); + } else { + return camera.intersects(this.bounds); + } + }; + GeomSprite.prototype.render = function (camera, cameraOffsetX, cameraOffsetY) { + if(this.type == GeomSprite.UNASSIGNED || this.visible === false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1 || this.cameraBlacklist.indexOf(camera.ID) !== -1 || this.inCamera(camera.worldView) == false) { + return false; + } + if(this.alpha !== 1) { + var globalAlpha = this._game.stage.context.globalAlpha; + this._game.stage.context.globalAlpha = this.alpha; + } + this._dx = cameraOffsetX + (this.bounds.x - camera.worldView.x); + this._dy = cameraOffsetY + (this.bounds.y - camera.worldView.y); + this._dw = this.bounds.width * this.scale.x; + this._dh = this.bounds.height * this.scale.y; + if(this.type == GeomSprite.CIRCLE) { + this._dx += this.circle.radius; + this._dy += this.circle.radius; + } + if(this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0) { + this._dx -= (camera.worldView.x * this.scrollFactor.x); + this._dy -= (camera.worldView.y * this.scrollFactor.y); + } + this._dx = Math.round(this._dx); + this._dy = Math.round(this._dy); + this._dw = Math.round(this._dw); + this._dh = Math.round(this._dh); + this._game.stage.saveCanvasValues(); + this._game.stage.context.lineWidth = this.lineWidth; + this._game.stage.context.strokeStyle = this.lineColor; + this._game.stage.context.fillStyle = this.fillColor; + if(this._game.stage.fillStyle !== this.fillColor) { + } + if(this.type == GeomSprite.CIRCLE) { + this._game.stage.context.beginPath(); + this._game.stage.context.arc(this._dx, this._dy, this.circle.radius, 0, Math.PI * 2); + this._game.stage.context.stroke(); + if(this.renderFill) { + this._game.stage.context.fill(); + } + this._game.stage.context.closePath(); + } else if(this.type == GeomSprite.LINE) { + this._game.stage.context.beginPath(); + this._game.stage.context.moveTo(this._dx, this._dy); + this._game.stage.context.lineTo(this.line.x2, this.line.y2); + this._game.stage.context.stroke(); + this._game.stage.context.closePath(); + } else if(this.type == GeomSprite.POINT) { + this._game.stage.context.fillRect(this._dx, this._dy, 2, 2); + } else if(this.type == GeomSprite.RECTANGLE) { + if(this.renderOutline == false) { + this._game.stage.context.fillRect(this._dx, this._dy, this.rect.width, this.rect.height); + } else { + this._game.stage.context.beginPath(); + this._game.stage.context.rect(this._dx, this._dy, this.rect.width, this.rect.height); + this._game.stage.context.stroke(); + if(this.renderFill) { + this._game.stage.context.fill(); + } + this._game.stage.context.closePath(); + } + this._game.stage.context.fillStyle = 'rgb(255,255,255)'; + this.renderPoint(this._dx, this._dy, this.rect.topLeft, 2); + this.renderPoint(this._dx, this._dy, this.rect.topCenter, 2); + this.renderPoint(this._dx, this._dy, this.rect.topRight, 2); + this.renderPoint(this._dx, this._dy, this.rect.leftCenter, 2); + this.renderPoint(this._dx, this._dy, this.rect.center, 2); + this.renderPoint(this._dx, this._dy, this.rect.rightCenter, 2); + this.renderPoint(this._dx, this._dy, this.rect.bottomLeft, 2); + this.renderPoint(this._dx, this._dy, this.rect.bottomCenter, 2); + this.renderPoint(this._dx, this._dy, this.rect.bottomRight, 2); + } + this._game.stage.restoreCanvasValues(); + if(this.rotation !== 0) { + this._game.stage.context.translate(0, 0); + this._game.stage.context.restore(); + } + if(globalAlpha > -1) { + this._game.stage.context.globalAlpha = globalAlpha; + } + return true; + }; + GeomSprite.prototype.renderPoint = function (offsetX, offsetY, point, size) { + offsetX = 0; + offsetY = 0; + this._game.stage.context.fillRect(offsetX + point.x, offsetY + point.y, 1, 1); + }; + GeomSprite.prototype.renderDebugInfo = function (x, y, color) { + if (typeof color === "undefined") { color = 'rgb(255,255,255)'; } + }; + GeomSprite.prototype.collide = function (source) { + if(this.type == GeomSprite.CIRCLE && source.type == GeomSprite.CIRCLE) { + return Phaser.Collision.circleToCircle(this.circle, source.circle).result; + } + if(this.type == GeomSprite.CIRCLE && source.type == GeomSprite.RECTANGLE) { + return Phaser.Collision.circleToRectangle(this.circle, source.rect).result; + } + if(this.type == GeomSprite.CIRCLE && source.type == GeomSprite.POINT) { + return Phaser.Collision.circleContainsPoint(this.circle, source.point).result; + } + if(this.type == GeomSprite.CIRCLE && source.type == GeomSprite.LINE) { + return Phaser.Collision.lineToCircle(source.line, this.circle).result; + } + if(this.type == GeomSprite.RECTANGLE && source.type == GeomSprite.RECTANGLE) { + return Phaser.Collision.rectangleToRectangle(this.rect, source.rect).result; + } + if(this.type == GeomSprite.RECTANGLE && source.type == GeomSprite.CIRCLE) { + return Phaser.Collision.circleToRectangle(source.circle, this.rect).result; + } + if(this.type == GeomSprite.RECTANGLE && source.type == GeomSprite.POINT) { + return Phaser.Collision.pointToRectangle(source.point, this.rect).result; + } + if(this.type == GeomSprite.RECTANGLE && source.type == GeomSprite.LINE) { + return Phaser.Collision.lineToRectangle(source.line, this.rect).result; + } + if(this.type == GeomSprite.POINT && source.type == GeomSprite.POINT) { + return this.point.equals(source.point); + } + if(this.type == GeomSprite.POINT && source.type == GeomSprite.CIRCLE) { + return Phaser.Collision.circleContainsPoint(source.circle, this.point).result; + } + if(this.type == GeomSprite.POINT && source.type == GeomSprite.RECTANGLE) { + return Phaser.Collision.pointToRectangle(this.point, source.rect).result; + } + if(this.type == GeomSprite.POINT && source.type == GeomSprite.LINE) { + return source.line.isPointOnLine(this.point.x, this.point.y); + } + if(this.type == GeomSprite.LINE && source.type == GeomSprite.LINE) { + return Phaser.Collision.lineSegmentToLineSegment(this.line, source.line).result; + } + if(this.type == GeomSprite.LINE && source.type == GeomSprite.CIRCLE) { + return Phaser.Collision.lineToCircle(this.line, source.circle).result; + } + if(this.type == GeomSprite.LINE && source.type == GeomSprite.RECTANGLE) { + return Phaser.Collision.lineSegmentToRectangle(this.line, source.rect).result; + } + if(this.type == GeomSprite.LINE && source.type == GeomSprite.POINT) { + return this.line.isPointOnLine(source.point.x, source.point.y); + } + return false; + }; + return GeomSprite; + })(Phaser.GameObject); + Phaser.GeomSprite = GeomSprite; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Particle = (function (_super) { + __extends(Particle, _super); + function Particle(game) { + _super.call(this, game); + this.lifespan = 0; + this.friction = 500; + } + Particle.prototype.update = function () { + if(this.lifespan <= 0) { + return; + } + this.lifespan -= this._game.time.elapsed; + if(this.lifespan <= 0) { + this.kill(); + } + if(this.touching) { + if(this.angularVelocity != 0) { + this.angularVelocity = -this.angularVelocity; + } + } + if(this.acceleration.y > 0) { + if(this.touching & Phaser.Collision.FLOOR) { + this.drag.x = this.friction; + if(!(this.wasTouching & Phaser.Collision.FLOOR)) { + if(this.velocity.y < -this.elasticity * 10) { + if(this.angularVelocity != 0) { + this.angularVelocity *= -this.elasticity; + } + } else { + this.velocity.y = 0; + this.angularVelocity = 0; + } + } + } else { + this.drag.x = 0; + } + } + }; + Particle.prototype.onEmit = function () { + }; + return Particle; + })(Phaser.Sprite); + Phaser.Particle = Particle; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var TilemapLayer = (function () { + function TilemapLayer(game, parent, key, mapFormat, name, tileWidth, tileHeight) { + this._startX = 0; + this._startY = 0; + this._maxX = 0; + this._maxY = 0; + this._tx = 0; + this._ty = 0; + this._dx = 0; + this._dy = 0; + this._oldCameraX = 0; + this._oldCameraY = 0; + this.alpha = 1; + this.exists = true; + this.visible = true; + this.widthInTiles = 0; + this.heightInTiles = 0; + this.widthInPixels = 0; + this.heightInPixels = 0; + this.tileMargin = 0; + this.tileSpacing = 0; + this._game = game; + this._parent = parent; + this.name = name; + this.mapFormat = mapFormat; + this.tileWidth = tileWidth; + this.tileHeight = tileHeight; + this.boundsInTiles = new Phaser.Rectangle(); + this.mapData = []; + this._texture = this._game.cache.getImage(key); + } + TilemapLayer.prototype.getTileFromWorldXY = function (x, y) { + x = this._game.math.snapToFloor(x, this.tileWidth) / this.tileWidth; + y = this._game.math.snapToFloor(y, this.tileHeight) / this.tileHeight; + return this.getTileIndex(x, y); + }; + TilemapLayer.prototype.getTileOverlaps = function (object) { + var mapX = this._game.math.snapToFloor(object.bounds.x, this.tileWidth); + var mapY = this._game.math.snapToFloor(object.bounds.y, this.tileHeight); + var mapW = this._game.math.snapToCeil(object.bounds.width, this.tileWidth) + this.tileWidth; + var mapH = this._game.math.snapToCeil(object.bounds.height, this.tileHeight) + this.tileHeight; + var tileX = mapX / this.tileWidth; + var tileY = mapY / this.tileHeight; + var tileW = mapW / this.tileWidth; + var tileH = mapH / this.tileHeight; + if(tileX < 0) { + tileX = 0; + } + if(tileY < 0) { + tileY = 0; + } + if(tileW > this.widthInTiles) { + tileW = this.widthInTiles; + } + if(tileH > this.heightInTiles) { + tileH = this.heightInTiles; + } + var tiles = this.getTileBlock(tileX, tileY, tileW, tileH); + var result = []; + var tempBounds = new Phaser.Quad(); + for(var r = 0; r < tiles.length; r++) { + if(tiles[r].tile.allowCollisions != Phaser.Collision.NONE) { + tempBounds.setTo(tiles[r].x * this.tileWidth, tiles[r].y * this.tileHeight, this.tileWidth, this.tileHeight); + if(tempBounds.intersects(object.bounds)) { + result.push(Phaser.Collision.separateTile(object, { + x: tempBounds.x, + y: tempBounds.y, + width: tempBounds.width, + height: tempBounds.height, + mass: 1.0, + immovable: true, + allowCollisions: Phaser.Collision.ANY + })); + } else { + result.push(false); + } + } else { + result.push(false); + } + } + return { + x: tileX, + y: tileY, + w: tileW, + h: tileH, + collision: result + }; + }; + TilemapLayer.prototype.getTileBlock = function (x, y, width, height) { + var output = []; + for(var ty = y; ty < y + height; ty++) { + for(var tx = x; tx < x + width; tx++) { + output.push({ + x: tx, + y: ty, + tile: this._parent.tiles[this.mapData[ty][tx]] + }); + } + } + return output; + }; + TilemapLayer.prototype.getTileIndex = function (x, y) { + if(y >= 0 && y < this.mapData.length) { + if(x >= 0 && x < this.mapData[y].length) { + return this.mapData[y][x]; + } + } + return null; + }; + TilemapLayer.prototype.addColumn = function (column) { + var data = []; + for(var c = 0; c < column.length; c++) { + data[c] = parseInt(column[c]); + } + if(this.widthInTiles == 0) { + this.widthInTiles = data.length; + this.widthInPixels = this.widthInTiles * this.tileWidth; + } + this.mapData.push(data); + this.heightInTiles++; + this.heightInPixels += this.tileHeight; + }; + TilemapLayer.prototype.updateBounds = function () { + this.boundsInTiles.setTo(0, 0, this.widthInTiles, this.heightInTiles); + console.log('layer bounds', this.boundsInTiles); + }; + TilemapLayer.prototype.parseTileOffsets = function () { + this._tileOffsets = []; + var i = 0; + if(this.mapFormat == Phaser.Tilemap.FORMAT_TILED_JSON) { + this._tileOffsets[0] = null; + i = 1; + } + for(var ty = this.tileMargin; ty < this._texture.height; ty += (this.tileHeight + this.tileSpacing)) { + for(var tx = this.tileMargin; tx < this._texture.width; tx += (this.tileWidth + this.tileSpacing)) { + this._tileOffsets[i] = { + x: tx, + y: ty + }; + i++; + } + } + return this._tileOffsets.length; + }; + TilemapLayer.prototype.renderDebugInfo = function (x, y, color) { + if (typeof color === "undefined") { color = 'rgb(255,255,255)'; } + this._game.stage.context.fillStyle = color; + this._game.stage.context.fillText('TilemapLayer: ' + this.name, x, y); + this._game.stage.context.fillText('startX: ' + this._startX + ' endX: ' + this._maxX, x, y + 14); + this._game.stage.context.fillText('startY: ' + this._startY + ' endY: ' + this._maxY, x, y + 28); + this._game.stage.context.fillText('dx: ' + this._dx + ' dy: ' + this._dy, x, y + 42); + }; + TilemapLayer.prototype.render = function (camera, dx, dy) { + if(this.visible === false || this.alpha < 0.1) { + return false; + } + this._maxX = this._game.math.ceil(camera.width / this.tileWidth) + 1; + this._maxY = this._game.math.ceil(camera.height / this.tileHeight) + 1; + this._startX = this._game.math.floor(camera.worldView.x / this.tileWidth); + this._startY = this._game.math.floor(camera.worldView.y / this.tileHeight); + if(this._startX < 0) { + this._startX = 0; + } + if(this._startY < 0) { + this._startY = 0; + } + if(this._maxX > this.widthInTiles) { + this._maxX = this.widthInTiles; + } + if(this._maxY > this.heightInTiles) { + this._maxY = this.heightInTiles; + } + if(this._startX + this._maxX > this.widthInTiles) { + this._startX = this.widthInTiles - this._maxX; + } + if(this._startY + this._maxY > this.heightInTiles) { + this._startY = this.heightInTiles - this._maxY; + } + this._dx = dx; + this._dy = dy; + this._dx += -(camera.worldView.x - (this._startX * this.tileWidth)); + this._dy += -(camera.worldView.y - (this._startY * this.tileHeight)); + this._tx = this._dx; + this._ty = this._dy; + if(this.alpha !== 1) { + var globalAlpha = this._game.stage.context.globalAlpha; + this._game.stage.context.globalAlpha = this.alpha; + } + for(var row = this._startY; row < this._startY + this._maxY; row++) { + this._columnData = this.mapData[row]; + for(var tile = this._startX; tile < this._startX + this._maxX; tile++) { + if(this._tileOffsets[this._columnData[tile]]) { + this._game.stage.context.drawImage(this._texture, this._tileOffsets[this._columnData[tile]].x, this._tileOffsets[this._columnData[tile]].y, this.tileWidth, this.tileHeight, this._tx, this._ty, this.tileWidth, this.tileHeight); + } + this._tx += this.tileWidth; + } + this._tx = this._dx; + this._ty += this.tileHeight; + } + if(globalAlpha > -1) { + this._game.stage.context.globalAlpha = globalAlpha; + } + return true; + }; + return TilemapLayer; + })(); + Phaser.TilemapLayer = TilemapLayer; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Tile = (function () { + function Tile(game, tilemap, index, width, height) { + this._game = game; + this.tilemap = tilemap; + this.index = index; + this.width = width; + this.height = height; + this.allowCollisions = Phaser.Collision.NONE; + } + Tile.prototype.destroy = function () { + this.tilemap = null; + }; + Tile.prototype.toString = function () { + return "[{Tiled (index=" + this.index + " collisions=" + this.allowCollisions + " width=" + this.width + " height=" + this.height + ")}]"; + }; + return Tile; + })(); + Phaser.Tile = Tile; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Tilemap = (function (_super) { + __extends(Tilemap, _super); + function Tilemap(game, key, mapData, format, resizeWorld, tileWidth, tileHeight) { + if (typeof resizeWorld === "undefined") { resizeWorld = true; } + if (typeof tileWidth === "undefined") { tileWidth = 0; } + if (typeof tileHeight === "undefined") { tileHeight = 0; } + _super.call(this, game); + this.isGroup = false; + this.tiles = []; + this.layers = []; + this.mapFormat = format; + switch(format) { + case Tilemap.FORMAT_CSV: + this.parseCSV(game.cache.getText(mapData), key, tileWidth, tileHeight); + break; + case Tilemap.FORMAT_TILED_JSON: + this.parseTiledJSON(game.cache.getText(mapData), key); + break; + } + if(this.currentLayer && resizeWorld) { + this._game.world.setSize(this.currentLayer.widthInPixels, this.currentLayer.heightInPixels, true); + } + } + Tilemap.FORMAT_CSV = 0; + Tilemap.FORMAT_TILED_JSON = 1; + Tilemap.prototype.update = function () { + }; + Tilemap.prototype.render = function (camera, cameraOffsetX, cameraOffsetY) { + if(this.cameraBlacklist.indexOf(camera.ID) == -1) { + for(var i = 0; i < this.layers.length; i++) { + this.layers[i].render(camera, cameraOffsetX, cameraOffsetY); + } + } + }; + Tilemap.prototype.parseCSV = function (data, key, tileWidth, tileHeight) { + var layer = new Phaser.TilemapLayer(this._game, this, key, Tilemap.FORMAT_CSV, 'TileLayerCSV' + this.layers.length.toString(), tileWidth, tileHeight); + data = data.trim(); + var rows = data.split("\n"); + for(var i = 0; i < rows.length; i++) { + var column = rows[i].split(","); + if(column.length > 0) { + layer.addColumn(column); + } + } + layer.updateBounds(); + var tileQuantity = layer.parseTileOffsets(); + this.currentLayer = layer; + this.layers.push(layer); + this.generateTiles(tileQuantity); + }; + Tilemap.prototype.parseTiledJSON = function (data, key) { + data = data.trim(); + var json = JSON.parse(data); + for(var i = 0; i < json.layers.length; i++) { + var layer = new Phaser.TilemapLayer(this._game, this, key, Tilemap.FORMAT_TILED_JSON, json.layers[i].name, json.tilewidth, json.tileheight); + layer.alpha = json.layers[i].opacity; + layer.visible = json.layers[i].visible; + layer.tileMargin = json.tilesets[0].margin; + layer.tileSpacing = json.tilesets[0].spacing; + var c = 0; + var row; + for(var t = 0; t < json.layers[i].data.length; t++) { + if(c == 0) { + row = []; + } + row.push(json.layers[i].data[t]); + c++; + if(c == json.layers[i].width) { + layer.addColumn(row); + c = 0; + } + } + layer.updateBounds(); + var tileQuantity = layer.parseTileOffsets(); + this.currentLayer = layer; + this.layers.push(layer); + } + this.generateTiles(tileQuantity); + }; + Tilemap.prototype.generateTiles = function (qty) { + for(var i = 0; i < qty; i++) { + this.tiles.push(new Phaser.Tile(this._game, this, i, this.currentLayer.tileWidth, this.currentLayer.tileHeight)); + } + }; + Object.defineProperty(Tilemap.prototype, "widthInPixels", { + get: function () { + return this.currentLayer.widthInPixels; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Tilemap.prototype, "heightInPixels", { + get: function () { + return this.currentLayer.heightInPixels; + }, + enumerable: true, + configurable: true + }); + Tilemap.prototype.setCollisionRange = function (start, end, collision) { + if (typeof collision === "undefined") { collision = Phaser.Collision.ANY; } + for(var i = start; i < end; i++) { + this.tiles[i].allowCollisions = collision; + } + }; + Tilemap.prototype.setCollisionByIndex = function (values, collision) { + if (typeof collision === "undefined") { collision = Phaser.Collision.ANY; } + for(var i = 0; i < values.length; i++) { + this.tiles[values[i]].allowCollisions = collision; + } + }; + Tilemap.prototype.getTile = function (x, y, layer) { + if (typeof layer === "undefined") { layer = 0; } + return this.tiles[this.layers[layer].getTileIndex(x, y)]; + }; + Tilemap.prototype.getTileFromWorldXY = function (x, y, layer) { + if (typeof layer === "undefined") { layer = 0; } + return this.tiles[this.layers[layer].getTileFromWorldXY(x, y)]; + }; + Tilemap.prototype.getTileFromInputXY = function (layer) { + if (typeof layer === "undefined") { layer = 0; } + return this.tiles[this.layers[layer].getTileFromWorldXY(this._game.input.worldX, this._game.input.worldY)]; + }; + Tilemap.prototype.getTileOverlaps = function (object) { + return this.currentLayer.getTileOverlaps(object); + }; + Tilemap.prototype.collide = function (objectOrGroup, callback) { + if (typeof objectOrGroup === "undefined") { objectOrGroup = null; } + if (typeof callback === "undefined") { callback = null; } + if(objectOrGroup == null) { + objectOrGroup = this._game.world.group; + } + if(objectOrGroup.isGroup == false) { + if(objectOrGroup.exists && objectOrGroup.allowCollisions != Phaser.Collision.NONE) { + this.currentLayer.getTileOverlaps(objectOrGroup); + } + } else { + objectOrGroup.forEachAlive(this.currentLayer.getTileOverlaps); + } + return true; + }; + return Tilemap; + })(Phaser.GameObject); + Phaser.Tilemap = Tilemap; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var ScrollRegion = (function () { + function ScrollRegion(x, y, width, height, speedX, speedY) { + this._anchorWidth = 0; + this._anchorHeight = 0; + this._inverseWidth = 0; + this._inverseHeight = 0; + this.visible = true; + this._A = new Phaser.Quad(x, y, width, height); + this._B = new Phaser.Quad(x, y, width, height); + this._C = new Phaser.Quad(x, y, width, height); + this._D = new Phaser.Quad(x, y, width, height); + this._scroll = new Phaser.MicroPoint(); + this._bounds = new Phaser.Quad(x, y, width, height); + this.scrollSpeed = new Phaser.MicroPoint(speedX, speedY); + } + ScrollRegion.prototype.update = function (delta) { + this._scroll.x += this.scrollSpeed.x; + this._scroll.y += this.scrollSpeed.y; + if(this._scroll.x > this._bounds.right) { + this._scroll.x = this._bounds.x; + } + if(this._scroll.x < this._bounds.x) { + this._scroll.x = this._bounds.right; + } + if(this._scroll.y > this._bounds.bottom) { + this._scroll.y = this._bounds.y; + } + if(this._scroll.y < this._bounds.y) { + this._scroll.y = this._bounds.bottom; + } + this._anchorWidth = (this._bounds.width - this._scroll.x) + this._bounds.x; + this._anchorHeight = (this._bounds.height - this._scroll.y) + this._bounds.y; + if(this._anchorWidth > this._bounds.width) { + this._anchorWidth = this._bounds.width; + } + if(this._anchorHeight > this._bounds.height) { + this._anchorHeight = this._bounds.height; + } + this._inverseWidth = this._bounds.width - this._anchorWidth; + this._inverseHeight = this._bounds.height - this._anchorHeight; + this._A.setTo(this._scroll.x, this._scroll.y, this._anchorWidth, this._anchorHeight); + this._B.y = this._scroll.y; + this._B.width = this._inverseWidth; + this._B.height = this._anchorHeight; + this._C.x = this._scroll.x; + this._C.width = this._anchorWidth; + this._C.height = this._inverseHeight; + this._D.width = this._inverseWidth; + this._D.height = this._inverseHeight; + }; + ScrollRegion.prototype.render = function (context, texture, dx, dy, dw, dh) { + if(this.visible == false) { + return; + } + this.crop(context, texture, this._A.x, this._A.y, this._A.width, this._A.height, dx, dy, dw, dh, 0, 0); + this.crop(context, texture, this._B.x, this._B.y, this._B.width, this._B.height, dx, dy, dw, dh, this._A.width, 0); + this.crop(context, texture, this._C.x, this._C.y, this._C.width, this._C.height, dx, dy, dw, dh, 0, this._A.height); + this.crop(context, texture, this._D.x, this._D.y, this._D.width, this._D.height, dx, dy, dw, dh, this._C.width, this._A.height); + }; + ScrollRegion.prototype.crop = function (context, texture, srcX, srcY, srcW, srcH, destX, destY, destW, destH, offsetX, offsetY) { + offsetX += destX; + offsetY += destY; + if(srcW > (destX + destW) - offsetX) { + srcW = (destX + destW) - offsetX; + } + if(srcH > (destY + destH) - offsetY) { + srcH = (destY + destH) - offsetY; + } + srcX = Math.floor(srcX); + srcY = Math.floor(srcY); + srcW = Math.floor(srcW); + srcH = Math.floor(srcH); + offsetX = Math.floor(offsetX + this._bounds.x); + offsetY = Math.floor(offsetY + this._bounds.y); + if(srcW > 0 && srcH > 0) { + context.drawImage(texture, srcX, srcY, srcW, srcH, offsetX, offsetY, srcW, srcH); + } + }; + return ScrollRegion; + })(); + Phaser.ScrollRegion = ScrollRegion; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var ScrollZone = (function (_super) { + __extends(ScrollZone, _super); + function ScrollZone(game, key, x, y, width, height) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof width === "undefined") { width = 0; } + if (typeof height === "undefined") { height = 0; } + _super.call(this, game, x, y, width, height); + this._dynamicTexture = null; + this._dx = 0; + this._dy = 0; + this._dw = 0; + this._dh = 0; + this.flipped = false; + this.regions = []; + if(this._game.cache.getImage(key)) { + this._texture = this._game.cache.getImage(key); + this.width = this._texture.width; + this.height = this._texture.height; + if(width > this._texture.width || height > this._texture.height) { + this.createRepeatingTexture(width, height); + this.width = width; + this.height = height; + } + this.addRegion(0, 0, this.width, this.height); + if((width < this._texture.width || height < this._texture.height) && width !== 0 && height !== 0) { + this.width = width; + this.height = height; + } + } + } + ScrollZone.prototype.addRegion = function (x, y, width, height, speedX, speedY) { + if (typeof speedX === "undefined") { speedX = 0; } + if (typeof speedY === "undefined") { speedY = 0; } + if(x > this.width || y > this.height || x < 0 || y < 0 || (x + width) > this.width || (y + height) > this.height) { + throw Error('Invalid ScrollRegion defined. Cannot be larger than parent ScrollZone'); + return; + } + this.currentRegion = new Phaser.ScrollRegion(x, y, width, height, speedX, speedY); + this.regions.push(this.currentRegion); + return this.currentRegion; + }; + ScrollZone.prototype.setSpeed = function (x, y) { + if(this.currentRegion) { + this.currentRegion.scrollSpeed.setTo(x, y); + } + return this; + }; + ScrollZone.prototype.update = function () { + for(var i = 0; i < this.regions.length; i++) { + this.regions[i].update(this._game.time.delta); + } + }; + ScrollZone.prototype.inCamera = function (camera) { + if(this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0) { + this._dx = this.bounds.x - (camera.x * this.scrollFactor.x); + this._dy = this.bounds.y - (camera.y * this.scrollFactor.x); + this._dw = this.bounds.width * this.scale.x; + this._dh = this.bounds.height * this.scale.y; + return (camera.right > this._dx) && (camera.x < this._dx + this._dw) && (camera.bottom > this._dy) && (camera.y < this._dy + this._dh); + } else { + return camera.intersects(this.bounds, this.bounds.length); + } + }; + ScrollZone.prototype.render = function (camera, cameraOffsetX, cameraOffsetY) { + if(this.visible == false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1 || this.cameraBlacklist.indexOf(camera.ID) !== -1 || this.inCamera(camera.worldView) == false) { + return false; + } + if(this.alpha !== 1) { + var globalAlpha = this._game.stage.context.globalAlpha; + this._game.stage.context.globalAlpha = this.alpha; + } + this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x); + this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y); + this._dw = this.bounds.width * this.scale.x; + this._dh = this.bounds.height * this.scale.y; + if(this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0) { + this._dx -= (camera.worldView.x * this.scrollFactor.x); + this._dy -= (camera.worldView.y * this.scrollFactor.y); + } + if(this.angle !== 0 || this.flipped == true) { + this._game.stage.context.save(); + this._game.stage.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2)); + if(this.angle !== 0) { + this._game.stage.context.rotate(this.angle * (Math.PI / 180)); + } + this._dx = -(this._dw / 2); + this._dy = -(this._dh / 2); + if(this.flipped == true) { + this._game.stage.context.scale(-1, 1); + } + } + this._dx = Math.round(this._dx); + this._dy = Math.round(this._dy); + this._dw = Math.round(this._dw); + this._dh = Math.round(this._dh); + for(var i = 0; i < this.regions.length; i++) { + if(this._dynamicTexture) { + this.regions[i].render(this._game.stage.context, this._dynamicTexture.canvas, this._dx, this._dy, this._dw, this._dh); + } else { + this.regions[i].render(this._game.stage.context, this._texture, this._dx, this._dy, this._dw, this._dh); + } + } + if(globalAlpha > -1) { + this._game.stage.context.globalAlpha = globalAlpha; + } + return true; + }; + ScrollZone.prototype.createRepeatingTexture = function (regionWidth, regionHeight) { + var tileWidth = Math.ceil(this._texture.width / regionWidth) * regionWidth; + var tileHeight = Math.ceil(this._texture.height / regionHeight) * regionHeight; + this._dynamicTexture = new Phaser.DynamicTexture(this._game, tileWidth, tileHeight); + this._dynamicTexture.context.rect(0, 0, tileWidth, tileHeight); + this._dynamicTexture.context.fillStyle = this._dynamicTexture.context.createPattern(this._texture, "repeat"); + this._dynamicTexture.context.fill(); + }; + return ScrollZone; + })(Phaser.GameObject); + Phaser.ScrollZone = ScrollZone; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Game = (function () { + function Game(callbackContext, parent, width, height, initCallback, createCallback, updateCallback, renderCallback) { + if (typeof parent === "undefined") { parent = ''; } + if (typeof width === "undefined") { width = 800; } + if (typeof height === "undefined") { height = 600; } + if (typeof initCallback === "undefined") { initCallback = null; } + if (typeof createCallback === "undefined") { createCallback = null; } + if (typeof updateCallback === "undefined") { updateCallback = null; } + if (typeof renderCallback === "undefined") { renderCallback = null; } + var _this = this; + this._maxAccumulation = 32; + this._accumulator = 0; + this._step = 0; + this._loadComplete = false; + this._paused = false; + this._pendingState = null; + this.onInitCallback = null; + this.onCreateCallback = null; + this.onUpdateCallback = null; + this.onRenderCallback = null; + this.onPausedCallback = null; + this.isBooted = false; + this.callbackContext = callbackContext; + this.onInitCallback = initCallback; + this.onCreateCallback = createCallback; + this.onUpdateCallback = updateCallback; + this.onRenderCallback = renderCallback; + if(document.readyState === 'complete' || document.readyState === 'interactive') { + setTimeout(function () { + return _this.boot(parent, width, height); + }); + } else { + document.addEventListener('DOMContentLoaded', function () { + return _this.boot(parent, width, height); + }, false); + window.addEventListener('load', function () { + return _this.boot(parent, width, height); + }, false); + } + } + Game.prototype.boot = function (parent, width, height) { + var _this = this; + if(this.isBooted == true) { + return; + } + if(!document.body) { + window.setTimeout(function () { + return _this.boot(parent, width, height); + }, 13); + } else { + this.device = new Phaser.Device(); + this.motion = new Phaser.Motion(this); + this.math = new Phaser.GameMath(this); + this.stage = new Phaser.Stage(this, parent, width, height); + this.world = new Phaser.World(this, width, height); + this.sound = new Phaser.SoundManager(this); + this.cache = new Phaser.Cache(this); + this.collision = new Phaser.Collision(this); + this.loader = new Phaser.Loader(this, this.loadComplete); + this.time = new Phaser.Time(this); + this.tweens = new Phaser.TweenManager(this); + this.input = new Phaser.Input(this); + this.rnd = new Phaser.RandomDataGenerator([ + (Date.now() * Math.random()).toString() + ]); + this.framerate = 60; + if(this.onInitCallback == null && this.onCreateCallback == null && this.onUpdateCallback == null && this.onRenderCallback == null && this._pendingState == null) { + this.isBooted = false; + this.stage.drawInitScreen(); + } else { + this.isBooted = true; + this._loadComplete = false; + this._raf = new Phaser.RequestAnimationFrame(this.loop, this); + if(this._pendingState) { + this.switchState(this._pendingState, false, false); + } else { + this.startState(); + } + } + } + }; + Game.prototype.loadComplete = function () { + this._loadComplete = true; + }; + Game.prototype.loop = function () { + this.time.update(); + this.tweens.update(); + if(this._paused == true) { + if(this.onPausedCallback !== null) { + this.onPausedCallback.call(this.callbackContext); + } + return; + } + this.input.update(); + this.stage.update(); + this._accumulator += this.time.delta; + if(this._accumulator > this._maxAccumulation) { + this._accumulator = this._maxAccumulation; + } + while(this._accumulator >= this._step) { + this.time.elapsed = this.time.timeScale * (this._step / 1000); + this.world.update(); + this._accumulator = this._accumulator - this._step; + } + if(this._loadComplete && this.onUpdateCallback) { + this.onUpdateCallback.call(this.callbackContext); + } + this.world.render(); + if(this._loadComplete && this.onRenderCallback) { + this.onRenderCallback.call(this.callbackContext); + } + }; + Game.prototype.startState = function () { + if(this.onInitCallback !== null) { + this.loader.reset(); + this.onInitCallback.call(this.callbackContext); + if(this.loader.queueSize == 0) { + if(this.onCreateCallback !== null) { + this.onCreateCallback.call(this.callbackContext); + } + this._loadComplete = true; + } + } else { + if(this.onCreateCallback !== null) { + this.onCreateCallback.call(this.callbackContext); + } + this._loadComplete = true; + } + }; + Game.prototype.setCallbacks = function (initCallback, createCallback, updateCallback, renderCallback) { + if (typeof initCallback === "undefined") { initCallback = null; } + if (typeof createCallback === "undefined") { createCallback = null; } + if (typeof updateCallback === "undefined") { updateCallback = null; } + if (typeof renderCallback === "undefined") { renderCallback = null; } + this.onInitCallback = initCallback; + this.onCreateCallback = createCallback; + this.onUpdateCallback = updateCallback; + this.onRenderCallback = renderCallback; + }; + Game.prototype.switchState = function (state, clearWorld, clearCache) { + if (typeof clearWorld === "undefined") { clearWorld = true; } + if (typeof clearCache === "undefined") { clearCache = false; } + if(this.isBooted == false) { + this._pendingState = state; + return; + } + if(typeof state === 'function') { + state = new state(this); + } + if(state['create'] || state['update']) { + this.callbackContext = state; + this.onInitCallback = null; + this.onCreateCallback = null; + this.onUpdateCallback = null; + this.onRenderCallback = null; + this.onPausedCallback = null; + if(state['init']) { + this.onInitCallback = state['init']; + } + if(state['create']) { + this.onCreateCallback = state['create']; + } + if(state['update']) { + this.onUpdateCallback = state['update']; + } + if(state['render']) { + this.onRenderCallback = state['render']; + } + if(state['paused']) { + this.onPausedCallback = state['paused']; + } + if(clearWorld) { + this.world.destroy(); + if(clearCache == true) { + this.cache.destroy(); + } + } + this._loadComplete = false; + this.startState(); + } else { + throw new Error("Invalid State object given. Must contain at least a create or update function."); + } + }; + Game.prototype.destroy = function () { + this.callbackContext = null; + this.onInitCallback = null; + this.onCreateCallback = null; + this.onUpdateCallback = null; + this.onRenderCallback = null; + this.onPausedCallback = null; + this.camera = null; + this.cache = null; + this.input = null; + this.loader = null; + this.sound = null; + this.stage = null; + this.time = null; + this.world = null; + this.isBooted = false; + }; + Object.defineProperty(Game.prototype, "paused", { + get: function () { + return this._paused; + }, + set: function (value) { + if(value == true && this._paused == false) { + this._paused = true; + } else if(value == false && this._paused == true) { + this._paused = false; + this.time.time = Date.now(); + this.input.reset(); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Game.prototype, "framerate", { + get: function () { + return 1000 / this._step; + }, + set: function (value) { + this._step = 1000 / value; + if(this._maxAccumulation < this._step) { + this._maxAccumulation = this._step; + } + }, + enumerable: true, + configurable: true + }); + Game.prototype.createCamera = function (x, y, width, height) { + return this.world.createCamera(x, y, width, height); + }; + Game.prototype.createGeomSprite = function (x, y) { + return this.world.createGeomSprite(x, y); + }; + Game.prototype.createSprite = function (x, y, key) { + if (typeof key === "undefined") { key = ''; } + return this.world.createSprite(x, y, key); + }; + Game.prototype.createDynamicTexture = function (width, height) { + return this.world.createDynamicTexture(width, height); + }; + Game.prototype.createGroup = function (MaxSize) { + if (typeof MaxSize === "undefined") { MaxSize = 0; } + return this.world.createGroup(MaxSize); + }; + Game.prototype.createParticle = function () { + return this.world.createParticle(); + }; + Game.prototype.createEmitter = function (x, y, size) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof size === "undefined") { size = 0; } + return this.world.createEmitter(x, y, size); + }; + Game.prototype.createScrollZone = function (key, x, y, width, height) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof width === "undefined") { width = 0; } + if (typeof height === "undefined") { height = 0; } + return this.world.createScrollZone(key, x, y, width, height); + }; + Game.prototype.createTilemap = function (key, mapData, format, resizeWorld, tileWidth, tileHeight) { + if (typeof resizeWorld === "undefined") { resizeWorld = true; } + if (typeof tileWidth === "undefined") { tileWidth = 0; } + if (typeof tileHeight === "undefined") { tileHeight = 0; } + return this.world.createTilemap(key, mapData, format, resizeWorld, tileWidth, tileHeight); + }; + Game.prototype.createTween = function (obj) { + return this.tweens.create(obj); + }; + Game.prototype.collide = function (objectOrGroup1, objectOrGroup2, notifyCallback) { + if (typeof objectOrGroup1 === "undefined") { objectOrGroup1 = null; } + if (typeof objectOrGroup2 === "undefined") { objectOrGroup2 = null; } + if (typeof notifyCallback === "undefined") { notifyCallback = null; } + return this.collision.overlap(objectOrGroup1, objectOrGroup2, notifyCallback, Phaser.Collision.separate); + }; + return Game; + })(); + Phaser.Game = Game; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Animation = (function () { + function Animation(game, parent, frameData, name, frames, delay, looped) { + this._game = game; + this._parent = parent; + this._frames = frames; + this._frameData = frameData; + this.name = name; + this.delay = 1000 / delay; + this.looped = looped; + this.isFinished = false; + this.isPlaying = false; + this._frameIndex = 0; + this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); + } + Object.defineProperty(Animation.prototype, "frameTotal", { + get: function () { + return this._frames.length; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "frame", { + get: function () { + return this._frameIndex; + }, + set: function (value) { + this.currentFrame = this._frameData.getFrame(value); + if(this.currentFrame !== null) { + this._parent.bounds.width = this.currentFrame.width; + this._parent.bounds.height = this.currentFrame.height; + this._frameIndex = value; + } + }, + enumerable: true, + configurable: true + }); + Animation.prototype.play = function (frameRate, loop) { + if (typeof frameRate === "undefined") { frameRate = null; } + if(frameRate !== null) { + this.delay = 1000 / frameRate; + } + if(loop !== undefined) { + this.looped = loop; + } + this.isPlaying = true; + this.isFinished = false; + this._timeLastFrame = this._game.time.now; + this._timeNextFrame = this._game.time.now + this.delay; + this._frameIndex = 0; + this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); + }; + Animation.prototype.restart = function () { + this.isPlaying = true; + this.isFinished = false; + this._timeLastFrame = this._game.time.now; + this._timeNextFrame = this._game.time.now + this.delay; + this._frameIndex = 0; + this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); + }; + Animation.prototype.stop = function () { + this.isPlaying = false; + this.isFinished = true; + }; + Animation.prototype.update = function () { + if(this.isPlaying == true && this._game.time.now >= this._timeNextFrame) { + this._frameIndex++; + if(this._frameIndex == this._frames.length) { + if(this.looped) { + this._frameIndex = 0; + this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); + } else { + this.onComplete(); + } + } else { + this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); + } + this._timeLastFrame = this._game.time.now; + this._timeNextFrame = this._game.time.now + this.delay; + return true; + } + return false; + }; + Animation.prototype.destroy = function () { + this._game = null; + this._parent = null; + this._frames = null; + this._frameData = null; + this.currentFrame = null; + this.isPlaying = false; + }; + Animation.prototype.onComplete = function () { + this.isPlaying = false; + this.isFinished = true; + }; + return Animation; + })(); + Phaser.Animation = Animation; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var AnimationLoader = (function () { + function AnimationLoader() { } + AnimationLoader.parseSpriteSheet = function parseSpriteSheet(game, key, frameWidth, frameHeight, frameMax) { + var img = game.cache.getImage(key); + if(img == null) { + return null; + } + var width = img.width; + var height = img.height; + var row = Math.round(width / frameWidth); + var column = Math.round(height / frameHeight); + var total = row * column; + if(frameMax !== -1) { + total = frameMax; + } + if(width == 0 || height == 0 || width < frameWidth || height < frameHeight || total === 0) { + return null; + } + var data = new Phaser.FrameData(); + var x = 0; + var y = 0; + for(var i = 0; i < total; i++) { + data.addFrame(new Phaser.Frame(x, y, frameWidth, frameHeight, '')); + x += frameWidth; + if(x === width) { + x = 0; + y += frameHeight; + } + } + return data; + }; + AnimationLoader.parseJSONData = function parseJSONData(game, json) { + var data = new Phaser.FrameData(); + var frames = json; + var newFrame; + for(var i = 0; i < frames.length; i++) { + newFrame = data.addFrame(new Phaser.Frame(frames[i].frame.x, frames[i].frame.y, frames[i].frame.w, frames[i].frame.h, frames[i].filename)); + newFrame.setTrim(frames[i].trimmed, frames[i].sourceSize.w, frames[i].sourceSize.h, frames[i].spriteSourceSize.x, frames[i].spriteSourceSize.y, frames[i].spriteSourceSize.w, frames[i].spriteSourceSize.h); + } + return data; + }; + return AnimationLoader; + })(); + Phaser.AnimationLoader = AnimationLoader; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var Frame = (function () { + function Frame(x, y, width, height, name) { + this.name = ''; + this.rotated = false; + this.rotationDirection = 'cw'; + this.x = x; + this.y = y; + this.width = width; + this.height = height; + this.name = name; + this.rotated = false; + this.trimmed = false; + } + Frame.prototype.setRotation = function (rotated, rotationDirection) { + }; + Frame.prototype.setTrim = function (trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight) { + this.trimmed = trimmed; + this.sourceSizeW = actualWidth; + this.sourceSizeH = actualHeight; + this.spriteSourceSizeX = destX; + this.spriteSourceSizeY = destY; + this.spriteSourceSizeW = destWidth; + this.spriteSourceSizeH = destHeight; + }; + return Frame; + })(); + Phaser.Frame = Frame; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var FrameData = (function () { + function FrameData() { + this._frames = []; + this._frameNames = []; + } + Object.defineProperty(FrameData.prototype, "total", { + get: function () { + return this._frames.length; + }, + enumerable: true, + configurable: true + }); + FrameData.prototype.addFrame = function (frame) { + frame.index = this._frames.length; + this._frames.push(frame); + if(frame.name !== '') { + this._frameNames[frame.name] = frame.index; + } + return frame; + }; + FrameData.prototype.getFrame = function (index) { + if(this._frames[index]) { + return this._frames[index]; + } + return null; + }; + FrameData.prototype.getFrameByName = function (name) { + if(this._frameNames[name] >= 0) { + return this._frames[this._frameNames[name]]; + } + return null; + }; + FrameData.prototype.checkFrameName = function (name) { + if(this._frameNames[name] >= 0) { + return true; + } + return false; + }; + FrameData.prototype.getFrameRange = function (start, end, output) { + if (typeof output === "undefined") { output = []; } + for(var i = start; i <= end; i++) { + output.push(this._frames[i]); + } + return output; + }; + FrameData.prototype.getFrameIndexes = function (output) { + if (typeof output === "undefined") { output = []; } + output.length = 0; + for(var i = 0; i < this._frames.length; i++) { + output.push(i); + } + return output; + }; + FrameData.prototype.getFrameIndexesByName = function (input) { + var output = []; + for(var i = 0; i < input.length; i++) { + if(this.getFrameByName(input[i])) { + output.push(this.getFrameByName(input[i]).index); + } + } + return output; + }; + FrameData.prototype.getAllFrames = function () { + return this._frames; + }; + FrameData.prototype.getFrames = function (range) { + var output = []; + for(var i = 0; i < range.length; i++) { + output.push(this._frames[i]); + } + return output; + }; + return FrameData; + })(); + Phaser.FrameData = FrameData; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var AnimationManager = (function () { + function AnimationManager(game, parent) { + this._frameData = null; + this.currentFrame = null; + this._game = game; + this._parent = parent; + this._anims = { + }; + } + AnimationManager.prototype.loadFrameData = function (frameData) { + this._frameData = frameData; + this.frame = 0; + }; + AnimationManager.prototype.add = function (name, frames, frameRate, loop, useNumericIndex) { + if (typeof frames === "undefined") { frames = null; } + if (typeof frameRate === "undefined") { frameRate = 60; } + if (typeof loop === "undefined") { loop = false; } + if (typeof useNumericIndex === "undefined") { useNumericIndex = true; } + if(this._frameData == null) { + return; + } + if(frames == null) { + frames = this._frameData.getFrameIndexes(); + } else { + if(this.validateFrames(frames, useNumericIndex) == false) { + throw Error('Invalid frames given to Animation ' + name); + return; + } + } + if(useNumericIndex == false) { + frames = this._frameData.getFrameIndexesByName(frames); + } + this._anims[name] = new Phaser.Animation(this._game, this._parent, this._frameData, name, frames, frameRate, loop); + this.currentAnim = this._anims[name]; + this.currentFrame = this.currentAnim.currentFrame; + }; + AnimationManager.prototype.validateFrames = function (frames, useNumericIndex) { + for(var i = 0; i < frames.length; i++) { + if(useNumericIndex == true) { + if(frames[i] > this._frameData.total) { + return false; + } + } else { + if(this._frameData.checkFrameName(frames[i]) == false) { + return false; + } + } + } + return true; + }; + AnimationManager.prototype.play = function (name, frameRate, loop) { + if (typeof frameRate === "undefined") { frameRate = null; } + if(this._anims[name]) { + if(this.currentAnim == this._anims[name]) { + if(this.currentAnim.isPlaying == false) { + this.currentAnim.play(frameRate, loop); + } + } else { + this.currentAnim = this._anims[name]; + this.currentAnim.play(frameRate, loop); + } + } + }; + AnimationManager.prototype.stop = function (name) { + if(this._anims[name]) { + this.currentAnim = this._anims[name]; + this.currentAnim.stop(); + } + }; + AnimationManager.prototype.update = function () { + if(this.currentAnim && this.currentAnim.update() == true) { + this.currentFrame = this.currentAnim.currentFrame; + this._parent.bounds.width = this.currentFrame.width; + this._parent.bounds.height = this.currentFrame.height; + } + }; + Object.defineProperty(AnimationManager.prototype, "frameData", { + get: function () { + return this._frameData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationManager.prototype, "frameTotal", { + get: function () { + return this._frameData.total; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationManager.prototype, "frame", { + get: function () { + return this._frameIndex; + }, + set: function (value) { + if(this._frameData.getFrame(value) !== null) { + this.currentFrame = this._frameData.getFrame(value); + this._parent.bounds.width = this.currentFrame.width; + this._parent.bounds.height = this.currentFrame.height; + this._frameIndex = value; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationManager.prototype, "frameName", { + get: function () { + return this.currentFrame.name; + }, + set: function (value) { + if(this._frameData.getFrameByName(value) !== null) { + this.currentFrame = this._frameData.getFrameByName(value); + this._parent.bounds.width = this.currentFrame.width; + this._parent.bounds.height = this.currentFrame.height; + this._frameIndex = this.currentFrame.index; + } + }, + enumerable: true, + configurable: true + }); + return AnimationManager; + })(); + Phaser.AnimationManager = AnimationManager; +})(Phaser || (Phaser = {})); +var Phaser; +(function (Phaser) { + var State = (function () { + function State(game) { + this.game = game; + this.camera = game.camera; + this.cache = game.cache; + this.collision = game.collision; + this.input = game.input; + this.loader = game.loader; + this.math = game.math; + this.motion = game.motion; + this.sound = game.sound; + this.stage = game.stage; + this.time = game.time; + this.tweens = game.tweens; + this.world = game.world; + } + State.prototype.init = function () { + }; + State.prototype.create = function () { + }; + State.prototype.update = function () { + }; + State.prototype.render = function () { + }; + State.prototype.paused = function () { + }; + State.prototype.createCamera = function (x, y, width, height) { + return this.game.world.createCamera(x, y, width, height); + }; + State.prototype.createGeomSprite = function (x, y) { + return this.world.createGeomSprite(x, y); + }; + State.prototype.createSprite = function (x, y, key) { + if (typeof key === "undefined") { key = ''; } + return this.game.world.createSprite(x, y, key); + }; + State.prototype.createDynamicTexture = function (width, height) { + return this.game.world.createDynamicTexture(width, height); + }; + State.prototype.createGroup = function (MaxSize) { + if (typeof MaxSize === "undefined") { MaxSize = 0; } + return this.game.world.createGroup(MaxSize); + }; + State.prototype.createParticle = function () { + return this.game.world.createParticle(); + }; + State.prototype.createEmitter = function (x, y, size) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof size === "undefined") { size = 0; } + return this.game.world.createEmitter(x, y, size); + }; + State.prototype.createScrollZone = function (key, x, y, width, height) { + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof width === "undefined") { width = 0; } + if (typeof height === "undefined") { height = 0; } + return this.game.world.createScrollZone(key, x, y, width, height); + }; + State.prototype.createTilemap = function (key, mapData, format, resizeWorld, tileWidth, tileHeight) { + if (typeof resizeWorld === "undefined") { resizeWorld = true; } + if (typeof tileWidth === "undefined") { tileWidth = 0; } + if (typeof tileHeight === "undefined") { tileHeight = 0; } + return this.game.world.createTilemap(key, mapData, format, resizeWorld, tileWidth, tileHeight); + }; + State.prototype.createTween = function (obj) { + return this.game.tweens.create(obj); + }; + State.prototype.collide = function (ObjectOrGroup1, ObjectOrGroup2, NotifyCallback) { + if (typeof ObjectOrGroup1 === "undefined") { ObjectOrGroup1 = null; } + if (typeof ObjectOrGroup2 === "undefined") { ObjectOrGroup2 = null; } + if (typeof NotifyCallback === "undefined") { NotifyCallback = null; } + return this.collision.overlap(ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, Phaser.Collision.separate); + }; + return State; + })(); + Phaser.State = State; +})(Phaser || (Phaser = {}));