phaser-ce
Version:
Phaser CE (Community Edition) is a fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.
3 lines (2 loc) • 649 kB
JavaScript
/* Phaser v2.20.2 - http://phaser.io - @photonstorm - (c) 2016 Photon Storm Ltd. */
(function(){var r,t=this,X=X||{VERSION:"2.20.2",AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,WEBGL_MULTI:4,NONE:0,LEFT:1,RIGHT:2,UP:3,DOWN:4,SPRITE:0,BUTTON:1,IMAGE: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,ELLIPSE:16,SPRITEBATCH:17,RETROFONT:18,POINTER:19,ROPE:20,CIRCLE:21,RECTANGLE:22,LINE:23,MATRIX:24,POINT:25,ROUNDEDRECTANGLE:26,CREATURE:27,VIDEO:28,PENDING_ATLAS:-1,HORIZONTAL:0,VERTICAL:1,LANDSCAPE:0,PORTRAIT:1,ANGLE_UP:270,ANGLE_DOWN:90,ANGLE_LEFT:180,ANGLE_RIGHT:0,ANGLE_NORTH_EAST:315,ANGLE_NORTH_WEST:225,ANGLE_SOUTH_EAST:45,ANGLE_SOUTH_WEST:135,TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12,blendModes:{NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16},scaleModes:{DEFAULT:0,LINEAR:0,NEAREST:1},PIXI:PIXI||{},_UID:0,_ID:0};if("undefined"!=typeof AudioBufferSourceNode&&(AudioBufferSourceNode.prototype.start||(AudioBufferSourceNode.prototype.start=AudioBufferSourceNode.prototype.noteGrainOn),AudioBufferSourceNode.prototype.stop||(AudioBufferSourceNode.prototype.stop=AudioBufferSourceNode.prototype.noteOff)),Math.trunc||(Math.trunc=function(t){return t<0?Math.ceil(t):Math.floor(t)}),Function.prototype.bind||(Function.prototype.bind=(r=Array.prototype.slice,function(e){var i=this,s=r.call(arguments,1);if("function"!=typeof i)throw new TypeError;function n(){var t=s.concat(r.call(arguments));i.apply(this instanceof n?this:e,t)}return n.prototype=function t(e){if(e&&(t.prototype=e),!(this instanceof t))return new t}(i.prototype),n})),Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),Array.prototype.forEach||(Array.prototype.forEach=function(t){"use strict";if(null==this)throw new TypeError;var e=Object(this),i=e.length>>>0;if("function"!=typeof t)throw new TypeError;for(var s=2<=arguments.length?arguments[1]:void 0,n=0;n<i;n++)n in e&&t.call(s,e[n],n,e)}),"function"!=typeof window.Uint32Array&&"object"!=typeof window.Uint32Array){var e=function(t){var e=new Array;window[t]=function(t){if("number"==typeof t){Array.call(this,t),this.length=t;for(var e=0;e<this.length;e++)this[e]=0}else{Array.call(this,t.length),this.length=t.length;for(e=0;e<this.length;e++)this[e]=t[e]}},window[t].prototype=e,window[t].constructor=window[t]};e("Float32Array"),e("Uint32Array"),e("Uint16Array"),e("Int16Array"),e("ArrayBuffer")}for(var i in window.console||(window.console={},window.console.log=window.console.assert=function(){},window.console.warn=window.console.assert=function(){}),Object.assign||(Object.assign=function(t,e){"use strict";if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(t),s=Object.prototype.hasOwnProperty,n=1;n<arguments.length;n++){var r=arguments[n];if(null!=r)for(var o in r)s.call(r,o)&&(i[o]=r[o])}return i}),X.Utils={defaults:function(t,e){for(var i=Object.keys(e),s=0,n=i.length;s<n;s++){var r=i[s];void 0===t[r]&&(t[r]=e[r])}return t},reverseString:function(t){return t.split("").reverse().join("")},getProperty:function(t,e){var i=e.split(".");switch(i.length){case 1:return t[e];case 2:return t[i[0]][i[1]];case 3:return t[i[0]][i[1]][i[2]];case 4:return t[i[0]][i[1]][i[2]][i[3]];default:return this._getProperty(t,e)}},setProperties:function(t,e){for(var i in e)this.setProperty(t,i,e[i]);return t},setProperty:function(t,e,i){var s=e.split(".");switch(s.length){case 1:t[e]=i;break;case 2:t[s[0]][s[1]]=i;break;case 3:t[s[0]][s[1]][s[2]]=i;break;case 4:t[s[0]][s[1]][s[2]][s[3]]=i;break;default:this._setProperty(t,e,i)}},_getProperty:function(t,e){for(var i=e.split("."),s=i.length,n=0,r=t;n<s;){var o=i[n];if(null==r)return;r=r[o],n++}return r},_setProperty:function(t,e,i){var s=e.split("."),n=s.length,r=0,o=t,a=s[0];if(1===n)t[e]=i;else{for(;r<n-1;)o=o[a],a=s[++r];o[a]=i}return t},chanceRoll:function(t){return void 0===t&&(t=50),0<t&&100*Math.random()<=t},randomChoice:function(t,e){return Math.random()<.5?t:e},parseDimension:function(t,e){var i=0;return"string"==typeof t?"%"===t.substr(-1)?(i=parseInt(t,10)/100,0===e?window.innerWidth*i:window.innerHeight*i):parseInt(t,10):t},pad:function(t,e,i,s){if(void 0===e)e=0;if(void 0===i)i=" ";if(void 0===s)s=3;var n=0;if(e+1>=(t=t.toString()).length)switch(s){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var r=Math.ceil((n=e-t.length)/2);t=new Array(n-r+1).join(i)+t+new Array(r+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t},isPlainObject:function(t){if("object"!=typeof t||t.nodeType||t===t.window)return!1;try{if(t.constructor&&!{}.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0},extend:function(){var t,e,i,s,n,r,o=arguments[0]||{},a=1,h=arguments.length,l=!1;for("boolean"==typeof o&&(l=o,o=arguments[1]||{},a=2),h===a&&(o=this,--a);a<h;a++)if(null!=(t=arguments[a]))for(e in t)i=o[e],o!==(s=t[e])&&(l&&s&&(X.Utils.isPlainObject(s)||(n=Array.isArray(s)))?(r=n?(n=!1,i&&Array.isArray(i)?i:[]):i&&X.Utils.isPlainObject(i)?i:{},o[e]=X.Utils.extend(l,r,s)):void 0!==s&&(o[e]=s));return o},mixinPrototype:function(t,e,i){void 0===i&&(i=!1);for(var s=Object.keys(e),n=0;n<s.length;n++){var r=s[n],o=e[r];!i&&r in t||(!o||"function"!=typeof o.get&&"function"!=typeof o.set?t[r]=o:"function"==typeof o.clone?t[r]=o.clone():Object.defineProperty(t,r,o))}},mixin:function(t,e){if(!t||"object"!=typeof t)return e;for(var i in t){var s=t[i];if(!s.childNodes&&!s.cloneNode){var n=typeof t[i];t[i]&&"object"===n?typeof e[i]===n?e[i]=X.Utils.mixin(t[i],e[i]):e[i]=X.Utils.mixin(t[i],new s.constructor):e[i]=t[i]}}return e}},X.Circle=function(t,e,i){t=t||0,e=e||0,i=i||0,this.x=t,this.y=e,this._diameter=i,(this._radius=0)<i&&(this._radius=.5*i),this.type=X.CIRCLE},X.Circle.prototype={circumference:function(){return Math.PI*this._radius*2},random:function(t){void 0===t&&(t=new X.Point);var e=2*Math.PI*Math.random(),i=Math.random()+Math.random(),s=1<i?2-i:i,n=s*Math.cos(e),r=s*Math.sin(e);return t.x=this.x+n*this.radius,t.y=this.y+r*this.radius,t},getBounds:function(){return new X.Rectangle(this.x-this.radius,this.y-this.radius,this.diameter,this.diameter)},setTo:function(t,e,i){return this.x=t,this.y=e,this._diameter=i,this._radius=.5*i,this},copyFrom:function(t){return this.setTo(t.x,t.y,t.diameter)},copyTo:function(t){return t.x=this.x,t.y=this.y,t.diameter=this._diameter,t},distance:function(t,e){var i=X.Math.distance(this.x,this.y,t.x,t.y);return e?Math.round(i):i},clone:function(t){return null==t?t=new X.Circle(this.x,this.y,this.diameter):t.setTo(this.x,this.y,this.diameter),t},contains:function(t,e){return X.Circle.contains(this,t,e)},circumferencePoint:function(t,e,i){return X.Circle.circumferencePoint(this,t,e,i)},sample:function(t,e,i,s,n){t||(t=60),null==e&&(e=0),null==i&&(i=X.Math.PI2),n||(n=[]);for(var r=0;r<t;)this.circumferencePoint(X.Math.linear(e,i,r/t),s,n[r]||(n[r]=new X.Point)),r+=1;return n},offset:function(t,e){return this.x+=t,this.y+=e,this},offsetPoint:function(t){return this.offset(t.x,t.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}},X.Circle.prototype.constructor=X.Circle,Object.defineProperty(X.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(t){0<t&&(this._diameter=t,this._radius=.5*t)}}),Object.defineProperty(X.Circle.prototype,"radius",{get:function(){return this._radius},set:function(t){0<t&&(this._radius=t,this._diameter=2*t)}}),Object.defineProperty(X.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(t){t>this.x?(this._radius=0,this._diameter=0):this.radius=this.x-t}}),Object.defineProperty(X.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(t){t<this.x?(this._radius=0,this._diameter=0):this.radius=t-this.x}}),Object.defineProperty(X.Circle.prototype,"top",{get:function(){return this.y-this._radius},set:function(t){t>this.y?(this._radius=0,this._diameter=0):this.radius=this.y-t}}),Object.defineProperty(X.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(t){t<this.y?(this._radius=0,this._diameter=0):this.radius=t-this.y}}),Object.defineProperty(X.Circle.prototype,"area",{get:function(){return 0<this._radius?Math.PI*this._radius*this._radius:0}}),Object.defineProperty(X.Circle.prototype,"empty",{get:function(){return 0===this._diameter},set:function(t){!0===t&&this.setTo(0,0,0)}}),X.Circle.contains=function(t,e,i){return 0<t.radius&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius},X.Circle.equals=function(t,e){return t.x===e.x&&t.y===e.y&&t.diameter===e.diameter},X.Circle.intersects=function(t,e){return X.Math.distance(t.x,t.y,e.x,e.y)<=t.radius+e.radius},X.Circle.circumferencePoint=function(t,e,i,s){return void 0===i&&(i=!1),void 0===s&&(s=new X.Point),!0===i&&(e=X.Math.degToRad(e)),s.x=t.x+t.radius*Math.cos(e),s.y=t.y+t.radius*Math.sin(e),s},X.Circle.intersectsRectangle=function(t,e){var i=Math.abs(t.x-e.x-e.halfWidth);if(e.halfWidth+t.radius<i)return!1;var s=Math.abs(t.y-e.y-e.halfHeight);if(e.halfHeight+t.radius<s)return!1;if(i<=e.halfWidth||s<=e.halfHeight)return!0;var n=i-e.halfWidth,r=s-e.halfHeight;return n*n+r*r<=t.radius*t.radius},X.Circle.intersectsLine=function(t,e,i){var s=t.x,n=t.y,r=(e.end.y-e.start.y)/(e.end.x-e.start.x),o=e.end.y-r*e.end.x,a=t.radius,h=t.radius,l=o+r*s,c=(s*(h*h)-r*(a*a)*(o-n)+a*h*Math.sqrt(a*a*(r*r)+h*h-l*l-n*n+2*l*n))/(a*a*(r*r)+h*h),u=(s*(h*h)-r*(a*a)*(o-n)-a*h*Math.sqrt(a*a*(r*r)+h*h-l*l-n*n+2*l*n))/(a*a*(r*r)+h*h),d=r*c+o,p=r*u+o,f=new X.Point(c,d),g=new X.Point(u,p),m=e.pointOnSegment(f.x,f.y,.01),y=e.pointOnSegment(g.x,g.y,.01);return m&&y?!i||[f,g]:m?!i||[f]:y?!i||[g]:!!i&&[]},PIXI.Circle=X.Circle,X.Ellipse=function(t,e,i,s){t=t||0,e=e||0,i=i||0,s=s||0,this.x=t,this.y=e,this.width=i,this.height=s,this.type=X.ELLIPSE},X.Ellipse.prototype={setTo:function(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this},getBounds:function(){return new X.Rectangle(this.x-this.width,this.y-this.height,this.width,this.height)},copyFrom:function(t){return this.setTo(t.x,t.y,t.width,t.height)},copyTo:function(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t},clone:function(t){return null==t?t=new X.Ellipse(this.x,this.y,this.width,this.height):t.setTo(this.x,this.y,this.width,this.height),t},contains:function(t,e){return X.Ellipse.contains(this,t,e)},random:function(t){void 0===t&&(t=new X.Point);var e=Math.random()*Math.PI*2,i=Math.sqrt(Math.random());return t.x=this.centerX+.5*i*Math.cos(e)*this.width,t.y=this.centerY+.5*i*Math.sin(e)*this.height,t},toString:function(){return"[{Phaser.Ellipse (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")}]"}},X.Ellipse.prototype.constructor=X.Ellipse,Object.defineProperty(X.Ellipse.prototype,"left",{get:function(){return this.x},set:function(t){this.x=t}}),Object.defineProperty(X.Ellipse.prototype,"right",{get:function(){return this.x+this.width},set:function(t){t<this.x?this.width=0:this.width=t-this.x}}),Object.defineProperty(X.Ellipse.prototype,"top",{get:function(){return this.y},set:function(t){this.y=t}}),Object.defineProperty(X.Ellipse.prototype,"bottom",{get:function(){return this.y+this.height},set:function(t){t<this.y?this.height=0:this.height=t-this.y}}),Object.defineProperty(X.Ellipse.prototype,"centerX",{get:function(){return this.x+.5*this.width}}),Object.defineProperty(X.Ellipse.prototype,"centerY",{get:function(){return this.y+.5*this.height}}),Object.defineProperty(X.Ellipse.prototype,"empty",{get:function(){return 0===this.width||0===this.height},set:function(t){!0===t&&this.setTo(0,0,0,0)}}),X.Ellipse.contains=function(t,e,i){if(t.width<=0||t.height<=0)return!1;var s=(e-t.x)/t.width-.5,n=(i-t.y)/t.height-.5;return(s*=s)+(n*=n)<.25},X.Ellipse.intersectsLine=function(t,e,i){var s=t.x,n=t.y,r=(e.end.y-e.start.y)/(e.end.x-e.start.x),o=e.end.y-r*e.end.x,a=t.width/2,h=t.height/2,l=o+r*s,c=(s*(h*h)-r*(a*a)*(o-n)+a*h*Math.sqrt(a*a*(r*r)+h*h-l*l-n*n+2*l*n))/(a*a*(r*r)+h*h),u=(s*(h*h)-r*(a*a)*(o-n)-a*h*Math.sqrt(a*a*(r*r)+h*h-l*l-n*n+2*l*n))/(a*a*(r*r)+h*h),d=r*c+o,p=r*u+o,f=new X.Point(c,d),g=new X.Point(u,p),m=e.pointOnSegment(f.x,f.y,.01),y=e.pointOnSegment(g.x,g.y,.01);return m&&y?!i||[f,g]:m?!i||[f]:y?!i||[g]:!!i&&[]},PIXI.Ellipse=X.Ellipse,X.Line=function(t,e,i,s){t=t||0,e=e||0,i=i||0,s=s||0,this.start=new X.Point(t,e),this.end=new X.Point(i,s),this.type=X.LINE},X.Line.prototype={setTo:function(t,e,i,s){return this.start.setTo(t,e),this.end.setTo(i,s),this},fromPoints:function(t,e){return this.setTo(t.x,t.y,e.x,e.y),this},fromSprite:function(t,e,i){return void 0===i&&(i=!1),i?this.setTo(t.centerX,t.centerY,e.centerX,e.centerY):this.fromPoints(t,e)},fromAngle:function(t,e,i,s){return this.start.setTo(t,e),this.end.setTo(t+Math.cos(i)*s,e+Math.sin(i)*s),this},rotate:function(t,e){var i=(this.start.x+this.end.x)/2,s=(this.start.y+this.end.y)/2;return this.start.rotate(i,s,t,e),this.end.rotate(i,s,t,e),this},rotateAround:function(t,e,i,s){return this.start.rotate(t,e,i,s),this.end.rotate(t,e,i,s),this},intersects:function(t,e,i){return X.Line.intersectsPoints(this.start,this.end,t.start,t.end,e,i)},reflect:function(t){return X.Line.reflect(this,t)},midPoint:function(t){return void 0===t&&(t=new X.Point),t.x=(this.start.x+this.end.x)/2,t.y=(this.start.y+this.end.y)/2,t},centerOn:function(t,e){var i=t-(this.start.x+this.end.x)/2,s=e-(this.start.y+this.end.y)/2;this.start.add(i,s),this.end.add(i,s)},pointOnLine:function(t,e,i){return X.Math.fuzzyEqual((t-this.start.x)*(this.end.y-this.start.y),(this.end.x-this.start.x)*(e-this.start.y),i||0)},pointOnSegment:function(t,e,i){var s=Math.min(this.start.x,this.end.x),n=Math.max(this.start.x,this.end.x),r=Math.min(this.start.y,this.end.y),o=Math.max(this.start.y,this.end.y);return this.pointOnLine(t,e,i)&&s<=t&&t<=n&&r<=e&&e<=o},random:function(t){void 0===t&&(t=new X.Point);var e=Math.random();return t.x=this.start.x+e*(this.end.x-this.start.x),t.y=this.start.y+e*(this.end.y-this.start.y),t},coordinatesOnLine:function(t,e){void 0===t&&(t=1),void 0===e&&(e=[]);var i=Math.round(this.start.x),s=Math.round(this.start.y),n=Math.round(this.end.x),r=Math.round(this.end.y),o=Math.abs(n-i),a=Math.abs(r-s),h=i<n?1:-1,l=s<r?1:-1,c=o-a;e.push([i,s]);for(var u=1;i!==n||s!==r;){var d=c<<1;-a<d&&(c-=a,i+=h),d<o&&(c+=o,s+=l),u%t==0&&e.push([i,s]),u++}return e},clone:function(t){return null==t?t=new X.Line(this.start.x,this.start.y,this.end.x,this.end.y):t.setTo(this.start.x,this.start.y,this.end.x,this.end.y),t}},Object.defineProperty(X.Line.prototype,"length",{get:function(){return Math.sqrt((this.end.x-this.start.x)*(this.end.x-this.start.x)+(this.end.y-this.start.y)*(this.end.y-this.start.y))}}),Object.defineProperty(X.Line.prototype,"angle",{get:function(){return X.Point.angle(this.end,this.start)}}),Object.defineProperty(X.Line.prototype,"slope",{get:function(){return(this.end.y-this.start.y)/(this.end.x-this.start.x)}}),Object.defineProperty(X.Line.prototype,"perpSlope",{get:function(){return-(this.end.x-this.start.x)/(this.end.y-this.start.y)}}),Object.defineProperty(X.Line.prototype,"x",{get:function(){return Math.min(this.start.x,this.end.x)}}),Object.defineProperty(X.Line.prototype,"y",{get:function(){return Math.min(this.start.y,this.end.y)}}),Object.defineProperty(X.Line.prototype,"left",{get:function(){return Math.min(this.start.x,this.end.x)}}),Object.defineProperty(X.Line.prototype,"right",{get:function(){return Math.max(this.start.x,this.end.x)}}),Object.defineProperty(X.Line.prototype,"top",{get:function(){return Math.min(this.start.y,this.end.y)}}),Object.defineProperty(X.Line.prototype,"bottom",{get:function(){return Math.max(this.start.y,this.end.y)}}),Object.defineProperty(X.Line.prototype,"width",{get:function(){return Math.abs(this.start.x-this.end.x)}}),Object.defineProperty(X.Line.prototype,"height",{get:function(){return Math.abs(this.start.y-this.end.y)}}),Object.defineProperty(X.Line.prototype,"normalX",{get:function(){return Math.cos(this.angle-1.5707963267948966)}}),Object.defineProperty(X.Line.prototype,"normalY",{get:function(){return Math.sin(this.angle-1.5707963267948966)}}),Object.defineProperty(X.Line.prototype,"normalAngle",{get:function(){return X.Math.wrap(this.angle-1.5707963267948966,-Math.PI,Math.PI)}}),X.Line.intersectsPoints=function(t,e,i,s,n,r){void 0===n&&(n=!0),void 0===r&&(r=new X.Point);var o=e.y-t.y,a=s.y-i.y,h=t.x-e.x,l=i.x-s.x,c=e.x*t.y-t.x*e.y,u=s.x*i.y-i.x*s.y,d=o*l-a*h;if(0===d)return null;if(r.x=(h*u-l*c)/d,r.y=(a*c-o*u)/d,n){var p=(s.y-i.y)*(e.x-t.x)-(s.x-i.x)*(e.y-t.y),f=((s.x-i.x)*(t.y-i.y)-(s.y-i.y)*(t.x-i.x))/p,g=((e.x-t.x)*(t.y-i.y)-(e.y-t.y)*(t.x-i.x))/p;return 0<=f&&f<=1&&0<=g&&g<=1?r:null}return r},X.Line.intersects=function(t,e,i,s){return X.Line.intersectsPoints(t.start,t.end,e.start,e.end,i,s)},X.Line.intersectsRectangle=function(t,e){if(0===t.length||e.empty)return!1;var i=t.start.x,s=t.start.y,n=t.end.x,r=t.end.y,o=e.x,a=e.y,h=e.right,l=e.bottom,c=0;if(o<=i&&i<=h&&a<=s&&s<=l||o<=n&&n<=h&&a<=r&&r<=l)return!0;if(i<o&&o<=n){if(a<(c=s+(r-s)*(o-i)/(n-i))&&c<=l)return!0}else if(h<i&&n<=h&&a<=(c=s+(r-s)*(h-i)/(n-i))&&c<=l)return!0;if(s<a&&a<=r){if(o<=(c=i+(n-i)*(a-s)/(r-s))&&c<=h)return!0}else if(l<s&&r<=l&&o<=(c=i+(n-i)*(l-s)/(r-s))&&c<=h)return!0;return!1},X.Line.intersectionWithRectangle=function(t,e,i){var s=X.Line.intersectionWithRectangle;i||(i=new X.Point),s.edges||(s.edges=[new X.Line,new X.Line,new X.Line,new X.Line]),s.edgeIntersection||(s.edgeIntersection=new X.Point);var n=s.edges,r=s.edgeIntersection.set(0),o=e.x,a=e.y,h=e.right,l=e.bottom,c=1/0;n[0].setTo(o,a,h,a),n[1].setTo(o,l,h,l),n[2].setTo(o,a,o,l),n[3].setTo(h,a,h,l);for(var u,d=0;u=n[d];d++)if(t.intersects(u,!0,r)){var p=t.start.distance(r);p<c&&(c=p,i.copyFrom(r))}return null!=p?i:null},X.Line.reflect=function(t,e){return 2*e.normalAngle-3.141592653589793-t.angle},X.Matrix=function(t,e,i,s,n,r){null==t&&(t=1),null==e&&(e=0),null==i&&(i=0),null==s&&(s=1),null==n&&(n=0),null==r&&(r=0),this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=r,this.type=X.MATRIX},X.Matrix.prototype={fromArray:function(t){return this.setTo(t[0],t[1],t[3],t[4],t[2],t[5])},setTo:function(t,e,i,s,n,r){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=r,this},clone:function(t){return null==t?t=new X.Matrix(this.a,this.b,this.c,this.d,this.tx,this.ty):(t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty),t},copyTo:function(t){return t.copyFrom(this),t},copyFrom:function(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this},toArray:function(t,e){return void 0===e&&(e=new Float32Array(9)),t?(e[0]=this.a,e[1]=this.b,e[2]=0,e[3]=this.c,e[4]=this.d,e[5]=0,e[6]=this.tx,e[7]=this.ty):(e[0]=this.a,e[1]=this.c,e[2]=this.tx,e[3]=this.b,e[4]=this.d,e[5]=this.ty,e[6]=0,e[7]=0),e[8]=1,e},apply:function(t,e){return void 0===e&&(e=new X.Point),e.x=this.a*t.x+this.c*t.y+this.tx,e.y=this.b*t.x+this.d*t.y+this.ty,e},applyInverse:function(t,e){void 0===e&&(e=new X.Point);var i=1/(this.a*this.d+this.c*-this.b),s=t.x,n=t.y;return e.x=this.d*i*s+-this.c*i*n+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*n+-this.b*i*s+(-this.ty*this.a+this.tx*this.b)*i,e},translate:function(t,e){return this.tx+=t,this.ty+=e,this},scale:function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},rotate:function(t){var e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,r=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=r*e-this.ty*i,this.ty=r*i+this.ty*e,this},append:function(t){var e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this},identity:function(){return this.setTo(1,0,0,1,0,0)}},X.identityMatrix=new X.Matrix,X.Point=function(t,e){t=t||0,e=e||0,this.x=t,this.y=e,this.type=X.POINT},X.Point.prototype={copyFrom:function(t){return this.setTo(t.x,t.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(t,e){return X.Point.set(this,t,e)},set:function(t,e){return X.Point.set(this,t,e)},setToPolar:function(t,e,i){return null==e&&(e=1),i&&(t=X.Math.degToRad(t)),this.setTo(Math.cos(t)*e,Math.sin(t)*e)},add:function(t,e){return this.x+=t,this.y+=e,this},subtract:function(t,e){return this.x-=t,this.y-=e,this},multiply:function(t,e){return this.x*=t,this.y*=e,this},divide:function(t,e){return this.x/=t,this.y/=e,this},clampX:function(t,e){return this.x=X.Math.clamp(this.x,t,e),this},clampY:function(t,e){return this.y=X.Math.clamp(this.y,t,e),this},clamp:function(t,e){return this.x=X.Math.clamp(this.x,t,e),this.y=X.Math.clamp(this.y,t,e),this},clip:function(t){var e=t.left,i=t.top,s=t.right,n=t.bottom;return this.x<e?this.x=e:this.x>s&&(this.x=s),this.y<i?this.y=i:this.y>n&&(this.y=n),this},clone:function(t){return null==t?t=new X.Point(this.x,this.y):t.setTo(this.x,this.y),t},copyTo:function(t){return t.x=this.x,t.y=this.y,t},distance:function(t,e){return X.Point.distance(this,t,e)},equals:function(t){return t.x===this.x&&t.y===this.y},equalsXY:function(t,e){return this.x===t&&this.y===e},fuzzyEquals:function(t,e){return X.Point.fuzzyEquals(this,t,e)},fuzzyEqualsXY:function(t,e,i){return X.Point.fuzzyEqualsXY(this,t,e,i)},angle:function(t,e){return this.angleXY(t.x,t.y,e)},angleXY:function(t,e,i){var s=Math.atan2(e-this.y,t-this.x);return i?X.Math.radToDeg(s):s},atan:function(t){var e=Math.atan2(this.y,this.x);return t?X.Math.radToDeg(e):e},rotate:function(t,e,i,s,n){return X.Point.rotate(this,t,e,i,s,n)},getMagnitude:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},getMagnitudeSq:function(){return this.x*this.x+this.y*this.y},setMagnitude:function(t){return this.normalize().multiply(t,t)},normalize:function(){if(!this.isZero()){var t=this.getMagnitude();this.x/=t,this.y/=t}return this},limit:function(t){return this.getMagnitudeSq()>t*t&&this.setMagnitude(t),this},expand:function(t){return this.getMagnitudeSq()<t*t&&this.setMagnitude(t),this},isZero:function(){return 0===this.x&&0===this.y},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},perp:function(){return this.setTo(-this.y,this.x)},rperp:function(){return this.setTo(this.y,-this.x)},normalRightHand:function(){return this.setTo(-1*this.y,this.x)},floor:function(){return this.setTo(Math.floor(this.x),Math.floor(this.y))},ceil:function(){return this.setTo(Math.ceil(this.x),Math.ceil(this.y))},round:function(){return this.setTo(Math.round(this.x),Math.round(this.y))},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}},X.Point.prototype.constructor=X.Point,X.Point.add=function(t,e,i){return void 0===i&&(i=new X.Point),i.x=t.x+e.x,i.y=t.y+e.y,i},X.Point.subtract=function(t,e,i){return void 0===i&&(i=new X.Point),i.x=t.x-e.x,i.y=t.y-e.y,i},X.Point.multiply=function(t,e,i){return void 0===i&&(i=new X.Point),i.x=t.x*e.x,i.y=t.y*e.y,i},X.Point.divide=function(t,e,i){return void 0===i&&(i=new X.Point),i.x=t.x/e.x,i.y=t.y/e.y,i},X.Point.equals=function(t,e){return t.x===e.x&&t.y===e.y},X.Point.equalsXY=function(t,e,i){return t.x===e&&t.y===i},X.Point.fuzzyEquals=function(t,e,i){return X.Math.fuzzyEqual(t.x,e.x,i)&&X.Math.fuzzyEqual(t.y,e.y,i)},X.Point.fuzzyEqualsXY=function(t,e,i,s){return X.Math.fuzzyEqual(t.x,e,s)&&X.Math.fuzzyEqual(t.y,i,s)},X.Point.angle=function(t,e){return Math.atan2(t.y-e.y,t.x-e.x)},X.Point.negative=function(t,e){return void 0===e&&(e=new X.Point),e.setTo(-t.x,-t.y)},X.Point.multiplyAdd=function(t,e,i,s){return void 0===s&&(s=new X.Point),s.setTo((t.x+e.x)*i,(t.y+e.y)*i)},X.Point.interpolate=function(t,e,i,s){return void 0===s&&(s=new X.Point),s.setTo(t.x+(e.x-t.x)*i,t.y+(e.y-t.y)*i)},X.Point.perp=function(t,e){return void 0===e&&(e=new X.Point),e.setTo(-t.y,t.x)},X.Point.rperp=function(t,e){return void 0===e&&(e=new X.Point),e.setTo(t.y,-t.x)},X.Point.distance=function(t,e,i){var s=X.Math.distance(t.x,t.y,e.x,e.y);return i?Math.round(s):s},X.Point.project=function(t,e,i){void 0===i&&(i=new X.Point);var s=t.dot(e)/e.getMagnitudeSq();return 0!==s&&i.setTo(s*e.x,s*e.y),i},X.Point.projectUnit=function(t,e,i){void 0===i&&(i=new X.Point);var s=t.dot(e);return 0!==s&&i.setTo(s*e.x,s*e.y),i},X.Point.normalRightHand=function(t,e){return void 0===e&&(e=new X.Point),e.setTo(-1*t.y,t.x)},X.Point.normalize=function(t,e){void 0===e&&(e=new X.Point);var i=t.getMagnitude();return 0!==i&&e.setTo(t.x/i,t.y/i),e},X.Point.rotate=function(t,e,i,s,n,r){if(n&&(s=X.Math.degToRad(s)),void 0===r){t.subtract(e,i);var o=Math.sin(s),a=Math.cos(s),h=a*t.x-o*t.y,l=o*t.x+a*t.y;t.x=h+e,t.y=l+i}else{var c=s+Math.atan2(t.y-i,t.x-e);t.x=e+r*Math.cos(c),t.y=i+r*Math.sin(c)}return t},X.Point.centroid=function(t,e){if(void 0===e&&(e=new X.Point),"[object Array]"!==Object.prototype.toString.call(t))throw new Error("Phaser.Point. Parameter 'points' must be an array");var i=t.length;if(i<1)throw new Error("Phaser.Point. Parameter 'points' array must not be empty");if(1===i)return e.copyFrom(t[0]),e;for(var s=0;s<i;s++)X.Point.add(e,t[s],e);return e.divide(i,i),e},X.Point.parse=function(t,e,i){e=e||"x",i=i||"y";var s=new X.Point;return t[e]&&(s.x=parseFloat(t[e])),t[i]&&(s.y=parseFloat(t[i])),s},X.Point.trunc=function(t){return t.x=X.Math.trunc(t.x),t.y=X.Math.trunc(t.y),t},X.Point.isPoint=function(t){return null!=t&&"number"==typeof t.x&&"number"==typeof t.y},X.Point.set=function(t,e,i){return t.x=e||0,t.y=i||(0!==i?t.x:0),t},X.Point.sortClockwise=function(t,e){e||(e=this.centroid(t));var n=e.x,r=e.y;return t.sort(function(t,e){if(0<=t.x-n&&e.x-n<0)return-1;if(t.x-n<0&&0<=e.x-n)return 1;if(t.x-n==0&&e.x-n==0)return 0<=t.y-r||0<=e.y-r?t.y>e.y?1:-1:e.y>t.y?1:-1;var i=(t.x-n)*-(e.y-r)-(e.x-n)*-(t.y-r);if(i<0)return-1;if(0<i)return 1;var s=(t.x-n)*(t.x-n)+(t.y-r)*(t.y-r);return(e.x-n)*(e.x-n)+(e.y-r)*(e.y-r)<s?-1:1})},PIXI.Point=X.Point,X.Polygon=function(){this.area=0,this._points=[],0<arguments.length&&this.setTo.apply(this,arguments),this.closed=!0,this.flattened=!1,this.type=X.POLYGON},X.Polygon.prototype={toNumberArray:function(t){void 0===t&&(t=[]);for(var e=0;e<this._points.length;e++)"number"==typeof this._points[e]?(t.push(this._points[e]),t.push(this._points[e+1]),e++):(t.push(this._points[e].x),t.push(this._points[e].y));return t},flatten:function(){return this._points=this.toNumberArray(),this.flattened=!0,this},clone:function(t){var e=this._points.slice();return null==t?t=new X.Polygon(e):t.setTo(e),t},contains:function(t,e){var i=!1;if(this.flattened)for(var s=-2,n=this._points.length-2;(s+=2)<this._points.length;n=s){var r=this._points[s],o=this._points[s+1],a=this._points[n],h=this._points[n+1];(o<=e&&e<h||h<=e&&e<o)&&t<(a-r)*(e-o)/(h-o)+r&&(i=!i)}else for(s=-1,n=this._points.length-1;++s<this._points.length;n=s){r=this._points[s].x,o=this._points[s].y,a=this._points[n].x,h=this._points[n].y;(o<=e&&e<h||h<=e&&e<o)&&t<(a-r)*(e-o)/(h-o)+r&&(i=!i)}return i},setTo:function(t){if(this.area=0,this._points=[],0<arguments.length){Array.isArray(t)||(t=Array.prototype.slice.call(arguments));for(var e=Number.MAX_VALUE,i=0,s=t.length;i<s;i++){if("number"==typeof t[i]){var n=new PIXI.Point(t[i],t[i+1]);i++}else if(Array.isArray(t[i]))n=new PIXI.Point(t[i][0],t[i][1]);else n=new PIXI.Point(t[i].x,t[i].y);this._points.push(n),n.y<e&&(e=n.y)}this.calculateArea(e)}return this},calculateArea:function(t){for(var e,i,s,n,r=0,o=this._points.length;r<o;r++)e=this._points[r],i=r===o-1?this._points[0]:this._points[r+1],s=(e.y-t+(i.y-t))/2,n=e.x-i.x,this.area+=s*n;return this.area}},X.Polygon.prototype.constructor=X.Polygon,Object.defineProperty(X.Polygon.prototype,"points",{get:function(){return this._points}}),PIXI.Polygon=X.Polygon,X.Rectangle=function(t,e,i,s){t=t||0,e=e||0,i=i||0,s=s||0,this.x=t,this.y=e,this.width=i,this.height=s,this.type=X.RECTANGLE},X.Rectangle.prototype={offset:function(t,e){return this.x+=t,this.y+=e,this},offsetPoint:function(t){return this.offset(t.x,t.y)},setTo:function(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this},scale:function(t,e){return void 0===e&&(e=t),this.width*=t,this.height*=e,this},centerOn:function(t,e){return this.centerX=t,this.centerY=e,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)},ceil:function(){this.x=Math.ceil(this.x),this.y=Math.ceil(this.y)},ceilAll:function(){this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.width=Math.ceil(this.width),this.height=Math.ceil(this.height)},copyFrom:function(t){return this.setTo(t.x,t.y,t.width,t.height)},copyFromBounds:function(t){return this.setTo(t.left,t.top,t.width,t.height)},copyTo:function(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t},inflate:function(t,e){return X.Rectangle.inflate(this,t,e)},size:function(t){return X.Rectangle.size(this,t)},resize:function(t,e){return this.width=t,this.height=e,this},clone:function(t){return X.Rectangle.clone(this,t)},contains:function(t,e){return X.Rectangle.contains(this,t,e)},containsRect:function(t){return X.Rectangle.containsRect(t,this)},equals:function(t){return X.Rectangle.equals(this,t)},intersection:function(t,e){return X.Rectangle.intersection(this,t,e)},intersects:function(t){return X.Rectangle.intersects(this,t)},intersectsRaw:function(t,e,i,s,n){return X.Rectangle.intersectsRaw(this,t,e,i,s,n)},union:function(t,e){return X.Rectangle.union(this,t,e)},random:function(t){return void 0===t&&(t=new X.Point),t.x=this.randomX,t.y=this.randomY,t},getPoint:function(t,e){switch(void 0===e&&(e=new X.Point),t){default:case X.TOP_LEFT:return e.set(this.x,this.y);case X.TOP_CENTER:return e.set(this.centerX,this.y);case X.TOP_RIGHT:return e.set(this.right,this.y);case X.LEFT_CENTER:return e.set(this.x,this.centerY);case X.CENTER:return e.set(this.centerX,this.centerY);case X.RIGHT_CENTER:return e.set(this.right,this.centerY);case X.BOTTOM_LEFT:return e.set(this.x,this.bottom);case X.BOTTOM_CENTER:return e.set(this.centerX,this.bottom);case X.BOTTOM_RIGHT:return e.set(this.right,this.bottom)}},sides:function(t,e,i,s){arguments.length||(t=new X.Line,e=new X.Line,i=new X.Line,s=new X.Line);var n=this.x,r=this.y,o=this.right,a=this.bottom;return t.setTo(n,r,o,r),e.setTo(o,r,o,a),i.setTo(n,a,o,a),s.setTo(n,r,n,a),arguments.length?null:[t,e,i,s]},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}},Object.defineProperty(X.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)}}),Object.defineProperty(X.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)}}),Object.defineProperty(X.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(t){t<=this.y?this.height=0:this.height=t-this.y}}),Object.defineProperty(X.Rectangle.prototype,"bottomLeft",{get:function(){return new X.Point(this.x,this.bottom)},set:function(t){this.x=t.x,this.bottom=t.y}}),Object.defineProperty(X.Rectangle.prototype,"bottomRight",{get:function(){return new X.Point(this.right,this.bottom)},set:function(t){this.right=t.x,this.bottom=t.y}}),Object.defineProperty(X.Rectangle.prototype,"left",{get:function(){return this.x},set:function(t){t>=this.right?this.width=0:this.width=this.right-t,this.x=t}}),Object.defineProperty(X.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}}),Object.defineProperty(X.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}}),Object.defineProperty(X.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}}),Object.defineProperty(X.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(t){this.x=t-this.halfWidth}}),Object.defineProperty(X.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(t){this.y=t-this.halfHeight}}),Object.defineProperty(X.Rectangle.prototype,"randomX",{get:function(){return this.x+Math.random()*this.width}}),Object.defineProperty(X.Rectangle.prototype,"randomY",{get:function(){return this.y+Math.random()*this.height}}),Object.defineProperty(X.Rectangle.prototype,"top",{get:function(){return this.y},set:function(t){t>=this.bottom?(this.height=0,this.y=t):this.height=this.bottom-t}}),Object.defineProperty(X.Rectangle.prototype,"topLeft",{get:function(){return new X.Point(this.x,this.y)},set:function(t){this.x=t.x,this.y=t.y}}),Object.defineProperty(X.Rectangle.prototype,"topRight",{get:function(){return new X.Point(this.x+this.width,this.y)},set:function(t){this.right=t.x,this.y=t.y}}),Object.defineProperty(X.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(t){!0===t&&this.setTo(0,0,0,0)}}),X.Rectangle.prototype.constructor=X.Rectangle,X.Rectangle.inflate=function(t,e,i){return t.x-=e,t.width+=2*e,t.y-=i,t.height+=2*i,t},X.Rectangle.inflatePoint=function(t,e){return X.Rectangle.inflate(t,e.x,e.y)},X.Rectangle.size=function(t,e){return null==e?e=new X.Point(t.width,t.height):e.setTo(t.width,t.height),e},X.Rectangle.clone=function(t,e){return null==e?e=new X.Rectangle(t.x,t.y,t.width,t.height):e.setTo(t.x,t.y,t.width,t.height),e},X.Rectangle.createFromBounds=function(t,e){return null==e&&(e=new X.Rectangle(t.x,t.y,t.width,t.height)),e.copyFromBounds(t)},X.Rectangle.contains=function(t,e,i){return!(t.width<=0||t.height<=0)&&(e>=t.x&&e<t.right&&i>=t.y&&i<t.bottom)},X.Rectangle.containsRaw=function(t,e,i,s,n,r){return t<=n&&n<t+i&&e<=r&&r<e+s},X.Rectangle.containsPoint=function(t,e){return X.Rectangle.contains(t,e.x,e.y)},X.Rectangle.containsRect=function(t,e){return!(t.volume>e.volume)&&(t.x>=e.x&&t.y>=e.y&&t.right<e.right&&t.bottom<e.bottom)},X.Rectangle.equals=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height},X.Rectangle.sameDimensions=function(t,e){return t.width===e.width&&t.height===e.height},X.Rectangle.intersection=function(t,e,i){return void 0===i&&(i=new X.Rectangle),X.Rectangle.intersects(t,e)&&(i.x=Math.max(t.x,e.x),i.y=Math.max(t.y,e.y),i.width=Math.min(t.right,e.right)-i.x,i.height=Math.min(t.bottom,e.bottom)-i.y),i},X.Rectangle.intersects=function(t,e){return!(t.width<=0||t.height<=0||e.width<=0||e.height<=0)&&!(t.right<e.x||t.bottom<e.y||t.x>e.right||t.y>e.bottom)},X.Rectangle.intersectsRaw=function(t,e,i,s,n,r){return void 0===r&&(r=0),!(e>t.right+r||i<t.left-r||s>t.bottom+r||n<t.top-r)},X.Rectangle.union=function(t,e,i){return void 0===i&&(i=new X.Rectangle),i.setTo(Math.min(t.x,e.x),Math.min(t.y,e.y),Math.max(t.right,e.right)-Math.min(t.left,e.left),Math.max(t.bottom,e.bottom)-Math.min(t.top,e.top))},X.Rectangle.aabb=function(t,e){void 0===e&&(e=new X.Rectangle);var i=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;return t.forEach(function(t){t.x>i&&(i=t.x),t.x<s&&(s=t.x),t.y>n&&(n=t.y),t.y<r&&(r=t.y)}),e.setTo(s,r,i-s,n-r),e},PIXI.Rectangle=X.Rectangle,X.EmptyRectangle=new X.Rectangle(0,0,0,0),X.RoundedRectangle=function(t,e,i,s,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=20),this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n||20,this.type=X.ROUNDEDRECTANGLE},X.RoundedRectangle.prototype={clone:function(){return new X.RoundedRectangle(this.x,this.y,this.width,this.height,this.radius)},contains:function(t,e){if(this.width<=0||this.height<=0)return!1;var i=this.x;if(i<=t&&t<=i+this.width){var s=this.y;if(s<=e&&e<=s+this.height)return!0}return!1}},X.RoundedRectangle.prototype.constructor=X.RoundedRectangle,PIXI.RoundedRectangle=X.RoundedRectangle,X.Camera=function(t,e,i,s,n,r){this.game=t,this.world=t.world,this.id=0,this.view=new X.Rectangle(i,s,n,r),this.bounds=new X.Rectangle(i,s,n,r),this.deadzone=null,this.visible=!0,this.roundPx=!0,this.atLimit={x:!1,y:!1},this.target=null,this.displayObject=null,this.scale=null,this.totalInView=0,this.lerp=new X.Point(1,1),this.onShakeComplete=new X.Signal,this.onFlashComplete=new X.Signal,this.onFadeComplete=new X.Signal,this.fx=null,this._targetPosition=new X.Point,this._edge=0,this._position=new X.Point,this._shake={intensity:0,duration:0,horizontal:!1,vertical:!1,shakeBounds:!0,x:0,y:0},this._fxDuration=0,this._fxType=0,this._fixedView=new X.Rectangle},X.Camera.FOLLOW_LOCKON=0,X.Camera.FOLLOW_PLATFORMER=1,X.Camera.FOLLOW_TOPDOWN=2,X.Camera.FOLLOW_TOPDOWN_TIGHT=3,X.Camera.SHAKE_BOTH=4,X.Camera.SHAKE_HORIZONTAL=5,X.Camera.SHAKE_VERTICAL=6,X.Camera.ENABLE_FX=!0,X.Camera.FLASH=0,X.Camera.FADE_OUT=1,X.Camera.FADE_IN=2,X.Camera.prototype={boot:function(){this.displayObject=this.game.world,this.scale=this.game.world.scale,this.game.camera=this,X.Graphics&&X.Camera.ENABLE_FX&&(this.fx=new X.Graphics(this.game),this.game.stage.addChild(this.fx))},preUpdate:function(){this.totalInView=0},follow:function(t,e,i,s){var n;switch(void 0===e&&(e=X.Camera.FOLLOW_LOCKON),void 0===i&&(i=1),void 0===s&&(s=1),this.target=t,this.lerp.set(i,s),e){case X.Camera.FOLLOW_PLATFORMER:var r=this.width/8,o=this.height/3;this.deadzone=new X.Rectangle((this.width-r)/2,(this.height-o)/2-.25*o,r,o);break;case X.Camera.FOLLOW_TOPDOWN:n=Math.max(this.width,this.height)/4,this.deadzone=new X.Rectangle((this.width-n)/2,(this.height-n)/2,n,n);break;case X.Camera.FOLLOW_TOPDOWN_TIGHT:n=Math.max(this.width,this.height)/8,this.deadzone=new X.Rectangle((this.width-n)/2,(this.height-n)/2,n,n);break;case X.Camera.FOLLOW_LOCKON:default:this.deadzone=null}},unfollow:function(){this.target=null},focusOn:function(t){this.setPosition(Math.round(t.x-this.view.halfWidth),Math.round(t.y-this.view.halfHeight))},focusOnXY:function(t,e){this.setPosition(Math.round(t-this.view.halfWidth),Math.round(e-this.view.halfHeight))},shake:function(t,e,i,s,n){return void 0===t&&(t=.05),void 0===e&&(e=500),void 0===i&&(i=!0),void 0===s&&(s=X.Camera.SHAKE_BOTH),void 0===n&&(n=!0),!(!i&&0<this._shake.duration)&&(this._shake.intensity=t,this._shake.duration=e,this._shake.shakeBounds=n,this._shake.x=0,this._shake.y=0,this._shake.horizontal=s===X.Camera.SHAKE_BOTH||s===X.Camera.SHAKE_HORIZONTAL,this._shake.vertical=s===X.Camera.SHAKE_BOTH||s===X.Camera.SHAKE_VERTICAL,!0)},flash:function(t,e,i,s){return void 0===t&&(t=16777215),void 0===e&&(e=500),void 0===i&&(i=!1),void 0===s&&(s=1),!(!this.fx||!i&&0<this._fxDuration)&&(this.fx.clear(),this.fx.beginFill(t,s),this.fx.drawRect(0,0,this.width,this.height),this.fx.endFill(),this.fx.alpha=1,this._fxDuration=e,!(this._fxType=0))},fade:function(t,e,i,s){return this.fadeEffect(t,e,i,s,X.Camera.FADE_OUT)},fadeIn:function(t,e,i,s){return this.fadeEffect(t,e,i,s,X.Camera.FADE_IN)},fadeEffect:function(t,e,i,s,n){if(void 0===t&&(t=0),void 0===e&&(e=500),void 0===i&&(i=!1),void 0===s&&(s=1),!this.fx||!i&&0<this._fxDuration)return!1;if(this.fx.clear(),this.fx.beginFill(t,s),this.fx.drawRect(0,0,this.width,this.height),this.fx.endFill(),n<1||2<n)throw new Error("Wrong `type` argument");return this.fx.alpha=n===X.Camera.FADE_IN?1:0,this._fxDuration=e,this._fxType=n,!0},update:function(){0<this._fxDuration&&this.updateFX(),0<this._shake.duration&&this.updateShake(),this.bounds&&this.checkBounds(),this.roundPx&&(this.view.floor(),this._shake.x=Math.floor(this._shake.x),this._shake.y=Math.floor(this._shake.y)),this.displayObject.position.x=-this.view.x,this.displayObject.position.y=-this.view.y},updateFX:function(){this._fxType===X.Camera.FLASH?(this.fx.alpha-=this.game.time.delta/this._fxDuration,this.fx.alpha<=0&&(this._fxDuration=0,this.fx.alpha=0,this.onFlashComplete.dispatch())):this._fxType===X.Camera.FADE_IN?(this.fx.alpha-=this.game.time.delta/this._fxDuration,this.fx.alpha<=0&&(this._fxDuration=0,this.fx.alpha=0,this.onFadeComplete.dispatch())):(this.fx.alpha+=this.game.time.delta/this._fxDuration,1<=this.fx.alpha&&(this._fxDuration=0,this.fx.alpha=1,this.onFadeComplete.dispatch()))},updateShake:function(){this._shake.duration-=this.game.time.delta,this._shake.duration<=0?(this.onShakeComplete.dispatch(),this._shake.x=0,this._shake.y=0):(this._shake.horizontal&&(this._shake.x=this.game.rnd.frac()*this._shake.intensity*this.view.width*2-this._shake.intensity*this.view.width),this._shake.vertical&&(this._shake.y=this.game.rnd.frac()*this._shake.intensity*this.view.height*2-this._shake.intensity*this.view.height))},updateTarget:function(){this._targetPosition.x=this.view.x+this.target.worldPosition.x,this._targetPosition.y=this.view.y+this.target.worldPosition.y,this.deadzone?(this._edge=this._targetPosition.x-this.view.x,this._edge<this.deadzone.left?this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.deadzone.left,this.lerp.x):this._edge>this.deadzone.right&&(this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.deadzone.right,this.lerp.x)),this._edge=this._targetPosition.y-this.view.y,this._edge<this.deadzone.top?this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.deadzone.top,this.lerp.y):this._edge>this.deadzone.bottom&&(this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.deadzone.bottom,this.lerp.y))):(this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.view.halfWidth,this.lerp.x),this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.view.halfHeight,this.lerp.y)),this.bounds&&this.checkBounds(),this.roundPx&&this.view.floor(),this.displayObject.position.x=-this.view.x,this.displayObject.position.y=-this.view.y},setBoundsToWorld:function(){this.bounds&&this.bounds.copyFrom(this.game.world.bounds)},checkBounds:function(){this.atLimit.x=!1,this.atLimit.y=!1;var t=this.view.x+this._shake.x,e=this.view.right+this._shake.x,i=this.view.y+this._shake.y,s=this.view.bottom+this._shake.y;t<=this.bounds.x*this.scale.x?(this.atLimit.x=!0,this.view.x=this.bounds.x*this.scale.x,this._shake.shakeBounds||(this._shake.x=0)):e>=this.bounds.right*this.scale.x&&(this.atLimit.x=!0,this.view.x=this.bounds.right*this.scale.x-this.width,this._shake.shakeBounds||(this._shake.x=0)),i<=this.bounds.top*this.scale.y?(this.atLimit.y=!0,this.view.y=this.bounds.top*this.scale.y,this._shake.shakeBounds||(this._shake.y=0)):s>=this.bounds.bottom*this.scale.y&&(this.atLimit.y=!0,this.view.y=this.bounds.bottom*this.scale.y-this.height,this._shake.shakeBounds||(this._shake.y=0))},setPosition:function(t,e){this.view.x=t,this.view.y=e,this.bounds&&this.checkBounds()},setSize:function(t,e){this.view.width=t,this.view.height=e},reset:function(){this.target=null,this.view.x=0,this.view.y=0,this._shake.duration=0,this._shake.x=0,this._shake.y=0,this.resetFX()},resetFX:function(){this.fx&&(this.fx.clear(),this.fx.alpha=0),this._fxDuration=0}},X.Camera.prototype.constructor=X.Camera,Object.defineProperty(X.Camera.prototype,"x",{get:function(){return this.view.x},set:function(t){this.view.x=t,this.bounds&&this.checkBounds()}}),Object.defineProperty(X.Camera.prototype,"y",{get:function(){return this.view.y},set:function(t){this.view.y=t,this.bounds&&this.checkBounds()}}),Object.defineProperty(X.Camera.prototype,"position",{get:function(){return this._position.set(this.view.x,this.view.y),this._position},set:function(t){void 0!==t.x&&(this.view.x=t.x),void 0!==t.y&&(this.view.y=t.y),this.bounds&&this.checkBounds()}}),Object.defineProperty(X.Camera.prototype,"width",{get:function(){return this.view.width},set:function(t){this.view.width=t}}),Object.defineProperty(X.Camera.prototype,"height",{get:function(){return this.view.height},set:function(t){this.view.height=t}}),Object.defineProperty(X.Camera.prototype,"shakeIntensity",{get:function(){return this._shake.intensity},set:function(t){this._shake.intensity=t}}),Object.defineProperty(X.Camera.prototype,"fixedView",{get:function(){return this._fixedView.setTo(0,0,this.view.width,this.view.height),this._fixedView}}),Object.defineProperty(X.Camera.prototype,"centerX",{get:function(){return this.x+.5*this.width}}),Object.defineProperty(X.Camera.prototype,"centerY",{get:function(){return this.y+.5*this.height}}),X.State=function(){this.game=null,this.key="",this.add=null,this.make=null,this.camera=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.sound=null,this.scale=null,this.stage=null,this.state=null,this.time=null,this.tweens=null,this.world=null,this.particles=null,this.physics=null,this.rnd=null},X.State.prototype={init:function(){},preload:function(){},loadUpdate:function(){},loadRender:function(){},create:function(){},update:function(){},postUpdate:function(){},preRender:function(){},render:function(){},resize:function(){},paused:function(){},resumed:function(){},pauseUpdate:function(){},shutdown:function(){}},X.State.prototype.constructor=X.State,X.StateManager=function(t,e){this.game=t,this.states={},(this._pendingState=null)!=e&&(this._pendingState=e),this._clearWorld=!1,this._clearCache=!1,this._created=!1,this._args=[],this.current="",this.onStateChange=new X.Signal,this.onInitCallback=null,this.onPreloadCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPreRenderCallback=null,this.onLoadUpdateCallback=null,this.onLoadRenderCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null,this.onShutDownCallback=null},X.StateManager.prototype={boot:function(){this.game.onPause.add(this.pause,this),this.game.onResume.add(this.resume,this),null!==this._pendingState&&"string"!=typeof this._pendingState&&this.add("default",this._pendingState,!0)},add:function(t,e,i){var s;return void 0===i&&(i=!1),e instanceof X.State?s=e:"object"==typeof e?(s=e).game=this.game:"function"==typeof e&&(s=new e(this.game)),this.states[t]=s,i&&(this.game.isBooted?this.start(t):this._pendingState=t),s},remove:function(t){this.current===t&&(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.onPreRenderCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null),delete this.states[t]},start:function(t,e,i){void 0===e&&(e=!0),void 0===i&&(i=!1),this.checkState(t)&&(this._pendingState=t,this._clearWorld=e,this._clearCache=i,3<arguments.length&&(this._args=Array.prototype.splice.call(arguments,3)))},restart:function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!1),this._pendingState=this.current,this._clearWorld=t,this._clearCache=e,2<arguments.length&&(this._args=Array.prototype.slice.call(arguments,2))},dummy:function(){},preUpdate:function(){if(this._pendingState&&this.game.isBooted){if(this.clearCurrentState(),this.setCurrentState(this._pendingState),this.current!==this._pendingState)return;this._pendingState=null,this.onPreloadCallback?(this.game.load.reset(!0),this.onPreloadCallback.call(this.callbackContext,this.game),0===this.game.load.totalQueuedFiles()&&0===this.game.load.totalQueuedPacks()?this.loadComplete():this.game.load.start()):this.loadComplete()}},clearCurrentState:function(){this.current&&(this.onShutDownCallback&&this.onShutDownCallback.call(this.callbackContext,this.game),this.game.tweens.removeAll(),this.game.camera.reset(),this.game.input.reset(!0),this.game.physics.clear(),this.game.time.removeAll(),this.game.scale.reset(this._clearWorld),this.game.debug&&this.game.debug.reset(),this._clearWorld&&(this.game.world.shutdown(),this._clearCache&&this.game.cache.destroy()))},checkState:function(t){var e=this.states[t];return e?!!(e.preload||e.create||e.update||e.render)||(console.warn("Invalid Phaser State object given. Must contain at least one of the required functions: preload, create, update or render"),!1):(console.warn("Phaser.StateManager - No state found with the key: "+t),!1)},link:function(t){var e=this.states[t];e.game=this.game,e.add=this.game.add,e.make=this.game.make,e.camera=this.game.camera,e.cache=this.game.cache,e.input=this.game.input,e.load=this.game.load,e.math=this.game.math,e.sound=this.game.sound,e.scale=this.game.scale,e.state=this,e.stage=this.game.stage,e.time=this.game.time,e.tweens=this.game.tweens,e.world=this.game.world,e.particles=this.game.particles,e.rnd=this.game.rnd,e.physics=this.game.physics,e.key=t},unlink:function(t){var e=this.states[t];e&&(e.game=null,e.add=null,e.make=null,e.camera=null,e.cache=null,e.input=null,e.load=null,e.math=null,e.sound=null,e.scale=null,e.state=null,e.stage=null,e.time=null,e.tweens=null,e.world=null,e.particles=null,e.rnd=null,e.physics=null)},setCurrentState:function(t){var e=this.current,i=this.states[t];this.callbackContext=i,this.link(t),this.onInitCallback=i.init||this.dummy,this.onPreloadCallback=i.preload||null,this.onLoadRenderCallback=i.loadRender||null,this.onLoadUpdateCallback=i.loadUpdate||null,this.onCreateCallback=i.create||null,this.onUpdateCallback=i.update||null,this.onPostUpdateCallback=i.postUpdate||null,this.onPreRenderCallback=i.preRender||null,this.onRenderCallback=i.render||null,this.onResizeCallback=i.resize||null,this.onPausedCallback=i.paused||null,this.onResumedCallback=i.resumed||null,this.onPauseUpdateCallback=i.pauseUpdate||null,this.onShutDownCallback=i.shutdown||this.dummy,""!==this.current&&this.game.physics.reset(),this.current=t,this._created=!1,this.onStateChange.dispatch(this.curren