diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6c6b690fa..feb01f00f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,17 @@
See [README: Change Log: Unreleased](README.md#unreleased).
+## Version 2.8.7 - 12th September 2017
+
+### Bug Fixes
+
+* Fixed TypeScript error (#351).
+* [onChildInputDown](https://photonstorm.github.io/phaser-ce/Phaser.Particles.Arcade.Emitter.html#onChildInputDown), [onChildInputUp](https://photonstorm.github.io/phaser-ce/Phaser.Particles.Arcade.Emitter.html#onChildInputUp), [onChildInputOver](https://photonstorm.github.io/phaser-ce/Phaser.Particles.Arcade.Emitter.html#onChildInputOver), and [onChildInputOut](https://photonstorm.github.io/phaser-ce/Phaser.Particles.Arcade.Emitter.html#onChildInputOut) signals now fire correctly for particle emitters (#349).
+
+### Thanks
+
+@lucasgray, @photonstorm, @samme, @yupaul
+
## Version 2.8.6 - 10th September 2017
### Updates
diff --git a/README.md b/README.md
index 8751871ed..41e22e436 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ Thousands of developers worldwide use Phaser. From indies and multi-national dig
Phaser v2 was built and maintained by [Photon Storm](http://www.photonstorm.com) and turned over to the community (as Phaser CE) in November 2016. [Phaser v3](https://github.com/photonstorm/phaser/tree/master/v3) is in active development.
-The [current Phaser CE release is 2.8.6](https://github.com/photonstorm/phaser-ce/releases/tag/v2.8.6).
+The [current Phaser CE release is 2.8.7](https://github.com/photonstorm/phaser-ce/releases/tag/v2.8.7).
- **Visit:** The [Phaser website](http://phaser.io) and follow on [Twitter](https://twitter.com/photonstorm) (#[phaserjs](https://twitter.com/hashtag/phaserjs))
- **Learn:** [API Docs](https://photonstorm.github.io/phaser-ce/), [Support Forum][forum] and [StackOverflow](http://stackoverflow.com/questions/tagged/phaser-framework)
@@ -128,16 +128,16 @@ Please see additional steps for [Browserify/CommonJS](#browserify) and [Webpack]
[Phaser CE is on jsDelivr](http://www.jsdelivr.com/projects/phaser-ce), a "super-fast CDN for developers". Include the following in your html:
```html
-
+
```
or the minified version:
```html
-
+
```
-[Custom builds](https://cdn.jsdelivr.net/npm/phaser-ce@2.8.6/build/custom/) are available too.
+[Custom builds](https://cdn.jsdelivr.net/npm/phaser-ce@2.8.7/build/custom/) are available too.
@@ -328,41 +328,16 @@ Written something cool in Phaser? Please tell us about it in the [forum][forum],
# Change Log
-## Unreleased
+## Version 2.8.7 - 12th September 2017
### Bug Fixes
-* `onChildInput*` signals now fire correctly for particle emitters (#349).
* Fixed TypeScript error (#351).
+* [onChildInputDown](https://photonstorm.github.io/phaser-ce/Phaser.Particles.Arcade.Emitter.html#onChildInputDown), [onChildInputUp](https://photonstorm.github.io/phaser-ce/Phaser.Particles.Arcade.Emitter.html#onChildInputUp), [onChildInputOver](https://photonstorm.github.io/phaser-ce/Phaser.Particles.Arcade.Emitter.html#onChildInputOver), and [onChildInputOut](https://photonstorm.github.io/phaser-ce/Phaser.Particles.Arcade.Emitter.html#onChildInputOut) signals now fire correctly for particle emitters (#349).
### Thanks
-@lucasgray, @samme, @yupaul
-
-## Version 2.8.6 - 10th September 2017
-
-### Updates
-
-* Several internal changes in [Phaser.DeviceButton](https://photonstorm.github.io/phaser-ce/Phaser.DeviceButton.html) and [Phaser.Pointer](https://photonstorm.github.io/phaser-ce/Phaser.Pointer.html) (#340).
-
-### Bug Fixes
-
-* Fixed an issue where the [DEFAULT](https://photonstorm.github.io/phaser-ce/Phaser.Cache.html#_DEFAULT) and [MISSING](https://photonstorm.github.io/phaser-ce/Phaser.Cache.html#_MISSING) textures could be missing from the game cache when the game starts (#280 via #138).
-* Fixed several issues related to [Phaser.MSPointer](https://photonstorm.github.io/phaser-ce/Phaser.MSPointer) and pointer events (#293, #250)
-* Fixed an error when using [TweenData#generateData](https://photonstorm.github.io/phaser-ce/Phaser.TweenData.html#generateData) with an array-based tween (#346).
-* Fixed game in an iframe not auto-resuming when refocused (#236).
-* Fixed some TypeScript definitions (#342, #344).
-
-### Documentation
-
-* Fixed navigation menu obscuring anchor link targets at the top of the window (#343).
-* Updated [Phaser.MSPointer](https://photonstorm.github.io/phaser-ce/Phaser.MSPointer.html)
-* Added example for [Tween#tween.onUpdateCallback](https://photonstorm.github.io/phaser-ce/Phaser.Tween.html#onUpdateCallback).
-* Updated [TweenData#value](https://photonstorm.github.io/phaser-ce/Phaser.TweenData.html#value).
-
-### Thanks
-
-@2called-chaos, @bseiller, @falquaddoomi, @johnbuttcoingalt, @photonstorm, @samme, @samvieten, @yupaul
+@lucasgray, @photonstorm, @samme, @yupaul
For changes in previous releases please see the extensive [Change Log](https://github.com/photonstorm/phaser-ce/blob/master/CHANGELOG.md).
@@ -386,10 +361,10 @@ All rights reserved.
[![Analytics](https://ga-beacon.appspot.com/UA-44006568-2/phaser/index)](https://github.com/igrigorik/ga-beacon)
-[get-js]: https://github.com/photonstorm/phaser-ce/releases/download/v2.8.6/phaser.js
-[get-minjs]: https://github.com/photonstorm/phaser-ce/releases/download/v2.8.6/phaser.min.js
-[get-zip]: https://github.com/photonstorm/phaser-ce/archive/v2.8.6.zip
-[get-tgz]: https://github.com/photonstorm/phaser-ce/archive/v2.8.6.tar.gz
+[get-js]: https://github.com/photonstorm/phaser-ce/releases/download/v2.8.7/phaser.js
+[get-minjs]: https://github.com/photonstorm/phaser-ce/releases/download/v2.8.7/phaser.min.js
+[get-zip]: https://github.com/photonstorm/phaser-ce/archive/v2.8.7.zip
+[get-tgz]: https://github.com/photonstorm/phaser-ce/archive/v2.8.7.tar.gz
[clone-http]: https://github.com/photonstorm/phaser.git
[clone-ssh]: ssh://git@github.com:photonstorm/phaser.git
[clone-svn]: https://github.com/photonstorm/phaser
diff --git a/build/custom/creature.min.js b/build/custom/creature.min.js
index 3cf73f475..6c5f9bf22 100644
--- a/build/custom/creature.min.js
+++ b/build/custom/creature.min.js
@@ -1,4 +1,4 @@
-/* Phaser v2.8.6 Creature Build - http://phaser.io - @photonstorm - (c) 2016 Photon Storm Ltd. */
+/* Phaser v2.8.7 Creature Build - http://phaser.io - @photonstorm - (c) 2016 Photon Storm Ltd. */
function dualQuat(){this.real=quat.create(),this.real[Q_W]=0,this.imaginary=quat.create(),this.imaginary[Q_W]=0,this.tmpQ1=quat.create()}function MeshBone(t,e,r,n){this.key=t,this.world_rest_angle=0,this.rest_parent_mat=mat4.create(),this.rest_parent_inv_mat=mat4.create(),this.rest_world_mat=mat4.create(),this.rest_world_inv_mat=mat4.create(),this.bind_world_mat=mat4.create(),this.bind_world_inv_mat=mat4.create(),this.parent_world_mat=mat4.create(),this.parent_world_inv_mat=mat4.create(),this.local_rest_start_pt=null,this.local_rest_end_pt=null,this.setRestParentMat(n,null),this.setLocalRestStartPt(e),this.setLocalRestEndPt(r),this.setParentWorldInvMat(mat4.create()),this.setParentWorldMat(mat4.create()),this.local_binormal_dir=vec3.fromValues(0,0,1),this.tag_id=0,this.children=[]}function MeshRenderRegion(t,e,r,n,a,i,s){this.store_indices=t,this.store_rest_pts=e,this.store_uvs=r,this.use_local_displacements=!1,this.use_post_displacements=!1,this.use_uv_warp=!1,this.uv_warp_local_offset=vec2.fromValues(0,0),this.uv_warp_global_offset=vec2.fromValues(0,0),this.uv_warp_scale=vec2.fromValues(1,1),this.start_pt_index=n,this.end_pt_index=a,this.start_index=i,this.end_index=s,this.main_bone=null,this.local_displacements=[],this.post_displacements=[],this.uv_warp_ref_uvs=[],this.normal_weight_map={},this.fast_normal_weight_map=[],this.fast_bones_map=[],this.relevant_bones_indices=[],this.use_dq=!0,this.tag_id=-1,this.initUvWarp()}function MeshRenderBoneComposition(){this.root_bone=null,this.bones_map={},this.regions=[],this.regions_map={}}function MeshBoneCache(t){this.key=t}function MeshDisplacementCache(t){this.key=t,this.local_displacements=[],this.post_displacements=[]}function MeshUVWarpCache(t){this.uv_warp_global_offset=vec2.create(),this.uv_warp_local_offset=vec2.create(),this.uv_warp_scale=vec2.fromValues(-1,-1),this.key=t,this.enabled=!1}function MeshBoneCacheManager(){this.is_ready=!1,this.bone_cache_table=null,this.bone_cache_data_ready=null,this.bone_cache_table=[],this.bone_cache_data_ready=[]}function MeshDisplacementCacheManager(){this.is_ready=!1,this.displacement_cache_table=null,this.displacement_cache_data_ready=null,this.displacement_cache_table=[],this.displacement_cache_data_ready=[]}function MeshUVWarpCacheManager(){this.is_ready=!1,this.uv_cache_table=null,this.uv_cache_data_ready=null,this.uv_cache_table=[],this.uv_cache_data_ready=[]}function Creature(t,e){this.total_num_pts=0,this.total_num_indices=0,this.global_indices=null,this.global_pts=null,this.global_uvs=null,this.render_pts=null,this.render_colours=null,this.render_composition=null,this.boundary_indices=[],this.boundary_min=vec2.create(),this.boundary_max=vec2.create(),this.anchor_point_map={},this.anchor_points_active=!1,this.LoadFromData(t,e)}function CreatureAnimation(t,e){this.name=e,this.bones_cache=new MeshBoneCacheManager,this.displacement_cache=new MeshDisplacementCacheManager,this.uv_warp_cache=new MeshUVWarpCacheManager,this.cache_pts=[],this.fill_cache_pts=[],this.LoadFromData(e,t)}function CreatureManager(t){this.target_creature=t,this.is_playing=!1,this.run_time=0,this.time_scale=30,this.blending_factor=0,this.should_loop=!0,this.use_custom_time_range=!1,this.custom_start_time=0,this.custom_end_time=0,this.animations={},this.bones_override_callback=null,this.blend_render_pts=[],this.blend_render_pts.push([]),this.blend_render_pts.push([]),this.do_blending=!1,this.active_blend_animation_names=[],this.active_blend_animation_names.push(""),this.active_blend_animation_names.push("")}!function(t){"use strict";var e={};"undefined"==typeof exports?"function"==typeof define&&"object"==typeof define.amd&&define.amd?(e.exports={},define(function(){return e.exports})):e.exports="undefined"!=typeof window?window:t:e.exports=exports,function(t){if(!e)var e=1e-6;if(!r)var r="undefined"!=typeof Float32Array?Float32Array:Array;if(!n)var n=Math.random;var a={};a.setMatrixArrayType=function(t){r=t},void 0!==t&&(t.glMatrix=a);var i=Math.PI/180;a.toRadian=function(t){return t*i};var s={};s.create=function(){var t=new r(2);return t[0]=0,t[1]=0,t},s.clone=function(t){var e=new r(2);return e[0]=t[0],e[1]=t[1],e},s.fromValues=function(t,e){var n=new r(2);return n[0]=t,n[1]=e,n},s.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},s.set=function(t,e,r){return t[0]=e,t[1]=r,t},s.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},s.subtract=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t},s.sub=s.subtract,s.multiply=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t},s.mul=s.multiply,s.divide=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t},s.div=s.divide,s.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t},s.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t},s.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},s.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t},s.distance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1];return Math.sqrt(r*r+n*n)},s.dist=s.distance,s.squaredDistance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1];return r*r+n*n},s.sqrDist=s.squaredDistance,s.length=function(t){var e=t[0],r=t[1];return Math.sqrt(e*e+r*r)},s.len=s.length,s.squaredLength=function(t){var e=t[0],r=t[1];return e*e+r*r},s.sqrLen=s.squaredLength,s.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},s.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},s.normalize=function(t,e){var r=e[0],n=e[1],a=r*r+n*n;return a>0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a),t},s.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},s.cross=function(t,e,r){var n=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=n,t},s.lerp=function(t,e,r,n){var a=e[0],i=e[1];return t[0]=a+n*(r[0]-a),t[1]=i+n*(r[1]-i),t},s.random=function(t,e){e=e||1;var r=2*n()*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t},s.transformMat2=function(t,e,r){var n=e[0],a=e[1];return t[0]=r[0]*n+r[2]*a,t[1]=r[1]*n+r[3]*a,t},s.transformMat2d=function(t,e,r){var n=e[0],a=e[1];return t[0]=r[0]*n+r[2]*a+r[4],t[1]=r[1]*n+r[3]*a+r[5],t},s.transformMat3=function(t,e,r){var n=e[0],a=e[1];return t[0]=r[0]*n+r[3]*a+r[6],t[1]=r[1]*n+r[4]*a+r[7],t},s.transformMat4=function(t,e,r){var n=e[0],a=e[1];return t[0]=r[0]*n+r[4]*a+r[12],t[1]=r[1]*n+r[5]*a+r[13],t},s.forEach=function(){var t=s.create();return function(e,r,n,a,i,s){var o,c;for(r||(r=2),n||(n=0),c=a?Math.min(a*r+n,e.length):e.length,o=n;o0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i),t},o.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},o.cross=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=r[0],o=r[1],c=r[2];return t[0]=a*c-i*o,t[1]=i*s-n*c,t[2]=n*o-a*s,t},o.lerp=function(t,e,r,n){var a=e[0],i=e[1],s=e[2];return t[0]=a+n*(r[0]-a),t[1]=i+n*(r[1]-i),t[2]=s+n*(r[2]-s),t},o.random=function(t,e){e=e||1;var r=2*n()*Math.PI,a=2*n()-1,i=Math.sqrt(1-a*a)*e;return t[0]=Math.cos(r)*i,t[1]=Math.sin(r)*i,t[2]=a*e,t},o.transformMat4=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=r[3]*n+r[7]*a+r[11]*i+r[15];return s=s||1,t[0]=(r[0]*n+r[4]*a+r[8]*i+r[12])/s,t[1]=(r[1]*n+r[5]*a+r[9]*i+r[13])/s,t[2]=(r[2]*n+r[6]*a+r[10]*i+r[14])/s,t},o.transformMat3=function(t,e,r){var n=e[0],a=e[1],i=e[2];return t[0]=n*r[0]+a*r[3]+i*r[6],t[1]=n*r[1]+a*r[4]+i*r[7],t[2]=n*r[2]+a*r[5]+i*r[8],t},o.transformQuat=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=r[0],o=r[1],c=r[2],h=r[3],u=h*n+o*i-c*a,l=h*a+c*n-s*i,_=h*i+s*a-o*n,p=-s*n-o*a-c*i;return t[0]=u*h+p*-s+l*-c-_*-o,t[1]=l*h+p*-o+_*-s-u*-c,t[2]=_*h+p*-c+u*-o-l*-s,t},o.rotateX=function(t,e,r,n){var a=[],i=[];return a[0]=e[0]-r[0],a[1]=e[1]-r[1],a[2]=e[2]-r[2],i[0]=a[0],i[1]=a[1]*Math.cos(n)-a[2]*Math.sin(n),i[2]=a[1]*Math.sin(n)+a[2]*Math.cos(n),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t},o.rotateY=function(t,e,r,n){var a=[],i=[];return a[0]=e[0]-r[0],a[1]=e[1]-r[1],a[2]=e[2]-r[2],i[0]=a[2]*Math.sin(n)+a[0]*Math.cos(n),i[1]=a[1],i[2]=a[2]*Math.cos(n)-a[0]*Math.sin(n),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t},o.rotateZ=function(t,e,r,n){var a=[],i=[];return a[0]=e[0]-r[0],a[1]=e[1]-r[1],a[2]=e[2]-r[2],i[0]=a[0]*Math.cos(n)-a[1]*Math.sin(n),i[1]=a[0]*Math.sin(n)+a[1]*Math.cos(n),i[2]=a[2],t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t},o.forEach=function(){var t=o.create();return function(e,r,n,a,i,s){var o,c;for(r||(r=3),n||(n=0),c=a?Math.min(a*r+n,e.length):e.length,o=n;o0&&(s=1/Math.sqrt(s),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t[3]=e[3]*s),t},c.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},c.lerp=function(t,e,r,n){var a=e[0],i=e[1],s=e[2],o=e[3];return t[0]=a+n*(r[0]-a),t[1]=i+n*(r[1]-i),t[2]=s+n*(r[2]-s),t[3]=o+n*(r[3]-o),t},c.random=function(t,e){return e=e||1,t[0]=n(),t[1]=n(),t[2]=n(),t[3]=n(),c.normalize(t,t),c.scale(t,t,e),t},c.transformMat4=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=e[3];return t[0]=r[0]*n+r[4]*a+r[8]*i+r[12]*s,t[1]=r[1]*n+r[5]*a+r[9]*i+r[13]*s,t[2]=r[2]*n+r[6]*a+r[10]*i+r[14]*s,t[3]=r[3]*n+r[7]*a+r[11]*i+r[15]*s,t},c.transformQuat=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=r[0],o=r[1],c=r[2],h=r[3],u=h*n+o*i-c*a,l=h*a+c*n-s*i,_=h*i+s*a-o*n,p=-s*n-o*a-c*i;return t[0]=u*h+p*-s+l*-c-_*-o,t[1]=l*h+p*-o+_*-s-u*-c,t[2]=_*h+p*-c+u*-o-l*-s,t},c.forEach=function(){var t=c.create();return function(e,r,n,a,i,s){var o,c;for(r||(r=4),n||(n=0),c=a?Math.min(a*r+n,e.length):e.length,o=n;o.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(o.cross(t,a,i),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+s,p.normalize(n,n))}}(),p.setAxes=function(){var t=l.create();return function(e,r,n,a){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=a[0],t[4]=a[1],t[7]=a[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],p.normalize(e,p.fromMat3(e,t))}}(),p.clone=c.clone,p.fromValues=c.fromValues,p.copy=c.copy,p.set=c.set,p.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},p.setAxisAngle=function(t,e,r){r*=.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t},p.add=c.add,p.multiply=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=e[3],o=r[0],c=r[1],h=r[2],u=r[3];return t[0]=n*u+s*o+a*h-i*c,t[1]=a*u+s*c+i*o-n*h,t[2]=i*u+s*h+n*c-a*o,t[3]=s*u-n*o-a*c-i*h,t},p.mul=p.multiply,p.scale=c.scale,p.rotateX=function(t,e,r){r*=.5;var n=e[0],a=e[1],i=e[2],s=e[3],o=Math.sin(r),c=Math.cos(r);return t[0]=n*c+s*o,t[1]=a*c+i*o,t[2]=i*c-a*o,t[3]=s*c-n*o,t},p.rotateY=function(t,e,r){r*=.5;var n=e[0],a=e[1],i=e[2],s=e[3],o=Math.sin(r),c=Math.cos(r);return t[0]=n*c-i*o,t[1]=a*c+s*o,t[2]=i*c+n*o,t[3]=s*c-a*o,t},p.rotateZ=function(t,e,r){r*=.5;var n=e[0],a=e[1],i=e[2],s=e[3],o=Math.sin(r),c=Math.cos(r);return t[0]=n*c+a*o,t[1]=a*c-n*o,t[2]=i*c+s*o,t[3]=s*c-i*o,t},p.calculateW=function(t,e){var r=e[0],n=e[1],a=e[2];return t[0]=r,t[1]=n,t[2]=a,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-a*a)),t},p.dot=c.dot,p.lerp=c.lerp,p.slerp=function(t,e,r,n){var a,i,s,o,c,h=e[0],u=e[1],l=e[2],_=e[3],p=r[0],d=r[1],m=r[2],f=r[3];return(i=h*p+u*d+l*m+_*f)<0&&(i=-i,p=-p,d=-d,m=-m,f=-f),1-i>1e-6?(a=Math.acos(i),s=Math.sin(a),o=Math.sin((1-n)*a)/s,c=Math.sin(n*a)/s):(o=1-n,c=n),t[0]=o*h+c*p,t[1]=o*u+c*d,t[2]=o*l+c*m,t[3]=o*_+c*f,t},p.invert=function(t,e){var r=e[0],n=e[1],a=e[2],i=e[3],s=r*r+n*n+a*a+i*i,o=s?1/s:0;return t[0]=-r*o,t[1]=-n*o,t[2]=-a*o,t[3]=i*o,t},p.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},p.length=c.length,p.len=p.length,p.squaredLength=c.squaredLength,p.sqrLen=p.squaredLength,p.normalize=c.normalize,p.fromMat3=function(t,e){var r,n=e[0]+e[4]+e[8];if(n>0)r=Math.sqrt(n+1),t[3]=.5*r,r=.5/r,t[0]=(e[5]-e[7])*r,t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else{var a=0;e[4]>e[0]&&(a=1),e[8]>e[3*a+a]&&(a=2);var i=(a+1)%3,s=(a+2)%3;r=Math.sqrt(e[3*a+a]-e[3*i+i]-e[3*s+s]+1),t[a]=.5*r,r=.5/r,t[3]=(e[3*i+s]-e[3*s+i])*r,t[i]=(e[3*i+a]+e[3*a+i])*r,t[s]=(e[3*s+a]+e[3*a+s])*r}return t},p.str=function(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},void 0!==t&&(t.quat=p)}(e.exports)}(this);var Q_X=0,Q_Y=1,Q_Z=2,Q_W=3;dualQuat.prototype.reset=function(){quat.identity(this.real),this.real[Q_W]=0,quat.identity(this.imaginary),this.imaginary[Q_W]=0,quat.identity(this.tmpQ1)},dualQuat.prototype.createFromData=function(t,e){this.real=t,this.imaginary=quat.create(),this.imaginary[Q_W]=-.5*(e[Q_X]*t[Q_X]+e[Q_Y]*t[Q_Y]+e[Q_Z]*t[Q_Z]),this.imaginary[Q_X]=.5*(e[Q_X]*t[Q_W]+e[Q_Y]*t[Q_Z]-e[Q_Z]*t[Q_Y]),this.imaginary[Q_Y]=.5*(-e[Q_X]*t[Q_Z]+e[Q_Y]*t[Q_W]+e[Q_Z]*t[Q_X]),this.imaginary[Q_Z]=.5*(e[Q_X]*t[Q_Y]-e[Q_Y]*t[Q_X]+e[Q_Z]*t[Q_W])},dualQuat.prototype.add=function(t,e,r){quat.copy(this.tmpQ1,t.real),quat.scale(this.tmpQ1,this.tmpQ1,e),quat.add(this.real,this.tmpQ1,this.real),quat.copy(this.tmpQ1,t.imaginary),quat.scale(this.tmpQ1,this.tmpQ1,r),quat.add(this.imaginary,this.tmpQ1,this.imaginary)},dualQuat.prototype.normalize=function(){var t=quat.length(this.real);this.real=quat.scale(this.real,this.real,1/t),this.imaginary=quat.scale(this.imaginary,this.imaginary,1/t)};var v0=vec3.create(),ve=vec3.create(),trans=vec3.create(),tmpVec1=vec3.create(),tmpVec2=vec3.create(),tmpVec0=vec3.create(),aVec=vec3.create(),rot=vec3.create();dualQuat.prototype.transform=function(t){return v0[Q_X]=this.real[Q_X],v0[Q_Y]=this.real[Q_Y],v0[Q_Z]=this.real[Q_Z],ve[Q_X]=this.imaginary[Q_X],ve[Q_Y]=this.imaginary[Q_Y],ve[Q_Z]=this.imaginary[Q_Z],tmpVec1=vec3.scale(tmpVec1,v0,this.imaginary[Q_W]),tmpVec2=vec3.cross(tmpVec2,v0,ve),tmpVec0=vec3.scale(tmpVec0,ve,this.real[Q_W]),aVec=vec3.subtract(aVec,tmpVec0,tmpVec1),trans=vec3.add(trans,aVec,tmpVec2),trans=vec3.scale(trans,trans,2),rot=vec3.transformQuat(rot,t,this.real),rot=vec3.add(rot,rot,trans)};var Utils={};Utils.setAxisMatrix=function(t,e,r){var n=mat4.create();return n[0]=t[Q_X],n[4]=t[Q_Y],n[8]=t[Q_Z],n[1]=e[Q_X],n[5]=e[Q_Y],n[9]=e[Q_Z],n[2]=r[Q_X],n[6]=r[Q_Y],n[10]=r[Q_Z],n[12]=0,n[13]=0,n[14]=0,n[3]=0,n[7]=0,n[11]=0,n[15]=1,n=mat4.transpose(n,n)},Utils.matrixToQuat=function(t){var e,r=quat.create(),n=t,a=n[0],i=n[4],s=n[8],o=n[1],c=n[5],h=n[9],u=n[2],l=n[6],_=n[10],p=a+c+_;return p>0?(e=.5/Math.sqrt(p+1),r[Q_W]=.25/e,r[Q_X]=(l-h)*e,r[Q_Y]=(s-u)*e,r[Q_Z]=(o-i)*e):a>c&&a>_?(e=2*Math.sqrt(1+a-c-_),r[Q_W]=(l-h)/e,r[Q_X]=.25*e,r[Q_Y]=(i+o)/e,r[Q_Z]=(s+u)/e):c>_?(e=2*Math.sqrt(1+c-a-_),r[Q_W]=(s-u)/e,r[Q_X]=(i+o)/e,r[Q_Y]=.25*e,r[Q_Z]=(h+l)/e):(e=2*Math.sqrt(1+_-a-c),r[Q_W]=(o-i)/e,r[Q_X]=(s+u)/e,r[Q_Y]=(h+l)/e,r[Q_Z]=.25*e),r},Utils.rotateVec_90=function(t){return vec3.fromValues(-t[Q_Y],t[Q_X],t[Q_Z])},Utils.calcRotateMat=function(t){var e=vec3.clone(t);e=vec3.normalize(e,e);var r=Utils.rotateVec_90(e),n=vec3.fromValues(e[Q_X],e[Q_Y],0),a=vec3.fromValues(r[Q_X],r[Q_Y],0),i=vec3.fromValues(0,0,1);mat4.create();return Utils.setAxisMatrix(n,a,i)},Utils.getMatTranslate=function(t){var e=vec3.create();return e[Q_X]=t[12],e[Q_Y]=t[13],e[Q_Z]=t[14],e},Utils.addMat=function(t,e){for(var r=mat4.create(),n=0;n<16;n++)r[n]=t[n]+e[n];return r},Utils.mulMat=function(t,e){for(var r=mat4.create(),n=0;n<16;n++)r[n]=t[n]*e;return r},Utils.clamp=function(t,e,r){return tr?r:t};var newVec1=vec3.create(),newVec2=vec3.create();Utils.vecInterp=function(t,e,r){newVec1=vec3.scale(newVec1,t,1-r),newVec2=vec3.scale(newVec2,e,r);var n=vec3.create();return n=vec3.add(n,newVec1,newVec2)},Utils.vec2Interp=function(t,e,r){var n=vec2.create(),a=vec2.create();n=vec2.scale(n,t,1-r),a=vec2.scale(a,e,r);var i=vec2.create();return i=vec2.add(i,n,a)},MeshBone.prototype.setRestParentMat=function(t,e){this.rest_parent_mat=t,null==e?(this.rest_parent_inv_mat=mat4.clone(this.rest_parent_mat),mat4.invert(this.rest_parent_inv_mat,this.rest_parent_inv_mat)):this.rest_parent_inv_mat=mat4.clone(e)},MeshBone.prototype.setParentWorldMat=function(t){this.parent_world_mat=t},MeshBone.prototype.setParentWorldInvMat=function(t){this.parent_world_inv_mat=t},MeshBone.prototype.getLocalRestStartPt=function(){return this.local_rest_start_pt},MeshBone.prototype.getLocalRestEndPt=function(){return this.local_rest_end_pt},MeshBone.prototype.setLocalRestStartPt=function(t){this.local_rest_start_pt=vec3.create(),this.local_rest_start_pt=vec3.transformMat4(this.local_rest_start_pt,t,this.rest_parent_inv_mat),this.calcRestData()},MeshBone.prototype.setLocalRestEndPt=function(t){this.local_rest_end_pt=vec3.create(),this.local_rest_end_pt=vec3.transformMat4(this.local_rest_end_pt,t,this.rest_parent_inv_mat),this.calcRestData()},MeshBone.prototype.calcRestData=function(){if(null!=this.local_rest_start_pt&&null!=this.local_rest_end_pt){var t=this.computeDirs(this.local_rest_start_pt,this.local_rest_end_pt);this.local_rest_dir=t.first,this.local_rest_normal_dir=t.second,this.computeRestLength()}},MeshBone.prototype.setWorldStartPt=function(t){this.world_start_pt=t},MeshBone.prototype.setWorldEndPt=function(t){this.world_end_pt=t},MeshBone.prototype.fixDQs=function(t){quat.dot(this.world_dq.real,t.real)<0&&(this.world_dq.real=quat.scale(this.world_dq.real,this.world_dq.real,-1),this.world_dq.imaginary=quat.scale(this.world_dq.imaginary,this.world_dq.imaginary,-1));for(var e=0;e.05&&a.push(i);this.relevant_bones_indices.push(a)}for(var e in t){var s=t[e];this.fast_bones_map.push(s)}},MeshRenderRegion.prototype.initUvWarp=function(){var t=this.getUVsIndex();this.uv_warp_ref_uvs=[];for(var e=0;en&&(n=o),o=0&&null!==t?i=this.boundary_max[0]-n*t:t<0?i=-Math.abs(this.boundary_max[0]-n*Math.abs(t)):null===t&&(i=this.anchor_point_map&&this.anchor_point_map[r]?this.anchor_point_map[r][0]:0),e>=0&&null!==e?s=this.boundary_max[1]-a*e:e<0?s=-Math.abs(this.boundary_max[1]-a*Math.abs(e)):null===e&&(s=this.anchor_point_map&&this.anchor_point_map[r]?this.anchor_point_map[r][1]:0);var o={AnchorPoints:[{point:[i,s],anim_clip_name:r}]};this.anchor_point_map=this.FillAnchorPointMap(o)},Creature.prototype.GetAnchorPoint=function(t){return t in this.anchor_point_map?this.anchor_point_map[t]:vec2.fromValues(0,0)},Creature.prototype.FillRenderColours=function(t,e,r,n){for(var a=0;a=o&&n<=c){a=!0;break}}a&&t[n]++}this.boundary_indices=[];for(e=0;ei&&(e[0]=i),e[1]>s&&(e[1]=s),r[0]0)){for(var n=r.cache_pts,a=r.start_time;a<=r.end_time;a++){this.setRunTime(a);for(var i=[],s=0;s<3*this.target_creature.total_num_pts;s++)i[s]=0;this.PoseCreature(t,i),n.push(i)}this.setRunTime(e)}},CreatureManager.prototype.FillSinglePointCacheFrame=function(t,e){var r=this.getRunTime(),n=this.animations[t];this.setRunTime(e);for(var a=[],i=0;i<3*this.target_creature.total_num_pts;i++)a[i]=0;this.PoseCreature(t,a),n.fill_cache_pts.push(a),n.verifyFillCache(),this.setRunTime(r)},CreatureManager.prototype.GetIsPlaying=function(){return this.is_playing},CreatureManager.prototype.SetShouldLoop=function(t){this.should_loop=t},CreatureManager.prototype.SetUseCustomTimeRange=function(t){this.use_custom_time_range=t},CreatureManager.prototype.SetCustomTimeRange=function(t,e){this.custom_start_time=t,this.custom_end_time=e},CreatureManager.prototype.SetIsPlaying=function(t){this.is_playing=t},CreatureManager.prototype.ResetToStartTimes=function(){var t=this.animations[active_animation_name];this.run_time=t.start_time},CreatureManager.prototype.setRunTime=function(t){this.run_time=t,this.correctTime()},CreatureManager.prototype.increRunTime=function(t){this.run_time+=t,this.correctTime()},CreatureManager.prototype.correctTime=function(){var t=this.animations[this.active_animation_name],e=t.start_time,r=t.end_time;this.use_custom_time_range&&(e=this.custom_start_time,r=this.custom_end_time),this.run_time>r?this.should_loop?this.run_time=e:this.run_time=r:this.run_time0?i.poseFromCachePts(this.getRunTime(),this.blend_render_pts[t],this.target_creature.total_num_pts):this.PoseCreature(this.active_blend_animation_names[t],this.blend_render_pts[t]);for(var e=0;e<3*this.target_creature.total_num_pts;e++){var r=e,n=this.blend_render_pts[0][e],a=this.blend_render_pts[1][e];this.target_creature.render_pts.set(r,(1-blending_factor)*n+blending_factor*a)}}else{var i=this.animations[this.active_animation_name];i.cache_pts.length>0?i.poseFromCachePts(this.getRunTime(),this.target_creature.render_pts,this.target_creature.total_num_pts):this.PoseCreature(this.active_animation_name,this.target_creature.render_pts)}},CreatureManager.prototype.SetTimeScale=function(t){this.time_scale=t},CreatureManager.prototype.SetBlending=function(t){if(this.do_blending=t,this.do_blending){if(0==this.blend_render_pts[0].length){for(var e=[],r=0;r<3*target_creature.total_num_pts;r++)e.push(0);this.blend_render_pts.set(0,e)}if(0==this.blend_render_pts[1].length){for(var e=[],r=0;r<3*this.target_creature.total_num_pts;r++)e.push(0);this.blend_render_pts[1]=e}}},CreatureManager.prototype.SetBlendingAnimations=function(t,e){this.active_blend_animation_names[0]=t,this.active_blend_animation_names[1]=e},CreatureManager.prototype.SetBlendingFactor=function(t){this.blending_factor=t},CreatureManager.prototype.IsContactBone=function(t,e){var r=this.target_creature.render_composition.getRootBone();return this.ProcessContactBone(t,e,r)},CreatureManager.prototype.PoseCreature=function(t,e){var r=this.animations[t],n=r.bones_cache,a=r.displacement_cache,i=r.uv_warp_cache,s=this.target_creature.render_composition,o=s.getBonesMap(),c=s.getRegionsMap();n.retrieveValuesAtTime(this.getRunTime(),o),this.AlterBonesByAnchor(o,t),null!=this.bones_override_callback&&this.bones_override_callback(o),a.retrieveValuesAtTime(this.getRunTime(),c),i.retrieveValuesAtTime(this.getRunTime(),c);var h=s.getRegions(),u=s.getBonesMap();s.updateAllTransforms(!1);for(var l=0,_=h.length;l<_;l++){var p=h[l],d=p.getStartPtIndex();p.poseFinalPts(e,3*d,u);for(var m=3*p.getStartPtIndex(),f=3*p.getEndPtIndex(),v=m;v<=f;v+=3)e[v+2]=.001*-l}};
//# sourceMappingURL=creature.map
\ No newline at end of file
diff --git a/build/custom/p2.min.js b/build/custom/p2.min.js
index 6cf9e4bb5..4644521af 100644
--- a/build/custom/p2.min.js
+++ b/build/custom/p2.min.js
@@ -1,4 +1,4 @@
-/* Phaser v2.8.6 P2.JS Build - http://phaser.io - @photonstorm - (c) 2016 Photon Storm Ltd. */
+/* Phaser v2.8.7 P2.JS Build - 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,o,i){function n(a,r){if(!o[a]){if(!e[a]){var c="function"==typeof require&&require;if(!r&&c)return c(a,!0);if(s)return s(a,!0);throw new Error("Cannot find module '"+a+"'")}var h=o[a]={exports:{}};e[a][0].call(h.exports,function(t){var o=e[a][1][t];return n(o||t)},h,h.exports,t,e,o,i)}return o[a].exports}for(var s="function"==typeof require&&require,a=0;a=0&&c<=1&&h>=0&&h<=1}},{"./Scalar":4}],2:[function(t,e,o){function i(){}e.exports=i,i.area=function(t,e,o){return(e[0]-t[0])*(o[1]-t[1])-(o[0]-t[0])*(e[1]-t[1])},i.left=function(t,e,o){return i.area(t,e,o)>0},i.leftOn=function(t,e,o){return i.area(t,e,o)>=0},i.right=function(t,e,o){return i.area(t,e,o)<0},i.rightOn=function(t,e,o){return i.area(t,e,o)<=0};var n=[],s=[];i.collinear=function(t,e,o,a){if(a){var r=n,c=s;r[0]=e[0]-t[0],r[1]=e[1]-t[1],c[0]=o[0]-e[0],c[1]=o[1]-e[1];var h=r[0]*c[0]+r[1]*c[1],l=Math.sqrt(r[0]*r[0]+r[1]*r[1]),p=Math.sqrt(c[0]*c[0]+c[1]*c[1]);return Math.acos(h/(l*p))t.vertices.length)throw new Error("lol2");if(e<0)throw new Error("lol3");for(var i=e;ie[t][0])&&(t=o);a.left(this.at(t-1),this.at(t),this.at(t+1))||this.reverse()},i.prototype.reverse=function(){for(var t=[],e=0,o=this.vertices.length;e!==o;e++)t.push(this.vertices.pop());this.vertices=t},i.prototype.isReflex=function(t){return a.right(this.at(t-1),this.at(t),this.at(t+1))};var c=[],h=[];i.prototype.canSee=function(t,e){var o,i,n=c,r=h;if(a.leftOn(this.at(t+1),this.at(t),this.at(e))&&a.rightOn(this.at(t-1),this.at(t),this.at(e)))return!1;i=a.sqdist(this.at(t),this.at(e));for(var l=0;l!==this.vertices.length;++l)if((l+1)%this.vertices.length!==t&&l!==t&&a.leftOn(this.at(t),this.at(e),this.at(l+1))&&a.rightOn(this.at(t),this.at(e),this.at(l))&&(n[0]=this.at(t),n[1]=this.at(e),r[0]=this.at(l),r[1]=this.at(l+1),o=s.lineInt(n,r),a.sqdist(this.at(t),o)0?this.slice(t):[this]},i.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],o=0;or)return console.warn("quickDecomp: max level ("+r+") reached."),t;for(var q=0;qy&&(y+=this.vertices.length),v=Number.MAX_VALUE,y3&&o>=0;--o)a.collinear(this.at(o-1),this.at(o),this.at(o+1),t)&&(this.vertices.splice(o%this.vertices.length,1),o--,e++);return e}},{"./Line":1,"./Point":2,"./Scalar":4}],4:[function(t,e,o){function i(){}e.exports=i,i.eq=function(t,e,o){return o=o||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,o){function i(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=i;var s=n.create();i.prototype.setFromPoints=function(t,e,o,i){var a=this.lowerBound,r=this.upperBound;"number"!=typeof o&&(o=0),0!==o?n.rotate(a,t[0],o):n.copy(a,t[0]),n.copy(r,a);for(var c=Math.cos(o),h=Math.sin(o),l=1;lr[f]&&(r[f]=p[f]),p[f]o&&(this.lowerBound[e]=o);var i=t.upperBound[e];this.upperBound[e]c?-1:r}},{"../math/vec2":30,"../utils/Utils":57}],8:[function(t,e,o){function i(t){this.type=t,this.result=[],this.world=null,this.boundingVolumeType=i.AABB}var n=t("../math/vec2"),s=t("../objects/Body");e.exports=i,i.AABB=1,i.BOUNDING_CIRCLE=2,i.prototype.setWorld=function(t){this.world=t},i.prototype.getCollisionPairs=function(t){};var a=n.create();i.boundingRadiusCheck=function(t,e){n.sub(a,t.position,e.position);var o=n.squaredLength(a),i=t.boundingRadius+e.boundingRadius;return o<=i*i},i.aabbCheck=function(t,e){return t.getAABB().overlaps(e.getAABB())},i.prototype.boundingVolumeCheck=function(t,e){var o;switch(this.boundingVolumeType){case i.BOUNDING_CIRCLE:o=i.boundingRadiusCheck(t,e);break;case i.AABB:o=i.aabbCheck(t,e);break;default:throw new Error("Bounding volume type not recognized: "+this.boundingVolumeType)}return o},i.canCollide=function(t,e){var o=s.KINEMATIC,i=s.STATIC;return(t.type!==i||e.type!==i)&&(!(t.type===o&&e.type===i||t.type===i&&e.type===o)&&((t.type!==o||e.type!==o)&&((t.sleepState!==s.SLEEPING||e.sleepState!==s.SLEEPING)&&!(t.sleepState===s.SLEEPING&&e.type===i||e.sleepState===s.SLEEPING&&t.type===i))))},i.NAIVE=1,i.SAP=2},{"../math/vec2":30,"../objects/Body":31}],9:[function(t,e,o){function i(){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=i,(i.prototype=new n).constructor=i,i.prototype.getCollisionPairs=function(t){var e=t.bodies,o=this.result;o.length=0;for(var i=0,s=e.length;i!==s;i++)for(var a=e[i],r=0;rK&&Y0)for(U=0;UMath.pow(v,2))return 0;if(p)return!0;var y=this.createContactEquation(t,n,e,s);return r(y.normalA,h,o),a.normalize(y.normalA,y.normalA),a.scale(y.contactPointA,y.normalA,u),a.scale(y.contactPointB,y.normalA,-d),c(y.contactPointA,y.contactPointA,o),r(y.contactPointA,y.contactPointA,t.position),c(y.contactPointB,y.contactPointB,h),r(y.contactPointB,y.contactPointB,n.position),this.contactEquations.push(y),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(y)),1},i.prototype[y.PLANE|y.CONVEX]=i.prototype[y.PLANE|y.BOX]=i.prototype.planeConvex=function(t,e,o,i,n,s,l,p,u){var d=A,f=b,v=E,y=0;a.rotate(f,g,i);for(var m=0;m!==s.vertices.length;m++){var B=s.vertices[m];if(a.rotate(d,B,p),c(d,d,l),r(v,d,o),h(v,f)<=0){if(u)return!0;y++;var q=this.createContactEquation(t,n,e,s);r(v,d,o),a.copy(q.normalA,f);var P=h(v,q.normalA);a.scale(v,q.normalA,P),r(q.contactPointB,d,n.position),r(q.contactPointA,d,v),r(q.contactPointA,q.contactPointA,t.position),this.contactEquations.push(q),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(q))}}return this.enableFrictionReduction&&this.enableFriction&&y&&this.frictionEquations.push(this.createFrictionFromAverage(y)),y},i.prototype[y.PARTICLE|y.PLANE]=i.prototype.particlePlane=function(t,e,o,i,n,s,c,l,p){var u=A,d=b;l=l||0,r(u,o,c),a.rotate(d,g,l);var f=h(u,d);if(f>0)return 0;if(p)return!0;var v=this.createContactEquation(n,t,s,e);return a.copy(v.normalA,d),a.scale(u,v.normalA,f),r(v.contactPointA,o,u),r(v.contactPointA,v.contactPointA,n.position),r(v.contactPointB,o,t.position),this.contactEquations.push(v),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(v)),1},i.prototype[y.CIRCLE|y.PARTICLE]=i.prototype.circleParticle=function(t,e,o,i,n,s,h,l,p){var u=A;if(r(u,h,o),a.squaredLength(u)>Math.pow(e.radius,2))return 0;if(p)return!0;var d=this.createContactEquation(t,n,e,s);return a.copy(d.normalA,u),a.normalize(d.normalA,d.normalA),a.scale(d.contactPointA,d.normalA,e.radius),c(d.contactPointA,d.contactPointA,o),r(d.contactPointA,d.contactPointA,t.position),r(d.contactPointB,h,n.position),this.contactEquations.push(d),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(d)),1};var H=new f({radius:1}),Z=a.create(),J=a.create();a.create();i.prototype[y.PLANE|y.CAPSULE]=i.prototype.planeCapsule=function(t,e,o,i,n,s,r,h,l){var p=Z,u=J,d=H;a.set(p,-s.length/2,0),a.rotate(p,p,h),c(p,p,r),a.set(u,s.length/2,0),a.rotate(u,u,h),c(u,u,r),d.radius=s.radius;var f;this.enableFrictionReduction&&(f=this.enableFriction,this.enableFriction=!1);var v=this.circlePlane(n,d,p,0,t,e,o,i,l),y=this.circlePlane(n,d,u,0,t,e,o,i,l);if(this.enableFrictionReduction&&(this.enableFriction=f),l)return v||y;var m=v+y;return this.enableFrictionReduction&&m&&this.frictionEquations.push(this.createFrictionFromAverage(m)),m},i.prototype[y.CIRCLE|y.PLANE]=i.prototype.circlePlane=function(t,e,o,i,n,s,l,p,u){var d=t,f=e,v=o,y=n,m=l,B=p;B=B||0;var q=A,P=b,w=E;r(q,v,m),a.rotate(P,g,B);var S=h(P,q);if(S>f.radius)return 0;if(u)return!0;var C=this.createContactEquation(y,d,s,e);return a.copy(C.normalA,P),a.scale(C.contactPointB,C.normalA,-f.radius),c(C.contactPointB,C.contactPointB,v),r(C.contactPointB,C.contactPointB,d.position),a.scale(w,C.normalA,S),r(C.contactPointA,q,w),c(C.contactPointA,C.contactPointA,m),r(C.contactPointA,C.contactPointA,y.position),this.contactEquations.push(C),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(C)),1},i.prototype[y.CONVEX]=i.prototype[y.CONVEX|y.BOX]=i.prototype[y.BOX]=i.prototype.convexConvex=function(t,e,o,n,s,l,p,u,d,f){var v=A,y=b,m=E,g=B,P=q,L=w,x=S,F=C,M=0,f="number"==typeof f?f:0;if(!i.findSeparatingAxis(e,o,n,l,p,u,v))return 0;r(x,p,o),h(v,x)>0&&a.scale(v,v,-1);var I=i.getClosestEdge(e,n,v,!0),R=i.getClosestEdge(l,u,v);if(-1===I||-1===R)return 0;for(var V=0;V<2;V++){var T=I,N=R,G=e,O=l,U=o,k=p,_=n,D=u,W=t,j=s;if(0===V){var X;X=T,T=N,N=X,X=G,G=O,O=X,X=U,U=k,k=X,X=_,_=D,D=X,X=W,W=j,j=X}for(var z=N;z=3){if(d)return!0;var Q=this.createContactEquation(W,j,G,O);M++;var Z=G.vertices[T%G.vertices.length],J=G.vertices[(T+1)%G.vertices.length];a.rotate(m,Z,_),a.rotate(g,J,_),c(m,m,U),c(g,g,U),r(P,g,m),a.rotate90cw(Q.normalA,P),a.normalize(Q.normalA,Q.normalA),r(x,y,m);var $=h(Q.normalA,x);a.scale(L,Q.normalA,$),r(Q.contactPointA,y,U),r(Q.contactPointA,Q.contactPointA,L),c(Q.contactPointA,Q.contactPointA,U),r(Q.contactPointA,Q.contactPointA,W.position),r(Q.contactPointB,y,k),c(Q.contactPointB,Q.contactPointB,k),r(Q.contactPointB,Q.contactPointB,j.position),this.contactEquations.push(Q),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(Q))}}}return this.enableFrictionReduction&&this.enableFriction&&M&&this.frictionEquations.push(this.createFrictionFromAverage(M)),M};var Q=a.fromValues(0,0);i.projectConvexOntoAxis=function(t,e,o,i,n){var s,r,c=null,l=null,p=Q;a.rotate(p,i,-o);for(var u=0;uc)&&(c=r),(null===l||rc){var d=l;l=c,c=d}var f=h(e,i);a.set(n,l+f,c+f)};var $=a.fromValues(0,0),tt=a.fromValues(0,0),et=a.fromValues(0,0),ot=a.fromValues(0,0),it=a.fromValues(0,0),nt=a.fromValues(0,0);i.findSeparatingAxis=function(t,e,o,n,s,c,h){var l=null,p=!1,u=!1,d=$,f=tt,v=et,y=ot,g=it,A=nt;if(t instanceof m&&n instanceof m)for(P=0;2!==P;P++){var b=t,E=o;1===P&&(b=n,E=c);for(w=0;2!==w;w++){0===w?a.set(y,0,1):1===w&&a.set(y,1,0),0!==E&&a.rotate(y,y,E),i.projectConvexOntoAxis(t,e,o,y,g),i.projectConvexOntoAxis(n,s,c,y,A);var B=g,q=A;g[0]>A[0]&&(q=g,B=A,!0),p=(S=q[0]-B[1])<=0,(null===l||S>l)&&(a.copy(h,y),l=S,u=p)}}else for(var P=0;2!==P;P++){var b=t,E=o;1===P&&(b=n,E=c);for(var w=0;w!==b.vertices.length;w++){a.rotate(f,b.vertices[w],E),a.rotate(v,b.vertices[(w+1)%b.vertices.length],E),r(d,v,f),a.rotate90cw(y,d),a.normalize(y,y),i.projectConvexOntoAxis(t,e,o,y,g),i.projectConvexOntoAxis(n,s,c,y,A);var B=g,q=A;g[0]>A[0]&&(q=g,B=A,!0);var S=q[0]-B[1];p=S<=0,(null===l||S>l)&&(a.copy(h,y),l=S,u=p)}}return u};var st=a.fromValues(0,0),at=a.fromValues(0,0),rt=a.fromValues(0,0);i.getClosestEdge=function(t,e,o,i){var n=st,s=at,c=rt;a.rotate(n,o,-e),i&&a.scale(n,n,-1);for(var l=-1,p=t.vertices.length,u=-1,d=0;d!==p;d++){r(s,t.vertices[(d+1)%p],t.vertices[d%p]),a.rotate90cw(c,s),a.normalize(c,c);var f=h(c,n);(-1===l||f>u)&&(l=d%p,u=f)}return l};var ct=a.create(),ht=a.create(),lt=a.create(),pt=a.create(),ut=a.create(),dt=a.create(),ft=a.create();i.prototype[y.CIRCLE|y.HEIGHTFIELD]=i.prototype.circleHeightfield=function(t,e,o,i,n,s,h,l,p,u){var d=s.heights,u=u||e.radius,f=s.elementWidth,v=ht,y=ct,m=ut,g=ft,A=dt,b=lt,E=pt,B=Math.floor((o[0]-u-h[0])/f),q=Math.ceil((o[0]+u-h[0])/f);B<0&&(B=0),q>=d.length&&(q=d.length-1);for(var P=d[B],w=d[q],S=B;SP&&(P=d[S]);if(o[1]-u>P)return!p&&0;for(var C=!1,S=B;S=b[0]&&y[0]0)for(S=B;S<=q;S++)if(a.set(b,S*f,d[S]),a.add(b,b,h),a.sub(v,o,b),a.squaredLength(v)=l.length&&(m=l.length-1);for(var g=l[y],A=l[m],b=y;bg&&(g=l[b]);if(t.aabb.lowerBound[1]>g)return!h&&0;for(var E=0,b=y;b=0||s.containsPoint(this.from))&&this.intersectBody(t,n)}};var a=s.create();i.prototype.intersectBody=function(t,e){var o=this.checkCollisionResponse;if(!o||e.collisionResponse)for(var i=a,n=0,r=e.shapes.length;ne.boundingRadius*e.boundingRadius||(this._currentBody=s,this._currentShape=e,e.raycast(t,this,i,o),this._currentBody=this._currentShape=null)},i.prototype.getAABB=function(t){var e=this.to,o=this.from;s.set(t.lowerBound,Math.min(e[0],o[0]),Math.min(e[1],o[1])),s.set(t.upperBound,Math.max(e[0],o[0]),Math.max(e[1],o[1]))};s.create();i.prototype.reportIntersection=function(t,e,o,n){this.from,this.to;var a=this._currentShape,r=this._currentBody;if(!(this.skipBackfaces&&s.dot(o,this.direction)>0))switch(this.mode){case i.ALL:t.set(o,a,r,e,n),this.callback(t);break;case i.CLOSEST:(e=0&&!(t[s].aabb.lowerBound[e]<=n.aabb.lowerBound[e]);s--)t[s+1]=t[s];t[s+1]=n}return t},i.prototype.sortList=function(){var t=this.axisList,e=this.axisIndex;i.sortAxisList(t,e)},i.prototype.getCollisionPairs=function(t){var e=this.axisList,o=this.result,i=this.axisIndex;o.length=0;for(var n=e.length;n--;){var a=e[n];a.aabbNeedsUpdate&&a.updateAABB()}this.sortList();for(var r=0,c=0|e.length;r!==c;r++)for(var h=e[r],l=r+1;lthis.upperLimit&&(s.maxForce=0,s.minForce=-this.maxForce,this.distance=this.upperLimit,p=!0),this.lowerLimitEnabled&&this.positiono?(r.scale(n.normalA,h,-1),r.sub(n.contactPointA,l,a.position),r.sub(n.contactPointB,p,c.position),r.scale(f,h,o),r.add(n.contactPointA,n.contactPointA,f),-1===t.indexOf(n)&&t.push(n)):-1!==(b=t.indexOf(n))&&t.splice(b,1),this.lowerLimitEnabled&&gr?(f.angle=r,-1===n.indexOf(f)&&n.push(f)):-1!==(m=n.indexOf(f))&&n.splice(m,1),this.lowerLimitEnabled&&y>1;if(e<3)return[];for(var o=[],n=[],s=0;s3;){var r=n[(s+0)%a],c=n[(s+1)%a],h=n[(s+2)%a],l=t[2*r],p=t[2*r+1],u=t[2*c],d=t[2*c+1],f=t[2*h],v=t[2*h+1],y=!1;if(i._convex(l,p,u,d,f,v)){y=!0;for(var m=0;m3*a)break}return o.push(n[0],n[1],n[2]),o},i._PointInTriangle=function(t,e,o,i,n,s,a,r){var c=a-o,h=r-i,l=n-o,p=s-i,u=t-o,d=e-i,f=c*c+h*h,v=c*l+h*p,y=c*u+h*d,m=l*l+p*p,g=l*u+p*d,A=1/(f*m-v*v),b=(m*y-v*g)*A,E=(f*g-v*y)*A;return b>=0&&E>=0&&b+E<1},i._convex=function(t,e,o,i,n,s){return(e-i)*(n-o)+(o-t)*(s-i)>=0},e.exports=i},{}],30:[function(t,e,o){var i=e.exports={},n=t("../utils/Utils");i.crossLength=function(t,e){return t[0]*e[1]-t[1]*e[0]},i.crossVZ=function(t,e,o){return i.rotate(t,e,-Math.PI/2),i.scale(t,t,o),t},i.crossZV=function(t,e,o){return i.rotate(t,o,Math.PI/2),i.scale(t,t,e),t},i.rotate=function(t,e,o){if(0!==o){var i=Math.cos(o),n=Math.sin(o),s=e[0],a=e[1];t[0]=i*s-n*a,t[1]=n*s+i*a}else t[0]=e[0],t[1]=e[1]},i.rotate90cw=function(t,e){var o=e[0],i=e[1];t[0]=i,t[1]=-o},i.toLocalFrame=function(t,e,o,n){i.copy(t,e),i.sub(t,t,o),i.rotate(t,t,-n)},i.toGlobalFrame=function(t,e,o,n){i.copy(t,e),i.rotate(t,t,n),i.add(t,t,o)},i.vectorToLocalFrame=function(t,e,o){i.rotate(t,e,-o)},i.vectorToGlobalFrame=function(t,e,o){i.rotate(t,e,o)},i.centroid=function(t,e,o,n){return i.add(t,e,o),i.add(t,t,n),i.scale(t,t,1/3),t},i.create=function(){var t=new n.ARRAY_TYPE(2);return t[0]=0,t[1]=0,t},i.clone=function(t){var e=new n.ARRAY_TYPE(2);return e[0]=t[0],e[1]=t[1],e},i.fromValues=function(t,e){var o=new n.ARRAY_TYPE(2);return o[0]=t,o[1]=e,o},i.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},i.set=function(t,e,o){return t[0]=e,t[1]=o,t},i.add=function(t,e,o){return t[0]=e[0]+o[0],t[1]=e[1]+o[1],t},i.subtract=function(t,e,o){return t[0]=e[0]-o[0],t[1]=e[1]-o[1],t},i.sub=i.subtract,i.multiply=function(t,e,o){return t[0]=e[0]*o[0],t[1]=e[1]*o[1],t},i.mul=i.multiply,i.divide=function(t,e,o){return t[0]=e[0]/o[0],t[1]=e[1]/o[1],t},i.div=i.divide,i.scale=function(t,e,o){return t[0]=e[0]*o,t[1]=e[1]*o,t},i.distance=function(t,e){var o=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(o*o+i*i)},i.dist=i.distance,i.squaredDistance=function(t,e){var o=e[0]-t[0],i=e[1]-t[1];return o*o+i*i},i.sqrDist=i.squaredDistance,i.length=function(t){var e=t[0],o=t[1];return Math.sqrt(e*e+o*o)},i.len=i.length,i.squaredLength=function(t){var e=t[0],o=t[1];return e*e+o*o},i.sqrLen=i.squaredLength,i.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},i.normalize=function(t,e){var o=e[0],i=e[1],n=o*o+i*i;return n>0&&(n=1/Math.sqrt(n),t[0]=e[0]*n,t[1]=e[1]*n),t},i.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},i.str=function(t){return"vec2("+t[0]+", "+t[1]+")"},i.lerp=function(t,e,o,i){var n=e[0],s=e[1];return t[0]=n+i*(o[0]-n),t[1]=s+i*(o[1]-s),t},i.reflect=function(t,e,o){var i=e[0]*o[0]+e[1]*o[1];t[0]=e[0]-2*o[0]*i,t[1]=e[1]-2*o[1]*i},i.getLineSegmentsIntersection=function(t,e,o,n,s){var a=i.getLineSegmentsIntersectionFraction(e,o,n,s);return!(a<0)&&(t[0]=e[0]+a*(o[0]-e[0]),t[1]=e[1]+a*(o[1]-e[1]),!0)},i.getLineSegmentsIntersectionFraction=function(t,e,o,i){var n,s,a=e[0]-t[0],r=e[1]-t[1],c=i[0]-o[0],h=i[1]-o[1];return n=(-r*(t[0]-o[0])+a*(t[1]-o[1]))/(-c*r+a*h),s=(c*(t[1]-o[1])-h*(t[0]-o[0]))/(-c*r+a*h),n>=0&&n<=1&&s>=0&&s<=1?s:-1}},{"../utils/Utils":57}],31:[function(t,e,o){function i(t){t=t||{},l.call(this),this.id=t.id||++i._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=i.STATIC,void 0!==t.type?this.type=t.type:t.mass?this.type=i.DYNAMIC:this.type=i.STATIC,this.boundingRadius=0,this.aabb=new h,this.aabbNeedsUpdate=!0,this.allowSleep=void 0===t.allowSleep||t.allowSleep,this.wantsToSleep=!1,this.sleepState=i.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"),s=t("poly-decomp"),a=t("../shapes/Convex"),r=t("../collision/RaycastResult"),c=t("../collision/Ray"),h=t("../collision/AABB"),l=t("../events/EventEmitter");e.exports=i,i.prototype=new l,i.prototype.constructor=i,i._idCounter=0,i.prototype.updateSolveMassProperties=function(){this.sleepState===i.SLEEPING||this.type===i.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve=0):(this.invMassSolve=this.invMass,this.invInertiaSolve=this.invInertia)},i.prototype.setDensity=function(t){var e=this.getArea();this.mass=e*t,this.updateMassProperties()},i.prototype.getArea=function(){for(var t=0,e=0;eo&&(o=a+r)}this.boundingRadius=o},i.prototype.addShape=function(t,e,o){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=o||0,this.shapes.push(t),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0},i.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)},i.prototype.updateMassProperties=function(){if(this.type===i.STATIC||this.type===i.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,o=this.mass/e,s=0;if(this.fixedRotation)this.inertia=Number.MAX_VALUE,this.invInertia=0;else{for(var a=0;a0?1/s:0}this.invMass=1/this.mass,n.set(this.massMultiplier,this.fixedX?0:1,this.fixedY?0:1)}};n.create();i.prototype.applyForce=function(t,e){if(n.add(this.force,this.force,t),e){var o=n.crossLength(e,t);this.angularForce+=o}};var d=n.create(),f=n.create(),v=n.create();i.prototype.applyForceLocal=function(t,e){e=e||v;var o=d,i=f;this.vectorToWorldFrame(o,t),this.vectorToWorldFrame(i,e),this.applyForce(o,i)};var y=n.create();i.prototype.applyImpulse=function(t,e){if(this.type===i.DYNAMIC){var o=y;if(n.scale(o,t,this.invMass),n.multiply(o,this.massMultiplier,o),n.add(this.velocity,o,this.velocity),e){var s=n.crossLength(e,t);s*=this.invInertia,this.angularVelocity+=s}}};var m=n.create(),g=n.create(),A=n.create();i.prototype.applyImpulseLocal=function(t,e){e=e||A;var o=m,i=g;this.vectorToWorldFrame(o,t),this.vectorToWorldFrame(i,e),this.applyImpulse(o,i)},i.prototype.toLocalFrame=function(t,e){n.toLocalFrame(t,e,this.position,this.angle)},i.prototype.toWorldFrame=function(t,e){n.toGlobalFrame(t,e,this.position,this.angle)},i.prototype.vectorToLocalFrame=function(t,e){n.vectorToLocalFrame(t,e,this.angle)},i.prototype.vectorToWorldFrame=function(t,e){n.vectorToGlobalFrame(t,e,this.angle)},i.prototype.fromPolygon=function(t,e){e=e||{};for(c=this.shapes.length;c>=0;--c)this.removeShape(this.shapes[c]);var o=new s.Polygon;if(o.vertices=t,o.makeCCW(),"number"==typeof e.removeCollinearPoints&&o.removeCollinearPoints(e.removeCollinearPoints),void 0===e.skipSimpleCheck&&!o.isSimple())return!1;this.concavePath=o.vertices.slice(0);for(c=0;c=Math.pow(this.sleepSpeedLimit,2)?(this.idleTime=0,this.sleepState=i.AWAKE):(this.idleTime+=o,this.sleepState=i.SLEEPY),this.idleTime>this.sleepTimeLimit&&(e?this.wantsToSleep=!0:this.sleep())}},i.prototype.overlaps=function(t){return this.world.overlapKeeper.bodiesAreOverlapping(this,t)};var q=n.create(),P=n.create();i.prototype.integrate=function(t){var e=this.invMass,o=this.force,i=this.position,s=this.velocity;n.copy(this.previousPosition,this.position),this.previousAngle=this.angle,this.fixedRotation||(this.angularVelocity+=this.angularForce*this.invInertia*t),n.scale(q,o,t*e),n.multiply(q,this.massMultiplier,q),n.add(s,q,s),this.integrateToTimeOfImpact(t)||(n.scale(P,s,t),n.add(i,i,P),this.fixedRotation||(this.angle+=this.angularVelocity*t)),this.aabbNeedsUpdate=!0};var w=new r,S=new c({mode:c.ALL}),C=n.create(),L=n.create(),x=n.create(),F=n.create();i.prototype.integrateToTimeOfImpact=function(t){if(this.ccdSpeedThreshold<0||n.squaredLength(this.velocity)=h&&c=0&&(s.rotate(d,p,i),s.scale(d,d,2*m-1),e.reportIntersection(t,q,d,-1),t.shouldStop(e)))return}for(var A=Math.pow(this.radius,2)+Math.pow(y,2),m=0;m<2;m++){s.set(f,y*(2*m-1),0),s.toGlobalFrame(f,f,o,i);var b=Math.pow(a[0]-n[0],2)+Math.pow(a[1]-n[1],2),E=2*((a[0]-n[0])*(n[0]-f[0])+(a[1]-n[1])*(n[1]-f[1])),B=Math.pow(n[0]-f[0],2)+Math.pow(n[1]-f[1],2)-Math.pow(this.radius,2),q=Math.pow(E,2)-4*b*B;if(!(q<0))if(0===q){if(s.lerp(u,n,a,q),s.squaredDistance(u,o)>A&&(s.sub(d,u,f),s.normalize(d,d),e.reportIntersection(t,q,d,-1),t.shouldStop(e)))return}else{var P=Math.sqrt(q),w=1/(2*b),S=(-E-P)*w,C=(-E+P)*w;if(S>=0&&S<=1&&(s.lerp(u,n,a,S),s.squaredDistance(u,o)>A&&(s.sub(d,u,f),s.normalize(d,d),e.reportIntersection(t,S,d,-1),t.shouldStop(e))))return;if(C>=0&&C<=1&&(s.lerp(u,n,a,C),s.squaredDistance(u,o)>A&&(s.sub(d,u,f),s.normalize(d,d),e.reportIntersection(t,C,d,-1),t.shouldStop(e))))return}}}},{"../math/vec2":30,"./Shape":45}],39:[function(t,e,o){function i(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"),s=t("../math/vec2");e.exports=i,(i.prototype=new n).constructor=i,i.prototype.computeMomentOfInertia=function(t){var e=this.radius;return t*e*e/2},i.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius},i.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius},i.prototype.computeAABB=function(t,e,o){var i=this.radius;s.set(t.upperBound,i,i),s.set(t.lowerBound,-i,-i),e&&(s.add(t.lowerBound,t.lowerBound,e),s.add(t.upperBound,t.upperBound,e))};var a=s.create(),r=s.create();i.prototype.raycast=function(t,e,o,i){var n=e.from,c=e.to,h=this.radius,l=Math.pow(c[0]-n[0],2)+Math.pow(c[1]-n[1],2),p=2*((c[0]-n[0])*(n[0]-o[0])+(c[1]-n[1])*(n[1]-o[1])),u=Math.pow(n[0]-o[0],2)+Math.pow(n[1]-o[1],2)-Math.pow(h,2),d=Math.pow(p,2)-4*l*u,f=a,v=r;if(!(d<0))if(0===d)s.lerp(f,n,c,d),s.sub(v,f,o),s.normalize(v,v),e.reportIntersection(t,d,v,-1);else{var y=Math.sqrt(d),m=1/(2*l),g=(-p-y)*m,A=(-p+y)*m;if(g>=0&&g<=1&&(s.lerp(f,n,c,g),s.sub(v,f,o),s.normalize(v,v),e.reportIntersection(t,g,v,-1),t.shouldStop(e)))return;A>=0&&A<=1&&(s.lerp(f,n,c,A),s.sub(v,f,o),s.normalize(v,v),e.reportIntersection(t,A,v,-1))}}},{"../math/vec2":30,"./Shape":45}],40:[function(t,e,o){function i(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:[],o=0;on)&&(n=i),(null===a||in){var h=a;a=n,n=h}s.set(e,a,n)},i.prototype.projectOntoWorldAxis=function(t,e,o,i){var n=c;this.projectOntoLocalAxis(t,i),0!==o?s.rotate(n,t,o):n=t;var a=s.dot(e,n);s.set(i,i[0]+a,i[1]+a)},i.prototype.updateTriangles=function(){this.triangles.length=0;for(var t=[],e=0;ee&&(e=i)}this.boundingRadius=Math.sqrt(e)},i.triangleArea=function(t,e,o){return.5*((e[0]-t[0])*(o[1]-t[1])-(o[0]-t[0])*(e[1]-t[1]))},i.prototype.updateArea=function(){this.updateTriangles(),this.area=0;for(var t=this.triangles,e=this.vertices,o=0;o!==t.length;o++){var n=t[o],s=e[n[0]],a=e[n[1]],r=e[n[2]],c=i.triangleArea(s,a,r);this.area+=c}},i.prototype.computeAABB=function(t,e,o){t.setFromPoints(this.vertices,e,o,0)};var f=s.create(),v=s.create(),y=s.create();i.prototype.raycast=function(t,e,o,i){var n=f,a=v,r=y,c=this.vertices;s.toLocalFrame(n,e.from,o,i),s.toLocalFrame(a,e.to,o,i);for(var h=c.length,l=0;l=0&&(s.sub(r,u,p),s.rotate(r,r,-Math.PI/2+i),s.normalize(r,r),e.reportIntersection(t,d,r,l))}}},{"../math/polyk":29,"../math/vec2":30,"./Shape":45,"poly-decomp":5}],41:[function(t,e,o){function i(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"),s=t("../math/vec2");t("../utils/Utils");e.exports=i,(i.prototype=new n).constructor=i,i.prototype.updateMaxMinValues=function(){for(var t=this.heights,e=t[0],o=t[0],i=0;i!==t.length;i++){var n=t[i];n>e&&(e=n),ng){var A=m;m=g,g=A}for(var b=0;b=0&&(s.sub(u,f,d),s.rotate(u,u,i+Math.PI/2),s.normalize(u,u),e.reportIntersection(t,E,u,-1),t.shouldStop(e)))return}}},{"../math/vec2":30,"../utils/Utils":57,"./Shape":45}],42:[function(t,e,o){function i(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"),s=t("../math/vec2");e.exports=i,(i.prototype=new n).constructor=i,i.prototype.computeMomentOfInertia=function(t){return t*Math.pow(this.length,2)/12},i.prototype.updateBoundingRadius=function(){this.boundingRadius=this.length/2};var a=[s.create(),s.create()];i.prototype.computeAABB=function(t,e,o){var i=this.length/2;s.set(a[0],-i,0),s.set(a[1],i,0),t.setFromPoints(a,e,o,0)};s.create();var r=s.create(),c=s.create(),h=s.create(),l=s.fromValues(0,1);i.prototype.raycast=function(t,e,o,i){var n=e.from,a=e.to,p=c,u=h,d=this.length/2;s.set(p,-d,0),s.set(u,d,0),s.toGlobalFrame(p,p,o,i),s.toGlobalFrame(u,u,o,i);var f=s.getLineSegmentsIntersectionFraction(p,u,n,a);if(f>=0){var v=r;s.rotate(v,l,i),e.reportIntersection(t,f,v,-1)}}},{"../math/vec2":30,"./Shape":45}],43:[function(t,e,o){function i(t){(t=t||{}).type=n.PARTICLE,n.call(this,t)}var n=t("./Shape"),s=t("../math/vec2");e.exports=i,(i.prototype=new n).constructor=i,i.prototype.computeMomentOfInertia=function(t){return 0},i.prototype.updateBoundingRadius=function(){this.boundingRadius=0},i.prototype.computeAABB=function(t,e,o){s.copy(t.lowerBound,e),s.copy(t.upperBound,e)}},{"../math/vec2":30,"./Shape":45}],44:[function(t,e,o){function i(t){(t=t||{}).type=n.PLANE,n.call(this,t)}var n=t("./Shape"),s=t("../math/vec2");t("../utils/Utils");e.exports=i,(i.prototype=new n).constructor=i,i.prototype.computeMomentOfInertia=function(t){return 0},i.prototype.updateBoundingRadius=function(){this.boundingRadius=Number.MAX_VALUE},i.prototype.computeAABB=function(t,e,o){var i=o%(2*Math.PI),n=s.set,a=t.lowerBound,r=t.upperBound;n(a,-1e7,-1e7),n(r,1e7,1e7),0===i?r[1]=0:i===Math.PI/2?a[0]=0:i===Math.PI?a[1]=0:i===3*Math.PI/2&&(r[0]=0)},i.prototype.updateArea=function(){this.area=Number.MAX_VALUE};var a=s.create(),r=(s.create(),s.create(),s.create()),c=s.create();i.prototype.raycast=function(t,e,o,i){var n=e.from,h=e.to,l=e.direction,p=a,u=r,d=c;s.set(u,0,1),s.rotate(u,u,i),s.sub(d,n,o);var f=s.dot(d,u);if(s.sub(d,h,o),!(f*s.dot(d,u)>0||s.squaredDistance(n,h)d*r&&(v=d*r-p),s[t]+=v,e.addToWlambda(v),v}},{"../equations/FrictionEquation":23,"../math/vec2":30,"../utils/Utils":57,"./Solver":47}],47:[function(t,e,o){function i(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=i,(i.prototype=new n).constructor=i,i.prototype.solve=function(t,e){throw new Error("Solver.solve should be implemented by subclasses!")};var s={bodies:[]};i.prototype.solveIsland=function(t,e){this.removeAllEquations(),e.equations.length&&(this.addEquations(e.equations),s.bodies.length=0,e.getBodies(s.bodies),s.bodies.length&&this.solve(t,s))},i.prototype.sortEquations=function(){this.equationSortFunction&&this.equations.sort(this.equationSortFunction)},i.prototype.addEquation=function(t){t.enabled&&this.equations.push(t)},i.prototype.addEquations=function(t){for(var e=0,o=t.length;e!==o;e++){var i=t[e];i.enabled&&this.equations.push(i)}},i.prototype.removeEquation=function(t){var e=this.equations.indexOf(t);-1!==e&&this.equations.splice(e,1)},i.prototype.removeAllEquations=function(){this.equations.length=0},i.GS=1,i.ISLAND=2},{"../events/EventEmitter":26,"../utils/Utils":57}],48:[function(t,e,o){function i(){s.apply(this,arguments)}var n=t("../equations/ContactEquation"),s=t("./Pool");e.exports=i,(i.prototype=new s).constructor=i,i.prototype.create=function(){return new n},i.prototype.destroy=function(t){return t.bodyA=t.bodyB=null,this}},{"../equations/ContactEquation":21,"./Pool":55}],49:[function(t,e,o){function i(){s.apply(this,arguments)}var n=t("../equations/FrictionEquation"),s=t("./Pool");e.exports=i,(i.prototype=new s).constructor=i,i.prototype.create=function(){return new n},i.prototype.destroy=function(t){return t.bodyA=t.bodyB=null,this}},{"../equations/FrictionEquation":23,"./Pool":55}],50:[function(t,e,o){function i(){s.apply(this,arguments)}var n=t("../world/IslandNode"),s=t("./Pool");e.exports=i,(i.prototype=new s).constructor=i,i.prototype.create=function(){return new n},i.prototype.destroy=function(t){return t.reset(),this}},{"../world/IslandNode":60,"./Pool":55}],51:[function(t,e,o){function i(){s.apply(this,arguments)}var n=t("../world/Island"),s=t("./Pool");e.exports=i,(i.prototype=new s).constructor=i,i.prototype.create=function(){return new n},i.prototype.destroy=function(t){return t.reset(),this}},{"../world/Island":58,"./Pool":55}],52:[function(t,e,o){function i(){this.overlappingShapesLastState=new n,this.overlappingShapesCurrentState=new n,this.recordPool=new s({size:16}),this.tmpDict=new n,this.tmpArray1=[]}var n=t("./TupleDictionary"),s=(t("./OverlapKeeperRecord"),t("./OverlapKeeperRecordPool"));t("./Utils");e.exports=i,i.prototype.tick=function(){for(var t=this.overlappingShapesLastState,e=this.overlappingShapesCurrentState,o=t.keys.length;o--;){var i=t.keys[o],n=t.getByKey(i);e.getByKey(i);n&&this.recordPool.release(n)}t.reset(),t.copy(e),e.reset()},i.prototype.setOverlapping=function(t,e,o,i){this.overlappingShapesLastState;var n=this.overlappingShapesCurrentState;if(!n.get(e.id,i.id)){var s=this.recordPool.get();s.set(t,e,o,i),n.set(e.id,i.id,s)}},i.prototype.getNewOverlaps=function(t){return this.getDiff(this.overlappingShapesLastState,this.overlappingShapesCurrentState,t)},i.prototype.getEndOverlaps=function(t){return this.getDiff(this.overlappingShapesCurrentState,this.overlappingShapesLastState,t)},i.prototype.bodiesAreOverlapping=function(t,e){for(var o=this.overlappingShapesCurrentState,i=o.keys.length;i--;){var n=o.keys[i],s=o.data[n];if(s.bodyA===t&&s.bodyB===e||s.bodyA===e&&s.bodyB===t)return!0}return!1},i.prototype.getDiff=function(t,e,o){var i=t,n=e;(o=o||[]).length=0;for(var s=n.keys.length;s--;){var a=n.keys[s],r=n.data[a];if(!r)throw new Error("Key "+a+" had no data!");i.data[a]||o.push(r)}return o},i.prototype.isNewOverlap=function(t,e){var o=0|t.id,i=0|e.id,n=this.overlappingShapesLastState,s=this.overlappingShapesCurrentState;return!n.get(o,i)&&!!s.get(o,i)},i.prototype.getNewBodyOverlaps=function(t){this.tmpArray1.length=0;var e=this.getNewOverlaps(this.tmpArray1);return this.getBodyDiff(e,t)},i.prototype.getEndBodyOverlaps=function(t){this.tmpArray1.length=0;var e=this.getEndOverlaps(this.tmpArray1);return this.getBodyDiff(e,t)},i.prototype.getBodyDiff=function(t,e){e=e||[];for(var o=this.tmpDict,i=t.length;i--;){var n=t[i];o.set(0|n.bodyA.id,0|n.bodyB.id,n)}for(i=o.keys.length;i--;)(n=o.getByKey(o.keys[i]))&&e.push(n.bodyA,n.bodyB);return o.reset(),e}},{"./OverlapKeeperRecord":53,"./OverlapKeeperRecordPool":54,"./TupleDictionary":56,"./Utils":57}],53:[function(t,e,o){function i(t,e,o,i){this.shapeA=e,this.shapeB=i,this.bodyA=t,this.bodyB=o}e.exports=i,i.prototype.set=function(t,e,o,n){i.call(this,t,e,o,n)}},{}],54:[function(t,e,o){function i(){s.apply(this,arguments)}var n=t("./OverlapKeeperRecord"),s=t("./Pool");e.exports=i,(i.prototype=new s).constructor=i,i.prototype.create=function(){return new n},i.prototype.destroy=function(t){return t.bodyA=t.bodyB=t.shapeA=t.shapeB=null,this}},{"./OverlapKeeperRecord":53,"./Pool":55}],55:[function(t,e,o){function i(t){t=t||{},this.objects=[],void 0!==t.size&&this.resize(t.size)}e.exports=i,i.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)},i.prototype.getByKey=function(t){return t|=0,this.data[t]},i.prototype.get=function(t,e){return this.data[this.getKey(t,e)]},i.prototype.set=function(t,e,o){if(!o)throw new Error("No data!");var i=this.getKey(t,e);return this.data[i]||this.keys.push(i),this.data[i]=o,i},i.prototype.reset=function(){for(var t=this.data,e=this.keys,o=e.length;o--;)delete t[e[o]];e.length=0},i.prototype.copy=function(t){this.reset(),n.appendArray(this.keys,t.keys);for(var e=t.keys.length;e--;){var o=t.keys[e];this.data[o]=t.data[o]}}},{"./Utils":57}],57:[function(t,e,o){function i(){}e.exports=i,i.appendArray=function(t,e){if(e.length<15e4)t.push.apply(t,e);else for(var o=0,i=e.length;o!==i;++o)t.push(e[o])},i.splice=function(t,e,o){o=o||1;for(var i=e,n=t.length-o;i=t&&i=0;q-=2)for(S=b.length-2;S>=0;S-=2)(B[q]===b[S]&&B[q+1]===b[S+1]||B[q+1]===b[S]&&B[q]===b[S+1])&&b.splice(S,2);X=p.length;for(q=0;q!==X;q++){var w=p[q];if(!w.collideConnected)for(var S=b.length-2;S>=0;S-=2)(w.bodyA===b[S]&&w.bodyB===b[S+1]||w.bodyB===b[S]&&w.bodyA===b[S+1])&&b.splice(S,2)}this.postBroadphaseEvent.pairs=b,this.emit(this.postBroadphaseEvent),this.postBroadphaseEvent.pairs=null,l.reset(this);for(var q=0,C=b.length;q!==C;q+=2)for(var L=b[q],x=b[q+1],F=0,M=L.shapes.length;F!==M;F++)for(var I=L.shapes[F],R=I.position,V=I.angle,T=0,N=x.shapes.length;T!==N;T++){var G=x.shapes[T],O=G.position,U=G.angle,k=this.defaultContactMaterial;if(I.material&&G.material){var _=this.getContactMaterial(I.material,G.material);_&&(k=_)}this.runNarrowphase(l,L,I,R,V,x,G,O,U,k,this.frictionGravity)}for(q=0;q!==c;q++)(z=n[q])._wakeUpAfterNarrowphase&&(z.wakeUp(),z._wakeUpAfterNarrowphase=!1);if(this.has("endContact")){this.overlapKeeper.getEndOverlaps(P);for(var D=this.endContactEvent,T=P.length;T--;){var W=P[T];D.shapeA=W.shapeA,D.shapeB=W.shapeB,D.bodyA=W.bodyA,D.bodyB=W.bodyB,this.emit(D)}P.length=0}var j=this.preSolveEvent;j.contactEquations=l.contactEquations,j.frictionEquations=l.frictionEquations,this.emit(j),j.contactEquations=j.frictionEquations=null;var X=p.length;for(q=0;q!==X;q++)p[q].update();if(l.contactEquations.length||l.frictionEquations.length||X)if(this.islandSplit){for(v.equations.length=0,g.appendArray(v.equations,l.contactEquations),g.appendArray(v.equations,l.frictionEquations),q=0;q!==X;q++)g.appendArray(v.equations,p[q].equations);v.split(this);for(q=0;q!==v.islands.length;q++)(H=v.islands[q]).equations.length&&r.solveIsland(t,H)}else{for(r.addEquations(l.contactEquations),r.addEquations(l.frictionEquations),q=0;q!==X;q++)r.addEquations(p[q].equations);this.solveConstraints&&r.solve(t,this),r.removeAllEquations()}for(q=0;q!==c;q++){var z=n[q];z.integrate(t)}for(q=0;q!==c;q++)n[q].setZeroForce();if(this.emitImpactEvent&&this.has("impact"))for(var Y=this.impactEvent,q=0;q!==l.contactEquations.length;q++){var K=l.contactEquations[q];K.firstImpact&&(Y.bodyA=K.bodyA,Y.bodyB=K.bodyB,Y.shapeA=K.shapeA,Y.shapeB=K.shapeB,Y.contactEquation=K,this.emit(Y))}if(this.sleepMode===i.BODY_SLEEPING)for(q=0;q!==c;q++)n[q].sleepTick(this.time,!1,t);else if(this.sleepMode===i.ISLAND_SLEEPING&&this.islandSplit){for(q=0;q!==c;q++)n[q].sleepTick(this.time,!0,t);for(q=0;q0,t.frictionCoefficient=l.friction;var v;v=e.type===u.STATIC||e.type===u.KINEMATIC?a.mass:a.type===u.STATIC||a.type===u.KINEMATIC?e.mass:e.mass*a.mass/(e.mass+a.mass),t.slipForce=l.friction*p*v,t.restitution=l.restitution,t.surfaceVelocity=l.surfaceVelocity,t.frictionStiffness=l.frictionStiffness,t.frictionRelaxation=l.frictionRelaxation,t.stiffness=l.stiffness,t.relaxation=l.relaxation,t.contactSkinSize=l.contactSkinSize,t.enabledEquations=e.collisionResponse&&a.collisionResponse&&o.collisionResponse&&r.collisionResponse;var y=t[o.type|r.type],m=0;if(y){var g=o.sensor||r.sensor,A=t.frictionEquations.length;m=o.type=2*Math.pow(a.sleepSpeedLimit,2)&&(e._wakeUpAfterNarrowphase=!0),a.allowSleep&&a.type===u.DYNAMIC&&a.sleepState===u.SLEEPING&&e.sleepState===u.AWAKE&&e.type!==u.STATIC&&s.squaredLength(e.velocity)+Math.pow(e.angularVelocity,2)>=2*Math.pow(e.sleepSpeedLimit,2)&&(a._wakeUpAfterNarrowphase=!0),this.overlapKeeper.setOverlapping(e,o,a,r),this.has("beginContact")&&this.overlapKeeper.isNewOverlap(o,r)){var E=this.beginContactEvent;if(E.shapeA=o,E.shapeB=r,E.bodyA=e,E.bodyB=a,E.contactEquations.length=0,"number"==typeof m)for(P=t.contactEquations.length-m;P1)for(var P=t.frictionEquations.length-b;P=0;e--)this.removeConstraint(t[e]);for(var o=this.bodies,e=o.length-1;e>=0;e--)this.removeBody(o[e]);for(var n=this.springs,e=n.length-1;e>=0;e--)this.removeSpring(n[e]);for(var s=this.contactMaterials,e=s.length-1;e>=0;e--)this.removeContactMaterial(s[e]);i.apply(this)};var w=s.create(),S=(s.fromValues(0,0),s.fromValues(0,0));i.prototype.hitTest=function(t,e,o){o=o||0;var i=new u({position:t}),n=new l,p=t,d=w,f=S;i.addShape(n);for(var v=this.narrowphase,y=[],m=0,g=e.length;m!==g;m++)for(var A=e[m],b=0,E=A.shapes.length;b!==E;b++){var B=A.shapes[b];s.rotate(d,B.position,A.angle),s.add(d,d,A.position);var q=B.angle+A.angle;(B instanceof a&&v.circleParticle(A,B,d,q,i,n,p,0,!0)||B instanceof r&&v.particleConvex(i,n,p,0,A,B,d,q,!0)||B instanceof c&&v.particlePlane(i,n,p,0,A,B,d,q,!0)||B instanceof h&&v.particleCapsule(i,n,p,0,A,B,d,q,!0)||B instanceof l&&s.squaredLength(s.sub(f,d,t))0?Math.acos(i/c):-Math.acos(i/c),this.worldScale.x=c,this.worldScale.y=u/c}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=u/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.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?c:a,d=d>h?d:h);var f=this._bounds;if(!p){var m=(f=new s.Rectangle).x,g=f.width+f.x,y=f.y,v=f.height+f.y,x=this.worldTransform,b=x.a,_=x.b,T=x.c,w=x.d,C=x.tx,S=x.ty,P=b*g+T*v+C,E=w*v+_*g+S,A=b*m+T*v+C,R=w*v+_*m+S,M=b*m+T*y+C,L=w*y+_*m+S,I=b*g+T*y+C,O=w*y+_*g+S;c=P,d=E,u=E,l=I<(l=M<(l=A<(l=P)?A:l)?M:l)?I:l,u=O<(u=L<(u=R(c=M>(c=A>c?A:c)?M:c)?I:c,d=O>(d=L>(d=R>d?R:d)?L:d)?O:d}if(f.x=l,f.y=u,f.width=c-l,f.height=d-u,e)for(t.worldTransform=r,n=0;n(f=w>(f=_>(f=x>f?x:f)?_:f)?w:f)?S:f,m=P>(m=C>(m=T>(m=b>m?b:m)?T:m)?C:m)?P:m}var E=this._bounds;return E.x=g,E.width=f-g,E.y=y,E.height=m-y,this._currentBounds=E,E},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 a=i._uvs;if(a){var h,l,u,c,d=t.anchor.x,p=t.anchor.y;if(i.trim){var f=i.trim;h=(l=f.x-d*f.width)+i.crop.width,u=(c=f.y-p*f.height)+i.crop.height}else h=i.frame.width*(1-d),l=i.frame.width*-d,u=i.frame.height*(1-p),c=i.frame.height*-p;var m=this.currentBatchSize*this.vertexSize,g=(this.currentBatchSize,i.baseTexture.resolution),y=i.baseTexture.textureIndex,v=o.a/g,x=o.b/g,b=o.c/g,_=o.d/g,T=o.tx,w=o.ty,C=(i.crop.width,i.crop.height);if(i.rotated){var S=o.a,P=o.b,E=o.c,A=o.d,R=l,M=h;T=o.c*C+T,w=o.d*C+w,v=6.123233995736766e-17*S-E,x=6.123233995736766e-17*P-A,b=S+6.123233995736766e-17*E,_=P+6.123233995736766e-17*A,i._updateUvsInverted(),h=u,l=c,u=M,c=R}var L=this.colors,I=this.positions,O=t.tint,k=(O>>16)+(65280&O)+((255&O)<<16)+(255*t.worldAlpha<<24);this.renderSession.roundPixels?(I[m++]=v*l+b*c+T|0,I[m++]=_*c+x*l+w|0,I[m++]=a.x0,I[m++]=a.y0,L[m++]=k,I[m++]=y,I[m++]=v*h+b*c+T|0,I[m++]=_*c+x*h+w|0,I[m++]=a.x1,I[m++]=a.y1,L[m++]=k,I[m++]=y,I[m++]=v*h+b*u+T|0,I[m++]=_*u+x*h+w|0,I[m++]=a.x2,I[m++]=a.y2,L[m++]=k,I[m++]=y,I[m++]=v*l+b*u+T|0,I[m++]=_*u+x*l+w|0,I[m++]=a.x3,I[m++]=a.y3,L[m++]=k,I[m++]=y):(I[m++]=v*l+b*c+T,I[m++]=_*c+x*l+w,I[m++]=a.x0,I[m++]=a.y0,L[m++]=k,I[m++]=y,I[m++]=v*h+b*c+T,I[m++]=_*c+x*h+w,I[m++]=a.x1,I[m++]=a.y1,L[m++]=k,I[m++]=y,I[m++]=v*h+b*u+T,I[m++]=_*u+x*h+w,I[m++]=a.x2,I[m++]=a.y2,L[m++]=k,I[m++]=y,I[m++]=v*l+b*u+T,I[m++]=_*u+x*l+w,I[m++]=a.x3,I[m++]=a.y3,L[m++]=k,I[m++]=y),this.sprites[this.currentBatchSize++]=t}},s.WebGLSpriteBatch.prototype.renderTilingSprite=function(t){var e=t.tilingTexture,i=e.baseTexture,n=this.gl,r=t.texture.baseTexture.textureIndex;s.WebGLRenderer.textureArray[r]!=i&&(this.flush(),n.activeTexture(n.TEXTURE0+r),n.bindTexture(n.TEXTURE_2D,i._glTextures[n.id]),s.WebGLRenderer.textureArray[r]=i),this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=e.baseTexture),t._uvs||(t._uvs=new s.TextureUvs);var o=t._uvs,a=e.baseTexture.width,h=e.baseTexture.height;t.tilePosition.x%=a*t.tileScaleOffset.x,t.tilePosition.y%=h*t.tileScaleOffset.y;var l=t.tilePosition.x/(a*t.tileScaleOffset.x),u=t.tilePosition.y/(h*t.tileScaleOffset.y),c=t.width/a/(t.tileScale.x*t.tileScaleOffset.x),d=t.height/h/(t.tileScale.y*t.tileScaleOffset.y);o.x0=0-l,o.y0=0-u,o.x1=1*c-l,o.y1=0-u,o.x2=1*c-l,o.y2=1*d-u,o.x3=0-l,o.y3=1*d-u;var p=t.tint,f=(p>>16)+(65280&p)+((255&p)<<16)+(255*t.worldAlpha<<24),m=this.positions,g=this.colors,y=t.width,v=t.height,x=t.anchor.x,b=t.anchor.y,_=y*(1-x),T=y*-x,w=v*(1-b),C=v*-b,S=this.currentBatchSize*this.vertexSize,P=e.baseTexture.resolution,E=t.worldTransform,A=E.a/P,R=E.b/P,M=E.c/P,L=E.d/P,I=E.tx,O=E.ty;m[S++]=A*T+M*C+I,m[S++]=L*C+R*T+O,m[S++]=o.x0,m[S++]=o.y0,g[S++]=f,m[S++]=r,m[S++]=A*_+M*C+I,m[S++]=L*C+R*_+O,m[S++]=o.x1,m[S++]=o.y1,g[S++]=f,m[S++]=r,m[S++]=A*_+M*w+I,m[S++]=L*w+R*_+O,m[S++]=o.x2,m[S++]=o.y2,g[S++]=f,m[S++]=r,m[S++]=A*T+M*w+I,m[S++]=L*w+R*T+O,m[S++]=o.x3,m[S++]=o.y3,g[S++]=f,m[S++]=r,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,u=0,c=null,d=this.renderSession.blendModeManager.currentBlendMode,p=null,f=!1,m=!1,g=0,y=this.currentBatchSize;g0&&(v=!1),(f||m)&&(this.renderBatch(c,l,u),u=g,l=0,c=r,f&&(d=o,this.renderSession.blendModeManager.setBlendMode(d)),m)){(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(c,l,u),this.currentBatchSize=0,this.renderSession.flushCount++}},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++,this.renderSession.flushCount++}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(){function t(t,e){this._scaleFactor=t,this._deltaMode=e,this.originalEvent=null}var e=this,i=i||{VERSION:"2.8.6",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(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,e,s,n,r,o,a=arguments[0]||{},h=1,l=arguments.length,u=!1;for("boolean"==typeof a&&(u=a,a=arguments[1]||{},h=2),l===h&&(a=this,--h);h0&&(this._radius=.5*s),this.type=i.CIRCLE},i.Circle.prototype={circumference:function(){return Math.PI*this._radius*2},random:function(t){void 0===t&&(t=new i.Point);var e=2*Math.PI*Math.random(),s=Math.random()+Math.random(),n=s>1?2-s:s,r=n*Math.cos(e),o=n*Math.sin(e);return t.x=this.x+r*this.radius,t.y=this.y+o*this.radius,t},getBounds:function(){return new i.Rectangle(this.x-this.radius,this.y-this.radius,this.diameter,this.diameter)},setTo:function(t,e,i){return this.x=t,this.y=e,this._diameter=i,this._radius=.5*i,this},copyFrom:function(t){return this.setTo(t.x,t.y,t.diameter)},copyTo:function(t){return t.x=this.x,t.y=this.y,t.diameter=this._diameter,t},distance:function(t,e){var s=i.Math.distance(this.x,this.y,t.x,t.y);return e?Math.round(s):s},clone:function(t){return void 0===t||null===t?t=new i.Circle(this.x,this.y,this.diameter):t.setTo(this.x,this.y,this.diameter),t},contains:function(t,e){return i.Circle.contains(this,t,e)},circumferencePoint:function(t,e,s){return i.Circle.circumferencePoint(this,t,e,s)},offset:function(t,e){return this.x+=t,this.y+=e,this},offsetPoint:function(t){return this.offset(t.x,t.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}},i.Circle.prototype.constructor=i.Circle,Object.defineProperty(i.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(t){t>0&&(this._diameter=t,this._radius=.5*t)}}),Object.defineProperty(i.Circle.prototype,"radius",{get:function(){return this._radius},set:function(t){t>0&&(this._radius=t,this._diameter=2*t)}}),Object.defineProperty(i.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(i.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(i.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(t){t0?Math.PI*this._radius*this._radius:0}}),Object.defineProperty(i.Circle.prototype,"empty",{get:function(){return 0===this._diameter},set:function(t){!0===t&&this.setTo(0,0,0)}}),i.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},i.Circle.equals=function(t,e){return t.x===e.x&&t.y===e.y&&t.diameter===e.diameter},i.Circle.intersects=function(t,e){return i.Math.distance(t.x,t.y,e.x,e.y)<=t.radius+e.radius},i.Circle.circumferencePoint=function(t,e,s,n){return void 0===s&&(s=!1),void 0===n&&(n=new i.Point),!0===s&&(e=i.Math.degToRad(e)),n.x=t.x+t.radius*Math.cos(e),n.y=t.y+t.radius*Math.sin(e),n},i.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},PIXI.Circle=i.Circle,i.Ellipse=function(t,e,s,n){t=t||0,e=e||0,s=s||0,n=n||0,this.x=t,this.y=e,this.width=s,this.height=n,this.type=i.ELLIPSE},i.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 i.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 i.Ellipse(this.x,this.y,this.width,this.height):t.setTo(this.x,this.y,this.width,this.height),t},contains:function(t,e){return i.Ellipse.contains(this,t,e)},random:function(t){void 0===t&&(t=new i.Point);var e=Math.random()*Math.PI*2,s=Math.random();return t.x=Math.sqrt(s)*Math.cos(e),t.y=Math.sqrt(s)*Math.sin(e),t.x=this.x+t.x*this.width/2,t.y=this.y+t.y*this.height/2,t},toString:function(){return"[{Phaser.Ellipse (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")}]"}},i.Ellipse.prototype.constructor=i.Ellipse,Object.defineProperty(i.Ellipse.prototype,"left",{get:function(){return this.x},set:function(t){this.x=t}}),Object.defineProperty(i.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 i.Point);var e=Math.random();return t.x=this.start.x+e*(this.end.x-this.start.x),t.y=this.start.y+e*(this.end.y-this.start.y),t},coordinatesOnLine:function(t,e){void 0===t&&(t=1),void 0===e&&(e=[]);var i=Math.round(this.start.x),s=Math.round(this.start.y),n=Math.round(this.end.x),r=Math.round(this.end.y),o=Math.abs(n-i),a=Math.abs(r-s),h=i-a&&(u-=a,i+=h),d=0&&m<=1&&g>=0&&g<=1?o:null}return o},i.Line.intersects=function(t,e,s,n){return i.Line.intersectsPoints(t.start,t.end,e.start,e.end,s,n)},i.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,u=0;if(i>=o&&i<=h&&s>=a&&s<=l||n>=o&&n<=h&&r>=a&&r<=l)return!0;if(i=o){if((u=s+(r-s)*(o-i)/(n-i))>a&&u<=l)return!0}else if(i>h&&n<=h&&(u=s+(r-s)*(h-i)/(n-i))>=a&&u<=l)return!0;if(s=a){if((u=i+(n-i)*(a-s)/(r-s))>=o&&u<=h)return!0}else if(s>l&&r<=l&&(u=i+(n-i)*(l-s)/(r-s))>=o&&u<=h)return!0;return!1},i.Line.reflect=function(t,e){return 2*e.normalAngle-3.141592653589793-t.angle},i.Matrix=function(t,e,s,n,r,o){void 0!==t&&null!==t||(t=1),void 0!==e&&null!==e||(e=0),void 0!==s&&null!==s||(s=0),void 0!==n&&null!==n||(n=1),void 0!==r&&null!==r||(r=0),void 0!==o&&null!==o||(o=0),this.a=t,this.b=e,this.c=s,this.d=n,this.tx=r,this.ty=o,this.type=i.MATRIX},i.Matrix.prototype={fromArray:function(t){return this.setTo(t[0],t[1],t[3],t[4],t[2],t[5])},setTo:function(t,e,i,s,n,r){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=r,this},clone:function(t){return void 0===t||null===t?t=new i.Matrix(this.a,this.b,this.c,this.d,this.tx,this.ty):(t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty),t},copyTo:function(t){return t.copyFrom(this),t},copyFrom:function(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this},toArray:function(t,e){return void 0===e&&(e=new Float32Array(9)),t?(e[0]=this.a,e[1]=this.b,e[2]=0,e[3]=this.c,e[4]=this.d,e[5]=0,e[6]=this.tx,e[7]=this.ty,e[8]=1):(e[0]=this.a,e[1]=this.c,e[2]=this.tx,e[3]=this.b,e[4]=this.d,e[5]=this.ty,e[6]=0,e[7]=0,e[8]=1),e},apply:function(t,e){return void 0===e&&(e=new i.Point),e.x=this.a*t.x+this.c*t.y+this.tx,e.y=this.b*t.x+this.d*t.y+this.ty,e},applyInverse:function(t,e){void 0===e&&(e=new i.Point);var s=1/(this.a*this.d+this.c*-this.b),n=t.x,r=t.y;return e.x=this.d*s*n+-this.c*s*r+(this.ty*this.c-this.tx*this.d)*s,e.y=this.a*s*r+-this.b*s*n+(-this.ty*this.a+this.tx*this.b)*s,e},translate:function(t,e){return this.tx+=t,this.ty+=e,this},scale:function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},rotate:function(t){var e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,r=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=r*e-this.ty*i,this.ty=r*i+this.ty*e,this},append:function(t){var e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this},identity:function(){return this.setTo(1,0,0,1,0,0)}},i.identityMatrix=new i.Matrix,i.Point=function(t,e){t=t||0,e=e||0,this.x=t,this.y=e,this.type=i.POINT},i.Point.prototype={copyFrom:function(t){return this.setTo(t.x,t.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(t,e){return i.Point.set(this,t,e)},set:function(t,e){return i.Point.set(this,t,e)},setToPolar:function(t,e,s){return null==e&&(e=1),s&&(t=i.Math.degToRad(t)),this.setTo(Math.cos(t)*e,Math.sin(t)*e)},add:function(t,e){return this.x+=t,this.y+=e,this},subtract:function(t,e){return this.x-=t,this.y-=e,this},multiply:function(t,e){return this.x*=t,this.y*=e,this},divide:function(t,e){return this.x/=t,this.y/=e,this},clampX:function(t,e){return this.x=i.Math.clamp(this.x,t,e),this},clampY:function(t,e){return this.y=i.Math.clamp(this.y,t,e),this},clamp:function(t,e){return this.x=i.Math.clamp(this.x,t,e),this.y=i.Math.clamp(this.y,t,e),this},clone:function(t){return void 0===t||null===t?t=new i.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 i.Point.distance(this,t,e)},equals:function(t){return t.x===this.x&&t.y===this.y},angle:function(t,e){return void 0===e&&(e=!1),e?i.Math.radToDeg(Math.atan2(t.y-this.y,t.x-this.x)):Math.atan2(t.y-this.y,t.x-this.x)},rotate:function(t,e,s,n,r){return i.Point.rotate(this,t,e,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},isZero:function(){return 0===this.x&&0===this.y},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},perp:function(){return this.setTo(-this.y,this.x)},rperp:function(){return this.setTo(this.y,-this.x)},normalRightHand:function(){return this.setTo(-1*this.y,this.x)},floor:function(){return this.setTo(Math.floor(this.x),Math.floor(this.y))},ceil:function(){return this.setTo(Math.ceil(this.x),Math.ceil(this.y))},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}},i.Point.prototype.constructor=i.Point,i.Point.add=function(t,e,s){return void 0===s&&(s=new i.Point),s.x=t.x+e.x,s.y=t.y+e.y,s},i.Point.subtract=function(t,e,s){return void 0===s&&(s=new i.Point),s.x=t.x-e.x,s.y=t.y-e.y,s},i.Point.multiply=function(t,e,s){return void 0===s&&(s=new i.Point),s.x=t.x*e.x,s.y=t.y*e.y,s},i.Point.divide=function(t,e,s){return void 0===s&&(s=new i.Point),s.x=t.x/e.x,s.y=t.y/e.y,s},i.Point.equals=function(t,e){return t.x===e.x&&t.y===e.y},i.Point.angle=function(t,e){return Math.atan2(t.y-e.y,t.x-e.x)},i.Point.negative=function(t,e){return void 0===e&&(e=new i.Point),e.setTo(-t.x,-t.y)},i.Point.multiplyAdd=function(t,e,s,n){return void 0===n&&(n=new i.Point),n.setTo(t.x+e.x*s,t.y+e.y*s)},i.Point.interpolate=function(t,e,s,n){return void 0===n&&(n=new i.Point),n.setTo(t.x+(e.x-t.x)*s,t.y+(e.y-t.y)*s)},i.Point.perp=function(t,e){return void 0===e&&(e=new i.Point),e.setTo(-t.y,t.x)},i.Point.rperp=function(t,e){return void 0===e&&(e=new i.Point),e.setTo(t.y,-t.x)},i.Point.distance=function(t,e,s){var n=i.Math.distance(t.x,t.y,e.x,e.y);return s?Math.round(n):n},i.Point.project=function(t,e,s){void 0===s&&(s=new i.Point);var n=t.dot(e)/e.getMagnitudeSq();return 0!==n&&s.setTo(n*e.x,n*e.y),s},i.Point.projectUnit=function(t,e,s){void 0===s&&(s=new i.Point);var n=t.dot(e);return 0!==n&&s.setTo(n*e.x,n*e.y),s},i.Point.normalRightHand=function(t,e){return void 0===e&&(e=new i.Point),e.setTo(-1*t.y,t.x)},i.Point.normalize=function(t,e){void 0===e&&(e=new i.Point);var s=t.getMagnitude();return 0!==s&&e.setTo(t.x/s,t.y/s),e},i.Point.rotate=function(t,e,s,n,r,o){if(r&&(n=i.Math.degToRad(n)),void 0===o){t.subtract(e,s);var a=Math.sin(n),h=Math.cos(n),l=h*t.x-a*t.y,u=a*t.x+h*t.y;t.x=l+e,t.y=u+s}else{var c=n+Math.atan2(t.y-s,t.x-e);t.x=e+o*Math.cos(c),t.y=s+o*Math.sin(c)}return t},i.Point.centroid=function(t,e){if(void 0===e&&(e=new i.Point),"[object Array]"!==Object.prototype.toString.call(t))throw new Error("Phaser.Point. Parameter 'points' must be an array");var s=t.length;if(s<1)throw new Error("Phaser.Point. Parameter 'points' array must not be empty");if(1===s)return e.copyFrom(t[0]),e;for(var n=0;n0&&this.setTo.apply(this,arguments),this.closed=!0,this.flattened=!1,this.type=i.POLYGON},i.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(i.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(i.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}}),Object.defineProperty(i.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}}),Object.defineProperty(i.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(t){this.x=t-this.halfWidth}}),Object.defineProperty(i.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(t){this.y=t-this.halfHeight}}),Object.defineProperty(i.Rectangle.prototype,"randomX",{get:function(){return this.x+Math.random()*this.width}}),Object.defineProperty(i.Rectangle.prototype,"randomY",{get:function(){return this.y+Math.random()*this.height}}),Object.defineProperty(i.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(i.Rectangle.prototype,"topLeft",{get:function(){return new i.Point(this.x,this.y)},set:function(t){this.x=t.x,this.y=t.y}}),Object.defineProperty(i.Rectangle.prototype,"topRight",{get:function(){return new i.Point(this.x+this.width,this.y)},set:function(t){this.right=t.x,this.y=t.y}}),Object.defineProperty(i.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(t){!0===t&&this.setTo(0,0,0,0)}}),i.Rectangle.prototype.constructor=i.Rectangle,i.Rectangle.inflate=function(t,e,i){return t.x-=e,t.width+=2*e,t.y-=i,t.height+=2*i,t},i.Rectangle.inflatePoint=function(t,e){return i.Rectangle.inflate(t,e.x,e.y)},i.Rectangle.size=function(t,e){return void 0===e||null===e?e=new i.Point(t.width,t.height):e.setTo(t.width,t.height),e},i.Rectangle.clone=function(t,e){return void 0===e||null===e?e=new i.Rectangle(t.x,t.y,t.width,t.height):e.setTo(t.x,t.y,t.width,t.height),e},i.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)},i.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}},i.RoundedRectangle.prototype.constructor=i.RoundedRectangle,PIXI.RoundedRectangle=i.RoundedRectangle,i.Camera=function(t,e,s,n,r,o){this.game=t,this.world=t.world,this.id=0,this.view=new i.Rectangle(s,n,r,o),this.bounds=new i.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 i.Point(1,1),this.onShakeComplete=new i.Signal,this.onFlashComplete=new i.Signal,this.onFadeComplete=new i.Signal,this.fx=null,this._targetPosition=new i.Point,this._edge=0,this._position=new i.Point,this._shake={intensity:0,duration:0,horizontal:!1,vertical:!1,shakeBounds:!0,x:0,y:0},this._fxDuration=0,this._fxType=0},i.Camera.FOLLOW_LOCKON=0,i.Camera.FOLLOW_PLATFORMER=1,i.Camera.FOLLOW_TOPDOWN=2,i.Camera.FOLLOW_TOPDOWN_TIGHT=3,i.Camera.SHAKE_BOTH=4,i.Camera.SHAKE_HORIZONTAL=5,i.Camera.SHAKE_VERTICAL=6,i.Camera.ENABLE_FX=!0,i.Camera.prototype={boot:function(){this.displayObject=this.game.world,this.scale=this.game.world.scale,this.game.camera=this,i.Graphics&&i.Camera.ENABLE_FX&&(this.fx=new i.Graphics(this.game),this.game.stage.addChild(this.fx))},preUpdate:function(){this.totalInView=0},follow:function(t,e,s,n){void 0===e&&(e=i.Camera.FOLLOW_LOCKON),void 0===s&&(s=1),void 0===n&&(n=1),this.target=t,this.lerp.set(s,n);var r;switch(e){case i.Camera.FOLLOW_PLATFORMER:var o=this.width/8,a=this.height/3;this.deadzone=new i.Rectangle((this.width-o)/2,(this.height-a)/2-.25*a,o,a);break;case i.Camera.FOLLOW_TOPDOWN:r=Math.max(this.width,this.height)/4,this.deadzone=new i.Rectangle((this.width-r)/2,(this.height-r)/2,r,r);break;case i.Camera.FOLLOW_TOPDOWN_TIGHT:r=Math.max(this.width,this.height)/8,this.deadzone=new i.Rectangle((this.width-r)/2,(this.height-r)/2,r,r);break;case i.Camera.FOLLOW_LOCKON:default:this.deadzone=null}},unfollow:function(){this.target=null},focusOn:function(t){this.setPosition(Math.round(t.x-this.view.halfWidth),Math.round(t.y-this.view.halfHeight))},focusOnXY:function(t,e){this.setPosition(Math.round(t-this.view.halfWidth),Math.round(e-this.view.halfHeight))},shake:function(t,e,s,n,r){return void 0===t&&(t=.05),void 0===e&&(e=500),void 0===s&&(s=!0),void 0===n&&(n=i.Camera.SHAKE_BOTH),void 0===r&&(r=!0),!(!s&&this._shake.duration>0)&&(this._shake.intensity=t,this._shake.duration=e,this._shake.shakeBounds=r,this._shake.x=0,this._shake.y=0,this._shake.horizontal=n===i.Camera.SHAKE_BOTH||n===i.Camera.SHAKE_HORIZONTAL,this._shake.vertical=n===i.Camera.SHAKE_BOTH||n===i.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}},i.Camera.prototype.constructor=i.Camera,Object.defineProperty(i.Camera.prototype,"x",{get:function(){return this.view.x},set:function(t){this.view.x=t,this.bounds&&this.checkBounds()}}),Object.defineProperty(i.Camera.prototype,"y",{get:function(){return this.view.y},set:function(t){this.view.y=t,this.bounds&&this.checkBounds()}}),Object.defineProperty(i.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(i.Camera.prototype,"width",{get:function(){return this.view.width},set:function(t){this.view.width=t}}),Object.defineProperty(i.Camera.prototype,"height",{get:function(){return this.view.height},set:function(t){this.view.height=t}}),Object.defineProperty(i.Camera.prototype,"shakeIntensity",{get:function(){return this._shake.intensity},set:function(t){this._shake.intensity=t}}),i.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},i.State.prototype={init:function(){},preload:function(){},loadUpdate:function(){},loadRender:function(){},create:function(){},update:function(){},preRender:function(){},render:function(){},resize:function(){},paused:function(){},resumed:function(){},pauseUpdate:function(){},shutdown:function(){}},i.State.prototype.constructor=i.State,i.StateManager=function(t,e){this.game=t,this.states={},this._pendingState=null,void 0!==e&&null!==e&&(this._pendingState=e),this._clearWorld=!1,this._clearCache=!1,this._created=!1,this._args=[],this.current="",this.onStateChange=new i.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},i.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,s){void 0===s&&(s=!1);var n;return e instanceof i.State?n=e:"object"==typeof e?(n=e).game=this.game:"function"==typeof e&&(n=new e(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 a 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){this.states[t].game=this.game,this.states[t].add=this.game.add,this.states[t].make=this.game.make,this.states[t].camera=this.game.camera,this.states[t].cache=this.game.cache,this.states[t].input=this.game.input,this.states[t].load=this.game.load,this.states[t].math=this.game.math,this.states[t].sound=this.game.sound,this.states[t].scale=this.game.scale,this.states[t].state=this,this.states[t].stage=this.game.stage,this.states[t].time=this.game.time,this.states[t].tweens=this.game.tweens,this.states[t].world=this.game.world,this.states[t].particles=this.game.particles,this.states[t].rnd=this.game.rnd,this.states[t].physics=this.game.physics,this.states[t].key=t},unlink:function(t){this.states[t]&&(this.states[t].game=null,this.states[t].add=null,this.states[t].make=null,this.states[t].camera=null,this.states[t].cache=null,this.states[t].input=null,this.states[t].load=null,this.states[t].math=null,this.states[t].sound=null,this.states[t].scale=null,this.states[t].state=null,this.states[t].stage=null,this.states[t].time=null,this.states[t].tweens=null,this.states[t].world=null,this.states[t].particles=null,this.states[t].rnd=null,this.states[t].physics=null)},setCurrentState:function(t){this.callbackContext=this.states[t],this.link(t),this.onInitCallback=this.states[t].init||this.dummy,this.onPreloadCallback=this.states[t].preload||null,this.onLoadRenderCallback=this.states[t].loadRender||null,this.onLoadUpdateCallback=this.states[t].loadUpdate||null,this.onCreateCallback=this.states[t].create||null,this.onUpdateCallback=this.states[t].update||null,this.onPreRenderCallback=this.states[t].preRender||null,this.onRenderCallback=this.states[t].render||null,this.onResizeCallback=this.states[t].resize||null,this.onPausedCallback=this.states[t].paused||null,this.onResumedCallback=this.states[t].resumed||null,this.onPauseUpdateCallback=this.states[t].pauseUpdate||null,this.onShutDownCallback=this.states[t].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.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game),!1===this._created&&this.onCreateCallback?(this._created=!0,this.onCreateCallback.call(this.callbackContext,this.game)):this._created=!0},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)},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===i.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.onRenderCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null,this.game=null,this.states={},this._pendingState=null,this.current=""}},i.StateManager.prototype.constructor=i.StateManager,Object.defineProperty(i.StateManager.prototype,"created",{get:function(){return this._created}}),i.Signal=function(){},i.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,e,s,n,r){var o,a=this._indexOfListener(t,s);if(-1!==a){if((o=this._bindings[a]).isOnce()!==e)throw new Error("You cannot add"+(e?"":"Once")+"() then add"+(e?"Once":"")+"() the same listener without removing the relationship first.")}else o=new i.SignalBinding(this,t,e,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)},i.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)},i.Group.prototype.createMultiple=function(t,e,i,s){void 0===i&&(i=0),void 0===s&&(s=!1),Array.isArray(e)||(e=[e]),Array.isArray(i)||(i=[i]);var n=this,r=[];return e.forEach(function(e){i.forEach(function(i){for(var o=0;othis.children.length||-1===t&&-1===e)return!1;for(var a=new i.Rectangle(0,0,s,n),h=t*s,l=e*n,u=o;uthis.children.length-1&&(t=0),this.cursor)return this.cursorIndex=t,this.cursor=this.children[this.cursorIndex],this.cursor},i.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},i.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},i.Group.prototype.swap=function(t,e){this.swapChildren(t,e),this.updateZ()},i.Group.prototype.bringToTop=function(t){return t.parent===this&&this.getIndex(t)0&&(this.remove(t,!1,!0),this.addAt(t,0,!0)),t},i.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},i.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},i.Group.prototype.reverse=function(){this.children.reverse(),this.updateZ()},i.Group.prototype.getIndex=function(t){return this.children.indexOf(t)},i.Group.prototype.getByName=function(t){for(var e=0;e0))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},i.Group.prototype.checkProperty=function(t,e,s,n){if(void 0===n&&(n=!1),this!==t.parent)return!1;var r=i.Utils.getProperty(t,e);return!(void 0===r&&n||r!==s)},i.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)},i.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=0;o2){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()}},i.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},i.Group.prototype.iterate=function(t,e,s,n,r,o){if(0===this.children.length){if(s===i.Group.RETURN_TOTAL)return 0;if(s===i.Group.RETURN_ALL)return[]}var a=0;if(s===i.Group.RETURN_ALL)var h=[];for(var l=0;l0)return this.children[this.children.length-1]},i.Group.prototype.getBottom=function(){if(this.children.length>0)return this.children[0]},i.Group.prototype.getClosestTo=function(t,e,s){for(var n=Number.MAX_VALUE,r=0,o=null,a=0;an&&(!e||e.call(s,h,r))&&(n=r,o=h)}return o},i.Group.prototype.countLiving=function(){return this.iterate("alive",!0,i.Group.RETURN_TOTAL)},i.Group.prototype.countDead=function(){return this.iterate("alive",!1,i.Group.RETURN_TOTAL)},i.Group.prototype.getRandom=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.children.length),0===e?null:i.ArrayUtils.getRandomItem(this.children,t,e)},i.Group.prototype.getRandomExists=function(t,e){var i=this.getAll("exists",!0,t,e);return this.game.rnd.pick(i)},i.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 i.Group){do{t.add(this.children[0],e)}while(this.children.length>0);this.hash=[],this.cursor=null}return t},i.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}},i.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()}},i.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)},i.Group.prototype.shuffle=function(){i.ArrayUtils.shuffle(this.children),this.updateZ()},i.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(i.Group.prototype,"total",{get:function(){return this.iterate("exists",!0,i.Group.RETURN_TOTAL)}}),Object.defineProperty(i.Group.prototype,"length",{get:function(){return this.children.length}}),Object.defineProperty(i.Group.prototype,"angle",{get:function(){return i.Math.radToDeg(this.rotation)},set:function(t){this.rotation=i.Math.degToRad(t)}}),Object.defineProperty(i.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(i.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(i.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(i.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(i.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(i.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}}),i.World=function(t){i.Group.call(this,t,null,"__world",!1),this.bounds=new i.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)},i.World.prototype=Object.create(i.Group.prototype),i.World.prototype.constructor=i.World,i.World.prototype.boot=function(){this.camera=new i.Camera(this.game,0,0,0,this.game.width,this.game.height),this.game.stage.addChild(this),this.camera.boot()},i.World.prototype.stateChange=function(){this.x=0,this.y=0,this.camera.reset()},i.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()},i.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))},Object.defineProperty(i.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.updateRender(this.time.slowMotion*this.time.desiredFps);else{var e=1e3*this.time.slowMotion/this.time.desiredFps;this._deltaTime+=Math.max(Math.min(3*e,this.time.elapsed),0);var i=0;for(this.updatesThisFrame=Math.floor(this._deltaTime/e),this.forceSingleUpdate&&(this.updatesThisFrame=Math.min(1,this.updatesThisFrame));this._deltaTime>=e&&(this._deltaTime-=e,this.currentUpdateID=i,this.updateLogic(this.time.desiredFpsMult),i++,!this.forceSingleUpdate||1!==i);)this.time.refresh();i>this._lastCount?this._spiraling++:i=i.Input.MAX_POINTERS)return console.warn("Phaser.Input.addPointer: Maximum limit of "+i.Input.MAX_POINTERS+" pointers reached."),null;var t=this.pointers.length+1,e=new i.Pointer(this.game,t,i.PointerMode.TOUCH);return this.pointers.push(e),this["pointer"+t]=e,e},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+e.x=a&&this.game.camera.y+e.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}},i.DeviceButton.prototype.constructor=i.DeviceButton,Object.defineProperty(i.DeviceButton.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}}),i.Pointer=function(t,e,s){this.game=t,this.id=e,this.type=i.POINTER,this.exists=!0,this.identifier=0,this.pointerId=null,this.pointerMode=s||i.PointerMode.CURSOR|i.PointerMode.CONTACT,this.target=null,this.button=null,this.leftButton=new i.DeviceButton(this,i.Pointer.LEFT_BUTTON),this.middleButton=new i.DeviceButton(this,i.Pointer.MIDDLE_BUTTON),this.rightButton=new i.DeviceButton(this,i.Pointer.RIGHT_BUTTON),this.backButton=new i.DeviceButton(this,i.Pointer.BACK_BUTTON),this.forwardButton=new i.DeviceButton(this,i.Pointer.FORWARD_BUTTON),this.eraserButton=new i.DeviceButton(this,i.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 i.Point,this.positionDown=new i.Point,this.positionUp=new i.Point,this.circle=new i.Circle(0,0,44),this._clickTrampolines=null,this._trampolineTargetObject=null},i.Pointer.NO_BUTTON=0,i.Pointer.LEFT_BUTTON=1,i.Pointer.RIGHT_BUTTON=2,i.Pointer.MIDDLE_BUTTON=4,i.Pointer.BACK_BUTTON=8,i.Pointer.FORWARD_BUTTON=16,i.Pointer.ERASER_BUTTON=32,i.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){t===i.Mouse.LEFT_BUTTON&&this.leftButton.start(e),t===i.Mouse.RIGHT_BUTTON&&this.rightButton.start(e),t===i.Mouse.MIDDLE_BUTTON&&this.middleButton.start(e),t===i.Mouse.BACK_BUTTON&&this.backButton.start(e),t===i.Mouse.FORWARD_BUTTON&&this.forwardButton.start(e)},processButtonsUp:function(t,e){t===i.Mouse.LEFT_BUTTON&&this.leftButton.stop(e),t===i.Mouse.RIGHT_BUTTON&&this.rightButton.stop(e),t===i.Mouse.MIDDLE_BUTTON&&this.middleButton.stop(e),t===i.Mouse.BACK_BUTTON&&this.backButton.stop(e),t===i.Mouse.FORWARD_BUTTON&&this.forwardButton.stop(e)},processButtonsUpDown:function(t,e){var s="down"===e.type.toLowerCase().substr(-4),n="move"===e.type.toLowerCase().substr(-4);void 0!==t?(s&&1===t&&e.ctrlKey&&(t=2),this.leftButton.startStop(i.Pointer.LEFT_BUTTON&t,e),this.rightButton.startStop(i.Pointer.RIGHT_BUTTON&t,e),this.middleButton.startStop(i.Pointer.MIDDLE_BUTTON&t,e),this.backButton.startStop(i.Pointer.BACK_BUTTON&t,e),this.forwardButton.startStop(i.Pointer.FORWARD_BUTTON&t,e),this.eraserButton.startStop(i.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===i.Input.MOUSE_OVERRIDES_TOUCH||e.multiInputOverride===i.Input.MOUSE_TOUCH_COMBINE||e.multiInputOverride===i.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&&(t.interactiveItems.total>0&&this.processInteractiveObjects(!1),this.dirty=!1),!1===this._holdSent&&this.duration>=t.holdRate&&((t.multiInputOverride===i.Input.MOUSE_OVERRIDES_TOUCH||t.multiInputOverride===i.Input.MOUSE_TOUCH_COMBINE||t.multiInputOverride===i.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 s=this.game.input;if(!s.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&&s.mouse.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)*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===i.Input.MOUSE_OVERRIDES_TOUCH||s.multiInputOverride===i.Input.MOUSE_TOUCH_COMBINE||s.multiInputOverride===i.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,e);return null===this.targetObject||this.game.paused&&!this.targetObject.noPause||!0!==this.targetObject.isDragged?s.interactiveItems.total>0&&this.processInteractiveObjects(e):!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 e=this.game.input;{if(!this._stateReset||!this.withinGame)return this.timeUp=this.game.time.time,(e.multiInputOverride===i.Input.MOUSE_OVERRIDES_TOUCH||e.multiInputOverride===i.Input.MOUSE_TOUCH_COMBINE||e.multiInputOverride===i.Input.TOUCH_OVERRIDES_MOUSE&&0===e.totalActivePointers)&&(e.onUp.dispatch(this,t),this.duration>=0&&this.duration<=e.tapRate&&(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&&e.currentPointers--,e.interactiveItems.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=i.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 s=this._pointerData[t.id];if(!1===s.isOver||t.dirty){var n=!1===s.isOver;s.isOver=!0,s.isOut=!1,s.timeOver=this.game.time.time,s.x=t.x-this.sprite.x,s.y=t.y-this.sprite.y,this.useHandCursor&&!1===s.isDragged&&(this.game.canvas.style.cursor="pointer",this._setHandCursor=!0),!e&&n&&this.sprite&&this.sprite.events&&this.sprite.events.onInputOver$dispatch(this.sprite,t),this.sprite.parent&&this.sprite.parent.type===i.GROUP&&this.sprite.parent.onChildInputOver.dispatch(this.sprite,t)}}},_pointerOutHandler:function(t,e){if(null!==this.sprite){var s=this._pointerData[t.id];s.isOver=!1,s.isOut=!0,s.timeOut=this.game.time.time,this.useHandCursor&&!1===s.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.type===i.GROUP&&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.type===i.GROUP&&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 s=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,s),this.sprite&&this.sprite.parent&&this.sprite.parent.type===i.GROUP&&this.sprite.parent.onChildInputUp.dispatch(this.sprite,t,s),s&&(s=this.checkPointerOver(t))),e.isOver=s,!s&&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){if(void 0===e&&(e=!1),t.isUp)return this.stopDrag(t),!1;var i=this.globalToLocal(t),s=i.x+this._dragPoint.x+this.dragOffset.x,n=i.y+this._dragPoint.y+this.dragOffset.y;if(this.sprite.fixedToCamera)this.allowHorizontalDrag&&(this.sprite.cameraOffset.x=s-this.game.camera.x),this.allowVerticalDrag&&(this.sprite.cameraOffset.y=n-this.game.camera.y),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(this.sprite.cameraOffset.x=Math.round((this.sprite.cameraOffset.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.cameraOffset.y=Math.round((this.sprite.cameraOffset.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,this.snapPoint.set(this.sprite.cameraOffset.x,this.sprite.cameraOffset.y));else{var r=this.game.camera.x-this._pointerData[t.id].camX,o=this.game.camera.y-this._pointerData[t.id].camY;this.allowHorizontalDrag&&(this.sprite.x=s+r),this.allowVerticalDrag&&(this.sprite.y=n+o),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(this.sprite.x=Math.round((this.sprite.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.y=Math.round((this.sprite.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,this.snapPoint.set(this.sprite.x,this.sprite.y))}return this.sprite.events.onDragUpdate.dispatch(this.sprite,t,s,n,this.snapPoint,e),!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)))}},i.InputHandler.prototype.constructor=i.InputHandler,i.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 i.SinglePad(t,this),new i.SinglePad(t,this),new i.SinglePad(t,this),new i.SinglePad(t,this)]},i.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 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 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}},i.Component.InCamera=function(){},i.Component.InCamera.prototype={inCamera:{get:function(){return this.game.world.camera.view.intersects(this._bounds)}}},i.Component.InputEnabled=function(){},i.Component.InputEnabled.prototype={input:null,inputEnabled:{get:function(){return this.input&&this.input.enabled},set:function(t){t?null===this.input?(this.input=new i.InputHandler(this),this.input.start()):this.input&&!this.input.enabled&&this.input.start():this.input&&this.input.enabled&&this.input.stop()}}},i.Component.InWorld=function(){},i.Component.InWorld.preUpdate=function(){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},i.Component.InWorld.prototype={checkWorldBounds:!1,outOfBoundsKill:!1,outOfCameraBoundsKill:!1,_outOfBoundsFired:!1,inWorld:{get:function(){return this.game.world.bounds.intersects(this.getBounds())}}},i.Component.LifeSpan=function(){},i.Component.LifeSpan.preUpdate=function(){return!(this.lifespan>0&&(this.lifespan-=this.game.time.physicsElapsedMS,this.lifespan<=0))||(this.kill(),!1)},i.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}},i.Component.LoadTexture=function(){},i.Component.LoadTexture.prototype={customRender:!1,_frame:null,loadTexture:function(t,e,s){t===i.PENDING_ATLAS?(t=e,e=0):e=e||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;if(i.RenderTexture&&t instanceof i.RenderTexture)this.key=t.key,this.setTexture(t);else if(i.BitmapData&&t instanceof i.BitmapData)this.customRender=!0,this.setTexture(t.texture),r=n.hasFrameData(t.key,i.Cache.BITMAPDATA)?!this.animations.loadFrameData(n.getFrameData(t.key,i.Cache.BITMAPDATA),e):!this.animations.loadFrameData(t.frameData,0);else if(i.Video&&t instanceof i.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(i.Tilemap&&t instanceof i.TilemapLayer)this.setTexture(PIXI.Texture.fromCanvas(t.canvas));else if(t instanceof PIXI.Texture)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,e)}r&&(this._frame=i.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}}},i.Component.Overlap=function(){},i.Component.Overlap.prototype={overlap:function(t){return i.Rectangle.intersects(this.getBounds(),t.getBounds())}},i.Component.PhysicsBody=function(){},i.Component.PhysicsBody.preUpdate=function(){return 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))},i.Component.PhysicsBody.postUpdate=function(){this.exists&&this.body&&this.body.postUpdate()},i.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)}}},i.Component.Reset=function(){},i.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},i.Component.ScaleMinMax=function(){},i.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,e,s,n){void 0===e?e=s=n=t:void 0===s&&(s=n=e,e=t),null===t?this.scaleMin=null:this.scaleMin?this.scaleMin.set(t,e):this.scaleMin=new i.Point(t,e),null===s?this.scaleMax=null:this.scaleMax?this.scaleMax.set(s,n):this.scaleMax=new i.Point(s,n),null===this.scaleMin?this.transformCallback=null:(this.transformCallback=this.checkTransform,this.transformCallbackContext=this)}},i.Component.Smoothed=function(){},i.Component.Smoothed.prototype={smoothed:{get:function(){return!this.texture.baseTexture.scaleMode},set:function(t){t?this.texture&&(this.texture.baseTexture.scaleMode=0):this.texture&&(this.texture.baseTexture.scaleMode=1)}}},i.GameObjectFactory=function(t){this.game=t,this.world=this.game.world},i.GameObjectFactory.prototype={existing:function(t){return this.world.add(t)},weapon:function(t,e,s,n,r){var o=this.game.plugins.add(i.Weapon);return r&&(o.bulletClass=r),o.createBullets(t,e,s,n),o},image:function(t,e,s,n,r){return void 0===r&&(r=this.world),r.add(new i.Image(this.game,t,e,s,n))},sprite:function(t,e,i,s,n){return void 0===n&&(n=this.world),n.create(t,e,i,s)},creature:function(t,e,s,n,r){void 0===r&&(r=this.world);var o=new i.Creature(this.game,t,e,s,n);return r.add(o),o},tween:function(t){return this.game.tweens.create(t)},group:function(t,e,s,n,r){return new i.Group(this.game,t,e,s,n,r)},physicsGroup:function(t,e,s,n){return new i.Group(this.game,e,s,n,!0,t)},spriteBatch:function(t,e,s){return void 0===t&&(t=null),void 0===e&&(e="group"),void 0===s&&(s=!1),new i.SpriteBatch(this.game,t,e,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,e,s,n,r,o,a){return void 0===a&&(a=this.world),a.add(new i.TileSprite(this.game,t,e,s,n,r,o))},rope:function(t,e,s,n,r,o){return void 0===o&&(o=this.world),o.add(new i.Rope(this.game,t,e,s,n,r))},text:function(t,e,s,n,r){return void 0===r&&(r=this.world),r.add(new i.Text(this.game,t,e,s,n))},button:function(t,e,s,n,r,o,a,h,l,u){return void 0===u&&(u=this.world),u.add(new i.Button(this.game,t,e,s,n,r,o,a,h,l))},graphics:function(t,e,s){return void 0===s&&(s=this.world),s.add(new i.Graphics(this.game,t,e))},emitter:function(t,e,s){return this.game.particles.add(new i.Particles.Arcade.Emitter(this.game,t,e,s))},retroFont:function(t,e,s,n,r,o,a,h,l){return new i.RetroFont(this.game,t,e,s,n,r,o,a,h,l)},bitmapText:function(t,e,s,n,r,o){return void 0===o&&(o=this.world),o.add(new i.BitmapText(this.game,t,e,s,n,r))},tilemap:function(t,e,s,n,r){return new i.Tilemap(this.game,t,e,s,n,r)},renderTexture:function(t,e,s,n){void 0!==s&&""!==s||(s=this.game.rnd.uuid()),void 0===n&&(n=!1);var r=new i.RenderTexture(this.game,t,e,s);return n&&this.game.cache.addRenderTexture(s,r),r},video:function(t,e){return new i.Video(this.game,t,e)},bitmapData:function(t,e,s,n){void 0===n&&(n=!1),void 0!==s&&""!==s||(s=this.game.rnd.uuid());var r=new i.BitmapData(this.game,s,t,e);return n&&this.game.cache.addBitmapData(s,r),r},filter:function(t){var e=Array.prototype.slice.call(arguments,1);return(t=new i.Filter[t](this.game)).init.apply(t,e),t},plugin:function(t){return this.game.plugins.add(t)}},i.GameObjectFactory.prototype.constructor=i.GameObjectFactory,i.GameObjectCreator=function(t){this.game=t,this.world=this.game.world},i.GameObjectCreator.prototype={image:function(t,e,s,n){return new i.Image(this.game,t,e,s,n)},sprite:function(t,e,s,n){return new i.Sprite(this.game,t,e,s,n)},tween:function(t){return new i.Tween(t,this.game,this.game.tweens)},group:function(t,e,s,n,r){return new i.Group(this.game,t,e,s,n,r)},spriteBatch:function(t,e,s){return void 0===e&&(e="group"),void 0===s&&(s=!1),new i.SpriteBatch(this.game,t,e,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,e,s,n,r,o){return new i.TileSprite(this.game,t,e,s,n,r,o)},rope:function(t,e,s,n,r){return new i.Rope(this.game,t,e,s,n,r)},text:function(t,e,s,n){return new i.Text(this.game,t,e,s,n)},button:function(t,e,s,n,r,o,a,h,l){return new i.Button(this.game,t,e,s,n,r,o,a,h,l)},graphics:function(t,e){return new i.Graphics(this.game,t,e)},emitter:function(t,e,s){return new i.Particles.Arcade.Emitter(this.game,t,e,s)},retroFont:function(t,e,s,n,r,o,a,h,l){return new i.RetroFont(this.game,t,e,s,n,r,o,a,h,l)},bitmapText:function(t,e,s,n,r,o){return new i.BitmapText(this.game,t,e,s,n,r,o)},tilemap:function(t,e,s,n,r){return new i.Tilemap(this.game,t,e,s,n,r)},renderTexture:function(t,e,s,n){void 0!==s&&""!==s||(s=this.game.rnd.uuid()),void 0===n&&(n=!1);var r=new i.RenderTexture(this.game,t,e,s);return n&&this.game.cache.addRenderTexture(s,r),r},bitmapData:function(t,e,s,n){void 0===n&&(n=!1),void 0!==s&&""!==s||(s=this.game.rnd.uuid());var r=new i.BitmapData(this.game,s,t,e);return n&&this.game.cache.addBitmapData(s,r),r},filter:function(t){var e=Array.prototype.slice.call(arguments,1);return(t=new i.Filter[t](this.game)).init.apply(t,e),t}},i.GameObjectCreator.prototype.constructor=i.GameObjectCreator,i.Sprite=function(t,e,s,n,r){e=e||0,s=s||0,n=n||null,r=r||null,this.type=i.SPRITE,this.physicsType=i.SPRITE,PIXI.Sprite.call(this,i.Cache.DEFAULT),i.Component.Core.init.call(this,t,e,s,n,r)},i.Sprite.prototype=Object.create(PIXI.Sprite.prototype),i.Sprite.prototype.constructor=i.Sprite,i.Component.Core.install.call(i.Sprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),i.Sprite.prototype.preUpdatePhysics=i.Component.PhysicsBody.preUpdate,i.Sprite.prototype.preUpdateLifeSpan=i.Component.LifeSpan.preUpdate,i.Sprite.prototype.preUpdateInWorld=i.Component.InWorld.preUpdate,i.Sprite.prototype.preUpdateCore=i.Component.Core.preUpdate,i.Sprite.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},i.Image=function(t,e,s,n,r){e=e||0,s=s||0,n=n||null,r=r||null,this.type=i.IMAGE,PIXI.Sprite.call(this,i.Cache.DEFAULT),i.Component.Core.init.call(this,t,e,s,n,r)},i.Image.prototype=Object.create(PIXI.Sprite.prototype),i.Image.prototype.constructor=i.Image,i.Component.Core.install.call(i.Image.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Destroy","FixedToCamera","InputEnabled","LifeSpan","LoadTexture","Overlap","Reset","ScaleMinMax","Smoothed"]),i.Image.prototype.preUpdateLifeSpan=i.Component.LifeSpan.preUpdate,i.Image.prototype.preUpdateInWorld=i.Component.InWorld.preUpdate,i.Image.prototype.preUpdateCore=i.Component.Core.preUpdate,i.Image.prototype.preUpdate=function(){return!(!this.preUpdateInWorld()||!this.preUpdateLifeSpan())&&this.preUpdateCore()},i.Button=function(t,e,s,n,r,o,a,h,l,u){e=e||0,s=s||0,n=n||null,r=r||null,o=o||this,i.Image.call(this,t,e,s,n,h),this.type=i.BUTTON,this.physicsType=i.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 i.Signal,this.onInputOut=new i.Signal,this.onInputDown=new i.Signal,this.onInputUp=new i.Signal,this.onOverMouseOnly=!0,this.justReleasedPreventsOver=i.PointerMode.TOUCH,this.freezeFrames=!1,this.forceOut=!1,this.inputEnabled=!0,this.input.start(0,!0),this.input.useHandCursor=!0,this.setFrames(a,h,l,u),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),this.events.onRemovedFromWorld.add(this.removedFromWorld,this)},i.Button.prototype=Object.create(i.Image.prototype),i.Button.prototype.constructor=i.Button;return i.Button.prototype.clearFrames=function(){this.setFrames(null,null,null,null)},i.Button.prototype.removedFromWorld=function(){this.inputEnabled=!1},i.Button.prototype.setStateFrame=function(t,e,i){var s="_on"+t+"Frame";null!==e?(this[s]=e,i&&this.changeStateFrame(t)):this[s]=null},i.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)},i.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())},i.Button.prototype.setStateSound=function(t,e,s){var n="on"+t+"Sound",r="on"+t+"SoundMarker";e instanceof i.Sound||e instanceof i.AudioSprite?(this[n]=e,this[r]="string"==typeof s?s:""):(this[n]=null,this[r]="")},i.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},i.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)},i.Button.prototype.setOverSound=function(t,e){this.setStateSound("Over",t,e)},i.Button.prototype.setOutSound=function(t,e){this.setStateSound("Out",t,e)},i.Button.prototype.setDownSound=function(t,e){this.setStateSound("Down",t,e)},i.Button.prototype.setUpSound=function(t,e){this.setStateSound("Up",t,e)},i.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)))},i.Button.prototype.onInputOutHandler=function(t,e){this.changeStateFrame("Out"),this.playStateSound("Out"),this.onInputOut&&this.onInputOut.dispatch(this,e)},i.Button.prototype.onInputDownHandler=function(t,e){this.changeStateFrame("Down"),this.playStateSound("Down"),this.onInputDown&&this.onInputDown.dispatch(this,e)},i.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")))},i.SpriteBatch=function(t,e,s,n){void 0!==e&&null!==e||(e=t.world),i.Group.call(this,t,e,s,n),this.type=i.SPRITEBATCH,this.fastSpriteBatch=null,this.ready=!1},i.SpriteBatch.prototype=Object.create(i.Group.prototype),i.SpriteBatch.prototype.constructor=i.SpriteBatch,i.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())},i.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&&e>=0&&e<=this.height&&(i.Device.LITTLE_ENDIAN?this.pixels[e*this.width+t]=o<<24|r<<16|n<<8|s:this.pixels[e*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,e,s){s||(s=i.Color.createColor());var n=~~(t+e*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,e,s,n,r){return i.Color.unpackPixel(this.getPixel32(t,e),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 e=i.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{i.Color.unpackPixel(this.getPixel32(s,n),e),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===e.a&&!o);return e.x=s,e.y=n,e},getBounds:function(t){return void 0===t&&(t=new i.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,s,n,r,o,a,h,l,u,c,d,p,f,m,g,y){if(void 0!==t&&null!==t||(t=this),t instanceof i.RenderTexture&&(t=t.getCanvas()),this._image=t,t instanceof i.Sprite||t instanceof i.Image||t instanceof i.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 i.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 i.BitmapData)this._image=t.canvas;else if("string"==typeof t){if(null===(t=this.game.cache.getImage(t)))return;this._image=t}this._size.set(this._image.width,this._image.height)}if(void 0!==e&&null!==e||(e=0),void 0!==s&&null!==s||(s=0),n&&(this._size.x=n),r&&(this._size.y=r),void 0!==o&&null!==o||(o=e),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 u&&(this._rotate=u),"number"==typeof c&&(this._anchor.x=c),"number"==typeof d&&(this._anchor.y=d),"number"==typeof p&&(this._scale.x=p),"number"==typeof f&&(this._scale.y=f),"number"==typeof m&&(this._alpha.current=m),void 0===g&&(g=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)){var v=this.context;return this._alpha.prev=v.globalAlpha,v.save(),v.globalAlpha=this._alpha.current,g&&(this.op=g),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+e,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,e,s){if(void 0===e&&(e=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 i.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,e&&(this.op=e),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,e,s){if(t.hasOwnProperty("texture")&&this.copyTransform(t,e,s),t.type===i.GROUP&&t.exists)this.drawGroup(t,e,s);else if(t.hasOwnProperty("children")&&t.children.length>0)for(var n=0;ne.width&&(n=e.width);var r=this.context;return r.fillStyle=r.createPattern(e,s),this._circle=new i.Circle(t.start.x,t.start.y,e.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,e.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),i.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=u=t[0],l=c=t[1];for(var m=s;mu&&(u=d),p>c&&(c=p);f=Math.max(u-h,c-l)}return i.EarCut.earcutLinked(o,a,s,h,l,f),a},i.EarCut.linkedList=function(t,e,s,n,r){var o,a,h,l=0;for(o=e,a=s-n;o0)for(o=e;o=e;o-=n)h=i.EarCut.insertNode(o,t[o],t[o+1],h);return h},i.EarCut.filterPoints=function(t,e){if(!t)return t;e||(e=t);var s,n=t;do{if(s=!1,n.steiner||!i.EarCut.equals(n,n.next)&&0!==i.EarCut.area(n.prev,n,n.next))n=n.next;else{if(i.EarCut.removeNode(n),(n=e=n.prev)===n.next)return null;s=!0}}while(s||n!==e);return e},i.EarCut.earcutLinked=function(t,e,s,n,r,o,a){if(t){!a&&o&&i.EarCut.indexCurve(t,n,r,o);for(var h,l,u=t;t.prev!==t.next;)if(h=t.prev,l=t.next,o?i.EarCut.isEarHashed(t,n,r,o):i.EarCut.isEar(t))e.push(h.i/s),e.push(t.i/s),e.push(l.i/s),i.EarCut.removeNode(t),t=l.next,u=l.next;else if((t=l)===u){a?1===a?(t=i.EarCut.cureLocalIntersections(t,e,s),i.EarCut.earcutLinked(t,e,s,n,r,o,2)):2===a&&i.EarCut.splitEarcut(t,e,s,n,r,o):i.EarCut.earcutLinked(i.EarCut.filterPoints(t),e,s,n,r,o,1);break}}},i.EarCut.isEar=function(t){var e=t.prev,s=t,n=t.next;if(i.EarCut.area(e,s,n)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(i.EarCut.pointInTriangle(e.x,e.y,s.x,s.y,n.x,n.y,r.x,r.y)&&i.EarCut.area(r.prev,r,r.next)>=0)return!1;r=r.next}return!0},i.EarCut.isEarHashed=function(t,e,s,n){var r=t.prev,o=t,a=t.next;if(i.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,c=r.y>o.y?r.y>a.y?r.y:a.y:o.y>a.y?o.y:a.y,d=i.EarCut.zOrder(h,l,e,s,n),p=i.EarCut.zOrder(u,c,e,s,n),f=t.nextZ;f&&f.z<=p;){if(f!==t.prev&&f!==t.next&&i.EarCut.pointInTriangle(r.x,r.y,o.x,o.y,a.x,a.y,f.x,f.y)&&i.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&&i.EarCut.pointInTriangle(r.x,r.y,o.x,o.y,a.x,a.y,f.x,f.y)&&i.EarCut.area(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0},i.EarCut.cureLocalIntersections=function(t,e,s){var n=t;do{var r=n.prev,o=n.next.next;i.EarCut.intersects(r,n,n.next,o)&&i.EarCut.locallyInside(r,o)&&i.EarCut.locallyInside(o,r)&&(e.push(r.i/s),e.push(n.i/s),e.push(o.i/s),i.EarCut.removeNode(n),i.EarCut.removeNode(n.next),n=t=o),n=n.next}while(n!==t);return n},i.EarCut.splitEarcut=function(t,e,s,n,r,o){var a=t;do{for(var h=a.next.next;h!==a.prev;){if(a.i!==h.i&&i.EarCut.isValidDiagonal(a,h)){var l=i.EarCut.splitPolygon(a,h);return a=i.EarCut.filterPoints(a,a.next),l=i.EarCut.filterPoints(l,l.next),i.EarCut.earcutLinked(a,e,s,n,r,o),void i.EarCut.earcutLinked(l,e,s,n,r,o)}h=h.next}a=a.next}while(a!==t)},i.EarCut.eliminateHoles=function(t,e,s,n){var r,o,a,h,l,u=[];for(r=0,o=e.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&&i.EarCut.pointInTriangle(os.x)&&i.EarCut.locallyInside(n,t)&&(s=n,c=l),n=n.next;return s},i.EarCut.indexCurve=function(t,e,s,n){var r=t;do{null===r.z&&(r.z=i.EarCut.zOrder(r.x,r.y,e,s,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,i.EarCut.sortLinked(r)},i.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},i.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},i.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},i.EarCut.isValidDiagonal=function(t,e){return i.EarCut.equals(t,e)||t.next.i!==e.i&&t.prev.i!==e.i&&!i.EarCut.intersectsPolygon(t,e)&&i.EarCut.locallyInside(t,e)&&i.EarCut.locallyInside(e,t)&&i.EarCut.middleInside(t,e)},i.EarCut.area=function(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)},i.EarCut.equals=function(t,e){return t.x===e.x&&t.y===e.y},i.EarCut.intersects=function(t,e,s,n){return i.EarCut.area(t,e,s)>0!=i.EarCut.area(t,e,n)>0&&i.EarCut.area(s,n,t)>0!=i.EarCut.area(s,n,e)>0},i.EarCut.intersectsPolygon=function(t,e){var s=t;do{if(s.i!==t.i&&s.next.i!==t.i&&s.i!==e.i&&s.next.i!==e.i&&i.EarCut.intersects(s,s.next,t,e))return!0;s=s.next}while(s!==t);return!1},i.EarCut.locallyInside=function(t,e){return i.EarCut.area(t.prev,t,t.next)<0?i.EarCut.area(t,e,t.next)>=0&&i.EarCut.area(t,t.prev,e)>=0:i.EarCut.area(t,e,t.prev)<0||i.EarCut.area(t,t.next,e)<0},i.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},i.EarCut.splitPolygon=function(t,e){var s=new i.EarCut.Node(t.i,t.x,t.y),n=new i.EarCut.Node(e.i,e.x,e.y),r=t.next,o=e.prev;return t.next=e,e.prev=t,s.next=r,r.prev=s,n.next=s,s.prev=n,o.next=n,n.prev=o,n},i.EarCut.insertNode=function(t,e,s,n){var r=new i.EarCut.Node(t,e,s);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r},i.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)},i.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 s,n=e.gl,r=e.projection,o=e.offset,a=e.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===i.RECTANGLE?PIXI.WebGLGraphics.buildRectangle(a,o):a.type===i.CIRCLE||a.type===i.ELLIPSE?PIXI.WebGLGraphics.buildCircle(a,o):a.type===i.ROUNDEDRECTANGLE&&PIXI.WebGLGraphics.buildRoundedRectangle(a,o)),s.lastIndex++}for(n=0;n19600?(_=y-x,T=v-b,_/=M=Math.sqrt(_*_+T*T),T/=M,_*=F,T*=F,L.push(p-_,f-T),L.push(G,N,X,U),L.push(p+_,f+T),L.push(G,N,X,U),L.push(p-_,f-T),L.push(G,N,X,U),k++):(L.push(l,u),L.push(G,N,X,U),L.push(p-(l-p),f-(u-f)),L.push(G,N,X,U));for(c=n[2*(O-2)],d=n[2*(O-2)+1],p=n[2*(O-1)],y=-(d-(f=n[2*(O-1)+1])),v=c-p,y/=M=Math.sqrt(y*y+v*v),v/=M,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),I.push(D),s=0;sh?r:h,l=ou?o:u;s.push(a,l,h,l,h,u,a,u);var d=s.length/2;for(c=0;cP?P:S,e.beginPath(),e.moveTo(_,T+S),e.lineTo(_,T+C-S),e.quadraticCurveTo(_,T+C,_+S,T+C),e.lineTo(_+w-S,T+C),e.quadraticCurveTo(_+w,T+C,_+w,T+C-S),e.lineTo(_+w,T+S),e.quadraticCurveTo(_+w,T,_+w-S,T),e.lineTo(_+S,T),e.quadraticCurveTo(_,T,_,T+S),e.closePath(),(r.fillColor||0===r.fillColor)&&(e.globalAlpha=r.fillAlpha*s,e.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),e.fill()),r.lineWidth&&(e.globalAlpha=r.lineAlpha*s,e.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),e.stroke())}}},PIXI.CanvasGraphics.renderGraphicsMask=function(t,e){var s=t.graphicsData.length;if(0!==s){e.beginPath();for(var n=0;nC?C:w,e.moveTo(x,b+w),e.lineTo(x,b+T-w),e.quadraticCurveTo(x,b+T,x+w,b+T),e.lineTo(x+_-w,b+T),e.quadraticCurveTo(x+_,b+T,x+_,b+T-w),e.lineTo(x+_,b+w),e.quadraticCurveTo(x+_,b,x+_-w,b),e.lineTo(x+w,b),e.quadraticCurveTo(x,b,x,b+w),e.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}},i.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},i.GraphicsData.prototype.constructor=i.GraphicsData,i.GraphicsData.prototype.clone=function(){return new i.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.fill,this.shape)},i.Graphics=function(t,e,s){void 0===e&&(e=0),void 0===s&&(s=0),this.type=i.GRAPHICS,this.physicsType=i.SPRITE,this.anchor=new i.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 i.Rectangle(0,0,1,1),this.dirty=!0,this._boundsDirty=!1,this.webGLDirty=!1,this.cachedSpriteDirty=!1,i.Component.Core.init.call(this,t,e,s,"",null)},i.Graphics.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),i.Graphics.prototype.constructor=i.Graphics,i.Component.Core.install.call(i.Graphics.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),i.Graphics.prototype.preUpdatePhysics=i.Component.PhysicsBody.preUpdate,i.Graphics.prototype.preUpdateLifeSpan=i.Component.LifeSpan.preUpdate,i.Graphics.prototype.preUpdateInWorld=i.Component.InWorld.preUpdate,i.Graphics.prototype.preUpdateCore=i.Component.Core.preUpdate,i.Graphics.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},i.Graphics.prototype.postUpdate=function(){i.Component.PhysicsBody.postUpdate.call(this),i.Component.FixedToCamera.postUpdate.call(this),this._boundsDirty&&(this.updateLocalBounds(),this._boundsDirty=!1);for(var t=0;t0&&this.drawPolygon(s)}else this.drawPolygon(s)},i.Graphics.prototype.drawTriangles=function(t,e,s){void 0===s&&(s=!1);var n,r=new i.Point,o=new i.Point,a=new i.Point,h=[];if(e)if(t[0]instanceof i.Point)for(n=0;nu*a)}return this.dirty=!0,this._boundsDirty=!0,this},i.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,u=e+Math.sin(s)*i;r&&this.filling?this.moveTo(t,e):this.moveTo(l,u);for(var c=this.currentPath.shape.points,d=a/(2*h),p=2*d,f=Math.cos(d),m=Math.sin(d),g=h-1,y=g%1/g,v=0;v<=g;v++){var x=d+s+p*(v+y*v),b=Math.cos(x),_=-Math.sin(x);c.push((f*b+m*_)*i+t,(f*-_+m*b)*i+e)}return this.dirty=!0,this._boundsDirty=!0,this},i.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},i.Graphics.prototype.endFill=function(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this},i.Graphics.prototype.drawRect=function(t,e,s,n){return this.drawShape(new i.Rectangle(t,e,s,n)),this},i.Graphics.prototype.drawRoundedRect=function(t,e,s,n,r){return this.drawShape(new i.RoundedRectangle(t,e,s,n,r)),this},i.Graphics.prototype.drawCircle=function(t,e,s){return this.drawShape(new i.Circle(t,e,s)),this},i.Graphics.prototype.drawEllipse=function(t,e,s,n){return this.drawShape(new i.Ellipse(t,e,s,n)),this},i.Graphics.prototype.drawPolygon=function(t){t instanceof i.Polygon&&(t=t.points);var e=t;if(!Array.isArray(e)){e=new Array(arguments.length);for(var s=0;sT?g:T,T=v>T?v:T,T=b>T?b:T,w=y>w?y:w,w=x>w?x:w,w=_>w?_:w,this._bounds.x=C,this._bounds.width=T-C,this._bounds.y=S,this._bounds.height=w-S,this._currentBounds=this._bounds,this._currentBounds},i.Graphics.prototype.getLocalBounds=function(){var t=this.worldTransform;this.worldTransform=i.identityMatrix;for(var e=0;ee?a+l:e,s=hn?h+u:n;else if(p===i.CIRCLE)a=r.x,h=r.y,l=r.radius+f/2,u=r.radius+f/2,t=a-le?a+l:e,s=h-un?h+u:n;else if(p===i.ELLIPSE)a=r.x,h=r.y,l=r.width+f/2,u=r.height+f/2,t=a-le?a+l:e,s=h-un?h+u:n;else{o=r.points;for(var m=0;me?a+f:e,s=h-fn?h+f:n}}else t=0,e=0,s=0,n=0;var g=this.boundsPadding;this._localBounds.x=t-g,this._localBounds.width=e-t+2*g,this._localBounds.y=s-g,this._localBounds.height=n-s+2*g},i.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},i.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()},i.Graphics.prototype.destroyCachedSprite=function(){this._cachedSprite.texture.destroy(!0),this._cachedSprite=null},i.Graphics.prototype.drawShape=function(t){this.currentPath&&this.currentPath.shape.points.length<=2&&this.graphicsData.pop(),this.currentPath=null,t instanceof i.Polygon&&(t=t.clone()).flatten();var e=new i.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,t);return this.graphicsData.push(e),e.type===i.POLYGON&&(e.shape.closed=this.filling,this.currentPath=e),this.dirty=!0,this._boundsDirty=!0,e},Object.defineProperty(i.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}}),i.RenderTexture=function(t,e,s,n,r,o,a,h){if(void 0===e&&(e=100),void 0===s&&(s=100),void 0===n&&(n=""),void 0===r&&(r=i.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=i.RENDERTEXTURE,this._tempMatrix=new i.Matrix,this.width=e,this.height=s,this.resolution=o,this.frame=new i.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===i.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 i.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 i.Matrix,this._updateUvs()},i.RenderTexture.prototype=Object.create(PIXI.Texture.prototype),i.RenderTexture.prototype.constructor=i.RenderTexture,i.RenderTexture.prototype.renderXY=function(t,e,s,n){t.updateTransform(),this._tempMatrix.copyFrom(t.worldTransform),this._tempMatrix.tx=e,this._tempMatrix.ty=s,this.renderer.type===i.WEBGL?this._renderWebGL(t,this._tempMatrix,n):this._renderCanvas(t,this._tempMatrix,n)},i.RenderTexture.prototype.renderRawXY=function(t,e,s,n){this._tempMatrix.identity().translate(e,s),this.renderer.type===i.WEBGL?this._renderWebGL(t,this._tempMatrix,n):this._renderCanvas(t,this._tempMatrix,n)},i.RenderTexture.prototype.render=function(t,e,s){void 0===e||null===e?this._tempMatrix.copyFrom(t.worldTransform):this._tempMatrix.copyFrom(e),this.renderer.type===i.WEBGL?this._renderWebGL(t,this._tempMatrix,s):this._renderCanvas(t,this._tempMatrix,s)},i.RenderTexture.prototype.resize=function(t,e,s){t===this.width&&e===this.height||(this.valid=t>0&&e>0,this.width=t,this.height=e,this.frame.width=this.crop.width=t*this.resolution,this.frame.height=this.crop.height=e*this.resolution,s&&(this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution),this.renderer.type===i.WEBGL&&(this.projection.x=this.width/2,this.projection.y=-this.height/2),this.valid&&this.textureBuffer.resize(this.width,this.height))},i.RenderTexture.prototype.clear=function(){this.valid&&(this.renderer.type===i.WEBGL&&this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer),this.textureBuffer.clear())},i.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 u=0,c=0;c0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.measureLine(h[c]):Math.ceil(this.context.measureText(h[c]).width),c>0&&(u+=i[c-1]),l=u+d}else for(c=0;c0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?l+=this.measureLine(h[c]):l+=Math.ceil(this.context.measureText(h[c]).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,m=this._lineSpacing;m<0&&Math.abs(m)>p&&(m=-p),0!==m&&(f+=m>0?m*e.length:m*(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 g,y;for(this._charCount=0,a=0;a0&&(y+=m*a),"right"===this.style.align?g+=n-s[a]:"center"===this.style.align&&(g+=(n-s[a])/2),this.autoRound&&(g=Math.round(g),y=Math.round(y)),this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.updateLine(e[a],g,y):(this.style.stroke&&this.style.strokeThickness&&(this.updateShadow(this.style.shadowStroke),0===i?this.context.strokeText(e[a],g,y):this.renderTabLine(e[a],g,y,!1)),this.style.fill&&(this.updateShadow(this.style.shadowFill),0===i?this.context.fillText(e[a],g,y):this.renderTabLine(e[a],g,y,!0)));this.updateTexture(),this.dirty=!1},i.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)},i.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++}},i.Text.prototype.clearColors=function(){return this.colors=[],this.strokeColors=[],this.dirty=!0,this},i.Text.prototype.clearFontValues=function(){return this.fontStyles=[],this.fontWeights=[],this.dirty=!0,this},i.Text.prototype.addColor=function(t,e){return this.colors[e]=t,this.dirty=!0,this},i.Text.prototype.addStrokeColor=function(t,e){return this.strokeColors[e]=t,this.dirty=!0,this},i.Text.prototype.addFontStyle=function(t,e){return this.fontStyles[e]=t,this.dirty=!0,this},i.Text.prototype.addFontWeight=function(t,e){return this.fontWeights[e]=t,this.dirty=!0,this},i.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)/)},i.Text.prototype.runWordWrap=function(t){return this.useAdvancedWrap?this.advancedWordWrap(t):this.basicWordWrap(t)},i.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===c){for(var m=p;m.length&&(m=m.slice(0,-1),!((f=e.measureText(m).width)<=l)););if(!m.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");var g=d.substr(m.length);u[c]=g,h+=m}var y=u[c].length?c:c+1,v=u.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,"")},i.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},i.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()},i.Text.prototype._renderWebGL=function(t){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderWebGL.call(this,t)},i.Text.prototype._renderCanvas=function(t){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderCanvas.call(this,t)},i.Text.prototype.determineFontProperties=function(t){var e=i.Text.fontPropertiesCache[t];if(!e){e={};var s=i.Text.fontPropertiesCanvas,n=i.Text.fontPropertiesContext;n.font=t;var r=Math.ceil(n.measureText("|MÉq").width),o=Math.ceil(n.measureText("|MÉq").width),a=2*o;if(o=1.4*o|0,s.width=r,s.height=a,n.fillStyle="#f00",n.fillRect(0,0,r,a),n.font=t,n.textBaseline="alphabetic",n.fillStyle="#000",n.fillText("|MÉq",0,o),!n.getImageData(0,0,r,a))return e.ascent=o,e.descent=o+6,e.fontSize=e.ascent+e.descent,i.Text.fontPropertiesCache[t]=e,e;var h,l,u=n.getImageData(0,0,r,a).data,c=u.length,d=4*r,p=0,f=!1;for(h=0;ho;h--){for(l=0;l0?this._maxWidth:null,l=[],u=0;u=h&&r>-1)return{width:o||n,text:i.substr(0,u-(u-r)),end:c,chars:l};n+=(p.xAdvance+m)*e,l.push(s+(p.xOffset+m)*e),s+=(p.xAdvance+m)*e,a=d}return{width:n,text:i,end:c,chars:l}},i.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=u.width),n+=t.lineHeight*i,e=e.substr(u.text.length+1)}while(!1===u.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(i.BitmapText.prototype,"text",{get:function(){return this._text},set:function(t){t!==this._text&&(this._text=t.toString()||"",this.updateText())}}),Object.defineProperty(i.BitmapText.prototype,"maxWidth",{get:function(){return this._maxWidth},set:function(t){t!==this._maxWidth&&(this._maxWidth=t,this.updateText())}}),Object.defineProperty(i.BitmapText.prototype,"smoothed",{get:function(){return!this._data.base.scaleMode},set:function(t){this._data.base.scaleMode=t?0:1}}),i.RetroFont=function(t,e,s,n,r,o,a,h,l,u){if(!t.cache.checkImageKey(e))return!1;void 0!==o&&null!==o||(o=t.cache.getImage(e).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=u||0,this.align="left",this.multiLine=!1,this.autoUpperCase=!0,this.customSpacingX=0,this.customSpacingY=0,this.fixedWidth=0,this.fontSet=t.cache.getImage(e),this._text="",this.grabData=[],this.frameData=new i.FrameData;for(var c=this.offsetX,d=this.offsetY,p=0,f=0;f?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",i.RetroFont.TEXT_SET2=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",i.RetroFont.TEXT_SET3="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",i.RetroFont.TEXT_SET4="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",i.RetroFont.TEXT_SET5="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",i.RetroFont.TEXT_SET6="ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",i.RetroFont.TEXT_SET7="AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",i.RetroFont.TEXT_SET8="0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",i.RetroFont.TEXT_SET9="ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",i.RetroFont.TEXT_SET10="ABCDEFGHIJKLMNOPQRSTUVWXYZ",i.RetroFont.TEXT_SET11="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789",i.RetroFont.prototype.setFixedWidth=function(t,e){void 0===e&&(e="left"),this.fixedWidth=t,this.align=e},i.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)},i.RetroFont.prototype.buildRetroFontText=function(){var t=0,e=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===i.RetroFont.ALIGN_RIGHT?t=this.width-this._text.length*(this.characterWidth+this.customSpacingX):this.align===i.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},i.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},i.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},i.RetroFont.prototype.removeUnsupportedCharacters=function(t){for(var e="",i=0;i=0||!t&&"\n"===s)&&(e=e.concat(s))}return e},i.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(i.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(i.RetroFont.prototype,"smoothed",{get:function(){return this.stamp.smoothed},set:function(t){this.stamp.smoothed=t,this.buildRetroFontText()}}),i.Rope=function(t,e,s,n,r,o){this.points=[],this.points=o,this._hasUpdateAnimation=!1,this._updateAnimationCallback=null,e=e||0,s=s||0,n=n||null,r=r||null,this.type=i.ROPE,this.points=o,PIXI.DisplayObjectContainer.call(this),this.texture=i.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=i.Rope.TRIANGLE_STRIP,i.Component.Core.init.call(this,t,e,s,n,r),this.refresh()},i.Rope.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),i.Rope.prototype.constructor=i.Rope,i.Component.Core.install.call(i.Rope.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),i.Rope.prototype.preUpdatePhysics=i.Component.PhysicsBody.preUpdate,i.Rope.prototype.preUpdateLifeSpan=i.Component.LifeSpan.preUpdate,i.Rope.prototype.preUpdateInWorld=i.Component.InWorld.preUpdate,i.Rope.prototype.preUpdateCore=i.Component.Core.preUpdate,i.Rope.TRIANGLE_STRIP=0,i.Rope.TRIANGLES=1,i.Rope.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},i.Rope.prototype.update=function(){this._hasUpdateAnimation&&this.updateAnimation.call(this)},i.Rope.prototype.reset=function(t,e){return i.Component.Reset.prototype.reset.call(this,t,e),this},i.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)}},i.Rope.prototype.setTexture=function(t){this.texture=t},i.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())},i.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)},i.Rope.prototype._renderStrip=function(t){var e=t.gl,s=t.projection,n=t.offset,r=t.shaderManager.stripShader,o=this.drawMode===i.Rope.TRIANGLE_STRIP?e.TRIANGLE_STRIP:e.TRIANGLES;t.blendModeManager.setBlendMode(this.blendMode),e.uniformMatrix3fv(r.translationMatrix,!1,this.worldTransform.toArray(!0)),e.uniform2f(r.projectionVector,s.x,-s.y),e.uniform2f(r.offsetVector,-n.x,-n.y),e.uniform1f(r.alpha,this.worldAlpha),this.dirty?(this.dirty=!1,e.bindBuffer(e.ARRAY_BUFFER,this._vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertices,e.STATIC_DRAW),e.vertexAttribPointer(r.aVertexPosition,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this._uvBuffer),e.bufferData(e.ARRAY_BUFFER,this.uvs,e.STATIC_DRAW),e.vertexAttribPointer(r.aTextureCoord,2,e.FLOAT,!1,0,0),e.activeTexture(e.TEXTURE0),this.texture.baseTexture._dirty[e.id]?t.renderer.updateTexture(this.texture.baseTexture):e.bindTexture(e.TEXTURE_2D,this.texture.baseTexture._glTextures[e.id]),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,e.STATIC_DRAW)):(e.bindBuffer(e.ARRAY_BUFFER,this._vertexBuffer),e.bufferSubData(e.ARRAY_BUFFER,0,this.vertices),e.vertexAttribPointer(r.aVertexPosition,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this._uvBuffer),e.vertexAttribPointer(r.aTextureCoord,2,e.FLOAT,!1,0,0),e.activeTexture(e.TEXTURE0),this.texture.baseTexture._dirty[e.id]?t.renderer.updateTexture(this.texture.baseTexture):e.bindTexture(e.TEXTURE_2D,this.texture.baseTexture._glTextures[e.id]),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._indexBuffer)),e.drawElements(o,this.indices.length,e.UNSIGNED_SHORT,0)},i.Rope.prototype._renderCanvas=function(t){var e=t.context,s=this.worldTransform,n=s.tx*t.resolution+t.shakeX,r=s.ty*t.resolution+t.shakeY;t.roundPixels?e.setTransform(s.a,s.b,s.c,s.d,0|n,0|r):e.setTransform(s.a,s.b,s.c,s.d,n,r),this.drawMode===i.Rope.TRIANGLE_STRIP?this._renderCanvasTriangleStrip(e):this._renderCanvasTriangles(e)},i.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,T=this.canvasPadding/this.worldTransform.d,w=(l+u+c)/3,C=(d+p+f)/3,S=l-w,P=d-C,E=Math.sqrt(S*S+P*P);l=w+S/E*(E+_),d=C+P/E*(E+T),P=p-C,u=w+(S=u-w)/(E=Math.sqrt(S*S+P*P))*(E+_),p=C+P/E*(E+T),P=f-C,c=w+(S=c-w)/(E=Math.sqrt(S*S+P*P))*(E+_),f=C+P/E*(E+T)}t.save(),t.beginPath(),t.moveTo(l,d),t.lineTo(u,p),t.lineTo(c,f),t.closePath(),t.clip();var A=m*x+v*y+g*b-x*y-v*g-m*b,R=l*x+v*c+u*b-x*c-v*u-l*b,M=m*u+l*y+g*c-u*y-l*g-m*c,L=m*x*c+v*u*y+l*g*b-l*x*y-v*g*c-m*u*b,I=d*x+v*f+p*b-x*f-v*p-d*b,O=m*p+d*y+g*f-p*y-d*g-m*f,k=m*x*f+v*p*y+d*g*b-d*x*y-v*g*f-m*p*b;t.transform(R/A,I/A,M/A,O/A,L/A,k/A),t.drawImage(o,0,0),t.restore()},i.Rope.prototype.renderStripFlat=function(t){var e=this.context,i=t.vertices,s=i.length/2;this.count++,e.beginPath();for(var n=1;nh?g:h,l=y>l?y:l}if(u===-1/0||l===1/0)return PIXI.EmptyRectangle;var v=this._bounds;return v.x=u,v.width=h-u,v.y=c,v.height=l-c,this._currentBounds=v,v},Object.defineProperty(i.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(i.Rope.prototype,"segments",{get:function(){for(var t,e,s,n,r,o,a,h,l=[],u=0;u(_=y>(_=m>(_=p>_?p:_)?m:_)?y:_)?x:_,T=b>(T=v>(T=g>(T=f>T?f:T)?g:T)?v:T)?b:T;var S=this._bounds;return S.x=w,S.width=_-w,S.y=C,S.height=T-C,this._currentBounds=S,S},Object.defineProperty(i.TileSprite.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t}}),Object.defineProperty(i.TileSprite.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t}}),i.CanvasPool={create:function(t,e,s){var n,r=i.CanvasPool.getFirst();if(-1===r){var o={parent:t,canvas:document.createElement("canvas")};i.CanvasPool.pool.push(o),n=o.canvas}else i.CanvasPool.pool[r].parent=t,n=i.CanvasPool.pool[r].canvas;return void 0!==e&&(n.width=e,n.height=s),n},getFirst:function(){for(var t=i.CanvasPool.pool,e=0;e=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&&e(),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=function(){try{var t=document.createElement("canvas");return t.screencanvas=!1,!!window.WebGLRenderingContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))}catch(t){return!1}}(),s.webGL=!!s.webGL,s.worker=!!window.Worker,s.pointerLock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document,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=i.CanvasPool.create(this,6,1),e=t.getContext("2d");e.fillStyle="rgba(10, 20, 30, 0.5)",e.fillRect(0,0,1,1);var n=e.getImageData(0,0,1,1);if(n){e.putImageData(n,1,0);var r=e.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]}e.globalCompositeOperation="multiply",s.canUseMultiply="multiply"===e.globalCompositeOperation,i.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"))},i.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))))))},i.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)))},i.Device.needsTouchUnlock=function(){return!!(!this.cocoonJS&&(this.iOS||this.android)||window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock)},i.Device.isConsoleOpen=function(){return console.warn("Phaser.Device.isConsoleOpen is deprecated and will be removed."),!1},i.Device.isAndroidStockBrowser=function(){var t=window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]+)/);return t&&t[1]<537},i.Canvas={create:function(t,e,s,n,r){e=e||256,s=s||256;var o=r?document.createElement("canvas"):i.CanvasPool.create(t,e,s);return"string"==typeof n&&""!==n&&(o.id=n),o.width=e,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,e){var s=i.Canvas.getSmoothingPrefix(t);return s&&(t[s]=e),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 e=i.Canvas.getSmoothingPrefix(t);if(e)return t[e]},setImageRenderingCrisp:function(t){for(var e=["optimizeSpeed","crisp-edges","-moz-crisp-edges","-webkit-optimize-contrast","optimize-contrast","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=i.Math.PI2-s?t=e:(Math.abs(e-t)>Math.PI&&(et?t+=s:e=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}},i.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)},i.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(",")}},i.RandomDataGenerator.prototype.constructor=i.RandomDataGenerator,i.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)},i.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 i.QuadTree(this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[1]=new i.QuadTree(this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[2]=new i.QuadTree(this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[3]=new i.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 i.Rectangle)var e=this.objects,s=this.getIndex(t);else{if(!t.body)return this._empty;var e=this.objects,s=this.getIndex(t.body)}return this.nodes[0]&&(e=-1!==s?e.concat(this.nodes[s].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}},i.QuadTree.prototype.constructor=i.QuadTree,i.Net=function(t){this.game=t},i.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," "))}},i.Net.prototype.constructor=i.Net,i.TweenManager=function(t){this.game=t,this.frameBased=!1,this._tweens=[],this._add=[],this.easeMap={Power0:i.Easing.Power0,Power1:i.Easing.Power1,Power2:i.Easing.Power2,Power3:i.Easing.Power3,Power4:i.Easing.Power4,Linear:i.Easing.Linear.None,Quad:i.Easing.Quadratic.Out,Cubic:i.Easing.Cubic.Out,Quart:i.Easing.Quartic.Out,Quint:i.Easing.Quintic.Out,Sine:i.Easing.Sinusoidal.Out,Expo:i.Easing.Exponential.Out,Circ:i.Easing.Circular.Out,Elastic:i.Easing.Elastic.Out,Back:i.Easing.Back.Out,Bounce:i.Easing.Bounce.Out,"Quad.easeIn":i.Easing.Quadratic.In,"Cubic.easeIn":i.Easing.Cubic.In,"Quart.easeIn":i.Easing.Quartic.In,"Quint.easeIn":i.Easing.Quintic.In,"Sine.easeIn":i.Easing.Sinusoidal.In,"Expo.easeIn":i.Easing.Exponential.In,"Circ.easeIn":i.Easing.Circular.In,"Elastic.easeIn":i.Easing.Elastic.In,"Back.easeIn":i.Easing.Back.In,"Bounce.easeIn":i.Easing.Bounce.In,"Quad.easeOut":i.Easing.Quadratic.Out,"Cubic.easeOut":i.Easing.Cubic.Out,"Quart.easeOut":i.Easing.Quartic.Out,"Quint.easeOut":i.Easing.Quintic.Out,"Sine.easeOut":i.Easing.Sinusoidal.Out,"Expo.easeOut":i.Easing.Exponential.Out,"Circ.easeOut":i.Easing.Circular.Out,"Elastic.easeOut":i.Easing.Elastic.Out,"Back.easeOut":i.Easing.Back.Out,"Bounce.easeOut":i.Easing.Bounce.Out,"Quad.easeInOut":i.Easing.Quadratic.InOut,"Cubic.easeInOut":i.Easing.Cubic.InOut,"Quart.easeInOut":i.Easing.Quartic.InOut,"Quint.easeInOut":i.Easing.Quintic.InOut,"Sine.easeInOut":i.Easing.Sinusoidal.InOut,"Expo.easeInOut":i.Easing.Exponential.InOut,"Circ.easeInOut":i.Easing.Circular.InOut,"Elastic.easeInOut":i.Easing.Elastic.InOut,"Back.easeInOut":i.Easing.Back.InOut,"Bounce.easeInOut":i.Easing.Bounce.InOut},this.game.onPause.add(this._pauseAll,this),this.game.onResume.add(this._resumeAll,this)},i.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){return this._tweens.some(function(e){return e.target===t})},_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)}},i.TweenManager.prototype.constructor=i.TweenManager,i.Tween=function(t,e,s){this.game=e,this.target=t,this.manager=s,this.timeline=[],this.reverse=!1,this.timeScale=1,this.repeatCounter=0,this.pendingDelete=!1,this.onStart=new i.Signal,this.onLoop=new i.Signal,this.onRepeat=new i.Signal,this.onChildComplete=new i.Signal,this.onComplete=new i.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},i.Tween.prototype={to:function(t,e,s,n,r,o,a){return(void 0===e||e<=0)&&(e=1e3),void 0!==s&&null!==s||(s=i.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 i.TweenData(this).to(t,e,s,r,o,a)),n&&this.start(),this)},from:function(t,e,s,n,r,o,a){return void 0===e&&(e=1e3),void 0!==s&&null!==s||(s=i.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 i.TweenData(this).from(t,e,s,r,o,a)),n&&this.start(),this)},start:function(t){if(void 0===t&&(t=0),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.yoyoCounter=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],10)),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 i.TweenData.PENDING;this.isRunning=!0}var e=this.parent.frameBased?this.game.time.physicsElapsedMS:this.game.time.elapsedMS;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);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():i.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,i.TweenData.COMPLETE}this.inReverse=!this.inReverse}else if(0===this.repeatCounter)return i.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,i.TweenData.LOOPED}},i.TweenData.prototype.constructor=i.TweenData,i.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){var e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),-i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4))},Out:function(t){var e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),i*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/.4)+1)},InOut:function(t){var e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),(t*=2)<1?i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4)*-.5:i*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(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-i.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*i.Easing.Bounce.In(2*t):.5*i.Easing.Bounce.Out(2*t-1)+.5}}},i.Easing.Default=i.Easing.Linear.None,i.Easing.Power0=i.Easing.Linear.None,i.Easing.Power1=i.Easing.Quadratic.Out,i.Easing.Power2=i.Easing.Cubic.Out,i.Easing.Power3=i.Easing.Quartic.Out,i.Easing.Power4=i.Easing.Quintic.Out,i.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.fps=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 i.Timer(this.game,!1),this._frameCount=0,this._elapsedAccumulator=0,this._started=0,this._timeLastSecond=0,this._pauseStarted=0,this._justResumed=!1,this._timers=[]},i.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 e=new i.Timer(this.game,t);return this._timers.push(e),e},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&&(this.fps=Math.round(1e3*this.frames/(this.now-this._timeLastSecond)),this.fpsMin=Math.min(this.fpsMin,this.fps),this.fpsMax=Math.max(this.fpsMax,this.fps),this._timeLastSecond=this.now,this.frames=0)},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(i.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}}),i.Time.prototype.constructor=i.Time,i.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 i.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},i.Timer.MINUTE=6e4,i.Timer.SECOND=1e3,i.Timer.HALF=500,i.Timer.QUARTER=250,i.Timer.prototype={create:function(t,e,s,n,r,o){var a=t=Math.round(t);0===this._now?a+=this.game.time.time:a+=this._now;var h=new i.TimerEvent(this,t,a,s,e,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(i.Timer.prototype,"length",{get:function(){return this.events.length}}),Object.defineProperty(i.Timer.prototype,"ms",{get:function(){return this.running?this._now-this._started-this._pauseTotal:0}}),Object.defineProperty(i.Timer.prototype,"seconds",{get:function(){return this.running?.001*this.ms:0}}),i.Timer.prototype.constructor=i.Timer,i.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},i.TimerEvent.prototype.constructor=i.TimerEvent,i.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=[]},i.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,e,s,n,r){return e=e||[],s=s||60,void 0===n&&(n=!1),void 0===r&&(r=!(!e||"number"!=typeof e[0])),this._outputFrames=[],this._frameData.getFrameIndexes(e,r,this._outputFrames),this._anims[t]=new i.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}},i.AnimationManager.prototype.constructor=i.AnimationManager,Object.defineProperty(i.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}}),Object.defineProperty(i.AnimationManager.prototype,"frameTotal",{get:function(){return this._frameData.total}}),Object.defineProperty(i.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(t){this.currentAnim.paused=t}}),Object.defineProperty(i.AnimationManager.prototype,"name",{get:function(){if(this.currentAnim)return this.currentAnim.name}}),Object.defineProperty(i.AnimationManager.prototype,"frame",{get:function(){if(this.currentFrame)return this.currentFrame.index},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(i.AnimationManager.prototype,"frameName",{get:function(){if(this.currentFrame)return this.currentFrame.name},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)}}),i.Animation=function(t,e,s,n,r,o,a){void 0===a&&(a=!1),this.game=t,this._parent=e,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 i.Signal,this.onUpdate=null,this.onComplete=new i.Signal,this.onLoop=new i.Signal,this.isReversed=!1,this.game.onPause.add(this.onPause,this),this.game.onResume.add(this.onResume,this)},i.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=this._timeNextFrame)&&(this._frameSkip=1,this._frameDiff=this.game.time.time-this._timeNextFrame,this._timeLastFrame=this.game.time.time,this._frameDiff>this.delay?(this._frameSkip=Math.floor(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay):this._frameDiff=0,this._timeNextFrame=this.game.time.time+(this.delay-this._frameDiff),this.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||!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.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()}},i.Animation.prototype.constructor=i.Animation,Object.defineProperty(i.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(i.Animation.prototype,"reversed",{get:function(){return this.isReversed},set:function(t){this.isReversed=t}}),Object.defineProperty(i.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}}),Object.defineProperty(i.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(i.Animation.prototype,"speed",{get:function(){return 1e3/this.delay},set:function(t){t>0&&(this.delay=1e3/t)}}),Object.defineProperty(i.Animation.prototype,"enableUpdate",{get:function(){return null!==this.onUpdate},set:function(t){t&&null===this.onUpdate?this.onUpdate=new i.Signal:t||null===this.onUpdate||(this.onUpdate.dispose(),this.onUpdate=null)}}),i.Animation.generateFrameNames=function(t,e,s,n,r){void 0===n&&(n="");var o=[],a="";if(e=s;h--)a=t+(a="number"==typeof r?i.Utils.pad(h.toString(),r,"0",1):h.toString())+n,o.push(a);return o},i.Frame=function(t,e,s,n,r,o){this.index=t,this.x=e,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=i.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},i.Frame.prototype={resize:function(t,e){this.width=t,this.height=e,this.centerX=Math.floor(t/2),this.centerY=Math.floor(e/2),this.distance=i.Math.distance(0,0,t,e),this.sourceSizeW=t,this.sourceSizeH=e,this.right=this.x+t,this.bottom=this.y+e},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 i.Frame(this.index,this.x,this.y,this.width,this.height,this.name);for(var e in this)this.hasOwnProperty(e)&&(t[e]=this[e]);return t},getRect:function(t){return void 0===t?t=new i.Rectangle(this.x,this.y,this.width,this.height):t.setTo(this.x,this.y,this.width,this.height),t}},i.Frame.prototype.constructor=i.Frame,i.FrameData=function(){this._frames=[],this._frameNames=[]},i.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 i.FrameData,e=0;ed||h<-d)return console.warn("Phaser.AnimationParser.spriteSheet: skipFrames = "+h.toString()+" is larger than total sprite number "+d.toString()),null;if(h<0&&(h=d+h),-1!==r&&(d=h+r),0===u||0===c||uu&&(f=o,m+=n+a);return p},JSONData:function(t,e){if(!e.frames)return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"),void console.log(e);for(var s,n=new i.FrameData,r=e.frames,o=0;o tag")}},i.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 i.Signal,this._cacheMap=[],this._cacheMap[i.Cache.CANVAS]=this._cache.canvas,this._cacheMap[i.Cache.IMAGE]=this._cache.image,this._cacheMap[i.Cache.TEXTURE]=this._cache.texture,this._cacheMap[i.Cache.SOUND]=this._cache.sound,this._cacheMap[i.Cache.TEXT]=this._cache.text,this._cacheMap[i.Cache.PHYSICS]=this._cache.physics,this._cacheMap[i.Cache.TILEMAP]=this._cache.tilemap,this._cacheMap[i.Cache.BINARY]=this._cache.binary,this._cacheMap[i.Cache.BITMAPDATA]=this._cache.bitmapData,this._cacheMap[i.Cache.BITMAPFONT]=this._cache.bitmapFont,this._cacheMap[i.Cache.JSON]=this._cache.json,this._cacheMap[i.Cache.XML]=this._cache.xml,this._cacheMap[i.Cache.VIDEO]=this._cache.video,this._cacheMap[i.Cache.SHADER]=this._cache.shader,this._cacheMap[i.Cache.RENDER_TEXTURE]=this._cache.renderTexture,this._pendingCount=0,this.onReady=new i.Signal,this._addImages()},i.Cache.CANVAS=1,i.Cache.IMAGE=2,i.Cache.TEXTURE=3,i.Cache.SOUND=4,i.Cache.TEXT=5,i.Cache.PHYSICS=6,i.Cache.TILEMAP=7,i.Cache.BINARY=8,i.Cache.BITMAPDATA=9,i.Cache.BITMAPFONT=10,i.Cache.JSON=11,i.Cache.XML=12,i.Cache.VIDEO=13,i.Cache.SHADER=14,i.Cache.RENDER_TEXTURE=15,i.Cache.DEFAULT=null,i.Cache.DEFAULT_KEY="__default",i.Cache.DEFAULT_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==",i.Cache.MISSING=null,i.Cache.MISSING_KEY="__missing",i.Cache.MISSING_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==",i.Cache.READY_TIMEOUT=1e3,i.Cache.prototype={addCompressedTextureMetaData:function(t,e,s,n){this.checkImageKey(t)&&this.removeImage(t);var r=s in i.LoaderParser?i.LoaderParser[s](n):n,o={key:t,url:e,data:r,base:new PIXI.BaseTexture(r,null,this.game.resolution),frame:new i.Frame(0,0,0,r.width,r.height,t),frameData:new i.FrameData,fileFormat:s};return o.frameData.addFrame(new i.Frame(0,0,0,r.width,r.height,e)),this._cache.image[t]=o,this._resolveURL(e,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,e,s){this.checkImageKey(t)&&this.removeImage(t),!1===s.complete&&console.warn('Phaser.Cache.addImage: Image "'+t+"\" hasn't been retrieved yet");var n={key:t,url:e,data:s,base:new PIXI.BaseTexture(s,null,this.game.resolution),frame:new i.Frame(0,0,0,s.width,s.height,t),frameData:new i.FrameData};return n.frameData.addFrame(new i.Frame(0,0,0,s.width,s.height,e)),this._cache.image[t]=n,this._resolveURL(e,n),"__default"===t?i.Cache.DEFAULT=new PIXI.Texture(n.base):"__missing"===t&&(i.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(i.Cache.DEFAULT_KEY,i.Cache.DEFAULT_SRC,function(t){t.base.skipRender=!0,i.Cache.DEFAULT=new PIXI.Texture(t.base)})},addMissingImage:function(){this.addImageAsync(i.Cache.MISSING_KEY,i.Cache.MISSING_SRC,function(t){i.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,e,s){return e.key=t,void 0===s&&(s=new i.FrameData).addFrame(e.textureFrame),this._cache.bitmapData[t]={data:e,frameData:s},e},addBitmapFont:function(t,e,s,n,r,o,a){var h={url:e,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?i.LoaderParser.jsonBitmapFont(n,h.base,o,a,!1,this.game.resolution):i.LoaderParser.xmlBitmapFont(n,h.base,o,a,!1,this.game.resolution),this._cache.bitmapFont[t]=h,this._resolveURL(e,h)},addBitmapFontFromAtlas:function(t,e,s,n,r,o,a){var h=this.getFrameByName(e,s);if(h){var l={font:null,base:this.getBaseTexture(e),frame:h};void 0===o&&(o=0),void 0===a&&(a=0);var u;"json"===r?(u=this.getJSON(n),l.font=i.LoaderParser.jsonBitmapFont(u,l.base,o,a,h,this.game.resolution)):(u=this.getXML(n),l.font=i.LoaderParser.xmlBitmapFont(u,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,e){this._cache.renderTexture[t]={texture:e,frame:new i.Frame(0,0,0,e.width,e.height,"","")}},addSpriteSheet:function(t,e,s,n,r,o,a,h,l){void 0===o&&(o=-1),void 0===a&&(a=0),void 0===h&&(h=0);var u={key:t,url:e,data:s,frameWidth:n,frameHeight:r,margin:a,spacing:h,base:new PIXI.BaseTexture(s,null,this.game.resolution),frameData:i.AnimationParser.spriteSheet(this.game,s,n,r,o,a,h,l)};this._cache.image[t]=u,this._resolveURL(e,u)},addTextureAtlas:function(t,e,s,n,r){var o={key:t,url:e,data:s,base:new PIXI.BaseTexture(s,null,this.game.resolution)};r===i.Loader.TEXTURE_ATLAS_XML_STARLING?o.frameData=i.AnimationParser.XMLData(this.game,n,t):r===i.Loader.TEXTURE_ATLAS_JSON_PYXEL?o.frameData=i.AnimationParser.JSONDataPyxel(this.game,n,t):Array.isArray(n.frames)?o.frameData=i.AnimationParser.JSONData(this.game,n,t):o.frameData=i.AnimationParser.JSONDataHash(this.game,n,t),this._cache.image[t]=o,this._resolveURL(e,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 e=this.getItem(t,i.Cache.SOUND,"isSoundDecoded");if(e)return e.decoded},isSoundReady:function(t){var e=this.getItem(t,i.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(i.Cache.CANVAS,t)},checkImageKey:function(t){return this.checkKey(i.Cache.IMAGE,t)},checkTextureKey:function(t){return this.checkKey(i.Cache.TEXTURE,t)},checkSoundKey:function(t){return this.checkKey(i.Cache.SOUND,t)},checkTextKey:function(t){return this.checkKey(i.Cache.TEXT,t)},checkPhysicsKey:function(t){return this.checkKey(i.Cache.PHYSICS,t)},checkTilemapKey:function(t){return this.checkKey(i.Cache.TILEMAP,t)},checkBinaryKey:function(t){return this.checkKey(i.Cache.BINARY,t)},checkBitmapDataKey:function(t){return this.checkKey(i.Cache.BITMAPDATA,t)},checkBitmapFontKey:function(t){return this.checkKey(i.Cache.BITMAPFONT,t)},checkJSONKey:function(t){return this.checkKey(i.Cache.JSON,t)},checkXMLKey:function(t){return this.checkKey(i.Cache.XML,t)},checkVideoKey:function(t){return this.checkKey(i.Cache.VIDEO,t)},checkShaderKey:function(t){return this.checkKey(i.Cache.SHADER,t)},checkRenderTextureKey:function(t){return this.checkKey(i.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,i.Cache.CANVAS,"getCanvas","canvas")},getImage:function(t,e){void 0!==t&&null!==t||(t="__default"),void 0===e&&(e=!1);var s=this.getItem(t,i.Cache.IMAGE,"getImage");return null===s&&(s=this.getItem("__missing",i.Cache.IMAGE,"getImage")),e?s:s.data},getTextureFrame:function(t){return this.getItem(t,i.Cache.TEXTURE,"getTextureFrame","frame")},getSound:function(t){return this.getItem(t,i.Cache.SOUND,"getSound")},getSoundData:function(t){return this.getItem(t,i.Cache.SOUND,"getSoundData","data")},getText:function(t){return this.getItem(t,i.Cache.TEXT,"getText","data")},getPhysicsData:function(t,e,s){var n=this.getItem(t,i.Cache.PHYSICS,"getPhysicsData","data");if(null===n||void 0===e||null===e)return n;if(n[e]){var r=n[e];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+" / "+e+'"');return null},getTilemapData:function(t){return this.getItem(t,i.Cache.TILEMAP,"getTilemapData")},getBinary:function(t){return this.getItem(t,i.Cache.BINARY,"getBinary")},getBitmapData:function(t){return this.getItem(t,i.Cache.BITMAPDATA,"getBitmapData","data")},getBitmapFont:function(t){return this.getItem(t,i.Cache.BITMAPFONT,"getBitmapFont")},getJSON:function(t,e){var s=this.getItem(t,i.Cache.JSON,"getJSON","data");return s?e?i.Utils.extend(!0,Array.isArray(s)?[]:{},s):s:null},getXML:function(t){return this.getItem(t,i.Cache.XML,"getXML","data")},getVideo:function(t){return this.getItem(t,i.Cache.VIDEO,"getVideo")},getShader:function(t){return this.getItem(t,i.Cache.SHADER,"getShader","data")},getRenderTexture:function(t){return this.getItem(t,i.Cache.RENDER_TEXTURE,"getRenderTexture")},getBaseTexture:function(t,e){return void 0===e&&(e=i.Cache.IMAGE),this.getItem(t,e,"getBaseTexture","base")},getFrame:function(t,e){return void 0===e&&(e=i.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=i.Cache.IMAGE),this.getItem(t,e,"getFrameData","frameData")},hasFrameData:function(t,e){return void 0===e&&(e=i.Cache.IMAGE),null!==this.getItem(t,e,"","frameData")},updateFrameData:function(t,e,s){void 0===s&&(s=i.Cache.IMAGE),this._cacheMap[s][t]&&(this._cacheMap[s][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=i.Cache.IMAGE);var e=[];if(this._cacheMap[t])for(var s in this._cacheMap[t])"__default"!==s&&"__missing"!==s&&e.push(s);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]},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.",e),t._ready())},i.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)}},i.Cache.prototype.constructor=i.Cache,Object.defineProperty(i.Cache.prototype,"isReady",{get:function(){return this._pendingCount<=0}}),i.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 i.Signal,this.onLoadComplete=new i.Signal,this.onPackComplete=new i.Signal,this.onFileStart=new i.Signal,this.onFileComplete=new i.Signal,this.onFileError=new i.Signal,this.useXDomainRequest=!1,this._warnedAboutXDomainRequest=!1,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},i.Loader.TEXTURE_ATLAS_JSON_ARRAY=0,i.Loader.TEXTURE_ATLAS_JSON_HASH=1,i.Loader.TEXTURE_ATLAS_XML_STARLING=2,i.Loader.PHYSICS_LIME_CORONA_JSON=3,i.Loader.PHYSICS_PHASER_JSON=4,i.Loader.TEXTURE_ATLAS_JSON_PYXEL=5,i.Loader.prototype={setPreloadSprite:function(t,e){e=e||0,this.preloadSprite={sprite:t,direction:e,width:t.width,height:t.height,rect:null},this.preloadSprite.rect=0===e?new i.Rectangle(0,0,1,t.height):new i.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.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 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()}},xhrLoadWithXDR:function(t,e,i,s,n){this._warnedAboutXDomainRequest||this.game.device.ie&&!(this.game.device.ieVersion>=10)||(this._warnedAboutXDomainRequest=!0,console.warn("Phaser.Loader - using XDomainRequest outside of IE 9"));var r=new window.XDomainRequest;r.open("GET",e,!0),r.responseType=i,r.timeout=3e3,n=n||this.fileError;var o=this;r.onerror=function(){try{return n.call(o,t,r)}catch(e){o.asyncComplete(t,e.message||"Exception")}},r.ontimeout=function(){try{return n.call(o,t,r)}catch(e){o.asyncComplete(t,e.message||"Exception")}},r.onprogress=function(){},r.onload=function(){try{return 4===r.readyState&&r.status>=400&&r.status<=599?n.call(o,t,r):s.call(o,t,r)}catch(e){o.asyncComplete(t,e.message||"Exception")}},t.requestObject=r,t.requestUrl=e,setTimeout(function(){r.send()},0)},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,e){var s=!0;switch(t.type){case"packfile":r=JSON.parse(e.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,e.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===i.Loader.TEXTURE_ATLAS_JSON_ARRAY||t.format===i.Loader.TEXTURE_ATLAS_JSON_HASH||t.format===i.Loader.TEXTURE_ATLAS_JSON_PYXEL)this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",this.jsonLoadComplete);else{if(t.format!==i.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=e.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=e.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=e.responseText,this.cache.addText(t.key,t.url,t.data);break;case"shader":t.data=e.responseText,this.cache.addShader(t.key,t.url,t.data);break;case"physics":var r=JSON.parse(e.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=e.responseText,document.head.appendChild(t.data),t.callback&&(t.data=t.callback.call(t.callbackContext,t.key,e.responseText));break;case"binary":t.callback?t.data=t.callback.call(t.callbackContext,t.key,e.response):t.data=e.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(i.Loader.prototype,"progressFloat",{get:function(){var t=this._loadedFileCount/this._totalFileCount*100;return i.Math.clamp(t||0,0,100)}}),Object.defineProperty(i.Loader.prototype,"progress",{get:function(){return Math.round(this.progressFloat)}}),i.Loader.prototype.constructor=i.Loader,i.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"),u=n?n.x:0,c=n?n.y:0,d=0;d=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]),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}},i.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])},i.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]}},i.AudioSprite.prototype.constructor=i.AudioSprite,i.Sound=function(t,e,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=e,this.key=e,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.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._removeFromSoundManager=!1,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*this.game.sound.volume,r&&this.gainNode.connect(this.masterGainNode)):this.usingAudioTag&&(this.game.cache.getSound(e)&&this.game.cache.isSoundReady(e)?(this._sound=this.game.cache.getSoundData(e),this.totalDuration=0,this._sound.duration&&(this.totalDuration=this._sound.duration)):this.game.cache.onSoundUnlock.add(this.soundHasUnlocked,this)),this.onDecoded=new i.Signal,this.onPlay=new i.Signal,this.onPause=new i.Signal,this.onResume=new i.Signal,this.onLoop=new i.Signal,this.onStop=new i.Signal,this.onMute=new i.Signal,this.onMarkerComplete=new i.Signal,this.onFadeComplete=new i.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},i.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._sound.onended=null,this.isPlaying=!1,this.currentTime=this.durationMS,this.stop(),this._markedToDelete&&(this.externalNode?this._sound.disconnect(this.externalNode):this.gainNode&&this._sound.disconnect(this.gainNode),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(){this.game.cache.checkSoundKey(this.key)?(this.isDecoded&&!this._onDecodedEventDispatched&&(this.onDecoded.dispatch(this),this._onDecodedEventDispatched=!0),this.pendingPlayback&&this.game.cache.isSoundReady(this.key)&&(this.pendingPlayback=!1,this.play(this._tempMarker,this._tempPosition,this._tempVolume,this._tempLoop)),this.isPlaying&&(this.currentTime=this.game.time.time-this.startTime,this.currentTime>=this.durationMS&&(this.usingWebAudio?this.loop?(this.onLoop.dispatch(this),this.isPlaying=!1,""===this.currentMarker?(this.currentTime=0,this.startTime=this.game.time.time,this.isPlaying=!0):(this.onMarkerComplete.dispatch(this.currentMarker,this),this.play(this.currentMarker,0,this.volume,!0,!0))):""!==this.currentMarker&&this.stop():this.loop?(this.onLoop.dispatch(this),""===this.currentMarker&&(this.currentTime=0,this.startTime=this.game.time.time),this.isPlaying=!1,this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop()))):this.destroy()},loopFull:function(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)){if(this.usingWebAudio){if(void 0===this._sound.stop)this._sound.noteOff(0);else try{this._sound.stop(0)}catch(t){}this.externalNode?this._sound.disconnect(this.externalNode):this.gainNode&&this._sound.disconnect(this.gainNode)}else this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0);this.isPlaying=!1}if(""===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._sound=this.context.createBufferSource(),this.externalNode?this._sound.connect(this.externalNode):this._sound.connect(this.gainNode),this._buffer=this.game.cache.getSoundData(this.key),this._sound.buffer=this._buffer,this.loop&&""===t&&(this._sound.loop=!0),this.loop||""!==t||(this._sound.onended=this.onEndedHandler.bind(this)),this.totalDuration=this._sound.buffer.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=Math.ceil(1e3*this.totalDuration)),void 0===this._sound.start?this._sound.noteGrainOn(0,this.position,this.duration):this.loop&&""===t?this._sound.start(0,0):this._sound.start(0,this.position,this.duration),this.isPlaying=!0,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.totalDuration=this._sound.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this._sound.currentTime=this.position,this._sound.muted=this._muted,this._muted||this.game.sound.mute?this._sound.volume=0:this._sound.volume=this._volume,this.isPlaying=!0,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):this.pendingPlayback=!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._sound&&(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&&this._sound){if(this.usingWebAudio){var t=Math.max(0,this.position+this.pausedPosition/1e3);this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this.externalNode?this._sound.connect(this.externalNode):this._sound.connect(this.gainNode),this.loop&&(this._sound.loop=!0),this.loop||""!==this.currentMarker||(this._sound.onended=this.onEndedHandler.bind(this));var e=this.duration-this.pausedPosition/1e3;void 0===this._sound.start?this._sound.noteGrainOn(0,t,e):this.loop&&this.game.device.chrome?42===this.game.device.chromeVersion?this._sound.start(0):this._sound.start(0,t):this._sound.start(0,t,e)}else this._sound.currentTime=this._tempPause,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)if(this.usingWebAudio){if(void 0===this._sound.stop)this._sound.noteOff(0);else try{this._sound.stop(0)}catch(t){}this.externalNode?this._sound.disconnect(this.externalNode):this.gainNode&&this._sound.disconnect(this.gainNode)}else this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0);if(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,e){this.isPlaying&&!this.paused&&e!==this.volume&&(void 0===t&&(t=1e3),void 0!==e?(this.fadeTween=this.game.add.tween(this).to({volume:e},t,i.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())}},i.Sound.prototype.constructor=i.Sound,Object.defineProperty(i.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}}),Object.defineProperty(i.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}}),Object.defineProperty(i.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(i.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))}}),i.SoundManager=function(t){this.game=t,this.onSoundDecode=new i.Signal,this.onVolumeChange=new i.Signal,this.onMute=new i.Signal,this.onUnMute=new i.Signal,this.context=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 i.ArraySet,this._watching=!1,this._watchCallback=null,this._watchContext=null},i.SoundManager.prototype={boot:function(){if(this.game.device.iOS&&!1===this.game.device.webAudio&&(this.channels=1),window.PhaserGlobal){if(!0===window.PhaserGlobal.disableAudio)return this.noAudio=!0,void(this.touchLocked=!1);if(!0===window.PhaserGlobal.disableWebAudio)return this.usingAudioTag=!0,void(this.touchLocked=!1)}if(window.PhaserGlobal&&window.PhaserGlobal.audioContext)this.context=window.PhaserGlobal.audioContext;else if(window.AudioContext)try{this.context=new window.AudioContext}catch(t){this.context=null,this.usingWebAudio=!1,this.touchLocked=!1}else if(window.webkitAudioContext)try{this.context=new window.webkitAudioContext}catch(t){this.context=null,this.usingWebAudio=!1,this.touchLocked=!1}if(null===this.context){if(void 0===window.Audio)return void(this.noAudio=!0);this.usingAudioTag=!0}else this.usingWebAudio=!0,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);this.noAudio||this.game.device.needsTouchUnlock()&&this.setTouchLock()},setTouchLock:function(){this.noAudio||window.PhaserGlobal&&!0===window.PhaserGlobal.disableAudio||(this.game.device.iOSVersion>8||this.game.device.chromeVersion>=55?this.game.input.addTouchLockCallback(this.unlock,this,!0):this.game.input.addTouchLockCallback(this.unlock,this),this.touchLocked=!0)},unlock:function(){if(this.noAudio||!this.touchLocked||null!==this._unlockSource)return!0;if(this.usingAudioTag)this.touchLocked=!1,this._unlockSource=null;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),void 0===this._unlockSource.start?this._unlockSource.noteOn(0):this._unlockSource.start(0),"suspended"===this._unlockSource.context.state&&this._unlockSource.context.resume()}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 e=this._parentBounds.width,s=this._parentBounds.height,n=this.getParentBounds(this._parentBounds),r=n.width!==e||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))}},i.ScaleManager.prototype.constructor=i.ScaleManager,Object.defineProperty(i.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(i.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(i.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(i.ScaleManager.prototype,"currentScaleMode",{get:function(){return this.isFullScreen?this._fullScreenScaleMode:this._scaleMode}}),Object.defineProperty(i.ScaleManager.prototype,"pageAlignHorizontally",{get:function(){return this._pageAlignHorizontally},set:function(t){t!==this._pageAlignHorizontally&&(this._pageAlignHorizontally=t,this.queueUpdate(!0))}}),Object.defineProperty(i.ScaleManager.prototype,"pageAlignVertically",{get:function(){return this._pageAlignVertically},set:function(t){t!==this._pageAlignVertically&&(this._pageAlignVertically=t,this.queueUpdate(!0))}}),Object.defineProperty(i.ScaleManager.prototype,"isFullScreen",{get:function(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}}),Object.defineProperty(i.ScaleManager.prototype,"isPortrait",{get:function(){return"portrait"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(i.ScaleManager.prototype,"isLandscape",{get:function(){return"landscape"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(i.ScaleManager.prototype,"isGamePortrait",{get:function(){return this.height>this.width}}),Object.defineProperty(i.ScaleManager.prototype,"isGameLandscape",{get:function(){return this.width>this.height}}),i.Utils.Debug=function(t){this.game=t,this.sprite=null,this.bmd=null,this.canvas=null,this.context=null,this.font="14px Courier",this.columnWidth=100,this.lineHeight=16,this.lineWidth=1,this.renderShadow=!0,this.currentX=0,this.currentY=0,this.currentAlpha=1,this.dirty=!1,this.isDisabled=!1,this._line=null,this._rect=null},i.Utils.Debug.prototype={boot:function(){this.game.renderType===i.CANVAS?this.context=this.game.context:(this.bmd=new i.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=i.CanvasPool.create(this,this.game.width,this.game.height),this.context=this.canvas.getContext("2d")),this._line=new i.Line,this._rect=new i.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 i.Rectangle,layoutBounds:new i.Rectangle,documentBounds:new i.Rectangle},i.Device.whenReady(function(t){var e=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(i.DOM,"scrollX",{get:e}),Object.defineProperty(i.DOM,"scrollY",{get:s}),Object.defineProperty(i.DOM.visualBounds,"x",{get:e}),Object.defineProperty(i.DOM.visualBounds,"y",{get:s}),Object.defineProperty(i.DOM.layoutBounds,"x",{value:0}),Object.defineProperty(i.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(i.DOM.visualBounds,"width",{get:n}),Object.defineProperty(i.DOM.visualBounds,"height",{get:r}),Object.defineProperty(i.DOM.layoutBounds,"width",{get:n}),Object.defineProperty(i.DOM.layoutBounds,"height",{get:r})}else Object.defineProperty(i.DOM.visualBounds,"width",{get:function(){return window.innerWidth}}),Object.defineProperty(i.DOM.visualBounds,"height",{get:function(){return window.innerHeight}}),Object.defineProperty(i.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(i.ArraySet.prototype,"total",{get:function(){return this.list.length}}),Object.defineProperty(i.ArraySet.prototype,"first",{get:function(){return this.position=0,this.list.length>0?this.list[0]:null}}),Object.defineProperty(i.ArraySet.prototype,"next",{get:function(){return this.position0;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,e){if("string"!=typeof e&&(e=(e%360+360)%360),90===e||-270===e||"rotateLeft"===e)t=(t=i.ArrayUtils.transposeMatrix(t)).reverse();else if(-90===e||270===e||"rotateRight"===e)t=t.reverse(),t=i.ArrayUtils.transposeMatrix(t);else if(180===Math.abs(e)||"rotate180"===e){for(var s=0;s>>0:(t<<24|e<<16|s<<8|n)>>>0},unpackPixel:function(t,e,s,n){return void 0!==e&&null!==e||(e=i.Color.createColor()),void 0!==s&&null!==s||(s=!1),void 0!==n&&null!==n||(n=!1),i.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+")",s&&i.Color.RGBtoHSL(e.r,e.g,e.b,e),n&&i.Color.RGBtoHSV(e.r,e.g,e.b,e),e},fromRGBA:function(t,e){return e||(e=i.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,s,n){n||(n=i.Color.createColor(t,e,s,1)),t/=255,e/=255,s/=255;var r=Math.min(t,e,s),o=Math.max(t,e,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=(e-s)/a+(e1&&(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,e,s,n,r,o,a,h){var l={r:t||0,g:e||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 i.Color.updateColor(l)},updateColor:function(t){return t.rgba="rgba("+t.r.toString()+","+t.g.toString()+","+t.b.toString()+","+t.a.toString()+")",t.color=i.Color.getColor(t.r,t.g,t.b),t.color32=i.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,e,s,n,r){return void 0===n&&(n=255),void 0===r&&(r="#"),"#"===r?"#"+((1<<24)+(t<<16)+(e<<8)+s).toString(16).slice(1):"0x"+i.Color.componentToHex(n)+i.Color.componentToHex(t)+i.Color.componentToHex(e)+i.Color.componentToHex(s)},hexToRGB:function(t){var e=i.Color.hexToColor(t);if(e)return i.Color.getColor32(e.a,e.r,e.g,e.b)},hexToColor:function(t,e){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);e?(e.r=n,e.g=r,e.b=o):e=i.Color.createColor(n,r,o)}return e},webToColor:function(t,e){e||(e=i.Color.createColor());var s=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(t);return s&&(e.r=parseInt(s[1],10),e.g=parseInt(s[2],10),e.b=parseInt(s[3],10),e.a=void 0!==s[4]?parseFloat(s[4]):1,i.Color.updateColor(e)),e},valueToColor:function(t,e){if(e||(e=i.Color.createColor()),"string"==typeof t)return 0===t.indexOf("rgb")?i.Color.webToColor(t,e):(e.a=1,i.Color.hexToColor(t,e));if("number"==typeof t){var s=i.Color.getRGB(t);return e.r=s.r,e.g=s.g,e.b=s.b,e.a=s.a/255,e}return e},componentToHex:function(t){var e=t.toString(16);return 1===e.length?"0"+e:e},HSVColorWheel:function(t,e){void 0===t&&(t=1),void 0===e&&(e=1);for(var s=[],n=0;n<=359;n++)s.push(i.Color.HSVtoRGB(n/359,t,e));return s},HSLColorWheel:function(t,e){void 0===t&&(t=.5),void 0===e&&(e=.5);for(var s=[],n=0;n<=359;n++)s.push(i.Color.HSLtoRGB(n/359,t,e));return s},interpolateColor:function(t,e,s,n,r){void 0===r&&(r=255);var o=i.Color.getRGB(t),a=i.Color.getRGB(e),h=(a.red-o.red)*n/s+o.red,l=(a.green-o.green)*n/s+o.green,u=(a.blue-o.blue)*n/s+o.blue;return i.Color.getColor32(r,h,l,u)},interpolateColorWithRGB:function(t,e,s,n,r,o){var a=i.Color.getRGB(t),h=(e-a.red)*o/r+a.red,l=(s-a.green)*o/r+a.green,u=(n-a.blue)*o/r+a.blue;return i.Color.getColor(h,l,u)},interpolateRGB:function(t,e,s,n,r,o,a,h){var l=(n-t)*h/a+t,u=(r-e)*h/a+e,c=(o-s)*h/a+s;return i.Color.getColor(l,u,c)},getRandomColor:function(t,e,s){if(void 0===t&&(t=0),void 0===e&&(e=255),void 0===s&&(s=255),e>255||t>e)return i.Color.getColor(255,255,255);var n=t+Math.round(Math.random()*(e-t)),r=t+Math.round(Math.random()*(e-t)),o=t+Math.round(Math.random()*(e-t));return i.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 e=i.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 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,e){return i.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 i.Color.blendAdd(t,e)},blendLinearBurn:function(t,e){return i.Color.blendSubtract(t,e)},blendLinearLight:function(t,e){return e<128?i.Color.blendLinearBurn(t,2*e):i.Color.blendLinearDodge(t,2*(e-128))},blendVividLight:function(t,e){return e<128?i.Color.blendColorBurn(t,2*e):i.Color.blendColorDodge(t,2*(e-128))},blendPinLight:function(t,e){return e<128?i.Color.blendDarken(t,2*e):i.Color.blendLighten(t,2*(e-128))},blendHardMix:function(t,e){return i.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 i.Color.blendReflect(e,t)},blendPhoenix:function(t,e){return Math.min(t,e)-Math.max(t,e)+255}},i.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()},i.Physics.ARCADE=0,i.Physics.P2JS=1,i.Physics.NINJA=2,i.Physics.BOX2D=3,i.Physics.CHIPMUNK=4,i.Physics.MATTERJS=5,i.Physics.prototype={parseConfig:function(){this.config.hasOwnProperty("arcade")&&!0!==this.config.arcade||!i.Physics.hasOwnProperty("Arcade")||(this.arcade=new i.Physics.Arcade(this.game)),this.config.hasOwnProperty("ninja")&&!0===this.config.ninja&&i.Physics.hasOwnProperty("Ninja")&&(this.ninja=new i.Physics.Ninja(this.game)),this.config.hasOwnProperty("p2")&&!0===this.config.p2&&i.Physics.hasOwnProperty("P2")&&(this.p2=new i.Physics.P2(this.game,this.config)),this.config.hasOwnProperty("box2d")&&!0===this.config.box2d&&i.Physics.hasOwnProperty("BOX2D")&&(this.box2d=new i.Physics.BOX2D(this.game,this.config)),this.config.hasOwnProperty("matter")&&!0===this.config.matter&&i.Physics.hasOwnProperty("Matter")&&(this.matter=new i.Physics.Matter(this.game,this.config))},startSystem:function(t){t===i.Physics.ARCADE?this.arcade=new i.Physics.Arcade(this.game):t===i.Physics.P2JS?null===this.p2?this.p2=new i.Physics.P2(this.game,this.config):this.p2.reset():t===i.Physics.NINJA?this.ninja=new i.Physics.Ninja(this.game):t===i.Physics.BOX2D?null===this.box2d?this.box2d=new i.Physics.Box2D(this.game,this.config):this.box2d.reset():t===i.Physics.MATTERJS&&(null===this.matter?this.matter=new i.Physics.Matter(this.game,this.config):this.matter.reset())},enable:function(t,e,s){void 0===e&&(e=i.Physics.ARCADE),void 0===s&&(s=!1),e===i.Physics.ARCADE?this.arcade.enable(t):e===i.Physics.P2JS&&this.p2?this.p2.enable(t,s):e===i.Physics.NINJA&&this.ninja?this.ninja.enableAABB(t):e===i.Physics.BOX2D&&this.box2d?this.box2d.enable(t):e===i.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}},i.Physics.prototype.constructor=i.Physics,i.Physics.Arcade=function(t){this.game=t,this.gravity=new i.Point,this.bounds=new i.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=i.Physics.Arcade.LEFT_RIGHT,this.skipQuadTree=!0,this.isPaused=!1,this.quadTree=new i.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()},i.Physics.Arcade.prototype.constructor=i.Physics.Arcade,i.Physics.Arcade.SORT_NONE=0,i.Physics.Arcade.LEFT_RIGHT=1,i.Physics.Arcade.RIGHT_LEFT=2,i.Physics.Arcade.TOP_BOTTOM=3,i.Physics.Arcade.BOTTOM_TOP=4,i.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 s=1;if(Array.isArray(t))for(s=t.length;s--;)t[s]instanceof i.Group?this.enable(t[s].children,e):(this.enableBody(t[s]),e&&t[s].hasOwnProperty("children")&&t[s].children.length>0&&this.enable(t[s],!0));else t instanceof i.Group?this.enable(t.children,e):(this.enableBody(t),e&&t.hasOwnProperty("children")&&t.children.length>0&&this.enable(t.children,!0))},enableBody:function(t){t.hasOwnProperty("body")&&null===t.body&&(t.body=new i.Physics.Arcade.Body(t),t.parent&&t.parent instanceof i.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,e){null!==t.physicsSortDirection?e=t.physicsSortDirection:void 0===e&&(e=this.sortDirection),e===i.Physics.Arcade.LEFT_RIGHT?t.hash.sort(this.sortLeftRight):e===i.Physics.Arcade.RIGHT_LEFT?t.hash.sort(this.sortRightLeft):e===i.Physics.Arcade.TOP_BOTTOM?t.hash.sort(this.sortTopBottom):e===i.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;o