From b63bd14172c3e375da26c562a7c65bb2f901fdf3 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Mon, 18 Nov 2013 20:27:40 +0000 Subject: [PATCH] ScaleMode fix, BitmapData change and Device updates. --- Gruntfile.js | 1 + README.md | 2 + build/phaser.js | 2018 ++++++++++++++++++++++++--- build/phaser.min.js | 20 +- examples/_site/examples.json | 16 + examples/assets/pics/backscroll.png | Bin 0 -> 14138 bytes src/gameobjects/BitmapData.js | 24 +- src/gameobjects/Sprite.js | 2 +- src/system/Device.js | 11 + src/system/StageScaleMode.js | 12 +- 10 files changed, 1867 insertions(+), 239 deletions(-) create mode 100644 examples/assets/pics/backscroll.png diff --git a/Gruntfile.js b/Gruntfile.js index bb57821c..771821a2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -84,6 +84,7 @@ module.exports = function (grunt) { 'src/input/InputHandler.js', 'src/gameobjects/Events.js', 'src/gameobjects/GameObjectFactory.js', + 'src/gameobjects/BitmapData.js', 'src/gameobjects/Sprite.js', 'src/gameobjects/TileSprite.js', 'src/gameobjects/Text.js', diff --git a/README.md b/README.md index afa31f6d..9ced1ff0 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ Version 1.1.3 - in build * New: Added Group.iterate, a powerful way to count or return children that match a certain criteria. Refactored Group to use iterate, lots of repeated code cut. * New: Added Group.sort. You can now sort the Group based on any given numeric property (x, y, health), finally you can do depth-sorting :) Example created to show. * New: Enhanced renderTexture so it can accept a Phaser.Group object and improved documentation and examples. +* New: Device.littleEndian boolean added. Only safe to use if the browser supports TypedArrays (which IE9 doesn't, but nearly all others do) * Fixed: Lots of fixes to the TypeScript definitions file (many thanks gltovar) * Fixed: Tilemap commands use specified layer when one given (thanks Izzimach) @@ -66,6 +67,7 @@ Version 1.1.3 - in build * Fixed: Group.swap had a hellish to find bug that only manifested when B-A upward swaps occured. Hours of debugging later = bug crushed. * Fixed: Point.rotate asDegrees fixed (thanks BorisKozo) * Fixed: ArcadePhysics.separateTile wasn't returning the value, so the custom process callback wasn't getting called (thanks flameiguana) +* Fixed: StageScaleMode.forceOrientation now correctly stores the forcePortrait value (thanks haden) * Updated: ArcadePhysics.updateMotion applies the dt to the velocity calculations as well as position now (thanks jcs) * Updated: RequestAnimationFrame now retains the callbackID which is passed to cancelRequestAnimationFrame. diff --git a/build/phaser.js b/build/phaser.js index 0c44531d..00f0335a 100644 --- a/build/phaser.js +++ b/build/phaser.js @@ -18,7 +18,7 @@ * * Phaser - http://www.phaser.io * -* v1.1.3 - Built at: Thu Nov 07 2013 06:09:12 +* v1.1.3 - Built at: Mon Nov 18 2013 20:26:29 * * By Richard Davey http://www.photonstorm.com @photonstorm * @@ -77,6 +77,7 @@ var Phaser = Phaser || { TILEMAPLAYER: 10, EMITTER: 11, POLYGON: 12, + BITMAPDATA: 13, NONE: 0, LEFT: 1, @@ -1304,7 +1305,6 @@ PIXI.DisplayObject.prototype.removeFilter = function(data) { //if(!this.filter)return; //this.filter = false; - console.log("YUOIO") // modify the list.. var startBlock = data.start; @@ -6722,7 +6722,6 @@ PIXI.WebGLRenderGroup = function(gl, transparent) this.batchs = []; this.toRemove = []; - console.log(this.transparent) this.filterManager = new PIXI.WebGLFilterManager(this.transparent); } @@ -7822,7 +7821,6 @@ PIXI._CompileShader = function(gl, shaderSrc, shaderType) gl.compileShader(shader); if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { - console.log(gl.getShaderInfoLog(shader)); return null; } @@ -10168,7 +10166,18 @@ Phaser.StateManager.prototype = { if (this._created && this.onRenderCallback) { + if (this.game.renderType === Phaser.CANVAS) + { + this.game.context.save(); + this.game.context.setTransform(1, 0, 0, 1, 0, 0); + } + this.onRenderCallback.call(this.callbackContext, this.game); + + if (this.game.renderType === Phaser.CANVAS) + { + this.game.context.restore(); + } } else { @@ -11077,10 +11086,36 @@ Phaser.PluginManager.prototype = { * @param {Phaser.Plugin} plugin - The plugin to be removed. */ remove: function (plugin) { + + if (this._pluginsLength == 0) + { + return; + } - // TODO - this._pluginsLength--; + for (this._p = 0; this._p < this._pluginsLength; this._p++) + { + if (this.plugins[this._p] === plugin) + { + plugin.destroy(); + this.plugins.splice(this._p, 1); + this._pluginsLength--; + return; + } + } + }, + /** + * Removes all Plugins from the PluginManager. + * @method Phaser.PluginManager#removeAll + */ + removeAll: function() { + + for (this._p = 0; this._p < this._pluginsLength; this._p++) + { + this.plugins[this._p].destroy(); + } + this.plugins.length = 0; + this._pluginsLength = 0; }, /** @@ -11419,7 +11454,7 @@ Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", { */ Phaser.Group = function (game, parent, name, useStage) { - if (typeof parent === 'undefined') + if (typeof parent === 'undefined' || typeof parent === null) { parent = game.world; } @@ -15332,6 +15367,30 @@ Phaser.Mouse = function (game) { */ this.pointerLock = new Phaser.Signal; + /** + * The browser mouse event. + * @property {MouseEvent} event + */ + this.event; + + /** + * @property {function} _onMouseDown + * @private + */ + this._onMouseDown; + + /** + * @property {function} _onMouseMove + * @private + */ + this._onMouseMove; + + /** + * @property {function} _onMouseUp + * @private + */ + this._onMouseUp; + }; /** @@ -15385,9 +15444,13 @@ Phaser.Mouse.prototype = { return _this.onMouseUp(event); }; - this.game.renderer.view.addEventListener('mousedown', this._onMouseDown, true); - this.game.renderer.view.addEventListener('mousemove', this._onMouseMove, true); - this.game.renderer.view.addEventListener('mouseup', this._onMouseUp, true); + // this.game.renderer.view.addEventListener('mousedown', this._onMouseDown, true); + // this.game.renderer.view.addEventListener('mousemove', this._onMouseMove, true); + // this.game.renderer.view.addEventListener('mouseup', this._onMouseUp, true); + + document.addEventListener('mousedown', this._onMouseDown, true); + document.addEventListener('mousemove', this._onMouseMove, true); + document.addEventListener('mouseup', this._onMouseUp, true); }, @@ -15398,20 +15461,11 @@ Phaser.Mouse.prototype = { */ onMouseDown: function (event) { + this.event = event; + event.preventDefault(); - if (event.which === 1) - { - this.button = Phaser.Mouse.LEFT_BUTTON; - } - else if (event.which === 2) - { - this.button = Phaser.Mouse.MIDDLE_BUTTON; - } - else if (event.which === 3) - { - this.button = Phaser.Mouse.RIGHT_BUTTON; - } + this.button = event.which; if (this.mouseDownCallback) { @@ -15436,6 +15490,8 @@ Phaser.Mouse.prototype = { */ onMouseMove: function (event) { + this.event = event; + event.preventDefault(); if (this.mouseMoveCallback) @@ -15461,6 +15517,8 @@ Phaser.Mouse.prototype = { */ onMouseUp: function (event) { + this.event = event; + event.preventDefault(); this.button = Phaser.Mouse.NO_BUTTON; @@ -15556,9 +15614,13 @@ Phaser.Mouse.prototype = { */ stop: function () { - this.game.stage.canvas.removeEventListener('mousedown', this._onMouseDown, true); - this.game.stage.canvas.removeEventListener('mousemove', this._onMouseMove, true); - this.game.stage.canvas.removeEventListener('mouseup', this._onMouseUp, true); + // this.game.stage.canvas.removeEventListener('mousedown', this._onMouseDown, true); + // this.game.stage.canvas.removeEventListener('mousemove', this._onMouseMove, true); + // this.game.stage.canvas.removeEventListener('mouseup', this._onMouseUp, true); + + document.removeEventListener('mousedown', this._onMouseDown, true); + document.removeEventListener('mousemove', this._onMouseMove, true); + document.removeEventListener('mouseup', this._onMouseUp, true); } @@ -15805,28 +15867,6 @@ Phaser.Pointer = function (game, id) { */ this._stateReset = false; - /** - * A Vector object containing the initial position when the Pointer was engaged with the screen. - * @property {Vec2} positionDown - * @default - **/ - this.positionDown = null; - - /** - * A Vector object containing the current position of the Pointer on the screen. - * @property {Vec2} position - * @default - **/ - this.position = null; - - /** - * A Circle object centered on the x/y screen coordinates of the Pointer. - * Default size of 44px (Apple's recommended "finger tip" size). - * @property {Circle} circle - * @default - **/ - this.circle = null; - /** * Description. * @property {boolean} withinGame @@ -15953,26 +15993,27 @@ Phaser.Pointer = function (game, id) { this.targetObject = null; /** - * Description. - * @property {boolean} isDown - Description. + * An active pointer is one that is currently pressed down on the display. A Mouse is always active. + * @property {boolean} active * @default */ this.active = false; /** - * Description + * A Phaser.Point object containing the current x/y values of the pointer on the display. * @property {Phaser.Point} position */ this.position = new Phaser.Point(); /** - * Description + * A Phaser.Point object containing the x/y values of the pointer when it was last in a down state on the display. * @property {Phaser.Point} positionDown */ this.positionDown = new Phaser.Point(); /** - * Description + * A Phaser.Circle that is centered on the x/y coordinates of this pointer, useful for hit detection. + * The Circle size is 44px (Apples recommended "finger tip" size). * @property {Phaser.Circle} circle */ this.circle = new Phaser.Circle(0, 0, 44); @@ -18200,6 +18241,20 @@ Phaser.GameObjectFactory.prototype = { return texture; + }, + + /** + * A BitmapData object which can be manipulated and drawn to like a traditional Canvas object and used to texture Sprites. + * + * @method Phaser.GameObjectFactory#bitmapData + * @param {number} [width=256] - The width of the BitmapData in pixels. + * @param {number} [height=256] - The height of the BitmapData in pixels. + * @return {Phaser.BitmapData} The newly created BitmapData object. + */ + bitmapData: function (width, height) { + + return new Phaser.BitmapData(this.game, width, height); + } }; @@ -18209,6 +18264,1107 @@ Phaser.GameObjectFactory.prototype = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +/** +* Creates a new `BitmapData` object. +* +* @class Phaser.BitmapData +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {number} [width=256] - The width of the BitmapData in pixels. +* @param {number} [height=256] - The height of the BitmapData in pixels. +*/ +Phaser.BitmapData = function (game, width, height) { + + if (typeof width === 'undefined') { width = 256; } + if (typeof height === 'undefined') { height = 256; } + + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ + this.game = game; + + /** + * @property {string} name - The name of the BitmapData. + */ + this.name = ''; + + /** + * @property {number} width - The width of the BitmapData in pixels. + */ + this.width = width; + + /** + * @property {number} height - The height of the BitmapData in pixels. + */ + this.height = height; + + /** + * @property {HTMLCanvasElement} canvas - The canvas to which this BitmapData draws. + * @default + */ + this.canvas = Phaser.Canvas.create(width, height); + + /** + * @property {CanvasRenderingContext2D} context - The 2d context of the canvas. + * @default + */ + this.context = this.canvas.getContext('2d'); + + /** + * @property {array} imageData - The canvas image data. + */ + this.imageData = this.context.getImageData(0, 0, width, height); + + /** + * @property {UInt8Clamped} pixels - A reference to the context imageData buffer. + */ + this.pixels = this.imageData.data.buffer; + + /** + * @property {PIXI.BaseTexture} baseTexture - The PIXI.BaseTexture. + * @default + */ + this.baseTexture = new PIXI.BaseTexture(this.canvas); + + /** + * @property {PIXI.Texture} texture - The PIXI.Texture. + * @default + */ + this.texture = new PIXI.Texture(this.baseTexture); + + /** + * @property {Phaser.Frame} textureFrame - The Frame this BitmapData uses for rendering. + * @default + */ + this.textureFrame = new Phaser.Frame(0, 0, 0, width, height, 'bitmapData', game.rnd.uuid()); + + /** + * @property {number} type - The const type of this object. + * @default + */ + this.type = Phaser.BITMAPDATA; + + this._dirty = false; + +} + +Phaser.BitmapData.prototype = { + + /** + * Updates the given Sprite so that it uses this BitmapData as its texture. + * @method Phaser.BitmapData.add + * @param {Phaser.Sprite} sprite - The sprite to apply this texture to. + */ + add: function (sprite) { + + sprite.loadTexture(this); + + }, + + /** + * Given an array of Sprites it will update each of them so that their Textures reference this BitmapData. + * @method Phaser.BitmapData.addTo + * @param {Phaser.Sprite[]} sprites - An array of Sprites to apply this texture to. + */ + addTo: function (sprites) { + + for (var i = 0; i < objects.length; i++) + { + if (objects[i].texture) + { + } + } + + }, + + /** + * Clears the BitmapData. + * @method Phaser.BitmapData.clear + */ + clear: function () { + + this.context.clearRect(0, 0, this.width, this.height); + + this._dirty = true; + + }, + + refreshBuffer: function () { + + this.imageData = this.context.getImageData(0, 0, this.width, this.height); + this.pixels = new Int32Array(this.imageData.data.buffer); + + // this.data8 = new Uint8ClampedArray(this.imageData.buffer); + // this.data32 = new Uint32Array(this.imageData.buffer); + + }, + + /** + * Sets the color of the given pixel to the specified red, green, blue and alpha values. + * @method Phaser.BitmapData.setPixel32 + * @param {number} x - The X coordinate of the pixel to be set. + * @param {number} y - The Y coordinate of the pixel to be set. + * @param {number} red - The red color value, between 0 and 0xFF (255). + * @param {number} green - The green color value, between 0 and 0xFF (255). + * @param {number} blue - The blue color value, between 0 and 0xFF (255). + * @param {number} alpha - The alpha color value, between 0 and 0xFF (255). + */ + setPixel32: function (x, y, red, green, blue, alpha) { + + if (x >= 0 && x <= this.width && y >= 0 && y <= this.height) + { + this.pixels[y * this.width + x] = (alpha << 24) | (blue << 16) | (green << 8) | red; + + /* + if (this.isLittleEndian) + { + this.data32[y * this.width + x] = (alpha << 24) | (blue << 16) | (green << 8) | red; + } + else + { + this.data32[y * this.width + x] = (red << 24) | (green << 16) | (blue << 8) | alpha; + } + */ + + // this.imageData.data.set(this.data8); + + this.context.putImageData(this.imageData, 0, 0); + + this._dirty = true; + } + + }, + + /** + * Sets the color of the given pixel to the specified red, green and blue values. + * @method Phaser.BitmapData.setPixel + * @param {number} x - The X coordinate of the pixel to be set. + * @param {number} y - The Y coordinate of the pixel to be set. + * @param {number} red - The red color value (between 0 and 255) + * @param {number} green - The green color value (between 0 and 255) + * @param {number} blue - The blue color value (between 0 and 255) + */ + setPixel: function (x, y, red, green, blue) { + + this.setPixel32(x, y, red, green, blue, 255); + + }, + + /** + * Get a color of a specific pixel. + * @param {number} x - The X coordinate of the pixel to get. + * @param {number} y - The Y coordinate of the pixel to get. + * @return {number} A native color value integer (format: 0xRRGGBB) + */ + getPixel: function (x, y) { + + if (x >= 0 && x <= this.width && y >= 0 && y <= this.height) + { + return this.data32[y * this.width + x]; + } + + }, + + /** + * Get a color of a specific pixel (including alpha value). + * @param {number} x - The X coordinate of the pixel to get. + * @param {number} y - The Y coordinate of the pixel to get. + * @return {number} A native color value integer (format: 0xAARRGGBB) + */ + getPixel32: function (x, y) { + + if (x >= 0 && x <= this.width && y >= 0 && y <= this.height) + { + return this.data32[y * this.width + x]; + } + + }, + + /** + * Get pixels in array in a specific Rectangle. + * @param rect {Rectangle} The specific Rectangle. + * @return {array} CanvasPixelArray. + */ + getPixels: function (rect) { + + // return this.context.getImageData(rect.x, rect.y, rect.width, rect.height); + + }, + + /** + * Adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending at endAngle + * going in the given direction by anticlockwise (defaulting to clockwise). + * @method Phaser.BitmapData.arc + * @param {number} x - The x axis of the coordinate for the arc's center + * @param {number} y - The y axis of the coordinate for the arc's center + * @param {number} radius - The arc's radius + * @param {number} startAngle - The starting point, measured from the x axis, from which it will be drawn, expressed in radians. + * @param {number} endAngle - The end arc's angle to which it will be drawn, expressed in radians. + * @param {boolean} [anticlockwise=true] - true draws the arc anticlockwise, otherwise in a clockwise direction. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + arc: function (x, y, radius, startAngle, endAngle, anticlockwise) { + + if (typeof anticlockwise === 'undefined') { anticlockwise = false; } + + this._dirty = true; + this.context.arc(x, y, radius, startAngle, endAngle, anticlockwise); + return this; + + }, + + /** + * Adds an arc with the given control points and radius, connected to the previous point by a straight line. + * @method Phaser.BitmapData.arcTo + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} radius + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + arcTo: function (x1, y1, x2, y2, radius) { + + this._dirty = true; + this.context.arcTo(x1, y1, x2, y2, radius); + return this; + + }, + + /** + * Begins a fill with the specified color. This ends the current sub-path. + * @method Phaser.BitmapData.beginFill + * @param {string} color - A CSS compatible color value (ex. "red", "#FF0000", or "rgba(255,0,0,0.5)"). Setting to null will result in no fill. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + beginFill: function (color) { + + this.fillStyle(color); + + return this; + + }, + + /** + * Begins a linear gradient fill defined by the line (x0, y0) to (x1, y1). This ends the current sub-path. For + * example, the following code defines a black to white vertical gradient ranging from 20px to 120px, and draws a square to display it: + * + * ```myGraphics.beginLinearGradientFill(["#000","#FFF"], [0, 1], 0, 20, 0, 120).rect(20, 20, 120, 120);``` + * + * @method Phaser.BitmapData.beginLinearGradientFill + * @param {Array} colors - An array of CSS compatible color values. For example, ["#F00","#00F"] would define a gradient drawing from red to blue. + * @param {Array} ratios - An array of gradient positions which correspond to the colors. For example, [0.1, 0.9] would draw the first color to 10% then interpolating to the second color at 90%. + * @param {number} x0 - The position of the first point defining the line that defines the gradient direction and size. + * @param {number} y0 - The position of the first point defining the line that defines the gradient direction and size. + * @param {number} x1 - The position of the second point defining the line that defines the gradient direction and size. + * @param {number} y1 - The position of the second point defining the line that defines the gradient direction and size. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + beginLinearGradientFill: function (colors, ratios, x0, y0, x1, y1) { + + var gradient = this.createLinearGradient(x0, y0, x1, y1); + + for (var i = 0, len = colors.length; i < len; i++) + { + gradient.addColorStop(ratios[i], colors[i]); + } + + this.fillStyle(gradient); + + return this; + + }, + + /** + * Begins a linear gradient stroke defined by the line (x0, y0) to (x1, y1). This ends the current sub-path. For + * example, the following code defines a black to white vertical gradient ranging from 20px to 120px, and draws a + * square to display it: + * + * ```myGraphics.setStrokeStyle(10).beginLinearGradientStroke(["#000","#FFF"], [0, 1], 0, 20, 0, 120).drawRect(20, 20, 120, 120);``` + * + * @method Phaser.BitmapData.beginLinearGradientStroke + * @param {Array} colors - An array of CSS compatible color values. For example, ["#F00","#00F"] would define a gradient drawing from red to blue. + * @param {Array} ratios - An array of gradient positions which correspond to the colors. For example, [0.1, 0.9] would draw the first color to 10% then interpolating to the second color at 90%. + * @param {number} x0 - The position of the first point defining the line that defines the gradient direction and size. + * @param {number} y0 - The position of the first point defining the line that defines the gradient direction and size. + * @param {number} x1 - The position of the second point defining the line that defines the gradient direction and size. + * @param {number} y1 - The position of the second point defining the line that defines the gradient direction and size. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + beginLinearGradientStroke: function (colors, ratios, x0, y0, x1, y1) { + + var gradient = this.createLinearGradient(x0, y0, x1, y1); + + for (var i = 0, len = colors.length; i < len; i++) + { + gradient.addColorStop(ratios[i], colors[i]); + } + + this.strokeStyle(gradient); + + return this; + + }, + + /** + * Begins a radial gradient stroke. This ends the current sub-path. For example, the following code defines a red to + * blue radial gradient centered at (100, 100), with a radius of 50, and draws a rectangle to display it: + * + * myGraphics.setStrokeStyle(10) + * .beginRadialGradientStroke(["#F00","#00F"], [0, 1], 100, 100, 0, 100, 100, 50) + * .drawRect(50, 90, 150, 110); + * + * @method Phaser.BitmapData.beginRadialGradientStroke + * @param {Array} colors - An array of CSS compatible color values. For example, ["#F00","#00F"] would define a gradient drawing from red to blue. + * @param {Array} ratios - An array of gradient positions which correspond to the colors. For example, [0.1, 0.9] would draw the first color to 10% then interpolating to the second color at 90%. + * @param {number} x0 - Center position of the inner circle that defines the gradient. + * @param {number} y0 - Center position of the inner circle that defines the gradient. + * @param {number} r0 - Radius of the inner circle that defines the gradient. + * @param {number} x1 - Center position of the outer circle that defines the gradient. + * @param {number} y1 - Center position of the outer circle that defines the gradient. + * @param {number} r1 - Radius of the outer circle that defines the gradient. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + beginRadialGradientStroke: function (colors, ratios, x0, y0, r0, x1, y1, r1) { + + var gradient = this.createRadialGradient(x0, y0, r0, x1, y1, r1); + + for (var i = 0, len = colors.length; i < len; i++) + { + gradient.addColorStop(ratios[i], colors[i]); + } + + this.strokeStyle(gradient); + + return this; + + }, + + /** + * Starts a new path by resetting the list of sub-paths. Call this method when you want to create a new path. + * @method Phaser.BitmapData.beginPath + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + beginPath: function () { + + this.context.beginPath(); + return this; + + }, + + /** + * Begins a stroke with the specified color. This ends the current sub-path. + * @method Phaser.BitmapData.beginStroke + * @param {String} color A CSS compatible color value (ex. "#FF0000", "red", or "rgba(255,0,0,0.5)"). Setting to null will result in no stroke. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + beginStroke: function (color) { + + this.strokeStyle(color); + return this; + + }, + + /** + * Adds a bezier curve from the current context point to (x, y) using the control points (cp1x, cp1y) and (cp2x, cp2y). + * @method Phaser.BitmapData.bezierCurveTo + * @param {number} cp1x - The x axis of control point 1. + * @param {number} cp1y - The y axis of control point 1. + * @param {number} cp2x - The x axis of control point 2. + * @param {number} cp2y - The y axis of control point 2. + * @param {number} x - The x axis of the ending point. + * @param {number} y - The y axis of the ending point. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + bezierCurveTo: function (cp1x, cp1y, cp2x, cp2y, x, y) { + + this._dirty = true; + this.context.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y); + return this; + + }, + + /** + * Draws a circle with the specified radius at (x, y). + * @method Phaser.BitmapData.circle + * @param {number} x - x coordinate center point of circle. + * @param {number} y - y coordinate center point of circle. + * @param {number} radius - Radius of circle in radians. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + circle: function (x, y, radius) { + + this.arc(x, y, radius, 0, Math.PI*2); + return this; + + }, + + /** + * Sets all pixels in the rectangle defined by starting point (x, y) and size (width, height) to transparent black. + * @method Phaser.BitmapData.clearRect + * @param {number} x - The x axis of the coordinate for the rectangle starting point. + * @param {number} y - The y axis of the coordinate for the rectangle starting point. + * @param {number} width - The rectangles width. + * @param {number} height - The rectangles height. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + clearRect: function (x, y, width, height) { + + this._dirty = true; + this.context.clearRect(x, y, width, height); + return this; + + }, + + /** + * Creates a clipping path from the current sub-paths. Everything drawn after clip() is called appears inside the clipping path only. + * @method Phaser.BitmapData.clip + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + clip: function (x, y, width, height) { + + this._dirty = true; + this.context.clip(); + return this; + + }, + + /** + * Tries to draw a straight line from the current point to the start. If the shape has already been closed or has only one point, this function does nothing. + * @method Phaser.BitmapData.closePath + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + closePath: function () { + + this._dirty = true; + this.context.closePath(); + return this; + + }, + + /** + * Creates a linear gradient with defined by an imaginary line which implies the direction of the gradient. + * Once the gradient is created colors can be inserted using the addColorStop method. + * @method Phaser.BitmapData.createLinearGradient + * @param {number} x - The x axis of the coordinate for the gradients starting point. + * @param {number} y - The y axis of the coordinate for the gradients starting point. + * @param {number} width - The width of the gradient. + * @param {number} height - The height of the gradient. + * @return {CanvasGradient} The Linear Gradient. + */ + createLinearGradient: function (x, y, width, height) { + + return this.context.createLinearGradient(x, y, width, height); + + }, + + // createPattern + + /** + * Creates a radial gradient. + * @method Phaser.BitmapData.createRadialGradient + * @param {number} x0 + * @param {number} y0 + * @param {number} r0 + * @param {number} x1 + * @param {number} y1 + * @param {number} r1 + * @return {CanvasGradient} The Radial Gradient. + */ + createRadialGradient: function (x, y, width, height) { + + return this.context.createRadialGradient(x0, y0, r0, x1, y1, r1); + + }, + + // drawImage + // drawSystemFocusRing (?) + + /** + * Draws an ellipse (oval) with a specified width (w) and height (h). + * @method Phaser.BitmapData.ellipse + * @param {number} x - x coordinate center point of ellipse. + * @param {number} y - y coordinate center point of ellipse. + * @param {number} w - height (horizontal diameter) of ellipse. The horizontal radius will be half of this number. + * @param {number} h - width (vertical diameter) of ellipse. The vertical radius will be half of this number. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + ellipse: function (x, y, w, h) { + + var k = 0.5522848; + var ox = (w / 2) * k; + var oy = (h / 2) * k; + var xe = x + w; + var ye = y + h; + var xm = x + w / 2; + var ym = y + h / 2; + + this.moveTo(x, ym); + this.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y); + this.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym); + this.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye); + this.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym); + + return this; + + }, + + /** + * Fills the subpaths with the current fill style. + * @method Phaser.BitmapData.fill + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + fill: function () { + + this._dirty = true; + this.context.fill(); + return this; + + }, + + /** + * Draws a filled rectangle at (x, y) position whose size is determined by width and height. + * @method Phaser.BitmapData.fillRect + * @param {number} x - The x axis of the coordinate for the rectangle starting point. + * @param {number} y - The y axis of the coordinate for the rectangle starting point. + * @param {number} width - The rectangles width. + * @param {number} height - The rectangles height. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + fillRect: function (x, y, width, height) { + + this._dirty = true; + this.context.fillRect(x, y, width, height); + return this; + + }, + + /** + * Sets the fill style. + * @method Phaser.BitmapData.fillStyle + * @param {string} color - The fill color value in CSS format: #RRGGBB or rgba(r,g,b,a) + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + fillStyle: function (color) { + + this.context.fillStyle = color; + return this; + + }, + + // fillText + + /** + * Sets the font. + * @method Phaser.BitmapData.font + * @param {DOMString} font - The font to be used for any text rendering. Default value 10px sans-serif. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + font: function (font) { + + this.context.font = font; + return this; + + }, + + /** + * Alpha value that is applied to shapes and images before they are composited onto the canvas. Default 1.0 (opaque). + * @method Phaser.BitmapData.globalAlpha + * @param {number} alpha - Alpha value that is applied to shapes and images before they are composited onto the canvas. Default 1.0 (opaque). + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + globalAlpha: function (alpha) { + + this.context.globalAlpha = alpha; + return this; + + }, + + /** + * With globalAlpha applied this sets how shapes and images are drawn onto the existing bitmap. Possible values: source-atop, source-in, source-out, + * source-over (default), destination-atop, destination-in, destination-out, destination-over, lighter, darker, copy and xor. + * @method Phaser.BitmapData.globalCompositeOperation + * @param {DOMString} operation - The composite operation to apply. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + globalCompositeOperation: function (operation) { + + this.context.globalCompositeOperation = operation; + return this; + + }, + + /** + * Type of endings on the end of lines. Possible values: butt (default), round, square. + * @method Phaser.BitmapData.lineCap + * @param {DOMString} style - Possible values: butt (default), round, square + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + lineCap: function (style) { + + this.context.lineCap = style; + return this; + + }, + + /** + * Specifies where to start a dasharray on a line. + * @method Phaser.BitmapData.lineDashOffset + * @param {number} offset - Specifies where to start a dasharray on a line. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + lineDashOffset: function (offset) { + + this.context.lineDashOffset = offset; + return this; + + }, + + /** + * Defines the type of corners where two lines meet. Possible values: round, bevel, miter (default) + * @method Phaser.BitmapData.lineJoin + * @param {DOMString} join - Possible values: round, bevel, miter (default) + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + lineJoin: function (join) { + + this.context.lineJoin = join; + return this; + + }, + + /** + * Width of lines. Default 1.0 + * @method Phaser.BitmapData.lineWidth + * @param {number} width - Width of lines. Default 1.0 + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + lineWidth: function (width) { + + this.context.lineWidth = width; + return this; + + }, + + /** + * Default 10. + * @method Phaser.BitmapData.miterLimit + * @param {number} limit - Default 10. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + miterLimit: function (limit) { + + this.context.miterLimit = limit; + return this; + + }, + + // getImageData + // getLineDash + // isPointInPath + // isPointInStroke + + /** + * Connects the last point in the subpath to the x, y coordinates with a straight line. + * @method Phaser.BitmapData.lineTo + * @param {number} x - The x axis of the coordinate for the end of the line. + * @param {number} y - The y axis of the coordinate for the end of the line. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + lineTo: function (x, y) { + + this._dirty = true; + this.context.lineTo(x, y); + return this; + + }, + + // measureText + + /** + * Moves the starting point of a new subpath to the (x, y) coordinates. + * @method Phaser.BitmapData.moveTo + * @param {number} x - The x axis of the point. + * @param {number} y - The y axis of the point. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + moveTo: function (x, y) { + + this.context.moveTo(x, y); + return this; + + }, + + // putImageData + + /** + * Draws a quadratic curve from the current drawing point to (x, y) using the control point (cpx, cpy). + * @method Phaser.BitmapData.quadraticCurveTo + * @param {Number} cpx - The x axis of the control point. + * @param {Number} cpy - The y axis of the control point. + * @param {Number} x - The x axis of the ending point. + * @param {Number} y - The y axis of the ending point. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + quadraticCurveTo: function(cpx, cpy, x, y) { + + this._dirty = true; + this.context.quadraticCurveTo(cpx, cpy, x, y); + return this; + + }, + + /** + * Draws a rectangle at (x, y) position whose size is determined by width and height. + * @method Phaser.BitmapData.rect + * @param {number} x - The x axis of the coordinate for the rectangle starting point. + * @param {number} y - The y axis of the coordinate for the rectangle starting point. + * @param {number} width - The rectangles width. + * @param {number} height - The rectangles height. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + rect: function (x, y, width, height) { + + this._dirty = true; + this.context.rect(x, y, width, height); + return this; + + }, + + /** + * Restores the drawing style state to the last element on the 'state stack' saved by save(). + * @method Phaser.BitmapData.restore + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + restore: function () { + + this._dirty = true; + this.context.restore(); + return this; + + }, + + /** + * Rotates the drawing context values by r radians. + * @method Phaser.BitmapData.rotate + * @param {number} angle - The angle of rotation given in radians. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + rotate: function (angle) { + + this._dirty = true; + this.context.rotate(angle); + return this; + + }, + + /** + * Sets the stroke style for the current sub-path. Like all drawing methods, this can be chained, so you can define + * the stroke style and color in a single line of code like so: + * + * ```myGraphics.setStrokeStyle(8,"round").beginStroke("#F00");``` + * + * @method Phaser.BitmapData.setStrokeStyle + * @param {number} thickness - The width of the stroke. + * @param {string|number} [caps=0] - Indicates the type of caps to use at the end of lines. One of butt, round, or square. Defaults to "butt". Also accepts the values 0 (butt), 1 (round), and 2 (square) for use with he tiny API. + * @param {string|number} [joints=0] Specifies the type of joints that should be used where two lines meet. One of bevel, round, or miter. Defaults to "miter". Also accepts the values 0 (miter), 1 (round), and 2 (bevel) for use with the tiny API. + * @param {number} [miterLimit=10] - If joints is set to "miter", then you can specify a miter limit ratio which controls at what point a mitered joint will be clipped. + * @param {boolean} [ignoreScale=false] - If true, the stroke will be drawn at the specified thickness regardless of active transformations. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + setStrokeStyle: function (thickness, caps, joints, miterLimit, ignoreScale) { + + if (typeof thickness === 'undefined') { thickness = 1; } + if (typeof caps === 'undefined') { caps = 'butt'; } + if (typeof joints === 'undefined') { joints = 'miter'; } + if (typeof miterLimit === 'undefined') { miterLimit = 10; } + + this.lineWidth(thickness); + this.lineCap(caps); + this.lineJoin(joints); + this.miterLimit(miterLimit); + + return this; + + }, + + /** + * Saves the current drawing style state using a stack so you can revert any change you make to it using restore(). + * @method Phaser.BitmapData.save + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + save: function () { + + this._dirty = true; + this.context.save(); + return this; + + }, + + /** + * Scales the current drawing context. + * @method Phaser.BitmapData.scale + * @param {number} x + * @param {number} y + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + scale: function (x, y) { + + this._dirty = true; + this.context.scale(x, y); + return this; + + }, + + /** + * + * @method Phaser.BitmapData.scrollPathIntoView + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + scrollPathIntoView: function () { + + this._dirty = true; + this.context.scrollPathIntoView(); + return this; + + }, + + // setLineDash + // setTransform + + /** + * Strokes the subpaths with the current stroke style. + * @method Phaser.BitmapData.stroke + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + stroke: function () { + + this._dirty = true; + this.context.stroke(); + return this; + + }, + + /** + * Paints a rectangle which has a starting point at (x, y) and has a w width and an h height onto the canvas, using the current stroke style. + * @method Phaser.BitmapData.strokeRect + * @param {number} x - The x axis for the starting point of the rectangle. + * @param {number} y - The y axis for the starting point of the rectangle. + * @param {number} width - The rectangles width. + * @param {number} height - The rectangles height. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + strokeRect: function () { + + this._dirty = true; + this.context.strokeRect(x, y, width, height); + return this; + + }, + + /** + * Color or style to use for the lines around shapes. Default #000 (black). + * @method Phaser.BitmapData.strokeStyle + * @param {string} style - Color or style to use for the lines around shapes. Default #000 (black). + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + strokeStyle: function (style) { + + this.context.strokeStyle = style; + return this; + + }, + + // strokeText + // transform + // translate + + /** + * If the game is running in WebGL this will push the texture up to the GPU if it's dirty. + * This is called automatically if the BitmapData is being used by a Sprite, otherwise you need to remember to call it in your render function. + * @method Phaser.BitmapData.render + */ + render: function () { + + if (this._dirty) + { + // Only needed if running in WebGL, otherwise this array will never get cleared down + if (this.game.renderType == Phaser.WEBGL) + { + PIXI.texturesToUpdate.push(this.baseTexture); + } + + this._dirty = false; + } + + } + +} + +// EaselJS Tiny API emulation + +/** +* Shortcut to moveTo. +* @method Phaser.BitmapData.prototype.mt +*/ +Phaser.BitmapData.prototype.mt = Phaser.BitmapData.prototype.moveTo; + +/** +* Shortcut to lineTo. +* @method Phaser.BitmapData.prototype.mt +*/ +Phaser.BitmapData.prototype.lt = Phaser.BitmapData.prototype.lineTo; + +/** +* Shortcut to arcTo. +* @method Phaser.BitmapData.prototype.at +*/ +Phaser.BitmapData.prototype.at = Phaser.BitmapData.prototype.arcTo; + +/** +* Shortcut to bezierCurveTo. +* @method Phaser.BitmapData.prototype.bt +*/ +Phaser.BitmapData.prototype.bt = Phaser.BitmapData.prototype.bezierCurveTo; + +/** +* Shortcut to quadraticCurveTo. +* @method Phaser.BitmapData.prototype.qt +*/ +Phaser.BitmapData.prototype.qt = Phaser.BitmapData.prototype.quadraticCurveTo; + +/** +* Shortcut to arc. +* @method Phaser.BitmapData.prototype.a +*/ +Phaser.BitmapData.prototype.a = Phaser.BitmapData.prototype.arc; + +/** +* Shortcut to rect. +* @method Phaser.BitmapData.prototype.r +*/ +Phaser.BitmapData.prototype.r = Phaser.BitmapData.prototype.rect; + +/** +* Shortcut to closePath. +* @method Phaser.BitmapData.prototype.cp +*/ +Phaser.BitmapData.prototype.cp = Phaser.BitmapData.prototype.closePath; + +/** +* Shortcut to clear. +* @method Phaser.BitmapData.prototype.c +*/ +Phaser.BitmapData.prototype.c = Phaser.BitmapData.prototype.clear; + +/** +* Shortcut to beginFill. +* @method Phaser.BitmapData.prototype.f +*/ +Phaser.BitmapData.prototype.f = Phaser.BitmapData.prototype.beginFill; + +/** +* Shortcut to beginLinearGradientFill. +* @method Phaser.BitmapData.prototype.lf +*/ +Phaser.BitmapData.prototype.lf = Phaser.BitmapData.prototype.beginLinearGradientFill; + +/** +* Shortcut to beginRadialGradientFill. +* @method Phaser.BitmapData.prototype.rf +*/ +Phaser.BitmapData.prototype.rf = Phaser.BitmapData.prototype.beginRadialGradientFill; + +/** +* Shortcut to beginBitmapFill. +* @method Phaser.BitmapData.prototype.bf +*/ +//Phaser.BitmapData.prototype.bf = Phaser.BitmapData.prototype.beginBitmapFill; + +/** +* Shortcut to endFill. +* @method Phaser.BitmapData.prototype.ef +*/ +Phaser.BitmapData.prototype.ef = Phaser.BitmapData.prototype.endFill; + +/** +* Shortcut to setStrokeStyle. +* @method Phaser.BitmapData.prototype.ss +*/ +Phaser.BitmapData.prototype.ss = Phaser.BitmapData.prototype.setStrokeStyle; + +/** +* Shortcut to beginStroke. +* @method Phaser.BitmapData.prototype.s +*/ +Phaser.BitmapData.prototype.s = Phaser.BitmapData.prototype.beginStroke; + +/** +* Shortcut to beginLinearGradientStroke. +* @method Phaser.BitmapData.prototype.ls +*/ +Phaser.BitmapData.prototype.ls = Phaser.BitmapData.prototype.beginLinearGradientStroke; + +/** +* Shortcut to beginRadialGradientStroke. +* @method Phaser.BitmapData.prototype.rs +*/ +Phaser.BitmapData.prototype.rs = Phaser.BitmapData.prototype.beginRadialGradientStroke; + +/** +* Shortcut to beginBitmapStroke. +* @method Phaser.BitmapData.prototype.bs +*/ +// Phaser.BitmapData.prototype.bs = Phaser.BitmapData.prototype.beginBitmapStroke; + +/** +* Shortcut to endStroke. +* @method Phaser.BitmapData.prototype.es +*/ +// Phaser.BitmapData.prototype.es = Phaser.BitmapData.prototype.endStroke; + +/** +* Shortcut to rect. +* @method Phaser.BitmapData.prototype.dr +*/ +Phaser.BitmapData.prototype.dr = Phaser.BitmapData.prototype.rect; + +/** +* Shortcut to drawRoundRect. +* @method Phaser.BitmapData.prototype.rr +*/ +// Phaser.BitmapData.prototype.rr = Phaser.BitmapData.prototype.drawRoundRect; + +/** +* Shortcut to drawRoundRectComplex. +* @method Phaser.BitmapData.prototype.rc +*/ +// Phaser.BitmapData.prototype.rc = Phaser.BitmapData.prototype.drawRoundRectComplex; + +/** +* Shortcut to drawCircle. +* @method Phaser.BitmapData.prototype.dc +*/ +Phaser.BitmapData.prototype.dc = Phaser.BitmapData.prototype.circle; + +/** +* Shortcut to drawEllipse. +* @method Phaser.BitmapData.prototype.de +*/ +Phaser.BitmapData.prototype.de = Phaser.BitmapData.prototype.ellipse; + +/** +* Shortcut to drawPolyStar. +* @method Phaser.BitmapData.prototype.dp +*/ +// Phaser.BitmapData.prototype.dp = Phaser.BitmapData.prototype.drawPolyStar; + +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + /** * Create a new `Sprite` object. Sprites are the lifeblood of your game, used for nearly everything visual. * At its most basic a Sprite consists of a set of coordinates and a texture that is rendered to the canvas. @@ -18220,7 +19376,7 @@ Phaser.GameObjectFactory.prototype = { * @param {Phaser.Game} game - A reference to the currently running game. * @param {number} x - The x coordinate (in world space) to position the Sprite at. * @param {number} y - The y coordinate (in world space) to position the Sprite at. -* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. +* @param {string|Phaser.RenderTexture|Phaser.BitmapData|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. * @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. */ Phaser.Sprite = function (game, x, y, key, frame) { @@ -18294,7 +19450,7 @@ Phaser.Sprite = function (game, x, y, key, frame) { this.input = new Phaser.InputHandler(this); /** - * @property {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. + * @property {string|Phaser.RenderTexture|Phaser.BitmapData|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture, BitmapData or PIXI.Texture. */ this.key = key; @@ -18309,6 +19465,12 @@ Phaser.Sprite = function (game, x, y, key, frame) { this.currentFrame = this.game.cache.getTextureFrame(key.name); } + else if (key instanceof Phaser.BitmapData) + { + PIXI.Sprite.call(this, key.texture, key.textureFrame); + + this.currentFrame = key.textureFrame; + } else if (key instanceof PIXI.Texture) { PIXI.Sprite.call(this, key); @@ -18557,7 +19719,7 @@ Phaser.Sprite.prototype.constructor = Phaser.Sprite; */ Phaser.Sprite.prototype.preUpdate = function() { - if (!this.exists) + if (!this.exists || (this.group && !this.group.exists)) { this.renderOrderID = -1; return; @@ -18835,6 +19997,11 @@ Phaser.Sprite.prototype.resetCrop = function() { */ Phaser.Sprite.prototype.postUpdate = function() { + if (this.key instanceof Phaser.BitmapData && this.key._dirty) + { + this.key.render(); + } + if (this.exists) { // The sprite is positioned in this call, after taking into consideration motion updates and collision @@ -18868,7 +20035,7 @@ Phaser.Sprite.prototype.postUpdate = function() { * * @method Phaser.Sprite#loadTexture * @memberof Phaser.Sprite -* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. +* @param {string|Phaser.RenderTexture|Phaser.BitmapData|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture, BitmapData or PIXI.Texture. * @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. */ Phaser.Sprite.prototype.loadTexture = function (key, frame) { @@ -18879,6 +20046,11 @@ Phaser.Sprite.prototype.loadTexture = function (key, frame) { { this.currentFrame = this.game.cache.getTextureFrame(key.name); } + else if (key instanceof Phaser.BitmapData) + { + this.setTexture(key.texture); + this.currentFrame = key.textureFrame; + } else if (key instanceof PIXI.Texture) { this.currentFrame = frame; @@ -20354,6 +21526,9 @@ Phaser.Graphics = function (game, x, y) { */ this.type = Phaser.GRAPHICS; + this.position.x = x; + this.position.y = y; + }; Phaser.Graphics.prototype = Object.create(PIXI.Graphics.prototype); @@ -20385,10 +21560,14 @@ Phaser.Graphics.prototype.destroy = function() { Phaser.Graphics.prototype.drawPolygon = function (poly) { graphics.moveTo(poly.points[0].x, poly.points[0].y); - for (var i = 1; i < poly.points.length; i += 1) { + + for (var i = 1; i < poly.points.length; i += 1) + { graphics.lineTo(poly.points[i].x, poly.points[i].y); } + graphics.lineTo(poly.points[0].x, poly.points[0].y); + } Object.defineProperty(Phaser.Graphics.prototype, 'angle', { @@ -20434,7 +21613,7 @@ Object.defineProperty(Phaser.Graphics.prototype, 'y', { */ /** -* A dynamic initially blank canvas to which images can be drawn +* A RenderTexture is a special texture that allows any displayObject to be rendered to it. * @class Phaser.RenderTexture * @constructor * @param {Phaser.Game} game - Current game instance. @@ -20454,7 +21633,7 @@ Phaser.RenderTexture = function (game, key, width, height) { */ this.name = key; - PIXI.EventTarget.call( this ); + PIXI.EventTarget.call(this); /** * @property {number} width - the width. @@ -20467,22 +21646,22 @@ Phaser.RenderTexture = function (game, key, width, height) { this.height = height || 100; /** - * I know this has a typo in it, but it's because the PIXI.RenderTexture does and we need to pair-up with it - * once they update pixi to fix the typo, we'll fix it here too :) - * @property {Description} indetityMatrix - Description. + * @property {PIXI.mat3} indetityMatrix - Matrix object. */ this.indetityMatrix = PIXI.mat3.create(); /** - * @property {Description} frame - Description. + * @property {PIXI.Rectangle} frame - The frame for this texture. */ this.frame = new PIXI.Rectangle(0, 0, this.width, this.height); /** - * @property {Description} type - Description. + * @property {number} type - Base Phaser object type. */ this.type = Phaser.RENDERTEXTURE; + this._tempPoint = { x: 0, y: 0 }; + if (PIXI.gl) { this.initWebGL(); @@ -20494,8 +21673,250 @@ Phaser.RenderTexture = function (game, key, width, height) { }; -Phaser.RenderTexture.prototype = Phaser.Utils.extend(true, PIXI.RenderTexture.prototype); -Phaser.RenderTexture.prototype.constructor = Phaser.RenderTexture; +Phaser.RenderTexture.prototype = Object.create(PIXI.Texture.prototype); +Phaser.RenderTexture.prototype.constructor = PIXI.RenderTexture; + +/** +* This function will draw the display object to the texture. If the display object is a Group or has children it will +* draw all children as well. +* +* @method render +* @param {DisplayObject} displayObject - The display object to render this texture on. +* @param {Phaser.Point} [position] - Where to draw the display object. +* @param {boolean} [clear=false] - If true the texture will be cleared before the displayObject is drawn. +*/ +Phaser.RenderTexture.prototype.render = function(displayObject, position, clear) { + + if (typeof position === 'undefined') { position = false; } + if (typeof clear === 'undefined') { clear = false; } + + if (displayObject instanceof Phaser.Group) + { + displayObject = displayObject._container; + } + + if (PIXI.gl) + { + this.renderWebGL(displayObject, position, clear); + } + else + { + this.renderCanvas(displayObject, position, clear); + } + +} + +/** +* This function will draw the display object to the texture at the given x/y coordinates. +* If the display object is a Group or has children it will draw all children as well. +* +* @method renderXY +* @param {DisplayObject} displayObject - The display object to render this texture on. +* @param {number} x - The x coordinate to draw the display object at. +* @param {number} y - The y coordinate to draw the display object at. +* @param {boolean} [clear=false] - If true the texture will be cleared before the displayObject is drawn. +*/ +Phaser.RenderTexture.prototype.renderXY = function(displayObject, x, y, clear) { + + this._tempPoint.x = x; + this._tempPoint.y = y; + + this.render(displayObject, this._tempPoint, clear); + +} + +/** + * Initializes the webgl data for this texture + * + * @method initWebGL + * @private + */ +Phaser.RenderTexture.prototype.initWebGL = function() +{ + var gl = PIXI.gl; + this.glFramebuffer = gl.createFramebuffer(); + + gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer ); + + this.glFramebuffer.width = this.width; + this.glFramebuffer.height = this.height; + + this.baseTexture = new PIXI.BaseTexture(); + + this.baseTexture.width = this.width; + this.baseTexture.height = this.height; + + this.baseTexture._glTexture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, this.baseTexture._glTexture); + + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + + this.baseTexture.isRender = true; + + gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer ); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.baseTexture._glTexture, 0); + + // create a projection matrix.. + this.projection = new PIXI.Point(this.width/2 , -this.height/2); + + // set the correct render function.. + // this.render = this.renderWebGL; +} + + +Phaser.RenderTexture.prototype.resize = function(width, height) +{ + + this.width = width; + this.height = height; + + if(PIXI.gl) + { + this.projection.x = this.width/2 + this.projection.y = -this.height/2; + + var gl = PIXI.gl; + gl.bindTexture(gl.TEXTURE_2D, this.baseTexture._glTexture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + } + else + { + + this.frame.width = this.width + this.frame.height = this.height; + this.renderer.resize(this.width, this.height); + } +} + +/** + * Initializes the canvas data for this texture + * + * @method initCanvas + * @private + */ +Phaser.RenderTexture.prototype.initCanvas = function() +{ + this.renderer = new PIXI.CanvasRenderer(this.width, this.height, null, 0); + + this.baseTexture = new PIXI.BaseTexture(this.renderer.view); + this.frame = new PIXI.Rectangle(0, 0, this.width, this.height); + + // this.render = this.renderCanvas; +} + +/** + * This function will draw the display object to the texture. + * + * @method renderWebGL + * @param displayObject {DisplayObject} The display object to render this texture on + * @param clear {Boolean} If true the texture will be cleared before the displayObject is drawn + * @private + */ +Phaser.RenderTexture.prototype.renderWebGL = function(displayObject, position, clear) +{ + var gl = PIXI.gl; + + // enable the alpha color mask.. + gl.colorMask(true, true, true, true); + + gl.viewport(0, 0, this.width, this.height); + + gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer ); + + if(clear) + { + gl.clearColor(0,0,0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); + } + + // THIS WILL MESS WITH HIT TESTING! + var children = displayObject.children; + + //TODO -? create a new one??? dont think so! + var originalWorldTransform = displayObject.worldTransform; + displayObject.worldTransform = PIXI.mat3.create();//sthis.indetityMatrix; + // modify to flip... + displayObject.worldTransform[4] = -1; + displayObject.worldTransform[5] = this.projection.y * -2; + + if(position) + { + displayObject.worldTransform[2] = position.x; + displayObject.worldTransform[5] -= position.y; + } + + PIXI.visibleCount++; + displayObject.vcount = PIXI.visibleCount; + + for(var i=0,j=children.length; i @@ -20636,37 +22057,43 @@ Phaser.Canvas = { * * @method Phaser.Canvas.addToDOM * @param {HTMLCanvasElement} canvas - The canvas to set the touch action on. - * @param {string} parent - The DOM element to add the canvas to. Defaults to ''. + * @param {string|HTMLElement} parent - The DOM element to add the canvas to. Defaults to ''. * @param {boolean} overflowHidden - If set to true it will add the overflow='hidden' style to the parent DOM element. * @return {HTMLCanvasElement} Returns the source canvas. */ addToDOM: function (canvas, parent, overflowHidden) { - parent = parent || ''; + var target; if (typeof overflowHidden === 'undefined') { overflowHidden = true; } - if (parent !== '') + if (parent) { - if (document.getElementById(parent)) + // hopefully an element ID + if (typeof parent === 'string') { - document.getElementById(parent).appendChild(canvas); + target = document.getElementById(parent); + } + // quick test for a HTMLelement + else if (typeof parent === 'object' && parent.nodeType === 1) + { + target = parent; + } - if (overflowHidden) - { - document.getElementById(parent).style.overflow = 'hidden'; - } - } - else + if (overflowHidden) { - document.body.appendChild(canvas); + target.style.overflow = 'hidden'; } } - else + + // fallback, covers an invalid ID and a none HTMLelement object + if(!target) { - document.body.appendChild(canvas); + target = document.body; } + target.appendChild(canvas); + return canvas; }, @@ -21066,17 +22493,15 @@ Phaser.StageScaleMode.prototype = { * The optional orientationImage is displayed when the game is in the incorrect orientation. * @method Phaser.StageScaleMode#forceOrientation * @param {boolean} forceLandscape - true if the game should run in landscape mode only. - * @param {boolean} forcePortrait - true if the game should run in portrait mode only. - * @param {string} [forcePortrait=''] - The string of an image in the Phaser.Cache to display when this game is in the incorrect orientation. + * @param {boolean} [forcePortrait=false] - true if the game should run in portrait mode only. + * @param {string} [orientationImage=''] - The string of an image in the Phaser.Cache to display when this game is in the incorrect orientation. */ forceOrientation: function (forceLandscape, forcePortrait, orientationImage) { - this.forceLandscape = forceLandscape; + if (typeof forcePortrait === 'undefined') { forcePortrait = false; } - if (typeof forcePortrait === 'undefined') - { - this.forcePortrait = false; - } + this.forceLandscape = forceLandscape; + this.forcePortrait = forcePortrait; if (typeof orientationImage !== 'undefined') { @@ -21730,6 +23155,12 @@ Phaser.Device = function () { */ this.pixelRatio = 0; + /** + * @property {boolean} littleEndian - Is the device big or little endian? (only detected if the browser supports TypedArrays) + * @default + */ + this.littleEndian = false; + // Run the checks this._checkAudio(); this._checkBrowser(); @@ -21909,6 +23340,11 @@ Phaser.Device.prototype = { this.iPhone4 = (this.pixelRatio == 2 && this.iPhone); this.iPad = navigator.userAgent.toLowerCase().indexOf('ipad') != -1; + if (typeof Int8Array !== 'undefined') + { + this.littleEndian = new Int8Array(new Int16Array([1]).buffer)[0] > 0; + } + }, /** @@ -22022,21 +23458,15 @@ Phaser.Device.prototype = { */ Phaser.RequestAnimationFrame = function(game) { - /** - * @property {Phaser.Game} game - The currently running game. - */ + /** + * @property {Phaser.Game} game - The currently running game. + */ this.game = game; - /** - * @property {boolean} _isSetTimeOut - Description. - * @private - */ - this._isSetTimeOut = false; - - /** - * @property {boolean} isRunning - Description. - * @default - */ + /** + * @property {boolean} isRunning - true if RequestAnimationFrame is running, otherwise false. + * @default + */ this.isRunning = false; var vendors = [ @@ -22053,15 +23483,19 @@ Phaser.RequestAnimationFrame = function(game) { } /** - * The function called by the update - * @property _onLoop + * @property {boolean} _isSetTimeOut - true if the browser is using setTimeout instead of raf. + * @private + */ + this._isSetTimeOut = false; + + /** + * @property {function} _onLoop - The function called by the update. * @private */ this._onLoop = null; /** - * The callback ID used when calling cancel - * @property _timeOutID + * @property {number} _timeOutID - The callback ID used when calling cancel. * @private */ this._timeOutID = null; @@ -22070,7 +23504,6 @@ Phaser.RequestAnimationFrame = function(game) { Phaser.RequestAnimationFrame.prototype = { - /** * Starts the requestAnimatioFrame running or setTimeout if unavailable in browser * @method Phaser.RequestAnimationFrame#start @@ -23354,7 +24787,7 @@ Phaser.Math = { } - return { sin: sinTable, cos: cosTable }; + return { sin: sinTable, cos: cosTable, length: length }; }, @@ -24749,7 +26182,7 @@ Phaser.Point.rotate = function (a, x, y, angle, asDegrees, distance) { if (asDegrees) { - angle = Phaser.Math.radToDeg(angle); + angle = Phaser.Math.degToRad(angle); } // Get distance from origin (cx/cy) to this point @@ -27992,7 +29425,11 @@ Phaser.Animation.prototype = { else { this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); - this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + + if (this.currentFrame) + { + this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + } } return true; @@ -28975,6 +30412,12 @@ Phaser.Cache = function (game) { */ this._tilesets = {}; + /** + * @property {object} _bitmapDatas - BitmapData key-value container. + * @private + */ + this._bitmapDatas = {}; + this.addDefaultImage(); /** @@ -28999,12 +30442,27 @@ Phaser.Cache.prototype = { }, + /** + * Add a BitmapData object in to the cache. + * @method Phaser.Cache#addBitmapData + * @param {string} key - Asset key for this BitmapData. + * @param {Phaser.BitmapData} bitmapData - The BitmapData object to be addded to the cache. + * @return {Phaser.BitmapData} The BitmapData object to be addded to the cache. + */ + addBitmapData: function (key, bitmapData) { + + this._bitmapDatas[key] = bitmapData; + + return bitmapData; + + }, + /** * Add a new Phaser.RenderTexture in to the cache. * * @method Phaser.Cache#addRenderTexture * @param {string} key - The unique key by which you will reference this object. - * @param {Phaser.Texture} textue - The texture to use as the base of the RenderTexture. + * @param {Phaser.Texture} texture - The texture to use as the base of the RenderTexture. */ addRenderTexture: function (key, texture) { @@ -29277,7 +30735,7 @@ Phaser.Cache.prototype = { }, /** - * Get acanvas object from the cache by its key. + * Get a canvas object from the cache by its key. * * @method Phaser.Cache#getCanvas * @param {string} key - Asset key of the canvas you want. @@ -29291,6 +30749,25 @@ Phaser.Cache.prototype = { } return null; + + }, + + /** + * Get a BitmapData object from the cache by its key. + * + * @method Phaser.Cache#getBitmapData + * @param {string} key - Asset key of the BitmapData object you want. + * @return {Phaser.BitmapData} The requested BitmapData object if found, or null if not. + */ + getBitmapData: function (key) { + + if (this._bitmapDatas[key]) + { + return this._bitmapDatas[key]; + } + + return null; + }, /** @@ -29326,6 +30803,7 @@ Phaser.Cache.prototype = { } return null; + }, /** @@ -33077,6 +34555,7 @@ Phaser.Color = { * Given an alpha and 3 color values this will return an integer representation of it. * * @method Phaser.Color.getColor32 + * @static * @param {number} alpha - The Alpha value (between 0 and 255). * @param {number} red - The Red channel value (between 0 and 255). * @param {number} green - The Green channel value (between 0 and 255). @@ -33091,6 +34570,7 @@ Phaser.Color = { * Given 3 color values this will return an integer representation of it. * * @method Phaser.Color.getColor + * @static * @param {number} red - The Red channel value (between 0 and 255). * @param {number} green - The Green channel value (between 0 and 255). * @param {number} blue - The Blue channel value (between 0 and 255). @@ -33101,17 +34581,19 @@ Phaser.Color = { }, /** - * Converts the given hex string into an object containing the RGB values. + * Converts the given hex string into an integer color value. * * @method Phaser.Color.hexToRGB + * @static * @param {string} h - The string hex color to convert. - * @returns {object} An object with 3 properties: r,g and b. + * @returns {number} The rgb color value. */ hexToRGB: function (h) { var hex16 = (h.charAt(0) == "#") ? h.substring(1, 7) : h; - if (hex16.length==3) { + if (hex16.length==3) + { hex16 = hex16.charAt(0) + hex16.charAt(0) + hex16.charAt(1) + hex16.charAt(1) + hex16.charAt(2) + hex16.charAt(2); } @@ -33128,6 +34610,7 @@ Phaser.Color = { * RGB format information and HSL information. Each section starts on a newline, 3 lines in total. * * @method Phaser.Color.getColorInfo + * @static * @param {number} color - A color value in the format 0xAARRGGBB. * @returns {string} String containing the 3 lines of information. */ @@ -33153,6 +34636,7 @@ Phaser.Color = { * Return a string representation of the color in the format 0xAARRGGBB. * * @method Phaser.Color.RGBtoHexstring + * @static * @param {number} color - The color to get the string representation for * @returns {string} A string of length 10 characters in the format 0xAARRGGBB */ @@ -33168,6 +34652,7 @@ Phaser.Color = { * Return a string representation of the color in the format #RRGGBB. * * @method Phaser.Color.RGBtoWebstring + * @static * @param {number} color - The color to get the string representation for. * @returns {string} A string of length 10 characters in the format 0xAARRGGBB. */ @@ -33183,6 +34668,7 @@ Phaser.Color = { * Return a string containing a hex representation of the given color. * * @method Phaser.Color.colorToHexstring + * @static * @param {number} color - The color channel to get the hex value for, must be a value between 0 and 255). * @returns {string} A string of length 2 characters, i.e. 255 = FF, 0 = 00. */ @@ -33199,11 +34685,12 @@ Phaser.Color = { /** * Interpolates the two given colours based on the supplied step and currentStep properties. * @method Phaser.Color.interpolateColor - * @param {number} color1 - Description. - * @param {number} color2 - Description. - * @param {number} steps - Description. - * @param {number} currentStep - Description. - * @param {number} alpha - Description. + * @static + * @param {number} color1 - The first color value. + * @param {number} color2 - The second color value. + * @param {number} steps - The number of steps to run the interpolation over. + * @param {number} currentStep - The currentStep value. If the interpolation will take 100 steps, a currentStep value of 50 would be half-way between the two. + * @param {number} alpha - The alpha of the returned color. * @returns {number} The interpolated color value. */ interpolateColor: function (color1, color2, steps, currentStep, alpha) { @@ -33223,12 +34710,13 @@ Phaser.Color = { /** * Interpolates the two given colours based on the supplied step and currentStep properties. * @method Phaser.Color.interpolateColorWithRGB - * @param {number} color - Description. - * @param {number} r - Description. - * @param {number} g - Description. - * @param {number} b - Description. - * @param {number} steps - Description. - * @param {number} currentStep - Description. + * @static + * @param {number} color - The first color value. + * @param {number} r - The red color value, between 0 and 0xFF (255). + * @param {number} g - The green color value, between 0 and 0xFF (255). + * @param {number} b - The blue color value, between 0 and 0xFF (255). + * @param {number} steps - The number of steps to run the interpolation over. + * @param {number} currentStep - The currentStep value. If the interpolation will take 100 steps, a currentStep value of 50 would be half-way between the two. * @returns {number} The interpolated color value. */ interpolateColorWithRGB: function (color, r, g, b, steps, currentStep) { @@ -33245,14 +34733,15 @@ Phaser.Color = { /** * Interpolates the two given colours based on the supplied step and currentStep properties. * @method Phaser.Color.interpolateRGB - * @param {number} r1 - Description. - * @param {number} g1 - Description. - * @param {number} b1 - Description. - * @param {number} r2 - Description. - * @param {number} g2 - Description. - * @param {number} b2 - Description. - * @param {number} steps - Description. - * @param {number} currentStep - Description. + * @static + * @param {number} r1 - The red color value, between 0 and 0xFF (255). + * @param {number} g1 - The green color value, between 0 and 0xFF (255). + * @param {number} b1 - The blue color value, between 0 and 0xFF (255). + * @param {number} r2 - The red color value, between 0 and 0xFF (255). + * @param {number} g2 - The green color value, between 0 and 0xFF (255). + * @param {number} b2 - The blue color value, between 0 and 0xFF (255). + * @param {number} steps - The number of steps to run the interpolation over. + * @param {number} currentStep - The currentStep value. If the interpolation will take 100 steps, a currentStep value of 50 would be half-way between the two. * @returns {number} The interpolated color value. */ interpolateRGB: function (r1, g1, b1, r2, g2, b2, steps, currentStep) { @@ -33267,10 +34756,11 @@ Phaser.Color = { /** * Returns a random color value between black and white - *

Set the min value to start each channel from the given offset.

- *

Set the max value to restrict the maximum color used per channel

+ * Set the min value to start each channel from the given offset. + * Set the max value to restrict the maximum color used per channel. * * @method Phaser.Color.getRandomColor + * @static * @param {number} min - The lowest value to use for the color. * @param {number} max - The highest value to use for the color. * @param {number} alpha - The alpha value of the returning color (default 255 = fully opaque). @@ -33302,9 +34792,10 @@ Phaser.Color = { /** * Return the component parts of a color as an Object with the properties alpha, red, green, blue * - *

Alpha will only be set if it exist in the given color (0xAARRGGBB)

+ * Alpha will only be set if it exist in the given color (0xAARRGGBB) * * @method Phaser.Color.getRGB + * @static * @param {number} color - Color in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB). * @returns {object} An Object with properties: alpha, red, green, blue. */ @@ -33322,6 +34813,7 @@ Phaser.Color = { /** * Returns a CSS friendly string value from the given color. * @method Phaser.Color.getWebRGB + * @static * @param {number} color * @returns {string}A string in the format: 'rgba(r,g,b,a)' */ @@ -33340,6 +34832,7 @@ Phaser.Color = { * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component, as a value between 0 and 255. * * @method Phaser.Color.getAlpha + * @static * @param {number} color - In the format 0xAARRGGBB. * @returns {number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)). */ @@ -33351,6 +34844,7 @@ Phaser.Color = { * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component as a value between 0 and 1. * * @method Phaser.Color.getAlphaFloat + * @static * @param {number} color - In the format 0xAARRGGBB. * @returns {number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)). */ @@ -33362,6 +34856,7 @@ Phaser.Color = { * Given a native color value (in the format 0xAARRGGBB) this will return the Red component, as a value between 0 and 255. * * @method Phaser.Color.getRed + * @static * @param {number} color In the format 0xAARRGGBB. * @returns {number} The Red component of the color, will be between 0 and 255 (0 being no color, 255 full Red). */ @@ -33373,6 +34868,7 @@ Phaser.Color = { * Given a native color value (in the format 0xAARRGGBB) this will return the Green component, as a value between 0 and 255. * * @method Phaser.Color.getGreen + * @static * @param {number} color - In the format 0xAARRGGBB. * @returns {number} The Green component of the color, will be between 0 and 255 (0 being no color, 255 full Green). */ @@ -33384,6 +34880,7 @@ Phaser.Color = { * Given a native color value (in the format 0xAARRGGBB) this will return the Blue component, as a value between 0 and 255. * * @method Phaser.Color.getBlue + * @static * @param {number} color - In the format 0xAARRGGBB. * @returns {number} The Blue component of the color, will be between 0 and 255 (0 being no color, 255 full Blue). */ @@ -33697,8 +35194,8 @@ Phaser.Physics.Arcade.prototype = { }, /** - * Checks for collision between two game objects. The objects can be Sprites, Groups, Emitters or Tilemaps. - * You can perform Sprite vs. Sprite, Sprite vs. Group, Group vs. Group, Sprite vs. Tilemap or Group vs. Tilemap collisions. + * Checks for collision between two game objects. The objects can be Sprites, Groups, Emitters or Tilemap Layers. + * You can perform Sprite vs. Sprite, Sprite vs. Group, Group vs. Group, Sprite vs. Tilemap Layer or Group vs. Tilemap Layer collisions. * The objects are also automatically separated. * * @method Phaser.Physics.Arcade#collide @@ -34233,6 +35730,8 @@ Phaser.Physics.Arcade.prototype = { this._result = (this.separateTileX(body, tile, true) || this.separateTileY(body, tile, true)); + return this._result; + }, /** @@ -36500,9 +37999,9 @@ Phaser.Tilemap.prototype = { if (typeof layer === "undefined") { layer = this.currentLayer; } - if (x >= 0 && x < this.layers[this.currentLayer].width && y >= 0 && y < this.layers[this.currentLayer].height) + if (x >= 0 && x < this.layers[layer].width && y >= 0 && y < this.layers[layer].height) { - this.layers[this.currentLayer].data[y][x] = index; + this.layers[layer].data[y][x] = index; } this.dirty = true; @@ -36513,9 +38012,9 @@ Phaser.Tilemap.prototype = { if (typeof layer === "undefined") { layer = this.currentLayer; } - if (x >= 0 && x < this.layers[this.currentLayer].width && y >= 0 && y < this.layers[this.currentLayer].height) + if (x >= 0 && x < this.layers[layer].width && y >= 0 && y < this.layers[layer].height) { - return this.layers[this.currentLayer].data[y][x]; + return this.layers[layer].data[y][x]; } }, @@ -36527,9 +38026,9 @@ Phaser.Tilemap.prototype = { x = this.game.math.snapToFloor(x, tileWidth) / tileWidth; y = this.game.math.snapToFloor(y, tileHeight) / tileHeight; - if (x >= 0 && x < this.layers[this.currentLayer].width && y >= 0 && y < this.layers[this.currentLayer].height) + if (x >= 0 && x < this.layers[layer].width && y >= 0 && y < this.layers[layer].height) { - return this.layers[this.currentLayer].data[y][x]; + return this.layers[layer].data[y][x]; } }, @@ -36546,9 +38045,9 @@ Phaser.Tilemap.prototype = { x = this.game.math.snapToFloor(x, tileWidth) / tileWidth; y = this.game.math.snapToFloor(y, tileHeight) / tileHeight; - if (x >= 0 && x < this.layers[this.currentLayer].width && y >= 0 && y < this.layers[this.currentLayer].height) + if (x >= 0 && x < this.layers[layer].width && y >= 0 && y < this.layers[layer].height) { - this.layers[this.currentLayer].data[y][x] = index; + this.layers[layer].data[y][x] = index; } this.dirty = true; @@ -37025,6 +38524,21 @@ Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset, */ this._startY = 0; + /** + * @property {number} scrollFactorX - speed at which this layer scrolls + * horizontally, relative to the camera (e.g. scrollFactorX of 0.5 scrolls + * half as quickly as the 'normal' camera-locked layers do) + * @default 1 + */ + this.scrollFactorX = 1; + /** + * @property {number} scrollFactorY - speed at which this layer scrolls + * vertically, relative to the camera (e.g. scrollFactorY of 0.5 scrolls + * half as quickly as the 'normal' camera-locked layers do) + * @default 1 + */ + this.scrollFactorY = 1; + this.tilemap = null; this.layer = null; this.index = 0; @@ -37055,8 +38569,8 @@ Phaser.TilemapLayer.prototype.constructor = Phaser.TilemapLayer; Phaser.TilemapLayer.prototype.update = function () { - this.scrollX = this.game.camera.x; - this.scrollY = this.game.camera.y; + this.scrollX = this.game.camera.x * this.scrollFactorX; + this.scrollY = this.game.camera.y * this.scrollFactorY; this.render(); @@ -37110,6 +38624,82 @@ Phaser.TilemapLayer.prototype.updateMapData = function (tilemap, layer) { } +/** + * Take an x coordinate that doesn't account for scrollFactorY and 'fix' it + * into a scrolled local space. Used primarily internally + * @param {number} x - x coordinate in camera space + * @return {number} x coordinate in scrollFactor-adjusted dimensions + */ +Phaser.TilemapLayer.prototype._fixX = function(x) { + + if (this.scrollFactorX === 1) + { + return x; + } + + var left_edge = x - (this._x / this.scrollFactorX); + + return this._x + left_edge; + +} + +/** + * Take an x coordinate that _does_ account for scrollFactorY and 'unfix' it + * back to camera space. Used primarily internally + * @param {number} x - x coordinate in scrollFactor-adjusted dimensions + * @return {number} x coordinate in camera space + */ +Phaser.TilemapLayer.prototype._unfixX = function(x) { + + if (this.scrollFactorX === 1) + { + return x; + } + + var left_edge = x - this._x; + + return (this._x / this.scrollFactorX) + left_edge; + +} + +/** + * Take a y coordinate that doesn't account for scrollFactorY and 'fix' it + * into a scrolled local space. Used primarily internally + * @param {number} y - y coordinate in camera space + * @return {number} y coordinate in scrollFactor-adjusted dimensions + */ +Phaser.TilemapLayer.prototype._fixY = function(y) { + + if (this.scrollFactorY === 1) + { + return y; + } + + var top_edge = y - (this._y / this.scrollFactorY); + + return this._y + top_edge; + +} + +/** + * Take a y coordinate that _does_ account for scrollFactorY and 'unfix' it + * back to camera space. Used primarily internally + * @param {number} y - y coordinate in scrollFactor-adjusted dimensions + * @return {number} y coordinate in camera space + */ +Phaser.TilemapLayer.prototype._unfixY = function(y) { + + if (this.scrollFactorY === 1) + { + return y; + } + + var top_edge = y - this._y; + + return (this._y / this.scrollFactorY) + top_edge; + +} + /** * Convert a pixel value to a tile coordinate. * @param {number} x - X position of the point in target tile. @@ -37120,7 +38710,7 @@ Phaser.TilemapLayer.prototype.getTileX = function (x) { var tileWidth = this.tileWidth * this.scale.x; - return this.game.math.snapToFloor(x, tileWidth) / tileWidth; + return this.game.math.snapToFloor(this._fixX(x), tileWidth) / tileWidth; } @@ -37134,7 +38724,7 @@ Phaser.TilemapLayer.prototype.getTileY = function (y) { var tileHeight = this.tileHeight * this.scale.y; - return this.game.math.snapToFloor(y, tileHeight) / tileHeight; + return this.game.math.snapToFloor(this._fixY(y), tileHeight) / tileHeight; } @@ -37175,6 +38765,10 @@ Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides y = 0; } + // adjust the x,y coordinates for scrollFactor + x = this._fixX( x ); + y = this._fixY( y ); + if (width > this.widthInPixels) { width = this.widthInPixels; @@ -37222,7 +38816,10 @@ Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides if (collides == false || (collides && _tile.collideNone == false)) { - this._results.push({ x: wx * sx, right: (wx * sx) + sx, y: wy * sy, bottom: (wy * sy) + sy, width: sx, height: sy, tx: wx, ty: wy, tile: _tile }); + // convert tile coordinates back to camera space for return + var _wx = this._unfixX( wx*sx ) / tileWidth; + var _wy = this._unfixY( wy*sy ) / tileHeight; + this._results.push({ x: _wx * sx, right: (_wx * sx) + sx, y: _wy * sy, bottom: (_wy * sy) + sy, width: sx, height: sy, tx: _wx, ty: _wy, tile: _tile }); } } } @@ -37705,118 +39302,141 @@ Object.defineProperty(Phaser.Tileset.prototype, "total", { }); /** - * We're replacing a couple of Pixi's methods here to fix or add some vital functionality: +* We're replacing a couple of Pixi's methods here to fix or add some vital functionality: +* +* 1) Added support for Trimmed sprite sheets +* 2) Skip display objects with an alpha of zero +* 3) Avoid Style Recalculation from the incorrect bgcolor value +* +* Hopefully we can remove this once Pixi has been updated to support these things. +*/ + +/** + * Renders the stage to its canvas view * - * 1) Added support for Trimmed sprite sheets - * 2) Skip display objects with an alpha of zero - * - * Hopefully we can remove this once Pixi has been updated to support these things. + * @method render + * @param stage {Stage} the Stage element to be rendered */ +PIXI.CanvasRenderer.prototype.render = function(stage) +{ + PIXI.texturesToUpdate.length = 0; + PIXI.texturesToDestroy.length = 0; + + PIXI.visibleCount++; + stage.updateTransform(); + + // update the background color + // if(this.view.style.backgroundColor!=stage.backgroundColorString && !this.transparent)this.view.style.backgroundColor = stage.backgroundColorString; + + this.context.setTransform(1, 0, 0, 1, 0, 0); + this.context.clearRect(0, 0, this.width, this.height) + this.renderDisplayObject(stage); + + // Remove frame updates + if (PIXI.Texture.frameUpdates.length > 0) + { + PIXI.Texture.frameUpdates.length = 0; + } + +} PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject) { - // no loger recurrsive! - var transform; - var context = this.context; - - context.globalCompositeOperation = 'source-over'; - - // one the display object hits this. we can break the loop + // Once the display object hits this we can break the loop var testObject = displayObject.last._iNext; displayObject = displayObject.first; do { - transform = displayObject.worldTransform; + //transform = displayObject.worldTransform; - if(!displayObject.visible) + if (!displayObject.visible) { displayObject = displayObject.last._iNext; continue; } - if(!displayObject.renderable || displayObject.alpha == 0) + if (!displayObject.renderable || displayObject.alpha == 0) { displayObject = displayObject._iNext; continue; } - if(displayObject instanceof PIXI.Sprite) + if (displayObject instanceof PIXI.Sprite) { - var frame = displayObject.texture.frame; + // var frame = displayObject.texture.frame; - if(frame) + if (displayObject.texture.frame) { - context.globalAlpha = displayObject.worldAlpha; + this.context.globalAlpha = displayObject.worldAlpha; if (displayObject.texture.trimmed) { - context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2] + displayObject.texture.trim.x, transform[5] + displayObject.texture.trim.y); + this.context.setTransform(displayObject.worldTransform[0], displayObject.worldTransform[3], displayObject.worldTransform[1], displayObject.worldTransform[4], displayObject.worldTransform[2] + displayObject.texture.trim.x, displayObject.worldTransform[5] + displayObject.texture.trim.y); } else { - context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]); + this.context.setTransform(displayObject.worldTransform[0], displayObject.worldTransform[3], displayObject.worldTransform[1], displayObject.worldTransform[4], displayObject.worldTransform[2], displayObject.worldTransform[5]); } - context.drawImage(displayObject.texture.baseTexture.source, - frame.x, - frame.y, - frame.width, - frame.height, - (displayObject.anchor.x) * -frame.width, - (displayObject.anchor.y) * -frame.height, - frame.width, - frame.height); + this.context.drawImage( + displayObject.texture.baseTexture.source, + displayObject.texture.frame.x, + displayObject.texture.frame.y, + displayObject.texture.frame.width, + displayObject.texture.frame.height, + (displayObject.anchor.x) * -displayObject.texture.frame.width, + (displayObject.anchor.y) * -displayObject.texture.frame.height, + displayObject.texture.frame.width, + displayObject.texture.frame.height); } } - else if(displayObject instanceof PIXI.Strip) + else if (displayObject instanceof PIXI.Strip) { - context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]) + this.context.setTransform(displayObject.worldTransform[0], displayObject.worldTransform[3], displayObject.worldTransform[1], displayObject.worldTransform[4], displayObject.worldTransform[2], displayObject.worldTransform[5]) this.renderStrip(displayObject); } - else if(displayObject instanceof PIXI.TilingSprite) + else if (displayObject instanceof PIXI.TilingSprite) { - context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]) + this.context.setTransform(displayObject.worldTransform[0], displayObject.worldTransform[3], displayObject.worldTransform[1], displayObject.worldTransform[4], displayObject.worldTransform[2], displayObject.worldTransform[5]) this.renderTilingSprite(displayObject); } - else if(displayObject instanceof PIXI.CustomRenderable) + else if (displayObject instanceof PIXI.CustomRenderable) { displayObject.renderCanvas(this); } - else if(displayObject instanceof PIXI.Graphics) + else if (displayObject instanceof PIXI.Graphics) { - context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]) - PIXI.CanvasGraphics.renderGraphics(displayObject, context); + this.context.setTransform(displayObject.worldTransform[0], displayObject.worldTransform[3], displayObject.worldTransform[1], displayObject.worldTransform[4], displayObject.worldTransform[2], displayObject.worldTransform[5]) + PIXI.CanvasGraphics.renderGraphics(displayObject, this.context); } - else if(displayObject instanceof PIXI.FilterBlock) + else if (displayObject instanceof PIXI.FilterBlock) { - if(displayObject.open) + if (displayObject.open) { - context.save(); + this.context.save(); var cacheAlpha = displayObject.mask.alpha; var maskTransform = displayObject.mask.worldTransform; - context.setTransform(maskTransform[0], maskTransform[3], maskTransform[1], maskTransform[4], maskTransform[2], maskTransform[5]) + this.context.setTransform(maskTransform[0], maskTransform[3], maskTransform[1], maskTransform[4], maskTransform[2], maskTransform[5]) displayObject.mask.worldAlpha = 0.5; - context.worldAlpha = 0; + this.context.worldAlpha = 0; - PIXI.CanvasGraphics.renderGraphicsMask(displayObject.mask, context); - context.clip(); + PIXI.CanvasGraphics.renderGraphicsMask(displayObject.mask, this.context); + this.context.clip(); displayObject.mask.worldAlpha = cacheAlpha; } else { - context.restore(); + this.context.restore(); } } - // count++ + // count++ displayObject = displayObject._iNext; - - } while(displayObject != testObject) diff --git a/build/phaser.min.js b/build/phaser.min.js index 01dc9612..3c791264 100644 --- a/build/phaser.min.js +++ b/build/phaser.min.js @@ -1,12 +1,12 @@ /*! Phaser v1.1.3 | (c) 2013 Photon Storm Ltd. */ -!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.Phaser=b()}(this,function(){function b(a){return[(255&a>>16)/255,(255&a>>8)/255,(255&a)/255]}function c(){return d.Matrix="undefined"!=typeof Float32Array?Float32Array:Array,d.Matrix}function b(a){return[(255&a>>16)/255,(255&a>>8)/255,(255&a)/255]}var d=d||{},e=e||{VERSION:"1.1.3",DEV_VERSION:"1.1.3",GAMES:[],AUTO:0,CANVAS:1,WEBGL:2,SPRITE:0,BUTTON:1,BULLET:2,GRAPHICS:3,TEXT:4,TILESPRITE:5,BITMAPTEXT:6,GROUP:7,RENDERTEXTURE:8,TILEMAP:9,TILEMAPLAYER:10,EMITTER:11,POLYGON:12,NONE:0,LEFT:1,RIGHT:2,UP:3,DOWN:4};d.InteractionManager=function(){},e.Utils={shuffle:function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},pad:function(a,b,c,d){if("undefined"==typeof b)var b=0;if("undefined"==typeof c)var c=" ";if("undefined"==typeof d)var d=3;if(b+1>=a.length)switch(d){case 1:a=Array(b+1-a.length).join(c)+a;break;case 3:var e=Math.ceil((padlen=b-a.length)/2),f=padlen-e;a=Array(f+1).join(c)+a+Array(e+1).join(c);break;default:a+=Array(b+1-a.length).join(c)}return a},isPlainObject:function(a){if("object"!=typeof a||a.nodeType||a===a.window)return!1;try{if(a.constructor&&!hasOwn.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(b){return!1}return!0},extend:function(){var a,b,c,d,f,g,h=arguments[0]||{},i=1,j=arguments.length,k=!1;for("boolean"==typeof h&&(k=h,h=arguments[1]||{},i=2),j===i&&(h=this,--i);j>i;i++)if(null!=(a=arguments[i]))for(b in a)c=h[b],d=a[b],h!==d&&(k&&d&&(e.Utils.isPlainObject(d)||(f=Array.isArray(d)))?(f?(f=!1,g=c&&Array.isArray(c)?c:[]):g=c&&e.Utils.isPlainObject(c)?c:{},h[b]=e.Utils.extend(k,g,d)):void 0!==d&&(h[b]=d));return h}},"function"!=typeof Function.prototype.bind&&(Function.prototype.bind=function(){var a=Array.prototype.slice;return function(b){function c(){var f=e.concat(a.call(arguments));d.apply(this instanceof c?this:b,f)}var d=this,e=a.call(arguments,1);if("function"!=typeof d)throw new TypeError;return c.prototype=function f(a){return a&&(f.prototype=a),this instanceof f?void 0:new f}(d.prototype),c}}()),c(),d.mat3={},d.mat3.create=function(){var a=new d.Matrix(9);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},d.mat3.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},d.mat4={},d.mat4.create=function(){var a=new d.Matrix(16);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},d.mat3.multiply=function(a,b,c){c||(c=a);var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=a[6],k=a[7],l=a[8],m=b[0],n=b[1],o=b[2],p=b[3],q=b[4],r=b[5],s=b[6],t=b[7],u=b[8];return c[0]=m*d+n*g+o*j,c[1]=m*e+n*h+o*k,c[2]=m*f+n*i+o*l,c[3]=p*d+q*g+r*j,c[4]=p*e+q*h+r*k,c[5]=p*f+q*i+r*l,c[6]=s*d+t*g+u*j,c[7]=s*e+t*h+u*k,c[8]=s*f+t*i+u*l,c},d.mat3.clone=function(a){var b=new d.Matrix(9);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b},d.mat3.transpose=function(a,b){if(!b||a===b){var c=a[1],d=a[2],e=a[5];return a[1]=a[3],a[2]=a[6],a[3]=c,a[5]=a[7],a[6]=d,a[7]=e,a}return b[0]=a[0],b[1]=a[3],b[2]=a[6],b[3]=a[1],b[4]=a[4],b[5]=a[7],b[6]=a[2],b[7]=a[5],b[8]=a[8],b},d.mat3.toMat4=function(a,b){return b||(b=d.mat4.create()),b[15]=1,b[14]=0,b[13]=0,b[12]=0,b[11]=0,b[10]=a[8],b[9]=a[7],b[8]=a[6],b[7]=0,b[6]=a[5],b[5]=a[4],b[4]=a[3],b[3]=0,b[2]=a[2],b[1]=a[1],b[0]=a[0],b},d.mat4.create=function(){var a=new d.Matrix(16);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},d.mat4.transpose=function(a,b){if(!b||a===b){var c=a[1],d=a[2],e=a[3],f=a[6],g=a[7],h=a[11];return a[1]=a[4],a[2]=a[8],a[3]=a[12],a[4]=c,a[6]=a[9],a[7]=a[13],a[8]=d,a[9]=f,a[11]=a[14],a[12]=e,a[13]=g,a[14]=h,a}return b[0]=a[0],b[1]=a[4],b[2]=a[8],b[3]=a[12],b[4]=a[1],b[5]=a[5],b[6]=a[9],b[7]=a[13],b[8]=a[2],b[9]=a[6],b[10]=a[10],b[11]=a[14],b[12]=a[3],b[13]=a[7],b[14]=a[11],b[15]=a[15],b},d.mat4.multiply=function(a,b,c){c||(c=a);var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=a[6],k=a[7],l=a[8],m=a[9],n=a[10],o=a[11],p=a[12],q=a[13],r=a[14],s=a[15],t=b[0],u=b[1],v=b[2],w=b[3];return c[0]=t*d+u*h+v*l+w*p,c[1]=t*e+u*i+v*m+w*q,c[2]=t*f+u*j+v*n+w*r,c[3]=t*g+u*k+v*o+w*s,t=b[4],u=b[5],v=b[6],w=b[7],c[4]=t*d+u*h+v*l+w*p,c[5]=t*e+u*i+v*m+w*q,c[6]=t*f+u*j+v*n+w*r,c[7]=t*g+u*k+v*o+w*s,t=b[8],u=b[9],v=b[10],w=b[11],c[8]=t*d+u*h+v*l+w*p,c[9]=t*e+u*i+v*m+w*q,c[10]=t*f+u*j+v*n+w*r,c[11]=t*g+u*k+v*o+w*s,t=b[12],u=b[13],v=b[14],w=b[15],c[12]=t*d+u*h+v*l+w*p,c[13]=t*e+u*i+v*m+w*q,c[14]=t*f+u*j+v*n+w*r,c[15]=t*g+u*k+v*o+w*s,c},d.Point=function(a,b){this.x=a||0,this.y=b||0},d.Point.prototype.clone=function(){return new d.Point(this.x,this.y)},d.Point.prototype.constructor=d.Point,d.Rectangle=function(a,b,c,d){this.x=a||0,this.y=b||0,this.width=c||0,this.height=d||0},d.Rectangle.prototype.clone=function(){return new d.Rectangle(this.x,this.y,this.width,this.height)},d.Rectangle.prototype.contains=function(a,b){if(this.width<=0||this.height<=0)return!1;var c=this.x;if(a>=c&&a<=c+this.width){var d=this.y;if(b>=d&&b<=d+this.height)return!0}return!1},d.Rectangle.prototype.constructor=d.Rectangle,d.Polygon=function(a){if(a instanceof Array||(a=Array.prototype.slice.call(arguments)),"number"==typeof a[0]){for(var b=[],c=0,e=a.length;e>c;c+=2)b.push(new d.Point(a[c],a[c+1]));a=b}this.points=a},d.Polygon.prototype.clone=function(){for(var a=[],b=0;bb!=i>b&&(h-f)*(b-g)/(i-g)+f>a;j&&(c=!c)}return c},d.Polygon.prototype.constructor=d.Polygon,d.DisplayObject=function(){this.last=this,this.first=this,this.position=new d.Point,this.scale=new d.Point(1,1),this.pivot=new d.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.hitArea=null,this.buttonMode=!1,this.renderable=!1,this.parent=null,this.stage=null,this.worldAlpha=1,this._interactive=!1,this.worldTransform=d.mat3.create(),this.localTransform=d.mat3.create(),this.color=[],this.dynamic=!0,this._sr=0,this._cr=1,this.filterArea=new d.Rectangle(0,0,1,1)},d.DisplayObject.prototype.constructor=d.DisplayObject,d.DisplayObject.prototype.setInteractive=function(a){this.interactive=a},Object.defineProperty(d.DisplayObject.prototype,"interactive",{get:function(){return this._interactive},set:function(a){this._interactive=a,this.stage&&(this.stage.dirty=!0)}}),Object.defineProperty(d.DisplayObject.prototype,"mask",{get:function(){return this._mask},set:function(a){a?this._mask?(a.start=this._mask.start,a.end=this._mask.end):(this.addFilter(a),a.renderable=!1):(this.removeFilter(this._mask),this._mask.renderable=!0),this._mask=a}}),Object.defineProperty(d.DisplayObject.prototype,"filters",{get:function(){return this._filters},set:function(a){if(a){this._filters&&this.removeFilter(this._filters),this.addFilter(a);for(var b=[],c=0;c=0&&b<=this.children.length))throw new Error(a+" The index "+b+" supplied is out of bounds "+this.children.length);if(void 0!=a.parent&&a.parent.removeChild(a),a.parent=this,this.stage){var c=a;do c.interactive&&(this.stage.dirty=!0),c.stage=this.stage,c=c._iNext;while(c)}var d,e,f=a.first,g=a.last;if(b==this.children.length){e=this.last;for(var h=this,i=this.last;h;)h.last==i&&(h.last=a.last),h=h.parent}else e=0==b?this:this.children[b-1].last;d=e._iNext,d&&(d._iPrev=g,g._iNext=d),f._iPrev=e,e._iNext=f,this.children.splice(b,0,a),this.__renderGroup&&(a.__renderGroup&&a.__renderGroup.removeDisplayObjectAndChildren(a),this.__renderGroup.addDisplayObjectAndChildren(a))},d.DisplayObjectContainer.prototype.swapChildren=function(){},d.DisplayObjectContainer.prototype.getChildAt=function(a){if(a>=0&&aa;a++)this.children[a].updateTransform()}},d.blendModes={},d.blendModes.NORMAL=0,d.blendModes.SCREEN=1,d.Sprite=function(a){d.DisplayObjectContainer.call(this),this.anchor=new d.Point,this.texture=a,this.blendMode=d.blendModes.NORMAL,this._width=0,this._height=0,a.baseTexture.hasLoaded?this.updateFrame=!0:(this.onTextureUpdateBind=this.onTextureUpdate.bind(this),this.texture.addEventListener("update",this.onTextureUpdateBind)),this.renderable=!0},d.Sprite.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Sprite.prototype.constructor=d.Sprite,Object.defineProperty(d.Sprite.prototype,"width",{get:function(){return this.scale.x*this.texture.frame.width},set:function(a){this.scale.x=a/this.texture.frame.width,this._width=a}}),Object.defineProperty(d.Sprite.prototype,"height",{get:function(){return this.scale.y*this.texture.frame.height},set:function(a){this.scale.y=a/this.texture.frame.height,this._height=a}}),d.Sprite.prototype.setTexture=function(a){this.texture.baseTexture!=a.baseTexture?(this.textureChange=!0,this.texture=a,this.__renderGroup&&this.__renderGroup.updateTexture(this)):this.texture=a,this.updateFrame=!0},d.Sprite.prototype.onTextureUpdate=function(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height),this.updateFrame=!0},d.Sprite.fromFrame=function(a){var b=d.TextureCache[a];if(!b)throw new Error("The frameId '"+a+"' does not exist in the texture cache"+this);return new d.Sprite(b)},d.Sprite.fromImage=function(a){var b=d.Texture.fromImage(a);return new d.Sprite(b)},d.Stage=function(a){d.DisplayObjectContainer.call(this),this.worldTransform=d.mat3.create(),this.interactive=!0,this.interactionManager=new d.InteractionManager(this),this.dirty=!0,this.__childrenAdded=[],this.__childrenRemoved=[],this.stage=this,this.stage.hitArea=new d.Rectangle(0,0,1e5,1e5),this.setBackgroundColor(a),this.worldVisible=!0},d.Stage.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Stage.prototype.constructor=d.Stage,d.Stage.prototype.setInteractionDelegate=function(a){this.interactionManager.setTargetDomElement(a)},d.Stage.prototype.updateTransform=function(){this.worldAlpha=1,this.vcount=d.visibleCount;for(var a=0,b=this.children.length;b>a;a++)this.children[a].updateTransform();this.dirty&&(this.dirty=!1,this.interactionManager.dirty=!0),this.interactive&&this.interactionManager.update()},d.Stage.prototype.setBackgroundColor=function(a){this.backgroundColor=a||0,this.backgroundColorSplit=b(this.backgroundColor);var c=this.backgroundColor.toString(16);c="000000".substr(0,6-c.length)+c,this.backgroundColorString="#"+c},d.Stage.prototype.getMousePosition=function(){return this.interactionManager.mouse.global},d.CustomRenderable=function(){d.DisplayObject.call(this),this.renderable=!0},d.CustomRenderable.prototype=Object.create(d.DisplayObject.prototype),d.CustomRenderable.prototype.constructor=d.CustomRenderable,d.CustomRenderable.prototype.renderCanvas=function(){},d.CustomRenderable.prototype.initWebGL=function(){},d.CustomRenderable.prototype.renderWebGL=function(){},d.Strip=function(a,b,c){d.DisplayObjectContainer.call(this),this.texture=a,this.blendMode=d.blendModes.NORMAL;try{this.uvs=new Float32Array([0,1,1,1,1,0,0,1]),this.verticies=new Float32Array([0,0,0,0,0,0,0,0,0]),this.colors=new Float32Array([1,1,1,1]),this.indices=new Uint16Array([0,1,2,3])}catch(e){this.uvs=[0,1,1,1,1,0,0,1],this.verticies=[0,0,0,0,0,0,0,0,0],this.colors=[1,1,1,1],this.indices=[0,1,2,3]}this.width=b,this.height=c,a.baseTexture.hasLoaded?(this.width=this.texture.frame.width,this.height=this.texture.frame.height,this.updateFrame=!0):(this.onTextureUpdateBind=this.onTextureUpdate.bind(this),this.texture.addEventListener("update",this.onTextureUpdateBind)),this.renderable=!0},d.Strip.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Strip.prototype.constructor=d.Strip,d.Strip.prototype.setTexture=function(a){this.texture=a,this.width=a.frame.width,this.height=a.frame.height,this.updateFrame=!0},d.Strip.prototype.onTextureUpdate=function(){this.updateFrame=!0},d.Rope=function(a,b){d.Strip.call(this,a),this.points=b;try{this.verticies=new Float32Array(4*b.length),this.uvs=new Float32Array(4*b.length),this.colors=new Float32Array(2*b.length),this.indices=new Uint16Array(2*b.length)}catch(c){this.verticies=verticies,this.uvs=uvs,this.colors=colors,this.indices=indices}this.refresh()},d.Rope.prototype=Object.create(d.Strip.prototype),d.Rope.prototype.constructor=d.Rope,d.Rope.prototype.refresh=function(){var a=this.points;if(!(a.length<1)){var b=this.uvs,c=this.indices,d=this.colors,e=a[0],f=a[0];this.count-=.2,b[0]=0,b[1]=1,b[2]=0,b[3]=1,d[0]=1,d[1]=1,c[0]=0,c[1]=1;for(var g=a.length,h=1;g>h;h++){var f=a[h],i=4*h,j=h/(g-1);h%2?(b[i]=j,b[i+1]=0,b[i+2]=j,b[i+3]=1):(b[i]=j,b[i+1]=0,b[i+2]=j,b[i+3]=1),i=2*h,d[i]=1,d[i+1]=1,i=2*h,c[i]=i,c[i+1]=i+1,e=f}}},d.Rope.prototype.updateTransform=function(){var a=this.points;if(!(a.length<1)){var b,c=this.verticies,e=a[0],f={x:0,y:0},g=a[0];this.count-=.2,c[0]=g.x+f.x,c[1]=g.y+f.y,c[2]=g.x-f.x,c[3]=g.y-f.y;for(var h=a.length,i=1;h>i;i++){var g=a[i],j=4*i;b=i1&&(k=1);var l=Math.sqrt(f.x*f.x+f.y*f.y),m=this.texture.height/2;f.x/=l,f.y/=l,f.x*=m,f.y*=m,c[j]=g.x+f.x,c[j+1]=g.y+f.y,c[j+2]=g.x-f.x,c[j+3]=g.y-f.y,e=g}d.DisplayObjectContainer.prototype.updateTransform.call(this)}},d.Rope.prototype.setTexture=function(a){this.texture=a,this.updateFrame=!0},d.TilingSprite=function(a,b,c){d.DisplayObjectContainer.call(this),this.texture=a,this.width=b,this.height=c,this.tileScale=new d.Point(1,1),this.tilePosition=new d.Point(0,0),this.renderable=!0,this.blendMode=d.blendModes.NORMAL},d.TilingSprite.prototype=Object.create(d.DisplayObjectContainer.prototype),d.TilingSprite.prototype.constructor=d.TilingSprite,d.TilingSprite.prototype.setTexture=function(a){this.texture=a,this.updateFrame=!0},d.TilingSprite.prototype.onTextureUpdate=function(){this.updateFrame=!0},d.AbstractFilter=function(a,b){this.passes=[this],this.dirty=!0,this.padding=0,this.uniforms=b||{},this.fragmentSrc=a||[]},d.BlurFilter=function(){this.blurXFilter=new d.BlurXFilter,this.blurYFilter=new d.BlurYFilter,this.passes=[this.blurXFilter,this.blurYFilter]},Object.defineProperty(d.BlurFilter.prototype,"blur",{get:function(){return this.blurXFilter.blur},set:function(a){this.blurXFilter.blur=this.blurYFilter.blur=a}}),Object.defineProperty(d.BlurFilter.prototype,"blurX",{get:function(){return this.blurXFilter.blur},set:function(a){this.blurXFilter.blur=a}}),Object.defineProperty(d.BlurFilter.prototype,"blurY",{get:function(){return this.blurYFilter.blur},set:function(a){this.blurYFilter.blur=a}}),d.BlurXFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {","vec4 sum = vec4(0.0);","sum += texture2D(uSampler, vec2(vTextureCoord.x - 4.0*blur, vTextureCoord.y)) * 0.05;","sum += texture2D(uSampler, vec2(vTextureCoord.x - 3.0*blur, vTextureCoord.y)) * 0.09;","sum += texture2D(uSampler, vec2(vTextureCoord.x - 2.0*blur, vTextureCoord.y)) * 0.12;","sum += texture2D(uSampler, vec2(vTextureCoord.x - blur, vTextureCoord.y)) * 0.15;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;","sum += texture2D(uSampler, vec2(vTextureCoord.x + blur, vTextureCoord.y)) * 0.15;","sum += texture2D(uSampler, vec2(vTextureCoord.x + 2.0*blur, vTextureCoord.y)) * 0.12;","sum += texture2D(uSampler, vec2(vTextureCoord.x + 3.0*blur, vTextureCoord.y)) * 0.09;","sum += texture2D(uSampler, vec2(vTextureCoord.x + 4.0*blur, vTextureCoord.y)) * 0.05;","gl_FragColor = sum;","}"]},d.BlurXFilter.prototype=Object.create(d.AbstractFilter.prototype),d.BlurXFilter.prototype.constructor=d.BlurXFilter,Object.defineProperty(d.BlurXFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.dirty=!0,this.uniforms.blur.value=1/7e3*a}}),d.BlurYFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {","vec4 sum = vec4(0.0);","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 4.0*blur)) * 0.05;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 3.0*blur)) * 0.09;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 2.0*blur)) * 0.12;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - blur)) * 0.15;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + blur)) * 0.15;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 2.0*blur)) * 0.12;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 3.0*blur)) * 0.09;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 4.0*blur)) * 0.05;","gl_FragColor = sum;","}"]},d.BlurYFilter.prototype=Object.create(d.AbstractFilter.prototype),d.BlurYFilter.prototype.constructor=d.BlurYFilter,Object.defineProperty(d.BlurYFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.uniforms.blur.value=1/7e3*a}}),d.ColorMatrixFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={matrix:{type:"mat4",value:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float invert;","uniform mat4 matrix;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vTextureCoord) * matrix;","gl_FragColor = gl_FragColor * vColor;","}"]},d.ColorMatrixFilter.prototype=Object.create(d.AbstractFilter.prototype),d.ColorMatrixFilter.prototype.constructor=d.ColorMatrixFilter,Object.defineProperty(d.ColorMatrixFilter.prototype,"matrix",{get:function(){return this.uniforms.matrix.value},set:function(a){this.uniforms.matrix.value=a}}),d.CrossHatchFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {"," float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb);"," "," gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);"," "," if (lum < 1.00) {"," if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," "," if (lum < 0.75) {"," if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," "," if (lum < 0.50) {"," if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," "," if (lum < 0.3) {"," if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }","}"]},d.CrossHatchFilter.prototype=Object.create(d.AbstractFilter.prototype),d.CrossHatchFilter.prototype.constructor=d.BlurYFilter,Object.defineProperty(d.CrossHatchFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.uniforms.blur.value=1/7e3*a}}),d.DisplacementFilter=function(a){d.AbstractFilter.call(this),this.passes=[this],a.baseTexture._powerOf2=!0,this.uniforms={displacementMap:{type:"sampler2D",value:a},scale:{type:"f2",value:{x:30,y:30}},offset:{type:"f2",value:{x:0,y:0}},mapDimensions:{type:"f2",value:{x:1,y:5112}},dimensions:{type:"f4",value:[0,0,0,0]}},a.baseTexture.hasLoaded?(this.uniforms.mapDimensions.value.x=a.width,this.uniforms.mapDimensions.value.y=a.height):(this.boundLoadedFunction=this.onTextureLoaded.bind(this),a.baseTexture.on("loaded",this.boundLoadedFunction)),this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D displacementMap;","uniform sampler2D uSampler;","uniform vec2 scale;","uniform vec2 offset;","uniform vec4 dimensions;","uniform vec2 mapDimensions;","void main(void) {","vec2 mapCords = vTextureCoord.xy;","mapCords += (dimensions.zw + offset)/ dimensions.xy ;","mapCords.y *= -1.0;","mapCords.y += 1.0;","vec2 matSample = texture2D(displacementMap, mapCords).xy;","matSample -= 0.5;","matSample *= scale;","matSample /= mapDimensions;","gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x + matSample.x, vTextureCoord.y + matSample.y));","gl_FragColor.rgb = mix( gl_FragColor.rgb, gl_FragColor.rgb, 1.0);","vec2 cord = vTextureCoord;","gl_FragColor = gl_FragColor * vColor;","}"]},d.DisplacementFilter.prototype=Object.create(d.AbstractFilter.prototype),d.DisplacementFilter.prototype.constructor=d.DisplacementFilter,d.DisplacementFilter.prototype.onTextureLoaded=function(){this.uniforms.mapDimensions.value.x=this.uniforms.displacementMap.value.width,this.uniforms.mapDimensions.value.y=this.uniforms.displacementMap.value.height,this.uniforms.displacementMap.value.baseTexture.off("loaded",this.boundLoadedFunction)},Object.defineProperty(d.DisplacementFilter.prototype,"map",{get:function(){return this.uniforms.displacementMap.value},set:function(a){this.uniforms.displacementMap.value=a}}),Object.defineProperty(d.DisplacementFilter.prototype,"scale",{get:function(){return this.uniforms.scale.value},set:function(a){this.uniforms.scale.value=a}}),Object.defineProperty(d.DisplacementFilter.prototype,"offset",{get:function(){return this.uniforms.offset.value},set:function(a){this.uniforms.offset.value=a}}),d.DotScreenFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={scale:{type:"f",value:1},angle:{type:"f",value:5},dimensions:{type:"f4",value:[0,0,0,0]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform vec4 dimensions;","uniform sampler2D uSampler;","uniform float angle;","uniform float scale;","float pattern() {","float s = sin(angle), c = cos(angle);","vec2 tex = vTextureCoord * dimensions.xy;","vec2 point = vec2(","c * tex.x - s * tex.y,","s * tex.x + c * tex.y",") * scale;","return (sin(point.x) * sin(point.y)) * 4.0;","}","void main() {","vec4 color = texture2D(uSampler, vTextureCoord);","float average = (color.r + color.g + color.b) / 3.0;","gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a);","}"]},d.DotScreenFilter.prototype=Object.create(d.DotScreenFilter.prototype),d.DotScreenFilter.prototype.constructor=d.DotScreenFilter,Object.defineProperty(d.DotScreenFilter.prototype,"scale",{get:function(){return this.uniforms.scale.value},set:function(a){this.dirty=!0,this.uniforms.scale.value=a}}),Object.defineProperty(d.DotScreenFilter.prototype,"angle",{get:function(){return this.uniforms.angle.value},set:function(a){this.dirty=!0,this.uniforms.angle.value=a}}),d.FilterBlock=function(){this.visible=!0,this.renderable=!0},d.GreyFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={grey:{type:"f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","uniform float grey;","void main(void) {","gl_FragColor = texture2D(uSampler, vTextureCoord);","gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2126*gl_FragColor.r + 0.7152*gl_FragColor.g + 0.0722*gl_FragColor.b), grey);","gl_FragColor = gl_FragColor * vColor;","}"]},d.GreyFilter.prototype=Object.create(d.AbstractFilter.prototype),d.GreyFilter.prototype.constructor=d.GreyFilter,Object.defineProperty(d.GreyFilter.prototype,"grey",{get:function(){return this.uniforms.grey.value},set:function(a){this.uniforms.grey.value=a}}),d.InvertFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={invert:{type:"f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float invert;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vTextureCoord);","gl_FragColor.rgb = mix( (vec3(1)-gl_FragColor.rgb) * gl_FragColor.a, gl_FragColor.rgb, 1.0 - invert);","gl_FragColor = gl_FragColor * vColor;","}"]},d.InvertFilter.prototype=Object.create(d.AbstractFilter.prototype),d.InvertFilter.prototype.constructor=d.InvertFilter,Object.defineProperty(d.InvertFilter.prototype,"invert",{get:function(){return this.uniforms.invert.value},set:function(a){this.uniforms.invert.value=a}}),d.PixelateFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={invert:{type:"f",value:0},dimensions:{type:"f4",value:new Float32Array([1e4,100,10,10])},pixelSize:{type:"f2",value:{x:10,y:10}}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform vec2 testDim;","uniform vec4 dimensions;","uniform vec2 pixelSize;","uniform sampler2D uSampler;","void main(void) {","vec2 coord = vTextureCoord;","vec2 size = dimensions.xy/pixelSize;","vec2 color = floor( ( vTextureCoord * size ) ) / size + pixelSize/dimensions.xy * 0.5;","gl_FragColor = texture2D(uSampler, color);","}"]},d.PixelateFilter.prototype=Object.create(d.AbstractFilter.prototype),d.PixelateFilter.prototype.constructor=d.PixelateFilter,Object.defineProperty(d.PixelateFilter.prototype,"size",{get:function(){return this.uniforms.pixelSize.value},set:function(a){this.dirty=!0,this.uniforms.pixelSize.value=a}}),d.RGBSplitFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={red:{type:"f2",value:{x:20,y:20}},green:{type:"f2",value:{x:-20,y:20}},blue:{type:"f2",value:{x:20,y:-20}},dimensions:{type:"f4",value:[0,0,0,0]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform vec2 red;","uniform vec2 green;","uniform vec2 blue;","uniform vec4 dimensions;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/dimensions.xy).r;","gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/dimensions.xy).g;","gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/dimensions.xy).b;","gl_FragColor.a = texture2D(uSampler, vTextureCoord).a;","}"]},d.RGBSplitFilter.prototype=Object.create(d.AbstractFilter.prototype),d.RGBSplitFilter.prototype.constructor=d.RGBSplitFilter,Object.defineProperty(d.RGBSplitFilter.prototype,"angle",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.uniforms.blur.value=1/7e3*a}}),d.SepiaFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={sepia:{type:"f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float sepia;","uniform sampler2D uSampler;","const mat3 sepiaMatrix = mat3(0.3588, 0.7044, 0.1368, 0.2990, 0.5870, 0.1140, 0.2392, 0.4696, 0.0912);","void main(void) {","gl_FragColor = texture2D(uSampler, vTextureCoord);","gl_FragColor.rgb = mix( gl_FragColor.rgb, gl_FragColor.rgb * sepiaMatrix, sepia);","gl_FragColor = gl_FragColor * vColor;","}"]},d.SepiaFilter.prototype=Object.create(d.AbstractFilter.prototype),d.SepiaFilter.prototype.constructor=d.SepiaFilter,Object.defineProperty(d.SepiaFilter.prototype,"sepia",{get:function(){return this.uniforms.sepia.value},set:function(a){this.uniforms.sepia.value=a}}),d.SmartBlurFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","uniform sampler2D uSampler;","const vec2 delta = vec2(1.0/10.0, 0.0);","float random(vec3 scale, float seed) {","return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);","}","void main(void) {","vec4 color = vec4(0.0);","float total = 0.0;","float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);","for (float t = -30.0; t <= 30.0; t++) {","float percent = (t + offset - 0.5) / 30.0;","float weight = 1.0 - abs(percent);","vec4 sample = texture2D(uSampler, vTextureCoord + delta * percent);","sample.rgb *= sample.a;","color += sample * weight;","total += weight;","}","gl_FragColor = color / total;","gl_FragColor.rgb /= gl_FragColor.a + 0.00001;","}"] +!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.Phaser=b()}(this,function(){function b(a){return[(255&a>>16)/255,(255&a>>8)/255,(255&a)/255]}function c(){return d.Matrix="undefined"!=typeof Float32Array?Float32Array:Array,d.Matrix}function b(a){return[(255&a>>16)/255,(255&a>>8)/255,(255&a)/255]}var d=d||{},e=e||{VERSION:"1.1.3",DEV_VERSION:"1.1.3",GAMES:[],AUTO:0,CANVAS:1,WEBGL:2,SPRITE:0,BUTTON:1,BULLET:2,GRAPHICS:3,TEXT:4,TILESPRITE:5,BITMAPTEXT:6,GROUP:7,RENDERTEXTURE:8,TILEMAP:9,TILEMAPLAYER:10,EMITTER:11,POLYGON:12,BITMAPDATA:13,NONE:0,LEFT:1,RIGHT:2,UP:3,DOWN:4};d.InteractionManager=function(){},e.Utils={shuffle:function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},pad:function(a,b,c,d){if("undefined"==typeof b)var b=0;if("undefined"==typeof c)var c=" ";if("undefined"==typeof d)var d=3;if(b+1>=a.length)switch(d){case 1:a=Array(b+1-a.length).join(c)+a;break;case 3:var e=Math.ceil((padlen=b-a.length)/2),f=padlen-e;a=Array(f+1).join(c)+a+Array(e+1).join(c);break;default:a+=Array(b+1-a.length).join(c)}return a},isPlainObject:function(a){if("object"!=typeof a||a.nodeType||a===a.window)return!1;try{if(a.constructor&&!hasOwn.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(b){return!1}return!0},extend:function(){var a,b,c,d,f,g,h=arguments[0]||{},i=1,j=arguments.length,k=!1;for("boolean"==typeof h&&(k=h,h=arguments[1]||{},i=2),j===i&&(h=this,--i);j>i;i++)if(null!=(a=arguments[i]))for(b in a)c=h[b],d=a[b],h!==d&&(k&&d&&(e.Utils.isPlainObject(d)||(f=Array.isArray(d)))?(f?(f=!1,g=c&&Array.isArray(c)?c:[]):g=c&&e.Utils.isPlainObject(c)?c:{},h[b]=e.Utils.extend(k,g,d)):void 0!==d&&(h[b]=d));return h}},"function"!=typeof Function.prototype.bind&&(Function.prototype.bind=function(){var a=Array.prototype.slice;return function(b){function c(){var f=e.concat(a.call(arguments));d.apply(this instanceof c?this:b,f)}var d=this,e=a.call(arguments,1);if("function"!=typeof d)throw new TypeError;return c.prototype=function f(a){return a&&(f.prototype=a),this instanceof f?void 0:new f}(d.prototype),c}}()),c(),d.mat3={},d.mat3.create=function(){var a=new d.Matrix(9);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},d.mat3.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},d.mat4={},d.mat4.create=function(){var a=new d.Matrix(16);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},d.mat3.multiply=function(a,b,c){c||(c=a);var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=a[6],k=a[7],l=a[8],m=b[0],n=b[1],o=b[2],p=b[3],q=b[4],r=b[5],s=b[6],t=b[7],u=b[8];return c[0]=m*d+n*g+o*j,c[1]=m*e+n*h+o*k,c[2]=m*f+n*i+o*l,c[3]=p*d+q*g+r*j,c[4]=p*e+q*h+r*k,c[5]=p*f+q*i+r*l,c[6]=s*d+t*g+u*j,c[7]=s*e+t*h+u*k,c[8]=s*f+t*i+u*l,c},d.mat3.clone=function(a){var b=new d.Matrix(9);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b},d.mat3.transpose=function(a,b){if(!b||a===b){var c=a[1],d=a[2],e=a[5];return a[1]=a[3],a[2]=a[6],a[3]=c,a[5]=a[7],a[6]=d,a[7]=e,a}return b[0]=a[0],b[1]=a[3],b[2]=a[6],b[3]=a[1],b[4]=a[4],b[5]=a[7],b[6]=a[2],b[7]=a[5],b[8]=a[8],b},d.mat3.toMat4=function(a,b){return b||(b=d.mat4.create()),b[15]=1,b[14]=0,b[13]=0,b[12]=0,b[11]=0,b[10]=a[8],b[9]=a[7],b[8]=a[6],b[7]=0,b[6]=a[5],b[5]=a[4],b[4]=a[3],b[3]=0,b[2]=a[2],b[1]=a[1],b[0]=a[0],b},d.mat4.create=function(){var a=new d.Matrix(16);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},d.mat4.transpose=function(a,b){if(!b||a===b){var c=a[1],d=a[2],e=a[3],f=a[6],g=a[7],h=a[11];return a[1]=a[4],a[2]=a[8],a[3]=a[12],a[4]=c,a[6]=a[9],a[7]=a[13],a[8]=d,a[9]=f,a[11]=a[14],a[12]=e,a[13]=g,a[14]=h,a}return b[0]=a[0],b[1]=a[4],b[2]=a[8],b[3]=a[12],b[4]=a[1],b[5]=a[5],b[6]=a[9],b[7]=a[13],b[8]=a[2],b[9]=a[6],b[10]=a[10],b[11]=a[14],b[12]=a[3],b[13]=a[7],b[14]=a[11],b[15]=a[15],b},d.mat4.multiply=function(a,b,c){c||(c=a);var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=a[6],k=a[7],l=a[8],m=a[9],n=a[10],o=a[11],p=a[12],q=a[13],r=a[14],s=a[15],t=b[0],u=b[1],v=b[2],w=b[3];return c[0]=t*d+u*h+v*l+w*p,c[1]=t*e+u*i+v*m+w*q,c[2]=t*f+u*j+v*n+w*r,c[3]=t*g+u*k+v*o+w*s,t=b[4],u=b[5],v=b[6],w=b[7],c[4]=t*d+u*h+v*l+w*p,c[5]=t*e+u*i+v*m+w*q,c[6]=t*f+u*j+v*n+w*r,c[7]=t*g+u*k+v*o+w*s,t=b[8],u=b[9],v=b[10],w=b[11],c[8]=t*d+u*h+v*l+w*p,c[9]=t*e+u*i+v*m+w*q,c[10]=t*f+u*j+v*n+w*r,c[11]=t*g+u*k+v*o+w*s,t=b[12],u=b[13],v=b[14],w=b[15],c[12]=t*d+u*h+v*l+w*p,c[13]=t*e+u*i+v*m+w*q,c[14]=t*f+u*j+v*n+w*r,c[15]=t*g+u*k+v*o+w*s,c},d.Point=function(a,b){this.x=a||0,this.y=b||0},d.Point.prototype.clone=function(){return new d.Point(this.x,this.y)},d.Point.prototype.constructor=d.Point,d.Rectangle=function(a,b,c,d){this.x=a||0,this.y=b||0,this.width=c||0,this.height=d||0},d.Rectangle.prototype.clone=function(){return new d.Rectangle(this.x,this.y,this.width,this.height)},d.Rectangle.prototype.contains=function(a,b){if(this.width<=0||this.height<=0)return!1;var c=this.x;if(a>=c&&a<=c+this.width){var d=this.y;if(b>=d&&b<=d+this.height)return!0}return!1},d.Rectangle.prototype.constructor=d.Rectangle,d.Polygon=function(a){if(a instanceof Array||(a=Array.prototype.slice.call(arguments)),"number"==typeof a[0]){for(var b=[],c=0,e=a.length;e>c;c+=2)b.push(new d.Point(a[c],a[c+1]));a=b}this.points=a},d.Polygon.prototype.clone=function(){for(var a=[],b=0;bb!=i>b&&(h-f)*(b-g)/(i-g)+f>a;j&&(c=!c)}return c},d.Polygon.prototype.constructor=d.Polygon,d.DisplayObject=function(){this.last=this,this.first=this,this.position=new d.Point,this.scale=new d.Point(1,1),this.pivot=new d.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.hitArea=null,this.buttonMode=!1,this.renderable=!1,this.parent=null,this.stage=null,this.worldAlpha=1,this._interactive=!1,this.worldTransform=d.mat3.create(),this.localTransform=d.mat3.create(),this.color=[],this.dynamic=!0,this._sr=0,this._cr=1,this.filterArea=new d.Rectangle(0,0,1,1)},d.DisplayObject.prototype.constructor=d.DisplayObject,d.DisplayObject.prototype.setInteractive=function(a){this.interactive=a},Object.defineProperty(d.DisplayObject.prototype,"interactive",{get:function(){return this._interactive},set:function(a){this._interactive=a,this.stage&&(this.stage.dirty=!0)}}),Object.defineProperty(d.DisplayObject.prototype,"mask",{get:function(){return this._mask},set:function(a){a?this._mask?(a.start=this._mask.start,a.end=this._mask.end):(this.addFilter(a),a.renderable=!1):(this.removeFilter(this._mask),this._mask.renderable=!0),this._mask=a}}),Object.defineProperty(d.DisplayObject.prototype,"filters",{get:function(){return this._filters},set:function(a){if(a){this._filters&&this.removeFilter(this._filters),this.addFilter(a);for(var b=[],c=0;c=0&&b<=this.children.length))throw new Error(a+" The index "+b+" supplied is out of bounds "+this.children.length);if(void 0!=a.parent&&a.parent.removeChild(a),a.parent=this,this.stage){var c=a;do c.interactive&&(this.stage.dirty=!0),c.stage=this.stage,c=c._iNext;while(c)}var d,e,f=a.first,g=a.last;if(b==this.children.length){e=this.last;for(var h=this,i=this.last;h;)h.last==i&&(h.last=a.last),h=h.parent}else e=0==b?this:this.children[b-1].last;d=e._iNext,d&&(d._iPrev=g,g._iNext=d),f._iPrev=e,e._iNext=f,this.children.splice(b,0,a),this.__renderGroup&&(a.__renderGroup&&a.__renderGroup.removeDisplayObjectAndChildren(a),this.__renderGroup.addDisplayObjectAndChildren(a))},d.DisplayObjectContainer.prototype.swapChildren=function(){},d.DisplayObjectContainer.prototype.getChildAt=function(a){if(a>=0&&aa;a++)this.children[a].updateTransform()}},d.blendModes={},d.blendModes.NORMAL=0,d.blendModes.SCREEN=1,d.Sprite=function(a){d.DisplayObjectContainer.call(this),this.anchor=new d.Point,this.texture=a,this.blendMode=d.blendModes.NORMAL,this._width=0,this._height=0,a.baseTexture.hasLoaded?this.updateFrame=!0:(this.onTextureUpdateBind=this.onTextureUpdate.bind(this),this.texture.addEventListener("update",this.onTextureUpdateBind)),this.renderable=!0},d.Sprite.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Sprite.prototype.constructor=d.Sprite,Object.defineProperty(d.Sprite.prototype,"width",{get:function(){return this.scale.x*this.texture.frame.width},set:function(a){this.scale.x=a/this.texture.frame.width,this._width=a}}),Object.defineProperty(d.Sprite.prototype,"height",{get:function(){return this.scale.y*this.texture.frame.height},set:function(a){this.scale.y=a/this.texture.frame.height,this._height=a}}),d.Sprite.prototype.setTexture=function(a){this.texture.baseTexture!=a.baseTexture?(this.textureChange=!0,this.texture=a,this.__renderGroup&&this.__renderGroup.updateTexture(this)):this.texture=a,this.updateFrame=!0},d.Sprite.prototype.onTextureUpdate=function(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height),this.updateFrame=!0},d.Sprite.fromFrame=function(a){var b=d.TextureCache[a];if(!b)throw new Error("The frameId '"+a+"' does not exist in the texture cache"+this);return new d.Sprite(b)},d.Sprite.fromImage=function(a){var b=d.Texture.fromImage(a);return new d.Sprite(b)},d.Stage=function(a){d.DisplayObjectContainer.call(this),this.worldTransform=d.mat3.create(),this.interactive=!0,this.interactionManager=new d.InteractionManager(this),this.dirty=!0,this.__childrenAdded=[],this.__childrenRemoved=[],this.stage=this,this.stage.hitArea=new d.Rectangle(0,0,1e5,1e5),this.setBackgroundColor(a),this.worldVisible=!0},d.Stage.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Stage.prototype.constructor=d.Stage,d.Stage.prototype.setInteractionDelegate=function(a){this.interactionManager.setTargetDomElement(a)},d.Stage.prototype.updateTransform=function(){this.worldAlpha=1,this.vcount=d.visibleCount;for(var a=0,b=this.children.length;b>a;a++)this.children[a].updateTransform();this.dirty&&(this.dirty=!1,this.interactionManager.dirty=!0),this.interactive&&this.interactionManager.update()},d.Stage.prototype.setBackgroundColor=function(a){this.backgroundColor=a||0,this.backgroundColorSplit=b(this.backgroundColor);var c=this.backgroundColor.toString(16);c="000000".substr(0,6-c.length)+c,this.backgroundColorString="#"+c},d.Stage.prototype.getMousePosition=function(){return this.interactionManager.mouse.global},d.CustomRenderable=function(){d.DisplayObject.call(this),this.renderable=!0},d.CustomRenderable.prototype=Object.create(d.DisplayObject.prototype),d.CustomRenderable.prototype.constructor=d.CustomRenderable,d.CustomRenderable.prototype.renderCanvas=function(){},d.CustomRenderable.prototype.initWebGL=function(){},d.CustomRenderable.prototype.renderWebGL=function(){},d.Strip=function(a,b,c){d.DisplayObjectContainer.call(this),this.texture=a,this.blendMode=d.blendModes.NORMAL;try{this.uvs=new Float32Array([0,1,1,1,1,0,0,1]),this.verticies=new Float32Array([0,0,0,0,0,0,0,0,0]),this.colors=new Float32Array([1,1,1,1]),this.indices=new Uint16Array([0,1,2,3])}catch(e){this.uvs=[0,1,1,1,1,0,0,1],this.verticies=[0,0,0,0,0,0,0,0,0],this.colors=[1,1,1,1],this.indices=[0,1,2,3]}this.width=b,this.height=c,a.baseTexture.hasLoaded?(this.width=this.texture.frame.width,this.height=this.texture.frame.height,this.updateFrame=!0):(this.onTextureUpdateBind=this.onTextureUpdate.bind(this),this.texture.addEventListener("update",this.onTextureUpdateBind)),this.renderable=!0},d.Strip.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Strip.prototype.constructor=d.Strip,d.Strip.prototype.setTexture=function(a){this.texture=a,this.width=a.frame.width,this.height=a.frame.height,this.updateFrame=!0},d.Strip.prototype.onTextureUpdate=function(){this.updateFrame=!0},d.Rope=function(a,b){d.Strip.call(this,a),this.points=b;try{this.verticies=new Float32Array(4*b.length),this.uvs=new Float32Array(4*b.length),this.colors=new Float32Array(2*b.length),this.indices=new Uint16Array(2*b.length)}catch(c){this.verticies=verticies,this.uvs=uvs,this.colors=colors,this.indices=indices}this.refresh()},d.Rope.prototype=Object.create(d.Strip.prototype),d.Rope.prototype.constructor=d.Rope,d.Rope.prototype.refresh=function(){var a=this.points;if(!(a.length<1)){var b=this.uvs,c=this.indices,d=this.colors,e=a[0],f=a[0];this.count-=.2,b[0]=0,b[1]=1,b[2]=0,b[3]=1,d[0]=1,d[1]=1,c[0]=0,c[1]=1;for(var g=a.length,h=1;g>h;h++){var f=a[h],i=4*h,j=h/(g-1);h%2?(b[i]=j,b[i+1]=0,b[i+2]=j,b[i+3]=1):(b[i]=j,b[i+1]=0,b[i+2]=j,b[i+3]=1),i=2*h,d[i]=1,d[i+1]=1,i=2*h,c[i]=i,c[i+1]=i+1,e=f}}},d.Rope.prototype.updateTransform=function(){var a=this.points;if(!(a.length<1)){var b,c=this.verticies,e=a[0],f={x:0,y:0},g=a[0];this.count-=.2,c[0]=g.x+f.x,c[1]=g.y+f.y,c[2]=g.x-f.x,c[3]=g.y-f.y;for(var h=a.length,i=1;h>i;i++){var g=a[i],j=4*i;b=i1&&(k=1);var l=Math.sqrt(f.x*f.x+f.y*f.y),m=this.texture.height/2;f.x/=l,f.y/=l,f.x*=m,f.y*=m,c[j]=g.x+f.x,c[j+1]=g.y+f.y,c[j+2]=g.x-f.x,c[j+3]=g.y-f.y,e=g}d.DisplayObjectContainer.prototype.updateTransform.call(this)}},d.Rope.prototype.setTexture=function(a){this.texture=a,this.updateFrame=!0},d.TilingSprite=function(a,b,c){d.DisplayObjectContainer.call(this),this.texture=a,this.width=b,this.height=c,this.tileScale=new d.Point(1,1),this.tilePosition=new d.Point(0,0),this.renderable=!0,this.blendMode=d.blendModes.NORMAL},d.TilingSprite.prototype=Object.create(d.DisplayObjectContainer.prototype),d.TilingSprite.prototype.constructor=d.TilingSprite,d.TilingSprite.prototype.setTexture=function(a){this.texture=a,this.updateFrame=!0},d.TilingSprite.prototype.onTextureUpdate=function(){this.updateFrame=!0},d.AbstractFilter=function(a,b){this.passes=[this],this.dirty=!0,this.padding=0,this.uniforms=b||{},this.fragmentSrc=a||[]},d.BlurFilter=function(){this.blurXFilter=new d.BlurXFilter,this.blurYFilter=new d.BlurYFilter,this.passes=[this.blurXFilter,this.blurYFilter]},Object.defineProperty(d.BlurFilter.prototype,"blur",{get:function(){return this.blurXFilter.blur},set:function(a){this.blurXFilter.blur=this.blurYFilter.blur=a}}),Object.defineProperty(d.BlurFilter.prototype,"blurX",{get:function(){return this.blurXFilter.blur},set:function(a){this.blurXFilter.blur=a}}),Object.defineProperty(d.BlurFilter.prototype,"blurY",{get:function(){return this.blurYFilter.blur},set:function(a){this.blurYFilter.blur=a}}),d.BlurXFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {","vec4 sum = vec4(0.0);","sum += texture2D(uSampler, vec2(vTextureCoord.x - 4.0*blur, vTextureCoord.y)) * 0.05;","sum += texture2D(uSampler, vec2(vTextureCoord.x - 3.0*blur, vTextureCoord.y)) * 0.09;","sum += texture2D(uSampler, vec2(vTextureCoord.x - 2.0*blur, vTextureCoord.y)) * 0.12;","sum += texture2D(uSampler, vec2(vTextureCoord.x - blur, vTextureCoord.y)) * 0.15;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;","sum += texture2D(uSampler, vec2(vTextureCoord.x + blur, vTextureCoord.y)) * 0.15;","sum += texture2D(uSampler, vec2(vTextureCoord.x + 2.0*blur, vTextureCoord.y)) * 0.12;","sum += texture2D(uSampler, vec2(vTextureCoord.x + 3.0*blur, vTextureCoord.y)) * 0.09;","sum += texture2D(uSampler, vec2(vTextureCoord.x + 4.0*blur, vTextureCoord.y)) * 0.05;","gl_FragColor = sum;","}"]},d.BlurXFilter.prototype=Object.create(d.AbstractFilter.prototype),d.BlurXFilter.prototype.constructor=d.BlurXFilter,Object.defineProperty(d.BlurXFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.dirty=!0,this.uniforms.blur.value=1/7e3*a}}),d.BlurYFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {","vec4 sum = vec4(0.0);","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 4.0*blur)) * 0.05;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 3.0*blur)) * 0.09;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 2.0*blur)) * 0.12;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - blur)) * 0.15;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + blur)) * 0.15;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 2.0*blur)) * 0.12;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 3.0*blur)) * 0.09;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 4.0*blur)) * 0.05;","gl_FragColor = sum;","}"]},d.BlurYFilter.prototype=Object.create(d.AbstractFilter.prototype),d.BlurYFilter.prototype.constructor=d.BlurYFilter,Object.defineProperty(d.BlurYFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.uniforms.blur.value=1/7e3*a}}),d.ColorMatrixFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={matrix:{type:"mat4",value:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float invert;","uniform mat4 matrix;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vTextureCoord) * matrix;","gl_FragColor = gl_FragColor * vColor;","}"]},d.ColorMatrixFilter.prototype=Object.create(d.AbstractFilter.prototype),d.ColorMatrixFilter.prototype.constructor=d.ColorMatrixFilter,Object.defineProperty(d.ColorMatrixFilter.prototype,"matrix",{get:function(){return this.uniforms.matrix.value},set:function(a){this.uniforms.matrix.value=a}}),d.CrossHatchFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {"," float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb);"," "," gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);"," "," if (lum < 1.00) {"," if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," "," if (lum < 0.75) {"," if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," "," if (lum < 0.50) {"," if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," "," if (lum < 0.3) {"," if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }","}"]},d.CrossHatchFilter.prototype=Object.create(d.AbstractFilter.prototype),d.CrossHatchFilter.prototype.constructor=d.BlurYFilter,Object.defineProperty(d.CrossHatchFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.uniforms.blur.value=1/7e3*a}}),d.DisplacementFilter=function(a){d.AbstractFilter.call(this),this.passes=[this],a.baseTexture._powerOf2=!0,this.uniforms={displacementMap:{type:"sampler2D",value:a},scale:{type:"f2",value:{x:30,y:30}},offset:{type:"f2",value:{x:0,y:0}},mapDimensions:{type:"f2",value:{x:1,y:5112}},dimensions:{type:"f4",value:[0,0,0,0]}},a.baseTexture.hasLoaded?(this.uniforms.mapDimensions.value.x=a.width,this.uniforms.mapDimensions.value.y=a.height):(this.boundLoadedFunction=this.onTextureLoaded.bind(this),a.baseTexture.on("loaded",this.boundLoadedFunction)),this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D displacementMap;","uniform sampler2D uSampler;","uniform vec2 scale;","uniform vec2 offset;","uniform vec4 dimensions;","uniform vec2 mapDimensions;","void main(void) {","vec2 mapCords = vTextureCoord.xy;","mapCords += (dimensions.zw + offset)/ dimensions.xy ;","mapCords.y *= -1.0;","mapCords.y += 1.0;","vec2 matSample = texture2D(displacementMap, mapCords).xy;","matSample -= 0.5;","matSample *= scale;","matSample /= mapDimensions;","gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x + matSample.x, vTextureCoord.y + matSample.y));","gl_FragColor.rgb = mix( gl_FragColor.rgb, gl_FragColor.rgb, 1.0);","vec2 cord = vTextureCoord;","gl_FragColor = gl_FragColor * vColor;","}"]},d.DisplacementFilter.prototype=Object.create(d.AbstractFilter.prototype),d.DisplacementFilter.prototype.constructor=d.DisplacementFilter,d.DisplacementFilter.prototype.onTextureLoaded=function(){this.uniforms.mapDimensions.value.x=this.uniforms.displacementMap.value.width,this.uniforms.mapDimensions.value.y=this.uniforms.displacementMap.value.height,this.uniforms.displacementMap.value.baseTexture.off("loaded",this.boundLoadedFunction)},Object.defineProperty(d.DisplacementFilter.prototype,"map",{get:function(){return this.uniforms.displacementMap.value},set:function(a){this.uniforms.displacementMap.value=a}}),Object.defineProperty(d.DisplacementFilter.prototype,"scale",{get:function(){return this.uniforms.scale.value},set:function(a){this.uniforms.scale.value=a}}),Object.defineProperty(d.DisplacementFilter.prototype,"offset",{get:function(){return this.uniforms.offset.value},set:function(a){this.uniforms.offset.value=a}}),d.DotScreenFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={scale:{type:"f",value:1},angle:{type:"f",value:5},dimensions:{type:"f4",value:[0,0,0,0]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform vec4 dimensions;","uniform sampler2D uSampler;","uniform float angle;","uniform float scale;","float pattern() {","float s = sin(angle), c = cos(angle);","vec2 tex = vTextureCoord * dimensions.xy;","vec2 point = vec2(","c * tex.x - s * tex.y,","s * tex.x + c * tex.y",") * scale;","return (sin(point.x) * sin(point.y)) * 4.0;","}","void main() {","vec4 color = texture2D(uSampler, vTextureCoord);","float average = (color.r + color.g + color.b) / 3.0;","gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a);","}"]},d.DotScreenFilter.prototype=Object.create(d.DotScreenFilter.prototype),d.DotScreenFilter.prototype.constructor=d.DotScreenFilter,Object.defineProperty(d.DotScreenFilter.prototype,"scale",{get:function(){return this.uniforms.scale.value},set:function(a){this.dirty=!0,this.uniforms.scale.value=a}}),Object.defineProperty(d.DotScreenFilter.prototype,"angle",{get:function(){return this.uniforms.angle.value},set:function(a){this.dirty=!0,this.uniforms.angle.value=a}}),d.FilterBlock=function(){this.visible=!0,this.renderable=!0},d.GreyFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={grey:{type:"f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","uniform float grey;","void main(void) {","gl_FragColor = texture2D(uSampler, vTextureCoord);","gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2126*gl_FragColor.r + 0.7152*gl_FragColor.g + 0.0722*gl_FragColor.b), grey);","gl_FragColor = gl_FragColor * vColor;","}"]},d.GreyFilter.prototype=Object.create(d.AbstractFilter.prototype),d.GreyFilter.prototype.constructor=d.GreyFilter,Object.defineProperty(d.GreyFilter.prototype,"grey",{get:function(){return this.uniforms.grey.value},set:function(a){this.uniforms.grey.value=a}}),d.InvertFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={invert:{type:"f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float invert;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vTextureCoord);","gl_FragColor.rgb = mix( (vec3(1)-gl_FragColor.rgb) * gl_FragColor.a, gl_FragColor.rgb, 1.0 - invert);","gl_FragColor = gl_FragColor * vColor;","}"]},d.InvertFilter.prototype=Object.create(d.AbstractFilter.prototype),d.InvertFilter.prototype.constructor=d.InvertFilter,Object.defineProperty(d.InvertFilter.prototype,"invert",{get:function(){return this.uniforms.invert.value},set:function(a){this.uniforms.invert.value=a}}),d.PixelateFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={invert:{type:"f",value:0},dimensions:{type:"f4",value:new Float32Array([1e4,100,10,10])},pixelSize:{type:"f2",value:{x:10,y:10}}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform vec2 testDim;","uniform vec4 dimensions;","uniform vec2 pixelSize;","uniform sampler2D uSampler;","void main(void) {","vec2 coord = vTextureCoord;","vec2 size = dimensions.xy/pixelSize;","vec2 color = floor( ( vTextureCoord * size ) ) / size + pixelSize/dimensions.xy * 0.5;","gl_FragColor = texture2D(uSampler, color);","}"]},d.PixelateFilter.prototype=Object.create(d.AbstractFilter.prototype),d.PixelateFilter.prototype.constructor=d.PixelateFilter,Object.defineProperty(d.PixelateFilter.prototype,"size",{get:function(){return this.uniforms.pixelSize.value},set:function(a){this.dirty=!0,this.uniforms.pixelSize.value=a}}),d.RGBSplitFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={red:{type:"f2",value:{x:20,y:20}},green:{type:"f2",value:{x:-20,y:20}},blue:{type:"f2",value:{x:20,y:-20}},dimensions:{type:"f4",value:[0,0,0,0]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform vec2 red;","uniform vec2 green;","uniform vec2 blue;","uniform vec4 dimensions;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/dimensions.xy).r;","gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/dimensions.xy).g;","gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/dimensions.xy).b;","gl_FragColor.a = texture2D(uSampler, vTextureCoord).a;","}"]},d.RGBSplitFilter.prototype=Object.create(d.AbstractFilter.prototype),d.RGBSplitFilter.prototype.constructor=d.RGBSplitFilter,Object.defineProperty(d.RGBSplitFilter.prototype,"angle",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.uniforms.blur.value=1/7e3*a}}),d.SepiaFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={sepia:{type:"f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float sepia;","uniform sampler2D uSampler;","const mat3 sepiaMatrix = mat3(0.3588, 0.7044, 0.1368, 0.2990, 0.5870, 0.1140, 0.2392, 0.4696, 0.0912);","void main(void) {","gl_FragColor = texture2D(uSampler, vTextureCoord);","gl_FragColor.rgb = mix( gl_FragColor.rgb, gl_FragColor.rgb * sepiaMatrix, sepia);","gl_FragColor = gl_FragColor * vColor;","}"]},d.SepiaFilter.prototype=Object.create(d.AbstractFilter.prototype),d.SepiaFilter.prototype.constructor=d.SepiaFilter,Object.defineProperty(d.SepiaFilter.prototype,"sepia",{get:function(){return this.uniforms.sepia.value},set:function(a){this.uniforms.sepia.value=a}}),d.SmartBlurFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","uniform sampler2D uSampler;","const vec2 delta = vec2(1.0/10.0, 0.0);","float random(vec3 scale, float seed) {","return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);","}","void main(void) {","vec4 color = vec4(0.0);","float total = 0.0;","float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);","for (float t = -30.0; t <= 30.0; t++) {","float percent = (t + offset - 0.5) / 30.0;","float weight = 1.0 - abs(percent);","vec4 sample = texture2D(uSampler, vTextureCoord + delta * percent);","sample.rgb *= sample.a;","color += sample * weight;","total += weight;","}","gl_FragColor = color / total;","gl_FragColor.rgb /= gl_FragColor.a + 0.00001;","}"] },d.SmartBlurFilter.prototype=Object.create(d.AbstractFilter.prototype),d.SmartBlurFilter.prototype.constructor=d.SmartBlurFilter,Object.defineProperty(d.SmartBlurFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value},set:function(a){this.uniforms.blur.value=a}}),d.TwistFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={radius:{type:"f",value:.5},angle:{type:"f",value:5},offset:{type:"f2",value:{x:.5,y:.5}}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform vec4 dimensions;","uniform sampler2D uSampler;","uniform float radius;","uniform float angle;","uniform vec2 offset;","void main(void) {","vec2 coord = vTextureCoord - offset;","float distance = length(coord);","if (distance < radius){","float ratio = (radius - distance) / radius;","float angleMod = ratio * ratio * angle;","float s = sin(angleMod);","float c = cos(angleMod);","coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c);","}","gl_FragColor = texture2D(uSampler, coord+offset);","}"]},d.TwistFilter.prototype=Object.create(d.AbstractFilter.prototype),d.TwistFilter.prototype.constructor=d.TwistFilter,Object.defineProperty(d.TwistFilter.prototype,"offset",{get:function(){return this.uniforms.offset.value},set:function(a){this.dirty=!0,this.uniforms.offset.value=a}}),Object.defineProperty(d.TwistFilter.prototype,"radius",{get:function(){return this.uniforms.radius.value},set:function(a){this.dirty=!0,this.uniforms.radius.value=a}}),Object.defineProperty(d.TwistFilter.prototype,"angle",{get:function(){return this.uniforms.angle.value},set:function(a){this.dirty=!0,this.uniforms.angle.value=a}}),d.Graphics=function(){d.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor="black",this.graphicsData=[],this.currentPath={points:[]}},d.Graphics.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Graphics.prototype.constructor=d.Graphics,d.Graphics.prototype.lineStyle=function(a,b,c){0==this.currentPath.points.length&&this.graphicsData.pop(),this.lineWidth=a||0,this.lineColor=b||0,this.lineAlpha=void 0==c?1:c,this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:d.Graphics.POLY},this.graphicsData.push(this.currentPath)},d.Graphics.prototype.moveTo=function(a,b){0==this.currentPath.points.length&&this.graphicsData.pop(),this.currentPath=this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:d.Graphics.POLY},this.currentPath.points.push(a,b),this.graphicsData.push(this.currentPath)},d.Graphics.prototype.lineTo=function(a,b){this.currentPath.points.push(a,b),this.dirty=!0},d.Graphics.prototype.beginFill=function(a,b){this.filling=!0,this.fillColor=a||0,this.fillAlpha=void 0==b?1:b},d.Graphics.prototype.endFill=function(){this.filling=!1,this.fillColor=null,this.fillAlpha=1},d.Graphics.prototype.drawRect=function(a,b,c,e){0==this.currentPath.points.length&&this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[a,b,c,e],type:d.Graphics.RECT},this.graphicsData.push(this.currentPath),this.dirty=!0},d.Graphics.prototype.drawCircle=function(a,b,c){0==this.currentPath.points.length&&this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[a,b,c,c],type:d.Graphics.CIRC},this.graphicsData.push(this.currentPath),this.dirty=!0},d.Graphics.prototype.drawElipse=function(a,b,c,e){0==this.currentPath.points.length&&this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[a,b,c,e],type:d.Graphics.ELIP},this.graphicsData.push(this.currentPath),this.dirty=!0},d.Graphics.prototype.clear=function(){this.lineWidth=0,this.filling=!1,this.dirty=!0,this.clearDirty=!0,this.graphicsData=[],this.bounds=null},d.Graphics.prototype.updateFilterBounds=function(){if(!this.bounds){for(var a,b,c,e=1/0,f=-1/0,g=1/0,h=-1/0,i=0;ib?b:e,f=b+m>f?b+m:f,g=g>c?b:g,h=c+n>h?c+n:h}else if(k===d.Graphics.CIRC||k===d.Graphics.ELIP){b=a.x,c=a.y;var o=a.radius+l/2;e=e>b-o?b-o:e,f=b+o>f?b+o:f,g=g>c-o?c-o:g,h=c+o>h?c+o:h}else for(var p=0;pb-l?b-l:e,f=b+l>f?b+l:f,g=g>c-l?c-l:g,h=c+l>h?c+l:h}this.bounds=new d.Rectangle(e,g,f-e,h-g)}},d.Graphics.POLY=0,d.Graphics.RECT=1,d.Graphics.CIRC=2,d.Graphics.ELIP=3,d.CanvasGraphics=function(){},d.CanvasGraphics.renderGraphics=function(a,b){for(var c=a.worldAlpha,e=0;e1&&(c=1,console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object"));for(var e=0;1>e;e++){var f=a.graphicsData[e],g=f.points;if(f.type==d.Graphics.POLY){b.beginPath(),b.moveTo(g[0],g[1]);for(var h=1;h0&&(d.Texture.frameUpdates=[])},d.CanvasRenderer.prototype.resize=function(a,b){this.width=a,this.height=b,this.view.width=a,this.view.height=b},d.CanvasRenderer.prototype.renderDisplayObject=function(a){var b,c=this.context;c.globalCompositeOperation="source-over";var e=a.last._iNext;a=a.first;do if(b=a.worldTransform,a.visible)if(a.renderable){if(a instanceof d.Sprite){var f=a.texture.frame;f&&f.width&&f.height&&(c.globalAlpha=a.worldAlpha,c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),c.drawImage(a.texture.baseTexture.source,f.x,f.y,f.width,f.height,a.anchor.x*-f.width,a.anchor.y*-f.height,f.width,f.height))}else if(a instanceof d.Strip)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),this.renderStrip(a);else if(a instanceof d.TilingSprite)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),this.renderTilingSprite(a);else if(a instanceof d.CustomRenderable)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),a.renderCanvas(this);else if(a instanceof d.Graphics)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),d.CanvasGraphics.renderGraphics(a,c);else if(a instanceof d.FilterBlock&&a.data instanceof d.Graphics){var g=a.data;if(a.open){c.save();var h=g.alpha,i=g.worldTransform;c.setTransform(i[0],i[3],i[1],i[4],i[2],i[5]),g.worldAlpha=.5,c.worldAlpha=0,d.CanvasGraphics.renderGraphicsMask(g,c),c.clip(),g.worldAlpha=h}else c.restore()}a=a._iNext}else a=a._iNext;else a=a.last._iNext;while(a!=e)},d.CanvasRenderer.prototype.renderStripFlat=function(a){var b=this.context,c=a.verticies;a.uvs;var d=c.length/2;this.count++,b.beginPath();for(var e=1;d-2>e;e++){var f=2*e,g=c[f],h=c[f+2],i=c[f+4],j=c[f+1],k=c[f+3],l=c[f+5];b.moveTo(g,j),b.lineTo(h,k),b.lineTo(i,l)}b.fillStyle="#FF0000",b.fill(),b.closePath()},d.CanvasRenderer.prototype.renderTilingSprite=function(a){var b=this.context;b.globalAlpha=a.worldAlpha,a.__tilePattern||(a.__tilePattern=b.createPattern(a.texture.baseTexture.source,"repeat")),b.beginPath();var c=a.tilePosition,d=a.tileScale;b.scale(d.x,d.y),b.translate(c.x,c.y),b.fillStyle=a.__tilePattern,b.fillRect(-c.x,-c.y,a.width/d.x,a.height/d.y),b.scale(1/d.x,1/d.y),b.translate(-c.x,-c.y),b.closePath()},d.CanvasRenderer.prototype.renderStrip=function(a){var b=this.context,c=a.verticies,d=a.uvs,e=c.length/2;this.count++;for(var f=1;e-2>f;f++){var g=2*f,h=c[g],i=c[g+2],j=c[g+4],k=c[g+1],l=c[g+3],m=c[g+5],n=d[g]*a.texture.width,o=d[g+2]*a.texture.width,p=d[g+4]*a.texture.width,q=d[g+1]*a.texture.height,r=d[g+3]*a.texture.height,s=d[g+5]*a.texture.height;b.save(),b.beginPath(),b.moveTo(h,k),b.lineTo(i,l),b.lineTo(j,m),b.closePath(),b.clip();var t=n*r+q*p+o*s-r*p-q*o-n*s,u=h*r+q*j+i*s-r*j-q*i-h*s,v=n*i+h*p+o*j-i*p-h*o-n*j,w=n*r*j+q*i*p+h*o*s-h*r*p-q*o*j-n*i*s,x=k*r+q*m+l*s-r*m-q*l-k*s,y=n*l+k*p+o*m-l*p-k*o-n*m,z=n*r*m+q*l*p+k*o*s-k*r*p-q*o*m-n*l*s;b.transform(u/t,x/t,v/t,y/t,w/t,z/t),b.drawImage(a.texture.baseTexture.source,0,0),b.restore()}},d.PixiShader=function(){this.program,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;","}"]},d.PixiShader.prototype.init=function(){var a=d.compileProgram(this.vertexSrc||d.PixiShader.defaultVertexSrc,this.fragmentSrc),b=d.gl;b.useProgram(a),this.uSampler=b.getUniformLocation(a,"uSampler"),this.projectionVector=b.getUniformLocation(a,"projectionVector"),this.offsetVector=b.getUniformLocation(a,"offsetVector"),this.aVertexPosition=b.getAttribLocation(a,"aVertexPosition"),this.colorAttribute=b.getAttribLocation(a,"aColor"),this.aTextureCoord=b.getAttribLocation(a,"aTextureCoord");for(var c in this.uniforms)this.uniforms[c].uniformLocation=b.getUniformLocation(a,c);this.program=a},d.PixiShader.prototype.syncUniforms=function(){var a=d.gl;for(var b in this.uniforms){var c=this.uniforms[b].type;if("f"==c&&a.uniform1f(this.uniforms[b].uniformLocation,this.uniforms[b].value),"f2"==c)a.uniform2f(this.uniforms[b].uniformLocation,this.uniforms[b].value.x,this.uniforms[b].value.y);else if("f4"==c)a.uniform4fv(this.uniforms[b].uniformLocation,this.uniforms[b].value);else if("mat4"==c)a.uniformMatrix4fv(this.uniforms[b].uniformLocation,!1,this.uniforms[b].value);else if("sampler2D"==c){var e=this.uniforms[b].value;a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,e.baseTexture._glTexture),a.uniform1i(this.uniforms[b].uniformLocation,1)}}},d.PixiShader.defaultVertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying float vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {","gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);","vTextureCoord = aTextureCoord;","vColor = aColor;","}"],d.PrimitiveShader=function(){this.program,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {","gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform float alpha;","varying vec4 vColor;","void main(void) {","vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);","v -= offsetVector.xyx;","gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);","vColor = aColor * alpha;","}"]},d.PrimitiveShader.prototype.init=function(){var a=d.compileProgram(this.vertexSrc,this.fragmentSrc),b=d.gl;b.useProgram(a),this.projectionVector=b.getUniformLocation(a,"projectionVector"),this.offsetVector=b.getUniformLocation(a,"offsetVector"),this.aVertexPosition=b.getAttribLocation(a,"aVertexPosition"),this.colorAttribute=b.getAttribLocation(a,"aColor"),this.translationMatrix=b.getUniformLocation(a,"translationMatrix"),this.alpha=b.getUniformLocation(a,"alpha"),this.program=a},d.StripShader=function(){this.program,this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));","gl_FragColor = gl_FragColor * alpha;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","varying vec2 vTextureCoord;","varying vec2 offsetVector;","varying float vColor;","void main(void) {","vec3 v = translationMatrix * vec3(aVertexPosition, 1.0);","v -= offsetVector.xyx;","gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / projectionVector.y + 1.0 , 0.0, 1.0);","vTextureCoord = aTextureCoord;","vColor = aColor;","}"]},d.StripShader.prototype.init=function(){var a=d.compileProgram(this.vertexSrc,this.fragmentSrc),b=d.gl;b.useProgram(a),this.uSampler=b.getUniformLocation(a,"uSampler"),this.projectionVector=b.getUniformLocation(a,"projectionVector"),this.offsetVector=b.getUniformLocation(a,"offsetVector"),this.colorAttribute=b.getAttribLocation(a,"aColor"),this.aVertexPosition=b.getAttribLocation(a,"aVertexPosition"),this.aTextureCoord=b.getAttribLocation(a,"aTextureCoord"),this.translationMatrix=b.getUniformLocation(a,"translationMatrix"),this.alpha=b.getUniformLocation(a,"alpha"),this.program=a},d._batchs=[],d._getBatch=function(a){return 0==d._batchs.length?new d.WebGLBatch(a):d._batchs.pop()},d._returnBatch=function(a){a.clean(),d._batchs.push(a)},d._restoreBatchs=function(a){for(var b=0;bc;c++){var d=6*c,e=4*c;this.indices[d+0]=e+0,this.indices[d+1]=e+1,this.indices[d+2]=e+2,this.indices[d+3]=e+0,this.indices[d+4]=e+2,this.indices[d+5]=e+3}a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this.indices,a.STATIC_DRAW)},d.WebGLBatch.prototype.refresh=function(){this.gl,this.dynamicSizethis.width&&(f.width=this.width),f.y<0&&(f.y=0),f.height>this.height&&(f.height=this.height),b.bindFramebuffer(b.FRAMEBUFFER,e.frameBuffer),b.viewport(0,0,f.width,f.height),d.projection.x=f.width/2,d.projection.y=-f.height/2,d.offset.x=-f.x,d.offset.y=-f.y,b.uniform2f(d.defaultShader.projectionVector,f.width/2,-f.height/2),b.uniform2f(d.defaultShader.offsetVector,-f.x,-f.y),b.colorMask(!0,!0,!0,!0),b.clearColor(0,0,0,0),b.clear(b.COLOR_BUFFER_BIT),a._glFilterTexture=e},d.WebGLFilterManager.prototype.popFilter=function(){var a=d.gl,b=this.filterStack.pop(),c=b.target.filterArea,e=b._glFilterTexture;if(b.filterPasses.length>1){a.viewport(0,0,c.width,c.height),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=0,this.vertexArray[1]=c.height,this.vertexArray[2]=c.width,this.vertexArray[3]=c.height,this.vertexArray[4]=0,this.vertexArray[5]=0,this.vertexArray[6]=c.width,this.vertexArray[7]=0,a.bufferSubData(a.ARRAY_BUFFER,0,this.vertexArray),a.bindBuffer(a.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=c.width/this.width,this.uvArray[5]=c.height/this.height,this.uvArray[6]=c.width/this.width,this.uvArray[7]=c.height/this.height,a.bufferSubData(a.ARRAY_BUFFER,0,this.uvArray);var f=e,g=this.texturePool.pop();g||(g=new d.FilterTexture(this.width,this.height)),a.bindFramebuffer(a.FRAMEBUFFER,g.frameBuffer),a.clear(a.COLOR_BUFFER_BIT),a.disable(a.BLEND);for(var h=0;hs?s:E,E=E>t?t:E,E=E>u?u:E,E=E>v?v:E,F=F>w?w:F,F=F>x?x:F,F=F>y?y:F,F=F>z?z:F,C=s>C?s:C,C=t>C?t:C,C=u>C?u:C,C=v>C?v:C,D=w>D?w:D,D=x>D?x:D,D=y>D?y:D,D=z>D?z:D),l=!1,A=A._iNext}while(A!=B);a.filterArea.x=E,a.filterArea.y=F,a.filterArea.width=C-E,a.filterArea.height=D-F},d.FilterTexture=function(a,b){var c=d.gl;this.frameBuffer=c.createFramebuffer(),this.texture=c.createTexture(),c.bindTexture(c.TEXTURE_2D,this.texture),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.bindFramebuffer(c.FRAMEBUFFER,this.framebuffer),c.bindFramebuffer(c.FRAMEBUFFER,this.frameBuffer),c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,this.texture,0),this.resize(a,b)},d.FilterTexture.prototype.resize=function(a,b){this.width=a,this.height=b;var c=d.gl;c.bindTexture(c.TEXTURE_2D,this.texture),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,a,b,0,c.RGBA,c.UNSIGNED_BYTE,null)},d.WebGLGraphics=function(){},d.WebGLGraphics.renderGraphics=function(a,b){var c=d.gl;a._webGL||(a._webGL={points:[],indices:[],lastIndex:0,buffer:c.createBuffer(),indexBuffer:c.createBuffer()}),a.dirty&&(a.dirty=!1,a.clearDirty&&(a.clearDirty=!1,a._webGL.lastIndex=0,a._webGL.points=[],a._webGL.indices=[]),d.WebGLGraphics.updateGraphics(a)),d.activatePrimitiveShader();var e=d.mat3.clone(a.worldTransform);d.mat3.transpose(e),c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA),c.uniformMatrix3fv(d.primitiveShader.translationMatrix,!1,e),c.uniform2f(d.primitiveShader.projectionVector,b.x,-b.y),c.uniform2f(d.primitiveShader.offsetVector,-d.offset.x,-d.offset.y),c.uniform1f(d.primitiveShader.alpha,a.worldAlpha),c.bindBuffer(c.ARRAY_BUFFER,a._webGL.buffer),c.vertexAttribPointer(d.primitiveShader.aVertexPosition,2,c.FLOAT,!1,24,0),c.vertexAttribPointer(d.primitiveShader.colorAttribute,4,c.FLOAT,!1,24,8),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,a._webGL.indexBuffer),c.drawElements(c.TRIANGLE_STRIP,a._webGL.indices.length,c.UNSIGNED_SHORT,0),d.deactivatePrimitiveShader()},d.WebGLGraphics.updateGraphics=function(a){for(var b=a._webGL.lastIndex;b3&&d.WebGLGraphics.buildPoly(c,a._webGL),c.lineWidth>0&&d.WebGLGraphics.buildLine(c,a._webGL)):c.type==d.Graphics.RECT?d.WebGLGraphics.buildRectangle(c,a._webGL):(c.type==d.Graphics.CIRC||c.type==d.Graphics.ELIP)&&d.WebGLGraphics.buildCircle(c,a._webGL)}a._webGL.lastIndex=a.graphicsData.length;var e=d.gl;a._webGL.glPoints=new Float32Array(a._webGL.points),e.bindBuffer(e.ARRAY_BUFFER,a._webGL.buffer),e.bufferData(e.ARRAY_BUFFER,a._webGL.glPoints,e.STATIC_DRAW),a._webGL.glIndicies=new Uint16Array(a._webGL.indices),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a._webGL.indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,a._webGL.glIndicies,e.STATIC_DRAW)},d.WebGLGraphics.buildRectangle=function(a,c){var e=a.points,f=e[0],g=e[1],h=e[2],i=e[3];if(a.fill){var j=b(a.fillColor),k=a.fillAlpha,l=j[0]*k,m=j[1]*k,n=j[2]*k,o=c.points,p=c.indices,q=o.length/6;o.push(f,g),o.push(l,m,n,k),o.push(f+h,g),o.push(l,m,n,k),o.push(f,g+i),o.push(l,m,n,k),o.push(f+h,g+i),o.push(l,m,n,k),p.push(q,q,q+1,q+2,q+3,q+3)}a.lineWidth&&(a.points=[f,g,f+h,g,f+h,g+i,f,g+i,f,g],d.WebGLGraphics.buildLine(a,c))},d.WebGLGraphics.buildCircle=function(a,c){var e=a.points,f=e[0],g=e[1],h=e[2],i=e[3],j=40,k=2*Math.PI/j;if(a.fill){var l=b(a.fillColor),m=a.fillAlpha,n=l[0]*m,o=l[1]*m,p=l[2]*m,q=c.points,r=c.indices,s=q.length/6;r.push(s);for(var t=0;j+1>t;t++)q.push(f,g,n,o,p,m),q.push(f+Math.sin(k*t)*h,g+Math.cos(k*t)*i,n,o,p,m),r.push(s++,s++);r.push(s-1)}if(a.lineWidth){a.points=[];for(var t=0;j+1>t;t++)a.points.push(f+Math.sin(k*t)*h,g+Math.cos(k*t)*i);d.WebGLGraphics.buildLine(a,c)}},d.WebGLGraphics.buildLine=function(a,c){var e=a.points;if(0!=e.length){if(a.lineWidth%2)for(var f=0;ff;f++)k=e[2*(f-1)],l=e[2*(f-1)+1],m=e[2*f],n=e[2*f+1],o=e[2*(f+1)],p=e[2*(f+1)+1],q=-(l-n),r=k-m,E=Math.sqrt(q*q+r*r),q/=E,r/=E,q*=K,r*=K,s=-(n-p),t=m-o,E=Math.sqrt(s*s+t*t),s/=E,t/=E,s*=K,t*=K,w=-r+l-(-r+n),x=-q+m-(-q+k),y=(-q+k)*(-r+n)-(-q+m)*(-r+l),z=-t+p-(-t+n),A=-s+m-(-s+o),B=(-s+o)*(-t+n)-(-s+m)*(-t+p),C=w*A-z*x,Math.abs(C)<.1?(C+=10.1,F.push(m-q,n-r,N,O,P,M),F.push(m+q,n+r,N,O,P,M)):(px=(x*B-A*y)/C,py=(z*y-w*B)/C,D=(px-m)*(px-m)+(py-n)+(py-n),D>19600?(u=q-s,v=r-t,E=Math.sqrt(u*u+v*v),u/=E,v/=E,u*=K,v*=K,F.push(m-u,n-v),F.push(N,O,P,M),F.push(m+u,n+v),F.push(N,O,P,M),F.push(m-u,n-v),F.push(N,O,P,M),I++):(F.push(px,py),F.push(N,O,P,M),F.push(m-(px-m),n-(py-n)),F.push(N,O,P,M))); -k=e[2*(H-2)],l=e[2*(H-2)+1],m=e[2*(H-1)],n=e[2*(H-1)+1],q=-(l-n),r=k-m,E=Math.sqrt(q*q+r*r),q/=E,r/=E,q*=K,r*=K,F.push(m-q,n-r),F.push(N,O,P,M),F.push(m+q,n+r),F.push(N,O,P,M),G.push(J);for(var f=0;I>f;f++)G.push(J++);G.push(J-1)}},d.WebGLGraphics.buildPoly=function(a,c){var e=a.points;if(!(e.length<6)){for(var f=c.points,g=c.indices,h=e.length/2,i=b(a.fillColor),j=a.fillAlpha,k=i[0]*j,l=i[1]*j,m=i[2]*j,n=d.PolyK.Triangulate(e),o=f.length/6,p=0;pp;p++)f.push(e[2*p],e[2*p+1],k,l,m,j)}},d._defaultFrame=new d.Rectangle(0,0,1,1),d.gl,d.WebGLRenderer=function(a,b,c,e,f){this.transparent=!!e,this.width=a||800,this.height=b||600,this.view=c||document.createElement("canvas"),this.view.width=this.width,this.view.height=this.height;var g=this;this.view.addEventListener("webglcontextlost",function(a){g.handleContextLost(a)},!1),this.view.addEventListener("webglcontextrestored",function(a){g.handleContextRestored(a)},!1),this.batchs=[];var h={alpha:this.transparent,antialias:!!f,premultipliedAlpha:!1,stencil:!0};try{d.gl=this.gl=this.view.getContext("experimental-webgl",h)}catch(i){try{d.gl=this.gl=this.view.getContext("webgl",h)}catch(i){throw new Error(" This browser does not support webGL. Try using the canvas renderer"+this)}}d.initDefaultShaders();var j=this.gl;j.useProgram(d.defaultShader.program),d.WebGLRenderer.gl=j,this.batch=new d.WebGLBatch(j),j.disable(j.DEPTH_TEST),j.disable(j.CULL_FACE),j.enable(j.BLEND),j.colorMask(!0,!0,!0,this.transparent),d.projection=new d.Point(400,300),d.offset=new d.Point(0,0),this.resize(this.width,this.height),this.contextLost=!1,this.stageRenderGroup=new d.WebGLRenderGroup(this.gl,this.transparent)},d.WebGLRenderer.prototype.constructor=d.WebGLRenderer,d.WebGLRenderer.getBatch=function(){return 0==d._batchs.length?new d.WebGLBatch(d.WebGLRenderer.gl):d._batchs.pop()},d.WebGLRenderer.returnBatch=function(a){a.clean(),d._batchs.push(a)},d.WebGLRenderer.prototype.render=function(a){if(!this.contextLost){this.__stage!==a&&(this.__stage=a,this.stageRenderGroup.setRenderable(a)),d.WebGLRenderer.updateTextures(),d.visibleCount++,a.updateTransform();var b=this.gl;if(b.colorMask(!0,!0,!0,this.transparent),b.viewport(0,0,this.width,this.height),b.bindFramebuffer(b.FRAMEBUFFER,null),b.clearColor(a.backgroundColorSplit[0],a.backgroundColorSplit[1],a.backgroundColorSplit[2],!this.transparent),b.clear(b.COLOR_BUFFER_BIT),this.stageRenderGroup.backgroundColor=a.backgroundColorSplit,d.projection.x=this.width/2,d.projection.y=-this.height/2,this.stageRenderGroup.render(d.projection),a.interactive&&(a._interactiveEventsAdded||(a._interactiveEventsAdded=!0,a.interactionManager.setTarget(this))),d.Texture.frameUpdates.length>0){for(var c=0;cn;n++)renderable=this.batchs[n],renderable instanceof d.WebGLBatch?this.batchs[n].render():this.renderSpecial(renderable,b);endBatch instanceof d.WebGLBatch?endBatch.render(0,h+1):this.renderSpecial(endBatch,b)},d.WebGLRenderGroup.prototype.renderSpecial=function(a,b){var c=a.vcount===d.visibleCount;a instanceof d.TilingSprite?c&&this.renderTilingSprite(a,b):a instanceof d.Strip?c&&this.renderStrip(a,b):a instanceof d.CustomRenderable?c&&a.renderWebGL(this,b):a instanceof d.Graphics?c&&a.renderable&&d.WebGLGraphics.renderGraphics(a,b):a instanceof d.FilterBlock&&this.handleFilterBlock(a,b)},flip=!1;var f=[],g=0;return d.WebGLRenderGroup.prototype.handleFilterBlock=function(a,b){var c=d.gl;if(a.open)a.data instanceof Array?this.filterManager.pushFilter(a):(g++,f.push(a),c.enable(c.STENCIL_TEST),c.colorMask(!1,!1,!1,!1),c.stencilFunc(c.ALWAYS,1,1),c.stencilOp(c.KEEP,c.KEEP,c.INCR),d.WebGLGraphics.renderGraphics(a.data,b),c.colorMask(!0,!0,!0,!0),c.stencilFunc(c.NOTEQUAL,0,f.length),c.stencilOp(c.KEEP,c.KEEP,c.KEEP));else if(a.data instanceof Array)this.filterManager.popFilter();else{var e=f.pop(a);e&&(c.colorMask(!1,!1,!1,!1),c.stencilFunc(c.ALWAYS,1,1),c.stencilOp(c.KEEP,c.KEEP,c.DECR),d.WebGLGraphics.renderGraphics(e.data,b),c.colorMask(!0,!0,!0,!0),c.stencilFunc(c.NOTEQUAL,0,f.length),c.stencilOp(c.KEEP,c.KEEP,c.KEEP)),c.disable(c.STENCIL_TEST)}},d.WebGLRenderGroup.prototype.updateTexture=function(a){this.removeObject(a);for(var b=a.first;b!=this.root&&(b=b._iPrev,!b.renderable||!b.__renderGroup););for(var c=a.last;c._iNext&&(c=c._iNext,!c.renderable||!c.__renderGroup););this.insertObject(a,b,c)},d.WebGLRenderGroup.prototype.addFilterBlocks=function(a,b){a.__renderGroup=this,b.__renderGroup=this;for(var c=a;c!=this.root.first&&(c=c._iPrev,!c.renderable||!c.__renderGroup););this.insertAfter(a,c);for(var d=b;d!=this.root.first&&(d=d._iPrev,!d.renderable||!d.__renderGroup););this.insertAfter(b,d)},d.WebGLRenderGroup.prototype.removeFilterBlocks=function(a,b){this.removeObject(a),this.removeObject(b)},d.WebGLRenderGroup.prototype.addDisplayObjectAndChildren=function(a){a.__renderGroup&&a.__renderGroup.removeDisplayObjectAndChildren(a);for(var b=a.first;b!=this.root.first&&(b=b._iPrev,!b.renderable||!b.__renderGroup););for(var c=a.last;c._iNext&&(c=c._iNext,!c.renderable||!c.__renderGroup););var d=a.first,e=a.last._iNext;do d.__renderGroup=this,d.renderable&&(this.insertObject(d,b,c),b=d),d=d._iNext;while(d!=e)},d.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren=function(a){if(a.__renderGroup==this){a.last;do a.__renderGroup=null,a.renderable&&this.removeObject(a),a=a._iNext;while(a)}},d.WebGLRenderGroup.prototype.insertObject=function(a,b,c){var e=b,f=c;if(a instanceof d.Sprite){var g,h;if(e instanceof d.Sprite){if(g=e.batch,g&&g.texture==a.texture.baseTexture&&g.blendMode==a.blendMode)return g.insertAfter(a,e),void 0}else g=e;if(f)if(f instanceof d.Sprite){if(h=f.batch){if(h.texture==a.texture.baseTexture&&h.blendMode==a.blendMode)return h.insertBefore(a,f),void 0;if(h==g){var i=g.split(f),j=d.WebGLRenderer.getBatch(),k=this.batchs.indexOf(g);return j.init(a),this.batchs.splice(k+1,0,j,i),void 0}}}else h=f;var j=d.WebGLRenderer.getBatch();if(j.init(a),g){var k=this.batchs.indexOf(g);this.batchs.splice(k+1,0,j)}else this.batchs.push(j)}else a instanceof d.TilingSprite?this.initTilingSprite(a):a instanceof d.Strip&&this.initStrip(a),this.insertAfter(a,e)},d.WebGLRenderGroup.prototype.insertAfter=function(a,b){if(b instanceof d.Sprite){var c=b.batch;if(c)if(c.tail==b){var e=this.batchs.indexOf(c);this.batchs.splice(e+1,0,a)}else{var f=c.split(b.__next),e=this.batchs.indexOf(c);this.batchs.splice(e+1,0,a,f)}else this.batchs.push(a)}else{var e=this.batchs.indexOf(b);this.batchs.splice(e+1,0,a)}},d.WebGLRenderGroup.prototype.removeObject=function(a){var b;if(a instanceof d.Sprite){var c=a.batch;if(!c)return;c.remove(a),0==c.size&&(b=c)}else b=a;if(b){var e=this.batchs.indexOf(b);if(-1==e)return;if(0==e||e==this.batchs.length-1)return this.batchs.splice(e,1),b instanceof d.WebGLBatch&&d.WebGLRenderer.returnBatch(b),void 0;if(this.batchs[e-1]instanceof d.WebGLBatch&&this.batchs[e+1]instanceof d.WebGLBatch&&this.batchs[e-1].texture==this.batchs[e+1].texture&&this.batchs[e-1].blendMode==this.batchs[e+1].blendMode)return this.batchs[e-1].merge(this.batchs[e+1]),b instanceof d.WebGLBatch&&d.WebGLRenderer.returnBatch(b),d.WebGLRenderer.returnBatch(this.batchs[e+1]),this.batchs.splice(e,2),void 0;this.batchs.splice(e,1),b instanceof d.WebGLBatch&&d.WebGLRenderer.returnBatch(b)}},d.WebGLRenderGroup.prototype.initTilingSprite=function(a){var b=this.gl;a.verticies=new Float32Array([0,0,a.width,0,a.width,a.height,0,a.height]),a.uvs=new Float32Array([0,0,1,0,1,1,0,1]),a.colors=new Float32Array([1,1,1,1]),a.indices=new Uint16Array([0,1,3,2]),a._vertexBuffer=b.createBuffer(),a._indexBuffer=b.createBuffer(),a._uvBuffer=b.createBuffer(),a._colorBuffer=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,a._vertexBuffer),b.bufferData(b.ARRAY_BUFFER,a.verticies,b.STATIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._uvBuffer),b.bufferData(b.ARRAY_BUFFER,a.uvs,b.DYNAMIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._colorBuffer),b.bufferData(b.ARRAY_BUFFER,a.colors,b.STATIC_DRAW),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,a._indexBuffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,a.indices,b.STATIC_DRAW),a.texture.baseTexture._glTexture?(b.bindTexture(b.TEXTURE_2D,a.texture.baseTexture._glTexture),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.REPEAT),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.REPEAT),a.texture.baseTexture._powerOf2=!0):a.texture.baseTexture._powerOf2=!0},d.WebGLRenderGroup.prototype.renderStrip=function(a,b){var c=this.gl;d.activateStripShader();var e=d.stripShader;e.program;var f=d.mat3.clone(a.worldTransform);d.mat3.transpose(f),c.uniformMatrix3fv(e.translationMatrix,!1,f),c.uniform2f(e.projectionVector,b.x,b.y),c.uniform2f(e.offsetVector,-d.offset.x,-d.offset.y),c.uniform1f(e.alpha,a.worldAlpha),a.dirty?(a.dirty=!1,c.bindBuffer(c.ARRAY_BUFFER,a._vertexBuffer),c.bufferData(c.ARRAY_BUFFER,a.verticies,c.STATIC_DRAW),c.vertexAttribPointer(e.aVertexPosition,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,a._uvBuffer),c.bufferData(c.ARRAY_BUFFER,a.uvs,c.STATIC_DRAW),c.vertexAttribPointer(e.aTextureCoord,2,c.FLOAT,!1,0,0),c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,a.texture.baseTexture._glTexture),c.bindBuffer(c.ARRAY_BUFFER,a._colorBuffer),c.bufferData(c.ARRAY_BUFFER,a.colors,c.STATIC_DRAW),c.vertexAttribPointer(e.colorAttribute,1,c.FLOAT,!1,0,0),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,a._indexBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,a.indices,c.STATIC_DRAW)):(c.bindBuffer(c.ARRAY_BUFFER,a._vertexBuffer),c.bufferSubData(c.ARRAY_BUFFER,0,a.verticies),c.vertexAttribPointer(e.aVertexPosition,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,a._uvBuffer),c.vertexAttribPointer(e.aTextureCoord,2,c.FLOAT,!1,0,0),c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,a.texture.baseTexture._glTexture),c.bindBuffer(c.ARRAY_BUFFER,a._colorBuffer),c.vertexAttribPointer(e.colorAttribute,1,c.FLOAT,!1,0,0),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,a._indexBuffer)),c.drawElements(c.TRIANGLE_STRIP,a.indices.length,c.UNSIGNED_SHORT,0),d.deactivateStripShader()},d.WebGLRenderGroup.prototype.renderTilingSprite=function(a,b){var c=this.gl;d.shaderProgram;var e=a.tilePosition,f=a.tileScale,g=e.x/a.texture.baseTexture.width,h=e.y/a.texture.baseTexture.height,i=a.width/a.texture.baseTexture.width/f.x,j=a.height/a.texture.baseTexture.height/f.y;a.uvs[0]=0-g,a.uvs[1]=0-h,a.uvs[2]=1*i-g,a.uvs[3]=0-h,a.uvs[4]=1*i-g,a.uvs[5]=1*j-h,a.uvs[6]=0-g,a.uvs[7]=1*j-h,c.bindBuffer(c.ARRAY_BUFFER,a._uvBuffer),c.bufferSubData(c.ARRAY_BUFFER,0,a.uvs),this.renderStrip(a,b)},d.WebGLRenderGroup.prototype.initStrip=function(a){var b=this.gl;this.shaderProgram,a._vertexBuffer=b.createBuffer(),a._indexBuffer=b.createBuffer(),a._uvBuffer=b.createBuffer(),a._colorBuffer=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,a._vertexBuffer),b.bufferData(b.ARRAY_BUFFER,a.verticies,b.DYNAMIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._uvBuffer),b.bufferData(b.ARRAY_BUFFER,a.uvs,b.STATIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._colorBuffer),b.bufferData(b.ARRAY_BUFFER,a.colors,b.STATIC_DRAW),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,a._indexBuffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,a.indices,b.STATIC_DRAW)},d.initDefaultShaders=function(){d.primitiveShader=new d.PrimitiveShader,d.primitiveShader.init(),d.stripShader=new d.StripShader,d.stripShader.init(),d.defaultShader=new d.PixiShader,d.defaultShader.init();var a=d.gl,b=d.defaultShader.program;a.useProgram(b),a.enableVertexAttribArray(d.defaultShader.aVertexPosition),a.enableVertexAttribArray(d.defaultShader.colorAttribute),a.enableVertexAttribArray(d.defaultShader.aTextureCoord)},d.activatePrimitiveShader=function(){var a=d.gl;a.useProgram(d.primitiveShader.program),a.disableVertexAttribArray(d.defaultShader.aVertexPosition),a.disableVertexAttribArray(d.defaultShader.colorAttribute),a.disableVertexAttribArray(d.defaultShader.aTextureCoord),a.enableVertexAttribArray(d.primitiveShader.aVertexPosition),a.enableVertexAttribArray(d.primitiveShader.colorAttribute)},d.deactivatePrimitiveShader=function(){var a=d.gl;a.useProgram(d.defaultShader.program),a.disableVertexAttribArray(d.primitiveShader.aVertexPosition),a.disableVertexAttribArray(d.primitiveShader.colorAttribute),a.enableVertexAttribArray(d.defaultShader.aVertexPosition),a.enableVertexAttribArray(d.defaultShader.colorAttribute),a.enableVertexAttribArray(d.defaultShader.aTextureCoord)},d.activateStripShader=function(){var a=d.gl;a.useProgram(d.stripShader.program)},d.deactivateStripShader=function(){var a=d.gl;a.useProgram(d.defaultShader.program)},d.CompileVertexShader=function(a,b){return d._CompileShader(a,b,a.VERTEX_SHADER)},d.CompileFragmentShader=function(a,b){return d._CompileShader(a,b,a.FRAGMENT_SHADER)},d._CompileShader=function(a,b,c){var d=b.join("\n"),e=a.createShader(c);return a.shaderSource(e,d),a.compileShader(e),a.getShaderParameter(e,a.COMPILE_STATUS)?e:(console.log(a.getShaderInfoLog(e)),null)},d.compileProgram=function(a,b){var c=d.gl,e=d.CompileFragmentShader(c,b),f=d.CompileVertexShader(c,a),g=c.createProgram();return c.attachShader(g,f),c.attachShader(g,e),c.linkProgram(g),c.getProgramParameter(g,c.LINK_STATUS)||console.log("Could not initialise shaders"),g},d.BitmapText=function(a,b){d.DisplayObjectContainer.call(this),this.setText(a),this.setStyle(b),this.updateText(),this.dirty=!1},d.BitmapText.prototype=Object.create(d.DisplayObjectContainer.prototype),d.BitmapText.prototype.constructor=d.BitmapText,d.BitmapText.prototype.setText=function(a){this.text=a||" ",this.dirty=!0},d.BitmapText.prototype.setStyle=function(a){a=a||{},a.align=a.align||"left",this.style=a;var b=a.font.split(" ");this.fontName=b[b.length-1],this.fontSize=b.length>=2?parseInt(b[b.length-2],10):d.BitmapText.fonts[this.fontName].size,this.dirty=!0},d.BitmapText.prototype.updateText=function(){for(var a=d.BitmapText.fonts[this.fontName],b=new d.Point,c=null,e=[],f=0,g=[],h=0,i=this.fontSize/a.size,j=0;j=j;j++){var n=0;"right"==this.style.align?n=f-g[j]:"center"==this.style.align&&(n=(f-g[j])/2),m.push(n)}for(j=0;j0;)this.removeChild(this.getChildAt(0));this.updateText(),this.dirty=!1}d.DisplayObjectContainer.prototype.updateTransform.call(this)},d.BitmapText.fonts={},d.Text=function(a,b){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),d.Sprite.call(this,d.Texture.fromCanvas(this.canvas)),this.setText(a),this.setStyle(b),this.updateText(),this.dirty=!1},d.Text.prototype=Object.create(d.Sprite.prototype),d.Text.prototype.constructor=d.Text,d.Text.prototype.setStyle=function(a){a=a||{},a.font=a.font||"bold 20pt Arial",a.fill=a.fill||"black",a.align=a.align||"left",a.stroke=a.stroke||"black",a.strokeThickness=a.strokeThickness||0,a.wordWrap=a.wordWrap||!1,a.wordWrapWidth=a.wordWrapWidth||100,this.style=a,this.dirty=!0},d.Text.prototype.setText=function(a){this.text=a.toString()||" ",this.dirty=!0},d.Text.prototype.updateText=function(){this.context.font=this.style.font;var a=this.text;this.style.wordWrap&&(a=this.wordWrap(this.text));for(var b=a.split(/(?:\r\n|\r|\n)/),c=[],e=0,f=0;fe?(g>0&&(b+="\n"),b+=f[g]+" ",e=this.style.wordWrapWidth-h):(e-=i,b+=f[g]+" ")}b+="\n"}return b},d.Text.prototype.destroy=function(a){a&&this.texture.destroy()},d.Text.heightCache={},d.BaseTextureCache={},d.texturesToUpdate=[],d.texturesToDestroy=[],d.BaseTexture=function(a){if(d.EventTarget.call(this),this.width=100,this.height=100,this.hasLoaded=!1,this.source=a,a){if(this.source instanceof Image||this.source instanceof HTMLImageElement)if(this.source.complete)this.hasLoaded=!0,this.width=this.source.width,this.height=this.source.height,d.texturesToUpdate.push(this);else{var b=this;this.source.onload=function(){b.hasLoaded=!0,b.width=b.source.width,b.height=b.source.height,d.texturesToUpdate.push(b),b.dispatchEvent({type:"loaded",content:b})}}else this.hasLoaded=!0,this.width=this.source.width,this.height=this.source.height,d.texturesToUpdate.push(this);this._powerOf2=!1}},d.BaseTexture.prototype.constructor=d.BaseTexture,d.BaseTexture.prototype.destroy=function(){this.source instanceof Image&&(this.source.src=null),this.source=null,d.texturesToDestroy.push(this)},d.BaseTexture.fromImage=function(a,b){var c=d.BaseTextureCache[a];if(!c){var e=new Image;b&&(e.crossOrigin=""),e.src=a,c=new d.BaseTexture(e),d.BaseTextureCache[a]=c}return c},d.TextureCache={},d.FrameCache={},d.Texture=function(a,b){if(d.EventTarget.call(this),b||(this.noFrame=!0,b=new d.Rectangle(0,0,1,1)),a instanceof d.Texture&&(a=a.baseTexture),this.baseTexture=a,this.frame=b,this.trim=new d.Point,this.scope=this,a.hasLoaded)this.noFrame&&(b=new d.Rectangle(0,0,a.width,a.height)),this.setFrame(b);else{var c=this;a.addEventListener("loaded",function(){c.onBaseTextureLoaded()})}},d.Texture.prototype.constructor=d.Texture,d.Texture.prototype.onBaseTextureLoaded=function(){var a=this.baseTexture;a.removeEventListener("loaded",this.onLoaded),this.noFrame&&(this.frame=new d.Rectangle(0,0,a.width,a.height)),this.noFrame=!1,this.width=this.frame.width,this.height=this.frame.height,this.scope.dispatchEvent({type:"update",content:this})},d.Texture.prototype.destroy=function(a){a&&this.baseTexture.destroy()},d.Texture.prototype.setFrame=function(a){if(this.frame=a,this.width=a.width,this.height=a.height,a.x+a.width>this.baseTexture.width||a.y+a.height>this.baseTexture.height)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.updateFrame=!0,d.Texture.frameUpdates.push(this)},d.Texture.fromImage=function(a,b){var c=d.TextureCache[a];return c||(c=new d.Texture(d.BaseTexture.fromImage(a,b)),d.TextureCache[a]=c),c},d.Texture.fromFrame=function(a){var b=d.TextureCache[a];if(!b)throw new Error("The frameId '"+a+"' does not exist in the texture cache "+this);return b},d.Texture.fromCanvas=function(a){var b=new d.BaseTexture(a);return new d.Texture(b)},d.Texture.addTextureToCache=function(a,b){d.TextureCache[b]=a},d.Texture.removeTextureFromCache=function(a){var b=d.TextureCache[a];return d.TextureCache[a]=null,b},d.Texture.frameUpdates=[],d.RenderTexture=function(a,b){d.EventTarget.call(this),this.width=a||100,this.height=b||100,this.indetityMatrix=d.mat3.create(),this.frame=new d.Rectangle(0,0,this.width,this.height),d.gl?this.initWebGL():this.initCanvas()},d.RenderTexture.prototype=Object.create(d.Texture.prototype),d.RenderTexture.prototype.constructor=d.RenderTexture,d.RenderTexture.prototype.initWebGL=function(){var a=d.gl;this.glFramebuffer=a.createFramebuffer(),a.bindFramebuffer(a.FRAMEBUFFER,this.glFramebuffer),this.glFramebuffer.width=this.width,this.glFramebuffer.height=this.height,this.baseTexture=new d.BaseTexture,this.baseTexture.width=this.width,this.baseTexture.height=this.height,this.baseTexture._glTexture=a.createTexture(),a.bindTexture(a.TEXTURE_2D,this.baseTexture._glTexture),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,this.width,this.height,0,a.RGBA,a.UNSIGNED_BYTE,null),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),this.baseTexture.isRender=!0,a.bindFramebuffer(a.FRAMEBUFFER,this.glFramebuffer),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,this.baseTexture._glTexture,0),this.projection=new d.Point(this.width/2,-this.height/2),this.render=this.renderWebGL},d.RenderTexture.prototype.resize=function(a,b){if(this.width=a,this.height=b,d.gl){this.projection.x=this.width/2,this.projection.y=-this.height/2;var c=d.gl;c.bindTexture(c.TEXTURE_2D,this.baseTexture._glTexture),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,this.width,this.height,0,c.RGBA,c.UNSIGNED_BYTE,null)}else this.frame.width=this.width,this.frame.height=this.height,this.renderer.resize(this.width,this.height)},d.RenderTexture.prototype.initCanvas=function(){this.renderer=new d.CanvasRenderer(this.width,this.height,null,0),this.baseTexture=new d.BaseTexture(this.renderer.view),this.frame=new d.Rectangle(0,0,this.width,this.height),this.render=this.renderCanvas},d.RenderTexture.prototype.renderWebGL=function(a,b,c){var e=d.gl;e.colorMask(!0,!0,!0,!0),e.viewport(0,0,this.width,this.height),e.bindFramebuffer(e.FRAMEBUFFER,this.glFramebuffer),c&&(e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT));var f=a.children,g=a.worldTransform;a.worldTransform=d.mat3.create(),a.worldTransform[4]=-1,a.worldTransform[5]=-2*this.projection.y,b&&(a.worldTransform[2]=b.x,a.worldTransform[5]-=b.y),d.visibleCount++,a.vcount=d.visibleCount;for(var h=0,i=f.length;i>h;h++)f[h].updateTransform();var j=a.__renderGroup;j?a==j.root?j.render(this.projection,this.glFramebuffer):j.renderSpecific(a,this.projection,this.glFramebuffer):(this.renderGroup||(this.renderGroup=new d.WebGLRenderGroup(e)),this.renderGroup.setRenderable(a),this.renderGroup.render(this.projection,this.glFramebuffer)),a.worldTransform=g},d.RenderTexture.prototype.renderCanvas=function(a,b,c){var e=a.children;a.worldTransform=d.mat3.create(),b&&(a.worldTransform[2]=b.x,a.worldTransform[5]=b.y);for(var f=0,g=e.length;g>f;f++)e[f].updateTransform();c&&this.renderer.context.clearRect(0,0,this.width,this.height),this.renderer.renderDisplayObject(a),this.renderer.context.setTransform(1,0,0,1,0,0)},d.EventTarget=function(){var a={};this.addEventListener=this.on=function(b,c){void 0===a[b]&&(a[b]=[]),-1===a[b].indexOf(c)&&a[b].push(c)},this.dispatchEvent=this.emit=function(b){if(a[b.type]&&a[b.type].length)for(var c=0,d=a[b.type].length;d>c;c++)a[b.type][c](b)},this.removeEventListener=this.off=function(b,c){var d=a[b].indexOf(c);-1!==d&&a[b].splice(d,1)}},d.PolyK={},d.PolyK.Triangulate=function(a){var b=!0,c=a.length>>1;if(3>c)return[];for(var e=[],f=[],g=0;c>g;g++)f.push(g);for(var g=0,h=c;h>3;){var i=f[(g+0)%h],j=f[(g+1)%h],k=f[(g+2)%h],l=a[2*i],m=a[2*i+1],n=a[2*j],o=a[2*j+1],p=a[2*k],q=a[2*k+1],r=!1;if(d.PolyK._convex(l,m,n,o,p,q,b)){r=!0;for(var s=0;h>s;s++){var t=f[s];if(t!=i&&t!=j&&t!=k&&d.PolyK._PointInTriangle(a[2*t],a[2*t+1],l,m,n,o,p,q)){r=!1;break}}}if(r)e.push(i,j,k),f.splice((g+1)%h,1),h--,g=0;else if(g++>3*h){if(!b)return console.log("PIXI Warning: shape too complex to fill"),[];var e=[];f=[];for(var g=0;c>g;g++)f.push(g);g=0,h=c,b=!1}}return e.push(f[0],f[1],f[2]),e},d.PolyK._PointInTriangle=function(a,b,c,d,e,f,g,h){var i=g-c,j=h-d,k=e-c,l=f-d,m=a-c,n=b-d,o=i*i+j*j,p=i*k+j*l,q=i*m+j*n,r=k*k+l*l,s=k*m+l*n,t=1/(o*r-p*p),u=(r*q-p*s)*t,v=(o*s-p*q)*t;return u>=0&&v>=0&&1>u+v},d.PolyK._convex=function(a,b,c,d,e,f,g){return(b-d)*(e-c)+(c-a)*(f-d)>=0==g},e.Camera=function(a,b,c,d,f,g){this.game=a,this.world=a.world,this.id=0,this.view=new e.Rectangle(c,d,f,g),this.screenView=new e.Rectangle(c,d,f,g),this.bounds=new e.Rectangle(c,d,f,g),this.deadzone=null,this.visible=!0,this.atLimit={x:!1,y:!1},this.target=null,this._edge=0,this.displayObject=null},e.Camera.FOLLOW_LOCKON=0,e.Camera.FOLLOW_PLATFORMER=1,e.Camera.FOLLOW_TOPDOWN=2,e.Camera.FOLLOW_TOPDOWN_TIGHT=3,e.Camera.prototype={follow:function(a,b){"undefined"==typeof b&&(b=e.Camera.FOLLOW_LOCKON),this.target=a;var c;switch(b){case e.Camera.FOLLOW_PLATFORMER:var d=this.width/8,f=this.height/3;this.deadzone=new e.Rectangle((this.width-d)/2,(this.height-f)/2-.25*f,d,f);break;case e.Camera.FOLLOW_TOPDOWN:c=Math.max(this.width,this.height)/4,this.deadzone=new e.Rectangle((this.width-c)/2,(this.height-c)/2,c,c);break;case e.Camera.FOLLOW_TOPDOWN_TIGHT:c=Math.max(this.width,this.height)/8,this.deadzone=new e.Rectangle((this.width-c)/2,(this.height-c)/2,c,c);break;case e.Camera.FOLLOW_LOCKON:default:this.deadzone=null}},focusOn:function(a){this.setPosition(Math.round(a.x-this.view.halfWidth),Math.round(a.y-this.view.halfHeight))},focusOnXY:function(a,b){this.setPosition(Math.round(a-this.view.halfWidth),Math.round(b-this.view.halfHeight))},update:function(){this.target&&this.updateTarget(),this.bounds&&this.checkBounds(),this.displayObject.position.x=-this.view.x,this.displayObject.position.y=-this.view.y},updateTarget:function(){this.deadzone?(this._edge=this.target.x-this.deadzone.x,this.view.x>this._edge&&(this.view.x=this._edge),this._edge=this.target.x+this.target.width-this.deadzone.x-this.deadzone.width,this.view.xthis._edge&&(this.view.y=this._edge),this._edge=this.target.y+this.target.height-this.deadzone.y-this.deadzone.height,this.view.ythis.bounds.right-this.width&&(this.atLimit.x=!0,this.view.x=this.bounds.right-this.width+1),this.view.ythis.bounds.bottom-this.height&&(this.atLimit.y=!0,this.view.y=this.bounds.bottom-this.height+1),this.view.floor()},setPosition:function(a,b){this.view.x=a,this.view.y=b,this.bounds&&this.checkBounds()},setSize:function(a,b){this.view.width=a,this.view.height=b}},Object.defineProperty(e.Camera.prototype,"x",{get:function(){return this.view.x},set:function(a){this.view.x=a,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"y",{get:function(){return this.view.y},set:function(a){this.view.y=a,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"width",{get:function(){return this.view.width},set:function(a){this.view.width=a}}),Object.defineProperty(e.Camera.prototype,"height",{get:function(){return this.view.height},set:function(a){this.view.height=a}}),e.State=function(){this.game=null,this.add=null,this.camera=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.particles=null,this.physics=null -},e.State.prototype={preload:function(){},loadUpdate:function(){},loadRender:function(){},create:function(){},update:function(){},render:function(){},paused:function(){},destroy:function(){}},e.StateManager=function(a,b){this.game=a,this.states={},null!==b&&(this._pendingState=b)},e.StateManager.prototype={game:null,_pendingState:null,_created:!1,states:{},current:"",onInitCallback:null,onPreloadCallback:null,onCreateCallback:null,onUpdateCallback:null,onRenderCallback:null,onPreRenderCallback:null,onLoadUpdateCallback:null,onLoadRenderCallback:null,onPausedCallback:null,onShutDownCallback:null,boot:function(){null!==this._pendingState&&("string"==typeof this._pendingState?this.start(this._pendingState,!1,!1):this.add("default",this._pendingState,!0))},add:function(a,b,c){"undefined"==typeof c&&(c=!1);var d;return b instanceof e.State?d=b:"object"==typeof b?(d=b,d.game=this.game):"function"==typeof b&&(d=new b(this.game)),this.states[a]=d,c&&(this.game.isBooted?this.start(a):this._pendingState=a),d},remove:function(a){this.current==a&&(this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onPausedCallback=null,this.onDestroyCallback=null),delete this.states[a]},start:function(a,b,c){return"undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=!1),0==this.game.isBooted?(this._pendingState=a,void 0):(0!=this.checkState(a)&&(this.current&&this.onShutDownCallback.call(this.callbackContext,this.game),b&&(this.game.tweens.removeAll(),this.game.world.destroy(),1==c&&this.game.cache.destroy()),this.setCurrentState(a),this.onPreloadCallback?(this.game.load.reset(),this.onPreloadCallback.call(this.callbackContext,this.game),0==this.game.load.queueSize?this.game.loadComplete():this.game.load.start()):this.game.loadComplete()),void 0)},dummy:function(){},checkState:function(a){if(this.states[a]){var b=!1;return this.states[a].preload&&(b=!0),0==b&&this.states[a].loadRender&&(b=!0),0==b&&this.states[a].loadUpdate&&(b=!0),0==b&&this.states[a].create&&(b=!0),0==b&&this.states[a].update&&(b=!0),0==b&&this.states[a].preRender&&(b=!0),0==b&&this.states[a].render&&(b=!0),0==b&&this.states[a].paused&&(b=!0),0==b?(console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions."),!1):!0}return console.warn("Phaser.StateManager - No state found with the key: "+a),!1},link:function(a){this.states[a].game=this.game,this.states[a].add=this.game.add,this.states[a].camera=this.game.camera,this.states[a].cache=this.game.cache,this.states[a].input=this.game.input,this.states[a].load=this.game.load,this.states[a].math=this.game.math,this.states[a].sound=this.game.sound,this.states[a].stage=this.game.stage,this.states[a].time=this.game.time,this.states[a].tweens=this.game.tweens,this.states[a].world=this.game.world,this.states[a].particles=this.game.particles,this.states[a].physics=this.game.physics,this.states[a].rnd=this.game.rnd},setCurrentState:function(a){this.callbackContext=this.states[a],this.link(a),this.onInitCallback=this.states[a].init||this.dummy,this.onPreloadCallback=this.states[a].preload||null,this.onLoadRenderCallback=this.states[a].loadRender||null,this.onLoadUpdateCallback=this.states[a].loadUpdate||null,this.onCreateCallback=this.states[a].create||null,this.onUpdateCallback=this.states[a].update||null,this.onPreRenderCallback=this.states[a].preRender||null,this.onRenderCallback=this.states[a].render||null,this.onPausedCallback=this.states[a].paused||null,this.onShutDownCallback=this.states[a].shutdown||this.dummy,this.current=a,this._created=!1,this.onInitCallback.call(this.callbackContext,this.game)},loadComplete:function(){0==this._created&&this.onCreateCallback?(this._created=!0,this.onCreateCallback.call(this.callbackContext,this.game)):this._created=!0},update:function(){this._created&&this.onUpdateCallback?this.onUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},preRender:function(){this.onPreRenderCallback&&this.onPreRenderCallback.call(this.callbackContext,this.game)},render:function(){this._created&&this.onRenderCallback?this.onRenderCallback.call(this.callbackContext,this.game):this.onLoadRenderCallback&&this.onLoadRenderCallback.call(this.callbackContext,this.game)},destroy:function(){this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onPausedCallback=null,this.onDestroyCallback=null,this.game=null,this.states={},this._pendingState=null}},e.LinkedList=function(){this.next=null,this.prev=null,this.first=null,this.last=null,this.total=0},e.LinkedList.prototype={add:function(a){return 0==this.total&&null==this.first&&null==this.last?(this.first=a,this.last=a,this.next=a,a.prev=this,this.total++,a):(this.last.next=a,a.prev=this.last,this.last=a,this.total++,a)},remove:function(a){a==this.first?this.first=this.first.next:a==this.last&&(this.last=this.last.prev),a.prev&&(a.prev.next=a.next),a.next&&(a.next.prev=a.prev),a.next=a.prev=null,null==this.first&&(this.last=null),this.total--},callAll:function(a){if(this.first&&this.last){var b=this.first;do b&&b[a]&&b[a].call(b),b=b.next;while(b!=this.last.next)}}},e.Signal=function(){this._bindings=[],this._prevParams=null;var a=this;this.dispatch=function(){e.Signal.prototype.dispatch.apply(a,arguments)}},e.Signal.prototype={memorize:!1,_shouldPropagate:!0,active:!0,validateListener:function(a,b){if("function"!=typeof a)throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",b))},_registerListener:function(a,b,c,d){var f,g=this._indexOfListener(a,c);if(-1!==g){if(f=this._bindings[g],f.isOnce()!==b)throw new Error("You cannot add"+(b?"":"Once")+"() then add"+(b?"Once":"")+"() the same listener without removing the relationship first.")}else f=new e.SignalBinding(this,a,b,c,d),this._addBinding(f);return this.memorize&&this._prevParams&&f.execute(this._prevParams),f},_addBinding:function(a){var b=this._bindings.length;do--b;while(this._bindings[b]&&a._priority<=this._bindings[b]._priority);this._bindings.splice(b+1,0,a)},_indexOfListener:function(a,b){for(var c,d=this._bindings.length;d--;)if(c=this._bindings[d],c._listener===a&&c.context===b)return d;return-1},has:function(a,b){return-1!==this._indexOfListener(a,b)},add:function(a,b,c){return this.validateListener(a,"add"),this._registerListener(a,!1,b,c)},addOnce:function(a,b,c){return this.validateListener(a,"addOnce"),this._registerListener(a,!0,b,c)},remove:function(a,b){this.validateListener(a,"remove");var c=this._indexOfListener(a,b);return-1!==c&&(this._bindings[c]._destroy(),this._bindings.splice(c,1)),a},removeAll:function(){for(var a=this._bindings.length;a--;)this._bindings[a]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(){if(this.active){var a,b=Array.prototype.slice.call(arguments),c=this._bindings.length;if(this.memorize&&(this._prevParams=b),c){a=this._bindings.slice(),this._shouldPropagate=!0;do c--;while(a[c]&&this._shouldPropagate&&a[c].execute(b)!==!1)}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(),delete this._bindings,delete this._prevParams},toString:function(){return"[Phaser.Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}},e.SignalBinding=function(a,b,c,d,e){this._listener=b,this._isOnce=c,this.context=d,this._signal=a,this._priority=e||0},e.SignalBinding.prototype={active:!0,params:null,execute:function(a){var b,c;return this.active&&this._listener&&(c=this.params?this.params.concat(a):a,b=this._listener.apply(this.context,c),this._isOnce&&this.detach()),b},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[Phaser.SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},e.Plugin=function(a,b){"undefined"==typeof b&&(b=null),this.game=a,this.parent=b,this.active=!1,this.visible=!1,this.hasPreUpdate=!1,this.hasUpdate=!1,this.hasPostUpdate=!1,this.hasRender=!1,this.hasPostRender=!1},e.Plugin.prototype={preUpdate:function(){},update:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null,this.parent=null,this.active=!1,this.visible=!1}},e.PluginManager=function(a,b){this.game=a,this._parent=b,this.plugins=[],this._pluginsLength=0},e.PluginManager.prototype={add:function(a){var b=!1;return"function"==typeof a?a=new a(this.game,this._parent):(a.game=this.game,a.parent=this._parent),"function"==typeof a.preUpdate&&(a.hasPreUpdate=!0,b=!0),"function"==typeof a.update&&(a.hasUpdate=!0,b=!0),"function"==typeof a.postUpdate&&(a.hasPostUpdate=!0,b=!0),"function"==typeof a.render&&(a.hasRender=!0,b=!0),"function"==typeof a.postRender&&(a.hasPostRender=!0,b=!0),b?((a.hasPreUpdate||a.hasUpdate)&&(a.active=!0),(a.hasRender||a.hasPostRender)&&(a.visible=!0),this._pluginsLength=this.plugins.push(a),"function"==typeof a.init&&a.init(),a):null},remove:function(){this._pluginsLength--},preUpdate:function(){if(0!=this._pluginsLength)for(this._p=0;this._pthis._nextOffsetCheck&&(e.Canvas.getOffset(this.canvas,this.offset),this._nextOffsetCheck=this.game.time.now+this.checkOffsetInterval)},visibilityChange:function(a){this.disableVisibilityChange||(this.game.paused="pagehide"==a.type||"blur"==a.type||1==document.hidden||1==document.webkitHidden?!0:!1)}},Object.defineProperty(e.Stage.prototype,"backgroundColor",{get:function(){return this._backgroundColor},set:function(a){this._backgroundColor=a,this.game.renderType==e.CANVAS?this._stage.backgroundColorString=a:("string"==typeof a&&(a=e.Color.hexToRGB(a)),this._stage.setBackgroundColor(a))}}),e.Group=function(a,b,c,f){"undefined"==typeof b&&(b=a.world),"undefined"==typeof f&&(f=!1),this.game=a,this.name=c||"group",f?this._container=this.game.stage._stage:(this._container=new d.DisplayObjectContainer,this._container.name=this.name,b?b instanceof e.Group?(b._container.addChild(this._container),b._container.updateTransform()):(b.addChild(this._container),b.updateTransform()):(this.game.stage._stage.addChild(this._container),this.game.stage._stage.updateTransform())),this.type=e.GROUP,this.exists=!0,this.scale=new e.Point(1,1),this.cursor=null},e.Group.RETURN_NONE=0,e.Group.RETURN_TOTAL=1,e.Group.RETURN_CHILD=2,e.Group.SORT_ASCENDING=-1,e.Group.SORT_DESCENDING=1,e.Group.prototype={add:function(a){return a.group!==this&&(a.group=this,a.events&&a.events.onAddedToGroup.dispatch(a,this),this._container.addChild(a),a.updateTransform(),null===this.cursor&&(this.cursor=a)),a},addAt:function(a,b){return a.group!==this&&(a.group=this,a.events&&a.events.onAddedToGroup.dispatch(a,this),this._container.addChildAt(a,b),a.updateTransform(),null===this.cursor&&(this.cursor=a)),a},getAt:function(a){return this._container.getChildAt(a)},create:function(a,b,c,d,f){"undefined"==typeof f&&(f=!0);var g=new e.Sprite(this.game,a,b,c,d);return g.group=this,g.exists=f,g.visible=f,g.alive=f,g.events&&g.events.onAddedToGroup.dispatch(g,this),this._container.addChild(g),g.updateTransform(),null===this.cursor&&(this.cursor=g),g},createMultiple:function(a,b,c,d){"undefined"==typeof d&&(d=!1);for(var f=0;a>f;f++){var g=new e.Sprite(this.game,0,0,b,c);g.group=this,g.exists=d,g.visible=d,g.alive=d,g.events&&g.events.onAddedToGroup.dispatch(g,this),this._container.addChild(g),g.updateTransform(),null===this.cursor&&(this.cursor=g)}},next:function(){this.cursor&&(this.cursor=this.cursor==this._container.last?this._container._iNext:this.cursor._iNext)},previous:function(){this.cursor&&(this.cursor=this.cursor==this._container._iNext?this._container.last:this.cursor._iPrev)},childTest:function(a,b){var c=a+" next: ";c+=b._iNext?b._iNext.name:"-null-",c=c+" "+a+" prev: ",c+=b._iPrev?b._iPrev.name:"-null-",console.log(c)},swapIndex:function(a,b){var c=this.getAt(a),d=this.getAt(b);console.log("swapIndex ",a," with ",b),this.swap(c,d)},swap:function(a,b){if(a===b||!a.parent||!b.parent||a.group!==this||b.group!==this)return!1;var c=a._iPrev,d=a._iNext,e=b._iPrev,f=b._iNext,g=this._container.last._iNext,h=this.game.stage._stage;do h!==a&&h!==b&&(h.first===a?h.first=b:h.first===b&&(h.first=a),h.last===a?h.last=b:h.last===b&&(h.last=a)),h=h._iNext;while(h!=g);return a._iNext==b?(a._iNext=f,a._iPrev=b,b._iNext=a,b._iPrev=c,c&&(c._iNext=b),f&&(f._iPrev=a),a.__renderGroup&&a.__renderGroup.updateTexture(a),b.__renderGroup&&b.__renderGroup.updateTexture(b),!0):b._iNext==a?(a._iNext=b,a._iPrev=e,b._iNext=d,b._iPrev=a,e&&(e._iNext=a),d&&(d._iPrev=b),a.__renderGroup&&a.__renderGroup.updateTexture(a),b.__renderGroup&&b.__renderGroup.updateTexture(b),!0):(a._iNext=f,a._iPrev=e,b._iNext=d,b._iPrev=c,c&&(c._iNext=b),d&&(d._iPrev=b),e&&(e._iNext=a),f&&(f._iPrev=a),a.__renderGroup&&a.__renderGroup.updateTexture(a),b.__renderGroup&&b.__renderGroup.updateTexture(b),!0)},bringToTop:function(a){return a.group===this&&(this.remove(a),this.add(a)),a},getIndex:function(a){return this._container.children.indexOf(a)},replace:function(a,b){if(this._container.first._iNext){var c=this.getIndex(a);-1!=c&&(void 0!=b.parent&&(b.events.onRemovedFromGroup.dispatch(b,this),b.parent.removeChild(b)),this._container.removeChild(a),this._container.addChildAt(b,c),b.events.onAddedToGroup.dispatch(b,this),b.updateTransform(),this.cursor==a&&(this.cursor=this._container._iNext))}},setProperty:function(a,b,c,d){d=d||0;var e=b.length;1==e?0==d?a[b[0]]=c:1==d?a[b[0]]+=c:2==d?a[b[0]]-=c:3==d?a[b[0]]*=c:4==d&&(a[b[0]]/=c):2==e?0==d?a[b[0]][b[1]]=c:1==d?a[b[0]][b[1]]+=c:2==d?a[b[0]][b[1]]-=c:3==d?a[b[0]][b[1]]*=c:4==d&&(a[b[0]][b[1]]/=c):3==e?0==d?a[b[0]][b[1]][b[2]]=c:1==d?a[b[0]][b[1]][b[2]]+=c:2==d?a[b[0]][b[1]][b[2]]-=c:3==d?a[b[0]][b[1]][b[2]]*=c:4==d&&(a[b[0]][b[1]][b[2]]/=c):4==e&&(0==d?a[b[0]][b[1]][b[2]][b[3]]=c:1==d?a[b[0]][b[1]][b[2]][b[3]]+=c:2==d?a[b[0]][b[1]][b[2]][b[3]]-=c:3==d?a[b[0]][b[1]][b[2]][b[3]]*=c:4==d&&(a[b[0]][b[1]][b[2]][b[3]]/=c))},setAll:function(a,b,c,d,e){if(a=a.split("."),"undefined"==typeof c&&(c=!1),"undefined"==typeof d&&(d=!1),e=e||0,this._container.children.length>0&&this._container.first._iNext){var f=this._container.first._iNext;do(0==c||c&&f.alive)&&(0==d||d&&f.visible)&&this.setProperty(f,a,b,e),f=f._iNext;while(f!=this._container.last._iNext)}},addAll:function(a,b,c,d){this.setAll(a,b,c,d,1)},subAll:function(a,b,c,d){this.setAll(a,b,c,d,2)},multiplyAll:function(a,b,c,d){this.setAll(a,b,c,d,3)},divideAll:function(a,b,c,d){this.setAll(a,b,c,d,4)},callAllExists:function(a,b){var c=Array.prototype.splice.call(arguments,2);if(this._container.children.length>0&&this._container.first._iNext){var d=this._container.first._iNext;do d.exists==b&&d[a]&&d[a].apply(d,c),d=d._iNext;while(d!=this._container.last._iNext)}},callbackFromArray:function(a,b,c){if(1==c){if(a[b[0]])return a[b[0]]}else if(2==c){if(a[b[0]][b[1]])return a[b[0]][b[1]]}else if(3==c){if(a[b[0]][b[1]][b[2]])return a[b[0]][b[1]][b[2]]}else if(4==c){if(a[b[0]][b[1]][b[2]][b[3]])return a[b[0]][b[1]][b[2]][b[3]]}else if(a[b])return a[b];return!1},callAll:function(a,b){if("undefined"!=typeof a){a=a.split(".");var c=a.length;if("undefined"==typeof b)b=null;else if("string"==typeof b){b=b.split(".");var d=b.length}var e=Array.prototype.splice.call(arguments,2),f=null;if(this._container.children.length>0&&this._container.first._iNext){var g=this._container.first._iNext;do f=this.callbackFromArray(g,a,c),b&&f?(callbackContext=this.callbackFromArray(g,b,d),f&&f.apply(callbackContext,e)):f&&f.apply(g,e),g=g._iNext;while(g!=this._container.last._iNext)}}},forEach:function(a,b,c){"undefined"==typeof c&&(c=!1);var d=Array.prototype.splice.call(arguments,3);if(d.unshift(null),this._container.children.length>0&&this._container.first._iNext){var e=this._container.first._iNext;do(0==c||c&&e.exists)&&(d[0]=e,a.apply(b,d)),e=e._iNext;while(e!=this._container.last._iNext)}},forEachExists:function(a,b){var c=Array.prototype.splice.call(arguments,2);c.unshift(null),this.iterate("exists",!0,e.Group.RETURN_TOTAL,a,b,c)},forEachAlive:function(a,b){var c=Array.prototype.splice.call(arguments,2);c.unshift(null),this.iterate("alive",!0,e.Group.RETURN_TOTAL,a,b,c)},forEachDead:function(a,b){var c=Array.prototype.splice.call(arguments,2);c.unshift(null),this.iterate("alive",!1,e.Group.RETURN_TOTAL,a,b,c)},sort:function(a,b){"undefined"==typeof a&&(a="y"),"undefined"==typeof b&&(b=e.Group.SORT_ASCENDING);var c,d;do{c=!1;for(var f=0,g=this._container.children.length-1;g>f;f++)b==e.Group.SORT_ASCENDING?this._container.children[f][a]>this._container.children[f+1][a]&&(this.swap(this.getAt(f),this.getAt(f+1)),d=this._container.children[f],this._container.children[f]=this._container.children[f+1],this._container.children[f+1]=d,c=!0):this._container.children[f][a]0&&this._container.first._iNext){var i=this._container.first._iNext;do{if(i[a]===b&&(h++,d&&(g[0]=i,d.apply(f,g)),c==e.Group.RETURN_CHILD))return i;i=i._iNext}while(i!=this._container.last._iNext)}return c==e.Group.RETURN_TOTAL?h:c==e.Group.RETURN_CHILD?null:void 0},getFirstExists:function(a){return"boolean"!=typeof a&&(a=!0),this.iterate("exists",a,e.Group.RETURN_CHILD)},getFirstAlive:function(){return this.iterate("alive",!0,e.Group.RETURN_CHILD)},getFirstDead:function(){return this.iterate("alive",!1,e.Group.RETURN_CHILD)},countLiving:function(){return this.iterate("alive",!0,e.Group.RETURN_TOTAL)},countDead:function(){return this.iterate("alive",!1,e.Group.RETURN_TOTAL)},getRandom:function(a,b){return 0==this._container.children.length?null:(a=a||0,b=b||this._container.children.length,this.game.math.getRandom(this._container.children,a,b))},remove:function(a){a.events&&a.events.onRemovedFromGroup.dispatch(a,this),this._container.removeChild(a),this.cursor==a&&(this.cursor=this._container._iNext?this._container._iNext:null),a.group=null},removeAll:function(){if(0!=this._container.children.length){do this._container.children[0].events&&this._container.children[0].events.onRemovedFromGroup.dispatch(this._container.children[0],this),this._container.removeChild(this._container.children[0]);while(this._container.children.length>0);this.cursor=null}},removeBetween:function(a,b){if(0!=this._container.children.length){if(a>b||0>a||b>this._container.children.length)return!1;for(var c=a;b>c;c++){var d=this._container.children[c];d.events.onRemovedFromGroup.dispatch(d,this),this._container.removeChild(d),this.cursor==d&&(this.cursor=this._container._iNext?this._container._iNext:null)}}},destroy:function(){this.removeAll(),this._container.parent.removeChild(this._container),this._container=null,this.game=null,this.exists=!1,this.cursor=null},validate:function(){var a=this.game.stage._stage.last._iNext,b=this.game.stage._stage,c=null,d=null,e=0;do{if(e>0){if(b!==c)return console.log("check next fail"),!1;if(b._iPrev!==d)return console.log("check previous fail"),!1}c=b._iNext,d=b,b=b._iNext,e++}while(b!=a);return!0},dump:function(a){"undefined"==typeof a&&(a=!1);var b=20,c="\n"+e.Utils.pad("Node",b)+"|"+e.Utils.pad("Next",b)+"|"+e.Utils.pad("Previous",b)+"|"+e.Utils.pad("First",b)+"|"+e.Utils.pad("Last",b);console.log(c);var c=e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b);if(console.log(c),a)var d=this.game.stage._stage.last._iNext,f=this.game.stage._stage;else var d=this._container.last._iNext,f=this._container;do{var g=f.name||"*";if(this.cursor==f)var g="> "+g;var h="-",i="-",j="-",k="-";f._iNext&&(h=f._iNext.name),f._iPrev&&(i=f._iPrev.name),f.first&&(j=f.first.name),f.last&&(k=f.last.name),"undefined"==typeof h&&(h="-"),"undefined"==typeof i&&(i="-"),"undefined"==typeof j&&(j="-"),"undefined"==typeof k&&(k="-");var c=e.Utils.pad(g,b)+"|"+e.Utils.pad(h,b)+"|"+e.Utils.pad(i,b)+"|"+e.Utils.pad(j,b)+"|"+e.Utils.pad(k,b);console.log(c),f=f._iNext}while(f!=d)}},Object.defineProperty(e.Group.prototype,"total",{get:function(){return this.iterate("exists",!0,e.Group.RETURN_TOTAL)}}),Object.defineProperty(e.Group.prototype,"length",{get:function(){return this.iterate("exists",!0,e.Group.RETURN_TOTAL)}}),Object.defineProperty(e.Group.prototype,"x",{get:function(){return this._container.position.x},set:function(a){this._container.position.x=a}}),Object.defineProperty(e.Group.prototype,"y",{get:function(){return this._container.position.y},set:function(a){this._container.position.y=a}}),Object.defineProperty(e.Group.prototype,"angle",{get:function(){return e.Math.radToDeg(this._container.rotation)},set:function(a){this._container.rotation=e.Math.degToRad(a)}}),Object.defineProperty(e.Group.prototype,"rotation",{get:function(){return this._container.rotation},set:function(a){this._container.rotation=a}}),Object.defineProperty(e.Group.prototype,"visible",{get:function(){return this._container.visible},set:function(a){this._container.visible=a}}),Object.defineProperty(e.Group.prototype,"alpha",{get:function(){return this._container.alpha},set:function(a){this._container.alpha=a}}),e.World=function(a){e.Group.call(this,a,null,"__world",!1),this.scale=new e.Point(1,1),this.bounds=new e.Rectangle(0,0,a.width,a.height),this.camera=null,this.currentRenderOrderID=0},e.World.prototype=Object.create(e.Group.prototype),e.World.prototype.constructor=e.World,e.World.prototype.boot=function(){this.camera=new e.Camera(this.game,0,0,0,this.game.width,this.game.height),this.camera.displayObject=this._container,this.game.camera=this.camera},e.World.prototype.update=function(){if(this.currentRenderOrderID=0,this.game.stage._stage.first._iNext){var a=this.game.stage._stage.first._iNext;do a.preUpdate&&a.preUpdate(),a.update&&a.update(),a=a._iNext;while(a!=this.game.stage._stage.last._iNext)}},e.World.prototype.postUpdate=function(){if(this.camera.update(),this.game.stage._stage.first._iNext){var a=this.game.stage._stage.first._iNext;do a.postUpdate&&a.postUpdate(),a=a._iNext;while(a!=this.game.stage._stage.last._iNext)}},e.World.prototype.setBounds=function(a,b,c,d){this.bounds.setTo(a,b,c,d),this.camera.bounds&&this.camera.bounds.setTo(a,b,c,d)},e.World.prototype.destroy=function(){this.camera.x=0,this.camera.y=0,this.game.input.reset(!0),this.removeAll()},Object.defineProperty(e.World.prototype,"width",{get:function(){return this.bounds.width},set:function(a){this.bounds.width=a}}),Object.defineProperty(e.World.prototype,"height",{get:function(){return this.bounds.height},set:function(a){this.bounds.height=a}}),Object.defineProperty(e.World.prototype,"centerX",{get:function(){return this.bounds.halfWidth}}),Object.defineProperty(e.World.prototype,"centerY",{get:function(){return this.bounds.halfHeight}}),Object.defineProperty(e.World.prototype,"randomX",{get:function(){return this.bounds.x<0?this.game.rnd.integerInRange(this.bounds.x,this.bounds.width-Math.abs(this.bounds.x)):this.game.rnd.integerInRange(this.bounds.x,this.bounds.width)}}),Object.defineProperty(e.World.prototype,"randomY",{get:function(){return this.bounds.y<0?this.game.rnd.integerInRange(this.bounds.y,this.bounds.height-Math.abs(this.bounds.y)):this.game.rnd.integerInRange(this.bounds.y,this.bounds.height)}}),Object.defineProperty(e.World.prototype,"visible",{get:function(){return this._container.visible},set:function(a){this._container.visible=a}}),e.Game=function(a,b,c,d,f,g,h){a=a||800,b=b||600,c=c||e.AUTO,d=d||"",f=f||null,"undefined"==typeof g&&(g=!1),"undefined"==typeof h&&(h=!0),this.id=e.GAMES.push(this)-1,this.parent=d,this.width=a,this.height=b,this.transparent=g,this.antialias=h,this.renderer=null,this.state=new e.StateManager(this,f),this._paused=!1,this.renderType=c,this._loadComplete=!1,this.isBooted=!1,this.isRunning=!1,this.raf=null,this.add=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.net=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.physics=null,this.rnd=null,this.device=null,this.camera=null,this.canvas=null,this.context=null,this.debug=null,this.particles=null;var i=this;return this._onBoot=function(){return i.boot()},"complete"===document.readyState||"interactive"===document.readyState?window.setTimeout(this._onBoot,0):(document.addEventListener("DOMContentLoaded",this._onBoot,!1),window.addEventListener("load",this._onBoot,!1)),this},e.Game.prototype={boot:function(){this.isBooted||(document.body?(document.removeEventListener("DOMContentLoaded",this._onBoot),window.removeEventListener("load",this._onBoot),this.onPause=new e.Signal,this.onResume=new e.Signal,this.isBooted=!0,this.device=new e.Device,this.math=e.Math,this.rnd=new e.RandomDataGenerator([(Date.now()*Math.random()).toString()]),this.stage=new e.Stage(this,this.width,this.height),this.setUpRenderer(),this.world=new e.World(this),this.add=new e.GameObjectFactory(this),this.cache=new e.Cache(this),this.load=new e.Loader(this),this.time=new e.Time(this),this.tweens=new e.TweenManager(this),this.input=new e.Input(this),this.sound=new e.SoundManager(this),this.physics=new e.Physics.Arcade(this),this.particles=new e.Particles(this),this.plugins=new e.PluginManager(this,this),this.net=new e.Net(this),this.debug=new e.Utils.Debug(this),this.stage.boot(),this.world.boot(),this.input.boot(),this.sound.boot(),this.state.boot(),this.load.onLoadComplete.add(this.loadComplete,this),this.showDebugHeader(),this.isRunning=!0,this._loadComplete=!1,this.raf=new e.RequestAnimationFrame(this),this.raf.start()):window.setTimeout(this._onBoot,20))},showDebugHeader:function(){var a=e.DEV_VERSION,b="Canvas",c="HTML Audio";if(this.renderType==e.WEBGL&&(b="WebGL"),this.device.webAudio&&(c="WebAudio"),this.device.chrome){var d=["%c %c %c Phaser v"+a+" - Renderer: "+b+" - Audio: "+c+" %c %c ","background: #00bff3","background: #0072bc","color: #ffffff; background: #003471","background: #0072bc","background: #00bff3"];console.log.apply(console,d)}else console.log("Phaser v"+a+" - Renderer: "+b+" - Audio: "+c)},setUpRenderer:function(){if(this.renderType===e.CANVAS||this.renderType===e.AUTO&&0==this.device.webGL){if(!this.device.canvas)throw new Error("Phaser.Game - cannot create Canvas or WebGL context, aborting.");this.renderType=e.CANVAS,this.renderer=new d.CanvasRenderer(this.width,this.height,this.stage.canvas,this.transparent),e.Canvas.setSmoothingEnabled(this.renderer.context,this.antialias),this.canvas=this.renderer.view,this.context=this.renderer.context}else this.renderType=e.WEBGL,this.renderer=new d.WebGLRenderer(this.width,this.height,this.stage.canvas,this.transparent,this.antialias),this.canvas=this.renderer.view,this.context=null;e.Canvas.addToDOM(this.renderer.view,this.parent,!0),e.Canvas.setTouchAction(this.renderer.view)},loadComplete:function(){this._loadComplete=!0,this.state.loadComplete()},update:function(a){this.time.update(a),this._paused?(this.renderer.render(this.stage._stage),this.plugins.render(),this.state.render()):(this.plugins.preUpdate(),this.physics.preUpdate(),this.stage.update(),this.input.update(),this.tweens.update(),this.sound.update(),this.world.update(),this.particles.update(),this.state.update(),this.plugins.update(),this.world.postUpdate(),this.plugins.postUpdate(),this.renderer.render(this.stage._stage),this.plugins.render(),this.state.render(),this.plugins.postRender())},destroy:function(){this.raf.stop(),this.input.destroy(),this.state.destroy(),this.state=null,this.cache=null,this.input=null,this.load=null,this.sound=null,this.stage=null,this.time=null,this.world=null,this.isBooted=!1}},Object.defineProperty(e.Game.prototype,"paused",{get:function(){return this._paused},set:function(a){a===!0?0==this._paused&&(this._paused=!0,this.onPause.dispatch(this)):this._paused&&(this._paused=!1,this.onResume.dispatch(this))}}),e.Input=function(a){this.game=a,this.hitCanvas=null,this.hitContext=null},e.Input.MOUSE_OVERRIDES_TOUCH=0,e.Input.TOUCH_OVERRIDES_MOUSE=1,e.Input.MOUSE_TOUCH_COMBINE=2,e.Input.prototype={game:null,pollRate:0,_pollCounter:0,_oldPosition:null,_x:0,_y:0,disabled:!1,multiInputOverride:e.Input.MOUSE_TOUCH_COMBINE,position:null,speed:null,circle:null,scale:null,maxPointers:10,currentPointers:0,tapRate:200,doubleTapRate:300,holdRate:2e3,justPressedRate:200,justReleasedRate:200,recordPointerHistory:!1,recordRate:100,recordLimit:100,pointer1:null,pointer2:null,pointer3:null,pointer4:null,pointer5:null,pointer6:null,pointer7:null,pointer8:null,pointer9:null,pointer10:null,activePointer:null,mousePointer:null,mouse:null,keyboard:null,touch:null,mspointer:null,onDown:null,onUp:null,onTap:null,onHold:null,interactiveItems:new e.LinkedList,boot:function(){this.mousePointer=new e.Pointer(this.game,0),this.pointer1=new e.Pointer(this.game,1),this.pointer2=new e.Pointer(this.game,2),this.mouse=new e.Mouse(this.game),this.keyboard=new e.Keyboard(this.game),this.touch=new e.Touch(this.game),this.mspointer=new e.MSPointer(this.game),this.onDown=new e.Signal,this.onUp=new e.Signal,this.onTap=new e.Signal,this.onHold=new e.Signal,this.scale=new e.Point(1,1),this.speed=new e.Point,this.position=new e.Point,this._oldPosition=new e.Point,this.circle=new e.Circle(0,0,44),this.activePointer=this.mousePointer,this.currentPointers=0,this.hitCanvas=document.createElement("canvas"),this.hitCanvas.width=1,this.hitCanvas.height=1,this.hitContext=this.hitCanvas.getContext("2d"),this.mouse.start(),this.keyboard.start(),this.touch.start(),this.mspointer.start(),this.mousePointer.active=!0 -},destroy:function(){this.mouse.stop(),this.keyboard.stop(),this.touch.stop(),this.mspointer.stop()},addPointer:function(){for(var a=0,b=10;b>0;b--)null===this["pointer"+b]&&(a=b);return 0==a?(console.warn("You can only have 10 Pointer objects"),null):(this["pointer"+a]=new e.Pointer(this.game,a),this["pointer"+a])},update:function(){return this.pollRate>0&&this._pollCounter=b;b++)this["pointer"+b]&&this["pointer"+b].reset();this.currentPointers=0,this.game.stage.canvas.style.cursor="default",1==a&&(this.onDown.dispose(),this.onUp.dispose(),this.onTap.dispose(),this.onHold.dispose(),this.onDown=new e.Signal,this.onUp=new e.Signal,this.onTap=new e.Signal,this.onHold=new e.Signal,this.interactiveItems.callAll("reset")),this._pollCounter=0}},resetSpeed:function(a,b){this._oldPosition.setTo(a,b),this.speed.setTo(0,0)},startPointer:function(a){if(this.maxPointers<10&&this.totalActivePointers==this.maxPointers)return null;if(0==this.pointer1.active)return this.pointer1.start(a);if(0==this.pointer2.active)return this.pointer2.start(a);for(var b=3;10>=b;b++)if(this["pointer"+b]&&0==this["pointer"+b].active)return this["pointer"+b].start(a);return null},updatePointer:function(a){if(this.pointer1.active&&this.pointer1.identifier==a.identifier)return this.pointer1.move(a);if(this.pointer2.active&&this.pointer2.identifier==a.identifier)return this.pointer2.move(a);for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].active&&this["pointer"+b].identifier==a.identifier)return this["pointer"+b].move(a);return null},stopPointer:function(a){if(this.pointer1.active&&this.pointer1.identifier==a.identifier)return this.pointer1.stop(a);if(this.pointer2.active&&this.pointer2.identifier==a.identifier)return this.pointer2.stop(a);for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].active&&this["pointer"+b].identifier==a.identifier)return this["pointer"+b].stop(a);return null},getPointer:function(a){if(a=a||!1,this.pointer1.active==a)return this.pointer1;if(this.pointer2.active==a)return this.pointer2;for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].active==a)return this["pointer"+b];return null},getPointerFromIdentifier:function(a){if(this.pointer1.identifier==a)return this.pointer1;if(this.pointer2.identifier==a)return this.pointer2;for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].identifier==a)return this["pointer"+b];return null}},Object.defineProperty(e.Input.prototype,"x",{get:function(){return this._x},set:function(a){this._x=Math.floor(a)}}),Object.defineProperty(e.Input.prototype,"y",{get:function(){return this._y},set:function(a){this._y=Math.floor(a)}}),Object.defineProperty(e.Input.prototype,"pollLocked",{get:function(){return this.pollRate>0&&this._pollCounter=a;a++)this["pointer"+a]&&this["pointer"+a].active&&this.currentPointers++;return this.currentPointers}}),Object.defineProperty(e.Input.prototype,"worldX",{get:function(){return this.game.camera.view.x+this.x}}),Object.defineProperty(e.Input.prototype,"worldY",{get:function(){return this.game.camera.view.y+this.y}}),e.Key=function(a,b){this.game=a,this.isDown=!1,this.isUp=!1,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.timeDown=0,this.duration=0,this.timeUp=0,this.repeats=0,this.keyCode=b,this.onDown=new e.Signal,this.onUp=new e.Signal},e.Key.prototype={processKeyDown:function(a){this.altKey=a.altKey,this.ctrlKey=a.ctrlKey,this.shiftKey=a.shiftKey,this.isDown?(this.duration=a.timeStamp-this.timeDown,this.repeats++):(this.isDown=!0,this.isUp=!1,this.timeDown=a.timeStamp,this.duration=0,this.repeats=0,this.onDown.dispatch(this))},processKeyUp:function(a){this.isDown=!1,this.isUp=!0,this.timeUp=a.timeStamp,this.onUp.dispatch(this)},justPressed:function(a){return"undefined"==typeof a&&(a=250),this.isDown&&this.duration=this.game.input.holdRate&&((this.game.input.multiInputOverride==e.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==e.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==e.Input.TOUCH_OVERRIDES_MOUSE&&0==this.game.input.currentPointers)&&this.game.input.onHold.dispatch(this),this._holdSent=!0),this.game.input.recordPointerHistory&&this.game.time.now>=this._nextDrop&&(this._nextDrop=this.game.time.now+this.game.input.recordRate,this._history.push({x:this.position.x,y:this.position.y}),this._history.length>this.game.input.recordLimit&&this._history.shift()))},move:function(a){if(!this.game.input.pollLocked){if("undefined"!=typeof a.button&&(this.button=a.button),this.clientX=a.clientX,this.clientY=a.clientY,this.pageX=a.pageX,this.pageY=a.pageY,this.screenX=a.screenX,this.screenY=a.screenY,this.x=(this.pageX-this.game.stage.offset.x)*this.game.input.scale.x,this.y=(this.pageY-this.game.stage.offset.y)*this.game.input.scale.y,this.position.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,(this.game.input.multiInputOverride==e.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==e.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==e.Input.TOUCH_OVERRIDES_MOUSE&&0==this.game.input.currentPointers)&&(this.game.input.activePointer=this,this.game.input.x=this.x,this.game.input.y=this.y,this.game.input.position.setTo(this.game.input.x,this.game.input.y),this.game.input.circle.x=this.game.input.x,this.game.input.circle.y=this.game.input.y),this.game.paused)return this;if(null!==this.targetObject&&1==this.targetObject.isDragged)return 0==this.targetObject.update(this)&&(this.targetObject=null),this;if(this._highestRenderOrderID=-1,this._highestRenderObject=null,this._highestInputPriorityID=-1,this.game.input.interactiveItems.total>0){var b=this.game.input.interactiveItems.next;do(b.pixelPerfect||b.priorityID>this._highestInputPriorityID||b.priorityID==this._highestInputPriorityID&&b.sprite.renderOrderID>this._highestRenderOrderID)&&b.checkPointerOver(this)&&(this._highestRenderOrderID=b.sprite.renderOrderID,this._highestInputPriorityID=b.priorityID,this._highestRenderObject=b),b=b.next;while(null!=b)}return null==this._highestRenderObject?this.targetObject&&(this.targetObject._pointerOutHandler(this),this.targetObject=null):null==this.targetObject?(this.targetObject=this._highestRenderObject,this._highestRenderObject._pointerOverHandler(this)):this.targetObject==this._highestRenderObject?0==this._highestRenderObject.update(this)&&(this.targetObject=null):(this.targetObject._pointerOutHandler(this),this.targetObject=this._highestRenderObject,this.targetObject._pointerOverHandler(this)),this}},leave:function(a){this.withinGame=!1,this.move(a)},stop:function(a){if(this._stateReset)return a.preventDefault(),void 0;if(this.timeUp=this.game.time.now,(this.game.input.multiInputOverride==e.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==e.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==e.Input.TOUCH_OVERRIDES_MOUSE&&0==this.game.input.currentPointers)&&(this.game.input.onUp.dispatch(this,a),this.duration>=0&&this.duration<=this.game.input.tapRate&&(this.timeUp-this.previousTapTime0&&(this.active=!1),this.withinGame=!1,this.isDown=!1,this.isUp=!0,0==this.isMouse&&this.game.input.currentPointers--,this.game.input.interactiveItems.total>0){var b=this.game.input.interactiveItems.next;do b&&b._releasedHandler(this),b=b.next;while(null!=b)}return this.targetObject&&this.targetObject._releasedHandler(this),this.targetObject=null,this},justPressed:function(a){return a=a||this.game.input.justPressedRate,this.isDown===!0&&this.timeDown+a>this.game.time.now},justReleased:function(a){return a=a||this.game.input.justReleasedRate,this.isUp===!0&&this.timeUp+a>this.game.time.now},reset:function(){0==this.isMouse&&(this.active=!1),this.identifier=null,this.isDown=!1,this.isUp=!0,this.totalTouches=0,this._holdSent=!1,this._history.length=0,this._stateReset=!0,this.targetObject&&this.targetObject._releasedHandler(this),this.targetObject=null},toString:function(){return"[{Pointer (id="+this.id+" 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+")}]"}},Object.defineProperty(e.Pointer.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.now-this.timeDown}}),Object.defineProperty(e.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x}}),Object.defineProperty(e.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y}}),e.Touch=function(a){this.game=a,this.disabled=!1,this.callbackContext=this.game,this.touchStartCallback=null,this.touchMoveCallback=null,this.touchEndCallback=null,this.touchEnterCallback=null,this.touchLeaveCallback=null,this.touchCancelCallback=null,this.preventDefault=!0,this._onTouchStart=null,this._onTouchMove=null,this._onTouchEnd=null,this._onTouchEnter=null,this._onTouchLeave=null,this._onTouchCancel=null,this._onTouchMove=null},e.Touch.prototype={start:function(){var a=this;this.game.device.touch&&(this._onTouchStart=function(b){return a.onTouchStart(b)},this._onTouchMove=function(b){return a.onTouchMove(b)},this._onTouchEnd=function(b){return a.onTouchEnd(b)},this._onTouchEnter=function(b){return a.onTouchEnter(b)},this._onTouchLeave=function(b){return a.onTouchLeave(b)},this._onTouchCancel=function(b){return a.onTouchCancel(b)},this.game.renderer.view.addEventListener("touchstart",this._onTouchStart,!1),this.game.renderer.view.addEventListener("touchmove",this._onTouchMove,!1),this.game.renderer.view.addEventListener("touchend",this._onTouchEnd,!1),this.game.renderer.view.addEventListener("touchenter",this._onTouchEnter,!1),this.game.renderer.view.addEventListener("touchleave",this._onTouchLeave,!1),this.game.renderer.view.addEventListener("touchcancel",this._onTouchCancel,!1))},consumeDocumentTouches:function(){this._documentTouchMove=function(a){a.preventDefault()},document.addEventListener("touchmove",this._documentTouchMove,!1)},onTouchStart:function(a){if(this.touchStartCallback&&this.touchStartCallback.call(this.callbackContext,a),!this.game.input.disabled&&!this.disabled){this.preventDefault&&a.preventDefault();for(var b=0;bc;c++)this._pointerData[c]={id:c,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1};this.snapOffset=new e.Point,this.enabled=!0,this.sprite.events&&null==this.sprite.events.onInputOver&&(this.sprite.events.onInputOver=new e.Signal,this.sprite.events.onInputOut=new e.Signal,this.sprite.events.onInputDown=new e.Signal,this.sprite.events.onInputUp=new e.Signal,this.sprite.events.onDragStart=new e.Signal,this.sprite.events.onDragStop=new e.Signal)}return this.sprite},reset:function(){this.enabled=!1;for(var a=0;10>a;a++)this._pointerData[a]={id:a,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1}},stop:function(){0!=this.enabled&&(this.enabled=!1,this.game.input.interactiveItems.remove(this))},destroy:function(){this.enabled&&(this.enabled=!1,this.game.input.interactiveItems.remove(this),this.stop(),this.sprite=null)},pointerX:function(a){return a=a||0,this._pointerData[a].x},pointerY:function(a){return a=a||0,this._pointerData[a].y},pointerDown:function(a){return a=a||0,this._pointerData[a].isDown},pointerUp:function(a){return a=a||0,this._pointerData[a].isUp},pointerTimeDown:function(a){return a=a||0,this._pointerData[a].timeDown},pointerTimeUp:function(a){return a=a||0,this._pointerData[a].timeUp},pointerOver:function(a){if(this.enabled){if("undefined"!=typeof a)return this._pointerData[a].isOver;for(var b=0;10>b;b++)if(this._pointerData[b].isOver)return!0}return!1},pointerOut:function(){if(this.enabled){if("undefined"!=typeof index)return this._pointerData[index].isOut;for(var a=0;10>a;a++)if(this._pointerData[a].isOut)return!0}return!1},pointerTimeOver:function(a){return a=a||0,this._pointerData[a].timeOver},pointerTimeOut:function(a){return a=a||0,this._pointerData[a].timeOut},pointerDragged:function(a){return a=a||0,this._pointerData[a].isDragged},checkPointerOver:function(a){return this.enabled&&this.sprite.visible&&(this.sprite.getLocalUnmodifiedPosition(this._tempPoint,a.x,a.y),this._tempPoint.x>=0&&this._tempPoint.x<=this.sprite.currentFrame.width&&this._tempPoint.y>=0&&this._tempPoint.y<=this.sprite.currentFrame.height)?this.pixelPerfect?this.checkPixel(this._tempPoint.x,this._tempPoint.y):!0:!1},checkPixel:function(a,b){if(this.sprite.texture.baseTexture.source){this.game.input.hitContext.clearRect(0,0,1,1),a+=this.sprite.texture.frame.x,b+=this.sprite.texture.frame.y,this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,a,b,1,1,0,0,1,1);var c=this.game.input.hitContext.getImageData(0,0,1,1);if(c.data[3]>=this.pixelPerfectAlpha)return!0}return!1},update:function(a){return 0==this.enabled||0==this.sprite.visible||this.sprite.group&&0==this.sprite.group.visible?(this._pointerOutHandler(a),!1):this.draggable&&this._draggedPointerID==a.id?this.updateDrag(a):1==this._pointerData[a.id].isOver?this.checkPointerOver(a)?(this._pointerData[a.id].x=a.x-this.sprite.x,this._pointerData[a.id].y=a.y-this.sprite.y,!0):(this._pointerOutHandler(a),!1):void 0},_pointerOverHandler:function(a){0==this._pointerData[a.id].isOver&&(this._pointerData[a.id].isOver=!0,this._pointerData[a.id].isOut=!1,this._pointerData[a.id].timeOver=this.game.time.now,this._pointerData[a.id].x=a.x-this.sprite.x,this._pointerData[a.id].y=a.y-this.sprite.y,this.useHandCursor&&0==this._pointerData[a.id].isDragged&&(this.game.stage.canvas.style.cursor="pointer"),this.sprite.events.onInputOver.dispatch(this.sprite,a))},_pointerOutHandler:function(a){this._pointerData[a.id].isOver=!1,this._pointerData[a.id].isOut=!0,this._pointerData[a.id].timeOut=this.game.time.now,this.useHandCursor&&0==this._pointerData[a.id].isDragged&&(this.game.stage.canvas.style.cursor="default"),this.sprite&&this.sprite.events&&this.sprite.events.onInputOut.dispatch(this.sprite,a)},_touchedHandler:function(a){return 0==this._pointerData[a.id].isDown&&1==this._pointerData[a.id].isOver&&(this._pointerData[a.id].isDown=!0,this._pointerData[a.id].isUp=!1,this._pointerData[a.id].timeDown=this.game.time.now,this.sprite.events.onInputDown.dispatch(this.sprite,a),this.draggable&&0==this.isDragged&&this.startDrag(a),this.bringToTop&&this.sprite.bringToTop()),this.consumePointerEvent},_releasedHandler:function(a){this._pointerData[a.id].isDown&&a.isUp&&(this._pointerData[a.id].isDown=!1,this._pointerData[a.id].isUp=!0,this._pointerData[a.id].timeUp=this.game.time.now,this._pointerData[a.id].downDuration=this._pointerData[a.id].timeUp-this._pointerData[a.id].timeDown,this.checkPointerOver(a)?this.sprite.events.onInputUp.dispatch(this.sprite,a):this.useHandCursor&&(this.game.stage.canvas.style.cursor="default"),this.draggable&&this.isDragged&&this._draggedPointerID==a.id&&this.stopDrag(a))},updateDrag:function(a){return a.isUp?(this.stopDrag(a),!1):(this.allowHorizontalDrag&&(this.sprite.x=a.x+this._dragPoint.x+this.dragOffset.x),this.allowVerticalDrag&&(this.sprite.y=a.y+this._dragPoint.y+this.dragOffset.y),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(this.sprite.x=Math.round(this.sprite.x/this.snapX)*this.snapX,this.sprite.y=Math.round(this.sprite.y/this.snapY)*this.snapY),!0)},justOver:function(a,b){return a=a||0,b=b||500,this._pointerData[a].isOver&&this.overDuration(a)a;a++)this._pointerData[a].isDragged=!1; -this.draggable=!1,this.isDragged=!1,this._draggedPointerID=-1},startDrag:function(a){this.isDragged=!0,this._draggedPointerID=a.id,this._pointerData[a.id].isDragged=!0,this.dragFromCenter?(this.sprite.centerOn(a.x,a.y),this._dragPoint.setTo(this.sprite.x-a.x,this.sprite.y-a.y)):this._dragPoint.setTo(this.sprite.x-a.x,this.sprite.y-a.y),this.updateDrag(a),this.bringToTop&&this.sprite.bringToTop(),this.sprite.events.onDragStart.dispatch(this.sprite,a)},stopDrag:function(a){this.isDragged=!1,this._draggedPointerID=-1,this._pointerData[a.id].isDragged=!1,this.snapOnRelease&&(this.sprite.x=Math.round(this.sprite.x/this.snapX)*this.snapX,this.sprite.y=Math.round(this.sprite.y/this.snapY)*this.snapY),this.sprite.events.onDragStop.dispatch(this.sprite,a),this.sprite.events.onInputUp.dispatch(this.sprite,a),0==this.checkPointerOver(a)&&this._pointerOutHandler(a)},setDragLock:function(a,b){"undefined"==typeof a&&(a=!0),"undefined"==typeof b&&(b=!0),this.allowHorizontalDrag=a,this.allowVerticalDrag=b},enableSnap:function(a,b,c,d){"undefined"==typeof c&&(c=!0),"undefined"==typeof d&&(d=!1),this.snapX=a,this.snapY=b,this.snapOnDrag=c,this.snapOnRelease=d},disableSnap:function(){this.snapOnDrag=!1,this.snapOnRelease=!1},checkBoundsRect:function(){this.sprite.xthis.boundsRect.right&&(this.sprite.x=this.boundsRect.right-this.sprite.width),this.sprite.ythis.boundsRect.bottom&&(this.sprite.y=this.boundsRect.bottom-this.sprite.height)},checkBoundsSprite:function(){this.sprite.xthis.boundsSprite.x+this.boundsSprite.width&&(this.sprite.x=this.boundsSprite.x+this.boundsSprite.width-this.sprite.width),this.sprite.ythis.boundsSprite.y+this.boundsSprite.height&&(this.sprite.y=this.boundsSprite.y+this.boundsSprite.height-this.sprite.height)}},e.Events=function(a){this.parent=a,this.onAddedToGroup=new e.Signal,this.onRemovedFromGroup=new e.Signal,this.onKilled=new e.Signal,this.onRevived=new e.Signal,this.onOutOfBounds=new e.Signal,this.onInputOver=null,this.onInputOut=null,this.onInputDown=null,this.onInputUp=null,this.onDragStart=null,this.onDragStop=null,this.onAnimationStart=null,this.onAnimationComplete=null,this.onAnimationLoop=null},e.Events.prototype={destroy:function(){this.parent=null,this.onAddedToGroup.dispose(),this.onRemovedFromGroup.dispose(),this.onKilled.dispose(),this.onRevived.dispose(),this.onOutOfBounds.dispose(),this.onInputOver&&(this.onInputOver.dispose(),this.onInputOut.dispose(),this.onInputDown.dispose(),this.onInputUp.dispose(),this.onDragStart.dispose(),this.onDragStop.dispose()),this.onAnimationStart&&(this.onAnimationStart.dispose(),this.onAnimationComplete.dispose(),this.onAnimationLoop.dispose())}},e.GameObjectFactory=function(a){this.game=a,this.world=this.game.world},e.GameObjectFactory.prototype={existing:function(a){return this.world.add(a)},sprite:function(a,b,c,d){return this.world.create(a,b,c,d)},child:function(a,b,c,d,e){return a.create(b,c,d,e)},tween:function(a){return this.game.tweens.create(a)},group:function(a,b){return new e.Group(this.game,a,b)},audio:function(a,b,c){return this.game.sound.add(a,b,c)},tileSprite:function(a,b,c,d,f,g){return this.world.add(new e.TileSprite(this.game,a,b,c,d,f,g))},text:function(a,b,c,d){return this.world.add(new e.Text(this.game,a,b,c,d))},button:function(a,b,c,d,f,g,h,i){return this.world.add(new e.Button(this.game,a,b,c,d,f,g,h,i))},graphics:function(a,b){return this.world.add(new e.Graphics(this.game,a,b))},emitter:function(a,b,c){return this.game.particles.add(new e.Particles.Arcade.Emitter(this.game,a,b,c))},bitmapText:function(a,b,c,d){return this.world.add(new e.BitmapText(this.game,a,b,c,d))},tilemap:function(a){return new e.Tilemap(this.game,a)},tileset:function(a){return this.game.cache.getTileset(a)},tilemapLayer:function(a,b,c,d,f,g,h){return this.world.add(new e.TilemapLayer(this.game,a,b,c,d,f,g,h))},renderTexture:function(a,b,c){var d=new e.RenderTexture(this.game,a,b,c);return this.game.cache.addRenderTexture(a,d),d}},e.Sprite=function(a,b,c,f,g){b=b||0,c=c||0,f=f||null,g=g||null,this.game=a,this.exists=!0,this.alive=!0,this.group=null,this.name="",this.type=e.SPRITE,this.renderOrderID=-1,this.lifespan=0,this.events=new e.Events(this),this.animations=new e.AnimationManager(this),this.input=new e.InputHandler(this),this.key=f,this.currentFrame=null,f instanceof e.RenderTexture?(d.Sprite.call(this,f),this.currentFrame=this.game.cache.getTextureFrame(f.name)):f instanceof d.Texture?(d.Sprite.call(this,f),this.currentFrame=g):((null==f||0==this.game.cache.checkImageKey(f))&&(f="__default",this.key=f),d.Sprite.call(this,d.TextureCache[f]),this.game.cache.isSpriteSheet(f)?(this.animations.loadFrameData(this.game.cache.getFrameData(f)),null!==g&&("string"==typeof g?this.frameName=g:this.frame=g)):this.currentFrame=this.game.cache.getFrame(f)),this.textureRegion=new e.Rectangle(this.texture.frame.x,this.texture.frame.y,this.texture.frame.width,this.texture.frame.height),this.anchor=new e.Point,this.x=b,this.y=c,this.position.x=b,this.position.y=c,this.world=new e.Point(b,c),this.autoCull=!1,this.scale=new e.Point(1,1),this._cache={dirty:!1,a00:-1,a01:-1,a02:-1,a10:-1,a11:-1,a12:-1,id:-1,i01:-1,i10:-1,idi:-1,left:null,right:null,top:null,bottom:null,prevX:b,prevY:c,x:-1,y:-1,scaleX:1,scaleY:1,width:this.currentFrame.sourceSizeW,height:this.currentFrame.sourceSizeH,halfWidth:Math.floor(this.currentFrame.sourceSizeW/2),halfHeight:Math.floor(this.currentFrame.sourceSizeH/2),calcWidth:-1,calcHeight:-1,frameID:-1,frameWidth:this.currentFrame.width,frameHeight:this.currentFrame.height,cameraVisible:!0,cropX:0,cropY:0,cropWidth:this.currentFrame.sourceSizeW,cropHeight:this.currentFrame.sourceSizeH},this.offset=new e.Point,this.center=new e.Point(b+Math.floor(this._cache.width/2),c+Math.floor(this._cache.height/2)),this.topLeft=new e.Point(b,c),this.topRight=new e.Point(b+this._cache.width,c),this.bottomRight=new e.Point(b+this._cache.width,c+this._cache.height),this.bottomLeft=new e.Point(b,c+this._cache.height),this.bounds=new e.Rectangle(b,c,this._cache.width,this._cache.height),this.body=new e.Physics.Arcade.Body(this),this.health=1,this.inWorld=e.Rectangle.intersects(this.bounds,this.game.world.bounds),this.inWorldThreshold=0,this.outOfBoundsKill=!1,this._outOfBoundsFired=!1,this.fixedToCamera=!1,this.cameraOffset=new e.Point,this.crop=new e.Rectangle(0,0,this._cache.width,this._cache.height),this.cropEnabled=!1,this.updateCache(),this.updateBounds()},e.Sprite.prototype=Object.create(d.Sprite.prototype),e.Sprite.prototype.constructor=e.Sprite,e.Sprite.prototype.preUpdate=function(){return this.exists?this.lifespan>0&&(this.lifespan-=this.game.time.elapsed,this.lifespan<=0)?(this.kill(),void 0):(this._cache.dirty=!1,this.visible&&(this.renderOrderID=this.game.world.currentRenderOrderID++),this.updateCache(),this.updateAnimation(),this.updateCrop(),(this._cache.dirty||this.world.x!==this._cache.prevX||this.world.y!==this._cache.prevY)&&this.updateBounds(),this.body&&this.body.preUpdate(),void 0):(this.renderOrderID=-1,void 0)},e.Sprite.prototype.updateCache=function(){this._cache.prevX=this.world.x,this._cache.prevY=this.world.y,this.fixedToCamera&&(this.x=this.game.camera.view.x+this.cameraOffset.x,this.y=this.game.camera.view.y+this.cameraOffset.y),this.world.setTo(this.game.camera.x+this.worldTransform[2],this.game.camera.y+this.worldTransform[5]),(this.worldTransform[1]!=this._cache.i01||this.worldTransform[3]!=this._cache.i10||this.worldTransform[0]!=this._cache.a00||this.worldTransform[41]!=this._cache.a11)&&(this._cache.a00=this.worldTransform[0],this._cache.a01=this.worldTransform[1],this._cache.a10=this.worldTransform[3],this._cache.a11=this.worldTransform[4],this._cache.i01=this.worldTransform[1],this._cache.i10=this.worldTransform[3],this._cache.scaleX=Math.sqrt(this._cache.a00*this._cache.a00+this._cache.a01*this._cache.a01),this._cache.scaleY=Math.sqrt(this._cache.a10*this._cache.a10+this._cache.a11*this._cache.a11),this._cache.a01*=-1,this._cache.a10*=-1,this._cache.id=1/(this._cache.a00*this._cache.a11+this._cache.a01*-this._cache.a10),this._cache.idi=1/(this._cache.a00*this._cache.a11+this._cache.i01*-this._cache.i10),this._cache.dirty=!0),this._cache.a02=this.worldTransform[2],this._cache.a12=this.worldTransform[5]},e.Sprite.prototype.updateAnimation=function(){(this.animations.update()||this.currentFrame&&this.currentFrame.uuid!=this._cache.frameID)&&(this._cache.frameID=this.currentFrame.uuid,this._cache.frameWidth=this.texture.frame.width,this._cache.frameHeight=this.texture.frame.height,this._cache.width=this.currentFrame.width,this._cache.height=this.currentFrame.height,this._cache.halfWidth=Math.floor(this._cache.width/2),this._cache.halfHeight=Math.floor(this._cache.height/2),this._cache.dirty=!0)},e.Sprite.prototype.updateCrop=function(){!this.cropEnabled||this.crop.width==this._cache.cropWidth&&this.crop.height==this._cache.cropHeight&&this.crop.x==this._cache.cropX&&this.crop.y==this._cache.cropY||(this.crop.floorAll(),this._cache.cropX=this.crop.x,this._cache.cropY=this.crop.y,this._cache.cropWidth=this.crop.width,this._cache.cropHeight=this.crop.height,this.texture.frame=this.crop,this.texture.width=this.crop.width,this.texture.height=this.crop.height,this.texture.updateFrame=!0,d.Texture.frameUpdates.push(this.texture))},e.Sprite.prototype.updateBounds=function(){this.offset.setTo(this._cache.a02-this.anchor.x*this.width,this._cache.a12-this.anchor.y*this.height),this.getLocalPosition(this.center,this.offset.x+this.width/2,this.offset.y+this.height/2),this.getLocalPosition(this.topLeft,this.offset.x,this.offset.y),this.getLocalPosition(this.topRight,this.offset.x+this.width,this.offset.y),this.getLocalPosition(this.bottomLeft,this.offset.x,this.offset.y+this.height),this.getLocalPosition(this.bottomRight,this.offset.x+this.width,this.offset.y+this.height),this._cache.left=e.Math.min(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x),this._cache.right=e.Math.max(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x),this._cache.top=e.Math.min(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y),this._cache.bottom=e.Math.max(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y),this.bounds.setTo(this._cache.left,this._cache.top,this._cache.right-this._cache.left,this._cache.bottom-this._cache.top),this.updateFrame=!0,0==this.inWorld?(this.inWorld=e.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold),this.inWorld&&(this._outOfBoundsFired=!1)):(this.inWorld=e.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold),0==this.inWorld&&(this.events.onOutOfBounds.dispatch(this),this._outOfBoundsFired=!0,this.outOfBoundsKill&&this.kill())),this._cache.cameraVisible=e.Rectangle.intersects(this.game.world.camera.screenView,this.bounds,0),this.autoCull&&(this.renderable=this._cache.cameraVisible),this.body&&this.body.updateBounds(this.center.x,this.center.y,this._cache.scaleX,this._cache.scaleY)},e.Sprite.prototype.getLocalPosition=function(a,b,c){return a.x=(this._cache.a11*this._cache.id*b+-this._cache.a01*this._cache.id*c+(this._cache.a12*this._cache.a01-this._cache.a02*this._cache.a11)*this._cache.id)*this.scale.x+this._cache.a02,a.y=(this._cache.a00*this._cache.id*c+-this._cache.a10*this._cache.id*b+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.a10)*this._cache.id)*this.scale.y+this._cache.a12,a},e.Sprite.prototype.getLocalUnmodifiedPosition=function(a,b,c){return a.x=this._cache.a11*this._cache.idi*b+-this._cache.i01*this._cache.idi*c+(this._cache.a12*this._cache.i01-this._cache.a02*this._cache.a11)*this._cache.idi+this.anchor.x*this._cache.width,a.y=this._cache.a00*this._cache.idi*c+-this._cache.i10*this._cache.idi*b+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.i10)*this._cache.idi+this.anchor.y*this._cache.height,a},e.Sprite.prototype.resetCrop=function(){this.crop=new e.Rectangle(0,0,this._cache.width,this._cache.height),this.texture.setFrame(this.crop),this.cropEnabled=!1},e.Sprite.prototype.postUpdate=function(){this.exists&&(this.body&&this.body.postUpdate(),this.fixedToCamera?(this._cache.x=this.game.camera.view.x+this.cameraOffset.x,this._cache.y=this.game.camera.view.y+this.cameraOffset.y):(this._cache.x=this.x,this._cache.y=this.y),this.world.setTo(this.game.camera.x+this.worldTransform[2],this.game.camera.y+this.worldTransform[5]),this.position.x=this._cache.x,this.position.y=this._cache.y)},e.Sprite.prototype.loadTexture=function(a,b){this.key=a,a instanceof e.RenderTexture?this.currentFrame=this.game.cache.getTextureFrame(a.name):a instanceof d.Texture?this.currentFrame=b:(("undefined"==typeof a||this.game.cache.checkImageKey(a)===!1)&&(a="__default",this.key=a),this.game.cache.isSpriteSheet(a)?(this.animations.loadFrameData(this.game.cache.getFrameData(a)),"undefined"!=typeof b&&("string"==typeof b?this.frameName=b:this.frame=b)):(this.currentFrame=this.game.cache.getFrame(a),this.setTexture(d.TextureCache[a])))},e.Sprite.prototype.centerOn=function(a,b){return this.x=a+(this.x-this.center.x),this.y=b+(this.y-this.center.y),this},e.Sprite.prototype.revive=function(a){return"undefined"==typeof a&&(a=1),this.alive=!0,this.exists=!0,this.visible=!0,this.health=a,this.events&&this.events.onRevived.dispatch(this),this},e.Sprite.prototype.kill=function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.events&&this.events.onKilled.dispatch(this),this},e.Sprite.prototype.destroy=function(){this.group&&this.group.remove(this),this.input&&this.input.destroy(),this.events&&this.events.destroy(),this.animations&&this.animations.destroy(),this.alive=!1,this.exists=!1,this.visible=!1,this.game=null},e.Sprite.prototype.damage=function(a){return this.alive&&(this.health-=a,this.health<0&&this.kill()),this},e.Sprite.prototype.reset=function(a,b,c){return"undefined"==typeof c&&(c=1),this.x=a,this.y=b,this.position.x=this.x,this.position.y=this.y,this.alive=!0,this.exists=!0,this.visible=!0,this.renderable=!0,this._outOfBoundsFired=!1,this.health=c,this.body&&this.body.reset(),this},e.Sprite.prototype.bringToTop=function(){return this.group?this.group.bringToTop(this):this.game.world.bringToTop(this),this},e.Sprite.prototype.play=function(a,b,c,d){return this.animations?this.animations.play(a,b,c,d):void 0},Object.defineProperty(e.Sprite.prototype,"angle",{get:function(){return e.Math.wrapAngle(e.Math.radToDeg(this.rotation))},set:function(a){this.rotation=e.Math.degToRad(e.Math.wrapAngle(a))}}),Object.defineProperty(e.Sprite.prototype,"frame",{get:function(){return this.animations.frame},set:function(a){this.animations.frame=a}}),Object.defineProperty(e.Sprite.prototype,"frameName",{get:function(){return this.animations.frameName},set:function(a){this.animations.frameName=a}}),Object.defineProperty(e.Sprite.prototype,"inCamera",{get:function(){return this._cache.cameraVisible}}),Object.defineProperty(e.Sprite.prototype,"width",{get:function(){return this.scale.x*this.currentFrame.width},set:function(a){this.scale.x=a/this.currentFrame.width,this._cache.scaleX=a/this.currentFrame.width,this._width=a}}),Object.defineProperty(e.Sprite.prototype,"height",{get:function(){return this.scale.y*this.currentFrame.height},set:function(a){this.scale.y=a/this.currentFrame.height,this._cache.scaleY=a/this.currentFrame.height,this._height=a}}),Object.defineProperty(e.Sprite.prototype,"inputEnabled",{get:function(){return this.input.enabled},set:function(a){a?0==this.input.enabled&&this.input.start():this.input.enabled&&this.input.stop()}}),e.TileSprite=function(a,b,c,f,g,h,i){b=b||0,c=c||0,f=f||256,g=g||256,h=h||null,i=i||null,e.Sprite.call(this,a,b,c,h,i),this.texture=d.TextureCache[h],d.TilingSprite.call(this,this.texture,f,g),this.type=e.TILESPRITE,this.tileScale=new e.Point(1,1),this.tilePosition=new e.Point(0,0)},e.TileSprite.prototype=e.Utils.extend(!0,d.TilingSprite.prototype,e.Sprite.prototype),e.TileSprite.prototype.constructor=e.TileSprite,e.Text=function(a,b,c,f,g){b=b||0,c=c||0,f=f||"",g=g||"",this.exists=!0,this.alive=!0,this.group=null,this.name="",this.game=a,this._text=f,this._style=g,d.Text.call(this,f,g),this.type=e.TEXT,this.position.x=this.x=b,this.position.y=this.y=c,this.anchor=new e.Point,this.scale=new e.Point(1,1),this._cache={dirty:!1,a00:1,a01:0,a02:b,a10:0,a11:1,a12:c,id:1,x:-1,y:-1,scaleX:1,scaleY:1},this._cache.x=this.x,this._cache.y=this.y,this.renderable=!0},e.Text.prototype=Object.create(d.Text.prototype),e.Text.prototype.constructor=e.Text,e.Text.prototype.update=function(){this.exists&&(this._cache.dirty=!1,this._cache.x=this.x,this._cache.y=this.y,(this.position.x!=this._cache.x||this.position.y!=this._cache.y)&&(this.position.x=this._cache.x,this.position.y=this._cache.y,this._cache.dirty=!0))},e.Text.prototype.destroy=function(){this.group&&this.group.remove(this),this.canvas.parentNode?this.canvas.parentNode.removeChild(this.canvas):(this.canvas=null,this.context=null),this.exists=!1,this.group=null},Object.defineProperty(e.Text.prototype,"angle",{get:function(){return e.Math.radToDeg(this.rotation)},set:function(a){this.rotation=e.Math.degToRad(a)}}),Object.defineProperty(e.Text.prototype,"content",{get:function(){return this._text},set:function(a){a!==this._text&&(this._text=a,this.setText(a))}}),Object.defineProperty(e.Text.prototype,"font",{get:function(){return this._style},set:function(a){a!==this._style&&(this._style=a,this.setStyle(a))}}),e.BitmapText=function(a,b,c,f,g){b=b||0,c=c||0,f=f||"",g=g||"",this.exists=!0,this.alive=!0,this.group=null,this.name="",this.game=a,d.BitmapText.call(this,f,g),this.type=e.BITMAPTEXT,this.position.x=b,this.position.y=c,this.anchor=new e.Point,this.scale=new e.Point(1,1),this._cache={dirty:!1,a00:1,a01:0,a02:b,a10:0,a11:1,a12:c,id:1,x:-1,y:-1,scaleX:1,scaleY:1},this._cache.x=this.x,this._cache.y=this.y,this.renderable=!0},e.BitmapText.prototype=Object.create(d.BitmapText.prototype),e.BitmapText.prototype.constructor=e.BitmapText,e.BitmapText.prototype.update=function(){this.exists&&(this._cache.dirty=!1,this._cache.x=this.x,this._cache.y=this.y,(this.position.x!=this._cache.x||this.position.y!=this._cache.y)&&(this.position.x=this._cache.x,this.position.y=this._cache.y,this._cache.dirty=!0),this.pivot.x=this.anchor.x*this.width,this.pivot.y=this.anchor.y*this.height)},e.BitmapText.prototype.destroy=function(){this.group&&this.group.remove(this),this.canvas&&this.canvas.parentNode?this.canvas.parentNode.removeChild(this.canvas):(this.canvas=null,this.context=null),this.exists=!1,this.group=null},Object.defineProperty(e.BitmapText.prototype,"angle",{get:function(){return e.Math.radToDeg(this.rotation)},set:function(a){this.rotation=e.Math.degToRad(a)}}),Object.defineProperty(e.BitmapText.prototype,"x",{get:function(){return this.position.x},set:function(a){this.position.x=a}}),Object.defineProperty(e.BitmapText.prototype,"y",{get:function(){return this.position.y},set:function(a){this.position.y=a}}),e.Button=function(a,b,c,d,f,g,h,i,j){b=b||0,c=c||0,d=d||null,f=f||null,g=g||this,e.Sprite.call(this,a,b,c,d,i),this.type=e.BUTTON,this._onOverFrameName=null,this._onOutFrameName=null,this._onDownFrameName=null,this._onUpFrameName=null,this._onOverFrameID=null,this._onOutFrameID=null,this._onDownFrameID=null,this._onUpFrameID=null,this.onOverSound=null,this.onOutSound=null,this.onDownSound=null,this.onUpSound=null,this.onOverSoundMarker="",this.onOutSoundMarker="",this.onDownSoundMarker="",this.onUpSoundMarker="",this.onInputOver=new e.Signal,this.onInputOut=new e.Signal,this.onInputDown=new e.Signal,this.onInputUp=new e.Signal,this.freezeFrames=!1,this.forceOut=!0,this.setFrames(h,i,j),null!==f&&this.onInputUp.add(f,g),this.input.start(0,!0),this.events.onInputOver.add(this.onInputOverHandler,this),this.events.onInputOut.add(this.onInputOutHandler,this),this.events.onInputDown.add(this.onInputDownHandler,this),this.events.onInputUp.add(this.onInputUpHandler,this)},e.Button.prototype=Object.create(e.Sprite.prototype),e.Button.prototype=e.Utils.extend(!0,e.Button.prototype,e.Sprite.prototype,d.Sprite.prototype),e.Button.prototype.constructor=e.Button,e.Button.prototype.setFrames=function(a,b,c){null!==a&&("string"==typeof a?(this._onOverFrameName=a,this.input.pointerOver()&&(this.frameName=a)):(this._onOverFrameID=a,this.input.pointerOver()&&(this.frame=a))),null!==b&&("string"==typeof b?(this._onOutFrameName=b,this._onUpFrameName=b,0==this.input.pointerOver()&&(this.frameName=b)):(this._onOutFrameID=b,this._onUpFrameID=b,0==this.input.pointerOver()&&(this.frame=b))),null!==c&&("string"==typeof c?(this._onDownFrameName=c,this.input.pointerDown()&&(this.frameName=c)):(this._onDownFrameID=c,this.input.pointerDown()&&(this.frame=c)))},e.Button.prototype.setSounds=function(a,b,c,d,e,f,g,h){this.setOverSound(a,b),this.setOutSound(e,f),this.setUpSound(g,h),this.setDownSound(c,d)},e.Button.prototype.setOverSound=function(a,b){this.onOverSound=null,this.onOverSoundMarker="",a instanceof e.Sound&&(this.onOverSound=a),"string"==typeof b&&(this.onOverSoundMarker=b)},e.Button.prototype.setOutSound=function(a,b){this.onOutSound=null,this.onOutSoundMarker="",a instanceof e.Sound&&(this.onOutSound=a),"string"==typeof b&&(this.onOutSoundMarker=b)},e.Button.prototype.setUpSound=function(a,b){this.onUpSound=null,this.onUpSoundMarker="",a instanceof e.Sound&&(this.onUpSound=a),"string"==typeof b&&(this.onUpSoundMarker=b)},e.Button.prototype.setDownSound=function(a,b){this.onDownSound=null,this.onDownSoundMarker="",a instanceof e.Sound&&(this.onDownSound=a),"string"==typeof b&&(this.onDownSoundMarker=b)},e.Button.prototype.onInputOverHandler=function(a){0==this.freezeFrames&&(null!=this._onOverFrameName?this.frameName=this._onOverFrameName:null!=this._onOverFrameID&&(this.frame=this._onOverFrameID)),this.onOverSound&&this.onOverSound.play(this.onOverSoundMarker),this.onInputOver&&this.onInputOver.dispatch(this,a)},e.Button.prototype.onInputOutHandler=function(a){0==this.freezeFrames&&(null!=this._onOutFrameName?this.frameName=this._onOutFrameName:null!=this._onOutFrameID&&(this.frame=this._onOutFrameID)),this.onOutSound&&this.onOutSound.play(this.onOutSoundMarker),this.onInputOut&&this.onInputOut.dispatch(this,a)},e.Button.prototype.onInputDownHandler=function(a){0==this.freezeFrames&&(null!=this._onDownFrameName?this.frameName=this._onDownFrameName:null!=this._onDownFrameID&&(this.frame=this._onDownFrameID)),this.onDownSound&&this.onDownSound.play(this.onDownSoundMarker),this.onInputDown&&this.onInputDown.dispatch(this,a)},e.Button.prototype.onInputUpHandler=function(a){0==this.freezeFrames&&(null!=this._onUpFrameName?this.frameName=this._onUpFrameName:null!=this._onUpFrameID&&(this.frame=this._onUpFrameID)),this.onUpSound&&this.onUpSound.play(this.onUpSoundMarker),this.forceOut&&0==this.freezeFrames&&(null!=this._onOutFrameName?this.frameName=this._onOutFrameName:null!=this._onOutFrameID&&(this.frame=this._onOutFrameID)),this.onInputUp&&this.onInputUp.dispatch(this,a)},e.Graphics=function(a){this.game=a,d.Graphics.call(this),this.type=e.GRAPHICS},e.Graphics.prototype=Object.create(d.Graphics.prototype),e.Graphics.prototype.constructor=e.Graphics,e.Graphics.prototype.destroy=function(){this.clear(),this.group&&this.group.remove(this),this.game=null},e.Graphics.prototype.drawPolygon=function(a){graphics.moveTo(a.points[0].x,a.points[0].y);for(var b=1;bwindow.outerHeight?90:0,this.scaleFactor=new e.Point(1,1),this.aspectRatio=0;var d=this;window.addEventListener("orientationchange",function(a){return d.checkOrientation(a)},!1),window.addEventListener("resize",function(a){return d.checkResize(a)},!1),document.addEventListener("webkitfullscreenchange",function(a){return d.fullScreenChange(a)},!1),document.addEventListener("mozfullscreenchange",function(a){return d.fullScreenChange(a)},!1),document.addEventListener("fullscreenchange",function(a){return d.fullScreenChange(a)},!1)},e.StageScaleMode.EXACT_FIT=0,e.StageScaleMode.NO_SCALE=1,e.StageScaleMode.SHOW_ALL=2,e.StageScaleMode.prototype={startFullScreen:function(a){if(!this.isFullScreen){"undefined"!=typeof a&&e.Canvas.setSmoothingEnabled(this.game.context,a);var b=this.game.canvas;this._width=this.width,this._height=this.height,console.log("startFullScreen",this._width,this._height),b.requestFullScreen?b.requestFullScreen():b.mozRequestFullScreen?b.mozRequestFullScreen():b.webkitRequestFullScreen&&b.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}},stopFullScreen:function(){document.cancelFullScreen?document.cancelFullScreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen()},fullScreenChange:function(){this.isFullScreen?(this.game.stage.canvas.style.width="100%",this.game.stage.canvas.style.height="100%",this.setMaximum(),this.game.input.scale.setTo(this.game.width/this.width,this.game.height/this.height),this.aspectRatio=this.width/this.height,this.scaleFactor.x=this.game.width/this.width,this.scaleFactor.y=this.game.height/this.height):(this.game.stage.canvas.style.width=this.game.width+"px",this.game.stage.canvas.style.height=this.game.height+"px",this.width=this._width,this.height=this._height,this.game.input.scale.setTo(this.game.width/this.width,this.game.height/this.height),this.aspectRatio=this.width/this.height,this.scaleFactor.x=this.game.width/this.width,this.scaleFactor.y=this.game.height/this.height)},forceOrientation:function(a,b,c){this.forceLandscape=a,"undefined"==typeof b&&(this.forcePortrait=!1),"undefined"!=typeof c&&((null==c||0==this.game.cache.checkImageKey(c))&&(c="__default"),this.orientationSprite=new d.Sprite(d.TextureCache[c]),this.orientationSprite.anchor.x=.5,this.orientationSprite.anchor.y=.5,this.orientationSprite.position.x=this.game.width/2,this.orientationSprite.position.y=this.game.height/2,this.checkOrientationState(),this.incorrectOrientation?(this.orientationSprite.visible=!0,this.game.world.visible=!1):(this.orientationSprite.visible=!1,this.game.world.visible=!0),this.game.stage._stage.addChild(this.orientationSprite))},checkOrientationState:function(){this.incorrectOrientation?(this.forceLandscape&&window.innerWidth>window.innerHeight||this.forcePortrait&&window.innerHeight>window.innerWidth)&&(this.game.paused=!1,this.incorrectOrientation=!1,this.orientationSprite&&(this.orientationSprite.visible=!1,this.game.world.visible=!0),this.refresh()):(this.forceLandscape&&window.innerWidthwindow.outerHeight?90:0,this.isLandscape?this.enterLandscape.dispatch(this.orientation,!0,!1):this.enterPortrait.dispatch(this.orientation,!1,!0),this.game.stage.scaleMode!==e.StageScaleMode.NO_SCALE&&this.refresh(),this.checkOrientationState()},refresh:function(){var a=this;0==this.game.device.iPad&&0==this.game.device.webApp&&0==this.game.device.desktop&&(this.game.device.android&&0==this.game.device.chrome?window.scrollTo(0,1):window.scrollTo(0,0)),null==this._check&&this.maxIterations>0&&(this._iterations=this.maxIterations,this._check=window.setInterval(function(){return a.setScreenSize()},10),this.setScreenSize())},setScreenSize:function(a){"undefined"==typeof a&&(a=!1),0==this.game.device.iPad&&0==this.game.device.webApp&&0==this.game.device.desktop&&(this.game.device.android&&0==this.game.device.chrome?window.scrollTo(0,1):window.scrollTo(0,0)),this._iterations--,(a||window.innerHeight>this._startHeight||this._iterations<0)&&(document.documentElement.style.minHeight=window.innerHeight+"px",1==this.incorrectOrientation?this.setMaximum():this.game.stage.scaleMode==e.StageScaleMode.EXACT_FIT?this.setExactFit():this.game.stage.scaleMode==e.StageScaleMode.SHOW_ALL&&this.setShowAll(),this.setSize(),clearInterval(this._check),this._check=null) -},setSize:function(){0==this.incorrectOrientation&&(this.maxWidth&&this.width>this.maxWidth&&(this.width=this.maxWidth),this.maxHeight&&this.height>this.maxHeight&&(this.height=this.maxHeight),this.minWidth&&this.widththis.maxWidth?this.maxWidth:a,this.height=this.maxHeight&&b>this.maxHeight?this.maxHeight:b}},Object.defineProperty(e.StageScaleMode.prototype,"isFullScreen",{get:function(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement}}),Object.defineProperty(e.StageScaleMode.prototype,"isPortrait",{get:function(){return 0==this.orientation||180==this.orientation}}),Object.defineProperty(e.StageScaleMode.prototype,"isLandscape",{get:function(){return 90===this.orientation||-90===this.orientation}}),e.Device=function(){this.patchAndroidClearRectBug=!1,this.desktop=!1,this.iOS=!1,this.android=!1,this.chromeOS=!1,this.linux=!1,this.macOS=!1,this.windows=!1,this.canvas=!1,this.file=!1,this.fileSystem=!1,this.localStorage=!1,this.webGL=!1,this.worker=!1,this.touch=!1,this.mspointer=!1,this.css3D=!1,this.pointerLock=!1,this.arora=!1,this.chrome=!1,this.epiphany=!1,this.firefox=!1,this.ie=!1,this.ieVersion=0,this.mobileSafari=!1,this.midori=!1,this.opera=!1,this.safari=!1,this.webApp=!1,this.audioData=!1,this.webAudio=!1,this.ogg=!1,this.opus=!1,this.mp3=!1,this.wav=!1,this.m4a=!1,this.webm=!1,this.iPhone=!1,this.iPhone4=!1,this.iPad=!1,this.pixelRatio=0,this._checkAudio(),this._checkBrowser(),this._checkCSS3D(),this._checkDevice(),this._checkFeatures(),this._checkOS()},e.Device.prototype={_checkOS:function(){var a=navigator.userAgent;/Android/.test(a)?this.android=!0:/CrOS/.test(a)?this.chromeOS=!0:/iP[ao]d|iPhone/i.test(a)?this.iOS=!0:/Linux/.test(a)?this.linux=!0:/Mac OS/.test(a)?this.macOS=!0:/Windows/.test(a)&&(this.windows=!0),(this.windows||this.macOS||this.linux)&&(this.desktop=!0)},_checkFeatures:function(){this.canvas=!!window.CanvasRenderingContext2D;try{this.localStorage=!!localStorage.getItem}catch(a){this.localStorage=!1}this.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),this.fileSystem=!!window.requestFileSystem,this.webGL=function(){try{var a=document.createElement("canvas");return!!window.WebGLRenderingContext&&(a.getContext("webgl")||a.getContext("experimental-webgl"))}catch(b){return!1}}(),this.webGL=null===this.webGL||this.webGL===!1?!1:!0,this.worker=!!window.Worker,("ontouchstart"in document.documentElement||window.navigator.msPointerEnabled)&&(this.touch=!0),window.navigator.msPointerEnabled&&(this.mspointer=!0),this.pointerLock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document},_checkBrowser:function(){var a=navigator.userAgent;/Arora/.test(a)?this.arora=!0:/Chrome/.test(a)?this.chrome=!0:/Epiphany/.test(a)?this.epiphany=!0:/Firefox/.test(a)?this.firefox=!0:/Mobile Safari/.test(a)?this.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(a)?(this.ie=!0,this.ieVersion=parseInt(RegExp.$1)):/Midori/.test(a)?this.midori=!0:/Opera/.test(a)?this.opera=!0:/Safari/.test(a)&&(this.safari=!0),navigator.standalone&&(this.webApp=!0)},_checkAudio:function(){this.audioData=!!window.Audio,this.webAudio=!(!window.webkitAudioContext&&!window.AudioContext);var a=document.createElement("audio"),b=!1;try{(b=!!a.canPlayType)&&(a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.ogg=!0),a.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")&&(this.opus=!0),a.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(this.mp3=!0),a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(this.wav=!0),(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;").replace(/^no$/,""))&&(this.m4a=!0),a.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")&&(this.webm=!0))}catch(c){}},_checkDevice:function(){this.pixelRatio=window.devicePixelRatio||1,this.iPhone=-1!=navigator.userAgent.toLowerCase().indexOf("iphone"),this.iPhone4=2==this.pixelRatio&&this.iPhone,this.iPad=-1!=navigator.userAgent.toLowerCase().indexOf("ipad")},_checkCSS3D:function(){var a,b=document.createElement("p"),c={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(b,null);for(var d in c)void 0!==b.style[d]&&(b.style[d]="translate3d(1px,1px,1px)",a=window.getComputedStyle(b).getPropertyValue(c[d]));document.body.removeChild(b),this.css3D=void 0!==a&&a.length>0&&"none"!==a},canPlayAudio:function(a){return"mp3"==a&&this.mp3?!0:"ogg"==a&&(this.ogg||this.opus)?!0:"m4a"==a&&this.m4a?!0:"wav"==a&&this.wav?!0:"webm"==a&&this.webm?!0:!1},isConsoleOpen:function(){return window.console&&window.console.firebug?!0:window.console?(console.profile(),console.profileEnd(),console.clear&&console.clear(),console.profiles.length>0):!1}},e.RequestAnimationFrame=function(a){this.game=a,this._isSetTimeOut=!1,this.isRunning=!1;for(var b=["ms","moz","webkit","o"],c=0;c>>0,b-=d,b*=d,d=b>>>0,b-=d,d+=4294967296*b;return 2.3283064365386963e-10*(d>>>0)},integer:function(){return 4294967296*this.rnd.apply(this)},frac:function(){return this.rnd.apply(this)+1.1102230246251565e-16*(0|2097152*this.rnd.apply(this))},real:function(){return this.integer()+this.frac()},integerInRange:function(a,b){return Math.floor(this.realInRange(a,b))},realInRange:function(a,b){return this.frac()*(b-a)+a},normal:function(){return 1-2*this.frac()},uuid:function(){var a,b;for(b=a="";a++<36;b+=~a%5|4&3*a?(15^a?8^this.frac()*(20^a?16:4):4).toString(16):"-");return b},pick:function(a){return a[this.integerInRange(0,a.length)]},weightedPick:function(a){return a[~~(Math.pow(this.frac(),2)*a.length)]},timestamp:function(a,b){return this.realInRange(a||9466848e5,b||1577862e6)},angle:function(){return this.integerInRange(-180,180)}},e.Math={PI2:2*Math.PI,fuzzyEqual:function(a,b,c){return"undefined"==typeof c&&(c=1e-4),Math.abs(a-b)a},fuzzyGreaterThan:function(a,b,c){return"undefined"==typeof c&&(c=1e-4),a>b-c},fuzzyCeil:function(a,b){return"undefined"==typeof b&&(b=1e-4),Math.ceil(a-b)},fuzzyFloor:function(a,b){return"undefined"==typeof b&&(b=1e-4),Math.floor(a+b)},average:function(){for(var a=[],b=0;b0?Math.floor(a):Math.ceil(a)},shear:function(a){return a%1},snapTo:function(a,b,c){return"undefined"==typeof c&&(c=0),0==b?a:(a-=c,a=b*Math.round(a/b),c+a)},snapToFloor:function(a,b,c){return"undefined"==typeof c&&(c=0),0==b?a:(a-=c,a=b*Math.floor(a/b),c+a)},snapToCeil:function(a,b,c){return"undefined"==typeof c&&(c=0),0==b?a:(a-=c,a=b*Math.ceil(a/b),c+a)},snapToInArray:function(a,b,c){if("undefined"==typeof c&&(c=!0),c&&b.sort(),a=f-a?f:e},roundTo:function(a,b,c){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=10);var d=Math.pow(c,-b);return Math.round(a*d)/d},floorTo:function(a,b,c){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=10);var d=Math.pow(c,-b);return Math.floor(a*d)/d},ceilTo:function(a,b,c){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=10);var d=Math.pow(c,-b);return Math.ceil(a*d)/d},interpolateFloat:function(a,b,c){return(b-a)*c+a},angleBetween:function(a,b,c,d){return Math.atan2(d-b,c-a)},normalizeAngle:function(a,b){"undefined"==typeof b&&(b=!0);var c=b?GameMath.PI:180;return this.wrap(a,c,-c)},nearestAngleBetween:function(a,b,c){"undefined"==typeof c&&(c=!0);var d=c?Math.PI:180;return a=this.normalizeAngle(a,c),b=this.normalizeAngle(b,c),-d/2>a&&b>d/2&&(a+=2*d),-d/2>b&&a>d/2&&(b+=2*d),b-a},interpolateAngles:function(a,b,c,d,e){return"undefined"==typeof d&&(d=!0),"undefined"==typeof e&&(e=null),a=this.normalizeAngle(a,d),b=this.normalizeAngleToAnother(b,a,d),"function"==typeof e?e(c,a,b-a,1):this.interpolateFloat(a,b,c)},chanceRoll:function(a){return"undefined"==typeof a&&(a=50),0>=a?!1:a>=100?!0:100*Math.random()>=a?!1:!0},numberArray:function(a,b){for(var c=[],d=a;b>=d;d++)c.push(d);return c},maxAdd:function(a,b,c){return a+=b,a>c&&(a=c),a},minSub:function(a,b,c){return a-=b,c>a&&(a=c),a},wrap:function(a,b,c){var d=c-b;if(0>=d)return 0;var e=(a-b)%d;return 0>e&&(e+=d),e+b},wrapValue:function(a,b,c){var d;return a=Math.abs(a),b=Math.abs(b),c=Math.abs(c),d=(a+b)%c},randomSign:function(){return Math.random()>.5?1:-1},isOdd:function(a){return 1&a},isEven:function(a){return 1&a?!1:!0},max:function(){for(var a=1,b=0,c=arguments.length;c>a;a++)arguments[b]a;a++)arguments[a]=-180&&180>=a?a:(b=(a+180)%360,0>b&&(b+=360),b-180)},angleLimit:function(a,b,c){var d=a;return a>c?d=c:b>a&&(d=b),d},linearInterpolation:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d);return 0>b?this.linear(a[0],a[1],d):b>1?this.linear(a[c],a[c-1],c-d):this.linear(a[e],a[e+1>c?c:e+1],d-e)},bezierInterpolation:function(a,b){for(var c=0,d=a.length-1,e=0;d>=e;e++)c+=Math.pow(1-b,d-e)*Math.pow(b,e)*a[e]*this.bernstein(d,e);return c},catmullRomInterpolation:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d);return a[0]===a[c]?(0>b&&(e=Math.floor(d=c*(1+b))),this.catmullRom(a[(e-1+c)%c],a[e],a[(e+1)%c],a[(e+2)%c],d-e)):0>b?a[0]-(this.catmullRom(a[0],a[0],a[1],a[1],-d)-a[0]):b>1?a[c]-(this.catmullRom(a[c],a[c],a[c-1],a[c-1],d-c)-a[c]):this.catmullRom(a[e?e-1:0],a[e],a[e+1>c?c:e+1],a[e+2>c?c:e+2],d-e)},linear:function(a,b,c){return(b-a)*c+a},bernstein:function(a,b){return this.factorial(a)/this.factorial(b)/this.factorial(a-b)},catmullRom:function(a,b,c,d,e){var f=.5*(c-a),g=.5*(d-b),h=e*e,i=e*h;return(2*b-2*c+f+g)*i+(-3*b+3*c-2*f-g)*h+f*e+b},difference:function(a,b){return Math.abs(a-b)},getRandom:function(a,b,c){if("undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=0),null!=a){var d=c;if((0==d||d>a.length-b)&&(d=a.length-b),d>0)return a[b+Math.floor(Math.random()*d)]}return null},floor:function(a){var b=0|a;return a>0?b:b!=a?b-1:b},ceil:function(a){var b=0|a;return a>0?b!=a?b+1:b:b},sinCosGenerator:function(a,b,c,d){"undefined"==typeof b&&(b=1),"undefined"==typeof c&&(c=1),"undefined"==typeof d&&(d=1);for(var e=b,f=c,g=d*Math.PI/a,h=[],i=[],j=0;a>j;j++)f-=e*g,e+=f*g,h[j]=f,i[j]=e;return{sin:i,cos:h}},shift:function(a){var b=a.shift();return a.push(b),b},shuffleArray:function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},distance:function(a,b,c,d){var e=a-c,f=b-d;return Math.sqrt(e*e+f*f)},distanceRounded:function(a,b,c,d){return Math.round(e.Math.distance(a,b,c,d))},clamp:function(a,b,c){return b>a?b:a>c?c:a},clampBottom:function(a,b){return b>a?b:a},within:function(a,b,c){return Math.abs(a-b)<=c},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},smoothstep:function(a,b,c){return b>=a?0:a>=c?1:(a=(a-b)/(c-b),a*a*(3-2*a))},smootherstep:function(a,b,c){return b>=a?0:a>=c?1:(a=(a-b)/(c-b),a*a*a*(a*(6*a-15)+10))},sign:function(a){return 0>a?-1:a>0?1:0},degToRad:function(){var a=Math.PI/180;return function(b){return b*a}}(),radToDeg:function(){var a=180/Math.PI;return function(b){return b*a}}()},e.QuadTree=function(a,b,c,d,e,f,g,h){this.physicsManager=a,this.ID=a.quadTreeID,a.quadTreeID++,this.maxObjects=f||10,this.maxLevels=g||4,this.level=h||0,this.bounds={x:Math.round(b),y:Math.round(c),width:d,height:e,subWidth:Math.floor(d/2),subHeight:Math.floor(e/2),right:Math.round(b)+Math.floor(d/2),bottom:Math.round(c)+Math.floor(e/2)},this.objects=[],this.nodes=[]},e.QuadTree.prototype={split:function(){this.level++,this.nodes[0]=new e.QuadTree(this.physicsManager,this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level),this.nodes[1]=new e.QuadTree(this.physicsManager,this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level),this.nodes[2]=new e.QuadTree(this.physicsManager,this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level),this.nodes[3]=new e.QuadTree(this.physicsManager,this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level)},insert:function(a){var b,c=0;if(null!=this.nodes[0]&&(b=this.getIndex(a),-1!==b))return this.nodes[b].insert(a),void 0;if(this.objects.push(a),this.objects.length>this.maxObjects&&this.levelthis.bounds.bottom&&(b=2):a.x>this.bounds.right&&(a.ythis.bounds.bottom&&(b=3)),b},retrieve:function(a){var b=this.objects;return a.body.quadTreeIndex=this.getIndex(a.body),a.body.quadTreeIDs.push(this.ID),this.nodes[0]&&(-1!==a.body.quadTreeIndex?b=b.concat(this.nodes[a.body.quadTreeIndex].retrieve(a)):(b=b.concat(this.nodes[0].retrieve(a)),b=b.concat(this.nodes[1].retrieve(a)),b=b.concat(this.nodes[2].retrieve(a)),b=b.concat(this.nodes[3].retrieve(a)))),b},clear:function(){this.objects=[];for(var a=0,b=this.nodes.length;b>a;a++)this.nodes[a]&&(this.nodes[a].clear(),delete this.nodes[a])}},e.Circle=function(a,b,c){a=a||0,b=b||0,c=c||0,this.x=a,this.y=b,this._diameter=c,this._radius=c>0?.5*c:0},e.Circle.prototype={circumference:function(){return 2*Math.PI*this._radius},setTo:function(a,b,c){return this.x=a,this.y=b,this._diameter=c,this._radius=.5*c,this},copyFrom:function(a){return this.setTo(a.x,a.y,a.diameter)},copyTo:function(a){return a[x]=this.x,a[y]=this.y,a[diameter]=this._diameter,a},distance:function(a,b){return"undefined"==typeof b&&(b=!1),b?e.Math.distanceRound(this.x,this.y,a.x,a.y):e.Math.distance(this.x,this.y,a.x,a.y)},clone:function(b){return"undefined"==typeof b&&(b=new e.Circle),b.setTo(a.x,a.y,a.diameter)},contains:function(a,b){return e.Circle.contains(this,a,b)},circumferencePoint:function(a,b,c){return e.Circle.circumferencePoint(this,a,b,c)},offset:function(a,b){return this.x+=a,this.y+=b,this},offsetPoint:function(a){return this.offset(a.x,a.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}},Object.defineProperty(e.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(a){a>0&&(this._diameter=a,this._radius=.5*a)}}),Object.defineProperty(e.Circle.prototype,"radius",{get:function(){return this._radius},set:function(a){a>0&&(this._radius=a,this._diameter=2*a)}}),Object.defineProperty(e.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(a){a>this.x?(this._radius=0,this._diameter=0):this.radius=this.x-a}}),Object.defineProperty(e.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(a){athis.y?(this._radius=0,this._diameter=0):this.radius=this.y-a}}),Object.defineProperty(e.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(a){a0?Math.PI*this._radius*this._radius:0}}),Object.defineProperty(e.Circle.prototype,"empty",{get:function(){return 0==this._diameter},set:function(){this.setTo(0,0,0)}}),e.Circle.contains=function(a,b,c){if(b>=a.left&&b<=a.right&&c>=a.top&&c<=a.bottom){var d=(a.x-b)*(a.x-b),e=(a.y-c)*(a.y-c);return d+e<=a.radius*a.radius}return!1},e.Circle.equals=function(a,b){return a.x==b.x&&a.y==b.y&&a.diameter==b.diameter},e.Circle.intersects=function(a,b){return e.Math.distance(a.x,a.y,b.x,b.y)<=a.radius+b.radius},e.Circle.circumferencePoint=function(a,b,c,d){return"undefined"==typeof c&&(c=!1),"undefined"==typeof d&&(d=new e.Point),c===!0&&(b=e.Math.radToDeg(b)),d.x=a.x+a.radius*Math.cos(b),d.y=a.y+a.radius*Math.sin(b),d},e.Circle.intersectsRectangle=function(a,b){var c=Math.abs(a.x-b.x-b.halfWidth),d=b.halfWidth+a.radius;if(c>d)return!1;var e=Math.abs(a.y-b.y-b.halfHeight),f=b.halfHeight+a.radius;if(e>f)return!1;if(c<=b.halfWidth||e<=b.halfHeight)return!0;var g=c-b.halfWidth,h=e-b.halfHeight,i=g*g,j=h*h,k=a.radius*a.radius;return k>=i+j},e.Point=function(a,b){a=a||0,b=b||0,this.x=a,this.y=b},e.Point.prototype={copyFrom:function(a){return this.setTo(a.x,a.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(a,b){return this.x=a,this.y=b,this},add:function(a,b){return this.x+=a,this.y+=b,this},subtract:function(a,b){return this.x-=a,this.y-=b,this},multiply:function(a,b){return this.x*=a,this.y*=b,this},divide:function(a,b){return this.x/=a,this.y/=b,this},clampX:function(a,b){return this.x=e.Math.clamp(this.x,a,b),this},clampY:function(a,b){return this.y=e.Math.clamp(this.y,a,b),this},clamp:function(a,b){return this.x=e.Math.clamp(this.x,a,b),this.y=e.Math.clamp(this.y,a,b),this},clone:function(a){return"undefined"==typeof a&&(a=new e.Point),a.setTo(this.x,this.y)},copyFrom:function(a){return this.setTo(a.x,a.y)},copyTo:function(a){return a[x]=this.x,a[y]=this.y,a},distance:function(a,b){return e.Point.distance(this,a,b)},equals:function(a){return a.x==this.x&&a.y==this.y},rotate:function(a,b,c,d,f){return e.Point.rotate(this,a,b,c,d,f)},getMagnitude:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},setMagnitude:function(a){return this.normalize().multiply(a,a)},normalize:function(){if(!this.isZero()){var a=this.getMagnitude();this.x/=a,this.y/=a}return this},isZero:function(){return 0===this.x&&0===this.y},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}},e.Point.add=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x+b.x,c.y=a.y+b.y,c},e.Point.subtract=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x-b.x,c.y=a.y-b.y,c},e.Point.multiply=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x*b.x,c.y=a.y*b.y,c},e.Point.divide=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x/b.x,c.y=a.y/b.y,c},e.Point.equals=function(a,b){return a.x==b.x&&a.y==b.y},e.Point.distance=function(a,b,c){return"undefined"==typeof c&&(c=!1),c?e.Math.distanceRound(a.x,a.y,b.x,b.y):e.Math.distance(a.x,a.y,b.x,b.y)},e.Point.rotate=function(a,b,c,d,f,g){return f=f||!1,g=g||null,f&&(d=e.Math.radToDeg(d)),null===g&&(g=Math.sqrt((b-a.x)*(b-a.x)+(c-a.y)*(c-a.y))),a.setTo(b+g*Math.cos(d),c+g*Math.sin(d))},e.Rectangle=function(a,b,c,d){a=a||0,b=b||0,c=c||0,d=d||0,this.x=a,this.y=b,this.width=c,this.height=d},e.Rectangle.prototype={offset:function(a,b){return this.x+=a,this.y+=b,this},offsetPoint:function(a){return this.offset(a.x,a.y)},setTo:function(a,b,c,d){return this.x=a,this.y=b,this.width=c,this.height=d,this},floor:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y)},floorAll:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.width=Math.floor(this.width),this.height=Math.floor(this.height)},copyFrom:function(a){return this.setTo(a.x,a.y,a.width,a.height)},copyTo:function(a){return a.x=this.x,a.y=this.y,a.width=this.width,a.height=this.height,a},inflate:function(a,b){return e.Rectangle.inflate(this,a,b)},size:function(a){return e.Rectangle.size(this,a)},clone:function(a){return e.Rectangle.clone(this,a)},contains:function(a,b){return e.Rectangle.contains(this,a,b)},containsRect:function(a){return e.Rectangle.containsRect(this,a)},equals:function(a){return e.Rectangle.equals(this,a)},intersection:function(a){return e.Rectangle.intersection(this,a,output)},intersects:function(a,b){return e.Rectangle.intersects(this,a,b)},intersectsRaw:function(a,b,c,d,f){return e.Rectangle.intersectsRaw(this,a,b,c,d,f)},union:function(a,b){return e.Rectangle.union(this,a,b)},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}},Object.defineProperty(e.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)}}),Object.defineProperty(e.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)}}),Object.defineProperty(e.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){this.height=a<=this.y?0:this.y-a}}),Object.defineProperty(e.Rectangle.prototype,"bottomRight",{get:function(){return new e.Point(this.right,this.bottom)},set:function(a){this.right=a.x,this.bottom=a.y}}),Object.defineProperty(e.Rectangle.prototype,"left",{get:function(){return this.x},set:function(a){this.width=a>=this.right?0:this.right-a,this.x=a}}),Object.defineProperty(e.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(a){this.width=a<=this.x?0:this.x+a}}),Object.defineProperty(e.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}}),Object.defineProperty(e.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}}),Object.defineProperty(e.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(a){this.x=a-this.halfWidth}}),Object.defineProperty(e.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(a){this.y=a-this.halfHeight}}),Object.defineProperty(e.Rectangle.prototype,"top",{get:function(){return this.y},set:function(a){a>=this.bottom?(this.height=0,this.y=a):this.height=this.bottom-a}}),Object.defineProperty(e.Rectangle.prototype,"topLeft",{get:function(){return new e.Point(this.x,this.y)},set:function(a){this.x=a.x,this.y=a.y}}),Object.defineProperty(e.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(){this.setTo(0,0,0,0)}}),e.Rectangle.inflate=function(a,b,c){return a.x-=b,a.width+=2*b,a.y-=c,a.height+=2*c,a},e.Rectangle.inflatePoint=function(a,b){return e.Rectangle.inflate(a,b.x,b.y)},e.Rectangle.size=function(a,b){return"undefined"==typeof b&&(b=new e.Point),b.setTo(a.width,a.height)},e.Rectangle.clone=function(a,b){return"undefined"==typeof b&&(b=new e.Rectangle),b.setTo(a.x,a.y,a.width,a.height)},e.Rectangle.contains=function(a,b,c){return b>=a.x&&b<=a.right&&c>=a.y&&c<=a.bottom},e.Rectangle.containsRaw=function(a,b,c,d,e,f){return e>=a&&a+c>=e&&f>=b&&b+d>=f},e.Rectangle.containsPoint=function(a,b){return e.Rectangle.contains(a,b.x,b.y)},e.Rectangle.containsRect=function(a,b){return a.volume>b.volume?!1:a.x>=b.x&&a.y>=b.y&&a.right<=b.right&&a.bottom<=b.bottom},e.Rectangle.equals=function(a,b){return a.x==b.x&&a.y==b.y&&a.width==b.width&&a.height==b.height},e.Rectangle.intersection=function(a,b,c){return c=c||new e.Rectangle,e.Rectangle.intersects(a,b)&&(c.x=Math.max(a.x,b.x),c.y=Math.max(a.y,b.y),c.width=Math.min(a.right,b.right)-c.x,c.height=Math.min(a.bottom,b.bottom)-c.y),c},e.Rectangle.intersects=function(a,b){return a.xa.right+f||ca.bottom+f||e1){if(a&&a==this.decodeURI(e[0]))return this.decodeURI(e[1]);b[this.decodeURI(e[0])]=this.decodeURI(e[1])}}return b},decodeURI:function(a){return decodeURIComponent(a.replace(/\+/g," "))}},e.TweenManager=function(a){this.game=a,this._tweens=[],this._add=[],this.game.onPause.add(this.pauseAll,this),this.game.onResume.add(this.resumeAll,this)},e.TweenManager.prototype={REVISION:"11dev",getAll:function(){return this._tweens},removeAll:function(){this._tweens=[]},add:function(a){this._add.push(a)},create:function(a){return new e.Tween(a,this.game)},remove:function(a){var b=this._tweens.indexOf(a);-1!==b&&(this._tweens[b].pendingDelete=!0)},update:function(){if(0===this._tweens.length&&0===this._add.length)return!1;for(var a=0,b=this._tweens.length;b>a;)this._tweens[a].update(this.game.time.now)?a++:(this._tweens.splice(a,1),b--);return this._add.length>0&&(this._tweens=this._tweens.concat(this._add),this._add.length=0),!0},isTweening:function(a){return this._tweens.some(function(b){return b._object===a})},pauseAll:function(){for(var a=this._tweens.length-1;a>=0;a--)this._tweens[a].pause()},resumeAll:function(){for(var a=this._tweens.length-1;a>=0;a--)this._tweens[a].resume()}},e.Tween=function(a,b){this._object=a,this.game=b,this._manager=this.game.tweens,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._repeat=0,this._yoyo=!1,this._reversed=!1,this._delayTime=0,this._startTime=null,this._easingFunction=e.Easing.Linear.None,this._interpolationFunction=e.Math.linearInterpolation,this._chainedTweens=[],this._onStartCallback=null,this._onStartCallbackFired=!1,this._onUpdateCallback=null,this._onCompleteCallback=null,this._pausedTime=0,this.pendingDelete=!1;for(var c in a)this._valuesStart[c]=parseFloat(a[c],10);this.onStart=new e.Signal,this.onComplete=new e.Signal,this.isRunning=!1},e.Tween.prototype={to:function(a,b,c,d,e,f,g){b=b||1e3,c=c||null,d=d||!1,e=e||0,f=f||0,g=g||!1;var h;return this._parent?(h=this._manager.create(this._object),this._lastChild.chain(h),this._lastChild=h):(h=this,this._parent=this,this._lastChild=this),h._repeat=f,h._duration=b,h._valuesEnd=a,null!==c&&(h._easingFunction=c),e>0&&(h._delayTime=e),h._yoyo=g,d?this.start():this},start:function(){if(null!==this.game&&null!==this._object){this._manager.add(this),this.onStart.dispatch(this._object),this.isRunning=!0,this._onStartCallbackFired=!1,this._startTime=this.game.time.now+this._delayTime;for(var a in this._valuesEnd){if(this._valuesEnd[a]instanceof Array){if(0===this._valuesEnd[a].length)continue;this._valuesEnd[a]=[this._object[a]].concat(this._valuesEnd[a])}this._valuesStart[a]=this._object[a],this._valuesStart[a]instanceof Array==!1&&(this._valuesStart[a]*=1),this._valuesStartRepeat[a]=this._valuesStart[a]||0}return this}},stop:function(){return this.isRunning=!1,this._manager.remove(this),this},delay:function(a){return this._delayTime=a,this},repeat:function(a){return this._repeat=a,this},yoyo:function(a){return this._yoyo=a,this},easing:function(a){return this._easingFunction=a,this},interpolation:function(a){return this._interpolationFunction=a,this},chain:function(){return this._chainedTweens=arguments,this},loop:function(){return this._lastChild.chain(this),this},onStartCallback:function(a){return this._onStartCallback=a,this},onUpdateCallback:function(a){return this._onUpdateCallback=a,this},onCompleteCallback:function(a){return this._onCompleteCallback=a,this},pause:function(){this._paused=!0,this._pausedTime=this.game.time.now},resume:function(){this._paused=!1,this._startTime+=this.game.time.now-this._pausedTime},update:function(a){if(this.pendingDelete)return!1;if(this._paused||a1?1:c;var d=this._easingFunction(c);for(b in this._valuesEnd){var e=this._valuesStart[b]||0,f=this._valuesEnd[b];f instanceof Array?this._object[b]=this._interpolationFunction(f,d):("string"==typeof f&&(f=e+parseFloat(f,10)),"number"==typeof f&&(this._object[b]=e+(f-e)*d))}if(null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._object,d),1==c){if(this._repeat>0){isFinite(this._repeat)&&this._repeat--; -for(b in this._valuesStartRepeat){if("string"==typeof this._valuesEnd[b]&&(this._valuesStartRepeat[b]=this._valuesStartRepeat[b]+parseFloat(this._valuesEnd[b],10)),this._yoyo){var g=this._valuesStartRepeat[b];this._valuesStartRepeat[b]=this._valuesEnd[b],this._valuesEnd[b]=g,this._reversed=!this._reversed}this._valuesStart[b]=this._valuesStartRepeat[b]}return this._startTime=a+this._delayTime,this.onComplete.dispatch(this._object),null!==this._onCompleteCallback&&this._onCompleteCallback.call(this._object),!0}this.onComplete.dispatch(this._object),null!==this._onCompleteCallback&&this._onCompleteCallback.call(this._object);for(var h=0,i=this._chainedTweens.length;i>h;h++)this._chainedTweens[h].start(a);return!1}return!0}},e.Easing={Linear:{None:function(a){return a}},Quadratic:{In:function(a){return a*a},Out:function(a){return a*(2-a)},InOut:function(a){return(a*=2)<1?.5*a*a:-.5*(--a*(a-2)-1)}},Cubic:{In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)}},Quartic:{In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return(a*=2)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)}},Quintic:{In:function(a){return a*a*a*a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)}},Sinusoidal:{In:function(a){return 1-Math.cos(a*Math.PI/2)},Out:function(a){return Math.sin(a*Math.PI/2)},InOut:function(a){return.5*(1-Math.cos(Math.PI*a))}},Exponential:{In:function(a){return 0===a?0:Math.pow(1024,a-1)},Out:function(a){return 1===a?1:1-Math.pow(2,-10*a)},InOut:function(a){return 0===a?0:1===a?1:(a*=2)<1?.5*Math.pow(1024,a-1):.5*(-Math.pow(2,-10*(a-1))+2)}},Circular:{In:function(a){return 1-Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*a)},InOut:function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)}},Elastic:{In:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),-(c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*2*Math.PI/d)))},Out:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),c*Math.pow(2,-10*a)*Math.sin((a-b)*2*Math.PI/d)+1)},InOut:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),(a*=2)<1?-.5*c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*2*Math.PI/d):.5*c*Math.pow(2,-10*(a-=1))*Math.sin((a-b)*2*Math.PI/d)+1)}},Back:{In:function(a){var b=1.70158;return a*a*((b+1)*a-b)},Out:function(a){var b=1.70158;return--a*a*((b+1)*a+b)+1},InOut:function(a){var b=2.5949095;return(a*=2)<1?.5*a*a*((b+1)*a-b):.5*((a-=2)*a*((b+1)*a+b)+2)}},Bounce:{In:function(a){return 1-e.Easing.Bounce.Out(1-a)},Out:function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?7.5625*(a-=1.5/2.75)*a+.75:2.5/2.75>a?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},InOut:function(a){return.5>a?.5*e.Easing.Bounce.In(2*a):.5*e.Easing.Bounce.Out(2*a-1)+.5}}},e.Time=function(a){this.game=a,this._started=0,this._timeLastSecond=0,this._pauseStarted=0,this.physicsElapsed=0,this.time=0,this.pausedTime=0,this.now=0,this.elapsed=0,this.fps=0,this.fpsMin=1e3,this.fpsMax=0,this.msMin=1e3,this.msMax=0,this.frames=0,this.pauseDuration=0,this.timeToCall=0,this.lastTime=0,this.game.onPause.add(this.gamePaused,this),this.game.onResume.add(this.gameResumed,this),this._justResumed=!1},e.Time.prototype={totalElapsedSeconds:function(){return.001*(this.now-this._started)},update:function(a){this.now=a,this._justResumed&&(this.time=this.now,this._justResumed=!1),this.timeToCall=this.game.math.max(0,16-(a-this.lastTime)),this.elapsed=this.now-this.time,this.msMin=this.game.math.min(this.msMin,this.elapsed),this.msMax=this.game.math.max(this.msMax,this.elapsed),this.frames++,this.now>this._timeLastSecond+1e3&&(this.fps=Math.round(1e3*this.frames/(this.now-this._timeLastSecond)),this.fpsMin=this.game.math.min(this.fpsMin,this.fps),this.fpsMax=this.game.math.max(this.fpsMax,this.fps),this._timeLastSecond=this.now,this.frames=0),this.time=this.now,this.lastTime=a+this.timeToCall,this.physicsElapsed=1*(this.elapsed/1e3),this.physicsElapsed>1&&(this.physicsElapsed=1),this.game.paused&&(this.pausedTime=this.now-this._pauseStarted)},gamePaused:function(){this._pauseStarted=this.now},gameResumed:function(){this.time=Date.now(),this.pauseDuration=this.pausedTime,this._justResumed=!0},elapsedSince:function(a){return this.now-a},elapsedSecondsSince:function(a){return.001*(this.now-a)},reset:function(){this._started=this.now}},e.AnimationManager=function(a){this.sprite=a,this.game=a.game,this.currentFrame=null,this.updateIfVisible=!0,this.isLoaded=!1,this._frameData=null,this._anims={},this._outputFrames=[]},e.AnimationManager.prototype={loadFrameData:function(a){this._frameData=a,this.frame=0,this.isLoaded=!0},add:function(a,b,c,f,g){return null==this._frameData?(console.warn("No FrameData available for Phaser.Animation "+a),void 0):(c=c||60,"undefined"==typeof f&&(f=!1),"undefined"==typeof g&&(g=b&&"number"==typeof b[0]?!0:!1),null==this.sprite.events.onAnimationStart&&(this.sprite.events.onAnimationStart=new e.Signal,this.sprite.events.onAnimationComplete=new e.Signal,this.sprite.events.onAnimationLoop=new e.Signal),this._outputFrames.length=0,this._frameData.getFrameIndexes(b,g,this._outputFrames),this._anims[a]=new e.Animation(this.game,this.sprite,a,this._frameData,this._outputFrames,c,f),this.currentAnim=this._anims[a],this.currentFrame=this.currentAnim.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid]),this._anims[a])},validateFrames:function(a,b){"undefined"==typeof b&&(b=!0);for(var c=0;cthis._frameData.total)return!1}else if(0==this._frameData.checkFrameName(a[c]))return!1;return!0},play:function(a,b,c,d){if(this._anims[a]){if(this.currentAnim!=this._anims[a])return this.currentAnim=this._anims[a],this.currentAnim.paused=!1,this.currentAnim.play(b,c,d);if(0==this.currentAnim.isPlaying)return this.currentAnim.paused=!1,this.currentAnim.play(b,c,d)}},stop:function(a,b){"undefined"==typeof b&&(b=!1),"string"==typeof a?this._anims[a]&&(this.currentAnim=this._anims[a],this.currentAnim.stop(b)):this.currentAnim&&this.currentAnim.stop(b)},update:function(){return this.updateIfVisible&&0==this.sprite.visible?!1:this.currentAnim&&1==this.currentAnim.update()?(this.currentFrame=this.currentAnim.currentFrame,this.sprite.currentFrame=this.currentFrame,!0):!1},getAnimation:function(a){return"string"==typeof a&&this._anims[a]?this._anims[a]:!1},refreshFrame:function(){this.sprite.currentFrame=this.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid])},destroy:function(){this._anims={},this._frameData=null,this._frameIndex=0,this.currentAnim=null,this.currentFrame=null}},Object.defineProperty(e.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}}),Object.defineProperty(e.AnimationManager.prototype,"frameTotal",{get:function(){return this._frameData?this._frameData.total:-1}}),Object.defineProperty(e.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(a){this.currentAnim.paused=a}}),Object.defineProperty(e.AnimationManager.prototype,"frame",{get:function(){return this.currentFrame?this._frameIndex:void 0},set:function(a){"number"==typeof a&&this._frameData&&null!==this._frameData.getFrame(a)&&(this.currentFrame=this._frameData.getFrame(a),this._frameIndex=a,this.sprite.currentFrame=this.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid]))}}),Object.defineProperty(e.AnimationManager.prototype,"frameName",{get:function(){return this.currentFrame?this.currentFrame.name:void 0},set:function(a){"string"==typeof a&&this._frameData&&null!==this._frameData.getFrameByName(a)?(this.currentFrame=this._frameData.getFrameByName(a),this._frameIndex=this.currentFrame.index,this.sprite.currentFrame=this.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid])):console.warn("Cannot set frameName: "+a)}}),e.Animation=function(a,b,c,d,e,f,g){this.game=a,this._parent=b,this._frameData=d,this.name=c,this._frames=[],this._frames=this._frames.concat(e),this.delay=1e3/f,this.looped=g,this.killOnComplete=!1,this.isFinished=!1,this.isPlaying=!1,this.isPaused=!1,this._pauseStartTime=0,this._frameIndex=0,this._frameDiff=0,this._frameSkip=1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex])},e.Animation.prototype={play:function(a,b,c){return"number"==typeof a&&(this.delay=1e3/a),"boolean"==typeof b&&(this.looped=b),"undefined"!=typeof c&&(this.killOnComplete=c),this.isPlaying=!0,this.isFinished=!1,this.paused=!1,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]),this._parent.setTexture(d.TextureCache[this.currentFrame.uuid]),this._parent.events&&this._parent.events.onAnimationStart.dispatch(this._parent,this),this},restart:function(){this.isPlaying=!0,this.isFinished=!1,this.paused=!1,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])},stop:function(a){"undefined"==typeof a&&(a=!1),this.isPlaying=!1,this.isFinished=!0,this.paused=!1,a&&(this.currentFrame=this._frameData.getFrame(this._frames[0]))},update:function(){return this.isPaused?!1:1==this.isPlaying&&this.game.time.now>=this._timeNextFrame?(this._frameSkip=1,this._frameDiff=this.game.time.now-this._timeNextFrame,this._timeLastFrame=this.game.time.now,this._frameDiff>this.delay&&(this._frameSkip=Math.floor(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay),this._timeNextFrame=this.game.time.now+(this.delay-this._frameDiff),this._frameIndex+=this._frameSkip,this._frameIndex>=this._frames.length?this.looped?(this._frameIndex%=this._frames.length,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&this._parent.setTexture(d.TextureCache[this.currentFrame.uuid]),this._parent.events.onAnimationLoop.dispatch(this._parent,this)):this.onComplete():(this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this._parent.setTexture(d.TextureCache[this.currentFrame.uuid])),!0):!1},destroy:function(){this.game=null,this._parent=null,this._frames=null,this._frameData=null,this.currentFrame=null,this.isPlaying=!1},onComplete:function(){this.isPlaying=!1,this.isFinished=!0,this.paused=!1,this._parent.events&&this._parent.events.onAnimationComplete.dispatch(this._parent,this),this.killOnComplete&&this._parent.kill()}},Object.defineProperty(e.Animation.prototype,"paused",{get:function(){return this.isPaused},set:function(a){this.isPaused=a,a?this._pauseStartTime=this.game.time.now:this.isPlaying&&(this._timeNextFrame=this.game.time.now+this.delay)}}),Object.defineProperty(e.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}}),Object.defineProperty(e.Animation.prototype,"frame",{get:function(){return null!==this.currentFrame?this.currentFrame.index:this._frameIndex},set:function(a){this.currentFrame=this._frameData.getFrame(a),null!==this.currentFrame&&(this._frameIndex=a,this._parent.setTexture(d.TextureCache[this.currentFrame.uuid]))}}),e.Animation.generateFrameNames=function(a,b,c,d,f){"undefined"==typeof d&&(d="");var g=[],h="";if(c>b)for(var i=b;c>=i;i++)h="number"==typeof f?e.Utils.pad(i.toString(),f,"0",1):i.toString(),h=a+h+d,g.push(h);else for(var i=b;i>=c;i--)h="number"==typeof f?e.Utils.pad(i.toString(),f,"0",1):i.toString(),h=a+h+d,g.push(h);return g},e.Frame=function(a,b,c,d,f,g,h){this.index=a,this.x=b,this.y=c,this.width=d,this.height=f,this.name=g,this.uuid=h,this.centerX=Math.floor(d/2),this.centerY=Math.floor(f/2),this.distance=e.Math.distance(0,0,d,f),this.rotated=!1,this.rotationDirection="cw",this.trimmed=!1,this.sourceSizeW=d,this.sourceSizeH=f,this.spriteSourceSizeX=0,this.spriteSourceSizeY=0,this.spriteSourceSizeW=0,this.spriteSourceSizeH=0},e.Frame.prototype={setTrim:function(a,b,c,d,e,f,g){this.trimmed=a,a&&(this.width=b,this.height=c,this.sourceSizeW=b,this.sourceSizeH=c,this.centerX=Math.floor(b/2),this.centerY=Math.floor(c/2),this.spriteSourceSizeX=d,this.spriteSourceSizeY=e,this.spriteSourceSizeW=f,this.spriteSourceSizeH=g)}},e.FrameData=function(){this._frames=[],this._frameNames=[]},e.FrameData.prototype={addFrame:function(a){return a.index=this._frames.length,this._frames.push(a),""!==a.name&&(this._frameNames[a.name]=a.index),a},getFrame:function(a){return this._frames.length>a?this._frames[a]:null},getFrameByName:function(a){return"number"==typeof this._frameNames[a]?this._frames[this._frameNames[a]]:null},checkFrameName:function(a){return null==this._frameNames[a]?!1:!0},getFrameRange:function(a,b,c){"undefined"==typeof c&&(c=[]);for(var d=a;b>=d;d++)c.push(this._frames[d]);return c},getFrames:function(a,b,c){if("undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=[]),"undefined"==typeof a||0==a.length)for(var d=0;dd;d++)b?c.push(this.getFrame(a[d])):c.push(this.getFrameByName(a[d]));return c},getFrameIndexes:function(a,b,c){if("undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=[]),"undefined"==typeof a||0==a.length)for(var d=0,e=this._frames.length;e>d;d++)c.push(this._frames[d].index);else for(var d=0,e=a.length;e>d;d++)b?c.push(a[d]):this.getFrameByName(a[d])&&c.push(this.getFrameByName(a[d]).index);return c}},Object.defineProperty(e.FrameData.prototype,"total",{get:function(){return this._frames.length}}),e.AnimationParser={spriteSheet:function(a,b,c,f,g){var h=a.cache.getImage(b);if(null==h)return null;var i=h.width,j=h.height;0>=c&&(c=Math.floor(-i/Math.min(-1,c))),0>=f&&(f=Math.floor(-j/Math.min(-1,f)));var k=Math.round(i/c),l=Math.round(j/f),m=k*l;if(-1!==g&&(m=g),0==i||0==j||c>i||f>j||0===m)return console.warn("Phaser.AnimationParser.spriteSheet: width/height zero or width/height < given frameWidth/frameHeight"),null;for(var n=new e.FrameData,o=0,p=0,q=0;m>q;q++){var r=a.rnd.uuid();n.addFrame(new e.Frame(q,o,p,c,f,"",r)),d.TextureCache[r]=new d.Texture(d.BaseTextureCache[b],{x:o,y:p,width:c,height:f}),o+=c,o===i&&(o=0,p+=f)}return n},JSONData:function(a,b,c){if(!b.frames)return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"),console.log(b),void 0;for(var f,g=new e.FrameData,h=b.frames,i=0;i tag"),void 0;for(var f,g,h,i,j,k,l,m,n,o,p,q=new e.FrameData,r=b.getElementsByTagName("SubTexture"),s=0;s0?(this._progressChunk=100/this._keys.length,this.loadFile()):(this.progress=100,this.hasLoaded=!0,this.onLoadComplete.dispatch()))},loadFile:function(){var a=this._fileList[this._keys.shift()],b=this;switch(a.type){case"image":case"spritesheet":case"textureatlas":case"bitmapfont":case"tileset":a.data=new Image,a.data.name=a.key,a.data.onload=function(){return b.fileComplete(a.key)},a.data.onerror=function(){return b.fileError(a.key)},a.data.crossOrigin=this.crossOrigin,a.data.src=this.baseURL+a.url;break;case"audio":a.url=this.getAudioURL(a.url),null!==a.url?this.game.sound.usingWebAudio?(this._xhr.open("GET",this.baseURL+a.url,!0),this._xhr.responseType="arraybuffer",this._xhr.onload=function(){return b.fileComplete(a.key)},this._xhr.onerror=function(){return b.fileError(a.key)},this._xhr.send()):this.game.sound.usingAudioTag&&(this.game.sound.touchLocked?(a.data=new Audio,a.data.name=a.key,a.data.preload="auto",a.data.src=this.baseURL+a.url,this.fileComplete(a.key)):(a.data=new Audio,a.data.name=a.key,a.data.onerror=function(){return b.fileError(a.key)},a.data.preload="auto",a.data.src=this.baseURL+a.url,a.data.addEventListener("canplaythrough",e.GAMES[this.game.id].load.fileComplete(a.key),!1),a.data.load())):this.fileError(a.key);break;case"tilemap":this._xhr.open("GET",this.baseURL+a.url,!0),this._xhr.responseType="text",a.format==e.Tilemap.TILED_JSON?this._xhr.onload=function(){return b.jsonLoadComplete(a.key)}:a.format==e.Tilemap.CSV&&(this._xhr.onload=function(){return b.csvLoadComplete(a.key)}),this._xhr.onerror=function(){return b.dataLoadError(a.key)},this._xhr.send();break;case"text":this._xhr.open("GET",this.baseURL+a.url,!0),this._xhr.responseType="text",this._xhr.onload=function(){return b.fileComplete(a.key)},this._xhr.onerror=function(){return b.fileError(a.key)},this._xhr.send()}},getAudioURL:function(a){for(var b,c=0;c100&&(this.progress=100),null!==this.preloadSprite&&(0==this.preloadSprite.direction?this.preloadSprite.crop.width=Math.floor(this.preloadSprite.width/100*this.progress):this.preloadSprite.crop.height=Math.floor(this.preloadSprite.height/100*this.progress),this.preloadSprite.sprite.crop=this.preloadSprite.crop),this.onFileComplete.dispatch(this.progress,a,b,this.queueSize-this._keys.length,this.queueSize),this._keys.length>0?this.loadFile():(this.hasLoaded=!0,this.isLoading=!1,this.removeAll(),this.onLoadComplete.dispatch())}},e.LoaderParser={bitmapFont:function(a,b,c){if(!b.getElementsByTagName("font"))return console.warn("Phaser.LoaderParser.bitmapFont: Invalid XML given, missing tag"),void 0;var e=d.TextureCache[c],f={},g=b.getElementsByTagName("info")[0],h=b.getElementsByTagName("common")[0];f.font=g.attributes.getNamedItem("face").nodeValue,f.size=parseInt(g.attributes.getNamedItem("size").nodeValue,10),f.lineHeight=parseInt(h.attributes.getNamedItem("lineHeight").nodeValue,10),f.chars={};for(var i=b.getElementsByTagName("char"),j=0;j=this.durationMS&&(this.usingWebAudio?this.loop?(this.onLoop.dispatch(this),""==this.currentMarker?(this.currentTime=0,this.startTime=this.game.time.now):this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop():this.loop?(this.onLoop.dispatch(this),this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop()))},play:function(a,b,c,d,e){if(a=a||"",b=b||0,c=c||1,"undefined"==typeof d&&(d=!1),"undefined"==typeof e&&(e=!0),1!=this.isPlaying||0!=e||0!=this.override){if(this.isPlaying&&this.override&&(this.usingWebAudio?"undefined"==typeof this._sound.stop?this._sound.noteOff(0):this._sound.stop(0):this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0)),this.currentMarker=a,""!==a){if(!this.markers[a])return console.warn("Phaser.Sound.play: audio marker "+a+" doesn't exist"),void 0;this.position=this.markers[a].start,this.volume=this.markers[a].volume,this.loop=this.markers[a].loop,this.duration=this.markers[a].duration,this.durationMS=this.markers[a].durationMS,this._tempMarker=a,this._tempPosition=this.position,this._tempVolume=this.volume,this._tempLoop=this.loop}else this.position=b,this.volume=c,this.loop=d,this.duration=0,this.durationMS=0,this._tempMarker=a,this._tempPosition=b,this._tempVolume=c,this._tempLoop=d;this.usingWebAudio?this.game.cache.isSoundDecoded(this.key)?(null==this._buffer&&(this._buffer=this.game.cache.getSoundData(this.key)),this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this._sound.connect(this.gainNode),this.totalDuration=this._sound.buffer.duration,0==this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this.loop&&""==a&&(this._sound.loop=!0),"undefined"==typeof this._sound.start?this._sound.noteGrainOn(0,this.position,this.duration):this._sound.start(0,this.position,this.duration),this.isPlaying=!0,this.startTime=this.game.time.now,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):(this.pendingPlayback=!0,this.game.cache.getSound(this.key)&&0==this.game.cache.getSound(this.key).isDecoding&&this.game.sound.decode(this.key,this)):this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked?(this.game.cache.reloadSound(this.key),this.pendingPlayback=!0):this._sound&&4==this._sound.readyState?(this._sound.play(),this.totalDuration=this._sound.duration,0==this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this._sound.currentTime=this.position,this._sound.muted=this._muted,this._sound.volume=this._muted?0:this._volume,this.isPlaying=!0,this.startTime=this.game.time.now,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):this.pendingPlayback=!0}},restart:function(a,b,c,d){a=a||"",b=b||0,c=c||1,"undefined"==typeof d&&(d=!1),this.play(a,b,c,d,!0)},pause:function(){this.isPlaying&&this._sound&&(this.stop(),this.isPlaying=!1,this.paused=!0,this.pausedPosition=this.currentTime,this.pausedTime=this.game.time.now,this.onPause.dispatch(this))},resume:function(){if(this.paused&&this._sound){if(this.usingWebAudio){var a=this.position+this.pausedPosition/1e3;this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this._sound.connect(this.gainNode),"undefined"==typeof this._sound.start?this._sound.noteGrainOn(0,a,this.duration):this._sound.start(0,a,this.duration)}else this._sound.play();this.isPlaying=!0,this.paused=!1,this.startTime+=this.game.time.now-this.pausedTime,this.onResume.dispatch(this)}},stop:function(){this.isPlaying&&this._sound&&(this.usingWebAudio?"undefined"==typeof this._sound.stop?this._sound.noteOff(0):this._sound.stop(0):this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0)),this.isPlaying=!1;var a=this.currentMarker;this.currentMarker="",this.onStop.dispatch(this,a)}},Object.defineProperty(e.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}}),Object.defineProperty(e.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}}),Object.defineProperty(e.Sound.prototype,"mute",{get:function(){return this._muted},set:function(a){a=a||null,a?(this._muted=!0,this.usingWebAudio?(this._muteVolume=this.gainNode.gain.value,this.gainNode.gain.value=0):this.usingAudioTag&&this._sound&&(this._muteVolume=this._sound.volume,this._sound.volume=0)):(this._muted=!1,this.usingWebAudio?this.gainNode.gain.value=this._muteVolume:this.usingAudioTag&&this._sound&&(this._sound.volume=this._muteVolume)),this.onMute.dispatch(this)}}),Object.defineProperty(e.Sound.prototype,"volume",{get:function(){return this._volume},set:function(a){this.usingWebAudio?(this._volume=a,this.gainNode.gain.value=a):this.usingAudioTag&&this._sound&&a>=0&&1>=a&&(this._volume=a,this._sound.volume=a)}}),e.SoundManager=function(a){this.game=a,this.onSoundDecode=new e.Signal,this._muted=!1,this._unlockSource=null,this._volume=1,this._sounds=[],this.context=null,this.usingWebAudio=!0,this.usingAudioTag=!1,this.noAudio=!1,this.touchLocked=!1,this.channels=32},e.SoundManager.prototype={boot:function(){if(this.game.device.iOS&&0==this.game.device.webAudio&&(this.channels=1),this.game.device.iOS||window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock?(this.game.input.touch.callbackContext=this,this.game.input.touch.touchStartCallback=this.unlock,this.game.input.mouse.callbackContext=this,this.game.input.mouse.mouseDownCallback=this.unlock,this.touchLocked=!0):this.touchLocked=!1,window.PhaserGlobal){if(1==window.PhaserGlobal.disableAudio)return this.usingWebAudio=!1,this.noAudio=!0,void 0;if(1==window.PhaserGlobal.disableWebAudio)return this.usingWebAudio=!1,this.usingAudioTag=!0,this.noAudio=!1,void 0}window.AudioContext?this.context=new window.AudioContext:window.webkitAudioContext?this.context=new window.webkitAudioContext:window.Audio?(this.usingWebAudio=!1,this.usingAudioTag=!0):(this.usingWebAudio=!1,this.noAudio=!0),null!==this.context&&(this.masterGain="undefined"==typeof this.context.createGain?this.context.createGainNode():this.context.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this.context.destination))},unlock:function(){if(0!=this.touchLocked)if(0==this.game.device.webAudio||window.PhaserGlobal&&1==window.PhaserGlobal.disableWebAudio)this.touchLocked=!1,this._unlockSource=null,this.game.input.touch.callbackContext=null,this.game.input.touch.touchStartCallback=null,this.game.input.mouse.callbackContext=null,this.game.input.mouse.mouseDownCallback=null;else{var a=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource(),this._unlockSource.buffer=a,this._unlockSource.connect(this.context.destination),this._unlockSource.noteOn(0)}},stopAll:function(){for(var a=0;a255)return e.Color.getColor(255,255,255);if(a>b)return e.Color.getColor(255,255,255);var d=a+Math.round(Math.random()*(b-a)),f=a+Math.round(Math.random()*(b-a)),g=a+Math.round(Math.random()*(b-a));return e.Color.getColor32(c,d,f,g)},getRGB:function(a){return{alpha:a>>>24,red:255&a>>16,green:255&a>>8,blue:255&a}},getWebRGB:function(a){var b=(a>>>24)/255,c=255&a>>16,d=255&a>>8,e=255&a;return"rgba("+c.toString()+","+d.toString()+","+e.toString()+","+b.toString()+")"},getAlpha:function(a){return a>>>24},getAlphaFloat:function(a){return(a>>>24)/255},getRed:function(a){return 255&a>>16},getGreen:function(a){return 255&a>>8},getBlue:function(a){return 255&a}},e.Physics={},e.Physics.Arcade=function(a){this.game=a,this.gravity=new e.Point,this.bounds=new e.Rectangle(0,0,a.world.width,a.world.height),this.maxObjects=10,this.maxLevels=4,this.OVERLAP_BIAS=4,this.quadTree=new e.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this.quadTreeID=0,this._bounds1=new e.Rectangle,this._bounds2=new e.Rectangle,this._overlap=0,this._maxOverlap=0,this._velocity1=0,this._velocity2=0,this._newVelocity1=0,this._newVelocity2=0,this._average=0,this._mapData=[],this._mapTiles=0,this._result=!1,this._total=0,this._angle=0,this._dx=0,this._dy=0},e.Physics.Arcade.prototype={updateMotion:function(a){this._velocityDelta=60*.5*(this.computeVelocity(0,a,a.angularVelocity,a.angularAcceleration,a.angularDrag,a.maxAngular)-a.angularVelocity)*this.game.time.physicsElapsed,a.angularVelocity+=this._velocityDelta,a.rotation+=a.angularVelocity*this.game.time.physicsElapsed,a.angularVelocity+=this._velocityDelta,this._velocityDelta=60*.5*(this.computeVelocity(1,a,a.velocity.x,a.acceleration.x,a.drag.x,a.maxVelocity.x)-a.velocity.x)*this.game.time.physicsElapsed,a.velocity.x+=this._velocityDelta,a.x+=a.velocity.x*this.game.time.physicsElapsed,a.velocity.x+=this._velocityDelta,this._velocityDelta=60*.5*(this.computeVelocity(2,a,a.velocity.y,a.acceleration.y,a.drag.y,a.maxVelocity.y)-a.velocity.y)*this.game.time.physicsElapsed,a.velocity.y+=this._velocityDelta,a.y+=a.velocity.y*this.game.time.physicsElapsed,a.velocity.y+=this._velocityDelta},computeVelocity:function(a,b,c,d,e,f){return f=f||1e4,1==a&&b.allowGravity?c+=this.gravity.x+b.gravity.x:2==a&&b.allowGravity&&(c+=this.gravity.y+b.gravity.y),0!==d?c+=d*this.game.time.physicsElapsed:0!==e&&(this._drag=e*this.game.time.physicsElapsed,c-this._drag>0?c-=this._drag:c+this._drag<0?c+=this._drag:c=0),c>f?c=f:-f>c&&(c=-f),c},preUpdate:function(){this.quadTree.clear(),this.quadTreeID=0,this.quadTree=new e.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels)},postUpdate:function(){this.quadTree.clear()},overlap:function(a,b){return a&&b&&a.exists&&b.exists?e.Rectangle.intersects(a.body,b.body):!1},collide:function(a,b,c,d,f){return c=c||null,d=d||null,f=f||c,this._result=!1,this._total=0,a&&b&&a.exists&&b.exists&&(a.type==e.SPRITE?b.type==e.SPRITE?this.collideSpriteVsSprite(a,b,c,d,f):b.type==e.GROUP||b.type==e.EMITTER?this.collideSpriteVsGroup(a,b,c,d,f):b.type==e.TILEMAPLAYER&&this.collideSpriteVsTilemapLayer(a,b,c,d,f):a.type==e.GROUP?b.type==e.SPRITE?this.collideSpriteVsGroup(b,a,c,d,f):b.type==e.GROUP||b.type==e.EMITTER?this.collideGroupVsGroup(a,b,c,d,f):b.type==e.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(a,b,c,d,f):a.type==e.TILEMAPLAYER?b.type==e.SPRITE?this.collideSpriteVsTilemapLayer(b,a,c,d,f):(b.type==e.GROUP||b.type==e.EMITTER)&&this.collideGroupVsTilemapLayer(b,a,c,d,f):a.type==e.EMITTER&&(b.type==e.SPRITE?this.collideSpriteVsGroup(b,a,c,d,f):b.type==e.GROUP||b.type==e.EMITTER?this.collideGroupVsGroup(a,b,c,d,f):b.type==e.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(a,b,c,d,f))),this._total>0},collideSpriteVsTilemapLayer:function(a,b,c,d,e){if(this._mapData=b.getTiles(a.body.x,a.body.y,a.body.width,a.body.height,!0),0!=this._mapData.length)for(var f=0;ff;f++)this._potentials[f].sprite.group==b&&(this.separate(a.body,this._potentials[f]),this._result&&d&&(this._result=d.call(e,a,this._potentials[f].sprite)),this._result&&(this._total++,c&&c.call(e,a,this._potentials[f].sprite)))}},collideGroupVsGroup:function(a,b,c,d,e){if(0!=a.length&&0!=b.length&&a._container.first._iNext){var f=a._container.first._iNext;do f.exists&&this.collideSpriteVsGroup(f,b,c,d,e),f=f._iNext;while(f!=a._container.last._iNext)}},separate:function(a,b){this._result=this.separateX(a,b)||this.separateY(a,b)},separateX:function(a,b){return a.immovable&&b.immovable?!1:(this._overlap=0,e.Rectangle.intersects(a,b)&&(this._maxOverlap=a.deltaAbsX()+b.deltaAbsX()+this.OVERLAP_BIAS,0==a.deltaX()&&0==b.deltaX()?(a.embedded=!0,b.embedded=!0):a.deltaX()>b.deltaX()?(this._overlap=a.x+a.width-b.x,this._overlap>this._maxOverlap||0==a.allowCollision.right||0==b.allowCollision.left?this._overlap=0:(a.touching.right=!0,b.touching.left=!0)):a.deltaX()this._maxOverlap||0==a.allowCollision.left||0==b.allowCollision.right?this._overlap=0:(a.touching.left=!0,b.touching.right=!0)),0!=this._overlap)?(a.overlapX=this._overlap,b.overlapX=this._overlap,a.customSeparateX||b.customSeparateX?!0:(this._velocity1=a.velocity.x,this._velocity2=b.velocity.x,a.immovable||b.immovable?a.immovable?b.immovable||(b.x+=this._overlap,b.velocity.x=this._velocity1-this._velocity2*b.bounce.x):(a.x=a.x-this._overlap,a.velocity.x=this._velocity2-this._velocity1*a.bounce.x):(this._overlap*=.5,a.x=a.x-this._overlap,b.x+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(this._velocity2>0?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(this._velocity1>0?1:-1),this._average=.5*(this._newVelocity1+this._newVelocity2),this._newVelocity1-=this._average,this._newVelocity2-=this._average,a.velocity.x=this._average+this._newVelocity1*a.bounce.x,b.velocity.x=this._average+this._newVelocity2*b.bounce.x),!0)):!1) -},separateY:function(a,b){return a.immovable&&b.immovable?!1:(this._overlap=0,e.Rectangle.intersects(a,b)&&(this._maxOverlap=a.deltaAbsY()+b.deltaAbsY()+this.OVERLAP_BIAS,0==a.deltaY()&&0==b.deltaY()?(a.embedded=!0,b.embedded=!0):a.deltaY()>b.deltaY()?(this._overlap=a.y+a.height-b.y,this._overlap>this._maxOverlap||0==a.allowCollision.down||0==b.allowCollision.up?this._overlap=0:(a.touching.down=!0,b.touching.up=!0)):a.deltaY()this._maxOverlap||0==a.allowCollision.up||0==b.allowCollision.down?this._overlap=0:(a.touching.up=!0,b.touching.down=!0)),0!=this._overlap)?(a.overlapY=this._overlap,b.overlapY=this._overlap,a.customSeparateY||b.customSeparateY?!0:(this._velocity1=a.velocity.y,this._velocity2=b.velocity.y,a.immovable||b.immovable?a.immovable?b.immovable||(b.y+=this._overlap,b.velocity.y=this._velocity1-this._velocity2*b.bounce.y,a.sprite.active&&a.moves&&a.deltaY()b.deltaY()&&(a.x+=b.x-b.lastX)):(this._overlap*=.5,a.y=a.y-this._overlap,b.y+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(this._velocity2>0?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(this._velocity1>0?1:-1),this._average=.5*(this._newVelocity1+this._newVelocity2),this._newVelocity1-=this._average,this._newVelocity2-=this._average,a.velocity.y=this._average+this._newVelocity1*a.bounce.y,b.velocity.y=this._average+this._newVelocity2*b.bounce.y),!0)):!1)},separateTile:function(a,b){this._result=this.separateTileX(a,b,!0)||this.separateTileY(a,b,!0)},separateTileX:function(a,b,c){return a.immovable||0==a.deltaX()||0==e.Rectangle.intersects(a.hullX,b)?!1:(this._overlap=0,a.deltaX()<0?(this._overlap=b.right-a.hullX.x,0==a.allowCollision.left||0==b.tile.collideRight?this._overlap=0:a.touching.left=!0):(this._overlap=a.hullX.right-b.x,0==a.allowCollision.right||0==b.tile.collideLeft?this._overlap=0:a.touching.right=!0),0!=this._overlap?(c&&(a.x=a.deltaX()<0?a.x+this._overlap:a.x-this._overlap,a.velocity.x=0==a.bounce.x?0:-a.velocity.x*a.bounce.x,a.updateHulls()),!0):!1)},separateTileY:function(a,b,c){return a.immovable||0==a.deltaY()||0==e.Rectangle.intersects(a.hullY,b)?!1:(this._overlap=0,a.deltaY()<0?(this._overlap=b.bottom-a.hullY.y,0==a.allowCollision.up||0==b.tile.collideDown?this._overlap=0:a.touching.up=!0):(this._overlap=a.hullY.bottom-b.y,0==a.allowCollision.down||0==b.tile.collideUp?this._overlap=0:a.touching.down=!0),0!=this._overlap?(c&&(a.y=a.deltaY()<0?a.y+this._overlap:a.y-this._overlap,a.velocity.y=0==a.bounce.y?0:-a.velocity.y*a.bounce.y,a.updateHulls()),!0):!1)},moveToObject:function(a,b,c,d){return"undefined"==typeof c&&(c=60),"undefined"==typeof d&&(d=0),this._angle=Math.atan2(b.y-a.y,b.x-a.x),d>0&&(c=this.distanceBetween(a,b)/(d/1e3)),a.body.velocity.x=Math.cos(this._angle)*c,a.body.velocity.y=Math.sin(this._angle)*c,this._angle},moveToPointer:function(a,b,c,d){return"undefined"==typeof b&&(b=60),c=c||this.game.input.activePointer,"undefined"==typeof d&&(d=0),this._angle=this.angleToPointer(a,c),d>0&&(b=this.distanceToPointer(a,c)/(d/1e3)),a.body.velocity.x=Math.cos(this._angle)*b,a.body.velocity.y=Math.sin(this._angle)*b,this._angle},moveToXY:function(a,b,c,d,e){return"undefined"==typeof d&&(d=60),"undefined"==typeof e&&(e=0),this._angle=Math.atan2(c-a.y,b-a.x),e>0&&(d=this.distanceToXY(a,b,c)/(e/1e3)),a.body.velocity.x=Math.cos(this._angle)*d,a.body.velocity.y=Math.sin(this._angle)*d,this._angle},velocityFromAngle:function(a,b,c){return"undefined"==typeof b&&(b=60),c=c||new e.Point,c.setTo(Math.cos(this.game.math.degToRad(a))*b,Math.sin(this.game.math.degToRad(a))*b)},velocityFromRotation:function(a,b,c){return"undefined"==typeof b&&(b=60),c=c||new e.Point,c.setTo(Math.cos(a)*b,Math.sin(a)*b)},accelerationFromRotation:function(a,b,c){return"undefined"==typeof b&&(b=60),c=c||new e.Point,c.setTo(Math.cos(a)*b,Math.sin(a)*b)},accelerateToObject:function(a,b,c,d,e){return"undefined"==typeof c&&(c=60),"undefined"==typeof d&&(d=1e3),"undefined"==typeof e&&(e=1e3),this._angle=this.angleBetween(a,b),a.body.acceleration.setTo(Math.cos(this._angle)*c,Math.sin(this._angle)*c),a.body.maxVelocity.setTo(d,e),this._angle},accelerateToPointer:function(a,b,c,d,e){return"undefined"==typeof c&&(c=60),"undefined"==typeof b&&(b=this.game.input.activePointer),"undefined"==typeof d&&(d=1e3),"undefined"==typeof e&&(e=1e3),this._angle=this.angleToPointer(a,b),a.body.acceleration.setTo(Math.cos(this._angle)*c,Math.sin(this._angle)*c),a.body.maxVelocity.setTo(d,e),this._angle},accelerateToXY:function(a,b,c,d,e,f){return"undefined"==typeof d&&(d=60),"undefined"==typeof e&&(e=1e3),"undefined"==typeof f&&(f=1e3),this._angle=this.angleToXY(a,b,c),a.body.acceleration.setTo(Math.cos(this._angle)*d,Math.sin(this._angle)*d),a.body.maxVelocity.setTo(e,f),this._angle},distanceBetween:function(a,b){return this._dx=a.x-b.x,this._dy=a.y-b.y,Math.sqrt(this._dx*this._dx+this._dy*this._dy)},distanceToXY:function(a,b,c){return this._dx=a.x-b,this._dy=a.y-c,Math.sqrt(this._dx*this._dx+this._dy*this._dy)},distanceToPointer:function(a,b){return b=b||this.game.input.activePointer,this._dx=a.x-b.x,this._dy=a.y-b.y,Math.sqrt(this._dx*this._dx+this._dy*this._dy)},angleBetween:function(a,b){return this._dx=b.x-a.x,this._dy=b.y-a.y,Math.atan2(this._dy,this._dx)},angleToXY:function(a,b,c){return this._dx=b-a.x,this._dy=c-a.y,Math.atan2(this._dy,this._dx)},angleToPointer:function(a,b){return b=b||this.game.input.activePointer,this._dx=b.worldX-a.x,this._dy=b.worldY-a.y,Math.atan2(this._dy,this._dx)}},e.Physics.Arcade.Body=function(a){this.sprite=a,this.game=a.game,this.offset=new e.Point,this.x=a.x,this.y=a.y,this.preX=a.x,this.preY=a.y,this.preRotation=a.angle,this.screenX=a.x,this.screenY=a.y,this.sourceWidth=a.currentFrame.sourceSizeW,this.sourceHeight=a.currentFrame.sourceSizeH,this.width=a.currentFrame.sourceSizeW,this.height=a.currentFrame.sourceSizeH,this.halfWidth=Math.floor(a.currentFrame.sourceSizeW/2),this.halfHeight=Math.floor(a.currentFrame.sourceSizeH/2),this.center=new e.Point(this.x+this.halfWidth,this.y+this.halfHeight),this._sx=a.scale.x,this._sy=a.scale.y,this.velocity=new e.Point,this.acceleration=new e.Point,this.drag=new e.Point,this.gravity=new e.Point,this.bounce=new e.Point,this.maxVelocity=new e.Point(1e4,1e4),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.skipQuadTree=!1,this.quadTreeIDs=[],this.quadTreeIndex=-1,this.allowCollision={none:!1,any:!0,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.facing=e.NONE,this.immovable=!1,this.moves=!0,this.rotation=0,this.allowRotation=!0,this.allowGravity=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.hullX=new e.Rectangle,this.hullY=new e.Rectangle,this.embedded=!1,this.collideWorldBounds=!1},e.Physics.Arcade.Body.prototype={updateBounds:function(a,b,c,d){(c!=this._sx||d!=this._sy)&&(this.width=this.sourceWidth*c,this.height=this.sourceHeight*d,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this._sx=c,this._sy=d,this.center.setTo(this.x+this.halfWidth,this.y+this.halfHeight))},preUpdate:function(){this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.embedded=!1,this.screenX=this.sprite.worldTransform[2]-this.sprite.anchor.x*this.width+this.offset.x,this.screenY=this.sprite.worldTransform[5]-this.sprite.anchor.y*this.height+this.offset.y,this.preX=this.sprite.world.x-this.sprite.anchor.x*this.width+this.offset.x,this.preY=this.sprite.world.y-this.sprite.anchor.y*this.height+this.offset.y,this.preRotation=this.sprite.angle,this.x=this.preX,this.y=this.preY,this.rotation=this.preRotation,this.moves&&(this.game.physics.updateMotion(this),this.collideWorldBounds&&this.checkWorldBounds(),this.updateHulls()),0==this.skipQuadTree&&0==this.allowCollision.none&&this.sprite.visible&&this.sprite.alive&&(this.quadTreeIDs=[],this.quadTreeIndex=-1,this.game.physics.quadTree.insert(this))},postUpdate:function(){this.deltaX()<0?this.facing=e.LEFT:this.deltaX()>0&&(this.facing=e.RIGHT),this.deltaY()<0?this.facing=e.UP:this.deltaY()>0&&(this.facing=e.DOWN),(0!==this.deltaX()||0!==this.deltaY())&&(this.sprite.x+=this.deltaX(),this.sprite.y+=this.deltaY(),this.center.setTo(this.x+this.halfWidth,this.y+this.halfHeight)),this.allowRotation&&(this.sprite.angle+=this.deltaZ())},updateHulls:function(){this.hullX.setTo(this.x,this.preY,this.width,this.height),this.hullY.setTo(this.preX,this.y,this.width,this.height)},checkWorldBounds:function(){this.xthis.game.world.bounds.right&&(this.x=this.game.world.bounds.right-this.width,this.velocity.x*=-this.bounce.x),this.ythis.game.world.bounds.bottom&&(this.y=this.game.world.bounds.bottom-this.height,this.velocity.y*=-this.bounce.y)},setSize:function(a,b,c,d){c=c||this.offset.x,d=d||this.offset.y,this.sourceWidth=a,this.sourceHeight=b,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.setTo(c,d),this.center.setTo(this.x+this.halfWidth,this.y+this.halfHeight)},reset:function(){this.velocity.setTo(0,0),this.acceleration.setTo(0,0),this.angularVelocity=0,this.angularAcceleration=0,this.preX=this.sprite.world.x-this.sprite.anchor.x*this.width+this.offset.x,this.preY=this.sprite.world.y-this.sprite.anchor.y*this.height+this.offset.y,this.preRotation=this.sprite.angle,this.x=this.preX,this.y=this.preY,this.rotation=this.preRotation,this.center.setTo(this.x+this.halfWidth,this.y+this.halfHeight)},deltaAbsX:function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},deltaAbsY:function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},deltaX:function(){return this.x-this.preX},deltaY:function(){return this.y-this.preY},deltaZ:function(){return this.rotation-this.preRotation}},Object.defineProperty(e.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){this.height=a<=this.y?0:this.y-a}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"right",{get:function(){return this.x+this.width},set:function(a){this.width=a<=this.x?0:this.x+a}}),e.Particles=function(){this.emitters={},this.ID=0},e.Particles.prototype={add:function(a){return this.emitters[a.name]=a,a},remove:function(a){delete this.emitters[a.name]},update:function(){for(var a in this.emitters)this.emitters[a].exists&&this.emitters[a].update()}},e.Particles.Arcade={},e.Particles.Arcade.Emitter=function(a,b,c,d){this.maxParticles=d||50,e.Group.call(this,a),this.name="emitter"+this.game.particles.ID++,this.type=e.EMITTER,this.x=0,this.y=0,this.width=1,this.height=1,this.minParticleSpeed=new e.Point(-100,-100),this.maxParticleSpeed=new e.Point(100,100),this.minParticleScale=1,this.maxParticleScale=1,this.minRotation=-360,this.maxRotation=360,this.gravity=2,this.particleClass=null,this.particleDrag=new e.Point,this.angularDrag=0,this.frequency=100,this.lifespan=2e3,this.bounce=new e.Point,this._quantity=0,this._timer=0,this._counter=0,this._explode=!0,this.on=!1,this.exists=!0,this.emitX=b,this.emitY=c},e.Particles.Arcade.Emitter.prototype=Object.create(e.Group.prototype),e.Particles.Arcade.Emitter.prototype.constructor=e.Particles.Arcade.Emitter,e.Particles.Arcade.Emitter.prototype.update=function(){if(this.on)if(this._explode){this._counter=0;do this.emitParticle(),this._counter++;while(this._counter=this._timer&&(this.emitParticle(),this._counter++,this._quantity>0&&this._counter>=this._quantity&&(this.on=!1),this._timer=this.game.time.now+this.frequency)},e.Particles.Arcade.Emitter.prototype.makeParticles=function(a,b,c,d,f){"undefined"==typeof b&&(b=0),c=c||this.maxParticles,d=d||0,"undefined"==typeof f&&(f=!1);for(var g,h=0,i=a,j=0;c>h;)null==this.particleClass&&("object"==typeof a&&(i=this.game.rnd.pick(a)),"object"==typeof b&&(j=this.game.rnd.pick(b)),g=new e.Sprite(this.game,0,0,i,j)),d>0?(g.body.allowCollision.any=!0,g.body.allowCollision.none=!1):g.body.allowCollision.none=!0,g.body.collideWorldBounds=f,g.exists=!1,g.visible=!1,g.anchor.setTo(.5,.5),this.add(g),h++;return this},e.Particles.Arcade.Emitter.prototype.kill=function(){this.on=!1,this.alive=!1,this.exists=!1},e.Particles.Arcade.Emitter.prototype.revive=function(){this.alive=!0,this.exists=!0},e.Particles.Arcade.Emitter.prototype.start=function(a,b,c,d){"boolean"!=typeof a&&(a=!0),b=b||0,c=c||250,d=d||0,this.revive(),this.visible=!0,this.on=!0,this._explode=a,this.lifespan=b,this.frequency=c,a?this._quantity=d:this._quantity+=d,this._counter=0,this._timer=this.game.time.now+c},e.Particles.Arcade.Emitter.prototype.emitParticle=function(){var a=this.getFirstExists(!1);if(null!=a){if(this.width>1||this.height>1?a.reset(this.game.rnd.integerInRange(this.left,this.right),this.game.rnd.integerInRange(this.top,this.bottom)):a.reset(this.emitX,this.emitY),a.lifespan=this.lifespan,a.body.bounce.setTo(this.bounce.x,this.bounce.y),a.body.velocity.x=this.minParticleSpeed.x!=this.maxParticleSpeed.x?this.game.rnd.integerInRange(this.minParticleSpeed.x,this.maxParticleSpeed.x):this.minParticleSpeed.x,a.body.velocity.y=this.minParticleSpeed.y!=this.maxParticleSpeed.y?this.game.rnd.integerInRange(this.minParticleSpeed.y,this.maxParticleSpeed.y):this.minParticleSpeed.y,a.body.gravity.y=this.gravity,a.body.angularVelocity=this.minRotation!=this.maxRotation?this.game.rnd.integerInRange(this.minRotation,this.maxRotation):this.minRotation,1!==this.minParticleScale||1!==this.maxParticleScale){var b=this.game.rnd.realInRange(this.minParticleScale,this.maxParticleScale);a.scale.setTo(b,b)}a.body.drag.x=this.particleDrag.x,a.body.drag.y=this.particleDrag.y,a.body.angularDrag=this.angularDrag}},e.Particles.Arcade.Emitter.prototype.setSize=function(a,b){this.width=a,this.height=b},e.Particles.Arcade.Emitter.prototype.setXSpeed=function(a,b){a=a||0,b=b||0,this.minParticleSpeed.x=a,this.maxParticleSpeed.x=b},e.Particles.Arcade.Emitter.prototype.setYSpeed=function(a,b){a=a||0,b=b||0,this.minParticleSpeed.y=a,this.maxParticleSpeed.y=b},e.Particles.Arcade.Emitter.prototype.setRotation=function(a,b){a=a||0,b=b||0,this.minRotation=a,this.maxRotation=b},e.Particles.Arcade.Emitter.prototype.at=function(a){this.emitX=a.center.x,this.emitY=a.center.y},Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"alpha",{get:function(){return this._container.alpha},set:function(a){this._container.alpha=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"visible",{get:function(){return this._container.visible},set:function(a){this._container.visible=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"x",{get:function(){return this.emitX},set:function(a){this.emitX=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"y",{get:function(){return this.emitY},set:function(a){this.emitY=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"left",{get:function(){return Math.floor(this.x-this.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"right",{get:function(){return Math.floor(this.x+this.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"top",{get:function(){return Math.floor(this.y-this.height/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return Math.floor(this.y+this.height/2)}}),e.Tile=function(a,b,c,d,e,f){this.tileset=a,this.index=b,this.width=e,this.height=f,this.x=c,this.y=d,this.mass=1,this.collideNone=!0,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.separateX=!0,this.separateY=!0,this.collisionCallback=null,this.collisionCallbackContext=this},e.Tile.prototype={setCollisionCallback:function(a,b){this.collisionCallbackContext=b,this.collisionCallback=a},destroy:function(){this.tileset=null},setCollision:function(a,b,c,d){this.collideLeft=a,this.collideRight=b,this.collideUp=c,this.collideDown=d,this.collideNone=a||b||c||d?!1:!0},resetCollision:function(){this.collideNone=!0,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1}},Object.defineProperty(e.Tile.prototype,"bottom",{get:function(){return this.y+this.height}}),Object.defineProperty(e.Tile.prototype,"right",{get:function(){return this.x+this.width}}),e.Tilemap=function(a,b){this.game=a,this.layers,"string"==typeof b?(this.key=b,this.layers=a.cache.getTilemapData(b).layers,this.calculateIndexes()):this.layers=[],this.currentLayer=0,this.debugMap=[],this.dirty=!1,this._results=[],this._tempA=0,this._tempB=0},e.Tilemap.CSV=0,e.Tilemap.TILED_JSON=1,e.Tilemap.prototype={create:function(a,b,c){for(var d=[],f=0;c>f;f++){d[f]=[];for(var g=0;b>g;g++)d[f][g]=0}this.currentLayer=this.layers.push({name:a,width:b,height:c,alpha:1,visible:!0,tileMargin:0,tileSpacing:0,format:e.Tilemap.CSV,data:d,indexes:[]}),this.dirty=!0},calculateIndexes:function(){for(var a=0;a=0&&b=0&&c=0&&a=0&&b=0&&a=0&&b=0&&b=0&&ca&&(a=0),0>b&&(b=0),c>this.layers[e].width&&(c=this.layers[e].width),d>this.layers[e].height&&(d=this.layers[e].height),this._results.length=0,this._results.push({x:a,y:b,width:c,height:d,layer:e});for(var f=b;b+d>f;f++)for(var g=a;a+c>g;g++)this._results.push({x:g,y:f,index:this.layers[e].data[f][g]});return this._results},paste:function(a,b,c,d){if("undefined"==typeof a&&(a=0),"undefined"==typeof b&&(b=0),"undefined"==typeof d&&(d=this.currentLayer),c&&!(c.length<2)){for(var e=c[1].x-a,f=c[1].y-b,g=1;g1?this.debugMap[this.layers[this.currentLayer].data[c][d]]?b.push("background: "+this.debugMap[this.layers[this.currentLayer].data[c][d]]):b.push("background: #ffffff"):b.push("background: rgb(0, 0, 0)");a+="\n"}b[0]=a,console.log.apply(console,b)},destroy:function(){this.removeAllLayers(),this.game=null}},e.TilemapLayer=function(a,b,c,f,g,h,i,j){this.game=a,this.canvas=e.Canvas.create(f,g),this.context=this.canvas.getContext("2d"),this.baseTexture=new d.BaseTexture(this.canvas),this.texture=new d.Texture(this.baseTexture),this.textureFrame=new e.Frame(0,0,0,f,g,"tilemaplayer",a.rnd.uuid()),e.Sprite.call(this,this.game,b,c,this.texture,this.textureFrame),this.type=e.TILEMAPLAYER,this.fixedToCamera=!0,this.tileset=null,this.tileWidth=0,this.tileHeight=0,this.tileMargin=0,this.tileSpacing=0,this.widthInPixels=0,this.heightInPixels=0,this.renderWidth=f,this.renderHeight=g,this._ga=1,this._dx=0,this._dy=0,this._dw=0,this._dh=0,this._tx=0,this._ty=0,this._results=[],this._tw=0,this._th=0,this._tl=0,this._maxX=0,this._maxY=0,this._startX=0,this._startY=0,this.tilemap=null,this.layer=null,this.index=0,this._x=0,this._y=0,this._prevX=0,this._prevY=0,this.dirty=!0,(h instanceof e.Tileset||"string"==typeof h)&&this.updateTileset(h),i instanceof e.Tilemap&&this.updateMapData(i,j)},e.TilemapLayer.prototype=Object.create(e.Sprite.prototype),e.TilemapLayer.prototype=e.Utils.extend(!0,e.TilemapLayer.prototype,e.Sprite.prototype,d.Sprite.prototype),e.TilemapLayer.prototype.constructor=e.TilemapLayer,e.TilemapLayer.prototype.update=function(){this.scrollX=this.game.camera.x,this.scrollY=this.game.camera.y,this.render()},e.TilemapLayer.prototype.resizeWorld=function(){this.game.world.setBounds(0,0,this.widthInPixels,this.heightInPixels)},e.TilemapLayer.prototype.updateTileset=function(a){if(a instanceof e.Tileset)this.tileset=a;else{if("string"!=typeof a)return;this.tileset=this.game.cache.getTileset("tiles")}this.tileWidth=this.tileset.tileWidth,this.tileHeight=this.tileset.tileHeight,this.tileMargin=this.tileset.tileMargin,this.tileSpacing=this.tileset.tileSpacing,this.updateMax()},e.TilemapLayer.prototype.updateMapData=function(a,b){"undefined"==typeof b&&(b=0),a instanceof e.Tilemap&&(this.tilemap=a,this.layer=this.tilemap.layers[b],this.index=b,this.updateMax(),this.tilemap.dirty=!0)},e.TilemapLayer.prototype.getTileX=function(a){var b=this.tileWidth*this.scale.x;return this.game.math.snapToFloor(a,b)/b},e.TilemapLayer.prototype.getTileY=function(a){var b=this.tileHeight*this.scale.y;return this.game.math.snapToFloor(a,b)/b},e.TilemapLayer.prototype.getTileXY=function(a,b,c){return c.x=this.getTileX(a),c.y=this.getTileY(b),c},e.TilemapLayer.prototype.getTiles=function(a,b,c,d,e){if(null!==this.tilemap){"undefined"==typeof e&&(e=!1),0>a&&(a=0),0>b&&(b=0),c>this.widthInPixels&&(c=this.widthInPixels),d>this.heightInPixels&&(d=this.heightInPixels);var f=this.tileWidth*this.scale.x,g=this.tileHeight*this.scale.y;this._tx=this.game.math.snapToFloor(a,f)/f,this._ty=this.game.math.snapToFloor(b,g)/g,this._tw=(this.game.math.snapToCeil(c,f)+f)/f,this._th=(this.game.math.snapToCeil(d,g)+g)/g,this._results=[];for(var h=0,i=null,j=0,k=0,l=this._ty;lthis.layer.width&&(this._maxX=this.layer.width),this._maxY>this.layer.height&&(this._maxY=this.layer.height),this.widthInPixels=this.layer.width*this.tileWidth,this.heightInPixels=this.layer.height*this.tileHeight),this.dirty=!0},e.TilemapLayer.prototype.render=function(){if(this.tilemap&&this.tilemap.dirty&&(this.dirty=!0),this.dirty&&this.tileset&&this.tilemap&&this.visible){this._prevX=this._dx,this._prevY=this._dy,this._dx=-(this._x-this._startX*this.tileWidth),this._dy=-(this._y-this._startY*this.tileHeight),this._tx=this._dx,this._ty=this._dy,this.context.clearRect(0,0,this.canvas.width,this.canvas.height);for(var a=this._startY;a0?this.deltaX():-this.deltaX()},e.TilemapLayer.prototype.deltaAbsY=function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},e.TilemapLayer.prototype.deltaX=function(){return this._dx-this._prevX},e.TilemapLayer.prototype.deltaY=function(){return this._dy-this._prevY},Object.defineProperty(e.TilemapLayer.prototype,"scrollX",{get:function(){return this._x},set:function(a){a!==this._x&&a>=0&&this.layer&&(this._x=a,this._x>this.widthInPixels-this.renderWidth&&(this._x=this.widthInPixels-this.renderWidth),this._startX=this.game.math.floor(this._x/this.tileWidth),this._startX<0&&(this._startX=0),this._startX+this._maxX>this.layer.width&&(this._startX=this.layer.width-this._maxX),this.dirty=!0)}}),Object.defineProperty(e.TilemapLayer.prototype,"scrollY",{get:function(){return this._y},set:function(a){a!==this._y&&a>=0&&this.layer&&(this._y=a,this._y>this.heightInPixels-this.renderHeight&&(this._y=this.heightInPixels-this.renderHeight),this._startY=this.game.math.floor(this._y/this.tileHeight),this._startY<0&&(this._startY=0),this._startY+this._maxY>this.layer.height&&(this._startY=this.layer.height-this._maxY),this.dirty=!0)}}),e.TilemapParser={tileset:function(a,b,c,d,f,g,h){var i=a.cache.getTilesetImage(b);if(null==i)return null;var j=i.width,k=i.height;0>=c&&(c=Math.floor(-j/Math.min(-1,c))),0>=d&&(d=Math.floor(-k/Math.min(-1,d)));var l=Math.round(j/c),m=Math.round(k/d),n=l*m;if(-1!==f&&(n=f),0==j||0==k||c>j||d>k||0===n)return console.warn("Phaser.TilemapParser.tileSet: width/height zero or width/height < given tileWidth/tileHeight"),null;for(var o=g,p=g,q=new e.Tileset(i,b,c,d,g,h),r=0;n>r;r++)q.addTile(new e.Tile(q,r,o,p,c,d)),o+=c+h,o===j&&(o=g,p+=d+h);return q},parse:function(a,b,c){return c===e.Tilemap.CSV?this.parseCSV(b):c===e.Tilemap.TILED_JSON?this.parseTiledJSON(b):void 0},parseCSV:function(a){a=a.trim();for(var b=[],c=a.split("\n"),d=c.length,e=0,f=0;fa)for(var g=a;b>=g;g++)this.tiles[g].setCollision(c,d,e,f)},setCollision:function(a,b,c,d,e){this.tiles[a]&&this.tiles[a].setCollision(b,c,d,e)}},Object.defineProperty(e.Tileset.prototype,"total",{get:function(){return this.tiles.length}}),d.CanvasRenderer.prototype.renderDisplayObject=function(a){var b,c=this.context;c.globalCompositeOperation="source-over";var e=a.last._iNext;a=a.first;do if(b=a.worldTransform,a.visible)if(a.renderable&&0!=a.alpha){if(a instanceof d.Sprite){var f=a.texture.frame;f&&(c.globalAlpha=a.worldAlpha,a.texture.trimmed?c.setTransform(b[0],b[3],b[1],b[4],b[2]+a.texture.trim.x,b[5]+a.texture.trim.y):c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),c.drawImage(a.texture.baseTexture.source,f.x,f.y,f.width,f.height,a.anchor.x*-f.width,a.anchor.y*-f.height,f.width,f.height))}else if(a instanceof d.Strip)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),this.renderStrip(a);else if(a instanceof d.TilingSprite)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),this.renderTilingSprite(a);else if(a instanceof d.CustomRenderable)a.renderCanvas(this);else if(a instanceof d.Graphics)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),d.CanvasGraphics.renderGraphics(a,c);else if(a instanceof d.FilterBlock)if(a.open){c.save();var g=a.mask.alpha,h=a.mask.worldTransform;c.setTransform(h[0],h[3],h[1],h[4],h[2],h[5]),a.mask.worldAlpha=.5,c.worldAlpha=0,d.CanvasGraphics.renderGraphicsMask(a.mask,c),c.clip(),a.mask.worldAlpha=g}else c.restore();a=a._iNext}else a=a._iNext;else a=a.last._iNext;while(a!=e)},d.WebGLBatch.prototype.update=function(){this.gl;for(var a,b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r=0,s=this.head;s;){if(s.vcount===d.visibleCount){if(b=s.texture.frame.width,c=s.texture.frame.height,e=s.anchor.x,f=s.anchor.y,g=b*(1-e),h=b*-e,i=c*(1-f),j=c*-f,k=8*r,a=s.worldTransform,l=a[0],m=a[3],n=a[1],o=a[4],p=a[2],q=a[5],s.texture.trimmed&&(p+=s.texture.trim.x,q+=s.texture.trim.y),this.verticies[k+0]=l*h+n*j+p,this.verticies[k+1]=o*j+m*h+q,this.verticies[k+2]=l*g+n*j+p,this.verticies[k+3]=o*j+m*g+q,this.verticies[k+4]=l*g+n*i+p,this.verticies[k+5]=o*i+m*g+q,this.verticies[k+6]=l*h+n*i+p,this.verticies[k+7]=o*i+m*h+q,s.updateFrame||s.texture.updateFrame){this.dirtyUVS=!0;var t=s.texture,u=t.frame,v=t.baseTexture.width,w=t.baseTexture.height;this.uvs[k+0]=u.x/v,this.uvs[k+1]=u.y/w,this.uvs[k+2]=(u.x+u.width)/v,this.uvs[k+3]=u.y/w,this.uvs[k+4]=(u.x+u.width)/v,this.uvs[k+5]=(u.y+u.height)/w,this.uvs[k+6]=u.x/v,this.uvs[k+7]=(u.y+u.height)/w,s.updateFrame=!1 -}if(s.cacheAlpha!=s.worldAlpha){s.cacheAlpha=s.worldAlpha;var x=4*r;this.colors[x]=this.colors[x+1]=this.colors[x+2]=this.colors[x+3]=s.worldAlpha,this.dirtyColors=!0}}else k=8*r,this.verticies[k+0]=0,this.verticies[k+1]=0,this.verticies[k+2]=0,this.verticies[k+3]=0,this.verticies[k+4]=0,this.verticies[k+5]=0,this.verticies[k+6]=0,this.verticies[k+7]=0;r++,s=s.__next}},e}); \ No newline at end of file +k=e[2*(H-2)],l=e[2*(H-2)+1],m=e[2*(H-1)],n=e[2*(H-1)+1],q=-(l-n),r=k-m,E=Math.sqrt(q*q+r*r),q/=E,r/=E,q*=K,r*=K,F.push(m-q,n-r),F.push(N,O,P,M),F.push(m+q,n+r),F.push(N,O,P,M),G.push(J);for(var f=0;I>f;f++)G.push(J++);G.push(J-1)}},d.WebGLGraphics.buildPoly=function(a,c){var e=a.points;if(!(e.length<6)){for(var f=c.points,g=c.indices,h=e.length/2,i=b(a.fillColor),j=a.fillAlpha,k=i[0]*j,l=i[1]*j,m=i[2]*j,n=d.PolyK.Triangulate(e),o=f.length/6,p=0;pp;p++)f.push(e[2*p],e[2*p+1],k,l,m,j)}},d._defaultFrame=new d.Rectangle(0,0,1,1),d.gl,d.WebGLRenderer=function(a,b,c,e,f){this.transparent=!!e,this.width=a||800,this.height=b||600,this.view=c||document.createElement("canvas"),this.view.width=this.width,this.view.height=this.height;var g=this;this.view.addEventListener("webglcontextlost",function(a){g.handleContextLost(a)},!1),this.view.addEventListener("webglcontextrestored",function(a){g.handleContextRestored(a)},!1),this.batchs=[];var h={alpha:this.transparent,antialias:!!f,premultipliedAlpha:!1,stencil:!0};try{d.gl=this.gl=this.view.getContext("experimental-webgl",h)}catch(i){try{d.gl=this.gl=this.view.getContext("webgl",h)}catch(i){throw new Error(" This browser does not support webGL. Try using the canvas renderer"+this)}}d.initDefaultShaders();var j=this.gl;j.useProgram(d.defaultShader.program),d.WebGLRenderer.gl=j,this.batch=new d.WebGLBatch(j),j.disable(j.DEPTH_TEST),j.disable(j.CULL_FACE),j.enable(j.BLEND),j.colorMask(!0,!0,!0,this.transparent),d.projection=new d.Point(400,300),d.offset=new d.Point(0,0),this.resize(this.width,this.height),this.contextLost=!1,this.stageRenderGroup=new d.WebGLRenderGroup(this.gl,this.transparent)},d.WebGLRenderer.prototype.constructor=d.WebGLRenderer,d.WebGLRenderer.getBatch=function(){return 0==d._batchs.length?new d.WebGLBatch(d.WebGLRenderer.gl):d._batchs.pop()},d.WebGLRenderer.returnBatch=function(a){a.clean(),d._batchs.push(a)},d.WebGLRenderer.prototype.render=function(a){if(!this.contextLost){this.__stage!==a&&(this.__stage=a,this.stageRenderGroup.setRenderable(a)),d.WebGLRenderer.updateTextures(),d.visibleCount++,a.updateTransform();var b=this.gl;if(b.colorMask(!0,!0,!0,this.transparent),b.viewport(0,0,this.width,this.height),b.bindFramebuffer(b.FRAMEBUFFER,null),b.clearColor(a.backgroundColorSplit[0],a.backgroundColorSplit[1],a.backgroundColorSplit[2],!this.transparent),b.clear(b.COLOR_BUFFER_BIT),this.stageRenderGroup.backgroundColor=a.backgroundColorSplit,d.projection.x=this.width/2,d.projection.y=-this.height/2,this.stageRenderGroup.render(d.projection),a.interactive&&(a._interactiveEventsAdded||(a._interactiveEventsAdded=!0,a.interactionManager.setTarget(this))),d.Texture.frameUpdates.length>0){for(var c=0;cn;n++)renderable=this.batchs[n],renderable instanceof d.WebGLBatch?this.batchs[n].render():this.renderSpecial(renderable,b);endBatch instanceof d.WebGLBatch?endBatch.render(0,h+1):this.renderSpecial(endBatch,b)},d.WebGLRenderGroup.prototype.renderSpecial=function(a,b){var c=a.vcount===d.visibleCount;a instanceof d.TilingSprite?c&&this.renderTilingSprite(a,b):a instanceof d.Strip?c&&this.renderStrip(a,b):a instanceof d.CustomRenderable?c&&a.renderWebGL(this,b):a instanceof d.Graphics?c&&a.renderable&&d.WebGLGraphics.renderGraphics(a,b):a instanceof d.FilterBlock&&this.handleFilterBlock(a,b)},flip=!1;var f=[],g=0;return d.WebGLRenderGroup.prototype.handleFilterBlock=function(a,b){var c=d.gl;if(a.open)a.data instanceof Array?this.filterManager.pushFilter(a):(g++,f.push(a),c.enable(c.STENCIL_TEST),c.colorMask(!1,!1,!1,!1),c.stencilFunc(c.ALWAYS,1,1),c.stencilOp(c.KEEP,c.KEEP,c.INCR),d.WebGLGraphics.renderGraphics(a.data,b),c.colorMask(!0,!0,!0,!0),c.stencilFunc(c.NOTEQUAL,0,f.length),c.stencilOp(c.KEEP,c.KEEP,c.KEEP));else if(a.data instanceof Array)this.filterManager.popFilter();else{var e=f.pop(a);e&&(c.colorMask(!1,!1,!1,!1),c.stencilFunc(c.ALWAYS,1,1),c.stencilOp(c.KEEP,c.KEEP,c.DECR),d.WebGLGraphics.renderGraphics(e.data,b),c.colorMask(!0,!0,!0,!0),c.stencilFunc(c.NOTEQUAL,0,f.length),c.stencilOp(c.KEEP,c.KEEP,c.KEEP)),c.disable(c.STENCIL_TEST)}},d.WebGLRenderGroup.prototype.updateTexture=function(a){this.removeObject(a);for(var b=a.first;b!=this.root&&(b=b._iPrev,!b.renderable||!b.__renderGroup););for(var c=a.last;c._iNext&&(c=c._iNext,!c.renderable||!c.__renderGroup););this.insertObject(a,b,c)},d.WebGLRenderGroup.prototype.addFilterBlocks=function(a,b){a.__renderGroup=this,b.__renderGroup=this;for(var c=a;c!=this.root.first&&(c=c._iPrev,!c.renderable||!c.__renderGroup););this.insertAfter(a,c);for(var d=b;d!=this.root.first&&(d=d._iPrev,!d.renderable||!d.__renderGroup););this.insertAfter(b,d)},d.WebGLRenderGroup.prototype.removeFilterBlocks=function(a,b){this.removeObject(a),this.removeObject(b)},d.WebGLRenderGroup.prototype.addDisplayObjectAndChildren=function(a){a.__renderGroup&&a.__renderGroup.removeDisplayObjectAndChildren(a);for(var b=a.first;b!=this.root.first&&(b=b._iPrev,!b.renderable||!b.__renderGroup););for(var c=a.last;c._iNext&&(c=c._iNext,!c.renderable||!c.__renderGroup););var d=a.first,e=a.last._iNext;do d.__renderGroup=this,d.renderable&&(this.insertObject(d,b,c),b=d),d=d._iNext;while(d!=e)},d.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren=function(a){if(a.__renderGroup==this){a.last;do a.__renderGroup=null,a.renderable&&this.removeObject(a),a=a._iNext;while(a)}},d.WebGLRenderGroup.prototype.insertObject=function(a,b,c){var e=b,f=c;if(a instanceof d.Sprite){var g,h;if(e instanceof d.Sprite){if(g=e.batch,g&&g.texture==a.texture.baseTexture&&g.blendMode==a.blendMode)return g.insertAfter(a,e),void 0}else g=e;if(f)if(f instanceof d.Sprite){if(h=f.batch){if(h.texture==a.texture.baseTexture&&h.blendMode==a.blendMode)return h.insertBefore(a,f),void 0;if(h==g){var i=g.split(f),j=d.WebGLRenderer.getBatch(),k=this.batchs.indexOf(g);return j.init(a),this.batchs.splice(k+1,0,j,i),void 0}}}else h=f;var j=d.WebGLRenderer.getBatch();if(j.init(a),g){var k=this.batchs.indexOf(g);this.batchs.splice(k+1,0,j)}else this.batchs.push(j)}else a instanceof d.TilingSprite?this.initTilingSprite(a):a instanceof d.Strip&&this.initStrip(a),this.insertAfter(a,e)},d.WebGLRenderGroup.prototype.insertAfter=function(a,b){if(b instanceof d.Sprite){var c=b.batch;if(c)if(c.tail==b){var e=this.batchs.indexOf(c);this.batchs.splice(e+1,0,a)}else{var f=c.split(b.__next),e=this.batchs.indexOf(c);this.batchs.splice(e+1,0,a,f)}else this.batchs.push(a)}else{var e=this.batchs.indexOf(b);this.batchs.splice(e+1,0,a)}},d.WebGLRenderGroup.prototype.removeObject=function(a){var b;if(a instanceof d.Sprite){var c=a.batch;if(!c)return;c.remove(a),0==c.size&&(b=c)}else b=a;if(b){var e=this.batchs.indexOf(b);if(-1==e)return;if(0==e||e==this.batchs.length-1)return this.batchs.splice(e,1),b instanceof d.WebGLBatch&&d.WebGLRenderer.returnBatch(b),void 0;if(this.batchs[e-1]instanceof d.WebGLBatch&&this.batchs[e+1]instanceof d.WebGLBatch&&this.batchs[e-1].texture==this.batchs[e+1].texture&&this.batchs[e-1].blendMode==this.batchs[e+1].blendMode)return this.batchs[e-1].merge(this.batchs[e+1]),b instanceof d.WebGLBatch&&d.WebGLRenderer.returnBatch(b),d.WebGLRenderer.returnBatch(this.batchs[e+1]),this.batchs.splice(e,2),void 0;this.batchs.splice(e,1),b instanceof d.WebGLBatch&&d.WebGLRenderer.returnBatch(b)}},d.WebGLRenderGroup.prototype.initTilingSprite=function(a){var b=this.gl;a.verticies=new Float32Array([0,0,a.width,0,a.width,a.height,0,a.height]),a.uvs=new Float32Array([0,0,1,0,1,1,0,1]),a.colors=new Float32Array([1,1,1,1]),a.indices=new Uint16Array([0,1,3,2]),a._vertexBuffer=b.createBuffer(),a._indexBuffer=b.createBuffer(),a._uvBuffer=b.createBuffer(),a._colorBuffer=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,a._vertexBuffer),b.bufferData(b.ARRAY_BUFFER,a.verticies,b.STATIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._uvBuffer),b.bufferData(b.ARRAY_BUFFER,a.uvs,b.DYNAMIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._colorBuffer),b.bufferData(b.ARRAY_BUFFER,a.colors,b.STATIC_DRAW),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,a._indexBuffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,a.indices,b.STATIC_DRAW),a.texture.baseTexture._glTexture?(b.bindTexture(b.TEXTURE_2D,a.texture.baseTexture._glTexture),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.REPEAT),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.REPEAT),a.texture.baseTexture._powerOf2=!0):a.texture.baseTexture._powerOf2=!0},d.WebGLRenderGroup.prototype.renderStrip=function(a,b){var c=this.gl;d.activateStripShader();var e=d.stripShader;e.program;var f=d.mat3.clone(a.worldTransform);d.mat3.transpose(f),c.uniformMatrix3fv(e.translationMatrix,!1,f),c.uniform2f(e.projectionVector,b.x,b.y),c.uniform2f(e.offsetVector,-d.offset.x,-d.offset.y),c.uniform1f(e.alpha,a.worldAlpha),a.dirty?(a.dirty=!1,c.bindBuffer(c.ARRAY_BUFFER,a._vertexBuffer),c.bufferData(c.ARRAY_BUFFER,a.verticies,c.STATIC_DRAW),c.vertexAttribPointer(e.aVertexPosition,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,a._uvBuffer),c.bufferData(c.ARRAY_BUFFER,a.uvs,c.STATIC_DRAW),c.vertexAttribPointer(e.aTextureCoord,2,c.FLOAT,!1,0,0),c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,a.texture.baseTexture._glTexture),c.bindBuffer(c.ARRAY_BUFFER,a._colorBuffer),c.bufferData(c.ARRAY_BUFFER,a.colors,c.STATIC_DRAW),c.vertexAttribPointer(e.colorAttribute,1,c.FLOAT,!1,0,0),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,a._indexBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,a.indices,c.STATIC_DRAW)):(c.bindBuffer(c.ARRAY_BUFFER,a._vertexBuffer),c.bufferSubData(c.ARRAY_BUFFER,0,a.verticies),c.vertexAttribPointer(e.aVertexPosition,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,a._uvBuffer),c.vertexAttribPointer(e.aTextureCoord,2,c.FLOAT,!1,0,0),c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,a.texture.baseTexture._glTexture),c.bindBuffer(c.ARRAY_BUFFER,a._colorBuffer),c.vertexAttribPointer(e.colorAttribute,1,c.FLOAT,!1,0,0),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,a._indexBuffer)),c.drawElements(c.TRIANGLE_STRIP,a.indices.length,c.UNSIGNED_SHORT,0),d.deactivateStripShader()},d.WebGLRenderGroup.prototype.renderTilingSprite=function(a,b){var c=this.gl;d.shaderProgram;var e=a.tilePosition,f=a.tileScale,g=e.x/a.texture.baseTexture.width,h=e.y/a.texture.baseTexture.height,i=a.width/a.texture.baseTexture.width/f.x,j=a.height/a.texture.baseTexture.height/f.y;a.uvs[0]=0-g,a.uvs[1]=0-h,a.uvs[2]=1*i-g,a.uvs[3]=0-h,a.uvs[4]=1*i-g,a.uvs[5]=1*j-h,a.uvs[6]=0-g,a.uvs[7]=1*j-h,c.bindBuffer(c.ARRAY_BUFFER,a._uvBuffer),c.bufferSubData(c.ARRAY_BUFFER,0,a.uvs),this.renderStrip(a,b)},d.WebGLRenderGroup.prototype.initStrip=function(a){var b=this.gl;this.shaderProgram,a._vertexBuffer=b.createBuffer(),a._indexBuffer=b.createBuffer(),a._uvBuffer=b.createBuffer(),a._colorBuffer=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,a._vertexBuffer),b.bufferData(b.ARRAY_BUFFER,a.verticies,b.DYNAMIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._uvBuffer),b.bufferData(b.ARRAY_BUFFER,a.uvs,b.STATIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._colorBuffer),b.bufferData(b.ARRAY_BUFFER,a.colors,b.STATIC_DRAW),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,a._indexBuffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,a.indices,b.STATIC_DRAW)},d.initDefaultShaders=function(){d.primitiveShader=new d.PrimitiveShader,d.primitiveShader.init(),d.stripShader=new d.StripShader,d.stripShader.init(),d.defaultShader=new d.PixiShader,d.defaultShader.init();var a=d.gl,b=d.defaultShader.program;a.useProgram(b),a.enableVertexAttribArray(d.defaultShader.aVertexPosition),a.enableVertexAttribArray(d.defaultShader.colorAttribute),a.enableVertexAttribArray(d.defaultShader.aTextureCoord)},d.activatePrimitiveShader=function(){var a=d.gl;a.useProgram(d.primitiveShader.program),a.disableVertexAttribArray(d.defaultShader.aVertexPosition),a.disableVertexAttribArray(d.defaultShader.colorAttribute),a.disableVertexAttribArray(d.defaultShader.aTextureCoord),a.enableVertexAttribArray(d.primitiveShader.aVertexPosition),a.enableVertexAttribArray(d.primitiveShader.colorAttribute)},d.deactivatePrimitiveShader=function(){var a=d.gl;a.useProgram(d.defaultShader.program),a.disableVertexAttribArray(d.primitiveShader.aVertexPosition),a.disableVertexAttribArray(d.primitiveShader.colorAttribute),a.enableVertexAttribArray(d.defaultShader.aVertexPosition),a.enableVertexAttribArray(d.defaultShader.colorAttribute),a.enableVertexAttribArray(d.defaultShader.aTextureCoord)},d.activateStripShader=function(){var a=d.gl;a.useProgram(d.stripShader.program)},d.deactivateStripShader=function(){var a=d.gl;a.useProgram(d.defaultShader.program)},d.CompileVertexShader=function(a,b){return d._CompileShader(a,b,a.VERTEX_SHADER)},d.CompileFragmentShader=function(a,b){return d._CompileShader(a,b,a.FRAGMENT_SHADER)},d._CompileShader=function(a,b,c){var d=b.join("\n"),e=a.createShader(c);return a.shaderSource(e,d),a.compileShader(e),a.getShaderParameter(e,a.COMPILE_STATUS)?e:null},d.compileProgram=function(a,b){var c=d.gl,e=d.CompileFragmentShader(c,b),f=d.CompileVertexShader(c,a),g=c.createProgram();return c.attachShader(g,f),c.attachShader(g,e),c.linkProgram(g),c.getProgramParameter(g,c.LINK_STATUS)||console.log("Could not initialise shaders"),g},d.BitmapText=function(a,b){d.DisplayObjectContainer.call(this),this.setText(a),this.setStyle(b),this.updateText(),this.dirty=!1},d.BitmapText.prototype=Object.create(d.DisplayObjectContainer.prototype),d.BitmapText.prototype.constructor=d.BitmapText,d.BitmapText.prototype.setText=function(a){this.text=a||" ",this.dirty=!0},d.BitmapText.prototype.setStyle=function(a){a=a||{},a.align=a.align||"left",this.style=a;var b=a.font.split(" ");this.fontName=b[b.length-1],this.fontSize=b.length>=2?parseInt(b[b.length-2],10):d.BitmapText.fonts[this.fontName].size,this.dirty=!0},d.BitmapText.prototype.updateText=function(){for(var a=d.BitmapText.fonts[this.fontName],b=new d.Point,c=null,e=[],f=0,g=[],h=0,i=this.fontSize/a.size,j=0;j=j;j++){var n=0;"right"==this.style.align?n=f-g[j]:"center"==this.style.align&&(n=(f-g[j])/2),m.push(n)}for(j=0;j0;)this.removeChild(this.getChildAt(0));this.updateText(),this.dirty=!1}d.DisplayObjectContainer.prototype.updateTransform.call(this)},d.BitmapText.fonts={},d.Text=function(a,b){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),d.Sprite.call(this,d.Texture.fromCanvas(this.canvas)),this.setText(a),this.setStyle(b),this.updateText(),this.dirty=!1},d.Text.prototype=Object.create(d.Sprite.prototype),d.Text.prototype.constructor=d.Text,d.Text.prototype.setStyle=function(a){a=a||{},a.font=a.font||"bold 20pt Arial",a.fill=a.fill||"black",a.align=a.align||"left",a.stroke=a.stroke||"black",a.strokeThickness=a.strokeThickness||0,a.wordWrap=a.wordWrap||!1,a.wordWrapWidth=a.wordWrapWidth||100,this.style=a,this.dirty=!0},d.Text.prototype.setText=function(a){this.text=a.toString()||" ",this.dirty=!0},d.Text.prototype.updateText=function(){this.context.font=this.style.font;var a=this.text;this.style.wordWrap&&(a=this.wordWrap(this.text));for(var b=a.split(/(?:\r\n|\r|\n)/),c=[],e=0,f=0;fe?(g>0&&(b+="\n"),b+=f[g]+" ",e=this.style.wordWrapWidth-h):(e-=i,b+=f[g]+" ")}b+="\n"}return b},d.Text.prototype.destroy=function(a){a&&this.texture.destroy()},d.Text.heightCache={},d.BaseTextureCache={},d.texturesToUpdate=[],d.texturesToDestroy=[],d.BaseTexture=function(a){if(d.EventTarget.call(this),this.width=100,this.height=100,this.hasLoaded=!1,this.source=a,a){if(this.source instanceof Image||this.source instanceof HTMLImageElement)if(this.source.complete)this.hasLoaded=!0,this.width=this.source.width,this.height=this.source.height,d.texturesToUpdate.push(this);else{var b=this;this.source.onload=function(){b.hasLoaded=!0,b.width=b.source.width,b.height=b.source.height,d.texturesToUpdate.push(b),b.dispatchEvent({type:"loaded",content:b})}}else this.hasLoaded=!0,this.width=this.source.width,this.height=this.source.height,d.texturesToUpdate.push(this);this._powerOf2=!1}},d.BaseTexture.prototype.constructor=d.BaseTexture,d.BaseTexture.prototype.destroy=function(){this.source instanceof Image&&(this.source.src=null),this.source=null,d.texturesToDestroy.push(this)},d.BaseTexture.fromImage=function(a,b){var c=d.BaseTextureCache[a];if(!c){var e=new Image;b&&(e.crossOrigin=""),e.src=a,c=new d.BaseTexture(e),d.BaseTextureCache[a]=c}return c},d.TextureCache={},d.FrameCache={},d.Texture=function(a,b){if(d.EventTarget.call(this),b||(this.noFrame=!0,b=new d.Rectangle(0,0,1,1)),a instanceof d.Texture&&(a=a.baseTexture),this.baseTexture=a,this.frame=b,this.trim=new d.Point,this.scope=this,a.hasLoaded)this.noFrame&&(b=new d.Rectangle(0,0,a.width,a.height)),this.setFrame(b);else{var c=this;a.addEventListener("loaded",function(){c.onBaseTextureLoaded()})}},d.Texture.prototype.constructor=d.Texture,d.Texture.prototype.onBaseTextureLoaded=function(){var a=this.baseTexture;a.removeEventListener("loaded",this.onLoaded),this.noFrame&&(this.frame=new d.Rectangle(0,0,a.width,a.height)),this.noFrame=!1,this.width=this.frame.width,this.height=this.frame.height,this.scope.dispatchEvent({type:"update",content:this})},d.Texture.prototype.destroy=function(a){a&&this.baseTexture.destroy()},d.Texture.prototype.setFrame=function(a){if(this.frame=a,this.width=a.width,this.height=a.height,a.x+a.width>this.baseTexture.width||a.y+a.height>this.baseTexture.height)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.updateFrame=!0,d.Texture.frameUpdates.push(this)},d.Texture.fromImage=function(a,b){var c=d.TextureCache[a];return c||(c=new d.Texture(d.BaseTexture.fromImage(a,b)),d.TextureCache[a]=c),c},d.Texture.fromFrame=function(a){var b=d.TextureCache[a];if(!b)throw new Error("The frameId '"+a+"' does not exist in the texture cache "+this);return b},d.Texture.fromCanvas=function(a){var b=new d.BaseTexture(a);return new d.Texture(b)},d.Texture.addTextureToCache=function(a,b){d.TextureCache[b]=a},d.Texture.removeTextureFromCache=function(a){var b=d.TextureCache[a];return d.TextureCache[a]=null,b},d.Texture.frameUpdates=[],d.RenderTexture=function(a,b){d.EventTarget.call(this),this.width=a||100,this.height=b||100,this.indetityMatrix=d.mat3.create(),this.frame=new d.Rectangle(0,0,this.width,this.height),d.gl?this.initWebGL():this.initCanvas()},d.RenderTexture.prototype=Object.create(d.Texture.prototype),d.RenderTexture.prototype.constructor=d.RenderTexture,d.RenderTexture.prototype.initWebGL=function(){var a=d.gl;this.glFramebuffer=a.createFramebuffer(),a.bindFramebuffer(a.FRAMEBUFFER,this.glFramebuffer),this.glFramebuffer.width=this.width,this.glFramebuffer.height=this.height,this.baseTexture=new d.BaseTexture,this.baseTexture.width=this.width,this.baseTexture.height=this.height,this.baseTexture._glTexture=a.createTexture(),a.bindTexture(a.TEXTURE_2D,this.baseTexture._glTexture),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,this.width,this.height,0,a.RGBA,a.UNSIGNED_BYTE,null),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),this.baseTexture.isRender=!0,a.bindFramebuffer(a.FRAMEBUFFER,this.glFramebuffer),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,this.baseTexture._glTexture,0),this.projection=new d.Point(this.width/2,-this.height/2),this.render=this.renderWebGL},d.RenderTexture.prototype.resize=function(a,b){if(this.width=a,this.height=b,d.gl){this.projection.x=this.width/2,this.projection.y=-this.height/2;var c=d.gl;c.bindTexture(c.TEXTURE_2D,this.baseTexture._glTexture),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,this.width,this.height,0,c.RGBA,c.UNSIGNED_BYTE,null)}else this.frame.width=this.width,this.frame.height=this.height,this.renderer.resize(this.width,this.height)},d.RenderTexture.prototype.initCanvas=function(){this.renderer=new d.CanvasRenderer(this.width,this.height,null,0),this.baseTexture=new d.BaseTexture(this.renderer.view),this.frame=new d.Rectangle(0,0,this.width,this.height),this.render=this.renderCanvas},d.RenderTexture.prototype.renderWebGL=function(a,b,c){var e=d.gl;e.colorMask(!0,!0,!0,!0),e.viewport(0,0,this.width,this.height),e.bindFramebuffer(e.FRAMEBUFFER,this.glFramebuffer),c&&(e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT));var f=a.children,g=a.worldTransform;a.worldTransform=d.mat3.create(),a.worldTransform[4]=-1,a.worldTransform[5]=-2*this.projection.y,b&&(a.worldTransform[2]=b.x,a.worldTransform[5]-=b.y),d.visibleCount++,a.vcount=d.visibleCount;for(var h=0,i=f.length;i>h;h++)f[h].updateTransform();var j=a.__renderGroup;j?a==j.root?j.render(this.projection,this.glFramebuffer):j.renderSpecific(a,this.projection,this.glFramebuffer):(this.renderGroup||(this.renderGroup=new d.WebGLRenderGroup(e)),this.renderGroup.setRenderable(a),this.renderGroup.render(this.projection,this.glFramebuffer)),a.worldTransform=g},d.RenderTexture.prototype.renderCanvas=function(a,b,c){var e=a.children;a.worldTransform=d.mat3.create(),b&&(a.worldTransform[2]=b.x,a.worldTransform[5]=b.y);for(var f=0,g=e.length;g>f;f++)e[f].updateTransform();c&&this.renderer.context.clearRect(0,0,this.width,this.height),this.renderer.renderDisplayObject(a),this.renderer.context.setTransform(1,0,0,1,0,0)},d.EventTarget=function(){var a={};this.addEventListener=this.on=function(b,c){void 0===a[b]&&(a[b]=[]),-1===a[b].indexOf(c)&&a[b].push(c)},this.dispatchEvent=this.emit=function(b){if(a[b.type]&&a[b.type].length)for(var c=0,d=a[b.type].length;d>c;c++)a[b.type][c](b)},this.removeEventListener=this.off=function(b,c){var d=a[b].indexOf(c);-1!==d&&a[b].splice(d,1)}},d.PolyK={},d.PolyK.Triangulate=function(a){var b=!0,c=a.length>>1;if(3>c)return[];for(var e=[],f=[],g=0;c>g;g++)f.push(g);for(var g=0,h=c;h>3;){var i=f[(g+0)%h],j=f[(g+1)%h],k=f[(g+2)%h],l=a[2*i],m=a[2*i+1],n=a[2*j],o=a[2*j+1],p=a[2*k],q=a[2*k+1],r=!1;if(d.PolyK._convex(l,m,n,o,p,q,b)){r=!0;for(var s=0;h>s;s++){var t=f[s];if(t!=i&&t!=j&&t!=k&&d.PolyK._PointInTriangle(a[2*t],a[2*t+1],l,m,n,o,p,q)){r=!1;break}}}if(r)e.push(i,j,k),f.splice((g+1)%h,1),h--,g=0;else if(g++>3*h){if(!b)return console.log("PIXI Warning: shape too complex to fill"),[];var e=[];f=[];for(var g=0;c>g;g++)f.push(g);g=0,h=c,b=!1}}return e.push(f[0],f[1],f[2]),e},d.PolyK._PointInTriangle=function(a,b,c,d,e,f,g,h){var i=g-c,j=h-d,k=e-c,l=f-d,m=a-c,n=b-d,o=i*i+j*j,p=i*k+j*l,q=i*m+j*n,r=k*k+l*l,s=k*m+l*n,t=1/(o*r-p*p),u=(r*q-p*s)*t,v=(o*s-p*q)*t;return u>=0&&v>=0&&1>u+v},d.PolyK._convex=function(a,b,c,d,e,f,g){return(b-d)*(e-c)+(c-a)*(f-d)>=0==g},e.Camera=function(a,b,c,d,f,g){this.game=a,this.world=a.world,this.id=0,this.view=new e.Rectangle(c,d,f,g),this.screenView=new e.Rectangle(c,d,f,g),this.bounds=new e.Rectangle(c,d,f,g),this.deadzone=null,this.visible=!0,this.atLimit={x:!1,y:!1},this.target=null,this._edge=0,this.displayObject=null},e.Camera.FOLLOW_LOCKON=0,e.Camera.FOLLOW_PLATFORMER=1,e.Camera.FOLLOW_TOPDOWN=2,e.Camera.FOLLOW_TOPDOWN_TIGHT=3,e.Camera.prototype={follow:function(a,b){"undefined"==typeof b&&(b=e.Camera.FOLLOW_LOCKON),this.target=a;var c;switch(b){case e.Camera.FOLLOW_PLATFORMER:var d=this.width/8,f=this.height/3;this.deadzone=new e.Rectangle((this.width-d)/2,(this.height-f)/2-.25*f,d,f);break;case e.Camera.FOLLOW_TOPDOWN:c=Math.max(this.width,this.height)/4,this.deadzone=new e.Rectangle((this.width-c)/2,(this.height-c)/2,c,c);break;case e.Camera.FOLLOW_TOPDOWN_TIGHT:c=Math.max(this.width,this.height)/8,this.deadzone=new e.Rectangle((this.width-c)/2,(this.height-c)/2,c,c);break;case e.Camera.FOLLOW_LOCKON:default:this.deadzone=null}},focusOn:function(a){this.setPosition(Math.round(a.x-this.view.halfWidth),Math.round(a.y-this.view.halfHeight))},focusOnXY:function(a,b){this.setPosition(Math.round(a-this.view.halfWidth),Math.round(b-this.view.halfHeight))},update:function(){this.target&&this.updateTarget(),this.bounds&&this.checkBounds(),this.displayObject.position.x=-this.view.x,this.displayObject.position.y=-this.view.y},updateTarget:function(){this.deadzone?(this._edge=this.target.x-this.deadzone.x,this.view.x>this._edge&&(this.view.x=this._edge),this._edge=this.target.x+this.target.width-this.deadzone.x-this.deadzone.width,this.view.xthis._edge&&(this.view.y=this._edge),this._edge=this.target.y+this.target.height-this.deadzone.y-this.deadzone.height,this.view.ythis.bounds.right-this.width&&(this.atLimit.x=!0,this.view.x=this.bounds.right-this.width+1),this.view.ythis.bounds.bottom-this.height&&(this.atLimit.y=!0,this.view.y=this.bounds.bottom-this.height+1),this.view.floor()},setPosition:function(a,b){this.view.x=a,this.view.y=b,this.bounds&&this.checkBounds()},setSize:function(a,b){this.view.width=a,this.view.height=b}},Object.defineProperty(e.Camera.prototype,"x",{get:function(){return this.view.x},set:function(a){this.view.x=a,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"y",{get:function(){return this.view.y},set:function(a){this.view.y=a,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"width",{get:function(){return this.view.width},set:function(a){this.view.width=a}}),Object.defineProperty(e.Camera.prototype,"height",{get:function(){return this.view.height},set:function(a){this.view.height=a}}),e.State=function(){this.game=null,this.add=null,this.camera=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.particles=null,this.physics=null +},e.State.prototype={preload:function(){},loadUpdate:function(){},loadRender:function(){},create:function(){},update:function(){},render:function(){},paused:function(){},destroy:function(){}},e.StateManager=function(a,b){this.game=a,this.states={},null!==b&&(this._pendingState=b)},e.StateManager.prototype={game:null,_pendingState:null,_created:!1,states:{},current:"",onInitCallback:null,onPreloadCallback:null,onCreateCallback:null,onUpdateCallback:null,onRenderCallback:null,onPreRenderCallback:null,onLoadUpdateCallback:null,onLoadRenderCallback:null,onPausedCallback:null,onShutDownCallback:null,boot:function(){null!==this._pendingState&&("string"==typeof this._pendingState?this.start(this._pendingState,!1,!1):this.add("default",this._pendingState,!0))},add:function(a,b,c){"undefined"==typeof c&&(c=!1);var d;return b instanceof e.State?d=b:"object"==typeof b?(d=b,d.game=this.game):"function"==typeof b&&(d=new b(this.game)),this.states[a]=d,c&&(this.game.isBooted?this.start(a):this._pendingState=a),d},remove:function(a){this.current==a&&(this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onPausedCallback=null,this.onDestroyCallback=null),delete this.states[a]},start:function(a,b,c){return"undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=!1),0==this.game.isBooted?(this._pendingState=a,void 0):(0!=this.checkState(a)&&(this.current&&this.onShutDownCallback.call(this.callbackContext,this.game),b&&(this.game.tweens.removeAll(),this.game.world.destroy(),1==c&&this.game.cache.destroy()),this.setCurrentState(a),this.onPreloadCallback?(this.game.load.reset(),this.onPreloadCallback.call(this.callbackContext,this.game),0==this.game.load.queueSize?this.game.loadComplete():this.game.load.start()):this.game.loadComplete()),void 0)},dummy:function(){},checkState:function(a){if(this.states[a]){var b=!1;return this.states[a].preload&&(b=!0),0==b&&this.states[a].loadRender&&(b=!0),0==b&&this.states[a].loadUpdate&&(b=!0),0==b&&this.states[a].create&&(b=!0),0==b&&this.states[a].update&&(b=!0),0==b&&this.states[a].preRender&&(b=!0),0==b&&this.states[a].render&&(b=!0),0==b&&this.states[a].paused&&(b=!0),0==b?(console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions."),!1):!0}return console.warn("Phaser.StateManager - No state found with the key: "+a),!1},link:function(a){this.states[a].game=this.game,this.states[a].add=this.game.add,this.states[a].camera=this.game.camera,this.states[a].cache=this.game.cache,this.states[a].input=this.game.input,this.states[a].load=this.game.load,this.states[a].math=this.game.math,this.states[a].sound=this.game.sound,this.states[a].stage=this.game.stage,this.states[a].time=this.game.time,this.states[a].tweens=this.game.tweens,this.states[a].world=this.game.world,this.states[a].particles=this.game.particles,this.states[a].physics=this.game.physics,this.states[a].rnd=this.game.rnd},setCurrentState:function(a){this.callbackContext=this.states[a],this.link(a),this.onInitCallback=this.states[a].init||this.dummy,this.onPreloadCallback=this.states[a].preload||null,this.onLoadRenderCallback=this.states[a].loadRender||null,this.onLoadUpdateCallback=this.states[a].loadUpdate||null,this.onCreateCallback=this.states[a].create||null,this.onUpdateCallback=this.states[a].update||null,this.onPreRenderCallback=this.states[a].preRender||null,this.onRenderCallback=this.states[a].render||null,this.onPausedCallback=this.states[a].paused||null,this.onShutDownCallback=this.states[a].shutdown||this.dummy,this.current=a,this._created=!1,this.onInitCallback.call(this.callbackContext,this.game)},loadComplete:function(){0==this._created&&this.onCreateCallback?(this._created=!0,this.onCreateCallback.call(this.callbackContext,this.game)):this._created=!0},update:function(){this._created&&this.onUpdateCallback?this.onUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},preRender:function(){this.onPreRenderCallback&&this.onPreRenderCallback.call(this.callbackContext,this.game)},render:function(){this._created&&this.onRenderCallback?(this.game.renderType===e.CANVAS&&(this.game.context.save(),this.game.context.setTransform(1,0,0,1,0,0)),this.onRenderCallback.call(this.callbackContext,this.game),this.game.renderType===e.CANVAS&&this.game.context.restore()):this.onLoadRenderCallback&&this.onLoadRenderCallback.call(this.callbackContext,this.game)},destroy:function(){this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onPausedCallback=null,this.onDestroyCallback=null,this.game=null,this.states={},this._pendingState=null}},e.LinkedList=function(){this.next=null,this.prev=null,this.first=null,this.last=null,this.total=0},e.LinkedList.prototype={add:function(a){return 0==this.total&&null==this.first&&null==this.last?(this.first=a,this.last=a,this.next=a,a.prev=this,this.total++,a):(this.last.next=a,a.prev=this.last,this.last=a,this.total++,a)},remove:function(a){a==this.first?this.first=this.first.next:a==this.last&&(this.last=this.last.prev),a.prev&&(a.prev.next=a.next),a.next&&(a.next.prev=a.prev),a.next=a.prev=null,null==this.first&&(this.last=null),this.total--},callAll:function(a){if(this.first&&this.last){var b=this.first;do b&&b[a]&&b[a].call(b),b=b.next;while(b!=this.last.next)}}},e.Signal=function(){this._bindings=[],this._prevParams=null;var a=this;this.dispatch=function(){e.Signal.prototype.dispatch.apply(a,arguments)}},e.Signal.prototype={memorize:!1,_shouldPropagate:!0,active:!0,validateListener:function(a,b){if("function"!=typeof a)throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",b))},_registerListener:function(a,b,c,d){var f,g=this._indexOfListener(a,c);if(-1!==g){if(f=this._bindings[g],f.isOnce()!==b)throw new Error("You cannot add"+(b?"":"Once")+"() then add"+(b?"Once":"")+"() the same listener without removing the relationship first.")}else f=new e.SignalBinding(this,a,b,c,d),this._addBinding(f);return this.memorize&&this._prevParams&&f.execute(this._prevParams),f},_addBinding:function(a){var b=this._bindings.length;do--b;while(this._bindings[b]&&a._priority<=this._bindings[b]._priority);this._bindings.splice(b+1,0,a)},_indexOfListener:function(a,b){for(var c,d=this._bindings.length;d--;)if(c=this._bindings[d],c._listener===a&&c.context===b)return d;return-1},has:function(a,b){return-1!==this._indexOfListener(a,b)},add:function(a,b,c){return this.validateListener(a,"add"),this._registerListener(a,!1,b,c)},addOnce:function(a,b,c){return this.validateListener(a,"addOnce"),this._registerListener(a,!0,b,c)},remove:function(a,b){this.validateListener(a,"remove");var c=this._indexOfListener(a,b);return-1!==c&&(this._bindings[c]._destroy(),this._bindings.splice(c,1)),a},removeAll:function(){for(var a=this._bindings.length;a--;)this._bindings[a]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(){if(this.active){var a,b=Array.prototype.slice.call(arguments),c=this._bindings.length;if(this.memorize&&(this._prevParams=b),c){a=this._bindings.slice(),this._shouldPropagate=!0;do c--;while(a[c]&&this._shouldPropagate&&a[c].execute(b)!==!1)}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(),delete this._bindings,delete this._prevParams},toString:function(){return"[Phaser.Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}},e.SignalBinding=function(a,b,c,d,e){this._listener=b,this._isOnce=c,this.context=d,this._signal=a,this._priority=e||0},e.SignalBinding.prototype={active:!0,params:null,execute:function(a){var b,c;return this.active&&this._listener&&(c=this.params?this.params.concat(a):a,b=this._listener.apply(this.context,c),this._isOnce&&this.detach()),b},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[Phaser.SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},e.Plugin=function(a,b){"undefined"==typeof b&&(b=null),this.game=a,this.parent=b,this.active=!1,this.visible=!1,this.hasPreUpdate=!1,this.hasUpdate=!1,this.hasPostUpdate=!1,this.hasRender=!1,this.hasPostRender=!1},e.Plugin.prototype={preUpdate:function(){},update:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null,this.parent=null,this.active=!1,this.visible=!1}},e.PluginManager=function(a,b){this.game=a,this._parent=b,this.plugins=[],this._pluginsLength=0},e.PluginManager.prototype={add:function(a){var b=!1;return"function"==typeof a?a=new a(this.game,this._parent):(a.game=this.game,a.parent=this._parent),"function"==typeof a.preUpdate&&(a.hasPreUpdate=!0,b=!0),"function"==typeof a.update&&(a.hasUpdate=!0,b=!0),"function"==typeof a.postUpdate&&(a.hasPostUpdate=!0,b=!0),"function"==typeof a.render&&(a.hasRender=!0,b=!0),"function"==typeof a.postRender&&(a.hasPostRender=!0,b=!0),b?((a.hasPreUpdate||a.hasUpdate)&&(a.active=!0),(a.hasRender||a.hasPostRender)&&(a.visible=!0),this._pluginsLength=this.plugins.push(a),"function"==typeof a.init&&a.init(),a):null},remove:function(a){if(0!=this._pluginsLength)for(this._p=0;this._pthis._nextOffsetCheck&&(e.Canvas.getOffset(this.canvas,this.offset),this._nextOffsetCheck=this.game.time.now+this.checkOffsetInterval)},visibilityChange:function(a){this.disableVisibilityChange||(this.game.paused="pagehide"==a.type||"blur"==a.type||1==document.hidden||1==document.webkitHidden?!0:!1)}},Object.defineProperty(e.Stage.prototype,"backgroundColor",{get:function(){return this._backgroundColor},set:function(a){this._backgroundColor=a,this.game.renderType==e.CANVAS?this._stage.backgroundColorString=a:("string"==typeof a&&(a=e.Color.hexToRGB(a)),this._stage.setBackgroundColor(a))}}),e.Group=function(a,b,c,f){("undefined"==typeof b||null===typeof b)&&(b=a.world),"undefined"==typeof f&&(f=!1),this.game=a,this.name=c||"group",f?this._container=this.game.stage._stage:(this._container=new d.DisplayObjectContainer,this._container.name=this.name,b?b instanceof e.Group?(b._container.addChild(this._container),b._container.updateTransform()):(b.addChild(this._container),b.updateTransform()):(this.game.stage._stage.addChild(this._container),this.game.stage._stage.updateTransform())),this.type=e.GROUP,this.exists=!0,this.scale=new e.Point(1,1),this.cursor=null},e.Group.RETURN_NONE=0,e.Group.RETURN_TOTAL=1,e.Group.RETURN_CHILD=2,e.Group.SORT_ASCENDING=-1,e.Group.SORT_DESCENDING=1,e.Group.prototype={add:function(a){return a.group!==this&&(a.group=this,a.events&&a.events.onAddedToGroup.dispatch(a,this),this._container.addChild(a),a.updateTransform(),null===this.cursor&&(this.cursor=a)),a},addAt:function(a,b){return a.group!==this&&(a.group=this,a.events&&a.events.onAddedToGroup.dispatch(a,this),this._container.addChildAt(a,b),a.updateTransform(),null===this.cursor&&(this.cursor=a)),a},getAt:function(a){return this._container.getChildAt(a)},create:function(a,b,c,d,f){"undefined"==typeof f&&(f=!0);var g=new e.Sprite(this.game,a,b,c,d);return g.group=this,g.exists=f,g.visible=f,g.alive=f,g.events&&g.events.onAddedToGroup.dispatch(g,this),this._container.addChild(g),g.updateTransform(),null===this.cursor&&(this.cursor=g),g},createMultiple:function(a,b,c,d){"undefined"==typeof d&&(d=!1);for(var f=0;a>f;f++){var g=new e.Sprite(this.game,0,0,b,c);g.group=this,g.exists=d,g.visible=d,g.alive=d,g.events&&g.events.onAddedToGroup.dispatch(g,this),this._container.addChild(g),g.updateTransform(),null===this.cursor&&(this.cursor=g)}},next:function(){this.cursor&&(this.cursor=this.cursor==this._container.last?this._container._iNext:this.cursor._iNext)},previous:function(){this.cursor&&(this.cursor=this.cursor==this._container._iNext?this._container.last:this.cursor._iPrev)},childTest:function(a,b){var c=a+" next: ";c+=b._iNext?b._iNext.name:"-null-",c=c+" "+a+" prev: ",c+=b._iPrev?b._iPrev.name:"-null-",console.log(c)},swapIndex:function(a,b){var c=this.getAt(a),d=this.getAt(b);console.log("swapIndex ",a," with ",b),this.swap(c,d)},swap:function(a,b){if(a===b||!a.parent||!b.parent||a.group!==this||b.group!==this)return!1;var c=a._iPrev,d=a._iNext,e=b._iPrev,f=b._iNext,g=this._container.last._iNext,h=this.game.stage._stage;do h!==a&&h!==b&&(h.first===a?h.first=b:h.first===b&&(h.first=a),h.last===a?h.last=b:h.last===b&&(h.last=a)),h=h._iNext;while(h!=g);return a._iNext==b?(a._iNext=f,a._iPrev=b,b._iNext=a,b._iPrev=c,c&&(c._iNext=b),f&&(f._iPrev=a),a.__renderGroup&&a.__renderGroup.updateTexture(a),b.__renderGroup&&b.__renderGroup.updateTexture(b),!0):b._iNext==a?(a._iNext=b,a._iPrev=e,b._iNext=d,b._iPrev=a,e&&(e._iNext=a),d&&(d._iPrev=b),a.__renderGroup&&a.__renderGroup.updateTexture(a),b.__renderGroup&&b.__renderGroup.updateTexture(b),!0):(a._iNext=f,a._iPrev=e,b._iNext=d,b._iPrev=c,c&&(c._iNext=b),d&&(d._iPrev=b),e&&(e._iNext=a),f&&(f._iPrev=a),a.__renderGroup&&a.__renderGroup.updateTexture(a),b.__renderGroup&&b.__renderGroup.updateTexture(b),!0)},bringToTop:function(a){return a.group===this&&(this.remove(a),this.add(a)),a},getIndex:function(a){return this._container.children.indexOf(a)},replace:function(a,b){if(this._container.first._iNext){var c=this.getIndex(a);-1!=c&&(void 0!=b.parent&&(b.events.onRemovedFromGroup.dispatch(b,this),b.parent.removeChild(b)),this._container.removeChild(a),this._container.addChildAt(b,c),b.events.onAddedToGroup.dispatch(b,this),b.updateTransform(),this.cursor==a&&(this.cursor=this._container._iNext))}},setProperty:function(a,b,c,d){d=d||0;var e=b.length;1==e?0==d?a[b[0]]=c:1==d?a[b[0]]+=c:2==d?a[b[0]]-=c:3==d?a[b[0]]*=c:4==d&&(a[b[0]]/=c):2==e?0==d?a[b[0]][b[1]]=c:1==d?a[b[0]][b[1]]+=c:2==d?a[b[0]][b[1]]-=c:3==d?a[b[0]][b[1]]*=c:4==d&&(a[b[0]][b[1]]/=c):3==e?0==d?a[b[0]][b[1]][b[2]]=c:1==d?a[b[0]][b[1]][b[2]]+=c:2==d?a[b[0]][b[1]][b[2]]-=c:3==d?a[b[0]][b[1]][b[2]]*=c:4==d&&(a[b[0]][b[1]][b[2]]/=c):4==e&&(0==d?a[b[0]][b[1]][b[2]][b[3]]=c:1==d?a[b[0]][b[1]][b[2]][b[3]]+=c:2==d?a[b[0]][b[1]][b[2]][b[3]]-=c:3==d?a[b[0]][b[1]][b[2]][b[3]]*=c:4==d&&(a[b[0]][b[1]][b[2]][b[3]]/=c))},setAll:function(a,b,c,d,e){if(a=a.split("."),"undefined"==typeof c&&(c=!1),"undefined"==typeof d&&(d=!1),e=e||0,this._container.children.length>0&&this._container.first._iNext){var f=this._container.first._iNext;do(0==c||c&&f.alive)&&(0==d||d&&f.visible)&&this.setProperty(f,a,b,e),f=f._iNext;while(f!=this._container.last._iNext)}},addAll:function(a,b,c,d){this.setAll(a,b,c,d,1)},subAll:function(a,b,c,d){this.setAll(a,b,c,d,2)},multiplyAll:function(a,b,c,d){this.setAll(a,b,c,d,3)},divideAll:function(a,b,c,d){this.setAll(a,b,c,d,4)},callAllExists:function(a,b){var c=Array.prototype.splice.call(arguments,2);if(this._container.children.length>0&&this._container.first._iNext){var d=this._container.first._iNext;do d.exists==b&&d[a]&&d[a].apply(d,c),d=d._iNext;while(d!=this._container.last._iNext)}},callbackFromArray:function(a,b,c){if(1==c){if(a[b[0]])return a[b[0]]}else if(2==c){if(a[b[0]][b[1]])return a[b[0]][b[1]]}else if(3==c){if(a[b[0]][b[1]][b[2]])return a[b[0]][b[1]][b[2]]}else if(4==c){if(a[b[0]][b[1]][b[2]][b[3]])return a[b[0]][b[1]][b[2]][b[3]]}else if(a[b])return a[b];return!1},callAll:function(a,b){if("undefined"!=typeof a){a=a.split(".");var c=a.length;if("undefined"==typeof b)b=null;else if("string"==typeof b){b=b.split(".");var d=b.length}var e=Array.prototype.splice.call(arguments,2),f=null;if(this._container.children.length>0&&this._container.first._iNext){var g=this._container.first._iNext;do f=this.callbackFromArray(g,a,c),b&&f?(callbackContext=this.callbackFromArray(g,b,d),f&&f.apply(callbackContext,e)):f&&f.apply(g,e),g=g._iNext;while(g!=this._container.last._iNext)}}},forEach:function(a,b,c){"undefined"==typeof c&&(c=!1);var d=Array.prototype.splice.call(arguments,3);if(d.unshift(null),this._container.children.length>0&&this._container.first._iNext){var e=this._container.first._iNext;do(0==c||c&&e.exists)&&(d[0]=e,a.apply(b,d)),e=e._iNext;while(e!=this._container.last._iNext)}},forEachExists:function(a,b){var c=Array.prototype.splice.call(arguments,2);c.unshift(null),this.iterate("exists",!0,e.Group.RETURN_TOTAL,a,b,c)},forEachAlive:function(a,b){var c=Array.prototype.splice.call(arguments,2);c.unshift(null),this.iterate("alive",!0,e.Group.RETURN_TOTAL,a,b,c)},forEachDead:function(a,b){var c=Array.prototype.splice.call(arguments,2);c.unshift(null),this.iterate("alive",!1,e.Group.RETURN_TOTAL,a,b,c)},sort:function(a,b){"undefined"==typeof a&&(a="y"),"undefined"==typeof b&&(b=e.Group.SORT_ASCENDING);var c,d;do{c=!1;for(var f=0,g=this._container.children.length-1;g>f;f++)b==e.Group.SORT_ASCENDING?this._container.children[f][a]>this._container.children[f+1][a]&&(this.swap(this.getAt(f),this.getAt(f+1)),d=this._container.children[f],this._container.children[f]=this._container.children[f+1],this._container.children[f+1]=d,c=!0):this._container.children[f][a]0&&this._container.first._iNext){var i=this._container.first._iNext;do{if(i[a]===b&&(h++,d&&(g[0]=i,d.apply(f,g)),c==e.Group.RETURN_CHILD))return i;i=i._iNext}while(i!=this._container.last._iNext)}return c==e.Group.RETURN_TOTAL?h:c==e.Group.RETURN_CHILD?null:void 0},getFirstExists:function(a){return"boolean"!=typeof a&&(a=!0),this.iterate("exists",a,e.Group.RETURN_CHILD)},getFirstAlive:function(){return this.iterate("alive",!0,e.Group.RETURN_CHILD)},getFirstDead:function(){return this.iterate("alive",!1,e.Group.RETURN_CHILD)},countLiving:function(){return this.iterate("alive",!0,e.Group.RETURN_TOTAL)},countDead:function(){return this.iterate("alive",!1,e.Group.RETURN_TOTAL)},getRandom:function(a,b){return 0==this._container.children.length?null:(a=a||0,b=b||this._container.children.length,this.game.math.getRandom(this._container.children,a,b))},remove:function(a){a.events&&a.events.onRemovedFromGroup.dispatch(a,this),this._container.removeChild(a),this.cursor==a&&(this.cursor=this._container._iNext?this._container._iNext:null),a.group=null},removeAll:function(){if(0!=this._container.children.length){do this._container.children[0].events&&this._container.children[0].events.onRemovedFromGroup.dispatch(this._container.children[0],this),this._container.removeChild(this._container.children[0]);while(this._container.children.length>0);this.cursor=null}},removeBetween:function(a,b){if(0!=this._container.children.length){if(a>b||0>a||b>this._container.children.length)return!1;for(var c=a;b>c;c++){var d=this._container.children[c];d.events.onRemovedFromGroup.dispatch(d,this),this._container.removeChild(d),this.cursor==d&&(this.cursor=this._container._iNext?this._container._iNext:null)}}},destroy:function(){this.removeAll(),this._container.parent.removeChild(this._container),this._container=null,this.game=null,this.exists=!1,this.cursor=null},validate:function(){var a=this.game.stage._stage.last._iNext,b=this.game.stage._stage,c=null,d=null,e=0;do{if(e>0){if(b!==c)return console.log("check next fail"),!1;if(b._iPrev!==d)return console.log("check previous fail"),!1}c=b._iNext,d=b,b=b._iNext,e++}while(b!=a);return!0},dump:function(a){"undefined"==typeof a&&(a=!1);var b=20,c="\n"+e.Utils.pad("Node",b)+"|"+e.Utils.pad("Next",b)+"|"+e.Utils.pad("Previous",b)+"|"+e.Utils.pad("First",b)+"|"+e.Utils.pad("Last",b);console.log(c);var c=e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b);if(console.log(c),a)var d=this.game.stage._stage.last._iNext,f=this.game.stage._stage;else var d=this._container.last._iNext,f=this._container;do{var g=f.name||"*";if(this.cursor==f)var g="> "+g;var h="-",i="-",j="-",k="-";f._iNext&&(h=f._iNext.name),f._iPrev&&(i=f._iPrev.name),f.first&&(j=f.first.name),f.last&&(k=f.last.name),"undefined"==typeof h&&(h="-"),"undefined"==typeof i&&(i="-"),"undefined"==typeof j&&(j="-"),"undefined"==typeof k&&(k="-");var c=e.Utils.pad(g,b)+"|"+e.Utils.pad(h,b)+"|"+e.Utils.pad(i,b)+"|"+e.Utils.pad(j,b)+"|"+e.Utils.pad(k,b);console.log(c),f=f._iNext}while(f!=d)}},Object.defineProperty(e.Group.prototype,"total",{get:function(){return this.iterate("exists",!0,e.Group.RETURN_TOTAL)}}),Object.defineProperty(e.Group.prototype,"length",{get:function(){return this.iterate("exists",!0,e.Group.RETURN_TOTAL)}}),Object.defineProperty(e.Group.prototype,"x",{get:function(){return this._container.position.x},set:function(a){this._container.position.x=a}}),Object.defineProperty(e.Group.prototype,"y",{get:function(){return this._container.position.y},set:function(a){this._container.position.y=a}}),Object.defineProperty(e.Group.prototype,"angle",{get:function(){return e.Math.radToDeg(this._container.rotation)},set:function(a){this._container.rotation=e.Math.degToRad(a)}}),Object.defineProperty(e.Group.prototype,"rotation",{get:function(){return this._container.rotation},set:function(a){this._container.rotation=a}}),Object.defineProperty(e.Group.prototype,"visible",{get:function(){return this._container.visible},set:function(a){this._container.visible=a}}),Object.defineProperty(e.Group.prototype,"alpha",{get:function(){return this._container.alpha},set:function(a){this._container.alpha=a}}),e.World=function(a){e.Group.call(this,a,null,"__world",!1),this.scale=new e.Point(1,1),this.bounds=new e.Rectangle(0,0,a.width,a.height),this.camera=null,this.currentRenderOrderID=0},e.World.prototype=Object.create(e.Group.prototype),e.World.prototype.constructor=e.World,e.World.prototype.boot=function(){this.camera=new e.Camera(this.game,0,0,0,this.game.width,this.game.height),this.camera.displayObject=this._container,this.game.camera=this.camera},e.World.prototype.update=function(){if(this.currentRenderOrderID=0,this.game.stage._stage.first._iNext){var a=this.game.stage._stage.first._iNext;do a.preUpdate&&a.preUpdate(),a.update&&a.update(),a=a._iNext;while(a!=this.game.stage._stage.last._iNext)}},e.World.prototype.postUpdate=function(){if(this.camera.update(),this.game.stage._stage.first._iNext){var a=this.game.stage._stage.first._iNext;do a.postUpdate&&a.postUpdate(),a=a._iNext;while(a!=this.game.stage._stage.last._iNext)}},e.World.prototype.setBounds=function(a,b,c,d){this.bounds.setTo(a,b,c,d),this.camera.bounds&&this.camera.bounds.setTo(a,b,c,d)},e.World.prototype.destroy=function(){this.camera.x=0,this.camera.y=0,this.game.input.reset(!0),this.removeAll()},Object.defineProperty(e.World.prototype,"width",{get:function(){return this.bounds.width},set:function(a){this.bounds.width=a}}),Object.defineProperty(e.World.prototype,"height",{get:function(){return this.bounds.height},set:function(a){this.bounds.height=a}}),Object.defineProperty(e.World.prototype,"centerX",{get:function(){return this.bounds.halfWidth}}),Object.defineProperty(e.World.prototype,"centerY",{get:function(){return this.bounds.halfHeight}}),Object.defineProperty(e.World.prototype,"randomX",{get:function(){return this.bounds.x<0?this.game.rnd.integerInRange(this.bounds.x,this.bounds.width-Math.abs(this.bounds.x)):this.game.rnd.integerInRange(this.bounds.x,this.bounds.width)}}),Object.defineProperty(e.World.prototype,"randomY",{get:function(){return this.bounds.y<0?this.game.rnd.integerInRange(this.bounds.y,this.bounds.height-Math.abs(this.bounds.y)):this.game.rnd.integerInRange(this.bounds.y,this.bounds.height)}}),Object.defineProperty(e.World.prototype,"visible",{get:function(){return this._container.visible},set:function(a){this._container.visible=a}}),e.Game=function(a,b,c,d,f,g,h){a=a||800,b=b||600,c=c||e.AUTO,d=d||"",f=f||null,"undefined"==typeof g&&(g=!1),"undefined"==typeof h&&(h=!0),this.id=e.GAMES.push(this)-1,this.parent=d,this.width=a,this.height=b,this.transparent=g,this.antialias=h,this.renderer=null,this.state=new e.StateManager(this,f),this._paused=!1,this.renderType=c,this._loadComplete=!1,this.isBooted=!1,this.isRunning=!1,this.raf=null,this.add=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.net=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.physics=null,this.rnd=null,this.device=null,this.camera=null,this.canvas=null,this.context=null,this.debug=null,this.particles=null;var i=this;return this._onBoot=function(){return i.boot()},"complete"===document.readyState||"interactive"===document.readyState?window.setTimeout(this._onBoot,0):(document.addEventListener("DOMContentLoaded",this._onBoot,!1),window.addEventListener("load",this._onBoot,!1)),this},e.Game.prototype={boot:function(){this.isBooted||(document.body?(document.removeEventListener("DOMContentLoaded",this._onBoot),window.removeEventListener("load",this._onBoot),this.onPause=new e.Signal,this.onResume=new e.Signal,this.isBooted=!0,this.device=new e.Device,this.math=e.Math,this.rnd=new e.RandomDataGenerator([(Date.now()*Math.random()).toString()]),this.stage=new e.Stage(this,this.width,this.height),this.setUpRenderer(),this.world=new e.World(this),this.add=new e.GameObjectFactory(this),this.cache=new e.Cache(this),this.load=new e.Loader(this),this.time=new e.Time(this),this.tweens=new e.TweenManager(this),this.input=new e.Input(this),this.sound=new e.SoundManager(this),this.physics=new e.Physics.Arcade(this),this.particles=new e.Particles(this),this.plugins=new e.PluginManager(this,this),this.net=new e.Net(this),this.debug=new e.Utils.Debug(this),this.stage.boot(),this.world.boot(),this.input.boot(),this.sound.boot(),this.state.boot(),this.load.onLoadComplete.add(this.loadComplete,this),this.showDebugHeader(),this.isRunning=!0,this._loadComplete=!1,this.raf=new e.RequestAnimationFrame(this),this.raf.start()):window.setTimeout(this._onBoot,20))},showDebugHeader:function(){var a=e.DEV_VERSION,b="Canvas",c="HTML Audio";if(this.renderType==e.WEBGL&&(b="WebGL"),this.device.webAudio&&(c="WebAudio"),this.device.chrome){var d=["%c %c %c Phaser v"+a+" - Renderer: "+b+" - Audio: "+c+" %c %c ","background: #00bff3","background: #0072bc","color: #ffffff; background: #003471","background: #0072bc","background: #00bff3"];console.log.apply(console,d)}else console.log("Phaser v"+a+" - Renderer: "+b+" - Audio: "+c)},setUpRenderer:function(){if(this.renderType===e.CANVAS||this.renderType===e.AUTO&&0==this.device.webGL){if(!this.device.canvas)throw new Error("Phaser.Game - cannot create Canvas or WebGL context, aborting.");this.renderType=e.CANVAS,this.renderer=new d.CanvasRenderer(this.width,this.height,this.stage.canvas,this.transparent),e.Canvas.setSmoothingEnabled(this.renderer.context,this.antialias),this.canvas=this.renderer.view,this.context=this.renderer.context}else this.renderType=e.WEBGL,this.renderer=new d.WebGLRenderer(this.width,this.height,this.stage.canvas,this.transparent,this.antialias),this.canvas=this.renderer.view,this.context=null;e.Canvas.addToDOM(this.renderer.view,this.parent,!0),e.Canvas.setTouchAction(this.renderer.view)},loadComplete:function(){this._loadComplete=!0,this.state.loadComplete()},update:function(a){this.time.update(a),this._paused?(this.renderer.render(this.stage._stage),this.plugins.render(),this.state.render()):(this.plugins.preUpdate(),this.physics.preUpdate(),this.stage.update(),this.input.update(),this.tweens.update(),this.sound.update(),this.world.update(),this.particles.update(),this.state.update(),this.plugins.update(),this.world.postUpdate(),this.plugins.postUpdate(),this.renderer.render(this.stage._stage),this.plugins.render(),this.state.render(),this.plugins.postRender())},destroy:function(){this.raf.stop(),this.input.destroy(),this.state.destroy(),this.state=null,this.cache=null,this.input=null,this.load=null,this.sound=null,this.stage=null,this.time=null,this.world=null,this.isBooted=!1}},Object.defineProperty(e.Game.prototype,"paused",{get:function(){return this._paused},set:function(a){a===!0?0==this._paused&&(this._paused=!0,this.onPause.dispatch(this)):this._paused&&(this._paused=!1,this.onResume.dispatch(this))}}),e.Input=function(a){this.game=a,this.hitCanvas=null,this.hitContext=null},e.Input.MOUSE_OVERRIDES_TOUCH=0,e.Input.TOUCH_OVERRIDES_MOUSE=1,e.Input.MOUSE_TOUCH_COMBINE=2,e.Input.prototype={game:null,pollRate:0,_pollCounter:0,_oldPosition:null,_x:0,_y:0,disabled:!1,multiInputOverride:e.Input.MOUSE_TOUCH_COMBINE,position:null,speed:null,circle:null,scale:null,maxPointers:10,currentPointers:0,tapRate:200,doubleTapRate:300,holdRate:2e3,justPressedRate:200,justReleasedRate:200,recordPointerHistory:!1,recordRate:100,recordLimit:100,pointer1:null,pointer2:null,pointer3:null,pointer4:null,pointer5:null,pointer6:null,pointer7:null,pointer8:null,pointer9:null,pointer10:null,activePointer:null,mousePointer:null,mouse:null,keyboard:null,touch:null,mspointer:null,onDown:null,onUp:null,onTap:null,onHold:null,interactiveItems:new e.LinkedList,boot:function(){this.mousePointer=new e.Pointer(this.game,0),this.pointer1=new e.Pointer(this.game,1),this.pointer2=new e.Pointer(this.game,2),this.mouse=new e.Mouse(this.game),this.keyboard=new e.Keyboard(this.game),this.touch=new e.Touch(this.game),this.mspointer=new e.MSPointer(this.game),this.onDown=new e.Signal,this.onUp=new e.Signal,this.onTap=new e.Signal,this.onHold=new e.Signal,this.scale=new e.Point(1,1),this.speed=new e.Point,this.position=new e.Point,this._oldPosition=new e.Point,this.circle=new e.Circle(0,0,44),this.activePointer=this.mousePointer,this.currentPointers=0,this.hitCanvas=document.createElement("canvas"),this.hitCanvas.width=1,this.hitCanvas.height=1,this.hitContext=this.hitCanvas.getContext("2d"),this.mouse.start(),this.keyboard.start(),this.touch.start(),this.mspointer.start(),this.mousePointer.active=!0 +},destroy:function(){this.mouse.stop(),this.keyboard.stop(),this.touch.stop(),this.mspointer.stop()},addPointer:function(){for(var a=0,b=10;b>0;b--)null===this["pointer"+b]&&(a=b);return 0==a?(console.warn("You can only have 10 Pointer objects"),null):(this["pointer"+a]=new e.Pointer(this.game,a),this["pointer"+a])},update:function(){return this.pollRate>0&&this._pollCounter=b;b++)this["pointer"+b]&&this["pointer"+b].reset();this.currentPointers=0,this.game.stage.canvas.style.cursor="default",1==a&&(this.onDown.dispose(),this.onUp.dispose(),this.onTap.dispose(),this.onHold.dispose(),this.onDown=new e.Signal,this.onUp=new e.Signal,this.onTap=new e.Signal,this.onHold=new e.Signal,this.interactiveItems.callAll("reset")),this._pollCounter=0}},resetSpeed:function(a,b){this._oldPosition.setTo(a,b),this.speed.setTo(0,0)},startPointer:function(a){if(this.maxPointers<10&&this.totalActivePointers==this.maxPointers)return null;if(0==this.pointer1.active)return this.pointer1.start(a);if(0==this.pointer2.active)return this.pointer2.start(a);for(var b=3;10>=b;b++)if(this["pointer"+b]&&0==this["pointer"+b].active)return this["pointer"+b].start(a);return null},updatePointer:function(a){if(this.pointer1.active&&this.pointer1.identifier==a.identifier)return this.pointer1.move(a);if(this.pointer2.active&&this.pointer2.identifier==a.identifier)return this.pointer2.move(a);for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].active&&this["pointer"+b].identifier==a.identifier)return this["pointer"+b].move(a);return null},stopPointer:function(a){if(this.pointer1.active&&this.pointer1.identifier==a.identifier)return this.pointer1.stop(a);if(this.pointer2.active&&this.pointer2.identifier==a.identifier)return this.pointer2.stop(a);for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].active&&this["pointer"+b].identifier==a.identifier)return this["pointer"+b].stop(a);return null},getPointer:function(a){if(a=a||!1,this.pointer1.active==a)return this.pointer1;if(this.pointer2.active==a)return this.pointer2;for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].active==a)return this["pointer"+b];return null},getPointerFromIdentifier:function(a){if(this.pointer1.identifier==a)return this.pointer1;if(this.pointer2.identifier==a)return this.pointer2;for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].identifier==a)return this["pointer"+b];return null}},Object.defineProperty(e.Input.prototype,"x",{get:function(){return this._x},set:function(a){this._x=Math.floor(a)}}),Object.defineProperty(e.Input.prototype,"y",{get:function(){return this._y},set:function(a){this._y=Math.floor(a)}}),Object.defineProperty(e.Input.prototype,"pollLocked",{get:function(){return this.pollRate>0&&this._pollCounter=a;a++)this["pointer"+a]&&this["pointer"+a].active&&this.currentPointers++;return this.currentPointers}}),Object.defineProperty(e.Input.prototype,"worldX",{get:function(){return this.game.camera.view.x+this.x}}),Object.defineProperty(e.Input.prototype,"worldY",{get:function(){return this.game.camera.view.y+this.y}}),e.Key=function(a,b){this.game=a,this.isDown=!1,this.isUp=!1,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.timeDown=0,this.duration=0,this.timeUp=0,this.repeats=0,this.keyCode=b,this.onDown=new e.Signal,this.onUp=new e.Signal},e.Key.prototype={processKeyDown:function(a){this.altKey=a.altKey,this.ctrlKey=a.ctrlKey,this.shiftKey=a.shiftKey,this.isDown?(this.duration=a.timeStamp-this.timeDown,this.repeats++):(this.isDown=!0,this.isUp=!1,this.timeDown=a.timeStamp,this.duration=0,this.repeats=0,this.onDown.dispatch(this))},processKeyUp:function(a){this.isDown=!1,this.isUp=!0,this.timeUp=a.timeStamp,this.onUp.dispatch(this)},justPressed:function(a){return"undefined"==typeof a&&(a=250),this.isDown&&this.duration=this.game.input.holdRate&&((this.game.input.multiInputOverride==e.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==e.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==e.Input.TOUCH_OVERRIDES_MOUSE&&0==this.game.input.currentPointers)&&this.game.input.onHold.dispatch(this),this._holdSent=!0),this.game.input.recordPointerHistory&&this.game.time.now>=this._nextDrop&&(this._nextDrop=this.game.time.now+this.game.input.recordRate,this._history.push({x:this.position.x,y:this.position.y}),this._history.length>this.game.input.recordLimit&&this._history.shift()))},move:function(a){if(!this.game.input.pollLocked){if("undefined"!=typeof a.button&&(this.button=a.button),this.clientX=a.clientX,this.clientY=a.clientY,this.pageX=a.pageX,this.pageY=a.pageY,this.screenX=a.screenX,this.screenY=a.screenY,this.x=(this.pageX-this.game.stage.offset.x)*this.game.input.scale.x,this.y=(this.pageY-this.game.stage.offset.y)*this.game.input.scale.y,this.position.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,(this.game.input.multiInputOverride==e.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==e.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==e.Input.TOUCH_OVERRIDES_MOUSE&&0==this.game.input.currentPointers)&&(this.game.input.activePointer=this,this.game.input.x=this.x,this.game.input.y=this.y,this.game.input.position.setTo(this.game.input.x,this.game.input.y),this.game.input.circle.x=this.game.input.x,this.game.input.circle.y=this.game.input.y),this.game.paused)return this;if(null!==this.targetObject&&1==this.targetObject.isDragged)return 0==this.targetObject.update(this)&&(this.targetObject=null),this;if(this._highestRenderOrderID=-1,this._highestRenderObject=null,this._highestInputPriorityID=-1,this.game.input.interactiveItems.total>0){var b=this.game.input.interactiveItems.next;do(b.pixelPerfect||b.priorityID>this._highestInputPriorityID||b.priorityID==this._highestInputPriorityID&&b.sprite.renderOrderID>this._highestRenderOrderID)&&b.checkPointerOver(this)&&(this._highestRenderOrderID=b.sprite.renderOrderID,this._highestInputPriorityID=b.priorityID,this._highestRenderObject=b),b=b.next;while(null!=b)}return null==this._highestRenderObject?this.targetObject&&(this.targetObject._pointerOutHandler(this),this.targetObject=null):null==this.targetObject?(this.targetObject=this._highestRenderObject,this._highestRenderObject._pointerOverHandler(this)):this.targetObject==this._highestRenderObject?0==this._highestRenderObject.update(this)&&(this.targetObject=null):(this.targetObject._pointerOutHandler(this),this.targetObject=this._highestRenderObject,this.targetObject._pointerOverHandler(this)),this}},leave:function(a){this.withinGame=!1,this.move(a)},stop:function(a){if(this._stateReset)return a.preventDefault(),void 0;if(this.timeUp=this.game.time.now,(this.game.input.multiInputOverride==e.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==e.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==e.Input.TOUCH_OVERRIDES_MOUSE&&0==this.game.input.currentPointers)&&(this.game.input.onUp.dispatch(this,a),this.duration>=0&&this.duration<=this.game.input.tapRate&&(this.timeUp-this.previousTapTime0&&(this.active=!1),this.withinGame=!1,this.isDown=!1,this.isUp=!0,0==this.isMouse&&this.game.input.currentPointers--,this.game.input.interactiveItems.total>0){var b=this.game.input.interactiveItems.next;do b&&b._releasedHandler(this),b=b.next;while(null!=b)}return this.targetObject&&this.targetObject._releasedHandler(this),this.targetObject=null,this},justPressed:function(a){return a=a||this.game.input.justPressedRate,this.isDown===!0&&this.timeDown+a>this.game.time.now},justReleased:function(a){return a=a||this.game.input.justReleasedRate,this.isUp===!0&&this.timeUp+a>this.game.time.now},reset:function(){0==this.isMouse&&(this.active=!1),this.identifier=null,this.isDown=!1,this.isUp=!0,this.totalTouches=0,this._holdSent=!1,this._history.length=0,this._stateReset=!0,this.targetObject&&this.targetObject._releasedHandler(this),this.targetObject=null},toString:function(){return"[{Pointer (id="+this.id+" 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+")}]"}},Object.defineProperty(e.Pointer.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.now-this.timeDown}}),Object.defineProperty(e.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x}}),Object.defineProperty(e.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y}}),e.Touch=function(a){this.game=a,this.disabled=!1,this.callbackContext=this.game,this.touchStartCallback=null,this.touchMoveCallback=null,this.touchEndCallback=null,this.touchEnterCallback=null,this.touchLeaveCallback=null,this.touchCancelCallback=null,this.preventDefault=!0,this._onTouchStart=null,this._onTouchMove=null,this._onTouchEnd=null,this._onTouchEnter=null,this._onTouchLeave=null,this._onTouchCancel=null,this._onTouchMove=null},e.Touch.prototype={start:function(){var a=this;this.game.device.touch&&(this._onTouchStart=function(b){return a.onTouchStart(b)},this._onTouchMove=function(b){return a.onTouchMove(b)},this._onTouchEnd=function(b){return a.onTouchEnd(b)},this._onTouchEnter=function(b){return a.onTouchEnter(b)},this._onTouchLeave=function(b){return a.onTouchLeave(b)},this._onTouchCancel=function(b){return a.onTouchCancel(b)},this.game.renderer.view.addEventListener("touchstart",this._onTouchStart,!1),this.game.renderer.view.addEventListener("touchmove",this._onTouchMove,!1),this.game.renderer.view.addEventListener("touchend",this._onTouchEnd,!1),this.game.renderer.view.addEventListener("touchenter",this._onTouchEnter,!1),this.game.renderer.view.addEventListener("touchleave",this._onTouchLeave,!1),this.game.renderer.view.addEventListener("touchcancel",this._onTouchCancel,!1))},consumeDocumentTouches:function(){this._documentTouchMove=function(a){a.preventDefault()},document.addEventListener("touchmove",this._documentTouchMove,!1)},onTouchStart:function(a){if(this.touchStartCallback&&this.touchStartCallback.call(this.callbackContext,a),!this.game.input.disabled&&!this.disabled){this.preventDefault&&a.preventDefault();for(var b=0;bc;c++)this._pointerData[c]={id:c,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1};this.snapOffset=new e.Point,this.enabled=!0,this.sprite.events&&null==this.sprite.events.onInputOver&&(this.sprite.events.onInputOver=new e.Signal,this.sprite.events.onInputOut=new e.Signal,this.sprite.events.onInputDown=new e.Signal,this.sprite.events.onInputUp=new e.Signal,this.sprite.events.onDragStart=new e.Signal,this.sprite.events.onDragStop=new e.Signal)}return this.sprite},reset:function(){this.enabled=!1;for(var a=0;10>a;a++)this._pointerData[a]={id:a,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1}},stop:function(){0!=this.enabled&&(this.enabled=!1,this.game.input.interactiveItems.remove(this))},destroy:function(){this.enabled&&(this.enabled=!1,this.game.input.interactiveItems.remove(this),this.stop(),this.sprite=null)},pointerX:function(a){return a=a||0,this._pointerData[a].x},pointerY:function(a){return a=a||0,this._pointerData[a].y},pointerDown:function(a){return a=a||0,this._pointerData[a].isDown},pointerUp:function(a){return a=a||0,this._pointerData[a].isUp},pointerTimeDown:function(a){return a=a||0,this._pointerData[a].timeDown},pointerTimeUp:function(a){return a=a||0,this._pointerData[a].timeUp},pointerOver:function(a){if(this.enabled){if("undefined"!=typeof a)return this._pointerData[a].isOver;for(var b=0;10>b;b++)if(this._pointerData[b].isOver)return!0}return!1},pointerOut:function(){if(this.enabled){if("undefined"!=typeof index)return this._pointerData[index].isOut;for(var a=0;10>a;a++)if(this._pointerData[a].isOut)return!0}return!1},pointerTimeOver:function(a){return a=a||0,this._pointerData[a].timeOver},pointerTimeOut:function(a){return a=a||0,this._pointerData[a].timeOut},pointerDragged:function(a){return a=a||0,this._pointerData[a].isDragged},checkPointerOver:function(a){return this.enabled&&this.sprite.visible&&(this.sprite.getLocalUnmodifiedPosition(this._tempPoint,a.x,a.y),this._tempPoint.x>=0&&this._tempPoint.x<=this.sprite.currentFrame.width&&this._tempPoint.y>=0&&this._tempPoint.y<=this.sprite.currentFrame.height)?this.pixelPerfect?this.checkPixel(this._tempPoint.x,this._tempPoint.y):!0:!1},checkPixel:function(a,b){if(this.sprite.texture.baseTexture.source){this.game.input.hitContext.clearRect(0,0,1,1),a+=this.sprite.texture.frame.x,b+=this.sprite.texture.frame.y,this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,a,b,1,1,0,0,1,1);var c=this.game.input.hitContext.getImageData(0,0,1,1);if(c.data[3]>=this.pixelPerfectAlpha)return!0}return!1},update:function(a){return 0==this.enabled||0==this.sprite.visible||this.sprite.group&&0==this.sprite.group.visible?(this._pointerOutHandler(a),!1):this.draggable&&this._draggedPointerID==a.id?this.updateDrag(a):1==this._pointerData[a.id].isOver?this.checkPointerOver(a)?(this._pointerData[a.id].x=a.x-this.sprite.x,this._pointerData[a.id].y=a.y-this.sprite.y,!0):(this._pointerOutHandler(a),!1):void 0},_pointerOverHandler:function(a){0==this._pointerData[a.id].isOver&&(this._pointerData[a.id].isOver=!0,this._pointerData[a.id].isOut=!1,this._pointerData[a.id].timeOver=this.game.time.now,this._pointerData[a.id].x=a.x-this.sprite.x,this._pointerData[a.id].y=a.y-this.sprite.y,this.useHandCursor&&0==this._pointerData[a.id].isDragged&&(this.game.stage.canvas.style.cursor="pointer"),this.sprite.events.onInputOver.dispatch(this.sprite,a))},_pointerOutHandler:function(a){this._pointerData[a.id].isOver=!1,this._pointerData[a.id].isOut=!0,this._pointerData[a.id].timeOut=this.game.time.now,this.useHandCursor&&0==this._pointerData[a.id].isDragged&&(this.game.stage.canvas.style.cursor="default"),this.sprite&&this.sprite.events&&this.sprite.events.onInputOut.dispatch(this.sprite,a)},_touchedHandler:function(a){return 0==this._pointerData[a.id].isDown&&1==this._pointerData[a.id].isOver&&(this._pointerData[a.id].isDown=!0,this._pointerData[a.id].isUp=!1,this._pointerData[a.id].timeDown=this.game.time.now,this.sprite.events.onInputDown.dispatch(this.sprite,a),this.draggable&&0==this.isDragged&&this.startDrag(a),this.bringToTop&&this.sprite.bringToTop()),this.consumePointerEvent},_releasedHandler:function(a){this._pointerData[a.id].isDown&&a.isUp&&(this._pointerData[a.id].isDown=!1,this._pointerData[a.id].isUp=!0,this._pointerData[a.id].timeUp=this.game.time.now,this._pointerData[a.id].downDuration=this._pointerData[a.id].timeUp-this._pointerData[a.id].timeDown,this.checkPointerOver(a)?this.sprite.events.onInputUp.dispatch(this.sprite,a):this.useHandCursor&&(this.game.stage.canvas.style.cursor="default"),this.draggable&&this.isDragged&&this._draggedPointerID==a.id&&this.stopDrag(a))},updateDrag:function(a){return a.isUp?(this.stopDrag(a),!1):(this.allowHorizontalDrag&&(this.sprite.x=a.x+this._dragPoint.x+this.dragOffset.x),this.allowVerticalDrag&&(this.sprite.y=a.y+this._dragPoint.y+this.dragOffset.y),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(this.sprite.x=Math.round(this.sprite.x/this.snapX)*this.snapX,this.sprite.y=Math.round(this.sprite.y/this.snapY)*this.snapY),!0)},justOver:function(a,b){return a=a||0,b=b||500,this._pointerData[a].isOver&&this.overDuration(a)a;a++)this._pointerData[a].isDragged=!1;this.draggable=!1,this.isDragged=!1,this._draggedPointerID=-1},startDrag:function(a){this.isDragged=!0,this._draggedPointerID=a.id,this._pointerData[a.id].isDragged=!0,this.dragFromCenter?(this.sprite.centerOn(a.x,a.y),this._dragPoint.setTo(this.sprite.x-a.x,this.sprite.y-a.y)):this._dragPoint.setTo(this.sprite.x-a.x,this.sprite.y-a.y),this.updateDrag(a),this.bringToTop&&this.sprite.bringToTop(),this.sprite.events.onDragStart.dispatch(this.sprite,a) +},stopDrag:function(a){this.isDragged=!1,this._draggedPointerID=-1,this._pointerData[a.id].isDragged=!1,this.snapOnRelease&&(this.sprite.x=Math.round(this.sprite.x/this.snapX)*this.snapX,this.sprite.y=Math.round(this.sprite.y/this.snapY)*this.snapY),this.sprite.events.onDragStop.dispatch(this.sprite,a),this.sprite.events.onInputUp.dispatch(this.sprite,a),0==this.checkPointerOver(a)&&this._pointerOutHandler(a)},setDragLock:function(a,b){"undefined"==typeof a&&(a=!0),"undefined"==typeof b&&(b=!0),this.allowHorizontalDrag=a,this.allowVerticalDrag=b},enableSnap:function(a,b,c,d){"undefined"==typeof c&&(c=!0),"undefined"==typeof d&&(d=!1),this.snapX=a,this.snapY=b,this.snapOnDrag=c,this.snapOnRelease=d},disableSnap:function(){this.snapOnDrag=!1,this.snapOnRelease=!1},checkBoundsRect:function(){this.sprite.xthis.boundsRect.right&&(this.sprite.x=this.boundsRect.right-this.sprite.width),this.sprite.ythis.boundsRect.bottom&&(this.sprite.y=this.boundsRect.bottom-this.sprite.height)},checkBoundsSprite:function(){this.sprite.xthis.boundsSprite.x+this.boundsSprite.width&&(this.sprite.x=this.boundsSprite.x+this.boundsSprite.width-this.sprite.width),this.sprite.ythis.boundsSprite.y+this.boundsSprite.height&&(this.sprite.y=this.boundsSprite.y+this.boundsSprite.height-this.sprite.height)}},e.Events=function(a){this.parent=a,this.onAddedToGroup=new e.Signal,this.onRemovedFromGroup=new e.Signal,this.onKilled=new e.Signal,this.onRevived=new e.Signal,this.onOutOfBounds=new e.Signal,this.onInputOver=null,this.onInputOut=null,this.onInputDown=null,this.onInputUp=null,this.onDragStart=null,this.onDragStop=null,this.onAnimationStart=null,this.onAnimationComplete=null,this.onAnimationLoop=null},e.Events.prototype={destroy:function(){this.parent=null,this.onAddedToGroup.dispose(),this.onRemovedFromGroup.dispose(),this.onKilled.dispose(),this.onRevived.dispose(),this.onOutOfBounds.dispose(),this.onInputOver&&(this.onInputOver.dispose(),this.onInputOut.dispose(),this.onInputDown.dispose(),this.onInputUp.dispose(),this.onDragStart.dispose(),this.onDragStop.dispose()),this.onAnimationStart&&(this.onAnimationStart.dispose(),this.onAnimationComplete.dispose(),this.onAnimationLoop.dispose())}},e.GameObjectFactory=function(a){this.game=a,this.world=this.game.world},e.GameObjectFactory.prototype={existing:function(a){return this.world.add(a)},sprite:function(a,b,c,d){return this.world.create(a,b,c,d)},child:function(a,b,c,d,e){return a.create(b,c,d,e)},tween:function(a){return this.game.tweens.create(a)},group:function(a,b){return new e.Group(this.game,a,b)},audio:function(a,b,c){return this.game.sound.add(a,b,c)},tileSprite:function(a,b,c,d,f,g){return this.world.add(new e.TileSprite(this.game,a,b,c,d,f,g))},text:function(a,b,c,d){return this.world.add(new e.Text(this.game,a,b,c,d))},button:function(a,b,c,d,f,g,h,i){return this.world.add(new e.Button(this.game,a,b,c,d,f,g,h,i))},graphics:function(a,b){return this.world.add(new e.Graphics(this.game,a,b))},emitter:function(a,b,c){return this.game.particles.add(new e.Particles.Arcade.Emitter(this.game,a,b,c))},bitmapText:function(a,b,c,d){return this.world.add(new e.BitmapText(this.game,a,b,c,d))},tilemap:function(a){return new e.Tilemap(this.game,a)},tileset:function(a){return this.game.cache.getTileset(a)},tilemapLayer:function(a,b,c,d,f,g,h){return this.world.add(new e.TilemapLayer(this.game,a,b,c,d,f,g,h))},renderTexture:function(a,b,c){var d=new e.RenderTexture(this.game,a,b,c);return this.game.cache.addRenderTexture(a,d),d},bitmapData:function(a,b){return new e.BitmapData(this.game,a,b)}},e.BitmapData=function(a,b,c){"undefined"==typeof b&&(b=256),"undefined"==typeof c&&(c=256),this.game=a,this.name="",this.width=b,this.height=c,this.canvas=e.Canvas.create(b,c),this.context=this.canvas.getContext("2d"),this.imageData=this.context.getImageData(0,0,b,c),this.pixels=this.imageData.data.buffer,this.baseTexture=new d.BaseTexture(this.canvas),this.texture=new d.Texture(this.baseTexture),this.textureFrame=new e.Frame(0,0,0,b,c,"bitmapData",a.rnd.uuid()),this.type=e.BITMAPDATA,this._dirty=!1},e.BitmapData.prototype={add:function(a){a.loadTexture(this)},addTo:function(){for(var a=0;a=0&&a<=this.width&&b>=0&&b<=this.height&&(this.pixels[b*this.width+a]=f<<24|e<<16|d<<8|c,this.context.putImageData(this.imageData,0,0),this._dirty=!0)},setPixel:function(a,b,c,d,e){this.setPixel32(a,b,c,d,e,255)},getPixel:function(a,b){return a>=0&&a<=this.width&&b>=0&&b<=this.height?this.data32[b*this.width+a]:void 0},getPixel32:function(a,b){return a>=0&&a<=this.width&&b>=0&&b<=this.height?this.data32[b*this.width+a]:void 0},getPixels:function(){},arc:function(a,b,c,d,e,f){return"undefined"==typeof f&&(f=!1),this._dirty=!0,this.context.arc(a,b,c,d,e,f),this},arcTo:function(a,b,c,d,e){return this._dirty=!0,this.context.arcTo(a,b,c,d,e),this},beginFill:function(a){return this.fillStyle(a),this},beginLinearGradientFill:function(a,b,c,d,e,f){for(var g=this.createLinearGradient(c,d,e,f),h=0,i=a.length;i>h;h++)g.addColorStop(b[h],a[h]);return this.fillStyle(g),this},beginLinearGradientStroke:function(a,b,c,d,e,f){for(var g=this.createLinearGradient(c,d,e,f),h=0,i=a.length;i>h;h++)g.addColorStop(b[h],a[h]);return this.strokeStyle(g),this},beginRadialGradientStroke:function(a,b,c,d,e,f,g,h){for(var i=this.createRadialGradient(c,d,e,f,g,h),j=0,k=a.length;k>j;j++)i.addColorStop(b[j],a[j]);return this.strokeStyle(i),this},beginPath:function(){return this.context.beginPath(),this},beginStroke:function(a){return this.strokeStyle(a),this},bezierCurveTo:function(a,b,c,d,e,f){return this._dirty=!0,this.context.bezierCurveTo(a,b,c,d,e,f),this},circle:function(a,b,c){return this.arc(a,b,c,0,2*Math.PI),this},clearRect:function(a,b,c,d){return this._dirty=!0,this.context.clearRect(a,b,c,d),this},clip:function(){return this._dirty=!0,this.context.clip(),this},closePath:function(){return this._dirty=!0,this.context.closePath(),this},createLinearGradient:function(a,b,c,d){return this.context.createLinearGradient(a,b,c,d)},createRadialGradient:function(){return this.context.createRadialGradient(x0,y0,r0,x1,y1,r1)},ellipse:function(a,b,c,d){var e=.5522848,f=c/2*e,g=d/2*e,h=a+c,i=b+d,j=a+c/2,k=b+d/2;return this.moveTo(a,k),this.bezierCurveTo(a,k-g,j-f,b,j,b),this.bezierCurveTo(j+f,b,h,k-g,h,k),this.bezierCurveTo(h,k+g,j+f,i,j,i),this.bezierCurveTo(j-f,i,a,k+g,a,k),this},fill:function(){return this._dirty=!0,this.context.fill(),this},fillRect:function(a,b,c,d){return this._dirty=!0,this.context.fillRect(a,b,c,d),this},fillStyle:function(a){return this.context.fillStyle=a,this},font:function(a){return this.context.font=a,this},globalAlpha:function(a){return this.context.globalAlpha=a,this},globalCompositeOperation:function(a){return this.context.globalCompositeOperation=a,this},lineCap:function(a){return this.context.lineCap=a,this},lineDashOffset:function(a){return this.context.lineDashOffset=a,this},lineJoin:function(a){return this.context.lineJoin=a,this},lineWidth:function(a){return this.context.lineWidth=a,this},miterLimit:function(a){return this.context.miterLimit=a,this},lineTo:function(a,b){return this._dirty=!0,this.context.lineTo(a,b),this},moveTo:function(a,b){return this.context.moveTo(a,b),this},quadraticCurveTo:function(a,b,c,d){return this._dirty=!0,this.context.quadraticCurveTo(a,b,c,d),this},rect:function(a,b,c,d){return this._dirty=!0,this.context.rect(a,b,c,d),this},restore:function(){return this._dirty=!0,this.context.restore(),this},rotate:function(a){return this._dirty=!0,this.context.rotate(a),this},setStrokeStyle:function(a,b,c,d){return"undefined"==typeof a&&(a=1),"undefined"==typeof b&&(b="butt"),"undefined"==typeof c&&(c="miter"),"undefined"==typeof d&&(d=10),this.lineWidth(a),this.lineCap(b),this.lineJoin(c),this.miterLimit(d),this},save:function(){return this._dirty=!0,this.context.save(),this},scale:function(a,b){return this._dirty=!0,this.context.scale(a,b),this},scrollPathIntoView:function(){return this._dirty=!0,this.context.scrollPathIntoView(),this},stroke:function(){return this._dirty=!0,this.context.stroke(),this},strokeRect:function(){return this._dirty=!0,this.context.strokeRect(x,y,width,height),this},strokeStyle:function(a){return this.context.strokeStyle=a,this},render:function(){this._dirty&&(this.game.renderType==e.WEBGL&&d.texturesToUpdate.push(this.baseTexture),this._dirty=!1)}},e.BitmapData.prototype.mt=e.BitmapData.prototype.moveTo,e.BitmapData.prototype.lt=e.BitmapData.prototype.lineTo,e.BitmapData.prototype.at=e.BitmapData.prototype.arcTo,e.BitmapData.prototype.bt=e.BitmapData.prototype.bezierCurveTo,e.BitmapData.prototype.qt=e.BitmapData.prototype.quadraticCurveTo,e.BitmapData.prototype.a=e.BitmapData.prototype.arc,e.BitmapData.prototype.r=e.BitmapData.prototype.rect,e.BitmapData.prototype.cp=e.BitmapData.prototype.closePath,e.BitmapData.prototype.c=e.BitmapData.prototype.clear,e.BitmapData.prototype.f=e.BitmapData.prototype.beginFill,e.BitmapData.prototype.lf=e.BitmapData.prototype.beginLinearGradientFill,e.BitmapData.prototype.rf=e.BitmapData.prototype.beginRadialGradientFill,e.BitmapData.prototype.ef=e.BitmapData.prototype.endFill,e.BitmapData.prototype.ss=e.BitmapData.prototype.setStrokeStyle,e.BitmapData.prototype.s=e.BitmapData.prototype.beginStroke,e.BitmapData.prototype.ls=e.BitmapData.prototype.beginLinearGradientStroke,e.BitmapData.prototype.rs=e.BitmapData.prototype.beginRadialGradientStroke,e.BitmapData.prototype.dr=e.BitmapData.prototype.rect,e.BitmapData.prototype.dc=e.BitmapData.prototype.circle,e.BitmapData.prototype.de=e.BitmapData.prototype.ellipse,e.Sprite=function(a,b,c,f,g){b=b||0,c=c||0,f=f||null,g=g||null,this.game=a,this.exists=!0,this.alive=!0,this.group=null,this.name="",this.type=e.SPRITE,this.renderOrderID=-1,this.lifespan=0,this.events=new e.Events(this),this.animations=new e.AnimationManager(this),this.input=new e.InputHandler(this),this.key=f,this.currentFrame=null,f instanceof e.RenderTexture?(d.Sprite.call(this,f),this.currentFrame=this.game.cache.getTextureFrame(f.name)):f instanceof e.BitmapData?(d.Sprite.call(this,f.texture,f.textureFrame),this.currentFrame=f.textureFrame):f instanceof d.Texture?(d.Sprite.call(this,f),this.currentFrame=g):((null==f||0==this.game.cache.checkImageKey(f))&&(f="__default",this.key=f),d.Sprite.call(this,d.TextureCache[f]),this.game.cache.isSpriteSheet(f)?(this.animations.loadFrameData(this.game.cache.getFrameData(f)),null!==g&&("string"==typeof g?this.frameName=g:this.frame=g)):this.currentFrame=this.game.cache.getFrame(f)),this.textureRegion=new e.Rectangle(this.texture.frame.x,this.texture.frame.y,this.texture.frame.width,this.texture.frame.height),this.anchor=new e.Point,this.x=b,this.y=c,this.position.x=b,this.position.y=c,this.world=new e.Point(b,c),this.autoCull=!1,this.scale=new e.Point(1,1),this._cache={dirty:!1,a00:-1,a01:-1,a02:-1,a10:-1,a11:-1,a12:-1,id:-1,i01:-1,i10:-1,idi:-1,left:null,right:null,top:null,bottom:null,prevX:b,prevY:c,x:-1,y:-1,scaleX:1,scaleY:1,width:this.currentFrame.sourceSizeW,height:this.currentFrame.sourceSizeH,halfWidth:Math.floor(this.currentFrame.sourceSizeW/2),halfHeight:Math.floor(this.currentFrame.sourceSizeH/2),calcWidth:-1,calcHeight:-1,frameID:-1,frameWidth:this.currentFrame.width,frameHeight:this.currentFrame.height,cameraVisible:!0,cropX:0,cropY:0,cropWidth:this.currentFrame.sourceSizeW,cropHeight:this.currentFrame.sourceSizeH},this.offset=new e.Point,this.center=new e.Point(b+Math.floor(this._cache.width/2),c+Math.floor(this._cache.height/2)),this.topLeft=new e.Point(b,c),this.topRight=new e.Point(b+this._cache.width,c),this.bottomRight=new e.Point(b+this._cache.width,c+this._cache.height),this.bottomLeft=new e.Point(b,c+this._cache.height),this.bounds=new e.Rectangle(b,c,this._cache.width,this._cache.height),this.body=new e.Physics.Arcade.Body(this),this.health=1,this.inWorld=e.Rectangle.intersects(this.bounds,this.game.world.bounds),this.inWorldThreshold=0,this.outOfBoundsKill=!1,this._outOfBoundsFired=!1,this.fixedToCamera=!1,this.cameraOffset=new e.Point,this.crop=new e.Rectangle(0,0,this._cache.width,this._cache.height),this.cropEnabled=!1,this.updateCache(),this.updateBounds()},e.Sprite.prototype=Object.create(d.Sprite.prototype),e.Sprite.prototype.constructor=e.Sprite,e.Sprite.prototype.preUpdate=function(){return!this.exists||this.group&&!this.group.exists?(this.renderOrderID=-1,void 0):this.lifespan>0&&(this.lifespan-=this.game.time.elapsed,this.lifespan<=0)?(this.kill(),void 0):(this._cache.dirty=!1,this.visible&&(this.renderOrderID=this.game.world.currentRenderOrderID++),this.updateCache(),this.updateAnimation(),this.updateCrop(),(this._cache.dirty||this.world.x!==this._cache.prevX||this.world.y!==this._cache.prevY)&&this.updateBounds(),this.body&&this.body.preUpdate(),void 0)},e.Sprite.prototype.updateCache=function(){this._cache.prevX=this.world.x,this._cache.prevY=this.world.y,this.fixedToCamera&&(this.x=this.game.camera.view.x+this.cameraOffset.x,this.y=this.game.camera.view.y+this.cameraOffset.y),this.world.setTo(this.game.camera.x+this.worldTransform[2],this.game.camera.y+this.worldTransform[5]),(this.worldTransform[1]!=this._cache.i01||this.worldTransform[3]!=this._cache.i10||this.worldTransform[0]!=this._cache.a00||this.worldTransform[41]!=this._cache.a11)&&(this._cache.a00=this.worldTransform[0],this._cache.a01=this.worldTransform[1],this._cache.a10=this.worldTransform[3],this._cache.a11=this.worldTransform[4],this._cache.i01=this.worldTransform[1],this._cache.i10=this.worldTransform[3],this._cache.scaleX=Math.sqrt(this._cache.a00*this._cache.a00+this._cache.a01*this._cache.a01),this._cache.scaleY=Math.sqrt(this._cache.a10*this._cache.a10+this._cache.a11*this._cache.a11),this._cache.a01*=-1,this._cache.a10*=-1,this._cache.id=1/(this._cache.a00*this._cache.a11+this._cache.a01*-this._cache.a10),this._cache.idi=1/(this._cache.a00*this._cache.a11+this._cache.i01*-this._cache.i10),this._cache.dirty=!0),this._cache.a02=this.worldTransform[2],this._cache.a12=this.worldTransform[5]},e.Sprite.prototype.updateAnimation=function(){(this.animations.update()||this.currentFrame&&this.currentFrame.uuid!=this._cache.frameID)&&(this._cache.frameID=this.currentFrame.uuid,this._cache.frameWidth=this.texture.frame.width,this._cache.frameHeight=this.texture.frame.height,this._cache.width=this.currentFrame.width,this._cache.height=this.currentFrame.height,this._cache.halfWidth=Math.floor(this._cache.width/2),this._cache.halfHeight=Math.floor(this._cache.height/2),this._cache.dirty=!0)},e.Sprite.prototype.updateCrop=function(){!this.cropEnabled||this.crop.width==this._cache.cropWidth&&this.crop.height==this._cache.cropHeight&&this.crop.x==this._cache.cropX&&this.crop.y==this._cache.cropY||(this.crop.floorAll(),this._cache.cropX=this.crop.x,this._cache.cropY=this.crop.y,this._cache.cropWidth=this.crop.width,this._cache.cropHeight=this.crop.height,this.texture.frame=this.crop,this.texture.width=this.crop.width,this.texture.height=this.crop.height,this.texture.updateFrame=!0,d.Texture.frameUpdates.push(this.texture))},e.Sprite.prototype.updateBounds=function(){this.offset.setTo(this._cache.a02-this.anchor.x*this.width,this._cache.a12-this.anchor.y*this.height),this.getLocalPosition(this.center,this.offset.x+this.width/2,this.offset.y+this.height/2),this.getLocalPosition(this.topLeft,this.offset.x,this.offset.y),this.getLocalPosition(this.topRight,this.offset.x+this.width,this.offset.y),this.getLocalPosition(this.bottomLeft,this.offset.x,this.offset.y+this.height),this.getLocalPosition(this.bottomRight,this.offset.x+this.width,this.offset.y+this.height),this._cache.left=e.Math.min(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x),this._cache.right=e.Math.max(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x),this._cache.top=e.Math.min(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y),this._cache.bottom=e.Math.max(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y),this.bounds.setTo(this._cache.left,this._cache.top,this._cache.right-this._cache.left,this._cache.bottom-this._cache.top),this.updateFrame=!0,0==this.inWorld?(this.inWorld=e.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold),this.inWorld&&(this._outOfBoundsFired=!1)):(this.inWorld=e.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold),0==this.inWorld&&(this.events.onOutOfBounds.dispatch(this),this._outOfBoundsFired=!0,this.outOfBoundsKill&&this.kill())),this._cache.cameraVisible=e.Rectangle.intersects(this.game.world.camera.screenView,this.bounds,0),this.autoCull&&(this.renderable=this._cache.cameraVisible),this.body&&this.body.updateBounds(this.center.x,this.center.y,this._cache.scaleX,this._cache.scaleY)},e.Sprite.prototype.getLocalPosition=function(a,b,c){return a.x=(this._cache.a11*this._cache.id*b+-this._cache.a01*this._cache.id*c+(this._cache.a12*this._cache.a01-this._cache.a02*this._cache.a11)*this._cache.id)*this.scale.x+this._cache.a02,a.y=(this._cache.a00*this._cache.id*c+-this._cache.a10*this._cache.id*b+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.a10)*this._cache.id)*this.scale.y+this._cache.a12,a},e.Sprite.prototype.getLocalUnmodifiedPosition=function(a,b,c){return a.x=this._cache.a11*this._cache.idi*b+-this._cache.i01*this._cache.idi*c+(this._cache.a12*this._cache.i01-this._cache.a02*this._cache.a11)*this._cache.idi+this.anchor.x*this._cache.width,a.y=this._cache.a00*this._cache.idi*c+-this._cache.i10*this._cache.idi*b+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.i10)*this._cache.idi+this.anchor.y*this._cache.height,a},e.Sprite.prototype.resetCrop=function(){this.crop=new e.Rectangle(0,0,this._cache.width,this._cache.height),this.texture.setFrame(this.crop),this.cropEnabled=!1},e.Sprite.prototype.postUpdate=function(){this.key instanceof e.BitmapData&&this.key._dirty&&this.key.render(),this.exists&&(this.body&&this.body.postUpdate(),this.fixedToCamera?(this._cache.x=this.game.camera.view.x+this.cameraOffset.x,this._cache.y=this.game.camera.view.y+this.cameraOffset.y):(this._cache.x=this.x,this._cache.y=this.y),this.world.setTo(this.game.camera.x+this.worldTransform[2],this.game.camera.y+this.worldTransform[5]),this.position.x=this._cache.x,this.position.y=this._cache.y)},e.Sprite.prototype.loadTexture=function(a,b){this.key=a,a instanceof e.RenderTexture?this.currentFrame=this.game.cache.getTextureFrame(a.name):a instanceof e.BitmapData?(this.setTexture(a.texture),this.currentFrame=a.textureFrame):a instanceof d.Texture?this.currentFrame=b:(("undefined"==typeof a||this.game.cache.checkImageKey(a)===!1)&&(a="__default",this.key=a),this.game.cache.isSpriteSheet(a)?(this.animations.loadFrameData(this.game.cache.getFrameData(a)),"undefined"!=typeof b&&("string"==typeof b?this.frameName=b:this.frame=b)):(this.currentFrame=this.game.cache.getFrame(a),this.setTexture(d.TextureCache[a])))},e.Sprite.prototype.centerOn=function(a,b){return this.x=a+(this.x-this.center.x),this.y=b+(this.y-this.center.y),this},e.Sprite.prototype.revive=function(a){return"undefined"==typeof a&&(a=1),this.alive=!0,this.exists=!0,this.visible=!0,this.health=a,this.events&&this.events.onRevived.dispatch(this),this},e.Sprite.prototype.kill=function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.events&&this.events.onKilled.dispatch(this),this},e.Sprite.prototype.destroy=function(){this.group&&this.group.remove(this),this.input&&this.input.destroy(),this.events&&this.events.destroy(),this.animations&&this.animations.destroy(),this.alive=!1,this.exists=!1,this.visible=!1,this.game=null},e.Sprite.prototype.damage=function(a){return this.alive&&(this.health-=a,this.health<0&&this.kill()),this},e.Sprite.prototype.reset=function(a,b,c){return"undefined"==typeof c&&(c=1),this.x=a,this.y=b,this.position.x=this.x,this.position.y=this.y,this.alive=!0,this.exists=!0,this.visible=!0,this.renderable=!0,this._outOfBoundsFired=!1,this.health=c,this.body&&this.body.reset(),this},e.Sprite.prototype.bringToTop=function(){return this.group?this.group.bringToTop(this):this.game.world.bringToTop(this),this},e.Sprite.prototype.play=function(a,b,c,d){return this.animations?this.animations.play(a,b,c,d):void 0},Object.defineProperty(e.Sprite.prototype,"angle",{get:function(){return e.Math.wrapAngle(e.Math.radToDeg(this.rotation))},set:function(a){this.rotation=e.Math.degToRad(e.Math.wrapAngle(a))}}),Object.defineProperty(e.Sprite.prototype,"frame",{get:function(){return this.animations.frame},set:function(a){this.animations.frame=a}}),Object.defineProperty(e.Sprite.prototype,"frameName",{get:function(){return this.animations.frameName},set:function(a){this.animations.frameName=a}}),Object.defineProperty(e.Sprite.prototype,"inCamera",{get:function(){return this._cache.cameraVisible}}),Object.defineProperty(e.Sprite.prototype,"width",{get:function(){return this.scale.x*this.currentFrame.width},set:function(a){this.scale.x=a/this.currentFrame.width,this._cache.scaleX=a/this.currentFrame.width,this._width=a}}),Object.defineProperty(e.Sprite.prototype,"height",{get:function(){return this.scale.y*this.currentFrame.height},set:function(a){this.scale.y=a/this.currentFrame.height,this._cache.scaleY=a/this.currentFrame.height,this._height=a}}),Object.defineProperty(e.Sprite.prototype,"inputEnabled",{get:function(){return this.input.enabled},set:function(a){a?0==this.input.enabled&&this.input.start():this.input.enabled&&this.input.stop()}}),e.TileSprite=function(a,b,c,f,g,h,i){b=b||0,c=c||0,f=f||256,g=g||256,h=h||null,i=i||null,e.Sprite.call(this,a,b,c,h,i),this.texture=d.TextureCache[h],d.TilingSprite.call(this,this.texture,f,g),this.type=e.TILESPRITE,this.tileScale=new e.Point(1,1),this.tilePosition=new e.Point(0,0)},e.TileSprite.prototype=e.Utils.extend(!0,d.TilingSprite.prototype,e.Sprite.prototype),e.TileSprite.prototype.constructor=e.TileSprite,e.Text=function(a,b,c,f,g){b=b||0,c=c||0,f=f||"",g=g||"",this.exists=!0,this.alive=!0,this.group=null,this.name="",this.game=a,this._text=f,this._style=g,d.Text.call(this,f,g),this.type=e.TEXT,this.position.x=this.x=b,this.position.y=this.y=c,this.anchor=new e.Point,this.scale=new e.Point(1,1),this._cache={dirty:!1,a00:1,a01:0,a02:b,a10:0,a11:1,a12:c,id:1,x:-1,y:-1,scaleX:1,scaleY:1},this._cache.x=this.x,this._cache.y=this.y,this.renderable=!0},e.Text.prototype=Object.create(d.Text.prototype),e.Text.prototype.constructor=e.Text,e.Text.prototype.update=function(){this.exists&&(this._cache.dirty=!1,this._cache.x=this.x,this._cache.y=this.y,(this.position.x!=this._cache.x||this.position.y!=this._cache.y)&&(this.position.x=this._cache.x,this.position.y=this._cache.y,this._cache.dirty=!0))},e.Text.prototype.destroy=function(){this.group&&this.group.remove(this),this.canvas.parentNode?this.canvas.parentNode.removeChild(this.canvas):(this.canvas=null,this.context=null),this.exists=!1,this.group=null},Object.defineProperty(e.Text.prototype,"angle",{get:function(){return e.Math.radToDeg(this.rotation)},set:function(a){this.rotation=e.Math.degToRad(a)}}),Object.defineProperty(e.Text.prototype,"content",{get:function(){return this._text},set:function(a){a!==this._text&&(this._text=a,this.setText(a))}}),Object.defineProperty(e.Text.prototype,"font",{get:function(){return this._style},set:function(a){a!==this._style&&(this._style=a,this.setStyle(a))}}),e.BitmapText=function(a,b,c,f,g){b=b||0,c=c||0,f=f||"",g=g||"",this.exists=!0,this.alive=!0,this.group=null,this.name="",this.game=a,d.BitmapText.call(this,f,g),this.type=e.BITMAPTEXT,this.position.x=b,this.position.y=c,this.anchor=new e.Point,this.scale=new e.Point(1,1),this._cache={dirty:!1,a00:1,a01:0,a02:b,a10:0,a11:1,a12:c,id:1,x:-1,y:-1,scaleX:1,scaleY:1},this._cache.x=this.x,this._cache.y=this.y,this.renderable=!0},e.BitmapText.prototype=Object.create(d.BitmapText.prototype),e.BitmapText.prototype.constructor=e.BitmapText,e.BitmapText.prototype.update=function(){this.exists&&(this._cache.dirty=!1,this._cache.x=this.x,this._cache.y=this.y,(this.position.x!=this._cache.x||this.position.y!=this._cache.y)&&(this.position.x=this._cache.x,this.position.y=this._cache.y,this._cache.dirty=!0),this.pivot.x=this.anchor.x*this.width,this.pivot.y=this.anchor.y*this.height)},e.BitmapText.prototype.destroy=function(){this.group&&this.group.remove(this),this.canvas&&this.canvas.parentNode?this.canvas.parentNode.removeChild(this.canvas):(this.canvas=null,this.context=null),this.exists=!1,this.group=null},Object.defineProperty(e.BitmapText.prototype,"angle",{get:function(){return e.Math.radToDeg(this.rotation)},set:function(a){this.rotation=e.Math.degToRad(a)}}),Object.defineProperty(e.BitmapText.prototype,"x",{get:function(){return this.position.x},set:function(a){this.position.x=a}}),Object.defineProperty(e.BitmapText.prototype,"y",{get:function(){return this.position.y},set:function(a){this.position.y=a}}),e.Button=function(a,b,c,d,f,g,h,i,j){b=b||0,c=c||0,d=d||null,f=f||null,g=g||this,e.Sprite.call(this,a,b,c,d,i),this.type=e.BUTTON,this._onOverFrameName=null,this._onOutFrameName=null,this._onDownFrameName=null,this._onUpFrameName=null,this._onOverFrameID=null,this._onOutFrameID=null,this._onDownFrameID=null,this._onUpFrameID=null,this.onOverSound=null,this.onOutSound=null,this.onDownSound=null,this.onUpSound=null,this.onOverSoundMarker="",this.onOutSoundMarker="",this.onDownSoundMarker="",this.onUpSoundMarker="",this.onInputOver=new e.Signal,this.onInputOut=new e.Signal,this.onInputDown=new e.Signal,this.onInputUp=new e.Signal,this.freezeFrames=!1,this.forceOut=!0,this.setFrames(h,i,j),null!==f&&this.onInputUp.add(f,g),this.input.start(0,!0),this.events.onInputOver.add(this.onInputOverHandler,this),this.events.onInputOut.add(this.onInputOutHandler,this),this.events.onInputDown.add(this.onInputDownHandler,this),this.events.onInputUp.add(this.onInputUpHandler,this)},e.Button.prototype=Object.create(e.Sprite.prototype),e.Button.prototype=e.Utils.extend(!0,e.Button.prototype,e.Sprite.prototype,d.Sprite.prototype),e.Button.prototype.constructor=e.Button,e.Button.prototype.setFrames=function(a,b,c){null!==a&&("string"==typeof a?(this._onOverFrameName=a,this.input.pointerOver()&&(this.frameName=a)):(this._onOverFrameID=a,this.input.pointerOver()&&(this.frame=a))),null!==b&&("string"==typeof b?(this._onOutFrameName=b,this._onUpFrameName=b,0==this.input.pointerOver()&&(this.frameName=b)):(this._onOutFrameID=b,this._onUpFrameID=b,0==this.input.pointerOver()&&(this.frame=b))),null!==c&&("string"==typeof c?(this._onDownFrameName=c,this.input.pointerDown()&&(this.frameName=c)):(this._onDownFrameID=c,this.input.pointerDown()&&(this.frame=c)))},e.Button.prototype.setSounds=function(a,b,c,d,e,f,g,h){this.setOverSound(a,b),this.setOutSound(e,f),this.setUpSound(g,h),this.setDownSound(c,d)},e.Button.prototype.setOverSound=function(a,b){this.onOverSound=null,this.onOverSoundMarker="",a instanceof e.Sound&&(this.onOverSound=a),"string"==typeof b&&(this.onOverSoundMarker=b)},e.Button.prototype.setOutSound=function(a,b){this.onOutSound=null,this.onOutSoundMarker="",a instanceof e.Sound&&(this.onOutSound=a),"string"==typeof b&&(this.onOutSoundMarker=b)},e.Button.prototype.setUpSound=function(a,b){this.onUpSound=null,this.onUpSoundMarker="",a instanceof e.Sound&&(this.onUpSound=a),"string"==typeof b&&(this.onUpSoundMarker=b)},e.Button.prototype.setDownSound=function(a,b){this.onDownSound=null,this.onDownSoundMarker="",a instanceof e.Sound&&(this.onDownSound=a),"string"==typeof b&&(this.onDownSoundMarker=b)},e.Button.prototype.onInputOverHandler=function(a){0==this.freezeFrames&&(null!=this._onOverFrameName?this.frameName=this._onOverFrameName:null!=this._onOverFrameID&&(this.frame=this._onOverFrameID)),this.onOverSound&&this.onOverSound.play(this.onOverSoundMarker),this.onInputOver&&this.onInputOver.dispatch(this,a)},e.Button.prototype.onInputOutHandler=function(a){0==this.freezeFrames&&(null!=this._onOutFrameName?this.frameName=this._onOutFrameName:null!=this._onOutFrameID&&(this.frame=this._onOutFrameID)),this.onOutSound&&this.onOutSound.play(this.onOutSoundMarker),this.onInputOut&&this.onInputOut.dispatch(this,a)},e.Button.prototype.onInputDownHandler=function(a){0==this.freezeFrames&&(null!=this._onDownFrameName?this.frameName=this._onDownFrameName:null!=this._onDownFrameID&&(this.frame=this._onDownFrameID)),this.onDownSound&&this.onDownSound.play(this.onDownSoundMarker),this.onInputDown&&this.onInputDown.dispatch(this,a)},e.Button.prototype.onInputUpHandler=function(a){0==this.freezeFrames&&(null!=this._onUpFrameName?this.frameName=this._onUpFrameName:null!=this._onUpFrameID&&(this.frame=this._onUpFrameID)),this.onUpSound&&this.onUpSound.play(this.onUpSoundMarker),this.forceOut&&0==this.freezeFrames&&(null!=this._onOutFrameName?this.frameName=this._onOutFrameName:null!=this._onOutFrameID&&(this.frame=this._onOutFrameID)),this.onInputUp&&this.onInputUp.dispatch(this,a)},e.Graphics=function(a,b,c){this.game=a,d.Graphics.call(this),this.type=e.GRAPHICS,this.position.x=b,this.position.y=c},e.Graphics.prototype=Object.create(d.Graphics.prototype),e.Graphics.prototype.constructor=e.Graphics,e.Graphics.prototype.destroy=function(){this.clear(),this.group&&this.group.remove(this),this.game=null},e.Graphics.prototype.drawPolygon=function(a){graphics.moveTo(a.points[0].x,a.points[0].y);for(var b=1;bh;h++)f[h].updateTransform();var j=a.__renderGroup;j?a==j.root?j.render(this.projection,this.glFramebuffer):j.renderSpecific(a,this.projection,this.glFramebuffer):(this.renderGroup||(this.renderGroup=new d.WebGLRenderGroup(e)),this.renderGroup.setRenderable(a),this.renderGroup.render(this.projection,this.glFramebuffer)),a.worldTransform=g},e.RenderTexture.prototype.renderCanvas=function(a,b,c){var e=a.children;a.worldTransform=d.mat3.create(),b&&(a.worldTransform[2]=b.x,a.worldTransform[5]=b.y);for(var f=0,g=e.length;g>f;f++)e[f].updateTransform();c&&this.renderer.context.clearRect(0,0,this.width,this.height),this.renderer.renderDisplayObject(a),this.renderer.context.setTransform(1,0,0,1,0,0)},e.Canvas={create:function(a,b){a=a||256,b=b||256;var c=document.createElement("canvas");return c.width=a,c.height=b,c.style.display="block",c},getOffset:function(a,b){b=b||new e.Point;var c=a.getBoundingClientRect(),d=a.clientTop||document.body.clientTop||0,f=a.clientLeft||document.body.clientLeft||0,g=window.pageYOffset||a.scrollTop||document.body.scrollTop,h=window.pageXOffset||a.scrollLeft||document.body.scrollLeft;return b.x=c.left+h-f,b.y=c.top+g-d,b},getAspectRatio:function(a){return a.width/a.height},setBackgroundColor:function(a,b){return b=b||"rgb(0,0,0)",a.style.backgroundColor=b,a},setTouchAction:function(a,b){return b=b||"none",a.style.msTouchAction=b,a.style["ms-touch-action"]=b,a.style["touch-action"]=b,a},setUserSelect:function(a,b){return b=b||"none",a.style["-webkit-touch-callout"]=b,a.style["-webkit-user-select"]=b,a.style["-khtml-user-select"]=b,a.style["-moz-user-select"]=b,a.style["-ms-user-select"]=b,a.style["user-select"]=b,a.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",a},addToDOM:function(a,b,c){var d;return"undefined"==typeof c&&(c=!0),b&&("string"==typeof b?d=document.getElementById(b):"object"==typeof b&&1===b.nodeType&&(d=b),c&&(d.style.overflow="hidden")),d||(d=document.body),d.appendChild(a),a},setTransform:function(a,b,c,d,e,f,g){return a.setTransform(d,f,g,e,b,c),a},setSmoothingEnabled:function(a,b){return a.imageSmoothingEnabled=b,a.mozImageSmoothingEnabled=b,a.oImageSmoothingEnabled=b,a.webkitImageSmoothingEnabled=b,a.msImageSmoothingEnabled=b,a},setImageRenderingCrisp:function(a){return a.style["image-rendering"]="crisp-edges",a.style["image-rendering"]="-moz-crisp-edges",a.style["image-rendering"]="-webkit-optimize-contrast",a.style.msInterpolationMode="nearest-neighbor",a},setImageRenderingBicubic:function(a){return a.style["image-rendering"]="auto",a.style.msInterpolationMode="bicubic",a}},e.StageScaleMode=function(a,b,c){this.game=a,this.width=b,this.height=c,this.minWidth=null,this.maxWidth=null,this.minHeight=null,this.maxHeight=null,this._startHeight=0,this.forceLandscape=!1,this.forcePortrait=!1,this.incorrectOrientation=!1,this.pageAlignHorizontally=!1,this.pageAlignVertically=!1,this._width=0,this._height=0,this.maxIterations=5,this.orientationSprite=null,this.enterLandscape=new e.Signal,this.enterPortrait=new e.Signal,this.orientation=window.orientation?window.orientation:window.outerWidth>window.outerHeight?90:0,this.scaleFactor=new e.Point(1,1),this.aspectRatio=0;var d=this;window.addEventListener("orientationchange",function(a){return d.checkOrientation(a)},!1),window.addEventListener("resize",function(a){return d.checkResize(a)},!1),document.addEventListener("webkitfullscreenchange",function(a){return d.fullScreenChange(a)},!1),document.addEventListener("mozfullscreenchange",function(a){return d.fullScreenChange(a)},!1),document.addEventListener("fullscreenchange",function(a){return d.fullScreenChange(a)},!1)},e.StageScaleMode.EXACT_FIT=0,e.StageScaleMode.NO_SCALE=1,e.StageScaleMode.SHOW_ALL=2,e.StageScaleMode.prototype={startFullScreen:function(a){if(!this.isFullScreen){"undefined"!=typeof a&&e.Canvas.setSmoothingEnabled(this.game.context,a);var b=this.game.canvas;this._width=this.width,this._height=this.height,console.log("startFullScreen",this._width,this._height),b.requestFullScreen?b.requestFullScreen():b.mozRequestFullScreen?b.mozRequestFullScreen():b.webkitRequestFullScreen&&b.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}},stopFullScreen:function(){document.cancelFullScreen?document.cancelFullScreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen()},fullScreenChange:function(){this.isFullScreen?(this.game.stage.canvas.style.width="100%",this.game.stage.canvas.style.height="100%",this.setMaximum(),this.game.input.scale.setTo(this.game.width/this.width,this.game.height/this.height),this.aspectRatio=this.width/this.height,this.scaleFactor.x=this.game.width/this.width,this.scaleFactor.y=this.game.height/this.height):(this.game.stage.canvas.style.width=this.game.width+"px",this.game.stage.canvas.style.height=this.game.height+"px",this.width=this._width,this.height=this._height,this.game.input.scale.setTo(this.game.width/this.width,this.game.height/this.height),this.aspectRatio=this.width/this.height,this.scaleFactor.x=this.game.width/this.width,this.scaleFactor.y=this.game.height/this.height)},forceOrientation:function(a,b,c){"undefined"==typeof b&&(b=!1),this.forceLandscape=a,this.forcePortrait=b,"undefined"!=typeof c&&((null==c||0==this.game.cache.checkImageKey(c))&&(c="__default"),this.orientationSprite=new d.Sprite(d.TextureCache[c]),this.orientationSprite.anchor.x=.5,this.orientationSprite.anchor.y=.5,this.orientationSprite.position.x=this.game.width/2,this.orientationSprite.position.y=this.game.height/2,this.checkOrientationState(),this.incorrectOrientation?(this.orientationSprite.visible=!0,this.game.world.visible=!1):(this.orientationSprite.visible=!1,this.game.world.visible=!0),this.game.stage._stage.addChild(this.orientationSprite))},checkOrientationState:function(){this.incorrectOrientation?(this.forceLandscape&&window.innerWidth>window.innerHeight||this.forcePortrait&&window.innerHeight>window.innerWidth)&&(this.game.paused=!1,this.incorrectOrientation=!1,this.orientationSprite&&(this.orientationSprite.visible=!1,this.game.world.visible=!0),this.refresh()):(this.forceLandscape&&window.innerWidthwindow.outerHeight?90:0,this.isLandscape?this.enterLandscape.dispatch(this.orientation,!0,!1):this.enterPortrait.dispatch(this.orientation,!1,!0),this.game.stage.scaleMode!==e.StageScaleMode.NO_SCALE&&this.refresh(),this.checkOrientationState()},refresh:function(){var a=this;0==this.game.device.iPad&&0==this.game.device.webApp&&0==this.game.device.desktop&&(this.game.device.android&&0==this.game.device.chrome?window.scrollTo(0,1):window.scrollTo(0,0)),null==this._check&&this.maxIterations>0&&(this._iterations=this.maxIterations,this._check=window.setInterval(function(){return a.setScreenSize()},10),this.setScreenSize())},setScreenSize:function(a){"undefined"==typeof a&&(a=!1),0==this.game.device.iPad&&0==this.game.device.webApp&&0==this.game.device.desktop&&(this.game.device.android&&0==this.game.device.chrome?window.scrollTo(0,1):window.scrollTo(0,0)),this._iterations--,(a||window.innerHeight>this._startHeight||this._iterations<0)&&(document.documentElement.style.minHeight=window.innerHeight+"px",1==this.incorrectOrientation?this.setMaximum():this.game.stage.scaleMode==e.StageScaleMode.EXACT_FIT?this.setExactFit():this.game.stage.scaleMode==e.StageScaleMode.SHOW_ALL&&this.setShowAll(),this.setSize(),clearInterval(this._check),this._check=null)},setSize:function(){0==this.incorrectOrientation&&(this.maxWidth&&this.width>this.maxWidth&&(this.width=this.maxWidth),this.maxHeight&&this.height>this.maxHeight&&(this.height=this.maxHeight),this.minWidth&&this.widththis.maxWidth?this.maxWidth:a,this.height=this.maxHeight&&b>this.maxHeight?this.maxHeight:b}},Object.defineProperty(e.StageScaleMode.prototype,"isFullScreen",{get:function(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement}}),Object.defineProperty(e.StageScaleMode.prototype,"isPortrait",{get:function(){return 0==this.orientation||180==this.orientation}}),Object.defineProperty(e.StageScaleMode.prototype,"isLandscape",{get:function(){return 90===this.orientation||-90===this.orientation}}),e.Device=function(){this.patchAndroidClearRectBug=!1,this.desktop=!1,this.iOS=!1,this.android=!1,this.chromeOS=!1,this.linux=!1,this.macOS=!1,this.windows=!1,this.canvas=!1,this.file=!1,this.fileSystem=!1,this.localStorage=!1,this.webGL=!1,this.worker=!1,this.touch=!1,this.mspointer=!1,this.css3D=!1,this.pointerLock=!1,this.arora=!1,this.chrome=!1,this.epiphany=!1,this.firefox=!1,this.ie=!1,this.ieVersion=0,this.mobileSafari=!1,this.midori=!1,this.opera=!1,this.safari=!1,this.webApp=!1,this.audioData=!1,this.webAudio=!1,this.ogg=!1,this.opus=!1,this.mp3=!1,this.wav=!1,this.m4a=!1,this.webm=!1,this.iPhone=!1,this.iPhone4=!1,this.iPad=!1,this.pixelRatio=0,this.littleEndian=!1,this._checkAudio(),this._checkBrowser(),this._checkCSS3D(),this._checkDevice(),this._checkFeatures(),this._checkOS()},e.Device.prototype={_checkOS:function(){var a=navigator.userAgent;/Android/.test(a)?this.android=!0:/CrOS/.test(a)?this.chromeOS=!0:/iP[ao]d|iPhone/i.test(a)?this.iOS=!0:/Linux/.test(a)?this.linux=!0:/Mac OS/.test(a)?this.macOS=!0:/Windows/.test(a)&&(this.windows=!0),(this.windows||this.macOS||this.linux)&&(this.desktop=!0)},_checkFeatures:function(){this.canvas=!!window.CanvasRenderingContext2D;try{this.localStorage=!!localStorage.getItem}catch(a){this.localStorage=!1}this.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),this.fileSystem=!!window.requestFileSystem,this.webGL=function(){try{var a=document.createElement("canvas");return!!window.WebGLRenderingContext&&(a.getContext("webgl")||a.getContext("experimental-webgl"))}catch(b){return!1}}(),this.webGL=null===this.webGL||this.webGL===!1?!1:!0,this.worker=!!window.Worker,("ontouchstart"in document.documentElement||window.navigator.msPointerEnabled)&&(this.touch=!0),window.navigator.msPointerEnabled&&(this.mspointer=!0),this.pointerLock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document},_checkBrowser:function(){var a=navigator.userAgent;/Arora/.test(a)?this.arora=!0:/Chrome/.test(a)?this.chrome=!0:/Epiphany/.test(a)?this.epiphany=!0:/Firefox/.test(a)?this.firefox=!0:/Mobile Safari/.test(a)?this.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(a)?(this.ie=!0,this.ieVersion=parseInt(RegExp.$1)):/Midori/.test(a)?this.midori=!0:/Opera/.test(a)?this.opera=!0:/Safari/.test(a)&&(this.safari=!0),navigator.standalone&&(this.webApp=!0)},_checkAudio:function(){this.audioData=!!window.Audio,this.webAudio=!(!window.webkitAudioContext&&!window.AudioContext);var a=document.createElement("audio"),b=!1;try{(b=!!a.canPlayType)&&(a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.ogg=!0),a.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")&&(this.opus=!0),a.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(this.mp3=!0),a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(this.wav=!0),(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;").replace(/^no$/,""))&&(this.m4a=!0),a.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")&&(this.webm=!0))}catch(c){}},_checkDevice:function(){this.pixelRatio=window.devicePixelRatio||1,this.iPhone=-1!=navigator.userAgent.toLowerCase().indexOf("iphone"),this.iPhone4=2==this.pixelRatio&&this.iPhone,this.iPad=-1!=navigator.userAgent.toLowerCase().indexOf("ipad"),"undefined"!=typeof Int8Array&&(this.littleEndian=new Int8Array(new Int16Array([1]).buffer)[0]>0)},_checkCSS3D:function(){var a,b=document.createElement("p"),c={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(b,null);for(var d in c)void 0!==b.style[d]&&(b.style[d]="translate3d(1px,1px,1px)",a=window.getComputedStyle(b).getPropertyValue(c[d]));document.body.removeChild(b),this.css3D=void 0!==a&&a.length>0&&"none"!==a},canPlayAudio:function(a){return"mp3"==a&&this.mp3?!0:"ogg"==a&&(this.ogg||this.opus)?!0:"m4a"==a&&this.m4a?!0:"wav"==a&&this.wav?!0:"webm"==a&&this.webm?!0:!1},isConsoleOpen:function(){return window.console&&window.console.firebug?!0:window.console?(console.profile(),console.profileEnd(),console.clear&&console.clear(),console.profiles.length>0):!1}},e.RequestAnimationFrame=function(a){this.game=a,this.isRunning=!1;for(var b=["ms","moz","webkit","o"],c=0;c>>0,b-=d,b*=d,d=b>>>0,b-=d,d+=4294967296*b;return 2.3283064365386963e-10*(d>>>0)},integer:function(){return 4294967296*this.rnd.apply(this)},frac:function(){return this.rnd.apply(this)+1.1102230246251565e-16*(0|2097152*this.rnd.apply(this))},real:function(){return this.integer()+this.frac()},integerInRange:function(a,b){return Math.floor(this.realInRange(a,b))},realInRange:function(a,b){return this.frac()*(b-a)+a},normal:function(){return 1-2*this.frac()},uuid:function(){var a,b;for(b=a="";a++<36;b+=~a%5|4&3*a?(15^a?8^this.frac()*(20^a?16:4):4).toString(16):"-");return b},pick:function(a){return a[this.integerInRange(0,a.length)]},weightedPick:function(a){return a[~~(Math.pow(this.frac(),2)*a.length)]},timestamp:function(a,b){return this.realInRange(a||9466848e5,b||1577862e6)},angle:function(){return this.integerInRange(-180,180)}},e.Math={PI2:2*Math.PI,fuzzyEqual:function(a,b,c){return"undefined"==typeof c&&(c=1e-4),Math.abs(a-b)a},fuzzyGreaterThan:function(a,b,c){return"undefined"==typeof c&&(c=1e-4),a>b-c},fuzzyCeil:function(a,b){return"undefined"==typeof b&&(b=1e-4),Math.ceil(a-b)},fuzzyFloor:function(a,b){return"undefined"==typeof b&&(b=1e-4),Math.floor(a+b)},average:function(){for(var a=[],b=0;b0?Math.floor(a):Math.ceil(a)},shear:function(a){return a%1},snapTo:function(a,b,c){return"undefined"==typeof c&&(c=0),0==b?a:(a-=c,a=b*Math.round(a/b),c+a)},snapToFloor:function(a,b,c){return"undefined"==typeof c&&(c=0),0==b?a:(a-=c,a=b*Math.floor(a/b),c+a)},snapToCeil:function(a,b,c){return"undefined"==typeof c&&(c=0),0==b?a:(a-=c,a=b*Math.ceil(a/b),c+a)},snapToInArray:function(a,b,c){if("undefined"==typeof c&&(c=!0),c&&b.sort(),a=f-a?f:e},roundTo:function(a,b,c){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=10);var d=Math.pow(c,-b);return Math.round(a*d)/d},floorTo:function(a,b,c){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=10);var d=Math.pow(c,-b);return Math.floor(a*d)/d},ceilTo:function(a,b,c){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=10);var d=Math.pow(c,-b);return Math.ceil(a*d)/d},interpolateFloat:function(a,b,c){return(b-a)*c+a},angleBetween:function(a,b,c,d){return Math.atan2(d-b,c-a)},normalizeAngle:function(a,b){"undefined"==typeof b&&(b=!0);var c=b?GameMath.PI:180;return this.wrap(a,c,-c)},nearestAngleBetween:function(a,b,c){"undefined"==typeof c&&(c=!0);var d=c?Math.PI:180;return a=this.normalizeAngle(a,c),b=this.normalizeAngle(b,c),-d/2>a&&b>d/2&&(a+=2*d),-d/2>b&&a>d/2&&(b+=2*d),b-a},interpolateAngles:function(a,b,c,d,e){return"undefined"==typeof d&&(d=!0),"undefined"==typeof e&&(e=null),a=this.normalizeAngle(a,d),b=this.normalizeAngleToAnother(b,a,d),"function"==typeof e?e(c,a,b-a,1):this.interpolateFloat(a,b,c)},chanceRoll:function(a){return"undefined"==typeof a&&(a=50),0>=a?!1:a>=100?!0:100*Math.random()>=a?!1:!0},numberArray:function(a,b){for(var c=[],d=a;b>=d;d++)c.push(d);return c},maxAdd:function(a,b,c){return a+=b,a>c&&(a=c),a},minSub:function(a,b,c){return a-=b,c>a&&(a=c),a},wrap:function(a,b,c){var d=c-b;if(0>=d)return 0;var e=(a-b)%d;return 0>e&&(e+=d),e+b},wrapValue:function(a,b,c){var d;return a=Math.abs(a),b=Math.abs(b),c=Math.abs(c),d=(a+b)%c},randomSign:function(){return Math.random()>.5?1:-1},isOdd:function(a){return 1&a},isEven:function(a){return 1&a?!1:!0},max:function(){for(var a=1,b=0,c=arguments.length;c>a;a++)arguments[b]a;a++)arguments[a]=-180&&180>=a?a:(b=(a+180)%360,0>b&&(b+=360),b-180)},angleLimit:function(a,b,c){var d=a;return a>c?d=c:b>a&&(d=b),d},linearInterpolation:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d);return 0>b?this.linear(a[0],a[1],d):b>1?this.linear(a[c],a[c-1],c-d):this.linear(a[e],a[e+1>c?c:e+1],d-e)},bezierInterpolation:function(a,b){for(var c=0,d=a.length-1,e=0;d>=e;e++)c+=Math.pow(1-b,d-e)*Math.pow(b,e)*a[e]*this.bernstein(d,e);return c},catmullRomInterpolation:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d);return a[0]===a[c]?(0>b&&(e=Math.floor(d=c*(1+b))),this.catmullRom(a[(e-1+c)%c],a[e],a[(e+1)%c],a[(e+2)%c],d-e)):0>b?a[0]-(this.catmullRom(a[0],a[0],a[1],a[1],-d)-a[0]):b>1?a[c]-(this.catmullRom(a[c],a[c],a[c-1],a[c-1],d-c)-a[c]):this.catmullRom(a[e?e-1:0],a[e],a[e+1>c?c:e+1],a[e+2>c?c:e+2],d-e)},linear:function(a,b,c){return(b-a)*c+a},bernstein:function(a,b){return this.factorial(a)/this.factorial(b)/this.factorial(a-b)},catmullRom:function(a,b,c,d,e){var f=.5*(c-a),g=.5*(d-b),h=e*e,i=e*h;return(2*b-2*c+f+g)*i+(-3*b+3*c-2*f-g)*h+f*e+b},difference:function(a,b){return Math.abs(a-b)},getRandom:function(a,b,c){if("undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=0),null!=a){var d=c;if((0==d||d>a.length-b)&&(d=a.length-b),d>0)return a[b+Math.floor(Math.random()*d)]}return null},floor:function(a){var b=0|a;return a>0?b:b!=a?b-1:b},ceil:function(a){var b=0|a;return a>0?b!=a?b+1:b:b},sinCosGenerator:function(a,b,c,d){"undefined"==typeof b&&(b=1),"undefined"==typeof c&&(c=1),"undefined"==typeof d&&(d=1);for(var e=b,f=c,g=d*Math.PI/a,h=[],i=[],j=0;a>j;j++)f-=e*g,e+=f*g,h[j]=f,i[j]=e;return{sin:i,cos:h,length:a}},shift:function(a){var b=a.shift();return a.push(b),b},shuffleArray:function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},distance:function(a,b,c,d){var e=a-c,f=b-d;return Math.sqrt(e*e+f*f)},distanceRounded:function(a,b,c,d){return Math.round(e.Math.distance(a,b,c,d))},clamp:function(a,b,c){return b>a?b:a>c?c:a},clampBottom:function(a,b){return b>a?b:a},within:function(a,b,c){return Math.abs(a-b)<=c},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},smoothstep:function(a,b,c){return b>=a?0:a>=c?1:(a=(a-b)/(c-b),a*a*(3-2*a))},smootherstep:function(a,b,c){return b>=a?0:a>=c?1:(a=(a-b)/(c-b),a*a*a*(a*(6*a-15)+10))},sign:function(a){return 0>a?-1:a>0?1:0},degToRad:function(){var a=Math.PI/180;return function(b){return b*a}}(),radToDeg:function(){var a=180/Math.PI;return function(b){return b*a}}()},e.QuadTree=function(a,b,c,d,e,f,g,h){this.physicsManager=a,this.ID=a.quadTreeID,a.quadTreeID++,this.maxObjects=f||10,this.maxLevels=g||4,this.level=h||0,this.bounds={x:Math.round(b),y:Math.round(c),width:d,height:e,subWidth:Math.floor(d/2),subHeight:Math.floor(e/2),right:Math.round(b)+Math.floor(d/2),bottom:Math.round(c)+Math.floor(e/2)},this.objects=[],this.nodes=[]},e.QuadTree.prototype={split:function(){this.level++,this.nodes[0]=new e.QuadTree(this.physicsManager,this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level),this.nodes[1]=new e.QuadTree(this.physicsManager,this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level),this.nodes[2]=new e.QuadTree(this.physicsManager,this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level),this.nodes[3]=new e.QuadTree(this.physicsManager,this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level)},insert:function(a){var b,c=0;if(null!=this.nodes[0]&&(b=this.getIndex(a),-1!==b))return this.nodes[b].insert(a),void 0;if(this.objects.push(a),this.objects.length>this.maxObjects&&this.levelthis.bounds.bottom&&(b=2):a.x>this.bounds.right&&(a.ythis.bounds.bottom&&(b=3)),b},retrieve:function(a){var b=this.objects;return a.body.quadTreeIndex=this.getIndex(a.body),a.body.quadTreeIDs.push(this.ID),this.nodes[0]&&(-1!==a.body.quadTreeIndex?b=b.concat(this.nodes[a.body.quadTreeIndex].retrieve(a)):(b=b.concat(this.nodes[0].retrieve(a)),b=b.concat(this.nodes[1].retrieve(a)),b=b.concat(this.nodes[2].retrieve(a)),b=b.concat(this.nodes[3].retrieve(a)))),b},clear:function(){this.objects=[];for(var a=0,b=this.nodes.length;b>a;a++)this.nodes[a]&&(this.nodes[a].clear(),delete this.nodes[a])}},e.Circle=function(a,b,c){a=a||0,b=b||0,c=c||0,this.x=a,this.y=b,this._diameter=c,this._radius=c>0?.5*c:0},e.Circle.prototype={circumference:function(){return 2*Math.PI*this._radius},setTo:function(a,b,c){return this.x=a,this.y=b,this._diameter=c,this._radius=.5*c,this},copyFrom:function(a){return this.setTo(a.x,a.y,a.diameter)},copyTo:function(a){return a[x]=this.x,a[y]=this.y,a[diameter]=this._diameter,a},distance:function(a,b){return"undefined"==typeof b&&(b=!1),b?e.Math.distanceRound(this.x,this.y,a.x,a.y):e.Math.distance(this.x,this.y,a.x,a.y)},clone:function(b){return"undefined"==typeof b&&(b=new e.Circle),b.setTo(a.x,a.y,a.diameter)},contains:function(a,b){return e.Circle.contains(this,a,b)},circumferencePoint:function(a,b,c){return e.Circle.circumferencePoint(this,a,b,c)},offset:function(a,b){return this.x+=a,this.y+=b,this},offsetPoint:function(a){return this.offset(a.x,a.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}},Object.defineProperty(e.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(a){a>0&&(this._diameter=a,this._radius=.5*a)}}),Object.defineProperty(e.Circle.prototype,"radius",{get:function(){return this._radius},set:function(a){a>0&&(this._radius=a,this._diameter=2*a)}}),Object.defineProperty(e.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(a){a>this.x?(this._radius=0,this._diameter=0):this.radius=this.x-a}}),Object.defineProperty(e.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(a){athis.y?(this._radius=0,this._diameter=0):this.radius=this.y-a}}),Object.defineProperty(e.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(a){a0?Math.PI*this._radius*this._radius:0}}),Object.defineProperty(e.Circle.prototype,"empty",{get:function(){return 0==this._diameter},set:function(){this.setTo(0,0,0)}}),e.Circle.contains=function(a,b,c){if(b>=a.left&&b<=a.right&&c>=a.top&&c<=a.bottom){var d=(a.x-b)*(a.x-b),e=(a.y-c)*(a.y-c);return d+e<=a.radius*a.radius}return!1},e.Circle.equals=function(a,b){return a.x==b.x&&a.y==b.y&&a.diameter==b.diameter},e.Circle.intersects=function(a,b){return e.Math.distance(a.x,a.y,b.x,b.y)<=a.radius+b.radius},e.Circle.circumferencePoint=function(a,b,c,d){return"undefined"==typeof c&&(c=!1),"undefined"==typeof d&&(d=new e.Point),c===!0&&(b=e.Math.radToDeg(b)),d.x=a.x+a.radius*Math.cos(b),d.y=a.y+a.radius*Math.sin(b),d},e.Circle.intersectsRectangle=function(a,b){var c=Math.abs(a.x-b.x-b.halfWidth),d=b.halfWidth+a.radius;if(c>d)return!1;var e=Math.abs(a.y-b.y-b.halfHeight),f=b.halfHeight+a.radius;if(e>f)return!1;if(c<=b.halfWidth||e<=b.halfHeight)return!0;var g=c-b.halfWidth,h=e-b.halfHeight,i=g*g,j=h*h,k=a.radius*a.radius;return k>=i+j},e.Point=function(a,b){a=a||0,b=b||0,this.x=a,this.y=b},e.Point.prototype={copyFrom:function(a){return this.setTo(a.x,a.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(a,b){return this.x=a,this.y=b,this},add:function(a,b){return this.x+=a,this.y+=b,this},subtract:function(a,b){return this.x-=a,this.y-=b,this},multiply:function(a,b){return this.x*=a,this.y*=b,this},divide:function(a,b){return this.x/=a,this.y/=b,this},clampX:function(a,b){return this.x=e.Math.clamp(this.x,a,b),this},clampY:function(a,b){return this.y=e.Math.clamp(this.y,a,b),this},clamp:function(a,b){return this.x=e.Math.clamp(this.x,a,b),this.y=e.Math.clamp(this.y,a,b),this},clone:function(a){return"undefined"==typeof a&&(a=new e.Point),a.setTo(this.x,this.y)},copyFrom:function(a){return this.setTo(a.x,a.y)},copyTo:function(a){return a[x]=this.x,a[y]=this.y,a},distance:function(a,b){return e.Point.distance(this,a,b)},equals:function(a){return a.x==this.x&&a.y==this.y},rotate:function(a,b,c,d,f){return e.Point.rotate(this,a,b,c,d,f)},getMagnitude:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},setMagnitude:function(a){return this.normalize().multiply(a,a)},normalize:function(){if(!this.isZero()){var a=this.getMagnitude();this.x/=a,this.y/=a}return this},isZero:function(){return 0===this.x&&0===this.y},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}},e.Point.add=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x+b.x,c.y=a.y+b.y,c},e.Point.subtract=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x-b.x,c.y=a.y-b.y,c},e.Point.multiply=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x*b.x,c.y=a.y*b.y,c},e.Point.divide=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x/b.x,c.y=a.y/b.y,c},e.Point.equals=function(a,b){return a.x==b.x&&a.y==b.y},e.Point.distance=function(a,b,c){return"undefined"==typeof c&&(c=!1),c?e.Math.distanceRound(a.x,a.y,b.x,b.y):e.Math.distance(a.x,a.y,b.x,b.y)},e.Point.rotate=function(a,b,c,d,f,g){return f=f||!1,g=g||null,f&&(d=e.Math.degToRad(d)),null===g&&(g=Math.sqrt((b-a.x)*(b-a.x)+(c-a.y)*(c-a.y))),a.setTo(b+g*Math.cos(d),c+g*Math.sin(d))},e.Rectangle=function(a,b,c,d){a=a||0,b=b||0,c=c||0,d=d||0,this.x=a,this.y=b,this.width=c,this.height=d},e.Rectangle.prototype={offset:function(a,b){return this.x+=a,this.y+=b,this},offsetPoint:function(a){return this.offset(a.x,a.y)},setTo:function(a,b,c,d){return this.x=a,this.y=b,this.width=c,this.height=d,this},floor:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y)},floorAll:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.width=Math.floor(this.width),this.height=Math.floor(this.height)},copyFrom:function(a){return this.setTo(a.x,a.y,a.width,a.height)},copyTo:function(a){return a.x=this.x,a.y=this.y,a.width=this.width,a.height=this.height,a},inflate:function(a,b){return e.Rectangle.inflate(this,a,b)},size:function(a){return e.Rectangle.size(this,a)},clone:function(a){return e.Rectangle.clone(this,a) +},contains:function(a,b){return e.Rectangle.contains(this,a,b)},containsRect:function(a){return e.Rectangle.containsRect(this,a)},equals:function(a){return e.Rectangle.equals(this,a)},intersection:function(a){return e.Rectangle.intersection(this,a,output)},intersects:function(a,b){return e.Rectangle.intersects(this,a,b)},intersectsRaw:function(a,b,c,d,f){return e.Rectangle.intersectsRaw(this,a,b,c,d,f)},union:function(a,b){return e.Rectangle.union(this,a,b)},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}},Object.defineProperty(e.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)}}),Object.defineProperty(e.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)}}),Object.defineProperty(e.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){this.height=a<=this.y?0:this.y-a}}),Object.defineProperty(e.Rectangle.prototype,"bottomRight",{get:function(){return new e.Point(this.right,this.bottom)},set:function(a){this.right=a.x,this.bottom=a.y}}),Object.defineProperty(e.Rectangle.prototype,"left",{get:function(){return this.x},set:function(a){this.width=a>=this.right?0:this.right-a,this.x=a}}),Object.defineProperty(e.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(a){this.width=a<=this.x?0:this.x+a}}),Object.defineProperty(e.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}}),Object.defineProperty(e.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}}),Object.defineProperty(e.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(a){this.x=a-this.halfWidth}}),Object.defineProperty(e.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(a){this.y=a-this.halfHeight}}),Object.defineProperty(e.Rectangle.prototype,"top",{get:function(){return this.y},set:function(a){a>=this.bottom?(this.height=0,this.y=a):this.height=this.bottom-a}}),Object.defineProperty(e.Rectangle.prototype,"topLeft",{get:function(){return new e.Point(this.x,this.y)},set:function(a){this.x=a.x,this.y=a.y}}),Object.defineProperty(e.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(){this.setTo(0,0,0,0)}}),e.Rectangle.inflate=function(a,b,c){return a.x-=b,a.width+=2*b,a.y-=c,a.height+=2*c,a},e.Rectangle.inflatePoint=function(a,b){return e.Rectangle.inflate(a,b.x,b.y)},e.Rectangle.size=function(a,b){return"undefined"==typeof b&&(b=new e.Point),b.setTo(a.width,a.height)},e.Rectangle.clone=function(a,b){return"undefined"==typeof b&&(b=new e.Rectangle),b.setTo(a.x,a.y,a.width,a.height)},e.Rectangle.contains=function(a,b,c){return b>=a.x&&b<=a.right&&c>=a.y&&c<=a.bottom},e.Rectangle.containsRaw=function(a,b,c,d,e,f){return e>=a&&a+c>=e&&f>=b&&b+d>=f},e.Rectangle.containsPoint=function(a,b){return e.Rectangle.contains(a,b.x,b.y)},e.Rectangle.containsRect=function(a,b){return a.volume>b.volume?!1:a.x>=b.x&&a.y>=b.y&&a.right<=b.right&&a.bottom<=b.bottom},e.Rectangle.equals=function(a,b){return a.x==b.x&&a.y==b.y&&a.width==b.width&&a.height==b.height},e.Rectangle.intersection=function(a,b,c){return c=c||new e.Rectangle,e.Rectangle.intersects(a,b)&&(c.x=Math.max(a.x,b.x),c.y=Math.max(a.y,b.y),c.width=Math.min(a.right,b.right)-c.x,c.height=Math.min(a.bottom,b.bottom)-c.y),c},e.Rectangle.intersects=function(a,b){return a.xa.right+f||ca.bottom+f||e1){if(a&&a==this.decodeURI(e[0]))return this.decodeURI(e[1]);b[this.decodeURI(e[0])]=this.decodeURI(e[1])}}return b},decodeURI:function(a){return decodeURIComponent(a.replace(/\+/g," "))}},e.TweenManager=function(a){this.game=a,this._tweens=[],this._add=[],this.game.onPause.add(this.pauseAll,this),this.game.onResume.add(this.resumeAll,this)},e.TweenManager.prototype={REVISION:"11dev",getAll:function(){return this._tweens},removeAll:function(){this._tweens=[]},add:function(a){this._add.push(a)},create:function(a){return new e.Tween(a,this.game)},remove:function(a){var b=this._tweens.indexOf(a);-1!==b&&(this._tweens[b].pendingDelete=!0)},update:function(){if(0===this._tweens.length&&0===this._add.length)return!1;for(var a=0,b=this._tweens.length;b>a;)this._tweens[a].update(this.game.time.now)?a++:(this._tweens.splice(a,1),b--);return this._add.length>0&&(this._tweens=this._tweens.concat(this._add),this._add.length=0),!0},isTweening:function(a){return this._tweens.some(function(b){return b._object===a})},pauseAll:function(){for(var a=this._tweens.length-1;a>=0;a--)this._tweens[a].pause()},resumeAll:function(){for(var a=this._tweens.length-1;a>=0;a--)this._tweens[a].resume()}},e.Tween=function(a,b){this._object=a,this.game=b,this._manager=this.game.tweens,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._repeat=0,this._yoyo=!1,this._reversed=!1,this._delayTime=0,this._startTime=null,this._easingFunction=e.Easing.Linear.None,this._interpolationFunction=e.Math.linearInterpolation,this._chainedTweens=[],this._onStartCallback=null,this._onStartCallbackFired=!1,this._onUpdateCallback=null,this._onCompleteCallback=null,this._pausedTime=0,this.pendingDelete=!1;for(var c in a)this._valuesStart[c]=parseFloat(a[c],10);this.onStart=new e.Signal,this.onComplete=new e.Signal,this.isRunning=!1},e.Tween.prototype={to:function(a,b,c,d,e,f,g){b=b||1e3,c=c||null,d=d||!1,e=e||0,f=f||0,g=g||!1;var h;return this._parent?(h=this._manager.create(this._object),this._lastChild.chain(h),this._lastChild=h):(h=this,this._parent=this,this._lastChild=this),h._repeat=f,h._duration=b,h._valuesEnd=a,null!==c&&(h._easingFunction=c),e>0&&(h._delayTime=e),h._yoyo=g,d?this.start():this},start:function(){if(null!==this.game&&null!==this._object){this._manager.add(this),this.onStart.dispatch(this._object),this.isRunning=!0,this._onStartCallbackFired=!1,this._startTime=this.game.time.now+this._delayTime;for(var a in this._valuesEnd){if(this._valuesEnd[a]instanceof Array){if(0===this._valuesEnd[a].length)continue;this._valuesEnd[a]=[this._object[a]].concat(this._valuesEnd[a])}this._valuesStart[a]=this._object[a],this._valuesStart[a]instanceof Array==!1&&(this._valuesStart[a]*=1),this._valuesStartRepeat[a]=this._valuesStart[a]||0}return this}},stop:function(){return this.isRunning=!1,this._manager.remove(this),this},delay:function(a){return this._delayTime=a,this},repeat:function(a){return this._repeat=a,this},yoyo:function(a){return this._yoyo=a,this},easing:function(a){return this._easingFunction=a,this},interpolation:function(a){return this._interpolationFunction=a,this},chain:function(){return this._chainedTweens=arguments,this},loop:function(){return this._lastChild.chain(this),this},onStartCallback:function(a){return this._onStartCallback=a,this},onUpdateCallback:function(a){return this._onUpdateCallback=a,this},onCompleteCallback:function(a){return this._onCompleteCallback=a,this},pause:function(){this._paused=!0,this._pausedTime=this.game.time.now},resume:function(){this._paused=!1,this._startTime+=this.game.time.now-this._pausedTime},update:function(a){if(this.pendingDelete)return!1;if(this._paused||a1?1:c;var d=this._easingFunction(c);for(b in this._valuesEnd){var e=this._valuesStart[b]||0,f=this._valuesEnd[b];f instanceof Array?this._object[b]=this._interpolationFunction(f,d):("string"==typeof f&&(f=e+parseFloat(f,10)),"number"==typeof f&&(this._object[b]=e+(f-e)*d))}if(null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._object,d),1==c){if(this._repeat>0){isFinite(this._repeat)&&this._repeat--;for(b in this._valuesStartRepeat){if("string"==typeof this._valuesEnd[b]&&(this._valuesStartRepeat[b]=this._valuesStartRepeat[b]+parseFloat(this._valuesEnd[b],10)),this._yoyo){var g=this._valuesStartRepeat[b];this._valuesStartRepeat[b]=this._valuesEnd[b],this._valuesEnd[b]=g,this._reversed=!this._reversed}this._valuesStart[b]=this._valuesStartRepeat[b]}return this._startTime=a+this._delayTime,this.onComplete.dispatch(this._object),null!==this._onCompleteCallback&&this._onCompleteCallback.call(this._object),!0}this.onComplete.dispatch(this._object),null!==this._onCompleteCallback&&this._onCompleteCallback.call(this._object);for(var h=0,i=this._chainedTweens.length;i>h;h++)this._chainedTweens[h].start(a);return!1}return!0}},e.Easing={Linear:{None:function(a){return a}},Quadratic:{In:function(a){return a*a},Out:function(a){return a*(2-a)},InOut:function(a){return(a*=2)<1?.5*a*a:-.5*(--a*(a-2)-1)}},Cubic:{In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)}},Quartic:{In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return(a*=2)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)}},Quintic:{In:function(a){return a*a*a*a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)}},Sinusoidal:{In:function(a){return 1-Math.cos(a*Math.PI/2)},Out:function(a){return Math.sin(a*Math.PI/2)},InOut:function(a){return.5*(1-Math.cos(Math.PI*a))}},Exponential:{In:function(a){return 0===a?0:Math.pow(1024,a-1)},Out:function(a){return 1===a?1:1-Math.pow(2,-10*a)},InOut:function(a){return 0===a?0:1===a?1:(a*=2)<1?.5*Math.pow(1024,a-1):.5*(-Math.pow(2,-10*(a-1))+2)}},Circular:{In:function(a){return 1-Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*a)},InOut:function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)}},Elastic:{In:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),-(c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*2*Math.PI/d)))},Out:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),c*Math.pow(2,-10*a)*Math.sin((a-b)*2*Math.PI/d)+1)},InOut:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),(a*=2)<1?-.5*c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*2*Math.PI/d):.5*c*Math.pow(2,-10*(a-=1))*Math.sin((a-b)*2*Math.PI/d)+1)}},Back:{In:function(a){var b=1.70158;return a*a*((b+1)*a-b)},Out:function(a){var b=1.70158;return--a*a*((b+1)*a+b)+1},InOut:function(a){var b=2.5949095;return(a*=2)<1?.5*a*a*((b+1)*a-b):.5*((a-=2)*a*((b+1)*a+b)+2)}},Bounce:{In:function(a){return 1-e.Easing.Bounce.Out(1-a)},Out:function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?7.5625*(a-=1.5/2.75)*a+.75:2.5/2.75>a?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},InOut:function(a){return.5>a?.5*e.Easing.Bounce.In(2*a):.5*e.Easing.Bounce.Out(2*a-1)+.5}}},e.Time=function(a){this.game=a,this._started=0,this._timeLastSecond=0,this._pauseStarted=0,this.physicsElapsed=0,this.time=0,this.pausedTime=0,this.now=0,this.elapsed=0,this.fps=0,this.fpsMin=1e3,this.fpsMax=0,this.msMin=1e3,this.msMax=0,this.frames=0,this.pauseDuration=0,this.timeToCall=0,this.lastTime=0,this.game.onPause.add(this.gamePaused,this),this.game.onResume.add(this.gameResumed,this),this._justResumed=!1},e.Time.prototype={totalElapsedSeconds:function(){return.001*(this.now-this._started)},update:function(a){this.now=a,this._justResumed&&(this.time=this.now,this._justResumed=!1),this.timeToCall=this.game.math.max(0,16-(a-this.lastTime)),this.elapsed=this.now-this.time,this.msMin=this.game.math.min(this.msMin,this.elapsed),this.msMax=this.game.math.max(this.msMax,this.elapsed),this.frames++,this.now>this._timeLastSecond+1e3&&(this.fps=Math.round(1e3*this.frames/(this.now-this._timeLastSecond)),this.fpsMin=this.game.math.min(this.fpsMin,this.fps),this.fpsMax=this.game.math.max(this.fpsMax,this.fps),this._timeLastSecond=this.now,this.frames=0),this.time=this.now,this.lastTime=a+this.timeToCall,this.physicsElapsed=1*(this.elapsed/1e3),this.physicsElapsed>1&&(this.physicsElapsed=1),this.game.paused&&(this.pausedTime=this.now-this._pauseStarted)},gamePaused:function(){this._pauseStarted=this.now},gameResumed:function(){this.time=Date.now(),this.pauseDuration=this.pausedTime,this._justResumed=!0},elapsedSince:function(a){return this.now-a},elapsedSecondsSince:function(a){return.001*(this.now-a)},reset:function(){this._started=this.now}},e.AnimationManager=function(a){this.sprite=a,this.game=a.game,this.currentFrame=null,this.updateIfVisible=!0,this.isLoaded=!1,this._frameData=null,this._anims={},this._outputFrames=[]},e.AnimationManager.prototype={loadFrameData:function(a){this._frameData=a,this.frame=0,this.isLoaded=!0},add:function(a,b,c,f,g){return null==this._frameData?(console.warn("No FrameData available for Phaser.Animation "+a),void 0):(c=c||60,"undefined"==typeof f&&(f=!1),"undefined"==typeof g&&(g=b&&"number"==typeof b[0]?!0:!1),null==this.sprite.events.onAnimationStart&&(this.sprite.events.onAnimationStart=new e.Signal,this.sprite.events.onAnimationComplete=new e.Signal,this.sprite.events.onAnimationLoop=new e.Signal),this._outputFrames.length=0,this._frameData.getFrameIndexes(b,g,this._outputFrames),this._anims[a]=new e.Animation(this.game,this.sprite,a,this._frameData,this._outputFrames,c,f),this.currentAnim=this._anims[a],this.currentFrame=this.currentAnim.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid]),this._anims[a])},validateFrames:function(a,b){"undefined"==typeof b&&(b=!0);for(var c=0;cthis._frameData.total)return!1}else if(0==this._frameData.checkFrameName(a[c]))return!1;return!0},play:function(a,b,c,d){if(this._anims[a]){if(this.currentAnim!=this._anims[a])return this.currentAnim=this._anims[a],this.currentAnim.paused=!1,this.currentAnim.play(b,c,d);if(0==this.currentAnim.isPlaying)return this.currentAnim.paused=!1,this.currentAnim.play(b,c,d)}},stop:function(a,b){"undefined"==typeof b&&(b=!1),"string"==typeof a?this._anims[a]&&(this.currentAnim=this._anims[a],this.currentAnim.stop(b)):this.currentAnim&&this.currentAnim.stop(b)},update:function(){return this.updateIfVisible&&0==this.sprite.visible?!1:this.currentAnim&&1==this.currentAnim.update()?(this.currentFrame=this.currentAnim.currentFrame,this.sprite.currentFrame=this.currentFrame,!0):!1},getAnimation:function(a){return"string"==typeof a&&this._anims[a]?this._anims[a]:!1},refreshFrame:function(){this.sprite.currentFrame=this.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid])},destroy:function(){this._anims={},this._frameData=null,this._frameIndex=0,this.currentAnim=null,this.currentFrame=null}},Object.defineProperty(e.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}}),Object.defineProperty(e.AnimationManager.prototype,"frameTotal",{get:function(){return this._frameData?this._frameData.total:-1}}),Object.defineProperty(e.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(a){this.currentAnim.paused=a}}),Object.defineProperty(e.AnimationManager.prototype,"frame",{get:function(){return this.currentFrame?this._frameIndex:void 0},set:function(a){"number"==typeof a&&this._frameData&&null!==this._frameData.getFrame(a)&&(this.currentFrame=this._frameData.getFrame(a),this._frameIndex=a,this.sprite.currentFrame=this.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid]))}}),Object.defineProperty(e.AnimationManager.prototype,"frameName",{get:function(){return this.currentFrame?this.currentFrame.name:void 0},set:function(a){"string"==typeof a&&this._frameData&&null!==this._frameData.getFrameByName(a)?(this.currentFrame=this._frameData.getFrameByName(a),this._frameIndex=this.currentFrame.index,this.sprite.currentFrame=this.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid])):console.warn("Cannot set frameName: "+a)}}),e.Animation=function(a,b,c,d,e,f,g){this.game=a,this._parent=b,this._frameData=d,this.name=c,this._frames=[],this._frames=this._frames.concat(e),this.delay=1e3/f,this.looped=g,this.killOnComplete=!1,this.isFinished=!1,this.isPlaying=!1,this.isPaused=!1,this._pauseStartTime=0,this._frameIndex=0,this._frameDiff=0,this._frameSkip=1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex])},e.Animation.prototype={play:function(a,b,c){return"number"==typeof a&&(this.delay=1e3/a),"boolean"==typeof b&&(this.looped=b),"undefined"!=typeof c&&(this.killOnComplete=c),this.isPlaying=!0,this.isFinished=!1,this.paused=!1,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]),this._parent.setTexture(d.TextureCache[this.currentFrame.uuid]),this._parent.events&&this._parent.events.onAnimationStart.dispatch(this._parent,this),this},restart:function(){this.isPlaying=!0,this.isFinished=!1,this.paused=!1,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])},stop:function(a){"undefined"==typeof a&&(a=!1),this.isPlaying=!1,this.isFinished=!0,this.paused=!1,a&&(this.currentFrame=this._frameData.getFrame(this._frames[0]))},update:function(){return this.isPaused?!1:1==this.isPlaying&&this.game.time.now>=this._timeNextFrame?(this._frameSkip=1,this._frameDiff=this.game.time.now-this._timeNextFrame,this._timeLastFrame=this.game.time.now,this._frameDiff>this.delay&&(this._frameSkip=Math.floor(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay),this._timeNextFrame=this.game.time.now+(this.delay-this._frameDiff),this._frameIndex+=this._frameSkip,this._frameIndex>=this._frames.length?this.looped?(this._frameIndex%=this._frames.length,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&this._parent.setTexture(d.TextureCache[this.currentFrame.uuid]),this._parent.events.onAnimationLoop.dispatch(this._parent,this)):this.onComplete():(this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&this._parent.setTexture(d.TextureCache[this.currentFrame.uuid])),!0):!1},destroy:function(){this.game=null,this._parent=null,this._frames=null,this._frameData=null,this.currentFrame=null,this.isPlaying=!1},onComplete:function(){this.isPlaying=!1,this.isFinished=!0,this.paused=!1,this._parent.events&&this._parent.events.onAnimationComplete.dispatch(this._parent,this),this.killOnComplete&&this._parent.kill()}},Object.defineProperty(e.Animation.prototype,"paused",{get:function(){return this.isPaused},set:function(a){this.isPaused=a,a?this._pauseStartTime=this.game.time.now:this.isPlaying&&(this._timeNextFrame=this.game.time.now+this.delay)}}),Object.defineProperty(e.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}}),Object.defineProperty(e.Animation.prototype,"frame",{get:function(){return null!==this.currentFrame?this.currentFrame.index:this._frameIndex},set:function(a){this.currentFrame=this._frameData.getFrame(a),null!==this.currentFrame&&(this._frameIndex=a,this._parent.setTexture(d.TextureCache[this.currentFrame.uuid]))}}),e.Animation.generateFrameNames=function(a,b,c,d,f){"undefined"==typeof d&&(d="");var g=[],h="";if(c>b)for(var i=b;c>=i;i++)h="number"==typeof f?e.Utils.pad(i.toString(),f,"0",1):i.toString(),h=a+h+d,g.push(h);else for(var i=b;i>=c;i--)h="number"==typeof f?e.Utils.pad(i.toString(),f,"0",1):i.toString(),h=a+h+d,g.push(h);return g},e.Frame=function(a,b,c,d,f,g,h){this.index=a,this.x=b,this.y=c,this.width=d,this.height=f,this.name=g,this.uuid=h,this.centerX=Math.floor(d/2),this.centerY=Math.floor(f/2),this.distance=e.Math.distance(0,0,d,f),this.rotated=!1,this.rotationDirection="cw",this.trimmed=!1,this.sourceSizeW=d,this.sourceSizeH=f,this.spriteSourceSizeX=0,this.spriteSourceSizeY=0,this.spriteSourceSizeW=0,this.spriteSourceSizeH=0},e.Frame.prototype={setTrim:function(a,b,c,d,e,f,g){this.trimmed=a,a&&(this.width=b,this.height=c,this.sourceSizeW=b,this.sourceSizeH=c,this.centerX=Math.floor(b/2),this.centerY=Math.floor(c/2),this.spriteSourceSizeX=d,this.spriteSourceSizeY=e,this.spriteSourceSizeW=f,this.spriteSourceSizeH=g)}},e.FrameData=function(){this._frames=[],this._frameNames=[]},e.FrameData.prototype={addFrame:function(a){return a.index=this._frames.length,this._frames.push(a),""!==a.name&&(this._frameNames[a.name]=a.index),a},getFrame:function(a){return this._frames.length>a?this._frames[a]:null},getFrameByName:function(a){return"number"==typeof this._frameNames[a]?this._frames[this._frameNames[a]]:null},checkFrameName:function(a){return null==this._frameNames[a]?!1:!0},getFrameRange:function(a,b,c){"undefined"==typeof c&&(c=[]);for(var d=a;b>=d;d++)c.push(this._frames[d]);return c},getFrames:function(a,b,c){if("undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=[]),"undefined"==typeof a||0==a.length)for(var d=0;dd;d++)b?c.push(this.getFrame(a[d])):c.push(this.getFrameByName(a[d]));return c},getFrameIndexes:function(a,b,c){if("undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=[]),"undefined"==typeof a||0==a.length)for(var d=0,e=this._frames.length;e>d;d++)c.push(this._frames[d].index);else for(var d=0,e=a.length;e>d;d++)b?c.push(a[d]):this.getFrameByName(a[d])&&c.push(this.getFrameByName(a[d]).index);return c}},Object.defineProperty(e.FrameData.prototype,"total",{get:function(){return this._frames.length}}),e.AnimationParser={spriteSheet:function(a,b,c,f,g){var h=a.cache.getImage(b);if(null==h)return null;var i=h.width,j=h.height;0>=c&&(c=Math.floor(-i/Math.min(-1,c))),0>=f&&(f=Math.floor(-j/Math.min(-1,f)));var k=Math.round(i/c),l=Math.round(j/f),m=k*l;if(-1!==g&&(m=g),0==i||0==j||c>i||f>j||0===m)return console.warn("Phaser.AnimationParser.spriteSheet: width/height zero or width/height < given frameWidth/frameHeight"),null;for(var n=new e.FrameData,o=0,p=0,q=0;m>q;q++){var r=a.rnd.uuid();n.addFrame(new e.Frame(q,o,p,c,f,"",r)),d.TextureCache[r]=new d.Texture(d.BaseTextureCache[b],{x:o,y:p,width:c,height:f}),o+=c,o===i&&(o=0,p+=f)}return n},JSONData:function(a,b,c){if(!b.frames)return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"),console.log(b),void 0;for(var f,g=new e.FrameData,h=b.frames,i=0;i tag"),void 0;for(var f,g,h,i,j,k,l,m,n,o,p,q=new e.FrameData,r=b.getElementsByTagName("SubTexture"),s=0;s0?(this._progressChunk=100/this._keys.length,this.loadFile()):(this.progress=100,this.hasLoaded=!0,this.onLoadComplete.dispatch()))},loadFile:function(){var a=this._fileList[this._keys.shift()],b=this;switch(a.type){case"image":case"spritesheet":case"textureatlas":case"bitmapfont":case"tileset":a.data=new Image,a.data.name=a.key,a.data.onload=function(){return b.fileComplete(a.key)},a.data.onerror=function(){return b.fileError(a.key)},a.data.crossOrigin=this.crossOrigin,a.data.src=this.baseURL+a.url;break;case"audio":a.url=this.getAudioURL(a.url),null!==a.url?this.game.sound.usingWebAudio?(this._xhr.open("GET",this.baseURL+a.url,!0),this._xhr.responseType="arraybuffer",this._xhr.onload=function(){return b.fileComplete(a.key)},this._xhr.onerror=function(){return b.fileError(a.key)},this._xhr.send()):this.game.sound.usingAudioTag&&(this.game.sound.touchLocked?(a.data=new Audio,a.data.name=a.key,a.data.preload="auto",a.data.src=this.baseURL+a.url,this.fileComplete(a.key)):(a.data=new Audio,a.data.name=a.key,a.data.onerror=function(){return b.fileError(a.key)},a.data.preload="auto",a.data.src=this.baseURL+a.url,a.data.addEventListener("canplaythrough",e.GAMES[this.game.id].load.fileComplete(a.key),!1),a.data.load())):this.fileError(a.key);break;case"tilemap":this._xhr.open("GET",this.baseURL+a.url,!0),this._xhr.responseType="text",a.format==e.Tilemap.TILED_JSON?this._xhr.onload=function(){return b.jsonLoadComplete(a.key)}:a.format==e.Tilemap.CSV&&(this._xhr.onload=function(){return b.csvLoadComplete(a.key)}),this._xhr.onerror=function(){return b.dataLoadError(a.key)},this._xhr.send();break;case"text":this._xhr.open("GET",this.baseURL+a.url,!0),this._xhr.responseType="text",this._xhr.onload=function(){return b.fileComplete(a.key)},this._xhr.onerror=function(){return b.fileError(a.key)},this._xhr.send()}},getAudioURL:function(a){for(var b,c=0;c100&&(this.progress=100),null!==this.preloadSprite&&(0==this.preloadSprite.direction?this.preloadSprite.crop.width=Math.floor(this.preloadSprite.width/100*this.progress):this.preloadSprite.crop.height=Math.floor(this.preloadSprite.height/100*this.progress),this.preloadSprite.sprite.crop=this.preloadSprite.crop),this.onFileComplete.dispatch(this.progress,a,b,this.queueSize-this._keys.length,this.queueSize),this._keys.length>0?this.loadFile():(this.hasLoaded=!0,this.isLoading=!1,this.removeAll(),this.onLoadComplete.dispatch())}},e.LoaderParser={bitmapFont:function(a,b,c){if(!b.getElementsByTagName("font"))return console.warn("Phaser.LoaderParser.bitmapFont: Invalid XML given, missing tag"),void 0;var e=d.TextureCache[c],f={},g=b.getElementsByTagName("info")[0],h=b.getElementsByTagName("common")[0];f.font=g.attributes.getNamedItem("face").nodeValue,f.size=parseInt(g.attributes.getNamedItem("size").nodeValue,10),f.lineHeight=parseInt(h.attributes.getNamedItem("lineHeight").nodeValue,10),f.chars={};for(var i=b.getElementsByTagName("char"),j=0;j=this.durationMS&&(this.usingWebAudio?this.loop?(this.onLoop.dispatch(this),""==this.currentMarker?(this.currentTime=0,this.startTime=this.game.time.now):this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop():this.loop?(this.onLoop.dispatch(this),this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop()))},play:function(a,b,c,d,e){if(a=a||"",b=b||0,c=c||1,"undefined"==typeof d&&(d=!1),"undefined"==typeof e&&(e=!0),1!=this.isPlaying||0!=e||0!=this.override){if(this.isPlaying&&this.override&&(this.usingWebAudio?"undefined"==typeof this._sound.stop?this._sound.noteOff(0):this._sound.stop(0):this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0)),this.currentMarker=a,""!==a){if(!this.markers[a])return console.warn("Phaser.Sound.play: audio marker "+a+" doesn't exist"),void 0;this.position=this.markers[a].start,this.volume=this.markers[a].volume,this.loop=this.markers[a].loop,this.duration=this.markers[a].duration,this.durationMS=this.markers[a].durationMS,this._tempMarker=a,this._tempPosition=this.position,this._tempVolume=this.volume,this._tempLoop=this.loop}else this.position=b,this.volume=c,this.loop=d,this.duration=0,this.durationMS=0,this._tempMarker=a,this._tempPosition=b,this._tempVolume=c,this._tempLoop=d;this.usingWebAudio?this.game.cache.isSoundDecoded(this.key)?(null==this._buffer&&(this._buffer=this.game.cache.getSoundData(this.key)),this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this._sound.connect(this.gainNode),this.totalDuration=this._sound.buffer.duration,0==this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this.loop&&""==a&&(this._sound.loop=!0),"undefined"==typeof this._sound.start?this._sound.noteGrainOn(0,this.position,this.duration):this._sound.start(0,this.position,this.duration),this.isPlaying=!0,this.startTime=this.game.time.now,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):(this.pendingPlayback=!0,this.game.cache.getSound(this.key)&&0==this.game.cache.getSound(this.key).isDecoding&&this.game.sound.decode(this.key,this)):this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked?(this.game.cache.reloadSound(this.key),this.pendingPlayback=!0):this._sound&&4==this._sound.readyState?(this._sound.play(),this.totalDuration=this._sound.duration,0==this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this._sound.currentTime=this.position,this._sound.muted=this._muted,this._sound.volume=this._muted?0:this._volume,this.isPlaying=!0,this.startTime=this.game.time.now,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):this.pendingPlayback=!0}},restart:function(a,b,c,d){a=a||"",b=b||0,c=c||1,"undefined"==typeof d&&(d=!1),this.play(a,b,c,d,!0)},pause:function(){this.isPlaying&&this._sound&&(this.stop(),this.isPlaying=!1,this.paused=!0,this.pausedPosition=this.currentTime,this.pausedTime=this.game.time.now,this.onPause.dispatch(this))},resume:function(){if(this.paused&&this._sound){if(this.usingWebAudio){var a=this.position+this.pausedPosition/1e3;this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this._sound.connect(this.gainNode),"undefined"==typeof this._sound.start?this._sound.noteGrainOn(0,a,this.duration):this._sound.start(0,a,this.duration)}else this._sound.play();this.isPlaying=!0,this.paused=!1,this.startTime+=this.game.time.now-this.pausedTime,this.onResume.dispatch(this)}},stop:function(){this.isPlaying&&this._sound&&(this.usingWebAudio?"undefined"==typeof this._sound.stop?this._sound.noteOff(0):this._sound.stop(0):this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0)),this.isPlaying=!1;var a=this.currentMarker;this.currentMarker="",this.onStop.dispatch(this,a)}},Object.defineProperty(e.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}}),Object.defineProperty(e.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}}),Object.defineProperty(e.Sound.prototype,"mute",{get:function(){return this._muted},set:function(a){a=a||null,a?(this._muted=!0,this.usingWebAudio?(this._muteVolume=this.gainNode.gain.value,this.gainNode.gain.value=0):this.usingAudioTag&&this._sound&&(this._muteVolume=this._sound.volume,this._sound.volume=0)):(this._muted=!1,this.usingWebAudio?this.gainNode.gain.value=this._muteVolume:this.usingAudioTag&&this._sound&&(this._sound.volume=this._muteVolume)),this.onMute.dispatch(this)}}),Object.defineProperty(e.Sound.prototype,"volume",{get:function(){return this._volume},set:function(a){this.usingWebAudio?(this._volume=a,this.gainNode.gain.value=a):this.usingAudioTag&&this._sound&&a>=0&&1>=a&&(this._volume=a,this._sound.volume=a)}}),e.SoundManager=function(a){this.game=a,this.onSoundDecode=new e.Signal,this._muted=!1,this._unlockSource=null,this._volume=1,this._sounds=[],this.context=null,this.usingWebAudio=!0,this.usingAudioTag=!1,this.noAudio=!1,this.touchLocked=!1,this.channels=32},e.SoundManager.prototype={boot:function(){if(this.game.device.iOS&&0==this.game.device.webAudio&&(this.channels=1),this.game.device.iOS||window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock?(this.game.input.touch.callbackContext=this,this.game.input.touch.touchStartCallback=this.unlock,this.game.input.mouse.callbackContext=this,this.game.input.mouse.mouseDownCallback=this.unlock,this.touchLocked=!0):this.touchLocked=!1,window.PhaserGlobal){if(1==window.PhaserGlobal.disableAudio)return this.usingWebAudio=!1,this.noAudio=!0,void 0;if(1==window.PhaserGlobal.disableWebAudio)return this.usingWebAudio=!1,this.usingAudioTag=!0,this.noAudio=!1,void 0}window.AudioContext?this.context=new window.AudioContext:window.webkitAudioContext?this.context=new window.webkitAudioContext:window.Audio?(this.usingWebAudio=!1,this.usingAudioTag=!0):(this.usingWebAudio=!1,this.noAudio=!0),null!==this.context&&(this.masterGain="undefined"==typeof this.context.createGain?this.context.createGainNode():this.context.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this.context.destination))},unlock:function(){if(0!=this.touchLocked)if(0==this.game.device.webAudio||window.PhaserGlobal&&1==window.PhaserGlobal.disableWebAudio)this.touchLocked=!1,this._unlockSource=null,this.game.input.touch.callbackContext=null,this.game.input.touch.touchStartCallback=null,this.game.input.mouse.callbackContext=null,this.game.input.mouse.mouseDownCallback=null;else{var a=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource(),this._unlockSource.buffer=a,this._unlockSource.connect(this.context.destination),this._unlockSource.noteOn(0)}},stopAll:function(){for(var a=0;a255)return e.Color.getColor(255,255,255);if(a>b)return e.Color.getColor(255,255,255);var d=a+Math.round(Math.random()*(b-a)),f=a+Math.round(Math.random()*(b-a)),g=a+Math.round(Math.random()*(b-a));return e.Color.getColor32(c,d,f,g)},getRGB:function(a){return{alpha:a>>>24,red:255&a>>16,green:255&a>>8,blue:255&a}},getWebRGB:function(a){var b=(a>>>24)/255,c=255&a>>16,d=255&a>>8,e=255&a;return"rgba("+c.toString()+","+d.toString()+","+e.toString()+","+b.toString()+")"},getAlpha:function(a){return a>>>24},getAlphaFloat:function(a){return(a>>>24)/255},getRed:function(a){return 255&a>>16},getGreen:function(a){return 255&a>>8},getBlue:function(a){return 255&a}},e.Physics={},e.Physics.Arcade=function(a){this.game=a,this.gravity=new e.Point,this.bounds=new e.Rectangle(0,0,a.world.width,a.world.height),this.maxObjects=10,this.maxLevels=4,this.OVERLAP_BIAS=4,this.quadTree=new e.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this.quadTreeID=0,this._bounds1=new e.Rectangle,this._bounds2=new e.Rectangle,this._overlap=0,this._maxOverlap=0,this._velocity1=0,this._velocity2=0,this._newVelocity1=0,this._newVelocity2=0,this._average=0,this._mapData=[],this._mapTiles=0,this._result=!1,this._total=0,this._angle=0,this._dx=0,this._dy=0},e.Physics.Arcade.prototype={updateMotion:function(a){this._velocityDelta=60*.5*(this.computeVelocity(0,a,a.angularVelocity,a.angularAcceleration,a.angularDrag,a.maxAngular)-a.angularVelocity)*this.game.time.physicsElapsed,a.angularVelocity+=this._velocityDelta,a.rotation+=a.angularVelocity*this.game.time.physicsElapsed,a.angularVelocity+=this._velocityDelta,this._velocityDelta=60*.5*(this.computeVelocity(1,a,a.velocity.x,a.acceleration.x,a.drag.x,a.maxVelocity.x)-a.velocity.x)*this.game.time.physicsElapsed,a.velocity.x+=this._velocityDelta,a.x+=a.velocity.x*this.game.time.physicsElapsed,a.velocity.x+=this._velocityDelta,this._velocityDelta=60*.5*(this.computeVelocity(2,a,a.velocity.y,a.acceleration.y,a.drag.y,a.maxVelocity.y)-a.velocity.y)*this.game.time.physicsElapsed,a.velocity.y+=this._velocityDelta,a.y+=a.velocity.y*this.game.time.physicsElapsed,a.velocity.y+=this._velocityDelta},computeVelocity:function(a,b,c,d,e,f){return f=f||1e4,1==a&&b.allowGravity?c+=this.gravity.x+b.gravity.x:2==a&&b.allowGravity&&(c+=this.gravity.y+b.gravity.y),0!==d?c+=d*this.game.time.physicsElapsed:0!==e&&(this._drag=e*this.game.time.physicsElapsed,c-this._drag>0?c-=this._drag:c+this._drag<0?c+=this._drag:c=0),c>f?c=f:-f>c&&(c=-f),c},preUpdate:function(){this.quadTree.clear(),this.quadTreeID=0,this.quadTree=new e.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels)},postUpdate:function(){this.quadTree.clear()},overlap:function(a,b){return a&&b&&a.exists&&b.exists?e.Rectangle.intersects(a.body,b.body):!1},collide:function(a,b,c,d,f){return c=c||null,d=d||null,f=f||c,this._result=!1,this._total=0,a&&b&&a.exists&&b.exists&&(a.type==e.SPRITE?b.type==e.SPRITE?this.collideSpriteVsSprite(a,b,c,d,f):b.type==e.GROUP||b.type==e.EMITTER?this.collideSpriteVsGroup(a,b,c,d,f):b.type==e.TILEMAPLAYER&&this.collideSpriteVsTilemapLayer(a,b,c,d,f):a.type==e.GROUP?b.type==e.SPRITE?this.collideSpriteVsGroup(b,a,c,d,f):b.type==e.GROUP||b.type==e.EMITTER?this.collideGroupVsGroup(a,b,c,d,f):b.type==e.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(a,b,c,d,f):a.type==e.TILEMAPLAYER?b.type==e.SPRITE?this.collideSpriteVsTilemapLayer(b,a,c,d,f):(b.type==e.GROUP||b.type==e.EMITTER)&&this.collideGroupVsTilemapLayer(b,a,c,d,f):a.type==e.EMITTER&&(b.type==e.SPRITE?this.collideSpriteVsGroup(b,a,c,d,f):b.type==e.GROUP||b.type==e.EMITTER?this.collideGroupVsGroup(a,b,c,d,f):b.type==e.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(a,b,c,d,f))),this._total>0},collideSpriteVsTilemapLayer:function(a,b,c,d,e){if(this._mapData=b.getTiles(a.body.x,a.body.y,a.body.width,a.body.height,!0),0!=this._mapData.length)for(var f=0;ff;f++)this._potentials[f].sprite.group==b&&(this.separate(a.body,this._potentials[f]),this._result&&d&&(this._result=d.call(e,a,this._potentials[f].sprite)),this._result&&(this._total++,c&&c.call(e,a,this._potentials[f].sprite)))}},collideGroupVsGroup:function(a,b,c,d,e){if(0!=a.length&&0!=b.length&&a._container.first._iNext){var f=a._container.first._iNext;do f.exists&&this.collideSpriteVsGroup(f,b,c,d,e),f=f._iNext;while(f!=a._container.last._iNext)}},separate:function(a,b){this._result=this.separateX(a,b)||this.separateY(a,b)},separateX:function(a,b){return a.immovable&&b.immovable?!1:(this._overlap=0,e.Rectangle.intersects(a,b)&&(this._maxOverlap=a.deltaAbsX()+b.deltaAbsX()+this.OVERLAP_BIAS,0==a.deltaX()&&0==b.deltaX()?(a.embedded=!0,b.embedded=!0):a.deltaX()>b.deltaX()?(this._overlap=a.x+a.width-b.x,this._overlap>this._maxOverlap||0==a.allowCollision.right||0==b.allowCollision.left?this._overlap=0:(a.touching.right=!0,b.touching.left=!0)):a.deltaX()this._maxOverlap||0==a.allowCollision.left||0==b.allowCollision.right?this._overlap=0:(a.touching.left=!0,b.touching.right=!0)),0!=this._overlap)?(a.overlapX=this._overlap,b.overlapX=this._overlap,a.customSeparateX||b.customSeparateX?!0:(this._velocity1=a.velocity.x,this._velocity2=b.velocity.x,a.immovable||b.immovable?a.immovable?b.immovable||(b.x+=this._overlap,b.velocity.x=this._velocity1-this._velocity2*b.bounce.x):(a.x=a.x-this._overlap,a.velocity.x=this._velocity2-this._velocity1*a.bounce.x):(this._overlap*=.5,a.x=a.x-this._overlap,b.x+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(this._velocity2>0?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(this._velocity1>0?1:-1),this._average=.5*(this._newVelocity1+this._newVelocity2),this._newVelocity1-=this._average,this._newVelocity2-=this._average,a.velocity.x=this._average+this._newVelocity1*a.bounce.x,b.velocity.x=this._average+this._newVelocity2*b.bounce.x),!0)):!1)},separateY:function(a,b){return a.immovable&&b.immovable?!1:(this._overlap=0,e.Rectangle.intersects(a,b)&&(this._maxOverlap=a.deltaAbsY()+b.deltaAbsY()+this.OVERLAP_BIAS,0==a.deltaY()&&0==b.deltaY()?(a.embedded=!0,b.embedded=!0):a.deltaY()>b.deltaY()?(this._overlap=a.y+a.height-b.y,this._overlap>this._maxOverlap||0==a.allowCollision.down||0==b.allowCollision.up?this._overlap=0:(a.touching.down=!0,b.touching.up=!0)):a.deltaY()this._maxOverlap||0==a.allowCollision.up||0==b.allowCollision.down?this._overlap=0:(a.touching.up=!0,b.touching.down=!0)),0!=this._overlap)?(a.overlapY=this._overlap,b.overlapY=this._overlap,a.customSeparateY||b.customSeparateY?!0:(this._velocity1=a.velocity.y,this._velocity2=b.velocity.y,a.immovable||b.immovable?a.immovable?b.immovable||(b.y+=this._overlap,b.velocity.y=this._velocity1-this._velocity2*b.bounce.y,a.sprite.active&&a.moves&&a.deltaY()b.deltaY()&&(a.x+=b.x-b.lastX)):(this._overlap*=.5,a.y=a.y-this._overlap,b.y+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(this._velocity2>0?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(this._velocity1>0?1:-1),this._average=.5*(this._newVelocity1+this._newVelocity2),this._newVelocity1-=this._average,this._newVelocity2-=this._average,a.velocity.y=this._average+this._newVelocity1*a.bounce.y,b.velocity.y=this._average+this._newVelocity2*b.bounce.y),!0)):!1)},separateTile:function(a,b){return this._result=this.separateTileX(a,b,!0)||this.separateTileY(a,b,!0),this._result},separateTileX:function(a,b,c){return a.immovable||0==a.deltaX()||0==e.Rectangle.intersects(a.hullX,b)?!1:(this._overlap=0,a.deltaX()<0?(this._overlap=b.right-a.hullX.x,0==a.allowCollision.left||0==b.tile.collideRight?this._overlap=0:a.touching.left=!0):(this._overlap=a.hullX.right-b.x,0==a.allowCollision.right||0==b.tile.collideLeft?this._overlap=0:a.touching.right=!0),0!=this._overlap?(c&&(a.x=a.deltaX()<0?a.x+this._overlap:a.x-this._overlap,a.velocity.x=0==a.bounce.x?0:-a.velocity.x*a.bounce.x,a.updateHulls()),!0):!1)},separateTileY:function(a,b,c){return a.immovable||0==a.deltaY()||0==e.Rectangle.intersects(a.hullY,b)?!1:(this._overlap=0,a.deltaY()<0?(this._overlap=b.bottom-a.hullY.y,0==a.allowCollision.up||0==b.tile.collideDown?this._overlap=0:a.touching.up=!0):(this._overlap=a.hullY.bottom-b.y,0==a.allowCollision.down||0==b.tile.collideUp?this._overlap=0:a.touching.down=!0),0!=this._overlap?(c&&(a.y=a.deltaY()<0?a.y+this._overlap:a.y-this._overlap,a.velocity.y=0==a.bounce.y?0:-a.velocity.y*a.bounce.y,a.updateHulls()),!0):!1)},moveToObject:function(a,b,c,d){return"undefined"==typeof c&&(c=60),"undefined"==typeof d&&(d=0),this._angle=Math.atan2(b.y-a.y,b.x-a.x),d>0&&(c=this.distanceBetween(a,b)/(d/1e3)),a.body.velocity.x=Math.cos(this._angle)*c,a.body.velocity.y=Math.sin(this._angle)*c,this._angle},moveToPointer:function(a,b,c,d){return"undefined"==typeof b&&(b=60),c=c||this.game.input.activePointer,"undefined"==typeof d&&(d=0),this._angle=this.angleToPointer(a,c),d>0&&(b=this.distanceToPointer(a,c)/(d/1e3)),a.body.velocity.x=Math.cos(this._angle)*b,a.body.velocity.y=Math.sin(this._angle)*b,this._angle},moveToXY:function(a,b,c,d,e){return"undefined"==typeof d&&(d=60),"undefined"==typeof e&&(e=0),this._angle=Math.atan2(c-a.y,b-a.x),e>0&&(d=this.distanceToXY(a,b,c)/(e/1e3)),a.body.velocity.x=Math.cos(this._angle)*d,a.body.velocity.y=Math.sin(this._angle)*d,this._angle},velocityFromAngle:function(a,b,c){return"undefined"==typeof b&&(b=60),c=c||new e.Point,c.setTo(Math.cos(this.game.math.degToRad(a))*b,Math.sin(this.game.math.degToRad(a))*b)},velocityFromRotation:function(a,b,c){return"undefined"==typeof b&&(b=60),c=c||new e.Point,c.setTo(Math.cos(a)*b,Math.sin(a)*b)},accelerationFromRotation:function(a,b,c){return"undefined"==typeof b&&(b=60),c=c||new e.Point,c.setTo(Math.cos(a)*b,Math.sin(a)*b)},accelerateToObject:function(a,b,c,d,e){return"undefined"==typeof c&&(c=60),"undefined"==typeof d&&(d=1e3),"undefined"==typeof e&&(e=1e3),this._angle=this.angleBetween(a,b),a.body.acceleration.setTo(Math.cos(this._angle)*c,Math.sin(this._angle)*c),a.body.maxVelocity.setTo(d,e),this._angle},accelerateToPointer:function(a,b,c,d,e){return"undefined"==typeof c&&(c=60),"undefined"==typeof b&&(b=this.game.input.activePointer),"undefined"==typeof d&&(d=1e3),"undefined"==typeof e&&(e=1e3),this._angle=this.angleToPointer(a,b),a.body.acceleration.setTo(Math.cos(this._angle)*c,Math.sin(this._angle)*c),a.body.maxVelocity.setTo(d,e),this._angle},accelerateToXY:function(a,b,c,d,e,f){return"undefined"==typeof d&&(d=60),"undefined"==typeof e&&(e=1e3),"undefined"==typeof f&&(f=1e3),this._angle=this.angleToXY(a,b,c),a.body.acceleration.setTo(Math.cos(this._angle)*d,Math.sin(this._angle)*d),a.body.maxVelocity.setTo(e,f),this._angle},distanceBetween:function(a,b){return this._dx=a.x-b.x,this._dy=a.y-b.y,Math.sqrt(this._dx*this._dx+this._dy*this._dy)},distanceToXY:function(a,b,c){return this._dx=a.x-b,this._dy=a.y-c,Math.sqrt(this._dx*this._dx+this._dy*this._dy)},distanceToPointer:function(a,b){return b=b||this.game.input.activePointer,this._dx=a.x-b.x,this._dy=a.y-b.y,Math.sqrt(this._dx*this._dx+this._dy*this._dy)},angleBetween:function(a,b){return this._dx=b.x-a.x,this._dy=b.y-a.y,Math.atan2(this._dy,this._dx)},angleToXY:function(a,b,c){return this._dx=b-a.x,this._dy=c-a.y,Math.atan2(this._dy,this._dx)},angleToPointer:function(a,b){return b=b||this.game.input.activePointer,this._dx=b.worldX-a.x,this._dy=b.worldY-a.y,Math.atan2(this._dy,this._dx)}},e.Physics.Arcade.Body=function(a){this.sprite=a,this.game=a.game,this.offset=new e.Point,this.x=a.x,this.y=a.y,this.preX=a.x,this.preY=a.y,this.preRotation=a.angle,this.screenX=a.x,this.screenY=a.y,this.sourceWidth=a.currentFrame.sourceSizeW,this.sourceHeight=a.currentFrame.sourceSizeH,this.width=a.currentFrame.sourceSizeW,this.height=a.currentFrame.sourceSizeH,this.halfWidth=Math.floor(a.currentFrame.sourceSizeW/2),this.halfHeight=Math.floor(a.currentFrame.sourceSizeH/2),this.center=new e.Point(this.x+this.halfWidth,this.y+this.halfHeight),this._sx=a.scale.x,this._sy=a.scale.y,this.velocity=new e.Point,this.acceleration=new e.Point,this.drag=new e.Point,this.gravity=new e.Point,this.bounce=new e.Point,this.maxVelocity=new e.Point(1e4,1e4),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.skipQuadTree=!1,this.quadTreeIDs=[],this.quadTreeIndex=-1,this.allowCollision={none:!1,any:!0,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.facing=e.NONE,this.immovable=!1,this.moves=!0,this.rotation=0,this.allowRotation=!0,this.allowGravity=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.hullX=new e.Rectangle,this.hullY=new e.Rectangle,this.embedded=!1,this.collideWorldBounds=!1},e.Physics.Arcade.Body.prototype={updateBounds:function(a,b,c,d){(c!=this._sx||d!=this._sy)&&(this.width=this.sourceWidth*c,this.height=this.sourceHeight*d,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this._sx=c,this._sy=d,this.center.setTo(this.x+this.halfWidth,this.y+this.halfHeight))},preUpdate:function(){this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.embedded=!1,this.screenX=this.sprite.worldTransform[2]-this.sprite.anchor.x*this.width+this.offset.x,this.screenY=this.sprite.worldTransform[5]-this.sprite.anchor.y*this.height+this.offset.y,this.preX=this.sprite.world.x-this.sprite.anchor.x*this.width+this.offset.x,this.preY=this.sprite.world.y-this.sprite.anchor.y*this.height+this.offset.y,this.preRotation=this.sprite.angle,this.x=this.preX,this.y=this.preY,this.rotation=this.preRotation,this.moves&&(this.game.physics.updateMotion(this),this.collideWorldBounds&&this.checkWorldBounds(),this.updateHulls()),0==this.skipQuadTree&&0==this.allowCollision.none&&this.sprite.visible&&this.sprite.alive&&(this.quadTreeIDs=[],this.quadTreeIndex=-1,this.game.physics.quadTree.insert(this))},postUpdate:function(){this.deltaX()<0?this.facing=e.LEFT:this.deltaX()>0&&(this.facing=e.RIGHT),this.deltaY()<0?this.facing=e.UP:this.deltaY()>0&&(this.facing=e.DOWN),(0!==this.deltaX()||0!==this.deltaY())&&(this.sprite.x+=this.deltaX(),this.sprite.y+=this.deltaY(),this.center.setTo(this.x+this.halfWidth,this.y+this.halfHeight)),this.allowRotation&&(this.sprite.angle+=this.deltaZ())},updateHulls:function(){this.hullX.setTo(this.x,this.preY,this.width,this.height),this.hullY.setTo(this.preX,this.y,this.width,this.height)},checkWorldBounds:function(){this.xthis.game.world.bounds.right&&(this.x=this.game.world.bounds.right-this.width,this.velocity.x*=-this.bounce.x),this.ythis.game.world.bounds.bottom&&(this.y=this.game.world.bounds.bottom-this.height,this.velocity.y*=-this.bounce.y)},setSize:function(a,b,c,d){c=c||this.offset.x,d=d||this.offset.y,this.sourceWidth=a,this.sourceHeight=b,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.setTo(c,d),this.center.setTo(this.x+this.halfWidth,this.y+this.halfHeight)},reset:function(){this.velocity.setTo(0,0),this.acceleration.setTo(0,0),this.angularVelocity=0,this.angularAcceleration=0,this.preX=this.sprite.world.x-this.sprite.anchor.x*this.width+this.offset.x,this.preY=this.sprite.world.y-this.sprite.anchor.y*this.height+this.offset.y,this.preRotation=this.sprite.angle,this.x=this.preX,this.y=this.preY,this.rotation=this.preRotation,this.center.setTo(this.x+this.halfWidth,this.y+this.halfHeight)},deltaAbsX:function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},deltaAbsY:function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},deltaX:function(){return this.x-this.preX},deltaY:function(){return this.y-this.preY},deltaZ:function(){return this.rotation-this.preRotation}},Object.defineProperty(e.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){this.height=a<=this.y?0:this.y-a}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"right",{get:function(){return this.x+this.width},set:function(a){this.width=a<=this.x?0:this.x+a}}),e.Particles=function(){this.emitters={},this.ID=0},e.Particles.prototype={add:function(a){return this.emitters[a.name]=a,a},remove:function(a){delete this.emitters[a.name]},update:function(){for(var a in this.emitters)this.emitters[a].exists&&this.emitters[a].update()}},e.Particles.Arcade={},e.Particles.Arcade.Emitter=function(a,b,c,d){this.maxParticles=d||50,e.Group.call(this,a),this.name="emitter"+this.game.particles.ID++,this.type=e.EMITTER,this.x=0,this.y=0,this.width=1,this.height=1,this.minParticleSpeed=new e.Point(-100,-100),this.maxParticleSpeed=new e.Point(100,100),this.minParticleScale=1,this.maxParticleScale=1,this.minRotation=-360,this.maxRotation=360,this.gravity=2,this.particleClass=null,this.particleDrag=new e.Point,this.angularDrag=0,this.frequency=100,this.lifespan=2e3,this.bounce=new e.Point,this._quantity=0,this._timer=0,this._counter=0,this._explode=!0,this.on=!1,this.exists=!0,this.emitX=b,this.emitY=c},e.Particles.Arcade.Emitter.prototype=Object.create(e.Group.prototype),e.Particles.Arcade.Emitter.prototype.constructor=e.Particles.Arcade.Emitter,e.Particles.Arcade.Emitter.prototype.update=function(){if(this.on)if(this._explode){this._counter=0;do this.emitParticle(),this._counter++;while(this._counter=this._timer&&(this.emitParticle(),this._counter++,this._quantity>0&&this._counter>=this._quantity&&(this.on=!1),this._timer=this.game.time.now+this.frequency)},e.Particles.Arcade.Emitter.prototype.makeParticles=function(a,b,c,d,f){"undefined"==typeof b&&(b=0),c=c||this.maxParticles,d=d||0,"undefined"==typeof f&&(f=!1);for(var g,h=0,i=a,j=0;c>h;)null==this.particleClass&&("object"==typeof a&&(i=this.game.rnd.pick(a)),"object"==typeof b&&(j=this.game.rnd.pick(b)),g=new e.Sprite(this.game,0,0,i,j)),d>0?(g.body.allowCollision.any=!0,g.body.allowCollision.none=!1):g.body.allowCollision.none=!0,g.body.collideWorldBounds=f,g.exists=!1,g.visible=!1,g.anchor.setTo(.5,.5),this.add(g),h++;return this},e.Particles.Arcade.Emitter.prototype.kill=function(){this.on=!1,this.alive=!1,this.exists=!1},e.Particles.Arcade.Emitter.prototype.revive=function(){this.alive=!0,this.exists=!0},e.Particles.Arcade.Emitter.prototype.start=function(a,b,c,d){"boolean"!=typeof a&&(a=!0),b=b||0,c=c||250,d=d||0,this.revive(),this.visible=!0,this.on=!0,this._explode=a,this.lifespan=b,this.frequency=c,a?this._quantity=d:this._quantity+=d,this._counter=0,this._timer=this.game.time.now+c},e.Particles.Arcade.Emitter.prototype.emitParticle=function(){var a=this.getFirstExists(!1);if(null!=a){if(this.width>1||this.height>1?a.reset(this.game.rnd.integerInRange(this.left,this.right),this.game.rnd.integerInRange(this.top,this.bottom)):a.reset(this.emitX,this.emitY),a.lifespan=this.lifespan,a.body.bounce.setTo(this.bounce.x,this.bounce.y),a.body.velocity.x=this.minParticleSpeed.x!=this.maxParticleSpeed.x?this.game.rnd.integerInRange(this.minParticleSpeed.x,this.maxParticleSpeed.x):this.minParticleSpeed.x,a.body.velocity.y=this.minParticleSpeed.y!=this.maxParticleSpeed.y?this.game.rnd.integerInRange(this.minParticleSpeed.y,this.maxParticleSpeed.y):this.minParticleSpeed.y,a.body.gravity.y=this.gravity,a.body.angularVelocity=this.minRotation!=this.maxRotation?this.game.rnd.integerInRange(this.minRotation,this.maxRotation):this.minRotation,1!==this.minParticleScale||1!==this.maxParticleScale){var b=this.game.rnd.realInRange(this.minParticleScale,this.maxParticleScale);a.scale.setTo(b,b)}a.body.drag.x=this.particleDrag.x,a.body.drag.y=this.particleDrag.y,a.body.angularDrag=this.angularDrag}},e.Particles.Arcade.Emitter.prototype.setSize=function(a,b){this.width=a,this.height=b},e.Particles.Arcade.Emitter.prototype.setXSpeed=function(a,b){a=a||0,b=b||0,this.minParticleSpeed.x=a,this.maxParticleSpeed.x=b},e.Particles.Arcade.Emitter.prototype.setYSpeed=function(a,b){a=a||0,b=b||0,this.minParticleSpeed.y=a,this.maxParticleSpeed.y=b},e.Particles.Arcade.Emitter.prototype.setRotation=function(a,b){a=a||0,b=b||0,this.minRotation=a,this.maxRotation=b},e.Particles.Arcade.Emitter.prototype.at=function(a){this.emitX=a.center.x,this.emitY=a.center.y},Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"alpha",{get:function(){return this._container.alpha},set:function(a){this._container.alpha=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"visible",{get:function(){return this._container.visible},set:function(a){this._container.visible=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"x",{get:function(){return this.emitX},set:function(a){this.emitX=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"y",{get:function(){return this.emitY},set:function(a){this.emitY=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"left",{get:function(){return Math.floor(this.x-this.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"right",{get:function(){return Math.floor(this.x+this.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"top",{get:function(){return Math.floor(this.y-this.height/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return Math.floor(this.y+this.height/2)}}),e.Tile=function(a,b,c,d,e,f){this.tileset=a,this.index=b,this.width=e,this.height=f,this.x=c,this.y=d,this.mass=1,this.collideNone=!0,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.separateX=!0,this.separateY=!0,this.collisionCallback=null,this.collisionCallbackContext=this},e.Tile.prototype={setCollisionCallback:function(a,b){this.collisionCallbackContext=b,this.collisionCallback=a},destroy:function(){this.tileset=null},setCollision:function(a,b,c,d){this.collideLeft=a,this.collideRight=b,this.collideUp=c,this.collideDown=d,this.collideNone=a||b||c||d?!1:!0},resetCollision:function(){this.collideNone=!0,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1}},Object.defineProperty(e.Tile.prototype,"bottom",{get:function(){return this.y+this.height}}),Object.defineProperty(e.Tile.prototype,"right",{get:function(){return this.x+this.width}}),e.Tilemap=function(a,b){this.game=a,this.layers,"string"==typeof b?(this.key=b,this.layers=a.cache.getTilemapData(b).layers,this.calculateIndexes()):this.layers=[],this.currentLayer=0,this.debugMap=[],this.dirty=!1,this._results=[],this._tempA=0,this._tempB=0},e.Tilemap.CSV=0,e.Tilemap.TILED_JSON=1,e.Tilemap.prototype={create:function(a,b,c){for(var d=[],f=0;c>f;f++){d[f]=[];for(var g=0;b>g;g++)d[f][g]=0}this.currentLayer=this.layers.push({name:a,width:b,height:c,alpha:1,visible:!0,tileMargin:0,tileSpacing:0,format:e.Tilemap.CSV,data:d,indexes:[]}),this.dirty=!0},calculateIndexes:function(){for(var a=0;a=0&&b=0&&c=0&&a=0&&b=0&&a=0&&b=0&&b=0&&ca&&(a=0),0>b&&(b=0),c>this.layers[e].width&&(c=this.layers[e].width),d>this.layers[e].height&&(d=this.layers[e].height),this._results.length=0,this._results.push({x:a,y:b,width:c,height:d,layer:e});for(var f=b;b+d>f;f++)for(var g=a;a+c>g;g++)this._results.push({x:g,y:f,index:this.layers[e].data[f][g]});return this._results},paste:function(a,b,c,d){if("undefined"==typeof a&&(a=0),"undefined"==typeof b&&(b=0),"undefined"==typeof d&&(d=this.currentLayer),c&&!(c.length<2)){for(var e=c[1].x-a,f=c[1].y-b,g=1;g1?this.debugMap[this.layers[this.currentLayer].data[c][d]]?b.push("background: "+this.debugMap[this.layers[this.currentLayer].data[c][d]]):b.push("background: #ffffff"):b.push("background: rgb(0, 0, 0)");a+="\n"}b[0]=a,console.log.apply(console,b)},destroy:function(){this.removeAllLayers(),this.game=null}},e.TilemapLayer=function(a,b,c,f,g,h,i,j){this.game=a,this.canvas=e.Canvas.create(f,g),this.context=this.canvas.getContext("2d"),this.baseTexture=new d.BaseTexture(this.canvas),this.texture=new d.Texture(this.baseTexture),this.textureFrame=new e.Frame(0,0,0,f,g,"tilemaplayer",a.rnd.uuid()),e.Sprite.call(this,this.game,b,c,this.texture,this.textureFrame),this.type=e.TILEMAPLAYER,this.fixedToCamera=!0,this.tileset=null,this.tileWidth=0,this.tileHeight=0,this.tileMargin=0,this.tileSpacing=0,this.widthInPixels=0,this.heightInPixels=0,this.renderWidth=f,this.renderHeight=g,this._ga=1,this._dx=0,this._dy=0,this._dw=0,this._dh=0,this._tx=0,this._ty=0,this._results=[],this._tw=0,this._th=0,this._tl=0,this._maxX=0,this._maxY=0,this._startX=0,this._startY=0,this.scrollFactorX=1,this.scrollFactorY=1,this.tilemap=null,this.layer=null,this.index=0,this._x=0,this._y=0,this._prevX=0,this._prevY=0,this.dirty=!0,(h instanceof e.Tileset||"string"==typeof h)&&this.updateTileset(h),i instanceof e.Tilemap&&this.updateMapData(i,j) +},e.TilemapLayer.prototype=Object.create(e.Sprite.prototype),e.TilemapLayer.prototype=e.Utils.extend(!0,e.TilemapLayer.prototype,e.Sprite.prototype,d.Sprite.prototype),e.TilemapLayer.prototype.constructor=e.TilemapLayer,e.TilemapLayer.prototype.update=function(){this.scrollX=this.game.camera.x*this.scrollFactorX,this.scrollY=this.game.camera.y*this.scrollFactorY,this.render()},e.TilemapLayer.prototype.resizeWorld=function(){this.game.world.setBounds(0,0,this.widthInPixels,this.heightInPixels)},e.TilemapLayer.prototype.updateTileset=function(a){if(a instanceof e.Tileset)this.tileset=a;else{if("string"!=typeof a)return;this.tileset=this.game.cache.getTileset("tiles")}this.tileWidth=this.tileset.tileWidth,this.tileHeight=this.tileset.tileHeight,this.tileMargin=this.tileset.tileMargin,this.tileSpacing=this.tileset.tileSpacing,this.updateMax()},e.TilemapLayer.prototype.updateMapData=function(a,b){"undefined"==typeof b&&(b=0),a instanceof e.Tilemap&&(this.tilemap=a,this.layer=this.tilemap.layers[b],this.index=b,this.updateMax(),this.tilemap.dirty=!0)},e.TilemapLayer.prototype._fixX=function(a){if(1===this.scrollFactorX)return a;var b=a-this._x/this.scrollFactorX;return this._x+b},e.TilemapLayer.prototype._unfixX=function(a){if(1===this.scrollFactorX)return a;var b=a-this._x;return this._x/this.scrollFactorX+b},e.TilemapLayer.prototype._fixY=function(a){if(1===this.scrollFactorY)return a;var b=a-this._y/this.scrollFactorY;return this._y+b},e.TilemapLayer.prototype._unfixY=function(a){if(1===this.scrollFactorY)return a;var b=a-this._y;return this._y/this.scrollFactorY+b},e.TilemapLayer.prototype.getTileX=function(a){var b=this.tileWidth*this.scale.x;return this.game.math.snapToFloor(this._fixX(a),b)/b},e.TilemapLayer.prototype.getTileY=function(a){var b=this.tileHeight*this.scale.y;return this.game.math.snapToFloor(this._fixY(a),b)/b},e.TilemapLayer.prototype.getTileXY=function(a,b,c){return c.x=this.getTileX(a),c.y=this.getTileY(b),c},e.TilemapLayer.prototype.getTiles=function(a,b,c,d,e){if(null!==this.tilemap){"undefined"==typeof e&&(e=!1),0>a&&(a=0),0>b&&(b=0),a=this._fixX(a),b=this._fixY(b),c>this.widthInPixels&&(c=this.widthInPixels),d>this.heightInPixels&&(d=this.heightInPixels);var f=this.tileWidth*this.scale.x,g=this.tileHeight*this.scale.y;this._tx=this.game.math.snapToFloor(a,f)/f,this._ty=this.game.math.snapToFloor(b,g)/g,this._tw=(this.game.math.snapToCeil(c,f)+f)/f,this._th=(this.game.math.snapToCeil(d,g)+g)/g,this._results=[];for(var h=0,i=null,j=0,k=0,l=this._ty;lthis.layer.width&&(this._maxX=this.layer.width),this._maxY>this.layer.height&&(this._maxY=this.layer.height),this.widthInPixels=this.layer.width*this.tileWidth,this.heightInPixels=this.layer.height*this.tileHeight),this.dirty=!0},e.TilemapLayer.prototype.render=function(){if(this.tilemap&&this.tilemap.dirty&&(this.dirty=!0),this.dirty&&this.tileset&&this.tilemap&&this.visible){this._prevX=this._dx,this._prevY=this._dy,this._dx=-(this._x-this._startX*this.tileWidth),this._dy=-(this._y-this._startY*this.tileHeight),this._tx=this._dx,this._ty=this._dy,this.context.clearRect(0,0,this.canvas.width,this.canvas.height);for(var a=this._startY;a0?this.deltaX():-this.deltaX()},e.TilemapLayer.prototype.deltaAbsY=function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},e.TilemapLayer.prototype.deltaX=function(){return this._dx-this._prevX},e.TilemapLayer.prototype.deltaY=function(){return this._dy-this._prevY},Object.defineProperty(e.TilemapLayer.prototype,"scrollX",{get:function(){return this._x},set:function(a){a!==this._x&&a>=0&&this.layer&&(this._x=a,this._x>this.widthInPixels-this.renderWidth&&(this._x=this.widthInPixels-this.renderWidth),this._startX=this.game.math.floor(this._x/this.tileWidth),this._startX<0&&(this._startX=0),this._startX+this._maxX>this.layer.width&&(this._startX=this.layer.width-this._maxX),this.dirty=!0)}}),Object.defineProperty(e.TilemapLayer.prototype,"scrollY",{get:function(){return this._y},set:function(a){a!==this._y&&a>=0&&this.layer&&(this._y=a,this._y>this.heightInPixels-this.renderHeight&&(this._y=this.heightInPixels-this.renderHeight),this._startY=this.game.math.floor(this._y/this.tileHeight),this._startY<0&&(this._startY=0),this._startY+this._maxY>this.layer.height&&(this._startY=this.layer.height-this._maxY),this.dirty=!0)}}),e.TilemapParser={tileset:function(a,b,c,d,f,g,h){var i=a.cache.getTilesetImage(b);if(null==i)return null;var j=i.width,k=i.height;0>=c&&(c=Math.floor(-j/Math.min(-1,c))),0>=d&&(d=Math.floor(-k/Math.min(-1,d)));var l=Math.round(j/c),m=Math.round(k/d),n=l*m;if(-1!==f&&(n=f),0==j||0==k||c>j||d>k||0===n)return console.warn("Phaser.TilemapParser.tileSet: width/height zero or width/height < given tileWidth/tileHeight"),null;for(var o=g,p=g,q=new e.Tileset(i,b,c,d,g,h),r=0;n>r;r++)q.addTile(new e.Tile(q,r,o,p,c,d)),o+=c+h,o===j&&(o=g,p+=d+h);return q},parse:function(a,b,c){return c===e.Tilemap.CSV?this.parseCSV(b):c===e.Tilemap.TILED_JSON?this.parseTiledJSON(b):void 0},parseCSV:function(a){a=a.trim();for(var b=[],c=a.split("\n"),d=c.length,e=0,f=0;fa)for(var g=a;b>=g;g++)this.tiles[g].setCollision(c,d,e,f)},setCollision:function(a,b,c,d,e){this.tiles[a]&&this.tiles[a].setCollision(b,c,d,e)}},Object.defineProperty(e.Tileset.prototype,"total",{get:function(){return this.tiles.length}}),d.CanvasRenderer.prototype.render=function(a){d.texturesToUpdate.length=0,d.texturesToDestroy.length=0,d.visibleCount++,a.updateTransform(),this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.width,this.height),this.renderDisplayObject(a),d.Texture.frameUpdates.length>0&&(d.Texture.frameUpdates.length=0)},d.CanvasRenderer.prototype.renderDisplayObject=function(a){var b=a.last._iNext;a=a.first;do if(a.visible)if(a.renderable&&0!=a.alpha){if(a instanceof d.Sprite)a.texture.frame&&(this.context.globalAlpha=a.worldAlpha,a.texture.trimmed?this.context.setTransform(a.worldTransform[0],a.worldTransform[3],a.worldTransform[1],a.worldTransform[4],a.worldTransform[2]+a.texture.trim.x,a.worldTransform[5]+a.texture.trim.y):this.context.setTransform(a.worldTransform[0],a.worldTransform[3],a.worldTransform[1],a.worldTransform[4],a.worldTransform[2],a.worldTransform[5]),this.context.drawImage(a.texture.baseTexture.source,a.texture.frame.x,a.texture.frame.y,a.texture.frame.width,a.texture.frame.height,a.anchor.x*-a.texture.frame.width,a.anchor.y*-a.texture.frame.height,a.texture.frame.width,a.texture.frame.height));else if(a instanceof d.Strip)this.context.setTransform(a.worldTransform[0],a.worldTransform[3],a.worldTransform[1],a.worldTransform[4],a.worldTransform[2],a.worldTransform[5]),this.renderStrip(a);else if(a instanceof d.TilingSprite)this.context.setTransform(a.worldTransform[0],a.worldTransform[3],a.worldTransform[1],a.worldTransform[4],a.worldTransform[2],a.worldTransform[5]),this.renderTilingSprite(a);else if(a instanceof d.CustomRenderable)a.renderCanvas(this);else if(a instanceof d.Graphics)this.context.setTransform(a.worldTransform[0],a.worldTransform[3],a.worldTransform[1],a.worldTransform[4],a.worldTransform[2],a.worldTransform[5]),d.CanvasGraphics.renderGraphics(a,this.context);else if(a instanceof d.FilterBlock)if(a.open){this.context.save();var c=a.mask.alpha,e=a.mask.worldTransform;this.context.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]),a.mask.worldAlpha=.5,this.context.worldAlpha=0,d.CanvasGraphics.renderGraphicsMask(a.mask,this.context),this.context.clip(),a.mask.worldAlpha=c}else this.context.restore();a=a._iNext}else a=a._iNext;else a=a.last._iNext;while(a!=b)},d.WebGLBatch.prototype.update=function(){this.gl;for(var a,b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r=0,s=this.head;s;){if(s.vcount===d.visibleCount){if(b=s.texture.frame.width,c=s.texture.frame.height,e=s.anchor.x,f=s.anchor.y,g=b*(1-e),h=b*-e,i=c*(1-f),j=c*-f,k=8*r,a=s.worldTransform,l=a[0],m=a[3],n=a[1],o=a[4],p=a[2],q=a[5],s.texture.trimmed&&(p+=s.texture.trim.x,q+=s.texture.trim.y),this.verticies[k+0]=l*h+n*j+p,this.verticies[k+1]=o*j+m*h+q,this.verticies[k+2]=l*g+n*j+p,this.verticies[k+3]=o*j+m*g+q,this.verticies[k+4]=l*g+n*i+p,this.verticies[k+5]=o*i+m*g+q,this.verticies[k+6]=l*h+n*i+p,this.verticies[k+7]=o*i+m*h+q,s.updateFrame||s.texture.updateFrame){this.dirtyUVS=!0;var t=s.texture,u=t.frame,v=t.baseTexture.width,w=t.baseTexture.height;this.uvs[k+0]=u.x/v,this.uvs[k+1]=u.y/w,this.uvs[k+2]=(u.x+u.width)/v,this.uvs[k+3]=u.y/w,this.uvs[k+4]=(u.x+u.width)/v,this.uvs[k+5]=(u.y+u.height)/w,this.uvs[k+6]=u.x/v,this.uvs[k+7]=(u.y+u.height)/w,s.updateFrame=!1}if(s.cacheAlpha!=s.worldAlpha){s.cacheAlpha=s.worldAlpha;var x=4*r;this.colors[x]=this.colors[x+1]=this.colors[x+2]=this.colors[x+3]=s.worldAlpha,this.dirtyColors=!0}}else k=8*r,this.verticies[k+0]=0,this.verticies[k+1]=0,this.verticies[k+2]=0,this.verticies[k+3]=0,this.verticies[k+4]=0,this.verticies[k+5]=0,this.verticies[k+6]=0,this.verticies[k+7]=0;r++,s=s.__next}},e}); \ No newline at end of file diff --git a/examples/_site/examples.json b/examples/_site/examples.json index 93340fd0..1674520e 100644 --- a/examples/_site/examples.json +++ b/examples/_site/examples.json @@ -148,6 +148,10 @@ } ], "display": [ + { + "file": "bitmapdata+wobble.js", + "title": "bitmapdata wobble" + }, { "file": "fullscreen.js", "title": "fullscreen" @@ -159,6 +163,18 @@ { "file": "render+crisp.js", "title": "render crisp" + }, + { + "file": "render+texture+mirror.js", + "title": "render texture mirror" + }, + { + "file": "render+texture+starfield.js", + "title": "render texture starfield" + }, + { + "file": "render+texture+trail.js", + "title": "render texture trail" } ], "games": [ diff --git a/examples/assets/pics/backscroll.png b/examples/assets/pics/backscroll.png new file mode 100644 index 0000000000000000000000000000000000000000..c6ace246ad27d481d66e74f718e1b4d72924809b GIT binary patch literal 14138 zcmYLwWmH_t)-41L?(PY$!Ce{%ZVd!?C%88noZ#+(APqDc+#Q0uyE~0bkig^I@7;6% zRPQmm_OjYlHEXR|-&K`m&{0TGU|?X-|3R;KARGdQ z;ZGO^)x$0c_HKnuU=uuhpn}QIt~`QGn80^PD0oaxo7Y7GBGx}u-BHC|WyjkOWY2eg zegCbZnfIdl#~p()BYn#O7kc|Hxlq39Mlp~$5X{}j9g7Q6&mjFF`*t>26D-=@#nR~Pd9qe)4f z%xwki%=d^&lp}p6OeXb=sDJ-d(Nz|43ItN)hiMQ2P0CH|(k+>KP|>d`fQ;T)qMwQO z?Lz{dv4&rp5^{>h#6`iuy)4-_;TW|MRw6@a!ry(f`2{9EPfToBIfRfEF}`m`NB8fK zNBPGBtneKQAP7@Y&gV$Mn>NA<5t2z2ajwPR7cc+v$$|6h--+;DrhL{1W%d`QdDc@> zHN(GyRqxEI&kwW6F|nDXo`idS_d_wzAZ;&zq#Pr^^o^XAi!T%yL2vGQp*{K@#|eCU z%r?eA`v1!C#9op_U&Q=hcwW;*Ux`GFZpjPLggtIiddb8{$PY>Osu$@`xCk?Q-6py! zzOpoGk?yxu`Tspg)IB4o%f#-R=u^3S#DRCl@;As1?JSX)>Fo~P=Q!G;5>a<*-{6P> ziqC`(k^M(K6~=%~i{<^o_4(`T!HK7}2j#L(n_6fi; z{u%lxOR}%T=C(MX0$joR@aEmN){WDRH_P&b`V4)9GUBs*a3m{cxG6nD3o^*H((D5_ zaFxGTruMf&umIWrO(Kji4M2h|G^X~HVvzeUv~E$LNIZ>Pl1bnCwhW8sWN9D_YRIVK zl6MLED!{AjfQ?dlX|g{37b(h064YRl(}cY)_M0vX3{C7zX2jw+cm7bgxe4&;oc7>9 z0X1t8hr8spLaTMjqZ4mFh^Ub54~AXY^**~t!9=~n*y;8gLiBlt*Ln(nJ(-OK_J`yM z^un8%vgdyB85ahd9@8SQC(*Vdn0*aP+TGYgQ?ZI!Vcn&O4PG|FFy!BN`cI^t`H6tA z0H&dad_d9KL8ia4Y$$cgJ-H>Q&U{_lmQ7N*_UpuXGv|H5tb{Y08!M5X3;P*3ciTLF z(|bIAI8Whsyu74)Jb-EVp`{~Uo^2C(J2c^YnZURqb79a&E~XaQ7f5{F!N>rdmJ67U zNRKP~t~Qe?&r>R38&kl8*?Fmsc>OEce@C6pE6J=Hsrhr#VU0CEFW_W4Gj1YHuUv__ zgqwb%N8n6doc4WKp`po*pBiDY{aUNECL8 zc4ne;?}fuoil5=Z6tQWf`*$SvBS*& zDzf?R02U~=P2+O6w+2bu{Ml|=oW0Lm(#9NQ;8rlPd$%ixSAQr4>9Al0^pm zo3#O%t&{fwR{pW<-!Iot$%8IawhiU&DW@}=2=3O&e7EcZ=CWMew$O3d+0oXCONzNs zo;J4zOlN|8h;uPQd!`5jbejRAL$Zkzs@QFiilW_5X;It8fny-a_xN)k7qMz>@Pp55C6M2+-$sFH*P2gc&ib*<-r*)gSbt<%w~Gx(yBAo z`QbyZ^x&;zrMX9VZ(mdQ6)_~4&>)J$3JIF5Z3;Ec2^h?TMc=6L&*zFpOi6-dSnHl! zRvrtfeo)j-3X!&~=?RQa6U0S27HAjD)#??;Hq3L=H{Uj9slCjmVO!>oRY`5CaaiP4 zHL}Y;<-`vgz5HblcsodfLrRG)i#_c$X&9~~)Ahn32Sa$^Le;$XdIR4W3Is1<@|kr52PhCK z_Luefx4ci(%ut$S?Ozmkyo* zPEmo4j!ay_6)(~KQfaQ?4!Pa_eB*nNMXY{wU>TGDtnn-v;Xb#+^YNA&P6O04O{-L z8I`5czIE~$x+We_?^DP-Gkgk?$lwjGdtfd;7>m@+H~9^cWMaH_(r0T$!o!q#smwa8 z$mogIkp)Lc3KtEUQFEOPu^=+9|Bh#$8QU!lL7Ah(0qPJ6TEIW>hZBE{1d5x#G76>Tc186MaMAgKU}D4RkY`&y@}pP>if~My;Cr@lc^6@#tbGW> zwp95|3Xe`^bQLXsnY!QF)^EFP)Pm_2PPh=rGV5Rz-L3B@p~p$S&`k)$9*H?Ex#5rf zQc*CO&a_LD<=apo$K~LRBx%_P7xcw()YoJ!NhD zprl!ljFE~!cZ_5V-kr3Z?ddfkxceoUwKe978rGR;KYv=KW+X616&2*CX2BucYMM43 z>&dpTA$Ep?ch~uD$a$I;$u2=oA}6WBI(GGI}4 zT`WnsE%fDD!bpyP1O24%i8ndvOf=CaXQ+F>*uQ*yy-Sj5c&T!3f?By12Pjdgq$Nz# z1245Qr=}1MU0R#MH#Y#PuOk26b0%X|t9LmuPcF=$x%c48WXTMaQxoWZB0-A~AW}RC ze;Kf>iVW@Gxu;_-ta)wx#on9b`Uq{r3V1sGTN|oz2PnN5Kw+*f__L^62!DvQ&x>18 zCEuZ>3eOZWae`;NeB$& z1mB6F*~)^?V=>XYdaXq$%nbmpC@wmVs9T1ye6a>{oaSQZ?_-TpUQ&^bI(2g%{;}tVv4q_?Br;^4xJ^HRa`EUta?Md! zOh!&wb@I**49bNK>Nrw>ywVGPgK%%(ImY{>g;5sokA;afJo0>bV*S`)Z}KR!>Kf^Y zOUs0OpWOH!W>vLisioG6B2Y>tbaYY724!x3;&z~qkyZJ9Q{T?r%6QZB$5>QgvPW5s z5v4ZzlVt6kfRhd4d^I6k?`r=QzH4;i&sxh{!v<3N1k7ly&$7w$etlp?J-w z!25C_|L$`I@0Kv)x@YIuiq(&}Eb75>El1sV48x7L6-F^95k;j5FqM${)J5941o!tx zD^h!cTZZf0l1%xd&fyv??Hg^JmRahT+8IgVfQp^mm&_i=SC(+MfTg|1%LOHDc_T_p zRDq33D|6#Wd|E-k=!MBUqS3Z0i3b#wS8Ty9K{6wwAIw1=0V#^_CzW%h*z8?~``6uv z1b-cC9?%Fle}M+rSXY0d-rSAWkJWU0zk0qmCzrZh?Y=pm9k|;1os_qE-NR7zeFZvh zx7wW0M(A_g0Z5WepK6^u^%JcB4)p(` z_%@_t)V}<4*g0KA@BU^_H?4d43^;ANh<@GE+tDd6 z9#JmS&}=^U_H0z7panB}c|go2D>WG@E7C=>ymd=Qa*xq%Lbg)KneUx)cm24>l3X?S z-mNdg!Z*T~44J=CA93y(@l^%!Q3f_%DW+{o56RrL=X}#yE~)8?>MbH=Px1-!`z(NZ zHP$4GSI*_XBPXzdORG6T2#1>rgx64~C=h#8&B`u%{%&F47g%TkW9_yJf)AMGMkJoh zf!cK^Ye73bafB2}V%V4r4|sGU-kohpqpXkWA5?7?}Fm{Cz&} z0)rBQ!ur0qtHgx-jlS^bubGos{vI7fL0|o9@YokyHlIZNH8lSe%$ijFHp{e?#&9X; z5y-G!p}>%Io2Ohc@&hAPJ;m$nl#y35dpOwBel&pfrIy|U}M z*J^NnExn!_lMXuBIwhDG3mlT5h;2q;fZLb*$&4PcyQ|!c1s#Nq3$3wYRvH@it7+%i zhr4fNnGq(7lubab)1$zMarsEn#hzZCtJqEdKJ9Raze>asP&>T*yObY%;-78YO{>fK z^}~VEGp~1$Ys`W&7FWjtle*!+B6l)ymtthPyBsr5Lpn>(Z?;1<4 zWV-tEiHCJyv>Omxh@`Spzs&?(jfyX5oq=LSx18K$X+ta<`y0Q7(1&RhIR(-LT~#&U zaxdtq7l(P+TYIez$+X-a>h3P_|-rFvpT2gcOi}<*n8PIj++L8?=A>@B{bAZ~0{B}wuktpf)-sGK!QmS7 z_1dPcSN7y6S_z|7QUa*FhtOa3ow_wklQ^+x5N%g?p$|V)fTN!p-_b!M>PD&x#vf$mIAjHS$lB-{AQp*^X-)pkteHc3M zhCRmvNLNU$aMlx9u5DJX>Yh(d=N7L2K3v}}AM+0KtWavX7qW*l)`tc|5krg+hK1*u8!T5Ce`=kqRijIDpA-_v5^zx}x|+a-?YqO-IZownV6^CZeBe zi*+s^?I3t;BCqBMDr9p{bJM2X8g|Get3;X5LvqioSMZnMTDyrqm4DOpC>dtZGL17- zQVuUJ)K|a#v(17p1t~KLwm&|%E)wbsvk7t%EKXPU_WRyPtw9QVR*9WHyH-b+n{lvs zh$Av&wG~})>3F?u;kZ+MT;NaOFIXa=nzBnI&})TS@u0T38ieVWo`{+OD_x=X?o(t5 z`Z(=HPN>=)ciwMn7o5a;EQuEEB0*W5tDx!ttyrs~&~9BID@1c37QYRs^4w z2F3AE-nk706Sh7Z-FgwY#a(8(kHcDq2;fPhiL`x^+?UI^ja&jND+{9PXP*R2pksD^ zIpIWy;BR6oT5;;HeOH+CnY8pWb96!c0V3nQ(~Z2wd=Ect!Wxks1I@x<1rTr@e5kq3in1~Eh{m$gg(-@OBudb) z_u-r&J-lF4ULY;C(eP0bf|D#z7rWm?f|g!*iGx1>+wBV6dMo! zc;KY-;Ot;3Lr?wy3ewH>`Lk?ZES=hvh;L~>V7BVW*cHhZVglP03MtKG4;Hn6C z+6dCMQ>Sc~U4vEn%u&K=-ZeN>w4qa|ea;qsNa|1E;(FWRcC2wEee-KEwm8{*h=*KG6$y5X}-@gYF|GN13+LTavqyy2pF;qpNVCsUER zz1&Vg-VK;f^31O_ajl>k0SU>z=-_0l*E^=RvYQ+iBG?S9%QAy7of=l%ndg2#(grn$ zCCM^`2KnFJZ6q~92Y1ij)NY^o@0uw$GDoE(AFIF}(bX5jZ zzN2RAiC3msV`l4UBD$_TP1x6x5d3fqb_dnIXJ}4$F*^DNRs4D)_eZa9!%%eaF0n%2 zeOP((+f4!&S=D=U3|gNLuNrB7v+jLDX6N{^$$SW0y>F3rl%J8I-D5Ov^|vY%UQTpK z(Xr6rmf)gel5E~mE4Qii2zg&EwDIw05S{o55r<~|t+@i?7BxOc1Abu}B^bV<(az%X z6aB}kk^!F6k8Cn7*24MmNUX$Ck|+i=$O3-ltr)G~w86?La;Bt2~&YW5(T^_9aNhyFqj17C4cS;ovvr5`OI-)}9 z!Zi9AI$Y}H6&4AK?o7KAS>64|_ zz^yvTU<053g_Z7_V6eSOH5*(+un4>~e-4azp9225(feOF+P>6l))Z~WzLmrEj$JFTi zm)QI1-RBPul38tPi^=;Hwzwi>HES6ns{Fjbpx;4C)n>V6kQpT? zFlq&ZwgYhNXY3j3H^8lh;UmrImJ!LOgZcZ*TU+9Zq?4szAp^aEf1q7;eL;w4Lp?)S zo)!ovT(*CL6a%C1RCgqV$qrjvgvr()MIwGormb_IZC#|gPmy6w%l`}MOu{u#++Esy zYqqUWon*li+Ztque$*-Xjzt)@Ev`ZLZaR8P?1CSjcncd6_xz^N5Jq4C9m8vJMU4CH zU8mjd{Jv=%(r)gi`}tUE`kqKRp~P+F?tT5~;zwJJLQepuWfQWI_a9gG)wD5wy&Fi5 zA9gq#1ekfSy1ZLWRvtc%0%3MD3Y<7Z$l0wwGDI9edf9`#a<~CeSiy(+i=?^rN1b2z z5zkpDu*n90GY-bwoet`T_RGSuNx@-!F^Vv^p)O;0V?esk z%z8b?PKF-Rb@$W$F3IB2a)52~k)>|sW@>^AZs~SLjcZgdbo|mWlAkn(=#Wk9_5|1F z2oc^b@$x#%Pya2oIE857iOFs3Ox5IRN&C;7xX$s2fv~^rWKLb#E53)o53%NH>sYEs zZd((p8KFmFqg+h>&>yNKu{$D^>k`(wi$6ksKR!z@jPlLL=r}&ozX@@Sx6xPl3hk8M zF@b+rQQ=ewPY^8cJtG2Fg`N1!u(yOFC1fgN%ThWl8m*SeulTT@s!>WFTAFw2vDdbD zQ~R@w(bgwYG;ekcZ_rDE&t09vmQ*SYK<0hoRA;Uc&cjIol#reBflVDlt)A%pbh^l) zSXTK%Z>b%pNJ!Avj*Vc~5tye-c2N5`$^#43dxj5Aq#;aML( zP{e9@AtX*vou~>4-i%;VN0jl1*27KCw1;;3`sNtFp(EyUpNk5J2UX%sGF;j9PgNns z%s^j9h5hUZ$=y8YeX6R6)*5oSg?j965+cvQxTY<*%5aGcGraDW^S_6qPuIyPra|y5 z?mCR*YYlQFj3oAAGDfnr{N!jt>J;@=<}vtfUc9DXVyoG({W@-$53jcFj-y*2kw&yD zESGfIY+y65mL=U~5gHxOM3Q9(u&KxW+oc9)c6j^%=^)y2z)%A&^OuISVIN!o6ZRjb zl$(Ymd7|4K87dg5QeN>nDE13h^NC|W52-xXRRl8UCl<84SHlIO&JD}=himjl0!y_obQD4Xm){Djzpl&QkMlT0j7a(LgKaGc{(7f=t}XmviJPg> zE$Wm-2M&@%Trw&kKvY+kor2<6T|IIoacquk=|kvOFf8fsG99KQhnSD% z1R2TnzHpu%=q*A9_Ziclxsq=PZ}djW+Ei+1+Tq|`pFw5)pw7(DMN#@T9l!cRBq!8Q zs4USm%+9h_UmY1d=Tg|j@lFNBdC0r3mpWDZ(3RsGa4u`N?#@X)Y(8svY#Q6p=qNrM zZW3peBG%mA(_R709^qgczGeuY7B2a$*)3rSXq0PdD&{p=NwzeCWs_7l5X$w$JP0Rn z#tgr=lu5hWR|YRLPhxxg+7q+-x8@Abd|dY#8ld! zA(Cp$_nx1o??%VKd_f_OjVwDhTN$0i$&4Y%byC2^an9A3#dux;I}gT>)Js;{GG=xI znxANv`#MyfAchB2Tg6c}Q!Bf}emB^-TqhNw)MJGO;`=$?M5pxzVPp%pP z8_J-q$SO6(ln=HV{IL95%6b;Ydt~aJl*D&+sDd38ld4<5a?>|U|I9kvbwV#K=9GW~ zzy3>*C`&b8w-TFLC?sF6wH3-uJ+HDU(%V7=749clvz6gzDFiZMRWmyF6A#{>(v;2> zi{7QIdO)}P2i%drqB)S>%90C638XuCH!G5_7GUxi?rsjphsc&pR#sX~6$7VqJ!ZzIII*`kfhjgp zxprDH5Uu^YqxJ0Y(bgb2X+(=H(~Fg~m59UDK| zimz?L+4Z~eW_H$GbWe+1@FHqE8tTt$QoZ%&f2=Wl^zA*HIa0<9=XCrZn0?C@9A!w! z%LP&6)AEpXdf`?x^mMJ+WahmwRE%hiIN5{pv6-i=EjTUW`e}UPLW*!^%RT^@itu?H z9wQtt5qY2*&wlFtF3cgY>ro=<;Ee;h(jVeSbZ+8xA5x5Sf!}~zlIIz_0@Nw#e_3^c zs1%VQ=`tSfl>Gjp%xGz=6cFk!o4yWFm&s$QS90`K=Xq6jKRJ81&5R*4PEM=4pQ!Pt z5?q12+OFy{Y$Gr>*h>z2iL`&tDYbS-QPdKH;52F?N7rb*rYVBy3Cg0ubi@5|k-vupH1J5wceNJY$>98LX9_oS8e%lEAGnG(&ucP$mPuA1cqK6v`~gH&2# zgY<6WMjsP4ZdG;NL#5NrAKza%TkKJR-wHTn0+|OxZXDX2N`^m59+mBw>|RUPn5(J) zAd2V^8ZwmiefQ#a@WZ#mKwK?F;Vi#~kDv#FuWONru1LRp(^T0)3hr$Cg-mN6mdn~& zB#4B1Tq!N#BRHNSC?nj%H6G3Rn)bXL57oRRALc;S19P5ZEzCv110;`kvK3NxhZ$B< z*^Dxfc53{K!8qATzk7Wj@?eJr>u*hpM|z&s=oU#1W28a(Fek{4!{LOSBxf^aKjS0o zAuA+`Kzuoa39Nt=?gEDhAZ)u_pDgntPB%nzQrwoZ#Tq<3=eK!NyKzhS;0m=x!ButvlCeEAR zLYG1~o>3$SQBJ!!YFTOpr%fp6Ut9VAHu;AZi_iNfoXvDrzH7%-3XnRuCXjb|2#Nm? zyZM91uOF_cNgHn?OLnWFx9f-)dgBCdrt;%xE22dEK5|CX6%?7mzsAo0?jt2w`dtmx8_=@j2XIw?hS?C&DQeQyfyQg2~`Z&|- zU;fO&j$RgwiZA=9N?BFueE!u|cWS90i7qlN>f*AP<>=Uf*S5gKpQL=j^?SG_ zqH=a+ZmU@$+C>;q(B-$6C-Q4pO`lYn~vx{*kUr4cLuYt9h+Ji zrTI;(;~9+!kEU*<(NjL{zqS?dk;I*&v3E)SHo25BUPi>Ej^QHA_p$@O>?@%_q`vX( z-@@!Ed39=)o_=>W1p^RELaEXiQ1oQ4)S5rfKUJSbepUeDt0+N7P@__tB&>g@tky~g z9q-DV`$caM0Y3>ve}q}~q><$uEc6{Hau~~L#$?QTwAM-6U76(p;<*#1m0|~00Wlq8 zaiM*BpjNJ7SB5Kr2KUPjAg$kLY>Jstbm2<}D)u6MdIvhSm_LL}m@@FQPEoMOjLP3Y z=(@V=S;_e7hJ{*5j_uMz$;4f(0HunAbo=h|l8(~$VUCf}xO5wrZ~WJE_f2*}&)$Vc z6d0lR$#7rz$99XR8{ofw)`qAUqgGrhRAc{6^lSka`h_R~Q7uz>8{M35=pHv&9#ZV8 z*VBfV>48p_&IaX+X-VAv>?A!|G~lhEk(+R(>TMSTGWOF#er%`r9A{ftEB}KpyQ;re z9?dFR2)=jV&WTL2hZ7=bosv#sVs9Qhnl|D)#w<9peB4EKh~cH`Y=jCBpC!s?wU+$zm6|*WrwQ(xQ8N_h<(iKOG+B8i{e4R=Xh#uj&TBF?q$o&?r;K@|@V?0EM{%NZft=U8foANMceI2Q~-Ob(kd~q z+KyZR^HcuX-TWtwOz3r0Z1(UM!Jo4lIh)}yf>f5LvDsM>Q1@&XVv~dJ%~=nQuD17I zknRmx4)`74J@RT$pSo};-b8sZ&WOIUfLJbU4I0#kmYtKuKFhfgP8{5hAUQU`@qK9f z%r&?l#t@5G75M$4|Ayxb7?=UdMk&V2{^EToUq%2SYsRP1;)%pqMV+v?jzmg1^Zp$a z=?{94$|KI4I4JmHTgsWe^QgWY2%##f+zZ+oIM{MHIv zPUj5Y8b3Q*GK^zhl9XOgn_(`MezsPQQlgMsfzh3oVi}@U7RsTFDN?O#Jm{|Dh&eSt z=`*2-{azZ(hp>2J>|{f+p6Q~y-KHLV@1fGRx6Ah9ZeG^#eDx-3wEFWnA}wi|8Hm5F z^f$`CguA+vBN<;(Ka+|{(i4)Ynae`l+ST$uzkqT2Qig?OT0T?pk=u8&4N?7d!sbsM zSFZ4X4DEz|#-qt7e2cY#5`zwDm9>rnpu9=G` zKwQcPArkM&plE=mORHzwqfmX?H}gJQL;(gChkAj-g} z9^*lohssE>9A**KWcU){UiB7&jnjPUMeu%WoY*FPaeM_qNi1 z+DdiBTqaXsr0IG8Qchg3I?_~stKq8)lNnZNZ}=sd0qYY1tau+ zbyKF@)P%~m-6Qy+KK)XY^LQ83 z8E;9v-Vc0B%0tHs`us(XaK?JGjZ+84vP#UuP^QBt6y8nl$|F*`X_J|xT>~XW&U*_p zFY>P7g}D}&X2fQ+jj7S9F2S=%w`sUfmgC{FU4Wkh&Bd)p#K{`DlvZIHkI1@9q{%c` zxFb_Hj0`&~CQ%JtwN(Wca6rk1yP89Lt%pt{*abZnt3HdtcF0*ex$pg%(wx#V$@}Rm3 zPoV#Fa?}{GarpEP2^rax#2?H|{~zjkgqibn8_4-}%9m5Fvm$`j|8}sk&?7hwq)?s% z8flE^^xoA=lo~p}Cos>$^otsoaJ)_}87@I;lg3Utzadbkx@J{h&mTE3TfaKml1=2r z`H_!%K7ZfQ--@de5T&&PntGG5tyk1Z8}n)QkDgP^0eB-(V+9K9csb0_0X}E-%TIKK zUGFig{{K+-FJp>fx=rH;3)*&`M9kyoDX6QU-?_o(IP7?C;O+N1UI05Ckc1+sZWM( zVC4l5;SoY-MPs47^nIw|Ly}~}UusV1+*0a)*~YQBh9*j%(o&EV#~cd%q-xcV(So2m zgv44?W4z9w9oKOGAad8=JFkcx^EjlBmTZ#Pz6$zI-f(250!CQhK zkDxwPy1b+T#X}j3qRPr*PA;+;*<>}WjMv50tp7U{ELaqWF~D%iwOd(Uz-w}~m%OlE z%}J1dzDimD+3SbuNd^|_=zWx^L2_I4iFAyg?kMX;ULafEvP!kV>xoNvYl1oL34xdL zNatF?Rwl_+;+EHE_ekzU#cP)!uQ-fO25>v>*ZAp{iM_;WOP(iXz~TtcId#Z61x7XX zbM)k&41?-D#)GyebEysIpNuK8mhMfCTXY^xPuce?s>^*ClxmdQ_6*QZ=WS63M2FrU{SBy3FVEn{n>q^ zoJM`rh%qN)yX-N1xGG+Ya@pj(Djw<0$|@bla3i-Ze`K&oQSXMbP23R&BQzX&%dxnQ zkD%xObDo{~J>&{#u%PeRLwR53^2R#!!&|iu>II+klkb$vCFDPV{hoT>0wjFhL%v|b zS{Q_h$fCJVPHzZ1HfPetv6^>%K|$`n+tW@4RyuX^bna?2iRng3H%AAOFhW-t$L^dM zE(k8VSImP|7O9F8P{(X`0j?xQ)&@EDdH)iNn|%1`Qr!?JFL)z5Z+;>cM?d~V>~uD0 znvBySWUF&fYe$C@y#|Pd!8T7iwoMkd6p;2&sxb0Q*>c?ET<6UFT-;B_T{I4c73FrU zjB2!lA@qI(gcHwUH%+P!w>afBPgd1T;x6nh5j=i;yL)l?gY#O;5B<3JLV0P1muR*x z*PF!IQpoyEpM3DT`xd}8FBg=zAvgVhIy)`?XXvC0|L2zoquM99jiA+rTSUh#z$=!^ zHjb);Q=Xjipq{edf+Dk((~|=(FDcsiS5PruMBJM%a8B$OI}4$xF~z#Bd6>F~0~}O@ znW$r-6#8$Z-TzW2_Q+6kSm10Wy=u@(z}rKdP0LYMo`?bVUuq@Jxs@H`-}?JEhvx9d z=vx&DV)AuZfZ8jXRW1;)OK_DX8a?4EOZ~>YS2;E{r%+14z+@j zY@LxSSFA*$O{oyBQkjO_E9IY&&ogq%qxVQe{Y!+n3wRw3rMUXPYXA~d|GOq*E*iKh zjQXw_KTW9`66>+v!3cbpMFXjYXgMBJ0K1KBM2Cu;M16ycM*sOQQBdxOzGNl!0#)3< z`MJr&&kzaq;G(F|LgmW5s8D@LVD9v6mFr#heS`LHrf99}`Ev3-TL+;%N+-tUr4n_c zXe?i-BizSZPg-{ubUtJkbU>~yM)-YPUPY^L2jnbrp*Hhs{R2lk<6o`X%pT@v%2^Fc zH6^>_47tCb^sk|XFGQ8y=Q&Amlt5Jt zKIZBXa)Rr4+sBlSwin~QeAaJr-kbo^FSLxd(fIbN+89ohNrO07xlFch>p^c-SxMki`Afnq9XoqOq$yPCv>^L;Z9?3wX#7w<56L6X(nU$%WJF$d!bp4-@?Tlggi~ZxT;KFk! c3>=KfkKDQ#(aEv5%WyDq(#lem0OO$l2ca%B8~^|S literal 0 HcmV?d00001 diff --git a/src/gameobjects/BitmapData.js b/src/gameobjects/BitmapData.js index 863d7e56..a1f5247f 100644 --- a/src/gameobjects/BitmapData.js +++ b/src/gameobjects/BitmapData.js @@ -55,31 +55,11 @@ Phaser.BitmapData = function (game, width, height) { */ this.imageData = this.context.getImageData(0, 0, width, height); - this.pixels = new Int32Array(this.imageData.data.buffer); - /** - * @property {Uint8ClampedArray} data8 - A uint8 clamped view on the buffer. + * @property {UInt8Clamped} pixels - A reference to the context imageData buffer. */ - // this.data8 = new Uint8ClampedArray(this.imageData.buffer); + this.pixels = this.imageData.data.buffer; - /** - * @property {Uint32Array} data32 - A Uint32 view on the buffer. - */ - // this.data32 = new Uint32Array(this.imageData.buffer); - - // Little or big-endian? - // this.data32[1] = 0x0a0b0c0d; - - /** - * @property {boolean} isLittleEndian - . - */ - this.isLittleEndian = true; - - // if (this.data32[4] === 0x0a && this.data32[5] === 0x0b && this.data32[6] === 0x0c && this.data32[7] === 0x0d) - // { - // this.isLittleEndian = false; - // } - /** * @property {PIXI.BaseTexture} baseTexture - The PIXI.BaseTexture. * @default diff --git a/src/gameobjects/Sprite.js b/src/gameobjects/Sprite.js index 7b2d9b8f..81ba258b 100644 --- a/src/gameobjects/Sprite.js +++ b/src/gameobjects/Sprite.js @@ -358,7 +358,7 @@ Phaser.Sprite.prototype.constructor = Phaser.Sprite; */ Phaser.Sprite.prototype.preUpdate = function() { - if (!this.exists || !this.group.exists) + if (!this.exists || (this.group && !this.group.exists)) { this.renderOrderID = -1; return; diff --git a/src/system/Device.js b/src/system/Device.js index 6bdfbf3a..db7a6372 100644 --- a/src/system/Device.js +++ b/src/system/Device.js @@ -265,6 +265,12 @@ Phaser.Device = function () { */ this.pixelRatio = 0; + /** + * @property {boolean} littleEndian - Is the device big or little endian? (only detected if the browser supports TypedArrays) + * @default + */ + this.littleEndian = false; + // Run the checks this._checkAudio(); this._checkBrowser(); @@ -444,6 +450,11 @@ Phaser.Device.prototype = { this.iPhone4 = (this.pixelRatio == 2 && this.iPhone); this.iPad = navigator.userAgent.toLowerCase().indexOf('ipad') != -1; + if (typeof Int8Array !== 'undefined') + { + this.littleEndian = new Int8Array(new Int16Array([1]).buffer)[0] > 0; + } + }, /** diff --git a/src/system/StageScaleMode.js b/src/system/StageScaleMode.js index c9318806..e46f9a1e 100644 --- a/src/system/StageScaleMode.js +++ b/src/system/StageScaleMode.js @@ -310,17 +310,15 @@ Phaser.StageScaleMode.prototype = { * The optional orientationImage is displayed when the game is in the incorrect orientation. * @method Phaser.StageScaleMode#forceOrientation * @param {boolean} forceLandscape - true if the game should run in landscape mode only. - * @param {boolean} forcePortrait - true if the game should run in portrait mode only. - * @param {string} [forcePortrait=''] - The string of an image in the Phaser.Cache to display when this game is in the incorrect orientation. + * @param {boolean} [forcePortrait=false] - true if the game should run in portrait mode only. + * @param {string} [orientationImage=''] - The string of an image in the Phaser.Cache to display when this game is in the incorrect orientation. */ forceOrientation: function (forceLandscape, forcePortrait, orientationImage) { - this.forceLandscape = forceLandscape; + if (typeof forcePortrait === 'undefined') { forcePortrait = false; } - if (typeof forcePortrait === 'undefined') - { - this.forcePortrait = false; - } + this.forceLandscape = forceLandscape; + this.forcePortrait = forcePortrait; if (typeof orientationImage !== 'undefined') {