/* 2016 Photon Storm Ltd. @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} 2016 Photon Storm Ltd. @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} @overview Phaser - http://phaser.io v2.11.0 "2018-06-26" - Built: Tue Jun 26 2018 10:56:52 By Richard Davey http://www.photonstorm.com @photonstorm Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering. Phaser uses Pixi.js for rendering, created by Mat Groves http://matgroves.com @Doormat23 Phaser uses p2.js for full-body physics, created by Stefan Hedman https://github.com/schteppe/p2.js @schteppe Phaser contains a port of N+ Physics, converted by Richard Davey, original by http://www.metanetsoftware.com Many thanks to Adam Saltsman (@ADAMATOMIC) for releasing Flixel, from which both Phaser and my love of framework development originate. Follow development at http://phaser.io and on our forum "If you want your children to be intelligent, read them fairy tales." "If you want them to be more intelligent, read them more fairy tales." -- Albert Einstein {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} 2016 Photon Storm Ltd, Richard Davey @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} ? 2012 Timo Hausmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 'use strict';var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(c,h,u){c!=Array.prototype&&c!=Object.prototype&&(c[h]=u.value)};$jscomp.getGlobal=function(c){return"undefined"!=typeof window&&window===c?c:"undefined"!=typeof global&&null!=global?global:c};$jscomp.global=$jscomp.getGlobal(this); $jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.Symbol=function(){var c=0;return function(h){return $jscomp.SYMBOL_PREFIX+(h||"")+c++}}(); $jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var c=$jscomp.global.Symbol.iterator;c||(c=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[c]&&$jscomp.defineProperty(Array.prototype,c,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(c){var h=0;return $jscomp.iteratorPrototype(function(){return hu&&(u=Math.max(0,a+u));if(null==l||l>a)l=a;l=Number(l);0>l&&(l=Math.max(0,a+l));for(u=Number(u||0);uc||1342177279>>=1)h+=h;return l}},"es6","es3"); !function(c){if("object"==typeof exports)module.exports=c();else{var h;"undefined"!=typeof window?h=window:"undefined"!=typeof global?h=global:"undefined"!=typeof self&&(h=self);h.p2=c()}}(function(){return function a(h,u,l){function b(e,g){if(!u[e]){if(!h[e]){var f="function"==typeof require&&require;if(!g&&f)return f(e,!0);if(d)return d(e,!0);throw Error("Cannot find module '"+e+"'");}g=u[e]={exports:{}};h[e][0].call(g.exports,function(a){var d=h[e][1][a];return b(d?d:a)},g,g.exports,a,h,u,l)}return u[e].exports} for(var d="function"==typeof require&&require,e=0;e=g&&0<=a&&1>=a}},{"./Scalar":4}],2:[function(h,u,l){function a(){}u.exports=a;a.area=function(a,b,d){return(b[0]-a[0])*(d[1]-a[1])-(d[0]-a[0])*(b[1]-a[1])};a.left=function(b,d,g){return 0a.area(b,d,g)};a.rightOn=function(b,d,g){return 0>=a.area(b,d,g)};var b=[],d=[];a.collinear=function(e,f, g,k){return k?(b[0]=f[0]-e[0],b[1]=f[1]-e[1],d[0]=g[0]-f[0],d[1]=g[1]-f[1],Math.acos((b[0]*d[0]+b[1]*d[1])/(Math.sqrt(b[0]*b[0]+b[1]*b[1])*Math.sqrt(d[0]*d[0]+d[1]*d[1])))a?a%d+d:a%d]};a.prototype.first=function(){return this.vertices[0]};a.prototype.last=function(){return this.vertices[this.vertices.length-1]};a.prototype.clear=function(){this.vertices.length=0};a.prototype.append=function(a,b,d){if("undefined"==typeof b)throw Error("From is not given!");if("undefined"==typeof d)throw Error("To is not given!");if(d-1a.vertices.length)throw Error("lol2"); if(0>b)throw Error("lol3");for(;bb[a][0])a=d;e.left(this.at(a-1),this.at(a),this.at(a+1))||this.reverse()};a.prototype.reverse=function(){for(var a=[],b=0,d=this.vertices.length;b!==d;b++)a.push(this.vertices.pop());this.vertices=a};a.prototype.isReflex=function(a){return e.right(this.at(a-1),this.at(a),this.at(a+1))};var g= [],k=[];a.prototype.canSee=function(a,b){if(e.leftOn(this.at(a+1),this.at(a),this.at(b))&&e.rightOn(this.at(a-1),this.at(a),this.at(b)))return!1;var f=e.sqdist(this.at(a),this.at(b));for(var m=0;m!==this.vertices.length;++m)if((m+1)%this.vertices.length!==a&&m!==a&&e.leftOn(this.at(a),this.at(b),this.at(m+1))&&e.rightOn(this.at(a),this.at(b),this.at(m))){g[0]=this.at(a);g[1]=this.at(b);k[0]=this.at(m);k[1]=this.at(m+1);var l=d.lineInt(g,k);if(e.sqdist(this.at(a),l)F.length)return d;h++;if(h>l)return console.warn("quickDecomp: max level ("+l+") reached."),d;for(var D=0;Dt&&(t+=this.vertices.length);m=Number.MAX_VALUE;if(t (http://steffe.se)",keywords:["p2.js","p2","physics","engine","2d"],main:"./src/p2.js",engines:{node:"*"},repository:{type:"git",url:"https://github.com/schteppe/p2.js.git"},bugs:{url:"https://github.com/schteppe/p2.js/issues"}, licenses:[{type:"MIT"}],devDependencies:{grunt:"^0.4.5","grunt-contrib-jshint":"^0.11.2","grunt-contrib-nodeunit":"^0.4.1","grunt-contrib-uglify":"~0.4.0","grunt-contrib-watch":"~0.5.0","grunt-browserify":"~2.0.1","grunt-contrib-concat":"^0.4.0"},dependencies:{"poly-decomp":"0.1.1"}}},{}],7:[function(h,u,l){function a(a){this.lowerBound=b.create();a&&a.lowerBound&&b.copy(this.lowerBound,a.lowerBound);this.upperBound=b.create();a&&a.upperBound&&b.copy(this.upperBound,a.upperBound)}var b=h("../math/vec2"); h("../utils/Utils");u.exports=a;var d=b.create();a.prototype.setFromPoints=function(a,f,g,k){var e=this.lowerBound,l=this.upperBound;"number"!==typeof g&&(g=0);0!==g?b.rotate(e,a[0],g):b.copy(e,a[0]);b.copy(l,e);for(var n=Math.cos(g),h=Math.sin(g),t=1;tv;v++)r[v]>l[v]&&(l[v]=r[v]),r[v]d&&(this.lowerBound[b]=d);d=a.upperBound[b];this.upperBound[b]e||a>e?-1:a}},{"../math/vec2":30,"../utils/Utils":57}],8:[function(h,u,l){function a(b){this.type=b;this.result=[];this.world=null;this.boundingVolumeType=a.AABB}var b=h("../math/vec2"),d=h("../objects/Body");u.exports=a;a.AABB=1;a.BOUNDING_CIRCLE=2;a.prototype.setWorld=function(a){this.world=a};a.prototype.getCollisionPairs=function(a){};var e=b.create();a.boundingRadiusCheck=function(a,d){b.sub(e,a.position,d.position);var f=b.squaredLength(e);a=a.boundingRadius+d.boundingRadius;return f<= a*a};a.aabbCheck=function(a,b){return a.getAABB().overlaps(b.getAABB())};a.prototype.boundingVolumeCheck=function(b,d){switch(this.boundingVolumeType){case a.BOUNDING_CIRCLE:b=a.boundingRadiusCheck(b,d);break;case a.AABB:b=a.aabbCheck(b,d);break;default:throw Error("Bounding volume type not recognized: "+this.boundingVolumeType);}return b};a.canCollide=function(a,b){var e=d.KINEMATIC,f=d.STATIC;return a.type===f&&b.type===f||a.type===e&&b.type===f||a.type===f&&b.type===e||a.type===e&&b.type===e|| a.sleepState===d.SLEEPING&&b.sleepState===d.SLEEPING||a.sleepState===d.SLEEPING&&b.type===f||b.sleepState===d.SLEEPING&&a.type===f?!1:!0};a.NAIVE=1;a.SAP=2},{"../math/vec2":30,"../objects/Body":31}],9:[function(h,u,l){function a(){b.call(this,b.NAIVE)}h("../shapes/Circle");h("../shapes/Plane");h("../shapes/Shape");h("../shapes/Particle");var b=h("../collision/Broadphase");h("../math/vec2");u.exports=a;a.prototype=new b;a.prototype.constructor=a;a.prototype.getCollisionPairs=function(a){a=a.bodies; for(var d=this.result,f=d.length=0,g=a.length;f!==g;f++)for(var k=a[f],l=0;l=t*h)return!1;h=t}return!0}var e=h("../math/vec2"),f=e.sub,g=e.add,k=e.dot;h("../utils/Utils"); var m=h("../utils/ContactEquationPool"),p=h("../utils/FrictionEquationPool"),n=h("../utils/TupleDictionary"),q=h("../equations/Equation");h("../equations/ContactEquation");h("../equations/FrictionEquation");l=h("../shapes/Circle");var t=h("../shapes/Convex"),r=h("../shapes/Shape");h("../objects/Body");var v=h("../shapes/Box");u.exports=a;var x=e.fromValues(0,1),w=e.fromValues(0,0),y=e.fromValues(0,0),A=e.fromValues(0,0),z=e.fromValues(0,0),C=e.fromValues(0,0),B=e.fromValues(0,0),E=e.fromValues(0, 0),F=e.fromValues(0,0),D=e.fromValues(0,0),H=e.fromValues(0,0),G=e.fromValues(0,0),J=e.fromValues(0,0),L=e.fromValues(0,0),K=e.fromValues(0,0),R=e.fromValues(0,0),U=e.fromValues(0,0),ba=e.fromValues(0,0),X=e.fromValues(0,0),I=[],Y=e.create(),ra=e.create();a.prototype.bodiesOverlap=function(a,b){for(var d=0,e=a.shapes.length;d!==e;d++){var f=a.shapes[d];a.toWorldFrame(Y,f.position);for(var g=0,k=b.shapes.length;g!==k;g++){var l=b.shapes[g];b.toWorldFrame(ra,l.position);if(this[f.type|l.type](a,f,Y, f.angle+a.angle,b,l,ra,l.angle+b.angle,!0))return!0}}return!1};a.prototype.collidedLastStep=function(a,b){return!!this.collidingBodiesLastStep.get(a.id|0,b.id|0)};a.prototype.reset=function(){this.collidingBodiesLastStep.reset();for(var a=this.contactEquations,b=a.length;b--;){var d=a[b];this.collidingBodiesLastStep.set(d.bodyA.id,d.bodyB.id,!0)}a=this.contactEquations;b=this.frictionEquations;for(d=0;dt;t++){e.set(ca,(0===t?-1:1)*d.length/2,0);e.rotate(ca,ca,g);e.add(ca,ca,f);for(var r=0;2>r;r++){e.set(da,(0===r?-1:1)*l.length/2,0);e.rotate(da,da,p);e.add(da,da,m);this.enableFrictionReduction&&(h=this.enableFriction,this.enableFriction=!1);var v=this.circleCircle(a, d,ca,g,k,l,da,p,n,d.radius,l.radius);this.enableFrictionReduction&&(this.enableFriction=h);if(n&&v)return!0;q+=v}}this.enableFrictionReduction&&(h=this.enableFriction,this.enableFriction=!1);b(la,d);t=this.convexCapsule(a,la,f,g,k,l,m,p,n);this.enableFrictionReduction&&(this.enableFriction=h);if(n&&t)return!0;q+=t;this.enableFrictionReduction&&(h=this.enableFriction,this.enableFriction=!1);b(la,l);a=this.convexCapsule(k,la,m,p,a,d,f,g,n);this.enableFrictionReduction&&(this.enableFriction=h);if(n&& a)return!0;q+=a;this.enableFrictionReduction&&q&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(q));return q};a.prototype[r.LINE|r.LINE]=a.prototype.lineLine=function(a,b,d,e,f,g,k,l,m){return m?!1:0};a.prototype[r.PLANE|r.LINE]=a.prototype.planeLine=function(a,b,d,l,m,p,n,h,q){var t=0;e.set(w,-p.length/2,0);e.set(y,p.length/2,0);e.rotate(A,w,h);e.rotate(z,y,h);g(A,A,n);g(z,z,n);e.copy(w,A);e.copy(y,z);f(C,y,w);e.normalize(B,C);e.rotate90cw(D,B);e.rotate(F,x,l);I[0]= w;I[1]=y;for(l=0;lr){if(q)return!0;var v=this.createContactEquation(a,m,b,p);t++;e.copy(v.normalA,F);e.normalize(v.normalA,v.normalA);e.scale(E,F,r);f(v.contactPointA,h,E);f(v.contactPointA,v.contactPointA,a.position);f(v.contactPointB,h,n);g(v.contactPointB,v.contactPointB,n);f(v.contactPointB,v.contactPointB,m.position);this.contactEquations.push(v);this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(v))}}if(q)return!1; this.enableFrictionReduction||t&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(t));return t};a.prototype[r.PARTICLE|r.CAPSULE]=a.prototype.particleCapsule=function(a,b,d,e,f,g,k,l,m){return this.circleLine(a,b,d,e,f,g,k,l,m,g.radius,0)};a.prototype[r.CIRCLE|r.LINE]=a.prototype.circleLine=function(a,b,d,l,m,p,n,h,q,t,r){t=t||0;r="undefined"!==typeof r?r:b.radius;e.set(F,-p.length/2,0);e.set(D,p.length/2,0);e.rotate(H,F,h);e.rotate(G,D,h);g(H,H,n);g(G,G,n);e.copy(F, H);e.copy(D,G);f(B,D,F);e.normalize(E,B);e.rotate90cw(C,E);f(J,d,F);h=k(J,C);f(z,F,n);f(L,d,n);l=r+t;if(Math.abs(h)v&&hMath.pow(k,2))return 0;if(h)return!0;b=this.createContactEquation(a,l,b,m);f(b.normalA,p,d);e.normalize(b.normalA,b.normalA);e.scale(b.contactPointA,b.normalA,q);e.scale(b.contactPointB,b.normalA,-t);g(b.contactPointA,b.contactPointA,d);f(b.contactPointA,b.contactPointA,a.position);g(b.contactPointB,b.contactPointB,p);f(b.contactPointB,b.contactPointB,l.position);this.contactEquations.push(b);this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(b)); return 1};a.prototype[r.PLANE|r.CONVEX]=a.prototype[r.PLANE|r.BOX]=a.prototype.planeConvex=function(a,b,d,l,m,p,n,h,q){var t=0;e.rotate(y,x,l);for(l=0;l!==p.vertices.length;l++)if(e.rotate(w,p.vertices[l],h),g(w,w,n),f(A,w,d),0>=k(A,y)){if(q)return!0;t++;var r=this.createContactEquation(a,m,b,p);f(A,w,d);e.copy(r.normalA,y);var v=k(A,r.normalA);e.scale(A,r.normalA,v);f(r.contactPointB,w,m.position);f(r.contactPointA,w,A);f(r.contactPointA,r.contactPointA,a.position);this.contactEquations.push(r); this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(r))}this.enableFrictionReduction&&this.enableFriction&&t&&this.frictionEquations.push(this.createFrictionFromAverage(t));return t};a.prototype[r.PARTICLE|r.PLANE]=a.prototype.particlePlane=function(a,b,d,g,l,m,p,n,h){n=n||0;f(w,d,p);e.rotate(y,x,n);g=k(w,y);if(0Math.pow(b.radius,2))return 0;if(h)return!0;k=this.createContactEquation(a,l,b,m);e.copy(k.normalA,w);e.normalize(k.normalA,k.normalA);e.scale(k.contactPointA,k.normalA,b.radius);g(k.contactPointA, k.contactPointA,d);f(k.contactPointA,k.contactPointA,a.position);f(k.contactPointB,p,l.position);this.contactEquations.push(k);this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(k));return 1};var qa=new l({radius:1}),ea=e.create(),fa=e.create();e.create();a.prototype[r.PLANE|r.CAPSULE]=a.prototype.planeCapsule=function(a,b,d,f,k,l,m,p,n){e.set(ea,-l.length/2,0);e.rotate(ea,ea,p);g(ea,ea,m);e.set(fa,l.length/2,0);e.rotate(fa,fa,p);g(fa,fa,m);qa.radius=l.radius;if(this.enableFrictionReduction){var h= this.enableFriction;this.enableFriction=!1}l=this.circlePlane(k,qa,ea,0,a,b,d,f,n);a=this.circlePlane(k,qa,fa,0,a,b,d,f,n);this.enableFrictionReduction&&(this.enableFriction=h);if(n)return l||a;n=l+a;this.enableFrictionReduction&&n&&this.frictionEquations.push(this.createFrictionFromAverage(n));return n};a.prototype[r.CIRCLE|r.PLANE]=a.prototype.circlePlane=function(a,b,d,l,m,p,n,h,q){l=h||0;f(w,d,n);e.rotate(y,x,l);l=k(y,w);if(l>b.radius)return 0;if(q)return!0;p=this.createContactEquation(m,a,p, b);e.copy(p.normalA,y);e.scale(p.contactPointB,p.normalA,-b.radius);g(p.contactPointB,p.contactPointB,d);f(p.contactPointB,p.contactPointB,a.position);e.scale(A,p.normalA,l);f(p.contactPointA,w,A);g(p.contactPointA,p.contactPointA,n);f(p.contactPointA,p.contactPointA,m.position);this.contactEquations.push(p);this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(p));return 1};a.prototype[r.CONVEX]=a.prototype[r.CONVEX|r.BOX]=a.prototype[r.BOX]=a.prototype.convexConvex=function(b, d,l,m,p,n,h,q,t,r){var v=0;r="number"===typeof r?r:0;if(!a.findSeparatingAxis(d,l,m,n,h,q,w))return 0;f(F,h,l);0G;G++){var u=x,J=L,K=d,M=n,B=l,U=h,R=m,ba=q,Y=b,X=p;if(0===G){var N=u;u=J;J=N;N=K;K=M;M=N;N=B;B=U;U=N;N=R;R=ba;ba=N;N=Y;Y=X;X=N}for(N=J;N=T)&&I++}if(3<=I){if(t)return!0;I=this.createContactEquation(Y,X,K,M);v++;T=K.vertices[u%K.vertices.length];pa=K.vertices[(u+1)%K.vertices.length];e.rotate(A,T,R);e.rotate(z,pa,R);g(A,A,B);g(z,z,B);f(C,z,A);e.rotate90cw(I.normalA,C);e.normalize(I.normalA,I.normalA);f(F, y,A);T=k(I.normalA,F);e.scale(E,I.normalA,T);f(I.contactPointA,y,B);f(I.contactPointA,I.contactPointA,E);g(I.contactPointA,I.contactPointA,B);f(I.contactPointA,I.contactPointA,Y.position);f(I.contactPointB,y,U);g(I.contactPointB,I.contactPointB,U);f(I.contactPointB,I.contactPointB,X.position);this.contactEquations.push(I);this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(I))}}}this.enableFrictionReduction&&this.enableFriction&&v&&this.frictionEquations.push(this.createFrictionFromAverage(v)); return v};var ja=e.fromValues(0,0);a.projectConvexOntoAxis=function(a,b,d,f,g){var l=null,m=null;e.rotate(ja,f,-d);for(d=0;dl)l=p;if(null===m||pl&&(a=m,m=l,l=a);b=k(b,f);e.set(g,m+b,l+b)};var ta=e.fromValues(0,0),ua=e.fromValues(0,0),va=e.fromValues(0,0),O=e.fromValues(0,0),V=e.fromValues(0,0),W=e.fromValues(0,0);a.findSeparatingAxis=function(b,d,g,k,l,m,p){var n=null,h=!1;if(b instanceof v&&k instanceof v)for(var q=0;2!== q;q++){var t=g;1===q&&(t=m);for(var r=0;2!==r;r++){0===r?e.set(O,0,1):1===r&&e.set(O,1,0);0!==t&&e.rotate(O,O,t);a.projectConvexOntoAxis(b,d,g,O,V);a.projectConvexOntoAxis(k,l,m,O,W);var x=V;var w=W;V[0]>W[0]&&(w=V,x=W);w=w[0]-x[1];x=0>=w;if(null===n||w>n)e.copy(p,O),n=w,h=x}}else for(q=0;2!==q;q++){var L=b;t=g;1===q&&(L=k,t=m);for(r=0;r!==L.vertices.length;r++)if(e.rotate(ua,L.vertices[r],t),e.rotate(va,L.vertices[(r+1)%L.vertices.length],t),f(ta,va,ua),e.rotate90cw(O,ta),e.normalize(O,O),a.projectConvexOntoAxis(b, d,g,O,V),a.projectConvexOntoAxis(k,l,m,O,W),x=V,w=W,V[0]>W[0]&&(w=V,x=W),w=w[0]-x[1],x=0>=w,null===n||w>n)e.copy(p,O),n=w,h=x}return h};var ma=e.fromValues(0,0),wa=e.fromValues(0,0),na=e.fromValues(0,0);a.getClosestEdge=function(a,b,d,g){e.rotate(ma,d,-b);g&&e.scale(ma,ma,-1);b=-1;d=a.vertices.length;g=-1;for(var l=0;l!==d;l++){f(wa,a.vertices[(l+1)%d],a.vertices[l%d]);e.rotate90cw(na,wa);e.normalize(na,na);var m=k(na,ma);if(-1===b||m>g)b=l%d,g=m}return b};var Z=e.create(),aa=e.create(),P=e.create(), ka=e.create(),xa=e.create(),S=e.create(),ya=e.create();a.prototype[r.CIRCLE|r.HEIGHTFIELD]=a.prototype.circleHeightfield=function(a,b,d,k,l,m,p,n,h,q){k=m.heights;q=q||b.radius;n=m.elementWidth;var t=Math.floor((d[0]-q-p[0])/n),r=Math.ceil((d[0]+q-p[0])/n);0>t&&(t=0);r>=k.length&&(r=k.length-1);for(var v=k[t],x=k[r],w=t;wv&&(v=k[w]);if(d[1]-q>v)return h?!1:0;for(w=t;w=P[0]&&Z[0]=v){if(h)return!0;e.scale(aa,S,-v);e.add(xa,Z,aa);e.copy(ya,S);x=this.createContactEquation(l,a,m,b);e.copy(x.normalA,ya);e.scale(x.contactPointB,x.normalA,-q);g(x.contactPointB,x.contactPointB,d);f(x.contactPointB,x.contactPointB,a.position);e.copy(x.contactPointA,xa);e.sub(x.contactPointA,x.contactPointA,l.position);this.contactEquations.push(x);this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(x))}v= !1;if(0n&&(n=0);h>=m.length&&(h=m.length-1);for(var q=m[n],t=m[h],r=n;rq&&(q=m[r]);if(a.aabb.lowerBound[1]>q)return p? !1:0;q=0;for(r=n;rd.boundingRadius*d.boundingRadius||(this._currentBody=n,this._currentShape=d,d.raycast(a,this,p,l),this._currentBody=this._currentShape=null)};a.prototype.getAABB=function(a){var d=this.to,e=this.from;b.set(a.lowerBound, Math.min(d[0],e[0]),Math.min(d[1],e[1]));b.set(a.upperBound,Math.max(d[0],e[0]),Math.max(d[1],e[1]))};b.create();a.prototype.reportIntersection=function(d,e,f,l){var g=this._currentShape,k=this._currentBody;if(!(this.skipBackfaces&&0this.upperLimit&&(l.maxForce=0,l.minForce=-this.maxForce,this.distance=this.upperLimit,a=!0);this.lowerLimitEnabled&&this.positionb?(f.scale(e.normalA,k,-1),f.sub(e.contactPointA,m,l.position), f.sub(e.contactPointB,p,h.position),f.scale(t,k,b),f.add(e.contactPointA,e.contactPointA,t),-1===a.indexOf(e)&&a.push(e)):(b=a.indexOf(e),-1!==b&&a.splice(b,1));this.lowerLimitEnabled&&uq?(B.angle=q,-1===f.indexOf(B)&&f.push(B)):(q=f.indexOf(B),-1!==q&&f.splice(q,1));this.lowerLimitEnabled&&Fb;b++)this.G[b]=0;this.epsilon=this.b=this.a=this.offset=0;this.timeStep=1/60;this.needsUpdate=!0;this.relativeVelocity=this.multiplier=0;this.enabled=!0}u.exports=a;var b=h("../math/vec2"),d=h("../utils/Utils");h("../objects/Body");a.prototype.constructor=a;a.DEFAULT_STIFFNESS=1E6;a.DEFAULT_RELAXATION=4;a.prototype.update=function(){var a=this.stiffness,b=this.relaxation,d=this.timeStep;this.a=4/(d*(1+4* b));this.b=4*b/(1+4*b);this.epsilon=4/(d*d*a*(1+4*b));this.needsUpdate=!1};a.prototype.gmult=function(a,b,d,e,f){return a[0]*b[0]+a[1]*b[1]+a[2]*d+a[3]*e[0]+a[4]*e[1]+a[5]*f};a.prototype.computeB=function(a,b,d){var e=this.computeGW(),f=this.computeGq(),g=this.computeGiMf();return-f*a-e*b-g*d};var e=b.create(),f=b.create();a.prototype.computeGq=function(){return this.gmult(this.G,e,this.bodyA.angle,f,this.bodyB.angle)+this.offset};a.prototype.computeGW=function(){var a=this.bodyA,b=this.bodyB;return this.gmult(this.G, a.velocity,a.angularVelocity,b.velocity,b.angularVelocity)+this.relativeVelocity};a.prototype.computeGWlambda=function(){var a=this.bodyA,b=this.bodyB;return this.gmult(this.G,a.vlambda,a.wlambda,b.vlambda,b.wlambda)};var g=b.create(),k=b.create();a.prototype.computeGiMf=function(){var a=this.bodyA,d=this.bodyB,e=a.angularForce,f=d.force,l=d.angularForce,m=d.invMassSolve,p=a.invInertiaSolve,n=d.invInertiaSolve,h=this.G;b.scale(g,a.force,a.invMassSolve);b.multiply(g,a.massMultiplier,g);b.scale(k,f, m);b.multiply(k,d.massMultiplier,k);return this.gmult(h,g,e*p,k,l*n)};a.prototype.computeGiMGt=function(){var a=this.bodyA,b=this.bodyB,d=a.invMassSolve,e=b.invMassSolve,f=this.G;return f[0]*f[0]*d*a.massMultiplier[0]+f[1]*f[1]*d*a.massMultiplier[1]+f[2]*f[2]*a.invInertiaSolve+f[3]*f[3]*e*b.massMultiplier[0]+f[4]*f[4]*e*b.massMultiplier[1]+f[5]*f[5]*b.invInertiaSolve};var m=b.create(),p=b.create(),n=b.create();b.create();b.create();b.create();a.prototype.addToWlambda=function(a){var d=this.bodyA, e=this.bodyB,f=d.invMassSolve,g=e.invMassSolve,k=d.invInertiaSolve,l=e.invInertiaSolve,h=this.G;p[0]=h[0];p[1]=h[1];n[0]=h[3];n[1]=h[4];b.scale(m,p,f*a);b.multiply(m,m,d.massMultiplier);b.add(d.vlambda,d.vlambda,m);d.wlambda+=k*h[2]*a;b.scale(m,n,g*a);b.multiply(m,m,e.massMultiplier);b.add(e.vlambda,e.vlambda,m);e.wlambda+=l*h[5]*a};a.prototype.computeInvC=function(a){return 1/(this.computeGiMGt()+a)}},{"../math/vec2":30,"../objects/Body":31,"../utils/Utils":57}],23:[function(h,u,l){function a(a, f,g){d.call(this,a,f,-g,g);this.contactPointA=b.create();this.contactPointB=b.create();this.t=b.create();this.contactEquations=[];this.shapeB=this.shapeA=null;this.frictionCoefficient=.3}var b=h("../math/vec2"),d=h("./Equation");h("../utils/Utils");u.exports=a;a.prototype=new d;a.prototype.constructor=a;a.prototype.setSlipForce=function(a){this.maxForce=a;this.minForce=-a};a.prototype.getSlipForce=function(){return this.maxForce};a.prototype.computeB=function(a,d,g){a=this.contactPointA;var e=this.contactPointB, f=this.t,l=this.G;l[0]=-f[0];l[1]=-f[1];l[2]=-b.crossLength(a,f);l[3]=f[0];l[4]=f[1];l[5]=b.crossLength(e,f);a=this.computeGW();e=this.computeGiMf();return-a*d-g*e}},{"../math/vec2":30,"../utils/Utils":57,"./Equation":22}],24:[function(h,u,l){function a(a,d,e){e=e||{};b.call(this,a,d,-Number.MAX_VALUE,Number.MAX_VALUE);this.angle=e.angle||0;a=this.G;a[2]=1;a[5]=-1}var b=h("./Equation"),d=h("../math/vec2");u.exports=a;a.prototype=new b;a.prototype.constructor=a;var e=d.create(),f=d.create(),g=d.fromValues(1, 0),k=d.fromValues(0,1);a.prototype.computeGq=function(){d.rotate(e,g,this.bodyA.angle+this.angle);d.rotate(f,k,this.bodyB.angle);return d.dot(e,f)}},{"../math/vec2":30,"./Equation":22}],25:[function(h,u,l){function a(a,e){b.call(this,a,e,-Number.MAX_VALUE,Number.MAX_VALUE);this.ratio=this.relativeVelocity=1}var b=h("./Equation");h("../math/vec2");u.exports=a;a.prototype=new b;a.prototype.constructor=a;a.prototype.computeB=function(a,b,f){a=this.G;a[2]=-1;a[5]=this.ratio;a=this.computeGiMf();return-this.computeGW()* b-f*a}},{"../math/vec2":30,"./Equation":22}],26:[function(h,u,l){h=function(){};u.exports=h;h.prototype={constructor:h,on:function(a,b,d){b.context=d||this;void 0===this._listeners&&(this._listeners={});d=this._listeners;void 0===d[a]&&(d[a]=[]);-1===d[a].indexOf(b)&&d[a].push(b);return this},has:function(a,b){if(void 0===this._listeners)return!1;var d=this._listeners;if(b){if(void 0!==d[a]&&-1!==d[a].indexOf(b))return!0}else if(void 0!==d[a])return!0;return!1},off:function(a,b){if(void 0===this._listeners)return this; var d=this._listeners;b=d[a].indexOf(b);-1!==b&&d[a].splice(b,1);return this},emit:function(a){if(void 0===this._listeners)return this;var b=this._listeners[a.type];if(void 0!==b){a.target=this;for(var d=0,e=b.length;da.length)return 0;for(var b=a.length-2,e=0,f=0;f>1;if(3>d)return[];for(var e=[],f=[],g=0;g3*d)break}e.push(f[0],f[1],f[2]);return e},_PointInTriangle:function(a, d,e,f,g,k,l,p){l-=e;p-=f;g-=e;k-=f;a-=e;e=d-f;d=l*l+p*p;f=l*g+p*k;l=l*a+p*e;p=g*g+k*k;g=g*a+k*e;k=1/(d*p-f*f);p=(p*l-f*g)*k;l=(d*g-f*l)*k;return 0<=p&&0<=l&&1>p+l},_convex:function(a,d,e,f,g,k){return 0<=(d-f)*(g-e)+(e-a)*(k-f)}};u.exports=a},{}],30:[function(h,u,l){var a=u.exports={},b=h("../utils/Utils");a.crossLength=function(a,b){return a[0]*b[1]-a[1]*b[0]};a.crossVZ=function(b,e,f){a.rotate(b,e,-Math.PI/2);a.scale(b,b,f);return b};a.crossZV=function(b,e,f){a.rotate(b,f,Math.PI/2);a.scale(b,b, e);return b};a.rotate=function(a,b,f){if(0!==f){var d=Math.cos(f);f=Math.sin(f);var e=b[0];b=b[1];a[0]=d*e-f*b;a[1]=f*e+d*b}else a[0]=b[0],a[1]=b[1]};a.rotate90cw=function(a,b){var d=b[0];a[0]=b[1];a[1]=-d};a.toLocalFrame=function(b,e,f,g){a.copy(b,e);a.sub(b,b,f);a.rotate(b,b,-g)};a.toGlobalFrame=function(b,e,f,g){a.copy(b,e);a.rotate(b,b,g);a.add(b,b,f)};a.vectorToLocalFrame=function(b,e,f){a.rotate(b,e,-f)};a.vectorToGlobalFrame=function(b,e,f){a.rotate(b,e,f)};a.centroid=function(b,e,f,g){a.add(b, e,f);a.add(b,b,g);a.scale(b,b,1/3);return b};a.create=function(){var a=new b.ARRAY_TYPE(2);a[0]=0;a[1]=0;return a};a.clone=function(a){var d=new b.ARRAY_TYPE(2);d[0]=a[0];d[1]=a[1];return d};a.fromValues=function(a,e){var d=new b.ARRAY_TYPE(2);d[0]=a;d[1]=e;return d};a.copy=function(a,b){a[0]=b[0];a[1]=b[1];return a};a.set=function(a,b,f){a[0]=b;a[1]=f;return a};a.add=function(a,b,f){a[0]=b[0]+f[0];a[1]=b[1]+f[1];return a};a.subtract=function(a,b,f){a[0]=b[0]-f[0];a[1]=b[1]-f[1];return a};a.sub=a.subtract; a.multiply=function(a,b,f){a[0]=b[0]*f[0];a[1]=b[1]*f[1];return a};a.mul=a.multiply;a.divide=function(a,b,f){a[0]=b[0]/f[0];a[1]=b[1]/f[1];return a};a.div=a.divide;a.scale=function(a,b,f){a[0]=b[0]*f;a[1]=b[1]*f;return a};a.distance=function(a,b){var d=b[0]-a[0];a=b[1]-a[1];return Math.sqrt(d*d+a*a)};a.dist=a.distance;a.squaredDistance=function(a,b){var d=b[0]-a[0];a=b[1]-a[1];return d*d+a*a};a.sqrDist=a.squaredDistance;a.length=function(a){var b=a[0];a=a[1];return Math.sqrt(b*b+a*a)};a.len=a.length; a.squaredLength=function(a){var b=a[0];a=a[1];return b*b+a*a};a.sqrLen=a.squaredLength;a.negate=function(a,b){a[0]=-b[0];a[1]=-b[1];return a};a.normalize=function(a,b){var d=b[0],e=b[1];d=d*d+e*e;0g)return!1;b[0]=e[0]+g*(f[0]-e[0]);b[1]=e[1]+g*(f[1]-e[1]);return!0};a.getLineSegmentsIntersectionFraction=function(a,b,f,g){var d=b[0]-a[0];b=b[1]-a[1];var e=g[0]-f[0],l=g[1]-f[1];g=(-b*(a[0]-f[0])+d*(a[1]-f[1]))/(-e*b+d*l);a=(e*(a[1]-f[1])-l*(a[0]-f[0]))/(-e*b+d*l);return 0<=g&&1>=g&&0<=a&&1>=a?a:-1}},{"../utils/Utils":57}],31:[function(h,u,l){function a(d){d=d||{}; k.call(this);this.id=d.id||++a._idCounter;this.world=null;this.shapes=[];this.mass=d.mass||0;this.invInertiaSolve=this.invMassSolve=this.invInertia=this.inertia=this.invMass=0;this.fixedRotation=!!d.fixedRotation;this.fixedX=!!d.fixedX;this.fixedY=!!d.fixedY;this.massMultiplier=b.create();this.position=b.fromValues(0,0);d.position&&b.copy(this.position,d.position);this.interpolatedPosition=b.fromValues(0,0);this.interpolatedAngle=0;this.previousPosition=b.fromValues(0,0);this.previousAngle=0;this.velocity= b.fromValues(0,0);d.velocity&&b.copy(this.velocity,d.velocity);this.vlambda=b.fromValues(0,0);this.wlambda=0;this.angle=d.angle||0;this.angularVelocity=d.angularVelocity||0;this.force=b.create();d.force&&b.copy(this.force,d.force);this.angularForce=d.angularForce||0;this.damping="number"===typeof d.damping?d.damping:.1;this.angularDamping="number"===typeof d.angularDamping?d.angularDamping:.1;this.type=a.STATIC;this.type="undefined"!==typeof d.type?d.type:d.mass?a.DYNAMIC:a.STATIC;this.boundingRadius= 0;this.aabb=new g;this.aabbNeedsUpdate=!0;this.allowSleep=void 0!==d.allowSleep?d.allowSleep:!0;this.wantsToSleep=!1;this.sleepState=a.AWAKE;this.sleepSpeedLimit=void 0!==d.sleepSpeedLimit?d.sleepSpeedLimit:.2;this.sleepTimeLimit=void 0!==d.sleepTimeLimit?d.sleepTimeLimit:1;this.gravityScale=void 0!==d.gravityScale?d.gravityScale:1;this.collisionResponse=void 0!==d.collisionResponse?d.collisionResponse:!0;this.timeLastSleepy=this.idleTime=0;this.ccdSpeedThreshold=void 0!==d.ccdSpeedThreshold?d.ccdSpeedThreshold: -1;this.ccdIterations=void 0!==d.ccdIterations?d.ccdIterations:10;this.concavePath=null;this._wakeUpAfterNarrowphase=!1;this.updateMassProperties()}var b=h("../math/vec2"),d=h("poly-decomp"),e=h("../shapes/Convex");l=h("../collision/RaycastResult");var f=h("../collision/Ray"),g=h("../collision/AABB"),k=h("../events/EventEmitter");u.exports=a;a.prototype=new k;a.prototype.constructor=a;a._idCounter=0;a.prototype.updateSolveMassProperties=function(){this.sleepState===a.SLEEPING||this.type===a.KINEMATIC? this.invInertiaSolve=this.invMassSolve=0:(this.invMassSolve=this.invMass,this.invInertiaSolve=this.invInertia)};a.prototype.setDensity=function(a){this.mass=this.getArea()*a;this.updateMassProperties()};a.prototype.getArea=function(){for(var a=0,b=0;be&&(e=k+g)}this.boundingRadius=e};a.prototype.addShape=function(a,d,e){if(a.body)throw Error("A shape can only be added to one body.");a.body=this;d?b.copy(a.position,d): b.set(a.position,0,0);a.angle=e||0;this.shapes.push(a);this.updateMassProperties();this.updateBoundingRadius();this.aabbNeedsUpdate=!0};a.prototype.removeShape=function(a){var b=this.shapes.indexOf(a);return-1!==b?(this.shapes.splice(b,1),this.aabbNeedsUpdate=!0,a.body=null,!0):!1};a.prototype.updateMassProperties=function(){if(this.type===a.STATIC||this.type===a.KINEMATIC)this.mass=Number.MAX_VALUE,this.invMass=0,this.inertia=Number.MAX_VALUE,this.invInertia=0;else{var d=this.shapes,e=d.length,f= this.mass/e,g=0;if(this.fixedRotation)this.inertia=Number.MAX_VALUE,this.invInertia=0;else{for(var k=0;k=Math.pow(this.sleepSpeedLimit,2)?(this.idleTime=0,this.sleepState=a.AWAKE):(this.idleTime+=f,this.sleepState=a.SLEEPY),this.idleTime>this.sleepTimeLimit&&(e?this.wantsToSleep=!0:this.sleep()))};a.prototype.overlaps=function(a){return this.world.overlapKeeper.bodiesAreOverlapping(this,a)};var C=b.create(),B=b.create();a.prototype.integrate=function(a){var d= this.invMass,e=this.force,f=this.position,g=this.velocity;b.copy(this.previousPosition,this.position);this.previousAngle=this.angle;this.fixedRotation||(this.angularVelocity+=this.angularForce*this.invInertia*a);b.scale(C,e,a*d);b.multiply(C,this.massMultiplier,C);b.add(g,C,g);this.integrateToTimeOfImpact(a)||(b.scale(B,g,a),b.add(f,f,B),this.fixedRotation||(this.angle+=this.angularVelocity*a));this.aabbNeedsUpdate=!0};var E=new l,F=new f({mode:f.ALL}),D=b.create(),H=b.create(),G=b.create(),J=b.create(); a.prototype.integrateToTimeOfImpact=function(a){if(0>this.ccdSpeedThreshold||b.squaredLength(this.velocity)=m&&lt;t++){var r=this.radius*(2*t-1);d.set(k,-q,r);d.set(m,q,r);d.toGlobalFrame(k,k,e,l);d.toGlobalFrame(m,m,e,l);var u=d.getLineSegmentsIntersectionFraction(h,n,k,m);if(0<=u&&(d.rotate(g,p,l),d.scale(g,g,2*t-1),b.reportIntersection(a,u,g,-1),a.shouldStop(b)))return}r= Math.pow(this.radius,2)+Math.pow(q,2);for(t=0;2>t;t++){d.set(k,q*(2*t-1),0);d.toGlobalFrame(k,k,e,l);var C=Math.pow(n[0]-h[0],2)+Math.pow(n[1]-h[1],2),B=2*((n[0]-h[0])*(h[0]-k[0])+(n[1]-h[1])*(h[1]-k[1]));u=Math.pow(B,2)-4*C*(Math.pow(h[0]-k[0],2)+Math.pow(h[1]-k[1],2)-Math.pow(this.radius,2));if(!(0>u))if(0===u){if(d.lerp(f,h,n,u),d.squaredDistance(f,e)>r&&(d.sub(g,f,k),d.normalize(g,g),b.reportIntersection(a,u,g,-1),a.shouldStop(b)))break}else{u=Math.sqrt(u);var E=1/(2*C);C=(-B-u)*E;B=(-B+u)*E; if(0<=C&&1>=C&&(d.lerp(f,h,n,C),d.squaredDistance(f,e)>r&&(d.sub(g,f,k),d.normalize(g,g),b.reportIntersection(a,C,g,-1),a.shouldStop(b))))break;if(0<=B&&1>=B&&(d.lerp(f,h,n,B),d.squaredDistance(f,e)>r&&(d.sub(g,f,k),d.normalize(g,g),b.reportIntersection(a,B,g,-1),a.shouldStop(b))))break}}}},{"../math/vec2":30,"./Shape":45}],39:[function(h,u,l){function a(a){"number"===typeof a&&(a={radius:a},console.warn("The Circle constructor signature has changed. Please use the following format: new Circle({ radius: 1 })")); a=a||{};this.radius=a.radius||1;a.type=b.CIRCLE;b.call(this,a)}var b=h("./Shape"),d=h("../math/vec2");u.exports=a;a.prototype=new b;a.prototype.constructor=a;a.prototype.computeMomentOfInertia=function(a){var b=this.radius;return a*b*b/2};a.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius};a.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius};a.prototype.computeAABB=function(a,b,e){e=this.radius;d.set(a.upperBound,e,e);d.set(a.lowerBound,-e,-e);b&&(d.add(a.lowerBound, a.lowerBound,b),d.add(a.upperBound,a.upperBound,b))};var e=d.create(),f=d.create();a.prototype.raycast=function(a,b,l,p){p=b.from;var g=b.to,k=Math.pow(g[0]-p[0],2)+Math.pow(g[1]-p[1],2),m=2*((g[0]-p[0])*(p[0]-l[0])+(g[1]-p[1])*(p[1]-l[1])),h=Math.pow(m,2)-4*k*(Math.pow(p[0]-l[0],2)+Math.pow(p[1]-l[1],2)-Math.pow(this.radius,2));if(!(0>h))if(0===h)d.lerp(e,p,g,h),d.sub(f,e,l),d.normalize(f,f),b.reportIntersection(a,h,f,-1);else{h=Math.sqrt(h);var v=1/(2*k);k=(-m-h)*v;m=(-m+h)*v;if(0<=k&&1>=k&&(d.lerp(e, p,g,k),d.sub(f,e,l),d.normalize(f,f),b.reportIntersection(a,k,f,-1),a.shouldStop(b)))return;0<=m&&1>=m&&(d.lerp(e,p,g,m),d.sub(f,e,l),d.normalize(f,f),b.reportIntersection(a,m,f,-1))}}},{"../math/vec2":30,"./Shape":45}],40:[function(h,u,l){function a(a,e){Array.isArray(a)&&(a={vertices:a,axes:e},console.warn("The Convex constructor signature has changed. Please use the following format: new Convex({ vertices: [...], ... })"));a=a||{};this.vertices=[];var f=void 0!==a.vertices?a.vertices:[];for(e= 0;ethis.area)throw Error("Convex vertices must be given in conter-clockwise winding.");}var b=h("./Shape"),d=h("../math/vec2"),e=h("../math/polyk");h("poly-decomp");u.exports=a;a.prototype=new b;a.prototype.constructor=a;var f=d.create(),g=d.create();a.prototype.projectOntoLocalAxis=function(a,b){var e=null,g=null;a=f;for(var k=0;ke)e=l;if(null=== g||le&&(a=g,g=e,e=a);d.set(b,g,e)};a.prototype.projectOntoWorldAxis=function(a,b,e,f){var k=g;this.projectOntoLocalAxis(a,f);0!==e?d.rotate(k,a,e):k=a;a=d.dot(b,k);d.set(f,f[0]+a,f[1]+a)};a.prototype.updateTriangles=function(){this.triangles.length=0;for(var a=[],b=0;bb&&(b=f)}this.boundingRadius=Math.sqrt(b)};a.triangleArea=function(a,b,d){return.5*((b[0]-a[0])*(d[1]-a[1])-(d[0]-a[0])*(b[1]-a[1]))};a.prototype.updateArea=function(){this.updateTriangles();this.area=0;for(var b=this.triangles,d=this.vertices,e=0;e!==b.length;e++){var f=b[e];f=a.triangleArea(d[f[0]],d[f[1]], d[f[2]]);this.area+=f}};a.prototype.computeAABB=function(a,b,d){a.setFromPoints(this.vertices,b,d,0)};var p=d.create(),n=d.create(),q=d.create();a.prototype.raycast=function(a,b,e,f){var g=this.vertices;d.toLocalFrame(p,b.from,e,f);d.toLocalFrame(n,b.to,e,f);e=g.length;for(var k=0;kb&&(b=f);fe*t&&(d=e*t-l);h[a]+=d;b.addToWlambda(d);return d}},{"../equations/FrictionEquation":23,"../math/vec2":30,"../utils/Utils":57,"./Solver":47}],47:[function(h,u,l){function a(a,d){a=a||{};b.call(this);this.type=d;this.equations=[];this.equationSortFunction=a.equationSortFunction||!1} h("../utils/Utils");var b=h("../events/EventEmitter");u.exports=a;a.prototype=new b;a.prototype.constructor=a;a.prototype.solve=function(a,b){throw Error("Solver.solve should be implemented by subclasses!");};var d={bodies:[]};a.prototype.solveIsland=function(a,b){this.removeAllEquations();b.equations.length&&(this.addEquations(b.equations),d.bodies.length=0,b.getBodies(d.bodies),d.bodies.length&&this.solve(a,d))};a.prototype.sortEquations=function(){this.equationSortFunction&&this.equations.sort(this.equationSortFunction)}; a.prototype.addEquation=function(a){a.enabled&&this.equations.push(a)};a.prototype.addEquations=function(a){for(var b=0,d=a.length;b!==d;b++){var e=a[b];e.enabled&&this.equations.push(e)}};a.prototype.removeEquation=function(a){a=this.equations.indexOf(a);-1!==a&&this.equations.splice(a,1)};a.prototype.removeAllEquations=function(){this.equations.length=0};a.GS=1;a.ISLAND=2},{"../events/EventEmitter":26,"../utils/Utils":57}],48:[function(h,u,l){function a(){d.apply(this,arguments)}var b=h("../equations/ContactEquation"), d=h("./Pool");u.exports=a;a.prototype=new d;a.prototype.constructor=a;a.prototype.create=function(){return new b};a.prototype.destroy=function(a){a.bodyA=a.bodyB=null;return this}},{"../equations/ContactEquation":21,"./Pool":55}],49:[function(h,u,l){function a(){d.apply(this,arguments)}var b=h("../equations/FrictionEquation"),d=h("./Pool");u.exports=a;a.prototype=new d;a.prototype.constructor=a;a.prototype.create=function(){return new b};a.prototype.destroy=function(a){a.bodyA=a.bodyB=null;return this}}, {"../equations/FrictionEquation":23,"./Pool":55}],50:[function(h,u,l){function a(){d.apply(this,arguments)}var b=h("../world/IslandNode"),d=h("./Pool");u.exports=a;a.prototype=new d;a.prototype.constructor=a;a.prototype.create=function(){return new b};a.prototype.destroy=function(a){a.reset();return this}},{"../world/IslandNode":60,"./Pool":55}],51:[function(h,u,l){function a(){d.apply(this,arguments)}var b=h("../world/Island"),d=h("./Pool");u.exports=a;a.prototype=new d;a.prototype.constructor=a; a.prototype.create=function(){return new b};a.prototype.destroy=function(a){a.reset();return this}},{"../world/Island":58,"./Pool":55}],52:[function(h,u,l){function a(){this.overlappingShapesLastState=new b;this.overlappingShapesCurrentState=new b;this.recordPool=new d({size:16});this.tmpDict=new b;this.tmpArray1=[]}var b=h("./TupleDictionary");h("./OverlapKeeperRecord");var d=h("./OverlapKeeperRecordPool");h("./Utils");u.exports=a;a.prototype.tick=function(){for(var a=this.overlappingShapesLastState, b=this.overlappingShapesCurrentState,d=a.keys.length;d--;){var l=a.keys[d],m=a.getByKey(l);b.getByKey(l);m&&this.recordPool.release(m)}a.reset();a.copy(b);b.reset()};a.prototype.setOverlapping=function(a,b,d,l){var e=this.overlappingShapesCurrentState;if(!e.get(b.id,l.id)){var f=this.recordPool.get();f.set(a,b,d,l);e.set(b.id,l.id,f)}};a.prototype.getNewOverlaps=function(a){return this.getDiff(this.overlappingShapesLastState,this.overlappingShapesCurrentState,a)};a.prototype.getEndOverlaps=function(a){return this.getDiff(this.overlappingShapesCurrentState, this.overlappingShapesLastState,a)};a.prototype.bodiesAreOverlapping=function(a,b){for(var d=this.overlappingShapesCurrentState,e=d.keys.length;e--;){var f=d.data[d.keys[e]];if(f.bodyA===a&&f.bodyB===b||f.bodyA===b&&f.bodyB===a)return!0}return!1};a.prototype.getDiff=function(a,b,d){d=d||[];d.length=0;for(var e=b.keys.length;e--;){var f=b.keys[e],g=b.data[f];if(!g)throw Error("Key "+f+" had no data!");a.data[f]||d.push(g)}return d};a.prototype.isNewOverlap=function(a,b){a=a.id|0;b=b.id|0;var d=this.overlappingShapesCurrentState; return!this.overlappingShapesLastState.get(a,b)&&!!d.get(a,b)};a.prototype.getNewBodyOverlaps=function(a){this.tmpArray1.length=0;var b=this.getNewOverlaps(this.tmpArray1);return this.getBodyDiff(b,a)};a.prototype.getEndBodyOverlaps=function(a){this.tmpArray1.length=0;var b=this.getEndOverlaps(this.tmpArray1);return this.getBodyDiff(b,a)};a.prototype.getBodyDiff=function(a,b){b=b||[];for(var d=this.tmpDict,e=a.length;e--;){var f=a[e];d.set(f.bodyA.id|0,f.bodyB.id|0,f)}for(e=d.keys.length;e--;)(f= d.getByKey(d.keys[e]))&&b.push(f.bodyA,f.bodyB);d.reset();return b}},{"./OverlapKeeperRecord":53,"./OverlapKeeperRecordPool":54,"./TupleDictionary":56,"./Utils":57}],53:[function(h,u,l){function a(a,d,e,f){this.shapeA=d;this.shapeB=f;this.bodyA=a;this.bodyB=e}u.exports=a;a.prototype.set=function(b,d,e,f){a.call(this,b,d,e,f)}},{}],54:[function(h,u,l){function a(){d.apply(this,arguments)}var b=h("./OverlapKeeperRecord"),d=h("./Pool");u.exports=a;a.prototype=new d;a.prototype.constructor=a;a.prototype.create= function(){return new b};a.prototype.destroy=function(a){a.bodyA=a.bodyB=a.shapeA=a.shapeB=null;return this}},{"./OverlapKeeperRecord":53,"./Pool":55}],55:[function(h,u,l){function a(a){a=a||{};this.objects=[];void 0!==a.size&&this.resize(a.size)}u.exports=a;a.prototype.resize=function(a){for(var b=this.objects;b.length>a;)b.pop();for(;b.length(b|0)?a<<16|b&65535:b<<16|a&65535)|0};a.prototype.getByKey=function(a){return this.data[a|0]};a.prototype.get=function(a,b){return this.data[this.getKey(a,b)]};a.prototype.set=function(a,b,f){if(!f)throw Error("No data!");a=this.getKey(a,b);this.data[a]||this.keys.push(a);this.data[a]=f;return a};a.prototype.reset= function(){for(var a=this.data,b=this.keys,f=b.length;f--;)delete a[b[f]];b.length=0};a.prototype.copy=function(a){this.reset();b.appendArray(this.keys,a.keys);for(var d=a.keys.length;d--;){var f=a.keys[d];this.data[f]=a.data[f]}}},{"./Utils":57}],57:[function(h,u,l){function a(){}u.exports=a;a.appendArray=function(a,d){if(15E4>d.length)a.push.apply(a,d);else for(var b=0,f=d.length;b!==f;++b)a.push(d[b])};a.splice=function(a,d,e){e=e||1;for(var b=a.length-e;d=a&&b=2*Math.pow(l.sleepSpeedLimit,2)&&(b._wakeUpAfterNarrowphase= !0);l.allowSleep&&l.type===n.DYNAMIC&&l.sleepState===n.SLEEPING&&b.sleepState===n.AWAKE&&b.type!==n.STATIC&&d.squaredLength(b.velocity)+Math.pow(b.angularVelocity,2)>=2*Math.pow(b.sleepSpeedLimit,2)&&(l._wakeUpAfterNarrowphase=!0);this.overlapKeeper.setOverlapping(b,e,l,k);if(this.has("beginContact")&&this.overlapKeeper.isNewOverlap(e,k)){f=this.beginContactEvent;f.shapeA=e;f.shapeB=k;f.bodyA=b;f.bodyB=l;f.contactEquations.length=0;if("number"===typeof q)for(b=a.contactEquations.length-q;bb||0>d)throw Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");this.children[b]=a;this.children[d]=c}};h.DisplayObjectContainer.prototype.getChildIndex=function(c){c=this.children.indexOf(c);if(-1===c)throw Error("The supplied DisplayObject must be a child of the caller");return c};h.DisplayObjectContainer.prototype.setChildIndex= function(c,a){if(0>a||a>=this.children.length)throw Error("The supplied index is out of bounds");var b=this.getChildIndex(c);this.children.splice(b,1);this.children.splice(a,0,c)};h.DisplayObjectContainer.prototype.getChildAt=function(c){if(0>c||c>=this.children.length)throw Error("getChildAt: Supplied index "+c+" does not exist in the child list, or the supplied DisplayObject must be a child of the caller");return this.children[c]};h.DisplayObjectContainer.prototype.removeChild=function(c){c=this.children.indexOf(c); if(-1!==c)return this.removeChildAt(c)};h.DisplayObjectContainer.prototype.removeChildAt=function(c){var a=this.getChildAt(c);a&&(a.parent=void 0,this.children.splice(c,1));return a};h.DisplayObjectContainer.prototype.bringChildToTop=function(c){if(c.parent===this)return this.setChildIndex(c,this.children.length-1)};h.DisplayObjectContainer.prototype.sendChildToBack=function(c){if(c.parent===this)return this.setChildIndex(c,0)};h.DisplayObjectContainer.prototype.removeChildren=function(c,a){void 0=== c&&(c=0);void 0===a&&(a=this.children.length);var b=a-c;if(0q?k:q;l=l>n?l:n}q=this._bounds;if(!p){q=new h.Rectangle;var t=q.x;k=q.width+q.x;l=q.y;p=q.height+q.y;d=this.worldTransform;var r=d.a,v=d.b,u=d.c,w=d.d,y=d.tx,A=d.ty;f=r*k+u*p+y;g=w*p+v*k+A;d=r*t+u*p+y;p=w*p+v*t+A;n=r*t+u*l+y;t=w*l+v*t+A;r=r*k+u*l+y;v=w*l+v*k+A;k=f;l=g;f=dk?d:k;k=n>k?n:k;k=r>k?r:k;l=p>l?p:l;l=t>l?t:l;l=v>l?v:l}q.x=f;q.y=g;q.width=k-f;q.height=l-g;if(a)for(c.worldTransform= e,d=0;d=this.alpha))if(this._cacheAsBitmap)this._renderCachedSprite(c);else{var a;if(this._mask||this._filters){this._filters&& (c.spriteBatch.flush(),c.filterManager.pushFilter(this._filterBlock));this._mask&&(c.spriteBatch.stop(),c.maskManager.pushMask(this.mask,c),c.spriteBatch.start());for(a=0;ag&&(g*=-1,b=d,d=-a,a=-b),0>c&&(c*=-1,b=e,e=-f,f=-b),t=g*a+p,b=g*d+p,r=c*f+h,q=c*e+h;else{var v=g*a+l*f+p,u=c*f+k*a+h,w=g*d+l*f+p;f=c*f+k*d+h;var y=g*d+l*e+p;d=c*e+k*d+h;g=g*a+l*e+p;a=c*e+k*a+h;t=vb?v:b;b=w>b?w:b;b=y>b?y:b;b=g>b?g:b;q=u> q?u:q;q=f>q?f:q;q=d>q?d:q;q=a>q?a:q}a=this._bounds;a.x=t;a.width=b-t;a.y=r;a.height=q-r;return this._currentBounds=a};h.Sprite.prototype.getLocalBounds=function(){var c=this.worldTransform;this.worldTransform=Phaser.identityMatrix;for(var a=0;a=this.alpha)&& this.renderable){var b=this.worldTransform;a&&(b=a);if(this._mask||this._filters){b=c.spriteBatch;this._filters&&(b.flush(),c.filterManager.pushFilter(this._filterBlock));this._mask&&(b.stop(),c.maskManager.pushMask(this.mask,c),b.start());b.render(this);for(a=0;athis.texture.crop.width||1>this.texture.crop.height)){var b=this.worldTransform;a&&(b=a);this.blendMode!==c.currentBlendMode&&(c.currentBlendMode=this.blendMode,c.context.globalCompositeOperation=h.blendModesCanvas[c.currentBlendMode]);this._mask&&c.maskManager.pushMask(this._mask,c);if(this.texture.valid){a=this.texture.baseTexture.resolution/c.resolution;c.context.globalAlpha=this.worldAlpha; c.smoothProperty&&c.scaleMode!==this.texture.baseTexture.scaleMode&&(c.scaleMode=this.texture.baseTexture.scaleMode,c.context[c.smoothProperty]=c.scaleMode===h.scaleModes.LINEAR);var d=this.texture.trim?this.texture.trim.x-this.anchor.x*this.texture.trim.width:this.anchor.x*-this.texture.frame.width,e=this.texture.trim?this.texture.trim.y-this.anchor.y*this.texture.trim.height:this.anchor.y*-this.texture.frame.height,f=b.tx*c.resolution+c.shakeX,g=b.ty*c.resolution+c.shakeY,k=this.texture.crop.width, l=this.texture.crop.height;if(this.texture.rotated){var p=b.a,n=b.b,q=b.c,t=b.d,r=k;f=b.c*l+f;g=b.d*l+g;b.a=6.123233995736766E-17*p+-q;b.b=6.123233995736766E-17*n+-t;b.c=p+6.123233995736766E-17*q;b.d=n+6.123233995736766E-17*t;k=l;l=r}c.roundPixels?(c.context.setTransform(b.a,b.b,b.c,b.d,f|0,g|0),d|=0,e|=0):c.context.setTransform(b.a,b.b,b.c,b.d,f,g);d/=a;e/=a;k|=0;l|=0;if(k&&l){if(16777215!==this.tint){if(this.texture.requiresReTint||this.cachedTint!==this.tint)this.tintedTexture=h.CanvasTinter.getTintedTexture(this, this.tint),this.cachedTint=this.tint,this.texture.requiresReTint=!1;c.context.drawImage(this.tintedTexture,0,0,k,l,d,e,k/a,l/a)}else c.context.drawImage(this.texture.baseTexture.source,this.texture.crop.x,this.texture.crop.y,k,l,d,e,k/a,l/a);for(b=0;b= "+this.MAX_TEXTURES+".0) { gl_FragColor = BLUE;return;}"," if(isnan(vTextureIndex)) { gl_FragColor = RED;return;}","}"];a=h.compileProgram(c,this.vertexSrc||h.PixiShader.defaultVertexSrc,this.fragmentSrc);c.useProgram(a);this.uSamplerArray=c.getUniformLocation(a,"uSamplerArray[0]");this.projectionVector= c.getUniformLocation(a,"projectionVector");this.offsetVector=c.getUniformLocation(a,"offsetVector");this.dimensions=c.getUniformLocation(a,"dimensions");this.aVertexPosition=c.getAttribLocation(a,"aVertexPosition");this.aTextureCoord=c.getAttribLocation(a,"aTextureCoord");this.colorAttribute=c.getAttribLocation(a,"aColor");this.aTextureIndex=c.getAttribLocation(a,"aTextureIndex");b=[];var d=c.createTexture();c.activeTexture(c.TEXTURE0);c.bindTexture(c.TEXTURE_2D,d);c.texImage2D(c.TEXTURE_2D,0,c.RGB, 1,1,0,c.RGB,c.UNSIGNED_BYTE,null);for(var e=0;e 0.0) gl_Position = vec4(0.0);"," gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = vec4(aColor.rgb * aColor.a, aColor.a);"," vTextureIndex = aTextureIndex;","}"];h.PixiFastShader=function(c){this._UID=Phaser._UID++;this.gl=c;this.program=null;if(h._enableMultiTextureToggle){c=this.gl;this.MAX_TEXTURES=c.getParameter(c.MAX_TEXTURE_IMAGE_UNITS); c="\tif (vTextureIndex == 0.0) { gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;return;}\n";for(var a=1;a= "+this.MAX_TEXTURES+".0) { gl_FragColor = BLUE;return;}"," if(isnan(vTextureIndex)) {gl_FragColor = RED;return;}","}"]}else this.fragmentSrc=["// PixiFastShader Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","varying float vTextureIndex;","uniform sampler2D uSampler;", "void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;","}"];this.vertexSrc=["// PixiFastShader Vertex Shader.","attribute vec2 aVertexPosition;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","attribute vec2 aTextureCoord;","attribute float aColor;","attribute float aTextureIndex;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform mat3 uMatrix;","varying vec2 vTextureCoord;","varying float vColor;","varying float vTextureIndex;", "const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," vec2 v;"," vec2 sv = aVertexPosition * aScale;"," v.x = (sv.x) * cos(aRotation) - (sv.y) * sin(aRotation);"," v.y = (sv.x) * sin(aRotation) + (sv.y) * cos(aRotation);"," v = ( uMatrix * vec3(v + aPositionCoord , 1.0) ).xy ;"," gl_Position = vec4( ( v / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vTextureIndex = aTextureIndex;"," vColor = aColor;","}"];this.textureCount=0;this.init()};h.PixiFastShader.prototype.constructor= h.PixiFastShader;h.PixiFastShader.prototype.init=function(){var c=this.gl,a=h.compileProgram(c,this.vertexSrc,this.fragmentSrc);c.useProgram(a);this.uSampler=h._enableMultiTextureToggle?c.getUniformLocation(a,"uSamplerArray[0]"):c.getUniformLocation(a,"uSampler");if(h._enableMultiTextureToggle){var b=[],d=c.createTexture();c.activeTexture(c.TEXTURE0);c.bindTexture(c.TEXTURE_2D,d);c.texImage2D(c.TEXTURE_2D,0,c.RGB,1,1,0,c.RGB,c.UNSIGNED_BYTE,null);for(var e=0;e= "+this.MAX_TEXTURES+".0) { gl_FragColor = BLUE;return;}"," if(isnan(vTextureIndex)) {gl_FragColor = RED;return;}", "}"]}else this.fragmentSrc=["//StripShader Fragment Shader.","precision mediump float;","varying vec2 vTextureCoord;","varying float vTextureIndex;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord);","}"];this.vertexSrc=["//StripShader Vertex Shader.","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aTextureIndex;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;", "varying vec2 vTextureCoord;","varying float vTextureIndex;","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;"," vTextureIndex = aTextureIndex;","}"];this.init()};h.StripShader.prototype.constructor=h.StripShader;h.StripShader.prototype.init=function(){var c=this.gl,a=h.compileProgram(c,this.vertexSrc, this.fragmentSrc);c.useProgram(a);this.uSampler=h._enableMultiTextureToggle?c.getUniformLocation(a,"uSamplerArray[0]"):c.getUniformLocation(a,"uSampler");if(h._enableMultiTextureToggle){var b=[],d=c.createTexture();c.activeTexture(c.TEXTURE0);c.bindTexture(c.TEXTURE_2D,d);c.texImage2D(c.TEXTURE_2D,0,c.RGB,1,1,0,c.RGB,c.UNSIGNED_BYTE,null);for(var e=0;e>1;a|=a>>2;a|=a>>4;a|=a>>8;a|=a>>16;return++a},b=this.gl,d=b.getParameter(b.MAX_TEXTURE_IMAGE_UNITS),e=b.getParameter(b.MAX_TEXTURE_SIZE);b=this.game.cache._cache.image; for(var f=null,g=0;g=e?(k.textureIndex=0,console.warn('setTexturePriority: Image "%s" was given textureIndex=0 because there is no available texture space (%s).', f,e)):k.textureIndex=1+g%(d-1);this.currentBatchedTextures.push(f)}else console.warn('setTexturePriority: There is no image "%s" in the image cache.',f);this.renderSession.maxTextureAvailableSpace=e;return this.currentBatchedTextures}console.warn("setTexturePriority error: Multi Texture support hasn't been enabled in the Phaser Game Config.")};h.WebGLRenderer.prototype.render=function(c){if(!this.contextLost){var a=this.gl;a.viewport(0,0,this.width,this.height);a.bindFramebuffer(a.FRAMEBUFFER,null); this.game.clearBeforeRender&&(a.clearColor(c._bgColor.r,c._bgColor.g,c._bgColor.b,c._bgColor.a),a.clear(a.COLOR_BUFFER_BIT));this.offset.x=this.game.camera._shake.x;this.offset.y=this.game.camera._shake.y;this.renderDisplayObject(c,this.projection)}};h.WebGLRenderer.prototype.renderDisplayObject=function(c,a,b,d){this.renderSession.blendModeManager.setBlendMode(h.blendModes.NORMAL);this.renderSession.drawCount=0;this.renderSession.flipY=b?-1:1;this.renderSession.projection=a;this.renderSession.offset= this.offset;this.spriteBatch.begin(this.renderSession);this.filterManager.begin(this.renderSession,b);c._renderWebGL(this.renderSession,d);this.spriteBatch.end()};h.WebGLRenderer.prototype.resize=function(c,a){this.width=c*this.resolution;this.height=a*this.resolution;this.view.width=this.width;this.view.height=this.height;this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px");this.gl.viewport(0,0,this.width,this.height);this.projection.x= this.width/2/this.resolution;this.projection.y=-this.height/2/this.resolution};h.WebGLRenderer.prototype.updateCompressedTexture=function(c){if(!c.hasLoaded)return!1;var a=this.gl,b=c.source;c._glTextures[a.id]||(c._glTextures[a.id]=a.createTexture());a.activeTexture(a.TEXTURE0+c.textureIndex);a.bindTexture(a.TEXTURE_2D,c._glTextures[a.id]);a.compressedTexImage2D(a.TEXTURE_2D,0,b.glExtensionFormat,b.width,b.height,0,b.textureData);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,c.scaleMode===h.scaleModes.LINEAR? a.LINEAR:a.NEAREST);c.mipmap&&Phaser.Math.isPowerOfTwo(c.width,c.height)?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,c.scaleMode===h.scaleModes.LINEAR?a.LINEAR_MIPMAP_LINEAR:a.NEAREST_MIPMAP_NEAREST),a.generateMipmap(a.TEXTURE_2D)):a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,c.scaleMode===h.scaleModes.LINEAR?a.LINEAR:a.NEAREST);c._powerOf2?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.REPEAT),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.REPEAT)):(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._dirty[a.id]=!1;return!0};h.WebGLRenderer.prototype.updateTexture=function(c){if(!c.hasLoaded)return!1;if(c.source.compressionAlgorithm)return this.updateCompressedTexture(c);var a=this.gl;c._glTextures[a.id]||(c._glTextures[a.id]=a.createTexture());a.activeTexture(a.TEXTURE0+c.textureIndex);a.bindTexture(a.TEXTURE_2D,c._glTextures[a.id]);a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,c.premultipliedAlpha);a.texImage2D(a.TEXTURE_2D, 0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,c.source);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,c.scaleMode===h.scaleModes.LINEAR?a.LINEAR:a.NEAREST);c.mipmap&&Phaser.Math.isPowerOfTwo(c.width,c.height)?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,c.scaleMode===h.scaleModes.LINEAR?a.LINEAR_MIPMAP_LINEAR:a.NEAREST_MIPMAP_NEAREST),a.generateMipmap(a.TEXTURE_2D)):a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,c.scaleMode===h.scaleModes.LINEAR?a.LINEAR:a.NEAREST);c._powerOf2?(a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_S,a.REPEAT),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.REPEAT)):(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._dirty[a.id]=!1;return!0};h.WebGLRenderer.prototype.destroy=function(){this.offset=this.projection=h.glContexts[this.glContextId]=null;this.shaderManager.destroy();this.spriteBatch.destroy();this.maskManager.destroy();this.filterManager.destroy();this.renderSession=this.gl=this.filterManager= this.maskManager=this.spriteBatch=this.shaderManager=null;Phaser.CanvasPool.remove(this);h.instances[this.glContextId]=null;h.WebGLRenderer.glContextId--};h.WebGLRenderer.prototype.mapBlendModes=function(){var c=this.gl;if(!h.blendModesWebGL){var a=[],b=h.blendModes;a[b.NORMAL]=[c.ONE,c.ONE_MINUS_SRC_ALPHA];a[b.ADD]=[c.SRC_ALPHA,c.DST_ALPHA];a[b.MULTIPLY]=[c.DST_COLOR,c.ONE_MINUS_SRC_ALPHA];a[b.SCREEN]=[c.SRC_ALPHA,c.ONE];a[b.OVERLAY]=[c.ONE,c.ONE_MINUS_SRC_ALPHA];a[b.DARKEN]=[c.ONE,c.ONE_MINUS_SRC_ALPHA]; a[b.LIGHTEN]=[c.ONE,c.ONE_MINUS_SRC_ALPHA];a[b.COLOR_DODGE]=[c.ONE,c.ONE_MINUS_SRC_ALPHA];a[b.COLOR_BURN]=[c.ONE,c.ONE_MINUS_SRC_ALPHA];a[b.HARD_LIGHT]=[c.ONE,c.ONE_MINUS_SRC_ALPHA];a[b.SOFT_LIGHT]=[c.ONE,c.ONE_MINUS_SRC_ALPHA];a[b.DIFFERENCE]=[c.ONE,c.ONE_MINUS_SRC_ALPHA];a[b.EXCLUSION]=[c.ONE,c.ONE_MINUS_SRC_ALPHA];a[b.HUE]=[c.ONE,c.ONE_MINUS_SRC_ALPHA];a[b.SATURATION]=[c.ONE,c.ONE_MINUS_SRC_ALPHA];a[b.COLOR]=[c.ONE,c.ONE_MINUS_SRC_ALPHA];a[b.LUMINOSITY]=[c.ONE,c.ONE_MINUS_SRC_ALPHA];h.blendModesWebGL= a}};h.WebGLRenderer.prototype.getMaxTextureUnit=function(){var c=this.gl;return c.getParameter(c.MAX_TEXTURE_IMAGE_UNITS)};h.enableMultiTexture=function(){h._enableMultiTextureToggle=!0};h.WebGLRenderer.glContextId=0;h.WebGLRenderer.textureArray=[];h.WebGLBlendModeManager=function(){this.currentBlendMode=99999};h.WebGLBlendModeManager.prototype.constructor=h.WebGLBlendModeManager;h.WebGLBlendModeManager.prototype.setContext=function(c){this.gl=c};h.WebGLBlendModeManager.prototype.setBlendMode=function(c){if(this.currentBlendMode=== c)return!1;this.currentBlendMode=c;(c=h.blendModesWebGL[this.currentBlendMode])&&this.gl.blendFunc(c[0],c[1]);return!0};h.WebGLBlendModeManager.prototype.destroy=function(){this.gl=null};h.WebGLMaskManager=function(){};h.WebGLMaskManager.prototype.constructor=h.WebGLMaskManager;h.WebGLMaskManager.prototype.setContext=function(c){this.gl=c};h.WebGLMaskManager.prototype.pushMask=function(c,a){var b=a.gl;c.dirty&&h.WebGLGraphics.updateGraphics(c,b);void 0!==c._webGL[b.id]&&void 0!==c._webGL[b.id].data&& 0!==c._webGL[b.id].data.length&&a.stencilManager.pushStencil(c,c._webGL[b.id].data[0],a)};h.WebGLMaskManager.prototype.popMask=function(c,a){var b=this.gl;void 0!==c._webGL[b.id]&&void 0!==c._webGL[b.id].data&&0!==c._webGL[b.id].data.length&&a.stencilManager.popStencil(c,c._webGL[b.id].data[0],a)};h.WebGLMaskManager.prototype.destroy=function(){this.gl=null};h.WebGLStencilManager=function(){this.stencilStack=[];this.reverse=!0;this.count=0};h.WebGLStencilManager.prototype.setContext=function(c){this.gl= c};h.WebGLStencilManager.prototype.pushStencil=function(c,a,b){var d=this.gl;this.bindGraphics(c,a,b);0===this.stencilStack.length&&(d.enable(d.STENCIL_TEST),d.clear(d.STENCIL_BUFFER_BIT),this.reverse=!0,this.count=0);this.stencilStack.push(a);c=this.count;d.colorMask(!1,!1,!1,!1);d.stencilFunc(d.ALWAYS,0,255);d.stencilOp(d.KEEP,d.KEEP,d.INVERT);1===a.mode?(d.drawElements(d.TRIANGLE_FAN,a.indices.length-4,d.UNSIGNED_SHORT,0),this.reverse?(d.stencilFunc(d.EQUAL,255-c,255),d.stencilOp(d.KEEP,d.KEEP, d.DECR)):(d.stencilFunc(d.EQUAL,c,255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)),d.drawElements(d.TRIANGLE_FAN,4,d.UNSIGNED_SHORT,2*(a.indices.length-4)),this.reverse?d.stencilFunc(d.EQUAL,255-(c+1),255):d.stencilFunc(d.EQUAL,c+1,255),this.reverse=!this.reverse):(this.reverse?(d.stencilFunc(d.EQUAL,c,255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)):(d.stencilFunc(d.EQUAL,255-c,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)),d.drawElements(d.TRIANGLE_STRIP,a.indices.length,d.UNSIGNED_SHORT,0),this.reverse?d.stencilFunc(d.EQUAL, c+1,255):d.stencilFunc(d.EQUAL,255-(c+1),255));d.colorMask(!0,!0,!0,!0);d.stencilOp(d.KEEP,d.KEEP,d.KEEP);this.count++};h.WebGLStencilManager.prototype.bindGraphics=function(c,a,b){this._currentGraphics=c;var d=this.gl,e=b.projection,f=b.offset;if(1===a.mode){var g=b.shaderManager.complexPrimitiveShader;b.shaderManager.setShader(g);d.uniform1f(g.flipY,b.flipY);d.uniformMatrix3fv(g.translationMatrix,!1,c.worldTransform.toArray(!0));d.uniform2f(g.projectionVector,e.x,-e.y);d.uniform2f(g.offsetVector, -f.x,-f.y);d.uniform3fv(g.tintColor,Phaser.Color.hexToRGBArray(c.tint));d.uniform3fv(g.color,a.color);d.uniform1f(g.alpha,c.worldAlpha*a.alpha);d.bindBuffer(d.ARRAY_BUFFER,a.buffer);d.vertexAttribPointer(g.aVertexPosition,2,d.FLOAT,!1,8,0)}else g=b.shaderManager.primitiveShader,b.shaderManager.setShader(g),d.uniformMatrix3fv(g.translationMatrix,!1,c.worldTransform.toArray(!0)),d.uniform1f(g.flipY,b.flipY),d.uniform2f(g.projectionVector,e.x,-e.y),d.uniform2f(g.offsetVector,-f.x,-f.y),d.uniform3fv(g.tintColor, Phaser.Color.hexToRGBArray(c.tint)),d.uniform1f(g.alpha,c.worldAlpha),d.bindBuffer(d.ARRAY_BUFFER,a.buffer),d.vertexAttribPointer(g.aVertexPosition,2,d.FLOAT,!1,24,0),d.vertexAttribPointer(g.colorAttribute,4,d.FLOAT,!1,24,8);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,a.indexBuffer)};h.WebGLStencilManager.prototype.popStencil=function(c,a,b){var d=this.gl;this.stencilStack.pop();this.count--;if(0===this.stencilStack.length)d.disable(d.STENCIL_TEST);else{var e=this.count;this.bindGraphics(c,a,b);d.colorMask(!1, !1,!1,!1);1===a.mode?((this.reverse=!this.reverse)?(d.stencilFunc(d.EQUAL,255-(e+1),255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)):(d.stencilFunc(d.EQUAL,e+1,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)),d.drawElements(d.TRIANGLE_FAN,4,d.UNSIGNED_SHORT,2*(a.indices.length-4)),d.stencilFunc(d.ALWAYS,0,255),d.stencilOp(d.KEEP,d.KEEP,d.INVERT),d.drawElements(d.TRIANGLE_FAN,a.indices.length-4,d.UNSIGNED_SHORT,0)):(this.reverse?(d.stencilFunc(d.EQUAL,e+1,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)):(d.stencilFunc(d.EQUAL, 255-(e+1),255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)),d.drawElements(d.TRIANGLE_STRIP,a.indices.length,d.UNSIGNED_SHORT,0));this.reverse?d.stencilFunc(d.EQUAL,e,255):d.stencilFunc(d.EQUAL,255-e,255);d.colorMask(!0,!0,!0,!0);d.stencilOp(d.KEEP,d.KEEP,d.KEEP)}};h.WebGLStencilManager.prototype.destroy=function(){this.gl=this.stencilStack=null};h.WebGLShaderManager=function(){this.maxAttibs=10;this.attribState=[];this.tempAttribState=[];for(var c=0;c=this.size&&(this.flush(), this.currentBaseTexture=b.baseTexture);if(a=b._uvs){e=c.anchor.x;var g=c.anchor.y;if(b.trim){var k=b.trim;e=k.x-e*k.width;d=e+b.crop.width;g=k.y-g*k.height;k=g+b.crop.height}else d=b.frame.width*(1-e),e=b.frame.width*-e,k=b.frame.height*(1-g),g=b.frame.height*-g;var m=this.currentBatchSize*this.vertexSize,l=b.baseTexture.resolution,n=b.baseTexture.textureIndex,q=f.a/l,t=f.b/l,r=f.c/l,v=f.d/l;l=f.tx;var u=f.ty,w=b.crop.height;if(b.rotated){r=f.a;v=f.b;var y=f.c,A=f.d,z=e,C=d;l=f.c*w+l;u=f.d*w+u;q= 6.123233995736766E-17*r+-y;t=6.123233995736766E-17*v+-A;r+=6.123233995736766E-17*y;v+=6.123233995736766E-17*A;b._updateUvsInverted();d=k;e=g;k=C;g=z}b=this.colors;f=this.positions;w=c.tint;w=(w>>16)+(w&65280)+((w&255)<<16)+(255*c.worldAlpha<<24);this.renderSession.roundPixels?(f[m++]=q*e+r*g+l|0,f[m++]=v*g+t*e+u|0,f[m++]=a.x0,f[m++]=a.y0,b[m++]=w,f[m++]=n,f[m++]=q*d+r*g+l|0,f[m++]=v*g+t*d+u|0,f[m++]=a.x1,f[m++]=a.y1,b[m++]=w,f[m++]=n,f[m++]=q*d+r*k+l|0,f[m++]=v*k+t*d+u|0,f[m++]=a.x2,f[m++]=a.y2,b[m++]= w,f[m++]=n,f[m++]=q*e+r*k+l|0,f[m++]=v*k+t*e+u|0):(f[m++]=q*e+r*g+l,f[m++]=v*g+t*e+u,f[m++]=a.x0,f[m++]=a.y0,b[m++]=w,f[m++]=n,f[m++]=q*d+r*g+l,f[m++]=v*g+t*d+u,f[m++]=a.x1,f[m++]=a.y1,b[m++]=w,f[m++]=n,f[m++]=q*d+r*k+l,f[m++]=v*k+t*d+u,f[m++]=a.x2,f[m++]=a.y2,b[m++]=w,f[m++]=n,f[m++]=q*e+r*k+l,f[m++]=v*k+t*e+u);f[m++]=a.x3;f[m++]=a.y3;b[m++]=w;f[m++]=n;this.sprites[this.currentBatchSize++]=c}};h.WebGLSpriteBatch.prototype.renderTilingSprite=function(c){var a=c.tilingTexture,b=a.baseTexture,d=this.gl, e=c.texture.baseTexture.textureIndex;h.WebGLRenderer.textureArray[e]!=b&&(this.flush(),d.activeTexture(d.TEXTURE0+e),d.bindTexture(d.TEXTURE_2D,b._glTextures[d.id]),h.WebGLRenderer.textureArray[e]=b);this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=a.baseTexture);c._uvs||(c._uvs=new h.TextureUvs);b=c._uvs;var f=a.baseTexture.width,g=a.baseTexture.height;c.tilePosition.x%=f*c.tileScaleOffset.x;c.tilePosition.y%=g*c.tileScaleOffset.y;d=c.tilePosition.x/(f*c.tileScaleOffset.x); var k=c.tilePosition.y/(g*c.tileScaleOffset.y);f=c.width/f/(c.tileScale.x*c.tileScaleOffset.x);g=c.height/g/(c.tileScale.y*c.tileScaleOffset.y);b.x0=0-d;b.y0=0-k;b.x1=1*f-d;b.y1=0-k;b.x2=1*f-d;b.y2=1*g-k;b.x3=0-d;b.y3=1*g-k;d=c.tint;d=(d>>16)+(d&65280)+((d&255)<<16)+(255*c.worldAlpha<<24);k=this.positions;g=this.colors;var m=c.width,l=c.height,n=c.anchor.x,q=c.anchor.y;f=m*(1-n);m*=-n;n=l*(1-q);l*=-q;q=this.currentBatchSize*this.vertexSize;var t=a.baseTexture.resolution,r=c.worldTransform;a=r.a/t; var v=r.b/t,u=r.c/t;t=r.d/t;var w=r.tx;r=r.ty;k[q++]=a*m+u*l+w;k[q++]=t*l+v*m+r;k[q++]=b.x0;k[q++]=b.y0;g[q++]=d;k[q++]=e;k[q++]=a*f+u*l+w;k[q++]=t*l+v*f+r;k[q++]=b.x1;k[q++]=b.y1;g[q++]=d;k[q++]=e;k[q++]=a*f+u*n+w;k[q++]=t*n+v*f+r;k[q++]=b.x2;k[q++]=b.y2;g[q++]=d;k[q++]=e;k[q++]=a*m+u*n+w;k[q++]=t*n+v*m+r;k[q++]=b.x3;k[q++]=b.y3;g[q++]=d;k[q++]=e;this.sprites[this.currentBatchSize++]=c};h.WebGLSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var c=this.gl;if(this.dirty){this.dirty= !1;var a=this.defaultShader.shaders[c.id];c.activeTexture(c.TEXTURE0);c.bindBuffer(c.ARRAY_BUFFER,this.vertexBuffer);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var b=this.vertexSize;c.vertexAttribPointer(a.aVertexPosition,2,c.FLOAT,!1,b,0);c.vertexAttribPointer(a.aTextureCoord,2,c.FLOAT,!1,b,8);c.vertexAttribPointer(a.colorAttribute,4,c.UNSIGNED_BYTE,!0,b,16);c.vertexAttribPointer(a.aTextureIndex,1,c.FLOAT,!1,b,20)}this.currentBatchSize>.5*this.size?c.bufferSubData(c.ARRAY_BUFFER,0,this.vertices): (c.bindBuffer(c.ARRAY_BUFFER,this.vertexBuffer),b=this.positions.subarray(0,this.currentBatchSize*this.vertexSize),c.bufferSubData(c.ARRAY_BUFFER,0,b));for(var d,e,f=b=0,g=null,k=this.renderSession.blendModeManager.currentBlendMode,m=null,p,n,q=0,t=this.currentBatchSize;q=this.size&&this.flush()}};h.WebGLFastSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var c= this.gl;if(this.currentBaseTexture._glTextures[c.id]){if(this.currentBatchSize>.5*this.size)c.bufferSubData(c.ARRAY_BUFFER,0,this.vertices);else{var a=this.vertices.subarray(0,4*this.currentBatchSize*this.vertSize);c.bufferSubData(c.ARRAY_BUFFER,0,a)}c.drawElements(c.TRIANGLES,6*this.currentBatchSize,c.UNSIGNED_SHORT,0);this.currentBatchSize=0;this.renderSession.drawCount++}else this.renderSession.renderer.updateTexture(this.currentBaseTexture,c)}};h.WebGLFastSpriteBatch.prototype.stop=function(){this.flush()}; h.WebGLFastSpriteBatch.prototype.start=function(){var c=this.gl;c.activeTexture(c.TEXTURE0);c.bindBuffer(c.ARRAY_BUFFER,this.vertexBuffer);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var a=this.renderSession.projection;c.uniform2f(this.shader.projectionVector,a.x,a.y);c.uniformMatrix3fv(this.shader.uMatrix,!1,this.matrix);a=4*this.vertSize;c.vertexAttribPointer(this.shader.aVertexPosition,2,c.FLOAT,!1,a,0);c.vertexAttribPointer(this.shader.aPositionCoord,2,c.FLOAT,!1,a,8);c.vertexAttribPointer(this.shader.aScale, 2,c.FLOAT,!1,a,16);c.vertexAttribPointer(this.shader.aRotation,1,c.FLOAT,!1,a,24);c.vertexAttribPointer(this.shader.aTextureCoord,2,c.FLOAT,!1,a,28);c.vertexAttribPointer(this.shader.colorAttribute,1,c.FLOAT,!1,a,36);c.vertexAttribPointer(this.shader.aTextureIndex,1,c.FLOAT,!1,a,40)};h.WebGLFilterManager=function(){this.filterStack=[];this.offsetY=this.offsetX=0};h.WebGLFilterManager.prototype.constructor=h.WebGLFilterManager;h.WebGLFilterManager.prototype.setContext=function(c){this.gl=c;this.texturePool= [];this.initShaderBuffers()};h.WebGLFilterManager.prototype.begin=function(c,a){this.renderSession=c;this.defaultShader=c.shaderManager.defaultShader;c=this.renderSession.projection;this.width=2*c.x;this.height=2*-c.y;this.buffer=a};h.WebGLFilterManager.prototype.pushFilter=function(c){var a=this.gl,b=this.renderSession.projection,d=this.renderSession.offset;c._filterArea=c.target.filterArea||c.target.getBounds();c._previous_stencil_mgr=this.renderSession.stencilManager;this.renderSession.stencilManager= new h.WebGLStencilManager;this.renderSession.stencilManager.setContext(a);a.disable(a.STENCIL_TEST);this.filterStack.push(c);var e=c.filterPasses[0];this.offsetX+=c._filterArea.x;this.offsetY+=c._filterArea.y;var f=this.texturePool.pop();f?f.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution):f=new h.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution);a.bindTexture(a.TEXTURE_2D,f.texture);var g=c._filterArea; e=e.padding;g.x-=e;g.y-=e;g.width+=2*e;g.height+=2*e;0>g.x&&(g.x=0);g.width>this.width&&(g.width=this.width);0>g.y&&(g.y=0);g.height>this.height&&(g.height=this.height);a.bindFramebuffer(a.FRAMEBUFFER,f.frameBuffer);a.viewport(0,0,g.width*this.renderSession.resolution,g.height*this.renderSession.resolution);b.x=g.width/2;b.y=-g.height/2;d.x=-g.x;d.y=-g.y;a.colorMask(!0,!0,!0,!0);a.clearColor(0,0,0,0);a.clear(a.COLOR_BUFFER_BIT);c._glFilterTexture=f};h.WebGLFilterManager.prototype.popFilter=function(){var c= this.gl,a=this.filterStack.pop(),b=a._filterArea,d=a._glFilterTexture,e=this.renderSession.projection,f=this.renderSession.offset;if(1this.baseTexture.width||c.y+c.height>this.baseTexture.height)){if(!h.TextureSilentFail)throw Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.valid=!1}else this.valid= c&&c.width&&c.height&&this.baseTexture.source&&this.baseTexture.hasLoaded,this.trim&&(this.width=this.trim.width,this.height=this.trim.height,this.frame.width=this.trim.width,this.frame.height=this.trim.height),this.valid&&this._updateUvs()};h.Texture.prototype._updateUvs=function(){this._uvs||(this._uvs=new h.TextureUvs);var c=this.crop,a=this.baseTexture.width,b=this.baseTexture.height;this._uvs.x0=c.x/a;this._uvs.y0=c.y/b;this._uvs.x1=(c.x+c.width)/a;this._uvs.y1=c.y/b;this._uvs.x2=(c.x+c.width)/ a;this._uvs.y2=(c.y+c.height)/b;this._uvs.x3=c.x/a;this._uvs.y3=(c.y+c.height)/b};h.Texture.prototype._updateUvsInverted=function(){this._uvs||(this._uvs=new h.TextureUvs);var c=this.crop,a=this.baseTexture.width,b=this.baseTexture.height;this._uvs.x0=c.x/a;this._uvs.y0=c.y/b;this._uvs.x1=(c.x+c.height)/a;this._uvs.y1=c.y/b;this._uvs.x2=(c.x+c.height)/a;this._uvs.y2=(c.y+c.width)/b;this._uvs.x3=c.x/a;this._uvs.y3=(c.y+c.width)/b};h.Texture.fromCanvas=function(c,a){c=h.BaseTexture.fromCanvas(c,a); return new h.Texture(c)};h.TextureUvs=function(){this.y3=this.x3=this.y2=this.x2=this.y1=this.x1=this.y0=this.x0=0};"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(exports=module.exports=h),exports.PIXI=h):"undefined"!==typeof define&&define.amd?define("PIXI",this.PIXI=h):this.PIXI=h;return h}).call(this); (function(){var c=c||{VERSION:"2.11.0",GAMES:[],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};"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(a){return 0>a?Math.ceil(a):Math.floor(a)});Function.prototype.bind||(Function.prototype.bind=function(){var a= Array.prototype.slice;return function(b){function d(){var f=c.concat(a.call(arguments));e.apply(this instanceof d?this:b,f)}var e=this,c=a.call(arguments,1);if("function"!==typeof e)throw new TypeError;d.prototype=function m(a){a&&(m.prototype=a);if(!(this instanceof m))return new m}(e.prototype);return d}}());Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)});Array.prototype.forEach||(Array.prototype.forEach=function(a){if(void 0===this||null=== this)throw new TypeError;var b=Object(this),d=b.length>>>0;if("function"!==typeof a)throw new TypeError;for(var e=2<=arguments.length?arguments[1]:void 0,c=0;cMath.random()?a:b},parseDimension:function(a,b){"string"===typeof a?"%"===a.substr(-1)?(a=parseInt(a,10)/100,b=0===b?window.innerWidth*a:window.innerHeight*a):b=parseInt(a,10):b=a;return b},pad:function(a,b,d,e){void 0===b&&(b=0);void 0===d&&(d=" ");void 0===e&&(e=3);a=a.toString();if(b+1>=a.length)switch(e){case 1:a=Array(b+1-a.length).join(d)+a; break;case 3:e=Math.ceil((b-=a.length)/2);a=Array(b-e+1).join(d)+a+Array(e+1).join(d);break;default:a+=Array(b+1-a.length).join(d)}return a},isPlainObject:function(a){if("object"!==typeof a||a.nodeType||a===a.window)return!1;try{if(a.constructor&&!{}.hasOwnProperty.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(b){return!1}return!0},extend:function(){var a,b,d,e=arguments[0]||{},f=1,g=arguments.length,k=!1;"boolean"===typeof e&&(k=e,e=arguments[1]||{},f=2);g===f&&(e=this,--f);for(;f< g;f++)if(null!=(a=arguments[f]))for(b in a){var m=e[b];var h=a[b];e!==h&&(k&&h&&(c.Utils.isPlainObject(h)||(d=Array.isArray(h)))?(d?(d=!1,m=m&&Array.isArray(m)?m:[]):m=m&&c.Utils.isPlainObject(m)?m:{},e[b]=c.Utils.extend(k,m,h)):void 0!==h&&(e[b]=h))}return e},mixinPrototype:function(a,b,d){void 0===d&&(d=!1);for(var e=Object.keys(b),c=0;cthis.x?this._diameter=this._radius=0:this.radius=this.x-a}});Object.defineProperty(c.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(a){athis.y?this._diameter=this._radius=0:this.radius=this.y-a}});Object.defineProperty(c.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(a){a=a.left&&b<=a.right&&d>=a.top&&d<=a.bottom?(a.x-b)*(a.x-b)+(a.y-d)*(a.y-d)<=a.radius*a.radius:!1};c.Circle.equals=function(a,b){return a.x===b.x&&a.y===b.y&&a.diameter===b.diameter};c.Circle.intersects=function(a,b){return c.Math.distance(a.x,a.y,b.x,b.y)<=a.radius+b.radius};c.Circle.circumferencePoint=function(a,b,d,e){void 0===d&&(d=!1);void 0===e&&(e=new c.Point);!0===d&&(b=c.Math.degToRad(b));e.x=a.x+a.radius*Math.cos(b); e.y=a.y+a.radius*Math.sin(b);return e};c.Circle.intersectsRectangle=function(a,b){var d=Math.abs(a.x-b.x-b.halfWidth);if(d>b.halfWidth+a.radius)return!1;var e=Math.abs(a.y-b.y-b.halfHeight);if(e>b.halfHeight+a.radius)return!1;if(d<=b.halfWidth||e<=b.halfHeight)return!0;d-=b.halfWidth;b=e-b.halfHeight;return d*d+b*b<=a.radius*a.radius};c.Circle.intersectsLine=function(a,b,d){var e=a.x,f=a.y,g=(b.end.y-b.start.y)/(b.end.x-b.start.x),k=b.end.y-g*b.end.x,m=a.radius,h=a.radius,n=k+g*e;a=(e*h*h-g*m*m*(k- f)+m*h*Math.sqrt(m*m*g*g+h*h-n*n-f*f+2*n*f))/(m*m*g*g+h*h);e=(e*h*h-g*m*m*(k-f)-m*h*Math.sqrt(m*m*g*g+h*h-n*n-f*f+2*n*f))/(m*m*g*g+h*h);f=g*e+k;g=new c.Point(a,g*a+k);k=new c.Point(e,f);a=b.pointOnSegment(g.x,g.y,.01);b=b.pointOnSegment(k.x,k.y,.01);return a&&b?d?[g,k]:!0:a?d?[g]:!0:b?d?[k]:!0:d?[]:!1};PIXI.Circle=c.Circle;c.Ellipse=function(a,b,d,e){this.x=a||0;this.y=b||0;this.width=d||0;this.height=e||0;this.type=c.ELLIPSE};c.Ellipse.prototype={setTo:function(a,b,d,e){this.x=a;this.y=b;this.width= d;this.height=e;return this},getBounds:function(){return new c.Rectangle(this.x-this.width,this.y-this.height,this.width,this.height)},copyFrom:function(a){return this.setTo(a.x,a.y,a.width,a.height)},copyTo:function(a){a.x=this.x;a.y=this.y;a.width=this.width;a.height=this.height;return a},clone:function(a){void 0===a||null===a?a=new c.Ellipse(this.x,this.y,this.width,this.height):a.setTo(this.x,this.y,this.width,this.height);return a},contains:function(a,b){return c.Ellipse.contains(this,a,b)}, random:function(a){void 0===a&&(a=new c.Point);var b=Math.random()*Math.PI*2,d=Math.sqrt(Math.random());a.x=this.centerX+.5*d*Math.cos(b)*this.width;a.y=this.centerY+.5*d*Math.sin(b)*this.height;return a},toString:function(){return"[{Phaser.Ellipse (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")}]"}};c.Ellipse.prototype.constructor=c.Ellipse;Object.defineProperty(c.Ellipse.prototype,"left",{get:function(){return this.x},set:function(a){this.x=a}});Object.defineProperty(c.Ellipse.prototype, "right",{get:function(){return this.x+this.width},set:function(a){this.width=a=a.width||0>=a.height)return!1;b=(b-a.x)/a.width-.5;a=(d-a.y)/a.height-.5;return.25>b*b+a*a};c.Ellipse.intersectsLine=function(a,b,d){var e=a.x,f=a.y,g=(b.end.y-b.start.y)/(b.end.x-b.start.x),k=b.end.y-g*b.end.x,m=a.width/2,h=a.height/2,n=k+g*e;a=(e*h*h-g*m*m* (k-f)+m*h*Math.sqrt(m*m*g*g+h*h-n*n-f*f+2*n*f))/(m*m*g*g+h*h);e=(e*h*h-g*m*m*(k-f)-m*h*Math.sqrt(m*m*g*g+h*h-n*n-f*f+2*n*f))/(m*m*g*g+h*h);f=g*e+k;g=new c.Point(a,g*a+k);k=new c.Point(e,f);a=b.pointOnSegment(g.x,g.y,.01);b=b.pointOnSegment(k.x,k.y,.01);return a&&b?d?[g,k]:!0:a?d?[g]:!0:b?d?[k]:!0:d?[]:!1};PIXI.Ellipse=c.Ellipse;c.Line=function(a,b,d,e){d=d||0;e=e||0;this.start=new c.Point(a||0,b||0);this.end=new c.Point(d,e);this.type=c.LINE};c.Line.prototype={setTo:function(a,b,d,e){this.start.setTo(a, b);this.end.setTo(d,e);return this},fromPoints:function(a,b){this.setTo(a.x,a.y,b.x,b.y);return this},fromSprite:function(a,b,d){void 0===d&&(d=!1);return d?this.setTo(a.centerX,a.centerY,b.centerX,b.centerY):this.fromPoints(a,b)},fromAngle:function(a,b,d,e){this.start.setTo(a,b);this.end.setTo(a+Math.cos(d)*e,b+Math.sin(d)*e);return this},rotate:function(a,b){var d=(this.start.x+this.end.x)/2,e=(this.start.y+this.end.y)/2;this.start.rotate(d,e,a,b);this.end.rotate(d,e,a,b);return this},rotateAround:function(a, b,d,e){this.start.rotate(a,b,d,e);this.end.rotate(a,b,d,e);return this},intersects:function(a,b,d){return c.Line.intersectsPoints(this.start,this.end,a.start,a.end,b,d)},reflect:function(a){return c.Line.reflect(this,a)},midPoint:function(a){void 0===a&&(a=new c.Point);a.x=(this.start.x+this.end.x)/2;a.y=(this.start.y+this.end.y)/2;return a},centerOn:function(a,b){a-=(this.start.x+this.end.x)/2;b-=(this.start.y+this.end.y)/2;this.start.add(a,b);this.end.add(a,b)},pointOnLine:function(a,b,d){return c.Math.fuzzyEqual((a- this.start.x)*(this.end.y-this.start.y),(this.end.x-this.start.x)*(b-this.start.y),d||0)},pointOnSegment:function(a,b,d){var e=Math.min(this.start.x,this.end.x),c=Math.max(this.start.x,this.end.x),g=Math.min(this.start.y,this.end.y),k=Math.max(this.start.y,this.end.y);return this.pointOnLine(a,b,d)&&a>=e&&a<=c&&b>=g&&b<=k},random:function(a){void 0===a&&(a=new c.Point);var b=Math.random();a.x=this.start.x+b*(this.end.x-this.start.x);a.y=this.start.y+b*(this.end.y-this.start.y);return a},coordinatesOnLine:function(a, b){void 0===a&&(a=1);void 0===b&&(b=[]);var d=Math.round(this.start.x),e=Math.round(this.start.y),c=Math.round(this.end.x),g=Math.round(this.end.y),k=Math.abs(c-d),m=Math.abs(g-e),h=d-m&&(l-=m,d+=h);r=e&&0<=a&&1>=a)?g:null};c.Line.intersects=function(a,b,d,e){return c.Line.intersectsPoints(a.start,a.end,b.start,b.end,d,e)};c.Line.intersectsRectangle=function(a,b){if(0===a.length||b.empty)return!1;var d=a.start.x,e=a.start.y,c=a.end.x;a=a.end.y;var g=b.x,k=b.y,m=b.right;b=b.bottom;if(d>=g&&d<=m&&e>=k&&e<=b||c>=g&&c<=m&&a>=k&&a<=b)return!0;if(d=g){var h= e+(a-e)*(g-d)/(c-d);if(h>k&&h<=b)return!0}else if(d>m&&c<=m&&(h=e+(a-e)*(m-d)/(c-d),h>=k&&h<=b))return!0;if(e=k){if(h=d+(c-d)*(k-e)/(a-e),h>=g&&h<=m)return!0}else if(e>b&&a<=b&&(h=d+(c-d)*(b-e)/(a-e),h>=g&&h<=m))return!0;return!1};c.Line.intersectionWithRectangle=function(a,b,d){var e=c.Line.intersectionWithRectangle;d||(d=new c.Point);e.edges||(e.edges=[new c.Line,new c.Line,new c.Line,new c.Line]);e.edgeIntersection||(e.edgeIntersection=new c.Point);var f=e.edges;e=e.edgeIntersection.set(0); var g=b.x,k=b.y,m=b.right,h=b.bottom;b=Infinity;f[0].setTo(g,k,m,k);f[1].setTo(g,h,m,h);f[2].setTo(g,k,g,h);f[3].setTo(m,k,m,h);for(k=0;g=f[k];k++)if(a.intersects(g,!0,e)){var n=a.start.distance(e);ne&&(this.x=e);this.ya&&(this.y=a);return this},clone:function(a){void 0===a||null===a?a=new c.Point(this.x,this.y):a.setTo(this.x,this.y);return a},copyTo:function(a){a.x=this.x;a.y=this.y; return a},distance:function(a,b){return c.Point.distance(this,a,b)},equals:function(a){return a.x===this.x&&a.y===this.y},equalsXY:function(a,b){return this.x===a&&this.y===b},fuzzyEquals:function(a,b){return c.Point.fuzzyEquals(this,a,b)},fuzzyEqualsXY:function(a,b,d){return c.Point.fuzzyEqualsXY(this,a,b,d)},angle:function(a,b){return this.angleXY(a.x,a.y,b)},angleXY:function(a,b,d){a=Math.atan2(b-this.y,a-this.x);return d?c.Math.radToDeg(a):a},atan:function(a){var b=Math.atan2(this.y,this.x);return a? c.Math.radToDeg(b):b},rotate:function(a,b,d,e,f){return c.Point.rotate(this,a,b,d,e,f)},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(a){return this.normalize().multiply(a,a)},normalize:function(){if(!this.isZero()){var a=this.getMagnitude();this.x/=a;this.y/=a}return this},limit:function(a){this.getMagnitudeSq()>a*a&&this.setMagnitude(a);return this},expand:function(a){this.getMagnitudeSq()< a*a&&this.setMagnitude(a);return this},isZero:function(){return 0===this.x&&0===this.y},dot:function(a){return this.x*a.x+this.y*a.y},cross:function(a){return this.x*a.y-this.y*a.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+")}]"}};c.Point.prototype.constructor=c.Point;c.Point.add=function(a,b,d){void 0===d&&(d=new c.Point);d.x=a.x+b.x;d.y=a.y+b.y;return d};c.Point.subtract=function(a,b,d){void 0===d&&(d=new c.Point);d.x=a.x-b.x;d.y=a.y-b.y;return d};c.Point.multiply=function(a,b,d){void 0===d&&(d=new c.Point);d.x=a.x*b.x;d.y=a.y*b.y;return d};c.Point.divide=function(a,b,d){void 0===d&&(d=new c.Point);d.x=a.x/b.x;d.y=a.y/b.y;return d};c.Point.equals= function(a,b){return a.x===b.x&&a.y===b.y};c.Point.equalsXY=function(a,b,d){return a.x===b&&a.y===d};c.Point.fuzzyEquals=function(a,b,d){return c.Math.fuzzyEquals(a.x,b.x,d)&&c.Math.fuzzyEquals(a.y,b.y,d)};c.Point.fuzzyEqualsXY=function(a,b,d,e){return c.Math.fuzzyEquals(a.x,b,e)&&c.Math.fuzzyEquals(a.y,d,e)};c.Point.angle=function(a,b){return Math.atan2(a.y-b.y,a.x-b.x)};c.Point.negative=function(a,b){void 0===b&&(b=new c.Point);return b.setTo(-a.x,-a.y)};c.Point.multiplyAdd=function(a,b,d,e){void 0=== e&&(e=new c.Point);return e.setTo(a.x+b.x*d,a.y+b.y*d)};c.Point.interpolate=function(a,b,d,e){void 0===e&&(e=new c.Point);return e.setTo(a.x+(b.x-a.x)*d,a.y+(b.y-a.y)*d)};c.Point.perp=function(a,b){void 0===b&&(b=new c.Point);return b.setTo(-a.y,a.x)};c.Point.rperp=function(a,b){void 0===b&&(b=new c.Point);return b.setTo(a.y,-a.x)};c.Point.distance=function(a,b,d){a=c.Math.distance(a.x,a.y,b.x,b.y);return d?Math.round(a):a};c.Point.project=function(a,b,d){void 0===d&&(d=new c.Point);a=a.dot(b)/b.getMagnitudeSq(); 0!==a&&d.setTo(a*b.x,a*b.y);return d};c.Point.projectUnit=function(a,b,d){void 0===d&&(d=new c.Point);a=a.dot(b);0!==a&&d.setTo(a*b.x,a*b.y);return d};c.Point.normalRightHand=function(a,b){void 0===b&&(b=new c.Point);return b.setTo(-1*a.y,a.x)};c.Point.normalize=function(a,b){void 0===b&&(b=new c.Point);var d=a.getMagnitude();0!==d&&b.setTo(a.x/d,a.y/d);return b};c.Point.rotate=function(a,b,d,e,f,g){f&&(e=c.Math.degToRad(e));void 0===g?(a.subtract(b,d),g=Math.sin(e),e=Math.cos(e),f=g*a.x+e*a.y,a.x= e*a.x-g*a.y+b,a.y=f+d):(e+=Math.atan2(a.y-d,a.x-b),a.x=b+g*Math.cos(e),a.y=d+g*Math.sin(e));return a};c.Point.centroid=function(a,b){void 0===b&&(b=new c.Point);if("[object Array]"!==Object.prototype.toString.call(a))throw Error("Phaser.Point. Parameter 'points' must be an array");var d=a.length;if(1>d)throw Error("Phaser.Point. Parameter 'points' array must not be empty");if(1===d)return b.copyFrom(a[0]),b;for(var e=0;eb.x-d)return-1;if(0>a.x-d&&0<= b.x-d)return 1;if(0===a.x-d&&0===b.x-d)return 0<=a.y-e||0<=b.y-e?a.y>b.y?1:-1:b.y>a.y?1:-1;var c=(a.x-d)*-(b.y-e)-(b.x-d)*-(a.y-e);return 0>c?-1:0(b.x-d)*(b.x-d)+(b.y-e)*(b.y-e)?-1:1})};PIXI.Point=c.Point;c.Polygon=function(){this.area=0;this._points=[];0=this.right?0:this.right-a;this.x=a}});Object.defineProperty(c.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(a){this.width=a<=this.x?0:a-this.x}});Object.defineProperty(c.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}});Object.defineProperty(c.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}});Object.defineProperty(c.Rectangle.prototype,"centerX",{get:function(){return this.x+ this.halfWidth},set:function(a){this.x=a-this.halfWidth}});Object.defineProperty(c.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(a){this.y=a-this.halfHeight}});Object.defineProperty(c.Rectangle.prototype,"randomX",{get:function(){return this.x+Math.random()*this.width}});Object.defineProperty(c.Rectangle.prototype,"randomY",{get:function(){return this.y+Math.random()*this.height}});Object.defineProperty(c.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(c.Rectangle.prototype,"topLeft",{get:function(){return new c.Point(this.x,this.y)},set:function(a){this.x=a.x;this.y=a.y}});Object.defineProperty(c.Rectangle.prototype,"topRight",{get:function(){return new c.Point(this.x+this.width,this.y)},set:function(a){this.right=a.x;this.y=a.y}});Object.defineProperty(c.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(a){!0=== a&&this.setTo(0,0,0,0)}});c.Rectangle.prototype.constructor=c.Rectangle;c.Rectangle.inflate=function(a,b,d){a.x-=b;a.width+=2*b;a.y-=d;a.height+=2*d;return a};c.Rectangle.inflatePoint=function(a,b){return c.Rectangle.inflate(a,b.x,b.y)};c.Rectangle.size=function(a,b){void 0===b||null===b?b=new c.Point(a.width,a.height):b.setTo(a.width,a.height);return b};c.Rectangle.clone=function(a,b){void 0===b||null===b?b=new c.Rectangle(a.x,a.y,a.width,a.height):b.setTo(a.x,a.y,a.width,a.height);return b};c.Rectangle.createFromBounds= function(a,b){if(void 0===b||null===b)b=new c.Rectangle(a.x,a.y,a.width,a.height);return b.copyFromBounds(a)};c.Rectangle.contains=function(a,b,d){return 0>=a.width||0>=a.height?!1:b>=a.x&&b=a.y&&d=a&&c=b&&gb.volume?!1:a.x>=b.x&&a.y>=b.y&&a.right=a.width||0>=a.height||0>=b.width|| 0>=b.height?!1:!(a.rightb.right||a.y>b.bottom)};c.Rectangle.intersectsRaw=function(a,b,d,e,c,g){void 0===g&&(g=0);return!(b>a.right+g||da.bottom+g||cd&&(d=a.x);a.xf&&(f=a.y);a.y=this.width||0>=this.height)return!1;var d=this.x;return a>=d&&a<=d+this.width&&(a=this.y,b>=a&&b<=a+this.height)?!0:!1}};c.RoundedRectangle.prototype.constructor=c.RoundedRectangle;PIXI.RoundedRectangle=c.RoundedRectangle;c.Camera=function(a,b,d,e,f,g){this.game=a;this.world=a.world;this.id=0;this.view=new c.Rectangle(d,e,f,g);this.bounds=new c.Rectangle(d,e,f,g);this.deadzone= null;this.roundPx=this.visible=!0;this.atLimit={x:!1,y:!1};this.scale=this.displayObject=this.target=null;this.totalInView=0;this.lerp=new c.Point(1,1);this.onShakeComplete=new c.Signal;this.onFlashComplete=new c.Signal;this.onFadeComplete=new c.Signal;this.fx=null;this._targetPosition=new c.Point;this._edge=0;this._position=new c.Point;this._shake={intensity:0,duration:0,horizontal:!1,vertical:!1,shakeBounds:!0,x:0,y:0};this._fxType=this._fxDuration=0;this._fixedView=new c.Rectangle};c.Camera.FOLLOW_LOCKON= 0;c.Camera.FOLLOW_PLATFORMER=1;c.Camera.FOLLOW_TOPDOWN=2;c.Camera.FOLLOW_TOPDOWN_TIGHT=3;c.Camera.SHAKE_BOTH=4;c.Camera.SHAKE_HORIZONTAL=5;c.Camera.SHAKE_VERTICAL=6;c.Camera.ENABLE_FX=!0;c.Camera.prototype={boot:function(){this.displayObject=this.game.world;this.scale=this.game.world.scale;this.game.camera=this;c.Graphics&&c.Camera.ENABLE_FX&&(this.fx=new c.Graphics(this.game),this.game.stage.addChild(this.fx))},preUpdate:function(){this.totalInView=0},follow:function(a,b,d,e){void 0===b&&(b=c.Camera.FOLLOW_LOCKON); void 0===d&&(d=1);void 0===e&&(e=1);this.target=a;this.lerp.set(d,e);switch(b){case c.Camera.FOLLOW_PLATFORMER:a=this.width/8;b=this.height/3;this.deadzone=new c.Rectangle((this.width-a)/2,(this.height-b)/2-.25*b,a,b);break;case c.Camera.FOLLOW_TOPDOWN:a=Math.max(this.width,this.height)/4;this.deadzone=new c.Rectangle((this.width-a)/2,(this.height-a)/2,a,a);break;case c.Camera.FOLLOW_TOPDOWN_TIGHT:a=Math.max(this.width,this.height)/8;this.deadzone=new c.Rectangle((this.width-a)/2,(this.height-a)/ 2,a,a);break;case c.Camera.FOLLOW_LOCKON:this.deadzone=null;break;default:this.deadzone=null}},unfollow:function(){this.target=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))},shake:function(a,b,d,e,f){void 0===a&&(a=.05);void 0===b&&(b=500);void 0===d&&(d=!0);void 0===e&&(e=c.Camera.SHAKE_BOTH);void 0===f&&(f=!0);if(!d&& 0=this.fx.alpha&&(this._fxDuration=0,this.fx.alpha=0,this.onFlashComplete.dispatch())):(this.fx.alpha+=this.game.time.elapsedMS/this._fxDuration,1<=this.fx.alpha&&(this._fxDuration= 0,this.fx.alpha=1,this.onFadeComplete.dispatch()))},updateShake:function(){this._shake.duration-=this.game.time.elapsedMS;0>=this._shake.duration?(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._edgethis.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._edgethis.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 a=this.view.right+this._shake.x,b=this.view.y+this._shake.y,d=this.view.bottom+this._shake.y;this.view.x+this._shake.x<=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)):a>=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));b<=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)):d>=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(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},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}};c.Camera.prototype.constructor=c.Camera;Object.defineProperty(c.Camera.prototype,"x",{get:function(){return this.view.x},set:function(a){this.view.x=a;this.bounds&&this.checkBounds()}});Object.defineProperty(c.Camera.prototype, "y",{get:function(){return this.view.y},set:function(a){this.view.y=a;this.bounds&&this.checkBounds()}});Object.defineProperty(c.Camera.prototype,"position",{get:function(){this._position.set(this.view.x,this.view.y);return this._position},set:function(a){"undefined"!==typeof a.x&&(this.view.x=a.x);"undefined"!==typeof a.y&&(this.view.y=a.y);this.bounds&&this.checkBounds()}});Object.defineProperty(c.Camera.prototype,"width",{get:function(){return this.view.width},set:function(a){this.view.width=a}}); Object.defineProperty(c.Camera.prototype,"height",{get:function(){return this.view.height},set:function(a){this.view.height=a}});Object.defineProperty(c.Camera.prototype,"shakeIntensity",{get:function(){return this._shake.intensity},set:function(a){this._shake.intensity=a}});Object.defineProperty(c.Camera.prototype,"fixedView",{get:function(){this._fixedView.setTo(0,0,this.view.width,this.view.height);return this._fixedView}});c.State=function(){this.game=null;this.key="";this.rnd=this.physics=this.particles= this.world=this.tweens=this.time=this.state=this.stage=this.scale=this.sound=this.math=this.load=this.input=this.cache=this.camera=this.make=this.add=null};c.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(){}};c.State.prototype.constructor= c.State;c.StateManager=function(a,b){this.game=a;this.states={};this._pendingState=null;"undefined"!==typeof b&&null!==b&&(this._pendingState=b);this._created=this._clearCache=this._clearWorld=!1;this._args=[];this.current="";this.onStateChange=new c.Signal;this.onShutDownCallback=this.onPauseUpdateCallback=this.onResumedCallback=this.onPausedCallback=this.onLoadRenderCallback=this.onLoadUpdateCallback=this.onPreRenderCallback=this.onResizeCallback=this.onRenderCallback=this.onUpdateCallback=this.onCreateCallback= this.onPreloadCallback=this.onInitCallback=null};c.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(a,b,d){void 0===d&&(d=!1);if(b instanceof c.State)var e=b;else"object"===typeof b?(e=b,e.game=this.game):"function"===typeof b&&(e=new b(this.game));this.states[a]=e;d&&(this.game.isBooted?this.start(a):this._pendingState= a);return e},remove:function(a){this.current===a&&(this.onPauseUpdateCallback=this.onResumedCallback=this.onPausedCallback=this.onResizeCallback=this.onRenderCallback=this.onPreRenderCallback=this.onUpdateCallback=this.onCreateCallback=this.onLoadUpdateCallback=this.onLoadRenderCallback=this.onPreloadCallback=this.onShutDownCallback=this.onInitCallback=this.callbackContext=null);delete this.states[a]},start:function(a,b,d){void 0===b&&(b=!0);void 0===d&&(d=!1);this.checkState(a)&&(this._pendingState= a,this._clearWorld=b,this._clearCache=d,3a||a>=this.children.length?-1:this.getChildAt(a)};c.Group.prototype.create=function(a,b,d,c,f,g){void 0===f&&(f=!0);a=new this.classType(this.game,a,b,d,c);a.exists=f;a.visible=f;a.alive=f;return this.add(a,!1,g)};c.Group.prototype.createMultiple=function(a,b,d,c,f,g){void 0===d&&(d=0);void 0===c&&(c=!1);Array.isArray(b)||(b=[b]);Array.isArray(d)||(d= [d]);var e=this,m=[];b.forEach(function(b){d.forEach(function(d){for(var k=0;kthis.children.length||-1===a&&-1===b)return!1;for(var k=new c.Rectangle(0,0,d,e),m=a*d,h=b*e;gthis.children.length-1&&(a=0);if(this.cursor)return this.cursorIndex=a,this.cursor=this.children[this.cursorIndex]};c.Group.prototype.next=function(){if(this.cursor)return this.cursorIndex>=this.children.length-1?this.cursorIndex=0:this.cursorIndex++, this.cursor=this.children[this.cursorIndex]};c.Group.prototype.previous=function(){if(this.cursor)return 0===this.cursorIndex?this.cursorIndex=this.children.length-1:this.cursorIndex--,this.cursor=this.children[this.cursorIndex]};c.Group.prototype.swap=function(a,b){this.swapChildren(a,b);this.updateZ()};c.Group.prototype.bringToTop=function(a){a.parent===this&&this.getIndex(a)a||a>this.children.length)return-1;this.getChildAt(a).x=b;this.getChildAt(a).y=d};c.Group.prototype.reverse=function(){this.children.reverse();this.updateZ()};c.Group.prototype.getIndex=function(a){return this.children.indexOf(a)};c.Group.prototype.getByName=function(a){for(var b=0;b=b&&(a=b-1);b=this.children[a];this.updateOnlyExistingChildren&&!b.exists||b.update()}};c.Group.prototype.postUpdate=function(){this.fixedToCamera&&(this.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y);for(var a=0;a=arguments.length)for(var c=0;cthis.children.length||(void 0===a&&(a="z"),void 0===b&&(b=c.Group.SORT_ASCENDING),this._sortProperty=a,b===c.Group.SORT_ASCENDING?this.children.sort(this.ascendingSortHandler.bind(this)):this.children.sort(this.descendingSortHandler.bind(this)),this.updateZ())};c.Group.prototype.customSort=function(a,b){2>this.children.length||(this.children.sort(a.bind(b)),this.updateZ())};c.Group.prototype.ascendingSortHandler=function(a,b){return a[this._sortProperty] b[this._sortProperty]?1:a.zb[this._sortProperty]?-1:0};c.Group.prototype.iterate=function(a,b,d,e,f,g){if(0===this.children.length){if(d===c.Group.RETURN_TOTAL)return 0;if(d===c.Group.RETURN_ALL)return[]}var k=0;if(d===c.Group.RETURN_ALL)var m=[];for(var h=0;he&&(!b||b.call(d,m,f))&&(e=f,g=m))}return g};c.Group.prototype.count=function(a,b){return this.iterate(a,b,c.Group.RETURN_TOTAL)};c.Group.prototype.countLiving=function(){return this.count("alive",!0)};c.Group.prototype.countDead=function(){return this.count("alive",!1)};c.Group.prototype.getRandom=function(a,b){void 0===a&&(a=0);void 0===b&&(b=this.children.length);return 0===b?null:c.ArrayUtils.getRandomItem(this.children,a,b)};c.Group.prototype.getRandomExists= function(a,b){a=this.getAll("exists",!0,a,b);return this.game.rnd.pick(a)};c.Group.prototype.getAll=function(a,b,d,c){void 0===d&&(d=0);void 0===c&&(c=this.children.length);for(var e=[];db||0>a||b>this.children.length)return!1;for(;b>=a;){if(!c&&this.children[b].events)this.children[b].events.onRemovedFromGroup$dispatch(this.children[b],this);var e=this.removeChild(this.children[b]); this.removeFromHash(e);d&&e&&e.destroy(!0);this.cursor===this.children[b]&&(this.cursor=null);b--}this.updateZ()}};c.Group.prototype.scatter=function(a,b){null==a&&(a=this.game.world.bounds);this.forEach(function(b){b.position.set(a.randomX,a.randomY)},null,b)};c.Group.prototype.shuffle=function(){c.ArrayUtils.shuffle(this.children);this.updateZ()};c.Group.prototype.destroy=function(a,b){null===this.game||this.ignoreDestroy||(void 0===a&&(a=!0),void 0===b&&(b=!1),this.onDestroy.dispatch(this,a,b), this.removeAll(a),this.filters=this.cursor=null,this.pendingDestroy=!1,b||(this.parent&&this.parent.removeChild(this),this.game=null,this.exists=!1))};Object.defineProperty(c.Group.prototype,"total",{get:function(){return this.iterate("exists",!0,c.Group.RETURN_TOTAL)}});Object.defineProperty(c.Group.prototype,"length",{get:function(){return this.children.length}});Object.defineProperty(c.Group.prototype,"angle",{get:function(){return c.Math.radToDeg(this.rotation)},set:function(a){this.rotation= c.Math.degToRad(a)}});Object.defineProperty(c.Group.prototype,"centerX",{get:function(){return this.getBounds(this.parent).centerX},set:function(a){var b=this.getBounds(this.parent);this.x=a+(this.x-b.x)-b.halfWidth}});Object.defineProperty(c.Group.prototype,"centerY",{get:function(){return this.getBounds(this.parent).centerY},set:function(a){var b=this.getBounds(this.parent);this.y=a+(this.y-b.y)-b.halfHeight}});Object.defineProperty(c.Group.prototype,"left",{get:function(){return this.getBounds(this.parent).left}, set:function(a){var b=this.getBounds(this.parent);this.x=a+(this.x-b.x)}});Object.defineProperty(c.Group.prototype,"right",{get:function(){return this.getBounds(this.parent).right},set:function(a){var b=this.getBounds(this.parent);this.x=a+(this.x-b.x)-b.width}});Object.defineProperty(c.Group.prototype,"top",{get:function(){return this.getBounds(this.parent).top},set:function(a){var b=this.getBounds(this.parent);this.y=a+(this.y-b.y)}});Object.defineProperty(c.Group.prototype,"bottom",{get:function(){return this.getBounds(this.parent).bottom}, set:function(a){var b=this.getBounds(this.parent);this.y=a+(this.y-b.y)-b.height}});c.World=function(a){c.Group.call(this,a,null,"__world",!1);this.bounds=new c.Rectangle(0,0,a.width,a.height);this.camera=null;this._definedSize=!1;this._width=a.width;this._height=a.height;this.game.state.onStateChange.add(this.stateChange,this)};c.World.prototype=Object.create(c.Group.prototype);c.World.prototype.constructor=c.World;c.World.prototype.boot=function(){this.camera=new c.Camera(this.game,0,0,0,this.game.width, this.game.height);this.game.stage.addChild(this);this.camera.boot()};c.World.prototype.stateChange=function(){this.y=this.x=0;this.camera.reset()};c.World.prototype.setBounds=function(a,b,d,c){this._definedSize=!0;this._width=d;this._height=c;this.bounds.setTo(a,b,d,c);this.x=a;this.y=b;this.camera.bounds&&this.camera.bounds.setTo(a,b,Math.max(d,this.game.width),Math.max(c,this.game.height));this.game.physics.setBoundsToWorld()};c.World.prototype.resize=function(a,b){this._definedSize&&(athis.bounds.right&&(a.x=this.bounds.left)),f&&(a.y+a._currentBounds.height< this.bounds.top?a.y=this.bounds.bottom:a.y>this.bounds.bottom&&(a.y=this.bounds.top))):(c&&a.x+bthis.bounds.right&&(a.x=this.bounds.left-b),f&&a.y+bthis.bounds.bottom&&(a.y=this.bounds.top-b))};c.World.prototype.wrapAll=function(a,b,d,c,f,g){a.forEach(this.wrap,this,b,d,c,f,g)};Object.defineProperty(c.World.prototype,"width",{get:function(){return this.bounds.width},set:function(a){athis.bounds.x?this.game.rnd.between(this.bounds.x,this.bounds.width-Math.abs(this.bounds.x)):this.game.rnd.between(this.bounds.x,this.bounds.width)}});Object.defineProperty(c.World.prototype,"randomY",{get:function(){return 0>this.bounds.y?this.game.rnd.between(this.bounds.y,this.bounds.height-Math.abs(this.bounds.y)):this.game.rnd.between(this.bounds.y,this.bounds.height)}});c.Game=function(a,b,d,e,f,g,k,m){this.id=c.GAMES.push(this)- 1;this.config=null;this.physicsConfig=m;this.parent="";this.width=800;this.height=600;this.resolution=1;this._width=800;this._height=600;this.transparent=!1;this.antialias=!0;this.preserveDrawingBuffer=this.multiTexture=!1;this.clearBeforeRender=!0;this.renderer=null;this.renderType=c.AUTO;this.state=null;this.isRunning=this.isBooted=!1;this.rnd=this.plugins=this.physics=this.world=this.tweens=this.time=this.stage=this.sound=this.scale=this.net=this.math=this.load=this.input=this.cache=this.make= this.add=this.raf=null;this.device=c.Device;this.create=this.particles=this.debug=this.context=this.canvas=this.camera=null;this.pendingStep=this.stepping=this.pendingDestroy=this.lockRender=!1;this.stepCount=0;this.onFocus=this.onBlur=this.onResume=this.onPause=null;this._codePaused=this._paused=!1;this.currentUpdateID=0;this.rendersThisFrame=this.updatesThisFrame=1;this._spiraling=this._lastCount=this._deltaTime=0;this._kickstart=!0;this.fpsProblemNotifier=new c.Signal;this.forceSingleRender=this.forceSingleUpdate= !0;this.dropFrames=!1;this._nextFpsNotification=0;1===arguments.length&&"object"===typeof arguments[0]?this.parseConfig(arguments[0]):(this.config={enableDebug:!0},"undefined"!==typeof a&&(this._width=a),"undefined"!==typeof b&&(this._height=b),"undefined"!==typeof d&&(this.renderType=d),"undefined"!==typeof e&&(this.parent=e),"undefined"!==typeof g&&(this.transparent=g),"undefined"!==typeof k&&(this.antialias=k),this.rnd=new c.RandomDataGenerator([(Date.now()*Math.random()).toString()]),this.state= new c.StateManager(this,f));this.device.whenReady(this.boot,this);return this};c.Game.prototype={parseConfig:function(a){this.config=a;void 0===a.enableDebug&&(this.config.enableDebug=!0);a.width&&(this._width=a.width);a.height&&(this._height=a.height);a.renderer&&(this.renderType=a.renderer);a.parent&&(this.parent=a.parent);void 0!==a.transparent&&(this.transparent=a.transparent);void 0!==a.antialias&&(this.antialias=a.antialias);void 0!==a.clearBeforeRender&&(this.clearBeforeRender=a.clearBeforeRender); void 0!==a.multiTexture&&(this.multiTexture=a.multiTexture);a.resolution&&(this.resolution=a.resolution);void 0!==a.preserveDrawingBuffer&&(this.preserveDrawingBuffer=a.preserveDrawingBuffer);a.physicsConfig&&(this.physicsConfig=a.physicsConfig);var b=[(Date.now()*Math.random()).toString()];a.seed&&(b=a.seed);this.rnd=new c.RandomDataGenerator(b);b=null;a.state&&(b=a.state);this.state=new c.StateManager(this,b)},boot:function(){this.isBooted||(this.onPause=new c.Signal,this.onResume=new c.Signal, this.onBlur=new c.Signal,this.onFocus=new c.Signal,this.isBooted=!0,PIXI.game=this,this.math=c.Math,this.scale=new c.ScaleManager(this,this._width,this._height),this.stage=new c.Stage(this),this.setUpRenderer(),this.world=new c.World(this),this.add=new c.GameObjectFactory(this),this.make=new c.GameObjectCreator(this),this.cache=new c.Cache(this),this.load=new c.Loader(this),this.time=new c.Time(this),this.tweens=new c.TweenManager(this),this.input=new c.Input(this),this.sound=new c.SoundManager(this), this.physics=new c.Physics(this,this.physicsConfig),this.particles=new c.Particles(this),this.create=new c.Create(this),this.plugins=new c.PluginManager(this),this.net=new c.Net(this),this.time.boot(),this.stage.boot(),this.world.boot(),this.scale.boot(),this.input.boot(this.config),this.sound.boot(),this.state.boot(),this.config.enableDebug?(this.debug=new c.Utils.Debug(this),this.debug.boot()):this.debug={preUpdate:function(){},update:function(){},reset:function(){},isDisabled:!0},this.showDebugHeader(), this.isRunning=!0,this.raf=this.config&&this.config.forceSetTimeOut?new c.RequestAnimationFrame(this,this.config.forceSetTimeOut):new c.RequestAnimationFrame(this,!1),this._kickstart=!0,this.focusWindow(),this.config.disableStart||(this.cache.isReady?this.raf.start():this.cache.onReady.addOnce(function(){this.raf.start()},this)))},showDebugHeader:function(){if(!window.PhaserGlobal||!window.PhaserGlobal.hideBanner){var a=c.VERSION,b="Canvas",d="HTML Audio",e=1;this.renderType===c.WEBGL?(b="WebGL", e++):this.renderType===c.HEADLESS&&(b="Headless");this.device.webAudio&&(d="WebAudio",e++);if(this.device.ie)window.console&&console.log("Phaser v"+a+" | Pixi.js | "+b+" | "+d+" | http://phaser.io");else{a=["%c %c %c Phaser CE v"+a+" | Pixi.js | "+b+" | "+d+" %c %c %c http://phaser.io %c\u2665%c\u2665%c\u2665","background: #fb8cb3","background: #d44a52","color: #ffffff; background: #871905;","background: #d44a52","background: #fb8cb3","background: #ffffff"];for(b=0;3>b;b++)bthis._nextFpsNotification&&(this._nextFpsNotification=this.time.time+ 1E4,this.fpsProblemNotifier.dispatch()),this._spiraling=this._deltaTime=0,this.dropFrames?this.rendersThisFrame=0:(this.updateRender(this.time.slowMotion*this.time.desiredFps),this.rendersThisFrame=1);else{a=1E3*this.time.slowMotion/this.time.desiredFps;this._deltaTime+=Math.max(Math.min(3*a,this.time.elapsed),0);var b=0;this.updatesThisFrame=Math.floor(this._deltaTime/a);this.forceSingleUpdate&&(this.updatesThisFrame=Math.min(1,this.updatesThisFrame));for(this.rendersThisFrame=this.forceSingleRender? 1:Math.min(1,this.updatesThisFrame);this._deltaTime>=a&&(this._deltaTime-=a,this.currentUpdateID=b,this.updateLogic(this.time.desiredFpsMult),b++,!this.forceSingleUpdate||1!==b);)this.time.refresh();b>this._lastCount?this._spiraling++:b=c.Input.MAX_POINTERS)return console.warn("Phaser.Input.addPointer: Maximum limit of "+c.Input.MAX_POINTERS+" pointers reached."),null;var a=this.pointers.length+1,b=new c.Pointer(this.game,a,c.PointerMode.CONTACT);this.pointers.push(b);return this["pointer"+a]=b}, update:function(){this.keyboard&&this.keyboard.update();if(0=this.maxPointers)return null;if(!this.pointer1.active)return this.pointer1.start(a);if(!this.pointer2.active)return this.pointer2.start(a);for(var b=2;b=g&&this.game.camera.x+b.x=e&&this.game.camera.y+b.y=g&&this._localPoint.x=e&&this._localPoint.y< e+f))return!0}else if(a instanceof PIXI.Sprite){if(e=a.texture.frame.width/a.texture.baseTexture.resolution,f=a.texture.frame.height/a.texture.baseTexture.resolution,g=-e*a.anchor.x,this._localPoint.x>=g&&this._localPoint.x=e&&this._localPoint.y this.game.time.time},justReleased:function(a){return this.isUp&&this.timeUp+(a||250)>this.game.time.time},reset:function(){this.isDown=!1;this.isUp=!0;this.timeDown=this.game.time.time;this.repeats=0;this.ctrlKey=this.shiftKey=this.altKey=!1},destroy:function(){this.onDown.dispose();this.onUp.dispose();this.onFloat.dispose();this.game=this.parent=null}};c.DeviceButton.prototype.constructor=c.DeviceButton;Object.defineProperty(c.DeviceButton.prototype,"duration",{get:function(){return this.isUp?-1: this.game.time.time-this.timeDown}});c.Pointer=function(a,b,d){this.game=a;this.id=b;this.type=c.POINTER;this.exists=!0;this.identifier=0;this.pointerId=null;this.pointerMode=d||c.PointerMode.CURSOR|c.PointerMode.CONTACT;this.button=this.target=null;this.leftButton=new c.DeviceButton(this,c.Pointer.LEFT_BUTTON);this.middleButton=new c.DeviceButton(this,c.Pointer.MIDDLE_BUTTON);this.rightButton=new c.DeviceButton(this,c.Pointer.RIGHT_BUTTON);this.backButton=new c.DeviceButton(this,c.Pointer.BACK_BUTTON); this.forwardButton=new c.DeviceButton(this,c.Pointer.FORWARD_BUTTON);this.eraserButton=new c.DeviceButton(this,c.Pointer.ERASER_BUTTON);this._holdSent=!1;this._history=[];this._nextDrop=0;this.withinGame=this._stateReset=!1;this.screenY=this.screenX=this.pageY=this.pageX=this.clientY=this.clientX=-1;this.movementY=this.movementX=this.rawMovementY=this.rawMovementX=0;this.y=this.x=-1;this.isMouse=0===b;this.isDown=!1;this.isUp=!0;this.totalTouches=this.previousTapTime=this.timeUp=this.timeDown=0;this.msSinceLastClick= Number.MAX_VALUE;this.targetObject=null;this.interactiveCandidates=[];this.dirty=this.active=!1;this.position=new c.Point;this.positionDown=new c.Point;this.positionUp=new c.Point;this.circle=new c.Circle(0,0,44);this._trampolineTargetObject=this._clickTrampolines=null};c.Pointer.NO_BUTTON=0;c.Pointer.LEFT_BUTTON=1;c.Pointer.RIGHT_BUTTON=2;c.Pointer.MIDDLE_BUTTON=4;c.Pointer.BACK_BUTTON=8;c.Pointer.FORWARD_BUTTON=16;c.Pointer.ERASER_BUTTON=32;c.Pointer.prototype={resetButtons:function(){this.isDown= !1;this.isUp=!0;this.isMouse&&(this.leftButton.reset(),this.middleButton.reset(),this.rightButton.reset(),this.backButton.reset(),this.forwardButton.reset(),this.eraserButton.reset())},processButtonsDown:function(a,b){a===c.Mouse.LEFT_BUTTON&&this.leftButton.start(b);a===c.Mouse.RIGHT_BUTTON&&this.rightButton.start(b);a===c.Mouse.MIDDLE_BUTTON&&this.middleButton.start(b);a===c.Mouse.BACK_BUTTON&&this.backButton.start(b);a===c.Mouse.FORWARD_BUTTON&&this.forwardButton.start(b)},processButtonsUp:function(a, b){a===c.Mouse.LEFT_BUTTON&&this.leftButton.stop(b);a===c.Mouse.RIGHT_BUTTON&&this.rightButton.stop(b);a===c.Mouse.MIDDLE_BUTTON&&this.middleButton.stop(b);a===c.Mouse.BACK_BUTTON&&this.backButton.stop(b);a===c.Mouse.FORWARD_BUTTON&&this.forwardButton.stop(b)},processButtonsUpDown:function(a,b){var d="down"===b.type.toLowerCase().substr(-4),e="move"===b.type.toLowerCase().substr(-4);void 0!==a?(d&&1===a&&b.ctrlKey&&(a=2),this.leftButton.startStop(c.Pointer.LEFT_BUTTON&a,b),this.rightButton.startStop(c.Pointer.RIGHT_BUTTON& a,b),this.middleButton.startStop(c.Pointer.MIDDLE_BUTTON&a,b),this.backButton.startStop(c.Pointer.BACK_BUTTON&a,b),this.forwardButton.startStop(c.Pointer.FORWARD_BUTTON&a,b),this.eraserButton.startStop(c.Pointer.ERASER_BUTTON&a,b)):void 0!==b.button?d&&b.ctrlKey&&0===b.button?this.rightButton.start(b):d?this.processButtonsDown(b.button,b):e||this.processButtonsUp(b.button,b):d?b.ctrlKey?this.rightButton.start(b):this.leftButton.start(b):(this.leftButton.stop(b),this.rightButton.stop(b))},updateButtons:function(a){this.button= a.button;this.processButtonsUpDown(a.buttons,a);this.isUp=!0;this.isDown=!1;if(this.leftButton.isDown||this.rightButton.isDown||this.middleButton.isDown||this.backButton.isDown||this.forwardButton.isDown||this.eraserButton.isDown)this.isUp=!1,this.isDown=!0},start:function(a){var b=this.game.input;a.pointerId&&(this.pointerId=a.pointerId);this.identifier=a.identifier;this.target=a.target;this.isMouse?this.updateButtons(a):(this.isDown=!0,this.isUp=!1);this.withinGame=this.active=!0;this.dirty=!1; this._history=[];this._trampolineTargetObject=this._clickTrampolines=null;this.msSinceLastClick=this.game.time.time-this.timeDown;this.timeDown=this.game.time.time;this._holdSent=!1;this.move(a,!0);this.positionDown.setTo(this.x,this.y);if(b.multiInputOverride===c.Input.MOUSE_OVERRIDES_TOUCH||b.multiInputOverride===c.Input.MOUSE_TOUCH_COMBINE||b.multiInputOverride===c.Input.TOUCH_OVERRIDES_MOUSE&&0===b.totalActivePointers)b.x=this.x,b.y=this.y,b.position.setTo(this.x,this.y),b.onDown.dispatch(this, a),b.resetSpeed(this.x,this.y);this._stateReset=!1;this.totalTouches++;null!==this.targetObject&&this.targetObject._touchedHandler(this);return this},update:function(){var a=this.game.input;this.active&&(this.dirty&&(0=a.holdRate&&((a.multiInputOverride===c.Input.MOUSE_OVERRIDES_TOUCH||a.multiInputOverride===c.Input.MOUSE_TOUCH_COMBINE||a.multiInputOverride===c.Input.TOUCH_OVERRIDES_MOUSE&& 0===a.totalActivePointers)&&a.onHold.dispatch(this),this._holdSent=!0),a.recordPointerHistory&&this.game.time.time>=this._nextDrop&&(this._nextDrop=this.game.time.time+a.recordRate,this._history.push({x:this.position.x,y:this.position.y}),this._history.length>a.recordLimit&&this._history.shift()))},move:function(a,b){var d=this.game.input;if(!d.pollLocked){void 0===b&&(b=!1);void 0!==a.button&&(this.button=a.button);this.isMouse&&this.updateButtons(a);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.isMouse&&d.mouse.locked&&!b&&(this.rawMovementX=a.movementX||a.mozMovementX||a.webkitMovementX||0,this.rawMovementY=a.movementY||a.mozMovementY||a.webkitMovementY||0,this.movementX+=this.rawMovementX,this.movementY+=this.rawMovementY);this.x=(this.pageX-this.game.scale.offset.x)*d.scale.x;this.y=(this.pageY-this.game.scale.offset.y)*d.scale.y;this.position.setTo(this.x,this.y);this.circle.x=this.x;this.circle.y= this.y;if(d.multiInputOverride===c.Input.MOUSE_OVERRIDES_TOUCH||d.multiInputOverride===c.Input.MOUSE_TOUCH_COMBINE||d.multiInputOverride===c.Input.TOUCH_OVERRIDES_MOUSE&&0===d.totalActivePointers)d.activePointer=this,d.x=this.x,d.y=this.y,d.position.setTo(d.x,d.y),d.circle.x=d.x,d.circle.y=d.y;this.withinGame=this.game.scale.bounds.contains(this.pageX,this.pageY);for(var e=d.moveCallbacks.length;e--;)d.moveCallbacks[e].callback.call(d.moveCallbacks[e].context,this,this.x,this.y,b,a);null===this.targetObject|| this.game.paused&&!this.targetObject.noPause||!0!==this.targetObject.isDragged?0this.game.time.time},justReleased:function(a){a=a||this.game.input.justReleasedRate;return this.isUp&&this.timeUp+a>this.game.time.time},addClickTrampoline:function(a,b,d,c){if(this.isDown){for(var e=this._clickTrampolines=this._clickTrampolines||[],g=0;ga;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};this.snapOffset=new c.Point;this._wasEnabled=this.enabled=!0}this.sprite.events.onAddedToGroup.add(this.addedToGroup,this);this.sprite.events.onRemovedFromGroup.add(this.removedFromGroup,this);return this.sprite},addedToGroup:function(){this._dragPhase||this._wasEnabled&&!this.enabled&&this.start()},removedFromGroup:function(){this._dragPhase|| (this.enabled?(this._wasEnabled=!0,this.stop()):this._wasEnabled=!1)},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(){!1!==this.enabled&&(this.enabled=!1,this.game.input.interactiveItems.remove(this))},destroy:function(){this.sprite&&(this._setHandCursor&&(this.game.canvas.style.cursor="",this._setHandCursor=!1),this.enabled=!1,this.game.input.interactiveItems.remove(this), this._pointerData.length=0,this.sprite=this.boundsSprite=this.boundsRect=null)},validForInput:function(a,b,d){void 0===d&&(d=!0);return!this.enabled||0===this.sprite.scale.x||0===this.sprite.scale.y||this.priorityIDa||this.priorityID===a&&this.sprite.renderOrderID>b?!0:!1},isPixelPerfect:function(){return this.pixelPerfectClick||this.pixelPerfectOver}, pointerX:function(a){return this._pointerData[a||0].x},pointerY:function(a){return this._pointerData[a||0].y},pointerDown:function(a){return this._pointerData[a||0].isDown},pointerUp:function(a){return this._pointerData[a||0].isUp},pointerTimeDown:function(a){return this._pointerData[a||0].timeDown},pointerTimeUp:function(a){return this._pointerData[a||0].timeUp},pointerOver:function(a){if(!this.enabled)return!1;if(void 0===a){for(a=0;10>a;a++)if(this._pointerData[a].isOver)return!0;return!1}return this._pointerData[a].isOver}, pointerOut:function(a){if(!this.enabled)return!1;if(void 0===a)for(a=0;10>a;a++){if(this._pointerData[a].isOut)return!0}else return this._pointerData[a].isOut},pointerTimeOver:function(a){return this._pointerData[a||0].timeOver},pointerTimeOut:function(a){return this._pointerData[a||0].timeOut},pointerDragged:function(a){return this._pointerData[a||0].isDragged},checkPointerDown:function(a,b){return a.isDown&&this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&& 0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y?this.game.input.hitTest(this.sprite,a,this._tempPoint)?(void 0===b&&(b=!1),!b&&this.pixelPerfectClick?this.checkPixel(this._tempPoint.x,this._tempPoint.y):!0):!1:!1},checkPointerOver:function(a,b){return this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y?this.game.input.hitTest(this.sprite,a,this._tempPoint)?(void 0===b&&(b=!1),!b&&this.pixelPerfectOver? this.checkPixel(this._tempPoint.x,this._tempPoint.y):!0):!1:!1},checkPixel:function(a,b,d){if(this.sprite.texture.baseTexture.source){null===a&&null===b&&(this.game.input.getLocalPosition(this.sprite,d,this._tempPoint),a=this._tempPoint.x,b=this._tempPoint.y);0!==this.sprite.anchor.x&&(a-=-this.sprite.texture.frame.width*this.sprite.anchor.x);0!==this.sprite.anchor.y&&(b-=-this.sprite.texture.frame.height*this.sprite.anchor.y);a+=this.sprite.texture.frame.x;b+=this.sprite.texture.frame.y;if(this.sprite.texture.trim&& (a-=this.sprite.texture.trim.x,b-=this.sprite.texture.trim.y,athis.sprite.texture.crop.right||bthis.sprite.texture.crop.bottom))return this._dx=a,this._dy=b,!1;this._dx=a;this._dy=b;this.game.input.hitContext.clearRect(0,0,1,1);this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,a,b,1,1,0,0,1,1);if(this.game.input.hitContext.getImageData(0,0,1,1).data[3]>=this.pixelPerfectAlpha)return!0}return!1},update:function(a){if(null!== this.sprite&&void 0!==this.sprite.parent){if(!this.enabled||!this.sprite.visible||!this.sprite.parent.visible)return this._pointerOutHandler(a),!1;if(this._pendingDrag)return this._dragDistancePass||(this._dragDistancePass=c.Math.distance(a.x,a.y,this.downPoint.x,this.downPoint.y)>=this.dragDistanceThreshold),this._dragDistancePass&&this._dragTimePass&&this.startDrag(a),!0;if(this.draggable&&this._draggedPointerID===a.id)return this.updateDrag(a,!1);if(this._pointerData[a.id].isOver){if(this.checkPointerOver(a))return this._pointerData[a.id].x= a.x-this.sprite.x,this._pointerData[a.id].y=a.y-this.sprite.y,!0;this._pointerOutHandler(a);return!1}}},_pointerOverHandler:function(a,b){if(null!==this.sprite){var d=this._pointerData[a.id];if(!1===d.isOver||a.dirty){var c=!1===d.isOver;d.isOver=!0;d.isOut=!1;d.timeOver=this.game.time.time;d.x=a.x-this.sprite.x;d.y=a.y-this.sprite.y;this.useHandCursor&&!1===d.isDragged&&(this.game.canvas.style.cursor="pointer",this._setHandCursor=!0);if(!b&&c&&this.sprite&&this.sprite.events)this.sprite.events.onInputOver$dispatch(this.sprite, a);this.sprite.parent&&this.sprite.parent.onChildInputOver&&this.sprite.parent.onChildInputOver.dispatch(this.sprite,a)}}},_pointerOutHandler:function(a,b){if(null!==this.sprite){var d=this._pointerData[a.id];d.isOver=!1;d.isOut=!0;d.timeOut=this.game.time.time;this.useHandCursor&&!1===d.isDragged&&(this.game.canvas.style.cursor="",this._setHandCursor=!1);!b&&this.sprite&&this.sprite.events&&(this.sprite.events.onInputOut$dispatch(this.sprite,a),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputOut&& this.sprite.parent.onChildInputOut.dispatch(this.sprite,a))}},_touchedHandler:function(a){if(null!==this.sprite){var b=this._pointerData[a.id];if(!b.isDown&&b.isOver&&(!this.pixelPerfectClick||this.checkPixel(null,null,a))){b.isDown=!0;b.isUp=!1;b.timeDown=this.game.time.time;this.downPoint.set(a.x,a.y);a.dirty=!0;if(this.sprite&&this.sprite.events&&(this.sprite.events.onInputDown$dispatch(this.sprite,a),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputDown&&this.sprite.parent.onChildInputDown.dispatch(this.sprite, a),null===this.sprite))return;this.draggable&&!1===this.isDragged&&(0===this.dragTimeThreshold&&0===this.dragDistanceThreshold?this.startDrag(a):(this._pendingDrag=!0,this._dragDistancePass=0===this.dragDistanceThreshold,0a;a++)this._pointerData[a].isDragged=!1;this.isDragged=this.draggable=!1;this._draggedPointerID=-1;this._pendingDrag=!1},startDrag:function(a){var b=this.sprite.x,d=this.sprite.y,e=this.globalToLocal(a);this.isDragged=!0;this._draggedPointerID=a.id;this._pointerData[a.id].camX=this.game.camera.x;this._pointerData[a.id].camY= this.game.camera.y;this._pointerData[a.id].isDragged=!0;if(this.sprite.fixedToCamera){if(this.dragFromCenter){var f=this.sprite.getBounds();f=this.globalToLocal(new c.Point(f.centerX,f.centerY));this.sprite.cameraOffset.x=e.x+(this.sprite.cameraOffset.x-f.x);this.sprite.cameraOffset.y=e.y+(this.sprite.cameraOffset.y-f.y)}this._dragPoint.setTo(this.sprite.cameraOffset.x-a.x,this.sprite.cameraOffset.y-a.y)}else this.dragFromCenter&&(f=this.sprite.getBounds(),f=this.globalToLocal(new c.Point(f.centerX, f.centerY)),this.sprite.x=e.x+(this.sprite.x-f.x),this.sprite.y=e.y+(this.sprite.y-f.y)),this._dragPoint.setTo(this.sprite.x-e.x,this.sprite.y-e.y);this.updateDrag(a,!0);this.bringToTop&&(this._dragPhase=!0,this.sprite.bringToTop());this.dragStartPoint.set(b,d);this.sprite.events.onDragStart$dispatch(this.sprite,a,b,d);this._pendingDrag=!1},globalToLocalX:function(a){this.scaleLayer&&(a-=this.game.scale.grid.boundsFluid.x,a*=this.game.scale.grid.scaleFluidInversed.x);return a},globalToLocalY:function(a){this.scaleLayer&& (a-=this.game.scale.grid.boundsFluid.y,a*=this.game.scale.grid.scaleFluidInversed.y);return a},globalToLocal:function(a){return this.sprite.parent?this.game.input.getLocalPosition(this.sprite.parent,{x:a.x,y:a.y}):a},stopDrag:function(a){this.isDragged=!1;this._draggedPointerID=-1;this._pendingDrag=this._dragPhase=this._pointerData[a.id].isDragged=!1;this.snapOnRelease&&(this.sprite.fixedToCamera?(this.sprite.cameraOffset.x=Math.round((this.sprite.cameraOffset.x-this.snapOffsetX%this.snapX)/this.snapX)* this.snapX+this.snapOffsetX%this.snapX,this.sprite.cameraOffset.y=Math.round((this.sprite.cameraOffset.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY):(this.sprite.x=Math.round((this.sprite.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.y=Math.round((this.sprite.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY));this.sprite.events.onDragStop$dispatch(this.sprite,a);!1===this.checkPointerOver(a)&& this._pointerOutHandler(a)},setDragLock:function(a,b){void 0===a&&(a=!0);void 0===b&&(b=!0);this.allowHorizontalDrag=a;this.allowVerticalDrag=b},enableSnap:function(a,b,d,c,f,g){void 0===d&&(d=!0);void 0===c&&(c=!1);void 0===f&&(f=0);void 0===g&&(g=0);this.snapX=a;this.snapY=b;this.snapOffsetX=f;this.snapOffsetY=g;this.snapOnDrag=d;this.snapOnRelease=c},disableSnap:function(){this.snapOnRelease=this.snapOnDrag=!1},checkBoundsRect:function(){this.sprite.fixedToCamera?(this.sprite.cameraOffset.xthis.boundsRect.right&&(this.sprite.cameraOffset.x=this.boundsRect.right-this.sprite.width),this.sprite.cameraOffset.ythis.boundsRect.bottom&&(this.sprite.cameraOffset.y=this.boundsRect.bottom-this.sprite.height)):(this.sprite.leftthis.boundsRect.right&&(this.sprite.x=this.boundsRect.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.topthis.boundsRect.bottom&&(this.sprite.y=this.boundsRect.bottom-(this.sprite.height-this.sprite.offsetY)))},checkBoundsSprite:function(){this.sprite.fixedToCamera&&this.boundsSprite.fixedToCamera?(this.sprite.cameraOffset.xthis.boundsSprite.cameraOffset.x+this.boundsSprite.width&&(this.sprite.cameraOffset.x=this.boundsSprite.cameraOffset.x+this.boundsSprite.width-this.sprite.width),this.sprite.cameraOffset.ythis.boundsSprite.cameraOffset.y+this.boundsSprite.height&&(this.sprite.cameraOffset.y=this.boundsSprite.cameraOffset.y+ this.boundsSprite.height-this.sprite.height)):(this.sprite.leftthis.boundsSprite.right&&(this.sprite.x=this.boundsSprite.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.topthis.boundsSprite.bottom&&(this.sprite.y=this.boundsSprite.bottom-(this.sprite.height-this.sprite.offsetY)))}};c.InputHandler.prototype.constructor= c.InputHandler;c.PointerLock=function(a){this.game=a;this.input=a.input;this.element=a.canvas;this.locked=this.active=!1;this.onChange=new c.Signal;this.onError=new c.Signal;this.boundOnChangeHandler=this.onChangeHandler.bind(this);this.boundOnErrorHandler=this.onErrorHandler.bind(this);a=a.device;this.pointerLockElement=a.pointerLockElement;this.pointerlockchange=a.pointerlockchange;this.pointerlockerror=a.pointerlockerror};c.PointerLock.prototype.start=function(){if(!this.game.device.pointerLock|| this.active)return!1;this.element.requestPointerLock||(this.element.requestPointerLock=this.element.mozRequestPointerLock||this.element.webkitRequestPointerLock);document.exitPointerLock||(document.exitPointerLock=document.mozExitPointerLock||document.webkitExitPointerLock);document.addEventListener(this.pointerlockchange,this.boundOnChangeHandler,!0);document.addEventListener(this.pointerlockerror,this.boundOnErrorHandler,!0);return this.active=!0};c.PointerLock.prototype.stop=function(){document.removeEventListener(this.pointerlockchange, this.boundOnChangeHandler,!0);document.removeEventListener(this.pointerlockerror,this.boundOnErrorHandler,!0);this.active=!1};c.PointerLock.prototype.request=function(){this.active&&!this.locked&&this.element.requestPointerLock()};c.PointerLock.prototype.exit=function(){document.exitPointerLock()};c.PointerLock.prototype.onChangeHandler=function(a){this.locked=document[this.pointerLockElement]===this.element;this.onChange.dispatch(this.locked,a)};c.PointerLock.prototype.onErrorHandler=function(a){this.onError.dispatch(a)}; c.Gamepad=function(a){this.game=a;this._gamepadIndexMap={};this._rawPads=[];this._active=!1;this.enabled=!0;this._gamepadSupportAvailable=!!navigator.webkitGetGamepads||!!navigator.webkitGamepads||-1!==navigator.userAgent.indexOf("Firefox/")||!!navigator.getGamepads;this._prevRawGamepadTypes=[];this._prevTimestamps=[];this.callbackContext=this;this._gamepaddisconnected=this._ongamepadconnected=this.onFloatCallback=this.onAxisCallback=this.onUpCallback=this.onDownCallback=this.onDisconnectCallback= this.onConnectCallback=null;this._gamepads=[new c.SinglePad(a,this),new c.SinglePad(a,this),new c.SinglePad(a,this),new c.SinglePad(a,this)]};c.Gamepad.prototype={addCallbacks:function(a,b){"undefined"!==typeof b&&(this.onConnectCallback="function"===typeof b.onConnect?b.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"===typeof b.onDisconnect?b.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"===typeof b.onDown?b.onDown:this.onDownCallback,this.onUpCallback= "function"===typeof b.onUp?b.onUp:this.onUpCallback,this.onAxisCallback="function"===typeof b.onAxis?b.onAxis:this.onAxisCallback,this.onFloatCallback="function"===typeof b.onFloat?b.onFloat:this.onFloatCallback,this.callbackContext=a)},start:function(){if(!this._active){this._active=!0;var a=this;this._onGamepadConnected=function(b){return a.onGamepadConnected(b)};this._onGamepadDisconnected=function(b){return a.onGamepadDisconnected(b)};window.addEventListener("gamepadconnected",this._onGamepadConnected, !1);window.addEventListener("gamepaddisconnected",this._onGamepadDisconnected,!1)}},onGamepadConnected:function(a){a=a.gamepad;this._rawPads.push(a);this._gamepads[a.index].connect(a)},onGamepadDisconnected:function(a){a=a.gamepad;for(var b in this._rawPads)this._rawPads[b].index===a.index&&this._rawPads.splice(b,1);this._gamepads[a.index].disconnect()},update:function(){this._pollGamepads();this.pad1.pollStatus();this.pad2.pollStatus();this.pad3.pollStatus();this.pad4.pollStatus()},_pollGamepads:function(){if(this._active){if(navigator.getGamepads)var a= navigator.getGamepads();else navigator.webkitGetGamepads?a=navigator.webkitGetGamepads():navigator.webkitGamepads&&(a=navigator.webkitGamepads());if(a){this._rawPads=[];for(var b=!1,d=0;dthis._rawPads.length&&d.disconnect(),f=0;fthis.deadZone||0>b&&b<-this.deadZone?this.processAxisChange(a,b):this.processAxisChange(a,0);this._prevTimestamp=this._rawPad.timestamp}},connect:function(a){var b=!this.connected;this.connected=!0;this.index=a.index;this._rawPad=a;this._buttons=[];this._buttonsLen=a.buttons.length;this._axes=[];this._axesLen=a.axes.length;for(var d=0;d=this.health&&this.kill());return this},setHealth:function(a){this.health=a;this.health>this.maxHealth&&(this.health=this.maxHealth);return this},heal:function(a){this.alive&&(this.health+=a,this.health>this.maxHealth&&(this.health=this.maxHealth)); return this}};c.Component.InCamera=function(){};c.Component.InCamera.prototype={inCamera:{get:function(){return this.game.world.camera.view.intersects(this._bounds)}}};c.Component.InputEnabled=function(){};c.Component.InputEnabled.prototype={input:null,inputEnabled:{get:function(){return this.input&&this.input.enabled},set:function(a){a?null===this.input?(this.input=new c.InputHandler(this),this.input.start()):this.input&&!this.input.enabled&&this.input.start():this.input&&this.input.enabled&&this.input.stop()}}}; c.Component.InWorld=function(){};c.Component.InWorld.preUpdate=function(){if(this.pendingDestroy)return this.destroy(),!1;if(this.autoCull||this.checkWorldBounds){this._bounds.copyFrom(this.getBounds());this._bounds.x+=this.game.camera.view.x;this._bounds.y+=this.game.camera.view.y;if(this.autoCull)if(this.game.world.camera.view.intersects(this._bounds))this.renderable=!0,this.game.world.camera.totalInView++;else if(this.renderable=!1,this.outOfCameraBoundsKill)return this.kill(),!1;if(this.checkWorldBounds)if(this._outOfBoundsFired&& this.game.world.bounds.intersects(this._bounds))this._outOfBoundsFired=!1,this.events.onEnterBounds$dispatch(this);else if(!this._outOfBoundsFired&&!this.game.world.bounds.intersects(this._bounds)&&(this._outOfBoundsFired=!0,this.events.onOutOfBounds$dispatch(this),this.outOfBoundsKill))return this.kill(),!1}return!0};c.Component.InWorld.prototype={checkWorldBounds:!1,outOfBoundsKill:!1,outOfCameraBoundsKill:!1,_outOfBoundsFired:!1,inWorld:{get:function(){return this.game.world.bounds.intersects(this.getBounds())}}}; c.Component.LifeSpan=function(){};c.Component.LifeSpan.preUpdate=function(){return this.pendingDestroy?(this.destroy(),!1):0=this.lifespan)?(this.kill(),!1):!0};c.Component.LifeSpan.prototype={alive:!0,lifespan:0,revive:function(a){void 0===a&&(a=100);this.visible=this.exists=this.alive=!0;"function"===typeof this.setHealth&&this.setHealth(a);if(this.events)this.events.onRevived$dispatch(this);return this},kill:function(){this.visible= this.exists=this.alive=!1;if(this.events)this.events.onKilled$dispatch(this);return this}};c.Component.LoadTexture=function(){};c.Component.LoadTexture.prototype={customRender:!1,_frame:null,loadTexture:function(a,b,d){a===c.PENDING_ATLAS?(a=b,b=0):b=b||0;(d||void 0===d)&&this.animations&&this.animations.stop();this.key=a;this.customRender=!1;var e=this.game.cache,f=!0;d=!this.texture.baseTexture.scaleMode;c.RenderTexture&&a instanceof c.RenderTexture?(this.key=a.key,this.setTexture(a)):c.BitmapData&& a instanceof c.BitmapData?(this.customRender=!0,this.setTexture(a.texture),f=e.hasFrameData(a.key,c.Cache.BITMAPDATA)?!this.animations.loadFrameData(e.getFrameData(a.key,c.Cache.BITMAPDATA),b):!this.animations.loadFrameData(a.frameData,0)):c.Video&&a instanceof c.Video?(this.customRender=!0,b=a.texture.valid,this.setTexture(a.texture),this.setFrame(a.texture.frame.clone()),a.onChangeSource.add(this.resizeFrame,this),this.texture.valid=b):c.Tilemap&&a instanceof c.TilemapLayer?this.setTexture(PIXI.Texture.fromCanvas(a.canvas)): a instanceof PIXI.Texture?this.setTexture(a):(f=e.getImage(a,!0),this.key=f.key,this.setTexture(new PIXI.Texture(f.base)),this.texture.baseTexture.skipRender="__default"===a?!0:!1,f=!this.animations.loadFrameData(f.frameData,b));f&&(this._frame=c.Rectangle.clone(this.texture.frame));d||(this.texture.baseTexture.scaleMode=1)},setFrame:function(a){this._frame=a;this.texture.frame.x=a.x;this.texture.frame.y=a.y;this.texture.frame.width=a.width;this.texture.frame.height=a.height;this.texture.crop.x=a.x; this.texture.crop.y=a.y;this.texture.crop.width=a.width;this.texture.crop.height=a.height;a.trimmed?(this.texture.trim?(this.texture.trim.x=a.spriteSourceSizeX,this.texture.trim.y=a.spriteSourceSizeY,this.texture.trim.width=a.sourceSizeW,this.texture.trim.height=a.sourceSizeH):this.texture.trim={x:a.spriteSourceSizeX,y:a.spriteSourceSizeY,width:a.sourceSizeW,height:a.sourceSizeH},this.texture.width=a.sourceSizeW,this.texture.height=a.sourceSizeH,this.texture.frame.width=a.sourceSizeW,this.texture.frame.height= a.sourceSizeH):!a.trimmed&&this.texture.trim&&(this.texture.trim=null);a.rotated&&(this.texture.rotated=!0);this.cropRect&&this.updateCrop();this.texture.requiresReTint=!0;this.texture._updateUvs();this.tilingTexture&&(this.refreshTexture=!0)},resizeFrame:function(a,b,d){this.texture.frame.resize(b,d);this.texture.setFrame(this.texture.frame)},resetFrame:function(){this._frame&&this.setFrame(this._frame)},frame:{get:function(){return this.animations.frame},set:function(a){this.animations.frame=a}}, frameName:{get:function(){return this.animations.frameName},set:function(a){this.animations.frameName=a}}};c.Component.Overlap=function(){};c.Component.Overlap.prototype={overlap:function(a){return c.Rectangle.intersects(this.getBounds(),a.getBounds())}};c.Component.PhysicsBody=function(){};c.Component.PhysicsBody.preUpdate=function(){if(this.pendingDestroy)return this.destroy(),!1;if(this.fresh&&this.exists)return this.world.setTo(this.parent.position.x+this.position.x,this.parent.position.y+this.position.y), this.worldTransform.tx=this.world.x,this.worldTransform.ty=this.world.y,this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,this.body&&this.body.preUpdate(),this.fresh=!1,this.preUpdateChildren(),!1;this.previousPosition.set(this.world.x,this.world.y);this.previousRotation=this.rotation;return this._exists&&this.parent.exists?!0:(this.renderOrderID=-1,!1)};c.Component.PhysicsBody.postUpdate=function(){this.exists&&this.body&&this.body.postUpdate()};c.Component.PhysicsBody.prototype= {body:null,x:{get:function(){return this.position.x},set:function(a){this.position.x=a;this.body&&!this.body.dirty&&(this.body._reset=!0)}},y:{get:function(){return this.position.y},set:function(a){this.position.y=a;this.body&&!this.body.dirty&&(this.body._reset=!0)}}};c.Component.Reset=function(){};c.Component.Reset.prototype.reset=function(a,b,d){void 0===d&&(d=1);this.world.set(a,b);this.position.set(a,b);this.renderable=this.visible=this.exists=this.fresh=!0;this.components.InWorld&&(this._outOfBoundsFired= !1);this.components.LifeSpan&&(this.alive=!0,this.health=d);this.components.PhysicsBody&&this.body&&this.body.reset(a,b,!1,!1);return this};c.Component.ScaleMinMax=function(){};c.Component.ScaleMinMax.prototype={transformCallback:null,transformCallbackContext:this,scaleMin:null,scaleMax:null,checkTransform:function(a){this.scaleMin&&(a.athis.scaleMax.x&&(a.a=this.scaleMax.x),a.d>this.scaleMax.y&& (a.d=this.scaleMax.y))},setScaleMinMax:function(a,b,d,e){void 0===b?b=d=e=a:void 0===d&&(d=e=b,b=a);null===a?this.scaleMin=null:this.scaleMin?this.scaleMin.set(a,b):this.scaleMin=new c.Point(a,b);null===d?this.scaleMax=null:this.scaleMax?this.scaleMax.set(d,e):this.scaleMax=new c.Point(d,e);null===this.scaleMin?this.transformCallback=null:(this.transformCallback=this.checkTransform,this.transformCallbackContext=this)}};c.Component.Smoothed=function(){};c.Component.Smoothed.prototype={smoothed:{get:function(){return!this.texture.baseTexture.scaleMode}, set:function(a){a?this.texture&&(this.texture.baseTexture.scaleMode=0,this.texture.baseTexture.dirty()):this.texture&&(this.texture.baseTexture.scaleMode=1,this.texture.baseTexture.dirty())}}};c.GameObjectFactory=function(a){this.game=a;this.world=this.game.world};c.GameObjectFactory.prototype={existing:function(a){return this.world.add(a)},weapon:function(a,b,d,e,f){var g=this.game.plugins.add(c.Weapon);f&&(g.bulletClass=f);g.createBullets(a,b,d,e);return g},image:function(a,b,d,e,f){void 0===f&& (f=this.world);return f.add(new c.Image(this.game,a,b,d,e))},sprite:function(a,b,d,e,f){void 0===f&&(f=this.world);return f.add(new c.Sprite(this.game,a,b,d,e))},creature:function(a,b,d,e,f){void 0===f&&(f=this.world);a=new c.Creature(this.game,a,b,d,e);f.add(a);return a},tween:function(a){return this.game.tweens.create(a)},group:function(a,b,d,e,f){return new c.Group(this.game,a,b,d,e,f)},physicsGroup:function(a,b,d,e){return new c.Group(this.game,b,d,e,!0,a)},spriteBatch:function(a,b,d){void 0=== a&&(a=null);void 0===b&&(b="group");void 0===d&&(d=!1);return new c.SpriteBatch(this.game,a,b,d)},audio:function(a,b,d,c){return this.game.sound.add(a,b,d,c)},sound:function(a,b,d,c){return this.game.sound.add(a,b,d,c)},audioSprite:function(a){return this.game.sound.addSprite(a)},tileSprite:function(a,b,d,e,f,g,k){void 0===k&&(k=this.world);return k.add(new c.TileSprite(this.game,a,b,d,e,f,g))},rope:function(a,b,d,e,f,g){void 0===g&&(g=this.world);return g.add(new c.Rope(this.game,a,b,d,e,f))},text:function(a, b,d,e,f){void 0===f&&(f=this.world);return f.add(new c.Text(this.game,a,b,d,e))},button:function(a,b,d,e,f,g,k,m,h,n){void 0===n&&(n=this.world);return n.add(new c.Button(this.game,a,b,d,e,f,g,k,m,h))},graphics:function(a,b,d){void 0===d&&(d=this.world);return d.add(new c.Graphics(this.game,a,b))},emitter:function(a,b,d){return this.game.particles.add(new c.Particles.Arcade.Emitter(this.game,a,b,d))},retroFont:function(a,b,d,e,f,g,k,m,h){return new c.RetroFont(this.game,a,b,d,e,f,g,k,m,h)},bitmapText:function(a, b,d,e,f,g){void 0===g&&(g=this.world);return g.add(new c.BitmapText(this.game,a,b,d,e,f))},tilemap:function(a,b,d,e,f){return new c.Tilemap(this.game,a,b,d,e,f)},renderTexture:function(a,b,d,e){if(void 0===d||""===d)d=this.game.rnd.uuid();void 0===e&&(e=!1);a=new c.RenderTexture(this.game,a,b,d);e&&this.game.cache.addRenderTexture(d,a);return a},video:function(a,b){return new c.Video(this.game,a,b)},bitmapData:function(a,b,d,e){void 0===e&&(e=!1);if(void 0===d||""===d)d=this.game.rnd.uuid();a=new c.BitmapData(this.game, d,a,b);e&&this.game.cache.addBitmapData(d,a);return a},filter:function(a){var b=Array.prototype.slice.call(arguments,1);a=new c.Filter[a](this.game);a.init.apply(a,b);return a},plugin:function(){return this.game.plugins.add.apply(this.game.plugins,arguments)}};c.GameObjectFactory.prototype.constructor=c.GameObjectFactory;c.GameObjectCreator=function(a){this.game=a;this.world=this.game.world};c.GameObjectCreator.prototype={image:function(a,b,d,e){return new c.Image(this.game,a,b,d,e)},sprite:function(a, b,d,e){return new c.Sprite(this.game,a,b,d,e)},tween:function(a){return new c.Tween(a,this.game,this.game.tweens)},group:function(a,b,d,e,f){return new c.Group(this.game,a||null,b,d,e,f)},spriteBatch:function(a,b,d){void 0===b&&(b="group");void 0===d&&(d=!1);return new c.SpriteBatch(this.game,a,b,d)},audio:function(a,b,d,c){return this.game.sound.add(a,b,d,c)},audioSprite:function(a){return this.game.sound.addSprite(a)},sound:function(a,b,d,c){return this.game.sound.add(a,b,d,c)},tileSprite:function(a, b,d,e,f,g){return new c.TileSprite(this.game,a,b,d,e,f,g)},rope:function(a,b,d,e,f){return new c.Rope(this.game,a,b,d,e,f)},text:function(a,b,d,e){return new c.Text(this.game,a,b,d,e)},button:function(a,b,d,e,f,g,k,m,h){return new c.Button(this.game,a,b,d,e,f,g,k,m,h)},graphics:function(a,b){return new c.Graphics(this.game,a,b)},emitter:function(a,b,d){return new c.Particles.Arcade.Emitter(this.game,a,b,d)},retroFont:function(a,b,d,e,f,g,k,m,h){return new c.RetroFont(this.game,a,b,d,e,f,g,k,m,h)}, bitmapText:function(a,b,d,e,f,g){return new c.BitmapText(this.game,a,b,d,e,f,g)},tilemap:function(a,b,d,e,f){return new c.Tilemap(this.game,a,b,d,e,f)},renderTexture:function(a,b,d,e){if(void 0===d||""===d)d=this.game.rnd.uuid();void 0===e&&(e=!1);a=new c.RenderTexture(this.game,a,b,d);e&&this.game.cache.addRenderTexture(d,a);return a},bitmapData:function(a,b,d,e){void 0===e&&(e=!1);if(void 0===d||""===d)d=this.game.rnd.uuid();a=new c.BitmapData(this.game,d,a,b);e&&this.game.cache.addBitmapData(d, a);return a},filter:function(a){var b=Array.prototype.slice.call(arguments,1);a=new c.Filter[a](this.game);a.init.apply(a,b);return a}};c.GameObjectCreator.prototype.constructor=c.GameObjectCreator;c.Sprite=function(a,b,d,e,f){b=b||0;d=d||0;e=e||null;f=f||null;this.physicsType=this.type=c.SPRITE;PIXI.Sprite.call(this,c.Cache.DEFAULT);c.Component.Core.init.call(this,a,b,d,e,f)};c.Sprite.prototype=Object.create(PIXI.Sprite.prototype);c.Sprite.prototype.constructor=c.Sprite;c.Component.Core.install.call(c.Sprite.prototype, "Angle Animation AutoCull Bounds BringToTop Crop Delta Destroy FixedToCamera Health InCamera InputEnabled InWorld LifeSpan LoadTexture Overlap PhysicsBody Reset ScaleMinMax Smoothed".split(" "));c.Sprite.prototype.preUpdatePhysics=c.Component.PhysicsBody.preUpdate;c.Sprite.prototype.preUpdateLifeSpan=c.Component.LifeSpan.preUpdate;c.Sprite.prototype.preUpdateInWorld=c.Component.InWorld.preUpdate;c.Sprite.prototype.preUpdateCore=c.Component.Core.preUpdate;c.Sprite.prototype.preUpdate=function(){return this.preUpdatePhysics()&& this.preUpdateLifeSpan()&&this.preUpdateInWorld()?this.preUpdateCore():!1};c.Image=function(a,b,d,e,f){b=b||0;d=d||0;e=e||null;f=f||null;this.type=c.IMAGE;PIXI.Sprite.call(this,c.Cache.DEFAULT);c.Component.Core.init.call(this,a,b,d,e,f)};c.Image.prototype=Object.create(PIXI.Sprite.prototype);c.Image.prototype.constructor=c.Image;c.Component.Core.install.call(c.Image.prototype,"Angle Animation AutoCull Bounds BringToTop Crop Destroy FixedToCamera InputEnabled LifeSpan LoadTexture Overlap Reset ScaleMinMax Smoothed".split(" ")); c.Image.prototype.preUpdateLifeSpan=c.Component.LifeSpan.preUpdate;c.Image.prototype.preUpdateInWorld=c.Component.InWorld.preUpdate;c.Image.prototype.preUpdateCore=c.Component.Core.preUpdate;c.Image.prototype.preUpdate=function(){return this.preUpdateInWorld()&&this.preUpdateLifeSpan()?this.preUpdateCore():!1};c.Button=function(a,b,d,e,f,g,k,m,h,n){f=f||null;g=g||this;c.Image.call(this,a,b||0,d||0,e||null,m);this.type=c.BUTTON;this.physicsType=c.SPRITE;this.onUpSound=this.onDownSound=this.onOutSound= this.onOverSound=this._onUpFrame=this._onDownFrame=this._onOutFrame=this._onOverFrame=null;this.onUpSoundMarker=this.onDownSoundMarker=this.onOutSoundMarker=this.onOverSoundMarker="";this.onInputOver=new c.Signal;this.onInputOut=new c.Signal;this.onInputDown=new c.Signal;this.onInputUp=new c.Signal;this.onOverMouseOnly=!0;this.justReleasedPreventsOver=c.PointerMode.CONTACT;this.forceOut=this.freezeFrames=!1;this.inputEnabled=!0;this.input.start(0,!0);this.input.useHandCursor=!0;this.setFrames(k,m, h,n);null!==f&&this.onInputUp.add(f,g);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)};c.Button.prototype=Object.create(c.Image.prototype);c.Button.prototype.constructor=c.Button;c.Button.prototype.clearFrames=function(){this.setFrames(null,null,null,null)};c.Button.prototype.setStateFrame=function(a,b,d){var c="_on"+a+"Frame"; null!==b?(this[c]=b,d&&this.changeStateFrame(a)):this[c]=null};c.Button.prototype.changeStateFrame=function(a){if(this.freezeFrames)return!1;a=this["_on"+a+"Frame"];return"string"===typeof a?(this.frameName=a,!0):"number"===typeof a?(this.frame=a,!0):!1};c.Button.prototype.setFrames=function(a,b,d,c){this.setStateFrame("Over",a,this.input.pointerOver());this.setStateFrame("Out",b,!this.input.pointerOver());this.setStateFrame("Down",d,this.input.pointerDown());this.setStateFrame("Up",c,this.input.pointerUp())}; c.Button.prototype.setStateSound=function(a,b,d){var e="on"+a+"Sound";a="on"+a+"SoundMarker";b instanceof c.Sound||b instanceof c.AudioSprite?(this[e]=b,this[a]="string"===typeof d?d:""):(this[e]=null,this[a]="")};c.Button.prototype.playStateSound=function(a){var b=this["on"+a+"Sound"];return b?(b.play(this["on"+a+"SoundMarker"]),!0):!1};c.Button.prototype.setSounds=function(a,b,d,c,f,g,k,m){this.setStateSound("Over",a,b);this.setStateSound("Out",f,g);this.setStateSound("Down",d,c);this.setStateSound("Up", k,m)};c.Button.prototype.setOverSound=function(a,b){this.setStateSound("Over",a,b)};c.Button.prototype.setOutSound=function(a,b){this.setStateSound("Out",a,b)};c.Button.prototype.setDownSound=function(a,b){this.setStateSound("Down",a,b)};c.Button.prototype.setUpSound=function(a,b){this.setStateSound("Up",a,b)};c.Button.prototype.onInputOverHandler=function(a,b){if(!b.justReleased()||(this.justReleasedPreventsOver&b.pointerMode)!==b.pointerMode)if(this.changeStateFrame("Over"),!this.onOverMouseOnly|| b.isMouse)this.playStateSound("Over"),this.onInputOver&&this.onInputOver.dispatch(this,b)};c.Button.prototype.onInputOutHandler=function(a,b){this.changeStateFrame("Out");this.playStateSound("Out");this.onInputOut&&this.onInputOut.dispatch(this,b)};c.Button.prototype.onInputDownHandler=function(a,b){this.changeStateFrame("Down");this.playStateSound("Down");this.onInputDown&&this.onInputDown.dispatch(this,b)};c.Button.prototype.onInputUpHandler=function(a,b,d){this.playStateSound("Up");this.onInputUp&& this.onInputUp.dispatch(this,b,d);this.freezeFrames||(!0===this.forceOut||(this.forceOut&b.pointerMode)===b.pointerMode?this.changeStateFrame("Out"):this.changeStateFrame("Up")||(d?this.changeStateFrame("Over"):this.changeStateFrame("Out")))};c.SpriteBatch=function(a,b,d,e){if(void 0===b||null===b)b=a.world;c.Group.call(this,a,b,d,e);this.type=c.SPRITEBATCH;this.fastSpriteBatch=null;this.ready=!1};c.SpriteBatch.prototype=Object.create(c.Group.prototype);c.SpriteBatch.prototype.constructor=c.SpriteBatch; c.SpriteBatch.prototype._renderWebGL=function(a){!this.visible||0>=this.alpha||!this.children.length||(this.ready||(this.fastSpriteBatch=new PIXI.WebGLFastSpriteBatch(a.gl),this.ready=!0),this.fastSpriteBatch.gl!==a.gl&&this.fastSpriteBatch.setContext(a.gl),a.spriteBatch.stop(),a.shaderManager.setShader(a.shaderManager.fastShader),this.fastSpriteBatch.begin(this,a),this.fastSpriteBatch.render(this),a.spriteBatch.start())};c.SpriteBatch.prototype._renderCanvas=function(a){if(this.visible&&!(0>=this.alpha)&& this.children.length){var b=a.context;b.globalAlpha=this.worldAlpha;this.displayObjectUpdateTransform();for(var d=this.worldTransform,c=!0,f=0;fa){a=Math.abs(a);var g=this.width-a;b&&d.drawImage(f,0,0,a,e,g,0,a,e);d.drawImage(f,a,0,g,e,0,0,g,e)}else g=this.width-a,b&&d.drawImage(f,g,0,a,e,0,0,a,e),d.drawImage(f,0,0,g,e,a,0,g,e);this.clear();return this.copy(this._swapCanvas)},moveV:function(a,b){void 0===b&&(b=!0);void 0===this._swapCanvas&&(this._swapCanvas=c.CanvasPool.create(this,this.width,this.height));var d=this._swapCanvas.getContext("2d"), e=this.width,f=this.canvas;d.clearRect(0,0,this.width,this.height);if(0>a){a=Math.abs(a);var g=this.height-a;b&&d.drawImage(f,0,0,e,a,0,g,e,a);d.drawImage(f,0,a,e,g,0,0,e,g)}else g=this.height-a,b&&d.drawImage(f,0,g,e,a,0,0,e,a),d.drawImage(f,0,0,e,g,0,a,e,g);this.clear();return this.copy(this._swapCanvas)},add:function(a){if(Array.isArray(a))for(var b=0;b=this.height||0>=e))g=!0}else if(2===a||3===a)if(e++,e===this.height&&(e=0,d+=f,d>=this.width||0>=d))g=!0;while(0===b.a&&!g);b.x=d;b.y=e;return b},getBounds:function(a){void 0===a&&(a=new c.Rectangle);a.x=this.getFirstPixel(2).x;if(a.x===this.width)return a.setTo(0, 0,0,0);a.y=this.getFirstPixel(0).y;a.width=this.getFirstPixel(3).x-a.x+1;a.height=this.getFirstPixel(1).y-a.y+1;return a},addToWorld:function(a,b,d,c,f,g){f=f||1;g=g||1;a=this.game.add.image(a,b,this);a.anchor.set(d,c);a.scale.set(f,g);return a},copy:function(a,b,d,e,f,g,k,m,h,n,l,t,r,v,u,w,y){if(void 0===a||null===a)a=this;a instanceof c.RenderTexture&&(a=a.getCanvas());this._image=a;if(a instanceof c.Sprite||a instanceof c.Image||a instanceof c.Text||a instanceof PIXI.Sprite){this._pos.set(a.texture.crop.x, a.texture.crop.y);this._size.set(a.texture.crop.width,a.texture.crop.height);this._scale.set(a.scale.x,a.scale.y);this._anchor.set(a.anchor.x,a.anchor.y);this._rotate=a.rotation;this._alpha.current=a.alpha;this._image=a.texture instanceof c.RenderTexture?a.texture.getCanvas():a.texture.baseTexture.source;if(void 0===g||null===g)g=a.x;if(void 0===k||null===k)k=a.y;a.texture.trim&&(g+=a.texture.trim.x-a.anchor.x*a.texture.trim.width,k+=a.texture.trim.y-a.anchor.y*a.texture.trim.height);16777215!==a.tint&& (a.cachedTint!==a.tint&&(a.cachedTint=a.tint,a.tintedTexture=PIXI.CanvasTinter.getTintedTexture(a,a.tint)),this._image=a.tintedTexture,this._pos.set(0))}else{this._pos.set(0);this._scale.set(1);this._anchor.set(0);this._rotate=0;this._alpha.current=1;if(a instanceof c.BitmapData)this._image=a.canvas;else if("string"===typeof a){a=this.game.cache.getImage(a);if(null===a)return;this._image=a}this._size.set(this._image.width,this._image.height)}if(void 0===b||null===b)b=0;if(void 0===d||null===d)d=0; e&&(this._size.x=e);f&&(this._size.y=f);if(void 0===g||null===g)g=b;if(void 0===k||null===k)k=d;if(void 0===m||null===m)m=this._size.x;if(void 0===h||null===h)h=this._size.y;"number"===typeof n&&(this._rotate=n);"number"===typeof l&&(this._anchor.x=l);"number"===typeof t&&(this._anchor.y=t);"number"===typeof r&&(this._scale.x=r);"number"===typeof v&&(this._scale.y=v);"number"===typeof u&&(this._alpha.current=u);void 0===w&&(w=null);void 0===y&&(y=!1);if(!(0>=this._alpha.current||0===this._scale.x|| 0===this._scale.y||0===this._size.x||0===this._size.y))return a=this.context,this._alpha.prev=a.globalAlpha,a.save(),a.globalAlpha=this._alpha.current,w&&(this.op=w),y&&(g|=0,k|=0),a.translate(g,k),a.scale(this._scale.x,this._scale.y),a.rotate(this._rotate),a.drawImage(this._image,this._pos.x+b,this._pos.y+d,this._size.x,this._size.y,-m*this._anchor.x,-h*this._anchor.y,m,h),a.restore(),a.globalAlpha=this._alpha.prev,this.dirty=!0,this},copyTransform:function(a,b,d){void 0===b&&(b=null);void 0===d&& (d=!1);if(!a.hasOwnProperty("worldTransform")||!a.worldVisible||0===a.worldAlpha)return this;var e=a.worldTransform;this._pos.set(a.texture.crop.x,a.texture.crop.y);this._size.set(a.texture.crop.width,a.texture.crop.height);if(0===e.a||0===e.d||0===this._size.x||0===this._size.y)return this;this._image=a.texture instanceof c.RenderTexture?a.texture.getCanvas():a.texture.baseTexture.source;var f=e.tx,g=e.ty;a.texture.trim&&(f+=a.texture.trim.x-a.anchor.x*a.texture.trim.width,g+=a.texture.trim.y-a.anchor.y* a.texture.trim.height);16777215!==a.tint&&(a.cachedTint!==a.tint&&(a.cachedTint=a.tint,a.tintedTexture=PIXI.CanvasTinter.getTintedTexture(a,a.tint)),this._image=a.tintedTexture,this._pos.set(0));d&&(f|=0,g|=0);d=this.context;this._alpha.prev=d.globalAlpha;d.save();d.globalAlpha=this._alpha.current;b&&(this.op=b);d[this.smoothProperty]=a.texture.baseTexture.scaleMode===PIXI.scaleModes.LINEAR;d.setTransform(e.a,e.b,e.c,e.d,f,g);d.drawImage(this._image,this._pos.x,this._pos.y,this._size.x,this._size.y, -this._size.x*a.anchor.x,-this._size.y*a.anchor.y,this._size.x,this._size.y);d.restore();d.globalAlpha=this._alpha.prev;this.dirty=!0;return this},copyRect:function(a,b,d,c,f,g,k){return this.copy(a,b.x,b.y,b.width,b.height,d,c,b.width,b.height,0,0,0,1,1,f,g,k)},draw:function(a,b,d,c,f,g,k){return this.copy(a,null,null,null,null,b,d,c,f,null,null,null,null,null,null,g,k)},drawGroup:function(a,b,d){0b.width&&(e=b.width);var f=this.context;f.fillStyle=f.createPattern(b,d);this._circle=new c.Circle(a.start.x,a.start.y,b.height);this._circle.circumferencePoint(a.angle-1.5707963267948966,!1,this._pos);f.save();f.translate(this._pos.x, this._pos.y);f.rotate(a.angle);f.fillRect(0,0,e,b.height);f.restore();this.dirty=!0;return this},render:function(){!this.disableTextureUpload&&this.dirty&&(this.baseTexture.dirty(),this.dirty=!1);return this},destroy:function(){this.frameData.destroy();this.texture.destroy(!0);c.CanvasPool.remove(this)},blendReset:function(){this.op="source-over";return this},blendSourceOver:function(){this.op="source-over";return this},blendSourceIn:function(){this.op="source-in";return this},blendSourceOut:function(){this.op= "source-out";return this},blendSourceAtop:function(){this.op="source-atop";return this},blendDestinationOver:function(){this.op="destination-over";return this},blendDestinationIn:function(){this.op="destination-in";return this},blendDestinationOut:function(){this.op="destination-out";return this},blendDestinationAtop:function(){this.op="destination-atop";return this},blendXor:function(){this.op="xor";return this},blendAdd:function(){this.op="lighter";return this},blendMultiply:function(){this.op= "multiply";return this},blendScreen:function(){this.op="screen";return this},blendOverlay:function(){this.op="overlay";return this},blendDarken:function(){this.op="darken";return this},blendLighten:function(){this.op="lighten";return this},blendColorDodge:function(){this.op="color-dodge";return this},blendColorBurn:function(){this.op="color-burn";return this},blendHardLight:function(){this.op="hard-light";return this},blendSoftLight:function(){this.op="soft-light";return this},blendDifference:function(){this.op= "difference";return this},blendExclusion:function(){this.op="exclusion";return this},blendHue:function(){this.op="hue";return this},blendSaturation:function(){this.op="saturation";return this},blendColor:function(){this.op="color";return this},blendLuminosity:function(){this.op="luminosity";return this},copyBitmapData:function(a,b,d){a.update();for(var c=0,f;c80*d){var m=b=a[0];var h=e=a[1];for(var n=d;nb&&(b=l);t>e&&(e=t)}l=Math.max(b-m,e-h)}c.EarCut.earcutLinked(g, k,d,m,h,l);return k};c.EarCut.linkedList=function(a,b,d,e,f){var g=0,k;var m=b;for(k=d-e;m=b;m-=e)h=c.EarCut.insertNode(m,a[m],a[m+1],h);return h};c.EarCut.filterPoints=function(a,b){if(!a)return a;b||(b=a);do{var d=!1;if(a.steiner||!c.EarCut.equals(a,a.next)&&0!==c.EarCut.area(a.prev,a,a.next))a=a.next;else{c.EarCut.removeNode(a);a=b=a.prev;if(a===a.next)return null; d=!0}}while(d||a!==b);return b};c.EarCut.earcutLinked=function(a,b,d,e,f,g,k){if(a){!k&&g&&c.EarCut.indexCurve(a,e,f,g);for(var m=a,h,n;a.prev!==a.next;)if(h=a.prev,n=a.next,g?c.EarCut.isEarHashed(a,e,f,g):c.EarCut.isEar(a))b.push(h.i/d),b.push(a.i/d),b.push(n.i/d),c.EarCut.removeNode(a),m=a=n.next;else if(a=n,a===m){k?1===k?(a=c.EarCut.cureLocalIntersections(a,b,d),c.EarCut.earcutLinked(a,b,d,e,f,g,2)):2===k&&c.EarCut.splitEarcut(a,b,d,e,f,g):c.EarCut.earcutLinked(c.EarCut.filterPoints(a),b,d,e, f,g,1);break}}};c.EarCut.isEar=function(a){var b=a.prev,d=a.next;if(0<=c.EarCut.area(b,a,d))return!1;for(var e=a.next.next;e!==a.prev;){if(c.EarCut.pointInTriangle(b.x,b.y,a.x,a.y,d.x,d.y,e.x,e.y)&&0<=c.EarCut.area(e.prev,e,e.next))return!1;e=e.next}return!0};c.EarCut.isEarHashed=function(a,b,d,e){var f=a.prev,g=a.next;if(0<=c.EarCut.area(f,a,g))return!1;var k=f.x>a.x?f.x>g.x?f.x:g.x:a.x>g.x?a.x:g.x,m=f.y>a.y?f.y>g.y?f.y:g.y:a.y>g.y?a.y:g.y,h=c.EarCut.zOrder(f.x=h;){if(d!==a.prev&&d!==a.next&&c.EarCut.pointInTriangle(f.x,f.y,a.x,a.y,g.x,g.y,d.x,d.y)&&0<=c.EarCut.area(d.prev,d,d.next))return!1;d=d.prevZ}return!0};c.EarCut.cureLocalIntersections=function(a,b,d){var e=a;do{var f=e.prev,g=e.next.next; c.EarCut.intersects(f,e,e.next,g)&&c.EarCut.locallyInside(f,g)&&c.EarCut.locallyInside(g,f)&&(b.push(f.i/d),b.push(e.i/d),b.push(g.i/d),c.EarCut.removeNode(e),c.EarCut.removeNode(e.next),e=a=g);e=e.next}while(e!==a);return e};c.EarCut.splitEarcut=function(a,b,d,e,f,g){var k=a;do{for(var m=k.next.next;m!==k.prev;){if(k.i!==m.i&&c.EarCut.isValidDiagonal(k,m)){a=c.EarCut.splitPolygon(k,m);k=c.EarCut.filterPoints(k,k.next);a=c.EarCut.filterPoints(a,a.next);c.EarCut.earcutLinked(k,b,d,e,f,g);c.EarCut.earcutLinked(a, b,d,e,f,g);return}m=m.next}k=k.next}while(k!==a)};c.EarCut.eliminateHoles=function(a,b,d,e){var f=[],g;var k=0;for(g=b.length;k=d.next.y){var k=d.x+(f-d.y)*(d.next.x-d.x)/(d.next.y-d.y);if(k<=e&&k>g){g=k;var m=d.x=d.x&&d.x>=m.x&&c.EarCut.pointInTriangle(fm.x)&& c.EarCut.locallyInside(d,a)&&(m=d,k=h)}d=d.next}return m};c.EarCut.indexCurve=function(a,b,d,e){var f=a;do null===f.z&&(f.z=c.EarCut.zOrder(f.x,f.y,b,d,e)),f.prevZ=f.prev,f=f.nextZ=f.next;while(f!==a);f.prevZ.nextZ=null;f.prevZ=null;c.EarCut.sortLinked(f)};c.EarCut.sortLinked=function(a){var b,d,c,f,g=1;do{var k=a;var m=a=null;for(d=0;k;){d++;var h=k;for(b=c=0;bc.EarCut.area(a.prev,a,a.next)?0<=c.EarCut.area(a,b,a.next)&&0<=c.EarCut.area(a,a.prev,b):0>c.EarCut.area(a,b,a.prev)||0>c.EarCut.area(a,a.next,b)};c.EarCut.middleInside=function(a,b){var d=a,c=!1,f=(a.x+b.x)/2;b=(a.y+ b.y)/2;do d.y>b!==d.next.y>b&&f<(d.next.x-d.x)*(b-d.y)/(d.next.y-d.y)+d.x&&(c=!c),d=d.next;while(d!==a);return c};c.EarCut.splitPolygon=function(a,b){var d=new c.EarCut.Node(a.i,a.x,a.y),e=new c.EarCut.Node(b.i,b.x,b.y),f=a.next,g=b.prev;a.next=b;b.prev=a;d.next=f;f.prev=d;e.next=d;d.prev=e;g.next=e;e.prev=g;return e};c.EarCut.insertNode=function(a,b,d,e){a=new c.EarCut.Node(a,b,d);e?(a.next=e.next,a.prev=e,e.next.prev=a,e.next=a):(a.prev=a,a.next=a);return a};c.EarCut.removeNode=function(a){a.next.prev= a.prev;a.prev.next=a.next;a.prevZ&&(a.prevZ.nextZ=a.nextZ);a.nextZ&&(a.nextZ.prevZ=a.prevZ)};c.EarCut.Node=function(a,b,d){this.i=a;this.x=b;this.y=d;this.nextZ=this.prevZ=this.z=this.next=this.prev=null;this.steiner=!1};PIXI.WebGLGraphics=function(){};PIXI.WebGLGraphics.stencilBufferLimit=6;PIXI.WebGLGraphics.renderGraphics=function(a,b){var d=b.gl,e=b.projection,f=b.offset,g=b.shaderManager.primitiveShader;a.dirty&&PIXI.WebGLGraphics.updateGraphics(a,d);var k=a._webGL[d.id];if(k)for(var m=0;m=PIXI.WebGLGraphics.stencilBufferLimit&&(f.points.length<2*PIXI.WebGLGraphics.stencilBufferLimit?(e=PIXI.WebGLGraphics.switchMode(d,0),PIXI.WebGLGraphics.buildPoly(f, e)||(e=PIXI.WebGLGraphics.switchMode(d,1),PIXI.WebGLGraphics.buildComplexPoly(f,e))):(e=PIXI.WebGLGraphics.switchMode(d,1),PIXI.WebGLGraphics.buildComplexPoly(f,e))),0=r;r++)t=r/20,e=a+(d-a)*t,m=b+(c-b)*t,h=d+(f-d)*t,n=c+(g-c)*t,e+=(h-e)*t,m+=(n-m)*t,l.push(e,m);return l};PIXI.WebGLGraphics.buildCircle=function(a,b){var d=a.shape,e=d.x,f=d.y,g;a.type=== c.CIRCLE?d=g=d.radius:(g=d.width,d=d.height);var k=2*Math.PI/40;if(a.fill){var m=c.Color.hexToRGBArray(a.fillColor);var h=a.fillAlpha,n=m[0]*h,l=m[1]*h,t=m[2]*h,r=b.points,v=b.indices,u=r.length/6;v.push(u);for(m=0;41>m;m++)r.push(e,f,n,l,t,h),r.push(e+Math.sin(k*m)*g,f+Math.cos(k*m)*d,n,l,t,h),v.push(u++,u++);v.push(u-1)}if(a.lineWidth){h=a.points;a.points=[];for(m=0;41>m;m++)a.points.push(e+Math.sin(k*m)*g,f+Math.cos(k*m)*d);PIXI.WebGLGraphics.buildLine(a,b);a.points=h}};PIXI.WebGLGraphics.buildLine= function(a,b){var d,e=a.points;if(0!==e.length){if(a.lineWidth%2)for(d=0;dMath.abs(B)?(g.push(u-y,w-A,n,l,t,a),g.push(u+y,w+A,n,l,t,a)):(D=(D*C-H*r)/B,z=(v*r-z*C)/B,C=(D-u)*(D-u)+(z-w)+(z-w),19600d.length)){var e=b.indices;b.points=d;b.alpha=a.fillAlpha;b.color=c.Color.hexToRGBArray(a.fillColor);b=Infinity;var f=-Infinity,g=Infinity,k=-Infinity;for(a=0;af?m:f;g=hk?h:k}d.push(b,g,f,g,f,k,b,k);d=d.length/2;for(a=0;ad.length)){var e=b.points;b=b.indices;var f=d.length/2,g=c.Color.hexToRGBArray(a.fillColor);a=a.fillAlpha;var k=g[0]*a,h=g[1]*a;g=g[2]*a;var p=c.EarCut.Triangulate(d,null,2);if(!p)return!1;var n=e.length/6,l;for(l=0;lv?v:g;b.beginPath();b.moveTo(p,n+g);b.lineTo(p,n+r-g);b.quadraticCurveTo(p,n+r,p+g,n+r);b.lineTo(p+t-g,n+r);b.quadraticCurveTo(p+t,n+r,p+t,n+r-g);b.lineTo(p+t,n+g);b.quadraticCurveTo(p+t,n,p+t-g,n);b.lineTo(p+g,n);b.quadraticCurveTo(p,n,p,n+g);b.closePath();if(f.fillColor||0===f.fillColor)b.globalAlpha=f.fillAlpha*d,b.fillStyle="#"+("00000"+(k|0).toString(16)).substr(-6),b.fill();f.lineWidth&&(b.globalAlpha=f.lineAlpha*d,b.strokeStyle="#"+("00000"+(h|0).toString(16)).substr(-6), b.stroke())}}};PIXI.CanvasGraphics.renderGraphicsMask=function(a,b){var d=a.graphicsData.length;if(0!==d){b.beginPath();for(var e=0;el?l:g,b.moveTo(f,k+g),b.lineTo(f,k+n-g),b.quadraticCurveTo(f,k+n,f+g,k+n),b.lineTo(f+p-g,k+n),b.quadraticCurveTo(f+p, k+n,f+p,k+n-g),b.lineTo(f+p,k+g),b.quadraticCurveTo(f+p,k,f+p-g,k),b.lineTo(f+g,k),b.quadraticCurveTo(f,k,f,k+g),b.closePath())}}};PIXI.CanvasGraphics.updateGraphicsTint=function(a){if(16777215!==a.tint)for(var b=(a.tint>>16&255)/255,d=(a.tint>>8&255)/255,c=(a.tint&255)/255,f=0;f>16&255)/255*b*255<<16)+((k>>8&255)/255*d*255<<8)+(k&255)/255*c*255;g._lineTint=((h>>16&255)/255*b*255<<16)+((h>>8&255)/255* d*255<<8)+(h&255)/255*c*255}};c.GraphicsData=function(a,b,d,c,f,g,k){this.lineWidth=a;this.lineColor=b;this.lineAlpha=d;this._lineTint=b;this.fillColor=c;this.fillAlpha=f;this._fillTint=c;this.fill=g;this.shape=k;this.type=k.type};c.GraphicsData.prototype.constructor=c.GraphicsData;c.GraphicsData.prototype.clone=function(){return new c.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.fill,this.shape)};c.Graphics=function(a,b,d){void 0===b&&(b=0);void 0=== d&&(d=0);this.type=c.GRAPHICS;this.physicsType=c.SPRITE;this.anchor=new c.Point;PIXI.DisplayObjectContainer.call(this);this.renderable=!0;this.fillAlpha=1;this.lineColor=this.lineWidth=0;this.graphicsData=[];this.tint=16777215;this.blendMode=PIXI.blendModes.NORMAL;this.currentPath=null;this._webGL=[];this.isMask=!1;this.boundsPadding=0;this._localBounds=new c.Rectangle(0,0,1,1);this.dirty=!0;this.cachedSpriteDirty=this.webGLDirty=this._boundsDirty=!1;c.Component.Core.init.call(this,a,b,d,"",null)}; c.Graphics.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);c.Graphics.prototype.constructor=c.Graphics;c.Component.Core.install.call(c.Graphics.prototype,"Angle AutoCull Bounds Destroy FixedToCamera InputEnabled InWorld LifeSpan PhysicsBody Reset".split(" "));c.Graphics.prototype.preUpdatePhysics=c.Component.PhysicsBody.preUpdate;c.Graphics.prototype.preUpdateLifeSpan=c.Component.LifeSpan.preUpdate;c.Graphics.prototype.preUpdateInWorld=c.Component.InWorld.preUpdate;c.Graphics.prototype.preUpdateCore= c.Component.Core.preUpdate;c.Graphics.prototype.preUpdate=function(){return this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld()?this.preUpdateCore():!1};c.Graphics.prototype.postUpdate=function(){c.Component.PhysicsBody.postUpdate.call(this);c.Component.FixedToCamera.postUpdate.call(this);this._boundsDirty&&(this.updateLocalBounds(),this._boundsDirty=!1);for(var a=0;a=p;++p){h=p/20;var n=g+(a-g)*h;var l=k+(b-k)*h;e.push(n+(a+(d-a)*h-n)*h,l+(b+(c-b)*h-l)*h)}this._boundsDirty=this.dirty= !0;return this};c.Graphics.prototype.bezierCurveTo=function(a,b,d,c,f,g){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);for(var e,h,p,n,l,t=this.currentPath.shape.points,r=t[t.length-2],v=t[t.length-1],u,w=1;20>=w;++w)u=w/20,e=1-u,h=e*e,p=h*e,n=u*u,l=n*u,t.push(p*r+3*h*u*a+3*e*n*d+l*f,p*v+3*h*u*b+3*e*n*c+l*g);this._boundsDirty=this.dirty=!0;return this};c.Graphics.prototype.arcTo=function(a,b,d,c,f){this.currentPath?0===this.currentPath.shape.points.length&& this.currentPath.shape.points.push(a,b):this.moveTo(a,b);var e=this.currentPath.shape.points,k=e[e.length-1]-b,h=e[e.length-2]-a;c-=b;d-=a;var p=Math.abs(k*d-h*c);if(1E-8>p||0===f)e[e.length-2]===a&&e[e.length-1]===b||e.push(a,b);else{var n=k*k+h*h,l=c*c+d*d,t=k*c+h*d;e=f*Math.sqrt(n)/p;p=f*Math.sqrt(l)/p;n=e*t/n;l=p*t/l;t=e*d+p*h;var r=e*c+p*k;this.arc(t+a,r+b,f,Math.atan2(k*(p+n)-r,h*(p+n)-t),Math.atan2(c*(e+l)-r,d*(e+l)-t),h*c>d*k)}this._boundsDirty=this.dirty=!0;return this};c.Graphics.prototype.arc= function(a,b,d,c,f,g,k){if(c===f)return this;void 0===g&&(g=!1);void 0===k&&(k=40);!g&&f<=c?f+=2*Math.PI:g&&c<=f&&(c+=2*Math.PI);f=g?-1*(c-f):f-c;var e=Math.ceil(Math.abs(f)/(2*Math.PI))*k;if(0===f)return this;k=a+Math.cos(c)*d;var h=b+Math.sin(c)*d;g&&this.filling?this.moveTo(a,b):this.moveTo(k,h);g=this.currentPath.shape.points;f/=2*e;k=2*f;h=Math.cos(f);var n=Math.sin(f);--e;for(var l=e%1/e,t=0;t<=e;t++){var r=f+c+k*(t+l*t),v=Math.cos(r);r=-Math.sin(r);g.push((h*v+n*r)*d+a,(h*-r+n*v)*d+b)}this._boundsDirty= this.dirty=!0;return this};c.Graphics.prototype.beginFill=function(a,b){this.filling=!0;this.fillColor=a||0;this.fillAlpha=void 0===b?1:b;this.currentPath&&2>=this.currentPath.shape.points.length&&(this.currentPath.fill=this.filling,this.currentPath.fillColor=this.fillColor,this.currentPath.fillAlpha=this.fillAlpha);return this};c.Graphics.prototype.endFill=function(){this.filling=!1;this.fillColor=null;this.fillAlpha=1;return this};c.Graphics.prototype.drawRect=function(a,b,d,e){this.drawShape(new c.Rectangle(a, b,d,e));return this};c.Graphics.prototype.drawRoundedRect=function(a,b,d,e,f){this.drawShape(new c.RoundedRectangle(a,b,d,e,f));return this};c.Graphics.prototype.drawCircle=function(a,b,d){this.drawShape(new c.Circle(a,b,d));return this};c.Graphics.prototype.drawEllipse=function(a,b,d,e){this.drawShape({x:a,y:b,width:d,height:e,type:c.ELLIPSE});return this};c.Graphics.prototype.drawPolygon=function(a){a instanceof c.Polygon&&(a=a.points);var b=a;if(!Array.isArray(b)){b=Array(arguments.length);for(var d= 0;df?a:f;f=v>f?v:f;h=g>h?g:h;h=d>h?d:h;this._bounds.x=r;this._bounds.width=(k>f?k:f)-r;this._bounds.y=b;this._bounds.height=(e>h?e:h)-b;return this._currentBounds=this._bounds};c.Graphics.prototype.getLocalBounds=function(){var a=this.worldTransform;this.worldTransform=c.identityMatrix;for(var b=0;bb?g+h:b,d=ke?k+p:e;else if(g===c.CIRCLE)g=f.x,k=f.y,h=f.radius+p/2,p=f.radius+p/2,a=g-hb?g+h:b,d=k-pe?k+p:e;else if(g===c.ELLIPSE)g=f.x,k=f.y,h=f.width+p/2,p=f.height+p/2,a=g-hb?g+h:b,d=k-pe?k+p:e;else for(f=f.points,h=0;hb?g+p:b,d=k-pe?k+p:e;else e=d=b=a=0;n=this.boundsPadding;this._localBounds.x=a-n;this._localBounds.width=b-a+2*n;this._localBounds.y=d-n;this._localBounds.height=e-d+2*n};c.Graphics.prototype._generateCachedSprite=function(){var a=this.getLocalBounds();if(this._cachedSprite)this._cachedSprite.buffer.resize(a.width,a.height);else{var b=new PIXI.CanvasBuffer(a.width,a.height),d=PIXI.Texture.fromCanvas(b.canvas); this._cachedSprite=new PIXI.Sprite(d);this._cachedSprite.buffer=b;this._cachedSprite.worldTransform=this.worldTransform}this._cachedSprite.anchor.x=-(a.x/a.width);this._cachedSprite.anchor.y=-(a.y/a.height);this._cachedSprite.buffer.context.translate(-a.x,-a.y);this.worldAlpha=1;PIXI.CanvasGraphics.renderGraphics(this,this._cachedSprite.buffer.context);this._cachedSprite.alpha=this.alpha};c.Graphics.prototype.updateCachedSpriteTexture=function(){var a=this._cachedSprite,b=a.texture,d=a.buffer.canvas; b.baseTexture.width=d.width;b.baseTexture.height=d.height;b.crop.width=b.frame.width=d.width;b.crop.height=b.frame.height=d.height;a._width=d.width;a._height=d.height;b.baseTexture.dirty()};c.Graphics.prototype.destroyCachedSprite=function(){this._cachedSprite.texture.destroy(!0);this._cachedSprite=null};c.Graphics.prototype.drawShape=function(a){this.currentPath&&2>=this.currentPath.shape.points.length&&this.graphicsData.pop();this.currentPath=null;a instanceof c.Polygon&&(a=a.clone(),a.flatten()); a=new c.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,a);this.graphicsData.push(a);a.type===c.POLYGON&&(a.shape.closed=this.filling,this.currentPath=a);this._boundsDirty=this.dirty=!0;return a};Object.defineProperty(c.Graphics.prototype,"cacheAsBitmap",{get:function(){return this._cacheAsBitmap},set:function(a){(this._cacheAsBitmap=a)?this._generateCachedSprite():this.destroyCachedSprite();this.webGLDirty=this.dirty=!0}});c.RenderTexture=function(a, b,d,e,f,g,k,h){void 0===b&&(b=100);void 0===d&&(d=100);void 0===e&&(e="");void 0===f&&(f=c.scaleModes.DEFAULT);void 0===g&&(g=1);void 0===k&&(k=PIXI.defaultRenderer);void 0===h&&(h=0);this.game=a;this.key=e;this.type=c.RENDERTEXTURE;this._tempMatrix=new c.Matrix;this.width=b;this.height=d;this.resolution=g;this.frame=new c.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution);this.crop=this.frame.clone();this.baseTexture=new PIXI.BaseTexture;this.baseTexture.width=this.width*this.resolution; this.baseTexture.height=this.height*this.resolution;this.baseTexture._glTextures=[];this.baseTexture.resolution=this.resolution;this.baseTexture.scaleMode=f;this.baseTexture.hasLoaded=!0;PIXI.Texture.call(this,this.baseTexture,this.frame.clone());this.renderer=k;this.renderer.type===c.WEBGL?(a=this.renderer.gl,this.baseTexture.textureIndex=h,this.baseTexture._dirty[a.id]=!1,this.textureBuffer=new PIXI.FilterTexture(a,this.width,this.height,this.baseTexture.scaleMode,h),this.baseTexture._glTextures[a.id]= this.textureBuffer.texture,this.projection=new c.Point(.5*this.width,.5*-this.height)):(this.textureBuffer=new PIXI.CanvasBuffer(this.width*this.resolution,this.height*this.resolution),this.baseTexture.source=this.textureBuffer.canvas);this.valid=!0;this.tempMatrix=new c.Matrix;this._updateUvs()};c.RenderTexture.prototype=Object.create(PIXI.Texture.prototype);c.RenderTexture.prototype.constructor=c.RenderTexture;c.RenderTexture.prototype.renderXY=function(a,b,d,e){a.updateTransform();this._tempMatrix.copyFrom(a.worldTransform); this._tempMatrix.tx=b;this._tempMatrix.ty=d;this.renderer.type===c.WEBGL?this._renderWebGL(a,this._tempMatrix,e):this._renderCanvas(a,this._tempMatrix,e)};c.RenderTexture.prototype.renderRawXY=function(a,b,d,e){this._tempMatrix.identity().translate(b,d);this.renderer.type===c.WEBGL?this._renderWebGL(a,this._tempMatrix,e):this._renderCanvas(a,this._tempMatrix,e)};c.RenderTexture.prototype.render=function(a,b,d){void 0===b||null===b?this._tempMatrix.copyFrom(a.worldTransform):this._tempMatrix.copyFrom(b); this.renderer.type===c.WEBGL?this._renderWebGL(a,this._tempMatrix,d):this._renderCanvas(a,this._tempMatrix,d)};c.RenderTexture.prototype.resize=function(a,b,d){if(a!==this.width||b!==this.height)this.valid=0l&&Math.abs(l)>p&&(l=-p);0!==l&&(k+=0l){if(0===n){for(f=t;f.length&&!(f=f.slice(0,-1),r=b.measureText(f).width,r<=l););if(!f.length)throw Error("This text's wordWrapWidth setting is less than a single character!");l=q.substr(f.length); k[n]=l;h+=f}l=k.slice(k[n].length?n:n+1).join(" ").replace(/[ \n]*$/gi,"");a[g+1]=l+" "+(a[g+1]||"");f=a.length;break}else h+=t,l-=r}c+=h.replace(/[ \n]*$/gi,"")+"\n"}}return c=c.replace(/[\s|\n]*$/gi,"")};c.Text.prototype.basicWordWrap=function(a){var b="";a=a.split("\n");for(var d=0;dc?(0d&&(this.style.wordWrapWidth=d));this.updateTexture();return this};c.Text.prototype.updateTexture=function(){var a=this.texture.baseTexture,b=this.texture.crop,d=this.texture.frame,c=this.canvas.width,f=this.canvas.height;a.width=c;a.height=f;b.width=c;b.height=f;d.width=c;d.height=f;this.texture.width= c;this.texture.height=f;this._width=c;this._height=f;this.textBounds&&(a=this.textBounds.x,b=this.textBounds.y,"right"===this.style.boundsAlignH?a+=this.textBounds.width-this.canvas.width/this.resolution:"center"===this.style.boundsAlignH&&(a+=this.textBounds.halfWidth-this.canvas.width/this.resolution/2),"bottom"===this.style.boundsAlignV?b+=this.textBounds.height-this.canvas.height/this.resolution:"middle"===this.style.boundsAlignV&&(b+=this.textBounds.halfHeight-this.canvas.height/this.resolution/ 2),this.pivot.x=-a,this.pivot.y=-b);this.renderable=0!==c&&0!==f;this.texture.requiresReTint=!0;this.texture.baseTexture.dirty()};c.Text.prototype._renderWebGL=function(a){this.dirty&&(this.updateText(),this.dirty=!1);PIXI.Sprite.prototype._renderWebGL.call(this,a)};c.Text.prototype._renderCanvas=function(a){this.dirty&&(this.updateText(),this.dirty=!1);PIXI.Sprite.prototype._renderCanvas.call(this,a)};c.Text.prototype.determineFontProperties=function(a){var b=c.Text.fontPropertiesCache[a],d=this.testString|| "|M\u00c9q";if(!b){b={};var e=c.Text.fontPropertiesCanvas,f=c.Text.fontPropertiesContext;f.font=a;var g=Math.ceil(f.measureText(d).width),k=Math.ceil(f.measureText(d).width),h=2*k;k=1.4*k|0;e.width=g;e.height=h;f.fillStyle="#f00";f.fillRect(0,0,g,h);f.font=a;f.textBaseline="alphabetic";f.fillStyle="#000";f.fillText(d,0,k);if(!f.getImageData(0,0,g,h))return b.ascent=k,b.descent=k+6,b.fontSize=b.ascent+b.descent,c.Text.fontPropertiesCache[a]=b;d=f.getImageData(0,0,g,h).data;e=d.length;g*=4;var l,n= 0,q=!1;for(f=0;fk;f--){for(l=0;l=l&&-1this.textWidth&&(this.textWidth=g.width);f+=a.lineHeight*d;b=b.substr(g.text.length+1)}while(!1===g.end);this.textHeight=f;f=b=0;for(var k=this.textWidth*this.anchor.x,h=this.textHeight*this.anchor.y,l=0;l?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; c.RetroFont.TEXT_SET2=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ";c.RetroFont.TEXT_SET3="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ";c.RetroFont.TEXT_SET4="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789";c.RetroFont.TEXT_SET5="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789";c.RetroFont.TEXT_SET6="ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ";c.RetroFont.TEXT_SET7="AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39";c.RetroFont.TEXT_SET8="0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ";c.RetroFont.TEXT_SET9= "ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!";c.RetroFont.TEXT_SET10="ABCDEFGHIJKLMNOPQRSTUVWXYZ";c.RetroFont.TEXT_SET11="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789";c.RetroFont.prototype.setFixedWidth=function(a,b){void 0===b&&(b="left");this.fixedWidth=a;this.align=b};c.RetroFont.prototype.setText=function(a,b,d,c,f,g){this.multiLine=b||!1;this.customSpacingX=d||0;this.customSpacingY=c||0;this.align=f||"left";this.autoUpperCase=g?!1:!0;0e&&(e=0);this.pasteLine(b[d],e,a,this.customSpacingX);a+=this.characterHeight+this.customSpacingY}}else 0e&&(e=0),this.pasteLine(this._text,e,0,this.customSpacingX);this.requiresReTint=!0};c.RetroFont.prototype.pasteLine=function(a,b,d,c){for(var e=0;ethis.width))break};c.RetroFont.prototype.getLongestLine=function(){var a=0;if(0a&&(a=b[d].length);return a};c.RetroFont.prototype.removeUnsupportedCharacters=function(a){for(var b="",d=0;da.length)){var b=this.uvs,d=this.indices,c=this.colors;this.count-=.2;b[0]=0;b[1]=0;b[2]=0;b[3]=1;c[0]=1;c[1]=1;d[0]=0;d[1]=1;a=a.length;for(var f,g,k=1;ka.length)){var b=a[0];this.count-=.2;for(var d=this.vertices,c=a.length,f,g,k,h=0;h=this.alpha||(a.spriteBatch.stop(), this._vertexBuffer||this._initWebGL(a),a.shaderManager.setShader(a.shaderManager.stripShader),this._renderStrip(a),a.spriteBatch.start())};c.Rope.prototype._initWebGL=function(a){a=a.gl;this._vertexBuffer=a.createBuffer();this._indexBuffer=a.createBuffer();this._uvBuffer=a.createBuffer();this._colorBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,this._vertexBuffer);a.bufferData(a.ARRAY_BUFFER,this.vertices,a.DYNAMIC_DRAW);a.bindBuffer(a.ARRAY_BUFFER,this._uvBuffer);a.bufferData(a.ARRAY_BUFFER, this.uvs,a.STATIC_DRAW);a.bindBuffer(a.ARRAY_BUFFER,this._colorBuffer);a.bufferData(a.ARRAY_BUFFER,this.colors,a.STATIC_DRAW);a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this._indexBuffer);a.bufferData(a.ELEMENT_ARRAY_BUFFER,this.indices,a.STATIC_DRAW)};c.Rope.prototype._renderStrip=function(a){var b=a.gl,d=a.projection,e=a.offset,f=a.shaderManager.stripShader,g=this.drawMode===c.Rope.TRIANGLE_STRIP?b.TRIANGLE_STRIP:b.TRIANGLES;a.blendModeManager.setBlendMode(this.blendMode);b.uniformMatrix3fv(f.translationMatrix, !1,this.worldTransform.toArray(!0));b.uniform2f(f.projectionVector,d.x,-d.y);b.uniform2f(f.offsetVector,-e.x,-e.y);b.uniform1f(f.alpha,this.worldAlpha);this.dirty?(this.dirty=!1,b.bindBuffer(b.ARRAY_BUFFER,this._vertexBuffer),b.bufferData(b.ARRAY_BUFFER,this.vertices,b.STATIC_DRAW),b.vertexAttribPointer(f.aVertexPosition,2,b.FLOAT,!1,0,0),b.bindBuffer(b.ARRAY_BUFFER,this._uvBuffer),b.bufferData(b.ARRAY_BUFFER,this.uvs,b.STATIC_DRAW),b.vertexAttribPointer(f.aTextureCoord,2,b.FLOAT,!1,0,0),b.activeTexture(b.TEXTURE0), this.texture.baseTexture._dirty[b.id]?a.renderer.updateTexture(this.texture.baseTexture):b.bindTexture(b.TEXTURE_2D,this.texture.baseTexture._glTextures[b.id]),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,this._indexBuffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,this.indices,b.STATIC_DRAW)):(b.bindBuffer(b.ARRAY_BUFFER,this._vertexBuffer),b.bufferSubData(b.ARRAY_BUFFER,0,this.vertices),b.vertexAttribPointer(f.aVertexPosition,2,b.FLOAT,!1,0,0),b.bindBuffer(b.ARRAY_BUFFER,this._uvBuffer),b.vertexAttribPointer(f.aTextureCoord, 2,b.FLOAT,!1,0,0),b.activeTexture(b.TEXTURE0),this.texture.baseTexture._dirty[b.id]?a.renderer.updateTexture(this.texture.baseTexture):b.bindTexture(b.TEXTURE_2D,this.texture.baseTexture._glTextures[b.id]),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,this._indexBuffer));b.drawElements(g,this.indices.length,b.UNSIGNED_SHORT,0)};c.Rope.prototype._renderCanvas=function(a){var b=a.context,d=this.worldTransform,e=d.tx*a.resolution+a.shakeX,f=d.ty*a.resolution+a.shakeY;a.roundPixels?b.setTransform(d.a,d.b,d.c,d.d, e|0,f|0):b.setTransform(d.a,d.b,d.c,d.d,e,f);this.drawMode===c.Rope.TRIANGLE_STRIP?this._renderCanvasTriangleStrip(b):this._renderCanvasTriangles(b)};c.Rope.prototype._renderCanvasTriangleStrip=function(a){var b=this.vertices,d=this.uvs,c=b.length/2;this.count++;for(var f=0;fb?x:b;h=r>h? r:h}if(-Infinity===l||Infinity===h)return c.EmptyRectangle;a=this._bounds;a.x=l;a.width=b-l;a.y=n;a.height=h-n;return this._currentBounds=a};Object.defineProperty(c.Rope.prototype,"updateAnimation",{get:function(){return this._updateAnimation},set:function(a){a&&"function"===typeof a?(this._hasUpdateAnimation=!0,this._updateAnimation=a):(this._hasUpdateAnimation=!1,this._updateAnimation=null)}});Object.defineProperty(c.Rope.prototype,"segments",{get:function(){for(var a=[],b,d,e,f,g=0;gf?b:f;f=r>f?r:f;f=u>f?u:f;h=a>h?a:h;h=g>h?g:h;h=d>h?d:h;b=this._bounds;b.x=n;b.width=(k>f?k:f)-n;b.y=l;b.height=(c>h?c:h)-l;return this._currentBounds=b};Object.defineProperty(c.TileSprite.prototype,"width",{get:function(){return this._width}, set:function(a){this._width=a}});Object.defineProperty(c.TileSprite.prototype,"height",{get:function(){return this._height},set:function(a){this._height=a}});c.CanvasPool={create:function(a,b,d){var e=c.CanvasPool.getFirst();-1===e?(a={parent:a,canvas:document.createElement("canvas")},c.CanvasPool.pool.push(a),a=a.canvas):(c.CanvasPool.pool[e].parent=a,a=c.CanvasPool.pool[e].canvas);void 0!==b&&(a.width=b,a.height=d);return a},getFirst:function(){for(var a=c.CanvasPool.pool,b=0;bd.firefoxVersion&&(d.getUserMedia=!1);!d.iOS&&(d.ie||d.firefox||d.chrome)&&(d.canvasBitBltShift=!0);if(d.safari||d.mobileSafari)d.canvasBitBltShift=!1;(function(){var a=c.CanvasPool.create(this,6,1),b=a.getContext("2d");b.fillStyle="rgba(10, 20, 30, 0.5)";b.fillRect(0,0,1,1);var g=b.getImageData(0, 0,1,1);if(g){b.putImageData(g,1,0);var k=b.getImageData(1,0,1,1);d.canHandleAlpha=k.data[0]===g.data[0]&&k.data[1]===g.data[1]&&k.data[2]===g.data[2]&&k.data[3]===g.data[3]}b.globalCompositeOperation="multiply";d.canUseMultiply="multiply"===b.globalCompositeOperation;c.CanvasPool.removeByCanvas(a);PIXI.CanvasTinter.tintMethod=d.canUseMultiply?PIXI.CanvasTinter.tintWithMultiply:PIXI.CanvasTinter.tintWithPerPixel})();(function(){for(var a="requestFullscreen requestFullScreen webkitRequestFullscreen webkitRequestFullScreen msRequestFullscreen msRequestFullScreen mozRequestFullScreen mozRequestFullscreen".split(" "), b=document.createElement("div"),c=0;ca[1]};c.Canvas={create:function(a,b,d,e,f){b=b||256;d=d||256;a=f?document.createElement("canvas"):c.CanvasPool.create(a,b,d);"string"===typeof e&&""!==e&&(a.id=e);a.width=b;a.height=d;a.style.display="block";return a},setBackgroundColor:function(a,b){a.style.backgroundColor=b||"rgb(0,0,0)";return a},setTouchAction:function(a,b){b=b||"none";a.style.msTouchAction=b;a.style["ms-touch-action"]=b;a.style["touch-action"]=b;return a},setUserSelect:function(a,b){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)";return a},addToDOM:function(a,b,d){var c;void 0===d&&(d=!0);b&&("string"===typeof b?c=document.getElementById(b):"object"===typeof b&&1===b.nodeType&&(c=b));c||(c=document.body);d&&c.style&&(c.style.overflow="hidden");c.appendChild(a);return a},removeFromDOM:function(a){a.parentNode&&a.parentNode.removeChild(a)}, setTransform:function(a,b,d,c,f,g,k){a.setTransform(c,g,k,f,b,d);return a},setSmoothingEnabled:function(a,b){var d=c.Canvas.getSmoothingPrefix(a);d&&(a[d]=b);return a},getSmoothingPrefix:function(a){var b=["i","webkitI","msI","mozI","oI"],d;for(d in b){var c=b[d]+"mageSmoothingEnabled";if(c in a)return c}return null},getSmoothingEnabled:function(a){var b=c.Canvas.getSmoothingPrefix(a);if(b)return a[b]},setImageRenderingCrisp:function(a){for(var b=["-webkit-optimize-contrast","-moz-crisp-edges","crisp-edges", "pixelated"],d=0;db){var d= a;a=b;b=d}return Math.random()*(b-a)+a},between:function(a,b){void 0===a&&(a=0);void 0===b&&(b=1);if(a===b)return a;if(a>b){var d=a;a=b;b=d}a=Math.ceil(a);b=Math.floor(b);return Math.floor(Math.random()*(b-a+1))+a},fuzzyEqual:function(a,b,d){void 0===d&&(d=1E-4);return Math.abs(a-b)b-d},fuzzyCeil:function(a,b){void 0===b&&(b=1E-4);return Math.ceil(a-b)},fuzzyFloor:function(a, b){void 0===b&&(b=1E-4);return Math.floor(a+b)},average:function(){for(var a=0,b=arguments.length,d=0;da?-0:0===a?a:0):a},rotateToAngle:function(a,b,d){void 0===d&&(d=.05);if(a===b)return a;Math.abs(b-a)<=d||Math.abs(b-a)>=c.Math.PI2-d?a=b:(Math.abs(b-a)>Math.PI&&(b=ba?a+=d:b=d)return 0;a=(a-b)%d;0>a&&(a+=d);return a+b},wrapValue:function(a,b,d){a=Math.abs(a);b=Math.abs(b);d=Math.abs(d);return(a+b)%d},isOdd:function(a){return!!(a&1)},isEven:function(a){return!(a&1)},min:function(){for(var a=1===arguments.length&&"object"===typeof arguments[0]?arguments[0]:arguments,b=1,d=0,c=a.length;ba[d]&&(d=b);return a[d]},minProperty:function(a){for(var b=2===arguments.length&&"object"===typeof arguments[1]?arguments[1]:arguments.slice(1),d=1,c=0,f=b.length;db[c][a]&&(c=d);return b[c][a]}, wrapAngle:function(a,b){return b?this.wrap(a,-Math.PI,Math.PI):this.wrap(a,-180,180)},linearInterpolation:function(a,b){var d=a.length-1,c=d*b,f=Math.floor(c);return 0>b?this.linear(a[0],a[1],c):1d?d:f+1],c-f)},bezierInterpolation:function(a,b){for(var d=0,c=a.length-1,f=0;f<=c;f++)d+=Math.pow(1-b,c-f)*Math.pow(b,f)*a[f]*this.bernstein(c,f);return d},catmullRomInterpolation:function(a,b){var d=a.length-1,c=d*b,f=Math.floor(c);return a[0]===a[d]? (0>b&&(f=Math.floor(c=d*(1+b))),this.catmullRom(a[(f-1+d)%d],a[f],a[(f+1)%d],a[(f+2)%d],c-f)):0>b?a[0]-(this.catmullRom(a[0],a[0],a[1],a[1],-c)-a[0]):1a?-1:0b||d>b?1:aa?0:(a-d)/b}};c.RandomDataGenerator=function(a){void 0===a&&(a=[]);this.c=1;this.s2=this.s1=this.s0=0;"string"===typeof a?this.state(a):this.sow(a)};c.RandomDataGenerator.prototype={rnd:function(){var a=2091639*this.s0+2.3283064365386963E-10*this.c;this.c=a|0;this.s0=this.s1;this.s1=this.s2;return this.s2=a-this.c},sow:function(a){this.s0=this.hash(" ");this.s1= this.hash(this.s0);this.s2=this.hash(this.s1);this.c=1;if(a)for(var b=0;bthis.s0);this.s1-=this.hash(d);this.s1+=~~(0>this.s1);this.s2-=this.hash(d);this.s2+=~~(0>this.s2)}},hash:function(a){var b;var d=4022871197;a=a.toString();for(b=0;b>>0;c-=d;c*=d;d=c>>>0;c-=d;d+=4294967296*c}return 2.3283064365386963E-10*(d>>>0)},integer:function(){return 4294967296*this.rnd.apply(this)}, frac:function(){return this.rnd.apply(this)+1.1102230246251565E-16*(2097152*this.rnd.apply(this)|0)},real:function(){return this.integer()+this.frac()},integerInRange:function(a,b){return Math.floor(this.realInRange(0,b-a+1)+a)},between:function(a,b){return this.integerInRange(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="";36>a++;b+=~a%5|3*a&4?(a^15?8^this.frac()*(a^20?16:4):4).toString(16):"-");return b},pick:function(a){return a[this.integerInRange(0, a.length-1)]},sign:function(){return this.pick([-1,1])},weightedPick:function(a){return a[~~(Math.pow(this.frac(),2)*(a.length-1)+.5)]},timestamp:function(a,b){return this.realInRange(a||9466848E5,b||1577862E6)},angle:function(){return this.integerInRange(-180,180)},state:function(a){"string"===typeof a&&a.match(/^!rnd/)&&(a=a.split(","),this.c=parseFloat(a[1]),this.s0=parseFloat(a[2]),this.s1=parseFloat(a[3]),this.s2=parseFloat(a[4]));return["!rnd",this.c,this.s0,this.s1,this.s2].join()}};c.RandomDataGenerator.prototype.constructor= c.RandomDataGenerator;c.QuadTree=function(a,b,d,c,f,g,k){this.maxObjects=10;this.maxLevels=4;this.level=0;this.bounds={};this.objects=[];this.nodes=[];this._empty=[];this.reset(a,b,d,c,f,g,k)};c.QuadTree.prototype={reset:function(a,b,d,c,f,g,k){this.maxObjects=f||10;this.maxLevels=g||4;this.level=k||0;this.bounds={x:Math.round(a),y:Math.round(b),width:d,height:c,subWidth:Math.floor(d/2),subHeight:Math.floor(c/2),right:Math.round(a)+Math.floor(d/2),bottom:Math.round(b)+Math.floor(c/2)};this.objects.length= 0;this.nodes.length=0},populate:function(a){a.forEach(this.populateHandler,this,!0)},populateHandler:function(a){a.body&&a.exists&&this.insert(a.body)},split:function(){this.nodes[0]=new c.QuadTree(this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1);this.nodes[1]=new c.QuadTree(this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1);this.nodes[2]=new c.QuadTree(this.bounds.x, this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1);this.nodes[3]=new c.QuadTree(this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1)},insert:function(a){var b=0;if(null!=this.nodes[0]){var d=this.getIndex(a);if(-1!==d){this.nodes[d].insert(a);return}}this.objects.push(a);if(this.objects.length>this.maxObjects&&this.levelthis.bounds.bottom&&(b=2):a.x>this.bounds.right&&(a.ythis.bounds.bottom&&(b=3));return b},retrieve:function(a){if(a instanceof c.Rectangle)var b=this.objects,d=this.getIndex(a);else{if(!a.body)return this._empty; b=this.objects;d=this.getIndex(a.body)}this.nodes[0]&&(-1!==d?b=b.concat(this.nodes[d].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))));return b},clear:function(){this.objects.length=0;for(var a=this.nodes.length;a--;)this.nodes[a].clear(),this.nodes.splice(a,1);this.nodes.length=0}};c.QuadTree.prototype.constructor=c.QuadTree;c.Net=function(a){this.game=a};c.Net.prototype={getHostName:function(){return window.location&& window.location.hostname?window.location.hostname:null},checkDomainName:function(a){return-1!==window.location.hostname.indexOf(a)},updateQueryString:function(a,b,d,c){void 0===d&&(d=!1);if(void 0===c||""===c)c=window.location.href;var e=new RegExp("([?|&])"+a+"=.*?(&|#|$)(.*)","gi");if(e.test(c))a="undefined"!==typeof b&&null!==b?c.replace(e,"$1"+a+"="+b+"$2$3"):c.replace(e,"$1$3").replace(/(&|\?)$/,"");else{if("undefined"!==typeof b&&null!==b){e=-1!==c.indexOf("?")?"&":"?";var g=c.split("#");c= g[0]+e+a+"="+b;g[1]&&(c+="#"+g[1])}a=c}if(d)window.location.href=a;else return a},getQueryString:function(a){void 0===a&&(a="");var b={},d=location.search.substring(1).split("&"),c;for(c in d){var f=d[c].split("=");if(1=b)b=1E3;if(void 0===d||null===d)d=c.Easing.Default;void 0===e&&(e=!1);void 0===f&&(f=0);void 0===g&&(g=0);void 0===k&&(k=!1); "string"===typeof d&&this.manager.easeMap[d]&&(d=this.manager.easeMap[d]);if(this.isRunning)return console.warn("Phaser.Tween.to cannot be called after Tween.start"),this;this.timeline.push((new c.TweenData(this)).to(a,b,d,f,g,k));e&&this.start();return this},from:function(a,b,d,e,f,g,k){void 0===b&&(b=1E3);if(void 0===d||null===d)d=c.Easing.Default;void 0===e&&(e=!1);void 0===f&&(f=0);void 0===g&&(g=0);void 0===k&&(k=!1);"string"===typeof d&&this.manager.easeMap[d]&&(d=this.manager.easeMap[d]);if(this.isRunning)return console.warn("Phaser.Tween.from cannot be called after Tween.start"), this;this.timeline.push((new c.TweenData(this)).from(a,b,d,f,g,k));e&&this.start();return this},start:function(a){void 0===a&&(a=0);if(this.pendingDelete)return console.warn("Phaser.Tween.start cannot be called after Tween.stop"),this;if(null===this.game||null===this.target||0===this.timeline.length||this.isRunning)return this;for(var b=0;ba||a>this.timeline.length-1)a=0;this.current=a;this.timeline[this.current].start();return this},stop:function(a){void 0===a&&(a=!1);this.isRunning=!1;this._onUpdateCallbackContext=this._onUpdateCallback=null;a&&(this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start());this.manager.remove(this);return this},updateTweenData:function(a,b,d){if(0=== this.timeline.length)return this;void 0===d&&(d=0);if(-1===d)for(d=0;dthis.current&&(this.current=this.timeline.length-1,a=!0)):(this.current++,this.current=== this.timeline.length&&(this.current=0,a=!0));if(a){if(-1===this.repeatCounter)return this.timeline[this.current].start(),this.onLoop.dispatch(this.target,this),!0;if(0=this.startTime)this.isRunning=!0;else return c.TweenData.PENDING;else if(a(a*=2)?.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 1>(a*=2)?.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 1>(a*=2)?.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 1>(a*=2)?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)}},Sinusoidal:{In:function(a){return 0===a?0:1===a?1:1-Math.cos(a*Math.PI/2)},Out:function(a){return 0===a?0:1===a?1:Math.sin(a*Math.PI/2)},InOut:function(a){return 0===a?0:1===a?1:.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:1>(a*=2)?.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 1>(a*=2)?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)}},Elastic:{In:function(a){var b=.1;if(0===a)return 0;if(1===a)return 1;if(!b||1>b){b=1;var d=.1}else d=.4*Math.asin(1/b)/(2*Math.PI);return-(b*Math.pow(2,10*--a)*Math.sin(2*(a-d)*Math.PI/.4))},Out:function(a){var b=.1;if(0===a)return 0;if(1===a)return 1;if(!b||1>b){b=1;var d=.1}else d=.4*Math.asin(1/b)/(2*Math.PI); return b*Math.pow(2,-10*a)*Math.sin(2*(a-d)*Math.PI/.4)+1},InOut:function(a){var b=.1;if(0===a)return 0;if(1===a)return 1;if(!b||1>b){b=1;var d=.1}else d=.4*Math.asin(1/b)/(2*Math.PI);return 1>(a*=2)?-.5*b*Math.pow(2,10*--a)*Math.sin(2*(a-d)*Math.PI/.4):b*Math.pow(2,-10*--a)*Math.sin(2*(a-d)*Math.PI/.4)*.5+1}},Back:{In:function(a){return a*a*(2.70158*a-1.70158)},Out:function(a){return--a*a*(2.70158*a+1.70158)+1},InOut:function(a){return 1>(a*=2)?.5*a*a*(3.5949095*a-2.5949095):.5*((a-=2)*a*(3.5949095* a+2.5949095)+2)}},Bounce:{In:function(a){return 1-c.Easing.Bounce.Out(1-a)},Out:function(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+.75:a<2.5/2.75?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*c.Easing.Bounce.In(2*a):.5*c.Easing.Bounce.Out(2*a-1)+.5}}};c.Easing.Default=c.Easing.Linear.None;c.Easing.Power0=c.Easing.Linear.None;c.Easing.Power1=c.Easing.Quadratic.Out;c.Easing.Power2=c.Easing.Cubic.Out;c.Easing.Power3=c.Easing.Quartic.Out; c.Easing.Power4=c.Easing.Quintic.Out;c.Time=function(a){this.game=a;this.elapsedMS=this.elapsed=this.now=this.prevTime=this.time=0;this.physicsElapsed=1/60;this.physicsElapsedMS=1/60*1E3;this.desiredFpsMult=1/60;this._desiredFps=60;this.suggestedFps=this.desiredFps;this.slowMotion=1;this.advancedTiming=!1;this.rps=this.ups=this.fps=this.renders=this.updates=this.frames=0;this.fpsMin=1E3;this.fpsMax=0;this.msMin=1E3;this.timeExpected=this.timeToCall=this.pauseDuration=this.msMax=0;this.events=new c.Timer(this.game, !1);this._pauseStarted=this._timeLastSecond=this._started=this._elapsedAccumulator=this._frameCount=0;this._justResumed=!1;this._timers=[]};c.Time.prototype={boot:function(){this._started=Date.now();this.time=Date.now();this.events.start();this.timeExpected=this.time},add:function(a){this._timers.push(a);return a},create:function(a){void 0===a&&(a=!0);a=new c.Timer(this.game,a);this._timers.push(a);return a},removeAll:function(){for(var a=0;a=2*this._desiredFps&&(this.suggestedFps=5*Math.floor(200/(this._elapsedAccumulator/this._frameCount)),this._elapsedAccumulator=this._frameCount=0);this.msMin=Math.min(this.msMin,this.elapsed);this.msMax=Math.max(this.msMax, this.elapsed);this.frames++;if(this.now>this._timeLastSecond+1E3){var a=this.now-this._timeLastSecond;this.fps=Math.round(1E3*this.frames/a);this.ups=Math.round(1E3*this.updates/a);this.rps=Math.round(1E3*this.renders/a);this.fpsMin=Math.min(this.fpsMin,this.fps);this.fpsMax=Math.max(this.fpsMax,this.fps);this._timeLastSecond=this.now;this.renders=this.updates=this.frames=0}},countUpdate:function(){this.advancedTiming&&this.updates++},countRender:function(){this.advancedTiming&&this.renders++},gamePaused:function(){this._pauseStarted= Date.now();this.events.pause();for(var a=this._timers.length;a--;)this._timers[a]._pause()},gameResumed:function(){this.time=Date.now();this.pauseDuration=this.time-this._pauseStarted;this.events.resume();for(var a=this._timers.length;a--;)this._timers[a]._resume()},totalElapsedSeconds:function(){return.001*(this.time-this._started)},elapsedSince:function(a){return this.time-a},elapsedSecondsSince:function(a){return.001*(this.time-a)},reset:function(){this._started=this.time;this.removeAll()}};Object.defineProperty(c.Time.prototype, "desiredFps",{get:function(){return this._desiredFps},set:function(a){this._desiredFps=a;this.physicsElapsed=1/a;this.physicsElapsedMS=1E3*this.physicsElapsed;this.desiredFpsMult=1/a}});c.Time.prototype.constructor=c.Time;c.Timer=function(a,b){void 0===b&&(b=!0);this.game=a;this.running=!1;this.autoDestroy=b;this.expired=!1;this.elapsed=0;this.events=[];this.onComplete=new c.Signal;this.nextTick=0;this.timeCap=1E3;this._codePaused=this.paused=!1;this._pauseTotal=this._pauseStarted=this._started=0; this._now=Date.now();this._newTick=this._diff=this._i=this._marked=this._len=0};c.Timer.MINUTE=6E4;c.Timer.SECOND=1E3;c.Timer.HALF=500;c.Timer.QUARTER=250;c.Timer.prototype={create:function(a,b,d,e,f,g){var k=a=Math.round(a);k=0===this._now?k+this.game.time.time:k+this._now;a=new c.TimerEvent(this,a,k,d,b,e,f,g);this.events.push(a);this.order();this.expired=!1;return a},add:function(a,b,d){return this.create(a,!1,0,b,d,Array.prototype.slice.call(arguments,3))},repeat:function(a,b,d,c){return this.create(a, !1,b,d,c,Array.prototype.slice.call(arguments,4))},loop:function(a,b,d){return this.create(a,!0,0,b,d,Array.prototype.slice.call(arguments,3))},start:function(a){if(!this.running)for(this._started=this.game.time.time+(a||0),this.running=!0,a=0;ab.tick?1:0},clearPendingEvents:function(){for(this._i=this.events.length;this._i--;)this.events[this._i].pendingDelete&&this.events.splice(this._i,1);this._len=this.events.length;this._i=0},update:function(a){if(this.paused)return!0;this.elapsed=a-this._now;this._now=a;this.elapsed>this.timeCap&&this.adjustEvents(a-this.elapsed); this._marked=0;this.clearPendingEvents();if(this.running&&this._now>=this.nextTick&&0=a.tick&&!a.pendingDelete)this._newTick=this._now+a.delay-(this._now-a.tick),0>this._newTick&&(this._newTick=this._now+a.delay),!0===a.loop?a.tick=this._newTick:0 this._marked?this.order():(this.expired=!0,this.onComplete.dispatch(this))}return this.expired&&this.autoDestroy?!1:!0},pause:function(){this.running&&(this._codePaused=!0,this.paused||(this._pauseStarted=this.game.time.time,this.paused=!0))},_pause:function(){!this.paused&&this.running&&(this._pauseStarted=this.game.time.time,this.paused=!0)},adjustEvents:function(a){for(var b=0;bd&&(d=0);this.events[b].tick= this._now+d}a=this.nextTick-a;this.nextTick=0>a?this._now:this._now+a},resume:function(){if(this.paused){var a=this.game.time.time;this._pauseTotal+=a-this._now;this._now=a;this.adjustEvents(this._pauseStarted);this._codePaused=this.paused=!1}},_resume:function(){this._codePaused||this.resume()},removeAll:function(){this.onComplete.removeAll();this._i=this._len=this.events.length=0},destroy:function(){this.onComplete.removeAll();this.running=!1;this.expired=!0;this.events=[];this._i=this._len=0}}; Object.defineProperty(c.Timer.prototype,"next",{get:function(){return this.nextTick}});Object.defineProperty(c.Timer.prototype,"duration",{get:function(){return this.running&&this.nextTick>this._now?this.nextTick-this._now:0}});Object.defineProperty(c.Timer.prototype,"length",{get:function(){return this.events.length}});Object.defineProperty(c.Timer.prototype,"ms",{get:function(){return this.running?this._now-this._started-this._pauseTotal:0}});Object.defineProperty(c.Timer.prototype,"seconds",{get:function(){return this.running? .001*this.ms:0}});c.Timer.prototype.constructor=c.Timer;c.TimerEvent=function(a,b,d,c,f,g,k,h){this.timer=a;this.delay=b;this.tick=d;this.repeatCount=c-1;this.loop=f;this.callback=g;this.callbackContext=k;this.args=h;this.pendingDelete=!1};c.TimerEvent.prototype.constructor=c.TimerEvent;c.AnimationManager=function(a){this.sprite=a;this.game=a.game;this.currentAnim=this.currentFrame=null;this.updateIfVisible=!0;this.isLoaded=!1;this._frameData=null;this._anims={};this._outputFrames=[]};c.AnimationManager.prototype= {loadFrameData:function(a,b){if(void 0===a)return!1;if(this.isLoaded)for(var d in this._anims)this._anims[d].updateFrameData(a);this._frameData=a;void 0===b||null===b?this.frame=0:"string"===typeof b?this.frameName=b:this.frame=b;return this.isLoaded=!0},copyFrameData:function(a,b){this._frameData=a.clone();if(this.isLoaded)for(var d in this._anims)this._anims[d].updateFrameData(this._frameData);void 0===b||null===b?this.frame=0:"string"===typeof b?this.frameName=b:this.frame=b;return this.isLoaded= !0},add:function(a,b,d,e,f){b=b||[];d=d||60;void 0===e&&(e=!1);void 0===f&&(f=b&&"number"===typeof b[0]?!0:!1);this._outputFrames=[];this._frameData.getFrameIndexes(b,f,this._outputFrames);this._anims[a]=new c.Animation(this.game,this.sprite,a,this._frameData,this._outputFrames,d,e);this.currentAnim=this._anims[a];this.sprite.tilingTexture&&(this.sprite.refreshTexture=!0);return this._anims[a]},validateFrames:function(a,b){void 0===b&&(b=!0);for(var d=0;dthis._frameData.total)return!1}else if(!1=== this._frameData.checkFrameName(a[d]))return!1;return!0},play:function(a,b,d,c){if(this._anims[a]){if(this.currentAnim===this._anims[a])return!1===this.currentAnim.isPlaying?(this.currentAnim.paused=!1,this.currentAnim.play(b,d,c)):this.currentAnim;this.currentAnim&&this.currentAnim.isPlaying&&this.currentAnim.stop();this.currentAnim=this._anims[a];this.currentAnim.paused=!1;this.currentFrame=this.currentAnim.currentFrame;return this.currentAnim.play(b,d,c)}},stop:function(a,b){void 0===b&&(b=!1); !this.currentAnim||"string"===typeof a&&a!==this.currentAnim.name||this.currentAnim.stop(b)},update:function(){return this.updateIfVisible&&!this.sprite.visible?!1:this.currentAnim&&this.currentAnim.update()?(this.currentFrame=this.currentAnim.currentFrame,!0):!1},next:function(a){this.currentAnim&&(this.currentAnim.next(a),this.currentFrame=this.currentAnim.currentFrame)},previous:function(a){this.currentAnim&&(this.currentAnim.previous(a),this.currentFrame=this.currentAnim.currentFrame)},getAnimation:function(a){return"string"=== typeof a&&this._anims[a]?this._anims[a]:null},refreshFrame:function(){},destroy:function(){var a=null;for(a in this._anims)this._anims.hasOwnProperty(a)&&this._anims[a].destroy();this._anims={};this._outputFrames=[];this.game=this.sprite=this.currentFrame=this.currentAnim=this._frameData=null}};c.AnimationManager.prototype.constructor=c.AnimationManager;Object.defineProperty(c.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}});Object.defineProperty(c.AnimationManager.prototype, "frameTotal",{get:function(){return this._frameData.total}});Object.defineProperty(c.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(a){this.currentAnim.paused=a}});Object.defineProperty(c.AnimationManager.prototype,"name",{get:function(){if(this.currentAnim)return this.currentAnim.name}});Object.defineProperty(c.AnimationManager.prototype,"frame",{get:function(){if(this.currentFrame)return this.currentFrame.index},set:function(a){var b;"number"=== typeof a&&this._frameData&&(b=this._frameData.getFrame(a))&&(this.currentFrame=b,this.sprite.setFrame(this.currentFrame))}});Object.defineProperty(c.AnimationManager.prototype,"frameName",{get:function(){if(this.currentFrame)return this.currentFrame.name},set:function(a){var b;"string"===typeof a&&this._frameData&&(b=this._frameData.getFrameByName(a))?(this.currentFrame=b,this._frameIndex=this.currentFrame.index,this.sprite.setFrame(this.currentFrame)):console.warn("Cannot set frameName: "+a)}}); c.Animation=function(a,b,d,e,f,g,k){void 0===k&&(k=!1);this.game=a;this._parent=b;this._frameData=e;this.name=d;this._frames=[];this._frames=this._frames.concat(f);this.delay=1E3/g;this.loop=k;this.loopCount=0;this.isPaused=this.isPlaying=this.isFinished=this.killOnComplete=!1;this._frameDiff=this._frameIndex=this._pauseStartTime=0;this._frameSkip=1;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this.onStart=new c.Signal;this.onUpdate=null;this.onComplete=new c.Signal; this.onLoop=new c.Signal;this.isReversed=!1;this.game.onPause.add(this.onPause,this);this.game.onResume.add(this.onResume,this)};c.Animation.prototype={play:function(a,b,d){"number"===typeof a&&(this.delay=1E3/a);"boolean"===typeof b&&(this.loop=b);"undefined"!==typeof d&&(this.killOnComplete=d);this.isPlaying=!0;this.paused=this.isFinished=!1;this.loopCount=0;this._timeLastFrame=this.game.time.time;this._timeNextFrame=this.game.time.time+this.delay;this._frameIndex=this.isReversed?this._frames.length- 1:0;this.updateCurrentFrame(!1,!0);this._parent.events.onAnimationStart$dispatch(this._parent,this);this.onStart.dispatch(this._parent,this);this._parent.animations.currentAnim=this;this._parent.animations.currentFrame=this.currentFrame;return this},restart:function(){this.isPlaying=!0;this.paused=this.isFinished=!1;this.loopCount=0;this._timeLastFrame=this.game.time.time;this._timeNextFrame=this.game.time.time+this.delay;this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]); this._parent.setFrame(this.currentFrame);this._parent.animations.currentAnim=this;this._parent.animations.currentFrame=this.currentFrame;this.onStart.dispatch(this._parent,this)},reverse:function(){this.reversed=!this.reversed;return this},reverseOnce:function(){this.onComplete.addOnce(this.reverse,this);return this.reverse()},setFrame:function(a,b){var d;void 0===b&&(b=!1);if("string"===typeof a)for(b=0;b=this._timeNextFrame)if(this._frameSkip=1,this._frameDiff=this.game.time.time-this._timeNextFrame,this._timeLastFrame=this.game.time.time,this._frameDiff>this.delay?(this._frameSkip=Math.floor(this._frameDiff/this.delay), this._frameDiff-=this._frameSkip*this.delay):this._frameDiff=0,this._timeNextFrame=this.game.time.time+(this.delay-this._frameDiff),this._frameIndex=this.isReversed?this._frameIndex-this._frameSkip:this._frameIndex+this._frameSkip,!this.isReversed&&this._frameIndex>=this._frames.length||this.isReversed&&-1>=this._frameIndex){if(this.loop)return this._frameIndex=Math.abs(this._frameIndex)%this._frames.length,this.isReversed&&(this._frameIndex=this._frames.length-1-this._frameIndex),(this.currentFrame= this._frameData.getFrame(this._frames[this._frameIndex]))&&this._parent.setFrame(this.currentFrame),this.loopCount++,this._parent.events.onAnimationLoop$dispatch(this._parent,this),this.onLoop.dispatch(this._parent,this),this.onUpdate?(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData):!0;this.complete()}else return this.updateCurrentFrame(!0);return!1},updateCurrentFrame:function(a,b){void 0===b&&(b=!1);if(!this._frameData)return!1;var d=this.currentFrame.index;(this.currentFrame= this._frameData.getFrame(this._frames[this._frameIndex]))&&(b||!b&&d!==this.currentFrame.index)&&this._parent.setFrame(this.currentFrame);return this.onUpdate&&a?(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData):!0},next:function(a){void 0===a&&(a=1);a=this._frameIndex+a;a>=this._frames.length&&(a=this.loop?a%this._frames.length:this._frames.length-1);a!==this._frameIndex&&(this._frameIndex=a,this.updateCurrentFrame(!0))},previous:function(a){void 0===a&&(a=1);a=this._frameIndex- a;0>a&&(this.loop?a=this._frames.length+a:a++);a!==this._frameIndex&&(this._frameIndex=a,this.updateCurrentFrame(!0))},updateFrameData:function(a){this.currentFrame=(this._frameData=a)?this._frameData.getFrame(this._frames[this._frameIndex%this._frames.length]):null},destroy:function(){this._frameData&&(this.game.onPause.remove(this.onPause,this),this.game.onResume.remove(this.onResume,this),this.currentFrame=this._frameData=this._frames=this._parent=this.game=null,this.isPlaying=!1,this.onStart.dispose(), this.onLoop.dispose(),this.onComplete.dispose(),this.onUpdate&&this.onUpdate.dispose())},complete:function(){this._frameIndex=this._frames.length-1;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this.updateCurrentFrame(!1);this.isPlaying=!1;this.isFinished=!0;this.paused=!1;this._parent.events.onAnimationComplete$dispatch(this._parent,this);this.onComplete.dispatch(this._parent,this);this.killOnComplete&&this._parent.kill()}};c.Animation.prototype.constructor=c.Animation; Object.defineProperty(c.Animation.prototype,"paused",{get:function(){return this.isPaused},set:function(a){(this.isPaused=a)?this._pauseStartTime=this.game.time.time:this.isPlaying&&(this._timeNextFrame=this.game.time.time+this.delay)}});Object.defineProperty(c.Animation.prototype,"reversed",{get:function(){return this.isReversed},set:function(a){this.isReversed=a}});Object.defineProperty(c.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}});Object.defineProperty(c.Animation.prototype, "frame",{get:function(){return null!==this.currentFrame?this.currentFrame.index:this._frameIndex},set:function(a){this.currentFrame=this._frameData.getFrame(this._frames[a]);null!==this.currentFrame&&(this._frameIndex=a,this._parent.setFrame(this.currentFrame),this.onUpdate&&this.onUpdate.dispatch(this,this.currentFrame))}});Object.defineProperty(c.Animation.prototype,"speed",{get:function(){return 1E3/this.delay},set:function(a){0=d;k--)b="number"===typeof f?c.Utils.pad(k.toString(),f,"0",1):k.toString(),b=a+b+e,g.push(b); return g};c.Frame=function(a,b,d,e,f,g){this.index=a;this.x=b;this.y=d;this.width=e;this.height=f;0!==this.width&&0!==this.height||console.warn('Phaser.Frame: Frame "'+this.name+'" has a width or height of zero');this.name=g;this.centerX=Math.floor(e/2);this.centerY=Math.floor(f/2);this.distance=c.Math.distance(0,0,e,f);this.trimmed=this.rotated=!1;this.sourceSizeW=e;this.sourceSizeH=f;this.spriteSourceSizeH=this.spriteSourceSizeW=this.spriteSourceSizeY=this.spriteSourceSizeX=0;this.right=this.x+ this.width;this.bottom=this.y+this.height};c.Frame.prototype={resize:function(a,b){this.width=a;this.height=b;this.centerX=Math.floor(a/2);this.centerY=Math.floor(b/2);this.distance=c.Math.distance(0,0,a,b);this.sourceSizeW=a;this.sourceSizeH=b;this.right=this.x+a;this.bottom=this.y+b},setTrim:function(a,b,d,c,f,g,k){if(this.trimmed=a)this.sourceSizeW=b,this.sourceSizeH=d,this.centerX=Math.floor(b/2),this.centerY=Math.floor(d/2),this.spriteSourceSizeX=c,this.spriteSourceSizeY=f,this.spriteSourceSizeW= g,this.spriteSourceSizeH=k},clone:function(){var a=new c.Frame(this.index,this.x,this.y,this.width,this.height,this.name),b;for(b in this)this.hasOwnProperty(b)&&(a[b]=this[b]);return a},getRect:function(a){void 0===a?a=new c.Rectangle(this.x,this.y,this.width,this.height):a.setTo(this.x,this.y,this.width,this.height);return a}};c.Frame.prototype.constructor=c.Frame;c.FrameData=function(){this._frames=[];this._frameNames=[]};c.FrameData.prototype={addFrame:function(a){a.index=this._frames.length; this._frames.push(a);""!==a.name&&(this._frameNames[a.name]=a.index);return a},getFrame:function(a){a>=this._frames.length&&(a=0);return this._frames[a]},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},clone:function(){for(var a=new c.FrameData,b=0;b=d||0>=e)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' frameWidth (%s) or frameHeight (%s) must be positive",b,d,e),null;a=m.width;m=m.height;if(0===a||0===m)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' width (%s) or height (%s) is zero",b,a,m),null;if(al||h<-l)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' skipFrames = %s is larger than the frame total %s",b,h,l),null;-1h&&(r=q+h,l=Math.min(l,m+h),t=r-l+1);if(0>t)return console.warn("First frame index %s is outside of range [0, %d]", t,q),null;if(r>q)return console.warn("Last frame index %s is outside of range [0, %d]",r,q),null;b=new c.FrameData;h=f=g;for(q=l=0;qr);q++)q>=t&&b.addFrame(new c.Frame(l++,f,h,d,e,"")),f+=d+k,f+d>a&&(f=g,h+=e+k);return b},JSONData:function(a,b){if(b.frames){a=new c.FrameData;b=b.frames;for(var d,e=0;e tag")}};c.Cache=function(a){this.game=a;this.autoResolveURL=!1;this._cache={canvas:{},image:{},texture:{},sound:{},video:{},text:{}, json:{},xml:{},physics:{},tilemap:{},binary:{},bitmapData:{},bitmapFont:{},shader:{},renderTexture:{},compressedTexture:{}};this._urlMap={};this._urlResolver=new Image;this._urlTemp=null;this.onSoundUnlock=new c.Signal;this._cacheMap=[];this._cacheMap[c.Cache.CANVAS]=this._cache.canvas;this._cacheMap[c.Cache.IMAGE]=this._cache.image;this._cacheMap[c.Cache.TEXTURE]=this._cache.texture;this._cacheMap[c.Cache.SOUND]=this._cache.sound;this._cacheMap[c.Cache.TEXT]=this._cache.text;this._cacheMap[c.Cache.PHYSICS]= this._cache.physics;this._cacheMap[c.Cache.TILEMAP]=this._cache.tilemap;this._cacheMap[c.Cache.BINARY]=this._cache.binary;this._cacheMap[c.Cache.BITMAPDATA]=this._cache.bitmapData;this._cacheMap[c.Cache.BITMAPFONT]=this._cache.bitmapFont;this._cacheMap[c.Cache.JSON]=this._cache.json;this._cacheMap[c.Cache.XML]=this._cache.xml;this._cacheMap[c.Cache.VIDEO]=this._cache.video;this._cacheMap[c.Cache.SHADER]=this._cache.shader;this._cacheMap[c.Cache.RENDER_TEXTURE]=this._cache.renderTexture;this._pendingCount= 0;this.onReady=new c.Signal;this._addImages()};c.Cache.CANVAS=1;c.Cache.IMAGE=2;c.Cache.TEXTURE=3;c.Cache.SOUND=4;c.Cache.TEXT=5;c.Cache.PHYSICS=6;c.Cache.TILEMAP=7;c.Cache.BINARY=8;c.Cache.BITMAPDATA=9;c.Cache.BITMAPFONT=10;c.Cache.JSON=11;c.Cache.XML=12;c.Cache.VIDEO=13;c.Cache.SHADER=14;c.Cache.RENDER_TEXTURE=15;c.Cache.DEFAULT=null;c.Cache.DEFAULT_KEY="__default";c.Cache.DEFAULT_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=="; c.Cache.MISSING=null;c.Cache.MISSING_KEY="__missing";c.Cache.MISSING_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==";c.Cache.READY_TIMEOUT=1E3;c.Cache.prototype={addCompressedTextureMetaData:function(a, b,d,e){this.checkImageKey(a)&&this.removeImage(a);e=d in c.LoaderParser?c.LoaderParser[d](e):e;d={key:a,url:b,data:e,base:new PIXI.BaseTexture(e,null,this.game.resolution),frame:new c.Frame(0,0,0,e.width,e.height,a),frameData:new c.FrameData,fileFormat:d};d.frameData.addFrame(new c.Frame(0,0,0,e.width,e.height,b));this._cache.image[a]=d;this._resolveURL(b,d);return d},addCanvas:function(a,b,d){void 0===d&&(d=b.getContext("2d"));this._cache.canvas[a]={canvas:b,context:d}},addImage:function(a,b,d){this.checkImageKey(a)&& this.removeImage(a);!1===d.complete&&console.warn('Phaser.Cache.addImage: Image "'+a+"\" hasn't been retrieved yet");var e={key:a,url:b,data:d,base:new PIXI.BaseTexture(d,null,this.game.resolution),frame:new c.Frame(0,0,0,d.width,d.height,a),frameData:new c.FrameData};e.frameData.addFrame(new c.Frame(0,0,0,d.width,d.height,b));this._cache.image[a]=e;this._resolveURL(b,e);"__default"===a?c.Cache.DEFAULT=new PIXI.Texture(e.base):"__missing"===a&&(c.Cache.MISSING=new PIXI.Texture(e.base));return e}, addImageAsync:function(a,b,d){var c=this,f=new Image;f.onload=function(){d.call(this,c.addImage(a,null,f));c._removePending();f.onload=null};this._addPending();f.src=b},addDefaultImage:function(){this.addImageAsync(c.Cache.DEFAULT_KEY,c.Cache.DEFAULT_SRC,function(a){a.base.skipRender=!0;c.Cache.DEFAULT=new PIXI.Texture(a.base)})},addMissingImage:function(){this.addImageAsync(c.Cache.MISSING_KEY,c.Cache.MISSING_SRC,function(a){c.Cache.MISSING=new PIXI.Texture(a.base)})},addSound:function(a,b,d,c,f){void 0=== c&&(c=!0,f=!1);void 0===f&&(c=!1,f=!0);var e=!1;f&&(e=!0);this._cache.sound[a]={url:b,data:d,isDecoding:!1,decoded:e,webAudio:c,audioTag:f,locked:this.game.sound.touchLocked};this._resolveURL(b,this._cache.sound[a])},addText:function(a,b,d){this._cache.text[a]={url:b,data:d};this._resolveURL(b,this._cache.text[a])},addPhysicsData:function(a,b,d,c){this._cache.physics[a]={url:b,data:d,format:c};this._resolveURL(b,this._cache.physics[a])},addTilemap:function(a,b,d,c){this._cache.tilemap[a]={url:b,data:d, format:c};this._resolveURL(b,this._cache.tilemap[a])},addBinary:function(a,b){this._cache.binary[a]=b},addBitmapData:function(a,b,d){b.key=a;void 0===d&&(d=new c.FrameData,d.addFrame(b.textureFrame));this._cache.bitmapData[a]={data:b,frameData:d};return b},addBitmapFont:function(a,b,d,e,f,g,k){d={url:b,data:d,font:null,base:new PIXI.BaseTexture(d,null,this.game.resolution)};void 0===g&&(g=0);void 0===k&&(k=0);d.font="json"===f?c.LoaderParser.jsonBitmapFont(e,d.base,g,k,!1,this.game.resolution):c.LoaderParser.xmlBitmapFont(e, d.base,g,k,!1,this.game.resolution);this._cache.bitmapFont[a]=d;this._resolveURL(b,d)},addBitmapFontFromAtlas:function(a,b,d,e,f,g,k){if(d=this.getFrameByName(b,d))b={font:null,base:this.getBaseTexture(b),frame:d},void 0===g&&(g=0),void 0===k&&(k=0),"json"===f?(e=this.getJSON(e),b.font=c.LoaderParser.jsonBitmapFont(e,b.base,g,k,d,this.game.resolution)):(e=this.getXML(e),b.font=c.LoaderParser.xmlBitmapFont(e,b.base,g,k,d,this.game.resolution)),this._cache.bitmapFont[a]=b},addJSON:function(a,b,d){this._cache.json[a]= {url:b,data:d};this._resolveURL(b,this._cache.json[a])},addXML:function(a,b,d){this._cache.xml[a]={url:b,data:d};this._resolveURL(b,this._cache.xml[a])},addVideo:function(a,b,d,c){this._cache.video[a]={url:b,data:d,isBlob:c,locked:!0};this._resolveURL(b,this._cache.video[a])},addShader:function(a,b,d){this._cache.shader[a]={url:b,data:d};this._resolveURL(b,this._cache.shader[a])},addRenderTexture:function(a,b){this._cache.renderTexture[a]={texture:b,frame:new c.Frame(0,0,0,b.width,b.height,"","")}}, addSpriteSheet:function(a,b,d,e,f,g,k,h,l){void 0===g&&(g=-1);void 0===k&&(k=0);void 0===h&&(h=0);d={key:a,url:b,data:d,frameWidth:e,frameHeight:f,margin:k,spacing:h,base:new PIXI.BaseTexture(d,null,this.game.resolution),frameData:c.AnimationParser.spriteSheet(this.game,d,e,f,g,k,h,l)};this._cache.image[a]=d;this._resolveURL(b,d)},addTextureAtlas:function(a,b,d,e,f){d={key:a,url:b,data:d,base:new PIXI.BaseTexture(d,null,this.game.resolution)};f===c.Loader.TEXTURE_ATLAS_XML_STARLING?d.frameData=c.AnimationParser.XMLData(this.game, e,a):f===c.Loader.TEXTURE_ATLAS_JSON_PYXEL?d.frameData=c.AnimationParser.JSONDataPyxel(this.game,e,a):Array.isArray(e.frames)?d.frameData=c.AnimationParser.JSONData(this.game,e,a):d.frameData=c.AnimationParser.JSONDataHash(this.game,e,a);this._cache.image[a]=d;this._resolveURL(b,d)},reloadSound:function(a){var b=this,d=this.getSound(a);d&&(d.data.src=d.url,d.data.addEventListener("canplaythrough",function(){return b.reloadSoundComplete(a)},!1),d.data.load())},reloadSoundComplete:function(a){var b= this.getSound(a);b&&(b.locked=!1,this.onSoundUnlock.dispatch(a))},updateSound:function(a,b,d){(a=this.getSound(a))&&(a[b]=d)},decodedSound:function(a,b){a=this.getSound(a);a.data=b;a.decoded=!0;a.isDecoding=!1},isSoundDecoded:function(a){if(a=this.getItem(a,c.Cache.SOUND,"isSoundDecoded"))return a.decoded},isSoundReady:function(a){if(a=this.getItem(a,c.Cache.SOUND,"isSoundDecoded"))return a.decoded&&!this.game.sound.touchLocked},checkKey:function(a,b){return this._cacheMap[a][b]?!0:!1},checkURL:function(a){return this._urlMap[this._resolveURL(a)]? !0:!1},checkCanvasKey:function(a){return this.checkKey(c.Cache.CANVAS,a)},checkImageKey:function(a){return this.checkKey(c.Cache.IMAGE,a)},checkTextureKey:function(a){return this.checkKey(c.Cache.TEXTURE,a)},checkSoundKey:function(a){return this.checkKey(c.Cache.SOUND,a)},checkTextKey:function(a){return this.checkKey(c.Cache.TEXT,a)},checkPhysicsKey:function(a){return this.checkKey(c.Cache.PHYSICS,a)},checkTilemapKey:function(a){return this.checkKey(c.Cache.TILEMAP,a)},checkBinaryKey:function(a){return this.checkKey(c.Cache.BINARY, a)},checkBitmapDataKey:function(a){return this.checkKey(c.Cache.BITMAPDATA,a)},checkBitmapFontKey:function(a){return this.checkKey(c.Cache.BITMAPFONT,a)},checkJSONKey:function(a){return this.checkKey(c.Cache.JSON,a)},checkXMLKey:function(a){return this.checkKey(c.Cache.XML,a)},checkVideoKey:function(a){return this.checkKey(c.Cache.VIDEO,a)},checkShaderKey:function(a){return this.checkKey(c.Cache.SHADER,a)},checkRenderTextureKey:function(a){return this.checkKey(c.Cache.RENDER_TEXTURE,a)},getItem:function(a, b,d,c){if(this.checkKey(b,a))return void 0===c?this._cacheMap[b][a]:this._cacheMap[b][a][c];d&&console.warn("Phaser.Cache."+d+': Key "'+a+'" not found in Cache.');return null},getCanvas:function(a){return this.getItem(a,c.Cache.CANVAS,"getCanvas","canvas")},getImage:function(a,b){if(void 0===a||null===a)a="__default";void 0===b&&(b=!1);a=this.getItem(a,c.Cache.IMAGE,"getImage");null===a&&(a=this.getItem("__missing",c.Cache.IMAGE,"getImage"));return b?a:a.data},getTextureFrame:function(a){return this.getItem(a, c.Cache.TEXTURE,"getTextureFrame","frame")},getSound:function(a){return this.getItem(a,c.Cache.SOUND,"getSound")},getSoundData:function(a){return this.getItem(a,c.Cache.SOUND,"getSoundData","data")},getText:function(a){return this.getItem(a,c.Cache.TEXT,"getText","data")},getPhysicsData:function(a,b,d){var e=this.getItem(a,c.Cache.PHYSICS,"getPhysicsData","data");if(null===e||void 0===b||null===b)return e;if(e[b])if((b=e[b])&&d){for(var f in b)if(f=b[f],f.fixtureKey===d)return f;console.warn('Phaser.Cache.getPhysicsData: Could not find given fixtureKey: "'+ d+" in "+a+'"')}else return b;else console.warn('Phaser.Cache.getPhysicsData: Invalid key/object: "'+a+" / "+b+'"');return null},getTilemapData:function(a){return this.getItem(a,c.Cache.TILEMAP,"getTilemapData")},getBinary:function(a){return this.getItem(a,c.Cache.BINARY,"getBinary")},getBitmapData:function(a){return this.getItem(a,c.Cache.BITMAPDATA,"getBitmapData","data")},getBitmapFont:function(a){return this.getItem(a,c.Cache.BITMAPFONT,"getBitmapFont")},getJSON:function(a,b){return(a=this.getItem(a, c.Cache.JSON,"getJSON","data"))?b?c.Utils.extend(!0,Array.isArray(a)?[]:{},a):a:null},getXML:function(a){return this.getItem(a,c.Cache.XML,"getXML","data")},getVideo:function(a){return this.getItem(a,c.Cache.VIDEO,"getVideo")},getShader:function(a){return this.getItem(a,c.Cache.SHADER,"getShader","data")},getRenderTexture:function(a){return this.getItem(a,c.Cache.RENDER_TEXTURE,"getRenderTexture")},getBaseTexture:function(a,b){void 0===b&&(b=c.Cache.IMAGE);return this.getItem(a,b,"getBaseTexture", "base")},getFrame:function(a,b){void 0===b&&(b=c.Cache.IMAGE);return this.getItem(a,b,"getFrame","frame")},getFrameCount:function(a,b){return(a=this.getFrameData(a,b))?a.total:0},getFrameData:function(a,b){void 0===b&&(b=c.Cache.IMAGE);return this.getItem(a,b,"getFrameData","frameData")},hasFrameData:function(a,b){void 0===b&&(b=c.Cache.IMAGE);return null!==this.getItem(a,b,"","frameData")},updateFrameData:function(a,b,d){void 0===d&&(d=c.Cache.IMAGE);this._cacheMap[d][a]&&(this._cacheMap[d][a].frameData= b)},getFrameByIndex:function(a,b,d){return(a=this.getFrameData(a,d))?a.getFrame(b):null},getFrameByName:function(a,b,d){return(a=this.getFrameData(a,d))?a.getFrameByName(b):null},getURL:function(a){if(a=this._resolveURL(a))return this._urlMap[a];console.warn('Phaser.Cache.getUrl: Invalid url: "'+a+'" or Cache.autoResolveURL was false');return null},getKeys:function(a){void 0===a&&(a=c.Cache.IMAGE);var b=[];if(this._cacheMap[a])for(var d in this._cacheMap[a])"__default"!==d&&"__missing"!==d&&b.push(d); return b},removeCanvas:function(a){delete this._cache.canvas[a]},removeImage:function(a,b){void 0===b&&(b=!0);var d=this.getImage(a,!0);b&&d.base&&d.base.destroy();delete this._cache.image[a]},removeSound:function(a){delete this._cache.sound[a]},removeText:function(a){delete this._cache.text[a]},removePhysics:function(a){delete this._cache.physics[a]},removeTilemap:function(a){delete this._cache.tilemap[a]},removeBinary:function(a){delete this._cache.binary[a]},removeBitmapData:function(a){delete this._cache.bitmapData[a]}, removeBitmapFont:function(a){delete this._cache.bitmapFont[a]},removeJSON:function(a){delete this._cache.json[a]},removeXML:function(a){delete this._cache.xml[a]},removeVideo:function(a){delete this._cache.video[a]},removeShader:function(a){delete this._cache.shader[a]},removeRenderTexture:function(a){delete this._cache.renderTexture[a]},removeSpriteSheet:function(a){delete this._cache.spriteSheet[a]},removeTextureAtlas:function(a){delete this._cache.image[a]},clearGLTextures:function(){for(var a in this._cache.image)this._cache.image[a].base._glTextures= []},_resolveURL:function(a,b){if(!this.autoResolveURL)return null;this._urlResolver.src=this.game.load.baseURL+a;this._urlTemp=this._urlResolver.src;this._urlResolver.src="";b&&(this._urlMap[this._urlTemp]=b);return this._urlTemp},destroy:function(){for(var a=0;a=this._pendingCount}});c.Loader=function(a){this.game=a;this.cache=a.cache;this.hasLoaded=this.isLoading=this.resetLocked=!1;this.preloadSprite=null;this.crossOrigin=!1;this.path=this.baseURL="";this.headers= {requestedWith:!1,json:"application/json",xml:"application/xml"};this.onLoadStart=new c.Signal;this.onBeforeLoadComplete=new c.Signal;this.onLoadComplete=new c.Signal;this.onPackComplete=new c.Signal;this.onFileStart=new c.Signal;this.onFileComplete=new c.Signal;this.onFileError=new c.Signal;this.enableParallel=!0;this.maxParallelDownloads=4;this._withSyncPointDepth=0;this._fileList=[];this._flightQueue=[];this._processingHead=0;this._fileLoadStarted=!1;this._loadedFileCount=this._loadedPackCount= this._totalFileCount=this._totalPackCount=0};c.Loader.TEXTURE_ATLAS_JSON_ARRAY=0;c.Loader.TEXTURE_ATLAS_JSON_HASH=1;c.Loader.TEXTURE_ATLAS_XML_STARLING=2;c.Loader.PHYSICS_LIME_CORONA_JSON=3;c.Loader.PHYSICS_PHASER_JSON=4;c.Loader.TEXTURE_ATLAS_JSON_PYXEL=5;c.Loader.prototype={setPreloadSprite:function(a,b){b=b||0;this.preloadSprite={sprite:a,direction:b,width:a.width,height:a.height,rect:null};this.preloadSprite.rect=0===b?new c.Rectangle(0,0,1,a.height):new c.Rectangle(0,0,a.width,1);a.crop(this.preloadSprite.rect); a.visible=!0},resize:function(){this.preloadSprite&&this.preloadSprite.height!==this.preloadSprite.sprite.height&&(this.preloadSprite.rect.height=this.preloadSprite.sprite.height)},checkKeyExists:function(a,b){return-1=c||d&&this._loadedPackCount===this._totalPackCount);a++);this.updateProgress();if(this._processingHead>=this._fileList.length)this.finishedLoading();else if(!this._flightQueue.length){console.warn("Phaser.Loader - aborting: processing queue empty, loading may have stalled");var f=this;setTimeout(function(){f.finishedLoading(!0)},2E3)}}else console.warn("Phaser.Loader - active loading canceled / reset"), this.finishedLoading(!0)},finishedLoading:function(a){this.hasLoaded||(this.hasLoaded=!0,this.isLoading=!1,a||this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this.game.state.loadUpdate(),this.onBeforeLoadComplete.dispatch(),this.reset(),this.onLoadComplete.dispatch(),this.game.state&&this.game.state.loadComplete())},asyncComplete:function(a,b){void 0===b&&(b="");a.loaded=!0;a.error=!!b;b&&(a.errorMessage=b,console.warn("Phaser.Loader - "+a.type+"["+a.key+"]: "+b));this.processLoadQueue()}, processPack:function(a){var b=a.data[a.key];if(b)for(var d=0;d=e.status?f.call(k,a,e):c.call(k,a,e)}catch(m){k.hasLoaded?window.console&&console.error(m):k.asyncComplete(a,m.message||"Exception")}};e.onerror=function(){try{return f.call(k,a,e)}catch(m){k.hasLoaded?window.console&&console.error(m):k.asyncComplete(a,m.message||"Exception")}};a.requestObject=e;a.requestUrl=b;e.send()},getVideoURL:function(a){for(var b=0;b=c?f="PVRTC":7<=c&&11>=c?f="S3TC":6===c&&(f="ETC1");switch(c){case 0:d=35841;break;case 1:d=35843;break;case 2:d=35840;break;case 3:d=35842;break;case 6:d=36196;break; case 7:d=33777;break;case 9:d=33778;break;case 11:d=33779;break;default:d=-1}d={complete:!0,fileFormat:"PVR",compressionAlgorithm:f,flags:b[1],pixelFormat:c,colorSpace:b[4],channelType:b[5],height:b[6],width:b[7],depth:b[8],numberOfSurfaces:b[9],numberOfFaces:b[10],numberOfMipmaps:b[11],metaDataSize:b[12],textureData:a.subarray(52+b[12],a.byteLength),glExtensionFormat:d}}return d},dds:function(a){var b=new Uint8Array(a);a=new Uint32Array(a);var d=null;68===b[0]&&68===b[1]&&83===b[2]&&32===b[3]&&(d= {complete:!0,fileFormat:"DDS",compressionAlgorithm:"S3TC",size:a[1],flags:a[2],height:a[3],width:a[4],pitch:a[5],depth:a[6],mipmapCount:a[7],formatSize:a[19],formatFlag:a[19],formatFourCC:[String.fromCharCode(b[84]),String.fromCharCode(b[85]),String.fromCharCode(b[86]),String.fromCharCode(b[87])].join(""),formatBitCount:a[21],formatRBitMask:a[22],formatGBitMask:a[23],formatBBitMask:a[24],formatABitMask:a[25],caps1:a[26],caps2:a[27],caps3:a[28],caps4:a[29],reserved2:a[30],DXGIFormat:null,resourceDimension:null, miscFlag:null,arraySize:null,textureData:b.subarray(a[1]+4,b.byteLength)},"DX10"===d.formatFourCC&&(d.DXGIFormat=a[31],d.resourceDimension=a[32],d.miscFlag=a[33],d.arraySize=a[34],d.miscFlag=a[35]));return d},ktx:function(a){var b=new Uint8Array(a);a=new Uint32Array(a);var d=null,c=16+a[15]/4|0,f=a[c],g=a[7],k=0;if(171===b[0]&&75===b[1]&&84===b[2]&&88===b[3]&&32===b[4]&&49===b[5]&&49===b[6]&&187===b[7]&&13===b[8]&&10===b[9]&&26===b[10]&&10===b[11]&&0<=[36196,35840,35841,35842,35843,33776,33777,33778, 33779].indexOf(g)){switch(g){case 36196:k="ETC1";break;case 35840:case 35841:case 35842:case 35843:k="PVRTC";break;case 33776:case 33777:case 33778:case 33779:k="S3TC"}d={complete:!0,fileFormat:"KTX",compressionAlgorithm:k,endianness:a[3],glType:a[4],glTypeSize:a[5],glFormat:a[6],glInternalFormat:a[7],glBaseInternalFormat:a[8],width:a[9],height:a[10],pixelDepth:a[11],numberOfArrayElements:a[12],numberOfFaces:a[13],numberOfMipmapLevels:a[14],bytesOfKeyValueData:a[15],keyAndValueByteSize:a[16],imageSize:f, textureData:b.subarray(4*(c+1),f+100)}}return d},pkm:function(a){a=new Uint8Array(a);var b=null;80===a[0]&&75===a[1]&&77===a[2]&&32===a[3]&&(b={complete:!0,fileFormat:"PKM",compressionAlgorithm:"ETC1",format:(a[6]<<8|a[7])&65535,width:(a[8]<<8|a[9])&65535,height:(a[10]<<8|a[11])&65535,originalWidth:(a[12]<<8|a[13])&65535,originalHeight:(a[14]<<8|a[15])&65535,textureData:a.subarray(16,a.length)});return b}};c.AudioSprite=function(a,b){this.game=a;this.key=b;this.config=this.game.cache.getJSON(b+"-audioatlas"); this.autoplayKey=null;this.autoplay=!1;this.sounds={};for(var d in this.config.spritemap)a=this.config.spritemap[d],b=this.game.add.sound(this.key),b.addMarker(d,a.start,a.end-a.start,null,a.loop),this.sounds[d]=b;this.config.autoplay&&(this.autoplayKey=this.config.autoplay,this.play(this.autoplayKey),this.autoplay=this.sounds[this.autoplayKey])};c.AudioSprite.prototype={play:function(a,b){void 0===b&&(b=1);return this.sounds[a].play(a,null,b)},stop:function(a){if(a)this.sounds[a].stop();else for(var b in this.sounds)this.sounds[b].stop()}, get:function(a){return this.sounds[a]}};c.AudioSprite.prototype.constructor=c.AudioSprite;c.Sound=function(a,b,d,e,f){void 0===d&&(d=1);void 0===e&&(e=!1);void 0===f&&(f=a.sound.connectToMaster);this.game=a;this.key=this.name=b;this.loop=e;this.markers={};this.context=null;this.autoplay=!1;this.stopTime=this.position=this.durationMS=this.duration=this.currentTime=this.startTime=this.totalDuration=0;this.paused=!1;this.pausedTime=this.pausedPosition=0;this.isPlaying=!1;this.currentMarker="";this.fadeTween= null;this.playOnce=this.allowMultiple=this.override=this.pendingPlayback=!1;this.usingWebAudio=this.game.sound.usingWebAudio;this.usingAudioTag=this.game.sound.usingAudioTag;this._sound=this.gainNode=this.masterGainNode=this.externalNode=null;this._globalVolume=1;this._removeFromSoundManager=this._markedToDelete=!1;this._sourceId=0;this.usingWebAudio?(this.context=this.game.sound.context,this.masterGainNode=this.game.sound.masterGain,this.gainNode=void 0===this.context.createGain?this.context.createGainNode(): this.context.createGain(),this.gainNode.gain.value=d,f&&this.gainNode.connect(this.masterGainNode)):this.usingAudioTag&&(this.game.cache.getSound(b)&&this.game.cache.isSoundReady(b)?(this._sound=this.game.cache.getSoundData(b),this.totalDuration=0,this._sound.duration&&(this.totalDuration=this._sound.duration)):this.game.cache.onSoundUnlock.add(this.soundHasUnlocked,this));this.onDecoded=new c.Signal;this.onPlay=new c.Signal;this.onPause=new c.Signal;this.onResume=new c.Signal;this.onLoop=new c.Signal; this.onStop=new c.Signal;this.onMute=new c.Signal;this.onMarkerComplete=new c.Signal;this.onFadeComplete=new c.Signal;this._volume=d;this._buffer=null;this._muted=!1;this._tempLoop=this._muteVolume=this._tempPause=this._tempVolume=this._tempPosition=this._tempMarker=0;this._onDecodedEventDispatched=this._paused=!1};c.Sound.prototype={soundHasUnlocked:function(a){a===this.key&&(this._sound=this.game.cache.getSoundData(this.key),this.totalDuration=this._sound.duration)},addMarker:function(a,b,d,c,f){if(void 0=== d||null===d)d=1;if(void 0===c||null===c)c=1;void 0===f&&(f=!1);this.markers[a]={name:a,start:b,stop:b+d,volume:c,duration:d,durationMS:1E3*d,loop:f}},removeMarker:function(a){delete this.markers[a]},onEndedHandler:function(){this._removeOnEndedHandler();this.isPlaying=!1;this.currentTime=this.durationMS;this.stop();this.playOnce&&(this._removeFromSoundManager=this._markedToDelete=!0);this._markedToDelete&&(this._disconnectSource(),this._removeFromSoundManager?this.game.sound.remove(this):(this.markers= {},this.externalNode=this._buffer=this.context=null,this.onDecoded.dispose(),this.onPlay.dispose(),this.onPause.dispose(),this.onResume.dispose(),this.onLoop.dispose(),this.onStop.dispose(),this.onMute.dispose(),this.onMarkerComplete.dispose()))},update:function(){this.game.cache.checkSoundKey(this.key)?(this.isDecoded&&!this._onDecodedEventDispatched&&(this.onDecoded.dispatch(this),this._onDecodedEventDispatched=!0),this.pendingPlayback&&this.game.cache.isSoundReady(this.key)&&(this.pendingPlayback= !1,this.play(this._tempMarker,this._tempPosition,this._tempVolume,this._tempLoop)),this.isPlaying&&(this.currentTime=this.game.time.time-this.startTime,this.currentTime>=this.durationMS&&(this.usingWebAudio?this.loop?(this.onLoop.dispatch(this),this.isPlaying=!1,""===this.currentMarker?(this.currentTime=0,this.startTime=this.game.time.time,this.isPlaying=!0):(this.onMarkerComplete.dispatch(this.currentMarker,this),this.play(this.currentMarker,0,this.volume,!0,!0))):""!==this.currentMarker&&this.stop(): this.loop?(this.onLoop.dispatch(this),""===this.currentMarker&&(this.currentTime=0,this.startTime=this.game.time.time),this.isPlaying=!1,this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop()))):this.destroy()},loopFull:function(a){return this.play(null,0,a,!0)},play:function(a,b,d,c,f){if(void 0===a||!1===a||null===a)a="";void 0===f&&(f=!0);if(this.isPlaying&&!this.allowMultiple&&!f&&!this.override)return this;this._sound&&this.isPlaying&&!this.allowMultiple&&(this.override||f)&&(this.usingWebAudio? this._stopSourceAndDisconnect():this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0),this.isPlaying=!1);if(""===a&&0=a.chromeVersion&&console.log('A "GainNode.gain.value setter smoothing is deprecated" notice in Chrome is normal. ')},setTouchLock:function(){this.noAudio||window.PhaserGlobal&&!0===window.PhaserGlobal.disableAudio||(this.game.input.addTouchLockCallback(this.unlock,this,!0),this.touchLocked=!0)},setTouchUnlock:function(){this.touchLocked=!1;this._unlockSource=null;this.onTouchUnlock.dispatch()}, resumeWebAudio:function(){if(this.usingWebAudio&&"suspended"===this.context.state)return this.context.resume()},unlock:function(){if(this.noAudio||!this.touchLocked||null!==this._unlockSource)return!0;if(this.usingAudioTag)this.setTouchUnlock();else if(this.usingWebAudio){var a=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource();this._unlockSource.buffer=a;this._unlockSource.connect(this.context.destination);var b=this;this._unlockSource.onended=function(){b.setTouchUnlock(); b.resumeWebAudio()};void 0===this._unlockSource.start?this._unlockSource.noteOn(0):this._unlockSource.start(0);this.resumeWebAudio()}return!0},stopAll:function(){if(!this.noAudio)for(var a=0;aa?a=0:1=a.width||0>=a.height||0>=b||0>=d)return a;var e=a.height*b/a.width,g=a.width*d/a.height;(g>b?c:!c)?(a.width=Math.floor(b),a.height=Math.floor(e)):(a.width=Math.floor(g), a.height=Math.floor(d));return a},destroy:function(){this.game.onResume.remove(this._gameResumed,this);window.removeEventListener("orientationchange",this._orientationChange,!1);window.removeEventListener("resize",this._windowResize,!1);this.compatibility.supportsFullScreen&&(document.removeEventListener("webkitfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("mozfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("MSFullscreenChange",this._fullScreenChange, !1),document.removeEventListener("fullscreenchange",this._fullScreenChange,!1),document.removeEventListener("webkitfullscreenerror",this._fullScreenError,!1),document.removeEventListener("mozfullscreenerror",this._fullScreenError,!1),document.removeEventListener("MSFullscreenError",this._fullScreenError,!1),document.removeEventListener("fullscreenerror",this._fullScreenError,!1))}};c.ScaleManager.prototype.constructor=c.ScaleManager;Object.defineProperty(c.ScaleManager.prototype,"boundingParent", {get:function(){return this.parentIsWindow||this.isFullScreen&&this.hasPhaserSetFullScreen&&!this._createdFullScreenTarget?null:this.game.canvas&&this.game.canvas.parentNode||null}});Object.defineProperty(c.ScaleManager.prototype,"scaleMode",{get:function(){return this._scaleMode},set:function(a){a!==this._scaleMode&&(this.isFullScreen||(this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.queueUpdate(!0)),this._scaleMode=a);return this._scaleMode}});Object.defineProperty(c.ScaleManager.prototype, "fullScreenScaleMode",{get:function(){return this._fullScreenScaleMode},set:function(a){a!==this._fullScreenScaleMode&&(this.isFullScreen?(this.prepScreenMode(!1),this._fullScreenScaleMode=a,this.prepScreenMode(!0),this.queueUpdate(!0)):this._fullScreenScaleMode=a);return this._fullScreenScaleMode}});Object.defineProperty(c.ScaleManager.prototype,"currentScaleMode",{get:function(){return this.isFullScreen?this._fullScreenScaleMode:this._scaleMode}});Object.defineProperty(c.ScaleManager.prototype, "pageAlignHorizontally",{get:function(){return this._pageAlignHorizontally},set:function(a){a!==this._pageAlignHorizontally&&(this._pageAlignHorizontally=a,this.queueUpdate(!0))}});Object.defineProperty(c.ScaleManager.prototype,"pageAlignVertically",{get:function(){return this._pageAlignVertically},set:function(a){a!==this._pageAlignVertically&&(this._pageAlignVertically=a,this.queueUpdate(!0))}});Object.defineProperty(c.ScaleManager.prototype,"isFullScreen",{get:function(){return!!(document.fullscreenElement|| document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}});Object.defineProperty(c.ScaleManager.prototype,"isPortrait",{get:function(){return"portrait"===this.classifyOrientation(this.screenOrientation)}});Object.defineProperty(c.ScaleManager.prototype,"isLandscape",{get:function(){return"landscape"===this.classifyOrientation(this.screenOrientation)}});Object.defineProperty(c.ScaleManager.prototype,"isGamePortrait",{get:function(){return this.height>this.width}}); Object.defineProperty(c.ScaleManager.prototype,"isGameLandscape",{get:function(){return this.width>this.height}});c.Utils.Debug=function(a){this.game=a;this.context=this.canvas=this.bmd=this.sprite=null;this.font="14px monospace";this.columnWidth=100;this.lineHeight=16;this.lineWidth=1;this.renderShadow=!0;this.currentColor=null;this.currentY=this.currentX=0;this.currentAlpha=1;this.isDisabled=this.dirty=!1;this._rect=this._line=null};c.Utils.Debug.GEOM_AUTO=0;c.Utils.Debug.GEOM_RECTANGLE=1;c.Utils.Debug.GEOM_CIRCLE= 2;c.Utils.Debug.GEOM_POINT=3;c.Utils.Debug.GEOM_LINE=4;c.Utils.Debug.GEOM_ELLIPSE=5;c.Utils.Debug.prototype={boot:function(){this.game.renderType===c.CANVAS?this.context=this.game.context:(this.bmd=new c.BitmapData(this.game,"__DEBUG",this.game.width,this.game.height,!0),this.sprite=this.game.make.image(0,0,this.bmd),this.game.stage.addChild(this.sprite),this.game.scale.onSizeChange.add(this.resize,this),this.canvas=c.CanvasPool.create(this,this.game.width,this.game.height),this.context=this.canvas.getContext("2d")); this._line=new c.Line;this._rect=new c.Rectangle},resize:function(){this.bmd.resize(this.game.width,this.game.height);this.canvas.width=this.game.width;this.canvas.height=this.game.height},preUpdate:function(){this.dirty&&this.sprite&&(this.bmd.clear(),this.bmd.draw(this.canvas,0,0),this.context.clearRect(0,0,this.game.width,this.game.height),this.dirty=!1)},reset:function(){this.context&&this.context.clearRect(0,0,this.game.width,this.game.height);this.sprite&&this.bmd.clear()},start:function(a, b,d,c){"number"!==typeof a&&(a=0);"number"!==typeof b&&(b=0);d=d||"rgb(255,255,255)";void 0===c&&(c=0);this.currentX=a;this.currentY=b;this.currentColor=d;this.columnWidth=c;this.dirty=!0;this.context.save();this.context.setTransform(1,0,0,1,0,0);this.context.strokeStyle=d;this.context.fillStyle=d;this.context.font=this.font;this.context.globalAlpha=this.currentAlpha},stop:function(){this.context.restore()},line:function(){for(var a=this.currentX,b=0;bb.width?"portrait-primary":"landscape-primary";if("viewport"!==a){if("window.orientation"===a&&"number"===typeof window.orientation)return 0===window.orientation||180===window.orientation? "portrait-primary":"landscape-primary";if(window.matchMedia){if(window.matchMedia("(orientation: portrait)").matches)return"portrait-primary";if(window.matchMedia("(orientation: landscape)").matches)return"landscape-primary"}}return this.visualBounds.height>this.visualBounds.width?"portrait-primary":"landscape-primary"},visualBounds:new c.Rectangle,layoutBounds:new c.Rectangle,documentBounds:new c.Rectangle};c.Device.whenReady(function(a){var b=window&&"pageXOffset"in window?function(){return window.pageXOffset}: function(){return document.documentElement.scrollLeft},d=window&&"pageYOffset"in window?function(){return window.pageYOffset}:function(){return document.documentElement.scrollTop};Object.defineProperty(c.DOM,"scrollX",{get:b});Object.defineProperty(c.DOM,"scrollY",{get:d});Object.defineProperty(c.DOM.visualBounds,"x",{get:b});Object.defineProperty(c.DOM.visualBounds,"y",{get:d});Object.defineProperty(c.DOM.layoutBounds,"x",{value:0});Object.defineProperty(c.DOM.layoutBounds,"y",{value:0});a.desktop&& document.documentElement.clientWidth<=window.innerWidth&&document.documentElement.clientHeight<=window.innerHeight?(a=function(){return Math.max(window.innerWidth,document.documentElement.clientWidth)},b=function(){return Math.max(window.innerHeight,document.documentElement.clientHeight)},Object.defineProperty(c.DOM.visualBounds,"width",{get:a}),Object.defineProperty(c.DOM.visualBounds,"height",{get:b}),Object.defineProperty(c.DOM.layoutBounds,"width",{get:a}),Object.defineProperty(c.DOM.layoutBounds, "height",{get:b})):(Object.defineProperty(c.DOM.visualBounds,"width",{get:function(){return window.innerWidth}}),Object.defineProperty(c.DOM.visualBounds,"height",{get:function(){return window.innerHeight}}),Object.defineProperty(c.DOM.layoutBounds,"width",{get:function(){var a=document.documentElement.clientWidth,b=window.innerWidth;return a=c||0===d)){null==d&&(d=1);for(c-=d;b>>0:(a<<24|b<<16|d<<8|e)>>>0},unpackPixel:function(a,b,d,e){if(void 0===b||null===b)b=c.Color.createColor();if(void 0===d||null===d)d=!1;if(void 0===e||null===e)e=!1; c.Device.LITTLE_ENDIAN?(b.a=(a&4278190080)>>>24,b.b=(a&16711680)>>>16,b.g=(a&65280)>>>8,b.r=a&255):(b.r=(a&4278190080)>>>24,b.g=(a&16711680)>>>16,b.b=(a&65280)>>>8,b.a=a&255);b.color=a;b.rgba="rgba("+b.r+","+b.g+","+b.b+","+b.a/255+")";d&&c.Color.RGBtoHSL(b.r,b.g,b.b,b);e&&c.Color.RGBtoHSV(b.r,b.g,b.b,b);return b},fromRGBA:function(a,b){b||(b=c.Color.createColor());b.r=(a&4278190080)>>>24;b.g=(a&16711680)>>>16;b.b=(a&65280)>>>8;b.a=a&255;b.rgba="rgba("+b.r+","+b.g+","+b.b+","+b.a+")";return b},toRGBA:function(a, b,d,c){return a<<24|b<<16|d<<8|c},toABGR:function(a,b,d,c){return(c<<24|d<<16|b<<8|a)>>>0},hexToRGBArray:function(a){return[(a>>16&255)/255,(a>>8&255)/255,(a&255)/255]},RGBArrayToHex:function(a){return(255*a[0]<<16)+(255*a[1]<<8)+255*a[2]},RGBtoHSL:function(a,b,d,e){e||(e=c.Color.createColor(a,b,d,1));a/=255;b/=255;d/=255;var f=Math.min(a,b,d),g=Math.max(a,b,d);e.h=0;e.s=0;e.l=(g+f)/2;if(g!==f){var k=g-f;e.s=.5d?d*(1+b):d+b-d*b,d=2*d-b,e.r=c.Color.hueToColor(d,b,a+1/3),e.g=c.Color.hueToColor(d,b,a),e.b=c.Color.hueToColor(d,b,a-1/3));e.r=Math.floor(255*e.r|0);e.g=Math.floor(255*e.g|0);e.b=Math.floor(255*e.b|0);c.Color.updateColor(e);return e},RGBtoHSV:function(a,b,d,e){e||(e=c.Color.createColor(a,b,d,255));a/=255;b/=255;d/=255;var f=Math.min(a,b,d),g=Math.max(a,b,d),k=g-f;e.h=0;e.s=0===g?0:k/ g;e.v=g;g!==f&&(g===a?e.h=(b-d)/k+(bd&&(d+=1);1d?b:d<2/3?a+(b-a)*(2/3-d)*6:a},createColor:function(a,b,d,e,f,g,k,h){return c.Color.updateColor({r:a||0,g:b||0,b:d||0,a:e||1,h:f||0,s:g||0,l:k||0,v:h||0,color:0,color32:0,rgba:""})},updateColor:function(a){a.rgba="rgba("+a.r.toFixed()+","+a.g.toFixed()+","+a.b.toFixed()+","+a.a.toString()+")";a.color=c.Color.getColor(a.r,a.g,a.b);a.color32=c.Color.getColor32(255*a.a,a.r,a.g,a.b);return a},getColor32:function(a,b, d,c){return a<<24|b<<16|d<<8|c},getColor:function(a,b,d){return a<<16|b<<8|d},RGBtoString:function(a,b,d,e,f){void 0===e&&(e=255);void 0===f&&(f="#");return"#"===f?"#"+(16777216+(a<<16)+(b<<8)+d).toString(16).slice(1):"0x"+c.Color.componentToHex(e)+c.Color.componentToHex(a)+c.Color.componentToHex(b)+c.Color.componentToHex(d)},hexToRGB:function(a){if(a=c.Color.hexToColor(a))return c.Color.getColor32(a.a,a.r,a.g,a.b)},hexToColor:function(a,b){a=a.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,function(a, b,d,c){return b+b+d+d+c+c});var d=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);if(d){a=parseInt(d[1],16);var e=parseInt(d[2],16);d=parseInt(d[3],16);b?(b.r=a,b.g=e,b.b=d):b=c.Color.createColor(a,e,d)}return b},webToColor:function(a,b){b||(b=c.Color.createColor());if(a=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(a))b.r=~~Number(a[1]),b.g=~~Number(a[2]),b.b=~~Number(a[3]),b.a=void 0!==a[4]?Number(a[4]):1,c.Color.updateColor(b);return b},valueToColor:function(a, b){b||(b=c.Color.createColor());if("string"===typeof a){if(0===a.indexOf("rgb"))return c.Color.webToColor(a,b);b.a=1;return c.Color.hexToColor(a,b)}"number"===typeof a&&(a=c.Color.getRGB(a),b.r=a.r,b.g=a.g,b.b=a.b,b.a=a.a/255);return b},componentToHex:function(a){a=a.toString(16);return 1===a.length?"0"+a:a},HSVColorWheel:function(a,b){void 0===a&&(a=1);void 0===b&&(b=1);for(var d=[],e=0;359>=e;e++)d.push(c.Color.HSVtoRGB(e/359,a,b));return d},HSLColorWheel:function(a,b){void 0===a&&(a=.5);void 0=== b&&(b=.5);for(var d=[],e=0;359>=e;e++)d.push(c.Color.HSLtoRGB(e/359,a,b));return d},interpolateColor:function(a,b,d,e,f,g){void 0===f&&(f=255);void 0===g&&(g=0);a=c.Color.getRGB(a);b=c.Color.getRGB(b);if(0===g)var k=(b.red-a.red)*e/d+a.red,h=(b.green-a.green)*e/d+a.green,l=(b.blue-a.blue)*e/d+a.blue;if(1===g){g=c.Color.RGBtoHSV(a.r,a.g,a.b);k=c.Color.RGBtoHSV(b.r,b.g,b.b);h=k.h-g.h;g.h>k.h&&(l=k.h,k.h=g.h,g.h=l,h=-h,e=d-e);if(.5=h&&(n=(k.h-g.h)*e/d+g.h);var q= c.Color.HSVtoRGB(n,(k.s-g.s)*e/d+g.s,(k.v-g.v)*e/d+g.v,q);k=q.r;h=q.g;l=q.b}return c.Color.getColor32(f,k,h,l)},interpolateColorWithRGB:function(a,b,d,e,f,g){a=c.Color.getRGB(a);return c.Color.getColor((b-a.red)*g/f+a.red,(d-a.green)*g/f+a.green,(e-a.blue)*g/f+a.blue)},interpolateRGB:function(a,b,d,e,f,g,k,h){return c.Color.getColor((e-a)*h/k+a,(f-b)*h/k+b,(g-d)*h/k+d)},linear:function(a,b,d){return this.interpolateColor(a,b,1,d)},linearInterpolation:function(a,b){b=c.Math.linear(0,a.length-1,b); return this.linear(a[Math.floor(b)],a[Math.ceil(b)],b%1)},getRandomColor:function(a,b,d){void 0===a&&(a=0);void 0===b&&(b=255);void 0===d&&(d=255);return 255b?c.Color.getColor(255,255,255):c.Color.getColor32(d,a+Math.round(Math.random()*(b-a)),a+Math.round(Math.random()*(b-a)),a+Math.round(Math.random()*(b-a)))},getRGB:function(a){return 16777215>>24,red:a>>16&255,green:a>>8&255,blue:a&255,a:a>>>24,r:a>>16&255,g:a>>8&255,b:a&255}:{alpha:255,red:a>>16&255,green:a>>8&255,blue:a&255, a:255,r:a>>16&255,g:a>>8&255,b:a&255}},getWebRGB:function(a){if("object"===typeof a)return"rgba("+a.r.toString()+","+a.g.toString()+","+a.b.toString()+","+(a.a/255).toString()+")";a=c.Color.getRGB(a);return"rgba("+a.r.toString()+","+a.g.toString()+","+a.b.toString()+","+(a.a/255).toString()+")"},getAlpha:function(a){return a>>>24},getAlphaFloat:function(a){return(a>>>24)/255},getRed:function(a){return a>>16&255},getGreen:function(a){return a>>8&255},getBlue:function(a){return a&255},blendNormal:function(a){return a}, blendLighten:function(a,b){return b>a?b:a},blendDarken:function(a,b){return b>a?a:b},blendMultiply:function(a,b){return a*b/255},blendAverage:function(a,b){return(a+b)/2},blendAdd:function(a,b){return Math.min(255,a+b)},blendSubtract:function(a,b){return Math.max(0,a+b-255)},blendDifference:function(a,b){return Math.abs(a-b)},blendNegation:function(a,b){return 255-Math.abs(255-a-b)},blendScreen:function(a,b){return 255-((255-a)*(255-b)>>8)},blendExclusion:function(a,b){return a+b-2*a*b/255},blendOverlay:function(a, b){return 128>b?2*a*b/255:255-2*(255-a)*(255-b)/255},blendSoftLight:function(a,b){return 128>b?b/255*((a>>1)+64)*2:255-2*(255-((a>>1)+64))*(255-b)/255},blendHardLight:function(a,b){return c.Color.blendOverlay(b,a)},blendColorDodge:function(a,b){return 255===b?b:Math.min(255,(a<<8)/(255-b))},blendColorBurn:function(a,b){return 0===b?b:Math.max(0,255-(255-a<<8)/b)},blendLinearDodge:function(a,b){return c.Color.blendAdd(a,b)},blendLinearBurn:function(a,b){return c.Color.blendSubtract(a,b)},blendLinearLight:function(a, b){return 128>b?c.Color.blendLinearBurn(a,2*b):c.Color.blendLinearDodge(a,2*(b-128))},blendVividLight:function(a,b){return 128>b?c.Color.blendColorBurn(a,2*b):c.Color.blendColorDodge(a,2*(b-128))},blendPinLight:function(a,b){return 128>b?c.Color.blendDarken(a,2*b):c.Color.blendLighten(a,2*(b-128))},blendHardMix:function(a,b){return 128>c.Color.blendVividLight(a,b)?0:255},blendReflect:function(a,b){return 255===b?b:Math.min(255,a*a/(255-b))},blendGlow:function(a,b){return c.Color.blendReflect(b,a)}, blendPhoenix:function(a,b){return Math.min(a,b)-Math.max(a,b)+255}};c.Physics=function(a,b){b=b||{};this.game=a;this.config=b;this.matter=this.chipmunk=this.box2d=this.ninja=this.p2=this.arcade=null;this.parseConfig()};c.Physics.ARCADE=0;c.Physics.P2JS=1;c.Physics.NINJA=2;c.Physics.BOX2D=3;c.Physics.CHIPMUNK=4;c.Physics.MATTERJS=5;c.Physics.prototype={parseConfig:function(){this.config.hasOwnProperty("arcade")&&!0!==this.config.arcade||!c.Physics.hasOwnProperty("Arcade")||(this.arcade=new c.Physics.Arcade(this.game)); this.config.hasOwnProperty("ninja")&&!0===this.config.ninja&&c.Physics.hasOwnProperty("Ninja")&&(this.ninja=new c.Physics.Ninja(this.game));this.config.hasOwnProperty("p2")&&!0===this.config.p2&&c.Physics.hasOwnProperty("P2")&&(this.p2=new c.Physics.P2(this.game,this.config));this.config.hasOwnProperty("box2d")&&!0===this.config.box2d&&c.Physics.hasOwnProperty("BOX2D")&&(this.box2d=new c.Physics.BOX2D(this.game,this.config));this.config.hasOwnProperty("matter")&&!0===this.config.matter&&c.Physics.hasOwnProperty("Matter")&& (this.matter=new c.Physics.Matter(this.game,this.config))},startSystem:function(a){a===c.Physics.ARCADE?this.arcade=new c.Physics.Arcade(this.game):a===c.Physics.P2JS?null===this.p2?this.p2=new c.Physics.P2(this.game,this.config):this.p2.reset():a===c.Physics.NINJA?this.ninja=new c.Physics.Ninja(this.game):a===c.Physics.BOX2D?null===this.box2d?this.box2d=new c.Physics.Box2D(this.game,this.config):this.box2d.reset():a===c.Physics.MATTERJS&&(null===this.matter?this.matter=new c.Physics.Matter(this.game, this.config):this.matter.reset())},enable:function(a,b,d){void 0===b&&(b=c.Physics.ARCADE);void 0===d&&(d=!1);b===c.Physics.ARCADE?this.arcade.enable(a):b===c.Physics.P2JS&&this.p2?this.p2.enable(a,d):b===c.Physics.NINJA&&this.ninja?this.ninja.enableAABB(a):b===c.Physics.BOX2D&&this.box2d?this.box2d.enable(a):b===c.Physics.MATTERJS&&this.matter?this.matter.enable(a):console.warn(a.key+" is attempting to enable a physics body using an unknown physics system.")},preUpdate:function(){this.p2&&this.p2.preUpdate(); this.box2d&&this.box2d.preUpdate();this.matter&&this.matter.preUpdate()},update:function(){this.p2&&this.p2.update();this.box2d&&this.box2d.update();this.matter&&this.matter.update()},setBoundsToWorld:function(){this.arcade&&this.arcade.setBoundsToWorld();this.ninja&&this.ninja.setBoundsToWorld();this.p2&&this.p2.setBoundsToWorld();this.box2d&&this.box2d.setBoundsToWorld();this.matter&&this.matter.setBoundsToWorld()},clear:function(){this.p2&&this.p2.clear();this.box2d&&this.box2d.clear();this.matter&& this.matter.clear()},reset:function(){this.p2&&this.p2.reset();this.box2d&&this.box2d.reset();this.matter&&this.matter.reset()},destroy:function(){this.p2&&this.p2.destroy();this.box2d&&this.box2d.destroy();this.matter&&this.matter.destroy();this.matter=this.box2d=this.p2=this.ninja=this.arcade=null}};c.Physics.prototype.constructor=c.Physics;c.Physics.Arcade=function(a){this.game=a;this.gravity=new c.Point;this.bounds=new c.Rectangle(0,0,a.world.width,a.world.height);this.checkCollision={up:!0,down:!0, left:!0,right:!0};this.maxObjects=10;this.OVERLAP_BIAS=this.maxLevels=4;this.forceX=!1;this.sortDirection=c.Physics.Arcade.LEFT_RIGHT;this.skipQuadTree=!0;this.isPaused=!1;this.quadTree=new c.QuadTree(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._total=0;this.setBoundsToWorld()};c.Physics.Arcade.prototype.constructor=c.Physics.Arcade;c.Physics.Arcade.SORT_NONE=0;c.Physics.Arcade.LEFT_RIGHT=1;c.Physics.Arcade.RIGHT_LEFT= 2;c.Physics.Arcade.TOP_BOTTOM=3;c.Physics.Arcade.BOTTOM_TOP=4;c.Physics.Arcade.prototype={setBounds:function(a,b,d,c){this.bounds.setTo(a,b,d,c)},setBoundsToWorld:function(){this.bounds.copyFrom(this.game.world.bounds)},enable:function(a,b){void 0===b&&(b=!0);var d;if(Array.isArray(a))for(d=a.length;d--;)a[d]instanceof c.Group?this.enable(a[d].children,b):(this.enableBody(a[d]),b&&a[d].hasOwnProperty("children")&&0d+f?d+f:0);d>g?d=g:d<-g&&(d=-g);return d},overlap:function(a,b,d,c,f){d=d||null;this._total=0;this.collideObjects(a,b,d,c||null,f||d,!0);return 0h.right)break;else{if(h.x>a.body.right)continue}else if(this.sortDirection===c.Physics.Arcade.TOP_BOTTOM)if(a.body.bottom h.bottom)break;else if(h.y>a.body.bottom)continue;this.collideSpriteVsSprite(a,l,d,e,f,g)}}else for(this.quadTree.clear(),this.quadTree.reset(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.quadTree.populate(b),b=this.quadTree.retrieve(a),m=0;mn.right)continue;else{if(n.x>h.right)break}else if(this.sortDirection===c.Physics.Arcade.TOP_BOTTOM)if(h.bottomn.bottom)continue;else if(n.y>m.body.bottom)break;this.collideSpriteVsSprite(m,q,b,d,e,f)}}}}},collideGroupVsGroup:function(a,b,d,e,f,g){if(0!==a.length&&0!==b.length)for(var h=0;hh)if(m.xe)return this.separateCircle(a,b,f)}c=d=!1;this.forceX||Math.abs(this.gravity.y+a.gravity.y)=b.right||a.position.y>=b.bottom?!1:!0},circleBodyIntersects:function(a,b){var d=c.Math.clamp(a.center.x,b.left,b.right);b=c.Math.clamp(a.center.y,b.top,b.bottom);return(a.center.x-d)*(a.center.x-d)+(a.center.y-b)*(a.center.y-b)<=a.halfWidth*a.halfWidth},separateCircle:function(a,b,d){this.getOverlapX(a,b);this.getOverlapY(a,b);var e=Math.atan2(b.center.y-a.center.y,b.center.x-a.center.x),f=0;if(a.isCircle!==b.isCircle){var g=b.isCircle?a.position.x:b.position.x,h=b.isCircle?a.position.y: b.position.y,m=b.isCircle?a.right:b.right,l=b.isCircle?a.bottom:b.bottom,n=a.isCircle?a.center.x:b.center.x,q=a.isCircle?a.center.y:b.center.y,t=a.isCircle?a.halfWidth:b.halfWidth;qm&&(f=c.Math.distance(n,q,m,h)-t):q>l&&(nm&&(f=c.Math.distance(n,q,m,l)-t));f*=-1}else f=a.halfWidth+b.halfWidth-c.Math.distance(a.center.x,a.center.y,b.center.x,b.center.y);if(d||0===f||a.immovable&&b.immovable||a.customSeparateX||b.customSeparateX)return 0!== f&&(a.onOverlap&&a.onOverlap.dispatch(a.sprite,b.sprite),b.onOverlap&&b.onOverlap.dispatch(b.sprite,a.sprite)),0!==f;m=a.velocity.x*Math.cos(e)+a.velocity.y*Math.sin(e);d=-a.velocity.x*Math.sin(e)+a.velocity.y*Math.cos(e);l=b.velocity.x*Math.cos(e)+b.velocity.y*Math.sin(e);g=-b.velocity.x*Math.sin(e)+b.velocity.y*Math.cos(e);h=((a.mass-b.mass)*m+2*b.mass*l)/(a.mass+b.mass);m=(2*a.mass*m+(b.mass-a.mass)*l)/(a.mass+b.mass);a.immovable||(a.velocity.x=(h*Math.cos(e)-d*Math.sin(e))*a.bounce.x,a.velocity.y= (d*Math.cos(e)+h*Math.sin(e))*a.bounce.y);b.immovable||(b.velocity.x=(m*Math.cos(e)-g*Math.sin(e))*b.bounce.x,b.velocity.y=(g*Math.cos(e)+m*Math.sin(e))*b.bounce.y);Math.abs(e)a.velocity.x?a.velocity.x*=-1:0>b.velocity.x&&!b.immovable&&a.velocity.xa.velocity.y?a.velocity.y*=-1:0>b.velocity.y&&!b.immovable&&a.velocity.yMath.PI/ 2&&(0>a.velocity.x&&!a.immovable&&b.velocity.xb.velocity.x?b.velocity.x*=-1:0>a.velocity.y&&!a.immovable&&b.velocity.yb.velocity.y&&(b.velocity.y*=-1));a.immovable||(a.x+=a.velocity.x*this.game.time.physicsElapsed-f*Math.cos(e),a.y+=a.velocity.y*this.game.time.physicsElapsed-f*Math.sin(e));b.immovable||(b.x+=b.velocity.x*this.game.time.physicsElapsed+ f*Math.cos(e),b.y+=b.velocity.y*this.game.time.physicsElapsed+f*Math.sin(e));a.onCollide&&a.onCollide.dispatch(a.sprite,b.sprite);b.onCollide&&b.onCollide.dispatch(b.sprite,a.sprite);return!0},getOverlapX:function(a,b,d){var c=0,f=a.deltaAbsX()+b.deltaAbsX()+this.OVERLAP_BIAS;0===a.deltaX()&&0===b.deltaX()?(a.embedded=!0,b.embedded=!0):a.deltaX()>b.deltaX()?(c=a.right-b.x,c>f&&!d||!1===a.checkCollision.right||!1===b.checkCollision.left?c=0:(a.touching.none=!1,a.touching.right=!0,b.touching.none=!1, b.touching.left=!0)):a.deltaX()f&&!d||!1===a.checkCollision.left||!1===b.checkCollision.right?c=0:(a.touching.none=!1,a.touching.left=!0,b.touching.none=!1,b.touching.right=!0));a.overlapX=c;return b.overlapX=c},getOverlapY:function(a,b,d){var c=0,f=a.deltaAbsY()+b.deltaAbsY()+this.OVERLAP_BIAS;0===a.deltaY()&&0===b.deltaY()?(a.embedded=!0,b.embedded=!0):a.deltaY()>b.deltaY()?(c=a.bottom-b.y,c>f&&!d||!1===a.checkCollision.down||!1===b.checkCollision.up?c=0:(a.touching.none= !1,a.touching.down=!0,b.touching.none=!1,b.touching.up=!0)):a.deltaY()f&&!d||!1===a.checkCollision.up||!1===b.checkCollision.down?c=0:(a.touching.none=!1,a.touching.up=!0,b.touching.none=!1,b.touching.down=!0));a.overlapY=c;return b.overlapY=c},separateX:function(a,b,d){var c=this.getOverlapX(a,b,d);if(d||0===c||a.immovable&&b.immovable||a.customSeparateX||b.customSeparateX)return 0!==c||a.embedded&&b.embedded;d=a.velocity.x;var f=b.velocity.x;a.immovable||b.immovable? a.immovable?(b.x+=c,b.velocity.x=d-f*b.bounce.x,a.moves&&(b.y+=(a.y-a.prev.y)*a.friction.y)):(a.x-=c,a.velocity.x=f-d*a.bounce.x,b.moves&&(a.y+=(b.y-b.prev.y)*b.friction.y)):(c*=.5,a.x-=c,b.x+=c,c=Math.sqrt(f*f*b.mass/a.mass)*(0e&&(g=l,e=n)}return g},angleBetween:function(a,b,d){void 0===d&&(d=!1);return d?c.Point.angle(b.world,a.world):c.Point.angle(b,a)},angleBetweenCenters:function(a,b){return Math.atan2(b.centerY-a.centerY,b.centerX-a.centerX)},angleToXY:function(a,b,d,c){void 0=== c&&(c=!1);return c?Math.atan2(d-a.world.y,b-a.world.x):Math.atan2(d-a.y,b-a.x)},angleToPointer:function(a,b,d){void 0===b&&(b=this.game.input.activePointer);void 0===d&&(d=!1);return d?Math.atan2(b.worldY-a.world.y,b.worldX-a.world.x):Math.atan2(b.worldY-a.y,b.worldX-a.x)},worldAngleToPointer:function(a,b){return this.angleToPointer(a,b,!0)}};c.Physics.Arcade.Body=function(a){this.sprite=a;this.game=a.game;this.type=c.Physics.ARCADE;this.enable=!0;this.isCircle=!1;this.radius=0;this.offset=new c.Point; this.position=new c.Point(a.x,a.y);this.prev=new c.Point(this.position.x,this.position.y);this.allowRotation=!0;this.preRotation=this.rotation=a.angle;this.width=a.width;this.height=a.height;this.sourceWidth=a.width;this.sourceHeight=a.height;a.texture&&(this.sourceWidth=a.texture.frame.width,this.sourceHeight=a.texture.frame.height);this.halfWidth=Math.abs(a.width/2);this.halfHeight=Math.abs(a.height/2);this.center=new c.Point(a.x+this.halfWidth,a.y+this.halfHeight);this.velocity=new c.Point;this.newVelocity= new c.Point;this.deltaMax=new c.Point;this.acceleration=new c.Point;this.allowDrag=!0;this.drag=new c.Point;this.allowGravity=!0;this.gravity=new c.Point;this.bounce=new c.Point;this.onOverlap=this.onCollide=this.onWorldBounds=this.worldBounce=null;this.maxVelocity=new c.Point(1E4,1E4);this.friction=new c.Point(1,0);this.angularDrag=this.angularAcceleration=this.angularVelocity=0;this.maxAngular=1E3;this.mass=1;this.speed=this.angle=0;this.facing=c.NONE;this.immovable=!1;this.moves=!0;this.customSeparateY= this.customSeparateX=!1;this.overlapR=this.overlapY=this.overlapX=0;this.collideWorldBounds=this.embedded=!1;this.checkCollision={none:!1,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.blocked={none:!0,up:!1,down:!1,left:!1,right:!1};this.tilePadding=new c.Point;this.isMoving=this.syncBounds=this.skipQuadTree=this.dirty=!1;this.stopVelocityOnCollide=!0;this.moveDuration=this.moveDistance=this.moveTimer= 0;this.moveEnd=this.moveTarget=null;this.onMoveComplete=new c.Signal;this.movementCallbackContext=this.movementCallback=null;this._reset=!0;this._sx=a.scale.x;this._sy=a.scale.y;this._dy=this._dx=0};c.Physics.Arcade.Body.prototype={updateBounds:function(){if(this.syncBounds){var a=this.sprite.getBounds();a.ceilAll();if(a.width!==this.width||a.height!==this.height)this.width=a.width,this.height=a.height,this._reset=!0}else{a=Math.abs(this.sprite.scale.x);var b=Math.abs(this.sprite.scale.y);if(a!== this._sx||b!==this._sy)this.width=this.sourceWidth*a,this.height=this.sourceHeight*b,this._sx=a,this._sy=b,this._reset=!0}this._reset&&(this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter())},updateCenter:function(){this.center.setTo(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},preUpdate:function(){if(this.enable&&!this.game.physics.arcade.isPaused){this.dirty=!0;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.blocked.none=!0;this.blocked.up=!1;this.blocked.down=!1;this.blocked.left=!1;this.blocked.right=!1;this.overlapY=this.overlapX=this.overlapR=0;this.embedded=!1;this.updateBounds();this.position.x=this.sprite.world.x-this.sprite.anchor.x*this.sprite.width+this.sprite.scale.x* this.offset.x;this.position.x-=0>this.sprite.scale.x?this.width:0;this.position.y=this.sprite.world.y-this.sprite.anchor.y*this.sprite.height+this.sprite.scale.y*this.offset.y;this.position.y-=0>this.sprite.scale.y?this.height:0;this.updateCenter();this.preRotation=this.rotation=this.sprite.angle;if(this._reset||this.sprite.fresh)this.prev.x=this.position.x,this.prev.y=this.position.y;if(this.moves){this.game.physics.arcade.updateMotion(this);this.newVelocity.set(this.velocity.x*this.game.time.physicsElapsed, this.velocity.y*this.game.time.physicsElapsed);this.position.x+=this.newVelocity.x;this.position.y+=this.newVelocity.y;this.updateCenter();if(this.position.x!==this.prev.x||this.position.y!==this.prev.y)this.angle=this.velocity.atan();this.speed=Math.sqrt(this.velocity.x*this.velocity.x+this.velocity.y*this.velocity.y);this.collideWorldBounds&&this.checkWorldBounds()&&this.onWorldBounds&&this.onWorldBounds.dispatch(this.sprite,this.blocked.up,this.blocked.down,this.blocked.left,this.blocked.right)}this._dx= this.deltaX();this._dy=this.deltaY();this._reset=!1}},updateMovement:function(){var a=0!==this.overlapX||0!==this.overlapY;if(0this.deltaX()?this.facing=c.LEFT:0this.deltaY()?this.facing=c.UP:0this._dx&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:0this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(0>this._dy&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:0this.deltaMax.y&&(this._dy=this.deltaMax.y)),this.sprite.position.x+=this._dx,this.sprite.position.y+=this._dy,this._reset=!0),this.updateCenter(),this.allowRotation&&(this.sprite.angle+=this.deltaZ()),this.prev.x= this.position.x,this.prev.y=this.position.y)},checkWorldBounds:function(){var a=this.position,b=this.game.physics.arcade.bounds,d=this.game.physics.arcade.checkCollision,c=this.worldBounce?-this.worldBounce.x:-this.bounce.x,f=this.worldBounce?-this.worldBounce.y:-this.bounce.y;a.xb.right&&d.right&&(a.x=b.right-this.width,this.velocity.x*=c,this.blocked.right=!0,this.blocked.none=!1);a.yb.bottom&&d.down&&(a.y=b.bottom-this.height,this.velocity.y*=f,this.blocked.down=!0,this.blocked.none=!1);return!this.blocked.none},moveFrom:function(a,b,d){void 0===b&&(b=this.speed);if(0===b)return!1;if(void 0===d){var c=this.angle;d=this.game.math.radToDeg(c)}else c=this.game.math.degToRad(d);this.moveTimer=0;this.moveDuration=a;0===d||180===d?this.velocity.set(Math.cos(c)*b,0):90===d||270===d?this.velocity.set(0,Math.sin(c)* b):this.velocity.setToPolar(c,b);return this.isMoving=!0},moveTo:function(a,b,d){a=b/(a/1E3);if(0===a)return!1;if(void 0===d){var e=this.angle;d=this.game.math.radToDeg(e)}else e=this.game.math.degToRad(d);b=Math.abs(b);this.moveDuration=0;this.moveDistance=b;null===this.moveTarget&&(this.moveTarget=new c.Line,this.moveEnd=new c.Point);this.moveTarget.fromAngle(this.x,this.y,e,b);this.moveEnd.set(this.moveTarget.end.x,this.moveTarget.end.y);this.moveTarget.setTo(this.x,this.y,this.x,this.y);0===d|| 180===d?this.velocity.set(Math.cos(e)*a,0):90===d||270===d?this.velocity.set(0,Math.sin(e)*a):this.velocity.setToPolar(e,a);return this.isMoving=!0},setSize:function(a,b,d,c){void 0===d&&(d=this.offset.x);void 0===c&&(c=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(d,c);this.updateCenter();this.isCircle=!1;this.radius= 0},setCircle:function(a,b,d){void 0===b&&(b=this.offset.x);void 0===d&&(d=this.offset.y);0this.sprite.scale.x?this.width:0;this.position.y=b-this.sprite.anchor.y*this.sprite.height+this.sprite.scale.y*this.offset.y;this.position.y-=0>this.sprite.scale.y?this.height:0;this.prev.x=this.position.x;this.prev.y=this.position.y;this.preRotation=this.rotation=this.sprite.angle;this.updateBounds();this.updateCenter()},stop:function(){this.velocity.set(0);this.acceleration.set(0);this.angularAcceleration=this.angularVelocity=this.speed=0},getBounds:function(a){a.x=this.x;a.y= this.y;a.right=this.right;a.bottom=this.bottom;return a},hitTest:function(a,b){return this.isCircle?c.Circle.contains(this,a,b):c.Rectangle.contains(this,a,b)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return 0b.deltaAbsY()?m=-1:b.deltaAbsX()a.deltaX()&&!a.blocked.left&&b.collideRight&&a.checkCollision.left?b.faceRight&&a.x-db.left&&(c=a.right- d-b.left,c>this.TILE_BIAS&&(c=0));0!==c&&(a.customSeparateX?a.overlapX=c:this.processTileSeparationX(a,c));return c},tileCheckY:function(a,b,d){var c=0;d=d.getTileOffsetY();0>a.deltaY()&&!a.blocked.up&&b.collideDown&&a.checkCollision.up?b.faceBottom&&a.y-db.top&&(c=a.bottom-d-b.top,c>this.TILE_BIAS&&(c=0));0!==c&&(a.customSeparateY?a.overlapY=c:this.processTileSeparationY(a, c));return c},processTileSeparationX:function(a,b){0>b?(a.blocked.left=!0,a.blocked.none=!1):0b?(a.blocked.up=!0,a.blocked.none=!1):0d;u=0<=d?++b:--b)u=p.vertices[u],p2.vec2.rotate(r,u,q),t.push([(r[0]+n[0])*this.ppu,-(r[1]+n[1])*this.ppu]);this.drawConvex(f,t,p.triangles,16711680,g,h,this.settings.debugPolygons,[n[0]* this.ppu,-n[1]*this.ppu])}a++}}},drawRectangle:function(a,b,d,c,f,g,h,l,p){void 0===p&&(p=1);void 0===h&&(h=0);a.lineStyle(p,h,1);a.beginFill(l);a.drawRect(b-f/2,d-g/2,f,g)},drawCircle:function(a,b,d,c,f,g,h){void 0===h&&(h=1);void 0===g&&(g=16777215);a.lineStyle(h,0,1);a.beginFill(g,1);a.drawCircle(b,d,2*-f);a.endFill();a.moveTo(b,d);a.lineTo(b+f*Math.cos(-c),d+f*Math.sin(-c))},drawLine:function(a,b,d,c){void 0===c&&(c=1);void 0===d&&(d=0);a.lineStyle(5*c,d,1);a.moveTo(-b/2,0);a.lineTo(b/2,0)},drawConvex:function(a, b,d,c,f,g,h,l){void 0===g&&(g=1);void 0===c&&(c=0);if(h){c=[16711680,65280,255];for(d=0;d!==b.length+1;){var e=b[d%b.length];h=b[(d+1)%b.length];f=e[0];var k=e[1];e=h[0];h=h[1];a.lineStyle(g,c[d%c.length],1);a.moveTo(f,-k);a.lineTo(e,-h);a.drawCircle(f,-k,2*g);d++}a.lineStyle(g,0,1);return a.drawCircle(l[0],l[1],2*g)}a.lineStyle(g,c,1);a.beginFill(f);for(d=0;d!==b.length;)l=b[d],g=l[0],l=l[1],0===d?a.moveTo(g,-l):a.lineTo(g,-l),d++;a.endFill();if(2=d)d=32;if(void 0===c||0>=c)c=32;void 0===f&&(f=0);void 0===g&&(g=0);this.name=a;this.firstgid=b|0;this.imageWidth=d|0;this.imageHeight=c|0;this.imageMargin=f|0;this.imageSpacing=g|0;this.properties=h||{};this.images=[];this.total=0};c.ImageCollection.prototype={containsImageIndex:function(a){return a>=this.firstgid&&athis.right||b>this.bottom)},intersects:function(a,b,d,c){return d<=this.worldX||c<=this.worldY||a>=this.worldX+this.width||b>=this.worldY+this.height?!1:!0},setCollisionCallback:function(a,b){this.collisionCallback=a;this.collisionCallbackContext=b},destroy:function(){this.properties=this.collisionCallbackContext=this.collisionCallback=null},setCollision:function(a,b,d,c){this.collideLeft=a;this.collideRight=b;this.collideUp=d;this.collideDown= c;this.faceLeft=a;this.faceRight=b;this.faceTop=d;this.faceBottom=c},resetCollision:function(){this.faceRight=this.faceLeft=this.faceBottom=this.faceTop=this.collideDown=this.collideUp=this.collideRight=this.collideLeft=!1},isInteresting:function(a,b){return a&&b?this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.faceTop||this.faceBottom||this.faceLeft||this.faceRight||this.collisionCallback:a?this.collideLeft||this.collideRight||this.collideUp||this.collideDown:b?this.faceTop|| this.faceBottom||this.faceLeft||this.faceRight:!1},copy:function(a){this.index=a.index;this.alpha=a.alpha;this.properties=a.properties;this.collideUp=a.collideUp;this.collideDown=a.collideDown;this.collideLeft=a.collideLeft;this.collideRight=a.collideRight;this.collisionCallback=a.collisionCallback;this.collisionCallbackContext=a.collisionCallbackContext}};c.Tile.prototype.constructor=c.Tile;Object.defineProperty(c.Tile.prototype,"collides",{get:function(){return this.collideLeft||this.collideRight|| this.collideUp||this.collideDown}});Object.defineProperty(c.Tile.prototype,"canCollide",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}});Object.defineProperty(c.Tile.prototype,"left",{get:function(){return this.worldX}});Object.defineProperty(c.Tile.prototype,"right",{get:function(){return this.worldX+this.width}});Object.defineProperty(c.Tile.prototype,"top",{get:function(){return this.worldY}});Object.defineProperty(c.Tile.prototype, "bottom",{get:function(){return this.worldY+this.height}});c.Tilemap=function(a,b,d,e,f,g){this.game=a;this.key=b;a=c.TilemapParser.parse(this.game,b,d,e,f,g);null!==a&&(this.width=a.width,this.height=a.height,this.tileWidth=a.tileWidth,this.tileHeight=a.tileHeight,this.orientation=a.orientation,this.format=a.format,this.version=a.version,this.properties=a.properties,this.widthInPixels=a.widthInPixels,this.heightInPixels=a.heightInPixels,this.layers=a.layers,this.tilesets=a.tilesets,this.imagecollections= a.imagecollections,this.tiles=a.tiles,this.objects=a.objects,this.collideIndexes=[],this.collision=a.collision,this.images=a.images,this.enableDebug=!1,this.currentLayer=0,this.debugMap=[],this._results=[],this._tempB=this._tempA=0)};c.Tilemap.CSV=0;c.Tilemap.TILED_JSON=1;c.Tilemap.NORTH=0;c.Tilemap.EAST=1;c.Tilemap.SOUTH=2;c.Tilemap.WEST=3;c.Tilemap.prototype={create:function(a,b,d,c,f,g){void 0===g&&(g=this.game.world);this.width=b;this.height=d;this.setTileSize(c,f);this.layers.length=0;return this.createBlankLayer(a, b,d,c,f,g)},setTileSize:function(a,b){this.tileWidth=a;this.tileHeight=b;this.widthInPixels=this.width*a;this.heightInPixels=this.height*b},addTilesetImage:function(a,b,d,e,f,g,h){if(void 0===a)return null;void 0===d&&(d=this.tileWidth);void 0===e&&(e=this.tileHeight);void 0===f&&(f=0);void 0===g&&(g=0);void 0===h&&(h=0);0===d&&(d=32);0===e&&(e=32);if(void 0===b||null===b)b=a;if(b instanceof c.BitmapData)b=b.canvas;else{if(!this.game.cache.checkImageKey(b))return console.warn('Phaser.Tilemap.addTilesetImage: Invalid image key given: "'+ b+'"'),null;b=this.game.cache.getImage(b)}var k=this.getTilesetIndex(a);if(null===k&&this.format===c.Tilemap.TILED_JSON)return console.warn('Phaser.Tilemap.addTilesetImage: No data found in the JSON matching the tileset name: "'+a+'"'),console.log("Tilesets: ",this.tilesets),null;if(this.tilesets[k])return this.tilesets[k].setImage(b),this.tilesets[k];a=new c.Tileset(a,h,d,e,f,g,{});a.setImage(b);this.tilesets.push(a);b=this.tilesets.length-1;for(var l=k=f,n=0,q=0,t=0,r=h;rthis._results.length)return 0;for(var p=0,n,q=1,t=this._results.length;qthis.layers.length)console.warn('Tilemap.createLayer: Invalid layer ID given: "'+ a+'"'),console.log("Layers: ",this.layers);else return void 0===b||0>=b?b=Math.min(this.game.width,this.layers[f].widthInPixels):b>this.game.width&&(b=this.game.width),void 0===d||0>=d?d=Math.min(this.game.height,this.layers[f].heightInPixels):d>this.game.height&&(d=this.game.height),this.enableDebug&&(console.group("Tilemap.createLayer"),console.log("Name:",this.layers[f].name),console.log("Size:",b,"x",d),console.log("Tileset:",this.tilesets[0].name,"index:",f)),a=e.add(new c.TilemapLayer(this.game, this,f,b,d)),this.enableDebug&&console.groupEnd(),a},createBlankLayer:function(a,b,d,e,f,g){void 0===g&&(g=this.game.world);if(null!==this.getLayerIndex(a))console.warn("Tilemap.createBlankLayer: Layer with matching name already exists: "+a);else{for(var h={name:a,x:0,y:0,width:b,height:d,widthInPixels:b*e,heightInPixels:d*f,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:null},l,p=[],n=0;nthis.game.width&&(b=this.game.width);h>this.game.height&&(h=this.game.height);p=new c.TilemapLayer(this.game,this,this.layers.length-1,b,h);p.name=a;return g.add(p)}},getIndex:function(a,b){for(var d=0;dthis._results.length))for(a=1;ab)){for(;a<=b;a++)this.setCollisionByIndex(a,d,c,!1);f&&this.calculateFaces(c)}},setCollisionByExclusion:function(a,b,d,c){void 0=== b&&(b=!0);void 0===c&&(c=!0);d=this.getLayer(d);for(var e=0,g=this.tiles.length;ea&&(a=0);0>b&&(b=0);d>this.layers[f].width&&(d=this.layers[f].width);c>this.layers[f].height&&(c=this.layers[f].height);this._results.length=0;this._results.push({x:a,y:b,width:d,height:c,layer:f});for(var e=b;e d.length)){a-=d[1].x;b-=d[1].y;for(var e=1;ethis._results.length||(this._tempA=a,this._tempB=b,this._results.forEach(this.swapHandler,this),this.paste(d,c,this._results,h))},swapHandler:function(a){a.index===this._tempA?a.index=this._tempB:a.index===this._tempB&&(a.index=this._tempA)},forEach:function(a,b,d,c,f,g,h){h= this.getLayer(h);this.copy(d,c,f,g,h);2>this._results.length||(this._results.forEach(a,b),this.paste(d,c,this._results,h))},replace:function(a,b,d,c,f,g,h){h=this.getLayer(h);this.copy(d,c,f,g,h);if(!(2>this._results.length)){for(f=1;fthis._results.length)){d=[];for(c=1;cthis._results.length)){d=[];for(e=1;ethis._results.length)){for(c=1;ca)for(;b.lengthb&&(h=-b,p=0);0>d&&(l=-d,n=0);if(b=this.renderSettings.copyCanvas){if(b.width=l&&(x-=l);var w=this.layer.data[x];var y=u;var A=f-d;for(b=a;0<=A;y++,A--,b+=n){y>=h&&(y-=h);var z=w[y];if(z&&!(0>z.index)){var C=z.index,B=t[C];void 0===B&&(B=this.resolveTileset(C));z.alpha===r||this.debug||(r=e.globalAlpha=z.alpha);B?z.rotation||z.flipped?(e.save(),e.translate(b+z.centerX,c+z.centerY),e.rotate(z.rotation),z.flipped&&e.scale(-1,1),B.draw(e,-z.centerX,-z.centerY,C),e.restore()):B.draw(e,b,c,C):this.debugSettings.missingImageFill&& (e.fillStyle=this.debugSettings.missingImageFill,e.fillRect(b,c,n,q));z.debug&&this.debugSettings.debuggedTileOverfill&&(e.fillStyle=this.debugSettings.debuggedTileOverfill,e.fillRect(b,c,n,q))}}}};c.TilemapLayer.prototype.renderDeltaScroll=function(a,b){var d=this._mc.scrollX,c=this._mc.scrollY,f=this.canvas.width,g=this.canvas.height,h=this._mc.tileWidth,l=this._mc.tileHeight,p=0,n=-h,q=0,t=-l;0>a?(p=f+a,n=f-1):0b?(q=g+b,t=g-1):0=f&&(r-=f);var u=this.layer.data[r];var x=t;var w=p-l;for(b=a;0<=w;x++,w--,b+=g){x>=c&&(x-=c);var y=u[x];!y||0>y.index||!y.collides|| (this.debugSettings.collidingTileOverfill&&(d.fillStyle=this.debugSettings.collidingTileOverfill,d.fillRect(b,n,this._mc.cw,this._mc.ch)),this.debugSettings.facingEdgeStroke&&(d.beginPath(),y.faceTop&&(d.moveTo(b,n),d.lineTo(b+this._mc.cw,n)),y.faceBottom&&(d.moveTo(b,n+this._mc.ch),d.lineTo(b+this._mc.cw,n+this._mc.ch)),y.faceLeft&&(d.moveTo(b,n),d.lineTo(b,n+this._mc.ch)),y.faceRight&&(d.moveTo(b+this._mc.cw,n),d.lineTo(b+this._mc.cw,n+this._mc.ch)),d.closePath(),d.stroke()))}}};Object.defineProperty(c.TilemapLayer.prototype, "wrap",{get:function(){return this._wrap},set:function(a){this._wrap=a;this.dirty=!0}});Object.defineProperty(c.TilemapLayer.prototype,"scrollX",{get:function(){return this._scrollX},set:function(a){this._scrollX=a}});Object.defineProperty(c.TilemapLayer.prototype,"scrollY",{get:function(){return this._scrollY},set:function(a){this._scrollY=a}});Object.defineProperty(c.TilemapLayer.prototype,"collisionWidth",{get:function(){return this._mc.cw},set:function(a){this._mc.cw=a|0;this.dirty=!0}});Object.defineProperty(c.TilemapLayer.prototype, "collisionHeight",{get:function(){return this._mc.ch},set:function(a){this._mc.ch=a|0;this.dirty=!0}});c.TilemapParser={INSERT_NULL:!1,parse:function(a,b,d,e,f,g){void 0===d&&(d=32);void 0===e&&(e=32);void 0===f&&(f=10);void 0===g&&(g=10);if(void 0===b)return this.getEmptyData();if(null===b)return this.getEmptyData(d,e,f,g);if(a=a.cache.getTilemapData(b)){if(a.format===c.Tilemap.CSV)return this.parseCSV(b,a.data,d,e);if(!a.format||a.format===c.Tilemap.TILED_JSON)return this.parseTiledJSON(a.data)}else console.warn("Phaser.TilemapParser.parse - No map data found for key "+ b)},parseCSV:function(a,b,d,e){var f=this.getEmptyData();b=b.trim();var g=[];b=b.split("\n");for(var h=b.length,l=0,p=0;p>>0;f.data=l;delete f.encoding}else if(f.compression){console.warn("TilemapParser.parseTiledJSON - Layer compression is unsupported, skipping layer '"+f.name+"'");continue}g={name:f.name,x:f.x,y:f.y,width:f.width,height:f.height,widthInPixels:f.width*a.tilewidth,heightInPixels:f.height*a.tileheight,alpha:f.opacity,offsetX:f.offsetx,offsetY:f.offsety,visible:f.visible,properties:{},indexes:[],callbacks:[],bodies:[]};f.properties&&(g.properties=f.properties); p=0;l=[];var n=[],q=0;for(h=f.data.length;qu.index||(f=b.tiles[u.index][2],f=b.tilesets[f],f.tileProperties&&f.tileProperties[u.index-f.firstgid]&&(u.properties=c.Utils.mixin(f.tileProperties[u.index-f.firstgid],u.properties)),(q=d[u.index])&&this.parseObjectGroup(q, b.objects,b.collision,u.layer.name,{x:u.worldX+q.x,y:u.worldY+q.y}));return b}};c.Tileset=function(a,b,c,e,f,g,h){if(void 0===c||0>=c)c=32;if(void 0===e||0>=e)e=32;void 0===f&&(f=0);void 0===g&&(g=0);this.name=a;this.firstgid=b|0;this.tileWidth=c|0;this.tileHeight=e|0;this.tileMargin=f|0;this.tileSpacing=g|0;this.properties=h||{};this.image=null;this.total=this.columns=this.rows=0;this.drawCoords=[]};c.Tileset.prototype={draw:function(a,b,c,e){e=e-this.firstgid<<1;0<=e&&e+1=this.firstgid&&a=this._timer)if(this._timer=this.game.time.time+this.frequency*this.game.time.slowMotion,0!==this._flowTotal)if(0=this._flowTotal)){this.on=!1;break}}else this.emitParticle()&&(this._counter++,-1!==this._flowTotal&&this._counter>=this._flowTotal&&(this.on=!1));else this.emitParticle()&&(this._counter++,0=this._total&&(this.on=!1));for(a=this.children.length;a--;)this.children[a].exists&&this.children[a].update()};c.Particles.Arcade.Emitter.prototype.makeParticles=function(a,b,c,e,f,g){void 0===b&&(b=0);void 0===c&&(c=this.maxParticles);void 0===e&&(e=!1);void 0===f&&(f=!1);void 0===g&&(g=null);var d=0,h=a,l=b;this._frames=b;c>this.maxParticles&&(this.maxParticles=c);for(;dthis.maxParticles&&(c=this.maxParticles);this._counter=0;this._flowQuantity=c;this._flowTotal=e;f?(this.start(!0,a,b,c),this._counter+=c,this.on=!0,this._timer=this.game.time.time+b*this.game.time.slowMotion):this.start(!1,a,b,c);return this};c.Particles.Arcade.Emitter.prototype.start=function(a, b,c,e,f){void 0===a&&(a=!0);void 0===b&&(b=0);if(void 0===c||null===c)c=250;void 0===e&&(e=0);void 0===f&&(f=!1);e>this.maxParticles&&(e=this.maxParticles);this.revive();this.visible=!0;this.lifespan=b;this.frequency=c;if(a||f)for(a=0;a=this.bulletFrames.length&&(this.bulletFrameIndex=0)):this.bulletFrameRandom&&(b.frame=this.bulletFrames[Math.floor(Math.random()*this.bulletFrames.length)]),b.data.bodyDirty&&(this._data.customBody&&b.body.setSize(this._data.width,this._data.height,this._data.offsetX,this._data.offsetY),b.body.collideWorldBounds= this.bulletCollideWorldBounds,b.data.bodyDirty=!1),b.body.velocity.set(d,h),b.body.gravity.set(this.bulletGravity.x,this.bulletGravity.y),0!==this.bulletSpeedVariance?(d=this.fireRate,d+=c.Math.between(-this.fireRateVariance,this.fireRateVariance),0>d&&(d=0),d=this.game.time.now+d):d=this.game.time.now+this.fireRate,this.multiFire?this._hasFired||(this._hasFired=!0,this._tempNextFire=d,this.shots++):(this._nextFire=d,this.shots++),this.onFire.dispatch(b,this,g),0c.Weapon.KILL_LIFESPAN&& (this.data.killType===c.Weapon.KILL_DISTANCE?this.game.physics.arcade.distanceToXY(this,this.data.fromX,this.data.fromY,!0)>this.data.killDistance&&this.kill():this.data.bulletManager.bulletBounds.intersects(this)||this.kill()),this.data.rotateToVelocity&&(this.rotation=this.body.velocity.atan()),this.data.bulletManager.bulletWorldWrap&&this.game.world.wrap(this,this.data.bulletManager.bulletWorldWrapPadding))};c.Video=function(a,b,d){void 0===b&&(b=null);void 0===d&&(d=null);this.game=a;this.key= b;this.height=this.width=0;this.type=c.VIDEO;this.touchLocked=this.disableTextureUpload=!1;this.onPlay=new c.Signal;this.onChangeSource=new c.Signal;this.onComplete=new c.Signal;this.onAccess=new c.Signal;this.onError=new c.Signal;this.onTimeout=new c.Signal;this.onTouchUnlock=new c.Signal;this.playWhenUnlocked=!0;this.timeout=15E3;this.videoStream=this.video=this._timeOutID=null;this.isStreaming=!1;this.retryLimit=20;this.retry=0;this.retryInterval=500;this._retryID=null;this._autoplay=this._pendingChangeSource= this._pending=this._paused=this._codePaused=this._muted=this._codeMuted=!1;this._playCallback=this._endCallback=null;if(b&&this.game.cache.checkVideoKey(b)){var e=this.game.cache.getVideo(b);e.isBlob?this.createVideoFromBlob(e.data):this.video=e.data;this.width=this.video.videoWidth;this.height=this.video.videoHeight}else d&&this.createVideoFromURL(d,!1);this.baseTexture=this.video&&!d?new PIXI.BaseTexture(this.video,null,this.game.resolution):new PIXI.BaseTexture(c.Cache.DEFAULT.baseTexture.source, null,this.game.resolution);this.baseTexture.forceLoaded(this.width,this.height);this.texture=new PIXI.Texture(this.baseTexture);this.textureFrame=new c.Frame(0,0,0,this.width,this.height,"video");this.texture.setFrame(this.textureFrame);this.texture.valid=!1;null!==b&&this.video&&(this.texture.valid=this.video.canplay);this.snapshot=null;c.BitmapData&&(this.snapshot=new c.BitmapData(this.game,"",this.width,this.height));this.game.device.needsTouchUnlock()?this.setTouchLock():e&&(e.locked=!1)};c.Video.prototype= {connectToMediaStream:function(a,b){a&&b&&(this.video=a,this.videoStream=b,this.isStreaming=!0,this.baseTexture.source=this.video,this.updateTexture(null,this.video.videoWidth,this.video.videoHeight),this.onAccess.dispatch(this));return this},startMediaStream:function(a,b,c){void 0===a&&(a=!1);void 0===b&&(b=null);void 0===c&&(c=null);if(!this.game.device.getUserMedia)return this.onError.dispatch(this,"No getUserMedia"),!1;null!==this.videoStream&&(this.videoStream.active?this.videoStream.active= !1:this.videoStream.stop());this.removeVideoElement();this.video=document.createElement("video");this.video.setAttribute("autoplay","autoplay");null!==b&&(this.video.width=b);null!==c&&(this.video.height=c);this._timeOutID=window.setTimeout(this.getUserMediaTimeout.bind(this),this.timeout);try{navigator.getUserMedia({audio:a,video:!0},this.getUserMediaSuccess.bind(this),this.getUserMediaError.bind(this))}catch(e){this.getUserMediaError(e)}return this},getUserMediaTimeout:function(){clearTimeout(this._timeOutID); this.onTimeout.dispatch(this)},getUserMediaError:function(a){clearTimeout(this._timeOutID);this.onError.dispatch(this,a)},getUserMediaSuccess:function(a){clearTimeout(this._timeOutID);this.videoStream=a;void 0!==this.video.mozSrcObject?this.video.mozSrcObject=a:this.video.src=window.URL&&window.URL.createObjectURL(a)||a;var b=this;this.video.onloadeddata=function(){function a(){if(0a?a=0:1