From 3d44afa9f6f17a32f250f4283a486480f75e5908 Mon Sep 17 00:00:00 2001 From: jsfehler Date: Thu, 25 Jan 2024 14:07:11 -0500 Subject: [PATCH] chore: Update phaser-ce version (#276) --- docs/examples/lib/phaser.min.js | 4 ++-- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/examples/lib/phaser.min.js b/docs/examples/lib/phaser.min.js index c4c21d3..ac6dc73 100644 --- a/docs/examples/lib/phaser.min.js +++ b/docs/examples/lib/phaser.min.js @@ -1,4 +1,4 @@ -/* Phaser v2.13.3 - http://phaser.io - @photonstorm - (c) 2016 Photon Storm Ltd. */ +/* Phaser v2.20.0 - http://phaser.io - @photonstorm - (c) 2016 Photon Storm Ltd. */ -!function(t){if("object"==typeof exports)module.exports=t();else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.p2=t()}}(function(){return function t(e,i,s){function n(o,a){if(!i[o]){if(!e[o]){var h="function"==typeof require&&require;if(!a&&h)return h(o,!0);if(r)return r(o,!0);throw new Error("Cannot find module '"+o+"'")}var l=i[o]={exports:{}};e[o][0].call(l.exports,function(t){var i=e[o][1][t];return n(i||t)},l,l.exports,t,e,i,s)}return i[o].exports}for(var r="function"==typeof require&&require,o=0;o=0&&h<=1&&l>=0&&l<=1}},{"./Scalar":4}],2:[function(t,e,i){function s(){}e.exports=s,s.area=function(t,e,i){return(e[0]-t[0])*(i[1]-t[1])-(i[0]-t[0])*(e[1]-t[1])},s.left=function(t,e,i){return s.area(t,e,i)>0},s.leftOn=function(t,e,i){return s.area(t,e,i)>=0},s.right=function(t,e,i){return s.area(t,e,i)<0},s.rightOn=function(t,e,i){return s.area(t,e,i)<=0};var n=[],r=[];s.collinear=function(t,e,i,o){if(o){var a=n,h=r;a[0]=e[0]-t[0],a[1]=e[1]-t[1],h[0]=i[0]-e[0],h[1]=i[1]-e[1];var l=a[0]*h[0]+a[1]*h[1],c=Math.sqrt(a[0]*a[0]+a[1]*a[1]),u=Math.sqrt(h[0]*h[0]+h[1]*h[1]);return Math.acos(l/(c*u))t.vertices.length)throw new Error("lol2");if(e<0)throw new Error("lol3");for(var s=e;se[t][0])&&(t=i);o.left(this.at(t-1),this.at(t),this.at(t+1))||this.reverse()},s.prototype.reverse=function(){for(var t=[],e=0,i=this.vertices.length;e!==i;e++)t.push(this.vertices.pop());this.vertices=t},s.prototype.isReflex=function(t){return o.right(this.at(t-1),this.at(t),this.at(t+1))};var h=[],l=[];s.prototype.canSee=function(t,e){var i,s,n=h,a=l;if(o.leftOn(this.at(t+1),this.at(t),this.at(e))&&o.rightOn(this.at(t-1),this.at(t),this.at(e)))return!1;s=o.sqdist(this.at(t),this.at(e));for(var c=0;c!==this.vertices.length;++c)if((c+1)%this.vertices.length!==t&&c!==t&&o.leftOn(this.at(t),this.at(e),this.at(c+1))&&o.rightOn(this.at(t),this.at(e),this.at(c))&&(n[0]=this.at(t),n[1]=this.at(e),a[0]=this.at(c),a[1]=this.at(c+1),i=r.lineInt(n,a),o.sqdist(this.at(t),i)0?this.slice(t):[this]},s.prototype.slice=function(t){if(0==t.length)return[this];if(t instanceof Array&&t.length&&t[0]instanceof Array&&2==t[0].length&&t[0][0]instanceof Array){for(var e=[this],i=0;ia)return console.warn("quickDecomp: max level ("+a+") reached."),t;for(var T=0;Tm&&(m+=this.vertices.length),g=Number.MAX_VALUE,m3&&i>=0;--i)o.collinear(this.at(i-1),this.at(i),this.at(i+1),t)&&(this.vertices.splice(i%this.vertices.length,1),i--,e++);return e}},{"./Line":1,"./Point":2,"./Scalar":4}],4:[function(t,e,i){function s(){}e.exports=s,s.eq=function(t,e,i){return i=i||0,Math.abs(t-e) (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(t,e,i){function s(t){this.lowerBound=n.create(),t&&t.lowerBound&&n.copy(this.lowerBound,t.lowerBound),this.upperBound=n.create(),t&&t.upperBound&&n.copy(this.upperBound,t.upperBound)}var n=t("../math/vec2");t("../utils/Utils");e.exports=s;var r=n.create();s.prototype.setFromPoints=function(t,e,i,s){var o=this.lowerBound,a=this.upperBound;"number"!=typeof i&&(i=0),0!==i?n.rotate(o,t[0],i):n.copy(o,t[0]),n.copy(a,o);for(var h=Math.cos(i),l=Math.sin(i),c=1;ca[f]&&(a[f]=u[f]),u[f]i&&(this.lowerBound[e]=i);var s=t.upperBound[e];this.upperBound[e]h?-1:a}},{"../math/vec2":30,"../utils/Utils":57}],8:[function(t,e,i){function s(t){this.type=t,this.result=[],this.world=null,this.boundingVolumeType=s.AABB}var n=t("../math/vec2"),r=t("../objects/Body");e.exports=s,s.AABB=1,s.BOUNDING_CIRCLE=2,s.prototype.setWorld=function(t){this.world=t},s.prototype.getCollisionPairs=function(t){};var o=n.create();s.boundingRadiusCheck=function(t,e){n.sub(o,t.position,e.position);var i=n.squaredLength(o),s=t.boundingRadius+e.boundingRadius;return i<=s*s},s.aabbCheck=function(t,e){return t.getAABB().overlaps(e.getAABB())},s.prototype.boundingVolumeCheck=function(t,e){var i;switch(this.boundingVolumeType){case s.BOUNDING_CIRCLE:i=s.boundingRadiusCheck(t,e);break;case s.AABB:i=s.aabbCheck(t,e);break;default:throw new Error("Bounding volume type not recognized: "+this.boundingVolumeType)}return i},s.canCollide=function(t,e){var i=r.KINEMATIC,s=r.STATIC;return(t.type!==s||e.type!==s)&&(!(t.type===i&&e.type===s||t.type===s&&e.type===i)&&((t.type!==i||e.type!==i)&&((t.sleepState!==r.SLEEPING||e.sleepState!==r.SLEEPING)&&!(t.sleepState===r.SLEEPING&&e.type===s||e.sleepState===r.SLEEPING&&t.type===s))))},s.NAIVE=1,s.SAP=2},{"../math/vec2":30,"../objects/Body":31}],9:[function(t,e,i){function s(){n.call(this,n.NAIVE)}t("../shapes/Circle"),t("../shapes/Plane"),t("../shapes/Shape"),t("../shapes/Particle");var n=t("../collision/Broadphase");t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.getCollisionPairs=function(t){var e=t.bodies,i=this.result;i.length=0;for(var s=0,r=e.length;s!==r;s++)for(var o=e[s],a=0;az&&Y0)for(G=0;GMath.pow(g,2))return 0;if(u)return!0;var m=this.createContactEquation(t,n,e,r);return a(m.normalA,l,i),o.normalize(m.normalA,m.normalA),o.scale(m.contactPointA,m.normalA,d),o.scale(m.contactPointB,m.normalA,-p),h(m.contactPointA,m.contactPointA,i),a(m.contactPointA,m.contactPointA,t.position),h(m.contactPointB,m.contactPointB,l),a(m.contactPointB,m.contactPointB,n.position),this.contactEquations.push(m),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(m)),1},s.prototype[m.PLANE|m.CONVEX]=s.prototype[m.PLANE|m.BOX]=s.prototype.planeConvex=function(t,e,i,s,n,r,c,u,d){var p=x,f=b,g=_,m=0;o.rotate(f,v,s);for(var y=0;y!==r.vertices.length;y++){var w=r.vertices[y];if(o.rotate(p,w,u),h(p,p,c),a(g,p,i),l(g,f)<=0){if(d)return!0;m++;var T=this.createContactEquation(t,n,e,r);a(g,p,i),o.copy(T.normalA,f);var P=l(g,T.normalA);o.scale(g,T.normalA,P),a(T.contactPointB,p,n.position),a(T.contactPointA,p,g),a(T.contactPointA,T.contactPointA,t.position),this.contactEquations.push(T),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(T))}}return this.enableFrictionReduction&&this.enableFriction&&m&&this.frictionEquations.push(this.createFrictionFromAverage(m)),m},s.prototype[m.PARTICLE|m.PLANE]=s.prototype.particlePlane=function(t,e,i,s,n,r,h,c,u){var d=x,p=b;c=c||0,a(d,i,h),o.rotate(p,v,c);var f=l(d,p);if(f>0)return 0;if(u)return!0;var g=this.createContactEquation(n,t,r,e);return o.copy(g.normalA,p),o.scale(d,g.normalA,f),a(g.contactPointA,i,d),a(g.contactPointA,g.contactPointA,n.position),a(g.contactPointB,i,t.position),this.contactEquations.push(g),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(g)),1},s.prototype[m.CIRCLE|m.PARTICLE]=s.prototype.circleParticle=function(t,e,i,s,n,r,l,c,u){var d=x;if(a(d,l,i),o.squaredLength(d)>Math.pow(e.radius,2))return 0;if(u)return!0;var p=this.createContactEquation(t,n,e,r);return o.copy(p.normalA,d),o.normalize(p.normalA,p.normalA),o.scale(p.contactPointA,p.normalA,e.radius),h(p.contactPointA,p.contactPointA,i),a(p.contactPointA,p.contactPointA,t.position),a(p.contactPointB,l,n.position),this.contactEquations.push(p),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(p)),1};var K=new f({radius:1}),J=o.create(),Q=o.create();o.create();s.prototype[m.PLANE|m.CAPSULE]=s.prototype.planeCapsule=function(t,e,i,s,n,r,a,l,c){var u=J,d=Q,p=K;o.set(u,-r.length/2,0),o.rotate(u,u,l),h(u,u,a),o.set(d,r.length/2,0),o.rotate(d,d,l),h(d,d,a),p.radius=r.radius;var f;this.enableFrictionReduction&&(f=this.enableFriction,this.enableFriction=!1);var g=this.circlePlane(n,p,u,0,t,e,i,s,c),m=this.circlePlane(n,p,d,0,t,e,i,s,c);if(this.enableFrictionReduction&&(this.enableFriction=f),c)return g||m;var y=g+m;return this.enableFrictionReduction&&y&&this.frictionEquations.push(this.createFrictionFromAverage(y)),y},s.prototype[m.CIRCLE|m.PLANE]=s.prototype.circlePlane=function(t,e,i,s,n,r,c,u,d){var p=t,f=e,g=i,m=n,y=c,w=u;w=w||0;var T=x,P=b,C=_;a(T,g,y),o.rotate(P,v,w);var S=l(P,T);if(S>f.radius)return 0;if(d)return!0;var A=this.createContactEquation(m,p,r,e);return o.copy(A.normalA,P),o.scale(A.contactPointB,A.normalA,-f.radius),h(A.contactPointB,A.contactPointB,g),a(A.contactPointB,A.contactPointB,p.position),o.scale(C,A.normalA,S),a(A.contactPointA,T,C),h(A.contactPointA,A.contactPointA,y),a(A.contactPointA,A.contactPointA,m.position),this.contactEquations.push(A),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(A)),1},s.prototype[m.CONVEX]=s.prototype[m.CONVEX|m.BOX]=s.prototype[m.BOX]=s.prototype.convexConvex=function(t,e,i,n,r,c,u,d,p,f){var g=x,m=b,y=_,v=w,P=T,E=C,M=S,R=A,L=0,f="number"==typeof f?f:0;if(!s.findSeparatingAxis(e,i,n,c,u,d,g))return 0;a(M,u,i),l(g,M)>0&&o.scale(g,g,-1);var B=s.getClosestEdge(e,n,g,!0),I=s.getClosestEdge(c,d,g);if(-1===B||-1===I)return 0;for(var O=0;O<2;O++){var k=B,F=I,D=e,U=c,G=i,N=u,X=n,W=d,j=t,V=r;if(0===O){var H;H=k,k=F,F=H,H=D,D=U,U=H,H=G,G=N,N=H,H=X,X=W,W=H,H=j,j=V,V=H}for(var q=F;q=3){if(p)return!0;var Z=this.createContactEquation(j,V,D,U);L++;var J=D.vertices[k%D.vertices.length],Q=D.vertices[(k+1)%D.vertices.length];o.rotate(y,J,X),o.rotate(v,Q,X),h(y,y,G),h(v,v,G),a(P,v,y),o.rotate90cw(Z.normalA,P),o.normalize(Z.normalA,Z.normalA),a(M,m,y);var $=l(Z.normalA,M);o.scale(E,Z.normalA,$),a(Z.contactPointA,m,G),a(Z.contactPointA,Z.contactPointA,E),h(Z.contactPointA,Z.contactPointA,G),a(Z.contactPointA,Z.contactPointA,j.position),a(Z.contactPointB,m,N),h(Z.contactPointB,Z.contactPointB,N),a(Z.contactPointB,Z.contactPointB,V.position),this.contactEquations.push(Z),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(Z))}}}return this.enableFrictionReduction&&this.enableFriction&&L&&this.frictionEquations.push(this.createFrictionFromAverage(L)),L};var Z=o.fromValues(0,0);s.projectConvexOntoAxis=function(t,e,i,s,n){var r,a,h=null,c=null,u=Z;o.rotate(u,s,-i);for(var d=0;dh)&&(h=a),(null===c||ah){var p=c;c=h,h=p}var f=l(e,s);o.set(n,c+f,h+f)};var $=o.fromValues(0,0),tt=o.fromValues(0,0),et=o.fromValues(0,0),it=o.fromValues(0,0),st=o.fromValues(0,0),nt=o.fromValues(0,0);s.findSeparatingAxis=function(t,e,i,n,r,h,l){var c=null,u=!1,d=!1,p=$,f=tt,g=et,m=it,v=st,x=nt;if(t instanceof y&&n instanceof y)for(P=0;2!==P;P++){var b=t,_=i;1===P&&(b=n,_=h);for(C=0;2!==C;C++){0===C?o.set(m,0,1):1===C&&o.set(m,1,0),0!==_&&o.rotate(m,m,_),s.projectConvexOntoAxis(t,e,i,m,v),s.projectConvexOntoAxis(n,r,h,m,x);var w=v,T=x;v[0]>x[0]&&(T=v,w=x,!0),u=(S=T[0]-w[1])<=0,(null===c||S>c)&&(o.copy(l,m),c=S,d=u)}}else for(var P=0;2!==P;P++){var b=t,_=i;1===P&&(b=n,_=h);for(var C=0;C!==b.vertices.length;C++){o.rotate(f,b.vertices[C],_),o.rotate(g,b.vertices[(C+1)%b.vertices.length],_),a(p,g,f),o.rotate90cw(m,p),o.normalize(m,m),s.projectConvexOntoAxis(t,e,i,m,v),s.projectConvexOntoAxis(n,r,h,m,x);var w=v,T=x;v[0]>x[0]&&(T=v,w=x,!0);var S=T[0]-w[1];u=S<=0,(null===c||S>c)&&(o.copy(l,m),c=S,d=u)}}return d};var rt=o.fromValues(0,0),ot=o.fromValues(0,0),at=o.fromValues(0,0);s.getClosestEdge=function(t,e,i,s){var n=rt,r=ot,h=at;o.rotate(n,i,-e),s&&o.scale(n,n,-1);for(var c=-1,u=t.vertices.length,d=-1,p=0;p!==u;p++){a(r,t.vertices[(p+1)%u],t.vertices[p%u]),o.rotate90cw(h,r),o.normalize(h,h);var f=l(h,n);(-1===c||f>d)&&(c=p%u,d=f)}return c};var ht=o.create(),lt=o.create(),ct=o.create(),ut=o.create(),dt=o.create(),pt=o.create(),ft=o.create();s.prototype[m.CIRCLE|m.HEIGHTFIELD]=s.prototype.circleHeightfield=function(t,e,i,s,n,r,l,c,u,d){var p=r.heights,d=d||e.radius,f=r.elementWidth,g=lt,m=ht,y=dt,v=ft,x=pt,b=ct,_=ut,w=Math.floor((i[0]-d-l[0])/f),T=Math.ceil((i[0]+d-l[0])/f);w<0&&(w=0),T>=p.length&&(T=p.length-1);for(var P=p[w],C=p[T],S=w;SP&&(P=p[S]);if(i[1]-d>P)return!u&&0;for(var A=!1,S=w;S=b[0]&&m[0]<_[0]&&E<=0){if(u)return!0;A=!0,o.scale(g,x,-E),o.add(y,m,g),o.copy(v,x);M=this.createContactEquation(n,t,r,e);o.copy(M.normalA,v),o.scale(M.contactPointB,M.normalA,-d),h(M.contactPointB,M.contactPointB,i),a(M.contactPointB,M.contactPointB,t.position),o.copy(M.contactPointA,y),o.sub(M.contactPointA,M.contactPointA,n.position),this.contactEquations.push(M),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(M))}}if(A=!1,d>0)for(S=w;S<=T;S++)if(o.set(b,S*f,p[S]),o.add(b,b,l),o.sub(g,i,b),o.squaredLength(g)=c.length&&(y=c.length-1);for(var v=c[m],x=c[y],b=m;bv&&(v=c[b]);if(t.aabb.lowerBound[1]>v)return!l&&0;for(var _=0,b=m;b=0||r.containsPoint(this.from))&&this.intersectBody(t,n)}};var o=r.create();s.prototype.intersectBody=function(t,e){var i=this.checkCollisionResponse;if(!i||e.collisionResponse)for(var s=o,n=0,a=e.shapes.length;ne.boundingRadius*e.boundingRadius||(this._currentBody=r,this._currentShape=e,e.raycast(t,this,s,i),this._currentBody=this._currentShape=null)},s.prototype.getAABB=function(t){var e=this.to,i=this.from;r.set(t.lowerBound,Math.min(e[0],i[0]),Math.min(e[1],i[1])),r.set(t.upperBound,Math.max(e[0],i[0]),Math.max(e[1],i[1]))};r.create();s.prototype.reportIntersection=function(t,e,i,n){this.from,this.to;var o=this._currentShape,a=this._currentBody;if(!(this.skipBackfaces&&r.dot(i,this.direction)>0))switch(this.mode){case s.ALL:t.set(i,o,a,e,n),this.callback(t);break;case s.CLOSEST:(e=0&&!(t[r].aabb.lowerBound[e]<=n.aabb.lowerBound[e]);r--)t[r+1]=t[r];t[r+1]=n}return t},s.prototype.sortList=function(){var t=this.axisList,e=this.axisIndex;s.sortAxisList(t,e)},s.prototype.getCollisionPairs=function(t){var e=this.axisList,i=this.result,s=this.axisIndex;i.length=0;for(var n=e.length;n--;){var o=e[n];o.aabbNeedsUpdate&&o.updateAABB()}this.sortList();for(var a=0,h=0|e.length;a!==h;a++)for(var l=e[a],c=a+1;cthis.upperLimit&&(r.maxForce=0,r.minForce=-this.maxForce,this.distance=this.upperLimit,u=!0),this.lowerLimitEnabled&&this.positioni?(a.scale(n.normalA,l,-1),a.sub(n.contactPointA,c,o.position),a.sub(n.contactPointB,u,h.position),a.scale(f,l,i),a.add(n.contactPointA,n.contactPointA,f),-1===t.indexOf(n)&&t.push(n)):-1!==(b=t.indexOf(n))&&t.splice(b,1),this.lowerLimitEnabled&&va?(f.angle=a,-1===n.indexOf(f)&&n.push(f)):-1!==(y=n.indexOf(f))&&n.splice(y,1),this.lowerLimitEnabled&&m>1;if(e<3)return[];for(var i=[],n=[],r=0;r3;){var a=n[(r+0)%o],h=n[(r+1)%o],l=n[(r+2)%o],c=t[2*a],u=t[2*a+1],d=t[2*h],p=t[2*h+1],f=t[2*l],g=t[2*l+1],m=!1;if(s._convex(c,u,d,p,f,g)){m=!0;for(var y=0;y3*o)break}return i.push(n[0],n[1],n[2]),i},s._PointInTriangle=function(t,e,i,s,n,r,o,a){var h=o-i,l=a-s,c=n-i,u=r-s,d=t-i,p=e-s,f=h*h+l*l,g=h*c+l*u,m=h*d+l*p,y=c*c+u*u,v=c*d+u*p,x=1/(f*y-g*g),b=(y*m-g*v)*x,_=(f*v-g*m)*x;return b>=0&&_>=0&&b+_<1},s._convex=function(t,e,i,s,n,r){return(e-s)*(n-i)+(i-t)*(r-s)>=0},e.exports=s},{}],30:[function(t,e,i){var s=e.exports={},n=t("../utils/Utils");s.crossLength=function(t,e){return t[0]*e[1]-t[1]*e[0]},s.crossVZ=function(t,e,i){return s.rotate(t,e,-Math.PI/2),s.scale(t,t,i),t},s.crossZV=function(t,e,i){return s.rotate(t,i,Math.PI/2),s.scale(t,t,e),t},s.rotate=function(t,e,i){if(0!==i){var s=Math.cos(i),n=Math.sin(i),r=e[0],o=e[1];t[0]=s*r-n*o,t[1]=n*r+s*o}else t[0]=e[0],t[1]=e[1]},s.rotate90cw=function(t,e){var i=e[0],s=e[1];t[0]=s,t[1]=-i},s.toLocalFrame=function(t,e,i,n){s.copy(t,e),s.sub(t,t,i),s.rotate(t,t,-n)},s.toGlobalFrame=function(t,e,i,n){s.copy(t,e),s.rotate(t,t,n),s.add(t,t,i)},s.vectorToLocalFrame=function(t,e,i){s.rotate(t,e,-i)},s.vectorToGlobalFrame=function(t,e,i){s.rotate(t,e,i)},s.centroid=function(t,e,i,n){return s.add(t,e,i),s.add(t,t,n),s.scale(t,t,1/3),t},s.create=function(){var t=new n.ARRAY_TYPE(2);return t[0]=0,t[1]=0,t},s.clone=function(t){var e=new n.ARRAY_TYPE(2);return e[0]=t[0],e[1]=t[1],e},s.fromValues=function(t,e){var i=new n.ARRAY_TYPE(2);return i[0]=t,i[1]=e,i},s.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},s.set=function(t,e,i){return t[0]=e,t[1]=i,t},s.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t},s.subtract=function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t},s.sub=s.subtract,s.multiply=function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t},s.mul=s.multiply,s.divide=function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t},s.div=s.divide,s.scale=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t},s.distance=function(t,e){var i=e[0]-t[0],s=e[1]-t[1];return Math.sqrt(i*i+s*s)},s.dist=s.distance,s.squaredDistance=function(t,e){var i=e[0]-t[0],s=e[1]-t[1];return i*i+s*s},s.sqrDist=s.squaredDistance,s.length=function(t){var e=t[0],i=t[1];return Math.sqrt(e*e+i*i)},s.len=s.length,s.squaredLength=function(t){var e=t[0],i=t[1];return e*e+i*i},s.sqrLen=s.squaredLength,s.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},s.normalize=function(t,e){var i=e[0],s=e[1],n=i*i+s*s;return n>0&&(n=1/Math.sqrt(n),t[0]=e[0]*n,t[1]=e[1]*n),t},s.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},s.str=function(t){return"vec2("+t[0]+", "+t[1]+")"},s.lerp=function(t,e,i,s){var n=e[0],r=e[1];return t[0]=n+s*(i[0]-n),t[1]=r+s*(i[1]-r),t},s.reflect=function(t,e,i){var s=e[0]*i[0]+e[1]*i[1];t[0]=e[0]-2*i[0]*s,t[1]=e[1]-2*i[1]*s},s.getLineSegmentsIntersection=function(t,e,i,n,r){var o=s.getLineSegmentsIntersectionFraction(e,i,n,r);return!(o<0)&&(t[0]=e[0]+o*(i[0]-e[0]),t[1]=e[1]+o*(i[1]-e[1]),!0)},s.getLineSegmentsIntersectionFraction=function(t,e,i,s){var n,r,o=e[0]-t[0],a=e[1]-t[1],h=s[0]-i[0],l=s[1]-i[1];return n=(-a*(t[0]-i[0])+o*(t[1]-i[1]))/(-h*a+o*l),r=(h*(t[1]-i[1])-l*(t[0]-i[0]))/(-h*a+o*l),n>=0&&n<=1&&r>=0&&r<=1?r:-1}},{"../utils/Utils":57}],31:[function(t,e,i){function s(t){t=t||{},c.call(this),this.id=t.id||++s._idCounter,this.world=null,this.shapes=[],this.mass=t.mass||0,this.invMass=0,this.inertia=0,this.invInertia=0,this.invMassSolve=0,this.invInertiaSolve=0,this.fixedRotation=!!t.fixedRotation,this.fixedX=!!t.fixedX,this.fixedY=!!t.fixedY,this.massMultiplier=n.create(),this.position=n.fromValues(0,0),t.position&&n.copy(this.position,t.position),this.interpolatedPosition=n.fromValues(0,0),this.interpolatedAngle=0,this.previousPosition=n.fromValues(0,0),this.previousAngle=0,this.velocity=n.fromValues(0,0),t.velocity&&n.copy(this.velocity,t.velocity),this.vlambda=n.fromValues(0,0),this.wlambda=0,this.angle=t.angle||0,this.angularVelocity=t.angularVelocity||0,this.force=n.create(),t.force&&n.copy(this.force,t.force),this.angularForce=t.angularForce||0,this.damping="number"==typeof t.damping?t.damping:.1,this.angularDamping="number"==typeof t.angularDamping?t.angularDamping:.1,this.type=s.STATIC,void 0!==t.type?this.type=t.type:t.mass?this.type=s.DYNAMIC:this.type=s.STATIC,this.boundingRadius=0,this.aabb=new l,this.aabbNeedsUpdate=!0,this.allowSleep=void 0===t.allowSleep||t.allowSleep,this.wantsToSleep=!1,this.sleepState=s.AWAKE,this.sleepSpeedLimit=void 0!==t.sleepSpeedLimit?t.sleepSpeedLimit:.2,this.sleepTimeLimit=void 0!==t.sleepTimeLimit?t.sleepTimeLimit:1,this.gravityScale=void 0!==t.gravityScale?t.gravityScale:1,this.collisionResponse=void 0===t.collisionResponse||t.collisionResponse,this.idleTime=0,this.timeLastSleepy=0,this.ccdSpeedThreshold=void 0!==t.ccdSpeedThreshold?t.ccdSpeedThreshold:-1,this.ccdIterations=void 0!==t.ccdIterations?t.ccdIterations:10,this.concavePath=null,this._wakeUpAfterNarrowphase=!1,this.updateMassProperties()}var n=t("../math/vec2"),r=t("poly-decomp"),o=t("../shapes/Convex"),a=t("../collision/RaycastResult"),h=t("../collision/Ray"),l=t("../collision/AABB"),c=t("../events/EventEmitter");e.exports=s,s.prototype=new c,s.prototype.constructor=s,s._idCounter=0,s.prototype.updateSolveMassProperties=function(){this.sleepState===s.SLEEPING||this.type===s.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve=0):(this.invMassSolve=this.invMass,this.invInertiaSolve=this.invInertia)},s.prototype.setDensity=function(t){var e=this.getArea();this.mass=e*t,this.updateMassProperties()},s.prototype.getArea=function(){for(var t=0,e=0;ei&&(i=o+a)}this.boundingRadius=i},s.prototype.addShape=function(t,e,i){if(t.body)throw new Error("A shape can only be added to one body.");t.body=this,e?n.copy(t.position,e):n.set(t.position,0,0),t.angle=i||0,this.shapes.push(t),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0},s.prototype.removeShape=function(t){var e=this.shapes.indexOf(t);return-1!==e&&(this.shapes.splice(e,1),this.aabbNeedsUpdate=!0,t.body=null,!0)},s.prototype.updateMassProperties=function(){if(this.type===s.STATIC||this.type===s.KINEMATIC)this.mass=Number.MAX_VALUE,this.invMass=0,this.inertia=Number.MAX_VALUE,this.invInertia=0;else{var t=this.shapes,e=t.length,i=this.mass/e,r=0;if(this.fixedRotation)this.inertia=Number.MAX_VALUE,this.invInertia=0;else{for(var o=0;o0?1/r:0}this.invMass=1/this.mass,n.set(this.massMultiplier,this.fixedX?0:1,this.fixedY?0:1)}};n.create();s.prototype.applyForce=function(t,e){if(n.add(this.force,this.force,t),e){var i=n.crossLength(e,t);this.angularForce+=i}};var p=n.create(),f=n.create(),g=n.create();s.prototype.applyForceLocal=function(t,e){e=e||g;var i=p,s=f;this.vectorToWorldFrame(i,t),this.vectorToWorldFrame(s,e),this.applyForce(i,s)};var m=n.create();s.prototype.applyImpulse=function(t,e){if(this.type===s.DYNAMIC){var i=m;if(n.scale(i,t,this.invMass),n.multiply(i,this.massMultiplier,i),n.add(this.velocity,i,this.velocity),e){var r=n.crossLength(e,t);r*=this.invInertia,this.angularVelocity+=r}}};var y=n.create(),v=n.create(),x=n.create();s.prototype.applyImpulseLocal=function(t,e){e=e||x;var i=y,s=v;this.vectorToWorldFrame(i,t),this.vectorToWorldFrame(s,e),this.applyImpulse(i,s)},s.prototype.toLocalFrame=function(t,e){n.toLocalFrame(t,e,this.position,this.angle)},s.prototype.toWorldFrame=function(t,e){n.toGlobalFrame(t,e,this.position,this.angle)},s.prototype.vectorToLocalFrame=function(t,e){n.vectorToLocalFrame(t,e,this.angle)},s.prototype.vectorToWorldFrame=function(t,e){n.vectorToGlobalFrame(t,e,this.angle)},s.prototype.fromPolygon=function(t,e){e=e||{};for(h=this.shapes.length;h>=0;--h)this.removeShape(this.shapes[h]);var i=new r.Polygon;if(i.vertices=t,i.makeCCW(),"number"==typeof e.removeCollinearPoints&&i.removeCollinearPoints(e.removeCollinearPoints),void 0===e.skipSimpleCheck&&!i.isSimple())return!1;this.concavePath=i.vertices.slice(0);for(h=0;h=Math.pow(this.sleepSpeedLimit,2)?(this.idleTime=0,this.sleepState=s.AWAKE):(this.idleTime+=i,this.sleepState=s.SLEEPY),this.idleTime>this.sleepTimeLimit&&(e?this.wantsToSleep=!0:this.sleep())}},s.prototype.overlaps=function(t){return this.world.overlapKeeper.bodiesAreOverlapping(this,t)};var T=n.create(),P=n.create();s.prototype.integrate=function(t){var e=this.invMass,i=this.force,s=this.position,r=this.velocity;n.copy(this.previousPosition,this.position),this.previousAngle=this.angle,this.fixedRotation||(this.angularVelocity+=this.angularForce*this.invInertia*t),n.scale(T,i,t*e),n.multiply(T,this.massMultiplier,T),n.add(r,T,r),this.integrateToTimeOfImpact(t)||(n.scale(P,r,t),n.add(s,s,P),this.fixedRotation||(this.angle+=this.angularVelocity*t)),this.aabbNeedsUpdate=!0};var C=new a,S=new h({mode:h.ALL}),A=n.create(),E=n.create(),M=n.create(),R=n.create();s.prototype.integrateToTimeOfImpact=function(t){if(this.ccdSpeedThreshold<0||n.squaredLength(this.velocity)=l&&h=0&&(r.rotate(p,u,s),r.scale(p,p,2*y-1),e.reportIntersection(t,T,p,-1),t.shouldStop(e)))return}for(var x=Math.pow(this.radius,2)+Math.pow(m,2),y=0;y<2;y++){r.set(f,m*(2*y-1),0),r.toGlobalFrame(f,f,i,s);var b=Math.pow(o[0]-n[0],2)+Math.pow(o[1]-n[1],2),_=2*((o[0]-n[0])*(n[0]-f[0])+(o[1]-n[1])*(n[1]-f[1])),w=Math.pow(n[0]-f[0],2)+Math.pow(n[1]-f[1],2)-Math.pow(this.radius,2),T=Math.pow(_,2)-4*b*w;if(!(T<0))if(0===T){if(r.lerp(d,n,o,T),r.squaredDistance(d,i)>x&&(r.sub(p,d,f),r.normalize(p,p),e.reportIntersection(t,T,p,-1),t.shouldStop(e)))return}else{var P=Math.sqrt(T),C=1/(2*b),S=(-_-P)*C,A=(-_+P)*C;if(S>=0&&S<=1&&(r.lerp(d,n,o,S),r.squaredDistance(d,i)>x&&(r.sub(p,d,f),r.normalize(p,p),e.reportIntersection(t,S,p,-1),t.shouldStop(e))))return;if(A>=0&&A<=1&&(r.lerp(d,n,o,A),r.squaredDistance(d,i)>x&&(r.sub(p,d,f),r.normalize(p,p),e.reportIntersection(t,A,p,-1),t.shouldStop(e))))return}}}},{"../math/vec2":30,"./Shape":45}],39:[function(t,e,i){function s(t){"number"==typeof arguments[0]&&(t={radius:arguments[0]},console.warn("The Circle constructor signature has changed. Please use the following format: new Circle({ radius: 1 })")),t=t||{},this.radius=t.radius||1,t.type=n.CIRCLE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeMomentOfInertia=function(t){var e=this.radius;return t*e*e/2},s.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius},s.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius},s.prototype.computeAABB=function(t,e,i){var s=this.radius;r.set(t.upperBound,s,s),r.set(t.lowerBound,-s,-s),e&&(r.add(t.lowerBound,t.lowerBound,e),r.add(t.upperBound,t.upperBound,e))};var o=r.create(),a=r.create();s.prototype.raycast=function(t,e,i,s){var n=e.from,h=e.to,l=this.radius,c=Math.pow(h[0]-n[0],2)+Math.pow(h[1]-n[1],2),u=2*((h[0]-n[0])*(n[0]-i[0])+(h[1]-n[1])*(n[1]-i[1])),d=Math.pow(n[0]-i[0],2)+Math.pow(n[1]-i[1],2)-Math.pow(l,2),p=Math.pow(u,2)-4*c*d,f=o,g=a;if(!(p<0))if(0===p)r.lerp(f,n,h,p),r.sub(g,f,i),r.normalize(g,g),e.reportIntersection(t,p,g,-1);else{var m=Math.sqrt(p),y=1/(2*c),v=(-u-m)*y,x=(-u+m)*y;if(v>=0&&v<=1&&(r.lerp(f,n,h,v),r.sub(g,f,i),r.normalize(g,g),e.reportIntersection(t,v,g,-1),t.shouldStop(e)))return;x>=0&&x<=1&&(r.lerp(f,n,h,x),r.sub(g,f,i),r.normalize(g,g),e.reportIntersection(t,x,g,-1))}}},{"../math/vec2":30,"./Shape":45}],40:[function(t,e,i){function s(t){Array.isArray(arguments[0])&&(t={vertices:arguments[0],axes:arguments[1]},console.warn("The Convex constructor signature has changed. Please use the following format: new Convex({ vertices: [...], ... })")),t=t||{},this.vertices=[];for(var e=void 0!==t.vertices?t.vertices:[],i=0;in)&&(n=s),(null===o||sn){var l=o;o=n,n=l}r.set(e,o,n)},s.prototype.projectOntoWorldAxis=function(t,e,i,s){var n=h;this.projectOntoLocalAxis(t,s),0!==i?r.rotate(n,t,i):n=t;var o=r.dot(e,n);r.set(s,s[0]+o,s[1]+o)},s.prototype.updateTriangles=function(){this.triangles.length=0;for(var t=[],e=0;ee&&(e=s)}this.boundingRadius=Math.sqrt(e)},s.triangleArea=function(t,e,i){return.5*((e[0]-t[0])*(i[1]-t[1])-(i[0]-t[0])*(e[1]-t[1]))},s.prototype.updateArea=function(){this.updateTriangles(),this.area=0;for(var t=this.triangles,e=this.vertices,i=0;i!==t.length;i++){var n=t[i],r=e[n[0]],o=e[n[1]],a=e[n[2]],h=s.triangleArea(r,o,a);this.area+=h}},s.prototype.computeAABB=function(t,e,i){t.setFromPoints(this.vertices,e,i,0)};var f=r.create(),g=r.create(),m=r.create();s.prototype.raycast=function(t,e,i,s){var n=f,o=g,a=m,h=this.vertices;r.toLocalFrame(n,e.from,i,s),r.toLocalFrame(o,e.to,i,s);for(var l=h.length,c=0;c=0&&(r.sub(a,d,u),r.rotate(a,a,-Math.PI/2+s),r.normalize(a,a),e.reportIntersection(t,p,a,c))}}},{"../math/polyk":29,"../math/vec2":30,"./Shape":45,"poly-decomp":5}],41:[function(t,e,i){function s(t){if(Array.isArray(arguments[0])){if(t={heights:arguments[0]},"object"==typeof arguments[1])for(var e in arguments[1])t[e]=arguments[1][e];console.warn("The Heightfield constructor signature has changed. Please use the following format: new Heightfield({ heights: [...], ... })")}t=t||{},this.heights=t.heights?t.heights.slice(0):[],this.maxValue=t.maxValue||null,this.minValue=t.minValue||null,this.elementWidth=t.elementWidth||.1,void 0!==t.maxValue&&void 0!==t.minValue||this.updateMaxMinValues(),t.type=n.HEIGHTFIELD,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");t("../utils/Utils");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.updateMaxMinValues=function(){for(var t=this.heights,e=t[0],i=t[0],s=0;s!==t.length;s++){var n=t[s];n>e&&(e=n),nv){var x=y;y=v,v=x}for(var b=0;b=0&&(r.sub(d,f,p),r.rotate(d,d,s+Math.PI/2),r.normalize(d,d),e.reportIntersection(t,_,d,-1),t.shouldStop(e)))return}}},{"../math/vec2":30,"../utils/Utils":57,"./Shape":45}],42:[function(t,e,i){function s(t){"number"==typeof arguments[0]&&(t={length:arguments[0]},console.warn("The Line constructor signature has changed. Please use the following format: new Line({ length: 1, ... })")),t=t||{},this.length=t.length||1,t.type=n.LINE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeMomentOfInertia=function(t){return t*Math.pow(this.length,2)/12},s.prototype.updateBoundingRadius=function(){this.boundingRadius=this.length/2};var o=[r.create(),r.create()];s.prototype.computeAABB=function(t,e,i){var s=this.length/2;r.set(o[0],-s,0),r.set(o[1],s,0),t.setFromPoints(o,e,i,0)};r.create();var a=r.create(),h=r.create(),l=r.create(),c=r.fromValues(0,1);s.prototype.raycast=function(t,e,i,s){var n=e.from,o=e.to,u=h,d=l,p=this.length/2;r.set(u,-p,0),r.set(d,p,0),r.toGlobalFrame(u,u,i,s),r.toGlobalFrame(d,d,i,s);var f=r.getLineSegmentsIntersectionFraction(u,d,n,o);if(f>=0){var g=a;r.rotate(g,c,s),e.reportIntersection(t,f,g,-1)}}},{"../math/vec2":30,"./Shape":45}],43:[function(t,e,i){function s(t){(t=t||{}).type=n.PARTICLE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeMomentOfInertia=function(t){return 0},s.prototype.updateBoundingRadius=function(){this.boundingRadius=0},s.prototype.computeAABB=function(t,e,i){r.copy(t.lowerBound,e),r.copy(t.upperBound,e)}},{"../math/vec2":30,"./Shape":45}],44:[function(t,e,i){function s(t){(t=t||{}).type=n.PLANE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");t("../utils/Utils");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeMomentOfInertia=function(t){return 0},s.prototype.updateBoundingRadius=function(){this.boundingRadius=Number.MAX_VALUE},s.prototype.computeAABB=function(t,e,i){var s=i%(2*Math.PI),n=r.set,o=t.lowerBound,a=t.upperBound;n(o,-1e7,-1e7),n(a,1e7,1e7),0===s?a[1]=0:s===Math.PI/2?o[0]=0:s===Math.PI?o[1]=0:s===3*Math.PI/2&&(a[0]=0)},s.prototype.updateArea=function(){this.area=Number.MAX_VALUE};var o=r.create(),a=(r.create(),r.create(),r.create()),h=r.create();s.prototype.raycast=function(t,e,i,s){var n=e.from,l=e.to,c=e.direction,u=o,d=a,p=h;r.set(d,0,1),r.rotate(d,d,s),r.sub(p,n,i);var f=r.dot(p,d);if(r.sub(p,l,i),!(f*r.dot(p,d)>0||r.squaredDistance(n,l)p*a&&(g=p*a-u),r[t]+=g,e.addToWlambda(g),g}},{"../equations/FrictionEquation":23,"../math/vec2":30,"../utils/Utils":57,"./Solver":47}],47:[function(t,e,i){function s(t,e){t=t||{},n.call(this),this.type=e,this.equations=[],this.equationSortFunction=t.equationSortFunction||!1}t("../utils/Utils");var n=t("../events/EventEmitter");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.solve=function(t,e){throw new Error("Solver.solve should be implemented by subclasses!")};var r={bodies:[]};s.prototype.solveIsland=function(t,e){this.removeAllEquations(),e.equations.length&&(this.addEquations(e.equations),r.bodies.length=0,e.getBodies(r.bodies),r.bodies.length&&this.solve(t,r))},s.prototype.sortEquations=function(){this.equationSortFunction&&this.equations.sort(this.equationSortFunction)},s.prototype.addEquation=function(t){t.enabled&&this.equations.push(t)},s.prototype.addEquations=function(t){for(var e=0,i=t.length;e!==i;e++){var s=t[e];s.enabled&&this.equations.push(s)}},s.prototype.removeEquation=function(t){var e=this.equations.indexOf(t);-1!==e&&this.equations.splice(e,1)},s.prototype.removeAllEquations=function(){this.equations.length=0},s.GS=1,s.ISLAND=2},{"../events/EventEmitter":26,"../utils/Utils":57}],48:[function(t,e,i){function s(){r.apply(this,arguments)}var n=t("../equations/ContactEquation"),r=t("./Pool");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.create=function(){return new n},s.prototype.destroy=function(t){return t.bodyA=t.bodyB=null,this}},{"../equations/ContactEquation":21,"./Pool":55}],49:[function(t,e,i){function s(){r.apply(this,arguments)}var n=t("../equations/FrictionEquation"),r=t("./Pool");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.create=function(){return new n},s.prototype.destroy=function(t){return t.bodyA=t.bodyB=null,this}},{"../equations/FrictionEquation":23,"./Pool":55}],50:[function(t,e,i){function s(){r.apply(this,arguments)}var n=t("../world/IslandNode"),r=t("./Pool");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.create=function(){return new n},s.prototype.destroy=function(t){return t.reset(),this}},{"../world/IslandNode":60,"./Pool":55}],51:[function(t,e,i){function s(){r.apply(this,arguments)}var n=t("../world/Island"),r=t("./Pool");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.create=function(){return new n},s.prototype.destroy=function(t){return t.reset(),this}},{"../world/Island":58,"./Pool":55}],52:[function(t,e,i){function s(){this.overlappingShapesLastState=new n,this.overlappingShapesCurrentState=new n,this.recordPool=new r({size:16}),this.tmpDict=new n,this.tmpArray1=[]}var n=t("./TupleDictionary"),r=(t("./OverlapKeeperRecord"),t("./OverlapKeeperRecordPool"));t("./Utils");e.exports=s,s.prototype.tick=function(){for(var t=this.overlappingShapesLastState,e=this.overlappingShapesCurrentState,i=t.keys.length;i--;){var s=t.keys[i],n=t.getByKey(s);e.getByKey(s);n&&this.recordPool.release(n)}t.reset(),t.copy(e),e.reset()},s.prototype.setOverlapping=function(t,e,i,s){this.overlappingShapesLastState;var n=this.overlappingShapesCurrentState;if(!n.get(e.id,s.id)){var r=this.recordPool.get();r.set(t,e,i,s),n.set(e.id,s.id,r)}},s.prototype.getNewOverlaps=function(t){return this.getDiff(this.overlappingShapesLastState,this.overlappingShapesCurrentState,t)},s.prototype.getEndOverlaps=function(t){return this.getDiff(this.overlappingShapesCurrentState,this.overlappingShapesLastState,t)},s.prototype.bodiesAreOverlapping=function(t,e){for(var i=this.overlappingShapesCurrentState,s=i.keys.length;s--;){var n=i.keys[s],r=i.data[n];if(r.bodyA===t&&r.bodyB===e||r.bodyA===e&&r.bodyB===t)return!0}return!1},s.prototype.getDiff=function(t,e,i){var s=t,n=e;(i=i||[]).length=0;for(var r=n.keys.length;r--;){var o=n.keys[r],a=n.data[o];if(!a)throw new Error("Key "+o+" had no data!");s.data[o]||i.push(a)}return i},s.prototype.isNewOverlap=function(t,e){var i=0|t.id,s=0|e.id,n=this.overlappingShapesLastState,r=this.overlappingShapesCurrentState;return!n.get(i,s)&&!!r.get(i,s)},s.prototype.getNewBodyOverlaps=function(t){this.tmpArray1.length=0;var e=this.getNewOverlaps(this.tmpArray1);return this.getBodyDiff(e,t)},s.prototype.getEndBodyOverlaps=function(t){this.tmpArray1.length=0;var e=this.getEndOverlaps(this.tmpArray1);return this.getBodyDiff(e,t)},s.prototype.getBodyDiff=function(t,e){e=e||[];for(var i=this.tmpDict,s=t.length;s--;){var n=t[s];i.set(0|n.bodyA.id,0|n.bodyB.id,n)}for(s=i.keys.length;s--;)(n=i.getByKey(i.keys[s]))&&e.push(n.bodyA,n.bodyB);return i.reset(),e}},{"./OverlapKeeperRecord":53,"./OverlapKeeperRecordPool":54,"./TupleDictionary":56,"./Utils":57}],53:[function(t,e,i){function s(t,e,i,s){this.shapeA=e,this.shapeB=s,this.bodyA=t,this.bodyB=i}e.exports=s,s.prototype.set=function(t,e,i,n){s.call(this,t,e,i,n)}},{}],54:[function(t,e,i){function s(){r.apply(this,arguments)}var n=t("./OverlapKeeperRecord"),r=t("./Pool");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.create=function(){return new n},s.prototype.destroy=function(t){return t.bodyA=t.bodyB=t.shapeA=t.shapeB=null,this}},{"./OverlapKeeperRecord":53,"./Pool":55}],55:[function(t,e,i){function s(t){t=t||{},this.objects=[],void 0!==t.size&&this.resize(t.size)}e.exports=s,s.prototype.resize=function(t){for(var e=this.objects;e.length>t;)e.pop();for(;e.length(0|e)?t<<16|65535&e:e<<16|65535&t)},s.prototype.getByKey=function(t){return t|=0,this.data[t]},s.prototype.get=function(t,e){return this.data[this.getKey(t,e)]},s.prototype.set=function(t,e,i){if(!i)throw new Error("No data!");var s=this.getKey(t,e);return this.data[s]||this.keys.push(s),this.data[s]=i,s},s.prototype.reset=function(){for(var t=this.data,e=this.keys,i=e.length;i--;)delete t[e[i]];e.length=0},s.prototype.copy=function(t){this.reset(),n.appendArray(this.keys,t.keys);for(var e=t.keys.length;e--;){var i=t.keys[e];this.data[i]=t.data[i]}}},{"./Utils":57}],57:[function(t,e,i){function s(){}e.exports=s,s.appendArray=function(t,e){if(e.length<15e4)t.push.apply(t,e);else for(var i=0,s=e.length;i!==s;++i)t.push(e[i])},s.splice=function(t,e,i){i=i||1;for(var s=e,n=t.length-i;s=t&&s=0;T-=2)for(S=b.length-2;S>=0;S-=2)(w[T]===b[S]&&w[T+1]===b[S+1]||w[T+1]===b[S]&&w[T]===b[S+1])&&b.splice(S,2);H=u.length;for(T=0;T!==H;T++){var C=u[T];if(!C.collideConnected)for(var S=b.length-2;S>=0;S-=2)(C.bodyA===b[S]&&C.bodyB===b[S+1]||C.bodyB===b[S]&&C.bodyA===b[S+1])&&b.splice(S,2)}this.postBroadphaseEvent.pairs=b,this.emit(this.postBroadphaseEvent),this.postBroadphaseEvent.pairs=null,c.reset(this);for(var T=0,A=b.length;T!==A;T+=2)for(var E=b[T],M=b[T+1],R=0,L=E.shapes.length;R!==L;R++)for(var B=E.shapes[R],I=B.position,O=B.angle,k=0,F=M.shapes.length;k!==F;k++){var D=M.shapes[k],U=D.position,G=D.angle,N=this.defaultContactMaterial;if(B.material&&D.material){var X=this.getContactMaterial(B.material,D.material);X&&(N=X)}this.runNarrowphase(c,E,B,I,O,M,D,U,G,N,this.frictionGravity)}for(T=0;T!==h;T++)(q=n[T])._wakeUpAfterNarrowphase&&(q.wakeUp(),q._wakeUpAfterNarrowphase=!1);if(this.has("endContact")){this.overlapKeeper.getEndOverlaps(P);for(var W=this.endContactEvent,k=P.length;k--;){var j=P[k];W.shapeA=j.shapeA,W.shapeB=j.shapeB,W.bodyA=j.bodyA,W.bodyB=j.bodyB,this.emit(W)}P.length=0}var V=this.preSolveEvent;V.contactEquations=c.contactEquations,V.frictionEquations=c.frictionEquations,this.emit(V),V.contactEquations=V.frictionEquations=null;var H=u.length;for(T=0;T!==H;T++)u[T].update();if(c.contactEquations.length||c.frictionEquations.length||H)if(this.islandSplit){for(g.equations.length=0,v.appendArray(g.equations,c.contactEquations),v.appendArray(g.equations,c.frictionEquations),T=0;T!==H;T++)v.appendArray(g.equations,u[T].equations);g.split(this);for(T=0;T!==g.islands.length;T++)(K=g.islands[T]).equations.length&&a.solveIsland(t,K)}else{for(a.addEquations(c.contactEquations),a.addEquations(c.frictionEquations),T=0;T!==H;T++)a.addEquations(u[T].equations);this.solveConstraints&&a.solve(t,this),a.removeAllEquations()}for(T=0;T!==h;T++){var q=n[T];q.integrate(t)}for(T=0;T!==h;T++)n[T].setZeroForce();if(this.emitImpactEvent&&this.has("impact"))for(var Y=this.impactEvent,T=0;T!==c.contactEquations.length;T++){var z=c.contactEquations[T];z.firstImpact&&(Y.bodyA=z.bodyA,Y.bodyB=z.bodyB,Y.shapeA=z.shapeA,Y.shapeB=z.shapeB,Y.contactEquation=z,this.emit(Y))}if(this.sleepMode===s.BODY_SLEEPING)for(T=0;T!==h;T++)n[T].sleepTick(this.time,!1,t);else if(this.sleepMode===s.ISLAND_SLEEPING&&this.islandSplit){for(T=0;T!==h;T++)n[T].sleepTick(this.time,!0,t);for(T=0;T0,t.frictionCoefficient=c.friction;var g;g=e.type===d.STATIC||e.type===d.KINEMATIC?o.mass:o.type===d.STATIC||o.type===d.KINEMATIC?e.mass:e.mass*o.mass/(e.mass+o.mass),t.slipForce=c.friction*u*g,t.restitution=c.restitution,t.surfaceVelocity=c.surfaceVelocity,t.frictionStiffness=c.frictionStiffness,t.frictionRelaxation=c.frictionRelaxation,t.stiffness=c.stiffness,t.relaxation=c.relaxation,t.contactSkinSize=c.contactSkinSize,t.enabledEquations=e.collisionResponse&&o.collisionResponse&&i.collisionResponse&&a.collisionResponse;var m=t[i.type|a.type],y=0;if(m){var v=i.sensor||a.sensor,x=t.frictionEquations.length;y=i.type=2*Math.pow(o.sleepSpeedLimit,2)&&(e._wakeUpAfterNarrowphase=!0),o.allowSleep&&o.type===d.DYNAMIC&&o.sleepState===d.SLEEPING&&e.sleepState===d.AWAKE&&e.type!==d.STATIC&&r.squaredLength(e.velocity)+Math.pow(e.angularVelocity,2)>=2*Math.pow(e.sleepSpeedLimit,2)&&(o._wakeUpAfterNarrowphase=!0),this.overlapKeeper.setOverlapping(e,i,o,a),this.has("beginContact")&&this.overlapKeeper.isNewOverlap(i,a)){var _=this.beginContactEvent;if(_.shapeA=i,_.shapeB=a,_.bodyA=e,_.bodyB=o,_.contactEquations.length=0,"number"==typeof y)for(P=t.contactEquations.length-y;P1)for(var P=t.frictionEquations.length-b;P=0;e--)this.removeConstraint(t[e]);for(var i=this.bodies,e=i.length-1;e>=0;e--)this.removeBody(i[e]);for(var n=this.springs,e=n.length-1;e>=0;e--)this.removeSpring(n[e]);for(var r=this.contactMaterials,e=r.length-1;e>=0;e--)this.removeContactMaterial(r[e]);s.apply(this)};var C=r.create(),S=(r.fromValues(0,0),r.fromValues(0,0));s.prototype.hitTest=function(t,e,i){i=i||0;var s=new d({position:t}),n=new c,u=t,p=C,f=S;s.addShape(n);for(var g=this.narrowphase,m=[],y=0,v=e.length;y!==v;y++)for(var x=e[y],b=0,_=x.shapes.length;b!==_;b++){var w=x.shapes[b];r.rotate(p,w.position,x.angle),r.add(p,p,x.position);var T=w.angle+x.angle;(w instanceof o&&g.circleParticle(x,w,p,T,s,n,u,0,!0)||w instanceof a&&g.particleConvex(s,n,u,0,x,w,p,T,!0)||w instanceof h&&g.particlePlane(s,n,u,0,x,w,p,T,!0)||w instanceof l&&g.particleCapsule(s,n,u,0,x,w,p,T,!0)||w instanceof c&&r.squaredLength(r.sub(f,p,t))0?Math.acos(i/u):-Math.acos(i/u),this.worldScale.x=u,this.worldScale.y=c/u}else if(n||r){var d=Math.sqrt(n*n+r*r);this.worldRotation=Phaser.Math.HALF_PI-(r>0?Math.acos(-n/d):-Math.acos(n/d)),this.worldScale.x=c/d,this.worldScale.y=d}else this.worldScale.x=0,this.worldScale.y=0;return this.worldAlpha=this.alpha*e.worldAlpha,this.worldPosition.x=l.tx,this.worldPosition.y=l.ty,this._currentBounds=null,this.transformCallback&&this.transformCallback.call(this.transformCallbackContext,l,h),this},preUpdate:function(){},generateTexture:function(t,e,i){var n=this.getLocalBounds(),r=new Phaser.RenderTexture(this.game,0|n.width,0|n.height,i,e,t);return s.DisplayObject._tempMatrix.tx=-n.x,s.DisplayObject._tempMatrix.ty=-n.y,r.render(this,s.DisplayObject._tempMatrix),r},updateCache:function(){return this._generateCachedSprite(),this},toGlobal:function(t){return this.updateTransform(),this.worldTransform.apply(t)},toLocal:function(t,e){return e&&(t=e.toGlobal(t)),this.updateTransform(),this.worldTransform.applyInverse(t)},_renderCachedSprite:function(t){this._cachedSprite.worldAlpha=this.worldAlpha,t.gl?s.Sprite.prototype._renderWebGL.call(this._cachedSprite,t):s.Sprite.prototype._renderCanvas.call(this._cachedSprite,t)},_generateCachedSprite:function(){this._cacheAsBitmap=!1;var t=this.getLocalBounds();if(t.width=Math.max(1,Math.ceil(t.width)),t.height=Math.max(1,Math.ceil(t.height)),this.updateTransform(),this._cachedSprite)this._cachedSprite.texture.resize(t.width,t.height);else{var e=0;this.texture&&this.texture.baseTexture&&s._enableMultiTextureToggle&&(e=this.texture.baseTexture.textureIndex);var i=new Phaser.RenderTexture(this.game,t.width,t.height,void 0,void 0,void 0,void 0,e);this._cachedSprite=new s.Sprite(i),this._cachedSprite.worldTransform=this.worldTransform}var n=this._filters;this._filters=null,this._cachedSprite.filters=n,s.DisplayObject._tempMatrix.tx=-t.x,s.DisplayObject._tempMatrix.ty=-t.y,this._cachedSprite.texture.render(this,s.DisplayObject._tempMatrix,!0),this._cachedSprite.anchor.x=-t.x/t.width,this._cachedSprite.anchor.y=-t.y/t.height,this._filters=n,this._cacheAsBitmap=!0},_destroyCachedSprite:function(){this._cachedSprite&&(this._cachedSprite.texture.destroy(!0),this._cachedSprite=null)}},s.DisplayObject.prototype.displayObjectUpdateTransform=s.DisplayObject.prototype.updateTransform,Object.defineProperties(s.DisplayObject.prototype,{x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},worldVisible:{get:function(){if(this.visible){var t=this.parent;if(!t)return this.visible;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}return!1}},mask:{get:function(){return this._mask},set:function(t){this._mask&&(this._mask.isMask=!1),this._mask=t,t&&(this._mask.isMask=!0)}},filters:{get:function(){return this._filters},set:function(t){if(Array.isArray(t)){for(var e=[],i=0;i=0&&e<=this.children.length)return t.parent&&t.parent.removeChild(t),t.parent=this,this.children.splice(e,0,t),t;throw new Error(t+"addChildAt: The index "+e+" supplied is out of bounds "+this.children.length)},s.DisplayObjectContainer.prototype.swapChildren=function(t,e){if(t!==e){var i=this.getChildIndex(t),s=this.getChildIndex(e);if(i<0||s<0)throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");this.children[i]=e,this.children[s]=t}},s.DisplayObjectContainer.prototype.getChildIndex=function(t){var e=this.children.indexOf(t);if(-1===e)throw new Error("The supplied DisplayObject must be a child of the caller");return e},s.DisplayObjectContainer.prototype.setChildIndex=function(t,e){if(e<0||e>=this.children.length)throw new Error("The supplied index is out of bounds");var i=this.getChildIndex(t);this.children.splice(i,1),this.children.splice(e,0,t)},s.DisplayObjectContainer.prototype.getChildAt=function(t){if(t<0||t>=this.children.length)throw new Error("getChildAt: Supplied index "+t+" does not exist in the child list, or the supplied DisplayObject must be a child of the caller");return this.children[t]},s.DisplayObjectContainer.prototype.removeChild=function(t){var e=this.children.indexOf(t);if(-1!==e)return this.removeChildAt(e)},s.DisplayObjectContainer.prototype.removeChildAt=function(t){var e=this.getChildAt(t);return e&&(e.parent=void 0,this.children.splice(t,1)),e},s.DisplayObjectContainer.prototype.bringChildToTop=function(t){if(t.parent===this)return this.setChildIndex(t,this.children.length-1)},s.DisplayObjectContainer.prototype.sendChildToBack=function(t){if(t.parent===this)return this.setChildIndex(t,0)},s.DisplayObjectContainer.prototype.removeChildren=function(t,e){void 0===t&&(t=0),void 0===e&&(e=this.children.length);var i=e-t;if(i>0&&i<=e){for(var s=this.children.splice(t,i),n=0;na?u:a,d=d>h?d:h);var f=this._bounds;if(!p){var g=(f=new s.Rectangle).x,m=f.width+f.x,y=f.y,v=f.height+f.y,x=this.worldTransform,b=x.a,_=x.b,w=x.c,T=x.d,P=x.tx,C=x.ty,S=b*m+w*v+P,A=T*v+_*m+C,E=b*g+w*v+P,M=T*v+_*g+C,R=b*g+w*y+P,L=T*y+_*g+C,B=b*m+w*y+P,I=T*y+_*m+C;u=S,d=A,c=A,l=B<(l=R<(l=E<(l=S)?E:l)?R:l)?B:l,c=I<(c=L<(c=M(u=R>(u=E>u?E:u)?R:u)?B:u,d=I>(d=L>(d=M>d?M:d)?L:d)?I:d}if(f.x=l,f.y=c,f.width=u-l,f.height=d-c,e)for(t.worldTransform=r,n=0;n(f=T>(f=_>(f=x>f?x:f)?_:f)?T:f)?C:f,g=S>(g=P>(g=w>(g=b>g?b:g)?w:g)?P:g)?S:g}var A=this._bounds;return A.x=m,A.width=f-m,A.y=y,A.height=g-y,this._currentBounds=A,A},s.Sprite.prototype.getLocalBounds=function(){var t=this.worldTransform;this.worldTransform=Phaser.identityMatrix;for(var e=0;e= "+this.MAX_TEXTURES+".0) { gl_FragColor = BLUE;return;}"," if(isnan(vTextureIndex)) { gl_FragColor = RED;return;}","}"];var n=s.compileProgram(t,this.vertexSrc||s.PixiShader.defaultVertexSrc,this.fragmentSrc);t.useProgram(n),this.uSamplerArray=t.getUniformLocation(n,"uSamplerArray[0]"),this.projectionVector=t.getUniformLocation(n,"projectionVector"),this.offsetVector=t.getUniformLocation(n,"offsetVector"),this.dimensions=t.getUniformLocation(n,"dimensions"),this.aVertexPosition=t.getAttribLocation(n,"aVertexPosition"),this.aTextureCoord=t.getAttribLocation(n,"aTextureCoord"),this.colorAttribute=t.getAttribLocation(n,"aColor"),this.aTextureIndex=t.getAttribLocation(n,"aTextureIndex");var r=[],o=t.createTexture();t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,o),t.texImage2D(t.TEXTURE_2D,0,t.RGB,1,1,0,t.RGB,t.UNSIGNED_BYTE,null);for(var a=0;a 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;","}"],s.PixiFastShader=function(t){if(this._UID=Phaser._UID++,this.gl=t,this.program=null,s._enableMultiTextureToggle){var t=this.gl;this.MAX_TEXTURES=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);for(var e="\tif (vTextureIndex == 0.0) { gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;return;}\n",i=1;i= "+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()},s.PixiFastShader.prototype.constructor=s.PixiFastShader,s.PixiFastShader.prototype.init=function(){var t=this.gl,e=s.compileProgram(t,this.vertexSrc,this.fragmentSrc);if(t.useProgram(e),this.uSampler=s._enableMultiTextureToggle?t.getUniformLocation(e,"uSamplerArray[0]"):t.getUniformLocation(e,"uSampler"),s._enableMultiTextureToggle){var i=[],n=t.createTexture();t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,n),t.texImage2D(t.TEXTURE_2D,0,t.RGB,1,1,0,t.RGB,t.UNSIGNED_BYTE,null);for(var r=0;r= "+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()},s.StripShader.prototype.constructor=s.StripShader,s.StripShader.prototype.init=function(){var t=this.gl,e=s.compileProgram(t,this.vertexSrc,this.fragmentSrc);if(t.useProgram(e),this.uSampler=s._enableMultiTextureToggle?t.getUniformLocation(e,"uSamplerArray[0]"):t.getUniformLocation(e,"uSampler"),s._enableMultiTextureToggle){var i=[],n=t.createTexture();t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,n),t.texImage2D(t.TEXTURE_2D,0,t.RGB,1,1,0,t.RGB,t.UNSIGNED_BYTE,null);for(var r=0;r>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t},i=this.gl,n=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),r=i.getParameter(i.MAX_TEXTURE_SIZE),o=this.game.cache._cache.image,a=null,h=0;h=this.size&&(this.flush(),this.currentBaseTexture=i.baseTexture);var n=i._uvs;if(n){var r,o,a,h,l=t.anchor.x,c=t.anchor.y;if(i.trim){var u=i.trim;r=(o=u.x-l*u.width)+i.crop.width,a=(h=u.y-c*u.height)+i.crop.height}else r=i.frame.width*(1-l),o=i.frame.width*-l,a=i.frame.height*(1-c),h=i.frame.height*-c;var d=this.currentBatchSize*this.vertexSize,p=i.baseTexture.resolution,f=i.baseTexture.textureIndex,g=s.a/p,m=s.b/p,y=s.c/p,v=s.d/p,x=s.tx,b=s.ty,_=i.crop.height;if(i.rotated){var w=s.a,T=s.b,P=s.c,C=s.d,S=o,A=r;x=s.c*_+x,b=s.d*_+b,g=6.123233995736766e-17*w-P,m=6.123233995736766e-17*T-C,y=w+6.123233995736766e-17*P,v=T+6.123233995736766e-17*C,i._updateUvsInverted(),r=a,o=h,a=A,h=S}var E=this.colors,M=this.positions,R=t.tint,L=(R>>16)+(65280&R)+((255&R)<<16)+(255*t.worldAlpha<<24);this.renderSession.roundPixels?(M[d++]=g*o+y*h+x|0,M[d++]=v*h+m*o+b|0,M[d++]=n.x0,M[d++]=n.y0,E[d++]=L,M[d++]=f,M[d++]=g*r+y*h+x|0,M[d++]=v*h+m*r+b|0,M[d++]=n.x1,M[d++]=n.y1,E[d++]=L,M[d++]=f,M[d++]=g*r+y*a+x|0,M[d++]=v*a+m*r+b|0,M[d++]=n.x2,M[d++]=n.y2,E[d++]=L,M[d++]=f,M[d++]=g*o+y*a+x|0,M[d++]=v*a+m*o+b|0,M[d++]=n.x3,M[d++]=n.y3,E[d++]=L,M[d++]=f):(M[d++]=g*o+y*h+x,M[d++]=v*h+m*o+b,M[d++]=n.x0,M[d++]=n.y0,E[d++]=L,M[d++]=f,M[d++]=g*r+y*h+x,M[d++]=v*h+m*r+b,M[d++]=n.x1,M[d++]=n.y1,E[d++]=L,M[d++]=f,M[d++]=g*r+y*a+x,M[d++]=v*a+m*r+b,M[d++]=n.x2,M[d++]=n.y2,E[d++]=L,M[d++]=f,M[d++]=g*o+y*a+x,M[d++]=v*a+m*o+b,M[d++]=n.x3,M[d++]=n.y3,E[d++]=L,M[d++]=f),this.sprites[this.currentBatchSize++]=t}},s.WebGLSpriteBatch.prototype.renderTilingSprite=function(t){var e=t.tilingTexture,i=t.texture.baseTexture.textureIndex;this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=e.baseTexture),t._uvs||(t._uvs=new s.TextureUvs);var n=t._uvs,r=e.baseTexture.width,o=e.baseTexture.height;t.tilePosition.x%=r*t.tileScaleOffset.x,t.tilePosition.y%=o*t.tileScaleOffset.y;var a=t.tilePosition.x/(r*t.tileScaleOffset.x),h=t.tilePosition.y/(o*t.tileScaleOffset.y),l=t.width/r/(t.tileScale.x*t.tileScaleOffset.x),c=t.height/o/(t.tileScale.y*t.tileScaleOffset.y);n.x0=0-a,n.y0=0-h,n.x1=1*l-a,n.y1=0-h,n.x2=1*l-a,n.y2=1*c-h,n.x3=0-a,n.y3=1*c-h;var u=t.tint,d=(u>>16)+(65280&u)+((255&u)<<16)+(255*t.worldAlpha<<24),p=this.positions,f=this.colors,g=t.width,m=t.height,y=t.anchor.x,v=t.anchor.y,x=g*(1-y),b=g*-y,_=m*(1-v),w=m*-v,T=this.currentBatchSize*this.vertexSize,P=e.baseTexture.resolution,C=t.worldTransform,S=C.a/P,A=C.b/P,E=C.c/P,M=C.d/P,R=C.tx,L=C.ty;p[T++]=S*b+E*w+R,p[T++]=M*w+A*b+L,p[T++]=n.x0,p[T++]=n.y0,f[T++]=d,p[T++]=i,p[T++]=S*x+E*w+R,p[T++]=M*w+A*x+L,p[T++]=n.x1,p[T++]=n.y1,f[T++]=d,p[T++]=i,p[T++]=S*x+E*_+R,p[T++]=M*_+A*x+L,p[T++]=n.x2,p[T++]=n.y2,f[T++]=d,p[T++]=i,p[T++]=S*b+E*_+R,p[T++]=M*_+A*b+L,p[T++]=n.x3,p[T++]=n.y3,f[T++]=d,p[T++]=i,this.sprites[this.currentBatchSize++]=t},s.WebGLSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var t,e=this.gl;if(this.dirty){this.dirty=!1,t=this.defaultShader.shaders[e.id],e.activeTexture(e.TEXTURE0),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var i=this.vertexSize;e.vertexAttribPointer(t.aVertexPosition,2,e.FLOAT,!1,i,0),e.vertexAttribPointer(t.aTextureCoord,2,e.FLOAT,!1,i,8),e.vertexAttribPointer(t.colorAttribute,4,e.UNSIGNED_BYTE,!0,i,16),e.vertexAttribPointer(t.aTextureIndex,1,e.FLOAT,!1,i,20)}if(this.currentBatchSize>.5*this.size)e.bufferSubData(e.ARRAY_BUFFER,0,this.vertices);else{e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer);var n=this.positions.subarray(0,this.currentBatchSize*this.vertexSize);e.bufferSubData(e.ARRAY_BUFFER,0,n)}for(var r,o,a,h,l=0,c=0,u=null,d=this.renderSession.blendModeManager.currentBlendMode,p=null,f=!1,g=!1,m=0,y=this.currentBatchSize;m0&&(v=!1),(u!==r&&!v||f||g)&&(this.renderBatch(u,l,c),c=m,l=0,u=r,f&&(d=o,this.renderSession.blendModeManager.setBlendMode(d)),g)){(t=(p=a).shaders[e.id])||((t=new s.PixiShader(e)).fragmentSrc=p.fragmentSrc,t.uniforms=p.uniforms,t.init(),p.shaders[e.id]=t),this.renderSession.shaderManager.setShader(t),t.dirty&&t.syncUniforms();var x=this.renderSession.projection;e.uniform2f(t.projectionVector,x.x,x.y);var b=this.renderSession.offset;e.uniform2f(t.offsetVector,b.x,b.y)}l++}this.renderBatch(u,l,c),this.currentBatchSize=0}},s.WebGLSpriteBatch.prototype.renderBatch=function(t,e,i){if(0!==e){var s=this.gl;if(t._dirty[s.id]){if(!this.renderSession.renderer.updateTexture(t))return}else s.bindTexture(s.TEXTURE_2D,t._glTextures[s.id]);s.drawElements(s.TRIANGLES,6*e,s.UNSIGNED_SHORT,6*i*2),this.renderSession.drawCount++}},s.WebGLSpriteBatch.prototype.stop=function(){this.flush(),this.dirty=!0},s.WebGLSpriteBatch.prototype.start=function(){this.dirty=!0},s.WebGLSpriteBatch.prototype.destroy=function(){this.vertices=null,this.indices=null,this.gl.deleteBuffer(this.vertexBuffer),this.gl.deleteBuffer(this.indexBuffer),this.currentBaseTexture=null,this.gl=null},s.WebGLFastSpriteBatch=function(t){this.vertSize=11,this.maxSize=6e3,this.size=this.maxSize;var e=4*this.size*this.vertSize,i=6*this.maxSize;this.vertices=new Float32Array(e),this.indices=new Uint16Array(i),this.vertexBuffer=null,this.indexBuffer=null,this.lastIndexCount=0;for(var s=0,n=0;s=this.size&&this.flush()}},s.WebGLFastSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var t=this.gl;if(this.currentBaseTexture._glTextures[t.id]){if(this.currentBatchSize>.5*this.size)t.bufferSubData(t.ARRAY_BUFFER,0,this.vertices);else{var e=this.vertices.subarray(0,4*this.currentBatchSize*this.vertSize);t.bufferSubData(t.ARRAY_BUFFER,0,e)}t.drawElements(t.TRIANGLES,6*this.currentBatchSize,t.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++}else this.renderSession.renderer.updateTexture(this.currentBaseTexture,t)}},s.WebGLFastSpriteBatch.prototype.stop=function(){this.flush()},s.WebGLFastSpriteBatch.prototype.start=function(){var t=this.gl;t.activeTexture(t.TEXTURE0),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var e=this.renderSession.projection;t.uniform2f(this.shader.projectionVector,e.x,e.y),t.uniformMatrix3fv(this.shader.uMatrix,!1,this.matrix);var i=4*this.vertSize;t.vertexAttribPointer(this.shader.aVertexPosition,2,t.FLOAT,!1,i,0),t.vertexAttribPointer(this.shader.aPositionCoord,2,t.FLOAT,!1,i,8),t.vertexAttribPointer(this.shader.aScale,2,t.FLOAT,!1,i,16),t.vertexAttribPointer(this.shader.aRotation,1,t.FLOAT,!1,i,24),t.vertexAttribPointer(this.shader.aTextureCoord,2,t.FLOAT,!1,i,28),t.vertexAttribPointer(this.shader.colorAttribute,1,t.FLOAT,!1,i,36),t.vertexAttribPointer(this.shader.aTextureIndex,1,t.FLOAT,!1,i,40)},s.WebGLFilterManager=function(){this.filterStack=[],this.offsetX=0,this.offsetY=0},s.WebGLFilterManager.prototype.constructor=s.WebGLFilterManager,s.WebGLFilterManager.prototype.setContext=function(t){this.gl=t,this.texturePool=[],this.initShaderBuffers()},s.WebGLFilterManager.prototype.begin=function(t,e){this.renderSession=t,this.defaultShader=t.shaderManager.defaultShader;var i=this.renderSession.projection;this.width=2*i.x,this.height=2*-i.y,this.buffer=e},s.WebGLFilterManager.prototype.pushFilter=function(t){var e=this.gl,i=this.renderSession.projection,n=this.renderSession.offset;t._filterArea=t.target.filterArea||t.target.getBounds(),t._previous_stencil_mgr=this.renderSession.stencilManager,this.renderSession.stencilManager=new s.WebGLStencilManager,this.renderSession.stencilManager.setContext(e),e.disable(e.STENCIL_TEST),this.filterStack.push(t);var r=t.filterPasses[0];this.offsetX+=t._filterArea.x,this.offsetY+=t._filterArea.y;var o=this.texturePool.pop();o?o.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution):o=new s.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution),e.bindTexture(e.TEXTURE_2D,o.texture);var a=t._filterArea,h=r.padding;a.x-=h,a.y-=h,a.width+=2*h,a.height+=2*h,a.x<0&&(a.x=0),a.width>this.width&&(a.width=this.width),a.y<0&&(a.y=0),a.height>this.height&&(a.height=this.height),e.bindFramebuffer(e.FRAMEBUFFER,o.frameBuffer),e.viewport(0,0,a.width*this.renderSession.resolution,a.height*this.renderSession.resolution),i.x=a.width/2,i.y=-a.height/2,n.x=-a.x,n.y=-a.y,e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),t._glFilterTexture=o},s.WebGLFilterManager.prototype.popFilter=function(){var t=this.gl,e=this.filterStack.pop(),i=e._filterArea,n=e._glFilterTexture,r=this.renderSession.projection,o=this.renderSession.offset;if(e.filterPasses.length>1){t.viewport(0,0,i.width*this.renderSession.resolution,i.height*this.renderSession.resolution),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=0,this.vertexArray[1]=i.height,this.vertexArray[2]=i.width,this.vertexArray[3]=i.height,this.vertexArray[4]=0,this.vertexArray[5]=0,this.vertexArray[6]=i.width,this.vertexArray[7]=0,t.bufferSubData(t.ARRAY_BUFFER,0,this.vertexArray),t.bindBuffer(t.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=i.width/this.width,this.uvArray[5]=i.height/this.height,this.uvArray[6]=i.width/this.width,this.uvArray[7]=i.height/this.height,t.bufferSubData(t.ARRAY_BUFFER,0,this.uvArray);var a=n,h=this.texturePool.pop();h||(h=new s.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution)),h.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution),t.bindFramebuffer(t.FRAMEBUFFER,h.frameBuffer),t.clear(t.COLOR_BUFFER_BIT),t.disable(t.BLEND);for(var l=0;l0?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.applyFilterPass(d,i,p,f),this.texturePool.push(n),e._glFilterTexture=null},s.WebGLFilterManager.prototype.applyFilterPass=function(t,e,i,n){var r=this.gl,o=t.shaders[r.id];o||((o=new s.PixiShader(r)).fragmentSrc=t.fragmentSrc,o.uniforms=t.uniforms,o.init(!0),t.shaders[r.id]=o),this.renderSession.shaderManager.setShader(o),r.uniform2f(o.projectionVector,i/2,-n/2),r.uniform2f(o.offsetVector,0,0),t.uniforms.dimensions&&(t.uniforms.dimensions.value[0]=this.width,t.uniforms.dimensions.value[1]=this.height,t.uniforms.dimensions.value[2]=this.vertexArray[0],t.uniforms.dimensions.value[3]=this.vertexArray[5]),o.syncUniforms(),r.bindBuffer(r.ARRAY_BUFFER,this.vertexBuffer),r.vertexAttribPointer(o.aVertexPosition,2,r.FLOAT,!1,0,0),r.bindBuffer(r.ARRAY_BUFFER,this.uvBuffer),r.vertexAttribPointer(o.aTextureCoord,2,r.FLOAT,!1,0,0),r.bindBuffer(r.ARRAY_BUFFER,this.colorBuffer),r.vertexAttribPointer(o.colorAttribute,2,r.FLOAT,!1,0,0),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,this.indexBuffer),r.drawElements(r.TRIANGLES,6,r.UNSIGNED_SHORT,0),this.renderSession.drawCount++},s.WebGLFilterManager.prototype.initShaderBuffers=function(){var t=this.gl;this.vertexBuffer=t.createBuffer(),this.uvBuffer=t.createBuffer(),this.colorBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),this.vertexArray=new Float32Array([0,0,1,0,0,1,1,1]),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertexArray,t.STATIC_DRAW),this.uvArray=new Float32Array([0,0,1,0,0,1,1,1]),t.bindBuffer(t.ARRAY_BUFFER,this.uvBuffer),t.bufferData(t.ARRAY_BUFFER,this.uvArray,t.STATIC_DRAW),this.colorArray=new Float32Array([1,16777215,1,16777215,1,16777215,1,16777215]),t.bindBuffer(t.ARRAY_BUFFER,this.colorBuffer),t.bufferData(t.ARRAY_BUFFER,this.colorArray,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,1,3,2]),t.STATIC_DRAW)},s.WebGLFilterManager.prototype.destroy=function(){var t=this.gl;this.filterStack=null,this.offsetX=0,this.offsetY=0;for(var e=0;e=0;t--){var e=this._glTextures[t],i=s.glContexts[t];i&&e&&i.deleteTexture(e)}this._glTextures.length=0,this.dirty()},s.BaseTexture.fromCanvas=function(t,e,i){return 0===t.width&&(t.width=1),0===t.height&&(t.height=1),i=i||1,new s.BaseTexture(t,e,i)},s.TextureSilentFail=!1,s.Texture=function(t,e,i,n){this.noFrame=!1,e||(this.noFrame=!0,e=new s.Rectangle(0,0,1,1)),t instanceof s.Texture&&(t=t.baseTexture),this.baseTexture=t,this.frame=e,this.trim=n,this.valid=!1,this.isTiling=!1,this.requiresUpdate=!1,this.requiresReTint=!1,this._uvs=null,this.width=0,this.height=0,this.crop=i||new s.Rectangle(0,0,1,1),this.rotated=!1,t.hasLoaded&&(this.noFrame&&(e=new s.Rectangle(0,0,t.width,t.height)),this.setFrame(e))},s.Texture.prototype.constructor=s.Texture,s.Texture.prototype.onBaseTextureLoaded=function(){var t=this.baseTexture;this.noFrame&&(this.frame=new s.Rectangle(0,0,t.width,t.height)),this.setFrame(this.frame)},s.Texture.prototype.destroy=function(t){t&&this.baseTexture.destroy(),this.valid=!1},s.Texture.prototype.setFrame=function(t){if(this.noFrame=!1,this.frame=t,this.width=t.width,this.height=t.height,this.crop.x=t.x,this.crop.y=t.y,this.crop.width=t.width,this.crop.height=t.height,this.trim||!(t.x+t.width>this.baseTexture.width||t.y+t.height>this.baseTexture.height))this.valid=t&&t.width&&t.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();else{if(!s.TextureSilentFail)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.valid=!1}},s.Texture.prototype._updateUvs=function(){this._uvs||(this._uvs=new s.TextureUvs);var t=this.crop,e=this.baseTexture.width,i=this.baseTexture.height;this._uvs.x0=t.x/e,this._uvs.y0=t.y/i,this._uvs.x1=(t.x+t.width)/e,this._uvs.y1=t.y/i,this._uvs.x2=(t.x+t.width)/e,this._uvs.y2=(t.y+t.height)/i,this._uvs.x3=t.x/e,this._uvs.y3=(t.y+t.height)/i},s.Texture.prototype._updateUvsInverted=function(){this._uvs||(this._uvs=new s.TextureUvs);var t=this.crop,e=this.baseTexture.width,i=this.baseTexture.height;this._uvs.x0=t.x/e,this._uvs.y0=t.y/i,this._uvs.x1=(t.x+t.height)/e,this._uvs.y1=t.y/i,this._uvs.x2=(t.x+t.height)/e,this._uvs.y2=(t.y+t.width)/i,this._uvs.x3=t.x/e,this._uvs.y3=(t.y+t.width)/i},s.Texture.fromCanvas=function(t,e){var i=s.BaseTexture.fromCanvas(t,e);return new s.Texture(i)},s.TextureUvs=function(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y3=0},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=s),exports.PIXI=s):"undefined"!=typeof define&&define.amd?define("PIXI",i.PIXI=s):i.PIXI=s,s}.call(this),function(){var t=this,e=e||{VERSION:"2.13.3",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};if("undefined"!=typeof AudioBufferSourceNode&&(AudioBufferSourceNode.prototype.start||(AudioBufferSourceNode.prototype.start=AudioBufferSourceNode.prototype.noteGrainOn),AudioBufferSourceNode.prototype.stop||(AudioBufferSourceNode.prototype.stop=AudioBufferSourceNode.prototype.noteOff)),Math.trunc||(Math.trunc=function(t){return t<0?Math.ceil(t):Math.floor(t)}),Function.prototype.bind||(Function.prototype.bind=function(){var t=Array.prototype.slice;return function(e){function i(){var r=n.concat(t.call(arguments));s.apply(this instanceof i?this:e,r)}var s=this,n=t.call(arguments,1);if("function"!=typeof s)throw new TypeError;return i.prototype=function t(e){if(e&&(t.prototype=e),!(this instanceof t))return new t}(s.prototype),i}}()),Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),Array.prototype.forEach||(Array.prototype.forEach=function(t){"use strict";if(void 0===this||null===this)throw new TypeError;var e=Object(this),i=e.length>>>0;if("function"!=typeof t)throw new TypeError;for(var s=arguments.length>=2?arguments[1]:void 0,n=0;n0&&100*Math.random()<=t},randomChoice:function(t,e){return Math.random()<.5?t:e},parseDimension:function(t,e){var i=0,s=0;return"string"==typeof t?"%"===t.substr(-1)?(i=parseInt(t,10)/100,s=0===e?window.innerWidth*i:window.innerHeight*i):s=parseInt(t,10):s=t,s},pad:function(t,e,i,s){if(void 0===e)var e=0;if(void 0===i)var i=" ";if(void 0===s)var s=3;var n=0;if(e+1>=(t=t.toString()).length)switch(s){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var r=Math.ceil((n=e-t.length)/2),o=n-r;t=new Array(o+1).join(i)+t+new Array(r+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t},isPlainObject:function(t){if("object"!=typeof t||t.nodeType||t===t.window)return!1;try{if(t.constructor&&!{}.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0},extend:function(){var t,i,s,n,r,o,a=arguments[0]||{},h=1,l=arguments.length,c=!1;for("boolean"==typeof a&&(c=a,a=arguments[1]||{},h=2),l===h&&(a=this,--h);h0&&(this._radius=.5*s),this.type=e.CIRCLE},e.Circle.prototype={circumference:function(){return Math.PI*this._radius*2},random:function(t){void 0===t&&(t=new e.Point);var i=2*Math.PI*Math.random(),s=Math.random()+Math.random(),n=s>1?2-s:s,r=n*Math.cos(i),o=n*Math.sin(i);return t.x=this.x+r*this.radius,t.y=this.y+o*this.radius,t},getBounds:function(){return new e.Rectangle(this.x-this.radius,this.y-this.radius,this.diameter,this.diameter)},setTo:function(t,e,i){return this.x=t,this.y=e,this._diameter=i,this._radius=.5*i,this},copyFrom:function(t){return this.setTo(t.x,t.y,t.diameter)},copyTo:function(t){return t.x=this.x,t.y=this.y,t.diameter=this._diameter,t},distance:function(t,i){var s=e.Math.distance(this.x,this.y,t.x,t.y);return i?Math.round(s):s},clone:function(t){return void 0===t||null===t?t=new e.Circle(this.x,this.y,this.diameter):t.setTo(this.x,this.y,this.diameter),t},contains:function(t,i){return e.Circle.contains(this,t,i)},circumferencePoint:function(t,i,s){return e.Circle.circumferencePoint(this,t,i,s)},sample:function(t,i,s,n,r){t||(t=60),null==i&&(i=0),null==s&&(s=e.Math.PI2),r||(r=[]);for(var o=0;o0&&(this._diameter=t,this._radius=.5*t)}}),Object.defineProperty(e.Circle.prototype,"radius",{get:function(){return this._radius},set:function(t){t>0&&(this._radius=t,this._diameter=2*t)}}),Object.defineProperty(e.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(t){t>this.x?(this._radius=0,this._diameter=0):this.radius=this.x-t}}),Object.defineProperty(e.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(t){tthis.y?(this._radius=0,this._diameter=0):this.radius=this.y-t}}),Object.defineProperty(e.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(t){t0?Math.PI*this._radius*this._radius:0}}),Object.defineProperty(e.Circle.prototype,"empty",{get:function(){return 0===this._diameter},set:function(t){!0===t&&this.setTo(0,0,0)}}),e.Circle.contains=function(t,e,i){return t.radius>0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius},e.Circle.equals=function(t,e){return t.x===e.x&&t.y===e.y&&t.diameter===e.diameter},e.Circle.intersects=function(t,i){return e.Math.distance(t.x,t.y,i.x,i.y)<=t.radius+i.radius},e.Circle.circumferencePoint=function(t,i,s,n){return void 0===s&&(s=!1),void 0===n&&(n=new e.Point),!0===s&&(i=e.Math.degToRad(i)),n.x=t.x+t.radius*Math.cos(i),n.y=t.y+t.radius*Math.sin(i),n},e.Circle.intersectsRectangle=function(t,e){var i=Math.abs(t.x-e.x-e.halfWidth);if(i>e.halfWidth+t.radius)return!1;var s=Math.abs(t.y-e.y-e.halfHeight);if(s>e.halfHeight+t.radius)return!1;if(i<=e.halfWidth||s<=e.halfHeight)return!0;var n=i-e.halfWidth,r=s-e.halfHeight;return n*n+r*r<=t.radius*t.radius},e.Circle.intersectsLine=function(t,i,s){var n=t.x,r=t.y,o=(i.end.y-i.start.y)/(i.end.x-i.start.x),a=i.end.y-o*i.end.x,h=t.radius,l=t.radius,c=a+o*n,u=(n*(l*l)-o*(h*h)*(a-r)+h*l*Math.sqrt(h*h*(o*o)+l*l-c*c-r*r+2*c*r))/(h*h*(o*o)+l*l),d=(n*(l*l)-o*(h*h)*(a-r)-h*l*Math.sqrt(h*h*(o*o)+l*l-c*c-r*r+2*c*r))/(h*h*(o*o)+l*l),p=o*u+a,f=o*d+a,g=new e.Point(u,p),m=new e.Point(d,f),y=i.pointOnSegment(g.x,g.y,.01),v=i.pointOnSegment(m.x,m.y,.01);return y&&v?!s||[g,m]:y?!s||[g]:v?!s||[m]:!!s&&[]},PIXI.Circle=e.Circle,e.Ellipse=function(t,i,s,n){t=t||0,i=i||0,s=s||0,n=n||0,this.x=t,this.y=i,this.width=s,this.height=n,this.type=e.ELLIPSE},e.Ellipse.prototype={setTo:function(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this},getBounds:function(){return new e.Rectangle(this.x-this.width,this.y-this.height,this.width,this.height)},copyFrom:function(t){return this.setTo(t.x,t.y,t.width,t.height)},copyTo:function(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t},clone:function(t){return void 0===t||null===t?t=new e.Ellipse(this.x,this.y,this.width,this.height):t.setTo(this.x,this.y,this.width,this.height),t},contains:function(t,i){return e.Ellipse.contains(this,t,i)},random:function(t){void 0===t&&(t=new e.Point);var i=Math.random()*Math.PI*2,s=Math.sqrt(Math.random());return t.x=this.centerX+.5*s*Math.cos(i)*this.width,t.y=this.centerY+.5*s*Math.sin(i)*this.height,t},toString:function(){return"[{Phaser.Ellipse (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")}]"}},e.Ellipse.prototype.constructor=e.Ellipse,Object.defineProperty(e.Ellipse.prototype,"left",{get:function(){return this.x},set:function(t){this.x=t}}),Object.defineProperty(e.Ellipse.prototype,"right",{get:function(){return this.x+this.width},set:function(t){t=s&&t<=n&&e>=r&&e<=o},random:function(t){void 0===t&&(t=new e.Point);var i=Math.random();return t.x=this.start.x+i*(this.end.x-this.start.x),t.y=this.start.y+i*(this.end.y-this.start.y),t},coordinatesOnLine:function(t,e){void 0===t&&(t=1),void 0===e&&(e=[]);var i=Math.round(this.start.x),s=Math.round(this.start.y),n=Math.round(this.end.x),r=Math.round(this.end.y),o=Math.abs(n-i),a=Math.abs(r-s),h=i-a&&(c-=a,i+=h),d=0&&g<=1&&m>=0&&m<=1?o:null}return o},e.Line.intersects=function(t,i,s,n){return e.Line.intersectsPoints(t.start,t.end,i.start,i.end,s,n)},e.Line.intersectsRectangle=function(t,e){if(0===t.length||e.empty)return!1;var i=t.start.x,s=t.start.y,n=t.end.x,r=t.end.y,o=e.x,a=e.y,h=e.right,l=e.bottom,c=0;if(i>=o&&i<=h&&s>=a&&s<=l||n>=o&&n<=h&&r>=a&&r<=l)return!0;if(i=o){if((c=s+(r-s)*(o-i)/(n-i))>a&&c<=l)return!0}else if(i>h&&n<=h&&(c=s+(r-s)*(h-i)/(n-i))>=a&&c<=l)return!0;if(s=a){if((c=i+(n-i)*(a-s)/(r-s))>=o&&c<=h)return!0}else if(s>l&&r<=l&&(c=i+(n-i)*(l-s)/(r-s))>=o&&c<=h)return!0;return!1},e.Line.intersectionWithRectangle=function(t,i,s){var n=e.Line.intersectionWithRectangle;s||(s=new e.Point),n.edges||(n.edges=[new e.Line,new e.Line,new e.Line,new e.Line]),n.edgeIntersection||(n.edgeIntersection=new e.Point);var r=n.edges,o=n.edgeIntersection.set(0),a=i.x,h=i.y,l=i.right,c=i.bottom,u=1/0;r[0].setTo(a,h,l,h),r[1].setTo(a,c,l,c),r[2].setTo(a,h,a,c),r[3].setTo(l,h,l,c);for(var d,p=0;d=r[p];p++)if(t.intersects(d,!0,o)){var f=t.start.distance(o);fs&&(this.x=s),this.yn&&(this.y=n),this},clone:function(t){return void 0===t||null===t?t=new e.Point(this.x,this.y):t.setTo(this.x,this.y),t},copyTo:function(t){return t.x=this.x,t.y=this.y,t},distance:function(t,i){return e.Point.distance(this,t,i)},equals:function(t){return t.x===this.x&&t.y===this.y},equalsXY:function(t,e){return this.x===t&&this.y===e},fuzzyEquals:function(t,i){return e.Point.fuzzyEquals(this,t,i)},fuzzyEqualsXY:function(t,i,s){return e.Point.fuzzyEqualsXY(this,t,i,s)},angle:function(t,e){return this.angleXY(t.x,t.y,e)},angleXY:function(t,i,s){var n=Math.atan2(i-this.y,t-this.x);return s?e.Math.radToDeg(n):n},atan:function(t){var i=Math.atan2(this.y,this.x);return t?e.Math.radToDeg(i):i},rotate:function(t,i,s,n,r){return e.Point.rotate(this,t,i,s,n,r)},getMagnitude:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},getMagnitudeSq:function(){return this.x*this.x+this.y*this.y},setMagnitude:function(t){return this.normalize().multiply(t,t)},normalize:function(){if(!this.isZero()){var t=this.getMagnitude();this.x/=t,this.y/=t}return this},limit:function(t){return this.getMagnitudeSq()>t*t&&this.setMagnitude(t),this},expand:function(t){return this.getMagnitudeSq()=0&&e.x-i<0)return-1;if(t.x-i<0&&e.x-i>=0)return 1;if(t.x-i==0&&e.x-i==0)return t.y-s>=0||e.y-s>=0?t.y>e.y?1:-1:e.y>t.y?1:-1;var n=(t.x-i)*-(e.y-s)-(e.x-i)*-(t.y-s);return n<0?-1:n>0?1:(t.x-i)*(t.x-i)+(t.y-s)*(t.y-s)>(e.x-i)*(e.x-i)+(e.y-s)*(e.y-s)?-1:1})},PIXI.Point=e.Point,e.Polygon=function(){this.area=0,this._points=[],arguments.length>0&&this.setTo.apply(this,arguments),this.closed=!0,this.flattened=!1,this.type=e.POLYGON},e.Polygon.prototype={toNumberArray:function(t){void 0===t&&(t=[]);for(var e=0;e0){Array.isArray(t)||(t=Array.prototype.slice.call(arguments));for(var e=Number.MAX_VALUE,i=0,s=t.length;i=this.right?this.width=0:this.width=this.right-t,this.x=t}}),Object.defineProperty(e.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}}),Object.defineProperty(e.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}}),Object.defineProperty(e.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}}),Object.defineProperty(e.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(t){this.x=t-this.halfWidth}}),Object.defineProperty(e.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(t){this.y=t-this.halfHeight}}),Object.defineProperty(e.Rectangle.prototype,"randomX",{get:function(){return this.x+Math.random()*this.width}}),Object.defineProperty(e.Rectangle.prototype,"randomY",{get:function(){return this.y+Math.random()*this.height}}),Object.defineProperty(e.Rectangle.prototype,"top",{get:function(){return this.y},set:function(t){t>=this.bottom?(this.height=0,this.y=t):this.height=this.bottom-t}}),Object.defineProperty(e.Rectangle.prototype,"topLeft",{get:function(){return new e.Point(this.x,this.y)},set:function(t){this.x=t.x,this.y=t.y}}),Object.defineProperty(e.Rectangle.prototype,"topRight",{get:function(){return new e.Point(this.x+this.width,this.y)},set:function(t){this.right=t.x,this.y=t.y}}),Object.defineProperty(e.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(t){!0===t&&this.setTo(0,0,0,0)}}),e.Rectangle.prototype.constructor=e.Rectangle,e.Rectangle.inflate=function(t,e,i){return t.x-=e,t.width+=2*e,t.y-=i,t.height+=2*i,t},e.Rectangle.inflatePoint=function(t,i){return e.Rectangle.inflate(t,i.x,i.y)},e.Rectangle.size=function(t,i){return void 0===i||null===i?i=new e.Point(t.width,t.height):i.setTo(t.width,t.height),i},e.Rectangle.clone=function(t,i){return void 0===i||null===i?i=new e.Rectangle(t.x,t.y,t.width,t.height):i.setTo(t.x,t.y,t.width,t.height),i},e.Rectangle.createFromBounds=function(t,i){return void 0!==i&&null!==i||(i=new e.Rectangle(t.x,t.y,t.width,t.height)),i.copyFromBounds(t)},e.Rectangle.contains=function(t,e,i){return!(t.width<=0||t.height<=0)&&(e>=t.x&&e=t.y&&i=t&&n=e&&re.volume)&&(t.x>=e.x&&t.y>=e.y&&t.righte.right||t.y>e.bottom)},e.Rectangle.intersectsRaw=function(t,e,i,s,n,r){return void 0===r&&(r=0),!(e>t.right+r||it.bottom+r||ns&&(s=t.x),t.xr&&(r=t.y),t.y=i&&t<=i+this.width){var s=this.y;if(e>=s&&e<=s+this.height)return!0}return!1}},e.RoundedRectangle.prototype.constructor=e.RoundedRectangle,PIXI.RoundedRectangle=e.RoundedRectangle,e.Camera=function(t,i,s,n,r,o){this.game=t,this.world=t.world,this.id=0,this.view=new e.Rectangle(s,n,r,o),this.bounds=new e.Rectangle(s,n,r,o),this.deadzone=null,this.visible=!0,this.roundPx=!0,this.atLimit={x:!1,y:!1},this.target=null,this.displayObject=null,this.scale=null,this.totalInView=0,this.lerp=new e.Point(1,1),this.onShakeComplete=new e.Signal,this.onFlashComplete=new e.Signal,this.onFadeComplete=new e.Signal,this.fx=null,this._targetPosition=new e.Point,this._edge=0,this._position=new e.Point,this._shake={intensity:0,duration:0,horizontal:!1,vertical:!1,shakeBounds:!0,x:0,y:0},this._fxDuration=0,this._fxType=0,this._fixedView=new e.Rectangle},e.Camera.FOLLOW_LOCKON=0,e.Camera.FOLLOW_PLATFORMER=1,e.Camera.FOLLOW_TOPDOWN=2,e.Camera.FOLLOW_TOPDOWN_TIGHT=3,e.Camera.SHAKE_BOTH=4,e.Camera.SHAKE_HORIZONTAL=5,e.Camera.SHAKE_VERTICAL=6,e.Camera.ENABLE_FX=!0,e.Camera.prototype={boot:function(){this.displayObject=this.game.world,this.scale=this.game.world.scale,this.game.camera=this,e.Graphics&&e.Camera.ENABLE_FX&&(this.fx=new e.Graphics(this.game),this.game.stage.addChild(this.fx))},preUpdate:function(){this.totalInView=0},follow:function(t,i,s,n){void 0===i&&(i=e.Camera.FOLLOW_LOCKON),void 0===s&&(s=1),void 0===n&&(n=1),this.target=t,this.lerp.set(s,n);var r;switch(i){case e.Camera.FOLLOW_PLATFORMER:var o=this.width/8,a=this.height/3;this.deadzone=new e.Rectangle((this.width-o)/2,(this.height-a)/2-.25*a,o,a);break;case e.Camera.FOLLOW_TOPDOWN:r=Math.max(this.width,this.height)/4,this.deadzone=new e.Rectangle((this.width-r)/2,(this.height-r)/2,r,r);break;case e.Camera.FOLLOW_TOPDOWN_TIGHT:r=Math.max(this.width,this.height)/8,this.deadzone=new e.Rectangle((this.width-r)/2,(this.height-r)/2,r,r);break;case e.Camera.FOLLOW_LOCKON:default:this.deadzone=null}},unfollow:function(){this.target=null},focusOn:function(t){this.setPosition(Math.round(t.x-this.view.halfWidth),Math.round(t.y-this.view.halfHeight))},focusOnXY:function(t,e){this.setPosition(Math.round(t-this.view.halfWidth),Math.round(e-this.view.halfHeight))},shake:function(t,i,s,n,r){return void 0===t&&(t=.05),void 0===i&&(i=500),void 0===s&&(s=!0),void 0===n&&(n=e.Camera.SHAKE_BOTH),void 0===r&&(r=!0),!(!s&&this._shake.duration>0)&&(this._shake.intensity=t,this._shake.duration=i,this._shake.shakeBounds=r,this._shake.x=0,this._shake.y=0,this._shake.horizontal=n===e.Camera.SHAKE_BOTH||n===e.Camera.SHAKE_HORIZONTAL,this._shake.vertical=n===e.Camera.SHAKE_BOTH||n===e.Camera.SHAKE_VERTICAL,!0)},flash:function(t,e,i,s){return void 0===t&&(t=16777215),void 0===e&&(e=500),void 0===i&&(i=!1),void 0===s&&(s=1),!(!this.fx||!i&&this._fxDuration>0)&&(this.fx.clear(),this.fx.beginFill(t,s),this.fx.drawRect(0,0,this.width,this.height),this.fx.endFill(),this.fx.alpha=1,this._fxDuration=e,this._fxType=0,!0)},fade:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=500),void 0===i&&(i=!1),void 0===s&&(s=1),!(!this.fx||!i&&this._fxDuration>0)&&(this.fx.clear(),this.fx.beginFill(t,s),this.fx.drawRect(0,0,this.width,this.height),this.fx.endFill(),this.fx.alpha=0,this._fxDuration=e,this._fxType=1,!0)},update:function(){this._fxDuration>0&&this.updateFX(),this._shake.duration>0&&this.updateShake(),this.bounds&&this.checkBounds(),this.roundPx&&(this.view.floor(),this._shake.x=Math.floor(this._shake.x),this._shake.y=Math.floor(this._shake.y)),this.displayObject.position.x=-this.view.x,this.displayObject.position.y=-this.view.y},updateFX:function(){0===this._fxType?(this.fx.alpha-=this.game.time.elapsedMS/this._fxDuration,this.fx.alpha<=0&&(this._fxDuration=0,this.fx.alpha=0,this.onFlashComplete.dispatch())):(this.fx.alpha+=this.game.time.elapsedMS/this._fxDuration,this.fx.alpha>=1&&(this._fxDuration=0,this.fx.alpha=1,this.onFadeComplete.dispatch()))},updateShake:function(){this._shake.duration-=this.game.time.elapsedMS,this._shake.duration<=0?(this.onShakeComplete.dispatch(),this._shake.x=0,this._shake.y=0):(this._shake.horizontal&&(this._shake.x=this.game.rnd.frac()*this._shake.intensity*this.view.width*2-this._shake.intensity*this.view.width),this._shake.vertical&&(this._shake.y=this.game.rnd.frac()*this._shake.intensity*this.view.height*2-this._shake.intensity*this.view.height))},updateTarget:function(){this._targetPosition.x=this.view.x+this.target.worldPosition.x,this._targetPosition.y=this.view.y+this.target.worldPosition.y,this.deadzone?(this._edge=this._targetPosition.x-this.view.x,this._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 t=this.view.x+this._shake.x,e=this.view.right+this._shake.x,i=this.view.y+this._shake.y,s=this.view.bottom+this._shake.y;t<=this.bounds.x*this.scale.x?(this.atLimit.x=!0,this.view.x=this.bounds.x*this.scale.x,this._shake.shakeBounds||(this._shake.x=0)):e>=this.bounds.right*this.scale.x&&(this.atLimit.x=!0,this.view.x=this.bounds.right*this.scale.x-this.width,this._shake.shakeBounds||(this._shake.x=0)),i<=this.bounds.top*this.scale.y?(this.atLimit.y=!0,this.view.y=this.bounds.top*this.scale.y,this._shake.shakeBounds||(this._shake.y=0)):s>=this.bounds.bottom*this.scale.y&&(this.atLimit.y=!0,this.view.y=this.bounds.bottom*this.scale.y-this.height,this._shake.shakeBounds||(this._shake.y=0))},setPosition:function(t,e){this.view.x=t,this.view.y=e,this.bounds&&this.checkBounds()},setSize:function(t,e){this.view.width=t,this.view.height=e},reset:function(){this.target=null,this.view.x=0,this.view.y=0,this._shake.duration=0,this._shake.x=0,this._shake.y=0,this.resetFX()},resetFX:function(){this.fx&&(this.fx.clear(),this.fx.alpha=0),this._fxDuration=0}},e.Camera.prototype.constructor=e.Camera,Object.defineProperty(e.Camera.prototype,"x",{get:function(){return this.view.x},set:function(t){this.view.x=t,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"y",{get:function(){return this.view.y},set:function(t){this.view.y=t,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"position",{get:function(){return this._position.set(this.view.x,this.view.y),this._position},set:function(t){void 0!==t.x&&(this.view.x=t.x),void 0!==t.y&&(this.view.y=t.y),this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"width",{get:function(){return this.view.width},set:function(t){this.view.width=t}}),Object.defineProperty(e.Camera.prototype,"height",{get:function(){return this.view.height},set:function(t){this.view.height=t}}),Object.defineProperty(e.Camera.prototype,"shakeIntensity",{get:function(){return this._shake.intensity},set:function(t){this._shake.intensity=t}}),Object.defineProperty(e.Camera.prototype,"fixedView",{get:function(){return this._fixedView.setTo(0,0,this.view.width,this.view.height),this._fixedView}}),Object.defineProperty(e.Camera.prototype,"centerX",{get:function(){return this.x+.5*this.width}}),Object.defineProperty(e.Camera.prototype,"centerY",{get:function(){return this.y+.5*this.height}}),e.State=function(){this.game=null,this.key="",this.add=null,this.make=null,this.camera=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.sound=null,this.scale=null,this.stage=null,this.state=null,this.time=null,this.tweens=null,this.world=null,this.particles=null,this.physics=null,this.rnd=null},e.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(){}},e.State.prototype.constructor=e.State,e.StateManager=function(t,i){this.game=t,this.states={},this._pendingState=null,void 0!==i&&null!==i&&(this._pendingState=i),this._clearWorld=!1,this._clearCache=!1,this._created=!1,this._args=[],this.current="",this.onStateChange=new e.Signal,this.onInitCallback=null,this.onPreloadCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPreRenderCallback=null,this.onLoadUpdateCallback=null,this.onLoadRenderCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null,this.onShutDownCallback=null},e.StateManager.prototype={boot:function(){this.game.onPause.add(this.pause,this),this.game.onResume.add(this.resume,this),null!==this._pendingState&&"string"!=typeof this._pendingState&&this.add("default",this._pendingState,!0)},add:function(t,i,s){void 0===s&&(s=!1);var n;return i instanceof e.State?n=i:"object"==typeof i?(n=i).game=this.game:"function"==typeof i&&(n=new i(this.game)),this.states[t]=n,s&&(this.game.isBooted?this.start(t):this._pendingState=t),n},remove:function(t){this.current===t&&(this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onPreRenderCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null),delete this.states[t]},start:function(t,e,i){void 0===e&&(e=!0),void 0===i&&(i=!1),this.checkState(t)&&(this._pendingState=t,this._clearWorld=e,this._clearCache=i,arguments.length>3&&(this._args=Array.prototype.splice.call(arguments,3)))},restart:function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!1),this._pendingState=this.current,this._clearWorld=t,this._clearCache=e,arguments.length>2&&(this._args=Array.prototype.slice.call(arguments,2))},dummy:function(){},preUpdate:function(){if(this._pendingState&&this.game.isBooted){var t=this.current;if(this.clearCurrentState(),this.setCurrentState(this._pendingState),this.onStateChange.dispatch(this.current,t),this.current!==this._pendingState)return;this._pendingState=null,this.onPreloadCallback?(this.game.load.reset(!0),this.onPreloadCallback.call(this.callbackContext,this.game),0===this.game.load.totalQueuedFiles()&&0===this.game.load.totalQueuedPacks()?this.loadComplete():this.game.load.start()):this.loadComplete()}},clearCurrentState:function(){this.current&&(this.onShutDownCallback&&this.onShutDownCallback.call(this.callbackContext,this.game),this.game.tweens.removeAll(),this.game.camera.reset(),this.game.input.reset(!0),this.game.physics.clear(),this.game.time.removeAll(),this.game.scale.reset(this._clearWorld),this.game.debug&&this.game.debug.reset(),this._clearWorld&&(this.game.world.shutdown(),this._clearCache&&this.game.cache.destroy()))},checkState:function(t){var e=this.states[t];return e?!!(e.preload||e.create||e.update||e.render)||(console.warn("Invalid Phaser State object given. Must contain at least one of the required functions: preload, create, update or render"),!1):(console.warn("Phaser.StateManager - No state found with the key: "+t),!1)},link:function(t){var e=this.states[t];e.game=this.game,e.add=this.game.add,e.make=this.game.make,e.camera=this.game.camera,e.cache=this.game.cache,e.input=this.game.input,e.load=this.game.load,e.math=this.game.math,e.sound=this.game.sound,e.scale=this.game.scale,e.state=this,e.stage=this.game.stage,e.time=this.game.time,e.tweens=this.game.tweens,e.world=this.game.world,e.particles=this.game.particles,e.rnd=this.game.rnd,e.physics=this.game.physics,e.key=t},unlink:function(t){var e=this.states[t];e&&(e.game=null,e.add=null,e.make=null,e.camera=null,e.cache=null,e.input=null,e.load=null,e.math=null,e.sound=null,e.scale=null,e.state=null,e.stage=null,e.time=null,e.tweens=null,e.world=null,e.particles=null,e.rnd=null,e.physics=null)},setCurrentState:function(t){var e=this.states[t];this.callbackContext=e,this.link(t),this.onInitCallback=e.init||this.dummy,this.onPreloadCallback=e.preload||null,this.onLoadRenderCallback=e.loadRender||null,this.onLoadUpdateCallback=e.loadUpdate||null,this.onCreateCallback=e.create||null,this.onUpdateCallback=e.update||null,this.onPostUpdateCallback=e.postUpdate||null,this.onPreRenderCallback=e.preRender||null,this.onRenderCallback=e.render||null,this.onResizeCallback=e.resize||null,this.onPausedCallback=e.paused||null,this.onResumedCallback=e.resumed||null,this.onPauseUpdateCallback=e.pauseUpdate||null,this.onShutDownCallback=e.shutdown||this.dummy,""!==this.current&&this.game.physics.reset(),this.current=t,this._created=!1,this.onInitCallback.apply(this.callbackContext,this._args),t===this._pendingState&&(this._args=[]),this.game._kickstart=!0},getCurrentState:function(){return this.states[this.current]},loadComplete:function(){!1===this._created&&this.onCreateCallback?(this._created=!0,this.onCreateCallback.call(this.callbackContext,this.game)):this._created=!0},loadUpdate:function(){!1===this._created&&this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},pause:function(){this._created&&this.onPausedCallback&&this.onPausedCallback.call(this.callbackContext,this.game)},resume:function(){this._created&&this.onResumedCallback&&this.onResumedCallback.call(this.callbackContext,this.game)},update:function(){this._created?this.onUpdateCallback&&this.onUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},postUpdate:function(){this._created&&this.onPostUpdateCallback&&this.onPostUpdateCallback.call(this.callbackContext,this.game)},pauseUpdate:function(){this._created?this.onPauseUpdateCallback&&this.onPauseUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},preRender:function(t){this._created&&this.onPreRenderCallback&&this.onPreRenderCallback.call(this.callbackContext,this.game,t)},resize:function(t,e){this.onResizeCallback&&this.onResizeCallback.call(this.callbackContext,t,e)},render:function(){this._created?this.onRenderCallback&&(this.game.renderType===e.CANVAS?(this.game.context.save(),this.game.context.setTransform(1,0,0,1,0,0),this.onRenderCallback.call(this.callbackContext,this.game),this.game.context.restore()):this.onRenderCallback.call(this.callbackContext,this.game)):this.onLoadRenderCallback&&this.onLoadRenderCallback.call(this.callbackContext,this.game)},destroy:function(){this._clearWorld=!0,this._clearCache=!0,this.clearCurrentState(),this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onPostUpdateCallback=null,this.onRenderCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null,this.game=null,this.states={},this._pendingState=null,this.current=""}},e.StateManager.prototype.constructor=e.StateManager,Object.defineProperty(e.StateManager.prototype,"created",{get:function(){return this._created}}),e.Signal=function(){},e.Signal.prototype={_bindings:null,_prevParams:null,memorize:!1,_shouldPropagate:!0,active:!0,_boundDispatch:!1,validateListener:function(t,e){if("function"!=typeof t)throw new Error("Phaser.Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}",e))},_registerListener:function(t,i,s,n,r){var o,a=this._indexOfListener(t,s);if(-1!==a){if((o=this._bindings[a]).isOnce()!==i)throw new Error("You cannot add"+(i?"":"Once")+"() then add"+(i?"Once":"")+"() the same listener without removing the relationship first.")}else o=new e.SignalBinding(this,t,i,s,n,r),this._addBinding(o);return this.memorize&&this._prevParams&&o.execute(this._prevParams),o},_addBinding:function(t){this._bindings||(this._bindings=[]);var e=this._bindings.length;do{e--}while(this._bindings[e]&&t._priority<=this._bindings[e]._priority);this._bindings.splice(e+1,0,t)},_indexOfListener:function(t,e){if(!this._bindings)return-1;void 0===e&&(e=null);for(var i,s=this._bindings.length;s--;)if((i=this._bindings[s])._listener===t&&i.context===e)return s;return-1},has:function(t,e){return-1!==this._indexOfListener(t,e)},add:function(t,e,i){this.validateListener(t,"add");var s=[];if(arguments.length>3)for(var n=3;n3)for(var n=3;n=this.children.length?-1:this.getChildAt(t)},e.Group.prototype.create=function(t,e,i,s,n,r){void 0===n&&(n=!0);var o=new this.classType(this.game,t,e,i,s);return o.exists=n,o.visible=n,o.alive=n,this.add(o,!1,r)},e.Group.prototype.createMultiple=function(t,e,i,s,n,r){void 0===i&&(i=0),void 0===s&&(s=!1),Array.isArray(e)||(e=[e]),Array.isArray(i)||(i=[i]);var o=this,a=[];return e.forEach(function(e){i.forEach(function(i){for(var h=0;hthis.children.length||-1===t&&-1===i)return!1;for(var a=new e.Rectangle(0,0,s,n),h=t*s,l=i*n,c=o;cthis.children.length-1&&(t=0),this.cursor)return this.cursorIndex=t,this.cursor=this.children[this.cursorIndex],this.cursor},e.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],this.cursor},e.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],this.cursor},e.Group.prototype.swap=function(t,e){this.swapChildren(t,e),this.updateZ()},e.Group.prototype.bringToTop=function(t){return t.parent===this&&this.getIndex(t)0&&(this.remove(t,!1,!0),this.addAt(t,0,!0)),t},e.Group.prototype.sendChildToBack=e.Group.prototype.sendToBack,e.Group.prototype.moveUp=function(t){if(t.parent===this&&this.getIndex(t)0){var e=this.getIndex(t),i=this.getAt(e-1);i&&this.swap(t,i)}return t},e.Group.prototype.xy=function(t,e,i){if(t<0||t>this.children.length)return-1;this.getChildAt(t).x=e,this.getChildAt(t).y=i},e.Group.prototype.reverse=function(){this.children.reverse(),this.updateZ()},e.Group.prototype.getIndex=function(t){return this.children.indexOf(t)},e.Group.prototype.getByName=function(t){return this.getFirst("name",t)},e.Group.prototype.replace=function(t,i){var s=this.getIndex(t);if(-1!==s)return i.parent&&(i.parent instanceof e.Group?i.parent.remove(i):i.parent.removeChild(i)),this.remove(t),this.addAt(i,s),t},e.Group.prototype.hasProperty=function(t,e){var i=e.length;return 1===i&&e[0]in t||(2===i&&e[0]in t&&e[1]in t[e[0]]||(3===i&&e[0]in t&&e[1]in t[e[0]]&&e[2]in t[e[0]][e[1]]||4===i&&e[0]in t&&e[1]in t[e[0]]&&e[2]in t[e[0]][e[1]]&&e[3]in t[e[0]][e[1]][e[2]]))},e.Group.prototype.setProperty=function(t,e,i,s,n){if(void 0===n&&(n=!1),s=s||0,!this.hasProperty(t,e)&&(!n||s>0))return!1;var r=e.length;return 1===r?0===s?t[e[0]]=i:1===s?t[e[0]]+=i:2===s?t[e[0]]-=i:3===s?t[e[0]]*=i:4===s&&(t[e[0]]/=i):2===r?0===s?t[e[0]][e[1]]=i:1===s?t[e[0]][e[1]]+=i:2===s?t[e[0]][e[1]]-=i:3===s?t[e[0]][e[1]]*=i:4===s&&(t[e[0]][e[1]]/=i):3===r?0===s?t[e[0]][e[1]][e[2]]=i:1===s?t[e[0]][e[1]][e[2]]+=i:2===s?t[e[0]][e[1]][e[2]]-=i:3===s?t[e[0]][e[1]][e[2]]*=i:4===s&&(t[e[0]][e[1]][e[2]]/=i):4===r&&(0===s?t[e[0]][e[1]][e[2]][e[3]]=i:1===s?t[e[0]][e[1]][e[2]][e[3]]+=i:2===s?t[e[0]][e[1]][e[2]][e[3]]-=i:3===s?t[e[0]][e[1]][e[2]][e[3]]*=i:4===s&&(t[e[0]][e[1]][e[2]][e[3]]/=i)),!0},e.Group.prototype.checkProperty=function(t,i,s,n){if(void 0===n&&(n=!1),this!==t.parent)return!1;var r=e.Utils.getProperty(t,i);return!(void 0===r&&n||r!==s)},e.Group.prototype.set=function(t,e,i,s,n,r,o){if(void 0===o&&(o=!1),e=e.split("."),void 0===s&&(s=!1),void 0===n&&(n=!1),(!1===s||s&&t.alive)&&(!1===n||n&&t.visible))return this.setProperty(t,e,i,r,o)},e.Group.prototype.setAll=function(t,e,i,s,n,r){void 0===i&&(i=!1),void 0===s&&(s=!1),void 0===r&&(r=!1),t=t.split("."),n=n||0;for(var o=this.children.length,a=0;a2){i=[];for(s=2;s2){n=[];for(a=2;a=e&&(t=e-1);var i=this.children[t];this.updateOnlyExistingChildren&&!i.exists||i.update()}},e.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 t=0;t2){s=[null];for(var n=2;n2){s=[null];for(var n=2;n2){s=[null];for(var n=2;ne[this._sortProperty]?1:t.ze[this._sortProperty]?-1:0},e.Group.prototype.iterate=function(t,i,s,n,r,o){if(0===this.children.length){if(s===e.Group.RETURN_TOTAL)return 0;if(s===e.Group.RETURN_ALL)return[]}var a=0;if(s===e.Group.RETURN_ALL)var h=[];for(var l=0;l0)return this.children[this.children.length-1]},e.Group.prototype.getBottom=function(){if(this.children.length>0)return this.children[0]},e.Group.prototype.getClosestTo=function(t,i,s){for(var n=Number.MAX_VALUE,r=0,o=null,a=0;an&&(!i||i.call(s,h,r))&&(n=r,o=h)}return o},e.Group.prototype.count=function(t,i){return this.iterate(t,i,e.Group.RETURN_TOTAL)},e.Group.prototype.countLiving=function(){return this.count("alive",!0)},e.Group.prototype.countDead=function(){return this.count("alive",!1)},e.Group.prototype.getRandom=function(t,i){return void 0===t&&(t=0),void 0===i&&(i=this.children.length),0===i?null:e.ArrayUtils.getRandomItem(this.children,t,i)},e.Group.prototype.getRandomExists=function(t,e){var i=this.getAll("exists",!0,t,e);return this.game.rnd.pick(i)},e.Group.prototype.getAll=function(t,e,i,s){void 0===i&&(i=0),void 0===s&&(s=this.children.length);for(var n=[],r=i;r0&&t instanceof e.Group){do{t.add(this.children[0],i)}while(this.children.length>0);this.hash=[],this.cursor=null}return t},e.Group.prototype.removeAll=function(t,e,i){if(void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===i&&(i=!1),0!==this.children.length){do{!e&&this.children[0].events&&this.children[0].events.onRemovedFromGroup$dispatch(this.children[0],this);var s=this.removeChild(this.children[0]);this.removeFromHash(s),t&&s&&s.destroy(!0,i)}while(this.children.length>0);this.hash=[],this.cursor=null}},e.Group.prototype.removeBetween=function(t,e,i,s){if(void 0===e&&(e=this.children.length-1),void 0===i&&(i=!1),void 0===s&&(s=!1),0!==this.children.length){if(t>e||t<0||e>this.children.length)return!1;for(var n=e;n>=t;){!s&&this.children[n].events&&this.children[n].events.onRemovedFromGroup$dispatch(this.children[n],this);var r=this.removeChild(this.children[n]);this.removeFromHash(r),i&&r&&r.destroy(!0),this.cursor===this.children[n]&&(this.cursor=null),n--}this.updateZ()}},e.Group.prototype.scatter=function(t,e){null==t&&(t=this.game.world.bounds),this.forEach(function(e){e.position.set(t.randomX,t.randomY)},null,e)},e.Group.prototype.shuffle=function(){e.ArrayUtils.shuffle(this.children),this.updateZ()},e.Group.prototype.destroy=function(t,e){null===this.game||this.ignoreDestroy||(void 0===t&&(t=!0),void 0===e&&(e=!1),this.onDestroy.dispatch(this,t,e),this.removeAll(t),this.cursor=null,this.filters=null,this.pendingDestroy=!1,e||(this.parent&&this.parent.removeChild(this),this.game=null,this.exists=!1))},Object.defineProperty(e.Group.prototype,"total",{get:function(){return this.iterate("exists",!0,e.Group.RETURN_TOTAL)}}),Object.defineProperty(e.Group.prototype,"length",{get:function(){return this.children.length}}),Object.defineProperty(e.Group.prototype,"angle",{get:function(){return e.Math.radToDeg(this.rotation)},set:function(t){this.rotation=e.Math.degToRad(t)}}),Object.defineProperty(e.Group.prototype,"centerX",{get:function(){return this.getBounds(this.parent).centerX},set:function(t){var e=this.getBounds(this.parent),i=this.x-e.x;this.x=t+i-e.halfWidth}}),Object.defineProperty(e.Group.prototype,"centerY",{get:function(){return this.getBounds(this.parent).centerY},set:function(t){var e=this.getBounds(this.parent),i=this.y-e.y;this.y=t+i-e.halfHeight}}),Object.defineProperty(e.Group.prototype,"left",{get:function(){return this.getBounds(this.parent).left},set:function(t){var e=this.getBounds(this.parent),i=this.x-e.x;this.x=t+i}}),Object.defineProperty(e.Group.prototype,"right",{get:function(){return this.getBounds(this.parent).right},set:function(t){var e=this.getBounds(this.parent),i=this.x-e.x;this.x=t+i-e.width}}),Object.defineProperty(e.Group.prototype,"top",{get:function(){return this.getBounds(this.parent).top},set:function(t){var e=this.getBounds(this.parent),i=this.y-e.y;this.y=t+i}}),Object.defineProperty(e.Group.prototype,"bottom",{get:function(){return this.getBounds(this.parent).bottom},set:function(t){var e=this.getBounds(this.parent),i=this.y-e.y;this.y=t+i-e.height}}),e.World=function(t){e.Group.call(this,t,null,"__world",!1),this.bounds=new e.Rectangle(0,0,t.width,t.height),this.camera=null,this._definedSize=!1,this._width=t.width,this._height=t.height,this.game.state.onStateChange.add(this.stateChange,this)},e.World.prototype=Object.create(e.Group.prototype),e.World.prototype.constructor=e.World,e.World.prototype.boot=function(){this.camera=new e.Camera(this.game,0,0,0,this.game.width,this.game.height),this.game.stage.addChild(this),this.camera.boot()},e.World.prototype.stateChange=function(){this.x=0,this.y=0,this.camera.reset()},e.World.prototype.setBounds=function(t,e,i,s){this._definedSize=!0,this._width=i,this._height=s,this.bounds.setTo(t,e,i,s),this.x=t,this.y=e,this.camera.bounds&&this.camera.bounds.setTo(t,e,Math.max(i,this.game.width),Math.max(s,this.game.height)),this.game.physics.setBoundsToWorld()},e.World.prototype.resize=function(t,e){this._definedSize&&(tthis.bounds.right&&(t.x=this.bounds.left)),n&&(t.y+t._currentBounds.heightthis.bounds.bottom&&(t.y=this.bounds.top))):(s&&t.x+ethis.bounds.right&&(t.x=this.bounds.left-e),n&&t.y+ethis.bounds.bottom&&(t.y=this.bounds.top-e))},e.World.prototype.wrapAll=function(t,e,i,s,n,r){t.forEach(this.wrap,this,e,i,s,n,r)},Object.defineProperty(e.World.prototype,"width",{get:function(){return this.bounds.width},set:function(t){t1&&!this.forceSingleUpdate)this.time.time>this._nextFpsNotification&&(this._nextFpsNotification=this.time.time+1e4,this.fpsProblemNotifier.dispatch()),this._deltaTime=0,this._spiraling=0,this.dropFrames?this.rendersThisFrame=0:(this.updateRender(this.time.slowMotion*this.time.desiredFps),this.rendersThisFrame=1);else{var i=1e3*this.time.slowMotion/this.time.desiredFps;this._deltaTime+=Math.max(Math.min(3*i,this.time.elapsed),0);var s=0;for(this.updatesThisFrame=Math.floor(this._deltaTime/i),this.forceSingleUpdate&&(this.updatesThisFrame=Math.min(1,this.updatesThisFrame)),this.forceSingleRender?this.rendersThisFrame=1:this.rendersThisFrame=Math.min(1,this.updatesThisFrame);this._deltaTime>=i&&(this._deltaTime-=i,this.currentUpdateID=s,this.updateLogic(this.time.desiredFpsMult),s++,!this.forceSingleUpdate||1!==s);)this.time.refresh();s>this._lastCount?this._spiraling++:s0&&this.updateRender(this._deltaTime/i)}this.renderer.type===e.WEBGL&&this.renderer.gl.flush()}},updateLogic:function(t){this._paused||this.pendingStep?(this.scale.pauseUpdate(),this.state.pauseUpdate(t),this.debug.preUpdate(),this.input.pauseUpdate()):(this.stepping&&(this.pendingStep=!0),this.time.countUpdate(),this.scale.preUpdate(),this.debug.preUpdate(),this.camera.preUpdate(),this.physics.preUpdate(),this.state.preUpdate(t),this.plugins.preUpdate(t),this.stage.preUpdate(),this.state.update(),this.stage.update(),this.tweens.update(),this.sound.update(),this.input.update(),this.physics.update(),this.plugins.update(),this.stage.postUpdate(),this.state.postUpdate(),this.plugins.postUpdate()),this.stage.updateTransform()},updateRender:function(t){this.lockRender||this.renderType===e.HEADLESS||(this.time.countRender(),this.state.preRender(t),this.renderer.render(this.stage),this.plugins.render(t),this.state.render(t),this.plugins.postRender(t))},enableStep:function(){this.stepping=!0,this.pendingStep=!1,this.stepCount=0},disableStep:function(){this.stepping=!1,this.pendingStep=!1},step:function(){this.pendingStep=!1,this.stepCount++},destroy:function(){this.raf.stop(),this.debug.destroy(),this.state.destroy(),this.sound.destroy(),this.scale.destroy(),this.stage.destroy(),this.input.destroy(),this.physics.destroy(),this.plugins.destroy(),this.tweens.destroy(),this.debug=null,this.state=null,this.sound=null,this.scale=null,this.stage=null,this.input=null,this.physics=null,this.plugins=null,this.tweens=null,this.cache=null,this.load=null,this.time=null,this.world=null,this.isBooted=!1,this.renderer.destroy(!1),e.Canvas.removeFromDOM(this.canvas),PIXI.game===this&&(PIXI.game=null),PIXI.defaultRenderer=null,e.GAMES[this.id]=null},gamePaused:function(t){this._paused||(this._paused=!0,this.time.gamePaused(),this.sound.muteOnPause&&this.sound.setMute(),this.onPause.dispatch(t),this.device.cordova&&this.device.iOS&&(this.lockRender=!0))},gameResumed:function(t){this._paused&&!this._codePaused&&(this._paused=!1,this.time.gameResumed(),this.input.reset(),this.sound.muteOnPause&&this.sound.unsetMute(),this.onResume.dispatch(t),this.device.cordova&&this.device.iOS&&(this.lockRender=!1))},focusLoss:function(t){this.onBlur.dispatch(t),this.stage.disableVisibilityChange||this.gamePaused(t)},focusGain:function(t){this.focusWindow(),this.onFocus.dispatch(t),this.stage.disableVisibilityChange||this.gameResumed(t)},focusWindow:function(){window.focus&&(!window.PhaserGlobal||window.PhaserGlobal&&!window.PhaserGlobal.stopFocus)&&window.focus()}},e.Game.prototype.constructor=e.Game,Object.defineProperty(e.Game.prototype,"paused",{get:function(){return this._paused},set:function(t){!0===t?(!1===this._paused&&(this._paused=!0,this.sound.muteOnPause&&this.sound.setMute(),this.time.gamePaused(),this.onPause.dispatch(this)),this._codePaused=!0):(this._paused&&(this._paused=!1,this.input.reset(),this.sound.unsetMute(),this.time.gameResumed(),this.onResume.dispatch(this)),this._codePaused=!1)}}),e.Input=function(t){this.game=t,this.hitCanvas=null,this.hitContext=null,this.moveCallbacks=[],this.customCandidateHandler=null,this.customCandidateHandlerContext=null,this.pollRate=0,this.enabled=!0,this.multiInputOverride=e.Input.MOUSE_TOUCH_COMBINE,this.position=null,this.speed=null,this.circle=null,this.scale=null,this.maxPointers=-1,this.tapRate=200,this.doubleTapRate=300,this.holdRate=2e3,this.justPressedRate=200,this.justReleasedRate=200,this.recordPointerHistory=!1,this.recordRate=100,this.recordLimit=100,this.touchLockCallbacks=[],this.pointer1=null,this.pointer2=null,this.pointer3=null,this.pointer4=null,this.pointer5=null,this.pointer6=null,this.pointer7=null,this.pointer8=null,this.pointer9=null,this.pointer10=null,this.pointers=[],this.activePointer=null,this.mousePointer=null,this.mouse=null,this.keyboard=null,this.touch=null,this.mspointer=null,this.gamepad=null,this.resetLocked=!1,this.onDown=null,this.onUp=null,this.onTap=null,this.onHold=null,this.minPriorityID=0,this.interactiveItems=new e.ArraySet,this._localPoint=new e.Point,this._pollCounter=0,this._oldPosition=null,this._x=0,this._y=0},e.Input.MOUSE_OVERRIDES_TOUCH=0,e.Input.TOUCH_OVERRIDES_MOUSE=1,e.Input.MOUSE_TOUCH_COMBINE=2,e.Input.MAX_POINTERS=10,e.Input.prototype={boot:function(t){"maxPointers"in t&&(this.maxPointers=t.maxPointers),this.mousePointer=new e.Pointer(this.game,0,e.PointerMode.CURSOR),this.addPointer(),this.addPointer(),this.mouse=new e.Mouse(this.game),this.touch=new e.Touch(this.game),this.mspointer=new e.MSPointer(this.game),this.mouseWheel=new e.MouseWheel(this.game),this.pointerLock=new e.PointerLock(this.game),e.Keyboard&&(this.keyboard=new e.Keyboard(this.game)),e.Gamepad&&(this.gamepad=new e.Gamepad(this.game)),this.onDown=new e.Signal,this.onUp=new e.Signal,this.onTap=new e.Signal,this.onHold=new e.Signal,this.scale=new e.Point(1,1),this.speed=new e.Point,this.position=new e.Point,this._oldPosition=new e.Point,this.circle=new e.Circle(0,0,45),this.activePointer=this.mousePointer,this.hitCanvas=e.CanvasPool.create(this,1,1),this.hitContext=this.hitCanvas.getContext("2d"),this.game.device.mspointer&&!1!==t.mspointer?this.mspointer.start():this.game.device.touch&&!1!==t.touch&&this.touch.start(),this.mspointer.active||!1===t.mouse||this.mouse.start(),this.mousePointer.active=!0,!1!==t.mouseWheel&&this.mouseWheel.start(),!1!==t.pointerLock&&this.pointerLock.start(),this.keyboard&&!1!==t.keyboard&&this.keyboard.start();var i=this;this._onClickTrampoline=function(t){i.onClickTrampoline(t)},this.game.canvas.addEventListener("click",this._onClickTrampoline,!1)},destroy:function(){this.mouse.stop(),this.mouseWheel.stop(),this.touch.stop(),this.mspointer.stop(),this.pointerLock.stop(),this.keyboard&&this.keyboard.stop(),this.gamepad&&this.gamepad.stop(),this.moveCallbacks=[],e.CanvasPool.remove(this),this.game.canvas.removeEventListener("click",this._onClickTrampoline)},setInteractiveCandidateHandler:function(t,e){this.customCandidateHandler=t,this.customCandidateHandlerContext=e},addMoveCallback:function(t,e){this.moveCallbacks.push({callback:t,context:e})},addTouchLockCallback:function(t,e,i){void 0===i&&(i=!1),this.touchLockCallbacks.push({callback:t,context:e,onEnd:i})},removeTouchLockCallback:function(t,e){for(var i=this.touchLockCallbacks.length;i--;)if(this.touchLockCallbacks[i].callback===t&&this.touchLockCallbacks[i].context===e)return this.touchLockCallbacks.splice(i,1),!0;return!1},executeTouchLockCallbacks:function(t,e){for(var i=this.touchLockCallbacks.length;i--;){var s=this.touchLockCallbacks[i];s.onEnd===t&&s.callback.call(s.context,this,e)&&this.touchLockCallbacks.splice(i,1)}},deleteMoveCallback:function(t,e){for(var i=this.moveCallbacks.length;i--;)if(this.moveCallbacks[i].callback===t&&this.moveCallbacks[i].context===e)return void this.moveCallbacks.splice(i,1)},addPointer:function(){if(this.pointers.length>=e.Input.MAX_POINTERS)return console.warn("Phaser.Input.addPointer: Maximum limit of "+e.Input.MAX_POINTERS+" pointers reached."),null;var t=this.pointers.length+1,i=new e.Pointer(this.game,t,e.PointerMode.CONTACT);return this.pointers.push(i),this["pointer"+t]=i,i},update:function(){if(this.keyboard&&this.keyboard.update(),this.pollRate>0&&this._pollCounter=0&&this.countActivePointers(this.maxPointers)>=this.maxPointers)return null;if(!this.pointer1.active)return this.pointer1.start(t);if(!this.pointer2.active)return this.pointer2.start(t);for(var e=2;e0;i++)this.pointers[i].active&&e--;return t-e},getPointer:function(t){void 0===t&&(t=!1);for(var e=0;e=o&&this.game.camera.x+i.x=a&&this.game.camera.y+i.y=o&&this._localPoint.x=a&&this._localPoint.y=o&&this._localPoint.x=a&&this._localPoint.y0&&this._pollCounterthis.game.time.time},justReleased:function(t){return t=t||250,this.isUp&&this.timeUp+t>this.game.time.time},reset:function(){this.isDown=!1,this.isUp=!0,this.timeDown=this.game.time.time,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1},destroy:function(){this.onDown.dispose(),this.onUp.dispose(),this.onFloat.dispose(),this.parent=null,this.game=null}},e.DeviceButton.prototype.constructor=e.DeviceButton,Object.defineProperty(e.DeviceButton.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}}),e.Pointer=function(t,i,s){this.game=t,this.id=i,this.type=e.POINTER,this.exists=!0,this.identifier=0,this.pointerId=null,this.pointerMode=s||e.PointerMode.CURSOR|e.PointerMode.CONTACT,this.target=null,this.button=null,this.leftButton=new e.DeviceButton(this,e.Pointer.LEFT_BUTTON),this.middleButton=new e.DeviceButton(this,e.Pointer.MIDDLE_BUTTON),this.rightButton=new e.DeviceButton(this,e.Pointer.RIGHT_BUTTON),this.backButton=new e.DeviceButton(this,e.Pointer.BACK_BUTTON),this.forwardButton=new e.DeviceButton(this,e.Pointer.FORWARD_BUTTON),this.eraserButton=new e.DeviceButton(this,e.Pointer.ERASER_BUTTON),this._holdSent=!1,this._history=[],this._nextDrop=0,this._stateReset=!1,this.withinGame=!1,this.clientX=-1,this.clientY=-1,this.pageX=-1,this.pageY=-1,this.screenX=-1,this.screenY=-1,this.rawMovementX=0,this.rawMovementY=0,this.movementX=0,this.movementY=0,this.x=-1,this.y=-1,this.isMouse=0===i,this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.previousTapTime=0,this.totalTouches=0,this.msSinceLastClick=Number.MAX_VALUE,this.targetObject=null,this.interactiveCandidates=[],this.active=!1,this.dirty=!1,this.position=new e.Point,this.positionDown=new e.Point,this.positionUp=new e.Point,this.circle=new e.Circle(0,0,44),this._clickTrampolines=null,this._trampolineTargetObject=null},e.Pointer.NO_BUTTON=0,e.Pointer.LEFT_BUTTON=1,e.Pointer.RIGHT_BUTTON=2,e.Pointer.MIDDLE_BUTTON=4,e.Pointer.BACK_BUTTON=8,e.Pointer.FORWARD_BUTTON=16,e.Pointer.ERASER_BUTTON=32,e.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(t,i){switch(t){case e.Mouse.LEFT_BUTTON:this.leftButton.start(i);break;case e.Mouse.RIGHT_BUTTON:this.rightButton.start(i);break;case e.Mouse.MIDDLE_BUTTON:this.middleButton.start(i);break;case e.Mouse.BACK_BUTTON:this.backButton.start(i);break;case e.Mouse.FORWARD_BUTTON:this.forwardButton.start(i)}},processButtonsUp:function(t,i){switch(t){case e.Mouse.LEFT_BUTTON:this.leftButton.stop(i);break;case e.Mouse.RIGHT_BUTTON:this.rightButton.stop(i);break;case e.Mouse.MIDDLE_BUTTON:this.middleButton.stop(i);break;case e.Mouse.BACK_BUTTON:this.backButton.stop(i);break;case e.Mouse.FORWARD_BUTTON:this.forwardButton.stop(i)}},processButtonsUpDown:function(t,i){var s=i.type.toLowerCase().substr(-4),n="down"===s,r="move"===s;void 0!==t?(n&&1===t&&i.ctrlKey&&(t=2),this.leftButton.startStop(e.Pointer.LEFT_BUTTON&t,i),this.rightButton.startStop(e.Pointer.RIGHT_BUTTON&t,i),this.middleButton.startStop(e.Pointer.MIDDLE_BUTTON&t,i),this.backButton.startStop(e.Pointer.BACK_BUTTON&t,i),this.forwardButton.startStop(e.Pointer.FORWARD_BUTTON&t,i),this.eraserButton.startStop(e.Pointer.ERASER_BUTTON&t,i)):void 0!==i.button?n&&i.ctrlKey&&0===i.button?this.rightButton.start(i):n?this.processButtonsDown(i.button,i):r||this.processButtonsUp(i.button,i):n?i.ctrlKey?this.rightButton.start(i):this.leftButton.start(i):(this.leftButton.stop(i),this.rightButton.stop(i))},updateButtons:function(t){this.button=t.button,this.processButtonsUpDown(t.buttons,t),this.isUp=!0,this.isDown=!1,(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(t){var i=this.game.input;return t.pointerId&&(this.pointerId=t.pointerId),this.identifier=t.identifier,this.target=t.target,this.isMouse?this.updateButtons(t):(this.isDown=!0,this.isUp=!1),this.active=!0,this.withinGame=!0,this.dirty=!1,this._history=[],this._clickTrampolines=null,this._trampolineTargetObject=null,this.msSinceLastClick=this.game.time.time-this.timeDown,this.timeDown=this.game.time.time,this._holdSent=!1,this.move(t,!0),this.positionDown.setTo(this.x,this.y),(i.multiInputOverride===e.Input.MOUSE_OVERRIDES_TOUCH||i.multiInputOverride===e.Input.MOUSE_TOUCH_COMBINE||i.multiInputOverride===e.Input.TOUCH_OVERRIDES_MOUSE&&0===i.totalActivePointers)&&(i.x=this.x,i.y=this.y,i.position.setTo(this.x,this.y),i.onDown.dispatch(this,t),i.resetSpeed(this.x,this.y)),this._stateReset=!1,this.totalTouches++,null!==this.targetObject&&this.targetObject._touchedHandler(this),this},update:function(){var t=this.game.input;this.active&&(this.dirty&&(t.interactiveItems.total>0&&this.processInteractiveObjects(!1),this.dirty=!1),!1===this._holdSent&&this.duration>=t.holdRate&&((t.multiInputOverride===e.Input.MOUSE_OVERRIDES_TOUCH||t.multiInputOverride===e.Input.MOUSE_TOUCH_COMBINE||t.multiInputOverride===e.Input.TOUCH_OVERRIDES_MOUSE&&0===t.totalActivePointers)&&t.onHold.dispatch(this),this._holdSent=!0),t.recordPointerHistory&&this.game.time.time>=this._nextDrop&&(this._nextDrop=this.game.time.time+t.recordRate,this._history.push({x:this.position.x,y:this.position.y}),this._history.length>t.recordLimit&&this._history.shift()))},move:function(t,i){var s=this.game.input;if(!s.pollLocked){void 0===i&&(i=!1),void 0!==t.button&&(this.button=t.button),this.isMouse&&this.updateButtons(t),this.clientX=t.clientX,this.clientY=t.clientY,this.pageX=t.pageX,this.pageY=t.pageY,this.screenX=t.screenX,this.screenY=t.screenY,this.isMouse&&s.pointerLock.locked&&!i&&(this.rawMovementX=t.movementX||t.mozMovementX||t.webkitMovementX||0,this.rawMovementY=t.movementY||t.mozMovementY||t.webkitMovementY||0,this.movementX+=this.rawMovementX,this.movementY+=this.rawMovementY),this.x=(this.pageX-this.game.scale.offset.x)*s.scale.x,this.y=(this.pageY-this.game.scale.offset.y)*s.scale.y,this.position.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,(s.multiInputOverride===e.Input.MOUSE_OVERRIDES_TOUCH||s.multiInputOverride===e.Input.MOUSE_TOUCH_COMBINE||s.multiInputOverride===e.Input.TOUCH_OVERRIDES_MOUSE&&0===s.totalActivePointers)&&(s.activePointer=this,s.x=this.x,s.y=this.y,s.position.setTo(s.x,s.y),s.circle.x=s.x,s.circle.y=s.y),this.withinGame=this.game.scale.bounds.contains(this.pageX,this.pageY);for(var n=s.moveCallbacks.length;n--;)s.moveCallbacks[n].callback.call(s.moveCallbacks[n].context,this,this.x,this.y,i,t);return null===this.targetObject||this.game.paused&&!this.targetObject.noPause||!0!==this.targetObject.isDragged?s.interactiveItems.total>0&&this.processInteractiveObjects(i):!1===this.targetObject.update(this)&&(this.targetObject=null),this}},processInteractiveObjects:function(t){var e=0,i=-1,s=null,n=this.game.input.interactiveItems.first;for(this.interactiveCandidates=[];n;)n.checked=!1,!n.validForInput(i,e,!1)||this.game.paused&&!n.sprite.noPause||(n.checked=!0,(t&&n.checkPointerDown(this,!0)||!t&&n.checkPointerOver(this,!0))&&(e=n.sprite.renderOrderID,i=n.priorityID,s=n,this.interactiveCandidates.push(n))),n=this.game.input.interactiveItems.next;for(n=this.game.input.interactiveItems.first;n;)!n.checked&&n.validForInput(i,e,!0)&&(t&&n.checkPointerDown(this,!1)||!t&&n.checkPointerOver(this,!1))&&(e=n.sprite.renderOrderID,i=n.priorityID,s=n,this.interactiveCandidates.push(n)),n=this.game.input.interactiveItems.next;return this.game.input.customCandidateHandler&&(s=this.game.input.customCandidateHandler.call(this.game.input.customCandidateHandlerContext,this,this.interactiveCandidates,s)),this.swapTarget(s,!1),null!==this.targetObject},swapTarget:function(t,e){void 0===e&&(e=!1),null===t?this.targetObject&&(this.targetObject._pointerOutHandler(this,e),this.targetObject=null):null===this.targetObject?(this.targetObject=t,t._pointerOverHandler(this,e)):this.targetObject===t?!1===t.update(this)&&(this.targetObject=null):(this.targetObject._pointerOutHandler(this,e),this.targetObject=t,this.targetObject._pointerOverHandler(this,e))},leave:function(t){this.withinGame=!1,this.move(t,!1)},stop:function(t){var i=this.game.input;{if(!this._stateReset||!this.withinGame){if(this.timeUp=this.game.time.time,(i.multiInputOverride===e.Input.MOUSE_OVERRIDES_TOUCH||i.multiInputOverride===e.Input.MOUSE_TOUCH_COMBINE||i.multiInputOverride===e.Input.TOUCH_OVERRIDES_MOUSE&&0===i.totalActivePointers)&&(i.onUp.dispatch(this,t),this.duration>=0&&this.duration<=i.tapRate)){var s=this.timeUp-this.previousTapTime0&&(this.active=!1),this.withinGame=this.game.scale.bounds.contains(t.pageX,t.pageY),this.pointerId=null,this.identifier=null,this.positionUp.setTo(this.x,this.y),!1===this.isMouse&&i.currentPointers--,i.callAll("_releasedHandler",this),this._clickTrampolines&&(this._trampolineTargetObject=this.targetObject),this.targetObject=null,this}t.preventDefault()}},justPressed:function(t){return t=t||this.game.input.justPressedRate,!0===this.isDown&&this.timeDown+t>this.game.time.time},justReleased:function(t){return t=t||this.game.input.justReleasedRate,this.isUp&&this.timeUp+t>this.game.time.time},addClickTrampoline:function(t,e,i,s){if(this.isDown){for(var n=this._clickTrampolines=this._clickTrampolines||[],r=0;rt||this.priorityID===t&&this.sprite.renderOrderID>e))},isPixelPerfect:function(){return this.pixelPerfectClick||this.pixelPerfectOver},pointerX:function(t){return t=t||0,this._pointerData[t].x},pointerY:function(t){return t=t||0,this._pointerData[t].y},pointerDown:function(t){return t=t||0,this._pointerData[t].isDown},pointerUp:function(t){return t=t||0,this._pointerData[t].isUp},pointerTimeDown:function(t){return t=t||0,this._pointerData[t].timeDown},pointerTimeUp:function(t){return t=t||0,this._pointerData[t].timeUp},pointerOver:function(t){if(!this.enabled)return!1;if(void 0===t){for(var e=0;e<10;e++)if(this._pointerData[e].isOver)return!0;return!1}return this._pointerData[t].isOver},pointerOut:function(t){if(!this.enabled)return!1;if(void 0!==t)return this._pointerData[t].isOut;for(var e=0;e<10;e++)if(this._pointerData[e].isOut)return!0},pointerTimeOver:function(t){return t=t||0,this._pointerData[t].timeOver},pointerTimeOut:function(t){return t=t||0,this._pointerData[t].timeOut},pointerDragged:function(t){return t=t||0,this._pointerData[t].isDragged},checkPointerDown:function(t,e){return!!(t.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,t,this._tempPoint)&&(void 0===e&&(e=!1),!(!e&&this.pixelPerfectClick)||this.checkPixel(this._tempPoint.x,this._tempPoint.y)))},checkPointerOver:function(t,e){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,t,this._tempPoint)&&(void 0===e&&(e=!1),!(!e&&this.pixelPerfectOver)||this.checkPixel(this._tempPoint.x,this._tempPoint.y)))},checkPixel:function(t,e,i){if(this.sprite.texture.baseTexture.source){if(null===t&&null===e){this.game.input.getLocalPosition(this.sprite,i,this._tempPoint);var t=this._tempPoint.x,e=this._tempPoint.y}if(0!==this.sprite.anchor.x&&(t-=-this.sprite.texture.frame.width*this.sprite.anchor.x),0!==this.sprite.anchor.y&&(e-=-this.sprite.texture.frame.height*this.sprite.anchor.y),t+=this.sprite.texture.frame.x,e+=this.sprite.texture.frame.y,this.sprite.texture.trim&&(t-=this.sprite.texture.trim.x,e-=this.sprite.texture.trim.y,tthis.sprite.texture.crop.right||ethis.sprite.texture.crop.bottom))return this._dx=t,this._dy=e,!1;if(this._dx=t,this._dy=e,this.game.input.hitContext.clearRect(0,0,1,1),this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,t,e,1,1,0,0,1,1),this.game.input.hitContext.getImageData(0,0,1,1).data[3]>=this.pixelPerfectAlpha)return!0}return!1},update:function(t){if(null!==this.sprite&&void 0!==this.sprite.parent)return this.enabled&&this.sprite.visible&&this.sprite.parent.visible?this._pendingDrag?(this._dragDistancePass||(this._dragDistancePass=e.Math.distance(t.x,t.y,this.downPoint.x,this.downPoint.y)>=this.dragDistanceThreshold),this._dragDistancePass&&this._dragTimePass&&this.startDrag(t),!0):this.draggable&&this._draggedPointerID===t.id?this.updateDrag(t,!1):this._pointerData[t.id].isOver?this.checkPointerOver(t)?(this._pointerData[t.id].x=t.x-this.sprite.x,this._pointerData[t.id].y=t.y-this.sprite.y,!0):(this._pointerOutHandler(t),!1):void 0:(this._pointerOutHandler(t),!1)},_pointerOverHandler:function(t,e){if(null!==this.sprite){var i=this._pointerData[t.id];if(!1===i.isOver||t.dirty){var s=!1===i.isOver;i.isOver=!0,i.isOut=!1,i.timeOver=this.game.time.time,i.x=t.x-this.sprite.x,i.y=t.y-this.sprite.y,this.useHandCursor&&!1===i.isDragged&&(this.game.canvas.style.cursor="pointer",this._setHandCursor=!0),!e&&s&&this.sprite&&this.sprite.events&&this.sprite.events.onInputOver$dispatch(this.sprite,t),this.sprite.parent&&this.sprite.parent.onChildInputOver&&this.sprite.parent.onChildInputOver.dispatch(this.sprite,t)}}},_pointerOutHandler:function(t,e){if(null!==this.sprite){var i=this._pointerData[t.id];i.isOver=!1,i.isOut=!0,i.timeOut=this.game.time.time,this.useHandCursor&&!1===i.isDragged&&(this.game.canvas.style.cursor="",this._setHandCursor=!1),!e&&this.sprite&&this.sprite.events&&(this.sprite.events.onInputOut$dispatch(this.sprite,t),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputOut&&this.sprite.parent.onChildInputOut.dispatch(this.sprite,t))}},_touchedHandler:function(t){if(null!==this.sprite){var e=this._pointerData[t.id];if(!e.isDown&&e.isOver){if(this.pixelPerfectClick&&!this.checkPixel(null,null,t))return;if(e.isDown=!0,e.isUp=!1,e.timeDown=this.game.time.time,this.downPoint.set(t.x,t.y),t.dirty=!0,this.sprite&&this.sprite.events&&(this.sprite.events.onInputDown$dispatch(this.sprite,t),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputDown&&this.sprite.parent.onChildInputDown.dispatch(this.sprite,t),null===this.sprite))return;this.draggable&&!1===this.isDragged&&(0===this.dragTimeThreshold&&0===this.dragDistanceThreshold?this.startDrag(t):(this._pendingDrag=!0,this._dragDistancePass=0===this.dragDistanceThreshold,this.dragTimeThreshold>0?(this._dragTimePass=!1,this.game.time.events.add(this.dragTimeThreshold,this.dragTimeElapsed,this,t)):this._dragTimePass=!0)),this.bringToTop&&this.sprite.bringToTop()}}},dragTimeElapsed:function(t){this._dragTimePass=!0,this._pendingDrag&&this.sprite&&this._dragDistancePass&&this.startDrag(t)},_releasedHandler:function(t){if(null!==this.sprite){var e=this._pointerData[t.id];if(e.isDown&&t.isUp){e.isDown=!1,e.isUp=!0,e.timeUp=this.game.time.time,e.downDuration=e.timeUp-e.timeDown;var i=this.checkPointerOver(t);this.sprite&&this.sprite.events&&(this.dragStopBlocksInputUp&&(!this.dragStopBlocksInputUp||this.draggable&&this.isDragged&&this._draggedPointerID===t.id)||this.sprite.events.onInputUp$dispatch(this.sprite,t,i),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputUp&&this.sprite.parent.onChildInputUp.dispatch(this.sprite,t,i),i&&(i=this.checkPointerOver(t))),e.isOver=i,!i&&this.useHandCursor&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),t.dirty=!0,this._pendingDrag=!1,this.draggable&&this.isDragged&&this._draggedPointerID===t.id&&this.stopDrag(t)}}},updateDrag:function(t,e){var i=this.game.camera,s=this.dragOffset,n=this._dragPoint,r=this._pointerData[t.id],o=this.snapPoint,a=this.sprite;if(void 0===e&&(e=!1),t.isUp)return this.stopDrag(t),!1;var h=this.globalToLocal(t);if(a.fixedToCamera)var l=i.scale.x*h.x+n.x+s.x,c=i.scale.y*h.y+n.y+s.y;else var l=h.x+n.x+s.x,c=h.y+n.y+s.y;if(a.fixedToCamera){var u=a.cameraOffset,d=u.x,p=u.y;this.allowHorizontalDrag&&(u.x=l-i.x),this.allowVerticalDrag&&(u.y=c-i.y),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(u.x=Math.round((u.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,u.y=Math.round((u.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,o.set(u.x,u.y));var f=u.x-d,g=u.y-p}else{var m=i.x-r.camX,y=i.y-r.camY,d=a.x,p=a.y;this.allowHorizontalDrag&&(a.x=l+m),this.allowVerticalDrag&&(a.y=c+y),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(a.x=Math.round((a.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,a.y=Math.round((a.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,o.set(a.x,a.y));var f=a.x-d,g=a.y-p}return this.sprite.events.onDragUpdate.dispatch(a,t,l,c,o,e,f,g),!0},justOver:function(t,e){return t=t||0,e=e||500,this._pointerData[t].isOver&&this.overDuration(t)this.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)))}},e.InputHandler.prototype.constructor=e.InputHandler,e.PointerLock=function(t){this.game=t,this.input=t.input,this.element=t.canvas,this.active=!1,this.locked=!1,this.onChange=new e.Signal,this.onError=new e.Signal,this.boundOnChangeHandler=this.onChangeHandler.bind(this),this.boundOnErrorHandler=this.onErrorHandler.bind(this);var i=t.device;this.pointerLockElement=i.pointerLockElement,this.pointerlockchange=i.pointerlockchange,this.pointerlockerror=i.pointerlockerror},e.PointerLock.prototype.start=function(){return!(!this.game.device.pointerLock||this.active)&&(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),this.active=!0,!0)},e.PointerLock.prototype.stop=function(){this.active&&(document.removeEventListener(this.pointerlockchange,this.boundOnChangeHandler,!0),document.removeEventListener(this.pointerlockerror,this.boundOnErrorHandler,!0),this.active=!1)},e.PointerLock.prototype.request=function(){this.active&&!this.locked&&this.element.requestPointerLock()},e.PointerLock.prototype.exit=function(){document.exitPointerLock()},e.PointerLock.prototype.onChangeHandler=function(t){this.locked=document[this.pointerLockElement]===this.element,this.onChange.dispatch(this.locked,t)},e.PointerLock.prototype.onErrorHandler=function(t){this.onError.dispatch(t)},e.Gamepad=function(t){this.game=t,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.onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null,this._ongamepadconnected=null,this._gamepaddisconnected=null,this._gamepads=[new e.SinglePad(t,this),new e.SinglePad(t,this),new e.SinglePad(t,this),new e.SinglePad(t,this)]},e.Gamepad.prototype={addCallbacks:function(t,e){void 0!==e&&(this.onConnectCallback="function"==typeof e.onConnect?e.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"==typeof e.onDisconnect?e.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"==typeof e.onDown?e.onDown:this.onDownCallback,this.onUpCallback="function"==typeof e.onUp?e.onUp:this.onUpCallback,this.onAxisCallback="function"==typeof e.onAxis?e.onAxis:this.onAxisCallback,this.onFloatCallback="function"==typeof e.onFloat?e.onFloat:this.onFloatCallback,this.callbackContext=t)},start:function(){if(!this._active){this._active=!0;var t=this;this._onGamepadConnected=function(e){return t.onGamepadConnected(e)},this._onGamepadDisconnected=function(e){return t.onGamepadDisconnected(e)},window.addEventListener("gamepadconnected",this._onGamepadConnected,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisconnected,!1)}},onGamepadConnected:function(t){var e=t.gamepad;this._rawPads.push(e),this._gamepads[e.index].connect(e)},onGamepadDisconnected:function(t){var e=t.gamepad;for(var i in this._rawPads)this._rawPads[i].index===e.index&&this._rawPads.splice(i,1);this._gamepads[e.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)t=navigator.getGamepads();else if(navigator.webkitGetGamepads)t=navigator.webkitGetGamepads();else if(navigator.webkitGamepads)var t=navigator.webkitGamepads();if(t){this._rawPads=[];for(var e=!1,i=0;i0&&s>this.deadZone||s<0&&s<-this.deadZone?this.processAxisChange(i,s):this.processAxisChange(i,0)}this._prevTimestamp=this._rawPad.timestamp}},connect:function(t){var i=!this.connected;this.connected=!0,this.index=t.index,this._rawPad=t,this._buttons=[],this._buttonsLen=t.buttons.length,this._axes=[],this._axesLen=t.axes.length;for(var s=0;sthis.maxHealth&&(this.health=this.maxHealth),this},heal:function(t){return this.alive&&(this.health+=t,this.health>this.maxHealth&&(this.health=this.maxHealth)),this}},e.Component.InCamera=function(){},e.Component.InCamera.prototype={inCamera:{get:function(){return this.game.world.camera.view.intersects(this._bounds)}}},e.Component.InputEnabled=function(){},e.Component.InputEnabled.prototype={input:null,inputEnabled:{get:function(){return this.input&&this.input.enabled},set:function(t){t?null===this.input?(this.input=new e.InputHandler(this),this.input.start()):this.input&&!this.input.enabled&&this.input.start():this.input&&this.input.enabled&&this.input.stop()}}},e.Component.InWorld=function(){},e.Component.InWorld.preUpdate=function(){if(this.pendingDestroy)return this.destroy(),!1;if(this.autoCull||this.checkWorldBounds){if(this._bounds.copyFrom(this.getBounds()),this._bounds.x+=this.game.camera.view.x,this._bounds.y+=this.game.camera.view.y,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},e.Component.InWorld.prototype={checkWorldBounds:!1,outOfBoundsKill:!1,outOfCameraBoundsKill:!1,_outOfBoundsFired:!1,inWorld:{get:function(){return this.game.world.bounds.intersects(this.getBounds())}}},e.Component.LifeSpan=function(){},e.Component.LifeSpan.preUpdate=function(){return this.pendingDestroy?(this.destroy(),!1):!(this.lifespan>0&&(this.lifespan-=this.game.time.physicsElapsedMS,this.lifespan<=0))||(this.kill(),!1)},e.Component.LifeSpan.prototype={alive:!0,lifespan:0,revive:function(t){return void 0===t&&(t=100),this.alive=!0,this.exists=!0,this.visible=!0,"function"==typeof this.setHealth&&this.setHealth(t),this.events&&this.events.onRevived$dispatch(this),this},kill:function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.events&&this.events.onKilled$dispatch(this),this}},e.Component.LoadTexture=function(){},e.Component.LoadTexture.prototype={customRender:!1,_frame:null,loadTexture:function(t,i,s){t===e.PENDING_ATLAS?(t=i,i=0):i=i||0,(s||void 0===s)&&this.animations&&this.animations.stop(),this.key=t,this.customRender=!1;var n=this.game.cache,r=!0,o=this.texture.baseTexture.scaleMode===PIXI.scaleModes.LINEAR;if(e.RenderTexture&&t instanceof e.RenderTexture)this.key=t.key,this.setTexture(t);else if(e.BitmapData&&t instanceof e.BitmapData)this.customRender=!0,this.setTexture(t.texture),r=n.hasFrameData(t.key,e.Cache.BITMAPDATA)?!this.animations.loadFrameData(n.getFrameData(t.key,e.Cache.BITMAPDATA),i):!this.animations.loadFrameData(t.frameData,0);else if(e.Video&&t instanceof e.Video){this.customRender=!0;var a=t.texture.valid;this.setTexture(t.texture),this.setFrame(t.texture.frame.clone()),t.onChangeSource.add(this.resizeFrame,this),this.texture.valid=a}else if(e.Tilemap&&t instanceof e.TilemapLayer)this.setTexture(PIXI.Texture.fromCanvas(t.canvas));else if(t instanceof PIXI.Texture)o=t.baseTexture.scaleMode===PIXI.scaleModes.LINEAR,this.setTexture(t);else{var h=n.getImage(t,!0);this.key=h.key,this.setTexture(new PIXI.Texture(h.base)),this.texture.baseTexture.skipRender="__default"===t,r=!this.animations.loadFrameData(h.frameData,i)}r&&(this._frame=e.Rectangle.clone(this.texture.frame)),o||(this.texture.baseTexture.scaleMode=1)},setFrame:function(t){this._frame=t,this.texture.frame.x=t.x,this.texture.frame.y=t.y,this.texture.frame.width=t.width,this.texture.frame.height=t.height,this.texture.crop.x=t.x,this.texture.crop.y=t.y,this.texture.crop.width=t.width,this.texture.crop.height=t.height,t.trimmed?(this.texture.trim?(this.texture.trim.x=t.spriteSourceSizeX,this.texture.trim.y=t.spriteSourceSizeY,this.texture.trim.width=t.sourceSizeW,this.texture.trim.height=t.sourceSizeH):this.texture.trim={x:t.spriteSourceSizeX,y:t.spriteSourceSizeY,width:t.sourceSizeW,height:t.sourceSizeH},this.texture.width=t.sourceSizeW,this.texture.height=t.sourceSizeH,this.texture.frame.width=t.sourceSizeW,this.texture.frame.height=t.sourceSizeH):!t.trimmed&&this.texture.trim&&(this.texture.trim=null),t.rotated&&(this.texture.rotated=!0),this.cropRect&&this.updateCrop(),this.texture.requiresReTint=!0,this.texture._updateUvs(),this.tilingTexture&&(this.refreshTexture=!0)},resizeFrame:function(t,e,i){this.texture.frame.resize(e,i),this.texture.setFrame(this.texture.frame)},resetFrame:function(){this._frame&&this.setFrame(this._frame)},frame:{get:function(){return this.animations.frame},set:function(t){this.animations.frame=t}},frameName:{get:function(){return this.animations.frameName},set:function(t){this.animations.frameName=t}}},e.Component.Overlap=function(){},e.Component.Overlap.prototype={overlap:function(t){return e.Rectangle.intersects(this.getBounds(),t.getBounds())}},e.Component.PhysicsBody=function(){},e.Component.PhysicsBody.preUpdate=function(){return this.pendingDestroy?(this.destroy(),!1):this.fresh&&this.exists?(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,!(!this._exists||!this.parent.exists)||(this.renderOrderID=-1,!1))},e.Component.PhysicsBody.postUpdate=function(){this.exists&&this.body&&this.body.postUpdate()},e.Component.PhysicsBody.prototype={body:null,x:{get:function(){return this.position.x},set:function(t){this.position.x=t,this.body&&!this.body.dirty&&(this.body._reset=!0)}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t,this.body&&!this.body.dirty&&(this.body._reset=!0)}}},e.Component.Reset=function(){},e.Component.Reset.prototype.reset=function(t,e,i){return void 0===i&&(i=1),this.world.set(t,e),this.position.set(t,e),this.fresh=!0,this.exists=!0,this.visible=!0,this.renderable=!0,this.components.InWorld&&(this._outOfBoundsFired=!1),this.components.LifeSpan&&(this.alive=!0,this.health=i),this.components.PhysicsBody&&this.body&&this.body.reset(t,e,!1,!1),this},e.Component.ScaleMinMax=function(){},e.Component.ScaleMinMax.prototype={transformCallback:null,transformCallbackContext:this,scaleMin:null,scaleMax:null,checkTransform:function(t){this.scaleMin&&(t.athis.scaleMax.x&&(t.a=this.scaleMax.x),t.d>this.scaleMax.y&&(t.d=this.scaleMax.y))},setScaleMinMax:function(t,i,s,n){void 0===i?i=s=n=t:void 0===s&&(s=n=i,i=t),null===t?this.scaleMin=null:this.scaleMin?this.scaleMin.set(t,i):this.scaleMin=new e.Point(t,i),null===s?this.scaleMax=null:this.scaleMax?this.scaleMax.set(s,n):this.scaleMax=new e.Point(s,n),null===this.scaleMin?this.transformCallback=null:(this.transformCallback=this.checkTransform,this.transformCallbackContext=this)}},e.Component.Smoothed=function(){},e.Component.Smoothed.prototype={smoothed:{get:function(){return!this.texture.baseTexture.scaleMode},set:function(t){t?this.texture&&0!==this.texture.baseTexture.scaleMode&&(this.texture.baseTexture.scaleMode=0,this.texture.baseTexture.dirty()):this.texture&&1!==this.texture.baseTexture.scaleMode&&(this.texture.baseTexture.scaleMode=1,this.texture.baseTexture.dirty())}}},e.GameObjectFactory=function(t){this.game=t,this.world=this.game.world},e.GameObjectFactory.prototype={existing:function(t){return this.world.add(t)},weapon:function(t,i,s,n,r){var o=this.game.plugins.add(e.Weapon);return r&&(o.bulletClass=r),o.createBullets(t,i,s,n),o},image:function(t,i,s,n,r){return void 0===r&&(r=this.world),r.add(new e.Image(this.game,t,i,s,n))},sprite:function(t,i,s,n,r){return void 0===r&&(r=this.world),r.add(new e.Sprite(this.game,t,i,s,n))},creature:function(t,i,s,n,r,o,a){void 0===r&&(r=this.world);var h=new e.Creature(this.game,t,i,s,n,o,a);return r.add(h),h},tween:function(t){return this.game.tweens.create(t)},group:function(t,i,s,n,r){return new e.Group(this.game,t,i,s,n,r)},physicsGroup:function(t,i,s,n){return new e.Group(this.game,i,s,n,!0,t)},spriteBatch:function(t,i,s){return void 0===t&&(t=null),void 0===i&&(i="group"),void 0===s&&(s=!1),new e.SpriteBatch(this.game,t,i,s)},audio:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},sound:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},audioSprite:function(t){return this.game.sound.addSprite(t)},tileSprite:function(t,i,s,n,r,o,a){return void 0===a&&(a=this.world),a.add(new e.TileSprite(this.game,t,i,s,n,r,o))},rope:function(t,i,s,n,r,o){return void 0===o&&(o=this.world),o.add(new e.Rope(this.game,t,i,s,n,r))},text:function(t,i,s,n,r){return void 0===r&&(r=this.world),r.add(new e.Text(this.game,t,i,s,n))},button:function(t,i,s,n,r,o,a,h,l,c){return void 0===c&&(c=this.world),c.add(new e.Button(this.game,t,i,s,n,r,o,a,h,l))},graphics:function(t,i,s){return void 0===s&&(s=this.world),s.add(new e.Graphics(this.game,t,i))},emitter:function(t,i,s){return this.game.particles.add(new e.Particles.Arcade.Emitter(this.game,t,i,s))},retroFont:function(t,i,s,n,r,o,a,h,l){return new e.RetroFont(this.game,t,i,s,n,r,o,a,h,l)},bitmapText:function(t,i,s,n,r,o){return void 0===o&&(o=this.world),o.add(new e.BitmapText(this.game,t,i,s,n,r))},tilemap:function(t,i,s,n,r){return new e.Tilemap(this.game,t,i,s,n,r)},renderTexture:function(t,i,s,n){void 0!==s&&""!==s||(s=this.game.rnd.uuid()),void 0===n&&(n=!1);var r=new e.RenderTexture(this.game,t,i,s);return n&&this.game.cache.addRenderTexture(s,r),r},video:function(t,i){return new e.Video(this.game,t,i)},bitmapData:function(t,i,s,n){void 0===n&&(n=!1),void 0!==s&&""!==s||(s=this.game.rnd.uuid());var r=new e.BitmapData(this.game,s,t,i);return n&&this.game.cache.addBitmapData(s,r),r},filter:function(t){var i=Array.prototype.slice.call(arguments,1);return(t=new e.Filter[t](this.game)).init.apply(t,i),t},plugin:function(){return this.game.plugins.add.apply(this.game.plugins,arguments)}},e.GameObjectFactory.prototype.constructor=e.GameObjectFactory,e.GameObjectCreator=function(t){this.game=t,this.world=this.game.world},e.GameObjectCreator.prototype={image:function(t,i,s,n){return new e.Image(this.game,t,i,s,n)},sprite:function(t,i,s,n){return new e.Sprite(this.game,t,i,s,n)},tween:function(t){return new e.Tween(t,this.game,this.game.tweens)},group:function(t,i,s,n,r){return new e.Group(this.game,t||null,i,s,n,r)},spriteBatch:function(t,i,s){return void 0===i&&(i="group"),void 0===s&&(s=!1),new e.SpriteBatch(this.game,t,i,s)},audio:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},audioSprite:function(t){return this.game.sound.addSprite(t)},sound:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},tileSprite:function(t,i,s,n,r,o){return new e.TileSprite(this.game,t,i,s,n,r,o)},rope:function(t,i,s,n,r){return new e.Rope(this.game,t,i,s,n,r)},text:function(t,i,s,n){return new e.Text(this.game,t,i,s,n)},button:function(t,i,s,n,r,o,a,h,l){return new e.Button(this.game,t,i,s,n,r,o,a,h,l)},graphics:function(t,i){return new e.Graphics(this.game,t,i)},emitter:function(t,i,s){return new e.Particles.Arcade.Emitter(this.game,t,i,s)},retroFont:function(t,i,s,n,r,o,a,h,l){return new e.RetroFont(this.game,t,i,s,n,r,o,a,h,l)},bitmapText:function(t,i,s,n,r,o){return new e.BitmapText(this.game,t,i,s,n,r,o)},tilemap:function(t,i,s,n,r){return new e.Tilemap(this.game,t,i,s,n,r)},renderTexture:function(t,i,s,n){void 0!==s&&""!==s||(s=this.game.rnd.uuid()),void 0===n&&(n=!1);var r=new e.RenderTexture(this.game,t,i,s);return n&&this.game.cache.addRenderTexture(s,r),r},bitmapData:function(t,i,s,n){void 0===n&&(n=!1),void 0!==s&&""!==s||(s=this.game.rnd.uuid());var r=new e.BitmapData(this.game,s,t,i);return n&&this.game.cache.addBitmapData(s,r),r},filter:function(t){var i=Array.prototype.slice.call(arguments,1);return(t=new e.Filter[t](this.game)).init.apply(t,i),t}},e.GameObjectCreator.prototype.constructor=e.GameObjectCreator,e.Sprite=function(t,i,s,n,r){i=i||0,s=s||0,n=n||null,r=r||null,this.type=e.SPRITE,this.physicsType=e.SPRITE,PIXI.Sprite.call(this,e.Cache.DEFAULT),e.Component.Core.init.call(this,t,i,s,n,r)},e.Sprite.prototype=Object.create(PIXI.Sprite.prototype),e.Sprite.prototype.constructor=e.Sprite,e.Component.Core.install.call(e.Sprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),e.Sprite.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.Sprite.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.Sprite.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.Sprite.prototype.preUpdateCore=e.Component.Core.preUpdate,e.Sprite.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.Image=function(t,i,s,n,r){i=i||0,s=s||0,n=n||null,r=r||null,this.type=e.IMAGE,PIXI.Sprite.call(this,e.Cache.DEFAULT),e.Component.Core.init.call(this,t,i,s,n,r)},e.Image.prototype=Object.create(PIXI.Sprite.prototype),e.Image.prototype.constructor=e.Image,e.Component.Core.install.call(e.Image.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Destroy","FixedToCamera","InputEnabled","LifeSpan","LoadTexture","Overlap","Reset","ScaleMinMax","Smoothed"]),e.Image.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.Image.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.Image.prototype.preUpdateCore=e.Component.Core.preUpdate,e.Image.prototype.preUpdate=function(){return!(!this.preUpdateInWorld()||!this.preUpdateLifeSpan())&&this.preUpdateCore()},e.Button=function(t,i,s,n,r,o,a,h,l,c){i=i||0,s=s||0,n=n||null,r=r||null,o=o||this,e.Image.call(this,t,i,s,n,h),this.type=e.BUTTON,this.physicsType=e.SPRITE,this._onOverFrame=null,this._onOutFrame=null,this._onDownFrame=null,this._onUpFrame=null,this.onOverSound=null,this.onOutSound=null,this.onDownSound=null,this.onUpSound=null,this.onOverSoundMarker="",this.onOutSoundMarker="",this.onDownSoundMarker="",this.onUpSoundMarker="",this.onInputOver=new e.Signal,this.onInputOut=new e.Signal,this.onInputDown=new e.Signal,this.onInputUp=new e.Signal,this.onOverMouseOnly=!0,this.justReleasedPreventsOver=e.PointerMode.CONTACT,this.freezeFrames=!1,this.forceOut=!1,this.inputEnabled=!0,this.input.start(0,!0),this.input.useHandCursor=!0,this.setFrames(a,h,l,c),null!==r&&this.onInputUp.add(r,o),this.events.onInputOver.add(this.onInputOverHandler,this),this.events.onInputOut.add(this.onInputOutHandler,this),this.events.onInputDown.add(this.onInputDownHandler,this),this.events.onInputUp.add(this.onInputUpHandler,this)},e.Button.prototype=Object.create(e.Image.prototype),e.Button.prototype.constructor=e.Button;return e.Button.prototype.clearFrames=function(){this.setFrames(null,null,null,null)},e.Button.prototype.setStateFrame=function(t,e,i){var s="_on"+t+"Frame";null!==e?(this[s]=e,i&&this.changeStateFrame(t)):this[s]=null},e.Button.prototype.changeStateFrame=function(t){if(this.freezeFrames)return!1;var e=this["_on"+t+"Frame"];return"string"==typeof e?(this.frameName=e,!0):"number"==typeof e&&(this.frame=e,!0)},e.Button.prototype.setFrames=function(t,e,i,s){this.setStateFrame("Over",t,this.input.pointerOver()),this.setStateFrame("Out",e,!this.input.pointerOver()),this.setStateFrame("Down",i,this.input.pointerDown()),this.setStateFrame("Up",s,this.input.pointerUp())},e.Button.prototype.setStateSound=function(t,i,s){var n="on"+t+"Sound",r="on"+t+"SoundMarker";i instanceof e.Sound||i instanceof e.AudioSprite?(this[n]=i,this[r]="string"==typeof s?s:""):(this[n]=null,this[r]="")},e.Button.prototype.playStateSound=function(t){var e=this["on"+t+"Sound"];if(e){var i=this["on"+t+"SoundMarker"];return e.play(i),!0}return!1},e.Button.prototype.setSounds=function(t,e,i,s,n,r,o,a){this.setStateSound("Over",t,e),this.setStateSound("Out",n,r),this.setStateSound("Down",i,s),this.setStateSound("Up",o,a)},e.Button.prototype.setOverSound=function(t,e){this.setStateSound("Over",t,e)},e.Button.prototype.setOutSound=function(t,e){this.setStateSound("Out",t,e)},e.Button.prototype.setDownSound=function(t,e){this.setStateSound("Down",t,e)},e.Button.prototype.setUpSound=function(t,e){this.setStateSound("Up",t,e)},e.Button.prototype.onInputOverHandler=function(t,e){e.justReleased()&&(this.justReleasedPreventsOver&e.pointerMode)===e.pointerMode||(this.changeStateFrame("Over"),this.onOverMouseOnly&&!e.isMouse||(this.playStateSound("Over"),this.onInputOver&&this.onInputOver.dispatch(this,e)))},e.Button.prototype.onInputOutHandler=function(t,e){this.changeStateFrame("Out"),this.playStateSound("Out"),this.onInputOut&&this.onInputOut.dispatch(this,e)},e.Button.prototype.onInputDownHandler=function(t,e){this.changeStateFrame("Down"),this.playStateSound("Down"),this.onInputDown&&this.onInputDown.dispatch(this,e)},e.Button.prototype.onInputUpHandler=function(t,e,i){this.playStateSound("Up"),this.onInputUp&&this.onInputUp.dispatch(this,e,i),this.freezeFrames||(!0===this.forceOut||(this.forceOut&e.pointerMode)===e.pointerMode?this.changeStateFrame("Out"):this.changeStateFrame("Up")||(i?this.changeStateFrame("Over"):this.changeStateFrame("Out")))},e.SpriteBatch=function(t,i,s,n){void 0!==i&&null!==i||(i=t.world),e.Group.call(this,t,i,s,n),this.type=e.SPRITEBATCH,this.fastSpriteBatch=null,this.ready=!1},e.SpriteBatch.prototype=Object.create(e.Group.prototype),e.SpriteBatch.prototype.constructor=e.SpriteBatch,e.SpriteBatch.prototype._renderWebGL=function(t){!this.visible||this.alpha<=0||!this.children.length||(this.ready||(this.fastSpriteBatch=new PIXI.WebGLFastSpriteBatch(t.gl),this.ready=!0),this.fastSpriteBatch.gl!==t.gl&&this.fastSpriteBatch.setContext(t.gl),t.spriteBatch.stop(),t.shaderManager.setShader(t.shaderManager.fastShader),this.fastSpriteBatch.begin(this,t),this.fastSpriteBatch.render(this),t.spriteBatch.start())},e.SpriteBatch.prototype._renderCanvas=function(t){if(this.visible&&!(this.alpha<=0)&&this.children.length){var e=t.context;e.globalAlpha=this.worldAlpha,this.displayObjectUpdateTransform();for(var i=this.worldTransform,s=!0,n=0;n=0&&t<=this.width&&i>=0&&i<=this.height&&(e.Device.LITTLE_ENDIAN?this.pixels[i*this.width+t]=o<<24|r<<16|n<<8|s:this.pixels[i*this.width+t]=s<<24|n<<16|r<<8|o,a&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0)),this},setPixel:function(t,e,i,s,n,r){return this.setPixel32(t,e,i,s,n,255,r)},getPixel:function(t,i,s){s||(s=e.Color.createColor());var n=~~(t+i*this.width);return n*=4,s.r=this.data[n],s.g=this.data[++n],s.b=this.data[++n],s.a=this.data[++n],s},getPixel32:function(t,e){if(t>=0&&t<=this.width&&e>=0&&e<=this.height)return this.pixels[e*this.width+t]},getPixelRGB:function(t,i,s,n,r){return e.Color.unpackPixel(this.getPixel32(t,i),s,n,r)},getPixels:function(t){return this.context.getImageData(t.x,t.y,t.width,t.height)},getFirstPixel:function(t){void 0===t&&(t=0);var i=e.Color.createColor(),s=0,n=0,r=1,o=!1;1===t?(r=-1,n=this.height):3===t&&(r=-1,s=this.width);do{e.Color.unpackPixel(this.getPixel32(s,n),i),0===t||1===t?++s===this.width&&(s=0,((n+=r)>=this.height||n<=0)&&(o=!0)):2!==t&&3!==t||++n===this.height&&(n=0,((s+=r)>=this.width||s<=0)&&(o=!0))}while(0===i.a&&!o);return i.x=s,i.y=n,i},getBounds:function(t){return void 0===t&&(t=new e.Rectangle),t.x=this.getFirstPixel(2).x,t.x===this.width?t.setTo(0,0,0,0):(t.y=this.getFirstPixel(0).y,t.width=this.getFirstPixel(3).x-t.x+1,t.height=this.getFirstPixel(1).y-t.y+1,t)},addToWorld:function(t,e,i,s,n,r){n=n||1,r=r||1;var o=this.game.add.image(t,e,this);return o.anchor.set(i,s),o.scale.set(n,r),o},copy:function(t,i,s,n,r,o,a,h,l,c,u,d,p,f,g,m,y){if(void 0!==t&&null!==t||(t=this),t instanceof e.RenderTexture&&(t=t.getCanvas()),this._image=t,t instanceof e.Sprite||t instanceof e.Image||t instanceof e.Text||t instanceof PIXI.Sprite)this._pos.set(t.texture.crop.x,t.texture.crop.y),this._size.set(t.texture.crop.width,t.texture.crop.height),this._scale.set(t.scale.x,t.scale.y),this._anchor.set(t.anchor.x,t.anchor.y),this._rotate=t.rotation,this._alpha.current=t.alpha,t.texture instanceof e.RenderTexture?this._image=t.texture.getCanvas():this._image=t.texture.baseTexture.source,void 0!==o&&null!==o||(o=t.x),void 0!==a&&null!==a||(a=t.y),t.texture.trim&&(o+=t.texture.trim.x-t.anchor.x*t.texture.trim.width,a+=t.texture.trim.y-t.anchor.y*t.texture.trim.height),16777215!==t.tint&&(t.cachedTint!==t.tint&&(t.cachedTint=t.tint,t.tintedTexture=PIXI.CanvasTinter.getTintedTexture(t,t.tint)),this._image=t.tintedTexture,this._pos.set(0));else{if(this._pos.set(0),this._scale.set(1),this._anchor.set(0),this._rotate=0,this._alpha.current=1,t instanceof e.BitmapData)this._image=t.canvas;else if("string"==typeof t){if(null===(t=this.game.cache.getImage(t)))return this;this._image=t}this._size.set(this._image.width,this._image.height)}if(void 0!==i&&null!==i||(i=0),void 0!==s&&null!==s||(s=0),n&&(this._size.x=n),r&&(this._size.y=r),void 0!==o&&null!==o||(o=i),void 0!==a&&null!==a||(a=s),void 0!==h&&null!==h||(h=this._size.x),void 0!==l&&null!==l||(l=this._size.y),"number"==typeof c&&(this._rotate=c),"number"==typeof u&&(this._anchor.x=u),"number"==typeof d&&(this._anchor.y=d),"number"==typeof p&&(this._scale.x=p),"number"==typeof f&&(this._scale.y=f),"number"==typeof g&&(this._alpha.current=g),void 0===m&&(m=null),void 0===y&&(y=!1),this._alpha.current<=0||0===this._scale.x||0===this._scale.y||0===this._size.x||0===this._size.y)return this;var v=this.context;return this._alpha.prev=v.globalAlpha,v.save(),v.globalAlpha=this._alpha.current,m&&(this.op=m),y&&(o|=0,a|=0),v.translate(o,a),v.scale(this._scale.x,this._scale.y),v.rotate(this._rotate),v.drawImage(this._image,this._pos.x+i,this._pos.y+s,this._size.x,this._size.y,-h*this._anchor.x,-l*this._anchor.y,h,l),v.restore(),v.globalAlpha=this._alpha.prev,this.dirty=!0,this},copyTransform:function(t,i,s){if(void 0===i&&(i=null),void 0===s&&(s=!1),!t.hasOwnProperty("worldTransform")||!t.worldVisible||0===t.worldAlpha)return this;var n=t.worldTransform;if(this._pos.set(t.texture.crop.x,t.texture.crop.y),this._size.set(t.texture.crop.width,t.texture.crop.height),0===n.a||0===n.d||0===this._size.x||0===this._size.y)return this;t.texture instanceof e.RenderTexture?this._image=t.texture.getCanvas():this._image=t.texture.baseTexture.source;var r=n.tx,o=n.ty;t.texture.trim&&(r+=t.texture.trim.x-t.anchor.x*t.texture.trim.width,o+=t.texture.trim.y-t.anchor.y*t.texture.trim.height),16777215!==t.tint&&(t.cachedTint!==t.tint&&(t.cachedTint=t.tint,t.tintedTexture=PIXI.CanvasTinter.getTintedTexture(t,t.tint)),this._image=t.tintedTexture,this._pos.set(0)),s&&(r|=0,o|=0);var a=this.context;return this._alpha.prev=a.globalAlpha,a.save(),a.globalAlpha=this._alpha.current,i&&(this.op=i),a[this.smoothProperty]=t.texture.baseTexture.scaleMode===PIXI.scaleModes.LINEAR,a.setTransform(n.a,n.b,n.c,n.d,r,o),a.drawImage(this._image,this._pos.x,this._pos.y,this._size.x,this._size.y,-this._size.x*t.anchor.x,-this._size.y*t.anchor.y,this._size.x,this._size.y),a.restore(),a.globalAlpha=this._alpha.prev,this.dirty=!0,this},copyRect:function(t,e,i,s,n,r,o){return this.copy(t,e.x,e.y,e.width,e.height,i,s,e.width,e.height,0,0,0,1,1,n,r,o)},draw:function(t,e,i,s,n,r,o){return this.copy(t,null,null,null,null,e,i,s,n,null,null,null,null,null,null,r,o)},drawGroup:function(t,e,i){return t.total>0&&t.forEachExists(this.drawGroupProxy,this,e,i),this},drawGroupProxy:function(t,i,s){if(t.hasOwnProperty("texture")&&this.copyTransform(t,i,s),t.type===e.GROUP&&t.exists)this.drawGroup(t,i,s);else if(t.hasOwnProperty("children")&&t.children.length>0)for(var n=0;ni.width&&(n=i.width);var r=this.context;return r.fillStyle=r.createPattern(i,s),this._circle=new e.Circle(t.start.x,t.start.y,i.height),this._circle.circumferencePoint(t.angle-1.5707963267948966,!1,this._pos),r.save(),r.translate(this._pos.x,this._pos.y),r.rotate(t.angle),r.fillRect(0,0,n,i.height),r.restore(),this.dirty=!0,this}},render:function(){return!this.disableTextureUpload&&this.dirty&&(this.baseTexture.dirty(),this.dirty=!1),this},destroy:function(){this.frameData.destroy(),this.texture.destroy(!0),e.CanvasPool.remove(this)},blendReset:function(){return this.op="source-over",this},blendSourceOver:function(){return this.op="source-over",this},blendSourceIn:function(){return this.op="source-in",this},blendSourceOut:function(){return this.op="source-out",this},blendSourceAtop:function(){return this.op="source-atop",this},blendDestinationOver:function(){return this.op="destination-over",this},blendDestinationIn:function(){return this.op="destination-in",this},blendDestinationOut:function(){return this.op="destination-out",this},blendDestinationAtop:function(){return this.op="destination-atop",this},blendXor:function(){return this.op="xor",this},blendAdd:function(){return this.op="lighter",this},blendMultiply:function(){return this.op="multiply",this},blendScreen:function(){return this.op="screen",this},blendOverlay:function(){return this.op="overlay",this},blendDarken:function(){return this.op="darken",this},blendLighten:function(){return this.op="lighten",this},blendColorDodge:function(){return this.op="color-dodge",this},blendColorBurn:function(){return this.op="color-burn",this},blendHardLight:function(){return this.op="hard-light",this},blendSoftLight:function(){return this.op="soft-light",this},blendDifference:function(){return this.op="difference",this},blendExclusion:function(){return this.op="exclusion",this},blendHue:function(){return this.op="hue",this},blendSaturation:function(){return this.op="saturation",this},blendColor:function(){return this.op="color",this},blendLuminosity:function(){return this.op="luminosity",this},copyBitmapData:function(t,e,i){t.update();for(var s,n=0;n80*s){h=c=t[0],l=u=t[1];for(var g=s;gc&&(c=d),p>u&&(u=p);f=Math.max(c-h,u-l)}return e.EarCut.earcutLinked(o,a,s,h,l,f),a},e.EarCut.linkedList=function(t,i,s,n,r){var o,a,h,l=0;for(o=i,a=s-n;o0)for(o=i;o=i;o-=n)h=e.EarCut.insertNode(o,t[o],t[o+1],h);return h},e.EarCut.filterPoints=function(t,i){if(!t)return t;i||(i=t);var s,n=t;do{if(s=!1,n.steiner||!e.EarCut.equals(n,n.next)&&0!==e.EarCut.area(n.prev,n,n.next))n=n.next;else{if(e.EarCut.removeNode(n),(n=i=n.prev)===n.next)return null;s=!0}}while(s||n!==i);return i},e.EarCut.earcutLinked=function(t,i,s,n,r,o,a){if(t){!a&&o&&e.EarCut.indexCurve(t,n,r,o);for(var h,l,c=t;t.prev!==t.next;)if(h=t.prev,l=t.next,o?e.EarCut.isEarHashed(t,n,r,o):e.EarCut.isEar(t))i.push(h.i/s),i.push(t.i/s),i.push(l.i/s),e.EarCut.removeNode(t),t=l.next,c=l.next;else if((t=l)===c){a?1===a?(t=e.EarCut.cureLocalIntersections(t,i,s),e.EarCut.earcutLinked(t,i,s,n,r,o,2)):2===a&&e.EarCut.splitEarcut(t,i,s,n,r,o):e.EarCut.earcutLinked(e.EarCut.filterPoints(t),i,s,n,r,o,1);break}}},e.EarCut.isEar=function(t){var i=t.prev,s=t,n=t.next;if(e.EarCut.area(i,s,n)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(e.EarCut.pointInTriangle(i.x,i.y,s.x,s.y,n.x,n.y,r.x,r.y)&&e.EarCut.area(r.prev,r,r.next)>=0)return!1;r=r.next}return!0},e.EarCut.isEarHashed=function(t,i,s,n){var r=t.prev,o=t,a=t.next;if(e.EarCut.area(r,o,a)>=0)return!1;for(var h=r.xo.x?r.x>a.x?r.x:a.x:o.x>a.x?o.x:a.x,u=r.y>o.y?r.y>a.y?r.y:a.y:o.y>a.y?o.y:a.y,d=e.EarCut.zOrder(h,l,i,s,n),p=e.EarCut.zOrder(c,u,i,s,n),f=t.nextZ;f&&f.z<=p;){if(f!==t.prev&&f!==t.next&&e.EarCut.pointInTriangle(r.x,r.y,o.x,o.y,a.x,a.y,f.x,f.y)&&e.EarCut.area(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=t.prevZ;f&&f.z>=d;){if(f!==t.prev&&f!==t.next&&e.EarCut.pointInTriangle(r.x,r.y,o.x,o.y,a.x,a.y,f.x,f.y)&&e.EarCut.area(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0},e.EarCut.cureLocalIntersections=function(t,i,s){var n=t;do{var r=n.prev,o=n.next.next;e.EarCut.intersects(r,n,n.next,o)&&e.EarCut.locallyInside(r,o)&&e.EarCut.locallyInside(o,r)&&(i.push(r.i/s),i.push(n.i/s),i.push(o.i/s),e.EarCut.removeNode(n),e.EarCut.removeNode(n.next),n=t=o),n=n.next}while(n!==t);return n},e.EarCut.splitEarcut=function(t,i,s,n,r,o){var a=t;do{for(var h=a.next.next;h!==a.prev;){if(a.i!==h.i&&e.EarCut.isValidDiagonal(a,h)){var l=e.EarCut.splitPolygon(a,h);return a=e.EarCut.filterPoints(a,a.next),l=e.EarCut.filterPoints(l,l.next),e.EarCut.earcutLinked(a,i,s,n,r,o),void e.EarCut.earcutLinked(l,i,s,n,r,o)}h=h.next}a=a.next}while(a!==t)},e.EarCut.eliminateHoles=function(t,i,s,n){var r,o,a,h,l,c=[];for(r=0,o=i.length;r=n.next.y){var h=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);h<=r&&h>a&&(a=h,s=n.x=n.x&&n.x>=s.x&&e.EarCut.pointInTriangle(os.x)&&e.EarCut.locallyInside(n,t)&&(s=n,u=l),n=n.next;return s},e.EarCut.indexCurve=function(t,i,s,n){var r=t;do{null===r.z&&(r.z=e.EarCut.zOrder(r.x,r.y,i,s,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,e.EarCut.sortLinked(r)},e.EarCut.sortLinked=function(t){var e,i,s,n,r,o,a,h,l=1;do{for(i=t,t=null,r=null,o=0;i;){for(o++,s=i,a=0,e=0;e0||h>0&&s;)0===a?(n=s,s=s.nextZ,h--):0!==h&&s?i.z<=s.z?(n=i,i=i.nextZ,a--):(n=s,s=s.nextZ,h--):(n=i,i=i.nextZ,a--),r?r.nextZ=n:t=n,n.prevZ=r,r=n;i=s}r.nextZ=null,l*=2}while(o>1);return t},e.EarCut.zOrder=function(t,e,i,s,n){return t=32767*(t-i)/n,e=32767*(e-s)/n,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1},e.EarCut.getLeftmost=function(t){var e=t,i=t;do{e.x=0&&(t-o)*(s-a)-(i-o)*(e-a)>=0&&(i-o)*(r-a)-(n-o)*(s-a)>=0},e.EarCut.isValidDiagonal=function(t,i){return e.EarCut.equals(t,i)||t.next.i!==i.i&&t.prev.i!==i.i&&!e.EarCut.intersectsPolygon(t,i)&&e.EarCut.locallyInside(t,i)&&e.EarCut.locallyInside(i,t)&&e.EarCut.middleInside(t,i)},e.EarCut.area=function(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)},e.EarCut.equals=function(t,e){return t.x===e.x&&t.y===e.y},e.EarCut.intersects=function(t,i,s,n){return e.EarCut.area(t,i,s)>0!=e.EarCut.area(t,i,n)>0&&e.EarCut.area(s,n,t)>0!=e.EarCut.area(s,n,i)>0},e.EarCut.intersectsPolygon=function(t,i){var s=t;do{if(s.i!==t.i&&s.next.i!==t.i&&s.i!==i.i&&s.next.i!==i.i&&e.EarCut.intersects(s,s.next,t,i))return!0;s=s.next}while(s!==t);return!1},e.EarCut.locallyInside=function(t,i){return e.EarCut.area(t.prev,t,t.next)<0?e.EarCut.area(t,i,t.next)>=0&&e.EarCut.area(t,t.prev,i)>=0:e.EarCut.area(t,i,t.prev)<0||e.EarCut.area(t,t.next,i)<0},e.EarCut.middleInside=function(t,e){var i=t,s=!1,n=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&n<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==t);return s},e.EarCut.splitPolygon=function(t,i){var s=new e.EarCut.Node(t.i,t.x,t.y),n=new e.EarCut.Node(i.i,i.x,i.y),r=t.next,o=i.prev;return t.next=i,i.prev=t,s.next=r,r.prev=s,n.next=s,s.prev=n,o.next=n,n.prev=o,n},e.EarCut.insertNode=function(t,i,s,n){var r=new e.EarCut.Node(t,i,s);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r},e.EarCut.removeNode=function(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)},e.EarCut.Node=function(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1},PIXI.WebGLGraphics=function(){},PIXI.WebGLGraphics.stencilBufferLimit=6,PIXI.WebGLGraphics.renderGraphics=function(t,i){var s,n=i.gl,r=i.projection,o=i.offset,a=i.shaderManager.primitiveShader;t.dirty&&PIXI.WebGLGraphics.updateGraphics(t,n);var h=t._webGL[n.id];if(h)for(var l=0;l=PIXI.WebGLGraphics.stencilBufferLimit&&(a.points.length<2*PIXI.WebGLGraphics.stencilBufferLimit?(o=PIXI.WebGLGraphics.switchMode(s,0),PIXI.WebGLGraphics.buildPoly(a,o)||(o=PIXI.WebGLGraphics.switchMode(s,1),PIXI.WebGLGraphics.buildComplexPoly(a,o))):(o=PIXI.WebGLGraphics.switchMode(s,1),PIXI.WebGLGraphics.buildComplexPoly(a,o))),a.lineWidth>0&&(o=PIXI.WebGLGraphics.switchMode(s,0),PIXI.WebGLGraphics.buildLine(a,o))):(o=PIXI.WebGLGraphics.switchMode(s,0),a.type===e.RECTANGLE?PIXI.WebGLGraphics.buildRectangle(a,o):a.type===e.CIRCLE||a.type===e.ELLIPSE?PIXI.WebGLGraphics.buildCircle(a,o):a.type===e.ROUNDEDRECTANGLE&&PIXI.WebGLGraphics.buildRoundedRectangle(a,o)),s.lastIndex++}for(n=0;n19600?(_=y-x,w=v-b,_/=R=Math.sqrt(_*_+w*w),w/=R,_*=F,w*=F,L.push(p-_,f-w),L.push(G,N,X,U),L.push(p+_,f+w),L.push(G,N,X,U),L.push(p-_,f-w),L.push(G,N,X,U),O++):(L.push(l,c),L.push(G,N,X,U),L.push(p-(l-p),f-(c-f)),L.push(G,N,X,U));for(u=n[2*(I-2)],d=n[2*(I-2)+1],p=n[2*(I-1)],y=-(d-(f=n[2*(I-1)+1])),v=u-p,y/=R=Math.sqrt(y*y+v*v),v/=R,y*=F,v*=F,L.push(p-y,f-v),L.push(G,N,X,U),L.push(p+y,f+v),L.push(G,N,X,U),B.push(k),s=0;sh?r:h,l=oc?o:c;s.push(a,l,h,l,h,c,a,c);var d=s.length/2;for(u=0;uS?S:C,i.beginPath(),i.moveTo(_,w+C),i.lineTo(_,w+P-C),i.quadraticCurveTo(_,w+P,_+C,w+P),i.lineTo(_+T-C,w+P),i.quadraticCurveTo(_+T,w+P,_+T,w+P-C),i.lineTo(_+T,w+C),i.quadraticCurveTo(_+T,w,_+T-C,w),i.lineTo(_+C,w),i.quadraticCurveTo(_,w,_,w+C),i.closePath(),(r.fillColor||0===r.fillColor)&&(i.globalAlpha=r.fillAlpha*s,i.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),i.fill()),r.lineWidth&&(i.globalAlpha=r.lineAlpha*s,i.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),i.stroke())}}},PIXI.CanvasGraphics.renderGraphicsMask=function(t,i){var s=t.graphicsData.length;if(0!==s){i.beginPath();for(var n=0;nP?P:T,i.moveTo(x,b+T),i.lineTo(x,b+w-T),i.quadraticCurveTo(x,b+w,x+T,b+w),i.lineTo(x+_-T,b+w),i.quadraticCurveTo(x+_,b+w,x+_,b+w-T),i.lineTo(x+_,b+T),i.quadraticCurveTo(x+_,b,x+_-T,b),i.lineTo(x+T,b),i.quadraticCurveTo(x,b,x,b+T),i.closePath()}}}},PIXI.CanvasGraphics.updateGraphicsTint=function(t){if(16777215!==t.tint)for(var e=(t.tint>>16&255)/255,i=(t.tint>>8&255)/255,s=(255&t.tint)/255,n=0;n>16&255)/255*e*255<<16)+((o>>8&255)/255*i*255<<8)+(255&o)/255*s*255,r._lineTint=((a>>16&255)/255*e*255<<16)+((a>>8&255)/255*i*255<<8)+(255&a)/255*s*255}},e.GraphicsData=function(t,e,i,s,n,r,o){this.lineWidth=t,this.lineColor=e,this.lineAlpha=i,this._lineTint=e,this.fillColor=s,this.fillAlpha=n,this._fillTint=s,this.fill=r,this.shape=o,this.type=o.type},e.GraphicsData.prototype.constructor=e.GraphicsData,e.GraphicsData.prototype.clone=function(){return new e.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.fill,this.shape)},e.Graphics=function(t,i,s){void 0===i&&(i=0),void 0===s&&(s=0),this.type=e.GRAPHICS,this.physicsType=e.SPRITE,this.anchor=new e.Point,PIXI.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor=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 e.Rectangle(0,0,1,1),this.dirty=!0,this._boundsDirty=!1,this.webGLDirty=!1,this.cachedSpriteDirty=!1,e.Component.Core.init.call(this,t,i,s,"",null)},e.Graphics.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),e.Graphics.prototype.constructor=e.Graphics,e.Component.Core.install.call(e.Graphics.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),e.Graphics.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.Graphics.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.Graphics.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.Graphics.prototype.preUpdateCore=e.Component.Core.preUpdate,e.Graphics.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.Graphics.prototype.postUpdate=function(){e.Component.PhysicsBody.postUpdate.call(this),e.Component.FixedToCamera.postUpdate.call(this),this._boundsDirty&&(this.updateLocalBounds(),this._boundsDirty=!1);for(var t=0;t0&&this.drawPolygon(s)}else this.drawPolygon(s)},e.Graphics.prototype.drawTriangles=function(t,i,s){void 0===s&&(s=!1);var n,r=new e.Point,o=new e.Point,a=new e.Point,h=[];if(i)if(t[0]instanceof e.Point)for(n=0;nc*a)}return this.dirty=!0,this._boundsDirty=!0,this},e.Graphics.prototype.arc=function(t,e,i,s,n,r,o){if(s===n)return this;void 0===r&&(r=!1),void 0===o&&(o=40),!r&&n<=s?n+=2*Math.PI:r&&s<=n&&(s+=2*Math.PI);var a=r?-1*(s-n):n-s,h=Math.ceil(Math.abs(a)/(2*Math.PI))*o;if(0===a)return this;var l=t+Math.cos(s)*i,c=e+Math.sin(s)*i;r&&this.filling?this.moveTo(t,e):this.moveTo(l,c);for(var u=this.currentPath.shape.points,d=a/(2*h),p=2*d,f=Math.cos(d),g=Math.sin(d),m=h-1,y=m%1/m,v=0;v<=m;v++){var x=d+s+p*(v+y*v),b=Math.cos(x),_=-Math.sin(x);u.push((f*b+g*_)*i+t,(f*-_+g*b)*i+e)}return this.dirty=!0,this._boundsDirty=!0,this},e.Graphics.prototype.beginFill=function(t,e){return this.filling=!0,this.fillColor=t||0,this.fillAlpha=void 0===e?1:e,this.currentPath&&this.currentPath.shape.points.length<=2&&(this.currentPath.fill=this.filling,this.currentPath.fillColor=this.fillColor,this.currentPath.fillAlpha=this.fillAlpha),this},e.Graphics.prototype.endFill=function(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this},e.Graphics.prototype.drawRect=function(t,i,s,n){return this.drawShape(new e.Rectangle(t,i,s,n)),this},e.Graphics.prototype.drawRoundedRect=function(t,i,s,n,r){return this.drawShape(new e.RoundedRectangle(t,i,s,n,r)),this},e.Graphics.prototype.drawCircle=function(t,i,s){return this.drawShape(new e.Circle(t,i,s)),this},e.Graphics.prototype.drawEllipse=function(t,i,s,n){return this.drawShape({x:t,y:i,width:s,height:n,type:e.ELLIPSE}),this},e.Graphics.prototype.drawPolygon=function(t){t instanceof e.Polygon&&(t=t.points);var i=t;if(!Array.isArray(i)){i=new Array(arguments.length);for(var s=0;sw?m:w,w=v>w?v:w,w=b>w?b:w,T=y>T?y:T,T=x>T?x:T,T=_>T?_:T,this._bounds.x=P,this._bounds.width=w-P,this._bounds.y=C,this._bounds.height=T-C,this._currentBounds=this._bounds,this._currentBounds},e.Graphics.prototype.getLocalBounds=function(){var t=this.worldTransform;this.worldTransform=e.identityMatrix;for(var i=0;ii?a+l:i,s=hn?h+c:n;else if(p===e.CIRCLE)a=r.x,h=r.y,l=r.radius+f/2,c=r.radius+f/2,t=a-li?a+l:i,s=h-cn?h+c:n;else if(p===e.ELLIPSE)a=r.x,h=r.y,l=r.width+f/2,c=r.height+f/2,t=a-li?a+l:i,s=h-cn?h+c:n;else{o=r.points;for(var g=0;gi?a+f:i,s=h-fn?h+f:n}}else t=0,i=0,s=0,n=0;var m=this.boundsPadding;this._localBounds.x=t-m,this._localBounds.width=i-t+2*m,this._localBounds.y=s-m,this._localBounds.height=n-s+2*m},e.Graphics.prototype._generateCachedSprite=function(){var t=this.getLocalBounds();if(this._cachedSprite)this._cachedSprite.buffer.resize(t.width,t.height);else{var e=new PIXI.CanvasBuffer(t.width,t.height),i=PIXI.Texture.fromCanvas(e.canvas);this._cachedSprite=new PIXI.Sprite(i),this._cachedSprite.buffer=e,this._cachedSprite.worldTransform=this.worldTransform}this._cachedSprite.anchor.x=-t.x/t.width,this._cachedSprite.anchor.y=-t.y/t.height,this._cachedSprite.buffer.context.translate(-t.x,-t.y),this.worldAlpha=1,PIXI.CanvasGraphics.renderGraphics(this,this._cachedSprite.buffer.context),this._cachedSprite.alpha=this.alpha},e.Graphics.prototype.updateCachedSpriteTexture=function(){var t=this._cachedSprite,e=t.texture,i=t.buffer.canvas;e.baseTexture.width=i.width,e.baseTexture.height=i.height,e.crop.width=e.frame.width=i.width,e.crop.height=e.frame.height=i.height,t._width=i.width,t._height=i.height,e.baseTexture.dirty()},e.Graphics.prototype.destroyCachedSprite=function(){this._cachedSprite.texture.destroy(!0),this._cachedSprite=null},e.Graphics.prototype.drawShape=function(t){this.currentPath&&this.currentPath.shape.points.length<=2&&this.graphicsData.pop(),this.currentPath=null,t instanceof e.Polygon&&(t=t.clone()).flatten();var i=new e.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,t);return this.graphicsData.push(i),i.type===e.POLYGON&&(i.shape.closed=this.filling,this.currentPath=i),this.dirty=!0,this._boundsDirty=!0,i},Object.defineProperty(e.Graphics.prototype,"cacheAsBitmap",{get:function(){return this._cacheAsBitmap},set:function(t){this._cacheAsBitmap=t,this._cacheAsBitmap?this._generateCachedSprite():this.destroyCachedSprite(),this.dirty=!0,this.webGLDirty=!0}}),e.RenderTexture=function(t,i,s,n,r,o,a,h){if(void 0===i&&(i=100),void 0===s&&(s=100),void 0===n&&(n=""),void 0===r&&(r=e.scaleModes.DEFAULT),void 0===o&&(o=1),void 0===a&&(a=PIXI.defaultRenderer),void 0===h&&(h=0),this.game=t,this.key=n,this.type=e.RENDERTEXTURE,this._tempMatrix=new e.Matrix,this.width=i,this.height=s,this.resolution=o,this.frame=new e.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=r,this.baseTexture.hasLoaded=!0,PIXI.Texture.call(this,this.baseTexture,this.frame.clone()),this.renderer=a,this.renderer.type===e.WEBGL){var l=this.renderer.gl;this.baseTexture.textureIndex=h,this.baseTexture._dirty[l.id]=!1,this.textureBuffer=new PIXI.FilterTexture(l,this.width,this.height,this.baseTexture.scaleMode,h),this.baseTexture._glTextures[l.id]=this.textureBuffer.texture,this.projection=new e.Point(.5*this.width,.5*-this.height)}else 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 e.Matrix,this._updateUvs()},e.RenderTexture.prototype=Object.create(PIXI.Texture.prototype),e.RenderTexture.prototype.constructor=e.RenderTexture,e.RenderTexture.prototype.renderXY=function(t,i,s,n){t.updateTransform(),this._tempMatrix.copyFrom(t.worldTransform),this._tempMatrix.tx=i,this._tempMatrix.ty=s,this.renderer.type===e.WEBGL?this._renderWebGL(t,this._tempMatrix,n):this._renderCanvas(t,this._tempMatrix,n)},e.RenderTexture.prototype.renderRawXY=function(t,i,s,n){this._tempMatrix.identity().translate(i,s),this.renderer.type===e.WEBGL?this._renderWebGL(t,this._tempMatrix,n):this._renderCanvas(t,this._tempMatrix,n)},e.RenderTexture.prototype.render=function(t,i,s){void 0===i||null===i?this._tempMatrix.copyFrom(t.worldTransform):this._tempMatrix.copyFrom(i),this.renderer.type===e.WEBGL?this._renderWebGL(t,this._tempMatrix,s):this._renderCanvas(t,this._tempMatrix,s)},e.RenderTexture.prototype.resize=function(t,i,s){t===this.width&&i===this.height||(this.valid=t>0&&i>0,this.width=t,this.height=i,this.frame.width=this.crop.width=t*this.resolution,this.frame.height=this.crop.height=i*this.resolution,s&&(this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution),this.renderer.type===e.WEBGL&&(this.projection.x=this.width/2,this.projection.y=-this.height/2),this.valid&&this.textureBuffer.resize(this.width,this.height))},e.RenderTexture.prototype.clear=function(){this.valid&&(this.renderer.type===e.WEBGL&&this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer),this.textureBuffer.clear())},e.RenderTexture.prototype._renderWebGL=function(t,e,i){if(this.valid&&0!==t.alpha){var s=t.worldTransform;s.identity(),s.translate(0,2*this.projection.y),e&&s.append(e),s.scale(1,-1);for(var n=0;n-1&&this.characterLimitSize0&&this.style.maxLines0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?l+=this.measureLine(e[a]):l+=this.context.measureText(e[a]).width,this.style.wordWrap&&(l-=this.context.measureText(" ").width)}else{var h=e[a].split(/(?:\t)/),l=this.padding.x+this.style.strokeThickness;if(Array.isArray(i))for(var c=0,u=0;u0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.measureLine(h[u]):Math.ceil(this.context.measureText(h[u]).width),u>0&&(c+=i[u-1]),l=c+d}else for(u=0;u0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?l+=this.measureLine(h[u]):l+=Math.ceil(this.context.measureText(h[u]).width),l+=this.game.math.snapToCeil(l,i)-l}s[a]=Math.ceil(l),n=Math.max(n,s[a])}this.canvas.width=n*this._res;var p=r.fontSize+this.style.strokeThickness+this.padding.y,f=p*o,g=this._lineSpacing;g<0&&Math.abs(g)>p&&(g=-p),0!==g&&(f+=g>0?g*e.length:g*(e.length-1)),this.canvas.height=f*this._res,this.context.scale(this._res,this._res),navigator.isCocoonJS&&this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.style.backgroundColor&&(this.context.fillStyle=this.style.backgroundColor,this.context.fillRect(0,0,this.canvas.width,this.canvas.height)),this.context.fillStyle=this.style.fill,this.context.font=this.style.font,this.context.strokeStyle=this.style.stroke,this.context.textBaseline="alphabetic",this.context.lineWidth=this.style.strokeThickness,this.context.lineCap="round",this.context.lineJoin="round";var m,y;for(this._charCount=0,a=0;a0&&(y+=g*a),"right"===this.style.align?m+=n-s[a]:"center"===this.style.align&&(m+=(n-s[a])/2),this.autoRound&&(m=Math.round(m),y=Math.round(y)),this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.updateLine(e[a],m,y):(this.style.stroke&&this.style.strokeThickness&&(this.updateShadow(this.style.shadowStroke),0===i?this.context.strokeText(e[a],m,y):this.renderTabLine(e[a],m,y,!1)),this.style.fill&&(this.updateShadow(this.style.shadowFill),0===i?this.context.fillText(e[a],m,y):this.renderTabLine(e[a],m,y,!0)));this.updateTexture(),this.dirty=!1},e.Text.prototype.renderTabLine=function(t,e,i,s){var n=t.split(/(?:\t)/),r=this.style.tabs,o=0;if(Array.isArray(r))for(var a=0,h=0;h0&&(a+=r[h-1]),o=e+a,s?this.context.fillText(n[h],o,i):this.context.strokeText(n[h],o,i);else for(h=0;h0||this.fontStyles.length>0){var n=this.fontToComponents(this.context.font);this.fontStyles[this._charCount]&&(n.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(n.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(n)}this.style.stroke&&this.style.strokeThickness&&(this.strokeColors[this._charCount]&&(this.context.strokeStyle=this.strokeColors[this._charCount]),this.updateShadow(this.style.shadowStroke)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill)),e+=this.context.measureText(s).width,this._charCount++}return Math.ceil(e)},e.Text.prototype.updateLine=function(t,e,i){for(var s=0;s0||this.fontStyles.length>0){var r=this.fontToComponents(this.context.font);this.fontStyles[this._charCount]&&(r.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(r.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(r)}this.style.stroke&&this.style.strokeThickness&&(this.strokeColors[this._charCount]&&(this.context.strokeStyle=this.strokeColors[this._charCount]),this.updateShadow(this.style.shadowStroke),this.context.strokeText(n,e,i)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill),this.context.fillText(n,e,i)),e+=this.context.measureText(n).width,this._charCount++}},e.Text.prototype.clearColors=function(){return this.colors=[],this.strokeColors=[],this.dirty=!0,this},e.Text.prototype.clearFontValues=function(){return this.fontStyles=[],this.fontWeights=[],this.dirty=!0,this},e.Text.prototype.addColor=function(t,e){return this.colors[e]=t,this.dirty=!0,this},e.Text.prototype.addStrokeColor=function(t,e){return this.strokeColors[e]=t,this.dirty=!0,this},e.Text.prototype.addFontStyle=function(t,e){return this.fontStyles[e]=t,this.dirty=!0,this},e.Text.prototype.addFontWeight=function(t,e){return this.fontWeights[e]=t,this.dirty=!0,this},e.Text.prototype.precalculateWordWrap=function(t){return this.texture.baseTexture.resolution=this._res,this.context.font=this.style.font,this.runWordWrap(t).split(/(?:\r\n|\r|\n)/)},e.Text.prototype.runWordWrap=function(t){return this.useAdvancedWrap?this.advancedWordWrap(t):this.basicWordWrap(t)},e.Text.prototype.advancedWordWrap=function(t){for(var e=this.context,i=this.style.wordWrapWidth,s="",n=t.replace(/ +/gi," ").split(/\r?\n/gi),r=n.length,o=0;ol){if(0===u){for(var g=p;g.length&&(g=g.slice(0,-1),!((f=e.measureText(g).width)<=l)););if(!g.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");var m=d.substr(g.length);c[u]=m,h+=g}var y=c[u].length?u:u+1,v=c.slice(y).join(" ").replace(/[ \n]*$/gi,"");n[o+1]=v+" "+(n[o+1]||""),r=n.length;break}h+=p,l-=f}s+=h.replace(/[ \n]*$/gi,"")+"\n"}}return s=s.replace(/[\s|\n]*$/gi,"")},e.Text.prototype.basicWordWrap=function(t){for(var e="",i=t.split("\n"),s=0;sn?(o>0&&(e+="\n"),e+=r[o]+" ",n=this.style.wordWrapWidth-a):(n-=h,e+=r[o]+" ")}ss&&(this.style.wordWrapWidth=s)),this.updateTexture(),this},e.Text.prototype.updateTexture=function(){var t=this.texture.baseTexture,e=this.texture.crop,i=this.texture.frame,s=this.canvas.width,n=this.canvas.height;if(t.width=s,t.height=n,e.width=s,e.height=n,i.width=s,i.height=n,this.texture.width=s,this.texture.height=n,this._width=s,this._height=n,this.textBounds){var r=this.textBounds.x,o=this.textBounds.y;"right"===this.style.boundsAlignH?r+=this.textBounds.width-this.canvas.width/this.resolution:"center"===this.style.boundsAlignH&&(r+=this.textBounds.halfWidth-this.canvas.width/this.resolution/2),"bottom"===this.style.boundsAlignV?o+=this.textBounds.height-this.canvas.height/this.resolution:"middle"===this.style.boundsAlignV&&(o+=this.textBounds.halfHeight-this.canvas.height/this.resolution/2),this.pivot.x=-r,this.pivot.y=-o}this.renderable=0!==s&&0!==n,this.texture.requiresReTint=!0,this.texture.baseTexture.dirty()},e.Text.prototype._renderWebGL=function(t){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderWebGL.call(this,t)},e.Text.prototype._renderCanvas=function(t){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderCanvas.call(this,t)},e.Text.prototype.determineFontProperties=function(t){var i=e.Text.fontPropertiesCache[t],s=this.testString||"|MÉq";if(!i){i={};var n=e.Text.fontPropertiesCanvas,r=e.Text.fontPropertiesContext;r.font=t;var o=Math.ceil(r.measureText(s).width),a=Math.ceil(r.measureText(s).width),h=2*a;if(a=1.4*a|0,n.width=o,n.height=h,r.fillStyle="#f00",r.fillRect(0,0,o,h),r.font=t,r.textBaseline="alphabetic",r.fillStyle="#000",r.fillText(s,0,a),!r.getImageData(0,0,o,h))return i.ascent=a,i.descent=a+6,i.fontSize=i.ascent+i.descent,e.Text.fontPropertiesCache[t]=i,i;var l,c,u=r.getImageData(0,0,o,h).data,d=u.length,p=4*o,f=0,g=!1;for(l=0;la;l--){for(c=0;c0?this._maxWidth:null,l=[],c=0;c=h&&r>-1)return{width:o||n,text:i.substr(0,c-(c-r)),end:!1,chars:l};n+=(p.xAdvance+g+this.letterSpacing)*e,l.push(s+(p.xOffset+g+this.letterSpacing)*e),s+=(p.xAdvance+g+this.letterSpacing)*e,a=d}return{width:n,text:i,end:u,chars:l}},e.BitmapText.prototype.cleanText=function(t,e){void 0===e&&(e="");var i=this._data.font;if(!i)return"";for(var s=/\r\n|\n\r|\n|\r/g,n=t.replace(s,"\n").split("\n"),r=0;rthis.textWidth&&(this.textWidth=c.width),n+=t.lineHeight*i,e=e.substr(c.text.length+1)}while(!1===c.end);this.textHeight=n;for(var r=0,o=0,a=this.textWidth*this.anchor.x,h=this.textHeight*this.anchor.y,l=0;l0&&(this._fontSize=t,this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"text",{get:function(){return this._text},set:function(t){t!==this._text&&(this._text=t.toString()||"",this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"maxWidth",{get:function(){return this._maxWidth},set:function(t){t!==this._maxWidth&&(this._maxWidth=t,this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"smoothed",{get:function(){return!this._data.base.scaleMode},set:function(t){this._data.base.scaleMode=t?0:1,this._data.base.dirty()}}),e.RetroFont=function(t,i,s,n,r,o,a,h,l,c){if(!t.cache.checkImageKey(i))return!1;void 0!==o&&null!==o||(o=t.cache.getImage(i).width/s),this.characterWidth=s,this.characterHeight=n,this.characterSpacingX=a||0,this.characterSpacingY=h||0,this.characterPerRow=o,this.offsetX=l||0,this.offsetY=c||0,this.align="left",this.multiLine=!1,this.autoUpperCase=!0,this.customSpacingX=0,this.customSpacingY=0,this.fixedWidth=0,this.fontSet=t.cache.getImage(i),this._text="",this.grabData=[],this.frameData=new e.FrameData;for(var u=this.offsetX,d=this.offsetY,p=0,f=0;f?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",e.RetroFont.TEXT_SET2=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",e.RetroFont.TEXT_SET3="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",e.RetroFont.TEXT_SET4="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",e.RetroFont.TEXT_SET5="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",e.RetroFont.TEXT_SET6="ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",e.RetroFont.TEXT_SET7="AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",e.RetroFont.TEXT_SET8="0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",e.RetroFont.TEXT_SET9="ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",e.RetroFont.TEXT_SET10="ABCDEFGHIJKLMNOPQRSTUVWXYZ",e.RetroFont.TEXT_SET11="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789",e.RetroFont.prototype.setFixedWidth=function(t,e){void 0===e&&(e="left"),this.fixedWidth=t,this.align=e},e.RetroFont.prototype.setText=function(t,e,i,s,n,r){this.multiLine=e||!1,this.customSpacingX=i||0,this.customSpacingY=s||0,this.align=n||"left",this.autoUpperCase=!r,t.length>0&&(this.text=t)},e.RetroFont.prototype.buildRetroFontText=function(){var t=0,i=0;if(this.clear(),this.multiLine){var s=this._text.split("\n");this.fixedWidth>0?this.resize(this.fixedWidth,s.length*(this.characterHeight+this.customSpacingY)-this.customSpacingY,!0):this.resize(this.getLongestLine()*(this.characterWidth+this.customSpacingX),s.length*(this.characterHeight+this.customSpacingY)-this.customSpacingY,!0);for(var n=0;n0?this.resize(this.fixedWidth,this.characterHeight,!0):this.resize(this._text.length*(this.characterWidth+this.customSpacingX),this.characterHeight,!0),t=0,this.align===e.RetroFont.ALIGN_RIGHT?t=this.width-this._text.length*(this.characterWidth+this.customSpacingX):this.align===e.RetroFont.ALIGN_CENTER&&(t=this.width/2-this._text.length*(this.characterWidth+this.customSpacingX)/2,t+=this.customSpacingX/2),t<0&&(t=0),this.pasteLine(this._text,t,0,this.customSpacingX);this.requiresReTint=!0},e.RetroFont.prototype.pasteLine=function(t,e,i,s){for(var n=0;n=0&&(this.stamp.frame=this.grabData[t.charCodeAt(n)],this.renderXY(this.stamp,e,i,!1),(e+=this.characterWidth+s)>this.width))break},e.RetroFont.prototype.getLongestLine=function(){var t=0;if(this._text.length>0)for(var e=this._text.split("\n"),i=0;it&&(t=e[i].length);return t},e.RetroFont.prototype.removeUnsupportedCharacters=function(t){for(var e="",i=0;i=0||!t&&"\n"===s)&&(e=e.concat(s))}return e},e.RetroFont.prototype.updateOffset=function(t,e){if(this.offsetX!==t||this.offsetY!==e){for(var i=t-this.offsetX,s=e-this.offsetY,n=this.game.cache.getFrameData(this.stamp.key).getFrames(),r=n.length;r--;)n[r].x+=i,n[r].y+=s;this.buildRetroFontText()}},Object.defineProperty(e.RetroFont.prototype,"text",{get:function(){return this._text},set:function(t){var e;(e=this.autoUpperCase?t.toUpperCase():t)!==this._text&&(this._text=e,this.removeUnsupportedCharacters(this.multiLine),this.buildRetroFontText())}}),Object.defineProperty(e.RetroFont.prototype,"smoothed",{get:function(){return this.stamp.smoothed},set:function(t){this.stamp.smoothed=t,this.buildRetroFontText()}}),e.Rope=function(t,i,s,n,r,o){this.points=o||[],this._hasUpdateAnimation=!1,this._updateAnimationCallback=null,i=i||0,s=s||0,n=n||null,r=r||null,this.type=e.ROPE,PIXI.DisplayObjectContainer.call(this),this.texture=e.Cache.DEFAULT,this.uvs=new Float32Array([0,1,1,1,1,0,0,1]),this.vertices=new Float32Array([0,0,100,0,100,100,0,100]),this.colors=new Float32Array([1,1,1,1]),this.indices=new Uint16Array([0,1,2,3]),o&&(this.vertices=new Float32Array(4*o.length),this.uvs=new Float32Array(4*o.length),this.colors=new Float32Array(2*o.length),this.indices=new Uint16Array(2*o.length)),this.dirty=!0,this.canvasPadding=0,this.drawMode=e.Rope.TRIANGLE_STRIP,e.Component.Core.init.call(this,t,i,s,n,r),this.refresh()},e.Rope.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),e.Rope.prototype.constructor=e.Rope,e.Component.Core.install.call(e.Rope.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),e.Rope.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.Rope.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.Rope.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.Rope.prototype.preUpdateCore=e.Component.Core.preUpdate,e.Rope.TRIANGLE_STRIP=0,e.Rope.TRIANGLES=1,e.Rope.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.Rope.prototype.update=function(){this._hasUpdateAnimation&&this.updateAnimation.call(this)},e.Rope.prototype.reset=function(t,i){return e.Component.Reset.prototype.reset.call(this,t,i),this},e.Rope.prototype.refresh=function(){var t=this.points;if(!(t.length<1)){var e=this.uvs,i=this.indices,s=this.colors;this.count-=.2,e[0]=0,e[1]=0,e[2]=0,e[3]=1,s[0]=1,s[1]=1,i[0]=0,i[1]=1;for(var n,r,o=t.length,a=1;a1&&1,o=Math.sqrt(s.x*s.x+s.y*s.y),a=this.texture.height/2,s.x/=o,s.y/=o,s.x*=a,s.y*=a,h[r]=n.x+s.x,h[r+1]=n.y+s.y,h[r+2]=n.x-s.x,h[r+3]=n.y-s.y,i=n;PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)}},e.Rope.prototype.setTexture=function(t){this.texture=t},e.Rope.prototype._renderWebGL=function(t){!this.visible||this.alpha<=0||(t.spriteBatch.stop(),this._vertexBuffer||this._initWebGL(t),t.shaderManager.setShader(t.shaderManager.stripShader),this._renderStrip(t),t.spriteBatch.start())},e.Rope.prototype._initWebGL=function(t){var e=t.gl;this._vertexBuffer=e.createBuffer(),this._indexBuffer=e.createBuffer(),this._uvBuffer=e.createBuffer(),this._colorBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this._vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertices,e.DYNAMIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this._uvBuffer),e.bufferData(e.ARRAY_BUFFER,this.uvs,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this._colorBuffer),e.bufferData(e.ARRAY_BUFFER,this.colors,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,e.STATIC_DRAW)},e.Rope.prototype._renderStrip=function(t){var i=t.gl,s=t.projection,n=t.offset,r=t.shaderManager.stripShader,o=this.drawMode===e.Rope.TRIANGLE_STRIP?i.TRIANGLE_STRIP:i.TRIANGLES;t.blendModeManager.setBlendMode(this.blendMode),i.uniformMatrix3fv(r.translationMatrix,!1,this.worldTransform.toArray(!0)),i.uniform2f(r.projectionVector,s.x,-s.y),i.uniform2f(r.offsetVector,-n.x,-n.y),i.uniform1f(r.alpha,this.worldAlpha),this.dirty?(this.dirty=!1,i.bindBuffer(i.ARRAY_BUFFER,this._vertexBuffer),i.bufferData(i.ARRAY_BUFFER,this.vertices,i.STATIC_DRAW),i.vertexAttribPointer(r.aVertexPosition,2,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,this._uvBuffer),i.bufferData(i.ARRAY_BUFFER,this.uvs,i.STATIC_DRAW),i.vertexAttribPointer(r.aTextureCoord,2,i.FLOAT,!1,0,0),i.activeTexture(i.TEXTURE0),this.texture.baseTexture._dirty[i.id]?t.renderer.updateTexture(this.texture.baseTexture):i.bindTexture(i.TEXTURE_2D,this.texture.baseTexture._glTextures[i.id]),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,this._indexBuffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,this.indices,i.STATIC_DRAW)):(i.bindBuffer(i.ARRAY_BUFFER,this._vertexBuffer),i.bufferSubData(i.ARRAY_BUFFER,0,this.vertices),i.vertexAttribPointer(r.aVertexPosition,2,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,this._uvBuffer),i.vertexAttribPointer(r.aTextureCoord,2,i.FLOAT,!1,0,0),i.activeTexture(i.TEXTURE0),this.texture.baseTexture._dirty[i.id]?t.renderer.updateTexture(this.texture.baseTexture):i.bindTexture(i.TEXTURE_2D,this.texture.baseTexture._glTextures[i.id]),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,this._indexBuffer)),i.drawElements(o,this.indices.length,i.UNSIGNED_SHORT,0)},e.Rope.prototype._renderCanvas=function(t){var i=t.context,s=this.worldTransform,n=s.tx*t.resolution+t.shakeX,r=s.ty*t.resolution+t.shakeY;t.roundPixels?i.setTransform(s.a,s.b,s.c,s.d,0|n,0|r):i.setTransform(s.a,s.b,s.c,s.d,n,r),this.drawMode===e.Rope.TRIANGLE_STRIP?this._renderCanvasTriangleStrip(i):this._renderCanvasTriangles(i)},e.Rope.prototype._renderCanvasTriangleStrip=function(t){var e=this.vertices,i=this.uvs,s=e.length/2;this.count++;for(var n=0;n0){var _=this.canvasPadding/this.worldTransform.a,w=this.canvasPadding/this.worldTransform.d,T=(l+c+u)/3,P=(d+p+f)/3,C=l-T,S=d-P,A=Math.sqrt(C*C+S*S);l=T+C/A*(A+_),d=P+S/A*(A+w),S=p-P,c=T+(C=c-T)/(A=Math.sqrt(C*C+S*S))*(A+_),p=P+S/A*(A+w),S=f-P,u=T+(C=u-T)/(A=Math.sqrt(C*C+S*S))*(A+_),f=P+S/A*(A+w)}t.save(),t.beginPath(),t.moveTo(l,d),t.lineTo(c,p),t.lineTo(u,f),t.closePath(),t.clip();var E=g*x+v*y+m*b-x*y-v*m-g*b,M=l*x+v*u+c*b-x*u-v*c-l*b,R=g*c+l*y+m*u-c*y-l*m-g*u,L=g*x*u+v*c*y+l*m*b-l*x*y-v*m*u-g*c*b,B=d*x+v*f+p*b-x*f-v*p-d*b,I=g*p+d*y+m*f-p*y-d*m-g*f,O=g*x*f+v*p*y+d*m*b-d*x*y-v*m*f-g*p*b;t.transform(M/E,B/E,R/E,I/E,L/E,O/E),t.drawImage(o,0,0),t.restore()},e.Rope.prototype.renderStripFlat=function(t){var e=this.context,i=t.vertices,s=i.length/2;this.count++,e.beginPath();for(var n=1;nl?y:l,c=v>c?v:c}if(u===-1/0||c===1/0)return e.EmptyRectangle;var x=this._bounds;return x.x=u,x.width=l-u,x.y=d,x.height=c-d,this._currentBounds=x,x},Object.defineProperty(e.Rope.prototype,"updateAnimation",{get:function(){return this._updateAnimation},set:function(t){t&&"function"==typeof t?(this._hasUpdateAnimation=!0,this._updateAnimation=t):(this._hasUpdateAnimation=!1,this._updateAnimation=null)}}),Object.defineProperty(e.Rope.prototype,"segments",{get:function(){for(var t,i,s,n,r,o,a,h,l=[],c=0;c(_=y>(_=g>(_=p>_?p:_)?g:_)?y:_)?x:_,w=b>(w=v>(w=m>(w=f>w?f:w)?m:w)?v:w)?b:w;var C=this._bounds;return C.x=T,C.width=_-T,C.y=P,C.height=w-P,this._currentBounds=C,C},Object.defineProperty(e.TileSprite.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t}}),Object.defineProperty(e.TileSprite.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t}}),e.CanvasPool={create:function(t,i,s){var n,r=e.CanvasPool.getFirst();if(-1===r){var o={parent:t,canvas:document.createElement("canvas")};e.CanvasPool.pool.push(o),n=o.canvas}else e.CanvasPool.pool[r].parent=t,n=e.CanvasPool.pool[r].canvas;return void 0!==i&&(n.width=i,n.height=s),n},getFirst:function(){for(var t=e.CanvasPool.pool,i=0;i=9&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var e=parseInt(RegExp.$1,10),i=parseInt(RegExp.$2,10);(10===e&&i>=11||e>10)&&(s.dolby=!0)}}catch(t){}}(),function(){var t=document.createElement("video");try{t.canPlayType&&(t.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,"")&&(s.oggVideo=!0),t.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,"")&&(s.h264Video=!0,s.mp4Video=!0),t.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")&&(s.webmVideo=!0),t.canPlayType('video/webm; codecs="vp9"').replace(/^no$/,"")&&(s.vp9Video=!0),t.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/,"")&&(s.hlsVideo=!0))}catch(t){}}(),function(){var t,e=document.createElement("p"),i={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(e,null);for(var n in i)void 0!==e.style[n]&&(e.style[n]="translate3d(1px,1px,1px)",t=window.getComputedStyle(e).getPropertyValue(i[n]));document.body.removeChild(e),s.css3D=void 0!==t&&t.length>0&&"none"!==t}(),s.pixelRatio=window.devicePixelRatio||1,s.iPhone=-1!==navigator.userAgent.toLowerCase().indexOf("iphone"),s.iPhone4=2===s.pixelRatio&&s.iPhone,s.iPad=-1!==navigator.userAgent.toLowerCase().indexOf("ipad"),"undefined"!=typeof Int8Array?s.typedArray=!0:s.typedArray=!1,"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint32Array&&(s.littleEndian=t(),s.LITTLE_ENDIAN=s.littleEndian),s.support32bit="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof Int32Array&&null!==s.littleEndian&&i(),navigator.vibrate=navigator.vibrate||navigator.webkitVibrate||navigator.mozVibrate||navigator.msVibrate,navigator.vibrate&&(s.vibration=!0),function(){s.canvas=!!window.CanvasRenderingContext2D||s.cocoonJS;try{s.localStorage=!!localStorage.getItem}catch(t){s.localStorage=!1}s.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),s.fileSystem=!!window.requestFileSystem,s.webGL=!!window.WebGLRenderingContext,s.worker=!!window.Worker,s.pointerLockElement="pointerLockElement"in document&&"pointerLockElement"||"mozPointerLockElement"in document&&"mozPointerLockElement"||"webkitPointerLockElement"in document&&"webkitPointerLockElement",s.pointerlockchange="onpointerlockchange"in document&&"pointerlockchange"||"onmozpointerlockchange"in document&&"mozpointerlockchange"||"onwebkitpointerlockchange"in document&&"webkitpointerlockchange",s.pointerlockerror="onpointerlockerror"in document&&"pointerlockerror"||"onmozpointerlockerror"in document&&"mozpointerlockerror"||"onwebkitpointerlockerror"in document&&"webkitpointerlockerror",s.pointerLock=!!s.pointerLockElement,s.quirksMode="CSS1Compat"!==document.compatMode,navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||navigator.oGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,s.getUserMedia=s.getUserMedia&&!!navigator.getUserMedia&&!!window.URL,s.firefox&&s.firefoxVersion<21&&(s.getUserMedia=!1),!s.iOS&&(s.ie||s.firefox||s.chrome)&&(s.canvasBitBltShift=!0),(s.safari||s.mobileSafari)&&(s.canvasBitBltShift=!1)}(),function(){var t=e.CanvasPool.create(this,6,1),i=t.getContext("2d");i.fillStyle="rgba(10, 20, 30, 0.5)",i.fillRect(0,0,1,1);var n=i.getImageData(0,0,1,1);if(n){i.putImageData(n,1,0);var r=i.getImageData(1,0,1,1);s.canHandleAlpha=r.data[0]===n.data[0]&&r.data[1]===n.data[1]&&r.data[2]===n.data[2]&&r.data[3]===n.data[3]}i.globalCompositeOperation="multiply",s.canUseMultiply="multiply"===i.globalCompositeOperation,e.CanvasPool.removeByCanvas(t),PIXI.CanvasTinter.tintMethod=s.canUseMultiply?PIXI.CanvasTinter.tintWithMultiply:PIXI.CanvasTinter.tintWithPerPixel}(),function(){for(var t=["requestFullscreen","requestFullScreen","webkitRequestFullscreen","webkitRequestFullScreen","msRequestFullscreen","msRequestFullScreen","mozRequestFullScreen","mozRequestFullscreen"],e=document.createElement("div"),i=0;i=1)&&(s.touch=!0),(window.PointerEvent||window.MSPointerEvent||window.navigator.msPointerEnabled||window.navigator.pointerEnabled)&&(s.mspointer=!0),s.cocoonJS||("onwheel"in window||s.ie&&"WheelEvent"in window?s.wheelEvent="wheel":"onmousewheel"in window?s.wheelEvent="mousewheel":s.firefox&&"MouseScrollEvent"in window&&(s.wheelEvent="DOMMouseScroll"))},e.Device.canPlayAudio=function(t){return!("mp3"!==t||!this.mp3)||(!("ogg"!==t||!this.ogg&&!this.opus)||(!("m4a"!==t||!this.m4a)||(!("opus"!==t||!this.opus)||(!("wav"!==t||!this.wav)||(!("webm"!==t||!this.webm)||!("mp4"!==t||!this.dolby))))))},e.Device.canPlayVideo=function(t){return!("webm"!==t||!this.webmVideo&&!this.vp9Video)||(!("mp4"!==t||!this.mp4Video&&!this.h264Video)||(!("ogg"!==t&&"ogv"!==t||!this.oggVideo)||!("mpeg"!==t||!this.hlsVideo)))},e.Device.needsTouchUnlock=function(){return!!(!this.cocoonJS&&(this.iOS||this.android)||window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock)},e.Device.isAndroidStockBrowser=function(){var t=window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]+)/);return t&&t[1]<537},e.Canvas={create:function(t,i,s,n,r){i=i||256,s=s||256;var o=r?document.createElement("canvas"):e.CanvasPool.create(t,i,s);return"string"==typeof n&&""!==n&&(o.id=n),o.width=i,o.height=s,o.style.display="block",o},setBackgroundColor:function(t,e){return e=e||"rgb(0,0,0)",t.style.backgroundColor=e,t},setTouchAction:function(t,e){return e=e||"none",t.style.msTouchAction=e,t.style["ms-touch-action"]=e,t.style["touch-action"]=e,t},setUserSelect:function(t,e){return e=e||"none",t.style["-webkit-touch-callout"]=e,t.style["-webkit-user-select"]=e,t.style["-khtml-user-select"]=e,t.style["-moz-user-select"]=e,t.style["-ms-user-select"]=e,t.style["user-select"]=e,t.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",t},addToDOM:function(t,e,i){var s;return void 0===i&&(i=!0),e&&("string"==typeof e?s=document.getElementById(e):"object"==typeof e&&1===e.nodeType&&(s=e)),s||(s=document.body),i&&s.style&&(s.style.overflow="hidden"),s.appendChild(t),t},removeFromDOM:function(t){t.parentNode&&t.parentNode.removeChild(t)},setTransform:function(t,e,i,s,n,r,o){return t.setTransform(s,r,o,n,e,i),t},setSmoothingEnabled:function(t,i){var s=e.Canvas.getSmoothingPrefix(t);return s&&(t[s]=i),t},getSmoothingPrefix:function(t){var e=["i","webkitI","msI","mozI","oI"];for(var i in e){var s=e[i]+"mageSmoothingEnabled";if(s in t)return s}return null},getSmoothingEnabled:function(t){var i=e.Canvas.getSmoothingPrefix(t);if(i)return t[i]},setImageRenderingCrisp:function(t){for(var e=["-webkit-optimize-contrast","-moz-crisp-edges","crisp-edges","pixelated"],i=0;i0&&0==(t&t-1))return t;for(var e=1;e0&&0==(t&t-1)&&e>0&&0==(e&e-1)},random:function(t,e){if(void 0===t&&(t=0),void 0===e&&(e=1),t===e)return t;if(t>e){var i=t;t=e,e=i}return Math.random()*(e-t)+t},between:function(t,e){if(void 0===t&&(t=0),void 0===e&&(e=1),t===e)return t;if(t>e){var i=t;t=e,e=i}return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t},fuzzyEqual:function(t,e,i){return void 0===i&&(i=1e-4),Math.abs(t-e)e-i},fuzzyCeil:function(t,e){return void 0===e&&(e=1e-4),Math.ceil(t-e)},fuzzyFloor:function(t,e){return void 0===e&&(e=1e-4),Math.floor(t+e)},average:function(){for(var t=0,e=arguments.length,i=0;i=e.Math.PI2-s?t=i:(Math.abs(i-t)>Math.PI&&(it?t+=s:i=0?t:t+2*Math.PI},maxAdd:function(t,e,i){return Math.min(t+e,i)},minSub:function(t,e,i){return Math.max(t-e,i)},wrap:function(t,e,i){var s=i-e;if(s<=0)return 0;var n=(t-e)%s;return n<0&&(n+=s),n+e},wrapValue:function(t,e,i){return t=Math.abs(t),e=Math.abs(e),i=Math.abs(i),(t+e)%i},isOdd:function(t){return!!(1&t)},isEven:function(t){return!(1&t)},min:function(){if(1===arguments.length&&"object"==typeof arguments[0])t=arguments[0];else var t=arguments;for(var e=1,i=0,s=t.length;et[i]&&(i=e);return t[i]},minProperty:function(t){if(2===arguments.length&&"object"==typeof arguments[1])e=arguments[1];else var e=arguments.slice(1);for(var i=1,s=0,n=e.length;ie[s][t]&&(s=i);return e[s][t]},wrapAngle:function(t,e){return e?this.wrap(t,-Math.PI,Math.PI):this.wrap(t,-180,180)},linearInterpolation:function(t,e){var i=t.length-1,s=i*e,n=Math.floor(s);return e<0?this.linear(t[0],t[1],s):e>1?this.linear(t[i],t[i-1],i-s):this.linear(t[n],t[n+1>i?i:n+1],s-n)},bezierInterpolation:function(t,e){for(var i=0,s=t.length-1,n=0;n<=s;n++)i+=Math.pow(1-e,s-n)*Math.pow(e,n)*t[n]*this.bernstein(s,n);return i},catmullRomInterpolation:function(t,e){var i=t.length-1,s=i*e,n=Math.floor(s);return t[0]===t[i]?(e<0&&(n=Math.floor(s=i*(1+e))),this.catmullRom(t[(n-1+i)%i],t[n],t[(n+1)%i],t[(n+2)%i],s-n)):e<0?t[0]-(this.catmullRom(t[0],t[0],t[1],t[1],-s)-t[0]):e>1?t[i]-(this.catmullRom(t[i],t[i],t[i-1],t[i-1],s-i)-t[i]):this.catmullRom(t[n?n-1:0],t[n],t[i0?Math.ceil(t):Math.floor(t)},sinCosGenerator:function(t,e,i,s){void 0===e&&(e=1),void 0===i&&(i=1),void 0===s&&(s=1);for(var n=e,r=i,o=s*Math.PI/t,a=[],h=[],l=0;l0?1:0},percent:function(t,e,i){return void 0===i&&(i=0),t>e||i>e?1:tt?0:(t-i)/e}},e.RandomDataGenerator=function(t){void 0===t&&(t=[]),this.c=1,this.s0=0,this.s1=0,this.s2=0,"string"==typeof t?this.state(t):this.sow(t)},e.RandomDataGenerator.prototype={rnd:function(){var t=2091639*this.s0+2.3283064365386963e-10*this.c;return this.c=0|t,this.s0=this.s1,this.s1=this.s2,this.s2=t-this.c,this.s2},sow:function(t){if(this.s0=this.hash(" "),this.s1=this.hash(this.s0),this.s2=this.hash(this.s1),this.c=1,t)for(var e=0;e>>0,s=(e*=s)>>>0,s+=4294967296*(e-=s);return 2.3283064365386963e-10*(s>>>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(t,e){return Math.floor(this.realInRange(0,e-t+1)+t)},between:function(t,e){return this.integerInRange(t,e)},realInRange:function(t,e){return this.frac()*(e-t)+t},normal:function(){return 1-2*this.frac()},uuid:function(){var t="",e="";for(e=t="";t++<36;e+=~t%5|3*t&4?(15^t?8^this.frac()*(20^t?16:4):4).toString(16):"-");return e},pick:function(t){return t[this.integerInRange(0,t.length-1)]},sign:function(){return this.pick([-1,1])},weightedPick:function(t){return t[~~(Math.pow(this.frac(),2)*(t.length-1)+.5)]},timestamp:function(t,e){return this.realInRange(t||9466848e5,e||1577862e6)},angle:function(){return this.integerInRange(-180,180)},state:function(t){return"string"==typeof t&&t.match(/^!rnd/)&&(t=t.split(","),this.c=parseFloat(t[1]),this.s0=parseFloat(t[2]),this.s1=parseFloat(t[3]),this.s2=parseFloat(t[4])),["!rnd",this.c,this.s0,this.s1,this.s2].join(",")}},e.RandomDataGenerator.prototype.constructor=e.RandomDataGenerator,e.QuadTree=function(t,e,i,s,n,r,o){this.maxObjects=10,this.maxLevels=4,this.level=0,this.bounds={},this.objects=[],this.nodes=[],this._empty=[],this.reset(t,e,i,s,n,r,o)},e.QuadTree.prototype={reset:function(t,e,i,s,n,r,o){this.maxObjects=n||10,this.maxLevels=r||4,this.level=o||0,this.bounds={x:Math.round(t),y:Math.round(e),width:i,height:s,subWidth:Math.floor(i/2),subHeight:Math.floor(s/2),right:Math.round(t)+Math.floor(i/2),bottom:Math.round(e)+Math.floor(s/2)},this.objects.length=0,this.nodes.length=0},populate:function(t){t.forEach(this.populateHandler,this,!0)},populateHandler:function(t){t.body&&t.exists&&this.insert(t.body)},split:function(){this.nodes[0]=new e.QuadTree(this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[1]=new e.QuadTree(this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[2]=new e.QuadTree(this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[3]=new e.QuadTree(this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1)},insert:function(t){var e,i=0;if(null==this.nodes[0]||-1===(e=this.getIndex(t))){if(this.objects.push(t),this.objects.length>this.maxObjects&&this.levelthis.bounds.bottom&&(e=2):t.x>this.bounds.right&&(t.ythis.bounds.bottom&&(e=3)),e},retrieve:function(t){if(t instanceof e.Rectangle)var i=this.objects,s=this.getIndex(t);else{if(!t.body)return this._empty;var i=this.objects,s=this.getIndex(t.body)}return this.nodes[0]&&(i=-1!==s?i.concat(this.nodes[s].retrieve(t)):(i=(i=(i=i.concat(this.nodes[0].retrieve(t))).concat(this.nodes[1].retrieve(t))).concat(this.nodes[2].retrieve(t))).concat(this.nodes[3].retrieve(t))),i},clear:function(){this.objects.length=0;for(var t=this.nodes.length;t--;)this.nodes[t].clear(),this.nodes.splice(t,1);this.nodes.length=0}},e.QuadTree.prototype.constructor=e.QuadTree,e.Net=function(t){this.game=t},e.Net.prototype={getHostName:function(){return window.location&&window.location.hostname?window.location.hostname:null},checkDomainName:function(t){return-1!==window.location.hostname.indexOf(t)},updateQueryString:function(t,e,i,s){void 0===i&&(i=!1),void 0!==s&&""!==s||(s=window.location.href);var n="",r=new RegExp("([?|&])"+t+"=.*?(&|#|$)(.*)","gi");if(r.test(s))n=void 0!==e&&null!==e?s.replace(r,"$1"+t+"="+e+"$2$3"):s.replace(r,"$1$3").replace(/(&|\?)$/,"");else if(void 0!==e&&null!==e){var o=-1!==s.indexOf("?")?"&":"?",a=s.split("#");s=a[0]+o+t+"="+e,a[1]&&(s+="#"+a[1]),n=s}else n=s;if(!i)return n;window.location.href=n},getQueryString:function(t){void 0===t&&(t="");var e={},i=location.search.substring(1).split("&");for(var s in i){var n=i[s].split("=");if(n.length>1){if(t&&t===this.decodeURI(n[0]))return this.decodeURI(n[1]);e[this.decodeURI(n[0])]=this.decodeURI(n[1])}}return e},decodeURI:function(t){return decodeURIComponent(t.replace(/\+/g," "))}},e.Net.prototype.constructor=e.Net,e.TweenManager=function(t){this.game=t,this.frameBased=!1,this._tweens=[],this._add=[],this.easeMap={Power0:e.Easing.Power0,Power1:e.Easing.Power1,Power2:e.Easing.Power2,Power3:e.Easing.Power3,Power4:e.Easing.Power4,Linear:e.Easing.Linear.None,Quad:e.Easing.Quadratic.Out,Cubic:e.Easing.Cubic.Out,Quart:e.Easing.Quartic.Out,Quint:e.Easing.Quintic.Out,Sine:e.Easing.Sinusoidal.Out,Expo:e.Easing.Exponential.Out,Circ:e.Easing.Circular.Out,Elastic:e.Easing.Elastic.Out,Back:e.Easing.Back.Out,Bounce:e.Easing.Bounce.Out,"Quad.easeIn":e.Easing.Quadratic.In,"Cubic.easeIn":e.Easing.Cubic.In,"Quart.easeIn":e.Easing.Quartic.In,"Quint.easeIn":e.Easing.Quintic.In,"Sine.easeIn":e.Easing.Sinusoidal.In,"Expo.easeIn":e.Easing.Exponential.In,"Circ.easeIn":e.Easing.Circular.In,"Elastic.easeIn":e.Easing.Elastic.In,"Back.easeIn":e.Easing.Back.In,"Bounce.easeIn":e.Easing.Bounce.In,"Quad.easeOut":e.Easing.Quadratic.Out,"Cubic.easeOut":e.Easing.Cubic.Out,"Quart.easeOut":e.Easing.Quartic.Out,"Quint.easeOut":e.Easing.Quintic.Out,"Sine.easeOut":e.Easing.Sinusoidal.Out,"Expo.easeOut":e.Easing.Exponential.Out,"Circ.easeOut":e.Easing.Circular.Out,"Elastic.easeOut":e.Easing.Elastic.Out,"Back.easeOut":e.Easing.Back.Out,"Bounce.easeOut":e.Easing.Bounce.Out,"Quad.easeInOut":e.Easing.Quadratic.InOut,"Cubic.easeInOut":e.Easing.Cubic.InOut,"Quart.easeInOut":e.Easing.Quartic.InOut,"Quint.easeInOut":e.Easing.Quintic.InOut,"Sine.easeInOut":e.Easing.Sinusoidal.InOut,"Expo.easeInOut":e.Easing.Exponential.InOut,"Circ.easeInOut":e.Easing.Circular.InOut,"Elastic.easeInOut":e.Easing.Elastic.InOut,"Back.easeInOut":e.Easing.Back.InOut,"Bounce.easeInOut":e.Easing.Bounce.InOut},this.game.onPause.add(this._pauseAll,this),this.game.onResume.add(this._resumeAll,this)},e.TweenManager.prototype={getAll:function(){return this._tweens},removeAll:function(){for(var t=0;t0&&(this._tweens=this._tweens.concat(this._add),this._add.length=0),!0},isTweening:function(t,e){return e||(e=!1),this._tweens.some(function(i){return i.target===t&&(!e||i.isRunning&&!i.pendingDelete)})},_pauseAll:function(){for(var t=this._tweens.length-1;t>=0;t--)this._tweens[t]._pause()},_resumeAll:function(){for(var t=this._tweens.length-1;t>=0;t--)this._tweens[t]._resume()},pauseAll:function(){for(var t=this._tweens.length-1;t>=0;t--)this._tweens[t].pause()},resumeAll:function(){for(var t=this._tweens.length-1;t>=0;t--)this._tweens[t].resume(!0)},destroy:function(){this.game.onPause.remove(this._pauseAll,this),this.game.onResume.remove(this._resumeAll,this),this.game=null,this._add=null,this._tweens=null}},e.TweenManager.prototype.constructor=e.TweenManager,e.Tween=function(t,i,s){this.game=i,this.target=t,this.manager=s,this.timeline=[],this.reverse=!1,this.timeScale=1,this.repeatCounter=0,this.pendingDelete=!1,this.onStart=new e.Signal,this.onLoop=new e.Signal,this.onRepeat=new e.Signal,this.onChildComplete=new e.Signal,this.onComplete=new e.Signal,this.isRunning=!1,this.current=0,this.properties={},this.chainedTween=null,this.isPaused=!1,this.frameBased=s.frameBased,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,this._pausedTime=0,this._codePaused=!1,this._hasStarted=!1},e.Tween.updateColor=function(t){e.Color.updateColor(t.target)},e.Tween.prototype={to:function(t,i,s,n,r,o,a){return(void 0===i||i<=0)&&(i=1e3),void 0!==s&&null!==s||(s=e.Easing.Default),void 0===n&&(n=!1),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=!1),"string"==typeof s&&this.manager.easeMap[s]&&(s=this.manager.easeMap[s]),this.isRunning?(console.warn("Phaser.Tween.to cannot be called after Tween.start"),this):(this.timeline.push(new e.TweenData(this).to(t,i,s,r,o,a)),n&&this.start(),this)},from:function(t,i,s,n,r,o,a){return void 0===i&&(i=1e3),void 0!==s&&null!==s||(s=e.Easing.Default),void 0===n&&(n=!1),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=!1),"string"==typeof s&&this.manager.easeMap[s]&&(s=this.manager.easeMap[s]),this.isRunning?(console.warn("Phaser.Tween.from cannot be called after Tween.start"),this):(this.timeline.push(new e.TweenData(this).from(t,i,s,r,o,a)),n&&this.start(),this)},start:function(t){if(void 0===t&&(t=0),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(i=0;ithis.timeline.length-1)&&(t=0),this.current=t,this.timeline[this.current].start(),this},stop:function(t){return void 0===t&&(t=!1),this.isRunning=!1,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,t&&(this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start()),this.manager.remove(this),this},updateTweenData:function(t,e,i){if(0===this.timeline.length)return this;if(void 0===i&&(i=0),-1===i)for(var s=0;s0?arguments[t-1].chainedTween=arguments[t]:this.chainedTween=arguments[t];return this},loop:function(t){return void 0===t&&(t=!0),this.repeatCounter=t?-1:0,this},onUpdateCallback:function(t,e){return this._onUpdateCallback=t,this._onUpdateCallbackContext=e,this},pause:function(){this.isPaused=!0,this._codePaused=!0,this._pausedTime=this.game.time.time},_pause:function(){this._codePaused||(this.isPaused=!0,this._pausedTime=this.game.time.time)},resume:function(){if(this.isPaused){this.isPaused=!1,this._codePaused=!1;for(var t=0;t0?(this.repeatCounter--,this.timeline[this.current].start(),this.onRepeat.dispatch(this.target,this),!0):(this.isRunning=!1,this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start(),!1):(this.onChildComplete.dispatch(this.target,this),this.timeline[this.current].start(),!0)}},generateData:function(t,e){if(null===this.game||null===this.target)return null;void 0===t&&(t=60),void 0===e&&(e=[]);for(s=0;s0?this.isRunning=!1:this.isRunning=!0,this.isFrom)for(var t in this.vStartCache)this.vStart[t]=this.vEndCache[t],this.vEnd[t]=this.vStartCache[t],this.parent.target[t]=this.vStart[t];return this.value=0,this.repeatCounter=this.repeatTotal,this},loadValues:function(){for(var t in this.parent.properties){if(this.vStart[t]=this.parent.properties[t],Array.isArray(this.vEnd[t])){if(0===this.vEnd[t].length)continue;0===this.percent&&(this.vEnd[t]=[this.vStart[t]].concat(this.vEnd[t]))}void 0!==this.vEnd[t]?("string"==typeof this.vEnd[t]&&(this.vEnd[t]=this.vStart[t]+parseFloat(this.vEnd[t])),this.parent.properties[t]=this.vEnd[t]):this.vEnd[t]=this.vStart[t],this.vStartCache[t]=this.vStart[t],this.vEndCache[t]=this.vEnd[t]}return this},update:function(t){if(this.isRunning){if(t=this.startTime))return e.TweenData.PENDING;this.isRunning=!0}var i=this.parent.frameBased?this.game.time.physicsElapsedMS:this.game.time.elapsedMS;this.parent.reverse?(this.dt-=i*this.parent.timeScale,this.dt=Math.max(this.dt,0)):(this.dt+=i*this.parent.timeScale,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent);for(var s in this.vEnd){var n=this.vStart[s],r=this.vEnd[s];Array.isArray(r)?this.parent.target[s]=this.interpolationFunction.call(this.interpolationContext,r,this.value):this.parent.target[s]=n+(r-n)*this.value}return!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent?this.repeat():e.TweenData.RUNNING},generateData:function(t){this.parent.reverse?this.dt=this.duration:this.dt=0;var e=[],i=!1,s=1/t*1e3;do{this.parent.reverse?(this.dt-=s,this.dt=Math.max(this.dt,0)):(this.dt+=s,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent);var n={};for(var r in this.vEnd){var o=this.vStart[r],a=this.vEnd[r];Array.isArray(a)?n[r]=this.interpolationFunction.call(this.interpolationContext,a,this.value):n[r]=o+(a-o)*this.value}e.push(n),(!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent)&&(i=!0)}while(!i);if(this.yoyo){var h=e.slice();h.reverse(),e=e.concat(h)}return e},repeat:function(){if(this.yoyo){if(this.inReverse&&0===this.repeatCounter){for(var t in this.vStartCache)this.vStart[t]=this.vStartCache[t],this.vEnd[t]=this.vEndCache[t];return this.inReverse=!1,e.TweenData.COMPLETE}this.inReverse=!this.inReverse}else if(0===this.repeatCounter)return e.TweenData.COMPLETE;if(this.inReverse)for(var t in this.vStartCache)this.vStart[t]=this.vEndCache[t],this.vEnd[t]=this.vStartCache[t];else{for(var t in this.vStartCache)this.vStart[t]=this.vStartCache[t],this.vEnd[t]=this.vEndCache[t];this.repeatCounter>0&&this.repeatCounter--}return this.startTime=this.game.time.time,this.yoyo&&this.inReverse?this.startTime+=this.yoyoDelay:this.inReverse||(this.startTime+=this.repeatDelay),this.parent.reverse?this.dt=this.duration:this.dt=0,e.TweenData.LOOPED}},e.TweenData.prototype.constructor=e.TweenData,e.Easing={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)},Out:function(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)},InOut:function(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:(.1,-1*Math.pow(2,10*(t-=1))*Math.sin((t-.1)*(2*Math.PI)/.4))},Out:function(t){return 0===t?0:1===t?1:(.1,1*Math.pow(2,-10*t)*Math.sin((t-.1)*(2*Math.PI)/.4)+1)},InOut:function(t){return 0===t?0:1===t?1:(.1,(t*=2)<1?1*Math.pow(2,10*(t-=1))*Math.sin((t-.1)*(2*Math.PI)/.4)*-.5:1*Math.pow(2,-10*(t-=1))*Math.sin((t-.1)*(2*Math.PI)/.4)*.5+1)}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-e.Easing.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*e.Easing.Bounce.In(2*t):.5*e.Easing.Bounce.Out(2*t-1)+.5}}},e.Easing.Default=e.Easing.Linear.None,e.Easing.Power0=e.Easing.Linear.None,e.Easing.Power1=e.Easing.Quadratic.Out,e.Easing.Power2=e.Easing.Cubic.Out,e.Easing.Power3=e.Easing.Quartic.Out,e.Easing.Power4=e.Easing.Quintic.Out,e.Time=function(t){this.game=t,this.time=0,this.prevTime=0,this.now=0,this.elapsed=0,this.elapsedMS=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.frames=0,this.updates=0,this.renders=0,this.fps=0,this.ups=0,this.rps=0,this.fpsMin=1e3,this.fpsMax=0,this.msMin=1e3,this.msMax=0,this.pauseDuration=0,this.timeToCall=0,this.timeExpected=0,this.events=new e.Timer(this.game,!1),this._frameCount=0,this._elapsedAccumulator=0,this._started=0,this._timeLastSecond=0,this._pauseStarted=0,this._justResumed=!1,this._timers=[]},e.Time.prototype={boot:function(){this._started=Date.now(),this.time=Date.now(),this.events.start(),this.timeExpected=this.time},add:function(t){return this._timers.push(t),t},create:function(t){void 0===t&&(t=!0);var i=new e.Timer(this.game,t);return this._timers.push(i),i},removeAll:function(){for(var t=0;t=2*this._desiredFps&&(this.suggestedFps=5*Math.floor(200/(this._elapsedAccumulator/this._frameCount)),this._frameCount=0,this._elapsedAccumulator=0),this.msMin=Math.min(this.msMin,this.elapsed),this.msMax=Math.max(this.msMax,this.elapsed),this.frames++,this.now>this._timeLastSecond+1e3){var t=this.now-this._timeLastSecond;this.fps=Math.round(1e3*this.frames/t),this.ups=Math.round(1e3*this.updates/t),this.rps=Math.round(1e3*this.renders/t),this.fpsMin=Math.min(this.fpsMin,this.fps),this.fpsMax=Math.max(this.fpsMax,this.fps),this._timeLastSecond=this.now,this.frames=0,this.updates=0,this.renders=0}},countUpdate:function(){this.advancedTiming&&this.updates++},countRender:function(){this.advancedTiming&&this.renders++},gamePaused:function(){this._pauseStarted=Date.now(),this.events.pause();for(var t=this._timers.length;t--;)this._timers[t]._pause()},gameResumed:function(){this.time=Date.now(),this.pauseDuration=this.time-this._pauseStarted,this.events.resume();for(var t=this._timers.length;t--;)this._timers[t]._resume()},totalElapsedSeconds:function(){return.001*(this.time-this._started)},elapsedSince:function(t){return this.time-t},elapsedSecondsSince:function(t){return.001*(this.time-t)},reset:function(){this._started=this.time,this.removeAll()}},Object.defineProperty(e.Time.prototype,"desiredFps",{get:function(){return this._desiredFps},set:function(t){this._desiredFps=t,this.physicsElapsed=1/t,this.physicsElapsedMS=1e3*this.physicsElapsed,this.desiredFpsMult=1/t}}),e.Time.prototype.constructor=e.Time,e.Timer=function(t,i){void 0===i&&(i=!0),this.game=t,this.running=!1,this.autoDestroy=i,this.expired=!1,this.elapsed=0,this.events=[],this.onComplete=new e.Signal,this.nextTick=0,this.timeCap=1e3,this.paused=!1,this._codePaused=!1,this._started=0,this._pauseStarted=0,this._pauseTotal=0,this._now=Date.now(),this._len=0,this._marked=0,this._i=0,this._diff=0,this._newTick=0},e.Timer.MINUTE=6e4,e.Timer.SECOND=1e3,e.Timer.HALF=500,e.Timer.QUARTER=250,e.Timer.prototype={create:function(t,i,s,n,r,o){var a=t=Math.round(t);0===this._now?a+=this.game.time.time:a+=this._now;var h=new e.TimerEvent(this,t,a,s,i,n,r,o);return this.events.push(h),this.order(),this.expired=!1,h},add:function(t,e,i){return this.create(t,!1,0,e,i,Array.prototype.slice.call(arguments,3))},repeat:function(t,e,i,s){return this.create(t,!1,e,i,s,Array.prototype.slice.call(arguments,4))},loop:function(t,e,i){return this.create(t,!0,0,e,i,Array.prototype.slice.call(arguments,3))},start:function(t){if(!this.running){this._started=this.game.time.time+(t||0),this.running=!0;for(var e=0;e0&&(this.events.sort(this.sortHandler),this.nextTick=this.events[0].tick)},sortHandler:function(t,e){return t.ticke.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(t){if(this.paused)return!0;if(this.elapsed=t-this._now,this._now=t,this.elapsed>this.timeCap&&this.adjustEvents(t-this.elapsed),this._marked=0,this.clearPendingEvents(),this.running&&this._now>=this.nextTick&&this._len>0){for(;this._i=e.tick)||e.pendingDelete)break;this._newTick=this._now+e.delay-(this._now-e.tick),this._newTick<0&&(this._newTick=this._now+e.delay),!0===e.loop?(e.tick=this._newTick,e.callback.apply(e.callbackContext,e.args)):e.repeatCount>0?(e.repeatCount--,e.tick=this._newTick,e.callback.apply(e.callbackContext,e.args)):(this._marked++,e.pendingDelete=!0,e.callback.apply(e.callbackContext,e.args)),this._i++}this.events.length>this._marked?this.order():(this.expired=!0,this.onComplete.dispatch(this))}return!this.expired||!this.autoDestroy},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(t){for(var e=0;ethis._now?this.nextTick-this._now:0}}),Object.defineProperty(e.Timer.prototype,"length",{get:function(){return this.events.length}}),Object.defineProperty(e.Timer.prototype,"ms",{get:function(){return this.running?this._now-this._started-this._pauseTotal:0}}),Object.defineProperty(e.Timer.prototype,"seconds",{get:function(){return this.running?.001*this.ms:0}}),e.Timer.prototype.constructor=e.Timer,e.TimerEvent=function(t,e,i,s,n,r,o,a){this.timer=t,this.delay=e,this.tick=i,this.repeatCount=s-1,this.loop=n,this.callback=r,this.callbackContext=o,this.args=a,this.pendingDelete=!1},e.TimerEvent.prototype.constructor=e.TimerEvent,e.AnimationManager=function(t){this.sprite=t,this.game=t.game,this.currentFrame=null,this.currentAnim=null,this.updateIfVisible=!0,this.isLoaded=!1,this._frameData=null,this._anims={},this._outputFrames=[]},e.AnimationManager.prototype={loadFrameData:function(t,e){if(void 0===t)return!1;if(this.isLoaded)for(var i in this._anims)this._anims[i].updateFrameData(t);return this._frameData=t,void 0===e||null===e?this.frame=0:"string"==typeof e?this.frameName=e:this.frame=e,this.isLoaded=!0,!0},copyFrameData:function(t,e){if(this._frameData=t.clone(),this.isLoaded)for(var i in this._anims)this._anims[i].updateFrameData(this._frameData);return void 0===e||null===e?this.frame=0:"string"==typeof e?this.frameName=e:this.frame=e,this.isLoaded=!0,!0},add:function(t,i,s,n,r){return i=i||[],s=s||60,void 0===n&&(n=!1),void 0===r&&(r=!(!i||"number"!=typeof i[0])),this._outputFrames=[],this._frameData.getFrameIndexes(i,r,this._outputFrames),this._anims[t]=new e.Animation(this.game,this.sprite,t,this._frameData,this._outputFrames,s,n),this.currentAnim=this._anims[t],this.sprite.tilingTexture&&(this.sprite.refreshTexture=!0),this._anims[t]},validateFrames:function(t,e){void 0===e&&(e=!0);for(var i=0;ithis._frameData.total)return!1}else if(!1===this._frameData.checkFrameName(t[i]))return!1;return!0},play:function(t,e,i,s){if(this._anims[t])return this.currentAnim===this._anims[t]?!1===this.currentAnim.isPlaying?(this.currentAnim.paused=!1,this.currentAnim.play(e,i,s)):this.currentAnim:(this.currentAnim&&this.currentAnim.isPlaying&&this.currentAnim.stop(),this.currentAnim=this._anims[t],this.currentAnim.paused=!1,this.currentFrame=this.currentAnim.currentFrame,this.currentAnim.play(e,i,s))},stop:function(t,e){void 0===e&&(e=!1),!this.currentAnim||"string"==typeof t&&t!==this.currentAnim.name||this.currentAnim.stop(e)},update:function(){return!(this.updateIfVisible&&!this.sprite.visible)&&(!(!this.currentAnim||!this.currentAnim.update())&&(this.currentFrame=this.currentAnim.currentFrame,!0))},next:function(t){this.currentAnim&&(this.currentAnim.next(t),this.currentFrame=this.currentAnim.currentFrame)},previous:function(t){this.currentAnim&&(this.currentAnim.previous(t),this.currentFrame=this.currentAnim.currentFrame)},getAnimation:function(t){return"string"==typeof t&&this._anims[t]?this._anims[t]:null},refreshFrame:function(){},destroy:function(){t=null;for(var t in this._anims)this._anims.hasOwnProperty(t)&&this._anims[t].destroy();this._anims={},this._outputFrames=[],this._frameData=null,this.currentAnim=null,this.currentFrame=null,this.sprite=null,this.game=null}},e.AnimationManager.prototype.constructor=e.AnimationManager,Object.defineProperty(e.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}}),Object.defineProperty(e.AnimationManager.prototype,"frameTotal",{get:function(){return this._frameData.total}}),Object.defineProperty(e.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(t){this.currentAnim.paused=t}}),Object.defineProperty(e.AnimationManager.prototype,"name",{get:function(){return this.currentAnim?this.currentAnim.name:void 0}}),Object.defineProperty(e.AnimationManager.prototype,"frame",{get:function(){return this.currentFrame?this.currentFrame.index:void 0},set:function(t){var e;"number"==typeof t&&this._frameData&&(e=this._frameData.getFrame(t))&&(this.currentFrame=e,this.sprite.setFrame(this.currentFrame))}}),Object.defineProperty(e.AnimationManager.prototype,"frameName",{get:function(){return this.currentFrame?this.currentFrame.name:void 0},set:function(t){var e;"string"==typeof t&&this._frameData&&(e=this._frameData.getFrameByName(t))?(this.currentFrame=e,this._frameIndex=this.currentFrame.index,this.sprite.setFrame(this.currentFrame)):console.warn("Cannot set frameName: "+t)}}),e.Animation=function(t,i,s,n,r,o,a){void 0===a&&(a=!1),this.game=t,this._parent=i,this._frameData=n,this.name=s,this._frames=[],this._frames=this._frames.concat(r),this.delay=1e3/o,this.loop=a,this.loopCount=0,this.killOnComplete=!1,this.isFinished=!1,this.isPlaying=!1,this.isPaused=!1,this._pauseStartTime=0,this._frameIndex=0,this._frameDiff=0,this._frameSkip=1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.onStart=new e.Signal,this.onUpdate=null,this.onComplete=new e.Signal,this.onLoop=new e.Signal,this.isReversed=!1,this.game.onPause.add(this.onPause,this),this.game.onResume.add(this.onResume,this)},e.Animation.prototype={play:function(t,e,i){return"number"==typeof t&&(this.delay=1e3/t),"boolean"==typeof e&&(this.loop=e),void 0!==i&&(this.killOnComplete=i),this.isPlaying=!0,this.isFinished=!1,this.paused=!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,this},restart:function(){this.isPlaying=!0,this.isFinished=!1,this.paused=!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(){return this.reversed=!this.reversed,this},reverseOnce:function(){return this.onComplete.addOnce(this.reverse,this),this.reverse()},setFrame:function(t,e){var i;if(void 0===e&&(e=!1),"string"==typeof t)for(s=0;s=0)&&(this._frameSkip=1,this._frameDiff=e,this._timeLastFrame=t,this._frameDiff>this.delay&&(this._frameSkip=Math.floor(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay),this._timeNextFrame=t+(this.delay-this._frameDiff),this.isReversed?this._frameIndex-=this._frameSkip:this._frameIndex+=this._frameSkip,!this.isReversed&&this._frameIndex>=this._frames.length||this.isReversed&&this._frameIndex<=-1?this.loop?(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.currentFrame&&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)):(this.complete(),!1):this.updateCurrentFrame(!0))},updateCurrentFrame:function(t,e){if(void 0===e&&(e=!1),!this._frameData)return!1;var i=this.currentFrame.index;return this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&(e||i!==this.currentFrame.index)&&this._parent.setFrame(this.currentFrame),!this.onUpdate||!t||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)},next:function(t){void 0===t&&(t=1);var e=this._frameIndex+t;e>=this._frames.length&&(this.loop?e%=this._frames.length:e=this._frames.length-1),e!==this._frameIndex&&(this._frameIndex=e,this.updateCurrentFrame(!0))},previous:function(t){void 0===t&&(t=1);var e=this._frameIndex-t;e<0&&(this.loop?e=this._frames.length+e:e++),e!==this._frameIndex&&(this._frameIndex=e,this.updateCurrentFrame(!0))},updateFrameData:function(t){this._frameData=t,this.currentFrame=this._frameData?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.game=null,this._parent=null,this._frames=null,this._frameData=null,this.currentFrame=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()}},e.Animation.prototype.constructor=e.Animation,Object.defineProperty(e.Animation.prototype,"paused",{get:function(){return this.isPaused},set:function(t){this.isPaused=t,t?this._pauseStartTime=this.game.time.time:this.isPlaying&&(this._timeNextFrame=this.game.time.time+this.delay)}}),Object.defineProperty(e.Animation.prototype,"reversed",{get:function(){return this.isReversed},set:function(t){this.isReversed=t}}),Object.defineProperty(e.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}}),Object.defineProperty(e.Animation.prototype,"frame",{get:function(){return null!==this.currentFrame?this.currentFrame.index:this._frameIndex},set:function(t){this.currentFrame=this._frameData.getFrame(this._frames[t]),null!==this.currentFrame&&(this._frameIndex=t,this._parent.setFrame(this.currentFrame),this.onUpdate&&this.onUpdate.dispatch(this,this.currentFrame))}}),Object.defineProperty(e.Animation.prototype,"speed",{get:function(){return 1e3/this.delay},set:function(t){t>0&&(this.delay=1e3/t)}}),Object.defineProperty(e.Animation.prototype,"enableUpdate",{get:function(){return null!==this.onUpdate},set:function(t){t&&null===this.onUpdate?this.onUpdate=new e.Signal:t||null===this.onUpdate||(this.onUpdate.dispose(),this.onUpdate=null)}}),e.Animation.generateFrameNames=function(t,i,s,n,r){void 0===n&&(n="");var o=[],a="";if(i=s;h--)a=t+(a="number"==typeof r?e.Utils.pad(h.toString(),r,"0",1):h.toString())+n,o.push(a);return o},e.Frame=function(t,i,s,n,r,o){this.index=t,this.x=i,this.y=s,this.width=n,this.height=r,0!==this.width&&0!==this.height||console.warn('Phaser.Frame: Frame "'+this.name+'" has a width or height of zero'),this.name=o,this.centerX=Math.floor(n/2),this.centerY=Math.floor(r/2),this.distance=e.Math.distance(0,0,n,r),this.rotated=!1,this.trimmed=!1,this.sourceSizeW=n,this.sourceSizeH=r,this.spriteSourceSizeX=0,this.spriteSourceSizeY=0,this.spriteSourceSizeW=0,this.spriteSourceSizeH=0,this.right=this.x+this.width,this.bottom=this.y+this.height},e.Frame.prototype={resize:function(t,i){this.width=t,this.height=i,this.centerX=Math.floor(t/2),this.centerY=Math.floor(i/2),this.distance=e.Math.distance(0,0,t,i),this.sourceSizeW=t,this.sourceSizeH=i,this.right=this.x+t,this.bottom=this.y+i},setTrim:function(t,e,i,s,n,r,o){this.trimmed=t,t&&(this.sourceSizeW=e,this.sourceSizeH=i,this.centerX=Math.floor(e/2),this.centerY=Math.floor(i/2),this.spriteSourceSizeX=s,this.spriteSourceSizeY=n,this.spriteSourceSizeW=r,this.spriteSourceSizeH=o)},clone:function(){var t=new e.Frame(this.index,this.x,this.y,this.width,this.height,this.name);for(var i in this)this.hasOwnProperty(i)&&(t[i]=this[i]);return t},getRect:function(t){return void 0===t?t=new e.Rectangle(this.x,this.y,this.width,this.height):t.setTo(this.x,this.y,this.width,this.height),t}},e.Frame.prototype.constructor=e.Frame,e.FrameData=function(){this._frames=[],this._frameNames=[]},e.FrameData.prototype={addFrame:function(t){return t.index=this._frames.length,this._frames.push(t),""!==t.name&&(this._frameNames[t.name]=t.index),t},getFrame:function(t){return t>=this._frames.length&&(t=0),this._frames[t]},getFrameByName:function(t){return"number"==typeof this._frameNames[t]?this._frames[this._frameNames[t]]:null},checkFrameName:function(t){return null!=this._frameNames[t]},clone:function(){for(var t=new e.FrameData,i=0;if||h<-f)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' skipFrames = %s is larger than the frame total %s",i,h,f),null;if(r>-1&&(v=(f=r)-1),d<1&&console.warn("Phaser.AnimationParser.spriteSheet: image '%s' has width %d, but it should be at least %d (frameWidth=%s, margin=%s, spacing=%s)",i,c,s+o+a,s,o,a),p<1&&console.warn("Phaser.AnimationParser.spriteSheet: image '%s' has height %d, but it should be at least %d (frameHeight=%s, margin=%s, spacing=%s)",i,u,n+o+a,n,o,a),0===g)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' zero frames were produced",i),null;if(h>0?v=(y=h)+(f=Math.min(f,g-h))-1:h<0&&(y=(v=m+h)-(f=Math.min(f,g+h))+1),y<0)return console.warn("First frame index %s is outside of range [0, %d]",y,m),null;if(v>m)return console.warn("Last frame index %s is outside of range [0, %d]",v,m),null;for(var x=new e.FrameData,b=o,_=o,w=0,T=0;Tv);T++)T>=y&&x.addFrame(new e.Frame(w++,b,_,s,n,"")),(b+=s+a)+s>c&&(b=o,_+=n+a);return x},JSONData:function(t,i){if(!i.frames)return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"),void console.log(i);for(var s,n=new e.FrameData,r=i.frames,o=0;o tag")}},e.Cache=function(t){this.game=t,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 e.Signal,this._cacheMap=[],this._cacheMap[e.Cache.CANVAS]=this._cache.canvas,this._cacheMap[e.Cache.IMAGE]=this._cache.image,this._cacheMap[e.Cache.TEXTURE]=this._cache.texture,this._cacheMap[e.Cache.SOUND]=this._cache.sound,this._cacheMap[e.Cache.TEXT]=this._cache.text,this._cacheMap[e.Cache.PHYSICS]=this._cache.physics,this._cacheMap[e.Cache.TILEMAP]=this._cache.tilemap,this._cacheMap[e.Cache.BINARY]=this._cache.binary,this._cacheMap[e.Cache.BITMAPDATA]=this._cache.bitmapData,this._cacheMap[e.Cache.BITMAPFONT]=this._cache.bitmapFont,this._cacheMap[e.Cache.JSON]=this._cache.json,this._cacheMap[e.Cache.XML]=this._cache.xml,this._cacheMap[e.Cache.VIDEO]=this._cache.video,this._cacheMap[e.Cache.SHADER]=this._cache.shader,this._cacheMap[e.Cache.RENDER_TEXTURE]=this._cache.renderTexture,this._pendingCount=0,this.onReady=new e.Signal,this._addImages()},e.Cache.CANVAS=1,e.Cache.IMAGE=2,e.Cache.TEXTURE=3,e.Cache.SOUND=4,e.Cache.TEXT=5,e.Cache.PHYSICS=6,e.Cache.TILEMAP=7,e.Cache.BINARY=8,e.Cache.BITMAPDATA=9,e.Cache.BITMAPFONT=10,e.Cache.JSON=11,e.Cache.XML=12,e.Cache.VIDEO=13,e.Cache.SHADER=14,e.Cache.RENDER_TEXTURE=15,e.Cache.DEFAULT=null,e.Cache.DEFAULT_KEY="__default",e.Cache.DEFAULT_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==",e.Cache.MISSING=null,e.Cache.MISSING_KEY="__missing",e.Cache.MISSING_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==",e.Cache.READY_TIMEOUT=1e3,e.Cache.prototype={addCompressedTextureMetaData:function(t,i,s,n){this.checkImageKey(t)&&this.removeImage(t);var r=s in e.LoaderParser?e.LoaderParser[s](n):n,o={key:t,url:i,data:r,base:new PIXI.BaseTexture(r,null,this.game.resolution),frame:new e.Frame(0,0,0,r.width,r.height,t),frameData:new e.FrameData,fileFormat:s};return o.frameData.addFrame(new e.Frame(0,0,0,r.width,r.height,i)),this._cache.image[t]=o,this._resolveURL(i,o),o},addCanvas:function(t,e,i){void 0===i&&(i=e.getContext("2d")),this._cache.canvas[t]={canvas:e,context:i}},addImage:function(t,i,s){this.checkImageKey(t)&&this.removeImage(t),!1===s.complete&&console.warn('Phaser.Cache.addImage: Image "%s" is not complete',t);var n={key:t,url:i,data:s,base:new PIXI.BaseTexture(s,null,this.game.resolution),frame:new e.Frame(0,0,0,s.width,s.height,t),frameData:new e.FrameData};return n.frameData.addFrame(new e.Frame(0,0,0,s.width,s.height,i)),this._cache.image[t]=n,this._resolveURL(i,n),"__default"===t?e.Cache.DEFAULT=new PIXI.Texture(n.base):"__missing"===t&&(e.Cache.MISSING=new PIXI.Texture(n.base)),n},addImageAsync:function(t,e,i){var s=this,n=new Image;n.onload=function(){i.call(this,s.addImage(t,null,n)),s._removePending(),n.onload=null},this._addPending(),n.src=e},addDefaultImage:function(){this.addImageAsync(e.Cache.DEFAULT_KEY,e.Cache.DEFAULT_SRC,function(t){t.base.skipRender=!0,e.Cache.DEFAULT=new PIXI.Texture(t.base)})},addMissingImage:function(){this.addImageAsync(e.Cache.MISSING_KEY,e.Cache.MISSING_SRC,function(t){e.Cache.MISSING=new PIXI.Texture(t.base)})},addSound:function(t,e,i,s,n){void 0===s&&(s=!0,n=!1),void 0===n&&(s=!1,n=!0);var r=!1;n&&(r=!0),this._cache.sound[t]={url:e,data:i,isDecoding:!1,decoded:r,webAudio:s,audioTag:n,locked:this.game.sound.touchLocked},this._resolveURL(e,this._cache.sound[t])},addText:function(t,e,i){this._cache.text[t]={url:e,data:i},this._resolveURL(e,this._cache.text[t])},addPhysicsData:function(t,e,i,s){this._cache.physics[t]={url:e,data:i,format:s},this._resolveURL(e,this._cache.physics[t])},addTilemap:function(t,e,i,s){this._cache.tilemap[t]={url:e,data:i,format:s},this._resolveURL(e,this._cache.tilemap[t])},addBinary:function(t,e){this._cache.binary[t]=e},addBitmapData:function(t,i,s){return i.key=t,void 0===s&&(s=new e.FrameData).addFrame(i.textureFrame),this._cache.bitmapData[t]={data:i,frameData:s},i},addBitmapFont:function(t,i,s,n,r,o,a){var h={url:i,data:s,font:null,base:new PIXI.BaseTexture(s,null,this.game.resolution)};void 0===o&&(o=0),void 0===a&&(a=0),h.font="json"===r?e.LoaderParser.jsonBitmapFont(n,h.base,o,a,!1,this.game.resolution):e.LoaderParser.xmlBitmapFont(n,h.base,o,a,!1,this.game.resolution),this._cache.bitmapFont[t]=h,this._resolveURL(i,h)},addBitmapFontFromAtlas:function(t,i,s,n,r,o,a){var h=this.getFrameByName(i,s);if(h){var l={font:null,base:this.getBaseTexture(i),frame:h};void 0===o&&(o=0),void 0===a&&(a=0);var c;"json"===r?(c=this.getJSON(n),l.font=e.LoaderParser.jsonBitmapFont(c,l.base,o,a,h,this.game.resolution)):(c=this.getXML(n),l.font=e.LoaderParser.xmlBitmapFont(c,l.base,o,a,h,this.game.resolution)),this._cache.bitmapFont[t]=l}},addJSON:function(t,e,i){this._cache.json[t]={url:e,data:i},this._resolveURL(e,this._cache.json[t])},addXML:function(t,e,i){this._cache.xml[t]={url:e,data:i},this._resolveURL(e,this._cache.xml[t])},addVideo:function(t,e,i,s){this._cache.video[t]={url:e,data:i,isBlob:s,locked:!0},this._resolveURL(e,this._cache.video[t])},addShader:function(t,e,i){this._cache.shader[t]={url:e,data:i},this._resolveURL(e,this._cache.shader[t])},addRenderTexture:function(t,i){this._cache.renderTexture[t]={texture:i,frame:new e.Frame(0,0,0,i.width,i.height,"","")}},addSpriteSheet:function(t,i,s,n,r,o,a,h,l){void 0===o&&(o=-1),void 0===a&&(a=0),void 0===h&&(h=0);var c={key:t,url:i,data:s,frameWidth:n,frameHeight:r,margin:a,spacing:h,base:new PIXI.BaseTexture(s,null,this.game.resolution),frameData:e.AnimationParser.spriteSheet(this.game,s,n,r,o,a,h,l)};this._cache.image[t]=c,this._resolveURL(i,c)},addTextureAtlas:function(t,i,s,n,r){var o={key:t,url:i,data:s,base:new PIXI.BaseTexture(s,null,this.game.resolution)};r===e.Loader.TEXTURE_ATLAS_XML_STARLING?o.frameData=e.AnimationParser.XMLData(this.game,n,t):r===e.Loader.TEXTURE_ATLAS_JSON_PYXEL?o.frameData=e.AnimationParser.JSONDataPyxel(this.game,n,t):Array.isArray(n.frames)?o.frameData=e.AnimationParser.JSONData(this.game,n,t):o.frameData=e.AnimationParser.JSONDataHash(this.game,n,t),this._cache.image[t]=o,this._resolveURL(i,o)},reloadSound:function(t){var e=this,i=this.getSound(t);i&&(i.data.src=i.url,i.data.addEventListener("canplaythrough",function(){return e.reloadSoundComplete(t)},!1),i.data.load())},reloadSoundComplete:function(t){var e=this.getSound(t);e&&(e.locked=!1,this.onSoundUnlock.dispatch(t))},updateSound:function(t,e,i){var s=this.getSound(t);s&&(s[e]=i)},decodedSound:function(t,e){var i=this.getSound(t);i.data=e,i.decoded=!0,i.isDecoding=!1},isSoundDecoded:function(t){var i=this.getItem(t,e.Cache.SOUND,"isSoundDecoded");if(i)return i.decoded},isSoundReady:function(t){var i=this.getItem(t,e.Cache.SOUND,"isSoundDecoded");if(i)return i.decoded&&!this.game.sound.touchLocked},checkKey:function(t,e){return!!this._cacheMap[t][e]},checkURL:function(t){return!!this._urlMap[this._resolveURL(t)]},checkCanvasKey:function(t){return this.checkKey(e.Cache.CANVAS,t)},checkImageKey:function(t){return this.checkKey(e.Cache.IMAGE,t)},checkTextureKey:function(t){return this.checkKey(e.Cache.TEXTURE,t)},checkSoundKey:function(t){return this.checkKey(e.Cache.SOUND,t)},checkTextKey:function(t){return this.checkKey(e.Cache.TEXT,t)},checkPhysicsKey:function(t){return this.checkKey(e.Cache.PHYSICS,t)},checkTilemapKey:function(t){return this.checkKey(e.Cache.TILEMAP,t)},checkBinaryKey:function(t){return this.checkKey(e.Cache.BINARY,t)},checkBitmapDataKey:function(t){return this.checkKey(e.Cache.BITMAPDATA,t)},checkBitmapFontKey:function(t){return this.checkKey(e.Cache.BITMAPFONT,t)},checkJSONKey:function(t){return this.checkKey(e.Cache.JSON,t)},checkXMLKey:function(t){return this.checkKey(e.Cache.XML,t)},checkVideoKey:function(t){return this.checkKey(e.Cache.VIDEO,t)},checkShaderKey:function(t){return this.checkKey(e.Cache.SHADER,t)},checkRenderTextureKey:function(t){return this.checkKey(e.Cache.RENDER_TEXTURE,t)},getItem:function(t,e,i,s){return this.checkKey(e,t)?void 0===s?this._cacheMap[e][t]:this._cacheMap[e][t][s]:(i&&console.warn("Phaser.Cache."+i+': Key "'+t+'" not found in Cache.'),null)},getCanvas:function(t){return this.getItem(t,e.Cache.CANVAS,"getCanvas","canvas")},getImage:function(t,i){void 0!==t&&null!==t||(t="__default"),void 0===i&&(i=!1);var s=this.getItem(t,e.Cache.IMAGE,"getImage");return null===s&&(s=this.getItem("__missing",e.Cache.IMAGE,"getImage")),i?s:s.data},getTextureFrame:function(t){return this.getItem(t,e.Cache.TEXTURE,"getTextureFrame","frame")},getSound:function(t){return this.getItem(t,e.Cache.SOUND,"getSound")},getSoundData:function(t){return this.getItem(t,e.Cache.SOUND,"getSoundData","data")},getText:function(t){return this.getItem(t,e.Cache.TEXT,"getText","data")},getPhysicsData:function(t,i,s){var n=this.getItem(t,e.Cache.PHYSICS,"getPhysicsData","data");if(null===n||void 0===i||null===i)return n;if(n[i]){var r=n[i];if(!r||!s)return r;for(var o in r)if((o=r[o]).fixtureKey===s)return o;console.warn('Phaser.Cache.getPhysicsData: Could not find given fixtureKey: "'+s+" in "+t+'"')}else console.warn('Phaser.Cache.getPhysicsData: Invalid key/object: "'+t+" / "+i+'"');return null},getTilemapData:function(t){return this.getItem(t,e.Cache.TILEMAP,"getTilemapData")},getBinary:function(t){return this.getItem(t,e.Cache.BINARY,"getBinary")},getBitmapData:function(t){return this.getItem(t,e.Cache.BITMAPDATA,"getBitmapData","data")},getBitmapFont:function(t){return this.getItem(t,e.Cache.BITMAPFONT,"getBitmapFont")},getJSON:function(t,i){var s=this.getItem(t,e.Cache.JSON,"getJSON","data");return s?i?e.Utils.extend(!0,Array.isArray(s)?[]:{},s):s:null},getXML:function(t){return this.getItem(t,e.Cache.XML,"getXML","data")},getVideo:function(t){return this.getItem(t,e.Cache.VIDEO,"getVideo")},getShader:function(t){return this.getItem(t,e.Cache.SHADER,"getShader","data")},getRenderTexture:function(t){return this.getItem(t,e.Cache.RENDER_TEXTURE,"getRenderTexture")},getBaseTexture:function(t,i){return void 0===i&&(i=e.Cache.IMAGE),this.getItem(t,i,"getBaseTexture","base")},getFrame:function(t,i){return void 0===i&&(i=e.Cache.IMAGE),this.getItem(t,i,"getFrame","frame")},getFrameCount:function(t,e){var i=this.getFrameData(t,e);return i?i.total:0},getFrameData:function(t,i){return void 0===i&&(i=e.Cache.IMAGE),this.getItem(t,i,"getFrameData","frameData")},hasFrameData:function(t,i){return void 0===i&&(i=e.Cache.IMAGE),null!==this.getItem(t,i,"","frameData")},updateFrameData:function(t,i,s){void 0===s&&(s=e.Cache.IMAGE),this._cacheMap[s][t]&&(this._cacheMap[s][t].frameData=i)},getFrameByIndex:function(t,e,i){var s=this.getFrameData(t,i);return s?s.getFrame(e):null},getFrameByName:function(t,e,i){var s=this.getFrameData(t,i);return s?s.getFrameByName(e):null},getURL:function(t){return(t=this._resolveURL(t))?this._urlMap[t]:(console.warn('Phaser.Cache.getUrl: Invalid url: "'+t+'" or Cache.autoResolveURL was false'),null)},getKeys:function(t){void 0===t&&(t=e.Cache.IMAGE);var i=[];if(this._cacheMap[t])for(var s in this._cacheMap[t])"__default"!==s&&"__missing"!==s&&i.push(s);return i},removeCanvas:function(t){delete this._cache.canvas[t]},removeImage:function(t,e){void 0===e&&(e=!0);var i=this.getImage(t,!0);e&&i.base&&i.base.destroy(),delete this._cache.image[t]},removeSound:function(t){delete this._cache.sound[t]},removeText:function(t){delete this._cache.text[t]},removePhysics:function(t){delete this._cache.physics[t]},removeTilemap:function(t){delete this._cache.tilemap[t]},removeBinary:function(t){delete this._cache.binary[t]},removeBitmapData:function(t){delete this._cache.bitmapData[t]},removeBitmapFont:function(t){delete this._cache.bitmapFont[t]},removeJSON:function(t){delete this._cache.json[t]},removeXML:function(t){delete this._cache.xml[t]},removeVideo:function(t){delete this._cache.video[t]},removeShader:function(t){delete this._cache.shader[t]},removeRenderTexture:function(t){delete this._cache.renderTexture[t]},removeSpriteSheet:function(t){delete this._cache.spriteSheet[t]},removeTextureAtlas:function(t){delete this._cache.image[t]},clearGLTextures:function(){for(var t in this._cache.image)this._cache.image[t].base._glTextures=[]},_resolveURL:function(t,e){return this.autoResolveURL?(this._urlResolver.src=this.game.load.baseURL+t,this._urlTemp=this._urlResolver.src,this._urlResolver.src="",e&&(this._urlMap[this._urlTemp]=e),this._urlTemp):null},destroy:function(){for(var t=0;t0?setTimeout(function(){t.isReady||(console.warn("Phaser.Cache: Still waiting for images after %s ms.",i),t._ready())},e.Cache.READY_TIMEOUT):this._ready()},_addPending:function(){this._pendingCount+=1},_removePending:function(){this._pendingCount-=1,this._checkReady()},_checkReady:function(){this.isReady&&this._ready()},_ready:function(){this._pendingCount=0,this.onReady.dispatch(this)}},e.Cache.prototype.constructor=e.Cache,Object.defineProperty(e.Cache.prototype,"isReady",{get:function(){return this._pendingCount<=0}}),e.Loader=function(t){this.game=t,this.cache=t.cache,this.resetLocked=!1,this.isLoading=!1,this.hasLoaded=!1,this.preloadSprite=null,this.crossOrigin=!1,this.baseURL="",this.path="",this.headers={requestedWith:!1,json:"application/json",xml:"application/xml"},this.onLoadStart=new e.Signal,this.onBeforeLoadComplete=new e.Signal,this.onLoadComplete=new e.Signal,this.onPackComplete=new e.Signal,this.onFileStart=new e.Signal,this.onFileComplete=new e.Signal,this.onFileError=new e.Signal,this.enableParallel=!0,this.maxParallelDownloads=4,this._withSyncPointDepth=0,this._fileList=[],this._flightQueue=[],this._processingHead=0,this._fileLoadStarted=!1,this._totalPackCount=0,this._totalFileCount=0,this._loadedPackCount=0,this._loadedFileCount=0},e.Loader.TEXTURE_ATLAS_JSON_ARRAY=0,e.Loader.TEXTURE_ATLAS_JSON_HASH=1,e.Loader.TEXTURE_ATLAS_XML_STARLING=2,e.Loader.PHYSICS_LIME_CORONA_JSON=3,e.Loader.PHYSICS_PHASER_JSON=4,e.Loader.TEXTURE_ATLAS_JSON_PYXEL=5,e.Loader.prototype={setPreloadSprite:function(t,i){i=i||0,this.preloadSprite={sprite:t,direction:i,width:t.width,height:t.height,rect:null},this.preloadSprite.rect=0===i?new e.Rectangle(0,0,1,t.height):new e.Rectangle(0,0,t.width,1),t.crop(this.preloadSprite.rect),t.visible=!0},resize:function(){this.preloadSprite&&this.preloadSprite.height!==this.preloadSprite.sprite.height&&(this.preloadSprite.rect.height=this.preloadSprite.sprite.height)},checkKeyExists:function(t,e){return this.getAssetIndex(t,e)>-1},getAssetIndex:function(t,e){for(var i=-1,s=0;s-1&&{index:i,file:this._fileList[i]}},reset:function(t,e){void 0===e&&(e=!1),this.resetLocked||(t&&(this.preloadSprite=null),this.isLoading=!1,this._processingHead=0,this._fileList.length=0,this._flightQueue.length=0,this._fileLoadStarted=!1,this._totalFileCount=0,this._totalPackCount=0,this._loadedPackCount=0,this._loadedFileCount=0,e&&(this.onLoadStart.removeAll(),this.onLoadComplete.removeAll(),this.onPackComplete.removeAll(),this.onFileStart.removeAll(),this.onFileComplete.removeAll(),this.onFileError.removeAll()))},addToFileList:function(t,e,i,s,n,r){if(void 0===n&&(n=!1),void 0===e||""===e)return console.warn("Phaser.Loader: Invalid or no key given of type "+t),this;if(void 0===i||null===i){if(!r)return console.warn("Phaser.Loader: No URL given for file type: "+t+" key: "+e),this;i=e+r}var o={type:t,key:e,path:this.path,url:i,syncPoint:this._withSyncPointDepth>0,data:null,loading:!1,loaded:!1,error:!1};if(s)for(var a in s)o[a]=s[a];var h=this.getAssetIndex(t,e);if(n&&h>-1){var l=this._fileList[h];l.loading||l.loaded?(this._fileList.push(o),this._totalFileCount++):this._fileList[h]=o}else-1===h&&(this._fileList.push(o),this._totalFileCount++);return this},replaceInFileList:function(t,e,i,s){return this.addToFileList(t,e,i,s,!0)},pack:function(t,e,i,s){if(void 0===e&&(e=null),void 0===i&&(i=null),void 0===s&&(s=null),!e&&!i)return console.warn("Phaser.Loader.pack - Both url and data are null. One must be set."),this;var n={type:"packfile",key:t,url:e,path:this.path,syncPoint:!0,data:null,loading:!1,loaded:!1,error:!1,callbackContext:s};i&&("string"==typeof i&&(i=JSON.parse(i)),n.data=i||{},n.loaded=!0);for(var r=0;r=e||t&&this._loadedPackCount===this._totalPackCount)break}if(this.updateProgress(),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 n=this;setTimeout(function(){n.finishedLoading(!0)},2e3)}},finishedLoading:function(t){this.hasLoaded||(this.hasLoaded=!0,this.isLoading=!1,t||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(t,e){void 0===e&&(e=""),t.loaded=!0,t.error=!!e,e&&(t.errorMessage=e,console.warn("Phaser.Loader - "+t.type+"["+t.key+"]: "+e)),this.processLoadQueue()},processPack:function(t){var i=t.data[t.key];if(i)for(var s=0;s=400&&r.status<=599?n.call(o,t,r):s.call(o,t,r)}catch(e){o.hasLoaded?window.console&&console.error(e):o.asyncComplete(t,e.message||"Exception")}},r.onerror=function(){try{return n.call(o,t,r)}catch(e){o.hasLoaded?window.console&&console.error(e):o.asyncComplete(t,e.message||"Exception")}},t.requestObject=r,t.requestUrl=e,r.send()},getVideoURL:function(t){for(var e=0;e=0&&(s=s.substr(0,s.indexOf("?"))),i=s.substr((Math.max(0,s.lastIndexOf("."))||1/0)+1).toLowerCase(),this.game.device.canPlayVideo(i))return t[e]}}return null},getAudioURL:function(t){if(this.game.sound.noAudio)return null;for(var e=0;e=0&&(s=s.substr(0,s.indexOf("?"))),i=s.substr((Math.max(0,s.lastIndexOf("."))||1/0)+1).toLowerCase(),this.game.device.canPlayAudio(i))return t[e]}}return null},fileError:function(t,e,i){var s="error loading asset from URL "+(t.requestUrl||this.transformUrl(t.url,t));!i&&e&&(i=e.status),i&&(s=s+" ("+i+")"),this.asyncComplete(t,s)},fileComplete:function(t,i){var s=!0;switch(t.type){case"packfile":r=JSON.parse(i.responseText);t.data=r||{};break;case"texture":var n=/\.([^.]+)$/.exec(t.url.split("?",1)[0])[1].toLowerCase();null!==t.data?this.cache.addCompressedTextureMetaData(t.key,t.url,n,t.data):this.cache.addCompressedTextureMetaData(t.key,t.url,n,i.response);break;case"image":this.cache.addImage(t.key,t.url,t.data);break;case"spritesheet":this.cache.addSpriteSheet(t.key,t.url,t.data,t.frameWidth,t.frameHeight,t.frameMax,t.margin,t.spacing,t.skipFrames);break;case"textureatlas":if(null==t.atlasURL)this.cache.addTextureAtlas(t.key,t.url,t.data,t.atlasData,t.format);else if(s=!1,t.format===e.Loader.TEXTURE_ATLAS_JSON_ARRAY||t.format===e.Loader.TEXTURE_ATLAS_JSON_HASH||t.format===e.Loader.TEXTURE_ATLAS_JSON_PYXEL)this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",this.jsonLoadComplete);else{if(t.format!==e.Loader.TEXTURE_ATLAS_XML_STARLING)throw new Error("Phaser.Loader. Invalid Texture Atlas format: "+t.format);this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",this.xmlLoadComplete)}break;case"bitmapfont":t.atlasURL?(s=!1,this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",function(t,e){var i;try{i=JSON.parse(e.responseText)}catch(t){}i?(t.atlasType="json",this.jsonLoadComplete(t,e)):(t.atlasType="xml",this.xmlLoadComplete(t,e))})):this.cache.addBitmapFont(t.key,t.url,t.data,t.atlasData,t.atlasType,t.xSpacing,t.ySpacing);break;case"video":if(t.asBlob)try{t.data=i.response}catch(e){throw new Error("Phaser.Loader. Unable to parse video file as Blob: "+t.key)}this.cache.addVideo(t.key,t.url,t.data,t.asBlob);break;case"audio":this.game.sound.usingWebAudio?(t.data=i.response,this.cache.addSound(t.key,t.url,t.data,!0,!1),t.autoDecode&&this.game.sound.decode(t.key)):this.cache.addSound(t.key,t.url,t.data,!1,!0);break;case"text":t.data=i.responseText,this.cache.addText(t.key,t.url,t.data);break;case"shader":t.data=i.responseText,this.cache.addShader(t.key,t.url,t.data);break;case"physics":var r=JSON.parse(i.responseText);this.cache.addPhysicsData(t.key,t.url,r,t.format);break;case"script":t.data=document.createElement("script"),t.data.language="javascript",t.data.type="text/javascript",t.data.defer=!1,t.data.text=i.responseText,document.head.appendChild(t.data),t.callback&&(t.data=t.callback.call(t.callbackContext,t.key,i.responseText));break;case"binary":t.callback?t.data=t.callback.call(t.callbackContext,t.key,i.response):t.data=i.response,this.cache.addBinary(t.key,t.data)}s&&this.asyncComplete(t)},jsonLoadComplete:function(t,e){var i=JSON.parse(e.responseText);"tilemap"===t.type?this.cache.addTilemap(t.key,t.url,i,t.format):"bitmapfont"===t.type?this.cache.addBitmapFont(t.key,t.url,t.data,i,t.atlasType,t.xSpacing,t.ySpacing):"json"===t.type?this.cache.addJSON(t.key,t.url,i):this.cache.addTextureAtlas(t.key,t.url,t.data,i,t.format),this.asyncComplete(t)},csvLoadComplete:function(t,e){var i=e.responseText;this.cache.addTilemap(t.key,t.url,i,t.format),this.asyncComplete(t)},xmlLoadComplete:function(t,e){var i=e.responseText,s=this.parseXml(i);if(!s){var n=e.responseType||e.contentType;return console.warn("Phaser.Loader - "+t.key+": invalid XML ("+n+")"),void this.asyncComplete(t,"invalid XML")}"bitmapfont"===t.type?this.cache.addBitmapFont(t.key,t.url,t.data,s,t.atlasType,t.xSpacing,t.ySpacing):"textureatlas"===t.type?this.cache.addTextureAtlas(t.key,t.url,t.data,s,t.format):"xml"===t.type&&this.cache.addXML(t.key,t.url,s),this.asyncComplete(t)},parseXml:function(t){var e;try{if(window.DOMParser){var i=new DOMParser;e=i.parseFromString(t,"text/xml")}else(e=new ActiveXObject("Microsoft.XMLDOM")).async="false",e.loadXML(t)}catch(t){e=null}return e&&e.documentElement&&!e.getElementsByTagName("parsererror").length?e:null},updateProgress:function(){this.preloadSprite&&(0===this.preloadSprite.direction?this.preloadSprite.rect.width=Math.floor(this.preloadSprite.width/100*this.progress):this.preloadSprite.rect.height=Math.floor(this.preloadSprite.height/100*this.progress),this.preloadSprite.sprite?this.preloadSprite.sprite.updateCrop():this.preloadSprite=null)},totalLoadedFiles:function(){return this._loadedFileCount},totalQueuedFiles:function(){return this._totalFileCount-this._loadedFileCount},totalLoadedPacks:function(){return this._totalPackCount},totalQueuedPacks:function(){return this._totalPackCount-this._loadedPackCount}},Object.defineProperty(e.Loader.prototype,"progressFloat",{get:function(){var t=this._loadedFileCount/this._totalFileCount*100;return e.Math.clamp(t||0,0,100)}}),Object.defineProperty(e.Loader.prototype,"progress",{get:function(){return Math.round(this.progressFloat)}}),e.Loader.prototype.constructor=e.Loader,e.LoaderParser={bitmapFont:function(t,e,i,s,n,r){return this.xmlBitmapFont(t,e,i,s,n,r)},xmlBitmapFont:function(t,e,i,s,n,r){null==r&&(r=1);var o={},a=t.getElementsByTagName("info")[0],h=t.getElementsByTagName("common")[0];o.font=a.getAttribute("face"),o.size=parseInt(a.getAttribute("size"),10),o.lineHeight=parseInt(h.getAttribute("lineHeight"),10)+s,o.chars={};for(var l=t.getElementsByTagName("char"),c=n?n.x:0,u=n?n.y:0,d=0;dn.spriteSourceSizeX+n.spriteSourceSizeW&&(f.width-=f.x+f.width-n.spriteSourceSizeX-n.spriteSourceSizeW),f.y+f.height>n.spriteSourceSizeY+n.spriteSourceSizeH&&(f.height-=f.y+f.height-n.spriteSourceSizeY-n.spriteSourceSizeH),f.xn.spriteSourceSizeX+n.spriteSourceSizeW&&(s.width-=s.x+s.width-n.spriteSourceSizeX-n.spriteSourceSizeW),s.y+s.height>n.spriteSourceSizeY+n.spriteSourceSizeH&&(s.height-=s.y+s.height-n.spriteSourceSizeY-n.spriteSourceSizeH),s.x=0){switch(r>=0&&r<=3?e="PVRTC":r>=7&&r<=11?e="S3TC":6===r&&(e="ETC1"),r){case 0:o=35841;break;case 1:o=35843;break;case 2:o=35840;break;case 3:o=35842;break;case 6:o=36196;break;case 7:o=33777;break;case 9:o=33778;break;case 11:o=33779;break;default:o=-1}n={complete:!0,fileFormat:"PVR",compressionAlgorithm:e,flags:i[1],pixelFormat:r,colorSpace:i[4],channelType:i[5],height:i[6],width:i[7],depth:i[8],numberOfSurfaces:i[9],numberOfFaces:i[10],numberOfMipmaps:i[11],metaDataSize:i[12],textureData:s.subarray(52+i[12],s.byteLength),glExtensionFormat:o}}return n},dds:function(t){var e=new Uint8Array(t),i=new Uint32Array(t),s=null;return 68===e[0]&&68===e[1]&&83===e[2]&&32===e[3]&&("DX10"===(s={complete:!0,fileFormat:"DDS",compressionAlgorithm:"S3TC",size:i[1],flags:i[2],height:i[3],width:i[4],pitch:i[5],depth:i[6],mipmapCount:i[7],formatSize:i[19],formatFlag:i[19],formatFourCC:[String.fromCharCode(e[84]),String.fromCharCode(e[85]),String.fromCharCode(e[86]),String.fromCharCode(e[87])].join(""),formatBitCount:i[21],formatRBitMask:i[22],formatGBitMask:i[23],formatBBitMask:i[24],formatABitMask:i[25],caps1:i[26],caps2:i[27],caps3:i[28],caps4:i[29],reserved2:i[30],DXGIFormat:null,resourceDimension:null,miscFlag:null,arraySize:null,textureData:e.subarray(i[1]+4,e.byteLength)}).formatFourCC?(s.DXGIFormat=i[31],s.resourceDimension=i[32],s.miscFlag=i[33],s.arraySize=i[34],s.miscFlag=i[35]):"DXT5"===s.formatFourCC?s.glExtensionFormat=33779:"DXT3"===s.formatFourCC&&(s.glExtensionFormat=33778)),s},ktx:function(t){var e=new Uint8Array(t),i=new Uint32Array(t),s=null,n=16+i[15]/4|0,r=i[n],o=i[7],a=0;if(171===e[0]&&75===e[1]&&84===e[2]&&88===e[3]&&32===e[4]&&49===e[5]&&49===e[6]&&187===e[7]&&13===e[8]&&10===e[9]&&26===e[10]&&10===e[11]&&[36196,35840,35841,35842,35843,33776,33777,33778,33779].indexOf(o)>=0){switch(o){case 36196:a="ETC1";break;case 35840:case 35841:case 35842:case 35843:a="PVRTC";break;case 33776:case 33777:case 33778:case 33779:a="S3TC"}s={complete:!0,fileFormat:"KTX",compressionAlgorithm:a,endianness:i[3],glType:i[4],glTypeSize:i[5],glFormat:i[6],glInternalFormat:i[7],glBaseInternalFormat:i[8],width:i[9],height:i[10],pixelDepth:i[11],numberOfArrayElements:i[12],numberOfFaces:i[13],numberOfMipmapLevels:i[14],bytesOfKeyValueData:i[15],keyAndValueByteSize:i[16],imageSize:r,textureData:e.subarray(4*(n+1),r+100)}}return s},pkm:function(t){var e=new Uint8Array(t),i=null;return 80===e[0]&&75===e[1]&&77===e[2]&&32===e[3]&&(i={complete:!0,fileFormat:"PKM",compressionAlgorithm:"ETC1",format:65535&(e[6]<<8|e[7]),width:65535&(e[8]<<8|e[9]),height:65535&(e[10]<<8|e[11]),originalWidth:65535&(e[12]<<8|e[13]),originalHeight:65535&(e[14]<<8|e[15]),textureData:e.subarray(16,e.length)}),i}},e.AudioSprite=function(t,e){this.game=t,this.key=e,this.config=this.game.cache.getJSON(e+"-audioatlas"),this.autoplayKey=null,this.autoplay=!1,this.sounds={};for(var i in this.config.spritemap){var s=this.config.spritemap[i],n=this.game.add.sound(this.key);n.addMarker(i,s.start,s.end-s.start,null,s.loop),this.sounds[i]=n}this.config.autoplay&&(this.autoplayKey=this.config.autoplay,this.play(this.autoplayKey),this.autoplay=this.sounds[this.autoplayKey])},e.AudioSprite.prototype={play:function(t,e){return void 0===e&&(e=1),this.sounds[t].play(t,null,e)},stop:function(t){if(t)this.sounds[t].stop();else for(var e in this.sounds)this.sounds[e].stop()},get:function(t){return this.sounds[t]}},e.AudioSprite.prototype.constructor=e.AudioSprite,e.Sound=function(t,i,s,n,r){void 0===s&&(s=1),void 0===n&&(n=!1),void 0===r&&(r=t.sound.connectToMaster),this.game=t,this.name=i,this.key=i,this.loop=n,this.markers={},this.context=null,this.autoplay=!1,this.totalDuration=0,this.startTime=0,this.currentTime=0,this.duration=0,this.durationMS=0,this.position=0,this.stopTime=0,this.paused=!1,this.pausedPosition=0,this.pausedTime=0,this.isPlaying=!1,this.currentMarker="",this.fadeTween=null,this.pendingPlayback=!1,this.override=!1,this.allowMultiple=!1,this.playOnce=!1,this.usingWebAudio=this.game.sound.usingWebAudio,this.usingAudioTag=this.game.sound.usingAudioTag,this.externalNode=null,this.masterGainNode=null,this.gainNode=null,this._sound=null,this._globalVolume=1,this._markedToDelete=!1,this._pendingStart=!1,this._removeFromSoundManager=!1,this._sourceId=0,this.usingWebAudio?(this.context=this.game.sound.context,this.masterGainNode=this.game.sound.masterGain,void 0===this.context.createGain?this.gainNode=this.context.createGainNode():this.gainNode=this.context.createGain(),this.gainNode.gain.value=s,r&&this.gainNode.connect(this.masterGainNode)):this.usingAudioTag&&(this.game.cache.getSound(i)&&this.game.cache.isSoundReady(i)?(this._sound=this.game.cache.getSoundData(i),this.totalDuration=0,this._sound.duration&&(this.totalDuration=this._sound.duration)):this.game.cache.onSoundUnlock.add(this.soundHasUnlocked,this)),this.onDecoded=new e.Signal,this.onPlay=new e.Signal,this.onPause=new e.Signal,this.onResume=new e.Signal,this.onLoop=new e.Signal,this.onStop=new e.Signal,this.onMute=new e.Signal,this.onMarkerComplete=new e.Signal,this.onFadeComplete=new e.Signal,this._volume=s,this._buffer=null,this._muted=!1,this._tempMarker=0,this._tempPosition=0,this._tempVolume=0,this._tempPause=0,this._muteVolume=0,this._tempLoop=0,this._paused=!1,this._onDecodedEventDispatched=!1},e.Sound.prototype={soundHasUnlocked:function(t){t===this.key&&(this._sound=this.game.cache.getSoundData(this.key),this.totalDuration=this._sound.duration)},addMarker:function(t,e,i,s,n){void 0!==i&&null!==i||(i=1),void 0!==s&&null!==s||(s=1),void 0===n&&(n=!1),this.markers[t]={name:t,start:e,stop:e+i,volume:s,duration:i,durationMS:1e3*i,loop:n}},removeMarker:function(t){delete this.markers[t]},onEndedHandler:function(){this._removeOnEndedHandler(),this.isPlaying=!1,this.currentTime=this.durationMS,this.stop(),this.playOnce&&(this._markedToDelete=!0,this._removeFromSoundManager=!0),this._markedToDelete&&(this._disconnectSource(),this._removeFromSoundManager?this.game.sound.remove(this):(this.markers={},this.context=null,this._buffer=null,this.externalNode=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(){if(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));var t=this.game.time.time;if(this.isPlaying){if(this._pendingStart){var e=this._sound.currentTime;if(!(e>((this.paused?this._tempPause:0)||this.position||0)))return;this._pendingStart=!1,this.startTime=t-1e3*e,this.stopTime=this.startTime+this.durationMS}this.currentTime=t-this.startTime,this.currentTime>=this.durationMS&&(this.usingWebAudio?this.loop?(this.onLoop.dispatch(this),this.isPlaying=!1,""===this.currentMarker?(this.currentTime=0,this.startTime=t,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=t),this.isPlaying=!1,this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop())}}else this.destroy()},loopFull:function(t){return this.play(null,0,t,!0)},play:function(t,e,i,s,n){if(void 0!==t&&!1!==t&&null!==t||(t=""),void 0===n&&(n=!0),this.isPlaying&&!this.allowMultiple&&!n&&!this.override)return this;if(this._sound&&this.isPlaying&&!this.allowMultiple&&(this.override||n)&&(this.usingWebAudio?this._stopSourceAndDisconnect():this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0),this.isPlaying=!1),""===t&&Object.keys(this.markers).length>0)return this;if(""!==t){if(!this.markers[t])return console.warn("Phaser.Sound.play: audio marker "+t+" doesn't exist"),this;this.currentMarker=t,this.position=this.markers[t].start,this.volume=this.markers[t].volume,this.loop=this.markers[t].loop,this.duration=this.markers[t].duration,this.durationMS=this.markers[t].durationMS,void 0!==i&&(this.volume=i),void 0!==s&&(this.loop=s),this._tempMarker=t,this._tempPosition=this.position,this._tempVolume=this.volume,this._tempLoop=this.loop}else e=e||0,void 0===i&&(i=this._volume),void 0===s&&(s=this.loop),this.position=Math.max(0,e),this.volume=i,this.loop=s,this.duration=0,this.durationMS=0,this._tempMarker=t,this._tempPosition=e,this._tempVolume=i,this._tempLoop=s;return this.usingWebAudio?this.game.cache.isSoundDecoded(this.key)?(this._createSourceAndConnect(),this.loop&&""===t&&(this._sound.loop=!0),this.loop||""!==t||this._addOnEndedHandler(),this.totalDuration=this._sound.buffer.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=Math.ceil(1e3*this.totalDuration)),this.loop&&""===t?this._startSource(0,0):this._startSource(0,this.position,this.duration),this.isPlaying=!0,this.paused=!1,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):(this.pendingPlayback=!0,this.game.cache.getSound(this.key)&&!1===this.game.cache.getSound(this.key).isDecoding&&this.game.sound.decode(this.key,this)):this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked?(this.game.cache.reloadSound(this.key),this.pendingPlayback=!0):this._sound&&(this.game.device.cocoonJS||4===this._sound.readyState)?(this._sound.play(),this._sound.loop=this.loop,this.totalDuration=this._sound.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this._globalVolume=this.game.sound.volume,this._sound.currentTime=this.position,this._sound.muted=this._muted,this._muted||this.game.sound.mute?this._sound.volume=0:this._sound.volume=this._volume*this._globalVolume,this._pendingStart=!0,this.isPlaying=!0,this.paused=!1,this._tempPause=0,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):this.pendingPlayback=!0,this.playOnce&&(this.loop&&console.warn("Phaser.Sound.play: audio clip "+this.name+" cannot be deleted while looping."),this._markedToDelete=!0,this._removeFromSoundManager=!0),this},restart:function(t,e,i,s){t=t||"",e=e||0,i=i||1,void 0===s&&(s=!1),this.play(t,e,i,s,!0)},pause:function(){this.isPlaying&&(this.paused=!0,this.pausedPosition=this.currentTime,this.pausedTime=this.game.time.time,this._tempPause=this._sound.currentTime,this.onPause.dispatch(this),this.stop())},resume:function(){if(this.paused){if(this.usingWebAudio){var t=Math.max(0,this.position+this.pausedPosition/1e3);this._createSourceAndConnect(),""===this.currentMarker&&(this.loop?this._sound.loop=!0:this._addOnEndedHandler());var e=this.duration-this.pausedPosition/1e3;this.loop&&""===this.currentMarker?this._startSource(0,t):this._startSource(0,t,e)}else this._pendingStart=!0,this._sound.currentTime=this._tempPause,this._tempPause=0,this._sound.play();this.isPlaying=!0,this.paused=!1,this.startTime+=this.game.time.time-this.pausedTime,this.onResume.dispatch(this)}},stop:function(){if(this.isPlaying&&this._sound&&(this.usingWebAudio?this._stopSourceAndDisconnect():this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0)),this.pendingPlayback=!1,this.isPlaying=!1,!this.paused){var t=this.currentMarker;""!==this.currentMarker&&this.onMarkerComplete.dispatch(this.currentMarker,this),this.currentMarker="",null!==this.fadeTween&&this.fadeTween.stop(),this.onStop.dispatch(this,t)}},fadeIn:function(t,e,i){void 0===e&&(e=!1),void 0===i&&(i=this.currentMarker),this.paused||(this.play(i,0,0,e),this.fadeTo(t,1))},fadeOut:function(t){this.fadeTo(t,0)},fadeTo:function(t,i){this.isPlaying&&!this.paused&&i!==this.volume&&(void 0===t&&(t=1e3),void 0!==i?(this.fadeTween=this.game.add.tween(this).to({volume:i},t,e.Easing.Linear.None,!0),this.fadeTween.onComplete.add(this.fadeComplete,this)):console.warn("Phaser.Sound.fadeTo: No Volume Specified."))},fadeComplete:function(){this.onFadeComplete.dispatch(this,this.volume),0===this.volume&&this.stop()},updateGlobalVolume:function(t){this.usingAudioTag&&this._sound&&(this._globalVolume=t,this._sound.volume=this._globalVolume*this._volume)},destroy:function(t){void 0===t&&(t=!0),this._markedToDelete=!0,this._removeFromSoundManager=t,this.stop(),t?this.game.sound.remove(this):(this.markers={},this.context=null,this._buffer=null,this.externalNode=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())},_createSourceAndConnect:function(){this._sound=this.context.createBufferSource(),this._sound.connect(this.externalNode||this.gainNode),this._buffer=this.game.cache.getSoundData(this.key),this._sound.buffer=this._buffer,this._sourceId++},_disconnectSource:function(){this._sound.disconnect(this.externalNode||this.gainNode)},_startSource:function(t,e,i){void 0===i?this._sound.start(t||0,e||0):this._sound.start(t||0,e||0,i)},_stopSourceAndDisconnect:function(){this._removeOnEndedHandler();try{this._sound.stop(0)}catch(t){}this._disconnectSource(),this._sound=null},_addOnEndedHandler:function(){this._sound.onended=this.onEndedHandler.bind(this)},_removeOnEndedHandler:function(){this._sound.onended=null}},e.Sound.prototype.constructor=e.Sound,Object.defineProperty(e.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}}),Object.defineProperty(e.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}}),Object.defineProperty(e.Sound.prototype,"mute",{get:function(){return this._muted||this.game.sound.mute},set:function(t){(t=t||!1)!==this._muted&&(t?(this._muted=!0,this._muteVolume=this._tempVolume,this.usingWebAudio?this.gainNode.gain.value=0:this.usingAudioTag&&this._sound&&(this._sound.volume=0)):(this._muted=!1,this.usingWebAudio?this.gainNode.gain.value=this._muteVolume:this.usingAudioTag&&this._sound&&(this._sound.volume=this._muteVolume)),this.onMute.dispatch(this))}}),Object.defineProperty(e.Sound.prototype,"volume",{get:function(){return this._volume},set:function(t){this.usingAudioTag&&(t=this.game.math.clamp(t,0,1)),this._muted?this._muteVolume=t:(this._tempVolume=t,this._volume=t,this.usingWebAudio?this.gainNode.gain.value=t:this.usingAudioTag&&this._sound&&(this._sound.volume=this._globalVolume*t))}}),Object.defineProperty(e.Sound.prototype,"sourceId",{get:function(){return this._sound?this._sourceId:null}}),e.SoundManager=function(t){this.game=t,this.onSoundDecode=new e.Signal,this.onVolumeChange=new e.Signal,this.onMute=new e.Signal,this.onUnMute=new e.Signal,this.onTouchUnlock=new e.Signal,this.context=null,this.baseLatency=null,this.usingWebAudio=!1,this.usingAudioTag=!1,this.noAudio=!1,this.connectToMaster=!0,this.touchLocked=!1,this.channels=32,this.muteOnPause=!0,this._codeMuted=!1,this._muted=!1,this._unlockSource=null,this._volume=1,this._sounds=[],this._watchList=new e.ArraySet,this._watching=!1,this._watchCallback=null,this._watchContext=null,this._resumeWebAudioOnClick=this._resumeWebAudioOnClick.bind(this)},e.SoundManager.prototype={boot:function(){var t=this.game.device,e=window.PhaserGlobal;if(t.iOS&&!1===t.webAudio&&(this.channels=1),e){if(!0===e.disableAudio)return this.noAudio=!0,void(this.touchLocked=!1);if(!0===e.disableWebAudio)return this.usingAudioTag=!0,void(this.touchLocked=!1)}if(e&&e.audioContext)this.context=e.audioContext;else{var i=window.AudioContext||window.webkitAudioContext;if(i)try{this.context=new i}catch(t){this.context=null,this.usingWebAudio=!1,this.touchLocked=!1,console.warn(t)}}if(null===this.context){if(void 0===window.Audio)return void(this.noAudio=!0);this.usingAudioTag=!0}else this.usingWebAudio=!0,this.baseLatency=this.context.baseLatency||256/(this.context.sampleRate||44100),void 0===this.context.createGain?this.masterGain=this.context.createGainNode():this.masterGain=this.context.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this.context.destination),"suspended"===this.context.state&&this.game.canvas.addEventListener("click",this._resumeWebAudioOnClick);this.noAudio||t.needsTouchUnlock()&&this.setTouchLock(),this.usingWebAudio&&t.chrome&&t.chromeVersion<=65&&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 t=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource(),this._unlockSource.buffer=t,this._unlockSource.connect(this.context.destination);var e=this;this._unlockSource.onended=function(){e.setTouchUnlock(),e.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 t=0;t1&&(t=1),this._volume!==t){if(this._volume=t,this.usingWebAudio)this.masterGain.gain.value=t;else for(var e=0;e=400?0:100,this.dom.getOffset(this.game.canvas,this.offset);var i=this._parentBounds.width,s=this._parentBounds.height,n=this.getParentBounds(this._parentBounds),r=n.width!==i||n.height!==s,o=this.updateOrientationState();(r||o)&&(this.onResize&&this.onResize.call(this.onResizeContext,this,n),this.updateLayout(),this.signalSizeChange());var a=2*this._updateThrottle;this._updateThrottlee;return(h=h?s:!s)?(t.width=Math.floor(n),t.height=Math.floor(r)):(t.width=Math.floor(o),t.height=Math.floor(a)),t},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))}},e.ScaleManager.prototype.constructor=e.ScaleManager,Object.defineProperty(e.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(e.ScaleManager.prototype,"scaleMode",{get:function(){return this._scaleMode},set:function(t){return t!==this._scaleMode&&(this.isFullScreen||(this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.queueUpdate(!0)),this._scaleMode=t),this._scaleMode}}),Object.defineProperty(e.ScaleManager.prototype,"fullScreenScaleMode",{get:function(){return this._fullScreenScaleMode},set:function(t){return t!==this._fullScreenScaleMode&&(this.isFullScreen?(this.prepScreenMode(!1),this._fullScreenScaleMode=t,this.prepScreenMode(!0),this.queueUpdate(!0)):this._fullScreenScaleMode=t),this._fullScreenScaleMode}}),Object.defineProperty(e.ScaleManager.prototype,"currentScaleMode",{get:function(){return this.isFullScreen?this._fullScreenScaleMode:this._scaleMode}}),Object.defineProperty(e.ScaleManager.prototype,"pageAlignHorizontally",{get:function(){return this._pageAlignHorizontally},set:function(t){t!==this._pageAlignHorizontally&&(this._pageAlignHorizontally=t,this.queueUpdate(!0))}}),Object.defineProperty(e.ScaleManager.prototype,"pageAlignVertically",{get:function(){return this._pageAlignVertically},set:function(t){t!==this._pageAlignVertically&&(this._pageAlignVertically=t,this.queueUpdate(!0))}}),Object.defineProperty(e.ScaleManager.prototype,"isFullScreen",{get:function(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}}),Object.defineProperty(e.ScaleManager.prototype,"isPortrait",{get:function(){return"portrait"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(e.ScaleManager.prototype,"isLandscape",{get:function(){return"landscape"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(e.ScaleManager.prototype,"isGamePortrait",{get:function(){return this.height>this.width}}),Object.defineProperty(e.ScaleManager.prototype,"isGameLandscape",{get:function(){return this.width>this.height}}),e.Utils.Debug=function(t){this.game=t,this.sprite=null,this.bmd=null,this.canvas=null,this.context=null,this.font="14px monospace",this.columnWidth=100,this.lineHeight=16,this.lineWidth=1,this.renderShadow=!0,this.currentColor=null,this.currentX=0,this.currentY=0,this.currentAlpha=1,this.dirty=!1,this.isDisabled=!1,this._line=null,this._rect=null},e.Utils.Debug.GEOM_AUTO=0,e.Utils.Debug.GEOM_RECTANGLE=1,e.Utils.Debug.GEOM_CIRCLE=2,e.Utils.Debug.GEOM_POINT=3,e.Utils.Debug.GEOM_LINE=4,e.Utils.Debug.GEOM_ELLIPSE=5,e.Utils.Debug.prototype={boot:function(){this.game.renderType===e.CANVAS?this.context=this.game.context:(this.bmd=new e.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=e.CanvasPool.create(this,this.game.width,this.game.height),this.context=this.canvas.getContext("2d")),this._line=new e.Line,this._rect=new e.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(t,e,i,s){"number"!=typeof t&&(t=0),"number"!=typeof e&&(e=0),i=i||"rgb(255,255,255)",void 0===s&&(s=0),this.currentX=t,this.currentY=e,this.currentColor=i,this.columnWidth=s,this.dirty=!0,this.context.save(),this.context.setTransform(1,0,0,1,0,0),this.context.strokeStyle=i,this.context.fillStyle=i,this.context.font=this.font,this.context.globalAlpha=this.currentAlpha},stop:function(){this.context.restore()},line:function(){for(var t=this.currentX,e=0;e0)for(var e=0;e=0&&i.right>=0&&i.top<=this.layoutBounds.width&&i.left<=this.layoutBounds.height},getScreenOrientation:function(t){var e=window.screen,i=e.orientation||e.mozOrientation||e.msOrientation;if(i&&"string"==typeof i.type)return i.type;if("string"==typeof i)return i;var s="portrait-primary",n="landscape-primary";if("screen"===t)return e.height>e.width?s:n;if("viewport"===t)return this.visualBounds.height>this.visualBounds.width?s:n;if("window.orientation"===t&&"number"==typeof window.orientation)return 0===window.orientation||180===window.orientation?s:n;if(window.matchMedia){if(window.matchMedia("(orientation: portrait)").matches)return s;if(window.matchMedia("(orientation: landscape)").matches)return n}return this.visualBounds.height>this.visualBounds.width?s:n},visualBounds:new e.Rectangle,layoutBounds:new e.Rectangle,documentBounds:new e.Rectangle},e.Device.whenReady(function(t){var i=window&&"pageXOffset"in window?function(){return window.pageXOffset}:function(){return document.documentElement.scrollLeft},s=window&&"pageYOffset"in window?function(){return window.pageYOffset}:function(){return document.documentElement.scrollTop};if(Object.defineProperty(e.DOM,"scrollX",{get:i}),Object.defineProperty(e.DOM,"scrollY",{get:s}),Object.defineProperty(e.DOM.visualBounds,"x",{get:i}),Object.defineProperty(e.DOM.visualBounds,"y",{get:s}),Object.defineProperty(e.DOM.layoutBounds,"x",{value:0}),Object.defineProperty(e.DOM.layoutBounds,"y",{value:0}),t.desktop&&document.documentElement.clientWidth<=window.innerWidth&&document.documentElement.clientHeight<=window.innerHeight){var n=function(){return Math.max(window.innerWidth,document.documentElement.clientWidth)},r=function(){return Math.max(window.innerHeight,document.documentElement.clientHeight)};Object.defineProperty(e.DOM.visualBounds,"width",{get:n}),Object.defineProperty(e.DOM.visualBounds,"height",{get:r}),Object.defineProperty(e.DOM.layoutBounds,"width",{get:n}),Object.defineProperty(e.DOM.layoutBounds,"height",{get:r})}else Object.defineProperty(e.DOM.visualBounds,"width",{get:function(){return window.innerWidth}}),Object.defineProperty(e.DOM.visualBounds,"height",{get:function(){return window.innerHeight}}),Object.defineProperty(e.DOM.layoutBounds,"width",{get:function(){var t=document.documentElement.clientWidth,e=window.innerWidth;return t-1},reset:function(){this.list.length=0},remove:function(t){var e=this.list.indexOf(t);if(e>-1)return this.list.splice(e,1),t},setAll:function(t,e){for(var i=this.list.length;i--;)this.list[i]&&(this.list[i][t]=e)},callAll:function(t){for(var e=Array.prototype.slice.call(arguments,1),i=this.list.length;i--;)this.list[i]&&this.list[i][t]&&this.list[i][t].apply(this.list[i],e)},removeAll:function(t){void 0===t&&(t=!1);for(var e=this.list.length;e--;)if(this.list[e]){var i=this.remove(this.list[e]);t&&i.destroy()}this.position=0,this.list=[]}},Object.defineProperty(e.ArraySet.prototype,"total",{get:function(){return this.list.length}}),Object.defineProperty(e.ArraySet.prototype,"first",{get:function(){return this.position=0,this.list.length>0?this.list[0]:null}}),Object.defineProperty(e.ArraySet.prototype,"next",{get:function(){return this.position=s||0===i)){null==i&&(i=1);for(var n=s-i,r=e;r0;e--){var i=Math.floor(Math.random()*(e+1)),s=t[e];t[e]=t[i],t[i]=s}return t},transposeMatrix:function(t){for(var e=t.length,i=t[0].length,s=new Array(i),n=0;n-1;r--)s[n][r]=t[r][n]}return s},rotateMatrix:function(t,i){if("string"!=typeof i&&(i=(i%360+360)%360),90===i||-270===i||"rotateLeft"===i)t=(t=e.ArrayUtils.transposeMatrix(t)).reverse();else if(-90===i||270===i||"rotateRight"===i)t=t.reverse(),t=e.ArrayUtils.transposeMatrix(t);else if(180===Math.abs(i)||"rotate180"===i){for(var s=0;s>>0:(t<<24|i<<16|s<<8|n)>>>0},unpackPixel:function(t,i,s,n){return void 0!==i&&null!==i||(i=e.Color.createColor()),void 0!==s&&null!==s||(s=!1),void 0!==n&&null!==n||(n=!1),e.Device.LITTLE_ENDIAN?(i.a=(4278190080&t)>>>24,i.b=(16711680&t)>>>16,i.g=(65280&t)>>>8,i.r=255&t):(i.r=(4278190080&t)>>>24,i.g=(16711680&t)>>>16,i.b=(65280&t)>>>8,i.a=255&t),i.color=t,i.rgba="rgba("+i.r+","+i.g+","+i.b+","+i.a/255+")",s&&e.Color.RGBtoHSL(i.r,i.g,i.b,i),n&&e.Color.RGBtoHSV(i.r,i.g,i.b,i),i},fromRGBA:function(t,i){return i||(i=e.Color.createColor()),i.r=(4278190080&t)>>>24,i.g=(16711680&t)>>>16,i.b=(65280&t)>>>8,i.a=255&t,i.rgba="rgba("+i.r+","+i.g+","+i.b+","+i.a+")",i},toRGBA:function(t,e,i,s){return t<<24|e<<16|i<<8|s},toABGR:function(t,e,i,s){return(s<<24|i<<16|e<<8|t)>>>0},hexToRGBArray:function(t){return[(t>>16&255)/255,(t>>8&255)/255,(255&t)/255]},RGBArrayToHex:function(t){return(255*t[0]<<16)+(255*t[1]<<8)+255*t[2]},RGBtoHSL:function(t,i,s,n){n||(n=e.Color.createColor(t,i,s,1)),t/=255,i/=255,s/=255;var r=Math.min(t,i,s),o=Math.max(t,i,s);if(n.h=0,n.s=0,n.l=(o+r)/2,o!==r){var a=o-r;n.s=n.l>.5?a/(2-o-r):a/(o+r),o===t?n.h=(i-s)/a+(i1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t},createColor:function(t,i,s,n,r,o,a,h){var l={r:t||0,g:i||0,b:s||0,a:n||1,h:r||0,s:o||0,l:a||0,v:h||0,color:0,color32:0,rgba:""};return e.Color.updateColor(l)},updateColor:function(t){return t.rgba="rgba("+t.r.toFixed()+","+t.g.toFixed()+","+t.b.toFixed()+","+t.a.toString()+")",t.color=e.Color.getColor(t.r,t.g,t.b),t.color32=e.Color.getColor32(255*t.a,t.r,t.g,t.b),t},getColor32:function(t,e,i,s){return t<<24|e<<16|i<<8|s},getColor:function(t,e,i){return t<<16|e<<8|i},RGBtoString:function(t,i,s,n,r){return void 0===n&&(n=255),void 0===r&&(r="#"),"#"===r?"#"+((1<<24)+(t<<16)+(i<<8)+s).toString(16).slice(1):"0x"+e.Color.componentToHex(n)+e.Color.componentToHex(t)+e.Color.componentToHex(i)+e.Color.componentToHex(s)},hexToRGB:function(t){var i=e.Color.hexToColor(t);if(i)return e.Color.getColor32(i.a,i.r,i.g,i.b)},hexToColor:function(t,i){t=t.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,function(t,e,i,s){return e+e+i+i+s+s});var s=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);if(s){var n=parseInt(s[1],16),r=parseInt(s[2],16),o=parseInt(s[3],16);i?(i.r=n,i.g=r,i.b=o):i=e.Color.createColor(n,r,o)}return i},webToColor:function(t,i){i||(i=e.Color.createColor());var s=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(t);return s&&(i.r=~~Number(s[1]),i.g=~~Number(s[2]),i.b=~~Number(s[3]),i.a=void 0!==s[4]?Number(s[4]):1,e.Color.updateColor(i)),i},valueToColor:function(t,i){if(i||(i=e.Color.createColor()),"string"==typeof t)return 0===t.indexOf("rgb")?e.Color.webToColor(t,i):(i.a=1,e.Color.hexToColor(t,i));if("number"==typeof t){var s=e.Color.getRGB(t);return i.r=s.r,i.g=s.g,i.b=s.b,i.a=s.a/255,i}return i},componentToHex:function(t){var e=t.toString(16);return 1===e.length?"0"+e:e},HSVColorWheel:function(t,i){void 0===t&&(t=1),void 0===i&&(i=1);for(var s=[],n=0;n<=359;n++)s.push(e.Color.HSVtoRGB(n/359,t,i));return s},HSLColorWheel:function(t,i){void 0===t&&(t=.5),void 0===i&&(i=.5);for(var s=[],n=0;n<=359;n++)s.push(e.Color.HSLtoRGB(n/359,t,i));return s},interpolateColor:function(t,i,s,n,r,o){void 0===r&&(r=255),void 0===o&&(o=0);var a=e.Color.getRGB(t),h=e.Color.getRGB(i);if(0===o)var l=(h.red-a.red)*n/s+a.red,c=(h.green-a.green)*n/s+a.green,u=(h.blue-a.blue)*n/s+a.blue;if(1===o){var d,p=e.Color.RGBtoHSV(a.r,a.g,a.b),f=e.Color.RGBtoHSV(h.r,h.g,h.b),g=f.h-p.h;if(p.h>f.h){var m=f.h;f.h=p.h,p.h=m,g=-g,n=s-n}g>.5&&(p.h=p.h+1,d=((f.h-p.h)*n/s+p.h)%1),g<=.5&&(d=(f.h-p.h)*n/s+p.h);var y=(f.s-p.s)*n/s+p.s,v=(f.v-p.v)*n/s+p.v,x=e.Color.HSVtoRGB(d,y,v,x),l=x.r,c=x.g,u=x.b}return e.Color.getColor32(r,l,c,u)},interpolateColorWithRGB:function(t,i,s,n,r,o){var a=e.Color.getRGB(t),h=(i-a.red)*o/r+a.red,l=(s-a.green)*o/r+a.green,c=(n-a.blue)*o/r+a.blue;return e.Color.getColor(h,l,c)},interpolateRGB:function(t,i,s,n,r,o,a,h){var l=(n-t)*h/a+t,c=(r-i)*h/a+i,u=(o-s)*h/a+s;return e.Color.getColor(l,c,u)},linear:function(t,e,i){return this.interpolateColor(t,e,1,i)},linearInterpolation:function(t,i){var s=e.Math.linear(0,t.length-1,i),n=t[Math.floor(s)],r=t[Math.ceil(s)];return this.linear(n,r,s%1)},getRandomColor:function(t,i,s){if(void 0===t&&(t=0),void 0===i&&(i=255),void 0===s&&(s=255),i>255||t>i)return e.Color.getColor(255,255,255);var n=t+Math.round(Math.random()*(i-t)),r=t+Math.round(Math.random()*(i-t)),o=t+Math.round(Math.random()*(i-t));return e.Color.getColor32(s,n,r,o)},getRGB:function(t){return t>16777215?{alpha:t>>>24,red:t>>16&255,green:t>>8&255,blue:255&t,a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{alpha:255,red:t>>16&255,green:t>>8&255,blue:255&t,a:255,r:t>>16&255,g:t>>8&255,b:255&t}},getWebRGB:function(t){if("object"==typeof t)return"rgba("+t.r.toString()+","+t.g.toString()+","+t.b.toString()+","+(t.a/255).toString()+")";var i=e.Color.getRGB(t);return"rgba("+i.r.toString()+","+i.g.toString()+","+i.b.toString()+","+(i.a/255).toString()+")"},getAlpha:function(t){return t>>>24},getAlphaFloat:function(t){return(t>>>24)/255},getRed:function(t){return t>>16&255},getGreen:function(t){return t>>8&255},getBlue:function(t){return 255&t},blendNormal:function(t){return t},blendLighten:function(t,e){return e>t?e:t},blendDarken:function(t,e){return e>t?t:e},blendMultiply:function(t,e){return t*e/255},blendAverage:function(t,e){return(t+e)/2},blendAdd:function(t,e){return Math.min(255,t+e)},blendSubtract:function(t,e){return Math.max(0,t+e-255)},blendDifference:function(t,e){return Math.abs(t-e)},blendNegation:function(t,e){return 255-Math.abs(255-t-e)},blendScreen:function(t,e){return 255-((255-t)*(255-e)>>8)},blendExclusion:function(t,e){return t+e-2*t*e/255},blendOverlay:function(t,e){return e<128?2*t*e/255:255-2*(255-t)*(255-e)/255},blendSoftLight:function(t,e){return e<128?2*(64+(t>>1))*(e/255):255-2*(255-(64+(t>>1)))*(255-e)/255},blendHardLight:function(t,i){return e.Color.blendOverlay(i,t)},blendColorDodge:function(t,e){return 255===e?e:Math.min(255,(t<<8)/(255-e))},blendColorBurn:function(t,e){return 0===e?e:Math.max(0,255-(255-t<<8)/e)},blendLinearDodge:function(t,i){return e.Color.blendAdd(t,i)},blendLinearBurn:function(t,i){return e.Color.blendSubtract(t,i)},blendLinearLight:function(t,i){return i<128?e.Color.blendLinearBurn(t,2*i):e.Color.blendLinearDodge(t,2*(i-128))},blendVividLight:function(t,i){return i<128?e.Color.blendColorBurn(t,2*i):e.Color.blendColorDodge(t,2*(i-128))},blendPinLight:function(t,i){return i<128?e.Color.blendDarken(t,2*i):e.Color.blendLighten(t,2*(i-128))},blendHardMix:function(t,i){return e.Color.blendVividLight(t,i)<128?0:255},blendReflect:function(t,e){return 255===e?e:Math.min(255,t*t/(255-e))},blendGlow:function(t,i){return e.Color.blendReflect(i,t)},blendPhoenix:function(t,e){return Math.min(t,e)-Math.max(t,e)+255}},e.Physics=function(t,e){e=e||{},this.game=t,this.config=e,this.arcade=null,this.p2=null,this.ninja=null,this.box2d=null,this.chipmunk=null,this.matter=null,this.parseConfig()},e.Physics.ARCADE=0,e.Physics.P2JS=1,e.Physics.NINJA=2,e.Physics.BOX2D=3,e.Physics.CHIPMUNK=4,e.Physics.MATTERJS=5,e.Physics.prototype={parseConfig:function(){this.config.hasOwnProperty("arcade")&&!0!==this.config.arcade||!e.Physics.hasOwnProperty("Arcade")||(this.arcade=new e.Physics.Arcade(this.game)),this.config.hasOwnProperty("ninja")&&!0===this.config.ninja&&e.Physics.hasOwnProperty("Ninja")&&(this.ninja=new e.Physics.Ninja(this.game)),this.config.hasOwnProperty("p2")&&!0===this.config.p2&&e.Physics.hasOwnProperty("P2")&&(this.p2=new e.Physics.P2(this.game,this.config)),this.config.hasOwnProperty("box2d")&&!0===this.config.box2d&&e.Physics.hasOwnProperty("BOX2D")&&(this.box2d=new e.Physics.Box2D(this.game,this.config)),this.config.hasOwnProperty("matter")&&!0===this.config.matter&&e.Physics.hasOwnProperty("Matter")&&(this.matter=new e.Physics.Matter(this.game,this.config))},startSystem:function(t){t===e.Physics.ARCADE?this.arcade=new e.Physics.Arcade(this.game):t===e.Physics.P2JS?null===this.p2?this.p2=new e.Physics.P2(this.game,this.config):this.p2.reset():t===e.Physics.NINJA?this.ninja=new e.Physics.Ninja(this.game):t===e.Physics.BOX2D?null===this.box2d?this.box2d=new e.Physics.Box2D(this.game,this.config):this.box2d.reset():t===e.Physics.MATTERJS&&(null===this.matter?this.matter=new e.Physics.Matter(this.game,this.config):this.matter.reset())},enable:function(t,i,s){void 0===i&&(i=e.Physics.ARCADE),void 0===s&&(s=!1),i===e.Physics.ARCADE?this.arcade.enable(t):i===e.Physics.P2JS&&this.p2?this.p2.enable(t,s):i===e.Physics.NINJA&&this.ninja?this.ninja.enableAABB(t):i===e.Physics.BOX2D&&this.box2d?this.box2d.enable(t):i===e.Physics.MATTERJS&&this.matter?this.matter.enable(t):console.warn(t.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.arcade=null,this.ninja=null,this.p2=null,this.box2d=null,this.matter=null}},e.Physics.prototype.constructor=e.Physics,e.Physics.Arcade=function(t){this.game=t,this.gravity=new e.Point,this.bounds=new e.Rectangle(0,0,t.world.width,t.world.height),this.checkCollision={up:!0,down:!0,left:!0,right:!0},this.maxObjects=10,this.maxLevels=4,this.OVERLAP_BIAS=4,this.forceX=!1,this.sortDirection=e.Physics.Arcade.LEFT_RIGHT,this.skipQuadTree=!0,this.isPaused=!1,this.quadTree=new e.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()},e.Physics.Arcade.prototype.constructor=e.Physics.Arcade,e.Physics.Arcade.SORT_NONE=0,e.Physics.Arcade.LEFT_RIGHT=1,e.Physics.Arcade.RIGHT_LEFT=2,e.Physics.Arcade.TOP_BOTTOM=3,e.Physics.Arcade.BOTTOM_TOP=4,e.Physics.Arcade.prototype={setBounds:function(t,e,i,s){this.bounds.setTo(t,e,i,s)},setBoundsToWorld:function(){this.bounds.copyFrom(this.game.world.bounds)},enable:function(t,i){void 0===i&&(i=!0);var s=1;if(Array.isArray(t))for(s=t.length;s--;)t[s]instanceof e.Group?this.enable(t[s].children,i):(this.enableBody(t[s]),i&&t[s].hasOwnProperty("children")&&t[s].children.length>0&&this.enable(t[s],!0));else t instanceof e.Group?this.enable(t.children,i):(this.enableBody(t),i&&t.hasOwnProperty("children")&&t.children.length>0&&this.enable(t.children,!0))},enableBody:function(t){t.hasOwnProperty("body")&&null===t.body&&(t.body=new e.Physics.Arcade.Body(t),t.parent&&t.parent instanceof e.Group&&t.parent.addToHash(t))},updateMotion:function(t){if(t.allowRotation){var e=this.computeVelocity(0,t,t.angularVelocity,t.angularAcceleration,t.angularDrag,t.maxAngular)-t.angularVelocity;t.angularVelocity+=e,t.rotation+=t.angularVelocity*this.game.time.physicsElapsed}t.velocity.x=this.computeVelocity(1,t,t.velocity.x,t.acceleration.x,t.drag.x,t.maxVelocity.x),t.velocity.y=this.computeVelocity(2,t,t.velocity.y,t.acceleration.y,t.drag.y,t.maxVelocity.y)},computeVelocity:function(t,e,i,s,n,r){return void 0===r&&(r=1e4),1===t&&e.allowGravity?i+=(this.gravity.x+e.gravity.x)*this.game.time.physicsElapsed:2===t&&e.allowGravity&&(i+=(this.gravity.y+e.gravity.y)*this.game.time.physicsElapsed),s?i+=s*this.game.time.physicsElapsed:n&&e.allowDrag&&(i-(n*=this.game.time.physicsElapsed)>0?i-=n:i+n<0?i+=n:i=0),i>r?i=r:i<-r&&(i=-r),i},overlap:function(t,e,i,s,n){return i=i||null,s=s||null,n=n||i,this._total=0,this.collideObjects(t,e,i,s,n,!0),this._total>0},collide:function(t,e,i,s,n){return i=i||null,s=s||null,n=n||i,this._total=0,this.collideObjects(t,e,i,s,n,!1),this._total>0},sortLeftRight:function(t,e){return t.body&&e.body?t.body.x-e.body.x:0},sortRightLeft:function(t,e){return t.body&&e.body?e.body.x-t.body.x:0},sortTopBottom:function(t,e){return t.body&&e.body?t.body.y-e.body.y:0},sortBottomTop:function(t,e){return t.body&&e.body?e.body.y-t.body.y:0},sort:function(t,i){null!==t.physicsSortDirection?i=t.physicsSortDirection:void 0===i&&(i=this.sortDirection),i===e.Physics.Arcade.LEFT_RIGHT?t.hash.sort(this.sortLeftRight):i===e.Physics.Arcade.RIGHT_LEFT?t.hash.sort(this.sortRightLeft):i===e.Physics.Arcade.TOP_BOTTOM?t.hash.sort(this.sortTopBottom):i===e.Physics.Arcade.BOTTOM_TOP&&t.hash.sort(this.sortBottomTop)},collideObjects:function(t,e,i,s,n,r){if(!Array.isArray(t)&&Array.isArray(e))for(o=0;oa.right)break;if(a.x>t.body.right)continue}else if(this.sortDirection===e.Physics.Arcade.TOP_BOTTOM){if(t.body.bottoma.bottom)break;if(a.y>t.body.bottom)continue}this.collideSpriteVsSprite(t,l,s,n,r,o)}}else{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(i);for(var c=this.quadTree.retrieve(t),h=0;hc.right)continue;if(c.x>a.right)break}else if(this.sortDirection===e.Physics.Arcade.TOP_BOTTOM){if(a.bottomc.bottom)continue;if(c.y>h.body.bottom)break}this.collideSpriteVsSprite(h,u,i,s,n,r)}}}}},collideGroupVsGroup:function(t,i,s,n,r,o){if(0!==t.length&&0!==i.length)for(var a=0;aa.bottom)&&(h.xa.right))return this.separateCircle(t,e,n)}var l=!1,c=!1;this.forceX||Math.abs(this.gravity.y+t.gravity.y)=i.right)&&!(t.position.y>=i.bottom))))},circleBodyIntersects:function(t,i){var s=e.Math.clamp(t.center.x,i.left,i.right),n=e.Math.clamp(t.center.y,i.top,i.bottom);return(t.center.x-s)*(t.center.x-s)+(t.center.y-n)*(t.center.y-n)<=t.halfWidth*t.halfWidth},separateCircle:function(t,i,s){this.getOverlapX(t,i),this.getOverlapY(t,i);var n=i.center.x-t.center.x,r=i.center.y-t.center.y,o=Math.atan2(r,n),a=0;if(t.isCircle!==i.isCircle){var h={x:i.isCircle?t.position.x:i.position.x,y:i.isCircle?t.position.y:i.position.y,right:i.isCircle?t.right:i.right,bottom:i.isCircle?t.bottom:i.bottom},l={x:t.isCircle?t.center.x:i.center.x,y:t.isCircle?t.center.y:i.center.y,radius:t.isCircle?t.halfWidth:i.halfWidth};l.yh.right&&(a=e.Math.distance(l.x,l.y,h.right,h.y)-l.radius):l.y>h.bottom&&(l.xh.right&&(a=e.Math.distance(l.x,l.y,h.right,h.bottom)-l.radius)),a*=-1}else a=t.halfWidth+i.halfWidth-e.Math.distance(t.center.x,t.center.y,i.center.x,i.center.y);if(s||0===a||t.immovable&&i.immovable||t.customSeparateX||i.customSeparateX)return 0!==a&&(t.onOverlap&&t.onOverlap.dispatch(t.sprite,i.sprite),i.onOverlap&&i.onOverlap.dispatch(i.sprite,t.sprite)),0!==a;var c={x:t.velocity.x*Math.cos(o)+t.velocity.y*Math.sin(o),y:-t.velocity.x*Math.sin(o)+t.velocity.y*Math.cos(o)},u={x:i.velocity.x*Math.cos(o)+i.velocity.y*Math.sin(o),y:-i.velocity.x*Math.sin(o)+i.velocity.y*Math.cos(o)},d=((t.mass-i.mass)*c.x+2*i.mass*u.x)/(t.mass+i.mass),p=(2*t.mass*c.x+(i.mass-t.mass)*u.x)/(t.mass+i.mass);return t.immovable||(t.velocity.x=(d*Math.cos(o)-c.y*Math.sin(o))*t.bounce.x,t.velocity.y=(c.y*Math.cos(o)+d*Math.sin(o))*t.bounce.y),i.immovable||(i.velocity.x=(p*Math.cos(o)-u.y*Math.sin(o))*i.bounce.x,i.velocity.y=(u.y*Math.cos(o)+p*Math.sin(o))*i.bounce.y),Math.abs(o)0&&!t.immovable&&i.velocity.x>t.velocity.x?t.velocity.x*=-1:i.velocity.x<0&&!i.immovable&&t.velocity.x0&&!t.immovable&&i.velocity.y>t.velocity.y?t.velocity.y*=-1:i.velocity.y<0&&!i.immovable&&t.velocity.yMath.PI/2&&(t.velocity.x<0&&!t.immovable&&i.velocity.x0&&!i.immovable&&t.velocity.x>i.velocity.x?i.velocity.x*=-1:t.velocity.y<0&&!t.immovable&&i.velocity.y0&&!i.immovable&&t.velocity.x>i.velocity.y&&(i.velocity.y*=-1)),t.immovable||(t.x+=t.velocity.x*this.game.time.physicsElapsed-a*Math.cos(o),t.y+=t.velocity.y*this.game.time.physicsElapsed-a*Math.sin(o)),i.immovable||(i.x+=i.velocity.x*this.game.time.physicsElapsed+a*Math.cos(o),i.y+=i.velocity.y*this.game.time.physicsElapsed+a*Math.sin(o)),t.onCollide&&t.onCollide.dispatch(t.sprite,i.sprite),i.onCollide&&i.onCollide.dispatch(i.sprite,t.sprite),!0},getOverlapX:function(t,e,i){var s=0,n=t.deltaAbsX()+e.deltaAbsX()+this.OVERLAP_BIAS;return 0===t.deltaX()&&0===e.deltaX()?(t.embedded=!0,e.embedded=!0):t.deltaX()>e.deltaX()?(s=t.right-e.x)>n&&!i||!1===t.checkCollision.right||!1===e.checkCollision.left?s=0:(t.touching.none=!1,t.touching.right=!0,e.touching.none=!1,e.touching.left=!0):t.deltaX()n&&!i||!1===t.checkCollision.left||!1===e.checkCollision.right?s=0:(t.touching.none=!1,t.touching.left=!0,e.touching.none=!1,e.touching.right=!0)),t.overlapX=s,e.overlapX=s,s},getOverlapY:function(t,e,i){var s=0,n=t.deltaAbsY()+e.deltaAbsY()+this.OVERLAP_BIAS;return 0===t.deltaY()&&0===e.deltaY()?(t.embedded=!0,e.embedded=!0):t.deltaY()>e.deltaY()?(s=t.bottom-e.y)>n&&!i||!1===t.checkCollision.down||!1===e.checkCollision.up?s=0:(t.touching.none=!1,t.touching.down=!0,e.touching.none=!1,e.touching.up=!0):t.deltaY()n&&!i||!1===t.checkCollision.up||!1===e.checkCollision.down?s=0:(t.touching.none=!1,t.touching.up=!0,e.touching.none=!1,e.touching.down=!0)),t.overlapY=s,e.overlapY=s,s},separateX:function(t,e,i){var s=this.getOverlapX(t,e,i);if(i||0===s||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==s||t.embedded&&e.embedded;var n=t.velocity.x,r=e.velocity.x;if(t.immovable||e.immovable)t.immovable?(e.x+=s,e.velocity.x=n-r*e.bounce.x,t.moves&&(e.y+=(t.y-t.prev.y)*t.friction.y)):(t.x-=s,t.velocity.x=r-n*t.bounce.x,e.moves&&(t.y+=(e.y-e.prev.y)*e.friction.y));else{s*=.5,t.x-=s,e.x+=s;var o=Math.sqrt(r*r*e.mass/t.mass)*(r>0?1:-1),a=Math.sqrt(n*n*t.mass/e.mass)*(n>0?1:-1),h=.5*(o+a);o-=h,a-=h,t.velocity.x=h+o*t.bounce.x,e.velocity.x=h+a*e.bounce.x}return!0},separateY:function(t,e,i){var s=this.getOverlapY(t,e,i);if(i||0===s||t.immovable&&e.immovable||t.customSeparateY||e.customSeparateY)return 0!==s||t.embedded&&e.embedded;var n=t.velocity.y,r=e.velocity.y;if(t.immovable||e.immovable)t.immovable?(e.y+=s,e.velocity.y=n-r*e.bounce.y,t.moves&&(e.x+=(t.x-t.prev.x)*t.friction.x)):(t.y-=s,t.velocity.y=r-n*t.bounce.y,e.moves&&(t.x+=(e.x-e.prev.x)*e.friction.x));else{s*=.5,t.y-=s,e.y+=s;var o=Math.sqrt(r*r*e.mass/t.mass)*(r>0?1:-1),a=Math.sqrt(n*n*t.mass/e.mass)*(n>0?1:-1),h=.5*(o+a);o-=h,a-=h,t.velocity.y=h+o*t.bounce.y,e.velocity.y=h+a*e.bounce.y}return!0},getObjectsUnderPointer:function(t,e,i,s){if(0!==e.length&&t.exists)return this.getObjectsAtLocation(t.x,t.y,e,i,s,t)},getObjectsAtLocation:function(t,i,s,n,r,o){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(s);for(var a=new e.Rectangle(t,i,1,1),h=[],l=this.quadTree.retrieve(a),c=0;c0&&(s=this.distanceBetween(t,i)/(n/1e3)),t.body.velocity.setToPolar(r,s),r},moveToPointer:function(t,e,i,s){void 0===e&&(e=60),i=i||this.game.input.activePointer,void 0===s&&(s=0);var n=this.angleToPointer(t,i);return s>0&&(e=this.distanceToPointer(t,i)/(s/1e3)),t.body.velocity.setToPolar(n,e),n},moveToXY:function(t,e,i,s,n){void 0===s&&(s=60),void 0===n&&(n=0);var r=Math.atan2(i-t.y,e-t.x);return n>0&&(s=this.distanceToXY(t,e,i)/(n/1e3)),t.body.velocity.setToPolar(r,s),r},velocityFromAngle:function(t,i,s){return void 0===i&&(i=60),(s=s||new e.Point).setToPolar(t,i,!0)},velocityFromRotation:function(t,i,s){return void 0===i&&(i=60),(s=s||new e.Point).setToPolar(t,i)},accelerationFromRotation:function(t,i,s){return void 0===i&&(i=60),(s=s||new e.Point).setToPolar(t,i)},accelerateToObject:function(t,e,i,s,n){void 0===i&&(i=60),void 0===s&&(s=1e3),void 0===n&&(n=1e3);var r=this.angleBetween(t,e);return t.body.acceleration.setToPolar(r,i),t.body.maxVelocity.setTo(s,n),r},accelerateToPointer:function(t,e,i,s,n){void 0===i&&(i=60),void 0===e&&(e=this.game.input.activePointer),void 0===s&&(s=1e3),void 0===n&&(n=1e3);var r=this.angleToPointer(t,e);return t.body.acceleration.setToPolar(r,i),t.body.maxVelocity.setTo(s,n),r},accelerateToXY:function(t,e,i,s,n,r){void 0===s&&(s=60),void 0===n&&(n=1e3),void 0===r&&(r=1e3);var o=this.angleToXY(t,e,i);return t.body.acceleration.setTo(o,s),t.body.maxVelocity.setTo(n,r),o},distanceBetween:function(t,e,i,s){void 0===i&&(i=!1);var n,r;return s?(n=t.centerX-e.centerX,r=t.centerY-e.centerY):i?(n=t.world.x-e.world.x,r=t.world.y-e.world.y):(n=t.x-e.x,r=t.y-e.y),Math.sqrt(n*n+r*r)},distanceToXY:function(t,e,i,s){void 0===s&&(s=!1);var n=s?t.world.x-e:t.x-e,r=s?t.world.y-i:t.y-i;return Math.sqrt(n*n+r*r)},distanceToPointer:function(t,e,i){void 0===e&&(e=this.game.input.activePointer),void 0===i&&(i=!1);var s=i?t.world.x-e.worldX:t.x-e.worldX,n=i?t.world.y-e.worldY:t.y-e.worldY;return Math.sqrt(s*s+n*n)},closest:function(t,e,i,s){for(var n=1/0,r=null,o=0,a=e.length;on&&(r=h,n=l)}return r},angleBetween:function(t,i,s){return void 0===s&&(s=!1),s?e.Point.angle(i.world,t.world):e.Point.angle(i,t)},angleBetweenCenters:function(t,e){var i=e.centerX-t.centerX,s=e.centerY-t.centerY;return Math.atan2(s,i)},angleToXY:function(t,e,i,s){return void 0===s&&(s=!1),s?Math.atan2(i-t.world.y,e-t.world.x):Math.atan2(i-t.y,e-t.x)},angleToPointer:function(t,e,i){return void 0===e&&(e=this.game.input.activePointer),void 0===i&&(i=!1),i?Math.atan2(e.worldY-t.world.y,e.worldX-t.world.x):Math.atan2(e.worldY-t.y,e.worldX-t.x)},worldAngleToPointer:function(t,e){return this.angleToPointer(t,e,!0)}},e.Physics.Arcade.Body=function(t){this.sprite=t,this.game=t.game,this.type=e.Physics.ARCADE,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new e.Point,this.position=new e.Point(t.x,t.y),this.prev=new e.Point(this.position.x,this.position.y),this.allowRotation=!0,this.rotation=t.angle,this.preRotation=t.angle,this.width=t.width,this.height=t.height,this.sourceWidth=t.width,this.sourceHeight=t.height,t.texture&&(this.sourceWidth=t.texture.frame.width,this.sourceHeight=t.texture.frame.height),this.halfWidth=Math.abs(t.width/2),this.halfHeight=Math.abs(t.height/2),this.center=new e.Point(t.x+this.halfWidth,t.y+this.halfHeight),this.velocity=new e.Point,this.newVelocity=new e.Point,this.deltaMax=new e.Point,this.acceleration=new e.Point,this.allowDrag=!0,this.drag=new e.Point,this.allowGravity=!0,this.gravity=new e.Point,this.bounce=new e.Point,this.worldBounce=null,this.onWorldBounds=null,this.onCollide=null,this.onOverlap=null,this.maxVelocity=new e.Point(1e4,1e4),this.friction=new e.Point(1,0),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.angle=0,this.speed=0,this.facing=e.NONE,this.immovable=!1,this.moves=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!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 e.Point,this.dirty=!1,this.skipQuadTree=!1,this.syncBounds=!1,this.isMoving=!1,this.stopVelocityOnCollide=!0,this.moveTimer=0,this.moveDistance=0,this.moveDuration=0,this.moveTarget=null,this.moveEnd=null,this.onMoveComplete=new e.Signal,this.movementCallback=null,this.movementCallbackContext=null,this._reset=!0,this._sx=t.scale.x,this._sy=t.scale.y,this._dx=0,this._dy=0},e.Physics.Arcade.Body.prototype={updateBounds:function(){if(this.syncBounds){var t=this.sprite.getBounds();t.ceilAll(),t.width===this.width&&t.height===this.height||(this.width=t.width,this.height=t.height,this._reset=!0)}else{var e=Math.abs(this.sprite.scale.x),i=Math.abs(this.sprite.scale.y);e===this._sx&&i===this._sy||(this.width=this.sourceWidth*e,this.height=this.sourceHeight*i,this._sx=e,this._sy=i,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(){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.overlapR=0,this.overlapX=0,this.overlapY=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-=this.sprite.scale.x<0?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-=this.sprite.scale.y<0?this.height:0,this.updateCenter(),this.rotation=this.sprite.angle,this.preRotation=this.rotation,(this._reset||this.sprite.fresh)&&(this.prev.x=this.position.x,this.prev.y=this.position.y),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(),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 t=0,e=0!==this.overlapX||0!==this.overlapY;if(this.moveDuration>0?(this.moveTimer+=this.game.time.elapsedMS,t=this.moveTimer/this.moveDuration):(this.moveTarget.end.set(this.position.x,this.position.y),t=this.moveTarget.length/this.moveDistance),this.movementCallback)var i=this.movementCallback.call(this.movementCallbackContext,this,this.velocity,t);return!(e||t>=1||void 0!==i&&!0!==i)||(this.stopMovement(t>=1||this.stopVelocityOnCollide&&e),!1)},stopMovement:function(t){this.isMoving&&(this.isMoving=!1,t&&this.velocity.set(0),this.onMoveComplete.dispatch(this.sprite,0!==this.overlapX||0!==this.overlapY))},postUpdate:function(){this.enable&&this.dirty&&(this.isMoving&&this.updateMovement(),this.dirty=!1,this.deltaX()<0?this.facing=e.LEFT:this.deltaX()>0&&(this.facing=e.RIGHT),this.deltaY()<0?this.facing=e.UP:this.deltaY()>0&&(this.facing=e.DOWN),this.moves&&(this._dx=this.deltaX(),this._dy=this.deltaY(),0!==this.deltaMax.x&&0!==this._dx&&(this._dx<0&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:this._dx>0&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:this._dy>0&&this._dy>this.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 t=this.position,e=this.game.physics.arcade.bounds,i=this.game.physics.arcade.checkCollision,s=this.worldBounce?-this.worldBounce.x:-this.bounce.x,n=this.worldBounce?-this.worldBounce.y:-this.bounce.y;return t.xe.right&&i.right&&(t.x=e.right-this.width,this.velocity.x*=s,this.blocked.right=!0,this.blocked.none=!1),t.ye.bottom&&i.down&&(t.y=e.bottom-this.height,this.velocity.y*=n,this.blocked.down=!0,this.blocked.none=!1),!this.blocked.none},moveFrom:function(t,e,i){if(void 0===e&&(e=this.speed),0===e)return!1;var s;return void 0===i?(s=this.angle,i=this.game.math.radToDeg(s)):s=this.game.math.degToRad(i),this.moveTimer=0,this.moveDuration=t,0===i||180===i?this.velocity.set(Math.cos(s)*e,0):90===i||270===i?this.velocity.set(0,Math.sin(s)*e):this.velocity.setToPolar(s,e),this.isMoving=!0,!0},moveTo:function(t,i,s){var n=i/(t/1e3);if(0===n)return!1;var r;return void 0===s?(r=this.angle,s=this.game.math.radToDeg(r)):r=this.game.math.degToRad(s),i=Math.abs(i),this.moveDuration=0,this.moveDistance=i,null===this.moveTarget&&(this.moveTarget=new e.Line,this.moveEnd=new e.Point),this.moveTarget.fromAngle(this.x,this.y,r,i),this.moveEnd.set(this.moveTarget.end.x,this.moveTarget.end.y),this.moveTarget.setTo(this.x,this.y,this.x,this.y),0===s||180===s?this.velocity.set(Math.cos(r)*n,0):90===s||270===s?this.velocity.set(0,Math.sin(r)*n):this.velocity.setToPolar(r,n),this.isMoving=!0,!0},setSize:function(t,e,i,s){void 0===i&&(i=this.offset.x),void 0===s&&(s=this.offset.y),this.sourceWidth=t,this.sourceHeight=e,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(i,s),this.updateCenter(),this.isCircle=!1,this.radius=0},setCircle:function(t,e,i){void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.isCircle=!0,this.radius=t,this.sourceWidth=2*t,this.sourceHeight=2*t,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(e,i),this.updateCenter()):this.isCircle=!1},reset:function(t,e){this.stop(),this.position.x=t-this.sprite.anchor.x*this.sprite.width+this.sprite.scale.x*this.offset.x,this.position.x-=this.sprite.scale.x<0?this.width:0,this.position.y=e-this.sprite.anchor.y*this.sprite.height+this.sprite.scale.y*this.offset.y,this.position.y-=this.sprite.scale.y<0?this.height:0,this.prev.x=this.position.x,this.prev.y=this.position.y,this.rotation=this.sprite.angle,this.preRotation=this.rotation,this.updateBounds(),this.updateCenter()},stop:function(){this.velocity.set(0),this.acceleration.set(0),this.speed=0,this.angularVelocity=0,this.angularAcceleration=0},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,i){return this.isCircle?e.Circle.contains(this,t,i):e.Rectangle.contains(this,t,i)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},deltaAbsY:function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},deltaX:function(){return this.position.x-this.prev.x},deltaY:function(){return this.position.y-this.prev.y},deltaZ:function(){return this.rotation-this.preRotation},destroy:function(){this.sprite.parent&&this.sprite.parent instanceof e.Group&&this.sprite.parent.removeFromHash(this.sprite),this.sprite.body=null,this.sprite=null}},Object.defineProperty(e.Physics.Arcade.Body.prototype,"left",{get:function(){return this.position.x}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"right",{get:function(){return this.position.x+this.width}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"top",{get:function(){return this.position.y}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.position.y+this.height}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"x",{get:function(){return this.position.x},set:function(t){this.position.x=t}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"y",{get:function(){return this.position.y},set:function(t){this.position.y=t}}),e.Physics.Arcade.Body.render=function(t,e,i,s,n){void 0===s&&(s=!0),i=i||"rgba(0,255,0,0.4)",t.fillStyle=i,t.strokeStyle=i,t.lineWidth=n||1,e.isCircle?(t.beginPath(),t.arc(e.center.x-e.game.camera.x,e.center.y-e.game.camera.y,e.halfWidth,0,2*Math.PI),s?t.fill():t.stroke()):s?t.fillRect(e.position.x-e.game.camera.x,e.position.y-e.game.camera.y,e.width,e.height):t.strokeRect(e.position.x-e.game.camera.x,e.position.y-e.game.camera.y,e.width,e.height)},e.Physics.Arcade.Body.renderBodyInfo=function(t,e){t.line("x: "+e.x.toFixed(2),"y: "+e.y.toFixed(2),"width: "+e.width,"height: "+e.height),t.line("velocity x: "+e.velocity.x.toFixed(2),"y: "+e.velocity.y.toFixed(2),"deltaX: "+e._dx.toFixed(2),"deltaY: "+e._dy.toFixed(2)),t.line("acceleration x: "+e.acceleration.x.toFixed(2),"y: "+e.acceleration.y.toFixed(2),"speed: "+e.speed.toFixed(2),"angle: "+e.angle.toFixed(2)),t.line("gravity x: "+e.gravity.x,"y: "+e.gravity.y,"bounce x: "+e.bounce.x.toFixed(2),"y: "+e.bounce.y.toFixed(2)),t.line("touching left: "+e.touching.left,"right: "+e.touching.right,"up: "+e.touching.up,"down: "+e.touching.down),t.line("blocked left: "+e.blocked.left,"right: "+e.blocked.right,"up: "+e.blocked.up,"down: "+e.blocked.down)},e.Physics.Arcade.Body.prototype.constructor=e.Physics.Arcade.Body,e.Physics.Arcade.TilemapCollision=function(){},e.Physics.Arcade.TilemapCollision.prototype={TILE_BIAS:16,collideSpriteVsTilemapLayer:function(t,e,i,s,n,r){if(t.body){var o=e.getTiles(t.body.position.x-t.body.tilePadding.x-e.getTileOffsetX(),t.body.position.y-t.body.tilePadding.y-e.getTileOffsetY(),t.body.width+t.body.tilePadding.x,t.body.height+t.body.tilePadding.y,!1,!1);if(0!==o.length)for(var a=0;ae.deltaAbsY()?l=-1:e.deltaAbsX()0&&!t.blocked.right&&e.collideLeft&&t.checkCollision.right&&e.faceLeft&&t.right-n>e.left&&(s=t.right-n-e.left)>this.TILE_BIAS&&(s=0),0!==s&&(t.customSeparateX?t.overlapX=s:this.processTileSeparationX(t,s)),s},tileCheckY:function(t,e,i){var s=0,n=i.getTileOffsetY();return t.deltaY()<0&&!t.blocked.up&&e.collideDown&&t.checkCollision.up?e.faceBottom&&t.y-n0&&!t.blocked.down&&e.collideUp&&t.checkCollision.down&&e.faceTop&&t.bottom-n>e.top&&(s=t.bottom-n-e.top)>this.TILE_BIAS&&(s=0),0!==s&&(t.customSeparateY?t.overlapY=s:this.processTileSeparationY(t,s)),s},processTileSeparationX:function(t,e){e<0?(t.blocked.left=!0,t.blocked.none=!1):e>0&&(t.blocked.right=!0,t.blocked.none=!1),t.position.x-=e,0===t.bounce.x?t.velocity.x=0:t.velocity.x=-t.velocity.x*t.bounce.x},processTileSeparationY:function(t,e){e<0?(t.blocked.up=!0,t.blocked.none=!1):e>0&&(t.blocked.down=!0,t.blocked.none=!1),t.position.y-=e,0===t.bounce.y?t.velocity.y=0:t.velocity.y=-t.velocity.y*t.bounce.y}},e.Utils.mixinPrototype(e.Physics.Arcade.prototype,e.Physics.Arcade.TilemapCollision.prototype),p2.Body.prototype.parent=null,p2.Spring.prototype.parent=null,e.Physics.P2=function(t,i){this.game=t,void 0===i?i={gravity:[0,0],broadphase:new p2.SAPBroadphase}:(i.hasOwnProperty("gravity")||(i.gravity=[0,0]),i.hasOwnProperty("broadphase")||(i.broadphase=new p2.SAPBroadphase)),this.config=i,this.world=new p2.World(this.config),this.frameRate=1/60,this.useElapsedTime=!1,this.paused=!1,this.materials=[],this.gravity=new e.Physics.P2.InversePointProxy(this,this.world.gravity),this.walls={left:null,right:null,top:null,bottom:null},this.onBodyAdded=new e.Signal,this.onBodyRemoved=new e.Signal,this.onSpringAdded=new e.Signal,this.onSpringRemoved=new e.Signal,this.onConstraintAdded=new e.Signal,this.onConstraintRemoved=new e.Signal,this.onContactMaterialAdded=new e.Signal,this.onContactMaterialRemoved=new e.Signal,this.postBroadphaseCallback=null,this.callbackContext=null,this.onBeginContact=new e.Signal,this.onEndContact=new e.Signal,i.hasOwnProperty("mpx")&&i.hasOwnProperty("pxm")&&i.hasOwnProperty("mpxi")&&i.hasOwnProperty("pxmi")&&(this.mpx=i.mpx,this.mpxi=i.mpxi,this.pxm=i.pxm,this.pxmi=i.pxmi),this.world.on("beginContact",this.beginContactHandler,this),this.world.on("endContact",this.endContactHandler,this),this.collisionGroups=[],this.nothingCollisionGroup=new e.Physics.P2.CollisionGroup(1),this.boundsCollisionGroup=new e.Physics.P2.CollisionGroup(2),this.everythingCollisionGroup=new e.Physics.P2.CollisionGroup(2147483648),this.boundsCollidesWith=[],this._toRemove=[],this._collisionGroupID=2,this._boundsLeft=!0,this._boundsRight=!0,this._boundsTop=!0,this._boundsBottom=!0,this._boundsOwnGroup=!1,this.setBoundsToWorld(!0,!0,!0,!0,!1)},e.Physics.P2.prototype={removeBodyNextStep:function(t){this._toRemove.push(t)},preUpdate:function(){for(var t=this._toRemove.length;t--;)this.removeBody(this._toRemove[t]);this._toRemove.length=0},enable:function(t,i,s){void 0===i&&(i=!1),void 0===s&&(s=!0);var n=1;if(Array.isArray(t))for(n=t.length;n--;)t[n]instanceof e.Group?this.enable(t[n].children,i,s):(this.enableBody(t[n],i),s&&t[n].hasOwnProperty("children")&&t[n].children.length>0&&this.enable(t[n],i,!0));else t instanceof e.Group?this.enable(t.children,i,s):(this.enableBody(t,i),s&&t.hasOwnProperty("children")&&t.children.length>0&&this.enable(t.children,i,!0))},enableBody:function(t,i){t.hasOwnProperty("body")&&null===t.body&&(t.body=new e.Physics.P2.Body(this.game,t,t.x,t.y,1),t.body.debug=i,void 0!==t.anchor&&t.anchor.set(.5))},setImpactEvents:function(t){t?this.world.on("impact",this.impactHandler,this):this.world.off("impact",this.impactHandler,this)},setPostBroadphaseCallback:function(t,e){this.postBroadphaseCallback=t,this.callbackContext=e,null!==t?this.world.on("postBroadphase",this.postBroadphaseHandler,this):this.world.off("postBroadphase",this.postBroadphaseHandler,this)},postBroadphaseHandler:function(t){if(this.postBroadphaseCallback&&0!==t.pairs.length)for(var e=t.pairs.length-2;e>=0;e-=2)t.pairs[e].parent&&t.pairs[e+1].parent&&!this.postBroadphaseCallback.call(this.callbackContext,t.pairs[e].parent,t.pairs[e+1].parent)&&t.pairs.splice(e,2)},impactHandler:function(t){if(t.bodyA.parent&&t.bodyB.parent){var e=t.bodyA.parent,i=t.bodyB.parent;e._bodyCallbacks[t.bodyB.id]&&e._bodyCallbacks[t.bodyB.id].call(e._bodyCallbackContext[t.bodyB.id],e,i,t.shapeA,t.shapeB),i._bodyCallbacks[t.bodyA.id]&&i._bodyCallbacks[t.bodyA.id].call(i._bodyCallbackContext[t.bodyA.id],i,e,t.shapeB,t.shapeA),e._groupCallbacks[t.shapeB.collisionGroup]&&e._groupCallbacks[t.shapeB.collisionGroup].call(e._groupCallbackContext[t.shapeB.collisionGroup],e,i,t.shapeA,t.shapeB),i._groupCallbacks[t.shapeA.collisionGroup]&&i._groupCallbacks[t.shapeA.collisionGroup].call(i._groupCallbackContext[t.shapeA.collisionGroup],i,e,t.shapeB,t.shapeA)}},beginContactHandler:function(t){t.bodyA&&t.bodyB&&(this.onBeginContact.dispatch(t.bodyA,t.bodyB,t.shapeA,t.shapeB,t.contactEquations),t.bodyA.parent&&t.bodyA.parent.onBeginContact.dispatch(t.bodyB.parent,t.bodyB,t.shapeA,t.shapeB,t.contactEquations),t.bodyB.parent&&t.bodyB.parent.onBeginContact.dispatch(t.bodyA.parent,t.bodyA,t.shapeB,t.shapeA,t.contactEquations))},endContactHandler:function(t){t.bodyA&&t.bodyB&&(this.onEndContact.dispatch(t.bodyA,t.bodyB,t.shapeA,t.shapeB),t.bodyA.parent&&t.bodyA.parent.onEndContact.dispatch(t.bodyB.parent,t.bodyB,t.shapeA,t.shapeB),t.bodyB.parent&&t.bodyB.parent.onEndContact.dispatch(t.bodyA.parent,t.bodyA,t.shapeB,t.shapeA))},setBoundsToWorld:function(t,e,i,s,n){this.setBounds(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,t,e,i,s,n)},setWorldMaterial:function(t,e,i,s,n){void 0===e&&(e=!0),void 0===i&&(i=!0),void 0===s&&(s=!0),void 0===n&&(n=!0),e&&this.walls.left&&(this.walls.left.shapes[0].material=t),i&&this.walls.right&&(this.walls.right.shapes[0].material=t),s&&this.walls.top&&(this.walls.top.shapes[0].material=t),n&&this.walls.bottom&&(this.walls.bottom.shapes[0].material=t)},updateBoundsCollisionGroup:function(t){void 0===t&&(t=!0);var e=t?this.boundsCollisionGroup.mask:this.everythingCollisionGroup.mask;this.walls.left&&(this.walls.left.shapes[0].collisionGroup=e),this.walls.right&&(this.walls.right.shapes[0].collisionGroup=e),this.walls.top&&(this.walls.top.shapes[0].collisionGroup=e),this.walls.bottom&&(this.walls.bottom.shapes[0].collisionGroup=e),this._boundsOwnGroup=t},setBounds:function(t,e,i,s,n,r,o,a,h){void 0===n&&(n=this._boundsLeft),void 0===r&&(r=this._boundsRight),void 0===o&&(o=this._boundsTop),void 0===a&&(a=this._boundsBottom),void 0===h&&(h=this._boundsOwnGroup),this.setupWall(n,"left",t,e,1.5707963267948966,h),this.setupWall(r,"right",t+i,e,-1.5707963267948966,h),this.setupWall(o,"top",t,e,-3.141592653589793,h),this.setupWall(a,"bottom",t,e+s,0,h),this._boundsLeft=n,this._boundsRight=r,this._boundsTop=o,this._boundsBottom=a,this._boundsOwnGroup=h},setupWall:function(t,e,i,s,n,r){t?(this.walls[e]?this.walls[e].position=[this.pxmi(i),this.pxmi(s)]:(this.walls[e]=new p2.Body({mass:0,position:[this.pxmi(i),this.pxmi(s)],angle:n}),this.walls[e].addShape(new p2.Plane),this.world.addBody(this.walls[e])),r&&(this.walls[e].shapes[0].collisionGroup=this.boundsCollisionGroup.mask)):this.walls[e]&&(this.world.removeBody(this.walls[e]),this.walls[e]=null)},pause:function(){this.paused=!0},resume:function(){this.paused=!1},update:function(){this.paused||(this.useElapsedTime?this.world.step(this.game.time.physicsElapsed):this.world.step(this.frameRate))},reset:function(){this.world.on("beginContact",this.beginContactHandler,this),this.world.on("endContact",this.endContactHandler,this),this.nothingCollisionGroup=new e.Physics.P2.CollisionGroup(1),this.boundsCollisionGroup=new e.Physics.P2.CollisionGroup(2),this.everythingCollisionGroup=new e.Physics.P2.CollisionGroup(2147483648),this._collisionGroupID=2,this.setBoundsToWorld(!0,!0,!0,!0,!1)},clear:function(){this.world.time=0,this.world.fixedStepTime=0,this.world.solver&&this.world.solver.equations.length&&this.world.solver.removeAllEquations();for(var t=this.world.constraints,e=t.length-1;e>=0;e--)this.world.removeConstraint(t[e]);for(var i=this.world.bodies,e=i.length-1;e>=0;e--)this.world.removeBody(i[e]);for(var s=this.world.springs,e=s.length-1;e>=0;e--)this.world.removeSpring(s[e]);for(var n=this.world.contactMaterials,e=n.length-1;e>=0;e--)this.world.removeContactMaterial(n[e]);this.world.off("beginContact",this.beginContactHandler,this),this.world.off("endContact",this.endContactHandler,this),this.postBroadphaseCallback=null,this.callbackContext=null,this.impactCallback=null,this.collisionGroups=[],this._toRemove=[],this.boundsCollidesWith=[],this.walls={left:null,right:null,top:null,bottom:null}},destroy:function(){this.clear(),this.game=null},addBody:function(t){return!t.data.world&&(this.world.addBody(t.data),this.onBodyAdded.dispatch(t),!0)},removeBody:function(t){return t.data.world===this.world&&(this.world.removeBody(t.data),this.onBodyRemoved.dispatch(t)),t},addSpring:function(t){return t instanceof e.Physics.P2.Spring||t instanceof e.Physics.P2.RotationalSpring?this.world.addSpring(t.data):this.world.addSpring(t),this.onSpringAdded.dispatch(t),t},removeSpring:function(t){return t instanceof e.Physics.P2.Spring||t instanceof e.Physics.P2.RotationalSpring?this.world.removeSpring(t.data):this.world.removeSpring(t),this.onSpringRemoved.dispatch(t),t},createDistanceConstraint:function(t,i,s,n,r,o){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new e.Physics.P2.DistanceConstraint(this,t,i,s,n,r,o));console.warn("Cannot create Constraint, invalid body objects given")},createGearConstraint:function(t,i,s,n){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new e.Physics.P2.GearConstraint(this,t,i,s,n));console.warn("Cannot create Constraint, invalid body objects given")},createRevoluteConstraint:function(t,i,s,n,r,o){if(t=this.getBody(t),s=this.getBody(s),t&&s)return this.addConstraint(new e.Physics.P2.RevoluteConstraint(this,t,i,s,n,r,o));console.warn("Cannot create Constraint, invalid body objects given")},createLockConstraint:function(t,i,s,n,r){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new e.Physics.P2.LockConstraint(this,t,i,s,n,r));console.warn("Cannot create Constraint, invalid body objects given")},createPrismaticConstraint:function(t,i,s,n,r,o,a){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new e.Physics.P2.PrismaticConstraint(this,t,i,s,n,r,o,a));console.warn("Cannot create Constraint, invalid body objects given")},addConstraint:function(t){return this.world.addConstraint(t),this.onConstraintAdded.dispatch(t),t},removeConstraint:function(t){return this.world.removeConstraint(t),this.onConstraintRemoved.dispatch(t),t},addContactMaterial:function(t){return this.world.addContactMaterial(t),this.onContactMaterialAdded.dispatch(t),t},removeContactMaterial:function(t){return this.world.removeContactMaterial(t),this.onContactMaterialRemoved.dispatch(t),t},getContactMaterial:function(t,e){return this.world.getContactMaterial(t,e)},setMaterial:function(t,e){for(var i=e.length;i--;)e[i].setMaterial(t)},createMaterial:function(t,i){t=t||"";var s=new e.Physics.P2.Material(t);return this.materials.push(s),void 0!==i&&i.setMaterial(s),s},createContactMaterial:function(t,i,s){void 0===t&&(t=this.createMaterial()),void 0===i&&(i=this.createMaterial());var n=new e.Physics.P2.ContactMaterial(t,i,s);return this.addContactMaterial(n)},getBodies:function(){for(var t=[],e=this.world.bodies.length;e--;)t.push(this.world.bodies[e].parent);return t},getBody:function(t){return t instanceof p2.Body?t:t instanceof e.Physics.P2.Body?t.data:t.body&&t.body.type===e.Physics.P2JS?t.body.data:null},getSprings:function(){for(var t=[],e=this.world.springs.length;e--;)t.push(this.world.springs[e].parent);return t},getConstraints:function(){for(var t=[],e=this.world.constraints.length;e--;)t.push(this.world.constraints[e]);return t},hitTest:function(t,i,s,n){void 0===i&&(i=this.world.bodies),void 0===s&&(s=5),void 0===n&&(n=!1);for(var r=[this.pxmi(t.x),this.pxmi(t.y)],o=[],a=i.length;a--;)i[a]instanceof e.Physics.P2.Body&&(!n||i[a].data.type!==p2.Body.STATIC)?o.push(i[a].data):i[a]instanceof p2.Body&&i[a].parent&&(!n||i[a].type!==p2.Body.STATIC)?o.push(i[a]):i[a]instanceof e.Sprite&&i[a].hasOwnProperty("body")&&(!n||i[a].body.data.type!==p2.Body.STATIC)&&o.push(i[a].body.data);return this.world.hitTest(r,o,s)},toJSON:function(){return this.world.toJSON()},createCollisionGroup:function(t){var i=Math.pow(2,this._collisionGroupID);this.walls.left&&(this.walls.left.shapes[0].collisionMask=this.walls.left.shapes[0].collisionMask|i),this.walls.right&&(this.walls.right.shapes[0].collisionMask=this.walls.right.shapes[0].collisionMask|i),this.walls.top&&(this.walls.top.shapes[0].collisionMask=this.walls.top.shapes[0].collisionMask|i),this.walls.bottom&&(this.walls.bottom.shapes[0].collisionMask=this.walls.bottom.shapes[0].collisionMask|i),this._collisionGroupID++;var s=new e.Physics.P2.CollisionGroup(i);return this.collisionGroups.push(s),t&&this.setCollisionGroup(t,s),s},setCollisionGroup:function(t,i){if(t instanceof e.Group)for(var s=0;s-1&&u.collides)if(s){var d=t.getTileRight(e,l,a);0===n&&(r=u.x*u.width,o=u.y*u.height,n=u.width),d&&d.collides?n+=u.width:((p=this.createBody(r,o,0,!1)).addRectangle(n,u.height,n/2,u.height/2,0),i&&this.addBody(p),t.layers[e].bodies.push(p),n=0)}else{var p=this.createBody(u.x*u.width,u.y*u.height,0,!1);p.addRectangle(u.width,u.height,u.width/2,u.height/2,0),i&&this.addBody(p),t.layers[e].bodies.push(p)}}}return t.layers[e].bodies},mpx:function(t){return t*=20},pxm:function(t){return.05*t},mpxi:function(t){return t*=-20},pxmi:function(t){return-.05*t}},Object.defineProperty(e.Physics.P2.prototype,"friction",{get:function(){return this.world.defaultContactMaterial.friction},set:function(t){this.world.defaultContactMaterial.friction=t}}),Object.defineProperty(e.Physics.P2.prototype,"restitution",{get:function(){return this.world.defaultContactMaterial.restitution},set:function(t){this.world.defaultContactMaterial.restitution=t}}),Object.defineProperty(e.Physics.P2.prototype,"contactMaterial",{get:function(){return this.world.defaultContactMaterial},set:function(t){this.world.defaultContactMaterial=t}}),Object.defineProperty(e.Physics.P2.prototype,"applySpringForces",{get:function(){return this.world.applySpringForces},set:function(t){this.world.applySpringForces=t}}),Object.defineProperty(e.Physics.P2.prototype,"applyDamping",{get:function(){return this.world.applyDamping},set:function(t){this.world.applyDamping=t}}),Object.defineProperty(e.Physics.P2.prototype,"applyGravity",{get:function(){return this.world.applyGravity},set:function(t){this.world.applyGravity=t}}),Object.defineProperty(e.Physics.P2.prototype,"solveConstraints",{get:function(){return this.world.solveConstraints},set:function(t){this.world.solveConstraints=t}}),Object.defineProperty(e.Physics.P2.prototype,"time",{get:function(){return this.world.time}}),Object.defineProperty(e.Physics.P2.prototype,"emitImpactEvent",{get:function(){return this.world.emitImpactEvent},set:function(t){this.world.emitImpactEvent=t}}),Object.defineProperty(e.Physics.P2.prototype,"sleepMode",{get:function(){return this.world.sleepMode},set:function(t){this.world.sleepMode=t}}),Object.defineProperty(e.Physics.P2.prototype,"total",{get:function(){return this.world.bodies.length}}),e.Physics.P2.FixtureList=function(t){Array.isArray(t)||(t=[t]),this.rawList=t,this.init(),this.parse(this.rawList)},e.Physics.P2.FixtureList.prototype={init:function(){this.namedFixtures={},this.groupedFixtures=[],this.allFixtures=[]},setCategory:function(t,e){this.getFixtures(e).forEach(function(e){e.collisionGroup=t})},setMask:function(t,e){this.getFixtures(e).forEach(function(e){e.collisionMask=t})},setSensor:function(t,e){this.getFixtures(e).forEach(function(e){e.sensor=t})},setMaterial:function(t,e){this.getFixtures(e).forEach(function(e){e.material=t})},getFixtures:function(t){var e=[];if(t){t instanceof Array||(t=[t]);var i=this;return t.forEach(function(t){i.namedFixtures[t]&&e.push(i.namedFixtures[t])}),this.flatten(e)}return this.allFixtures},getFixtureByKey:function(t){return this.namedFixtures[t]},getGroup:function(t){return this.groupedFixtures[t]},parse:function(){var t,e,i,s;i=this.rawList,s=[];for(t in i)e=i[t],isNaN(t-0)?this.namedFixtures[t]=this.flatten(e):(this.groupedFixtures[t]=this.groupedFixtures[t]||[],this.groupedFixtures[t]=this.groupedFixtures[t].concat(e)),s.push(this.allFixtures=this.flatten(this.groupedFixtures))},flatten:function(t){var e,i;return e=[],i=arguments.callee,t.forEach(function(t){return Array.prototype.push.apply(e,Array.isArray(t)?i(t):[t])}),e}},e.Physics.P2.PointProxy=function(t,e){this.world=t,this.destination=e},e.Physics.P2.PointProxy.prototype.constructor=e.Physics.P2.PointProxy,Object.defineProperty(e.Physics.P2.PointProxy.prototype,"x",{get:function(){return this.world.mpx(this.destination[0])},set:function(t){this.destination[0]=this.world.pxm(t)}}),Object.defineProperty(e.Physics.P2.PointProxy.prototype,"y",{get:function(){return this.world.mpx(this.destination[1])},set:function(t){this.destination[1]=this.world.pxm(t)}}),Object.defineProperty(e.Physics.P2.PointProxy.prototype,"mx",{get:function(){return this.destination[0]},set:function(t){this.destination[0]=t}}),Object.defineProperty(e.Physics.P2.PointProxy.prototype,"my",{get:function(){return this.destination[1]},set:function(t){this.destination[1]=t}}),e.Physics.P2.InversePointProxy=function(t,e){this.world=t,this.destination=e},e.Physics.P2.InversePointProxy.prototype.constructor=e.Physics.P2.InversePointProxy,Object.defineProperty(e.Physics.P2.InversePointProxy.prototype,"x",{get:function(){return this.world.mpxi(this.destination[0])},set:function(t){this.destination[0]=this.world.pxmi(t)}}),Object.defineProperty(e.Physics.P2.InversePointProxy.prototype,"y",{get:function(){return this.world.mpxi(this.destination[1])},set:function(t){this.destination[1]=this.world.pxmi(t)}}),Object.defineProperty(e.Physics.P2.InversePointProxy.prototype,"mx",{get:function(){return this.destination[0]},set:function(t){this.destination[0]=-t}}),Object.defineProperty(e.Physics.P2.InversePointProxy.prototype,"my",{get:function(){return this.destination[1]},set:function(t){this.destination[1]=-t}}),e.Physics.P2.Body=function(t,i,s,n,r){i=i||null,s=s||0,n=n||0,void 0===r&&(r=1),this.game=t,this.world=t.physics.p2,this.sprite=i,this.type=e.Physics.P2JS,this.offset=new e.Point,this.data=new p2.Body({position:[this.world.pxmi(s),this.world.pxmi(n)],mass:r}),this.data.parent=this,this.velocity=new e.Physics.P2.InversePointProxy(this.world,this.data.velocity),this.force=new e.Physics.P2.InversePointProxy(this.world,this.data.force),this.gravity=new e.Point,this.onBeginContact=new e.Signal,this.onEndContact=new e.Signal,this.collidesWith=[],this.removeNextStep=!1,this.debugBody=null,this.dirty=!1,this._collideWorldBounds=!0,this._bodyCallbacks={},this._bodyCallbackContext={},this._groupCallbacks={},this._groupCallbackContext={},this._reset=!1,i&&(this.setRectangleFromSprite(i),i.exists&&this.game.physics.p2.addBody(this))},e.Physics.P2.Body.prototype={createBodyCallback:function(t,e,i){var s=-1;t.id?s=t.id:t.body&&(s=t.body.id),s>-1&&(null===e?(delete this._bodyCallbacks[s],delete this._bodyCallbackContext[s]):(this._bodyCallbacks[s]=e,this._bodyCallbackContext[s]=i))},createGroupCallback:function(t,e,i){null===e?(delete this._groupCallbacks[t.mask],delete this._groupCallbackContext[t.mask]):(this._groupCallbacks[t.mask]=e,this._groupCallbackContext[t.mask]=i)},getCollisionMask:function(){var t=0;this._collideWorldBounds&&(t=this.game.physics.p2.boundsCollisionGroup.mask);for(var e=0;e=0;i--)this.data.shapes[i].collisionMask=e;else t.collisionMask=e},setCollisionGroup:function(t,e){var i=this.getCollisionMask();if(void 0===e)for(var s=this.data.shapes.length-1;s>=0;s--)this.data.shapes[s].collisionGroup=t.mask,this.data.shapes[s].collisionMask=i;else e.collisionGroup=t.mask,e.collisionMask=i},clearCollision:function(t,e,i){if(void 0===t&&(t=!0),void 0===e&&(e=!0),void 0===i)for(var s=this.data.shapes.length-1;s>=0;s--)t&&(this.data.shapes[s].collisionGroup=null),e&&(this.data.shapes[s].collisionMask=null);else t&&(i.collisionGroup=null),e&&(i.collisionMask=null);t&&(this.collidesWith.length=0)},removeCollisionGroup:function(t,e,i){void 0===e&&(e=!0);var s;if(Array.isArray(t))for(r=0;r-1&&(this.collidesWith.splice(s,1),e&&(delete this._groupCallbacks[t.mask],delete this._groupCallbackContext[t.mask]));else(s=this.collidesWith.indexOf(t))>-1&&(this.collidesWith.splice(s,1),e&&(delete this._groupCallbacks[t.mask],delete this._groupCallbackContext[t.mask]));var n=this.getCollisionMask();if(void 0===i)for(var r=this.data.shapes.length-1;r>=0;r--)this.data.shapes[r].collisionMask=n;else i.collisionMask=n},collides:function(t,e,i,s){if(Array.isArray(t))for(r=0;r=0;r--)this.data.shapes[r].collisionMask=n;else s.collisionMask=n},adjustCenterOfMass:function(){this.data.adjustCenterOfMass(),this.shapeChanged()},getVelocityAtPoint:function(t,e){return this.data.getVelocityAtPoint(t,e)},applyDamping:function(t){this.data.applyDamping(t)},applyImpulse:function(t,e,i){this.data.applyImpulse(t,[this.world.pxmi(e),this.world.pxmi(i)])},applyImpulseLocal:function(t,e,i){this.data.applyImpulseLocal(t,[this.world.pxmi(e),this.world.pxmi(i)])},applyForce:function(t,e,i){this.data.applyForce(t,[this.world.pxmi(e),this.world.pxmi(i)])},setZeroForce:function(){this.data.setZeroForce()},setZeroRotation:function(){this.data.angularVelocity=0},setZeroVelocity:function(){this.data.velocity[0]=0,this.data.velocity[1]=0},setZeroDamping:function(){this.data.damping=0,this.data.angularDamping=0},toLocalFrame:function(t,e){return this.data.toLocalFrame(t,e)},toWorldFrame:function(t,e){return this.data.toWorldFrame(t,e)},rotateLeft:function(t){this.data.angularVelocity=this.world.pxm(-t)},rotateRight:function(t){this.data.angularVelocity=this.world.pxm(t)},moveForward:function(t){var e=this.world.pxmi(-t),i=this.data.angle+Math.PI/2;this.data.velocity[0]=e*Math.cos(i),this.data.velocity[1]=e*Math.sin(i)},moveBackward:function(t){var e=this.world.pxmi(-t),i=this.data.angle+Math.PI/2;this.data.velocity[0]=-e*Math.cos(i),this.data.velocity[1]=-e*Math.sin(i)},thrust:function(t){var e=this.world.pxmi(-t),i=this.data.angle+Math.PI/2;this.data.force[0]+=e*Math.cos(i),this.data.force[1]+=e*Math.sin(i)},thrustLeft:function(t){var e=this.world.pxmi(-t),i=this.data.angle;this.data.force[0]+=e*Math.cos(i),this.data.force[1]+=e*Math.sin(i)},thrustRight:function(t){var e=this.world.pxmi(-t),i=this.data.angle;this.data.force[0]-=e*Math.cos(i),this.data.force[1]-=e*Math.sin(i)},reverse:function(t){var e=this.world.pxmi(-t),i=this.data.angle+Math.PI/2;this.data.force[0]-=e*Math.cos(i),this.data.force[1]-=e*Math.sin(i)},moveLeft:function(t){this.data.velocity[0]=this.world.pxmi(-t)},moveRight:function(t){this.data.velocity[0]=this.world.pxmi(t)},moveUp:function(t){this.data.velocity[1]=this.world.pxmi(-t)},moveDown:function(t){this.data.velocity[1]=this.world.pxmi(t)},preUpdate:function(){this.dirty=!0,this.removeNextStep&&(this.removeFromWorld(),this.removeNextStep=!1)},postUpdate:function(){this.sprite.x=this.world.mpxi(this.data.position[0])+this.offset.x,this.sprite.y=this.world.mpxi(this.data.position[1])+this.offset.y,this.fixedRotation||(this.sprite.rotation=this.data.angle),this.debugBody&&this.debugBody.updateSpriteTransform(),this.dirty=!1},reset:function(t,e,i,s){void 0===i&&(i=!1),void 0===s&&(s=!1),this.setZeroForce(),this.setZeroVelocity(),this.setZeroRotation(),i&&this.setZeroDamping(),s&&(this.mass=1),this.x=t,this.y=e},addToWorld:function(){if(this.game.physics.p2._toRemove)for(var t=0;t=0;i--)this.data.shapes[i].material=t;else e.material=t},shapeChanged:function(){this.debugBody&&this.debugBody.draw()},addPhaserPolygon:function(t,e){for(var i=this.game.cache.getPhysicsData(t,e),s=[],n=0;n=0?dp;n=p>=0?++d:--d)l=e.vertices[n],p2.vec2.rotate(u,l,t),c.push([(u[0]+a[0])*this.ppu,-(u[1]+a[1])*this.ppu]);this.drawConvex(h,c,e.triangles,16711680,i,r,this.settings.debugPolygons,[a[0]*this.ppu,-a[1]*this.ppu])}s++}}},drawRectangle:function(t,e,i,s,n,r,o,a,h){void 0===h&&(h=1),void 0===o&&(o=0),t.lineStyle(h,o,1),t.beginFill(a),t.drawRect(e-n/2,i-r/2,n,r)},drawCircle:function(t,e,i,s,n,r,o){void 0===o&&(o=1),void 0===r&&(r=16777215),t.lineStyle(o,0,1),t.beginFill(r,1),t.drawCircle(e,i,2*-n),t.endFill(),t.moveTo(e,i),t.lineTo(e+n*Math.cos(-s),i+n*Math.sin(-s))},drawLine:function(t,e,i,s){void 0===s&&(s=1),void 0===i&&(i=0),t.lineStyle(5*s,i,1),t.moveTo(-e/2,0),t.lineTo(e/2,0)},drawConvex:function(t,e,i,s,n,r,o,a){var h,l,c,u,d,p,f,g,m,y,v;if(void 0===r&&(r=1),void 0===s&&(s=0),o){for(h=[16711680,65280,255],l=0;l!==e.length+1;)u=e[l%e.length],d=e[(l+1)%e.length],f=u[0],y=u[1],g=d[0],v=d[1],t.lineStyle(r,h[l%h.length],1),t.moveTo(f,-y),t.lineTo(g,-v),t.drawCircle(f,-y,2*r),l++;return t.lineStyle(r,0,1),t.drawCircle(a[0],a[1],2*r)}for(t.lineStyle(r,s,1),t.beginFill(n),l=0;l!==e.length;)p=(c=e[l])[0],m=c[1],0===l?t.moveTo(p,-m):t.lineTo(p,-m),l++;if(t.endFill(),e.length>2)return t.moveTo(e[e.length-1][0],-e[e.length-1][1]),t.lineTo(e[0][0],-e[0][1])},drawPath:function(t,e,i,s,n){var r,o,a,h,l,c,u,d,p,f,g;for(void 0===n&&(n=1),void 0===i&&(i=0),t.lineStyle(n,i,1),"number"==typeof s&&t.beginFill(s),o=null,a=null,r=0;r2&&"number"==typeof s&&(t.moveTo(e[e.length-1][0],e[e.length-1][1]),t.lineTo(e[0][0],e[0][1]))},drawPlane:function(t,e,i,s,n,r,o,a,h,l){var c,u;void 0===r&&(r=1),void 0===s&&(s=16777215),t.lineStyle(r,n,11),t.beginFill(s),t.moveTo(e,-i),c=e+Math.cos(l)*this.game.width,u=i+Math.sin(l)*this.game.height,t.lineTo(c,-u),t.moveTo(e,-i),c=e+Math.cos(l)*-this.game.width,u=i+Math.sin(l)*-this.game.height,t.lineTo(c,-u)},drawCapsule:function(t,e,i,s,n,r,o,a,h){void 0===h&&(h=1),void 0===o&&(o=0),t.lineStyle(h,o,1);var l=Math.cos(s),c=Math.sin(s);t.beginFill(a,1),t.drawCircle(-n/2*l+e,-n/2*c+i,2*-r),t.drawCircle(n/2*l+e,n/2*c+i,2*-r),t.endFill(),t.lineStyle(h,o,0),t.beginFill(a,1),t.moveTo(-n/2*l+r*c+e,-n/2*c+r*l+i),t.lineTo(n/2*l+r*c+e,n/2*c+r*l+i),t.lineTo(n/2*l-r*c+e,n/2*c-r*l+i),t.lineTo(-n/2*l-r*c+e,-n/2*c-r*l+i),t.endFill(),t.lineStyle(h,o,1),t.moveTo(-n/2*l+r*c+e,-n/2*c+r*l+i),t.lineTo(n/2*l+r*c+e,n/2*c+r*l+i),t.moveTo(-n/2*l-r*c+e,-n/2*c-r*l+i),t.lineTo(n/2*l-r*c+e,n/2*c-r*l+i)},randomPastelHex:function(){var t,e,i,s;return i=[255,255,255],s=Math.floor(256*Math.random()),e=Math.floor(256*Math.random()),t=Math.floor(256*Math.random()),s=Math.floor((s+3*i[0])/4),e=Math.floor((e+3*i[1])/4),t=Math.floor((t+3*i[2])/4),this.rgbToHex(s,e,t)},rgbToHex:function(t,e,i){return this.componentToHex(t)+this.componentToHex(e)+this.componentToHex(i)},componentToHex:function(t){var e;return 2===(e=t.toString(16)).length?e:e+"0"}}),e.Physics.P2.Spring=function(t,e,i,s,n,r,o,a,h,l){this.game=t.game,this.world=t,void 0===s&&(s=1),void 0===n&&(n=100),void 0===r&&(r=1);var c={restLength:s=t.pxm(s),stiffness:n,damping:r};void 0!==o&&null!==o&&(c.worldAnchorA=[t.pxm(o[0]),t.pxm(o[1])]),void 0!==a&&null!==a&&(c.worldAnchorB=[t.pxm(a[0]),t.pxm(a[1])]),void 0!==h&&null!==h&&(c.localAnchorA=[t.pxm(h[0]),t.pxm(h[1])]),void 0!==l&&null!==l&&(c.localAnchorB=[t.pxm(l[0]),t.pxm(l[1])]),this.data=new p2.LinearSpring(e,i,c),this.data.parent=this},e.Physics.P2.Spring.prototype.constructor=e.Physics.P2.Spring,e.Physics.P2.RotationalSpring=function(t,e,i,s,n,r){this.game=t.game,this.world=t,void 0===s&&(s=null),void 0===n&&(n=100),void 0===r&&(r=1),s&&(s=t.pxm(s));var o={restAngle:s,stiffness:n,damping:r};this.data=new p2.RotationalSpring(e,i,o),this.data.parent=this},e.Physics.P2.Spring.prototype.constructor=e.Physics.P2.Spring,e.Physics.P2.Material=function(t){this.name=t,p2.Material.call(this)},e.Physics.P2.Material.prototype=Object.create(p2.Material.prototype),e.Physics.P2.Material.prototype.constructor=e.Physics.P2.Material,e.Physics.P2.ContactMaterial=function(t,e,i){p2.ContactMaterial.call(this,t,e,i)},e.Physics.P2.ContactMaterial.prototype=Object.create(p2.ContactMaterial.prototype),e.Physics.P2.ContactMaterial.prototype.constructor=e.Physics.P2.ContactMaterial,e.Physics.P2.CollisionGroup=function(t){this.mask=t},e.Physics.P2.DistanceConstraint=function(t,e,i,s,n,r,o){void 0===s&&(s=100),void 0===n&&(n=[0,0]),void 0===r&&(r=[0,0]),void 0===o&&(o=Number.MAX_VALUE),this.game=t.game,this.world=t;var a={distance:s=t.pxm(s),localAnchorA:n=[t.pxmi(n[0]),t.pxmi(n[1])],localAnchorB:r=[t.pxmi(r[0]),t.pxmi(r[1])],maxForce:o};p2.DistanceConstraint.call(this,e,i,a)},e.Physics.P2.DistanceConstraint.prototype=Object.create(p2.DistanceConstraint.prototype),e.Physics.P2.DistanceConstraint.prototype.constructor=e.Physics.P2.DistanceConstraint,e.Physics.P2.GearConstraint=function(t,e,i,s,n){void 0===s&&(s=0),void 0===n&&(n=1),this.game=t.game,this.world=t;var r={angle:s,ratio:n};p2.GearConstraint.call(this,e,i,r)},e.Physics.P2.GearConstraint.prototype=Object.create(p2.GearConstraint.prototype),e.Physics.P2.GearConstraint.prototype.constructor=e.Physics.P2.GearConstraint,e.Physics.P2.LockConstraint=function(t,e,i,s,n,r){void 0===s&&(s=[0,0]),void 0===n&&(n=0),void 0===r&&(r=Number.MAX_VALUE),this.game=t.game,this.world=t;var o={localOffsetB:s=[t.pxm(s[0]),t.pxm(s[1])],localAngleB:n,maxForce:r};p2.LockConstraint.call(this,e,i,o)},e.Physics.P2.LockConstraint.prototype=Object.create(p2.LockConstraint.prototype),e.Physics.P2.LockConstraint.prototype.constructor=e.Physics.P2.LockConstraint,e.Physics.P2.PrismaticConstraint=function(t,e,i,s,n,r,o,a){void 0===s&&(s=!0),void 0===n&&(n=[0,0]),void 0===r&&(r=[0,0]),void 0===o&&(o=[0,0]),void 0===a&&(a=Number.MAX_VALUE),this.game=t.game,this.world=t;var h={localAnchorA:n=[t.pxmi(n[0]),t.pxmi(n[1])],localAnchorB:r=[t.pxmi(r[0]),t.pxmi(r[1])],localAxisA:o,maxForce:a,disableRotationalLock:!s};p2.PrismaticConstraint.call(this,e,i,h)},e.Physics.P2.PrismaticConstraint.prototype=Object.create(p2.PrismaticConstraint.prototype),e.Physics.P2.PrismaticConstraint.prototype.constructor=e.Physics.P2.PrismaticConstraint,e.Physics.P2.RevoluteConstraint=function(t,e,i,s,n,r,o){void 0===r&&(r=Number.MAX_VALUE),void 0===o&&(o=null),this.game=t.game,this.world=t,i=[t.pxmi(i[0]),t.pxmi(i[1])],n=[t.pxmi(n[0]),t.pxmi(n[1])],o&&(o=[t.pxmi(o[0]),t.pxmi(o[1])]);var a={worldPivot:o,localPivotA:i,localPivotB:n,maxForce:r};p2.RevoluteConstraint.call(this,e,s,a)},e.Physics.P2.RevoluteConstraint.prototype=Object.create(p2.RevoluteConstraint.prototype),e.Physics.P2.RevoluteConstraint.prototype.constructor=e.Physics.P2.RevoluteConstraint,e.ImageCollection=function(t,e,i,s,n,r,o){(void 0===i||i<=0)&&(i=32),(void 0===s||s<=0)&&(s=32),void 0===n&&(n=0),void 0===r&&(r=0),this.name=t,this.firstgid=0|e,this.imageWidth=0|i,this.imageHeight=0|s,this.imageMargin=0|n,this.imageSpacing=0|r,this.properties=o||{},this.images=[],this.total=0},e.ImageCollection.prototype={containsImageIndex:function(t){return t>=this.firstgid&&tthis.right||e>this.bottom)},intersects:function(t,e,i,s){return!(i<=this.worldX)&&(!(s<=this.worldY)&&(!(t>=this.worldX+this.width)&&!(e>=this.worldY+this.height)))},setCollisionCallback:function(t,e){this.collisionCallback=t,this.collisionCallbackContext=e},destroy:function(){this.collisionCallback=null,this.collisionCallbackContext=null,this.properties=null},setCollision:function(t,e,i,s){this.collideLeft=t,this.collideRight=e,this.collideUp=i,this.collideDown=s,this.faceLeft=t,this.faceRight=e,this.faceTop=i,this.faceBottom=s},resetCollision:function(){this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1},isInteresting:function(t,e){return t&&e?this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.faceTop||this.faceBottom||this.faceLeft||this.faceRight||this.collisionCallback:t?this.collideLeft||this.collideRight||this.collideUp||this.collideDown:!!e&&(this.faceTop||this.faceBottom||this.faceLeft||this.faceRight)},copy:function(t){this.index=t.index,this.alpha=t.alpha,this.properties=t.properties,this.collideUp=t.collideUp,this.collideDown=t.collideDown,this.collideLeft=t.collideLeft,this.collideRight=t.collideRight,this.collisionCallback=t.collisionCallback,this.collisionCallbackContext=t.collisionCallbackContext}},e.Tile.prototype.constructor=e.Tile,Object.defineProperty(e.Tile.prototype,"collides",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}}),Object.defineProperty(e.Tile.prototype,"canCollide",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}}),Object.defineProperty(e.Tile.prototype,"left",{get:function(){return this.worldX}}),Object.defineProperty(e.Tile.prototype,"right",{get:function(){return this.worldX+this.width}}),Object.defineProperty(e.Tile.prototype,"top",{get:function(){return this.worldY}}),Object.defineProperty(e.Tile.prototype,"bottom",{get:function(){return this.worldY+this.height}}),e.Tilemap=function(t,i,s,n,r,o){this.game=t,this.key=i;var a=e.TilemapParser.parse(this.game,i,s,n,r,o);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._tempA=0,this._tempB=0)},e.Tilemap.CSV=0,e.Tilemap.TILED_JSON=1,e.Tilemap.NORTH=0,e.Tilemap.EAST=1,e.Tilemap.SOUTH=2,e.Tilemap.WEST=3,e.Tilemap.prototype={create:function(t,e,i,s,n,r){return void 0===r&&(r=this.game.world),this.width=e,this.height=i,this.setTileSize(s,n),this.layers.length=0,this.createBlankLayer(t,e,i,s,n,r)},setTileSize:function(t,e){this.tileWidth=t,this.tileHeight=e,this.widthInPixels=this.width*t,this.heightInPixels=this.height*e},addTilesetImage:function(t,i,s,n,r,o,a){if(void 0===t)return null;void 0===s&&(s=this.tileWidth),void 0===n&&(n=this.tileHeight),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=0),0===s&&(s=32),0===n&&(n=32);var h=null;if(void 0!==i&&null!==i||(i=t),i instanceof e.BitmapData)h=i.canvas;else{if(!this.game.cache.checkImageKey(i))return console.warn('Phaser.Tilemap.addTilesetImage: Invalid image key given: "'+i+'"'),null;h=this.game.cache.getImage(i)}var l=this.getTilesetIndex(t);if(null===l&&this.format===e.Tilemap.TILED_JSON)return console.warn('Phaser.Tilemap.addTilesetImage: No data found in the JSON matching the tileset name: "'+t+'"'),console.log("Tilesets: ",this.tilesets),null;if(this.tilesets[l])return this.tilesets[l].setImage(h),this.tilesets[l];var c=new e.Tileset(t,a,s,n,r,o,{});c.setImage(h),this.tilesets.push(c);for(var u=this.tilesets.length-1,d=r,p=r,f=0,g=0,m=0,y=a;y1)for(u=0;uthis.layers.length)return console.warn('Tilemap.createLayer: Invalid layer ID given: "'+t+'"'),void console.log("Layers: ",this.layers);void 0===i||i<=0?i=Math.min(this.game.width,this.layers[r].widthInPixels):i>this.game.width&&(i=this.game.width),void 0===s||s<=0?s=Math.min(this.game.height,this.layers[r].heightInPixels):s>this.game.height&&(s=this.game.height),this.enableDebug&&(console.group("Tilemap.createLayer"),console.log("Name:",this.layers[r].name),console.log("Size:",i,"x",s),console.log("Tileset:",this.tilesets[0].name,"index:",r));var o=n.add(new e.TilemapLayer(this.game,this,r,i,s));return this.enableDebug&&console.groupEnd(),o},createBlankLayer:function(t,i,s,n,r,o){void 0===o&&(o=this.game.world);{if(null===this.getLayerIndex(t)){for(var a,h={name:t,x:0,y:0,width:i,height:s,widthInPixels:i*n,heightInPixels:s*r,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:null},l=[],c=0;cthis.game.width&&(d=this.game.width),p>this.game.height&&(p=this.game.height),(l=new e.TilemapLayer(this.game,this,this.layers.length-1,d,p)).name=t,o.add(l)}console.warn("Tilemap.createBlankLayer: Layer with matching name already exists: "+t)}},getIndex:function(t,e){for(var i=0;ie)){for(var r=t;r<=e;r++)this.setCollisionByIndex(r,i,s,!1);n&&this.calculateFaces(s)}},setCollisionByExclusion:function(t,e,i,s){void 0===e&&(e=!0),void 0===s&&(s=!0),i=this.getLayer(i);for(var n=0,r=this.tiles.length;n-1&&this.collideIndexes.splice(n,1)}for(var r=0;r0?this.layers[t].data[i-1][e]:null},getTileBelow:function(t,e,i){return i0?this.layers[t].data[i][e-1]:null},getTileRight:function(t,e,i){return e-1},removeTile:function(t,i,s){if(s=this.getLayer(s),t>=0&&t=0&&i=0&&i=0&&s-1?this.layers[n].data[s][i].setCollision(!0,!0,!0,!0):this.layers[n].data[s][i].resetCollision(),this.layers[n].dirty=!0,this.calculateFaces(n),this.layers[n].data[s][i]}return null},putTileWorldXY:function(t,e,i,s,n,r){return r=this.getLayer(r),e=this.game.math.snapToFloor(e,s)/s,i=this.game.math.snapToFloor(i,n)/n,this.putTile(t,e,i,r)},searchTileIndex:function(t,e,i,s){void 0===e&&(e=0),void 0===i&&(i=!1),s=this.getLayer(s);var n=0;if(i){for(r=this.layers[s].height-1;r>=0;r--)for(o=this.layers[s].width-1;o>=0;o--)if(this.layers[s].data[r][o].index===t){if(n===e)return this.layers[s].data[r][o];n++}}else for(var r=0;r=0&&t=0&&ethis.layers[n].width&&(i=this.layers[n].width),s>this.layers[n].height&&(s=this.layers[n].height),this._results.length=0,this._results.push({x:t,y:e,width:i,height:s,layer:n});for(var r=e;r1?this.debugMap[this.layers[this.currentLayer].data[i][s]]?e.push("background: "+this.debugMap[this.layers[this.currentLayer].data[i][s]]):e.push("background: #ffffff"):e.push("background: rgb(0, 0, 0)");t+="\n"}e[0]=t,console.log.apply(console,e)},destroy:function(){this.removeAllLayers(),this.data=[],this.game=null}},e.Tilemap.prototype.constructor=e.Tilemap,Object.defineProperty(e.Tilemap.prototype,"layer",{get:function(){return this.layers[this.currentLayer]},set:function(t){t!==this.currentLayer&&this.setLayer(t)}}),e.TilemapLayer=function(t,i,s,n,r){n|=0,r|=0,e.Sprite.call(this,t,0,0),this.map=i,this.index=s,this.layer=i.layers[s],this.canvas=e.CanvasPool.create(this,n,r),this.context=this.canvas.getContext("2d"),this.setTexture(new PIXI.Texture(new PIXI.BaseTexture(this.canvas,null,this.game.resolution))),this.type=e.TILEMAPLAYER,this.physicsType=e.TILEMAPLAYER,this.renderSettings={enableScrollDelta:!0,overdrawRatio:.2,copyCanvas:null},this.debug=!1,this.exists=!0,this.debugSettings={missingImageFill:"rgb(255,255,255)",debuggedTileOverfill:"rgba(0,255,0,0.4)",forceFullRedraw:!0,debugAlpha:.5,facingEdgeStroke:"rgba(0,255,0,1)",collidingTileOverfill:"rgba(0,255,0,0.2)"},this.scrollFactorX=1,this.scrollFactorY=1,this.dirty=!0,this.rayStepRate=4,this._wrap=!1,this._mc={scrollX:0,scrollY:0,renderWidth:0,renderHeight:0,tileWidth:i.tileWidth,tileHeight:i.tileHeight,cw:i.tileWidth,ch:i.tileHeight,tilesets:[]},this._scrollX=0,this._scrollY=0,this.tileOffset=new e.Point(this.layer.offsetX||0,this.layer.offsetY||0),this._results=[],t.device.canvasBitBltShift||(this.renderSettings.copyCanvas=e.TilemapLayer.ensureSharedCopyCanvas()),this.fixedToCamera=!0},e.TilemapLayer.prototype=Object.create(e.Sprite.prototype),e.TilemapLayer.prototype.constructor=e.TilemapLayer,e.TilemapLayer.prototype.preUpdateCore=e.Component.Core.preUpdate,e.TilemapLayer.sharedCopyCanvas=null,e.TilemapLayer.ensureSharedCopyCanvas=function(){return this.sharedCopyCanvas||(this.sharedCopyCanvas=e.CanvasPool.create(this,2,2)),this.sharedCopyCanvas},e.TilemapLayer.prototype.preUpdate=function(){return this.preUpdateCore()},e.TilemapLayer.prototype.postUpdate=function(){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y),this._scrollX=(this.game.camera.view.x-this.tileOffset.x)*this.scrollFactorX/this.scale.x,this._scrollY=(this.game.camera.view.y-this.tileOffset.y)*this.scrollFactorY/this.scale.y},e.TilemapLayer.prototype._renderCanvas=function(t){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y),this._scrollX=(this.game.camera.view.x-this.tileOffset.x)*this.scrollFactorX/this.scale.x,this._scrollY=(this.game.camera.view.y-this.tileOffset.y)*this.scrollFactorY/this.scale.y,this.render(),PIXI.Sprite.prototype._renderCanvas.call(this,t)},e.TilemapLayer.prototype._renderWebGL=function(t){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y),this._scrollX=(this.game.camera.view.x-this.tileOffset.x)*this.scrollFactorX/this.scale.x,this._scrollY=(this.game.camera.view.y-this.tileOffset.y)*this.scrollFactorY/this.scale.y,this.render(),PIXI.Sprite.prototype._renderWebGL.call(this,t)},e.TilemapLayer.prototype.destroy=function(){e.CanvasPool.remove(this),e.Component.Destroy.prototype.destroy.call(this)},e.TilemapLayer.prototype.resize=function(t,e){this.canvas.width=t,this.canvas.height=e,this.texture.frame.resize(t,e),this.texture.width=t,this.texture.height=e,this.texture.crop.width=t,this.texture.crop.height=e,this.texture.baseTexture.width=t,this.texture.baseTexture.height=e,this.texture.baseTexture.dirty(),this.texture.requiresUpdate=!0,this.texture._updateUvs(),this.dirty=!0},e.TilemapLayer.prototype.resizeWorld=function(){this.game.world.setBounds(0,0,this.layer.widthInPixels*this.scale.x,this.layer.heightInPixels*this.scale.y)},e.TilemapLayer.prototype.getTileOffsetX=function(){return this.tileOffset.x||(this.fixedToCamera?0:this.position.x)},e.TilemapLayer.prototype.getTileOffsetY=function(){return this.tileOffset.y||(this.fixedToCamera?0:this.position.y)},e.TilemapLayer.prototype._fixX=function(t){return 1===this.scrollFactorX||0===this.scrollFactorX&&0===this.position.x?t:0===this.scrollFactorX&&0!==this.position.x?t-this.position.x:this._scrollX+(t-this._scrollX/this.scrollFactorX)},e.TilemapLayer.prototype._unfixX=function(t){return 1===this.scrollFactorX?t:this._scrollX/this.scrollFactorX+(t-this._scrollX)},e.TilemapLayer.prototype._fixY=function(t){return 1===this.scrollFactorY||0===this.scrollFactorY&&0===this.position.y?t:0===this.scrollFactorY&&0!==this.position.y?t-this.position.y:this._scrollY+(t-this._scrollY/this.scrollFactorY)},e.TilemapLayer.prototype._unfixY=function(t){return 1===this.scrollFactorY?t:this._scrollY/this.scrollFactorY+(t-this._scrollY)},e.TilemapLayer.prototype.getTileX=function(t){return Math.floor(this._fixX(t)/this._mc.tileWidth)},e.TilemapLayer.prototype.getTileY=function(t){return Math.floor(this._fixY(t)/this._mc.tileHeight)},e.TilemapLayer.prototype.getTileXY=function(t,e,i){return i.x=this.getTileX(t),i.y=this.getTileY(e),i},e.TilemapLayer.prototype.getRayCastTiles=function(t,e,i,s){e||(e=this.rayStepRate),void 0===i&&(i=!1),void 0===s&&(s=!1);var n=this.getTiles(t.x,t.y,t.width,t.height,i,s);if(0===n.length)return[];for(var r=t.coordinatesOnLine(e),o=[],a=0;a=0;m++,v--,f+=c){m>=h&&(m-=h);var _=this.layer.data[m];for(g=b,y=n-i,p=x;y>=0;g++,y--,p+=l){g>=a&&(g-=a);var w=_[g];if(w&&!(w.index<0)){var T=w.index,P=u[T];void 0===P&&(P=this.resolveTileset(T)),w.alpha===d||this.debug||(o.globalAlpha=w.alpha,d=w.alpha),P?w.rotation||w.flipped?(o.save(),o.translate(p+w.centerX,f+w.centerY),o.rotate(w.rotation),w.flipped&&o.scale(-1,1),P.draw(o,-w.centerX,-w.centerY,T),o.restore()):P.draw(o,p,f,T):this.debugSettings.missingImageFill&&(o.fillStyle=this.debugSettings.missingImageFill,o.fillRect(p,f,l,c)),w.debug&&this.debugSettings.debuggedTileOverfill&&(o.fillStyle=this.debugSettings.debuggedTileOverfill,o.fillRect(p,f,l,c))}}}},e.TilemapLayer.prototype.renderDeltaScroll=function(t,e){var i=this._mc.scrollX,s=this._mc.scrollY,n=this.canvas.width,r=this.canvas.height,o=this._mc.tileWidth,a=this._mc.tileHeight,h=0,l=-o,c=0,u=-a;if(t<0?(h=n+t,l=n-1):t>0&&(l=t),e<0?(c=r+e,u=r-1):e>0&&(u=e),this.shiftCanvas(this.context,t,e),h=Math.floor((h+i)/o),l=Math.floor((l+i)/o),c=Math.floor((c+s)/a),u=Math.floor((u+s)/a),h<=l){this.context.clearRect(h*o-i,0,(l-h+1)*o,r);var d=Math.floor((0+s)/a),p=Math.floor((r-1+s)/a);this.renderRegion(i,s,h,d,l,p)}if(c<=u){this.context.clearRect(0,c*a-s,n,(u-c+1)*a);var f=Math.floor((0+i)/o),g=Math.floor((n-1+i)/o);this.renderRegion(i,s,f,c,g,u)}},e.TilemapLayer.prototype.renderFull=function(){var t=this._mc.scrollX,e=this._mc.scrollY,i=this.canvas.width,s=this.canvas.height,n=this._mc.tileWidth,r=this._mc.tileHeight,o=Math.floor(t/n),a=Math.floor((i-1+t)/n),h=Math.floor(e/r),l=Math.floor((s-1+e)/r);this.context.clearRect(0,0,i,s),this.renderRegion(t,e,o,h,a,l)},e.TilemapLayer.prototype.render=function(){var t=!1;if(this.visible){(this.dirty||this.layer.dirty)&&(this.layer.dirty=!1,t=!0);var e=this.canvas.width,i=this.canvas.height,s=0|this._scrollX,n=0|this._scrollY,r=this._mc,o=r.scrollX-s,a=r.scrollY-n;if(t||0!==o||0!==a||r.renderWidth!==e||r.renderHeight!==i)return this.context.save(),r.scrollX=s,r.scrollY=n,r.renderWidth===e&&r.renderHeight===i||(r.renderWidth=e,r.renderHeight=i),this.debug&&(this.context.globalAlpha=this.debugSettings.debugAlpha,this.debugSettings.forceFullRedraw&&(t=!0)),!t&&this.renderSettings.enableScrollDelta&&Math.abs(o)+Math.abs(a)=0;s++,r--,e+=f){s>=d&&(s-=d);var T=this.layer.data[s];for(i=_,n=m-g,t=x;n>=0;i++,n--,t+=p){i>=u&&(i-=u);var P=T[i];!P||P.index<0||!P.collides||(this.debugSettings.collidingTileOverfill&&(h.fillStyle=this.debugSettings.collidingTileOverfill,h.fillRect(t,e,this._mc.cw,this._mc.ch)),this.debugSettings.facingEdgeStroke&&(h.beginPath(),P.faceTop&&(h.moveTo(t,e),h.lineTo(t+this._mc.cw,e)),P.faceBottom&&(h.moveTo(t,e+this._mc.ch),h.lineTo(t+this._mc.cw,e+this._mc.ch)),P.faceLeft&&(h.moveTo(t,e),h.lineTo(t,e+this._mc.ch)),P.faceRight&&(h.moveTo(t+this._mc.cw,e),h.lineTo(t+this._mc.cw,e+this._mc.ch)),h.closePath(),h.stroke()))}}},Object.defineProperty(e.TilemapLayer.prototype,"wrap",{get:function(){return this._wrap},set:function(t){this._wrap=t,this.dirty=!0}}),Object.defineProperty(e.TilemapLayer.prototype,"scrollX",{get:function(){return this._scrollX},set:function(t){this._scrollX=t}}),Object.defineProperty(e.TilemapLayer.prototype,"scrollY",{get:function(){return this._scrollY},set:function(t){this._scrollY=t}}),Object.defineProperty(e.TilemapLayer.prototype,"collisionWidth",{get:function(){return this._mc.cw},set:function(t){this._mc.cw=0|t,this.dirty=!0}}),Object.defineProperty(e.TilemapLayer.prototype,"collisionHeight",{get:function(){return this._mc.ch},set:function(t){this._mc.ch=0|t,this.dirty=!0}}),e.TilemapParser={INSERT_NULL:!1,parse:function(t,i,s,n,r,o){if(void 0===s&&(s=32),void 0===n&&(n=32),void 0===r&&(r=10),void 0===o&&(o=10),void 0===i)return this.getEmptyData();if(null===i)return this.getEmptyData(s,n,r,o);var a=t.cache.getTilemapData(i);if(a){if(a.format===e.Tilemap.CSV)return this.parseCSV(i,a.data,s,n);if(!a.format||a.format===e.Tilemap.TILED_JSON)return this.parseTiledJSON(a.data)}else console.warn('No map data found for key "%s"',i)},parseCSV:function(t,i,s,n){for(var r=this.getEmptyData(),o=[],a=(i=i.trim()).split("\n"),h=a.length,l=0,c=0;c1.1&&console.warn('Some features in this Tiled JSON map (version %s) may not work in Phaser CE. Enable the json1 plugin and reexport the map in "Tiled 1.1" format. https://github.com/photonstorm/phaser-ce/issues/623',t.version);for(var i={width:t.width,height:t.height,tileWidth:t.tilewidth,tileHeight:t.tileheight,orientation:t.orientation,format:e.Tilemap.TILED_JSON,version:t.version,properties:t.properties,widthInPixels:t.width*t.tilewidth,heightInPixels:t.height*t.tileheight},s=[],n=0;n>>0;r.data=h,delete r.encoding}else if(r.compression){console.warn('Layer compression is unsupported, skipping layer "%s".',r.name);continue}k={name:r.name,x:r.x,y:r.y,width:r.width,height:r.height,widthInPixels:r.width*t.tilewidth,heightInPixels:r.height*t.tileheight,alpha:r.opacity,offsetX:r.offsetx,offsetY:r.offsety,visible:r.visible,properties:{},indexes:[],callbacks:[],bodies:[]};r.properties&&(k.properties=r.properties);for(var c,u,d,p=0,f=[],g=[],m=0,a=r.data.length;m536870912)switch(A>2147483648&&(A-=2147483648,d+=4),A>1073741824&&(A-=1073741824,d+=2),A>536870912&&(A-=536870912,d+=1),d){case 5:c=Math.PI/2;break;case 6:c=Math.PI;break;case 3:c=3*Math.PI/2;break;case 4:c=0,u=!0;break;case 7:c=Math.PI/2,u=!0;break;case 2:c=Math.PI,u=!0;break;case 1:c=3*Math.PI/2,u=!0}A>0?((F=new e.Tile(k,A,p,g.length,t.tilewidth,t.tileheight)).rotation=c,F.flipped=u,0!==d&&(F.flippedVal=d),f.push(F)):e.TilemapParser.INSERT_NULL?f.push(null):f.push(new e.Tile(k,-1,p,g.length,t.tilewidth,t.tileheight)),++p===r.width&&(g.push(f),p=0,f=[])}k.data=g,s.push(k)}i.layers=s;for(var y=[],n=0;n=0&&n+1=this.firstgid&&t=this._timer)if(this._timer=this.game.time.time+this.frequency*this.game.time.slowMotion,0!==this._flowTotal)if(this._flowQuantity>0){for(t=0;t=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++,this._total>0&&this._counter>=this._total&&(this.on=!1));for(var t=this.children.length;t--;)this.children[t].exists&&this.children[t].update()},e.Particles.Arcade.Emitter.prototype.makeParticles=function(t,e,i,s,n,r){void 0===e&&(e=0),void 0===i&&(i=this.maxParticles),void 0===s&&(s=!1),void 0===n&&(n=!1),void 0===r&&(r=null);var o,a=0,h=t,l=e;for(this._frames=e,i>this.maxParticles&&(this.maxParticles=i);athis.maxParticles&&(i=this.maxParticles),this._counter=0,this._flowQuantity=i,this._flowTotal=s,n?(this.start(!0,t,e,i),this._counter+=i,this.on=!0,this._timer=this.game.time.time+e*this.game.time.slowMotion):this.start(!1,t,e,i),this},e.Particles.Arcade.Emitter.prototype.start=function(t,e,i,s,n){if(void 0===t&&(t=!0),void 0===e&&(e=0),void 0!==i&&null!==i||(i=250),void 0===s&&(s=0),void 0===n&&(n=!1),s>this.maxParticles&&(s=this.maxParticles),this.revive(),this.visible=!0,this.lifespan=e,this.frequency=i,t||n)for(var r=0;r1&&(o=r.between(this.left,this.right)),null!==e?a=e:this.height>1&&(a=r.between(this.top,this.bottom)),this.resetParticle(n,o,a),!0},e.Particles.Arcade.Emitter.prototype.getNextParticle=function(){for(var t=this.length;t--;){var e=this.next();if(!e.exists)return e}return null},e.Particles.Arcade.Emitter.prototype.resetParticle=function(t,e,i){var s=this.game.rnd;t.reset(e,i),t.angle=0,t.lifespan=this.lifespan,this.particleBringToTop?this.bringToTop(t):this.particleSendToBack&&this.sendToBack(t),this.autoScale?t.setScaleData(this.scaleData):1!==this.minParticleScale||1!==this.maxParticleScale?t.scale.set(s.realInRange(this.minParticleScale,this.maxParticleScale)):this._minParticleScale.x!==this._maxParticleScale.x||this._minParticleScale.y!==this._maxParticleScale.y?t.scale.set(s.realInRange(this._minParticleScale.x,this._maxParticleScale.x),s.realInRange(this._minParticleScale.y,this._maxParticleScale.y)):t.scale.set(this._minParticleScale.x,this._minParticleScale.y),this.autoAlpha?t.setAlphaData(this.alphaData):t.alpha=s.realInRange(this.minParticleAlpha,this.maxParticleAlpha),t.blendMode=this.blendMode;var n=t.body;n.updateBounds(),n.bounce.copyFrom(this.bounce),n.drag.copyFrom(this.particleDrag),null!=this.minAngle&&null!=this.maxAngle?this.game.physics.arcade.velocityFromAngle(this.minAngle===this.maxAngle?this.minAngle:s.between(this.minAngle,this.maxAngle),this.minSpeed===this.maxSpeed?this.minSpeed:s.between(this.minSpeed,this.maxSpeed),n.velocity):(n.velocity.x=s.between(this.minParticleSpeed.x,this.maxParticleSpeed.x),n.velocity.y=s.between(this.minParticleSpeed.y,this.maxParticleSpeed.y)),n.angularVelocity=s.between(this.minRotation,this.maxRotation),n.gravity.copyFrom(this.gravity),n.angularDrag=this.angularDrag,t.onEmit()},e.Particles.Arcade.Emitter.prototype.destroy=function(){this.game.particles.remove(this),e.Group.prototype.destroy.call(this,!0,!1)},e.Particles.Arcade.Emitter.prototype.setSize=function(t,e){return this.area.width=t,this.area.height=e,this},e.Particles.Arcade.Emitter.prototype.setXSpeed=function(t,e){return t=t||0,e=e||0,this.minParticleSpeed.x=t,this.maxParticleSpeed.x=e,this},e.Particles.Arcade.Emitter.prototype.setYSpeed=function(t,e){return t=t||0,e=e||0,this.minParticleSpeed.y=t,this.maxParticleSpeed.y=e,this},e.Particles.Arcade.Emitter.prototype.setRotation=function(t,e){return t=t||0,e=e||0,this.minRotation=t,this.maxRotation=e,this},e.Particles.Arcade.Emitter.prototype.setAlpha=function(t,i,s,n,r){if(void 0===t&&(t=1),void 0===i&&(i=1),void 0===s&&(s=0),void 0===n&&(n=e.Easing.Linear.None),void 0===r&&(r=!1),this.minParticleAlpha=t,this.maxParticleAlpha=i,this.autoAlpha=!1,s>0&&t!==i){var o={v:t},a=this.game.make.tween(o).to({v:i},s,n);a.yoyo(r),this.alphaData=a.generateData(60),this.alphaData.reverse(),this.autoAlpha=!0}return this},e.Particles.Arcade.Emitter.prototype.setScale=function(t,i,s,n,r,o,a){if(void 0===t&&(t=1),void 0===i&&(i=1),void 0===s&&(s=1),void 0===n&&(n=1),void 0===r&&(r=0),void 0===o&&(o=e.Easing.Linear.None),void 0===a&&(a=!1),this.minParticleScale=1,this.maxParticleScale=1,this._minParticleScale.set(t,s),this._maxParticleScale.set(i,n),this.autoScale=!1,r>0&&(t!==i||s!==n)){var h={x:t,y:s},l=this.game.make.tween(h).to({x:i,y:n},r,o);l.yoyo(a),this.scaleData=l.generateData(60),this.scaleData.reverse(),this.autoScale=!0}return this},e.Particles.Arcade.Emitter.prototype.setAngle=function(t,e,i,s){return this.minAngle=t,this.maxAngle=e,null!=i&&(this.minSpeed=i),null!=s&&(this.maxSpeed=s),this},e.Particles.Arcade.Emitter.prototype.at=function(t){return t.center?(this.emitX=t.center.x,this.emitY=t.center.y):(this.emitX=t.world.x+t.anchor.x*t.width,this.emitY=t.world.y+t.anchor.y*t.height),this},Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"gravity",{get:function(){return this._gravity},set:function(t){"number"==typeof t?this._gravity.y=t:this._gravity=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"id",{get:function(){return this._id}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"width",{get:function(){return this.area.width},set:function(t){this.area.width=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"height",{get:function(){return this.area.height},set:function(t){this.area.height=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"x",{get:function(){return this.emitX},set:function(t){this.emitX=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"y",{get:function(){return this.emitY},set:function(t){this.emitY=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"left",{get:function(){return Math.floor(this.x-this.area.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"right",{get:function(){return Math.floor(this.x+this.area.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"top",{get:function(){return Math.floor(this.y-this.area.height/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return Math.floor(this.y+this.area.height/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"output",{get:function(){return 1e3*this._flowQuantity/this.frequency}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"lifespanOutput",{get:function(){return(0===this.lifespan?1/0:this.lifespan)*this._flowQuantity/this.frequency}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"remainder",{get:function(){return this.maxParticles-this.lifespanOutput}}),e.Weapon=function(t,i){e.Plugin.call(this,t,i),this.bullets=null,this.autoExpandBulletsGroup=!1,this.autofire=!1,this.shots=0,this.fireLimit=0,this.fireRate=100,this.fireRateVariance=0,this.fireFrom=new e.Rectangle(0,0,1,1),this.fireAngle=e.ANGLE_UP,this.bulletInheritSpriteSpeed=!1,this.bulletAnimation="",this.bulletFrameRandom=!1,this.bulletFrameCycle=!1,this.bulletWorldWrap=!1,this.bulletWorldWrapPadding=0,this.bulletAngleOffset=0,this.bulletAngleVariance=0,this.bulletSpeed=200,this.bulletSpeedVariance=0,this.bulletLifespan=0,this.bulletKillDistance=0,this.bulletGravity=new e.Point(0,0),this.bulletRotateToVelocity=!1,this.bulletKey="",this.bulletFrame="",this._bulletClass=e.Bullet,this._bulletCollideWorldBounds=!1,this._bulletKillType=e.Weapon.KILL_WORLD_BOUNDS,this._data={customBody:!1,width:0,height:0,offsetX:0,offsetY:0},this.bounds=new e.Rectangle,this.bulletBounds=t.world.bounds,this.bulletFrames=[],this.bulletFrameIndex=0,this.anims={},this.onFire=new e.Signal,this.onKill=new e.Signal,this.onFireLimit=new e.Signal,this.trackedSprite=null,this.trackedPointer=null,this.multiFire=!1,this._hasFired=!1,this.trackRotation=!1,this.trackOffset=new e.Point,this._nextFire=0,this._tempNextFire=0,this._rotatedPoint=new e.Point},e.Weapon.prototype=Object.create(e.Plugin.prototype),e.Weapon.prototype.constructor=e.Weapon,e.Weapon.KILL_NEVER=0,e.Weapon.KILL_LIFESPAN=1,e.Weapon.KILL_DISTANCE=2,e.Weapon.KILL_WEAPON_BOUNDS=3,e.Weapon.KILL_CAMERA_BOUNDS=4,e.Weapon.KILL_WORLD_BOUNDS=5,e.Weapon.KILL_STATIC_BOUNDS=6,e.Weapon.prototype.createBullets=function(t,i,s,n){return void 0===t&&(t=1),void 0===n&&(n=this.game.world),this.bullets&&!this.bullets.game&&(this.bullets=null),this.bullets||(this.bullets=this.game.add.physicsGroup(e.Physics.ARCADE,n),this.bullets.classType=this._bulletClass),0!==t&&(-1===t&&(this.autoExpandBulletsGroup=!0,t=1),this.bullets.createMultiple(t,i,s),this.bullets.setAll("data.bulletManager",this),this.bulletKey=i,this.bulletFrame=s),this},e.Weapon.prototype.forEach=function(t,e){return this.bullets.forEachExists(t,e,arguments),this},e.Weapon.prototype.pauseAll=function(){return this.bullets.setAll("body.enable",!1),this},e.Weapon.prototype.resumeAll=function(){return this.bullets.setAll("body.enable",!0),this},e.Weapon.prototype.killAll=function(){return this.bullets.callAllExists("kill",!0),this.bullets.setAll("body.enable",!0),this},e.Weapon.prototype.resetShots=function(t){return this.shots=0,void 0!==t&&(this.fireLimit=t),this},e.Weapon.prototype.destroy=function(){this.parent.remove(this,!1),this.bullets.destroy(),this.game=null,this.parent=null,this.active=!1,this.visible=!1},e.Weapon.prototype.update=function(){this._bulletKillType===e.Weapon.KILL_WEAPON_BOUNDS&&(this.trackedSprite?(this.trackedSprite.updateTransform(),this.bounds.centerOn(this.trackedSprite.worldPosition.x,this.trackedSprite.worldPosition.y)):this.trackedPointer&&this.bounds.centerOn(this.trackedPointer.worldX,this.trackedPointer.worldY)),this.autofire&&this.fire()},e.Weapon.prototype.postRender=function(){this.multiFire&&this._hasFired&&(this._hasFired=!1,this._nextFire=this._tempNextFire)},e.Weapon.prototype.trackSprite=function(t,e,i,s){return void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=!1),this.trackedPointer=null,this.trackedSprite=t,this.trackRotation=s,this.trackOffset.set(e,i),this},e.Weapon.prototype.trackPointer=function(t,e,i){return void 0===t&&(t=this.game.input.activePointer),void 0===e&&(e=0),void 0===i&&(i=0),this.trackedPointer=t,this.trackedSprite=null,this.trackRotation=!1,this.trackOffset.set(e,i),this},e.Weapon.prototype.fireMany=function(t,e){this.multiFire=!0;var i=[],s=this;return e||this.trackedSprite||this.trackedPointer?t.forEach(function(t){i.push(s.fire(e,null,null,t.x,t.y))}):t.forEach(function(t){i.push(s.fire(t))}),i},e.Weapon.prototype.fireOffset=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.fire(null,null,null,t,e)},e.Weapon.prototype.fire=function(t,i,s,n,r){if(void 0===i&&(i=null),void 0===s&&(s=null),this.game.time.now0&&this.shots===this.fireLimit)return null;var o=this.bulletSpeed;0!==this.bulletSpeedVariance&&(o+=e.Math.between(-this.bulletSpeedVariance,this.bulletSpeedVariance)),t?this.fireFrom.width>1?this.fireFrom.centerOn(t.x,t.y):(this.fireFrom.x=t.x,this.fireFrom.y=t.y):this.trackedSprite?(this.trackRotation?(this._rotatedPoint.set(this.trackedSprite.world.x+this.trackOffset.x,this.trackedSprite.world.y+this.trackOffset.y),this._rotatedPoint.rotate(this.trackedSprite.world.x,this.trackedSprite.world.y,this.trackedSprite.worldRotation),this.fireFrom.width>1?this.fireFrom.centerOn(this._rotatedPoint.x,this._rotatedPoint.y):(this.fireFrom.x=this._rotatedPoint.x,this.fireFrom.y=this._rotatedPoint.y)):this.fireFrom.width>1?this.fireFrom.centerOn(this.trackedSprite.world.x+this.trackOffset.x,this.trackedSprite.world.y+this.trackOffset.y):(this.fireFrom.x=this.trackedSprite.world.x+this.trackOffset.x,this.fireFrom.y=this.trackedSprite.world.y+this.trackOffset.y),this.bulletInheritSpriteSpeed&&(o+=this.trackedSprite.body.speed)):this.trackedPointer&&(this.fireFrom.width>1?this.fireFrom.centerOn(this.trackedPointer.world.x+this.trackOffset.x,this.trackedPointer.world.y+this.trackOffset.y):(this.fireFrom.x=this.trackedPointer.world.x+this.trackOffset.x,this.fireFrom.y=this.trackedPointer.world.y+this.trackOffset.y)),void 0!==n&&(this.fireFrom.x+=n),void 0!==r&&(this.fireFrom.y+=r);var a=this.fireFrom.width>1?this.fireFrom.randomX:this.fireFrom.x,h=this.fireFrom.height>1?this.fireFrom.randomY:this.fireFrom.y,l=this.trackRotation?this.trackedSprite.angle:this.fireAngle;null!==i&&null!==s&&(l=this.game.math.radToDeg(Math.atan2(s-h,i-a))),0!==this.bulletAngleVariance&&(l+=e.Math.between(-this.bulletAngleVariance,this.bulletAngleVariance));var c=0,u=0;0===l||180===l?c=Math.cos(this.game.math.degToRad(l))*o:90===l||270===l?u=Math.sin(this.game.math.degToRad(l))*o:(c=Math.cos(this.game.math.degToRad(l))*o,u=Math.sin(this.game.math.degToRad(l))*o);var d=null;if(this.autoExpandBulletsGroup?(d=this.bullets.getFirstExists(!1,!0,a,h,this.bulletKey,this.bulletFrame)).data.bulletManager=this:d=this.bullets.getFirstExists(!1),d){if(d.reset(a,h),d.data.fromX=a,d.data.fromY=h,d.data.killType=this.bulletKillType,d.data.killDistance=this.bulletKillDistance,d.data.rotateToVelocity=this.bulletRotateToVelocity,this.bulletKillType===e.Weapon.KILL_LIFESPAN&&(d.lifespan=this.bulletLifespan),d.angle=l+this.bulletAngleOffset,""!==this.bulletAnimation){if(null===d.animations.getAnimation(this.bulletAnimation)){var p=this.anims[this.bulletAnimation];d.animations.add(p.name,p.frames,p.frameRate,p.loop,p.useNumericIndex)}d.animations.play(this.bulletAnimation)}else this.bulletFrameCycle?(d.frame=this.bulletFrames[this.bulletFrameIndex],++this.bulletFrameIndex>=this.bulletFrames.length&&(this.bulletFrameIndex=0)):this.bulletFrameRandom&&(d.frame=this.bulletFrames[Math.floor(Math.random()*this.bulletFrames.length)]);d.data.bodyDirty&&(this._data.customBody&&d.body.setSize(this._data.width,this._data.height,this._data.offsetX,this._data.offsetY),d.body.collideWorldBounds=this.bulletCollideWorldBounds,d.data.bodyDirty=!1),d.body.velocity.set(c,u),d.body.gravity.set(this.bulletGravity.x,this.bulletGravity.y);var f=0;if(0!==this.bulletSpeedVariance){var g=this.fireRate;(g+=e.Math.between(-this.fireRateVariance,this.fireRateVariance))<0&&(g=0),f=this.game.time.now+g}else f=this.game.time.now+this.fireRate;this.multiFire?this._hasFired||(this._hasFired=!0,this._tempNextFire=f,this.shots++):(this._nextFire=f,this.shots++),this.onFire.dispatch(d,this,o),this.fireLimit>0&&this.shots===this.fireLimit&&this.onFireLimit.dispatch(this,this.fireLimit)}return d},e.Weapon.prototype.fireAtPointer=function(t){return void 0===t&&(t=this.game.input.activePointer),this.fire(null,t.worldX,t.worldY)},e.Weapon.prototype.fireAtSprite=function(t){return this.fire(null,t.world.x,t.world.y)},e.Weapon.prototype.fireAtXY=function(t,e){return this.fire(null,t,e)},e.Weapon.prototype.setBulletBodyOffset=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),this._data.customBody=!0,this._data.width=t,this._data.height=e,this._data.offsetX=i,this._data.offsetY=s,this.bullets.callAll("body.setSize","body",t,e,i,s),this.bullets.setAll("data.bodyDirty",!1),this},e.Weapon.prototype.setBulletFrames=function(t,i,s,n){return void 0===s&&(s=!0),void 0===n&&(n=!1),this.bulletFrames=e.ArrayUtils.numberArray(t,i),this.bulletFrameIndex=0,this.bulletFrameCycle=s,this.bulletFrameRandom=n,this},e.Weapon.prototype.addBulletAnimation=function(t,e,i,s,n){return this.anims[t]={name:t,frames:e,frameRate:i,loop:s,useNumericIndex:n},this.bullets.callAll("animations.add","animations",t,e,i,s,n),this.bulletAnimation=t,this},e.Weapon.prototype.debug=function(t,e,i){void 0===t&&(t=16),void 0===e&&(e=32),void 0===i&&(i=!1),this.game.debug.text("Weapon Plugin",t,e),this.game.debug.text("Bullets Alive: "+this.bullets.total+" - Total: "+this.bullets.length,t,e+24),i&&this.bullets.forEachExists(this.game.debug.body,this.game.debug,"rgba(255, 0, 255, 0.8)")},Object.defineProperty(e.Weapon.prototype,"bulletClass",{get:function(){return this._bulletClass},set:function(t){this._bulletClass=t,this.bullets&&(this.bullets.classType=this._bulletClass)}}),Object.defineProperty(e.Weapon.prototype,"bulletKillType",{get:function(){return this._bulletKillType},set:function(t){switch(t){case e.Weapon.KILL_STATIC_BOUNDS:case e.Weapon.KILL_WEAPON_BOUNDS:this.bulletBounds=this.bounds;break;case e.Weapon.KILL_CAMERA_BOUNDS:this.bulletBounds=this.game.camera.view;break;case e.Weapon.KILL_WORLD_BOUNDS:this.bulletBounds=this.game.world.bounds}this._bulletKillType=t}}),Object.defineProperty(e.Weapon.prototype,"bulletCollideWorldBounds",{get:function(){return this._bulletCollideWorldBounds},set:function(t){this._bulletCollideWorldBounds=t,this.bullets.setAll("body.collideWorldBounds",t),this.bullets.setAll("data.bodyDirty",!1)}}),Object.defineProperty(e.Weapon.prototype,"x",{get:function(){return this.fireFrom.x},set:function(t){this.fireFrom.x=t}}),Object.defineProperty(e.Weapon.prototype,"y",{get:function(){return this.fireFrom.y},set:function(t){this.fireFrom.y=t}}),e.Bullet=function(t,i,s,n,r){e.Sprite.call(this,t,i,s,n,r),this.anchor.set(.5),this.data={bulletManager:null,fromX:0,fromY:0,bodyDirty:!0,rotateToVelocity:!1,killType:0,killDistance:0}},e.Bullet.prototype=Object.create(e.Sprite.prototype),e.Bullet.prototype.constructor=e.Bullet,e.Bullet.prototype.kill=function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.data.bulletManager.onKill.dispatch(this),this},e.Bullet.prototype.update=function(){this.exists&&(this.data.killType>e.Weapon.KILL_LIFESPAN&&(this.data.killType===e.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))},e.Video=function(t,i,s){if(void 0===i&&(i=null),void 0===s&&(s=null),this.game=t,this.key=i,this.width=0,this.height=0,this.type=e.VIDEO,this.disableTextureUpload=!1,this.touchLocked=!1,this.onPlay=new e.Signal,this.onChangeSource=new e.Signal,this.onComplete=new e.Signal,this.onAccess=new e.Signal,this.onError=new e.Signal,this.onTimeout=new e.Signal,this.onTouchUnlock=new e.Signal,this.playWhenUnlocked=!0,this.timeout=15e3,this._timeOutID=null,this.video=null,this.videoStream=null,this.isStreaming=!1,this.retryLimit=20,this.retry=0,this.retryInterval=500,this._retryID=null,this._codeMuted=!1,this._muted=!1,this._codePaused=!1,this._paused=!1,this._pending=!1,this._pendingChangeSource=!1,this._autoplay=!1,this._endCallback=null,this._playCallback=null,i&&this.game.cache.checkVideoKey(i)){var n=this.game.cache.getVideo(i);n.isBlob?this.createVideoFromBlob(n.data):this.video=n.data,this.width=this.video.videoWidth,this.height=this.video.videoHeight}else s&&this.createVideoFromURL(s,!1);this.video&&!s?(this.baseTexture=new PIXI.BaseTexture(this.video,null,this.game.resolution),this.baseTexture.forceLoaded(this.width,this.height)):(this.baseTexture=new PIXI.BaseTexture(e.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 e.Frame(0,0,0,this.width,this.height,"video"),this.texture.setFrame(this.textureFrame),this.texture.valid=!1,null!==i&&this.video&&(this.texture.valid=this.video.canplay),this.snapshot=null,e.BitmapData&&(this.snapshot=new e.BitmapData(this.game,"",this.width,this.height)),this.game.device.needsTouchUnlock()?this.setTouchLock():n&&(n.locked=!1)},e.Video.prototype={connectToMediaStream:function(t,e){return t&&e&&(this.video=t,this.videoStream=e,this.isStreaming=!0,this.baseTexture.source=this.video,this.updateTexture(null,this.video.videoWidth,this.video.videoHeight),this.onAccess.dispatch(this)),this},startMediaStream:function(t,e,i){if(void 0===t&&(t=!1),void 0===e&&(e=null),void 0===i&&(i=null),!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"),this.video.setAttribute("playsinline","playsinline"),null!==e&&(this.video.width=e),null!==i&&(this.video.height=i),this._timeOutID=window.setTimeout(this.getUserMediaTimeout.bind(this),this.timeout);try{navigator.getUserMedia({audio:t,video:!0},this.getUserMediaSuccess.bind(this),this.getUserMediaError.bind(this))}catch(t){this.getUserMediaError(t)}return this},getUserMediaTimeout:function(){clearTimeout(this._timeOutID),this.onTimeout.dispatch(this)},getUserMediaError:function(t){clearTimeout(this._timeOutID),this.onError.dispatch(this,t)},getUserMediaSuccess:function(t){clearTimeout(this._timeOutID),this.videoStream=t,void 0!==this.video.mozSrcObject?this.video.mozSrcObject=t:void 0!==this.video.srcObject?this.video.srcObject=t:this.video.src=window.URL&&window.URL.createObjectURL(t)||t;var e=this;this.video.onloadeddata=function(){function t(){if(i>0)if(e.video.videoWidth>0){var s=e.video.videoWidth,n=e.video.videoHeight;isNaN(e.video.videoHeight)&&(n=s/(4/3)),e.video.play(),e.isStreaming=!0,e.baseTexture.source=e.video,e.updateTexture(null,s,n),e.onAccess.dispatch(e)}else window.setTimeout(t,500);else console.warn("Unable to connect to video stream. Webcam error?");i--}var i=10;t()}},createVideoFromBlob:function(t){var e=this;return this.video=document.createElement("video"),this.video.controls=!1,this.video.setAttribute("autoplay","autoplay"),this.video.setAttribute("playsinline","playsinline"),this.video.addEventListener("loadeddata",function(t){e.updateTexture(t)},!0),this.video.src=window.URL.createObjectURL(t),this.video.canplay=!0,this},createVideoFromURL:function(t,e){return void 0===e&&(e=!1),this.texture&&(this.texture.valid=!1),this.video=document.createElement("video"),this.video.controls=!1,e&&this.video.setAttribute("autoplay","autoplay"),this.video.setAttribute("playsinline","playsinline"),this.video.src=t,this.video.canplay=!0,this.video.load(),this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval),this.key=t,this},updateTexture:function(t,e,i){var s=!1;void 0!==e&&null!==e||(e=this.video.videoWidth,s=!0),void 0!==i&&null!==i||(i=this.video.videoHeight),this.width=e,this.height=i,this.baseTexture.source!==this.video&&(this.baseTexture.source=this.video),this.baseTexture.forceLoaded(e,i),this.texture.frame.resize(e,i),this.texture.width=e,this.texture.height=i,this.texture.valid=!0,this.snapshot&&this.snapshot.resize(e,i),s&&null!==this.key&&(this.onChangeSource.dispatch(this,e,i),this._autoplay&&(this.video.play(),this.onPlay.dispatch(this,this.loop,this.playbackRate)))},complete:function(){this.onComplete.dispatch(this)},play:function(t,e){return this._pendingChangeSource?this:(void 0===t&&(t=!1),void 0===e&&(e=1),this.game.sound.onMute&&(this.game.sound.onMute.add(this.setMute,this),this.game.sound.onUnMute.add(this.unsetMute,this),this.game.sound.mute&&this.setMute()),this.game.onPause.add(this.setPause,this),this.game.onResume.add(this.setResume,this),this._endCallback=this.complete.bind(this),this.video.addEventListener("ended",this._endCallback,!0),this.video.addEventListener("webkitendfullscreen",this._endCallback,!0),this.video.loop=t?"loop":"",this.video.playbackRate=e,this.touchLocked?this._pending=!0:(this._pending=!1,null!==this.key&&(4!==this.video.readyState?(this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval)):(this._playCallback=this.playHandler.bind(this),this.video.addEventListener("playing",this._playCallback,!0))),this.video.play(),this.onPlay.dispatch(this,t,e)),this)},playHandler:function(){this.video.removeEventListener("playing",this._playCallback,!0),this.updateTexture()},stop:function(){return this.game.sound.onMute&&(this.game.sound.onMute.remove(this.setMute,this),this.game.sound.onUnMute.remove(this.unsetMute,this)),this.game.onPause.remove(this.setPause,this),this.game.onResume.remove(this.setResume,this),this.isStreaming?(this.video.mozSrcObject?(this.video.mozSrcObject.stop(),this.video.src=null):this.video.srcObject?(this.video.srcObject.stop(),this.video.src=null):(this.video.src="",this.videoStream.active?this.videoStream.active=!1:this.videoStream.getTracks?this.videoStream.getTracks().forEach(function(t){t.stop()}):this.videoStream.stop()),this.videoStream=null,this.isStreaming=!1):(this.video.removeEventListener("ended",this._endCallback,!0),this.video.removeEventListener("webkitendfullscreen",this._endCallback,!0),this.video.removeEventListener("playing",this._playCallback,!0),this.touchLocked?this._pending=!1:this.video.pause()),this},add:function(t){if(Array.isArray(t))for(var e=0;e0?this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval):console.warn("Phaser.Video: Unable to start downloading video in time",this.isStreaming)},setTouchLock:function(){this.game.input.addTouchLockCallback(this.unlock,this,!0),this.touchLocked=!0},unlock:function(){if(this.touchLocked=!1,this.playWhenUnlocked&&(this.video.play(),this.onPlay.dispatch(this,this.loop,this.playbackRate)),this.key){var t=this.game.cache.getVideo(this.key);t&&!t.isBlob&&(t.locked=!1)}return this.onTouchUnlock.dispatch(this),!0},grab:function(t,e,i){if(void 0===t&&(t=!1),void 0===e&&(e=1),void 0===i&&(i=null),null!==this.snapshot)return t&&this.snapshot.cls(),this.snapshot.copy(this.video,0,0,this.width,this.height,0,0,this.width,this.height,0,0,0,1,1,e,i),this.snapshot;console.warn("Video.grab cannot run because Phaser.BitmapData is unavailable")},removeVideoElement:function(){if(this.video){for(this.video.parentNode&&this.video.parentNode.removeChild(this.video);this.video.hasChildNodes();)this.video.removeChild(this.video.firstChild);this.video.removeAttribute("autoplay"),this.video.removeAttribute("src"),this.video=null}},destroy:function(){this.stop(),this.removeVideoElement(),this.touchLocked&&this.game.input.removeTouchLockCallback(this.unlock,this),this._retryID&&window.clearTimeout(this._retryID)}},Object.defineProperty(e.Video.prototype,"currentTime",{get:function(){return this.video?this.video.currentTime:0},set:function(t){this.video.currentTime=t}}),Object.defineProperty(e.Video.prototype,"duration",{get:function(){return this.video?this.video.duration:0}}),Object.defineProperty(e.Video.prototype,"progress",{get:function(){return this.video?this.video.currentTime/this.video.duration:0}}),Object.defineProperty(e.Video.prototype,"mute",{get:function(){return this._muted},set:function(t){if(t=t||null){if(this._muted)return;this._codeMuted=!0,this.setMute()}else{if(!this._muted)return;this._codeMuted=!1,this.unsetMute()}}}),Object.defineProperty(e.Video.prototype,"paused",{get:function(){return this._paused},set:function(t){if(t=t||null,!this.touchLocked)if(t){if(this._paused)return;this._codePaused=!0,this.setPause()}else{if(!this._paused)return;this._codePaused=!1,this.setResume()}}}),Object.defineProperty(e.Video.prototype,"volume",{get:function(){return this.video?this.video.volume:1},set:function(t){t<0?t=0:t>1&&(t=1),this.video&&(this.video.volume=t)}}),Object.defineProperty(e.Video.prototype,"playbackRate",{get:function(){return this.video?this.video.playbackRate:1},set:function(t){this.video&&(this.video.playbackRate=t)}}),Object.defineProperty(e.Video.prototype,"loop",{get:function(){return!!this.video&&this.video.loop},set:function(t){t&&this.video?this.video.loop="loop":this.video&&(this.video.loop="")}}),Object.defineProperty(e.Video.prototype,"playing",{get:function(){return!!this.video&&!(this.video.paused&&this.video.ended)}}),e.Video.prototype.constructor=e.Video,void 0===PIXI.blendModes&&(PIXI.blendModes=e.blendModes),void 0===PIXI.scaleModes&&(PIXI.scaleModes=e.scaleModes),void 0===PIXI.Texture.emptyTexture&&(PIXI.Texture.emptyTexture=new PIXI.Texture(new PIXI.BaseTexture)),void 0===PIXI.DisplayObject._tempMatrix&&(PIXI.DisplayObject._tempMatrix=new e.Matrix),PIXI.TextureSilentFail=!0,PIXI.canUseNewCanvasBlendModes=function(){return e.Device.canUseMultiply},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=e),exports.Phaser=e):"undefined"!=typeof define&&define.amd?define("Phaser",t.Phaser=e):t.Phaser=e,e}.call(this); +!function(t){var e;"object"==typeof exports?module.exports=t():("undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.p2=t())}(function(){return function n(r,o,a){function h(i,t){if(!o[i]){if(!r[i]){var e="function"==typeof require&&require;if(!t&&e)return e(i,!0);if(l)return l(i,!0);throw new Error("Cannot find module '"+i+"'")}var s=o[i]={exports:{}};r[i][0].call(s.exports,function(t){var e=r[i][1][t];return h(e||t)},s,s.exports,n,r,o,a)}return o[i].exports}for(var l="function"==typeof require&&require,t=0;tt.vertices.length)throw new Error("lol2");if(e<0)throw new Error("lol3");for(var s=e;se[t][0])&&(t=i);w.left(this.at(t-1),this.at(t),this.at(t+1))||this.reverse()},T.prototype.reverse=function(){for(var t=[],e=0,i=this.vertices.length;e!==i;e++)t.push(this.vertices.pop());this.vertices=t},T.prototype.isReflex=function(t){return w.right(this.at(t-1),this.at(t),this.at(t+1))};var h=[],l=[];function P(t,e,i,s,n){n=n||0;var r=e[1]-t[1],o=t[0]-e[0],a=r*t[0]+o*t[1],h=s[1]-i[1],l=i[0]-s[0],c=h*i[0]+l*i[1],u=r*l-h*o;return d.eq(u,0,n)?[0,0]:[(l*a-o*c)/u,(r*c-h*a)/u]}T.prototype.canSee=function(t,e){var i,s,n=h,r=l;if(w.leftOn(this.at(t+1),this.at(t),this.at(e))&&w.rightOn(this.at(t-1),this.at(t),this.at(e)))return!1;s=w.sqdist(this.at(t),this.at(e));for(var o=0;o!==this.vertices.length;++o)if((o+1)%this.vertices.length!==t&&o!==t&&w.leftOn(this.at(t),this.at(e),this.at(o+1))&&w.rightOn(this.at(t),this.at(e),this.at(o))&&(n[0]=this.at(t),n[1]=this.at(e),r[0]=this.at(o),r[1]=this.at(o+1),i=a.lineInt(n,r),w.sqdist(this.at(t),i) (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(t,e,i){var p=t("../math/vec2");t("../utils/Utils");function s(t){this.lowerBound=p.create(),t&&t.lowerBound&&p.copy(this.lowerBound,t.lowerBound),this.upperBound=p.create(),t&&t.upperBound&&p.copy(this.upperBound,t.upperBound)}e.exports=s;var f=p.create();s.prototype.setFromPoints=function(t,e,i,s){var n=this.lowerBound,r=this.upperBound;"number"!=typeof i&&(i=0),0!==i?p.rotate(n,t[0],i):p.copy(n,t[0]),p.copy(r,n);for(var o=Math.cos(i),a=Math.sin(i),h=1;hr[d]&&(r[d]=l[d]),l[d]i&&(this.lowerBound[e]=i);var s=t.upperBound[e];this.upperBound[e]Math.pow(d,2))return 0;if(h)return!0;var p=this.createContactEquation(t,n,e,r);return W(p.normalA,o,i),X.normalize(p.normalA,p.normalA),X.scale(p.contactPointA,p.normalA,l),X.scale(p.contactPointB,p.normalA,-c),j(p.contactPointA,p.contactPointA,i),W(p.contactPointA,p.contactPointA,t.position),j(p.contactPointB,p.contactPointB,o),W(p.contactPointB,p.contactPointB,n.position),this.contactEquations.push(p),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(p)),1},$.prototype[l.PLANE|l.CONVEX]=$.prototype[l.PLANE|l.BOX]=$.prototype.planeConvex=function(t,e,i,s,n,r,o,a,h){var l=H,c=q,u=Y,d=0;X.rotate(c,P,s);for(var p=0;p!==r.vertices.length;p++){var f=r.vertices[p];if(X.rotate(l,f,a),j(l,l,o),W(u,l,i),V(u,c)<=0){if(h)return!0;d++;var g=this.createContactEquation(t,n,e,r);W(u,l,i),X.copy(g.normalA,c);var m=V(u,g.normalA);X.scale(u,g.normalA,m),W(g.contactPointB,l,n.position),W(g.contactPointA,l,u),W(g.contactPointA,g.contactPointA,t.position),this.contactEquations.push(g),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(g))}}return this.enableFrictionReduction&&this.enableFriction&&d&&this.frictionEquations.push(this.createFrictionFromAverage(d)),d},$.prototype[l.PARTICLE|l.PLANE]=$.prototype.particlePlane=function(t,e,i,s,n,r,o,a,h){var l=H,c=q;a=a||0,W(l,i,o),X.rotate(c,P,a);var u=V(l,c);if(0Math.pow(e.radius,2))return 0;if(h)return!0;var c=this.createContactEquation(t,n,e,r);return X.copy(c.normalA,l),X.normalize(c.normalA,c.normalA),X.scale(c.contactPointA,c.normalA,e.radius),j(c.contactPointA,c.contactPointA,i),W(c.contactPointA,c.contactPointA,t.position),W(c.contactPointB,o,n.position),this.contactEquations.push(c),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(c)),1};var C=new a({radius:1}),S=X.create(),A=X.create();X.create();$.prototype[l.PLANE|l.CAPSULE]=$.prototype.planeCapsule=function(t,e,i,s,n,r,o,a,h){var l,c=S,u=A,d=C;X.set(c,-r.length/2,0),X.rotate(c,c,a),j(c,c,o),X.set(u,r.length/2,0),X.rotate(u,u,a),j(u,u,o),d.radius=r.radius,this.enableFrictionReduction&&(l=this.enableFriction,this.enableFriction=!1);var p=this.circlePlane(n,d,c,0,t,e,i,s,h),f=this.circlePlane(n,d,u,0,t,e,i,s,h);if(this.enableFrictionReduction&&(this.enableFriction=l),h)return p||f;var g=p+f;return this.enableFrictionReduction&&g&&this.frictionEquations.push(this.createFrictionFromAverage(g)),g},$.prototype[l.CIRCLE|l.PLANE]=$.prototype.circlePlane=function(t,e,i,s,n,r,o,a,h){var l=t,c=e,u=i,d=n,p=o,f=a;f=f||0;var g=H,m=q,y=Y;W(g,u,p),X.rotate(m,P,f);var v=V(m,g);if(v>c.radius)return 0;if(h)return!0;var x=this.createContactEquation(d,l,r,e);return X.copy(x.normalA,m),X.scale(x.contactPointB,x.normalA,-c.radius),j(x.contactPointB,x.contactPointB,u),W(x.contactPointB,x.contactPointB,l.position),X.scale(y,x.normalA,v),W(x.contactPointA,g,y),j(x.contactPointA,x.contactPointA,p),W(x.contactPointA,x.contactPointA,d.position),this.contactEquations.push(x),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(x)),1},$.prototype[l.CONVEX]=$.prototype[l.CONVEX|l.BOX]=$.prototype[l.BOX]=$.prototype.convexConvex=function(t,e,i,s,n,r,o,a,h,l){var c=H,u=q,d=Y,p=z,f=K,g=J,m=Q,y=Z,v=0;l="number"==typeof l?l:0;if(!$.findSeparatingAxis(e,i,s,r,o,a,c))return 0;W(m,o,i),0g[0]&&(_=f,b=g,!0),h=(w=_[0]-b[1])<=0,(null===a||ag[0]&&(_=f,b=g,!0),h=(w=_[0]-b[1])<=0,(null===a||a=c.length&&(b=c.length-1);for(var _=c[x],w=c[b],T=x;T_&&(_=c[T]);if(i[1]-l>_)return!h&&0;var P=!1;for(T=x;T=y[0]&&p[0]=l.length&&(m=l.length-1);for(var y=l[g],v=l[m],x=g;xy&&(y=l[x]);if(t.aabb.lowerBound[1]>y)return!h&&0;var b=0;for(x=g;xe.boundingRadius*e.boundingRadius||(this._currentBody=n,(this._currentShape=e).raycast(t,this,s,i),this._currentBody=this._currentShape=null)},o.prototype.getAABB=function(t){var e=this.to,i=this.from;h.set(t.lowerBound,Math.min(e[0],i[0]),Math.min(e[1],i[1])),h.set(t.upperBound,Math.max(e[0],i[0]),Math.max(e[1],i[1]))};h.create();o.prototype.reportIntersection=function(t,e,i,s){this.from,this.to;var n=this._currentShape,r=this._currentBody;if(!(this.skipBackfaces&&0this.upperLimit&&(r.maxForce=0,r.minForce=-this.maxForce,this.distance=this.upperLimit,a=!0),this.lowerLimitEnabled&&this.position>1;if(e<3)return[];for(var i=[],s=[],n=0;n3*r)break}return i.push(s[0],s[1],s[2]),i},_PointInTriangle:function(t,e,i,s,n,r,o,a){var h=o-i,l=a-s,c=n-i,u=r-s,d=t-i,p=e-s,f=h*h+l*l,g=h*c+l*u,m=h*d+l*p,y=c*c+u*u,v=c*d+u*p,x=1/(f*y-g*g),b=(y*m-g*v)*x,_=(f*v-g*m)*x;return 0<=b&&0<=_&&b+_<1},_convex:function(t,e,i,s,n,r){return 0<=(e-s)*(n-i)+(i-t)*(r-s)}};e.exports=v},{}],30:[function(t,e,i){var o=e.exports={},s=t("../utils/Utils");o.crossLength=function(t,e){return t[0]*e[1]-t[1]*e[0]},o.crossVZ=function(t,e,i){return o.rotate(t,e,-Math.PI/2),o.scale(t,t,i),t},o.crossZV=function(t,e,i){return o.rotate(t,i,Math.PI/2),o.scale(t,t,e),t},o.rotate=function(t,e,i){if(0!==i){var s=Math.cos(i),n=Math.sin(i),r=e[0],o=e[1];t[0]=s*r-n*o,t[1]=n*r+s*o}else t[0]=e[0],t[1]=e[1]},o.rotate90cw=function(t,e){var i=e[0],s=e[1];t[0]=s,t[1]=-i},o.toLocalFrame=function(t,e,i,s){o.copy(t,e),o.sub(t,t,i),o.rotate(t,t,-s)},o.toGlobalFrame=function(t,e,i,s){o.copy(t,e),o.rotate(t,t,s),o.add(t,t,i)},o.vectorToLocalFrame=function(t,e,i){o.rotate(t,e,-i)},o.vectorToGlobalFrame=function(t,e,i){o.rotate(t,e,i)},o.centroid=function(t,e,i,s){return o.add(t,e,i),o.add(t,t,s),o.scale(t,t,1/3),t},o.create=function(){var t=new s.ARRAY_TYPE(2);return t[0]=0,t[1]=0,t},o.clone=function(t){var e=new s.ARRAY_TYPE(2);return e[0]=t[0],e[1]=t[1],e},o.fromValues=function(t,e){var i=new s.ARRAY_TYPE(2);return i[0]=t,i[1]=e,i},o.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},o.set=function(t,e,i){return t[0]=e,t[1]=i,t},o.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t},o.subtract=function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t},o.sub=o.subtract,o.multiply=function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t},o.mul=o.multiply,o.divide=function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t},o.div=o.divide,o.scale=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t},o.distance=function(t,e){var i=e[0]-t[0],s=e[1]-t[1];return Math.sqrt(i*i+s*s)},o.dist=o.distance,o.squaredDistance=function(t,e){var i=e[0]-t[0],s=e[1]-t[1];return i*i+s*s},o.sqrDist=o.squaredDistance,o.length=function(t){var e=t[0],i=t[1];return Math.sqrt(e*e+i*i)},o.len=o.length,o.squaredLength=function(t){var e=t[0],i=t[1];return e*e+i*i},o.sqrLen=o.squaredLength,o.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},o.normalize=function(t,e){var i=e[0],s=e[1],n=i*i+s*s;return 0this.sleepTimeLimit&&(e?this.wantsToSleep=!0:this.sleep())}},a.prototype.overlaps=function(t){return this.world.overlapKeeper.bodiesAreOverlapping(this,t)};var T=u.create(),P=u.create();a.prototype.integrate=function(t){var e=this.invMass,i=this.force,s=this.position,n=this.velocity;u.copy(this.previousPosition,this.position),this.previousAngle=this.angle,this.fixedRotation||(this.angularVelocity+=this.angularForce*this.invInertia*t),u.scale(T,i,t*e),u.multiply(T,this.massMultiplier,T),u.add(n,T,n),this.integrateToTimeOfImpact(t)||(u.scale(P,n,t),u.add(s,s,P),this.fixedRotation||(this.angle+=this.angularVelocity*t)),this.aabbNeedsUpdate=!0};var C=new s,S=new n({mode:n.ALL}),A=u.create(),E=u.create(),M=u.create(),R=u.create();a.prototype.integrateToTimeOfImpact=function(t){if(this.ccdSpeedThreshold<0||u.squaredLength(this.velocity)p&&(w.sub(a,o,h),w.normalize(a,a),e.reportIntersection(t,f,a,-1),t.shouldStop(e)))return}else{var v=Math.sqrt(f),x=1/(2*g),b=(-m-v)*x,_=(-m+v)*x;if(0<=b&&b<=1&&(w.lerp(o,n,r,b),w.squaredDistance(o,i)>p&&(w.sub(a,o,h),w.normalize(a,a),e.reportIntersection(t,b,a,-1),t.shouldStop(e))))return;if(0<=_&&_<=1&&(w.lerp(o,n,r,_),w.squaredDistance(o,i)>p&&(w.sub(a,o,h),w.normalize(a,a),e.reportIntersection(t,_,a,-1),t.shouldStop(e))))return}}}},{"../math/vec2":30,"./Shape":45}],39:[function(t,e,i){var s=t("./Shape"),y=t("../math/vec2");function n(t){"number"==typeof t&&(t={radius:t},console.warn("The Circle constructor signature has changed. Please use the following format: new Circle({ radius: 1 })")),t=t||{},this.radius=t.radius||1,t.type=s.CIRCLE,s.call(this,t)}(((e.exports=n).prototype=new s).constructor=n).prototype.computeMomentOfInertia=function(t){var e=this.radius;return t*e*e/2},n.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius},n.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius},n.prototype.computeAABB=function(t,e,i){var s=this.radius;y.set(t.upperBound,s,s),y.set(t.lowerBound,-s,-s),e&&(y.add(t.lowerBound,t.lowerBound,e),y.add(t.upperBound,t.upperBound,e))};var v=y.create(),x=y.create();n.prototype.raycast=function(t,e,i,s){var n=e.from,r=e.to,o=this.radius,a=Math.pow(r[0]-n[0],2)+Math.pow(r[1]-n[1],2),h=2*((r[0]-n[0])*(n[0]-i[0])+(r[1]-n[1])*(n[1]-i[1])),l=Math.pow(n[0]-i[0],2)+Math.pow(n[1]-i[1],2)-Math.pow(o,2),c=Math.pow(h,2)-4*a*l,u=v,d=x;if(!(c<0))if(0===c)y.lerp(u,n,r,c),y.sub(d,u,i),y.normalize(d,d),e.reportIntersection(t,c,d,-1);else{var p=Math.sqrt(c),f=1/(2*a),g=(-h-p)*f,m=(-h+p)*f;if(0<=g&&g<=1&&(y.lerp(u,n,r,g),y.sub(d,u,i),y.normalize(d,d),e.reportIntersection(t,g,d,-1),t.shouldStop(e)))return;0<=m&&m<=1&&(y.lerp(u,n,r,m),y.sub(d,u,i),y.normalize(d,d),e.reportIntersection(t,m,d,-1))}}},{"../math/vec2":30,"./Shape":45}],40:[function(t,e,i){var h=t("./Shape"),p=t("../math/vec2"),a=t("../math/polyk");t("poly-decomp");function d(t){Array.isArray(t)&&(t={vertices:t,axes:arguments[1]},console.warn("The Convex constructor signature has changed. Please use the following format: new Convex({ vertices: [...], ... })")),t=t||{},this.vertices=[];for(var e=void 0!==t.vertices?t.vertices:[],i=0;it;)e.pop();for(;e.length=t&&s=this.children.length)throw new Error("The supplied index is out of bounds");var i=this.getChildIndex(t);this.children.splice(i,1),this.children.splice(e,0,t)},O.DisplayObjectContainer.prototype.getChildAt=function(t){if(t<0||t>=this.children.length)throw new Error("getChildAt: Supplied index "+t+" does not exist in the child list, or the supplied DisplayObject must be a child of the caller");return this.children[t]},O.DisplayObjectContainer.prototype.removeChild=function(t){var e=this.children.indexOf(t);if(-1!==e)return this.removeChildAt(e)},O.DisplayObjectContainer.prototype.removeChildAt=function(t){var e=this.getChildAt(t);return e&&(e.parent=void 0,this.children.splice(t,1)),e},O.DisplayObjectContainer.prototype.bringChildToTop=function(t){if(t.parent===this)return this.setChildIndex(t,this.children.length-1)},O.DisplayObjectContainer.prototype.sendChildToBack=function(t){if(t.parent===this)return this.setChildIndex(t,0)},O.DisplayObjectContainer.prototype.removeChildren=function(t,e){void 0===t&&(t=0),void 0===e&&(e=this.children.length);var i=e-t;if(0= "+this.MAX_TEXTURES+".0) { gl_FragColor = BLUE;return;}"," if(isnan(vTextureIndex)) { gl_FragColor = RED;return;}","}"];var s=O.compileProgram(t,this.vertexSrc||O.PixiShader.defaultVertexSrc,this.fragmentSrc);t.useProgram(s),this.uSamplerArray=t.getUniformLocation(s,"uSamplerArray[0]"),this.projectionVector=t.getUniformLocation(s,"projectionVector"),this.offsetVector=t.getUniformLocation(s,"offsetVector"),this.dimensions=t.getUniformLocation(s,"dimensions"),this.aVertexPosition=t.getAttribLocation(s,"aVertexPosition"),this.aTextureCoord=t.getAttribLocation(s,"aTextureCoord"),this.colorAttribute=t.getAttribLocation(s,"aColor"),this.aTextureIndex=t.getAttribLocation(s,"aTextureIndex");var n=[],r=t.createTexture();t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,r),t.texImage2D(t.TEXTURE_2D,0,t.RGB,1,1,0,t.RGB,t.UNSIGNED_BYTE,null);for(var o=0;o 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;","}"],O.PixiFastShader=function(t){if(this._UID=Phaser._UID++,this.gl=t,this.program=null,O._enableMultiTextureToggle){t=this.gl;this.MAX_TEXTURES=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);for(var e="\tif (vTextureIndex == 0.0) { gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;return;}\n",i=1;i= "+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()},O.PixiFastShader.prototype.constructor=O.PixiFastShader,O.PixiFastShader.prototype.init=function(){var t=this.gl,e=O.compileProgram(t,this.vertexSrc,this.fragmentSrc);if(t.useProgram(e),this.uSampler=O._enableMultiTextureToggle?t.getUniformLocation(e,"uSamplerArray[0]"):t.getUniformLocation(e,"uSampler"),O._enableMultiTextureToggle){var i=[],s=t.createTexture();t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,s),t.texImage2D(t.TEXTURE_2D,0,t.RGB,1,1,0,t.RGB,t.UNSIGNED_BYTE,null);for(var n=0;n= "+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()},O.StripShader.prototype.constructor=O.StripShader,O.StripShader.prototype.init=function(){var t=this.gl,e=O.compileProgram(t,this.vertexSrc,this.fragmentSrc);if(t.useProgram(e),this.uSampler=O._enableMultiTextureToggle?t.getUniformLocation(e,"uSamplerArray[0]"):t.getUniformLocation(e,"uSampler"),O._enableMultiTextureToggle){var i=[],s=t.createTexture();t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,s),t.texImage2D(t.TEXTURE_2D,0,t.RGB,1,1,0,t.RGB,t.UNSIGNED_BYTE,null);for(var n=0;n>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t},i=this.gl,s=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),n=i.getParameter(i.MAX_TEXTURE_SIZE),r=this.game.cache._cache.image,o=null,a=0;a=this.size&&(this.flush(),this.currentBaseTexture=i.baseTexture);var o=i._uvs;if(o){var a,h,l,c,u=t.anchor.x,d=t.anchor.y;if(i.trim){var p=i.trim;a=(h=p.x-u*p.width)+i.crop.width,l=(c=p.y-d*p.height)+i.crop.height}else a=i.frame.width*(1-u),h=i.frame.width*-u,l=i.frame.height*(1-d),c=i.frame.height*-d;var f=this.currentBatchSize*this.vertexSize,g=i.baseTexture.resolution,m=i.baseTexture.textureIndex,y=r.a/g,v=r.b/g,x=r.c/g,b=r.d/g,_=r.tx,w=r.ty,T=i.crop.height;if(i.rotated){var P=r.a,C=r.b,S=r.c,A=r.d,E=h,M=a;_=r.c*T+_,w=r.d*T+w,y=6123233995736766e-32*P-S,v=6123233995736766e-32*C-A,x=P+6123233995736766e-32*S,b=C+6123233995736766e-32*A,i._updateUvsInverted(),a=l,h=c,l=M,c=E}var R=this.colors,L=this.positions,B=t.tint,I=(B>>16)+(65280&B)+((255&B)<<16)+(255*t.worldAlpha<<24);this.renderSession.roundPixels?(L[f++]=y*h+x*c+_|0,L[f++]=b*c+v*h+w|0,L[f++]=o.x0,L[f++]=o.y0,R[f++]=I,L[f++]=m,L[f++]=y*a+x*c+_|0,L[f++]=b*c+v*a+w|0,L[f++]=o.x1,L[f++]=o.y1,R[f++]=I,L[f++]=m,L[f++]=y*a+x*l+_|0,L[f++]=b*l+v*a+w|0,L[f++]=o.x2,L[f++]=o.y2,R[f++]=I,L[f++]=m,L[f++]=y*h+x*l+_|0,L[f++]=b*l+v*h+w|0):(L[f++]=y*h+x*c+_,L[f++]=b*c+v*h+w,L[f++]=o.x0,L[f++]=o.y0,R[f++]=I,L[f++]=m,L[f++]=y*a+x*c+_,L[f++]=b*c+v*a+w,L[f++]=o.x1,L[f++]=o.y1,R[f++]=I,L[f++]=m,L[f++]=y*a+x*l+_,L[f++]=b*l+v*a+w,L[f++]=o.x2,L[f++]=o.y2,R[f++]=I,L[f++]=m,L[f++]=y*h+x*l+_,L[f++]=b*l+v*h+w),L[f++]=o.x3,L[f++]=o.y3,R[f++]=I,L[f++]=m,this.sprites[this.currentBatchSize++]=t}},O.WebGLSpriteBatch.prototype.renderTilingSprite=function(t){var e=t.tilingTexture,i=t.texture.baseTexture.textureIndex;if(O._enableMultiTextureToggle){var s=e.baseTexture,n=this.gl;O.WebGLRenderer.textureArray[i]!=s&&(this.flush(),n.activeTexture(n.TEXTURE0+i),n.bindTexture(n.TEXTURE_2D,s._glTextures[n.id]),O.WebGLRenderer.textureArray[i]=s)}this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=e.baseTexture),t._uvs||(t._uvs=new O.TextureUvs);var r=t._uvs,o=e.baseTexture.width,a=e.baseTexture.height;t.tilePosition.x%=o*t.tileScaleOffset.x,t.tilePosition.y%=a*t.tileScaleOffset.y;var h=t.tilePosition.x/(o*t.tileScaleOffset.x),l=t.tilePosition.y/(a*t.tileScaleOffset.y),c=t.width/o/(t.tileScale.x*t.tileScaleOffset.x),u=t.height/a/(t.tileScale.y*t.tileScaleOffset.y);r.x0=0-h,r.y0=0-l,r.x1=1*c-h,r.y1=0-l,r.x2=1*c-h,r.y2=1*u-l,r.x3=0-h,r.y3=1*u-l;var d=t.tint,p=(d>>16)+(65280&d)+((255&d)<<16)+(255*t.worldAlpha<<24),f=this.positions,g=this.colors,m=t.width,y=t.height,v=t.anchor.x,x=t.anchor.y,b=m*(1-v),_=m*-v,w=y*(1-x),T=y*-x,P=this.currentBatchSize*this.vertexSize,C=e.baseTexture.resolution,S=t.worldTransform,A=S.a/C,E=S.b/C,M=S.c/C,R=S.d/C,L=S.tx,B=S.ty;f[P++]=A*_+M*T+L,f[P++]=R*T+E*_+B,f[P++]=r.x0,f[P++]=r.y0,g[P++]=p,f[P++]=i,f[P++]=A*b+M*T+L,f[P++]=R*T+E*b+B,f[P++]=r.x1,f[P++]=r.y1,g[P++]=p,f[P++]=i,f[P++]=A*b+M*w+L,f[P++]=R*w+E*b+B,f[P++]=r.x2,f[P++]=r.y2,g[P++]=p,f[P++]=i,f[P++]=A*_+M*w+L,f[P++]=R*w+E*_+B,f[P++]=r.x3,f[P++]=r.y3,g[P++]=p,f[P++]=i,this.sprites[this.currentBatchSize++]=t},O.WebGLSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var t,e,i,s,n=this.gl;if(this.dirty){this.dirty=!1,t=this.defaultShader.shaders[n.id],n.activeTexture(n.TEXTURE0),n.bindBuffer(n.ARRAY_BUFFER,this.vertexBuffer),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var r=this.vertexSize;n.vertexAttribPointer(t.aVertexPosition,2,n.FLOAT,!1,r,0),n.vertexAttribPointer(t.aTextureCoord,2,n.FLOAT,!1,r,8),n.vertexAttribPointer(t.colorAttribute,4,n.UNSIGNED_BYTE,!0,r,16),n.vertexAttribPointer(t.aTextureIndex,1,n.FLOAT,!1,r,20)}if(this.currentBatchSize>.5*this.size)n.bufferSubData(n.ARRAY_BUFFER,0,this.vertices);else{n.bindBuffer(n.ARRAY_BUFFER,this.vertexBuffer);var o=this.positions.subarray(0,this.currentBatchSize*this.vertexSize);n.bufferSubData(n.ARRAY_BUFFER,0,o)}for(var a,h=0,l=0,c=null,u=this.renderSession.blendModeManager.currentBlendMode,d=null,p=!1,f=!1,g=0,m=this.currentBatchSize;g=this.size&&this.flush()}},O.WebGLFastSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var t=this.gl;if(this.currentBaseTexture._glTextures[t.id]){if(this.currentBatchSize>.5*this.size)t.bufferSubData(t.ARRAY_BUFFER,0,this.vertices);else{var e=this.vertices.subarray(0,4*this.currentBatchSize*this.vertSize);t.bufferSubData(t.ARRAY_BUFFER,0,e)}t.drawElements(t.TRIANGLES,6*this.currentBatchSize,t.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++}else this.renderSession.renderer.updateTexture(this.currentBaseTexture,t)}},O.WebGLFastSpriteBatch.prototype.stop=function(){this.flush()},O.WebGLFastSpriteBatch.prototype.start=function(){var t=this.gl;t.activeTexture(t.TEXTURE0),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var e=this.renderSession.projection;t.uniform2f(this.shader.projectionVector,e.x,e.y),t.uniformMatrix3fv(this.shader.uMatrix,!1,this.matrix);var i=4*this.vertSize;t.vertexAttribPointer(this.shader.aVertexPosition,2,t.FLOAT,!1,i,0),t.vertexAttribPointer(this.shader.aPositionCoord,2,t.FLOAT,!1,i,8),t.vertexAttribPointer(this.shader.aScale,2,t.FLOAT,!1,i,16),t.vertexAttribPointer(this.shader.aRotation,1,t.FLOAT,!1,i,24),t.vertexAttribPointer(this.shader.aTextureCoord,2,t.FLOAT,!1,i,28),t.vertexAttribPointer(this.shader.colorAttribute,1,t.FLOAT,!1,i,36),t.vertexAttribPointer(this.shader.aTextureIndex,1,t.FLOAT,!1,i,40)},O.WebGLFilterManager=function(){this.filterStack=[],this.offsetX=0,this.offsetY=0},O.WebGLFilterManager.prototype.constructor=O.WebGLFilterManager,O.WebGLFilterManager.prototype.setContext=function(t){this.gl=t,this.texturePool=[],this.initShaderBuffers()},O.WebGLFilterManager.prototype.begin=function(t,e){this.renderSession=t,this.defaultShader=t.shaderManager.defaultShader;var i=this.renderSession.projection;this.width=2*i.x,this.height=2*-i.y,this.buffer=e},O.WebGLFilterManager.prototype.pushFilter=function(t){var e=this.gl,i=this.renderSession.projection,s=this.renderSession.offset;t._filterArea=t.target.filterArea||t.target.getBounds(),t._previous_stencil_mgr=this.renderSession.stencilManager,this.renderSession.stencilManager=new O.WebGLStencilManager,this.renderSession.stencilManager.setContext(e),e.disable(e.STENCIL_TEST),this.filterStack.push(t);var n=t.filterPasses[0];this.offsetX+=t._filterArea.x,this.offsetY+=t._filterArea.y;var r=this.texturePool.pop();r?r.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution):r=new O.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution),e.bindTexture(e.TEXTURE_2D,r.texture);var o=t._filterArea,a=n.padding;o.x-=a,o.y-=a,o.width+=2*a,o.height+=2*a,o.x<0&&(o.x=0),o.width>this.width&&(o.width=this.width),o.y<0&&(o.y=0),o.height>this.height&&(o.height=this.height),e.bindFramebuffer(e.FRAMEBUFFER,r.frameBuffer),e.viewport(0,0,o.width*this.renderSession.resolution,o.height*this.renderSession.resolution),i.x=o.width/2,i.y=-o.height/2,s.x=-o.x,s.y=-o.y,e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),t._glFilterTexture=r},O.WebGLFilterManager.prototype.popFilter=function(){var t=this.gl,e=this.filterStack.pop(),i=e._filterArea,s=e._glFilterTexture,n=this.renderSession.projection,r=this.renderSession.offset;if(1this.baseTexture.width||t.y+t.height>this.baseTexture.height))this.valid=t&&t.width&&t.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();else{if(!O.TextureSilentFail)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.valid=!1}},O.Texture.prototype._updateUvs=function(){this._uvs||(this._uvs=new O.TextureUvs);var t=this.crop,e=this.baseTexture.width,i=this.baseTexture.height;this._uvs.x0=t.x/e,this._uvs.y0=t.y/i,this._uvs.x1=(t.x+t.width)/e,this._uvs.y1=t.y/i,this._uvs.x2=(t.x+t.width)/e,this._uvs.y2=(t.y+t.height)/i,this._uvs.x3=t.x/e,this._uvs.y3=(t.y+t.height)/i},O.Texture.prototype._updateUvsInverted=function(){this._uvs||(this._uvs=new O.TextureUvs);var t=this.crop,e=this.baseTexture.width,i=this.baseTexture.height;this._uvs.x0=t.x/e,this._uvs.y0=t.y/i,this._uvs.x1=(t.x+t.height)/e,this._uvs.y1=t.y/i,this._uvs.x2=(t.x+t.height)/e,this._uvs.y2=(t.y+t.width)/i,this._uvs.x3=t.x/e,this._uvs.y3=(t.y+t.width)/i},O.Texture.fromCanvas=function(t,e){var i=O.BaseTexture.fromCanvas(t,e);return new O.Texture(i)},O.TextureUvs=function(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y3=0},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=O),exports.PIXI=O):"undefined"!=typeof define&&define.amd?define("PIXI",t.PIXI=O):t.PIXI=O,O}.call(this),function(){var r,t=this,X=X||{VERSION:"2.20.0",AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,WEBGL_MULTI:4,NONE:0,LEFT:1,RIGHT:2,UP:3,DOWN:4,SPRITE:0,BUTTON:1,IMAGE:2,GRAPHICS:3,TEXT:4,TILESPRITE:5,BITMAPTEXT:6,GROUP:7,RENDERTEXTURE:8,TILEMAP:9,TILEMAPLAYER:10,EMITTER:11,POLYGON:12,BITMAPDATA:13,CANVAS_FILTER:14,WEBGL_FILTER:15,ELLIPSE:16,SPRITEBATCH:17,RETROFONT:18,POINTER:19,ROPE:20,CIRCLE:21,RECTANGLE:22,LINE:23,MATRIX:24,POINT:25,ROUNDEDRECTANGLE:26,CREATURE:27,VIDEO:28,PENDING_ATLAS:-1,HORIZONTAL:0,VERTICAL:1,LANDSCAPE:0,PORTRAIT:1,ANGLE_UP:270,ANGLE_DOWN:90,ANGLE_LEFT:180,ANGLE_RIGHT:0,ANGLE_NORTH_EAST:315,ANGLE_NORTH_WEST:225,ANGLE_SOUTH_EAST:45,ANGLE_SOUTH_WEST:135,TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12,blendModes:{NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16},scaleModes:{DEFAULT:0,LINEAR:0,NEAREST:1},PIXI:PIXI||{},_UID:0,_ID:0};if("undefined"!=typeof AudioBufferSourceNode&&(AudioBufferSourceNode.prototype.start||(AudioBufferSourceNode.prototype.start=AudioBufferSourceNode.prototype.noteGrainOn),AudioBufferSourceNode.prototype.stop||(AudioBufferSourceNode.prototype.stop=AudioBufferSourceNode.prototype.noteOff)),Math.trunc||(Math.trunc=function(t){return t<0?Math.ceil(t):Math.floor(t)}),Function.prototype.bind||(Function.prototype.bind=(r=Array.prototype.slice,function(e){var i=this,s=r.call(arguments,1);if("function"!=typeof i)throw new TypeError;function n(){var t=s.concat(r.call(arguments));i.apply(this instanceof n?this:e,t)}return n.prototype=function t(e){if(e&&(t.prototype=e),!(this instanceof t))return new t}(i.prototype),n})),Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),Array.prototype.forEach||(Array.prototype.forEach=function(t){"use strict";if(null==this)throw new TypeError;var e=Object(this),i=e.length>>>0;if("function"!=typeof t)throw new TypeError;for(var s=2<=arguments.length?arguments[1]:void 0,n=0;n=(t=t.toString()).length)switch(s){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var r=Math.ceil((n=e-t.length)/2);t=new Array(n-r+1).join(i)+t+new Array(r+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t},isPlainObject:function(t){if("object"!=typeof t||t.nodeType||t===t.window)return!1;try{if(t.constructor&&!{}.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0},extend:function(){var t,e,i,s,n,r,o=arguments[0]||{},a=1,h=arguments.length,l=!1;for("boolean"==typeof o&&(l=o,o=arguments[1]||{},a=2),h===a&&(o=this,--a);athis.x?(this._radius=0,this._diameter=0):this.radius=this.x-t}}),Object.defineProperty(X.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(t){tthis.y?(this._radius=0,this._diameter=0):this.radius=this.y-t}}),Object.defineProperty(X.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(t){t=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius},X.Circle.equals=function(t,e){return t.x===e.x&&t.y===e.y&&t.diameter===e.diameter},X.Circle.intersects=function(t,e){return X.Math.distance(t.x,t.y,e.x,e.y)<=t.radius+e.radius},X.Circle.circumferencePoint=function(t,e,i,s){return void 0===i&&(i=!1),void 0===s&&(s=new X.Point),!0===i&&(e=X.Math.degToRad(e)),s.x=t.x+t.radius*Math.cos(e),s.y=t.y+t.radius*Math.sin(e),s},X.Circle.intersectsRectangle=function(t,e){var i=Math.abs(t.x-e.x-e.halfWidth);if(e.halfWidth+t.radiuss&&(this.x=s),this.yn&&(this.y=n),this},clone:function(t){return null==t?t=new X.Point(this.x,this.y):t.setTo(this.x,this.y),t},copyTo:function(t){return t.x=this.x,t.y=this.y,t},distance:function(t,e){return X.Point.distance(this,t,e)},equals:function(t){return t.x===this.x&&t.y===this.y},equalsXY:function(t,e){return this.x===t&&this.y===e},fuzzyEquals:function(t,e){return X.Point.fuzzyEquals(this,t,e)},fuzzyEqualsXY:function(t,e,i){return X.Point.fuzzyEqualsXY(this,t,e,i)},angle:function(t,e){return this.angleXY(t.x,t.y,e)},angleXY:function(t,e,i){var s=Math.atan2(e-this.y,t-this.x);return i?X.Math.radToDeg(s):s},atan:function(t){var e=Math.atan2(this.y,this.x);return t?X.Math.radToDeg(e):e},rotate:function(t,e,i,s,n){return X.Point.rotate(this,t,e,i,s,n)},getMagnitude:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},getMagnitudeSq:function(){return this.x*this.x+this.y*this.y},setMagnitude:function(t){return this.normalize().multiply(t,t)},normalize:function(){if(!this.isZero()){var t=this.getMagnitude();this.x/=t,this.y/=t}return this},limit:function(t){return this.getMagnitudeSq()>t*t&&this.setMagnitude(t),this},expand:function(t){return this.getMagnitudeSq()e.y?1:-1:e.y>t.y?1:-1;var i=(t.x-n)*-(e.y-r)-(e.x-n)*-(t.y-r);if(i<0)return-1;if(0=this.right?this.width=0:this.width=this.right-t,this.x=t}}),Object.defineProperty(X.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}}),Object.defineProperty(X.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}}),Object.defineProperty(X.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}}),Object.defineProperty(X.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(t){this.x=t-this.halfWidth}}),Object.defineProperty(X.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(t){this.y=t-this.halfHeight}}),Object.defineProperty(X.Rectangle.prototype,"randomX",{get:function(){return this.x+Math.random()*this.width}}),Object.defineProperty(X.Rectangle.prototype,"randomY",{get:function(){return this.y+Math.random()*this.height}}),Object.defineProperty(X.Rectangle.prototype,"top",{get:function(){return this.y},set:function(t){t>=this.bottom?(this.height=0,this.y=t):this.height=this.bottom-t}}),Object.defineProperty(X.Rectangle.prototype,"topLeft",{get:function(){return new X.Point(this.x,this.y)},set:function(t){this.x=t.x,this.y=t.y}}),Object.defineProperty(X.Rectangle.prototype,"topRight",{get:function(){return new X.Point(this.x+this.width,this.y)},set:function(t){this.right=t.x,this.y=t.y}}),Object.defineProperty(X.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(t){!0===t&&this.setTo(0,0,0,0)}}),X.Rectangle.prototype.constructor=X.Rectangle,X.Rectangle.inflate=function(t,e,i){return t.x-=e,t.width+=2*e,t.y-=i,t.height+=2*i,t},X.Rectangle.inflatePoint=function(t,e){return X.Rectangle.inflate(t,e.x,e.y)},X.Rectangle.size=function(t,e){return null==e?e=new X.Point(t.width,t.height):e.setTo(t.width,t.height),e},X.Rectangle.clone=function(t,e){return null==e?e=new X.Rectangle(t.x,t.y,t.width,t.height):e.setTo(t.x,t.y,t.width,t.height),e},X.Rectangle.createFromBounds=function(t,e){return null==e&&(e=new X.Rectangle(t.x,t.y,t.width,t.height)),e.copyFromBounds(t)},X.Rectangle.contains=function(t,e,i){return!(t.width<=0||t.height<=0)&&(e>=t.x&&e=t.y&&ie.volume)&&(t.x>=e.x&&t.y>=e.y&&t.righte.right||t.y>e.bottom)},X.Rectangle.intersectsRaw=function(t,e,i,s,n,r){return void 0===r&&(r=0),!(e>t.right+r||it.bottom+r||ni&&(i=t.x),t.xn&&(n=t.y),t.ythis.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 t=this.view.x+this._shake.x,e=this.view.right+this._shake.x,i=this.view.y+this._shake.y,s=this.view.bottom+this._shake.y;t<=this.bounds.x*this.scale.x?(this.atLimit.x=!0,this.view.x=this.bounds.x*this.scale.x,this._shake.shakeBounds||(this._shake.x=0)):e>=this.bounds.right*this.scale.x&&(this.atLimit.x=!0,this.view.x=this.bounds.right*this.scale.x-this.width,this._shake.shakeBounds||(this._shake.x=0)),i<=this.bounds.top*this.scale.y?(this.atLimit.y=!0,this.view.y=this.bounds.top*this.scale.y,this._shake.shakeBounds||(this._shake.y=0)):s>=this.bounds.bottom*this.scale.y&&(this.atLimit.y=!0,this.view.y=this.bounds.bottom*this.scale.y-this.height,this._shake.shakeBounds||(this._shake.y=0))},setPosition:function(t,e){this.view.x=t,this.view.y=e,this.bounds&&this.checkBounds()},setSize:function(t,e){this.view.width=t,this.view.height=e},reset:function(){this.target=null,this.view.x=0,this.view.y=0,this._shake.duration=0,this._shake.x=0,this._shake.y=0,this.resetFX()},resetFX:function(){this.fx&&(this.fx.clear(),this.fx.alpha=0),this._fxDuration=0}},X.Camera.prototype.constructor=X.Camera,Object.defineProperty(X.Camera.prototype,"x",{get:function(){return this.view.x},set:function(t){this.view.x=t,this.bounds&&this.checkBounds()}}),Object.defineProperty(X.Camera.prototype,"y",{get:function(){return this.view.y},set:function(t){this.view.y=t,this.bounds&&this.checkBounds()}}),Object.defineProperty(X.Camera.prototype,"position",{get:function(){return this._position.set(this.view.x,this.view.y),this._position},set:function(t){void 0!==t.x&&(this.view.x=t.x),void 0!==t.y&&(this.view.y=t.y),this.bounds&&this.checkBounds()}}),Object.defineProperty(X.Camera.prototype,"width",{get:function(){return this.view.width},set:function(t){this.view.width=t}}),Object.defineProperty(X.Camera.prototype,"height",{get:function(){return this.view.height},set:function(t){this.view.height=t}}),Object.defineProperty(X.Camera.prototype,"shakeIntensity",{get:function(){return this._shake.intensity},set:function(t){this._shake.intensity=t}}),Object.defineProperty(X.Camera.prototype,"fixedView",{get:function(){return this._fixedView.setTo(0,0,this.view.width,this.view.height),this._fixedView}}),Object.defineProperty(X.Camera.prototype,"centerX",{get:function(){return this.x+.5*this.width}}),Object.defineProperty(X.Camera.prototype,"centerY",{get:function(){return this.y+.5*this.height}}),X.State=function(){this.game=null,this.key="",this.add=null,this.make=null,this.camera=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.sound=null,this.scale=null,this.stage=null,this.state=null,this.time=null,this.tweens=null,this.world=null,this.particles=null,this.physics=null,this.rnd=null},X.State.prototype={init:function(){},preload:function(){},loadUpdate:function(){},loadRender:function(){},create:function(){},update:function(){},postUpdate:function(){},preRender:function(){},render:function(){},resize:function(){},paused:function(){},resumed:function(){},pauseUpdate:function(){},shutdown:function(){}},X.State.prototype.constructor=X.State,X.StateManager=function(t,e){this.game=t,this.states={},(this._pendingState=null)!=e&&(this._pendingState=e),this._clearWorld=!1,this._clearCache=!1,this._created=!1,this._args=[],this.current="",this.onStateChange=new X.Signal,this.onInitCallback=null,this.onPreloadCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPreRenderCallback=null,this.onLoadUpdateCallback=null,this.onLoadRenderCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null,this.onShutDownCallback=null},X.StateManager.prototype={boot:function(){this.game.onPause.add(this.pause,this),this.game.onResume.add(this.resume,this),null!==this._pendingState&&"string"!=typeof this._pendingState&&this.add("default",this._pendingState,!0)},add:function(t,e,i){var s;return void 0===i&&(i=!1),e instanceof X.State?s=e:"object"==typeof e?(s=e).game=this.game:"function"==typeof e&&(s=new e(this.game)),this.states[t]=s,i&&(this.game.isBooted?this.start(t):this._pendingState=t),s},remove:function(t){this.current===t&&(this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onPreRenderCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null),delete this.states[t]},start:function(t,e,i){void 0===e&&(e=!0),void 0===i&&(i=!1),this.checkState(t)&&(this._pendingState=t,this._clearWorld=e,this._clearCache=i,3=this.children.length?-1:this.getChildAt(t)},X.Group.prototype.create=function(t,e,i,s,n,r){void 0===n&&(n=!0);var o=new this.classType(this.game,t,e,i,s);return o.exists=n,o.visible=n,o.alive=n,this.add(o,!1,r)},X.Group.prototype.createMultiple=function(n,t,e,r,o,a){void 0===e&&(e=0),void 0===r&&(r=!1),Array.isArray(t)||(t=[t]),Array.isArray(e)||(e=[e]);var h=this,l=[];return t.forEach(function(s){e.forEach(function(t){for(var e=0;ethis.children.length||-1===t&&-1===e)return!1;for(var o=new X.Rectangle(0,0,i,s),a=t*i,h=e*s,l=r;lthis.children.length-1&&(t=0),this.cursor)return this.cursorIndex=t,this.cursor=this.children[this.cursorIndex],this.cursor},X.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],this.cursor},X.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],this.cursor},X.Group.prototype.swap=function(t,e){this.swapChildren(t,e),this.updateZ()},X.Group.prototype.bringToTop=function(t){return t.parent===this&&this.getIndex(t)this.children.length)return-1;this.getChildAt(t).x=e,this.getChildAt(t).y=i},X.Group.prototype.reverse=function(){this.children.reverse(),this.updateZ()},X.Group.prototype.getIndex=function(t){return this.children.indexOf(t)},X.Group.prototype.getByName=function(t){return this.getFirst("name",t)},X.Group.prototype.replace=function(t,e){var i=this.getIndex(t);if(-1!==i)return e.parent&&(e.parent instanceof X.Group?e.parent.remove(e):e.parent.removeChild(e)),this.remove(t),this.addAt(e,i),t},X.Group.prototype.hasProperty=function(t,e){var i=e.length;return 1===i&&e[0]in t||(2===i&&e[0]in t&&e[1]in t[e[0]]||(3===i&&e[0]in t&&e[1]in t[e[0]]&&e[2]in t[e[0]][e[1]]||4===i&&e[0]in t&&e[1]in t[e[0]]&&e[2]in t[e[0]][e[1]]&&e[3]in t[e[0]][e[1]][e[2]]))},X.Group.prototype.setProperty=function(t,e,i,s,n){if(void 0===n&&(n=!1),s=s||0,!this.hasProperty(t,e)&&(!n||0e[this._sortProperty]?1:t.ze[this._sortProperty]?-1:0},X.Group.prototype.iterate=function(t,e,i,s,n,r){if(0===this.children.length){if(i===X.Group.RETURN_TOTAL)return 0;if(i===X.Group.RETURN_ALL)return[]}var o=0;if(i===X.Group.RETURN_ALL)var a=[];for(var h=0;hthis.children.length)return!1;for(var n=e;t<=n;){!s&&this.children[n].events&&this.children[n].events.onRemovedFromGroup$dispatch(this.children[n],this);var r=this.removeChild(this.children[n]);this.removeFromHash(r),i&&r&&r.destroy(!0),this.cursor===this.children[n]&&(this.cursor=null),n--}this.updateZ()}},X.Group.prototype.scatter=function(e,t){null==e&&(e=this.game.world.bounds),this.forEach(function(t){t.position.set(e.randomX,e.randomY)},null,t)},X.Group.prototype.shuffle=function(){X.ArrayUtils.shuffle(this.children),this.updateZ()},X.Group.prototype.destroy=function(t,e){null===this.game||this.ignoreDestroy||(void 0===t&&(t=!0),void 0===e&&(e=!1),this.onDestroy.dispatch(this,t,e),this.removeAll(t),this.cursor=null,this.filters=null,this.pendingDestroy=!1,e||(this.parent&&this.parent.removeChild(this),this.game=null,this.exists=!1))},Object.defineProperty(X.Group.prototype,"total",{get:function(){return this.iterate("exists",!0,X.Group.RETURN_TOTAL)}}),Object.defineProperty(X.Group.prototype,"length",{get:function(){return this.children.length}}),Object.defineProperty(X.Group.prototype,"angle",{get:function(){return X.Math.radToDeg(this.rotation)},set:function(t){this.rotation=X.Math.degToRad(t)}}),Object.defineProperty(X.Group.prototype,"centerX",{get:function(){return this.getBounds(this.parent).centerX},set:function(t){var e=this.getBounds(this.parent),i=this.x-e.x;this.x=t+i-e.halfWidth}}),Object.defineProperty(X.Group.prototype,"centerY",{get:function(){return this.getBounds(this.parent).centerY},set:function(t){var e=this.getBounds(this.parent),i=this.y-e.y;this.y=t+i-e.halfHeight}}),Object.defineProperty(X.Group.prototype,"left",{get:function(){return this.getBounds(this.parent).left},set:function(t){var e=this.getBounds(this.parent),i=this.x-e.x;this.x=t+i}}),Object.defineProperty(X.Group.prototype,"right",{get:function(){return this.getBounds(this.parent).right},set:function(t){var e=this.getBounds(this.parent),i=this.x-e.x;this.x=t+i-e.width}}),Object.defineProperty(X.Group.prototype,"top",{get:function(){return this.getBounds(this.parent).top},set:function(t){var e=this.getBounds(this.parent),i=this.y-e.y;this.y=t+i}}),Object.defineProperty(X.Group.prototype,"bottom",{get:function(){return this.getBounds(this.parent).bottom},set:function(t){var e=this.getBounds(this.parent),i=this.y-e.y;this.y=t+i-e.height}}),X.World=function(t){X.Group.call(this,t,null,"__world",!1),this.bounds=new X.Rectangle(0,0,t.width,t.height),this.camera=null,this._definedSize=!1,this._width=t.width,this._height=t.height,this.game.state.onStateChange.add(this.stateChange,this)},X.World.prototype=Object.create(X.Group.prototype),X.World.prototype.constructor=X.World,X.World.prototype.boot=function(){this.camera=new X.Camera(this.game,0,0,0,this.game.width,this.game.height),this.game.stage.addChild(this),this.camera.boot()},X.World.prototype.stateChange=function(){this.x=0,this.y=0,this.camera.reset()},X.World.prototype.setBounds=function(t,e,i,s){this._definedSize=!0,this._width=i,this._height=s,this.bounds.setTo(t,e,i,s),this.x=t,this.y=e,this.camera.bounds&&this.camera.bounds.setTo(t,e,Math.max(i,this.game.width),Math.max(s,this.game.height)),this.game.physics.setBoundsToWorld()},X.World.prototype.resize=function(t,e){this._definedSize&&(tthis.bounds.right&&(t.x=this.bounds.left)),n&&(t.y+t._currentBounds.heightthis.bounds.bottom&&(t.y=this.bounds.top))):(s&&t.x+ethis.bounds.right&&(t.x=this.bounds.left-e),n&&t.y+ethis.bounds.bottom&&(t.y=this.bounds.top-e))},X.World.prototype.wrapAll=function(t,e,i,s,n,r){t.forEach(this.wrap,this,e,i,s,n,r)},Object.defineProperty(X.World.prototype,"width",{get:function(){return this.bounds.width},set:function(t){tthis.time.deltaMax){if(this.dropFrames)return;e=this.time.deltaMax}if(this.forceSingleUpdate)this.updatesThisFrame=1,this.rendersThisFrame=1,this.updateLogic(.001*e/this.time.slowMotion),this.updateRender();else if(2this._nextFpsNotification&&(this._nextFpsNotification=this.time.time+1e4,this.fpsProblemNotifier.dispatch()),this._deltaTime=0,this._spiraling=0;else{var i=0,s=1e3*this.time.desiredFpsMult;for(this._deltaTime+=e,this.updatesThisFrame=Math.floor(this._deltaTime/s),this.rendersThisFrame=this.forceSingleRender?1:Math.min(1,this.updatesThisFrame);this._deltaTime>=s;)this._deltaTime-=s,this.currentUpdateID=i,this.updateLogic(this.time.desiredFpsMult/this.time.slowMotion),this.time.refresh(),i++;i>this._lastCount?this._spiraling++:i=X.Input.MAX_POINTERS)return console.warn("Phaser.Input.addPointer: Maximum limit of "+X.Input.MAX_POINTERS+" pointers reached."),null;var t=this.pointers.length+1,e=new X.Pointer(this.game,t,X.PointerMode.CONTACT);return this.pointers.push(e),this["pointer"+t]=e},update:function(){if(this.keyboard&&this.keyboard.update(),0=this.maxPointers)return null;if(!this.pointer1.active)return this.pointer1.start(t);if(!this.pointer2.active)return this.pointer2.start(t);for(var e=2;e=r&&this.game.camera.x+e.x=o&&this.game.camera.y+e.y=r&&this._localPoint.x=o&&this._localPoint.y=r&&this._localPoint.x=o&&this._localPoint.ythis.game.time.time},justReleased:function(t){return t=t||250,this.isUp&&this.timeUp+t>this.game.time.time},reset:function(){this.isDown=!1,this.isUp=!0,this.timeDown=this.game.time.time,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1},destroy:function(){this.onDown.dispose(),this.onUp.dispose(),this.onFloat.dispose(),this.parent=null,this.game=null}},X.DeviceButton.prototype.constructor=X.DeviceButton,Object.defineProperty(X.DeviceButton.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}}),X.Pointer=function(t,e,i){this.game=t,this.id=e,this.type=X.POINTER,this.exists=!0,this.identifier=0,this.pointerId=null,this.pointerMode=i||X.PointerMode.CURSOR|X.PointerMode.CONTACT,this.target=null,this.button=null,this.leftButton=new X.DeviceButton(this,X.Pointer.LEFT_BUTTON),this.middleButton=new X.DeviceButton(this,X.Pointer.MIDDLE_BUTTON),this.rightButton=new X.DeviceButton(this,X.Pointer.RIGHT_BUTTON),this.backButton=new X.DeviceButton(this,X.Pointer.BACK_BUTTON),this.forwardButton=new X.DeviceButton(this,X.Pointer.FORWARD_BUTTON),this.eraserButton=new X.DeviceButton(this,X.Pointer.ERASER_BUTTON),this._holdSent=!1,this._history=[],this._nextDrop=0,this._stateReset=!1,this.withinGame=!1,this.clientX=-1,this.clientY=-1,this.pageX=-1,this.pageY=-1,this.screenX=-1,this.screenY=-1,this.rawMovementX=0,this.rawMovementY=0,this.movementX=0,this.movementY=0,this.x=-1,this.y=-1,this.isMouse=0===e,this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.previousTapTime=0,this.totalTouches=0,this.msSinceLastClick=Number.MAX_VALUE,this.targetObject=null,this.interactiveCandidates=[],this.active=!1,this.dirty=!1,this.position=new X.Point,this.positionDown=new X.Point,this.positionUp=new X.Point,this.circle=new X.Circle(0,0,44),this._clickTrampolines=null,this._trampolineTargetObject=null},X.Pointer.NO_BUTTON=0,X.Pointer.LEFT_BUTTON=1,X.Pointer.RIGHT_BUTTON=2,X.Pointer.MIDDLE_BUTTON=4,X.Pointer.BACK_BUTTON=8,X.Pointer.FORWARD_BUTTON=16,X.Pointer.ERASER_BUTTON=32,X.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(t,e){switch(t){case X.Mouse.LEFT_BUTTON:this.leftButton.start(e);break;case X.Mouse.RIGHT_BUTTON:this.rightButton.start(e);break;case X.Mouse.MIDDLE_BUTTON:this.middleButton.start(e);break;case X.Mouse.BACK_BUTTON:this.backButton.start(e);break;case X.Mouse.FORWARD_BUTTON:this.forwardButton.start(e)}},processButtonsUp:function(t,e){switch(t){case X.Mouse.LEFT_BUTTON:this.leftButton.stop(e);break;case X.Mouse.RIGHT_BUTTON:this.rightButton.stop(e);break;case X.Mouse.MIDDLE_BUTTON:this.middleButton.stop(e);break;case X.Mouse.BACK_BUTTON:this.backButton.stop(e);break;case X.Mouse.FORWARD_BUTTON:this.forwardButton.stop(e)}},processButtonsUpDown:function(t,e){var i=e.type.toLowerCase().substr(-4),s="down"===i,n="move"===i;void 0!==t?(s&&1===t&&e.ctrlKey&&(t=2),this.leftButton.startStop(X.Pointer.LEFT_BUTTON&t,e),this.rightButton.startStop(X.Pointer.RIGHT_BUTTON&t,e),this.middleButton.startStop(X.Pointer.MIDDLE_BUTTON&t,e),this.backButton.startStop(X.Pointer.BACK_BUTTON&t,e),this.forwardButton.startStop(X.Pointer.FORWARD_BUTTON&t,e),this.eraserButton.startStop(X.Pointer.ERASER_BUTTON&t,e)):void 0!==e.button?s&&e.ctrlKey&&0===e.button?this.rightButton.start(e):s?this.processButtonsDown(e.button,e):n||this.processButtonsUp(e.button,e):s?e.ctrlKey?this.rightButton.start(e):this.leftButton.start(e):(this.leftButton.stop(e),this.rightButton.stop(e))},updateButtons:function(t){this.button=t.button,this.processButtonsUpDown(t.buttons,t),this.isUp=!0,this.isDown=!1,(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(t){var e=this.game.input;return t.pointerId&&(this.pointerId=t.pointerId),this.identifier=t.identifier,this.target=t.target,this.isMouse?this.updateButtons(t):(this.isDown=!0,this.isUp=!1),this.active=!0,this.withinGame=!0,this.dirty=!1,this._history=[],this._clickTrampolines=null,this._trampolineTargetObject=null,this.msSinceLastClick=this.game.time.time-this.timeDown,this.timeDown=this.game.time.time,this._holdSent=!1,this.move(t,!0),this.positionDown.setTo(this.x,this.y),(e.multiInputOverride===X.Input.MOUSE_OVERRIDES_TOUCH||e.multiInputOverride===X.Input.MOUSE_TOUCH_COMBINE||e.multiInputOverride===X.Input.TOUCH_OVERRIDES_MOUSE&&0===e.totalActivePointers)&&(e.x=this.x,e.y=this.y,e.position.setTo(this.x,this.y),e.onDown.dispatch(this,t),e.resetSpeed(this.x,this.y)),this._stateReset=!1,this.totalTouches++,null!==this.targetObject&&this.targetObject._touchedHandler(this),this},update:function(){var t=this.game.input;this.active&&(this.dirty&&(0=t.holdRate&&((t.multiInputOverride===X.Input.MOUSE_OVERRIDES_TOUCH||t.multiInputOverride===X.Input.MOUSE_TOUCH_COMBINE||t.multiInputOverride===X.Input.TOUCH_OVERRIDES_MOUSE&&0===t.totalActivePointers)&&t.onHold.dispatch(this),this._holdSent=!0),t.recordPointerHistory&&this.game.time.time>=this._nextDrop&&(this._nextDrop=this.game.time.time+t.recordRate,this._history.push({x:this.position.x,y:this.position.y}),this._history.length>t.recordLimit&&this._history.shift()))},move:function(t,e){var i=this.game.input;if(!i.pollLocked){void 0===e&&(e=!1),void 0!==t.button&&(this.button=t.button),this.isMouse&&this.updateButtons(t),this.clientX=t.clientX,this.clientY=t.clientY,this.pageX=t.pageX,this.pageY=t.pageY,this.screenX=t.screenX,this.screenY=t.screenY,this.isMouse&&i.pointerLock.locked&&!e&&(this.rawMovementX=t.movementX||t.mozMovementX||t.webkitMovementX||0,this.rawMovementY=t.movementY||t.mozMovementY||t.webkitMovementY||0,this.movementX+=this.rawMovementX,this.movementY+=this.rawMovementY),this.x=(this.pageX-this.game.scale.offset.x)*i.scale.x,this.y=(this.pageY-this.game.scale.offset.y)*i.scale.y,this.position.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,(i.multiInputOverride===X.Input.MOUSE_OVERRIDES_TOUCH||i.multiInputOverride===X.Input.MOUSE_TOUCH_COMBINE||i.multiInputOverride===X.Input.TOUCH_OVERRIDES_MOUSE&&0===i.totalActivePointers)&&(i.activePointer=this,i.x=this.x,i.y=this.y,i.position.setTo(i.x,i.y),i.circle.x=i.x,i.circle.y=i.y),this.withinGame=this.game.scale.bounds.contains(this.pageX,this.pageY);for(var s=i.moveCallbacks.length;s--;)i.moveCallbacks[s].callback.call(i.moveCallbacks[s].context,this,this.x,this.y,e,t);return null===this.targetObject||this.game.paused&&!this.targetObject.noPause||!0!==this.targetObject.isDragged?0this.game.time.time},justReleased:function(t){return t=t||this.game.input.justReleasedRate,this.isUp&&this.timeUp+t>this.game.time.time},addClickTrampoline:function(t,e,i,s){if(this.isDown){for(var n=this._clickTrampolines=this._clickTrampolines||[],r=0;rt||this.priorityID===t&&this.sprite.renderOrderID>e))},isPixelPerfect:function(){return this.pixelPerfectClick||this.pixelPerfectOver},pointerX:function(t){return t=t||0,this._pointerData[t].x},pointerY:function(t){return t=t||0,this._pointerData[t].y},pointerDown:function(t){return t=t||0,this._pointerData[t].isDown},pointerUp:function(t){return t=t||0,this._pointerData[t].isUp},pointerTimeDown:function(t){return t=t||0,this._pointerData[t].timeDown},pointerTimeUp:function(t){return t=t||0,this._pointerData[t].timeUp},pointerOver:function(t){if(!this.enabled)return!1;if(void 0!==t)return this._pointerData[t].isOver;for(var e=0;e<10;e++)if(this._pointerData[e].isOver)return!0;return!1},pointerOut:function(t){if(!this.enabled)return!1;if(void 0!==t)return this._pointerData[t].isOut;for(var e=0;e<10;e++)if(this._pointerData[e].isOut)return!0},pointerTimeOver:function(t){return t=t||0,this._pointerData[t].timeOver},pointerTimeOut:function(t){return t=t||0,this._pointerData[t].timeOut},pointerDragged:function(t){return t=t||0,this._pointerData[t].isDragged},checkPointerDown:function(t,e){return!!(t.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,t,this._tempPoint)&&(void 0===e&&(e=!1),!(!e&&this.pixelPerfectClick)||this.checkPixel(this._tempPoint.x,this._tempPoint.y)))},checkPointerOver:function(t,e){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,t,this._tempPoint)&&(void 0===e&&(e=!1),!(!e&&this.pixelPerfectOver)||this.checkPixel(this._tempPoint.x,this._tempPoint.y)))},checkPixel:function(t,e,i){if(this.sprite.texture.baseTexture.source){if(null===t&&null===e){this.game.input.getLocalPosition(this.sprite,i,this._tempPoint);t=this._tempPoint.x,e=this._tempPoint.y}if(0!==this.sprite.anchor.x&&(t-=-this.sprite.texture.frame.width*this.sprite.anchor.x),0!==this.sprite.anchor.y&&(e-=-this.sprite.texture.frame.height*this.sprite.anchor.y),t+=this.sprite.texture.frame.x,e+=this.sprite.texture.frame.y,this.sprite.texture.trim&&(t-=this.sprite.texture.trim.x,e-=this.sprite.texture.trim.y,tthis.sprite.texture.crop.right||ethis.sprite.texture.crop.bottom))return this._dx=t,this._dy=e,!1;if(this._dx=t,this._dy=e,this.game.input.hitContext.clearRect(0,0,1,1),this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,t,e,1,1,0,0,1,1),this.game.input.hitContext.getImageData(0,0,1,1).data[3]>=this.pixelPerfectAlpha)return!0}return!1},update:function(t){if(null!==this.sprite&&void 0!==this.sprite.parent)return this.enabled&&this.sprite.visible&&this.sprite.parent.visible?this._pendingDrag?(this._dragDistancePass||(this._dragDistancePass=X.Math.distance(t.x,t.y,this.downPoint.x,this.downPoint.y)>=this.dragDistanceThreshold),this._dragDistancePass&&this._dragTimePass&&this.startDrag(t),!0):this.draggable&&this._draggedPointerID===t.id?this.updateDrag(t,!1):this._pointerData[t.id].isOver?this.checkPointerOver(t)?(this._pointerData[t.id].x=t.x-this.sprite.x,this._pointerData[t.id].y=t.y-this.sprite.y,!0):(this._pointerOutHandler(t),!1):void 0:(this._pointerOutHandler(t),!1)},_pointerOverHandler:function(t,e){if(null!==this.sprite){var i=this._pointerData[t.id];if(!1===i.isOver||t.dirty){var s=!1===i.isOver;i.isOver=!0,i.isOut=!1,i.timeOver=this.game.time.time,i.x=t.x-this.sprite.x,i.y=t.y-this.sprite.y,this.useHandCursor&&!1===i.isDragged&&(this.game.canvas.style.cursor="pointer",this._setHandCursor=!0),!e&&s&&this.sprite&&this.sprite.events&&this.sprite.events.onInputOver$dispatch(this.sprite,t),this.sprite.parent&&this.sprite.parent.onChildInputOver&&this.sprite.parent.onChildInputOver.dispatch(this.sprite,t)}}},_pointerOutHandler:function(t,e){if(null!==this.sprite){var i=this._pointerData[t.id];i.isOver=!1,i.isOut=!0,i.timeOut=this.game.time.time,this.useHandCursor&&!1===i.isDragged&&(this.game.canvas.style.cursor="",this._setHandCursor=!1),!e&&this.sprite&&this.sprite.events&&(this.sprite.events.onInputOut$dispatch(this.sprite,t),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputOut&&this.sprite.parent.onChildInputOut.dispatch(this.sprite,t))}},_touchedHandler:function(t){if(null!==this.sprite){var e=this._pointerData[t.id];if(!e.isDown&&e.isOver){if(this.pixelPerfectClick&&!this.checkPixel(null,null,t))return;if(e.isDown=!0,e.isUp=!1,e.timeDown=this.game.time.time,this.downPoint.set(t.x,t.y),t.dirty=!0,this.sprite&&this.sprite.events&&(this.sprite.events.onInputDown$dispatch(this.sprite,t),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputDown&&this.sprite.parent.onChildInputDown.dispatch(this.sprite,t),null===this.sprite))return;this.draggable&&!1===this.isDragged&&(0===this.dragTimeThreshold&&0===this.dragDistanceThreshold?this.startDrag(t):(this._pendingDrag=!0,this._dragDistancePass=0===this.dragDistanceThreshold,0this.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)))}},X.InputHandler.prototype.constructor=X.InputHandler,X.PointerLock=function(t){this.game=t,this.input=t.input,this.element=t.canvas,this.active=!1,this.locked=!1,this.onChange=new X.Signal,this.onError=new X.Signal,this.boundOnChangeHandler=this.onChangeHandler.bind(this),this.boundOnErrorHandler=this.onErrorHandler.bind(this);var e=t.device;this.pointerLockElement=e.pointerLockElement,this.pointerlockchange=e.pointerlockchange,this.pointerlockerror=e.pointerlockerror},X.PointerLock.prototype.start=function(){return!(!this.game.device.pointerLock||this.active)&&(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),this.active=!0)},X.PointerLock.prototype.stop=function(){this.active&&(document.removeEventListener(this.pointerlockchange,this.boundOnChangeHandler,!0),document.removeEventListener(this.pointerlockerror,this.boundOnErrorHandler,!0),this.active=!1)},X.PointerLock.prototype.request=function(){this.active&&!this.locked&&this.element.requestPointerLock()},X.PointerLock.prototype.exit=function(){document.exitPointerLock()},X.PointerLock.prototype.onChangeHandler=function(t){this.locked=document[this.pointerLockElement]===this.element,this.onChange.dispatch(this.locked,t)},X.PointerLock.prototype.onErrorHandler=function(t){this.onError.dispatch(t)},X.Gamepad=function(t){this.game=t,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).onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null,this._ongamepadconnected=null,this._gamepaddisconnected=null,this._gamepads=[new X.SinglePad(t,this),new X.SinglePad(t,this),new X.SinglePad(t,this),new X.SinglePad(t,this)]},X.Gamepad.prototype={addCallbacks:function(t,e){void 0!==e&&(this.onConnectCallback="function"==typeof e.onConnect?e.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"==typeof e.onDisconnect?e.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"==typeof e.onDown?e.onDown:this.onDownCallback,this.onUpCallback="function"==typeof e.onUp?e.onUp:this.onUpCallback,this.onAxisCallback="function"==typeof e.onAxis?e.onAxis:this.onAxisCallback,this.onFloatCallback="function"==typeof e.onFloat?e.onFloat:this.onFloatCallback,this.callbackContext=t)},start:function(){if(!this._active){this._active=!0;var e=this;this._onGamepadConnected=function(t){return e.onGamepadConnected(t)},this._onGamepadDisconnected=function(t){return e.onGamepadDisconnected(t)},window.addEventListener("gamepadconnected",this._onGamepadConnected,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisconnected,!1)}},onGamepadConnected:function(t){var e=t.gamepad;this._rawPads.push(e),this._gamepads[e.index].connect(e)},onGamepadDisconnected:function(t){var e=t.gamepad;for(var i in this._rawPads)this._rawPads[i].index===e.index&&this._rawPads.splice(i,1);this._gamepads[e.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 t=navigator.getGamepads();else if(navigator.webkitGetGamepads)t=navigator.webkitGetGamepads();else if(navigator.webkitGamepads)t=navigator.webkitGamepads();if(t){for(var e=!(this._rawPads=[]),i=0;ithis.deadZone||s<0&&s<-this.deadZone?this.processAxisChange(i,s):this.processAxisChange(i,0)}this._prevTimestamp=this._rawPad.timestamp}},connect:function(t){var e=!this.connected;this.connected=!0,this.index=t.index,this._rawPad=t,this._buttons=[],this._buttonsLen=t.buttons.length,this._axes=[],this._axesLen=t.axes.length;for(var i=0;ithis.maxHealth&&(this.health=this.maxHealth),this},heal:function(t){return this.alive&&(this.health+=t,this.health>this.maxHealth&&(this.health=this.maxHealth)),this}},X.Component.InCamera=function(){},X.Component.InCamera.prototype={inCamera:{get:function(){return this.game.world.camera.view.intersects(this._bounds)}}},X.Component.InputEnabled=function(){},X.Component.InputEnabled.prototype={input:null,inputEnabled:{get:function(){return this.input&&this.input.enabled},set:function(t){t?null===this.input?(this.input=new X.InputHandler(this),this.input.start()):this.input&&!this.input.enabled&&this.input.start():this.input&&this.input.enabled&&this.input.stop()}}},X.Component.InWorld=function(){},X.Component.InWorld.preUpdate=function(){if(this.pendingDestroy)return this.destroy(),!1;if(this.autoCull||this.checkWorldBounds){if(this._bounds.copyFrom(this.getBounds()),this._bounds.x+=this.game.camera.view.x,this._bounds.y+=this.game.camera.view.y,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},X.Component.InWorld.prototype={checkWorldBounds:!1,outOfBoundsKill:!1,outOfCameraBoundsKill:!1,_outOfBoundsFired:!1,inWorld:{get:function(){return this.game.world.bounds.intersects(this.getBounds())}}},X.Component.LifeSpan=function(){},X.Component.LifeSpan.preUpdate=function(){return this.pendingDestroy?(this.destroy(),!1):!(0this.scaleMax.x&&(t.a=this.scaleMax.x),t.d>this.scaleMax.y&&(t.d=this.scaleMax.y))},setScaleMinMax:function(t,e,i,s){void 0===e?e=i=s=t:void 0===i&&(i=s=e,e=t),null===t?this.scaleMin=null:this.scaleMin?this.scaleMin.set(t,e):this.scaleMin=new X.Point(t,e),null===i?this.scaleMax=null:this.scaleMax?this.scaleMax.set(i,s):this.scaleMax=new X.Point(i,s),null===this.scaleMin?this.transformCallback=null:(this.transformCallback=this.checkTransform,this.transformCallbackContext=this)}},X.Component.Smoothed=function(){},X.Component.Smoothed.prototype={smoothed:{get:function(){return!this.texture.baseTexture.scaleMode},set:function(t){t?this.texture&&0!==this.texture.baseTexture.scaleMode&&(this.texture.baseTexture.scaleMode=0,this.texture.baseTexture.dirty()):this.texture&&1!==this.texture.baseTexture.scaleMode&&(this.texture.baseTexture.scaleMode=1,this.texture.baseTexture.dirty())}}},X.GameObjectFactory=function(t){this.game=t,this.world=this.game.world},X.GameObjectFactory.prototype={existing:function(t){return this.world.add(t)},weapon:function(t,e,i,s,n){var r=this.game.plugins.add(X.Weapon);return n&&(r.bulletClass=n),r.createBullets(t,e,i,s),r},image:function(t,e,i,s,n){return void 0===n&&(n=this.world),n.add(new X.Image(this.game,t,e,i,s))},sprite:function(t,e,i,s,n){return void 0===n&&(n=this.world),n.add(new X.Sprite(this.game,t,e,i,s))},creature:function(t,e,i,s,n,r,o){void 0===n&&(n=this.world);var a=new X.Creature(this.game,t,e,i,s,r,o);return n.add(a),a},tween:function(t){return this.game.tweens.create(t)},group:function(t,e,i,s,n){return new X.Group(this.game,t,e,i,s,n)},physicsGroup:function(t,e,i,s){return new X.Group(this.game,e,i,s,!0,t)},spriteBatch:function(t,e,i){return void 0===t&&(t=null),void 0===e&&(e="group"),void 0===i&&(i=!1),new X.SpriteBatch(this.game,t,e,i)},audio:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},sound:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},audioSprite:function(t){return this.game.sound.addSprite(t)},tileSprite:function(t,e,i,s,n,r,o){return void 0===o&&(o=this.world),o.add(new X.TileSprite(this.game,t,e,i,s,n,r))},rope:function(t,e,i,s,n,r){return void 0===r&&(r=this.world),r.add(new X.Rope(this.game,t,e,i,s,n))},text:function(t,e,i,s,n){return void 0===n&&(n=this.world),n.add(new X.Text(this.game,t,e,i,s))},button:function(t,e,i,s,n,r,o,a,h,l){return void 0===l&&(l=this.world),l.add(new X.Button(this.game,t,e,i,s,n,r,o,a,h))},graphics:function(t,e,i){return void 0===i&&(i=this.world),i.add(new X.Graphics(this.game,t,e))},emitter:function(t,e,i){return this.game.particles.add(new X.Particles.Arcade.Emitter(this.game,t,e,i))},retroFont:function(t,e,i,s,n,r,o,a,h){return new X.RetroFont(this.game,t,e,i,s,n,r,o,a,h)},bitmapText:function(t,e,i,s,n,r){return void 0===r&&(r=this.world),r.add(new X.BitmapText(this.game,t,e,i,s,n))},tilemap:function(t,e,i,s,n){return new X.Tilemap(this.game,t,e,i,s,n)},renderTexture:function(t,e,i,s){void 0!==i&&""!==i||(i=this.game.rnd.uuid()),void 0===s&&(s=!1);var n=new X.RenderTexture(this.game,t,e,i);return s&&this.game.cache.addRenderTexture(i,n),n},video:function(t,e){return new X.Video(this.game,t,e)},bitmapData:function(t,e,i,s){void 0===s&&(s=!1),void 0!==i&&""!==i||(i=this.game.rnd.uuid());var n=new X.BitmapData(this.game,i,t,e);return s&&this.game.cache.addBitmapData(i,n),n},filter:function(t){var e=Array.prototype.slice.call(arguments,1);return(t=new X.Filter[t](this.game)).init.apply(t,e),t},plugin:function(){return this.game.plugins.add.apply(this.game.plugins,arguments)}},X.GameObjectFactory.prototype.constructor=X.GameObjectFactory,X.GameObjectCreator=function(t){this.game=t,this.world=this.game.world},X.GameObjectCreator.prototype={image:function(t,e,i,s){return new X.Image(this.game,t,e,i,s)},sprite:function(t,e,i,s){return new X.Sprite(this.game,t,e,i,s)},tween:function(t){return new X.Tween(t,this.game,this.game.tweens)},group:function(t,e,i,s,n){return new X.Group(this.game,t||null,e,i,s,n)},spriteBatch:function(t,e,i){return void 0===e&&(e="group"),void 0===i&&(i=!1),new X.SpriteBatch(this.game,t,e,i)},audio:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},audioSprite:function(t){return this.game.sound.addSprite(t)},sound:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},tileSprite:function(t,e,i,s,n,r){return new X.TileSprite(this.game,t,e,i,s,n,r)},rope:function(t,e,i,s,n){return new X.Rope(this.game,t,e,i,s,n)},text:function(t,e,i,s){return new X.Text(this.game,t,e,i,s)},button:function(t,e,i,s,n,r,o,a,h){return new X.Button(this.game,t,e,i,s,n,r,o,a,h)},graphics:function(t,e){return new X.Graphics(this.game,t,e)},emitter:function(t,e,i){return new X.Particles.Arcade.Emitter(this.game,t,e,i)},retroFont:function(t,e,i,s,n,r,o,a,h){return new X.RetroFont(this.game,t,e,i,s,n,r,o,a,h)},bitmapText:function(t,e,i,s,n,r){return new X.BitmapText(this.game,t,e,i,s,n,r)},tilemap:function(t,e,i,s,n){return new X.Tilemap(this.game,t,e,i,s,n)},renderTexture:function(t,e,i,s){void 0!==i&&""!==i||(i=this.game.rnd.uuid()),void 0===s&&(s=!1);var n=new X.RenderTexture(this.game,t,e,i);return s&&this.game.cache.addRenderTexture(i,n),n},bitmapData:function(t,e,i,s){void 0===s&&(s=!1),void 0!==i&&""!==i||(i=this.game.rnd.uuid());var n=new X.BitmapData(this.game,i,t,e);return s&&this.game.cache.addBitmapData(i,n),n},filter:function(t){var e=Array.prototype.slice.call(arguments,1);return(t=new X.Filter[t](this.game)).init.apply(t,e),t}},X.GameObjectCreator.prototype.constructor=X.GameObjectCreator,X.Sprite=function(t,e,i,s,n){e=e||0,i=i||0,s=s||null,n=n||null,this.type=X.SPRITE,this.physicsType=X.SPRITE,PIXI.Sprite.call(this,X.Cache.DEFAULT),X.Component.Core.init.call(this,t,e,i,s,n)},X.Sprite.prototype=Object.create(PIXI.Sprite.prototype),X.Sprite.prototype.constructor=X.Sprite,X.Component.Core.install.call(X.Sprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),X.Sprite.prototype.preUpdatePhysics=X.Component.PhysicsBody.preUpdate,X.Sprite.prototype.preUpdateLifeSpan=X.Component.LifeSpan.preUpdate,X.Sprite.prototype.preUpdateInWorld=X.Component.InWorld.preUpdate,X.Sprite.prototype.preUpdateCore=X.Component.Core.preUpdate,X.Sprite.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},X.Image=function(t,e,i,s,n){e=e||0,i=i||0,s=s||null,n=n||null,this.type=X.IMAGE,PIXI.Sprite.call(this,X.Cache.DEFAULT),X.Component.Core.init.call(this,t,e,i,s,n)},X.Image.prototype=Object.create(PIXI.Sprite.prototype),X.Image.prototype.constructor=X.Image,X.Component.Core.install.call(X.Image.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Destroy","FixedToCamera","InputEnabled","LifeSpan","LoadTexture","Overlap","Reset","ScaleMinMax","Smoothed"]),X.Image.prototype.preUpdateLifeSpan=X.Component.LifeSpan.preUpdate,X.Image.prototype.preUpdateInWorld=X.Component.InWorld.preUpdate,X.Image.prototype.preUpdateCore=X.Component.Core.preUpdate,X.Image.prototype.preUpdate=function(){return!(!this.preUpdateInWorld()||!this.preUpdateLifeSpan())&&this.preUpdateCore()},X.Button=function(t,e,i,s,n,r,o,a,h,l){e=e||0,i=i||0,s=s||null,n=n||null,r=r||this,X.Image.call(this,t,e,i,s,a),this.type=X.BUTTON,this.physicsType=X.SPRITE,this._onOverFrame=null,this._onOutFrame=null,this._onDownFrame=null,this._onUpFrame=null,this.onOverSound=null,this.onOutSound=null,this.onDownSound=null,this.onUpSound=null,this.onOverSoundMarker="",this.onOutSoundMarker="",this.onDownSoundMarker="",this.onUpSoundMarker="",this.onInputOver=new X.Signal,this.onInputOut=new X.Signal,this.onInputDown=new X.Signal,this.onInputUp=new X.Signal,this.onOverMouseOnly=!0,this.justReleasedPreventsOver=X.PointerMode.CONTACT,this.freezeFrames=!1,this.forceOut=!1,this.inputEnabled=!0,this.input.start(0,!0),this.input.useHandCursor=!0,this.setFrames(o,a,h,l),null!==n&&this.onInputUp.add(n,r),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)},X.Button.prototype=Object.create(X.Image.prototype),X.Button.prototype.constructor=X.Button;var h="Over",l="Out",c="Down",u="Up";return X.Button.prototype.clearFrames=function(){this.setFrames(null,null,null,null)},X.Button.prototype.setStateFrame=function(t,e,i){var s="_on"+t+"Frame";null!==e?(this[s]=e,i&&this.changeStateFrame(t)):this[s]=null},X.Button.prototype.changeStateFrame=function(t){if(this.freezeFrames)return!1;var e=this["_on"+t+"Frame"];return"string"==typeof e?(this.frameName=e,!0):"number"==typeof e&&(this.frame=e,!0)},X.Button.prototype.setFrames=function(t,e,i,s){this.setStateFrame(h,t,this.input.pointerOver()),this.setStateFrame(l,e,!this.input.pointerOver()),this.setStateFrame(c,i,this.input.pointerDown()),this.setStateFrame(u,s,this.input.pointerUp())},X.Button.prototype.setStateSound=function(t,e,i){var s="on"+t+"Sound",n="on"+t+"SoundMarker";e instanceof X.Sound||e instanceof X.AudioSprite?(this[s]=e,this[n]="string"==typeof i?i:""):(this[s]=null,this[n]="")},X.Button.prototype.playStateSound=function(t){var e=this["on"+t+"Sound"];if(e){var i=this["on"+t+"SoundMarker"];return e.play(i),!0}return!1},X.Button.prototype.setSounds=function(t,e,i,s,n,r,o,a){this.setStateSound(h,t,e),this.setStateSound(l,n,r),this.setStateSound(c,i,s),this.setStateSound(u,o,a)},X.Button.prototype.setOverSound=function(t,e){this.setStateSound(h,t,e)},X.Button.prototype.setOutSound=function(t,e){this.setStateSound(l,t,e)},X.Button.prototype.setDownSound=function(t,e){this.setStateSound(c,t,e)},X.Button.prototype.setUpSound=function(t,e){this.setStateSound(u,t,e)},X.Button.prototype.onInputOverHandler=function(t,e){e.justReleased()&&(this.justReleasedPreventsOver&e.pointerMode)===e.pointerMode||(this.changeStateFrame(h),this.onOverMouseOnly&&!e.isMouse||(this.playStateSound(h),this.onInputOver&&this.onInputOver.dispatch(this,e)))},X.Button.prototype.onInputOutHandler=function(t,e){this.changeStateFrame(l),this.playStateSound(l),this.onInputOut&&this.onInputOut.dispatch(this,e)},X.Button.prototype.onInputDownHandler=function(t,e){this.changeStateFrame(c),this.playStateSound(c),this.onInputDown&&this.onInputDown.dispatch(this,e)},X.Button.prototype.onInputUpHandler=function(t,e,i){(this.playStateSound(u),this.onInputUp&&this.onInputUp.dispatch(this,e,i),this.freezeFrames)||(!0===this.forceOut||(this.forceOut&e.pointerMode)===e.pointerMode?this.changeStateFrame(l):this.changeStateFrame(u)||(i?this.changeStateFrame(h):this.changeStateFrame(l)))},X.SpriteBatch=function(t,e,i,s){null==e&&(e=t.world),X.Group.call(this,t,e,i,s),this.type=X.SPRITEBATCH,this.fastSpriteBatch=null,this.ready=!1},X.SpriteBatch.prototype=Object.create(X.Group.prototype),X.SpriteBatch.prototype.constructor=X.SpriteBatch,X.SpriteBatch.prototype._renderWebGL=function(t){!this.visible||this.alpha<=0||!this.children.length||(this.ready||(this.fastSpriteBatch=new PIXI.WebGLFastSpriteBatch(t.gl),this.ready=!0),this.fastSpriteBatch.gl!==t.gl&&this.fastSpriteBatch.setContext(t.gl),t.spriteBatch.stop(),t.shaderManager.setShader(t.shaderManager.fastShader),this.fastSpriteBatch.begin(this,t),this.fastSpriteBatch.render(this),t.spriteBatch.start())},X.SpriteBatch.prototype._renderCanvas=function(t){if(this.visible&&!(this.alpha<=0)&&this.children.length){var e=t.context;e.globalAlpha=this.worldAlpha,this.displayObjectUpdateTransform();for(var i=this.worldTransform,s=!0,n=0;n=this.height||s<=0)&&(r=!0)):2!==t&&3!==t||++s===this.height&&(s=0,((i+=n)>=this.width||i<=0)&&(r=!0)),0===e.a&&!r;);return e.x=i,e.y=s,e},getBounds:function(t){return void 0===t&&(t=new X.Rectangle),t.x=this.getFirstPixel(2).x,t.x===this.width?t.setTo(0,0,0,0):(t.y=this.getFirstPixel(0).y,t.width=this.getFirstPixel(3).x-t.x+1,t.height=this.getFirstPixel(1).y-t.y+1,t)},addToWorld:function(t,e,i,s,n,r){n=n||1,r=r||1;var o=this.game.add.image(t,e,this);return o.anchor.set(i,s),o.scale.set(n,r),o},copy:function(t,e,i,s,n,r,o,a,h,l,c,u,d,p,f,g,m){if(null==t&&(t=this),t instanceof X.RenderTexture&&(t=t.getCanvas()),(this._image=t)instanceof X.Sprite||t instanceof X.Image||t instanceof X.Text||t instanceof PIXI.Sprite)this._pos.set(t.texture.crop.x,t.texture.crop.y),this._size.set(t.texture.crop.width,t.texture.crop.height),this._scale.set(t.scale.x,t.scale.y),this._anchor.set(t.anchor.x,t.anchor.y),this._rotate=t.rotation,this._alpha.current=t.alpha,t.texture instanceof X.RenderTexture?this._image=t.texture.getCanvas():this._image=t.texture.baseTexture.source,null==r&&(r=t.x),null==o&&(o=t.y),t.texture.trim&&(r+=t.texture.trim.x-t.anchor.x*t.texture.trim.width,o+=t.texture.trim.y-t.anchor.y*t.texture.trim.height),16777215!==t.tint&&(t.cachedTint!==t.tint&&(t.cachedTint=t.tint,t.tintedTexture=PIXI.CanvasTinter.getTintedTexture(t,t.tint)),this._image=t.tintedTexture,this._pos.set(0));else{if(this._pos.set(0),this._scale.set(1),this._anchor.set(0),this._rotate=0,this._alpha.current=1,t instanceof X.BitmapData)this._image=t.canvas;else if("string"==typeof t){if(null===(t=this.game.cache.getImage(t)))return this;this._image=t}this._size.set(this._image.width,this._image.height)}if(null==e&&(e=0),null==i&&(i=0),s&&(this._size.x=s),n&&(this._size.y=n),null==r&&(r=e),null==o&&(o=i),null==a&&(a=this._size.x),null==h&&(h=this._size.y),"number"==typeof l&&(this._rotate=l),"number"==typeof c&&(this._anchor.x=c),"number"==typeof u&&(this._anchor.y=u),"number"==typeof d&&(this._scale.x=d),"number"==typeof p&&(this._scale.y=p),"number"==typeof f&&(this._alpha.current=f),void 0===g&&(g=null),void 0===m&&(m=!1),this._alpha.current<=0||0===this._scale.x||0===this._scale.y||0===this._size.x||0===this._size.y)return this;var y=this.context;return this._alpha.prev=y.globalAlpha,y.save(),y.globalAlpha=this._alpha.current,g&&(this.op=g),m&&(r|=0,o|=0),y.translate(r,o),y.scale(this._scale.x,this._scale.y),y.rotate(this._rotate),y.drawImage(this._image,this._pos.x+e,this._pos.y+i,this._size.x,this._size.y,-a*this._anchor.x,-h*this._anchor.y,a,h),y.restore(),y.globalAlpha=this._alpha.prev,this.dirty=!0,this},copyTransform:function(t,e,i){if(void 0===e&&(e=null),void 0===i&&(i=!1),!t.hasOwnProperty("worldTransform")||!t.worldVisible||0===t.worldAlpha)return this;var s=t.worldTransform;if(this._pos.set(t.texture.crop.x,t.texture.crop.y),this._size.set(t.texture.crop.width,t.texture.crop.height),0===s.a||0===s.d||0===this._size.x||0===this._size.y)return this;t.texture instanceof X.RenderTexture?this._image=t.texture.getCanvas():this._image=t.texture.baseTexture.source;var n=s.tx,r=s.ty;t.texture.trim&&(n+=t.texture.trim.x-t.anchor.x*t.texture.trim.width,r+=t.texture.trim.y-t.anchor.y*t.texture.trim.height),16777215!==t.tint&&(t.cachedTint!==t.tint&&(t.cachedTint=t.tint,t.tintedTexture=PIXI.CanvasTinter.getTintedTexture(t,t.tint)),this._image=t.tintedTexture,this._pos.set(0)),i&&(n|=0,r|=0);var o=this.context;return this._alpha.prev=o.globalAlpha,o.save(),o.globalAlpha=this._alpha.current,e&&(this.op=e),o[this.smoothProperty]=t.texture.baseTexture.scaleMode===PIXI.scaleModes.LINEAR,o.setTransform(s.a,s.b,s.c,s.d,n,r),o.drawImage(this._image,this._pos.x,this._pos.y,this._size.x,this._size.y,-this._size.x*t.anchor.x,-this._size.y*t.anchor.y,this._size.x,this._size.y),o.restore(),o.globalAlpha=this._alpha.prev,this.dirty=!0,this},copyRect:function(t,e,i,s,n,r,o){return this.copy(t,e.x,e.y,e.width,e.height,i,s,e.width,e.height,0,0,0,1,1,n,r,o)},draw:function(t,e,i,s,n,r,o){return this.copy(t,null,null,null,null,e,i,s,n,null,null,null,null,null,null,r,o)},drawGroup:function(t,e,i){return 0e.width&&(s=e.width);var n=this.context;return n.fillStyle=n.createPattern(e,i),this._circle=new X.Circle(t.start.x,t.start.y,e.height),this._circle.circumferencePoint(t.angle-1.5707963267948966,!1,this._pos),n.save(),n.translate(this._pos.x,this._pos.y),n.rotate(t.angle),n.fillRect(0,0,s,e.height),n.restore(),this.dirty=!0,this}},render:function(){return!this.disableTextureUpload&&this.dirty&&(this.baseTexture.dirty(),this.dirty=!1),this},destroy:function(){this.frameData.destroy(),this.texture.destroy(!0),X.CanvasPool.remove(this)},blendReset:function(){return this.op="source-over",this},blendSourceOver:function(){return this.op="source-over",this},blendSourceIn:function(){return this.op="source-in",this},blendSourceOut:function(){return this.op="source-out",this},blendSourceAtop:function(){return this.op="source-atop",this},blendDestinationOver:function(){return this.op="destination-over",this},blendDestinationIn:function(){return this.op="destination-in",this},blendDestinationOut:function(){return this.op="destination-out",this},blendDestinationAtop:function(){return this.op="destination-atop",this},blendXor:function(){return this.op="xor",this},blendAdd:function(){return this.op="lighter",this},blendMultiply:function(){return this.op="multiply",this},blendScreen:function(){return this.op="screen",this},blendOverlay:function(){return this.op="overlay",this},blendDarken:function(){return this.op="darken",this},blendLighten:function(){return this.op="lighten",this},blendColorDodge:function(){return this.op="color-dodge",this},blendColorBurn:function(){return this.op="color-burn",this},blendHardLight:function(){return this.op="hard-light",this},blendSoftLight:function(){return this.op="soft-light",this},blendDifference:function(){return this.op="difference",this},blendExclusion:function(){return this.op="exclusion",this},blendHue:function(){return this.op="hue",this},blendSaturation:function(){return this.op="saturation",this},blendColor:function(){return this.op="color",this},blendLuminosity:function(){return this.op="luminosity",this},copyBitmapData:function(t,e,i){t.update();for(var s,n=0;n80*i){s=r=t[0],n=o=t[1];for(var f=i;fr.x?n.x>o.x?n.x:o.x:r.x>o.x?r.x:o.x,c=n.y>r.y?n.y>o.y?n.y:o.y:r.y>o.y?r.y:o.y,u=X.EarCut.zOrder(a,h,e,i,s),d=X.EarCut.zOrder(l,c,e,i,s),p=t.nextZ;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&X.EarCut.pointInTriangle(n.x,n.y,r.x,r.y,o.x,o.y,p.x,p.y)&&0<=X.EarCut.area(p.prev,p,p.next))return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=u;){if(p!==t.prev&&p!==t.next&&X.EarCut.pointInTriangle(n.x,n.y,r.x,r.y,o.x,o.y,p.x,p.y)&&0<=X.EarCut.area(p.prev,p,p.next))return!1;p=p.prevZ}return!0},X.EarCut.cureLocalIntersections=function(t,e,i){var s=t;do{var n=s.prev,r=s.next.next;X.EarCut.intersects(n,s,s.next,r)&&X.EarCut.locallyInside(n,r)&&X.EarCut.locallyInside(r,n)&&(e.push(n.i/i),e.push(s.i/i),e.push(r.i/i),X.EarCut.removeNode(s),X.EarCut.removeNode(s.next),s=t=r),s=s.next}while(s!==t);return s},X.EarCut.splitEarcut=function(t,e,i,s,n,r){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&X.EarCut.isValidDiagonal(o,a)){var h=X.EarCut.splitPolygon(o,a);return o=X.EarCut.filterPoints(o,o.next),h=X.EarCut.filterPoints(h,h.next),X.EarCut.earcutLinked(o,e,i,s,n,r),void X.EarCut.earcutLinked(h,e,i,s,n,r)}a=a.next}o=o.next}while(o!==t)},X.EarCut.eliminateHoles=function(t,e,i,s){var n,r,o,a,h,l=[];for(n=0,r=e.length;n=s.next.y){var a=s.x+(r-s.y)*(s.next.x-s.x)/(s.next.y-s.y);a<=n&&o=s.x&&s.x>=i.x&&X.EarCut.pointInTriangle(ri.x)&&X.EarCut.locallyInside(s,t)&&(i=s,c=h),s=s.next;return i},X.EarCut.indexCurve=function(t,e,i,s){for(var n=t;null===n.z&&(n.z=X.EarCut.zOrder(n.x,n.y,e,i,s)),n.prevZ=n.prev,n.nextZ=n.next,(n=n.next)!==t;);n.prevZ.nextZ=null,n.prevZ=null,X.EarCut.sortLinked(n)},X.EarCut.sortLinked=function(t){var e,i,s,n,r,o,a,h,l=1;do{for(i=t,r=t=null,o=0;i;){for(o++,s=i,e=a=0;er!=i.next.y>r&&n<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(s=!s),(i=i.next)!==t;);return s},X.EarCut.splitPolygon=function(t,e){var i=new X.EarCut.Node(t.i,t.x,t.y),s=new X.EarCut.Node(e.i,e.x,e.y),n=t.next,r=e.prev;return(t.next=e).prev=t,(i.next=n).prev=i,(s.next=i).prev=s,(r.next=s).prev=r,s},X.EarCut.insertNode=function(t,e,i,s){var n=new X.EarCut.Node(t,e,i);return s?(n.next=s.next,(n.prev=s).next.prev=n,s.next=n):(n.prev=n).next=n,n},X.EarCut.removeNode=function(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)},X.EarCut.Node=function(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1},PIXI.WebGLGraphics=function(){},PIXI.WebGLGraphics.stencilBufferLimit=6,PIXI.WebGLGraphics.renderGraphics=function(t,e){var i,s=e.gl,n=e.projection,r=e.offset,o=e.shaderManager.primitiveShader;t.dirty&&PIXI.WebGLGraphics.updateGraphics(t,s);var a=t._webGL[s.id];if(a)for(var h=0;h=PIXI.WebGLGraphics.stencilBufferLimit)if(o.points.length<2*PIXI.WebGLGraphics.stencilBufferLimit)s=PIXI.WebGLGraphics.switchMode(n,0),PIXI.WebGLGraphics.buildPoly(o,s)||(s=PIXI.WebGLGraphics.switchMode(n,1),PIXI.WebGLGraphics.buildComplexPoly(o,s));else s=PIXI.WebGLGraphics.switchMode(n,1),PIXI.WebGLGraphics.buildComplexPoly(o,s);0>16&255)/255,i=(t.tint>>8&255)/255,s=(255&t.tint)/255,n=0;n>16&255)/255*e*255<<16)+((o>>8&255)/255*i*255<<8)+(255&o)/255*s*255,r._lineTint=((a>>16&255)/255*e*255<<16)+((a>>8&255)/255*i*255<<8)+(255&a)/255*s*255}},X.GraphicsData=function(t,e,i,s,n,r,o){this.lineWidth=t,this.lineColor=e,this.lineAlpha=i,this._lineTint=e,this.fillColor=s,this.fillAlpha=n,this._fillTint=s,this.fill=r,this.shape=o,this.type=o.type},X.GraphicsData.prototype.constructor=X.GraphicsData,X.GraphicsData.prototype.clone=function(){return new X.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.fill,this.shape)},X.Graphics=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0),this.type=X.GRAPHICS,this.physicsType=X.SPRITE,this.anchor=new X.Point,PIXI.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor=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 X.Rectangle(0,0,1,1),this.dirty=!0,this._boundsDirty=!1,this.webGLDirty=!1,this.cachedSpriteDirty=!1,X.Component.Core.init.call(this,t,e,i,"",null)},X.Graphics.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),X.Graphics.prototype.constructor=X.Graphics,X.Component.Core.install.call(X.Graphics.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),X.Graphics.prototype.preUpdatePhysics=X.Component.PhysicsBody.preUpdate,X.Graphics.prototype.preUpdateLifeSpan=X.Component.LifeSpan.preUpdate,X.Graphics.prototype.preUpdateInWorld=X.Component.InWorld.preUpdate,X.Graphics.prototype.preUpdateCore=X.Component.Core.preUpdate,X.Graphics.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},X.Graphics.prototype.postUpdate=function(){X.Component.PhysicsBody.postUpdate.call(this),X.Component.FixedToCamera.postUpdate.call(this),this._boundsDirty&&(this.updateLocalBounds(),this._boundsDirty=!1);for(var t=0;tg&&(y=-g),0!==y&&(m+=0i&&(this.style.wordWrapWidth=i)),this.updateTexture(),this},X.Text.prototype.updateTexture=function(){var t=this.texture.baseTexture,e=this.texture.crop,i=this.texture.frame,s=this.canvas.width,n=this.canvas.height;if(t.width=s,t.height=n,e.width=s,e.height=n,i.width=s,i.height=n,this.texture.width=s,this.texture.height=n,this._width=s,this._height=n,this.textBounds){var r=this.textBounds.x,o=this.textBounds.y;"right"===this.style.boundsAlignH?r+=this.textBounds.width-this.canvas.width/this.resolution:"center"===this.style.boundsAlignH&&(r+=this.textBounds.halfWidth-this.canvas.width/this.resolution/2),"bottom"===this.style.boundsAlignV?o+=this.textBounds.height-this.canvas.height/this.resolution:"middle"===this.style.boundsAlignV&&(o+=this.textBounds.halfHeight-this.canvas.height/this.resolution/2),this.pivot.x=-r,this.pivot.y=-o}this.renderable=0!==s&&0!==n,this.texture.requiresReTint=!0,this.texture.baseTexture.dirty()},X.Text.prototype._renderWebGL=function(t){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderWebGL.call(this,t)},X.Text.prototype._renderCanvas=function(t){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderCanvas.call(this,t)},X.Text.prototype.determineFontProperties=function(t){var e=X.Text.fontPropertiesCache[t];if(e)return e;var i=X.Text.fontPropertiesContext;i.font=t;var s=i.measureText(this.testString);if(s.actualBoundingBoxAscent){e={ascent:n=Math.ceil(s.actualBoundingBoxAscent),descent:r=Math.ceil(s.actualBoundingBoxDescent),fontSize:n+r}}else{var n,r,o=i.measureText("MX").width;e={ascent:n=Math.ceil(.75*o),descent:r=Math.ceil(.25*o),fontSize:n+r}}return X.Text.fontPropertiesCache[t]=e},X.Text.prototype.getBounds=function(t){return this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype.getBounds.call(this,t)},X.Text.prototype.setCharacterLimit=function(t,e){this.characterLimitSuffix=void 0===e?"":e,this.characterLimitSize=t,this.updateText()},Object.defineProperty(X.Text.prototype,"text",{get:function(){return this._text},set:function(t){t!==this._text&&(this._text=t.toString()||"",this.dirty=!0,this.parent&&this.updateTransform())}}),Object.defineProperty(X.Text.prototype,"cssFont",{get:function(){return this.componentsToFont(this._fontComponents)},set:function(t){t=t||"bold 20pt Arial",this._fontComponents=this.fontToComponents(t),this.updateFont(this._fontComponents)}}),Object.defineProperty(X.Text.prototype,"font",{get:function(){return this._fontComponents.fontFamily},set:function(t){t=(t=t||"Arial").trim(),/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(t)||/['",]/.exec(t)||(t="'"+t+"'"),this._fontComponents.fontFamily=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(X.Text.prototype,"fontSize",{get:function(){var t=this._fontComponents.fontSize;return t&&/(?:^0$|px$)/.exec(t)?parseInt(t,10):t},set:function(t){"number"==typeof(t=t||"0")&&(t+="px"),this._fontComponents.fontSize=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(X.Text.prototype,"fontWeight",{get:function(){return this._fontComponents.fontWeight||"normal"},set:function(t){t=t||"normal",this._fontComponents.fontWeight=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(X.Text.prototype,"fontStyle",{get:function(){return this._fontComponents.fontStyle||"normal"},set:function(t){t=t||"normal",this._fontComponents.fontStyle=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(X.Text.prototype,"fontVariant",{get:function(){return this._fontComponents.fontVariant||"normal"},set:function(t){t=t||"normal",this._fontComponents.fontVariant=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(X.Text.prototype,"fill",{get:function(){return this.style.fill},set:function(t){t!==this.style.fill&&(this.style.fill=t,this.dirty=!0)}}),Object.defineProperty(X.Text.prototype,"align",{get:function(){return this.style.align},set:function(t){(t=t.toLowerCase())!==this.style.align&&(this.style.align=t,this.dirty=!0)}}),Object.defineProperty(X.Text.prototype,"resolution",{get:function(){return this._res},set:function(t){t!==this._res&&(this._res=t,this.dirty=!0)}}),Object.defineProperty(X.Text.prototype,"tabs",{get:function(){return this.style.tabs},set:function(t){t!==this.style.tabs&&(this.style.tabs=t,this.dirty=!0)}}),Object.defineProperty(X.Text.prototype,"boundsAlignH",{get:function(){return this.style.boundsAlignH},set:function(t){(t=t.toLowerCase())!==this.style.boundsAlignH&&(this.style.boundsAlignH=t,this.dirty=!0)}}),Object.defineProperty(X.Text.prototype,"boundsAlignV",{get:function(){return this.style.boundsAlignV},set:function(t){(t=t.toLowerCase())!==this.style.boundsAlignV&&(this.style.boundsAlignV=t,this.dirty=!0)}}),Object.defineProperty(X.Text.prototype,"stroke",{get:function(){return this.style.stroke},set:function(t){t!==this.style.stroke&&(this.style.stroke=t,this.dirty=!0)}}),Object.defineProperty(X.Text.prototype,"strokeThickness",{get:function(){return this.style.strokeThickness},set:function(t){t!==this.style.strokeThickness&&(this.style.strokeThickness=Number(t),this.dirty=!0)}}),Object.defineProperty(X.Text.prototype,"wordWrap",{get:function(){return this.style.wordWrap},set:function(t){t!==this.style.wordWrap&&(this.style.wordWrap=t,this.dirty=!0)}}),Object.defineProperty(X.Text.prototype,"wordWrapWidth",{get:function(){return this.style.wordWrapWidth},set:function(t){t!==this.style.wordWrapWidth&&(this.style.wordWrapWidth=t,this.dirty=!0)}}),Object.defineProperty(X.Text.prototype,"lineSpacing",{get:function(){return this._lineSpacing},set:function(t){t!==this._lineSpacing&&(this._lineSpacing=parseFloat(t),this.dirty=!0,this.parent&&this.updateTransform())}}),Object.defineProperty(X.Text.prototype,"shadowOffsetX",{get:function(){return this.style.shadowOffsetX},set:function(t){t!==this.style.shadowOffsetX&&(this.style.shadowOffsetX=t,this.dirty=!0)}}),Object.defineProperty(X.Text.prototype,"shadowOffsetY",{get:function(){return this.style.shadowOffsetY},set:function(t){t!==this.style.shadowOffsetY&&(this.style.shadowOffsetY=t,this.dirty=!0)}}),Object.defineProperty(X.Text.prototype,"shadowColor",{get:function(){return this.style.shadowColor},set:function(t){t!==this.style.shadowColor&&(this.style.shadowColor=t,this.dirty=!0)}}),Object.defineProperty(X.Text.prototype,"shadowBlur",{get:function(){return this.style.shadowBlur},set:function(t){t!==this.style.shadowBlur&&(this.style.shadowBlur=t,this.dirty=!0)}}),Object.defineProperty(X.Text.prototype,"shadowStroke",{get:function(){return this.style.shadowStroke},set:function(t){t!==this.style.shadowStroke&&(this.style.shadowStroke=t,this.dirty=!0)}}),Object.defineProperty(X.Text.prototype,"shadowFill",{get:function(){return this.style.shadowFill},set:function(t){t!==this.style.shadowFill&&(this.style.shadowFill=t,this.dirty=!0)}}),Object.defineProperty(X.Text.prototype,"width",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.x*(this.texture.frame.width/this.resolution)},set:function(t){this.scale.x=t/this.texture.frame.width,this._width=t}}),Object.defineProperty(X.Text.prototype,"height",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.y*(this.texture.frame.height/this.resolution)},set:function(t){this.scale.y=t/this.texture.frame.height,this._height=t}}),Object.defineProperty(X.Text.prototype,"testString",{get:function(){return this._testString},set:function(t){this._testString=t,this.updateText()}}),X.Text.fontPropertiesCache={},X.Text.fontPropertiesCanvas=document.createElement("canvas"),X.Text.fontPropertiesContext=X.Text.fontPropertiesCanvas.getContext("2d"),X.BitmapText=function(t,e,i,s,n,r,o){e=e||0,i=i||0,s=s||"",n=n||"",r=r||32,o=o||"left",PIXI.DisplayObjectContainer.call(this),this.type=X.BITMAPTEXT,this.physicsType=X.SPRITE,this.textWidth=0,this.textHeight=0,this.anchor=new X.Point,this._prevAnchor=new X.Point,this._glyphs=[],this._maxWidth=0,this._text=n.toString()||"",this._data=t.cache.getBitmapFont(s),this._font=s,this._fontSize=r,this._align=o,this._letterSpacing=0,this._tint=16777215,this.updateText(),this.dirty=!1,X.Component.Core.init.call(this,t,e,i,"",null)},X.BitmapText.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),X.BitmapText.prototype.constructor=X.BitmapText,X.Component.Core.install.call(X.BitmapText.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),X.BitmapText.prototype.preUpdatePhysics=X.Component.PhysicsBody.preUpdate,X.BitmapText.prototype.preUpdateLifeSpan=X.Component.LifeSpan.preUpdate,X.BitmapText.prototype.preUpdateInWorld=X.Component.InWorld.preUpdate,X.BitmapText.prototype.preUpdateCore=X.Component.Core.preUpdate,X.BitmapText.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},X.BitmapText.prototype.postUpdate=function(){X.Component.PhysicsBody.postUpdate.call(this),X.Component.FixedToCamera.postUpdate.call(this),this.body&&this.body.type===X.Physics.ARCADE&&(this.textWidth===this.body.sourceWidth&&this.textHeight===this.body.sourceHeight||this.body.setSize(this.textWidth,this.textHeight))},X.BitmapText.prototype.setText=function(t){this.text=t},X.BitmapText.prototype.scanLine=function(t,e,i){for(var s=0,n=0,r=-1,o=0,a=null,h=0this.textWidth&&(this.textWidth=c.width),n+=t.lineHeight*i,e=e.substr(c.text.length+1)}while(!1===c.end);this.textHeight=n;for(var r=0,o=0,a=this.textWidth*this.anchor.x,h=this.textHeight*this.anchor.y,l=0;l?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",X.RetroFont.TEXT_SET2=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",X.RetroFont.TEXT_SET3="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",X.RetroFont.TEXT_SET4="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",X.RetroFont.TEXT_SET5="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",X.RetroFont.TEXT_SET6="ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",X.RetroFont.TEXT_SET7="AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",X.RetroFont.TEXT_SET8="0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",X.RetroFont.TEXT_SET9="ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",X.RetroFont.TEXT_SET10="ABCDEFGHIJKLMNOPQRSTUVWXYZ",X.RetroFont.TEXT_SET11="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789",X.RetroFont.prototype.setFixedWidth=function(t,e){void 0===e&&(e="left"),this.fixedWidth=t,this.align=e},X.RetroFont.prototype.setText=function(t,e,i,s,n,r){this.multiLine=e||!1,this.customSpacingX=i||0,this.customSpacingY=s||0,this.align=n||"left",this.autoUpperCase=!r,0this.width))break},X.RetroFont.prototype.getLongestLine=function(){var t=0;if(0t&&(t=e[i].length);return t},X.RetroFont.prototype.removeUnsupportedCharacters=function(t){for(var e="",i=0;i=X.Math.PI2-i?t=e:(Math.abs(e-t)>Math.PI&&(et[i]&&(i=e);return t[i]},minProperty:function(t){if(2===arguments.length&&"object"==typeof arguments[1])var e=arguments[1];else e=arguments.slice(1);for(var i=1,s=0,n=e.length;ie[s][t]&&(s=i);return e[s][t]},wrapAngle:function(t,e){return e?this.wrap(t,-Math.PI,Math.PI):this.wrap(t,-180,180)},linearInterpolation:function(t,e){var i=t.length-1,s=i*e,n=Math.floor(s);return e<0?this.linear(t[0],t[1],s):1>>0,s=(e*=s)>>>0,s+=4294967296*(e-=s);return 2.3283064365386963e-10*(s>>>0)},integer:function(){return 4294967296*this.rnd.apply(this)},frac:function(){return this.rnd.apply(this)+11102230246251565e-32*(2097152*this.rnd.apply(this)|0)},real:function(){return this.integer()+this.frac()},integerInRange:function(t,e){return Math.floor(this.realInRange(0,e-t+1)+t)},between:function(t,e){return this.integerInRange(t,e)},realInRange:function(t,e){return this.frac()*(e-t)+t},normal:function(){return 1-2*this.frac()},uuid:function(){var t="",e="";for(e=t="";t++<36;e+=~t%5|3*t&4?(15^t?8^this.frac()*(20^t?16:4):4).toString(16):"-");return e},pick:function(t){return t[this.integerInRange(0,t.length-1)]},sign:function(){return this.pick([-1,1])},weightedPick:function(t){return t[~~(Math.pow(this.frac(),2)*(t.length-1)+.5)]},timestamp:function(t,e){return this.realInRange(t||9466848e5,e||1577862e6)},angle:function(){return this.integerInRange(-180,180)},state:function(t){return"string"==typeof t&&t.match(/^!rnd/)&&(t=t.split(","),this.c=parseFloat(t[1]),this.s0=parseFloat(t[2]),this.s1=parseFloat(t[3]),this.s2=parseFloat(t[4])),["!rnd",this.c,this.s0,this.s1,this.s2].join(",")}},X.RandomDataGenerator.prototype.constructor=X.RandomDataGenerator,X.QuadTree=function(t,e,i,s,n,r,o){this.maxObjects=10,this.maxLevels=4,this.level=0,this.bounds={},this.objects=[],this.nodes=[],this._empty=[],this.reset(t,e,i,s,n,r,o)},X.QuadTree.prototype={reset:function(t,e,i,s,n,r,o){this.maxObjects=n||10,this.maxLevels=r||4,this.level=o||0,this.bounds={x:Math.round(t),y:Math.round(e),width:i,height:s,subWidth:Math.floor(i/2),subHeight:Math.floor(s/2),right:Math.round(t)+Math.floor(i/2),bottom:Math.round(e)+Math.floor(s/2)},this.objects.length=0,this.nodes.length=0},populate:function(t){t.forEach(this.populateHandler,this,!0)},populateHandler:function(t){t.body&&t.exists&&this.insert(t.body)},split:function(){this.nodes[0]=new X.QuadTree(this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[1]=new X.QuadTree(this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[2]=new X.QuadTree(this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[3]=new X.QuadTree(this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1)},insert:function(t){var e,i=0;if(null==this.nodes[0]||-1===(e=this.getIndex(t))){if(this.objects.push(t),this.objects.length>this.maxObjects&&this.levelthis.bounds.bottom&&(e=2):t.x>this.bounds.right&&(t.ythis.bounds.bottom&&(e=3)),e},retrieve:function(t){if(t instanceof X.Rectangle)var e=this.objects,i=this.getIndex(t);else{if(!t.body)return this._empty;e=this.objects,i=this.getIndex(t.body)}return this.nodes[0]&&(e=-1!==i?e.concat(this.nodes[i].retrieve(t)):(e=(e=(e=e.concat(this.nodes[0].retrieve(t))).concat(this.nodes[1].retrieve(t))).concat(this.nodes[2].retrieve(t))).concat(this.nodes[3].retrieve(t))),e},clear:function(){this.objects.length=0;for(var t=this.nodes.length;t--;)this.nodes[t].clear(),this.nodes.splice(t,1);this.nodes.length=0}},X.QuadTree.prototype.constructor=X.QuadTree,X.TweenManager=function(t){this.game=t,this._tweens=[],this._add=[],this.easeMap={Power0:X.Easing.Power0,Power1:X.Easing.Power1,Power2:X.Easing.Power2,Power3:X.Easing.Power3,Power4:X.Easing.Power4,Linear:X.Easing.Linear.None,Quad:X.Easing.Quadratic.Out,Cubic:X.Easing.Cubic.Out,Quart:X.Easing.Quartic.Out,Quint:X.Easing.Quintic.Out,Sine:X.Easing.Sinusoidal.Out,Expo:X.Easing.Exponential.Out,Circ:X.Easing.Circular.Out,Elastic:X.Easing.Elastic.Out,Back:X.Easing.Back.Out,Bounce:X.Easing.Bounce.Out,"Quad.easeIn":X.Easing.Quadratic.In,"Cubic.easeIn":X.Easing.Cubic.In,"Quart.easeIn":X.Easing.Quartic.In,"Quint.easeIn":X.Easing.Quintic.In,"Sine.easeIn":X.Easing.Sinusoidal.In,"Expo.easeIn":X.Easing.Exponential.In,"Circ.easeIn":X.Easing.Circular.In,"Elastic.easeIn":X.Easing.Elastic.In,"Back.easeIn":X.Easing.Back.In,"Bounce.easeIn":X.Easing.Bounce.In,"Quad.easeOut":X.Easing.Quadratic.Out,"Cubic.easeOut":X.Easing.Cubic.Out,"Quart.easeOut":X.Easing.Quartic.Out,"Quint.easeOut":X.Easing.Quintic.Out,"Sine.easeOut":X.Easing.Sinusoidal.Out,"Expo.easeOut":X.Easing.Exponential.Out,"Circ.easeOut":X.Easing.Circular.Out,"Elastic.easeOut":X.Easing.Elastic.Out,"Back.easeOut":X.Easing.Back.Out,"Bounce.easeOut":X.Easing.Bounce.Out,"Quad.easeInOut":X.Easing.Quadratic.InOut,"Cubic.easeInOut":X.Easing.Cubic.InOut,"Quart.easeInOut":X.Easing.Quartic.InOut,"Quint.easeInOut":X.Easing.Quintic.InOut,"Sine.easeInOut":X.Easing.Sinusoidal.InOut,"Expo.easeInOut":X.Easing.Exponential.InOut,"Circ.easeInOut":X.Easing.Circular.InOut,"Elastic.easeInOut":X.Easing.Elastic.InOut,"Back.easeInOut":X.Easing.Back.InOut,"Bounce.easeInOut":X.Easing.Bounce.InOut},this.game.onPause.add(this._pauseAll,this),this.game.onResume.add(this._resumeAll,this)},X.TweenManager.prototype={getAll:function(){return this._tweens},removeAll:function(){for(var t=0;tthis.timeline.length-1)&&(t=0),this.current=t,this.timeline[this.current].start(),this},stop:function(t){return void 0===t&&(t=!1),this.isRunning=!1,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,t&&(this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start()),this.manager.remove(this),this},updateTweenData:function(t,e,i){if(0===this.timeline.length)return this;if(void 0===i&&(i=0),-1===i)for(var s=0;s=this.startTime))return X.TweenData.PENDING;this.isRunning=!0}var e=this.game.time.delta;for(var i in this.parent.reverse?(this.dt-=e*this.parent.timeScale,this.dt=Math.max(this.dt,0)):(this.dt+=e*this.parent.timeScale,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent),this.vEnd){var s=this.vStart[i],n=this.vEnd[i];Array.isArray(n)?this.parent.target[i]=this.interpolationFunction.call(this.interpolationContext,n,this.value):this.parent.target[i]=s+(n-s)*this.value}return!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent?this.repeat():X.TweenData.RUNNING},generateData:function(t){this.parent.reverse?this.dt=this.duration:this.dt=0;var e=[],i=!1,s=1/t*1e3;do{this.parent.reverse?(this.dt-=s,this.dt=Math.max(this.dt,0)):(this.dt+=s,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent);var n={};for(var r in this.vEnd){var o=this.vStart[r],a=this.vEnd[r];Array.isArray(a)?n[r]=this.interpolationFunction.call(this.interpolationContext,a,this.value):n[r]=o+(a-o)*this.value}e.push(n),(!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent)&&(i=!0)}while(!i);if(this.yoyo){var h=e.slice();h.reverse(),e=e.concat(h)}return e},repeat:function(){if(this.yoyo){if(this.inReverse&&0===this.repeatCounter){for(var t in this.vStartCache)this.vStart[t]=this.vStartCache[t],this.vEnd[t]=this.vEndCache[t];return this.inReverse=!1,X.TweenData.COMPLETE}this.inReverse=!this.inReverse}else if(0===this.repeatCounter)return X.TweenData.COMPLETE;if(this.inReverse)for(var t in this.vStartCache)this.vStart[t]=this.vEndCache[t],this.vEnd[t]=this.vStartCache[t];else{for(var t in this.vStartCache)this.vStart[t]=this.vStartCache[t],this.vEnd[t]=this.vEndCache[t];0=2*this._desiredFps&&(this.suggestedFps=5*Math.floor(200/(this._elapsedAccumulator/this._frameCount)),this._frameCount=0,this._elapsedAccumulator=0),this.msMin=Math.min(this.msMin,this.elapsed),this.msMax=Math.max(this.msMax,this.elapsed),this.frames++,this.now>this._timeLastSecond+1e3){var t=this.now-this._timeLastSecond;this.fps=Math.round(1e3*this.frames/t),this.ups=Math.round(1e3*this.updates/t),this.rps=Math.round(1e3*this.renders/t),this.fpsMin=Math.min(this.fpsMin,this.fps),this.fpsMax=Math.max(this.fpsMax,this.fps),this._timeLastSecond=this.now,this.frames=0,this.updates=0,this.renders=0}},preUpdate:function(t){t*=1e3,this.delta=t,this.deltaTotal+=t,this.game.paused||(this.events.update(this.deltaTotal),this.updateTimers()),this.advancedTiming&&this.updates++},preRender:function(){this.advancedTiming&&this.renders++},gamePaused:function(){this._pauseStarted=Date.now()},gameResumed:function(){this.time=Date.now(),this.pauseDuration=this.time-this._pauseStarted},totalElapsedSeconds:function(){return.001*(this.time-this._started)},elapsedSince:function(t){return this.time-t},elapsedSecondsSince:function(t){return.001*(this.time-t)},reset:function(){this._started=this.time,this.removeAll()}},Object.defineProperty(X.Time.prototype,"desiredFps",{get:function(){return this._desiredFps},set:function(t){this._desiredFps=t,this.desiredFpsMult=1/t}}),Object.defineProperty(X.Time.prototype,"desiredMinFps",{get:function(){return 1e3/this.deltaMax},set:function(t){this.deltaMax=1e3/t}}),X.Time.prototype.constructor=X.Time,X.Timer=function(t,e){void 0===e&&(e=!0),this.game=t,this.running=!1,this.autoDestroy=e,this.expired=!1,this.elapsed=0,this.events=[],this.onComplete=new X.Signal,this.nextTick=0,this.paused=!1,this._codePaused=!1,this._started=0,this._pauseStarted=0,this._pauseTotal=0,this._now=this.game.time?this.game.time.deltaTotal:0,this._len=0,this._marked=0,this._i=0,this._diff=0,this._newTick=0},X.Timer.MINUTE=6e4,X.Timer.SECOND=1e3,X.Timer.HALF=500,X.Timer.QUARTER=250,X.Timer.prototype={create:function(t,e,i,s,n,r){var o=(t=Math.round(t))+this._now,a=new X.TimerEvent(this,t,o,i,e,s,n,r);return this.events.push(a),this.order(),this.expired=!1,a},add:function(t,e,i){return this.create(t,!1,0,e,i,Array.prototype.slice.call(arguments,3))},repeat:function(t,e,i,s){return this.create(t,!1,e,i,s,Array.prototype.slice.call(arguments,4))},loop:function(t,e,i){return this.create(t,!0,0,e,i,Array.prototype.slice.call(arguments,3))},start:function(t){if(!this.running){this._started=this.game.time.deltaTotal+(t||0),this.running=!0;for(var e=0;ee.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(t){if(this.paused)return!0;if(this.elapsed=t-this._now,this._now=t,this._marked=0,this.clearPendingEvents(),this.running&&this._now>=this.nextTick&&0=e.tick)||e.pendingDelete)break;this._newTick=this._now+e.delay-(this._now-e.tick),this._newTick<0&&(this._newTick=this._now+e.delay),!0===e.loop?e.tick=this._newTick:0this._marked?this.order():(this.expired=!0,this.onComplete.dispatch(this))}return!this.expired||!this.autoDestroy},pause:function(){this.running&&(this._codePaused=!0,this.paused||(this._pauseStarted=this.game.time.deltaTotal,this.paused=!0))},_pause:function(){!this.paused&&this.running&&(this._pauseStarted=this.game.time.deltaTotal,this.paused=!0)},adjustEvents:function(t){for(var e=0;ethis._now?this.nextTick-this._now:0}}),Object.defineProperty(X.Timer.prototype,"length",{get:function(){return this.events.length}}),Object.defineProperty(X.Timer.prototype,"ms",{get:function(){return this.running?this._now-this._started-this._pauseTotal:0}}),Object.defineProperty(X.Timer.prototype,"seconds",{get:function(){return this.running?.001*this.ms:0}}),X.Timer.prototype.constructor=X.Timer,X.TimerEvent=function(t,e,i,s,n,r,o,a){this.timer=t,this.delay=e,this.tick=i,this.repeatCount=s-1,this.loop=n,this.callback=r,this.callbackContext=o,this.args=a,this.pendingDelete=!1},X.TimerEvent.prototype.constructor=X.TimerEvent,X.AnimationManager=function(t){this.sprite=t,this.game=t.game,this.currentFrame=null,this.currentAnim=null,this.updateIfVisible=!0,this.isLoaded=!1,this._frameData=null,this._anims={},this._outputFrames=[]},X.AnimationManager.prototype={loadFrameData:function(t,e){if(void 0===t)return!1;if(this.isLoaded)for(var i in this._anims)this._anims[i].updateFrameData(t);return this._frameData=t,null==e?this.frame=0:"string"==typeof e?this.frameName=e:this.frame=e,this.isLoaded=!0},copyFrameData:function(t,e){if(this._frameData=t.clone(),this.isLoaded)for(var i in this._anims)this._anims[i].updateFrameData(this._frameData);return null==e?this.frame=0:"string"==typeof e?this.frameName=e:this.frame=e,this.isLoaded=!0},add:function(t,e,i,s,n){return e=e||[],i=i||60,void 0===s&&(s=!1),void 0===n&&(n=!(!e||"number"!=typeof e[0])),this._outputFrames=[],this._frameData.getFrameIndexes(e,n,this._outputFrames),this._anims[t]=new X.Animation(this.game,this.sprite,t,this._frameData,this._outputFrames,i,s),this.currentAnim=this._anims[t],this.sprite.tilingTexture&&(this.sprite.refreshTexture=!0),this._anims[t]},validateFrames:function(t,e){void 0===e&&(e=!0);for(var i=0;ithis._frameData.total)return!1}else if(!1===this._frameData.checkFrameName(t[i]))return!1;return!0},play:function(t,e,i,s){if(this._anims[t])return this.currentAnim===this._anims[t]?!1===this.currentAnim.isPlaying?(this.currentAnim.paused=!1,this.currentAnim.play(e,i,s)):this.currentAnim:(this.currentAnim&&this.currentAnim.isPlaying&&this.currentAnim.stop(),this.currentAnim=this._anims[t],this.currentAnim.paused=!1,this.currentFrame=this.currentAnim.currentFrame,this.currentAnim.play(e,i,s))},stop:function(t,e){void 0===e&&(e=!1),!this.currentAnim||"string"==typeof t&&t!==this.currentAnim.name||this.currentAnim.stop(e)},update:function(){return!(this.updateIfVisible&&!this.sprite.visible)&&(!(!this.currentAnim||!this.currentAnim.update())&&(this.currentFrame=this.currentAnim.currentFrame,!0))},next:function(t){this.currentAnim&&(this.currentAnim.next(t),this.currentFrame=this.currentAnim.currentFrame)},previous:function(t){this.currentAnim&&(this.currentAnim.previous(t),this.currentFrame=this.currentAnim.currentFrame)},getAnimation:function(t){return"string"==typeof t&&this._anims[t]?this._anims[t]:null},refreshFrame:function(){},destroy:function(){var t=null;for(var t in this._anims)this._anims.hasOwnProperty(t)&&this._anims[t].destroy();this._anims={},this._outputFrames=[],this._frameData=null,this.currentAnim=null,this.currentFrame=null,this.sprite=null,this.game=null}},X.AnimationManager.prototype.constructor=X.AnimationManager,Object.defineProperty(X.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}}),Object.defineProperty(X.AnimationManager.prototype,"frameTotal",{get:function(){return this._frameData.total}}),Object.defineProperty(X.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(t){this.currentAnim.paused=t}}),Object.defineProperty(X.AnimationManager.prototype,"name",{get:function(){return this.currentAnim?this.currentAnim.name:void 0}}),Object.defineProperty(X.AnimationManager.prototype,"frame",{get:function(){return this.currentFrame?this.currentFrame.index:void 0},set:function(t){var e;"number"==typeof t&&this._frameData&&(e=this._frameData.getFrame(t))&&(this.currentFrame=e,this.sprite.setFrame(this.currentFrame))}}),Object.defineProperty(X.AnimationManager.prototype,"frameName",{get:function(){return this.currentFrame?this.currentFrame.name:void 0},set:function(t){var e;"string"==typeof t&&this._frameData&&(e=this._frameData.getFrameByName(t))?(this.currentFrame=e,this._frameIndex=this.currentFrame.index,this.sprite.setFrame(this.currentFrame)):console.warn("Cannot set frameName: "+t)}}),X.Animation=function(t,e,i,s,n,r,o){void 0===o&&(o=!1),this.game=t,this._parent=e,this._frameData=s,this.name=i,this._frames=[],this._frames=this._frames.concat(n),this.delay=1e3/r,this.loop=o,this.loopCount=0,this.killOnComplete=!1,this.isFinished=!1,this.isPlaying=!1,this.isPaused=!1,this._pauseStartTime=0,this._frameIndex=0,this._frameDiff=0,this._frameSkip=1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.onStart=new X.Signal,this.onUpdate=null,this.onComplete=new X.Signal,this.onLoop=new X.Signal,this.isReversed=!1,this.game.onPause.add(this.onPause,this),this.game.onResume.add(this.onResume,this)},X.Animation.prototype={play:function(t,e,i){return"number"==typeof t&&(this.delay=1e3/t),"boolean"==typeof e&&(this.loop=e),void 0!==i&&(this.killOnComplete=i),this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.deltaTotal,this._timeNextFrame=this.game.time.deltaTotal+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)._parent.animations.currentFrame=this.currentFrame,this},restart:function(){this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.deltaTotal,this._timeNextFrame=this.game.time.deltaTotal+this.delay,this._frameIndex=0,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this._parent.setFrame(this.currentFrame),(this._parent.animations.currentAnim=this)._parent.animations.currentFrame=this.currentFrame,this.onStart.dispatch(this._parent,this)},reverse:function(){return this.reversed=!this.reversed,this},reverseOnce:function(){return this.onComplete.addOnce(this.reverse,this),this.reverse()},setFrame:function(t,e){var i;if(void 0===e&&(e=!1),"string"==typeof t)for(var s=0;sthis.delay&&(this._frameSkip=Math.floor(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay),this._timeNextFrame=t+(this.delay-this._frameDiff),this.isReversed?this._frameIndex-=this._frameSkip:this._frameIndex+=this._frameSkip,!this.isReversed&&this._frameIndex>=this._frames.length||this.isReversed&&this._frameIndex<=-1?this.loop?(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.currentFrame&&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)):(this.complete(),!1):this.updateCurrentFrame(!0))},updateCurrentFrame:function(t,e){if(void 0===e&&(e=!1),!this._frameData)return!1;var i=this.currentFrame.index;return this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&(e||i!==this.currentFrame.index)&&this._parent.setFrame(this.currentFrame),!this.onUpdate||!t||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)},next:function(t){void 0===t&&(t=1);var e=this._frameIndex+t;e>=this._frames.length&&(this.loop?e%=this._frames.length:e=this._frames.length-1),e!==this._frameIndex&&(this._frameIndex=e,this.updateCurrentFrame(!0))},previous:function(t){void 0===t&&(t=1);var e=this._frameIndex-t;e<0&&(this.loop?e=this._frames.length+e:e++),e!==this._frameIndex&&(this._frameIndex=e,this.updateCurrentFrame(!0))},updateFrameData:function(t){this._frameData=t,this.currentFrame=this._frameData?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.game=null,this._parent=null,this._frames=null,this._frameData=null,this.currentFrame=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()}},X.Animation.prototype.constructor=X.Animation,Object.defineProperty(X.Animation.prototype,"paused",{get:function(){return this.isPaused},set:function(t){(this.isPaused=t)?this._pauseStartTime=this.game.time.deltaTotal:this.isPlaying&&(this._timeNextFrame=this.game.time.deltaTotal+this.delay)}}),Object.defineProperty(X.Animation.prototype,"reversed",{get:function(){return this.isReversed},set:function(t){this.isReversed=t}}),Object.defineProperty(X.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}}),Object.defineProperty(X.Animation.prototype,"frame",{get:function(){return null!==this.currentFrame?this.currentFrame.index:this._frameIndex},set:function(t){this.currentFrame=this._frameData.getFrame(this._frames[t]),null!==this.currentFrame&&(this._frameIndex=t,this._parent.setFrame(this.currentFrame),this.onUpdate&&this.onUpdate.dispatch(this,this.currentFrame))}}),Object.defineProperty(X.Animation.prototype,"speed",{get:function(){return 1e3/this.delay},set:function(t){0=this._frames.length&&(t=0),this._frames[t]},getFrameByName:function(t){return"number"==typeof this._frameNames[t]?this._frames[this._frameNames[t]]:null},checkFrameName:function(t){return null!=this._frameNames[t]},clone:function(){for(var t=new X.FrameData,e=0;e tag")}},X.Cache=function(t){this.game=t,this.autoResolveURL=!1,this._cache={canvas:{},image:{},texture:{},sound:{},video:{},text:{},json:{},xml:{},physics:{},tilemap:{},binary:{},bitmapData:{},bitmapFont:{},shader:{},renderTexture:{},compressedTexture:{},data:{}},this._urlMap={},this._urlResolver=new Image,this._urlTemp=null,this.onSoundUnlock=new X.Signal,this._cacheMap=[],this._cacheMap[X.Cache.CANVAS]=this._cache.canvas,this._cacheMap[X.Cache.IMAGE]=this._cache.image,this._cacheMap[X.Cache.TEXTURE]=this._cache.texture,this._cacheMap[X.Cache.SOUND]=this._cache.sound,this._cacheMap[X.Cache.TEXT]=this._cache.text,this._cacheMap[X.Cache.PHYSICS]=this._cache.physics,this._cacheMap[X.Cache.TILEMAP]=this._cache.tilemap,this._cacheMap[X.Cache.BINARY]=this._cache.binary,this._cacheMap[X.Cache.BITMAPDATA]=this._cache.bitmapData,this._cacheMap[X.Cache.BITMAPFONT]=this._cache.bitmapFont,this._cacheMap[X.Cache.JSON]=this._cache.json,this._cacheMap[X.Cache.XML]=this._cache.xml,this._cacheMap[X.Cache.VIDEO]=this._cache.video,this._cacheMap[X.Cache.SHADER]=this._cache.shader,this._cacheMap[X.Cache.RENDER_TEXTURE]=this._cache.renderTexture,this._cacheMap[X.Cache.DATA]=this._cache.data,this._pendingCount=0,this.onReady=new X.Signal,this._addImages()},X.Cache.CANVAS=1,X.Cache.IMAGE=2,X.Cache.TEXTURE=3,X.Cache.SOUND=4,X.Cache.TEXT=5,X.Cache.PHYSICS=6,X.Cache.TILEMAP=7,X.Cache.BINARY=8,X.Cache.BITMAPDATA=9,X.Cache.BITMAPFONT=10,X.Cache.JSON=11,X.Cache.XML=12,X.Cache.VIDEO=13,X.Cache.SHADER=14,X.Cache.RENDER_TEXTURE=15,X.Cache.DATA=16,X.Cache.DEFAULT=null,X.Cache.DEFAULT_KEY="__default",X.Cache.DEFAULT_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==",X.Cache.MISSING=null,X.Cache.MISSING_KEY="__missing",X.Cache.MISSING_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==",X.Cache.READY_TIMEOUT=1e3,X.Cache.prototype={addCompressedTextureMetaData:function(t,e,i,s){this.checkImageKey(t)&&this.removeImage(t);var n=i in X.LoaderParser?X.LoaderParser[i](s):s,r={key:t,url:e,data:n,base:new PIXI.BaseTexture(n,null,this.game.resolution),frame:new X.Frame(0,0,0,n.width,n.height,t),frameData:new X.FrameData,fileFormat:i};return r.frameData.addFrame(new X.Frame(0,0,0,n.width,n.height,e)),this._cache.image[t]=r,this._resolveURL(e,r),r},addCanvas:function(t,e,i){void 0===i&&(i=e.getContext("2d")),this._cache.canvas[t]={canvas:e,context:i}},addImage:function(t,e,i){this.checkImageKey(t)&&this.removeImage(t),!1===i.complete&&console.warn('Phaser.Cache.addImage: Image "%s" is not complete',t);var s={key:t,url:e,data:i,base:new PIXI.BaseTexture(i,null,this.game.resolution),frame:new X.Frame(0,0,0,i.width,i.height,t),frameData:new X.FrameData};return s.frameData.addFrame(new X.Frame(0,0,0,i.width,i.height,e)),this._cache.image[t]=s,this._resolveURL(e,s),"__default"===t?X.Cache.DEFAULT=new PIXI.Texture(s.base):"__missing"===t&&(X.Cache.MISSING=new PIXI.Texture(s.base)),s},addImageAsync:function(t,e,i){var s=this,n=new Image;n.onload=function(){i.call(this,s.addImage(t,null,n)),s._removePending(),n.onload=null},this._addPending(),n.src=e},addDefaultImage:function(){this.addImageAsync(X.Cache.DEFAULT_KEY,X.Cache.DEFAULT_SRC,function(t){t.base.skipRender=!0,X.Cache.DEFAULT=new PIXI.Texture(t.base)})},addMissingImage:function(){this.addImageAsync(X.Cache.MISSING_KEY,X.Cache.MISSING_SRC,function(t){X.Cache.MISSING=new PIXI.Texture(t.base)})},addSound:function(t,e,i,s,n){void 0===s&&(n=!(s=!0)),void 0===n&&(n=!(s=!1));var r=!1;n&&(r=!0),this._cache.sound[t]={url:e,data:i,isDecoding:!1,decoded:r,webAudio:s,audioTag:n,locked:this.game.sound.touchLocked},this._resolveURL(e,this._cache.sound[t])},addText:function(t,e,i){this._cache.text[t]={url:e,data:i},this._resolveURL(e,this._cache.text[t])},addPhysicsData:function(t,e,i,s){this._cache.physics[t]={url:e,data:i,format:s},this._resolveURL(e,this._cache.physics[t])},addTilemap:function(t,e,i,s){this._cache.tilemap[t]={url:e,data:i,format:s},this._resolveURL(e,this._cache.tilemap[t])},addBinary:function(t,e){this._cache.binary[t]=e},addBitmapData:function(t,e,i){return e.key=t,void 0===i&&(i=new X.FrameData).addFrame(e.textureFrame),this._cache.bitmapData[t]={data:e,frameData:i},e},addBitmapFont:function(t,e,i,s,n,r,o){var a={url:e,data:i,font:null,base:new PIXI.BaseTexture(i,null,this.game.resolution)};void 0===r&&(r=0),void 0===o&&(o=0),a.font="json"===n?X.LoaderParser.jsonBitmapFont(s,a.base,r,o,!1,this.game.resolution):X.LoaderParser.xmlBitmapFont(s,a.base,r,o,!1,this.game.resolution),this._cache.bitmapFont[t]=a,this._resolveURL(e,a)},addBitmapFontFromAtlas:function(t,e,i,s,n,r,o){var a=this.getFrameByName(e,i);if(a){var h,l={font:null,base:this.getBaseTexture(e),frame:a};void 0===r&&(r=0),void 0===o&&(o=0),"json"===n?(h=this.getJSON(s),l.font=X.LoaderParser.jsonBitmapFont(h,l.base,r,o,a,this.game.resolution)):(h=this.getXML(s),l.font=X.LoaderParser.xmlBitmapFont(h,l.base,r,o,a,this.game.resolution)),this._cache.bitmapFont[t]=l}},addJSON:function(t,e,i){this._cache.json[t]={url:e,data:i},this._resolveURL(e,this._cache.json[t])},addXML:function(t,e,i){this._cache.xml[t]={url:e,data:i},this._resolveURL(e,this._cache.xml[t])},addVideo:function(t,e,i,s){this._cache.video[t]={url:e,data:i,isBlob:s,locked:!0},this._resolveURL(e,this._cache.video[t])},addShader:function(t,e,i){this._cache.shader[t]={url:e,data:i},this._resolveURL(e,this._cache.shader[t])},addRenderTexture:function(t,e){this._cache.renderTexture[t]={texture:e,frame:new X.Frame(0,0,0,e.width,e.height,"","")}},addSpriteSheet:function(t,e,i,s,n,r,o,a,h){void 0===r&&(r=-1),void 0===o&&(o=0),void 0===a&&(a=0);var l={key:t,url:e,data:i,frameWidth:s,frameHeight:n,margin:o,spacing:a,base:new PIXI.BaseTexture(i,null,this.game.resolution),frameData:X.AnimationParser.spriteSheet(this.game,i,s,n,r,o,a,h)};this._cache.image[t]=l,this._resolveURL(e,l)},addTextureAtlas:function(t,e,i,s,n){var r={key:t,url:e,data:i,base:new PIXI.BaseTexture(i,null,this.game.resolution)};n===X.Loader.TEXTURE_ATLAS_XML_STARLING?r.frameData=X.AnimationParser.XMLData(this.game,s,t):n===X.Loader.TEXTURE_ATLAS_JSON_PYXEL?r.frameData=X.AnimationParser.JSONDataPyxel(this.game,s,t):Array.isArray(s.frames)?r.frameData=X.AnimationParser.JSONData(this.game,s,t):r.frameData=X.AnimationParser.JSONDataHash(this.game,s,t),this._cache.image[t]=r,this._resolveURL(e,r)},addData:function(t,e){this._cache.data[t]=e},reloadSound:function(t){var e=this,i=this.getSound(t);i&&(i.data.src=i.url,i.data.addEventListener("canplaythrough",function(){return e.reloadSoundComplete(t)},!1),i.data.load())},reloadSoundComplete:function(t){var e=this.getSound(t);e&&(e.locked=!1,this.onSoundUnlock.dispatch(t))},updateSound:function(t,e,i){var s=this.getSound(t);s&&(s[e]=i)},decodedSound:function(t,e){var i=this.getSound(t);i.data=e,i.decoded=!0,i.isDecoding=!1},isSoundDecoded:function(t){var e=this.getItem(t,X.Cache.SOUND,"isSoundDecoded");if(e)return e.decoded},isSoundReady:function(t){var e=this.getItem(t,X.Cache.SOUND,"isSoundDecoded");if(e)return e.decoded&&!this.game.sound.touchLocked},checkKey:function(t,e){return!!this._cacheMap[t][e]},checkURL:function(t){return!!this._urlMap[this._resolveURL(t)]},checkCanvasKey:function(t){return this.checkKey(X.Cache.CANVAS,t)},checkDataKey:function(t){return this.checkKey(X.Cache.DATA,t)},checkImageKey:function(t){return this.checkKey(X.Cache.IMAGE,t)},checkTextureKey:function(t){return this.checkKey(X.Cache.TEXTURE,t)},checkSoundKey:function(t){return this.checkKey(X.Cache.SOUND,t)},checkTextKey:function(t){return this.checkKey(X.Cache.TEXT,t)},checkPhysicsKey:function(t){return this.checkKey(X.Cache.PHYSICS,t)},checkTilemapKey:function(t){return this.checkKey(X.Cache.TILEMAP,t)},checkBinaryKey:function(t){return this.checkKey(X.Cache.BINARY,t)},checkBitmapDataKey:function(t){return this.checkKey(X.Cache.BITMAPDATA,t)},checkBitmapFontKey:function(t){return this.checkKey(X.Cache.BITMAPFONT,t)},checkJSONKey:function(t){return this.checkKey(X.Cache.JSON,t)},checkXMLKey:function(t){return this.checkKey(X.Cache.XML,t)},checkVideoKey:function(t){return this.checkKey(X.Cache.VIDEO,t)},checkShaderKey:function(t){return this.checkKey(X.Cache.SHADER,t)},checkRenderTextureKey:function(t){return this.checkKey(X.Cache.RENDER_TEXTURE,t)},getItem:function(t,e,i,s){return this.checkKey(e,t)?void 0===s?this._cacheMap[e][t]:this._cacheMap[e][t][s]:(i&&console.warn("Phaser.Cache."+i+': Key "'+t+'" not found in Cache.'),null)},getCanvas:function(t){return this.getItem(t,X.Cache.CANVAS,"getCanvas","canvas")},getImage:function(t,e){null==t&&(t="__default"),void 0===e&&(e=!1);var i=this.getItem(t,X.Cache.IMAGE,"getImage");return null===i&&(i=this.getItem("__missing",X.Cache.IMAGE,"getImage")),e?i:i.data},getTextureFrame:function(t){return this.getItem(t,X.Cache.TEXTURE,"getTextureFrame","frame")},getSound:function(t){return this.getItem(t,X.Cache.SOUND,"getSound")},getSoundData:function(t){return this.getItem(t,X.Cache.SOUND,"getSoundData","data")},getText:function(t){return this.getItem(t,X.Cache.TEXT,"getText","data")},getPhysicsData:function(t,e,i){var s=this.getItem(t,X.Cache.PHYSICS,"getPhysicsData","data");if(null===s||null==e)return s;if(s[e]){var n=s[e];if(!n||!i)return n;for(var r in n)if((r=n[r]).fixtureKey===i)return r;console.warn('Phaser.Cache.getPhysicsData: Could not find given fixtureKey: "'+i+" in "+t+'"')}else console.warn('Phaser.Cache.getPhysicsData: Invalid key/object: "'+t+" / "+e+'"');return null},getTilemapData:function(t){return this.getItem(t,X.Cache.TILEMAP,"getTilemapData")},getBinary:function(t){return this.getItem(t,X.Cache.BINARY,"getBinary")},getBitmapData:function(t){return this.getItem(t,X.Cache.BITMAPDATA,"getBitmapData","data")},getBitmapFont:function(t){return this.getItem(t,X.Cache.BITMAPFONT,"getBitmapFont")},getJSON:function(t,e){var i=this.getItem(t,X.Cache.JSON,"getJSON","data");return i?e?X.Utils.extend(!0,Array.isArray(i)?[]:{},i):i:null},getXML:function(t){return this.getItem(t,X.Cache.XML,"getXML","data")},getVideo:function(t){return this.getItem(t,X.Cache.VIDEO,"getVideo")},getShader:function(t){return this.getItem(t,X.Cache.SHADER,"getShader","data")},getRenderTexture:function(t){return this.getItem(t,X.Cache.RENDER_TEXTURE,"getRenderTexture")},getData:function(t){return this.getItem(t,X.Cache.DATA,"getData")},getBaseTexture:function(t,e){return void 0===e&&(e=X.Cache.IMAGE),this.getItem(t,e,"getBaseTexture","base")},getFrame:function(t,e){return void 0===e&&(e=X.Cache.IMAGE),this.getItem(t,e,"getFrame","frame")},getFrameCount:function(t,e){var i=this.getFrameData(t,e);return i?i.total:0},getFrameData:function(t,e){return void 0===e&&(e=X.Cache.IMAGE),this.getItem(t,e,"getFrameData","frameData")},hasFrameData:function(t,e){return void 0===e&&(e=X.Cache.IMAGE),null!==this.getItem(t,e,"","frameData")},updateFrameData:function(t,e,i){void 0===i&&(i=X.Cache.IMAGE),this._cacheMap[i][t]&&(this._cacheMap[i][t].frameData=e)},getFrameByIndex:function(t,e,i){var s=this.getFrameData(t,i);return s?s.getFrame(e):null},getFrameByName:function(t,e,i){var s=this.getFrameData(t,i);return s?s.getFrameByName(e):null},getURL:function(t){return(t=this._resolveURL(t))?this._urlMap[t]:(console.warn('Phaser.Cache.getUrl: Invalid url: "'+t+'" or Cache.autoResolveURL was false'),null)},getKeys:function(t){void 0===t&&(t=X.Cache.IMAGE);var e=[];if(this._cacheMap[t])for(var i in this._cacheMap[t])"__default"!==i&&"__missing"!==i&&e.push(i);return e},removeCanvas:function(t){delete this._cache.canvas[t]},removeImage:function(t,e){void 0===e&&(e=!0);var i=this.getImage(t,!0);e&&i.base&&i.base.destroy(),delete this._cache.image[t]},removeSound:function(t){delete this._cache.sound[t]},removeText:function(t){delete this._cache.text[t]},removePhysics:function(t){delete this._cache.physics[t]},removeTilemap:function(t){delete this._cache.tilemap[t]},removeBinary:function(t){delete this._cache.binary[t]},removeBitmapData:function(t){delete this._cache.bitmapData[t]},removeBitmapFont:function(t){delete this._cache.bitmapFont[t]},removeJSON:function(t){delete this._cache.json[t]},removeXML:function(t){delete this._cache.xml[t]},removeVideo:function(t){delete this._cache.video[t]},removeShader:function(t){delete this._cache.shader[t]},removeRenderTexture:function(t){delete this._cache.renderTexture[t]},removeSpriteSheet:function(t){delete this._cache.spriteSheet[t]},removeTextureAtlas:function(t){delete this._cache.image[t]},removeData:function(t){delete this._cache.data[t]},clearGLTextures:function(){for(var t in this._cache.image)this._cache.image[t].base._glTextures=[]},_resolveURL:function(t,e){return this.autoResolveURL?(this._urlResolver.src=this.game.load.baseURL+t,this._urlTemp=this._urlResolver.src,this._urlResolver.src="",e&&(this._urlMap[this._urlTemp]=e),this._urlTemp):null},destroy:function(){for(var t=0;t=i||e&&this._loadedPackCount===this._totalPackCount)break}if(this.updateProgress(),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 n=this;setTimeout(function(){n.finishedLoading(!0)},2e3)}}},finishedLoading:function(t){!this.hasLoaded&&this.game.state&&(this.hasLoaded=!0,this.isLoading=!1,t||this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this.game.state.loadUpdate(),this.onBeforeLoadComplete.dispatch(),this.reset(),this.onLoadComplete.dispatch(),this.game.state.loadComplete())},asyncComplete:function(t,e){void 0===e&&(e=""),t.loaded=!0,t.error=!!e,e&&(t.errorMessage=e,console.warn("Phaser.Loader - "+t.type+"["+t.key+"]: "+e)),this.processLoadQueue()},processPack:function(t){var e=t.data[t.key];if(e)for(var i=0;in.spriteSourceSizeX+n.spriteSourceSizeW&&(f.width-=f.x+f.width-n.spriteSourceSizeX-n.spriteSourceSizeW),f.y+f.height>n.spriteSourceSizeY+n.spriteSourceSizeH&&(f.height-=f.y+f.height-n.spriteSourceSizeY-n.spriteSourceSizeH),f.xr.spriteSourceSizeX+r.spriteSourceSizeW&&(i.width-=i.x+i.width-r.spriteSourceSizeX-r.spriteSourceSizeW),i.y+i.height>r.spriteSourceSizeY+r.spriteSourceSizeH&&(i.height-=i.y+i.height-r.spriteSourceSizeY-r.spriteSourceSizeH),i.x((this.paused?this._tempPause:0)||this.position||0)))return;this._pendingStart=!1,this.startTime=t-1e3*e,this.stopTime=this.startTime+this.durationMS}this.currentTime=t-this.startTime,this.currentTime>=this.durationMS&&(this.usingWebAudio?this.loop?(this.onLoop.dispatch(this),this.isPlaying=!1,""===this.currentMarker?(this.currentTime=0,this.startTime=t,this.isPlaying=!0):(this.onMarkerComplete.dispatch(this.currentMarker,this),this.play(this.currentMarker,0,this.volume,!0,!0,!1))):""!==this.currentMarker&&this.stop():this.loop?(this.onLoop.dispatch(this),""===this.currentMarker&&(this.currentTime=0,this.startTime=t),this.isPlaying=!1,this.play(this.currentMarker,0,this.volume,!0,!0,!1)):this.stop())}}else this.destroy()},loopFull:function(t){return this.play(null,0,t,!0)},play:function(t,e,i,s,n,r){if(void 0!==t&&!1!==t&&null!==t||(t=""),void 0===n&&(n=!0),void 0===r&&(r=!0),this.isPlaying&&!this.allowMultiple&&!n&&!this.override)return this;if(this._sound&&this.isPlaying&&!this.allowMultiple&&(this.override||n)&&(this.usingWebAudio?this._stopSourceAndDisconnect():this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0),this.isPlaying=!1),""===t&&0')},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()},webAudioIsSuspended:function(){return this.usingWebAudio&&"suspended"===this.context.state},resumeWebAudio:function(){if(this.usingWebAudio)return this.context.resume()},resumeWebAudioIfSuspended:function(){if(this.webAudioIsSuspended())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 t=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource(),this._unlockSource.buffer=t,this._unlockSource.connect(this.context.destination);var e=this;this._unlockSource.onended=function(){e.setTouchUnlock(),e.resumeWebAudioIfSuspended()},void 0===this._unlockSource.start?this._unlockSource.noteOn(0):this._unlockSource.start(0),this.resumeWebAudioIfSuspended()}return!0},stopAll:function(){if(!this.noAudio)for(var t=0;tthis.width}}),Object.defineProperty(X.ScaleManager.prototype,"isGameLandscape",{get:function(){return this.width>this.height}}),X.Utils.Debug=function(t){this.game=t,this.sprite=null,this.bmd=null,this.canvas=null,this.context=null,this.font="14px monospace",this.columnWidth=100,this.lineHeight=16,this.lineWidth=1,this.renderShadow=!0,this.currentColor=null,this.currentX=0,this.currentY=0,this.currentAlpha=1,this.dirty=!1,this.isDisabled=!1,this._line=null,this._rect=null},X.Utils.Debug.GEOM_AUTO=0,X.Utils.Debug.GEOM_RECTANGLE=1,X.Utils.Debug.GEOM_CIRCLE=2,X.Utils.Debug.GEOM_POINT=3,X.Utils.Debug.GEOM_LINE=4,X.Utils.Debug.GEOM_ELLIPSE=5,X.Utils.Debug.prototype={boot:function(){this.game.renderType===X.CANVAS?this.context=this.game.context:(this.bmd=new X.BitmapData(this.game,"__DEBUG",this.game.width,this.game.height,!0),this.sprite=this.game.make.image(0,0,this.bmd),this.sprite.anchor.set(0,0),this.game.stage.addChild(this.sprite),this.game.scale.onSizeChange.add(this.resize,this),this.canvas=X.CanvasPool.create(this,this.game.width,this.game.height),this.context=this.canvas.getContext("2d")),this._line=new X.Line,this._rect=new X.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(t,e,i,s){"number"!=typeof t&&(t=0),"number"!=typeof e&&(e=0),i=i||"rgb(255,255,255)",void 0===s&&(s=0),this.currentX=t,this.currentY=e,this.currentColor=i,this.columnWidth=s,this.dirty=!0,this.context.save(),this.context.setTransform(1,0,0,1,0,0),this.context.strokeStyle=i,this.context.fillStyle=i,this.context.font=this.font,this.context.globalAlpha=this.currentAlpha},stop:function(){this.context.restore()},line:function(){for(var t=this.currentX,e=0;e ")+o):o===s._pendingState?this.line("+ "+o):this.line(" "+o)}this.stop()},sound:function(t,e,i){var s=this.game.sound;this.start(t,e,i),s.noAudio?this.line("Audio is disabled"):(this.line("Volume: "+s.volume.toFixed(2)+(s.mute?" (Mute)":"")),this.line("Mute on pause: "+s.muteOnPause),this.line("Using: "+(s.usingWebAudio?"Web Audio - "+s.context.state:"Audio Tag")),this.line("Touch locked: "+s.touchLocked),this.line("Sounds: "+s._sounds.length)),this.stop()},soundInfo:function(t,e,i,s){if(this.start(e,i,s),this.line("Sound: "+t.key+" Touch locked: "+t.game.sound.touchLocked),this.line("Is Ready?: "+this.game.cache.isSoundReady(t.key)+" Pending Playback: "+t.pendingPlayback),this.line("Decoded: "+t.isDecoded+" Decoding: "+t.isDecoding),this.line("Playing: "+t.isPlaying+" Loop: "+t.loop),this.line("Time: "+(t.currentTime/1e3).toFixed(3)+"s Total: "+t.totalDuration.toFixed(3)+"s"),this.line("Volume: "+t.volume.toFixed(2)+(t.mute?" (Mute)":"")),this.line("Using: "+(t.usingWebAudio?"Web Audio":"Audio Tag")),t.usingWebAudio&&this.line(" Source: "+(t.sourceId||"none")),t.usingAudioTag&&t._sound){var n=t._sound;this.line(" currentSrc: "+n.currentSrc),this.line(" currentTime: "+n.currentTime),this.line(" duration: "+n.duration),this.line(" ended: "+n.ended),this.line(" loop: "+n.loop),this.line(" muted: "+n.muted),this.line(" paused: "+n.paused)}""!==t.currentMarker&&(this.line("Marker: "+t.currentMarker+" Duration: "+t.duration.toFixed(3)+"s ("+t.durationMS+"ms)"),this.line("Start: "+t.markers[t.currentMarker].start.toFixed(3)+" Stop: "+t.markers[t.currentMarker].stop.toFixed(3)),this.line("Position: "+t.position.toFixed(3))),this.stop()},camera:function(t,e,i){var s=t.deadzone,n=t.target,r=t.view;s&&(this._rect.setTo(r.x+s.x,r.y+s.y,s.width,s.height),this.rectangle(this._rect,e,i)),n&&(this._line.setTo(r.centerX,r.centerY,n.x,n.y),this.geom(this._line,e,i),this.geom(n,e,!1,3))},cameraInfo:function(t,e,i,s){var n=t.bounds,r=t.deadzone,o=t.target,a=t.view;this.start(e,i,s),this.line("Camera ("+t.width+" x "+t.height+")"),this.line("x: "+t.x+" y: "+t.y),this.line("Bounds: "+(n?"x: "+n.x+" y: "+n.y+" w: "+n.width+" h: "+n.height:"none")),this.line("View: x: "+a.x+" y: "+a.y+" w: "+a.width+" h: "+a.height),this.line("Center: x: "+t.centerX+" y: "+t.centerY),this.line("Deadzone: "+(r?"x: "+r.x+" y: "+r.y+" w: "+r.width+" h: "+r.height:r)),this.line("Total in view: "+t.totalInView),this.line("At limit: x: "+t.atLimit.x+" y: "+t.atLimit.y),this.line("Target: "+(o?o.name||o:"none")),this.stop()},timer:function(t,e,i,s){this.start(e,i,s),this.line("Timer (running: "+t.running+" expired: "+t.expired+")"),this.line("Next Tick: "+t.next+" Duration: "+t.duration),this.line("Paused: "+t.paused+" Length: "+t.length),this.stop()},pointer:function(t,e,i,s,n,r){if(null!=t&&(void 0===e&&(e=!1),i=i||"rgba(0,255,0,0.5)",s=s||"rgba(255,255,0,0.5)",r=r||"rgba(255,0,0,0.5)",!0!==e||!0!==t.isUp)){this.start(t.x,t.y-150,n),this.context.beginPath(),this.context.arc(t.x,t.y,t.circle.radius,0,2*Math.PI),t.active?this.context.fillStyle=t.isDown?i:s:this.context.fillStyle=r,this.context.fill(),this.context.closePath(),this.context.beginPath(),this.context.moveTo(t.positionDown.x,t.positionDown.y),this.context.lineTo(t.position.x,t.position.y),this.context.lineWidth=2,this.context.stroke(),this.context.closePath();var o=t.movementX,a=t.movementY;(o||a)&&(this.context.beginPath(),this.context.moveTo(o+t.position.x,a+t.position.y),this.context.lineTo(t.position.x,t.position.y),this.context.lineWidth=2,this.context.stroke(),this.context.closePath()),this.line("ID: "+t.id+" Active: "+t.active),this.line("World X: "+t.worldX.toFixed(1)+" World Y: "+t.worldY.toFixed(1)),this.line("Screen X: "+t.x.toFixed(1)+" Screen Y: "+t.y.toFixed(1)+" In: "+t.withinGame),this.line("Movement: X: "+o+" Y: "+a),this.line("Duration: "+t.duration+" ms"),this.line("is Down: "+t.isDown+" is Up: "+t.isUp),this.line("Identifier: "+t.identifier+" Pointer ID: "+t.pointerId),t.isMouse&&this.line("Buttons: "+this._pointerButtonIcon(t.leftButton)+" "+this._pointerButtonIcon(t.middleButton)+" "+this._pointerButtonIcon(t.rightButton)),this.stop()}},_pointerButtonIcon:function(t){return t.isDown?"x":t.isUp?"o":"-"},spriteInputInfo:function(t,e,i,s){this.start(e,i,s),this.line("Sprite Input: ("+t.width+" x "+t.height+")"),this.line("x: "+t.input.pointerX().toFixed(1)+" y: "+t.input.pointerY().toFixed(1)),this.line("over: "+t.input.pointerOver()+" duration: "+t.input.overDuration().toFixed(0)),this.line("down: "+t.input.pointerDown()+" duration: "+t.input.downDuration().toFixed(0)),this.line("just over: "+t.input.justOver()+" just out: "+t.input.justOut()),this.stop()},key:function(t,e,i,s){this.start(e,i,s,150),this.line("Key:",t.keyCode,"isDown:",t.isDown),this.line("justDown:",t.justDown,"justUp:",t.justUp),this.line("Time Down:",t.timeDown.toFixed(0),"duration:",t.duration.toFixed(0)),this.stop()},inputInfo:function(t,e,i,s){var n=this.game.input;if(void 0===s&&(s=!0),this.start(t,e,i),this.line("Input"),this.line("X: "+n.x+" Y: "+n.y),this.line("World X: "+n.worldX+" World Y: "+n.worldY),this.line("Scale X: "+n.scale.x.toFixed(2)+" Scale Y: "+n.scale.x.toFixed(2)),this.line("Screen X: "+n.activePointer.screenX.toFixed(1)+" Screen Y: "+n.activePointer.screenY.toFixed(1)),s){this.line("Sources:"),this.line(" "+this._inputHandler(n.mouse,"mouse")),this.line(" "+this._inputHandler(n.mspointer,"mspointer")),this.line(" "+this._inputHandler(n.touch,"touch"));var r=n.pointers,o=n.mousePointer,a=X.PointerModes,h=0,l=0;this.line("Pointers:"),this.line(" "+(o.isDown?"x":"o")+" "+a[o.pointerMode]+" "+o.identifier);for(var c=0;ce.width?s:n;if("viewport"===t)return this.visualBounds.height>this.visualBounds.width?s:n;if("window.orientation"===t&&"number"==typeof window.orientation)return 0===window.orientation||180===window.orientation?s:n;if(window.matchMedia){if(window.matchMedia("(orientation: portrait)").matches)return s;if(window.matchMedia("(orientation: landscape)").matches)return n}return this.visualBounds.height>this.visualBounds.width?s:n},visualBounds:new X.Rectangle,layoutBounds:new X.Rectangle,documentBounds:new X.Rectangle},X.Device.whenReady(function(t){var e=window&&"pageXOffset"in window?function(){return window.pageXOffset}:function(){return document.documentElement.scrollLeft},i=window&&"pageYOffset"in window?function(){return window.pageYOffset}:function(){return document.documentElement.scrollTop};if(Object.defineProperty(X.DOM,"scrollX",{get:e}),Object.defineProperty(X.DOM,"scrollY",{get:i}),Object.defineProperty(X.DOM.visualBounds,"x",{get:e}),Object.defineProperty(X.DOM.visualBounds,"y",{get:i}),Object.defineProperty(X.DOM.layoutBounds,"x",{value:0}),Object.defineProperty(X.DOM.layoutBounds,"y",{value:0}),t.desktop&&document.documentElement.clientWidth<=window.innerWidth&&document.documentElement.clientHeight<=window.innerHeight){var s=function(){return Math.max(window.innerWidth,document.documentElement.clientWidth)},n=function(){return Math.max(window.innerHeight,document.documentElement.clientHeight)};Object.defineProperty(X.DOM.visualBounds,"width",{get:s}),Object.defineProperty(X.DOM.visualBounds,"height",{get:n}),Object.defineProperty(X.DOM.layoutBounds,"width",{get:s}),Object.defineProperty(X.DOM.layoutBounds,"height",{get:n})}else Object.defineProperty(X.DOM.visualBounds,"width",{get:function(){return window.innerWidth}}),Object.defineProperty(X.DOM.visualBounds,"height",{get:function(){return window.innerHeight}}),Object.defineProperty(X.DOM.layoutBounds,"width",{get:function(){var t=document.documentElement.clientWidth,e=window.innerWidth;return t>>0:(t<<24|e<<16|i<<8|s)>>>0},unpackPixel:function(t,e,i,s){return null==e&&(e=X.Color.createColor()),null==i&&(i=!1),null==s&&(s=!1),X.Device.LITTLE_ENDIAN?(e.a=(4278190080&t)>>>24,e.b=(16711680&t)>>>16,e.g=(65280&t)>>>8,e.r=255&t):(e.r=(4278190080&t)>>>24,e.g=(16711680&t)>>>16,e.b=(65280&t)>>>8,e.a=255&t),e.color=t,e.rgba="rgba("+e.r+","+e.g+","+e.b+","+e.a/255+")",i&&X.Color.RGBtoHSL(e.r,e.g,e.b,e),s&&X.Color.RGBtoHSV(e.r,e.g,e.b,e),e},fromRGBA:function(t,e){return e||(e=X.Color.createColor()),e.r=(4278190080&t)>>>24,e.g=(16711680&t)>>>16,e.b=(65280&t)>>>8,e.a=255&t,e.rgba="rgba("+e.r+","+e.g+","+e.b+","+e.a+")",e},toRGBA:function(t,e,i,s){return t<<24|e<<16|i<<8|s},toABGR:function(t,e,i,s){return(s<<24|i<<16|e<<8|t)>>>0},hexToRGBArray:function(t){return[(t>>16&255)/255,(t>>8&255)/255,(255&t)/255]},RGBArrayToHex:function(t){return(255*t[0]<<16)+(255*t[1]<<8)+255*t[2]},RGBtoHSL:function(t,e,i,s){s||(s=X.Color.createColor(t,e,i,1)),t/=255,e/=255,i/=255;var n=Math.min(t,e,i),r=Math.max(t,e,i);if(s.h=0,s.s=0,s.l=(r+n)/2,r!==n){var o=r-n;s.s=.5p.h){var g=p.h;p.h=d.h,d.h=g,f=-f,s=i-s}.5>>24,red:t>>16&255,green:t>>8&255,blue:255&t,a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{alpha:255,red:t>>16&255,green:t>>8&255,blue:255&t,a:255,r:t>>16&255,g:t>>8&255,b:255&t}},getWebRGB:function(t){if("object"==typeof t)return"rgba("+t.r.toString()+","+t.g.toString()+","+t.b.toString()+","+(t.a/255).toString()+")";var e=X.Color.getRGB(t);return"rgba("+e.r.toString()+","+e.g.toString()+","+e.b.toString()+","+(e.a/255).toString()+")"},getAlpha:function(t){return t>>>24},getAlphaFloat:function(t){return(t>>>24)/255},getRed:function(t){return t>>16&255},getGreen:function(t){return t>>8&255},getBlue:function(t){return 255&t},blendNormal:function(t){return t},blendLighten:function(t,e){return t>8)},blendExclusion:function(t,e){return t+e-2*t*e/255},blendOverlay:function(t,e){return e<128?2*t*e/255:255-2*(255-t)*(255-e)/255},blendSoftLight:function(t,e){return e<128?2*(64+(t>>1))*(e/255):255-2*(255-(64+(t>>1)))*(255-e)/255},blendHardLight:function(t,e){return X.Color.blendOverlay(e,t)},blendColorDodge:function(t,e){return 255===e?e:Math.min(255,(t<<8)/(255-e))},blendColorBurn:function(t,e){return 0===e?e:Math.max(0,255-(255-t<<8)/e)},blendLinearDodge:function(t,e){return X.Color.blendAdd(t,e)},blendLinearBurn:function(t,e){return X.Color.blendSubtract(t,e)},blendLinearLight:function(t,e){return e<128?X.Color.blendLinearBurn(t,2*e):X.Color.blendLinearDodge(t,2*(e-128))},blendVividLight:function(t,e){return e<128?X.Color.blendColorBurn(t,2*e):X.Color.blendColorDodge(t,2*(e-128))},blendPinLight:function(t,e){return e<128?X.Color.blendDarken(t,2*e):X.Color.blendLighten(t,2*(e-128))},blendHardMix:function(t,e){return X.Color.blendVividLight(t,e)<128?0:255},blendReflect:function(t,e){return 255===e?e:Math.min(255,t*t/(255-e))},blendGlow:function(t,e){return X.Color.blendReflect(e,t)},blendPhoenix:function(t,e){return Math.min(t,e)-Math.max(t,e)+255}},X.Physics=function(t,e){e=e||{},this.game=t,this.config=e,this.arcade=null,this.p2=null,this.ninja=null,this.box2d=null,this.chipmunk=null,this.matter=null,this.parseConfig()},X.Physics.ARCADE=0,X.Physics.P2JS=1,X.Physics.NINJA=2,X.Physics.BOX2D=3,X.Physics.CHIPMUNK=4,X.Physics.MATTERJS=5,X.Physics.prototype={parseConfig:function(){this.config.hasOwnProperty("arcade")&&!0!==this.config.arcade||!X.Physics.hasOwnProperty("Arcade")||(this.arcade=new X.Physics.Arcade(this.game)),this.config.hasOwnProperty("ninja")&&!0===this.config.ninja&&X.Physics.hasOwnProperty("Ninja")&&(this.ninja=new X.Physics.Ninja(this.game)),this.config.hasOwnProperty("p2")&&!0===this.config.p2&&X.Physics.hasOwnProperty("P2")&&(this.p2=new X.Physics.P2(this.game,this.config)),this.config.hasOwnProperty("box2d")&&!0===this.config.box2d&&X.Physics.hasOwnProperty("BOX2D")&&(this.box2d=new X.Physics.Box2D(this.game,this.config)),this.config.hasOwnProperty("matter")&&!0===this.config.matter&&X.Physics.hasOwnProperty("Matter")&&(this.matter=new X.Physics.Matter(this.game,this.config))},startSystem:function(t){t===X.Physics.ARCADE?this.arcade=new X.Physics.Arcade(this.game):t===X.Physics.P2JS?null===this.p2?this.p2=new X.Physics.P2(this.game,this.config):this.p2.reset():t===X.Physics.NINJA?this.ninja=new X.Physics.Ninja(this.game):t===X.Physics.BOX2D?null===this.box2d?this.box2d=new X.Physics.Box2D(this.game,this.config):this.box2d.reset():t===X.Physics.MATTERJS&&(null===this.matter?this.matter=new X.Physics.Matter(this.game,this.config):this.matter.reset())},enable:function(t,e,i){void 0===e&&(e=X.Physics.ARCADE),void 0===i&&(i=!1),e===X.Physics.ARCADE?this.arcade.enable(t):e===X.Physics.P2JS&&this.p2?this.p2.enable(t,i):e===X.Physics.NINJA&&this.ninja?this.ninja.enableAABB(t):e===X.Physics.BOX2D&&this.box2d?this.box2d.enable(t):e===X.Physics.MATTERJS&&this.matter?this.matter.enable(t):console.warn(t.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.arcade=null,this.ninja=null,this.p2=null,this.box2d=null,this.matter=null}},X.Physics.prototype.constructor=X.Physics,X.Physics.Arcade=function(t){this.game=t,this.gravity=new X.Point,this.bounds=new X.Rectangle(0,0,t.world.width,t.world.height),this.checkCollision={up:!0,down:!0,left:!0,right:!0},this.maxObjects=10,this.maxLevels=4,this.OVERLAP_BIAS=4,this.forceX=!1,this.sortDirection=X.Physics.Arcade.LEFT_RIGHT,this.skipQuadTree=!0,this.isPaused=!1,this.quadTree=new X.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()},X.Physics.Arcade.prototype.constructor=X.Physics.Arcade,X.Physics.Arcade.SORT_NONE=0,X.Physics.Arcade.LEFT_RIGHT=1,X.Physics.Arcade.RIGHT_LEFT=2,X.Physics.Arcade.TOP_BOTTOM=3,X.Physics.Arcade.BOTTOM_TOP=4,X.Physics.Arcade.prototype={setBounds:function(t,e,i,s){this.bounds.setTo(t,e,i,s)},setBoundsToWorld:function(){this.bounds.copyFrom(this.game.world.bounds)},enable:function(t,e){void 0===e&&(e=!0);var i=1;if(Array.isArray(t))for(i=t.length;i--;)t[i]instanceof X.Group?this.enable(t[i].children,e):(this.enableBody(t[i]),e&&t[i].hasOwnProperty("children")&&0o.right)break;if(o.x>t.body.right)continue}else if(this.sortDirection===X.Physics.Arcade.TOP_BOTTOM){if(t.body.bottomo.bottom)break;if(o.y>t.body.bottom)continue}this.collideSpriteVsSprite(t,h,i,s,n,r)}}else{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(e);var l=this.quadTree.retrieve(t);for(a=0;al.right)continue;if(l.x>o.right)break}else if(this.sortDirection===X.Physics.Arcade.TOP_BOTTOM){if(o.bottoml.bottom)continue;if(l.y>a.body.bottom)break}this.collideSpriteVsSprite(a,c,e,i,s,n)}}}}},collideGroupVsGroup:function(t,e,i,s,n,r){if(0!==t.length&&0!==e.length)for(var o=0;oc)&&(u.xl))return this.separateCircle(t,e,n)}var d=!1,p=!1;this.forceX||Math.abs(this.gravity.y+t.gravity.y)=e.right)&&!(t.position.y>=e.bottom))))},circleBodyIntersects:function(t,e){var i=X.Math.clamp(t.center.x,e.left,e.right),s=X.Math.clamp(t.center.y,e.top,e.bottom);return(t.center.x-i)*(t.center.x-i)+(t.center.y-s)*(t.center.y-s)<=t.halfWidth*t.halfWidth},separateCircle:function(t,e,i){this.getOverlapX(t,e),this.getOverlapY(t,e);var s=e.center.x-t.center.x,n=e.center.y-t.center.y,r=Math.atan2(n,s),o=0;if(t.isCircle!==e.isCircle){var a={x:e.isCircle?t.position.x:e.position.x,y:e.isCircle?t.position.y:e.position.y,right:e.isCircle?t.right:e.right,bottom:e.isCircle?t.bottom:e.bottom},h={x:t.isCircle?t.center.x:e.center.x,y:t.isCircle?t.center.y:e.center.y,radius:t.isCircle?t.halfWidth:e.halfWidth};h.yt.velocity.x?t.velocity.x*=-1:e.velocity.x<0&&!e.immovable&&t.velocity.xt.velocity.y?t.velocity.y*=-1:e.velocity.y<0&&!e.immovable&&t.velocity.yMath.PI/2&&(t.velocity.x<0&&!t.immovable&&e.velocity.xe.velocity.x?e.velocity.x*=-1:t.velocity.y<0&&!t.immovable&&e.velocity.ye.velocity.y&&(e.velocity.y*=-1)),t.immovable||(t.x+=.001*t.velocity.x*this.game.time.delta-o*Math.cos(r),t.y+=.001*t.velocity.y*this.game.time.delta-o*Math.sin(r)),e.immovable||(e.x+=.001*e.velocity.x*this.game.time.delta+o*Math.cos(r),e.y+=.001*e.velocity.y*this.game.time.delta+o*Math.sin(r)),t.onCollide&&t.onCollide.dispatch(t.sprite,e.sprite),e.onCollide&&e.onCollide.dispatch(e.sprite,t.sprite),!0},getOverlapX:function(t,e,i){var s=0,n=t.deltaAbsX()+e.deltaAbsX()+this.OVERLAP_BIAS;return 0===t.deltaX()&&0===e.deltaX()?(t.embedded=!0,e.embedded=!0):t.deltaX()>e.deltaX()?n<(s=t.right-e.x)&&!i||!1===t.checkCollision.right||!1===e.checkCollision.left?s=0:(t.touching.none=!1,t.touching.right=!0,e.touching.none=!1,e.touching.left=!0):t.deltaX()e.deltaY()?n<(s=t.bottom-e.y)&&!i||!1===t.checkCollision.down||!1===e.checkCollision.up?s=0:(t.touching.none=!1,t.touching.down=!0,e.touching.none=!1,e.touching.up=!0):t.deltaY()this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&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 t=this.position,e=this.game.physics.arcade.bounds,i=this.game.physics.arcade.checkCollision,s=this.worldBounce?-this.worldBounce.x:-this.bounce.x,n=this.worldBounce?-this.worldBounce.y:-this.bounce.y;return t.xe.right&&i.right&&(t.x=e.right-this.width,this.velocity.x*=s,this.blocked.right=!0,this.blocked.none=!1),t.ye.bottom&&i.down&&(t.y=e.bottom-this.height,this.velocity.y*=n,this.blocked.down=!0,this.blocked.none=!1),!this.blocked.none},moveFrom:function(t,e,i){return void 0===e&&(e=this.speed),0!==e&&(void 0===i?(s=this.angle,i=this.game.math.radToDeg(s)):s=this.game.math.degToRad(i),this.moveTimer=0,this.moveDuration=t,0===i||180===i?this.velocity.set(Math.cos(s)*e,0):90===i||270===i?this.velocity.set(0,Math.sin(s)*e):this.velocity.setToPolar(s,e),this.isMoving=!0);var s},moveTo:function(t,e,i){var s,n=e/(t/1e3);return 0!==n&&(void 0===i?(s=this.angle,i=this.game.math.radToDeg(s)):s=this.game.math.degToRad(i),e=Math.abs(e),this.moveDuration=0,this.moveDistance=e,null===this.moveTarget&&(this.moveTarget=new X.Line,this.moveEnd=new X.Point),this.moveTarget.fromAngle(this.x,this.y,s,e),this.moveEnd.set(this.moveTarget.end.x,this.moveTarget.end.y),this.moveTarget.setTo(this.x,this.y,this.x,this.y),0===i||180===i?this.velocity.set(Math.cos(s)*n,0):90===i||270===i?this.velocity.set(0,Math.sin(s)*n):this.velocity.setToPolar(s,n),this.isMoving=!0)},setSize:function(t,e,i,s){void 0===i&&(i=this.offset.x),void 0===s&&(s=this.offset.y),this.sourceWidth=t,this.sourceHeight=e,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(i,s),this.updateCenter(),this.isCircle=!1,this.radius=0},setCircle:function(t,e,i){void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),0e.deltaAbsY()?l=-1:e.deltaAbsX()e.left&&(s=t.right-n-e.left)>this.TILE_BIAS&&(s=0),0!==s&&(t.customSeparateX?t.overlapX=s:this.processTileSeparationX(t,s)),s},tileCheckY:function(t,e,i){var s=0,n=i.getTileOffsetY();return t.deltaY()<0&&!t.blocked.up&&e.collideDown&&t.checkCollision.up?e.faceBottom&&t.y-ne.top&&(s=t.bottom-n-e.top)>this.TILE_BIAS&&(s=0),0!==s&&(t.customSeparateY?t.overlapY=s:this.processTileSeparationY(t,s)),s},processTileSeparationX:function(t,e){e<0?(t.blocked.left=!0,t.blocked.none=!1):0=this.firstgid&&tthis.right||e>this.bottom)},intersects:function(t,e,i,s){return!(i<=this.worldX)&&(!(s<=this.worldY)&&(!(t>=this.worldX+this.width)&&!(e>=this.worldY+this.height)))},setCollisionCallback:function(t,e){this.collisionCallback=t,this.collisionCallbackContext=e},destroy:function(){this.collisionCallback=null,this.collisionCallbackContext=null,this.properties=null},setCollision:function(t,e,i,s){this.collideLeft=t,this.collideRight=e,this.collideUp=i,this.collideDown=s,this.faceLeft=t,this.faceRight=e,this.faceTop=i,this.faceBottom=s},resetCollision:function(){this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1},isInteresting:function(t,e){return t&&e?this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.faceTop||this.faceBottom||this.faceLeft||this.faceRight||this.collisionCallback:t?this.collideLeft||this.collideRight||this.collideUp||this.collideDown:!!e&&(this.faceTop||this.faceBottom||this.faceLeft||this.faceRight)},copy:function(t){this.index=t.index,this.alpha=t.alpha,this.properties=t.properties,this.collideUp=t.collideUp,this.collideDown=t.collideDown,this.collideLeft=t.collideLeft,this.collideRight=t.collideRight,this.collisionCallback=t.collisionCallback,this.collisionCallbackContext=t.collisionCallbackContext}},X.Tile.prototype.constructor=X.Tile,Object.defineProperty(X.Tile.prototype,"collides",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}}),Object.defineProperty(X.Tile.prototype,"canCollide",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}}),Object.defineProperty(X.Tile.prototype,"left",{get:function(){return this.worldX}}),Object.defineProperty(X.Tile.prototype,"right",{get:function(){return this.worldX+this.width}}),Object.defineProperty(X.Tile.prototype,"top",{get:function(){return this.worldY}}),Object.defineProperty(X.Tile.prototype,"bottom",{get:function(){return this.worldY+this.height}}),X.Tilemap=function(t,e,i,s,n,r){this.game=t,this.key=e;var o=X.TilemapParser.parse(this.game,e,i,s,n,r);null!==o&&(this.width=o.width,this.height=o.height,this.tileWidth=o.tileWidth,this.tileHeight=o.tileHeight,this.orientation=o.orientation,this.format=o.format,this.version=o.version,this.properties=o.properties,this.widthInPixels=o.widthInPixels,this.heightInPixels=o.heightInPixels,this.layers=o.layers,this.tilesets=o.tilesets,this.imagecollections=o.imagecollections,this.tiles=o.tiles,this.objects=o.objects,this.objectsMap=o.objectsMap,this.collideIndexes=[],this.collision=o.collision,this.images=o.images,this.enableDebug=!1,this.currentLayer=0,this.debugMap=[],this._results=[],this._tempA=0,this._tempB=0)},X.Tilemap.CSV=0,X.Tilemap.TILED_JSON=1,X.Tilemap.NORTH=0,X.Tilemap.EAST=1,X.Tilemap.SOUTH=2,X.Tilemap.WEST=3,X.Tilemap.prototype={create:function(t,e,i,s,n,r){return void 0===r&&(r=this.game.world),this.width=e,this.height=i,this.setTileSize(s,n),this.layers.length=0,this.createBlankLayer(t,e,i,s,n,r)},setTileSize:function(t,e){this.tileWidth=t,this.tileHeight=e,this.widthInPixels=this.width*t,this.heightInPixels=this.height*e},addTilesetImage:function(t,e,i,s,n,r,o){if(void 0===t)return null;void 0===i&&(i=this.tileWidth),void 0===s&&(s=this.tileHeight),void 0===n&&(n=0),void 0===r&&(r=0),void 0===o&&(o=0),0===i&&(i=32),0===s&&(s=32);var a=null;if(null==e&&(e=t),X.BitmapData&&e instanceof X.BitmapData)a=e.canvas;else{if(!this.game.cache.checkImageKey(e))return console.warn('Phaser.Tilemap.addTilesetImage: Invalid image key given: "'+e+'"'),null;a=this.game.cache.getImage(e)}var h=this.getTilesetIndex(t);if(null===h&&this.format===X.Tilemap.TILED_JSON)return console.warn('Phaser.Tilemap.addTilesetImage: No data found in the JSON matching the tileset name: "'+t+'"'),console.log("Tilesets: ",this.tilesets),null;if(this.tilesets[h])return this.tilesets[h].setImage(a),this.tilesets[h];var l=new X.Tileset(t,o,i,s,n,r,{});l.setImage(a),this.tilesets.push(l);for(var c=this.tilesets.length-1,u=n,d=n,p=0,f=0,g=0,m=o;mthis.layers.length)return console.warn('Tilemap.createLayer: Invalid layer ID given: "'+t+'"'),void console.log("Layers: ",this.layers);void 0===e||e<=0?e=Math.min(this.game.width,this.layers[n].widthInPixels):e>this.game.width&&(e=this.game.width),void 0===i||i<=0?i=Math.min(this.game.height,this.layers[n].heightInPixels):i>this.game.height&&(i=this.game.height),this.enableDebug&&(console.group("Tilemap.createLayer"),console.log("Name:",this.layers[n].name),console.log("Size:",e,"x",i),console.log("Tileset:",this.tilesets[0].name,"index:",n));var r=s.add(new X.TilemapLayer(this.game,this,n,e,i));return this.enableDebug&&console.groupEnd(),r},createBlankLayer:function(t,e,i,s,n,r){if(void 0===r&&(r=this.game.world),null===this.getLayerIndex(t)){for(var o,a={name:t,x:0,y:0,width:e,height:i,widthInPixels:e*s,heightInPixels:i*n,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:null},h=[],l=0;lthis.game.width&&(u=this.game.width),d>this.game.height&&(d=this.game.height),(h=new X.TilemapLayer(this.game,this,this.layers.length-1,u,d)).name=t,r.add(h)}console.warn("Tilemap.createBlankLayer: Layer with matching name already exists: "+t)},getIndex:function(t,e){for(var i=0;ithis.layers[n].width&&(i=this.layers[n].width),s>this.layers[n].height&&(s=this.layers[n].height),this._results.length=0,this._results.push({x:t,y:e,width:i,height:s,layer:n});for(var r=e;r>>0;n.data=a,delete n.encoding}else if(n.compression){console.warn('Layer compression is unsupported, skipping layer "%s".',n.name);continue}var l={name:n.name,x:n.x,y:n.y,width:n.width,height:n.height,widthInPixels:n.width*t.tilewidth,heightInPixels:n.height*t.tileheight,alpha:n.opacity,offsetX:n.offsetx,offsetY:n.offsety,visible:n.visible,properties:{},indexes:[],callbacks:[],bodies:[]};n.properties&&(l.properties=n.properties);var c,u,d,p=0,f=[],g=[],m=0;for(o=n.data.length;m=this.firstgid&&t=this._timer)if(this._timer=this.game.time.deltaTotal+this.frequency,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(t=this.children.length;t--;)this.children[t].exists&&this.children[t].update()},X.Particles.Arcade.Emitter.prototype.makeParticles=function(t,e,i,s,n,r){var o;void 0===e&&(e=0),void 0===i&&(i=this.maxParticles),void 0===s&&(s=!1),void 0===n&&(n=!1),void 0===r&&(r=null);var a=0,h=t,l=e;for(this._frames=e,i>this.maxParticles&&(this.maxParticles=i);athis.maxParticles&&(i=this.maxParticles),this._counter=0,this._flowQuantity=i,this._flowTotal=s,n?(this.start(!0,t,e,i),this._counter+=i,this.on=!0,this._timer=this.game.time.deltaTotal+e):this.start(!1,t,e,i),this},X.Particles.Arcade.Emitter.prototype.start=function(t,e,i,s,n){if(void 0===t&&(t=!0),void 0===e&&(e=0),null==i&&(i=250),void 0===s&&(s=0),void 0===n&&(n=!1),s>this.maxParticles&&(s=this.maxParticles),this.revive(),this.visible=!0,this.lifespan=e,this.frequency=i,t||n)for(var r=0;r=this.bulletFrames.length&&(this.bulletFrameIndex=0)):this.bulletFrameRandom&&(u.frame=this.bulletFrames[Math.floor(Math.random()*this.bulletFrames.length)]);u.data.bodyDirty&&(this._data.customBody&&u.body.setSize(this._data.width,this._data.height,this._data.offsetX,this._data.offsetY),u.body.collideWorldBounds=this.bulletCollideWorldBounds,u.data.bodyDirty=!1),u.body.velocity.set(l,c),u.body.gravity.set(this.bulletGravity.x,this.bulletGravity.y);var p=0;if(0!==this.bulletSpeedVariance){var f=this.fireRate;(f+=X.Math.between(-this.fireRateVariance,this.fireRateVariance))<0&&(f=0),p=this.game.time.deltaTotal+f}else p=this.game.time.deltaTotal+this.fireRate;this.multiFire?this._hasFired||(this._hasFired=!0,this._tempNextFire=p,this.shots++):(this._nextFire=p,this.shots++),this.onFire.dispatch(u,this,r),0X.Weapon.KILL_LIFESPAN&&(this.data.killType===X.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))},X.Video=function(t,e,i){if(void 0===e&&(e=null),void 0===i&&(i=null),this.game=t,this.key=e,this.width=0,this.height=0,this.type=X.VIDEO,this.disableTextureUpload=!1,this.touchLocked=!1,this.onPlay=new X.Signal,this.onChangeSource=new X.Signal,this.onComplete=new X.Signal,this.onAccess=new X.Signal,this.onError=new X.Signal,this.onTimeout=new X.Signal,this.onTouchUnlock=new X.Signal,this.playWhenUnlocked=!0,this.timeout=15e3,this._timeOutID=null,this.video=null,this.videoStream=null,this.isStreaming=!1,this.retryLimit=20,this.retry=0,this.retryInterval=500,this._retryID=null,this._codeMuted=!1,this._muted=!1,this._codePaused=!1,this._paused=!1,this._pending=!1,this._pendingChangeSource=!1,this._autoplay=!1,this._endCallback=null,this._playCallback=null,e&&this.game.cache.checkVideoKey(e)){var s=this.game.cache.getVideo(e);s.isBlob?this.createVideoFromBlob(s.data):this.video=s.data,this.width=this.video.videoWidth,this.height=this.video.videoHeight}else i&&this.createVideoFromURL(i,!1);this.video&&!i?this.baseTexture=new PIXI.BaseTexture(this.video,null,this.game.resolution):this.baseTexture=new PIXI.BaseTexture(X.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 X.Frame(0,0,0,this.width,this.height,"video"),this.texture.setFrame(this.textureFrame),this.texture.valid=!1,null!==e&&this.video&&(this.texture.valid=this.video.canplay),this.snapshot=null,X.BitmapData&&(this.snapshot=new X.BitmapData(this.game,"",this.width,this.height)),this.game.device.needsTouchUnlock()?this.setTouchLock():s&&(s.locked=!1)},X.Video.prototype={connectToMediaStream:function(t,e){return t&&e&&(this.video=t,this.videoStream=e,this.isStreaming=!0,this.baseTexture.source=this.video,this.updateTexture(null,this.video.videoWidth,this.video.videoHeight),this.onAccess.dispatch(this)),this},startMediaStream:function(t,e,i,s){if(void 0===t&&(t=!1),void 0===e&&(e=null),void 0===i&&(i=null),void 0===s&&(s=!0),!this.game.device.getUserMedia)return this.onError.dispatch(this,"No getUserMedia"),!1;if(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"),this.video.setAttribute("playsinline","playsinline"),null!==e&&(this.video.width=e),null!==i&&(this.video.height=i),this._timeOutID=window.setTimeout(this.getUserMediaTimeout.bind(this),this.timeout),navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)navigator.mediaDevices.getUserMedia({audio:t,video:s}).then(this.getUserMediaSuccess.bind(this)).catch(this.getUserMediaError.bind(this));else try{navigator.getUserMedia({audio:t,video:s},this.getUserMediaSuccess.bind(this),this.getUserMediaError.bind(this))}catch(t){this.getUserMediaError(t)}return this},getUserMediaTimeout:function(){clearTimeout(this._timeOutID),this.onTimeout.dispatch(this)},getUserMediaError:function(t){clearTimeout(this._timeOutID),this.onError.dispatch(this,t)},getUserMediaSuccess:function(t){clearTimeout(this._timeOutID),this.videoStream=t,void 0!==this.video.mozSrcObject?this.video.mozSrcObject=t:void 0!==this.video.srcObject?this.video.srcObject=t:this.video.src=window.URL&&window.URL.createObjectURL(t)||t;var n=this;this.video.onloadeddata=function(){var s=10;!function t(){if(0