text: this.collCheck=this.collCheck||{};(function(){var l=document.createElement("canvas");var a=l.getContext("2d");a.save();var m=document.createElement("canvas");var c=m.getContext("2d");c.save();var i=[];var h=function(q,p){var o,n;o=g(q);n=g(p);return f(o,n)};collCheck.checkRectCollision=h;var e=function(r,p,n,q){if(collCheck.DEBUG||collCheck.DEBUG_COLLISION){document.body.appendChild(l);document.body.appendChild(m)}q=q||false;var s,o,v,u,t;intersection=h(r,p);if(!intersection){return false}n=n||0;n=Math.min(0.99999,n);l.width=intersection.width;l.height=intersection.height;m.width=intersection.width;m.height=intersection.height;v=d(intersection,r,a,1);u=d(intersection,p,c,2);t=k(v,u,intersection.width,intersection.height,n,q);if(t){t.x+=intersection.x;t.x2+=intersection.x;t.y+=intersection.y;t.y2+=intersection.y}else{return false}return t};collCheck.checkPixelCollision=e;var j=function(r,q){var n,s,p,o;p=r.localToGlobal(0,0);o=q.localToGlobal(0,0);n=r instanceof createjs.Bitmap?{width:r.image.width,height:r.image.height}:r.spriteSheet.getFrame(r.currentFrame).rect;s=q instanceof createjs.Bitmap?{width:q.image.width,height:q.image.height}:q.spriteSheet.getFrame(q.currentFrame).rect;return(Math.abs(o.x-p.x)<s.width*q.scaleX+n.width*r.scaleX&&Math.abs(o.y-p.y)<s.height*q.scaleY+n.height*q.scaleY)};var d=function(t,r,o,p){var u,s,n,q;if(r instanceof createjs.Bitmap){s=r.image}else{if(r instanceof createjs.Sprite){frame=r.spriteSheet.getFrame(r.currentFrame);n=frame.image.src+":"+frame.rect.x+":"+frame.rect.y+":"+frame.rect.width+":"+frame.rect.height;if(i[n]){s=i[n]}else{i[n]=s=createjs.SpriteSheetUtils.extractFrame(r.spriteSheet,r.currentFrame)}}}u=r.globalToLocal(t.x,t.y);o.restore();o.save();o.rotate(b(r,"rotation")*(Math.PI/180));o.scale(b(r,"scaleX","*"),b(r,"scaleY","*"));o.translate(-u.x-t["rect"+p].regX,-u.y-t["rect"+p].regY);if((q=r.sourceRect)!=undefined){o.drawImage(s,q.x,q.y,q.width,q.height,0,0,q.width,q.height)}else{o.drawImage(s,0,0,s.width,s.height)}return o.getImageData(0,0,t.width,t.height).data};var k=function(w,v,n,z,o,s){var A,u,t,r,q=3,p={x:Infinity,y:Infinity,x2:-Infinity,y2:-Infinity};for(r=0;r<z;++r){for(t=0;t<n;++t){A=w.length>q+1?w[q]/255:0;u=v.length>q+1?v[q]/255:0;if(A>o&&u>o){if(s){if(t<p.x){p.x=t}if(t>p.x2){p.x2=t}if(r<p.y){p.y=r}if(r>p.y2){p.y2=r}}else{return{x:t,y:r,width:1,height:1}}}q+=4}}if(p.x!=Infinity){p.width=p.x2-p.x+1;p.height=p.y2-p.y+1;return p}return null};var b=function(r,p,o){o=o||"+";if(r.parent&&r.parent[p]){var q=r[p];var n=b(r.parent,p,o);if(o=="*"){return q*n}else{return q+n}}return r[p]};var f=function(s,p){var r,o,q={},n={};q.cx=s.x+(q.hw=(s.width/2));q.cy=s.y+(q.hh=(s.height/2));n.cx=p.x+(n.hw=(p.width/2));n.cy=p.y+(n.hh=(p.height/2));r=Math.abs(q.cx-n.cx)-(q.hw+n.hw);o=Math.abs(q.cy-n.cy)-(q.hh+n.hh);if(r<0&&o<0){r=Math.min(Math.min(s.width,p.width),-r);o=Math.min(Math.min(s.height,p.height),-o);return{x:Math.max(s.x,p.x),y:Math.max(s.y,p.y),width:r,height:o,rect1:s,rect2:p}}else{return null}};collCheck.calculateIntersection=f;var g=function(v){var o={x:Infinity,y:Infinity,width:0,height:0};if(v instanceof createjs.Container){o.x2=-Infinity;o.y2=-Infinity;var q=v.children,u=q.length,z,y;for(y=0;y<u;y++){z=g(q[y]);if(z.x<o.x){o.x=z.x}if(z.y<o.y){o.y=z.y}if(z.x+z.width>o.x2){o.x2=z.x+z.width}if(z.y+z.height>o.y2){o.y2=z.y+z.height}}if(o.x==Infinity){o.x=0}if(o.y==Infinity){o.y=0}if(o.x2==Infinity){o.x2=0}if(o.y2==Infinity){o.y2=0}o.width=o.x2-o.x;o.height=o.y2-o.y;delete o.x2;delete o.y2}else{var t,s,r,p,w={},n;if(v instanceof createjs.Bitmap){n=v.sourceRect||v.image;w.width=n.width;w.height=n.height}else{if(v instanceof createjs.Sprite){if(v.spriteSheet._frames&&v.spriteSheet._frames[v.currentFrame]&&v.spriteSheet._frames[v.currentFrame].image){var x=v.spriteSheet.getFrame(v.currentFrame);w.width=x.rect.width;w.height=x.rect.height;w.regX=x.regX;w.regY=x.regY}else{o.x=v.x||0;o.y=v.y||0}}else{o.x=v.x||0;o.y=v.y||0}}w.regX=w.regX||0;w.width=w.width||0;w.regY=w.regY||0;w.height=w.height||0;o.regX=w.regX;o.regY=w.regY;t=v.localToGlobal(0-w.regX,0-w.regY);s=v.localToGlobal(w.width-w.regX,w.height-w.regY);r=v.localToGlobal(w.width-w.regX,0-w.regY);p=v.localToGlobal(0-w.regX,w.height-w.regY);o.x=Math.min(Math.min(Math.min(t.x,s.x),r.x),p.x);o.y=Math.min(Math.min(Math.min(t.y,s.y),r.y),p.y);o.width=Math.max(Math.max(Math.max(t.x,s.x),r.x),p.x)-o.x;o.height=Math.max(Math.max(Math.max(t.y,s.y),r.y),p.y)-o.y}return o};collCheck.getBounds=g;collCheck.px=collCheck.checkPixelCollision;collCheck.rect=collCheck.checkRectCollision}());