diff --git a/build/phaser.js b/build/phaser.js index 00f0335ae..bdd20d9f3 100644 --- a/build/phaser.js +++ b/build/phaser.js @@ -18,7 +18,7 @@ * * Phaser - http://www.phaser.io * -* v1.1.3 - Built at: Mon Nov 18 2013 20:26:29 +* v1.1.3 - Built at: Mon Nov 25 2013 13:10:47 * * By Richard Davey http://www.photonstorm.com @photonstorm * @@ -78,6 +78,8 @@ var Phaser = Phaser || { EMITTER: 11, POLYGON: 12, BITMAPDATA: 13, + CANVAS_FILTER: 14, + WEBGL_FILTER: 15, NONE: 0, LEFT: 1, @@ -92,6 +94,8 @@ PIXI.InteractionManager = function (dummy) { // however the Stage object expects a reference to it, so here is a dummy entry. }; +/* jshint supernew: true */ + /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. @@ -103,67 +107,69 @@ PIXI.InteractionManager = function (dummy) { * @static */ 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) { + + /** + * 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--) - { - var j = Math.floor(Math.random() * (i + 1)); - var temp = array[i]; - array[i] = array[j]; - array[j] = temp; - } + for (var i = array.length - 1; i > 0; i--) + { + var j = Math.floor(Math.random() * (i + 1)); + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } - return array; - - }, + return array; + + }, - /** - * Javascript string pad http://www.webtoolkit.info/. - * 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} The padded string - */ - pad: function (str, len, pad, dir) { + /** + * Javascript string pad http://www.webtoolkit.info/. + * 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} The padded string + */ + pad: function (str, len, pad, dir) { - if (typeof(len) == "undefined") { var len = 0; } - if (typeof(pad) == "undefined") { var pad = ' '; } - if (typeof(dir) == "undefined") { var dir = 3; } + if (typeof(len) == "undefined") { var len = 0; } + if (typeof(pad) == "undefined") { var pad = ' '; } + if (typeof(dir) == "undefined") { var dir = 3; } - if (len + 1 >= str.length) - { - switch (dir) - { - case 1: - str = Array(len + 1 - str.length).join(pad) + str; - break; + var padlen = 0; - case 3: - var right = Math.ceil((padlen = len - str.length) / 2); - var left = padlen - right; - str = Array(left+1).join(pad) + str + Array(right+1).join(pad); - break; + if (len + 1 >= str.length) + { + switch (dir) + { + case 1: + str = Array(len + 1 - str.length).join(pad) + str; + break; - default: - str = str + Array(len + 1 - str.length).join(pad); - break; - } - } + case 3: + var right = Math.ceil((padlen = len - str.length) / 2); + var left = padlen - right; + str = Array(left+1).join(pad) + str + Array(right+1).join(pad); + break; - return str; + default: + str = str + Array(len + 1 - str.length).join(pad); + break; + } + } - }, + return str; + + }, /** * This is a slightly modified version of jQuery.isPlainObject. A plain object is an object whose internal class property is [object Object]. @@ -171,41 +177,41 @@ Phaser.Utils = { * @param {object} obj - The object to inspect. * @return {boolean} - true if the object is plain, otherwise false. */ - isPlainObject: function (obj) { + isPlainObject: function (obj) { - // Not plain objects: - // - Any object or value whose internal [[Class]] property is not "[object Object]" - // - DOM nodes - // - window - if (typeof(obj) !== "object" || obj.nodeType || obj === obj.window) - { - return false; - } + // Not plain objects: + // - Any object or value whose internal [[Class]] property is not "[object Object]" + // - DOM nodes + // - window + if (typeof(obj) !== "object" || obj.nodeType || obj === obj.window) + { + return false; + } - // Support: Firefox <20 - // The try/catch suppresses exceptions thrown when attempting to access - // the "constructor" property of certain host objects, ie. |window.location| - // https://bugzilla.mozilla.org/show_bug.cgi?id=814622 - try { - if (obj.constructor && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) - { - return false; - } - } catch (e) { - return false; - } + // Support: Firefox <20 + // The try/catch suppresses exceptions thrown when attempting to access + // the "constructor" property of certain host objects, ie. |window.location| + // https://bugzilla.mozilla.org/show_bug.cgi?id=814622 + try { + if (obj.constructor && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) + { + return false; + } + } catch (e) { + return false; + } - // If the function hasn't returned already, we're confident that - // |obj| is a plain object, created by {} or constructed with new Object - return true; - }, + // If the function hasn't returned already, we're confident that + // |obj| is a plain object, created by {} or constructed with new Object + return true; + }, - // deep, target, objects to copy to the target object - // This is a slightly modified version of {@link http://api.jquery.com/jQuery.extend/|jQuery.extend} - // deep (boolean) - // target (object to add to) - // objects ... (objects to recurse and copy from) + // deep, target, objects to copy to the target object + // This is a slightly modified version of {@link http://api.jquery.com/jQuery.extend/|jQuery.extend} + // deep (boolean) + // target (object to add to) + // objects ... (objects to recurse and copy from) /** * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ @@ -214,117 +220,162 @@ Phaser.Utils = { * @param {object} target - The target object to copy to. * @return {object} The extended object. */ - extend: function () { + extend: function () { - var options, name, src, copy, copyIsArray, clone, - target = arguments[0] || {}, - i = 1, - length = arguments.length, - deep = false; + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; - // Handle a deep copy situation - if (typeof target === "boolean") - { - deep = target; - target = arguments[1] || {}; - // skip the boolean and the target - i = 2; - } + // Handle a deep copy situation + if (typeof target === "boolean") + { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } - // extend Phaser if only one argument is passed - if (length === i) - { - target = this; - --i; - } + // extend Phaser if only one argument is passed + if (length === i) + { + target = this; + --i; + } - for ( ; i < length; i++ ) - { - // Only deal with non-null/undefined values - if ((options = arguments[i]) != null) - { - // Extend the base object - for (name in options) - { - src = target[name]; - copy = options[name]; + for ( ; i < length; i++ ) + { + // Only deal with non-null/undefined values + if ((options = arguments[i]) != null) + { + // Extend the base object + for (name in options) + { + src = target[name]; + copy = options[name]; - // Prevent never-ending loop - if (target === copy) - { - continue; - } + // Prevent never-ending loop + if (target === copy) + { + continue; + } - // Recurse if we're merging plain objects or arrays - if (deep && copy && (Phaser.Utils.isPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) - { - if (copyIsArray) - { - copyIsArray = false; - clone = src && Array.isArray(src) ? src : []; - } - else - { - clone = src && Phaser.Utils.isPlainObject(src) ? src : {}; - } + // Recurse if we're merging plain objects or arrays + if (deep && copy && (Phaser.Utils.isPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) + { + if (copyIsArray) + { + copyIsArray = false; + clone = src && Array.isArray(src) ? src : []; + } + else + { + clone = src && Phaser.Utils.isPlainObject(src) ? src : {}; + } - // Never move original objects, clone them - target[name] = Phaser.Utils.extend(deep, clone, copy); + // Never move original objects, clone them + target[name] = Phaser.Utils.extend(deep, clone, copy); - // Don't bring in undefined values - } - else if (copy !== undefined) - { - target[name] = copy; - } - } - } - } + // Don't bring in undefined values + } + else if (copy !== undefined) + { + target[name] = copy; + } + } + } + } - // Return the modified object - return target; - } + // Return the modified object + return target; + } }; -// Global functions that PIXI needs +// Global functions that PIXI needs - /** - * Converts a hex color number to an [R, G, B] array - * - * @param {number} hex - * @return {array} - */ +(function() { + var consoleDisabled = false; + if (consoleDisabled) { + window.console = undefined; + } + if (window.console === undefined) { + window.console = { + debug: function() { + return true; + }, + info: function() { + return false; + }, + warn: function() { + return false; + }, + log: function() { + return false; + } + } + } + debug = (function(args) { + window.console.debug(args); + }); + info = (function(args) { + window.console.info(args); + }); + warn = (function(args) { + window.console.warn(args); + }); + log = (function(args) { + window.console.log(args); + }); +})(); + +/** +* Converts a hex color number to an [R, G, B] array +* +* @param {number} hex +* @return {array} +*/ function HEXtoRGB(hex) { - return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255]; + return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255]; } - /** - * A polyfill for Function.prototype.bind - */ +/** +* A polyfill for Function.prototype.bind +*/ if (typeof Function.prototype.bind != 'function') { - Function.prototype.bind = (function () { - var slice = Array.prototype.slice; - return function (thisArg) { - var target = this, boundArgs = slice.call(arguments, 1); - - if (typeof target != 'function') throw new TypeError(); - - function bound() { - var args = boundArgs.concat(slice.call(arguments)); - target.apply(this instanceof bound ? this : thisArg, args); - } - - bound.prototype = (function F(proto) { - proto && (F.prototype = proto); - if (!(this instanceof F)) return new F; - })(target.prototype); - - return bound; - }; - })(); -} + Function.prototype.bind = (function () { + + var slice = Array.prototype.slice; + + return function (thisArg) { + + var target = this, boundArgs = slice.call(arguments, 1); + + if (typeof target != 'function') + { + throw new TypeError(); + } + + function bound() { + var args = boundArgs.concat(slice.call(arguments)); + target.apply(this instanceof bound ? this : thisArg, args); + } + + bound.prototype = (function F(proto) { + proto && (F.prototype = proto); + + if (!(this instanceof F)) + { + return new F; + } + })(target.prototype); + + return bound; + }; + })(); +} @@ -1199,10 +1250,6 @@ Object.defineProperty(PIXI.DisplayObject.prototype, 'filters', { */ PIXI.DisplayObject.prototype.addFilter = function(data) { - //if(this.filter)return; - //this.filter = true; -// data[0].target = this; - // insert a filter block.. // TODO Onject pool thease bad boys.. @@ -1305,6 +1352,7 @@ PIXI.DisplayObject.prototype.removeFilter = function(data) { //if(!this.filter)return; //this.filter = false; + console.log("YUOIO") // modify the list.. var startBlock = data.start; @@ -1569,7 +1617,7 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) updateLast = updateLast.parent; } } - else if(index == 0) + else if(index === 0) { previousObject = this; } @@ -1785,9 +1833,9 @@ PIXI.Sprite = function(texture) * Setting than anchor to 0.5,0.5 means the textures origin is centered * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right * - * @property anchor - * @type Point - */ + * @property anchor + * @type Point + */ this.anchor = new PIXI.Point(); /** @@ -2520,9 +2568,9 @@ PIXI.TilingSprite.prototype.onTextureUpdate = function(event) * @class AbstractFilter * @constructor * @param fragmentSrc - * @param unifroms + * @param uniforms */ -PIXI.AbstractFilter = function(fragmentSrc, unifroms) +PIXI.AbstractFilter = function(fragmentSrc, uniforms) { /** * An array of passes - some filters contain a few steps this array simply stores the steps in a liniear fashion. @@ -2541,7 +2589,7 @@ PIXI.AbstractFilter = function(fragmentSrc, unifroms) @property uniforms @private */ - this.uniforms = unifroms || {}; + this.uniforms = uniforms || {}; this.fragmentSrc = fragmentSrc || []; } @@ -2632,7 +2680,7 @@ PIXI.BlurXFilter = function() // set the uniforms this.uniforms = { - blur: {type: 'f', value: 1/512}, + blur: {type: '1f', value: 1/512}, }; this.fragmentSrc = [ @@ -2689,7 +2737,7 @@ PIXI.BlurYFilter = function() // set the uniforms this.uniforms = { - blur: {type: 'f', value: 1/512}, + blur: {type: '1f', value: 1/512}, }; this.fragmentSrc = [ @@ -2803,7 +2851,7 @@ PIXI.CrossHatchFilter = function() // set the uniforms this.uniforms = { - blur: {type: 'f', value: 1/512}, + blur: {type: '1f', value: 1/512}, }; this.fragmentSrc = [ @@ -2820,25 +2868,25 @@ PIXI.CrossHatchFilter = function() " 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) {", + " 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) {", + " 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) {", + " 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) {", + " 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);", " }", " }", @@ -2884,10 +2932,10 @@ PIXI.DisplacementFilter = function(texture) //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]} + scale: {type: '2f', value:{x:30, y:30}}, + offset: {type: '2f', value:{x:0, y:0}}, + mapDimensions: {type: '2f', value:{x:1, y:5112}}, + dimensions: {type: '4fv', value:[0,0,0,0]} }; @@ -3013,9 +3061,9 @@ PIXI.DotScreenFilter = function() // set the uniforms this.uniforms = { - scale: {type: 'f', value:1}, - angle: {type: 'f', value:5}, - dimensions: {type: 'f4', value:[0,0,0,0]} + scale: {type: '1f', value:1}, + angle: {type: '1f', value:5}, + dimensions: {type: '4fv', value:[0,0,0,0]} }; this.fragmentSrc = [ @@ -3095,58 +3143,6 @@ PIXI.FilterBlock = function() * @author Mat Groves http://matgroves.com/ @Doormat23 */ - -/** - * - * This turns your displayObjects to black and white. - * @class GreyFilter - * @contructor - */ -PIXI.GreyFilter = function() -{ - 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. @@ -3161,7 +3157,7 @@ PIXI.InvertFilter = function() // set the uniforms this.uniforms = { - invert: {type: 'f', value: 1}, + invert: {type: '1f', value: 1}, }; this.fragmentSrc = [ @@ -3213,9 +3209,9 @@ PIXI.PixelateFilter = function() // 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}}, + invert: {type: '1f', value: 0}, + dimensions: {type: '4fv', value:new Float32Array([10000, 100, 10, 10])}, + pixelSize: {type: '2f', value:{x:10, y:10}}, }; this.fragmentSrc = [ @@ -3271,10 +3267,10 @@ PIXI.RGBSplitFilter = function() // 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]} + red: {type: '2f', value: {x:20, y:20}}, + green: {type: '2f', value: {x:-20, y:20}}, + blue: {type: '2f', value: {x:20, y:-20}}, + dimensions: {type: '4fv', value:[0,0,0,0]} }; this.fragmentSrc = [ @@ -3328,7 +3324,7 @@ PIXI.SepiaFilter = function() // set the uniforms this.uniforms = { - sepia: {type: 'f', value: 1}, + sepia: {type: '1f', value: 1}, }; this.fragmentSrc = [ @@ -3378,7 +3374,7 @@ PIXI.SmartBlurFilter = function() // set the uniforms this.uniforms = { - blur: {type: 'f', value: 1/512}, + blur: {type: '1f', value: 1/512}, }; this.fragmentSrc = [ @@ -3447,9 +3443,9 @@ PIXI.TwistFilter = function() // 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}}, + radius: {type: '1f', value:0.5}, + angle: {type: '1f', value:5}, + offset: {type: '2f', value:{x:0.5, y:0.5}}, }; this.fragmentSrc = [ @@ -3553,45 +3549,45 @@ PIXI.Graphics = function() this.renderable = true; /** - * The alpha of the fill of this graphics object - * - * @property fillAlpha - * @type Number - */ + * The alpha of the fill of this graphics object + * + * @property fillAlpha + * @type Number + */ this.fillAlpha = 1; /** - * The width of any lines drawn - * - * @property lineWidth - * @type Number - */ + * The width of any lines drawn + * + * @property lineWidth + * @type Number + */ this.lineWidth = 0; /** - * The color of any lines drawn - * - * @property lineColor - * @type String - */ + * The color of any lines drawn + * + * @property lineColor + * @type String + */ this.lineColor = "black"; /** - * Graphics data - * - * @property graphicsData - * @type Array - * @private - */ + * Graphics data + * + * @property graphicsData + * @type Array + * @private + */ this.graphicsData = []; /** - * Current path - * - * @property currentPath - * @type Object - * @private - */ + * Current path + * + * @property currentPath + * @type Object + * @private + */ this.currentPath = {points:[]}; } @@ -3609,7 +3605,7 @@ PIXI.Graphics.prototype.constructor = PIXI.Graphics; */ PIXI.Graphics.prototype.lineStyle = function(lineWidth, color, alpha) { - if(this.currentPath.points.length == 0)this.graphicsData.pop(); + if(this.currentPath.points.length === 0)this.graphicsData.pop(); this.lineWidth = lineWidth || 0; this.lineColor = color || 0; @@ -3630,7 +3626,7 @@ PIXI.Graphics.prototype.lineStyle = function(lineWidth, color, alpha) */ PIXI.Graphics.prototype.moveTo = function(x, y) { - if(this.currentPath.points.length == 0)this.graphicsData.pop(); + if(this.currentPath.points.length === 0)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:PIXI.Graphics.POLY}; @@ -3691,7 +3687,7 @@ PIXI.Graphics.prototype.endFill = function() */ PIXI.Graphics.prototype.drawRect = function( x, y, width, height ) { - if(this.currentPath.points.length == 0)this.graphicsData.pop(); + 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, @@ -3711,7 +3707,7 @@ PIXI.Graphics.prototype.drawRect = function( x, y, width, height ) */ PIXI.Graphics.prototype.drawCircle = function( x, y, radius) { - if(this.currentPath.points.length == 0)this.graphicsData.pop(); + 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, @@ -3732,7 +3728,7 @@ PIXI.Graphics.prototype.drawCircle = function( x, y, radius) */ PIXI.Graphics.prototype.drawElipse = function( x, y, width, height) { - if(this.currentPath.points.length == 0)this.graphicsData.pop(); + 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, @@ -4462,122 +4458,371 @@ PIXI.CanvasRenderer.prototype.renderStrip = function(strip) /** * @author Mat Groves http://matgroves.com/ @Doormat23 + * @author Richard Davey http://www.photonstorm.com @photonstorm */ - +/** +* @class PIXI.PixiShader +* @constructor +*/ 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;", - "}" - ]; - + /** + * @property {any} program - The WebGL program. + */ + this.program; + + /** + * @property {array} fragmentSrc - The fragment shader. + */ + this.fragmentSrc = [ + "precision lowp float;", + "varying vec2 vTextureCoord;", + "varying float vColor;", + "uniform sampler2D uSampler;", + "void main(void) {", + "gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;", + "}" + ]; + + /** + * @property {number} textureCount - A local texture counter for multi-texture shaders. + */ + this.textureCount = 0; + } +/** +* @method PIXI.PixiShader#init +*/ PIXI.PixiShader.prototype.init = function() { - var program = PIXI.compileProgram(this.vertexSrc || PIXI.PixiShader.defaultVertexSrc, this.fragmentSrc) - - var gl = PIXI.gl; - + 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 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(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"); - + 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] = + // get the uniform locations.. this.uniforms[key].uniformLocation = gl.getUniformLocation(program, key); - - } - this.program = program; + this.program = program; } +/** +* Updates the shader uniform values. +* Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ +* http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf +* +* @method PIXI.PixiShader#syncUniforms +*/ PIXI.PixiShader.prototype.syncUniforms = function() { - var gl = PIXI.gl; - - for (var key in this.uniforms) + this.textureCount = 1; + + 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") + var type = this.uniforms[key].type; + var transpose = false; + + if (this.uniforms[key].transpose) { - // console.log(this.uniforms[key].value) + transpose = this.uniforms[key].transpose; + } + + if (type == "1f") + { + // void uniform1f(WebGLUniformLocation? location, GLfloat x); + gl.uniform1f(this.uniforms[key].uniformLocation, this.uniforms[key].value); + } + else if (type == "1fv") + { + // void uniform1fv(WebGLUniformLocation? location, Float32Array v); + // void uniform1fv(WebGLUniformLocation? location, sequence v); + gl.uniform1fv(this.uniforms[key].uniformLocation, this.uniforms[key].value); + } + else if (type == "1i") + { + // void uniform1i(WebGLUniformLocation? location, GLint x); + gl.uniform1i(this.uniforms[key].uniformLocation, this.uniforms[key].value); + } + else if (type == "1iv") + { + // void uniform1iv(WebGLUniformLocation? location, Int32Array v); + // void uniform1iv(WebGLUniformLocation? location, sequence v); + gl.uniform1i(this.uniforms[key].uniformLocation, this.uniforms[key].value); + } + else if (type == "2f") + { + // void uniform2f(WebGLUniformLocation? location, GLfloat x, GLfloat y); + gl.uniform2f(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y); + } + else if (type == "2fv") + { + // void uniform2fv(WebGLUniformLocation? location, Float32Array v); + // void uniform2fv(WebGLUniformLocation? location, sequence v); + gl.uniform2fv(this.uniforms[key].uniformLocation, this.uniforms[key].value); + } + else if (type == "2i") + { + // void uniform2i(WebGLUniformLocation? location, GLint x, GLint y); + gl.uniform2i(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y); + } + else if (type == "2iv") + { + // void uniform2iv(WebGLUniformLocation? location, Int32Array v); + // void uniform2iv(WebGLUniformLocation? location, sequence v); + gl.uniform2iv(this.uniforms[key].uniformLocation, this.uniforms[key].value); + } + else if (type == "3f") + { + // void uniform3f(WebGLUniformLocation? location, GLfloat x, GLfloat y, GLfloat z); + gl.uniform3f(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y, this.uniforms[key].value.z); + } + else if (type == "3fv") + { + // void uniform3fv(WebGLUniformLocation? location, Float32Array v); + // void uniform3fv(WebGLUniformLocation? location, sequence v); + gl.uniform3fv(this.uniforms[key].uniformLocation, this.uniforms[key].value); + } + else if (type == "3i") + { + // void uniform3i(WebGLUniformLocation? location, GLint x, GLint y, GLint z); + gl.uniform3i(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y, this.uniforms[key].value.z); + } + else if (type == "3iv") + { + // void uniform3iv(WebGLUniformLocation? location, Int32Array v); + // void uniform3iv(WebGLUniformLocation? location, sequence v); + gl.uniform3iv(this.uniforms[key].uniformLocation, this.uniforms[key].value); + } + else if (type == "4f") + { + // void uniform4f(WebGLUniformLocation? location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + gl.uniform4f(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y, this.uniforms[key].value.z, this.uniforms[key].value.w); + } + else if (type == "4fv") + { + // void uniform4fv(WebGLUniformLocation? location, Float32Array v); + // void uniform4fv(WebGLUniformLocation? location, sequence v); 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); - } + else if (type == "4i") + { + // void uniform4i(WebGLUniformLocation? location, GLint x, GLint y, GLint z, GLint w); + gl.uniform4i(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y, this.uniforms[key].value.z, this.uniforms[key].value.w); + } + else if (type == "4iv") + { + // void uniform4iv(WebGLUniformLocation? location, Int32Array v); + // void uniform4iv(WebGLUniformLocation? location, sequence v); + gl.uniform4iv(this.uniforms[key].uniformLocation, this.uniforms[key].value); + } + else if (type == "mat2") + { + // void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array value); + // void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, sequence value); + gl.uniformMatrix2fv(this.uniforms[key].uniformLocation, transpose, this.uniforms[key].value); + } + else if (type == "mat3") + { + // void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array value); + // void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose, sequence value); + gl.uniformMatrix3fv(this.uniforms[key].uniformLocation, transpose, this.uniforms[key].value); + } + else if (type == "mat4") + { + // void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array value); + // void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose, sequence value); + gl.uniformMatrix4fv(this.uniforms[key].uniformLocation, transpose, this.uniforms[key].value); + } + else if (type == "sampler2D") + { + if (this.uniforms[key].value && this.uniforms[key].value.baseTexture.hasLoaded) + { + var texture = this.uniforms[key].value.baseTexture._glTexture; + var image = this.uniforms[key].value.baseTexture.source; + var format = gl.RGBA; + + if (this.uniforms[key].format && this.uniforms[key].format == 'luminance') + { + format = gl.LUMINANCE; + } + + gl.activeTexture(gl['TEXTURE' + this.textureCount]); + + if (this.uniforms[key].wrap) + { + if (this.uniforms[key].wrap == 'no-repeat' || this.uniforms[key].wrap === false) + { + this.createGLTextureLinear(gl, image, texture); + } + else if (this.uniforms[key].wrap == 'repeat' || this.uniforms[key].wrap === true) + { + this.createGLTexture(gl, image, format, texture); + } + else if (this.uniforms[key].wrap == 'nearest-repeat') + { + this.createGLTextureNearestRepeat(gl, image, texture); + } + else if (this.uniforms[key].wrap == 'nearest') + { + this.createGLTextureNearest(gl, image, texture); + } + else if (this.uniforms[key].wrap == 'audio') + { + this.createAudioTexture(gl, texture); + } + else if (this.uniforms[key].wrap == 'keyboard') + { + this.createKeyboardTexture(gl, texture); + } + } + else + { + this.createGLTextureLinear(gl, image, texture); + } + + gl.uniform1i(this.uniforms[key].uniformLocation, this.textureCount); + + this.textureCount++; + } + } } +}; + +/** +* Binds the given texture and image data. The texture is set to REPEAT. +* Code based on Effects.js from ShaderToy.com +* @method PIXI.PixiShader#createGLTexture +*/ +PIXI.PixiShader.prototype.createGLTexture = function(gl, image, format, texture) +{ + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); + gl.texImage2D(gl.TEXTURE_2D, 0, format, gl.RGBA, gl.UNSIGNED_BYTE, image); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT); + gl.generateMipmap(gl.TEXTURE_2D); +} + +/** +* Binds the given texture and image data. The texture is set to CLAMP_TO_EDGE. +* Code based on Effects.js from ShaderToy.com +* @method PIXI.PixiShader#createGLTextureLinear +*/ +PIXI.PixiShader.prototype.createGLTextureLinear = function(gl, image, texture) +{ + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); + 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); +} + +/** +* Binds the given texture and image data. The texture is set to REPEAT with NEAREST. +* Code based on Effects.js from ShaderToy.com +* @method PIXI.PixiShader#createGLTextureNearestRepeat +*/ +PIXI.PixiShader.prototype.createGLTextureNearestRepeat = function(gl, image, texture) +{ + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT); +} + +/** +* Binds the given texture and image data. The texture is set to CLAMP_TO_EDGE with NEAREST. +* Code based on Effects.js from ShaderToy.com +* @method PIXI.PixiShader#createGLTextureNearest +*/ +PIXI.PixiShader.prototype.createGLTextureNearest = function(gl, image, texture) +{ + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + 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); +} + +/** +* Binds the given texture data. The texture is set to CLAMP_TO_EDGE with LUMINANCE. Designed for use with real-time audio data. +* Code based on Effects.js from ShaderToy.com +* @method PIXI.PixiShader#createAudioTexture +*/ +PIXI.PixiShader.prototype.createAudioTexture = function(gl, texture) +{ + gl.bindTexture(gl.TEXTURE_2D, 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.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, 512, 2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, null); +} + +/** +* Binds the given texture data. The texture is set to CLAMP_TO_EDGE with LUMINANCE. Designed for use with keyboard input data. +* Code based on Effects.js from ShaderToy.com +* @method PIXI.PixiShader#createKeyboardTexture +*/ +PIXI.PixiShader.prototype.createKeyboardTexture = function(gl, texture) +{ + gl.bindTexture(gl.TEXTURE_2D, texture ); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST ); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST ); + 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.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, 256, 2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, null); } PIXI.PixiShader.defaultVertexSrc = [ - "attribute vec2 aVertexPosition;", - "attribute vec2 aTextureCoord;", - "attribute float aColor;", - - "uniform vec2 projectionVector;", - "uniform vec2 offsetVector;", - "varying vec2 vTextureCoord;", - - "varying float vColor;", + + "attribute vec2 aVertexPosition;", + "attribute vec2 aTextureCoord;", + "attribute float aColor;", - "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;", - "}" + "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;", + "}" ]; /** @@ -4715,7 +4960,7 @@ PIXI._batchs = []; */ PIXI._getBatch = function(gl) { - if(PIXI._batchs.length == 0) + if(PIXI._batchs.length === 0) { return new PIXI.WebGLBatch(gl); } @@ -4895,7 +5140,7 @@ PIXI.WebGLBatch.prototype.remove = function(sprite) { this.size--; - if(this.size == 0) + if(this.size === 0) { sprite.batch = null; sprite.__prev = null; @@ -5228,7 +5473,7 @@ PIXI.WebGLBatch.prototype.render = function(start, end) this.dirty = false; } - if (this.size == 0)return; + if (this.size === 0)return; this.update(); var gl = this.gl; @@ -6080,7 +6325,7 @@ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData) var wrap = true; var points = graphicsData.points; - if(points.length == 0)return; + 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) @@ -6444,7 +6689,7 @@ PIXI.WebGLRenderer.prototype.constructor = PIXI.WebGLRenderer; */ PIXI.WebGLRenderer.getBatch = function() { - if(PIXI._batchs.length == 0) + if(PIXI._batchs.length === 0) { return new PIXI.WebGLBatch(PIXI.WebGLRenderer.gl); } @@ -6722,6 +6967,7 @@ PIXI.WebGLRenderGroup = function(gl, transparent) this.batchs = []; this.toRemove = []; + // console.log(this.transparent) this.filterManager = new PIXI.WebGLFilterManager(this.transparent); } @@ -7471,7 +7717,7 @@ PIXI.WebGLRenderGroup.prototype.removeObject = function(displayObject) // ok so.. check to see if you adjacent batchs should be joined. // TODO may optimise? - if(index == 0 || index == this.batchs.length-1) + if(index === 0 || index == this.batchs.length-1) { // wha - eva! just get of the empty batch! this.batchs.splice(index, 1); @@ -7544,7 +7790,7 @@ PIXI.WebGLRenderGroup.prototype.initTilingSprite = function(sprite) gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, sprite._indexBuffer); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, sprite.indices, gl.STATIC_DRAW); -// return ( (x > 0) && ((x & (x - 1)) == 0) ); +// return ( (x > 0) && ((x & (x - 1)) === 0) ); if(sprite.texture.baseTexture._glTexture) { @@ -7821,6 +8067,7 @@ PIXI._CompileShader = function(gl, shaderSrc, shaderType) gl.compileShader(shader); if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { + console.log(gl.getShaderInfoLog(shader)); return null; } @@ -9130,35 +9377,35 @@ PIXI.PolyK._convex = function(ax, ay, bx, by, cx, cy, sign) */ Phaser.Camera = function (game, id, x, y, width, height) { - /** - * @property {Phaser.Game} game - A reference to the currently running Game. - */ - this.game = game; + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ + this.game = game; - /** - * @property {Phaser.World} world - A reference to the game world. - */ - this.world = game.world; + /** + * @property {Phaser.World} world - A reference to the game world. + */ + this.world = game.world; - /** - * @property {number} id - Reserved for future multiple camera set-ups. - * @default - */ - this.id = 0; + /** + * @property {number} id - Reserved for future multiple camera set-ups. + * @default + */ + this.id = 0; - /** - * Camera view. - * The view into the world we wish to render (by default the game dimensions). + /** + * Camera view. + * The view into the world we wish to render (by default the game dimensions). * The x/y values are in world coordinates, not screen coordinates, the width/height is how many pixels to render. * Objects outside of this view are not rendered (unless set to ignore the Camera, i.e. UI?). - * @property {Phaser.Rectangle} view - */ + * @property {Phaser.Rectangle} view + */ this.view = new Phaser.Rectangle(x, y, width, height); /** - * @property {Phaser.Rectangle} screenView - Used by Sprites to work out Camera culling. - */ - this.screenView = new Phaser.Rectangle(x, y, width, height); + * @property {Phaser.Rectangle} screenView - Used by Sprites to work out Camera culling. + */ + this.screenView = new Phaser.Rectangle(x, y, width, height); /** * The Camera is bound to this Rectangle and cannot move outside of it. By default it is enabled and set to the size of the World. @@ -9169,36 +9416,36 @@ Phaser.Camera = function (game, id, x, y, width, height) { this.bounds = new Phaser.Rectangle(x, y, width, height); /** - * @property {Phaser.Rectangle} deadzone - Moving inside this Rectangle will not cause camera moving. - */ + * @property {Phaser.Rectangle} deadzone - Moving inside this Rectangle will not cause camera moving. + */ this.deadzone = null; - /** - * @property {boolean} visible - Whether this camera is visible or not. - * @default - */ + /** + * @property {boolean} visible - Whether this camera is visible or not. + * @default + */ this.visible = true; - /** - * @property {boolean} atLimit - Whether this camera is flush with the World Bounds or not. + /** + * @property {boolean} atLimit - Whether this camera is flush with the World Bounds or not. */ this.atLimit = { x: false, y: false }; - /** - * @property {Phaser.Sprite} target - If the camera is tracking a Sprite, this is a reference to it, otherwise null. + /** + * @property {Phaser.Sprite} target - If the camera is tracking a Sprite, this is a reference to it, otherwise null. * @default */ this.target = null; - /** - * @property {number} edge - Edge property. + /** + * @property {number} edge - Edge property. * @private * @default */ this._edge = 0; this.displayObject = null; - + }; /** @@ -9227,7 +9474,7 @@ Phaser.Camera.FOLLOW_TOPDOWN_TIGHT = 3; Phaser.Camera.prototype = { - /** + /** * Tells this camera which sprite to follow. * @method Phaser.Camera#follow * @param {Phaser.Sprite} target - The object you want the camera to track. Set to null to not follow anything. @@ -9260,6 +9507,9 @@ Phaser.Camera.prototype = { break; case Phaser.Camera.FOLLOW_LOCKON: + this.deadzone = null; + break; + default: this.deadzone = null; break; @@ -9278,7 +9528,7 @@ Phaser.Camera.prototype = { }, - /** + /** * Move the camera focus on a location instantly. * @method Phaser.Camera#focusOnXY * @param {number} x - X position. @@ -9290,7 +9540,7 @@ Phaser.Camera.prototype = { }, - /** + /** * Update focusing and scrolling. * @method Phaser.Camera#update */ @@ -9459,7 +9709,7 @@ Object.defineProperty(Phaser.Camera.prototype, "x", { * @property {number} y - Gets or sets the cameras y position. */ Object.defineProperty(Phaser.Camera.prototype, "y", { - + get: function () { return this.view.y; }, @@ -9527,86 +9777,86 @@ Object.defineProperty(Phaser.Camera.prototype, "height", { Phaser.State = function () { /** - * @property {Phaser.Game} game - A reference to the currently running Game. - */ + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = null; - /** - * @property {Phaser.GameObjectFactory} add - Reference to the GameObjectFactory. - * @default - */ + /** + * @property {Phaser.GameObjectFactory} add - Reference to the GameObjectFactory. + * @default + */ this.add = null; /** - * @property {Phaser.Physics.PhysicsManager} camera - A handy reference to world.camera. - * @default - */ + * @property {Phaser.Camera} camera - A handy reference to world.camera. + * @default + */ this.camera = null; /** - * @property {Phaser.Cache} cache - Reference to the assets cache. - * @default - */ + * @property {Phaser.Cache} cache - Reference to the assets cache. + * @default + */ this.cache = null; /** - * @property {Phaser.Input} input - Reference to the input manager - * @default - */ + * @property {Phaser.Input} input - Reference to the input manager + * @default + */ this.input = null; /** - * @property {Phaser.Loader} load - Reference to the assets loader. - * @default - */ + * @property {Phaser.Loader} load - Reference to the assets loader. + * @default + */ this.load = null; /** - * @property {Phaser.GameMath} math - Reference to the math helper. - * @default - */ + * @property {Phaser.Math} math - Reference to the math helper. + * @default + */ this.math = null; /** - * @property {Phaser.SoundManager} sound - Reference to the sound manager. - * @default - */ + * @property {Phaser.SoundManager} sound - Reference to the sound manager. + * @default + */ this.sound = null; /** - * @property {Phaser.Stage} stage - Reference to the stage. - * @default - */ + * @property {Phaser.Stage} stage - Reference to the stage. + * @default + */ this.stage = null; /** - * @property {Phaser.TimeManager} time - Reference to game clock. - * @default - */ + * @property {Phaser.TimeManager} time - Reference to game clock. + * @default + */ this.time = null; /** - * @property {Phaser.TweenManager} tweens - Reference to the tween manager. - * @default - */ + * @property {Phaser.TweenManager} tweens - Reference to the tween manager. + * @default + */ this.tweens = null; /** - * @property {Phaser.World} world - Reference to the world. - * @default - */ + * @property {Phaser.World} world - Reference to the world. + * @default + */ this.world = null; - /** - * @property {Description} add - Description. - * @default - */ + /** + * @property {Phaser.Particles} particles - The Particle Manager for the game. It is called during the game update loop and in turn updates any Emitters attached to it. + * @default + */ this.particles = null; /** - * @property {Phaser.Physics.PhysicsManager} physics - Reference to the physics manager. - * @default - */ + * @property {Phaser.Physics.PhysicsManager} physics - Reference to the physics manager. + * @default + */ this.physics = null; }; @@ -9680,6 +9930,8 @@ Phaser.State.prototype = { }; +/* jshint newcap: false */ + /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. @@ -9696,148 +9948,117 @@ Phaser.State.prototype = { */ Phaser.StateManager = function (game, pendingState) { - /** - * A reference to the currently running game. - * @property {Phaser.Game} game. - */ - this.game = game; + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ + this.game = game; - /** - * Description. - * @property {Description} states. - */ - this.states = {}; + /** + * @property {Object} states - The object containing Phaser.States. + */ + this.states = {}; + + /** + * @property {Phaser.State} _pendingState - The state to be switched to in the next frame. + * @private + */ + this._pendingState = null; + + if (pendingState !== null) + { + this._pendingState = pendingState; + } + + /** + * @property {boolean} _created - Flag that sets if the State has been created or not. + * @private + */ + this._created = false; + + /** + * @property {string} current - The current active State object (defaults to null). + */ + this.current = ''; + + /** + * @property {function} onInitCallback - This will be called when the state is started (i.e. set as the current active state). + */ + this.onInitCallback = null; + + /** + * @property {function} onPreloadCallback - This will be called when init states (loading assets...). + */ + this.onPreloadCallback = null; + + /** + * @property {function} onCreateCallback - This will be called when create states (setup states...). + */ + this.onCreateCallback = null; + + /** + * @property {function} onUpdateCallback - This will be called when State is updated, this doesn't happen during load (@see onLoadUpdateCallback). + */ + this.onUpdateCallback = null; + + /** + * @property {function} onRenderCallback - This will be called when the State is rendered, this doesn't happen during load (see onLoadRenderCallback). + */ + this.onRenderCallback = null; + + /** + * @property {function} onPreRenderCallback - This will be called before the State is rendered and before the stage is cleared. + */ + this.onPreRenderCallback = null; + + /** + * @property {function} onLoadUpdateCallback - This will be called when the State is updated but only during the load process. + */ + this.onLoadUpdateCallback = null; + + /** + * @property {function} onLoadRenderCallback - This will be called when the State is rendered but only during the load process. + */ + this.onLoadRenderCallback = null; + + /** + * @property {function} onPausedCallback - This will be called when the state is paused. + */ + this.onPausedCallback = null; + + /** + * @property {function} onShutDownCallback - This will be called when the state is shut down (i.e. swapped to another state). + */ + this.onShutDownCallback = null; - if (pendingState !== null) - { - this._pendingState = pendingState; - } }; Phaser.StateManager.prototype = { - - /** - * A reference to the currently running game. - * @property {Phaser.Game} game. - */ - game: null, - /** - * The state to be switched to in the next frame. - * @property {State} _pendingState - * @private - */ - _pendingState: null, + /** + * The Boot handler is called by Phaser.Game when it first starts up. + * @method Phaser.StateManager#boot + * @private + */ + boot: function () { - /** - * Flag that sets if the State has been created or not. - * @property {boolean}_created - * @private - */ - _created: false, + if (this._pendingState !== null) + { + if (typeof this._pendingState === 'string') + { + // State was already added, so just start it + this.start(this._pendingState, false, false); + } + else + { + this.add('default', this._pendingState, true); + } - /** - * The state to be switched to in the next frame. - * @property {Description} states - */ - states: {}, + } - /** - * The current active State object (defaults to null). - * @property {string} current - */ - current: '', - - /** - * This will be called when the state is started (i.e. set as the current active state). - * @property {function} onInitCallback - */ - onInitCallback: null, + }, - /** - * This will be called when init states (loading assets...). - * @property {function} onPreloadCallback - */ - onPreloadCallback: null, - - /** - * This will be called when create states (setup states...). - * @property {function} onCreateCallback - */ - onCreateCallback: null, - - /** - * This will be called when State is updated, this doesn't happen during load (@see onLoadUpdateCallback). - * @property {function} onUpdateCallback - */ - onUpdateCallback: null, - - /** - * This will be called when the State is rendered, this doesn't happen during load (see onLoadRenderCallback). - * @property {function} onRenderCallback - */ - onRenderCallback: null, - - /** - * This will be called before the State is rendered and before the stage is cleared. - * @property {function} onPreRenderCallback - */ - onPreRenderCallback: null, - - /** - * This will be called when the State is updated but only during the load process. - * @property {function} onLoadUpdateCallback - */ - onLoadUpdateCallback: null, - - /** - * This will be called when the State is rendered but only during the load process. - * @property {function} onLoadRenderCallback - */ - onLoadRenderCallback: null, - - /** - * This will be called when states paused. - * @property {function} onPausedCallback - */ - onPausedCallback: null, - - /** - * This will be called when the state is shut down (i.e. swapped to another state). - * @property {function} onShutDownCallback - */ - onShutDownCallback: null, - - /** - * Description. - * @method Phaser.StateManager#boot - * @private - */ - boot: function () { - - // console.log('Phaser.StateManager.boot'); - - if (this._pendingState !== null) - { - // console.log('_pendingState found'); - // console.log(typeof this._pendingState); - - if (typeof this._pendingState === 'string') - { - // State was already added, so just start it - this.start(this._pendingState, false, false); - } - else - { - this.add('default', this._pendingState, true); - } - - } - - }, - - /** + /** * Add a new State. * @method Phaser.StateManager#add * @param key {string} - A unique key you use to reference this state, i.e. "MainMenu", "Level1". @@ -9848,78 +10069,69 @@ Phaser.StateManager.prototype = { if (typeof autoStart === "undefined") { autoStart = false; } - // console.log('Phaser.StateManager.addState', key); - // console.log(typeof state); - // console.log('autoStart?', autoStart); + var newState; - var newState; + if (state instanceof Phaser.State) + { + newState = state; + } + else if (typeof state === 'object') + { + newState = state; + newState.game = this.game; + } + else if (typeof state === 'function') + { + newState = new state(this.game); + } - if (state instanceof Phaser.State) - { - // console.log('Phaser.StateManager.addState: Phaser.State given'); - newState = state; - } - else if (typeof state === 'object') - { - // console.log('Phaser.StateManager.addState: Object given'); - newState = state; - newState.game = this.game; - } - else if (typeof state === 'function') - { - // console.log('Phaser.StateManager.addState: Function given'); - newState = new state(this.game); - } + this.states[key] = newState; - this.states[key] = newState; + if (autoStart) + { + if (this.game.isBooted) + { + this.start(key); + } + else + { + this._pendingState = key; + } + } - if (autoStart) - { - if (this.game.isBooted) - { - // console.log('Game is booted, so we can start the state now'); - this.start(key); - } - else - { - // console.log('Game is NOT booted, so set the current state as pending'); - this._pendingState = key; - } - } - - return newState; + return newState; }, - /** - * Delete the given state. - * @method Phaser.StateManager#remove - * @param {string} key - A unique key you use to reference this state, i.e. "MainMenu", "Level1". - */ + /** + * Delete the given state. + * @method Phaser.StateManager#remove + * @param {string} key - A unique key you use to reference this state, i.e. "MainMenu", "Level1". + */ remove: function (key) { - if (this.current == key) - { - this.callbackContext = null; + if (this.current == key) + { + this.callbackContext = null; - this.onInitCallback = null; - this.onShutDownCallback = 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.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[key]; + delete this.states[key]; }, - /** + /** * Start the given state * @method Phaser.StateManager#start * @param {string} key - The key of the state you want to start. @@ -9928,84 +10140,75 @@ Phaser.StateManager.prototype = { */ start: function (key, clearWorld, clearCache) { - // console.log('Phaser.StateManager.start', key); - // console.log(this); - // console.log(this.callbackContext); - if (typeof clearWorld === "undefined") { clearWorld = true; } if (typeof clearCache === "undefined") { clearCache = false; } - if (this.game.isBooted == false) + if (this.game.isBooted === false) { - // console.log('Game is NOT booted, so set the requested state as pending'); - this._pendingState = key; - return; + this._pendingState = key; + return; } - if (this.checkState(key) == false) - { - return; - } - else - { - // Already got a state running? - if (this.current) - { - this.onShutDownCallback.call(this.callbackContext, this.game); - } + if (this.checkState(key) === false) + { + return; + } + else + { + // Already got a state running? + if (this.current) + { + this.onShutDownCallback.call(this.callbackContext, this.game); + } - if (clearWorld) - { - this.game.tweens.removeAll(); + if (clearWorld) + { + this.game.tweens.removeAll(); - this.game.world.destroy(); + this.game.world.destroy(); - if (clearCache == true) - { - this.game.cache.destroy(); - } - } + if (clearCache === true) + { + this.game.cache.destroy(); + } + } - this.setCurrentState(key); - } + this.setCurrentState(key); + } if (this.onPreloadCallback) { - // console.log('Preload Callback found'); this.game.load.reset(); this.onPreloadCallback.call(this.callbackContext, this.game); // Is the loader empty? - if (this.game.load.queueSize == 0) + if (this.game.load.queueSize === 0) { - // console.log('Loader queue empty'); this.game.loadComplete(); } else { - // console.log('Loader started'); // Start the loader going as we have something in the queue this.game.load.start(); } } else { - // console.log('Preload callback not found'); // No init? Then there was nothing to load either this.game.loadComplete(); } }, - - /** - * Used by onInit and onShutdown when those functions don't exist on the state + + /** + * Used by onInit and onShutdown when those functions don't exist on the state * @method Phaser.StateManager#dummy * @private */ dummy: function () { }, - /** + /** * Description. * @method Phaser.StateManager#checkState * @param {string} key - The key of the state you want to check. @@ -10013,37 +10216,37 @@ Phaser.StateManager.prototype = { */ checkState: function (key) { - if (this.states[key]) - { - var valid = false; + if (this.states[key]) + { + var valid = false; - if (this.states[key]['preload']) { valid = true; } + if (this.states[key]['preload']) { valid = true; } - if (valid == false && this.states[key]['loadRender']) { valid = true; } - if (valid == false && this.states[key]['loadUpdate']) { valid = true; } - if (valid == false && this.states[key]['create']) { valid = true; } - if (valid == false && this.states[key]['update']) { valid = true; } - if (valid == false && this.states[key]['preRender']) { valid = true; } - if (valid == false && this.states[key]['render']) { valid = true; } - if (valid == false && this.states[key]['paused']) { valid = true; } + if (valid === false && this.states[key]['loadRender']) { valid = true; } + if (valid === false && this.states[key]['loadUpdate']) { valid = true; } + if (valid === false && this.states[key]['create']) { valid = true; } + if (valid === false && this.states[key]['update']) { valid = true; } + if (valid === false && this.states[key]['preRender']) { valid = true; } + if (valid === false && this.states[key]['render']) { valid = true; } + if (valid === false && this.states[key]['paused']) { valid = true; } - if (valid == false) - { - console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions."); - return false; - } + if (valid === false) + { + console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions."); + return false; + } - return true; - } - else - { - console.warn("Phaser.StateManager - No state found with the key: " + key); - return false; - } + return true; + } + else + { + console.warn("Phaser.StateManager - No state found with the key: " + key); + return false; + } }, - /** + /** * Links game properties to the State given by the key. * @method Phaser.StateManager#link * @param {string} key - State key. @@ -10051,7 +10254,6 @@ Phaser.StateManager.prototype = { */ link: function (key) { - // console.log('linked'); this.states[key].game = this.game; this.states[key].add = this.game.add; this.states[key].camera = this.game.camera; @@ -10070,19 +10272,19 @@ Phaser.StateManager.prototype = { }, - /** + /** * Sets the current State. Should not be called directly (use StateManager.start) * @method Phaser.StateManager#setCurrentState * @param {string} key - State key. * @protected */ - setCurrentState: function (key) { + setCurrentState: function (key) { this.callbackContext = this.states[key]; this.link(key); - // Used when the state is set as being the current active state + // Used when the state is set as being the current active state this.onInitCallback = this.states[key]['init'] || this.dummy; this.onPreloadCallback = this.states[key]['preload'] || null; @@ -10094,102 +10296,99 @@ Phaser.StateManager.prototype = { this.onRenderCallback = this.states[key]['render'] || null; this.onPausedCallback = this.states[key]['paused'] || null; - // Used when the state is no longer the current active state + // Used when the state is no longer the current active state this.onShutDownCallback = this.states[key]['shutdown'] || this.dummy; - this.current = key; - this._created = false; + this.current = key; + this._created = false; - this.onInitCallback.call(this.callbackContext, this.game); + this.onInitCallback.call(this.callbackContext, this.game); - }, + }, - /** - * @method Phaser.StateManager#loadComplete + /** + * @method Phaser.StateManager#loadComplete * @protected - */ + */ loadComplete: function () { - // console.log('Phaser.StateManager.loadComplete'); - - if (this._created == false && this.onCreateCallback) + if (this._created === false && this.onCreateCallback) { - // console.log('Create callback found'); - this._created = true; + this._created = true; this.onCreateCallback.call(this.callbackContext, this.game); } else { - this._created = true; + this._created = true; } }, - /** - * @method Phaser.StateManager#update + /** + * @method Phaser.StateManager#update * @protected - */ + */ update: function () { - if (this._created && this.onUpdateCallback) - { - this.onUpdateCallback.call(this.callbackContext, this.game); - } - else - { - if (this.onLoadUpdateCallback) - { - this.onLoadUpdateCallback.call(this.callbackContext, this.game); - } - } + if (this._created && this.onUpdateCallback) + { + this.onUpdateCallback.call(this.callbackContext, this.game); + } + else + { + if (this.onLoadUpdateCallback) + { + this.onLoadUpdateCallback.call(this.callbackContext, this.game); + } + } }, - /** - * @method Phaser.StateManager#preRender + /** + * @method Phaser.StateManager#preRender * @protected - */ + */ preRender: function () { - if (this.onPreRenderCallback) - { - this.onPreRenderCallback.call(this.callbackContext, this.game); - } + if (this.onPreRenderCallback) + { + this.onPreRenderCallback.call(this.callbackContext, this.game); + } }, - /** - * @method Phaser.StateManager#render + /** + * @method Phaser.StateManager#render * @protected - */ + */ render: function () { - if (this._created && this.onRenderCallback) - { - if (this.game.renderType === Phaser.CANVAS) - { - this.game.context.save(); - this.game.context.setTransform(1, 0, 0, 1, 0, 0); - } + if (this._created && this.onRenderCallback) + { + if (this.game.renderType === Phaser.CANVAS) + { + this.game.context.save(); + this.game.context.setTransform(1, 0, 0, 1, 0, 0); + } - this.onRenderCallback.call(this.callbackContext, this.game); + this.onRenderCallback.call(this.callbackContext, this.game); - if (this.game.renderType === Phaser.CANVAS) - { - this.game.context.restore(); - } - } - else - { - if (this.onLoadRenderCallback) - { - this.onLoadRenderCallback.call(this.callbackContext, this.game); - } - } + if (this.game.renderType === Phaser.CANVAS) + { + this.game.context.restore(); + } + } + else + { + if (this.onLoadRenderCallback) + { + this.onLoadRenderCallback.call(this.callbackContext, this.game); + } + } }, - /** + /** * Nuke the entire game from orbit * @method Phaser.StateManager#destroy */ @@ -10232,141 +10431,141 @@ Phaser.StateManager.prototype = { Phaser.LinkedList = function () { /** - * @property {object} next - Next element in the list. - * @default - */ + * @property {object} next - Next element in the list. + * @default + */ this.next = null; /** - * @property {object} prev - Previous element in the list. - * @default - */ + * @property {object} prev - Previous element in the list. + * @default + */ this.prev = null; /** - * @property {object} first - First element in the list. - * @default - */ + * @property {object} first - First element in the list. + * @default + */ this.first = null; /** - * @property {object} last - Last element in the list. - * @default - */ + * @property {object} last - Last element in the list. + * @default + */ this.last = null; /** - * @property {object} game - Number of elements in the list. - * @default - */ + * @property {object} game - Number of elements in the list. + * @default + */ this.total = 0; }; Phaser.LinkedList.prototype = { - /** + /** * Adds a new element to this linked list. - * - * @method Phaser.LinkedList#add - * @param {object} child - The element to add to this list. Can be a Phaser.Sprite or any other object you need to quickly iterate through. - * @return {object} The child that was added. + * + * @method Phaser.LinkedList#add + * @param {object} child - The element to add to this list. Can be a Phaser.Sprite or any other object you need to quickly iterate through. + * @return {object} The child that was added. */ add: function (child) { - // If the list is empty - if (this.total == 0 && this.first == null && this.last == null) - { - this.first = child; - this.last = child; - this.next = child; - child.prev = this; - this.total++; - return child; - } + // If the list is empty + if (this.total === 0 && this.first == null && this.last == null) + { + this.first = child; + this.last = child; + this.next = child; + child.prev = this; + this.total++; + return child; + } - // Get gets appended to the end of the list, regardless of anything, and it won't have any children of its own (non-nested list) - this.last.next = child; + // Get gets appended to the end of the list, regardless of anything, and it won't have any children of its own (non-nested list) + this.last.next = child; - child.prev = this.last; + child.prev = this.last; - this.last = child; + this.last = child; - this.total++; + this.total++; - return child; + return child; }, - /** + /** * Removes the given element from this linked list if it exists. - * - * @method Phaser.LinkedList#remove - * @param {object} child - The child to be removed from the list. + * + * @method Phaser.LinkedList#remove + * @param {object} child - The child to be removed from the list. */ remove: function (child) { - if (child == this.first) - { - // It was 'first', make 'first' point to first.next - this.first = this.first.next; - } - else if (child == this.last) - { - // It was 'last', make 'last' point to last.prev - this.last = this.last.prev; - } + if (child == this.first) + { + // It was 'first', make 'first' point to first.next + this.first = this.first.next; + } + else if (child == this.last) + { + // It was 'last', make 'last' point to last.prev + this.last = this.last.prev; + } - if (child.prev) - { - // make child.prev.next point to childs.next instead of child - child.prev.next = child.next; - } + if (child.prev) + { + // make child.prev.next point to childs.next instead of child + child.prev.next = child.next; + } - if (child.next) - { - // make child.next.prev point to child.prev instead of child - child.next.prev = child.prev; - } + if (child.next) + { + // make child.next.prev point to child.prev instead of child + child.next.prev = child.prev; + } - child.next = child.prev = null; + child.next = child.prev = null; - if (this.first == null ) - { - this.last = null; - } + if (this.first == null ) + { + this.last = null; + } - this.total--; + this.total--; }, - /** + /** * Calls a function on all members of this list, using the member as the context for the callback. * The function must exist on the member. - * - * @method Phaser.LinkedList#callAll - * @param {function} callback - The function to call. + * + * @method Phaser.LinkedList#callAll + * @param {function} callback - The function to call. */ callAll: function (callback) { - if (!this.first || !this.last) - { - return; - } + if (!this.first || !this.last) + { + return; + } - var entity = this.first; - - do - { - if (entity && entity[callback]) - { - entity[callback].call(entity); - } + var entity = this.first; + + do + { + if (entity && entity[callback]) + { + entity[callback].call(entity); + } - entity = entity.next; + entity = entity.next; - } - while(entity != this.last.next) + } + while(entity != this.last.next) } @@ -10385,287 +10584,292 @@ Phaser.LinkedList.prototype = { */ Phaser.Signal = function () { - /** - * @property {Array.} _bindings - Description. - * @private - */ - this._bindings = []; - - /** - * @property {Description} _prevParams - Description. - * @private - */ - this._prevParams = null; + /** + * @property {Array.} _bindings - Description. + * @private + */ + this._bindings = []; + + /** + * @property {Description} _prevParams - Description. + * @private + */ + this._prevParams = null; - // enforce dispatch to aways work on same context (#47) - var self = this; + // enforce dispatch to aways work on same context (#47) + var self = this; - /** - * @property {Description} dispatch - Description. - */ - this.dispatch = function(){ - Phaser.Signal.prototype.dispatch.apply(self, arguments); - }; + /** + * @property {Description} dispatch - Description. + */ + this.dispatch = function(){ + Phaser.Signal.prototype.dispatch.apply(self, arguments); + }; }; Phaser.Signal.prototype = { - /** + /** * If Signal should keep record of previously dispatched parameters and - * automatically execute listener during `add()`/`addOnce()` if Signal was - * already dispatched before. - * @property {boolean} memorize - */ - memorize: false, + * automatically execute listener during `add()`/`addOnce()` if Signal was + * already dispatched before. + * @property {boolean} memorize + */ + memorize: false, - /** - * @property {boolean} _shouldPropagate - * @private - */ - _shouldPropagate: true, + /** + * @property {boolean} _shouldPropagate + * @private + */ + _shouldPropagate: true, - /** - * If Signal is active and should broadcast events. - *

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

- * @property {boolean} active + /** + * If Signal is active and should broadcast events. + *

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

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

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

- * @see Signal.prototype.disable - * - * @method Phaser.Signal#halt - */ - halt: function () { - this._shouldPropagate = false; - }, + /** + * Stop propagation of the event, blocking the dispatch to next listeners on the queue. + *

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

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

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

- * - * @method Phaser.Signal#dispose - */ - dispose: function () { - this.removeAll(); - delete this._bindings; - delete this._prevParams; - }, + /** + * Forget memorized arguments. + * @see Signal.memorize + * + * @method Phaser.Signal#forget + */ + forget: function(){ + this._prevParams = null; + }, - /** - * - * @method Phaser.Signal#toString - * @return {string} String representation of the object. - */ - toString: function () { - return '[Phaser.Signal active:'+ this.active +' numListeners:'+ this.getNumListeners() +']'; - } + /** + * Remove all bindings from signal and destroy any reference to external objects (destroy Signal object). + *

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

+ * + * @method Phaser.Signal#dispose + */ + dispose: function () { + this.removeAll(); + delete this._bindings; + delete this._prevParams; + }, + + /** + * + * @method Phaser.Signal#toString + * @return {string} String representation of the object. + */ + toString: function () { + return '[Phaser.Signal active:'+ this.active +' numListeners:'+ this.getNumListeners() +']'; + } }; @@ -10696,33 +10900,33 @@ Phaser.Signal.prototype = { Phaser.SignalBinding = function (signal, listener, isOnce, listenerContext, priority) { /** - * @property {Phaser.Game} _listener - Handler function bound to the signal. - * @private - */ + * @property {Phaser.Game} _listener - Handler function bound to the signal. + * @private + */ this._listener = listener; /** - * @property {boolean} _isOnce - If binding should be executed just once. - * @private - */ + * @property {boolean} _isOnce - If binding should be executed just once. + * @private + */ this._isOnce = isOnce; /** - * @property {object|undefined|null} context - Context on which listener will be executed (object that should represent the `this` variable inside listener function). - * @memberof SignalBinding.prototype - */ + * @property {object|undefined|null} context - Context on which listener will be executed (object that should represent the `this` variable inside listener function). + * @memberof SignalBinding.prototype + */ this.context = listenerContext; /** - * @property {Signal} _signal - Reference to Signal object that listener is currently bound to. - * @private - */ + * @property {Signal} _signal - Reference to Signal object that listener is currently bound to. + * @private + */ this._signal = signal; /** - * @property {number} _priority - Listener priority. - * @private - */ + * @property {number} _priority - Listener priority. + * @private + */ this._priority = priority || 0; }; @@ -10733,7 +10937,7 @@ Phaser.SignalBinding.prototype = { * If binding is active and should be executed. * @property {boolean} active * @default - */ + */ active: true, /** @@ -10838,6 +11042,134 @@ Phaser.SignalBinding.prototype = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +/** +* This is a base Filter template to use for any Phaser filter development. +* +* @class Phaser.Filter +* @classdesc Phaser - Filter +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {Object} uniforms - Uniform mappings object +* @param {Array} fragmentSrc - The fragment shader code. +*/ +Phaser.Filter = function (game, uniforms, fragmentSrc) { + + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ + this.game = game; + + /** + * @property {number} type - The const type of this object, either Phaser.WEBGL_FILTER or Phaser.CANVAS_FILTER. + * @default + */ + this.type = Phaser.WEBGL_FILTER; + + /** + * An array of passes - some filters contain a few steps this array simply stores the steps in a linear fashion. + * For example the blur filter has two passes blurX and blurY. + * @property {array} passes - An array of filter objects. + * @private + */ + this.passes = [this]; + + /** + * @property {boolean} dirty - Internal PIXI var. + * @default + */ + this.dirty = true; + + /** + * @property {number} padding - Internal PIXI var. + * @default + */ + this.padding = 0; + + /** + * @property {object} uniforms - Default uniform mappings. + */ + this.uniforms = { + + resolution: { type: '3f', value: { x: 256, y: 256, z: 0 }}, + time: { type: '1f', value: 0 }, + mouse: { type: '4f', value: { x: 0, y: 0, z: 0, w: 0 }} + + }; + + /** + * @property {array} fragmentSrc - The fragment shader code. + */ + this.fragmentSrc = fragmentSrc || []; + +}; + +Phaser.Filter.prototype = { + + init: function () { + // This should be over-ridden. Will receive a variable number of arguments. + }, + + setResolution: function (width, height) { + + this.uniforms.resolution.value.x = width; + this.uniforms.resolution.value.y = height; + + }, + + update: function (pointer) { + + if (typeof pointer !== 'undefined') + { + this.uniforms.mouse.x = pointer.x; + this.uniforms.mouse.y = pointer.y; + } + + this.uniforms.time.value = this.game.time.totalElapsedSeconds(); + + }, + + /** + * Clear down this Filter and null out references + * @method Phaser.Filter#destroy + */ + destroy: function () { + + this.game = null; + + } + +}; + +Object.defineProperty(Phaser.Filter.prototype, 'width', { + + get: function() { + return this.uniforms.resolution.value.x; + }, + + set: function(value) { + this.uniforms.resolution.value.x = value; + } + +}); + +Object.defineProperty(Phaser.Filter.prototype, 'height', { + + get: function() { + return this.uniforms.resolution.value.y; + }, + + set: function(value) { + this.uniforms.resolution.value.y = value; + } + +}); + +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + /** * This is a base Plugin template to use for any Phaser plugin development. * @@ -10851,38 +11183,38 @@ Phaser.Plugin = function (game, parent) { if (typeof parent === 'undefined') { parent = null; } - /** - * @property {Phaser.Game} game - A reference to the currently running game. - */ + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ this.game = game; /** - * @property {Any} parent - The parent of this plugin. If added to the PluginManager the parent will be set to that, otherwise it will be null. - */ + * @property {Any} parent - The parent of this plugin. If added to the PluginManager the parent will be set to that, otherwise it will be null. + */ this.parent = parent; /** - * @property {boolean} active - A Plugin with active=true has its preUpdate and update methods called by the parent, otherwise they are skipped. - * @default - */ + * @property {boolean} active - A Plugin with active=true has its preUpdate and update methods called by the parent, otherwise they are skipped. + * @default + */ this.active = false; /** - * @property {boolean} visible - A Plugin with visible=true has its render and postRender methods called by the parent, otherwise they are skipped. - * @default - */ + * @property {boolean} visible - A Plugin with visible=true has its render and postRender methods called by the parent, otherwise they are skipped. + * @default + */ this.visible = false; /** - * @property {boolean} hasPreUpdate - A flag to indicate if this plugin has a preUpdate method. - * @default - */ + * @property {boolean} hasPreUpdate - A flag to indicate if this plugin has a preUpdate method. + * @default + */ this.hasPreUpdate = false; /** - * @property {boolean} hasUpdate - A flag to indicate if this plugin has an update method. - * @default - */ + * @property {boolean} hasUpdate - A flag to indicate if this plugin has an update method. + * @default + */ this.hasUpdate = false; /** @@ -10892,15 +11224,15 @@ Phaser.Plugin = function (game, parent) { this.hasPostUpdate = false; /** - * @property {boolean} hasRender - A flag to indicate if this plugin has a render method. - * @default - */ + * @property {boolean} hasRender - A flag to indicate if this plugin has a render method. + * @default + */ this.hasRender = false; /** - * @property {boolean} hasPostRender - A flag to indicate if this plugin has a postRender method. - * @default - */ + * @property {boolean} hasPostRender - A flag to indicate if this plugin has a postRender method. + * @default + */ this.hasPostRender = false; }; @@ -10954,6 +11286,8 @@ Phaser.Plugin.prototype = { }; +/* jshint newcap: false */ + /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. @@ -10961,7 +11295,7 @@ Phaser.Plugin.prototype = { */ /** -* Description. +* The Plugin Manager is responsible for the loading, running and unloading of Phaser Plugins. * * @class Phaser.PluginManager * @classdesc Phaser - PluginManager @@ -10971,27 +11305,27 @@ Phaser.Plugin.prototype = { */ Phaser.PluginManager = function(game, parent) { - /** - * @property {Phaser.Game} game - A reference to the currently running game. - */ + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ this.game = game; /** - * @property {Description} _parent - Description. - * @private - */ + * @property {Description} _parent - Description. + * @private + */ this._parent = parent; /** - * @property {array} plugins - Description. - */ + * @property {array} plugins - Description. + */ this.plugins = []; /** - * @property {array} _pluginsLength - Description. - * @private - * @default - */ + * @property {array} _pluginsLength - Description. + * @private + * @default + */ this._pluginsLength = 0; }; @@ -11081,13 +11415,13 @@ Phaser.PluginManager.prototype = { }, /** - * Remove a Plugin from the PluginManager. - * @method Phaser.PluginManager#remove - * @param {Phaser.Plugin} plugin - The plugin to be removed. - */ + * Remove a Plugin from the PluginManager. + * @method Phaser.PluginManager#remove + * @param {Phaser.Plugin} plugin - The plugin to be removed. + */ remove: function (plugin) { - if (this._pluginsLength == 0) + if (this._pluginsLength === 0) { return; } @@ -11105,9 +11439,9 @@ Phaser.PluginManager.prototype = { }, /** - * Removes all Plugins from the PluginManager. - * @method Phaser.PluginManager#removeAll - */ + * Removes all Plugins from the PluginManager. + * @method Phaser.PluginManager#removeAll + */ removeAll: function() { for (this._p = 0; this._p < this._pluginsLength; this._p++) @@ -11126,7 +11460,7 @@ Phaser.PluginManager.prototype = { */ preUpdate: function () { - if (this._pluginsLength == 0) + if (this._pluginsLength === 0) { return; } @@ -11149,7 +11483,7 @@ Phaser.PluginManager.prototype = { */ update: function () { - if (this._pluginsLength == 0) + if (this._pluginsLength === 0) { return; } @@ -11173,7 +11507,7 @@ Phaser.PluginManager.prototype = { */ postUpdate: function () { - if (this._pluginsLength == 0) + if (this._pluginsLength === 0) { return; } @@ -11196,7 +11530,7 @@ Phaser.PluginManager.prototype = { */ render: function () { - if (this._pluginsLength == 0) + if (this._pluginsLength === 0) { return; } @@ -11219,7 +11553,7 @@ Phaser.PluginManager.prototype = { */ postRender: function () { - if (this._pluginsLength == 0) + if (this._pluginsLength === 0) { return; } @@ -11269,26 +11603,26 @@ Phaser.PluginManager.prototype = { Phaser.Stage = function (game, width, height) { /** - * @property {Phaser.Game} game - A reference to the currently running Game. - */ - this.game = game; + * @property {Phaser.Game} game - A reference to the currently running Game. + */ + this.game = game; /** - * @property {string} game - Background color of the stage (defaults to black). Set via the public backgroundColor property. - * @private - * @default 'rgb(0,0,0)' - */ + * @property {string} game - Background color of the stage (defaults to black). Set via the public backgroundColor property. + * @private + * @default 'rgb(0,0,0)' + */ this._backgroundColor = 'rgb(0,0,0)'; /** - * @property {Phaser.Point} offset - Get the offset values (for input and other things). - */ - this.offset = new Phaser.Point; + * @property {Phaser.Point} offset - Get the offset values (for input and other things). + */ + this.offset = new Phaser.Point(); /** * @property {HTMLCanvasElement} canvas - Reference to the newly created <canvas> element. */ - this.canvas = Phaser.Canvas.create(width, height); + this.canvas = Phaser.Canvas.create(width, height); this.canvas.style['-webkit-full-screen'] = 'width: 100%; height: 100%'; /** @@ -11301,7 +11635,7 @@ Phaser.Stage = function (game, width, height) { /** * @property {number} scaleMode - The current scaleMode. - */ + */ this.scaleMode = Phaser.StageScaleMode.NO_SCALE; /** @@ -11310,8 +11644,8 @@ Phaser.Stage = function (game, width, height) { this.scale = new Phaser.StageScaleMode(this.game, width, height); /** - * @property {number} aspectRatio - Aspect ratio. - */ + * @property {number} aspectRatio - Aspect ratio. + */ this.aspectRatio = width / height; /** @@ -11350,6 +11684,8 @@ Phaser.Stage.prototype = { Phaser.Canvas.setUserSelect(this.canvas, 'none'); Phaser.Canvas.setTouchAction(this.canvas, 'none'); + this.backgroundColor = '#000'; + document.addEventListener('visibilitychange', this._onChange, false); document.addEventListener('webkitvisibilitychange', this._onChange, false); document.addEventListener('pagehide', this._onChange, false); @@ -11378,7 +11714,7 @@ Phaser.Stage.prototype = { }, - /** + /** * This method is called when the document visibility is changed. * @method Phaser.Stage#visibilityChange * @param {Event} event - Its type will be used to decide whether the game should be paused or not. @@ -11390,16 +11726,16 @@ Phaser.Stage.prototype = { return; } - if (event.type == 'pagehide' || event.type == 'blur' || document['hidden'] == true || document['webkitHidden'] == true) + if (event.type == 'pagehide' || event.type == 'blur' || document['hidden'] === true || document['webkitHidden'] === true) { - this.game.paused = true; + this.game.paused = true; } else { - this.game.paused = false; + this.game.paused = false; } - }, + } }; @@ -11417,19 +11753,23 @@ Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", { this._backgroundColor = color; - if (this.game.renderType == Phaser.CANVAS) + if (this.game.transparent === false) { - // Set it directly, this allows us to use rgb alpha values in Canvas mode. - this._stage.backgroundColorString = color; - } - else - { - if (typeof color === 'string') + if (this.game.renderType == Phaser.CANVAS) { - color = Phaser.Color.hexToRGB(color); + // Set it directly, this allows us to use rgb alpha values in Canvas mode. + this.game.canvas.style.backgroundColor = color; + } + else + { + if (typeof color === 'string') + { + color = Phaser.Color.hexToRGB(color); + } + + this._stage.setBackgroundColor(color); } - this._stage.setBackgroundColor(color); } } @@ -11454,77 +11794,77 @@ Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", { */ Phaser.Group = function (game, parent, name, useStage) { - if (typeof parent === 'undefined' || typeof parent === null) - { - parent = game.world; - } + if (typeof parent === 'undefined' || typeof parent === null) + { + parent = game.world; + } - if (typeof useStage === 'undefined') - { - useStage = false; - } + if (typeof useStage === 'undefined') + { + useStage = false; + } /** - * @property {Phaser.Game} game - A reference to the currently running Game. - */ - this.game = game; - + * @property {Phaser.Game} game - A reference to the currently running Game. + */ + this.game = game; + /** - * @property {string} name - A name for this Group. Not used internally but useful for debugging. - */ - this.name = name || 'group'; + * @property {string} name - A name for this Group. Not used internally but useful for debugging. + */ + this.name = name || 'group'; - if (useStage) - { - this._container = this.game.stage._stage; - } - else - { - this._container = new PIXI.DisplayObjectContainer(); - this._container.name = this.name; + if (useStage) + { + this._container = this.game.stage._stage; + } + else + { + this._container = new PIXI.DisplayObjectContainer(); + this._container.name = this.name; - if (parent) - { - if (parent instanceof Phaser.Group) - { - parent._container.addChild(this._container); - parent._container.updateTransform(); - } - else - { - parent.addChild(this._container); - parent.updateTransform(); - } - } - else - { - this.game.stage._stage.addChild(this._container); - this.game.stage._stage.updateTransform(); - } - } + if (parent) + { + if (parent instanceof Phaser.Group) + { + parent._container.addChild(this._container); + parent._container.updateTransform(); + } + else + { + parent.addChild(this._container); + parent.updateTransform(); + } + } + else + { + this.game.stage._stage.addChild(this._container); + this.game.stage._stage.updateTransform(); + } + } - /** - * @property {number} type - Internal Phaser Type value. - * @protected - */ - this.type = Phaser.GROUP; + /** + * @property {number} type - Internal Phaser Type value. + * @protected + */ + this.type = Phaser.GROUP; - /** - * @property {boolean} exists - If exists is true the the Group is updated, otherwise it is skipped. - * @default - */ - this.exists = true; + /** + * @property {boolean} exists - If exists is true the the Group is updated, otherwise it is skipped. + * @default + */ + this.exists = true; /** * @property {Phaser.Point} scale - Replaces the PIXI.Point with a slightly more flexible one. - */ + */ this.scale = new Phaser.Point(1, 1); /** * The cursor is a simple way to iterate through the objects in a Group using the Group.next and Group.previous functions. * The cursor is set to the first child added to the Group and doesn't change unless you call next, previous or set it directly with Group.cursor. * @property {any} cursor - The current display object that the Group cursor is pointing to. - */ + */ this.cursor = null; }; @@ -11569,612 +11909,610 @@ Phaser.Group.prototype = { * @see Phaser.Group#create * @see Phaser.Group#addAt * @method Phaser.Group#add - * @param {*} child - An instance of Phaser.Sprite, Phaser.Button or any other display object.. - * @return {*} The child that was added to the Group. + * @param {*} child - An instance of Phaser.Sprite, Phaser.Button or any other display object.. + * @return {*} The child that was added to the Group. */ - add: function (child) { + add: function (child) { - if (child.group !== this) - { - child.group = this; + if (child.group !== this) + { + child.group = this; - if (child.events) - { - child.events.onAddedToGroup.dispatch(child, this); - } + if (child.events) + { + child.events.onAddedToGroup.dispatch(child, this); + } - this._container.addChild(child); + this._container.addChild(child); - child.updateTransform(); + child.updateTransform(); - if (this.cursor === null) - { - this.cursor = child; - } - } + if (this.cursor === null) + { + this.cursor = child; + } + } - return child; + return child; - }, + }, /** * Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object. * The child is added to the Group at the location specified by the index value, this allows you to control child ordering. - * + * * @method Phaser.Group#addAt - * @param {*} child - An instance of Phaser.Sprite, Phaser.Button or any other display object.. - * @param {number} index - The index within the Group to insert the child to. - * @return {*} The child that was added to the Group. - */ - addAt: function (child, index) { + * @param {*} child - An instance of Phaser.Sprite, Phaser.Button or any other display object.. + * @param {number} index - The index within the Group to insert the child to. + * @return {*} The child that was added to the Group. + */ + addAt: function (child, index) { - if (child.group !== this) - { - child.group = this; + if (child.group !== this) + { + child.group = this; - if (child.events) - { - child.events.onAddedToGroup.dispatch(child, this); - } + if (child.events) + { + child.events.onAddedToGroup.dispatch(child, this); + } - this._container.addChildAt(child, index); + this._container.addChildAt(child, index); - child.updateTransform(); + child.updateTransform(); - if (this.cursor === null) - { - this.cursor = child; - } - } + if (this.cursor === null) + { + this.cursor = child; + } + } - return child; + return child; - }, + }, /** - * Returns the child found at the given index within this Group. - * + * Returns the child found at the given index within this Group. + * * @method Phaser.Group#getAt * @memberof Phaser.Group - * @param {number} index - The index to return the child from. - * @return {*} The child that was found at the given index. - */ - getAt: function (index) { + * @param {number} index - The index to return the child from. + * @return {*} The child that was found at the given index. + */ + getAt: function (index) { - return this._container.getChildAt(index); + return this._container.getChildAt(index); - }, + }, /** - * Automatically creates a new Phaser.Sprite object and adds it to the top of this Group. - * Useful if you don't need to create the Sprite instances before-hand. - * + * Automatically creates a new Phaser.Sprite object and adds it to the top of this Group. + * Useful if you don't need to create the Sprite instances before-hand. + * * @method Phaser.Group#create - * @param {number} x - The x coordinate to display the newly created Sprite at. The value is in relation to the Group.x point. - * @param {number} y - The y coordinate to display the newly created Sprite at. The value is in relation to the Group.y point. - * @param {string} key - The Game.cache key of the image that this Sprite will use. - * @param {number|string} [frame] - If the Sprite image contains multiple frames you can specify which one to use here. - * @param {boolean} [exists=true] - The default exists state of the Sprite. - * @return {Phaser.Sprite} The child that was created. - */ - create: function (x, y, key, frame, exists) { + * @param {number} x - The x coordinate to display the newly created Sprite at. The value is in relation to the Group.x point. + * @param {number} y - The y coordinate to display the newly created Sprite at. The value is in relation to the Group.y point. + * @param {string} key - The Game.cache key of the image that this Sprite will use. + * @param {number|string} [frame] - If the Sprite image contains multiple frames you can specify which one to use here. + * @param {boolean} [exists=true] - The default exists state of the Sprite. + * @return {Phaser.Sprite} The child that was created. + */ + create: function (x, y, key, frame, exists) { - if (typeof exists == 'undefined') { exists = true; } + if (typeof exists == 'undefined') { exists = true; } - var child = new Phaser.Sprite(this.game, x, y, key, frame); + var child = new Phaser.Sprite(this.game, x, y, key, frame); - child.group = this; - child.exists = exists; - child.visible = exists; - child.alive = exists; + child.group = this; + child.exists = exists; + child.visible = exists; + child.alive = exists; - if (child.events) - { - child.events.onAddedToGroup.dispatch(child, this); - } + if (child.events) + { + child.events.onAddedToGroup.dispatch(child, this); + } - this._container.addChild(child); - - child.updateTransform(); + this._container.addChild(child); + + child.updateTransform(); - if (this.cursor === null) - { - this.cursor = child; - } + if (this.cursor === null) + { + this.cursor = child; + } - return child; + return child; - }, + }, /** - * Automatically creates multiple Phaser.Sprite objects and adds them to the top of this Group. - * Useful if you need to quickly generate a pool of identical sprites, such as bullets. By default the sprites will be set to not exist - * and will be positioned at 0, 0 (relative to the Group.x/y) - * + * Automatically creates multiple Phaser.Sprite objects and adds them to the top of this Group. + * Useful if you need to quickly generate a pool of identical sprites, such as bullets. By default the sprites will be set to not exist + * and will be positioned at 0, 0 (relative to the Group.x/y) + * * @method Phaser.Group#createMultiple - * @param {number} quantity - The number of Sprites to create. - * @param {string} key - The Game.cache key of the image that this Sprite will use. - * @param {number|string} [frame] - If the Sprite image contains multiple frames you can specify which one to use here. - * @param {boolean} [exists=false] - The default exists state of the Sprite. - */ - createMultiple: function (quantity, key, frame, exists) { + * @param {number} quantity - The number of Sprites to create. + * @param {string} key - The Game.cache key of the image that this Sprite will use. + * @param {number|string} [frame] - If the Sprite image contains multiple frames you can specify which one to use here. + * @param {boolean} [exists=false] - The default exists state of the Sprite. + */ + createMultiple: function (quantity, key, frame, exists) { - if (typeof exists == 'undefined') { exists = false; } + if (typeof exists == 'undefined') { exists = false; } - for (var i = 0; i < quantity; i++) - { - var child = new Phaser.Sprite(this.game, 0, 0, key, frame); + for (var i = 0; i < quantity; i++) + { + var child = new Phaser.Sprite(this.game, 0, 0, key, frame); - child.group = this; - child.exists = exists; - child.visible = exists; - child.alive = exists; + child.group = this; + child.exists = exists; + child.visible = exists; + child.alive = exists; - if (child.events) - { - child.events.onAddedToGroup.dispatch(child, this); - } + if (child.events) + { + child.events.onAddedToGroup.dispatch(child, this); + } - this._container.addChild(child); - child.updateTransform(); + this._container.addChild(child); + child.updateTransform(); - if (this.cursor === null) - { - this.cursor = child; - } + if (this.cursor === null) + { + this.cursor = child; + } - } + } - }, + }, /** - * Advances the Group cursor to the next object in the Group. If it's at the end of the Group it wraps around to the first object. - * + * Advances the Group cursor to the next object in the Group. If it's at the end of the Group it wraps around to the first object. + * * @method Phaser.Group#next - */ - next: function () { + */ + next: function () { - if (this.cursor) - { - // Wrap the cursor? - if (this.cursor == this._container.last) - { - this.cursor = this._container._iNext; - } - else - { - this.cursor = this.cursor._iNext; - } - } + if (this.cursor) + { + // Wrap the cursor? + if (this.cursor == this._container.last) + { + this.cursor = this._container._iNext; + } + else + { + this.cursor = this.cursor._iNext; + } + } - }, + }, /** - * Moves the Group cursor to the previous object in the Group. If it's at the start of the Group it wraps around to the last object. - * + * Moves the Group cursor to the previous object in the Group. If it's at the start of the Group it wraps around to the last object. + * * @method Phaser.Group#previous - */ - previous: function () { + */ + previous: function () { - if (this.cursor) - { - // Wrap the cursor? - if (this.cursor == this._container._iNext) - { - this.cursor = this._container.last; - } - else - { - this.cursor = this.cursor._iPrev; - } - } + if (this.cursor) + { + // Wrap the cursor? + if (this.cursor == this._container._iNext) + { + this.cursor = this._container.last; + } + else + { + this.cursor = this.cursor._iPrev; + } + } - }, + }, - childTest: function (prefix, child) { + childTest: function (prefix, child) { - var s = prefix + ' next: '; + var s = prefix + ' next: '; - if (child._iNext) - { - s = s + child._iNext.name; - } - else - { - s = s + '-null-'; - } + if (child._iNext) + { + s = s + child._iNext.name; + } + else + { + s = s + '-null-'; + } - s = s + ' ' + prefix + ' prev: '; + s = s + ' ' + prefix + ' prev: '; - if (child._iPrev) - { - s = s + child._iPrev.name; - } - else - { - s = s + '-null-'; - } + if (child._iPrev) + { + s = s + child._iPrev.name; + } + else + { + s = s + '-null-'; + } - console.log(s); + console.log(s); - }, + }, - swapIndex: function (index1, index2) { + swapIndex: function (index1, index2) { - var child1 = this.getAt(index1); - var child2 = this.getAt(index2); + var child1 = this.getAt(index1); + var child2 = this.getAt(index2); - console.log('swapIndex ', index1, ' with ', index2); + console.log('swapIndex ', index1, ' with ', index2); - this.swap(child1, child2); + this.swap(child1, child2); - }, + }, - /** - * 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. - * + /** + * 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. - * @param {*} child2 - The second child to swap. + * @param {*} child1 - The first child to swap. + * @param {*} child2 - The second child to swap. * @return {boolean} True if the swap was successful, otherwise false. - */ - swap: function (child1, child2) { + */ + swap: function (child1, child2) { - if (child1 === child2 || !child1.parent || !child2.parent || child1.group !== this || child2.group !== this) - { - return false; - } + if (child1 === child2 || !child1.parent || !child2.parent || child1.group !== this || child2.group !== this) + { + return false; + } - // Cache the values - var child1Prev = child1._iPrev; - var child1Next = child1._iNext; - var child2Prev = child2._iPrev; - var child2Next = child2._iNext; + // Cache the values + var child1Prev = child1._iPrev; + var child1Next = child1._iNext; + var child2Prev = child2._iPrev; + var child2Next = child2._iNext; - var endNode = this._container.last._iNext; - var currentNode = this.game.stage._stage; - - do - { - if (currentNode !== child1 && currentNode !== child2) - { - if (currentNode.first === child1) - { - currentNode.first = child2; - } - else if (currentNode.first === child2) - { - currentNode.first = child1; - } + var endNode = this._container.last._iNext; + var currentNode = this.game.stage._stage; + + do + { + if (currentNode !== child1 && currentNode !== child2) + { + if (currentNode.first === child1) + { + currentNode.first = child2; + } + else if (currentNode.first === child2) + { + currentNode.first = child1; + } - if (currentNode.last === child1) - { - currentNode.last = child2; - } - else if (currentNode.last === child2) - { - currentNode.last = child1; - } - } + if (currentNode.last === child1) + { + currentNode.last = child2; + } + else if (currentNode.last === child2) + { + currentNode.last = child1; + } + } - currentNode = currentNode._iNext; - } - while (currentNode != endNode) + currentNode = currentNode._iNext; + } + while (currentNode != endNode) - if (child1._iNext == child2) - { - // This is a downward (A to B) neighbour swap - child1._iNext = child2Next; - child1._iPrev = child2; - child2._iNext = child1; - child2._iPrev = child1Prev; + if (child1._iNext == child2) + { + // This is a downward (A to B) neighbour swap + child1._iNext = child2Next; + child1._iPrev = child2; + child2._iNext = child1; + child2._iPrev = child1Prev; - if (child1Prev) { child1Prev._iNext = child2; } - if (child2Next) { child2Next._iPrev = child1; } + if (child1Prev) { child1Prev._iNext = child2; } + if (child2Next) { child2Next._iPrev = child1; } - if (child1.__renderGroup) - { - child1.__renderGroup.updateTexture(child1); - } + if (child1.__renderGroup) + { + child1.__renderGroup.updateTexture(child1); + } - if (child2.__renderGroup) - { - child2.__renderGroup.updateTexture(child2); - } + if (child2.__renderGroup) + { + child2.__renderGroup.updateTexture(child2); + } - return true; - } - else if (child2._iNext == child1) - { - // This is an upward (B to A) neighbour swap - child1._iNext = child2; - child1._iPrev = child2Prev; - child2._iNext = child1Next; - child2._iPrev = child1; + return true; + } + else if (child2._iNext == child1) + { + // This is an upward (B to A) neighbour swap + child1._iNext = child2; + child1._iPrev = child2Prev; + child2._iNext = child1Next; + child2._iPrev = child1; - if (child2Prev) { child2Prev._iNext = child1; } - if (child1Next) { child1Next._iPrev = child2; } + if (child2Prev) { child2Prev._iNext = child1; } + if (child1Next) { child1Next._iPrev = child2; } - if (child1.__renderGroup) - { - child1.__renderGroup.updateTexture(child1); - } + if (child1.__renderGroup) + { + child1.__renderGroup.updateTexture(child1); + } - if (child2.__renderGroup) - { - child2.__renderGroup.updateTexture(child2); - } + if (child2.__renderGroup) + { + child2.__renderGroup.updateTexture(child2); + } - return true; - } - else - { - // Children are far apart - child1._iNext = child2Next; - child1._iPrev = child2Prev; - child2._iNext = child1Next; - child2._iPrev = child1Prev; + return true; + } + else + { + // Children are far apart + child1._iNext = child2Next; + child1._iPrev = child2Prev; + child2._iNext = child1Next; + child2._iPrev = child1Prev; - if (child1Prev) { child1Prev._iNext = child2; } - if (child1Next) { child1Next._iPrev = child2; } - if (child2Prev) { child2Prev._iNext = child1; } - if (child2Next) { child2Next._iPrev = child1; } + if (child1Prev) { child1Prev._iNext = child2; } + if (child1Next) { child1Next._iPrev = child2; } + if (child2Prev) { child2Prev._iNext = child1; } + if (child2Next) { child2Next._iPrev = child1; } - if (child1.__renderGroup) - { - child1.__renderGroup.updateTexture(child1); - } + if (child1.__renderGroup) + { + child1.__renderGroup.updateTexture(child1); + } - if (child2.__renderGroup) - { - child2.__renderGroup.updateTexture(child2); - } + if (child2.__renderGroup) + { + child2.__renderGroup.updateTexture(child2); + } - return true; - } + return true; + } - return false; - - }, + return false; + + }, - /** - * Brings the given child to the top of this Group so it renders above all other children. - * + /** + * Brings the given child to the top of this Group so it renders above all other children. + * * @method Phaser.Group#bringToTop - * @param {*} child - The child to bring to the top of this Group. + * @param {*} child - The child to bring to the top of this Group. * @return {*} The child that was moved. - */ - bringToTop: function (child) { + */ + bringToTop: function (child) { - if (child.group === this) - { - this.remove(child); - this.add(child); - } + if (child.group === this) + { + this.remove(child); + this.add(child); + } - return child; + return child; - }, + }, - /** - * Get the index position of the given child in this Group. - * + /** + * Get the index position of the given child in this Group. + * * @method Phaser.Group#getIndex - * @param {*} child - The child to get the index for. + * @param {*} child - The child to get the index for. * @return {number} The index of the child or -1 if it's not a member of this Group. - */ - getIndex: function (child) { + */ + getIndex: function (child) { - return this._container.children.indexOf(child); + return this._container.children.indexOf(child); - }, + }, - /** - * Replaces a child of this Group with the given newChild. The newChild cannot be a member of this Group. - * + /** + * Replaces a child of this Group with the given newChild. The newChild cannot be a member of this Group. + * * @method Phaser.Group#replace - * @param {*} oldChild - The child in this Group that will be replaced. - * @param {*} newChild - The child to be inserted into this group. - */ - replace: function (oldChild, newChild) { + * @param {*} oldChild - The child in this Group that will be replaced. + * @param {*} newChild - The child to be inserted into this group. + */ + replace: function (oldChild, newChild) { - if (!this._container.first._iNext) - { - return; - } + if (!this._container.first._iNext) + { + return; + } - var index = this.getIndex(oldChild); - - if (index != -1) - { - if (newChild.parent != undefined) - { - newChild.events.onRemovedFromGroup.dispatch(newChild, this); - newChild.parent.removeChild(newChild); - } + var index = this.getIndex(oldChild); + + if (index != -1) + { + if (newChild.parent !== undefined) + { + newChild.events.onRemovedFromGroup.dispatch(newChild, this); + newChild.parent.removeChild(newChild); + } - this._container.removeChild(oldChild); - this._container.addChildAt(newChild, index); + this._container.removeChild(oldChild); + this._container.addChildAt(newChild, index); - newChild.events.onAddedToGroup.dispatch(newChild, this); - newChild.updateTransform(); + newChild.events.onAddedToGroup.dispatch(newChild, this); + newChild.updateTransform(); - if (this.cursor == oldChild) - { - this.cursor = this._container._iNext; - } - } + if (this.cursor == oldChild) + { + this.cursor = this._container._iNext; + } + } - }, + }, - /** - * Sets the given property to the given value on the child. The operation controls the assignment of the value. - * - * @method Phaser.Group#setProperty - * @param {*} child - The child to set the property value on. - * @param {array} key - An array of strings that make up the property that will be set. - * @param {*} value - The value that will be set. - * @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it. - */ - setProperty: function (child, key, value, operation) { + /** + * Sets the given property to the given value on the child. The operation controls the assignment of the value. + * + * @method Phaser.Group#setProperty + * @param {*} child - The child to set the property value on. + * @param {array} key - An array of strings that make up the property that will be set. + * @param {*} value - The value that will be set. + * @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it. + */ + setProperty: function (child, key, value, operation) { - operation = operation || 0; + operation = operation || 0; - // As ugly as this approach looks, and although it's limited to a depth of only 4, it's extremely fast. - // Much faster than a for loop or object iteration. There are no checks, so if the key isn't valid then it'll fail - // but as you are likely to call this from inner loops that have to perform well, I'll take that trade off. + // As ugly as this approach looks, and although it's limited to a depth of only 4, it's extremely fast. + // Much faster than a for loop or object iteration. There are no checks, so if the key isn't valid then it'll fail + // but as you are likely to call this from inner loops that have to perform well, I'll take that trade off. - // 0 = Equals - // 1 = Add - // 2 = Subtract - // 3 = Multiply - // 4 = Divide + // 0 = Equals + // 1 = Add + // 2 = Subtract + // 3 = Multiply + // 4 = Divide - var len = key.length; + var len = key.length; - if (len == 1) - { - if (operation == 0) { child[key[0]] = value; } - else if (operation == 1) { child[key[0]] += value; } - else if (operation == 2) { child[key[0]] -= value; } - else if (operation == 3) { child[key[0]] *= value; } - else if (operation == 4) { child[key[0]] /= value; } - } - else if (len == 2) - { - if (operation == 0) { child[key[0]][key[1]] = value; } - else if (operation == 1) { child[key[0]][key[1]] += value; } - else if (operation == 2) { child[key[0]][key[1]] -= value; } - else if (operation == 3) { child[key[0]][key[1]] *= value; } - else if (operation == 4) { child[key[0]][key[1]] /= value; } - } - else if (len == 3) - { - if (operation == 0) { child[key[0]][key[1]][key[2]] = value; } - else if (operation == 1) { child[key[0]][key[1]][key[2]] += value; } - else if (operation == 2) { child[key[0]][key[1]][key[2]] -= value; } - else if (operation == 3) { child[key[0]][key[1]][key[2]] *= value; } - else if (operation == 4) { child[key[0]][key[1]][key[2]] /= value; } - } - else if (len == 4) - { - if (operation == 0) { child[key[0]][key[1]][key[2]][key[3]] = value; } - else if (operation == 1) { child[key[0]][key[1]][key[2]][key[3]] += value; } - else if (operation == 2) { child[key[0]][key[1]][key[2]][key[3]] -= value; } - else if (operation == 3) { child[key[0]][key[1]][key[2]][key[3]] *= value; } - else if (operation == 4) { child[key[0]][key[1]][key[2]][key[3]] /= value; } - } - else - { - // TODO - Deep property scane - } + if (len == 1) + { + if (operation === 0) { child[key[0]] = value; } + else if (operation == 1) { child[key[0]] += value; } + else if (operation == 2) { child[key[0]] -= value; } + else if (operation == 3) { child[key[0]] *= value; } + else if (operation == 4) { child[key[0]] /= value; } + } + else if (len == 2) + { + if (operation === 0) { child[key[0]][key[1]] = value; } + else if (operation == 1) { child[key[0]][key[1]] += value; } + else if (operation == 2) { child[key[0]][key[1]] -= value; } + else if (operation == 3) { child[key[0]][key[1]] *= value; } + else if (operation == 4) { child[key[0]][key[1]] /= value; } + } + else if (len == 3) + { + if (operation === 0) { child[key[0]][key[1]][key[2]] = value; } + else if (operation == 1) { child[key[0]][key[1]][key[2]] += value; } + else if (operation == 2) { child[key[0]][key[1]][key[2]] -= value; } + else if (operation == 3) { child[key[0]][key[1]][key[2]] *= value; } + else if (operation == 4) { child[key[0]][key[1]][key[2]] /= value; } + } + else if (len == 4) + { + if (operation === 0) { child[key[0]][key[1]][key[2]][key[3]] = value; } + else if (operation == 1) { child[key[0]][key[1]][key[2]][key[3]] += value; } + else if (operation == 2) { child[key[0]][key[1]][key[2]][key[3]] -= value; } + else if (operation == 3) { child[key[0]][key[1]][key[2]][key[3]] *= value; } + else if (operation == 4) { child[key[0]][key[1]][key[2]][key[3]] /= value; } + } + + // TODO - Deep property scane - }, + }, - /** - * This function allows you to quickly set the same property across all children of this Group to a new value. - * The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication. - * - * @method Phaser.Group#setAll - * @param {string} key - The property, as a string, to be set. For example: 'body.velocity.x' - * @param {*} value - The value that will be set. - * @param {boolean} [checkAlive=false] - If set then only children with alive=true will be updated. - * @param {boolean} [checkVisible=false] - If set then only children with visible=true will be updated. - * @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it. - */ - setAll: function (key, value, checkAlive, checkVisible, operation) { + /** + * This function allows you to quickly set the same property across all children of this Group to a new value. + * The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication. + * + * @method Phaser.Group#setAll + * @param {string} key - The property, as a string, to be set. For example: 'body.velocity.x' + * @param {*} value - The value that will be set. + * @param {boolean} [checkAlive=false] - If set then only children with alive=true will be updated. + * @param {boolean} [checkVisible=false] - If set then only children with visible=true will be updated. + * @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it. + */ + setAll: function (key, value, checkAlive, checkVisible, operation) { - key = key.split('.'); + key = key.split('.'); - if (typeof checkAlive === 'undefined') { checkAlive = false; } - if (typeof checkVisible === 'undefined') { checkVisible = false; } + if (typeof checkAlive === 'undefined') { checkAlive = false; } + if (typeof checkVisible === 'undefined') { checkVisible = false; } - operation = operation || 0; + operation = operation || 0; - if (this._container.children.length > 0 && this._container.first._iNext) - { - var currentNode = this._container.first._iNext; - - do - { - if ((checkAlive == false || (checkAlive && currentNode.alive)) && (checkVisible == false || (checkVisible && currentNode.visible))) - { - this.setProperty(currentNode, key, value, operation); - } + if (this._container.children.length > 0 && this._container.first._iNext) + { + var currentNode = this._container.first._iNext; + + do + { + if ((checkAlive === false || (checkAlive && currentNode.alive)) && (checkVisible === false || (checkVisible && currentNode.visible))) + { + this.setProperty(currentNode, key, value, operation); + } - currentNode = currentNode._iNext; - } - while (currentNode != this._container.last._iNext) - } + currentNode = currentNode._iNext; + } + while (currentNode != this._container.last._iNext) + } - }, + }, - /** - * Adds the amount to the given property on all children in this Group. - * Group.addAll('x', 10) will add 10 to the child.x value. - * - * @method Phaser.Group#addAll - * @param {string} property - The property to increment, for example 'body.velocity.x' or 'angle'. - * @param {number} amount - The amount to increment the property by. If child.x = 10 then addAll('x', 40) would make child.x = 50. - * @param {boolean} checkAlive - If true the property will only be changed if the child is alive. - * @param {boolean} checkVisible - If true the property will only be changed if the child is visible. - */ - addAll: function (property, amount, checkAlive, checkVisible) { + /** + * Adds the amount to the given property on all children in this Group. + * Group.addAll('x', 10) will add 10 to the child.x value. + * + * @method Phaser.Group#addAll + * @param {string} property - The property to increment, for example 'body.velocity.x' or 'angle'. + * @param {number} amount - The amount to increment the property by. If child.x = 10 then addAll('x', 40) would make child.x = 50. + * @param {boolean} checkAlive - If true the property will only be changed if the child is alive. + * @param {boolean} checkVisible - If true the property will only be changed if the child is visible. + */ + addAll: function (property, amount, checkAlive, checkVisible) { - this.setAll(property, amount, checkAlive, checkVisible, 1); + this.setAll(property, amount, checkAlive, checkVisible, 1); - }, + }, - /** - * Subtracts the amount from the given property on all children in this Group. - * Group.subAll('x', 10) will minus 10 from the child.x value. - * - * @method Phaser.Group#subAll - * @param {string} property - The property to decrement, for example 'body.velocity.x' or 'angle'. - * @param {number} amount - The amount to subtract from the property. If child.x = 50 then subAll('x', 40) would make child.x = 10. - * @param {boolean} checkAlive - If true the property will only be changed if the child is alive. - * @param {boolean} checkVisible - If true the property will only be changed if the child is visible. - */ - subAll: function (property, amount, checkAlive, checkVisible) { + /** + * Subtracts the amount from the given property on all children in this Group. + * Group.subAll('x', 10) will minus 10 from the child.x value. + * + * @method Phaser.Group#subAll + * @param {string} property - The property to decrement, for example 'body.velocity.x' or 'angle'. + * @param {number} amount - The amount to subtract from the property. If child.x = 50 then subAll('x', 40) would make child.x = 10. + * @param {boolean} checkAlive - If true the property will only be changed if the child is alive. + * @param {boolean} checkVisible - If true the property will only be changed if the child is visible. + */ + subAll: function (property, amount, checkAlive, checkVisible) { - this.setAll(property, amount, checkAlive, checkVisible, 2); + this.setAll(property, amount, checkAlive, checkVisible, 2); - }, + }, - /** - * Multiplies the given property by the amount on all children in this Group. - * Group.multiplyAll('x', 2) will x2 the child.x value. - * - * @method Phaser.Group#multiplyAll - * @param {string} property - The property to multiply, for example 'body.velocity.x' or 'angle'. - * @param {number} amount - The amount to multiply the property by. If child.x = 10 then multiplyAll('x', 2) would make child.x = 20. - * @param {boolean} checkAlive - If true the property will only be changed if the child is alive. - * @param {boolean} checkVisible - If true the property will only be changed if the child is visible. - */ - multiplyAll: function (property, amount, checkAlive, checkVisible) { + /** + * Multiplies the given property by the amount on all children in this Group. + * Group.multiplyAll('x', 2) will x2 the child.x value. + * + * @method Phaser.Group#multiplyAll + * @param {string} property - The property to multiply, for example 'body.velocity.x' or 'angle'. + * @param {number} amount - The amount to multiply the property by. If child.x = 10 then multiplyAll('x', 2) would make child.x = 20. + * @param {boolean} checkAlive - If true the property will only be changed if the child is alive. + * @param {boolean} checkVisible - If true the property will only be changed if the child is visible. + */ + multiplyAll: function (property, amount, checkAlive, checkVisible) { - this.setAll(property, amount, checkAlive, checkVisible, 3); + this.setAll(property, amount, checkAlive, checkVisible, 3); - }, + }, - /** - * Divides the given property by the amount on all children in this Group. - * Group.divideAll('x', 2) will half the child.x value. - * - * @method Phaser.Group#divideAll - * @param {string} property - The property to divide, for example 'body.velocity.x' or 'angle'. - * @param {number} amount - The amount to divide the property by. If child.x = 100 then divideAll('x', 2) would make child.x = 50. - * @param {boolean} checkAlive - If true the property will only be changed if the child is alive. - * @param {boolean} checkVisible - If true the property will only be changed if the child is visible. - */ - divideAll: function (property, amount, checkAlive, checkVisible) { + /** + * Divides the given property by the amount on all children in this Group. + * Group.divideAll('x', 2) will half the child.x value. + * + * @method Phaser.Group#divideAll + * @param {string} property - The property to divide, for example 'body.velocity.x' or 'angle'. + * @param {number} amount - The amount to divide the property by. If child.x = 100 then divideAll('x', 2) would make child.x = 50. + * @param {boolean} checkAlive - If true the property will only be changed if the child is alive. + * @param {boolean} checkVisible - If true the property will only be changed if the child is visible. + */ + divideAll: function (property, amount, checkAlive, checkVisible) { - this.setAll(property, amount, checkAlive, checkVisible, 4); + this.setAll(property, amount, checkAlive, checkVisible, 4); - }, + }, - /** + /** * Calls a function on all of the children that have exists=true in this Group. * After the existsValue parameter you can add as many parameters as you like, which will all be passed to the child callback. * @@ -12183,30 +12521,30 @@ Phaser.Group.prototype = { * @param {boolean} existsValue - Only children with exists=existsValue will be called. * @param {...*} parameter - Additional parameters that will be passed to the callback. */ - callAllExists: function (callback, existsValue) { + callAllExists: function (callback, existsValue) { - var args = Array.prototype.splice.call(arguments, 2); + var args = Array.prototype.splice.call(arguments, 2); - if (this._container.children.length > 0 && this._container.first._iNext) - { - var currentNode = this._container.first._iNext; - - do - { - if (currentNode.exists == existsValue && currentNode[callback]) - { - currentNode[callback].apply(currentNode, args); - } + if (this._container.children.length > 0 && this._container.first._iNext) + { + var currentNode = this._container.first._iNext; + + do + { + if (currentNode.exists == existsValue && currentNode[callback]) + { + currentNode[callback].apply(currentNode, args); + } - currentNode = currentNode._iNext; - } - while (currentNode != this._container.last._iNext) + currentNode = currentNode._iNext; + } + while (currentNode != this._container.last._iNext) - } + } - }, + }, - /** + /** * Calls a function on all of the children that have exists=true in this Group. * * @method Phaser.Group#callbackFromArray @@ -12215,51 +12553,51 @@ Phaser.Group.prototype = { * @param {number} length - The size of the array (pre-calculated in callAll). * @protected */ - callbackFromArray: function (child, callback, length) { + callbackFromArray: function (child, callback, length) { - // Kinda looks like a Christmas tree + // Kinda looks like a Christmas tree - if (length == 1) - { - if (child[callback[0]]) - { - return child[callback[0]]; - } - } - else if (length == 2) - { - if (child[callback[0]][callback[1]]) - { - return child[callback[0]][callback[1]]; - } - } - else if (length == 3) - { - if (child[callback[0]][callback[1]][callback[2]]) - { - return child[callback[0]][callback[1]][callback[2]]; - } - } - else if (length == 4) - { - if (child[callback[0]][callback[1]][callback[2]][callback[3]]) - { - return child[callback[0]][callback[1]][callback[2]][callback[3]]; - } - } - else - { - if (child[callback]) - { - return child[callback]; - } - } + if (length == 1) + { + if (child[callback[0]]) + { + return child[callback[0]]; + } + } + else if (length == 2) + { + if (child[callback[0]][callback[1]]) + { + return child[callback[0]][callback[1]]; + } + } + else if (length == 3) + { + if (child[callback[0]][callback[1]][callback[2]]) + { + return child[callback[0]][callback[1]][callback[2]]; + } + } + else if (length == 4) + { + if (child[callback[0]][callback[1]][callback[2]][callback[3]]) + { + return child[callback[0]][callback[1]][callback[2]][callback[3]]; + } + } + else + { + if (child[callback]) + { + return child[callback]; + } + } - return false; + return false; - }, + }, - /** + /** * 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 and context you can add as many extra parameters as you like, which will all be passed to the child. * @@ -12268,341 +12606,342 @@ Phaser.Group.prototype = { * @param {string} [context=''] - A string containing the context under which the method will be executed. Leave to '' to default to the child. * @param {...*} parameter - Additional parameters that will be passed to the method. */ - callAll: function (method, context) { + callAll: function (method, context) { - if (typeof method === 'undefined') - { - return; - } + if (typeof method === 'undefined') + { + return; + } - // Extract the method into an array - method = method.split('.'); + // Extract the method into an array + method = method.split('.'); - var methodLength = method.length; + var methodLength = method.length; - if (typeof context === 'undefined') - { - context = null; - } - else - { - // Extract the context into an array - if (typeof context === 'string') - { - context = context.split('.'); - var contextLength = context.length; - } - } + if (typeof context === 'undefined') + { + context = null; + } + else + { + // Extract the context into an array + if (typeof context === 'string') + { + context = context.split('.'); + var contextLength = context.length; + } + } - var args = Array.prototype.splice.call(arguments, 2); - var callback = null; + var args = Array.prototype.splice.call(arguments, 2); + var callback = null; + var callbackContext = null; - if (this._container.children.length > 0 && this._container.first._iNext) - { - var child = this._container.first._iNext; - - do - { - callback = this.callbackFromArray(child, method, methodLength); + if (this._container.children.length > 0 && this._container.first._iNext) + { + var child = this._container.first._iNext; + + do + { + callback = this.callbackFromArray(child, method, methodLength); - if (context && callback) - { - callbackContext = this.callbackFromArray(child, context, contextLength); - - if (callback) - { - callback.apply(callbackContext, args); - } - } - else if (callback) - { - callback.apply(child, args); - } + if (context && callback) + { + callbackContext = this.callbackFromArray(child, context, contextLength); + + if (callback) + { + callback.apply(callbackContext, args); + } + } + else if (callback) + { + callback.apply(child, args); + } - child = child._iNext; - } - while (child != this._container.last._iNext) + child = child._iNext; + } + while (child != this._container.last._iNext) - } + } - }, + }, - /** - * Allows you to call your own function on each member of this Group. You must pass the callback and context in which it will run. - * After the checkExists parameter you can add as many parameters as you like, which will all be passed to the callback along with the child. - * For example: Group.forEach(awardBonusGold, this, true, 100, 500) - * - * @method Phaser.Group#forEach - * @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter. + /** + * Allows you to call your own function on each member of this Group. You must pass the callback and context in which it will run. + * After the checkExists parameter you can add as many parameters as you like, which will all be passed to the callback along with the child. + * For example: Group.forEach(awardBonusGold, this, true, 100, 500) + * + * @method Phaser.Group#forEach + * @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'). * @param {boolean} checkExists - If set only children with exists=true will be passed to the callback, otherwise all children will be passed. - */ - forEach: function (callback, callbackContext, checkExists) { + */ + forEach: function (callback, callbackContext, checkExists) { - if (typeof checkExists === 'undefined') - { - checkExists = false; - } + if (typeof checkExists === 'undefined') + { + checkExists = false; + } - var args = Array.prototype.splice.call(arguments, 3); - args.unshift(null); + var args = Array.prototype.splice.call(arguments, 3); + args.unshift(null); - if (this._container.children.length > 0 && this._container.first._iNext) - { - var currentNode = this._container.first._iNext; - - do - { - if (checkExists == false || (checkExists && currentNode.exists)) - { - args[0] = currentNode; - callback.apply(callbackContext, args); - } + if (this._container.children.length > 0 && this._container.first._iNext) + { + var currentNode = this._container.first._iNext; + + do + { + if (checkExists === false || (checkExists && currentNode.exists)) + { + args[0] = currentNode; + callback.apply(callbackContext, args); + } - currentNode = currentNode._iNext; - } - while (currentNode != this._container.last._iNext); + currentNode = currentNode._iNext; + } + while (currentNode != this._container.last._iNext); - } + } - }, + }, - /** - * 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. + /** + * 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) { + */ + forEachExists: function (callback, callbackContext) { - var args = Array.prototype.splice.call(arguments, 2); - args.unshift(null); + var args = Array.prototype.splice.call(arguments, 2); + args.unshift(null); - this.iterate('exists', true, Phaser.Group.RETURN_TOTAL, callback, callbackContext, args); + 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. - * 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. + /** + * 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'). - */ - forEachAlive: function (callback, callbackContext) { + */ + forEachAlive: function (callback, callbackContext) { - var args = Array.prototype.splice.call(arguments, 2); - args.unshift(null); + var args = Array.prototype.splice.call(arguments, 2); + args.unshift(null); - this.iterate('alive', true, Phaser.Group.RETURN_TOTAL, callback, callbackContext, args); + this.iterate('alive', true, Phaser.Group.RETURN_TOTAL, callback, callbackContext, args); - }, + }, - /** - * Allows you to call your own function on each dead member of this Group (where alive=false). 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.forEachDead(bringToLife, this) - * - * @method Phaser.Group#forEachDead - * @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter. + /** + * Allows you to call your own function on each dead member of this Group (where alive=false). 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.forEachDead(bringToLife, this) + * + * @method Phaser.Group#forEachDead + * @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'). - */ - forEachDead: function (callback, callbackContext) { + */ + forEachDead: function (callback, callbackContext) { - var args = Array.prototype.splice.call(arguments, 2); - args.unshift(null); + var args = Array.prototype.splice.call(arguments, 2); + args.unshift(null); - this.iterate('alive', false, Phaser.Group.RETURN_TOTAL, callback, callbackContext, args); + 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) { + /** + * 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; } + if (typeof index === 'undefined') { index = 'y'; } + if (typeof order === 'undefined') { order = Phaser.Group.SORT_ASCENDING; } - var swapped; - var temp; + var swapped; + var temp; - do { + do { - swapped = false; + 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); + 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. + /** + * 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) { + */ + iterate: function (key, value, returnType, callback, callbackContext, args) { - if (returnType == Phaser.Group.RETURN_TOTAL && this._container.children.length == 0) - { - return -1; - } + if (returnType == Phaser.Group.RETURN_TOTAL && this._container.children.length === 0) + { + return -1; + } - if (typeof callback === 'undefined') - { - callback = false; - } + if (typeof callback === 'undefined') + { + callback = false; + } - var total = 0; + var total = 0; - if (this._container.children.length > 0 && this._container.first._iNext) - { - var currentNode = this._container.first._iNext; - - do - { - if (currentNode[key] === value) - { - total++; + if (this._container.children.length > 0 && this._container.first._iNext) + { + var currentNode = this._container.first._iNext; + + do + { + if (currentNode[key] === value) + { + total++; - if (callback) - { - args[0] = currentNode; - callback.apply(callbackContext, args); - } + if (callback) + { + args[0] = currentNode; + callback.apply(callbackContext, args); + } - if (returnType == Phaser.Group.RETURN_CHILD) - { - return currentNode; - } - } + if (returnType == Phaser.Group.RETURN_CHILD) + { + return currentNode; + } + } - currentNode = currentNode._iNext; - } - while (currentNode != this._container.last._iNext); - } + 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; - } + if (returnType == Phaser.Group.RETURN_TOTAL) + { + return total; + } + else if (returnType == Phaser.Group.RETURN_CHILD) + { + return null; + } - }, + }, - /** + /** * Call this function to retrieve the first object with exists == (the given state) in the Group. * * @method Phaser.Group#getFirstExists * @param {boolean} state - True or false. * @return {Any} The first child, or null if none found. */ - getFirstExists: function (state) { + getFirstExists: function (state) { - if (typeof state !== 'boolean') - { - state = true; - } + if (typeof state !== 'boolean') + { + state = true; + } - return this.iterate('exists', state, Phaser.Group.RETURN_CHILD); + return this.iterate('exists', state, Phaser.Group.RETURN_CHILD); - }, + }, - /** - * Call this function to retrieve the first object with alive == true in the group. + /** + * Call this function to retrieve the first object with alive === true in the group. * This is handy for checking if everything has been wiped out, or choosing a squad leader, etc. * * @method Phaser.Group#getFirstAlive * @return {Any} The first alive child, or null if none found. */ - getFirstAlive: function () { + getFirstAlive: function () { - return this.iterate('alive', true, Phaser.Group.RETURN_CHILD); + return this.iterate('alive', true, Phaser.Group.RETURN_CHILD); - }, + }, - /** - * Call this function to retrieve the first object with alive == false in the group. + /** + * Call this function to retrieve the first object with alive === false in the group. * This is handy for checking if everything has been wiped out, or choosing a squad leader, etc. * * @method Phaser.Group#getFirstDead * @return {Any} The first dead child, or null if none found. */ - getFirstDead: function () { + getFirstDead: function () { - return this.iterate('alive', false, Phaser.Group.RETURN_CHILD); + return this.iterate('alive', false, Phaser.Group.RETURN_CHILD); - }, + }, - /** + /** * Call this function to find out how many members of the group are alive. * * @method Phaser.Group#countLiving * @return {number} The number of children flagged as alive. Returns -1 if Group is empty. */ - countLiving: function () { + countLiving: function () { - return this.iterate('alive', true, Phaser.Group.RETURN_TOTAL); + return this.iterate('alive', true, Phaser.Group.RETURN_TOTAL); - }, + }, - /** + /** * Call this function to find out how many members of the group are dead. * * @method Phaser.Group#countDead * @return {number} The number of children flagged as dead. Returns -1 if Group is empty. */ - countDead: function () { + countDead: function () { - return this.iterate('alive', false, Phaser.Group.RETURN_TOTAL); + return this.iterate('alive', false, Phaser.Group.RETURN_TOTAL); - }, + }, - /** + /** * Returns a member at random from the group. * * @method Phaser.Group#getRandom @@ -12610,276 +12949,276 @@ Phaser.Group.prototype = { * @param {number} length - Optional restriction on the number of values you want to randomly select from. * @return {Any} A random child of this Group. */ - getRandom: function (startIndex, length) { + getRandom: function (startIndex, length) { - if (this._container.children.length == 0) - { - return null; - } + if (this._container.children.length === 0) + { + return null; + } - startIndex = startIndex || 0; - length = length || this._container.children.length; + startIndex = startIndex || 0; + length = length || this._container.children.length; return this.game.math.getRandom(this._container.children, startIndex, length); - }, + }, - /** - * Removes the given child from this Group and sets its group property to null. - * - * @method Phaser.Group#remove - * @param {Any} child - The child to remove. - */ - remove: function (child) { + /** + * Removes the given child from this Group and sets its group property to null. + * + * @method Phaser.Group#remove + * @param {Any} child - The child to remove. + */ + remove: function (child) { - if (child.events) - { - child.events.onRemovedFromGroup.dispatch(child, this); - } + if (child.events) + { + child.events.onRemovedFromGroup.dispatch(child, this); + } - this._container.removeChild(child); + this._container.removeChild(child); - if (this.cursor == child) - { - if (this._container._iNext) - { - this.cursor = this._container._iNext; - } - else - { - this.cursor = null; - } - } + if (this.cursor == child) + { + if (this._container._iNext) + { + this.cursor = this._container._iNext; + } + else + { + this.cursor = null; + } + } - child.group = null; + child.group = null; - }, + }, - /** - * Removes all children from this Group, setting all group properties to null. - * The Group container remains on the display list. - * - * @method Phaser.Group#removeAll - */ - removeAll: function () { + /** + * Removes all children from this Group, setting all group properties to null. + * The Group container remains on the display list. + * + * @method Phaser.Group#removeAll + */ + removeAll: function () { - if (this._container.children.length == 0) - { - return; - } + if (this._container.children.length === 0) + { + return; + } - do - { - if (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); + do + { + if (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; + this.cursor = null; - }, + }, - /** - * Removes all children from this Group whos index falls beteen the given startIndex and endIndex values. - * - * @method Phaser.Group#removeBetween - * @param {number} startIndex - The index to start removing children from. - * @param {number} endIndex - The index to stop removing children from. Must be higher than startIndex and less than the length of the Group. - */ - removeBetween: function (startIndex, endIndex) { + /** + * Removes all children from this Group whos index falls beteen the given startIndex and endIndex values. + * + * @method Phaser.Group#removeBetween + * @param {number} startIndex - The index to start removing children from. + * @param {number} endIndex - The index to stop removing children from. Must be higher than startIndex and less than the length of the Group. + */ + removeBetween: function (startIndex, endIndex) { - if (this._container.children.length == 0) - { - return; - } + if (this._container.children.length === 0) + { + return; + } - if (startIndex > endIndex || startIndex < 0 || endIndex > this._container.children.length) - { - return false; - } + if (startIndex > endIndex || startIndex < 0 || endIndex > this._container.children.length) + { + return false; + } - for (var i = startIndex; i < endIndex; i++) - { - var child = this._container.children[i]; - child.events.onRemovedFromGroup.dispatch(child, this); - this._container.removeChild(child); - - if (this.cursor == child) - { - if (this._container._iNext) - { - this.cursor = this._container._iNext; - } - else - { - this.cursor = null; - } - } - } + for (var i = startIndex; i < endIndex; i++) + { + var child = this._container.children[i]; + child.events.onRemovedFromGroup.dispatch(child, this); + this._container.removeChild(child); + + if (this.cursor == child) + { + if (this._container._iNext) + { + this.cursor = this._container._iNext; + } + else + { + this.cursor = null; + } + } + } - }, + }, - /** - * Destroys this Group. Removes all children, then removes the container from the display list and nulls references. - * - * @method Phaser.Group#destroy - */ - destroy: function () { + /** + * Destroys this Group. Removes all children, then removes the container from the display list and nulls references. + * + * @method Phaser.Group#destroy + */ + destroy: function () { - this.removeAll(); + this.removeAll(); - this._container.parent.removeChild(this._container); + this._container.parent.removeChild(this._container); - this._container = null; + this._container = null; - this.game = null; + this.game = null; - this.exists = false; + this.exists = false; - this.cursor = null; + this.cursor = null; - }, + }, - validate: function () { + 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; + 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; - } + 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; - } - } + // check previous + if (displayObject._iPrev !== prevObject) + { + console.log('check previous fail'); + return false; + } + } - // Set the next object - nextObject = displayObject._iNext; - prevObject = displayObject; + // Set the next object + nextObject = displayObject._iNext; + prevObject = displayObject; - displayObject = displayObject._iNext; + displayObject = displayObject._iNext; - count++; + count++; - } - while(displayObject != testObject) + } + while(displayObject != testObject) - return true; + return true; - }, + }, - /** - * Dumps out a list of Group children and their index positions to the browser console. Useful for group debugging. - * - * @method Phaser.Group#dump - * @param {boolean} [full=false] - If full the dump will include the entire display list, start from the Stage. Otherwise it will only include this container. - */ - dump: function (full) { + /** + * Dumps out a list of Group children and their index positions to the browser console. Useful for group debugging. + * + * @method Phaser.Group#dump + * @param {boolean} [full=false] - If full the dump will include the entire display list, start from the Stage. Otherwise it will only include this container. + */ + dump: function (full) { - if (typeof full == 'undefined') - { - full = false; - } + if (typeof full == 'undefined') + { + full = false; + } - var spacing = 20; - var output = "\n" + Phaser.Utils.pad('Node', spacing) + "|" + Phaser.Utils.pad('Next', spacing) + "|" + Phaser.Utils.pad('Previous', spacing) + "|" + Phaser.Utils.pad('First', spacing) + "|" + Phaser.Utils.pad('Last', spacing); + var spacing = 20; + var output = "\n" + Phaser.Utils.pad('Node', spacing) + "|" + Phaser.Utils.pad('Next', spacing) + "|" + Phaser.Utils.pad('Previous', spacing) + "|" + Phaser.Utils.pad('First', spacing) + "|" + Phaser.Utils.pad('Last', spacing); - console.log(output); + console.log(output); - var output = Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing); - console.log(output); + var output = Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing); + console.log(output); - if (full) - { - var testObject = this.game.stage._stage.last._iNext; - var displayObject = this.game.stage._stage; - } - else - { - var testObject = this._container.last._iNext; - var displayObject = this._container; - } - - do - { - var name = displayObject.name || '*'; + if (full) + { + var testObject = this.game.stage._stage.last._iNext; + var displayObject = this.game.stage._stage; + } + else + { + var testObject = this._container.last._iNext; + var displayObject = this._container; + } + + do + { + var name = displayObject.name || '*'; - if (this.cursor == displayObject) - { - var name = '> ' + name; - } + if (this.cursor == displayObject) + { + var name = '> ' + name; + } - var nameNext = '-'; - var namePrev = '-'; - var nameFirst = '-'; - var nameLast = '-'; + var nameNext = '-'; + var namePrev = '-'; + var nameFirst = '-'; + var nameLast = '-'; - if (displayObject._iNext) - { - nameNext = displayObject._iNext.name; - } + if (displayObject._iNext) + { + nameNext = displayObject._iNext.name; + } - if (displayObject._iPrev) - { - namePrev = displayObject._iPrev.name; - } + if (displayObject._iPrev) + { + namePrev = displayObject._iPrev.name; + } - if (displayObject.first) - { - nameFirst = displayObject.first.name; - } + if (displayObject.first) + { + nameFirst = displayObject.first.name; + } - if (displayObject.last) - { - nameLast = displayObject.last.name; - } + if (displayObject.last) + { + nameLast = displayObject.last.name; + } - if (typeof nameNext === 'undefined') - { - nameNext = '-'; - } + if (typeof nameNext === 'undefined') + { + nameNext = '-'; + } - if (typeof namePrev === 'undefined') - { - namePrev = '-'; - } + if (typeof namePrev === 'undefined') + { + namePrev = '-'; + } - if (typeof nameFirst === 'undefined') - { - nameFirst = '-'; - } + if (typeof nameFirst === 'undefined') + { + nameFirst = '-'; + } - if (typeof nameLast === 'undefined') - { - nameLast = '-'; - } + if (typeof nameLast === 'undefined') + { + nameLast = '-'; + } - var output = Phaser.Utils.pad(name, spacing) + "|" + Phaser.Utils.pad(nameNext, spacing) + "|" + Phaser.Utils.pad(namePrev, spacing) + "|" + Phaser.Utils.pad(nameFirst, spacing) + "|" + Phaser.Utils.pad(nameLast, spacing); - console.log(output); + var output = Phaser.Utils.pad(name, spacing) + "|" + Phaser.Utils.pad(nameNext, spacing) + "|" + Phaser.Utils.pad(namePrev, spacing) + "|" + Phaser.Utils.pad(nameFirst, spacing) + "|" + Phaser.Utils.pad(nameLast, spacing); + console.log(output); - displayObject = displayObject._iNext; + displayObject = displayObject._iNext; - } - while(displayObject != testObject) + } + while(displayObject != testObject) - } + } }; @@ -12891,7 +13230,7 @@ Phaser.Group.prototype = { Object.defineProperty(Phaser.Group.prototype, "total", { get: function () { - return this.iterate('exists', true, Phaser.Group.RETURN_TOTAL); + return this.iterate('exists', true, Phaser.Group.RETURN_TOTAL); // return this._container.children.length; } @@ -12905,7 +13244,7 @@ Object.defineProperty(Phaser.Group.prototype, "total", { Object.defineProperty(Phaser.Group.prototype, "length", { get: function () { - return this.iterate('exists', true, Phaser.Group.RETURN_TOTAL); + return this.iterate('exists', true, Phaser.Group.RETURN_TOTAL); // return this._container.children.length; } @@ -13038,7 +13377,7 @@ Phaser.World = function (game) { /** * @property {Phaser.Point} scale - Replaces the PIXI.Point with a slightly more flexible one. - */ + */ this.scale = new Phaser.Point(1, 1); /** @@ -13046,20 +13385,20 @@ Phaser.World = function (game) { * By default we set the Bounds to be from 0,0 to Game.width,Game.height. I.e. it will match the size given to the game constructor with 0,0 representing the top-left of the display. * However 0,0 is actually the center of the world, and if you rotate or scale the world all of that will happen from 0,0. * So if you want to make a game in which the world itself will rotate you should adjust the bounds so that 0,0 is the center point, i.e. set them to -1000,-1000,2000,2000 for a 2000x2000 sized world centered around 0,0. - * @property {Phaser.Rectangle} bounds - Bound of this world that objects can not escape from. - */ - this.bounds = new Phaser.Rectangle(0, 0, game.width, game.height); + * @property {Phaser.Rectangle} bounds - Bound of this world that objects can not escape from. + */ + this.bounds = new Phaser.Rectangle(0, 0, game.width, game.height); /** - * @property {Phaser.Camera} camera - Camera instance. - */ - this.camera = null; + * @property {Phaser.Camera} camera - Camera instance. + */ + this.camera = null; /** - * @property {number} currentRenderOrderID - Reset each frame, keeps a count of the total number of objects updated. - */ - this.currentRenderOrderID = 0; - + * @property {number} currentRenderOrderID - Reset each frame, keeps a count of the total number of objects updated. + */ + this.currentRenderOrderID = 0; + }; Phaser.World.prototype = Object.create(Phaser.Group.prototype); @@ -13088,28 +13427,39 @@ Phaser.World.prototype.boot = function () { */ Phaser.World.prototype.update = function () { - this.currentRenderOrderID = 0; + this.currentRenderOrderID = 0; + + if (this.game.stage._stage.first._iNext) + { + var currentNode = this.game.stage._stage.first._iNext; + var skipChildren; + + do + { + skipChildren = false; - if (this.game.stage._stage.first._iNext) - { - var currentNode = this.game.stage._stage.first._iNext; - - do - { - if (currentNode['preUpdate']) - { - currentNode.preUpdate(); - } + if (currentNode['preUpdate']) + { + skipChildren = (currentNode.preUpdate() === false); + } - if (currentNode['update']) - { - currentNode.update(); - } - - currentNode = currentNode._iNext; - } - while (currentNode != this.game.stage._stage.last._iNext) - } + if (currentNode['update']) + { + skipChildren = (currentNode.update() === false) || skipChildren; + } + + if (skipChildren) + { + currentNode = currentNode.last._iNext; + } + else + { + currentNode = currentNode._iNext; + } + + } + while (currentNode != this.game.stage._stage.last._iNext) + } } @@ -13125,7 +13475,7 @@ Phaser.World.prototype.postUpdate = function () { { var currentNode = this.game.stage._stage.first._iNext; - do + do { if (currentNode['postUpdate']) { @@ -13318,380 +13668,380 @@ Object.defineProperty(Phaser.World.prototype, "visible", { */ Phaser.Game = function (width, height, renderer, parent, state, transparent, antialias) { - width = width || 800; - height = height || 600; - renderer = renderer || Phaser.AUTO; - parent = parent || ''; - state = state || null; + width = width || 800; + height = height || 600; + renderer = renderer || Phaser.AUTO; + parent = parent || ''; + state = state || null; - if (typeof transparent == 'undefined') { transparent = false; } - if (typeof antialias == 'undefined') { antialias = true; } + if (typeof transparent == 'undefined') { transparent = false; } + if (typeof antialias == 'undefined') { antialias = true; } - /** - * @property {number} id - Phaser Game ID (for when Pixi supports multiple instances). - */ - this.id = Phaser.GAMES.push(this) - 1; + /** + * @property {number} id - Phaser Game ID (for when Pixi supports multiple instances). + */ + this.id = Phaser.GAMES.push(this) - 1; - /** - * @property {HTMLElement} parent - The Games DOM parent. - */ - this.parent = parent; + /** + * @property {HTMLElement} parent - The Games DOM parent. + */ + this.parent = parent; - // Do some more intelligent size parsing here, so they can set "100%" for example, maybe pass the scale mode in here too? + // Do some more intelligent size parsing here, so they can set "100%" for example, maybe pass the scale mode in here too? - /** - * @property {number} width - The Game width (in pixels). - */ - this.width = width; + /** + * @property {number} width - The Game width (in pixels). + */ + this.width = width; - /** - * @property {number} height - The Game height (in pixels). - */ - this.height = height; + /** + * @property {number} height - The Game height (in pixels). + */ + this.height = height; - /** - * @property {boolean} transparent - Use a transparent canvas background or not. - */ - this.transparent = transparent; + /** + * @property {boolean} transparent - Use a transparent canvas background or not. + */ + this.transparent = transparent; - /** - * @property {boolean} antialias - Anti-alias graphics (in WebGL this helps with edges, in Canvas2D it retains pixel-art quality). - */ - this.antialias = antialias; + /** + * @property {boolean} antialias - Anti-alias graphics (in WebGL this helps with edges, in Canvas2D it retains pixel-art quality). + */ + this.antialias = antialias; - /** - * @property {number} renderer - The Pixi Renderer - * @default - */ - this.renderer = null; + /** + * @property {number} renderer - The Pixi Renderer + * @default + */ + this.renderer = null; - /** - * @property {number} state - The StateManager. - */ - this.state = new Phaser.StateManager(this, state); + /** + * @property {number} state - The StateManager. + */ + this.state = new Phaser.StateManager(this, state); - /** - * @property {boolean} _paused - Is game paused? - * @private - * @default - */ - this._paused = false; + /** + * @property {boolean} _paused - Is game paused? + * @private + * @default + */ + this._paused = false; - /** - * @property {number} renderType - The Renderer this Phaser.Game will use. Either Phaser.RENDERER_AUTO, Phaser.RENDERER_CANVAS or Phaser.RENDERER_WEBGL. - */ - this.renderType = renderer; + /** + * @property {number} renderType - The Renderer this Phaser.Game will use. Either Phaser.RENDERER_AUTO, Phaser.RENDERER_CANVAS or Phaser.RENDERER_WEBGL. + */ + this.renderType = renderer; - /** - * @property {boolean} _loadComplete - Whether load complete loading or not. - * @private - * @default - */ - this._loadComplete = false; + /** + * @property {boolean} _loadComplete - Whether load complete loading or not. + * @private + * @default + */ + this._loadComplete = false; - /** - * @property {boolean} isBooted - Whether the game engine is booted, aka available. - * @default - */ - this.isBooted = false; + /** + * @property {boolean} isBooted - Whether the game engine is booted, aka available. + * @default + */ + this.isBooted = false; - /** - * @property {boolean} id -Is game running or paused? - * @default - */ - this.isRunning = false; + /** + * @property {boolean} id -Is game running or paused? + * @default + */ + this.isRunning = false; - /** - * @property {Phaser.RequestAnimationFrame} raf - Automatically handles the core game loop via requestAnimationFrame or setTimeout - * @default - */ - this.raf = null; + /** + * @property {Phaser.RequestAnimationFrame} raf - Automatically handles the core game loop via requestAnimationFrame or setTimeout + * @default + */ + this.raf = null; - /** - * @property {Phaser.GameObjectFactory} add - Reference to the GameObject Factory. - * @default - */ + /** + * @property {Phaser.GameObjectFactory} add - Reference to the GameObject Factory. + * @default + */ this.add = null; /** - * @property {Phaser.Cache} cache - Reference to the assets cache. - * @default - */ + * @property {Phaser.Cache} cache - Reference to the assets cache. + * @default + */ this.cache = null; /** - * @property {Phaser.Input} input - Reference to the input manager - * @default - */ + * @property {Phaser.Input} input - Reference to the input manager + * @default + */ this.input = null; /** - * @property {Phaser.Loader} load - Reference to the assets loader. - * @default - */ + * @property {Phaser.Loader} load - Reference to the assets loader. + * @default + */ this.load = null; /** - * @property {Phaser.GameMath} math - Reference to the math helper. - * @default - */ + * @property {Phaser.Math} math - Reference to the math helper. + * @default + */ this.math = null; /** - * @property {Phaser.Net} net - Reference to the network class. - * @default - */ + * @property {Phaser.Net} net - Reference to the network class. + * @default + */ this.net = null; /** - * @property {Phaser.SoundManager} sound - Reference to the sound manager. - * @default - */ + * @property {Phaser.SoundManager} sound - Reference to the sound manager. + * @default + */ this.sound = null; /** - * @property {Phaser.Stage} stage - Reference to the stage. - * @default - */ + * @property {Phaser.Stage} stage - Reference to the stage. + * @default + */ this.stage = null; /** - * @property {Phaser.TimeManager} time - Reference to game clock. - * @default - */ + * @property {Phaser.TimeManager} time - Reference to game clock. + * @default + */ this.time = null; /** - * @property {Phaser.TweenManager} tweens - Reference to the tween manager. - * @default - */ + * @property {Phaser.TweenManager} tweens - Reference to the tween manager. + * @default + */ this.tweens = null; /** - * @property {Phaser.World} world - Reference to the world. - * @default - */ + * @property {Phaser.World} world - Reference to the world. + * @default + */ this.world = null; /** - * @property {Phaser.Physics.PhysicsManager} physics - Reference to the physics manager. - * @default - */ + * @property {Phaser.Physics.PhysicsManager} physics - Reference to the physics manager. + * @default + */ this.physics = null; /** - * @property {Phaser.RandomDataGenerator} rnd - Instance of repeatable random data generator helper. - * @default - */ + * @property {Phaser.RandomDataGenerator} rnd - Instance of repeatable random data generator helper. + * @default + */ this.rnd = null; /** - * @property {Phaser.Device} device - Contains device information and capabilities. - * @default - */ + * @property {Phaser.Device} device - Contains device information and capabilities. + * @default + */ this.device = null; /** - * @property {Phaser.Physics.PhysicsManager} camera - A handy reference to world.camera. - * @default - */ - this.camera = null; + * @property {Phaser.Physics.PhysicsManager} camera - A handy reference to world.camera. + * @default + */ + this.camera = null; - /** - * @property {HTMLCanvasElement} canvas - A handy reference to renderer.view. - * @default - */ - this.canvas = null; - - /** - * @property {Context} context - A handy reference to renderer.context (only set for CANVAS games) - * @default - */ - this.context = null; + /** + * @property {HTMLCanvasElement} canvas - A handy reference to renderer.view. + * @default + */ + this.canvas = null; /** - * @property {Phaser.Utils.Debug} debug - A set of useful debug utilitie. - * @default - */ - this.debug = null; + * @property {Context} context - A handy reference to renderer.context (only set for CANVAS games) + * @default + */ + this.context = null; - /** - * @property {Phaser.Particles} particles - The Particle Manager. - * @default - */ - this.particles = null; + /** + * @property {Phaser.Utils.Debug} debug - A set of useful debug utilitie. + * @default + */ + this.debug = null; - var _this = this; + /** + * @property {Phaser.Particles} particles - The Particle Manager. + * @default + */ + this.particles = null; + + var _this = this; this._onBoot = function () { return _this.boot(); } - if (document.readyState === 'complete' || document.readyState === 'interactive') - { - window.setTimeout(this._onBoot, 0); - } - else - { - document.addEventListener('DOMContentLoaded', this._onBoot, false); - window.addEventListener('load', this._onBoot, false); - } + if (document.readyState === 'complete' || document.readyState === 'interactive') + { + window.setTimeout(this._onBoot, 0); + } + else + { + document.addEventListener('DOMContentLoaded', this._onBoot, false); + window.addEventListener('load', this._onBoot, false); + } - return this; + return this; }; Phaser.Game.prototype = { - /** - * Initialize engine sub modules and start the game. - * - * @method Phaser.Game#boot - * @protected - */ - boot: function () { + /** + * Initialize engine sub modules and start the game. + * + * @method Phaser.Game#boot + * @protected + */ + boot: function () { - if (this.isBooted) - { - return; - } + if (this.isBooted) + { + return; + } - if (!document.body) - { - window.setTimeout(this._onBoot, 20); - } - else - { - document.removeEventListener('DOMContentLoaded', this._onBoot); - window.removeEventListener('load', this._onBoot); + if (!document.body) + { + window.setTimeout(this._onBoot, 20); + } + else + { + document.removeEventListener('DOMContentLoaded', this._onBoot); + window.removeEventListener('load', this._onBoot); - this.onPause = new Phaser.Signal; - this.onResume = new Phaser.Signal; + this.onPause = new Phaser.Signal(); + this.onResume = new Phaser.Signal(); - this.isBooted = true; + this.isBooted = true; - this.device = new Phaser.Device(); - this.math = Phaser.Math; - this.rnd = new Phaser.RandomDataGenerator([(Date.now() * Math.random()).toString()]); + this.device = new Phaser.Device(); + this.math = Phaser.Math; + this.rnd = new Phaser.RandomDataGenerator([(Date.now() * Math.random()).toString()]); - this.stage = new Phaser.Stage(this, this.width, this.height); + this.stage = new Phaser.Stage(this, this.width, this.height); - this.setUpRenderer(); + this.setUpRenderer(); - this.world = new Phaser.World(this); - this.add = new Phaser.GameObjectFactory(this); - this.cache = new Phaser.Cache(this); - this.load = new Phaser.Loader(this); - this.time = new Phaser.Time(this); - this.tweens = new Phaser.TweenManager(this); - this.input = new Phaser.Input(this); - this.sound = new Phaser.SoundManager(this); - this.physics = new Phaser.Physics.Arcade(this); - this.particles = new Phaser.Particles(this); - this.plugins = new Phaser.PluginManager(this, this); - this.net = new Phaser.Net(this); - this.debug = new Phaser.Utils.Debug(this); + this.world = new Phaser.World(this); + this.add = new Phaser.GameObjectFactory(this); + this.cache = new Phaser.Cache(this); + this.load = new Phaser.Loader(this); + this.time = new Phaser.Time(this); + this.tweens = new Phaser.TweenManager(this); + this.input = new Phaser.Input(this); + this.sound = new Phaser.SoundManager(this); + this.physics = new Phaser.Physics.Arcade(this); + this.particles = new Phaser.Particles(this); + this.plugins = new Phaser.PluginManager(this, this); + this.net = new Phaser.Net(this); + this.debug = new Phaser.Utils.Debug(this); - this.stage.boot(); - this.world.boot(); - this.input.boot(); - this.sound.boot(); - this.state.boot(); + this.stage.boot(); + this.world.boot(); + this.input.boot(); + this.sound.boot(); + this.state.boot(); - this.load.onLoadComplete.add(this.loadComplete, this); + this.load.onLoadComplete.add(this.loadComplete, this); - this.showDebugHeader(); + this.showDebugHeader(); - this.isRunning = true; + this.isRunning = true; this._loadComplete = false; - this.raf = new Phaser.RequestAnimationFrame(this); - this.raf.start(); + this.raf = new Phaser.RequestAnimationFrame(this); + this.raf.start(); - } + } - }, + }, - /** + /** * Displays a Phaser version debug header in the console. * * @method Phaser.Game#showDebugHeader * @protected */ - showDebugHeader: function () { + showDebugHeader: function () { - var v = Phaser.DEV_VERSION; - var r = 'Canvas'; - var a = 'HTML Audio'; + var v = Phaser.DEV_VERSION; + var r = 'Canvas'; + var a = 'HTML Audio'; - if (this.renderType == Phaser.WEBGL) - { - r = 'WebGL'; - } + if (this.renderType == Phaser.WEBGL) + { + r = 'WebGL'; + } - if (this.device.webAudio) - { - a = 'WebAudio'; - } + if (this.device.webAudio) + { + a = 'WebAudio'; + } - if (this.device.chrome) - { - var args = [ - '%c %c %c Phaser v' + v + ' - Renderer: ' + r + ' - Audio: ' + a + ' %c %c ', - 'background: #00bff3', - 'background: #0072bc', - 'color: #ffffff; background: #003471', - 'background: #0072bc', - 'background: #00bff3' - ]; + if (this.device.chrome) + { + var args = [ + '%c %c %c Phaser v' + v + ' - Renderer: ' + r + ' - Audio: ' + a + ' %c %c ', + 'background: #00bff3', + 'background: #0072bc', + 'color: #ffffff; background: #003471', + 'background: #0072bc', + 'background: #00bff3' + ]; - console.log.apply(console, args); - } - else - { - console.log('Phaser v' + v + ' - Renderer: ' + r + ' - Audio: ' + a); - } + console.log.apply(console, args); + } + else + { + console.log('Phaser v' + v + ' - Renderer: ' + r + ' - Audio: ' + a); + } - }, + }, - /** - * Checks if the device is capable of using the requested renderer and sets it up or an alternative if not. - * - * @method Phaser.Game#setUpRenderer - * @protected - */ - setUpRenderer: function () { + /** + * Checks if the device is capable of using the requested renderer and sets it up or an alternative if not. + * + * @method Phaser.Game#setUpRenderer + * @protected + */ + setUpRenderer: function () { - if (this.renderType === Phaser.CANVAS || (this.renderType === Phaser.AUTO && this.device.webGL == false)) - { - if (this.device.canvas) - { - this.renderType = Phaser.CANVAS; - this.renderer = new PIXI.CanvasRenderer(this.width, this.height, this.stage.canvas, this.transparent); - Phaser.Canvas.setSmoothingEnabled(this.renderer.context, this.antialias); - this.canvas = this.renderer.view; - this.context = this.renderer.context; - } - else - { - throw new Error('Phaser.Game - cannot create Canvas or WebGL context, aborting.'); - } - } - else - { - // They requested WebGL, and their browser supports it - this.renderType = Phaser.WEBGL; - this.renderer = new PIXI.WebGLRenderer(this.width, this.height, this.stage.canvas, this.transparent, this.antialias); - this.canvas = this.renderer.view; - this.context = null; - } + if (this.renderType === Phaser.CANVAS || (this.renderType === Phaser.AUTO && this.device.webGL === false)) + { + if (this.device.canvas) + { + this.renderType = Phaser.CANVAS; + this.renderer = new PIXI.CanvasRenderer(this.width, this.height, this.stage.canvas, this.transparent); + Phaser.Canvas.setSmoothingEnabled(this.renderer.context, this.antialias); + this.canvas = this.renderer.view; + this.context = this.renderer.context; + } + else + { + throw new Error('Phaser.Game - cannot create Canvas or WebGL context, aborting.'); + } + } + else + { + // They requested WebGL, and their browser supports it + this.renderType = Phaser.WEBGL; + this.renderer = new PIXI.WebGLRenderer(this.width, this.height, this.stage.canvas, this.transparent, this.antialias); + this.canvas = this.renderer.view; + this.context = null; + } Phaser.Canvas.addToDOM(this.renderer.view, this.parent, true); Phaser.Canvas.setTouchAction(this.renderer.view); - }, + }, - /** + /** * Called when the load has finished, after preload was run. * * @method Phaser.Game#loadComplete @@ -13705,61 +14055,61 @@ Phaser.Game.prototype = { }, - /** + /** * The core game loop. * * @method Phaser.Game#update * @protected - * @param {number} time - The current time as provided by RequestAnimationFrame. + * @param {number} time - The current time as provided by RequestAnimationFrame. */ - update: function (time) { + update: function (time) { - this.time.update(time); + this.time.update(time); - if (this._paused) - { - this.renderer.render(this.stage._stage); - this.plugins.render(); - this.state.render(); - } - else - { - this.plugins.preUpdate(); - this.physics.preUpdate(); + if (this._paused) + { + this.renderer.render(this.stage._stage); + this.plugins.render(); + this.state.render(); + } + else + { + 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.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.world.postUpdate(); this.plugins.postUpdate(); - this.renderer.render(this.stage._stage); - this.plugins.render(); - this.state.render(); + this.renderer.render(this.stage._stage); + this.plugins.render(); + this.state.render(); - this.plugins.postRender(); - } + this.plugins.postRender(); + } - }, + }, - /** + /** * Nuke the entire game from orbit * * @method Phaser.Game#destroy */ destroy: function () { - this.raf.stop(); + this.raf.stop(); - this.input.destroy(); + this.input.destroy(); - this.state.destroy(); + this.state.destroy(); this.state = null; this.cache = null; @@ -13789,22 +14139,22 @@ Object.defineProperty(Phaser.Game.prototype, "paused", { set: function (value) { - if (value === true) - { - if (this._paused == false) - { - this._paused = true; - this.onPause.dispatch(this); - } - } - else - { - if (this._paused) - { - this._paused = false; - this.onResume.dispatch(this); - } - } + if (value === true) + { + if (this._paused === false) + { + this._paused = true; + this.onPause.dispatch(this); + } + } + else + { + if (this._paused) + { + this._paused = false; + this.onResume.dispatch(this); + } + } } @@ -13821,32 +14171,32 @@ Object.defineProperty(Phaser.Game.prototype, "paused", { */ /** -* Constructor for Phaser Input. +* Phaser.Input is the Input Manager for all types of Input across Phaser, including mouse, keyboard, touch and MSPointer. +* The Input manager is updated automatically by the core game loop. +* * @class Phaser.Input -* @classdesc A game specific Input manager that looks after the mouse, keyboard and touch objects. -* This is updated by the core game loop. * @constructor * @param {Phaser.Game} game - Current game instance. */ Phaser.Input = function (game) { - /** - * @property {Phaser.Game} game - A reference to the currently running game. - */ - this.game = game; + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ + this.game = game; - /** - * @property {Description} hitCanvas - Description. + /** + * @property {HTMLCanvasElement} hitCanvas - The canvas to which single pixels are drawn in order to perform pixel-perfect hit detection. * @default - */ + */ this.hitCanvas = null; - /** - * @property {Description} hitContext - Description. - * @default - */ + /** + * @property {CanvasRenderingContext2D} hitContext - The context of the pixel perfect hit canvas. + * @default + */ this.hitContext = null; - + }; /** @@ -13869,11 +14219,6 @@ Phaser.Input.MOUSE_TOUCH_COMBINE = 2; Phaser.Input.prototype = { - /** - * @property {Phaser.Game} game - */ - game: null, - /** * How often should the input pointers be checked for updates? * A value of 0 means every single frame (60fps), a value of 1 means every other frame (30fps) and so on. @@ -13883,31 +14228,28 @@ Phaser.Input.prototype = { pollRate: 0, /** - * @property {number} _pollCounter - Description. - * @private - * @default - */ + * @property {number} _pollCounter - Internal var holding the current poll counter. + * @private + * @default + */ _pollCounter: 0, /** - * A vector object representing the previous position of the Pointer. - * @property {Vec2} vector + * @property {Phaser.Point} _oldPosition - A point object representing the previous position of the Pointer. * @private * @default */ _oldPosition: null, /** - * X coordinate of the most recent Pointer event - * @property {number} _x + * @property {number} _x - x coordinate of the most recent Pointer event * @private * @default */ _x: 0, /** - * Y coordinate of the most recent Pointer event - * @property {number} _y + * @property {number} _y - Y coordinate of the most recent Pointer event * @private * @default */ @@ -13928,17 +14270,14 @@ Phaser.Input.prototype = { multiInputOverride: Phaser.Input.MOUSE_TOUCH_COMBINE, /** - * A vector object representing the current position of the Pointer. - * @property {Phaser.Point} position + * @property {Phaser.Point} position - A point object representing the current position of the Pointer. * @default */ position: null, /** - * A vector object representing the speed of the Pointer. Only really useful in single Pointer games, - * otherwise see the Pointer objects directly. + * A point object representing the speed of the Pointer. Only really useful in single Pointer games, otherwise see the Pointer objects directly. * @property {Phaser.Point} speed - * @default */ speed: null, @@ -13946,7 +14285,6 @@ Phaser.Input.prototype = { * A Circle object centered on the x/y screen coordinates of the Input. * Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything. * @property {Phaser.Circle} circle - * @default */ circle: null, @@ -13954,7 +14292,6 @@ Phaser.Input.prototype = { * The scale by which all input coordinates are multiplied, calculated by the StageScaleMode. * In an un-scaled game the values will be x: 1 and y: 1. * @property {Phaser.Point} scale - * @default */ scale: null, @@ -14083,7 +14420,7 @@ Phaser.Input.prototype = { /** * A Pointer object * @property {Phaser.Pointer} pointer9 - */ + */ pointer9: null, /** @@ -14169,40 +14506,40 @@ Phaser.Input.prototype = { */ interactiveItems: new Phaser.LinkedList(), - /** + /** * Starts the Input Manager running. * @method Phaser.Input#boot * @protected */ boot: function () { - this.mousePointer = new Phaser.Pointer(this.game, 0); - this.pointer1 = new Phaser.Pointer(this.game, 1); - this.pointer2 = new Phaser.Pointer(this.game, 2); + this.mousePointer = new Phaser.Pointer(this.game, 0); + this.pointer1 = new Phaser.Pointer(this.game, 1); + this.pointer2 = new Phaser.Pointer(this.game, 2); - this.mouse = new Phaser.Mouse(this.game); - this.keyboard = new Phaser.Keyboard(this.game); - this.touch = new Phaser.Touch(this.game); - this.mspointer = new Phaser.MSPointer(this.game); + this.mouse = new Phaser.Mouse(this.game); + this.keyboard = new Phaser.Keyboard(this.game); + this.touch = new Phaser.Touch(this.game); + this.mspointer = new Phaser.MSPointer(this.game); - this.onDown = new Phaser.Signal(); - this.onUp = new Phaser.Signal(); - this.onTap = new Phaser.Signal(); - this.onHold = new Phaser.Signal(); + this.onDown = new Phaser.Signal(); + this.onUp = new Phaser.Signal(); + this.onTap = new Phaser.Signal(); + this.onHold = new Phaser.Signal(); - this.scale = new Phaser.Point(1, 1); - this.speed = new Phaser.Point(); - this.position = new Phaser.Point(); - this._oldPosition = new Phaser.Point(); + this.scale = new Phaser.Point(1, 1); + this.speed = new Phaser.Point(); + this.position = new Phaser.Point(); + this._oldPosition = new Phaser.Point(); - this.circle = new Phaser.Circle(0, 0, 44); + this.circle = new Phaser.Circle(0, 0, 44); - this.activePointer = this.mousePointer; - this.currentPointers = 0; + this.activePointer = this.mousePointer; + this.currentPointers = 0; - this.hitCanvas = document.createElement('canvas'); - this.hitCanvas.width = 1; - this.hitCanvas.height = 1; + this.hitCanvas = document.createElement('canvas'); + this.hitCanvas.width = 1; + this.hitCanvas.height = 1; this.hitContext = this.hitCanvas.getContext('2d'); this.mouse.start(); @@ -14226,7 +14563,7 @@ Phaser.Input.prototype = { }, - /** + /** * Add a new Pointer object to the Input Manager. By default Input creates 3 pointer objects: mousePointer, pointer1 and pointer2. * If you need more then use this to create a new one, up to a maximum of 10. * @method Phaser.Input#addPointer @@ -14244,7 +14581,7 @@ Phaser.Input.prototype = { } } - if (next == 0) + if (next === 0) { console.warn("You can only have 10 Pointer objects"); return null; @@ -14257,7 +14594,7 @@ Phaser.Input.prototype = { }, - /** + /** * Updates the Input Manager. Called by the core Game loop. * @method Phaser.Input#update * @protected @@ -14291,14 +14628,14 @@ Phaser.Input.prototype = { this._pollCounter = 0; }, - /** + /** * Reset all of the Pointers and Input states * @method Phaser.Input#reset * @param {boolean} hard - A soft reset (hard = false) won't reset any Signals that might be bound. A hard reset will. */ reset: function (hard) { - if (this.game.isBooted == false) + if (this.game.isBooted === false) { return; } @@ -14319,7 +14656,7 @@ Phaser.Input.prototype = { this.currentPointers = 0; this.game.stage.canvas.style.cursor = "default"; - if (hard == true) + if (hard === true) { this.onDown.dispose(); this.onUp.dispose(); @@ -14350,7 +14687,7 @@ Phaser.Input.prototype = { }, - /** + /** * Find the first free Pointer object and start it, passing in the event data. This is called automatically by Phaser.Touch and Phaser.MSPointer. * @method Phaser.Input#startPointer * @param {Any} event - The event data from the Touch event. @@ -14363,11 +14700,11 @@ Phaser.Input.prototype = { return null; } - if (this.pointer1.active == false) + if (this.pointer1.active === false) { return this.pointer1.start(event); } - else if (this.pointer2.active == false) + else if (this.pointer2.active === false) { return this.pointer2.start(event); } @@ -14375,7 +14712,7 @@ Phaser.Input.prototype = { { for (var i = 3; i <= 10; i++) { - if (this['pointer' + i] && this['pointer' + i].active == false) + if (this['pointer' + i] && this['pointer' + i].active === false) { return this['pointer' + i].start(event); } @@ -14386,7 +14723,7 @@ Phaser.Input.prototype = { }, - /** + /** * Updates the matching Pointer object, passing in the event data. This is called automatically and should not normally need to be invoked. * @method Phaser.Input#updatePointer * @param {Any} event - The event data from the Touch event. @@ -14417,7 +14754,7 @@ Phaser.Input.prototype = { }, - /** + /** * Stops the matching Pointer object, passing in the event data. * @method Phaser.Input#stopPointer * @param {Any} event - The event data from the Touch event. @@ -14448,7 +14785,7 @@ Phaser.Input.prototype = { }, - /** + /** * Get the next Pointer object whos active property matches the given state * @method Phaser.Input#getPointer * @param {boolean} state - The state the Pointer should be in (false for inactive, true for active). @@ -14481,7 +14818,7 @@ Phaser.Input.prototype = { }, - /** + /** * Get the Pointer object whos identified property matches the given identifier value. * @method Phaser.Input#getPointerFromIdentifier * @param {number} identifier - The Pointer.identifier value to search for. @@ -14609,7 +14946,7 @@ Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", { Object.defineProperty(Phaser.Input.prototype, "worldX", { get: function () { - return this.game.camera.view.x + this.x; + return this.game.camera.view.x + this.x; } }); @@ -14622,7 +14959,7 @@ Object.defineProperty(Phaser.Input.prototype, "worldX", { Object.defineProperty(Phaser.Input.prototype, "worldY", { get: function () { - return this.game.camera.view.y + this.y; + return this.game.camera.view.y + this.y; } }); @@ -14642,87 +14979,87 @@ Object.defineProperty(Phaser.Input.prototype, "worldY", { */ Phaser.Key = function (game, keycode) { - /** - * @property {Phaser.Game} game - A reference to the currently running game. - */ - this.game = game; + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ + this.game = game; - /** - * @property {boolean} isDown - The "down" state of the key. - * @default - */ - this.isDown = false; + /** + * @property {boolean} isDown - The "down" state of the key. + * @default + */ + this.isDown = false; - /** - * @property {boolean} isUp - The "up" state of the key. - * @default - */ - this.isUp = false; + /** + * @property {boolean} isUp - The "up" state of the key. + * @default + */ + this.isUp = false; - /** - * @property {boolean} altKey - The down state of the ALT key, if pressed at the same time as this key. - * @default - */ - this.altKey = false; + /** + * @property {boolean} altKey - The down state of the ALT key, if pressed at the same time as this key. + * @default + */ + this.altKey = false; - /** - * @property {boolean} ctrlKey - The down state of the CTRL key, if pressed at the same time as this key. - * @default - */ - this.ctrlKey = false; + /** + * @property {boolean} ctrlKey - The down state of the CTRL key, if pressed at the same time as this key. + * @default + */ + this.ctrlKey = false; - /** - * @property {boolean} shiftKey - The down state of the SHIFT key, if pressed at the same time as this key. - * @default - */ - this.shiftKey = false; + /** + * @property {boolean} shiftKey - The down state of the SHIFT key, if pressed at the same time as this key. + * @default + */ + this.shiftKey = false; - /** - * @property {number} timeDown - The timestamp when the key was last pressed down. - * @default - */ - this.timeDown = 0; + /** + * @property {number} timeDown - The timestamp when the key was last pressed down. + * @default + */ + this.timeDown = 0; - /** - * If the key is down this value holds the duration of that key press and is constantly updated. - * If the key is up it holds the duration of the previous down session. - * @property {number} duration - The number of milliseconds this key has been held down for. - * @default - */ - this.duration = 0; + /** + * If the key is down this value holds the duration of that key press and is constantly updated. + * If the key is up it holds the duration of the previous down session. + * @property {number} duration - The number of milliseconds this key has been held down for. + * @default + */ + this.duration = 0; - /** - * @property {number} timeUp - The timestamp when the key was last released. - * @default - */ - this.timeUp = 0; + /** + * @property {number} timeUp - The timestamp when the key was last released. + * @default + */ + this.timeUp = 0; - /** - * @property {number} repeats - If a key is held down this holds down the number of times the key has 'repeated'. - * @default - */ - this.repeats = 0; + /** + * @property {number} repeats - If a key is held down this holds down the number of times the key has 'repeated'. + * @default + */ + this.repeats = 0; - /** - * @property {number} keyCode - The keycode of this key. - */ - this.keyCode = keycode; + /** + * @property {number} keyCode - The keycode of this key. + */ + this.keyCode = keycode; - /** - * @property {Phaser.Signal} onDown - This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again). - */ + /** + * @property {Phaser.Signal} onDown - This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again). + */ this.onDown = new Phaser.Signal(); - /** - * @property {Phaser.Signal} onUp - This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again). - */ + /** + * @property {Phaser.Signal} onUp - This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again). + */ this.onUp = new Phaser.Signal(); - + }; Phaser.Key.prototype = { - /** + /** * Called automatically by Phaser.Keyboard. * @method Phaser.Key#processKeyDown * @param {KeyboardEvent} event. @@ -14753,7 +15090,7 @@ Phaser.Key.prototype = { }, - /** + /** * Called automatically by Phaser.Keyboard. * @method Phaser.Key#processKeyUp * @param {KeyboardEvent} event. @@ -14769,8 +15106,8 @@ Phaser.Key.prototype = { }, - /** - * Returns the "just pressed" state of the Key. Just pressed is considered true if the key was pressed down within the duration given (default 250ms) + /** + * Returns the "just pressed" state of the Key. Just pressed is considered true if the key was pressed down within the duration given (default 250ms) * @method Phaser.Key#justPressed * @param {number} [duration=250] - The duration below which the key is considered as being just pressed. * @return {boolean} True if the key is just pressed otherwise false. @@ -14783,8 +15120,8 @@ Phaser.Key.prototype = { }, - /** - * Returns the "just released" state of the Key. Just released is considered as being true if the key was released within the duration given (default 250ms) + /** + * Returns the "just released" state of the Key. Just released is considered as being true if the key was released within the duration given (default 250ms) * @method Phaser.Key#justPressed * @param {number} [duration=250] - The duration below which the key is considered as being just released. * @return {boolean} True if the key is just released otherwise false. @@ -14793,7 +15130,7 @@ Phaser.Key.prototype = { if (typeof duration === "undefined") { duration = 250; } - return (this.isDown == false && (this.game.time.now - this.timeUp < duration)); + return (this.isDown === false && (this.game.time.now - this.timeUp < duration)); } @@ -14806,36 +15143,35 @@ Phaser.Key.prototype = { */ /** -* Phaser - Keyboard constructor. +* The Keyboard class handles looking after keyboard input for your game. It will recognise and respond to key presses and dispatch the required events. * * @class Phaser.Keyboard -* @classdesc A Keyboard object Description. * @constructor * @param {Phaser.Game} game - A reference to the currently running game. */ Phaser.Keyboard = function (game) { - /** - * @property {Phaser.Game} game - Local reference to game. - */ - this.game = game; - - /** - * @property {Description} _keys - Description. - * @private - */ + /** + * @property {Phaser.Game} game - Local reference to game. + */ + this.game = game; + + /** + * @property {object} _keys - The object the key values are stored in. + * @private + */ this._keys = {}; /** - * @property {Description} _hotkeys - Description. + * @property {object} _hotkeys - The object the hot keys are stored in. * @private */ this._hotkeys = {}; - /** - * @property {Description} _capture - Description. - * @private - */ + /** + * @property {object} _capture - The object the key capture values are stored in. + * @private + */ this._capture = {}; /** @@ -14873,7 +15209,7 @@ Phaser.Keyboard = function (game) { * @property {function} onUpCallback - This callback is invoked every time a key is released. */ this.onUpCallback = null; - + }; Phaser.Keyboard.prototype = { @@ -14935,10 +15271,10 @@ Phaser.Keyboard.prototype = { */ createCursorKeys: function () { - return { - up: this.addKey(Phaser.Keyboard.UP), - down: this.addKey(Phaser.Keyboard.DOWN), - left: this.addKey(Phaser.Keyboard.LEFT), + return { + up: this.addKey(Phaser.Keyboard.UP), + down: this.addKey(Phaser.Keyboard.DOWN), + left: this.addKey(Phaser.Keyboard.LEFT), right: this.addKey(Phaser.Keyboard.RIGHT) } @@ -14962,8 +15298,8 @@ Phaser.Keyboard.prototype = { return _this.processKeyUp(event); }; - document.body.addEventListener('keydown', this._onKeyDown, false); - document.body.addEventListener('keyup', this._onKeyUp, false); + window.addEventListener('keydown', this._onKeyDown, false); + window.addEventListener('keyup', this._onKeyUp, false); }, @@ -14974,12 +15310,12 @@ Phaser.Keyboard.prototype = { */ stop: function () { - document.body.removeEventListener('keydown', this._onKeyDown); - document.body.removeEventListener('keyup', this._onKeyUp); + window.removeEventListener('keydown', this._onKeyDown); + window.removeEventListener('keyup', this._onKeyUp); }, - /** + /** * By default when a key is pressed Phaser will not stop the event from propagating up to the browser. * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. * You can use addKeyCapture to consume the keyboard event for specific keys so it doesn't bubble up to the the browser. @@ -15002,9 +15338,9 @@ Phaser.Keyboard.prototype = { } }, - /** - * Removes an existing key capture. - * @method Phaser.Keyboard#removeKeyCapture + /** + * Removes an existing key capture. + * @method Phaser.Keyboard#removeKeyCapture * @param {number} keycode */ removeKeyCapture: function (keycode) { @@ -15013,9 +15349,9 @@ Phaser.Keyboard.prototype = { }, - /** - * Clear all set key captures. - * @method Phaser.Keyboard#clearCaptures + /** + * Clear all set key captures. + * @method Phaser.Keyboard#clearCaptures */ clearCaptures: function () { @@ -15023,12 +15359,12 @@ Phaser.Keyboard.prototype = { }, - /** - * Process the keydown event. - * @method Phaser.Keyboard#processKeyDown + /** + * Process the keydown event. + * @method Phaser.Keyboard#processKeyDown * @param {KeyboardEvent} event * @protected - */ + */ processKeyDown: function (event) { if (this.game.input.disabled || this.disabled) @@ -15079,9 +15415,9 @@ Phaser.Keyboard.prototype = { }, - /** - * Process the keyup event. - * @method Phaser.Keyboard#processKeyUp + /** + * Process the keyup event. + * @method Phaser.Keyboard#processKeyUp * @param {KeyboardEvent} event * @protected */ @@ -15125,9 +15461,9 @@ Phaser.Keyboard.prototype = { }, - /** - * Reset the "isDown" state of all keys. - * @method Phaser.Keyboard#reset + /** + * Reset the "isDown" state of all keys. + * @method Phaser.Keyboard#reset */ reset: function () { @@ -15191,7 +15527,7 @@ Phaser.Keyboard.prototype = { return this._keys[keycode].isDown; } - return false; + return false; } @@ -15303,93 +15639,90 @@ Phaser.Keyboard.NUM_LOCK = 144; */ /** -* Phaser - Mouse constructor. +* Phaser.Mouse is responsible for handling all aspects of mouse interaction with the browser. It captures and processes mouse events. * * @class Phaser.Mouse -* @classdesc The Mouse class * @constructor * @param {Phaser.Game} game - A reference to the currently running game. */ Phaser.Mouse = function (game) { - /** - * @property {Phaser.Game} game - Local reference to game. - */ - this.game = game; - - /** - * @property {Object} callbackContext - Description. - */ - this.callbackContext = this.game; - - /** - * @property {function} mouseDownCallback - Description. - * @default - */ - this.mouseDownCallback = null; - - /** - * @property {function} mouseMoveCallback - Description. - * @default - */ - this.mouseMoveCallback = null; - - /** - * @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; + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ + this.game = game; + + /** + * @property {Object} callbackContext - The context under which callbacks are called. + */ + this.callbackContext = this.game; /** - * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. - * @property {boolean} disabled + * @property {function} mouseDownCallback - A callback that can be fired when the mouse is pressed down. + */ + this.mouseDownCallback = null; + + /** + * @property {function} mouseMoveCallback - A callback that can be fired when the mouse is moved while pressed down. + */ + this.mouseMoveCallback = null; + + /** + * @property {function} mouseUpCallback - A callback that can be fired when the mouse is released from a pressed down state. + */ + this.mouseUpCallback = null; + + /** + * @property {boolean} capture - If true the DOM mouse events will have event.preventDefault applied to them, if false they will propogate fully. + */ + this.capture = true; + + /** + * @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; + + /** + * @property {boolean} disabled - You can disable all Input by setting disabled = true. While set all new input related events will be ignored. * @default */ this.disabled = false; /** - * If the mouse has been Pointer Locked successfully this will be set to true. - * @property {boolean} locked + * @property {boolean} locked - If the mouse has been Pointer Locked successfully this will be set to true. * @default */ this.locked = false; /** - * This event is dispatched when the browser enters or leaves pointer lock state. - * @property {Phaser.Signal} pointerLock + * @property {Phaser.Signal} pointerLock - This event is dispatched when the browser enters or leaves pointer lock state. * @default */ - this.pointerLock = new Phaser.Signal; + this.pointerLock = new Phaser.Signal(); /** - * The browser mouse event. - * @property {MouseEvent} event + * @property {MouseEvent} event - The browser mouse event. */ - this.event; + this.event = null; /** - * @property {function} _onMouseDown + * @property {function} _onMouseDown - Internal event handler reference. * @private */ - this._onMouseDown; + this._onMouseDown = null; /** - * @property {function} _onMouseMove + * @property {function} _onMouseMove - Internal event handler reference. * @private */ - this._onMouseMove; + this._onMouseMove = null; /** - * @property {function} _onMouseUp + * @property {function} _onMouseUp - Internal event handler reference. * @private */ - this._onMouseUp; + this._onMouseUp = null; }; @@ -15398,6 +15731,7 @@ Phaser.Mouse = function (game) { * @type {number} */ Phaser.Mouse.NO_BUTTON = -1; + /** * @constant * @type {number} @@ -15418,7 +15752,7 @@ Phaser.Mouse.RIGHT_BUTTON = 2; Phaser.Mouse.prototype = { - /** + /** * Starts the event listeners running. * @method Phaser.Mouse#start */ @@ -15426,7 +15760,7 @@ Phaser.Mouse.prototype = { var _this = this; - if (this.game.device.android && this.game.device.chrome == false) + if (this.game.device.android && this.game.device.chrome === false) { // Android stock browser fires mouse events even if you preventDefault on the touchStart, so ... return; @@ -15454,16 +15788,19 @@ Phaser.Mouse.prototype = { }, - /** - * The internal method that handles the mouse down event from the browser. - * @method Phaser.Mouse#onMouseDown - * @param {MouseEvent} event + /** + * The internal method that handles the mouse down event from the browser. + * @method Phaser.Mouse#onMouseDown + * @param {MouseEvent} event - The native event from the browser. This gets stored in Mouse.event. */ onMouseDown: function (event) { this.event = event; - event.preventDefault(); + if (this.capture) + { + event.preventDefault(); + } this.button = event.which; @@ -15483,16 +15820,19 @@ Phaser.Mouse.prototype = { }, - /** + /** * The internal method that handles the mouse move event from the browser. - * @method Phaser.Mouse#onMouseMove - * @param {MouseEvent} event + * @method Phaser.Mouse#onMouseMove + * @param {MouseEvent} event - The native event from the browser. This gets stored in Mouse.event. */ onMouseMove: function (event) { this.event = event; - event.preventDefault(); + if (this.capture) + { + event.preventDefault(); + } if (this.mouseMoveCallback) { @@ -15510,18 +15850,21 @@ Phaser.Mouse.prototype = { }, - /** + /** * The internal method that handles the mouse up event from the browser. - * @method Phaser.Mouse#onMouseUp - * @param {MouseEvent} event + * @method Phaser.Mouse#onMouseUp + * @param {MouseEvent} event - The native event from the browser. This gets stored in Mouse.event. */ onMouseUp: function (event) { this.event = event; - event.preventDefault(); + if (this.capture) + { + event.preventDefault(); + } - this.button = Phaser.Mouse.NO_BUTTON; + this.button = Phaser.Mouse.NO_BUTTON; if (this.mouseUpCallback) { @@ -15543,7 +15886,7 @@ Phaser.Mouse.prototype = { * 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 + * @method Phaser.Mouse#requestPointerLock */ requestPointerLock: function () { @@ -15568,10 +15911,10 @@ Phaser.Mouse.prototype = { }, - /** - * Internal pointerLockChange handler. - * @method Phaser.Mouse#pointerLockChange - * @param {MouseEvent} event + /** + * Internal pointerLockChange handler. + * @method Phaser.Mouse#pointerLockChange + * @param {pointerlockchange} event - The native event from the browser. This gets stored in Mouse.event. */ pointerLockChange: function (event) { @@ -15581,20 +15924,20 @@ Phaser.Mouse.prototype = { { // Pointer was successfully locked this.locked = true; - this.pointerLock.dispatch(true); + this.pointerLock.dispatch(true, event); } else { // Pointer was unlocked this.locked = false; - this.pointerLock.dispatch(false); + this.pointerLock.dispatch(false, event); } }, - /** - * Internal release pointer lock handler. - * @method Phaser.Mouse#releasePointerLock + /** + * Internal release pointer lock handler. + * @method Phaser.Mouse#releasePointerLock */ releasePointerLock: function () { @@ -15608,7 +15951,7 @@ Phaser.Mouse.prototype = { }, - /** + /** * Stop the event listeners. * @method Phaser.Mouse#stop */ @@ -15644,33 +15987,15 @@ Phaser.Mouse.prototype = { */ Phaser.MSPointer = function (game) { - /** - * @property {Phaser.Game} game - Local reference to game. - */ - this.game = game; - - /** - * @property {Phaser.Game} callbackContext - Description. - */ - this.callbackContext = this.game; - - /** - * @property {Description} mouseDownCallback - Description. - * @default - */ - this.mouseDownCallback = null; - - /** - * @property {Description} mouseMoveCallback - Description. - * @default - */ - this.mouseMoveCallback = null; - - /** - * @property {Description} mouseUpCallback - Description. - * @default - */ - this.mouseUpCallback = null; + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ + this.game = game; + + /** + * @property {Object} callbackContext - The context under which callbacks are called (defaults to game). + */ + this.callbackContext = this.game; /** * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. @@ -15679,26 +16004,20 @@ Phaser.MSPointer = function (game) { this.disabled = false; /** - * Description. - * @property {Description} _onMSPointerDown + * @property {function} _onMSPointerDown - Internal function to handle MSPointer events. * @private - * @default */ this._onMSPointerDown = null; /** - * Description. - * @property {Description} _onMSPointerMove + * @property {function} _onMSPointerMove - Internal function to handle MSPointer events. * @private - * @default */ this._onMSPointerMove = null; /** - * Description. - * @property {Description} _onMSPointerUp + * @property {function} _onMSPointerUp - Internal function to handle MSPointer events. * @private - * @default */ this._onMSPointerUp = null; @@ -15706,7 +16025,7 @@ Phaser.MSPointer = function (game) { Phaser.MSPointer.prototype = { - /** + /** * Starts the event listeners running. * @method Phaser.MSPointer#start */ @@ -15714,7 +16033,7 @@ Phaser.MSPointer.prototype = { var _this = this; - if (this.game.device.mspointer == true) + if (this.game.device.mspointer === true) { this._onMSPointerDown = function (event) { return _this.onPointerDown(event); @@ -15732,6 +16051,11 @@ Phaser.MSPointer.prototype = { this.game.renderer.view.addEventListener('MSPointerMove', this._onMSPointerMove, false); this.game.renderer.view.addEventListener('MSPointerUp', this._onMSPointerUp, false); + // IE11+ uses non-prefix events + this.game.renderer.view.addEventListener('pointerDown', this._onMSPointerDown, false); + this.game.renderer.view.addEventListener('pointerMove', this._onMSPointerMove, false); + this.game.renderer.view.addEventListener('pointerUp', this._onMSPointerUp, false); + this.game.renderer.view.style['-ms-content-zooming'] = 'none'; this.game.renderer.view.style['-ms-touch-action'] = 'none'; @@ -15740,10 +16064,10 @@ Phaser.MSPointer.prototype = { }, /** - * Description. + * The function that handles the PointerDown event. * @method Phaser.MSPointer#onPointerDown - * @param {Any} event - **/ + * @param {PointerEvent} event + */ onPointerDown: function (event) { if (this.game.input.disabled || this.disabled) @@ -15759,10 +16083,10 @@ Phaser.MSPointer.prototype = { }, /** - * Description. + * The function that handles the PointerMove event. * @method Phaser.MSPointer#onPointerMove - * @param {Any} event - **/ + * @param {PointerEvent } event + */ onPointerMove: function (event) { if (this.game.input.disabled || this.disabled) @@ -15778,10 +16102,10 @@ Phaser.MSPointer.prototype = { }, /** - * Description. + * The function that handles the PointerUp event. * @method Phaser.MSPointer#onPointerUp - * @param {Any} event - **/ + * @param {PointerEvent} event + */ onPointerUp: function (event) { if (this.game.input.disabled || this.disabled) @@ -15796,7 +16120,7 @@ Phaser.MSPointer.prototype = { }, - /** + /** * Stop the event listeners. * @method Phaser.MSPointer#stop */ @@ -15806,6 +16130,10 @@ Phaser.MSPointer.prototype = { this.game.stage.canvas.removeEventListener('MSPointerMove', this._onMSPointerMove); this.game.stage.canvas.removeEventListener('MSPointerUp', this._onMSPointerUp); + this.game.stage.canvas.removeEventListener('pointerDown', this._onMSPointerDown); + this.game.stage.canvas.removeEventListener('pointerMove', this._onMSPointerMove); + this.game.stage.canvas.removeEventListener('pointerUp', this._onMSPointerUp); + } }; @@ -15822,192 +16150,167 @@ Phaser.MSPointer.prototype = { * @classdesc A Pointer object is used by the Mouse, Touch and MSPoint managers and represents a single finger on the touch screen. * @constructor * @param {Phaser.Game} game - A reference to the currently running game. -* @param {Description} id - Description. +* @param {number} id - The ID of the Pointer object within the game. Each game can have up to 10 active pointers. */ Phaser.Pointer = function (game, id) { /** - * @property {Phaser.Game} game - Local reference to game. + * @property {Phaser.Game} game - A reference to the currently running game. */ this.game = game; /** - * @property {Description} id - Description. + * @property {number} id - The ID of the Pointer object within the game. Each game can have up to 10 active pointers. */ this.id = id; /** - * Local private variable to store the status of dispatching a hold event. - * @property {boolean} _holdSent + * @property {boolean} _holdSent - Local private variable to store the status of dispatching a hold event. * @private * @default */ this._holdSent = false; /** - * Local private variable storing the short-term history of pointer movements. - * @property {array} _history + * @property {array} _history - Local private variable storing the short-term history of pointer movements. * @private */ this._history = []; /** - * Local private variable storing the time at which the next history drop should occur - * @property {number} _lastDrop + * @property {number} _lastDrop - Local private variable storing the time at which the next history drop should occur. * @private * @default */ this._nextDrop = 0; /** - * Monitor events outside of a state reset loop. - * @property {boolean} _stateReset - * @private - * @default - */ + * @property {boolean} _stateReset - Monitor events outside of a state reset loop. + * @private + * @default + */ this._stateReset = false; /** - * Description. - * @property {boolean} withinGame + * @property {boolean} withinGame - true if the Pointer is within the game area, otherwise false. */ this.withinGame = false; /** - * The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset. - * @property {number} clientX + * @property {number} clientX - The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset. * @default */ this.clientX = -1; /** - * The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset. - * @property {number} clientY + * @property {number} clientY - The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset. * @default */ this.clientY = -1; /** - * The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset. - * @property {number} pageX + * @property {number} pageX - The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset. * @default */ this.pageX = -1; /** - * The vertical coordinate of point relative to the viewport in pixels, including any scroll offset. - * @property {number} pageY + * @property {number} pageY - The vertical coordinate of point relative to the viewport in pixels, including any scroll offset. * @default */ this.pageY = -1; /** - * The horizontal coordinate of point relative to the screen in pixels. - * @property {number} screenX + * @property {number} screenX - The horizontal coordinate of point relative to the screen in pixels. * @default */ this.screenX = -1; /** - * The vertical coordinate of point relative to the screen in pixels. - * @property {number} screenY + * @property {number} screenY - The vertical coordinate of point relative to the screen in pixels. * @default */ this.screenY = -1; /** - * The horizontal coordinate of point relative to the game element. This value is automatically scaled based on game size. - * @property {number} x + * @property {number} x - The horizontal coordinate of point relative to the game element. This value is automatically scaled based on game size. * @default */ this.x = -1; /** - * The vertical coordinate of point relative to the game element. This value is automatically scaled based on game size. - * @property {number} y + * @property {number} y - The vertical coordinate of point relative to the game element. This value is automatically scaled based on game size. * @default */ this.y = -1; /** - * If the Pointer is a mouse this is true, otherwise false. - * @property {boolean} isMouse - * @type {boolean} + * @property {boolean} isMouse - If the Pointer is a mouse this is true, otherwise false. + * @default */ this.isMouse = false; /** - * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true. - * @property {boolean} isDown + * @property {boolean} isDown - If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true. * @default */ this.isDown = false; /** - * If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true. - * @property {boolean} isUp + * @property {boolean} isUp - If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true. * @default */ this.isUp = true; /** - * A timestamp representing when the Pointer first touched the touchscreen. - * @property {number} timeDown + * @property {number} timeDown - A timestamp representing when the Pointer first touched the touchscreen. * @default */ this.timeDown = 0; /** - * A timestamp representing when the Pointer left the touchscreen. - * @property {number} timeUp + * @property {number} timeUp - A timestamp representing when the Pointer left the touchscreen. * @default */ this.timeUp = 0; /** - * A timestamp representing when the Pointer was last tapped or clicked. - * @property {number} previousTapTime + * @property {number} previousTapTime - A timestamp representing when the Pointer was last tapped or clicked. * @default */ this.previousTapTime = 0; /** - * The total number of times this Pointer has been touched to the touchscreen. - * @property {number} totalTouches + * @property {number} totalTouches - The total number of times this Pointer has been touched to the touchscreen. * @default */ this.totalTouches = 0; /** - * The number of miliseconds since the last click. - * @property {number} msSinceLastClick + * @property {number} msSinceLastClick - The number of miliseconds since the last click. * @default */ this.msSinceLastClick = Number.MAX_VALUE; /** - * The Game Object this Pointer is currently over / touching / dragging. - * @property {Any} targetObject + * @property {any} targetObject - The Game Object this Pointer is currently over / touching / dragging. * @default */ this.targetObject = null; /** - * An active pointer is one that is currently pressed down on the display. A Mouse is always active. - * @property {boolean} active + * @property {boolean} active - An active pointer is one that is currently pressed down on the display. A Mouse is always active. * @default */ this.active = false; /** - * A Phaser.Point object containing the current x/y values of the pointer on the display. - * @property {Phaser.Point} position + * @property {Phaser.Point} position - A Phaser.Point object containing the current x/y values of the pointer on the display. */ this.position = new Phaser.Point(); /** - * A Phaser.Point object containing the x/y values of the pointer when it was last in a down state on the display. - * @property {Phaser.Point} positionDown + * @property {Phaser.Point} positionDown - A Phaser.Point object containing the x/y values of the pointer when it was last in a down state on the display. */ this.positionDown = new Phaser.Point(); @@ -16018,7 +16321,7 @@ Phaser.Pointer = function (game, id) { */ this.circle = new Phaser.Circle(0, 0, 44); - if (id == 0) + if (id === 0) { this.isMouse = true; } @@ -16027,7 +16330,7 @@ Phaser.Pointer = function (game, id) { Phaser.Pointer.prototype = { - /** + /** * Called when the Pointer is pressed onto the touchscreen. * @method Phaser.Pointer#start * @param {Any} event @@ -16043,7 +16346,7 @@ Phaser.Pointer.prototype = { } // Fix to stop rogue browser plugins from blocking the visibility state event - if (this.game.paused == true && this.game.stage.scale.incorrectOrientation == false) + if (this.game.paused === true && this.game.stage.scale.incorrectOrientation === false) { this.game.paused = false; return this; @@ -16066,7 +16369,7 @@ Phaser.Pointer.prototype = { // x and y are the old values here? this.positionDown.setTo(this.x, this.y); - if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0)) + if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers === 0)) { this.game.input.x = this.x; this.game.input.y = this.y; @@ -16078,7 +16381,7 @@ Phaser.Pointer.prototype = { this._stateReset = false; this.totalTouches++; - if (this.isMouse == false) + if (this.isMouse === false) { this.game.input.currentPointers++; } @@ -16092,17 +16395,17 @@ Phaser.Pointer.prototype = { }, - /** - * Description. + /** + * Called internall by the Input Manager. * @method Phaser.Pointer#update */ update: function () { if (this.active) { - if (this._holdSent == false && this.duration >= this.game.input.holdRate) + if (this._holdSent === false && this.duration >= this.game.input.holdRate) { - if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0)) + if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers === 0)) { this.game.input.onHold.dispatch(this); } @@ -16129,10 +16432,10 @@ Phaser.Pointer.prototype = { }, - /** - * Called when the Pointer is moved + /** + * Called when the Pointer is moved. * @method Phaser.Pointer#move - * @param {Any} event + * @param {MouseEvent|PointerEvent|TouchEvent} event - The event passed up from the input handler. */ move: function (event) { @@ -16162,7 +16465,7 @@ Phaser.Pointer.prototype = { this.circle.x = this.x; this.circle.y = this.y; - if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0)) + if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers === 0)) { this.game.input.activePointer = this; this.game.input.x = this.x; @@ -16179,9 +16482,9 @@ Phaser.Pointer.prototype = { } // Easy out if we're dragging something and it still exists - if (this.targetObject !== null && this.targetObject.isDragged == true) + if (this.targetObject !== null && this.targetObject.isDragged === true) { - if (this.targetObject.update(this) == false) + if (this.targetObject.update(this) === false) { this.targetObject = null; } @@ -16199,7 +16502,7 @@ Phaser.Pointer.prototype = { { var currentNode = this.game.input.interactiveItems.next; - do + do { // If the object is using pixelPerfect checks, or has a higher InputManager.PriorityID OR if the priority ID is the same as the current highest AND it has a higher renderOrderID, then set it to the top if (currentNode.pixelPerfect || currentNode.priorityID > this._highestInputPriorityID || (currentNode.priorityID == this._highestInputPriorityID && currentNode.sprite.renderOrderID > this._highestRenderOrderID)) @@ -16244,7 +16547,7 @@ Phaser.Pointer.prototype = { { // Same target as before, so update it // console.log("Same target as before, so update it"); - if (this._highestRenderObject.update(this) == false) + if (this._highestRenderObject.update(this) === false) { this.targetObject = null; } @@ -16266,10 +16569,10 @@ Phaser.Pointer.prototype = { }, - /** + /** * Called when the Pointer leaves the target area. * @method Phaser.Pointer#leave - * @param {Any} event + * @param {MouseEvent|PointerEvent|TouchEvent} event - The event passed up from the input handler. */ leave: function (event) { @@ -16278,10 +16581,10 @@ Phaser.Pointer.prototype = { }, - /** + /** * Called when the Pointer leaves the touchscreen. * @method Phaser.Pointer#stop - * @param {Any} event + * @param {MouseEvent|PointerEvent|TouchEvent} event - The event passed up from the input handler. */ stop: function (event) { @@ -16293,7 +16596,7 @@ Phaser.Pointer.prototype = { this.timeUp = this.game.time.now; - if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0)) + if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers === 0)) { this.game.input.onUp.dispatch(this, event); @@ -16326,7 +16629,7 @@ Phaser.Pointer.prototype = { this.isDown = false; this.isUp = true; - if (this.isMouse == false) + if (this.isMouse === false) { this.game.input.currentPointers--; } @@ -16335,7 +16638,7 @@ Phaser.Pointer.prototype = { { var currentNode = this.game.input.interactiveItems.next; - do + do { if (currentNode) { @@ -16357,11 +16660,13 @@ Phaser.Pointer.prototype = { }, - /** + /** * The Pointer is considered justPressed if the time it was pressed onto the touchscreen or clicked is less than justPressedRate. + * Note that calling justPressed doesn't reset the pressed status of the Pointer, it will return `true` for as long as the duration is valid. + * If you wish to check if the Pointer was pressed down just once then see the Sprite.events.onInputDown event. * @method Phaser.Pointer#justPressed - * @param {number} [duration] - * @return {boolean} + * @param {number} [duration] - The time to check against. If none given it will use InputManager.justPressedRate. + * @return {boolean} true if the Pointer was pressed down within the duration given. */ justPressed: function (duration) { @@ -16371,11 +16676,13 @@ Phaser.Pointer.prototype = { }, - /** + /** * The Pointer is considered justReleased if the time it left the touchscreen is less than justReleasedRate. + * Note that calling justReleased doesn't reset the pressed status of the Pointer, it will return `true` for as long as the duration is valid. + * If you wish to check if the Pointer was released just once then see the Sprite.events.onInputUp event. * @method Phaser.Pointer#justReleased - * @param {number} [duration] - * @return {boolean} + * @param {number} [duration] - The time to check against. If none given it will use InputManager.justReleasedRate. + * @return {boolean} true if the Pointer was released within the duration given. */ justReleased: function (duration) { @@ -16385,13 +16692,13 @@ Phaser.Pointer.prototype = { }, - /** + /** * Resets the Pointer properties. Called by InputManager.reset when you perform a State change. * @method Phaser.Pointer#reset */ reset: function () { - if (this.isMouse == false) + if (this.isMouse === false) { this.active = false; } @@ -16411,15 +16718,6 @@ Phaser.Pointer.prototype = { this.targetObject = null; - }, - - /** - * Returns a string representation of this object. - * @method Phaser.Pointer#toString - * @return {string} A string representation of the instance. - **/ - 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 + ")}]"; } }; @@ -16455,7 +16753,7 @@ Object.defineProperty(Phaser.Pointer.prototype, "worldX", { get: function () { - return this.game.world.camera.x + this.x; + return this.game.world.camera.x + this.x; } @@ -16471,7 +16769,7 @@ Object.defineProperty(Phaser.Pointer.prototype, "worldY", { get: function () { - return this.game.world.camera.y + this.y; + return this.game.world.camera.y + this.y; } @@ -16494,70 +16792,102 @@ Object.defineProperty(Phaser.Pointer.prototype, "worldY", { Phaser.Touch = function (game) { /** - * @property {Phaser.Game} game - Local reference to game. + * @property {Phaser.Game} game - A reference to the currently running game. */ this.game = game; /** - * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. - * @method Phaser.Touch#disabled + * @property {boolean} disabled - You can disable all Touch events by setting disabled = true. While set all new touch events will be ignored. * @return {boolean} */ this.disabled = false; /** - * @property {Phaser.Game} callbackContext - Description. + * @property {Object} callbackContext - The context under which callbacks are called. */ this.callbackContext = this.game; /** - * @property {Phaser.Game} touchStartCallback - Description. - * @default + * @property {function} touchStartCallback - A callback that can be fired on a touchStart event. */ this.touchStartCallback = null; /** - * @property {Phaser.Game} touchMoveCallback - Description. - * @default + * @property {function} touchMoveCallback - A callback that can be fired on a touchMove event. */ this.touchMoveCallback = null; /** - * @property {Phaser.Game} touchEndCallback - Description. - * @default + * @property {function} touchEndCallback - A callback that can be fired on a touchEnd event. */ this.touchEndCallback = null; /** - * @property {Phaser.Game} touchEnterCallback - Description. - * @default + * @property {function} touchEnterCallback - A callback that can be fired on a touchEnter event. */ this.touchEnterCallback = null; /** - * @property {Phaser.Game} touchLeaveCallback - Description. - * @default + * @property {function} touchLeaveCallback - A callback that can be fired on a touchLeave event. */ this.touchLeaveCallback = null; /** - * @property {Description} touchCancelCallback - Description. - * @default + * @property {function} touchCancelCallback - A callback that can be fired on a touchCancel event. */ this.touchCancelCallback = null; /** - * @property {boolean} preventDefault - Description. + * @property {boolean} preventDefault - If true the TouchEvent will have prevent.default called on it. * @default */ this.preventDefault = true; + /** + * @property {TouchEvent} event - The browser touch event. + */ + this.event = null; + + /** + * @property {function} _onTouchStart - Internal event handler reference. + * @private + */ this._onTouchStart = null; + + /** + * @property {function} _onTouchMove - Internal event handler reference. + * @private + */ this._onTouchMove = null; + + /** + * @property {function} _onTouchEnd - Internal event handler reference. + * @private + */ this._onTouchEnd = null; + + /** + * @property {function} _onTouchEnter - Internal event handler reference. + * @private + */ this._onTouchEnter = null; + + /** + * @property {function} _onTouchLeave - Internal event handler reference. + * @private + */ this._onTouchLeave = null; + + /** + * @property {function} _onTouchCancel - Internal event handler reference. + * @private + */ this._onTouchCancel = null; + + /** + * @property {function} _onTouchMove - Internal event handler reference. + * @private + */ this._onTouchMove = null; }; @@ -16623,12 +16953,14 @@ Phaser.Touch.prototype = { }, /** - * Description. + * The internal method that handles the touchstart event from the browser. * @method Phaser.Touch#onTouchStart - * @param {Any} event + * @param {TouchEvent} event - The native event from the browser. This gets stored in Touch.event. */ onTouchStart: function (event) { + this.event = event; + if (this.touchStartCallback) { this.touchStartCallback.call(this.callbackContext, event); @@ -16658,10 +16990,12 @@ Phaser.Touch.prototype = { * Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome). * Occurs for example on iOS when you put down 4 fingers and the app selector UI appears. * @method Phaser.Touch#onTouchCancel - * @param {Any} event + * @param {TouchEvent} event - The native event from the browser. This gets stored in Touch.event. */ onTouchCancel: function (event) { + this.event = event; + if (this.touchCancelCallback) { this.touchCancelCallback.call(this.callbackContext, event); @@ -16690,10 +17024,12 @@ Phaser.Touch.prototype = { * For touch enter and leave its a list of the touch points that have entered or left the target. * Doesn't appear to be supported by most browsers on a canvas element yet. * @method Phaser.Touch#onTouchEnter - * @param {Any} event + * @param {TouchEvent} event - The native event from the browser. This gets stored in Touch.event. */ onTouchEnter: function (event) { + this.event = event; + if (this.touchEnterCallback) { this.touchEnterCallback.call(this.callbackContext, event); @@ -16709,10 +17045,12 @@ Phaser.Touch.prototype = { event.preventDefault(); } + /* for (var i = 0; i < event.changedTouches.length; i++) { //console.log('touch enter'); } + */ }, @@ -16720,10 +17058,12 @@ Phaser.Touch.prototype = { * For touch enter and leave its a list of the touch points that have entered or left the target. * Doesn't appear to be supported by most browsers on a canvas element yet. * @method Phaser.Touch#onTouchLeave - * @param {Any} event - */ + * @param {TouchEvent} event - The native event from the browser. This gets stored in Touch.event. + */ onTouchLeave: function (event) { + this.event = event; + if (this.touchLeaveCallback) { this.touchLeaveCallback.call(this.callbackContext, event); @@ -16734,20 +17074,24 @@ Phaser.Touch.prototype = { event.preventDefault(); } + /* for (var i = 0; i < event.changedTouches.length; i++) { //console.log('touch leave'); } + */ }, /** - * Description. + * The handler for the touchmove events. * @method Phaser.Touch#onTouchMove - * @param {Any} event + * @param {TouchEvent} event - The native event from the browser. This gets stored in Touch.event. */ onTouchMove: function (event) { + this.event = event; + if (this.touchMoveCallback) { this.touchMoveCallback.call(this.callbackContext, event); @@ -16766,12 +17110,14 @@ Phaser.Touch.prototype = { }, /** - * Description. + * The handler for the touchend events. * @method Phaser.Touch#onTouchEnd - * @param {Any} event + * @param {TouchEvent} event - The native event from the browser. This gets stored in Touch.event. */ onTouchEnd: function (event) { + this.event = event; + if (this.touchEndCallback) { this.touchEndCallback.call(this.callbackContext, event); @@ -16818,131 +17164,129 @@ Phaser.Touch.prototype = { */ /** -* Constructor for Phaser InputHandler. +* The Input Handler is bound to a specific Sprite and is responsible for managing all Input events on that Sprite. * @class Phaser.InputHandler -* @classdesc Description. * @constructor -* @param {Phaser.Sprite} game - Description. +* @param {Phaser.Sprite} sprite - The Sprite object to which this Input Handler belongs. */ Phaser.InputHandler = function (sprite) { - /** - * @property {Phaser.Sprite} sprite - Description. - */ - this.sprite = sprite; + /** + * @property {Phaser.Sprite} sprite - The Sprite object to which this Input Handler belongs. + */ + this.sprite = sprite; /** * @property {Phaser.Game} game - A reference to the currently running game. */ this.game = sprite.game; - /** - * @property {boolean} enabled - Description. - * @default - */ + /** + * @property {boolean} enabled - If enabled the Input Handler will process input requests and monitor pointer activity. + * @default + */ this.enabled = false; - // Linked list references - /** - * @property {Description} parent - Description. - * @default - */ - this.parent = null; + /** + * @property {Description} parent - Description. + * @default + */ + // this.parent = null; - /** - * @property {Description} next - Description. - * @default - */ - this.next = null; + /** + * @property {Description} next - Linked List + * @default + */ + // this.next = null; - /** - * @property {Description} prev - Description. - * @default - */ - this.prev = null; + /** + * @property {Description} prev - Description. + * @default + */ + // this.prev = null; - /** - * @property {Description} last - Description. - * @default - */ - this.last = this; - - /** - * @property {Description} first - Description. - * @default - */ - this.first = this; + /** + * @property {Description} last - Description. + * @default + */ + // this.last = this; + + /** + * @property {Description} first - Description. + * @default + */ + // this.first = this; - /** - * @property {number} priorityID - The PriorityID controls which Sprite receives an Input event first if they should overlap. - * @default - */ + /** + * @property {number} priorityID - The PriorityID controls which Sprite receives an Input event first if they should overlap. + * @default + */ this.priorityID = 0; - /** - * @property {boolean} useHandCursor - Description. - * @default - */ + /** + * @property {boolean} useHandCursor - On a desktop browser you can set the 'hand' cursor to appear when moving over the Sprite. + * @default + */ this.useHandCursor = false; - - /** - * @property {boolean} isDragged - Description. - * @default - */ + + /** + * @property {boolean} isDragged - true if the Sprite is being currently dragged. + * @default + */ this.isDragged = false; - /** - * @property {boolean} allowHorizontalDrag - Description. - * @default - */ + /** + * @property {boolean} allowHorizontalDrag - Controls if the Sprite is allowed to be dragged horizontally. + * @default + */ this.allowHorizontalDrag = true; - /** - * @property {boolean} allowVerticalDrag - Description. - * @default - */ + /** + * @property {boolean} allowVerticalDrag - Controls if the Sprite is allowed to be dragged vertically. + * @default + */ this.allowVerticalDrag = true; - /** - * @property {boolean} bringToTop - Description. - * @default - */ + /** + * @property {boolean} bringToTop - If true when this Sprite is clicked or dragged it will automatically be bought to the top of the Group it is within. + * @default + */ this.bringToTop = false; - /** - * @property {Description} snapOffset - Description. - * @default - */ + /** + * @property {Phaser.Point} snapOffset - A Point object that contains by how far the Sprite snap is offset. + * @default + */ this.snapOffset = null; - /** - * @property {boolean} snapOnDrag - Description. - * @default - */ + /** + * @property {boolean} snapOnDrag - When the Sprite is dragged this controls if the center of the Sprite will snap to the pointer on drag or not. + * @default + */ this.snapOnDrag = false; - /** - * @property {boolean} snapOnRelease - Description. - * @default - */ + /** + * @property {boolean} snapOnRelease - When the Sprite is dragged this controls if the Sprite will be snapped on release. + * @default + */ this.snapOnRelease = false; - /** - * @property {number} snapX - Description. - * @default - */ + /** + * @property {number} snapX - When a Sprite has snapping enabled this holds the width of the snap grid. + * @default + */ this.snapX = 0; - /** - * @property {number} snapY - Description. - * @default - */ + /** + * @property {number} snapY - When a Sprite has snapping enabled this holds the height of the snap grid. + * @default + */ this.snapY = 0; - /** - * @property {number} pixelPerfect - Should we use pixel perfect hit detection? Warning: expensive. Only enable if you really need it! - * @default - */ + /** + * @property {number} pixelPerfect - Should we use pixel perfect hit detection? Warning: expensive. Only enable if you really need it! + * @default + */ this.pixelPerfect = false; /** @@ -16958,13 +17302,13 @@ Phaser.InputHandler = function (sprite) { this.draggable = false; /** - * @property {Description} boundsRect - A region of the game world within which the sprite is restricted during drag. + * @property {Phaser.Rectangle} boundsRect - A region of the game world within which the sprite is restricted during drag. * @default */ this.boundsRect = null; /** - * @property {Description} boundsSprite - A Sprite the bounds of which this sprite is restricted during drag. + * @property {Phaser.Sprite} boundsSprite - A Sprite the bounds of which this sprite is restricted during drag. * @default */ this.boundsSprite = null; @@ -16981,7 +17325,7 @@ Phaser.InputHandler = function (sprite) { * @property {Phaser.Point} _tempPoint - Description. * @private */ - this._tempPoint = new Phaser.Point; + this._tempPoint = new Phaser.Point(); this._pointerData = []; @@ -17005,23 +17349,23 @@ Phaser.InputHandler = function (sprite) { Phaser.InputHandler.prototype = { - /** - * Description. - * @method Phaser.InputHandler#start - * @param {number} priority - Description. - * @param {boolean} useHandCursor - Description. - * @return {Phaser.Sprite} Description. - */ - start: function (priority, useHandCursor) { + /** + * Starts the Input Handler running. This is called automatically when you enable input on a Sprite, or can be called directly if you need to set a specific priority. + * @method Phaser.InputHandler#start + * @param {number} priority - Higher priority sprites take click priority over low-priority sprites when they are stacked on-top of each other. + * @param {boolean} useHandCursor - If true the Sprite will show the hand cursor on mouse-over (doesn't apply to mobile browsers) + * @return {Phaser.Sprite} The Sprite object to which the Input Handler is bound. + */ + start: function (priority, useHandCursor) { - priority = priority || 0; - if (typeof useHandCursor == 'undefined') { useHandCursor = false; } + priority = priority || 0; + if (typeof useHandCursor == 'undefined') { useHandCursor = false; } // Turning on - if (this.enabled == false) + if (this.enabled === false) { // Register, etc - this.game.input.interactiveItems.add(this); + this.game.input.interactiveItems.add(this); this.useHandCursor = useHandCursor; this.priorityID = priority; @@ -17044,29 +17388,29 @@ Phaser.InputHandler.prototype = { }; } - this.snapOffset = new Phaser.Point; + this.snapOffset = new Phaser.Point(); this.enabled = true; // Create the signals the Input component will emit if (this.sprite.events && this.sprite.events.onInputOver == null) { - this.sprite.events.onInputOver = new Phaser.Signal; - this.sprite.events.onInputOut = new Phaser.Signal; - this.sprite.events.onInputDown = new Phaser.Signal; - this.sprite.events.onInputUp = new Phaser.Signal; - this.sprite.events.onDragStart = new Phaser.Signal; - this.sprite.events.onDragStop = new Phaser.Signal; + this.sprite.events.onInputOver = new Phaser.Signal(); + this.sprite.events.onInputOut = new Phaser.Signal(); + this.sprite.events.onInputDown = new Phaser.Signal(); + this.sprite.events.onInputUp = new Phaser.Signal(); + this.sprite.events.onDragStart = new Phaser.Signal(); + this.sprite.events.onDragStop = new Phaser.Signal(); } } return this.sprite; - }, + }, - /** - * Description. - * @method Phaser.InputHandler#reset - */ + /** + * Resets the Input Handler and disables it. + * @method Phaser.InputHandler#reset + */ reset: function () { this.enabled = false; @@ -17091,14 +17435,14 @@ Phaser.InputHandler.prototype = { } }, - /** - * Description. - * @method Phaser.InputHandler#stop - */ - stop: function () { + /** + * Stops the Input Handler from running. + * @method Phaser.InputHandler#stop + */ + stop: function () { // Turning off - if (this.enabled == false) + if (this.enabled === false) { return; } @@ -17106,15 +17450,15 @@ Phaser.InputHandler.prototype = { { // De-register, etc this.enabled = false; - this.game.input.interactiveItems.remove(this); + this.game.input.interactiveItems.remove(this); } - }, + }, - /** - * Clean up memory. - * @method Phaser.InputHandler#destroy - */ + /** + * Clean up memory. + * @method Phaser.InputHandler#destroy + */ destroy: function () { if (this.enabled) @@ -17123,99 +17467,99 @@ Phaser.InputHandler.prototype = { this.game.input.interactiveItems.remove(this); - this.stop(); + this.stop(); - this.sprite = null; + this.sprite = null; } }, - /** + /** * The x coordinate of the Input pointer, relative to the top-left of the parent Sprite. * This value is only set when the pointer is over this Sprite. * @method Phaser.InputHandler#pointerX - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer * @return {number} The x coordinate of the Input pointer. - */ + */ pointerX: function (pointer) { - pointer = pointer || 0; + pointer = pointer || 0; return this._pointerData[pointer].x; }, - /** + /** * The y coordinate of the Input pointer, relative to the top-left of the parent Sprite * This value is only set when the pointer is over this Sprite. * @method Phaser.InputHandler#pointerY - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer * @return {number} The y coordinate of the Input pointer. */ pointerY: function (pointer) { - pointer = pointer || 0; + pointer = pointer || 0; return this._pointerData[pointer].y; }, - /** + /** * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true. * @method Phaser.InputHandler#pointerDown - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer * @return {boolean} */ pointerDown: function (pointer) { - pointer = pointer || 0; + pointer = pointer || 0; return this._pointerData[pointer].isDown; }, - /** + /** * If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true * @method Phaser.InputHandler#pointerUp - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer * @return {boolean} */ pointerUp: function (pointer) { - pointer = pointer || 0; + pointer = pointer || 0; return this._pointerData[pointer].isUp; }, - /** + /** * A timestamp representing when the Pointer first touched the touchscreen. * @method Phaser.InputHandler#pointerTimeDown - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer * @return {number} */ pointerTimeDown: function (pointer) { - pointer = pointer || 0; + pointer = pointer || 0; return this._pointerData[pointer].timeDown; }, - /** + /** * A timestamp representing when the Pointer left the touchscreen. * @method Phaser.InputHandler#pointerTimeUp - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer * @return {number} */ pointerTimeUp: function (pointer) { - pointer = pointer || 0; + pointer = pointer || 0; return this._pointerData[pointer].timeUp; }, - /** + /** * Is the Pointer over this Sprite? * @method Phaser.InputHandler#pointerOver * @param {number} [index] - The ID number of a Pointer to check. If you don't provide a number it will check all Pointers. @@ -17245,13 +17589,13 @@ Phaser.InputHandler.prototype = { }, - /** + /** * Is the Pointer outside of this Sprite? * @method Phaser.InputHandler#pointerOut * @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) { + pointerOut: function (index) { if (this.enabled) { @@ -17275,52 +17619,52 @@ Phaser.InputHandler.prototype = { }, - /** + /** * A timestamp representing when the Pointer first touched the touchscreen. * @method Phaser.InputHandler#pointerTimeOver - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer * @return {number} */ pointerTimeOver: function (pointer) { - pointer = pointer || 0; + pointer = pointer || 0; return this._pointerData[pointer].timeOver; }, - /** + /** * A timestamp representing when the Pointer left the touchscreen. * @method Phaser.InputHandler#pointerTimeOut - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer * @return {number} */ pointerTimeOut: function (pointer) { - pointer = pointer || 0; + pointer = pointer || 0; return this._pointerData[pointer].timeOut; }, - /** + /** * Is this sprite being dragged by the mouse or not? * @method Phaser.InputHandler#pointerTimeOut - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer * @return {number} */ pointerDragged: function (pointer) { - pointer = pointer || 0; + pointer = pointer || 0; return this._pointerData[pointer].isDragged; }, - /** + /** * Checks if the given pointer is over this Sprite. * @method Phaser.InputHandler#checkPointerOver - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer * @return {boolean} */ checkPointerOver: function (pointer) { @@ -17346,7 +17690,7 @@ Phaser.InputHandler.prototype = { }, - /** + /** * 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 @@ -17378,14 +17722,14 @@ Phaser.InputHandler.prototype = { }, - /** + /** * Update. * @method Phaser.InputHandler#update - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer */ update: function (pointer) { - if (this.enabled == false || this.sprite.visible == false || (this.sprite.group && this.sprite.group.visible == false)) + if (this.enabled === false || this.sprite.visible === false || (this.sprite.group && this.sprite.group.visible === false)) { this._pointerOutHandler(pointer); return false; @@ -17395,7 +17739,7 @@ Phaser.InputHandler.prototype = { { return this.updateDrag(pointer); } - else if (this._pointerData[pointer.id].isOver == true) + else if (this._pointerData[pointer.id].isOver === true) { if (this.checkPointerOver(pointer)) { @@ -17411,15 +17755,15 @@ Phaser.InputHandler.prototype = { } }, - /** - * Description. - * @method Phaser.InputHandler#_pointerOverHandler - * @private - * @param {Pointer} pointer - */ + /** + * Internal method handling the pointer over event. + * @method Phaser.InputHandler#_pointerOverHandler + * @private + * @param {Phaser.Pointer} pointer + */ _pointerOverHandler: function (pointer) { - if (this._pointerData[pointer.id].isOver == false) + if (this._pointerData[pointer.id].isOver === false) { this._pointerData[pointer.id].isOver = true; this._pointerData[pointer.id].isOut = false; @@ -17427,7 +17771,7 @@ Phaser.InputHandler.prototype = { this._pointerData[pointer.id].x = pointer.x - this.sprite.x; this._pointerData[pointer.id].y = pointer.y - this.sprite.y; - if (this.useHandCursor && this._pointerData[pointer.id].isDragged == false) + if (this.useHandCursor && this._pointerData[pointer.id].isDragged === false) { this.game.stage.canvas.style.cursor = "pointer"; } @@ -17436,19 +17780,19 @@ Phaser.InputHandler.prototype = { } }, - /** - * Description. - * @method Phaser.InputHandler#_pointerOutHandler - * @private - * @param {Pointer} pointer - */ + /** + * Internal method handling the pointer out event. + * @method Phaser.InputHandler#_pointerOutHandler + * @private + * @param {Phaser.Pointer} pointer + */ _pointerOutHandler: function (pointer) { this._pointerData[pointer.id].isOver = false; this._pointerData[pointer.id].isOut = true; this._pointerData[pointer.id].timeOut = this.game.time.now; - if (this.useHandCursor && this._pointerData[pointer.id].isDragged == false) + if (this.useHandCursor && this._pointerData[pointer.id].isDragged === false) { this.game.stage.canvas.style.cursor = "default"; } @@ -17460,15 +17804,15 @@ Phaser.InputHandler.prototype = { }, - /** - * Description. - * @method Phaser.InputHandler#_touchedHandler - * @private - * @param {Pointer} pointer - */ + /** + * Internal method handling the touched event. + * @method Phaser.InputHandler#_touchedHandler + * @private + * @param {Phaser.Pointer} pointer + */ _touchedHandler: function (pointer) { - if (this._pointerData[pointer.id].isDown == false && this._pointerData[pointer.id].isOver == true) + if (this._pointerData[pointer.id].isDown === false && this._pointerData[pointer.id].isOver === true) { this._pointerData[pointer.id].isDown = true; this._pointerData[pointer.id].isUp = false; @@ -17476,7 +17820,7 @@ Phaser.InputHandler.prototype = { this.sprite.events.onInputDown.dispatch(this.sprite, pointer); // Start drag - if (this.draggable && this.isDragged == false) + if (this.draggable && this.isDragged === false) { this.startDrag(pointer); } @@ -17484,7 +17828,7 @@ Phaser.InputHandler.prototype = { if (this.bringToTop) { this.sprite.bringToTop(); - } + } } // Consume the event? @@ -17492,12 +17836,12 @@ Phaser.InputHandler.prototype = { }, - /** - * Description. - * @method Phaser.InputHandler#_releasedHandler - * @private - * @param {Pointer} pointer - */ + /** + * Internal method handling the pointer released event. + * @method Phaser.InputHandler#_releasedHandler + * @private + * @param {Phaser.Pointer} pointer + */ _releasedHandler: function (pointer) { // If was previously touched by this Pointer, check if still is AND still over this item @@ -17532,10 +17876,10 @@ Phaser.InputHandler.prototype = { }, - /** + /** * Updates the Pointer drag on this Sprite. * @method Phaser.InputHandler#updateDrag - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer * @return {boolean} */ updateDrag: function (pointer) { @@ -17576,79 +17920,79 @@ Phaser.InputHandler.prototype = { }, - /** + /** * Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second) * @method Phaser.InputHandler#justOver - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer * @param {number} delay - The time below which the pointer is considered as just over. * @return {boolean} */ justOver: function (pointer, delay) { - pointer = pointer || 0; - delay = delay || 500; + pointer = pointer || 0; + delay = delay || 500; return (this._pointerData[pointer].isOver && this.overDuration(pointer) < delay); }, - /** + /** * Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second) * @method Phaser.InputHandler#justOut - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer * @param {number} delay - The time below which the pointer is considered as just out. * @return {boolean} */ justOut: function (pointer, delay) { - pointer = pointer || 0; - delay = delay || 500; + pointer = pointer || 0; + delay = delay || 500; return (this._pointerData[pointer].isOut && (this.game.time.now - this._pointerData[pointer].timeOut < delay)); }, - /** + /** * Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second) * @method Phaser.InputHandler#justPressed - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer * @param {number} delay - The time below which the pointer is considered as just over. * @return {boolean} */ justPressed: function (pointer, delay) { - pointer = pointer || 0; - delay = delay || 500; + pointer = pointer || 0; + delay = delay || 500; return (this._pointerData[pointer].isDown && this.downDuration(pointer) < delay); }, - /** + /** * Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second) * @method Phaser.InputHandler#justReleased - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer * @param {number} delay - The time below which the pointer is considered as just out. * @return {boolean} */ justReleased: function (pointer, delay) { - pointer = pointer || 0; - delay = delay || 500; + pointer = pointer || 0; + delay = delay || 500; return (this._pointerData[pointer].isUp && (this.game.time.now - this._pointerData[pointer].timeUp < delay)); }, - /** + /** * If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds. * @method Phaser.InputHandler#overDuration - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer * @return {number} The number of milliseconds the pointer has been over the Sprite, or -1 if not over. */ overDuration: function (pointer) { - pointer = pointer || 0; + pointer = pointer || 0; if (this._pointerData[pointer].isOver) { @@ -17659,15 +18003,15 @@ Phaser.InputHandler.prototype = { }, - /** + /** * If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds. * @method Phaser.InputHandler#downDuration - * @param {Pointer} pointer + * @param {Phaser.Pointer} pointer * @return {number} The number of milliseconds the pointer has been pressed down on the Sprite, or -1 if not over. */ downDuration: function (pointer) { - pointer = pointer || 0; + pointer = pointer || 0; if (this._pointerData[pointer].isDown) { @@ -17678,25 +18022,24 @@ Phaser.InputHandler.prototype = { }, - /** + /** * Make this Sprite draggable by the mouse. You can also optionally set mouseStartDragCallback and mouseStopDragCallback * @method Phaser.InputHandler#enableDrag - * @param lockCenter If false the Sprite will drag from where you click it minus the dragOffset. If true it will center itself to the tip of the mouse pointer. - * @param bringToTop If true the Sprite will be bought to the top of the rendering list in its current Group. - * @param pixelPerfect If true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box. - * @param alphaThreshold If using pixel perfect collision this specifies the alpha level from 0 to 255 above which a collision is processed (default 255) - * @param boundsRect If you want to restrict the drag of this sprite to a specific FlxRect, pass the FlxRect here, otherwise it's free to drag anywhere - * @param boundsSprite If you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here + * @param {boolean} [lockCenter=false] - If false the Sprite will drag from where you click it minus the dragOffset. If true it will center itself to the tip of the mouse pointer. + * @param {boolean} [bringToTop=false] - If true the Sprite will be bought to the top of the rendering list in its current Group. + * @param {boolean} [pixelPerfect=false] - If true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box. + * @param {boolean} [alphaThreshold=255] - If using pixel perfect collision this specifies the alpha level from 0 to 255 above which a collision is processed. + * @param {Phaser.Rectangle} [boundsRect=null] - If you want to restrict the drag of this sprite to a specific Rectangle, pass the Phaser.Rectangle here, otherwise it's free to drag anywhere. + * @param {Phaser.Sprite} [boundsSprite=null] - If you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here. */ enableDrag: function (lockCenter, bringToTop, pixelPerfect, alphaThreshold, boundsRect, boundsSprite) { if (typeof lockCenter == 'undefined') { lockCenter = false; } if (typeof bringToTop == 'undefined') { bringToTop = false; } if (typeof pixelPerfect == 'undefined') { pixelPerfect = false; } - - alphaThreshold = alphaThreshold || 255; - boundsRect = boundsRect || null; - boundsSprite = boundsSprite || null; + if (typeof alphaThreshold == 'undefined') { alphaThreshold = 255; } + if (typeof boundsRect == 'undefined') { boundsRect = null; } + if (typeof boundsSprite == 'undefined') { boundsSprite = null; } this._dragPoint = new Phaser.Point(); this.draggable = true; @@ -17719,7 +18062,7 @@ Phaser.InputHandler.prototype = { }, - /** + /** * Stops this sprite from being able to be dragged. If it is currently the target of an active drag it will be stopped immediately. Also disables any set callbacks. * @method Phaser.InputHandler#disableDrag */ @@ -17739,9 +18082,10 @@ Phaser.InputHandler.prototype = { }, - /** + /** * Called by Pointer when drag starts on this Sprite. Should not usually be called directly. * @method Phaser.InputHandler#startDrag + * @param {Phaser.Pointer} pointer */ startDrag: function (pointer) { @@ -17770,9 +18114,10 @@ Phaser.InputHandler.prototype = { }, - /** + /** * Called by Pointer when drag is stopped on this Sprite. Should not usually be called directly. * @method Phaser.InputHandler#stopDrag + * @param {Phaser.Pointer} pointer */ stopDrag: function (pointer) { @@ -17789,37 +18134,37 @@ Phaser.InputHandler.prototype = { this.sprite.events.onDragStop.dispatch(this.sprite, pointer); this.sprite.events.onInputUp.dispatch(this.sprite, pointer); - if (this.checkPointerOver(pointer) == false) + if (this.checkPointerOver(pointer) === false) { this._pointerOutHandler(pointer); } }, - /** + /** * Restricts this sprite to drag movement only on the given axis. Note: If both are set to false the sprite will never move! * @method Phaser.InputHandler#setDragLock - * @param allowHorizontal To enable the sprite to be dragged horizontally set to true, otherwise false - * @param allowVertical To enable the sprite to be dragged vertically set to true, otherwise false + * @param {boolean} [allowHorizontal=true] - To enable the sprite to be dragged horizontally set to true, otherwise false. + * @param {boolean} [allowVertical=true] - To enable the sprite to be dragged vertically set to true, otherwise false. */ setDragLock: function (allowHorizontal, allowVertical) { if (typeof allowHorizontal == 'undefined') { allowHorizontal = true; } - if (typeof allowVertical == 'undefined') { allowVertical = true; } + if (typeof allowVertical == 'undefined') { allowVertical = true; } this.allowHorizontalDrag = allowHorizontal; this.allowVerticalDrag = allowVertical; }, - /** + /** * Make this Sprite snap to the given grid either during drag or when it's released. * For example 16x16 as the snapX and snapY would make the sprite snap to every 16 pixels. * @method Phaser.InputHandler#enableSnap - * @param snapX The width of the grid cell in pixels - * @param snapY The height of the grid cell in pixels - * @param onDrag If true the sprite will snap to the grid while being dragged - * @param onRelease If true the sprite will snap to the grid when released + * @param {number} snapX - The width of the grid cell to snap to. + * @param {number} snapY - The height of the grid cell to snap to. + * @param {boolean} [onDrag=true] - If true the sprite will snap to the grid while being dragged. + * @param {boolean} [onRelease=false] - If true the sprite will snap to the grid when released. */ enableSnap: function (snapX, snapY, onDrag, onRelease) { @@ -17833,7 +18178,7 @@ Phaser.InputHandler.prototype = { }, - /** + /** * Stops the sprite from snapping to a grid during drag or release. * @method Phaser.InputHandler#disableSnap */ @@ -17844,7 +18189,7 @@ Phaser.InputHandler.prototype = { }, - /** + /** * Bounds Rect check for the sprite drag * @method Phaser.InputHandler#checkBoundsRect */ @@ -17870,7 +18215,7 @@ Phaser.InputHandler.prototype = { }, - /** + /** * Parent Sprite Bounds check for the sprite drag. * @method Phaser.InputHandler#checkBoundsSprite */ @@ -17903,7 +18248,6 @@ Phaser.InputHandler.prototype = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ - /** * The Events component is a collection of events fired by the parent game object and its components. * @@ -17913,13 +18257,13 @@ Phaser.InputHandler.prototype = { * @param {Phaser.Sprite} sprite - A reference to Description. */ Phaser.Events = function (sprite) { - - this.parent = sprite; - this.onAddedToGroup = new Phaser.Signal; - this.onRemovedFromGroup = new Phaser.Signal; - this.onKilled = new Phaser.Signal; - this.onRevived = new Phaser.Signal; - this.onOutOfBounds = new Phaser.Signal; + + this.parent = sprite; + this.onAddedToGroup = new Phaser.Signal(); + this.onRemovedFromGroup = new Phaser.Signal(); + this.onKilled = new Phaser.Signal(); + this.onRevived = new Phaser.Signal(); + this.onOutOfBounds = new Phaser.Signal(); this.onInputOver = null; this.onInputOut = null; @@ -17928,41 +18272,41 @@ Phaser.Events = function (sprite) { this.onDragStart = null; this.onDragStop = null; - this.onAnimationStart = null; - this.onAnimationComplete = null; - this.onAnimationLoop = null; + this.onAnimationStart = null; + this.onAnimationComplete = null; + this.onAnimationLoop = null; }; Phaser.Events.prototype = { - destroy: function () { + destroy: function () { - this.parent = null; - this.onAddedToGroup.dispose(); - this.onRemovedFromGroup.dispose(); - this.onKilled.dispose(); - this.onRevived.dispose(); - this.onOutOfBounds.dispose(); + this.parent = null; + this.onAddedToGroup.dispose(); + this.onRemovedFromGroup.dispose(); + this.onKilled.dispose(); + this.onRevived.dispose(); + this.onOutOfBounds.dispose(); - if (this.onInputOver) - { - this.onInputOver.dispose(); - this.onInputOut.dispose(); - this.onInputDown.dispose(); - this.onInputUp.dispose(); - this.onDragStart.dispose(); - this.onDragStop.dispose(); - } + if (this.onInputOver) + { + this.onInputOver.dispose(); + this.onInputOut.dispose(); + this.onInputDown.dispose(); + this.onInputUp.dispose(); + this.onDragStart.dispose(); + this.onDragStop.dispose(); + } - if (this.onAnimationStart) - { - this.onAnimationStart.dispose(); - this.onAnimationComplete.dispose(); - this.onAnimationLoop.dispose(); - } + if (this.onAnimationStart) + { + this.onAnimationStart.dispose(); + this.onAnimationComplete.dispose(); + this.onAnimationLoop.dispose(); + } - } + } }; /** @@ -17981,14 +18325,14 @@ Phaser.Events.prototype = { Phaser.GameObjectFactory = function (game) { /** - * @property {Phaser.Game} game - A reference to the currently running Game. - */ - this.game = game; - + * @property {Phaser.Game} game - A reference to the currently running Game. + */ + this.game = game; + /** - * @property {Phaser.World} world - A reference to the game world. - */ - this.world = this.game.world; + * @property {Phaser.World} world - A reference to the game world. + */ + this.world = this.game.world; }; @@ -18006,7 +18350,7 @@ Phaser.GameObjectFactory.prototype = { }, - /** + /** * Create a new Sprite with specific position and sprite sheet key. * * @method Phaser.GameObjectFactory#sprite @@ -18067,14 +18411,14 @@ Phaser.GameObjectFactory.prototype = { }, /** - * Creates a new instance of the Sound class. - * + * Creates a new instance of the Sound class. + * * @method Phaser.GameObjectFactory#audio - * @param {string} key - The Game.cache key of the sound that this object will use. - * @param {number} volume - The volume at which the sound will be played. - * @param {boolean} loop - Whether or not the sound will loop. - * @return {Phaser.Sound} The newly created text object. - */ + * @param {string} key - The Game.cache key of the sound that this object will use. + * @param {number} volume - The volume at which the sound will be played. + * @param {boolean} loop - Whether or not the sound will loop. + * @return {Phaser.Sound} The newly created text object. + */ audio: function (key, volume, loop) { return this.game.sound.add(key, volume, loop); @@ -18082,17 +18426,17 @@ Phaser.GameObjectFactory.prototype = { }, /** - * Creates a new TileSprite. - * + * Creates a new TileSprite. + * * @method Phaser.GameObjectFactory#tileSprite - * @param {number} x - X position of the new tileSprite. - * @param {number} y - Y position of the new tileSprite. - * @param {number} width - the width of the tilesprite. - * @param {number} height - the height of the tilesprite. - * @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. - * @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. - * @return {Phaser.TileSprite} The newly created tileSprite object. - */ + * @param {number} x - X position of the new tileSprite. + * @param {number} y - Y position of the new tileSprite. + * @param {number} width - the width of the tilesprite. + * @param {number} height - the height of the tilesprite. + * @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. + * @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + * @return {Phaser.TileSprite} The newly created tileSprite object. + */ tileSprite: function (x, y, width, height, key, frame) { return this.world.add(new Phaser.TileSprite(this.game, x, y, width, height, key, frame)); @@ -18100,15 +18444,15 @@ Phaser.GameObjectFactory.prototype = { }, /** - * Creates a new Text. - * + * Creates a new Text. + * * @method Phaser.GameObjectFactory#text - * @param {number} x - X position of the new text object. - * @param {number} y - Y position of the new text object. - * @param {string} text - The actual text that will be written. - * @param {object} style - The style object containing style attributes like font, font size , etc. - * @return {Phaser.Text} The newly created text object. - */ + * @param {number} x - X position of the new text object. + * @param {number} y - Y position of the new text object. + * @param {string} text - The actual text that will be written. + * @param {object} style - The style object containing style attributes like font, font size , etc. + * @return {Phaser.Text} The newly created text object. + */ text: function (x, y, text, style) { return this.world.add(new Phaser.Text(this.game, x, y, text, style)); @@ -18136,13 +18480,13 @@ Phaser.GameObjectFactory.prototype = { }, /** - * Creates a new Graphics object. - * + * Creates a new Graphics object. + * * @method Phaser.GameObjectFactory#graphics - * @param {number} x - X position of the new graphics object. - * @param {number} y - Y position of the new graphics object. - * @return {Phaser.Graphics} The newly created graphics object. - */ + * @param {number} x - X position of the new graphics object. + * @param {number} y - Y position of the new graphics object. + * @return {Phaser.Graphics} The newly created graphics object. + */ graphics: function (x, y) { return this.world.add(new Phaser.Graphics(this.game, x, y)); @@ -18255,6 +18599,26 @@ Phaser.GameObjectFactory.prototype = { return new Phaser.BitmapData(this.game, width, height); + }, + + /** + * A WebGL shader/filter that can be applied to Sprites. + * + * @method Phaser.GameObjectFactory#filter + * @param {string} filter - The name of the filter you wish to create, for example "HueRotate" or "SineWave" + * @param {...} - Whatever parameters are needed to be passed to the filter init function. + * @return {Phaser.Filter} The newly created Phaser.Filter object. + */ + filter: function (filter) { + + var args = Array.prototype.splice.call(arguments, 1); + + var f = new Phaser.Filter[filter](this.game); + + f.init.apply(f, args); + + return f; + } }; @@ -18275,933 +18639,944 @@ Phaser.GameObjectFactory.prototype = { */ Phaser.BitmapData = function (game, width, height) { - if (typeof width === 'undefined') { width = 256; } - if (typeof height === 'undefined') { height = 256; } + if (typeof width === 'undefined') { width = 256; } + if (typeof height === 'undefined') { height = 256; } - /** - * @property {Phaser.Game} game - A reference to the currently running game. - */ - this.game = game; + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ + this.game = game; - /** + /** * @property {string} name - The name of the BitmapData. - */ + */ this.name = ''; - /** - * @property {number} width - The width of the BitmapData in pixels. + /** + * @property {number} width - The width of the BitmapData in pixels. */ - this.width = width; - - /** - * @property {number} height - The height of the BitmapData in pixels. + this.width = width; + + /** + * @property {number} height - The height of the BitmapData in pixels. */ - this.height = height; + this.height = height; - /** - * @property {HTMLCanvasElement} canvas - The canvas to which this BitmapData draws. - * @default - */ + /** + * @property {HTMLCanvasElement} canvas - The canvas to which this BitmapData draws. + * @default + */ this.canvas = Phaser.Canvas.create(width, height); - /** - * @property {CanvasRenderingContext2D} context - The 2d context of the canvas. - * @default - */ + /** + * @property {CanvasRenderingContext2D} context - The 2d context of the canvas. + * @default + */ this.context = this.canvas.getContext('2d'); - /** - * @property {array} imageData - The canvas image data. - */ - this.imageData = this.context.getImageData(0, 0, width, height); + /** + * @property {array} imageData - The canvas image data. + */ + this.imageData = this.context.getImageData(0, 0, width, height); - /** - * @property {UInt8Clamped} pixels - A reference to the context imageData buffer. - */ - this.pixels = this.imageData.data.buffer; + /** + * @property {UInt8Clamped} pixels - A reference to the context imageData buffer. + */ + if (this.imageData.data.buffer) + { + this.pixels = this.imageData.data.buffer; + } + else + { + this.pixels = this.imageData.data; + } - /** - * @property {PIXI.BaseTexture} baseTexture - The PIXI.BaseTexture. - * @default - */ + /** + * @property {PIXI.BaseTexture} baseTexture - The PIXI.BaseTexture. + * @default + */ this.baseTexture = new PIXI.BaseTexture(this.canvas); - /** - * @property {PIXI.Texture} texture - The PIXI.Texture. - * @default - */ + /** + * @property {PIXI.Texture} texture - The PIXI.Texture. + * @default + */ this.texture = new PIXI.Texture(this.baseTexture); - /** - * @property {Phaser.Frame} textureFrame - The Frame this BitmapData uses for rendering. - * @default - */ + /** + * @property {Phaser.Frame} textureFrame - The Frame this BitmapData uses for rendering. + * @default + */ this.textureFrame = new Phaser.Frame(0, 0, 0, width, height, 'bitmapData', game.rnd.uuid()); /** - * @property {number} type - The const type of this object. + * @property {number} type - The const type of this object. * @default - */ + */ this.type = Phaser.BITMAPDATA; - this._dirty = false; + this._dirty = false; } Phaser.BitmapData.prototype = { - /** - * Updates the given Sprite so that it uses this BitmapData as its texture. - * @method Phaser.BitmapData.add - * @param {Phaser.Sprite} sprite - The sprite to apply this texture to. - */ - add: function (sprite) { + /** + * Updates the given Sprite so that it uses this BitmapData as its texture. + * @method Phaser.BitmapData.add + * @param {Phaser.Sprite} sprite - The sprite to apply this texture to. + */ + add: function (sprite) { - sprite.loadTexture(this); - - }, - - /** - * Given an array of Sprites it will update each of them so that their Textures reference this BitmapData. - * @method Phaser.BitmapData.addTo - * @param {Phaser.Sprite[]} sprites - An array of Sprites to apply this texture to. - */ - addTo: function (sprites) { - - for (var i = 0; i < objects.length; i++) - { - if (objects[i].texture) - { - } - } - - }, - - /** - * Clears the BitmapData. - * @method Phaser.BitmapData.clear - */ - clear: function () { - - this.context.clearRect(0, 0, this.width, this.height); - - this._dirty = true; - - }, - - refreshBuffer: function () { - - this.imageData = this.context.getImageData(0, 0, this.width, this.height); - this.pixels = new Int32Array(this.imageData.data.buffer); - - // this.data8 = new Uint8ClampedArray(this.imageData.buffer); - // this.data32 = new Uint32Array(this.imageData.buffer); - - }, - - /** - * Sets the color of the given pixel to the specified red, green, blue and alpha values. - * @method Phaser.BitmapData.setPixel32 - * @param {number} x - The X coordinate of the pixel to be set. - * @param {number} y - The Y coordinate of the pixel to be set. - * @param {number} red - The red color value, between 0 and 0xFF (255). - * @param {number} green - The green color value, between 0 and 0xFF (255). - * @param {number} blue - The blue color value, between 0 and 0xFF (255). - * @param {number} alpha - The alpha color value, between 0 and 0xFF (255). - */ - setPixel32: function (x, y, red, green, blue, alpha) { - - if (x >= 0 && x <= this.width && y >= 0 && y <= this.height) - { - this.pixels[y * this.width + x] = (alpha << 24) | (blue << 16) | (green << 8) | red; - - /* - if (this.isLittleEndian) - { - this.data32[y * this.width + x] = (alpha << 24) | (blue << 16) | (green << 8) | red; - } - else - { - this.data32[y * this.width + x] = (red << 24) | (green << 16) | (blue << 8) | alpha; - } - */ - - // this.imageData.data.set(this.data8); - - this.context.putImageData(this.imageData, 0, 0); - - this._dirty = true; - } - - }, - - /** - * Sets the color of the given pixel to the specified red, green and blue values. - * @method Phaser.BitmapData.setPixel - * @param {number} x - The X coordinate of the pixel to be set. - * @param {number} y - The Y coordinate of the pixel to be set. - * @param {number} red - The red color value (between 0 and 255) - * @param {number} green - The green color value (between 0 and 255) - * @param {number} blue - The blue color value (between 0 and 255) - */ - setPixel: function (x, y, red, green, blue) { - - this.setPixel32(x, y, red, green, blue, 255); - - }, - - /** - * Get a color of a specific pixel. - * @param {number} x - The X coordinate of the pixel to get. - * @param {number} y - The Y coordinate of the pixel to get. - * @return {number} A native color value integer (format: 0xRRGGBB) - */ - getPixel: function (x, y) { - - if (x >= 0 && x <= this.width && y >= 0 && y <= this.height) - { - return this.data32[y * this.width + x]; - } - - }, - - /** - * Get a color of a specific pixel (including alpha value). - * @param {number} x - The X coordinate of the pixel to get. - * @param {number} y - The Y coordinate of the pixel to get. - * @return {number} A native color value integer (format: 0xAARRGGBB) - */ - getPixel32: function (x, y) { - - if (x >= 0 && x <= this.width && y >= 0 && y <= this.height) - { - return this.data32[y * this.width + x]; - } + sprite.loadTexture(this); }, /** - * Get pixels in array in a specific Rectangle. - * @param rect {Rectangle} The specific Rectangle. - * @return {array} CanvasPixelArray. - */ - getPixels: function (rect) { + * Given an array of Sprites it will update each of them so that their Textures reference this BitmapData. + * @method Phaser.BitmapData.addTo + * @param {Phaser.Sprite[]} sprites - An array of Sprites to apply this texture to. + */ + addTo: function (sprites) { - // return this.context.getImageData(rect.x, rect.y, rect.width, rect.height); + for (var i = 0; i < sprites.length; i++) + { + if (sprites[i].texture) + { + sprites[i].loadTexture(this); + } + } }, - /** - * Adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending at endAngle - * going in the given direction by anticlockwise (defaulting to clockwise). - * @method Phaser.BitmapData.arc - * @param {number} x - The x axis of the coordinate for the arc's center - * @param {number} y - The y axis of the coordinate for the arc's center - * @param {number} radius - The arc's radius - * @param {number} startAngle - The starting point, measured from the x axis, from which it will be drawn, expressed in radians. - * @param {number} endAngle - The end arc's angle to which it will be drawn, expressed in radians. - * @param {boolean} [anticlockwise=true] - true draws the arc anticlockwise, otherwise in a clockwise direction. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - arc: function (x, y, radius, startAngle, endAngle, anticlockwise) { - - if (typeof anticlockwise === 'undefined') { anticlockwise = false; } - - this._dirty = true; - this.context.arc(x, y, radius, startAngle, endAngle, anticlockwise); - return this; - - }, - - /** - * Adds an arc with the given control points and radius, connected to the previous point by a straight line. - * @method Phaser.BitmapData.arcTo - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @param {number} radius - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - arcTo: function (x1, y1, x2, y2, radius) { - - this._dirty = true; - this.context.arcTo(x1, y1, x2, y2, radius); - return this; - - }, - - /** - * Begins a fill with the specified color. This ends the current sub-path. - * @method Phaser.BitmapData.beginFill - * @param {string} color - A CSS compatible color value (ex. "red", "#FF0000", or "rgba(255,0,0,0.5)"). Setting to null will result in no fill. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - beginFill: function (color) { - - this.fillStyle(color); - - return this; - - }, - - /** - * Begins a linear gradient fill defined by the line (x0, y0) to (x1, y1). This ends the current sub-path. For - * example, the following code defines a black to white vertical gradient ranging from 20px to 120px, and draws a square to display it: - * - * ```myGraphics.beginLinearGradientFill(["#000","#FFF"], [0, 1], 0, 20, 0, 120).rect(20, 20, 120, 120);``` - * - * @method Phaser.BitmapData.beginLinearGradientFill - * @param {Array} colors - An array of CSS compatible color values. For example, ["#F00","#00F"] would define a gradient drawing from red to blue. - * @param {Array} ratios - An array of gradient positions which correspond to the colors. For example, [0.1, 0.9] would draw the first color to 10% then interpolating to the second color at 90%. - * @param {number} x0 - The position of the first point defining the line that defines the gradient direction and size. - * @param {number} y0 - The position of the first point defining the line that defines the gradient direction and size. - * @param {number} x1 - The position of the second point defining the line that defines the gradient direction and size. - * @param {number} y1 - The position of the second point defining the line that defines the gradient direction and size. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - beginLinearGradientFill: function (colors, ratios, x0, y0, x1, y1) { - - var gradient = this.createLinearGradient(x0, y0, x1, y1); - - for (var i = 0, len = colors.length; i < len; i++) - { - gradient.addColorStop(ratios[i], colors[i]); - } - - this.fillStyle(gradient); - - return this; - - }, - - /** - * Begins a linear gradient stroke defined by the line (x0, y0) to (x1, y1). This ends the current sub-path. For - * example, the following code defines a black to white vertical gradient ranging from 20px to 120px, and draws a - * square to display it: - * - * ```myGraphics.setStrokeStyle(10).beginLinearGradientStroke(["#000","#FFF"], [0, 1], 0, 20, 0, 120).drawRect(20, 20, 120, 120);``` - * - * @method Phaser.BitmapData.beginLinearGradientStroke - * @param {Array} colors - An array of CSS compatible color values. For example, ["#F00","#00F"] would define a gradient drawing from red to blue. - * @param {Array} ratios - An array of gradient positions which correspond to the colors. For example, [0.1, 0.9] would draw the first color to 10% then interpolating to the second color at 90%. - * @param {number} x0 - The position of the first point defining the line that defines the gradient direction and size. - * @param {number} y0 - The position of the first point defining the line that defines the gradient direction and size. - * @param {number} x1 - The position of the second point defining the line that defines the gradient direction and size. - * @param {number} y1 - The position of the second point defining the line that defines the gradient direction and size. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - beginLinearGradientStroke: function (colors, ratios, x0, y0, x1, y1) { - - var gradient = this.createLinearGradient(x0, y0, x1, y1); - - for (var i = 0, len = colors.length; i < len; i++) - { - gradient.addColorStop(ratios[i], colors[i]); - } - - this.strokeStyle(gradient); - - return this; - - }, - - /** - * Begins a radial gradient stroke. This ends the current sub-path. For example, the following code defines a red to - * blue radial gradient centered at (100, 100), with a radius of 50, and draws a rectangle to display it: - * - * myGraphics.setStrokeStyle(10) - * .beginRadialGradientStroke(["#F00","#00F"], [0, 1], 100, 100, 0, 100, 100, 50) - * .drawRect(50, 90, 150, 110); - * - * @method Phaser.BitmapData.beginRadialGradientStroke - * @param {Array} colors - An array of CSS compatible color values. For example, ["#F00","#00F"] would define a gradient drawing from red to blue. - * @param {Array} ratios - An array of gradient positions which correspond to the colors. For example, [0.1, 0.9] would draw the first color to 10% then interpolating to the second color at 90%. - * @param {number} x0 - Center position of the inner circle that defines the gradient. - * @param {number} y0 - Center position of the inner circle that defines the gradient. - * @param {number} r0 - Radius of the inner circle that defines the gradient. - * @param {number} x1 - Center position of the outer circle that defines the gradient. - * @param {number} y1 - Center position of the outer circle that defines the gradient. - * @param {number} r1 - Radius of the outer circle that defines the gradient. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - beginRadialGradientStroke: function (colors, ratios, x0, y0, r0, x1, y1, r1) { - - var gradient = this.createRadialGradient(x0, y0, r0, x1, y1, r1); - - for (var i = 0, len = colors.length; i < len; i++) - { - gradient.addColorStop(ratios[i], colors[i]); - } - - this.strokeStyle(gradient); - - return this; - - }, - - /** - * Starts a new path by resetting the list of sub-paths. Call this method when you want to create a new path. - * @method Phaser.BitmapData.beginPath - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - beginPath: function () { - - this.context.beginPath(); - return this; - - }, - - /** - * Begins a stroke with the specified color. This ends the current sub-path. - * @method Phaser.BitmapData.beginStroke - * @param {String} color A CSS compatible color value (ex. "#FF0000", "red", or "rgba(255,0,0,0.5)"). Setting to null will result in no stroke. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - beginStroke: function (color) { - - this.strokeStyle(color); - return this; - - }, - - /** - * Adds a bezier curve from the current context point to (x, y) using the control points (cp1x, cp1y) and (cp2x, cp2y). - * @method Phaser.BitmapData.bezierCurveTo - * @param {number} cp1x - The x axis of control point 1. - * @param {number} cp1y - The y axis of control point 1. - * @param {number} cp2x - The x axis of control point 2. - * @param {number} cp2y - The y axis of control point 2. - * @param {number} x - The x axis of the ending point. - * @param {number} y - The y axis of the ending point. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - bezierCurveTo: function (cp1x, cp1y, cp2x, cp2y, x, y) { - - this._dirty = true; - this.context.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y); - return this; - - }, - - /** - * Draws a circle with the specified radius at (x, y). - * @method Phaser.BitmapData.circle - * @param {number} x - x coordinate center point of circle. - * @param {number} y - y coordinate center point of circle. - * @param {number} radius - Radius of circle in radians. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - circle: function (x, y, radius) { - - this.arc(x, y, radius, 0, Math.PI*2); - return this; - - }, - - /** - * Sets all pixels in the rectangle defined by starting point (x, y) and size (width, height) to transparent black. - * @method Phaser.BitmapData.clearRect - * @param {number} x - The x axis of the coordinate for the rectangle starting point. - * @param {number} y - The y axis of the coordinate for the rectangle starting point. - * @param {number} width - The rectangles width. - * @param {number} height - The rectangles height. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - clearRect: function (x, y, width, height) { - - this._dirty = true; - this.context.clearRect(x, y, width, height); - return this; - - }, - - /** - * Creates a clipping path from the current sub-paths. Everything drawn after clip() is called appears inside the clipping path only. - * @method Phaser.BitmapData.clip - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - clip: function (x, y, width, height) { - - this._dirty = true; - this.context.clip(); - return this; - - }, - - /** - * Tries to draw a straight line from the current point to the start. If the shape has already been closed or has only one point, this function does nothing. - * @method Phaser.BitmapData.closePath - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - closePath: function () { - - this._dirty = true; - this.context.closePath(); - return this; - - }, - - /** - * Creates a linear gradient with defined by an imaginary line which implies the direction of the gradient. - * Once the gradient is created colors can be inserted using the addColorStop method. - * @method Phaser.BitmapData.createLinearGradient - * @param {number} x - The x axis of the coordinate for the gradients starting point. - * @param {number} y - The y axis of the coordinate for the gradients starting point. - * @param {number} width - The width of the gradient. - * @param {number} height - The height of the gradient. - * @return {CanvasGradient} The Linear Gradient. - */ - createLinearGradient: function (x, y, width, height) { - - return this.context.createLinearGradient(x, y, width, height); - - }, - - // createPattern - - /** - * Creates a radial gradient. - * @method Phaser.BitmapData.createRadialGradient - * @param {number} x0 - * @param {number} y0 - * @param {number} r0 - * @param {number} x1 - * @param {number} y1 - * @param {number} r1 - * @return {CanvasGradient} The Radial Gradient. - */ - createRadialGradient: function (x, y, width, height) { - - return this.context.createRadialGradient(x0, y0, r0, x1, y1, r1); - - }, - - // drawImage - // drawSystemFocusRing (?) - - /** - * Draws an ellipse (oval) with a specified width (w) and height (h). - * @method Phaser.BitmapData.ellipse - * @param {number} x - x coordinate center point of ellipse. - * @param {number} y - y coordinate center point of ellipse. - * @param {number} w - height (horizontal diameter) of ellipse. The horizontal radius will be half of this number. - * @param {number} h - width (vertical diameter) of ellipse. The vertical radius will be half of this number. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - ellipse: function (x, y, w, h) { - - var k = 0.5522848; - var ox = (w / 2) * k; - var oy = (h / 2) * k; - var xe = x + w; - var ye = y + h; - var xm = x + w / 2; - var ym = y + h / 2; - - this.moveTo(x, ym); - this.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y); - this.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym); - this.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye); - this.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym); - - return this; - - }, - - /** - * Fills the subpaths with the current fill style. - * @method Phaser.BitmapData.fill - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - fill: function () { - - this._dirty = true; - this.context.fill(); - return this; - - }, - - /** - * Draws a filled rectangle at (x, y) position whose size is determined by width and height. - * @method Phaser.BitmapData.fillRect - * @param {number} x - The x axis of the coordinate for the rectangle starting point. - * @param {number} y - The y axis of the coordinate for the rectangle starting point. - * @param {number} width - The rectangles width. - * @param {number} height - The rectangles height. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - fillRect: function (x, y, width, height) { - - this._dirty = true; - this.context.fillRect(x, y, width, height); - return this; - - }, - - /** - * Sets the fill style. - * @method Phaser.BitmapData.fillStyle - * @param {string} color - The fill color value in CSS format: #RRGGBB or rgba(r,g,b,a) - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - fillStyle: function (color) { - - this.context.fillStyle = color; - return this; - - }, - - // fillText - - /** - * Sets the font. - * @method Phaser.BitmapData.font - * @param {DOMString} font - The font to be used for any text rendering. Default value 10px sans-serif. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - font: function (font) { - - this.context.font = font; - return this; - - }, - - /** - * Alpha value that is applied to shapes and images before they are composited onto the canvas. Default 1.0 (opaque). - * @method Phaser.BitmapData.globalAlpha - * @param {number} alpha - Alpha value that is applied to shapes and images before they are composited onto the canvas. Default 1.0 (opaque). - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - globalAlpha: function (alpha) { - - this.context.globalAlpha = alpha; - return this; - - }, - - /** - * With globalAlpha applied this sets how shapes and images are drawn onto the existing bitmap. Possible values: source-atop, source-in, source-out, - * source-over (default), destination-atop, destination-in, destination-out, destination-over, lighter, darker, copy and xor. - * @method Phaser.BitmapData.globalCompositeOperation - * @param {DOMString} operation - The composite operation to apply. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - globalCompositeOperation: function (operation) { - - this.context.globalCompositeOperation = operation; - return this; - - }, - - /** - * Type of endings on the end of lines. Possible values: butt (default), round, square. - * @method Phaser.BitmapData.lineCap - * @param {DOMString} style - Possible values: butt (default), round, square - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - lineCap: function (style) { - - this.context.lineCap = style; - return this; - - }, - - /** - * Specifies where to start a dasharray on a line. - * @method Phaser.BitmapData.lineDashOffset - * @param {number} offset - Specifies where to start a dasharray on a line. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - lineDashOffset: function (offset) { - - this.context.lineDashOffset = offset; - return this; - - }, - - /** - * Defines the type of corners where two lines meet. Possible values: round, bevel, miter (default) - * @method Phaser.BitmapData.lineJoin - * @param {DOMString} join - Possible values: round, bevel, miter (default) - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - lineJoin: function (join) { - - this.context.lineJoin = join; - return this; - - }, - - /** - * Width of lines. Default 1.0 - * @method Phaser.BitmapData.lineWidth - * @param {number} width - Width of lines. Default 1.0 - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - lineWidth: function (width) { - - this.context.lineWidth = width; - return this; - - }, - - /** - * Default 10. - * @method Phaser.BitmapData.miterLimit - * @param {number} limit - Default 10. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - miterLimit: function (limit) { - - this.context.miterLimit = limit; - return this; - - }, - - // getImageData - // getLineDash - // isPointInPath - // isPointInStroke - - /** - * Connects the last point in the subpath to the x, y coordinates with a straight line. - * @method Phaser.BitmapData.lineTo - * @param {number} x - The x axis of the coordinate for the end of the line. - * @param {number} y - The y axis of the coordinate for the end of the line. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - lineTo: function (x, y) { - - this._dirty = true; - this.context.lineTo(x, y); - return this; - - }, - - // measureText - - /** - * Moves the starting point of a new subpath to the (x, y) coordinates. - * @method Phaser.BitmapData.moveTo - * @param {number} x - The x axis of the point. - * @param {number} y - The y axis of the point. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - moveTo: function (x, y) { - - this.context.moveTo(x, y); - return this; - - }, - - // putImageData - - /** - * Draws a quadratic curve from the current drawing point to (x, y) using the control point (cpx, cpy). - * @method Phaser.BitmapData.quadraticCurveTo - * @param {Number} cpx - The x axis of the control point. - * @param {Number} cpy - The y axis of the control point. - * @param {Number} x - The x axis of the ending point. - * @param {Number} y - The y axis of the ending point. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - quadraticCurveTo: function(cpx, cpy, x, y) { - - this._dirty = true; - this.context.quadraticCurveTo(cpx, cpy, x, y); - return this; - - }, - - /** - * Draws a rectangle at (x, y) position whose size is determined by width and height. - * @method Phaser.BitmapData.rect - * @param {number} x - The x axis of the coordinate for the rectangle starting point. - * @param {number} y - The y axis of the coordinate for the rectangle starting point. - * @param {number} width - The rectangles width. - * @param {number} height - The rectangles height. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - rect: function (x, y, width, height) { - - this._dirty = true; - this.context.rect(x, y, width, height); - return this; - - }, - - /** - * Restores the drawing style state to the last element on the 'state stack' saved by save(). - * @method Phaser.BitmapData.restore - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - restore: function () { - - this._dirty = true; - this.context.restore(); - return this; - - }, - - /** - * Rotates the drawing context values by r radians. - * @method Phaser.BitmapData.rotate - * @param {number} angle - The angle of rotation given in radians. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - rotate: function (angle) { - - this._dirty = true; - this.context.rotate(angle); - return this; - - }, - - /** - * Sets the stroke style for the current sub-path. Like all drawing methods, this can be chained, so you can define - * the stroke style and color in a single line of code like so: - * - * ```myGraphics.setStrokeStyle(8,"round").beginStroke("#F00");``` - * - * @method Phaser.BitmapData.setStrokeStyle - * @param {number} thickness - The width of the stroke. - * @param {string|number} [caps=0] - Indicates the type of caps to use at the end of lines. One of butt, round, or square. Defaults to "butt". Also accepts the values 0 (butt), 1 (round), and 2 (square) for use with he tiny API. - * @param {string|number} [joints=0] Specifies the type of joints that should be used where two lines meet. One of bevel, round, or miter. Defaults to "miter". Also accepts the values 0 (miter), 1 (round), and 2 (bevel) for use with the tiny API. - * @param {number} [miterLimit=10] - If joints is set to "miter", then you can specify a miter limit ratio which controls at what point a mitered joint will be clipped. - * @param {boolean} [ignoreScale=false] - If true, the stroke will be drawn at the specified thickness regardless of active transformations. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - setStrokeStyle: function (thickness, caps, joints, miterLimit, ignoreScale) { - - if (typeof thickness === 'undefined') { thickness = 1; } - if (typeof caps === 'undefined') { caps = 'butt'; } - if (typeof joints === 'undefined') { joints = 'miter'; } - if (typeof miterLimit === 'undefined') { miterLimit = 10; } - - this.lineWidth(thickness); - this.lineCap(caps); - this.lineJoin(joints); - this.miterLimit(miterLimit); - - return this; - - }, - - /** - * Saves the current drawing style state using a stack so you can revert any change you make to it using restore(). - * @method Phaser.BitmapData.save - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - save: function () { - - this._dirty = true; - this.context.save(); - return this; - - }, - - /** - * Scales the current drawing context. - * @method Phaser.BitmapData.scale - * @param {number} x - * @param {number} y - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - scale: function (x, y) { - - this._dirty = true; - this.context.scale(x, y); - return this; - - }, - - /** - * - * @method Phaser.BitmapData.scrollPathIntoView - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - scrollPathIntoView: function () { - - this._dirty = true; - this.context.scrollPathIntoView(); - return this; - - }, - - // setLineDash - // setTransform - - /** - * Strokes the subpaths with the current stroke style. - * @method Phaser.BitmapData.stroke - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - stroke: function () { - - this._dirty = true; - this.context.stroke(); - return this; - - }, - - /** - * Paints a rectangle which has a starting point at (x, y) and has a w width and an h height onto the canvas, using the current stroke style. - * @method Phaser.BitmapData.strokeRect - * @param {number} x - The x axis for the starting point of the rectangle. - * @param {number} y - The y axis for the starting point of the rectangle. - * @param {number} width - The rectangles width. - * @param {number} height - The rectangles height. - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - strokeRect: function () { - - this._dirty = true; - this.context.strokeRect(x, y, width, height); - return this; - - }, - - /** - * Color or style to use for the lines around shapes. Default #000 (black). - * @method Phaser.BitmapData.strokeStyle - * @param {string} style - Color or style to use for the lines around shapes. Default #000 (black). - * @return {Phaser.BitmapData} The BitmapData instance this method was called on. - */ - strokeStyle: function (style) { - - this.context.strokeStyle = style; - return this; - - }, - - // strokeText - // transform - // translate - - /** - * If the game is running in WebGL this will push the texture up to the GPU if it's dirty. - * This is called automatically if the BitmapData is being used by a Sprite, otherwise you need to remember to call it in your render function. - * @method Phaser.BitmapData.render - */ - render: function () { - - if (this._dirty) - { - // Only needed if running in WebGL, otherwise this array will never get cleared down - if (this.game.renderType == Phaser.WEBGL) - { - PIXI.texturesToUpdate.push(this.baseTexture); - } - - this._dirty = false; - } - - } + /** + * Clears the BitmapData. + * @method Phaser.BitmapData.clear + */ + clear: function () { + + this.context.clearRect(0, 0, this.width, this.height); + + this._dirty = true; + + }, + + refreshBuffer: function () { + + this.imageData = this.context.getImageData(0, 0, this.width, this.height); + this.pixels = new Int32Array(this.imageData.data.buffer); + + // this.data8 = new Uint8ClampedArray(this.imageData.buffer); + // this.data32 = new Uint32Array(this.imageData.buffer); + + }, + + /** + * Sets the color of the given pixel to the specified red, green, blue and alpha values. + * @method Phaser.BitmapData.setPixel32 + * @param {number} x - The X coordinate of the pixel to be set. + * @param {number} y - The Y coordinate of the pixel to be set. + * @param {number} red - The red color value, between 0 and 0xFF (255). + * @param {number} green - The green color value, between 0 and 0xFF (255). + * @param {number} blue - The blue color value, between 0 and 0xFF (255). + * @param {number} alpha - The alpha color value, between 0 and 0xFF (255). + */ + setPixel32: function (x, y, red, green, blue, alpha) { + + if (x >= 0 && x <= this.width && y >= 0 && y <= this.height) + { + this.pixels[y * this.width + x] = (alpha << 24) | (blue << 16) | (green << 8) | red; + + /* + if (this.isLittleEndian) + { + this.data32[y * this.width + x] = (alpha << 24) | (blue << 16) | (green << 8) | red; + } + else + { + this.data32[y * this.width + x] = (red << 24) | (green << 16) | (blue << 8) | alpha; + } + */ + + // this.imageData.data.set(this.data8); + + this.context.putImageData(this.imageData, 0, 0); + + this._dirty = true; + } + + }, + + /** + * Sets the color of the given pixel to the specified red, green and blue values. + * @method Phaser.BitmapData.setPixel + * @param {number} x - The X coordinate of the pixel to be set. + * @param {number} y - The Y coordinate of the pixel to be set. + * @param {number} red - The red color value (between 0 and 255) + * @param {number} green - The green color value (between 0 and 255) + * @param {number} blue - The blue color value (between 0 and 255) + */ + setPixel: function (x, y, red, green, blue) { + + this.setPixel32(x, y, red, green, blue, 255); + + }, + + /** + * Get a color of a specific pixel. + * @param {number} x - The X coordinate of the pixel to get. + * @param {number} y - The Y coordinate of the pixel to get. + * @return {number} A native color value integer (format: 0xRRGGBB) + */ + getPixel: function (x, y) { + + if (x >= 0 && x <= this.width && y >= 0 && y <= this.height) + { + return this.data32[y * this.width + x]; + } + + }, + + /** + * Get a color of a specific pixel (including alpha value). + * @param {number} x - The X coordinate of the pixel to get. + * @param {number} y - The Y coordinate of the pixel to get. + * @return {number} A native color value integer (format: 0xAARRGGBB) + */ + getPixel32: function (x, y) { + + if (x >= 0 && x <= this.width && y >= 0 && y <= this.height) + { + return this.data32[y * this.width + x]; + } + + }, + + /** + * Get pixels in array in a specific Rectangle. + * @param rect {Rectangle} The specific Rectangle. + * @return {array} CanvasPixelArray. + */ + getPixels: function (rect) { + + return this.context.getImageData(rect.x, rect.y, rect.width, rect.height); + + }, + + /** + * Adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending at endAngle + * going in the given direction by anticlockwise (defaulting to clockwise). + * @method Phaser.BitmapData.arc + * @param {number} x - The x axis of the coordinate for the arc's center + * @param {number} y - The y axis of the coordinate for the arc's center + * @param {number} radius - The arc's radius + * @param {number} startAngle - The starting point, measured from the x axis, from which it will be drawn, expressed in radians. + * @param {number} endAngle - The end arc's angle to which it will be drawn, expressed in radians. + * @param {boolean} [anticlockwise=true] - true draws the arc anticlockwise, otherwise in a clockwise direction. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + arc: function (x, y, radius, startAngle, endAngle, anticlockwise) { + + if (typeof anticlockwise === 'undefined') { anticlockwise = false; } + + this._dirty = true; + this.context.arc(x, y, radius, startAngle, endAngle, anticlockwise); + return this; + + }, + + /** + * Adds an arc with the given control points and radius, connected to the previous point by a straight line. + * @method Phaser.BitmapData.arcTo + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @param {number} radius + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + arcTo: function (x1, y1, x2, y2, radius) { + + this._dirty = true; + this.context.arcTo(x1, y1, x2, y2, radius); + return this; + + }, + + /** + * Begins a fill with the specified color. This ends the current sub-path. + * @method Phaser.BitmapData.beginFill + * @param {string} color - A CSS compatible color value (ex. "red", "#FF0000", or "rgba(255,0,0,0.5)"). Setting to null will result in no fill. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + beginFill: function (color) { + + this.fillStyle(color); + + return this; + + }, + + /** + * Begins a linear gradient fill defined by the line (x0, y0) to (x1, y1). This ends the current sub-path. For + * example, the following code defines a black to white vertical gradient ranging from 20px to 120px, and draws a square to display it: + * + * ```myGraphics.beginLinearGradientFill(["#000","#FFF"], [0, 1], 0, 20, 0, 120).rect(20, 20, 120, 120);``` + * + * @method Phaser.BitmapData.beginLinearGradientFill + * @param {Array} colors - An array of CSS compatible color values. For example, ["#F00","#00F"] would define a gradient drawing from red to blue. + * @param {Array} ratios - An array of gradient positions which correspond to the colors. For example, [0.1, 0.9] would draw the first color to 10% then interpolating to the second color at 90%. + * @param {number} x0 - The position of the first point defining the line that defines the gradient direction and size. + * @param {number} y0 - The position of the first point defining the line that defines the gradient direction and size. + * @param {number} x1 - The position of the second point defining the line that defines the gradient direction and size. + * @param {number} y1 - The position of the second point defining the line that defines the gradient direction and size. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + beginLinearGradientFill: function (colors, ratios, x0, y0, x1, y1) { + + var gradient = this.createLinearGradient(x0, y0, x1, y1); + + for (var i = 0, len = colors.length; i < len; i++) + { + gradient.addColorStop(ratios[i], colors[i]); + } + + this.fillStyle(gradient); + + return this; + + }, + + /** + * Begins a linear gradient stroke defined by the line (x0, y0) to (x1, y1). This ends the current sub-path. For + * example, the following code defines a black to white vertical gradient ranging from 20px to 120px, and draws a + * square to display it: + * + * ```myGraphics.setStrokeStyle(10).beginLinearGradientStroke(["#000","#FFF"], [0, 1], 0, 20, 0, 120).drawRect(20, 20, 120, 120);``` + * + * @method Phaser.BitmapData.beginLinearGradientStroke + * @param {Array} colors - An array of CSS compatible color values. For example, ["#F00","#00F"] would define a gradient drawing from red to blue. + * @param {Array} ratios - An array of gradient positions which correspond to the colors. For example, [0.1, 0.9] would draw the first color to 10% then interpolating to the second color at 90%. + * @param {number} x0 - The position of the first point defining the line that defines the gradient direction and size. + * @param {number} y0 - The position of the first point defining the line that defines the gradient direction and size. + * @param {number} x1 - The position of the second point defining the line that defines the gradient direction and size. + * @param {number} y1 - The position of the second point defining the line that defines the gradient direction and size. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + beginLinearGradientStroke: function (colors, ratios, x0, y0, x1, y1) { + + var gradient = this.createLinearGradient(x0, y0, x1, y1); + + for (var i = 0, len = colors.length; i < len; i++) + { + gradient.addColorStop(ratios[i], colors[i]); + } + + this.strokeStyle(gradient); + + return this; + + }, + + /** + * Begins a radial gradient stroke. This ends the current sub-path. For example, the following code defines a red to + * blue radial gradient centered at (100, 100), with a radius of 50, and draws a rectangle to display it: + * + * myGraphics.setStrokeStyle(10) + * .beginRadialGradientStroke(["#F00","#00F"], [0, 1], 100, 100, 0, 100, 100, 50) + * .drawRect(50, 90, 150, 110); + * + * @method Phaser.BitmapData.beginRadialGradientStroke + * @param {Array} colors - An array of CSS compatible color values. For example, ["#F00","#00F"] would define a gradient drawing from red to blue. + * @param {Array} ratios - An array of gradient positions which correspond to the colors. For example, [0.1, 0.9] would draw the first color to 10% then interpolating to the second color at 90%. + * @param {number} x0 - Center position of the inner circle that defines the gradient. + * @param {number} y0 - Center position of the inner circle that defines the gradient. + * @param {number} r0 - Radius of the inner circle that defines the gradient. + * @param {number} x1 - Center position of the outer circle that defines the gradient. + * @param {number} y1 - Center position of the outer circle that defines the gradient. + * @param {number} r1 - Radius of the outer circle that defines the gradient. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + beginRadialGradientStroke: function (colors, ratios, x0, y0, r0, x1, y1, r1) { + + var gradient = this.createRadialGradient(x0, y0, r0, x1, y1, r1); + + for (var i = 0, len = colors.length; i < len; i++) + { + gradient.addColorStop(ratios[i], colors[i]); + } + + this.strokeStyle(gradient); + + return this; + + }, + + /** + * Starts a new path by resetting the list of sub-paths. Call this method when you want to create a new path. + * @method Phaser.BitmapData.beginPath + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + beginPath: function () { + + this.context.beginPath(); + return this; + + }, + + /** + * Begins a stroke with the specified color. This ends the current sub-path. + * @method Phaser.BitmapData.beginStroke + * @param {String} color A CSS compatible color value (ex. "#FF0000", "red", or "rgba(255,0,0,0.5)"). Setting to null will result in no stroke. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + beginStroke: function (color) { + + this.strokeStyle(color); + return this; + + }, + + /** + * Adds a bezier curve from the current context point to (x, y) using the control points (cp1x, cp1y) and (cp2x, cp2y). + * @method Phaser.BitmapData.bezierCurveTo + * @param {number} cp1x - The x axis of control point 1. + * @param {number} cp1y - The y axis of control point 1. + * @param {number} cp2x - The x axis of control point 2. + * @param {number} cp2y - The y axis of control point 2. + * @param {number} x - The x axis of the ending point. + * @param {number} y - The y axis of the ending point. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + bezierCurveTo: function (cp1x, cp1y, cp2x, cp2y, x, y) { + + this._dirty = true; + this.context.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y); + return this; + + }, + + /** + * Draws a circle with the specified radius at (x, y). + * @method Phaser.BitmapData.circle + * @param {number} x - x coordinate center point of circle. + * @param {number} y - y coordinate center point of circle. + * @param {number} radius - Radius of circle in radians. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + circle: function (x, y, radius) { + + this.arc(x, y, radius, 0, Math.PI*2); + return this; + + }, + + /** + * Sets all pixels in the rectangle defined by starting point (x, y) and size (width, height) to transparent black. + * @method Phaser.BitmapData.clearRect + * @param {number} x - The x axis of the coordinate for the rectangle starting point. + * @param {number} y - The y axis of the coordinate for the rectangle starting point. + * @param {number} width - The rectangles width. + * @param {number} height - The rectangles height. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + clearRect: function (x, y, width, height) { + + this._dirty = true; + this.context.clearRect(x, y, width, height); + return this; + + }, + + /** + * Creates a clipping path from the current sub-paths. Everything drawn after clip() is called appears inside the clipping path only. + * @method Phaser.BitmapData.clip + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + clip: function () { + + this._dirty = true; + this.context.clip(); + return this; + + }, + + /** + * Tries to draw a straight line from the current point to the start. If the shape has already been closed or has only one point, this function does nothing. + * @method Phaser.BitmapData.closePath + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + closePath: function () { + + this._dirty = true; + this.context.closePath(); + return this; + + }, + + /** + * Creates a linear gradient with defined by an imaginary line which implies the direction of the gradient. + * Once the gradient is created colors can be inserted using the addColorStop method. + * @method Phaser.BitmapData.createLinearGradient + * @param {number} x - The x axis of the coordinate for the gradients starting point. + * @param {number} y - The y axis of the coordinate for the gradients starting point. + * @param {number} width - The width of the gradient. + * @param {number} height - The height of the gradient. + * @return {CanvasGradient} The Linear Gradient. + */ + createLinearGradient: function (x, y, width, height) { + + return this.context.createLinearGradient(x, y, width, height); + + }, + + // createPattern + + /** + * Creates a radial gradient. + * @method Phaser.BitmapData.createRadialGradient + * @param {number} x0 + * @param {number} y0 + * @param {number} r0 + * @param {number} x1 + * @param {number} y1 + * @param {number} r1 + * @return {CanvasGradient} The Radial Gradient. + */ + createRadialGradient: function (x0, y0, r0, x1, y1, r1) { + + return this.context.createRadialGradient(x0, y0, r0, x1, y1, r1); + + }, + + // drawImage + // drawSystemFocusRing (?) + + /** + * Draws an ellipse (oval) with a specified width (w) and height (h). + * @method Phaser.BitmapData.ellipse + * @param {number} x - x coordinate center point of ellipse. + * @param {number} y - y coordinate center point of ellipse. + * @param {number} w - height (horizontal diameter) of ellipse. The horizontal radius will be half of this number. + * @param {number} h - width (vertical diameter) of ellipse. The vertical radius will be half of this number. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + ellipse: function (x, y, w, h) { + + var k = 0.5522848; + var ox = (w / 2) * k; + var oy = (h / 2) * k; + var xe = x + w; + var ye = y + h; + var xm = x + w / 2; + var ym = y + h / 2; + + this.moveTo(x, ym); + this.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y); + this.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym); + this.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye); + this.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym); + + return this; + + }, + + /** + * Fills the subpaths with the current fill style. + * @method Phaser.BitmapData.fill + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + fill: function () { + + this._dirty = true; + this.context.fill(); + return this; + + }, + + /** + * Draws a filled rectangle at (x, y) position whose size is determined by width and height. + * @method Phaser.BitmapData.fillRect + * @param {number} x - The x axis of the coordinate for the rectangle starting point. + * @param {number} y - The y axis of the coordinate for the rectangle starting point. + * @param {number} width - The rectangles width. + * @param {number} height - The rectangles height. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + fillRect: function (x, y, width, height) { + + this._dirty = true; + this.context.fillRect(x, y, width, height); + return this; + + }, + + /** + * Sets the fill style. + * @method Phaser.BitmapData.fillStyle + * @param {string} color - The fill color value in CSS format: #RRGGBB or rgba(r,g,b,a) + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + fillStyle: function (color) { + + this.context.fillStyle = color; + return this; + + }, + + // fillText + + /** + * Sets the font. + * @method Phaser.BitmapData.font + * @param {DOMString} font - The font to be used for any text rendering. Default value 10px sans-serif. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + font: function (font) { + + this.context.font = font; + return this; + + }, + + /** + * Alpha value that is applied to shapes and images before they are composited onto the canvas. Default 1.0 (opaque). + * @method Phaser.BitmapData.globalAlpha + * @param {number} alpha - Alpha value that is applied to shapes and images before they are composited onto the canvas. Default 1.0 (opaque). + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + globalAlpha: function (alpha) { + + this.context.globalAlpha = alpha; + return this; + + }, + + /** + * With globalAlpha applied this sets how shapes and images are drawn onto the existing bitmap. Possible values: source-atop, source-in, source-out, + * source-over (default), destination-atop, destination-in, destination-out, destination-over, lighter, darker, copy and xor. + * @method Phaser.BitmapData.globalCompositeOperation + * @param {DOMString} operation - The composite operation to apply. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + globalCompositeOperation: function (operation) { + + this.context.globalCompositeOperation = operation; + return this; + + }, + + /** + * Type of endings on the end of lines. Possible values: butt (default), round, square. + * @method Phaser.BitmapData.lineCap + * @param {DOMString} style - Possible values: butt (default), round, square + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + lineCap: function (style) { + + this.context.lineCap = style; + return this; + + }, + + /** + * Specifies where to start a dasharray on a line. + * @method Phaser.BitmapData.lineDashOffset + * @param {number} offset - Specifies where to start a dasharray on a line. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + lineDashOffset: function (offset) { + + this.context.lineDashOffset = offset; + return this; + + }, + + /** + * Defines the type of corners where two lines meet. Possible values: round, bevel, miter (default) + * @method Phaser.BitmapData.lineJoin + * @param {DOMString} join - Possible values: round, bevel, miter (default) + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + lineJoin: function (join) { + + this.context.lineJoin = join; + return this; + + }, + + /** + * Width of lines. Default 1.0 + * @method Phaser.BitmapData.lineWidth + * @param {number} width - Width of lines. Default 1.0 + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + lineWidth: function (width) { + + this.context.lineWidth = width; + return this; + + }, + + /** + * Default 10. + * @method Phaser.BitmapData.miterLimit + * @param {number} limit - Default 10. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + miterLimit: function (limit) { + + this.context.miterLimit = limit; + return this; + + }, + + // getImageData + // getLineDash + // isPointInPath + // isPointInStroke + + /** + * Connects the last point in the subpath to the x, y coordinates with a straight line. + * @method Phaser.BitmapData.lineTo + * @param {number} x - The x axis of the coordinate for the end of the line. + * @param {number} y - The y axis of the coordinate for the end of the line. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + lineTo: function (x, y) { + + this._dirty = true; + this.context.lineTo(x, y); + return this; + + }, + + // measureText + + /** + * Moves the starting point of a new subpath to the (x, y) coordinates. + * @method Phaser.BitmapData.moveTo + * @param {number} x - The x axis of the point. + * @param {number} y - The y axis of the point. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + moveTo: function (x, y) { + + this.context.moveTo(x, y); + return this; + + }, + + // putImageData + + /** + * Draws a quadratic curve from the current drawing point to (x, y) using the control point (cpx, cpy). + * @method Phaser.BitmapData.quadraticCurveTo + * @param {Number} cpx - The x axis of the control point. + * @param {Number} cpy - The y axis of the control point. + * @param {Number} x - The x axis of the ending point. + * @param {Number} y - The y axis of the ending point. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + quadraticCurveTo: function(cpx, cpy, x, y) { + + this._dirty = true; + this.context.quadraticCurveTo(cpx, cpy, x, y); + return this; + + }, + + /** + * Draws a rectangle at (x, y) position whose size is determined by width and height. + * @method Phaser.BitmapData.rect + * @param {number} x - The x axis of the coordinate for the rectangle starting point. + * @param {number} y - The y axis of the coordinate for the rectangle starting point. + * @param {number} width - The rectangles width. + * @param {number} height - The rectangles height. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + rect: function (x, y, width, height) { + + this._dirty = true; + this.context.rect(x, y, width, height); + return this; + + }, + + /** + * Restores the drawing style state to the last element on the 'state stack' saved by save(). + * @method Phaser.BitmapData.restore + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + restore: function () { + + this._dirty = true; + this.context.restore(); + return this; + + }, + + /** + * Rotates the drawing context values by r radians. + * @method Phaser.BitmapData.rotate + * @param {number} angle - The angle of rotation given in radians. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + rotate: function (angle) { + + this._dirty = true; + this.context.rotate(angle); + return this; + + }, + + /** + * Sets the stroke style for the current sub-path. Like all drawing methods, this can be chained, so you can define + * the stroke style and color in a single line of code like so: + * + * ```myGraphics.setStrokeStyle(8,"round").beginStroke("#F00");``` + * + * @method Phaser.BitmapData.setStrokeStyle + * @param {number} thickness - The width of the stroke. + * @param {string|number} [caps=0] - Indicates the type of caps to use at the end of lines. One of butt, round, or square. Defaults to "butt". Also accepts the values 0 (butt), 1 (round), and 2 (square) for use with he tiny API. + * @param {string|number} [joints=0] Specifies the type of joints that should be used where two lines meet. One of bevel, round, or miter. Defaults to "miter". Also accepts the values 0 (miter), 1 (round), and 2 (bevel) for use with the tiny API. + * @param {number} [miterLimit=10] - If joints is set to "miter", then you can specify a miter limit ratio which controls at what point a mitered joint will be clipped. + * @param {boolean} [ignoreScale=false] - If true, the stroke will be drawn at the specified thickness regardless of active transformations. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + setStrokeStyle: function (thickness, caps, joints, miterLimit, ignoreScale) { + + if (typeof thickness === 'undefined') { thickness = 1; } + if (typeof caps === 'undefined') { caps = 'butt'; } + if (typeof joints === 'undefined') { joints = 'miter'; } + if (typeof miterLimit === 'undefined') { miterLimit = 10; } + + // TODO + ignoreScale = false; + + this.lineWidth(thickness); + this.lineCap(caps); + this.lineJoin(joints); + this.miterLimit(miterLimit); + + return this; + + }, + + /** + * Saves the current drawing style state using a stack so you can revert any change you make to it using restore(). + * @method Phaser.BitmapData.save + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + save: function () { + + this._dirty = true; + this.context.save(); + return this; + + }, + + /** + * Scales the current drawing context. + * @method Phaser.BitmapData.scale + * @param {number} x + * @param {number} y + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + scale: function (x, y) { + + this._dirty = true; + this.context.scale(x, y); + return this; + + }, + + /** + * + * @method Phaser.BitmapData.scrollPathIntoView + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + scrollPathIntoView: function () { + + this._dirty = true; + this.context.scrollPathIntoView(); + return this; + + }, + + // setLineDash + // setTransform + + /** + * Strokes the subpaths with the current stroke style. + * @method Phaser.BitmapData.stroke + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + stroke: function () { + + this._dirty = true; + this.context.stroke(); + return this; + + }, + + /** + * Paints a rectangle which has a starting point at (x, y) and has a w width and an h height onto the canvas, using the current stroke style. + * @method Phaser.BitmapData.strokeRect + * @param {number} x - The x axis for the starting point of the rectangle. + * @param {number} y - The y axis for the starting point of the rectangle. + * @param {number} width - The rectangles width. + * @param {number} height - The rectangles height. + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + strokeRect: function (x, y, width, height) { + + this._dirty = true; + this.context.strokeRect(x, y, width, height); + return this; + + }, + + /** + * Color or style to use for the lines around shapes. Default #000 (black). + * @method Phaser.BitmapData.strokeStyle + * @param {string} style - Color or style to use for the lines around shapes. Default #000 (black). + * @return {Phaser.BitmapData} The BitmapData instance this method was called on. + */ + strokeStyle: function (style) { + + this.context.strokeStyle = style; + return this; + + }, + + // strokeText + // transform + // translate + + /** + * If the game is running in WebGL this will push the texture up to the GPU if it's dirty. + * This is called automatically if the BitmapData is being used by a Sprite, otherwise you need to remember to call it in your render function. + * @method Phaser.BitmapData.render + */ + render: function () { + + if (this._dirty) + { + // Only needed if running in WebGL, otherwise this array will never get cleared down + if (this.game.renderType == Phaser.WEBGL) + { + PIXI.texturesToUpdate.push(this.baseTexture); + } + + this._dirty = false; + } + + } } -// EaselJS Tiny API emulation +// EaselJS Tiny API emulation /** * Shortcut to moveTo. @@ -19226,13 +19601,13 @@ Phaser.BitmapData.prototype.at = Phaser.BitmapData.prototype.arcTo; * @method Phaser.BitmapData.prototype.bt */ Phaser.BitmapData.prototype.bt = Phaser.BitmapData.prototype.bezierCurveTo; - + /** * Shortcut to quadraticCurveTo. * @method Phaser.BitmapData.prototype.qt */ Phaser.BitmapData.prototype.qt = Phaser.BitmapData.prototype.quadraticCurveTo; - + /** * Shortcut to arc. * @method Phaser.BitmapData.prototype.a @@ -19244,7 +19619,7 @@ Phaser.BitmapData.prototype.a = Phaser.BitmapData.prototype.arc; * @method Phaser.BitmapData.prototype.r */ Phaser.BitmapData.prototype.r = Phaser.BitmapData.prototype.rect; - + /** * Shortcut to closePath. * @method Phaser.BitmapData.prototype.cp @@ -19256,7 +19631,7 @@ Phaser.BitmapData.prototype.cp = Phaser.BitmapData.prototype.closePath; * @method Phaser.BitmapData.prototype.c */ Phaser.BitmapData.prototype.c = Phaser.BitmapData.prototype.clear; - + /** * Shortcut to beginFill. * @method Phaser.BitmapData.prototype.f @@ -19268,19 +19643,19 @@ Phaser.BitmapData.prototype.f = Phaser.BitmapData.prototype.beginFill; * @method Phaser.BitmapData.prototype.lf */ Phaser.BitmapData.prototype.lf = Phaser.BitmapData.prototype.beginLinearGradientFill; - + /** * Shortcut to beginRadialGradientFill. * @method Phaser.BitmapData.prototype.rf */ Phaser.BitmapData.prototype.rf = Phaser.BitmapData.prototype.beginRadialGradientFill; - + /** * Shortcut to beginBitmapFill. * @method Phaser.BitmapData.prototype.bf */ //Phaser.BitmapData.prototype.bf = Phaser.BitmapData.prototype.beginBitmapFill; - + /** * Shortcut to endFill. * @method Phaser.BitmapData.prototype.ef @@ -19292,13 +19667,13 @@ Phaser.BitmapData.prototype.ef = Phaser.BitmapData.prototype.endFill; * @method Phaser.BitmapData.prototype.ss */ Phaser.BitmapData.prototype.ss = Phaser.BitmapData.prototype.setStrokeStyle; - + /** * Shortcut to beginStroke. * @method Phaser.BitmapData.prototype.s */ Phaser.BitmapData.prototype.s = Phaser.BitmapData.prototype.beginStroke; - + /** * Shortcut to beginLinearGradientStroke. * @method Phaser.BitmapData.prototype.ls @@ -19310,31 +19685,31 @@ Phaser.BitmapData.prototype.ls = Phaser.BitmapData.prototype.beginLinearGradient * @method Phaser.BitmapData.prototype.rs */ Phaser.BitmapData.prototype.rs = Phaser.BitmapData.prototype.beginRadialGradientStroke; - + /** * Shortcut to beginBitmapStroke. * @method Phaser.BitmapData.prototype.bs */ // Phaser.BitmapData.prototype.bs = Phaser.BitmapData.prototype.beginBitmapStroke; - + /** * Shortcut to endStroke. * @method Phaser.BitmapData.prototype.es */ // Phaser.BitmapData.prototype.es = Phaser.BitmapData.prototype.endStroke; - + /** * Shortcut to rect. * @method Phaser.BitmapData.prototype.dr */ Phaser.BitmapData.prototype.dr = Phaser.BitmapData.prototype.rect; - + /** * Shortcut to drawRoundRect. * @method Phaser.BitmapData.prototype.rr */ // Phaser.BitmapData.prototype.rr = Phaser.BitmapData.prototype.drawRoundRect; - + /** * Shortcut to drawRoundRectComplex. * @method Phaser.BitmapData.prototype.rc @@ -19346,13 +19721,13 @@ Phaser.BitmapData.prototype.dr = Phaser.BitmapData.prototype.rect; * @method Phaser.BitmapData.prototype.dc */ Phaser.BitmapData.prototype.dc = Phaser.BitmapData.prototype.circle; - + /** * Shortcut to drawEllipse. * @method Phaser.BitmapData.prototype.de */ Phaser.BitmapData.prototype.de = Phaser.BitmapData.prototype.ellipse; - + /** * Shortcut to drawPolyStar. * @method Phaser.BitmapData.prototype.dp @@ -19387,55 +19762,55 @@ Phaser.Sprite = function (game, x, y, key, frame) { frame = frame || null; /** - * @property {Phaser.Game} game - A reference to the currently running Game. - */ - this.game = game; + * @property {Phaser.Game} game - A reference to the currently running Game. + */ + this.game = game; - /** - * @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all. - * @default - */ + /** + * @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all. + * @default + */ this.exists = true; - /** + /** * @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering. - * @default - */ + * @default + */ this.alive = true; - /** + /** * @property {Phaser.Group} group - The parent Group of this Sprite. This is usually set after Sprite instantiation by the parent. - */ + */ this.group = null; /** - * @property {string} name - The user defined name given to this Sprite. - * @default - */ + * @property {string} name - The user defined name given to this Sprite. + * @default + */ this.name = ''; /** - * @property {number} type - The const type of this object. - * @default - */ + * @property {number} type - The const type of this object. + * @readonly + */ this.type = Phaser.SPRITE; /** - * @property {number} renderOrderID - Used by the Renderer and Input Manager to control picking order. - * @default - */ + * @property {number} renderOrderID - Used by the Renderer and Input Manager to control picking order. + * @default + */ this.renderOrderID = -1; /** * If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc. - * The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called. - * @property {number} lifespan - The lifespan of the Sprite (in ms) before it will be killed. - * @default - */ + * The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called. + * @property {number} lifespan - The lifespan of the Sprite (in ms) before it will be killed. + * @default + */ this.lifespan = 0; /** - * @property {Events} events - The Events you can subscribe to that are dispatched when certain things happen on this Sprite or its components. + * @property {Phaser.Events} events - The Events you can subscribe to that are dispatched when certain things happen on this Sprite or its components. */ this.events = new Phaser.Events(this); @@ -19445,7 +19820,7 @@ Phaser.Sprite = function (game, x, y, key, frame) { this.animations = new Phaser.AnimationManager(this); /** - * @property {InputHandler} input - The Input Handler Component. + * @property {Phaser.InputHandler} input - The Input Handler Component. */ this.input = new Phaser.InputHandler(this); @@ -19479,11 +19854,16 @@ Phaser.Sprite = function (game, x, y, key, frame) { } else { - if (key == null || this.game.cache.checkImageKey(key) == false) + if (key === null || typeof key === 'undefined') { key = '__default'; this.key = key; } + else if (typeof key === 'string' && this.game.cache.checkImageKey(key) === false) + { + key = '__missing'; + this.key = key; + } PIXI.Sprite.call(this, PIXI.TextureCache[key]); @@ -19521,22 +19901,22 @@ Phaser.Sprite = function (game, x, y, key, frame) { * Setting than anchor to 0.5,0.5 means the textures origin is centered * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right * - * @property {Phaser.Point} anchor - The anchor around with Sprite rotation and scaling takes place. + * @property {Phaser.Point} anchor - The anchor around which rotation and scaling takes place. */ this.anchor = new Phaser.Point(); /** - * @property {number} x - The x coordinate (in world space) of this Sprite. + * @property {number} x - The x coordinate in world space of this Sprite. */ this.x = x; /** - * @property {number} y - The y coordinate (in world space) of this Sprite. + * @property {number} y - The y coordinate in world space of this Sprite. */ this.y = y; - this.position.x = x; - this.position.y = y; + this.position.x = x; + this.position.y = y; /** * @property {Phaser.Point} world - The world coordinates of this Sprite. This differs from the x/y coordinates which are relative to the Sprites container. @@ -19554,60 +19934,82 @@ Phaser.Sprite = function (game, x, y, key, frame) { /** * @property {Phaser.Point} scale - The scale of the Sprite when rendered. By default it's set to 1 (no scale). You can modify it via scale.x or scale.y or scale.setTo(x, y). A value of 1 means no change to the scale, 0.5 means "half the size", 2 means "twice the size", etc. - */ + */ this.scale = new Phaser.Point(1, 1); /** - * @property {Phaser.Point} _cache - A mini cache for storing all of the calculated values. + * @property {object} _cache - A mini cache for storing all of the calculated values. * @private */ - this._cache = { + this._cache = { dirty: false, // Transform cache - a00: -1, a01: -1, a02: -1, a10: -1, a11: -1, a12: -1, id: -1, + a00: -1, + a01: -1, + a02: -1, + a10: -1, + a11: -1, + a12: -1, + id: -1, // Input specific transform cache - i01: -1, i10: -1, idi: -1, + i01: -1, + i10: -1, + idi: -1, // Bounds check - left: null, right: null, top: null, bottom: null, + left: null, + right: null, + top: null, + bottom: null, // delta cache - prevX: x, prevY: y, + prevX: x, + prevY: y, // The previous calculated position - x: -1, y: -1, + x: -1, + y: -1, // The actual scale values based on the worldTransform - scaleX: 1, scaleY: 1, + scaleX: 1, + scaleY: 1, // The width/height of the image, based on the un-modified frame size multiplied by the final calculated scale size - width: this.currentFrame.sourceSizeW, height: this.currentFrame.sourceSizeH, + width: this.currentFrame.sourceSizeW, + height: this.currentFrame.sourceSizeH, // The actual width/height of the image if from a trimmed atlas, multiplied by the final calculated scale size - halfWidth: Math.floor(this.currentFrame.sourceSizeW / 2), halfHeight: Math.floor(this.currentFrame.sourceSizeH / 2), + halfWidth: Math.floor(this.currentFrame.sourceSizeW / 2), + halfHeight: Math.floor(this.currentFrame.sourceSizeH / 2), // The width/height of the image, based on the un-modified frame size multiplied by the final calculated scale size - calcWidth: -1, calcHeight: -1, + calcWidth: -1, + calcHeight: -1, // The current frame details // frameID: this.currentFrame.uuid, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height, - frameID: -1, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height, + frameID: -1, + frameWidth: this.currentFrame.width, + frameHeight: this.currentFrame.height, // If this sprite visible to the camera (regardless of being set to visible or not) cameraVisible: true, // Crop cache - cropX: 0, cropY: 0, cropWidth: this.currentFrame.sourceSizeW, cropHeight: this.currentFrame.sourceSizeH + cropX: 0, + cropY: 0, + cropWidth: this.currentFrame.sourceSizeW, + cropHeight: this.currentFrame.sourceSizeH }; /** * @property {Phaser.Point} offset - Corner point defaults. Should not typically be modified. - */ - this.offset = new Phaser.Point; + */ + this.offset = new Phaser.Point(); /** * @property {Phaser.Point} center - A Point containing the center coordinate of the Sprite. Takes rotation and scale into account. @@ -19649,7 +20051,7 @@ Phaser.Sprite = function (game, x, y, key, frame) { /** * @property {number} health - Health value. Used in combination with damage() to allow for quick killing of Sprites. - */ + */ this.health = 1; /** @@ -19686,7 +20088,7 @@ Phaser.Sprite = function (game, x, y, key, frame) { /** * @property {Phaser.Point} cameraOffset - If this Sprite is fixed to the camera then use this Point to specify how far away from the Camera x/y it's rendered. */ - this.cameraOffset = new Phaser.Point; + this.cameraOffset = new Phaser.Point(); /** * You can crop the Sprites texture by modifying the crop properties. For example crop.width = 50 would set the Sprite to only render 50px wide. @@ -19722,7 +20124,9 @@ Phaser.Sprite.prototype.preUpdate = function() { if (!this.exists || (this.group && !this.group.exists)) { this.renderOrderID = -1; - return; + + // Skip children if not exists + return false; } if (this.lifespan > 0) @@ -19732,7 +20136,7 @@ Phaser.Sprite.prototype.preUpdate = function() { if (this.lifespan <= 0) { this.kill(); - return; + return false; } } @@ -19760,6 +20164,8 @@ Phaser.Sprite.prototype.preUpdate = function() { this.body.preUpdate(); } + return true; + }; /** @@ -19889,7 +20295,7 @@ Phaser.Sprite.prototype.updateBounds = function() { this.updateFrame = true; - if (this.inWorld == false) + if (this.inWorld === false) { // Sprite WAS out of the screen, is it still? this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold); @@ -19905,7 +20311,7 @@ Phaser.Sprite.prototype.updateBounds = function() { // Sprite WAS in the screen, has it now left? this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold); - if (this.inWorld == false) + if (this.inWorld === false) { this.events.onOutOfBounds.dispatch(this); this._outOfBoundsFired = true; @@ -20431,7 +20837,7 @@ Object.defineProperty(Phaser.Sprite.prototype, "inputEnabled", { if (value) { - if (this.input.enabled == false) + if (this.input.enabled === false) { this.input.start(); } @@ -20455,8 +20861,9 @@ Object.defineProperty(Phaser.Sprite.prototype, "inputEnabled", { */ /** -* Create a new TileSprite. +* A TileSprite is a Sprite whos texture is set to repeat and can be scrolled. As it scrolls the texture repeats (wraps) on the edges. * @class Phaser.Tilemap +* @extends Phaser.Sprite * @constructor * @param {Phaser.Game} game - Current game instance. * @param {number} x - X position of the new tileSprite. @@ -20475,36 +20882,36 @@ Phaser.TileSprite = function (game, x, y, width, height, key, frame) { key = key || null; frame = frame || null; - Phaser.Sprite.call(this, game, x, y, key, frame); + Phaser.Sprite.call(this, game, x, y, key, frame); - /** - * @property {Description} texture - Description. + /** + * @property {PIXI.Texture} texture - The texture that the sprite renders with. */ this.texture = PIXI.TextureCache[key]; - PIXI.TilingSprite.call(this, this.texture, width, height); + PIXI.TilingSprite.call(this, this.texture, width, height); - /** - * @property {Description} type - Description. + /** + * @property {number} type - The const type of this object. + * @readonly */ - this.type = Phaser.TILESPRITE; + this.type = Phaser.TILESPRITE; - /** - * @property {Point} tileScale - The scaling of the image that is being tiled. - */ - this.tileScale = new Phaser.Point(1, 1); + /** + * @property {Phaser.Point} tileScale - The scaling of the image that is being tiled. + */ + this.tileScale = new Phaser.Point(1, 1); - /** - * @property {Point} tilePosition - The offset position of the image that is being tiled. - */ - this.tilePosition = new Phaser.Point(0, 0); + /** + * @property {Phaser.Point} tilePosition - The offset position of the image that is being tiled. + */ + this.tilePosition = new Phaser.Point(0, 0); }; Phaser.TileSprite.prototype = Phaser.Utils.extend(true, PIXI.TilingSprite.prototype, Phaser.Sprite.prototype); Phaser.TileSprite.prototype.constructor = Phaser.TileSprite; -// Add our own custom methods /** * @author Richard Davey @@ -20529,81 +20936,99 @@ Phaser.Text = function (game, x, y, text, style) { text = text || ''; style = style || ''; - // If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all - /** - * @property {boolean} exists - Description. - * @default - */ + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ + this.game = game; + + /** + * @property {boolean} exists - If exists = false then the Text isn't updated by the core game loop. + * @default + */ this.exists = true; - // This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering - /** - * @property {boolean} alive - Description. - * @default - */ + /** + * @property {boolean} alive - This is a handy little var your game can use to determine if an object is alive or not, it doesn't effect rendering. + * @default + */ this.alive = true; - /** - * @property {Description} group - Description. - * @default - */ + /** + * @property {Phaser.Group} group - The parent Group of this Text object. + */ this.group = null; - /** - * @property {string} name - Description. - * @default - */ + /** + * @property {string} name - The user defined name given to this object. + * @default + */ this.name = ''; /** - * @property {Phaser.Game} game - A reference to the currently running game. + * @property {number} type - The const type of this object. + * @default */ - this.game = game; + this.type = Phaser.TEXT; + /** + * @property {string} _text - Internal value. + * @private + */ this._text = text; + + /** + * @property {string} _style - Internal value. + * @private + */ this._style = style; PIXI.Text.call(this, text, style); /** - * @property {Description} type - Description. - */ - this.type = Phaser.TEXT; - - /** - * @property {Description} position - Description. - */ + * @property {Phaser.Point} position - The position of this Text object in world space. + */ this.position.x = this.x = x; this.position.y = this.y = y; - // Replaces the PIXI.Point with a slightly more flexible one /** - * @property {Phaser.Point} anchor - Description. - */ + * The anchor sets the origin point of the texture. + * The default is 0,0 this means the textures origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centered + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * + * @property {Phaser.Point} anchor - The anchor around which rotation and scaling takes place. + */ this.anchor = new Phaser.Point(); /** - * @property {Phaser.Point} scale - Description. - */ + * @property {Phaser.Point} scale - The scale of the object when rendered. By default it's set to 1 (no scale). You can modify it via scale.x or scale.y or scale.setTo(x, y). A value of 1 means no change to the scale, 0.5 means "half the size", 2 means "twice the size", etc. + */ this.scale = new Phaser.Point(1, 1); - // A mini cache for storing all of the calculated values /** - * @property {Description} _cache - Description. + * @property {object} _cache - A mini cache for storing all of the calculated values. * @private */ - this._cache = { + this._cache = { dirty: false, // Transform cache - a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1, + a00: 1, + a01: 0, + a02: x, + a10: 0, + a11: 1, + a12: y, + id: 1, // The previous calculated position - x: -1, y: -1, + x: -1, + y: -1, // The actual scale values based on the worldTransform - scaleX: 1, scaleY: 1 + scaleX: 1, + scaleY: 1 }; @@ -20611,7 +21036,7 @@ Phaser.Text = function (game, x, y, text, style) { this._cache.y = this.y; /** - * @property {boolean} renderable - Description. + * @property {boolean} renderable - A renderable object will be rendered to the context each frame. */ this.renderable = true; @@ -20672,11 +21097,11 @@ Phaser.Text.prototype.destroy = function() { } /** -* Get -* @returns {Description} -*//** -* Set -* @param {Description} value - Description +* Indicates the rotation of the Text, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. +* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90. +* If you wish to work in radians instead of degrees use the property Sprite.rotation instead. +* @name Phaser.Text#angle +* @property {number} angle - Gets or sets the angle of rotation in degrees. */ Object.defineProperty(Phaser.Text.prototype, 'angle', { @@ -20690,6 +21115,45 @@ Object.defineProperty(Phaser.Text.prototype, 'angle', { }); +/** +* The x coordinate of this object in world space. +* @name Phaser.Text#x +* @property {number} x - The x coordinate of this object in world space. +*/ +Object.defineProperty(Phaser.Text.prototype, 'x', { + + get: function() { + return this.position.x; + }, + + set: function(value) { + this.position.x = value; + } + +}); + +/** +* The y coordinate of this object in world space. +* @name Phaser.Text#y +* @property {number} y - The y coordinate of this object in world space. +*/ +Object.defineProperty(Phaser.Text.prototype, 'y', { + + get: function() { + return this.position.y; + }, + + set: function(value) { + this.position.y = value; + } + +}); + +/** +* The string to be rendered by this Text object. +* @name Phaser.Text#content +* @property {string} content - The string to be rendered by this Text object. +*/ Object.defineProperty(Phaser.Text.prototype, 'content', { get: function() { @@ -20709,6 +21173,11 @@ Object.defineProperty(Phaser.Text.prototype, 'content', { }); +/** +* The font the text will be rendered in. +* @name Phaser.Text#font +* @property {string} font - The font the text will be rendered in. +*/ Object.defineProperty(Phaser.Text.prototype, 'font', { get: function() { @@ -20751,100 +21220,108 @@ Phaser.BitmapText = function (game, x, y, text, style) { x = x || 0; y = y || 0; - text = text || ''; style = style || ''; - /** - * @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all. - * @default - */ - this.exists = true; - - /** - * @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering. - * @default - */ - this.alive = true; - - /** - * @property {Description} group - Description. - * @default - */ - this.group = null; - - /** - * @property {string} name - Description. - * @default - */ - this.name = ''; - /** * @property {Phaser.Game} game - A reference to the currently running Game. */ this.game = game; - PIXI.BitmapText.call(this, text, style); + /** + * @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all. + * @default + */ + this.exists = true; /** - * @property {Description} type - Description. + * @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering. + * @default + */ + this.alive = true; + + /** + * @property {Phaser.Group} group - The parent Group of this BitmapText. + */ + this.group = null; + + /** + * @property {string} name - The user defined name given to this BitmapText. + * @default + */ + this.name = ''; + + /** + * @property {number} type - The const type of this object. + * @readonly */ this.type = Phaser.BITMAPTEXT; - /** - * @property {number} position.x - Description. - */ + PIXI.BitmapText.call(this, text, style); + + /** + * @property {number} position.x - The x position of this object. + */ this.position.x = x; - /** - * @property {number} position.y - Description. - */ + /** + * @property {number} position.y - The y position of this object. + */ this.position.y = y; - // Replaces the PIXI.Point with a slightly more flexible one - /** - * @property {Phaser.Point} anchor - Description. - */ + /** + * The anchor sets the origin point of the texture. + * The default is 0,0 this means the textures origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centered + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * + * @property {Phaser.Point} anchor - The anchor around which rotation and scaling takes place. + */ this.anchor = new Phaser.Point(); - /** - * @property {Phaser.Point} scale - Description. - */ + /** + * @property {Phaser.Point} scale - The scale of the object when rendered. By default it's set to 1 (no scale). You can modify it via scale.x or scale.y or scale.setTo(x, y). A value of 1 means no change to the scale, 0.5 means "half the size", 2 means "twice the size", etc. + */ this.scale = new Phaser.Point(1, 1); - // A mini cache for storing all of the calculated values - /** - * @property {function} _cache - Description. - * @private - */ - this._cache = { + /** + * @property {object} _cache - A mini cache for storing all of the calculated values. + * @private + */ + this._cache = { dirty: false, // Transform cache - a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1, + a00: 1, + a01: 0, + a02: x, + a10: 0, + a11: 1, + a12: y, + id: 1, // The previous calculated position - x: -1, y: -1, + x: -1, + y: -1, // The actual scale values based on the worldTransform - scaleX: 1, scaleY: 1 + scaleX: 1, + scaleY: 1 }; this._cache.x = this.x; this._cache.y = this.y; - /** - * @property {boolean} renderable - Description. - * @private - */ + /** + * @property {boolean} renderable - A renderable object will be rendered to the context each frame. + */ this.renderable = true; }; Phaser.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype); -// Phaser.BitmapText.prototype = Phaser.Utils.extend(true, PIXI.BitmapText.prototype); Phaser.BitmapText.prototype.constructor = Phaser.BitmapText; /** @@ -20902,11 +21379,11 @@ Phaser.BitmapText.prototype.destroy = function() { } /** -* Get -* @returns {Description} -*//** -* Set -* @param {Description} value - Description +* Indicates the rotation of the BitmapText, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. +* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90. +* If you wish to work in radians instead of degrees use the property Sprite.rotation instead. +* @name Phaser.BitmapText#angle +* @property {number} angle - Gets or sets the angle of rotation in degrees. */ Object.defineProperty(Phaser.BitmapText.prototype, 'angle', { @@ -20921,11 +21398,9 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'angle', { }); /** -* Get -* @returns {Description} -*//** -* Set -* @param {Description} value - Description +* The x coordinate of this object in world space. +* @name Phaser.BitmapText#x +* @property {number} x - The x coordinate of this object in world space. */ Object.defineProperty(Phaser.BitmapText.prototype, 'x', { @@ -20940,11 +21415,9 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'x', { }); /** -* Get -* @returns {Description} -*//** -* Set -* @param {Description} value - Description +* The y coordinate of this object in world space. +* @name Phaser.BitmapText#y +* @property {number} y - The y coordinate of this object in world space. */ Object.defineProperty(Phaser.BitmapText.prototype, 'y', { @@ -20993,67 +21466,67 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame, callback = callback || null; callbackContext = callbackContext || this; - Phaser.Sprite.call(this, game, x, y, key, outFrame); + Phaser.Sprite.call(this, game, x, y, key, outFrame); - /** - * @property {number} type - The Phaser Object Type. - */ + /** + * @property {number} type - The Phaser Object Type. + */ this.type = Phaser.BUTTON; - /** - * @property {string} _onOverFrameName - Internal variable. - * @private - * @default - */ + /** + * @property {string} _onOverFrameName - Internal variable. + * @private + * @default + */ this._onOverFrameName = null; - /** - * @property {string} _onOutFrameName - Internal variable. - * @private - * @default - */ + /** + * @property {string} _onOutFrameName - Internal variable. + * @private + * @default + */ this._onOutFrameName = null; - /** - * @property {string} _onDownFrameName - Internal variable. - * @private - * @default - */ + /** + * @property {string} _onDownFrameName - Internal variable. + * @private + * @default + */ this._onDownFrameName = null; - /** - * @property {string} _onUpFrameName - Internal variable. - * @private - * @default - */ + /** + * @property {string} _onUpFrameName - Internal variable. + * @private + * @default + */ this._onUpFrameName = null; - /** - * @property {number} _onOverFrameID - Internal variable. - * @private - * @default - */ + /** + * @property {number} _onOverFrameID - Internal variable. + * @private + * @default + */ this._onOverFrameID = null; - /** - * @property {number} _onOutFrameID - Internal variable. - * @private - * @default - */ + /** + * @property {number} _onOutFrameID - Internal variable. + * @private + * @default + */ this._onOutFrameID = null; - /** - * @property {number} _onDownFrameID - Internal variable. - * @private - * @default - */ + /** + * @property {number} _onDownFrameID - Internal variable. + * @private + * @default + */ this._onDownFrameID = null; - /** - * @property {number} _onUpFrameID - Internal variable. - * @private - * @default - */ + /** + * @property {number} _onUpFrameID - Internal variable. + * @private + * @default + */ this._onUpFrameID = null; /** @@ -21104,25 +21577,25 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame, */ this.onUpSoundMarker = ''; - /** - * @property {Phaser.Signal} onInputOver - The Signal (or event) dispatched when this Button is in an Over state. - */ - this.onInputOver = new Phaser.Signal; + /** + * @property {Phaser.Signal} onInputOver - The Signal (or event) dispatched when this Button is in an Over state. + */ + this.onInputOver = new Phaser.Signal(); - /** - * @property {Phaser.Signal} onInputOut - The Signal (or event) dispatched when this Button is in an Out state. - */ - this.onInputOut = new Phaser.Signal; + /** + * @property {Phaser.Signal} onInputOut - The Signal (or event) dispatched when this Button is in an Out state. + */ + this.onInputOut = new Phaser.Signal(); - /** - * @property {Phaser.Signal} onInputDown - The Signal (or event) dispatched when this Button is in an Down state. - */ - this.onInputDown = new Phaser.Signal; + /** + * @property {Phaser.Signal} onInputDown - The Signal (or event) dispatched when this Button is in an Down state. + */ + this.onInputDown = new Phaser.Signal(); - /** - * @property {Phaser.Signal} onInputUp - The Signal (or event) dispatched when this Button is in an Up state. - */ - this.onInputUp = new Phaser.Signal; + /** + * @property {Phaser.Signal} onInputUp - The Signal (or event) dispatched when this Button is in an Up state. + */ + this.onInputUp = new Phaser.Signal(); /** * @property {boolean} freezeFrames - When true the Button will cease to change texture frame on all events (over, out, up, down). @@ -21197,7 +21670,7 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) { this._onOutFrameName = outFrame; this._onUpFrameName = outFrame; - if (this.input.pointerOver() == false) + if (this.input.pointerOver() === false) { this.frameName = outFrame; } @@ -21207,7 +21680,7 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) { this._onOutFrameID = outFrame; this._onUpFrameID = outFrame; - if (this.input.pointerOver() == false) + if (this.input.pointerOver() === false) { this.frame = outFrame; } @@ -21367,7 +21840,7 @@ Phaser.Button.prototype.setDownSound = function (sound, marker) { */ Phaser.Button.prototype.onInputOverHandler = function (pointer) { - if (this.freezeFrames == false) + if (this.freezeFrames === false) { if (this._onOverFrameName != null) { @@ -21399,7 +21872,7 @@ Phaser.Button.prototype.onInputOverHandler = function (pointer) { */ Phaser.Button.prototype.onInputOutHandler = function (pointer) { - if (this.freezeFrames == false) + if (this.freezeFrames === false) { if (this._onOutFrameName != null) { @@ -21431,7 +21904,7 @@ Phaser.Button.prototype.onInputOutHandler = function (pointer) { */ Phaser.Button.prototype.onInputDownHandler = function (pointer) { - if (this.freezeFrames == false) + if (this.freezeFrames === false) { if (this._onDownFrameName != null) { @@ -21463,7 +21936,7 @@ Phaser.Button.prototype.onInputDownHandler = function (pointer) { */ Phaser.Button.prototype.onInputUpHandler = function (pointer) { - if (this.freezeFrames == false) + if (this.freezeFrames === false) { if (this._onUpFrameName != null) { @@ -21480,7 +21953,7 @@ Phaser.Button.prototype.onInputUpHandler = function (pointer) { this.onUpSound.play(this.onUpSoundMarker); } - if (this.forceOut && this.freezeFrames == false) + if (this.forceOut && this.freezeFrames === false) { if (this._onOutFrameName != null) { @@ -21506,7 +21979,7 @@ Phaser.Button.prototype.onInputUpHandler = function (pointer) { */ /** -* Creates a new Graphics object. +* Creates a new `Graphics` object. * * @class Phaser.Graphics * @constructor @@ -21522,22 +21995,20 @@ Phaser.Graphics = function (game, x, y) { PIXI.Graphics.call(this); /** - * @property {Description} type - Description. + * @property {number} type - The Phaser Object Type. */ this.type = Phaser.GRAPHICS; this.position.x = x; - this.position.y = y; + this.position.y = y; }; Phaser.Graphics.prototype = Object.create(PIXI.Graphics.prototype); Phaser.Graphics.prototype.constructor = Phaser.Graphics; -// Add our own custom methods - /** -* Description. +* Destroy this Graphics instance. * * @method Phaser.Sprite.prototype.destroy */ @@ -21559,14 +22030,14 @@ Phaser.Graphics.prototype.destroy = function() { */ Phaser.Graphics.prototype.drawPolygon = function (poly) { - graphics.moveTo(poly.points[0].x, poly.points[0].y); + this.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); + this.lineTo(poly.points[i].x, poly.points[i].y); } - graphics.lineTo(poly.points[0].x, poly.points[0].y); + this.lineTo(poly.points[0].x, poly.points[0].y); } @@ -21623,54 +22094,54 @@ Object.defineProperty(Phaser.Graphics.prototype, 'y', { */ Phaser.RenderTexture = function (game, key, width, height) { - /** - * @property {Phaser.Game} game - A reference to the currently running game. - */ - this.game = game; + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ + this.game = game; - /** + /** * @property {string} name - the name of the object. - */ + */ this.name = key; - PIXI.EventTarget.call(this); + PIXI.EventTarget.call(this); - /** - * @property {number} width - the width. + /** + * @property {number} width - the width. */ - this.width = width || 100; - - /** - * @property {number} height - the height. + this.width = width || 100; + + /** + * @property {number} height - the height. */ - this.height = height || 100; + this.height = height || 100; - /** + /** * @property {PIXI.mat3} indetityMatrix - Matrix object. - */ - this.indetityMatrix = PIXI.mat3.create(); - - /** - * @property {PIXI.Rectangle} frame - The frame for this texture. */ - this.frame = new PIXI.Rectangle(0, 0, this.width, this.height); + this.indetityMatrix = PIXI.mat3.create(); - /** - * @property {number} type - Base Phaser object type. + /** + * @property {PIXI.Rectangle} frame - The frame for this texture. */ - this.type = Phaser.RENDERTEXTURE; + this.frame = new PIXI.Rectangle(0, 0, this.width, this.height); - this._tempPoint = { x: 0, y: 0 }; + /** + * @property {number} type - Base Phaser object type. + */ + this.type = Phaser.RENDERTEXTURE; - if (PIXI.gl) - { - this.initWebGL(); - } - else - { - this.initCanvas(); - } - + this._tempPoint = { x: 0, y: 0 }; + + if (PIXI.gl) + { + this.initWebGL(); + } + else + { + this.initCanvas(); + } + }; Phaser.RenderTexture.prototype = Object.create(PIXI.Texture.prototype); @@ -21687,22 +22158,22 @@ Phaser.RenderTexture.prototype.constructor = PIXI.RenderTexture; */ Phaser.RenderTexture.prototype.render = function(displayObject, position, clear) { - if (typeof position === 'undefined') { position = false; } - if (typeof clear === 'undefined') { clear = false; } + if (typeof position === 'undefined') { position = false; } + if (typeof clear === 'undefined') { clear = false; } - if (displayObject instanceof Phaser.Group) - { - displayObject = displayObject._container; - } + if (displayObject instanceof Phaser.Group) + { + displayObject = displayObject._container; + } - if (PIXI.gl) - { - this.renderWebGL(displayObject, position, clear); - } - else - { - this.renderCanvas(displayObject, position, clear); - } + if (PIXI.gl) + { + this.renderWebGL(displayObject, position, clear); + } + else + { + this.renderCanvas(displayObject, position, clear); + } } @@ -21718,10 +22189,10 @@ Phaser.RenderTexture.prototype.render = function(displayObject, position, clear) */ Phaser.RenderTexture.prototype.renderXY = function(displayObject, x, y, clear) { - this._tempPoint.x = x; - this._tempPoint.y = y; + this._tempPoint.x = x; + this._tempPoint.y = y; - this.render(displayObject, this._tempPoint, clear); + this.render(displayObject, this._tempPoint, clear); } @@ -21733,64 +22204,64 @@ Phaser.RenderTexture.prototype.renderXY = function(displayObject, x, y, clear) { */ Phaser.RenderTexture.prototype.initWebGL = function() { - var gl = PIXI.gl; - this.glFramebuffer = gl.createFramebuffer(); + var gl = PIXI.gl; + this.glFramebuffer = gl.createFramebuffer(); - gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer ); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer ); this.glFramebuffer.width = this.width; - this.glFramebuffer.height = this.height; + this.glFramebuffer.height = this.height; - this.baseTexture = new PIXI.BaseTexture(); + this.baseTexture = new PIXI.BaseTexture(); - this.baseTexture.width = this.width; - this.baseTexture.height = this.height; + this.baseTexture.width = this.width; + this.baseTexture.height = this.height; this.baseTexture._glTexture = gl.createTexture(); gl.bindTexture(gl.TEXTURE_2D, this.baseTexture._glTexture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - this.baseTexture.isRender = true; + this.baseTexture.isRender = true; - gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer ); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.baseTexture._glTexture, 0); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer ); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.baseTexture._glTexture, 0); - // create a projection matrix.. - this.projection = new PIXI.Point(this.width/2 , -this.height/2); + // create a projection matrix.. + this.projection = new PIXI.Point(this.width/2 , -this.height/2); - // set the correct render function.. - // this.render = this.renderWebGL; + // set the correct render function.. + // this.render = this.renderWebGL; } Phaser.RenderTexture.prototype.resize = function(width, height) { - this.width = width; - this.height = height; - - if(PIXI.gl) - { - this.projection.x = this.width/2 - this.projection.y = -this.height/2; - - var gl = PIXI.gl; - gl.bindTexture(gl.TEXTURE_2D, this.baseTexture._glTexture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - } - else - { - - this.frame.width = this.width - this.frame.height = this.height; - this.renderer.resize(this.width, this.height); - } + this.width = width; + this.height = height; + + if(PIXI.gl) + { + this.projection.x = this.width/2 + this.projection.y = -this.height/2; + + var gl = PIXI.gl; + gl.bindTexture(gl.TEXTURE_2D, this.baseTexture._glTexture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + } + else + { + + this.frame.width = this.width + this.frame.height = this.height; + this.renderer.resize(this.width, this.height); + } } /** @@ -21801,12 +22272,12 @@ Phaser.RenderTexture.prototype.resize = function(width, height) */ Phaser.RenderTexture.prototype.initCanvas = function() { - this.renderer = new PIXI.CanvasRenderer(this.width, this.height, null, 0); + this.renderer = new PIXI.CanvasRenderer(this.width, this.height, null, 0); - this.baseTexture = new PIXI.BaseTexture(this.renderer.view); - this.frame = new PIXI.Rectangle(0, 0, this.width, this.height); + this.baseTexture = new PIXI.BaseTexture(this.renderer.view); + this.frame = new PIXI.Rectangle(0, 0, this.width, this.height); - // this.render = this.renderCanvas; + // this.render = this.renderCanvas; } /** @@ -21819,69 +22290,72 @@ Phaser.RenderTexture.prototype.initCanvas = function() */ Phaser.RenderTexture.prototype.renderWebGL = function(displayObject, position, clear) { - var gl = PIXI.gl; + var gl = PIXI.gl; - // enable the alpha color mask.. - gl.colorMask(true, true, true, true); + // enable the alpha color mask.. + gl.colorMask(true, true, true, true); - gl.viewport(0, 0, this.width, this.height); + gl.viewport(0, 0, this.width, this.height); - gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer ); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer ); - if(clear) - { - gl.clearColor(0,0,0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); - } + if (clear) + { + gl.clearColor(0,0,0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); + } - // THIS WILL MESS WITH HIT TESTING! - var children = displayObject.children; + // THIS WILL MESS WITH HIT TESTING! + var children = displayObject.children; - //TODO -? create a new one??? dont think so! - var originalWorldTransform = displayObject.worldTransform; - displayObject.worldTransform = PIXI.mat3.create();//sthis.indetityMatrix; - // modify to flip... - displayObject.worldTransform[4] = -1; - displayObject.worldTransform[5] = this.projection.y * -2; + //TODO -? create a new one??? dont think so! + var originalWorldTransform = displayObject.worldTransform; + displayObject.worldTransform = PIXI.mat3.create();//sthis.indetityMatrix; + // modify to flip... + displayObject.worldTransform[4] = -1; + displayObject.worldTransform[5] = this.projection.y * -2; - if(position) - { - displayObject.worldTransform[2] = position.x; - displayObject.worldTransform[5] -= position.y; - } - - PIXI.visibleCount++; - displayObject.vcount = PIXI.visibleCount; - - for(var i=0,j=children.length; i window.outerHeight) { this.orientation = 90; @@ -22642,15 +23156,10 @@ Phaser.StageScaleMode.prototype = { */ refresh: function () { - var _this = this; - // We can't do anything about the status bars in iPads, web apps or desktops - if (this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false) + if (this.game.device.iPad === false && this.game.device.webApp === false && this.game.device.desktop === false) { - // document.documentElement['style'].minHeight = '2000px'; - // this._startHeight = window.innerHeight; - - if (this.game.device.android && this.game.device.chrome == false) + if (this.game.device.android && this.game.device.chrome === false) { window.scrollTo(0, 1); } @@ -22663,9 +23172,13 @@ Phaser.StageScaleMode.prototype = { if (this._check == null && this.maxIterations > 0) { this._iterations = this.maxIterations; + + var _this = this; + this._check = window.setInterval(function () { return _this.setScreenSize(); }, 10); + this.setScreenSize(); } @@ -22682,9 +23195,9 @@ Phaser.StageScaleMode.prototype = { force = false; } - if (this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false) + if (this.game.device.iPad === false && this.game.device.webApp === false && this.game.device.desktop === false) { - if (this.game.device.android && this.game.device.chrome == false) + if (this.game.device.android && this.game.device.chrome === false) { window.scrollTo(0, 1); } @@ -22701,7 +23214,7 @@ Phaser.StageScaleMode.prototype = { // Set minimum height of content to new window height document.documentElement['style'].minHeight = window.innerHeight + 'px'; - if (this.incorrectOrientation == true) + if (this.incorrectOrientation === true) { this.setMaximum(); } @@ -22727,7 +23240,7 @@ Phaser.StageScaleMode.prototype = { */ setSize: function () { - if (this.incorrectOrientation == false) + if (this.incorrectOrientation === false) { if (this.maxWidth && this.width > this.maxWidth) { @@ -22757,24 +23270,28 @@ Phaser.StageScaleMode.prototype = { if (this.pageAlignHorizontally) { - if (this.width < window.innerWidth && this.incorrectOrientation == false) + if (this.width < window.innerWidth && this.incorrectOrientation === false) { - this.game.canvas.style.marginLeft = Math.round((window.innerWidth - this.width) / 2) + 'px'; + this.margin.x = Math.round((window.innerWidth - this.width) / 2); + this.game.canvas.style.marginLeft = this.margin.x + 'px'; } else { + this.margin.x = 0; this.game.canvas.style.marginLeft = '0px'; } } if (this.pageAlignVertically) { - if (this.height < window.innerHeight && this.incorrectOrientation == false) + if (this.height < window.innerHeight && this.incorrectOrientation === false) { - this.game.canvas.style.marginTop = Math.round((window.innerHeight - this.height) / 2) + 'px'; + this.margin.y = Math.round((window.innerHeight - this.height) / 2); + this.game.canvas.style.marginTop = this.margin.y + 'px'; } else { + this.margin.y = 0; this.game.canvas.style.marginTop = '0px'; } } @@ -22786,6 +23303,11 @@ Phaser.StageScaleMode.prototype = { this.scaleFactor.x = this.game.width / this.width; this.scaleFactor.y = this.game.height / this.height; + this.scaleFactorInversed.x = this.width / this.game.width; + this.scaleFactorInversed.y = this.height / this.game.height; + + this.hasResized.dispatch(this.width, this.height); + this.checkOrientationState(); }, @@ -22870,7 +23392,7 @@ Object.defineProperty(Phaser.StageScaleMode.prototype, "isFullScreen", { Object.defineProperty(Phaser.StageScaleMode.prototype, "isPortrait", { get: function () { - return this.orientation == 0 || this.orientation == 180; + return this.orientation === 0 || this.orientation == 180; } }); @@ -23016,67 +23538,78 @@ Phaser.Device = function () { */ this.pointerLock = false; + /** + * @property {boolean} typedArray - Does the browser support TypedArrays? + * @default + */ + this.typedArray = false; + // Browser /** - * @property {boolean} arora - Is running in arora? + * @property {boolean} arora - Set to true if running in Arora. * @default */ this.arora = false; /** - * @property {boolean} chrome - Is running in chrome? + * @property {boolean} chrome - Set to true if running in Chrome. * @default */ this.chrome = false; /** - * @property {boolean} epiphany - Is running in epiphany? + * @property {boolean} epiphany - Set to true if running in Epiphany. * @default */ this.epiphany = false; /** - * @property {boolean} firefox - Is running in firefox? + * @property {boolean} firefox - Set to true if running in Firefox. * @default */ this.firefox = false; /** - * @property {boolean} ie - Is running in ie? + * @property {boolean} ie - Set to true if running in Internet Explorer. * @default */ this.ie = false; /** - * @property {number} ieVersion - Version of ie? + * @property {number} ieVersion - If running in Internet Explorer this will contain the major version number. * @default */ this.ieVersion = 0; /** - * @property {boolean} mobileSafari - Is running in mobileSafari? + * @property {boolean} mobileSafari - Set to true if running in Mobile Safari. * @default */ this.mobileSafari = false; /** - * @property {boolean} midori - Is running in midori? + * @property {boolean} midori - Set to true if running in Midori. * @default */ this.midori = false; /** - * @property {boolean} opera - Is running in opera? + * @property {boolean} opera - Set to true if running in Opera. * @default */ this.opera = false; /** - * @property {boolean} safari - Is running in safari? + * @property {boolean} safari - Set to true if running in Safari. * @default */ this.safari = false; + + /** + * @property {boolean} webApp - Set to true if running as a WebApp, i.e. within a WebView + * @default + */ this.webApp = false; // Audio @@ -23116,6 +23649,7 @@ Phaser.Device = function () { * @default */ this.wav = false; + /** * Can this device play m4a files? * @property {boolean} m4a - True if this device can play m4a files. @@ -23265,7 +23799,7 @@ Phaser.Device.prototype = { this.mobileSafari = true; } else if (/MSIE (\d+\.\d+);/.test(ua)) { this.ie = true; - this.ieVersion = parseInt(RegExp.$1); + this.ieVersion = parseInt(RegExp.$1, 10); } else if (/Midori/.test(ua)) { this.midori = true; } else if (/Opera/.test(ua)) { @@ -23343,6 +23877,12 @@ Phaser.Device.prototype = { if (typeof Int8Array !== 'undefined') { this.littleEndian = new Int8Array(new Int16Array([1]).buffer)[0] > 0; + this.typedArray = true; + } + else + { + this.littleEndian = false; + this.typedArray = false; } }, @@ -23457,149 +23997,151 @@ Phaser.Device.prototype = { * @param {Phaser.Game} game - A reference to the currently running game. */ Phaser.RequestAnimationFrame = function(game) { - - /** - * @property {Phaser.Game} game - The currently running game. - */ - this.game = game; + + /** + * @property {Phaser.Game} game - The currently running game. + */ + this.game = game; - /** - * @property {boolean} isRunning - true if RequestAnimationFrame is running, otherwise false. - * @default - */ - this.isRunning = false; + /** + * @property {boolean} isRunning - true if RequestAnimationFrame is running, otherwise false. + * @default + */ + this.isRunning = false; - var vendors = [ - 'ms', - 'moz', - 'webkit', - 'o' - ]; + var vendors = [ + 'ms', + 'moz', + 'webkit', + 'o' + ]; - for (var x = 0; x < vendors.length && !window.requestAnimationFrame; x++) - { - window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; - window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame']; - } + for (var x = 0; x < vendors.length && !window.requestAnimationFrame; x++) + { + window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; + window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame']; + } - /** - * @property {boolean} _isSetTimeOut - true if the browser is using setTimeout instead of raf. - * @private - */ - this._isSetTimeOut = false; + /** + * @property {boolean} _isSetTimeOut - true if the browser is using setTimeout instead of raf. + * @private + */ + this._isSetTimeOut = false; - /** - * @property {function} _onLoop - The function called by the update. - * @private - */ - this._onLoop = null; + /** + * @property {function} _onLoop - The function called by the update. + * @private + */ + this._onLoop = null; - /** - * @property {number} _timeOutID - The callback ID used when calling cancel. - * @private - */ - this._timeOutID = null; + /** + * @property {number} _timeOutID - The callback ID used when calling cancel. + * @private + */ + this._timeOutID = null; }; Phaser.RequestAnimationFrame.prototype = { - /** - * Starts the requestAnimatioFrame running or setTimeout if unavailable in browser - * @method Phaser.RequestAnimationFrame#start - */ - start: function () { + /** + * Starts the requestAnimatioFrame running or setTimeout if unavailable in browser + * @method Phaser.RequestAnimationFrame#start + */ + start: function () { - this.isRunning = true; + this.isRunning = true; - var _this = this; + var _this = this; - if (!window.requestAnimationFrame) - { - this._isSetTimeOut = true; + if (!window.requestAnimationFrame) + { + this._isSetTimeOut = true; this._onLoop = function () { return _this.updateSetTimeout(); }; - this._timeOutID = window.setTimeout(this._onLoop, 0); - } - else - { - this._isSetTimeOut = false; + this._timeOutID = window.setTimeout(this._onLoop, 0); + } + else + { + this._isSetTimeOut = false; this._onLoop = function (time) { return _this.updateRAF(time); }; - this._timeOutID = window.requestAnimationFrame(this._onLoop); - } + this._timeOutID = window.requestAnimationFrame(this._onLoop); + } - }, + }, - /** - * The update method for the requestAnimationFrame - * @method Phaser.RequestAnimationFrame#updateRAF - * @param {number} time - A timestamp, either from RAF or setTimeOut - */ - updateRAF: function (time) { + /** + * The update method for the requestAnimationFrame + * @method Phaser.RequestAnimationFrame#updateRAF + * @param {number} time - A timestamp, either from RAF or setTimeOut + */ + updateRAF: function (time) { - this.game.update(time); + this.game.update(time); - this._timeOutID = window.requestAnimationFrame(this._onLoop); + this._timeOutID = window.requestAnimationFrame(this._onLoop); - }, + }, - /** - * The update method for the setTimeout. - * @method Phaser.RequestAnimationFrame#updateSetTimeout - */ - updateSetTimeout: function () { + /** + * The update method for the setTimeout. + * @method Phaser.RequestAnimationFrame#updateSetTimeout + */ + updateSetTimeout: function () { - this.game.update(Date.now()); + this.game.update(Date.now()); - this._timeOutID = window.setTimeout(this._onLoop, this.game.time.timeToCall); + this._timeOutID = window.setTimeout(this._onLoop, this.game.time.timeToCall); - }, + }, - /** - * Stops the requestAnimationFrame from running. - * @method Phaser.RequestAnimationFrame#stop - */ - stop: function () { + /** + * Stops the requestAnimationFrame from running. + * @method Phaser.RequestAnimationFrame#stop + */ + stop: function () { - if (this._isSetTimeOut) - { - clearTimeout(this._timeOutID); - } - else - { - window.cancelAnimationFrame(this._timeOutID); - } + if (this._isSetTimeOut) + { + clearTimeout(this._timeOutID); + } + else + { + window.cancelAnimationFrame(this._timeOutID); + } - this.isRunning = false; + this.isRunning = false; - }, + }, - /** - * Is the browser using setTimeout? - * @method Phaser.RequestAnimationFrame#isSetTimeOut - * @return {boolean} - */ - isSetTimeOut: function () { - return this._isSetTimeOut; - }, + /** + * Is the browser using setTimeout? + * @method Phaser.RequestAnimationFrame#isSetTimeOut + * @return {boolean} + */ + isSetTimeOut: function () { + return this._isSetTimeOut; + }, - /** - * Is the browser using requestAnimationFrame? - * @method Phaser.RequestAnimationFrame#isRAF - * @return {boolean} - */ - isRAF: function () { - return (this._isSetTimeOut === false); - } + /** + * Is the browser using requestAnimationFrame? + * @method Phaser.RequestAnimationFrame#isRAF + * @return {boolean} + */ + isRAF: function () { + return (this._isSetTimeOut === false); + } }; +/* jshint noempty: false */ + /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. @@ -23618,232 +24160,231 @@ Phaser.RequestAnimationFrame.prototype = { * @param {array} seeds */ Phaser.RandomDataGenerator = function (seeds) { - - if (typeof seeds === "undefined") { seeds = []; } + + if (typeof seeds === "undefined") { seeds = []; } - this.sow(seeds); + /** + * @property {number} c - Internal var. + * @private + */ + this.c = 1; + + /** + * @property {number} s0 - Internal var. + * @private + */ + this.s0 = 0; + + /** + * @property {number} s1 - Internal var. + * @private + */ + this.s1 = 0; + + /** + * @property {number} s2 - Internal var. + * @private + */ + this.s2 = 0; + + this.sow(seeds); }; Phaser.RandomDataGenerator.prototype = { - /** - * @property {number} c - * @private - */ - c: 1, + /** + * Private random helper. + * @method Phaser.RandomDataGenerator#rnd + * @private + * @return {number} + */ + rnd: function () { - /** - * @property {number} s0 - * @private - */ - s0: 0, + var t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10; // 2^-32 - /** - * @property {number} s1 - * @private - */ - s1: 0, + this.c = t | 0; + this.s0 = this.s1; + this.s1 = this.s2; + this.s2 = t - this.c; - /** - * @property {number} s2 - * @private - */ - s2: 0, + return this.s2; + }, - /** - * Private random helper. - * @method Phaser.RandomDataGenerator#rnd - * @private - * @return {number} Description. - */ - rnd: function () { + /** + * Reset the seed of the random data generator. + * + * @method Phaser.RandomDataGenerator#sow + * @param {array} seeds + */ + sow: function (seeds) { - var t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10; // 2^-32 + if (typeof seeds === "undefined") { seeds = []; } - this.c = t | 0; - this.s0 = this.s1; - this.s1 = this.s2; - this.s2 = t - this.c; + this.s0 = this.hash(' '); + this.s1 = this.hash(this.s0); + this.s2 = this.hash(this.s1); + this.c = 1; - return this.s2; - }, + var seed; - /** - * Reset the seed of the random data generator. - * - * @method Phaser.RandomDataGenerator#sow - * @param {array} seeds - */ - sow: function (seeds) { + for (var i = 0; seed = seeds[i++]; ) + { + this.s0 -= this.hash(seed); + this.s0 += ~~(this.s0 < 0); + this.s1 -= this.hash(seed); + this.s1 += ~~(this.s1 < 0); + this.s2 -= this.hash(seed); + this.s2 += ~~(this.s2 < 0); + } + + }, - if (typeof seeds === "undefined") { seeds = []; } + /** + * Internal method that creates a seed hash. + * @method Phaser.RandomDataGenerator#hash + * @param {Any} data + * @private + * @return {number} hashed value. + */ + hash: function (data) { - this.s0 = this.hash(' '); - this.s1 = this.hash(this.s0); - this.s2 = this.hash(this.s1); - this.c = 1; + var h, i, n; + n = 0xefc8249d; + data = data.toString(); - var seed; + for (i = 0; i < data.length; i++) { + n += data.charCodeAt(i); + h = 0.02519603282416938 * n; + n = h >>> 0; + h -= n; + h *= n; + n = h >>> 0; + h -= n; + n += h * 0x100000000;// 2^32 + } - for (var i = 0; seed = seeds[i++]; ) - { - this.s0 -= this.hash(seed); - this.s0 += ~~(this.s0 < 0); - this.s1 -= this.hash(seed); - this.s1 += ~~(this.s1 < 0); - this.s2 -= this.hash(seed); - this.s2 += ~~(this.s2 < 0); - } - - }, + return (n >>> 0) * 2.3283064365386963e-10;// 2^-32 - /** - * Description. - * @method Phaser.RandomDataGenerator#hash - * @param {Any} data - * @private - * @return {number} Description. - */ - hash: function (data) { + }, - var h, i, n; - n = 0xefc8249d; - data = data.toString(); + /** + * Returns a random integer between 0 and 2^32. + * @method Phaser.RandomDataGenerator#integer + * @return {number} A random integer between 0 and 2^32. + */ + integer: function() { + return this.rnd.apply(this) * 0x100000000;// 2^32 + }, - for (i = 0; i < data.length; i++) { - n += data.charCodeAt(i); - h = 0.02519603282416938 * n; - n = h >>> 0; - h -= n; - h *= n; - n = h >>> 0; - h -= n; - n += h * 0x100000000;// 2^32 - } + /** + * Returns a random real number between 0 and 1. + * @method Phaser.RandomDataGenerator#frac + * @return {number} A random real number between 0 and 1. + */ + frac: function() { + return this.rnd.apply(this) + (this.rnd.apply(this) * 0x200000 | 0) * 1.1102230246251565e-16;// 2^-53 + }, - return (n >>> 0) * 2.3283064365386963e-10;// 2^-32 + /** + * Returns a random real number between 0 and 2^32. + * @method Phaser.RandomDataGenerator#real + * @return {number} A random real number between 0 and 2^32. + */ + real: function() { + return this.integer() + this.frac(); + }, - }, + /** + * Returns a random integer between min and max. + * @method Phaser.RandomDataGenerator#integerInRange + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * @return {number} A random number between min and max. + */ + integerInRange: function (min, max) { + return Math.floor(this.realInRange(min, max)); + }, - /** - * Returns a random integer between 0 and 2^32. - * @method Phaser.RandomDataGenerator#integer - * @return {number} - */ - integer: function() { - return this.rnd.apply(this) * 0x100000000;// 2^32 - }, + /** + * Returns a random real number between min and max. + * @method Phaser.RandomDataGenerator#realInRange + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * @return {number} A random number between min and max. + */ + realInRange: function (min, max) { - /** - * Returns a random real number between 0 and 1. - * @method Phaser.RandomDataGenerator#frac - * @return {number} - */ - frac: function() { - return this.rnd.apply(this) + (this.rnd.apply(this) * 0x200000 | 0) * 1.1102230246251565e-16;// 2^-53 - }, + return this.frac() * (max - min) + min; - /** - * Returns a random real number between 0 and 2^32. - * @method Phaser.RandomDataGenerator#real - * @return {number} - */ - real: function() { - return this.integer() + this.frac(); - }, + }, - /** - * Returns a random integer between min and max. - * @method Phaser.RandomDataGenerator#integerInRange - * @param {number} min - * @param {number} max - * @return {number} - */ - integerInRange: function (min, max) { - return Math.floor(this.realInRange(min, max)); - }, + /** + * Returns a random real number between -1 and 1. + * @method Phaser.RandomDataGenerator#normal + * @return {number} A random real number between -1 and 1. + */ + normal: function () { + return 1 - 2 * this.frac(); + }, - /** - * Returns a random real number between min and max. - * @method Phaser.RandomDataGenerator#realInRange - * @param {number} min - * @param {number} max - * @return {number} - */ - realInRange: function (min, max) { + /** + * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368 + * @method Phaser.RandomDataGenerator#uuid + * @return {string} A valid RFC4122 version4 ID hex string + */ + uuid: function () { - return this.frac() * (max - min) + min; + var a = ''; + var b = ''; - }, + for (b = a = ''; a++ < 36; b +=~a % 5 | a * 3&4 ? (a^15 ? 8^this.frac() * (a^20 ? 16 : 4) : 4).toString(16) : '-') + { + } - /** - * Returns a random real number between -1 and 1. - * @method Phaser.RandomDataGenerator#normal - * @return {number} - */ - normal: function () { - return 1 - 2 * this.frac(); - }, + return b; - /** - * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368 - * @method Phaser.RandomDataGenerator#uuid - * @return {string} - */ - uuid: function () { + }, - var a, b; + /** + * Returns a random member of `array`. + * @method Phaser.RandomDataGenerator#pick + * @param {Array} ary - An Array to pick a random member of. + * @return {any} A random member of the array. + */ + pick: function (ary) { + return ary[this.integerInRange(0, ary.length)]; + }, - for ( - b=a=''; - a++<36; - b+=~a%5|a*3&4?(a^15?8^this.frac()*(a^20?16:4):4).toString(16):'-' - ); + /** + * Returns a random member of `array`, favoring the earlier entries. + * @method Phaser.RandomDataGenerator#weightedPick + * @param {Array} ary - An Array to pick a random member of. + * @return {any} A random member of the array. + */ + weightedPick: function (ary) { + return ary[~~(Math.pow(this.frac(), 2) * ary.length)]; + }, - return b; + /** + * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified. + * @method Phaser.RandomDataGenerator#timestamp + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * @return {number} A random timestamp between min and max. + */ + timestamp: function (min, max) { + return this.realInRange(min || 946684800000, max || 1577862000000); + }, - }, - - /** - * Returns a random member of `array`. - * @method Phaser.RandomDataGenerator#pick - * @param {Any} ary - * @return {number} - */ - pick: function (ary) { - return ary[this.integerInRange(0, ary.length)]; - }, - - /** - * Returns a random member of `array`, favoring the earlier entries. - * @method Phaser.RandomDataGenerator#weightedPick - * @param {Any} ary - * @return {number} - */ - weightedPick: function (ary) { - return ary[~~(Math.pow(this.frac(), 2) * ary.length)]; - }, - - /** - * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified. - * @method Phaser.RandomDataGenerator#timestamp - * @param {number} min - * @param {number} max - * @return {number} - */ - timestamp: function (a, b) { - return this.realInRange(a || 946684800000, b || 1577862000000); - }, - - /** - * Returns a random angle between -180 and 180. - * @method Phaser.RandomDataGenerator#angle - * @return {number} - */ - angle: function() { - return this.integerInRange(-180, 180); - } + /** + * Returns a random angle between -180 and 180. + * @method Phaser.RandomDataGenerator#angle + * @return {number} A random number between -180 and 180. + */ + angle: function() { + return this.integerInRange(-180, 180); + } }; @@ -23860,78 +24401,78 @@ Phaser.RandomDataGenerator.prototype = { */ Phaser.Math = { - /** - * = 2 π - * @method Phaser.Math#PI2 - */ - PI2: Math.PI * 2, + /** + * = 2 π + * @method Phaser.Math#PI2 + */ + PI2: Math.PI * 2, - /** - * Two number are fuzzyEqual if their difference is less than ε. - * @method Phaser.Math#fuzzyEqual - * @param {number} a - * @param {number} b - * @param {number} epsilon - * @return {boolean} True if |a-b|<ε - */ + /** + * Two number are fuzzyEqual if their difference is less than ε. + * @method Phaser.Math#fuzzyEqual + * @param {number} a + * @param {number} b + * @param {number} epsilon + * @return {boolean} True if |a-b|<ε + */ fuzzyEqual: function (a, b, epsilon) { if (typeof epsilon === "undefined") { epsilon = 0.0001; } return Math.abs(a - b) < epsilon; }, - /** - * a is fuzzyLessThan b if it is less than b + ε. - * @method Phaser.Math#fuzzyEqual - * @param {number} a - * @param {number} b - * @param {number} epsilon - * @return {boolean} True if ab+ε - */ + /** + * a is fuzzyGreaterThan b if it is more than b - ε. + * @method Phaser.Math#fuzzyGreaterThan + * @param {number} a + * @param {number} b + * @param {number} epsilon + * @return {boolean} True if a>b+ε + */ fuzzyGreaterThan: function (a, b, epsilon) { if (typeof epsilon === "undefined") { epsilon = 0.0001; } return a > b - epsilon; }, - /** - * @method Phaser.Math#fuzzyCeil - * @param {number} val - * @param {number} epsilon - * @return {boolean} ceiling(val-ε) - */ + /** + * @method Phaser.Math#fuzzyCeil + * @param {number} val + * @param {number} epsilon + * @return {boolean} ceiling(val-ε) + */ fuzzyCeil: function (val, epsilon) { if (typeof epsilon === "undefined") { epsilon = 0.0001; } return Math.ceil(val - epsilon); }, - /** - * @method Phaser.Math#fuzzyFloor - * @param {number} val - * @param {number} epsilon - * @return {boolean} floor(val-ε) - */ + /** + * @method Phaser.Math#fuzzyFloor + * @param {number} val + * @param {number} epsilon + * @return {boolean} floor(val-ε) + */ fuzzyFloor: function (val, epsilon) { if (typeof epsilon === "undefined") { epsilon = 0.0001; } return Math.floor(val + epsilon); }, - /** + /** * Averages all values passed to the function and returns the result. You can pass as many parameters as you like. - * @method Phaser.Math#average + * @method Phaser.Math#average * @return {number} The average of all given values. - */ + */ average: function () { var args = []; @@ -23950,40 +24491,40 @@ Phaser.Math = { }, - /** - * @method Phaser.Math#truncate + /** + * @method Phaser.Math#truncate * @param {number} n * @return {number} - */ + */ truncate: function (n) { return (n > 0) ? Math.floor(n) : Math.ceil(n); }, - /** - * @method Phaser.Math#shear - * @param {number} n - * @return {number} n mod 1 - */ + /** + * @method Phaser.Math#shear + * @param {number} n + * @return {number} n mod 1 + */ shear: function (n) { return n % 1; }, - /** - * Snap a value to nearest grid slice, using rounding. - * - * Example: if you have an interval gap of 5 and a position of 12... you will snap to 10 whereas 14 will snap to 15. - * - * @method Phaser.Math#snapTo - * @param {number} input - The value to snap. - * @param {number} gap - The interval gap of the grid. - * @param {number} [start] - Optional starting offset for gap. + /** + * Snap a value to nearest grid slice, using rounding. + * + * Example: if you have an interval gap of 5 and a position of 12... you will snap to 10 whereas 14 will snap to 15. + * + * @method Phaser.Math#snapTo + * @param {number} input - The value to snap. + * @param {number} gap - The interval gap of the grid. + * @param {number} [start] - Optional starting offset for gap. * @return {number} - */ + */ snapTo: function (input, gap, start) { if (typeof start === "undefined") { start = 0; } - if (gap == 0) { + if (gap === 0) { return input; } @@ -23994,7 +24535,7 @@ Phaser.Math = { }, - /** + /** * Snap a value to nearest grid slice, using floor. * * Example: if you have an interval gap of 5 and a position of 12... you will snap to 10. As will 14 snap to 10... but 16 will snap to 15 @@ -24009,7 +24550,7 @@ Phaser.Math = { if (typeof start === "undefined") { start = 0; } - if (gap == 0) { + if (gap === 0) { return input; } @@ -24020,22 +24561,22 @@ Phaser.Math = { }, - /** - * Snap a value to nearest grid slice, using ceil. - * - * Example: if you have an interval gap of 5 and a position of 12... you will snap to 15. As will 14 will snap to 15... but 16 will snap to 20. - * + /** + * Snap a value to nearest grid slice, using ceil. + * + * Example: if you have an interval gap of 5 and a position of 12... you will snap to 15. As will 14 will snap to 15... but 16 will snap to 20. + * * @method Phaser.Math#snapToCeil * @param {number} input - The value to snap. * @param {number} gap - The interval gap of the grid. * @param {number} [start] - Optional starting offset for gap. * @return {number} - */ + */ snapToCeil: function (input, gap, start) { if (typeof start === "undefined") { start = 0; } - if (gap == 0) { + if (gap === 0) { return input; } @@ -24047,14 +24588,14 @@ Phaser.Math = { }, - /** - * Snaps a value to the nearest value in an array. - * @method Phaser.Math#snapToInArray - * @param {number} input - * @param {array} arr - * @param {boolean} sort - True if the array needs to be sorted. + /** + * Snaps a value to the nearest value in an array. + * @method Phaser.Math#snapToInArray + * @param {number} input + * @param {array} arr + * @param {boolean} sort - True if the array needs to be sorted. * @return {number} - */ + */ snapToInArray: function (input, arr, sort) { if (typeof sort === "undefined") { sort = true; } @@ -24080,42 +24621,42 @@ Phaser.Math = { }, - /** - * Round to some place comparative to a 'base', default is 10 for decimal place. - * - * 'place' is represented by the power applied to 'base' to get that place - * e.g. - * 2000/7 ~= 285.714285714285714285714 ~= (bin)100011101.1011011011011011 - * - * roundTo(2000/7,3) == 0 - * roundTo(2000/7,2) == 300 - * roundTo(2000/7,1) == 290 - * roundTo(2000/7,0) == 286 - * roundTo(2000/7,-1) == 285.7 - * roundTo(2000/7,-2) == 285.71 - * roundTo(2000/7,-3) == 285.714 - * roundTo(2000/7,-4) == 285.7143 - * roundTo(2000/7,-5) == 285.71429 - * - * roundTo(2000/7,3,2) == 288 -- 100100000 - * roundTo(2000/7,2,2) == 284 -- 100011100 - * roundTo(2000/7,1,2) == 286 -- 100011110 - * roundTo(2000/7,0,2) == 286 -- 100011110 - * roundTo(2000/7,-1,2) == 285.5 -- 100011101.1 - * roundTo(2000/7,-2,2) == 285.75 -- 100011101.11 - * roundTo(2000/7,-3,2) == 285.75 -- 100011101.11 - * roundTo(2000/7,-4,2) == 285.6875 -- 100011101.1011 - * roundTo(2000/7,-5,2) == 285.71875 -- 100011101.10111 - * - * Note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed - * because we are rounding 100011.1011011011011011 which rounds up. - * - * @method Phaser.Math#roundTo - * @param {number} value - The value to round. - * @param {number} place - The place to round to. - * @param {number} base - The base to round in... default is 10 for decimal. + /** + * Round to some place comparative to a 'base', default is 10 for decimal place. + * + * 'place' is represented by the power applied to 'base' to get that place + * e.g. + * 2000/7 ~= 285.714285714285714285714 ~= (bin)100011101.1011011011011011 + * + * roundTo(2000/7,3) === 0 + * roundTo(2000/7,2) == 300 + * roundTo(2000/7,1) == 290 + * roundTo(2000/7,0) == 286 + * roundTo(2000/7,-1) == 285.7 + * roundTo(2000/7,-2) == 285.71 + * roundTo(2000/7,-3) == 285.714 + * roundTo(2000/7,-4) == 285.7143 + * roundTo(2000/7,-5) == 285.71429 + * + * roundTo(2000/7,3,2) == 288 -- 100100000 + * roundTo(2000/7,2,2) == 284 -- 100011100 + * roundTo(2000/7,1,2) == 286 -- 100011110 + * roundTo(2000/7,0,2) == 286 -- 100011110 + * roundTo(2000/7,-1,2) == 285.5 -- 100011101.1 + * roundTo(2000/7,-2,2) == 285.75 -- 100011101.11 + * roundTo(2000/7,-3,2) == 285.75 -- 100011101.11 + * roundTo(2000/7,-4,2) == 285.6875 -- 100011101.1011 + * roundTo(2000/7,-5,2) == 285.71875 -- 100011101.10111 + * + * Note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed + * because we are rounding 100011.1011011011011011 which rounds up. + * + * @method Phaser.Math#roundTo + * @param {number} value - The value to round. + * @param {number} place - The place to round to. + * @param {number} base - The base to round in... default is 10 for decimal. * @return {number} - */ + */ roundTo: function (value, place, base) { if (typeof place === "undefined") { place = 0; } @@ -24128,12 +24669,12 @@ Phaser.Math = { }, /** - * @method Phaser.Math#floorTo - * @param {number} value - The value to round. - * @param {number} place - The place to round to. - * @param {number} base - The base to round in... default is 10 for decimal. + * @method Phaser.Math#floorTo + * @param {number} value - The value to round. + * @param {number} place - The place to round to. + * @param {number} base - The base to round in... default is 10 for decimal. * @return {number} - */ + */ floorTo: function (value, place, base) { if (typeof place === "undefined") { place = 0; } @@ -24146,12 +24687,12 @@ Phaser.Math = { }, /** - * @method Phaser.Math#ceilTo - * @param {number} value - The value to round. - * @param {number} place - The place to round to. - * @param {number} base - The base to round in... default is 10 for decimal. + * @method Phaser.Math#ceilTo + * @param {number} value - The value to round. + * @param {number} place - The place to round to. + * @param {number} base - The base to round in... default is 10 for decimal. * @return {number} - */ + */ ceilTo: function (value, place, base) { if (typeof place === "undefined") { place = 0; } @@ -24163,56 +24704,56 @@ Phaser.Math = { }, - /** - * A one dimensional linear interpolation of a value. - * @method Phaser.Math#interpolateFloat - * @param {number} a - * @param {number} b - * @param {number} weight + /** + * A one dimensional linear interpolation of a value. + * @method Phaser.Math#interpolateFloat + * @param {number} a + * @param {number} b + * @param {number} weight * @return {number} - */ + */ interpolateFloat: function (a, b, weight) { return (b - a) * weight + a; }, - /** - * Find the angle of a segment from (x1, y1) -> (x2, y2 ). - * @method Phaser.Math#angleBetween - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 + /** + * Find the angle of a segment from (x1, y1) -> (x2, y2 ). + * @method Phaser.Math#angleBetween + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 * @return {number} - */ + */ angleBetween: function (x1, y1, x2, y2) { return Math.atan2(y2 - y1, x2 - x1); }, - /** - * Set an angle within the bounds of -π toπ. - * @method Phaser.Math#normalizeAngle - * @param {number} angle - * @param {boolean} radians - True if angle size is expressed in radians. + /** + * Set an angle within the bounds of -π toπ. + * @method Phaser.Math#normalizeAngle + * @param {number} angle + * @param {boolean} radians - True if angle size is expressed in radians. * @return {number} - */ + */ normalizeAngle: function (angle, radians) { if (typeof radians === "undefined") { radians = true; } - var rd = (radians) ? GameMath.PI : 180; - return this.wrap(angle, rd, -rd); + var rd = (radians) ? Math.PI : 180; + return this.wrap(angle, -rd, rd); }, - /** - * Closest angle between two angles from a1 to a2 - * absolute value the return for exact angle - * @method Phaser.Math#nearestAngleBetween - * @param {number} a1 - * @param {number} a2 - * @param {boolean} radians - True if angle sizes are expressed in radians. + /** + * Closest angle between two angles from a1 to a2 + * absolute value the return for exact angle + * @method Phaser.Math#nearestAngleBetween + * @param {number} a1 + * @param {number} a2 + * @param {boolean} radians - True if angle sizes are expressed in radians. * @return {number} - */ + */ nearestAngleBetween: function (a1, a2, radians) { if (typeof radians === "undefined") { radians = true; } @@ -24235,16 +24776,16 @@ Phaser.Math = { }, - /** - * Interpolate across the shortest arc between two angles. - * @method Phaser.Math#interpolateAngles - * @param {number} a1 - Description. - * @param {number} a2 - Description. - * @param {number} weight - Description. - * @param {boolean} radians - True if angle sizes are expressed in radians. - * @param {Description} ease - Description. + /** + * Interpolate across the shortest arc between two angles. + * @method Phaser.Math#interpolateAngles + * @param {number} a1 - Description. + * @param {number} a2 - Description. + * @param {number} weight - Description. + * @param {boolean} radians - True if angle sizes are expressed in radians. + * @param {Description} ease - Description. * @return {number} - */ + */ interpolateAngles: function (a1, a2, weight, radians, ease) { if (typeof radians === "undefined") { radians = true; } @@ -24257,16 +24798,16 @@ Phaser.Math = { }, - /** - * Generate a random bool result based on the chance value. - *

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

- * @method Phaser.Math#chanceRoll - * @param {number} chance - The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%). - * @return {boolean} True if the roll passed, or false otherwise. - */ + /** + * Generate a random bool result based on the chance value. + *

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

+ * @method Phaser.Math#chanceRoll + * @param {number} chance - The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%). + * @return {boolean} True if the roll passed, or false otherwise. + */ chanceRoll: function (chance) { if (typeof chance === "undefined") { chance = 50; } @@ -24314,15 +24855,15 @@ Phaser.Math = { }, - /** - * Adds the given amount to the value, but never lets the value go over the specified maximum. - * - * @method Phaser.Math#maxAdd - * @param {number} value - The value to add the amount to. - * @param {number} amount - The amount to add to the value. - * @param {number} max- The maximum the value is allowed to be. + /** + * Adds the given amount to the value, but never lets the value go over the specified maximum. + * + * @method Phaser.Math#maxAdd + * @param {number} value - The value to add the amount to. + * @param {number} amount - The amount to add to the value. + * @param {number} max- The maximum the value is allowed to be. * @return {number} - */ + */ maxAdd: function (value, amount, max) { value += amount; @@ -24336,15 +24877,15 @@ Phaser.Math = { }, - /** - * Subtracts the given amount from the value, but never lets the value go below the specified minimum. - * - * @method Phaser.Math#minSub - * @param {number} value - The base value. - * @param {number} amount - The amount to subtract from the base value. - * @param {number} min - The minimum the value is allowed to be. - * @return {number} The new value. - */ + /** + * Subtracts the given amount from the value, but never lets the value go below the specified minimum. + * + * @method Phaser.Math#minSub + * @param {number} value - The base value. + * @param {number} amount - The amount to subtract from the base value. + * @param {number} min - The minimum the value is allowed to be. + * @return {number} The new value. + */ minSub: function (value, amount, min) { value -= amount; @@ -24392,11 +24933,11 @@ Phaser.Math = { * Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around. *

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

* - * @method Phaser.Math#wrapValue - * @param {number} value - The value to add the amount to. - * @param {number} amount - The amount to add to the value. - * @param {number} max - The maximum the value is allowed to be. - * @return {number} The wrapped value. + * @method Phaser.Math#wrapValue + * @param {number} value - The value to add the amount to. + * @param {number} amount - The amount to add to the value. + * @param {number} max - The maximum the value is allowed to be. + * @return {number} The wrapped value. */ wrapValue: function (value, amount, max) { @@ -24410,36 +24951,36 @@ Phaser.Math = { }, - /** - * Randomly returns either a 1 or -1. - * - * @method Phaser.Math#randomSign - * @return {number} 1 or -1 - */ + /** + * Randomly returns either a 1 or -1. + * + * @method Phaser.Math#randomSign + * @return {number} 1 or -1 + */ randomSign: function () { return (Math.random() > 0.5) ? 1 : -1; }, - /** - * Returns true if the number given is odd. - * - * @method Phaser.Math#isOdd - * @param {number} n - The number to check. - * @return {boolean} True if the given number is odd. False if the given number is even. - */ + /** + * Returns true if the number given is odd. + * + * @method Phaser.Math#isOdd + * @param {number} n - The number to check. + * @return {boolean} True if the given number is odd. False if the given number is even. + */ isOdd: function (n) { return (n & 1); }, - /** - * Returns true if the number given is even. - * - * @method Phaser.Math#isEven - * @param {number} n - The number to check. - * @return {boolean} True if the given number is even. False if the given number is odd. - */ + /** + * Returns true if the number given is even. + * + * @method Phaser.Math#isEven + * @param {number} n - The number to check. + * @return {boolean} True if the given number is even. False if the given number is odd. + */ isEven: function (n) { if (n & 1) @@ -24495,46 +25036,30 @@ Phaser.Math = { }, - /** - * Keeps an angle value between -180 and +180
- * Should be called whenever the angle is updated on the Sprite to stop it from going insane. - * - * @method Phaser.Math#wrapAngle - * @param {number} angle - The angle value to check - * @return {number} The new angle value, returns the same as the input angle if it was within bounds. - */ + /** + * Keeps an angle value between -180 and +180
+ * Should be called whenever the angle is updated on the Sprite to stop it from going insane. + * + * @method Phaser.Math#wrapAngle + * @param {number} angle - The angle value to check + * @return {number} The new angle value, returns the same as the input angle if it was within bounds. + */ wrapAngle: function (angle) { - var result = angle; - - // Nothing needs to change - if (angle >= -180 && angle <= 180) - { - return angle; - } - - // Else normalise it to -180, 180 - result = (angle + 180) % 360; - - if (result < 0) - { - result += 360; - } - - return result - 180; + return this.wrap(angle, -180, 180); }, - /** - * Keeps an angle value between the given min and max values. - * - * @method Phaser.Math#angleLimit - * @param {number} angle - The angle value to check. Must be between -180 and +180. - * @param {number} min - The minimum angle that is allowed (must be -180 or greater). - * @param {number} max - The maximum angle that is allowed (must be 180 or less). - * - * @return {number} The new angle value, returns the same as the input angle if it was within bounds - */ + /** + * Keeps an angle value between the given min and max values. + * + * @method Phaser.Math#angleLimit + * @param {number} angle - The angle value to check. Must be between -180 and +180. + * @param {number} min - The minimum angle that is allowed (must be -180 or greater). + * @param {number} max - The maximum angle that is allowed (must be 180 or less). + * + * @return {number} The new angle value, returns the same as the input angle if it was within bounds + */ angleLimit: function (angle, min, max) { var result = angle; @@ -24552,13 +25077,13 @@ Phaser.Math = { }, - /** - * Description. - * @method Phaser.Math#linearInterpolation - * @param {number} v - * @param {number} k - * @return {number} - */ + /** + * Description. + * @method Phaser.Math#linearInterpolation + * @param {number} v + * @param {number} k + * @return {number} + */ linearInterpolation: function (v, k) { var m = v.length - 1; @@ -24579,13 +25104,13 @@ Phaser.Math = { }, - /** - * Description. - * @method Phaser.Math#bezierInterpolation - * @param {number} v - * @param {number} k - * @return {number} - */ + /** + * Description. + * @method Phaser.Math#bezierInterpolation + * @param {number} v + * @param {number} k + * @return {number} + */ bezierInterpolation: function (v, k) { var b = 0; @@ -24600,13 +25125,13 @@ Phaser.Math = { }, - /** - * Description. - * @method Phaser.Math#catmullRomInterpolation - * @param {number} v - * @param {number} k - * @return {number} - */ + /** + * Description. + * @method Phaser.Math#catmullRomInterpolation + * @param {number} v + * @param {number} k + * @return {number} + */ catmullRomInterpolation: function (v, k) { var m = v.length - 1; @@ -24640,38 +25165,38 @@ Phaser.Math = { }, - /** - * Description. - * @method Phaser.Math#Linear - * @param {number} p0 - * @param {number} p1 - * @param {number} t - * @return {number} - */ + /** + * Description. + * @method Phaser.Math#Linear + * @param {number} p0 + * @param {number} p1 + * @param {number} t + * @return {number} + */ linear: function (p0, p1, t) { return (p1 - p0) * t + p0; }, - /** - * @method Phaser.Math#bernstein - * @param {number} n - * @param {number} i - * @return {number} - */ + /** + * @method Phaser.Math#bernstein + * @param {number} n + * @param {number} i + * @return {number} + */ bernstein: function (n, i) { return this.factorial(n) / this.factorial(i) / this.factorial(n - i); }, - /** - * Description. - * @method Phaser.Math#catmullRom - * @param {number} p0 - * @param {number} p1 - * @param {number} p2 - * @param {number} p3 - * @param {number} t - * @return {number} - */ + /** + * Description. + * @method Phaser.Math#catmullRom + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} t + * @return {number} + */ catmullRom: function (p0, p1, p2, p3, t) { var v0 = (p2 - p0) * 0.5, v1 = (p3 - p1) * 0.5, t2 = t * t, t3 = t * t2; @@ -24690,16 +25215,16 @@ Phaser.Math = { return Math.abs(a - b); }, - /** - * Fetch a random entry from the given array. - * Will return null if random selection is missing, or array has no entries. - * - * @method Phaser.Math#getRandom - * @param {array} objects - An array of objects. - * @param {number} startIndex - Optional offset off the front of the array. Default value is 0, or the beginning of the array. - * @param {number} length - Optional restriction on the number of values you want to randomly select from. - * @return {object} The random object that was selected. - */ + /** + * Fetch a random entry from the given array. + * Will return null if random selection is missing, or array has no entries. + * + * @method Phaser.Math#getRandom + * @param {array} objects - An array of objects. + * @param {number} startIndex - Optional offset off the front of the array. Default value is 0, or the beginning of the array. + * @param {number} length - Optional restriction on the number of values you want to randomly select from. + * @return {object} The random object that was selected. + */ getRandom: function (objects, startIndex, length) { if (typeof startIndex === "undefined") { startIndex = 0; } @@ -24709,7 +25234,7 @@ Phaser.Math = { var l = length; - if ((l == 0) || (l > objects.length - startIndex)) + if ((l === 0) || (l > objects.length - startIndex)) { l = objects.length - startIndex; } @@ -24724,13 +25249,13 @@ Phaser.Math = { }, - /** - * Round down to the next whole number. E.g. floor(1.7) == 1, and floor(-2.7) == -2. - * - * @method Phaser.Math#floor - * @param {number} Value Any number. - * @return {number} The rounded value of that number. - */ + /** + * Round down to the next whole number. E.g. floor(1.7) == 1, and floor(-2.7) == -2. + * + * @method Phaser.Math#floor + * @param {number} Value Any number. + * @return {number} The rounded value of that number. + */ floor: function (value) { var n = value | 0; @@ -24739,19 +25264,19 @@ Phaser.Math = { }, - /** - * Round up to the next whole number. E.g. ceil(1.3) == 2, and ceil(-2.3) == -3. - * + /** + * Round up to the next whole number. E.g. ceil(1.3) == 2, and ceil(-2.3) == -3. + * * @method Phaser.Math#ceil - * @param {number} value - Any number. - * @return {number} The rounded value of that number. - */ + * @param {number} value - Any number. + * @return {number} The rounded value of that number. + */ ceil: function (value) { var n = value | 0; return (value > 0) ? ((n != value) ? (n + 1) : (n)) : (n); }, - /** + /** * Generate a sine and cosine table simultaneously and extremely quickly. Based on research by Franky of scene.at *

* The parameters allow you to specify the length, amplitude and frequency of the wave. Once you have called this function @@ -24791,9 +25316,9 @@ Phaser.Math = { }, - /** - * Removes the top element from the stack and re-inserts it onto the bottom, then returns it. - * The original stack is modified in the process. This effectively moves the position of the data from the start to the end of the table. + /** + * Removes the top element from the stack and re-inserts it onto the bottom, then returns it. + * The original stack is modified in the process. This effectively moves the position of the data from the start to the end of the table. * * @method Phaser.Math#shift * @param {array} stack - The array to shift. @@ -24801,14 +25326,14 @@ Phaser.Math = { */ shift: function (stack) { - var s = stack.shift(); - stack.push(s); + var s = stack.shift(); + stack.push(s); - return s; + return s; }, - /** + /** * Shuffles the data in the given array into a new order * @method Phaser.Math#shuffleArray * @param {array} array - The array to shuffle @@ -24828,7 +25353,7 @@ Phaser.Math = { }, - /** + /** * Returns the distance between the two given set of coordinates. * * @method Phaser.Math#distance @@ -24837,7 +25362,7 @@ Phaser.Math = { * @param {number} x2 * @param {number} y2 * @return {number} The distance between this Point object and the destination Point object. - **/ + */ distance: function (x1, y1, x2, y2) { var dx = x1 - x2; @@ -24856,42 +25381,42 @@ Phaser.Math = { * @param {number} x2 * @param {number} y2 * @return {number} The distance between this Point object and the destination Point object. - **/ + */ distanceRounded: function (x1, y1, x2, y2) { - return Math.round(Phaser.Math.distance(x1, y1, x2, y2)); + return Math.round(Phaser.Math.distance(x1, y1, x2, y2)); }, - /** - * Force a value within the boundaries of two values. - * Clamp value to range - * - * @method Phaser.Math#clamp - * @param {number} x - * @param {number} a - * @param {number} b + /** + * Force a value within the boundaries of two values. + * Clamp value to range + * + * @method Phaser.Math#clamp + * @param {number} x + * @param {number} a + * @param {number} b * @return {number} - */ - clamp: function ( x, a, b ) { + */ + clamp: function ( x, a, b ) { - return ( x < a ) ? a : ( ( x > b ) ? b : x ); + return ( x < a ) ? a : ( ( x > b ) ? b : x ); - }, + }, - /** - * Clamp value to range to range - * - * @method Phaser.Math#mapLinear - * @param {number} x - * @param {number} a1 - * @param {number} a1 - * @param {number} a2 - * @param {number} b1 - * @param {number} b2 - * @return {number} - */ - mapLinear: function ( x, a1, a2, b1, b2 ) { + /** + * Linear mapping from range to range + * + * @method Phaser.Math#mapLinear + * @param {number} x + * @param {number} a1 + * @param {number} a1 + * @param {number} a2 + * @param {number} b1 + * @param {number} b2 + * @return {number} + */ + mapLinear: function ( x, a1, a2, b1, b2 ) { - return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 ); + return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 ); - }, + }, - /** - * Smoothstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep - * - * @method Phaser.Math#smoothstep - * @param {number} x - * @param {number} min - * @param {number} max - * @return {number} - */ - smoothstep: function ( x, min, max ) { + /** + * Smoothstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep + * + * @method Phaser.Math#smoothstep + * @param {number} x + * @param {number} min + * @param {number} max + * @return {number} + */ + smoothstep: function ( x, min, max ) { - if ( x <= min ) return 0; - if ( x >= max ) return 1; + if (x <= min) + { + return 0; + } - x = ( x - min )/( max - min ); + if (x >= max) + { + return 1; + } - return x*x*(3 - 2*x); + x = (x - min) / (max - min); - }, + return x * x * (3 - 2 * x); - /** + }, + + /** * Smootherstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep - * - * @method Phaser.Math#smootherstep - * @param {number} x - * @param {number} min - * @param {number} max - * @return {number} - */ - smootherstep: function ( x, min, max ) { + * + * @method Phaser.Math#smootherstep + * @param {number} x + * @param {number} min + * @param {number} max + * @return {number} + */ + smootherstep: function ( x, min, max ) { - if ( x <= min ) return 0; - if ( x >= max ) return 1; + if (x <= min) + { + return 0; + } - x = ( x - min )/( max - min ); + if (x >= max) + { + return 1; + } - return x*x*x*(x*(x*6 - 15) + 10); + x = (x - min) / (max - min); - }, + return x * x * x * (x * (x * 6 - 15) + 10); - /** - * A value representing the sign of the value. - * -1 for negative, +1 for positive, 0 if value is 0 - * - * @method Phaser.Math#sign - * @param {number} x - * @return {number} - */ - sign: function ( x ) { + }, - return ( x < 0 ) ? -1 : ( ( x > 0 ) ? 1 : 0 ); + /** + * A value representing the sign of the value. + * -1 for negative, +1 for positive, 0 if value is 0 + * + * @method Phaser.Math#sign + * @param {number} x + * @return {number} + */ + sign: function ( x ) { - }, + return ( x < 0 ) ? -1 : ( ( x > 0 ) ? 1 : 0 ); - /** - * Convert degrees to radians. - * - * @method Phaser.Math#degToRad - * @return {function} - */ - degToRad: function() { + }, - var degreeToRadiansFactor = Math.PI / 180; + /** + * Convert degrees to radians. + * + * @method Phaser.Math#degToRad + * @return {function} + */ + degToRad: function() { - return function ( degrees ) { + var degreeToRadiansFactor = Math.PI / 180; - return degrees * degreeToRadiansFactor; + return function ( degrees ) { - }; + return degrees * degreeToRadiansFactor; - }(), + }; - /** - * Convert degrees to radians. - * - * @method Phaser.Math#radToDeg - * @return {function} - */ - radToDeg: function() { + }(), - var radianToDegreesFactor = 180 / Math.PI; + /** + * Convert degrees to radians. + * + * @method Phaser.Math#radToDeg + * @return {function} + */ + radToDeg: function() { - return function ( radians ) { + var radianToDegreesFactor = 180 / Math.PI; - return radians * radianToDegreesFactor; + return function ( radians ) { - }; + return radians * radianToDegreesFactor; - }() + }; + + }() }; @@ -25078,208 +25617,209 @@ Phaser.Math = { * @param {number} level - Description. */ Phaser.QuadTree = function (physicsManager, x, y, width, height, maxObjects, maxLevels, level) { - - this.physicsManager = physicsManager; - this.ID = physicsManager.quadTreeID; - physicsManager.quadTreeID++; + + this.physicsManager = physicsManager; + this.ID = physicsManager.quadTreeID; + physicsManager.quadTreeID++; - this.maxObjects = maxObjects || 10; - this.maxLevels = maxLevels || 4; - this.level = level || 0; + this.maxObjects = maxObjects || 10; + this.maxLevels = maxLevels || 4; + this.level = level || 0; - this.bounds = { - x: Math.round(x), - y: Math.round(y), - width: width, - height: height, - subWidth: Math.floor(width / 2), - subHeight: Math.floor(height / 2), - right: Math.round(x) + Math.floor(width / 2), - bottom: Math.round(y) + Math.floor(height / 2) - }; - - this.objects = []; - this.nodes = []; + this.bounds = { + x: Math.round(x), + y: Math.round(y), + width: width, + height: height, + subWidth: Math.floor(width / 2), + subHeight: Math.floor(height / 2), + right: Math.round(x) + Math.floor(width / 2), + bottom: Math.round(y) + Math.floor(height / 2) + }; + + this.objects = []; + this.nodes = []; }; Phaser.QuadTree.prototype = { - /* - * Split the node into 4 subnodes - * - * @method Phaser.QuadTree#split - */ - split: function() { + /* + * Split the node into 4 subnodes + * + * @method Phaser.QuadTree#split + */ + split: function() { - this.level++; - - // top right node - this.nodes[0] = new Phaser.QuadTree(this.physicsManager, this.bounds.right, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level); - - // top left node - this.nodes[1] = new Phaser.QuadTree(this.physicsManager, this.bounds.x, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level); - - // bottom left node - this.nodes[2] = new Phaser.QuadTree(this.physicsManager, this.bounds.x, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level); - - // bottom right node - this.nodes[3] = new Phaser.QuadTree(this.physicsManager, this.bounds.right, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level); + this.level++; + + // top right node + this.nodes[0] = new Phaser.QuadTree(this.physicsManager, this.bounds.right, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level); + + // top left node + this.nodes[1] = new Phaser.QuadTree(this.physicsManager, this.bounds.x, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level); + + // bottom left node + this.nodes[2] = new Phaser.QuadTree(this.physicsManager, this.bounds.x, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level); + + // bottom right node + this.nodes[3] = new Phaser.QuadTree(this.physicsManager, this.bounds.right, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level); - }, + }, - /* - * Insert the object into the node. If the node - * exceeds the capacity, it will split and add all - * objects to their corresponding subnodes. - * - * @method Phaser.QuadTree#insert - * @param {object} body - Description. - */ - insert: function (body) { - - var i = 0; - var index; - - // if we have subnodes ... - if (this.nodes[0] != null) - { - index = this.getIndex(body); - - if (index !== -1) - { - this.nodes[index].insert(body); - return; - } - } - - this.objects.push(body); - - if (this.objects.length > this.maxObjects && this.level < this.maxLevels) - { - // Split if we don't already have subnodes - if (this.nodes[0] == null) - { - this.split(); - } - - // Add objects to subnodes - while (i < this.objects.length) - { - index = this.getIndex(this.objects[i]); - - if (index !== -1) - { - // this is expensive - see what we can do about it - this.nodes[index].insert(this.objects.splice(i, 1)[0]); - } - else - { - i++; - } - } - } - }, - - /* - * Determine which node the object belongs to. - * - * @method Phaser.QuadTree#getIndex - * @param {object} rect - Description. - * @return {number} index - Index of the subnode (0-3), or -1 if rect cannot completely fit within a subnode and is part of the parent node. - */ - getIndex: function (rect) { - - // default is that rect doesn't fit, i.e. it straddles the internal quadrants - var index = -1; + /* + * Insert the object into the node. If the node + * exceeds the capacity, it will split and add all + * objects to their corresponding subnodes. + * + * @method Phaser.QuadTree#insert + * @param {object} body - Description. + */ + insert: function (body) { + + var i = 0; + var index; + + // if we have subnodes ... + if (this.nodes[0] != null) + { + index = this.getIndex(body); + + if (index !== -1) + { + this.nodes[index].insert(body); + return; + } + } + + this.objects.push(body); + + if (this.objects.length > this.maxObjects && this.level < this.maxLevels) + { + // Split if we don't already have subnodes + if (this.nodes[0] == null) + { + this.split(); + } + + // Add objects to subnodes + while (i < this.objects.length) + { + index = this.getIndex(this.objects[i]); + + if (index !== -1) + { + // this is expensive - see what we can do about it + this.nodes[index].insert(this.objects.splice(i, 1)[0]); + } + else + { + i++; + } + } + } - if (rect.x < this.bounds.right && rect.right < this.bounds.right) - { - if ((rect.y < this.bounds.bottom && rect.bottom < this.bounds.bottom)) - { - // rect fits within the top-left quadrant of this quadtree - index = 1; - } - else if ((rect.y > this.bounds.bottom)) - { - // rect fits within the bottom-left quadrant of this quadtree - index = 2; - } - } - else if (rect.x > this.bounds.right) - { - // rect can completely fit within the right quadrants - if ((rect.y < this.bounds.bottom && rect.bottom < this.bounds.bottom)) - { - // rect fits within the top-right quadrant of this quadtree - index = 0; - } - else if ((rect.y > this.bounds.bottom)) - { - // rect fits within the bottom-right quadrant of this quadtree - index = 3; - } - } - - return index; + }, + + /* + * Determine which node the object belongs to. + * + * @method Phaser.QuadTree#getIndex + * @param {object} rect - Description. + * @return {number} index - Index of the subnode (0-3), or -1 if rect cannot completely fit within a subnode and is part of the parent node. + */ + getIndex: function (rect) { + + // default is that rect doesn't fit, i.e. it straddles the internal quadrants + var index = -1; - }, + if (rect.x < this.bounds.right && rect.right < this.bounds.right) + { + if ((rect.y < this.bounds.bottom && rect.bottom < this.bounds.bottom)) + { + // rect fits within the top-left quadrant of this quadtree + index = 1; + } + else if ((rect.y > this.bounds.bottom)) + { + // rect fits within the bottom-left quadrant of this quadtree + index = 2; + } + } + else if (rect.x > this.bounds.right) + { + // rect can completely fit within the right quadrants + if ((rect.y < this.bounds.bottom && rect.bottom < this.bounds.bottom)) + { + // rect fits within the top-right quadrant of this quadtree + index = 0; + } + else if ((rect.y > this.bounds.bottom)) + { + // rect fits within the bottom-right quadrant of this quadtree + index = 3; + } + } + + return index; - /* - * Return all objects that could collide with the given object. - * - * @method Phaser.QuadTree#retrieve - * @param {object} rect - Description. - * @Return {array} - Array with all detected objects. - */ - retrieve: function (sprite) { - - var returnObjects = this.objects; + }, - sprite.body.quadTreeIndex = this.getIndex(sprite.body); + /* + * Return all objects that could collide with the given object. + * + * @method Phaser.QuadTree#retrieve + * @param {object} rect - Description. + * @Return {array} - Array with all detected objects. + */ + retrieve: function (sprite) { + + var returnObjects = this.objects; - // Temp store for the node IDs this sprite is in, we can use this for fast elimination later - sprite.body.quadTreeIDs.push(this.ID); + sprite.body.quadTreeIndex = this.getIndex(sprite.body); - if (this.nodes[0]) - { - // if rect fits into a subnode .. - if (sprite.body.quadTreeIndex !== -1) - { - returnObjects = returnObjects.concat(this.nodes[sprite.body.quadTreeIndex].retrieve(sprite)); - } - else - { - // if rect does not fit into a subnode, check it against all subnodes (unrolled for speed) - returnObjects = returnObjects.concat(this.nodes[0].retrieve(sprite)); - returnObjects = returnObjects.concat(this.nodes[1].retrieve(sprite)); - returnObjects = returnObjects.concat(this.nodes[2].retrieve(sprite)); - returnObjects = returnObjects.concat(this.nodes[3].retrieve(sprite)); - } - } - - return returnObjects; + // Temp store for the node IDs this sprite is in, we can use this for fast elimination later + sprite.body.quadTreeIDs.push(this.ID); - }, + if (this.nodes[0]) + { + // if rect fits into a subnode .. + if (sprite.body.quadTreeIndex !== -1) + { + returnObjects = returnObjects.concat(this.nodes[sprite.body.quadTreeIndex].retrieve(sprite)); + } + else + { + // if rect does not fit into a subnode, check it against all subnodes (unrolled for speed) + returnObjects = returnObjects.concat(this.nodes[0].retrieve(sprite)); + returnObjects = returnObjects.concat(this.nodes[1].retrieve(sprite)); + returnObjects = returnObjects.concat(this.nodes[2].retrieve(sprite)); + returnObjects = returnObjects.concat(this.nodes[3].retrieve(sprite)); + } + } + + return returnObjects; - /* - * Clear the quadtree. - * @method Phaser.QuadTree#clear - */ - clear: function () { - - this.objects = []; - - for (var i = 0, len = this.nodes.length; i < len; i++) - { - // if (typeof this.nodes[i] !== 'undefined') - if (this.nodes[i]) - { - this.nodes[i].clear(); - delete this.nodes[i]; - } - } - } + }, + + /* + * Clear the quadtree. + * @method Phaser.QuadTree#clear + */ + clear: function () { + + this.objects = []; + + for (var i = 0, len = this.nodes.length; i < len; i++) + { + // if (typeof this.nodes[i] !== 'undefined') + if (this.nodes[i]) + { + this.nodes[i].clear(); + delete this.nodes[i]; + } + } + } }; @@ -25298,7 +25838,7 @@ Phaser.QuadTree.prototype = { * @param {number} [y] The y coordinate of the center of the circle. * @param {number} [diameter] The diameter of the circle. * @return {Phaser.Circle} This circle object -**/ +*/ Phaser.Circle = function (x, y, diameter) { x = x || 0; @@ -25307,26 +25847,26 @@ Phaser.Circle = function (x, y, diameter) { /** * @property {number} x - The x coordinate of the center of the circle. - **/ + */ this.x = x; /** * @property {number} y - The y coordinate of the center of the circle. - **/ + */ this.y = y; /** * @property {number} _diameter - The diameter of the circle. * @private - **/ + */ this._diameter = diameter; if (diameter > 0) { - /** - * @property {number} _radius - The radius of the circle. - * @private - **/ + /** + * @property {number} _radius - The radius of the circle. + * @private + */ this._radius = diameter * 0.5; } else @@ -25342,7 +25882,7 @@ Phaser.Circle.prototype = { * The circumference of the circle. * @method Phaser.Circle#circumference * @return {number} - **/ + */ circumference: function () { return 2 * (Math.PI * this._radius); }, @@ -25354,7 +25894,7 @@ Phaser.Circle.prototype = { * @param {number} y - The y coordinate of the center of the circle. * @param {number} diameter - The diameter of the circle in pixels. * @return {Circle} This circle object. - **/ + */ setTo: function (x, y, diameter) { this.x = x; this.y = y; @@ -25368,7 +25908,7 @@ Phaser.Circle.prototype = { * @method Phaser.Circle#copyFrom * @param {any} source - The object to copy from. * @return {Circle} This Circle object. - **/ + */ copyFrom: function (source) { return this.setTo(source.x, source.y, source.diameter); }, @@ -25378,11 +25918,11 @@ Phaser.Circle.prototype = { * @method Phaser.Circle#copyTo * @param {any} dest - The object to copy to. * @return {Object} This dest object. - **/ + */ copyTo: function(dest) { - dest[x] = this.x; - dest[y] = this.y; - dest[diameter] = this._diameter; + dest.x = this.x; + dest.y = this.y; + dest.diameter = this._diameter; return dest; }, @@ -25419,7 +25959,7 @@ Phaser.Circle.prototype = { if (typeof out === "undefined") { out = new Phaser.Circle(); } - return out.setTo(a.x, a.y, a.diameter); + return out.setTo(this.x, this.y, this.diameter); }, @@ -25452,7 +25992,7 @@ Phaser.Circle.prototype = { * @param {number} dx - Moves the x value of the Circle object by this amount. * @param {number} dy - Moves the y value of the Circle object by this amount. * @return {Circle} This Circle object. - **/ + */ offset: function (dx, dy) { this.x += dx; this.y += dy; @@ -25464,7 +26004,7 @@ Phaser.Circle.prototype = { * @method Phaser.Circle#offsetPoint * @param {Point} point A Point object to use to offset this Circle object (or any valid object with exposed x and y properties). * @return {Circle} This Circle object. - **/ + */ offsetPoint: function (point) { return this.offset(point.x, point.y); }, @@ -25473,7 +26013,7 @@ Phaser.Circle.prototype = { * Returns a string representation of this object. * @method Phaser.Circle#toString * @return {string} a string representation of the instance. - **/ + */ toString: function () { return "[{Phaser.Circle (x=" + this.x + " y=" + this.y + " diameter=" + this.diameter + " radius=" + this.radius + ")}]"; } @@ -25636,11 +26176,16 @@ Object.defineProperty(Phaser.Circle.prototype, "area", { Object.defineProperty(Phaser.Circle.prototype, "empty", { get: function () { - return (this._diameter == 0); + return (this._diameter === 0); }, set: function (value) { - this.setTo(0, 0, 0); + + if (value === true) + { + this.setTo(0, 0, 0); + } + } }); @@ -25767,20 +26312,20 @@ Phaser.Circle.intersectsRectangle = function (c, r) { * @constructor * @param {number} x The horizontal position of this Point (default 0) * @param {number} y The vertical position of this Point (default 0) -**/ +*/ Phaser.Point = function (x, y) { x = x || 0; y = y || 0; /** - * @property {number} x - The x coordinate of the point. - **/ + * @property {number} x - The x coordinate of the point. + */ this.x = x; /** - * @property {number} y - The y coordinate of the point. - **/ + * @property {number} y - The y coordinate of the point. + */ this.y = y; }; @@ -25792,7 +26337,7 @@ Phaser.Point.prototype = { * @method Phaser.Point#copyFrom * @param {any} source - The object to copy from. * @return {Point} This Point object. - **/ + */ copyFrom: function (source) { return this.setTo(source.x, source.y); }, @@ -25801,7 +26346,7 @@ Phaser.Point.prototype = { * Inverts the x and y values of this Point * @method Phaser.Point#invert * @return {Point} This Point object. - **/ + */ invert: function () { return this.setTo(this.y, this.x); }, @@ -25812,7 +26357,7 @@ Phaser.Point.prototype = { * @param {number} x - The horizontal position of this point. * @param {number} y - The vertical position of this point. * @return {Point} This Point object. Useful for chaining method calls. - **/ + */ setTo: function (x, y) { this.x = x; @@ -25827,7 +26372,7 @@ Phaser.Point.prototype = { * @param {number} x - The value to add to Point.x. * @param {number} y - The value to add to Point.y. * @return {Phaser.Point} This Point object. Useful for chaining method calls. - **/ + */ add: function (x, y) { this.x += x; @@ -25842,7 +26387,7 @@ Phaser.Point.prototype = { * @param {number} x - The value to subtract from Point.x. * @param {number} y - The value to subtract from Point.y. * @return {Phaser.Point} This Point object. Useful for chaining method calls. - **/ + */ subtract: function (x, y) { this.x -= x; @@ -25857,7 +26402,7 @@ Phaser.Point.prototype = { * @param {number} x - The value to multiply Point.x by. * @param {number} y - The value to multiply Point.x by. * @return {Phaser.Point} This Point object. Useful for chaining method calls. - **/ + */ multiply: function (x, y) { this.x *= x; @@ -25872,7 +26417,7 @@ Phaser.Point.prototype = { * @param {number} x - The value to divide Point.x by. * @param {number} y - The value to divide Point.x by. * @return {Phaser.Point} This Point object. Useful for chaining method calls. - **/ + */ divide: function (x, y) { this.x /= x; @@ -25932,32 +26477,22 @@ Phaser.Point.prototype = { */ clone: function (output) { - if (typeof output === "undefined") { output = new Phaser.Point; } + if (typeof output === "undefined") { output = new Phaser.Point(); } return output.setTo(this.x, this.y); }, - /** - * Copies the x and y properties from any given object to this Point. - * @method Phaser.Point#copyFrom - * @param {any} source - The object to copy from. - * @return {Point} This Point object. - **/ - copyFrom: function (source) { - return this.setTo(source.x, source.y); - }, - /** * Copies the x and y properties from this Point to any given object. * @method Phaser.Point#copyTo * @param {any} dest - The object to copy to. * @return {Object} The dest object. - **/ + */ copyTo: function(dest) { - dest[x] = this.x; - dest[y] = this.y; + dest.x = this.x; + dest.y = this.y; return dest; @@ -25999,29 +26534,29 @@ Phaser.Point.prototype = { }, /** - * Calculates the length of the vector - * @method Phaser.Point#getMagnitude - * @return {number} the length of the vector - */ + * Calculates the length of the vector + * @method Phaser.Point#getMagnitude + * @return {number} the length of the vector + */ getMagnitude: function() { return Math.sqrt((this.x * this.x) + (this.y * this.y)); }, /** - * Alters the length of the vector without changing the direction - * @method Phaser.Point#getMagnitude - * @param {number} magnitude the desired magnitude of the resulting vector - * @return {Phaser.Point} the modified original vector - */ + * Alters the length of the vector without changing the direction + * @method Phaser.Point#getMagnitude + * @param {number} magnitude the desired magnitude of the resulting vector + * @return {Phaser.Point} the modified original vector + */ setMagnitude: function(magnitude) { return this.normalize().multiply(magnitude, magnitude); }, /** - * Alters the vector so that its length is 1, but it retains the same direction - * @method Phaser.Point#normalize - * @return {Phaser.Point} the modified original vector - */ + * Alters the vector so that its length is 1, but it retains the same direction + * @method Phaser.Point#normalize + * @return {Phaser.Point} the modified original vector + */ normalize: function() { if(!this.isZero()) { @@ -26035,10 +26570,10 @@ Phaser.Point.prototype = { }, /** - * Determine if this point is at 0,0 - * @method Phaser.Point#isZero - * @return {boolean} True if this Point is 0,0, otherwise false - */ + * Determine if this point is at 0,0 + * @method Phaser.Point#isZero + * @return {boolean} True if this Point is 0,0, otherwise false + */ isZero: function() { return (this.x === 0 && this.y === 0); }, @@ -26047,7 +26582,7 @@ Phaser.Point.prototype = { * Returns a string representation of this object. * @method Phaser.Point#toString * @return {string} A string representation of the instance. - **/ + */ toString: function () { return '[{Point (x=' + this.x + ' y=' + this.y + ')}]'; } @@ -26162,7 +26697,7 @@ Phaser.Point.distance = function (a, b, round) { return Phaser.Math.distance(a.x, a.y, b.x, b.y); } -}, +}; /** * Rotates a Point around the x/y coordinates given to the desired angle. @@ -26208,10 +26743,10 @@ Phaser.Point.rotate = function (a, x, y, angle, asDegrees, distance) { * @constructor * @param {number} x - The x coordinate of the top-left corner of the Rectangle. * @param {number} y - The y coordinate of the top-left corner of the Rectangle. -* @param {number} width - The width of the Rectangle in pixels. -* @param {number} height - The height of the Rectangle in pixels. +* @param {number} width - The width of the Rectangle. +* @param {number} height - The height of the Rectangle. * @return {Rectangle} This Rectangle object. -**/ +*/ Phaser.Rectangle = function (x, y, width, height) { x = x || 0; @@ -26220,22 +26755,22 @@ Phaser.Rectangle = function (x, y, width, height) { height = height || 0; /** - * @property {number} x - Description. + * @property {number} x - The x coordinate of the top-left corner of the Rectangle. */ this.x = x; /** - * @property {number} y - Description. + * @property {number} y - The y coordinate of the top-left corner of the Rectangle. */ this.y = y; /** - * @property {number} width - Description. + * @property {number} width - The width of the Rectangle. */ this.width = width; /** - * @property {number} height - Description. + * @property {number} height - The height of the Rectangle. */ this.height = height; @@ -26249,7 +26784,7 @@ Phaser.Rectangle.prototype = { * @param {number} dx - Moves the x value of the Rectangle object by this amount. * @param {number} dy - Moves the y value of the Rectangle object by this amount. * @return {Rectangle} This Rectangle object. - **/ + */ offset: function (dx, dy) { this.x += dx; @@ -26264,7 +26799,7 @@ Phaser.Rectangle.prototype = { * @method Phaser.Rectangle#offsetPoint * @param {Point} point - A Point object to use to offset this Rectangle object. * @return {Rectangle} This Rectangle object. - **/ + */ offsetPoint: function (point) { return this.offset(point.x, point.y); }, @@ -26277,7 +26812,7 @@ Phaser.Rectangle.prototype = { * @param {number} width - The width of the Rectangle in pixels. * @param {number} height - The height of the Rectangle in pixels. * @return {Rectangle} This Rectangle object - **/ + */ setTo: function (x, y, width, height) { this.x = x; @@ -26292,7 +26827,7 @@ Phaser.Rectangle.prototype = { /** * Runs Math.floor() on both the x and y values of this Rectangle. * @method Phaser.Rectangle#floor - **/ + */ floor: function () { this.x = Math.floor(this.x); @@ -26303,7 +26838,7 @@ Phaser.Rectangle.prototype = { /** * Runs Math.floor() on the x, y, width and height values of this Rectangle. * @method Phaser.Rectangle#floorAll - **/ + */ floorAll: function () { this.x = Math.floor(this.x); @@ -26318,7 +26853,7 @@ Phaser.Rectangle.prototype = { * @method Phaser.Rectangle#copyFrom * @param {any} source - The object to copy from. * @return {Rectangle} This Rectangle object. - **/ + */ copyFrom: function (source) { return this.setTo(source.x, source.y, source.width, source.height); }, @@ -26328,7 +26863,7 @@ Phaser.Rectangle.prototype = { * @method Phaser.Rectangle#copyTo * @param {any} source - The object to copy to. * @return {object} This object. - **/ + */ copyTo: function (dest) { dest.x = this.x; @@ -26412,7 +26947,7 @@ Phaser.Rectangle.prototype = { * @return {Phaser.Rectangle} A Rectangle object that equals the area of intersection. If the Rectangles do not intersect, this method returns an empty Rectangle object; that is, a Rectangle with its x, y, width, and height properties set to 0. */ intersection: function (b, out) { - return Phaser.Rectangle.intersection(this, b, output); + return Phaser.Rectangle.intersection(this, b, out); }, /** @@ -26456,7 +26991,7 @@ Phaser.Rectangle.prototype = { * Returns a string representation of this object. * @method Phaser.Rectangle#toString * @return {string} A string representation of the instance. - **/ + */ toString: function () { return "[{Rectangle (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + " empty=" + this.empty + ")}]"; } @@ -26687,7 +27222,12 @@ Object.defineProperty(Phaser.Rectangle.prototype, "empty", { }, set: function (value) { - this.setTo(0, 0, 0, 0); + + if (value === true) + { + this.setTo(0, 0, 0, 0); + } + } }); @@ -26812,7 +27352,7 @@ Phaser.Rectangle.equals = function (a, b) { */ Phaser.Rectangle.intersection = function (a, b, out) { - out = out || new Phaser.Rectangle; + out = out || new Phaser.Rectangle(); if (Phaser.Rectangle.intersects(a, b)) { @@ -26901,8 +27441,8 @@ Phaser.Polygon = function (points) { PIXI.Polygon.call(this, points); /** - * @property {number} type - The base object type. - */ + * @property {number} type - The base object type. + */ this.type = Phaser.POLYGON; }; @@ -26916,165 +27456,161 @@ Phaser.Polygon.prototype.constructor = Phaser.Polygon; */ /** -* Description of Phaser.Net +* Phaser.Net handles browser URL related tasks such as checking host names, domain names and query string manipulation. * * @class Phaser.Net * @constructor * @param {Phaser.Game} game - A reference to the currently running game. */ Phaser.Net = function (game) { - - this.game = game; + + this.game = game; }; Phaser.Net.prototype = { - /** - * Returns the hostname given by the browser. - * - * @method Phaser.Net#getHostName - * @return {string} - */ - getHostName: function () { + /** + * Returns the hostname given by the browser. + * + * @method Phaser.Net#getHostName + * @return {string} + */ + getHostName: function () { - if (window.location && window.location.hostname) { - return window.location.hostname; - } + if (window.location && window.location.hostname) { + return window.location.hostname; + } - return null; + return null; - }, + }, - /** - * Compares the given domain name against the hostname of the browser containing the game. - * If the domain name is found it returns true. - * You can specify a part of a domain, for example 'google' would match 'google.com', 'google.co.uk', etc. - * Do not include 'http://' at the start. - * - * @method Phaser.Net#checkDomainName - * @param {string} domain - * @return {boolean} - */ - checkDomainName: function (domain) { - return window.location.hostname.indexOf(domain) !== -1; - }, + /** + * Compares the given domain name against the hostname of the browser containing the game. + * If the domain name is found it returns true. + * You can specify a part of a domain, for example 'google' would match 'google.com', 'google.co.uk', etc. + * Do not include 'http://' at the start. + * + * @method Phaser.Net#checkDomainName + * @param {string} domain + * @return {boolean} true if the given domain fragment can be found in the window.location.hostname + */ + checkDomainName: function (domain) { + return window.location.hostname.indexOf(domain) !== -1; + }, - /** - * Updates a value on the Query String and returns it in full. - * If the value doesn't already exist it is set. - * If the value exists it is replaced with the new value given. If you don't provide a new value it is removed from the query string. - * Optionally you can redirect to the new url, or just return it as a string. - * - * @method Phaser.Net#updateQueryString - * @param {string} key - The querystring key to update. - * @param {string} value - The new value to be set. If it already exists it will be replaced. - * @param {boolean} redirect - If true the browser will issue a redirect to the url with the new querystring. - * @param {string} url - The URL to modify. If none is given it uses window.location.href. - * @return {string} If redirect is false then the modified url and query string is returned. - */ - updateQueryString: function (key, value, redirect, url) { + /** + * Updates a value on the Query String and returns it in full. + * If the value doesn't already exist it is set. + * If the value exists it is replaced with the new value given. If you don't provide a new value it is removed from the query string. + * Optionally you can redirect to the new url, or just return it as a string. + * + * @method Phaser.Net#updateQueryString + * @param {string} key - The querystring key to update. + * @param {string} value - The new value to be set. If it already exists it will be replaced. + * @param {boolean} redirect - If true the browser will issue a redirect to the url with the new querystring. + * @param {string} url - The URL to modify. If none is given it uses window.location.href. + * @return {string} If redirect is false then the modified url and query string is returned. + */ + updateQueryString: function (key, value, redirect, url) { - if (typeof redirect === "undefined") { redirect = false; } - if (typeof url === "undefined") { url = ''; } + if (typeof redirect === "undefined") { redirect = false; } + if (typeof url === "undefined" || url === '') { url = window.location.href; } - if (url == '') { - url = window.location.href; - } + var output = ''; + var re = new RegExp("([?|&])" + key + "=.*?(&|#|$)(.*)", "gi"); + + if (re.test(url)) + { + if (typeof value !== 'undefined' && value !== null) + { + output = url.replace(re, '$1' + key + "=" + value + '$2$3'); + } + else + { + output = url.replace(re, '$1$3').replace(/(&|\?)$/, ''); + } + } + else + { + if (typeof value !== 'undefined' && value !== null) + { + var separator = url.indexOf('?') !== -1 ? '&' : '?'; + var hash = url.split('#'); + url = hash[0] + separator + key + '=' + value; - var output = ''; - var re = new RegExp("([?|&])" + key + "=.*?(&|#|$)(.*)", "gi"); - - if (re.test(url)) - { - if (typeof value !== 'undefined' && value !== null) - { - output = url.replace(re, '$1' + key + "=" + value + '$2$3'); - } - else - { - output = url.replace(re, '$1$3').replace(/(&|\?)$/, ''); - } - } - else - { - if (typeof value !== 'undefined' && value !== null) - { - var separator = url.indexOf('?') !== -1 ? '&' : '?'; - var hash = url.split('#'); - url = hash[0] + separator + key + '=' + value; + if (hash[1]) { + url += '#' + hash[1]; + } - if (hash[1]) { - url += '#' + hash[1]; - } + output = url; - output = url; + } + else + { + output = url; + } + } - } - else - { - output = url; - } - } + if (redirect) + { + window.location.href = output; + } + else + { + return output; + } - if (redirect) - { - window.location.href = output; - } - else - { - return output; - } + }, - }, + /** + * Returns the Query String as an object. + * If you specify a parameter it will return just the value of that parameter, should it exist. + * + * @method Phaser.Net#getQueryString + * @param {string} [parameter=''] - If specified this will return just the value for that key. + * @return {string|object} An object containing the key value pairs found in the query string or just the value if a parameter was given. + */ + getQueryString: function (parameter) { - /** - * Returns the Query String as an object. - * If you specify a parameter it will return just the value of that parameter, should it exist. - * - * @method Phaser.Net#getQueryString - * @param {string} [parameter=''] - If specified this will return just the value for that key. - * @return {string|object} An object containing the key value pairs found in the query string or just the value if a parameter was given. - */ - getQueryString: function (parameter) { + if (typeof parameter === "undefined") { parameter = ''; } - if (typeof parameter === "undefined") { parameter = ''; } + var output = {}; + var keyValues = location.search.substring(1).split('&'); - var output = {}; - var keyValues = location.search.substring(1).split('&'); + for (var i in keyValues) { - for (var i in keyValues) { + var key = keyValues[i].split('='); - var key = keyValues[i].split('='); + if (key.length > 1) + { + if (parameter && parameter == this.decodeURI(key[0])) + { + return this.decodeURI(key[1]); + } + else + { + output[this.decodeURI(key[0])] = this.decodeURI(key[1]); + } + } + } - if (key.length > 1) - { - if (parameter && parameter == this.decodeURI(key[0])) - { - return this.decodeURI(key[1]); - } - else - { - output[this.decodeURI(key[0])] = this.decodeURI(key[1]); - } - } - } + return output; - return output; + }, - }, - - /** - * Returns the Query String as an object. - * If you specify a parameter it will return just the value of that parameter, should it exist. - * - * @method Phaser.Net#decodeURI - * @param {string} value - The URI component to be decoded. - * @return {string} The decoded value. - */ - decodeURI: function (value) { - return decodeURIComponent(value.replace(/\+/g, " ")); - } + /** + * Returns the Query String as an object. + * If you specify a parameter it will return just the value of that parameter, should it exist. + * + * @method Phaser.Net#decodeURI + * @param {string} value - The URI component to be decoded. + * @return {string} The decoded value. + */ + decodeURI: function (value) { + return decodeURIComponent(value.replace(/\+/g, " ")); + } }; @@ -27102,180 +27638,183 @@ Phaser.Net.prototype = { */ Phaser.TweenManager = function (game) { - /** - * @property {Phaser.Game} game - Local reference to game. - */ - this.game = game; - - /** - * @property {array} _tweens - Description. - * @private - */ - this._tweens = []; - - /** - * @property {array} _add - Description. - * @private - */ - this._add = []; + /** + * @property {Phaser.Game} game - Local reference to game. + */ + this.game = game; + + /** + * @property {array} _tweens - Description. + * @private + */ + this._tweens = []; + + /** + * @property {array} _add - Description. + * @private + */ + this._add = []; - this.game.onPause.add(this.pauseAll, this); - this.game.onResume.add(this.resumeAll, this); + this.game.onPause.add(this.pauseAll, this); + this.game.onResume.add(this.resumeAll, this); }; Phaser.TweenManager.prototype = { - /** - * Version number of this library. - * @property {string} REVISION - * @default - */ - REVISION: '11dev', + /** + * Version number of this library. + * @property {string} REVISION + * @default + */ + REVISION: '11dev', - /** - * Get all the tween objects in an array. - * @method Phaser.TweenManager#getAll - * @returns {Phaser.Tween[]} Array with all tween objects. - */ - getAll: function () { + /** + * Get all the tween objects in an array. + * @method Phaser.TweenManager#getAll + * @returns {Phaser.Tween[]} Array with all tween objects. + */ + getAll: function () { - return this._tweens; + return this._tweens; - }, + }, - /** - * Remove all tween objects. - * @method Phaser.TweenManager#removeAll - */ - removeAll: function () { + /** + * Remove all tween objects. + * @method Phaser.TweenManager#removeAll + */ + removeAll: function () { - this._tweens = []; + this._tweens = []; - }, + }, - /** - * Add a new tween into the TweenManager. - * - * @method Phaser.TweenManager#add - * @param {Phaser.Tween} tween - The tween object you want to add. - * @returns {Phaser.Tween} The tween object you added to the manager. - */ - add: function ( tween ) { + /** + * Add a new tween into the TweenManager. + * + * @method Phaser.TweenManager#add + * @param {Phaser.Tween} tween - The tween object you want to add. + * @returns {Phaser.Tween} The tween object you added to the manager. + */ + add: function ( tween ) { - this._add.push( tween ); + this._add.push( tween ); - }, + }, - /** - * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite. - * - * @method Phaser.TweenManager#create - * @param {Object} object - Object the tween will be run on. - * @returns {Phaser.Tween} The newly created tween object. - */ + /** + * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite. + * + * @method Phaser.TweenManager#create + * @param {Object} object - Object the tween will be run on. + * @returns {Phaser.Tween} The newly created tween object. + */ create: function (object) { return new Phaser.Tween(object, this.game); }, - /** - * Remove a tween from this manager. - * - * @method Phaser.TweenManager#remove - * @param {Phaser.Tween} tween - The tween object you want to remove. - */ - remove: function ( tween ) { + /** + * Remove a tween from this manager. + * + * @method Phaser.TweenManager#remove + * @param {Phaser.Tween} tween - The tween object you want to remove. + */ + remove: function ( tween ) { - var i = this._tweens.indexOf( tween ); + var i = this._tweens.indexOf( tween ); - if ( i !== -1 ) { + if ( i !== -1 ) { - this._tweens[i].pendingDelete = true; + this._tweens[i].pendingDelete = true; - } - - }, - - /** - * Update all the tween objects you added to this manager. - * - * @method Phaser.TweenManager#update - * @returns {boolean} Return false if there's no tween to update, otherwise return true. - */ - update: function () { - - if ( this._tweens.length === 0 && this._add.length === 0 ) return false; - - var i = 0; - var numTweens = this._tweens.length; - - while ( i < numTweens ) { - - if ( this._tweens[ i ].update( this.game.time.now ) ) { - - i++; - - } else { - - this._tweens.splice( i, 1 ); - - numTweens--; - - } - - } - - // If there are any new tweens to be added, do so now - otherwise they can be spliced out of the array before ever running - if (this._add.length > 0) - { - this._tweens = this._tweens.concat(this._add); - this._add.length = 0; - } - - return true; - - }, - - /** - * Checks to see if a particular Sprite is currently being tweened. - * - * @method Phaser.TweenManager#isTweening - * @param {object} object - The object to check for tweens against. - * @returns {boolean} Returns true if the object is currently being tweened, false if not. - */ - isTweening: function(object) { - - return this._tweens.some(function(tween) { - return tween._object === object; - }); - - }, - - /** - * Pauses all currently running tweens. - * - * @method Phaser.TweenManager#update - */ - pauseAll: function () { - - for (var i = this._tweens.length - 1; i >= 0; i--) { - this._tweens[i].pause(); - }; + } }, - /** - * Pauses all currently paused tweens. - * - * @method Phaser.TweenManager#resumeAll - */ - resumeAll: function () { + /** + * Update all the tween objects you added to this manager. + * + * @method Phaser.TweenManager#update + * @returns {boolean} Return false if there's no tween to update, otherwise return true. + */ + update: function () { - for (var i = this._tweens.length - 1; i >= 0; i--) { - this._tweens[i].resume(); - }; + if ( this._tweens.length === 0 && this._add.length === 0 ) + { + return false; + } + + var i = 0; + var numTweens = this._tweens.length; + + while ( i < numTweens ) { + + if ( this._tweens[ i ].update( this.game.time.now ) ) { + + i++; + + } else { + + this._tweens.splice( i, 1 ); + + numTweens--; + + } + + } + + // If there are any new tweens to be added, do so now - otherwise they can be spliced out of the array before ever running + if (this._add.length > 0) + { + this._tweens = this._tweens.concat(this._add); + this._add.length = 0; + } + + return true; + + }, + + /** + * Checks to see if a particular Sprite is currently being tweened. + * + * @method Phaser.TweenManager#isTweening + * @param {object} object - The object to check for tweens against. + * @returns {boolean} Returns true if the object is currently being tweened, false if not. + */ + isTweening: function(object) { + + return this._tweens.some(function(tween) { + return tween._object === object; + }); + + }, + + /** + * Pauses all currently running tweens. + * + * @method Phaser.TweenManager#update + */ + pauseAll: function () { + + for (var i = this._tweens.length - 1; i >= 0; i--) { + this._tweens[i].pause(); + } + + }, + + /** + * Pauses all currently paused tweens. + * + * @method Phaser.TweenManager#resumeAll + */ + resumeAll: function () { + + for (var i = this._tweens.length - 1; i >= 0; i--) { + this._tweens[i].resume(); + } } @@ -27302,7 +27841,7 @@ Phaser.Tween = function (object, game) { * @property {object} _object * @private */ - this._object = object; + this._object = object; /** * @property {Phaser.Game} game - A reference to the currently running Game. @@ -27436,7 +27975,7 @@ Phaser.Tween = function (object, game) { // Set all starting values present on the target object for ( var field in object ) { - this._valuesStart[ field ] = parseFloat(object[field], 10); + this._valuesStart[ field ] = parseFloat(object[field], 10); } /** @@ -27459,45 +27998,45 @@ Phaser.Tween = function (object, game) { Phaser.Tween.prototype = { - /** - * Configure the Tween - * - * @method Phaser.Tween#to - * @param {object} properties - Properties you want to tween. - * @param {number} duration - Duration of this tween. - * @param {function} ease - Easing function. - * @param {boolean} autoStart - Whether this tween will start automatically or not. - * @param {number} delay - Delay before this tween will start, defaults to 0 (no delay). - * @param {boolean} repeat - Should the tween automatically restart once complete? (ignores any chained tweens). - * @param {Phaser.Tween} yoyo - Description. - * @return {Phaser.Tween} Itself. - */ - to: function ( properties, duration, ease, autoStart, delay, repeat, yoyo ) { + /** + * Configure the Tween + * + * @method Phaser.Tween#to + * @param {object} properties - Properties you want to tween. + * @param {number} duration - Duration of this tween. + * @param {function} ease - Easing function. + * @param {boolean} autoStart - Whether this tween will start automatically or not. + * @param {number} delay - Delay before this tween will start, defaults to 0 (no delay). + * @param {boolean} repeat - Should the tween automatically restart once complete? (ignores any chained tweens). + * @param {Phaser.Tween} yoyo - Description. + * @return {Phaser.Tween} Itself. + */ + to: function ( properties, duration, ease, autoStart, delay, repeat, yoyo ) { - duration = duration || 1000; - ease = ease || null; - autoStart = autoStart || false; - delay = delay || 0; - repeat = repeat || 0; - yoyo = yoyo || false; + duration = duration || 1000; + ease = ease || null; + autoStart = autoStart || false; + delay = delay || 0; + repeat = repeat || 0; + yoyo = yoyo || false; - var self; - if (this._parent) - { - self = this._manager.create(this._object); - this._lastChild.chain(self); - this._lastChild = self; - } - else - { - self = this; - this._parent = this; - this._lastChild = this; - } + var self; + if (this._parent) + { + self = this._manager.create(this._object); + this._lastChild.chain(self); + this._lastChild = self; + } + else + { + self = this; + this._parent = this; + this._lastChild = this; + } - self._repeat = repeat; + self._repeat = repeat; self._duration = duration; - self._valuesEnd = properties; + self._valuesEnd = properties; if (ease !== null) { @@ -27517,256 +28056,255 @@ Phaser.Tween.prototype = { return this; } - }, + }, - /** - * Starts the tween running. Can also be called by the autoStart parameter of Tween.to. - * - * @method Phaser.Tween#start - * @param {number} time - Description. - * @return {Phaser.Tween} Itself. - */ - start: function ( time ) { + /** + * Starts the tween running. Can also be called by the autoStart parameter of Tween.to. + * + * @method Phaser.Tween#start + * @return {Phaser.Tween} Itself. + */ + start: function () { if (this.game === null || this._object === null) { return; } - this._manager.add(this); + this._manager.add(this); - this.onStart.dispatch(this._object); + this.onStart.dispatch(this._object); this.isRunning = true; - this._onStartCallbackFired = false; + this._onStartCallbackFired = false; this._startTime = this.game.time.now + this._delayTime; - for ( var property in this._valuesEnd ) { + for ( var property in this._valuesEnd ) { - // check if an Array was provided as property value - if ( this._valuesEnd[ property ] instanceof Array ) { + // check if an Array was provided as property value + if ( this._valuesEnd[ property ] instanceof Array ) { - if ( this._valuesEnd[ property ].length === 0 ) { + if ( this._valuesEnd[ property ].length === 0 ) { - continue; + continue; - } + } - // create a local copy of the Array with the start value at the front - this._valuesEnd[ property ] = [ this._object[ property ] ].concat( this._valuesEnd[ property ] ); + // create a local copy of the Array with the start value at the front + this._valuesEnd[ property ] = [ this._object[ property ] ].concat( this._valuesEnd[ property ] ); - } + } - this._valuesStart[ property ] = this._object[ property ]; + this._valuesStart[ property ] = this._object[ property ]; - if ( ( this._valuesStart[ property ] instanceof Array ) === false ) { - this._valuesStart[ property ] *= 1.0; // Ensures we're using numbers, not strings - } + if ( ( this._valuesStart[ property ] instanceof Array ) === false ) { + this._valuesStart[ property ] *= 1.0; // Ensures we're using numbers, not strings + } - this._valuesStartRepeat[ property ] = this._valuesStart[ property ] || 0; + this._valuesStartRepeat[ property ] = this._valuesStart[ property ] || 0; - } + } - return this; + return this; - }, + }, - /** - * Stops the tween if running and removes it from the TweenManager. If there are any onComplete callbacks or events they are not dispatched. - * - * @method Phaser.Tween#stop - * @return {Phaser.Tween} Itself. - */ - stop: function () { + /** + * Stops the tween if running and removes it from the TweenManager. If there are any onComplete callbacks or events they are not dispatched. + * + * @method Phaser.Tween#stop + * @return {Phaser.Tween} Itself. + */ + stop: function () { this.isRunning = false; - this._manager.remove(this); + this._manager.remove(this); - return this; + return this; - }, + }, - /** - * Sets a delay time before this tween will start. - * - * @method Phaser.Tween#delay - * @param {number} amount - The amount of the delay in ms. - * @return {Phaser.Tween} Itself. - */ - delay: function ( amount ) { + /** + * Sets a delay time before this tween will start. + * + * @method Phaser.Tween#delay + * @param {number} amount - The amount of the delay in ms. + * @return {Phaser.Tween} Itself. + */ + delay: function ( amount ) { - this._delayTime = amount; - return this; + this._delayTime = amount; + return this; - }, + }, - /** - * Sets the number of times this tween will repeat. - * - * @method Phaser.Tween#repeat - * @param {number} times - How many times to repeat. - * @return {Phaser.Tween} Itself. - */ - repeat: function ( times ) { + /** + * Sets the number of times this tween will repeat. + * + * @method Phaser.Tween#repeat + * @param {number} times - How many times to repeat. + * @return {Phaser.Tween} Itself. + */ + repeat: function ( times ) { - this._repeat = times; - return this; + this._repeat = times; + return this; - }, + }, - /** - * A tween that has yoyo set to true will run through from start to finish, then reverse from finish to start. - * Used in combination with repeat you can create endless loops. - * - * @method Phaser.Tween#yoyo - * @param {boolean} yoyo - Set to true to yoyo this tween. - * @return {Phaser.Tween} Itself. - */ - yoyo: function( yoyo ) { + /** + * A tween that has yoyo set to true will run through from start to finish, then reverse from finish to start. + * Used in combination with repeat you can create endless loops. + * + * @method Phaser.Tween#yoyo + * @param {boolean} yoyo - Set to true to yoyo this tween. + * @return {Phaser.Tween} Itself. + */ + yoyo: function( yoyo ) { - this._yoyo = yoyo; - return this; + this._yoyo = yoyo; + return this; - }, + }, - /** - * Set easing function this tween will use, i.e. Phaser.Easing.Linear.None. - * - * @method Phaser.Tween#easing - * @param {function} easing - The easing function this tween will use, i.e. Phaser.Easing.Linear.None. - * @return {Phaser.Tween} Itself. - */ - easing: function ( easing ) { + /** + * Set easing function this tween will use, i.e. Phaser.Easing.Linear.None. + * + * @method Phaser.Tween#easing + * @param {function} easing - The easing function this tween will use, i.e. Phaser.Easing.Linear.None. + * @return {Phaser.Tween} Itself. + */ + easing: function ( easing ) { - this._easingFunction = easing; - return this; + this._easingFunction = easing; + return this; - }, + }, - /** - * Set interpolation function the tween will use, by default it uses Phaser.Math.linearInterpolation. - * - * @method Phaser.Tween#interpolation - * @param {function} interpolation - The interpolation function to use (Phaser.Math.linearInterpolation by default) - * @return {Phaser.Tween} Itself. - */ - interpolation: function ( interpolation ) { + /** + * Set interpolation function the tween will use, by default it uses Phaser.Math.linearInterpolation. + * + * @method Phaser.Tween#interpolation + * @param {function} interpolation - The interpolation function to use (Phaser.Math.linearInterpolation by default) + * @return {Phaser.Tween} Itself. + */ + interpolation: function ( interpolation ) { - this._interpolationFunction = interpolation; - return this; + this._interpolationFunction = interpolation; + return this; - }, + }, - /** - * You can chain tweens together by passing a reference to the chain function. This enables one tween to call another on completion. - * You can pass as many tweens as you like to this function, they will each be chained in sequence. - * - * @method Phaser.Tween#chain - * @return {Phaser.Tween} Itself. - */ - chain: function () { + /** + * You can chain tweens together by passing a reference to the chain function. This enables one tween to call another on completion. + * You can pass as many tweens as you like to this function, they will each be chained in sequence. + * + * @method Phaser.Tween#chain + * @return {Phaser.Tween} Itself. + */ + chain: function () { - this._chainedTweens = arguments; - return this; + this._chainedTweens = arguments; + return this; - }, + }, - /** - * Loop a chain of tweens - * - * Usage: - * game.add.tween(p).to({ x: 700 }, 1000, Phaser.Easing.Linear.None, true) - * .to({ y: 300 }, 1000, Phaser.Easing.Linear.None) - * .to({ x: 0 }, 1000, Phaser.Easing.Linear.None) - * .to({ y: 0 }, 1000, Phaser.Easing.Linear.None) - * .loop(); - * @method Phaser.Tween#loop - * @return {Phaser.Tween} Itself. - */ - loop: function() { + /** + * Loop a chain of tweens + * + * Usage: + * game.add.tween(p).to({ x: 700 }, 1000, Phaser.Easing.Linear.None, true) + * .to({ y: 300 }, 1000, Phaser.Easing.Linear.None) + * .to({ x: 0 }, 1000, Phaser.Easing.Linear.None) + * .to({ y: 0 }, 1000, Phaser.Easing.Linear.None) + * .loop(); + * @method Phaser.Tween#loop + * @return {Phaser.Tween} Itself. + */ + loop: function() { - this._lastChild.chain(this); - return this; + this._lastChild.chain(this); + return this; - }, + }, - /** - * Sets a callback to be fired when the tween starts. Note: callback will be called in the context of the global scope. - * - * @method Phaser.Tween#onStartCallback - * @param {function} callback - The callback to invoke on start. - * @return {Phaser.Tween} Itself. - */ - onStartCallback: function ( callback ) { + /** + * Sets a callback to be fired when the tween starts. Note: callback will be called in the context of the global scope. + * + * @method Phaser.Tween#onStartCallback + * @param {function} callback - The callback to invoke on start. + * @return {Phaser.Tween} Itself. + */ + onStartCallback: function ( callback ) { - this._onStartCallback = callback; - return this; + this._onStartCallback = callback; + return this; - }, + }, - /** - * Sets a callback to be fired each time this tween updates. Note: callback will be called in the context of the global scope. - * - * @method Phaser.Tween#onUpdateCallback - * @param {function} callback - The callback to invoke each time this tween is updated. - * @return {Phaser.Tween} Itself. - */ - onUpdateCallback: function ( callback ) { + /** + * Sets a callback to be fired each time this tween updates. Note: callback will be called in the context of the global scope. + * + * @method Phaser.Tween#onUpdateCallback + * @param {function} callback - The callback to invoke each time this tween is updated. + * @return {Phaser.Tween} Itself. + */ + onUpdateCallback: function ( callback ) { - this._onUpdateCallback = callback; - return this; + this._onUpdateCallback = callback; + return this; - }, + }, - /** - * Sets a callback to be fired when the tween completes. Note: callback will be called in the context of the global scope. - * - * @method Phaser.Tween#onCompleteCallback - * @param {function} callback - The callback to invoke on completion. - * @return {Phaser.Tween} Itself. - */ - onCompleteCallback: function ( callback ) { + /** + * Sets a callback to be fired when the tween completes. Note: callback will be called in the context of the global scope. + * + * @method Phaser.Tween#onCompleteCallback + * @param {function} callback - The callback to invoke on completion. + * @return {Phaser.Tween} Itself. + */ + onCompleteCallback: function ( callback ) { - this._onCompleteCallback = callback; - return this; + this._onCompleteCallback = callback; + return this; - }, + }, - /** - * Pauses the tween. - * - * @method Phaser.Tween#pause - */ + /** + * Pauses the tween. + * + * @method Phaser.Tween#pause + */ pause: function () { this._paused = true; this._pausedTime = this.game.time.now; }, - /** - * Resumes a paused tween. - * - * @method Phaser.Tween#resume - */ + /** + * Resumes a paused tween. + * + * @method Phaser.Tween#resume + */ resume: function () { this._paused = false; this._startTime += (this.game.time.now - this._pausedTime); }, - /** - * Core tween update function called by the TweenManager. Does not need to be invoked directly. - * - * @method Phaser.Tween#update - * @param {number} time - A timestamp passed in by the TweenManager. - * @return {boolean} false if the tween has completed and should be deleted from the manager, otherwise true (still active). - */ - update: function ( time ) { + /** + * Core tween update function called by the TweenManager. Does not need to be invoked directly. + * + * @method Phaser.Tween#update + * @param {number} time - A timestamp passed in by the TweenManager. + * @return {boolean} false if the tween has completed and should be deleted from the manager, otherwise true (still active). + */ + update: function ( time ) { - if (this.pendingDelete) - { - return false; - } + if (this.pendingDelete) + { + return false; + } if (this._paused || time < this._startTime) { @@ -27774,123 +28312,126 @@ Phaser.Tween.prototype = { } - var property; + var property; - if ( time < this._startTime ) { + if ( time < this._startTime ) { - return true; + return true; - } + } - if ( this._onStartCallbackFired === false ) { + if ( this._onStartCallbackFired === false ) { - if ( this._onStartCallback !== null ) { + if ( this._onStartCallback !== null ) { - this._onStartCallback.call( this._object ); + this._onStartCallback.call( this._object ); - } + } - this._onStartCallbackFired = true; + this._onStartCallbackFired = true; - } + } - var elapsed = ( time - this._startTime ) / this._duration; - elapsed = elapsed > 1 ? 1 : elapsed; + var elapsed = ( time - this._startTime ) / this._duration; + elapsed = elapsed > 1 ? 1 : elapsed; - var value = this._easingFunction( elapsed ); + var value = this._easingFunction( elapsed ); - for ( property in this._valuesEnd ) { + for ( property in this._valuesEnd ) { - var start = this._valuesStart[ property ] || 0; - var end = this._valuesEnd[ property ]; + var start = this._valuesStart[ property ] || 0; + var end = this._valuesEnd[ property ]; - if ( end instanceof Array ) { + if ( end instanceof Array ) { - this._object[ property ] = this._interpolationFunction( end, value ); + this._object[ property ] = this._interpolationFunction( end, value ); - } else { + } else { // Parses relative end values with start as base (e.g.: +10, -3) - if ( typeof(end) === "string" ) { - end = start + parseFloat(end, 10); - } + if ( typeof(end) === "string" ) { + end = start + parseFloat(end, 10); + } - // protect against non numeric properties. + // protect against non numeric properties. if ( typeof(end) === "number" ) { - this._object[ property ] = start + ( end - start ) * value; - } + this._object[ property ] = start + ( end - start ) * value; + } - } + } - } + } - if ( this._onUpdateCallback !== null ) { + if ( this._onUpdateCallback !== null ) { - this._onUpdateCallback.call( this._object, value ); + this._onUpdateCallback.call( this._object, value ); - } + } - if ( elapsed == 1 ) { + if ( elapsed == 1 ) { - if ( this._repeat > 0 ) { + if ( this._repeat > 0 ) { - if ( isFinite( this._repeat ) ) { - this._repeat--; - } + if ( isFinite( this._repeat ) ) { + this._repeat--; + } - // reassign starting values, restart by making startTime = now - for ( property in this._valuesStartRepeat ) { + // reassign starting values, restart by making startTime = now + for ( property in this._valuesStartRepeat ) { - if ( typeof( this._valuesEnd[ property ] ) === "string" ) { - this._valuesStartRepeat[ property ] = this._valuesStartRepeat[ property ] + parseFloat(this._valuesEnd[ property ], 10); - } + if ( typeof( this._valuesEnd[ property ] ) === "string" ) { + this._valuesStartRepeat[ property ] = this._valuesStartRepeat[ property ] + parseFloat(this._valuesEnd[ property ], 10); + } - if (this._yoyo) { - var tmp = this._valuesStartRepeat[ property ]; - this._valuesStartRepeat[ property ] = this._valuesEnd[ property ]; - this._valuesEnd[ property ] = tmp; - this._reversed = !this._reversed; - } - this._valuesStart[ property ] = this._valuesStartRepeat[ property ]; + if (this._yoyo) { + var tmp = this._valuesStartRepeat[ property ]; + this._valuesStartRepeat[ property ] = this._valuesEnd[ property ]; + this._valuesEnd[ property ] = tmp; + this._reversed = !this._reversed; + } + this._valuesStart[ property ] = this._valuesStartRepeat[ property ]; - } + } - this._startTime = time + this._delayTime; + this._startTime = time + this._delayTime; - this.onComplete.dispatch(this._object); + this.onComplete.dispatch(this._object); - if ( this._onCompleteCallback !== null ) { - this._onCompleteCallback.call( this._object ); - } + if ( this._onCompleteCallback !== null ) { + this._onCompleteCallback.call( this._object ); + } - return true; + return true; - } else { + } else { - this.onComplete.dispatch(this._object); + this.isRunning = false; + this.onComplete.dispatch(this._object); - if ( this._onCompleteCallback !== null ) { - this._onCompleteCallback.call( this._object ); - } + if ( this._onCompleteCallback !== null ) { + this._onCompleteCallback.call( this._object ); + } - for ( var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i ++ ) { + for ( var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i ++ ) { - this._chainedTweens[ i ].start( time ); + this._chainedTweens[ i ].start( time ); - } + } - return false; + return false; - } + } - } + } - return true; + return true; - } - + } + }; +/* jshint curly: false */ + /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. @@ -27909,547 +28450,547 @@ Phaser.Easing = { * * @class Phaser.Easing.Linear */ - Linear: { + Linear: { - /** - * Ease-in. - * - * @method Phaser.Easing.Linear#In - * @param {number} k - The value to be tweened. - * @returns {number} k^2. - */ - None: function ( k ) { + /** + * Ease-in. + * + * @method Phaser.Easing.Linear#In + * @param {number} k - The value to be tweened. + * @returns {number} k^2. + */ + None: function ( k ) { - return k; + return k; - } + } - }, + }, /** * Quadratic easing. * * @class Phaser.Easing.Quadratic */ - Quadratic: { + Quadratic: { - /** - * Ease-in. - * - * @method Phaser.Easing.Quadratic#In - * @param {number} k - The value to be tweened. - * @returns {number} k^2. - */ - In: function ( k ) { + /** + * Ease-in. + * + * @method Phaser.Easing.Quadratic#In + * @param {number} k - The value to be tweened. + * @returns {number} k^2. + */ + In: function ( k ) { - return k * k; + return k * k; - }, + }, - /** - * Ease-out. - * - * @method Phaser.Easing.Quadratic#Out - * @param {number} k - The value to be tweened. - * @returns {number} k* (2-k). - */ - Out: function ( k ) { + /** + * Ease-out. + * + * @method Phaser.Easing.Quadratic#Out + * @param {number} k - The value to be tweened. + * @returns {number} k* (2-k). + */ + Out: function ( k ) { - return k * ( 2 - k ); + return k * ( 2 - k ); - }, + }, - /** - * Ease-in/out. - * - * @method Phaser.Easing.Quadratic#InOut - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - InOut: function ( k ) { + /** + * Ease-in/out. + * + * @method Phaser.Easing.Quadratic#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + InOut: function ( k ) { - if ( ( k *= 2 ) < 1 ) return 0.5 * k * k; - return - 0.5 * ( --k * ( k - 2 ) - 1 ); + if ( ( k *= 2 ) < 1 ) return 0.5 * k * k; + return - 0.5 * ( --k * ( k - 2 ) - 1 ); - } + } - }, + }, /** * Cubic easing. * * @class Phaser.Easing.Cubic */ - Cubic: { + Cubic: { - /** - * Cubic ease-in. - * - * @method Phaser.Easing.Cubic#In - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - In: function ( k ) { + /** + * Cubic ease-in. + * + * @method Phaser.Easing.Cubic#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + In: function ( k ) { - return k * k * k; + return k * k * k; - }, + }, - /** - * Cubic ease-out. - * - * @method Phaser.Easing.Cubic#Out - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - Out: function ( k ) { + /** + * Cubic ease-out. + * + * @method Phaser.Easing.Cubic#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + Out: function ( k ) { - return --k * k * k + 1; + return --k * k * k + 1; - }, + }, - /** - * Cubic ease-in/out. - * - * @method Phaser.Easing.Cubic#InOut - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - InOut: function ( k ) { + /** + * Cubic ease-in/out. + * + * @method Phaser.Easing.Cubic#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + InOut: function ( k ) { - if ( ( k *= 2 ) < 1 ) return 0.5 * k * k * k; - return 0.5 * ( ( k -= 2 ) * k * k + 2 ); + if ( ( k *= 2 ) < 1 ) return 0.5 * k * k * k; + return 0.5 * ( ( k -= 2 ) * k * k + 2 ); - } + } - }, + }, /** * Quartic easing. * * @class Phaser.Easing.Quartic */ - Quartic: { + Quartic: { - /** - * Quartic ease-in. - * - * @method Phaser.Easing.Quartic#In - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - In: function ( k ) { + /** + * Quartic ease-in. + * + * @method Phaser.Easing.Quartic#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + In: function ( k ) { - return k * k * k * k; + return k * k * k * k; - }, + }, - /** - * Quartic ease-out. - * - * @method Phaser.Easing.Quartic#Out - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - Out: function ( k ) { + /** + * Quartic ease-out. + * + * @method Phaser.Easing.Quartic#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + Out: function ( k ) { - return 1 - ( --k * k * k * k ); + return 1 - ( --k * k * k * k ); - }, + }, - /** - * Quartic ease-in/out. - * - * @method Phaser.Easing.Quartic#InOut - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - InOut: function ( k ) { + /** + * Quartic ease-in/out. + * + * @method Phaser.Easing.Quartic#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + InOut: function ( k ) { - if ( ( k *= 2 ) < 1) return 0.5 * k * k * k * k; - return - 0.5 * ( ( k -= 2 ) * k * k * k - 2 ); + if ( ( k *= 2 ) < 1) return 0.5 * k * k * k * k; + return - 0.5 * ( ( k -= 2 ) * k * k * k - 2 ); - } + } - }, + }, /** * Quintic easing. * * @class Phaser.Easing.Quintic */ - Quintic: { + Quintic: { - /** - * Quintic ease-in. - * - * @method Phaser.Easing.Quintic#In - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - In: function ( k ) { + /** + * Quintic ease-in. + * + * @method Phaser.Easing.Quintic#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + In: function ( k ) { - return k * k * k * k * k; + return k * k * k * k * k; - }, + }, - /** - * Quintic ease-out. - * - * @method Phaser.Easing.Quintic#Out - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - Out: function ( k ) { + /** + * Quintic ease-out. + * + * @method Phaser.Easing.Quintic#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + Out: function ( k ) { - return --k * k * k * k * k + 1; + return --k * k * k * k * k + 1; - }, + }, - /** - * Quintic ease-in/out. - * - * @method Phaser.Easing.Quintic#InOut - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - InOut: function ( k ) { + /** + * Quintic ease-in/out. + * + * @method Phaser.Easing.Quintic#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + InOut: function ( k ) { - if ( ( k *= 2 ) < 1 ) return 0.5 * k * k * k * k * k; - return 0.5 * ( ( k -= 2 ) * k * k * k * k + 2 ); + if ( ( k *= 2 ) < 1 ) return 0.5 * k * k * k * k * k; + return 0.5 * ( ( k -= 2 ) * k * k * k * k + 2 ); - } + } - }, + }, /** * Sinusoidal easing. * * @class Phaser.Easing.Sinusoidal */ - Sinusoidal: { + Sinusoidal: { - /** - * Sinusoidal ease-in. - * - * @method Phaser.Easing.Sinusoidal#In - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - In: function ( k ) { + /** + * Sinusoidal ease-in. + * + * @method Phaser.Easing.Sinusoidal#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + In: function ( k ) { - return 1 - Math.cos( k * Math.PI / 2 ); + return 1 - Math.cos( k * Math.PI / 2 ); - }, + }, - /** - * Sinusoidal ease-out. - * - * @method Phaser.Easing.Sinusoidal#Out - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - Out: function ( k ) { + /** + * Sinusoidal ease-out. + * + * @method Phaser.Easing.Sinusoidal#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + Out: function ( k ) { - return Math.sin( k * Math.PI / 2 ); + return Math.sin( k * Math.PI / 2 ); - }, + }, - /** - * Sinusoidal ease-in/out. - * - * @method Phaser.Easing.Sinusoidal#InOut - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - InOut: function ( k ) { + /** + * Sinusoidal ease-in/out. + * + * @method Phaser.Easing.Sinusoidal#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + InOut: function ( k ) { - return 0.5 * ( 1 - Math.cos( Math.PI * k ) ); + return 0.5 * ( 1 - Math.cos( Math.PI * k ) ); - } + } - }, + }, /** * Exponential easing. * * @class Phaser.Easing.Exponential */ - Exponential: { + Exponential: { - /** - * Exponential ease-in. - * - * @method Phaser.Easing.Exponential#In - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - In: function ( k ) { + /** + * Exponential ease-in. + * + * @method Phaser.Easing.Exponential#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + In: function ( k ) { - return k === 0 ? 0 : Math.pow( 1024, k - 1 ); + return k === 0 ? 0 : Math.pow( 1024, k - 1 ); - }, + }, - /** - * Exponential ease-out. - * - * @method Phaser.Easing.Exponential#Out - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - Out: function ( k ) { + /** + * Exponential ease-out. + * + * @method Phaser.Easing.Exponential#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + Out: function ( k ) { - return k === 1 ? 1 : 1 - Math.pow( 2, - 10 * k ); + return k === 1 ? 1 : 1 - Math.pow( 2, - 10 * k ); - }, + }, - /** - * Exponential ease-in/out. - * - * @method Phaser.Easing.Exponential#InOut - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - InOut: function ( k ) { + /** + * Exponential ease-in/out. + * + * @method Phaser.Easing.Exponential#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + InOut: function ( k ) { - if ( k === 0 ) return 0; - if ( k === 1 ) return 1; - if ( ( k *= 2 ) < 1 ) return 0.5 * Math.pow( 1024, k - 1 ); - return 0.5 * ( - Math.pow( 2, - 10 * ( k - 1 ) ) + 2 ); + if ( k === 0 ) return 0; + if ( k === 1 ) return 1; + if ( ( k *= 2 ) < 1 ) return 0.5 * Math.pow( 1024, k - 1 ); + return 0.5 * ( - Math.pow( 2, - 10 * ( k - 1 ) ) + 2 ); - } + } - }, + }, /** * Circular easing. * * @class Phaser.Easing.Circular */ - Circular: { + Circular: { - /** - * Circular ease-in. - * - * @method Phaser.Easing.Circular#In - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - In: function ( k ) { - - return 1 - Math.sqrt( 1 - k * k ); - - }, - - /** - * Circular ease-out. - * - * @method Phaser.Easing.Circular#Out - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - Out: function ( k ) { - - return Math.sqrt( 1 - ( --k * k ) ); - - }, - - /** - * Circular ease-in/out. + /** + * Circular ease-in. * - * @method Phaser.Easing.Circular#InOut - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. + * @method Phaser.Easing.Circular#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. */ - InOut: function ( k ) { + In: function ( k ) { - if ( ( k *= 2 ) < 1) return - 0.5 * ( Math.sqrt( 1 - k * k) - 1); - return 0.5 * ( Math.sqrt( 1 - ( k -= 2) * k) + 1); + return 1 - Math.sqrt( 1 - k * k ); - } + }, - }, + /** + * Circular ease-out. + * + * @method Phaser.Easing.Circular#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + Out: function ( k ) { + + return Math.sqrt( 1 - ( --k * k ) ); + + }, + + /** + * Circular ease-in/out. + * + * @method Phaser.Easing.Circular#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + InOut: function ( k ) { + + if ( ( k *= 2 ) < 1) return - 0.5 * ( Math.sqrt( 1 - k * k) - 1); + return 0.5 * ( Math.sqrt( 1 - ( k -= 2) * k) + 1); + + } + + }, /** * Elastic easing. * * @class Phaser.Easing.Elastic */ - Elastic: { + Elastic: { - /** - * Elastic ease-in. - * - * @method Phaser.Easing.Elastic#In - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - In: function ( k ) { + /** + * Elastic ease-in. + * + * @method Phaser.Easing.Elastic#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + In: function ( k ) { - var s, a = 0.1, p = 0.4; - if ( k === 0 ) return 0; - if ( k === 1 ) return 1; - if ( !a || a < 1 ) { a = 1; s = p / 4; } - else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI ); - return - ( a * Math.pow( 2, 10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) ); + var s, a = 0.1, p = 0.4; + if ( k === 0 ) return 0; + if ( k === 1 ) return 1; + if ( !a || a < 1 ) { a = 1; s = p / 4; } + else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI ); + return - ( a * Math.pow( 2, 10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) ); - }, + }, - /** - * Elastic ease-out. - * - * @method Phaser.Easing.Elastic#Out - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - Out: function ( k ) { + /** + * Elastic ease-out. + * + * @method Phaser.Easing.Elastic#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + Out: function ( k ) { - var s, a = 0.1, p = 0.4; - if ( k === 0 ) return 0; - if ( k === 1 ) return 1; - if ( !a || a < 1 ) { a = 1; s = p / 4; } - else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI ); - return ( a * Math.pow( 2, - 10 * k) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) + 1 ); + var s, a = 0.1, p = 0.4; + if ( k === 0 ) return 0; + if ( k === 1 ) return 1; + if ( !a || a < 1 ) { a = 1; s = p / 4; } + else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI ); + return ( a * Math.pow( 2, - 10 * k) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) + 1 ); - }, + }, - /** - * Elastic ease-in/out. - * - * @method Phaser.Easing.Elastic#InOut - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - InOut: function ( k ) { + /** + * Elastic ease-in/out. + * + * @method Phaser.Easing.Elastic#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + InOut: function ( k ) { - var s, a = 0.1, p = 0.4; - if ( k === 0 ) return 0; - if ( k === 1 ) return 1; - if ( !a || a < 1 ) { a = 1; s = p / 4; } - else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI ); - if ( ( k *= 2 ) < 1 ) return - 0.5 * ( a * Math.pow( 2, 10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) ); - return a * Math.pow( 2, -10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) * 0.5 + 1; + var s, a = 0.1, p = 0.4; + if ( k === 0 ) return 0; + if ( k === 1 ) return 1; + if ( !a || a < 1 ) { a = 1; s = p / 4; } + else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI ); + if ( ( k *= 2 ) < 1 ) return - 0.5 * ( a * Math.pow( 2, 10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) ); + return a * Math.pow( 2, -10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) * 0.5 + 1; - } + } - }, + }, /** * Back easing. * * @class Phaser.Easing.Back */ - Back: { + Back: { - /** - * Back ease-in. - * - * @method Phaser.Easing.Back#In - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - In: function ( k ) { + /** + * Back ease-in. + * + * @method Phaser.Easing.Back#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + In: function ( k ) { - var s = 1.70158; - return k * k * ( ( s + 1 ) * k - s ); + var s = 1.70158; + return k * k * ( ( s + 1 ) * k - s ); - }, + }, - /** - * Back ease-out. - * - * @method Phaser.Easing.Back#Out - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - Out: function ( k ) { + /** + * Back ease-out. + * + * @method Phaser.Easing.Back#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + Out: function ( k ) { - var s = 1.70158; - return --k * k * ( ( s + 1 ) * k + s ) + 1; + var s = 1.70158; + return --k * k * ( ( s + 1 ) * k + s ) + 1; - }, + }, - /** - * Back ease-in/out. - * - * @method Phaser.Easing.Back#InOut - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - InOut: function ( k ) { + /** + * Back ease-in/out. + * + * @method Phaser.Easing.Back#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + InOut: function ( k ) { - var s = 1.70158 * 1.525; - if ( ( k *= 2 ) < 1 ) return 0.5 * ( k * k * ( ( s + 1 ) * k - s ) ); - return 0.5 * ( ( k -= 2 ) * k * ( ( s + 1 ) * k + s ) + 2 ); + var s = 1.70158 * 1.525; + if ( ( k *= 2 ) < 1 ) return 0.5 * ( k * k * ( ( s + 1 ) * k - s ) ); + return 0.5 * ( ( k -= 2 ) * k * ( ( s + 1 ) * k + s ) + 2 ); - } + } - }, + }, /** * Bounce easing. * * @class Phaser.Easing.Bounce */ - Bounce: { + Bounce: { - /** - * Bounce ease-in. - * - * @method Phaser.Easing.Bounce#In - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - In: function ( k ) { + /** + * Bounce ease-in. + * + * @method Phaser.Easing.Bounce#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + In: function ( k ) { - return 1 - Phaser.Easing.Bounce.Out( 1 - k ); + return 1 - Phaser.Easing.Bounce.Out( 1 - k ); - }, + }, - /** - * Bounce ease-out. - * - * @method Phaser.Easing.Bounce#Out - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - Out: function ( k ) { + /** + * Bounce ease-out. + * + * @method Phaser.Easing.Bounce#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + Out: function ( k ) { - if ( k < ( 1 / 2.75 ) ) { + if ( k < ( 1 / 2.75 ) ) { - return 7.5625 * k * k; + return 7.5625 * k * k; - } else if ( k < ( 2 / 2.75 ) ) { + } else if ( k < ( 2 / 2.75 ) ) { - return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75; + return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75; - } else if ( k < ( 2.5 / 2.75 ) ) { + } else if ( k < ( 2.5 / 2.75 ) ) { - return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375; + return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375; - } else { + } else { - return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375; + return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375; - } + } - }, + }, - /** - * Bounce ease-in/out. - * - * @method Phaser.Easing.Bounce#InOut - * @param {number} k - The value to be tweened. - * @returns {number} The tweened value. - */ - InOut: function ( k ) { + /** + * Bounce ease-in/out. + * + * @method Phaser.Easing.Bounce#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ + InOut: function ( k ) { - if ( k < 0.5 ) return Phaser.Easing.Bounce.In( k * 2 ) * 0.5; - return Phaser.Easing.Bounce.Out( k * 2 - 1 ) * 0.5 + 0.5; + if ( k < 0.5 ) return Phaser.Easing.Bounce.In( k * 2 ) * 0.5; + return Phaser.Easing.Bounce.Out( k * 2 - 1 ) * 0.5 + 0.5; - } + } - } + } }; @@ -28475,124 +29016,91 @@ Phaser.Time = function (game) { this.game = game; /** - * The time at which the Game instance started. - * @property {number} _started + * @property {number} _started - The time at which the Game instance started. * @private - * @default */ this._started = 0; /** - * The time (in ms) that the last second counter ticked over. - * @property {number} _timeLastSecond + * @property {number} _timeLastSecond - The time (in ms) that the last second counter ticked over. * @private - * @default */ this._timeLastSecond = 0; /** - * The time the game started being paused. - * @property {number} _pauseStarted + * @property {number} _pauseStarted - The time the game started being paused. * @private - * @default */ this._pauseStarted = 0; /** - * The elapsed time calculated for the physics motion updates. - * @property {number} physicsElapsed - * @default + * @property {number} physicsElapsed - The elapsed time calculated for the physics motion updates. */ this.physicsElapsed = 0; /** - * Game time counter. - * @property {number} time - * @default + * @property {number} time - Game time counter. */ this.time = 0; /** - * Records how long the game has been paused for. Is reset each time the game pauses. - * @property {number} pausedTime - * @default + * @property {number} pausedTime - Records how long the game has been paused for. Is reset each time the game pauses. */ this.pausedTime = 0; /** - * The time right now. - * @property {number} now - * @default + * @property {number} now - The time right now. */ this.now = 0; /** - * Elapsed time since the last frame. - * @property {number} elapsed - * @default + * @property {number} elapsed - Elapsed time since the last frame. */ this.elapsed = 0; /** - * Frames per second. - * @property {number} fps - * @default + * @property {number} fps - Frames per second. */ this.fps = 0; /** - * The lowest rate the fps has dropped to. - * @property {number} fpsMin - * @default + * @property {number} fpsMin - The lowest rate the fps has dropped to. */ this.fpsMin = 1000; /** - * The highest rate the fps has reached (usually no higher than 60fps). - * @property {number} fpsMax - * @default + * @property {number} fpsMax - The highest rate the fps has reached (usually no higher than 60fps). */ this.fpsMax = 0; /** - * The minimum amount of time the game has taken between two frames. - * @property {number} msMin + * @property {number} msMin - The minimum amount of time the game has taken between two frames. * @default */ this.msMin = 1000; /** - * The maximum amount of time the game has taken between two frames. - * @property {number} msMax - * @default + * @property {number} msMax - The maximum amount of time the game has taken between two frames. */ this.msMax = 0; /** - * The number of frames record in the last second. - * @property {number} frames - * @default + * @property {number} frames - The number of frames record in the last second. */ this.frames = 0; /** - * Records how long the game was paused for in miliseconds. - * @property {number} pauseDuration - * @default + * @property {number} pauseDuration - Records how long the game was paused for in miliseconds. */ this.pauseDuration = 0; /** - * The value that setTimeout needs to work out when to next update - * @property {number} timeToCall - * @default + * @property {number} timeToCall - The value that setTimeout needs to work out when to next update */ this.timeToCall = 0; /** - * Internal value used by timeToCall as part of the setTimeout loop - * @property {number} lastTime - * @default + * @property {number} lastTime - Internal value used by timeToCall as part of the setTimeout loop */ this.lastTime = 0; @@ -28601,9 +29109,8 @@ Phaser.Time = function (game) { this.game.onResume.add(this.gameResumed, this); /** - * Description. - * @property {boolean} _justResumed - * @default + * @property {boolean} _justResumed - Internal value used to recover from the game pause state. + * @private */ this._justResumed = false; @@ -28611,15 +29118,6 @@ Phaser.Time = function (game) { Phaser.Time.prototype = { - /** - * The number of seconds that have elapsed since the game was started. - * @method Phaser.Time#totalElapsedSeconds - * @return {number} - */ - totalElapsedSeconds: function() { - return (this.now - this._started) * 0.001; - }, - /** * Updates the game clock and calculate the fps. This is called automatically by Phaser.Game. * @method Phaser.Time#update @@ -28696,6 +29194,15 @@ Phaser.Time.prototype = { }, + /** + * The number of seconds that have elapsed since the game was started. + * @method Phaser.Time#totalElapsedSeconds + * @return {number} + */ + totalElapsedSeconds: function() { + return (this.now - this._started) * 0.001; + }, + /** * How long has passed since the given time. * @method Phaser.Time#elapsedSince @@ -28731,6 +29238,123 @@ Phaser.Time.prototype = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +/** +* Timer constructor. +* +* @class Phaser.Timer +* @classdesc A Timer +* @constructor +* @param {Phaser.Game} game A reference to the currently running game. +*/ +Phaser.Timer = function (game) { + + /** + * @property {Phaser.Game} game - Local reference to game. + */ + this.game = game; + + /** + * The time at which this Timer instance started. + * @property {number} _started + * @private + * @default + */ + this._started = 0; + + /** + * The time (in ms) that the last second counter ticked over. + * @property {number} _timeLastSecond + * @private + * @default + */ + this._timeLastSecond = 0; + + this.running = false; + + this.events = []; + + this.onEvent = new Phaser.Signal(); + + // Need to add custom FPS rate, for now we'll just use seconds + +} + +Phaser.Timer.prototype = { + + // delay could be from now, when the timer is created, or relative to an already running timer + + // add: function (delay, callback, callbackContext) { + add: function (delay) { + + this.events.push({ + delay: delay, + dispatched: false, + args: Array.prototype.splice.call(arguments, 1) + }); + + // this.events.push({ + // delay: delay, + // dispatched: false, + // callback: callback, + // callbackContext: callbackContext, + // args: Array.prototype.splice.call(arguments, 3) + // }); + + }, + + start: function() { + + this._started = this.game.time.now; + this.running = true; + + // sort the events based on delay here, also don't run unless events is populated + // add ability to auto-stop once all events are done + // add support for maximum duration + // add support for delay before starting + // add signals? + + }, + + stop: function() { + + this.running = false; + this.events.length = 0; + + }, + + update: function() { + + // TODO: Game Paused support + + if (this.running) + { + var seconds = this.seconds(); + + for (var i = 0, len = this.events.length; i < len; i++) + { + if (this.events[i].dispatched === false && seconds >= this.events[i].delay) + { + this.events[i].dispatched = true; + // this.events[i].callback.apply(this.events[i].callbackContext, this.events[i].args); + this.onEvent.dispatch.apply(this, this.events[i].args); + // ought to slice it now + } + } + } + + }, + + seconds: function() { + return (this.game.time.now - this._started) * 0.001; + } + +} +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + /** * The Animation Manager is used to add, play and update Phaser Animations. * Any Game Object such as Phaser.Sprite that supports animation contains a single AnimationManager instance. @@ -28744,49 +29368,49 @@ Phaser.AnimationManager = function (sprite) { /** * @property {Phaser.Sprite} sprite - A reference to the parent Sprite that owns this AnimationManager. */ - this.sprite = sprite; + this.sprite = sprite; /** * @property {Phaser.Game} game - A reference to the currently running Game. */ - this.game = sprite.game; + this.game = sprite.game; - /** - * @property {Phaser.Frame} currentFrame - The currently displayed Frame of animation, if any. - * @default - */ - this.currentFrame = null; - - /** - * @property {boolean} updateIfVisible - Should the animation data continue to update even if the Sprite.visible is set to false. - * @default - */ - this.updateIfVisible = true; + /** + * @property {Phaser.Frame} currentFrame - The currently displayed Frame of animation, if any. + * @default + */ + this.currentFrame = null; + + /** + * @property {boolean} updateIfVisible - Should the animation data continue to update even if the Sprite.visible is set to false. + * @default + */ + this.updateIfVisible = true; - /** - * @property {boolean} isLoaded - Set to true once animation data has been loaded. - * @default - */ - this.isLoaded = false; + /** + * @property {boolean} isLoaded - Set to true once animation data has been loaded. + * @default + */ + this.isLoaded = false; - /** - * @property {Phaser.FrameData} _frameData - A temp. var for holding the currently playing Animations FrameData. - * @private - * @default - */ - this._frameData = null; + /** + * @property {Phaser.FrameData} _frameData - A temp. var for holding the currently playing Animations FrameData. + * @private + * @default + */ + this._frameData = null; - /** - * @property {object} _anims - An internal object that stores all of the Animation instances. - * @private - */ - this._anims = {}; + /** + * @property {object} _anims - An internal object that stores all of the Animation instances. + * @private + */ + this._anims = {}; - /** - * @property {object} _outputFrames - An internal object to help avoid gc. - * @private - */ - this._outputFrames = []; + /** + * @property {object} _outputFrames - An internal object to help avoid gc. + * @private + */ + this._outputFrames = []; }; @@ -28800,226 +29424,226 @@ Phaser.AnimationManager.prototype = { * @private * @param {Phaser.FrameData} frameData - The FrameData set to load. */ - loadFrameData: function (frameData) { + loadFrameData: function (frameData) { - this._frameData = frameData; - this.frame = 0; - this.isLoaded = true; + this._frameData = frameData; + this.frame = 0; + this.isLoaded = true; - }, + }, - /** - * Adds a new animation under the given key. Optionally set the frames, frame rate and loop. - * Animations added in this way are played back with the play function. - * + /** + * Adds a new animation under the given key. Optionally set the frames, frame rate and loop. + * Animations added in this way are played back with the play function. + * * @method Phaser.AnimationManager#add - * @param {string} name - The unique (within this Sprite) name for the animation, i.e. "run", "fire", "walk". - * @param {Array} [frames=null] - An array of numbers/strings that correspond to the frames to add to this animation and in which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used. - * @param {number} [frameRate=60] - The speed at which the animation should play. The speed is given in frames per second. - * @param {boolean} [loop=false] - Whether or not the animation is looped or just plays once. - * @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? - * @return {Phaser.Animation} The Animation object that was created. - */ - add: function (name, frames, frameRate, loop, useNumericIndex) { + * @param {string} name - The unique (within this Sprite) name for the animation, i.e. "run", "fire", "walk". + * @param {Array} [frames=null] - An array of numbers/strings that correspond to the frames to add to this animation and in which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used. + * @param {number} [frameRate=60] - The speed at which the animation should play. The speed is given in frames per second. + * @param {boolean} [loop=false] - Whether or not the animation is looped or just plays once. + * @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? + * @return {Phaser.Animation} The Animation object that was created. + */ + add: function (name, frames, frameRate, loop, useNumericIndex) { - if (this._frameData == null) - { - console.warn('No FrameData available for Phaser.Animation ' + name); - return; - } + if (this._frameData == null) + { + console.warn('No FrameData available for Phaser.Animation ' + name); + return; + } - frameRate = frameRate || 60; + frameRate = frameRate || 60; - if (typeof loop === 'undefined') { loop = false; } + if (typeof loop === 'undefined') { loop = false; } - // If they didn't set the useNumericIndex then let's at least try and guess it - if (typeof useNumericIndex === 'undefined') - { - if (frames && typeof frames[0] === 'number') - { - useNumericIndex = true; - } - else - { - useNumericIndex = false; - } - } + // If they didn't set the useNumericIndex then let's at least try and guess it + if (typeof useNumericIndex === 'undefined') + { + if (frames && typeof frames[0] === 'number') + { + useNumericIndex = true; + } + else + { + useNumericIndex = false; + } + } - // Create the signals the AnimationManager will emit - if (this.sprite.events.onAnimationStart == null) - { - this.sprite.events.onAnimationStart = new Phaser.Signal(); - this.sprite.events.onAnimationComplete = new Phaser.Signal(); - this.sprite.events.onAnimationLoop = new Phaser.Signal(); - } + // Create the signals the AnimationManager will emit + if (this.sprite.events.onAnimationStart == null) + { + this.sprite.events.onAnimationStart = new Phaser.Signal(); + this.sprite.events.onAnimationComplete = new Phaser.Signal(); + this.sprite.events.onAnimationLoop = new Phaser.Signal(); + } - this._outputFrames.length = 0; + this._outputFrames.length = 0; - this._frameData.getFrameIndexes(frames, useNumericIndex, this._outputFrames); + this._frameData.getFrameIndexes(frames, useNumericIndex, this._outputFrames); - this._anims[name] = new Phaser.Animation(this.game, this.sprite, name, this._frameData, this._outputFrames, frameRate, loop); - this.currentAnim = this._anims[name]; - this.currentFrame = this.currentAnim.currentFrame; - this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + this._anims[name] = new Phaser.Animation(this.game, this.sprite, name, this._frameData, this._outputFrames, frameRate, loop); + this.currentAnim = this._anims[name]; + this.currentFrame = this.currentAnim.currentFrame; + this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); - return this._anims[name]; + return this._anims[name]; - }, + }, - /** - * Check whether the frames in the given array are valid and exist. - * + /** + * Check whether the frames in the given array are valid and exist. + * * @method Phaser.AnimationManager#validateFrames - * @param {Array} frames - An array of frames to be validated. - * @param {boolean} [useNumericIndex=true] - Validate the frames based on their numeric index (true) or string index (false) - * @return {boolean} True if all given Frames are valid, otherwise false. - */ - validateFrames: function (frames, useNumericIndex) { + * @param {Array} frames - An array of frames to be validated. + * @param {boolean} [useNumericIndex=true] - Validate the frames based on their numeric index (true) or string index (false) + * @return {boolean} True if all given Frames are valid, otherwise false. + */ + validateFrames: function (frames, useNumericIndex) { - if (typeof useNumericIndex == 'undefined') { useNumericIndex = true; } + if (typeof useNumericIndex == 'undefined') { useNumericIndex = true; } - for (var i = 0; i < frames.length; i++) - { - if (useNumericIndex == true) - { - if (frames[i] > this._frameData.total) - { - return false; - } - } - else - { - if (this._frameData.checkFrameName(frames[i]) == false) - { - return false; - } - } - } + for (var i = 0; i < frames.length; i++) + { + if (useNumericIndex === true) + { + if (frames[i] > this._frameData.total) + { + return false; + } + } + else + { + if (this._frameData.checkFrameName(frames[i]) === false) + { + return false; + } + } + } - return true; + return true; - }, + }, - /** - * Play an animation based on the given key. The animation should previously have been added via sprite.animations.add() - * If the requested animation is already playing this request will be ignored. If you need to reset an already running animation do so directly on the Animation object itself. - * - * @method Phaser.AnimationManager#play - * @param {string} name - The name of the animation to be played, e.g. "fire", "walk", "jump". + /** + * Play an animation based on the given key. The animation should previously have been added via sprite.animations.add() + * If the requested animation is already playing this request will be ignored. If you need to reset an already running animation do so directly on the Animation object itself. + * + * @method Phaser.AnimationManager#play + * @param {string} name - The name of the animation to be played, e.g. "fire", "walk", "jump". * @param {number} [frameRate=null] - The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. * @param {boolean} [loop=false] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. * @param {boolean} [killOnComplete=false] - If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. * @return {Phaser.Animation} A reference to playing Animation instance. - */ - play: function (name, frameRate, loop, killOnComplete) { + */ + play: function (name, frameRate, loop, killOnComplete) { - if (this._anims[name]) - { - if (this.currentAnim == this._anims[name]) - { - if (this.currentAnim.isPlaying == false) - { - this.currentAnim.paused = false; - return this.currentAnim.play(frameRate, loop, killOnComplete); - } - } - else - { - this.currentAnim = this._anims[name]; - this.currentAnim.paused = false; - return this.currentAnim.play(frameRate, loop, killOnComplete); - } - } + if (this._anims[name]) + { + if (this.currentAnim == this._anims[name]) + { + if (this.currentAnim.isPlaying === false) + { + this.currentAnim.paused = false; + return this.currentAnim.play(frameRate, loop, killOnComplete); + } + } + else + { + this.currentAnim = this._anims[name]; + this.currentAnim.paused = false; + return this.currentAnim.play(frameRate, loop, killOnComplete); + } + } - }, + }, - /** - * Stop playback of an animation. If a name is given that specific animation is stopped, otherwise the current animation is stopped. - * The currentAnim property of the AnimationManager is automatically set to the animation given. - * - * @method Phaser.AnimationManager#stop - * @param {string} [name=null] - The name of the animation to be stopped, e.g. "fire". If none is given the currently running animation is stopped. - * @param {boolean} [resetFrame=false] - When the animation is stopped should the currentFrame be set to the first frame of the animation (true) or paused on the last frame displayed (false) - */ - stop: function (name, resetFrame) { + /** + * Stop playback of an animation. If a name is given that specific animation is stopped, otherwise the current animation is stopped. + * The currentAnim property of the AnimationManager is automatically set to the animation given. + * + * @method Phaser.AnimationManager#stop + * @param {string} [name=null] - The name of the animation to be stopped, e.g. "fire". If none is given the currently running animation is stopped. + * @param {boolean} [resetFrame=false] - When the animation is stopped should the currentFrame be set to the first frame of the animation (true) or paused on the last frame displayed (false) + */ + stop: function (name, resetFrame) { - if (typeof resetFrame == 'undefined') { resetFrame = false; } + if (typeof resetFrame == 'undefined') { resetFrame = false; } - if (typeof name == 'string') - { - if (this._anims[name]) - { - this.currentAnim = this._anims[name]; - this.currentAnim.stop(resetFrame); - } - } - else - { - if (this.currentAnim) - { - this.currentAnim.stop(resetFrame); - } - } + if (typeof name == 'string') + { + if (this._anims[name]) + { + this.currentAnim = this._anims[name]; + this.currentAnim.stop(resetFrame); + } + } + else + { + if (this.currentAnim) + { + this.currentAnim.stop(resetFrame); + } + } - }, + }, - /** - * The main update function is called by the Sprites update loop. It's responsible for updating animation frames and firing related events. - * - * @method Phaser.AnimationManager#update - * @protected + /** + * The main update function is called by the Sprites update loop. It's responsible for updating animation frames and firing related events. + * + * @method Phaser.AnimationManager#update + * @protected * @return {boolean} True if a new animation frame has been set, otherwise false. - */ - update: function () { + */ + update: function () { - if (this.updateIfVisible && this.sprite.visible == false) - { - return false; - } + if (this.updateIfVisible && this.sprite.visible === false) + { + return false; + } - if (this.currentAnim && this.currentAnim.update() == true) - { - this.currentFrame = this.currentAnim.currentFrame; - this.sprite.currentFrame = this.currentFrame; - return true; - } + if (this.currentAnim && this.currentAnim.update() === true) + { + this.currentFrame = this.currentAnim.currentFrame; + this.sprite.currentFrame = this.currentFrame; + return true; + } - return false; + return false; - }, + }, - /** - * 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". + /** + * 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) { + */ + getAnimation: function (name) { - if (typeof name == 'string') - { - if (this._anims[name]) - { - return this._anims[name]; - } - } + if (typeof name == 'string') + { + if (this._anims[name]) + { + return this._anims[name]; + } + } - return false; + return false; - }, + }, /** * Refreshes the current frame data back to the parent Sprite and also resets the texture data. * * @method Phaser.AnimationManager#refreshFrame */ - refreshFrame: function () { + refreshFrame: function () { this.sprite.currentFrame = this.currentFrame; - this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); - }, + }, /** * Destroys all references this AnimationManager contains. Sets the _anims to a new object and nulls the current animation. @@ -29043,7 +29667,7 @@ Phaser.AnimationManager.prototype = { * @property {Phaser.FrameData} frameData - The current animations FrameData. * @readonly */ -Object.defineProperty(Phaser.AnimationManager.prototype, "frameData", { +Object.defineProperty(Phaser.AnimationManager.prototype, 'frameData', { get: function () { return this._frameData; @@ -29056,7 +29680,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameData", { * @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded. * @readonly */ -Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", { +Object.defineProperty(Phaser.AnimationManager.prototype, 'frameTotal', { get: function () { @@ -29076,7 +29700,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", { * @name Phaser.AnimationManager#paused * @property {boolean} paused - Gets and sets the paused state of the current animation. */ -Object.defineProperty(Phaser.AnimationManager.prototype, "paused", { +Object.defineProperty(Phaser.AnimationManager.prototype, 'paused', { get: function () { @@ -29096,15 +29720,15 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "paused", { * @name Phaser.AnimationManager#frame * @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display. */ -Object.defineProperty(Phaser.AnimationManager.prototype, "frame", { +Object.defineProperty(Phaser.AnimationManager.prototype, 'frame', { get: function () { - if (this.currentFrame) - { - return this._frameIndex; - } - + if (this.currentFrame) + { + return this._frameIndex; + } + }, set: function (value) { @@ -29114,7 +29738,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", { this.currentFrame = this._frameData.getFrame(value); this._frameIndex = value; this.sprite.currentFrame = this.currentFrame; - this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); } } @@ -29125,14 +29749,14 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", { * @name Phaser.AnimationManager#frameName * @property {string} frameName - Gets or sets the current frame name and updates the Texture Cache for display. */ -Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", { +Object.defineProperty(Phaser.AnimationManager.prototype, 'frameName', { get: function () { - if (this.currentFrame) - { - return this.currentFrame.name; - } + if (this.currentFrame) + { + return this.currentFrame.name; + } }, @@ -29143,11 +29767,11 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", { this.currentFrame = this._frameData.getFrameByName(value); this._frameIndex = this.currentFrame.index; this.sprite.currentFrame = this.currentFrame; - this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); } else { - console.warn("Cannot set frameName: " + value); + console.warn('Cannot set frameName: ' + value); } } @@ -29178,13 +29802,13 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope /** * @property {Phaser.Game} game - A reference to the currently running Game. */ - this.game = game; + this.game = game; /** * @property {Phaser.Sprite} _parent - A reference to the parent Sprite that owns this Animation. * @private */ - this._parent = parent; + this._parent = parent; /** * @property {Phaser.FrameData} _frameData - The FrameData the Animation uses. @@ -29201,18 +29825,18 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope * @property {object} _frames * @private */ - this._frames = []; + this._frames = []; this._frames = this._frames.concat(frames); /** * @property {number} delay - The delay in ms between each frame of the Animation. */ - this.delay = 1000 / delay; + this.delay = 1000 / delay; /** * @property {boolean} looped - The loop state of the Animation. */ - this.looped = looped; + this.looped = looped; /** * @property {boolean} looped - The loop state of the Animation. @@ -29223,13 +29847,13 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope * @property {boolean} isFinished - The finished state of the Animation. Set to true once playback completes, false during playback. * @default */ - this.isFinished = false; + this.isFinished = false; /** * @property {boolean} isPlaying - The playing state of the Animation. Set to false once playback completes, true during playback. * @default */ - this.isPlaying = false; + this.isPlaying = false; /** * @property {boolean} isPaused - The paused state of the Animation. @@ -29249,7 +29873,7 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope * @private * @default */ - this._frameIndex = 0; + this._frameIndex = 0; /** * @property {number} _frameDiff @@ -29268,8 +29892,8 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope /** * @property {Phaser.Frame} currentFrame - The currently displayed frame of the Animation. */ - this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); - + this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); + }; Phaser.Animation.prototype = { @@ -29314,7 +29938,7 @@ Phaser.Animation.prototype = { this._frameIndex = 0; this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); - this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); if (this._parent.events) { @@ -29381,7 +30005,7 @@ Phaser.Animation.prototype = { return false; } - if (this.isPlaying == true && this.game.time.now >= this._timeNextFrame) + if (this.isPlaying === true && this.game.time.now >= this._timeNextFrame) { this._frameSkip = 1; @@ -29486,7 +30110,7 @@ Phaser.Animation.prototype = { * @name Phaser.Animation#paused * @property {boolean} paused - Gets and sets the paused state of this Animation. */ -Object.defineProperty(Phaser.Animation.prototype, "paused", { +Object.defineProperty(Phaser.Animation.prototype, 'paused', { get: function () { @@ -29521,7 +30145,7 @@ Object.defineProperty(Phaser.Animation.prototype, "paused", { * @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded. * @readonly */ -Object.defineProperty(Phaser.Animation.prototype, "frameTotal", { +Object.defineProperty(Phaser.Animation.prototype, 'frameTotal', { get: function () { return this._frames.length; @@ -29533,7 +30157,7 @@ Object.defineProperty(Phaser.Animation.prototype, "frameTotal", { * @name Phaser.Animation#frame * @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display. */ -Object.defineProperty(Phaser.Animation.prototype, "frame", { +Object.defineProperty(Phaser.Animation.prototype, 'frame', { get: function () { @@ -29555,7 +30179,7 @@ Object.defineProperty(Phaser.Animation.prototype, "frame", { if (this.currentFrame !== null) { this._frameIndex = value; - this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); } } @@ -29645,124 +30269,124 @@ Phaser.Animation.generateFrameNames = function (prefix, start, stop, suffix, zer */ Phaser.Frame = function (index, x, y, width, height, name, uuid) { - /** - * @property {number} index - The index of this Frame within the FrameData set it is being added to. - */ - this.index = index; - - /** - * @property {number} x - X position within the image to cut from. - */ - this.x = x; + /** + * @property {number} index - The index of this Frame within the FrameData set it is being added to. + */ + this.index = index; + + /** + * @property {number} x - X position within the image to cut from. + */ + this.x = x; - /** - * @property {number} y - Y position within the image to cut from. - */ - this.y = y; + /** + * @property {number} y - Y position within the image to cut from. + */ + this.y = y; - /** - * @property {number} width - Width of the frame. - */ - this.width = width; + /** + * @property {number} width - Width of the frame. + */ + this.width = width; - /** - * @property {number} height - Height of the frame. - */ - this.height = height; + /** + * @property {number} height - Height of the frame. + */ + this.height = height; - /** - * @property {string} name - Useful for Texture Atlas files (is set to the filename value). - */ - this.name = name; + /** + * @property {string} name - Useful for Texture Atlas files (is set to the filename value). + */ + this.name = name; - /** - * @property {string} uuid - A link to the PIXI.TextureCache entry. - */ - this.uuid = uuid; + /** + * @property {string} uuid - A link to the PIXI.TextureCache entry. + */ + this.uuid = uuid; - /** - * @property {number} centerX - Center X position within the image to cut from. - */ + /** + * @property {number} centerX - Center X position within the image to cut from. + */ this.centerX = Math.floor(width / 2); - /** - * @property {number} centerY - Center Y position within the image to cut from. - */ + /** + * @property {number} centerY - Center Y position within the image to cut from. + */ this.centerY = Math.floor(height / 2); - /** - * @property {number} distance - The distance from the top left to the bottom-right of this Frame. - */ - this.distance = Phaser.Math.distance(0, 0, width, height); + /** + * @property {number} distance - The distance from the top left to the bottom-right of this Frame. + */ + this.distance = Phaser.Math.distance(0, 0, width, height); - /** - * @property {boolean} rotated - Rotated? (not yet implemented) - * @default - */ - this.rotated = false; + /** + * @property {boolean} rotated - Rotated? (not yet implemented) + * @default + */ + this.rotated = false; - /** - * @property {string} rotationDirection - Either 'cw' or 'ccw', rotation is always 90 degrees. - * @default 'cw' - */ - this.rotationDirection = 'cw'; + /** + * @property {string} rotationDirection - Either 'cw' or 'ccw', rotation is always 90 degrees. + * @default 'cw' + */ + this.rotationDirection = 'cw'; - /** - * @property {boolean} trimmed - Was it trimmed when packed? - * @default - */ - this.trimmed = false; + /** + * @property {boolean} trimmed - Was it trimmed when packed? + * @default + */ + this.trimmed = false; - /** - * @property {number} sourceSizeW - Width of the original sprite. - */ + /** + * @property {number} sourceSizeW - Width of the original sprite. + */ this.sourceSizeW = width; - /** - * @property {number} sourceSizeH - Height of the original sprite. - */ + /** + * @property {number} sourceSizeH - Height of the original sprite. + */ this.sourceSizeH = height; - /** - * @property {number} spriteSourceSizeX - X position of the trimmed sprite inside original sprite. - * @default - */ - this.spriteSourceSizeX = 0; + /** + * @property {number} spriteSourceSizeX - X position of the trimmed sprite inside original sprite. + * @default + */ + this.spriteSourceSizeX = 0; - /** - * @property {number} spriteSourceSizeY - Y position of the trimmed sprite inside original sprite. - * @default - */ - this.spriteSourceSizeY = 0; + /** + * @property {number} spriteSourceSizeY - Y position of the trimmed sprite inside original sprite. + * @default + */ + this.spriteSourceSizeY = 0; - /** - * @property {number} spriteSourceSizeW - Width of the trimmed sprite. - * @default - */ - this.spriteSourceSizeW = 0; + /** + * @property {number} spriteSourceSizeW - Width of the trimmed sprite. + * @default + */ + this.spriteSourceSizeW = 0; - /** - * @property {number} spriteSourceSizeH - Height of the trimmed sprite. - * @default - */ - this.spriteSourceSizeH = 0; + /** + * @property {number} spriteSourceSizeH - Height of the trimmed sprite. + * @default + */ + this.spriteSourceSizeH = 0; }; Phaser.Frame.prototype = { - /** - * If the frame was trimmed when added to the Texture Atlas this records the trim and source data. - * - * @method Phaser.Frame#setTrim - * @param {boolean} trimmed - If this frame was trimmed or not. - * @param {number} actualWidth - The width of the frame before being trimmed. - * @param {number} actualHeight - The height of the frame before being trimmed. - * @param {number} destX - The destination X position of the trimmed frame for display. - * @param {number} destY - The destination Y position of the trimmed frame for display. - * @param {number} destWidth - The destination width of the trimmed frame for display. - * @param {number} destHeight - The destination height of the trimmed frame for display. - */ + /** + * If the frame was trimmed when added to the Texture Atlas this records the trim and source data. + * + * @method Phaser.Frame#setTrim + * @param {boolean} trimmed - If this frame was trimmed or not. + * @param {number} actualWidth - The width of the frame before being trimmed. + * @param {number} actualHeight - The height of the frame before being trimmed. + * @param {number} destX - The destination X position of the trimmed frame for display. + * @param {number} destY - The destination Y position of the trimmed frame for display. + * @param {number} destWidth - The destination width of the trimmed frame for display. + * @param {number} destHeight - The destination height of the trimmed frame for display. + */ setTrim: function (trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight) { this.trimmed = trimmed; @@ -29773,8 +30397,8 @@ Phaser.Frame.prototype = { this.height = actualHeight; this.sourceSizeW = actualWidth; this.sourceSizeH = actualHeight; - this.centerX = Math.floor(actualWidth / 2); - this.centerY = Math.floor(actualHeight / 2); + this.centerX = Math.floor(actualWidth / 2); + this.centerY = Math.floor(actualHeight / 2); this.spriteSourceSizeX = destX; this.spriteSourceSizeY = destY; this.spriteSourceSizeW = destWidth; @@ -29799,17 +30423,17 @@ Phaser.Frame.prototype = { */ Phaser.FrameData = function () { - /** - * @property {Array} _frames - Local array of frames. - * @private - */ + /** + * @property {Array} _frames - Local array of frames. + * @private + */ this._frames = []; - /** - * @property {Array} _frameNames - Local array of frame names for name to index conversions. - * @private - */ + /** + * @property {Array} _frameNames - Local array of frame names for name to index conversions. + * @private + */ this._frameNames = []; }; @@ -29838,13 +30462,13 @@ Phaser.FrameData.prototype = { }, - /** - * Get a Frame by its numerical index. + /** + * Get a Frame by its numerical index. * * @method Phaser.FrameData#getFrame - * @param {number} index - The index of the frame you want to get. - * @return {Phaser.Frame} The frame, if found. - */ + * @param {number} index - The index of the frame you want to get. + * @return {Phaser.Frame} The frame, if found. + */ getFrame: function (index) { if (this._frames.length > index) @@ -29892,15 +30516,15 @@ Phaser.FrameData.prototype = { }, - /** - * Returns a range of frames based on the given start and end frame indexes and returns them in an Array. + /** + * Returns a range of frames based on the given start and end frame indexes and returns them in an Array. * * @method Phaser.FrameData#getFrameRange * @param {number} start - The starting frame index. - * @param {number} end - The ending frame index. - * @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created. - * @return {Array} An array of Frames between the start and end index values, or an empty array if none were found. - */ + * @param {number} end - The ending frame index. + * @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created. + * @return {Array} An array of Frames between the start and end index values, or an empty array if none were found. + */ getFrameRange: function (start, end, output) { if (typeof output === "undefined") { output = []; } @@ -29914,8 +30538,8 @@ Phaser.FrameData.prototype = { }, - /** - * Returns all of the Frames in this FrameData set where the frame index is found in the input array. + /** + * Returns all of the Frames in this FrameData set where the frame index is found in the input array. * The frames are returned in the output array, or if none is provided in a new Array object. * * @method Phaser.FrameData#getFrames @@ -29923,13 +30547,13 @@ Phaser.FrameData.prototype = { * @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? (false) * @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created. * @return {Array} An array of all Frames in this FrameData set matching the given names or IDs. - */ + */ getFrames: function (frames, useNumericIndex, output) { if (typeof useNumericIndex === "undefined") { useNumericIndex = true; } if (typeof output === "undefined") { output = []; } - if (typeof frames === "undefined" || frames.length == 0) + if (typeof frames === "undefined" || frames.length === 0) { // No input array, so we loop through all frames for (var i = 0; i < this._frames.length; i++) @@ -29976,7 +30600,7 @@ Phaser.FrameData.prototype = { if (typeof useNumericIndex === "undefined") { useNumericIndex = true; } if (typeof output === "undefined") { output = []; } - if (typeof frames === "undefined" || frames.length == 0) + if (typeof frames === "undefined" || frames.length === 0) { // No frames array, so we loop through all frames for (var i = 0, len = this._frames.length; i < len; i++) @@ -30080,7 +30704,7 @@ Phaser.AnimationParser = { } // Zero or smaller than frame sizes? - if (width == 0 || height == 0 || width < frameWidth || height < frameHeight || total === 0) + if (width === 0 || height === 0 || width < frameWidth || height < frameHeight || total === 0) { console.warn("Phaser.AnimationParser.spriteSheet: width/height zero or width/height < given frameWidth/frameHeight"); return null; @@ -30149,13 +30773,13 @@ Phaser.AnimationParser = { newFrame = data.addFrame(new Phaser.Frame( i, - frames[i].frame.x, - frames[i].frame.y, - frames[i].frame.w, - frames[i].frame.h, - frames[i].filename, + frames[i].frame.x, + frames[i].frame.y, + frames[i].frame.w, + frames[i].frame.h, + frames[i].filename, uuid - )); + )); PIXI.TextureCache[uuid] = new PIXI.Texture(PIXI.BaseTextureCache[cacheKey], { x: frames[i].frame.x, @@ -30167,12 +30791,12 @@ Phaser.AnimationParser = { if (frames[i].trimmed) { newFrame.setTrim( - frames[i].trimmed, - frames[i].sourceSize.w, - frames[i].sourceSize.h, - frames[i].spriteSourceSize.x, - frames[i].spriteSourceSize.y, - frames[i].spriteSourceSize.w, + frames[i].trimmed, + frames[i].sourceSize.w, + frames[i].sourceSize.h, + frames[i].spriteSourceSize.x, + frames[i].spriteSourceSize.y, + frames[i].spriteSourceSize.w, frames[i].spriteSourceSize.h ); @@ -30221,10 +30845,10 @@ Phaser.AnimationParser = { newFrame = data.addFrame(new Phaser.Frame( i, - frames[key].frame.x, - frames[key].frame.y, - frames[key].frame.w, - frames[key].frame.h, + frames[key].frame.x, + frames[key].frame.y, + frames[key].frame.w, + frames[key].frame.h, key, uuid )); @@ -30239,12 +30863,12 @@ Phaser.AnimationParser = { if (frames[key].trimmed) { newFrame.setTrim( - frames[key].trimmed, - frames[key].sourceSize.w, - frames[key].sourceSize.h, - frames[key].spriteSourceSize.x, - frames[key].spriteSourceSize.y, - frames[key].spriteSourceSize.w, + frames[key].trimmed, + frames[key].sourceSize.w, + frames[key].sourceSize.h, + frames[key].spriteSourceSize.x, + frames[key].spriteSourceSize.y, + frames[key].spriteSourceSize.w, frames[key].spriteSourceSize.h ); @@ -30286,6 +30910,7 @@ Phaser.AnimationParser = { var newFrame; var uuid; + var name; var frame; var x; var y; @@ -30303,20 +30928,20 @@ Phaser.AnimationParser = { frame = frames[i].attributes; name = frame.name.nodeValue; - x = parseInt(frame.x.nodeValue); - y = parseInt(frame.y.nodeValue); - width = parseInt(frame.width.nodeValue); - height = parseInt(frame.height.nodeValue); + x = parseInt(frame.x.nodeValue, 10); + y = parseInt(frame.y.nodeValue, 10); + width = parseInt(frame.width.nodeValue, 10); + height = parseInt(frame.height.nodeValue, 10); frameX = null; frameY = null; if (frame.frameX) { - frameX = Math.abs(parseInt(frame.frameX.nodeValue)); - frameY = Math.abs(parseInt(frame.frameY.nodeValue)); - frameWidth = parseInt(frame.frameWidth.nodeValue); - frameHeight = parseInt(frame.frameHeight.nodeValue); + frameX = Math.abs(parseInt(frame.frameX.nodeValue, 10)); + frameY = Math.abs(parseInt(frame.frameY.nodeValue, 10)); + frameWidth = parseInt(frame.frameWidth.nodeValue, 10); + frameHeight = parseInt(frame.frameHeight.nodeValue, 10); } newFrame = data.addFrame(new Phaser.Frame(i, x, y, width, height, name, uuid)); @@ -30366,44 +30991,44 @@ Phaser.AnimationParser = { Phaser.Cache = function (game) { /** - * @property {Phaser.Game} game - Local reference to game. - */ - this.game = game; + * @property {Phaser.Game} game - Local reference to game. + */ + this.game = game; - /** - * @property {object} game - Canvas key-value container. - * @private - */ + /** + * @property {object} game - Canvas key-value container. + * @private + */ this._canvases = {}; /** - * @property {object} _images - Image key-value container. - * @private - */ + * @property {object} _images - Image key-value container. + * @private + */ this._images = {}; /** - * @property {object} _textures - RenderTexture key-value container. - * @private - */ + * @property {object} _textures - RenderTexture key-value container. + * @private + */ this._textures = {}; /** - * @property {object} _sounds - Sound key-value container. - * @private - */ + * @property {object} _sounds - Sound key-value container. + * @private + */ this._sounds = {}; /** - * @property {object} _text - Text key-value container. - * @private - */ + * @property {object} _text - Text key-value container. + * @private + */ this._text = {}; /** - * @property {object} _tilemaps - Tilemap key-value container. - * @private - */ + * @property {object} _tilemaps - Tilemap key-value container. + * @private + */ this._tilemaps = {}; /** @@ -30419,11 +31044,12 @@ Phaser.Cache = function (game) { this._bitmapDatas = {}; this.addDefaultImage(); + this.addMissingImage(); /** - * @property {Phaser.Signal} onSoundUnlock - Description. - */ - this.onSoundUnlock = new Phaser.Signal; + * @property {Phaser.Signal} onSoundUnlock - This event is dispatched when the sound system is unlocked via a touch event on cellular devices. + */ + this.onSoundUnlock = new Phaser.Signal(); }; @@ -30589,14 +31215,14 @@ Phaser.Cache.prototype = { }, /** - * Adds a default image to be used when a key is wrong / missing. Is mapped to the key __default. + * Adds a default image to be used in special cases such as WebGL Filters. Is mapped to the key __default. * * @method Phaser.Cache#addDefaultImage */ addDefaultImage: function () { var img = new Image(); - img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=="; + img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=="; this._images['__default'] = { url: null, data: img, spriteSheet: false }; this._images['__default'].frame = new Phaser.Frame(0, 0, 0, 32, 32, '', ''); @@ -30606,6 +31232,24 @@ Phaser.Cache.prototype = { }, + /** + * Adds an image to be used when a key is wrong / missing. Is mapped to the key __missing. + * + * @method Phaser.Cache#addMissingImage + */ + addMissingImage: function () { + + var img = new Image(); + img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=="; + + this._images['__missing'] = { url: null, data: img, spriteSheet: false }; + this._images['__missing'].frame = new Phaser.Frame(0, 0, 0, 32, 32, '', ''); + + PIXI.BaseTextureCache['__missing'] = new PIXI.BaseTexture(img); + PIXI.TextureCache['__missing'] = new PIXI.Texture(PIXI.BaseTextureCache['__missing']); + + }, + /** * Add a new text data. * @@ -30613,7 +31257,7 @@ Phaser.Cache.prototype = { * @param {string} key - Asset key for the text data. * @param {string} url - URL of this text data file. * @param {object} data - Extra text data. - */ + */ addText: function (key, url, data) { this._text[key] = { @@ -30657,7 +31301,6 @@ Phaser.Cache.prototype = { webAudio = webAudio || true; audioTag = audioTag || false; - var locked = this.game.sound.touchLocked; var decoded = false; if (audioTag) @@ -30719,13 +31362,13 @@ Phaser.Cache.prototype = { }, - /** - * Add a new decoded sound. + /** + * Add a new decoded sound. * * @method Phaser.Cache#decodedSound - * @param {string} key - Asset key for the sound. - * @param {object} data - Extra sound data. - */ + * @param {string} key - Asset key for the sound. + * @param {object} data - Extra sound data. + */ decodedSound: function (key, data) { this._sounds[key].data = data; @@ -30734,13 +31377,13 @@ Phaser.Cache.prototype = { }, - /** - * Get a canvas object from the cache by its key. + /** + * Get a canvas object from the cache by its key. * * @method Phaser.Cache#getCanvas - * @param {string} key - Asset key of the canvas you want. - * @return {object} The canvas you want. - */ + * @param {string} key - Asset key of the canvas you want. + * @return {object} The canvas you want. + */ getCanvas: function (key) { if (this._canvases[key]) @@ -30776,7 +31419,7 @@ Phaser.Cache.prototype = { * @method Phaser.Cache#checkImageKey * @param {string} key - Asset key of the image you want. * @return {boolean} True if the key exists, otherwise false. - */ + */ checkImageKey: function (key) { if (this._images[key]) @@ -30788,13 +31431,13 @@ Phaser.Cache.prototype = { }, - /** - * Get image data by key. + /** + * Get image data by key. * * @method Phaser.Cache#getImage - * @param {string} key - Asset key of the image you want. - * @return {object} The image data you want. - */ + * @param {string} key - Asset key of the image you want. + * @return {object} The image data you want. + */ getImage: function (key) { if (this._images[key]) @@ -30812,7 +31455,7 @@ Phaser.Cache.prototype = { * @method Phaser.Cache#getTileSetImage * @param {string} key - Asset key of the image you want. * @return {object} The image data you want. - */ + */ getTilesetImage: function (key) { if (this._tilesets[key]) @@ -30830,7 +31473,7 @@ Phaser.Cache.prototype = { * @method Phaser.Cache#getTileset * @param {string} key - Asset key of the image you want. * @return {Phaser.Tileset} The tileset data. The tileset image is in the data property, the tile data in tileData. - */ + */ getTileset: function (key) { if (this._tilesets[key]) @@ -30859,13 +31502,13 @@ Phaser.Cache.prototype = { return null; }, - /** - * Get frame data by key. + /** + * Get frame data by key. * * @method Phaser.Cache#getFrameData - * @param {string} key - Asset key of the frame data you want. - * @return {Phaser.FrameData} The frame data you want. - */ + * @param {string} key - Asset key of the frame data you want. + * @return {Phaser.FrameData} The frame data you want. + */ getFrameData: function (key) { if (this._images[key] && this._images[key].frameData) @@ -30919,7 +31562,7 @@ Phaser.Cache.prototype = { */ getFrame: function (key) { - if (this._images[key] && this._images[key].spriteSheet == false) + if (this._images[key] && this._images[key].spriteSheet === false) { return this._images[key].frame; } @@ -30962,13 +31605,13 @@ Phaser.Cache.prototype = { }, - /** - * Get sound by key. + /** + * Get sound by key. * * @method Phaser.Cache#getSound - * @param {string} key - Asset key of the sound you want. - * @return {Phaser.Sound} The sound you want. - */ + * @param {string} key - Asset key of the sound you want. + * @return {Phaser.Sound} The sound you want. + */ getSound: function (key) { if (this._sounds[key]) @@ -30980,13 +31623,13 @@ Phaser.Cache.prototype = { }, - /** - * Get sound data by key. + /** + * Get sound data by key. * * @method Phaser.Cache#getSoundData - * @param {string} key - Asset key of the sound you want. - * @return {object} The sound data you want. - */ + * @param {string} key - Asset key of the sound you want. + * @return {object} The sound data you want. + */ getSoundData: function (key) { if (this._sounds[key]) @@ -30998,13 +31641,13 @@ Phaser.Cache.prototype = { }, - /** - * Check if the given sound has finished decoding. + /** + * Check if the given sound has finished decoding. * * @method Phaser.Cache#isSoundDecoded - * @param {string} key - Asset key of the sound you want. - * @return {boolean} The decoded state of the Sound object. - */ + * @param {string} key - Asset key of the sound you want. + * @return {boolean} The decoded state of the Sound object. + */ isSoundDecoded: function (key) { if (this._sounds[key]) @@ -31014,26 +31657,26 @@ Phaser.Cache.prototype = { }, - /** - * Check if the given sound is ready for playback. A sound is considered ready when it has finished decoding and the device is no longer touch locked. + /** + * Check if the given sound is ready for playback. A sound is considered ready when it has finished decoding and the device is no longer touch locked. * * @method Phaser.Cache#isSoundReady - * @param {string} key - Asset key of the sound you want. - * @return {boolean} True if the sound is decoded and the device is not touch locked. - */ + * @param {string} key - Asset key of the sound you want. + * @return {boolean} True if the sound is decoded and the device is not touch locked. + */ isSoundReady: function (key) { - return (this._sounds[key] && this._sounds[key].decoded && this.game.sound.touchLocked == false); + return (this._sounds[key] && this._sounds[key].decoded && this.game.sound.touchLocked === false); }, - /** - * Check whether an image asset is sprite sheet or not. + /** + * Check whether an image asset is sprite sheet or not. * * @method Phaser.Cache#isSpriteSheet - * @param {string} key - Asset key of the sprite sheet you want. - * @return {boolean} True if the image is a sprite sheet. - */ + * @param {string} key - Asset key of the sprite sheet you want. + * @return {boolean} True if the image is a sprite sheet. + */ isSpriteSheet: function (key) { if (this._images[key]) @@ -31045,13 +31688,13 @@ Phaser.Cache.prototype = { }, - /** - * Get text data by key. + /** + * Get text data by key. * * @method Phaser.Cache#getText - * @param {string} key - Asset key of the text data you want. - * @return {object} The text data you want. - */ + * @param {string} key - Asset key of the text data you want. + * @return {object} The text data you want. + */ getText: function (key) { if (this._text[key]) @@ -31087,42 +31730,42 @@ Phaser.Cache.prototype = { }, - /** - * Returns an array containing all of the keys of Images in the Cache. + /** + * Returns an array containing all of the keys of Images in the Cache. * * @method Phaser.Cache#getImageKeys - * @return {Array} The string based keys in the Cache. - */ + * @return {Array} The string based keys in the Cache. + */ getImageKeys: function () { - return this.getKeys(this._images); + return this.getKeys(this._images); }, - /** - * Returns an array containing all of the keys of Sounds in the Cache. + /** + * Returns an array containing all of the keys of Sounds in the Cache. * * @method Phaser.Cache#getSoundKeys - * @return {Array} The string based keys in the Cache. - */ + * @return {Array} The string based keys in the Cache. + */ getSoundKeys: function () { - return this.getKeys(this._sounds); + return this.getKeys(this._sounds); }, - /** - * Returns an array containing all of the keys of Text Files in the Cache. + /** + * Returns an array containing all of the keys of Text Files in the Cache. * * @method Phaser.Cache#getTextKeys - * @return {Array} The string based keys in the Cache. - */ + * @return {Array} The string based keys in the Cache. + */ getTextKeys: function () { - return this.getKeys(this._text); + return this.getKeys(this._text); }, - /** - * Removes a canvas from the cache. + /** + * Removes a canvas from the cache. * - * @method Phaser.Cache#removeCanvas + * @method Phaser.Cache#removeCanvas * @param {string} key - Key of the asset you want to remove. - */ + */ removeCanvas: function (key) { delete this._canvases[key]; }, @@ -31157,11 +31800,11 @@ Phaser.Cache.prototype = { delete this._text[key]; }, - /** - * Clears the cache. Removes every local cache object reference. + /** + * Clears the cache. Removes every local cache object reference. * - * @method Phaser.Cache#destroy - */ + * @method Phaser.Cache#destroy + */ destroy: function () { for (var item in this._canvases) @@ -31205,101 +31848,101 @@ Phaser.Cache.prototype = { */ Phaser.Loader = function (game) { - /** + /** * @property {Phaser.Game} game - Local reference to game. - */ - this.game = game; - - /** - * @property {array} _keys - Array stores assets keys. So you can get that asset by its unique key. - * @private */ - this._keys = []; + this.game = game; - /** - * @property {Description} _fileList - Contains all the assets file infos. - * @private + /** + * @property {array} _keys - Array stores assets keys. So you can get that asset by its unique key. + * @private */ - this._fileList = {}; + this._keys = []; - /** - * @property {number} _progressChunk - Indicates assets loading progress. (from 0 to 100) - * @private - * @default - */ - this._progressChunk = 0; + /** + * @property {Description} _fileList - Contains all the assets file infos. + * @private + */ + this._fileList = {}; - /** - * @property {XMLHttpRequest} - An XMLHttpRequest object used for loading text and audio data. - * @private - */ - this._xhr = new XMLHttpRequest(); + /** + * @property {number} _progressChunk - Indicates assets loading progress. (from 0 to 100) + * @private + * @default + */ + this._progressChunk = 0; - /** - * @property {number} - Length of assets queue. - * @default - */ - this.queueSize = 0; + /** + * @property {XMLHttpRequest} - An XMLHttpRequest object used for loading text and audio data. + * @private + */ + this._xhr = new XMLHttpRequest(); - /** - * @property {boolean} isLoading - True if the Loader is in the process of loading the queue. - * @default - */ - this.isLoading = false; + /** + * @property {number} - Length of assets queue. + * @default + */ + this.queueSize = 0; - /** - * @property {boolean} hasLoaded - True if all assets in the queue have finished loading. - * @default - */ - this.hasLoaded = false; + /** + * @property {boolean} isLoading - True if the Loader is in the process of loading the queue. + * @default + */ + this.isLoading = false; - /** - * @property {number} progress - The Load progress percentage value (from 0 to 100) - * @default - */ - this.progress = 0; + /** + * @property {boolean} hasLoaded - True if all assets in the queue have finished loading. + * @default + */ + this.hasLoaded = false; - /** - * You can optionally link a sprite to the preloader. - * If you do so the Sprite's width or height will be cropped based on the percentage loaded. - * @property {Description} preloadSprite - * @default - */ - this.preloadSprite = null; + /** + * @property {number} progress - The Load progress percentage value (from 0 to 100) + * @default + */ + this.progress = 0; - /** - * @property {string} crossOrigin - The crossOrigin value applied to loaded images - */ - this.crossOrigin = ''; + /** + * You can optionally link a sprite to the preloader. + * If you do so the Sprite's width or height will be cropped based on the percentage loaded. + * @property {Description} preloadSprite + * @default + */ + this.preloadSprite = null; - /** - * If you want to append a URL before the path of any asset you can set this here. - * Useful if you need to allow an asset url to be configured outside of the game code. - * MUST have / on the end of it! - * @property {string} baseURL - * @default - */ - this.baseURL = ''; + /** + * @property {string} crossOrigin - The crossOrigin value applied to loaded images + */ + this.crossOrigin = ''; - /** - * @property {Phaser.Signal} onFileComplete - Event signal. - */ - this.onFileComplete = new Phaser.Signal; - - /** - * @property {Phaser.Signal} onFileError - Event signal. - */ - this.onFileError = new Phaser.Signal; - - /** - * @property {Phaser.Signal} onLoadStart - Event signal. - */ - this.onLoadStart = new Phaser.Signal; - - /** - * @property {Phaser.Signal} onLoadComplete - Event signal. - */ - this.onLoadComplete = new Phaser.Signal; + /** + * If you want to append a URL before the path of any asset you can set this here. + * Useful if you need to allow an asset url to be configured outside of the game code. + * MUST have / on the end of it! + * @property {string} baseURL + * @default + */ + this.baseURL = ''; + + /** + * @property {Phaser.Signal} onFileComplete - Event signal. + */ + this.onFileComplete = new Phaser.Signal(); + + /** + * @property {Phaser.Signal} onFileError - Event signal. + */ + this.onFileError = new Phaser.Signal(); + + /** + * @property {Phaser.Signal} onLoadStart - Event signal. + */ + this.onLoadStart = new Phaser.Signal(); + + /** + * @property {Phaser.Signal} onLoadComplete - Event signal. + */ + this.onLoadComplete = new Phaser.Signal(); }; @@ -31323,978 +31966,989 @@ Phaser.Loader.TEXTURE_ATLAS_XML_STARLING = 2; Phaser.Loader.prototype = { - /** - * You can set a Sprite to be a "preload" sprite by passing it to this method. - * A "preload" sprite will have its width or height crop adjusted based on the percentage of the loader in real-time. - * This allows you to easily make loading bars for games. - * - * @method Phaser.Loader#setPreloadSprite + /** + * You can set a Sprite to be a "preload" sprite by passing it to this method. + * A "preload" sprite will have its width or height crop adjusted based on the percentage of the loader in real-time. + * This allows you to easily make loading bars for games. + * + * @method Phaser.Loader#setPreloadSprite * @param {Phaser.Sprite} sprite - The sprite that will be cropped during the load. * @param {number} [direction=0] - A value of zero means the sprite width will be cropped, a value of 1 means its height will be cropped. */ - setPreloadSprite: function (sprite, direction) { - - direction = direction || 0; - - this.preloadSprite = { sprite: sprite, direction: direction, width: sprite.width, height: sprite.height, crop: null }; - - if (direction == 0) - { - // Horizontal crop - this.preloadSprite.crop = new Phaser.Rectangle(0, 0, 1, sprite.height); - } - else - { - // Vertical crop - this.preloadSprite.crop = new Phaser.Rectangle(0, 0, sprite.width, 1); - } - - sprite.crop = this.preloadSprite.crop; - sprite.cropEnabled = true; - - }, - - /** - * Check whether asset exists with a specific key. - * - * @method Phaser.Loader#checkKeyExists - * @param {string} key - Key of the asset you want to check. - * @return {boolean} Return true if exists, otherwise return false. - */ - checkKeyExists: function (key) { - - if (this._fileList[key]) - { - return true; - } - else - { - return false; - } - - }, - - /** - * Reset loader, this will remove all loaded assets. - * - * @method Phaser.Loader#reset - */ - reset: function () { - - this.preloadSprite = null; - this.queueSize = 0; - this.isLoading = false; - - }, - - /** - * Internal function that adds a new entry to the file list. Do not call directly. - * - * @method Phaser.Loader#addToFileList - * @param {Description} type - Description. - * @param {string} key - Description. - * @param {string} url - URL of Description. - * @param {Description} properties - Description. - * @protected - */ - addToFileList: function (type, key, url, properties) { - - var entry = { - type: type, - key: key, - url: url, - data: null, - error: false, - loaded: false - }; - - if (typeof properties !== "undefined") - { - for (var prop in properties) - { - entry[prop] = properties[prop]; - } - } - - this._fileList[key] = entry; - - this._keys.push(key); - - this.queueSize++; - - }, - - /** - * Add an image to the Loader. - * - * @method Phaser.Loader#image - * @param {string} key - Unique asset key of this image file. - * @param {string} url - URL of image file. - * @param {boolean} overwrite - If an entry with a matching key already exists this will over-write it - */ - image: function (key, url, overwrite) { - - if (typeof overwrite === "undefined") { overwrite = false; } - - if (overwrite || this.checkKeyExists(key) == false) - { - this.addToFileList('image', key, url); - } - - return this; - - }, - - /** - * Add a text file to the Loader. - * - * @method Phaser.Loader#text - * @param {string} key - Unique asset key of the text file. - * @param {string} url - URL of the text file. - * @param {boolean} overwrite - True if Description. - */ - text: function (key, url, overwrite) { - - if (typeof overwrite === "undefined") { overwrite = false; } - - if (overwrite || this.checkKeyExists(key) == false) - { - this.addToFileList('text', key, url); - } - - return this; - - }, - - /** - * Add a new sprite sheet to the loader. - * - * @method Phaser.Loader#spritesheet - * @param {string} key - Unique asset key of the sheet file. - * @param {string} url - URL of the sheet file. - * @param {number} frameWidth - Width of each single frame. - * @param {number} frameHeight - Height of each single frame. - * @param {number} [frameMax=-1] - How many frames in this sprite sheet. If not specified it will divide the whole image into frames. - */ - spritesheet: function (key, url, frameWidth, frameHeight, frameMax) { - - if (typeof frameMax === "undefined") { frameMax = -1; } - - if (this.checkKeyExists(key) === false) - { - this.addToFileList('spritesheet', key, url, { frameWidth: frameWidth, frameHeight: frameHeight, frameMax: frameMax }); - } - - return this; - - }, - - /** - * Add a new tile set to the loader. These are used in the rendering of tile maps. - * - * @method Phaser.Loader#tileset - * @param {string} key - Unique asset key of the tileset file. - * @param {string} url - URL of the tileset. - * @param {number} tileWidth - Width of each single tile in pixels. - * @param {number} tileHeight - Height of each single tile in pixels. - * @param {number} [tileMax=-1] - How many tiles in this tileset. If not specified it will divide the whole image into tiles. - * @param {number} [tileMargin=0] - If the tiles have been drawn with a margin, specify the amount here. - * @param {number} [tileSpacing=0] - If the tiles have been drawn with spacing between them, specify the amount here. - */ - tileset: function (key, url, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing) { - - if (typeof tileMax === "undefined") { tileMax = -1; } - if (typeof tileMargin === "undefined") { tileMargin = 0; } - if (typeof tileSpacing === "undefined") { tileSpacing = 0; } - - if (this.checkKeyExists(key) === false) - { - this.addToFileList('tileset', key, url, { tileWidth: tileWidth, tileHeight: tileHeight, tileMax: tileMax, tileMargin: tileMargin, tileSpacing: tileSpacing }); - } - - return this; - - }, - - /** - * Add a new audio file to the loader. - * - * @method Phaser.Loader#audio - * @param {string} key - Unique asset key of the audio file. - * @param {Array} urls - An array containing the URLs of the audio files, i.e.: [ 'jump.mp3', 'jump.ogg', 'jump.m4a' ]. - * @param {boolean} autoDecode - When using Web Audio the audio files can either be decoded at load time or run-time. They can't be played until they are decoded, but this let's you control when that happens. Decoding is a non-blocking async process. - */ - audio: function (key, urls, autoDecode) { - - if (typeof autoDecode === "undefined") { autoDecode = true; } - - if (this.checkKeyExists(key) === false) - { - this.addToFileList('audio', key, urls, { buffer: null, autoDecode: autoDecode }); - } - - return this; - - }, - - /** - * Add a new tilemap loading request. - * - * @method Phaser.Loader#tilemap - * @param {string} key - Unique asset key of the tilemap data. - * @param {string} tilesetURL - The url of the tile set image file. - * @param {string} [mapDataURL] - The url of the map data file (csv/json) - * @param {object} [mapData] - An optional JSON data object (can be given in place of a URL). - * @param {string} [format] - The format of the map data. - */ - tilemap: function (key, mapDataURL, mapData, format) { - - if (typeof mapDataURL === "undefined") { mapDataURL = null; } - if (typeof mapData === "undefined") { mapData = null; } - if (typeof format === "undefined") { format = Phaser.Tilemap.CSV; } - - if (mapDataURL == null && mapData == null) - { - console.warn('Phaser.Loader.tilemap - Both mapDataURL and mapData are null. One must be set.'); - - return this; - } - - if (this.checkKeyExists(key) === false) - { - // A URL to a json/csv file has been given - if (mapDataURL) - { - this.addToFileList('tilemap', key, mapDataURL, { format: format }); - } - else - { - switch (format) - { - // A csv string or object has been given - case Phaser.Tilemap.CSV: - break; - - // An xml string or object has been given - case Phaser.Tilemap.TILED_JSON: - - if (typeof mapData === 'string') - { - mapData = JSON.parse(mapData); - } - break; - } - - this.game.cache.addTilemap(key, null, mapData, format); - - } - } - - return this; - - }, - - /** - * Add a new bitmap font loading request. - * - * @method Phaser.Loader#bitmapFont - * @param {string} key - Unique asset key of the bitmap font. - * @param {string} textureURL - The url of the font image file. - * @param {string} [xmlURL] - The url of the font data file (xml/fnt) - * @param {object} [xmlData] - An optional XML data object. - */ - bitmapFont: function (key, textureURL, xmlURL, xmlData) { - - if (typeof xmlURL === "undefined") { xmlURL = null; } - if (typeof xmlData === "undefined") { xmlData = null; } - - if (this.checkKeyExists(key) === false) - { - // A URL to a json/xml file has been given - if (xmlURL) - { - this.addToFileList('bitmapfont', key, textureURL, { xmlURL: xmlURL }); - } - else - { - // An xml string or object has been given - if (typeof xmlData === 'string') - { - var xml; - - try { - if (window['DOMParser']) - { - var domparser = new DOMParser(); - xml = domparser.parseFromString(xmlData, "text/xml"); - } - else - { - xml = new ActiveXObject("Microsoft.XMLDOM"); - xml.async = 'false'; - xml.loadXML(xmlData); - } - } - catch (e) - { - xml = undefined; - } - - if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length) - { - throw new Error("Phaser.Loader. Invalid Bitmap Font XML given"); - } - else - { - this.addToFileList('bitmapfont', key, textureURL, { xmlURL: null, xmlData: xml }); - } - } - } - } - - return this; - - }, - - /** - * Add a new texture atlas to the loader. This atlas uses the JSON Array data format. - * - * @method Phaser.Loader#atlasJSONArray - * @param {string} key - Unique asset key of the bitmap font. - * @param {Description} atlasURL - The url of the Description. - * @param {Description} atlasData - Description. - */ - atlasJSONArray: function (key, textureURL, atlasURL, atlasData) { - - return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY); - - }, - - /** - * Add a new texture atlas to the loader. This atlas uses the JSON Hash data format. - * - * @method Phaser.Loader#atlasJSONHash - * @param {string} key - Unique asset key of the bitmap font. - * @param {Description} atlasURL - The url of the Description. - * @param {Description} atlasData - Description. - */ - atlasJSONHash: function (key, textureURL, atlasURL, atlasData) { - - return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_HASH); - - }, - - /** - * Add a new texture atlas to the loader. This atlas uses the Starling XML data format. - * - * @method Phaser.Loader#atlasXML - * @param {string} key - Unique asset key of the bitmap font. - * @param {Description} atlasURL - The url of the Description. - * @param {Description} atlasData - Description. - */ - atlasXML: function (key, textureURL, atlasURL, atlasData) { - - return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING); - - }, - - /** - * Add a new texture atlas to the loader. - * - * @method Phaser.Loader#atlas - * @param {string} key - Unique asset key of the texture atlas file. - * @param {string} textureURL - The url of the texture atlas image file. - * @param {string} [atlasURL] - The url of the texture atlas data file (json/xml). You don't need this if you are passing an atlasData object instead. - * @param {object} [atlasData] - A JSON or XML data object. You don't need this if the data is being loaded from a URL. - * @param {number} [format] - A value describing the format of the data, the default is Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY. - */ - atlas: function (key, textureURL, atlasURL, atlasData, format) { - - if (typeof atlasURL === "undefined") { atlasURL = null; } - if (typeof atlasData === "undefined") { atlasData = null; } - if (typeof format === "undefined") { format = Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY; } - - if (this.checkKeyExists(key) === false) - { - // A URL to a json/xml file has been given - if (atlasURL) - { - this.addToFileList('textureatlas', key, textureURL, { atlasURL: atlasURL, format: format }); - } - else - { - switch (format) - { - // A json string or object has been given - case Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY: - - if (typeof atlasData === 'string') - { - atlasData = JSON.parse(atlasData); - } - break; - - // An xml string or object has been given - case Phaser.Loader.TEXTURE_ATLAS_XML_STARLING: - - if (typeof atlasData === 'string') - { - var xml; - - try { - if (window['DOMParser']) - { - var domparser = new DOMParser(); - xml = domparser.parseFromString(atlasData, "text/xml"); - } - else - { - xml = new ActiveXObject("Microsoft.XMLDOM"); - xml.async = 'false'; - xml.loadXML(atlasData); - } - } - catch (e) - { - xml = undefined; - } - - if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length) - { - throw new Error("Phaser.Loader. Invalid Texture Atlas XML given"); - } - else - { - atlasData = xml; - } - } - break; - } - - this.addToFileList('textureatlas', key, textureURL, { atlasURL: null, atlasData: atlasData, format: format }); - - } - - } - - return this; - - }, - - /** - * Remove loading request of a file. - * - * @method Phaser.Loader#removeFile - * @param key {string} Key of the file you want to remove. - */ - removeFile: function (key) { - - delete this._fileList[key]; - - }, - - /** - * Remove all file loading requests. - * - * @method Phaser.Loader#removeAll - */ - removeAll: function () { - - this._fileList = {}; - - }, - - /** - * Start loading the assets. Normally you don't need to call this yourself as the StateManager will do so. - * - * @method Phaser.Loader#start - */ - start: function () { - - if (this.isLoading) - { - return; - } - - this.progress = 0; - this.hasLoaded = false; - this.isLoading = true; - - this.onLoadStart.dispatch(this.queueSize); - - if (this._keys.length > 0) - { - this._progressChunk = 100 / this._keys.length; - this.loadFile(); - } - else - { - this.progress = 100; - this.hasLoaded = true; - this.onLoadComplete.dispatch(); - } - - }, - - /** - * Load files. Private method ONLY used by loader. - * - * @method Phaser.Loader#loadFile - * @private - */ - loadFile: function () { - - var file = this._fileList[this._keys.shift()]; - var _this = this; - - // Image or Data? - switch (file.type) - { - case 'image': - case 'spritesheet': - case 'textureatlas': - case 'bitmapfont': - case 'tileset': - file.data = new Image(); - file.data.name = file.key; - file.data.onload = function () { - return _this.fileComplete(file.key); - }; - file.data.onerror = function () { - return _this.fileError(file.key); - }; - file.data.crossOrigin = this.crossOrigin; - file.data.src = this.baseURL + file.url; - break; - - case 'audio': - file.url = this.getAudioURL(file.url); - - if (file.url !== null) - { - // WebAudio or Audio Tag? - if (this.game.sound.usingWebAudio) - { - this._xhr.open("GET", this.baseURL + file.url, true); - this._xhr.responseType = "arraybuffer"; - this._xhr.onload = function () { - return _this.fileComplete(file.key); - }; - this._xhr.onerror = function () { - return _this.fileError(file.key); - }; - this._xhr.send(); - } - else if (this.game.sound.usingAudioTag) - { - if (this.game.sound.touchLocked) - { - // If audio is locked we can't do this yet, so need to queue this load request. Bum. - file.data = new Audio(); - file.data.name = file.key; - file.data.preload = 'auto'; - file.data.src = this.baseURL + file.url; - this.fileComplete(file.key); - } - else - { - file.data = new Audio(); - file.data.name = file.key; - file.data.onerror = function () { - return _this.fileError(file.key); - }; - file.data.preload = 'auto'; - file.data.src = this.baseURL + file.url; - file.data.addEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete(file.key), false); - file.data.load(); - } - } - } - else - { - this.fileError(file.key); - } - - break; - - case 'tilemap': - this._xhr.open("GET", this.baseURL + file.url, true); - this._xhr.responseType = "text"; - - if (file.format == Phaser.Tilemap.TILED_JSON) - { - this._xhr.onload = function () { - return _this.jsonLoadComplete(file.key); - }; - } - else if (file.format == Phaser.Tilemap.CSV) - { - this._xhr.onload = function () { - return _this.csvLoadComplete(file.key); - }; - } - - this._xhr.onerror = function () { - return _this.dataLoadError(file.key); - }; - this._xhr.send(); - break; - - case 'text': - this._xhr.open("GET", this.baseURL + file.url, true); - this._xhr.responseType = "text"; - this._xhr.onload = function () { - return _this.fileComplete(file.key); - }; - this._xhr.onerror = function () { - return _this.fileError(file.key); - }; - this._xhr.send(); - break; - } - - }, - - /** - * Private method ONLY used by loader. - * @method Phaser.Loader#getAudioURL - * @param {Description} urls - Description. - * @private - */ - getAudioURL: function (urls) { - - var extension; - - for (var i = 0; i < urls.length; i++) - { - extension = urls[i].toLowerCase(); - extension = extension.substr((Math.max(0, extension.lastIndexOf(".")) || Infinity) + 1); - - if (this.game.device.canPlayAudio(extension)) - { - return urls[i]; - } - - } - - return null; - - }, - - /** - * Error occured when load a file. - * - * @method Phaser.Loader#fileError - * @param {string} key - Key of the error loading file. - */ - fileError: function (key) { - - this._fileList[key].loaded = true; - this._fileList[key].error = true; - - this.onFileError.dispatch(key); - - console.warn("Phaser.Loader error loading file: " + key + ' from URL ' + this._fileList[key].url); - - this.nextFile(key, false); - - }, - - /** - * Called when a file is successfully loaded. - * - * @method Phaser.Loader#fileComplete - * @param {string} key - Key of the successfully loaded file. - */ - fileComplete: function (key) { - - if (!this._fileList[key]) - { - console.warn('Phaser.Loader fileComplete invalid key ' + key); - return; - } - - this._fileList[key].loaded = true; - - var file = this._fileList[key]; - var loadNext = true; - var _this = this; - - switch (file.type) - { - case 'image': - - this.game.cache.addImage(file.key, file.url, file.data); - break; - - case 'spritesheet': - - this.game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax); - break; - - case 'tileset': - - this.game.cache.addTileset(file.key, file.url, file.data, file.tileWidth, file.tileHeight, file.tileMax, file.tileMargin, file.tileSpacing); - break; - - case 'textureatlas': - - if (file.atlasURL == null) - { - this.game.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData, file.format); - } - else - { - // Load the JSON or XML before carrying on with the next file - loadNext = false; - this._xhr.open("GET", this.baseURL + file.atlasURL, true); - this._xhr.responseType = "text"; - - if (file.format == Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY || file.format == Phaser.Loader.TEXTURE_ATLAS_JSON_HASH) - { - this._xhr.onload = function () { - return _this.jsonLoadComplete(file.key); - }; - } - else if (file.format == Phaser.Loader.TEXTURE_ATLAS_XML_STARLING) - { - this._xhr.onload = function () { - return _this.xmlLoadComplete(file.key); - }; - } - - this._xhr.onerror = function () { - return _this.dataLoadError(file.key); - }; - this._xhr.send(); - } - break; - - case 'bitmapfont': - - if (file.xmlURL == null) - { - this.game.cache.addBitmapFont(file.key, file.url, file.data, file.xmlData); - } - else - { - // Load the XML before carrying on with the next file - loadNext = false; - this._xhr.open("GET", this.baseURL + file.xmlURL, true); - this._xhr.responseType = "text"; - - this._xhr.onload = function () { - return _this.xmlLoadComplete(file.key); - }; - - this._xhr.onerror = function () { - return _this.dataLoadError(file.key); - }; - this._xhr.send(); - } - break; - - case 'audio': - - if (this.game.sound.usingWebAudio) - { - file.data = this._xhr.response; - - this.game.cache.addSound(file.key, file.url, file.data, true, false); - - if (file.autoDecode) - { - this.game.cache.updateSound(key, 'isDecoding', true); - - var that = this; - var key = file.key; - - this.game.sound.context.decodeAudioData(file.data, function (buffer) { - if (buffer) - { - that.game.cache.decodedSound(key, buffer); - } - }); - } - } - else - { - file.data.removeEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete); - this.game.cache.addSound(file.key, file.url, file.data, false, true); - } - break; - - case 'text': - file.data = this._xhr.responseText; - this.game.cache.addText(file.key, file.url, file.data); - break; - } - - if (loadNext) - { - this.nextFile(key, true); - } - - }, - - /** - * Successfully loaded a JSON file. - * - * @method Phaser.Loader#jsonLoadComplete - * @param {string} key - Key of the loaded JSON file. - */ - jsonLoadComplete: function (key) { - - var data = JSON.parse(this._xhr.responseText); - var file = this._fileList[key]; - - if (file.type == 'tilemap') - { - this.game.cache.addTilemap(file.key, file.url, data, file.format); - } - else - { - this.game.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format); - } - - this.nextFile(key, true); - - }, - - /** - * Successfully loaded a CSV file. - * - * @method Phaser.Loader#csvLoadComplete - * @param {string} key - Key of the loaded CSV file. - */ - csvLoadComplete: function (key) { - - var data = this._xhr.responseText; - var file = this._fileList[key]; - - this.game.cache.addTilemap(file.key, file.url, data, file.format); - - this.nextFile(key, true); - - }, - - /** - * Error occured when load a JSON. - * - * @method Phaser.Loader#dataLoadError - * @param {string} key - Key of the error loading JSON file. - */ - dataLoadError: function (key) { - - var file = this._fileList[key]; - - file.error = true; - - console.warn("Phaser.Loader dataLoadError: " + key); - - this.nextFile(key, true); - - }, - - /** - * Successfully loaded an XML file. - * - * @method Phaser.Loader#xmlLoadComplete - * @param {string} key - Key of the loaded XML file. - */ - xmlLoadComplete: function (key) { - - var data = this._xhr.responseText; - var xml; - - try - { - if (window['DOMParser']) - { - var domparser = new DOMParser(); - xml = domparser.parseFromString(data, "text/xml"); - } - else - { - xml = new ActiveXObject("Microsoft.XMLDOM"); - xml.async = 'false'; - xml.loadXML(data); - } - } - catch (e) - { - xml = undefined; - } - - if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length) - { - throw new Error("Phaser.Loader. Invalid XML given"); - } - - var file = this._fileList[key]; - - if (file.type == 'bitmapfont') - { - this.game.cache.addBitmapFont(file.key, file.url, file.data, xml); - } - else if (file.type == 'textureatlas') - { - this.game.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format); - } - - this.nextFile(key, true); - - }, - - /** - * Handle loading next file. - * - * @param previousKey {string} Key of previous loaded asset. - * @param success {boolean} Whether the previous asset loaded successfully or not. - * @private - */ - nextFile: function (previousKey, success) { - - this.progress = Math.round(this.progress + this._progressChunk); - - if (this.progress > 100) - { - this.progress = 100; - } - - if (this.preloadSprite !== null) - { - if (this.preloadSprite.direction == 0) - { - this.preloadSprite.crop.width = Math.floor((this.preloadSprite.width / 100) * this.progress); - } - else - { - this.preloadSprite.crop.height = Math.floor((this.preloadSprite.height / 100) * this.progress); - } - - this.preloadSprite.sprite.crop = this.preloadSprite.crop; - } - - this.onFileComplete.dispatch(this.progress, previousKey, success, this.queueSize - this._keys.length, this.queueSize); - - if (this._keys.length > 0) - { - this.loadFile(); - } - else - { - this.hasLoaded = true; - this.isLoading = false; - - this.removeAll(); - - this.onLoadComplete.dispatch(); - } - - } + setPreloadSprite: function (sprite, direction) { + + direction = direction || 0; + + this.preloadSprite = { sprite: sprite, direction: direction, width: sprite.width, height: sprite.height, crop: null }; + + if (direction === 0) + { + // Horizontal crop + this.preloadSprite.crop = new Phaser.Rectangle(0, 0, 1, sprite.height); + } + else + { + // Vertical crop + this.preloadSprite.crop = new Phaser.Rectangle(0, 0, sprite.width, 1); + } + + sprite.crop = this.preloadSprite.crop; + sprite.cropEnabled = true; + + }, + + /** + * Check whether asset exists with a specific key. + * + * @method Phaser.Loader#checkKeyExists + * @param {string} key - Key of the asset you want to check. + * @return {boolean} Return true if exists, otherwise return false. + */ + checkKeyExists: function (key) { + + if (this._fileList[key]) + { + return true; + } + else + { + return false; + } + + }, + + /** + * Reset loader, this will remove all loaded assets. + * + * @method Phaser.Loader#reset + */ + reset: function () { + + this.preloadSprite = null; + this.queueSize = 0; + this.isLoading = false; + + }, + + /** + * Internal function that adds a new entry to the file list. Do not call directly. + * + * @method Phaser.Loader#addToFileList + * @param {Description} type - Description. + * @param {string} key - Description. + * @param {string} url - URL of Description. + * @param {Description} properties - Description. + * @protected + */ + addToFileList: function (type, key, url, properties) { + + var entry = { + type: type, + key: key, + url: url, + data: null, + error: false, + loaded: false + }; + + if (typeof properties !== "undefined") + { + for (var prop in properties) + { + entry[prop] = properties[prop]; + } + } + + this._fileList[key] = entry; + + this._keys.push(key); + + this.queueSize++; + + }, + + /** + * Add an image to the Loader. + * + * @method Phaser.Loader#image + * @param {string} key - Unique asset key of this image file. + * @param {string} url - URL of image file. + * @param {boolean} overwrite - If an entry with a matching key already exists this will over-write it + */ + image: function (key, url, overwrite) { + + if (typeof overwrite === "undefined") { overwrite = false; } + + if (overwrite || this.checkKeyExists(key) === false) + { + this.addToFileList('image', key, url); + } + + return this; + + }, + + /** + * Add a text file to the Loader. + * + * @method Phaser.Loader#text + * @param {string} key - Unique asset key of the text file. + * @param {string} url - URL of the text file. + * @param {boolean} overwrite - True if Description. + */ + text: function (key, url, overwrite) { + + if (typeof overwrite === "undefined") { overwrite = false; } + + if (overwrite || this.checkKeyExists(key) === false) + { + this.addToFileList('text', key, url); + } + + return this; + + }, + + /** + * Add a new sprite sheet to the loader. + * + * @method Phaser.Loader#spritesheet + * @param {string} key - Unique asset key of the sheet file. + * @param {string} url - URL of the sheet file. + * @param {number} frameWidth - Width of each single frame. + * @param {number} frameHeight - Height of each single frame. + * @param {number} [frameMax=-1] - How many frames in this sprite sheet. If not specified it will divide the whole image into frames. + */ + spritesheet: function (key, url, frameWidth, frameHeight, frameMax) { + + if (typeof frameMax === "undefined") { frameMax = -1; } + + if (this.checkKeyExists(key) === false) + { + this.addToFileList('spritesheet', key, url, { frameWidth: frameWidth, frameHeight: frameHeight, frameMax: frameMax }); + } + + return this; + + }, + + /** + * Add a new tile set to the loader. These are used in the rendering of tile maps. + * + * @method Phaser.Loader#tileset + * @param {string} key - Unique asset key of the tileset file. + * @param {string} url - URL of the tileset. + * @param {number} tileWidth - Width of each single tile in pixels. + * @param {number} tileHeight - Height of each single tile in pixels. + * @param {number} [tileMax=-1] - How many tiles in this tileset. If not specified it will divide the whole image into tiles. + * @param {number} [tileMargin=0] - If the tiles have been drawn with a margin, specify the amount here. + * @param {number} [tileSpacing=0] - If the tiles have been drawn with spacing between them, specify the amount here. + */ + tileset: function (key, url, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing) { + + if (typeof tileMax === "undefined") { tileMax = -1; } + if (typeof tileMargin === "undefined") { tileMargin = 0; } + if (typeof tileSpacing === "undefined") { tileSpacing = 0; } + + if (this.checkKeyExists(key) === false) + { + this.addToFileList('tileset', key, url, { tileWidth: tileWidth, tileHeight: tileHeight, tileMax: tileMax, tileMargin: tileMargin, tileSpacing: tileSpacing }); + } + + return this; + + }, + + /** + * Add a new audio file to the loader. + * + * @method Phaser.Loader#audio + * @param {string} key - Unique asset key of the audio file. + * @param {Array|string} urls - An array containing the URLs of the audio files, i.e.: [ 'jump.mp3', 'jump.ogg', 'jump.m4a' ] or a single string containing just one URL. + * @param {boolean} autoDecode - When using Web Audio the audio files can either be decoded at load time or run-time. They can't be played until they are decoded, but this let's you control when that happens. Decoding is a non-blocking async process. + */ + audio: function (key, urls, autoDecode) { + + if (typeof autoDecode === "undefined") { autoDecode = true; } + + if (this.checkKeyExists(key) === false) + { + this.addToFileList('audio', key, urls, { buffer: null, autoDecode: autoDecode }); + } + + return this; + + }, + + /** + * Add a new tilemap loading request. + * + * @method Phaser.Loader#tilemap + * @param {string} key - Unique asset key of the tilemap data. + * @param {string} tilesetURL - The url of the tile set image file. + * @param {string} [mapDataURL] - The url of the map data file (csv/json) + * @param {object} [mapData] - An optional JSON data object (can be given in place of a URL). + * @param {string} [format] - The format of the map data. + */ + tilemap: function (key, mapDataURL, mapData, format) { + + if (typeof mapDataURL === "undefined") { mapDataURL = null; } + if (typeof mapData === "undefined") { mapData = null; } + if (typeof format === "undefined") { format = Phaser.Tilemap.CSV; } + + if (mapDataURL == null && mapData == null) + { + console.warn('Phaser.Loader.tilemap - Both mapDataURL and mapData are null. One must be set.'); + + return this; + } + + if (this.checkKeyExists(key) === false) + { + // A URL to a json/csv file has been given + if (mapDataURL) + { + this.addToFileList('tilemap', key, mapDataURL, { format: format }); + } + else + { + switch (format) + { + // A csv string or object has been given + case Phaser.Tilemap.CSV: + break; + + // An xml string or object has been given + case Phaser.Tilemap.TILED_JSON: + + if (typeof mapData === 'string') + { + mapData = JSON.parse(mapData); + } + break; + } + + this.game.cache.addTilemap(key, null, mapData, format); + + } + } + + return this; + + }, + + /** + * Add a new bitmap font loading request. + * + * @method Phaser.Loader#bitmapFont + * @param {string} key - Unique asset key of the bitmap font. + * @param {string} textureURL - The url of the font image file. + * @param {string} [xmlURL] - The url of the font data file (xml/fnt) + * @param {object} [xmlData] - An optional XML data object. + */ + bitmapFont: function (key, textureURL, xmlURL, xmlData) { + + if (typeof xmlURL === "undefined") { xmlURL = null; } + if (typeof xmlData === "undefined") { xmlData = null; } + + if (this.checkKeyExists(key) === false) + { + // A URL to a json/xml file has been given + if (xmlURL) + { + this.addToFileList('bitmapfont', key, textureURL, { xmlURL: xmlURL }); + } + else + { + // An xml string or object has been given + if (typeof xmlData === 'string') + { + var xml; + + try { + if (window['DOMParser']) + { + var domparser = new DOMParser(); + xml = domparser.parseFromString(xmlData, "text/xml"); + } + else + { + xml = new ActiveXObject("Microsoft.XMLDOM"); + xml.async = 'false'; + xml.loadXML(xmlData); + } + } + catch (e) + { + xml = undefined; + } + + if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length) + { + throw new Error("Phaser.Loader. Invalid Bitmap Font XML given"); + } + else + { + this.addToFileList('bitmapfont', key, textureURL, { xmlURL: null, xmlData: xml }); + } + } + } + } + + return this; + + }, + + /** + * Add a new texture atlas to the loader. This atlas uses the JSON Array data format. + * + * @method Phaser.Loader#atlasJSONArray + * @param {string} key - Unique asset key of the bitmap font. + * @param {Description} atlasURL - The url of the Description. + * @param {Description} atlasData - Description. + */ + atlasJSONArray: function (key, textureURL, atlasURL, atlasData) { + + return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY); + + }, + + /** + * Add a new texture atlas to the loader. This atlas uses the JSON Hash data format. + * + * @method Phaser.Loader#atlasJSONHash + * @param {string} key - Unique asset key of the bitmap font. + * @param {Description} atlasURL - The url of the Description. + * @param {Description} atlasData - Description. + */ + atlasJSONHash: function (key, textureURL, atlasURL, atlasData) { + + return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_HASH); + + }, + + /** + * Add a new texture atlas to the loader. This atlas uses the Starling XML data format. + * + * @method Phaser.Loader#atlasXML + * @param {string} key - Unique asset key of the bitmap font. + * @param {Description} atlasURL - The url of the Description. + * @param {Description} atlasData - Description. + */ + atlasXML: function (key, textureURL, atlasURL, atlasData) { + + return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING); + + }, + + /** + * Add a new texture atlas to the loader. + * + * @method Phaser.Loader#atlas + * @param {string} key - Unique asset key of the texture atlas file. + * @param {string} textureURL - The url of the texture atlas image file. + * @param {string} [atlasURL] - The url of the texture atlas data file (json/xml). You don't need this if you are passing an atlasData object instead. + * @param {object} [atlasData] - A JSON or XML data object. You don't need this if the data is being loaded from a URL. + * @param {number} [format] - A value describing the format of the data, the default is Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY. + */ + atlas: function (key, textureURL, atlasURL, atlasData, format) { + + if (typeof atlasURL === "undefined") { atlasURL = null; } + if (typeof atlasData === "undefined") { atlasData = null; } + if (typeof format === "undefined") { format = Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY; } + + if (this.checkKeyExists(key) === false) + { + // A URL to a json/xml file has been given + if (atlasURL) + { + this.addToFileList('textureatlas', key, textureURL, { atlasURL: atlasURL, format: format }); + } + else + { + switch (format) + { + // A json string or object has been given + case Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY: + + if (typeof atlasData === 'string') + { + atlasData = JSON.parse(atlasData); + } + break; + + // An xml string or object has been given + case Phaser.Loader.TEXTURE_ATLAS_XML_STARLING: + + if (typeof atlasData === 'string') + { + var xml; + + try { + if (window['DOMParser']) + { + var domparser = new DOMParser(); + xml = domparser.parseFromString(atlasData, "text/xml"); + } + else + { + xml = new ActiveXObject("Microsoft.XMLDOM"); + xml.async = 'false'; + xml.loadXML(atlasData); + } + } + catch (e) + { + xml = undefined; + } + + if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length) + { + throw new Error("Phaser.Loader. Invalid Texture Atlas XML given"); + } + else + { + atlasData = xml; + } + } + break; + } + + this.addToFileList('textureatlas', key, textureURL, { atlasURL: null, atlasData: atlasData, format: format }); + + } + + } + + return this; + + }, + + /** + * Remove loading request of a file. + * + * @method Phaser.Loader#removeFile + * @param key {string} Key of the file you want to remove. + */ + removeFile: function (key) { + + delete this._fileList[key]; + + }, + + /** + * Remove all file loading requests. + * + * @method Phaser.Loader#removeAll + */ + removeAll: function () { + + this._fileList = {}; + + }, + + /** + * Start loading the assets. Normally you don't need to call this yourself as the StateManager will do so. + * + * @method Phaser.Loader#start + */ + start: function () { + + if (this.isLoading) + { + return; + } + + this.progress = 0; + this.hasLoaded = false; + this.isLoading = true; + + this.onLoadStart.dispatch(this.queueSize); + + if (this._keys.length > 0) + { + this._progressChunk = 100 / this._keys.length; + this.loadFile(); + } + else + { + this.progress = 100; + this.hasLoaded = true; + this.onLoadComplete.dispatch(); + } + + }, + + /** + * Load files. Private method ONLY used by loader. + * + * @method Phaser.Loader#loadFile + * @private + */ + loadFile: function () { + + var file = this._fileList[this._keys.shift()]; + var _this = this; + + // Image or Data? + switch (file.type) + { + case 'image': + case 'spritesheet': + case 'textureatlas': + case 'bitmapfont': + case 'tileset': + file.data = new Image(); + file.data.name = file.key; + file.data.onload = function () { + return _this.fileComplete(file.key); + }; + file.data.onerror = function () { + return _this.fileError(file.key); + }; + file.data.crossOrigin = this.crossOrigin; + file.data.src = this.baseURL + file.url; + break; + + case 'audio': + file.url = this.getAudioURL(file.url); + + if (file.url !== null) + { + // WebAudio or Audio Tag? + if (this.game.sound.usingWebAudio) + { + this._xhr.open("GET", this.baseURL + file.url, true); + this._xhr.responseType = "arraybuffer"; + this._xhr.onload = function () { + return _this.fileComplete(file.key); + }; + this._xhr.onerror = function () { + return _this.fileError(file.key); + }; + this._xhr.send(); + } + else if (this.game.sound.usingAudioTag) + { + if (this.game.sound.touchLocked) + { + // If audio is locked we can't do this yet, so need to queue this load request. Bum. + file.data = new Audio(); + file.data.name = file.key; + file.data.preload = 'auto'; + file.data.src = this.baseURL + file.url; + this.fileComplete(file.key); + } + else + { + file.data = new Audio(); + file.data.name = file.key; + file.data.onerror = function () { + return _this.fileError(file.key); + }; + file.data.preload = 'auto'; + file.data.src = this.baseURL + file.url; + file.data.addEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete(file.key), false); + file.data.load(); + } + } + } + else + { + this.fileError(file.key); + } + + break; + + case 'tilemap': + this._xhr.open("GET", this.baseURL + file.url, true); + this._xhr.responseType = "text"; + + if (file.format == Phaser.Tilemap.TILED_JSON) + { + this._xhr.onload = function () { + return _this.jsonLoadComplete(file.key); + }; + } + else if (file.format == Phaser.Tilemap.CSV) + { + this._xhr.onload = function () { + return _this.csvLoadComplete(file.key); + }; + } + else + { + throw new Error("Phaser.Loader. Invalid Tilemap format: " + file.format); + } + + this._xhr.onerror = function () { + return _this.dataLoadError(file.key); + }; + this._xhr.send(); + break; + + case 'text': + this._xhr.open("GET", this.baseURL + file.url, true); + this._xhr.responseType = "text"; + this._xhr.onload = function () { + return _this.fileComplete(file.key); + }; + this._xhr.onerror = function () { + return _this.fileError(file.key); + }; + this._xhr.send(); + break; + } + + }, + + /** + * Private method ONLY used by loader. + * @method Phaser.Loader#getAudioURL + * @param {array|string} urls - Either an array of audio file URLs or a string containing a single URL path. + * @private + */ + getAudioURL: function (urls) { + + var extension; + + if (typeof urls === 'string') { urls = [urls]; } + + for (var i = 0; i < urls.length; i++) + { + extension = urls[i].toLowerCase(); + extension = extension.substr((Math.max(0, extension.lastIndexOf(".")) || Infinity) + 1); + + if (this.game.device.canPlayAudio(extension)) + { + return urls[i]; + } + + } + + return null; + + }, + + /** + * Error occured when load a file. + * + * @method Phaser.Loader#fileError + * @param {string} key - Key of the error loading file. + */ + fileError: function (key) { + + this._fileList[key].loaded = true; + this._fileList[key].error = true; + + this.onFileError.dispatch(key); + + console.warn("Phaser.Loader error loading file: " + key + ' from URL ' + this._fileList[key].url); + + this.nextFile(key, false); + + }, + + /** + * Called when a file is successfully loaded. + * + * @method Phaser.Loader#fileComplete + * @param {string} key - Key of the successfully loaded file. + */ + fileComplete: function (key) { + + if (!this._fileList[key]) + { + console.warn('Phaser.Loader fileComplete invalid key ' + key); + return; + } + + this._fileList[key].loaded = true; + + var file = this._fileList[key]; + var loadNext = true; + var _this = this; + + switch (file.type) + { + case 'image': + + this.game.cache.addImage(file.key, file.url, file.data); + break; + + case 'spritesheet': + + this.game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax); + break; + + case 'tileset': + + this.game.cache.addTileset(file.key, file.url, file.data, file.tileWidth, file.tileHeight, file.tileMax, file.tileMargin, file.tileSpacing); + break; + + case 'textureatlas': + + if (file.atlasURL == null) + { + this.game.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData, file.format); + } + else + { + // Load the JSON or XML before carrying on with the next file + loadNext = false; + this._xhr.open("GET", this.baseURL + file.atlasURL, true); + this._xhr.responseType = "text"; + + if (file.format == Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY || file.format == Phaser.Loader.TEXTURE_ATLAS_JSON_HASH) + { + this._xhr.onload = function () { + return _this.jsonLoadComplete(file.key); + }; + } + else if (file.format == Phaser.Loader.TEXTURE_ATLAS_XML_STARLING) + { + this._xhr.onload = function () { + return _this.xmlLoadComplete(file.key); + }; + } + else + { + throw new Error("Phaser.Loader. Invalid Texture Atlas format: " + file.format); + } + + this._xhr.onerror = function () { + return _this.dataLoadError(file.key); + }; + this._xhr.send(); + } + break; + + case 'bitmapfont': + + if (file.xmlURL == null) + { + this.game.cache.addBitmapFont(file.key, file.url, file.data, file.xmlData); + } + else + { + // Load the XML before carrying on with the next file + loadNext = false; + this._xhr.open("GET", this.baseURL + file.xmlURL, true); + this._xhr.responseType = "text"; + + this._xhr.onload = function () { + return _this.xmlLoadComplete(file.key); + }; + + this._xhr.onerror = function () { + return _this.dataLoadError(file.key); + }; + this._xhr.send(); + } + break; + + case 'audio': + + if (this.game.sound.usingWebAudio) + { + file.data = this._xhr.response; + + this.game.cache.addSound(file.key, file.url, file.data, true, false); + + if (file.autoDecode) + { + this.game.cache.updateSound(key, 'isDecoding', true); + + var that = this; + var key = file.key; + + this.game.sound.context.decodeAudioData(file.data, function (buffer) { + if (buffer) + { + that.game.cache.decodedSound(key, buffer); + } + }); + } + } + else + { + file.data.removeEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete); + this.game.cache.addSound(file.key, file.url, file.data, false, true); + } + break; + + case 'text': + file.data = this._xhr.responseText; + this.game.cache.addText(file.key, file.url, file.data); + break; + } + + if (loadNext) + { + this.nextFile(key, true); + } + + }, + + /** + * Successfully loaded a JSON file. + * + * @method Phaser.Loader#jsonLoadComplete + * @param {string} key - Key of the loaded JSON file. + */ + jsonLoadComplete: function (key) { + + var data = JSON.parse(this._xhr.responseText); + var file = this._fileList[key]; + + if (file.type == 'tilemap') + { + this.game.cache.addTilemap(file.key, file.url, data, file.format); + } + else + { + this.game.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format); + } + + this.nextFile(key, true); + + }, + + /** + * Successfully loaded a CSV file. + * + * @method Phaser.Loader#csvLoadComplete + * @param {string} key - Key of the loaded CSV file. + */ + csvLoadComplete: function (key) { + + var data = this._xhr.responseText; + var file = this._fileList[key]; + + this.game.cache.addTilemap(file.key, file.url, data, file.format); + + this.nextFile(key, true); + + }, + + /** + * Error occured when load a JSON. + * + * @method Phaser.Loader#dataLoadError + * @param {string} key - Key of the error loading JSON file. + */ + dataLoadError: function (key) { + + var file = this._fileList[key]; + + file.error = true; + + console.warn("Phaser.Loader dataLoadError: " + key); + + this.nextFile(key, true); + + }, + + /** + * Successfully loaded an XML file. + * + * @method Phaser.Loader#xmlLoadComplete + * @param {string} key - Key of the loaded XML file. + */ + xmlLoadComplete: function (key) { + + var data = this._xhr.responseText; + var xml; + + try + { + if (window['DOMParser']) + { + var domparser = new DOMParser(); + xml = domparser.parseFromString(data, "text/xml"); + } + else + { + xml = new ActiveXObject("Microsoft.XMLDOM"); + xml.async = 'false'; + xml.loadXML(data); + } + } + catch (e) + { + xml = undefined; + } + + if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length) + { + throw new Error("Phaser.Loader. Invalid XML given"); + } + + var file = this._fileList[key]; + + if (file.type == 'bitmapfont') + { + this.game.cache.addBitmapFont(file.key, file.url, file.data, xml); + } + else if (file.type == 'textureatlas') + { + this.game.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format); + } + + this.nextFile(key, true); + + }, + + /** + * Handle loading next file. + * + * @param previousKey {string} Key of previous loaded asset. + * @param success {boolean} Whether the previous asset loaded successfully or not. + * @private + */ + nextFile: function (previousKey, success) { + + this.progress = Math.round(this.progress + this._progressChunk); + + if (this.progress > 100) + { + this.progress = 100; + } + + if (this.preloadSprite !== null) + { + if (this.preloadSprite.direction === 0) + { + this.preloadSprite.crop.width = Math.floor((this.preloadSprite.width / 100) * this.progress); + } + else + { + this.preloadSprite.crop.height = Math.floor((this.preloadSprite.height / 100) * this.progress); + } + + this.preloadSprite.sprite.crop = this.preloadSprite.crop; + } + + this.onFileComplete.dispatch(this.progress, previousKey, success, this.queueSize - this._keys.length, this.queueSize); + + if (this._keys.length > 0) + { + this.loadFile(); + } + else + { + this.hasLoaded = true; + this.isLoading = false; + + this.removeAll(); + + this.onLoadComplete.dispatch(); + } + + } }; + /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. @@ -32307,14 +32961,14 @@ Phaser.Loader.prototype = { * @class Phaser.LoaderParser */ Phaser.LoaderParser = { - + /** * Parse frame data from an XML file. * @method Phaser.LoaderParser.bitmapFont * @param {object} xml - XML data you want to parse. * @return {FrameData} Generated FrameData object. */ - bitmapFont: function (game, xml, cacheKey) { + bitmapFont: function (game, xml, cacheKey) { // Malformed? if (!xml.getElementsByTagName('font')) @@ -32347,8 +33001,8 @@ Phaser.LoaderParser = { height: parseInt(letters[i].attributes.getNamedItem("height").nodeValue, 10) }; - // Note: This means you can only have 1 BitmapFont loaded at once! - // Need to replace this with our own handler soon. + // Note: This means you can only have 1 BitmapFont loaded at once! + // Need to replace this with our own handler soon. PIXI.TextureCache[charCode] = new PIXI.Texture(texture, textureRect); data.chars[charCode] = { @@ -32366,9 +33020,9 @@ Phaser.LoaderParser = { for (i = 0; i < kernings.length; i++) { - var first = parseInt(kernings[i].attributes.getNamedItem("first").nodeValue, 10); - var second = parseInt(kernings[i].attributes.getNamedItem("second").nodeValue, 10); - var amount = parseInt(kernings[i].attributes.getNamedItem("amount").nodeValue, 10); + var first = parseInt(kernings[i].attributes.getNamedItem("first").nodeValue, 10); + var second = parseInt(kernings[i].attributes.getNamedItem("second").nodeValue, 10); + var amount = parseInt(kernings[i].attributes.getNamedItem("amount").nodeValue, 10); data.chars[second].kerning[first] = amount; } @@ -32396,9 +33050,9 @@ Phaser.LoaderParser = { * @param {boolean} [loop=false] - Whether or not the sound will loop. */ Phaser.Sound = function (game, key, volume, loop) { - - volume = volume || 1; - if (typeof loop == 'undefined') { loop = false; } + + if (typeof volume == 'undefined') { volume = 1; } + if (typeof loop == 'undefined') { loop = false; } /** * A reference to the currently running Game. @@ -32407,157 +33061,128 @@ Phaser.Sound = function (game, key, volume, loop) { this.game = game; /** - * Name of the sound. - * @property {string} name - * @default + * @property {string} name - Name of the sound. */ this.name = key; /** - * Asset key for the sound. - * @property {string} key + * @property {string} key - Asset key for the sound. */ this.key = key; /** - * Whether or not the sound will loop. - * @property {boolean} loop + * @property {boolean} loop - Whether or not the sound will loop. */ this.loop = loop; /** - * The global audio volume. A value between 0 (silence) and 1 (full volume). - * @property {number} _volume + * @property {number} _volume - The global audio volume. A value between 0 (silence) and 1 (full volume). * @private */ this._volume = volume; /** - * The sound markers, empty by default. - * @property {object} markers + * @property {object} markers - The sound markers. */ this.markers = {}; - /** - * Reference to AudioContext instance. - * @property {AudioContext} context - * @default + * @property {AudioContext} context - Reference to the AudioContext instance. */ this.context = null; /** - * Decoded data buffer / Audio tag. - * @property {Description} _buffer + * @property {Description} _buffer - Decoded data buffer / Audio tag. * @private */ this._buffer = null; /** - * Boolean indicating whether the game is on "mute". - * @property {boolean} _muted + * @property {boolean} _muted - Boolean indicating whether the sound is muted or not. * @private * @default */ this._muted = false; /** - * Boolean indicating whether the sound should start automatically. - * @property {boolean} autoplay - * @private + * @property {boolean} autoplay - Boolean indicating whether the sound should start automatically. */ this.autoplay = false; /** - * The total duration of the sound, in milliseconds - * @property {number} totalDuration - * @default + * @property {number} totalDuration - The total duration of the sound, in milliseconds */ this.totalDuration = 0; /** - * Description. - * @property {number} startTime + * @property {number} startTime - The time the Sound starts at (typically 0 unless starting from a marker) * @default */ this.startTime = 0; /** - * Description. - * @property {number} currentTime - * @default + * @property {number} currentTime - The current time the sound is at. */ this.currentTime = 0; /** - * Description. - * @property {number} duration - * @default + * @property {number} duration - The duration of the sound. */ this.duration = 0; /** - * Description. - * @property {number} stopTime + * @property {number} stopTime - The time the sound stopped. */ this.stopTime = 0; /** - * Description. - * @property {boolean} paused + * @property {boolean} paused - true if the sound is paused, otherwise false. * @default */ this.paused = false; /** - * Description. - * @property {number} pausedPosition + * @property {number} pausedPosition - The position the sound had reached when it was paused. */ this.pausedPosition = 0; /** - * Description. - * @property {number} pausedTime + * @property {number} pausedTime - The game time at which the sound was paused. */ this.pausedTime = 0; /** - * Description. - * @property {boolean} isPlaying + * @property {boolean} isPlaying - true if the sound is currently playing, otherwise false. * @default */ this.isPlaying = false; /** - * Description. - * @property {string} currentMarker + * @property {string} currentMarker - The string ID of the currently playing marker, if any. * @default */ this.currentMarker = ''; /** - * Description. - * @property {boolean} pendingPlayback - * @default + * @property {boolean} pendingPlayback - true if the sound file is pending playback + * @readonly */ this.pendingPlayback = false; /** - * Description. - * @property {boolean} override + * @property {boolean} override - if true when you play this sound it will always start from the beginning. * @default */ this.override = false; /** - * Description. - * @property {boolean} usingWebAudio + * @property {boolean} usingWebAudio - true if this sound is being played with Web Audio. + * @readonly */ this.usingWebAudio = this.game.sound.usingWebAudio; /** - * Description. - * @property {Description} usingAudioTag + * @property {boolean} usingAudioTag - true if the sound is being played via the Audio tag. */ this.usingAudioTag = this.game.sound.usingAudioTag; @@ -32597,63 +33222,55 @@ Phaser.Sound = function (game, key, volume, loop) { } /** - * Description. - * @property {Phaser.Signal} onDecoded + * @property {Phaser.Signal} onDecoded - The onDecoded event is dispatched when the sound has finished decoding (typically for mp3 files) */ - this.onDecoded = new Phaser.Signal; + this.onDecoded = new Phaser.Signal(); /** - * Description. - * @property {Phaser.Signal} onPlay + * @property {Phaser.Signal} onPlay - The onPlay event is dispatched each time this sound is played. */ - this.onPlay = new Phaser.Signal; + this.onPlay = new Phaser.Signal(); /** - * Description. - * @property {Phaser.Signal} onPause + * @property {Phaser.Signal} onPause - The onPause event is dispatched when this sound is paused. */ - this.onPause = new Phaser.Signal; + this.onPause = new Phaser.Signal(); /** - * Description. - * @property {Phaser.Signal} onResume + * @property {Phaser.Signal} onResume - The onResume event is dispatched when this sound is resumed from a paused state. */ - this.onResume = new Phaser.Signal; + this.onResume = new Phaser.Signal(); /** - * Description. - * @property {Phaser.Signal} onLoop + * @property {Phaser.Signal} onLoop - The onLoop event is dispatched when this sound loops during playback. */ - this.onLoop = new Phaser.Signal; + this.onLoop = new Phaser.Signal(); /** - * Description. - * @property {Phaser.Signal} onStop + * @property {Phaser.Signal} onStop - The onStop event is dispatched when this sound stops playback. */ - this.onStop = new Phaser.Signal; + this.onStop = new Phaser.Signal(); /** - * Description. - * @property {Phaser.Signal} onMute + * @property {Phaser.Signal} onMute - The onMouse event is dispatched when this sound is muted. */ - this.onMute = new Phaser.Signal; + this.onMute = new Phaser.Signal(); /** - * Description. - * @property {Phaser.Signal} onMarkerComplete + * @property {Phaser.Signal} onMarkerComplete - The onMarkerComplete event is dispatched when a marker within this sound completes playback. */ - this.onMarkerComplete = new Phaser.Signal; + this.onMarkerComplete = new Phaser.Signal(); }; Phaser.Sound.prototype = { - /** + /** * Called automatically when this sound is unlocked. - * @method Phaser.Sound#soundHasUnlocked - * @param {string} key - Description. + * @method Phaser.Sound#soundHasUnlocked + * @param {string} key - The Phaser.Cache key of the sound file to check for decoding. * @protected - */ + */ soundHasUnlocked: function (key) { if (key == this.key) @@ -32661,22 +33278,22 @@ Phaser.Sound.prototype = { this._sound = this.game.cache.getSoundData(this.key); this.totalDuration = this._sound.duration; // console.log('sound has unlocked' + this._sound); - } + } - }, + }, - /** - * Description. - * @method Phaser.Sound#addMarker - * @param {string} name - Description. - * @param {Description} start - Description. - * @param {Description} stop - Description. - * @param {Description} volume - Description. - * @param {Description} loop - Description. + /** + * Description. + * @method Phaser.Sound#addMarker + * @param {string} name - Description. + * @param {Description} start - Description. + * @param {Description} stop - Description. + * @param {Description} volume - Description. + * @param {Description} loop - Description. addMarker: function (name, start, stop, volume, loop) { - volume = volume || 1; - if (typeof loop == 'undefined') { loop = false; } + volume = volume || 1; + if (typeof loop == 'undefined') { loop = false; } this.markers[name] = { name: name, @@ -32718,22 +33335,22 @@ Phaser.Sound.prototype = { }, - /** - * Removes a marker from the sound. - * @method Phaser.Sound#removeMarker - * @param {string} name - The key of the marker to remove. - */ + /** + * Removes a marker from the sound. + * @method Phaser.Sound#removeMarker + * @param {string} name - The key of the marker to remove. + */ removeMarker: function (name) { delete this.markers[name]; }, - /** - * Called automatically by Phaser.SoundManager. - * @method Phaser.Sound#update + /** + * Called automatically by Phaser.SoundManager. + * @method Phaser.Sound#update * @protected - */ + */ update: function () { if (this.pendingPlayback && this.game.cache.isSoundReady(this.key)) @@ -32757,7 +33374,7 @@ Phaser.Sound.prototype = { // won't work with markers, needs to reset the position this.onLoop.dispatch(this); - if (this.currentMarker == '') + if (this.currentMarker === '') { //console.log('loop2'); this.currentTime = 0; @@ -32791,27 +33408,28 @@ Phaser.Sound.prototype = { } }, - /** + /** * Play this sound, or a marked section of it. * @method Phaser.Sound#play * @param {string} [marker=''] - If you want to play a marker then give the key here, otherwise leave blank to play the full sound. * @param {number} [position=0] - The starting position to play the sound from - this is ignored if you provide a marker. - * @param {number} [volume=1] - Volume of the sound you want to play. + * @param {number} [volume=1] - Volume of the sound you want to play. If none is given it will use the volume given to the Sound when it was created (which defaults to 1 if none was specified). * @param {boolean} [loop=false] - Loop when it finished playing? * @param {boolean} [forceRestart=true] - If the sound is already playing you can set forceRestart to restart it from the beginning. - * @return {Sound} The playing sound object. + * @return {Phaser.Sound} This sound instance. */ play: function (marker, position, volume, loop, forceRestart) { - marker = marker || ''; - position = position || 0; - volume = volume || 1; - if (typeof loop == 'undefined') { loop = false; } - if (typeof forceRestart == 'undefined') { forceRestart = true; } + marker = marker || ''; + position = position || 0; + + if (typeof volume === 'undefined') { volume = this._volume; } + if (typeof loop === 'undefined') { loop = false; } + if (typeof forceRestart === 'undefined') { forceRestart = true; } // console.log(this.name + ' play ' + marker + ' position ' + position + ' volume ' + volume + ' loop ' + loop, 'force', forceRestart); - if (this.isPlaying == true && forceRestart == false && this.override == false) + if (this.isPlaying === true && forceRestart === false && this.override === false) { // Use Restart instead return; @@ -32896,14 +33514,14 @@ Phaser.Sound.prototype = { this._sound.connect(this.gainNode); this.totalDuration = this._sound.buffer.duration; - if (this.duration == 0) + if (this.duration === 0) { // console.log('duration reset'); this.duration = this.totalDuration; this.durationMS = this.totalDuration * 1000; } - if (this.loop && marker == '') + if (this.loop && marker === '') { this._sound.loop = true; } @@ -32914,9 +33532,9 @@ Phaser.Sound.prototype = { this._sound.noteGrainOn(0, this.position, this.duration); // this._sound.noteGrainOn(0, this.position, this.duration / 1000); //this._sound.noteOn(0); // the zero is vitally important, crashes iOS6 without it - } - else - { + } + else + { // this._sound.start(0, this.position, this.duration / 1000); this._sound.start(0, this.position, this.duration); } @@ -32926,12 +33544,12 @@ Phaser.Sound.prototype = { this.currentTime = 0; this.stopTime = this.startTime + this.durationMS; this.onPlay.dispatch(this); - } - else - { + } + else + { this.pendingPlayback = true; - if (this.game.cache.getSound(this.key) && this.game.cache.getSound(this.key).isDecoding == false) + if (this.game.cache.getSound(this.key) && this.game.cache.getSound(this.key).isDecoding === false) { this.game.sound.decode(this.key, this); } @@ -32955,7 +33573,7 @@ Phaser.Sound.prototype = { // This doesn't become available until you call play(), wonderful ... this.totalDuration = this._sound.duration; - if (this.duration == 0) + if (this.duration === 0) { this.duration = this.totalDuration; this.durationMS = this.totalDuration * 1000; @@ -32998,10 +33616,10 @@ Phaser.Sound.prototype = { */ restart: function (marker, position, volume, loop) { - marker = marker || ''; - position = position || 0; - volume = volume || 1; - if (typeof loop == 'undefined') { loop = false; } + marker = marker || ''; + position = position || 0; + volume = volume || 1; + if (typeof loop == 'undefined') { loop = false; } this.play(marker, position, volume, loop, true); @@ -33045,9 +33663,9 @@ Phaser.Sound.prototype = { { this._sound.noteGrainOn(0, p, this.duration); //this._sound.noteOn(0); // the zero is vitally important, crashes iOS6 without it - } - else - { + } + else + { this._sound.start(0, p, this.duration); } } @@ -33064,7 +33682,7 @@ Phaser.Sound.prototype = { }, - /** + /** * Stop playing this sound. * @method Phaser.Sound#stop */ @@ -33131,14 +33749,14 @@ Object.defineProperty(Phaser.Sound.prototype, "isDecoded", { * @property {boolean} mute - Gets or sets the muted state of this sound. */ Object.defineProperty(Phaser.Sound.prototype, "mute", { - + get: function () { return this._muted; }, set: function (value) { - value = value || null; + value = value || null; if (value) { @@ -33214,6 +33832,8 @@ Object.defineProperty(Phaser.Sound.prototype, "volume", { /** * Sound Manager constructor. +* The Sound Manager is responsible for playing back audio via either the Legacy HTML Audio tag or via Web Audio if the browser supports it. +* Note: On Firefox 25+ on Linux if you have media.gstreamer disabled in about:config then it cannot play back mp3 or m4a files. * * @class Phaser.SoundManager * @classdesc Phaser Sound Manager. @@ -33222,28 +33842,28 @@ Object.defineProperty(Phaser.Sound.prototype, "volume", { */ Phaser.SoundManager = function (game) { - /** - * @property {Phaser.Game} game - Local reference to game. - */ - this.game = game; - - /** - * @property {Phaser.Signal} onSoundDecode - Description. - */ - this.onSoundDecode = new Phaser.Signal; - - /** - * @property {boolean} _muted - Description. - * @private - * @default - */ + /** + * @property {Phaser.Game} game - Local reference to game. + */ + this.game = game; + + /** + * @property {Phaser.Signal} onSoundDecode - The event dispatched when a sound decodes (typically only for mp3 files) + */ + this.onSoundDecode = new Phaser.Signal(); + + /** + * @property {boolean} _muted - Internal mute tracking var. + * @private + * @default + */ this._muted = false; - /** - * @property {Description} _unlockSource - Description. - * @private - * @default - */ + /** + * @property {Description} _unlockSource - Internal unlock tracking var. + * @private + * @default + */ this._unlockSource = null; /** @@ -33261,41 +33881,41 @@ Phaser.SoundManager = function (game) { this._sounds = []; /** - * @property {Description} context - Description. + * @property {AudioContext} context - The AudioContext being used for playback. * @default */ this.context = null; - /** - * @property {boolean} usingWebAudio - Description. - * @default - */ + /** + * @property {boolean} usingWebAudio - true if this sound is being played with Web Audio. + * @readonly + */ this.usingWebAudio = true; - /** - * @property {boolean} usingAudioTag - Description. - * @default - */ + /** + * @property {boolean} usingAudioTag - true if the sound is being played via the Audio tag. + * @readonly + */ this.usingAudioTag = false; - /** - * @property {boolean} noAudio - Description. - * @default - */ + /** + * @property {boolean} noAudio - Has audio been disabled via the PhaserGlobal object? Useful if you need to use a 3rd party audio library instead. + * @default + */ this.noAudio = false; - /** - * @property {boolean} touchLocked - Description. - * @default - */ + /** + * @property {boolean} touchLocked - true if the audio system is currently locked awaiting a touch event. + * @default + */ this.touchLocked = false; - /** - * @property {number} channels - Description. - * @default - */ + /** + * @property {number} channels - The number of audio channels to use in playback. + * @default + */ this.channels = 32; - + }; Phaser.SoundManager.prototype = { @@ -33307,7 +33927,7 @@ Phaser.SoundManager.prototype = { */ boot: function () { - if (this.game.device.iOS && this.game.device.webAudio == false) + if (this.game.device.iOS && this.game.device.webAudio === false) { this.channels = 1; } @@ -33329,7 +33949,7 @@ Phaser.SoundManager.prototype = { if (window['PhaserGlobal']) { // Check to see if all audio playback is disabled (i.e. handled by a 3rd party class) - if (window['PhaserGlobal'].disableAudio == true) + if (window['PhaserGlobal'].disableAudio === true) { this.usingWebAudio = false; this.noAudio = true; @@ -33337,7 +33957,7 @@ Phaser.SoundManager.prototype = { } // Check if the Web Audio API is disabled (for testing Audio Tag playback during development) - if (window['PhaserGlobal'].disableWebAudio == true) + if (window['PhaserGlobal'].disableWebAudio === true) { this.usingWebAudio = false; this.usingAudioTag = true; @@ -33389,13 +34009,13 @@ Phaser.SoundManager.prototype = { */ unlock: function () { - if (this.touchLocked == false) + if (this.touchLocked === false) { return; } // Global override (mostly for Audio Tag testing) - if (this.game.device.webAudio == false || (window['PhaserGlobal'] && window['PhaserGlobal'].disableWebAudio == true)) + if (this.game.device.webAudio === false || (window['PhaserGlobal'] && window['PhaserGlobal'].disableWebAudio === true)) { // Create an Audio tag? this.touchLocked = false; @@ -33463,9 +34083,9 @@ Phaser.SoundManager.prototype = { } } - }, + }, - /** + /** * Decode a sound by its assets key. * @method Phaser.SoundManager#decode * @param {string} key - Assets key of the sound to be decoded. @@ -33530,11 +34150,12 @@ Phaser.SoundManager.prototype = { * @param {string} key - Asset key for the sound. * @param {number} [volume=1] - Default value for the volume. * @param {boolean} [loop=false] - Whether or not the sound will loop. + * @return {Phaser.Sound} The new sound instance. */ add: function (key, volume, loop) { - volume = volume || 1; - if (typeof loop == 'undefined') { loop = false; } + if (typeof volume === 'undefined') { volume = 1; } + if (typeof loop === 'undefined') { loop = false; } var sound = new Phaser.Sound(this.game, key, volume, loop); @@ -33542,6 +34163,27 @@ Phaser.SoundManager.prototype = { return sound; + }, + + /** + * Adds a new Sound into the SoundManager and starts it playing. + * @method Phaser.SoundManager#play + * @param {string} key - Asset key for the sound. + * @param {number} [volume=1] - Default value for the volume. + * @param {boolean} [loop=false] - Whether or not the sound will loop. + * @param {boolean} [destroyOnComplete=false] - If true the Sound will destroy itself once it has finished playing, or is stopped. + * @return {Phaser.Sound} The new sound instance. + */ + play: function (key, volume, loop, destroyOnComplete) { + + if (typeof destroyOnComplete == 'undefined') { destroyOnComplete = false; } + + var sound = this.add(key, volume, loop); + + sound.play(); + + return sound; + } }; @@ -33588,7 +34230,7 @@ Object.defineProperty(Phaser.SoundManager.prototype, "mute", { } else { - if (this._muted == false) + if (this._muted === false) { return; } @@ -33673,47 +34315,47 @@ Object.defineProperty(Phaser.SoundManager.prototype, "volume", { Phaser.Utils.Debug = function (game) { /** - * @property {Phaser.Game} game - A reference to the currently running Game. - */ + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = game; - /** - * @property {Context} context - The canvas context on which to render the debug information. - */ + /** + * @property {Context} context - The canvas context on which to render the debug information. + */ this.context = game.context; - /** - * @property {string} font - The font that the debug information is rendered in. - * @default '14px Courier' - */ + /** + * @property {string} font - The font that the debug information is rendered in. + * @default '14px Courier' + */ this.font = '14px Courier'; - /** - * @property {number} lineHeight - The line height between the debug text. - */ + /** + * @property {number} lineHeight - The line height between the debug text. + */ this.lineHeight = 16; - /** - * @property {boolean} renderShadow - Should the text be rendered with a slight shadow? Makes it easier to read on different types of background. - */ + /** + * @property {boolean} renderShadow - Should the text be rendered with a slight shadow? Makes it easier to read on different types of background. + */ this.renderShadow = true; - /** - * @property {Context} currentX - The current X position the debug information will be rendered at. - * @default - */ + /** + * @property {Context} currentX - The current X position the debug information will be rendered at. + * @default + */ this.currentX = 0; - /** - * @property {number} currentY - The current Y position the debug information will be rendered at. - * @default - */ + /** + * @property {number} currentY - The current Y position the debug information will be rendered at. + * @default + */ this.currentY = 0; - /** - * @property {number} currentAlpha - The current alpha the debug information will be rendered at. - * @default - */ + /** + * @property {number} currentAlpha - The current alpha the debug information will be rendered at. + * @default + */ this.currentAlpha = 1; }; @@ -33842,13 +34484,13 @@ Phaser.Utils.Debug.prototype = { }, /** - * Renders the corners and point information of the given Sprite. - * @method Phaser.Utils.Debug#renderSpriteCorners - * @param {Phaser.Sprite} sprite - The sprite to be rendered. - * @param {boolean} [showText=false] - If true the x/y coordinates of each point will be rendered. - * @param {boolean} [showBounds=false] - If true the bounds will be rendered over the top of the sprite. - * @param {string} [color='rgb(255,0,255)'] - The color the text is rendered in. - */ + * Renders the corners and point information of the given Sprite. + * @method Phaser.Utils.Debug#renderSpriteCorners + * @param {Phaser.Sprite} sprite - The sprite to be rendered. + * @param {boolean} [showText=false] - If true the x/y coordinates of each point will be rendered. + * @param {boolean} [showBounds=false] - If true the bounds will be rendered over the top of the sprite. + * @param {string} [color='rgb(255,0,255)'] - The color the text is rendered in. + */ renderSpriteCorners: function (sprite, showText, showBounds, color) { if (this.context == null) @@ -33984,7 +34626,7 @@ Phaser.Utils.Debug.prototype = { upColor = upColor || 'rgba(255,0,0,0.5)'; color = color || 'rgb(255,255,255)'; - if (hideIfUp == true && pointer.isUp == true) + if (hideIfUp === true && pointer.isUp === true) { return; } @@ -34030,7 +34672,7 @@ Phaser.Utils.Debug.prototype = { * @param {number} x - X position of the debug info to be rendered. * @param {number} y - Y position of the debug info to be rendered. * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string). - */ + */ renderSpriteInputInfo: function (sprite, x, y, color) { color = color || 'rgb(255,255,255)'; @@ -34046,13 +34688,13 @@ Phaser.Utils.Debug.prototype = { }, /** - * Render Sprite collision. - * @method Phaser.Utils.Debug#renderSpriteCollision - * @param {Phaser.Sprite} sprite - The sprite to be rendered. - * @param {number} x - X position of the debug info to be rendered. - * @param {number} y - Y position of the debug info to be rendered. + * Render Sprite collision. + * @method Phaser.Utils.Debug#renderSpriteCollision + * @param {Phaser.Sprite} sprite - The sprite to be rendered. + * @param {number} x - X position of the debug info to be rendered. + * @param {number} y - Y position of the debug info to be rendered. * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string). - */ + */ renderSpriteCollision: function (sprite, x, y, color) { color = color || 'rgb(255,255,255)'; @@ -34437,7 +35079,7 @@ Phaser.Utils.Debug.prototype = { * @param {number} y - Y position of the debug info to be rendered. * @param {string} [color] - Color of the debug info to be rendered (format is css color string). * @param {string} font - The font of text to draw. - */ + */ renderText: function (text, x, y, color, font) { if (this.context == null) @@ -34477,7 +35119,7 @@ Phaser.Utils.Debug.prototype = { var testObject = entity.last.next; entity = entity.first; - do + do { var name = entity.sprite.name || '*'; var nameNext = '-'; @@ -34619,13 +35261,13 @@ Phaser.Color = { var argb = Phaser.Color.getRGB(color); var hsl = Phaser.Color.RGBtoHSV(color); - // Hex format + // Hex format var result = Phaser.Color.RGBtoHexstring(color) + "\n"; - // RGB format + // RGB format result = result.concat("Alpha: " + argb.alpha + " Red: " + argb.red + " Green: " + argb.green + " Blue: " + argb.blue) + "\n"; - // HSL info + // HSL info result = result.concat("Hue: " + hsl.hue + " Saturation: " + hsl.saturation + " Lightnes: " + hsl.lightness); return result; @@ -34772,7 +35414,7 @@ Phaser.Color = { if (typeof max === "undefined") { max = 255; } if (typeof alpha === "undefined") { alpha = 255; } - // Sanity checks + // Sanity checks if (max > 255) { return Phaser.Color.getColor(255, 255, 255); } @@ -34887,7 +35529,7 @@ Phaser.Color = { getBlue: function (color) { return color & 0xFF; } - + }; /** @@ -34919,7 +35561,7 @@ Phaser.Physics.Arcade = function (game) { /** * @property {Phaser.Point} gravity - The World gravity setting. Defaults to x: 0, y: 0, or no gravity. */ - this.gravity = new Phaser.Point; + this.gravity = new Phaser.Point(); /** * @property {Phaser.Rectangle} bounds - The bounds inside of which the physics world exists. Defaults to match the world bounds. @@ -34957,13 +35599,13 @@ Phaser.Physics.Arcade = function (game) { * @property {Phaser.Rectangle} _bounds1 - Internal cache var. * @private */ - this._bounds1 = new Phaser.Rectangle; + this._bounds1 = new Phaser.Rectangle(); /** * @property {Phaser.Rectangle} _bounds2 - Internal cache var. * @private */ - this._bounds2 = new Phaser.Rectangle; + this._bounds2 = new Phaser.Rectangle(); /** * @property {number} _overlap - Internal cache var. @@ -35296,7 +35938,7 @@ Phaser.Physics.Arcade.prototype = { this._mapData = tilemapLayer.getTiles(sprite.body.x, sprite.body.y, sprite.body.width, sprite.body.height, true); - if (this._mapData.length == 0) + if (this._mapData.length === 0) { return; } @@ -35340,12 +35982,12 @@ Phaser.Physics.Arcade.prototype = { */ collideGroupVsTilemapLayer: function (group, tilemapLayer, collideCallback, processCallback, callbackContext) { - if (group.length == 0) + if (group.length === 0) { return; } - if (group.length == 0) + if (group.length === 0) { return; } @@ -35354,7 +35996,7 @@ Phaser.Physics.Arcade.prototype = { { var currentNode = group._container.first._iNext; - do + do { if (currentNode.exists) { @@ -35413,7 +36055,7 @@ Phaser.Physics.Arcade.prototype = { */ collideSpriteVsGroup: function (sprite, group, collideCallback, processCallback, callbackContext) { - if (group.length == 0) + if (group.length === 0) { return; } @@ -35455,7 +36097,7 @@ Phaser.Physics.Arcade.prototype = { */ collideGroupVsGroup: function (group1, group2, collideCallback, processCallback, callbackContext) { - if (group1.length == 0 || group2.length == 0) + if (group1.length === 0 || group2.length === 0) { return; } @@ -35464,7 +36106,7 @@ Phaser.Physics.Arcade.prototype = { { var currentNode = group1._container.first._iNext; - do + do { if (currentNode.exists) { @@ -35512,7 +36154,7 @@ Phaser.Physics.Arcade.prototype = { { this._maxOverlap = body1.deltaAbsX() + body2.deltaAbsX() + this.OVERLAP_BIAS; - if (body1.deltaX() == 0 && body2.deltaX() == 0) + if (body1.deltaX() === 0 && body2.deltaX() === 0) { // They overlap but neither of them are moving body1.embedded = true; @@ -35523,7 +36165,7 @@ Phaser.Physics.Arcade.prototype = { // Body1 is moving right and/or Body2 is moving left this._overlap = body1.x + body1.width - body2.x; - if ((this._overlap > this._maxOverlap) || body1.allowCollision.right == false || body2.allowCollision.left == false) + if ((this._overlap > this._maxOverlap) || body1.allowCollision.right === false || body2.allowCollision.left === false) { this._overlap = 0; } @@ -35538,7 +36180,7 @@ Phaser.Physics.Arcade.prototype = { // Body1 is moving left and/or Body2 is moving right this._overlap = body1.x - body2.width - body2.x; - if ((-this._overlap > this._maxOverlap) || body1.allowCollision.left == false || body2.allowCollision.right == false) + if ((-this._overlap > this._maxOverlap) || body1.allowCollision.left === false || body2.allowCollision.right === false) { this._overlap = 0; } @@ -35550,7 +36192,7 @@ Phaser.Physics.Arcade.prototype = { } // Then adjust their positions and velocities accordingly (if there was any overlap) - if (this._overlap != 0) + if (this._overlap !== 0) { body1.overlapX = this._overlap; body2.overlapX = this._overlap; @@ -35620,7 +36262,7 @@ Phaser.Physics.Arcade.prototype = { { this._maxOverlap = body1.deltaAbsY() + body2.deltaAbsY() + this.OVERLAP_BIAS; - if (body1.deltaY() == 0 && body2.deltaY() == 0) + if (body1.deltaY() === 0 && body2.deltaY() === 0) { // They overlap but neither of them are moving body1.embedded = true; @@ -35631,7 +36273,7 @@ Phaser.Physics.Arcade.prototype = { // Body1 is moving down and/or Body2 is moving up this._overlap = body1.y + body1.height - body2.y; - if ((this._overlap > this._maxOverlap) || body1.allowCollision.down == false || body2.allowCollision.up == false) + if ((this._overlap > this._maxOverlap) || body1.allowCollision.down === false || body2.allowCollision.up === false) { this._overlap = 0; } @@ -35646,7 +36288,7 @@ Phaser.Physics.Arcade.prototype = { // Body1 is moving up and/or Body2 is moving down this._overlap = body1.y - body2.height - body2.y; - if ((-this._overlap > this._maxOverlap) || body1.allowCollision.up == false || body2.allowCollision.down == false) + if ((-this._overlap > this._maxOverlap) || body1.allowCollision.up === false || body2.allowCollision.down === false) { this._overlap = 0; } @@ -35658,7 +36300,7 @@ Phaser.Physics.Arcade.prototype = { } // Then adjust their positions and velocities accordingly (if there was any overlap) - if (this._overlap != 0) + if (this._overlap !== 0) { body1.overlapY = this._overlap; body2.overlapY = this._overlap; @@ -35744,7 +36386,7 @@ Phaser.Physics.Arcade.prototype = { separateTileX: function (body, tile, separate) { // Can't separate two immovable objects (tiles are always immovable) - if (body.immovable || body.deltaX() == 0 || Phaser.Rectangle.intersects(body.hullX, tile) == false) + if (body.immovable || body.deltaX() === 0 || Phaser.Rectangle.intersects(body.hullX, tile) === false) { return false; } @@ -35759,8 +36401,8 @@ Phaser.Physics.Arcade.prototype = { // Moving left this._overlap = tile.right - body.hullX.x; - // if ((this._overlap > this._maxOverlap) || body.allowCollision.left == false || tile.tile.collideRight == false) - if (body.allowCollision.left == false || tile.tile.collideRight == false) + // if ((this._overlap > this._maxOverlap) || body.allowCollision.left === false || tile.tile.collideRight === false) + if (body.allowCollision.left === false || tile.tile.collideRight === false) { this._overlap = 0; } @@ -35774,8 +36416,8 @@ Phaser.Physics.Arcade.prototype = { // Moving right this._overlap = body.hullX.right - tile.x; - // if ((this._overlap > this._maxOverlap) || body.allowCollision.right == false || tile.tile.collideLeft == false) - if (body.allowCollision.right == false || tile.tile.collideLeft == false) + // if ((this._overlap > this._maxOverlap) || body.allowCollision.right === false || tile.tile.collideLeft === false) + if (body.allowCollision.right === false || tile.tile.collideLeft === false) { this._overlap = 0; } @@ -35786,7 +36428,7 @@ Phaser.Physics.Arcade.prototype = { } // Then adjust their positions and velocities accordingly (if there was any overlap) - if (this._overlap != 0) + if (this._overlap !== 0) { if (separate) { @@ -35799,7 +36441,7 @@ Phaser.Physics.Arcade.prototype = { body.x = body.x - this._overlap; } - if (body.bounce.x == 0) + if (body.bounce.x === 0) { body.velocity.x = 0; } @@ -35830,7 +36472,7 @@ Phaser.Physics.Arcade.prototype = { separateTileY: function (body, tile, separate) { // Can't separate two immovable objects (tiles are always immovable) - if (body.immovable || body.deltaY() == 0 || Phaser.Rectangle.intersects(body.hullY, tile) == false) + if (body.immovable || body.deltaY() === 0 || Phaser.Rectangle.intersects(body.hullY, tile) === false) { return false; } @@ -35845,8 +36487,8 @@ Phaser.Physics.Arcade.prototype = { // Moving up this._overlap = tile.bottom - body.hullY.y; - // if ((this._overlap > this._maxOverlap) || body.allowCollision.up == false || tile.tile.collideDown == false) - if (body.allowCollision.up == false || tile.tile.collideDown == false) + // if ((this._overlap > this._maxOverlap) || body.allowCollision.up === false || tile.tile.collideDown === false) + if (body.allowCollision.up === false || tile.tile.collideDown === false) { this._overlap = 0; } @@ -35860,8 +36502,8 @@ Phaser.Physics.Arcade.prototype = { // Moving down this._overlap = body.hullY.bottom - tile.y; - // if ((this._overlap > this._maxOverlap) || body.allowCollision.down == false || tile.tile.collideUp == false) - if (body.allowCollision.down == false || tile.tile.collideUp == false) + // if ((this._overlap > this._maxOverlap) || body.allowCollision.down === false || tile.tile.collideUp === false) + if (body.allowCollision.down === false || tile.tile.collideUp === false) { this._overlap = 0; } @@ -35872,7 +36514,7 @@ Phaser.Physics.Arcade.prototype = { } // Then adjust their positions and velocities accordingly (if there was any overlap) - if (this._overlap != 0) + if (this._overlap !== 0) { if (separate) { @@ -35885,7 +36527,7 @@ Phaser.Physics.Arcade.prototype = { body.y = body.y - this._overlap; } - if (body.bounce.y == 0) + if (body.bounce.y === 0) { body.velocity.y = 0; } @@ -36025,7 +36667,7 @@ Phaser.Physics.Arcade.prototype = { velocityFromAngle: function (angle, speed, point) { if (typeof speed === 'undefined') { speed = 60; } - point = point || new Phaser.Point; + point = point || new Phaser.Point(); return point.setTo((Math.cos(this.game.math.degToRad(angle)) * speed), (Math.sin(this.game.math.degToRad(angle)) * speed)); @@ -36044,7 +36686,7 @@ Phaser.Physics.Arcade.prototype = { velocityFromRotation: function (rotation, speed, point) { if (typeof speed === 'undefined') { speed = 60; } - point = point || new Phaser.Point; + point = point || new Phaser.Point(); return point.setTo((Math.cos(rotation) * speed), (Math.sin(rotation) * speed)); @@ -36063,7 +36705,7 @@ Phaser.Physics.Arcade.prototype = { accelerationFromRotation: function (rotation, speed, point) { if (typeof speed === 'undefined') { speed = 60; } - point = point || new Phaser.Point; + point = point || new Phaser.Point(); return point.setTo((Math.cos(rotation) * speed), (Math.sin(rotation) * speed)); @@ -36292,91 +36934,91 @@ Phaser.Physics.Arcade.Body = function (sprite) { /** * @property {Phaser.Sprite} sprite - Reference to the parent Sprite. */ - this.sprite = sprite; + this.sprite = sprite; /** * @property {Phaser.Game} game - Local reference to game. */ - this.game = sprite.game; + this.game = sprite.game; /** * @property {Phaser.Point} offset - The offset of the Physics Body from the Sprite x/y position. */ - this.offset = new Phaser.Point; + this.offset = new Phaser.Point(); /** * @property {number} x - The x position of the physics body. * @readonly */ - this.x = sprite.x; + this.x = sprite.x; /** * @property {number} y - The y position of the physics body. * @readonly */ - this.y = sprite.y; + this.y = sprite.y; /** * @property {number} preX - The previous x position of the physics body. * @readonly */ - this.preX = sprite.x; + this.preX = sprite.x; /** * @property {number} preY - The previous y position of the physics body. * @readonly */ - this.preY = sprite.y; + this.preY = sprite.y; /** * @property {number} preRotation - The previous rotation of the physics body. * @readonly */ - this.preRotation = sprite.angle; + this.preRotation = sprite.angle; /** * @property {number} screenX - The x position of the physics body translated to screen space. * @readonly */ - this.screenX = sprite.x; + this.screenX = sprite.x; /** * @property {number} screenY - The y position of the physics body translated to screen space. * @readonly */ - this.screenY = sprite.y; + this.screenY = sprite.y; /** * @property {number} sourceWidth - The un-scaled original size. * @readonly */ - this.sourceWidth = sprite.currentFrame.sourceSizeW; + this.sourceWidth = sprite.currentFrame.sourceSizeW; /** * @property {number} sourceHeight - The un-scaled original size. * @readonly */ - this.sourceHeight = sprite.currentFrame.sourceSizeH; + this.sourceHeight = sprite.currentFrame.sourceSizeH; /** * @property {number} width - The calculated width of the physics body. */ - this.width = sprite.currentFrame.sourceSizeW; + this.width = sprite.currentFrame.sourceSizeW; /** * @property .numInternal ID cache */ - this.height = sprite.currentFrame.sourceSizeH; + this.height = sprite.currentFrame.sourceSizeH; /** * @property {number} halfWidth - The calculated width / 2 of the physics body. */ - this.halfWidth = Math.floor(sprite.currentFrame.sourceSizeW / 2); + this.halfWidth = Math.floor(sprite.currentFrame.sourceSizeW / 2); /** * @property {number} halfHeight - The calculated height / 2 of the physics body. */ - this.halfHeight = Math.floor(sprite.currentFrame.sourceSizeH / 2); + this.halfHeight = Math.floor(sprite.currentFrame.sourceSizeH / 2); /** * @property {Phaser.Point} center - The center coordinate of the Physics Body. @@ -36387,38 +37029,38 @@ Phaser.Physics.Arcade.Body = function (sprite) { * @property {number} _sx - Internal cache var. * @private */ - this._sx = sprite.scale.x; + this._sx = sprite.scale.x; /** * @property {number} _sy - Internal cache var. * @private */ - this._sy = sprite.scale.y; + this._sy = sprite.scale.y; /** * @property {Phaser.Point} velocity - The velocity in pixels per second sq. of the Body. */ - this.velocity = new Phaser.Point; + this.velocity = new Phaser.Point(); /** * @property {Phaser.Point} acceleration - The velocity in pixels per second sq. of the Body. */ - this.acceleration = new Phaser.Point; + this.acceleration = new Phaser.Point(); /** * @property {Phaser.Point} drag - The drag applied to the motion of the Body. */ - this.drag = new Phaser.Point; + this.drag = new Phaser.Point(); /** * @property {Phaser.Point} gravity - A private Gravity setting for the Body. */ - this.gravity = new Phaser.Point; + this.gravity = new Phaser.Point(); /** * @property {Phaser.Point} bounce - The elasticitiy of the Body when colliding. bounce.x/y = 1 means full rebound, bounce.x/y = 0.5 means 50% rebound velocity. */ - this.bounce = new Phaser.Point; + this.bounce = new Phaser.Point(); /** * @property {Phaser.Point} maxVelocity - The maximum velocity in pixels per second sq. that the Body can reach. @@ -36474,7 +37116,7 @@ Phaser.Physics.Arcade.Body = function (sprite) { */ this.quadTreeIndex = -1; - // Allow collision + // Allow collision /** * Set the allowCollision properties to control which directions collision is processed for this Body. @@ -36592,20 +37234,20 @@ Phaser.Physics.Arcade.Body.prototype = { * @method Phaser.Physics.Arcade#updateBounds * @protected */ - updateBounds: function (centerX, centerY, scaleX, scaleY) { + updateBounds: function (centerX, centerY, scaleX, scaleY) { - if (scaleX != this._sx || scaleY != this._sy) - { - this.width = this.sourceWidth * scaleX; - this.height = this.sourceHeight * scaleY; - this.halfWidth = Math.floor(this.width / 2); - this.halfHeight = Math.floor(this.height / 2); - this._sx = scaleX; - this._sy = scaleY; + if (scaleX != this._sx || scaleY != this._sy) + { + this.width = this.sourceWidth * scaleX; + this.height = this.sourceHeight * scaleY; + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + this._sx = scaleX; + this._sy = scaleY; this.center.setTo(this.x + this.halfWidth, this.y + this.halfHeight); - } + } - }, + }, /** * Internal method. @@ -36613,55 +37255,55 @@ Phaser.Physics.Arcade.Body.prototype = { * @method Phaser.Physics.Arcade#preUpdate * @protected */ - preUpdate: function () { + preUpdate: function () { - // Store and reset collision flags - 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; + // Store and reset collision flags + 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 = true; - this.touching.up = false; - this.touching.down = false; - this.touching.left = false; - this.touching.right = false; + this.touching.none = true; + this.touching.up = false; + this.touching.down = false; + this.touching.left = false; + this.touching.right = false; - this.embedded = false; + this.embedded = false; - 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.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.preRotation = this.sprite.angle; - this.x = this.preX; - this.y = this.preY; - this.rotation = this.preRotation; + this.x = this.preX; + this.y = this.preY; + this.rotation = this.preRotation; - if (this.moves) - { - this.game.physics.updateMotion(this); + if (this.moves) + { + this.game.physics.updateMotion(this); - if (this.collideWorldBounds) - { - this.checkWorldBounds(); - } + if (this.collideWorldBounds) + { + this.checkWorldBounds(); + } - this.updateHulls(); + this.updateHulls(); } - if (this.skipQuadTree == false && this.allowCollision.none == false && this.sprite.visible && this.sprite.alive) - { - this.quadTreeIDs = []; - this.quadTreeIndex = -1; - this.game.physics.quadTree.insert(this); - } + if (this.skipQuadTree === false && this.allowCollision.none === false && this.sprite.visible && this.sprite.alive) + { + this.quadTreeIDs = []; + this.quadTreeIndex = -1; + this.game.physics.quadTree.insert(this); + } - }, + }, /** * Internal method. @@ -36669,25 +37311,25 @@ Phaser.Physics.Arcade.Body.prototype = { * @method Phaser.Physics.Arcade#postUpdate * @protected */ - postUpdate: function () { + postUpdate: function () { - if (this.deltaX() < 0) - { - this.facing = Phaser.LEFT; - } - else if (this.deltaX() > 0) - { - this.facing = Phaser.RIGHT; - } + if (this.deltaX() < 0) + { + this.facing = Phaser.LEFT; + } + else if (this.deltaX() > 0) + { + this.facing = Phaser.RIGHT; + } - if (this.deltaY() < 0) - { - this.facing = Phaser.UP; - } - else if (this.deltaY() > 0) - { - this.facing = Phaser.DOWN; - } + if (this.deltaY() < 0) + { + this.facing = Phaser.UP; + } + else if (this.deltaY() > 0) + { + this.facing = Phaser.DOWN; + } if (this.deltaX() !== 0 || this.deltaY() !== 0) { @@ -36696,12 +37338,12 @@ Phaser.Physics.Arcade.Body.prototype = { this.center.setTo(this.x + this.halfWidth, this.y + this.halfHeight); } - if (this.allowRotation) - { - this.sprite.angle += this.deltaZ(); - } + if (this.allowRotation) + { + this.sprite.angle += this.deltaZ(); + } - }, + }, /** * Internal method. @@ -36709,12 +37351,12 @@ Phaser.Physics.Arcade.Body.prototype = { * @method Phaser.Physics.Arcade#updateHulls * @protected */ - updateHulls: function () { + updateHulls: function () { - this.hullX.setTo(this.x, this.preY, this.width, this.height); - this.hullY.setTo(this.preX, this.y, this.width, this.height); + this.hullX.setTo(this.x, this.preY, this.width, this.height); + this.hullY.setTo(this.preX, this.y, this.width, this.height); - }, + }, /** * Internal method. @@ -36722,31 +37364,31 @@ Phaser.Physics.Arcade.Body.prototype = { * @method Phaser.Physics.Arcade#checkWorldBounds * @protected */ - checkWorldBounds: function () { + checkWorldBounds: function () { - if (this.x < this.game.world.bounds.x) - { - this.x = this.game.world.bounds.x; - this.velocity.x *= -this.bounce.x; - } - else if (this.right > this.game.world.bounds.right) - { - this.x = this.game.world.bounds.right - this.width; - this.velocity.x *= -this.bounce.x; - } + if (this.x < this.game.world.bounds.x) + { + this.x = this.game.world.bounds.x; + this.velocity.x *= -this.bounce.x; + } + else if (this.right > this.game.world.bounds.right) + { + this.x = this.game.world.bounds.right - this.width; + this.velocity.x *= -this.bounce.x; + } - if (this.y < this.game.world.bounds.y) - { - this.y = this.game.world.bounds.y; - this.velocity.y *= -this.bounce.y; - } - else if (this.bottom > this.game.world.bounds.bottom) - { - this.y = this.game.world.bounds.bottom - this.height; - this.velocity.y *= -this.bounce.y; - } + if (this.y < this.game.world.bounds.y) + { + this.y = this.game.world.bounds.y; + this.velocity.y *= -this.bounce.y; + } + else if (this.bottom > this.game.world.bounds.bottom) + { + this.y = this.game.world.bounds.bottom - this.height; + this.velocity.y *= -this.bounce.y; + } - }, + }, /** * You can modify the size of the physics Body to be any dimension you need. @@ -36759,46 +37401,46 @@ Phaser.Physics.Arcade.Body.prototype = { * @param {number} offsetX - The X offset of the Body from the Sprite position. * @param {number} offsetY - The Y offset of the Body from the Sprite position. */ - setSize: function (width, height, offsetX, offsetY) { + setSize: function (width, height, offsetX, offsetY) { - offsetX = offsetX || this.offset.x; - offsetY = offsetY || this.offset.y; + offsetX = offsetX || this.offset.x; + offsetY = offsetY || this.offset.y; - this.sourceWidth = width; - this.sourceHeight = height; - 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(offsetX, offsetY); + this.sourceWidth = width; + this.sourceHeight = height; + 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(offsetX, offsetY); this.center.setTo(this.x + this.halfWidth, this.y + this.halfHeight); - }, + }, /** * Resets all Body values (velocity, acceleration, rotation, etc) * * @method Phaser.Physics.Arcade#reset */ - reset: function () { + reset: function () { - this.velocity.setTo(0, 0); - this.acceleration.setTo(0, 0); + this.velocity.setTo(0, 0); + this.acceleration.setTo(0, 0); - this.angularVelocity = 0; - this.angularAcceleration = 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.preRotation = this.sprite.angle; - this.x = this.preX; - this.y = this.preY; - this.rotation = this.preRotation; + this.x = this.preX; + this.y = this.preY; + this.rotation = this.preRotation; this.center.setTo(this.x + this.halfWidth, this.y + this.halfHeight); - }, + }, /** * Returns the absolute delta x value. @@ -36856,7 +37498,7 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "bottom", { * The sum of the y and height properties. Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. * @method bottom * @return {number} - **/ + */ get: function () { return this.y + this.height; }, @@ -36865,7 +37507,7 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "bottom", { * The sum of the y and height properties. Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. * @method bottom * @param {number} value - **/ + */ set: function (value) { if (value <= this.y) @@ -36892,7 +37534,7 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "right", { * However it does affect the width property. * @method right * @return {number} - **/ + */ get: function () { return this.x + this.width; }, @@ -36902,7 +37544,7 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "right", { * However it does affect the width property. * @method right * @param {number} value - **/ + */ set: function (value) { if (value <= this.x) @@ -36934,62 +37576,67 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "right", { */ Phaser.Particles = function (game) { - /** - * @property {Description} emitters - Description. - */ - this.emitters = {}; + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ + this.game = game; - /** - * @property {number} ID - Description. - * @default - */ - this.ID = 0; + /** + * @property {object} emitters - Internal emitters store. + */ + this.emitters = {}; + + /** + * @property {number} ID - + * @default + */ + this.ID = 0; }; Phaser.Particles.prototype = { - /** - * Adds a new Particle Emitter to the Particle Manager. - * @method Phaser.Particles#add - * @param {Phaser.Emitter} emitter - Description. - * @return {Phaser.Emitter} The emitter that was added. - */ - add: function (emitter) { + /** + * Adds a new Particle Emitter to the Particle Manager. + * @method Phaser.Particles#add + * @param {Phaser.Emitter} emitter - The emitter to be added to the particle manager. + * @return {Phaser.Emitter} The emitter that was added. + */ + add: function (emitter) { - this.emitters[emitter.name] = emitter; + this.emitters[emitter.name] = emitter; - return emitter; + return emitter; - }, + }, - /** - * Removes an existing Particle Emitter from the Particle Manager. - * @method Phaser.Particles#remove - * @param {Phaser.Emitter} emitter - The emitter to remove. - */ - remove: function (emitter) { + /** + * Removes an existing Particle Emitter from the Particle Manager. + * @method Phaser.Particles#remove + * @param {Phaser.Emitter} emitter - The emitter to remove. + */ + remove: function (emitter) { - delete this.emitters[emitter.name]; + delete this.emitters[emitter.name]; - }, + }, - /** - * Called by the core game loop. Updates all Emitters who have their exists value set to true. - * @method Phaser.Particles#update - * @protected - */ - update: function () { + /** + * Called by the core game loop. Updates all Emitters who have their exists value set to true. + * @method Phaser.Particles#update + * @protected + */ + update: function () { - for (var key in this.emitters) - { - if (this.emitters[key].exists) - { - this.emitters[key].update(); - } - } + for (var key in this.emitters) + { + if (this.emitters[key].exists) + { + this.emitters[key].update(); + } + } - } + } }; Phaser.Particles.Arcade = {} @@ -37021,36 +37668,36 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) { * @property {number} maxParticles - The total number of particles in this emitter.. * @default */ - this.maxParticles = maxParticles || 50; + this.maxParticles = maxParticles || 50; - Phaser.Group.call(this, game); + Phaser.Group.call(this, game); /** - * @property {string} name - Description. - */ + * @property {string} name - Description. + */ this.name = 'emitter' + this.game.particles.ID++; /** - * @property {Description} type - Description. - */ + * @property {Description} type - Description. + */ this.type = Phaser.EMITTER; /** - * @property {number} x - The X position of the top left corner of the emitter in world space. - * @default - */ + * @property {number} x - The X position of the top left corner of the emitter in world space. + * @default + */ this.x = 0; /** - * @property {number} y - The Y position of the top left corner of emitter in world space. - * @default - */ + * @property {number} y - The Y position of the top left corner of emitter in world space. + * @default + */ this.y = 0; /** - * @property {number} width - The width of the emitter. Particles can be randomly generated from anywhere within this box. - * @default - */ + * @property {number} width - The width of the emitter. Particles can be randomly generated from anywhere within this box. + * @default + */ this.width = 1; /** @@ -37082,138 +37729,138 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) { this.minParticleScale = 1; /** - * The maximum possible scale of a particle. - * The default value is 1. - * @property {number} maxParticleScale - * @default - */ + * The maximum possible scale of a particle. + * The default value is 1. + * @property {number} maxParticleScale + * @default + */ this.maxParticleScale = 1; /** - * The minimum possible angular velocity of a particle. The default value is -360. - * @property {number} minRotation - * @default - */ + * The minimum possible angular velocity of a particle. The default value is -360. + * @property {number} minRotation + * @default + */ this.minRotation = -360; /** - * The maximum possible angular velocity of a particle. The default value is 360. - * @property {number} maxRotation - * @default - */ + * The maximum possible angular velocity of a particle. The default value is 360. + * @property {number} maxRotation + * @default + */ this.maxRotation = 360; /** - * Sets the gravity.y of each particle to this value on launch. - * @property {number} gravity - * @default - */ + * Sets the gravity.y of each particle to this value on launch. + * @property {number} gravity + * @default + */ this.gravity = 2; /** - * Set your own particle class type here. - * @property {Description} particleClass - * @default - */ + * Set your own particle class type here. + * @property {Description} particleClass + * @default + */ this.particleClass = null; /** - * The X and Y drag component of particles launched from the emitter. - * @property {Phaser.Point} particleDrag - */ + * The X and Y drag component of particles launched from the emitter. + * @property {Phaser.Point} particleDrag + */ this.particleDrag = new Phaser.Point(); /** - * The angular drag component of particles launched from the emitter if they are rotating. - * @property {number} angularDrag - * @default - */ + * The angular drag component of particles launched from the emitter if they are rotating. + * @property {number} angularDrag + * @default + */ this.angularDrag = 0; /** - * How often a particle is emitted in ms (if emitter is started with Explode == false). - * @property {boolean} frequency - * @default - */ + * How often a particle is emitted in ms (if emitter is started with Explode === false). + * @property {boolean} frequency + * @default + */ this.frequency = 100; /** - * How long each particle lives once it is emitted in ms. Default is 2 seconds. - * Set lifespan to 'zero' for particles to live forever. - * @property {number} lifespan - * @default - */ + * How long each particle lives once it is emitted in ms. Default is 2 seconds. + * Set lifespan to 'zero' for particles to live forever. + * @property {number} lifespan + * @default + */ this.lifespan = 2000; /** - * How much each particle should bounce on each axis. 1 = full bounce, 0 = no bounce. - * @property {Phaser.Point} bounce - */ + * How much each particle should bounce on each axis. 1 = full bounce, 0 = no bounce. + * @property {Phaser.Point} bounce + */ this.bounce = new Phaser.Point(); /** - * Internal helper for deciding how many particles to launch. - * @property {number} _quantity - * @private - * @default - */ + * Internal helper for deciding how many particles to launch. + * @property {number} _quantity + * @private + * @default + */ this._quantity = 0; - /** - * Internal helper for deciding when to launch particles or kill them. - * @property {number} _timer - * @private - * @default - */ + /** + * Internal helper for deciding when to launch particles or kill them. + * @property {number} _timer + * @private + * @default + */ this._timer = 0; /** - * Internal counter for figuring out how many particles to launch. - * @property {number} _counter - * @private - * @default - */ + * Internal counter for figuring out how many particles to launch. + * @property {number} _counter + * @private + * @default + */ this._counter = 0; /** - * Internal helper for the style of particle emission (all at once, or one at a time). - * @property {boolean} _explode - * @private - * @default - */ + * Internal helper for the style of particle emission (all at once, or one at a time). + * @property {boolean} _explode + * @private + * @default + */ this._explode = true; /** - * Determines whether the emitter is currently emitting particles. - * It is totally safe to directly toggle this. - * @property {boolean} on - * @default - */ + * Determines whether the emitter is currently emitting particles. + * It is totally safe to directly toggle this. + * @property {boolean} on + * @default + */ this.on = false; /** - * Determines whether the emitter is being updated by the core game loop. - * @property {boolean} exists - * @default - */ + * Determines whether the emitter is being updated by the core game loop. + * @property {boolean} exists + * @default + */ this.exists = true; /** - * The point the particles are emitted from. - * Emitter.x and Emitter.y control the containers location, which updates all current particles - * Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position. - * @property {boolean} emitX - */ + * The point the particles are emitted from. + * Emitter.x and Emitter.y control the containers location, which updates all current particles + * Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position. + * @property {boolean} emitX + */ this.emitX = x; /** - * The point the particles are emitted from. - * Emitter.x and Emitter.y control the containers location, which updates all current particles - * Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position. - * @property {boolean} emitY - */ + * The point the particles are emitted from. + * Emitter.x and Emitter.y control the containers location, which updates all current particles + * Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position. + * @property {boolean} emitY + */ this.emitY = y; - + }; Phaser.Particles.Arcade.Emitter.prototype = Object.create(Phaser.Group.prototype); @@ -37229,12 +37876,12 @@ Phaser.Particles.Arcade.Emitter.prototype.update = function () { { if (this._explode) { - this._counter = 0; + this._counter = 0; do { - this.emitParticle(); - this._counter++; + this.emitParticle(); + this._counter++; } while (this._counter < this._quantity); @@ -37242,22 +37889,22 @@ Phaser.Particles.Arcade.Emitter.prototype.update = function () { } else { - if (this.game.time.now >= this._timer) - { + if (this.game.time.now >= this._timer) + { this.emitParticle(); - - this._counter++; + + this._counter++; if (this._quantity > 0) { - if (this._counter >= this._quantity) - { - this.on = false; - } + if (this._counter >= this._quantity) + { + this.on = false; + } } this._timer = this.game.time.now + this.frequency; - } + } } } @@ -37281,7 +37928,7 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames frames = 0; } - quantity = quantity || this.maxParticles; + quantity = quantity || this.maxParticles; collide = collide || 0; if (typeof collideWorldBounds == 'undefined') @@ -37310,10 +37957,10 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames particle = new Phaser.Sprite(this.game, 0, 0, rndKey, rndFrame); } - else - { + // else + // { // particle = new this.particleClass(this.game); - } + // } if (collide > 0) { @@ -37375,18 +38022,18 @@ Phaser.Particles.Arcade.Emitter.prototype.revive = function () { */ Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, frequency, quantity) { - if (typeof explode !== 'boolean') - { - explode = true; - } + if (typeof explode !== 'boolean') + { + explode = true; + } - lifespan = lifespan || 0; + lifespan = lifespan || 0; - // How many ms between emissions? - frequency = frequency || 250; + // How many ms between emissions? + frequency = frequency || 250; - // Total number of particles to emit - quantity = quantity || 0; + // Total number of particles to emit + quantity = quantity || 0; this.revive(); @@ -37421,16 +38068,16 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () { if (particle == null) { - return; + return; } if (this.width > 1 || this.height > 1) { - particle.reset(this.game.rnd.integerInRange(this.left, this.right), this.game.rnd.integerInRange(this.top, this.bottom)); + particle.reset(this.game.rnd.integerInRange(this.left, this.right), this.game.rnd.integerInRange(this.top, this.bottom)); } else { - particle.reset(this.emitX, this.emitY); + particle.reset(this.emitX, this.emitY); } particle.lifespan = this.lifespan; @@ -37499,8 +38146,8 @@ Phaser.Particles.Arcade.Emitter.prototype.setSize = function (width, height) { */ Phaser.Particles.Arcade.Emitter.prototype.setXSpeed = function (min, max) { - min = min || 0; - max = max || 0; + min = min || 0; + max = max || 0; this.minParticleSpeed.x = min; this.maxParticleSpeed.x = max; @@ -37515,8 +38162,8 @@ Phaser.Particles.Arcade.Emitter.prototype.setXSpeed = function (min, max) { */ Phaser.Particles.Arcade.Emitter.prototype.setYSpeed = function (min, max) { - min = min || 0; - max = max || 0; + min = min || 0; + max = max || 0; this.minParticleSpeed.y = min; this.maxParticleSpeed.y = max; @@ -37531,8 +38178,8 @@ Phaser.Particles.Arcade.Emitter.prototype.setYSpeed = function (min, max) { */ Phaser.Particles.Arcade.Emitter.prototype.setRotation = function (min, max) { - min = min || 0; - max = max || 0; + min = min || 0; + max = max || 0; this.minRotation = min; this.maxRotation = max; @@ -37676,7 +38323,6 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "bottom", { * @module Phaser.Tile */ - /** * Create a new Tile. * @@ -37862,7 +38508,7 @@ Object.defineProperty(Phaser.Tile.prototype, "bottom", { * The sum of the y and height properties. Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. * @method bottom * @return {number} - **/ + */ get: function () { return this.y + this.height; } @@ -37876,7 +38522,7 @@ Object.defineProperty(Phaser.Tile.prototype, "right", { * However it does affect the width property. * @method right * @return {number} - **/ + */ get: function () { return this.x + this.width; } @@ -37885,26 +38531,26 @@ Object.defineProperty(Phaser.Tile.prototype, "right", { Phaser.Tilemap = function (game, key) { - /** - * @property {Phaser.Game} game - Description. - */ + /** + * @property {Phaser.Game} game - Description. + */ this.game = game; /** * @property {array} layers - Description. */ - this.layers; + this.layers = null; if (typeof key === 'string') { - this.key = key; + this.key = key; - this.layers = game.cache.getTilemapData(key).layers; + this.layers = game.cache.getTilemapData(key).layers; this.calculateIndexes(); } else { - this.layers = []; + this.layers = []; } this.currentLayer = 0; @@ -37940,15 +38586,15 @@ Phaser.Tilemap.prototype = { this.currentLayer = this.layers.push({ - name: name, - width: width, - height: height, - alpha: 1, - visible: true, - tileMargin: 0, - tileSpacing: 0, - format: Phaser.Tilemap.CSV, - data: data, + name: name, + width: width, + height: height, + alpha: 1, + visible: true, + tileMargin: 0, + tileSpacing: 0, + format: Phaser.Tilemap.CSV, + data: data, indexes: [] }); @@ -37981,10 +38627,10 @@ Phaser.Tilemap.prototype = { setLayer: function (layer) { - if (this.layers[layer]) - { - this.currentLayer = layer; - } + if (this.layers[layer]) + { + this.currentLayer = layer; + } }, @@ -37999,10 +38645,10 @@ Phaser.Tilemap.prototype = { if (typeof layer === "undefined") { layer = this.currentLayer; } - if (x >= 0 && x < this.layers[layer].width && y >= 0 && y < this.layers[layer].height) - { - this.layers[layer].data[y][x] = index; - } + if (x >= 0 && x < this.layers[layer].width && y >= 0 && y < this.layers[layer].height) + { + this.layers[layer].data[y][x] = index; + } this.dirty = true; @@ -38158,7 +38804,7 @@ Phaser.Tilemap.prototype = { }, - swapHandler: function (value, index, array) { + swapHandler: function (value, index) { if (value.index === this._tempA) { @@ -38347,14 +38993,14 @@ Phaser.Tilemap.prototype = { if (this.layers[this.currentLayer].data[y][x] > 1) { - if (this.debugMap[this.layers[this.currentLayer].data[y][x]]) - { - args.push("background: " + this.debugMap[this.layers[this.currentLayer].data[y][x]]); - } - else - { - args.push("background: #ffffff"); - } + if (this.debugMap[this.layers[this.currentLayer].data[y][x]]) + { + args.push("background: " + this.debugMap[this.layers[this.currentLayer].data[y][x]]); + } + else + { + args.push("background: #ffffff"); + } } else { @@ -38382,33 +39028,33 @@ Phaser.Tilemap.prototype = { // Maybe should extend Sprite? Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset, tilemap, layer) { - /** - * @property {Phaser.Game} game - Description. - */ + /** + * @property {Phaser.Game} game - Description. + */ this.game = game; - /** - * @property {Description} canvas - Description. - * @default - */ + /** + * @property {Description} canvas - Description. + * @default + */ this.canvas = Phaser.Canvas.create(renderWidth, renderHeight); - /** - * @property {Description} context - Description. - * @default - */ + /** + * @property {Description} context - Description. + * @default + */ this.context = this.canvas.getContext('2d'); - /** - * @property {Description} baseTexture - Description. - * @default - */ + /** + * @property {Description} baseTexture - Description. + * @default + */ this.baseTexture = new PIXI.BaseTexture(this.canvas); - /** - * @property {Description} texture - Description. - * @default - */ + /** + * @property {Description} texture - Description. + * @default + */ this.texture = new PIXI.Texture(this.baseTexture); this.textureFrame = new Phaser.Frame(0, 0, 0, renderWidth, renderHeight, 'tilemaplayer', game.rnd.uuid()); @@ -38526,18 +39172,18 @@ Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset, /** * @property {number} scrollFactorX - speed at which this layer scrolls - * horizontally, relative to the camera (e.g. scrollFactorX of 0.5 scrolls - * half as quickly as the 'normal' camera-locked layers do) - * @default 1 + * horizontally, relative to the camera (e.g. scrollFactorX of 0.5 scrolls + * half as quickly as the 'normal' camera-locked layers do) + * @default 1 */ - this.scrollFactorX = 1; + this.scrollFactorX = 1; /** * @property {number} scrollFactorY - speed at which this layer scrolls - * vertically, relative to the camera (e.g. scrollFactorY of 0.5 scrolls - * half as quickly as the 'normal' camera-locked layers do) - * @default 1 + * vertically, relative to the camera (e.g. scrollFactorY of 0.5 scrolls + * half as quickly as the 'normal' camera-locked layers do) + * @default 1 */ - this.scrollFactorY = 1; + this.scrollFactorY = 1; this.tilemap = null; this.layer = null; @@ -38632,14 +39278,14 @@ Phaser.TilemapLayer.prototype.updateMapData = function (tilemap, layer) { */ Phaser.TilemapLayer.prototype._fixX = function(x) { - if (this.scrollFactorX === 1) + if (this.scrollFactorX === 1) { return x; } - var left_edge = x - (this._x / this.scrollFactorX); + var leftEdge = x - (this._x / this.scrollFactorX); - return this._x + left_edge; + return this._x + leftEdge; } @@ -38651,14 +39297,14 @@ Phaser.TilemapLayer.prototype._fixX = function(x) { */ Phaser.TilemapLayer.prototype._unfixX = function(x) { - if (this.scrollFactorX === 1) + if (this.scrollFactorX === 1) { return x; } - var left_edge = x - this._x; + var leftEdge = x - this._x; - return (this._x / this.scrollFactorX) + left_edge; + return (this._x / this.scrollFactorX) + leftEdge; } @@ -38670,14 +39316,14 @@ Phaser.TilemapLayer.prototype._unfixX = function(x) { */ Phaser.TilemapLayer.prototype._fixY = function(y) { - if (this.scrollFactorY === 1) + if (this.scrollFactorY === 1) { return y; } - var top_edge = y - (this._y / this.scrollFactorY); + var topEdge = y - (this._y / this.scrollFactorY); - return this._y + top_edge; + return this._y + topEdge; } @@ -38689,14 +39335,14 @@ Phaser.TilemapLayer.prototype._fixY = function(y) { */ Phaser.TilemapLayer.prototype._unfixY = function(y) { - if (this.scrollFactorY === 1) + if (this.scrollFactorY === 1) { return y; } - var top_edge = y - this._y; + var topEdge = y - this._y; - return (this._y / this.scrollFactorY) + top_edge; + return (this._y / this.scrollFactorY) + topEdge; } @@ -38710,7 +39356,7 @@ Phaser.TilemapLayer.prototype.getTileX = function (x) { var tileWidth = this.tileWidth * this.scale.x; - return this.game.math.snapToFloor(this._fixX(x), tileWidth) / tileWidth; + return this.game.math.snapToFloor(this._fixX(x), tileWidth) / tileWidth; } @@ -38724,7 +39370,7 @@ Phaser.TilemapLayer.prototype.getTileY = function (y) { var tileHeight = this.tileHeight * this.scale.y; - return this.game.math.snapToFloor(this._fixY(y), tileHeight) / tileHeight; + return this.game.math.snapToFloor(this._fixY(y), tileHeight) / tileHeight; } @@ -38765,9 +39411,9 @@ Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides y = 0; } - // adjust the x,y coordinates for scrollFactor - x = this._fixX( x ); - y = this._fixY( y ); + // adjust the x,y coordinates for scrollFactor + x = this._fixX( x ); + y = this._fixY( y ); if (width > this.widthInPixels) { @@ -38814,11 +39460,11 @@ Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides sx = _tile.width * this.scale.x; sy = _tile.height * this.scale.y; - if (collides == false || (collides && _tile.collideNone == false)) + if (collides === false || (collides && _tile.collideNone === false)) { - // convert tile coordinates back to camera space for return - var _wx = this._unfixX( wx*sx ) / tileWidth; - var _wy = this._unfixY( wy*sy ) / tileHeight; + // convert tile coordinates back to camera space for return + var _wx = this._unfixX( wx*sx ) / tileWidth; + var _wy = this._unfixY( wy*sy ) / tileHeight; this._results.push({ x: _wx * sx, right: (_wx * sx) + sx, y: _wy * sy, bottom: (_wy * sy) + sy, width: sx, height: sy, tx: _wx, ty: _wy, tile: _tile }); } } @@ -39016,185 +39662,185 @@ Object.defineProperty(Phaser.TilemapLayer.prototype, "scrollY", { Phaser.TilemapParser = { - tileset: function (game, key, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing) { + tileset: function (game, key, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing) { - // How big is our image? - var img = game.cache.getTilesetImage(key); + // How big is our image? + var img = game.cache.getTilesetImage(key); - if (img == null) - { - return null; - } + if (img == null) + { + return null; + } - var width = img.width; - var height = img.height; + var width = img.width; + var height = img.height; - // If no tile width/height is given, try and figure it out (won't work if the tileset has margin/spacing) - if (tileWidth <= 0) - { - tileWidth = Math.floor(-width / Math.min(-1, tileWidth)); - } + // If no tile width/height is given, try and figure it out (won't work if the tileset has margin/spacing) + if (tileWidth <= 0) + { + tileWidth = Math.floor(-width / Math.min(-1, tileWidth)); + } - if (tileHeight <= 0) - { - tileHeight = Math.floor(-height / Math.min(-1, tileHeight)); - } + if (tileHeight <= 0) + { + tileHeight = Math.floor(-height / Math.min(-1, tileHeight)); + } - var row = Math.round(width / tileWidth); - var column = Math.round(height / tileHeight); - var total = row * column; - - if (tileMax !== -1) - { - total = tileMax; - } + var row = Math.round(width / tileWidth); + var column = Math.round(height / tileHeight); + var total = row * column; + + if (tileMax !== -1) + { + total = tileMax; + } - // Zero or smaller than tile sizes? - if (width == 0 || height == 0 || width < tileWidth || height < tileHeight || total === 0) - { - console.warn("Phaser.TilemapParser.tileSet: width/height zero or width/height < given tileWidth/tileHeight"); - return null; - } + // Zero or smaller than tile sizes? + if (width === 0 || height === 0 || width < tileWidth || height < tileHeight || total === 0) + { + console.warn("Phaser.TilemapParser.tileSet: width/height zero or width/height < given tileWidth/tileHeight"); + return null; + } - // Let's create some tiles - var x = tileMargin; - var y = tileMargin; + // Let's create some tiles + var x = tileMargin; + var y = tileMargin; - var tileset = new Phaser.Tileset(img, key, tileWidth, tileHeight, tileMargin, tileSpacing); + var tileset = new Phaser.Tileset(img, key, tileWidth, tileHeight, tileMargin, tileSpacing); - for (var i = 0; i < total; i++) - { - tileset.addTile(new Phaser.Tile(tileset, i, x, y, tileWidth, tileHeight)); + for (var i = 0; i < total; i++) + { + tileset.addTile(new Phaser.Tile(tileset, i, x, y, tileWidth, tileHeight)); - x += tileWidth + tileSpacing; + x += tileWidth + tileSpacing; - if (x === width) - { - x = tileMargin; - y += tileHeight + tileSpacing; - } - } - - return tileset; - - }, - - parse: function (game, data, format) { - - if (format === Phaser.Tilemap.CSV) - { - return this.parseCSV(data); - } - else if (format === Phaser.Tilemap.TILED_JSON) - { - return this.parseTiledJSON(data); - } - - }, - - /** - * Parse csv map data and generate tiles. - * - * @method Phaser.Tilemap.prototype.parseCSV - * @param {string} data - CSV map data. - */ - parseCSV: function (data) { - - // Trim any rogue whitespace from the data - data = data.trim(); - - var output = []; - var rows = data.split("\n"); - var height = rows.length; - var width = 0; - - for (var i = 0; i < rows.length; i++) - { - output[i] = []; - - var column = rows[i].split(","); - - for (var c = 0; c < column.length; c++) - { - output[i][c] = parseInt(column[c]); - } - - if (width == 0) + if (x === width) { - width = column.length; + x = tileMargin; + y += tileHeight + tileSpacing; } - } + } - return [{ name: 'csv', width: width, height: height, alpha: 1, visible: true, indexes: [], tileMargin: 0, tileSpacing: 0, data: output }]; + return tileset; - }, + }, - /** - * Parse JSON map data and generate tiles. - * - * @method Phaser.Tilemap.prototype.parseTiledJSON - * @param {string} data - JSON map data. - * @param {string} key - Asset key for tileset image. - */ - parseTiledJSON: function (json) { + parse: function (game, data, format) { - var layers = []; + if (format === Phaser.Tilemap.CSV) + { + return this.parseCSV(data); + } + else if (format === Phaser.Tilemap.TILED_JSON) + { + return this.parseTiledJSON(data); + } - for (var i = 0; i < json.layers.length; i++) - { - // Check it's a data layer - if (!json.layers[i].data) - { - continue; - } + }, - // json.tilewidth - // json.tileheight + /** + * Parse csv map data and generate tiles. + * + * @method Phaser.Tilemap.prototype.parseCSV + * @param {string} data - CSV map data. + */ + parseCSV: function (data) { - var layer = { + // Trim any rogue whitespace from the data + data = data.trim(); - name: json.layers[i].name, - width: json.layers[i].width, - height: json.layers[i].height, - alpha: json.layers[i].opacity, - visible: json.layers[i].visible, - indexes: [], + var output = []; + var rows = data.split("\n"); + var height = rows.length; + var width = 0; - tileMargin: json.tilesets[0].margin, - tileSpacing: json.tilesets[0].spacing, + for (var i = 0; i < rows.length; i++) + { + output[i] = []; - }; + var column = rows[i].split(","); - var output = []; - var c = 0; - var row; + for (var c = 0; c < column.length; c++) + { + output[i][c] = parseInt(column[c], 10); + } - for (var t = 0; t < json.layers[i].data.length; t++) - { - if (c == 0) - { - row = []; - } + if (width === 0) + { + width = column.length; + } + } - row.push(json.layers[i].data[t]); - c++; + return [{ name: 'csv', width: width, height: height, alpha: 1, visible: true, indexes: [], tileMargin: 0, tileSpacing: 0, data: output }]; - if (c == json.layers[i].width) - { - output.push(row); - c = 0; - } - } + }, - layer.data = output; - - layers.push(layer); + /** + * Parse JSON map data and generate tiles. + * + * @method Phaser.Tilemap.prototype.parseTiledJSON + * @param {string} data - JSON map data. + * @param {string} key - Asset key for tileset image. + */ + parseTiledJSON: function (json) { - } + var layers = []; - return layers; + for (var i = 0; i < json.layers.length; i++) + { + // Check it's a data layer + if (!json.layers[i].data) + { + continue; + } - } + // json.tilewidth + // json.tileheight + + var layer = { + + name: json.layers[i].name, + width: json.layers[i].width, + height: json.layers[i].height, + alpha: json.layers[i].opacity, + visible: json.layers[i].visible, + indexes: [], + + tileMargin: json.tilesets[0].margin, + tileSpacing: json.tilesets[0].spacing + + }; + + var output = []; + var c = 0; + var row; + + for (var t = 0; t < json.layers[i].data.length; t++) + { + if (c === 0) + { + row = []; + } + + row.push(json.layers[i].data[t]); + c++; + + if (c == json.layers[i].width) + { + output.push(row); + c = 0; + } + } + + layer.data = output; + + layers.push(layer); + + } + + return layers; + + } } @@ -39261,7 +39907,7 @@ Phaser.Tileset.prototype = { checkTileIndex: function (index) { - return (this.tiles[index]); + return (this.tiles[index]); }, @@ -39284,7 +39930,7 @@ Phaser.Tileset.prototype = { this.tiles[index].setCollision(left, right, up, down); } - }, + } } @@ -39319,240 +39965,239 @@ Object.defineProperty(Phaser.Tileset.prototype, "total", { */ PIXI.CanvasRenderer.prototype.render = function(stage) { - PIXI.texturesToUpdate.length = 0; - PIXI.texturesToDestroy.length = 0; - - PIXI.visibleCount++; - stage.updateTransform(); - - // update the background color - // if(this.view.style.backgroundColor!=stage.backgroundColorString && !this.transparent)this.view.style.backgroundColor = stage.backgroundColorString; + PIXI.texturesToUpdate.length = 0; + PIXI.texturesToDestroy.length = 0; + + PIXI.visibleCount++; + stage.updateTransform(); - this.context.setTransform(1, 0, 0, 1, 0, 0); - this.context.clearRect(0, 0, this.width, this.height) + this.context.setTransform(1, 0, 0, 1, 0, 0); + this.context.clearRect(0, 0, this.width, this.height) this.renderDisplayObject(stage); - // Remove frame updates - if (PIXI.Texture.frameUpdates.length > 0) - { - PIXI.Texture.frameUpdates.length = 0; - } - + // Remove frame updates + if (PIXI.Texture.frameUpdates.length > 0) + { + PIXI.Texture.frameUpdates.length = 0; + } + } PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject) { - // Once the display object hits this we can break the loop - var testObject = displayObject.last._iNext; - displayObject = displayObject.first; - - do - { - //transform = displayObject.worldTransform; - - if (!displayObject.visible) - { - displayObject = displayObject.last._iNext; - continue; - } - - if (!displayObject.renderable || displayObject.alpha == 0) - { - displayObject = displayObject._iNext; - continue; - } - - if (displayObject instanceof PIXI.Sprite) - { - // var frame = displayObject.texture.frame; - - if (displayObject.texture.frame) - { - this.context.globalAlpha = displayObject.worldAlpha; - - if (displayObject.texture.trimmed) - { - this.context.setTransform(displayObject.worldTransform[0], displayObject.worldTransform[3], displayObject.worldTransform[1], displayObject.worldTransform[4], displayObject.worldTransform[2] + displayObject.texture.trim.x, displayObject.worldTransform[5] + displayObject.texture.trim.y); - } - else - { - this.context.setTransform(displayObject.worldTransform[0], displayObject.worldTransform[3], displayObject.worldTransform[1], displayObject.worldTransform[4], displayObject.worldTransform[2], displayObject.worldTransform[5]); - } - - this.context.drawImage( - displayObject.texture.baseTexture.source, - displayObject.texture.frame.x, - displayObject.texture.frame.y, - displayObject.texture.frame.width, - displayObject.texture.frame.height, - (displayObject.anchor.x) * -displayObject.texture.frame.width, - (displayObject.anchor.y) * -displayObject.texture.frame.height, - displayObject.texture.frame.width, - displayObject.texture.frame.height); - } - } - else if (displayObject instanceof PIXI.Strip) - { - this.context.setTransform(displayObject.worldTransform[0], displayObject.worldTransform[3], displayObject.worldTransform[1], displayObject.worldTransform[4], displayObject.worldTransform[2], displayObject.worldTransform[5]) - this.renderStrip(displayObject); - } - else if (displayObject instanceof PIXI.TilingSprite) - { - this.context.setTransform(displayObject.worldTransform[0], displayObject.worldTransform[3], displayObject.worldTransform[1], displayObject.worldTransform[4], displayObject.worldTransform[2], displayObject.worldTransform[5]) - this.renderTilingSprite(displayObject); - } - else if (displayObject instanceof PIXI.CustomRenderable) - { - displayObject.renderCanvas(this); - } - else if (displayObject instanceof PIXI.Graphics) - { - this.context.setTransform(displayObject.worldTransform[0], displayObject.worldTransform[3], displayObject.worldTransform[1], displayObject.worldTransform[4], displayObject.worldTransform[2], displayObject.worldTransform[5]) - PIXI.CanvasGraphics.renderGraphics(displayObject, this.context); - } - else if (displayObject instanceof PIXI.FilterBlock) - { - if (displayObject.open) - { - this.context.save(); - - var cacheAlpha = displayObject.mask.alpha; - var maskTransform = displayObject.mask.worldTransform; - - this.context.setTransform(maskTransform[0], maskTransform[3], maskTransform[1], maskTransform[4], maskTransform[2], maskTransform[5]) - - displayObject.mask.worldAlpha = 0.5; - - this.context.worldAlpha = 0; - - PIXI.CanvasGraphics.renderGraphicsMask(displayObject.mask, this.context); - this.context.clip(); - - displayObject.mask.worldAlpha = cacheAlpha; - } - else - { - this.context.restore(); - } - } - // count++ - displayObject = displayObject._iNext; - } - while(displayObject != testObject) - + // Once the display object hits this we can break the loop + var testObject = displayObject.last._iNext; + displayObject = displayObject.first; + + do + { + //transform = displayObject.worldTransform; + + if (!displayObject.visible) + { + displayObject = displayObject.last._iNext; + continue; + } + + if (!displayObject.renderable || displayObject.alpha === 0) + { + displayObject = displayObject._iNext; + continue; + } + + if (displayObject instanceof PIXI.Sprite) + { + // var frame = displayObject.texture.frame; + + if (displayObject.texture.frame) + { + this.context.globalAlpha = displayObject.worldAlpha; + + if (displayObject.texture.trimmed) + { + this.context.setTransform(displayObject.worldTransform[0], displayObject.worldTransform[3], displayObject.worldTransform[1], displayObject.worldTransform[4], displayObject.worldTransform[2] + displayObject.texture.trim.x, displayObject.worldTransform[5] + displayObject.texture.trim.y); + } + else + { + this.context.setTransform(displayObject.worldTransform[0], displayObject.worldTransform[3], displayObject.worldTransform[1], displayObject.worldTransform[4], displayObject.worldTransform[2], displayObject.worldTransform[5]); + } + + this.context.drawImage( + displayObject.texture.baseTexture.source, + displayObject.texture.frame.x, + displayObject.texture.frame.y, + displayObject.texture.frame.width, + displayObject.texture.frame.height, + (displayObject.anchor.x) * -displayObject.texture.frame.width, + (displayObject.anchor.y) * -displayObject.texture.frame.height, + displayObject.texture.frame.width, + displayObject.texture.frame.height); + } + } + else if (displayObject instanceof PIXI.Strip) + { + this.context.setTransform(displayObject.worldTransform[0], displayObject.worldTransform[3], displayObject.worldTransform[1], displayObject.worldTransform[4], displayObject.worldTransform[2], displayObject.worldTransform[5]) + this.renderStrip(displayObject); + } + else if (displayObject instanceof PIXI.TilingSprite) + { + this.context.setTransform(displayObject.worldTransform[0], displayObject.worldTransform[3], displayObject.worldTransform[1], displayObject.worldTransform[4], displayObject.worldTransform[2], displayObject.worldTransform[5]) + this.renderTilingSprite(displayObject); + } + else if (displayObject instanceof PIXI.CustomRenderable) + { + displayObject.renderCanvas(this); + } + else if (displayObject instanceof PIXI.Graphics) + { + this.context.setTransform(displayObject.worldTransform[0], displayObject.worldTransform[3], displayObject.worldTransform[1], displayObject.worldTransform[4], displayObject.worldTransform[2], displayObject.worldTransform[5]) + PIXI.CanvasGraphics.renderGraphics(displayObject, this.context); + } + else if (displayObject instanceof PIXI.FilterBlock) + { + if (displayObject.open) + { + this.context.save(); + + var cacheAlpha = displayObject.mask.alpha; + var maskTransform = displayObject.mask.worldTransform; + + this.context.setTransform(maskTransform[0], maskTransform[3], maskTransform[1], maskTransform[4], maskTransform[2], maskTransform[5]) + + displayObject.mask.worldAlpha = 0.5; + + this.context.worldAlpha = 0; + + PIXI.CanvasGraphics.renderGraphicsMask(displayObject.mask, this.context); + this.context.clip(); + + displayObject.mask.worldAlpha = cacheAlpha; + } + else + { + this.context.restore(); + } + } + // count++ + displayObject = displayObject._iNext; + } + while(displayObject != testObject) + } PIXI.WebGLBatch.prototype.update = function() { - var gl = this.gl; - var worldTransform, width, height, aX, aY, w0, w1, h0, h1, index, index2, index3 + // var gl = this.gl; + // var worldTransform, width, height, aX, aY, w0, w1, h0, h1, index, index2, index3 - var a, b, c, d, tx, ty; + var worldTransform, width, height, aX, aY, w0, w1, h0, h1, index; - var indexRun = 0; + var a, b, c, d, tx, ty; - var displayObject = this.head; + var indexRun = 0; - while(displayObject) - { - if(displayObject.vcount === PIXI.visibleCount) - { - width = displayObject.texture.frame.width; - height = displayObject.texture.frame.height; + var displayObject = this.head; - // TODO trim?? - aX = displayObject.anchor.x;// - displayObject.texture.trim.x - aY = displayObject.anchor.y; //- displayObject.texture.trim.y - w0 = width * (1-aX); - w1 = width * -aX; + while(displayObject) + { + if(displayObject.vcount === PIXI.visibleCount) + { + width = displayObject.texture.frame.width; + height = displayObject.texture.frame.height; - h0 = height * (1-aY); - h1 = height * -aY; + // TODO trim?? + aX = displayObject.anchor.x;// - displayObject.texture.trim.x + aY = displayObject.anchor.y; //- displayObject.texture.trim.y + w0 = width * (1-aX); + w1 = width * -aX; - index = indexRun * 8; + h0 = height * (1-aY); + h1 = height * -aY; - worldTransform = displayObject.worldTransform; + index = indexRun * 8; - a = worldTransform[0]; - b = worldTransform[3]; - c = worldTransform[1]; - d = worldTransform[4]; - tx = worldTransform[2]; - ty = worldTransform[5]; + worldTransform = displayObject.worldTransform; - if (displayObject.texture.trimmed) - { - tx += displayObject.texture.trim.x; - ty += displayObject.texture.trim.y; - } + a = worldTransform[0]; + b = worldTransform[3]; + c = worldTransform[1]; + d = worldTransform[4]; + tx = worldTransform[2]; + ty = worldTransform[5]; - this.verticies[index + 0 ] = a * w1 + c * h1 + tx; - this.verticies[index + 1 ] = d * h1 + b * w1 + ty; + if (displayObject.texture.trimmed) + { + tx += displayObject.texture.trim.x; + ty += displayObject.texture.trim.y; + } - this.verticies[index + 2 ] = a * w0 + c * h1 + tx; - this.verticies[index + 3 ] = d * h1 + b * w0 + ty; + this.verticies[index + 0 ] = a * w1 + c * h1 + tx; + this.verticies[index + 1 ] = d * h1 + b * w1 + ty; - this.verticies[index + 4 ] = a * w0 + c * h0 + tx; - this.verticies[index + 5 ] = d * h0 + b * w0 + ty; + this.verticies[index + 2 ] = a * w0 + c * h1 + tx; + this.verticies[index + 3 ] = d * h1 + b * w0 + ty; - this.verticies[index + 6] = a * w1 + c * h0 + tx; - this.verticies[index + 7] = d * h0 + b * w1 + ty; + this.verticies[index + 4 ] = a * w0 + c * h0 + tx; + this.verticies[index + 5 ] = d * h0 + b * w0 + ty; - if(displayObject.updateFrame || displayObject.texture.updateFrame) - { - this.dirtyUVS = true; + this.verticies[index + 6] = a * w1 + c * h0 + tx; + this.verticies[index + 7] = d * h0 + b * w1 + ty; - var texture = displayObject.texture; + if(displayObject.updateFrame || displayObject.texture.updateFrame) + { + this.dirtyUVS = true; - var frame = texture.frame; - var tw = texture.baseTexture.width; - var th = texture.baseTexture.height; + var texture = displayObject.texture; - this.uvs[index + 0] = frame.x / tw; - this.uvs[index +1] = frame.y / th; + var frame = texture.frame; + var tw = texture.baseTexture.width; + var th = texture.baseTexture.height; - this.uvs[index +2] = (frame.x + frame.width) / tw; - this.uvs[index +3] = frame.y / th; + this.uvs[index + 0] = frame.x / tw; + this.uvs[index +1] = frame.y / th; - this.uvs[index +4] = (frame.x + frame.width) / tw; - this.uvs[index +5] = (frame.y + frame.height) / th; + this.uvs[index +2] = (frame.x + frame.width) / tw; + this.uvs[index +3] = frame.y / th; - this.uvs[index +6] = frame.x / tw; - this.uvs[index +7] = (frame.y + frame.height) / th; + this.uvs[index +4] = (frame.x + frame.width) / tw; + this.uvs[index +5] = (frame.y + frame.height) / th; - displayObject.updateFrame = false; - } + this.uvs[index +6] = frame.x / tw; + this.uvs[index +7] = (frame.y + frame.height) / th; - // TODO this probably could do with some optimisation.... - if(displayObject.cacheAlpha != displayObject.worldAlpha) - { - displayObject.cacheAlpha = displayObject.worldAlpha; + displayObject.updateFrame = false; + } - var colorIndex = indexRun * 4; - this.colors[colorIndex] = this.colors[colorIndex + 1] = this.colors[colorIndex + 2] = this.colors[colorIndex + 3] = displayObject.worldAlpha; - this.dirtyColors = true; - } - } - else - { - index = indexRun * 8; + // TODO this probably could do with some optimisation.... + if(displayObject.cacheAlpha != displayObject.worldAlpha) + { + displayObject.cacheAlpha = displayObject.worldAlpha; - this.verticies[index + 0 ] = 0; - this.verticies[index + 1 ] = 0; + var colorIndex = indexRun * 4; + this.colors[colorIndex] = this.colors[colorIndex + 1] = this.colors[colorIndex + 2] = this.colors[colorIndex + 3] = displayObject.worldAlpha; + this.dirtyColors = true; + } + } + else + { + index = indexRun * 8; - this.verticies[index + 2 ] = 0; - this.verticies[index + 3 ] = 0; + this.verticies[index + 0 ] = 0; + this.verticies[index + 1 ] = 0; - this.verticies[index + 4 ] = 0; - this.verticies[index + 5 ] = 0; + this.verticies[index + 2 ] = 0; + this.verticies[index + 3 ] = 0; - this.verticies[index + 6] = 0; - this.verticies[index + 7] = 0; - } + this.verticies[index + 4 ] = 0; + this.verticies[index + 5 ] = 0; - indexRun++; - displayObject = displayObject.__next; - } + this.verticies[index + 6] = 0; + this.verticies[index + 7] = 0; + } + + indexRun++; + displayObject = displayObject.__next; + } } return Phaser; }); \ No newline at end of file diff --git a/build/phaser.min.js b/build/phaser.min.js index 3c7912646..7500c959b 100644 --- a/build/phaser.min.js +++ b/build/phaser.min.js @@ -1,12 +1,12 @@ /*! Phaser v1.1.3 | (c) 2013 Photon Storm Ltd. */ -!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.Phaser=b()}(this,function(){function b(a){return[(255&a>>16)/255,(255&a>>8)/255,(255&a)/255]}function c(){return d.Matrix="undefined"!=typeof Float32Array?Float32Array:Array,d.Matrix}function b(a){return[(255&a>>16)/255,(255&a>>8)/255,(255&a)/255]}var d=d||{},e=e||{VERSION:"1.1.3",DEV_VERSION:"1.1.3",GAMES:[],AUTO:0,CANVAS:1,WEBGL:2,SPRITE:0,BUTTON:1,BULLET:2,GRAPHICS:3,TEXT:4,TILESPRITE:5,BITMAPTEXT:6,GROUP:7,RENDERTEXTURE:8,TILEMAP:9,TILEMAPLAYER:10,EMITTER:11,POLYGON:12,BITMAPDATA:13,NONE:0,LEFT:1,RIGHT:2,UP:3,DOWN:4};d.InteractionManager=function(){},e.Utils={shuffle:function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},pad:function(a,b,c,d){if("undefined"==typeof b)var b=0;if("undefined"==typeof c)var c=" ";if("undefined"==typeof d)var d=3;if(b+1>=a.length)switch(d){case 1:a=Array(b+1-a.length).join(c)+a;break;case 3:var e=Math.ceil((padlen=b-a.length)/2),f=padlen-e;a=Array(f+1).join(c)+a+Array(e+1).join(c);break;default:a+=Array(b+1-a.length).join(c)}return a},isPlainObject:function(a){if("object"!=typeof a||a.nodeType||a===a.window)return!1;try{if(a.constructor&&!hasOwn.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(b){return!1}return!0},extend:function(){var a,b,c,d,f,g,h=arguments[0]||{},i=1,j=arguments.length,k=!1;for("boolean"==typeof h&&(k=h,h=arguments[1]||{},i=2),j===i&&(h=this,--i);j>i;i++)if(null!=(a=arguments[i]))for(b in a)c=h[b],d=a[b],h!==d&&(k&&d&&(e.Utils.isPlainObject(d)||(f=Array.isArray(d)))?(f?(f=!1,g=c&&Array.isArray(c)?c:[]):g=c&&e.Utils.isPlainObject(c)?c:{},h[b]=e.Utils.extend(k,g,d)):void 0!==d&&(h[b]=d));return h}},"function"!=typeof Function.prototype.bind&&(Function.prototype.bind=function(){var a=Array.prototype.slice;return function(b){function c(){var f=e.concat(a.call(arguments));d.apply(this instanceof c?this:b,f)}var d=this,e=a.call(arguments,1);if("function"!=typeof d)throw new TypeError;return c.prototype=function f(a){return a&&(f.prototype=a),this instanceof f?void 0:new f}(d.prototype),c}}()),c(),d.mat3={},d.mat3.create=function(){var a=new d.Matrix(9);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},d.mat3.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},d.mat4={},d.mat4.create=function(){var a=new d.Matrix(16);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},d.mat3.multiply=function(a,b,c){c||(c=a);var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=a[6],k=a[7],l=a[8],m=b[0],n=b[1],o=b[2],p=b[3],q=b[4],r=b[5],s=b[6],t=b[7],u=b[8];return c[0]=m*d+n*g+o*j,c[1]=m*e+n*h+o*k,c[2]=m*f+n*i+o*l,c[3]=p*d+q*g+r*j,c[4]=p*e+q*h+r*k,c[5]=p*f+q*i+r*l,c[6]=s*d+t*g+u*j,c[7]=s*e+t*h+u*k,c[8]=s*f+t*i+u*l,c},d.mat3.clone=function(a){var b=new d.Matrix(9);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b},d.mat3.transpose=function(a,b){if(!b||a===b){var c=a[1],d=a[2],e=a[5];return a[1]=a[3],a[2]=a[6],a[3]=c,a[5]=a[7],a[6]=d,a[7]=e,a}return b[0]=a[0],b[1]=a[3],b[2]=a[6],b[3]=a[1],b[4]=a[4],b[5]=a[7],b[6]=a[2],b[7]=a[5],b[8]=a[8],b},d.mat3.toMat4=function(a,b){return b||(b=d.mat4.create()),b[15]=1,b[14]=0,b[13]=0,b[12]=0,b[11]=0,b[10]=a[8],b[9]=a[7],b[8]=a[6],b[7]=0,b[6]=a[5],b[5]=a[4],b[4]=a[3],b[3]=0,b[2]=a[2],b[1]=a[1],b[0]=a[0],b},d.mat4.create=function(){var a=new d.Matrix(16);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},d.mat4.transpose=function(a,b){if(!b||a===b){var c=a[1],d=a[2],e=a[3],f=a[6],g=a[7],h=a[11];return a[1]=a[4],a[2]=a[8],a[3]=a[12],a[4]=c,a[6]=a[9],a[7]=a[13],a[8]=d,a[9]=f,a[11]=a[14],a[12]=e,a[13]=g,a[14]=h,a}return b[0]=a[0],b[1]=a[4],b[2]=a[8],b[3]=a[12],b[4]=a[1],b[5]=a[5],b[6]=a[9],b[7]=a[13],b[8]=a[2],b[9]=a[6],b[10]=a[10],b[11]=a[14],b[12]=a[3],b[13]=a[7],b[14]=a[11],b[15]=a[15],b},d.mat4.multiply=function(a,b,c){c||(c=a);var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=a[6],k=a[7],l=a[8],m=a[9],n=a[10],o=a[11],p=a[12],q=a[13],r=a[14],s=a[15],t=b[0],u=b[1],v=b[2],w=b[3];return c[0]=t*d+u*h+v*l+w*p,c[1]=t*e+u*i+v*m+w*q,c[2]=t*f+u*j+v*n+w*r,c[3]=t*g+u*k+v*o+w*s,t=b[4],u=b[5],v=b[6],w=b[7],c[4]=t*d+u*h+v*l+w*p,c[5]=t*e+u*i+v*m+w*q,c[6]=t*f+u*j+v*n+w*r,c[7]=t*g+u*k+v*o+w*s,t=b[8],u=b[9],v=b[10],w=b[11],c[8]=t*d+u*h+v*l+w*p,c[9]=t*e+u*i+v*m+w*q,c[10]=t*f+u*j+v*n+w*r,c[11]=t*g+u*k+v*o+w*s,t=b[12],u=b[13],v=b[14],w=b[15],c[12]=t*d+u*h+v*l+w*p,c[13]=t*e+u*i+v*m+w*q,c[14]=t*f+u*j+v*n+w*r,c[15]=t*g+u*k+v*o+w*s,c},d.Point=function(a,b){this.x=a||0,this.y=b||0},d.Point.prototype.clone=function(){return new d.Point(this.x,this.y)},d.Point.prototype.constructor=d.Point,d.Rectangle=function(a,b,c,d){this.x=a||0,this.y=b||0,this.width=c||0,this.height=d||0},d.Rectangle.prototype.clone=function(){return new d.Rectangle(this.x,this.y,this.width,this.height)},d.Rectangle.prototype.contains=function(a,b){if(this.width<=0||this.height<=0)return!1;var c=this.x;if(a>=c&&a<=c+this.width){var d=this.y;if(b>=d&&b<=d+this.height)return!0}return!1},d.Rectangle.prototype.constructor=d.Rectangle,d.Polygon=function(a){if(a instanceof Array||(a=Array.prototype.slice.call(arguments)),"number"==typeof a[0]){for(var b=[],c=0,e=a.length;e>c;c+=2)b.push(new d.Point(a[c],a[c+1]));a=b}this.points=a},d.Polygon.prototype.clone=function(){for(var a=[],b=0;bb!=i>b&&(h-f)*(b-g)/(i-g)+f>a;j&&(c=!c)}return c},d.Polygon.prototype.constructor=d.Polygon,d.DisplayObject=function(){this.last=this,this.first=this,this.position=new d.Point,this.scale=new d.Point(1,1),this.pivot=new d.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.hitArea=null,this.buttonMode=!1,this.renderable=!1,this.parent=null,this.stage=null,this.worldAlpha=1,this._interactive=!1,this.worldTransform=d.mat3.create(),this.localTransform=d.mat3.create(),this.color=[],this.dynamic=!0,this._sr=0,this._cr=1,this.filterArea=new d.Rectangle(0,0,1,1)},d.DisplayObject.prototype.constructor=d.DisplayObject,d.DisplayObject.prototype.setInteractive=function(a){this.interactive=a},Object.defineProperty(d.DisplayObject.prototype,"interactive",{get:function(){return this._interactive},set:function(a){this._interactive=a,this.stage&&(this.stage.dirty=!0)}}),Object.defineProperty(d.DisplayObject.prototype,"mask",{get:function(){return this._mask},set:function(a){a?this._mask?(a.start=this._mask.start,a.end=this._mask.end):(this.addFilter(a),a.renderable=!1):(this.removeFilter(this._mask),this._mask.renderable=!0),this._mask=a}}),Object.defineProperty(d.DisplayObject.prototype,"filters",{get:function(){return this._filters},set:function(a){if(a){this._filters&&this.removeFilter(this._filters),this.addFilter(a);for(var b=[],c=0;c=0&&b<=this.children.length))throw new Error(a+" The index "+b+" supplied is out of bounds "+this.children.length);if(void 0!=a.parent&&a.parent.removeChild(a),a.parent=this,this.stage){var c=a;do c.interactive&&(this.stage.dirty=!0),c.stage=this.stage,c=c._iNext;while(c)}var d,e,f=a.first,g=a.last;if(b==this.children.length){e=this.last;for(var h=this,i=this.last;h;)h.last==i&&(h.last=a.last),h=h.parent}else e=0==b?this:this.children[b-1].last;d=e._iNext,d&&(d._iPrev=g,g._iNext=d),f._iPrev=e,e._iNext=f,this.children.splice(b,0,a),this.__renderGroup&&(a.__renderGroup&&a.__renderGroup.removeDisplayObjectAndChildren(a),this.__renderGroup.addDisplayObjectAndChildren(a))},d.DisplayObjectContainer.prototype.swapChildren=function(){},d.DisplayObjectContainer.prototype.getChildAt=function(a){if(a>=0&&aa;a++)this.children[a].updateTransform()}},d.blendModes={},d.blendModes.NORMAL=0,d.blendModes.SCREEN=1,d.Sprite=function(a){d.DisplayObjectContainer.call(this),this.anchor=new d.Point,this.texture=a,this.blendMode=d.blendModes.NORMAL,this._width=0,this._height=0,a.baseTexture.hasLoaded?this.updateFrame=!0:(this.onTextureUpdateBind=this.onTextureUpdate.bind(this),this.texture.addEventListener("update",this.onTextureUpdateBind)),this.renderable=!0},d.Sprite.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Sprite.prototype.constructor=d.Sprite,Object.defineProperty(d.Sprite.prototype,"width",{get:function(){return this.scale.x*this.texture.frame.width},set:function(a){this.scale.x=a/this.texture.frame.width,this._width=a}}),Object.defineProperty(d.Sprite.prototype,"height",{get:function(){return this.scale.y*this.texture.frame.height},set:function(a){this.scale.y=a/this.texture.frame.height,this._height=a}}),d.Sprite.prototype.setTexture=function(a){this.texture.baseTexture!=a.baseTexture?(this.textureChange=!0,this.texture=a,this.__renderGroup&&this.__renderGroup.updateTexture(this)):this.texture=a,this.updateFrame=!0},d.Sprite.prototype.onTextureUpdate=function(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height),this.updateFrame=!0},d.Sprite.fromFrame=function(a){var b=d.TextureCache[a];if(!b)throw new Error("The frameId '"+a+"' does not exist in the texture cache"+this);return new d.Sprite(b)},d.Sprite.fromImage=function(a){var b=d.Texture.fromImage(a);return new d.Sprite(b)},d.Stage=function(a){d.DisplayObjectContainer.call(this),this.worldTransform=d.mat3.create(),this.interactive=!0,this.interactionManager=new d.InteractionManager(this),this.dirty=!0,this.__childrenAdded=[],this.__childrenRemoved=[],this.stage=this,this.stage.hitArea=new d.Rectangle(0,0,1e5,1e5),this.setBackgroundColor(a),this.worldVisible=!0},d.Stage.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Stage.prototype.constructor=d.Stage,d.Stage.prototype.setInteractionDelegate=function(a){this.interactionManager.setTargetDomElement(a)},d.Stage.prototype.updateTransform=function(){this.worldAlpha=1,this.vcount=d.visibleCount;for(var a=0,b=this.children.length;b>a;a++)this.children[a].updateTransform();this.dirty&&(this.dirty=!1,this.interactionManager.dirty=!0),this.interactive&&this.interactionManager.update()},d.Stage.prototype.setBackgroundColor=function(a){this.backgroundColor=a||0,this.backgroundColorSplit=b(this.backgroundColor);var c=this.backgroundColor.toString(16);c="000000".substr(0,6-c.length)+c,this.backgroundColorString="#"+c},d.Stage.prototype.getMousePosition=function(){return this.interactionManager.mouse.global},d.CustomRenderable=function(){d.DisplayObject.call(this),this.renderable=!0},d.CustomRenderable.prototype=Object.create(d.DisplayObject.prototype),d.CustomRenderable.prototype.constructor=d.CustomRenderable,d.CustomRenderable.prototype.renderCanvas=function(){},d.CustomRenderable.prototype.initWebGL=function(){},d.CustomRenderable.prototype.renderWebGL=function(){},d.Strip=function(a,b,c){d.DisplayObjectContainer.call(this),this.texture=a,this.blendMode=d.blendModes.NORMAL;try{this.uvs=new Float32Array([0,1,1,1,1,0,0,1]),this.verticies=new Float32Array([0,0,0,0,0,0,0,0,0]),this.colors=new Float32Array([1,1,1,1]),this.indices=new Uint16Array([0,1,2,3])}catch(e){this.uvs=[0,1,1,1,1,0,0,1],this.verticies=[0,0,0,0,0,0,0,0,0],this.colors=[1,1,1,1],this.indices=[0,1,2,3]}this.width=b,this.height=c,a.baseTexture.hasLoaded?(this.width=this.texture.frame.width,this.height=this.texture.frame.height,this.updateFrame=!0):(this.onTextureUpdateBind=this.onTextureUpdate.bind(this),this.texture.addEventListener("update",this.onTextureUpdateBind)),this.renderable=!0},d.Strip.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Strip.prototype.constructor=d.Strip,d.Strip.prototype.setTexture=function(a){this.texture=a,this.width=a.frame.width,this.height=a.frame.height,this.updateFrame=!0},d.Strip.prototype.onTextureUpdate=function(){this.updateFrame=!0},d.Rope=function(a,b){d.Strip.call(this,a),this.points=b;try{this.verticies=new Float32Array(4*b.length),this.uvs=new Float32Array(4*b.length),this.colors=new Float32Array(2*b.length),this.indices=new Uint16Array(2*b.length)}catch(c){this.verticies=verticies,this.uvs=uvs,this.colors=colors,this.indices=indices}this.refresh()},d.Rope.prototype=Object.create(d.Strip.prototype),d.Rope.prototype.constructor=d.Rope,d.Rope.prototype.refresh=function(){var a=this.points;if(!(a.length<1)){var b=this.uvs,c=this.indices,d=this.colors,e=a[0],f=a[0];this.count-=.2,b[0]=0,b[1]=1,b[2]=0,b[3]=1,d[0]=1,d[1]=1,c[0]=0,c[1]=1;for(var g=a.length,h=1;g>h;h++){var f=a[h],i=4*h,j=h/(g-1);h%2?(b[i]=j,b[i+1]=0,b[i+2]=j,b[i+3]=1):(b[i]=j,b[i+1]=0,b[i+2]=j,b[i+3]=1),i=2*h,d[i]=1,d[i+1]=1,i=2*h,c[i]=i,c[i+1]=i+1,e=f}}},d.Rope.prototype.updateTransform=function(){var a=this.points;if(!(a.length<1)){var b,c=this.verticies,e=a[0],f={x:0,y:0},g=a[0];this.count-=.2,c[0]=g.x+f.x,c[1]=g.y+f.y,c[2]=g.x-f.x,c[3]=g.y-f.y;for(var h=a.length,i=1;h>i;i++){var g=a[i],j=4*i;b=i1&&(k=1);var l=Math.sqrt(f.x*f.x+f.y*f.y),m=this.texture.height/2;f.x/=l,f.y/=l,f.x*=m,f.y*=m,c[j]=g.x+f.x,c[j+1]=g.y+f.y,c[j+2]=g.x-f.x,c[j+3]=g.y-f.y,e=g}d.DisplayObjectContainer.prototype.updateTransform.call(this)}},d.Rope.prototype.setTexture=function(a){this.texture=a,this.updateFrame=!0},d.TilingSprite=function(a,b,c){d.DisplayObjectContainer.call(this),this.texture=a,this.width=b,this.height=c,this.tileScale=new d.Point(1,1),this.tilePosition=new d.Point(0,0),this.renderable=!0,this.blendMode=d.blendModes.NORMAL},d.TilingSprite.prototype=Object.create(d.DisplayObjectContainer.prototype),d.TilingSprite.prototype.constructor=d.TilingSprite,d.TilingSprite.prototype.setTexture=function(a){this.texture=a,this.updateFrame=!0},d.TilingSprite.prototype.onTextureUpdate=function(){this.updateFrame=!0},d.AbstractFilter=function(a,b){this.passes=[this],this.dirty=!0,this.padding=0,this.uniforms=b||{},this.fragmentSrc=a||[]},d.BlurFilter=function(){this.blurXFilter=new d.BlurXFilter,this.blurYFilter=new d.BlurYFilter,this.passes=[this.blurXFilter,this.blurYFilter]},Object.defineProperty(d.BlurFilter.prototype,"blur",{get:function(){return this.blurXFilter.blur},set:function(a){this.blurXFilter.blur=this.blurYFilter.blur=a}}),Object.defineProperty(d.BlurFilter.prototype,"blurX",{get:function(){return this.blurXFilter.blur},set:function(a){this.blurXFilter.blur=a}}),Object.defineProperty(d.BlurFilter.prototype,"blurY",{get:function(){return this.blurYFilter.blur},set:function(a){this.blurYFilter.blur=a}}),d.BlurXFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {","vec4 sum = vec4(0.0);","sum += texture2D(uSampler, vec2(vTextureCoord.x - 4.0*blur, vTextureCoord.y)) * 0.05;","sum += texture2D(uSampler, vec2(vTextureCoord.x - 3.0*blur, vTextureCoord.y)) * 0.09;","sum += texture2D(uSampler, vec2(vTextureCoord.x - 2.0*blur, vTextureCoord.y)) * 0.12;","sum += texture2D(uSampler, vec2(vTextureCoord.x - blur, vTextureCoord.y)) * 0.15;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;","sum += texture2D(uSampler, vec2(vTextureCoord.x + blur, vTextureCoord.y)) * 0.15;","sum += texture2D(uSampler, vec2(vTextureCoord.x + 2.0*blur, vTextureCoord.y)) * 0.12;","sum += texture2D(uSampler, vec2(vTextureCoord.x + 3.0*blur, vTextureCoord.y)) * 0.09;","sum += texture2D(uSampler, vec2(vTextureCoord.x + 4.0*blur, vTextureCoord.y)) * 0.05;","gl_FragColor = sum;","}"]},d.BlurXFilter.prototype=Object.create(d.AbstractFilter.prototype),d.BlurXFilter.prototype.constructor=d.BlurXFilter,Object.defineProperty(d.BlurXFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.dirty=!0,this.uniforms.blur.value=1/7e3*a}}),d.BlurYFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {","vec4 sum = vec4(0.0);","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 4.0*blur)) * 0.05;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 3.0*blur)) * 0.09;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 2.0*blur)) * 0.12;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - blur)) * 0.15;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + blur)) * 0.15;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 2.0*blur)) * 0.12;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 3.0*blur)) * 0.09;","sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 4.0*blur)) * 0.05;","gl_FragColor = sum;","}"]},d.BlurYFilter.prototype=Object.create(d.AbstractFilter.prototype),d.BlurYFilter.prototype.constructor=d.BlurYFilter,Object.defineProperty(d.BlurYFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.uniforms.blur.value=1/7e3*a}}),d.ColorMatrixFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={matrix:{type:"mat4",value:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float invert;","uniform mat4 matrix;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vTextureCoord) * matrix;","gl_FragColor = gl_FragColor * vColor;","}"]},d.ColorMatrixFilter.prototype=Object.create(d.AbstractFilter.prototype),d.ColorMatrixFilter.prototype.constructor=d.ColorMatrixFilter,Object.defineProperty(d.ColorMatrixFilter.prototype,"matrix",{get:function(){return this.uniforms.matrix.value},set:function(a){this.uniforms.matrix.value=a}}),d.CrossHatchFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {"," float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb);"," "," gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);"," "," if (lum < 1.00) {"," if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," "," if (lum < 0.75) {"," if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," "," if (lum < 0.50) {"," if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," "," if (lum < 0.3) {"," if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }","}"]},d.CrossHatchFilter.prototype=Object.create(d.AbstractFilter.prototype),d.CrossHatchFilter.prototype.constructor=d.BlurYFilter,Object.defineProperty(d.CrossHatchFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.uniforms.blur.value=1/7e3*a}}),d.DisplacementFilter=function(a){d.AbstractFilter.call(this),this.passes=[this],a.baseTexture._powerOf2=!0,this.uniforms={displacementMap:{type:"sampler2D",value:a},scale:{type:"f2",value:{x:30,y:30}},offset:{type:"f2",value:{x:0,y:0}},mapDimensions:{type:"f2",value:{x:1,y:5112}},dimensions:{type:"f4",value:[0,0,0,0]}},a.baseTexture.hasLoaded?(this.uniforms.mapDimensions.value.x=a.width,this.uniforms.mapDimensions.value.y=a.height):(this.boundLoadedFunction=this.onTextureLoaded.bind(this),a.baseTexture.on("loaded",this.boundLoadedFunction)),this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D displacementMap;","uniform sampler2D uSampler;","uniform vec2 scale;","uniform vec2 offset;","uniform vec4 dimensions;","uniform vec2 mapDimensions;","void main(void) {","vec2 mapCords = vTextureCoord.xy;","mapCords += (dimensions.zw + offset)/ dimensions.xy ;","mapCords.y *= -1.0;","mapCords.y += 1.0;","vec2 matSample = texture2D(displacementMap, mapCords).xy;","matSample -= 0.5;","matSample *= scale;","matSample /= mapDimensions;","gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x + matSample.x, vTextureCoord.y + matSample.y));","gl_FragColor.rgb = mix( gl_FragColor.rgb, gl_FragColor.rgb, 1.0);","vec2 cord = vTextureCoord;","gl_FragColor = gl_FragColor * vColor;","}"]},d.DisplacementFilter.prototype=Object.create(d.AbstractFilter.prototype),d.DisplacementFilter.prototype.constructor=d.DisplacementFilter,d.DisplacementFilter.prototype.onTextureLoaded=function(){this.uniforms.mapDimensions.value.x=this.uniforms.displacementMap.value.width,this.uniforms.mapDimensions.value.y=this.uniforms.displacementMap.value.height,this.uniforms.displacementMap.value.baseTexture.off("loaded",this.boundLoadedFunction)},Object.defineProperty(d.DisplacementFilter.prototype,"map",{get:function(){return this.uniforms.displacementMap.value},set:function(a){this.uniforms.displacementMap.value=a}}),Object.defineProperty(d.DisplacementFilter.prototype,"scale",{get:function(){return this.uniforms.scale.value},set:function(a){this.uniforms.scale.value=a}}),Object.defineProperty(d.DisplacementFilter.prototype,"offset",{get:function(){return this.uniforms.offset.value},set:function(a){this.uniforms.offset.value=a}}),d.DotScreenFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={scale:{type:"f",value:1},angle:{type:"f",value:5},dimensions:{type:"f4",value:[0,0,0,0]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform vec4 dimensions;","uniform sampler2D uSampler;","uniform float angle;","uniform float scale;","float pattern() {","float s = sin(angle), c = cos(angle);","vec2 tex = vTextureCoord * dimensions.xy;","vec2 point = vec2(","c * tex.x - s * tex.y,","s * tex.x + c * tex.y",") * scale;","return (sin(point.x) * sin(point.y)) * 4.0;","}","void main() {","vec4 color = texture2D(uSampler, vTextureCoord);","float average = (color.r + color.g + color.b) / 3.0;","gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a);","}"]},d.DotScreenFilter.prototype=Object.create(d.DotScreenFilter.prototype),d.DotScreenFilter.prototype.constructor=d.DotScreenFilter,Object.defineProperty(d.DotScreenFilter.prototype,"scale",{get:function(){return this.uniforms.scale.value},set:function(a){this.dirty=!0,this.uniforms.scale.value=a}}),Object.defineProperty(d.DotScreenFilter.prototype,"angle",{get:function(){return this.uniforms.angle.value},set:function(a){this.dirty=!0,this.uniforms.angle.value=a}}),d.FilterBlock=function(){this.visible=!0,this.renderable=!0},d.GreyFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={grey:{type:"f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","uniform float grey;","void main(void) {","gl_FragColor = texture2D(uSampler, vTextureCoord);","gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2126*gl_FragColor.r + 0.7152*gl_FragColor.g + 0.0722*gl_FragColor.b), grey);","gl_FragColor = gl_FragColor * vColor;","}"]},d.GreyFilter.prototype=Object.create(d.AbstractFilter.prototype),d.GreyFilter.prototype.constructor=d.GreyFilter,Object.defineProperty(d.GreyFilter.prototype,"grey",{get:function(){return this.uniforms.grey.value},set:function(a){this.uniforms.grey.value=a}}),d.InvertFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={invert:{type:"f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float invert;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vTextureCoord);","gl_FragColor.rgb = mix( (vec3(1)-gl_FragColor.rgb) * gl_FragColor.a, gl_FragColor.rgb, 1.0 - invert);","gl_FragColor = gl_FragColor * vColor;","}"]},d.InvertFilter.prototype=Object.create(d.AbstractFilter.prototype),d.InvertFilter.prototype.constructor=d.InvertFilter,Object.defineProperty(d.InvertFilter.prototype,"invert",{get:function(){return this.uniforms.invert.value},set:function(a){this.uniforms.invert.value=a}}),d.PixelateFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={invert:{type:"f",value:0},dimensions:{type:"f4",value:new Float32Array([1e4,100,10,10])},pixelSize:{type:"f2",value:{x:10,y:10}}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform vec2 testDim;","uniform vec4 dimensions;","uniform vec2 pixelSize;","uniform sampler2D uSampler;","void main(void) {","vec2 coord = vTextureCoord;","vec2 size = dimensions.xy/pixelSize;","vec2 color = floor( ( vTextureCoord * size ) ) / size + pixelSize/dimensions.xy * 0.5;","gl_FragColor = texture2D(uSampler, color);","}"]},d.PixelateFilter.prototype=Object.create(d.AbstractFilter.prototype),d.PixelateFilter.prototype.constructor=d.PixelateFilter,Object.defineProperty(d.PixelateFilter.prototype,"size",{get:function(){return this.uniforms.pixelSize.value},set:function(a){this.dirty=!0,this.uniforms.pixelSize.value=a}}),d.RGBSplitFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={red:{type:"f2",value:{x:20,y:20}},green:{type:"f2",value:{x:-20,y:20}},blue:{type:"f2",value:{x:20,y:-20}},dimensions:{type:"f4",value:[0,0,0,0]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform vec2 red;","uniform vec2 green;","uniform vec2 blue;","uniform vec4 dimensions;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/dimensions.xy).r;","gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/dimensions.xy).g;","gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/dimensions.xy).b;","gl_FragColor.a = texture2D(uSampler, vTextureCoord).a;","}"]},d.RGBSplitFilter.prototype=Object.create(d.AbstractFilter.prototype),d.RGBSplitFilter.prototype.constructor=d.RGBSplitFilter,Object.defineProperty(d.RGBSplitFilter.prototype,"angle",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.uniforms.blur.value=1/7e3*a}}),d.SepiaFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={sepia:{type:"f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float sepia;","uniform sampler2D uSampler;","const mat3 sepiaMatrix = mat3(0.3588, 0.7044, 0.1368, 0.2990, 0.5870, 0.1140, 0.2392, 0.4696, 0.0912);","void main(void) {","gl_FragColor = texture2D(uSampler, vTextureCoord);","gl_FragColor.rgb = mix( gl_FragColor.rgb, gl_FragColor.rgb * sepiaMatrix, sepia);","gl_FragColor = gl_FragColor * vColor;","}"]},d.SepiaFilter.prototype=Object.create(d.AbstractFilter.prototype),d.SepiaFilter.prototype.constructor=d.SepiaFilter,Object.defineProperty(d.SepiaFilter.prototype,"sepia",{get:function(){return this.uniforms.sepia.value},set:function(a){this.uniforms.sepia.value=a}}),d.SmartBlurFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","uniform sampler2D uSampler;","const vec2 delta = vec2(1.0/10.0, 0.0);","float random(vec3 scale, float seed) {","return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);","}","void main(void) {","vec4 color = vec4(0.0);","float total = 0.0;","float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);","for (float t = -30.0; t <= 30.0; t++) {","float percent = (t + offset - 0.5) / 30.0;","float weight = 1.0 - abs(percent);","vec4 sample = texture2D(uSampler, vTextureCoord + delta * percent);","sample.rgb *= sample.a;","color += sample * weight;","total += weight;","}","gl_FragColor = color / total;","gl_FragColor.rgb /= gl_FragColor.a + 0.00001;","}"] -},d.SmartBlurFilter.prototype=Object.create(d.AbstractFilter.prototype),d.SmartBlurFilter.prototype.constructor=d.SmartBlurFilter,Object.defineProperty(d.SmartBlurFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value},set:function(a){this.uniforms.blur.value=a}}),d.TwistFilter=function(){d.AbstractFilter.call(this),this.passes=[this],this.uniforms={radius:{type:"f",value:.5},angle:{type:"f",value:5},offset:{type:"f2",value:{x:.5,y:.5}}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform vec4 dimensions;","uniform sampler2D uSampler;","uniform float radius;","uniform float angle;","uniform vec2 offset;","void main(void) {","vec2 coord = vTextureCoord - offset;","float distance = length(coord);","if (distance < radius){","float ratio = (radius - distance) / radius;","float angleMod = ratio * ratio * angle;","float s = sin(angleMod);","float c = cos(angleMod);","coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c);","}","gl_FragColor = texture2D(uSampler, coord+offset);","}"]},d.TwistFilter.prototype=Object.create(d.AbstractFilter.prototype),d.TwistFilter.prototype.constructor=d.TwistFilter,Object.defineProperty(d.TwistFilter.prototype,"offset",{get:function(){return this.uniforms.offset.value},set:function(a){this.dirty=!0,this.uniforms.offset.value=a}}),Object.defineProperty(d.TwistFilter.prototype,"radius",{get:function(){return this.uniforms.radius.value},set:function(a){this.dirty=!0,this.uniforms.radius.value=a}}),Object.defineProperty(d.TwistFilter.prototype,"angle",{get:function(){return this.uniforms.angle.value},set:function(a){this.dirty=!0,this.uniforms.angle.value=a}}),d.Graphics=function(){d.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor="black",this.graphicsData=[],this.currentPath={points:[]}},d.Graphics.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Graphics.prototype.constructor=d.Graphics,d.Graphics.prototype.lineStyle=function(a,b,c){0==this.currentPath.points.length&&this.graphicsData.pop(),this.lineWidth=a||0,this.lineColor=b||0,this.lineAlpha=void 0==c?1:c,this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:d.Graphics.POLY},this.graphicsData.push(this.currentPath)},d.Graphics.prototype.moveTo=function(a,b){0==this.currentPath.points.length&&this.graphicsData.pop(),this.currentPath=this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:d.Graphics.POLY},this.currentPath.points.push(a,b),this.graphicsData.push(this.currentPath)},d.Graphics.prototype.lineTo=function(a,b){this.currentPath.points.push(a,b),this.dirty=!0},d.Graphics.prototype.beginFill=function(a,b){this.filling=!0,this.fillColor=a||0,this.fillAlpha=void 0==b?1:b},d.Graphics.prototype.endFill=function(){this.filling=!1,this.fillColor=null,this.fillAlpha=1},d.Graphics.prototype.drawRect=function(a,b,c,e){0==this.currentPath.points.length&&this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[a,b,c,e],type:d.Graphics.RECT},this.graphicsData.push(this.currentPath),this.dirty=!0},d.Graphics.prototype.drawCircle=function(a,b,c){0==this.currentPath.points.length&&this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[a,b,c,c],type:d.Graphics.CIRC},this.graphicsData.push(this.currentPath),this.dirty=!0},d.Graphics.prototype.drawElipse=function(a,b,c,e){0==this.currentPath.points.length&&this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[a,b,c,e],type:d.Graphics.ELIP},this.graphicsData.push(this.currentPath),this.dirty=!0},d.Graphics.prototype.clear=function(){this.lineWidth=0,this.filling=!1,this.dirty=!0,this.clearDirty=!0,this.graphicsData=[],this.bounds=null},d.Graphics.prototype.updateFilterBounds=function(){if(!this.bounds){for(var a,b,c,e=1/0,f=-1/0,g=1/0,h=-1/0,i=0;ib?b:e,f=b+m>f?b+m:f,g=g>c?b:g,h=c+n>h?c+n:h}else if(k===d.Graphics.CIRC||k===d.Graphics.ELIP){b=a.x,c=a.y;var o=a.radius+l/2;e=e>b-o?b-o:e,f=b+o>f?b+o:f,g=g>c-o?c-o:g,h=c+o>h?c+o:h}else for(var p=0;pb-l?b-l:e,f=b+l>f?b+l:f,g=g>c-l?c-l:g,h=c+l>h?c+l:h}this.bounds=new d.Rectangle(e,g,f-e,h-g)}},d.Graphics.POLY=0,d.Graphics.RECT=1,d.Graphics.CIRC=2,d.Graphics.ELIP=3,d.CanvasGraphics=function(){},d.CanvasGraphics.renderGraphics=function(a,b){for(var c=a.worldAlpha,e=0;e1&&(c=1,console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object"));for(var e=0;1>e;e++){var f=a.graphicsData[e],g=f.points;if(f.type==d.Graphics.POLY){b.beginPath(),b.moveTo(g[0],g[1]);for(var h=1;h0&&(d.Texture.frameUpdates=[])},d.CanvasRenderer.prototype.resize=function(a,b){this.width=a,this.height=b,this.view.width=a,this.view.height=b},d.CanvasRenderer.prototype.renderDisplayObject=function(a){var b,c=this.context;c.globalCompositeOperation="source-over";var e=a.last._iNext;a=a.first;do if(b=a.worldTransform,a.visible)if(a.renderable){if(a instanceof d.Sprite){var f=a.texture.frame;f&&f.width&&f.height&&(c.globalAlpha=a.worldAlpha,c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),c.drawImage(a.texture.baseTexture.source,f.x,f.y,f.width,f.height,a.anchor.x*-f.width,a.anchor.y*-f.height,f.width,f.height))}else if(a instanceof d.Strip)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),this.renderStrip(a);else if(a instanceof d.TilingSprite)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),this.renderTilingSprite(a);else if(a instanceof d.CustomRenderable)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),a.renderCanvas(this);else if(a instanceof d.Graphics)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),d.CanvasGraphics.renderGraphics(a,c);else if(a instanceof d.FilterBlock&&a.data instanceof d.Graphics){var g=a.data;if(a.open){c.save();var h=g.alpha,i=g.worldTransform;c.setTransform(i[0],i[3],i[1],i[4],i[2],i[5]),g.worldAlpha=.5,c.worldAlpha=0,d.CanvasGraphics.renderGraphicsMask(g,c),c.clip(),g.worldAlpha=h}else c.restore()}a=a._iNext}else a=a._iNext;else a=a.last._iNext;while(a!=e)},d.CanvasRenderer.prototype.renderStripFlat=function(a){var b=this.context,c=a.verticies;a.uvs;var d=c.length/2;this.count++,b.beginPath();for(var e=1;d-2>e;e++){var f=2*e,g=c[f],h=c[f+2],i=c[f+4],j=c[f+1],k=c[f+3],l=c[f+5];b.moveTo(g,j),b.lineTo(h,k),b.lineTo(i,l)}b.fillStyle="#FF0000",b.fill(),b.closePath()},d.CanvasRenderer.prototype.renderTilingSprite=function(a){var b=this.context;b.globalAlpha=a.worldAlpha,a.__tilePattern||(a.__tilePattern=b.createPattern(a.texture.baseTexture.source,"repeat")),b.beginPath();var c=a.tilePosition,d=a.tileScale;b.scale(d.x,d.y),b.translate(c.x,c.y),b.fillStyle=a.__tilePattern,b.fillRect(-c.x,-c.y,a.width/d.x,a.height/d.y),b.scale(1/d.x,1/d.y),b.translate(-c.x,-c.y),b.closePath()},d.CanvasRenderer.prototype.renderStrip=function(a){var b=this.context,c=a.verticies,d=a.uvs,e=c.length/2;this.count++;for(var f=1;e-2>f;f++){var g=2*f,h=c[g],i=c[g+2],j=c[g+4],k=c[g+1],l=c[g+3],m=c[g+5],n=d[g]*a.texture.width,o=d[g+2]*a.texture.width,p=d[g+4]*a.texture.width,q=d[g+1]*a.texture.height,r=d[g+3]*a.texture.height,s=d[g+5]*a.texture.height;b.save(),b.beginPath(),b.moveTo(h,k),b.lineTo(i,l),b.lineTo(j,m),b.closePath(),b.clip();var t=n*r+q*p+o*s-r*p-q*o-n*s,u=h*r+q*j+i*s-r*j-q*i-h*s,v=n*i+h*p+o*j-i*p-h*o-n*j,w=n*r*j+q*i*p+h*o*s-h*r*p-q*o*j-n*i*s,x=k*r+q*m+l*s-r*m-q*l-k*s,y=n*l+k*p+o*m-l*p-k*o-n*m,z=n*r*m+q*l*p+k*o*s-k*r*p-q*o*m-n*l*s;b.transform(u/t,x/t,v/t,y/t,w/t,z/t),b.drawImage(a.texture.baseTexture.source,0,0),b.restore()}},d.PixiShader=function(){this.program,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;","}"]},d.PixiShader.prototype.init=function(){var a=d.compileProgram(this.vertexSrc||d.PixiShader.defaultVertexSrc,this.fragmentSrc),b=d.gl;b.useProgram(a),this.uSampler=b.getUniformLocation(a,"uSampler"),this.projectionVector=b.getUniformLocation(a,"projectionVector"),this.offsetVector=b.getUniformLocation(a,"offsetVector"),this.aVertexPosition=b.getAttribLocation(a,"aVertexPosition"),this.colorAttribute=b.getAttribLocation(a,"aColor"),this.aTextureCoord=b.getAttribLocation(a,"aTextureCoord");for(var c in this.uniforms)this.uniforms[c].uniformLocation=b.getUniformLocation(a,c);this.program=a},d.PixiShader.prototype.syncUniforms=function(){var a=d.gl;for(var b in this.uniforms){var c=this.uniforms[b].type;if("f"==c&&a.uniform1f(this.uniforms[b].uniformLocation,this.uniforms[b].value),"f2"==c)a.uniform2f(this.uniforms[b].uniformLocation,this.uniforms[b].value.x,this.uniforms[b].value.y);else if("f4"==c)a.uniform4fv(this.uniforms[b].uniformLocation,this.uniforms[b].value);else if("mat4"==c)a.uniformMatrix4fv(this.uniforms[b].uniformLocation,!1,this.uniforms[b].value);else if("sampler2D"==c){var e=this.uniforms[b].value;a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,e.baseTexture._glTexture),a.uniform1i(this.uniforms[b].uniformLocation,1)}}},d.PixiShader.defaultVertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying float vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {","gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);","vTextureCoord = aTextureCoord;","vColor = aColor;","}"],d.PrimitiveShader=function(){this.program,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {","gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform float alpha;","varying vec4 vColor;","void main(void) {","vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);","v -= offsetVector.xyx;","gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);","vColor = aColor * alpha;","}"]},d.PrimitiveShader.prototype.init=function(){var a=d.compileProgram(this.vertexSrc,this.fragmentSrc),b=d.gl;b.useProgram(a),this.projectionVector=b.getUniformLocation(a,"projectionVector"),this.offsetVector=b.getUniformLocation(a,"offsetVector"),this.aVertexPosition=b.getAttribLocation(a,"aVertexPosition"),this.colorAttribute=b.getAttribLocation(a,"aColor"),this.translationMatrix=b.getUniformLocation(a,"translationMatrix"),this.alpha=b.getUniformLocation(a,"alpha"),this.program=a},d.StripShader=function(){this.program,this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));","gl_FragColor = gl_FragColor * alpha;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","varying vec2 vTextureCoord;","varying vec2 offsetVector;","varying float vColor;","void main(void) {","vec3 v = translationMatrix * vec3(aVertexPosition, 1.0);","v -= offsetVector.xyx;","gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / projectionVector.y + 1.0 , 0.0, 1.0);","vTextureCoord = aTextureCoord;","vColor = aColor;","}"]},d.StripShader.prototype.init=function(){var a=d.compileProgram(this.vertexSrc,this.fragmentSrc),b=d.gl;b.useProgram(a),this.uSampler=b.getUniformLocation(a,"uSampler"),this.projectionVector=b.getUniformLocation(a,"projectionVector"),this.offsetVector=b.getUniformLocation(a,"offsetVector"),this.colorAttribute=b.getAttribLocation(a,"aColor"),this.aVertexPosition=b.getAttribLocation(a,"aVertexPosition"),this.aTextureCoord=b.getAttribLocation(a,"aTextureCoord"),this.translationMatrix=b.getUniformLocation(a,"translationMatrix"),this.alpha=b.getUniformLocation(a,"alpha"),this.program=a},d._batchs=[],d._getBatch=function(a){return 0==d._batchs.length?new d.WebGLBatch(a):d._batchs.pop()},d._returnBatch=function(a){a.clean(),d._batchs.push(a)},d._restoreBatchs=function(a){for(var b=0;bc;c++){var d=6*c,e=4*c;this.indices[d+0]=e+0,this.indices[d+1]=e+1,this.indices[d+2]=e+2,this.indices[d+3]=e+0,this.indices[d+4]=e+2,this.indices[d+5]=e+3}a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this.indices,a.STATIC_DRAW)},d.WebGLBatch.prototype.refresh=function(){this.gl,this.dynamicSizethis.width&&(f.width=this.width),f.y<0&&(f.y=0),f.height>this.height&&(f.height=this.height),b.bindFramebuffer(b.FRAMEBUFFER,e.frameBuffer),b.viewport(0,0,f.width,f.height),d.projection.x=f.width/2,d.projection.y=-f.height/2,d.offset.x=-f.x,d.offset.y=-f.y,b.uniform2f(d.defaultShader.projectionVector,f.width/2,-f.height/2),b.uniform2f(d.defaultShader.offsetVector,-f.x,-f.y),b.colorMask(!0,!0,!0,!0),b.clearColor(0,0,0,0),b.clear(b.COLOR_BUFFER_BIT),a._glFilterTexture=e},d.WebGLFilterManager.prototype.popFilter=function(){var a=d.gl,b=this.filterStack.pop(),c=b.target.filterArea,e=b._glFilterTexture;if(b.filterPasses.length>1){a.viewport(0,0,c.width,c.height),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=0,this.vertexArray[1]=c.height,this.vertexArray[2]=c.width,this.vertexArray[3]=c.height,this.vertexArray[4]=0,this.vertexArray[5]=0,this.vertexArray[6]=c.width,this.vertexArray[7]=0,a.bufferSubData(a.ARRAY_BUFFER,0,this.vertexArray),a.bindBuffer(a.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=c.width/this.width,this.uvArray[5]=c.height/this.height,this.uvArray[6]=c.width/this.width,this.uvArray[7]=c.height/this.height,a.bufferSubData(a.ARRAY_BUFFER,0,this.uvArray);var f=e,g=this.texturePool.pop();g||(g=new d.FilterTexture(this.width,this.height)),a.bindFramebuffer(a.FRAMEBUFFER,g.frameBuffer),a.clear(a.COLOR_BUFFER_BIT),a.disable(a.BLEND);for(var h=0;hs?s:E,E=E>t?t:E,E=E>u?u:E,E=E>v?v:E,F=F>w?w:F,F=F>x?x:F,F=F>y?y:F,F=F>z?z:F,C=s>C?s:C,C=t>C?t:C,C=u>C?u:C,C=v>C?v:C,D=w>D?w:D,D=x>D?x:D,D=y>D?y:D,D=z>D?z:D),l=!1,A=A._iNext}while(A!=B);a.filterArea.x=E,a.filterArea.y=F,a.filterArea.width=C-E,a.filterArea.height=D-F},d.FilterTexture=function(a,b){var c=d.gl;this.frameBuffer=c.createFramebuffer(),this.texture=c.createTexture(),c.bindTexture(c.TEXTURE_2D,this.texture),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.bindFramebuffer(c.FRAMEBUFFER,this.framebuffer),c.bindFramebuffer(c.FRAMEBUFFER,this.frameBuffer),c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,this.texture,0),this.resize(a,b)},d.FilterTexture.prototype.resize=function(a,b){this.width=a,this.height=b;var c=d.gl;c.bindTexture(c.TEXTURE_2D,this.texture),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,a,b,0,c.RGBA,c.UNSIGNED_BYTE,null)},d.WebGLGraphics=function(){},d.WebGLGraphics.renderGraphics=function(a,b){var c=d.gl;a._webGL||(a._webGL={points:[],indices:[],lastIndex:0,buffer:c.createBuffer(),indexBuffer:c.createBuffer()}),a.dirty&&(a.dirty=!1,a.clearDirty&&(a.clearDirty=!1,a._webGL.lastIndex=0,a._webGL.points=[],a._webGL.indices=[]),d.WebGLGraphics.updateGraphics(a)),d.activatePrimitiveShader();var e=d.mat3.clone(a.worldTransform);d.mat3.transpose(e),c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA),c.uniformMatrix3fv(d.primitiveShader.translationMatrix,!1,e),c.uniform2f(d.primitiveShader.projectionVector,b.x,-b.y),c.uniform2f(d.primitiveShader.offsetVector,-d.offset.x,-d.offset.y),c.uniform1f(d.primitiveShader.alpha,a.worldAlpha),c.bindBuffer(c.ARRAY_BUFFER,a._webGL.buffer),c.vertexAttribPointer(d.primitiveShader.aVertexPosition,2,c.FLOAT,!1,24,0),c.vertexAttribPointer(d.primitiveShader.colorAttribute,4,c.FLOAT,!1,24,8),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,a._webGL.indexBuffer),c.drawElements(c.TRIANGLE_STRIP,a._webGL.indices.length,c.UNSIGNED_SHORT,0),d.deactivatePrimitiveShader()},d.WebGLGraphics.updateGraphics=function(a){for(var b=a._webGL.lastIndex;b3&&d.WebGLGraphics.buildPoly(c,a._webGL),c.lineWidth>0&&d.WebGLGraphics.buildLine(c,a._webGL)):c.type==d.Graphics.RECT?d.WebGLGraphics.buildRectangle(c,a._webGL):(c.type==d.Graphics.CIRC||c.type==d.Graphics.ELIP)&&d.WebGLGraphics.buildCircle(c,a._webGL)}a._webGL.lastIndex=a.graphicsData.length;var e=d.gl;a._webGL.glPoints=new Float32Array(a._webGL.points),e.bindBuffer(e.ARRAY_BUFFER,a._webGL.buffer),e.bufferData(e.ARRAY_BUFFER,a._webGL.glPoints,e.STATIC_DRAW),a._webGL.glIndicies=new Uint16Array(a._webGL.indices),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a._webGL.indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,a._webGL.glIndicies,e.STATIC_DRAW)},d.WebGLGraphics.buildRectangle=function(a,c){var e=a.points,f=e[0],g=e[1],h=e[2],i=e[3];if(a.fill){var j=b(a.fillColor),k=a.fillAlpha,l=j[0]*k,m=j[1]*k,n=j[2]*k,o=c.points,p=c.indices,q=o.length/6;o.push(f,g),o.push(l,m,n,k),o.push(f+h,g),o.push(l,m,n,k),o.push(f,g+i),o.push(l,m,n,k),o.push(f+h,g+i),o.push(l,m,n,k),p.push(q,q,q+1,q+2,q+3,q+3)}a.lineWidth&&(a.points=[f,g,f+h,g,f+h,g+i,f,g+i,f,g],d.WebGLGraphics.buildLine(a,c))},d.WebGLGraphics.buildCircle=function(a,c){var e=a.points,f=e[0],g=e[1],h=e[2],i=e[3],j=40,k=2*Math.PI/j;if(a.fill){var l=b(a.fillColor),m=a.fillAlpha,n=l[0]*m,o=l[1]*m,p=l[2]*m,q=c.points,r=c.indices,s=q.length/6;r.push(s);for(var t=0;j+1>t;t++)q.push(f,g,n,o,p,m),q.push(f+Math.sin(k*t)*h,g+Math.cos(k*t)*i,n,o,p,m),r.push(s++,s++);r.push(s-1)}if(a.lineWidth){a.points=[];for(var t=0;j+1>t;t++)a.points.push(f+Math.sin(k*t)*h,g+Math.cos(k*t)*i);d.WebGLGraphics.buildLine(a,c)}},d.WebGLGraphics.buildLine=function(a,c){var e=a.points;if(0!=e.length){if(a.lineWidth%2)for(var f=0;ff;f++)k=e[2*(f-1)],l=e[2*(f-1)+1],m=e[2*f],n=e[2*f+1],o=e[2*(f+1)],p=e[2*(f+1)+1],q=-(l-n),r=k-m,E=Math.sqrt(q*q+r*r),q/=E,r/=E,q*=K,r*=K,s=-(n-p),t=m-o,E=Math.sqrt(s*s+t*t),s/=E,t/=E,s*=K,t*=K,w=-r+l-(-r+n),x=-q+m-(-q+k),y=(-q+k)*(-r+n)-(-q+m)*(-r+l),z=-t+p-(-t+n),A=-s+m-(-s+o),B=(-s+o)*(-t+n)-(-s+m)*(-t+p),C=w*A-z*x,Math.abs(C)<.1?(C+=10.1,F.push(m-q,n-r,N,O,P,M),F.push(m+q,n+r,N,O,P,M)):(px=(x*B-A*y)/C,py=(z*y-w*B)/C,D=(px-m)*(px-m)+(py-n)+(py-n),D>19600?(u=q-s,v=r-t,E=Math.sqrt(u*u+v*v),u/=E,v/=E,u*=K,v*=K,F.push(m-u,n-v),F.push(N,O,P,M),F.push(m+u,n+v),F.push(N,O,P,M),F.push(m-u,n-v),F.push(N,O,P,M),I++):(F.push(px,py),F.push(N,O,P,M),F.push(m-(px-m),n-(py-n)),F.push(N,O,P,M))); -k=e[2*(H-2)],l=e[2*(H-2)+1],m=e[2*(H-1)],n=e[2*(H-1)+1],q=-(l-n),r=k-m,E=Math.sqrt(q*q+r*r),q/=E,r/=E,q*=K,r*=K,F.push(m-q,n-r),F.push(N,O,P,M),F.push(m+q,n+r),F.push(N,O,P,M),G.push(J);for(var f=0;I>f;f++)G.push(J++);G.push(J-1)}},d.WebGLGraphics.buildPoly=function(a,c){var e=a.points;if(!(e.length<6)){for(var f=c.points,g=c.indices,h=e.length/2,i=b(a.fillColor),j=a.fillAlpha,k=i[0]*j,l=i[1]*j,m=i[2]*j,n=d.PolyK.Triangulate(e),o=f.length/6,p=0;pp;p++)f.push(e[2*p],e[2*p+1],k,l,m,j)}},d._defaultFrame=new d.Rectangle(0,0,1,1),d.gl,d.WebGLRenderer=function(a,b,c,e,f){this.transparent=!!e,this.width=a||800,this.height=b||600,this.view=c||document.createElement("canvas"),this.view.width=this.width,this.view.height=this.height;var g=this;this.view.addEventListener("webglcontextlost",function(a){g.handleContextLost(a)},!1),this.view.addEventListener("webglcontextrestored",function(a){g.handleContextRestored(a)},!1),this.batchs=[];var h={alpha:this.transparent,antialias:!!f,premultipliedAlpha:!1,stencil:!0};try{d.gl=this.gl=this.view.getContext("experimental-webgl",h)}catch(i){try{d.gl=this.gl=this.view.getContext("webgl",h)}catch(i){throw new Error(" This browser does not support webGL. Try using the canvas renderer"+this)}}d.initDefaultShaders();var j=this.gl;j.useProgram(d.defaultShader.program),d.WebGLRenderer.gl=j,this.batch=new d.WebGLBatch(j),j.disable(j.DEPTH_TEST),j.disable(j.CULL_FACE),j.enable(j.BLEND),j.colorMask(!0,!0,!0,this.transparent),d.projection=new d.Point(400,300),d.offset=new d.Point(0,0),this.resize(this.width,this.height),this.contextLost=!1,this.stageRenderGroup=new d.WebGLRenderGroup(this.gl,this.transparent)},d.WebGLRenderer.prototype.constructor=d.WebGLRenderer,d.WebGLRenderer.getBatch=function(){return 0==d._batchs.length?new d.WebGLBatch(d.WebGLRenderer.gl):d._batchs.pop()},d.WebGLRenderer.returnBatch=function(a){a.clean(),d._batchs.push(a)},d.WebGLRenderer.prototype.render=function(a){if(!this.contextLost){this.__stage!==a&&(this.__stage=a,this.stageRenderGroup.setRenderable(a)),d.WebGLRenderer.updateTextures(),d.visibleCount++,a.updateTransform();var b=this.gl;if(b.colorMask(!0,!0,!0,this.transparent),b.viewport(0,0,this.width,this.height),b.bindFramebuffer(b.FRAMEBUFFER,null),b.clearColor(a.backgroundColorSplit[0],a.backgroundColorSplit[1],a.backgroundColorSplit[2],!this.transparent),b.clear(b.COLOR_BUFFER_BIT),this.stageRenderGroup.backgroundColor=a.backgroundColorSplit,d.projection.x=this.width/2,d.projection.y=-this.height/2,this.stageRenderGroup.render(d.projection),a.interactive&&(a._interactiveEventsAdded||(a._interactiveEventsAdded=!0,a.interactionManager.setTarget(this))),d.Texture.frameUpdates.length>0){for(var c=0;cn;n++)renderable=this.batchs[n],renderable instanceof d.WebGLBatch?this.batchs[n].render():this.renderSpecial(renderable,b);endBatch instanceof d.WebGLBatch?endBatch.render(0,h+1):this.renderSpecial(endBatch,b)},d.WebGLRenderGroup.prototype.renderSpecial=function(a,b){var c=a.vcount===d.visibleCount;a instanceof d.TilingSprite?c&&this.renderTilingSprite(a,b):a instanceof d.Strip?c&&this.renderStrip(a,b):a instanceof d.CustomRenderable?c&&a.renderWebGL(this,b):a instanceof d.Graphics?c&&a.renderable&&d.WebGLGraphics.renderGraphics(a,b):a instanceof d.FilterBlock&&this.handleFilterBlock(a,b)},flip=!1;var f=[],g=0;return d.WebGLRenderGroup.prototype.handleFilterBlock=function(a,b){var c=d.gl;if(a.open)a.data instanceof Array?this.filterManager.pushFilter(a):(g++,f.push(a),c.enable(c.STENCIL_TEST),c.colorMask(!1,!1,!1,!1),c.stencilFunc(c.ALWAYS,1,1),c.stencilOp(c.KEEP,c.KEEP,c.INCR),d.WebGLGraphics.renderGraphics(a.data,b),c.colorMask(!0,!0,!0,!0),c.stencilFunc(c.NOTEQUAL,0,f.length),c.stencilOp(c.KEEP,c.KEEP,c.KEEP));else if(a.data instanceof Array)this.filterManager.popFilter();else{var e=f.pop(a);e&&(c.colorMask(!1,!1,!1,!1),c.stencilFunc(c.ALWAYS,1,1),c.stencilOp(c.KEEP,c.KEEP,c.DECR),d.WebGLGraphics.renderGraphics(e.data,b),c.colorMask(!0,!0,!0,!0),c.stencilFunc(c.NOTEQUAL,0,f.length),c.stencilOp(c.KEEP,c.KEEP,c.KEEP)),c.disable(c.STENCIL_TEST)}},d.WebGLRenderGroup.prototype.updateTexture=function(a){this.removeObject(a);for(var b=a.first;b!=this.root&&(b=b._iPrev,!b.renderable||!b.__renderGroup););for(var c=a.last;c._iNext&&(c=c._iNext,!c.renderable||!c.__renderGroup););this.insertObject(a,b,c)},d.WebGLRenderGroup.prototype.addFilterBlocks=function(a,b){a.__renderGroup=this,b.__renderGroup=this;for(var c=a;c!=this.root.first&&(c=c._iPrev,!c.renderable||!c.__renderGroup););this.insertAfter(a,c);for(var d=b;d!=this.root.first&&(d=d._iPrev,!d.renderable||!d.__renderGroup););this.insertAfter(b,d)},d.WebGLRenderGroup.prototype.removeFilterBlocks=function(a,b){this.removeObject(a),this.removeObject(b)},d.WebGLRenderGroup.prototype.addDisplayObjectAndChildren=function(a){a.__renderGroup&&a.__renderGroup.removeDisplayObjectAndChildren(a);for(var b=a.first;b!=this.root.first&&(b=b._iPrev,!b.renderable||!b.__renderGroup););for(var c=a.last;c._iNext&&(c=c._iNext,!c.renderable||!c.__renderGroup););var d=a.first,e=a.last._iNext;do d.__renderGroup=this,d.renderable&&(this.insertObject(d,b,c),b=d),d=d._iNext;while(d!=e)},d.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren=function(a){if(a.__renderGroup==this){a.last;do a.__renderGroup=null,a.renderable&&this.removeObject(a),a=a._iNext;while(a)}},d.WebGLRenderGroup.prototype.insertObject=function(a,b,c){var e=b,f=c;if(a instanceof d.Sprite){var g,h;if(e instanceof d.Sprite){if(g=e.batch,g&&g.texture==a.texture.baseTexture&&g.blendMode==a.blendMode)return g.insertAfter(a,e),void 0}else g=e;if(f)if(f instanceof d.Sprite){if(h=f.batch){if(h.texture==a.texture.baseTexture&&h.blendMode==a.blendMode)return h.insertBefore(a,f),void 0;if(h==g){var i=g.split(f),j=d.WebGLRenderer.getBatch(),k=this.batchs.indexOf(g);return j.init(a),this.batchs.splice(k+1,0,j,i),void 0}}}else h=f;var j=d.WebGLRenderer.getBatch();if(j.init(a),g){var k=this.batchs.indexOf(g);this.batchs.splice(k+1,0,j)}else this.batchs.push(j)}else a instanceof d.TilingSprite?this.initTilingSprite(a):a instanceof d.Strip&&this.initStrip(a),this.insertAfter(a,e)},d.WebGLRenderGroup.prototype.insertAfter=function(a,b){if(b instanceof d.Sprite){var c=b.batch;if(c)if(c.tail==b){var e=this.batchs.indexOf(c);this.batchs.splice(e+1,0,a)}else{var f=c.split(b.__next),e=this.batchs.indexOf(c);this.batchs.splice(e+1,0,a,f)}else this.batchs.push(a)}else{var e=this.batchs.indexOf(b);this.batchs.splice(e+1,0,a)}},d.WebGLRenderGroup.prototype.removeObject=function(a){var b;if(a instanceof d.Sprite){var c=a.batch;if(!c)return;c.remove(a),0==c.size&&(b=c)}else b=a;if(b){var e=this.batchs.indexOf(b);if(-1==e)return;if(0==e||e==this.batchs.length-1)return this.batchs.splice(e,1),b instanceof d.WebGLBatch&&d.WebGLRenderer.returnBatch(b),void 0;if(this.batchs[e-1]instanceof d.WebGLBatch&&this.batchs[e+1]instanceof d.WebGLBatch&&this.batchs[e-1].texture==this.batchs[e+1].texture&&this.batchs[e-1].blendMode==this.batchs[e+1].blendMode)return this.batchs[e-1].merge(this.batchs[e+1]),b instanceof d.WebGLBatch&&d.WebGLRenderer.returnBatch(b),d.WebGLRenderer.returnBatch(this.batchs[e+1]),this.batchs.splice(e,2),void 0;this.batchs.splice(e,1),b instanceof d.WebGLBatch&&d.WebGLRenderer.returnBatch(b)}},d.WebGLRenderGroup.prototype.initTilingSprite=function(a){var b=this.gl;a.verticies=new Float32Array([0,0,a.width,0,a.width,a.height,0,a.height]),a.uvs=new Float32Array([0,0,1,0,1,1,0,1]),a.colors=new Float32Array([1,1,1,1]),a.indices=new Uint16Array([0,1,3,2]),a._vertexBuffer=b.createBuffer(),a._indexBuffer=b.createBuffer(),a._uvBuffer=b.createBuffer(),a._colorBuffer=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,a._vertexBuffer),b.bufferData(b.ARRAY_BUFFER,a.verticies,b.STATIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._uvBuffer),b.bufferData(b.ARRAY_BUFFER,a.uvs,b.DYNAMIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._colorBuffer),b.bufferData(b.ARRAY_BUFFER,a.colors,b.STATIC_DRAW),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,a._indexBuffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,a.indices,b.STATIC_DRAW),a.texture.baseTexture._glTexture?(b.bindTexture(b.TEXTURE_2D,a.texture.baseTexture._glTexture),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.REPEAT),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.REPEAT),a.texture.baseTexture._powerOf2=!0):a.texture.baseTexture._powerOf2=!0},d.WebGLRenderGroup.prototype.renderStrip=function(a,b){var c=this.gl;d.activateStripShader();var e=d.stripShader;e.program;var f=d.mat3.clone(a.worldTransform);d.mat3.transpose(f),c.uniformMatrix3fv(e.translationMatrix,!1,f),c.uniform2f(e.projectionVector,b.x,b.y),c.uniform2f(e.offsetVector,-d.offset.x,-d.offset.y),c.uniform1f(e.alpha,a.worldAlpha),a.dirty?(a.dirty=!1,c.bindBuffer(c.ARRAY_BUFFER,a._vertexBuffer),c.bufferData(c.ARRAY_BUFFER,a.verticies,c.STATIC_DRAW),c.vertexAttribPointer(e.aVertexPosition,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,a._uvBuffer),c.bufferData(c.ARRAY_BUFFER,a.uvs,c.STATIC_DRAW),c.vertexAttribPointer(e.aTextureCoord,2,c.FLOAT,!1,0,0),c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,a.texture.baseTexture._glTexture),c.bindBuffer(c.ARRAY_BUFFER,a._colorBuffer),c.bufferData(c.ARRAY_BUFFER,a.colors,c.STATIC_DRAW),c.vertexAttribPointer(e.colorAttribute,1,c.FLOAT,!1,0,0),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,a._indexBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,a.indices,c.STATIC_DRAW)):(c.bindBuffer(c.ARRAY_BUFFER,a._vertexBuffer),c.bufferSubData(c.ARRAY_BUFFER,0,a.verticies),c.vertexAttribPointer(e.aVertexPosition,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,a._uvBuffer),c.vertexAttribPointer(e.aTextureCoord,2,c.FLOAT,!1,0,0),c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,a.texture.baseTexture._glTexture),c.bindBuffer(c.ARRAY_BUFFER,a._colorBuffer),c.vertexAttribPointer(e.colorAttribute,1,c.FLOAT,!1,0,0),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,a._indexBuffer)),c.drawElements(c.TRIANGLE_STRIP,a.indices.length,c.UNSIGNED_SHORT,0),d.deactivateStripShader()},d.WebGLRenderGroup.prototype.renderTilingSprite=function(a,b){var c=this.gl;d.shaderProgram;var e=a.tilePosition,f=a.tileScale,g=e.x/a.texture.baseTexture.width,h=e.y/a.texture.baseTexture.height,i=a.width/a.texture.baseTexture.width/f.x,j=a.height/a.texture.baseTexture.height/f.y;a.uvs[0]=0-g,a.uvs[1]=0-h,a.uvs[2]=1*i-g,a.uvs[3]=0-h,a.uvs[4]=1*i-g,a.uvs[5]=1*j-h,a.uvs[6]=0-g,a.uvs[7]=1*j-h,c.bindBuffer(c.ARRAY_BUFFER,a._uvBuffer),c.bufferSubData(c.ARRAY_BUFFER,0,a.uvs),this.renderStrip(a,b)},d.WebGLRenderGroup.prototype.initStrip=function(a){var b=this.gl;this.shaderProgram,a._vertexBuffer=b.createBuffer(),a._indexBuffer=b.createBuffer(),a._uvBuffer=b.createBuffer(),a._colorBuffer=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,a._vertexBuffer),b.bufferData(b.ARRAY_BUFFER,a.verticies,b.DYNAMIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._uvBuffer),b.bufferData(b.ARRAY_BUFFER,a.uvs,b.STATIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._colorBuffer),b.bufferData(b.ARRAY_BUFFER,a.colors,b.STATIC_DRAW),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,a._indexBuffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,a.indices,b.STATIC_DRAW)},d.initDefaultShaders=function(){d.primitiveShader=new d.PrimitiveShader,d.primitiveShader.init(),d.stripShader=new d.StripShader,d.stripShader.init(),d.defaultShader=new d.PixiShader,d.defaultShader.init();var a=d.gl,b=d.defaultShader.program;a.useProgram(b),a.enableVertexAttribArray(d.defaultShader.aVertexPosition),a.enableVertexAttribArray(d.defaultShader.colorAttribute),a.enableVertexAttribArray(d.defaultShader.aTextureCoord)},d.activatePrimitiveShader=function(){var a=d.gl;a.useProgram(d.primitiveShader.program),a.disableVertexAttribArray(d.defaultShader.aVertexPosition),a.disableVertexAttribArray(d.defaultShader.colorAttribute),a.disableVertexAttribArray(d.defaultShader.aTextureCoord),a.enableVertexAttribArray(d.primitiveShader.aVertexPosition),a.enableVertexAttribArray(d.primitiveShader.colorAttribute)},d.deactivatePrimitiveShader=function(){var a=d.gl;a.useProgram(d.defaultShader.program),a.disableVertexAttribArray(d.primitiveShader.aVertexPosition),a.disableVertexAttribArray(d.primitiveShader.colorAttribute),a.enableVertexAttribArray(d.defaultShader.aVertexPosition),a.enableVertexAttribArray(d.defaultShader.colorAttribute),a.enableVertexAttribArray(d.defaultShader.aTextureCoord)},d.activateStripShader=function(){var a=d.gl;a.useProgram(d.stripShader.program)},d.deactivateStripShader=function(){var a=d.gl;a.useProgram(d.defaultShader.program)},d.CompileVertexShader=function(a,b){return d._CompileShader(a,b,a.VERTEX_SHADER)},d.CompileFragmentShader=function(a,b){return d._CompileShader(a,b,a.FRAGMENT_SHADER)},d._CompileShader=function(a,b,c){var d=b.join("\n"),e=a.createShader(c);return a.shaderSource(e,d),a.compileShader(e),a.getShaderParameter(e,a.COMPILE_STATUS)?e:null},d.compileProgram=function(a,b){var c=d.gl,e=d.CompileFragmentShader(c,b),f=d.CompileVertexShader(c,a),g=c.createProgram();return c.attachShader(g,f),c.attachShader(g,e),c.linkProgram(g),c.getProgramParameter(g,c.LINK_STATUS)||console.log("Could not initialise shaders"),g},d.BitmapText=function(a,b){d.DisplayObjectContainer.call(this),this.setText(a),this.setStyle(b),this.updateText(),this.dirty=!1},d.BitmapText.prototype=Object.create(d.DisplayObjectContainer.prototype),d.BitmapText.prototype.constructor=d.BitmapText,d.BitmapText.prototype.setText=function(a){this.text=a||" ",this.dirty=!0},d.BitmapText.prototype.setStyle=function(a){a=a||{},a.align=a.align||"left",this.style=a;var b=a.font.split(" ");this.fontName=b[b.length-1],this.fontSize=b.length>=2?parseInt(b[b.length-2],10):d.BitmapText.fonts[this.fontName].size,this.dirty=!0},d.BitmapText.prototype.updateText=function(){for(var a=d.BitmapText.fonts[this.fontName],b=new d.Point,c=null,e=[],f=0,g=[],h=0,i=this.fontSize/a.size,j=0;j=j;j++){var n=0;"right"==this.style.align?n=f-g[j]:"center"==this.style.align&&(n=(f-g[j])/2),m.push(n)}for(j=0;j0;)this.removeChild(this.getChildAt(0));this.updateText(),this.dirty=!1}d.DisplayObjectContainer.prototype.updateTransform.call(this)},d.BitmapText.fonts={},d.Text=function(a,b){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),d.Sprite.call(this,d.Texture.fromCanvas(this.canvas)),this.setText(a),this.setStyle(b),this.updateText(),this.dirty=!1},d.Text.prototype=Object.create(d.Sprite.prototype),d.Text.prototype.constructor=d.Text,d.Text.prototype.setStyle=function(a){a=a||{},a.font=a.font||"bold 20pt Arial",a.fill=a.fill||"black",a.align=a.align||"left",a.stroke=a.stroke||"black",a.strokeThickness=a.strokeThickness||0,a.wordWrap=a.wordWrap||!1,a.wordWrapWidth=a.wordWrapWidth||100,this.style=a,this.dirty=!0},d.Text.prototype.setText=function(a){this.text=a.toString()||" ",this.dirty=!0},d.Text.prototype.updateText=function(){this.context.font=this.style.font;var a=this.text;this.style.wordWrap&&(a=this.wordWrap(this.text));for(var b=a.split(/(?:\r\n|\r|\n)/),c=[],e=0,f=0;fe?(g>0&&(b+="\n"),b+=f[g]+" ",e=this.style.wordWrapWidth-h):(e-=i,b+=f[g]+" ")}b+="\n"}return b},d.Text.prototype.destroy=function(a){a&&this.texture.destroy()},d.Text.heightCache={},d.BaseTextureCache={},d.texturesToUpdate=[],d.texturesToDestroy=[],d.BaseTexture=function(a){if(d.EventTarget.call(this),this.width=100,this.height=100,this.hasLoaded=!1,this.source=a,a){if(this.source instanceof Image||this.source instanceof HTMLImageElement)if(this.source.complete)this.hasLoaded=!0,this.width=this.source.width,this.height=this.source.height,d.texturesToUpdate.push(this);else{var b=this;this.source.onload=function(){b.hasLoaded=!0,b.width=b.source.width,b.height=b.source.height,d.texturesToUpdate.push(b),b.dispatchEvent({type:"loaded",content:b})}}else this.hasLoaded=!0,this.width=this.source.width,this.height=this.source.height,d.texturesToUpdate.push(this);this._powerOf2=!1}},d.BaseTexture.prototype.constructor=d.BaseTexture,d.BaseTexture.prototype.destroy=function(){this.source instanceof Image&&(this.source.src=null),this.source=null,d.texturesToDestroy.push(this)},d.BaseTexture.fromImage=function(a,b){var c=d.BaseTextureCache[a];if(!c){var e=new Image;b&&(e.crossOrigin=""),e.src=a,c=new d.BaseTexture(e),d.BaseTextureCache[a]=c}return c},d.TextureCache={},d.FrameCache={},d.Texture=function(a,b){if(d.EventTarget.call(this),b||(this.noFrame=!0,b=new d.Rectangle(0,0,1,1)),a instanceof d.Texture&&(a=a.baseTexture),this.baseTexture=a,this.frame=b,this.trim=new d.Point,this.scope=this,a.hasLoaded)this.noFrame&&(b=new d.Rectangle(0,0,a.width,a.height)),this.setFrame(b);else{var c=this;a.addEventListener("loaded",function(){c.onBaseTextureLoaded()})}},d.Texture.prototype.constructor=d.Texture,d.Texture.prototype.onBaseTextureLoaded=function(){var a=this.baseTexture;a.removeEventListener("loaded",this.onLoaded),this.noFrame&&(this.frame=new d.Rectangle(0,0,a.width,a.height)),this.noFrame=!1,this.width=this.frame.width,this.height=this.frame.height,this.scope.dispatchEvent({type:"update",content:this})},d.Texture.prototype.destroy=function(a){a&&this.baseTexture.destroy()},d.Texture.prototype.setFrame=function(a){if(this.frame=a,this.width=a.width,this.height=a.height,a.x+a.width>this.baseTexture.width||a.y+a.height>this.baseTexture.height)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.updateFrame=!0,d.Texture.frameUpdates.push(this)},d.Texture.fromImage=function(a,b){var c=d.TextureCache[a];return c||(c=new d.Texture(d.BaseTexture.fromImage(a,b)),d.TextureCache[a]=c),c},d.Texture.fromFrame=function(a){var b=d.TextureCache[a];if(!b)throw new Error("The frameId '"+a+"' does not exist in the texture cache "+this);return b},d.Texture.fromCanvas=function(a){var b=new d.BaseTexture(a);return new d.Texture(b)},d.Texture.addTextureToCache=function(a,b){d.TextureCache[b]=a},d.Texture.removeTextureFromCache=function(a){var b=d.TextureCache[a];return d.TextureCache[a]=null,b},d.Texture.frameUpdates=[],d.RenderTexture=function(a,b){d.EventTarget.call(this),this.width=a||100,this.height=b||100,this.indetityMatrix=d.mat3.create(),this.frame=new d.Rectangle(0,0,this.width,this.height),d.gl?this.initWebGL():this.initCanvas()},d.RenderTexture.prototype=Object.create(d.Texture.prototype),d.RenderTexture.prototype.constructor=d.RenderTexture,d.RenderTexture.prototype.initWebGL=function(){var a=d.gl;this.glFramebuffer=a.createFramebuffer(),a.bindFramebuffer(a.FRAMEBUFFER,this.glFramebuffer),this.glFramebuffer.width=this.width,this.glFramebuffer.height=this.height,this.baseTexture=new d.BaseTexture,this.baseTexture.width=this.width,this.baseTexture.height=this.height,this.baseTexture._glTexture=a.createTexture(),a.bindTexture(a.TEXTURE_2D,this.baseTexture._glTexture),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,this.width,this.height,0,a.RGBA,a.UNSIGNED_BYTE,null),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),this.baseTexture.isRender=!0,a.bindFramebuffer(a.FRAMEBUFFER,this.glFramebuffer),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,this.baseTexture._glTexture,0),this.projection=new d.Point(this.width/2,-this.height/2),this.render=this.renderWebGL},d.RenderTexture.prototype.resize=function(a,b){if(this.width=a,this.height=b,d.gl){this.projection.x=this.width/2,this.projection.y=-this.height/2;var c=d.gl;c.bindTexture(c.TEXTURE_2D,this.baseTexture._glTexture),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,this.width,this.height,0,c.RGBA,c.UNSIGNED_BYTE,null)}else this.frame.width=this.width,this.frame.height=this.height,this.renderer.resize(this.width,this.height)},d.RenderTexture.prototype.initCanvas=function(){this.renderer=new d.CanvasRenderer(this.width,this.height,null,0),this.baseTexture=new d.BaseTexture(this.renderer.view),this.frame=new d.Rectangle(0,0,this.width,this.height),this.render=this.renderCanvas},d.RenderTexture.prototype.renderWebGL=function(a,b,c){var e=d.gl;e.colorMask(!0,!0,!0,!0),e.viewport(0,0,this.width,this.height),e.bindFramebuffer(e.FRAMEBUFFER,this.glFramebuffer),c&&(e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT));var f=a.children,g=a.worldTransform;a.worldTransform=d.mat3.create(),a.worldTransform[4]=-1,a.worldTransform[5]=-2*this.projection.y,b&&(a.worldTransform[2]=b.x,a.worldTransform[5]-=b.y),d.visibleCount++,a.vcount=d.visibleCount;for(var h=0,i=f.length;i>h;h++)f[h].updateTransform();var j=a.__renderGroup;j?a==j.root?j.render(this.projection,this.glFramebuffer):j.renderSpecific(a,this.projection,this.glFramebuffer):(this.renderGroup||(this.renderGroup=new d.WebGLRenderGroup(e)),this.renderGroup.setRenderable(a),this.renderGroup.render(this.projection,this.glFramebuffer)),a.worldTransform=g},d.RenderTexture.prototype.renderCanvas=function(a,b,c){var e=a.children;a.worldTransform=d.mat3.create(),b&&(a.worldTransform[2]=b.x,a.worldTransform[5]=b.y);for(var f=0,g=e.length;g>f;f++)e[f].updateTransform();c&&this.renderer.context.clearRect(0,0,this.width,this.height),this.renderer.renderDisplayObject(a),this.renderer.context.setTransform(1,0,0,1,0,0)},d.EventTarget=function(){var a={};this.addEventListener=this.on=function(b,c){void 0===a[b]&&(a[b]=[]),-1===a[b].indexOf(c)&&a[b].push(c)},this.dispatchEvent=this.emit=function(b){if(a[b.type]&&a[b.type].length)for(var c=0,d=a[b.type].length;d>c;c++)a[b.type][c](b)},this.removeEventListener=this.off=function(b,c){var d=a[b].indexOf(c);-1!==d&&a[b].splice(d,1)}},d.PolyK={},d.PolyK.Triangulate=function(a){var b=!0,c=a.length>>1;if(3>c)return[];for(var e=[],f=[],g=0;c>g;g++)f.push(g);for(var g=0,h=c;h>3;){var i=f[(g+0)%h],j=f[(g+1)%h],k=f[(g+2)%h],l=a[2*i],m=a[2*i+1],n=a[2*j],o=a[2*j+1],p=a[2*k],q=a[2*k+1],r=!1;if(d.PolyK._convex(l,m,n,o,p,q,b)){r=!0;for(var s=0;h>s;s++){var t=f[s];if(t!=i&&t!=j&&t!=k&&d.PolyK._PointInTriangle(a[2*t],a[2*t+1],l,m,n,o,p,q)){r=!1;break}}}if(r)e.push(i,j,k),f.splice((g+1)%h,1),h--,g=0;else if(g++>3*h){if(!b)return console.log("PIXI Warning: shape too complex to fill"),[];var e=[];f=[];for(var g=0;c>g;g++)f.push(g);g=0,h=c,b=!1}}return e.push(f[0],f[1],f[2]),e},d.PolyK._PointInTriangle=function(a,b,c,d,e,f,g,h){var i=g-c,j=h-d,k=e-c,l=f-d,m=a-c,n=b-d,o=i*i+j*j,p=i*k+j*l,q=i*m+j*n,r=k*k+l*l,s=k*m+l*n,t=1/(o*r-p*p),u=(r*q-p*s)*t,v=(o*s-p*q)*t;return u>=0&&v>=0&&1>u+v},d.PolyK._convex=function(a,b,c,d,e,f,g){return(b-d)*(e-c)+(c-a)*(f-d)>=0==g},e.Camera=function(a,b,c,d,f,g){this.game=a,this.world=a.world,this.id=0,this.view=new e.Rectangle(c,d,f,g),this.screenView=new e.Rectangle(c,d,f,g),this.bounds=new e.Rectangle(c,d,f,g),this.deadzone=null,this.visible=!0,this.atLimit={x:!1,y:!1},this.target=null,this._edge=0,this.displayObject=null},e.Camera.FOLLOW_LOCKON=0,e.Camera.FOLLOW_PLATFORMER=1,e.Camera.FOLLOW_TOPDOWN=2,e.Camera.FOLLOW_TOPDOWN_TIGHT=3,e.Camera.prototype={follow:function(a,b){"undefined"==typeof b&&(b=e.Camera.FOLLOW_LOCKON),this.target=a;var c;switch(b){case e.Camera.FOLLOW_PLATFORMER:var d=this.width/8,f=this.height/3;this.deadzone=new e.Rectangle((this.width-d)/2,(this.height-f)/2-.25*f,d,f);break;case e.Camera.FOLLOW_TOPDOWN:c=Math.max(this.width,this.height)/4,this.deadzone=new e.Rectangle((this.width-c)/2,(this.height-c)/2,c,c);break;case e.Camera.FOLLOW_TOPDOWN_TIGHT:c=Math.max(this.width,this.height)/8,this.deadzone=new e.Rectangle((this.width-c)/2,(this.height-c)/2,c,c);break;case e.Camera.FOLLOW_LOCKON:default:this.deadzone=null}},focusOn:function(a){this.setPosition(Math.round(a.x-this.view.halfWidth),Math.round(a.y-this.view.halfHeight))},focusOnXY:function(a,b){this.setPosition(Math.round(a-this.view.halfWidth),Math.round(b-this.view.halfHeight))},update:function(){this.target&&this.updateTarget(),this.bounds&&this.checkBounds(),this.displayObject.position.x=-this.view.x,this.displayObject.position.y=-this.view.y},updateTarget:function(){this.deadzone?(this._edge=this.target.x-this.deadzone.x,this.view.x>this._edge&&(this.view.x=this._edge),this._edge=this.target.x+this.target.width-this.deadzone.x-this.deadzone.width,this.view.xthis._edge&&(this.view.y=this._edge),this._edge=this.target.y+this.target.height-this.deadzone.y-this.deadzone.height,this.view.ythis.bounds.right-this.width&&(this.atLimit.x=!0,this.view.x=this.bounds.right-this.width+1),this.view.ythis.bounds.bottom-this.height&&(this.atLimit.y=!0,this.view.y=this.bounds.bottom-this.height+1),this.view.floor()},setPosition:function(a,b){this.view.x=a,this.view.y=b,this.bounds&&this.checkBounds()},setSize:function(a,b){this.view.width=a,this.view.height=b}},Object.defineProperty(e.Camera.prototype,"x",{get:function(){return this.view.x},set:function(a){this.view.x=a,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"y",{get:function(){return this.view.y},set:function(a){this.view.y=a,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"width",{get:function(){return this.view.width},set:function(a){this.view.width=a}}),Object.defineProperty(e.Camera.prototype,"height",{get:function(){return this.view.height},set:function(a){this.view.height=a}}),e.State=function(){this.game=null,this.add=null,this.camera=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.particles=null,this.physics=null -},e.State.prototype={preload:function(){},loadUpdate:function(){},loadRender:function(){},create:function(){},update:function(){},render:function(){},paused:function(){},destroy:function(){}},e.StateManager=function(a,b){this.game=a,this.states={},null!==b&&(this._pendingState=b)},e.StateManager.prototype={game:null,_pendingState:null,_created:!1,states:{},current:"",onInitCallback:null,onPreloadCallback:null,onCreateCallback:null,onUpdateCallback:null,onRenderCallback:null,onPreRenderCallback:null,onLoadUpdateCallback:null,onLoadRenderCallback:null,onPausedCallback:null,onShutDownCallback:null,boot:function(){null!==this._pendingState&&("string"==typeof this._pendingState?this.start(this._pendingState,!1,!1):this.add("default",this._pendingState,!0))},add:function(a,b,c){"undefined"==typeof c&&(c=!1);var d;return b instanceof e.State?d=b:"object"==typeof b?(d=b,d.game=this.game):"function"==typeof b&&(d=new b(this.game)),this.states[a]=d,c&&(this.game.isBooted?this.start(a):this._pendingState=a),d},remove:function(a){this.current==a&&(this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onPausedCallback=null,this.onDestroyCallback=null),delete this.states[a]},start:function(a,b,c){return"undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=!1),0==this.game.isBooted?(this._pendingState=a,void 0):(0!=this.checkState(a)&&(this.current&&this.onShutDownCallback.call(this.callbackContext,this.game),b&&(this.game.tweens.removeAll(),this.game.world.destroy(),1==c&&this.game.cache.destroy()),this.setCurrentState(a),this.onPreloadCallback?(this.game.load.reset(),this.onPreloadCallback.call(this.callbackContext,this.game),0==this.game.load.queueSize?this.game.loadComplete():this.game.load.start()):this.game.loadComplete()),void 0)},dummy:function(){},checkState:function(a){if(this.states[a]){var b=!1;return this.states[a].preload&&(b=!0),0==b&&this.states[a].loadRender&&(b=!0),0==b&&this.states[a].loadUpdate&&(b=!0),0==b&&this.states[a].create&&(b=!0),0==b&&this.states[a].update&&(b=!0),0==b&&this.states[a].preRender&&(b=!0),0==b&&this.states[a].render&&(b=!0),0==b&&this.states[a].paused&&(b=!0),0==b?(console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions."),!1):!0}return console.warn("Phaser.StateManager - No state found with the key: "+a),!1},link:function(a){this.states[a].game=this.game,this.states[a].add=this.game.add,this.states[a].camera=this.game.camera,this.states[a].cache=this.game.cache,this.states[a].input=this.game.input,this.states[a].load=this.game.load,this.states[a].math=this.game.math,this.states[a].sound=this.game.sound,this.states[a].stage=this.game.stage,this.states[a].time=this.game.time,this.states[a].tweens=this.game.tweens,this.states[a].world=this.game.world,this.states[a].particles=this.game.particles,this.states[a].physics=this.game.physics,this.states[a].rnd=this.game.rnd},setCurrentState:function(a){this.callbackContext=this.states[a],this.link(a),this.onInitCallback=this.states[a].init||this.dummy,this.onPreloadCallback=this.states[a].preload||null,this.onLoadRenderCallback=this.states[a].loadRender||null,this.onLoadUpdateCallback=this.states[a].loadUpdate||null,this.onCreateCallback=this.states[a].create||null,this.onUpdateCallback=this.states[a].update||null,this.onPreRenderCallback=this.states[a].preRender||null,this.onRenderCallback=this.states[a].render||null,this.onPausedCallback=this.states[a].paused||null,this.onShutDownCallback=this.states[a].shutdown||this.dummy,this.current=a,this._created=!1,this.onInitCallback.call(this.callbackContext,this.game)},loadComplete:function(){0==this._created&&this.onCreateCallback?(this._created=!0,this.onCreateCallback.call(this.callbackContext,this.game)):this._created=!0},update:function(){this._created&&this.onUpdateCallback?this.onUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},preRender:function(){this.onPreRenderCallback&&this.onPreRenderCallback.call(this.callbackContext,this.game)},render:function(){this._created&&this.onRenderCallback?(this.game.renderType===e.CANVAS&&(this.game.context.save(),this.game.context.setTransform(1,0,0,1,0,0)),this.onRenderCallback.call(this.callbackContext,this.game),this.game.renderType===e.CANVAS&&this.game.context.restore()):this.onLoadRenderCallback&&this.onLoadRenderCallback.call(this.callbackContext,this.game)},destroy:function(){this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onPausedCallback=null,this.onDestroyCallback=null,this.game=null,this.states={},this._pendingState=null}},e.LinkedList=function(){this.next=null,this.prev=null,this.first=null,this.last=null,this.total=0},e.LinkedList.prototype={add:function(a){return 0==this.total&&null==this.first&&null==this.last?(this.first=a,this.last=a,this.next=a,a.prev=this,this.total++,a):(this.last.next=a,a.prev=this.last,this.last=a,this.total++,a)},remove:function(a){a==this.first?this.first=this.first.next:a==this.last&&(this.last=this.last.prev),a.prev&&(a.prev.next=a.next),a.next&&(a.next.prev=a.prev),a.next=a.prev=null,null==this.first&&(this.last=null),this.total--},callAll:function(a){if(this.first&&this.last){var b=this.first;do b&&b[a]&&b[a].call(b),b=b.next;while(b!=this.last.next)}}},e.Signal=function(){this._bindings=[],this._prevParams=null;var a=this;this.dispatch=function(){e.Signal.prototype.dispatch.apply(a,arguments)}},e.Signal.prototype={memorize:!1,_shouldPropagate:!0,active:!0,validateListener:function(a,b){if("function"!=typeof a)throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",b))},_registerListener:function(a,b,c,d){var f,g=this._indexOfListener(a,c);if(-1!==g){if(f=this._bindings[g],f.isOnce()!==b)throw new Error("You cannot add"+(b?"":"Once")+"() then add"+(b?"Once":"")+"() the same listener without removing the relationship first.")}else f=new e.SignalBinding(this,a,b,c,d),this._addBinding(f);return this.memorize&&this._prevParams&&f.execute(this._prevParams),f},_addBinding:function(a){var b=this._bindings.length;do--b;while(this._bindings[b]&&a._priority<=this._bindings[b]._priority);this._bindings.splice(b+1,0,a)},_indexOfListener:function(a,b){for(var c,d=this._bindings.length;d--;)if(c=this._bindings[d],c._listener===a&&c.context===b)return d;return-1},has:function(a,b){return-1!==this._indexOfListener(a,b)},add:function(a,b,c){return this.validateListener(a,"add"),this._registerListener(a,!1,b,c)},addOnce:function(a,b,c){return this.validateListener(a,"addOnce"),this._registerListener(a,!0,b,c)},remove:function(a,b){this.validateListener(a,"remove");var c=this._indexOfListener(a,b);return-1!==c&&(this._bindings[c]._destroy(),this._bindings.splice(c,1)),a},removeAll:function(){for(var a=this._bindings.length;a--;)this._bindings[a]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(){if(this.active){var a,b=Array.prototype.slice.call(arguments),c=this._bindings.length;if(this.memorize&&(this._prevParams=b),c){a=this._bindings.slice(),this._shouldPropagate=!0;do c--;while(a[c]&&this._shouldPropagate&&a[c].execute(b)!==!1)}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(),delete this._bindings,delete this._prevParams},toString:function(){return"[Phaser.Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}},e.SignalBinding=function(a,b,c,d,e){this._listener=b,this._isOnce=c,this.context=d,this._signal=a,this._priority=e||0},e.SignalBinding.prototype={active:!0,params:null,execute:function(a){var b,c;return this.active&&this._listener&&(c=this.params?this.params.concat(a):a,b=this._listener.apply(this.context,c),this._isOnce&&this.detach()),b},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[Phaser.SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},e.Plugin=function(a,b){"undefined"==typeof b&&(b=null),this.game=a,this.parent=b,this.active=!1,this.visible=!1,this.hasPreUpdate=!1,this.hasUpdate=!1,this.hasPostUpdate=!1,this.hasRender=!1,this.hasPostRender=!1},e.Plugin.prototype={preUpdate:function(){},update:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null,this.parent=null,this.active=!1,this.visible=!1}},e.PluginManager=function(a,b){this.game=a,this._parent=b,this.plugins=[],this._pluginsLength=0},e.PluginManager.prototype={add:function(a){var b=!1;return"function"==typeof a?a=new a(this.game,this._parent):(a.game=this.game,a.parent=this._parent),"function"==typeof a.preUpdate&&(a.hasPreUpdate=!0,b=!0),"function"==typeof a.update&&(a.hasUpdate=!0,b=!0),"function"==typeof a.postUpdate&&(a.hasPostUpdate=!0,b=!0),"function"==typeof a.render&&(a.hasRender=!0,b=!0),"function"==typeof a.postRender&&(a.hasPostRender=!0,b=!0),b?((a.hasPreUpdate||a.hasUpdate)&&(a.active=!0),(a.hasRender||a.hasPostRender)&&(a.visible=!0),this._pluginsLength=this.plugins.push(a),"function"==typeof a.init&&a.init(),a):null},remove:function(a){if(0!=this._pluginsLength)for(this._p=0;this._pthis._nextOffsetCheck&&(e.Canvas.getOffset(this.canvas,this.offset),this._nextOffsetCheck=this.game.time.now+this.checkOffsetInterval)},visibilityChange:function(a){this.disableVisibilityChange||(this.game.paused="pagehide"==a.type||"blur"==a.type||1==document.hidden||1==document.webkitHidden?!0:!1)}},Object.defineProperty(e.Stage.prototype,"backgroundColor",{get:function(){return this._backgroundColor},set:function(a){this._backgroundColor=a,this.game.renderType==e.CANVAS?this._stage.backgroundColorString=a:("string"==typeof a&&(a=e.Color.hexToRGB(a)),this._stage.setBackgroundColor(a))}}),e.Group=function(a,b,c,f){("undefined"==typeof b||null===typeof b)&&(b=a.world),"undefined"==typeof f&&(f=!1),this.game=a,this.name=c||"group",f?this._container=this.game.stage._stage:(this._container=new d.DisplayObjectContainer,this._container.name=this.name,b?b instanceof e.Group?(b._container.addChild(this._container),b._container.updateTransform()):(b.addChild(this._container),b.updateTransform()):(this.game.stage._stage.addChild(this._container),this.game.stage._stage.updateTransform())),this.type=e.GROUP,this.exists=!0,this.scale=new e.Point(1,1),this.cursor=null},e.Group.RETURN_NONE=0,e.Group.RETURN_TOTAL=1,e.Group.RETURN_CHILD=2,e.Group.SORT_ASCENDING=-1,e.Group.SORT_DESCENDING=1,e.Group.prototype={add:function(a){return a.group!==this&&(a.group=this,a.events&&a.events.onAddedToGroup.dispatch(a,this),this._container.addChild(a),a.updateTransform(),null===this.cursor&&(this.cursor=a)),a},addAt:function(a,b){return a.group!==this&&(a.group=this,a.events&&a.events.onAddedToGroup.dispatch(a,this),this._container.addChildAt(a,b),a.updateTransform(),null===this.cursor&&(this.cursor=a)),a},getAt:function(a){return this._container.getChildAt(a)},create:function(a,b,c,d,f){"undefined"==typeof f&&(f=!0);var g=new e.Sprite(this.game,a,b,c,d);return g.group=this,g.exists=f,g.visible=f,g.alive=f,g.events&&g.events.onAddedToGroup.dispatch(g,this),this._container.addChild(g),g.updateTransform(),null===this.cursor&&(this.cursor=g),g},createMultiple:function(a,b,c,d){"undefined"==typeof d&&(d=!1);for(var f=0;a>f;f++){var g=new e.Sprite(this.game,0,0,b,c);g.group=this,g.exists=d,g.visible=d,g.alive=d,g.events&&g.events.onAddedToGroup.dispatch(g,this),this._container.addChild(g),g.updateTransform(),null===this.cursor&&(this.cursor=g)}},next:function(){this.cursor&&(this.cursor=this.cursor==this._container.last?this._container._iNext:this.cursor._iNext)},previous:function(){this.cursor&&(this.cursor=this.cursor==this._container._iNext?this._container.last:this.cursor._iPrev)},childTest:function(a,b){var c=a+" next: ";c+=b._iNext?b._iNext.name:"-null-",c=c+" "+a+" prev: ",c+=b._iPrev?b._iPrev.name:"-null-",console.log(c)},swapIndex:function(a,b){var c=this.getAt(a),d=this.getAt(b);console.log("swapIndex ",a," with ",b),this.swap(c,d)},swap:function(a,b){if(a===b||!a.parent||!b.parent||a.group!==this||b.group!==this)return!1;var c=a._iPrev,d=a._iNext,e=b._iPrev,f=b._iNext,g=this._container.last._iNext,h=this.game.stage._stage;do h!==a&&h!==b&&(h.first===a?h.first=b:h.first===b&&(h.first=a),h.last===a?h.last=b:h.last===b&&(h.last=a)),h=h._iNext;while(h!=g);return a._iNext==b?(a._iNext=f,a._iPrev=b,b._iNext=a,b._iPrev=c,c&&(c._iNext=b),f&&(f._iPrev=a),a.__renderGroup&&a.__renderGroup.updateTexture(a),b.__renderGroup&&b.__renderGroup.updateTexture(b),!0):b._iNext==a?(a._iNext=b,a._iPrev=e,b._iNext=d,b._iPrev=a,e&&(e._iNext=a),d&&(d._iPrev=b),a.__renderGroup&&a.__renderGroup.updateTexture(a),b.__renderGroup&&b.__renderGroup.updateTexture(b),!0):(a._iNext=f,a._iPrev=e,b._iNext=d,b._iPrev=c,c&&(c._iNext=b),d&&(d._iPrev=b),e&&(e._iNext=a),f&&(f._iPrev=a),a.__renderGroup&&a.__renderGroup.updateTexture(a),b.__renderGroup&&b.__renderGroup.updateTexture(b),!0)},bringToTop:function(a){return a.group===this&&(this.remove(a),this.add(a)),a},getIndex:function(a){return this._container.children.indexOf(a)},replace:function(a,b){if(this._container.first._iNext){var c=this.getIndex(a);-1!=c&&(void 0!=b.parent&&(b.events.onRemovedFromGroup.dispatch(b,this),b.parent.removeChild(b)),this._container.removeChild(a),this._container.addChildAt(b,c),b.events.onAddedToGroup.dispatch(b,this),b.updateTransform(),this.cursor==a&&(this.cursor=this._container._iNext))}},setProperty:function(a,b,c,d){d=d||0;var e=b.length;1==e?0==d?a[b[0]]=c:1==d?a[b[0]]+=c:2==d?a[b[0]]-=c:3==d?a[b[0]]*=c:4==d&&(a[b[0]]/=c):2==e?0==d?a[b[0]][b[1]]=c:1==d?a[b[0]][b[1]]+=c:2==d?a[b[0]][b[1]]-=c:3==d?a[b[0]][b[1]]*=c:4==d&&(a[b[0]][b[1]]/=c):3==e?0==d?a[b[0]][b[1]][b[2]]=c:1==d?a[b[0]][b[1]][b[2]]+=c:2==d?a[b[0]][b[1]][b[2]]-=c:3==d?a[b[0]][b[1]][b[2]]*=c:4==d&&(a[b[0]][b[1]][b[2]]/=c):4==e&&(0==d?a[b[0]][b[1]][b[2]][b[3]]=c:1==d?a[b[0]][b[1]][b[2]][b[3]]+=c:2==d?a[b[0]][b[1]][b[2]][b[3]]-=c:3==d?a[b[0]][b[1]][b[2]][b[3]]*=c:4==d&&(a[b[0]][b[1]][b[2]][b[3]]/=c))},setAll:function(a,b,c,d,e){if(a=a.split("."),"undefined"==typeof c&&(c=!1),"undefined"==typeof d&&(d=!1),e=e||0,this._container.children.length>0&&this._container.first._iNext){var f=this._container.first._iNext;do(0==c||c&&f.alive)&&(0==d||d&&f.visible)&&this.setProperty(f,a,b,e),f=f._iNext;while(f!=this._container.last._iNext)}},addAll:function(a,b,c,d){this.setAll(a,b,c,d,1)},subAll:function(a,b,c,d){this.setAll(a,b,c,d,2)},multiplyAll:function(a,b,c,d){this.setAll(a,b,c,d,3)},divideAll:function(a,b,c,d){this.setAll(a,b,c,d,4)},callAllExists:function(a,b){var c=Array.prototype.splice.call(arguments,2);if(this._container.children.length>0&&this._container.first._iNext){var d=this._container.first._iNext;do d.exists==b&&d[a]&&d[a].apply(d,c),d=d._iNext;while(d!=this._container.last._iNext)}},callbackFromArray:function(a,b,c){if(1==c){if(a[b[0]])return a[b[0]]}else if(2==c){if(a[b[0]][b[1]])return a[b[0]][b[1]]}else if(3==c){if(a[b[0]][b[1]][b[2]])return a[b[0]][b[1]][b[2]]}else if(4==c){if(a[b[0]][b[1]][b[2]][b[3]])return a[b[0]][b[1]][b[2]][b[3]]}else if(a[b])return a[b];return!1},callAll:function(a,b){if("undefined"!=typeof a){a=a.split(".");var c=a.length;if("undefined"==typeof b)b=null;else if("string"==typeof b){b=b.split(".");var d=b.length}var e=Array.prototype.splice.call(arguments,2),f=null;if(this._container.children.length>0&&this._container.first._iNext){var g=this._container.first._iNext;do f=this.callbackFromArray(g,a,c),b&&f?(callbackContext=this.callbackFromArray(g,b,d),f&&f.apply(callbackContext,e)):f&&f.apply(g,e),g=g._iNext;while(g!=this._container.last._iNext)}}},forEach:function(a,b,c){"undefined"==typeof c&&(c=!1);var d=Array.prototype.splice.call(arguments,3);if(d.unshift(null),this._container.children.length>0&&this._container.first._iNext){var e=this._container.first._iNext;do(0==c||c&&e.exists)&&(d[0]=e,a.apply(b,d)),e=e._iNext;while(e!=this._container.last._iNext)}},forEachExists:function(a,b){var c=Array.prototype.splice.call(arguments,2);c.unshift(null),this.iterate("exists",!0,e.Group.RETURN_TOTAL,a,b,c)},forEachAlive:function(a,b){var c=Array.prototype.splice.call(arguments,2);c.unshift(null),this.iterate("alive",!0,e.Group.RETURN_TOTAL,a,b,c)},forEachDead:function(a,b){var c=Array.prototype.splice.call(arguments,2);c.unshift(null),this.iterate("alive",!1,e.Group.RETURN_TOTAL,a,b,c)},sort:function(a,b){"undefined"==typeof a&&(a="y"),"undefined"==typeof b&&(b=e.Group.SORT_ASCENDING);var c,d;do{c=!1;for(var f=0,g=this._container.children.length-1;g>f;f++)b==e.Group.SORT_ASCENDING?this._container.children[f][a]>this._container.children[f+1][a]&&(this.swap(this.getAt(f),this.getAt(f+1)),d=this._container.children[f],this._container.children[f]=this._container.children[f+1],this._container.children[f+1]=d,c=!0):this._container.children[f][a]0&&this._container.first._iNext){var i=this._container.first._iNext;do{if(i[a]===b&&(h++,d&&(g[0]=i,d.apply(f,g)),c==e.Group.RETURN_CHILD))return i;i=i._iNext}while(i!=this._container.last._iNext)}return c==e.Group.RETURN_TOTAL?h:c==e.Group.RETURN_CHILD?null:void 0},getFirstExists:function(a){return"boolean"!=typeof a&&(a=!0),this.iterate("exists",a,e.Group.RETURN_CHILD)},getFirstAlive:function(){return this.iterate("alive",!0,e.Group.RETURN_CHILD)},getFirstDead:function(){return this.iterate("alive",!1,e.Group.RETURN_CHILD)},countLiving:function(){return this.iterate("alive",!0,e.Group.RETURN_TOTAL)},countDead:function(){return this.iterate("alive",!1,e.Group.RETURN_TOTAL)},getRandom:function(a,b){return 0==this._container.children.length?null:(a=a||0,b=b||this._container.children.length,this.game.math.getRandom(this._container.children,a,b))},remove:function(a){a.events&&a.events.onRemovedFromGroup.dispatch(a,this),this._container.removeChild(a),this.cursor==a&&(this.cursor=this._container._iNext?this._container._iNext:null),a.group=null},removeAll:function(){if(0!=this._container.children.length){do this._container.children[0].events&&this._container.children[0].events.onRemovedFromGroup.dispatch(this._container.children[0],this),this._container.removeChild(this._container.children[0]);while(this._container.children.length>0);this.cursor=null}},removeBetween:function(a,b){if(0!=this._container.children.length){if(a>b||0>a||b>this._container.children.length)return!1;for(var c=a;b>c;c++){var d=this._container.children[c];d.events.onRemovedFromGroup.dispatch(d,this),this._container.removeChild(d),this.cursor==d&&(this.cursor=this._container._iNext?this._container._iNext:null)}}},destroy:function(){this.removeAll(),this._container.parent.removeChild(this._container),this._container=null,this.game=null,this.exists=!1,this.cursor=null},validate:function(){var a=this.game.stage._stage.last._iNext,b=this.game.stage._stage,c=null,d=null,e=0;do{if(e>0){if(b!==c)return console.log("check next fail"),!1;if(b._iPrev!==d)return console.log("check previous fail"),!1}c=b._iNext,d=b,b=b._iNext,e++}while(b!=a);return!0},dump:function(a){"undefined"==typeof a&&(a=!1);var b=20,c="\n"+e.Utils.pad("Node",b)+"|"+e.Utils.pad("Next",b)+"|"+e.Utils.pad("Previous",b)+"|"+e.Utils.pad("First",b)+"|"+e.Utils.pad("Last",b);console.log(c);var c=e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b);if(console.log(c),a)var d=this.game.stage._stage.last._iNext,f=this.game.stage._stage;else var d=this._container.last._iNext,f=this._container;do{var g=f.name||"*";if(this.cursor==f)var g="> "+g;var h="-",i="-",j="-",k="-";f._iNext&&(h=f._iNext.name),f._iPrev&&(i=f._iPrev.name),f.first&&(j=f.first.name),f.last&&(k=f.last.name),"undefined"==typeof h&&(h="-"),"undefined"==typeof i&&(i="-"),"undefined"==typeof j&&(j="-"),"undefined"==typeof k&&(k="-");var c=e.Utils.pad(g,b)+"|"+e.Utils.pad(h,b)+"|"+e.Utils.pad(i,b)+"|"+e.Utils.pad(j,b)+"|"+e.Utils.pad(k,b);console.log(c),f=f._iNext}while(f!=d)}},Object.defineProperty(e.Group.prototype,"total",{get:function(){return this.iterate("exists",!0,e.Group.RETURN_TOTAL)}}),Object.defineProperty(e.Group.prototype,"length",{get:function(){return this.iterate("exists",!0,e.Group.RETURN_TOTAL)}}),Object.defineProperty(e.Group.prototype,"x",{get:function(){return this._container.position.x},set:function(a){this._container.position.x=a}}),Object.defineProperty(e.Group.prototype,"y",{get:function(){return this._container.position.y},set:function(a){this._container.position.y=a}}),Object.defineProperty(e.Group.prototype,"angle",{get:function(){return e.Math.radToDeg(this._container.rotation)},set:function(a){this._container.rotation=e.Math.degToRad(a)}}),Object.defineProperty(e.Group.prototype,"rotation",{get:function(){return this._container.rotation},set:function(a){this._container.rotation=a}}),Object.defineProperty(e.Group.prototype,"visible",{get:function(){return this._container.visible},set:function(a){this._container.visible=a}}),Object.defineProperty(e.Group.prototype,"alpha",{get:function(){return this._container.alpha},set:function(a){this._container.alpha=a}}),e.World=function(a){e.Group.call(this,a,null,"__world",!1),this.scale=new e.Point(1,1),this.bounds=new e.Rectangle(0,0,a.width,a.height),this.camera=null,this.currentRenderOrderID=0},e.World.prototype=Object.create(e.Group.prototype),e.World.prototype.constructor=e.World,e.World.prototype.boot=function(){this.camera=new e.Camera(this.game,0,0,0,this.game.width,this.game.height),this.camera.displayObject=this._container,this.game.camera=this.camera},e.World.prototype.update=function(){if(this.currentRenderOrderID=0,this.game.stage._stage.first._iNext){var a=this.game.stage._stage.first._iNext;do a.preUpdate&&a.preUpdate(),a.update&&a.update(),a=a._iNext;while(a!=this.game.stage._stage.last._iNext)}},e.World.prototype.postUpdate=function(){if(this.camera.update(),this.game.stage._stage.first._iNext){var a=this.game.stage._stage.first._iNext;do a.postUpdate&&a.postUpdate(),a=a._iNext;while(a!=this.game.stage._stage.last._iNext)}},e.World.prototype.setBounds=function(a,b,c,d){this.bounds.setTo(a,b,c,d),this.camera.bounds&&this.camera.bounds.setTo(a,b,c,d)},e.World.prototype.destroy=function(){this.camera.x=0,this.camera.y=0,this.game.input.reset(!0),this.removeAll()},Object.defineProperty(e.World.prototype,"width",{get:function(){return this.bounds.width},set:function(a){this.bounds.width=a}}),Object.defineProperty(e.World.prototype,"height",{get:function(){return this.bounds.height},set:function(a){this.bounds.height=a}}),Object.defineProperty(e.World.prototype,"centerX",{get:function(){return this.bounds.halfWidth}}),Object.defineProperty(e.World.prototype,"centerY",{get:function(){return this.bounds.halfHeight}}),Object.defineProperty(e.World.prototype,"randomX",{get:function(){return this.bounds.x<0?this.game.rnd.integerInRange(this.bounds.x,this.bounds.width-Math.abs(this.bounds.x)):this.game.rnd.integerInRange(this.bounds.x,this.bounds.width)}}),Object.defineProperty(e.World.prototype,"randomY",{get:function(){return this.bounds.y<0?this.game.rnd.integerInRange(this.bounds.y,this.bounds.height-Math.abs(this.bounds.y)):this.game.rnd.integerInRange(this.bounds.y,this.bounds.height)}}),Object.defineProperty(e.World.prototype,"visible",{get:function(){return this._container.visible},set:function(a){this._container.visible=a}}),e.Game=function(a,b,c,d,f,g,h){a=a||800,b=b||600,c=c||e.AUTO,d=d||"",f=f||null,"undefined"==typeof g&&(g=!1),"undefined"==typeof h&&(h=!0),this.id=e.GAMES.push(this)-1,this.parent=d,this.width=a,this.height=b,this.transparent=g,this.antialias=h,this.renderer=null,this.state=new e.StateManager(this,f),this._paused=!1,this.renderType=c,this._loadComplete=!1,this.isBooted=!1,this.isRunning=!1,this.raf=null,this.add=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.net=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.physics=null,this.rnd=null,this.device=null,this.camera=null,this.canvas=null,this.context=null,this.debug=null,this.particles=null;var i=this;return this._onBoot=function(){return i.boot()},"complete"===document.readyState||"interactive"===document.readyState?window.setTimeout(this._onBoot,0):(document.addEventListener("DOMContentLoaded",this._onBoot,!1),window.addEventListener("load",this._onBoot,!1)),this},e.Game.prototype={boot:function(){this.isBooted||(document.body?(document.removeEventListener("DOMContentLoaded",this._onBoot),window.removeEventListener("load",this._onBoot),this.onPause=new e.Signal,this.onResume=new e.Signal,this.isBooted=!0,this.device=new e.Device,this.math=e.Math,this.rnd=new e.RandomDataGenerator([(Date.now()*Math.random()).toString()]),this.stage=new e.Stage(this,this.width,this.height),this.setUpRenderer(),this.world=new e.World(this),this.add=new e.GameObjectFactory(this),this.cache=new e.Cache(this),this.load=new e.Loader(this),this.time=new e.Time(this),this.tweens=new e.TweenManager(this),this.input=new e.Input(this),this.sound=new e.SoundManager(this),this.physics=new e.Physics.Arcade(this),this.particles=new e.Particles(this),this.plugins=new e.PluginManager(this,this),this.net=new e.Net(this),this.debug=new e.Utils.Debug(this),this.stage.boot(),this.world.boot(),this.input.boot(),this.sound.boot(),this.state.boot(),this.load.onLoadComplete.add(this.loadComplete,this),this.showDebugHeader(),this.isRunning=!0,this._loadComplete=!1,this.raf=new e.RequestAnimationFrame(this),this.raf.start()):window.setTimeout(this._onBoot,20))},showDebugHeader:function(){var a=e.DEV_VERSION,b="Canvas",c="HTML Audio";if(this.renderType==e.WEBGL&&(b="WebGL"),this.device.webAudio&&(c="WebAudio"),this.device.chrome){var d=["%c %c %c Phaser v"+a+" - Renderer: "+b+" - Audio: "+c+" %c %c ","background: #00bff3","background: #0072bc","color: #ffffff; background: #003471","background: #0072bc","background: #00bff3"];console.log.apply(console,d)}else console.log("Phaser v"+a+" - Renderer: "+b+" - Audio: "+c)},setUpRenderer:function(){if(this.renderType===e.CANVAS||this.renderType===e.AUTO&&0==this.device.webGL){if(!this.device.canvas)throw new Error("Phaser.Game - cannot create Canvas or WebGL context, aborting.");this.renderType=e.CANVAS,this.renderer=new d.CanvasRenderer(this.width,this.height,this.stage.canvas,this.transparent),e.Canvas.setSmoothingEnabled(this.renderer.context,this.antialias),this.canvas=this.renderer.view,this.context=this.renderer.context}else this.renderType=e.WEBGL,this.renderer=new d.WebGLRenderer(this.width,this.height,this.stage.canvas,this.transparent,this.antialias),this.canvas=this.renderer.view,this.context=null;e.Canvas.addToDOM(this.renderer.view,this.parent,!0),e.Canvas.setTouchAction(this.renderer.view)},loadComplete:function(){this._loadComplete=!0,this.state.loadComplete()},update:function(a){this.time.update(a),this._paused?(this.renderer.render(this.stage._stage),this.plugins.render(),this.state.render()):(this.plugins.preUpdate(),this.physics.preUpdate(),this.stage.update(),this.input.update(),this.tweens.update(),this.sound.update(),this.world.update(),this.particles.update(),this.state.update(),this.plugins.update(),this.world.postUpdate(),this.plugins.postUpdate(),this.renderer.render(this.stage._stage),this.plugins.render(),this.state.render(),this.plugins.postRender())},destroy:function(){this.raf.stop(),this.input.destroy(),this.state.destroy(),this.state=null,this.cache=null,this.input=null,this.load=null,this.sound=null,this.stage=null,this.time=null,this.world=null,this.isBooted=!1}},Object.defineProperty(e.Game.prototype,"paused",{get:function(){return this._paused},set:function(a){a===!0?0==this._paused&&(this._paused=!0,this.onPause.dispatch(this)):this._paused&&(this._paused=!1,this.onResume.dispatch(this))}}),e.Input=function(a){this.game=a,this.hitCanvas=null,this.hitContext=null},e.Input.MOUSE_OVERRIDES_TOUCH=0,e.Input.TOUCH_OVERRIDES_MOUSE=1,e.Input.MOUSE_TOUCH_COMBINE=2,e.Input.prototype={game:null,pollRate:0,_pollCounter:0,_oldPosition:null,_x:0,_y:0,disabled:!1,multiInputOverride:e.Input.MOUSE_TOUCH_COMBINE,position:null,speed:null,circle:null,scale:null,maxPointers:10,currentPointers:0,tapRate:200,doubleTapRate:300,holdRate:2e3,justPressedRate:200,justReleasedRate:200,recordPointerHistory:!1,recordRate:100,recordLimit:100,pointer1:null,pointer2:null,pointer3:null,pointer4:null,pointer5:null,pointer6:null,pointer7:null,pointer8:null,pointer9:null,pointer10:null,activePointer:null,mousePointer:null,mouse:null,keyboard:null,touch:null,mspointer:null,onDown:null,onUp:null,onTap:null,onHold:null,interactiveItems:new e.LinkedList,boot:function(){this.mousePointer=new e.Pointer(this.game,0),this.pointer1=new e.Pointer(this.game,1),this.pointer2=new e.Pointer(this.game,2),this.mouse=new e.Mouse(this.game),this.keyboard=new e.Keyboard(this.game),this.touch=new e.Touch(this.game),this.mspointer=new e.MSPointer(this.game),this.onDown=new e.Signal,this.onUp=new e.Signal,this.onTap=new e.Signal,this.onHold=new e.Signal,this.scale=new e.Point(1,1),this.speed=new e.Point,this.position=new e.Point,this._oldPosition=new e.Point,this.circle=new e.Circle(0,0,44),this.activePointer=this.mousePointer,this.currentPointers=0,this.hitCanvas=document.createElement("canvas"),this.hitCanvas.width=1,this.hitCanvas.height=1,this.hitContext=this.hitCanvas.getContext("2d"),this.mouse.start(),this.keyboard.start(),this.touch.start(),this.mspointer.start(),this.mousePointer.active=!0 -},destroy:function(){this.mouse.stop(),this.keyboard.stop(),this.touch.stop(),this.mspointer.stop()},addPointer:function(){for(var a=0,b=10;b>0;b--)null===this["pointer"+b]&&(a=b);return 0==a?(console.warn("You can only have 10 Pointer objects"),null):(this["pointer"+a]=new e.Pointer(this.game,a),this["pointer"+a])},update:function(){return this.pollRate>0&&this._pollCounter=b;b++)this["pointer"+b]&&this["pointer"+b].reset();this.currentPointers=0,this.game.stage.canvas.style.cursor="default",1==a&&(this.onDown.dispose(),this.onUp.dispose(),this.onTap.dispose(),this.onHold.dispose(),this.onDown=new e.Signal,this.onUp=new e.Signal,this.onTap=new e.Signal,this.onHold=new e.Signal,this.interactiveItems.callAll("reset")),this._pollCounter=0}},resetSpeed:function(a,b){this._oldPosition.setTo(a,b),this.speed.setTo(0,0)},startPointer:function(a){if(this.maxPointers<10&&this.totalActivePointers==this.maxPointers)return null;if(0==this.pointer1.active)return this.pointer1.start(a);if(0==this.pointer2.active)return this.pointer2.start(a);for(var b=3;10>=b;b++)if(this["pointer"+b]&&0==this["pointer"+b].active)return this["pointer"+b].start(a);return null},updatePointer:function(a){if(this.pointer1.active&&this.pointer1.identifier==a.identifier)return this.pointer1.move(a);if(this.pointer2.active&&this.pointer2.identifier==a.identifier)return this.pointer2.move(a);for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].active&&this["pointer"+b].identifier==a.identifier)return this["pointer"+b].move(a);return null},stopPointer:function(a){if(this.pointer1.active&&this.pointer1.identifier==a.identifier)return this.pointer1.stop(a);if(this.pointer2.active&&this.pointer2.identifier==a.identifier)return this.pointer2.stop(a);for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].active&&this["pointer"+b].identifier==a.identifier)return this["pointer"+b].stop(a);return null},getPointer:function(a){if(a=a||!1,this.pointer1.active==a)return this.pointer1;if(this.pointer2.active==a)return this.pointer2;for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].active==a)return this["pointer"+b];return null},getPointerFromIdentifier:function(a){if(this.pointer1.identifier==a)return this.pointer1;if(this.pointer2.identifier==a)return this.pointer2;for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].identifier==a)return this["pointer"+b];return null}},Object.defineProperty(e.Input.prototype,"x",{get:function(){return this._x},set:function(a){this._x=Math.floor(a)}}),Object.defineProperty(e.Input.prototype,"y",{get:function(){return this._y},set:function(a){this._y=Math.floor(a)}}),Object.defineProperty(e.Input.prototype,"pollLocked",{get:function(){return this.pollRate>0&&this._pollCounter=a;a++)this["pointer"+a]&&this["pointer"+a].active&&this.currentPointers++;return this.currentPointers}}),Object.defineProperty(e.Input.prototype,"worldX",{get:function(){return this.game.camera.view.x+this.x}}),Object.defineProperty(e.Input.prototype,"worldY",{get:function(){return this.game.camera.view.y+this.y}}),e.Key=function(a,b){this.game=a,this.isDown=!1,this.isUp=!1,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.timeDown=0,this.duration=0,this.timeUp=0,this.repeats=0,this.keyCode=b,this.onDown=new e.Signal,this.onUp=new e.Signal},e.Key.prototype={processKeyDown:function(a){this.altKey=a.altKey,this.ctrlKey=a.ctrlKey,this.shiftKey=a.shiftKey,this.isDown?(this.duration=a.timeStamp-this.timeDown,this.repeats++):(this.isDown=!0,this.isUp=!1,this.timeDown=a.timeStamp,this.duration=0,this.repeats=0,this.onDown.dispatch(this))},processKeyUp:function(a){this.isDown=!1,this.isUp=!0,this.timeUp=a.timeStamp,this.onUp.dispatch(this)},justPressed:function(a){return"undefined"==typeof a&&(a=250),this.isDown&&this.duration=this.game.input.holdRate&&((this.game.input.multiInputOverride==e.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==e.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==e.Input.TOUCH_OVERRIDES_MOUSE&&0==this.game.input.currentPointers)&&this.game.input.onHold.dispatch(this),this._holdSent=!0),this.game.input.recordPointerHistory&&this.game.time.now>=this._nextDrop&&(this._nextDrop=this.game.time.now+this.game.input.recordRate,this._history.push({x:this.position.x,y:this.position.y}),this._history.length>this.game.input.recordLimit&&this._history.shift()))},move:function(a){if(!this.game.input.pollLocked){if("undefined"!=typeof a.button&&(this.button=a.button),this.clientX=a.clientX,this.clientY=a.clientY,this.pageX=a.pageX,this.pageY=a.pageY,this.screenX=a.screenX,this.screenY=a.screenY,this.x=(this.pageX-this.game.stage.offset.x)*this.game.input.scale.x,this.y=(this.pageY-this.game.stage.offset.y)*this.game.input.scale.y,this.position.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,(this.game.input.multiInputOverride==e.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==e.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==e.Input.TOUCH_OVERRIDES_MOUSE&&0==this.game.input.currentPointers)&&(this.game.input.activePointer=this,this.game.input.x=this.x,this.game.input.y=this.y,this.game.input.position.setTo(this.game.input.x,this.game.input.y),this.game.input.circle.x=this.game.input.x,this.game.input.circle.y=this.game.input.y),this.game.paused)return this;if(null!==this.targetObject&&1==this.targetObject.isDragged)return 0==this.targetObject.update(this)&&(this.targetObject=null),this;if(this._highestRenderOrderID=-1,this._highestRenderObject=null,this._highestInputPriorityID=-1,this.game.input.interactiveItems.total>0){var b=this.game.input.interactiveItems.next;do(b.pixelPerfect||b.priorityID>this._highestInputPriorityID||b.priorityID==this._highestInputPriorityID&&b.sprite.renderOrderID>this._highestRenderOrderID)&&b.checkPointerOver(this)&&(this._highestRenderOrderID=b.sprite.renderOrderID,this._highestInputPriorityID=b.priorityID,this._highestRenderObject=b),b=b.next;while(null!=b)}return null==this._highestRenderObject?this.targetObject&&(this.targetObject._pointerOutHandler(this),this.targetObject=null):null==this.targetObject?(this.targetObject=this._highestRenderObject,this._highestRenderObject._pointerOverHandler(this)):this.targetObject==this._highestRenderObject?0==this._highestRenderObject.update(this)&&(this.targetObject=null):(this.targetObject._pointerOutHandler(this),this.targetObject=this._highestRenderObject,this.targetObject._pointerOverHandler(this)),this}},leave:function(a){this.withinGame=!1,this.move(a)},stop:function(a){if(this._stateReset)return a.preventDefault(),void 0;if(this.timeUp=this.game.time.now,(this.game.input.multiInputOverride==e.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==e.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==e.Input.TOUCH_OVERRIDES_MOUSE&&0==this.game.input.currentPointers)&&(this.game.input.onUp.dispatch(this,a),this.duration>=0&&this.duration<=this.game.input.tapRate&&(this.timeUp-this.previousTapTime0&&(this.active=!1),this.withinGame=!1,this.isDown=!1,this.isUp=!0,0==this.isMouse&&this.game.input.currentPointers--,this.game.input.interactiveItems.total>0){var b=this.game.input.interactiveItems.next;do b&&b._releasedHandler(this),b=b.next;while(null!=b)}return this.targetObject&&this.targetObject._releasedHandler(this),this.targetObject=null,this},justPressed:function(a){return a=a||this.game.input.justPressedRate,this.isDown===!0&&this.timeDown+a>this.game.time.now},justReleased:function(a){return a=a||this.game.input.justReleasedRate,this.isUp===!0&&this.timeUp+a>this.game.time.now},reset:function(){0==this.isMouse&&(this.active=!1),this.identifier=null,this.isDown=!1,this.isUp=!0,this.totalTouches=0,this._holdSent=!1,this._history.length=0,this._stateReset=!0,this.targetObject&&this.targetObject._releasedHandler(this),this.targetObject=null},toString:function(){return"[{Pointer (id="+this.id+" identifer="+this.identifier+" active="+this.active+" duration="+this.duration+" withinGame="+this.withinGame+" x="+this.x+" y="+this.y+" clientX="+this.clientX+" clientY="+this.clientY+" screenX="+this.screenX+" screenY="+this.screenY+" pageX="+this.pageX+" pageY="+this.pageY+")}]"}},Object.defineProperty(e.Pointer.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.now-this.timeDown}}),Object.defineProperty(e.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x}}),Object.defineProperty(e.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y}}),e.Touch=function(a){this.game=a,this.disabled=!1,this.callbackContext=this.game,this.touchStartCallback=null,this.touchMoveCallback=null,this.touchEndCallback=null,this.touchEnterCallback=null,this.touchLeaveCallback=null,this.touchCancelCallback=null,this.preventDefault=!0,this._onTouchStart=null,this._onTouchMove=null,this._onTouchEnd=null,this._onTouchEnter=null,this._onTouchLeave=null,this._onTouchCancel=null,this._onTouchMove=null},e.Touch.prototype={start:function(){var a=this;this.game.device.touch&&(this._onTouchStart=function(b){return a.onTouchStart(b)},this._onTouchMove=function(b){return a.onTouchMove(b)},this._onTouchEnd=function(b){return a.onTouchEnd(b)},this._onTouchEnter=function(b){return a.onTouchEnter(b)},this._onTouchLeave=function(b){return a.onTouchLeave(b)},this._onTouchCancel=function(b){return a.onTouchCancel(b)},this.game.renderer.view.addEventListener("touchstart",this._onTouchStart,!1),this.game.renderer.view.addEventListener("touchmove",this._onTouchMove,!1),this.game.renderer.view.addEventListener("touchend",this._onTouchEnd,!1),this.game.renderer.view.addEventListener("touchenter",this._onTouchEnter,!1),this.game.renderer.view.addEventListener("touchleave",this._onTouchLeave,!1),this.game.renderer.view.addEventListener("touchcancel",this._onTouchCancel,!1))},consumeDocumentTouches:function(){this._documentTouchMove=function(a){a.preventDefault()},document.addEventListener("touchmove",this._documentTouchMove,!1)},onTouchStart:function(a){if(this.touchStartCallback&&this.touchStartCallback.call(this.callbackContext,a),!this.game.input.disabled&&!this.disabled){this.preventDefault&&a.preventDefault();for(var b=0;bc;c++)this._pointerData[c]={id:c,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1};this.snapOffset=new e.Point,this.enabled=!0,this.sprite.events&&null==this.sprite.events.onInputOver&&(this.sprite.events.onInputOver=new e.Signal,this.sprite.events.onInputOut=new e.Signal,this.sprite.events.onInputDown=new e.Signal,this.sprite.events.onInputUp=new e.Signal,this.sprite.events.onDragStart=new e.Signal,this.sprite.events.onDragStop=new e.Signal)}return this.sprite},reset:function(){this.enabled=!1;for(var a=0;10>a;a++)this._pointerData[a]={id:a,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1}},stop:function(){0!=this.enabled&&(this.enabled=!1,this.game.input.interactiveItems.remove(this))},destroy:function(){this.enabled&&(this.enabled=!1,this.game.input.interactiveItems.remove(this),this.stop(),this.sprite=null)},pointerX:function(a){return a=a||0,this._pointerData[a].x},pointerY:function(a){return a=a||0,this._pointerData[a].y},pointerDown:function(a){return a=a||0,this._pointerData[a].isDown},pointerUp:function(a){return a=a||0,this._pointerData[a].isUp},pointerTimeDown:function(a){return a=a||0,this._pointerData[a].timeDown},pointerTimeUp:function(a){return a=a||0,this._pointerData[a].timeUp},pointerOver:function(a){if(this.enabled){if("undefined"!=typeof a)return this._pointerData[a].isOver;for(var b=0;10>b;b++)if(this._pointerData[b].isOver)return!0}return!1},pointerOut:function(){if(this.enabled){if("undefined"!=typeof index)return this._pointerData[index].isOut;for(var a=0;10>a;a++)if(this._pointerData[a].isOut)return!0}return!1},pointerTimeOver:function(a){return a=a||0,this._pointerData[a].timeOver},pointerTimeOut:function(a){return a=a||0,this._pointerData[a].timeOut},pointerDragged:function(a){return a=a||0,this._pointerData[a].isDragged},checkPointerOver:function(a){return this.enabled&&this.sprite.visible&&(this.sprite.getLocalUnmodifiedPosition(this._tempPoint,a.x,a.y),this._tempPoint.x>=0&&this._tempPoint.x<=this.sprite.currentFrame.width&&this._tempPoint.y>=0&&this._tempPoint.y<=this.sprite.currentFrame.height)?this.pixelPerfect?this.checkPixel(this._tempPoint.x,this._tempPoint.y):!0:!1},checkPixel:function(a,b){if(this.sprite.texture.baseTexture.source){this.game.input.hitContext.clearRect(0,0,1,1),a+=this.sprite.texture.frame.x,b+=this.sprite.texture.frame.y,this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,a,b,1,1,0,0,1,1);var c=this.game.input.hitContext.getImageData(0,0,1,1);if(c.data[3]>=this.pixelPerfectAlpha)return!0}return!1},update:function(a){return 0==this.enabled||0==this.sprite.visible||this.sprite.group&&0==this.sprite.group.visible?(this._pointerOutHandler(a),!1):this.draggable&&this._draggedPointerID==a.id?this.updateDrag(a):1==this._pointerData[a.id].isOver?this.checkPointerOver(a)?(this._pointerData[a.id].x=a.x-this.sprite.x,this._pointerData[a.id].y=a.y-this.sprite.y,!0):(this._pointerOutHandler(a),!1):void 0},_pointerOverHandler:function(a){0==this._pointerData[a.id].isOver&&(this._pointerData[a.id].isOver=!0,this._pointerData[a.id].isOut=!1,this._pointerData[a.id].timeOver=this.game.time.now,this._pointerData[a.id].x=a.x-this.sprite.x,this._pointerData[a.id].y=a.y-this.sprite.y,this.useHandCursor&&0==this._pointerData[a.id].isDragged&&(this.game.stage.canvas.style.cursor="pointer"),this.sprite.events.onInputOver.dispatch(this.sprite,a))},_pointerOutHandler:function(a){this._pointerData[a.id].isOver=!1,this._pointerData[a.id].isOut=!0,this._pointerData[a.id].timeOut=this.game.time.now,this.useHandCursor&&0==this._pointerData[a.id].isDragged&&(this.game.stage.canvas.style.cursor="default"),this.sprite&&this.sprite.events&&this.sprite.events.onInputOut.dispatch(this.sprite,a)},_touchedHandler:function(a){return 0==this._pointerData[a.id].isDown&&1==this._pointerData[a.id].isOver&&(this._pointerData[a.id].isDown=!0,this._pointerData[a.id].isUp=!1,this._pointerData[a.id].timeDown=this.game.time.now,this.sprite.events.onInputDown.dispatch(this.sprite,a),this.draggable&&0==this.isDragged&&this.startDrag(a),this.bringToTop&&this.sprite.bringToTop()),this.consumePointerEvent},_releasedHandler:function(a){this._pointerData[a.id].isDown&&a.isUp&&(this._pointerData[a.id].isDown=!1,this._pointerData[a.id].isUp=!0,this._pointerData[a.id].timeUp=this.game.time.now,this._pointerData[a.id].downDuration=this._pointerData[a.id].timeUp-this._pointerData[a.id].timeDown,this.checkPointerOver(a)?this.sprite.events.onInputUp.dispatch(this.sprite,a):this.useHandCursor&&(this.game.stage.canvas.style.cursor="default"),this.draggable&&this.isDragged&&this._draggedPointerID==a.id&&this.stopDrag(a))},updateDrag:function(a){return a.isUp?(this.stopDrag(a),!1):(this.allowHorizontalDrag&&(this.sprite.x=a.x+this._dragPoint.x+this.dragOffset.x),this.allowVerticalDrag&&(this.sprite.y=a.y+this._dragPoint.y+this.dragOffset.y),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(this.sprite.x=Math.round(this.sprite.x/this.snapX)*this.snapX,this.sprite.y=Math.round(this.sprite.y/this.snapY)*this.snapY),!0)},justOver:function(a,b){return a=a||0,b=b||500,this._pointerData[a].isOver&&this.overDuration(a)a;a++)this._pointerData[a].isDragged=!1;this.draggable=!1,this.isDragged=!1,this._draggedPointerID=-1},startDrag:function(a){this.isDragged=!0,this._draggedPointerID=a.id,this._pointerData[a.id].isDragged=!0,this.dragFromCenter?(this.sprite.centerOn(a.x,a.y),this._dragPoint.setTo(this.sprite.x-a.x,this.sprite.y-a.y)):this._dragPoint.setTo(this.sprite.x-a.x,this.sprite.y-a.y),this.updateDrag(a),this.bringToTop&&this.sprite.bringToTop(),this.sprite.events.onDragStart.dispatch(this.sprite,a) -},stopDrag:function(a){this.isDragged=!1,this._draggedPointerID=-1,this._pointerData[a.id].isDragged=!1,this.snapOnRelease&&(this.sprite.x=Math.round(this.sprite.x/this.snapX)*this.snapX,this.sprite.y=Math.round(this.sprite.y/this.snapY)*this.snapY),this.sprite.events.onDragStop.dispatch(this.sprite,a),this.sprite.events.onInputUp.dispatch(this.sprite,a),0==this.checkPointerOver(a)&&this._pointerOutHandler(a)},setDragLock:function(a,b){"undefined"==typeof a&&(a=!0),"undefined"==typeof b&&(b=!0),this.allowHorizontalDrag=a,this.allowVerticalDrag=b},enableSnap:function(a,b,c,d){"undefined"==typeof c&&(c=!0),"undefined"==typeof d&&(d=!1),this.snapX=a,this.snapY=b,this.snapOnDrag=c,this.snapOnRelease=d},disableSnap:function(){this.snapOnDrag=!1,this.snapOnRelease=!1},checkBoundsRect:function(){this.sprite.xthis.boundsRect.right&&(this.sprite.x=this.boundsRect.right-this.sprite.width),this.sprite.ythis.boundsRect.bottom&&(this.sprite.y=this.boundsRect.bottom-this.sprite.height)},checkBoundsSprite:function(){this.sprite.xthis.boundsSprite.x+this.boundsSprite.width&&(this.sprite.x=this.boundsSprite.x+this.boundsSprite.width-this.sprite.width),this.sprite.ythis.boundsSprite.y+this.boundsSprite.height&&(this.sprite.y=this.boundsSprite.y+this.boundsSprite.height-this.sprite.height)}},e.Events=function(a){this.parent=a,this.onAddedToGroup=new e.Signal,this.onRemovedFromGroup=new e.Signal,this.onKilled=new e.Signal,this.onRevived=new e.Signal,this.onOutOfBounds=new e.Signal,this.onInputOver=null,this.onInputOut=null,this.onInputDown=null,this.onInputUp=null,this.onDragStart=null,this.onDragStop=null,this.onAnimationStart=null,this.onAnimationComplete=null,this.onAnimationLoop=null},e.Events.prototype={destroy:function(){this.parent=null,this.onAddedToGroup.dispose(),this.onRemovedFromGroup.dispose(),this.onKilled.dispose(),this.onRevived.dispose(),this.onOutOfBounds.dispose(),this.onInputOver&&(this.onInputOver.dispose(),this.onInputOut.dispose(),this.onInputDown.dispose(),this.onInputUp.dispose(),this.onDragStart.dispose(),this.onDragStop.dispose()),this.onAnimationStart&&(this.onAnimationStart.dispose(),this.onAnimationComplete.dispose(),this.onAnimationLoop.dispose())}},e.GameObjectFactory=function(a){this.game=a,this.world=this.game.world},e.GameObjectFactory.prototype={existing:function(a){return this.world.add(a)},sprite:function(a,b,c,d){return this.world.create(a,b,c,d)},child:function(a,b,c,d,e){return a.create(b,c,d,e)},tween:function(a){return this.game.tweens.create(a)},group:function(a,b){return new e.Group(this.game,a,b)},audio:function(a,b,c){return this.game.sound.add(a,b,c)},tileSprite:function(a,b,c,d,f,g){return this.world.add(new e.TileSprite(this.game,a,b,c,d,f,g))},text:function(a,b,c,d){return this.world.add(new e.Text(this.game,a,b,c,d))},button:function(a,b,c,d,f,g,h,i){return this.world.add(new e.Button(this.game,a,b,c,d,f,g,h,i))},graphics:function(a,b){return this.world.add(new e.Graphics(this.game,a,b))},emitter:function(a,b,c){return this.game.particles.add(new e.Particles.Arcade.Emitter(this.game,a,b,c))},bitmapText:function(a,b,c,d){return this.world.add(new e.BitmapText(this.game,a,b,c,d))},tilemap:function(a){return new e.Tilemap(this.game,a)},tileset:function(a){return this.game.cache.getTileset(a)},tilemapLayer:function(a,b,c,d,f,g,h){return this.world.add(new e.TilemapLayer(this.game,a,b,c,d,f,g,h))},renderTexture:function(a,b,c){var d=new e.RenderTexture(this.game,a,b,c);return this.game.cache.addRenderTexture(a,d),d},bitmapData:function(a,b){return new e.BitmapData(this.game,a,b)}},e.BitmapData=function(a,b,c){"undefined"==typeof b&&(b=256),"undefined"==typeof c&&(c=256),this.game=a,this.name="",this.width=b,this.height=c,this.canvas=e.Canvas.create(b,c),this.context=this.canvas.getContext("2d"),this.imageData=this.context.getImageData(0,0,b,c),this.pixels=this.imageData.data.buffer,this.baseTexture=new d.BaseTexture(this.canvas),this.texture=new d.Texture(this.baseTexture),this.textureFrame=new e.Frame(0,0,0,b,c,"bitmapData",a.rnd.uuid()),this.type=e.BITMAPDATA,this._dirty=!1},e.BitmapData.prototype={add:function(a){a.loadTexture(this)},addTo:function(){for(var a=0;a=0&&a<=this.width&&b>=0&&b<=this.height&&(this.pixels[b*this.width+a]=f<<24|e<<16|d<<8|c,this.context.putImageData(this.imageData,0,0),this._dirty=!0)},setPixel:function(a,b,c,d,e){this.setPixel32(a,b,c,d,e,255)},getPixel:function(a,b){return a>=0&&a<=this.width&&b>=0&&b<=this.height?this.data32[b*this.width+a]:void 0},getPixel32:function(a,b){return a>=0&&a<=this.width&&b>=0&&b<=this.height?this.data32[b*this.width+a]:void 0},getPixels:function(){},arc:function(a,b,c,d,e,f){return"undefined"==typeof f&&(f=!1),this._dirty=!0,this.context.arc(a,b,c,d,e,f),this},arcTo:function(a,b,c,d,e){return this._dirty=!0,this.context.arcTo(a,b,c,d,e),this},beginFill:function(a){return this.fillStyle(a),this},beginLinearGradientFill:function(a,b,c,d,e,f){for(var g=this.createLinearGradient(c,d,e,f),h=0,i=a.length;i>h;h++)g.addColorStop(b[h],a[h]);return this.fillStyle(g),this},beginLinearGradientStroke:function(a,b,c,d,e,f){for(var g=this.createLinearGradient(c,d,e,f),h=0,i=a.length;i>h;h++)g.addColorStop(b[h],a[h]);return this.strokeStyle(g),this},beginRadialGradientStroke:function(a,b,c,d,e,f,g,h){for(var i=this.createRadialGradient(c,d,e,f,g,h),j=0,k=a.length;k>j;j++)i.addColorStop(b[j],a[j]);return this.strokeStyle(i),this},beginPath:function(){return this.context.beginPath(),this},beginStroke:function(a){return this.strokeStyle(a),this},bezierCurveTo:function(a,b,c,d,e,f){return this._dirty=!0,this.context.bezierCurveTo(a,b,c,d,e,f),this},circle:function(a,b,c){return this.arc(a,b,c,0,2*Math.PI),this},clearRect:function(a,b,c,d){return this._dirty=!0,this.context.clearRect(a,b,c,d),this},clip:function(){return this._dirty=!0,this.context.clip(),this},closePath:function(){return this._dirty=!0,this.context.closePath(),this},createLinearGradient:function(a,b,c,d){return this.context.createLinearGradient(a,b,c,d)},createRadialGradient:function(){return this.context.createRadialGradient(x0,y0,r0,x1,y1,r1)},ellipse:function(a,b,c,d){var e=.5522848,f=c/2*e,g=d/2*e,h=a+c,i=b+d,j=a+c/2,k=b+d/2;return this.moveTo(a,k),this.bezierCurveTo(a,k-g,j-f,b,j,b),this.bezierCurveTo(j+f,b,h,k-g,h,k),this.bezierCurveTo(h,k+g,j+f,i,j,i),this.bezierCurveTo(j-f,i,a,k+g,a,k),this},fill:function(){return this._dirty=!0,this.context.fill(),this},fillRect:function(a,b,c,d){return this._dirty=!0,this.context.fillRect(a,b,c,d),this},fillStyle:function(a){return this.context.fillStyle=a,this},font:function(a){return this.context.font=a,this},globalAlpha:function(a){return this.context.globalAlpha=a,this},globalCompositeOperation:function(a){return this.context.globalCompositeOperation=a,this},lineCap:function(a){return this.context.lineCap=a,this},lineDashOffset:function(a){return this.context.lineDashOffset=a,this},lineJoin:function(a){return this.context.lineJoin=a,this},lineWidth:function(a){return this.context.lineWidth=a,this},miterLimit:function(a){return this.context.miterLimit=a,this},lineTo:function(a,b){return this._dirty=!0,this.context.lineTo(a,b),this},moveTo:function(a,b){return this.context.moveTo(a,b),this},quadraticCurveTo:function(a,b,c,d){return this._dirty=!0,this.context.quadraticCurveTo(a,b,c,d),this},rect:function(a,b,c,d){return this._dirty=!0,this.context.rect(a,b,c,d),this},restore:function(){return this._dirty=!0,this.context.restore(),this},rotate:function(a){return this._dirty=!0,this.context.rotate(a),this},setStrokeStyle:function(a,b,c,d){return"undefined"==typeof a&&(a=1),"undefined"==typeof b&&(b="butt"),"undefined"==typeof c&&(c="miter"),"undefined"==typeof d&&(d=10),this.lineWidth(a),this.lineCap(b),this.lineJoin(c),this.miterLimit(d),this},save:function(){return this._dirty=!0,this.context.save(),this},scale:function(a,b){return this._dirty=!0,this.context.scale(a,b),this},scrollPathIntoView:function(){return this._dirty=!0,this.context.scrollPathIntoView(),this},stroke:function(){return this._dirty=!0,this.context.stroke(),this},strokeRect:function(){return this._dirty=!0,this.context.strokeRect(x,y,width,height),this},strokeStyle:function(a){return this.context.strokeStyle=a,this},render:function(){this._dirty&&(this.game.renderType==e.WEBGL&&d.texturesToUpdate.push(this.baseTexture),this._dirty=!1)}},e.BitmapData.prototype.mt=e.BitmapData.prototype.moveTo,e.BitmapData.prototype.lt=e.BitmapData.prototype.lineTo,e.BitmapData.prototype.at=e.BitmapData.prototype.arcTo,e.BitmapData.prototype.bt=e.BitmapData.prototype.bezierCurveTo,e.BitmapData.prototype.qt=e.BitmapData.prototype.quadraticCurveTo,e.BitmapData.prototype.a=e.BitmapData.prototype.arc,e.BitmapData.prototype.r=e.BitmapData.prototype.rect,e.BitmapData.prototype.cp=e.BitmapData.prototype.closePath,e.BitmapData.prototype.c=e.BitmapData.prototype.clear,e.BitmapData.prototype.f=e.BitmapData.prototype.beginFill,e.BitmapData.prototype.lf=e.BitmapData.prototype.beginLinearGradientFill,e.BitmapData.prototype.rf=e.BitmapData.prototype.beginRadialGradientFill,e.BitmapData.prototype.ef=e.BitmapData.prototype.endFill,e.BitmapData.prototype.ss=e.BitmapData.prototype.setStrokeStyle,e.BitmapData.prototype.s=e.BitmapData.prototype.beginStroke,e.BitmapData.prototype.ls=e.BitmapData.prototype.beginLinearGradientStroke,e.BitmapData.prototype.rs=e.BitmapData.prototype.beginRadialGradientStroke,e.BitmapData.prototype.dr=e.BitmapData.prototype.rect,e.BitmapData.prototype.dc=e.BitmapData.prototype.circle,e.BitmapData.prototype.de=e.BitmapData.prototype.ellipse,e.Sprite=function(a,b,c,f,g){b=b||0,c=c||0,f=f||null,g=g||null,this.game=a,this.exists=!0,this.alive=!0,this.group=null,this.name="",this.type=e.SPRITE,this.renderOrderID=-1,this.lifespan=0,this.events=new e.Events(this),this.animations=new e.AnimationManager(this),this.input=new e.InputHandler(this),this.key=f,this.currentFrame=null,f instanceof e.RenderTexture?(d.Sprite.call(this,f),this.currentFrame=this.game.cache.getTextureFrame(f.name)):f instanceof e.BitmapData?(d.Sprite.call(this,f.texture,f.textureFrame),this.currentFrame=f.textureFrame):f instanceof d.Texture?(d.Sprite.call(this,f),this.currentFrame=g):((null==f||0==this.game.cache.checkImageKey(f))&&(f="__default",this.key=f),d.Sprite.call(this,d.TextureCache[f]),this.game.cache.isSpriteSheet(f)?(this.animations.loadFrameData(this.game.cache.getFrameData(f)),null!==g&&("string"==typeof g?this.frameName=g:this.frame=g)):this.currentFrame=this.game.cache.getFrame(f)),this.textureRegion=new e.Rectangle(this.texture.frame.x,this.texture.frame.y,this.texture.frame.width,this.texture.frame.height),this.anchor=new e.Point,this.x=b,this.y=c,this.position.x=b,this.position.y=c,this.world=new e.Point(b,c),this.autoCull=!1,this.scale=new e.Point(1,1),this._cache={dirty:!1,a00:-1,a01:-1,a02:-1,a10:-1,a11:-1,a12:-1,id:-1,i01:-1,i10:-1,idi:-1,left:null,right:null,top:null,bottom:null,prevX:b,prevY:c,x:-1,y:-1,scaleX:1,scaleY:1,width:this.currentFrame.sourceSizeW,height:this.currentFrame.sourceSizeH,halfWidth:Math.floor(this.currentFrame.sourceSizeW/2),halfHeight:Math.floor(this.currentFrame.sourceSizeH/2),calcWidth:-1,calcHeight:-1,frameID:-1,frameWidth:this.currentFrame.width,frameHeight:this.currentFrame.height,cameraVisible:!0,cropX:0,cropY:0,cropWidth:this.currentFrame.sourceSizeW,cropHeight:this.currentFrame.sourceSizeH},this.offset=new e.Point,this.center=new e.Point(b+Math.floor(this._cache.width/2),c+Math.floor(this._cache.height/2)),this.topLeft=new e.Point(b,c),this.topRight=new e.Point(b+this._cache.width,c),this.bottomRight=new e.Point(b+this._cache.width,c+this._cache.height),this.bottomLeft=new e.Point(b,c+this._cache.height),this.bounds=new e.Rectangle(b,c,this._cache.width,this._cache.height),this.body=new e.Physics.Arcade.Body(this),this.health=1,this.inWorld=e.Rectangle.intersects(this.bounds,this.game.world.bounds),this.inWorldThreshold=0,this.outOfBoundsKill=!1,this._outOfBoundsFired=!1,this.fixedToCamera=!1,this.cameraOffset=new e.Point,this.crop=new e.Rectangle(0,0,this._cache.width,this._cache.height),this.cropEnabled=!1,this.updateCache(),this.updateBounds()},e.Sprite.prototype=Object.create(d.Sprite.prototype),e.Sprite.prototype.constructor=e.Sprite,e.Sprite.prototype.preUpdate=function(){return!this.exists||this.group&&!this.group.exists?(this.renderOrderID=-1,void 0):this.lifespan>0&&(this.lifespan-=this.game.time.elapsed,this.lifespan<=0)?(this.kill(),void 0):(this._cache.dirty=!1,this.visible&&(this.renderOrderID=this.game.world.currentRenderOrderID++),this.updateCache(),this.updateAnimation(),this.updateCrop(),(this._cache.dirty||this.world.x!==this._cache.prevX||this.world.y!==this._cache.prevY)&&this.updateBounds(),this.body&&this.body.preUpdate(),void 0)},e.Sprite.prototype.updateCache=function(){this._cache.prevX=this.world.x,this._cache.prevY=this.world.y,this.fixedToCamera&&(this.x=this.game.camera.view.x+this.cameraOffset.x,this.y=this.game.camera.view.y+this.cameraOffset.y),this.world.setTo(this.game.camera.x+this.worldTransform[2],this.game.camera.y+this.worldTransform[5]),(this.worldTransform[1]!=this._cache.i01||this.worldTransform[3]!=this._cache.i10||this.worldTransform[0]!=this._cache.a00||this.worldTransform[41]!=this._cache.a11)&&(this._cache.a00=this.worldTransform[0],this._cache.a01=this.worldTransform[1],this._cache.a10=this.worldTransform[3],this._cache.a11=this.worldTransform[4],this._cache.i01=this.worldTransform[1],this._cache.i10=this.worldTransform[3],this._cache.scaleX=Math.sqrt(this._cache.a00*this._cache.a00+this._cache.a01*this._cache.a01),this._cache.scaleY=Math.sqrt(this._cache.a10*this._cache.a10+this._cache.a11*this._cache.a11),this._cache.a01*=-1,this._cache.a10*=-1,this._cache.id=1/(this._cache.a00*this._cache.a11+this._cache.a01*-this._cache.a10),this._cache.idi=1/(this._cache.a00*this._cache.a11+this._cache.i01*-this._cache.i10),this._cache.dirty=!0),this._cache.a02=this.worldTransform[2],this._cache.a12=this.worldTransform[5]},e.Sprite.prototype.updateAnimation=function(){(this.animations.update()||this.currentFrame&&this.currentFrame.uuid!=this._cache.frameID)&&(this._cache.frameID=this.currentFrame.uuid,this._cache.frameWidth=this.texture.frame.width,this._cache.frameHeight=this.texture.frame.height,this._cache.width=this.currentFrame.width,this._cache.height=this.currentFrame.height,this._cache.halfWidth=Math.floor(this._cache.width/2),this._cache.halfHeight=Math.floor(this._cache.height/2),this._cache.dirty=!0)},e.Sprite.prototype.updateCrop=function(){!this.cropEnabled||this.crop.width==this._cache.cropWidth&&this.crop.height==this._cache.cropHeight&&this.crop.x==this._cache.cropX&&this.crop.y==this._cache.cropY||(this.crop.floorAll(),this._cache.cropX=this.crop.x,this._cache.cropY=this.crop.y,this._cache.cropWidth=this.crop.width,this._cache.cropHeight=this.crop.height,this.texture.frame=this.crop,this.texture.width=this.crop.width,this.texture.height=this.crop.height,this.texture.updateFrame=!0,d.Texture.frameUpdates.push(this.texture))},e.Sprite.prototype.updateBounds=function(){this.offset.setTo(this._cache.a02-this.anchor.x*this.width,this._cache.a12-this.anchor.y*this.height),this.getLocalPosition(this.center,this.offset.x+this.width/2,this.offset.y+this.height/2),this.getLocalPosition(this.topLeft,this.offset.x,this.offset.y),this.getLocalPosition(this.topRight,this.offset.x+this.width,this.offset.y),this.getLocalPosition(this.bottomLeft,this.offset.x,this.offset.y+this.height),this.getLocalPosition(this.bottomRight,this.offset.x+this.width,this.offset.y+this.height),this._cache.left=e.Math.min(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x),this._cache.right=e.Math.max(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x),this._cache.top=e.Math.min(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y),this._cache.bottom=e.Math.max(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y),this.bounds.setTo(this._cache.left,this._cache.top,this._cache.right-this._cache.left,this._cache.bottom-this._cache.top),this.updateFrame=!0,0==this.inWorld?(this.inWorld=e.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold),this.inWorld&&(this._outOfBoundsFired=!1)):(this.inWorld=e.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold),0==this.inWorld&&(this.events.onOutOfBounds.dispatch(this),this._outOfBoundsFired=!0,this.outOfBoundsKill&&this.kill())),this._cache.cameraVisible=e.Rectangle.intersects(this.game.world.camera.screenView,this.bounds,0),this.autoCull&&(this.renderable=this._cache.cameraVisible),this.body&&this.body.updateBounds(this.center.x,this.center.y,this._cache.scaleX,this._cache.scaleY)},e.Sprite.prototype.getLocalPosition=function(a,b,c){return a.x=(this._cache.a11*this._cache.id*b+-this._cache.a01*this._cache.id*c+(this._cache.a12*this._cache.a01-this._cache.a02*this._cache.a11)*this._cache.id)*this.scale.x+this._cache.a02,a.y=(this._cache.a00*this._cache.id*c+-this._cache.a10*this._cache.id*b+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.a10)*this._cache.id)*this.scale.y+this._cache.a12,a},e.Sprite.prototype.getLocalUnmodifiedPosition=function(a,b,c){return a.x=this._cache.a11*this._cache.idi*b+-this._cache.i01*this._cache.idi*c+(this._cache.a12*this._cache.i01-this._cache.a02*this._cache.a11)*this._cache.idi+this.anchor.x*this._cache.width,a.y=this._cache.a00*this._cache.idi*c+-this._cache.i10*this._cache.idi*b+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.i10)*this._cache.idi+this.anchor.y*this._cache.height,a},e.Sprite.prototype.resetCrop=function(){this.crop=new e.Rectangle(0,0,this._cache.width,this._cache.height),this.texture.setFrame(this.crop),this.cropEnabled=!1},e.Sprite.prototype.postUpdate=function(){this.key instanceof e.BitmapData&&this.key._dirty&&this.key.render(),this.exists&&(this.body&&this.body.postUpdate(),this.fixedToCamera?(this._cache.x=this.game.camera.view.x+this.cameraOffset.x,this._cache.y=this.game.camera.view.y+this.cameraOffset.y):(this._cache.x=this.x,this._cache.y=this.y),this.world.setTo(this.game.camera.x+this.worldTransform[2],this.game.camera.y+this.worldTransform[5]),this.position.x=this._cache.x,this.position.y=this._cache.y)},e.Sprite.prototype.loadTexture=function(a,b){this.key=a,a instanceof e.RenderTexture?this.currentFrame=this.game.cache.getTextureFrame(a.name):a instanceof e.BitmapData?(this.setTexture(a.texture),this.currentFrame=a.textureFrame):a instanceof d.Texture?this.currentFrame=b:(("undefined"==typeof a||this.game.cache.checkImageKey(a)===!1)&&(a="__default",this.key=a),this.game.cache.isSpriteSheet(a)?(this.animations.loadFrameData(this.game.cache.getFrameData(a)),"undefined"!=typeof b&&("string"==typeof b?this.frameName=b:this.frame=b)):(this.currentFrame=this.game.cache.getFrame(a),this.setTexture(d.TextureCache[a])))},e.Sprite.prototype.centerOn=function(a,b){return this.x=a+(this.x-this.center.x),this.y=b+(this.y-this.center.y),this},e.Sprite.prototype.revive=function(a){return"undefined"==typeof a&&(a=1),this.alive=!0,this.exists=!0,this.visible=!0,this.health=a,this.events&&this.events.onRevived.dispatch(this),this},e.Sprite.prototype.kill=function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.events&&this.events.onKilled.dispatch(this),this},e.Sprite.prototype.destroy=function(){this.group&&this.group.remove(this),this.input&&this.input.destroy(),this.events&&this.events.destroy(),this.animations&&this.animations.destroy(),this.alive=!1,this.exists=!1,this.visible=!1,this.game=null},e.Sprite.prototype.damage=function(a){return this.alive&&(this.health-=a,this.health<0&&this.kill()),this},e.Sprite.prototype.reset=function(a,b,c){return"undefined"==typeof c&&(c=1),this.x=a,this.y=b,this.position.x=this.x,this.position.y=this.y,this.alive=!0,this.exists=!0,this.visible=!0,this.renderable=!0,this._outOfBoundsFired=!1,this.health=c,this.body&&this.body.reset(),this},e.Sprite.prototype.bringToTop=function(){return this.group?this.group.bringToTop(this):this.game.world.bringToTop(this),this},e.Sprite.prototype.play=function(a,b,c,d){return this.animations?this.animations.play(a,b,c,d):void 0},Object.defineProperty(e.Sprite.prototype,"angle",{get:function(){return e.Math.wrapAngle(e.Math.radToDeg(this.rotation))},set:function(a){this.rotation=e.Math.degToRad(e.Math.wrapAngle(a))}}),Object.defineProperty(e.Sprite.prototype,"frame",{get:function(){return this.animations.frame},set:function(a){this.animations.frame=a}}),Object.defineProperty(e.Sprite.prototype,"frameName",{get:function(){return this.animations.frameName},set:function(a){this.animations.frameName=a}}),Object.defineProperty(e.Sprite.prototype,"inCamera",{get:function(){return this._cache.cameraVisible}}),Object.defineProperty(e.Sprite.prototype,"width",{get:function(){return this.scale.x*this.currentFrame.width},set:function(a){this.scale.x=a/this.currentFrame.width,this._cache.scaleX=a/this.currentFrame.width,this._width=a}}),Object.defineProperty(e.Sprite.prototype,"height",{get:function(){return this.scale.y*this.currentFrame.height},set:function(a){this.scale.y=a/this.currentFrame.height,this._cache.scaleY=a/this.currentFrame.height,this._height=a}}),Object.defineProperty(e.Sprite.prototype,"inputEnabled",{get:function(){return this.input.enabled},set:function(a){a?0==this.input.enabled&&this.input.start():this.input.enabled&&this.input.stop()}}),e.TileSprite=function(a,b,c,f,g,h,i){b=b||0,c=c||0,f=f||256,g=g||256,h=h||null,i=i||null,e.Sprite.call(this,a,b,c,h,i),this.texture=d.TextureCache[h],d.TilingSprite.call(this,this.texture,f,g),this.type=e.TILESPRITE,this.tileScale=new e.Point(1,1),this.tilePosition=new e.Point(0,0)},e.TileSprite.prototype=e.Utils.extend(!0,d.TilingSprite.prototype,e.Sprite.prototype),e.TileSprite.prototype.constructor=e.TileSprite,e.Text=function(a,b,c,f,g){b=b||0,c=c||0,f=f||"",g=g||"",this.exists=!0,this.alive=!0,this.group=null,this.name="",this.game=a,this._text=f,this._style=g,d.Text.call(this,f,g),this.type=e.TEXT,this.position.x=this.x=b,this.position.y=this.y=c,this.anchor=new e.Point,this.scale=new e.Point(1,1),this._cache={dirty:!1,a00:1,a01:0,a02:b,a10:0,a11:1,a12:c,id:1,x:-1,y:-1,scaleX:1,scaleY:1},this._cache.x=this.x,this._cache.y=this.y,this.renderable=!0},e.Text.prototype=Object.create(d.Text.prototype),e.Text.prototype.constructor=e.Text,e.Text.prototype.update=function(){this.exists&&(this._cache.dirty=!1,this._cache.x=this.x,this._cache.y=this.y,(this.position.x!=this._cache.x||this.position.y!=this._cache.y)&&(this.position.x=this._cache.x,this.position.y=this._cache.y,this._cache.dirty=!0))},e.Text.prototype.destroy=function(){this.group&&this.group.remove(this),this.canvas.parentNode?this.canvas.parentNode.removeChild(this.canvas):(this.canvas=null,this.context=null),this.exists=!1,this.group=null},Object.defineProperty(e.Text.prototype,"angle",{get:function(){return e.Math.radToDeg(this.rotation)},set:function(a){this.rotation=e.Math.degToRad(a)}}),Object.defineProperty(e.Text.prototype,"content",{get:function(){return this._text},set:function(a){a!==this._text&&(this._text=a,this.setText(a))}}),Object.defineProperty(e.Text.prototype,"font",{get:function(){return this._style},set:function(a){a!==this._style&&(this._style=a,this.setStyle(a))}}),e.BitmapText=function(a,b,c,f,g){b=b||0,c=c||0,f=f||"",g=g||"",this.exists=!0,this.alive=!0,this.group=null,this.name="",this.game=a,d.BitmapText.call(this,f,g),this.type=e.BITMAPTEXT,this.position.x=b,this.position.y=c,this.anchor=new e.Point,this.scale=new e.Point(1,1),this._cache={dirty:!1,a00:1,a01:0,a02:b,a10:0,a11:1,a12:c,id:1,x:-1,y:-1,scaleX:1,scaleY:1},this._cache.x=this.x,this._cache.y=this.y,this.renderable=!0},e.BitmapText.prototype=Object.create(d.BitmapText.prototype),e.BitmapText.prototype.constructor=e.BitmapText,e.BitmapText.prototype.update=function(){this.exists&&(this._cache.dirty=!1,this._cache.x=this.x,this._cache.y=this.y,(this.position.x!=this._cache.x||this.position.y!=this._cache.y)&&(this.position.x=this._cache.x,this.position.y=this._cache.y,this._cache.dirty=!0),this.pivot.x=this.anchor.x*this.width,this.pivot.y=this.anchor.y*this.height)},e.BitmapText.prototype.destroy=function(){this.group&&this.group.remove(this),this.canvas&&this.canvas.parentNode?this.canvas.parentNode.removeChild(this.canvas):(this.canvas=null,this.context=null),this.exists=!1,this.group=null},Object.defineProperty(e.BitmapText.prototype,"angle",{get:function(){return e.Math.radToDeg(this.rotation)},set:function(a){this.rotation=e.Math.degToRad(a)}}),Object.defineProperty(e.BitmapText.prototype,"x",{get:function(){return this.position.x},set:function(a){this.position.x=a}}),Object.defineProperty(e.BitmapText.prototype,"y",{get:function(){return this.position.y},set:function(a){this.position.y=a}}),e.Button=function(a,b,c,d,f,g,h,i,j){b=b||0,c=c||0,d=d||null,f=f||null,g=g||this,e.Sprite.call(this,a,b,c,d,i),this.type=e.BUTTON,this._onOverFrameName=null,this._onOutFrameName=null,this._onDownFrameName=null,this._onUpFrameName=null,this._onOverFrameID=null,this._onOutFrameID=null,this._onDownFrameID=null,this._onUpFrameID=null,this.onOverSound=null,this.onOutSound=null,this.onDownSound=null,this.onUpSound=null,this.onOverSoundMarker="",this.onOutSoundMarker="",this.onDownSoundMarker="",this.onUpSoundMarker="",this.onInputOver=new e.Signal,this.onInputOut=new e.Signal,this.onInputDown=new e.Signal,this.onInputUp=new e.Signal,this.freezeFrames=!1,this.forceOut=!0,this.setFrames(h,i,j),null!==f&&this.onInputUp.add(f,g),this.input.start(0,!0),this.events.onInputOver.add(this.onInputOverHandler,this),this.events.onInputOut.add(this.onInputOutHandler,this),this.events.onInputDown.add(this.onInputDownHandler,this),this.events.onInputUp.add(this.onInputUpHandler,this)},e.Button.prototype=Object.create(e.Sprite.prototype),e.Button.prototype=e.Utils.extend(!0,e.Button.prototype,e.Sprite.prototype,d.Sprite.prototype),e.Button.prototype.constructor=e.Button,e.Button.prototype.setFrames=function(a,b,c){null!==a&&("string"==typeof a?(this._onOverFrameName=a,this.input.pointerOver()&&(this.frameName=a)):(this._onOverFrameID=a,this.input.pointerOver()&&(this.frame=a))),null!==b&&("string"==typeof b?(this._onOutFrameName=b,this._onUpFrameName=b,0==this.input.pointerOver()&&(this.frameName=b)):(this._onOutFrameID=b,this._onUpFrameID=b,0==this.input.pointerOver()&&(this.frame=b))),null!==c&&("string"==typeof c?(this._onDownFrameName=c,this.input.pointerDown()&&(this.frameName=c)):(this._onDownFrameID=c,this.input.pointerDown()&&(this.frame=c)))},e.Button.prototype.setSounds=function(a,b,c,d,e,f,g,h){this.setOverSound(a,b),this.setOutSound(e,f),this.setUpSound(g,h),this.setDownSound(c,d)},e.Button.prototype.setOverSound=function(a,b){this.onOverSound=null,this.onOverSoundMarker="",a instanceof e.Sound&&(this.onOverSound=a),"string"==typeof b&&(this.onOverSoundMarker=b)},e.Button.prototype.setOutSound=function(a,b){this.onOutSound=null,this.onOutSoundMarker="",a instanceof e.Sound&&(this.onOutSound=a),"string"==typeof b&&(this.onOutSoundMarker=b)},e.Button.prototype.setUpSound=function(a,b){this.onUpSound=null,this.onUpSoundMarker="",a instanceof e.Sound&&(this.onUpSound=a),"string"==typeof b&&(this.onUpSoundMarker=b)},e.Button.prototype.setDownSound=function(a,b){this.onDownSound=null,this.onDownSoundMarker="",a instanceof e.Sound&&(this.onDownSound=a),"string"==typeof b&&(this.onDownSoundMarker=b)},e.Button.prototype.onInputOverHandler=function(a){0==this.freezeFrames&&(null!=this._onOverFrameName?this.frameName=this._onOverFrameName:null!=this._onOverFrameID&&(this.frame=this._onOverFrameID)),this.onOverSound&&this.onOverSound.play(this.onOverSoundMarker),this.onInputOver&&this.onInputOver.dispatch(this,a)},e.Button.prototype.onInputOutHandler=function(a){0==this.freezeFrames&&(null!=this._onOutFrameName?this.frameName=this._onOutFrameName:null!=this._onOutFrameID&&(this.frame=this._onOutFrameID)),this.onOutSound&&this.onOutSound.play(this.onOutSoundMarker),this.onInputOut&&this.onInputOut.dispatch(this,a)},e.Button.prototype.onInputDownHandler=function(a){0==this.freezeFrames&&(null!=this._onDownFrameName?this.frameName=this._onDownFrameName:null!=this._onDownFrameID&&(this.frame=this._onDownFrameID)),this.onDownSound&&this.onDownSound.play(this.onDownSoundMarker),this.onInputDown&&this.onInputDown.dispatch(this,a)},e.Button.prototype.onInputUpHandler=function(a){0==this.freezeFrames&&(null!=this._onUpFrameName?this.frameName=this._onUpFrameName:null!=this._onUpFrameID&&(this.frame=this._onUpFrameID)),this.onUpSound&&this.onUpSound.play(this.onUpSoundMarker),this.forceOut&&0==this.freezeFrames&&(null!=this._onOutFrameName?this.frameName=this._onOutFrameName:null!=this._onOutFrameID&&(this.frame=this._onOutFrameID)),this.onInputUp&&this.onInputUp.dispatch(this,a)},e.Graphics=function(a,b,c){this.game=a,d.Graphics.call(this),this.type=e.GRAPHICS,this.position.x=b,this.position.y=c},e.Graphics.prototype=Object.create(d.Graphics.prototype),e.Graphics.prototype.constructor=e.Graphics,e.Graphics.prototype.destroy=function(){this.clear(),this.group&&this.group.remove(this),this.game=null},e.Graphics.prototype.drawPolygon=function(a){graphics.moveTo(a.points[0].x,a.points[0].y);for(var b=1;bh;h++)f[h].updateTransform();var j=a.__renderGroup;j?a==j.root?j.render(this.projection,this.glFramebuffer):j.renderSpecific(a,this.projection,this.glFramebuffer):(this.renderGroup||(this.renderGroup=new d.WebGLRenderGroup(e)),this.renderGroup.setRenderable(a),this.renderGroup.render(this.projection,this.glFramebuffer)),a.worldTransform=g},e.RenderTexture.prototype.renderCanvas=function(a,b,c){var e=a.children;a.worldTransform=d.mat3.create(),b&&(a.worldTransform[2]=b.x,a.worldTransform[5]=b.y);for(var f=0,g=e.length;g>f;f++)e[f].updateTransform();c&&this.renderer.context.clearRect(0,0,this.width,this.height),this.renderer.renderDisplayObject(a),this.renderer.context.setTransform(1,0,0,1,0,0)},e.Canvas={create:function(a,b){a=a||256,b=b||256;var c=document.createElement("canvas");return c.width=a,c.height=b,c.style.display="block",c},getOffset:function(a,b){b=b||new e.Point;var c=a.getBoundingClientRect(),d=a.clientTop||document.body.clientTop||0,f=a.clientLeft||document.body.clientLeft||0,g=window.pageYOffset||a.scrollTop||document.body.scrollTop,h=window.pageXOffset||a.scrollLeft||document.body.scrollLeft;return b.x=c.left+h-f,b.y=c.top+g-d,b},getAspectRatio:function(a){return a.width/a.height},setBackgroundColor:function(a,b){return b=b||"rgb(0,0,0)",a.style.backgroundColor=b,a},setTouchAction:function(a,b){return b=b||"none",a.style.msTouchAction=b,a.style["ms-touch-action"]=b,a.style["touch-action"]=b,a},setUserSelect:function(a,b){return b=b||"none",a.style["-webkit-touch-callout"]=b,a.style["-webkit-user-select"]=b,a.style["-khtml-user-select"]=b,a.style["-moz-user-select"]=b,a.style["-ms-user-select"]=b,a.style["user-select"]=b,a.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",a},addToDOM:function(a,b,c){var d;return"undefined"==typeof c&&(c=!0),b&&("string"==typeof b?d=document.getElementById(b):"object"==typeof b&&1===b.nodeType&&(d=b),c&&(d.style.overflow="hidden")),d||(d=document.body),d.appendChild(a),a},setTransform:function(a,b,c,d,e,f,g){return a.setTransform(d,f,g,e,b,c),a},setSmoothingEnabled:function(a,b){return a.imageSmoothingEnabled=b,a.mozImageSmoothingEnabled=b,a.oImageSmoothingEnabled=b,a.webkitImageSmoothingEnabled=b,a.msImageSmoothingEnabled=b,a},setImageRenderingCrisp:function(a){return a.style["image-rendering"]="crisp-edges",a.style["image-rendering"]="-moz-crisp-edges",a.style["image-rendering"]="-webkit-optimize-contrast",a.style.msInterpolationMode="nearest-neighbor",a},setImageRenderingBicubic:function(a){return a.style["image-rendering"]="auto",a.style.msInterpolationMode="bicubic",a}},e.StageScaleMode=function(a,b,c){this.game=a,this.width=b,this.height=c,this.minWidth=null,this.maxWidth=null,this.minHeight=null,this.maxHeight=null,this._startHeight=0,this.forceLandscape=!1,this.forcePortrait=!1,this.incorrectOrientation=!1,this.pageAlignHorizontally=!1,this.pageAlignVertically=!1,this._width=0,this._height=0,this.maxIterations=5,this.orientationSprite=null,this.enterLandscape=new e.Signal,this.enterPortrait=new e.Signal,this.orientation=window.orientation?window.orientation:window.outerWidth>window.outerHeight?90:0,this.scaleFactor=new e.Point(1,1),this.aspectRatio=0;var d=this;window.addEventListener("orientationchange",function(a){return d.checkOrientation(a)},!1),window.addEventListener("resize",function(a){return d.checkResize(a)},!1),document.addEventListener("webkitfullscreenchange",function(a){return d.fullScreenChange(a)},!1),document.addEventListener("mozfullscreenchange",function(a){return d.fullScreenChange(a)},!1),document.addEventListener("fullscreenchange",function(a){return d.fullScreenChange(a)},!1)},e.StageScaleMode.EXACT_FIT=0,e.StageScaleMode.NO_SCALE=1,e.StageScaleMode.SHOW_ALL=2,e.StageScaleMode.prototype={startFullScreen:function(a){if(!this.isFullScreen){"undefined"!=typeof a&&e.Canvas.setSmoothingEnabled(this.game.context,a);var b=this.game.canvas;this._width=this.width,this._height=this.height,console.log("startFullScreen",this._width,this._height),b.requestFullScreen?b.requestFullScreen():b.mozRequestFullScreen?b.mozRequestFullScreen():b.webkitRequestFullScreen&&b.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}},stopFullScreen:function(){document.cancelFullScreen?document.cancelFullScreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen()},fullScreenChange:function(){this.isFullScreen?(this.game.stage.canvas.style.width="100%",this.game.stage.canvas.style.height="100%",this.setMaximum(),this.game.input.scale.setTo(this.game.width/this.width,this.game.height/this.height),this.aspectRatio=this.width/this.height,this.scaleFactor.x=this.game.width/this.width,this.scaleFactor.y=this.game.height/this.height):(this.game.stage.canvas.style.width=this.game.width+"px",this.game.stage.canvas.style.height=this.game.height+"px",this.width=this._width,this.height=this._height,this.game.input.scale.setTo(this.game.width/this.width,this.game.height/this.height),this.aspectRatio=this.width/this.height,this.scaleFactor.x=this.game.width/this.width,this.scaleFactor.y=this.game.height/this.height)},forceOrientation:function(a,b,c){"undefined"==typeof b&&(b=!1),this.forceLandscape=a,this.forcePortrait=b,"undefined"!=typeof c&&((null==c||0==this.game.cache.checkImageKey(c))&&(c="__default"),this.orientationSprite=new d.Sprite(d.TextureCache[c]),this.orientationSprite.anchor.x=.5,this.orientationSprite.anchor.y=.5,this.orientationSprite.position.x=this.game.width/2,this.orientationSprite.position.y=this.game.height/2,this.checkOrientationState(),this.incorrectOrientation?(this.orientationSprite.visible=!0,this.game.world.visible=!1):(this.orientationSprite.visible=!1,this.game.world.visible=!0),this.game.stage._stage.addChild(this.orientationSprite))},checkOrientationState:function(){this.incorrectOrientation?(this.forceLandscape&&window.innerWidth>window.innerHeight||this.forcePortrait&&window.innerHeight>window.innerWidth)&&(this.game.paused=!1,this.incorrectOrientation=!1,this.orientationSprite&&(this.orientationSprite.visible=!1,this.game.world.visible=!0),this.refresh()):(this.forceLandscape&&window.innerWidthwindow.outerHeight?90:0,this.isLandscape?this.enterLandscape.dispatch(this.orientation,!0,!1):this.enterPortrait.dispatch(this.orientation,!1,!0),this.game.stage.scaleMode!==e.StageScaleMode.NO_SCALE&&this.refresh(),this.checkOrientationState()},refresh:function(){var a=this;0==this.game.device.iPad&&0==this.game.device.webApp&&0==this.game.device.desktop&&(this.game.device.android&&0==this.game.device.chrome?window.scrollTo(0,1):window.scrollTo(0,0)),null==this._check&&this.maxIterations>0&&(this._iterations=this.maxIterations,this._check=window.setInterval(function(){return a.setScreenSize()},10),this.setScreenSize())},setScreenSize:function(a){"undefined"==typeof a&&(a=!1),0==this.game.device.iPad&&0==this.game.device.webApp&&0==this.game.device.desktop&&(this.game.device.android&&0==this.game.device.chrome?window.scrollTo(0,1):window.scrollTo(0,0)),this._iterations--,(a||window.innerHeight>this._startHeight||this._iterations<0)&&(document.documentElement.style.minHeight=window.innerHeight+"px",1==this.incorrectOrientation?this.setMaximum():this.game.stage.scaleMode==e.StageScaleMode.EXACT_FIT?this.setExactFit():this.game.stage.scaleMode==e.StageScaleMode.SHOW_ALL&&this.setShowAll(),this.setSize(),clearInterval(this._check),this._check=null)},setSize:function(){0==this.incorrectOrientation&&(this.maxWidth&&this.width>this.maxWidth&&(this.width=this.maxWidth),this.maxHeight&&this.height>this.maxHeight&&(this.height=this.maxHeight),this.minWidth&&this.widththis.maxWidth?this.maxWidth:a,this.height=this.maxHeight&&b>this.maxHeight?this.maxHeight:b}},Object.defineProperty(e.StageScaleMode.prototype,"isFullScreen",{get:function(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement}}),Object.defineProperty(e.StageScaleMode.prototype,"isPortrait",{get:function(){return 0==this.orientation||180==this.orientation}}),Object.defineProperty(e.StageScaleMode.prototype,"isLandscape",{get:function(){return 90===this.orientation||-90===this.orientation}}),e.Device=function(){this.patchAndroidClearRectBug=!1,this.desktop=!1,this.iOS=!1,this.android=!1,this.chromeOS=!1,this.linux=!1,this.macOS=!1,this.windows=!1,this.canvas=!1,this.file=!1,this.fileSystem=!1,this.localStorage=!1,this.webGL=!1,this.worker=!1,this.touch=!1,this.mspointer=!1,this.css3D=!1,this.pointerLock=!1,this.arora=!1,this.chrome=!1,this.epiphany=!1,this.firefox=!1,this.ie=!1,this.ieVersion=0,this.mobileSafari=!1,this.midori=!1,this.opera=!1,this.safari=!1,this.webApp=!1,this.audioData=!1,this.webAudio=!1,this.ogg=!1,this.opus=!1,this.mp3=!1,this.wav=!1,this.m4a=!1,this.webm=!1,this.iPhone=!1,this.iPhone4=!1,this.iPad=!1,this.pixelRatio=0,this.littleEndian=!1,this._checkAudio(),this._checkBrowser(),this._checkCSS3D(),this._checkDevice(),this._checkFeatures(),this._checkOS()},e.Device.prototype={_checkOS:function(){var a=navigator.userAgent;/Android/.test(a)?this.android=!0:/CrOS/.test(a)?this.chromeOS=!0:/iP[ao]d|iPhone/i.test(a)?this.iOS=!0:/Linux/.test(a)?this.linux=!0:/Mac OS/.test(a)?this.macOS=!0:/Windows/.test(a)&&(this.windows=!0),(this.windows||this.macOS||this.linux)&&(this.desktop=!0)},_checkFeatures:function(){this.canvas=!!window.CanvasRenderingContext2D;try{this.localStorage=!!localStorage.getItem}catch(a){this.localStorage=!1}this.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),this.fileSystem=!!window.requestFileSystem,this.webGL=function(){try{var a=document.createElement("canvas");return!!window.WebGLRenderingContext&&(a.getContext("webgl")||a.getContext("experimental-webgl"))}catch(b){return!1}}(),this.webGL=null===this.webGL||this.webGL===!1?!1:!0,this.worker=!!window.Worker,("ontouchstart"in document.documentElement||window.navigator.msPointerEnabled)&&(this.touch=!0),window.navigator.msPointerEnabled&&(this.mspointer=!0),this.pointerLock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document},_checkBrowser:function(){var a=navigator.userAgent;/Arora/.test(a)?this.arora=!0:/Chrome/.test(a)?this.chrome=!0:/Epiphany/.test(a)?this.epiphany=!0:/Firefox/.test(a)?this.firefox=!0:/Mobile Safari/.test(a)?this.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(a)?(this.ie=!0,this.ieVersion=parseInt(RegExp.$1)):/Midori/.test(a)?this.midori=!0:/Opera/.test(a)?this.opera=!0:/Safari/.test(a)&&(this.safari=!0),navigator.standalone&&(this.webApp=!0)},_checkAudio:function(){this.audioData=!!window.Audio,this.webAudio=!(!window.webkitAudioContext&&!window.AudioContext);var a=document.createElement("audio"),b=!1;try{(b=!!a.canPlayType)&&(a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.ogg=!0),a.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")&&(this.opus=!0),a.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(this.mp3=!0),a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(this.wav=!0),(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;").replace(/^no$/,""))&&(this.m4a=!0),a.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")&&(this.webm=!0))}catch(c){}},_checkDevice:function(){this.pixelRatio=window.devicePixelRatio||1,this.iPhone=-1!=navigator.userAgent.toLowerCase().indexOf("iphone"),this.iPhone4=2==this.pixelRatio&&this.iPhone,this.iPad=-1!=navigator.userAgent.toLowerCase().indexOf("ipad"),"undefined"!=typeof Int8Array&&(this.littleEndian=new Int8Array(new Int16Array([1]).buffer)[0]>0)},_checkCSS3D:function(){var a,b=document.createElement("p"),c={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(b,null);for(var d in c)void 0!==b.style[d]&&(b.style[d]="translate3d(1px,1px,1px)",a=window.getComputedStyle(b).getPropertyValue(c[d]));document.body.removeChild(b),this.css3D=void 0!==a&&a.length>0&&"none"!==a},canPlayAudio:function(a){return"mp3"==a&&this.mp3?!0:"ogg"==a&&(this.ogg||this.opus)?!0:"m4a"==a&&this.m4a?!0:"wav"==a&&this.wav?!0:"webm"==a&&this.webm?!0:!1},isConsoleOpen:function(){return window.console&&window.console.firebug?!0:window.console?(console.profile(),console.profileEnd(),console.clear&&console.clear(),console.profiles.length>0):!1}},e.RequestAnimationFrame=function(a){this.game=a,this.isRunning=!1;for(var b=["ms","moz","webkit","o"],c=0;c>>0,b-=d,b*=d,d=b>>>0,b-=d,d+=4294967296*b;return 2.3283064365386963e-10*(d>>>0)},integer:function(){return 4294967296*this.rnd.apply(this)},frac:function(){return this.rnd.apply(this)+1.1102230246251565e-16*(0|2097152*this.rnd.apply(this))},real:function(){return this.integer()+this.frac()},integerInRange:function(a,b){return Math.floor(this.realInRange(a,b))},realInRange:function(a,b){return this.frac()*(b-a)+a},normal:function(){return 1-2*this.frac()},uuid:function(){var a,b;for(b=a="";a++<36;b+=~a%5|4&3*a?(15^a?8^this.frac()*(20^a?16:4):4).toString(16):"-");return b},pick:function(a){return a[this.integerInRange(0,a.length)]},weightedPick:function(a){return a[~~(Math.pow(this.frac(),2)*a.length)]},timestamp:function(a,b){return this.realInRange(a||9466848e5,b||1577862e6)},angle:function(){return this.integerInRange(-180,180)}},e.Math={PI2:2*Math.PI,fuzzyEqual:function(a,b,c){return"undefined"==typeof c&&(c=1e-4),Math.abs(a-b)a},fuzzyGreaterThan:function(a,b,c){return"undefined"==typeof c&&(c=1e-4),a>b-c},fuzzyCeil:function(a,b){return"undefined"==typeof b&&(b=1e-4),Math.ceil(a-b)},fuzzyFloor:function(a,b){return"undefined"==typeof b&&(b=1e-4),Math.floor(a+b)},average:function(){for(var a=[],b=0;b0?Math.floor(a):Math.ceil(a)},shear:function(a){return a%1},snapTo:function(a,b,c){return"undefined"==typeof c&&(c=0),0==b?a:(a-=c,a=b*Math.round(a/b),c+a)},snapToFloor:function(a,b,c){return"undefined"==typeof c&&(c=0),0==b?a:(a-=c,a=b*Math.floor(a/b),c+a)},snapToCeil:function(a,b,c){return"undefined"==typeof c&&(c=0),0==b?a:(a-=c,a=b*Math.ceil(a/b),c+a)},snapToInArray:function(a,b,c){if("undefined"==typeof c&&(c=!0),c&&b.sort(),a=f-a?f:e},roundTo:function(a,b,c){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=10);var d=Math.pow(c,-b);return Math.round(a*d)/d},floorTo:function(a,b,c){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=10);var d=Math.pow(c,-b);return Math.floor(a*d)/d},ceilTo:function(a,b,c){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=10);var d=Math.pow(c,-b);return Math.ceil(a*d)/d},interpolateFloat:function(a,b,c){return(b-a)*c+a},angleBetween:function(a,b,c,d){return Math.atan2(d-b,c-a)},normalizeAngle:function(a,b){"undefined"==typeof b&&(b=!0);var c=b?GameMath.PI:180;return this.wrap(a,c,-c)},nearestAngleBetween:function(a,b,c){"undefined"==typeof c&&(c=!0);var d=c?Math.PI:180;return a=this.normalizeAngle(a,c),b=this.normalizeAngle(b,c),-d/2>a&&b>d/2&&(a+=2*d),-d/2>b&&a>d/2&&(b+=2*d),b-a},interpolateAngles:function(a,b,c,d,e){return"undefined"==typeof d&&(d=!0),"undefined"==typeof e&&(e=null),a=this.normalizeAngle(a,d),b=this.normalizeAngleToAnother(b,a,d),"function"==typeof e?e(c,a,b-a,1):this.interpolateFloat(a,b,c)},chanceRoll:function(a){return"undefined"==typeof a&&(a=50),0>=a?!1:a>=100?!0:100*Math.random()>=a?!1:!0},numberArray:function(a,b){for(var c=[],d=a;b>=d;d++)c.push(d);return c},maxAdd:function(a,b,c){return a+=b,a>c&&(a=c),a},minSub:function(a,b,c){return a-=b,c>a&&(a=c),a},wrap:function(a,b,c){var d=c-b;if(0>=d)return 0;var e=(a-b)%d;return 0>e&&(e+=d),e+b},wrapValue:function(a,b,c){var d;return a=Math.abs(a),b=Math.abs(b),c=Math.abs(c),d=(a+b)%c},randomSign:function(){return Math.random()>.5?1:-1},isOdd:function(a){return 1&a},isEven:function(a){return 1&a?!1:!0},max:function(){for(var a=1,b=0,c=arguments.length;c>a;a++)arguments[b]a;a++)arguments[a]=-180&&180>=a?a:(b=(a+180)%360,0>b&&(b+=360),b-180)},angleLimit:function(a,b,c){var d=a;return a>c?d=c:b>a&&(d=b),d},linearInterpolation:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d);return 0>b?this.linear(a[0],a[1],d):b>1?this.linear(a[c],a[c-1],c-d):this.linear(a[e],a[e+1>c?c:e+1],d-e)},bezierInterpolation:function(a,b){for(var c=0,d=a.length-1,e=0;d>=e;e++)c+=Math.pow(1-b,d-e)*Math.pow(b,e)*a[e]*this.bernstein(d,e);return c},catmullRomInterpolation:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d);return a[0]===a[c]?(0>b&&(e=Math.floor(d=c*(1+b))),this.catmullRom(a[(e-1+c)%c],a[e],a[(e+1)%c],a[(e+2)%c],d-e)):0>b?a[0]-(this.catmullRom(a[0],a[0],a[1],a[1],-d)-a[0]):b>1?a[c]-(this.catmullRom(a[c],a[c],a[c-1],a[c-1],d-c)-a[c]):this.catmullRom(a[e?e-1:0],a[e],a[e+1>c?c:e+1],a[e+2>c?c:e+2],d-e)},linear:function(a,b,c){return(b-a)*c+a},bernstein:function(a,b){return this.factorial(a)/this.factorial(b)/this.factorial(a-b)},catmullRom:function(a,b,c,d,e){var f=.5*(c-a),g=.5*(d-b),h=e*e,i=e*h;return(2*b-2*c+f+g)*i+(-3*b+3*c-2*f-g)*h+f*e+b},difference:function(a,b){return Math.abs(a-b)},getRandom:function(a,b,c){if("undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=0),null!=a){var d=c;if((0==d||d>a.length-b)&&(d=a.length-b),d>0)return a[b+Math.floor(Math.random()*d)]}return null},floor:function(a){var b=0|a;return a>0?b:b!=a?b-1:b},ceil:function(a){var b=0|a;return a>0?b!=a?b+1:b:b},sinCosGenerator:function(a,b,c,d){"undefined"==typeof b&&(b=1),"undefined"==typeof c&&(c=1),"undefined"==typeof d&&(d=1);for(var e=b,f=c,g=d*Math.PI/a,h=[],i=[],j=0;a>j;j++)f-=e*g,e+=f*g,h[j]=f,i[j]=e;return{sin:i,cos:h,length:a}},shift:function(a){var b=a.shift();return a.push(b),b},shuffleArray:function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},distance:function(a,b,c,d){var e=a-c,f=b-d;return Math.sqrt(e*e+f*f)},distanceRounded:function(a,b,c,d){return Math.round(e.Math.distance(a,b,c,d))},clamp:function(a,b,c){return b>a?b:a>c?c:a},clampBottom:function(a,b){return b>a?b:a},within:function(a,b,c){return Math.abs(a-b)<=c},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},smoothstep:function(a,b,c){return b>=a?0:a>=c?1:(a=(a-b)/(c-b),a*a*(3-2*a))},smootherstep:function(a,b,c){return b>=a?0:a>=c?1:(a=(a-b)/(c-b),a*a*a*(a*(6*a-15)+10))},sign:function(a){return 0>a?-1:a>0?1:0},degToRad:function(){var a=Math.PI/180;return function(b){return b*a}}(),radToDeg:function(){var a=180/Math.PI;return function(b){return b*a}}()},e.QuadTree=function(a,b,c,d,e,f,g,h){this.physicsManager=a,this.ID=a.quadTreeID,a.quadTreeID++,this.maxObjects=f||10,this.maxLevels=g||4,this.level=h||0,this.bounds={x:Math.round(b),y:Math.round(c),width:d,height:e,subWidth:Math.floor(d/2),subHeight:Math.floor(e/2),right:Math.round(b)+Math.floor(d/2),bottom:Math.round(c)+Math.floor(e/2)},this.objects=[],this.nodes=[]},e.QuadTree.prototype={split:function(){this.level++,this.nodes[0]=new e.QuadTree(this.physicsManager,this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level),this.nodes[1]=new e.QuadTree(this.physicsManager,this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level),this.nodes[2]=new e.QuadTree(this.physicsManager,this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level),this.nodes[3]=new e.QuadTree(this.physicsManager,this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level)},insert:function(a){var b,c=0;if(null!=this.nodes[0]&&(b=this.getIndex(a),-1!==b))return this.nodes[b].insert(a),void 0;if(this.objects.push(a),this.objects.length>this.maxObjects&&this.levelthis.bounds.bottom&&(b=2):a.x>this.bounds.right&&(a.ythis.bounds.bottom&&(b=3)),b},retrieve:function(a){var b=this.objects;return a.body.quadTreeIndex=this.getIndex(a.body),a.body.quadTreeIDs.push(this.ID),this.nodes[0]&&(-1!==a.body.quadTreeIndex?b=b.concat(this.nodes[a.body.quadTreeIndex].retrieve(a)):(b=b.concat(this.nodes[0].retrieve(a)),b=b.concat(this.nodes[1].retrieve(a)),b=b.concat(this.nodes[2].retrieve(a)),b=b.concat(this.nodes[3].retrieve(a)))),b},clear:function(){this.objects=[];for(var a=0,b=this.nodes.length;b>a;a++)this.nodes[a]&&(this.nodes[a].clear(),delete this.nodes[a])}},e.Circle=function(a,b,c){a=a||0,b=b||0,c=c||0,this.x=a,this.y=b,this._diameter=c,this._radius=c>0?.5*c:0},e.Circle.prototype={circumference:function(){return 2*Math.PI*this._radius},setTo:function(a,b,c){return this.x=a,this.y=b,this._diameter=c,this._radius=.5*c,this},copyFrom:function(a){return this.setTo(a.x,a.y,a.diameter)},copyTo:function(a){return a[x]=this.x,a[y]=this.y,a[diameter]=this._diameter,a},distance:function(a,b){return"undefined"==typeof b&&(b=!1),b?e.Math.distanceRound(this.x,this.y,a.x,a.y):e.Math.distance(this.x,this.y,a.x,a.y)},clone:function(b){return"undefined"==typeof b&&(b=new e.Circle),b.setTo(a.x,a.y,a.diameter)},contains:function(a,b){return e.Circle.contains(this,a,b)},circumferencePoint:function(a,b,c){return e.Circle.circumferencePoint(this,a,b,c)},offset:function(a,b){return this.x+=a,this.y+=b,this},offsetPoint:function(a){return this.offset(a.x,a.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}},Object.defineProperty(e.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(a){a>0&&(this._diameter=a,this._radius=.5*a)}}),Object.defineProperty(e.Circle.prototype,"radius",{get:function(){return this._radius},set:function(a){a>0&&(this._radius=a,this._diameter=2*a)}}),Object.defineProperty(e.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(a){a>this.x?(this._radius=0,this._diameter=0):this.radius=this.x-a}}),Object.defineProperty(e.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(a){athis.y?(this._radius=0,this._diameter=0):this.radius=this.y-a}}),Object.defineProperty(e.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(a){a0?Math.PI*this._radius*this._radius:0}}),Object.defineProperty(e.Circle.prototype,"empty",{get:function(){return 0==this._diameter},set:function(){this.setTo(0,0,0)}}),e.Circle.contains=function(a,b,c){if(b>=a.left&&b<=a.right&&c>=a.top&&c<=a.bottom){var d=(a.x-b)*(a.x-b),e=(a.y-c)*(a.y-c);return d+e<=a.radius*a.radius}return!1},e.Circle.equals=function(a,b){return a.x==b.x&&a.y==b.y&&a.diameter==b.diameter},e.Circle.intersects=function(a,b){return e.Math.distance(a.x,a.y,b.x,b.y)<=a.radius+b.radius},e.Circle.circumferencePoint=function(a,b,c,d){return"undefined"==typeof c&&(c=!1),"undefined"==typeof d&&(d=new e.Point),c===!0&&(b=e.Math.radToDeg(b)),d.x=a.x+a.radius*Math.cos(b),d.y=a.y+a.radius*Math.sin(b),d},e.Circle.intersectsRectangle=function(a,b){var c=Math.abs(a.x-b.x-b.halfWidth),d=b.halfWidth+a.radius;if(c>d)return!1;var e=Math.abs(a.y-b.y-b.halfHeight),f=b.halfHeight+a.radius;if(e>f)return!1;if(c<=b.halfWidth||e<=b.halfHeight)return!0;var g=c-b.halfWidth,h=e-b.halfHeight,i=g*g,j=h*h,k=a.radius*a.radius;return k>=i+j},e.Point=function(a,b){a=a||0,b=b||0,this.x=a,this.y=b},e.Point.prototype={copyFrom:function(a){return this.setTo(a.x,a.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(a,b){return this.x=a,this.y=b,this},add:function(a,b){return this.x+=a,this.y+=b,this},subtract:function(a,b){return this.x-=a,this.y-=b,this},multiply:function(a,b){return this.x*=a,this.y*=b,this},divide:function(a,b){return this.x/=a,this.y/=b,this},clampX:function(a,b){return this.x=e.Math.clamp(this.x,a,b),this},clampY:function(a,b){return this.y=e.Math.clamp(this.y,a,b),this},clamp:function(a,b){return this.x=e.Math.clamp(this.x,a,b),this.y=e.Math.clamp(this.y,a,b),this},clone:function(a){return"undefined"==typeof a&&(a=new e.Point),a.setTo(this.x,this.y)},copyFrom:function(a){return this.setTo(a.x,a.y)},copyTo:function(a){return a[x]=this.x,a[y]=this.y,a},distance:function(a,b){return e.Point.distance(this,a,b)},equals:function(a){return a.x==this.x&&a.y==this.y},rotate:function(a,b,c,d,f){return e.Point.rotate(this,a,b,c,d,f)},getMagnitude:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},setMagnitude:function(a){return this.normalize().multiply(a,a)},normalize:function(){if(!this.isZero()){var a=this.getMagnitude();this.x/=a,this.y/=a}return this},isZero:function(){return 0===this.x&&0===this.y},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}},e.Point.add=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x+b.x,c.y=a.y+b.y,c},e.Point.subtract=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x-b.x,c.y=a.y-b.y,c},e.Point.multiply=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x*b.x,c.y=a.y*b.y,c},e.Point.divide=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x/b.x,c.y=a.y/b.y,c},e.Point.equals=function(a,b){return a.x==b.x&&a.y==b.y},e.Point.distance=function(a,b,c){return"undefined"==typeof c&&(c=!1),c?e.Math.distanceRound(a.x,a.y,b.x,b.y):e.Math.distance(a.x,a.y,b.x,b.y)},e.Point.rotate=function(a,b,c,d,f,g){return f=f||!1,g=g||null,f&&(d=e.Math.degToRad(d)),null===g&&(g=Math.sqrt((b-a.x)*(b-a.x)+(c-a.y)*(c-a.y))),a.setTo(b+g*Math.cos(d),c+g*Math.sin(d))},e.Rectangle=function(a,b,c,d){a=a||0,b=b||0,c=c||0,d=d||0,this.x=a,this.y=b,this.width=c,this.height=d},e.Rectangle.prototype={offset:function(a,b){return this.x+=a,this.y+=b,this},offsetPoint:function(a){return this.offset(a.x,a.y)},setTo:function(a,b,c,d){return this.x=a,this.y=b,this.width=c,this.height=d,this},floor:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y)},floorAll:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.width=Math.floor(this.width),this.height=Math.floor(this.height)},copyFrom:function(a){return this.setTo(a.x,a.y,a.width,a.height)},copyTo:function(a){return a.x=this.x,a.y=this.y,a.width=this.width,a.height=this.height,a},inflate:function(a,b){return e.Rectangle.inflate(this,a,b)},size:function(a){return e.Rectangle.size(this,a)},clone:function(a){return e.Rectangle.clone(this,a) -},contains:function(a,b){return e.Rectangle.contains(this,a,b)},containsRect:function(a){return e.Rectangle.containsRect(this,a)},equals:function(a){return e.Rectangle.equals(this,a)},intersection:function(a){return e.Rectangle.intersection(this,a,output)},intersects:function(a,b){return e.Rectangle.intersects(this,a,b)},intersectsRaw:function(a,b,c,d,f){return e.Rectangle.intersectsRaw(this,a,b,c,d,f)},union:function(a,b){return e.Rectangle.union(this,a,b)},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}},Object.defineProperty(e.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)}}),Object.defineProperty(e.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)}}),Object.defineProperty(e.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){this.height=a<=this.y?0:this.y-a}}),Object.defineProperty(e.Rectangle.prototype,"bottomRight",{get:function(){return new e.Point(this.right,this.bottom)},set:function(a){this.right=a.x,this.bottom=a.y}}),Object.defineProperty(e.Rectangle.prototype,"left",{get:function(){return this.x},set:function(a){this.width=a>=this.right?0:this.right-a,this.x=a}}),Object.defineProperty(e.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(a){this.width=a<=this.x?0:this.x+a}}),Object.defineProperty(e.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}}),Object.defineProperty(e.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}}),Object.defineProperty(e.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(a){this.x=a-this.halfWidth}}),Object.defineProperty(e.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(a){this.y=a-this.halfHeight}}),Object.defineProperty(e.Rectangle.prototype,"top",{get:function(){return this.y},set:function(a){a>=this.bottom?(this.height=0,this.y=a):this.height=this.bottom-a}}),Object.defineProperty(e.Rectangle.prototype,"topLeft",{get:function(){return new e.Point(this.x,this.y)},set:function(a){this.x=a.x,this.y=a.y}}),Object.defineProperty(e.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(){this.setTo(0,0,0,0)}}),e.Rectangle.inflate=function(a,b,c){return a.x-=b,a.width+=2*b,a.y-=c,a.height+=2*c,a},e.Rectangle.inflatePoint=function(a,b){return e.Rectangle.inflate(a,b.x,b.y)},e.Rectangle.size=function(a,b){return"undefined"==typeof b&&(b=new e.Point),b.setTo(a.width,a.height)},e.Rectangle.clone=function(a,b){return"undefined"==typeof b&&(b=new e.Rectangle),b.setTo(a.x,a.y,a.width,a.height)},e.Rectangle.contains=function(a,b,c){return b>=a.x&&b<=a.right&&c>=a.y&&c<=a.bottom},e.Rectangle.containsRaw=function(a,b,c,d,e,f){return e>=a&&a+c>=e&&f>=b&&b+d>=f},e.Rectangle.containsPoint=function(a,b){return e.Rectangle.contains(a,b.x,b.y)},e.Rectangle.containsRect=function(a,b){return a.volume>b.volume?!1:a.x>=b.x&&a.y>=b.y&&a.right<=b.right&&a.bottom<=b.bottom},e.Rectangle.equals=function(a,b){return a.x==b.x&&a.y==b.y&&a.width==b.width&&a.height==b.height},e.Rectangle.intersection=function(a,b,c){return c=c||new e.Rectangle,e.Rectangle.intersects(a,b)&&(c.x=Math.max(a.x,b.x),c.y=Math.max(a.y,b.y),c.width=Math.min(a.right,b.right)-c.x,c.height=Math.min(a.bottom,b.bottom)-c.y),c},e.Rectangle.intersects=function(a,b){return a.xa.right+f||ca.bottom+f||e1){if(a&&a==this.decodeURI(e[0]))return this.decodeURI(e[1]);b[this.decodeURI(e[0])]=this.decodeURI(e[1])}}return b},decodeURI:function(a){return decodeURIComponent(a.replace(/\+/g," "))}},e.TweenManager=function(a){this.game=a,this._tweens=[],this._add=[],this.game.onPause.add(this.pauseAll,this),this.game.onResume.add(this.resumeAll,this)},e.TweenManager.prototype={REVISION:"11dev",getAll:function(){return this._tweens},removeAll:function(){this._tweens=[]},add:function(a){this._add.push(a)},create:function(a){return new e.Tween(a,this.game)},remove:function(a){var b=this._tweens.indexOf(a);-1!==b&&(this._tweens[b].pendingDelete=!0)},update:function(){if(0===this._tweens.length&&0===this._add.length)return!1;for(var a=0,b=this._tweens.length;b>a;)this._tweens[a].update(this.game.time.now)?a++:(this._tweens.splice(a,1),b--);return this._add.length>0&&(this._tweens=this._tweens.concat(this._add),this._add.length=0),!0},isTweening:function(a){return this._tweens.some(function(b){return b._object===a})},pauseAll:function(){for(var a=this._tweens.length-1;a>=0;a--)this._tweens[a].pause()},resumeAll:function(){for(var a=this._tweens.length-1;a>=0;a--)this._tweens[a].resume()}},e.Tween=function(a,b){this._object=a,this.game=b,this._manager=this.game.tweens,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._repeat=0,this._yoyo=!1,this._reversed=!1,this._delayTime=0,this._startTime=null,this._easingFunction=e.Easing.Linear.None,this._interpolationFunction=e.Math.linearInterpolation,this._chainedTweens=[],this._onStartCallback=null,this._onStartCallbackFired=!1,this._onUpdateCallback=null,this._onCompleteCallback=null,this._pausedTime=0,this.pendingDelete=!1;for(var c in a)this._valuesStart[c]=parseFloat(a[c],10);this.onStart=new e.Signal,this.onComplete=new e.Signal,this.isRunning=!1},e.Tween.prototype={to:function(a,b,c,d,e,f,g){b=b||1e3,c=c||null,d=d||!1,e=e||0,f=f||0,g=g||!1;var h;return this._parent?(h=this._manager.create(this._object),this._lastChild.chain(h),this._lastChild=h):(h=this,this._parent=this,this._lastChild=this),h._repeat=f,h._duration=b,h._valuesEnd=a,null!==c&&(h._easingFunction=c),e>0&&(h._delayTime=e),h._yoyo=g,d?this.start():this},start:function(){if(null!==this.game&&null!==this._object){this._manager.add(this),this.onStart.dispatch(this._object),this.isRunning=!0,this._onStartCallbackFired=!1,this._startTime=this.game.time.now+this._delayTime;for(var a in this._valuesEnd){if(this._valuesEnd[a]instanceof Array){if(0===this._valuesEnd[a].length)continue;this._valuesEnd[a]=[this._object[a]].concat(this._valuesEnd[a])}this._valuesStart[a]=this._object[a],this._valuesStart[a]instanceof Array==!1&&(this._valuesStart[a]*=1),this._valuesStartRepeat[a]=this._valuesStart[a]||0}return this}},stop:function(){return this.isRunning=!1,this._manager.remove(this),this},delay:function(a){return this._delayTime=a,this},repeat:function(a){return this._repeat=a,this},yoyo:function(a){return this._yoyo=a,this},easing:function(a){return this._easingFunction=a,this},interpolation:function(a){return this._interpolationFunction=a,this},chain:function(){return this._chainedTweens=arguments,this},loop:function(){return this._lastChild.chain(this),this},onStartCallback:function(a){return this._onStartCallback=a,this},onUpdateCallback:function(a){return this._onUpdateCallback=a,this},onCompleteCallback:function(a){return this._onCompleteCallback=a,this},pause:function(){this._paused=!0,this._pausedTime=this.game.time.now},resume:function(){this._paused=!1,this._startTime+=this.game.time.now-this._pausedTime},update:function(a){if(this.pendingDelete)return!1;if(this._paused||a1?1:c;var d=this._easingFunction(c);for(b in this._valuesEnd){var e=this._valuesStart[b]||0,f=this._valuesEnd[b];f instanceof Array?this._object[b]=this._interpolationFunction(f,d):("string"==typeof f&&(f=e+parseFloat(f,10)),"number"==typeof f&&(this._object[b]=e+(f-e)*d))}if(null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._object,d),1==c){if(this._repeat>0){isFinite(this._repeat)&&this._repeat--;for(b in this._valuesStartRepeat){if("string"==typeof this._valuesEnd[b]&&(this._valuesStartRepeat[b]=this._valuesStartRepeat[b]+parseFloat(this._valuesEnd[b],10)),this._yoyo){var g=this._valuesStartRepeat[b];this._valuesStartRepeat[b]=this._valuesEnd[b],this._valuesEnd[b]=g,this._reversed=!this._reversed}this._valuesStart[b]=this._valuesStartRepeat[b]}return this._startTime=a+this._delayTime,this.onComplete.dispatch(this._object),null!==this._onCompleteCallback&&this._onCompleteCallback.call(this._object),!0}this.onComplete.dispatch(this._object),null!==this._onCompleteCallback&&this._onCompleteCallback.call(this._object);for(var h=0,i=this._chainedTweens.length;i>h;h++)this._chainedTweens[h].start(a);return!1}return!0}},e.Easing={Linear:{None:function(a){return a}},Quadratic:{In:function(a){return a*a},Out:function(a){return a*(2-a)},InOut:function(a){return(a*=2)<1?.5*a*a:-.5*(--a*(a-2)-1)}},Cubic:{In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)}},Quartic:{In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return(a*=2)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)}},Quintic:{In:function(a){return a*a*a*a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)}},Sinusoidal:{In:function(a){return 1-Math.cos(a*Math.PI/2)},Out:function(a){return Math.sin(a*Math.PI/2)},InOut:function(a){return.5*(1-Math.cos(Math.PI*a))}},Exponential:{In:function(a){return 0===a?0:Math.pow(1024,a-1)},Out:function(a){return 1===a?1:1-Math.pow(2,-10*a)},InOut:function(a){return 0===a?0:1===a?1:(a*=2)<1?.5*Math.pow(1024,a-1):.5*(-Math.pow(2,-10*(a-1))+2)}},Circular:{In:function(a){return 1-Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*a)},InOut:function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)}},Elastic:{In:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),-(c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*2*Math.PI/d)))},Out:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),c*Math.pow(2,-10*a)*Math.sin((a-b)*2*Math.PI/d)+1)},InOut:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),(a*=2)<1?-.5*c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*2*Math.PI/d):.5*c*Math.pow(2,-10*(a-=1))*Math.sin((a-b)*2*Math.PI/d)+1)}},Back:{In:function(a){var b=1.70158;return a*a*((b+1)*a-b)},Out:function(a){var b=1.70158;return--a*a*((b+1)*a+b)+1},InOut:function(a){var b=2.5949095;return(a*=2)<1?.5*a*a*((b+1)*a-b):.5*((a-=2)*a*((b+1)*a+b)+2)}},Bounce:{In:function(a){return 1-e.Easing.Bounce.Out(1-a)},Out:function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?7.5625*(a-=1.5/2.75)*a+.75:2.5/2.75>a?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},InOut:function(a){return.5>a?.5*e.Easing.Bounce.In(2*a):.5*e.Easing.Bounce.Out(2*a-1)+.5}}},e.Time=function(a){this.game=a,this._started=0,this._timeLastSecond=0,this._pauseStarted=0,this.physicsElapsed=0,this.time=0,this.pausedTime=0,this.now=0,this.elapsed=0,this.fps=0,this.fpsMin=1e3,this.fpsMax=0,this.msMin=1e3,this.msMax=0,this.frames=0,this.pauseDuration=0,this.timeToCall=0,this.lastTime=0,this.game.onPause.add(this.gamePaused,this),this.game.onResume.add(this.gameResumed,this),this._justResumed=!1},e.Time.prototype={totalElapsedSeconds:function(){return.001*(this.now-this._started)},update:function(a){this.now=a,this._justResumed&&(this.time=this.now,this._justResumed=!1),this.timeToCall=this.game.math.max(0,16-(a-this.lastTime)),this.elapsed=this.now-this.time,this.msMin=this.game.math.min(this.msMin,this.elapsed),this.msMax=this.game.math.max(this.msMax,this.elapsed),this.frames++,this.now>this._timeLastSecond+1e3&&(this.fps=Math.round(1e3*this.frames/(this.now-this._timeLastSecond)),this.fpsMin=this.game.math.min(this.fpsMin,this.fps),this.fpsMax=this.game.math.max(this.fpsMax,this.fps),this._timeLastSecond=this.now,this.frames=0),this.time=this.now,this.lastTime=a+this.timeToCall,this.physicsElapsed=1*(this.elapsed/1e3),this.physicsElapsed>1&&(this.physicsElapsed=1),this.game.paused&&(this.pausedTime=this.now-this._pauseStarted)},gamePaused:function(){this._pauseStarted=this.now},gameResumed:function(){this.time=Date.now(),this.pauseDuration=this.pausedTime,this._justResumed=!0},elapsedSince:function(a){return this.now-a},elapsedSecondsSince:function(a){return.001*(this.now-a)},reset:function(){this._started=this.now}},e.AnimationManager=function(a){this.sprite=a,this.game=a.game,this.currentFrame=null,this.updateIfVisible=!0,this.isLoaded=!1,this._frameData=null,this._anims={},this._outputFrames=[]},e.AnimationManager.prototype={loadFrameData:function(a){this._frameData=a,this.frame=0,this.isLoaded=!0},add:function(a,b,c,f,g){return null==this._frameData?(console.warn("No FrameData available for Phaser.Animation "+a),void 0):(c=c||60,"undefined"==typeof f&&(f=!1),"undefined"==typeof g&&(g=b&&"number"==typeof b[0]?!0:!1),null==this.sprite.events.onAnimationStart&&(this.sprite.events.onAnimationStart=new e.Signal,this.sprite.events.onAnimationComplete=new e.Signal,this.sprite.events.onAnimationLoop=new e.Signal),this._outputFrames.length=0,this._frameData.getFrameIndexes(b,g,this._outputFrames),this._anims[a]=new e.Animation(this.game,this.sprite,a,this._frameData,this._outputFrames,c,f),this.currentAnim=this._anims[a],this.currentFrame=this.currentAnim.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid]),this._anims[a])},validateFrames:function(a,b){"undefined"==typeof b&&(b=!0);for(var c=0;cthis._frameData.total)return!1}else if(0==this._frameData.checkFrameName(a[c]))return!1;return!0},play:function(a,b,c,d){if(this._anims[a]){if(this.currentAnim!=this._anims[a])return this.currentAnim=this._anims[a],this.currentAnim.paused=!1,this.currentAnim.play(b,c,d);if(0==this.currentAnim.isPlaying)return this.currentAnim.paused=!1,this.currentAnim.play(b,c,d)}},stop:function(a,b){"undefined"==typeof b&&(b=!1),"string"==typeof a?this._anims[a]&&(this.currentAnim=this._anims[a],this.currentAnim.stop(b)):this.currentAnim&&this.currentAnim.stop(b)},update:function(){return this.updateIfVisible&&0==this.sprite.visible?!1:this.currentAnim&&1==this.currentAnim.update()?(this.currentFrame=this.currentAnim.currentFrame,this.sprite.currentFrame=this.currentFrame,!0):!1},getAnimation:function(a){return"string"==typeof a&&this._anims[a]?this._anims[a]:!1},refreshFrame:function(){this.sprite.currentFrame=this.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid])},destroy:function(){this._anims={},this._frameData=null,this._frameIndex=0,this.currentAnim=null,this.currentFrame=null}},Object.defineProperty(e.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}}),Object.defineProperty(e.AnimationManager.prototype,"frameTotal",{get:function(){return this._frameData?this._frameData.total:-1}}),Object.defineProperty(e.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(a){this.currentAnim.paused=a}}),Object.defineProperty(e.AnimationManager.prototype,"frame",{get:function(){return this.currentFrame?this._frameIndex:void 0},set:function(a){"number"==typeof a&&this._frameData&&null!==this._frameData.getFrame(a)&&(this.currentFrame=this._frameData.getFrame(a),this._frameIndex=a,this.sprite.currentFrame=this.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid]))}}),Object.defineProperty(e.AnimationManager.prototype,"frameName",{get:function(){return this.currentFrame?this.currentFrame.name:void 0},set:function(a){"string"==typeof a&&this._frameData&&null!==this._frameData.getFrameByName(a)?(this.currentFrame=this._frameData.getFrameByName(a),this._frameIndex=this.currentFrame.index,this.sprite.currentFrame=this.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid])):console.warn("Cannot set frameName: "+a)}}),e.Animation=function(a,b,c,d,e,f,g){this.game=a,this._parent=b,this._frameData=d,this.name=c,this._frames=[],this._frames=this._frames.concat(e),this.delay=1e3/f,this.looped=g,this.killOnComplete=!1,this.isFinished=!1,this.isPlaying=!1,this.isPaused=!1,this._pauseStartTime=0,this._frameIndex=0,this._frameDiff=0,this._frameSkip=1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex])},e.Animation.prototype={play:function(a,b,c){return"number"==typeof a&&(this.delay=1e3/a),"boolean"==typeof b&&(this.looped=b),"undefined"!=typeof c&&(this.killOnComplete=c),this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this._timeLastFrame=this.game.time.now,this._timeNextFrame=this.game.time.now+this.delay,this._frameIndex=0,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this._parent.setTexture(d.TextureCache[this.currentFrame.uuid]),this._parent.events&&this._parent.events.onAnimationStart.dispatch(this._parent,this),this},restart:function(){this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this._timeLastFrame=this.game.time.now,this._timeNextFrame=this.game.time.now+this.delay,this._frameIndex=0,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex])},stop:function(a){"undefined"==typeof a&&(a=!1),this.isPlaying=!1,this.isFinished=!0,this.paused=!1,a&&(this.currentFrame=this._frameData.getFrame(this._frames[0]))},update:function(){return this.isPaused?!1:1==this.isPlaying&&this.game.time.now>=this._timeNextFrame?(this._frameSkip=1,this._frameDiff=this.game.time.now-this._timeNextFrame,this._timeLastFrame=this.game.time.now,this._frameDiff>this.delay&&(this._frameSkip=Math.floor(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay),this._timeNextFrame=this.game.time.now+(this.delay-this._frameDiff),this._frameIndex+=this._frameSkip,this._frameIndex>=this._frames.length?this.looped?(this._frameIndex%=this._frames.length,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&this._parent.setTexture(d.TextureCache[this.currentFrame.uuid]),this._parent.events.onAnimationLoop.dispatch(this._parent,this)):this.onComplete():(this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&this._parent.setTexture(d.TextureCache[this.currentFrame.uuid])),!0):!1},destroy:function(){this.game=null,this._parent=null,this._frames=null,this._frameData=null,this.currentFrame=null,this.isPlaying=!1},onComplete:function(){this.isPlaying=!1,this.isFinished=!0,this.paused=!1,this._parent.events&&this._parent.events.onAnimationComplete.dispatch(this._parent,this),this.killOnComplete&&this._parent.kill()}},Object.defineProperty(e.Animation.prototype,"paused",{get:function(){return this.isPaused},set:function(a){this.isPaused=a,a?this._pauseStartTime=this.game.time.now:this.isPlaying&&(this._timeNextFrame=this.game.time.now+this.delay)}}),Object.defineProperty(e.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}}),Object.defineProperty(e.Animation.prototype,"frame",{get:function(){return null!==this.currentFrame?this.currentFrame.index:this._frameIndex},set:function(a){this.currentFrame=this._frameData.getFrame(a),null!==this.currentFrame&&(this._frameIndex=a,this._parent.setTexture(d.TextureCache[this.currentFrame.uuid]))}}),e.Animation.generateFrameNames=function(a,b,c,d,f){"undefined"==typeof d&&(d="");var g=[],h="";if(c>b)for(var i=b;c>=i;i++)h="number"==typeof f?e.Utils.pad(i.toString(),f,"0",1):i.toString(),h=a+h+d,g.push(h);else for(var i=b;i>=c;i--)h="number"==typeof f?e.Utils.pad(i.toString(),f,"0",1):i.toString(),h=a+h+d,g.push(h);return g},e.Frame=function(a,b,c,d,f,g,h){this.index=a,this.x=b,this.y=c,this.width=d,this.height=f,this.name=g,this.uuid=h,this.centerX=Math.floor(d/2),this.centerY=Math.floor(f/2),this.distance=e.Math.distance(0,0,d,f),this.rotated=!1,this.rotationDirection="cw",this.trimmed=!1,this.sourceSizeW=d,this.sourceSizeH=f,this.spriteSourceSizeX=0,this.spriteSourceSizeY=0,this.spriteSourceSizeW=0,this.spriteSourceSizeH=0},e.Frame.prototype={setTrim:function(a,b,c,d,e,f,g){this.trimmed=a,a&&(this.width=b,this.height=c,this.sourceSizeW=b,this.sourceSizeH=c,this.centerX=Math.floor(b/2),this.centerY=Math.floor(c/2),this.spriteSourceSizeX=d,this.spriteSourceSizeY=e,this.spriteSourceSizeW=f,this.spriteSourceSizeH=g)}},e.FrameData=function(){this._frames=[],this._frameNames=[]},e.FrameData.prototype={addFrame:function(a){return a.index=this._frames.length,this._frames.push(a),""!==a.name&&(this._frameNames[a.name]=a.index),a},getFrame:function(a){return this._frames.length>a?this._frames[a]:null},getFrameByName:function(a){return"number"==typeof this._frameNames[a]?this._frames[this._frameNames[a]]:null},checkFrameName:function(a){return null==this._frameNames[a]?!1:!0},getFrameRange:function(a,b,c){"undefined"==typeof c&&(c=[]);for(var d=a;b>=d;d++)c.push(this._frames[d]);return c},getFrames:function(a,b,c){if("undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=[]),"undefined"==typeof a||0==a.length)for(var d=0;dd;d++)b?c.push(this.getFrame(a[d])):c.push(this.getFrameByName(a[d]));return c},getFrameIndexes:function(a,b,c){if("undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=[]),"undefined"==typeof a||0==a.length)for(var d=0,e=this._frames.length;e>d;d++)c.push(this._frames[d].index);else for(var d=0,e=a.length;e>d;d++)b?c.push(a[d]):this.getFrameByName(a[d])&&c.push(this.getFrameByName(a[d]).index);return c}},Object.defineProperty(e.FrameData.prototype,"total",{get:function(){return this._frames.length}}),e.AnimationParser={spriteSheet:function(a,b,c,f,g){var h=a.cache.getImage(b);if(null==h)return null;var i=h.width,j=h.height;0>=c&&(c=Math.floor(-i/Math.min(-1,c))),0>=f&&(f=Math.floor(-j/Math.min(-1,f)));var k=Math.round(i/c),l=Math.round(j/f),m=k*l;if(-1!==g&&(m=g),0==i||0==j||c>i||f>j||0===m)return console.warn("Phaser.AnimationParser.spriteSheet: width/height zero or width/height < given frameWidth/frameHeight"),null;for(var n=new e.FrameData,o=0,p=0,q=0;m>q;q++){var r=a.rnd.uuid();n.addFrame(new e.Frame(q,o,p,c,f,"",r)),d.TextureCache[r]=new d.Texture(d.BaseTextureCache[b],{x:o,y:p,width:c,height:f}),o+=c,o===i&&(o=0,p+=f)}return n},JSONData:function(a,b,c){if(!b.frames)return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"),console.log(b),void 0;for(var f,g=new e.FrameData,h=b.frames,i=0;i tag"),void 0;for(var f,g,h,i,j,k,l,m,n,o,p,q=new e.FrameData,r=b.getElementsByTagName("SubTexture"),s=0;s0?(this._progressChunk=100/this._keys.length,this.loadFile()):(this.progress=100,this.hasLoaded=!0,this.onLoadComplete.dispatch()))},loadFile:function(){var a=this._fileList[this._keys.shift()],b=this;switch(a.type){case"image":case"spritesheet":case"textureatlas":case"bitmapfont":case"tileset":a.data=new Image,a.data.name=a.key,a.data.onload=function(){return b.fileComplete(a.key)},a.data.onerror=function(){return b.fileError(a.key)},a.data.crossOrigin=this.crossOrigin,a.data.src=this.baseURL+a.url;break;case"audio":a.url=this.getAudioURL(a.url),null!==a.url?this.game.sound.usingWebAudio?(this._xhr.open("GET",this.baseURL+a.url,!0),this._xhr.responseType="arraybuffer",this._xhr.onload=function(){return b.fileComplete(a.key)},this._xhr.onerror=function(){return b.fileError(a.key)},this._xhr.send()):this.game.sound.usingAudioTag&&(this.game.sound.touchLocked?(a.data=new Audio,a.data.name=a.key,a.data.preload="auto",a.data.src=this.baseURL+a.url,this.fileComplete(a.key)):(a.data=new Audio,a.data.name=a.key,a.data.onerror=function(){return b.fileError(a.key)},a.data.preload="auto",a.data.src=this.baseURL+a.url,a.data.addEventListener("canplaythrough",e.GAMES[this.game.id].load.fileComplete(a.key),!1),a.data.load())):this.fileError(a.key);break;case"tilemap":this._xhr.open("GET",this.baseURL+a.url,!0),this._xhr.responseType="text",a.format==e.Tilemap.TILED_JSON?this._xhr.onload=function(){return b.jsonLoadComplete(a.key)}:a.format==e.Tilemap.CSV&&(this._xhr.onload=function(){return b.csvLoadComplete(a.key)}),this._xhr.onerror=function(){return b.dataLoadError(a.key)},this._xhr.send();break;case"text":this._xhr.open("GET",this.baseURL+a.url,!0),this._xhr.responseType="text",this._xhr.onload=function(){return b.fileComplete(a.key)},this._xhr.onerror=function(){return b.fileError(a.key)},this._xhr.send()}},getAudioURL:function(a){for(var b,c=0;c100&&(this.progress=100),null!==this.preloadSprite&&(0==this.preloadSprite.direction?this.preloadSprite.crop.width=Math.floor(this.preloadSprite.width/100*this.progress):this.preloadSprite.crop.height=Math.floor(this.preloadSprite.height/100*this.progress),this.preloadSprite.sprite.crop=this.preloadSprite.crop),this.onFileComplete.dispatch(this.progress,a,b,this.queueSize-this._keys.length,this.queueSize),this._keys.length>0?this.loadFile():(this.hasLoaded=!0,this.isLoading=!1,this.removeAll(),this.onLoadComplete.dispatch())}},e.LoaderParser={bitmapFont:function(a,b,c){if(!b.getElementsByTagName("font"))return console.warn("Phaser.LoaderParser.bitmapFont: Invalid XML given, missing tag"),void 0;var e=d.TextureCache[c],f={},g=b.getElementsByTagName("info")[0],h=b.getElementsByTagName("common")[0];f.font=g.attributes.getNamedItem("face").nodeValue,f.size=parseInt(g.attributes.getNamedItem("size").nodeValue,10),f.lineHeight=parseInt(h.attributes.getNamedItem("lineHeight").nodeValue,10),f.chars={};for(var i=b.getElementsByTagName("char"),j=0;j=this.durationMS&&(this.usingWebAudio?this.loop?(this.onLoop.dispatch(this),""==this.currentMarker?(this.currentTime=0,this.startTime=this.game.time.now):this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop():this.loop?(this.onLoop.dispatch(this),this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop()))},play:function(a,b,c,d,e){if(a=a||"",b=b||0,c=c||1,"undefined"==typeof d&&(d=!1),"undefined"==typeof e&&(e=!0),1!=this.isPlaying||0!=e||0!=this.override){if(this.isPlaying&&this.override&&(this.usingWebAudio?"undefined"==typeof this._sound.stop?this._sound.noteOff(0):this._sound.stop(0):this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0)),this.currentMarker=a,""!==a){if(!this.markers[a])return console.warn("Phaser.Sound.play: audio marker "+a+" doesn't exist"),void 0;this.position=this.markers[a].start,this.volume=this.markers[a].volume,this.loop=this.markers[a].loop,this.duration=this.markers[a].duration,this.durationMS=this.markers[a].durationMS,this._tempMarker=a,this._tempPosition=this.position,this._tempVolume=this.volume,this._tempLoop=this.loop}else this.position=b,this.volume=c,this.loop=d,this.duration=0,this.durationMS=0,this._tempMarker=a,this._tempPosition=b,this._tempVolume=c,this._tempLoop=d;this.usingWebAudio?this.game.cache.isSoundDecoded(this.key)?(null==this._buffer&&(this._buffer=this.game.cache.getSoundData(this.key)),this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this._sound.connect(this.gainNode),this.totalDuration=this._sound.buffer.duration,0==this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this.loop&&""==a&&(this._sound.loop=!0),"undefined"==typeof this._sound.start?this._sound.noteGrainOn(0,this.position,this.duration):this._sound.start(0,this.position,this.duration),this.isPlaying=!0,this.startTime=this.game.time.now,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):(this.pendingPlayback=!0,this.game.cache.getSound(this.key)&&0==this.game.cache.getSound(this.key).isDecoding&&this.game.sound.decode(this.key,this)):this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked?(this.game.cache.reloadSound(this.key),this.pendingPlayback=!0):this._sound&&4==this._sound.readyState?(this._sound.play(),this.totalDuration=this._sound.duration,0==this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this._sound.currentTime=this.position,this._sound.muted=this._muted,this._sound.volume=this._muted?0:this._volume,this.isPlaying=!0,this.startTime=this.game.time.now,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):this.pendingPlayback=!0}},restart:function(a,b,c,d){a=a||"",b=b||0,c=c||1,"undefined"==typeof d&&(d=!1),this.play(a,b,c,d,!0)},pause:function(){this.isPlaying&&this._sound&&(this.stop(),this.isPlaying=!1,this.paused=!0,this.pausedPosition=this.currentTime,this.pausedTime=this.game.time.now,this.onPause.dispatch(this))},resume:function(){if(this.paused&&this._sound){if(this.usingWebAudio){var a=this.position+this.pausedPosition/1e3;this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this._sound.connect(this.gainNode),"undefined"==typeof this._sound.start?this._sound.noteGrainOn(0,a,this.duration):this._sound.start(0,a,this.duration)}else this._sound.play();this.isPlaying=!0,this.paused=!1,this.startTime+=this.game.time.now-this.pausedTime,this.onResume.dispatch(this)}},stop:function(){this.isPlaying&&this._sound&&(this.usingWebAudio?"undefined"==typeof this._sound.stop?this._sound.noteOff(0):this._sound.stop(0):this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0)),this.isPlaying=!1;var a=this.currentMarker;this.currentMarker="",this.onStop.dispatch(this,a)}},Object.defineProperty(e.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}}),Object.defineProperty(e.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}}),Object.defineProperty(e.Sound.prototype,"mute",{get:function(){return this._muted},set:function(a){a=a||null,a?(this._muted=!0,this.usingWebAudio?(this._muteVolume=this.gainNode.gain.value,this.gainNode.gain.value=0):this.usingAudioTag&&this._sound&&(this._muteVolume=this._sound.volume,this._sound.volume=0)):(this._muted=!1,this.usingWebAudio?this.gainNode.gain.value=this._muteVolume:this.usingAudioTag&&this._sound&&(this._sound.volume=this._muteVolume)),this.onMute.dispatch(this)}}),Object.defineProperty(e.Sound.prototype,"volume",{get:function(){return this._volume},set:function(a){this.usingWebAudio?(this._volume=a,this.gainNode.gain.value=a):this.usingAudioTag&&this._sound&&a>=0&&1>=a&&(this._volume=a,this._sound.volume=a)}}),e.SoundManager=function(a){this.game=a,this.onSoundDecode=new e.Signal,this._muted=!1,this._unlockSource=null,this._volume=1,this._sounds=[],this.context=null,this.usingWebAudio=!0,this.usingAudioTag=!1,this.noAudio=!1,this.touchLocked=!1,this.channels=32},e.SoundManager.prototype={boot:function(){if(this.game.device.iOS&&0==this.game.device.webAudio&&(this.channels=1),this.game.device.iOS||window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock?(this.game.input.touch.callbackContext=this,this.game.input.touch.touchStartCallback=this.unlock,this.game.input.mouse.callbackContext=this,this.game.input.mouse.mouseDownCallback=this.unlock,this.touchLocked=!0):this.touchLocked=!1,window.PhaserGlobal){if(1==window.PhaserGlobal.disableAudio)return this.usingWebAudio=!1,this.noAudio=!0,void 0;if(1==window.PhaserGlobal.disableWebAudio)return this.usingWebAudio=!1,this.usingAudioTag=!0,this.noAudio=!1,void 0}window.AudioContext?this.context=new window.AudioContext:window.webkitAudioContext?this.context=new window.webkitAudioContext:window.Audio?(this.usingWebAudio=!1,this.usingAudioTag=!0):(this.usingWebAudio=!1,this.noAudio=!0),null!==this.context&&(this.masterGain="undefined"==typeof this.context.createGain?this.context.createGainNode():this.context.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this.context.destination))},unlock:function(){if(0!=this.touchLocked)if(0==this.game.device.webAudio||window.PhaserGlobal&&1==window.PhaserGlobal.disableWebAudio)this.touchLocked=!1,this._unlockSource=null,this.game.input.touch.callbackContext=null,this.game.input.touch.touchStartCallback=null,this.game.input.mouse.callbackContext=null,this.game.input.mouse.mouseDownCallback=null;else{var a=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource(),this._unlockSource.buffer=a,this._unlockSource.connect(this.context.destination),this._unlockSource.noteOn(0)}},stopAll:function(){for(var a=0;a255)return e.Color.getColor(255,255,255);if(a>b)return e.Color.getColor(255,255,255);var d=a+Math.round(Math.random()*(b-a)),f=a+Math.round(Math.random()*(b-a)),g=a+Math.round(Math.random()*(b-a));return e.Color.getColor32(c,d,f,g)},getRGB:function(a){return{alpha:a>>>24,red:255&a>>16,green:255&a>>8,blue:255&a}},getWebRGB:function(a){var b=(a>>>24)/255,c=255&a>>16,d=255&a>>8,e=255&a;return"rgba("+c.toString()+","+d.toString()+","+e.toString()+","+b.toString()+")"},getAlpha:function(a){return a>>>24},getAlphaFloat:function(a){return(a>>>24)/255},getRed:function(a){return 255&a>>16},getGreen:function(a){return 255&a>>8},getBlue:function(a){return 255&a}},e.Physics={},e.Physics.Arcade=function(a){this.game=a,this.gravity=new e.Point,this.bounds=new e.Rectangle(0,0,a.world.width,a.world.height),this.maxObjects=10,this.maxLevels=4,this.OVERLAP_BIAS=4,this.quadTree=new e.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this.quadTreeID=0,this._bounds1=new e.Rectangle,this._bounds2=new e.Rectangle,this._overlap=0,this._maxOverlap=0,this._velocity1=0,this._velocity2=0,this._newVelocity1=0,this._newVelocity2=0,this._average=0,this._mapData=[],this._mapTiles=0,this._result=!1,this._total=0,this._angle=0,this._dx=0,this._dy=0},e.Physics.Arcade.prototype={updateMotion:function(a){this._velocityDelta=60*.5*(this.computeVelocity(0,a,a.angularVelocity,a.angularAcceleration,a.angularDrag,a.maxAngular)-a.angularVelocity)*this.game.time.physicsElapsed,a.angularVelocity+=this._velocityDelta,a.rotation+=a.angularVelocity*this.game.time.physicsElapsed,a.angularVelocity+=this._velocityDelta,this._velocityDelta=60*.5*(this.computeVelocity(1,a,a.velocity.x,a.acceleration.x,a.drag.x,a.maxVelocity.x)-a.velocity.x)*this.game.time.physicsElapsed,a.velocity.x+=this._velocityDelta,a.x+=a.velocity.x*this.game.time.physicsElapsed,a.velocity.x+=this._velocityDelta,this._velocityDelta=60*.5*(this.computeVelocity(2,a,a.velocity.y,a.acceleration.y,a.drag.y,a.maxVelocity.y)-a.velocity.y)*this.game.time.physicsElapsed,a.velocity.y+=this._velocityDelta,a.y+=a.velocity.y*this.game.time.physicsElapsed,a.velocity.y+=this._velocityDelta},computeVelocity:function(a,b,c,d,e,f){return f=f||1e4,1==a&&b.allowGravity?c+=this.gravity.x+b.gravity.x:2==a&&b.allowGravity&&(c+=this.gravity.y+b.gravity.y),0!==d?c+=d*this.game.time.physicsElapsed:0!==e&&(this._drag=e*this.game.time.physicsElapsed,c-this._drag>0?c-=this._drag:c+this._drag<0?c+=this._drag:c=0),c>f?c=f:-f>c&&(c=-f),c},preUpdate:function(){this.quadTree.clear(),this.quadTreeID=0,this.quadTree=new e.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels)},postUpdate:function(){this.quadTree.clear()},overlap:function(a,b){return a&&b&&a.exists&&b.exists?e.Rectangle.intersects(a.body,b.body):!1},collide:function(a,b,c,d,f){return c=c||null,d=d||null,f=f||c,this._result=!1,this._total=0,a&&b&&a.exists&&b.exists&&(a.type==e.SPRITE?b.type==e.SPRITE?this.collideSpriteVsSprite(a,b,c,d,f):b.type==e.GROUP||b.type==e.EMITTER?this.collideSpriteVsGroup(a,b,c,d,f):b.type==e.TILEMAPLAYER&&this.collideSpriteVsTilemapLayer(a,b,c,d,f):a.type==e.GROUP?b.type==e.SPRITE?this.collideSpriteVsGroup(b,a,c,d,f):b.type==e.GROUP||b.type==e.EMITTER?this.collideGroupVsGroup(a,b,c,d,f):b.type==e.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(a,b,c,d,f):a.type==e.TILEMAPLAYER?b.type==e.SPRITE?this.collideSpriteVsTilemapLayer(b,a,c,d,f):(b.type==e.GROUP||b.type==e.EMITTER)&&this.collideGroupVsTilemapLayer(b,a,c,d,f):a.type==e.EMITTER&&(b.type==e.SPRITE?this.collideSpriteVsGroup(b,a,c,d,f):b.type==e.GROUP||b.type==e.EMITTER?this.collideGroupVsGroup(a,b,c,d,f):b.type==e.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(a,b,c,d,f))),this._total>0},collideSpriteVsTilemapLayer:function(a,b,c,d,e){if(this._mapData=b.getTiles(a.body.x,a.body.y,a.body.width,a.body.height,!0),0!=this._mapData.length)for(var f=0;ff;f++)this._potentials[f].sprite.group==b&&(this.separate(a.body,this._potentials[f]),this._result&&d&&(this._result=d.call(e,a,this._potentials[f].sprite)),this._result&&(this._total++,c&&c.call(e,a,this._potentials[f].sprite)))}},collideGroupVsGroup:function(a,b,c,d,e){if(0!=a.length&&0!=b.length&&a._container.first._iNext){var f=a._container.first._iNext;do f.exists&&this.collideSpriteVsGroup(f,b,c,d,e),f=f._iNext;while(f!=a._container.last._iNext)}},separate:function(a,b){this._result=this.separateX(a,b)||this.separateY(a,b)},separateX:function(a,b){return a.immovable&&b.immovable?!1:(this._overlap=0,e.Rectangle.intersects(a,b)&&(this._maxOverlap=a.deltaAbsX()+b.deltaAbsX()+this.OVERLAP_BIAS,0==a.deltaX()&&0==b.deltaX()?(a.embedded=!0,b.embedded=!0):a.deltaX()>b.deltaX()?(this._overlap=a.x+a.width-b.x,this._overlap>this._maxOverlap||0==a.allowCollision.right||0==b.allowCollision.left?this._overlap=0:(a.touching.right=!0,b.touching.left=!0)):a.deltaX()this._maxOverlap||0==a.allowCollision.left||0==b.allowCollision.right?this._overlap=0:(a.touching.left=!0,b.touching.right=!0)),0!=this._overlap)?(a.overlapX=this._overlap,b.overlapX=this._overlap,a.customSeparateX||b.customSeparateX?!0:(this._velocity1=a.velocity.x,this._velocity2=b.velocity.x,a.immovable||b.immovable?a.immovable?b.immovable||(b.x+=this._overlap,b.velocity.x=this._velocity1-this._velocity2*b.bounce.x):(a.x=a.x-this._overlap,a.velocity.x=this._velocity2-this._velocity1*a.bounce.x):(this._overlap*=.5,a.x=a.x-this._overlap,b.x+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(this._velocity2>0?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(this._velocity1>0?1:-1),this._average=.5*(this._newVelocity1+this._newVelocity2),this._newVelocity1-=this._average,this._newVelocity2-=this._average,a.velocity.x=this._average+this._newVelocity1*a.bounce.x,b.velocity.x=this._average+this._newVelocity2*b.bounce.x),!0)):!1)},separateY:function(a,b){return a.immovable&&b.immovable?!1:(this._overlap=0,e.Rectangle.intersects(a,b)&&(this._maxOverlap=a.deltaAbsY()+b.deltaAbsY()+this.OVERLAP_BIAS,0==a.deltaY()&&0==b.deltaY()?(a.embedded=!0,b.embedded=!0):a.deltaY()>b.deltaY()?(this._overlap=a.y+a.height-b.y,this._overlap>this._maxOverlap||0==a.allowCollision.down||0==b.allowCollision.up?this._overlap=0:(a.touching.down=!0,b.touching.up=!0)):a.deltaY()this._maxOverlap||0==a.allowCollision.up||0==b.allowCollision.down?this._overlap=0:(a.touching.up=!0,b.touching.down=!0)),0!=this._overlap)?(a.overlapY=this._overlap,b.overlapY=this._overlap,a.customSeparateY||b.customSeparateY?!0:(this._velocity1=a.velocity.y,this._velocity2=b.velocity.y,a.immovable||b.immovable?a.immovable?b.immovable||(b.y+=this._overlap,b.velocity.y=this._velocity1-this._velocity2*b.bounce.y,a.sprite.active&&a.moves&&a.deltaY()b.deltaY()&&(a.x+=b.x-b.lastX)):(this._overlap*=.5,a.y=a.y-this._overlap,b.y+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(this._velocity2>0?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(this._velocity1>0?1:-1),this._average=.5*(this._newVelocity1+this._newVelocity2),this._newVelocity1-=this._average,this._newVelocity2-=this._average,a.velocity.y=this._average+this._newVelocity1*a.bounce.y,b.velocity.y=this._average+this._newVelocity2*b.bounce.y),!0)):!1)},separateTile:function(a,b){return this._result=this.separateTileX(a,b,!0)||this.separateTileY(a,b,!0),this._result},separateTileX:function(a,b,c){return a.immovable||0==a.deltaX()||0==e.Rectangle.intersects(a.hullX,b)?!1:(this._overlap=0,a.deltaX()<0?(this._overlap=b.right-a.hullX.x,0==a.allowCollision.left||0==b.tile.collideRight?this._overlap=0:a.touching.left=!0):(this._overlap=a.hullX.right-b.x,0==a.allowCollision.right||0==b.tile.collideLeft?this._overlap=0:a.touching.right=!0),0!=this._overlap?(c&&(a.x=a.deltaX()<0?a.x+this._overlap:a.x-this._overlap,a.velocity.x=0==a.bounce.x?0:-a.velocity.x*a.bounce.x,a.updateHulls()),!0):!1)},separateTileY:function(a,b,c){return a.immovable||0==a.deltaY()||0==e.Rectangle.intersects(a.hullY,b)?!1:(this._overlap=0,a.deltaY()<0?(this._overlap=b.bottom-a.hullY.y,0==a.allowCollision.up||0==b.tile.collideDown?this._overlap=0:a.touching.up=!0):(this._overlap=a.hullY.bottom-b.y,0==a.allowCollision.down||0==b.tile.collideUp?this._overlap=0:a.touching.down=!0),0!=this._overlap?(c&&(a.y=a.deltaY()<0?a.y+this._overlap:a.y-this._overlap,a.velocity.y=0==a.bounce.y?0:-a.velocity.y*a.bounce.y,a.updateHulls()),!0):!1)},moveToObject:function(a,b,c,d){return"undefined"==typeof c&&(c=60),"undefined"==typeof d&&(d=0),this._angle=Math.atan2(b.y-a.y,b.x-a.x),d>0&&(c=this.distanceBetween(a,b)/(d/1e3)),a.body.velocity.x=Math.cos(this._angle)*c,a.body.velocity.y=Math.sin(this._angle)*c,this._angle},moveToPointer:function(a,b,c,d){return"undefined"==typeof b&&(b=60),c=c||this.game.input.activePointer,"undefined"==typeof d&&(d=0),this._angle=this.angleToPointer(a,c),d>0&&(b=this.distanceToPointer(a,c)/(d/1e3)),a.body.velocity.x=Math.cos(this._angle)*b,a.body.velocity.y=Math.sin(this._angle)*b,this._angle},moveToXY:function(a,b,c,d,e){return"undefined"==typeof d&&(d=60),"undefined"==typeof e&&(e=0),this._angle=Math.atan2(c-a.y,b-a.x),e>0&&(d=this.distanceToXY(a,b,c)/(e/1e3)),a.body.velocity.x=Math.cos(this._angle)*d,a.body.velocity.y=Math.sin(this._angle)*d,this._angle},velocityFromAngle:function(a,b,c){return"undefined"==typeof b&&(b=60),c=c||new e.Point,c.setTo(Math.cos(this.game.math.degToRad(a))*b,Math.sin(this.game.math.degToRad(a))*b)},velocityFromRotation:function(a,b,c){return"undefined"==typeof b&&(b=60),c=c||new e.Point,c.setTo(Math.cos(a)*b,Math.sin(a)*b)},accelerationFromRotation:function(a,b,c){return"undefined"==typeof b&&(b=60),c=c||new e.Point,c.setTo(Math.cos(a)*b,Math.sin(a)*b)},accelerateToObject:function(a,b,c,d,e){return"undefined"==typeof c&&(c=60),"undefined"==typeof d&&(d=1e3),"undefined"==typeof e&&(e=1e3),this._angle=this.angleBetween(a,b),a.body.acceleration.setTo(Math.cos(this._angle)*c,Math.sin(this._angle)*c),a.body.maxVelocity.setTo(d,e),this._angle},accelerateToPointer:function(a,b,c,d,e){return"undefined"==typeof c&&(c=60),"undefined"==typeof b&&(b=this.game.input.activePointer),"undefined"==typeof d&&(d=1e3),"undefined"==typeof e&&(e=1e3),this._angle=this.angleToPointer(a,b),a.body.acceleration.setTo(Math.cos(this._angle)*c,Math.sin(this._angle)*c),a.body.maxVelocity.setTo(d,e),this._angle},accelerateToXY:function(a,b,c,d,e,f){return"undefined"==typeof d&&(d=60),"undefined"==typeof e&&(e=1e3),"undefined"==typeof f&&(f=1e3),this._angle=this.angleToXY(a,b,c),a.body.acceleration.setTo(Math.cos(this._angle)*d,Math.sin(this._angle)*d),a.body.maxVelocity.setTo(e,f),this._angle},distanceBetween:function(a,b){return this._dx=a.x-b.x,this._dy=a.y-b.y,Math.sqrt(this._dx*this._dx+this._dy*this._dy)},distanceToXY:function(a,b,c){return this._dx=a.x-b,this._dy=a.y-c,Math.sqrt(this._dx*this._dx+this._dy*this._dy)},distanceToPointer:function(a,b){return b=b||this.game.input.activePointer,this._dx=a.x-b.x,this._dy=a.y-b.y,Math.sqrt(this._dx*this._dx+this._dy*this._dy)},angleBetween:function(a,b){return this._dx=b.x-a.x,this._dy=b.y-a.y,Math.atan2(this._dy,this._dx)},angleToXY:function(a,b,c){return this._dx=b-a.x,this._dy=c-a.y,Math.atan2(this._dy,this._dx)},angleToPointer:function(a,b){return b=b||this.game.input.activePointer,this._dx=b.worldX-a.x,this._dy=b.worldY-a.y,Math.atan2(this._dy,this._dx)}},e.Physics.Arcade.Body=function(a){this.sprite=a,this.game=a.game,this.offset=new e.Point,this.x=a.x,this.y=a.y,this.preX=a.x,this.preY=a.y,this.preRotation=a.angle,this.screenX=a.x,this.screenY=a.y,this.sourceWidth=a.currentFrame.sourceSizeW,this.sourceHeight=a.currentFrame.sourceSizeH,this.width=a.currentFrame.sourceSizeW,this.height=a.currentFrame.sourceSizeH,this.halfWidth=Math.floor(a.currentFrame.sourceSizeW/2),this.halfHeight=Math.floor(a.currentFrame.sourceSizeH/2),this.center=new e.Point(this.x+this.halfWidth,this.y+this.halfHeight),this._sx=a.scale.x,this._sy=a.scale.y,this.velocity=new e.Point,this.acceleration=new e.Point,this.drag=new e.Point,this.gravity=new e.Point,this.bounce=new e.Point,this.maxVelocity=new e.Point(1e4,1e4),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.skipQuadTree=!1,this.quadTreeIDs=[],this.quadTreeIndex=-1,this.allowCollision={none:!1,any:!0,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.facing=e.NONE,this.immovable=!1,this.moves=!0,this.rotation=0,this.allowRotation=!0,this.allowGravity=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.hullX=new e.Rectangle,this.hullY=new e.Rectangle,this.embedded=!1,this.collideWorldBounds=!1},e.Physics.Arcade.Body.prototype={updateBounds:function(a,b,c,d){(c!=this._sx||d!=this._sy)&&(this.width=this.sourceWidth*c,this.height=this.sourceHeight*d,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this._sx=c,this._sy=d,this.center.setTo(this.x+this.halfWidth,this.y+this.halfHeight))},preUpdate:function(){this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.embedded=!1,this.screenX=this.sprite.worldTransform[2]-this.sprite.anchor.x*this.width+this.offset.x,this.screenY=this.sprite.worldTransform[5]-this.sprite.anchor.y*this.height+this.offset.y,this.preX=this.sprite.world.x-this.sprite.anchor.x*this.width+this.offset.x,this.preY=this.sprite.world.y-this.sprite.anchor.y*this.height+this.offset.y,this.preRotation=this.sprite.angle,this.x=this.preX,this.y=this.preY,this.rotation=this.preRotation,this.moves&&(this.game.physics.updateMotion(this),this.collideWorldBounds&&this.checkWorldBounds(),this.updateHulls()),0==this.skipQuadTree&&0==this.allowCollision.none&&this.sprite.visible&&this.sprite.alive&&(this.quadTreeIDs=[],this.quadTreeIndex=-1,this.game.physics.quadTree.insert(this))},postUpdate:function(){this.deltaX()<0?this.facing=e.LEFT:this.deltaX()>0&&(this.facing=e.RIGHT),this.deltaY()<0?this.facing=e.UP:this.deltaY()>0&&(this.facing=e.DOWN),(0!==this.deltaX()||0!==this.deltaY())&&(this.sprite.x+=this.deltaX(),this.sprite.y+=this.deltaY(),this.center.setTo(this.x+this.halfWidth,this.y+this.halfHeight)),this.allowRotation&&(this.sprite.angle+=this.deltaZ())},updateHulls:function(){this.hullX.setTo(this.x,this.preY,this.width,this.height),this.hullY.setTo(this.preX,this.y,this.width,this.height)},checkWorldBounds:function(){this.xthis.game.world.bounds.right&&(this.x=this.game.world.bounds.right-this.width,this.velocity.x*=-this.bounce.x),this.ythis.game.world.bounds.bottom&&(this.y=this.game.world.bounds.bottom-this.height,this.velocity.y*=-this.bounce.y)},setSize:function(a,b,c,d){c=c||this.offset.x,d=d||this.offset.y,this.sourceWidth=a,this.sourceHeight=b,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.setTo(c,d),this.center.setTo(this.x+this.halfWidth,this.y+this.halfHeight)},reset:function(){this.velocity.setTo(0,0),this.acceleration.setTo(0,0),this.angularVelocity=0,this.angularAcceleration=0,this.preX=this.sprite.world.x-this.sprite.anchor.x*this.width+this.offset.x,this.preY=this.sprite.world.y-this.sprite.anchor.y*this.height+this.offset.y,this.preRotation=this.sprite.angle,this.x=this.preX,this.y=this.preY,this.rotation=this.preRotation,this.center.setTo(this.x+this.halfWidth,this.y+this.halfHeight)},deltaAbsX:function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},deltaAbsY:function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},deltaX:function(){return this.x-this.preX},deltaY:function(){return this.y-this.preY},deltaZ:function(){return this.rotation-this.preRotation}},Object.defineProperty(e.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){this.height=a<=this.y?0:this.y-a}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"right",{get:function(){return this.x+this.width},set:function(a){this.width=a<=this.x?0:this.x+a}}),e.Particles=function(){this.emitters={},this.ID=0},e.Particles.prototype={add:function(a){return this.emitters[a.name]=a,a},remove:function(a){delete this.emitters[a.name]},update:function(){for(var a in this.emitters)this.emitters[a].exists&&this.emitters[a].update()}},e.Particles.Arcade={},e.Particles.Arcade.Emitter=function(a,b,c,d){this.maxParticles=d||50,e.Group.call(this,a),this.name="emitter"+this.game.particles.ID++,this.type=e.EMITTER,this.x=0,this.y=0,this.width=1,this.height=1,this.minParticleSpeed=new e.Point(-100,-100),this.maxParticleSpeed=new e.Point(100,100),this.minParticleScale=1,this.maxParticleScale=1,this.minRotation=-360,this.maxRotation=360,this.gravity=2,this.particleClass=null,this.particleDrag=new e.Point,this.angularDrag=0,this.frequency=100,this.lifespan=2e3,this.bounce=new e.Point,this._quantity=0,this._timer=0,this._counter=0,this._explode=!0,this.on=!1,this.exists=!0,this.emitX=b,this.emitY=c},e.Particles.Arcade.Emitter.prototype=Object.create(e.Group.prototype),e.Particles.Arcade.Emitter.prototype.constructor=e.Particles.Arcade.Emitter,e.Particles.Arcade.Emitter.prototype.update=function(){if(this.on)if(this._explode){this._counter=0;do this.emitParticle(),this._counter++;while(this._counter=this._timer&&(this.emitParticle(),this._counter++,this._quantity>0&&this._counter>=this._quantity&&(this.on=!1),this._timer=this.game.time.now+this.frequency)},e.Particles.Arcade.Emitter.prototype.makeParticles=function(a,b,c,d,f){"undefined"==typeof b&&(b=0),c=c||this.maxParticles,d=d||0,"undefined"==typeof f&&(f=!1);for(var g,h=0,i=a,j=0;c>h;)null==this.particleClass&&("object"==typeof a&&(i=this.game.rnd.pick(a)),"object"==typeof b&&(j=this.game.rnd.pick(b)),g=new e.Sprite(this.game,0,0,i,j)),d>0?(g.body.allowCollision.any=!0,g.body.allowCollision.none=!1):g.body.allowCollision.none=!0,g.body.collideWorldBounds=f,g.exists=!1,g.visible=!1,g.anchor.setTo(.5,.5),this.add(g),h++;return this},e.Particles.Arcade.Emitter.prototype.kill=function(){this.on=!1,this.alive=!1,this.exists=!1},e.Particles.Arcade.Emitter.prototype.revive=function(){this.alive=!0,this.exists=!0},e.Particles.Arcade.Emitter.prototype.start=function(a,b,c,d){"boolean"!=typeof a&&(a=!0),b=b||0,c=c||250,d=d||0,this.revive(),this.visible=!0,this.on=!0,this._explode=a,this.lifespan=b,this.frequency=c,a?this._quantity=d:this._quantity+=d,this._counter=0,this._timer=this.game.time.now+c},e.Particles.Arcade.Emitter.prototype.emitParticle=function(){var a=this.getFirstExists(!1);if(null!=a){if(this.width>1||this.height>1?a.reset(this.game.rnd.integerInRange(this.left,this.right),this.game.rnd.integerInRange(this.top,this.bottom)):a.reset(this.emitX,this.emitY),a.lifespan=this.lifespan,a.body.bounce.setTo(this.bounce.x,this.bounce.y),a.body.velocity.x=this.minParticleSpeed.x!=this.maxParticleSpeed.x?this.game.rnd.integerInRange(this.minParticleSpeed.x,this.maxParticleSpeed.x):this.minParticleSpeed.x,a.body.velocity.y=this.minParticleSpeed.y!=this.maxParticleSpeed.y?this.game.rnd.integerInRange(this.minParticleSpeed.y,this.maxParticleSpeed.y):this.minParticleSpeed.y,a.body.gravity.y=this.gravity,a.body.angularVelocity=this.minRotation!=this.maxRotation?this.game.rnd.integerInRange(this.minRotation,this.maxRotation):this.minRotation,1!==this.minParticleScale||1!==this.maxParticleScale){var b=this.game.rnd.realInRange(this.minParticleScale,this.maxParticleScale);a.scale.setTo(b,b)}a.body.drag.x=this.particleDrag.x,a.body.drag.y=this.particleDrag.y,a.body.angularDrag=this.angularDrag}},e.Particles.Arcade.Emitter.prototype.setSize=function(a,b){this.width=a,this.height=b},e.Particles.Arcade.Emitter.prototype.setXSpeed=function(a,b){a=a||0,b=b||0,this.minParticleSpeed.x=a,this.maxParticleSpeed.x=b},e.Particles.Arcade.Emitter.prototype.setYSpeed=function(a,b){a=a||0,b=b||0,this.minParticleSpeed.y=a,this.maxParticleSpeed.y=b},e.Particles.Arcade.Emitter.prototype.setRotation=function(a,b){a=a||0,b=b||0,this.minRotation=a,this.maxRotation=b},e.Particles.Arcade.Emitter.prototype.at=function(a){this.emitX=a.center.x,this.emitY=a.center.y},Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"alpha",{get:function(){return this._container.alpha},set:function(a){this._container.alpha=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"visible",{get:function(){return this._container.visible},set:function(a){this._container.visible=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"x",{get:function(){return this.emitX},set:function(a){this.emitX=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"y",{get:function(){return this.emitY},set:function(a){this.emitY=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"left",{get:function(){return Math.floor(this.x-this.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"right",{get:function(){return Math.floor(this.x+this.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"top",{get:function(){return Math.floor(this.y-this.height/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return Math.floor(this.y+this.height/2)}}),e.Tile=function(a,b,c,d,e,f){this.tileset=a,this.index=b,this.width=e,this.height=f,this.x=c,this.y=d,this.mass=1,this.collideNone=!0,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.separateX=!0,this.separateY=!0,this.collisionCallback=null,this.collisionCallbackContext=this},e.Tile.prototype={setCollisionCallback:function(a,b){this.collisionCallbackContext=b,this.collisionCallback=a},destroy:function(){this.tileset=null},setCollision:function(a,b,c,d){this.collideLeft=a,this.collideRight=b,this.collideUp=c,this.collideDown=d,this.collideNone=a||b||c||d?!1:!0},resetCollision:function(){this.collideNone=!0,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1}},Object.defineProperty(e.Tile.prototype,"bottom",{get:function(){return this.y+this.height}}),Object.defineProperty(e.Tile.prototype,"right",{get:function(){return this.x+this.width}}),e.Tilemap=function(a,b){this.game=a,this.layers,"string"==typeof b?(this.key=b,this.layers=a.cache.getTilemapData(b).layers,this.calculateIndexes()):this.layers=[],this.currentLayer=0,this.debugMap=[],this.dirty=!1,this._results=[],this._tempA=0,this._tempB=0},e.Tilemap.CSV=0,e.Tilemap.TILED_JSON=1,e.Tilemap.prototype={create:function(a,b,c){for(var d=[],f=0;c>f;f++){d[f]=[];for(var g=0;b>g;g++)d[f][g]=0}this.currentLayer=this.layers.push({name:a,width:b,height:c,alpha:1,visible:!0,tileMargin:0,tileSpacing:0,format:e.Tilemap.CSV,data:d,indexes:[]}),this.dirty=!0},calculateIndexes:function(){for(var a=0;a=0&&b=0&&c=0&&a=0&&b=0&&a=0&&b=0&&b=0&&ca&&(a=0),0>b&&(b=0),c>this.layers[e].width&&(c=this.layers[e].width),d>this.layers[e].height&&(d=this.layers[e].height),this._results.length=0,this._results.push({x:a,y:b,width:c,height:d,layer:e});for(var f=b;b+d>f;f++)for(var g=a;a+c>g;g++)this._results.push({x:g,y:f,index:this.layers[e].data[f][g]});return this._results},paste:function(a,b,c,d){if("undefined"==typeof a&&(a=0),"undefined"==typeof b&&(b=0),"undefined"==typeof d&&(d=this.currentLayer),c&&!(c.length<2)){for(var e=c[1].x-a,f=c[1].y-b,g=1;g1?this.debugMap[this.layers[this.currentLayer].data[c][d]]?b.push("background: "+this.debugMap[this.layers[this.currentLayer].data[c][d]]):b.push("background: #ffffff"):b.push("background: rgb(0, 0, 0)");a+="\n"}b[0]=a,console.log.apply(console,b)},destroy:function(){this.removeAllLayers(),this.game=null}},e.TilemapLayer=function(a,b,c,f,g,h,i,j){this.game=a,this.canvas=e.Canvas.create(f,g),this.context=this.canvas.getContext("2d"),this.baseTexture=new d.BaseTexture(this.canvas),this.texture=new d.Texture(this.baseTexture),this.textureFrame=new e.Frame(0,0,0,f,g,"tilemaplayer",a.rnd.uuid()),e.Sprite.call(this,this.game,b,c,this.texture,this.textureFrame),this.type=e.TILEMAPLAYER,this.fixedToCamera=!0,this.tileset=null,this.tileWidth=0,this.tileHeight=0,this.tileMargin=0,this.tileSpacing=0,this.widthInPixels=0,this.heightInPixels=0,this.renderWidth=f,this.renderHeight=g,this._ga=1,this._dx=0,this._dy=0,this._dw=0,this._dh=0,this._tx=0,this._ty=0,this._results=[],this._tw=0,this._th=0,this._tl=0,this._maxX=0,this._maxY=0,this._startX=0,this._startY=0,this.scrollFactorX=1,this.scrollFactorY=1,this.tilemap=null,this.layer=null,this.index=0,this._x=0,this._y=0,this._prevX=0,this._prevY=0,this.dirty=!0,(h instanceof e.Tileset||"string"==typeof h)&&this.updateTileset(h),i instanceof e.Tilemap&&this.updateMapData(i,j) -},e.TilemapLayer.prototype=Object.create(e.Sprite.prototype),e.TilemapLayer.prototype=e.Utils.extend(!0,e.TilemapLayer.prototype,e.Sprite.prototype,d.Sprite.prototype),e.TilemapLayer.prototype.constructor=e.TilemapLayer,e.TilemapLayer.prototype.update=function(){this.scrollX=this.game.camera.x*this.scrollFactorX,this.scrollY=this.game.camera.y*this.scrollFactorY,this.render()},e.TilemapLayer.prototype.resizeWorld=function(){this.game.world.setBounds(0,0,this.widthInPixels,this.heightInPixels)},e.TilemapLayer.prototype.updateTileset=function(a){if(a instanceof e.Tileset)this.tileset=a;else{if("string"!=typeof a)return;this.tileset=this.game.cache.getTileset("tiles")}this.tileWidth=this.tileset.tileWidth,this.tileHeight=this.tileset.tileHeight,this.tileMargin=this.tileset.tileMargin,this.tileSpacing=this.tileset.tileSpacing,this.updateMax()},e.TilemapLayer.prototype.updateMapData=function(a,b){"undefined"==typeof b&&(b=0),a instanceof e.Tilemap&&(this.tilemap=a,this.layer=this.tilemap.layers[b],this.index=b,this.updateMax(),this.tilemap.dirty=!0)},e.TilemapLayer.prototype._fixX=function(a){if(1===this.scrollFactorX)return a;var b=a-this._x/this.scrollFactorX;return this._x+b},e.TilemapLayer.prototype._unfixX=function(a){if(1===this.scrollFactorX)return a;var b=a-this._x;return this._x/this.scrollFactorX+b},e.TilemapLayer.prototype._fixY=function(a){if(1===this.scrollFactorY)return a;var b=a-this._y/this.scrollFactorY;return this._y+b},e.TilemapLayer.prototype._unfixY=function(a){if(1===this.scrollFactorY)return a;var b=a-this._y;return this._y/this.scrollFactorY+b},e.TilemapLayer.prototype.getTileX=function(a){var b=this.tileWidth*this.scale.x;return this.game.math.snapToFloor(this._fixX(a),b)/b},e.TilemapLayer.prototype.getTileY=function(a){var b=this.tileHeight*this.scale.y;return this.game.math.snapToFloor(this._fixY(a),b)/b},e.TilemapLayer.prototype.getTileXY=function(a,b,c){return c.x=this.getTileX(a),c.y=this.getTileY(b),c},e.TilemapLayer.prototype.getTiles=function(a,b,c,d,e){if(null!==this.tilemap){"undefined"==typeof e&&(e=!1),0>a&&(a=0),0>b&&(b=0),a=this._fixX(a),b=this._fixY(b),c>this.widthInPixels&&(c=this.widthInPixels),d>this.heightInPixels&&(d=this.heightInPixels);var f=this.tileWidth*this.scale.x,g=this.tileHeight*this.scale.y;this._tx=this.game.math.snapToFloor(a,f)/f,this._ty=this.game.math.snapToFloor(b,g)/g,this._tw=(this.game.math.snapToCeil(c,f)+f)/f,this._th=(this.game.math.snapToCeil(d,g)+g)/g,this._results=[];for(var h=0,i=null,j=0,k=0,l=this._ty;lthis.layer.width&&(this._maxX=this.layer.width),this._maxY>this.layer.height&&(this._maxY=this.layer.height),this.widthInPixels=this.layer.width*this.tileWidth,this.heightInPixels=this.layer.height*this.tileHeight),this.dirty=!0},e.TilemapLayer.prototype.render=function(){if(this.tilemap&&this.tilemap.dirty&&(this.dirty=!0),this.dirty&&this.tileset&&this.tilemap&&this.visible){this._prevX=this._dx,this._prevY=this._dy,this._dx=-(this._x-this._startX*this.tileWidth),this._dy=-(this._y-this._startY*this.tileHeight),this._tx=this._dx,this._ty=this._dy,this.context.clearRect(0,0,this.canvas.width,this.canvas.height);for(var a=this._startY;a0?this.deltaX():-this.deltaX()},e.TilemapLayer.prototype.deltaAbsY=function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},e.TilemapLayer.prototype.deltaX=function(){return this._dx-this._prevX},e.TilemapLayer.prototype.deltaY=function(){return this._dy-this._prevY},Object.defineProperty(e.TilemapLayer.prototype,"scrollX",{get:function(){return this._x},set:function(a){a!==this._x&&a>=0&&this.layer&&(this._x=a,this._x>this.widthInPixels-this.renderWidth&&(this._x=this.widthInPixels-this.renderWidth),this._startX=this.game.math.floor(this._x/this.tileWidth),this._startX<0&&(this._startX=0),this._startX+this._maxX>this.layer.width&&(this._startX=this.layer.width-this._maxX),this.dirty=!0)}}),Object.defineProperty(e.TilemapLayer.prototype,"scrollY",{get:function(){return this._y},set:function(a){a!==this._y&&a>=0&&this.layer&&(this._y=a,this._y>this.heightInPixels-this.renderHeight&&(this._y=this.heightInPixels-this.renderHeight),this._startY=this.game.math.floor(this._y/this.tileHeight),this._startY<0&&(this._startY=0),this._startY+this._maxY>this.layer.height&&(this._startY=this.layer.height-this._maxY),this.dirty=!0)}}),e.TilemapParser={tileset:function(a,b,c,d,f,g,h){var i=a.cache.getTilesetImage(b);if(null==i)return null;var j=i.width,k=i.height;0>=c&&(c=Math.floor(-j/Math.min(-1,c))),0>=d&&(d=Math.floor(-k/Math.min(-1,d)));var l=Math.round(j/c),m=Math.round(k/d),n=l*m;if(-1!==f&&(n=f),0==j||0==k||c>j||d>k||0===n)return console.warn("Phaser.TilemapParser.tileSet: width/height zero or width/height < given tileWidth/tileHeight"),null;for(var o=g,p=g,q=new e.Tileset(i,b,c,d,g,h),r=0;n>r;r++)q.addTile(new e.Tile(q,r,o,p,c,d)),o+=c+h,o===j&&(o=g,p+=d+h);return q},parse:function(a,b,c){return c===e.Tilemap.CSV?this.parseCSV(b):c===e.Tilemap.TILED_JSON?this.parseTiledJSON(b):void 0},parseCSV:function(a){a=a.trim();for(var b=[],c=a.split("\n"),d=c.length,e=0,f=0;fa)for(var g=a;b>=g;g++)this.tiles[g].setCollision(c,d,e,f)},setCollision:function(a,b,c,d,e){this.tiles[a]&&this.tiles[a].setCollision(b,c,d,e)}},Object.defineProperty(e.Tileset.prototype,"total",{get:function(){return this.tiles.length}}),d.CanvasRenderer.prototype.render=function(a){d.texturesToUpdate.length=0,d.texturesToDestroy.length=0,d.visibleCount++,a.updateTransform(),this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.width,this.height),this.renderDisplayObject(a),d.Texture.frameUpdates.length>0&&(d.Texture.frameUpdates.length=0)},d.CanvasRenderer.prototype.renderDisplayObject=function(a){var b=a.last._iNext;a=a.first;do if(a.visible)if(a.renderable&&0!=a.alpha){if(a instanceof d.Sprite)a.texture.frame&&(this.context.globalAlpha=a.worldAlpha,a.texture.trimmed?this.context.setTransform(a.worldTransform[0],a.worldTransform[3],a.worldTransform[1],a.worldTransform[4],a.worldTransform[2]+a.texture.trim.x,a.worldTransform[5]+a.texture.trim.y):this.context.setTransform(a.worldTransform[0],a.worldTransform[3],a.worldTransform[1],a.worldTransform[4],a.worldTransform[2],a.worldTransform[5]),this.context.drawImage(a.texture.baseTexture.source,a.texture.frame.x,a.texture.frame.y,a.texture.frame.width,a.texture.frame.height,a.anchor.x*-a.texture.frame.width,a.anchor.y*-a.texture.frame.height,a.texture.frame.width,a.texture.frame.height));else if(a instanceof d.Strip)this.context.setTransform(a.worldTransform[0],a.worldTransform[3],a.worldTransform[1],a.worldTransform[4],a.worldTransform[2],a.worldTransform[5]),this.renderStrip(a);else if(a instanceof d.TilingSprite)this.context.setTransform(a.worldTransform[0],a.worldTransform[3],a.worldTransform[1],a.worldTransform[4],a.worldTransform[2],a.worldTransform[5]),this.renderTilingSprite(a);else if(a instanceof d.CustomRenderable)a.renderCanvas(this);else if(a instanceof d.Graphics)this.context.setTransform(a.worldTransform[0],a.worldTransform[3],a.worldTransform[1],a.worldTransform[4],a.worldTransform[2],a.worldTransform[5]),d.CanvasGraphics.renderGraphics(a,this.context);else if(a instanceof d.FilterBlock)if(a.open){this.context.save();var c=a.mask.alpha,e=a.mask.worldTransform;this.context.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]),a.mask.worldAlpha=.5,this.context.worldAlpha=0,d.CanvasGraphics.renderGraphicsMask(a.mask,this.context),this.context.clip(),a.mask.worldAlpha=c}else this.context.restore();a=a._iNext}else a=a._iNext;else a=a.last._iNext;while(a!=b)},d.WebGLBatch.prototype.update=function(){this.gl;for(var a,b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r=0,s=this.head;s;){if(s.vcount===d.visibleCount){if(b=s.texture.frame.width,c=s.texture.frame.height,e=s.anchor.x,f=s.anchor.y,g=b*(1-e),h=b*-e,i=c*(1-f),j=c*-f,k=8*r,a=s.worldTransform,l=a[0],m=a[3],n=a[1],o=a[4],p=a[2],q=a[5],s.texture.trimmed&&(p+=s.texture.trim.x,q+=s.texture.trim.y),this.verticies[k+0]=l*h+n*j+p,this.verticies[k+1]=o*j+m*h+q,this.verticies[k+2]=l*g+n*j+p,this.verticies[k+3]=o*j+m*g+q,this.verticies[k+4]=l*g+n*i+p,this.verticies[k+5]=o*i+m*g+q,this.verticies[k+6]=l*h+n*i+p,this.verticies[k+7]=o*i+m*h+q,s.updateFrame||s.texture.updateFrame){this.dirtyUVS=!0;var t=s.texture,u=t.frame,v=t.baseTexture.width,w=t.baseTexture.height;this.uvs[k+0]=u.x/v,this.uvs[k+1]=u.y/w,this.uvs[k+2]=(u.x+u.width)/v,this.uvs[k+3]=u.y/w,this.uvs[k+4]=(u.x+u.width)/v,this.uvs[k+5]=(u.y+u.height)/w,this.uvs[k+6]=u.x/v,this.uvs[k+7]=(u.y+u.height)/w,s.updateFrame=!1}if(s.cacheAlpha!=s.worldAlpha){s.cacheAlpha=s.worldAlpha;var x=4*r;this.colors[x]=this.colors[x+1]=this.colors[x+2]=this.colors[x+3]=s.worldAlpha,this.dirtyColors=!0}}else k=8*r,this.verticies[k+0]=0,this.verticies[k+1]=0,this.verticies[k+2]=0,this.verticies[k+3]=0,this.verticies[k+4]=0,this.verticies[k+5]=0,this.verticies[k+6]=0,this.verticies[k+7]=0;r++,s=s.__next}},e}); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.Phaser=b()}(this,function(){function a(a){return[(255&a>>16)/255,(255&a>>8)/255,(255&a)/255]}function b(){return c.Matrix="undefined"!=typeof Float32Array?Float32Array:Array,c.Matrix}function a(a){return[(255&a>>16)/255,(255&a>>8)/255,(255&a)/255]}var c=c||{},d=d||{VERSION:"1.1.3",DEV_VERSION:"1.1.3",GAMES:[],AUTO:0,CANVAS:1,WEBGL:2,SPRITE:0,BUTTON:1,BULLET:2,GRAPHICS:3,TEXT:4,TILESPRITE:5,BITMAPTEXT:6,GROUP:7,RENDERTEXTURE:8,TILEMAP:9,TILEMAPLAYER:10,EMITTER:11,POLYGON:12,BITMAPDATA:13,CANVAS_FILTER:14,WEBGL_FILTER:15,NONE:0,LEFT:1,RIGHT:2,UP:3,DOWN:4};c.InteractionManager=function(){},d.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;var e=0;if(b+1>=a.length)switch(d){case 1:a=Array(b+1-a.length).join(c)+a;break;case 3:var f=Math.ceil((e=b-a.length)/2),g=e-f;a=Array(g+1).join(c)+a+Array(f+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,e,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],e=a[b],h!==e&&(k&&e&&(d.Utils.isPlainObject(e)||(f=Array.isArray(e)))?(f?(f=!1,g=c&&Array.isArray(c)?c:[]):g=c&&d.Utils.isPlainObject(c)?c:{},h[b]=d.Utils.extend(k,g,e)):void 0!==e&&(h[b]=e));return h}},function(){var a=!1;a&&(window.console=void 0),void 0===window.console&&(window.console={debug:function(){return!0},info:function(){return!1},warn:function(){return!1},log:function(){return!1}}),debug=function(a){window.console.debug(a)},info=function(a){window.console.info(a)},warn=function(a){window.console.warn(a)},log=function(a){window.console.log(a)}}(),"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}}()),b(),c.mat3={},c.mat3.create=function(){var a=new c.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},c.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},c.mat4={},c.mat4.create=function(){var a=new c.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},c.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},c.mat3.clone=function(a){var b=new c.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},c.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},c.mat3.toMat4=function(a,b){return b||(b=c.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},c.mat4.create=function(){var a=new c.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},c.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},c.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},c.Point=function(a,b){this.x=a||0,this.y=b||0},c.Point.prototype.clone=function(){return new c.Point(this.x,this.y)},c.Point.prototype.constructor=c.Point,c.Rectangle=function(a,b,c,d){this.x=a||0,this.y=b||0,this.width=c||0,this.height=d||0},c.Rectangle.prototype.clone=function(){return new c.Rectangle(this.x,this.y,this.width,this.height)},c.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},c.Rectangle.prototype.constructor=c.Rectangle,c.Polygon=function(a){if(a instanceof Array||(a=Array.prototype.slice.call(arguments)),"number"==typeof a[0]){for(var b=[],d=0,e=a.length;e>d;d+=2)b.push(new c.Point(a[d],a[d+1]));a=b}this.points=a},c.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},c.Polygon.prototype.constructor=c.Polygon,c.DisplayObject=function(){this.last=this,this.first=this,this.position=new c.Point,this.scale=new c.Point(1,1),this.pivot=new c.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=c.mat3.create(),this.localTransform=c.mat3.create(),this.color=[],this.dynamic=!0,this._sr=0,this._cr=1,this.filterArea=new c.Rectangle(0,0,1,1)},c.DisplayObject.prototype.constructor=c.DisplayObject,c.DisplayObject.prototype.setInteractive=function(a){this.interactive=a},Object.defineProperty(c.DisplayObject.prototype,"interactive",{get:function(){return this._interactive},set:function(a){this._interactive=a,this.stage&&(this.stage.dirty=!0)}}),Object.defineProperty(c.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(c.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))},c.DisplayObjectContainer.prototype.swapChildren=function(){},c.DisplayObjectContainer.prototype.getChildAt=function(a){if(a>=0&&aa;a++)this.children[a].updateTransform()}},c.blendModes={},c.blendModes.NORMAL=0,c.blendModes.SCREEN=1,c.Sprite=function(a){c.DisplayObjectContainer.call(this),this.anchor=new c.Point,this.texture=a,this.blendMode=c.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},c.Sprite.prototype=Object.create(c.DisplayObjectContainer.prototype),c.Sprite.prototype.constructor=c.Sprite,Object.defineProperty(c.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(c.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}}),c.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},c.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},c.Sprite.fromFrame=function(a){var b=c.TextureCache[a];if(!b)throw new Error("The frameId '"+a+"' does not exist in the texture cache"+this);return new c.Sprite(b)},c.Sprite.fromImage=function(a){var b=c.Texture.fromImage(a);return new c.Sprite(b)},c.Stage=function(a){c.DisplayObjectContainer.call(this),this.worldTransform=c.mat3.create(),this.interactive=!0,this.interactionManager=new c.InteractionManager(this),this.dirty=!0,this.__childrenAdded=[],this.__childrenRemoved=[],this.stage=this,this.stage.hitArea=new c.Rectangle(0,0,1e5,1e5),this.setBackgroundColor(a),this.worldVisible=!0},c.Stage.prototype=Object.create(c.DisplayObjectContainer.prototype),c.Stage.prototype.constructor=c.Stage,c.Stage.prototype.setInteractionDelegate=function(a){this.interactionManager.setTargetDomElement(a)},c.Stage.prototype.updateTransform=function(){this.worldAlpha=1,this.vcount=c.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()},c.Stage.prototype.setBackgroundColor=function(b){this.backgroundColor=b||0,this.backgroundColorSplit=a(this.backgroundColor);var c=this.backgroundColor.toString(16);c="000000".substr(0,6-c.length)+c,this.backgroundColorString="#"+c},c.Stage.prototype.getMousePosition=function(){return this.interactionManager.mouse.global},c.CustomRenderable=function(){c.DisplayObject.call(this),this.renderable=!0},c.CustomRenderable.prototype=Object.create(c.DisplayObject.prototype),c.CustomRenderable.prototype.constructor=c.CustomRenderable,c.CustomRenderable.prototype.renderCanvas=function(){},c.CustomRenderable.prototype.initWebGL=function(){},c.CustomRenderable.prototype.renderWebGL=function(){},c.Strip=function(a,b,d){c.DisplayObjectContainer.call(this),this.texture=a,this.blendMode=c.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=d,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},c.Strip.prototype=Object.create(c.DisplayObjectContainer.prototype),c.Strip.prototype.constructor=c.Strip,c.Strip.prototype.setTexture=function(a){this.texture=a,this.width=a.frame.width,this.height=a.frame.height,this.updateFrame=!0},c.Strip.prototype.onTextureUpdate=function(){this.updateFrame=!0},c.Rope=function(a,b){c.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(d){this.verticies=verticies,this.uvs=uvs,this.colors=colors,this.indices=indices}this.refresh()},c.Rope.prototype=Object.create(c.Strip.prototype),c.Rope.prototype.constructor=c.Rope,c.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}}},c.Rope.prototype.updateTransform=function(){var a=this.points;if(!(a.length<1)){var b,d=this.verticies,e=a[0],f={x:0,y:0},g=a[0];this.count-=.2,d[0]=g.x+f.x,d[1]=g.y+f.y,d[2]=g.x-f.x,d[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,d[j]=g.x+f.x,d[j+1]=g.y+f.y,d[j+2]=g.x-f.x,d[j+3]=g.y-f.y,e=g}c.DisplayObjectContainer.prototype.updateTransform.call(this)}},c.Rope.prototype.setTexture=function(a){this.texture=a,this.updateFrame=!0},c.TilingSprite=function(a,b,d){c.DisplayObjectContainer.call(this),this.texture=a,this.width=b,this.height=d,this.tileScale=new c.Point(1,1),this.tilePosition=new c.Point(0,0),this.renderable=!0,this.blendMode=c.blendModes.NORMAL},c.TilingSprite.prototype=Object.create(c.DisplayObjectContainer.prototype),c.TilingSprite.prototype.constructor=c.TilingSprite,c.TilingSprite.prototype.setTexture=function(a){this.texture=a,this.updateFrame=!0},c.TilingSprite.prototype.onTextureUpdate=function(){this.updateFrame=!0},c.AbstractFilter=function(a,b){this.passes=[this],this.dirty=!0,this.padding=0,this.uniforms=b||{},this.fragmentSrc=a||[]},c.BlurFilter=function(){this.blurXFilter=new c.BlurXFilter,this.blurYFilter=new c.BlurYFilter,this.passes=[this.blurXFilter,this.blurYFilter]},Object.defineProperty(c.BlurFilter.prototype,"blur",{get:function(){return this.blurXFilter.blur},set:function(a){this.blurXFilter.blur=this.blurYFilter.blur=a}}),Object.defineProperty(c.BlurFilter.prototype,"blurX",{get:function(){return this.blurXFilter.blur},set:function(a){this.blurXFilter.blur=a}}),Object.defineProperty(c.BlurFilter.prototype,"blurY",{get:function(){return this.blurYFilter.blur},set:function(a){this.blurYFilter.blur=a}}),c.BlurXFilter=function(){c.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"1f",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;","}"]},c.BlurXFilter.prototype=Object.create(c.AbstractFilter.prototype),c.BlurXFilter.prototype.constructor=c.BlurXFilter,Object.defineProperty(c.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}}),c.BlurYFilter=function(){c.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"1f",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;","}"]},c.BlurYFilter.prototype=Object.create(c.AbstractFilter.prototype),c.BlurYFilter.prototype.constructor=c.BlurYFilter,Object.defineProperty(c.BlurYFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.uniforms.blur.value=1/7e3*a}}),c.ColorMatrixFilter=function(){c.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;","}"]},c.ColorMatrixFilter.prototype=Object.create(c.AbstractFilter.prototype),c.ColorMatrixFilter.prototype.constructor=c.ColorMatrixFilter,Object.defineProperty(c.ColorMatrixFilter.prototype,"matrix",{get:function(){return this.uniforms.matrix.value},set:function(a){this.uniforms.matrix.value=a}}),c.CrossHatchFilter=function(){c.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"1f",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);"," }"," }","}"]},c.CrossHatchFilter.prototype=Object.create(c.AbstractFilter.prototype),c.CrossHatchFilter.prototype.constructor=c.BlurYFilter,Object.defineProperty(c.CrossHatchFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.uniforms.blur.value=1/7e3*a}}),c.DisplacementFilter=function(a){c.AbstractFilter.call(this),this.passes=[this],a.baseTexture._powerOf2=!0,this.uniforms={displacementMap:{type:"sampler2D",value:a},scale:{type:"2f",value:{x:30,y:30}},offset:{type:"2f",value:{x:0,y:0}},mapDimensions:{type:"2f",value:{x:1,y:5112}},dimensions:{type:"4fv",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;","}"]},c.DisplacementFilter.prototype=Object.create(c.AbstractFilter.prototype),c.DisplacementFilter.prototype.constructor=c.DisplacementFilter,c.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(c.DisplacementFilter.prototype,"map",{get:function(){return this.uniforms.displacementMap.value},set:function(a){this.uniforms.displacementMap.value=a}}),Object.defineProperty(c.DisplacementFilter.prototype,"scale",{get:function(){return this.uniforms.scale.value},set:function(a){this.uniforms.scale.value=a}}),Object.defineProperty(c.DisplacementFilter.prototype,"offset",{get:function(){return this.uniforms.offset.value},set:function(a){this.uniforms.offset.value=a}}),c.DotScreenFilter=function(){c.AbstractFilter.call(this),this.passes=[this],this.uniforms={scale:{type:"1f",value:1},angle:{type:"1f",value:5},dimensions:{type:"4fv",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);","}"]},c.DotScreenFilter.prototype=Object.create(c.DotScreenFilter.prototype),c.DotScreenFilter.prototype.constructor=c.DotScreenFilter,Object.defineProperty(c.DotScreenFilter.prototype,"scale",{get:function(){return this.uniforms.scale.value},set:function(a){this.dirty=!0,this.uniforms.scale.value=a}}),Object.defineProperty(c.DotScreenFilter.prototype,"angle",{get:function(){return this.uniforms.angle.value},set:function(a){this.dirty=!0,this.uniforms.angle.value=a}}),c.FilterBlock=function(){this.visible=!0,this.renderable=!0},c.InvertFilter=function(){c.AbstractFilter.call(this),this.passes=[this],this.uniforms={invert:{type:"1f",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;","}"]},c.InvertFilter.prototype=Object.create(c.AbstractFilter.prototype),c.InvertFilter.prototype.constructor=c.InvertFilter,Object.defineProperty(c.InvertFilter.prototype,"invert",{get:function(){return this.uniforms.invert.value},set:function(a){this.uniforms.invert.value=a}}),c.PixelateFilter=function(){c.AbstractFilter.call(this),this.passes=[this],this.uniforms={invert:{type:"1f",value:0},dimensions:{type:"4fv",value:new Float32Array([1e4,100,10,10])},pixelSize:{type:"2f",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);","}"]},c.PixelateFilter.prototype=Object.create(c.AbstractFilter.prototype),c.PixelateFilter.prototype.constructor=c.PixelateFilter,Object.defineProperty(c.PixelateFilter.prototype,"size",{get:function(){return this.uniforms.pixelSize.value},set:function(a){this.dirty=!0,this.uniforms.pixelSize.value=a}}),c.RGBSplitFilter=function(){c.AbstractFilter.call(this),this.passes=[this],this.uniforms={red:{type:"2f",value:{x:20,y:20}},green:{type:"2f",value:{x:-20,y:20}},blue:{type:"2f",value:{x:20,y:-20}},dimensions:{type:"4fv",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;","}"]},c.RGBSplitFilter.prototype=Object.create(c.AbstractFilter.prototype),c.RGBSplitFilter.prototype.constructor=c.RGBSplitFilter,Object.defineProperty(c.RGBSplitFilter.prototype,"angle",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.uniforms.blur.value=1/7e3*a}}),c.SepiaFilter=function(){c.AbstractFilter.call(this),this.passes=[this],this.uniforms={sepia:{type:"1f",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;","}"]},c.SepiaFilter.prototype=Object.create(c.AbstractFilter.prototype),c.SepiaFilter.prototype.constructor=c.SepiaFilter,Object.defineProperty(c.SepiaFilter.prototype,"sepia",{get:function(){return this.uniforms.sepia.value},set:function(a){this.uniforms.sepia.value=a}}),c.SmartBlurFilter=function(){c.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"1f",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;","}"]},c.SmartBlurFilter.prototype=Object.create(c.AbstractFilter.prototype),c.SmartBlurFilter.prototype.constructor=c.SmartBlurFilter,Object.defineProperty(c.SmartBlurFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value +},set:function(a){this.uniforms.blur.value=a}}),c.TwistFilter=function(){c.AbstractFilter.call(this),this.passes=[this],this.uniforms={radius:{type:"1f",value:.5},angle:{type:"1f",value:5},offset:{type:"2f",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);","}"]},c.TwistFilter.prototype=Object.create(c.AbstractFilter.prototype),c.TwistFilter.prototype.constructor=c.TwistFilter,Object.defineProperty(c.TwistFilter.prototype,"offset",{get:function(){return this.uniforms.offset.value},set:function(a){this.dirty=!0,this.uniforms.offset.value=a}}),Object.defineProperty(c.TwistFilter.prototype,"radius",{get:function(){return this.uniforms.radius.value},set:function(a){this.dirty=!0,this.uniforms.radius.value=a}}),Object.defineProperty(c.TwistFilter.prototype,"angle",{get:function(){return this.uniforms.angle.value},set:function(a){this.dirty=!0,this.uniforms.angle.value=a}}),c.Graphics=function(){c.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor="black",this.graphicsData=[],this.currentPath={points:[]}},c.Graphics.prototype=Object.create(c.DisplayObjectContainer.prototype),c.Graphics.prototype.constructor=c.Graphics,c.Graphics.prototype.lineStyle=function(a,b,d){0===this.currentPath.points.length&&this.graphicsData.pop(),this.lineWidth=a||0,this.lineColor=b||0,this.lineAlpha=void 0==d?1:d,this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:c.Graphics.POLY},this.graphicsData.push(this.currentPath)},c.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:c.Graphics.POLY},this.currentPath.points.push(a,b),this.graphicsData.push(this.currentPath)},c.Graphics.prototype.lineTo=function(a,b){this.currentPath.points.push(a,b),this.dirty=!0},c.Graphics.prototype.beginFill=function(a,b){this.filling=!0,this.fillColor=a||0,this.fillAlpha=void 0==b?1:b},c.Graphics.prototype.endFill=function(){this.filling=!1,this.fillColor=null,this.fillAlpha=1},c.Graphics.prototype.drawRect=function(a,b,d,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,d,e],type:c.Graphics.RECT},this.graphicsData.push(this.currentPath),this.dirty=!0},c.Graphics.prototype.drawCircle=function(a,b,d){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,d,d],type:c.Graphics.CIRC},this.graphicsData.push(this.currentPath),this.dirty=!0},c.Graphics.prototype.drawElipse=function(a,b,d,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,d,e],type:c.Graphics.ELIP},this.graphicsData.push(this.currentPath),this.dirty=!0},c.Graphics.prototype.clear=function(){this.lineWidth=0,this.filling=!1,this.dirty=!0,this.clearDirty=!0,this.graphicsData=[],this.bounds=null},c.Graphics.prototype.updateFilterBounds=function(){if(!this.bounds){for(var a,b,d,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>d?b:g,h=d+n>h?d+n:h}else if(k===c.Graphics.CIRC||k===c.Graphics.ELIP){b=a.x,d=a.y;var o=a.radius+l/2;e=e>b-o?b-o:e,f=b+o>f?b+o:f,g=g>d-o?d-o:g,h=d+o>h?d+o:h}else for(var p=0;pb-l?b-l:e,f=b+l>f?b+l:f,g=g>d-l?d-l:g,h=d+l>h?d+l:h}this.bounds=new c.Rectangle(e,g,f-e,h-g)}},c.Graphics.POLY=0,c.Graphics.RECT=1,c.Graphics.CIRC=2,c.Graphics.ELIP=3,c.CanvasGraphics=function(){},c.CanvasGraphics.renderGraphics=function(a,b){for(var d=a.worldAlpha,e=0;e1&&(d=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==c.Graphics.POLY){b.beginPath(),b.moveTo(g[0],g[1]);for(var h=1;h0&&(c.Texture.frameUpdates=[])},c.CanvasRenderer.prototype.resize=function(a,b){this.width=a,this.height=b,this.view.width=a,this.view.height=b},c.CanvasRenderer.prototype.renderDisplayObject=function(a){var b,d=this.context;d.globalCompositeOperation="source-over";var e=a.last._iNext;a=a.first;do if(b=a.worldTransform,a.visible)if(a.renderable){if(a instanceof c.Sprite){var f=a.texture.frame;f&&f.width&&f.height&&(d.globalAlpha=a.worldAlpha,d.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),d.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 c.Strip)d.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),this.renderStrip(a);else if(a instanceof c.TilingSprite)d.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),this.renderTilingSprite(a);else if(a instanceof c.CustomRenderable)d.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),a.renderCanvas(this);else if(a instanceof c.Graphics)d.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),c.CanvasGraphics.renderGraphics(a,d);else if(a instanceof c.FilterBlock&&a.data instanceof c.Graphics){var g=a.data;if(a.open){d.save();var h=g.alpha,i=g.worldTransform;d.setTransform(i[0],i[3],i[1],i[4],i[2],i[5]),g.worldAlpha=.5,d.worldAlpha=0,c.CanvasGraphics.renderGraphicsMask(g,d),d.clip(),g.worldAlpha=h}else d.restore()}a=a._iNext}else a=a._iNext;else a=a.last._iNext;while(a!=e)},c.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()},c.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()},c.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()}},c.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;","}"],this.textureCount=0},c.PixiShader.prototype.init=function(){var a=c.compileProgram(this.vertexSrc||c.PixiShader.defaultVertexSrc,this.fragmentSrc),b=c.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 d in this.uniforms)this.uniforms[d].uniformLocation=b.getUniformLocation(a,d);this.program=a},c.PixiShader.prototype.syncUniforms=function(){this.textureCount=1;var a=c.gl;for(var b in this.uniforms){var d=this.uniforms[b].type,e=!1;if(this.uniforms[b].transpose&&(e=this.uniforms[b].transpose),"1f"==d)a.uniform1f(this.uniforms[b].uniformLocation,this.uniforms[b].value);else if("1fv"==d)a.uniform1fv(this.uniforms[b].uniformLocation,this.uniforms[b].value);else if("1i"==d)a.uniform1i(this.uniforms[b].uniformLocation,this.uniforms[b].value);else if("1iv"==d)a.uniform1i(this.uniforms[b].uniformLocation,this.uniforms[b].value);else if("2f"==d)a.uniform2f(this.uniforms[b].uniformLocation,this.uniforms[b].value.x,this.uniforms[b].value.y);else if("2fv"==d)a.uniform2fv(this.uniforms[b].uniformLocation,this.uniforms[b].value);else if("2i"==d)a.uniform2i(this.uniforms[b].uniformLocation,this.uniforms[b].value.x,this.uniforms[b].value.y);else if("2iv"==d)a.uniform2iv(this.uniforms[b].uniformLocation,this.uniforms[b].value);else if("3f"==d)a.uniform3f(this.uniforms[b].uniformLocation,this.uniforms[b].value.x,this.uniforms[b].value.y,this.uniforms[b].value.z);else if("3fv"==d)a.uniform3fv(this.uniforms[b].uniformLocation,this.uniforms[b].value);else if("3i"==d)a.uniform3i(this.uniforms[b].uniformLocation,this.uniforms[b].value.x,this.uniforms[b].value.y,this.uniforms[b].value.z);else if("3iv"==d)a.uniform3iv(this.uniforms[b].uniformLocation,this.uniforms[b].value);else if("4f"==d)a.uniform4f(this.uniforms[b].uniformLocation,this.uniforms[b].value.x,this.uniforms[b].value.y,this.uniforms[b].value.z,this.uniforms[b].value.w);else if("4fv"==d)a.uniform4fv(this.uniforms[b].uniformLocation,this.uniforms[b].value);else if("4i"==d)a.uniform4i(this.uniforms[b].uniformLocation,this.uniforms[b].value.x,this.uniforms[b].value.y,this.uniforms[b].value.z,this.uniforms[b].value.w);else if("4iv"==d)a.uniform4iv(this.uniforms[b].uniformLocation,this.uniforms[b].value);else if("mat2"==d)a.uniformMatrix2fv(this.uniforms[b].uniformLocation,e,this.uniforms[b].value);else if("mat3"==d)a.uniformMatrix3fv(this.uniforms[b].uniformLocation,e,this.uniforms[b].value);else if("mat4"==d)a.uniformMatrix4fv(this.uniforms[b].uniformLocation,e,this.uniforms[b].value);else if("sampler2D"==d&&this.uniforms[b].value&&this.uniforms[b].value.baseTexture.hasLoaded){var f=this.uniforms[b].value.baseTexture._glTexture,g=this.uniforms[b].value.baseTexture.source,h=a.RGBA;this.uniforms[b].format&&"luminance"==this.uniforms[b].format&&(h=a.LUMINANCE),a.activeTexture(a["TEXTURE"+this.textureCount]),this.uniforms[b].wrap?"no-repeat"==this.uniforms[b].wrap||this.uniforms[b].wrap===!1?this.createGLTextureLinear(a,g,f):"repeat"==this.uniforms[b].wrap||this.uniforms[b].wrap===!0?this.createGLTexture(a,g,h,f):"nearest-repeat"==this.uniforms[b].wrap?this.createGLTextureNearestRepeat(a,g,f):"nearest"==this.uniforms[b].wrap?this.createGLTextureNearest(a,g,f):"audio"==this.uniforms[b].wrap?this.createAudioTexture(a,f):"keyboard"==this.uniforms[b].wrap&&this.createKeyboardTexture(a,f):this.createGLTextureLinear(a,g,f),a.uniform1i(this.uniforms[b].uniformLocation,this.textureCount),this.textureCount++}}},c.PixiShader.prototype.createGLTexture=function(a,b,c,d){a.bindTexture(a.TEXTURE_2D,d),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,!1),a.texImage2D(a.TEXTURE_2D,0,c,a.RGBA,a.UNSIGNED_BYTE,b),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR_MIPMAP_LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.REPEAT),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.REPEAT),a.generateMipmap(a.TEXTURE_2D)},c.PixiShader.prototype.createGLTextureLinear=function(a,b,c){a.bindTexture(a.TEXTURE_2D,c),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,!1),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,b),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)},c.PixiShader.prototype.createGLTextureNearestRepeat=function(a,b,c){a.bindTexture(a.TEXTURE_2D,c),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,!1),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,b),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.REPEAT),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.REPEAT)},c.PixiShader.prototype.createGLTextureNearest=function(a,b,c){a.bindTexture(a.TEXTURE_2D,c),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,!1),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,b),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),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)},c.PixiShader.prototype.createAudioTexture=function(a,b){a.bindTexture(a.TEXTURE_2D,b),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),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,512,2,0,a.LUMINANCE,a.UNSIGNED_BYTE,null)},c.PixiShader.prototype.createKeyboardTexture=function(a,b){a.bindTexture(a.TEXTURE_2D,b),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),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),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,256,2,0,a.LUMINANCE,a.UNSIGNED_BYTE,null)},c.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;","}"],c.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;","}"]},c.PrimitiveShader.prototype.init=function(){var a=c.compileProgram(this.vertexSrc,this.fragmentSrc),b=c.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},c.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;","}"]},c.StripShader.prototype.init=function(){var a=c.compileProgram(this.vertexSrc,this.fragmentSrc),b=c.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},c._batchs=[],c._getBatch=function(a){return 0===c._batchs.length?new c.WebGLBatch(a):c._batchs.pop()},c._returnBatch=function(a){a.clean(),c._batchs.push(a)},c._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)},c.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),c.projection.x=f.width/2,c.projection.y=-f.height/2,c.offset.x=-f.x,c.offset.y=-f.y,b.uniform2f(c.defaultShader.projectionVector,f.width/2,-f.height/2),b.uniform2f(c.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},c.WebGLFilterManager.prototype.popFilter=function(){var a=c.gl,b=this.filterStack.pop(),d=b.target.filterArea,e=b._glFilterTexture;if(b.filterPasses.length>1){a.viewport(0,0,d.width,d.height),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=0,this.vertexArray[1]=d.height,this.vertexArray[2]=d.width,this.vertexArray[3]=d.height,this.vertexArray[4]=0,this.vertexArray[5]=0,this.vertexArray[6]=d.width,this.vertexArray[7]=0,a.bufferSubData(a.ARRAY_BUFFER,0,this.vertexArray),a.bindBuffer(a.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=d.width/this.width,this.uvArray[5]=d.height/this.height,this.uvArray[6]=d.width/this.width,this.uvArray[7]=d.height/this.height,a.bufferSubData(a.ARRAY_BUFFER,0,this.uvArray);var f=e,g=this.texturePool.pop();g||(g=new c.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},c.FilterTexture=function(a,b){var d=c.gl;this.frameBuffer=d.createFramebuffer(),this.texture=d.createTexture(),d.bindTexture(d.TEXTURE_2D,this.texture),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.bindFramebuffer(d.FRAMEBUFFER,this.framebuffer),d.bindFramebuffer(d.FRAMEBUFFER,this.frameBuffer),d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,this.texture,0),this.resize(a,b)},c.FilterTexture.prototype.resize=function(a,b){this.width=a,this.height=b;var d=c.gl;d.bindTexture(d.TEXTURE_2D,this.texture),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,a,b,0,d.RGBA,d.UNSIGNED_BYTE,null)},c.WebGLGraphics=function(){},c.WebGLGraphics.renderGraphics=function(a,b){var d=c.gl;a._webGL||(a._webGL={points:[],indices:[],lastIndex:0,buffer:d.createBuffer(),indexBuffer:d.createBuffer()}),a.dirty&&(a.dirty=!1,a.clearDirty&&(a.clearDirty=!1,a._webGL.lastIndex=0,a._webGL.points=[],a._webGL.indices=[]),c.WebGLGraphics.updateGraphics(a)),c.activatePrimitiveShader();var e=c.mat3.clone(a.worldTransform);c.mat3.transpose(e),d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA),d.uniformMatrix3fv(c.primitiveShader.translationMatrix,!1,e),d.uniform2f(c.primitiveShader.projectionVector,b.x,-b.y),d.uniform2f(c.primitiveShader.offsetVector,-c.offset.x,-c.offset.y),d.uniform1f(c.primitiveShader.alpha,a.worldAlpha),d.bindBuffer(d.ARRAY_BUFFER,a._webGL.buffer),d.vertexAttribPointer(c.primitiveShader.aVertexPosition,2,d.FLOAT,!1,24,0),d.vertexAttribPointer(c.primitiveShader.colorAttribute,4,d.FLOAT,!1,24,8),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,a._webGL.indexBuffer),d.drawElements(d.TRIANGLE_STRIP,a._webGL.indices.length,d.UNSIGNED_SHORT,0),c.deactivatePrimitiveShader()},c.WebGLGraphics.updateGraphics=function(a){for(var b=a._webGL.lastIndex;b3&&c.WebGLGraphics.buildPoly(d,a._webGL),d.lineWidth>0&&c.WebGLGraphics.buildLine(d,a._webGL)):d.type==c.Graphics.RECT?c.WebGLGraphics.buildRectangle(d,a._webGL):(d.type==c.Graphics.CIRC||d.type==c.Graphics.ELIP)&&c.WebGLGraphics.buildCircle(d,a._webGL)}a._webGL.lastIndex=a.graphicsData.length;var e=c.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)},c.WebGLGraphics.buildRectangle=function(b,d){var e=b.points,f=e[0],g=e[1],h=e[2],i=e[3];if(b.fill){var j=a(b.fillColor),k=b.fillAlpha,l=j[0]*k,m=j[1]*k,n=j[2]*k,o=d.points,p=d.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)}b.lineWidth&&(b.points=[f,g,f+h,g,f+h,g+i,f,g+i,f,g],c.WebGLGraphics.buildLine(b,d))},c.WebGLGraphics.buildCircle=function(b,d){var e=b.points,f=e[0],g=e[1],h=e[2],i=e[3],j=40,k=2*Math.PI/j;if(b.fill){var l=a(b.fillColor),m=b.fillAlpha,n=l[0]*m,o=l[1]*m,p=l[2]*m,q=d.points,r=d.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(b.lineWidth){b.points=[];for(var t=0;j+1>t;t++)b.points.push(f+Math.sin(k*t)*h,g+Math.cos(k*t)*i);c.WebGLGraphics.buildLine(b,d)}},c.WebGLGraphics.buildLine=function(b,d){var e=b.points;if(0!==e.length){if(b.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)}},c.WebGLGraphics.buildPoly=function(b,d){var e=b.points;if(!(e.length<6)){for(var f=d.points,g=d.indices,h=e.length/2,i=a(b.fillColor),j=b.fillAlpha,k=i[0]*j,l=i[1]*j,m=i[2]*j,n=c.PolyK.Triangulate(e),o=f.length/6,p=0;pp;p++)f.push(e[2*p],e[2*p+1],k,l,m,j)}},c._defaultFrame=new c.Rectangle(0,0,1,1),c.gl,c.WebGLRenderer=function(a,b,d,e,f){this.transparent=!!e,this.width=a||800,this.height=b||600,this.view=d||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{c.gl=this.gl=this.view.getContext("experimental-webgl",h)}catch(i){try{c.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)}}c.initDefaultShaders();var j=this.gl;j.useProgram(c.defaultShader.program),c.WebGLRenderer.gl=j,this.batch=new c.WebGLBatch(j),j.disable(j.DEPTH_TEST),j.disable(j.CULL_FACE),j.enable(j.BLEND),j.colorMask(!0,!0,!0,this.transparent),c.projection=new c.Point(400,300),c.offset=new c.Point(0,0),this.resize(this.width,this.height),this.contextLost=!1,this.stageRenderGroup=new c.WebGLRenderGroup(this.gl,this.transparent)},c.WebGLRenderer.prototype.constructor=c.WebGLRenderer,c.WebGLRenderer.getBatch=function(){return 0===c._batchs.length?new c.WebGLBatch(c.WebGLRenderer.gl):c._batchs.pop()},c.WebGLRenderer.returnBatch=function(a){a.clean(),c._batchs.push(a)},c.WebGLRenderer.prototype.render=function(a){if(!this.contextLost){this.__stage!==a&&(this.__stage=a,this.stageRenderGroup.setRenderable(a)),c.WebGLRenderer.updateTextures(),c.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,c.projection.x=this.width/2,c.projection.y=-this.height/2,this.stageRenderGroup.render(c.projection),a.interactive&&(a._interactiveEventsAdded||(a._interactiveEventsAdded=!0,a.interactionManager.setTarget(this))),c.Texture.frameUpdates.length>0){for(var d=0;dn;n++)renderable=this.batchs[n],renderable instanceof c.WebGLBatch?this.batchs[n].render():this.renderSpecial(renderable,b);endBatch instanceof c.WebGLBatch?endBatch.render(0,h+1):this.renderSpecial(endBatch,b)},c.WebGLRenderGroup.prototype.renderSpecial=function(a,b){var d=a.vcount===c.visibleCount;a instanceof c.TilingSprite?d&&this.renderTilingSprite(a,b):a instanceof c.Strip?d&&this.renderStrip(a,b):a instanceof c.CustomRenderable?d&&a.renderWebGL(this,b):a instanceof c.Graphics?d&&a.renderable&&c.WebGLGraphics.renderGraphics(a,b):a instanceof c.FilterBlock&&this.handleFilterBlock(a,b)},flip=!1;var e=[],f=0;return c.WebGLRenderGroup.prototype.handleFilterBlock=function(a,b){var d=c.gl;if(a.open)a.data instanceof Array?this.filterManager.pushFilter(a):(f++,e.push(a),d.enable(d.STENCIL_TEST),d.colorMask(!1,!1,!1,!1),d.stencilFunc(d.ALWAYS,1,1),d.stencilOp(d.KEEP,d.KEEP,d.INCR),c.WebGLGraphics.renderGraphics(a.data,b),d.colorMask(!0,!0,!0,!0),d.stencilFunc(d.NOTEQUAL,0,e.length),d.stencilOp(d.KEEP,d.KEEP,d.KEEP));else if(a.data instanceof Array)this.filterManager.popFilter();else{var g=e.pop(a);g&&(d.colorMask(!1,!1,!1,!1),d.stencilFunc(d.ALWAYS,1,1),d.stencilOp(d.KEEP,d.KEEP,d.DECR),c.WebGLGraphics.renderGraphics(g.data,b),d.colorMask(!0,!0,!0,!0),d.stencilFunc(d.NOTEQUAL,0,e.length),d.stencilOp(d.KEEP,d.KEEP,d.KEEP)),d.disable(d.STENCIL_TEST)}},c.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)},c.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)},c.WebGLRenderGroup.prototype.removeFilterBlocks=function(a,b){this.removeObject(a),this.removeObject(b)},c.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)},c.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)}},c.WebGLRenderGroup.prototype.insertObject=function(a,b,d){var e=b,f=d;if(a instanceof c.Sprite){var g,h;if(e instanceof c.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 c.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=c.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=c.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 c.TilingSprite?this.initTilingSprite(a):a instanceof c.Strip&&this.initStrip(a),this.insertAfter(a,e)},c.WebGLRenderGroup.prototype.insertAfter=function(a,b){if(b instanceof c.Sprite){var d=b.batch;if(d)if(d.tail==b){var e=this.batchs.indexOf(d);this.batchs.splice(e+1,0,a)}else{var f=d.split(b.__next),e=this.batchs.indexOf(d);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)}},c.WebGLRenderGroup.prototype.removeObject=function(a){var b;if(a instanceof c.Sprite){var d=a.batch;if(!d)return;d.remove(a),0==d.size&&(b=d)}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 c.WebGLBatch&&c.WebGLRenderer.returnBatch(b),void 0;if(this.batchs[e-1]instanceof c.WebGLBatch&&this.batchs[e+1]instanceof c.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 c.WebGLBatch&&c.WebGLRenderer.returnBatch(b),c.WebGLRenderer.returnBatch(this.batchs[e+1]),this.batchs.splice(e,2),void 0;this.batchs.splice(e,1),b instanceof c.WebGLBatch&&c.WebGLRenderer.returnBatch(b)}},c.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},c.WebGLRenderGroup.prototype.renderStrip=function(a,b){var d=this.gl;c.activateStripShader();var e=c.stripShader;e.program;var f=c.mat3.clone(a.worldTransform);c.mat3.transpose(f),d.uniformMatrix3fv(e.translationMatrix,!1,f),d.uniform2f(e.projectionVector,b.x,b.y),d.uniform2f(e.offsetVector,-c.offset.x,-c.offset.y),d.uniform1f(e.alpha,a.worldAlpha),a.dirty?(a.dirty=!1,d.bindBuffer(d.ARRAY_BUFFER,a._vertexBuffer),d.bufferData(d.ARRAY_BUFFER,a.verticies,d.STATIC_DRAW),d.vertexAttribPointer(e.aVertexPosition,2,d.FLOAT,!1,0,0),d.bindBuffer(d.ARRAY_BUFFER,a._uvBuffer),d.bufferData(d.ARRAY_BUFFER,a.uvs,d.STATIC_DRAW),d.vertexAttribPointer(e.aTextureCoord,2,d.FLOAT,!1,0,0),d.activeTexture(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,a.texture.baseTexture._glTexture),d.bindBuffer(d.ARRAY_BUFFER,a._colorBuffer),d.bufferData(d.ARRAY_BUFFER,a.colors,d.STATIC_DRAW),d.vertexAttribPointer(e.colorAttribute,1,d.FLOAT,!1,0,0),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,a._indexBuffer),d.bufferData(d.ELEMENT_ARRAY_BUFFER,a.indices,d.STATIC_DRAW)):(d.bindBuffer(d.ARRAY_BUFFER,a._vertexBuffer),d.bufferSubData(d.ARRAY_BUFFER,0,a.verticies),d.vertexAttribPointer(e.aVertexPosition,2,d.FLOAT,!1,0,0),d.bindBuffer(d.ARRAY_BUFFER,a._uvBuffer),d.vertexAttribPointer(e.aTextureCoord,2,d.FLOAT,!1,0,0),d.activeTexture(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,a.texture.baseTexture._glTexture),d.bindBuffer(d.ARRAY_BUFFER,a._colorBuffer),d.vertexAttribPointer(e.colorAttribute,1,d.FLOAT,!1,0,0),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,a._indexBuffer)),d.drawElements(d.TRIANGLE_STRIP,a.indices.length,d.UNSIGNED_SHORT,0),c.deactivateStripShader()},c.WebGLRenderGroup.prototype.renderTilingSprite=function(a,b){var d=this.gl;c.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,d.bindBuffer(d.ARRAY_BUFFER,a._uvBuffer),d.bufferSubData(d.ARRAY_BUFFER,0,a.uvs),this.renderStrip(a,b)},c.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)},c.initDefaultShaders=function(){c.primitiveShader=new c.PrimitiveShader,c.primitiveShader.init(),c.stripShader=new c.StripShader,c.stripShader.init(),c.defaultShader=new c.PixiShader,c.defaultShader.init();var a=c.gl,b=c.defaultShader.program;a.useProgram(b),a.enableVertexAttribArray(c.defaultShader.aVertexPosition),a.enableVertexAttribArray(c.defaultShader.colorAttribute),a.enableVertexAttribArray(c.defaultShader.aTextureCoord)},c.activatePrimitiveShader=function(){var a=c.gl;a.useProgram(c.primitiveShader.program),a.disableVertexAttribArray(c.defaultShader.aVertexPosition),a.disableVertexAttribArray(c.defaultShader.colorAttribute),a.disableVertexAttribArray(c.defaultShader.aTextureCoord),a.enableVertexAttribArray(c.primitiveShader.aVertexPosition),a.enableVertexAttribArray(c.primitiveShader.colorAttribute)},c.deactivatePrimitiveShader=function(){var a=c.gl;a.useProgram(c.defaultShader.program),a.disableVertexAttribArray(c.primitiveShader.aVertexPosition),a.disableVertexAttribArray(c.primitiveShader.colorAttribute),a.enableVertexAttribArray(c.defaultShader.aVertexPosition),a.enableVertexAttribArray(c.defaultShader.colorAttribute),a.enableVertexAttribArray(c.defaultShader.aTextureCoord)},c.activateStripShader=function(){var a=c.gl;a.useProgram(c.stripShader.program)},c.deactivateStripShader=function(){var a=c.gl;a.useProgram(c.defaultShader.program)},c.CompileVertexShader=function(a,b){return c._CompileShader(a,b,a.VERTEX_SHADER)},c.CompileFragmentShader=function(a,b){return c._CompileShader(a,b,a.FRAGMENT_SHADER)},c._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)},c.compileProgram=function(a,b){var d=c.gl,e=c.CompileFragmentShader(d,b),f=c.CompileVertexShader(d,a),g=d.createProgram();return d.attachShader(g,f),d.attachShader(g,e),d.linkProgram(g),d.getProgramParameter(g,d.LINK_STATUS)||console.log("Could not initialise shaders"),g},c.BitmapText=function(a,b){c.DisplayObjectContainer.call(this),this.setText(a),this.setStyle(b),this.updateText(),this.dirty=!1},c.BitmapText.prototype=Object.create(c.DisplayObjectContainer.prototype),c.BitmapText.prototype.constructor=c.BitmapText,c.BitmapText.prototype.setText=function(a){this.text=a||" ",this.dirty=!0},c.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):c.BitmapText.fonts[this.fontName].size,this.dirty=!0},c.BitmapText.prototype.updateText=function(){for(var a=c.BitmapText.fonts[this.fontName],b=new c.Point,d=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}c.DisplayObjectContainer.prototype.updateTransform.call(this)},c.BitmapText.fonts={},c.Text=function(a,b){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),c.Sprite.call(this,c.Texture.fromCanvas(this.canvas)),this.setText(a),this.setStyle(b),this.updateText(),this.dirty=!1},c.Text.prototype=Object.create(c.Sprite.prototype),c.Text.prototype.constructor=c.Text,c.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},c.Text.prototype.setText=function(a){this.text=a.toString()||" ",this.dirty=!0},c.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)/),d=[],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},c.Text.prototype.destroy=function(a){a&&this.texture.destroy()},c.Text.heightCache={},c.BaseTextureCache={},c.texturesToUpdate=[],c.texturesToDestroy=[],c.BaseTexture=function(a){if(c.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,c.texturesToUpdate.push(this);else{var b=this;this.source.onload=function(){b.hasLoaded=!0,b.width=b.source.width,b.height=b.source.height,c.texturesToUpdate.push(b),b.dispatchEvent({type:"loaded",content:b})}}else this.hasLoaded=!0,this.width=this.source.width,this.height=this.source.height,c.texturesToUpdate.push(this);this._powerOf2=!1}},c.BaseTexture.prototype.constructor=c.BaseTexture,c.BaseTexture.prototype.destroy=function(){this.source instanceof Image&&(this.source.src=null),this.source=null,c.texturesToDestroy.push(this)},c.BaseTexture.fromImage=function(a,b){var d=c.BaseTextureCache[a];if(!d){var e=new Image;b&&(e.crossOrigin=""),e.src=a,d=new c.BaseTexture(e),c.BaseTextureCache[a]=d}return d},c.TextureCache={},c.FrameCache={},c.Texture=function(a,b){if(c.EventTarget.call(this),b||(this.noFrame=!0,b=new c.Rectangle(0,0,1,1)),a instanceof c.Texture&&(a=a.baseTexture),this.baseTexture=a,this.frame=b,this.trim=new c.Point,this.scope=this,a.hasLoaded)this.noFrame&&(b=new c.Rectangle(0,0,a.width,a.height)),this.setFrame(b);else{var d=this;a.addEventListener("loaded",function(){d.onBaseTextureLoaded()})}},c.Texture.prototype.constructor=c.Texture,c.Texture.prototype.onBaseTextureLoaded=function(){var a=this.baseTexture;a.removeEventListener("loaded",this.onLoaded),this.noFrame&&(this.frame=new c.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})},c.Texture.prototype.destroy=function(a){a&&this.baseTexture.destroy()},c.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,c.Texture.frameUpdates.push(this)},c.Texture.fromImage=function(a,b){var d=c.TextureCache[a];return d||(d=new c.Texture(c.BaseTexture.fromImage(a,b)),c.TextureCache[a]=d),d},c.Texture.fromFrame=function(a){var b=c.TextureCache[a];if(!b)throw new Error("The frameId '"+a+"' does not exist in the texture cache "+this);return b},c.Texture.fromCanvas=function(a){var b=new c.BaseTexture(a);return new c.Texture(b)},c.Texture.addTextureToCache=function(a,b){c.TextureCache[b]=a},c.Texture.removeTextureFromCache=function(a){var b=c.TextureCache[a];return c.TextureCache[a]=null,b},c.Texture.frameUpdates=[],c.RenderTexture=function(a,b){c.EventTarget.call(this),this.width=a||100,this.height=b||100,this.indetityMatrix=c.mat3.create(),this.frame=new c.Rectangle(0,0,this.width,this.height),c.gl?this.initWebGL():this.initCanvas()},c.RenderTexture.prototype=Object.create(c.Texture.prototype),c.RenderTexture.prototype.constructor=c.RenderTexture,c.RenderTexture.prototype.initWebGL=function(){var a=c.gl;this.glFramebuffer=a.createFramebuffer(),a.bindFramebuffer(a.FRAMEBUFFER,this.glFramebuffer),this.glFramebuffer.width=this.width,this.glFramebuffer.height=this.height,this.baseTexture=new c.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 c.Point(this.width/2,-this.height/2),this.render=this.renderWebGL},c.RenderTexture.prototype.resize=function(a,b){if(this.width=a,this.height=b,c.gl){this.projection.x=this.width/2,this.projection.y=-this.height/2;var d=c.gl;d.bindTexture(d.TEXTURE_2D,this.baseTexture._glTexture),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,this.width,this.height,0,d.RGBA,d.UNSIGNED_BYTE,null)}else this.frame.width=this.width,this.frame.height=this.height,this.renderer.resize(this.width,this.height)},c.RenderTexture.prototype.initCanvas=function(){this.renderer=new c.CanvasRenderer(this.width,this.height,null,0),this.baseTexture=new c.BaseTexture(this.renderer.view),this.frame=new c.Rectangle(0,0,this.width,this.height),this.render=this.renderCanvas},c.RenderTexture.prototype.renderWebGL=function(a,b,d){var e=c.gl;e.colorMask(!0,!0,!0,!0),e.viewport(0,0,this.width,this.height),e.bindFramebuffer(e.FRAMEBUFFER,this.glFramebuffer),d&&(e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT));var f=a.children,g=a.worldTransform;a.worldTransform=c.mat3.create(),a.worldTransform[4]=-1,a.worldTransform[5]=-2*this.projection.y,b&&(a.worldTransform[2]=b.x,a.worldTransform[5]-=b.y),c.visibleCount++,a.vcount=c.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 c.WebGLRenderGroup(e)),this.renderGroup.setRenderable(a),this.renderGroup.render(this.projection,this.glFramebuffer)),a.worldTransform=g +},c.RenderTexture.prototype.renderCanvas=function(a,b,d){var e=a.children;a.worldTransform=c.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();d&&this.renderer.context.clearRect(0,0,this.width,this.height),this.renderer.renderDisplayObject(a),this.renderer.context.setTransform(1,0,0,1,0,0)},c.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)}},c.PolyK={},c.PolyK.Triangulate=function(a){var b=!0,d=a.length>>1;if(3>d)return[];for(var e=[],f=[],g=0;d>g;g++)f.push(g);for(var g=0,h=d;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(c.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&&c.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;d>g;g++)f.push(g);g=0,h=d,b=!1}}return e.push(f[0],f[1],f[2]),e},c.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},c.PolyK._convex=function(a,b,c,d,e,f,g){return(b-d)*(e-c)+(c-a)*(f-d)>=0==g},d.Camera=function(a,b,c,e,f,g){this.game=a,this.world=a.world,this.id=0,this.view=new d.Rectangle(c,e,f,g),this.screenView=new d.Rectangle(c,e,f,g),this.bounds=new d.Rectangle(c,e,f,g),this.deadzone=null,this.visible=!0,this.atLimit={x:!1,y:!1},this.target=null,this._edge=0,this.displayObject=null},d.Camera.FOLLOW_LOCKON=0,d.Camera.FOLLOW_PLATFORMER=1,d.Camera.FOLLOW_TOPDOWN=2,d.Camera.FOLLOW_TOPDOWN_TIGHT=3,d.Camera.prototype={follow:function(a,b){"undefined"==typeof b&&(b=d.Camera.FOLLOW_LOCKON),this.target=a;var c;switch(b){case d.Camera.FOLLOW_PLATFORMER:var e=this.width/8,f=this.height/3;this.deadzone=new d.Rectangle((this.width-e)/2,(this.height-f)/2-.25*f,e,f);break;case d.Camera.FOLLOW_TOPDOWN:c=Math.max(this.width,this.height)/4,this.deadzone=new d.Rectangle((this.width-c)/2,(this.height-c)/2,c,c);break;case d.Camera.FOLLOW_TOPDOWN_TIGHT:c=Math.max(this.width,this.height)/8,this.deadzone=new d.Rectangle((this.width-c)/2,(this.height-c)/2,c,c);break;case d.Camera.FOLLOW_LOCKON:this.deadzone=null;break;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(d.Camera.prototype,"x",{get:function(){return this.view.x},set:function(a){this.view.x=a,this.bounds&&this.checkBounds()}}),Object.defineProperty(d.Camera.prototype,"y",{get:function(){return this.view.y},set:function(a){this.view.y=a,this.bounds&&this.checkBounds()}}),Object.defineProperty(d.Camera.prototype,"width",{get:function(){return this.view.width},set:function(a){this.view.width=a}}),Object.defineProperty(d.Camera.prototype,"height",{get:function(){return this.view.height},set:function(a){this.view.height=a}}),d.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},d.State.prototype={preload:function(){},loadUpdate:function(){},loadRender:function(){},create:function(){},update:function(){},render:function(){},paused:function(){},destroy:function(){}},d.StateManager=function(a,b){this.game=a,this.states={},this._pendingState=null,null!==b&&(this._pendingState=b),this._created=!1,this.current="",this.onInitCallback=null,this.onPreloadCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onPreRenderCallback=null,this.onLoadUpdateCallback=null,this.onLoadRenderCallback=null,this.onPausedCallback=null,this.onShutDownCallback=null},d.StateManager.prototype={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 e;return b instanceof d.State?e=b:"object"==typeof b?(e=b,e.game=this.game):"function"==typeof b&&(e=new b(this.game)),this.states[a]=e,c&&(this.game.isBooted?this.start(a):this._pendingState=a),e},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),this.game.isBooted===!1?(this._pendingState=a,void 0):(this.checkState(a)!==!1&&(this.current&&this.onShutDownCallback.call(this.callbackContext,this.game),b&&(this.game.tweens.removeAll(),this.game.world.destroy(),c===!0&&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),b===!1&&this.states[a].loadRender&&(b=!0),b===!1&&this.states[a].loadUpdate&&(b=!0),b===!1&&this.states[a].create&&(b=!0),b===!1&&this.states[a].update&&(b=!0),b===!1&&this.states[a].preRender&&(b=!0),b===!1&&this.states[a].render&&(b=!0),b===!1&&this.states[a].paused&&(b=!0),b===!1?(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(){this._created===!1&&this.onCreateCallback?(this._created=!0,this.onCreateCallback.call(this.callbackContext,this.game)):this._created=!0},update:function(){this._created&&this.onUpdateCallback?this.onUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},preRender:function(){this.onPreRenderCallback&&this.onPreRenderCallback.call(this.callbackContext,this.game)},render:function(){this._created&&this.onRenderCallback?(this.game.renderType===d.CANVAS&&(this.game.context.save(),this.game.context.setTransform(1,0,0,1,0,0)),this.onRenderCallback.call(this.callbackContext,this.game),this.game.renderType===d.CANVAS&&this.game.context.restore()):this.onLoadRenderCallback&&this.onLoadRenderCallback.call(this.callbackContext,this.game)},destroy:function(){this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onPausedCallback=null,this.onDestroyCallback=null,this.game=null,this.states={},this._pendingState=null}},d.LinkedList=function(){this.next=null,this.prev=null,this.first=null,this.last=null,this.total=0},d.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)}}},d.Signal=function(){this._bindings=[],this._prevParams=null;var a=this;this.dispatch=function(){d.Signal.prototype.dispatch.apply(a,arguments)}},d.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,e){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 d.SignalBinding(this,a,b,c,e),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()+"]"}},d.SignalBinding=function(a,b,c,d,e){this._listener=b,this._isOnce=c,this.context=d,this._signal=a,this._priority=e||0},d.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+"]"}},d.Filter=function(a,b,c){this.game=a,this.type=d.WEBGL_FILTER,this.passes=[this],this.dirty=!0,this.padding=0,this.uniforms={resolution:{type:"3f",value:{x:256,y:256,z:0}},time:{type:"1f",value:0},mouse:{type:"4f",value:{x:0,y:0,z:0,w:0}}},this.fragmentSrc=c||[]},d.Filter.prototype={init:function(){},setResolution:function(a,b){this.uniforms.resolution.value.x=a,this.uniforms.resolution.value.y=b},update:function(a){"undefined"!=typeof a&&(this.uniforms.mouse.x=a.x,this.uniforms.mouse.y=a.y),this.uniforms.time.value=this.game.time.totalElapsedSeconds()},destroy:function(){this.game=null}},Object.defineProperty(d.Filter.prototype,"width",{get:function(){return this.uniforms.resolution.value.x},set:function(a){this.uniforms.resolution.value.x=a}}),Object.defineProperty(d.Filter.prototype,"height",{get:function(){return this.uniforms.resolution.value.y},set:function(a){this.uniforms.resolution.value.y=a}}),d.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},d.Plugin.prototype={preUpdate:function(){},update:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null,this.parent=null,this.active=!1,this.visible=!1}},d.PluginManager=function(a,b){this.game=a,this._parent=b,this.plugins=[],this._pluginsLength=0},d.PluginManager.prototype={add:function(a){var b=!1;return"function"==typeof a?a=new a(this.game,this._parent):(a.game=this.game,a.parent=this._parent),"function"==typeof a.preUpdate&&(a.hasPreUpdate=!0,b=!0),"function"==typeof a.update&&(a.hasUpdate=!0,b=!0),"function"==typeof a.postUpdate&&(a.hasPostUpdate=!0,b=!0),"function"==typeof a.render&&(a.hasRender=!0,b=!0),"function"==typeof a.postRender&&(a.hasPostRender=!0,b=!0),b?((a.hasPreUpdate||a.hasUpdate)&&(a.active=!0),(a.hasRender||a.hasPostRender)&&(a.visible=!0),this._pluginsLength=this.plugins.push(a),"function"==typeof a.init&&a.init(),a):null},remove:function(a){if(0!==this._pluginsLength)for(this._p=0;this._pthis._nextOffsetCheck&&(d.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||document.hidden===!0||document.webkitHidden===!0?!0:!1)}},Object.defineProperty(d.Stage.prototype,"backgroundColor",{get:function(){return this._backgroundColor},set:function(a){this._backgroundColor=a,this.game.transparent===!1&&(this.game.renderType==d.CANVAS?this.game.canvas.style.backgroundColor=a:("string"==typeof a&&(a=d.Color.hexToRGB(a)),this._stage.setBackgroundColor(a)))}}),d.Group=function(a,b,e,f){("undefined"==typeof b||null===typeof b)&&(b=a.world),"undefined"==typeof f&&(f=!1),this.game=a,this.name=e||"group",f?this._container=this.game.stage._stage:(this._container=new c.DisplayObjectContainer,this._container.name=this.name,b?b instanceof d.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=d.GROUP,this.exists=!0,this.scale=new d.Point(1,1),this.cursor=null},d.Group.RETURN_NONE=0,d.Group.RETURN_TOTAL=1,d.Group.RETURN_CHILD=2,d.Group.SORT_ASCENDING=-1,d.Group.SORT_DESCENDING=1,d.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,e,f){"undefined"==typeof f&&(f=!0);var g=new d.Sprite(this.game,a,b,c,e);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,e){"undefined"==typeof e&&(e=!1);for(var f=0;a>f;f++){var g=new d.Sprite(this.game,0,0,b,c);g.group=this,g.exists=e,g.visible=e,g.alive=e,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(c===!1||c&&f.alive)&&(d===!1||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,g=null;if(this._container.children.length>0&&this._container.first._iNext){var h=this._container.first._iNext;do f=this.callbackFromArray(h,a,c),b&&f?(g=this.callbackFromArray(h,b,d),f&&f.apply(g,e)):f&&f.apply(h,e),h=h._iNext;while(h!=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(c===!1||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,d.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,d.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,d.Group.RETURN_TOTAL,a,b,c)},sort:function(a,b){"undefined"==typeof a&&(a="y"),"undefined"==typeof b&&(b=d.Group.SORT_ASCENDING);var c,e;do{c=!1;for(var f=0,g=this._container.children.length-1;g>f;f++)b==d.Group.SORT_ASCENDING?this._container.children[f][a]>this._container.children[f+1][a]&&(this.swap(this.getAt(f),this.getAt(f+1)),e=this._container.children[f],this._container.children[f]=this._container.children[f+1],this._container.children[f+1]=e,c=!0):this._container.children[f][a]0&&this._container.first._iNext){var i=this._container.first._iNext;do{if(i[a]===b&&(h++,e&&(g[0]=i,e.apply(f,g)),c==d.Group.RETURN_CHILD))return i;i=i._iNext}while(i!=this._container.last._iNext)}return c==d.Group.RETURN_TOTAL?h:c==d.Group.RETURN_CHILD?null:void 0},getFirstExists:function(a){return"boolean"!=typeof a&&(a=!0),this.iterate("exists",a,d.Group.RETURN_CHILD)},getFirstAlive:function(){return this.iterate("alive",!0,d.Group.RETURN_CHILD)},getFirstDead:function(){return this.iterate("alive",!1,d.Group.RETURN_CHILD)},countLiving:function(){return this.iterate("alive",!0,d.Group.RETURN_TOTAL)},countDead:function(){return this.iterate("alive",!1,d.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"+d.Utils.pad("Node",b)+"|"+d.Utils.pad("Next",b)+"|"+d.Utils.pad("Previous",b)+"|"+d.Utils.pad("First",b)+"|"+d.Utils.pad("Last",b);console.log(c);var c=d.Utils.pad("----------",b)+"|"+d.Utils.pad("----------",b)+"|"+d.Utils.pad("----------",b)+"|"+d.Utils.pad("----------",b)+"|"+d.Utils.pad("----------",b);if(console.log(c),a)var e=this.game.stage._stage.last._iNext,f=this.game.stage._stage;else var e=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=d.Utils.pad(g,b)+"|"+d.Utils.pad(h,b)+"|"+d.Utils.pad(i,b)+"|"+d.Utils.pad(j,b)+"|"+d.Utils.pad(k,b);console.log(c),f=f._iNext}while(f!=e)}},Object.defineProperty(d.Group.prototype,"total",{get:function(){return this.iterate("exists",!0,d.Group.RETURN_TOTAL)}}),Object.defineProperty(d.Group.prototype,"length",{get:function(){return this.iterate("exists",!0,d.Group.RETURN_TOTAL)}}),Object.defineProperty(d.Group.prototype,"x",{get:function(){return this._container.position.x},set:function(a){this._container.position.x=a}}),Object.defineProperty(d.Group.prototype,"y",{get:function(){return this._container.position.y},set:function(a){this._container.position.y=a}}),Object.defineProperty(d.Group.prototype,"angle",{get:function(){return d.Math.radToDeg(this._container.rotation)},set:function(a){this._container.rotation=d.Math.degToRad(a)}}),Object.defineProperty(d.Group.prototype,"rotation",{get:function(){return this._container.rotation},set:function(a){this._container.rotation=a}}),Object.defineProperty(d.Group.prototype,"visible",{get:function(){return this._container.visible},set:function(a){this._container.visible=a}}),Object.defineProperty(d.Group.prototype,"alpha",{get:function(){return this._container.alpha},set:function(a){this._container.alpha=a}}),d.World=function(a){d.Group.call(this,a,null,"__world",!1),this.scale=new d.Point(1,1),this.bounds=new d.Rectangle(0,0,a.width,a.height),this.camera=null,this.currentRenderOrderID=0},d.World.prototype=Object.create(d.Group.prototype),d.World.prototype.constructor=d.World,d.World.prototype.boot=function(){this.camera=new d.Camera(this.game,0,0,0,this.game.width,this.game.height),this.camera.displayObject=this._container,this.game.camera=this.camera},d.World.prototype.update=function(){if(this.currentRenderOrderID=0,this.game.stage._stage.first._iNext){var a,b=this.game.stage._stage.first._iNext;do a=!1,b.preUpdate&&(a=b.preUpdate()===!1),b.update&&(a=b.update()===!1||a),b=a?b.last._iNext:b._iNext;while(b!=this.game.stage._stage.last._iNext)}},d.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)}},d.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) +},d.World.prototype.destroy=function(){this.camera.x=0,this.camera.y=0,this.game.input.reset(!0),this.removeAll()},Object.defineProperty(d.World.prototype,"width",{get:function(){return this.bounds.width},set:function(a){this.bounds.width=a}}),Object.defineProperty(d.World.prototype,"height",{get:function(){return this.bounds.height},set:function(a){this.bounds.height=a}}),Object.defineProperty(d.World.prototype,"centerX",{get:function(){return this.bounds.halfWidth}}),Object.defineProperty(d.World.prototype,"centerY",{get:function(){return this.bounds.halfHeight}}),Object.defineProperty(d.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(d.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(d.World.prototype,"visible",{get:function(){return this._container.visible},set:function(a){this._container.visible=a}}),d.Game=function(a,b,c,e,f,g,h){a=a||800,b=b||600,c=c||d.AUTO,e=e||"",f=f||null,"undefined"==typeof g&&(g=!1),"undefined"==typeof h&&(h=!0),this.id=d.GAMES.push(this)-1,this.parent=e,this.width=a,this.height=b,this.transparent=g,this.antialias=h,this.renderer=null,this.state=new d.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},d.Game.prototype={boot:function(){this.isBooted||(document.body?(document.removeEventListener("DOMContentLoaded",this._onBoot),window.removeEventListener("load",this._onBoot),this.onPause=new d.Signal,this.onResume=new d.Signal,this.isBooted=!0,this.device=new d.Device,this.math=d.Math,this.rnd=new d.RandomDataGenerator([(Date.now()*Math.random()).toString()]),this.stage=new d.Stage(this,this.width,this.height),this.setUpRenderer(),this.world=new d.World(this),this.add=new d.GameObjectFactory(this),this.cache=new d.Cache(this),this.load=new d.Loader(this),this.time=new d.Time(this),this.tweens=new d.TweenManager(this),this.input=new d.Input(this),this.sound=new d.SoundManager(this),this.physics=new d.Physics.Arcade(this),this.particles=new d.Particles(this),this.plugins=new d.PluginManager(this,this),this.net=new d.Net(this),this.debug=new d.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 d.RequestAnimationFrame(this),this.raf.start()):window.setTimeout(this._onBoot,20))},showDebugHeader:function(){var a=d.DEV_VERSION,b="Canvas",c="HTML Audio";if(this.renderType==d.WEBGL&&(b="WebGL"),this.device.webAudio&&(c="WebAudio"),this.device.chrome){var e=["%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,e)}else console.log("Phaser v"+a+" - Renderer: "+b+" - Audio: "+c)},setUpRenderer:function(){if(this.renderType===d.CANVAS||this.renderType===d.AUTO&&this.device.webGL===!1){if(!this.device.canvas)throw new Error("Phaser.Game - cannot create Canvas or WebGL context, aborting.");this.renderType=d.CANVAS,this.renderer=new c.CanvasRenderer(this.width,this.height,this.stage.canvas,this.transparent),d.Canvas.setSmoothingEnabled(this.renderer.context,this.antialias),this.canvas=this.renderer.view,this.context=this.renderer.context}else this.renderType=d.WEBGL,this.renderer=new c.WebGLRenderer(this.width,this.height,this.stage.canvas,this.transparent,this.antialias),this.canvas=this.renderer.view,this.context=null;d.Canvas.addToDOM(this.renderer.view,this.parent,!0),d.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(d.Game.prototype,"paused",{get:function(){return this._paused},set:function(a){a===!0?this._paused===!1&&(this._paused=!0,this.onPause.dispatch(this)):this._paused&&(this._paused=!1,this.onResume.dispatch(this))}}),d.Input=function(a){this.game=a,this.hitCanvas=null,this.hitContext=null},d.Input.MOUSE_OVERRIDES_TOUCH=0,d.Input.TOUCH_OVERRIDES_MOUSE=1,d.Input.MOUSE_TOUCH_COMBINE=2,d.Input.prototype={pollRate:0,_pollCounter:0,_oldPosition:null,_x:0,_y:0,disabled:!1,multiInputOverride:d.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 d.LinkedList,boot:function(){this.mousePointer=new d.Pointer(this.game,0),this.pointer1=new d.Pointer(this.game,1),this.pointer2=new d.Pointer(this.game,2),this.mouse=new d.Mouse(this.game),this.keyboard=new d.Keyboard(this.game),this.touch=new d.Touch(this.game),this.mspointer=new d.MSPointer(this.game),this.onDown=new d.Signal,this.onUp=new d.Signal,this.onTap=new d.Signal,this.onHold=new d.Signal,this.scale=new d.Point(1,1),this.speed=new d.Point,this.position=new d.Point,this._oldPosition=new d.Point,this.circle=new d.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 d.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",a===!0&&(this.onDown.dispose(),this.onUp.dispose(),this.onTap.dispose(),this.onHold.dispose(),this.onDown=new d.Signal,this.onUp=new d.Signal,this.onTap=new d.Signal,this.onHold=new d.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(this.pointer1.active===!1)return this.pointer1.start(a);if(this.pointer2.active===!1)return this.pointer2.start(a);for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].active===!1)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(d.Input.prototype,"x",{get:function(){return this._x},set:function(a){this._x=Math.floor(a)}}),Object.defineProperty(d.Input.prototype,"y",{get:function(){return this._y},set:function(a){this._y=Math.floor(a)}}),Object.defineProperty(d.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(d.Input.prototype,"worldX",{get:function(){return this.game.camera.view.x+this.x}}),Object.defineProperty(d.Input.prototype,"worldY",{get:function(){return this.game.camera.view.y+this.y}}),d.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 d.Signal,this.onUp=new d.Signal},d.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==d.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==d.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==d.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==d.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==d.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==d.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&&this.targetObject.isDragged===!0)return this.targetObject.update(this)===!1&&(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?this._highestRenderObject.update(this)===!1&&(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==d.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==d.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==d.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,this.isMouse===!1&&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(){this.isMouse===!1&&(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}},Object.defineProperty(d.Pointer.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.now-this.timeDown}}),Object.defineProperty(d.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x}}),Object.defineProperty(d.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y}}),d.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.event=null,this._onTouchStart=null,this._onTouchMove=null,this._onTouchEnd=null,this._onTouchEnter=null,this._onTouchLeave=null,this._onTouchCancel=null,this._onTouchMove=null},d.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.event=a,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 d.Point,this.enabled=!0,this.sprite.events&&null==this.sprite.events.onInputOver&&(this.sprite.events.onInputOver=new d.Signal,this.sprite.events.onInputOut=new d.Signal,this.sprite.events.onInputDown=new d.Signal,this.sprite.events.onInputUp=new d.Signal,this.sprite.events.onDragStart=new d.Signal,this.sprite.events.onDragStop=new d.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(){this.enabled!==!1&&(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(a){if(this.enabled){if("undefined"!=typeof a)return this._pointerData[a].isOut;for(var b=0;10>b;b++)if(this._pointerData[b].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 this.enabled===!1||this.sprite.visible===!1||this.sprite.group&&this.sprite.group.visible===!1?(this._pointerOutHandler(a),!1):this.draggable&&this._draggedPointerID==a.id?this.updateDrag(a):this._pointerData[a.id].isOver===!0?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){this._pointerData[a.id].isOver===!1&&(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&&this._pointerData[a.id].isDragged===!1&&(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&&this._pointerData[a.id].isDragged===!1&&(this.game.stage.canvas.style.cursor="default"),this.sprite&&this.sprite.events&&this.sprite.events.onInputOut.dispatch(this.sprite,a)},_touchedHandler:function(a){return this._pointerData[a.id].isDown===!1&&this._pointerData[a.id].isOver===!0&&(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&&this.isDragged===!1&&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),this.checkPointerOver(a)===!1&&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)}},d.Events=function(a){this.parent=a,this.onAddedToGroup=new d.Signal,this.onRemovedFromGroup=new d.Signal,this.onKilled=new d.Signal,this.onRevived=new d.Signal,this.onOutOfBounds=new d.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},d.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())}},d.GameObjectFactory=function(a){this.game=a,this.world=this.game.world},d.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 d.Group(this.game,a,b)},audio:function(a,b,c){return this.game.sound.add(a,b,c)},tileSprite:function(a,b,c,e,f,g){return this.world.add(new d.TileSprite(this.game,a,b,c,e,f,g))},text:function(a,b,c,e){return this.world.add(new d.Text(this.game,a,b,c,e))},button:function(a,b,c,e,f,g,h,i){return this.world.add(new d.Button(this.game,a,b,c,e,f,g,h,i))},graphics:function(a,b){return this.world.add(new d.Graphics(this.game,a,b))},emitter:function(a,b,c){return this.game.particles.add(new d.Particles.Arcade.Emitter(this.game,a,b,c))},bitmapText:function(a,b,c,e){return this.world.add(new d.BitmapText(this.game,a,b,c,e))},tilemap:function(a){return new d.Tilemap(this.game,a)},tileset:function(a){return this.game.cache.getTileset(a)},tilemapLayer:function(a,b,c,e,f,g,h){return this.world.add(new d.TilemapLayer(this.game,a,b,c,e,f,g,h))},renderTexture:function(a,b,c){var e=new d.RenderTexture(this.game,a,b,c);return this.game.cache.addRenderTexture(a,e),e},bitmapData:function(a,b){return new d.BitmapData(this.game,a,b)},filter:function(a){var b=Array.prototype.splice.call(arguments,1),c=new d.Filter[a](this.game);return c.init.apply(c,b),c}},d.BitmapData=function(a,b,e){"undefined"==typeof b&&(b=256),"undefined"==typeof e&&(e=256),this.game=a,this.name="",this.width=b,this.height=e,this.canvas=d.Canvas.create(b,e),this.context=this.canvas.getContext("2d"),this.imageData=this.context.getImageData(0,0,b,e),this.pixels=this.imageData.data.buffer?this.imageData.data.buffer:this.imageData.data,this.baseTexture=new c.BaseTexture(this.canvas),this.texture=new c.Texture(this.baseTexture),this.textureFrame=new d.Frame(0,0,0,b,e,"bitmapData",a.rnd.uuid()),this.type=d.BITMAPDATA,this._dirty=!1},d.BitmapData.prototype={add:function(a){a.loadTexture(this)},addTo:function(a){for(var b=0;b=0&&a<=this.width&&b>=0&&b<=this.height&&(this.pixels[b*this.width+a]=f<<24|e<<16|d<<8|c,this.context.putImageData(this.imageData,0,0),this._dirty=!0)},setPixel:function(a,b,c,d,e){this.setPixel32(a,b,c,d,e,255)},getPixel:function(a,b){return a>=0&&a<=this.width&&b>=0&&b<=this.height?this.data32[b*this.width+a]:void 0},getPixel32:function(a,b){return a>=0&&a<=this.width&&b>=0&&b<=this.height?this.data32[b*this.width+a]:void 0},getPixels:function(a){return this.context.getImageData(a.x,a.y,a.width,a.height)},arc:function(a,b,c,d,e,f){return"undefined"==typeof f&&(f=!1),this._dirty=!0,this.context.arc(a,b,c,d,e,f),this},arcTo:function(a,b,c,d,e){return this._dirty=!0,this.context.arcTo(a,b,c,d,e),this},beginFill:function(a){return this.fillStyle(a),this},beginLinearGradientFill:function(a,b,c,d,e,f){for(var g=this.createLinearGradient(c,d,e,f),h=0,i=a.length;i>h;h++)g.addColorStop(b[h],a[h]);return this.fillStyle(g),this},beginLinearGradientStroke:function(a,b,c,d,e,f){for(var g=this.createLinearGradient(c,d,e,f),h=0,i=a.length;i>h;h++)g.addColorStop(b[h],a[h]);return this.strokeStyle(g),this},beginRadialGradientStroke:function(a,b,c,d,e,f,g,h){for(var i=this.createRadialGradient(c,d,e,f,g,h),j=0,k=a.length;k>j;j++)i.addColorStop(b[j],a[j]);return this.strokeStyle(i),this},beginPath:function(){return this.context.beginPath(),this},beginStroke:function(a){return this.strokeStyle(a),this},bezierCurveTo:function(a,b,c,d,e,f){return this._dirty=!0,this.context.bezierCurveTo(a,b,c,d,e,f),this},circle:function(a,b,c){return this.arc(a,b,c,0,2*Math.PI),this},clearRect:function(a,b,c,d){return this._dirty=!0,this.context.clearRect(a,b,c,d),this},clip:function(){return this._dirty=!0,this.context.clip(),this},closePath:function(){return this._dirty=!0,this.context.closePath(),this},createLinearGradient:function(a,b,c,d){return this.context.createLinearGradient(a,b,c,d)},createRadialGradient:function(a,b,c,d,e,f){return this.context.createRadialGradient(a,b,c,d,e,f)},ellipse:function(a,b,c,d){var e=.5522848,f=c/2*e,g=d/2*e,h=a+c,i=b+d,j=a+c/2,k=b+d/2;return this.moveTo(a,k),this.bezierCurveTo(a,k-g,j-f,b,j,b),this.bezierCurveTo(j+f,b,h,k-g,h,k),this.bezierCurveTo(h,k+g,j+f,i,j,i),this.bezierCurveTo(j-f,i,a,k+g,a,k),this},fill:function(){return this._dirty=!0,this.context.fill(),this},fillRect:function(a,b,c,d){return this._dirty=!0,this.context.fillRect(a,b,c,d),this},fillStyle:function(a){return this.context.fillStyle=a,this},font:function(a){return this.context.font=a,this},globalAlpha:function(a){return this.context.globalAlpha=a,this},globalCompositeOperation:function(a){return this.context.globalCompositeOperation=a,this},lineCap:function(a){return this.context.lineCap=a,this},lineDashOffset:function(a){return this.context.lineDashOffset=a,this},lineJoin:function(a){return this.context.lineJoin=a,this},lineWidth:function(a){return this.context.lineWidth=a,this},miterLimit:function(a){return this.context.miterLimit=a,this},lineTo:function(a,b){return this._dirty=!0,this.context.lineTo(a,b),this},moveTo:function(a,b){return this.context.moveTo(a,b),this},quadraticCurveTo:function(a,b,c,d){return this._dirty=!0,this.context.quadraticCurveTo(a,b,c,d),this},rect:function(a,b,c,d){return this._dirty=!0,this.context.rect(a,b,c,d),this},restore:function(){return this._dirty=!0,this.context.restore(),this},rotate:function(a){return this._dirty=!0,this.context.rotate(a),this},setStrokeStyle:function(a,b,c,d,e){return"undefined"==typeof a&&(a=1),"undefined"==typeof b&&(b="butt"),"undefined"==typeof c&&(c="miter"),"undefined"==typeof d&&(d=10),e=!1,this.lineWidth(a),this.lineCap(b),this.lineJoin(c),this.miterLimit(d),this},save:function(){return this._dirty=!0,this.context.save(),this},scale:function(a,b){return this._dirty=!0,this.context.scale(a,b),this},scrollPathIntoView:function(){return this._dirty=!0,this.context.scrollPathIntoView(),this},stroke:function(){return this._dirty=!0,this.context.stroke(),this},strokeRect:function(a,b,c,d){return this._dirty=!0,this.context.strokeRect(a,b,c,d),this},strokeStyle:function(a){return this.context.strokeStyle=a,this},render:function(){this._dirty&&(this.game.renderType==d.WEBGL&&c.texturesToUpdate.push(this.baseTexture),this._dirty=!1)}},d.BitmapData.prototype.mt=d.BitmapData.prototype.moveTo,d.BitmapData.prototype.lt=d.BitmapData.prototype.lineTo,d.BitmapData.prototype.at=d.BitmapData.prototype.arcTo,d.BitmapData.prototype.bt=d.BitmapData.prototype.bezierCurveTo,d.BitmapData.prototype.qt=d.BitmapData.prototype.quadraticCurveTo,d.BitmapData.prototype.a=d.BitmapData.prototype.arc,d.BitmapData.prototype.r=d.BitmapData.prototype.rect,d.BitmapData.prototype.cp=d.BitmapData.prototype.closePath,d.BitmapData.prototype.c=d.BitmapData.prototype.clear,d.BitmapData.prototype.f=d.BitmapData.prototype.beginFill,d.BitmapData.prototype.lf=d.BitmapData.prototype.beginLinearGradientFill,d.BitmapData.prototype.rf=d.BitmapData.prototype.beginRadialGradientFill,d.BitmapData.prototype.ef=d.BitmapData.prototype.endFill,d.BitmapData.prototype.ss=d.BitmapData.prototype.setStrokeStyle,d.BitmapData.prototype.s=d.BitmapData.prototype.beginStroke,d.BitmapData.prototype.ls=d.BitmapData.prototype.beginLinearGradientStroke,d.BitmapData.prototype.rs=d.BitmapData.prototype.beginRadialGradientStroke,d.BitmapData.prototype.dr=d.BitmapData.prototype.rect,d.BitmapData.prototype.dc=d.BitmapData.prototype.circle,d.BitmapData.prototype.de=d.BitmapData.prototype.ellipse,d.Sprite=function(a,b,e,f,g){b=b||0,e=e||0,f=f||null,g=g||null,this.game=a,this.exists=!0,this.alive=!0,this.group=null,this.name="",this.type=d.SPRITE,this.renderOrderID=-1,this.lifespan=0,this.events=new d.Events(this),this.animations=new d.AnimationManager(this),this.input=new d.InputHandler(this),this.key=f,this.currentFrame=null,f instanceof d.RenderTexture?(c.Sprite.call(this,f),this.currentFrame=this.game.cache.getTextureFrame(f.name)):f instanceof d.BitmapData?(c.Sprite.call(this,f.texture,f.textureFrame),this.currentFrame=f.textureFrame):f instanceof c.Texture?(c.Sprite.call(this,f),this.currentFrame=g):(null===f||"undefined"==typeof f?(f="__default",this.key=f):"string"==typeof f&&this.game.cache.checkImageKey(f)===!1&&(f="__missing",this.key=f),c.Sprite.call(this,c.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 d.Rectangle(this.texture.frame.x,this.texture.frame.y,this.texture.frame.width,this.texture.frame.height),this.anchor=new d.Point,this.x=b,this.y=e,this.position.x=b,this.position.y=e,this.world=new d.Point(b,e),this.autoCull=!1,this.scale=new d.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:e,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 d.Point,this.center=new d.Point(b+Math.floor(this._cache.width/2),e+Math.floor(this._cache.height/2)),this.topLeft=new d.Point(b,e),this.topRight=new d.Point(b+this._cache.width,e),this.bottomRight=new d.Point(b+this._cache.width,e+this._cache.height),this.bottomLeft=new d.Point(b,e+this._cache.height),this.bounds=new d.Rectangle(b,e,this._cache.width,this._cache.height),this.body=new d.Physics.Arcade.Body(this),this.health=1,this.inWorld=d.Rectangle.intersects(this.bounds,this.game.world.bounds),this.inWorldThreshold=0,this.outOfBoundsKill=!1,this._outOfBoundsFired=!1,this.fixedToCamera=!1,this.cameraOffset=new d.Point,this.crop=new d.Rectangle(0,0,this._cache.width,this._cache.height),this.cropEnabled=!1,this.updateCache(),this.updateBounds()},d.Sprite.prototype=Object.create(c.Sprite.prototype),d.Sprite.prototype.constructor=d.Sprite,d.Sprite.prototype.preUpdate=function(){return!this.exists||this.group&&!this.group.exists?(this.renderOrderID=-1,!1):this.lifespan>0&&(this.lifespan-=this.game.time.elapsed,this.lifespan<=0)?(this.kill(),!1):(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(),!0)},d.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]},d.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)},d.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,c.Texture.frameUpdates.push(this.texture))},d.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=d.Math.min(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x),this._cache.right=d.Math.max(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x),this._cache.top=d.Math.min(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y),this._cache.bottom=d.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,this.inWorld===!1?(this.inWorld=d.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold),this.inWorld&&(this._outOfBoundsFired=!1)):(this.inWorld=d.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold),this.inWorld===!1&&(this.events.onOutOfBounds.dispatch(this),this._outOfBoundsFired=!0,this.outOfBoundsKill&&this.kill())),this._cache.cameraVisible=d.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)},d.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},d.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},d.Sprite.prototype.resetCrop=function(){this.crop=new d.Rectangle(0,0,this._cache.width,this._cache.height),this.texture.setFrame(this.crop),this.cropEnabled=!1},d.Sprite.prototype.postUpdate=function(){this.key instanceof d.BitmapData&&this.key._dirty&&this.key.render(),this.exists&&(this.body&&this.body.postUpdate(),this.fixedToCamera?(this._cache.x=this.game.camera.view.x+this.cameraOffset.x,this._cache.y=this.game.camera.view.y+this.cameraOffset.y):(this._cache.x=this.x,this._cache.y=this.y),this.world.setTo(this.game.camera.x+this.worldTransform[2],this.game.camera.y+this.worldTransform[5]),this.position.x=this._cache.x,this.position.y=this._cache.y)},d.Sprite.prototype.loadTexture=function(a,b){this.key=a,a instanceof d.RenderTexture?this.currentFrame=this.game.cache.getTextureFrame(a.name):a instanceof d.BitmapData?(this.setTexture(a.texture),this.currentFrame=a.textureFrame):a instanceof c.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(c.TextureCache[a])))},d.Sprite.prototype.centerOn=function(a,b){return this.x=a+(this.x-this.center.x),this.y=b+(this.y-this.center.y),this},d.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},d.Sprite.prototype.kill=function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.events&&this.events.onKilled.dispatch(this),this},d.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},d.Sprite.prototype.damage=function(a){return this.alive&&(this.health-=a,this.health<0&&this.kill()),this},d.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},d.Sprite.prototype.bringToTop=function(){return this.group?this.group.bringToTop(this):this.game.world.bringToTop(this),this},d.Sprite.prototype.play=function(a,b,c,d){return this.animations?this.animations.play(a,b,c,d):void 0},Object.defineProperty(d.Sprite.prototype,"angle",{get:function(){return d.Math.wrapAngle(d.Math.radToDeg(this.rotation))},set:function(a){this.rotation=d.Math.degToRad(d.Math.wrapAngle(a))}}),Object.defineProperty(d.Sprite.prototype,"frame",{get:function(){return this.animations.frame},set:function(a){this.animations.frame=a}}),Object.defineProperty(d.Sprite.prototype,"frameName",{get:function(){return this.animations.frameName},set:function(a){this.animations.frameName=a}}),Object.defineProperty(d.Sprite.prototype,"inCamera",{get:function(){return this._cache.cameraVisible}}),Object.defineProperty(d.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(d.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(d.Sprite.prototype,"inputEnabled",{get:function(){return this.input.enabled},set:function(a){a?this.input.enabled===!1&&this.input.start():this.input.enabled&&this.input.stop()}}),d.TileSprite=function(a,b,e,f,g,h,i){b=b||0,e=e||0,f=f||256,g=g||256,h=h||null,i=i||null,d.Sprite.call(this,a,b,e,h,i),this.texture=c.TextureCache[h],c.TilingSprite.call(this,this.texture,f,g),this.type=d.TILESPRITE,this.tileScale=new d.Point(1,1),this.tilePosition=new d.Point(0,0)},d.TileSprite.prototype=d.Utils.extend(!0,c.TilingSprite.prototype,d.Sprite.prototype),d.TileSprite.prototype.constructor=d.TileSprite,d.Text=function(a,b,e,f,g){b=b||0,e=e||0,f=f||"",g=g||"",this.game=a,this.exists=!0,this.alive=!0,this.group=null,this.name="",this.type=d.TEXT,this._text=f,this._style=g,c.Text.call(this,f,g),this.position.x=this.x=b,this.position.y=this.y=e,this.anchor=new d.Point,this.scale=new d.Point(1,1),this._cache={dirty:!1,a00:1,a01:0,a02:b,a10:0,a11:1,a12:e,id:1,x:-1,y:-1,scaleX:1,scaleY:1},this._cache.x=this.x,this._cache.y=this.y,this.renderable=!0},d.Text.prototype=Object.create(c.Text.prototype),d.Text.prototype.constructor=d.Text,d.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))},d.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(d.Text.prototype,"angle",{get:function(){return d.Math.radToDeg(this.rotation)},set:function(a){this.rotation=d.Math.degToRad(a)}}),Object.defineProperty(d.Text.prototype,"x",{get:function(){return this.position.x},set:function(a){this.position.x=a}}),Object.defineProperty(d.Text.prototype,"y",{get:function(){return this.position.y},set:function(a){this.position.y=a}}),Object.defineProperty(d.Text.prototype,"content",{get:function(){return this._text +},set:function(a){a!==this._text&&(this._text=a,this.setText(a))}}),Object.defineProperty(d.Text.prototype,"font",{get:function(){return this._style},set:function(a){a!==this._style&&(this._style=a,this.setStyle(a))}}),d.BitmapText=function(a,b,e,f,g){b=b||0,e=e||0,f=f||"",g=g||"",this.game=a,this.exists=!0,this.alive=!0,this.group=null,this.name="",this.type=d.BITMAPTEXT,c.BitmapText.call(this,f,g),this.position.x=b,this.position.y=e,this.anchor=new d.Point,this.scale=new d.Point(1,1),this._cache={dirty:!1,a00:1,a01:0,a02:b,a10:0,a11:1,a12:e,id:1,x:-1,y:-1,scaleX:1,scaleY:1},this._cache.x=this.x,this._cache.y=this.y,this.renderable=!0},d.BitmapText.prototype=Object.create(c.BitmapText.prototype),d.BitmapText.prototype.constructor=d.BitmapText,d.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)},d.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(d.BitmapText.prototype,"angle",{get:function(){return d.Math.radToDeg(this.rotation)},set:function(a){this.rotation=d.Math.degToRad(a)}}),Object.defineProperty(d.BitmapText.prototype,"x",{get:function(){return this.position.x},set:function(a){this.position.x=a}}),Object.defineProperty(d.BitmapText.prototype,"y",{get:function(){return this.position.y},set:function(a){this.position.y=a}}),d.Button=function(a,b,c,e,f,g,h,i,j){b=b||0,c=c||0,e=e||null,f=f||null,g=g||this,d.Sprite.call(this,a,b,c,e,i),this.type=d.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 d.Signal,this.onInputOut=new d.Signal,this.onInputDown=new d.Signal,this.onInputUp=new d.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)},d.Button.prototype=Object.create(d.Sprite.prototype),d.Button.prototype=d.Utils.extend(!0,d.Button.prototype,d.Sprite.prototype,c.Sprite.prototype),d.Button.prototype.constructor=d.Button,d.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,this.input.pointerOver()===!1&&(this.frameName=b)):(this._onOutFrameID=b,this._onUpFrameID=b,this.input.pointerOver()===!1&&(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)))},d.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)},d.Button.prototype.setOverSound=function(a,b){this.onOverSound=null,this.onOverSoundMarker="",a instanceof d.Sound&&(this.onOverSound=a),"string"==typeof b&&(this.onOverSoundMarker=b)},d.Button.prototype.setOutSound=function(a,b){this.onOutSound=null,this.onOutSoundMarker="",a instanceof d.Sound&&(this.onOutSound=a),"string"==typeof b&&(this.onOutSoundMarker=b)},d.Button.prototype.setUpSound=function(a,b){this.onUpSound=null,this.onUpSoundMarker="",a instanceof d.Sound&&(this.onUpSound=a),"string"==typeof b&&(this.onUpSoundMarker=b)},d.Button.prototype.setDownSound=function(a,b){this.onDownSound=null,this.onDownSoundMarker="",a instanceof d.Sound&&(this.onDownSound=a),"string"==typeof b&&(this.onDownSoundMarker=b)},d.Button.prototype.onInputOverHandler=function(a){this.freezeFrames===!1&&(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)},d.Button.prototype.onInputOutHandler=function(a){this.freezeFrames===!1&&(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)},d.Button.prototype.onInputDownHandler=function(a){this.freezeFrames===!1&&(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)},d.Button.prototype.onInputUpHandler=function(a){this.freezeFrames===!1&&(null!=this._onUpFrameName?this.frameName=this._onUpFrameName:null!=this._onUpFrameID&&(this.frame=this._onUpFrameID)),this.onUpSound&&this.onUpSound.play(this.onUpSoundMarker),this.forceOut&&this.freezeFrames===!1&&(null!=this._onOutFrameName?this.frameName=this._onOutFrameName:null!=this._onOutFrameID&&(this.frame=this._onOutFrameID)),this.onInputUp&&this.onInputUp.dispatch(this,a)},d.Graphics=function(a,b,e){this.game=a,c.Graphics.call(this),this.type=d.GRAPHICS,this.position.x=b,this.position.y=e},d.Graphics.prototype=Object.create(c.Graphics.prototype),d.Graphics.prototype.constructor=d.Graphics,d.Graphics.prototype.destroy=function(){this.clear(),this.group&&this.group.remove(this),this.game=null},d.Graphics.prototype.drawPolygon=function(a){this.moveTo(a.points[0].x,a.points[0].y);for(var b=1;bh;h++)f[h].updateTransform();var j=a.__renderGroup;j?a==j.root?j.render(this.projection,this.glFramebuffer):j.renderSpecific(a,this.projection,this.glFramebuffer):(this.renderGroup||(this.renderGroup=new c.WebGLRenderGroup(e)),this.renderGroup.setRenderable(a),this.renderGroup.render(this.projection,this.glFramebuffer)),a.worldTransform=g},d.RenderTexture.prototype.renderCanvas=function(a,b,d){var e=a.children;a.worldTransform=c.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();d&&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.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 d.Point;var c=a.getBoundingClientRect(),e=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-e,b},getAspectRatio:function(a){return a.width/a.height},setBackgroundColor:function(a,b){return b=b||"rgb(0,0,0)",a.style.backgroundColor=b,a},setTouchAction:function(a,b){return b=b||"none",a.style.msTouchAction=b,a.style["ms-touch-action"]=b,a.style["touch-action"]=b,a},setUserSelect:function(a,b){return b=b||"none",a.style["-webkit-touch-callout"]=b,a.style["-webkit-user-select"]=b,a.style["-khtml-user-select"]=b,a.style["-moz-user-select"]=b,a.style["-ms-user-select"]=b,a.style["user-select"]=b,a.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",a},addToDOM:function(a,b,c){var d;return"undefined"==typeof c&&(c=!0),b&&("string"==typeof b?d=document.getElementById(b):"object"==typeof b&&1===b.nodeType&&(d=b),c&&(d.style.overflow="hidden")),d||(d=document.body),d.appendChild(a),a},setTransform:function(a,b,c,d,e,f,g){return a.setTransform(d,f,g,e,b,c),a},setSmoothingEnabled:function(a,b){return a.imageSmoothingEnabled=b,a.mozImageSmoothingEnabled=b,a.oImageSmoothingEnabled=b,a.webkitImageSmoothingEnabled=b,a.msImageSmoothingEnabled=b,a},setImageRenderingCrisp:function(a){return a.style["image-rendering"]="crisp-edges",a.style["image-rendering"]="-moz-crisp-edges",a.style["image-rendering"]="-webkit-optimize-contrast",a.style.msInterpolationMode="nearest-neighbor",a},setImageRenderingBicubic:function(a){return a.style["image-rendering"]="auto",a.style.msInterpolationMode="bicubic",a}},d.StageScaleMode=function(a,b,c){this.game=a,this.width=b,this.height=c,this.minWidth=null,this.maxWidth=null,this.minHeight=null,this.maxHeight=null,this._startHeight=0,this.forceLandscape=!1,this.forcePortrait=!1,this.incorrectOrientation=!1,this.pageAlignHorizontally=!1,this.pageAlignVertically=!1,this._width=0,this._height=0,this.maxIterations=5,this.orientationSprite=null,this.enterLandscape=new d.Signal,this.enterPortrait=new d.Signal,this.enterIncorrectOrientation=new d.Signal,this.leaveIncorrectOrientation=new d.Signal,this.hasResized=new d.Signal,this.orientation=window.orientation?window.orientation:window.outerWidth>window.outerHeight?90:0,this.scaleFactor=new d.Point(1,1),this.scaleFactorInversed=new d.Point(1,1),this.margin=new d.Point(0,0),this.aspectRatio=0,this.event=null;var e=this;window.addEventListener("orientationchange",function(a){return e.checkOrientation(a)},!1),window.addEventListener("resize",function(a){return e.checkResize(a)},!1),document.addEventListener("webkitfullscreenchange",function(a){return e.fullScreenChange(a)},!1),document.addEventListener("mozfullscreenchange",function(a){return e.fullScreenChange(a)},!1),document.addEventListener("fullscreenchange",function(a){return e.fullScreenChange(a)},!1)},d.StageScaleMode.EXACT_FIT=0,d.StageScaleMode.NO_SCALE=1,d.StageScaleMode.SHOW_ALL=2,d.StageScaleMode.prototype={startFullScreen:function(a){if(!this.isFullScreen){"undefined"!=typeof a&&d.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(a){this.event=a,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,d){"undefined"==typeof b&&(b=!1),this.forceLandscape=a,this.forcePortrait=b,"undefined"!=typeof d&&((null==d||this.game.cache.checkImageKey(d)===!1)&&(d="__default"),this.orientationSprite=new c.Sprite(c.TextureCache[d]),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.leaveIncorrectOrientation.dispatch(),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!==d.StageScaleMode.NO_SCALE&&this.refresh(),this.checkOrientationState()},refresh:function(){if(this.game.device.iPad===!1&&this.game.device.webApp===!1&&this.game.device.desktop===!1&&(this.game.device.android&&this.game.device.chrome===!1?window.scrollTo(0,1):window.scrollTo(0,0)),null==this._check&&this.maxIterations>0){this._iterations=this.maxIterations;var a=this;this._check=window.setInterval(function(){return a.setScreenSize()},10),this.setScreenSize()}},setScreenSize:function(a){"undefined"==typeof a&&(a=!1),this.game.device.iPad===!1&&this.game.device.webApp===!1&&this.game.device.desktop===!1&&(this.game.device.android&&this.game.device.chrome===!1?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",this.incorrectOrientation===!0?this.setMaximum():this.game.stage.scaleMode==d.StageScaleMode.EXACT_FIT?this.setExactFit():this.game.stage.scaleMode==d.StageScaleMode.SHOW_ALL&&this.setShowAll(),this.setSize(),clearInterval(this._check),this._check=null)},setSize:function(){this.incorrectOrientation===!1&&(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(d.StageScaleMode.prototype,"isFullScreen",{get:function(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement}}),Object.defineProperty(d.StageScaleMode.prototype,"isPortrait",{get:function(){return 0===this.orientation||180==this.orientation}}),Object.defineProperty(d.StageScaleMode.prototype,"isLandscape",{get:function(){return 90===this.orientation||-90===this.orientation}}),d.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.typedArray=!1,this.arora=!1,this.chrome=!1,this.epiphany=!1,this.firefox=!1,this.ie=!1,this.ieVersion=0,this.mobileSafari=!1,this.midori=!1,this.opera=!1,this.safari=!1,this.webApp=!1,this.audioData=!1,this.webAudio=!1,this.ogg=!1,this.opus=!1,this.mp3=!1,this.wav=!1,this.m4a=!1,this.webm=!1,this.iPhone=!1,this.iPhone4=!1,this.iPad=!1,this.pixelRatio=0,this.littleEndian=!1,this._checkAudio(),this._checkBrowser(),this._checkCSS3D(),this._checkDevice(),this._checkFeatures(),this._checkOS()},d.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,10)):/Midori/.test(a)?this.midori=!0:/Opera/.test(a)?this.opera=!0:/Safari/.test(a)&&(this.safari=!0),navigator.standalone&&(this.webApp=!0)},_checkAudio:function(){this.audioData=!!window.Audio,this.webAudio=!(!window.webkitAudioContext&&!window.AudioContext);var a=document.createElement("audio"),b=!1;try{(b=!!a.canPlayType)&&(a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.ogg=!0),a.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")&&(this.opus=!0),a.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(this.mp3=!0),a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(this.wav=!0),(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;").replace(/^no$/,""))&&(this.m4a=!0),a.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")&&(this.webm=!0))}catch(c){}},_checkDevice:function(){this.pixelRatio=window.devicePixelRatio||1,this.iPhone=-1!=navigator.userAgent.toLowerCase().indexOf("iphone"),this.iPhone4=2==this.pixelRatio&&this.iPhone,this.iPad=-1!=navigator.userAgent.toLowerCase().indexOf("ipad"),"undefined"!=typeof Int8Array?(this.littleEndian=new Int8Array(new Int16Array([1]).buffer)[0]>0,this.typedArray=!0):(this.littleEndian=!1,this.typedArray=!1)},_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}},d.RequestAnimationFrame=function(a){this.game=a,this.isRunning=!1;for(var b=["ms","moz","webkit","o"],c=0;c>>0,b-=d,b*=d,d=b>>>0,b-=d,d+=4294967296*b;return 2.3283064365386963e-10*(d>>>0)},integer:function(){return 4294967296*this.rnd.apply(this)},frac:function(){return this.rnd.apply(this)+1.1102230246251565e-16*(0|2097152*this.rnd.apply(this))},real:function(){return this.integer()+this.frac()},integerInRange:function(a,b){return Math.floor(this.realInRange(a,b))},realInRange:function(a,b){return this.frac()*(b-a)+a},normal:function(){return 1-2*this.frac()},uuid:function(){var a="",b="";for(b=a="";a++<36;b+=~a%5|4&3*a?(15^a?8^this.frac()*(20^a?16:4):4).toString(16):"-");return b},pick:function(a){return a[this.integerInRange(0,a.length)]},weightedPick:function(a){return a[~~(Math.pow(this.frac(),2)*a.length)]},timestamp:function(a,b){return this.realInRange(a||9466848e5,b||1577862e6)},angle:function(){return this.integerInRange(-180,180)}},d.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?Math.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]c?d=c:b>a&&(d=b),d},linearInterpolation:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d);return 0>b?this.linear(a[0],a[1],d):b>1?this.linear(a[c],a[c-1],c-d):this.linear(a[e],a[e+1>c?c:e+1],d-e)},bezierInterpolation:function(a,b){for(var c=0,d=a.length-1,e=0;d>=e;e++)c+=Math.pow(1-b,d-e)*Math.pow(b,e)*a[e]*this.bernstein(d,e);return c},catmullRomInterpolation:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d);return a[0]===a[c]?(0>b&&(e=Math.floor(d=c*(1+b))),this.catmullRom(a[(e-1+c)%c],a[e],a[(e+1)%c],a[(e+2)%c],d-e)):0>b?a[0]-(this.catmullRom(a[0],a[0],a[1],a[1],-d)-a[0]):b>1?a[c]-(this.catmullRom(a[c],a[c],a[c-1],a[c-1],d-c)-a[c]):this.catmullRom(a[e?e-1:0],a[e],a[e+1>c?c:e+1],a[e+2>c?c:e+2],d-e)},linear:function(a,b,c){return(b-a)*c+a},bernstein:function(a,b){return this.factorial(a)/this.factorial(b)/this.factorial(a-b)},catmullRom:function(a,b,c,d,e){var f=.5*(c-a),g=.5*(d-b),h=e*e,i=e*h;return(2*b-2*c+f+g)*i+(-3*b+3*c-2*f-g)*h+f*e+b},difference:function(a,b){return Math.abs(a-b)},getRandom:function(a,b,c){if("undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=0),null!=a){var d=c;if((0===d||d>a.length-b)&&(d=a.length-b),d>0)return a[b+Math.floor(Math.random()*d)]}return null},floor:function(a){var b=0|a;return a>0?b:b!=a?b-1:b},ceil:function(a){var b=0|a;return a>0?b!=a?b+1:b:b},sinCosGenerator:function(a,b,c,d){"undefined"==typeof b&&(b=1),"undefined"==typeof c&&(c=1),"undefined"==typeof d&&(d=1);for(var e=b,f=c,g=d*Math.PI/a,h=[],i=[],j=0;a>j;j++)f-=e*g,e+=f*g,h[j]=f,i[j]=e;return{sin:i,cos:h,length:a}},shift:function(a){var b=a.shift();return a.push(b),b +},shuffleArray:function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},distance:function(a,b,c,d){var e=a-c,f=b-d;return Math.sqrt(e*e+f*f)},distanceRounded:function(a,b,c,e){return Math.round(d.Math.distance(a,b,c,e))},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}}()},d.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=[]},d.QuadTree.prototype={split:function(){this.level++,this.nodes[0]=new d.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 d.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 d.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 d.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])}},d.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},d.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?d.Math.distanceRound(this.x,this.y,a.x,a.y):d.Math.distance(this.x,this.y,a.x,a.y)},clone:function(a){return"undefined"==typeof a&&(a=new d.Circle),a.setTo(this.x,this.y,this.diameter)},contains:function(a,b){return d.Circle.contains(this,a,b)},circumferencePoint:function(a,b,c){return d.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(d.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(a){a>0&&(this._diameter=a,this._radius=.5*a)}}),Object.defineProperty(d.Circle.prototype,"radius",{get:function(){return this._radius},set:function(a){a>0&&(this._radius=a,this._diameter=2*a)}}),Object.defineProperty(d.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(d.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(d.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(a){a0?Math.PI*this._radius*this._radius:0}}),Object.defineProperty(d.Circle.prototype,"empty",{get:function(){return 0===this._diameter},set:function(a){a===!0&&this.setTo(0,0,0)}}),d.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},d.Circle.equals=function(a,b){return a.x==b.x&&a.y==b.y&&a.diameter==b.diameter},d.Circle.intersects=function(a,b){return d.Math.distance(a.x,a.y,b.x,b.y)<=a.radius+b.radius},d.Circle.circumferencePoint=function(a,b,c,e){return"undefined"==typeof c&&(c=!1),"undefined"==typeof e&&(e=new d.Point),c===!0&&(b=d.Math.radToDeg(b)),e.x=a.x+a.radius*Math.cos(b),e.y=a.y+a.radius*Math.sin(b),e},d.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},d.Point=function(a,b){a=a||0,b=b||0,this.x=a,this.y=b},d.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=d.Math.clamp(this.x,a,b),this},clampY:function(a,b){return this.y=d.Math.clamp(this.y,a,b),this},clamp:function(a,b){return this.x=d.Math.clamp(this.x,a,b),this.y=d.Math.clamp(this.y,a,b),this},clone:function(a){return"undefined"==typeof a&&(a=new d.Point),a.setTo(this.x,this.y)},copyTo:function(a){return a.x=this.x,a.y=this.y,a},distance:function(a,b){return d.Point.distance(this,a,b)},equals:function(a){return a.x==this.x&&a.y==this.y},rotate:function(a,b,c,e,f){return d.Point.rotate(this,a,b,c,e,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+")}]"}},d.Point.add=function(a,b,c){return"undefined"==typeof c&&(c=new d.Point),c.x=a.x+b.x,c.y=a.y+b.y,c},d.Point.subtract=function(a,b,c){return"undefined"==typeof c&&(c=new d.Point),c.x=a.x-b.x,c.y=a.y-b.y,c},d.Point.multiply=function(a,b,c){return"undefined"==typeof c&&(c=new d.Point),c.x=a.x*b.x,c.y=a.y*b.y,c},d.Point.divide=function(a,b,c){return"undefined"==typeof c&&(c=new d.Point),c.x=a.x/b.x,c.y=a.y/b.y,c},d.Point.equals=function(a,b){return a.x==b.x&&a.y==b.y},d.Point.distance=function(a,b,c){return"undefined"==typeof c&&(c=!1),c?d.Math.distanceRound(a.x,a.y,b.x,b.y):d.Math.distance(a.x,a.y,b.x,b.y)},d.Point.rotate=function(a,b,c,e,f,g){return f=f||!1,g=g||null,f&&(e=d.Math.degToRad(e)),null===g&&(g=Math.sqrt((b-a.x)*(b-a.x)+(c-a.y)*(c-a.y))),a.setTo(b+g*Math.cos(e),c+g*Math.sin(e))},d.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},d.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 d.Rectangle.inflate(this,a,b)},size:function(a){return d.Rectangle.size(this,a)},clone:function(a){return d.Rectangle.clone(this,a)},contains:function(a,b){return d.Rectangle.contains(this,a,b)},containsRect:function(a){return d.Rectangle.containsRect(this,a)},equals:function(a){return d.Rectangle.equals(this,a)},intersection:function(a,b){return d.Rectangle.intersection(this,a,b)},intersects:function(a,b){return d.Rectangle.intersects(this,a,b)},intersectsRaw:function(a,b,c,e,f){return d.Rectangle.intersectsRaw(this,a,b,c,e,f)},union:function(a,b){return d.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(d.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)}}),Object.defineProperty(d.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)}}),Object.defineProperty(d.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){this.height=a<=this.y?0:this.y-a}}),Object.defineProperty(d.Rectangle.prototype,"bottomRight",{get:function(){return new d.Point(this.right,this.bottom)},set:function(a){this.right=a.x,this.bottom=a.y}}),Object.defineProperty(d.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(d.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(a){this.width=a<=this.x?0:this.x+a}}),Object.defineProperty(d.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}}),Object.defineProperty(d.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}}),Object.defineProperty(d.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(a){this.x=a-this.halfWidth}}),Object.defineProperty(d.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(a){this.y=a-this.halfHeight}}),Object.defineProperty(d.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(d.Rectangle.prototype,"topLeft",{get:function(){return new d.Point(this.x,this.y)},set:function(a){this.x=a.x,this.y=a.y}}),Object.defineProperty(d.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(a){a===!0&&this.setTo(0,0,0,0)}}),d.Rectangle.inflate=function(a,b,c){return a.x-=b,a.width+=2*b,a.y-=c,a.height+=2*c,a},d.Rectangle.inflatePoint=function(a,b){return d.Rectangle.inflate(a,b.x,b.y)},d.Rectangle.size=function(a,b){return"undefined"==typeof b&&(b=new d.Point),b.setTo(a.width,a.height)},d.Rectangle.clone=function(a,b){return"undefined"==typeof b&&(b=new d.Rectangle),b.setTo(a.x,a.y,a.width,a.height)},d.Rectangle.contains=function(a,b,c){return b>=a.x&&b<=a.right&&c>=a.y&&c<=a.bottom},d.Rectangle.containsRaw=function(a,b,c,d,e,f){return e>=a&&a+c>=e&&f>=b&&b+d>=f},d.Rectangle.containsPoint=function(a,b){return d.Rectangle.contains(a,b.x,b.y)},d.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},d.Rectangle.equals=function(a,b){return a.x==b.x&&a.y==b.y&&a.width==b.width&&a.height==b.height},d.Rectangle.intersection=function(a,b,c){return c=c||new d.Rectangle,d.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},d.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," "))}},d.TweenManager=function(a){this.game=a,this._tweens=[],this._add=[],this.game.onPause.add(this.pauseAll,this),this.game.onResume.add(this.resumeAll,this)},d.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 d.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()}},d.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=d.Easing.Linear.None,this._interpolationFunction=d.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 d.Signal,this.onComplete=new d.Signal,this.isRunning=!1},d.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.isRunning=!1,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}},d.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-d.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*d.Easing.Bounce.In(2*a):.5*d.Easing.Bounce.Out(2*a-1)+.5}}},d.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},d.Time.prototype={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},totalElapsedSeconds:function(){return.001*(this.now-this._started)},elapsedSince:function(a){return this.now-a},elapsedSecondsSince:function(a){return.001*(this.now-a)},reset:function(){this._started=this.now}},d.Timer=function(a){this.game=a,this._started=0,this._timeLastSecond=0,this.running=!1,this.events=[],this.onEvent=new d.Signal},d.Timer.prototype={add:function(a){this.events.push({delay:a,dispatched:!1,args:Array.prototype.splice.call(arguments,1)})},start:function(){this._started=this.game.time.now,this.running=!0},stop:function(){this.running=!1,this.events.length=0},update:function(){if(this.running)for(var a=this.seconds(),b=0,c=this.events.length;c>b;b++)this.events[b].dispatched===!1&&a>=this.events[b].delay&&(this.events[b].dispatched=!0,this.onEvent.dispatch.apply(this,this.events[b].args))},seconds:function(){return.001*(this.game.time.now-this._started)}},d.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=[]},d.AnimationManager.prototype={loadFrameData:function(a){this._frameData=a,this.frame=0,this.isLoaded=!0},add:function(a,b,e,f,g){return null==this._frameData?(console.warn("No FrameData available for Phaser.Animation "+a),void 0):(e=e||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 d.Signal,this.sprite.events.onAnimationComplete=new d.Signal,this.sprite.events.onAnimationLoop=new d.Signal),this._outputFrames.length=0,this._frameData.getFrameIndexes(b,g,this._outputFrames),this._anims[a]=new d.Animation(this.game,this.sprite,a,this._frameData,this._outputFrames,e,f),this.currentAnim=this._anims[a],this.currentFrame=this.currentAnim.currentFrame,this.sprite.setTexture(c.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(this._frameData.checkFrameName(a[c])===!1)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(this.currentAnim.isPlaying===!1)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&&this.sprite.visible===!1?!1:this.currentAnim&&this.currentAnim.update()===!0?(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(c.TextureCache[this.currentFrame.uuid])},destroy:function(){this._anims={},this._frameData=null,this._frameIndex=0,this.currentAnim=null,this.currentFrame=null}},Object.defineProperty(d.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}}),Object.defineProperty(d.AnimationManager.prototype,"frameTotal",{get:function(){return this._frameData?this._frameData.total:-1}}),Object.defineProperty(d.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(a){this.currentAnim.paused=a}}),Object.defineProperty(d.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(c.TextureCache[this.currentFrame.uuid]))}}),Object.defineProperty(d.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(c.TextureCache[this.currentFrame.uuid])):console.warn("Cannot set frameName: "+a)}}),d.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])},d.Animation.prototype={play:function(a,b,d){return"number"==typeof a&&(this.delay=1e3/a),"boolean"==typeof b&&(this.looped=b),"undefined"!=typeof d&&(this.killOnComplete=d),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(c.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:this.isPlaying===!0&&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(c.TextureCache[this.currentFrame.uuid]),this._parent.events.onAnimationLoop.dispatch(this._parent,this)):this.onComplete():(this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&this._parent.setTexture(c.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(d.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(d.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}}),Object.defineProperty(d.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(c.TextureCache[this.currentFrame.uuid]))}}),d.Animation.generateFrameNames=function(a,b,c,e,f){"undefined"==typeof e&&(e="");var g=[],h="";if(c>b)for(var i=b;c>=i;i++)h="number"==typeof f?d.Utils.pad(i.toString(),f,"0",1):i.toString(),h=a+h+e,g.push(h);else for(var i=b;i>=c;i--)h="number"==typeof f?d.Utils.pad(i.toString(),f,"0",1):i.toString(),h=a+h+e,g.push(h);return g},d.Frame=function(a,b,c,e,f,g,h){this.index=a,this.x=b,this.y=c,this.width=e,this.height=f,this.name=g,this.uuid=h,this.centerX=Math.floor(e/2),this.centerY=Math.floor(f/2),this.distance=d.Math.distance(0,0,e,f),this.rotated=!1,this.rotationDirection="cw",this.trimmed=!1,this.sourceSizeW=e,this.sourceSizeH=f,this.spriteSourceSizeX=0,this.spriteSourceSizeY=0,this.spriteSourceSizeW=0,this.spriteSourceSizeH=0},d.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)}},d.FrameData=function(){this._frames=[],this._frameNames=[]},d.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(d.FrameData.prototype,"total",{get:function(){return this._frames.length}}),d.AnimationParser={spriteSheet:function(a,b,e,f,g){var h=a.cache.getImage(b);if(null==h)return null;var i=h.width,j=h.height;0>=e&&(e=Math.floor(-i/Math.min(-1,e))),0>=f&&(f=Math.floor(-j/Math.min(-1,f)));var k=Math.round(i/e),l=Math.round(j/f),m=k*l;if(-1!==g&&(m=g),0===i||0===j||e>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 d.FrameData,o=0,p=0,q=0;m>q;q++){var r=a.rnd.uuid();n.addFrame(new d.Frame(q,o,p,e,f,"",r)),c.TextureCache[r]=new c.Texture(c.BaseTextureCache[b],{x:o,y:p,width:e,height:f}),o+=e,o===i&&(o=0,p+=f)}return n},JSONData:function(a,b,e){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 d.FrameData,h=b.frames,i=0;i tag"),void 0;for(var f,g,h,i,j,k,l,m,n,o,p,q,r=new d.FrameData,s=b.getElementsByTagName("SubTexture"),t=0;t0?(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",d.GAMES[this.game.id].load.fileComplete(a.key),!1),a.data.load())):this.fileError(a.key);break;case"tilemap":if(this._xhr.open("GET",this.baseURL+a.url,!0),this._xhr.responseType="text",a.format==d.Tilemap.TILED_JSON)this._xhr.onload=function(){return b.jsonLoadComplete(a.key)};else{if(a.format!=d.Tilemap.CSV)throw new Error("Phaser.Loader. Invalid Tilemap format: "+a.format);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){var b;"string"==typeof a&&(a=[a]);for(var 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())}},d.LoaderParser={bitmapFont:function(a,b,d){if(!b.getElementsByTagName("font"))return console.warn("Phaser.LoaderParser.bitmapFont: Invalid XML given, missing tag"),void 0;var e=c.TextureCache[d],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,"undefined"==typeof c&&(c=this._volume),"undefined"==typeof d&&(d=!1),"undefined"==typeof e&&(e=!0),this.isPlaying!==!0||e!==!1||this.override!==!1){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)&&this.game.cache.getSound(this.key).isDecoding===!1&&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(d.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}}),Object.defineProperty(d.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}}),Object.defineProperty(d.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(d.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)}}),d.SoundManager=function(a){this.game=a,this.onSoundDecode=new d.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},d.SoundManager.prototype={boot:function(){if(this.game.device.iOS&&this.game.device.webAudio===!1&&(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(window.PhaserGlobal.disableAudio===!0)return this.usingWebAudio=!1,this.noAudio=!0,void 0;if(window.PhaserGlobal.disableWebAudio===!0)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(this.touchLocked!==!1)if(this.game.device.webAudio===!1||window.PhaserGlobal&&window.PhaserGlobal.disableWebAudio===!0)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 d.Color.getColor(255,255,255);if(a>b)return d.Color.getColor(255,255,255);var e=a+Math.round(Math.random()*(b-a)),f=a+Math.round(Math.random()*(b-a)),g=a+Math.round(Math.random()*(b-a));return d.Color.getColor32(c,e,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}},d.Physics={},d.Physics.Arcade=function(a){this.game=a,this.gravity=new d.Point,this.bounds=new d.Rectangle(0,0,a.world.width,a.world.height),this.maxObjects=10,this.maxLevels=4,this.OVERLAP_BIAS=4,this.quadTree=new d.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 d.Rectangle,this._bounds2=new d.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},d.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 d.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?d.Rectangle.intersects(a.body,b.body):!1},collide:function(a,b,c,e,f){return c=c||null,e=e||null,f=f||c,this._result=!1,this._total=0,a&&b&&a.exists&&b.exists&&(a.type==d.SPRITE?b.type==d.SPRITE?this.collideSpriteVsSprite(a,b,c,e,f):b.type==d.GROUP||b.type==d.EMITTER?this.collideSpriteVsGroup(a,b,c,e,f):b.type==d.TILEMAPLAYER&&this.collideSpriteVsTilemapLayer(a,b,c,e,f):a.type==d.GROUP?b.type==d.SPRITE?this.collideSpriteVsGroup(b,a,c,e,f):b.type==d.GROUP||b.type==d.EMITTER?this.collideGroupVsGroup(a,b,c,e,f):b.type==d.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(a,b,c,e,f):a.type==d.TILEMAPLAYER?b.type==d.SPRITE?this.collideSpriteVsTilemapLayer(b,a,c,e,f):(b.type==d.GROUP||b.type==d.EMITTER)&&this.collideGroupVsTilemapLayer(b,a,c,e,f):a.type==d.EMITTER&&(b.type==d.SPRITE?this.collideSpriteVsGroup(b,a,c,e,f):b.type==d.GROUP||b.type==d.EMITTER?this.collideGroupVsGroup(a,b,c,e,f):b.type==d.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(a,b,c,e,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,d.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||a.allowCollision.right===!1||b.allowCollision.left===!1?this._overlap=0:(a.touching.right=!0,b.touching.left=!0)):a.deltaX()this._maxOverlap||a.allowCollision.left===!1||b.allowCollision.right===!1?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,d.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||a.allowCollision.down===!1||b.allowCollision.up===!1?this._overlap=0:(a.touching.down=!0,b.touching.up=!0)):a.deltaY()this._maxOverlap||a.allowCollision.up===!1||b.allowCollision.down===!1?this._overlap=0:(a.touching.up=!0,b.touching.down=!0)),0!==this._overlap)?(a.overlapY=this._overlap,b.overlapY=this._overlap,a.customSeparateY||b.customSeparateY?!0:(this._velocity1=a.velocity.y,this._velocity2=b.velocity.y,a.immovable||b.immovable?a.immovable?b.immovable||(b.y+=this._overlap,b.velocity.y=this._velocity1-this._velocity2*b.bounce.y,a.sprite.active&&a.moves&&a.deltaY()b.deltaY()&&(a.x+=b.x-b.lastX)):(this._overlap*=.5,a.y=a.y-this._overlap,b.y+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(this._velocity2>0?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(this._velocity1>0?1:-1),this._average=.5*(this._newVelocity1+this._newVelocity2),this._newVelocity1-=this._average,this._newVelocity2-=this._average,a.velocity.y=this._average+this._newVelocity1*a.bounce.y,b.velocity.y=this._average+this._newVelocity2*b.bounce.y),!0)):!1)},separateTile:function(a,b){return this._result=this.separateTileX(a,b,!0)||this.separateTileY(a,b,!0),this._result},separateTileX:function(a,b,c){return a.immovable||0===a.deltaX()||d.Rectangle.intersects(a.hullX,b)===!1?!1:(this._overlap=0,a.deltaX()<0?(this._overlap=b.right-a.hullX.x,a.allowCollision.left===!1||b.tile.collideRight===!1?this._overlap=0:a.touching.left=!0):(this._overlap=a.hullX.right-b.x,a.allowCollision.right===!1||b.tile.collideLeft===!1?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()||d.Rectangle.intersects(a.hullY,b)===!1?!1:(this._overlap=0,a.deltaY()<0?(this._overlap=b.bottom-a.hullY.y,a.allowCollision.up===!1||b.tile.collideDown===!1?this._overlap=0:a.touching.up=!0):(this._overlap=a.hullY.bottom-b.y,a.allowCollision.down===!1||b.tile.collideUp===!1?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 d.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 d.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 d.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)}},d.Physics.Arcade.Body=function(a){this.sprite=a,this.game=a.game,this.offset=new d.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 d.Point(this.x+this.halfWidth,this.y+this.halfHeight),this._sx=a.scale.x,this._sy=a.scale.y,this.velocity=new d.Point,this.acceleration=new d.Point,this.drag=new d.Point,this.gravity=new d.Point,this.bounce=new d.Point,this.maxVelocity=new d.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=d.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 d.Rectangle,this.hullY=new d.Rectangle,this.embedded=!1,this.collideWorldBounds=!1},d.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()),this.skipQuadTree===!1&&this.allowCollision.none===!1&&this.sprite.visible&&this.sprite.alive&&(this.quadTreeIDs=[],this.quadTreeIndex=-1,this.game.physics.quadTree.insert(this))},postUpdate:function(){this.deltaX()<0?this.facing=d.LEFT:this.deltaX()>0&&(this.facing=d.RIGHT),this.deltaY()<0?this.facing=d.UP:this.deltaY()>0&&(this.facing=d.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(d.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(d.Physics.Arcade.Body.prototype,"right",{get:function(){return this.x+this.width},set:function(a){this.width=a<=this.x?0:this.x+a}}),d.Particles=function(a){this.game=a,this.emitters={},this.ID=0},d.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()}},d.Particles.Arcade={},d.Particles.Arcade.Emitter=function(a,b,c,e){this.maxParticles=e||50,d.Group.call(this,a),this.name="emitter"+this.game.particles.ID++,this.type=d.EMITTER,this.x=0,this.y=0,this.width=1,this.height=1,this.minParticleSpeed=new d.Point(-100,-100),this.maxParticleSpeed=new d.Point(100,100),this.minParticleScale=1,this.maxParticleScale=1,this.minRotation=-360,this.maxRotation=360,this.gravity=2,this.particleClass=null,this.particleDrag=new d.Point,this.angularDrag=0,this.frequency=100,this.lifespan=2e3,this.bounce=new d.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 +},d.Particles.Arcade.Emitter.prototype=Object.create(d.Group.prototype),d.Particles.Arcade.Emitter.prototype.constructor=d.Particles.Arcade.Emitter,d.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)},d.Particles.Arcade.Emitter.prototype.makeParticles=function(a,b,c,e,f){"undefined"==typeof b&&(b=0),c=c||this.maxParticles,e=e||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 d.Sprite(this.game,0,0,i,j)),e>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},d.Particles.Arcade.Emitter.prototype.kill=function(){this.on=!1,this.alive=!1,this.exists=!1},d.Particles.Arcade.Emitter.prototype.revive=function(){this.alive=!0,this.exists=!0},d.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},d.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}},d.Particles.Arcade.Emitter.prototype.setSize=function(a,b){this.width=a,this.height=b},d.Particles.Arcade.Emitter.prototype.setXSpeed=function(a,b){a=a||0,b=b||0,this.minParticleSpeed.x=a,this.maxParticleSpeed.x=b},d.Particles.Arcade.Emitter.prototype.setYSpeed=function(a,b){a=a||0,b=b||0,this.minParticleSpeed.y=a,this.maxParticleSpeed.y=b},d.Particles.Arcade.Emitter.prototype.setRotation=function(a,b){a=a||0,b=b||0,this.minRotation=a,this.maxRotation=b},d.Particles.Arcade.Emitter.prototype.at=function(a){this.emitX=a.center.x,this.emitY=a.center.y},Object.defineProperty(d.Particles.Arcade.Emitter.prototype,"alpha",{get:function(){return this._container.alpha},set:function(a){this._container.alpha=a}}),Object.defineProperty(d.Particles.Arcade.Emitter.prototype,"visible",{get:function(){return this._container.visible},set:function(a){this._container.visible=a}}),Object.defineProperty(d.Particles.Arcade.Emitter.prototype,"x",{get:function(){return this.emitX},set:function(a){this.emitX=a}}),Object.defineProperty(d.Particles.Arcade.Emitter.prototype,"y",{get:function(){return this.emitY},set:function(a){this.emitY=a}}),Object.defineProperty(d.Particles.Arcade.Emitter.prototype,"left",{get:function(){return Math.floor(this.x-this.width/2)}}),Object.defineProperty(d.Particles.Arcade.Emitter.prototype,"right",{get:function(){return Math.floor(this.x+this.width/2)}}),Object.defineProperty(d.Particles.Arcade.Emitter.prototype,"top",{get:function(){return Math.floor(this.y-this.height/2)}}),Object.defineProperty(d.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return Math.floor(this.y+this.height/2)}}),d.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},d.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(d.Tile.prototype,"bottom",{get:function(){return this.y+this.height}}),Object.defineProperty(d.Tile.prototype,"right",{get:function(){return this.x+this.width}}),d.Tilemap=function(a,b){this.game=a,this.layers=null,"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},d.Tilemap.CSV=0,d.Tilemap.TILED_JSON=1,d.Tilemap.prototype={create:function(a,b,c){for(var e=[],f=0;c>f;f++){e[f]=[];for(var g=0;b>g;g++)e[f][g]=0}this.currentLayer=this.layers.push({name:a,width:b,height:c,alpha:1,visible:!0,tileMargin:0,tileSpacing:0,format:d.Tilemap.CSV,data:e,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}},d.TilemapLayer=function(a,b,e,f,g,h,i,j){this.game=a,this.canvas=d.Canvas.create(f,g),this.context=this.canvas.getContext("2d"),this.baseTexture=new c.BaseTexture(this.canvas),this.texture=new c.Texture(this.baseTexture),this.textureFrame=new d.Frame(0,0,0,f,g,"tilemaplayer",a.rnd.uuid()),d.Sprite.call(this,this.game,b,e,this.texture,this.textureFrame),this.type=d.TILEMAPLAYER,this.fixedToCamera=!0,this.tileset=null,this.tileWidth=0,this.tileHeight=0,this.tileMargin=0,this.tileSpacing=0,this.widthInPixels=0,this.heightInPixels=0,this.renderWidth=f,this.renderHeight=g,this._ga=1,this._dx=0,this._dy=0,this._dw=0,this._dh=0,this._tx=0,this._ty=0,this._results=[],this._tw=0,this._th=0,this._tl=0,this._maxX=0,this._maxY=0,this._startX=0,this._startY=0,this.scrollFactorX=1,this.scrollFactorY=1,this.tilemap=null,this.layer=null,this.index=0,this._x=0,this._y=0,this._prevX=0,this._prevY=0,this.dirty=!0,(h instanceof d.Tileset||"string"==typeof h)&&this.updateTileset(h),i instanceof d.Tilemap&&this.updateMapData(i,j)},d.TilemapLayer.prototype=Object.create(d.Sprite.prototype),d.TilemapLayer.prototype=d.Utils.extend(!0,d.TilemapLayer.prototype,d.Sprite.prototype,c.Sprite.prototype),d.TilemapLayer.prototype.constructor=d.TilemapLayer,d.TilemapLayer.prototype.update=function(){this.scrollX=this.game.camera.x*this.scrollFactorX,this.scrollY=this.game.camera.y*this.scrollFactorY,this.render()},d.TilemapLayer.prototype.resizeWorld=function(){this.game.world.setBounds(0,0,this.widthInPixels,this.heightInPixels)},d.TilemapLayer.prototype.updateTileset=function(a){if(a instanceof d.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()},d.TilemapLayer.prototype.updateMapData=function(a,b){"undefined"==typeof b&&(b=0),a instanceof d.Tilemap&&(this.tilemap=a,this.layer=this.tilemap.layers[b],this.index=b,this.updateMax(),this.tilemap.dirty=!0)},d.TilemapLayer.prototype._fixX=function(a){if(1===this.scrollFactorX)return a;var b=a-this._x/this.scrollFactorX;return this._x+b},d.TilemapLayer.prototype._unfixX=function(a){if(1===this.scrollFactorX)return a;var b=a-this._x;return this._x/this.scrollFactorX+b},d.TilemapLayer.prototype._fixY=function(a){if(1===this.scrollFactorY)return a;var b=a-this._y/this.scrollFactorY;return this._y+b},d.TilemapLayer.prototype._unfixY=function(a){if(1===this.scrollFactorY)return a;var b=a-this._y;return this._y/this.scrollFactorY+b},d.TilemapLayer.prototype.getTileX=function(a){var b=this.tileWidth*this.scale.x;return this.game.math.snapToFloor(this._fixX(a),b)/b},d.TilemapLayer.prototype.getTileY=function(a){var b=this.tileHeight*this.scale.y;return this.game.math.snapToFloor(this._fixY(a),b)/b},d.TilemapLayer.prototype.getTileXY=function(a,b,c){return c.x=this.getTileX(a),c.y=this.getTileY(b),c},d.TilemapLayer.prototype.getTiles=function(a,b,c,d,e){if(null!==this.tilemap){"undefined"==typeof e&&(e=!1),0>a&&(a=0),0>b&&(b=0),a=this._fixX(a),b=this._fixY(b),c>this.widthInPixels&&(c=this.widthInPixels),d>this.heightInPixels&&(d=this.heightInPixels);var f=this.tileWidth*this.scale.x,g=this.tileHeight*this.scale.y;this._tx=this.game.math.snapToFloor(a,f)/f,this._ty=this.game.math.snapToFloor(b,g)/g,this._tw=(this.game.math.snapToCeil(c,f)+f)/f,this._th=(this.game.math.snapToCeil(d,g)+g)/g,this._results=[];for(var h=0,i=null,j=0,k=0,l=this._ty;lthis.layer.width&&(this._maxX=this.layer.width),this._maxY>this.layer.height&&(this._maxY=this.layer.height),this.widthInPixels=this.layer.width*this.tileWidth,this.heightInPixels=this.layer.height*this.tileHeight),this.dirty=!0},d.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()},d.TilemapLayer.prototype.deltaAbsY=function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},d.TilemapLayer.prototype.deltaX=function(){return this._dx-this._prevX},d.TilemapLayer.prototype.deltaY=function(){return this._dy-this._prevY},Object.defineProperty(d.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(d.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)}}),d.TilemapParser={tileset:function(a,b,c,e,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>=e&&(e=Math.floor(-k/Math.min(-1,e)));var l=Math.round(j/c),m=Math.round(k/e),n=l*m;if(-1!==f&&(n=f),0===j||0===k||c>j||e>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 d.Tileset(i,b,c,e,g,h),r=0;n>r;r++)q.addTile(new d.Tile(q,r,o,p,c,e)),o+=c+h,o===j&&(o=g,p+=e+h);return q},parse:function(a,b,c){return c===d.Tilemap.CSV?this.parseCSV(b):c===d.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(d.Tileset.prototype,"total",{get:function(){return this.tiles.length}}),c.CanvasRenderer.prototype.render=function(a){c.texturesToUpdate.length=0,c.texturesToDestroy.length=0,c.visibleCount++,a.updateTransform(),this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.width,this.height),this.renderDisplayObject(a),c.Texture.frameUpdates.length>0&&(c.Texture.frameUpdates.length=0)},c.CanvasRenderer.prototype.renderDisplayObject=function(a){var b=a.last._iNext;a=a.first;do if(a.visible)if(a.renderable&&0!==a.alpha){if(a instanceof c.Sprite)a.texture.frame&&(this.context.globalAlpha=a.worldAlpha,a.texture.trimmed?this.context.setTransform(a.worldTransform[0],a.worldTransform[3],a.worldTransform[1],a.worldTransform[4],a.worldTransform[2]+a.texture.trim.x,a.worldTransform[5]+a.texture.trim.y):this.context.setTransform(a.worldTransform[0],a.worldTransform[3],a.worldTransform[1],a.worldTransform[4],a.worldTransform[2],a.worldTransform[5]),this.context.drawImage(a.texture.baseTexture.source,a.texture.frame.x,a.texture.frame.y,a.texture.frame.width,a.texture.frame.height,a.anchor.x*-a.texture.frame.width,a.anchor.y*-a.texture.frame.height,a.texture.frame.width,a.texture.frame.height));else if(a instanceof c.Strip)this.context.setTransform(a.worldTransform[0],a.worldTransform[3],a.worldTransform[1],a.worldTransform[4],a.worldTransform[2],a.worldTransform[5]),this.renderStrip(a);else if(a instanceof c.TilingSprite)this.context.setTransform(a.worldTransform[0],a.worldTransform[3],a.worldTransform[1],a.worldTransform[4],a.worldTransform[2],a.worldTransform[5]),this.renderTilingSprite(a);else if(a instanceof c.CustomRenderable)a.renderCanvas(this);else if(a instanceof c.Graphics)this.context.setTransform(a.worldTransform[0],a.worldTransform[3],a.worldTransform[1],a.worldTransform[4],a.worldTransform[2],a.worldTransform[5]),c.CanvasGraphics.renderGraphics(a,this.context);else if(a instanceof c.FilterBlock)if(a.open){this.context.save();var d=a.mask.alpha,e=a.mask.worldTransform;this.context.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]),a.mask.worldAlpha=.5,this.context.worldAlpha=0,c.CanvasGraphics.renderGraphicsMask(a.mask,this.context),this.context.clip(),a.mask.worldAlpha=d}else this.context.restore();a=a._iNext}else a=a._iNext;else a=a.last._iNext;while(a!=b)},c.WebGLBatch.prototype.update=function(){for(var a,b,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r=0,s=this.head;s;){if(s.vcount===c.visibleCount){if(b=s.texture.frame.width,d=s.texture.frame.height,e=s.anchor.x,f=s.anchor.y,g=b*(1-e),h=b*-e,i=d*(1-f),j=d*-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}},d}); \ No newline at end of file diff --git a/examples/_site/examples.json b/examples/_site/examples.json index 1674520e8..477bb1cad 100644 --- a/examples/_site/examples.json +++ b/examples/_site/examples.json @@ -250,6 +250,10 @@ "file": "display+order.js", "title": "display order" }, + { + "file": "extending+a+group.js", + "title": "extending a group" + }, { "file": "for+each.js", "title": "for each" diff --git a/examples/_site/js/phaser-sideview.js b/examples/_site/js/phaser-sideview.js index 1c7278b4f..6f40b9b5c 100644 --- a/examples/_site/js/phaser-sideview.js +++ b/examples/_site/js/phaser-sideview.js @@ -36,6 +36,9 @@ $(document).ready(function(){ var height = $(window).height() - 270; $("#panel").css('height', height + 'px'); + // iFrame focus + $('a').click(function(e) { $('#viewer').focus(); }); + }) .fail(function() { diff --git a/examples/groups/extending a group.js b/examples/groups/extending a group.js new file mode 100644 index 000000000..cd5fb8964 --- /dev/null +++ b/examples/groups/extending a group.js @@ -0,0 +1,49 @@ +window.onload = function() { + + // Here is a custom group + // It will automatically create 30 sprites of the given image when created. + + MonsterGroup = function (game, image, action) { + + Phaser.Group.call(this, game); + + for (var i = 0; i < 30; i++) + { + var sprite = this.create(game.world.randomX, game.world.randomY, image); + + if (action == 'bounce') + { + game.add.tween(sprite).to({ y: sprite.y - 100 }, 2000, Phaser.Easing.Elastic.Out, true, 0, 1000, true); + } + else if (action == 'slide') + { + game.add.tween(sprite).to({ x: sprite.x + 200 }, 4000, Phaser.Easing.Elastic.Out, true, 0, 1000, true); + } + + } + + }; + + MonsterGroup.prototype = Object.create(Phaser.Group.prototype); + MonsterGroup.prototype.constructor = MonsterGroup; + + var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create }); + + var customGroup1; + var customGroup2; + + function preload() { + + game.load.image('ufo', 'assets/sprites/ufo.png'); + game.load.image('baddie', 'assets/sprites/space-baddie.png'); + + } + + function create() { + + customGroup1 = new MonsterGroup(game, 'ufo', 'bounce'); + customGroup2 = new MonsterGroup(game, 'baddie', 'slide'); + + } + +}(); diff --git a/examples/index.html b/examples/index.html index 311b0e657..e6d47fa17 100644 --- a/examples/index.html +++ b/examples/index.html @@ -12,7 +12,7 @@

- Phaser Version: 1.1.2 + Phaser Version: 1.1.3 New version:
diff --git a/examples/sideview.html b/examples/sideview.html index 12c290d82..8861fd44d 100644 --- a/examples/sideview.html +++ b/examples/sideview.html @@ -19,7 +19,7 @@
diff --git a/src/PixiPatch.js b/src/PixiPatch.js index a085f69a7..23cd92d28 100644 --- a/src/PixiPatch.js +++ b/src/PixiPatch.js @@ -21,12 +21,9 @@ PIXI.CanvasRenderer.prototype.render = function(stage) PIXI.visibleCount++; stage.updateTransform(); - - // update the background color - // if(this.view.style.backgroundColor!=stage.backgroundColorString && !this.transparent)this.view.style.backgroundColor = stage.backgroundColorString; this.context.setTransform(1, 0, 0, 1, 0, 0); - // this.context.clearRect(0, 0, this.width, this.height) + this.context.clearRect(0, 0, this.width, this.height) this.renderDisplayObject(stage); // Remove frame updates diff --git a/src/core/Stage.js b/src/core/Stage.js index 38c06883d..12b053a21 100644 --- a/src/core/Stage.js +++ b/src/core/Stage.js @@ -98,6 +98,8 @@ Phaser.Stage.prototype = { Phaser.Canvas.setUserSelect(this.canvas, 'none'); Phaser.Canvas.setTouchAction(this.canvas, 'none'); + this.backgroundColor = '#000'; + document.addEventListener('visibilitychange', this._onChange, false); document.addEventListener('webkitvisibilitychange', this._onChange, false); document.addEventListener('pagehide', this._onChange, false); @@ -165,19 +167,23 @@ Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", { this._backgroundColor = color; - if (this.game.renderType == Phaser.CANVAS) + if (this.game.transparent === false) { - // Set it directly, this allows us to use rgb alpha values in Canvas mode. - this._stage.backgroundColorString = color; - } - else - { - if (typeof color === 'string') + if (this.game.renderType == Phaser.CANVAS) { - color = Phaser.Color.hexToRGB(color); + // Set it directly, this allows us to use rgb alpha values in Canvas mode. + this.game.canvas.style.backgroundColor = color; + } + else + { + if (typeof color === 'string') + { + color = Phaser.Color.hexToRGB(color); + } + + this._stage.setBackgroundColor(color); } - this._stage.setBackgroundColor(color); } } diff --git a/src/gameobjects/Text.js b/src/gameobjects/Text.js index 63873f3a2..b5be06216 100644 --- a/src/gameobjects/Text.js +++ b/src/gameobjects/Text.js @@ -202,10 +202,10 @@ Object.defineProperty(Phaser.Text.prototype, 'angle', { /** * The x coordinate of this object in world space. -* @name Phaser.BitmapText#x +* @name Phaser.Text#x * @property {number} x - The x coordinate of this object in world space. */ -Object.defineProperty(Phaser.BitmapText.prototype, 'x', { +Object.defineProperty(Phaser.Text.prototype, 'x', { get: function() { return this.position.x; @@ -219,10 +219,10 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'x', { /** * The y coordinate of this object in world space. -* @name Phaser.BitmapText#y +* @name Phaser.Text#y * @property {number} y - The y coordinate of this object in world space. */ -Object.defineProperty(Phaser.BitmapText.prototype, 'y', { +Object.defineProperty(Phaser.Text.prototype, 'y', { get: function() { return this.position.y; diff --git a/src/input/Keyboard.js b/src/input/Keyboard.js index 2c66712f8..efd825693 100644 --- a/src/input/Keyboard.js +++ b/src/input/Keyboard.js @@ -160,8 +160,8 @@ Phaser.Keyboard.prototype = { return _this.processKeyUp(event); }; - document.body.addEventListener('keydown', this._onKeyDown, false); - document.body.addEventListener('keyup', this._onKeyUp, false); + window.addEventListener('keydown', this._onKeyDown, false); + window.addEventListener('keyup', this._onKeyUp, false); }, @@ -172,8 +172,8 @@ Phaser.Keyboard.prototype = { */ stop: function () { - document.body.removeEventListener('keydown', this._onKeyDown); - document.body.removeEventListener('keyup', this._onKeyUp); + window.removeEventListener('keydown', this._onKeyDown); + window.removeEventListener('keyup', this._onKeyUp); },