From 3f99b691c90707ff47ed05b012589a1890cc4b87 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Thu, 7 Nov 2013 06:10:15 +0000 Subject: [PATCH] Added in a Group.sort demo, also updated the documentation and build files. --- README.md | 3 +- build/phaser.js | 4251 ++++++++++++++++----- build/phaser.min.js | 19 +- docs/Animation.js.html | 6 +- docs/AnimationManager.js.html | 27 +- docs/AnimationParser.js.html | 6 +- docs/ArcadePhysics.js.html | 12 +- docs/BitmapText.js.html | 8 +- docs/Body.js.html | 6 +- docs/Button.js.html | 30 +- docs/Cache.js.html | 6 +- docs/Camera.js.html | 6 +- docs/Canvas.js.html | 6 +- docs/Circle.js.html | 6 +- docs/Color.js.html | 6 +- docs/Debug.js.html | 6 +- docs/Device.js.html | 6 +- docs/Easing.js.html | 6 +- docs/Emitter.js.html | 6 +- docs/Events.js.html | 6 +- docs/Frame.js.html | 6 +- docs/FrameData.js.html | 6 +- docs/Game.js.html | 15 +- docs/GameObjectFactory.js.html | 6 +- docs/Graphics.js.html | 18 +- docs/Group.js.html | 377 +- docs/Input.js.html | 6 +- docs/InputHandler.js.html | 71 +- docs/IntroDocs.js.html | 6 +- docs/Key.js.html | 6 +- docs/Keyboard.js.html | 6 +- docs/LinkedList.js.html | 6 +- docs/Loader.js.html | 6 +- docs/LoaderParser.js.html | 6 +- docs/MSPointer.js.html | 6 +- docs/Math.js.html | 6 +- docs/Mouse.js.html | 82 +- docs/Net.js.html | 6 +- docs/Particles.js.html | 6 +- docs/Phaser.Animation.html | 6 +- docs/Phaser.AnimationManager.html | 164 +- docs/Phaser.AnimationParser.html | 6 +- docs/Phaser.BitmapText.html | 6 +- docs/Phaser.Button.html | 135 +- docs/Phaser.Cache.html | 6 +- docs/Phaser.Camera.html | 6 +- docs/Phaser.Canvas.html | 6 +- docs/Phaser.Circle.html | 6 +- docs/Phaser.Color.html | 6 +- docs/Phaser.Device.html | 6 +- docs/Phaser.Easing.Back.html | 6 +- docs/Phaser.Easing.Bounce.html | 6 +- docs/Phaser.Easing.Circular.html | 6 +- docs/Phaser.Easing.Cubic.html | 6 +- docs/Phaser.Easing.Elastic.html | 6 +- docs/Phaser.Easing.Exponential.html | 6 +- docs/Phaser.Easing.Linear.html | 6 +- docs/Phaser.Easing.Quadratic.html | 6 +- docs/Phaser.Easing.Quartic.html | 6 +- docs/Phaser.Easing.Quintic.html | 6 +- docs/Phaser.Easing.Sinusoidal.html | 6 +- docs/Phaser.Easing.html | 6 +- docs/Phaser.Events.html | 6 +- docs/Phaser.Frame.html | 6 +- docs/Phaser.FrameData.html | 6 +- docs/Phaser.Game.html | 10 +- docs/Phaser.GameObjectFactory.html | 6 +- docs/Phaser.Graphics.html | 6 +- docs/Phaser.Group.html | 998 ++++- docs/Phaser.Input.html | 6 +- docs/Phaser.InputHandler.html | 125 +- docs/Phaser.Key.html | 6 +- docs/Phaser.Keyboard.html | 6 +- docs/Phaser.LinkedList.html | 6 +- docs/Phaser.Loader.html | 6 +- docs/Phaser.LoaderParser.html | 6 +- docs/Phaser.MSPointer.html | 6 +- docs/Phaser.Math.html | 6 +- docs/Phaser.Mouse.html | 320 +- docs/Phaser.Net.html | 6 +- docs/Phaser.Particles.Arcade.Emitter.html | 705 +++- docs/Phaser.Particles.html | 6 +- docs/Phaser.Physics.Arcade.Body.html | 6 +- docs/Phaser.Physics.Arcade.html | 6 +- docs/Phaser.Physics.html | 6 +- docs/Phaser.Plugin.html | 125 +- docs/Phaser.PluginManager.html | 89 +- docs/Phaser.Point.html | 6 +- docs/Phaser.Pointer.html | 24 +- docs/Phaser.Polygon.html | 712 ++++ docs/Phaser.QuadTree.html | 6 +- docs/Phaser.RandomDataGenerator.html | 6 +- docs/Phaser.Rectangle.html | 6 +- docs/Phaser.RenderTexture.html | 6 +- docs/Phaser.RequestAnimationFrame.html | 18 +- docs/Phaser.Signal.html | 6 +- docs/Phaser.Sound.html | 6 +- docs/Phaser.SoundManager.html | 6 +- docs/Phaser.Sprite.html | 6 +- docs/Phaser.Stage.html | 20 +- docs/Phaser.StageScaleMode.html | 412 +- docs/Phaser.State.html | 6 +- docs/Phaser.StateManager.html | 6 +- docs/Phaser.Text.html | 6 +- docs/Phaser.TileSprite.html | 6 +- docs/Phaser.Time.html | 6 +- docs/Phaser.Touch.html | 6 +- docs/Phaser.Tween.html | 6 +- docs/Phaser.TweenManager.html | 6 +- docs/Phaser.Utils.Debug.html | 6 +- docs/Phaser.Utils.html | 159 +- docs/Phaser.World.html | 108 +- docs/Phaser.html | 9 +- docs/Phaser.js.html | 9 +- docs/Plugin.js.html | 12 +- docs/PluginManager.js.html | 36 +- docs/Point.js.html | 6 +- docs/Pointer.js.html | 7 +- docs/Polygon.js.html | 474 +++ docs/QuadTree.js.html | 6 +- docs/RandomDataGenerator.js.html | 6 +- docs/Rectangle.js.html | 6 +- docs/RenderTexture.js.html | 6 +- docs/RequestAnimationFrame.js.html | 19 +- docs/Signal.js.html | 6 +- docs/SignalBinding.html | 6 +- docs/SignalBinding.js.html | 6 +- docs/Sound.js.html | 6 +- docs/SoundManager.js.html | 6 +- docs/Sprite.js.html | 6 +- docs/Stage.js.html | 7 +- docs/StageScaleMode.js.html | 168 +- docs/State.js.html | 6 +- docs/StateManager.js.html | 6 +- docs/Text.js.html | 6 +- docs/TileSprite.js.html | 6 +- docs/Time.js.html | 6 +- docs/Touch.js.html | 6 +- docs/Tween.js.html | 6 +- docs/TweenManager.js.html | 6 +- docs/Utils.js.html | 16 +- docs/World.js.html | 22 +- docs/classes.list.html | 9 +- docs/global.html | 8 +- docs/index.html | 6 +- docs/namespaces.list.html | 9 +- examples/_site/examples.json | 4 + examples/assets/maps/burd.json | 65 + examples/assets/maps/burd.tmx | 19 + examples/assets/maps/ground_1x1.png | Bin 0 -> 2229 bytes examples/assets/maps/walls_1x2.png | Bin 0 -> 2488 bytes examples/assets/pics/forgotten_worlds.png | Bin 0 -> 17077 bytes examples/groups/depth sort.js | 79 + examples/wip/sort.js | 69 +- src/Phaser.js | 1 + src/core/Group.js | 18 +- src/geom/Polygon.js | 22 +- 157 files changed, 9101 insertions(+), 1642 deletions(-) create mode 100644 docs/Phaser.Polygon.html create mode 100644 docs/Polygon.js.html create mode 100644 examples/assets/maps/burd.json create mode 100644 examples/assets/maps/burd.tmx create mode 100644 examples/assets/maps/ground_1x1.png create mode 100644 examples/assets/maps/walls_1x2.png create mode 100644 examples/assets/pics/forgotten_worlds.png create mode 100644 examples/groups/depth sort.js diff --git a/README.md b/README.md index 46447a13..a6b88205 100644 --- a/README.md +++ b/README.md @@ -47,10 +47,11 @@ Version 1.1.3 - in build * New: World.visible boolean added, toggles rendering of the world on/off entirely. * New: Polygon class & drawPolygon method added to Graphics (thanks rjimenezda) * New: Added Group.iterate, a powerful way to count or return child that match a certain criteria. Refactored Group to use iterate, lots of repeated code cut. -* New: Added Group.sort, can sort the Group based on any given numeric property (x, y, health), finally you can do depth-sorting :) +* 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. * Fixed: Mouse.stop now uses the true useCapture, which means the event listeners stop listening correctly (thanks beeglebug) * Fixed: Input Keyboard example fix (thanks Atrodilla) * Fixed: BitmapText.destroy now checks if it has a canvas before calling parentNode on it. +* Fixed: Group.swap had a hellish to find bug that only manifested when B-A upward swaps occured. Hours of debugging later = bug crushed. * 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. * Updated: Button now goes back to over state when setFrames used in action (thanks beeglebug) diff --git a/build/phaser.js b/build/phaser.js index 1113e7ac..0c44531d 100644 --- a/build/phaser.js +++ b/build/phaser.js @@ -18,7 +18,7 @@ * * Phaser - http://www.phaser.io * -* v1.1.2 - Built at: Fri Nov 01 2013 18:12:54 +* v1.1.3 - Built at: Thu Nov 07 2013 06:09:12 * * By Richard Davey http://www.photonstorm.com @photonstorm * @@ -57,8 +57,8 @@ var PIXI = PIXI || {}; */ var Phaser = Phaser || { - VERSION: '1.1.2', - DEV_VERSION: '1.1.2', + VERSION: '1.1.3', + DEV_VERSION: '1.1.3', GAMES: [], AUTO: 0, CANVAS: 1, @@ -76,6 +76,7 @@ var Phaser = Phaser || { TILEMAP: 9, TILEMAPLAYER: 10, EMITTER: 11, + POLYGON: 12, NONE: 0, LEFT: 1, @@ -102,6 +103,12 @@ PIXI.InteractionManager = function (dummy) { */ Phaser.Utils = { + /** + * A standard Fisher-Yates Array shuffle implementation. + * @method Phaser.Utils.shuffle + * @param {array} array - The array to shuffle. + * @return {array} The shuffled array. + */ shuffle: function (array) { for (var i = array.length - 1; i > 0; i--) @@ -118,14 +125,14 @@ Phaser.Utils = { /** * Javascript string pad http://www.webtoolkit.info/. - * pad = the string to pad it out with (defaults to a space)
+ * pad = the string to pad it out with (defaults to a space) * dir = 1 (left), 2 (right), 3 (both) * @method Phaser.Utils.pad * @param {string} str - The target string. * @param {number} len - Description. * @param {number} pad - the string to pad it out with (defaults to a space). * @param {number} [dir=3] the direction dir = 1 (left), 2 (right), 3 (both). - * @return {string} + * @return {string} The padded string */ pad: function (str, len, pad, dir) { @@ -347,7 +354,7 @@ PIXI.mat3.create = function() matrix[6] = 0; matrix[7] = 0; matrix[8] = 1; - + return matrix; } @@ -363,7 +370,7 @@ PIXI.mat3.identity = function(matrix) matrix[6] = 0; matrix[7] = 0; matrix[8] = 1; - + return matrix; } @@ -390,35 +397,35 @@ PIXI.mat4.create = function() matrix[13] = 0; matrix[14] = 0; matrix[15] = 1; - + return matrix; } -PIXI.mat3.multiply = function (mat, mat2, dest) +PIXI.mat3.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } - + // Cache the matrix values (makes for huge speed increases!) var a00 = mat[0], a01 = mat[1], a02 = mat[2], a10 = mat[3], a11 = mat[4], a12 = mat[5], a20 = mat[6], a21 = mat[7], a22 = mat[8], - + b00 = mat2[0], b01 = mat2[1], b02 = mat2[2], b10 = mat2[3], b11 = mat2[4], b12 = mat2[5], b20 = mat2[6], b21 = mat2[7], b22 = mat2[8]; - + dest[0] = b00 * a00 + b01 * a10 + b02 * a20; dest[1] = b00 * a01 + b01 * a11 + b02 * a21; dest[2] = b00 * a02 + b01 * a12 + b02 * a22; - + dest[3] = b10 * a00 + b11 * a10 + b12 * a20; dest[4] = b10 * a01 + b11 * a11 + b12 * a21; dest[5] = b10 * a02 + b11 * a12 + b12 * a22; - + dest[6] = b20 * a00 + b21 * a10 + b22 * a20; dest[7] = b20 * a01 + b21 * a11 + b22 * a21; dest[8] = b20 * a02 + b21 * a12 + b22 * a22; - + return dest; } @@ -435,11 +442,11 @@ PIXI.mat3.clone = function(mat) matrix[6] = mat[6]; matrix[7] = mat[7]; matrix[8] = mat[8]; - + return matrix; } -PIXI.mat3.transpose = function (mat, dest) +PIXI.mat3.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values if (!dest || mat === dest) { @@ -467,30 +474,30 @@ PIXI.mat3.transpose = function (mat, dest) return dest; } -PIXI.mat3.toMat4 = function (mat, dest) +PIXI.mat3.toMat4 = function (mat, dest) { if (!dest) { dest = PIXI.mat4.create(); } - + dest[15] = 1; dest[14] = 0; dest[13] = 0; dest[12] = 0; - + dest[11] = 0; dest[10] = mat[8]; dest[9] = mat[7]; dest[8] = mat[6]; - + dest[7] = 0; dest[6] = mat[5]; dest[5] = mat[4]; dest[4] = mat[3]; - + dest[3] = 0; dest[2] = mat[2]; dest[1] = mat[1]; dest[0] = mat[0]; - + return dest; } @@ -518,19 +525,19 @@ PIXI.mat4.create = function() matrix[13] = 0; matrix[14] = 0; matrix[15] = 1; - + return matrix; } -PIXI.mat4.transpose = function (mat, dest) +PIXI.mat4.transpose = function (mat, dest) { // If we are transposing ourselves we can skip a few steps but have to cache some values - if (!dest || mat === dest) + if (!dest || mat === dest) { var a01 = mat[1], a02 = mat[2], a03 = mat[3], a12 = mat[6], a13 = mat[7], a23 = mat[11]; - + mat[1] = mat[4]; mat[2] = mat[8]; mat[3] = mat[12]; @@ -545,7 +552,7 @@ PIXI.mat4.transpose = function (mat, dest) mat[14] = a23; return mat; } - + dest[0] = mat[0]; dest[1] = mat[4]; dest[2] = mat[8]; @@ -565,18 +572,18 @@ PIXI.mat4.transpose = function (mat, dest) return dest; } -PIXI.mat4.multiply = function (mat, mat2, dest) +PIXI.mat4.multiply = function (mat, mat2, dest) { if (!dest) { dest = mat; } - + // Cache the matrix values (makes for huge speed increases!) var a00 = mat[ 0], a01 = mat[ 1], a02 = mat[ 2], a03 = mat[3]; var a10 = mat[ 4], a11 = mat[ 5], a12 = mat[ 6], a13 = mat[7]; var a20 = mat[ 8], a21 = mat[ 9], a22 = mat[10], a23 = mat[11]; var a30 = mat[12], a31 = mat[13], a32 = mat[14], a33 = mat[15]; - + // Cache only the current line of the second matrix - var b0 = mat2[0], b1 = mat2[1], b2 = mat2[2], b3 = mat2[3]; + var b0 = mat2[0], b1 = mat2[1], b2 = mat2[2], b3 = mat2[3]; dest[0] = b0*a00 + b1*a10 + b2*a20 + b3*a30; dest[1] = b0*a01 + b1*a11 + b2*a21 + b3*a31; dest[2] = b0*a02 + b1*a12 + b2*a22 + b3*a32; @@ -620,19 +627,19 @@ PIXI.mat4.multiply = function (mat, mat2, dest) * The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis. * * @class Point - * @constructor - * @param x {number} position of the point - * @param y {number} position of the point + * @constructor + * @param x {Number} position of the point + * @param y {Number} position of the point */ PIXI.Point = function(x, y) { /** - * @property x + * @property x * @type Number * @default 0 */ this.x = x || 0; - + /** * @property y * @type Number @@ -664,11 +671,11 @@ PIXI.Point.prototype.constructor = PIXI.Point; * the Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its width and its height. * * @class Rectangle - * @constructor - * @param x {number} The X coord of the upper-left corner of the rectangle - * @param y {number} The Y coord of the upper-left corner of the rectangle - * @param width {number} The overall wisth of this rectangle - * @param height {number} The overall height of this rectangle + * @constructor + * @param x {Number} The X coord of the upper-left corner of the rectangle + * @param y {Number} The Y coord of the upper-left corner of the rectangle + * @param width {Number} The overall width of this rectangle + * @param height {Number} The overall height of this rectangle */ PIXI.Rectangle = function(x, y, width, height) { @@ -678,21 +685,21 @@ PIXI.Rectangle = function(x, y, width, height) * @default 0 */ this.x = x || 0; - + /** * @property y * @type Number * @default 0 */ this.y = y || 0; - + /** * @property width * @type Number * @default 0 */ this.width = width || 0; - + /** * @property height * @type Number @@ -716,8 +723,8 @@ PIXI.Rectangle.prototype.clone = function() * Checks if the x, and y coords passed to this function are contained within this Rectangle * * @method contains - * @param x {number} The X coord of the point to test - * @param y {number} The Y coord of the point to test + * @param x {Number} The X coord of the point to test + * @param y {Number} The Y coord of the point to test * @return {Boolean} if the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) @@ -729,7 +736,7 @@ PIXI.Rectangle.prototype.contains = function(x, y) if(x >= x1 && x <= x1 + this.width) { var y1 = this.y; - + if(y >= y1 && y <= y1 + this.height) { return true; @@ -743,6 +750,84 @@ PIXI.Rectangle.prototype.contains = function(x, y) PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; +/** + * @author Adrien Brault + */ + +/** + * @class Polygon + * @constructor + * @param points* {Array|Array|Point...|Number...} This can be an array of Points that form the polygon, + * a flat array of numbers that will be interpreted as [x,y, x,y, ...], or the arguments passed can be + * all the points of the polygon e.g. `new PIXI.Polygon(new PIXI.Point(), new PIXI.Point(), ...)`, or the + * arguments passed can be flat x,y values e.g. `new PIXI.Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are + * Numbers. + */ +PIXI.Polygon = function(points) +{ + //if points isn't an array, use arguments as the array + if(!(points instanceof Array)) + points = Array.prototype.slice.call(arguments); + + //if this is a flat array of numbers, convert it to points + if(typeof points[0] === 'number') { + var p = []; + for(var i = 0, il = points.length; i < il; i+=2) { + p.push( + new PIXI.Point(points[i], points[i + 1]) + ); + } + + points = p; + } + + this.points = points; +} + +/** + * Creates a clone of this polygon + * + * @method clone + * @return {Polygon} a copy of the polygon + */ +PIXI.Polygon.prototype.clone = function() +{ + var points = []; + for (var i=0; i y) != (yj > y)) && (x < (xj - xi) * (y - yi) / (yj - yi) + xi); + + if(intersect) inside = !inside; + } + + return inside; +} + +// constructor +PIXI.Polygon.prototype.constructor = PIXI.Polygon; + /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -757,7 +842,6 @@ PIXI.DisplayObject = function() { this.last = this; this.first = this; - /** * The coordinate of the object relative to the local coordinates of the parent. * @@ -910,6 +994,9 @@ PIXI.DisplayObject = function() this._sr = 0; this._cr = 1; + + this.filterArea = new PIXI.Rectangle(0,0,1,1); + /* * MOUSE Callbacks */ @@ -1034,16 +1121,71 @@ Object.defineProperty(PIXI.DisplayObject.prototype, 'mask', { }, set: function(value) { - this._mask = value; - + if(value) { - this.addFilter(value) + if(this._mask) + { + value.start = this._mask.start; + value.end = this._mask.end; + } + else + { + this.addFilter(value); + value.renderable = false; + } } else { - this.removeFilter(); + this.removeFilter(this._mask); + this._mask.renderable = true; } + + this._mask = value; + } +}); + +/** + * Sets the filters for the displayObject. + * * IMPORTANT: This is a webGL only feature and will be ignored by the canvas renderer. + * To remove filters simply set this property to 'null' + * @property filters + * @type Array An array of filters + */ +Object.defineProperty(PIXI.DisplayObject.prototype, 'filters', { + get: function() { + return this._filters; + }, + set: function(value) { + + if(value) + { + if(this._filters)this.removeFilter(this._filters); + this.addFilter(value); + + // now put all the passes in one place.. + var passes = []; + for (var i = 0; i < value.length; i++) + { + var filterPasses = value[i].passes; + for (var j = 0; j < filterPasses.length; j++) + { + passes.push(filterPasses[j]); + }; + }; + + value.start.filterPasses = passes; + } + else + { + if(this._filters)this.removeFilter(this._filters); + } + + this._filters = value; + + + + } }); @@ -1054,23 +1196,31 @@ Object.defineProperty(PIXI.DisplayObject.prototype, 'mask', { * @param mask {Graphics} the graphics object to use as a filter * @private */ -PIXI.DisplayObject.prototype.addFilter = function(mask) +PIXI.DisplayObject.prototype.addFilter = function(data) { - if(this.filter)return; - this.filter = true; + //if(this.filter)return; + //this.filter = true; +// data[0].target = this; + // insert a filter block.. + // TODO Onject pool thease bad boys.. var start = new PIXI.FilterBlock(); var end = new PIXI.FilterBlock(); - start.mask = mask; - end.mask = mask; + data.start = start; + data.end = end; + + start.data = data; + end.data = data; start.first = start.last = this; end.first = end.last = this; start.open = true; + start.target = this; + /* * insert start */ @@ -1142,8 +1292,6 @@ PIXI.DisplayObject.prototype.addFilter = function(mask) this.__renderGroup.addFilterBlocks(start, end); } - mask.renderable = false; - } /* @@ -1152,13 +1300,14 @@ PIXI.DisplayObject.prototype.addFilter = function(mask) * @method removeFilter * @private */ -PIXI.DisplayObject.prototype.removeFilter = function() +PIXI.DisplayObject.prototype.removeFilter = function(data) { - if(!this.filter)return; - this.filter = false; - + //if(!this.filter)return; + //this.filter = false; + console.log("YUOIO") // modify the list.. - var startBlock = this.first; + var startBlock = data.start; + var nextObject = startBlock._iNext; var previousObject = startBlock._iPrev; @@ -1168,9 +1317,8 @@ PIXI.DisplayObject.prototype.removeFilter = function() this.first = startBlock._iNext; - // remove the end filter - var lastBlock = this.last; + var lastBlock = data.end; var nextObject = lastBlock._iNext; var previousObject = lastBlock._iPrev; @@ -1189,9 +1337,6 @@ PIXI.DisplayObject.prototype.removeFilter = function() if(!updateLast)break; } - var mask = startBlock.mask - mask.renderable = true; - // if webGL... if(this.__renderGroup) { @@ -1287,18 +1432,6 @@ PIXI.DisplayObjectContainer = function() PIXI.DisplayObjectContainer.prototype = Object.create( PIXI.DisplayObject.prototype ); PIXI.DisplayObjectContainer.prototype.constructor = PIXI.DisplayObjectContainer; -//TODO make visible a getter setter -/* -Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'visible', { - get: function() { - return this._visible; - }, - set: function(value) { - this._visible = value; - - } -});*/ - /** * Adds a child to the container. * @@ -1342,7 +1475,7 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child) var previousObject; // this could be wrong if there is a filter?? - if(this.filter) + if(this._filters || this._mask) { previousObject = this.last._iPrev; } @@ -1392,7 +1525,7 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child) * * @method addChildAt * @param child {DisplayObject} The child to add - * @param index {number} The index to place the child in + * @param index {Number} The index to place the child in */ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) { @@ -1527,7 +1660,7 @@ PIXI.DisplayObjectContainer.prototype.swapChildren = function(child, child2) * Returns the Child at the specified index * * @method getChildAt - * @param index {number} The index to get the child from + * @param index {Number} The index to get the child from */ PIXI.DisplayObjectContainer.prototype.getChildAt = function(index) { @@ -1624,7 +1757,6 @@ PIXI.DisplayObjectContainer.prototype.updateTransform = function() this.children[i].updateTransform(); } } - /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -1779,7 +1911,7 @@ PIXI.Sprite.prototype.setTexture = function(texture) PIXI.Sprite.prototype.onTextureUpdate = function(event) { //this.texture.removeEventListener( 'update', this.onTextureUpdateBind ); - + // so if _width is 0 then width was not set.. if(this._width)this.scale.x = this._width / this.texture.frame.width; if(this._height)this.scale.y = this._height / this.texture.frame.height; @@ -1822,7 +1954,6 @@ PIXI.Sprite.fromImage = function(imageId) return new PIXI.Sprite(texture); } - /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -1833,11 +1964,10 @@ PIXI.Sprite.fromImage = function(imageId) * @class Stage * @extends DisplayObjectContainer * @constructor - * @param backgroundColor {number} the background color of the stage, easiest way to pass this in is in hex format + * @param backgroundColor {Number} the background color of the stage, easiest way to pass this in is in hex format * like: 0xFFFFFF for white - * @param interactive {Boolean} enable / disable interaction (default is false) */ -PIXI.Stage = function(backgroundColor, interactive) +PIXI.Stage = function(backgroundColor) { PIXI.DisplayObjectContainer.call( this ); @@ -1857,7 +1987,7 @@ PIXI.Stage = function(backgroundColor, interactive) * @property interactive * @type Boolean */ - this.interactive = interactive; + this.interactive = true; /** * The interaction manage for this stage, manages all interactive activity on the stage @@ -1893,6 +2023,18 @@ PIXI.Stage = function(backgroundColor, interactive) PIXI.Stage.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.Stage.prototype.constructor = PIXI.Stage; +/** + * Sets another DOM element which can receive mouse/touch interactions instead of the default Canvas element. + * This is useful for when you have other DOM elements ontop of the Canvas element. + * + * @method setInteractionDelegate + * @param domElement {DOMElement} This new domElement which will receive mouse/touch events + */ +PIXI.Stage.prototype.setInteractionDelegate = function(domElement) +{ + this.interactionManager.setTargetDomElement( domElement ); +} + /* * Updates the object transform for rendering * @@ -1924,7 +2066,7 @@ PIXI.Stage.prototype.updateTransform = function() * Sets the background color for the stage * * @method setBackgroundColor - * @param backgroundColor {number} the color of the background, easiest way to pass this in is in hex format + * @param backgroundColor {Number} the color of the background, easiest way to pass this in is in hex format * like: 0xFFFFFF for white */ PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor) @@ -1955,7 +2097,7 @@ PIXI.Stage.prototype.getMousePosition = function() /** * This object is one that will allow you to specify custom rendering functions based on render type * - * @class CustomRenderable + * @class CustomRenderable * @extends DisplayObject * @constructor */ @@ -1963,6 +2105,7 @@ PIXI.CustomRenderable = function() { PIXI.DisplayObject.call( this ); + this.renderable = true; } // constructor @@ -2013,20 +2156,20 @@ PIXI.Strip = function(texture, width, height) PIXI.DisplayObjectContainer.call( this ); this.texture = texture; this.blendMode = PIXI.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(error) @@ -2034,18 +2177,18 @@ PIXI.Strip = function(texture, width, height) 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.uvs = new Float32Array() this.verticies = new Float32Array() @@ -2054,7 +2197,7 @@ PIXI.Strip = function(texture, width, height) */ this.width = width; this.height = height; - + // load the texture! if(texture.baseTexture.hasLoaded) { @@ -2067,7 +2210,7 @@ PIXI.Strip = function(texture, width, height) this.onTextureUpdateBind = this.onTextureUpdate.bind(this); this.texture.addEventListener( 'update', this.onTextureUpdateBind ); } - + this.renderable = true; } @@ -2079,8 +2222,8 @@ PIXI.Strip.prototype.setTexture = function(texture) { //TODO SET THE TEXTURES //TODO VISIBILITY - - // stop current texture + + // stop current texture this.texture = texture; this.width = texture.frame.width; this.height = texture.frame.height; @@ -2103,7 +2246,7 @@ PIXI.Rope = function(texture, points) { PIXI.Strip.call( this, texture ); this.points = points; - + try { this.verticies = new Float32Array( points.length * 4); @@ -2114,12 +2257,12 @@ PIXI.Rope = function(texture, points) catch(error) { this.verticies = verticies - + this.uvs = uvs this.colors = colors this.indices = indices } - + this.refresh(); } @@ -2132,99 +2275,99 @@ PIXI.Rope.prototype.refresh = function() { var points = this.points; if(points.length < 1)return; - + var uvs = this.uvs var indices = this.indices; var colors = this.colors; - + var lastPoint = points[0]; var nextPoint; var perp = {x:0, y:0}; var point = points[0]; - + this.count-=0.2; - - + + uvs[0] = 0 uvs[1] = 1 uvs[2] = 0 uvs[3] = 1 - + colors[0] = 1; colors[1] = 1; - + indices[0] = 0; indices[1] = 1; - + var total = points.length; - - for (var i = 1; i < total; i++) + + for (var i = 1; i < total; i++) { - + var point = points[i]; var index = i * 4; // time to do some smart drawing! var amount = i/(total-1) - + if(i%2) { uvs[index] = amount; uvs[index+1] = 0; - + uvs[index+2] = amount uvs[index+3] = 1 - + } else { uvs[index] = amount uvs[index+1] = 0 - + uvs[index+2] = amount uvs[index+3] = 1 } - + index = i * 2; colors[index] = 1; colors[index+1] = 1; - + index = i * 2; indices[index] = index; indices[index + 1] = index + 1; - + lastPoint = point; } } PIXI.Rope.prototype.updateTransform = function() { - + var points = this.points; if(points.length < 1)return; - - var verticies = this.verticies - + + var verticies = this.verticies + var lastPoint = points[0]; var nextPoint; var perp = {x:0, y:0}; var point = points[0]; - + this.count-=0.2; - - verticies[0] = point.x + perp.x + + verticies[0] = point.x + perp.x verticies[1] = point.y + perp.y //+ 200 - verticies[2] = point.x - perp.x + verticies[2] = point.x - perp.x verticies[3] = point.y - perp.y//+200 // time to do some smart drawing! - + var total = points.length; - - for (var i = 1; i < total; i++) + + for (var i = 1; i < total; i++) { - + var point = points[i]; var index = i * 4; - + if(i < points.length-1) { nextPoint = points[i+1]; @@ -2233,35 +2376,35 @@ PIXI.Rope.prototype.updateTransform = function() { nextPoint = point } - + perp.y = -(nextPoint.x - lastPoint.x); perp.x = nextPoint.y - lastPoint.y; - + var ratio = (1 - (i / (total-1))) * 10; if(ratio > 1)ratio = 1; - + var perpLength = Math.sqrt(perp.x * perp.x + perp.y * perp.y); var num = this.texture.height/2//(20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; perp.x /= perpLength; perp.y /= perpLength; - + perp.x *= num; perp.y *= num; - - verticies[index] = point.x + perp.x + + verticies[index] = point.x + perp.x verticies[index+1] = point.y + perp.y - verticies[index+2] = point.x - perp.x + verticies[index+2] = point.x - perp.x verticies[index+3] = point.y - perp.y lastPoint = point; } - + PIXI.DisplayObjectContainer.prototype.updateTransform.call( this ); } PIXI.Rope.prototype.setTexture = function(texture) { - // stop current texture + // stop current texture this.texture = texture; this.updateFrame = true; } @@ -2281,8 +2424,8 @@ PIXI.Rope.prototype.setTexture = function(texture) * @extends DisplayObjectContainer * @constructor * @param texture {Texture} the texture of the tiling sprite - * @param width {number} the width of the tiling sprite - * @param height {number} the height of the tiling sprite + * @param width {Number} the width of the tiling sprite + * @param height {Number} the height of the tiling sprite */ PIXI.TilingSprite = function(texture, width, height) { @@ -2317,7 +2460,7 @@ PIXI.TilingSprite = function(texture, width, height) * * @property tileScale * @type Point - */ + */ this.tileScale = new PIXI.Point(1,1); /** @@ -2325,11 +2468,11 @@ PIXI.TilingSprite = function(texture, width, height) * * @property tilePosition * @type Point - */ + */ this.tilePosition = new PIXI.Point(0,0); this.renderable = true; - + this.blendMode = PIXI.blendModes.NORMAL } @@ -2347,8 +2490,8 @@ PIXI.TilingSprite.prototype.setTexture = function(texture) { //TODO SET THE TEXTURES //TODO VISIBILITY - - // stop current texture + + // stop current texture this.texture = texture; this.updateFrame = true; } @@ -2371,46 +2514,1042 @@ PIXI.TilingSprite.prototype.onTextureUpdate = function(event) */ - -PIXI.FilterBlock = function(mask) +/** + * This is the base class for creating a pixi.js filter. Currently only webGL supports filters. + * If you want to make a custom filter this should be your base class. + * @class AbstractFilter + * @constructor + * @param fragmentSrc + * @param unifroms + */ +PIXI.AbstractFilter = function(fragmentSrc, unifroms) +{ + /** + * An array of passes - some filters contain a few steps this array simply stores the steps in a liniear fashion. + * For example the blur filter has two passes blurX and blurY. + * @property passes + * @type Array an array of filter objects + * @private + */ + this.passes = [this]; + + + this.dirty = true; + this.padding = 0; + + /** + @property uniforms + @private + */ + this.uniforms = unifroms || {}; + + this.fragmentSrc = fragmentSrc || []; +} + + +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + + +/** + * + * The BlurFilter applies a Gaussian blur to an object. + * The strength of the blur can be set for x- and y-axis separately (always relative to the stage). + * + * @class BlurFilter + * @contructor + */ +PIXI.BlurFilter = function() +{ + + this.blurXFilter = new PIXI.BlurXFilter(); + this.blurYFilter = new PIXI.BlurYFilter(); + + this.passes =[this.blurXFilter, this.blurYFilter]; + +} + +/** + * Sets the strength of both the blurX and blurY properties simultaneously + * + * @property blur + * @type Number the strength of the blur + * @default 2 + */ +Object.defineProperty(PIXI.BlurFilter.prototype, 'blur', { + get: function() { + return this.blurXFilter.blur; + }, + set: function(value) { + this.blurXFilter.blur = this.blurYFilter.blur = value; + } +}); + +/** + * Sets the strength of the blurX property simultaneously + * + * @property blurX + * @type Number the strength of the blurX + * @default 2 + */ +Object.defineProperty(PIXI.BlurFilter.prototype, 'blurX', { + get: function() { + return this.blurXFilter.blur; + }, + set: function(value) { + this.blurXFilter.blur = value; + } +}); + +/** + * Sets the strength of the blurX property simultaneously + * + * @property blurY + * @type Number the strength of the blurY + * @default 2 + */ +Object.defineProperty(PIXI.BlurFilter.prototype, 'blurY', { + get: function() { + return this.blurYFilter.blur; + }, + set: function(value) { + this.blurYFilter.blur = value; + } +}); + +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + + + +PIXI.BlurXFilter = function() +{ + PIXI.AbstractFilter.call( this ); + + this.passes = [this]; + + // set the uniforms + 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;", + + "}" + ]; +} + +PIXI.BlurXFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); +PIXI.BlurXFilter.prototype.constructor = PIXI.BlurXFilter; + + +Object.defineProperty(PIXI.BlurXFilter.prototype, 'blur', { + get: function() { + return this.uniforms.blur.value / (1/7000); + }, + set: function(value) { + + this.dirty = true; + this.uniforms.blur.value = (1/7000) * value; + } +}); + +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + + + +PIXI.BlurYFilter = function() +{ + PIXI.AbstractFilter.call( this ); + + this.passes = [this]; + + // set the uniforms + 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;", + + "}" + ]; +} + +PIXI.BlurYFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); +PIXI.BlurYFilter.prototype.constructor = PIXI.BlurYFilter; + +Object.defineProperty(PIXI.BlurYFilter.prototype, 'blur', { + get: function() { + return this.uniforms.blur.value / (1/7000); + }, + set: function(value) { + //this.padding = value; + this.uniforms.blur.value = (1/7000) * value; + } +}); + +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * + * The ColorMatrixFilter class lets you apply a 4x4 matrix transformation on the RGBA + * color and alpha values of every pixel on your displayObject to produce a result + * with a new set of RGBA color and alpha values. Its pretty powerful! + * @class ColorMatrixFilter + * @contructor + */ +PIXI.ColorMatrixFilter = function() +{ + PIXI.AbstractFilter.call( this ); + + this.passes = [this]; + + // set the uniforms + 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;", + "}" + ]; + +} + +PIXI.ColorMatrixFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); +PIXI.ColorMatrixFilter.prototype.constructor = PIXI.ColorMatrixFilter; + +/** + * Sets the matrix of the color matrix filter + * + * @property matrix + * @type Array and array of 26 numbers + * @default [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1] + */ +Object.defineProperty(PIXI.ColorMatrixFilter.prototype, 'matrix', { + get: function() { + return this.uniforms.matrix.value; + }, + set: function(value) { + this.uniforms.matrix.value = value; + } +}); +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + + + +PIXI.CrossHatchFilter = function() +{ + PIXI.AbstractFilter.call( this ); + + this.passes = [this]; + + // set the uniforms + 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);", + " }", + " }", + "}" + ]; +} + +PIXI.CrossHatchFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); +PIXI.CrossHatchFilter.prototype.constructor = PIXI.BlurYFilter; + +Object.defineProperty(PIXI.CrossHatchFilter.prototype, 'blur', { + get: function() { + return this.uniforms.blur.value / (1/7000); + }, + set: function(value) { + //this.padding = value; + this.uniforms.blur.value = (1/7000) * value; + } +}); + +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + + +/** + * + * The DisplacementFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. + * You can use this filter to apply all manor of crazy warping effects + * Currently the r property of the texture is used offset the x and the g propery of the texture is used to offset the y. + * @class DisplacementFilter + * @contructor + * @param texture {Texture} The texture used for the displacemtent map * must be power of 2 texture at the moment + */ +PIXI.DisplacementFilter = function(texture) +{ + PIXI.AbstractFilter.call( this ); + + this.passes = [this]; + texture.baseTexture._powerOf2 = true; + + // set the uniforms + //console.log() + this.uniforms = { + displacementMap: {type: 'sampler2D', value:texture}, + 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]} + }; + + + if(texture.baseTexture.hasLoaded) + { + this.uniforms.mapDimensions.value.x = texture.width; + this.uniforms.mapDimensions.value.y = texture.height; + } + else + { + this.boundLoadedFunction = this.onTextureLoaded.bind(this); + + texture.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;",// = vec2(256.0, 256.0);", + // "const vec2 textureDimensions = vec2(750.0, 750.0);", + + "void main(void) {", + "vec2 mapCords = vTextureCoord.xy;", +// "mapCords -= ;", + "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 = texture2D(displacementMap, cord);", + "gl_FragColor = gl_FragColor * vColor;", + + "}" + ]; + +} + +PIXI.DisplacementFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); +PIXI.DisplacementFilter.prototype.constructor = PIXI.DisplacementFilter; + +PIXI.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) + +} + +/** + * The texture used for the displacemtent map * must be power of 2 texture at the moment + * + * @property map + * @type Texture + */ +Object.defineProperty(PIXI.DisplacementFilter.prototype, 'map', { + get: function() { + return this.uniforms.displacementMap.value; + }, + set: function(value) { + this.uniforms.displacementMap.value = value; + } +}); + +/** + * The multiplier used to scale the displacement result from the map calculation. + * + * @property scale + * @type Point + */ +Object.defineProperty(PIXI.DisplacementFilter.prototype, 'scale', { + get: function() { + return this.uniforms.scale.value; + }, + set: function(value) { + this.uniforms.scale.value = value; + } +}); + +/** + * The offset used to move the displacement map. + * + * @property offset + * @type Point + */ +Object.defineProperty(PIXI.DisplacementFilter.prototype, 'offset', { + get: function() { + return this.uniforms.offset.value; + }, + set: function(value) { + this.uniforms.offset.value = value; + } +}); +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js + */ + +/** + * + * This filter applies a pixlate effect making display objects appear "blocky" + * @class PixelateFilter + * @contructor + */ +PIXI.DotScreenFilter = function() +{ + PIXI.AbstractFilter.call( this ); + + this.passes = [this]; + + // set the uniforms + 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);", + "}", + ]; +} + +PIXI.DotScreenFilter.prototype = Object.create( PIXI.DotScreenFilter.prototype ); +PIXI.DotScreenFilter.prototype.constructor = PIXI.DotScreenFilter; + +/** + * + * This describes the the scale + * @property scale + * @type Number + */ +Object.defineProperty(PIXI.DotScreenFilter.prototype, 'scale', { + get: function() { + return this.uniforms.scale.value; + }, + set: function(value) { + this.dirty = true; + this.uniforms.scale.value = value; + } +}); + +/** + * + * This radius describes angle + * @property angle + * @type Number + */ +Object.defineProperty(PIXI.DotScreenFilter.prototype, 'angle', { + get: function() { + return this.uniforms.angle.value; + }, + set: function(value) { + this.dirty = true; + this.uniforms.angle.value = value; + } +}); +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + + + +PIXI.FilterBlock = function() { - this.graphics = mask this.visible = true; this.renderable = true; } - - /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ - -PIXI.MaskFilter = function(graphics) +/** + * + * This turns your displayObjects to black and white. + * @class GreyFilter + * @contructor + */ +PIXI.GreyFilter = function() { - // the graphics data that will be used for filtering - this.graphics; + PIXI.AbstractFilter.call( this ); + + this.passes = [this]; + + // set the uniforms + 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;", + "}" + ]; } +PIXI.GreyFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); +PIXI.GreyFilter.prototype.constructor = PIXI.GreyFilter; +/** +The strength of the grey. 1 will make the object black and white, 0 will make the object its normal color +@property grey +*/ +Object.defineProperty(PIXI.GreyFilter.prototype, 'grey', { + get: function() { + return this.uniforms.grey.value; + }, + set: function(value) { + this.uniforms.grey.value = value; + } +}); + +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * + * This inverts your displayObjects colors. + * @class InvertFilter + * @contructor + */ +PIXI.InvertFilter = function() +{ + PIXI.AbstractFilter.call( this ); + + this.passes = [this]; + + // set the uniforms + 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.rgb = gl_FragColor.rgb * gl_FragColor.a;", + "gl_FragColor = gl_FragColor * vColor;", + "}" + ]; + +} + +PIXI.InvertFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); +PIXI.InvertFilter.prototype.constructor = PIXI.InvertFilter; + +/** +The strength of the invert. 1 will fully invert the colors, 0 will make the object its normal color +@property invert +*/ +Object.defineProperty(PIXI.InvertFilter.prototype, 'invert', { + get: function() { + return this.uniforms.invert.value; + }, + set: function(value) { + this.uniforms.invert.value = value; + } +}); +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * + * This filter applies a pixlate effect making display objects appear "blocky" + * @class PixelateFilter + * @contructor + */ +PIXI.PixelateFilter = function() +{ + PIXI.AbstractFilter.call( this ); + + this.passes = [this]; + + // set the uniforms + this.uniforms = { + invert: {type: 'f', value: 0}, + dimensions: {type: 'f4', value:new Float32Array([10000, 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);", + "}" + ]; + + +} + +PIXI.PixelateFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); +PIXI.PixelateFilter.prototype.constructor = PIXI.PixelateFilter; + +/** + * + * This a point that describes the size of the blocs. x is the width of the block and y is the the height + * @property size + * @type Point + */ +Object.defineProperty(PIXI.PixelateFilter.prototype, 'size', { + get: function() { + return this.uniforms.pixelSize.value; + }, + set: function(value) { + this.dirty = true; + this.uniforms.pixelSize.value = value; + } +}); +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + + + +PIXI.RGBSplitFilter = function() +{ + PIXI.AbstractFilter.call( this ); + + this.passes = [this]; + + // set the uniforms + 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;", + "}" + ]; +} + +PIXI.RGBSplitFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); +PIXI.RGBSplitFilter.prototype.constructor = PIXI.RGBSplitFilter; + +Object.defineProperty(PIXI.RGBSplitFilter.prototype, 'angle', { + get: function() { + return this.uniforms.blur.value / (1/7000); + }, + set: function(value) { + //this.padding = value; + this.uniforms.blur.value = (1/7000) * value; + } +}); + +/** /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ /** - * The Graphics class contains a set of methods that you can use to create primitive shapes and lines. + * + * This applies a sepia effect to your displayObjects. + * @class SepiaFilter + * @contructor + */ +PIXI.SepiaFilter = function() +{ + PIXI.AbstractFilter.call( this ); + + this.passes = [this]; + + // set the uniforms + 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;", + "}" + ]; + +} + +PIXI.SepiaFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); +PIXI.SepiaFilter.prototype.constructor = PIXI.SepiaFilter; + +/** +The strength of the sepia. 1 will apply the full sepia effect, 0 will make the object its normal color +@property sepia +*/ +Object.defineProperty(PIXI.SepiaFilter.prototype, 'sepia', { + get: function() { + return this.uniforms.sepia.value; + }, + set: function(value) { + this.uniforms.sepia.value = value; + } +}); + +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + + + +PIXI.SmartBlurFilter = function() +{ + PIXI.AbstractFilter.call( this ); + + this.passes = [this]; + + // set the uniforms + this.uniforms = { + blur: {type: 'f', value: 1/512}, + }; + + this.fragmentSrc = [ + "precision mediump float;", + "varying vec2 vTextureCoord;", + "uniform sampler2D uSampler;", + // "uniform vec2 delta;", + "const vec2 delta = vec2(1.0/10.0, 0.0);", + // "uniform float darkness;", + + "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;", + // "gl_FragColor.rgb *= darkness;", + "}" + ]; +} + +PIXI.SmartBlurFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); +PIXI.SmartBlurFilter.prototype.constructor = PIXI.SmartBlurFilter; + +Object.defineProperty(PIXI.SmartBlurFilter.prototype, 'blur', { + get: function() { + return this.uniforms.blur.value; + }, + set: function(value) { + this.uniforms.blur.value = value; + } +}); + +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** + * + * This filter applies a pixlate effect making display objects appear "blocky" + * @class PixelateFilter + * @contructor + */ +PIXI.TwistFilter = function() +{ + PIXI.AbstractFilter.call( this ); + + this.passes = [this]; + + // set the uniforms + this.uniforms = { + radius: {type: 'f', value:0.5}, + angle: {type: 'f', value:5}, + offset: {type: 'f2', value:{x:0.5, y:0.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);", + "}" + ]; +} + +PIXI.TwistFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); +PIXI.TwistFilter.prototype.constructor = PIXI.TwistFilter; + +/** + * + * This point describes the the offset of the twist + * @property size + * @type Point + */ +Object.defineProperty(PIXI.TwistFilter.prototype, 'offset', { + get: function() { + return this.uniforms.offset.value; + }, + set: function(value) { + this.dirty = true; + this.uniforms.offset.value = value; + } +}); + +/** + * + * This radius describes size of the twist + * @property size + * @type Number + */ +Object.defineProperty(PIXI.TwistFilter.prototype, 'radius', { + get: function() { + return this.uniforms.radius.value; + }, + set: function(value) { + this.dirty = true; + this.uniforms.radius.value = value; + } +}); + +/** + * + * This radius describes angle of the twist + * @property angle + * @type Number + */ +Object.defineProperty(PIXI.TwistFilter.prototype, 'angle', { + get: function() { + return this.uniforms.angle.value; + }, + set: function(value) { + this.dirty = true; + this.uniforms.angle.value = value; + } +}); +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + + +/** + * The Graphics class contains a set of methods that you can use to create primitive shapes and lines. * It is important to know that with the webGL renderer only simple polys can be filled at this stage * Complex polys will not be filled. Heres an example of a complex poly: http://www.goodboydigital.com/wp-content/uploads/2013/06/complexPolygon.png * - * @class Graphics + * @class Graphics * @extends DisplayObjectContainer * @constructor */ PIXI.Graphics = function() { PIXI.DisplayObjectContainer.call( this ); - + this.renderable = true; /** @@ -2464,21 +3603,21 @@ PIXI.Graphics.prototype.constructor = PIXI.Graphics; * Specifies a line style used for subsequent calls to Graphics methods such as the lineTo() method or the drawCircle() method. * * @method lineStyle - * @param lineWidth {number} width of the line to draw, will update the object's stored style - * @param color {number} color of the line to draw, will update the object's stored style - * @param alpha {number} alpha of the line to draw, will update the object's stored style + * @param lineWidth {Number} width of the line to draw, will update the object's stored style + * @param color {Number} color of the line to draw, will update the object's stored style + * @param alpha {Number} alpha of the line to draw, will update the object's stored style */ PIXI.Graphics.prototype.lineStyle = function(lineWidth, color, alpha) { if(this.currentPath.points.length == 0)this.graphicsData.pop(); - + this.lineWidth = lineWidth || 0; this.lineColor = color || 0; this.lineAlpha = (alpha == undefined) ? 1 : alpha; - - this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha, + + this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha, fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling, points:[], type:PIXI.Graphics.POLY}; - + this.graphicsData.push(this.currentPath); } @@ -2486,18 +3625,18 @@ PIXI.Graphics.prototype.lineStyle = function(lineWidth, color, alpha) * Moves the current drawing position to (x, y). * * @method moveTo - * @param x {number} the X coord to move to - * @param y {number} the Y coord to move to + * @param x {Number} the X coord to move to + * @param y {Number} the Y coord to move to */ PIXI.Graphics.prototype.moveTo = function(x, y) { if(this.currentPath.points.length == 0)this.graphicsData.pop(); - - this.currentPath = this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha, + + this.currentPath = this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha, fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling, points:[], type:PIXI.Graphics.POLY}; - + this.currentPath.points.push(x, y); - + this.graphicsData.push(this.currentPath); } @@ -2506,8 +3645,8 @@ PIXI.Graphics.prototype.moveTo = function(x, y) * the current drawing position is then set to (x, y). * * @method lineTo - * @param x {number} the X coord to draw to - * @param y {number} the Y coord to draw to + * @param x {Number} the X coord to draw to + * @param y {Number} the Y coord to draw to */ PIXI.Graphics.prototype.lineTo = function(x, y) { @@ -2521,7 +3660,7 @@ PIXI.Graphics.prototype.lineTo = function(x, y) * * @method beginFill * @param color {uint} the color of the fill - * @param alpha {number} the alpha + * @param alpha {Number} the alpha */ PIXI.Graphics.prototype.beginFill = function(color, alpha) { @@ -2545,19 +3684,19 @@ PIXI.Graphics.prototype.endFill = function() /** * @method drawRect * - * @param x {number} The X coord of the top-left of the rectangle - * @param y {number} The Y coord of the top-left of the rectangle - * @param width {number} The width of the rectangle - * @param height {number} The height of the rectangle + * @param x {Number} The X coord of the top-left of the rectangle + * @param y {Number} The Y coord of the top-left of the rectangle + * @param width {Number} The width of the rectangle + * @param height {Number} The height of the rectangle */ PIXI.Graphics.prototype.drawRect = function( x, y, width, height ) { if(this.currentPath.points.length == 0)this.graphicsData.pop(); - - this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha, - fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling, + + this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha, + fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling, points:[x, y, width, height], type:PIXI.Graphics.RECT}; - + this.graphicsData.push(this.currentPath); this.dirty = true; } @@ -2566,18 +3705,18 @@ PIXI.Graphics.prototype.drawRect = function( x, y, width, height ) * Draws a circle. * * @method drawCircle - * @param x {number} The X coord of the center of the circle - * @param y {number} The Y coord of the center of the circle - * @param radius {number} The radius of the circle + * @param x {Number} The X coord of the center of the circle + * @param y {Number} The Y coord of the center of the circle + * @param radius {Number} The radius of the circle */ PIXI.Graphics.prototype.drawCircle = function( x, y, radius) { if(this.currentPath.points.length == 0)this.graphicsData.pop(); - - this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha, - fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling, + + this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha, + fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling, points:[x, y, radius, radius], type:PIXI.Graphics.CIRC}; - + this.graphicsData.push(this.currentPath); this.dirty = true; } @@ -2586,19 +3725,19 @@ PIXI.Graphics.prototype.drawCircle = function( x, y, radius) * Draws an elipse. * * @method drawElipse - * @param x {number} - * @param y {number} - * @param width {number} - * @param height {number} + * @param x {Number} + * @param y {Number} + * @param width {Number} + * @param height {Number} */ PIXI.Graphics.prototype.drawElipse = function( x, y, width, height) { if(this.currentPath.points.length == 0)this.graphicsData.pop(); - - this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha, - fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling, + + this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha, + fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling, points:[x, y, width, height], type:PIXI.Graphics.ELIP}; - + this.graphicsData.push(this.currentPath); this.dirty = true; } @@ -2612,10 +3751,85 @@ PIXI.Graphics.prototype.clear = function() { this.lineWidth = 0; this.filling = false; - + this.dirty = true; this.clearDirty = true; this.graphicsData = []; + + this.bounds = null//new PIXI.Rectangle(); +} + + +PIXI.Graphics.prototype.updateFilterBounds = function() +{ + if(!this.bounds) + { + var minX = Infinity; + var maxX = -Infinity; + + var minY = Infinity; + var maxY = -Infinity; + + var points, x, y; + + for (var i = 0; i < this.graphicsData.length; i++) { + + + var data = this.graphicsData[i]; + var type = data.type; + var lineWidth = data.lineWidth; + + points = data.points; + + if(type === PIXI.Graphics.RECT) + { + x = points.x - lineWidth/2; + y = points.y - lineWidth/2; + var width = points.width + lineWidth; + var height = points.height + lineWidth; + + minX = x < minX ? x : minX; + maxX = x + width > maxX ? x + width : maxX; + + minY = y < minY ? x : minY; + maxY = y + height > maxY ? y + height : maxY; + } + else if(type === PIXI.Graphics.CIRC || type === PIXI.Graphics.ELIP) + { + x = points.x; + y = points.y; + var radius = points.radius + lineWidth/2; + + minX = x - radius < minX ? x - radius : minX; + maxX = x + radius > maxX ? x + radius : maxX; + + minY = y - radius < minY ? y - radius : minY; + maxY = y + radius > maxY ? y + radius : maxY; + } + else + { + // POLY + for (var j = 0; j < points.length; j+=2) + { + + x = points[j]; + y = points[j+1]; + + minX = x-lineWidth < minX ? x-lineWidth : minX; + maxX = x+lineWidth > maxX ? x+lineWidth : maxX; + + minY = y-lineWidth < minY ? y-lineWidth : minY; + maxY = y+lineWidth > maxY ? y+lineWidth : maxY; + }; + } + + }; + + this.bounds = new PIXI.Rectangle(minX, minY, maxX - minX, maxY - minY); + + } + +// console.log(this.bounds); } // SOME TYPES: @@ -2636,7 +3850,7 @@ PIXI.Graphics.ELIP = 3; */ PIXI.CanvasGraphics = function() { - + } @@ -2652,33 +3866,33 @@ PIXI.CanvasGraphics = function() PIXI.CanvasGraphics.renderGraphics = function(graphics, context) { var worldAlpha = graphics.worldAlpha; - - for (var i=0; i < graphics.graphicsData.length; i++) + + for (var i=0; i < graphics.graphicsData.length; i++) { var data = graphics.graphicsData[i]; var points = data.points; - + context.strokeStyle = color = '#' + ('00000' + ( data.lineColor | 0).toString(16)).substr(-6); context.lineWidth = data.lineWidth; - + if(data.type == PIXI.Graphics.POLY) { context.beginPath(); - + context.moveTo(points[0], points[1]); - + for (var j=1; j < points.length/2; j++) { context.lineTo(points[j * 2], points[j * 2 + 1]); - } - + } + // if the first and last point are the same close the path - much neater :) if(points[0] == points[points.length-2] && points[1] == points[points.length-1]) { context.closePath(); } - + if(data.fill) { context.globalAlpha = data.fillAlpha * worldAlpha; @@ -2693,21 +3907,20 @@ PIXI.CanvasGraphics.renderGraphics = function(graphics, context) } else if(data.type == PIXI.Graphics.RECT) { - - // TODO - need to be Undefined! - if(data.fillColor) + + if(data.fillColor || data.fillColor === 0) { context.globalAlpha = data.fillAlpha * worldAlpha; context.fillStyle = color = '#' + ('00000' + ( data.fillColor | 0).toString(16)).substr(-6); context.fillRect(points[0], points[1], points[2], points[3]); - + } if(data.lineWidth) { context.globalAlpha = data.lineAlpha * worldAlpha; context.strokeRect(points[0], points[1], points[2], points[3]); } - + } else if(data.type == PIXI.Graphics.CIRC) { @@ -2715,7 +3928,7 @@ PIXI.CanvasGraphics.renderGraphics = function(graphics, context) context.beginPath(); context.arc(points[0], points[1], points[2],0,2*Math.PI); context.closePath(); - + if(data.fill) { context.globalAlpha = data.fillAlpha * worldAlpha; @@ -2730,19 +3943,19 @@ PIXI.CanvasGraphics.renderGraphics = function(graphics, context) } else if(data.type == PIXI.Graphics.ELIP) { - + // elipse code taken from: http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas - + var elipseData = data.points; - + var w = elipseData[2] * 2; var h = elipseData[3] * 2; - + var x = elipseData[0] - w/2; var y = elipseData[1] - h/2; - + context.beginPath(); - + var kappa = .5522848, ox = (w / 2) * kappa, // control point offset horizontal oy = (h / 2) * kappa, // control point offset vertical @@ -2750,15 +3963,15 @@ PIXI.CanvasGraphics.renderGraphics = function(graphics, context) ye = y + h, // y-end xm = x + w / 2, // x-middle ym = y + h / 2; // y-middle - + context.moveTo(x, ym); context.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y); context.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym); context.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye); context.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym); - + context.closePath(); - + if(data.fill) { context.globalAlpha = data.fillAlpha * worldAlpha; @@ -2771,7 +3984,7 @@ PIXI.CanvasGraphics.renderGraphics = function(graphics, context) context.stroke(); } } - + }; } @@ -2787,35 +4000,37 @@ PIXI.CanvasGraphics.renderGraphics = function(graphics, context) PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context) { var worldAlpha = graphics.worldAlpha; - + var len = graphics.graphicsData.length; + if(len === 0)return; + if(len > 1) { len = 1; console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object") } - - for (var i=0; i < 1; i++) + + for (var i=0; i < 1; i++) { var data = graphics.graphicsData[i]; var points = data.points; - + if(data.type == PIXI.Graphics.POLY) { context.beginPath(); context.moveTo(points[0], points[1]); - + for (var j=1; j < points.length/2; j++) { context.lineTo(points[j * 2], points[j * 2 + 1]); - } - + } + // if the first and last point are the same close the path - much neater :) if(points[0] == points[points.length-2] && points[1] == points[points.length-1]) { context.closePath(); } - + } else if(data.type == PIXI.Graphics.RECT) { @@ -2832,18 +4047,18 @@ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context) } else if(data.type == PIXI.Graphics.ELIP) { - + // elipse code taken from: http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas var elipseData = data.points; - + var w = elipseData[2] * 2; var h = elipseData[3] * 2; - + var x = elipseData[0] - w/2; var y = elipseData[1] - h/2; - + context.beginPath(); - + var kappa = .5522848, ox = (w / 2) * kappa, // control point offset horizontal oy = (h / 2) * kappa, // control point offset vertical @@ -2851,7 +4066,7 @@ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context) ye = y + h, // y-end xm = x + w / 2, // x-middle ym = y + h / 2; // y-middle - + context.moveTo(x, ym); context.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y); context.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym); @@ -2859,8 +4074,8 @@ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context) context.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym); context.closePath(); } - - + + }; } @@ -2875,8 +4090,8 @@ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context) * * @class CanvasRenderer * @constructor - * @param width=0 {number} the width of the canvas view - * @param height=0 {number} the height of the canvas view + * @param width=0 {Number} the width of the canvas view + * @param height=0 {Number} the height of the canvas view * @param view {Canvas} the canvas to use as a view, optional * @param transparent=false {Boolean} the transparency of the render view, default false */ @@ -2980,8 +4195,8 @@ PIXI.CanvasRenderer.prototype.render = function(stage) * resizes the canvas view to the specified width and height * * @method resize - * @param width {number} the new width of the canvas view - * @param height {number} the new height of the canvas view + * @param width {Number} the new width of the canvas view + * @param height {Number} the new height of the canvas view */ PIXI.CanvasRenderer.prototype.resize = function(width, height) { @@ -3029,9 +4244,10 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject) if(displayObject instanceof PIXI.Sprite) { + var frame = displayObject.texture.frame; - if(frame) + if(frame && frame.width && frame.height) { context.globalAlpha = displayObject.worldAlpha; @@ -3060,6 +4276,7 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject) } else if(displayObject instanceof PIXI.CustomRenderable) { + context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]); displayObject.renderCanvas(this); } else if(displayObject instanceof PIXI.Graphics) @@ -3069,27 +4286,36 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject) } else if(displayObject instanceof PIXI.FilterBlock) { - if(displayObject.open) - { - 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]) - - displayObject.mask.worldAlpha = 0.5; - - context.worldAlpha = 0; - - PIXI.CanvasGraphics.renderGraphicsMask(displayObject.mask, context); - context.clip(); - - displayObject.mask.worldAlpha = cacheAlpha; + if(displayObject.data instanceof PIXI.Graphics) + { + var mask = displayObject.data; + + if(displayObject.open) + { + context.save(); + + var cacheAlpha = mask.alpha; + var maskTransform = mask.worldTransform; + + context.setTransform(maskTransform[0], maskTransform[3], maskTransform[1], maskTransform[4], maskTransform[2], maskTransform[5]) + + mask.worldAlpha = 0.5; + + context.worldAlpha = 0; + + PIXI.CanvasGraphics.renderGraphicsMask(mask, context); + context.clip(); + + mask.worldAlpha = cacheAlpha; + } + else + { + context.restore(); + } } else { - context.restore(); + // only masks supported right now! } } // count++ @@ -3234,6 +4460,250 @@ PIXI.CanvasRenderer.prototype.renderStrip = function(strip) } +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + + +PIXI.PixiShader = function() +{ + // the webGL program.. + 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;", + "}" + ]; + +} + +PIXI.PixiShader.prototype.init = function() +{ + var program = PIXI.compileProgram(this.vertexSrc || PIXI.PixiShader.defaultVertexSrc, this.fragmentSrc) + + var gl = PIXI.gl; + + gl.useProgram(program); + + // get and store the uniforms for the shader + this.uSampler = gl.getUniformLocation(program, "uSampler"); + this.projectionVector = gl.getUniformLocation(program, "projectionVector"); + this.offsetVector = gl.getUniformLocation(program, "offsetVector"); + //this.dimensions = gl.getUniformLocation(this.program, "dimensions"); + + // get and store the attributes + this.aVertexPosition = gl.getAttribLocation(program, "aVertexPosition"); + this.colorAttribute = gl.getAttribLocation(program, "aColor"); + this.aTextureCoord = gl.getAttribLocation(program, "aTextureCoord"); + + // add those custom shaders! + for (var key in this.uniforms) + { + + // get the uniform locations.. + // program[key] = + this.uniforms[key].uniformLocation = gl.getUniformLocation(program, key); + + + } + + this.program = program; +} + +PIXI.PixiShader.prototype.syncUniforms = function() +{ + var gl = PIXI.gl; + + for (var key in this.uniforms) + { + //var + var type = this.uniforms[key].type; + + // need to grow this! + if(type == "f") + { + gl.uniform1f(this.uniforms[key].uniformLocation, this.uniforms[key].value); + } + if(type == "f2") + { + // console.log(this.program[key]) + gl.uniform2f(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y); + } + else if(type == "f4") + { + // console.log(this.uniforms[key].value) + gl.uniform4fv(this.uniforms[key].uniformLocation, this.uniforms[key].value); + } + else if(type == "mat4") + { + gl.uniformMatrix4fv(this.uniforms[key].uniformLocation, false, this.uniforms[key].value); + } + else if(type == "sampler2D") + { + // first texture... + var texture = this.uniforms[key].value; + + gl.activeTexture(gl.TEXTURE1); + gl.bindTexture(gl.TEXTURE_2D, texture.baseTexture._glTexture); + + gl.uniform1i(this.uniforms[key].uniformLocation, 1); + + // activate texture.. + // gl.uniformMatrix4fv(this.program[key], false, this.uniforms[key].value); + // gl.uniformMatrix4fv(this.program[key], false, this.uniforms[key].value); + } + } + +} + +PIXI.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;", + "}" +]; + +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + + +PIXI.PrimitiveShader = function() +{ + // the webGL program.. + 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;", + "}" + ]; + +} + +PIXI.PrimitiveShader.prototype.init = function() +{ + var program = PIXI.compileProgram(this.vertexSrc, this.fragmentSrc); + + var gl = PIXI.gl; + + gl.useProgram(program); + + // get and store the uniforms for the shader + this.projectionVector = gl.getUniformLocation(program, "projectionVector"); + this.offsetVector = gl.getUniformLocation(program, "offsetVector"); + + // get and store the attributes + this.aVertexPosition = gl.getAttribLocation(program, "aVertexPosition"); + this.colorAttribute = gl.getAttribLocation(program, "aColor"); + + this.translationMatrix = gl.getUniformLocation(program, "translationMatrix"); + this.alpha = gl.getUniformLocation(program, "alpha"); + + this.program = program; +} + +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + + +PIXI.StripShader = function() +{ + // the webGL program.. + 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;", + "}" + ]; +} + +PIXI.StripShader.prototype.init = function() +{ + var program = PIXI.compileProgram(this.vertexSrc, this.fragmentSrc) + + var gl = PIXI.gl; + + gl.useProgram(program); + + // get and store the uniforms for the shader + this.uSampler = gl.getUniformLocation(program, "uSampler"); + this.projectionVector = gl.getUniformLocation(program, "projectionVector"); + this.offsetVector = gl.getUniformLocation(program, "offsetVector"); + this.colorAttribute = gl.getAttribLocation(program, "aColor"); + //this.dimensions = gl.getUniformLocation(this.program, "dimensions"); + + // get and store the attributes + this.aVertexPosition = gl.getAttribLocation(program, "aVertexPosition"); + this.aTextureCoord = gl.getAttribLocation(program, "aTextureCoord"); + + this.translationMatrix = gl.getUniformLocation(program, "translationMatrix"); + this.alpha = gl.getUniformLocation(program, "alpha"); + + this.program = program; +} + /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -3651,7 +5121,10 @@ PIXI.WebGLBatch.prototype.update = function() var indexRun = 0; var displayObject = this.head; - + var verticies = this.verticies; + var uvs = this.uvs; + var colors = this.colors; + while(displayObject) { if(displayObject.vcount === PIXI.visibleCount) @@ -3679,17 +5152,17 @@ PIXI.WebGLBatch.prototype.update = function() tx = worldTransform[2]; ty = worldTransform[5]; - this.verticies[index + 0 ] = a * w1 + c * h1 + tx; - this.verticies[index + 1 ] = d * h1 + b * w1 + ty; + verticies[index + 0 ] = a * w1 + c * h1 + tx; + verticies[index + 1 ] = d * h1 + b * w1 + ty; - this.verticies[index + 2 ] = a * w0 + c * h1 + tx; - this.verticies[index + 3 ] = d * h1 + b * w0 + ty; + verticies[index + 2 ] = a * w0 + c * h1 + tx; + verticies[index + 3 ] = d * h1 + b * w0 + ty; - this.verticies[index + 4 ] = a * w0 + c * h0 + tx; - this.verticies[index + 5 ] = d * h0 + b * w0 + ty; + verticies[index + 4 ] = a * w0 + c * h0 + tx; + verticies[index + 5 ] = d * h0 + b * w0 + ty; - this.verticies[index + 6] = a * w1 + c * h0 + tx; - this.verticies[index + 7] = d * h0 + b * w1 + ty; + verticies[index + 6] = a * w1 + c * h0 + tx; + verticies[index + 7] = d * h0 + b * w1 + ty; if(displayObject.updateFrame || displayObject.texture.updateFrame) { @@ -3701,17 +5174,17 @@ PIXI.WebGLBatch.prototype.update = function() var tw = texture.baseTexture.width; var th = texture.baseTexture.height; - this.uvs[index + 0] = frame.x / tw; - this.uvs[index +1] = frame.y / th; + uvs[index + 0] = frame.x / tw; + uvs[index +1] = frame.y / th; - this.uvs[index +2] = (frame.x + frame.width) / tw; - this.uvs[index +3] = frame.y / th; + uvs[index +2] = (frame.x + frame.width) / tw; + uvs[index +3] = frame.y / th; - this.uvs[index +4] = (frame.x + frame.width) / tw; - this.uvs[index +5] = (frame.y + frame.height) / th; + uvs[index +4] = (frame.x + frame.width) / tw; + uvs[index +5] = (frame.y + frame.height) / th; - this.uvs[index +6] = frame.x / tw; - this.uvs[index +7] = (frame.y + frame.height) / th; + uvs[index +6] = frame.x / tw; + uvs[index +7] = (frame.y + frame.height) / th; displayObject.updateFrame = false; } @@ -3722,7 +5195,7 @@ PIXI.WebGLBatch.prototype.update = function() displayObject.cacheAlpha = displayObject.worldAlpha; var colorIndex = indexRun * 4; - this.colors[colorIndex] = this.colors[colorIndex + 1] = this.colors[colorIndex + 2] = this.colors[colorIndex + 3] = displayObject.worldAlpha; + colors[colorIndex] = colors[colorIndex + 1] = colors[colorIndex + 2] = colors[colorIndex + 3] = displayObject.worldAlpha; this.dirtyColors = true; } } @@ -3730,17 +5203,7 @@ PIXI.WebGLBatch.prototype.update = function() { index = indexRun * 8; - this.verticies[index + 0 ] = 0; - this.verticies[index + 1 ] = 0; - - this.verticies[index + 2 ] = 0; - this.verticies[index + 3 ] = 0; - - this.verticies[index + 4 ] = 0; - this.verticies[index + 5 ] = 0; - - this.verticies[index + 6] = 0; - this.verticies[index + 7] = 0; + verticies[index + 0 ] = verticies[index + 1 ] = verticies[index + 2 ] = verticies[index + 3 ] = verticies[index + 4 ] = verticies[index + 5 ] = verticies[index + 6] = verticies[index + 7] = 0; } indexRun++; @@ -3772,15 +5235,18 @@ PIXI.WebGLBatch.prototype.render = function(start, end) //TODO optimize this! - var shaderProgram = PIXI.shaderProgram; - gl.useProgram(shaderProgram); + var shaderProgram = PIXI.defaultShader; + + //gl.useProgram(shaderProgram); // update the verts.. gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); // ok.. gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.verticies) - gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, 2, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(shaderProgram.aVertexPosition, 2, gl.FLOAT, false, 0, 0); // update the uvs + //var isDefault = (shaderProgram == PIXI.shaderProgram) + gl.bindBuffer(gl.ARRAY_BUFFER, this.uvBuffer); if(this.dirtyUVS) @@ -3789,7 +5255,7 @@ PIXI.WebGLBatch.prototype.render = function(start, end) gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.uvs); } - gl.vertexAttribPointer(shaderProgram.textureCoordAttribute, 2, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(shaderProgram.aTextureCoord, 2, gl.FLOAT, false, 0, 0); gl.activeTexture(gl.TEXTURE0); gl.bindTexture(gl.TEXTURE_2D, this.texture._glTexture); @@ -3804,7 +5270,6 @@ PIXI.WebGLBatch.prototype.render = function(start, end) } gl.vertexAttribPointer(shaderProgram.colorAttribute, 1, gl.FLOAT, false, 0, 0); - // dont need to upload! gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); @@ -3818,6 +5283,525 @@ PIXI.WebGLBatch.prototype.render = function(start, end) * @author Mat Groves http://matgroves.com/ @Doormat23 */ + +PIXI.WebGLFilterManager = function(transparent) +{ + this.transparent = transparent; + + this.filterStack = []; + this.texturePool = []; + + this.offsetX = 0; + this.offsetY = 0; + + this.initShaderBuffers(); +} + +// API + +PIXI.WebGLFilterManager.prototype.begin = function(projection, buffer) +{ + this.width = projection.x * 2; + this.height = -projection.y * 2; + this.buffer = buffer; +} + +PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock) +{ + var gl = PIXI.gl; + + // filter program + // OPTIMISATION - the first filter is free if its a simple color change? + this.filterStack.push(filterBlock); + + var filter = filterBlock.filterPasses[0]; + + + + this.offsetX += filterBlock.target.filterArea.x; + this.offsetY += filterBlock.target.filterArea.y; + + + + + + var texture = this.texturePool.pop(); + if(!texture)texture = new PIXI.FilterTexture(this.width, this.height); + + gl.bindTexture(gl.TEXTURE_2D, texture.texture); + + this.getBounds(filterBlock.target); + + // addpadding? + //displayObject.filterArea.x + + var filterArea = filterBlock.target.filterArea; + + var padidng = filter.padding; + filterArea.x -= padidng; + filterArea.y -= padidng; + filterArea.width += padidng * 2; + filterArea.height += padidng * 2; + + // cap filter to screen size.. + if(filterArea.x < 0)filterArea.x = 0; + if(filterArea.width > this.width)filterArea.width = this.width; + if(filterArea.y < 0)filterArea.y = 0; + if(filterArea.height > this.height)filterArea.height = this.height; + + + //gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, filterArea.width, filterArea.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + gl.bindFramebuffer(gl.FRAMEBUFFER, texture.frameBuffer); + + // console.log(filterArea) + // set view port + gl.viewport(0, 0, filterArea.width, filterArea.height); + + PIXI.projection.x = filterArea.width/2; + PIXI.projection.y = -filterArea.height/2; + + PIXI.offset.x = -filterArea.x; + PIXI.offset.y = -filterArea.y; + + //console.log(PIXI.defaultShader.projectionVector) + // update projection + gl.uniform2f(PIXI.defaultShader.projectionVector, filterArea.width/2, -filterArea.height/2); + gl.uniform2f(PIXI.defaultShader.offsetVector, -filterArea.x, -filterArea.y); + //PIXI.primitiveProgram + + gl.colorMask(true, true, true, true); + gl.clearColor(0,0,0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); + + //filter.texture = texture; + filterBlock._glFilterTexture = texture; + + //console.log("PUSH") +} + + +PIXI.WebGLFilterManager.prototype.popFilter = function() +{ + + var gl = PIXI.gl; + + var filterBlock = this.filterStack.pop(); + + + + var filterArea = filterBlock.target.filterArea; + + var texture = filterBlock._glFilterTexture; + + if(filterBlock.filterPasses.length > 1) + { + gl.viewport(0, 0, filterArea.width, filterArea.height); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); + + this.vertexArray[0] = 0; + this.vertexArray[1] = filterArea.height; + + this.vertexArray[2] = filterArea.width; + this.vertexArray[3] = filterArea.height; + + this.vertexArray[4] = 0; + this.vertexArray[5] = 0; + + this.vertexArray[6] = filterArea.width; + this.vertexArray[7] = 0; + + + gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.vertexArray); + + + gl.bindBuffer(gl.ARRAY_BUFFER, this.uvBuffer); + // nnow set the uvs.. + this.uvArray[2] = filterArea.width/this.width; + this.uvArray[5] = filterArea.height/this.height; + this.uvArray[6] = filterArea.width/this.width; + this.uvArray[7] = filterArea.height/this.height; + + gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.uvArray); + + var inputTexture = texture; + var outputTexture = this.texturePool.pop(); + if(!outputTexture)outputTexture = new PIXI.FilterTexture(this.width, this.height); + + // need to clear this FBO as it may have some left over elements from a prvious filter. + gl.bindFramebuffer(gl.FRAMEBUFFER, outputTexture.frameBuffer ); + gl.clear(gl.COLOR_BUFFER_BIT); + + gl.disable(gl.BLEND); + + for (var i = 0; i < filterBlock.filterPasses.length-1; i++) + { + var filterPass = filterBlock.filterPasses[i]; + + gl.bindFramebuffer(gl.FRAMEBUFFER, outputTexture.frameBuffer ); + + // set texture + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture); + + // draw texture.. + //filterPass.applyFilterPass(filterArea.width, filterArea.height); + this.applyFilterPass(filterPass, filterArea, filterArea.width, filterArea.height); + + // swap the textures.. + var temp = inputTexture; + inputTexture = outputTexture; + outputTexture = temp; + + }; + + gl.enable(gl.BLEND); + + texture = inputTexture; + this.texturePool.push(outputTexture); + } + + var filter = filterBlock.filterPasses[filterBlock.filterPasses.length-1]; + + this.offsetX -= filterArea.x; + this.offsetY -= filterArea.y; + + + var sizeX = this.width; + var sizeY = this.height; + + var offsetX = 0; + var offsetY = 0; + + var buffer = this.buffer; + + // time to render the filters texture to the previous scene + if(this.filterStack.length === 0) + { + gl.colorMask(true, true, true, this.transparent); + } + else + { + var currentFilter = this.filterStack[this.filterStack.length-1]; + var filterArea = currentFilter.target.filterArea; + + sizeX = filterArea.width; + sizeY = filterArea.height; + + offsetX = filterArea.x; + offsetY = filterArea.y; + + buffer = currentFilter._glFilterTexture.frameBuffer; + } + + + + // TODO need toremove thease global elements.. + PIXI.projection.x = sizeX/2; + PIXI.projection.y = -sizeY/2; + + PIXI.offset.x = offsetX; + PIXI.offset.y = offsetY; + + + var filterArea = filterBlock.target.filterArea; + var x = filterArea.x-offsetX; + var y = filterArea.y-offsetY; + + // update the buffers.. + // make sure to flip the y! + gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); + + this.vertexArray[0] = x; + this.vertexArray[1] = y + filterArea.height; + + this.vertexArray[2] = x + filterArea.width; + this.vertexArray[3] = y + filterArea.height; + + this.vertexArray[4] = x; + this.vertexArray[5] = y; + + this.vertexArray[6] = x + filterArea.width; + this.vertexArray[7] = y; + + gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.vertexArray); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.uvBuffer); + + this.uvArray[2] = filterArea.width/this.width; + this.uvArray[5] = filterArea.height/this.height; + this.uvArray[6] = filterArea.width/this.width; + this.uvArray[7] = filterArea.height/this.height; + + gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.uvArray); + + gl.viewport(0, 0, sizeX, sizeY); + // bind the buffer + gl.bindFramebuffer(gl.FRAMEBUFFER, buffer ); + + // set texture + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, texture.texture); + + // apply! + //filter.applyFilterPass(sizeX, sizeY); + this.applyFilterPass(filter, filterArea, sizeX, sizeY); + + // now restore the regular shader.. + gl.useProgram(PIXI.defaultShader.program); + gl.uniform2f(PIXI.defaultShader.projectionVector, sizeX/2, -sizeY/2); + gl.uniform2f(PIXI.defaultShader.offsetVector, -offsetX, -offsetY); + + // return the texture to the pool + this.texturePool.push(texture); + filterBlock._glFilterTexture = null; +} + +PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea, width, height) +{ + // use program + var gl = PIXI.gl; + + if(!filter.shader) + { + var shader = new PIXI.PixiShader(); + + shader.fragmentSrc = filter.fragmentSrc; + shader.uniforms = filter.uniforms; + shader.init(); + + filter.shader = shader; + } + + var shader = filter.shader; + + // set the shader + gl.useProgram(shader.program); + + gl.uniform2f(shader.projectionVector, width/2, -height/2); + gl.uniform2f(shader.offsetVector, 0,0) + + if(filter.uniforms.dimensions) + { + //console.log(filter.uniforms.dimensions) + filter.uniforms.dimensions.value[0] = this.width;//width; + filter.uniforms.dimensions.value[1] = this.height;//height; + filter.uniforms.dimensions.value[2] = this.vertexArray[0]; + filter.uniforms.dimensions.value[3] = this.vertexArray[5];//filterArea.height; + // console.log(this.vertexArray[5]) + } + + shader.syncUniforms(); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); + gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 0, 0); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.uvBuffer); + gl.vertexAttribPointer(shader.aTextureCoord, 2, gl.FLOAT, false, 0, 0); + + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); + + // draw the filter... + gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0 ); +} + +PIXI.WebGLFilterManager.prototype.initShaderBuffers = function() +{ + var gl = PIXI.gl; + + // create some buffers + this.vertexBuffer = gl.createBuffer(); + this.uvBuffer = gl.createBuffer(); + this.indexBuffer = gl.createBuffer(); + + // bind and upload the vertexs.. + // keep a refferance to the vertexFloatData.. + this.vertexArray = new Float32Array([0.0, 0.0, + 1.0, 0.0, + 0.0, 1.0, + 1.0, 1.0]); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); + gl.bufferData( + gl.ARRAY_BUFFER, + this.vertexArray, + gl.STATIC_DRAW); + + + // bind and upload the uv buffer + this.uvArray = new Float32Array([0.0, 0.0, + 1.0, 0.0, + 0.0, 1.0, + 1.0, 1.0]); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.uvBuffer); + gl.bufferData( + gl.ARRAY_BUFFER, + this.uvArray, + gl.STATIC_DRAW); + + // bind and upload the index + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); + gl.bufferData( + gl.ELEMENT_ARRAY_BUFFER, + new Uint16Array([0, 1, 2, 1, 3, 2]), + gl.STATIC_DRAW); +} + +PIXI.WebGLFilterManager.prototype.getBounds = function(displayObject) +{ + // time to get the width and height of the object! + var worldTransform, width, height, aX, aY, w0, w1, h0, h1, index, doTest; + var a, b, c, d, tx, ty, x1, x2, x3, x4, y1, y2, y3, y4; + + var tempObject = displayObject.first; + var testObject = displayObject.last._iNext; + + var maxX = -Infinity; + var maxY = -Infinity; + + var minX = Infinity; + var minY = Infinity; + + do + { + // TODO can be optimized! - what if there is no scale / rotation? + + if(tempObject.visible) + { + if(tempObject instanceof PIXI.Sprite) + { + width = tempObject.texture.frame.width; + height = tempObject.texture.frame.height; + + // TODO trim?? + aX = tempObject.anchor.x; + aY = tempObject.anchor.y; + w0 = width * (1-aX); + w1 = width * -aX; + + h0 = height * (1-aY); + h1 = height * -aY; + + doTest = true; + } + else if(tempObject instanceof PIXI.Graphics) + { + tempObject.updateFilterBounds(); + + var bounds = tempObject.bounds; + + width = bounds.width; + height = bounds.height; + + w0 = bounds.x + w1 = bounds.x + bounds.width; + + h0 = bounds.y + h1 = bounds.y + bounds.height; + + doTest = true; + } + } + + if(doTest) + { + worldTransform = tempObject.worldTransform; + + a = worldTransform[0]; + b = worldTransform[3]; + c = worldTransform[1]; + d = worldTransform[4]; + tx = worldTransform[2]; + ty = worldTransform[5]; + + x1 = a * w1 + c * h1 + tx; + y1 = d * h1 + b * w1 + ty; + + x2 = a * w0 + c * h1 + tx; + y2 = d * h1 + b * w0 + ty; + + x3 = a * w0 + c * h0 + tx; + y3 = d * h0 + b * w0 + ty; + + x4 = a * w1 + c * h0 + tx; + y4 = d * h0 + b * w1 + ty; + + minX = x1 < minX ? x1 : minX; + minX = x2 < minX ? x2 : minX; + minX = x3 < minX ? x3 : minX; + minX = x4 < minX ? x4 : minX; + + minY = y1 < minY ? y1 : minY; + minY = y2 < minY ? y2 : minY; + minY = y3 < minY ? y3 : minY; + minY = y4 < minY ? y4 : minY; + + maxX = x1 > maxX ? x1 : maxX; + maxX = x2 > maxX ? x2 : maxX; + maxX = x3 > maxX ? x3 : maxX; + maxX = x4 > maxX ? x4 : maxX; + + maxY = y1 > maxY ? y1 : maxY; + maxY = y2 > maxY ? y2 : maxY; + maxY = y3 > maxY ? y3 : maxY; + maxY = y4 > maxY ? y4 : maxY; + } + + doTest = false; + tempObject = tempObject._iNext; + + } + while(tempObject != testObject) + + // maximum bounds is the size of the screen.. + //minX = minX > 0 ? minX : 0; + //minY = minY > 0 ? minY : 0; + + displayObject.filterArea.x = minX; + displayObject.filterArea.y = minY; + +// console.log(maxX+ " : " + minX) + displayObject.filterArea.width = maxX - minX; + displayObject.filterArea.height = maxY - minY; +} + +PIXI.FilterTexture = function(width, height) +{ + var gl = PIXI.gl; + + // next time to create a frame buffer and texture + this.frameBuffer = gl.createFramebuffer(); + this.texture = gl.createTexture(); + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + 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); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); + + gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); + + this.resize(width, height); +} + +PIXI.FilterTexture.prototype.resize = function(width, height) +{ + this.width = width; + this.height = height; + + var gl = PIXI.gl; + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + +} +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + /** * A set of functions used by the webGL renderer to draw the primitive graphics data * @@ -3862,7 +5846,6 @@ PIXI.WebGLGraphics.renderGraphics = function(graphics, projection) PIXI.WebGLGraphics.updateGraphics(graphics); } - PIXI.activatePrimitiveShader(); // This could be speeded up fo sure! @@ -3872,30 +5855,29 @@ PIXI.WebGLGraphics.renderGraphics = function(graphics, projection) // set the matrix transform for the gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); - - gl.uniformMatrix3fv(PIXI.primitiveProgram.translationMatrix, false, m); - - gl.uniform2f(PIXI.primitiveProgram.projectionVector, projection.x, projection.y); - - gl.uniform1f(PIXI.primitiveProgram.alpha, graphics.worldAlpha); + gl.uniformMatrix3fv(PIXI.primitiveShader.translationMatrix, false, m); + + gl.uniform2f(PIXI.primitiveShader.projectionVector, projection.x, -projection.y); + gl.uniform2f(PIXI.primitiveShader.offsetVector, -PIXI.offset.x, -PIXI.offset.y); + + gl.uniform1f(PIXI.primitiveShader.alpha, graphics.worldAlpha); gl.bindBuffer(gl.ARRAY_BUFFER, graphics._webGL.buffer); - // WHY DOES THIS LINE NEED TO BE THERE??? - gl.vertexAttribPointer(PIXI.shaderProgram.vertexPositionAttribute, 2, gl.FLOAT, false, 0, 0); - // its not even used.. but need to be set or it breaks? - // only on pc though.. - - gl.vertexAttribPointer(PIXI.primitiveProgram.vertexPositionAttribute, 2, gl.FLOAT, false, 4 * 6, 0); - gl.vertexAttribPointer(PIXI.primitiveProgram.colorAttribute, 4, gl.FLOAT, false,4 * 6, 2 * 4); + gl.vertexAttribPointer(PIXI.primitiveShader.aVertexPosition, 2, gl.FLOAT, false, 4 * 6, 0); + gl.vertexAttribPointer(PIXI.primitiveShader.colorAttribute, 4, gl.FLOAT, false,4 * 6, 2 * 4); // set the index buffer! gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, graphics._webGL.indexBuffer); + gl.drawElements(gl.TRIANGLE_STRIP, graphics._webGL.indices.length, gl.UNSIGNED_SHORT, 0 ); + PIXI.deactivatePrimitiveShader(); + + // return to default shader... - PIXI.activateDefaultShader(); +// PIXI.activateShader(PIXI.defaultShader); } /** @@ -4100,6 +6082,14 @@ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData) var points = graphicsData.points; if(points.length == 0)return; + // if the line width is an odd number add 0.5 to align to a whole pixel + if(graphicsData.lineWidth%2) + { + for (var i = 0; i < points.length; i++) { + points[i] += 0.5; + }; + } + // get first and last point.. figure out the middle! var firstPoint = new PIXI.Point( points[0], points[1] ); var lastPoint = new PIXI.Point( points[points.length - 2], points[points.length - 1] ); @@ -4201,16 +6191,27 @@ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData) c2 = (-perp2x + p3x) * (-perp2y + p2y) - (-perp2x + p2x) * (-perp2y + p3y); denom = a1*b2 - a2*b1; - - if (denom == 0) { - denom+=1; - } + + if(Math.abs(denom) < 0.1 ) + { + + denom+=10.1; + verts.push(p2x - perpx , p2y - perpy, + r, g, b, alpha); + + verts.push(p2x + perpx , p2y + perpy, + r, g, b, alpha); + + continue; + } px = (b1*c2 - b2*c1)/denom; py = (a2*c1 - a1*c2)/denom; + pdist = (px -p2x) * (px -p2x) + (py -p2y) + (py -p2y); + if(pdist > 140 * 140) { perp3x = perpx - perp2x; @@ -4235,6 +6236,7 @@ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData) } else { + verts.push(px , py); verts.push(r, g, b, alpha); @@ -4347,8 +6349,8 @@ PIXI.gl; * * @class WebGLRenderer * @constructor - * @param width=0 {number} the width of the canvas view - * @param height=0 {number} the height of the canvas view + * @param width=0 {Number} the width of the canvas view + * @param height=0 {Number} the height of the canvas view * @param view {Canvas} the canvas to use as a view, optional * @param transparent=false {Boolean} the transparency of the render view, default false * @param antialias=false {Boolean} sets antialias (only applicable in chrome at the moment) @@ -4374,27 +6376,38 @@ PIXI.WebGLRenderer = function(width, height, view, transparent, antialias) this.batchs = []; - try - { - PIXI.gl = this.gl = this.view.getContext("experimental-webgl", { - alpha: this.transparent, - antialias:!!antialias, // SPEED UP?? - premultipliedAlpha:false, - stencil:true - }); - } - catch (e) - { - throw new Error(" This browser does not support webGL. Try using the canvas renderer" + this); - } + var options = { + alpha: this.transparent, + antialias:!!antialias, // SPEED UP?? + premultipliedAlpha:false, + stencil:true + } - PIXI.initPrimitiveShader(); - PIXI.initDefaultShader(); - PIXI.initDefaultStripShader(); + //try 'experimental-webgl' + try { + PIXI.gl = this.gl = this.view.getContext("experimental-webgl", options); + } catch (e) { + //try 'webgl' + try { + PIXI.gl = this.gl = this.view.getContext("webgl", options); + } catch (e) { + // fail, not able to get a context + throw new Error(" This browser does not support webGL. Try using the canvas renderer" + this); + } + } - PIXI.activateDefaultShader(); + PIXI.initDefaultShaders(); + + + + + // PIXI.activateDefaultShader(); var gl = this.gl; + + gl.useProgram(PIXI.defaultShader.program); + + PIXI.WebGLRenderer.gl = gl; this.batch = new PIXI.WebGLBatch(gl); @@ -4405,11 +6418,17 @@ PIXI.WebGLRenderer = function(width, height, view, transparent, antialias) gl.colorMask(true, true, true, this.transparent); PIXI.projection = new PIXI.Point(400, 300); + PIXI.offset = new PIXI.Point(0, 0); + + // TODO remove thease globals.. this.resize(this.width, this.height); this.contextLost = false; - this.stageRenderGroup = new PIXI.WebGLRenderGroup(this.gl); + //PIXI.pushShader(PIXI.defaultShader); + + this.stageRenderGroup = new PIXI.WebGLRenderGroup(this.gl, this.transparent); + // this.stageRenderGroup. = this.transparent } // constructor @@ -4468,15 +6487,6 @@ PIXI.WebGLRenderer.prototype.render = function(stage) this.__stage = stage; this.stageRenderGroup.setRenderable(stage); } - - // TODO not needed now... - // update children if need be - // best to remove first! - /*for (var i=0; i < stage.__childrenRemoved.length; i++) - { - var group = stage.__childrenRemoved[i].__renderGroup - if(group)group.removeDisplayObject(stage.__childrenRemoved[i]); - }*/ // update any textures PIXI.WebGLRenderer.updateTextures(); @@ -4499,6 +6509,10 @@ PIXI.WebGLRenderer.prototype.render = function(stage) // HACK TO TEST this.stageRenderGroup.backgroundColor = stage.backgroundColorSplit; + + PIXI.projection.x = this.width/2; + PIXI.projection.y = -this.height/2; + this.stageRenderGroup.render(PIXI.projection); // interaction @@ -4608,8 +6622,8 @@ PIXI.WebGLRenderer.destroyTexture = function(texture) * resizes the webGL view to the specified width and height * * @method resize - * @param width {number} the new width of the webGL view - * @param height {number} the new height of the webGL view + * @param width {Number} the new width of the webGL view + * @param height {Number} the new height of the webGL view */ PIXI.WebGLRenderer.prototype.resize = function(width, height) { @@ -4624,7 +6638,10 @@ PIXI.WebGLRenderer.prototype.resize = function(width, height) //var projectionMatrix = this.projectionMatrix; PIXI.projection.x = this.width/2; - PIXI.projection.y = this.height/2; + PIXI.projection.y = -this.height/2; + + //PIXI.size.x = this.width/2; + //PIXI.size.y = -this.height/2; // projectionMatrix[0] = 2/this.width; // projectionMatrix[5] = -2/this.height; @@ -4695,14 +6712,18 @@ PIXI.WebGLRenderer.prototype.handleContextRestored = function(event) * @contructor * @param gl {WebGLContext} An instance of the webGL context */ -PIXI.WebGLRenderGroup = function(gl) +PIXI.WebGLRenderGroup = function(gl, transparent) { this.gl = gl; this.root; this.backgroundColor; + this.transparent = transparent == undefined ? true : transparent; + this.batchs = []; this.toRemove = []; + console.log(this.transparent) + this.filterManager = new PIXI.WebGLFilterManager(this.transparent); } // constructor @@ -4736,19 +6757,20 @@ PIXI.WebGLRenderGroup.prototype.setRenderable = function(displayObject) * @method render * @param projection {Object} */ -PIXI.WebGLRenderGroup.prototype.render = function(projection) +PIXI.WebGLRenderGroup.prototype.render = function(projection, buffer) { PIXI.WebGLRenderer.updateTextures(); var gl = this.gl; + gl.uniform2f(PIXI.defaultShader.projectionVector, projection.x, projection.y); + + this.filterManager.begin(projection, buffer); - gl.uniform2f(PIXI.shaderProgram.projectionVector, projection.x, projection.y); gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); - // will render all the elements in the group var renderable; - + for (var i=0; i < this.batchs.length; i++) { @@ -4759,61 +6781,12 @@ PIXI.WebGLRenderGroup.prototype.render = function(projection) continue; } - // non sprite batch.. - var worldVisible = renderable.vcount === PIXI.visibleCount; - - if(renderable instanceof PIXI.TilingSprite) - { - if(worldVisible)this.renderTilingSprite(renderable, projection); - } - else if(renderable instanceof PIXI.Strip) - { - if(worldVisible)this.renderStrip(renderable, projection); - } - else if(renderable instanceof PIXI.Graphics) - { - if(worldVisible && renderable.renderable) PIXI.WebGLGraphics.renderGraphics(renderable, projection);//, projectionMatrix); - } - else if(renderable instanceof PIXI.FilterBlock) - { - /* - * for now only masks are supported.. - */ - if(renderable.open) - { - gl.enable(gl.STENCIL_TEST); - - gl.colorMask(false, false, false, false); - gl.stencilFunc(gl.ALWAYS,1,0xff); - gl.stencilOp(gl.KEEP,gl.KEEP,gl.REPLACE); - - PIXI.WebGLGraphics.renderGraphics(renderable.mask, projection); - - gl.colorMask(true, true, true, false); - gl.stencilFunc(gl.NOTEQUAL,0,0xff); - gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP); - } - else - { - gl.disable(gl.STENCIL_TEST); - } - } + // render special + this.renderSpecial(renderable, projection); } } -/** - * Renders the stage to its webgl view - * - * @method handleFilter - * @param filter {FilterBlock} - * @private - */ -PIXI.WebGLRenderGroup.prototype.handleFilter = function(filter, projection) -{ - -} - /** * Renders a specific displayObject * @@ -4822,13 +6795,14 @@ PIXI.WebGLRenderGroup.prototype.handleFilter = function(filter, projection) * @param projection {Object} * @private */ -PIXI.WebGLRenderGroup.prototype.renderSpecific = function(displayObject, projection) +PIXI.WebGLRenderGroup.prototype.renderSpecific = function(displayObject, projection, buffer) { PIXI.WebGLRenderer.updateTextures(); - var gl = this.gl; - gl.uniform2f(PIXI.shaderProgram.projectionVector, projection.x, projection.y); + gl.uniform2f(PIXI.defaultShader.projectionVector, projection.x, projection.y); + + this.filterManager.begin(projection, buffer); // to do! // render part of the scene... @@ -4848,11 +6822,13 @@ PIXI.WebGLRenderGroup.prototype.renderSpecific = function(displayObject, project var nextRenderable = displayObject.first; while(nextRenderable._iNext) { - nextRenderable = nextRenderable._iNext; if(nextRenderable.renderable && nextRenderable.__renderGroup)break; + nextRenderable = nextRenderable._iNext; } var startBatch = nextRenderable.batch; + //console.log(nextRenderable); + //console.log(renderable) if(nextRenderable instanceof PIXI.Sprite) { startBatch = nextRenderable.batch; @@ -4882,13 +6858,11 @@ PIXI.WebGLRenderGroup.prototype.renderSpecific = function(displayObject, project } // Get the LAST renderable object - var lastRenderable = displayObject; - var endBatch; - var lastItem = displayObject; - while(lastItem.children.length > 0) + var lastRenderable = displayObject.last; + while(lastRenderable._iPrev) { - lastItem = lastItem.children[lastItem.children.length-1]; - if(lastItem.renderable)lastRenderable = lastItem; + if(lastRenderable.renderable && lastRenderable.__renderGroup)break; + lastRenderable = lastRenderable._iNext; } if(lastRenderable instanceof PIXI.Sprite) @@ -4917,6 +6891,7 @@ PIXI.WebGLRenderGroup.prototype.renderSpecific = function(displayObject, project endBatch = lastRenderable; } + //console.log(endBatch); // TODO - need to fold this up a bit! if(startBatch == endBatch) @@ -4982,8 +6957,10 @@ PIXI.WebGLRenderGroup.prototype.renderSpecific = function(displayObject, project */ PIXI.WebGLRenderGroup.prototype.renderSpecial = function(renderable, projection) { + var worldVisible = renderable.vcount === PIXI.visibleCount + if(renderable instanceof PIXI.TilingSprite) { if(worldVisible)this.renderTilingSprite(renderable, projection); @@ -5002,29 +6979,76 @@ PIXI.WebGLRenderGroup.prototype.renderSpecial = function(renderable, projection) } else if(renderable instanceof PIXI.FilterBlock) { - /* - * for now only masks are supported.. - */ + this.handleFilterBlock(renderable, projection); + } +} - var gl = PIXI.gl; +flip = false; +var maskStack = []; +var maskPosition = 0; - if(renderable.open) +//var usedMaskStack = []; + +PIXI.WebGLRenderGroup.prototype.handleFilterBlock = function(filterBlock, projection) +{ + /* + * for now only masks are supported.. + */ + var gl = PIXI.gl; + + if(filterBlock.open) + { + if(filterBlock.data instanceof Array) { - gl.enable(gl.STENCIL_TEST); - - gl.colorMask(false, false, false, false); - gl.stencilFunc(gl.ALWAYS,1,0xff); - gl.stencilOp(gl.KEEP,gl.KEEP,gl.REPLACE); - - PIXI.WebGLGraphics.renderGraphics(renderable.mask, projection); + this.filterManager.pushFilter(filterBlock); + // ok so.. + + } + else + { + maskPosition++; + + maskStack.push(filterBlock) + + gl.enable(gl.STENCIL_TEST); + + gl.colorMask(false, false, false, false); + + gl.stencilFunc(gl.ALWAYS,1,1); + gl.stencilOp(gl.KEEP,gl.KEEP,gl.INCR); + + PIXI.WebGLGraphics.renderGraphics(filterBlock.data, projection); - // we know this is a render texture so enable alpha too.. gl.colorMask(true, true, true, true); - gl.stencilFunc(gl.NOTEQUAL,0,0xff); + gl.stencilFunc(gl.NOTEQUAL,0,maskStack.length); gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP); } + } + else + { + if(filterBlock.data instanceof Array) + { + this.filterManager.popFilter(); + } else { + var maskData = maskStack.pop(filterBlock) + + + if(maskData) + { + gl.colorMask(false, false, false, false); + + gl.stencilFunc(gl.ALWAYS,1,1); + gl.stencilOp(gl.KEEP,gl.KEEP,gl.DECR); + + PIXI.WebGLGraphics.renderGraphics(maskData.data, projection); + + gl.colorMask(true, true, true, true); + gl.stencilFunc(gl.NOTEQUAL,0,maskStack.length); + gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP); + }; + gl.disable(gl.STENCIL_TEST); } } @@ -5090,7 +7114,7 @@ PIXI.WebGLRenderGroup.prototype.addFilterBlocks = function(start, end) * It keeps going back until it finds a sprite or the stage */ var previousRenderable = start; - while(previousRenderable != this.root) + while(previousRenderable != this.root.first) { previousRenderable = previousRenderable._iPrev; if(previousRenderable.renderable && previousRenderable.__renderGroup)break; @@ -5104,7 +7128,7 @@ PIXI.WebGLRenderGroup.prototype.addFilterBlocks = function(start, end) * scene graph */ var previousRenderable2 = end; - while(previousRenderable2 != this.root) + while(previousRenderable2 != this.root.first) { previousRenderable2 = previousRenderable2._iPrev; if(previousRenderable2.renderable && previousRenderable2.__renderGroup)break; @@ -5476,6 +7500,7 @@ PIXI.WebGLRenderGroup.prototype.removeObject = function(displayObject) } } + /** * Initializes a tiling sprite * @@ -5546,25 +7571,26 @@ PIXI.WebGLRenderGroup.prototype.initTilingSprite = function(sprite) PIXI.WebGLRenderGroup.prototype.renderStrip = function(strip, projection) { var gl = this.gl; - var shaderProgram = PIXI.shaderProgram; -// mat - //var mat4Real = PIXI.mat3.toMat4(strip.worldTransform); - //PIXI.mat4.transpose(mat4Real); - //PIXI.mat4.multiply(projectionMatrix, mat4Real, mat4Real ) + PIXI.activateStripShader(); + + var shader = PIXI.stripShader; + + var program = shader.program; - gl.useProgram(PIXI.stripShaderProgram); - var m = PIXI.mat3.clone(strip.worldTransform); PIXI.mat3.transpose(m); +// console.log(projection) // set the matrix transform for the - gl.uniformMatrix3fv(PIXI.stripShaderProgram.translationMatrix, false, m); - gl.uniform2f(PIXI.stripShaderProgram.projectionVector, projection.x, projection.y); - gl.uniform1f(PIXI.stripShaderProgram.alpha, strip.worldAlpha); + gl.uniformMatrix3fv(shader.translationMatrix, false, m); + gl.uniform2f(shader.projectionVector, projection.x, projection.y); + gl.uniform2f(shader.offsetVector, -PIXI.offset.x, -PIXI.offset.y); + + gl.uniform1f(shader.alpha, strip.worldAlpha); -/* + /* if(strip.blendMode == PIXI.blendModes.NORMAL) { gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); @@ -5575,23 +7601,22 @@ PIXI.WebGLRenderGroup.prototype.renderStrip = function(strip, projection) } */ - + //console.log("!!") if(!strip.dirty) - { - + { gl.bindBuffer(gl.ARRAY_BUFFER, strip._vertexBuffer); gl.bufferSubData(gl.ARRAY_BUFFER, 0, strip.verticies) - gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, 2, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 0, 0); // update the uvs gl.bindBuffer(gl.ARRAY_BUFFER, strip._uvBuffer); - gl.vertexAttribPointer(shaderProgram.textureCoordAttribute, 2, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(shader.aTextureCoord, 2, gl.FLOAT, false, 0, 0); gl.activeTexture(gl.TEXTURE0); gl.bindTexture(gl.TEXTURE_2D, strip.texture.baseTexture._glTexture); gl.bindBuffer(gl.ARRAY_BUFFER, strip._colorBuffer); - gl.vertexAttribPointer(shaderProgram.colorAttribute, 1, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(shader.colorAttribute, 1, gl.FLOAT, false, 0, 0); // dont need to upload! gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, strip._indexBuffer); @@ -5601,30 +7626,30 @@ PIXI.WebGLRenderGroup.prototype.renderStrip = function(strip, projection) strip.dirty = false; gl.bindBuffer(gl.ARRAY_BUFFER, strip._vertexBuffer); gl.bufferData(gl.ARRAY_BUFFER, strip.verticies, gl.STATIC_DRAW) - gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, 2, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 0, 0); // update the uvs gl.bindBuffer(gl.ARRAY_BUFFER, strip._uvBuffer); gl.bufferData(gl.ARRAY_BUFFER, strip.uvs, gl.STATIC_DRAW) - gl.vertexAttribPointer(shaderProgram.textureCoordAttribute, 2, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(shader.aTextureCoord, 2, gl.FLOAT, false, 0, 0); gl.activeTexture(gl.TEXTURE0); gl.bindTexture(gl.TEXTURE_2D, strip.texture.baseTexture._glTexture); - + // console.log(strip.texture.baseTexture._glTexture) gl.bindBuffer(gl.ARRAY_BUFFER, strip._colorBuffer); gl.bufferData(gl.ARRAY_BUFFER, strip.colors, gl.STATIC_DRAW) - gl.vertexAttribPointer(shaderProgram.colorAttribute, 1, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(shader.colorAttribute, 1, gl.FLOAT, false, 0, 0); // dont need to upload! gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, strip._indexBuffer); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, strip.indices, gl.STATIC_DRAW); } - //console.log(gl.TRIANGLE_STRIP); gl.drawElements(gl.TRIANGLE_STRIP, strip.indices.length, gl.UNSIGNED_SHORT, 0); - gl.useProgram(PIXI.shaderProgram); + PIXI.deactivateStripShader(); + //gl.useProgram(PIXI.currentProgram); } /** @@ -5638,6 +7663,8 @@ PIXI.WebGLRenderGroup.prototype.renderStrip = function(strip, projection) PIXI.WebGLRenderGroup.prototype.renderTilingSprite = function(sprite, projectionMatrix) { var gl = this.gl; + + var shaderProgram = PIXI.shaderProgram; var tilePosition = sprite.tilePosition; @@ -5705,156 +7732,77 @@ PIXI.WebGLRenderGroup.prototype.initStrip = function(strip) */ -/* - * the default suoer fast shader! - */ +PIXI.initDefaultShaders = function() +{ + PIXI.primitiveShader = new PIXI.PrimitiveShader(); + PIXI.primitiveShader.init(); -PIXI.shaderFragmentSrc = [ - "precision mediump float;", - "varying vec2 vTextureCoord;", - "varying float vColor;", - "uniform sampler2D uSampler;", - "void main(void) {", - "gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));", - "gl_FragColor = gl_FragColor * vColor;", - "}" -]; + PIXI.stripShader = new PIXI.StripShader(); + PIXI.stripShader.init(); -PIXI.shaderVertexSrc = [ - "attribute vec2 aVertexPosition;", - "attribute vec2 aTextureCoord;", - "attribute float aColor;", - //"uniform mat4 uMVMatrix;", + PIXI.defaultShader = new PIXI.PixiShader(); + PIXI.defaultShader.init(); + + var gl = PIXI.gl; + var shaderProgram = PIXI.defaultShader.program; + + + gl.useProgram(shaderProgram); - "uniform vec2 projectionVector;", - "varying vec2 vTextureCoord;", - "varying float vColor;", - "void main(void) {", - // "gl_Position = uMVMatrix * vec4(aVertexPosition, 1.0, 1.0);", - "gl_Position = vec4( aVertexPosition.x / projectionVector.x -1.0, aVertexPosition.y / -projectionVector.y + 1.0 , 0.0, 1.0);", - "vTextureCoord = aTextureCoord;", - "vColor = aColor;", - "}" -]; + gl.enableVertexAttribArray(PIXI.defaultShader.aVertexPosition); + gl.enableVertexAttribArray(PIXI.defaultShader.colorAttribute); + gl.enableVertexAttribArray(PIXI.defaultShader.aTextureCoord); +} + +PIXI.activatePrimitiveShader = function() +{ + var gl = PIXI.gl; + + gl.useProgram(PIXI.primitiveShader.program); + + gl.disableVertexAttribArray(PIXI.defaultShader.aVertexPosition); + gl.disableVertexAttribArray(PIXI.defaultShader.colorAttribute); + gl.disableVertexAttribArray(PIXI.defaultShader.aTextureCoord); + + gl.enableVertexAttribArray(PIXI.primitiveShader.aVertexPosition); + gl.enableVertexAttribArray(PIXI.primitiveShader.colorAttribute); +} + +PIXI.deactivatePrimitiveShader = function() +{ + var gl = PIXI.gl; + + gl.useProgram(PIXI.defaultShader.program); + + gl.disableVertexAttribArray(PIXI.primitiveShader.aVertexPosition); + gl.disableVertexAttribArray(PIXI.primitiveShader.colorAttribute); + + gl.enableVertexAttribArray(PIXI.defaultShader.aVertexPosition); + gl.enableVertexAttribArray(PIXI.defaultShader.colorAttribute); + gl.enableVertexAttribArray(PIXI.defaultShader.aTextureCoord); + +} + +PIXI.activateStripShader = function() +{ + var gl = PIXI.gl; + + gl.useProgram(PIXI.stripShader.program); + // gl.disableVertexAttribArray(PIXI.defaultShader.aTextureCoord); +} + +PIXI.deactivateStripShader = function() +{ + var gl = PIXI.gl; + + gl.useProgram(PIXI.defaultShader.program); + //gl.enableVertexAttribArray(PIXI.defaultShader.aTextureCoord); +} /* - * the triangle strip shader.. - */ -PIXI.stripShaderFragmentSrc = [ - "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;", - "}" -]; - - -PIXI.stripShaderVertexSrc = [ - "attribute vec2 aVertexPosition;", - "attribute vec2 aTextureCoord;", - "attribute float aColor;", - "uniform mat3 translationMatrix;", - "uniform vec2 projectionVector;", - "varying vec2 vTextureCoord;", - "varying float vColor;", - "void main(void) {", - "vec3 v = translationMatrix * vec3(aVertexPosition, 1.0);", - "gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);", - "vTextureCoord = aTextureCoord;", - "vColor = aColor;", - "}" -]; - - -/* - * primitive shader.. - */ - -PIXI.primitiveShaderFragmentSrc = [ - "precision mediump float;", - "varying vec4 vColor;", - "void main(void) {", - "gl_FragColor = vColor;", - "}" -]; - -PIXI.primitiveShaderVertexSrc = [ - "attribute vec2 aVertexPosition;", - "attribute vec4 aColor;", - "uniform mat3 translationMatrix;", - "uniform vec2 projectionVector;", - "uniform float alpha;", - "varying vec4 vColor;", - "void main(void) {", - "vec3 v = translationMatrix * vec3(aVertexPosition, 1.0);", - "gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);", - "vColor = aColor * alpha;", - "}" -]; - -PIXI.initPrimitiveShader = function() -{ - var gl = PIXI.gl; - - var shaderProgram = PIXI.compileProgram(PIXI.primitiveShaderVertexSrc, PIXI.primitiveShaderFragmentSrc) - - gl.useProgram(shaderProgram); - - shaderProgram.vertexPositionAttribute = gl.getAttribLocation(shaderProgram, "aVertexPosition"); - shaderProgram.colorAttribute = gl.getAttribLocation(shaderProgram, "aColor"); - - shaderProgram.projectionVector = gl.getUniformLocation(shaderProgram, "projectionVector"); - shaderProgram.translationMatrix = gl.getUniformLocation(shaderProgram, "translationMatrix"); - - shaderProgram.alpha = gl.getUniformLocation(shaderProgram, "alpha"); - - PIXI.primitiveProgram = shaderProgram; -} - -PIXI.initDefaultShader = function() -{ - var gl = this.gl; - var shaderProgram = PIXI.compileProgram(PIXI.shaderVertexSrc, PIXI.shaderFragmentSrc) - - gl.useProgram(shaderProgram); - - shaderProgram.vertexPositionAttribute = gl.getAttribLocation(shaderProgram, "aVertexPosition"); - shaderProgram.projectionVector = gl.getUniformLocation(shaderProgram, "projectionVector"); - shaderProgram.textureCoordAttribute = gl.getAttribLocation(shaderProgram, "aTextureCoord"); - shaderProgram.colorAttribute = gl.getAttribLocation(shaderProgram, "aColor"); - - // shaderProgram.mvMatrixUniform = gl.getUniformLocation(shaderProgram, "uMVMatrix"); - shaderProgram.samplerUniform = gl.getUniformLocation(shaderProgram, "uSampler"); - - PIXI.shaderProgram = shaderProgram; -} - -PIXI.initDefaultStripShader = function() -{ - var gl = this.gl; - var shaderProgram = PIXI.compileProgram(PIXI.stripShaderVertexSrc, PIXI.stripShaderFragmentSrc) - - gl.useProgram(shaderProgram); - - shaderProgram.vertexPositionAttribute = gl.getAttribLocation(shaderProgram, "aVertexPosition"); - shaderProgram.projectionVector = gl.getUniformLocation(shaderProgram, "projectionVector"); - shaderProgram.textureCoordAttribute = gl.getAttribLocation(shaderProgram, "aTextureCoord"); - shaderProgram.translationMatrix = gl.getUniformLocation(shaderProgram, "translationMatrix"); - shaderProgram.alpha = gl.getUniformLocation(shaderProgram, "alpha"); - - shaderProgram.colorAttribute = gl.getAttribLocation(shaderProgram, "aColor"); - - shaderProgram.projectionVector = gl.getUniformLocation(shaderProgram, "projectionVector"); - - shaderProgram.samplerUniform = gl.getUniformLocation(shaderProgram, "uSampler"); - - PIXI.stripShaderProgram = shaderProgram; -} +SHADER COMPILER HELPERS +*/ PIXI.CompileVertexShader = function(gl, shaderSrc) { @@ -5874,7 +7822,7 @@ PIXI._CompileShader = function(gl, shaderSrc, shaderType) gl.compileShader(shader); if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { - alert(gl.getShaderInfoLog(shader)); + console.log(gl.getShaderInfoLog(shader)); return null; } @@ -5895,49 +7843,19 @@ PIXI.compileProgram = function(vertexSrc, fragmentSrc) gl.linkProgram(shaderProgram); if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) { - alert("Could not initialise shaders"); + console.log("Could not initialise shaders"); } return shaderProgram; } - -PIXI.activateDefaultShader = function() -{ - var gl = PIXI.gl; - var shaderProgram = PIXI.shaderProgram; - - gl.useProgram(shaderProgram); - - - gl.enableVertexAttribArray(shaderProgram.vertexPositionAttribute); - gl.enableVertexAttribArray(shaderProgram.textureCoordAttribute); - gl.enableVertexAttribArray(shaderProgram.colorAttribute); -} - - - -PIXI.activatePrimitiveShader = function() -{ - var gl = PIXI.gl; - - gl.disableVertexAttribArray(PIXI.shaderProgram.textureCoordAttribute); - gl.disableVertexAttribArray(PIXI.shaderProgram.colorAttribute); - - gl.useProgram(PIXI.primitiveProgram); - - gl.enableVertexAttribArray(PIXI.primitiveProgram.vertexPositionAttribute); - gl.enableVertexAttribArray(PIXI.primitiveProgram.colorAttribute); -} - - /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ /** * A Text Object will create a line(s) of text using bitmap font. To split a line you can use "\n", "\r" or "\r\n" - * You can generate the fnt files using + * You can generate the fnt files using * http://www.angelcode.com/products/bmfont/ for windows or * http://www.bmglyph.com/ for mac. * @@ -6027,7 +7945,7 @@ PIXI.BitmapText.prototype.updateText = function() prevCharCode = null; continue; } - + var charData = data.chars[charCode]; if(!charData) continue; @@ -6068,7 +7986,7 @@ PIXI.BitmapText.prototype.updateText = function() this.addChild(c); } - this.width = maxLineWidth * scale; + this.width = pos.x * scale; this.height = (pos.y + data.lineHeight) * scale; }; @@ -6090,7 +8008,7 @@ PIXI.BitmapText.prototype.updateTransform = function() this.dirty = false; } - + PIXI.DisplayObjectContainer.prototype.updateTransform.call(this); }; @@ -6112,9 +8030,9 @@ PIXI.BitmapText.fonts = {}; * @param [style.fill="black"] {Object} A canvas fillstyle that will be used on the text eg "red", "#00FF00" * @param [style.align="left"] {String} An alignment of the multiline text ("left", "center" or "right") * @param [style.stroke] {String} A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00" - * @param [style.strokeThickness=0] {number} A number that represents the thickness of the stroke. Default is 0 (no stroke) + * @param [style.strokeThickness=0] {Number} A number that represents the thickness of the stroke. Default is 0 (no stroke) * @param [style.wordWrap=false] {Boolean} Indicates if word wrap should be used - * @param [style.wordWrapWidth=100] {number} The width at which text will wrap + * @param [style.wordWrapWidth=100] {Number} The width at which text will wrap */ PIXI.Text = function(text, style) { @@ -6124,7 +8042,7 @@ PIXI.Text = function(text, style) this.setText(text); this.setStyle(style); - + this.updateText(); this.dirty = false; }; @@ -6142,9 +8060,9 @@ PIXI.Text.prototype.constructor = PIXI.Text; * @param [style.fill="black"] {Object} A canvas fillstyle that will be used on the text eg "red", "#00FF00" * @param [style.align="left"] {String} An alignment of the multiline text ("left", "center" or "right") * @param [style.stroke="black"] {String} A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00" - * @param [style.strokeThickness=0] {number} A number that represents the thickness of the stroke. Default is 0 (no stroke) + * @param [style.strokeThickness=0] {Number} A number that represents the thickness of the stroke. Default is 0 (no stroke) * @param [style.wordWrap=false] {Boolean} Indicates if word wrap should be used - * @param [style.wordWrapWidth=100] {number} The width at which text will wrap + * @param [style.wordWrapWidth=100] {Number} The width at which text will wrap */ PIXI.Text.prototype.setStyle = function(style) { @@ -6166,7 +8084,7 @@ PIXI.Text.prototype.setStyle = function(style) * @methos setText * @param {String} text The copy that you would like the text to display */ -PIXI.Sprite.prototype.setText = function(text) +PIXI.Text.prototype.setText = function(text) { this.text = text.toString() || " "; this.dirty = true; @@ -6181,9 +8099,9 @@ PIXI.Sprite.prototype.setText = function(text) PIXI.Text.prototype.updateText = function() { this.context.font = this.style.font; - + var outputText = this.text; - + // word wrap // preserve original text if(this.style.wordWrap)outputText = this.wordWrap(this.text); @@ -6201,7 +8119,7 @@ PIXI.Text.prototype.updateText = function() maxLineWidth = Math.max(maxLineWidth, lineWidth); } this.canvas.width = maxLineWidth + this.style.strokeThickness; - + //calculate text height var lineHeight = this.determineFontHeight("font: " + this.style.font + ";") + this.style.strokeThickness; this.canvas.height = lineHeight * lines.length; @@ -6209,7 +8127,7 @@ PIXI.Text.prototype.updateText = function() //set canvas text styles this.context.fillStyle = this.style.fill; this.context.font = this.style.font; - + this.context.strokeStyle = this.style.stroke; this.context.lineWidth = this.style.strokeThickness; @@ -6219,7 +8137,7 @@ PIXI.Text.prototype.updateText = function() for (i = 0; i < lines.length; i++) { var linePosition = new PIXI.Point(this.style.strokeThickness / 2, this.style.strokeThickness / 2 + i * lineHeight); - + if(this.style.align == "right") { linePosition.x += maxLineWidth - lineWidths[i]; @@ -6239,7 +8157,7 @@ PIXI.Text.prototype.updateText = function() this.context.fillText(lines[i], linePosition.x, linePosition.y); } } - + this.updateTexture(); }; @@ -6255,10 +8173,10 @@ PIXI.Text.prototype.updateTexture = function() this.texture.baseTexture.height = this.canvas.height; this.texture.frame.width = this.canvas.width; this.texture.frame.height = this.canvas.height; - + this._width = this.canvas.width; this._height = this.canvas.height; - + PIXI.texturesToUpdate.push(this.texture.baseTexture); }; @@ -6272,10 +8190,10 @@ PIXI.Text.prototype.updateTransform = function() { if(this.dirty) { - this.updateText(); + this.updateText(); this.dirty = false; } - + PIXI.Sprite.prototype.updateTransform.call(this); }; @@ -6287,12 +8205,12 @@ PIXI.Text.prototype.updateTransform = function() * @param fontStyle {Object} * @private */ -PIXI.Text.prototype.determineFontHeight = function(fontStyle) +PIXI.Text.prototype.determineFontHeight = function(fontStyle) { // build a little reference dictionary so if the font style has been used return a // cached version... var result = PIXI.Text.heightCache[fontStyle]; - + if(!result) { var body = document.getElementsByTagName("body")[0]; @@ -6301,18 +8219,19 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle) dummy.appendChild(dummyText); dummy.setAttribute("style", fontStyle + ';position:absolute;top:0;left:0'); body.appendChild(dummy); - + result = dummy.offsetHeight; PIXI.Text.heightCache[fontStyle] = result; - + body.removeChild(dummy); } - + return result; }; /** - * A Text Object will apply wordwrap + * Applies newlines to a string to have it optimally fit into the horizontal + * bounds set by the Text object's wordWrapWidth property. * * @method wordWrap * @param text {String} @@ -6320,48 +8239,37 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle) */ PIXI.Text.prototype.wordWrap = function(text) { - // search good wrap position - var searchWrapPos = function(ctx, text, start, end, wrapWidth) - { - var p = Math.floor((end-start) / 2) + start; - if(p == start) { - return 1; - } - - if(ctx.measureText(text.substring(0,p)).width <= wrapWidth) - { - if(ctx.measureText(text.substring(0,p+1)).width > wrapWidth) - { - return p; - } - else - { - return arguments.callee(ctx, text, p, end, wrapWidth); - } - } - else - { - return arguments.callee(ctx, text, start, p, wrapWidth); - } - }; - - var lineWrap = function(ctx, text, wrapWidth) - { - if(ctx.measureText(text).width <= wrapWidth || text.length < 1) - { - return text; - } - var pos = searchWrapPos(ctx, text, 0, text.length, wrapWidth); - return text.substring(0, pos) + "\n" + arguments.callee(ctx, text.substring(pos), wrapWidth); - }; - + // Greedy wrapping algorithm that will wrap words as the line grows longer + // than its horizontal bounds. var result = ""; var lines = text.split("\n"); for (var i = 0; i < lines.length; i++) { - result += lineWrap(this.context, lines[i], this.style.wordWrapWidth) + "\n"; + var spaceLeft = this.style.wordWrapWidth; + var words = lines[i].split(" "); + for (var j = 0; j < words.length; j++) + { + var wordWidth = this.context.measureText(words[j]).width; + var wordWidthWithSpace = wordWidth + this.context.measureText(" ").width; + if(wordWidthWithSpace > spaceLeft) + { + // Skip printing the newline if it's the first word of the line that is + // greater than the word wrap width. + if(j > 0) + { + result += "\n"; + } + result += words[j] + " "; + spaceLeft = this.style.wordWrapWidth - wordWidth; + } + else + { + spaceLeft -= wordWidthWithSpace; + result += words[j] + " "; + } + } + result += "\n"; } - return result; }; @@ -6377,7 +8285,7 @@ PIXI.Text.prototype.destroy = function(destroyTexture) { this.texture.destroy(); } - + }; PIXI.Text.heightCache = {}; @@ -6446,19 +8354,19 @@ PIXI.BaseTexture = function(source) this.hasLoaded = true; this.width = this.source.width; this.height = this.source.height; - + PIXI.texturesToUpdate.push(this); } else { - + var scope = this; this.source.onload = function(){ - + scope.hasLoaded = true; scope.width = scope.source.width; scope.height = scope.source.height; - + // add it to somewhere... PIXI.texturesToUpdate.push(scope); scope.dispatchEvent( { type: 'loaded', content: scope } ); @@ -6471,7 +8379,7 @@ PIXI.BaseTexture = function(source) this.hasLoaded = true; this.width = this.source.width; this.height = this.source.height; - + PIXI.texturesToUpdate.push(this); } @@ -6511,7 +8419,7 @@ PIXI.BaseTexture.fromImage = function(imageUrl, crossorigin) { // new Image() breaks tex loading in some versions of Chrome. // See https://code.google.com/p/chromium/issues/detail?id=238071 - var image = new Image();//document.createElement('img'); + var image = new Image();//document.createElement('img'); if (crossorigin) { image.crossOrigin = ''; @@ -6539,7 +8447,7 @@ PIXI.FrameCache = {}; * @uses EventTarget * @constructor * @param baseTexture {BaseTexture} The base texture source to create the texture from - * @param frmae {Rectangle} The rectangle frame of the texture to show + * @param frame {Rectangle} The rectangle frame of the texture to show */ PIXI.Texture = function(baseTexture, frame) { @@ -6584,7 +8492,7 @@ PIXI.Texture = function(baseTexture, frame) { if(this.noFrame)frame = new PIXI.Rectangle(0,0, baseTexture.width, baseTexture.height); //console.log(frame) - + this.setFrame(frame); } else @@ -6663,13 +8571,13 @@ PIXI.Texture.prototype.setFrame = function(frame) PIXI.Texture.fromImage = function(imageUrl, crossorigin) { var texture = PIXI.TextureCache[imageUrl]; - + if(!texture) { texture = new PIXI.Texture(PIXI.BaseTexture.fromImage(imageUrl, crossorigin)); PIXI.TextureCache[imageUrl] = texture; } - + return texture; } @@ -6719,7 +8627,7 @@ PIXI.Texture.addTextureToCache = function(texture, id) } /** - * Remove a texture from the textureCache. + * Remove a texture from the textureCache. * * @static * @method removeTextureFromCache @@ -6766,8 +8674,8 @@ PIXI.Texture.frameUpdates = []; @class RenderTexture @extends Texture @constructor - @param width {number} The width of the render texture - @param height {number} The height of the render texture + @param width {Number} The width of the render texture + @param height {Number} The height of the render texture */ PIXI.RenderTexture = function(width, height) { @@ -6830,12 +8738,10 @@ PIXI.RenderTexture.prototype.initWebGL = function() 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); + this.projection = new PIXI.Point(this.width/2 , -this.height/2); // set the correct render function.. this.render = this.renderWebGL; - - } @@ -6848,7 +8754,7 @@ PIXI.RenderTexture.prototype.resize = function(width, height) if(PIXI.gl) { this.projection.x = this.width/2 - this.projection.y = this.height/2; + this.projection.y = -this.height/2; var gl = PIXI.gl; gl.bindTexture(gl.TEXTURE_2D, this.baseTexture._glTexture); @@ -6912,9 +8818,8 @@ PIXI.RenderTexture.prototype.renderWebGL = function(displayObject, position, cle displayObject.worldTransform = PIXI.mat3.create();//sthis.indetityMatrix; // modify to flip... displayObject.worldTransform[4] = -1; - displayObject.worldTransform[5] = this.projection.y * 2; + displayObject.worldTransform[5] = this.projection.y * -2; - if(position) { displayObject.worldTransform[2] = position.x; @@ -6935,20 +8840,20 @@ PIXI.RenderTexture.prototype.renderWebGL = function(displayObject, position, cle { if(displayObject == renderGroup.root) { - renderGroup.render(this.projection); + renderGroup.render(this.projection, this.glFramebuffer); } else { - renderGroup.renderSpecific(displayObject, this.projection); + renderGroup.renderSpecific(displayObject, this.projection, this.glFramebuffer); } } else { if(!this.renderGroup)this.renderGroup = new PIXI.WebGLRenderGroup(gl); this.renderGroup.setRenderable(displayObject); - this.renderGroup.render(this.projection); + this.renderGroup.render(this.projection, this.glFramebuffer); } - + displayObject.worldTransform = originalWorldTransform; } @@ -6989,7 +8894,6 @@ PIXI.RenderTexture.prototype.renderCanvas = function(displayObject, position, cl // PIXI.texturesToUpdate.push(this.baseTexture); } - /** * https://github.com/mrdoob/eventtarget.js/ * THankS mr DOob! @@ -7010,14 +8914,14 @@ PIXI.RenderTexture.prototype.renderCanvas = function(displayObject, position, cl PIXI.EventTarget = function () { var listeners = {}; - + this.addEventListener = this.on = function ( type, listener ) { - - + + if ( listeners[ type ] === undefined ) { listeners[ type ] = []; - + } if ( listeners[ type ].indexOf( listener ) === - 1 ) { @@ -7028,11 +8932,17 @@ PIXI.EventTarget = function () { }; this.dispatchEvent = this.emit = function ( event ) { - - for ( var listener in listeners[ event.type ] ) { - listeners[ event.type ][ listener ]( event ); - + if ( !listeners[ event.type ] || !listeners[ event.type ].length ) { + + return; + + } + + for(var i = 0, l = listeners[ event.type ].length; i < l; i++) { + + listeners[ event.type ][ i ]( event ); + } }; @@ -7055,7 +8965,7 @@ PIXI.EventTarget = function () { PolyK library url: http://polyk.ivank.net Released under MIT licence. - + Copyright (c) 2012 Ivan Kuckir Permission is hereby granted, free of charge, to any person @@ -7079,8 +8989,8 @@ PIXI.EventTarget = function () { FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - This is an amazing lib! - + This is an amazing lib! + slightly modified by mat groves (matgroves.com); */ @@ -7096,13 +9006,13 @@ PIXI.PolyK = {}; PIXI.PolyK.Triangulate = function(p) { var sign = true; - + var n = p.length>>1; if(n<3) return []; var tgs = []; var avl = []; for(var i=0; i 3) @@ -7110,11 +9020,11 @@ PIXI.PolyK.Triangulate = function(p) var i0 = avl[(i+0)%al]; var i1 = avl[(i+1)%al]; var i2 = avl[(i+2)%al]; - + var ax = p[2*i0], ay = p[2*i0+1]; var bx = p[2*i1], by = p[2*i1+1]; var cx = p[2*i2], cy = p[2*i2+1]; - + var earFound = false; if(PIXI.PolyK._convex(ax, ay, bx, by, cx, cy, sign)) { @@ -7133,7 +9043,7 @@ PIXI.PolyK.Triangulate = function(p) al--; i = 0; } - else if(i++ > 3*al) + else if(i++ > 3*al) { // need to flip flip reverse it! // reset! @@ -7142,17 +9052,17 @@ PIXI.PolyK.Triangulate = function(p) var tgs = []; avl = []; for(var i=0; i 0 && this._container.first._iNext) - { - var currentNode = this._container.first._iNext; - - do - { - if (currentNode.alive) - { - args[0] = currentNode; - callback.apply(callbackContext, args); - } - - currentNode = currentNode._iNext; - } - while (currentNode != this._container.last._iNext); - - } + this.iterate('alive', true, Phaser.Group.RETURN_TOTAL, callback, callbackContext, args); }, @@ -10364,23 +12382,121 @@ Phaser.Group.prototype = { var args = Array.prototype.splice.call(arguments, 2); args.unshift(null); + this.iterate('alive', false, Phaser.Group.RETURN_TOTAL, callback, callbackContext, args); + + }, + + /** + * Call this function to sort the group according to a particular value and order. + * For example to depth sort Sprites for Zelda-style game you might call `group.sort('y', Phaser.Group.SORT_ASCENDING)` at the bottom of your `State.update()`. + * + * @method Phaser.Group#sort + * @param {string} [index='y'] - The `string` name of the property you want to sort on. + * @param {number} [order=Phaser.Group.SORT_ASCENDING] - The `Group` constant that defines the sort order. Possible values are Phaser.Group.SORT_ASCENDING and Phaser.Group.SORT_DESCENDING. + */ + sort: function (index, order) { + + if (typeof index === 'undefined') { index = 'y'; } + if (typeof order === 'undefined') { order = Phaser.Group.SORT_ASCENDING; } + + var swapped; + var temp; + + do { + + swapped = false; + + for (var i = 0, len = this._container.children.length - 1; i < len; i++) + { + if (order == Phaser.Group.SORT_ASCENDING) + { + if (this._container.children[i][index] > this._container.children[i + 1][index]) + { + this.swap(this.getAt(i), this.getAt(i + 1)); + temp = this._container.children[i]; + this._container.children[i] = this._container.children[i + 1]; + this._container.children[i + 1] = temp; + swapped = true; + } + } + else + { + if (this._container.children[i][index] < this._container.children[i + 1][index]) + { + this.swap(this.getAt(i), this.getAt(i + 1)); + temp = this._container.children[i]; + this._container.children[i] = this._container.children[i + 1]; + this._container.children[i + 1] = temp; + swapped = true; + } + } + } + } while (swapped); + + }, + + /** + * Iterates over the children of the Group. When a child has a property matching key that equals the given value, it is considered as a match. + * Matched children can be sent to the optional callback, or simply returned or counted. + * You can add as many callback parameters as you like, which will all be passed to the callback along with the child, after the callbackContext parameter. + * + * @method Phaser.Group#iterate + * @param {string} key - The child property to check, i.e. 'exists', 'alive', 'health' + * @param {any} value - If child.key === this value it will be considered a match. Note that a strict comparison is used. + * @param {number} returnType - How to return the data from this method. Either Phaser.Group.RETURN_NONE, Phaser.Group.RETURN_TOTAL or Phaser.Group.RETURN_CHILD. + * @param {function} [callback=null] - Optional function that will be called on each matching child. Each child of the Group will be passed to it as its first parameter. + * @param {Object} [callbackContext] - The context in which the function should be called (usually 'this'). + */ + iterate: function (key, value, returnType, callback, callbackContext, args) { + + if (returnType == Phaser.Group.RETURN_TOTAL && this._container.children.length == 0) + { + return -1; + } + + if (typeof callback === 'undefined') + { + callback = false; + } + + var total = 0; + if (this._container.children.length > 0 && this._container.first._iNext) { var currentNode = this._container.first._iNext; do { - if (currentNode.alive == false) + if (currentNode[key] === value) { - args[0] = currentNode; - callback.apply(callbackContext, args); + total++; + + if (callback) + { + args[0] = currentNode; + callback.apply(callbackContext, args); + } + + if (returnType == Phaser.Group.RETURN_CHILD) + { + return currentNode; + } } currentNode = currentNode._iNext; } while (currentNode != this._container.last._iNext); - } + + if (returnType == Phaser.Group.RETURN_TOTAL) + { + return total; + } + else if (returnType == Phaser.Group.RETURN_CHILD) + { + return null; + } + }, /** @@ -10397,23 +12513,7 @@ Phaser.Group.prototype = { state = true; } - if (this._container.children.length > 0 && this._container.first._iNext) - { - var currentNode = this._container.first._iNext; - - do - { - if (currentNode.exists === state) - { - return currentNode; - } - - currentNode = currentNode._iNext; - } - while (currentNode != this._container.last._iNext); - } - - return null; + return this.iterate('exists', state, Phaser.Group.RETURN_CHILD); }, @@ -10426,23 +12526,7 @@ Phaser.Group.prototype = { */ getFirstAlive: function () { - if (this._container.children.length > 0 && this._container.first._iNext) - { - var currentNode = this._container.first._iNext; - - do - { - if (currentNode.alive) - { - return currentNode; - } - - currentNode = currentNode._iNext; - } - while (currentNode != this._container.last._iNext); - } - - return null; + return this.iterate('alive', true, Phaser.Group.RETURN_CHILD); }, @@ -10455,23 +12539,7 @@ Phaser.Group.prototype = { */ getFirstDead: function () { - if (this._container.children.length > 0 && this._container.first._iNext) - { - var currentNode = this._container.first._iNext; - - do - { - if (!currentNode.alive) - { - return currentNode; - } - - currentNode = currentNode._iNext; - } - while (currentNode != this._container.last._iNext); - } - - return null; + return this.iterate('alive', false, Phaser.Group.RETURN_CHILD); }, @@ -10483,29 +12551,7 @@ Phaser.Group.prototype = { */ countLiving: function () { - var total = 0; - - if (this._container.children.length > 0 && this._container.first._iNext) - { - var currentNode = this._container.first._iNext; - - do - { - if (currentNode.alive) - { - total++; - } - - currentNode = currentNode._iNext; - } - while (currentNode != this._container.last._iNext); - } - else - { - total = -1; - } - - return total; + return this.iterate('alive', true, Phaser.Group.RETURN_TOTAL); }, @@ -10517,29 +12563,7 @@ Phaser.Group.prototype = { */ countDead: function () { - var total = 0; - - if (this._container.children.length > 0 && this._container.first._iNext) - { - var currentNode = this._container.first._iNext; - - do - { - if (!currentNode.alive) - { - total++; - } - - currentNode = currentNode._iNext; - } - while (currentNode != this._container.last._iNext); - } - else - { - total = -1; - } - - return total; + return this.iterate('alive', false, Phaser.Group.RETURN_TOTAL); }, @@ -10684,6 +12708,48 @@ Phaser.Group.prototype = { }, + validate: function () { + + var testObject = this.game.stage._stage.last._iNext; + var displayObject = this.game.stage._stage; + var nextObject = null; + var prevObject = null; + var count = 0; + + do + { + if (count > 0) + { + // check next + if (displayObject !== nextObject) + { + console.log('check next fail'); + return false; + } + + // check previous + if (displayObject._iPrev !== prevObject) + { + console.log('check previous fail'); + return false; + } + } + + // Set the next object + nextObject = displayObject._iNext; + prevObject = displayObject; + + displayObject = displayObject._iNext; + + count++; + + } + while(displayObject != testObject) + + return true; + + }, + /** * Dumps out a list of Group children and their index positions to the browser console. Useful for group debugging. * @@ -10790,7 +12856,8 @@ Phaser.Group.prototype = { Object.defineProperty(Phaser.Group.prototype, "total", { get: function () { - return this._container.children.length; + return this.iterate('exists', true, Phaser.Group.RETURN_TOTAL); + // return this._container.children.length; } }); @@ -10803,7 +12870,8 @@ Object.defineProperty(Phaser.Group.prototype, "total", { Object.defineProperty(Phaser.Group.prototype, "length", { get: function () { - return this._container.children.length; + return this.iterate('exists', true, Phaser.Group.RETURN_TOTAL); + // return this._container.children.length; } }); @@ -11173,6 +13241,22 @@ Object.defineProperty(Phaser.World.prototype, "randomY", { }); +/** +* @name Phaser.World#visible +* @property {boolean} visible - Gets or sets the visible state of the World. +*/ +Object.defineProperty(Phaser.World.prototype, "visible", { + + get: function () { + return this._container.visible; + }, + + set: function (value) { + this._container.visible = value; + } + +}); + /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. @@ -11597,7 +13681,13 @@ Phaser.Game.prototype = { this.time.update(time); - if (!this._paused) + if (this._paused) + { + this.renderer.render(this.stage._stage); + this.plugins.render(); + this.state.render(); + } + else { this.plugins.preUpdate(); this.physics.preUpdate(); @@ -11612,6 +13702,7 @@ Phaser.Game.prototype = { this.plugins.update(); this.world.postUpdate(); + this.plugins.postUpdate(); this.renderer.render(this.stage._stage); this.plugins.render(); @@ -13197,23 +15288,29 @@ Phaser.Mouse = function (game) { this.callbackContext = this.game; /** - * @property {Description} mouseDownCallback - Description. + * @property {function} mouseDownCallback - Description. * @default */ this.mouseDownCallback = null; /** - * @property {Description} mouseMoveCallback - Description. + * @property {function} mouseMoveCallback - Description. * @default */ this.mouseMoveCallback = null; /** - * @property {Description} mouseUpCallback - Description. + * @property {function} mouseUpCallback - Description. * @default */ this.mouseUpCallback = null; + /** + * @property {number} button- The type of click, either: Phaser.Mouse.NO_BUTTON, Phaser.Mouse.LEFT_BUTTON, Phaser.Mouse.MIDDLE_BUTTON or Phaser.Mouse.RIGHT_BUTTON. + * @default + */ + this.button = -1; + /** * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. * @property {boolean} disabled @@ -13228,8 +15325,20 @@ Phaser.Mouse = function (game) { */ this.locked = false; + /** + * This event is dispatched when the browser enters or leaves pointer lock state. + * @property {Phaser.Signal} pointerLock + * @default + */ + this.pointerLock = new Phaser.Signal; + }; +/** +* @constant +* @type {number} +*/ +Phaser.Mouse.NO_BUTTON = -1; /** * @constant * @type {number} @@ -13283,7 +15392,7 @@ Phaser.Mouse.prototype = { }, /** - * Description. + * The internal method that handles the mouse down event from the browser. * @method Phaser.Mouse#onMouseDown * @param {MouseEvent} event */ @@ -13291,6 +15400,19 @@ Phaser.Mouse.prototype = { 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; + } + if (this.mouseDownCallback) { this.mouseDownCallback.call(this.callbackContext, event); @@ -13308,7 +15430,7 @@ Phaser.Mouse.prototype = { }, /** - * Description + * The internal method that handles the mouse move event from the browser. * @method Phaser.Mouse#onMouseMove * @param {MouseEvent} event */ @@ -13333,7 +15455,7 @@ Phaser.Mouse.prototype = { }, /** - * Description. + * The internal method that handles the mouse up event from the browser. * @method Phaser.Mouse#onMouseUp * @param {MouseEvent} event */ @@ -13341,6 +15463,8 @@ Phaser.Mouse.prototype = { event.preventDefault(); + this.button = Phaser.Mouse.NO_BUTTON; + if (this.mouseUpCallback) { this.mouseUpCallback.call(this.callbackContext, event); @@ -13358,7 +15482,9 @@ Phaser.Mouse.prototype = { }, /** - * Description. + * If the browser supports it you can request that the pointer be locked to the browser window. + * This is classically known as 'FPS controls', where the pointer can't leave the browser until the user presses an exit key. + * If the browser successfully enters a locked state the event Phaser.Mouse.pointerLock will be dispatched and the first parameter will be 'true'. * @method Phaser.Mouse#requestPointerLock */ requestPointerLock: function () { @@ -13377,15 +15503,15 @@ Phaser.Mouse.prototype = { return _this.pointerLockChange(event); }; - document.addEventListener('pointerlockchange', this._pointerLockChange, false); - document.addEventListener('mozpointerlockchange', this._pointerLockChange, false); - document.addEventListener('webkitpointerlockchange', this._pointerLockChange, false); + document.addEventListener('pointerlockchange', this._pointerLockChange, true); + document.addEventListener('mozpointerlockchange', this._pointerLockChange, true); + document.addEventListener('webkitpointerlockchange', this._pointerLockChange, true); } }, /** - * Description. + * Internal pointerLockChange handler. * @method Phaser.Mouse#pointerLockChange * @param {MouseEvent} event */ @@ -13397,17 +15523,19 @@ Phaser.Mouse.prototype = { { // Pointer was successfully locked this.locked = true; + this.pointerLock.dispatch(true); } else { // Pointer was unlocked this.locked = false; + this.pointerLock.dispatch(false); } }, /** - * Description. + * Internal release pointer lock handler. * @method Phaser.Mouse#releasePointerLock */ releasePointerLock: function () { @@ -13416,9 +15544,9 @@ Phaser.Mouse.prototype = { document.exitPointerLock(); - document.removeEventListener('pointerlockchange', this._pointerLockChange); - document.removeEventListener('mozpointerlockchange', this._pointerLockChange); - document.removeEventListener('webkitpointerlockchange', this._pointerLockChange); + document.removeEventListener('pointerlockchange', this._pointerLockChange, true); + document.removeEventListener('mozpointerlockchange', this._pointerLockChange, true); + document.removeEventListener('webkitpointerlockchange', this._pointerLockChange, true); }, @@ -13428,13 +15556,14 @@ Phaser.Mouse.prototype = { */ stop: function () { - this.game.stage.canvas.removeEventListener('mousedown', this._onMouseDown); - this.game.stage.canvas.removeEventListener('mousemove', this._onMouseMove); - this.game.stage.canvas.removeEventListener('mouseup', this._onMouseUp); + 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); } }; + /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. @@ -14017,7 +16146,6 @@ Phaser.Pointer.prototype = { } return this; - } // Work out which object is on the top @@ -15049,28 +17177,60 @@ Phaser.InputHandler.prototype = { /** * Is the Pointer over this Sprite? * @method Phaser.InputHandler#pointerOver - * @param {Pointer} pointer - * @return {bool + * @param {number} [index] - The ID number of a Pointer to check. If you don't provide a number it will check all Pointers. + * @return {boolean} True if the given pointer (if a index was given, or any pointer if not) is over this object. */ - pointerOver: function (pointer) { + pointerOver: function (index) { - pointer = pointer || 0; + if (this.enabled) + { + if (typeof index === 'undefined') + { + for (var i = 0; i < 10; i++) + { + if (this._pointerData[i].isOver) + { + return true; + } + } + } + else + { + return this._pointerData[index].isOver; + } + } - return this._pointerData[pointer].isOver; + return false; }, /** * Is the Pointer outside of this Sprite? * @method Phaser.InputHandler#pointerOut - * @param {Pointer} pointer - * @return {boolean} + * @param {number} [index] - The ID number of a Pointer to check. If you don't provide a number it will check all Pointers. + * @return {boolean} True if the given pointer (if a index was given, or any pointer if not) is out of this object. */ pointerOut: function (pointer) { - pointer = pointer || 0; + if (this.enabled) + { + if (typeof index === 'undefined') + { + for (var i = 0; i < 10; i++) + { + if (this._pointerData[i].isOut) + { + return true; + } + } + } + else + { + return this._pointerData[index].isOut; + } + } - return this._pointerData[pointer].isOut; + return false; }, @@ -15146,12 +17306,13 @@ Phaser.InputHandler.prototype = { }, /** - * Description. - * @method Phaser.InputHandler#checkPixel - * @param {Description} x - Description. - * @param {Description} y - Description. - * @return {boolean} - */ + * Runs a pixel perfect check against the given x/y coordinates of the Sprite this InputHandler is bound to. + * It compares the alpha value of the pixel and if >= InputHandler.pixelPerfectAlpha it returns true. + * @method Phaser.InputHandler#checkPixel + * @param {number} x - The x coordinate to check. + * @param {number} y - The y coordinate to check. + * @return {boolean} true if there is the alpha of the pixel is >= InputHandler.pixelPerfectAlpha + */ checkPixel: function (x, y) { // Grab a pixel from our image into the hitCanvas and then test it @@ -15159,8 +17320,6 @@ Phaser.InputHandler.prototype = { { this.game.input.hitContext.clearRect(0, 0, 1, 1); - // This will fail if the image is part of a texture atlas - need to modify the x/y values here - x += this.sprite.texture.frame.x; y += this.sprite.texture.frame.y; @@ -17554,7 +19713,7 @@ Phaser.BitmapText.prototype.destroy = function() { this.group.remove(this); } - if (this.canvas.parentNode) + if (this.canvas && this.canvas.parentNode) { this.canvas.parentNode.removeChild(this.canvas); } @@ -17798,6 +19957,13 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame, */ this.freezeFrames = false; + /** + * When the Button is clicked you can optionally force the state to "out". + * @property {boolean} forceOut + * @default + */ + this.forceOut = true; + this.setFrames(overFrame, outFrame, downFrame); if (callback !== null) @@ -17882,7 +20048,7 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) { { this._onDownFrameName = downFrame; - if (this.input.pointerOver()) + if (this.input.pointerDown()) { this.frameName = downFrame; } @@ -17891,7 +20057,7 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) { { this._onDownFrameID = downFrame; - if (this.input.pointerOver()) + if (this.input.pointerDown()) { this.frame = downFrame; } @@ -18142,10 +20308,23 @@ Phaser.Button.prototype.onInputUpHandler = function (pointer) { this.onUpSound.play(this.onUpSoundMarker); } + if (this.forceOut && this.freezeFrames == false) + { + if (this._onOutFrameName != null) + { + this.frameName = this._onOutFrameName; + } + else if (this._onOutFrameID != null) + { + this.frame = this._onOutFrameID; + } + } + if (this.onInputUp) { this.onInputUp.dispatch(this, pointer); } + }; /** @@ -18200,6 +20379,18 @@ Phaser.Graphics.prototype.destroy = function() { } +/* +* Draws a {Phaser.Polygon} or a {PIXI.Polygon} filled +*/ +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) { + 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', { get: function() { @@ -18582,45 +20773,19 @@ Phaser.Canvas = { Phaser.StageScaleMode = function (game, width, height) { /** - * @property {number} _startHeight - Stage height when starting the game. - * @default - * @private + * @property {Phaser.Game} game - A reference to the currently running game. */ - this._startHeight = 0; + this.game = game; /** - * @property {boolean} forceLandscape - If the game should be forced to use Landscape mode, this is set to true by Game.Stage - * @default + * @property {number} width - Width of the stage after calculation. */ - this.forceLandscape = false; + this.width = width; /** - * @property {boolean} forcePortrait - If the game should be forced to use Portrait mode, this is set to true by Game.Stage - * @default + * @property {number} height - Height of the stage after calculation. */ - this.forcePortrait = false; - - /** - * @property {boolean} incorrectOrientation - If the game should be forced to use a specific orientation and the device currently isn't in that orientation this is set to true. - * @default - */ - this.incorrectOrientation = false; - - /** - * @property {boolean} pageAlignHorizontally - If you wish to align your game in the middle of the page then you can set this value to true. -
  • It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing.
  • -
  • It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.
- * @default - */ - this.pageAlignHorizontally = false; - - /** - * @property {boolean} pageAlignVertically - If you wish to align your game in the middle of the page then you can set this value to true. -
  • It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing. -
  • It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.
- * @default - */ - this.pageAlignVertically = false; + this.height = height; /** * @property {number} minWidth - Minimum width the canvas should be scaled to (in pixels). @@ -18649,14 +20814,45 @@ Phaser.StageScaleMode = function (game, width, height) { this.maxHeight = null; /** - * @property {number} width - Width of the stage after calculation. + * @property {number} _startHeight - Stage height when starting the game. + * @default + * @private */ - this.width = width; + this._startHeight = 0; /** - * @property {number} height - Height of the stage after calculation. + * @property {boolean} forceLandscape - If the game should be forced to use Landscape mode, this is set to true by Game.Stage + * @default */ - this.height = height; + this.forceLandscape = false; + + /** + * @property {boolean} forcePortrait - If the game should be forced to use Portrait mode, this is set to true by Game.Stage + * @default + */ + this.forcePortrait = false; + + /** + * @property {boolean} incorrectOrientation - If the game should be forced to use a specific orientation and the device currently isn't in that orientation this is set to true. + * @default + */ + this.incorrectOrientation = false; + + /** + * @property {boolean} pageAlignHorizontally - If you wish to align your game in the middle of the page then you can set this value to true. + * It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing. + * It doesn't care about any other DOM element that may be on the page, it literally just sets the margin. + * @default + */ + this.pageAlignHorizontally = false; + + /** + * @property {boolean} pageAlignVertically - If you wish to align your game in the middle of the page then you can set this value to true. + * It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing. + * It doesn't care about any other DOM element that may be on the page, it literally just sets the margin. + * @default + */ + this.pageAlignVertically = false; /** * @property {number} _width - Cached stage width for full screen mode. @@ -18678,18 +20874,20 @@ Phaser.StageScaleMode = function (game, width, height) { */ this.maxIterations = 5; - /** - * @property {Phaser.Game} game - A reference to the currently running game. - */ - this.game = game; /** - * @property {Description} enterLandscape - Description. + * @property {PIXI.Sprite} orientationSprite - The Sprite that is optionally displayed if the browser enters an unsupported orientation. + * @default + */ + this.orientationSprite = null; + + /** + * @property {Phaser.Signal} enterLandscape - The event that is dispatched when the browser enters landscape orientation. */ this.enterLandscape = new Phaser.Signal(); /** - * @property {Description} enterPortrait - Description. + * @property {Phaser.Signal} enterPortrait - The event that is dispatched when the browser enters horizontal orientation. */ this.enterPortrait = new Phaser.Signal(); @@ -18710,7 +20908,7 @@ Phaser.StageScaleMode = function (game, width, height) { } /** - * @property {Description} scaleFactor - Description. + * @property {Phaser.Point} scaleFactor - The scale factor based on the game dimensions vs. the scaled dimensions. */ this.scaleFactor = new Phaser.Point(1, 1); @@ -18863,6 +21061,54 @@ Phaser.StageScaleMode.prototype = { }, + /** + * If you need your game to run in only one orientation you can force that to happen. + * 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. + */ + forceOrientation: function (forceLandscape, forcePortrait, orientationImage) { + + this.forceLandscape = forceLandscape; + + if (typeof forcePortrait === 'undefined') + { + this.forcePortrait = false; + } + + if (typeof orientationImage !== 'undefined') + { + if (orientationImage == null || this.game.cache.checkImageKey(orientationImage) == false) + { + orientationImage = '__default'; + } + + this.orientationSprite = new PIXI.Sprite(PIXI.TextureCache[orientationImage]); + this.orientationSprite.anchor.x = 0.5; + this.orientationSprite.anchor.y = 0.5; + this.orientationSprite.position.x = this.game.width / 2; + this.orientationSprite.position.y = this.game.height / 2; + + this.checkOrientationState(); + + if (this.incorrectOrientation) + { + this.orientationSprite.visible = true; + this.game.world.visible = false; + } + else + { + this.orientationSprite.visible = false; + this.game.world.visible = true; + } + + this.game.stage._stage.addChild(this.orientationSprite); + } + + }, + /** * Checks if the browser is in the correct orientation for your game (if forceLandscape or forcePortrait have been set) * @method Phaser.StageScaleMode#checkOrientationState @@ -18877,6 +21123,13 @@ Phaser.StageScaleMode.prototype = { // Back to normal this.game.paused = false; this.incorrectOrientation = false; + + if (this.orientationSprite) + { + this.orientationSprite.visible = false; + this.game.world.visible = true; + } + this.refresh(); } } @@ -18887,6 +21140,13 @@ Phaser.StageScaleMode.prototype = { // Show orientation screen this.game.paused = true; this.incorrectOrientation = true; + + if (this.orientationSprite && this.orientationSprite.visible == false) + { + this.orientationSprite.visible = true; + this.game.world.visible = false; + } + this.refresh(); } } @@ -18946,6 +21206,9 @@ Phaser.StageScaleMode.prototype = { { this.refresh(); } + + this.checkOrientationState(); + }, /** @@ -18985,7 +21248,7 @@ Phaser.StageScaleMode.prototype = { /** * Set screen size automatically based on the scaleMode. - * @param {Description} force - If force is true it will try to resize the game regardless of the document dimensions. + * @param {boolean} force - If force is true it will try to resize the game regardless of the document dimensions. */ setScreenSize: function (force) { @@ -19098,6 +21361,8 @@ Phaser.StageScaleMode.prototype = { this.scaleFactor.x = this.game.width / this.width; this.scaleFactor.y = this.game.height / this.height; + this.checkOrientationState(); + }, /** @@ -19794,6 +22059,13 @@ Phaser.RequestAnimationFrame = function(game) { */ this._onLoop = null; + /** + * The callback ID used when calling cancel + * @property _timeOutID + * @private + */ + this._timeOutID = null; + }; Phaser.RequestAnimationFrame.prototype = { @@ -19827,7 +22099,7 @@ Phaser.RequestAnimationFrame.prototype = { return _this.updateRAF(time); }; - window.requestAnimationFrame(this._onLoop); + this._timeOutID = window.requestAnimationFrame(this._onLoop); } }, @@ -19841,7 +22113,7 @@ Phaser.RequestAnimationFrame.prototype = { this.game.update(time); - window.requestAnimationFrame(this._onLoop); + this._timeOutID = window.requestAnimationFrame(this._onLoop); }, @@ -19869,7 +22141,7 @@ Phaser.RequestAnimationFrame.prototype = { } else { - window.cancelAnimationFrame; + window.cancelAnimationFrame(this._timeOutID); } this.isRunning = false; @@ -23180,6 +25452,36 @@ Phaser.Rectangle.union = function (a, b, out) { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +/** +* Creates a new Polygon. You have to provide a list of points. +* This can be an array of Points that form the polygon, a flat array of numbers that will be interpreted as [x,y, x,y, ...], +* or the arguments passed can be all the points of the polygon e.g. `new PIXI.Polygon(new PIXI.Point(), new PIXI.Point(), ...)`, or the +* arguments passed can be flat x,y values e.g. `new PIXI.Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are numbers. +* +* @class Phaser.Polygon +* @classdesc The polygon represents a list of orderded points in space +* @constructor +* @param {Array|Array} points - The array of Points. +*/ +Phaser.Polygon = function (points) { + + PIXI.Polygon.call(this, points); + + /** + * @property {number} type - The base object type. + */ + this.type = Phaser.POLYGON; + +}; + +Phaser.Polygon.prototype = Object.create(PIXI.Polygon.prototype); +Phaser.Polygon.prototype.constructor = Phaser.Polygon; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + /** * Description of Phaser.Net * @@ -25253,6 +27555,27 @@ Phaser.AnimationManager.prototype = { }, + /** + * Returns an animation that was previously added by name. + * + * @method Phaser.AnimationManager#getAnimation + * @param {string} name - The name of the animation to be returned, e.g. "fire". + * @return {Phaser.Animation|boolean} The Animation instance, if found, otherwise false. + */ + getAnimation: function (name) { + + if (typeof name == 'string') + { + if (this._anims[name]) + { + return this._anims[name]; + } + } + + return false; + + }, + /** * Refreshes the current frame data back to the parent Sprite and also resets the texture data. * @@ -31244,19 +33567,19 @@ Phaser.Physics.Arcade.prototype = { // If you're wondering why the velocity is halved and applied twice, read this: http://www.niksula.hut.fi/~hkankaan/Homepages/gravity.html // Rotation - this._velocityDelta = (this.computeVelocity(0, body, body.angularVelocity, body.angularAcceleration, body.angularDrag, body.maxAngular) - body.angularVelocity) / 2; + this._velocityDelta = (this.computeVelocity(0, body, body.angularVelocity, body.angularAcceleration, body.angularDrag, body.maxAngular) - body.angularVelocity) * this.game.time.physicsElapsed * 0.5 * 60; body.angularVelocity += this._velocityDelta; body.rotation += (body.angularVelocity * this.game.time.physicsElapsed); body.angularVelocity += this._velocityDelta; // Horizontal - this._velocityDelta = (this.computeVelocity(1, body, body.velocity.x, body.acceleration.x, body.drag.x, body.maxVelocity.x) - body.velocity.x) / 2; + this._velocityDelta = (this.computeVelocity(1, body, body.velocity.x, body.acceleration.x, body.drag.x, body.maxVelocity.x) - body.velocity.x) * this.game.time.physicsElapsed * 0.5 * 60; body.velocity.x += this._velocityDelta; body.x += (body.velocity.x * this.game.time.physicsElapsed); body.velocity.x += this._velocityDelta; // Vertical - this._velocityDelta = (this.computeVelocity(2, body, body.velocity.y, body.acceleration.y, body.drag.y, body.maxVelocity.y) - body.velocity.y) / 2; + this._velocityDelta = (this.computeVelocity(2, body, body.velocity.y, body.acceleration.y, body.drag.y, body.maxVelocity.y) - body.velocity.y) * this.game.time.physicsElapsed * 0.5 * 60; body.velocity.y += this._velocityDelta; body.y += (body.velocity.y * this.game.time.physicsElapsed); body.velocity.y += this._velocityDelta; diff --git a/build/phaser.min.js b/build/phaser.min.js index 12ad1400..01dc9612 100644 --- a/build/phaser.min.js +++ b/build/phaser.min.js @@ -1,11 +1,12 @@ -/*! Phaser v1.1.2 | (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.2",DEV_VERSION:"1.1.2",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,NONE:0,LEFT:1,RIGHT:2,UP:3,DOWN:4};return 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.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},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){this._mask=a,a?this.addFilter(a):this.removeFilter()}}),d.DisplayObject.prototype.addFilter=function(a){if(!this.filter){this.filter=!0;var b=new d.FilterBlock,c=new d.FilterBlock;b.mask=a,c.mask=a,b.first=b.last=this,c.first=c.last=this,b.open=!0;var e,f,g=b,h=b;f=this.first._iPrev,f?(e=f._iNext,g._iPrev=f,f._iNext=g):e=this,e&&(e._iPrev=h,h._iNext=e);var g=c,h=c,e=null,f=null;f=this.last,e=f._iNext,e&&(e._iPrev=h,h._iNext=e),g._iPrev=f,f._iNext=g;for(var i=this,j=this.last;i;)i.last==j&&(i.last=c),i=i.parent;this.first=b,this.__renderGroup&&this.__renderGroup.addFilterBlocks(b,c),a.renderable=!1}},d.DisplayObject.prototype.removeFilter=function(){if(this.filter){this.filter=!1;var a=this.first,b=a._iNext,c=a._iPrev;b&&(b._iPrev=c),c&&(c._iNext=b),this.first=a._iNext;var d=this.last,b=d._iNext,c=d._iPrev;b&&(b._iPrev=c),c._iNext=b;for(var e=d._iPrev,f=this;f.last==d&&(f.last=e,f=f.parent););var g=a.mask;g.renderable=!0,this.__renderGroup&&this.__renderGroup.removeFilterBlocks(a,d)}},d.DisplayObject.prototype.updateTransform=function(){this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation));var a=this.localTransform,b=this.parent.worldTransform,c=this.worldTransform;a[0]=this._cr*this.scale.x,a[1]=-this._sr*this.scale.y,a[3]=this._sr*this.scale.x,a[4]=this._cr*this.scale.y;var e=this.pivot.x,f=this.pivot.y,g=a[0],h=a[1],i=this.position.x-a[0]*e-f*a[1],j=a[3],k=a[4],l=this.position.y-a[4]*f-e*a[3],m=b[0],n=b[1],o=b[2],p=b[3],q=b[4],r=b[5];a[2]=i,a[5]=l,c[0]=m*g+n*j,c[1]=m*h+n*k,c[2]=m*i+n*l+o,c[3]=p*g+q*j,c[4]=p*h+q*k,c[5]=p*i+q*l+r,this.worldAlpha=this.alpha*this.parent.worldAlpha,this.vcount=d.visibleCount},d.visibleCount=0,d.DisplayObjectContainer=function(){d.DisplayObject.call(this),this.children=[]},d.DisplayObjectContainer.prototype=Object.create(d.DisplayObject.prototype),d.DisplayObjectContainer.prototype.constructor=d.DisplayObjectContainer,d.DisplayObjectContainer.prototype.addChild=function(a){if(void 0!=a.parent&&a.parent.removeChild(a),a.parent=this,this.children.push(a),this.stage){var b=a;do b.interactive&&(this.stage.dirty=!0),b.stage=this.stage,b=b._iNext;while(b)}var c,d,e=a.first,f=a.last;d=this.filter?this.last._iPrev:this.last,c=d._iNext;for(var g=this,h=d;g;)g.last==h&&(g.last=a.last),g=g.parent;c&&(c._iPrev=f,f._iNext=c),e._iPrev=d,d._iNext=e,this.__renderGroup&&(a.__renderGroup&&a.__renderGroup.removeDisplayObjectAndChildren(a),this.__renderGroup.addDisplayObjectAndChildren(a))},d.DisplayObjectContainer.prototype.addChildAt=function(a,b){if(!(b>=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,b){d.DisplayObjectContainer.call(this),this.worldTransform=d.mat3.create(),this.interactive=b,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.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)},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.FilterBlock=function(a){this.graphics=a,this.visible=!0,this.renderable=!0},d.MaskFilter=function(){this.graphics},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=[]},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&&(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)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.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._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.dynamicSize3&&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){var f=new d.Point(e[0],e[1]),g=new d.Point(e[e.length-2],e[e.length-1]);if(f.x==g.x&&f.y==g.y){e.pop(),e.pop(),g=new d.Point(e[e.length-2],e[e.length-1]);var h=g.x+.5*(f.x-g.x),i=g.y+.5*(f.y-g.y);e.unshift(h,i),e.push(h,i)}var j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E=c.points,F=c.indices,G=e.length/2,H=e.length,I=E.length/6,J=a.lineWidth/2,K=b(a.lineColor),L=a.lineAlpha,M=K[0]*L,N=K[1]*L,O=K[2]*L;j=e[0],k=e[1],l=e[2],m=e[3],p=-(k-m),q=j-l,D=Math.sqrt(p*p+q*q),p/=D,q/=D,p*=J,q*=J,E.push(j-p,k-q,M,N,O,L),E.push(j+p,k+q,M,N,O,L);for(var P=1;G-1>P;P++)j=e[2*(P-1)],k=e[2*(P-1)+1],l=e[2*P],m=e[2*P+1],n=e[2*(P+1)],o=e[2*(P+1)+1],p=-(k-m),q=j-l,D=Math.sqrt(p*p+q*q),p/=D,q/=D,p*=J,q*=J,r=-(m-o),s=l-n,D=Math.sqrt(r*r+s*s),r/=D,s/=D,r*=J,s*=J,v=-q+k-(-q+m),w=-p+l-(-p+j),x=(-p+j)*(-q+m)-(-p+l)*(-q+k),y=-s+o-(-s+m),z=-r+l-(-r+n),A=(-r+n)*(-s+m)-(-r+l)*(-s+o),B=v*z-y*w,0==B&&(B+=1),px=(w*A-z*x)/B,py=(y*x-v*A)/B,C=(px-l)*(px-l)+(py-m)+(py-m),C>19600?(t=p-r,u=q-s,D=Math.sqrt(t*t+u*u),t/=D,u/=D,t*=J,u*=J,E.push(l-t,m-u),E.push(M,N,O,L),E.push(l+t,m+u),E.push(M,N,O,L),E.push(l-t,m-u),E.push(M,N,O,L),H++):(E.push(px,py),E.push(M,N,O,L),E.push(l-(px-l),m-(py-m)),E.push(M,N,O,L));j=e[2*(G-2)],k=e[2*(G-2)+1],l=e[2*(G-1)],m=e[2*(G-1)+1],p=-(k-m),q=j-l,D=Math.sqrt(p*p+q*q),p/=D,q/=D,p*=J,q*=J,E.push(l-p,m-q),E.push(M,N,O,L),E.push(l+p,m+q),E.push(M,N,O,L),F.push(I);for(var P=0;H>P;P++)F.push(I++);F.push(I-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=[];try{d.gl=this.gl=this.view.getContext("experimental-webgl",{alpha:this.transparent,antialias:!!f,premultipliedAlpha:!1,stencil:!0})}catch(h){throw new Error(" This browser does not support webGL. Try using the canvas renderer"+this)}d.initPrimitiveShader(),d.initDefaultShader(),d.initDefaultStripShader(),d.activateDefaultShader();var i=this.gl;d.WebGLRenderer.gl=i,this.batch=new d.WebGLBatch(i),i.disable(i.DEPTH_TEST),i.disable(i.CULL_FACE),i.enable(i.BLEND),i.colorMask(!0,!0,!0,this.transparent),d.projection=new d.Point(400,300),this.resize(this.width,this.height),this.contextLost=!1,this.stageRenderGroup=new d.WebGLRenderGroup(this.gl)},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,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;c0;)n=n.children[n.children.length-1],n.renderable&&(m=n);if(m instanceof d.Sprite){l=m.batch;var k=l.head;if(k==m)g=0;else for(g=1;k.__next!=m;)g++,k=k.__next}else l=m;if(j==l)return j instanceof d.WebGLBatch?j.render(e,g+1):this.renderSpecial(j,b),void 0;f=this.batchs.indexOf(j),h=this.batchs.indexOf(l),j instanceof d.WebGLBatch?j.render(e):this.renderSpecial(j,b);for(var o=f+1;h>o;o++)renderable=this.batchs[o],renderable instanceof d.WebGLBatch?this.batchs[o].render():this.renderSpecial(renderable,b);l instanceof d.WebGLBatch?l.render(0,g+1):this.renderSpecial(l,b)},d.WebGLRenderGroup.prototype.renderSpecial=function(a,b){var c=a.vcount===d.visibleCount;if(a instanceof d.TilingSprite)c&&this.renderTilingSprite(a,b);else if(a instanceof d.Strip)c&&this.renderStrip(a,b);else if(a instanceof d.CustomRenderable)c&&a.renderWebGL(this,b);else if(a instanceof d.Graphics)c&&a.renderable&&d.WebGLGraphics.renderGraphics(a,b);else if(a instanceof d.FilterBlock){var e=d.gl;a.open?(e.enable(e.STENCIL_TEST),e.colorMask(!1,!1,!1,!1),e.stencilFunc(e.ALWAYS,1,255),e.stencilOp(e.KEEP,e.KEEP,e.REPLACE),d.WebGLGraphics.renderGraphics(a.mask,b),e.colorMask(!0,!0,!0,!0),e.stencilFunc(e.NOTEQUAL,0,255),e.stencilOp(e.KEEP,e.KEEP,e.KEEP)):e.disable(e.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&&(c=c._iPrev,!c.renderable||!c.__renderGroup););this.insertAfter(a,c);for(var d=b;d!=this.root&&(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,e=d.shaderProgram;c.useProgram(d.stripShaderProgram);var f=d.mat3.clone(a.worldTransform);d.mat3.transpose(f),c.uniformMatrix3fv(d.stripShaderProgram.translationMatrix,!1,f),c.uniform2f(d.stripShaderProgram.projectionVector,b.x,b.y),c.uniform1f(d.stripShaderProgram.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.vertexPositionAttribute,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.textureCoordAttribute,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.vertexPositionAttribute,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,a._uvBuffer),c.vertexAttribPointer(e.textureCoordAttribute,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),c.useProgram(d.shaderProgram)},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.shaderFragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));","gl_FragColor = gl_FragColor * vColor;","}"],d.shaderVertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform vec2 projectionVector;","varying vec2 vTextureCoord;","varying float vColor;","void main(void) {","gl_Position = vec4( aVertexPosition.x / projectionVector.x -1.0, aVertexPosition.y / -projectionVector.y + 1.0 , 0.0, 1.0);","vTextureCoord = aTextureCoord;","vColor = aColor;","}"],d.stripShaderFragmentSrc=["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;","}"],d.stripShaderVertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","varying vec2 vTextureCoord;","varying float vColor;","void main(void) {","vec3 v = translationMatrix * vec3(aVertexPosition, 1.0);","gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);","vTextureCoord = aTextureCoord;","vColor = aColor;","}"],d.primitiveShaderFragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {","gl_FragColor = vColor;","}"],d.primitiveShaderVertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform float alpha;","varying vec4 vColor;","void main(void) {","vec3 v = translationMatrix * vec3(aVertexPosition, 1.0);","gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);","vColor = aColor * alpha;","}"],d.initPrimitiveShader=function(){var a=d.gl,b=d.compileProgram(d.primitiveShaderVertexSrc,d.primitiveShaderFragmentSrc);a.useProgram(b),b.vertexPositionAttribute=a.getAttribLocation(b,"aVertexPosition"),b.colorAttribute=a.getAttribLocation(b,"aColor"),b.projectionVector=a.getUniformLocation(b,"projectionVector"),b.translationMatrix=a.getUniformLocation(b,"translationMatrix"),b.alpha=a.getUniformLocation(b,"alpha"),d.primitiveProgram=b},d.initDefaultShader=function(){var a=this.gl,b=d.compileProgram(d.shaderVertexSrc,d.shaderFragmentSrc);a.useProgram(b),b.vertexPositionAttribute=a.getAttribLocation(b,"aVertexPosition"),b.projectionVector=a.getUniformLocation(b,"projectionVector"),b.textureCoordAttribute=a.getAttribLocation(b,"aTextureCoord"),b.colorAttribute=a.getAttribLocation(b,"aColor"),b.samplerUniform=a.getUniformLocation(b,"uSampler"),d.shaderProgram=b},d.initDefaultStripShader=function(){var a=this.gl,b=d.compileProgram(d.stripShaderVertexSrc,d.stripShaderFragmentSrc);a.useProgram(b),b.vertexPositionAttribute=a.getAttribLocation(b,"aVertexPosition"),b.projectionVector=a.getUniformLocation(b,"projectionVector"),b.textureCoordAttribute=a.getAttribLocation(b,"aTextureCoord"),b.translationMatrix=a.getUniformLocation(b,"translationMatrix"),b.alpha=a.getUniformLocation(b,"alpha"),b.colorAttribute=a.getAttribLocation(b,"aColor"),b.projectionVector=a.getUniformLocation(b,"projectionVector"),b.samplerUniform=a.getUniformLocation(b,"uSampler"),d.stripShaderProgram=b},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:(alert(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)||alert("Could not initialise shaders"),g},d.activateDefaultShader=function(){var a=d.gl,b=d.shaderProgram;a.useProgram(b),a.enableVertexAttribArray(b.vertexPositionAttribute),a.enableVertexAttribArray(b.textureCoordAttribute),a.enableVertexAttribArray(b.colorAttribute)},d.activatePrimitiveShader=function(){var a=d.gl;a.disableVertexAttribArray(d.shaderProgram.textureCoordAttribute),a.disableVertexAttribArray(d.shaderProgram.colorAttribute),a.useProgram(d.primitiveProgram),a.enableVertexAttribArray(d.primitiveProgram.vertexPositionAttribute),a.enableVertexAttribArray(d.primitiveProgram.colorAttribute)},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.Sprite.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?f:arguments.callee(a,b,f,d,e):arguments.callee(a,b,c,f,e)},c=function(a,c,d){if(a.measureText(c).width<=d||c.length<1)return c;var e=b(a,c,0,c.length,d);return c.substring(0,e)+"\n"+arguments.callee(a,c.substring(e),d)},d="",e=a.split("\n"),f=0;fthis.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):j.renderSpecific(a,this.projection):(this.renderGroup||(this.renderGroup=new d.WebGLRenderGroup(e)),this.renderGroup.setRenderable(a),this.renderGroup.render(this.projection)),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){for(var c in a[b.type])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.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.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.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)},swap:function(a,b){if(a===b||!a.parent||!b.parent)return console.warn("You cannot swap a child with itself or swap un-parented children"),!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&&(f._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)}},forEachAlive:function(a,b){var c=Array.prototype.splice.call(arguments,2);if(c.unshift(null),this._container.children.length>0&&this._container.first._iNext){var d=this._container.first._iNext;do d.alive&&(c[0]=d,a.apply(b,c)),d=d._iNext;while(d!=this._container.last._iNext)}},forEachDead:function(a,b){var c=Array.prototype.splice.call(arguments,2);if(c.unshift(null),this._container.children.length>0&&this._container.first._iNext){var d=this._container.first._iNext;do 0==d.alive&&(c[0]=d,a.apply(b,c)),d=d._iNext;while(d!=this._container.last._iNext)}},getFirstExists:function(a){if("boolean"!=typeof a&&(a=!0),this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do{if(b.exists===a)return b;b=b._iNext}while(b!=this._container.last._iNext)}return null},getFirstAlive:function(){if(this._container.children.length>0&&this._container.first._iNext){var a=this._container.first._iNext;do{if(a.alive)return a;a=a._iNext}while(a!=this._container.last._iNext)}return null},getFirstDead:function(){if(this._container.children.length>0&&this._container.first._iNext){var a=this._container.first._iNext;do{if(!a.alive)return a;a=a._iNext}while(a!=this._container.last._iNext)}return null},countLiving:function(){var a=0;if(this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do b.alive&&a++,b=b._iNext;while(b!=this._container.last._iNext)}else a=-1;return a},countDead:function(){var a=0;if(this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do b.alive||a++,b=b._iNext;while(b!=this._container.last._iNext)}else a=-1;return a},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},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._container.children.length}}),Object.defineProperty(e.Group.prototype,"length",{get:function(){return this._container.children.length}}),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)}}),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.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.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){return a=a||0,this._pointerData[a].isOver},pointerOut:function(a){return a=a||0,this._pointerData[a].isOut},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.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.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.pointerOver()&&(this.frameName=c)):(this._onDownFrameID=c,this.input.pointerOver()&&(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.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},Object.defineProperty(e.Graphics.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.Graphics.prototype,"x",{get:function(){return this.position.x},set:function(a){this.position.x=a}}),Object.defineProperty(e.Graphics.prototype,"y",{get:function(){return this.position.y},set:function(a){this.position.y=a}}),e.RenderTexture=function(a,b,c,f){this.game=a,this.name=b,d.EventTarget.call(this),this.width=c||100,this.height=f||100,this.indetityMatrix=d.mat3.create(),this.frame=new d.Rectangle(0,0,this.width,this.height),this.type=e.RENDERTEXTURE,d.gl?this.initWebGL():this.initCanvas()},e.RenderTexture.prototype=e.Utils.extend(!0,d.RenderTexture.prototype),e.RenderTexture.prototype.constructor=e.RenderTexture,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){return b=b||"","undefined"==typeof c&&(c=!0),""!==b?document.getElementById(b)?(document.getElementById(b).appendChild(a),c&&(document.getElementById(b).style.overflow="hidden")):document.body.appendChild(a):document.body.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._startHeight=0,this.forceLandscape=!1,this.forcePortrait=!1,this.incorrectOrientation=!1,this.pageAlignHorizontally=!1,this.pageAlignVertically=!1,this.minWidth=null,this.maxWidth=null,this.minHeight=null,this.maxHeight=null,this.width=b,this.height=c,this._width=0,this._height=0,this.maxIterations=5,this.game=a,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)},checkOrientationState:function(){this.incorrectOrientation?(this.forceLandscape&&window.innerWidth>window.innerHeight||this.forcePortrait&&window.innerHeight>window.innerWidth)&&(this.game.paused=!1,this.incorrectOrientation=!1,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()},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},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=(this.computeVelocity(0,a,a.angularVelocity,a.angularAcceleration,a.angularDrag,a.maxAngular)-a.angularVelocity)/2,a.angularVelocity+=this._velocityDelta,a.rotation+=a.angularVelocity*this.game.time.physicsElapsed,a.angularVelocity+=this._velocityDelta,this._velocityDelta=(this.computeVelocity(1,a,a.velocity.x,a.acceleration.x,a.drag.x,a.maxVelocity.x)-a.velocity.x)/2,a.velocity.x+=this._velocityDelta,a.x+=a.velocity.x*this.game.time.physicsElapsed,a.velocity.x+=this._velocityDelta,this._velocityDelta=(this.computeVelocity(2,a,a.velocity.y,a.acceleration.y,a.drag.y,a.maxVelocity.y)-a.velocity.y)/2,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) +/*! 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;","}"] +},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 diff --git a/docs/Animation.js.html b/docs/Animation.js.html index 47b8c564..0fbf3d3b 100644 --- a/docs/Animation.js.html +++ b/docs/Animation.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -864,7 +868,7 @@ Phaser.Animation.generateFrameNames = function (prefix, start, stop, suffix, zer Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/AnimationManager.js.html b/docs/AnimationManager.js.html index 9835eb67..4c9a95a2 100644 --- a/docs/AnimationManager.js.html +++ b/docs/AnimationManager.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -640,6 +644,27 @@ Phaser.AnimationManager.prototype = { }, + /** + * Returns an animation that was previously added by name. + * + * @method Phaser.AnimationManager#getAnimation + * @param {string} name - The name of the animation to be returned, e.g. "fire". + * @return {Phaser.Animation|boolean} The Animation instance, if found, otherwise false. + */ + getAnimation: function (name) { + + if (typeof name == 'string') + { + if (this._anims[name]) + { + return this._anims[name]; + } + } + + return false; + + }, + /** * Refreshes the current frame data back to the parent Sprite and also resets the texture data. * @@ -804,7 +829,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/AnimationParser.js.html b/docs/AnimationParser.js.html index 4440a4cc..e5234ffa 100644 --- a/docs/AnimationParser.js.html +++ b/docs/AnimationParser.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -722,7 +726,7 @@ Phaser.AnimationParser = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/ArcadePhysics.js.html b/docs/ArcadePhysics.js.html index 6ee2a0ed..6d7f6624 100644 --- a/docs/ArcadePhysics.js.html +++ b/docs/ArcadePhysics.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -551,19 +555,19 @@ Phaser.Physics.Arcade.prototype = { // If you're wondering why the velocity is halved and applied twice, read this: http://www.niksula.hut.fi/~hkankaan/Homepages/gravity.html // Rotation - this._velocityDelta = (this.computeVelocity(0, body, body.angularVelocity, body.angularAcceleration, body.angularDrag, body.maxAngular) - body.angularVelocity) / 2; + this._velocityDelta = (this.computeVelocity(0, body, body.angularVelocity, body.angularAcceleration, body.angularDrag, body.maxAngular) - body.angularVelocity) * this.game.time.physicsElapsed * 0.5 * 60; body.angularVelocity += this._velocityDelta; body.rotation += (body.angularVelocity * this.game.time.physicsElapsed); body.angularVelocity += this._velocityDelta; // Horizontal - this._velocityDelta = (this.computeVelocity(1, body, body.velocity.x, body.acceleration.x, body.drag.x, body.maxVelocity.x) - body.velocity.x) / 2; + this._velocityDelta = (this.computeVelocity(1, body, body.velocity.x, body.acceleration.x, body.drag.x, body.maxVelocity.x) - body.velocity.x) * this.game.time.physicsElapsed * 0.5 * 60; body.velocity.x += this._velocityDelta; body.x += (body.velocity.x * this.game.time.physicsElapsed); body.velocity.x += this._velocityDelta; // Vertical - this._velocityDelta = (this.computeVelocity(2, body, body.velocity.y, body.acceleration.y, body.drag.y, body.maxVelocity.y) - body.velocity.y) / 2; + this._velocityDelta = (this.computeVelocity(2, body, body.velocity.y, body.acceleration.y, body.drag.y, body.maxVelocity.y) - body.velocity.y) * this.game.time.physicsElapsed * 0.5 * 60; body.velocity.y += this._velocityDelta; body.y += (body.velocity.y * this.game.time.physicsElapsed); body.velocity.y += this._velocityDelta; @@ -1777,7 +1781,7 @@ Phaser.Physics.Arcade.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/BitmapText.js.html b/docs/BitmapText.js.html index b46e1b33..df269efd 100644 --- a/docs/BitmapText.js.html +++ b/docs/BitmapText.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -534,7 +538,7 @@ Phaser.BitmapText.prototype.destroy = function() { this.group.remove(this); } - if (this.canvas.parentNode) + if (this.canvas && this.canvas.parentNode) { this.canvas.parentNode.removeChild(this.canvas); } @@ -627,7 +631,7 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'y', { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Body.js.html b/docs/Body.js.html index d6616b37..28fb6378 100644 --- a/docs/Body.js.html +++ b/docs/Body.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1043,7 +1047,7 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "right", { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Button.js.html b/docs/Button.js.html index 023f97fd..87c5050b 100644 --- a/docs/Button.js.html +++ b/docs/Button.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -548,6 +552,13 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame, */ this.freezeFrames = false; + /** + * When the Button is clicked you can optionally force the state to "out". + * @property {boolean} forceOut + * @default + */ + this.forceOut = true; + this.setFrames(overFrame, outFrame, downFrame); if (callback !== null) @@ -632,7 +643,7 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) { { this._onDownFrameName = downFrame; - if (this.input.pointerOver()) + if (this.input.pointerDown()) { this.frameName = downFrame; } @@ -641,7 +652,7 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) { { this._onDownFrameID = downFrame; - if (this.input.pointerOver()) + if (this.input.pointerDown()) { this.frame = downFrame; } @@ -892,10 +903,23 @@ Phaser.Button.prototype.onInputUpHandler = function (pointer) { this.onUpSound.play(this.onUpSoundMarker); } + if (this.forceOut && this.freezeFrames == false) + { + if (this._onOutFrameName != null) + { + this.frameName = this._onOutFrameName; + } + else if (this._onOutFrameID != null) + { + this.frame = this._onOutFrameID; + } + } + if (this.onInputUp) { this.onInputUp.dispatch(this, pointer); } + }; @@ -918,7 +942,7 @@ Phaser.Button.prototype.onInputUpHandler = function (pointer) { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Cache.js.html b/docs/Cache.js.html index b9793fa9..5ae17783 100644 --- a/docs/Cache.js.html +++ b/docs/Cache.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1195,7 +1199,7 @@ Phaser.Cache.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Camera.js.html b/docs/Camera.js.html index d50ee15b..042ab50e 100644 --- a/docs/Camera.js.html +++ b/docs/Camera.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -798,7 +802,7 @@ Object.defineProperty(Phaser.Camera.prototype, "height", { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Canvas.js.html b/docs/Canvas.js.html index 9fb144f5..b197843e 100644 --- a/docs/Canvas.js.html +++ b/docs/Canvas.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -654,7 +658,7 @@ Phaser.Canvas = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Circle.js.html b/docs/Circle.js.html index 443a6f99..87783e6e 100644 --- a/docs/Circle.js.html +++ b/docs/Circle.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -868,7 +872,7 @@ Phaser.Circle.intersectsRectangle = function (c, r) { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Color.js.html b/docs/Color.js.html index aa47afd2..ae9f9a8e 100644 --- a/docs/Color.js.html +++ b/docs/Color.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -730,7 +734,7 @@ Phaser.Color = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Debug.js.html b/docs/Debug.js.html index 01bf87b6..fa17cedd 100644 --- a/docs/Debug.js.html +++ b/docs/Debug.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1279,7 +1283,7 @@ Phaser.Utils.Debug.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Device.js.html b/docs/Device.js.html index 2905f171..26494d63 100644 --- a/docs/Device.js.html +++ b/docs/Device.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -941,7 +945,7 @@ Phaser.Device.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Easing.js.html b/docs/Easing.js.html index b3b0877c..dc251ecd 100644 --- a/docs/Easing.js.html +++ b/docs/Easing.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -959,7 +963,7 @@ Phaser.Easing = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Emitter.js.html b/docs/Emitter.js.html index d53bd7c1..f7369574 100644 --- a/docs/Emitter.js.html +++ b/docs/Emitter.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1073,7 +1077,7 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "bottom", { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Events.js.html b/docs/Events.js.html index 9d55330d..4a193e95 100644 --- a/docs/Events.js.html +++ b/docs/Events.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -465,7 +469,7 @@ Phaser.Events.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Frame.js.html b/docs/Frame.js.html index 0b826f9d..8d83b6c9 100644 --- a/docs/Frame.js.html +++ b/docs/Frame.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -558,7 +562,7 @@ Phaser.Frame.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/FrameData.js.html b/docs/FrameData.js.html index 034ff23c..36d50d8e 100644 --- a/docs/FrameData.js.html +++ b/docs/FrameData.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -635,7 +639,7 @@ Object.defineProperty(Phaser.FrameData.prototype, "total", { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Game.js.html b/docs/Game.js.html index f062d053..8ea2b812 100644 --- a/docs/Game.js.html +++ b/docs/Game.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -801,7 +805,13 @@ Phaser.Game.prototype = { this.time.update(time); - if (!this._paused) + if (this._paused) + { + this.renderer.render(this.stage._stage); + this.plugins.render(); + this.state.render(); + } + else { this.plugins.preUpdate(); this.physics.preUpdate(); @@ -816,6 +826,7 @@ Phaser.Game.prototype = { this.plugins.update(); this.world.postUpdate(); + this.plugins.postUpdate(); this.renderer.render(this.stage._stage); this.plugins.render(); @@ -912,7 +923,7 @@ Object.defineProperty(Phaser.Game.prototype, "paused", { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/GameObjectFactory.js.html b/docs/GameObjectFactory.js.html index 3595a28c..68b4096b 100644 --- a/docs/GameObjectFactory.js.html +++ b/docs/GameObjectFactory.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -676,7 +680,7 @@ Phaser.GameObjectFactory.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Graphics.js.html b/docs/Graphics.js.html index 2d48fb93..dd5cb437 100644 --- a/docs/Graphics.js.html +++ b/docs/Graphics.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -429,6 +433,18 @@ Phaser.Graphics.prototype.destroy = function() { } +/* +* Draws a {Phaser.Polygon} or a {PIXI.Polygon} filled +*/ +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) { + 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', { get: function() { @@ -485,7 +501,7 @@ Object.defineProperty(Phaser.Graphics.prototype, 'y', { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Group.js.html b/docs/Group.js.html index eb4f189a..da0f04ad 100644 --- a/docs/Group.js.html +++ b/docs/Group.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -470,6 +474,36 @@ Phaser.Group = function (game, parent, name, useStage) { }; +/** +* @constant +* @type {number} +*/ +Phaser.Group.RETURN_NONE = 0; + +/** +* @constant +* @type {number} +*/ +Phaser.Group.RETURN_TOTAL = 1; + +/** +* @constant +* @type {number} +*/ +Phaser.Group.RETURN_CHILD = 2; + +/** +* @constant +* @type {number} +*/ +Phaser.Group.SORT_ASCENDING = -1; + +/** +* @constant +* @type {number} +*/ +Phaser.Group.SORT_DESCENDING = 1; + Phaser.Group.prototype = { /** @@ -682,8 +716,48 @@ Phaser.Group.prototype = { }, + childTest: function (prefix, child) { + + var s = prefix + ' next: '; + + if (child._iNext) + { + s = s + child._iNext.name; + } + else + { + s = s + '-null-'; + } + + s = s + ' ' + prefix + ' prev: '; + + if (child._iPrev) + { + s = s + child._iPrev.name; + } + else + { + s = s + '-null-'; + } + + console.log(s); + + }, + + swapIndex: function (index1, index2) { + + var child1 = this.getAt(index1); + var child2 = this.getAt(index2); + + console.log('swapIndex ', index1, ' with ', index2); + + this.swap(child1, child2); + + }, + /** - * Swaps the position of two children in this Group. + * Swaps the position of two children in this Group. Both children must be in this Group. + * You cannot swap a child with itself, or swap un-parented children, doing so will return false. * * @method Phaser.Group#swap * @param {*} child1 - The first child to swap. @@ -692,9 +766,8 @@ Phaser.Group.prototype = { */ swap: function (child1, child2) { - if (child1 === child2 || !child1.parent || !child2.parent) + if (child1 === child2 || !child1.parent || !child2.parent || child1.group !== this || child2.group !== this) { - console.warn('You cannot swap a child with itself or swap un-parented children'); return false; } @@ -766,7 +839,7 @@ Phaser.Group.prototype = { child2._iPrev = child1; if (child2Prev) { child2Prev._iNext = child1; } - if (child1Next) { child2Next._iPrev = child2; } + if (child1Next) { child1Next._iPrev = child2; } if (child1.__renderGroup) { @@ -1133,7 +1206,7 @@ Phaser.Group.prototype = { /** * Calls a function on all of the children regardless if they are dead or alive (see callAllExists if you need control over that) - * After the method parameter you can add as many extra parameters as you like, which will all be passed to the child. + * After the method parameter and context you can add as many extra parameters as you like, which will all be passed to the child. * * @method Phaser.Group#callAll * @param {string} method - A string containing the name of the function that will be called. The function must exist on the child. @@ -1239,6 +1312,24 @@ Phaser.Group.prototype = { }, + /** + * Allows you to call your own function on each alive member of this Group (where child.alive=true). You must pass the callback and context in which it will run. + * You can add as many parameters as you like, which will all be passed to the callback along with the child. + * For example: Group.forEachAlive(causeDamage, this, 500) + * + * @method Phaser.Group#forEachAlive + * @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter. + * @param {Object} callbackContext - The context in which the function should be called (usually 'this'). + */ + forEachExists: function (callback, callbackContext) { + + var args = Array.prototype.splice.call(arguments, 2); + args.unshift(null); + + this.iterate('exists', true, Phaser.Group.RETURN_TOTAL, callback, callbackContext, args); + + }, + /** * Allows you to call your own function on each alive member of this Group (where child.alive=true). You must pass the callback and context in which it will run. * You can add as many parameters as you like, which will all be passed to the callback along with the child. @@ -1253,23 +1344,7 @@ Phaser.Group.prototype = { var args = Array.prototype.splice.call(arguments, 2); args.unshift(null); - if (this._container.children.length > 0 && this._container.first._iNext) - { - var currentNode = this._container.first._iNext; - - do - { - if (currentNode.alive) - { - args[0] = currentNode; - callback.apply(callbackContext, args); - } - - currentNode = currentNode._iNext; - } - while (currentNode != this._container.last._iNext); - - } + this.iterate('alive', true, Phaser.Group.RETURN_TOTAL, callback, callbackContext, args); }, @@ -1287,23 +1362,121 @@ Phaser.Group.prototype = { var args = Array.prototype.splice.call(arguments, 2); args.unshift(null); + this.iterate('alive', false, Phaser.Group.RETURN_TOTAL, callback, callbackContext, args); + + }, + + /** + * Call this function to sort the group according to a particular value and order. + * For example to depth sort Sprites for Zelda-style game you might call `group.sort('y', Phaser.Group.SORT_ASCENDING)` at the bottom of your `State.update()`. + * + * @method Phaser.Group#sort + * @param {string} [index='y'] - The `string` name of the property you want to sort on. + * @param {number} [order=Phaser.Group.SORT_ASCENDING] - The `Group` constant that defines the sort order. Possible values are Phaser.Group.SORT_ASCENDING and Phaser.Group.SORT_DESCENDING. + */ + sort: function (index, order) { + + if (typeof index === 'undefined') { index = 'y'; } + if (typeof order === 'undefined') { order = Phaser.Group.SORT_ASCENDING; } + + var swapped; + var temp; + + do { + + swapped = false; + + for (var i = 0, len = this._container.children.length - 1; i < len; i++) + { + if (order == Phaser.Group.SORT_ASCENDING) + { + if (this._container.children[i][index] > this._container.children[i + 1][index]) + { + this.swap(this.getAt(i), this.getAt(i + 1)); + temp = this._container.children[i]; + this._container.children[i] = this._container.children[i + 1]; + this._container.children[i + 1] = temp; + swapped = true; + } + } + else + { + if (this._container.children[i][index] < this._container.children[i + 1][index]) + { + this.swap(this.getAt(i), this.getAt(i + 1)); + temp = this._container.children[i]; + this._container.children[i] = this._container.children[i + 1]; + this._container.children[i + 1] = temp; + swapped = true; + } + } + } + } while (swapped); + + }, + + /** + * Iterates over the children of the Group. When a child has a property matching key that equals the given value, it is considered as a match. + * Matched children can be sent to the optional callback, or simply returned or counted. + * You can add as many callback parameters as you like, which will all be passed to the callback along with the child, after the callbackContext parameter. + * + * @method Phaser.Group#iterate + * @param {string} key - The child property to check, i.e. 'exists', 'alive', 'health' + * @param {any} value - If child.key === this value it will be considered a match. Note that a strict comparison is used. + * @param {number} returnType - How to return the data from this method. Either Phaser.Group.RETURN_NONE, Phaser.Group.RETURN_TOTAL or Phaser.Group.RETURN_CHILD. + * @param {function} [callback=null] - Optional function that will be called on each matching child. Each child of the Group will be passed to it as its first parameter. + * @param {Object} [callbackContext] - The context in which the function should be called (usually 'this'). + */ + iterate: function (key, value, returnType, callback, callbackContext, args) { + + if (returnType == Phaser.Group.RETURN_TOTAL && this._container.children.length == 0) + { + return -1; + } + + if (typeof callback === 'undefined') + { + callback = false; + } + + var total = 0; + if (this._container.children.length > 0 && this._container.first._iNext) { var currentNode = this._container.first._iNext; do { - if (currentNode.alive == false) + if (currentNode[key] === value) { - args[0] = currentNode; - callback.apply(callbackContext, args); + total++; + + if (callback) + { + args[0] = currentNode; + callback.apply(callbackContext, args); + } + + if (returnType == Phaser.Group.RETURN_CHILD) + { + return currentNode; + } } currentNode = currentNode._iNext; } while (currentNode != this._container.last._iNext); - } + + if (returnType == Phaser.Group.RETURN_TOTAL) + { + return total; + } + else if (returnType == Phaser.Group.RETURN_CHILD) + { + return null; + } + }, /** @@ -1320,23 +1493,7 @@ Phaser.Group.prototype = { state = true; } - if (this._container.children.length > 0 && this._container.first._iNext) - { - var currentNode = this._container.first._iNext; - - do - { - if (currentNode.exists === state) - { - return currentNode; - } - - currentNode = currentNode._iNext; - } - while (currentNode != this._container.last._iNext); - } - - return null; + return this.iterate('exists', state, Phaser.Group.RETURN_CHILD); }, @@ -1349,23 +1506,7 @@ Phaser.Group.prototype = { */ getFirstAlive: function () { - if (this._container.children.length > 0 && this._container.first._iNext) - { - var currentNode = this._container.first._iNext; - - do - { - if (currentNode.alive) - { - return currentNode; - } - - currentNode = currentNode._iNext; - } - while (currentNode != this._container.last._iNext); - } - - return null; + return this.iterate('alive', true, Phaser.Group.RETURN_CHILD); }, @@ -1378,23 +1519,7 @@ Phaser.Group.prototype = { */ getFirstDead: function () { - if (this._container.children.length > 0 && this._container.first._iNext) - { - var currentNode = this._container.first._iNext; - - do - { - if (!currentNode.alive) - { - return currentNode; - } - - currentNode = currentNode._iNext; - } - while (currentNode != this._container.last._iNext); - } - - return null; + return this.iterate('alive', false, Phaser.Group.RETURN_CHILD); }, @@ -1406,29 +1531,7 @@ Phaser.Group.prototype = { */ countLiving: function () { - var total = 0; - - if (this._container.children.length > 0 && this._container.first._iNext) - { - var currentNode = this._container.first._iNext; - - do - { - if (currentNode.alive) - { - total++; - } - - currentNode = currentNode._iNext; - } - while (currentNode != this._container.last._iNext); - } - else - { - total = -1; - } - - return total; + return this.iterate('alive', true, Phaser.Group.RETURN_TOTAL); }, @@ -1440,29 +1543,7 @@ Phaser.Group.prototype = { */ countDead: function () { - var total = 0; - - if (this._container.children.length > 0 && this._container.first._iNext) - { - var currentNode = this._container.first._iNext; - - do - { - if (!currentNode.alive) - { - total++; - } - - currentNode = currentNode._iNext; - } - while (currentNode != this._container.last._iNext); - } - else - { - total = -1; - } - - return total; + return this.iterate('alive', false, Phaser.Group.RETURN_TOTAL); }, @@ -1607,6 +1688,48 @@ Phaser.Group.prototype = { }, + validate: function () { + + var testObject = this.game.stage._stage.last._iNext; + var displayObject = this.game.stage._stage; + var nextObject = null; + var prevObject = null; + var count = 0; + + do + { + if (count > 0) + { + // check next + if (displayObject !== nextObject) + { + console.log('check next fail'); + return false; + } + + // check previous + if (displayObject._iPrev !== prevObject) + { + console.log('check previous fail'); + return false; + } + } + + // Set the next object + nextObject = displayObject._iNext; + prevObject = displayObject; + + displayObject = displayObject._iNext; + + count++; + + } + while(displayObject != testObject) + + return true; + + }, + /** * Dumps out a list of Group children and their index positions to the browser console. Useful for group debugging. * @@ -1713,7 +1836,8 @@ Phaser.Group.prototype = { Object.defineProperty(Phaser.Group.prototype, "total", { get: function () { - return this._container.children.length; + return this.iterate('exists', true, Phaser.Group.RETURN_TOTAL); + // return this._container.children.length; } }); @@ -1726,7 +1850,8 @@ Object.defineProperty(Phaser.Group.prototype, "total", { Object.defineProperty(Phaser.Group.prototype, "length", { get: function () { - return this._container.children.length; + return this.iterate('exists', true, Phaser.Group.RETURN_TOTAL); + // return this._container.children.length; } }); @@ -1855,7 +1980,7 @@ Object.defineProperty(Phaser.Group.prototype, "alpha", { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Input.js.html b/docs/Input.js.html index d5f1506f..aa9b7b2a 100644 --- a/docs/Input.js.html +++ b/docs/Input.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1210,7 +1214,7 @@ Object.defineProperty(Phaser.Input.prototype, "worldY", { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/InputHandler.js.html b/docs/InputHandler.js.html index e68b5490..483dfbe7 100644 --- a/docs/InputHandler.js.html +++ b/docs/InputHandler.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -784,28 +788,60 @@ Phaser.InputHandler.prototype = { /** * Is the Pointer over this Sprite? * @method Phaser.InputHandler#pointerOver - * @param {Pointer} pointer - * @return {bool + * @param {number} [index] - The ID number of a Pointer to check. If you don't provide a number it will check all Pointers. + * @return {boolean} True if the given pointer (if a index was given, or any pointer if not) is over this object. */ - pointerOver: function (pointer) { + pointerOver: function (index) { - pointer = pointer || 0; + if (this.enabled) + { + if (typeof index === 'undefined') + { + for (var i = 0; i < 10; i++) + { + if (this._pointerData[i].isOver) + { + return true; + } + } + } + else + { + return this._pointerData[index].isOver; + } + } - return this._pointerData[pointer].isOver; + return false; }, /** * Is the Pointer outside of this Sprite? * @method Phaser.InputHandler#pointerOut - * @param {Pointer} pointer - * @return {boolean} + * @param {number} [index] - The ID number of a Pointer to check. If you don't provide a number it will check all Pointers. + * @return {boolean} True if the given pointer (if a index was given, or any pointer if not) is out of this object. */ pointerOut: function (pointer) { - pointer = pointer || 0; + if (this.enabled) + { + if (typeof index === 'undefined') + { + for (var i = 0; i < 10; i++) + { + if (this._pointerData[i].isOut) + { + return true; + } + } + } + else + { + return this._pointerData[index].isOut; + } + } - return this._pointerData[pointer].isOut; + return false; }, @@ -881,12 +917,13 @@ Phaser.InputHandler.prototype = { }, /** - * Description. - * @method Phaser.InputHandler#checkPixel - * @param {Description} x - Description. - * @param {Description} y - Description. - * @return {boolean} - */ + * Runs a pixel perfect check against the given x/y coordinates of the Sprite this InputHandler is bound to. + * It compares the alpha value of the pixel and if >= InputHandler.pixelPerfectAlpha it returns true. + * @method Phaser.InputHandler#checkPixel + * @param {number} x - The x coordinate to check. + * @param {number} y - The y coordinate to check. + * @return {boolean} true if there is the alpha of the pixel is >= InputHandler.pixelPerfectAlpha + */ checkPixel: function (x, y) { // Grab a pixel from our image into the hitCanvas and then test it @@ -894,8 +931,6 @@ Phaser.InputHandler.prototype = { { this.game.input.hitContext.clearRect(0, 0, 1, 1); - // This will fail if the image is part of a texture atlas - need to modify the x/y values here - x += this.sprite.texture.frame.x; y += this.sprite.texture.frame.y; @@ -1452,7 +1487,7 @@ Phaser.InputHandler.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/IntroDocs.js.html b/docs/IntroDocs.js.html index 6c32b017..4cd57b7d 100644 --- a/docs/IntroDocs.js.html +++ b/docs/IntroDocs.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -427,7 +431,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Key.js.html b/docs/Key.js.html index 1e0ceab4..75e4fc28 100644 --- a/docs/Key.js.html +++ b/docs/Key.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -569,7 +573,7 @@ Phaser.Key.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Keyboard.js.html b/docs/Keyboard.js.html index 17070eb2..a929d9b2 100644 --- a/docs/Keyboard.js.html +++ b/docs/Keyboard.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -894,7 +898,7 @@ Phaser.Keyboard.NUM_LOCK = 144; Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/LinkedList.js.html b/docs/LinkedList.js.html index 465b2b13..606b2939 100644 --- a/docs/LinkedList.js.html +++ b/docs/LinkedList.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -551,7 +555,7 @@ Phaser.LinkedList.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Loader.js.html b/docs/Loader.js.html index bc7ebe8a..95c93cd0 100644 --- a/docs/Loader.js.html +++ b/docs/Loader.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1505,7 +1509,7 @@ Phaser.Loader.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/LoaderParser.js.html b/docs/LoaderParser.js.html index 0fcb6275..0da848cf 100644 --- a/docs/LoaderParser.js.html +++ b/docs/LoaderParser.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -480,7 +484,7 @@ Phaser.LoaderParser = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/MSPointer.js.html b/docs/MSPointer.js.html index 403bc6a7..2f78850e 100644 --- a/docs/MSPointer.js.html +++ b/docs/MSPointer.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -580,7 +584,7 @@ Phaser.MSPointer.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Math.js.html b/docs/Math.js.html index 88685c7b..6dba8a8f 100644 --- a/docs/Math.js.html +++ b/docs/Math.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1568,7 +1572,7 @@ Phaser.Math = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Mouse.js.html b/docs/Mouse.js.html index 81ec4808..5db431af 100644 --- a/docs/Mouse.js.html +++ b/docs/Mouse.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -404,23 +408,29 @@ Phaser.Mouse = function (game) { this.callbackContext = this.game; /** - * @property {Description} mouseDownCallback - Description. + * @property {function} mouseDownCallback - Description. * @default */ this.mouseDownCallback = null; /** - * @property {Description} mouseMoveCallback - Description. + * @property {function} mouseMoveCallback - Description. * @default */ this.mouseMoveCallback = null; /** - * @property {Description} mouseUpCallback - Description. + * @property {function} mouseUpCallback - Description. * @default */ this.mouseUpCallback = null; + /** + * @property {number} button- The type of click, either: Phaser.Mouse.NO_BUTTON, Phaser.Mouse.LEFT_BUTTON, Phaser.Mouse.MIDDLE_BUTTON or Phaser.Mouse.RIGHT_BUTTON. + * @default + */ + this.button = -1; + /** * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. * @property {boolean} disabled @@ -435,8 +445,20 @@ Phaser.Mouse = function (game) { */ this.locked = false; + /** + * This event is dispatched when the browser enters or leaves pointer lock state. + * @property {Phaser.Signal} pointerLock + * @default + */ + this.pointerLock = new Phaser.Signal; + }; +/** +* @constant +* @type {number} +*/ +Phaser.Mouse.NO_BUTTON = -1; /** * @constant * @type {number} @@ -490,7 +512,7 @@ Phaser.Mouse.prototype = { }, /** - * Description. + * The internal method that handles the mouse down event from the browser. * @method Phaser.Mouse#onMouseDown * @param {MouseEvent} event */ @@ -498,6 +520,19 @@ Phaser.Mouse.prototype = { 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; + } + if (this.mouseDownCallback) { this.mouseDownCallback.call(this.callbackContext, event); @@ -515,7 +550,7 @@ Phaser.Mouse.prototype = { }, /** - * Description + * The internal method that handles the mouse move event from the browser. * @method Phaser.Mouse#onMouseMove * @param {MouseEvent} event */ @@ -540,7 +575,7 @@ Phaser.Mouse.prototype = { }, /** - * Description. + * The internal method that handles the mouse up event from the browser. * @method Phaser.Mouse#onMouseUp * @param {MouseEvent} event */ @@ -548,6 +583,8 @@ Phaser.Mouse.prototype = { event.preventDefault(); + this.button = Phaser.Mouse.NO_BUTTON; + if (this.mouseUpCallback) { this.mouseUpCallback.call(this.callbackContext, event); @@ -565,7 +602,9 @@ Phaser.Mouse.prototype = { }, /** - * Description. + * If the browser supports it you can request that the pointer be locked to the browser window. + * This is classically known as 'FPS controls', where the pointer can't leave the browser until the user presses an exit key. + * If the browser successfully enters a locked state the event Phaser.Mouse.pointerLock will be dispatched and the first parameter will be 'true'. * @method Phaser.Mouse#requestPointerLock */ requestPointerLock: function () { @@ -584,15 +623,15 @@ Phaser.Mouse.prototype = { return _this.pointerLockChange(event); }; - document.addEventListener('pointerlockchange', this._pointerLockChange, false); - document.addEventListener('mozpointerlockchange', this._pointerLockChange, false); - document.addEventListener('webkitpointerlockchange', this._pointerLockChange, false); + document.addEventListener('pointerlockchange', this._pointerLockChange, true); + document.addEventListener('mozpointerlockchange', this._pointerLockChange, true); + document.addEventListener('webkitpointerlockchange', this._pointerLockChange, true); } }, /** - * Description. + * Internal pointerLockChange handler. * @method Phaser.Mouse#pointerLockChange * @param {MouseEvent} event */ @@ -604,17 +643,19 @@ Phaser.Mouse.prototype = { { // Pointer was successfully locked this.locked = true; + this.pointerLock.dispatch(true); } else { // Pointer was unlocked this.locked = false; + this.pointerLock.dispatch(false); } }, /** - * Description. + * Internal release pointer lock handler. * @method Phaser.Mouse#releasePointerLock */ releasePointerLock: function () { @@ -623,9 +664,9 @@ Phaser.Mouse.prototype = { document.exitPointerLock(); - document.removeEventListener('pointerlockchange', this._pointerLockChange); - document.removeEventListener('mozpointerlockchange', this._pointerLockChange); - document.removeEventListener('webkitpointerlockchange', this._pointerLockChange); + document.removeEventListener('pointerlockchange', this._pointerLockChange, true); + document.removeEventListener('mozpointerlockchange', this._pointerLockChange, true); + document.removeEventListener('webkitpointerlockchange', this._pointerLockChange, true); }, @@ -635,13 +676,14 @@ Phaser.Mouse.prototype = { */ stop: function () { - this.game.stage.canvas.removeEventListener('mousedown', this._onMouseDown); - this.game.stage.canvas.removeEventListener('mousemove', this._onMouseMove); - this.game.stage.canvas.removeEventListener('mouseup', this._onMouseUp); + 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); } -}; +}; + @@ -662,7 +704,7 @@ Phaser.Mouse.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Net.js.html b/docs/Net.js.html index 99a23c3d..84afc8ca 100644 --- a/docs/Net.js.html +++ b/docs/Net.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -566,7 +570,7 @@ Phaser.Net.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Particles.js.html b/docs/Particles.js.html index 94e87fbd..070871e9 100644 --- a/docs/Particles.js.html +++ b/docs/Particles.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -471,7 +475,7 @@ Phaser.Particles.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Animation.html b/docs/Phaser.Animation.html index 2f1ed4d8..e0bd1c50 100644 --- a/docs/Phaser.Animation.html +++ b/docs/Phaser.Animation.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -2871,7 +2875,7 @@ You could use this function to generate those by doing: Phaser.Animation.generat Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:09 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:34 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.AnimationManager.html b/docs/Phaser.AnimationManager.html index 874564cd..dc5bd53f 100644 --- a/docs/Phaser.AnimationManager.html +++ b/docs/Phaser.AnimationManager.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -718,7 +722,7 @@ Any Game Object such as Phaser.Sprite that supports animation contains a single
    Source:
    @@ -820,7 +824,7 @@ Any Game Object such as Phaser.Sprite that supports animation contains a single
    Source:
    @@ -922,7 +926,7 @@ Any Game Object such as Phaser.Sprite that supports animation contains a single
    Source:
    @@ -1024,7 +1028,7 @@ Any Game Object such as Phaser.Sprite that supports animation contains a single
    Source:
    @@ -1333,7 +1337,7 @@ Any Game Object such as Phaser.Sprite that supports animation contains a single
    Source:
    @@ -1919,7 +1923,7 @@ Animations added in this way are played back with the play function.

    Source:
    @@ -1942,6 +1946,150 @@ Animations added in this way are played back with the play function.

    + + + + +
    +

    getAnimation(name) → {Phaser.Animation|boolean}

    + + +
    +
    + + +
    +

    Returns an animation that was previously added by name.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    name + + +string + + + +

    The name of the animation to be returned, e.g. "fire".

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The Animation instance, if found, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Animation +| + +boolean + + +
    +
    + + + + +
    @@ -2263,7 +2411,7 @@ If the requested animation is already playing this request will be ignored. If y
    Source:
    @@ -2780,7 +2928,7 @@ The currentAnim property of the AnimationManager is automatically set to the ani Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:09 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:34 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.AnimationParser.html b/docs/Phaser.AnimationParser.html index 91609250..8c442175 100644 --- a/docs/Phaser.AnimationParser.html +++ b/docs/Phaser.AnimationParser.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1364,7 +1368,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:09 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:34 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.BitmapText.html b/docs/Phaser.BitmapText.html index c2fcabfa..67ec9005 100644 --- a/docs/Phaser.BitmapText.html +++ b/docs/Phaser.BitmapText.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1545,7 +1549,7 @@ On OS X we recommend Glyph Designer: Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:09 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:34 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Button.html b/docs/Phaser.Button.html index 0ce4a260..fc107494 100644 --- a/docs/Phaser.Button.html +++ b/docs/Phaser.Button.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -815,6 +819,115 @@ You can set a unique texture frame and Sound for any of these states.

    +
    +

    forceOut

    + + +
    +
    + +
    +

    When the Button is clicked you can optionally force the state to "out".

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    forceOut + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + +

    freezeFrames

    @@ -2352,7 +2465,7 @@ You can set a unique texture frame and Sound for any of these states.

    Source:
    @@ -2470,7 +2583,7 @@ You can set a unique texture frame and Sound for any of these states.

    Source:
    @@ -2588,7 +2701,7 @@ You can set a unique texture frame and Sound for any of these states.

    Source:
    @@ -2706,7 +2819,7 @@ You can set a unique texture frame and Sound for any of these states.

    Source:
    @@ -2867,7 +2980,7 @@ You can set a unique texture frame and Sound for any of these states.

    Source:
    @@ -3073,7 +3186,7 @@ exactly like setting them in the constructor.

    Source:
    @@ -3234,7 +3347,7 @@ exactly like setting them in the constructor.

    Source:
    @@ -3395,7 +3508,7 @@ exactly like setting them in the constructor.

    Source:
    @@ -3758,7 +3871,7 @@ Call this function with no parameters at all to reset all sounds on this Button.
    Source:
    @@ -3919,7 +4032,7 @@ Call this function with no parameters at all to reset all sounds on this Button.
    Source:
    @@ -3970,7 +4083,7 @@ Call this function with no parameters at all to reset all sounds on this Button. Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:09 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:34 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Cache.html b/docs/Phaser.Cache.html index 6dfde218..b6fb91c5 100644 --- a/docs/Phaser.Cache.html +++ b/docs/Phaser.Cache.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -6870,7 +6874,7 @@ Normally you don't call this directly but instead use getImageKeys, getSoundKeys Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:09 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:34 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Camera.html b/docs/Phaser.Camera.html index 930de0ad..5a501c95 100644 --- a/docs/Phaser.Camera.html +++ b/docs/Phaser.Camera.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -3220,7 +3224,7 @@ without having to use game.camera.x and game.camera.y.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:09 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:34 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Canvas.html b/docs/Phaser.Canvas.html index 70c501fd..d4f9fe2c 100644 --- a/docs/Phaser.Canvas.html +++ b/docs/Phaser.Canvas.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -2464,7 +2468,7 @@ patchy on earlier browsers, especially on mobile.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:09 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:34 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Circle.html b/docs/Phaser.Circle.html index 2ba740c4..8cbcbbbe 100644 --- a/docs/Phaser.Circle.html +++ b/docs/Phaser.Circle.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -4244,7 +4248,7 @@ This method checks the radius distances between the two Circle objects to see if Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:10 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:35 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Color.html b/docs/Phaser.Color.html index 5f108429..965c2f08 100644 --- a/docs/Phaser.Color.html +++ b/docs/Phaser.Color.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -3573,7 +3577,7 @@ RGB format information and HSL information. Each section starts on a newline, 3 Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:10 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:35 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Device.html b/docs/Phaser.Device.html index c9809d4a..afa3b307 100644 --- a/docs/Phaser.Device.html +++ b/docs/Phaser.Device.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -4949,7 +4953,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:10 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:35 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Easing.Back.html b/docs/Phaser.Easing.Back.html index 465d44f9..1bee0470 100644 --- a/docs/Phaser.Easing.Back.html +++ b/docs/Phaser.Easing.Back.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -925,7 +929,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:10 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:35 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Easing.Bounce.html b/docs/Phaser.Easing.Bounce.html index bc3cc399..af52da80 100644 --- a/docs/Phaser.Easing.Bounce.html +++ b/docs/Phaser.Easing.Bounce.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -925,7 +929,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:10 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:35 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Easing.Circular.html b/docs/Phaser.Easing.Circular.html index c97ebbfd..9a94ace4 100644 --- a/docs/Phaser.Easing.Circular.html +++ b/docs/Phaser.Easing.Circular.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -925,7 +929,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:10 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:35 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Easing.Cubic.html b/docs/Phaser.Easing.Cubic.html index 04e62e43..041bd032 100644 --- a/docs/Phaser.Easing.Cubic.html +++ b/docs/Phaser.Easing.Cubic.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -925,7 +929,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:10 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:35 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Easing.Elastic.html b/docs/Phaser.Easing.Elastic.html index 3619cc8a..7df5e323 100644 --- a/docs/Phaser.Easing.Elastic.html +++ b/docs/Phaser.Easing.Elastic.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -925,7 +929,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:10 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:35 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Easing.Exponential.html b/docs/Phaser.Easing.Exponential.html index dce20e52..fd0fa461 100644 --- a/docs/Phaser.Easing.Exponential.html +++ b/docs/Phaser.Easing.Exponential.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -925,7 +929,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:10 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:36 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Easing.Linear.html b/docs/Phaser.Easing.Linear.html index 71bbc9ef..a4d84373 100644 --- a/docs/Phaser.Easing.Linear.html +++ b/docs/Phaser.Easing.Linear.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -643,7 +647,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:11 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:36 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Easing.Quadratic.html b/docs/Phaser.Easing.Quadratic.html index 9c35f11c..00ed7b2d 100644 --- a/docs/Phaser.Easing.Quadratic.html +++ b/docs/Phaser.Easing.Quadratic.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -925,7 +929,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:11 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:36 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Easing.Quartic.html b/docs/Phaser.Easing.Quartic.html index f986d813..b251fbf6 100644 --- a/docs/Phaser.Easing.Quartic.html +++ b/docs/Phaser.Easing.Quartic.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -925,7 +929,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:11 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:36 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Easing.Quintic.html b/docs/Phaser.Easing.Quintic.html index 909d6a88..e9bc1318 100644 --- a/docs/Phaser.Easing.Quintic.html +++ b/docs/Phaser.Easing.Quintic.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -925,7 +929,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:11 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:36 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Easing.Sinusoidal.html b/docs/Phaser.Easing.Sinusoidal.html index 1ce4fdc2..c634c2a1 100644 --- a/docs/Phaser.Easing.Sinusoidal.html +++ b/docs/Phaser.Easing.Sinusoidal.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -925,7 +929,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:11 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:36 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Easing.html b/docs/Phaser.Easing.html index 13b7c936..f22ee2d0 100644 --- a/docs/Phaser.Easing.html +++ b/docs/Phaser.Easing.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -535,7 +539,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:10 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:35 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Events.html b/docs/Phaser.Events.html index 91377828..293b41b8 100644 --- a/docs/Phaser.Events.html +++ b/docs/Phaser.Events.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -549,7 +553,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:11 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:36 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Frame.html b/docs/Phaser.Frame.html index 81cc1d23..4c63fb1e 100644 --- a/docs/Phaser.Frame.html +++ b/docs/Phaser.Frame.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -2910,7 +2914,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:11 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:36 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.FrameData.html b/docs/Phaser.FrameData.html index 226c2bc4..8146f260 100644 --- a/docs/Phaser.FrameData.html +++ b/docs/Phaser.FrameData.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1857,7 +1861,7 @@ The frames are returned in the output array, or if none is provided in a new Arr Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:11 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:36 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Game.html b/docs/Phaser.Game.html index efe4da3d..897b6586 100644 --- a/docs/Phaser.Game.html +++ b/docs/Phaser.Game.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -2753,7 +2757,7 @@ When a game is paused the onPause event is dispatched. When it is resumed the on
    Source:
    @@ -4240,7 +4244,7 @@ When a game is paused the onPause event is dispatched. When it is resumed the on
    Source:
    @@ -4616,7 +4620,7 @@ When a game is paused the onPause event is dispatched. When it is resumed the on Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:11 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:36 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.GameObjectFactory.html b/docs/Phaser.GameObjectFactory.html index fe15f340..e4e143a7 100644 --- a/docs/Phaser.GameObjectFactory.html +++ b/docs/Phaser.GameObjectFactory.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -4130,7 +4134,7 @@ at set intervals, and fixes their positions and velocities accorindgly.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:11 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:36 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Graphics.html b/docs/Phaser.Graphics.html index 9074ef47..953c4c50 100644 --- a/docs/Phaser.Graphics.html +++ b/docs/Phaser.Graphics.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -701,7 +705,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:12 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:37 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Group.html b/docs/Phaser.Group.html index e7d86d96..cef437cb 100644 --- a/docs/Phaser.Group.html +++ b/docs/Phaser.Group.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -656,6 +660,306 @@
    +
    +

    <static, constant> RETURN_CHILD :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> RETURN_NONE :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> RETURN_TOTAL :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> SORT_ASCENDING :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> SORT_DESCENDING :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + +

    alpha

    @@ -741,7 +1045,7 @@
    Source:
    @@ -848,7 +1152,7 @@ This will have no impact on the rotation value of its children, but it will upda
    Source:
    @@ -1264,7 +1568,7 @@ The cursor is set to the first child added to the Group and doesn't change unles
    Source:
    @@ -1473,7 +1777,7 @@ This will have no impact on the rotation value of its children, but it will upda
    Source:
    @@ -1677,7 +1981,7 @@ This will have no impact on the rotation value of its children, but it will upda
    Source:
    @@ -1881,7 +2185,7 @@ This will have no impact on the rotation value of its children, but it will upda
    Source:
    @@ -1988,7 +2292,7 @@ This will have no impact on the x/y coordinates of its children, but it will upd
    Source:
    @@ -2095,7 +2399,7 @@ This will have no impact on the x/y coordinates of its children, but it will upd
    Source:
    @@ -2211,7 +2515,7 @@ that then see the addAt method.

    Source:
    @@ -2431,7 +2735,7 @@ Group.addAll('x', 10) will add 10 to the child.x value.

    Source:
    @@ -2573,7 +2877,7 @@ The child is added to the Group at the location specified by the index value, th
    Source:
    @@ -2714,7 +3018,7 @@ The child is added to the Group at the location specified by the index value, th
    Source:
    @@ -2774,7 +3078,7 @@ The child is added to the Group at the location specified by the index value, th

    Calls a function on all of the children regardless if they are dead or alive (see callAllExists if you need control over that) -After the method parameter you can add as many extra parameters as you like, which will all be passed to the child.

    +After the method parameter and context you can add as many extra parameters as you like, which will all be passed to the child.

    @@ -2948,7 +3252,7 @@ After the method parameter you can add as many extra parameters as you like, whi
    Source:
    @@ -3141,7 +3445,7 @@ After the existsValue parameter you can add as many parameters as you like, whic
    Source:
    @@ -3305,7 +3609,7 @@ After the existsValue parameter you can add as many parameters as you like, whic
    Source:
    @@ -3374,7 +3678,7 @@ After the existsValue parameter you can add as many parameters as you like, whic
    Source:
    @@ -3466,7 +3770,7 @@ After the existsValue parameter you can add as many parameters as you like, whic
    Source:
    @@ -3773,7 +4077,7 @@ Useful if you don't need to create the Sprite instances before-hand.

    Source:
    @@ -4046,7 +4350,7 @@ and will be positioned at 0, 0 (relative to the Group.x/y)

    Source:
    @@ -4115,7 +4419,7 @@ and will be positioned at 0, 0 (relative to the Group.x/y)

    Source:
    @@ -4303,7 +4607,7 @@ Group.divideAll('x', 2) will half the child.x value.

    Source:
    @@ -4441,7 +4745,7 @@ Group.divideAll('x', 2) will half the child.x value.

    Source:
    @@ -4607,7 +4911,7 @@ For example: Group.forEach(awardBonusGold, this, true, 100, 500)

    Source:
    @@ -4750,7 +5054,150 @@ For example: Group.forEachAlive(causeDamage, this, 500)

    Source:
    + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    +

    forEachAlive(callback, callbackContext)

    + + +
    +
    + + +
    +

    Allows you to call your own function on each alive member of this Group (where child.alive=true). You must pass the callback and context in which it will run. +You can add as many parameters as you like, which will all be passed to the callback along with the child. +For example: Group.forEachAlive(causeDamage, this, 500)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    callback + + +function + + + +

    The function that will be called. Each child of the Group will be passed to it as its first parameter.

    callbackContext + + +Object + + + +

    The context in which the function should be called (usually 'this').

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    @@ -4893,7 +5340,7 @@ For example: Group.forEachDead(bringToLife, this)

    Source:
    @@ -5011,7 +5458,7 @@ For example: Group.forEachDead(bringToLife, this)

    Source:
    @@ -5104,7 +5551,7 @@ This is handy for checking if everything has been wiped out, or choosing a squad
    Source:
    @@ -5197,7 +5644,7 @@ This is handy for checking if everything has been wiped out, or choosing a squad
    Source:
    @@ -5338,7 +5785,7 @@ This is handy for checking if everything has been wiped out, or choosing a squad
    Source:
    @@ -5479,7 +5926,7 @@ This is handy for checking if everything has been wiped out, or choosing a squad
    Source:
    @@ -5643,7 +6090,7 @@ This is handy for checking if everything has been wiped out, or choosing a squad
    Source:
    @@ -5689,6 +6136,288 @@ This is handy for checking if everything has been wiped out, or choosing a squad +
    + + + +
    +

    iterate(key, value, returnType, callback, callbackContext)

    + + +
    +
    + + +
    +

    Iterates over the children of the Group. When a child has a property matching key that equals the given value, it is considered as a match. +Matched children can be sent to the optional callback, or simply returned or counted. +You can add as many callback parameters as you like, which will all be passed to the callback along with the child, after the callbackContext parameter.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    key + + +string + + + + + + + + + + + +

    The child property to check, i.e. 'exists', 'alive', 'health'

    value + + +any + + + + + + + + + + + +

    If child.key === this value it will be considered a match. Note that a strict comparison is used.

    returnType + + +number + + + + + + + + + + + +

    How to return the data from this method. Either Phaser.Group.RETURN_NONE, Phaser.Group.RETURN_TOTAL or Phaser.Group.RETURN_CHILD.

    callback + + +function + + + + + + <optional>
    + + + + + +
    + + null + +

    Optional function that will be called on each matching child. Each child of the Group will be passed to it as its first parameter.

    callbackContext + + +Object + + + + + + <optional>
    + + + + + +
    + +

    The context in which the function should be called (usually 'this').

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + +
    @@ -5854,7 +6583,7 @@ Group.multiplyAll('x', 2) will x2 the child.x value.

    Source:
    @@ -5923,7 +6652,7 @@ Group.multiplyAll('x', 2) will x2 the child.x value.

    Source:
    @@ -5992,7 +6721,7 @@ Group.multiplyAll('x', 2) will x2 the child.x value.

    Source:
    @@ -6110,7 +6839,7 @@ Group.multiplyAll('x', 2) will x2 the child.x value.

    Source:
    @@ -6180,7 +6909,7 @@ The Group container remains on the display list.

    Source:
    @@ -6321,7 +7050,7 @@ The Group container remains on the display list.

    Source:
    @@ -6462,7 +7191,7 @@ The Group container remains on the display list.

    Source:
    @@ -6749,7 +7478,7 @@ The operation parameter controls how the new value is assigned to the property,
    Source:
    @@ -6992,7 +7721,185 @@ The operation parameter controls how the new value is assigned to the property,
    Source:
    + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    +

    sort(index, order)

    + + +
    +
    + + +
    +

    Call this function to sort the group according to a particular value and order. +For example to depth sort Sprites for Zelda-style game you might call group.sort('y', Phaser.Group.SORT_ASCENDING) at the bottom of your State.update().

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    index + + +string + + + + + + <optional>
    + + + + + +
    + + 'y' + +

    The string name of the property you want to sort on.

    order + + +number + + + + + + <optional>
    + + + + + +
    + + Phaser.Group.SORT_ASCENDING + +

    The Group constant that defines the sort order. Possible values are Phaser.Group.SORT_ASCENDING and Phaser.Group.SORT_DESCENDING.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    @@ -7180,7 +8087,7 @@ Group.subAll('x', 10) will minus 10 from the child.x value.

    Source:
    @@ -7216,7 +8123,8 @@ Group.subAll('x', 10) will minus 10 from the child.x value.

    -

    Swaps the position of two children in this Group.

    +

    Swaps the position of two children in this Group. Both children must be in this Group. +You cannot swap a child with itself, or swap un-parented children, doing so will return false.

    @@ -7321,7 +8229,7 @@ Group.subAll('x', 10) will minus 10 from the child.x value.

    Source:
    @@ -7395,7 +8303,7 @@ Group.subAll('x', 10) will minus 10 from the child.x value.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:12 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:37 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Input.html b/docs/Phaser.Input.html index dbcf6212..a132e7f6 100644 --- a/docs/Phaser.Input.html +++ b/docs/Phaser.Input.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -7270,7 +7274,7 @@ If you need more then use this to create a new one, up to a maximum of 10.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:12 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:37 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.InputHandler.html b/docs/Phaser.InputHandler.html index 1807f2f7..2627c7d7 100644 --- a/docs/Phaser.InputHandler.html +++ b/docs/Phaser.InputHandler.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -3193,7 +3197,7 @@ For example if you had a stack of 6 sprites with the same priority IDs and one c
    Source:
    @@ -3262,7 +3266,7 @@ For example if you had a stack of 6 sprites with the same priority IDs and one c
    Source:
    @@ -3298,7 +3302,8 @@ For example if you had a stack of 6 sprites with the same priority IDs and one c
    -

    Description.

    +

    Runs a pixel perfect check against the given x/y coordinates of the Sprite this InputHandler is bound to. +It compares the alpha value of the pixel and if >= InputHandler.pixelPerfectAlpha it returns true.

    @@ -3338,7 +3343,7 @@ For example if you had a stack of 6 sprites with the same priority IDs and one c -Description +number @@ -3348,7 +3353,7 @@ For example if you had a stack of 6 sprites with the same priority IDs and one c -

    Description.

    +

    The x coordinate to check.

    @@ -3361,7 +3366,7 @@ For example if you had a stack of 6 sprites with the same priority IDs and one c -Description +number @@ -3371,7 +3376,7 @@ For example if you had a stack of 6 sprites with the same priority IDs and one c -

    Description.

    +

    The y coordinate to check.

    @@ -3403,7 +3408,7 @@ For example if you had a stack of 6 sprites with the same priority IDs and one c
    Source:
    @@ -3427,6 +3432,10 @@ For example if you had a stack of 6 sprites with the same priority IDs and one c
    Returns:
    +
    +

    true if there is the alpha of the pixel is >= InputHandler.pixelPerfectAlpha

    +
    +
    @@ -3540,7 +3549,7 @@ For example if you had a stack of 6 sprites with the same priority IDs and one c
    Source:
    @@ -3697,7 +3706,7 @@ For example if you had a stack of 6 sprites with the same priority IDs and one c
    Source:
    @@ -3766,7 +3775,7 @@ For example if you had a stack of 6 sprites with the same priority IDs and one c
    Source:
    @@ -3884,7 +3893,7 @@ For example if you had a stack of 6 sprites with the same priority IDs and one c
    Source:
    @@ -4110,7 +4119,7 @@ For example if you had a stack of 6 sprites with the same priority IDs and one c
    Source:
    @@ -4278,7 +4287,7 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16
    Source:
    @@ -4419,7 +4428,7 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16
    Source:
    @@ -4579,7 +4588,7 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16
    Source:
    @@ -4739,7 +4748,7 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16
    Source:
    @@ -4899,7 +4908,7 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16
    Source:
    @@ -5036,7 +5045,7 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16
    Source:
    @@ -5224,7 +5233,7 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16
    -

    pointerOut(pointer) → {boolean}

    +

    pointerOut(index) → {boolean}

    @@ -5254,6 +5263,8 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16 Type + Argument + @@ -5266,23 +5277,33 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16 - pointer + index -Pointer +number + + + <optional>
    + + + + + + + - +

    The ID number of a Pointer to check. If you don't provide a number it will check all Pointers.

    @@ -5314,7 +5335,7 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16
    Source:
    @@ -5338,6 +5359,10 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16
    Returns:
    +
    +

    True if the given pointer (if a index was given, or any pointer if not) is out of this object.

    +
    +
    @@ -5361,7 +5386,7 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16
    -

    pointerOver(pointer)

    +

    pointerOver(index) → {boolean}

    @@ -5391,6 +5416,8 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16 Type + Argument + @@ -5403,23 +5430,33 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16 - pointer + index -Pointer +number + + + <optional>
    + + + + + + + - +

    The ID number of a Pointer to check. If you don't provide a number it will check all Pointers.

    @@ -5476,11 +5513,23 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16
    -

    {bool

    +

    True if the given pointer (if a index was given, or any pointer if not) is over this object.

    +
    +
    + Type +
    +
    + +boolean + + +
    +
    + @@ -5717,7 +5766,7 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16
    Source:
    @@ -5854,7 +5903,7 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16
    Source:
    @@ -5991,7 +6040,7 @@ For example 16x16 as the snapX and snapY would make the sprite snap to every 16
    Source:
    @@ -6768,7 +6817,7 @@ This value is only set when the pointer is over this Sprite.

    Source:
    @@ -7001,7 +7050,7 @@ This value is only set when the pointer is over this Sprite.

    Source:
    @@ -7139,7 +7188,7 @@ This value is only set when the pointer is over this Sprite.

    Source:
    @@ -7257,7 +7306,7 @@ This value is only set when the pointer is over this Sprite.

    Source:
    @@ -7375,7 +7424,7 @@ This value is only set when the pointer is over this Sprite.

    Source:
    @@ -7445,7 +7494,7 @@ This value is only set when the pointer is over this Sprite.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:12 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:37 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Key.html b/docs/Phaser.Key.html index 206d4fea..f11cdd48 100644 --- a/docs/Phaser.Key.html +++ b/docs/Phaser.Key.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -2492,7 +2496,7 @@ If the key is up it holds the duration of the previous down session.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:12 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:37 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Keyboard.html b/docs/Phaser.Keyboard.html index a81a8f6e..900b3eb2 100644 --- a/docs/Phaser.Keyboard.html +++ b/docs/Phaser.Keyboard.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -2919,7 +2923,7 @@ This is called automatically by Phaser.Input and should not normally be invoked Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:12 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:37 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.LinkedList.html b/docs/Phaser.LinkedList.html index 5559cd17..ea3e575e 100644 --- a/docs/Phaser.LinkedList.html +++ b/docs/Phaser.LinkedList.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1411,7 +1415,7 @@ The function must exist on the member.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:12 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:37 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Loader.html b/docs/Phaser.Loader.html index 7e09d445..43c90d7e 100644 --- a/docs/Phaser.Loader.html +++ b/docs/Phaser.Loader.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -5881,7 +5885,7 @@ This allows you to easily make loading bars for games.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:12 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:37 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.LoaderParser.html b/docs/Phaser.LoaderParser.html index 810d294a..96eaeadb 100644 --- a/docs/Phaser.LoaderParser.html +++ b/docs/Phaser.LoaderParser.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -643,7 +647,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:13 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:38 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.MSPointer.html b/docs/Phaser.MSPointer.html index 22b4862d..63e0df79 100644 --- a/docs/Phaser.MSPointer.html +++ b/docs/Phaser.MSPointer.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1676,7 +1680,7 @@ It will work only in Internet Explorer 10 and Windows Store or Windows Phone 8 a Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:13 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:38 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Math.html b/docs/Phaser.Math.html index bb997bae..97ffb3c2 100644 --- a/docs/Phaser.Math.html +++ b/docs/Phaser.Math.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -10142,7 +10146,7 @@ Should be called whenever the angle is updated on the Sprite to stop it from goi Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:13 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:38 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Mouse.html b/docs/Phaser.Mouse.html index f70b4fe1..d676a68d 100644 --- a/docs/Phaser.Mouse.html +++ b/docs/Phaser.Mouse.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -570,7 +574,7 @@
    Source:
    @@ -630,7 +634,67 @@
    Source:
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> NO_BUTTON :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    @@ -690,7 +754,109 @@
    Source:
    + + + + + + + +
    + + + +
    + + + +
    +

    button

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    button- + + +number + + + +

    The type of click, either: Phaser.Mouse.NO_BUTTON, Phaser.Mouse.LEFT_BUTTON, Phaser.Mouse.MIDDLE_BUTTON or Phaser.Mouse.RIGHT_BUTTON.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    @@ -901,7 +1067,7 @@
    Source:
    @@ -1112,7 +1278,7 @@
    Source:
    @@ -1175,7 +1341,7 @@ -Description +function @@ -1280,7 +1446,7 @@ -Description +function @@ -1385,7 +1551,7 @@ -Description +function @@ -1436,6 +1602,112 @@ +
    + + + +
    + + + +
    +

    pointerLock

    + + +
    +
    + +
    +

    This event is dispatched when the browser enters or leaves pointer lock state.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointerLock + + +Phaser.Signal + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + +
    @@ -1459,7 +1731,7 @@
    -

    Description.

    +

    The internal method that handles the mouse down event from the browser.

    @@ -1541,7 +1813,7 @@
    Source:
    @@ -1577,7 +1849,7 @@
    -

    Description

    +

    The internal method that handles the mouse move event from the browser.

    @@ -1659,7 +1931,7 @@
    Source:
    @@ -1695,7 +1967,7 @@
    -

    Description.

    +

    The internal method that handles the mouse up event from the browser.

    @@ -1777,7 +2049,7 @@
    Source:
    @@ -1813,7 +2085,7 @@
    -

    Description.

    +

    Internal pointerLockChange handler.

    @@ -1895,7 +2167,7 @@
    Source:
    @@ -1931,7 +2203,7 @@
    -

    Description.

    +

    Internal release pointer lock handler.

    @@ -1964,7 +2236,7 @@
    Source:
    @@ -2000,7 +2272,9 @@
    -

    Description.

    +

    If the browser supports it you can request that the pointer be locked to the browser window. +This is classically known as 'FPS controls', where the pointer can't leave the browser until the user presses an exit key. +If the browser successfully enters a locked state the event Phaser.Mouse.pointerLock will be dispatched and the first parameter will be 'true'.

    @@ -2033,7 +2307,7 @@
    Source:
    @@ -2102,7 +2376,7 @@
    Source:
    @@ -2171,7 +2445,7 @@
    Source:
    @@ -2222,7 +2496,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:13 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:38 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Net.html b/docs/Phaser.Net.html index 544e069f..78553c1a 100644 --- a/docs/Phaser.Net.html +++ b/docs/Phaser.Net.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1301,7 +1305,7 @@ Optionally you can redirect to the new url, or just return it as a string.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:13 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:38 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Particles.Arcade.Emitter.html b/docs/Phaser.Particles.Arcade.Emitter.html index 256cb53b..97066777 100644 --- a/docs/Phaser.Particles.Arcade.Emitter.html +++ b/docs/Phaser.Particles.Arcade.Emitter.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -867,7 +871,7 @@ This will have no impact on the rotation value of its children, but it will upda
    Source:
    @@ -2260,7 +2264,7 @@ Emitter.emitX and Emitter.emitY control the emission location relative to the x/
    Source:
    @@ -3766,7 +3770,7 @@ This will have no impact on the rotation value of its children, but it will upda
    Source:
    @@ -4082,7 +4086,7 @@ This will have no impact on the rotation value of its children, but it will upda
    Source:
    @@ -4930,7 +4934,7 @@ that then see the addAt method.

    Source:
    @@ -5155,7 +5159,7 @@ Group.addAll('x', 10) will add 10 to the child.x value.

    Source:
    @@ -5302,7 +5306,7 @@ The child is added to the Group at the location specified by the index value, th
    Source:
    @@ -5566,7 +5570,7 @@ The child is added to the Group at the location specified by the index value, th
    Source:
    @@ -5626,7 +5630,7 @@ The child is added to the Group at the location specified by the index value, th

    Calls a function on all of the children regardless if they are dead or alive (see callAllExists if you need control over that) -After the method parameter you can add as many extra parameters as you like, which will all be passed to the child.

    +After the method parameter and context you can add as many extra parameters as you like, which will all be passed to the child.

    @@ -5805,7 +5809,7 @@ After the method parameter you can add as many extra parameters as you like, whi
    Source:
    @@ -6003,7 +6007,7 @@ After the existsValue parameter you can add as many parameters as you like, whic
    Source:
    @@ -6172,7 +6176,7 @@ After the existsValue parameter you can add as many parameters as you like, whic
    Source:
    @@ -6246,7 +6250,7 @@ After the existsValue parameter you can add as many parameters as you like, whic
    Source:
    @@ -6343,7 +6347,7 @@ After the existsValue parameter you can add as many parameters as you like, whic
    Source:
    @@ -6655,7 +6659,7 @@ Useful if you don't need to create the Sprite instances before-hand.

    Source:
    @@ -6933,7 +6937,7 @@ and will be positioned at 0, 0 (relative to the Group.x/y)

    Source:
    @@ -7007,7 +7011,7 @@ and will be positioned at 0, 0 (relative to the Group.x/y)

    Source:
    @@ -7200,7 +7204,7 @@ Group.divideAll('x', 2) will half the child.x value.

    Source:
    @@ -7343,7 +7347,7 @@ Group.divideAll('x', 2) will half the child.x value.

    Source:
    @@ -7583,7 +7587,7 @@ For example: Group.forEach(awardBonusGold, this, true, 100, 500)

    Source:
    @@ -7731,7 +7735,155 @@ For example: Group.forEachAlive(causeDamage, this, 500)

    Source:
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    forEachAlive(callback, callbackContext)

    + + +
    +
    + + +
    +

    Allows you to call your own function on each alive member of this Group (where child.alive=true). You must pass the callback and context in which it will run. +You can add as many parameters as you like, which will all be passed to the callback along with the child. +For example: Group.forEachAlive(causeDamage, this, 500)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    callback + + +function + + + +

    The function that will be called. Each child of the Group will be passed to it as its first parameter.

    callbackContext + + +Object + + + +

    The context in which the function should be called (usually 'this').

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    @@ -7879,7 +8031,7 @@ For example: Group.forEachDead(bringToLife, this)

    Source:
    @@ -8002,7 +8154,7 @@ For example: Group.forEachDead(bringToLife, this)

    Source:
    @@ -8100,7 +8252,7 @@ This is handy for checking if everything has been wiped out, or choosing a squad
    Source:
    @@ -8198,7 +8350,7 @@ This is handy for checking if everything has been wiped out, or choosing a squad
    Source:
    @@ -8344,7 +8496,7 @@ This is handy for checking if everything has been wiped out, or choosing a squad
    Source:
    @@ -8490,7 +8642,7 @@ This is handy for checking if everything has been wiped out, or choosing a squad
    Source:
    @@ -8659,7 +8811,7 @@ This is handy for checking if everything has been wiped out, or choosing a squad
    Source:
    @@ -8705,6 +8857,293 @@ This is handy for checking if everything has been wiped out, or choosing a squad +
    + + + +
    +

    iterate(key, value, returnType, callback, callbackContext)

    + + +
    +
    + + +
    +

    Iterates over the children of the Group. When a child has a property matching key that equals the given value, it is considered as a match. +Matched children can be sent to the optional callback, or simply returned or counted. +You can add as many callback parameters as you like, which will all be passed to the callback along with the child, after the callbackContext parameter.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    key + + +string + + + + + + + + + + + +

    The child property to check, i.e. 'exists', 'alive', 'health'

    value + + +any + + + + + + + + + + + +

    If child.key === this value it will be considered a match. Note that a strict comparison is used.

    returnType + + +number + + + + + + + + + + + +

    How to return the data from this method. Either Phaser.Group.RETURN_NONE, Phaser.Group.RETURN_TOTAL or Phaser.Group.RETURN_CHILD.

    callback + + +function + + + + + + <optional>
    + + + + + +
    + + null + +

    Optional function that will be called on each matching child. Each child of the Group will be passed to it as its first parameter.

    callbackContext + + +Object + + + + + + <optional>
    + + + + + +
    + +

    The context in which the function should be called (usually 'this').

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + +
    @@ -9165,7 +9604,7 @@ Group.multiplyAll('x', 2) will x2 the child.x value.

    Source:
    @@ -9239,7 +9678,7 @@ Group.multiplyAll('x', 2) will x2 the child.x value.

    Source:
    @@ -9313,7 +9752,7 @@ Group.multiplyAll('x', 2) will x2 the child.x value.

    Source:
    @@ -9436,7 +9875,7 @@ Group.multiplyAll('x', 2) will x2 the child.x value.

    Source:
    @@ -9511,7 +9950,7 @@ The Group container remains on the display list.

    Source:
    @@ -9657,7 +10096,7 @@ The Group container remains on the display list.

    Source:
    @@ -9803,7 +10242,7 @@ The Group container remains on the display list.

    Source:
    @@ -10165,7 +10604,7 @@ The operation parameter controls how the new value is assigned to the property,
    Source:
    @@ -10413,7 +10852,7 @@ The operation parameter controls how the new value is assigned to the property,
    Source:
    @@ -11000,6 +11439,189 @@ The operation parameter controls how the new value is assigned to the property, + + + + +
    +

    sort(index, order)

    + + +
    +
    + + +
    +

    Call this function to sort the group according to a particular value and order. +For example to depth sort Sprites for Zelda-style game you might call group.sort('y', Phaser.Group.SORT_ASCENDING) at the bottom of your State.update().

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    index + + +string + + + + + + <optional>
    + + + + + +
    + + 'y' + +

    The string name of the property you want to sort on.

    order + + +number + + + + + + <optional>
    + + + + + +
    + + Phaser.Group.SORT_ASCENDING + +

    The Group constant that defines the sort order. Possible values are Phaser.Group.SORT_ASCENDING and Phaser.Group.SORT_DESCENDING.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + +
    @@ -11357,7 +11979,7 @@ Group.subAll('x', 10) will minus 10 from the child.x value.

    Source:
    @@ -11393,7 +12015,8 @@ Group.subAll('x', 10) will minus 10 from the child.x value.

    -

    Swaps the position of two children in this Group.

    +

    Swaps the position of two children in this Group. Both children must be in this Group. +You cannot swap a child with itself, or swap un-parented children, doing so will return false.

    @@ -11503,7 +12126,7 @@ Group.subAll('x', 10) will minus 10 from the child.x value.

    Source:
    @@ -11646,7 +12269,7 @@ Group.subAll('x', 10) will minus 10 from the child.x value.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:13 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:38 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Particles.html b/docs/Phaser.Particles.html index 5aff66c8..1afe0077 100644 --- a/docs/Phaser.Particles.html +++ b/docs/Phaser.Particles.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1092,7 +1096,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:13 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:38 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Physics.Arcade.Body.html b/docs/Phaser.Physics.Arcade.Body.html index 06781bc0..60d935a6 100644 --- a/docs/Phaser.Physics.Arcade.Body.html +++ b/docs/Phaser.Physics.Arcade.Body.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -6100,7 +6104,7 @@ touching.up = true means the collision happened to the top of this Body for exam Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:13 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:39 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Physics.Arcade.html b/docs/Phaser.Physics.Arcade.html index 5910418c..d5441c71 100644 --- a/docs/Phaser.Physics.Arcade.html +++ b/docs/Phaser.Physics.Arcade.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -7595,7 +7599,7 @@ One way to use this is: velocityFromRotation(rotation, 200, sprite.velocity) whi Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:13 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:39 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Physics.html b/docs/Phaser.Physics.html index 884d3607..344a63a6 100644 --- a/docs/Phaser.Physics.html +++ b/docs/Phaser.Physics.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -501,7 +505,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:13 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:39 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Plugin.html b/docs/Phaser.Plugin.html index 2c0cdc4d..db9fdc58 100644 --- a/docs/Phaser.Plugin.html +++ b/docs/Phaser.Plugin.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -845,7 +849,112 @@
    Source:
    + + + + + + + + + + + + + + + +
    +

    hasPostUpdate

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    hasPostUpdate + + +boolean + + + +

    A flag to indicate if this plugin has a postUpdate method.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    @@ -1055,7 +1164,7 @@
    Source:
    @@ -1432,7 +1541,7 @@
    Source:
    @@ -1502,7 +1611,7 @@ It is only called if visible is set to true.

    Source:
    @@ -1572,7 +1681,7 @@ It is only called if active is set to true.

    Source:
    @@ -1642,7 +1751,7 @@ It is only called if visible is set to true.

    Source:
    @@ -1712,7 +1821,7 @@ It is only called if active is set to true.

    Source:
    @@ -1763,7 +1872,7 @@ It is only called if active is set to true.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:14 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:39 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.PluginManager.html b/docs/Phaser.PluginManager.html index 80c95fbb..43b491e6 100644 --- a/docs/Phaser.PluginManager.html +++ b/docs/Phaser.PluginManager.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -944,7 +948,7 @@ The plugin's game and parent reference are set to this game and pluginmanager pa
    Source:
    @@ -1014,7 +1018,78 @@ It only calls plugins who have visible=true.

    Source:
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    postUpdate()

    + + +
    +
    + + +
    +

    PostUpdate is the last thing to be called before the world render. +In particular, it is called after the world postUpdate, which means the camera has been adjusted. +It only calls plugins who have active=true.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    @@ -1084,7 +1159,7 @@ It only calls plugins who have active=true.

    Source:
    @@ -1202,7 +1277,7 @@ It only calls plugins who have active=true.

    Source:
    @@ -1272,7 +1347,7 @@ It only calls plugins who have visible=true.

    Source:
    @@ -1342,7 +1417,7 @@ It only calls plugins who have active=true.

    Source:
    @@ -1393,7 +1468,7 @@ It only calls plugins who have active=true.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:14 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:39 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Point.html b/docs/Phaser.Point.html index a729ca09..dc2d5994 100644 --- a/docs/Phaser.Point.html +++ b/docs/Phaser.Point.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -5370,7 +5374,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:14 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:39 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Pointer.html b/docs/Phaser.Pointer.html index d4ecfd34..14e2b051 100644 --- a/docs/Phaser.Pointer.html +++ b/docs/Phaser.Pointer.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1176,7 +1180,7 @@ Default size of 44px (Apple's recommended "finger tip" size).

    Source:
    @@ -3431,7 +3435,7 @@ Default size of 44px (Apple's recommended "finger tip" size).

    Source:
    @@ -3537,7 +3541,7 @@ Default size of 44px (Apple's recommended "finger tip" size).

    Source:
    @@ -3875,7 +3879,7 @@ Default size of 44px (Apple's recommended "finger tip" size).

    Source:
    @@ -4024,7 +4028,7 @@ Default size of 44px (Apple's recommended "finger tip" size).

    Source:
    @@ -4161,7 +4165,7 @@ Default size of 44px (Apple's recommended "finger tip" size).

    Source:
    @@ -4348,7 +4352,7 @@ Default size of 44px (Apple's recommended "finger tip" size).

    Source:
    @@ -4584,7 +4588,7 @@ Default size of 44px (Apple's recommended "finger tip" size).

    Source:
    @@ -4653,7 +4657,7 @@ Default size of 44px (Apple's recommended "finger tip" size).

    Source:
    @@ -4796,7 +4800,7 @@ Default size of 44px (Apple's recommended "finger tip" size).

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:14 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:39 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Polygon.html b/docs/Phaser.Polygon.html new file mode 100644 index 00000000..ee1bb352 --- /dev/null +++ b/docs/Phaser.Polygon.html @@ -0,0 +1,712 @@ + + + + + + Phaser Class: Polygon + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Polygon

    +
    + +
    +

    + Phaser. + + Polygon +

    + +

    The polygon represents a list of orderded points in space

    + +
    + +
    +
    + + + + +
    +

    new Polygon(points)

    + + +
    +
    + + +
    +

    Creates a new Polygon. You have to provide a list of points. +This can be an array of Points that form the polygon, a flat array of numbers that will be interpreted as [x,y, x,y, ...], +or the arguments passed can be all the points of the polygon e.g. new PIXI.Polygon(new PIXI.Point(), new PIXI.Point(), ...), or the +arguments passed can be flat x,y values e.g. new PIXI.Polygon(x,y, x,y, x,y, ...) where x and y are numbers.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    points + + +Array.<Phaser.Point> +| + +Array.<number> + + + +

    The array of Points.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    type

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    type + + +number + + + +

    The base object type.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Thu Nov 07 2013 06:07:39 GMT-0000 (GMT) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.QuadTree.html b/docs/Phaser.QuadTree.html index e66947c6..9985f692 100644 --- a/docs/Phaser.QuadTree.html +++ b/docs/Phaser.QuadTree.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1262,7 +1266,7 @@ Split the node into 4 subnodes

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:14 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:39 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.RandomDataGenerator.html b/docs/Phaser.RandomDataGenerator.html index 872ff576..df270b8e 100644 --- a/docs/Phaser.RandomDataGenerator.html +++ b/docs/Phaser.RandomDataGenerator.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1955,7 +1959,7 @@ Random number generator from Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:14 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:39 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Rectangle.html b/docs/Phaser.Rectangle.html index eb699bdc..41f3c612 100644 --- a/docs/Phaser.Rectangle.html +++ b/docs/Phaser.Rectangle.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -7340,7 +7344,7 @@ This method checks the x, y, width, and height properties of the Rectangles.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:14 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:40 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.RenderTexture.html b/docs/Phaser.RenderTexture.html index 4f820fd1..c68ae97d 100644 --- a/docs/Phaser.RenderTexture.html +++ b/docs/Phaser.RenderTexture.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1341,7 +1345,7 @@ once they update pixi to fix the typo, we'll fix it here too :)

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:14 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:40 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.RequestAnimationFrame.html b/docs/Phaser.RequestAnimationFrame.html index 3e8dbe20..3acb8c90 100644 --- a/docs/Phaser.RequestAnimationFrame.html +++ b/docs/Phaser.RequestAnimationFrame.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -782,7 +786,7 @@
    Source:
    @@ -870,7 +874,7 @@
    Source:
    @@ -958,7 +962,7 @@
    Source:
    @@ -1027,7 +1031,7 @@
    Source:
    @@ -1145,7 +1149,7 @@
    Source:
    @@ -1214,7 +1218,7 @@
    Source:
    @@ -1265,7 +1269,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:14 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:40 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Signal.html b/docs/Phaser.Signal.html index 78a23c58..e5fba1f7 100644 --- a/docs/Phaser.Signal.html +++ b/docs/Phaser.Signal.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -2250,7 +2254,7 @@ already dispatched before.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:15 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:40 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Sound.html b/docs/Phaser.Sound.html index 32c945b3..1b7f84dd 100644 --- a/docs/Phaser.Sound.html +++ b/docs/Phaser.Sound.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -5683,7 +5687,7 @@ This allows you to bundle multiple sounds together into a single audio file and Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:15 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:40 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.SoundManager.html b/docs/Phaser.SoundManager.html index da4f87c0..23a45eb9 100644 --- a/docs/Phaser.SoundManager.html +++ b/docs/Phaser.SoundManager.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -2382,7 +2386,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:15 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:40 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Sprite.html b/docs/Phaser.Sprite.html index 287fb11a..d09f8f84 100644 --- a/docs/Phaser.Sprite.html +++ b/docs/Phaser.Sprite.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -7423,7 +7427,7 @@ It will dispatch the onRevived event, you can listen to Sprite.events.onRevived Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:15 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:40 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Stage.html b/docs/Phaser.Stage.html index 7f02fc8f..feb13f8c 100644 --- a/docs/Phaser.Stage.html +++ b/docs/Phaser.Stage.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -659,7 +663,7 @@ focus handling, game resizing, scaling and the pause, boot and orientation scree
    Source:
    @@ -764,7 +768,7 @@ focus handling, game resizing, scaling and the pause, boot and orientation scree
    Source:
    @@ -974,7 +978,7 @@ focus handling, game resizing, scaling and the pause, boot and orientation scree
    Source:
    @@ -1280,7 +1284,7 @@ focus handling, game resizing, scaling and the pause, boot and orientation scree
    Source:
    @@ -1382,7 +1386,7 @@ focus handling, game resizing, scaling and the pause, boot and orientation scree
    Source:
    @@ -1447,7 +1451,7 @@ focus handling, game resizing, scaling and the pause, boot and orientation scree
    Source:
    @@ -1565,7 +1569,7 @@ focus handling, game resizing, scaling and the pause, boot and orientation scree
    Source:
    @@ -1616,7 +1620,7 @@ focus handling, game resizing, scaling and the pause, boot and orientation scree Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:15 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:40 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.StageScaleMode.html b/docs/Phaser.StageScaleMode.html index 00663b7d..84070174 100644 --- a/docs/Phaser.StageScaleMode.html +++ b/docs/Phaser.StageScaleMode.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -617,7 +621,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b
    Source:
    @@ -677,7 +681,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b
    Source:
    @@ -737,7 +741,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b
    Source:
    @@ -842,7 +846,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b
    Source:
    @@ -905,7 +909,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b -Description +Phaser.Signal @@ -915,7 +919,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b -

    Description.

    +

    The event that is dispatched when the browser enters landscape orientation.

    @@ -944,7 +948,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b
    Source:
    @@ -1007,7 +1011,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b -Description +Phaser.Signal @@ -1017,7 +1021,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b -

    Description.

    +

    The event that is dispatched when the browser enters horizontal orientation.

    @@ -1046,7 +1050,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b
    Source:
    @@ -1151,7 +1155,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b
    Source:
    @@ -1256,7 +1260,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b
    Source:
    @@ -1358,7 +1362,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b
    Source:
    @@ -1460,7 +1464,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b
    Source:
    @@ -1565,7 +1569,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b
    Source:
    @@ -1667,7 +1671,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b
    Source:
    @@ -1769,7 +1773,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b
    Source:
    @@ -1871,7 +1875,7 @@ It is created by the AnimationManager, consists of Animation.Frame objects and b
    Source:
    @@ -1977,7 +1981,7 @@ If null it will scale to whatever height the browser can handle.

    Source:
    @@ -2082,7 +2086,7 @@ If null it will scale to whatever height the browser can handle.

    Source:
    @@ -2188,7 +2192,7 @@ If null it will scale to whatever width the browser can handle.

    Source:
    @@ -2293,7 +2297,7 @@ If null it will scale to whatever width the browser can handle.

    Source:
    @@ -2398,7 +2402,112 @@ If null it will scale to whatever width the browser can handle.

    Source:
    + + + + + + + +
    + + + +
    + + + +
    +

    orientationSprite

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    orientationSprite + + +PIXI.Sprite + + + +

    The Sprite that is optionally displayed if the browser enters an unsupported orientation.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    @@ -2472,8 +2581,8 @@ If null it will scale to whatever width the browser can handle.

    If you wish to align your game in the middle of the page then you can set this value to true. - <ul><li>It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing.</li> - <li>It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.</li></ul>

    +It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing. +It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.

    @@ -2505,7 +2614,7 @@ If null it will scale to whatever width the browser can handle.

    Source:
    @@ -2579,8 +2688,8 @@ If null it will scale to whatever width the browser can handle.

    If you wish to align your game in the middle of the page then you can set this value to true. - <ul><li>It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing. - <li>It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.</li></ul>

    +It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing. +It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.

    @@ -2612,7 +2721,7 @@ If null it will scale to whatever width the browser can handle.

    Source:
    @@ -2675,7 +2784,7 @@ If null it will scale to whatever width the browser can handle.

    -Description +Phaser.Point @@ -2685,7 +2794,7 @@ If null it will scale to whatever width the browser can handle.

    -

    Description.

    +

    The scale factor based on the game dimensions vs. the scaled dimensions.

    @@ -2714,7 +2823,7 @@ If null it will scale to whatever width the browser can handle.

    Source:
    @@ -2816,7 +2925,7 @@ If null it will scale to whatever width the browser can handle.

    Source:
    @@ -2930,7 +3039,7 @@ If null it will scale to whatever width the browser can handle.

    Source:
    @@ -2999,7 +3108,7 @@ If null it will scale to whatever width the browser can handle.

    Source:
    @@ -3117,7 +3226,216 @@ If null it will scale to whatever width the browser can handle.

    Source:
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    forceOrientation(forceLandscape, forcePortrait, forcePortrait)

    + + +
    +
    + + +
    +

    If you need your game to run in only one orientation you can force that to happen. +The optional orientationImage is displayed when the game is in the incorrect orientation.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    forceLandscape + + +boolean + + + + + + + + + + + +

    true if the game should run in landscape mode only.

    forcePortrait + + +boolean + + + + + + + + + + + +

    true if the game should run in portrait mode only.

    forcePortrait + + +string + + + + + + <optional>
    + + + + + +
    + + '' + +

    The string of an image in the Phaser.Cache to display when this game is in the incorrect orientation.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    @@ -3235,7 +3553,7 @@ If null it will scale to whatever width the browser can handle.

    Source:
    @@ -3304,7 +3622,7 @@ If null it will scale to whatever width the browser can handle.

    Source:
    @@ -3373,7 +3691,7 @@ If null it will scale to whatever width the browser can handle.

    Source:
    @@ -3442,7 +3760,7 @@ If null it will scale to whatever width the browser can handle.

    Source:
    @@ -3518,7 +3836,7 @@ If null it will scale to whatever width the browser can handle.

    -Description +boolean @@ -3560,7 +3878,7 @@ If null it will scale to whatever width the browser can handle.

    Source:
    @@ -3629,7 +3947,7 @@ If null it will scale to whatever width the browser can handle.

    Source:
    @@ -3698,7 +4016,7 @@ If null it will scale to whatever width the browser can handle.

    Source:
    @@ -3817,7 +4135,7 @@ Please note that this needs to be supported by the web browser and isn't the sam
    Source:
    @@ -3886,7 +4204,7 @@ Please note that this needs to be supported by the web browser and isn't the sam
    Source:
    @@ -3937,7 +4255,7 @@ Please note that this needs to be supported by the web browser and isn't the sam Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:15 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:40 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.State.html b/docs/Phaser.State.html index b34f2dfc..89d67faf 100644 --- a/docs/Phaser.State.html +++ b/docs/Phaser.State.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -2530,7 +2534,7 @@ If you need to use the loader, you may need to use them here.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:15 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:41 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.StateManager.html b/docs/Phaser.StateManager.html index c3e08086..44cdfb7a 100644 --- a/docs/Phaser.StateManager.html +++ b/docs/Phaser.StateManager.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -3387,7 +3391,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:15 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:41 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Text.html b/docs/Phaser.Text.html index c4428ec5..576112ce 100644 --- a/docs/Phaser.Text.html +++ b/docs/Phaser.Text.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1775,7 +1779,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:15 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:41 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.TileSprite.html b/docs/Phaser.TileSprite.html index 0c68cabc..e530a178 100644 --- a/docs/Phaser.TileSprite.html +++ b/docs/Phaser.TileSprite.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1108,7 +1112,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:16 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:41 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Time.html b/docs/Phaser.Time.html index 5c0dfb62..21f6c525 100644 --- a/docs/Phaser.Time.html +++ b/docs/Phaser.Time.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -2851,7 +2855,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:16 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:41 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Touch.html b/docs/Phaser.Touch.html index 15834479..ff63c9ce 100644 --- a/docs/Phaser.Touch.html +++ b/docs/Phaser.Touch.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -2502,7 +2506,7 @@ Doesn't appear to be supported by most browsers on a canvas element yet.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:16 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:41 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Tween.html b/docs/Phaser.Tween.html index c3c29b65..f7a6d3a6 100644 --- a/docs/Phaser.Tween.html +++ b/docs/Phaser.Tween.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -3208,7 +3212,7 @@ Used in combination with repeat you can create endless loops.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:16 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:41 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.TweenManager.html b/docs/Phaser.TweenManager.html index 034ee148..060bc355 100644 --- a/docs/Phaser.TweenManager.html +++ b/docs/Phaser.TweenManager.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1705,7 +1709,7 @@ Please see https://github.com/sole/tw Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:16 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:41 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Utils.Debug.html b/docs/Phaser.Utils.Debug.html index 98af9a88..462a039e 100644 --- a/docs/Phaser.Utils.Debug.html +++ b/docs/Phaser.Utils.Debug.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -5917,7 +5921,7 @@ your game set to use Phaser.AUTO then swap it for Phaser.CANVAS to ensure WebGL Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:16 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:41 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.Utils.html b/docs/Phaser.Utils.html index febf8b85..403d0ae1 100644 --- a/docs/Phaser.Utils.html +++ b/docs/Phaser.Utils.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -595,7 +599,7 @@
    Source:
    @@ -736,7 +740,7 @@
    Source:
    @@ -798,7 +802,7 @@

    Javascript string pad http://www.webtoolkit.info/. -pad = the string to pad it out with (defaults to a space)<br> +pad = the string to pad it out with (defaults to a space) dir = 1 (left), 2 (right), 3 (both)

    @@ -1006,7 +1010,7 @@ dir = 1 (left), 2 (right), 3 (both)

    Source:
    @@ -1030,6 +1034,10 @@ dir = 1 (left), 2 (right), 3 (both)

    Returns:
    +
    +

    The padded string

    +
    +
    @@ -1048,6 +1056,147 @@ dir = 1 (left), 2 (right), 3 (both)

    +
    + + + +
    +

    <static> shuffle(array) → {array}

    + + +
    +
    + + +
    +

    A standard Fisher-Yates Array shuffle implementation.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    array + + +array + + + +

    The array to shuffle.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The shuffled array.

    +
    + + + +
    +
    + Type +
    +
    + +array + + +
    +
    + + + + +
    @@ -1076,7 +1225,7 @@ dir = 1 (left), 2 (right), 3 (both)

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:16 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:41 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.World.html b/docs/Phaser.World.html index 698da122..b6b47394 100644 --- a/docs/Phaser.World.html +++ b/docs/Phaser.World.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1447,6 +1451,108 @@ So if you want to make a game in which the world itself will rotate you should a + + + + + + + + +
    +

    visible

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    visible + + +boolean + + + +

    Gets or sets the visible state of the World.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + +
    @@ -2051,7 +2157,7 @@ If you need to adjust the bounds of the world

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:16 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:42 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.html b/docs/Phaser.html index c36dfd2c..82c96a5d 100644 --- a/docs/Phaser.html +++ b/docs/Phaser.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -547,6 +551,9 @@
    Pointer
    +
    Polygon
    +
    +
    QuadTree
    @@ -641,7 +648,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Phaser.js.html b/docs/Phaser.js.html index 5bda255d..e497657a 100644 --- a/docs/Phaser.js.html +++ b/docs/Phaser.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -389,7 +393,7 @@ var Phaser = Phaser || { VERSION: '<%= version %>', - DEV_VERSION: '1.1.2', + DEV_VERSION: '1.1.3', GAMES: [], AUTO: 0, CANVAS: 1, @@ -407,6 +411,7 @@ var Phaser = Phaser || { TILEMAP: 9, TILEMAPLAYER: 10, EMITTER: 11, + POLYGON: 12, NONE: 0, LEFT: 1, @@ -441,7 +446,7 @@ PIXI.InteractionManager = function (dummy) { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Plugin.js.html b/docs/Plugin.js.html index 85de6001..496e9007 100644 --- a/docs/Plugin.js.html +++ b/docs/Plugin.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -429,6 +433,12 @@ Phaser.Plugin = function (game, parent) { * @default */ this.hasUpdate = false; + + /** + * @property {boolean} hasPostUpdate - A flag to indicate if this plugin has a postUpdate method. + * @default + */ + this.hasPostUpdate = false; /** * @property {boolean} hasRender - A flag to indicate if this plugin has a render method. @@ -513,7 +523,7 @@ Phaser.Plugin.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/PluginManager.js.html b/docs/PluginManager.js.html index a31f2053..43e8e8bd 100644 --- a/docs/PluginManager.js.html +++ b/docs/PluginManager.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -456,6 +460,12 @@ Phaser.PluginManager.prototype = { result = true; } + if (typeof plugin['postUpdate'] === 'function') + { + plugin.hasPostUpdate = true; + result = true; + } + if (typeof plugin['render'] === 'function') { plugin.hasRender = true; @@ -555,6 +565,30 @@ Phaser.PluginManager.prototype = { }, + /** + * PostUpdate is the last thing to be called before the world render. + * In particular, it is called after the world postUpdate, which means the camera has been adjusted. + * It only calls plugins who have active=true. + * + * @method Phaser.PluginManager#postUpdate + */ + postUpdate: function () { + + if (this._pluginsLength == 0) + { + return; + } + + for (this._p = 0; this._p < this._pluginsLength; this._p++) + { + if (this.plugins[this._p].active && this.plugins[this._p].hasPostUpdate) + { + this.plugins[this._p].postUpdate(); + } + } + + }, + /** * Render is called right after the Game Renderer completes, but before the State.render. * It only calls plugins who have visible=true. @@ -637,7 +671,7 @@ Phaser.PluginManager.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Point.js.html b/docs/Point.js.html index 652d3da0..133fb268 100644 --- a/docs/Point.js.html +++ b/docs/Point.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -838,7 +842,7 @@ Phaser.Point.rotate = function (a, x, y, angle, asDegrees, distance) { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Pointer.js.html b/docs/Pointer.js.html index ff6b8d47..ccb9d90e 100644 --- a/docs/Pointer.js.html +++ b/docs/Pointer.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -776,7 +780,6 @@ Phaser.Pointer.prototype = { } return this; - } // Work out which object is on the top @@ -1087,7 +1090,7 @@ Object.defineProperty(Phaser.Pointer.prototype, "worldY", { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Polygon.js.html b/docs/Polygon.js.html new file mode 100644 index 00000000..a53a81ef --- /dev/null +++ b/docs/Polygon.js.html @@ -0,0 +1,474 @@ + + + + + + Phaser Source: geom/Polygon.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: geom/Polygon.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Creates a new Polygon. You have to provide a list of points.
    +* This can be an array of Points that form the polygon, a flat array of numbers that will be interpreted as [x,y, x,y, ...], 
    +* or the arguments passed can be all the points of the polygon e.g. `new PIXI.Polygon(new PIXI.Point(), new PIXI.Point(), ...)`, or the
    +* arguments passed can be flat x,y values e.g. `new PIXI.Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are numbers.
    +*
    +* @class Phaser.Polygon
    +* @classdesc The polygon represents a list of orderded points in space
    +* @constructor
    +* @param {Array<Phaser.Point>|Array<number>} points - The array of Points.
    +*/
    +Phaser.Polygon = function (points) {
    +
    +    PIXI.Polygon.call(this, points);
    +
    +    /**
    +	* @property {number} type - The base object type.
    +	*/
    +    this.type = Phaser.POLYGON;
    +
    +};
    +
    +Phaser.Polygon.prototype = Object.create(PIXI.Polygon.prototype);
    +Phaser.Polygon.prototype.constructor = Phaser.Polygon;
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/QuadTree.js.html b/docs/QuadTree.js.html index 4c182a6c..333ade31 100644 --- a/docs/QuadTree.js.html +++ b/docs/QuadTree.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -662,7 +666,7 @@ Phaser.QuadTree.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/RandomDataGenerator.js.html b/docs/RandomDataGenerator.js.html index b6536568..c2017778 100644 --- a/docs/RandomDataGenerator.js.html +++ b/docs/RandomDataGenerator.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -644,7 +648,7 @@ Phaser.RandomDataGenerator.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Rectangle.js.html b/docs/Rectangle.js.html index 851e5e88..38b31819 100644 --- a/docs/Rectangle.js.html +++ b/docs/Rectangle.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1081,7 +1085,7 @@ Phaser.Rectangle.union = function (a, b, out) { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/RenderTexture.js.html b/docs/RenderTexture.js.html index 38a911ce..d5f37cdb 100644 --- a/docs/RenderTexture.js.html +++ b/docs/RenderTexture.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -467,7 +471,7 @@ Phaser.RenderTexture.prototype.constructor = Phaser.RenderTexture; Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/RequestAnimationFrame.js.html b/docs/RequestAnimationFrame.js.html index 0346e0c0..d860bfe1 100644 --- a/docs/RequestAnimationFrame.js.html +++ b/docs/RequestAnimationFrame.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -429,6 +433,13 @@ Phaser.RequestAnimationFrame = function(game) { */ this._onLoop = null; + /** + * The callback ID used when calling cancel + * @property _timeOutID + * @private + */ + this._timeOutID = null; + }; Phaser.RequestAnimationFrame.prototype = { @@ -462,7 +473,7 @@ Phaser.RequestAnimationFrame.prototype = { return _this.updateRAF(time); }; - window.requestAnimationFrame(this._onLoop); + this._timeOutID = window.requestAnimationFrame(this._onLoop); } }, @@ -476,7 +487,7 @@ Phaser.RequestAnimationFrame.prototype = { this.game.update(time); - window.requestAnimationFrame(this._onLoop); + this._timeOutID = window.requestAnimationFrame(this._onLoop); }, @@ -504,7 +515,7 @@ Phaser.RequestAnimationFrame.prototype = { } else { - window.cancelAnimationFrame; + window.cancelAnimationFrame(this._timeOutID); } this.isRunning = false; @@ -550,7 +561,7 @@ Phaser.RequestAnimationFrame.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Signal.js.html b/docs/Signal.js.html index f1c0b342..114ad650 100644 --- a/docs/Signal.js.html +++ b/docs/Signal.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -695,7 +699,7 @@ Phaser.Signal.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/SignalBinding.html b/docs/SignalBinding.html index 8eb6b926..7a218178 100644 --- a/docs/SignalBinding.html +++ b/docs/SignalBinding.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -695,7 +699,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:16 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:42 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/SignalBinding.js.html b/docs/SignalBinding.js.html index d48d7c68..195dd807 100644 --- a/docs/SignalBinding.js.html +++ b/docs/SignalBinding.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -560,7 +564,7 @@ Phaser.SignalBinding.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Sound.js.html b/docs/Sound.js.html index 6d020bb2..40fd3466 100644 --- a/docs/Sound.js.html +++ b/docs/Sound.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1225,7 +1229,7 @@ Object.defineProperty(Phaser.Sound.prototype, "volume", { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/SoundManager.js.html b/docs/SoundManager.js.html index 6feef1bf..6d6298fc 100644 --- a/docs/SoundManager.js.html +++ b/docs/SoundManager.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -847,7 +851,7 @@ Object.defineProperty(Phaser.SoundManager.prototype, "volume", { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Sprite.js.html b/docs/Sprite.js.html index 3b74d680..2c5121a2 100644 --- a/docs/Sprite.js.html +++ b/docs/Sprite.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1470,7 +1474,7 @@ Object.defineProperty(Phaser.Sprite.prototype, "inputEnabled", { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Stage.js.html b/docs/Stage.js.html index b118e5f0..88a5be02 100644 --- a/docs/Stage.js.html +++ b/docs/Stage.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -424,6 +428,7 @@ Phaser.Stage = function (game, width, height) { */ this._stage = new PIXI.Stage(0x000000, false); this._stage.name = '_stage_root'; + this._stage.interactive = false; /** * @property {number} scaleMode - The current scaleMode. @@ -582,7 +587,7 @@ Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/StageScaleMode.js.html b/docs/StageScaleMode.js.html index 78d5b5d2..44e96169 100644 --- a/docs/StageScaleMode.js.html +++ b/docs/StageScaleMode.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -396,45 +400,19 @@ Phaser.StageScaleMode = function (game, width, height) { /** - * @property {number} _startHeight - Stage height when starting the game. - * @default - * @private + * @property {Phaser.Game} game - A reference to the currently running game. */ - this._startHeight = 0; + this.game = game; /** - * @property {boolean} forceLandscape - If the game should be forced to use Landscape mode, this is set to true by Game.Stage - * @default + * @property {number} width - Width of the stage after calculation. */ - this.forceLandscape = false; + this.width = width; /** - * @property {boolean} forcePortrait - If the game should be forced to use Portrait mode, this is set to true by Game.Stage - * @default + * @property {number} height - Height of the stage after calculation. */ - this.forcePortrait = false; - - /** - * @property {boolean} incorrectOrientation - If the game should be forced to use a specific orientation and the device currently isn't in that orientation this is set to true. - * @default - */ - this.incorrectOrientation = false; - - /** - * @property {boolean} pageAlignHorizontally - If you wish to align your game in the middle of the page then you can set this value to true. - <ul><li>It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing.</li> - <li>It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.</li></ul> - * @default - */ - this.pageAlignHorizontally = false; - - /** - * @property {boolean} pageAlignVertically - If you wish to align your game in the middle of the page then you can set this value to true. - <ul><li>It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing. - <li>It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.</li></ul> - * @default - */ - this.pageAlignVertically = false; + this.height = height; /** * @property {number} minWidth - Minimum width the canvas should be scaled to (in pixels). @@ -463,14 +441,45 @@ Phaser.StageScaleMode = function (game, width, height) { this.maxHeight = null; /** - * @property {number} width - Width of the stage after calculation. + * @property {number} _startHeight - Stage height when starting the game. + * @default + * @private */ - this.width = width; + this._startHeight = 0; /** - * @property {number} height - Height of the stage after calculation. + * @property {boolean} forceLandscape - If the game should be forced to use Landscape mode, this is set to true by Game.Stage + * @default */ - this.height = height; + this.forceLandscape = false; + + /** + * @property {boolean} forcePortrait - If the game should be forced to use Portrait mode, this is set to true by Game.Stage + * @default + */ + this.forcePortrait = false; + + /** + * @property {boolean} incorrectOrientation - If the game should be forced to use a specific orientation and the device currently isn't in that orientation this is set to true. + * @default + */ + this.incorrectOrientation = false; + + /** + * @property {boolean} pageAlignHorizontally - If you wish to align your game in the middle of the page then you can set this value to true. + * It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing. + * It doesn't care about any other DOM element that may be on the page, it literally just sets the margin. + * @default + */ + this.pageAlignHorizontally = false; + + /** + * @property {boolean} pageAlignVertically - If you wish to align your game in the middle of the page then you can set this value to true. + * It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing. + * It doesn't care about any other DOM element that may be on the page, it literally just sets the margin. + * @default + */ + this.pageAlignVertically = false; /** * @property {number} _width - Cached stage width for full screen mode. @@ -492,18 +501,20 @@ Phaser.StageScaleMode = function (game, width, height) { */ this.maxIterations = 5; - /** - * @property {Phaser.Game} game - A reference to the currently running game. - */ - this.game = game; /** - * @property {Description} enterLandscape - Description. + * @property {PIXI.Sprite} orientationSprite - The Sprite that is optionally displayed if the browser enters an unsupported orientation. + * @default + */ + this.orientationSprite = null; + + /** + * @property {Phaser.Signal} enterLandscape - The event that is dispatched when the browser enters landscape orientation. */ this.enterLandscape = new Phaser.Signal(); /** - * @property {Description} enterPortrait - Description. + * @property {Phaser.Signal} enterPortrait - The event that is dispatched when the browser enters horizontal orientation. */ this.enterPortrait = new Phaser.Signal(); @@ -524,7 +535,7 @@ Phaser.StageScaleMode = function (game, width, height) { } /** - * @property {Description} scaleFactor - Description. + * @property {Phaser.Point} scaleFactor - The scale factor based on the game dimensions vs. the scaled dimensions. */ this.scaleFactor = new Phaser.Point(1, 1); @@ -677,6 +688,54 @@ Phaser.StageScaleMode.prototype = { }, + /** + * If you need your game to run in only one orientation you can force that to happen. + * 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. + */ + forceOrientation: function (forceLandscape, forcePortrait, orientationImage) { + + this.forceLandscape = forceLandscape; + + if (typeof forcePortrait === 'undefined') + { + this.forcePortrait = false; + } + + if (typeof orientationImage !== 'undefined') + { + if (orientationImage == null || this.game.cache.checkImageKey(orientationImage) == false) + { + orientationImage = '__default'; + } + + this.orientationSprite = new PIXI.Sprite(PIXI.TextureCache[orientationImage]); + this.orientationSprite.anchor.x = 0.5; + this.orientationSprite.anchor.y = 0.5; + this.orientationSprite.position.x = this.game.width / 2; + this.orientationSprite.position.y = this.game.height / 2; + + this.checkOrientationState(); + + if (this.incorrectOrientation) + { + this.orientationSprite.visible = true; + this.game.world.visible = false; + } + else + { + this.orientationSprite.visible = false; + this.game.world.visible = true; + } + + this.game.stage._stage.addChild(this.orientationSprite); + } + + }, + /** * Checks if the browser is in the correct orientation for your game (if forceLandscape or forcePortrait have been set) * @method Phaser.StageScaleMode#checkOrientationState @@ -691,6 +750,13 @@ Phaser.StageScaleMode.prototype = { // Back to normal this.game.paused = false; this.incorrectOrientation = false; + + if (this.orientationSprite) + { + this.orientationSprite.visible = false; + this.game.world.visible = true; + } + this.refresh(); } } @@ -701,6 +767,13 @@ Phaser.StageScaleMode.prototype = { // Show orientation screen this.game.paused = true; this.incorrectOrientation = true; + + if (this.orientationSprite && this.orientationSprite.visible == false) + { + this.orientationSprite.visible = true; + this.game.world.visible = false; + } + this.refresh(); } } @@ -760,6 +833,9 @@ Phaser.StageScaleMode.prototype = { { this.refresh(); } + + this.checkOrientationState(); + }, /** @@ -799,7 +875,7 @@ Phaser.StageScaleMode.prototype = { /** * Set screen size automatically based on the scaleMode. - * @param {Description} force - If force is true it will try to resize the game regardless of the document dimensions. + * @param {boolean} force - If force is true it will try to resize the game regardless of the document dimensions. */ setScreenSize: function (force) { @@ -912,6 +988,8 @@ Phaser.StageScaleMode.prototype = { this.scaleFactor.x = this.game.width / this.width; this.scaleFactor.y = this.game.height / this.height; + this.checkOrientationState(); + }, /** @@ -1032,7 +1110,7 @@ Object.defineProperty(Phaser.StageScaleMode.prototype, "isLandscape", { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/State.js.html b/docs/State.js.html index 8a7645ab..86321a5e 100644 --- a/docs/State.js.html +++ b/docs/State.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -567,7 +571,7 @@ Phaser.State.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/StateManager.js.html b/docs/StateManager.js.html index e0db8756..936996bc 100644 --- a/docs/StateManager.js.html +++ b/docs/StateManager.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -923,7 +927,7 @@ Phaser.StateManager.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Text.js.html b/docs/Text.js.html index 5efa4ea0..b5279587 100644 --- a/docs/Text.js.html +++ b/docs/Text.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -619,7 +623,7 @@ Object.defineProperty(Phaser.Text.prototype, 'font', { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/TileSprite.js.html b/docs/TileSprite.js.html index 8dee10d3..65631de4 100644 --- a/docs/TileSprite.js.html +++ b/docs/TileSprite.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -455,7 +459,7 @@ Phaser.TileSprite.prototype.constructor = Phaser.TileSprite; Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Time.js.html b/docs/Time.js.html index afbce834..8a8d63a6 100644 --- a/docs/Time.js.html +++ b/docs/Time.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -669,7 +673,7 @@ Phaser.Time.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Touch.js.html b/docs/Touch.js.html index b6a4a4af..3e898bc0 100644 --- a/docs/Touch.js.html +++ b/docs/Touch.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -731,7 +735,7 @@ Phaser.Touch.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Tween.js.html b/docs/Tween.js.html index 0066b61c..7df0af1b 100644 --- a/docs/Tween.js.html +++ b/docs/Tween.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -1008,7 +1012,7 @@ Phaser.Tween.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/TweenManager.js.html b/docs/TweenManager.js.html index 722ae4ba..d5ebbb4b 100644 --- a/docs/TweenManager.js.html +++ b/docs/TweenManager.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -599,7 +603,7 @@ Phaser.TweenManager.prototype = { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/Utils.js.html b/docs/Utils.js.html index 70a77684..f70c481d 100644 --- a/docs/Utils.js.html +++ b/docs/Utils.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -389,6 +393,12 @@ */ Phaser.Utils = { + /** + * A standard Fisher-Yates Array shuffle implementation. + * @method Phaser.Utils.shuffle + * @param {array} array - The array to shuffle. + * @return {array} The shuffled array. + */ shuffle: function (array) { for (var i = array.length - 1; i > 0; i--) @@ -405,14 +415,14 @@ Phaser.Utils = { /** * Javascript string pad http://www.webtoolkit.info/. - * pad = the string to pad it out with (defaults to a space)<br> + * pad = the string to pad it out with (defaults to a space) * dir = 1 (left), 2 (right), 3 (both) * @method Phaser.Utils.pad * @param {string} str - The target string. * @param {number} len - Description. * @param {number} pad - the string to pad it out with (defaults to a space). * @param {number} [dir=3] the direction dir = 1 (left), 2 (right), 3 (both). - * @return {string} + * @return {string} The padded string */ pad: function (str, len, pad, dir) { @@ -625,7 +635,7 @@ if (typeof Function.prototype.bind != 'function') { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/World.js.html b/docs/World.js.html index d972d47e..3bbdfea7 100644 --- a/docs/World.js.html +++ b/docs/World.js.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -636,6 +640,22 @@ Object.defineProperty(Phaser.World.prototype, "randomY", { } +}); + +/** +* @name Phaser.World#visible +* @property {boolean} visible - Gets or sets the visible state of the World. +*/ +Object.defineProperty(Phaser.World.prototype, "visible", { + + get: function () { + return this._container.visible; + }, + + set: function (value) { + this._container.visible = value; + } + }); @@ -658,7 +678,7 @@ Object.defineProperty(Phaser.World.prototype, "randomY", { Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/classes.list.html b/docs/classes.list.html index c75a6114..c9a4e61b 100644 --- a/docs/classes.list.html +++ b/docs/classes.list.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -584,6 +588,9 @@
    Pointer
    +
    Polygon
    +
    +
    QuadTree
    @@ -691,7 +698,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/global.html b/docs/global.html index c8af928f..6dcbb6f6 100644 --- a/docs/global.html +++ b/docs/global.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -738,7 +742,7 @@
    Source:
    @@ -1016,7 +1020,7 @@ However it does affect the width property.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/index.html b/docs/index.html index 85841a5c..d1854bfe 100644 --- a/docs/index.html +++ b/docs/index.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -509,7 +513,7 @@ and my love of game development originate.

    Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/docs/namespaces.list.html b/docs/namespaces.list.html index aad693b5..efe346e1 100644 --- a/docs/namespaces.list.html +++ b/docs/namespaces.list.html @@ -242,6 +242,10 @@ Pointer +
  • + Polygon +
  • +
  • QuadTree
  • @@ -584,6 +588,9 @@
    Pointer
    +
    Polygon
    +
    +
    QuadTree
    @@ -691,7 +698,7 @@ Documentation generated by JSDoc 3.3.0-dev - on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the DocStrap template. + on Thu Nov 07 2013 06:07:33 GMT-0000 (GMT) using the DocStrap template. diff --git a/examples/_site/examples.json b/examples/_site/examples.json index 4c9052a5..93340fd0 100644 --- a/examples/_site/examples.json +++ b/examples/_site/examples.json @@ -226,6 +226,10 @@ "file": "create+sprite+in+a+group.js", "title": "create sprite in a group" }, + { + "file": "depth+sort.js", + "title": "depth sort" + }, { "file": "display+order.js", "title": "display order" diff --git a/examples/assets/maps/burd.json b/examples/assets/maps/burd.json new file mode 100644 index 00000000..b807e39d --- /dev/null +++ b/examples/assets/maps/burd.json @@ -0,0 +1,65 @@ +{ "height":19, + "layers":[ + { + "data":[1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 11, 1, 1, 9, 13, 1, 1, 1, 1, 11, 1, 1, 1, 1, 1, 1, 5, 12, 1, 1, 1, 2, 1, 3, 1, 1, 8, 1, 1, 1, 1, 1, 8, 1, 1, 1, 1, 9, 1, 13, 1, 1, 8, 1, 1, 1, 5, 1, 1, 6, 1, 1, 1, 9, 1, 4, 1, 1, 1, 3, 1, 13, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 6, 1, 1, 1, 8, 1, 1, 1, 7, 1, 4, 1, 1, 9, 1, 12, 12, 1, 6, 1, 9, 1, 1, 11, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1, 3, 1, 1, 1, 1, 1, 5, 1, 1, 1, 2, 1, 1, 1, 1, 11, 7, 1, 1, 4, 1, 1, 1, 1, 1, 13, 1, 1, 1, 3, 1, 1, 1, 1, 9, 1, 9, 1, 2, 1, 1, 2, 1, 12, 1, 9, 1, 1, 9, 1, 1, 1, 8, 1, 1, 1, 1, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 3, 1, 1, 3, 1, 1, 1, 3, 1, 7, 1, 1, 2, 1, 3, 1, 13, 2, 10, 1, 3, 1, 1, 1, 9, 1, 4, 1, 1, 1, 11, 1, 1, 1, 1, 1, 7, 1, 1, 3, 1, 1, 1, 1, 1, 1, 6, 1, 8, 1, 1, 2, 1, 12, 1, 1, 1, 11, 12, 8, 1, 1, 1, 1, 11, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 6, 1, 1, 3, 1, 1, 1, 7, 1, 1, 1, 6, 1, 1, 8, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 6, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 10, 1, 1, 9, 1, 2, 1, 1, 1, 1, 7, 1, 1, 1, 5, 1, 3, 1, 1, 11, 1, 1, 1, 7, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 2, 1, 1, 3, 1, 1, 8, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 1, 8, 1, 1, 3, 1, 1, 3, 1, 8, 6, 1, 1, 1, 11, 1, 1, 1, 1, 1, 11, 1, 1, 1, 1, 3, 1, 1, 1, 1, 12, 1, 1, 9, 1, 1, 2, 5, 3, 1, 1, 2, 3, 1, 8, 4, 6, 1, 3, 1, 9, 6, 1, 4, 1, 5, 9, 1, 8, 1], + "height":19, + "name":"Tile Layer 1", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":25, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 29, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 0, 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 0, 0, 33, 0, 0, 31, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, 28, 0, 0, 0, 0, 30, 0, 0, 0, 0, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 31, 0, 0, 0, 31, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, 27, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 0, 0, 0, 0, 33, 0, 0, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":19, + "name":"Tile Layer 2", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":25, + "x":0, + "y":0 + }], + "orientation":"orthogonal", + "properties": + { + + }, + "tileheight":32, + "tilesets":[ + { + "firstgid":1, + "image":"ground_1x1.png", + "imageheight":32, + "imagewidth":800, + "margin":0, + "name":"ground_1x1", + "properties": + { + + }, + "spacing":0, + "tileheight":32, + "tilewidth":32 + }, + { + "firstgid":26, + "image":"walls_1x2.png", + "imageheight":64, + "imagewidth":256, + "margin":0, + "name":"walls_1x2", + "properties": + { + + }, + "spacing":0, + "tileheight":64, + "tilewidth":32 + }], + "tilewidth":32, + "version":1, + "width":25 +} \ No newline at end of file diff --git a/examples/assets/maps/burd.tmx b/examples/assets/maps/burd.tmx new file mode 100644 index 00000000..cd06b7c4 --- /dev/null +++ b/examples/assets/maps/burd.tmx @@ -0,0 +1,19 @@ + + + + + + + + + + + AQAAAAEAAAABAAAAAQAAAAIAAAABAAAAAQAAAAEAAAABAAAAAQAAAAsAAAABAAAAAQAAAAkAAAANAAAAAQAAAAEAAAABAAAAAQAAAAsAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAAFAAAADAAAAAEAAAABAAAAAQAAAAIAAAABAAAAAwAAAAEAAAABAAAACAAAAAEAAAABAAAAAQAAAAEAAAABAAAACAAAAAEAAAABAAAAAQAAAAEAAAAJAAAAAQAAAA0AAAABAAAAAQAAAAgAAAABAAAAAQAAAAEAAAAFAAAAAQAAAAEAAAAGAAAAAQAAAAEAAAABAAAACQAAAAEAAAAEAAAAAQAAAAEAAAABAAAAAwAAAAEAAAANAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAgAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAACgAAAAEAAAABAAAAAQAAAAEAAAABAAAABgAAAAEAAAABAAAAAQAAAAgAAAABAAAAAQAAAAEAAAAHAAAAAQAAAAQAAAABAAAAAQAAAAkAAAABAAAADAAAAAwAAAABAAAABgAAAAEAAAAJAAAAAQAAAAEAAAALAAAACAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAgAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAACQAAAAEAAAABAAAAAQAAAAMAAAABAAAAAQAAAAEAAAABAAAAAQAAAAUAAAABAAAAAQAAAAEAAAACAAAAAQAAAAEAAAABAAAAAQAAAAsAAAAHAAAAAQAAAAEAAAAEAAAAAQAAAAEAAAABAAAAAQAAAAEAAAANAAAAAQAAAAEAAAABAAAAAwAAAAEAAAABAAAAAQAAAAEAAAAJAAAAAQAAAAkAAAABAAAAAgAAAAEAAAABAAAAAgAAAAEAAAAMAAAAAQAAAAkAAAABAAAAAQAAAAkAAAABAAAAAQAAAAEAAAAIAAAAAQAAAAEAAAABAAAAAQAAAAgAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAQAAAABAAAAAQAAAAEAAAADAAAAAQAAAAEAAAADAAAAAQAAAAEAAAABAAAAAwAAAAEAAAAHAAAAAQAAAAEAAAACAAAAAQAAAAMAAAABAAAADQAAAAIAAAAKAAAAAQAAAAMAAAABAAAAAQAAAAEAAAAJAAAAAQAAAAQAAAABAAAAAQAAAAEAAAALAAAAAQAAAAEAAAABAAAAAQAAAAEAAAAHAAAAAQAAAAEAAAADAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAABgAAAAEAAAAIAAAAAQAAAAEAAAACAAAAAQAAAAwAAAABAAAAAQAAAAEAAAALAAAADAAAAAgAAAABAAAAAQAAAAEAAAABAAAACwAAAAEAAAABAAAAAQAAAAMAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAABQAAAAEAAAABAAAAAQAAAAEAAAAGAAAAAQAAAAEAAAADAAAAAQAAAAEAAAABAAAABwAAAAEAAAABAAAAAQAAAAYAAAABAAAAAQAAAAgAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAkAAAABAAAAAQAAAAEAAAABAAAABgAAAAEAAAABAAAAAQAAAAEAAAABAAAACQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAoAAAABAAAAAQAAAAkAAAABAAAAAgAAAAEAAAABAAAAAQAAAAEAAAAHAAAAAQAAAAEAAAABAAAABQAAAAEAAAADAAAAAQAAAAEAAAALAAAAAQAAAAEAAAABAAAABwAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAACgAAAAEAAAABAAAAAQAAAAIAAAABAAAAAQAAAAMAAAABAAAAAQAAAAgAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAwAAAAEAAAABAAAAAQAAAAEAAAANAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAABgAAAAEAAAAIAAAAAQAAAAEAAAADAAAAAQAAAAEAAAADAAAAAQAAAAgAAAAGAAAAAQAAAAEAAAABAAAACwAAAAEAAAABAAAAAQAAAAEAAAABAAAACwAAAAEAAAABAAAAAQAAAAEAAAADAAAAAQAAAAEAAAABAAAAAQAAAAwAAAABAAAAAQAAAAkAAAABAAAAAQAAAAIAAAAFAAAAAwAAAAEAAAABAAAAAgAAAAMAAAABAAAACAAAAAQAAAAGAAAAAQAAAAMAAAABAAAACQAAAAYAAAABAAAABAAAAAEAAAAFAAAACQAAAAEAAAAIAAAAAQAAAA== + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIQAAAAAAAAAAAAAAAAAAAAAAAAAdAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhAAAAAAAAAAAAAAAAAAAAAAAAABoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIQAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACEAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB0AAAAAAAAAAAAAACEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB0AAAAAAAAAAAAAACEAAAAAAAAAAAAAAB8AAAAAAAAAAAAAAAAAAAAhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHgAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAB4AAAAAAAAAAAAAAAAAAAAAAAAAHwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAHwAAAAAAAAAAAAAAAAAAAB8AAAAAAAAAAAAAAAAAAAAhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAACEAAAAAAAAAAAAAAB8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + + diff --git a/examples/assets/maps/ground_1x1.png b/examples/assets/maps/ground_1x1.png new file mode 100644 index 0000000000000000000000000000000000000000..7299cffb6f847c645fcca62d006c5b0828dedbda GIT binary patch literal 2229 zcmYk8dpy%^AIEo-R6@d2%IOKIRTPC$mP43Aw=hC;T5?=Yi) zIW8qDlp-;6xY5kUES8_mP7k`DyXW4vCEwx&Gkk#-U#7o-$*3LA^_!w)P#lk1|pr2z5#I&?~rFf zpdE0SwS`OU*kU0GrFub$yms8IX~v|-UQXwOj*Wp*klm5 zKBJ4Y$`C8#T zg-7ecZI`D4h{;|uG^fc`9TChAc=m-?Ntl$G#09qjbUS)|#B@s;)*IEVUU7{6ZqBd~ zd%cnqx6=Qw*ZT{En#oE2pIt5QPp6Nd&MN?#ZGBO$S1XODCl>Af6wD4?EgvIliusqRnc+ zsNhW0qcTeBusB@(hFR)H3PLDYh)!UTKhT*YY$Bp;OwK<5up&jdcr-9(nU_4xuKYsI z53O!?>_`M)L-c7dA`nsMJ!sV|>ht7rQvj#YI2zS04%5dF69d7`g=xtuL=1`n?hx=I z>70>+8oO!+YR#>;%WS6AjNUGzS6kX~u1NKFk5@5qplx(7}ywH zo2W7-2lVRajz-<;|M)w^TW|*_cvole$Zq9W&Z0l0^7!-dLB9hyK{1!}>29;k>_EsP zxFb+VyTYz#o38vF@TBe8yU4aVyOP?W@!bTE!N*{J`wR5hTI4eoMk>#>z&mpoJg*@R zxmSb8eL3=iQLRH=e5R-S)yaP;fF9+0;r+$uWfePw@ABqV&Fq7DxvOi#xNWwdc!7>L zqYLF>SJcfCERj+Q|^dMR?IW_4OpB$-g`%p_mrU5rjM)@9H*D4e;o-K2b>}()+NJR!L9W+yZMjVQxms3UBN7RrXp5vNY;~e1Ndi3^v&no zT*UPJ0i2`ux@)U6+oW4#1H!lEl&KKWa!MpTKvCuRrZI^xtp|LNQ7gu1nc>GCja(Pq zr*7#GWN~&F{$?ytCNjn}*nNb+3X0mwit^aw*w0kQb(2LfxcXqUsMwSp6LHU=#;E*k z;KfKOrh#lYlYmG+Eqx6CI)Hd!=aOqRTZjL3^*f7#Kj$59=8dm^>jpd|B{}6-SO|Wg z;v%s4%iWWo4BfpbZasGfDBKtO^_Fpa(EhY0D@5+%_qgLJkzZ^dD&1>UDFhe`T2xho40!8pu{H6_8?I z&?&cjq8+!3^+>ap79nU+>&Wr%Cuiiha8jO;H*nvq3FywzAmw6K8#7e=)C)OY{tK+Z z&ibJik(866z)+{|wlLD|@ywU6$>^`Zt;BU!M;M6{kM;@XIm^8bvE>pihrGODyVj<^ zoxn(W`A5F8P_zFc&G?gZ(B$+;7mzNM3jG0%tPxPVb)Q6(HMoU8Oo^-^C^X&stvct7 z?xdNtP6&FJi)B=wp_S&ZqfN7Ywr(Rvp{s`p3%Ps;<8^ouuGmKWT{O=*#RSK?zKJcm zu3KWbe?FdXxsX-V)(bGKnjCG*SHni6l>_uoM_H%tuNdBg`+;Bg-&Y%cS2^BnYV3`P zaZft{p0lr`wMSjHB&@%>)6lrU{jx1A#1dr(K8mlR!6C~K+4d^xJYE^oET-yRMbsz5 zoe!%|!U0~T%)f)O5mu*h5#==*C6Ghy>aCa}hXNIeE$=qmn|PslS8DUIdma}L_)xyI zEW;h+w9mNs^cVTSs{Cqu0tFo+uX`TEb2+UhCFy z_Mzt|I8TvUasaY(SJ^*aFiY)wWr)G5(9RK#Btp8IG-dxNe(mkmA!K@yLzPz0JR;RdRI+~xN zhFxJ<8Hvv?!K(k10Ut%=0lwzVq^fW|HdipmDIJ?%U(JjEB)85 zt345nC)J{S>#H=p&#WR6a5L%V?;-9Umksy#)L-q_3vN@D(kPd=tvPJA<>0{0H$NNG zOUTE%b#g2B-t{&q&EN{M#HKMqBtcpl1 z3pQW0d&9|e(zuB|B=W&1;I<#cWp!g8LxzQs#J{qcFZ^f&BMPJ3^<$xIe z?gzqAkqVms4Z7IJ>dQ>!-d&Iur3jfnCF77llAyS^lj(ct?-83xU>6*%t1W$!{tLfc BaJ2vc literal 0 HcmV?d00001 diff --git a/examples/assets/maps/walls_1x2.png b/examples/assets/maps/walls_1x2.png new file mode 100644 index 0000000000000000000000000000000000000000..5d268af7555373fb053bd84af0d609cd7d307e7d GIT binary patch literal 2488 zcmZuzdpy+X8h?LtXU4cxNSKkMtaTY@O{6exgUBtnP=+MAgw}19F(Q+Y+FcYC8ARh+ zji}VP?bJ!TWZc?H$_lyEHjOaMj?UTL=A84-@BO{+=Xsy!`&{1d^JKfbI>^bY$pQf6 zoE+^u0e~dGfPz6uz90A1+>k0cbjNeA(j%$)0$?(Q`KdDLMc!G5}Z!UIHa zI7E`Awo5ERCjMaU_yj}&dCGuATc1k<3KSNSE4ity3J?m9C_5yFCp;+Tq<6n{?nq4v z{;-uA(gR`2`jr0^>J7)P$!H;HYyb=Kg-I#Iu#lASBE?Ete zMPl^7N*fCSP9Z{OExvzY!MuP`2+=rlXyrBgiaF16Q(|Hr*}Ubw`gP&c8(z3tLaK?f z#@XqZqszkY)zoR`MuqbB7yaLZ{`>U(8XnVM?Q5k*IcGeHw?BeaC_JLa4!UyQwk{t3 z_E*->yB5%705O1CH1uZ*gL5JGI};A3Dno{qr-%JwWjL=psn>fJ6yBlxHF8w;c)jX~ zp!+>`txa*#aFj!{W}(iH>L1bHnHqtm^Z?c+%nbTSzVs}=e&Uht?temZ{s^m`CE#$={xUyxsQ}t9jzYs_j3dtWd7Ap;^Y;HC>gXQj``G4FfGlGRrroO|&mK-%Q%GQ?+ z^)^~+R*s=c77m%YUEF>%0#d@Fp3;v(O$LD>P)ZI)GoJ+V+yo!d70m#AS<+okE*CKq z_(lBU46nvI3yrAx?l&_g#-)MF!Kv|wN+B9?HNbz-y3%$J^uM|emR~s;Q-GZ?}PN8 zi$qI`J?JkVrb5p8w?=nmV=tN6U=)f=GYjH9YfIg`rUuZwgW}OmPiRYQ#NmV5re1^$ ztqP;8IeL6jd6A$(_%T?=3|H2$fwy6flt7~Bt_FkWR&TBalQ#(})RY2Fw{#FRUaDc! zFP$9fp}bf^+X(lV3vJebS>@(yHcSFvde^`!+x(dGi=<_#h}gyI5Nj*67Wf`5+rxDf z4Ji$lW`=;hxQNiqm~tb8wwo;Eq&hRAgI_l)9qtSDT+~D*CTnD}Q92TOH?CJkT(LBpT79EM%zq@N z`pwQKoXp+JojAOs&^jX7E)QSnt@UHoZF8S*>qqa(RGE%u30A%?k7~TuiHyBu;V^w6 zzNJTJfF3A3r{@~I?1bd2tz$p}f%TE&@c*LCSaJcPKQSmSSJ`$kGotG8EiDtOlO0X4 z5%r+%FovU!Dd0}7ifgcYSu0Bxp(cx$xhka88JL}gmY6q8@i#9&aduz9jE|MfF_;Xu zLtgnsCa6VGhTQZS9Lnh=+c0OE0TDGh49`uQLmf2WZd0G@IB3NQD9ezbd)dp0N&YR^ zz}ipr+B4>A_epPcsTO561StgkUbe73Zi?p(YX>Vo5gQlUoscaeBYi#B4IhF*+ZHAV z)5`-7X5r=Vi*J#We3<%_a2R|>R^+*+=#b9SKv)Rth zd%87k3`m|I6(iEm$znL*E2Q8^I)2-793&7Wj6d8|`>IRQ*}tIwbI)Lm0+Yt?ndt$l zdWJ3*zQ(wFN`Besf6o5`>c;w38h*~JIzt88qQ0&gImhU1?lY+0VYU$6B$QuY*1U2P zZzZK}EDGwqGhQXB9~oQ;k6DK%HfJ%Xv{i6}@2>h{WBK$YASEwXd;U_1e(Q!Z|Y=@O-DLMAl>3VU}RFEY+`2pp7G%`|077nq>3>PWG;L^)|E< Fe*kko`7i(g literal 0 HcmV?d00001 diff --git a/examples/assets/pics/forgotten_worlds.png b/examples/assets/pics/forgotten_worlds.png new file mode 100644 index 0000000000000000000000000000000000000000..7e713b30545f5f70f697379306b9454be6fcced6 GIT binary patch literal 17077 zcmZX*d03KZ`#x^dWHXallap&&O=XLk;zqenSz5Ve=0a|XiYwrT25yyQnOkMK;ZmBo zp}2w@QfZPYlA@v_SVN+Mh=xc?>eu)8=FEG1et&Ts96UVNecji6p69jP$ye>HcK@dQ zo0OE)?#q`hT$7Ue2__}AZQn1_o8Me`0n*?6P>Q_h8tDj!L`Hju`$?Vig@gSLU50x5 z`(5+%_C<#E_?bvaop-r>;oS9G<8uYP+>%SQ69&_PyFBG;y=`768E#YYy&LlS9)6o# zx3rC`0%s2Rr}yPcx>YA0&m@1VYY4jR{wU@8%l7Zz)+FNH9ed2OEZ2Fw({glywKIyL5((alboL~Qtx+c znkXd|`nwKnl7AaK@j}XZZtN=ph}fQsKHaMi0tC^7JWDF7s8$~)9_AaV^lJVj_3G}H zI|zcPzW}gMsi@_$bPqS6du!*Nn||J?v6lm4t(KkQGuoE@mD**ScKvmF({)l(w^MG1 zNnktwU`uP*k$CwMdwqkD?Z;AKFbbJF#s zZcG2LbH?en1%+B2V=)pt;`^~MVWTWp%z7qvGc|?^@$2o1r`zoEa_Uy1I34!n51=Gl z?P%Q~ao6t&p@Z9AAHF%UX@k`1p8)?^>^`=%@kb6648v-6s=Fq@1^l@>L-&zztXeTk zvJ@3nu)o*2`ZT%3rB{e|lu;}AL+X%1s>b`qcVq<$aw7;MOS`OS#)NEeZ2DbIN2!PZ$7!|OXYbtR&5jU3`+XD@e%aX6#e)e!oNAL*;DJGMhbT2@N)pO{=`%AV-n{o5gq?Lz&9cNYRJ zj^$u%)m%Q@S11?t0hGbhA{O?&owy3sh&*VLBnVov<+GGp$(zVW%rg)aNT*{SgG=+|Ne7^ z{x=YI;Dts zud8|?dO-NT?b*SjOT29RSAMzc-{(>dT%}#kyGrLdb1I*7+B{qya*T#G)xD0yJ@SvekktDe_8etx83~ z63;e*r?CBhY_4MO508FMJS_FC<6*@U&4GlxG6$hex}r{j(-^Br5Uj?-DMZ?TJn_{` zwLx9ITFv?Uw|$-BSkLp_^F=~dIh&LiXnmRh(W!|pw?8f!!}FWpRk1~^teESt;vBt@k5bcZ+k8GPb6=P^(h{E2<9w93WBh%Kn>$a zedsFON($&nDEtOtxrbB4Yi{pIa!`HKP0ZmECW36%N;-E!UH z`HciynddbT&bDvB!YKl={boc=qn5dp}7(6)edNwYI|3LKJ_czAJudq11m^crYe0Qn6KmG5s{8jV1&(Fn9S~R;sN$tCr)rdE<~P&b8u0WON?319@cDR+H*mS^9;6&NeV9=}wywW4n32}T<1d(?N_KJh<4^__>B`vT2)Ed}q2%L2`Z92_xF zeV7p*I+JrqG%?sw6v+gSCYA_$MDsHQag86bEd~{TamZG77Hd*-$om~ zF#jd)4!bTDonxpfDNP&JRdLiJ4Q9|AE-EBJAA0xlO@oHLg`USb(76h(q5)3NLSMs~ z>9u%^V;+WWzwNu~X54#fxDJv+7c)Tl4ihnRf&q z7%OiTX|jnrlmBAww%4$u7%0{UqF8&~$4}{mKoH~ezI_VRODA3DVw&S&`#8(}h!m zVcR~f{sVElrJ@>U1_FniBC<<<&T-mvI&VjiDcm$2f=D7CYc}8PaT@dNl&239Jo}1N|};st2$nx4H!IL|5b3=BBW)+Tulb7=5{6M=xv5<~i;&K_DajY`eB65f~oL|AWW8tyZUU4;#hS*yfR!uiK_v-wLr<;$2p{0YCYx(mR`wwbEpkX(B zmCb@pV|GtCj5X!FA^nTY|J4}4Ze4h5$z8>xTCI(@>y7rinp$clP9fB57r@kZQRzsA zu-;1{;b7m`A1RQW_jP2hmi~N-XPI;A=g_(4`qHfB*Jz29ol%%2elCBw~Wk{tDz9Tow94}@*amhp!^(N z01P!D&I3Xx!gn*;aw>a#Yg7o)diN_Nzz$hC@yI`C;lEnJU5eU{1O&>*7$3LE@H56w zW-GJt1X*{lxchjGj>%5ahi9hOiR}^()C=b-ftRLB7O?#<|LjLdy^MzEYi`*FH=ILQ zl%7)~MAu1X-}6Dr&sKlb41d-NdCXmhsp{wP;H&lF15hQ8XxgDk*j$Jl!W|ypJX|D zD~Nx{pwM%T$Oapm6-9iUrLE(KTExy>`-6>-^+tLZVrAt%w3p^p2F9l4oT@5xdl^Za znDY^flBMm?gn?$I<6o;%(J@4CmfaSse~Xflf+rfnTMBk!vz;h7inw5Z)rd#{U^!zM ze|BFfEwYS3B@s$wyX$9B32(O3tah3-C-hAF6yK>rjLf5zfWgK(u<0!ti#3+MO?!g6 zDsL;N_eYA|&Rk2|TXfBjgYV;&FFzxAHeIi+KW}gB#d@U>0K>Art-nA9=ix-#7H?I66Ds@P-(!0;M{Q?@c_(~h{ocpJ-8 z6n8_B4}I0kKrM&hvz1kK?BD)Z*s`)=M9VmKM;c>kRWxNuVYKBoxeQBAHMyUSZ%N{N z@Nz+t7JbJzIfOUuM0B9Ad%G}7<_Ao^CU{G|hu}aBsfqKmGs6*XL)+vsGXq#xo}99L z)t@u}>u(b2btd>*yKq!56fxYsvOshAEc1{3Z=@dER0gKx863WG*^8T!TX)UaXY#G2 z%z`45xa^U7!>K4!lxu7^XdzA`FMs#y#jfV(TikA@_>)wv|FWMg8uS3V+9@mw&>UCPGYrWFun+n?>{3Kx-s3>{qnEKm zZ9|k@WKH#SYp-UX`|j{?RS{Q#2x$dkao^8?4* z?RK`7mHQVLW3-SPce&)=aKvOnZD2~$jE5G4U%sg5MZaFfZj7>|dQRuGF2(}t^BjGq z8Uq{p(AgK`lfhG{h9AXK z^!5z6HZ6X>3vH)JFD zUEhD_;rDF4!cF_N%3g!u7$4Ab{~SV-Q7k*s&w4T52&xNnpk*mn;pw%=yS+h2U))d1 z70p(Ex(Kio?KO5z5biA_Ualx?sh63kipfqA7@uPsihN6J++_b{_Sd@xF#MT09SsJB zWmcw!_8INc8A@~b+)+fbvq3BM8v1757>o3OSBosRR?A3nq4Ip~nGwV8H>c$+w{f45FHr@WpP% zH`IQ;X_1;}XKazT_3o2G`N=5Z8c8_^Po(FfLax3L{c%@*fX^Fkvc&(6`-cuW}*K8|!AB5G}Ky@p*A!ruprhOIDxc zr$ZK7bnuo1jeeS3gN&;Fr`0pqtN(7J-|Zuik>ma;^98?aQ(i~m99|lt%(`sL#rmY*77v;4xE>}2RF1a*J zZ{Y1;xBFMuTn&eqbm55~8bQ2afVwj_HJ<47pu$DkRt3MIc_KK*I{M7Q!_yr+i#CyA zthhDUKP*ziRRcX1|I<3;fBpsB9WoSX97}wYQ(L#MO-`l6huOYrUGl^c02}|9EBchr zk4I>tKkm?AmHlanjdVVR;VY&a!sl0va`+?7tn$p|=q=1v1m0F{uk=LwjW@mwG8a&l zkYM>dKbAbsx_Uby_Va4dWLKl=JI^EP?9B1N*K+q`EGmi_w5Nak`gr%h0fVQjN-3bO#6|RO9y?1w*|n3WPh=m>1=q+ z*};=k-OR=cz^o>fMO${%) zN4L}^5VQr?HfNeBc$l*O%T3>~NGjzq~ImcSh^d~1l zakKTT$>2I}S3mJXdjX=u71XeH?n89ndI!Z;OcHCr#wYjwo2!563!TKCN7C^Pxp<(S zc9YjyKeh`K|Nc?YhT>RVUUafw3M`|$ci%9>JP+TsxSZ-dABY87;H+fa&CAQU?`BJ_ zqD}U8jub`yohy=ij?Bc;qEnEGaX;emt(Bt-XjWd>r5h$Sk}h-7?QByCdvS^x;SuLUIy8 z`-C5v85Nw%G5q`Mb*Zn%xy_*_>nWfXtTpl2~{Id-@X?2kUOnF}}v^sj_v zA>BL`>K2VpbyIXj`#DlTsm$v_)mG~L#AW`oR_O1<*_P6nT zP?{hD6XIyIXYymOVj@{kt@Jw^YvvJe z3(p^;ll(bvcxhzdic$tHA>Q0SD%z*rNcyC{1rDs|-g(F!mLO;AcFM&7TJb*qmMO&1 z)^c`{5!3oXQa$GgxR{kYm;i?}Og$oe{x+e>s{-}fMwAcwUFpPV0nxW6-b|BpQ#}ar z9a?Fwgte7}`rm7}fcu0z8xkkXhEI5uHMr-E0Z}XJ+G7D8bZGxyC6iyY!-q0geaT5=J1cW2H&ndgi2kIBnAdtf(6z(HE1D4s7eQf-n;SNPMi` z#%C+Y-!>y(DYuj(GwpVbA9{$)gfC>Sob;7eJ@V3D**WC4>5+!iZUE7@tg)x7 zc?Wgl<-A8_j~3LVUl$hR!zi}AdDdscxW8<$oASsbWn}G&fk%tQp(}n7 z{%|XuksE3}R>uJE6e)h42B*?JPL14sU_=zM*cai6b@y1n>} zM{I<)yO)j1eNOPhYL!#tR<_ChH?K9^Tx*Ri0ML}VpOuKb_R;O|d>xq3P7bC@NCc@5f?Qv z+ITa|pBwjQEb*-B@5`S417bw?%8+$|DIhN$xod7=PUxPHE}l>{{E>XzBLHBYL_>{k zOobY{chLr<&j<&UT*11MqAl^!-N0PJ=&Dx3arO~1d-4Ibur2{9bJvfR4tBTqGVC=% zF`4c@?Zk;??cn=WnP(IVeu|8{q%lG{Gg)b~{VDorAd#wPmf~5;{XPf@JMiF5Ur)nR zzL$!rr2?mXfK6!kVPyP7C&^(!W>w#_5bf3Mavz2~y)K7f2sc-cpdXKe?PK6&f8a{{ zM6)diV~t+qZPuue-;rCO96pJ5f^Jgr&R6M=a-ct*Ruc7F-= z&1Cvx9b3*sEPL0P)Jl>f4DAd5{W2{Ds&MT3BSse z3>~v67%M9*9OTg}d60LJr~PMm`zek*0tmram#0BQ-HoU)Oq5#rfn$HGW=t?91BUVy z%PK=(p20O-c!u+$EKgthyZJqgWj?JM+0_WbIEf#6#=tBF4>vE2edk8 zhW89j7y0G4t)~a>+EP^J*EHT}lg^d-4dnZcFRkZ$C~!270P~)_v>T)(GkZNV99>`p zKxiQ$Jv#7+OJ(MJ_REaUv(p9hD=G%C9`Y`>p@oWkLw!Ov{qmuOw<2>o8FE&@KirzI zmfL;pT~{tW^LLFC>eeHITzpsz115^+C;|}$~&muw<)o^r;OtP&o)|*jdzjU1D+c(FHuiNQ1U8HzgwX@iNqJ=z} zz{DROV$6EsCNs-l){>D-_j|ksWF4_E7e!#DI~%q-Nu8#(BSES4XJ#7@J*?2hRn^II zR#!;nw2`6+#l}FD4K;n}_yN0KA{FLOi>vK#U5^n*teBBtNps%>@kJ+hY*D=+f3LyS zk`<*PtLb}(TtUF+&-;&24?go-IYr}8-`}mXccAUpk0@EJ%=@g|^50GLMv!{7F8F6c&FwLiJo)9& znooyoS*p(+l|T~l?~?vRoTwEx*g(^>%s@$WH0w>;%;4_bk|cK$a~1h4V7#j~upvu= z+!t4rK8s$qGP2f>)%Yjs%fzQd^=8$Ymy!!^XyOo%#%|K`1%I!;iMBkvd*=~p3i@2K zx3Trn-2KCerf1*j%=T|*_qFx*7H5$i2LnJfH_u!8LFyCL>4~{(@?WqagXM?bYnem* zh&-Vk8ea}_Tau}vH|&zU-OkO$2kcDhhyaha-!VPG(~l*oT+hn^^43q9zCbuv7(y3? zADZD6Iiv5U(bwL$9F!vouPYK=~IrP=4Gcx$;NYOY5982`Q9ObO}$b?zlzkuay zKWDDgKqw4B#e6{*hvGAN?_^ALA=5PPMZ}KFQO9m=G_xQQ!mac02bJ22o*6!)kJ2(7 z&rRw~9)d%A(mN@GCH=Grwn&oRfExh?@}IfcU3Ulp$ui7TocuxFl75 z`3k-C1(^;(1O5oY*s&q)N}3h-)~u!vul>}B4=~K6Upae_trAzD_>;$mE&0}ZJHZ3y{`LAvbsdODM5X2k5(k?|B)EJyp@XfAD5r}BJmmFLF!O?Es3^n zmEpDELne-2hAGwsAmWEZvpFdN50U~#0xAJ|{`E6+`r6|FFV&UrZC#;SHdk>OygK5%yyy!yHw1`#0awXERtQf8Bwfk% z>cw94|J#{Ks6mtB-MxZOJpL{RrX$^_FmB4yzU~>7a0TPzvTb)bO!39BwTA z69WYuKaPtyzkiSAXd$vkraDgrQ|Dh^M}lTY#TFOH73&c?{kh%97J|iH1gk~eqW&3! z!D%iV+1a>!T)8dqUE@XnE>uhtG9~XJqYZJO?zb!@>3~Owar(ByK_9PK_&V-p24X1f zH;2{@7zibDVRaB0%l^IJOt!EHra4n`HZs4m(stDZMNlMso8CpS-q`9w`lo<7(~lYBHw!7v!F2d)mWN-DX{z zW+aqR*Um$hMbwK%f4uU{8W;sc$3(OCv;h{YcK`r>*?A(aR)UP_YV5kbP^2HooQ@^&EWvV9p-j5}YU0bre#eIR!mz?wEbZMQkN1l0 z?aj}KVO}5Ru1uXK=e@C(xkkUw67)BsjUr<{{>fWEn|~0hX{djrwu*qdbec;u;D$A| z=1nlXVfPc(qP69)PGFSK}C?6mNyf9$9PO=_Bas-_%#v zd_G=zC#{x-ZaQm{u<^acObr_1-c48O#5P1Z`rplb!kzl-xCflIXroHLcns+$MHxNo z_mnH7Eb6FF^hdqpEFy55*juUf^{MFW98`N^ce0f zSMre#5}75|r1`$Pq}?#Uc?Q(Utjr=G#A0D4}U?3B7vmQ1Mxt zw6c~B<&r=>u-8&sr6HdXNqV~`M1ZBLHI0MSpWG;d>PsgD(umw}Bta2BIEIB}m5c#i ze(VFi`vnEaW)gQ%4v>YH$m!C?h-Z(UG}ugl7cFGGhqGoM?=yfp2*H#uwlwEk5+Yw# zz3KF%AO~M!bnq6B8Iym_%c~U_9P}VD0Qd1?R)w&aGL*Txe#9?@^GI-K`=}uxm$m*X zYUY=s2k9?=O&VEY^Sbi*W~2iVE|m(wUy)Ab;^40+Ndcp3-eQ2d3o!qb8KgwO)WlmY z1A!1N;)9tE-YI2C6kKu;sJN9xW=zSn#_@LJ>pvAky7B<;fiVE65f9;K!O>fI6WJ5q z(eV{xhLT|RwjP$?1JCQ_1Y*ACu_HILVz9>1UDwfMmx8hu;;m}7Qo)KP6-U&A5Q(ed zji-qI8Nmk`tU-W&$w~-T7QkTea`EMhsONziext=i4{?n)&>0pT72KqThI%F>|Ayxm za(WEm$O5_LD5Ljgdy=8OTXQ|@0)|8o;p_y>dln#{wm;M5!@Wy=1(7xjHa&D7V&*-C zi05XBb16CU$)eSE@%@bXDEZ*Lb#}F z{%=d)7dXTauM=0HF==joLsh#3(K^nWA%pvz2CIw?eMz@kv@bX>Imka2EV2}F(HG4( zx~UZ?VxilTk)aPim3K5RPMNq~4EoxIuik2&9&}-Rs<^w9ZzasXgSZv&EH4ctNuhm*})3ukUw z`Y%=B8b+pv_3}}&+J!jG|QHv1bftUceeKS!6i=xIpnEJk2>ED~(8a7Z^ zTj-!sV5+Q!^Cs4t;KEy$+J|^F(@4Y|`0M&H2q?;@UVmJFPI(sXC?Tu_yeKI4#vyY&?V$#!R$drt> z<36m*0Qe)?(0@>D0YGto;QBa|*IcUn+{>#IxbRl`1G?w34SN3A4Y~xJbcNn?*&}1U zE$8y@j?h{KKbR)k&n*4XosUFovJ%0;zK0?^&nwnwdoY zm1IAs`)X2k5GgxnkA z3n5pm4!TfvzSJaqFnpF9VQRh_7jobVyv)D*sB{gG0ACY0+q)C^~%@)vLdplnktJNi^{9 zG+!mFxIA0wm(U;InZ zy{v8CLi#w$sRrP!xwU5T<^lyVX}sP0zoWWuKNGK%DYn8QEUQU%y}+Od!PPM z3CEnV$tZ1+rHGz-o3-i<&r7~$o3(3`;ed-|hjlF`LqEuQVl9L_X0s@qrkZbDp@Q_R ztDn1;9>&b_>Q-ZeY{>fd%>M3Y!j=RFO`AWU%k4R5d8jJ}dusw&V~5`w7tI$@g)>E7 zY2%Z2Ocy+TQ*iLYG~(7yFB7hs;s@(O>OGw2ZUmLxFY)1DGf%(>MfszexCa#>g*k+8 z+A6E7EysvBK)-oKm5~;ZpBRDMSTP2F+S;Mo{$G1ThDDw)A^6^#T`(i#j}^^W(rhqI zz5vjJG7~Vrd8`}gHH&il9Wa#heUrq{OTK4z)p=3Pu)`}yFx9~ib{pUc;q_!oi-9P# z9{2k$-82kYLjHFqMJCoLp zz1*GZ163fqe0FGH~4iYxj$@VTD-@f~hR7 zjSq~K7AD6zMfo@;tetN0niZEid+d>zSv4Vr^9e@I^KIR&Tk-z@XrV?rTZOXm?0Y0> z7p5T>TR(f5mORg`8l#1lJNn15i%>63vo%1c3x7{u{#nbkt2RNuKsr z@z!&J94{1!p~P%T8D?%pJ8822DIQPeb^TtTRMveBsW({yj_#A)ZcOp#E-uBNtnH78 zQ$1}%zPd9sb?i#&ed`VwkqyhiUsJasV~8K-awXb;`1^fs?eXkj-a`=avb6_!d72p~ zYMfw7#w-5(tmQ&)lAM;7{m}sHQv_-lULaRq@Np?F*f*yXBaGpxL^YO`S*qY?QZ)+i z<4ql@7yHoZhadL47wdiSvmaWymw;mUL|8T^U` zhU~KFxU{0^`UFeOv9A$}9mpFu=qaL>z5Gi<`n+i?1|Cg+B0`#UY!v@vyji;Exgh4z z7|vS$faWO;YpR1k^6NUzsv1?)4UW?k`i4dJwgalFuk_-3fJf1CvC-X*t!nxE6C+JB zUWFBOLu1ruL^CPBDdAY&+yysj?YyZb@pt1>yN1Wjpo&@2HL9K@=)R|scEi?M6jhntSxk@fGXz%g}@9X2-4x5{P7;mU2 zOvZg`r$HaaWM--}iV`)=e&osgI@~R4{+e32BK;^MU;DNAVK)UCi zzk2_29hOB>@~& z`FVZ}`5#K{-7FNedO8UIUSobR64}^B##tSf`)rj7(Z%w$_V?C`zdu}$6U09opX?d! zr?{2&SFs+(Mfyyd(29+p%J9V8HYD5MPvHUCPbbX(-D{-u>ET8`X#;!E&_ki-YkF1m z_kw9+|F5MDR-N>i0_W`0$nVv>>Y9ccLDki>Zz{9ynDQc+DPbcVD4h5{Aa&Jccq5)= zE(9lNUGc+#fABsz91^m0f*7FOJxxT%bqb4o=b?jzyw-s;HfQ_<(t zyDgqxJ!8o~1&Gz1&r*tu8<~xbMWp5$hO$##c355Z6T8uI_KT^CSr_F$)#lqNm5DY0FqdgH1Mk)OlMnAgot**L38GlYX(+ z2yH+V%`(Q3v^yEGZ)&{(OPBApqptaN_Tr1?(L9drW`--);t83I(?nHg;u)M3@9!8( z`kHJS+6mW?5MS%_-=&>D(+&O5J?;XW9lnHrm_xWugV^3CvtANb_p$dDfKYncfJ-8a zz9$MtoYe6Hz00WV#bLe1sb76lsiEi7O!pgiz9^p(g{v7o7q}(I?Sd2(%BOI<-h!Tg zDnTqZ-f>%h`!S?rL$i;k(-d)cF}gRjz;Beb-#lf>lt(~{5%f_OtV*0blruk}8MX#z z^v5Jy?^Mv{gb1eZL??`S2!_7J<`h0ebZ=#iOi<~#4$&K1_qOYfC&k;j}nDhsJtS^)0NaMB| zhj1%tXn%=bFk*wdI(=ryDKpX&;}uP4m%Q>Hzbk6Xn(h_rLI*Tqg7xqyQQ|cTlfXYW z4XtHcFRXpFzGoORA_8lbT{mrMFb8HiZC86q|KZlRWc|*yHn2*2h;^@~E%9UJFlqDL zl$NZtn{P_DY)-$-HK+3xg{3T;6HWcBD(;{y19?!*96|+p+0$t8SpfLDOdNA_Xw$n^ zW}>;^>C`d0e?y@`^serXWMl)_*}BLqZUHqQsk?Q6k33~hN)EJUrVp(Kw}?N#)7}MF zW^mN}*LFP`;JKz|XTRI*0pnRDeW;%qnaDf2W~OQkFRp`+h<~o~$yC$s;gbJ*k?G!^ zq?>V;#iVmUN>rb9_}uWt`pq!{vg?xsoeLhku92VpeMfE$BjVo2KmYT_z~uREdzsO< z?G>%oDUYT-$#*W|M>*a~V{Qa~t?(LpPsN71X#a!WE8v}F^mnNO2LP->%d(U6Iwj0e zgB3jPscPL?PLgjoch`bwiOmXP*Z*jpL^6ge3Mo!b$C=s@ytA13?EP#$v41_jwxh%E z`2A5t@{ijjHDSg^)=N%$MMXtaB?-O6lj5ABtj1FjSMmP(RV;~E%OEc=zgkZsJzNYP zp~}&JIjatPL@c+^>u@QsU*V}P!yh8#93ve$P;Y%J+T)Sng+F)eMp2)U*~Q@PBB|?1 zN;zBvh3CR4Ha_tM;^9fbV7;a+_s$6=BKfjR9) zabI5%eIpvMhcl)o+W>WS-Q>anRs9l0Je#Ls*pU6(aPP-l@@k*wh$ET1kOP5Du&5tp z%=7P0&%tNuWUsR5nP7xTNzdJpAQ3OprXZE1sFeGLq|sW#_;dLpIOti}<7ra-Zooa} z>I%KeHUApDLJ>H7=LCJMm=LxQYrbj{=hA?G7-(G$S7;|?)PdsA2(O}kbVP##kGpaf zf`EadWLh80mu*gD7W z@|phZ>GN1wBm2gKeq6*We^g>1w&SbKy?ru1@|DV78iueBm9hP!ldSgH!n=ustqJSy zq>iLD$@dkLH(l+Bl9wsN+e3!<)qEDu?730=$V%+UVy|q6rtkPQUbJmdgar;#VRSQR zyl(!}WezkIS=9kCZOH}|AQ1+Rf~vJpbGPs3KUN>44oTu0jm|}y%Y!(UYtCu%Z#Ft& zmwW%Jkk#K}UGLl?(thnMEku&3Qe$Jz!-i!X4{!VUIzB7s07J3Wk>{Os4DdJz^Czf+ zPaQjh1nj8b943@`E+JT{{Z(>9_KzaWj@YImRPHAVTi@LsiW(t^b>T*Mtyor-*H4&ou4_Q@rj9Kl%U z&Bo{fcp}FK_quY&`?0i%wNrja=dfjQ=g(7pnLsXIWl&ub6C+8##nD<%NsP!>0Cakc z@M|O2{^EV_H#qJTcQvHZe<*)jAEodab+g?-VKZ&emVId7H0=zrmcCtuc*C=bS2^Bp z4=Ml`69A+pxF?bNPF(WF#?V&Nco@Y>xlaRxZpF+?|0K+>SM{uzF`5R_^GqZ4fX(ch zyKI0k72Ex-MNI76tTu_{@2kt$DJ*pxl-hW$49SrX#8#2SnWPaNfd~ek^MT z;IX5<`NM)z{V;Z9D(yt2%=1+<4sm(WSH5 z%PC2w{oGd9d}`;~_a_h-;`okWNxMMH{iTf!=YB zo27tRdTxP2M{<~3d_sI)d4+<9Czes=54$#b9Ju^ZH+-MQ6Jy6ov;itg@NUqucoZeW zuGdk3?_*>!51&&Nkm)q{Syt(6Zviz2F=x{l4gPvY2EK`45zU2aRbtwQhj9mrynKn2 zgY=zhNZXDiv7(#qh40i9bxZV1>tTi1j)O zM@4O^NNf^yfNvCHl(bH#3*&)#Kp)bSWNREC_L88fBHLHTSiQ;f@%5W9W6QXysz|@w z#7r>L*Z5V3eZ{D{sqnEo#)PvxNlzD}cU&FwJaBABG&vImQ!aCUX8rfE* zhlt_B{ggUICX4U747#;1XXc>Eta?YJE0fq>Y$Dq_iEEY`G==_Eg-` z!e|{}aE6e2{^yxuLzuUP`edIUWPXTlL}@=MbTBfsfT%eLF;o(fqZ#x!R%A&yE<&_u z_T7npTcPP?uI#5c58t2S!;Eep%?oRv5_QHuLaOY(>+|Von`6CcnQ%1cjybpbv!R$; zd9w&r_jl&Zh4|NV-r UzU}5cQK`!p?Jm@uzj^on0Ye1$rvLx| literal 0 HcmV?d00001 diff --git a/examples/groups/depth sort.js b/examples/groups/depth sort.js new file mode 100644 index 00000000..fc7f319f --- /dev/null +++ b/examples/groups/depth sort.js @@ -0,0 +1,79 @@ +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update }); + +function preload() { + + game.load.image('phaser', 'assets/sprites/phaser-dude.png'); + game.load.tilemap('desert', 'assets/maps/burd.json', null, Phaser.Tilemap.TILED_JSON); + game.load.tileset('tiles', 'assets/maps/ground_1x1.png', 32, 32); + game.load.spritesheet('trees', 'assets/maps/walls_1x2.png', 32, 64); + +} + +var map; +var tileset; +var layer; + +var sprite; +var group; +var oldY = 0; +var cursors; + +function create() { + + // Create our tilemap to walk around + map = game.add.tilemap('desert'); + tileset = game.add.tileset('tiles'); + layer = game.add.tilemapLayer(0, 0, 800, 600, tileset, map, 0); + + // This group will hold the main player + all the tree sprites to depth sort against + group = game.add.group(); + + // The player + sprite = group.create(300, 200, 'phaser'); + + // Some trees + for (var i = 0; i < 50; i++) + { + var x = game.math.snapTo(game.world.randomX, 32); + var y = game.math.snapTo(game.world.randomY, 32); + group.create(x, y, 'trees', game.rnd.integerInRange(0, 8)); + } + + // Move it + cursors = game.input.keyboard.createCursorKeys(); + +} + +function update() { + + sprite.body.velocity.x = 0; + sprite.body.velocity.y = 0; + + if (cursors.left.isDown) + { + sprite.body.velocity.x = -200; + } + else if (cursors.right.isDown) + { + sprite.body.velocity.x = 200; + } + + if (cursors.up.isDown) + { + sprite.body.velocity.y = -200; + } + else if (cursors.down.isDown) + { + sprite.body.velocity.y = 200; + } + + if (sprite.y !== oldY) + { + // Group.sort() is an expensive operation + // You really want to minimise how often it is called as much as possible. + // So this little check helps at least, but if you can do it even less than this. + group.sort(); + oldY = sprite.y; + } + +} diff --git a/examples/wip/sort.js b/examples/wip/sort.js index 72870b0e..fc7f319f 100644 --- a/examples/wip/sort.js +++ b/examples/wip/sort.js @@ -1,48 +1,46 @@ -var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update }); function preload() { game.load.image('phaser', 'assets/sprites/phaser-dude.png'); - game.load.spritesheet('veggies', 'assets/sprites/fruitnveg32wh37.png', 32, 32); + game.load.tilemap('desert', 'assets/maps/burd.json', null, Phaser.Tilemap.TILED_JSON); + game.load.tileset('tiles', 'assets/maps/ground_1x1.png', 32, 32); + game.load.spritesheet('trees', 'assets/maps/walls_1x2.png', 32, 64); } +var map; +var tileset; +var layer; + var sprite; var group; var oldY = 0; +var cursors; function create() { - game.stage.backgroundColor = '#2d2d2d'; - - // sprite = game.add.sprite(32, 200, 'phaser'); - // sprite.name = 'phaser-dude'; + // Create our tilemap to walk around + map = game.add.tilemap('desert'); + tileset = game.add.tileset('tiles'); + layer = game.add.tilemapLayer(0, 0, 800, 600, tileset, map, 0); + // This group will hold the main player + all the tree sprites to depth sort against group = game.add.group(); + // The player sprite = group.create(300, 200, 'phaser'); - sprite.name = 'phaser-dude'; - var names = [ 'cherries', 'orange', 'swede', 'apple', 'pepper', 'dick', 'carrot', 'cucum', 'strawb', 'broc', 'pineapl', 'melon', 'white', 'spud', 'banana', 'lettuce']; - - for (var i = 0; i < names.length - 1; i++) + // Some trees + for (var i = 0; i < 50; i++) { - // var c = group.create(game.world.randomX, game.world.randomY, 'veggies', game.rnd.integerInRange(0, 36)); - var c = group.create(game.world.randomX, game.world.randomY, 'veggies', i); - c.name = names[i]; + var x = game.math.snapTo(game.world.randomX, 32); + var y = game.math.snapTo(game.world.randomY, 32); + group.create(x, y, 'trees', game.rnd.integerInRange(0, 8)); } - game.input.onUp.add(sortGroup, this); - game.input.keyboard.addKeyCapture([ Phaser.Keyboard.LEFT, Phaser.Keyboard.RIGHT, Phaser.Keyboard.UP, Phaser.Keyboard.DOWN ]); - -} - -function sortGroup () { - - console.log('%c ', 'background: #efefef'); - // group.dump(true); - group.sort(); - // group.dump(true); + // Move it + cursors = game.input.keyboard.createCursorKeys(); } @@ -51,36 +49,31 @@ function update() { sprite.body.velocity.x = 0; sprite.body.velocity.y = 0; - if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) + if (cursors.left.isDown) { sprite.body.velocity.x = -200; } - else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) + else if (cursors.right.isDown) { sprite.body.velocity.x = 200; } - if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) + if (cursors.up.isDown) { sprite.body.velocity.y = -200; } - else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) + else if (cursors.down.isDown) { sprite.body.velocity.y = 200; } if (sprite.y !== oldY) { - // console.log('sorted'); - // group.sort(); - // oldY = sprite.y; + // Group.sort() is an expensive operation + // You really want to minimise how often it is called as much as possible. + // So this little check helps at least, but if you can do it even less than this. + group.sort(); + oldY = sprite.y; } } - -function render() { - - game.debug.renderText(sprite.y, 32, 32); - // game.debug.renderInputInfo(32, 32); - -} \ No newline at end of file diff --git a/src/Phaser.js b/src/Phaser.js index 333d5f10..3eb9cd72 100644 --- a/src/Phaser.js +++ b/src/Phaser.js @@ -28,6 +28,7 @@ var Phaser = Phaser || { TILEMAP: 9, TILEMAPLAYER: 10, EMITTER: 11, + POLYGON: 12, NONE: 0, LEFT: 1, diff --git a/src/core/Group.js b/src/core/Group.js index 5d540f15..c83f4baf 100644 --- a/src/core/Group.js +++ b/src/core/Group.js @@ -985,23 +985,17 @@ Phaser.Group.prototype = { /** * Call this function to sort the group according to a particular value and order. - * For example, to sort game objects for Zelda-style overlaps you might call - * myGroup.sort("y",Group.ASCENDING) at the bottom of your - * State.update() override. To sort all existing objects after - * a big explosion or bomb attack, you might call myGroup.sort("exists",Group.DESCENDING). + * For example to depth sort Sprites for Zelda-style game you might call `group.sort('y', Phaser.Group.SORT_ASCENDING)` at the bottom of your `State.update()`. * - * @param {string} index The string name of the member variable you want to sort on. Default value is "z". - * @param {number} order A Group constant that defines the sort order. Possible values are Group.ASCENDING and Group.DESCENDING. Default value is Group.ASCENDING. + * @method Phaser.Group#sort + * @param {string} [index='y'] - The `string` name of the property you want to sort on. + * @param {number} [order=Phaser.Group.SORT_ASCENDING] - The `Group` constant that defines the sort order. Possible values are Phaser.Group.SORT_ASCENDING and Phaser.Group.SORT_DESCENDING. */ sort: function (index, order) { if (typeof index === 'undefined') { index = 'y'; } if (typeof order === 'undefined') { order = Phaser.Group.SORT_ASCENDING; } - console.log('-vvv--------------------------------------------------------------------------------'); - - this.dump(true); - var swapped; var temp; @@ -1036,10 +1030,6 @@ Phaser.Group.prototype = { } } while (swapped); - this.dump(true); - - console.log('-^^^--------------------------------------------------------------------------------'); - }, /** diff --git a/src/geom/Polygon.js b/src/geom/Polygon.js index a3c689b1..671c44e5 100644 --- a/src/geom/Polygon.js +++ b/src/geom/Polygon.js @@ -1,20 +1,26 @@ /** -* Creates a new Polygon. You have to provide a list of points +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Creates a new Polygon. You have to provide a list of points. +* This can be an array of Points that form the polygon, a flat array of numbers that will be interpreted as [x,y, x,y, ...], +* or the arguments passed can be all the points of the polygon e.g. `new PIXI.Polygon(new PIXI.Point(), new PIXI.Point(), ...)`, or the +* arguments passed can be flat x,y values e.g. `new PIXI.Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are numbers. +* * @class Phaser.Polygon * @classdesc The polygon represents a list of orderded points in space * @constructor -* @param points* {Array|Array|Point...|Number...} This can be an array of Points that form the polygon, -* a flat array of numbers that will be interpreted as [x,y, x,y, ...], or the arugments passed can be -* all the points of the polygon e.g. `new PIXI.Polygon(new PIXI.Point(), new PIXI.Point(), ...)`, or the -* arguments passed can be flat x,y values e.g. `new PIXI.Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are -* Numbers. -**/ +* @param {Array|Array} points - The array of Points. +*/ Phaser.Polygon = function (points) { PIXI.Polygon.call(this, points); /** - * @property {Description} type - Description. + * @property {number} type - The base object type. */ this.type = Phaser.POLYGON;