diff --git a/bounce/.gitignore b/bounce/.gitignore index 640d65b..067b061 100644 --- a/bounce/.gitignore +++ b/bounce/.gitignore @@ -5,7 +5,7 @@ library/ temp/ local/ -build/ +#build/ #///////////////////////////////////////////////////////////////////////////// # Logs and databases @@ -64,4 +64,4 @@ quick_gen_project_*_autogen.sh.meta # VS Code #////////////////////////// -.vscode/ \ No newline at end of file +.vscode/ diff --git a/bounce/build/web-mobile/cocos2d-js-min.js b/bounce/build/web-mobile/cocos2d-js-min.js new file mode 100644 index 0000000..19c7c7b --- /dev/null +++ b/bounce/build/web-mobile/cocos2d-js-min.js @@ -0,0 +1 @@ +(function(t,e,i){function n(i,s){var o=e[i];if(!o){var a=t[i];if(!a){var c="function"==typeof require&&require;if(!s&&c)return c(i,!0);if(r)return r(i,!0);var h=new Error("Cannot find module '"+i+"'");throw h.code="MODULE_NOT_FOUND",h}var l={};o=e[i]={exports:l},a[0]((function(t){return n(a[1][t]||t)}),o,l)}return o.exports}for(var r="function"==typeof require&&require,s=0;s2||i<0)&&(t[e.renderMode]=0),cc._renderType=cc.game.RENDER_TYPE_CANVAS,cc._supportRender=!1,0===i?cc.sys.capabilities.opengl?(cc._renderType=cc.game.RENDER_TYPE_WEBGL,cc._supportRender=!0):cc.sys.capabilities.canvas&&(cc._renderType=cc.game.RENDER_TYPE_CANVAS,cc._supportRender=!0):1===i&&cc.sys.capabilities.canvas?(cc._renderType=cc.game.RENDER_TYPE_CANVAS,cc._supportRender=!0):2===i&&cc.sys.capabilities.opengl&&(cc._renderType=cc.game.RENDER_TYPE_WEBGL,cc._supportRender=!0)})(t=cc.game.config),document.body?n():window.addEventListener("load",r,!1),s=!0}}),{"./cocos2d/core/platform/CCSys":185,"./cocos2d/core/utils":225}],2:[(function(t,e,i){function n(t,e){return function(i){"use strict";if(1!==arguments.length){var n="";2===arguments.length?n="Arguments: "+arguments[1]:arguments.length>2&&(n="Arguments: "+cc.js.shiftArguments.apply(null,arguments).join(", ")),t(e+" "+i+", please go to "+o+"#"+i+" to see details. "+n)}else t(e+" "+i+", please go to "+o+"#"+i+" to see details.")}}var r,s=t("./cocos2d/core/platform/CCEnum");cc.DebugMode=s({NONE:0,INFO:1,WARN:2,ERROR:3,INFO_FOR_WEB_PAGE:4,WARN_FOR_WEB_PAGE:5,ERROR_FOR_WEB_PAGE:6}),cc._initDebugSetting=function(t){if(cc.log=cc.logID=cc.warn=cc.warnID=cc.error=cc.errorID=cc.assert=cc.assertID=function(){},t!==cc.DebugMode.NONE){t>cc.DebugMode.ERROR?(function(){function e(t){if(cc._canvas){if(!r){var e=document.createElement("Div");e.setAttribute("id","logInfoDiv"),e.setAttribute("width","200"),e.setAttribute("height",cc._canvas.height);var i=e.style;i.zIndex="99999",i.position="absolute",i.top=i.left="0",(r=document.createElement("textarea")).setAttribute("rows","20"),r.setAttribute("cols","30"),r.setAttribute("disabled","true");var n=r.style;n.backgroundColor="transparent",n.borderBottom="1px solid #cccccc",n.borderTopWidth=n.borderLeftWidth=n.borderRightWidth="0px",n.borderTopStyle=n.borderLeftStyle=n.borderRightStyle="none",n.padding="0px",n.margin=0,e.appendChild(r),cc._canvas.parentNode.appendChild(e)}r.value=r.value+t+"\r\n",r.scrollTop=r.scrollHeight}}cc.error=function(){e("ERROR : "+cc.js.formatStr.apply(null,arguments))},cc.assert=function(t,i){"use strict";!t&&i&&e("ASSERT: "+(i=cc.js.formatStr.apply(null,cc.js.shiftArguments.apply(null,arguments))))},t!==cc.DebugMode.ERROR_FOR_WEB_PAGE&&(cc.warn=function(){e("WARN : "+cc.js.formatStr.apply(null,arguments))}),t===cc.DebugMode.INFO_FOR_WEB_PAGE&&(cc.log=cc.info=function(){e(cc.js.formatStr.apply(null,arguments))})})():console&&console.log.apply&&(console.error||(console.error=console.log),console.warn||(console.warn=console.log),console.error.bind?cc.error=console.error.bind(console):cc.error=function(){return console.error.apply(console,arguments)},cc.assert=function(t,e){if(!t)throw e&&(e=cc.js.formatStr.apply(null,cc.js.shiftArguments.apply(null,arguments))),new Error(e)}),t!==cc.DebugMode.ERROR&&(console.warn.bind?cc.warn=console.warn.bind(console):cc.warn=function(){return console.warn.apply(console,arguments)}),t===cc.DebugMode.INFO&&(console.log.bind?cc.log=console.log.bind(console):cc.log=function(){return console.log.apply(console,arguments)},cc.info=function(){(console.info||console.log).apply(console,arguments)}),cc.warnID=n(cc.warn,"Warning"),cc.errorID=n(cc.error,"Error"),cc.logID=n(cc.log,"Log");var e=n((function(){for(var t=[!1],e=0;e=0;i--)e.push(cc.p(t[i].x,t[i].y));return e}function r(t){for(var e=[],i=0;i=this._duration},_cloneDecoration:function(t){t._repeatForever=this._repeatForever,t._speed=this._speed,t._timesForRepeat=this._timesForRepeat,t._easeList=this._easeList,t._speedMethod=this._speedMethod,t._repeatMethod=this._repeatMethod},_reverseEaseList:function(t){if(this._easeList){t._easeList=[];for(var e=0;e1.192092896e-7?this._duration:1.192092896e-7);e=1>e?e:1,this.update(e>0?e:0),this._repeatMethod&&this._timesForRepeat>1&&this.isDone()&&(this._repeatForever||this._timesForRepeat--,this.startWithTarget(this.target),this.step(this._elapsed-this._duration))},startWithTarget:function(t){cc.Action.prototype.startWithTarget.call(this,t),this._elapsed=0,this._firstTick=!0},reverse:function(){return cc.logID(1010),null},setAmplitudeRate:function(t){cc.logID(1011)},getAmplitudeRate:function(){return cc.logID(1012),0},speed:function(t){return t<=0?(cc.logID(1013),this):(this._speedMethod=!0,this._speed*=t,this)},getSpeed:function(){return this._speed},setSpeed:function(t){return this._speed=t,this},repeat:function(t){return t=Math.round(t),isNaN(t)||t<1?(cc.logID(1014),this):(this._repeatMethod=!0,this._timesForRepeat*=t,this)},repeatForever:function(){return this._repeatMethod=!0,this._timesForRepeat=this.MAX_VALUE,this._repeatForever=!0,this}}),cc.actionInterval=function(t){return new cc.ActionInterval(t)},cc.Sequence=cc.ActionInterval.extend({_actions:null,_split:null,_last:0,_reversed:!1,ctor:function(t){cc.ActionInterval.prototype.ctor.call(this),this._actions=[];var e=t instanceof Array?t:arguments;if(1!==e.length){var i=e.length-1;if(i>=0&&null==e[i]&&cc.logID(1015),i>=0){for(var n,r=e[0],s=1;s1?e%1:e),this._last=n)},reverse:function(){var t=cc.Sequence._actionOneTwo(this._actions[1].reverse(),this._actions[0].reverse());return this._cloneDecoration(t),this._reverseEaseList(t),t._reversed=!0,t}}),cc.sequence=function(t){var e=t instanceof Array?t:arguments;if(1===e.length)return cc.errorID(1019),null;var i=e.length-1;i>=0&&null==e[i]&&cc.logID(1015);var n=null;if(i>=0){n=e[0];for(var r=1;r<=i;r++)e[r]&&(n=cc.Sequence._actionOneTwo(n,e[r]))}return n},cc.Sequence._actionOneTwo=function(t,e){var i=new cc.Sequence;return i.initWithTwoActions(t,e),i},cc.Repeat=cc.ActionInterval.extend({_times:0,_total:0,_nextDt:0,_actionInstant:!1,_innerAction:null,ctor:function(t,e){cc.ActionInterval.prototype.ctor.call(this),void 0!==e&&this.initWithAction(t,e)},initWithAction:function(t,e){var i=t._duration*e;return!!this.initWithDuration(i)&&(this._times=e,this._innerAction=t,t instanceof cc.ActionInstant&&(this._actionInstant=!0,this._times-=1),this._total=0,!0)},clone:function(){var t=new cc.Repeat;return this._cloneDecoration(t),t.initWithAction(this._innerAction.clone(),this._times),t},startWithTarget:function(t){this._total=0,this._nextDt=this._innerAction._duration/this._duration,cc.ActionInterval.prototype.startWithTarget.call(this,t),this._innerAction.startWithTarget(t)},stop:function(){this._innerAction.stop(),cc.Action.prototype.stop.call(this)},update:function(t){t=this._computeEaseTime(t);var e=this._innerAction,i=this._duration,n=this._times,r=this._nextDt;if(t>=r){for(;t>r&&this._total=1&&this._total=0&&null==e[i]&&cc.logID(1015),i>=0){for(var n,r=e[0],s=1;sr?this._two=cc.Sequence._actionOneTwo(e,cc.delayTime(n-r)):n0&&null==e[e.length-1]&&cc.logID(1015);for(var i=e[0],n=1;n180&&(i-=360),i<-180&&(i+=360),this._startAngleX=e,this._diffAngleX=i,this._startAngleY=t.rotationY%360;var n=this._dstAngleY-this._startAngleY;n>180&&(n-=360),n<-180&&(n+=360),this._diffAngleY=n},reverse:function(){cc.logID(1016)},update:function(t){t=this._computeEaseTime(t),this.target&&(this.target.rotationX=this._startAngleX+this._diffAngleX*t,this.target.rotationY=this._startAngleY+this._diffAngleY*t)}}),cc.rotateTo=function(t,e,i){return new cc.RotateTo(t,e,i)},cc.RotateBy=cc.ActionInterval.extend({_angleX:0,_startAngleX:0,_angleY:0,_startAngleY:0,ctor:function(t,e,i){cc.ActionInterval.prototype.ctor.call(this),void 0!==e&&this.initWithDuration(t,e,i)},initWithDuration:function(t,e,i){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._angleX=e||0,this._angleY=void 0!==i?i:this._angleX,!0)},clone:function(){var t=new cc.RotateBy;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._angleX,this._angleY),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._startAngleX=t.rotationX,this._startAngleY=t.rotationY},update:function(t){t=this._computeEaseTime(t),this.target&&(this.target.rotationX=this._startAngleX+this._angleX*t,this.target.rotationY=this._startAngleY+this._angleY*t)},reverse:function(){var t=new cc.RotateBy(this._duration,-this._angleX,-this._angleY);return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.rotateBy=function(t,e,i){return new cc.RotateBy(t,e,i)},cc.MoveBy=cc.ActionInterval.extend({_positionDelta:null,_startPosition:null,_previousPosition:null,ctor:function(t,e,i){cc.ActionInterval.prototype.ctor.call(this),this._positionDelta=cc.p(0,0),this._startPosition=cc.p(0,0),this._previousPosition=cc.p(0,0),void 0!==e&&this.initWithDuration(t,e,i)},initWithDuration:function(t,e,i){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(void 0!==e.x&&(i=e.y,e=e.x),this._positionDelta.x=e,this._positionDelta.y=i,!0)},clone:function(){var t=new cc.MoveBy;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._positionDelta),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t);var e=t.getPositionX(),i=t.getPositionY();this._previousPosition.x=e,this._previousPosition.y=i,this._startPosition.x=e,this._startPosition.y=i},update:function(t){if(t=this._computeEaseTime(t),this.target){var e=this._positionDelta.x*t,i=this._positionDelta.y*t,n=this._startPosition;if(cc.macro.ENABLE_STACKABLE_ACTIONS){var r=this.target.getPositionX(),s=this.target.getPositionY(),o=this._previousPosition;n.x=n.x+r-o.x,n.y=n.y+s-o.y,e+=n.x,i+=n.y,o.x=e,o.y=i,this.target.setPosition(e,i)}else this.target.setPosition(n.x+e,n.y+i)}},reverse:function(){var t=new cc.MoveBy(this._duration,cc.p(-this._positionDelta.x,-this._positionDelta.y));return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.moveBy=function(t,e,i){return new cc.MoveBy(t,e,i)},cc.MoveTo=cc.MoveBy.extend({_endPosition:null,ctor:function(t,e,i){cc.MoveBy.prototype.ctor.call(this),this._endPosition=cc.p(0,0),void 0!==e&&this.initWithDuration(t,e,i)},initWithDuration:function(t,e,i){return!!cc.MoveBy.prototype.initWithDuration.call(this,t,e,i)&&(void 0!==e.x&&(i=e.y,e=e.x),this._endPosition.x=e,this._endPosition.y=i,!0)},clone:function(){var t=new cc.MoveTo;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._endPosition),t},startWithTarget:function(t){cc.MoveBy.prototype.startWithTarget.call(this,t),this._positionDelta.x=this._endPosition.x-t.getPositionX(),this._positionDelta.y=this._endPosition.y-t.getPositionY()}}),cc.moveTo=function(t,e,i){return new cc.MoveTo(t,e,i)},cc.SkewTo=cc.ActionInterval.extend({_skewX:0,_skewY:0,_startSkewX:0,_startSkewY:0,_endSkewX:0,_endSkewY:0,_deltaX:0,_deltaY:0,ctor:function(t,e,i){cc.ActionInterval.prototype.ctor.call(this),void 0!==i&&this.initWithDuration(t,e,i)},initWithDuration:function(t,e,i){var n=!1;return cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._endSkewX=e,this._endSkewY=i,n=!0),n},clone:function(){var t=new cc.SkewTo;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._endSkewX,this._endSkewY),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._startSkewX=t.skewX%180,this._deltaX=this._endSkewX-this._startSkewX,this._deltaX>180&&(this._deltaX-=360),this._deltaX<-180&&(this._deltaX+=360),this._startSkewY=t.skewY%360,this._deltaY=this._endSkewY-this._startSkewY,this._deltaY>180&&(this._deltaY-=360),this._deltaY<-180&&(this._deltaY+=360)},update:function(t){t=this._computeEaseTime(t),this.target.skewX=this._startSkewX+this._deltaX*t,this.target.skewY=this._startSkewY+this._deltaY*t}}),cc.skewTo=function(t,e,i){return new cc.SkewTo(t,e,i)},cc.SkewBy=cc.SkewTo.extend({ctor:function(t,e,i){cc.SkewTo.prototype.ctor.call(this),void 0!==i&&this.initWithDuration(t,e,i)},initWithDuration:function(t,e,i){var n=!1;return cc.SkewTo.prototype.initWithDuration.call(this,t,e,i)&&(this._skewX=e,this._skewY=i,n=!0),n},clone:function(){var t=new cc.SkewBy;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._skewX,this._skewY),t},startWithTarget:function(t){cc.SkewTo.prototype.startWithTarget.call(this,t),this._deltaX=this._skewX,this._deltaY=this._skewY,this._endSkewX=this._startSkewX+this._deltaX,this._endSkewY=this._startSkewY+this._deltaY},reverse:function(){var t=new cc.SkewBy(this._duration,-this._skewX,-this._skewY);return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.skewBy=function(t,e,i){return new cc.SkewBy(t,e,i)},cc.JumpBy=cc.ActionInterval.extend({_startPosition:null,_delta:null,_height:0,_jumps:0,_previousPosition:null,ctor:function(t,e,i,n,r){cc.ActionInterval.prototype.ctor.call(this),this._startPosition=cc.p(0,0),this._previousPosition=cc.p(0,0),this._delta=cc.p(0,0),void 0!==n&&this.initWithDuration(t,e,i,n,r)},initWithDuration:function(t,e,i,n,r){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(void 0===r&&(r=n,n=i,i=e.y,e=e.x),this._delta.x=e,this._delta.y=i,this._height=n,this._jumps=r,!0)},clone:function(){var t=new cc.JumpBy;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._delta,this._height,this._jumps),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t);var e=t.getPositionX(),i=t.getPositionY();this._previousPosition.x=e,this._previousPosition.y=i,this._startPosition.x=e,this._startPosition.y=i},update:function(t){if(t=this._computeEaseTime(t),this.target){var e=t*this._jumps%1,i=4*this._height*e*(1-e);i+=this._delta.y*t;var n=this._delta.x*t,r=this._startPosition;if(cc.macro.ENABLE_STACKABLE_ACTIONS){var s=this.target.getPositionX(),o=this.target.getPositionY(),a=this._previousPosition;r.x=r.x+s-a.x,r.y=r.y+o-a.y,n+=r.x,i+=r.y,a.x=n,a.y=i,this.target.setPosition(n,i)}else this.target.setPosition(r.x+n,r.y+i)}},reverse:function(){var t=new cc.JumpBy(this._duration,cc.p(-this._delta.x,-this._delta.y),this._height,this._jumps);return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.jumpBy=function(t,e,i,n,r){return new cc.JumpBy(t,e,i,n,r)},cc.JumpTo=cc.JumpBy.extend({_endPosition:null,ctor:function(t,e,i,n,r){cc.JumpBy.prototype.ctor.call(this),this._endPosition=cc.p(0,0),void 0!==n&&this.initWithDuration(t,e,i,n,r)},initWithDuration:function(t,e,i,n,r){return!!cc.JumpBy.prototype.initWithDuration.call(this,t,e,i,n,r)&&(void 0===r&&(i=e.y,e=e.x),this._endPosition.x=e,this._endPosition.y=i,!0)},startWithTarget:function(t){cc.JumpBy.prototype.startWithTarget.call(this,t),this._delta.x=this._endPosition.x-this._startPosition.x,this._delta.y=this._endPosition.y-this._startPosition.y},clone:function(){var t=new cc.JumpTo;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._endPosition,this._height,this._jumps),t}}),cc.jumpTo=function(t,e,i,n,r){return new cc.JumpTo(t,e,i,n,r)},cc.bezierAt=function(t,e,i,n,r){return Math.pow(1-r,3)*t+3*r*Math.pow(1-r,2)*e+3*Math.pow(r,2)*(1-r)*i+Math.pow(r,3)*n},cc.BezierBy=cc.ActionInterval.extend({_config:null,_startPosition:null,_previousPosition:null,ctor:function(t,e){cc.ActionInterval.prototype.ctor.call(this),this._config=[],this._startPosition=cc.p(0,0),this._previousPosition=cc.p(0,0),e&&this.initWithDuration(t,e)},initWithDuration:function(t,e){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._config=e,!0)},clone:function(){var t=new cc.BezierBy;this._cloneDecoration(t);for(var e=[],i=0;ie/2?255:0}},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._originalState=t.opacity},stop:function(){this.target.opacity=this._originalState,cc.ActionInterval.prototype.stop.call(this)},reverse:function(){var t=new cc.Blink(this._duration,this._times);return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.blink=function(t,e){return new cc.Blink(t,e)},cc.FadeTo=cc.ActionInterval.extend({_toOpacity:0,_fromOpacity:0,ctor:function(t,e){cc.ActionInterval.prototype.ctor.call(this),void 0!==e&&this.initWithDuration(t,e)},initWithDuration:function(t,e){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._toOpacity=e,!0)},clone:function(){var t=new cc.FadeTo;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._toOpacity),t},update:function(t){t=this._computeEaseTime(t);var e=void 0!==this._fromOpacity?this._fromOpacity:255;this.target.opacity=e+(this._toOpacity-e)*t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._fromOpacity=t.opacity}}),cc.fadeTo=function(t,e){return new cc.FadeTo(t,e)},cc.FadeIn=cc.FadeTo.extend({_reverseAction:null,ctor:function(t){cc.FadeTo.prototype.ctor.call(this),null==t&&(t=0),this.initWithDuration(t,255)},reverse:function(){var t=new cc.FadeOut;return t.initWithDuration(this._duration,0),this._cloneDecoration(t),this._reverseEaseList(t),t},clone:function(){var t=new cc.FadeIn;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._toOpacity),t},startWithTarget:function(t){this._reverseAction&&(this._toOpacity=this._reverseAction._fromOpacity),cc.FadeTo.prototype.startWithTarget.call(this,t)}}),cc.fadeIn=function(t){return new cc.FadeIn(t)},cc.FadeOut=cc.FadeTo.extend({ctor:function(t){cc.FadeTo.prototype.ctor.call(this),null==t&&(t=0),this.initWithDuration(t,0)},reverse:function(){var t=new cc.FadeIn;return t._reverseAction=this,t.initWithDuration(this._duration,255),this._cloneDecoration(t),this._reverseEaseList(t),t},clone:function(){var t=new cc.FadeOut;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._toOpacity),t}}),cc.fadeOut=function(t){return new cc.FadeOut(t)},cc.TintTo=cc.ActionInterval.extend({_to:null,_from:null,ctor:function(t,e,i,n){cc.ActionInterval.prototype.ctor.call(this),this._to=cc.color(0,0,0),this._from=cc.color(0,0,0),e instanceof cc.Color&&(n=e.b,i=e.g,e=e.r),void 0!==n&&this.initWithDuration(t,e,i,n)},initWithDuration:function(t,e,i,n){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._to=cc.color(e,i,n),!0)},clone:function(){var t=new cc.TintTo;this._cloneDecoration(t);var e=this._to;return t.initWithDuration(this._duration,e.r,e.g,e.b),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._from=this.target.color},update:function(t){t=this._computeEaseTime(t);var e=this._from,i=this._to;e&&this.target.setColor(cc.color(e.r+(i.r-e.r)*t,e.g+(i.g-e.g)*t,e.b+(i.b-e.b)*t))}}),cc.tintTo=function(t,e,i,n){return new cc.TintTo(t,e,i,n)},cc.TintBy=cc.ActionInterval.extend({_deltaR:0,_deltaG:0,_deltaB:0,_fromR:0,_fromG:0,_fromB:0,ctor:function(t,e,i,n){cc.ActionInterval.prototype.ctor.call(this),void 0!==n&&this.initWithDuration(t,e,i,n)},initWithDuration:function(t,e,i,n){return!!cc.ActionInterval.prototype.initWithDuration.call(this,t)&&(this._deltaR=e,this._deltaG=i,this._deltaB=n,!0)},clone:function(){var t=new cc.TintBy;return this._cloneDecoration(t),t.initWithDuration(this._duration,this._deltaR,this._deltaG,this._deltaB),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t);var e=t.color;this._fromR=e.r,this._fromG=e.g,this._fromB=e.b},update:function(t){t=this._computeEaseTime(t),this.target.color=cc.color(this._fromR+this._deltaR*t,this._fromG+this._deltaG*t,this._fromB+this._deltaB*t)},reverse:function(){var t=new cc.TintBy(this._duration,-this._deltaR,-this._deltaG,-this._deltaB);return this._cloneDecoration(t),this._reverseEaseList(t),t}}),cc.tintBy=function(t,e,i,n){return new cc.TintBy(t,e,i,n)},cc.DelayTime=cc.ActionInterval.extend({update:function(t){},reverse:function(){var t=new cc.DelayTime(this._duration);return this._cloneDecoration(t),this._reverseEaseList(t),t},clone:function(){var t=new cc.DelayTime;return this._cloneDecoration(t),t.initWithDuration(this._duration),t}}),cc.delayTime=function(t){return new cc.DelayTime(t)},cc.ReverseTime=cc.ActionInterval.extend({_other:null,ctor:function(t){cc.ActionInterval.prototype.ctor.call(this),this._other=null,t&&this.initWithAction(t)},initWithAction:function(t){if(!t)throw new Error("cc.ReverseTime.initWithAction(): action must be non null");if(t===this._other)throw new Error("cc.ReverseTime.initWithAction(): the action was already passed in.");return!!cc.ActionInterval.prototype.initWithDuration.call(this,t._duration)&&(this._other=t,!0)},clone:function(){var t=new cc.ReverseTime;return this._cloneDecoration(t),t.initWithAction(this._other.clone()),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._other.startWithTarget(t)},update:function(t){t=this._computeEaseTime(t),this._other&&this._other.update(1-t)},reverse:function(){return this._other.clone()},stop:function(){this._other.stop(),cc.Action.prototype.stop.call(this)}}),cc.reverseTime=function(t){return new cc.ReverseTime(t)},cc.Animate=cc.ActionInterval.extend({_animation:null,_nextFrame:0,_origFrame:null,_executedLoops:0,_splitTimes:null,_currFrameIndex:0,ctor:function(t){cc.ActionInterval.prototype.ctor.call(this),this._splitTimes=[],t&&this.initWithAnimation(t)},getAnimation:function(){return this._animation},setAnimation:function(t){this._animation=t},getCurrentFrameIndex:function(){return this._currFrameIndex},initWithAnimation:function(t){if(!t)throw new Error("cc.Animate.initWithAnimation(): animation must be non-NULL");var e=t.getDuration();if(this.initWithDuration(e*t.getLoops())){this._nextFrame=0,this.setAnimation(t),this._origFrame=null,this._executedLoops=0;var i=this._splitTimes;i.length=0;var n=0,r=e/t.getTotalDelayUnits(),s=t.getFrames();cc.js.array.verifyType(s,cc.AnimationFrame);for(var o=0;othis._executedLoops&&(this._nextFrame=0,this._executedLoops++),t%=1}for(var e=this._animation.getFrames(),i=e.length,n=this._splitTimes,r=this._nextFrame;r0)for(var n=e.length-1;n>=0;n--){var r=e[n];if(!r)break;i.push(r.clone())}var s=new cc.SpriteFrameAnimation(i,t.getDelayPerUnit(),t.getLoops());s.setRestoreOriginalFrame(t.getRestoreOriginalFrame());var o=new cc.Animate(s);return this._cloneDecoration(o),this._reverseEaseList(o),o},stop:function(){this._animation.getRestoreOriginalFrame()&&this.target&&this.target.setSpriteFrame(this._origFrame),cc.Action.prototype.stop.call(this)}}),cc.animate=function(t){return new cc.Animate(t)},cc.TargetedAction=cc.ActionInterval.extend({_action:null,_forcedTarget:null,ctor:function(t,e){cc.ActionInterval.prototype.ctor.call(this),e&&this.initWithTarget(t,e)},initWithTarget:function(t,e){return!!this.initWithDuration(e._duration)&&(this._forcedTarget=t,this._action=e,!0)},clone:function(){var t=new cc.TargetedAction;return this._cloneDecoration(t),t.initWithTarget(this._forcedTarget,this._action.clone()),t},startWithTarget:function(t){cc.ActionInterval.prototype.startWithTarget.call(this,t),this._action.startWithTarget(this._forcedTarget)},stop:function(){this._action.stop()},update:function(t){t=this._computeEaseTime(t),this._action.update(t)},getForcedTarget:function(){return this._forcedTarget},setForcedTarget:function(t){this._forcedTarget!==t&&(this._forcedTarget=t)}}),cc.targetedAction=function(t,e){return new cc.TargetedAction(t,e)}}),{}],9:[(function(t,e,i){cc.ActionManager=cc._Class.extend({_elementPool:[],_searchElementByTarget:function(t,e){for(var i=0;i=n&&i.actionIndex--;break}}else cc.logID(1001)}},removeActionByTag:function(t,e){t===cc.Action.TAG_INVALID&&cc.logID(1002),cc.assertID(e,1003);var i=this._hashTargets[e.__instanceId];if(i)for(var n=i.actions.length,r=0;r=t&&e.actionIndex--,0===e.actions.length&&this._deleteHashElement(e)},_deleteHashElement:function(t){var e=!1;if(t&&!t.lock&&this._hashTargets[t.target.__instanceId]){delete this._hashTargets[t.target.__instanceId];for(var i=this._arrayTargets,n=0,r=i.length;n0?e:null})(n);for(var p=0,m=r.length;p1e-6){S=!1;break}return u._findFrameIndex=S?c:d,u}function r(t,e){var i=e.props,r=e.comps;if(i)for(var s in i){var a=n(t,s,i[s]);o.push(a)}if(r)for(var c in r){var h=t.getComponent(c);if(h){var l=r[c];for(var s in l){a=n(h,s,l[s]);o.push(a)}}}}var s=e.clip,o=e.curves;o.length=0,e.duration=s.duration,e.speed=s.speed,e.wrapMode=s.wrapMode,e.frameRate=s.sample,(e.wrapMode&_.Loop)===_.Loop?e.repeatCount=1/0:e.repeatCount=1;var f=s.curveData,p=f.paths;r(t,f);for(var m in p){var g=cc.find(m,t);if(g){r(g,p[m])}}var y=s.events;if(y)for(var v,x=0,C=y.length;x=0?T=v.events[S]:(T=new u,v.ratios.push(A),v.events.push(T)),T.add(b.func,b.params)}}var s=cc.js,o=t("./playable"),a=t("./animation-curves").DynamicAnimCurve,c=t("./animation-curves").quickFindIndex,h=t("./motion-path-helper").sampleMotionPaths,l=t("./animation-curves").EventAnimCurve,u=t("./animation-curves").EventInfo,_=t("./types").WrapModeMask,d=t("../core/utils/binary-search").binarySearchEpsilon;s.extend(n,o);var f=n.prototype;f.playState=function(t,e){t.clip&&(t.curveLoaded||r(this.target,t),t.animator=this,t.play(),"number"==typeof e&&t.setTime(e),this.play())},f.stopStatesExcept=function(t){var e=this._anims,i=e.array;for(e.i=0;e.i=0?(this._anims.fastRemoveAt(e),0===this._anims.array.length&&this.stop()):cc.errorID(3908),t.animator=null},f.sample=function(){var t=this._anims,e=t.array;for(t.i=0;t.i=o)a=r[o-1];else{var h=r[c-1],l="number"==typeof h,u=h&&h.lerp;if(l||u){var _=s[c-1],d=s[c],f=this.types[c-1],p=(e-_)/(d-_);f&&(p=n(p,f));var m=r[c];l?a=h+(m-h)*p:u&&(a=h.lerp(m,p))}else a=h}else a=r[c];var g=this.subProps;if(g){for(var y=this.target[this.prop],v=y,x=0;x0?((l&o.PingPong)===o.PingPong?c*=-1:f=n,d++):1===c&&f===n-1&&hu)break}f+=c,cc.director.getAnimationManager().pushDelayEvent(this,"_fireEvent",[f])}while(f!==h&&f>-1&&f=this.events.length||this._ignoreIndex===t)){var e=this.events[t].events;if(this.target.isValid)for(var i=this.target._components,n=0;nr)return i;var s=(e=(e-n)/(r-n))/(1/i),o=0|s;return s-o<1e-6?o:~(o+1)}}}),{"../core/utils/binary-search":222,"./bezier":16,"./types":21}],14:[(function(t,e,n){var r=cc.js,s=cc.Class({ctor:function(){this.__instanceId=cc.ClassManager.getNewInstanceId(),this._anims=new r.array.MutableForwardIterator([]),this._delayEvents=[]},update:function(t){var e=this._anims,n=e.array;for(e.i=0;e.i=0?this._anims.fastRemoveAt(e):cc.errorID(3907)},pushDelayEvent:function(t,e,i){this._delayEvents.push({target:t,func:e,args:i})}});cc.AnimationManager=e.exports=s}),{}],15:[(function(t,e,i){function n(t,e){a.call(this),cc.EventTarget.call(this),this._currentFramePlayed=!1,this._delay=0,this._delayTime=0,this._wrappedInfo=new h,this._lastWrappedInfo=null,this._process=r,this._clip=t,this._name=e||t&&t.name,this.animator=null,this.curves=[],this.delay=0,this.repeatCount=1,this.duration=1,this.speed=1,this.wrapMode=l.Normal,this.time=0,this._emit=this.emit,this.emit=function(){for(var t=new Array(arguments.length),e=0,i=t.length;e1&&(0|t.iterations)>(0|i.iterations)&&this.emit("lastframe",this),i.set(t)}t.stopped&&(this.stop(),this.emit("finished",this))}function s(){var t=this.time,e=this.duration;t>e?0===(t%=e)&&(t=e):t<0&&0!==(t%=e)&&(t+=e);for(var i=t/e,n=this.curves,r=0,s=n.length;r0&&this._lastIterations>i||this.time<0&&this._lastIterations0&&(this._delayTime-=t,this._delayTime>0)||(this._currentFramePlayed?this.time+=t*this.speed:this._currentFramePlayed=!0,this._process())},_._needRevers=function(t){var e=this.wrapMode,i=!1;if((e&u.PingPong)===u.PingPong){t-(0|t)==0&&t>0&&(t-=1);1&t&&(i=!i)}return(e&u.Reverse)===u.Reverse&&(i=!i),i},_.getWrappedInfo=function(t,e){e=e||new h;var i=!1,n=this.duration,r=this.repeatCount,s=t>0?t/n:-t/n;if(s>=r){s=r,i=!0;var o=r-(0|r);0===o&&(o=1),t=o*n*(t>0?1:-1)}if(t>n){var a=t%n;t=0===a?n:a}else t<0&&0!==(t%=n)&&(t+=n);var c=!1,l=this._wrapMode&u.ShouldWrap;l&&(c=this._needRevers(s));var _=c?-1:1;return this.speed<0&&(_*=-1),l&&c&&(t=n-t),e.ratio=t/n,e.time=t,e.direction=_,e.stopped=i,e.iterations=s,e},_.sample=function(){for(var t=this.getWrappedInfo(this.time,this._wrappedInfo),e=this.curves,i=0,n=e.length;i0}),(function(){this.curves.length=0})),o.getset(_,"wrapMode",(function(){return this._wrapMode}),(function(t){this._wrapMode=t,this.time=0,t&u.Loop?this.repeatCount=1/0:this.repeatCount=1})),o.getset(_,"repeatCount",(function(){return this._repeatCount}),(function(t){this._repeatCount=t;var e=this._wrapMode&u.ShouldWrap,i=(this.wrapMode&u.Reverse)===u.Reverse;this._process=t!==1/0||e||i?r:s})),o.getset(_,"delay",(function(){return this._delay}),(function(t){this._delayTime=this._delay=t})),cc.AnimationState=e.exports=n}),{"./playable":20,"./types":21}],16:[(function(t,e,i){function n(t,e,i,n,r){var s=1-r;return t*s*s*s+3*e*s*s*r+3*i*s*r*r+n*r*r*r}function r(t){return t<0?-Math.pow(-t,1/3):Math.pow(t,1/3)}function s(t,e){var i=(function(t,e){var i,n,s,u,_,d=e-0,f=e-t[0],p=3*d,m=3*f,g=3*(e-t[2]),y=1/(-d+m-g+(e-1)),v=(p-6*f+g)*y,x=v*(1/3),C=(-p+m)*y,T=1/3*(3*C-v*v),b=T*(1/3),A=(2*v*v*v-9*v*C+d*y*27)/27,S=A/2,w=S*S+b*b*b;if(w<0){var E=1/3*-T,I=l(E*E*E),R=-A/(2*I),P=a(R<-1?-1:R>1?1:R),O=2*r(I);return s=O*o(P*(1/3))-x,u=O*o((P+h)*(1/3))-x,_=O*o((P+2*h)*(1/3))-x,0<=s&&s<=1?0<=u&&u<=1?0<=_&&_<=1?c(s,u,_):c(s,u):0<=_&&_<=1?c(s,_):s:0<=u&&u<=1?0<=_&&_<=1?c(u,_):u:_}if(0===w)return i=S<0?r(-S):-r(S),s=2*i-x,u=-i-x,0<=s&&s<=1?0<=u&&u<=1?c(s,u):s:u;var B=l(w);return i=r(-S+B),n=r(S+B),s=i-n-x})(t,e),n=1-i;return 0*n*n*n+3*t[1]*i*n*n+3*t[3]*i*i*n+1*i*i*i}var o=Math.cos,a=Math.acos,c=Math.max,h=2*Math.PI,l=Math.sqrt;e.exports={bezier:n,bezierByTime:s}}),{}],17:[(function(t,e,i){function n(t,e){return function(i){return i<.5?e(2*i)/2:t(2*i-1)/2+.5}}var r={constant:function(){return 0},linear:function(t){return t},quadIn:function(t){return t*t},quadOut:function(t){return t*(2-t)},quadInOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},cubicIn:function(t){return t*t*t},cubicOut:function(t){return--t*t*t+1},cubicInOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},quartIn:function(t){return t*t*t*t},quartOut:function(t){return 1- --t*t*t*t},quartInOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},quintIn:function(t){return t*t*t*t*t},quintOut:function(t){return--t*t*t*t*t+1},quintInOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},sineIn:function(t){return 1-Math.cos(t*Math.PI/2)},sineOut:function(t){return Math.sin(t*Math.PI/2)},sineInOut:function(t){return.5*(1-Math.cos(Math.PI*t))},expoIn:function(t){return 0===t?0:Math.pow(1024,t-1)},expoOut:function(t){return 1===t?1:1-Math.pow(2,-10*t)},expoInOut: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)))},circIn:function(t){return 1-Math.sqrt(1-t*t)},circOut:function(t){return Math.sqrt(1- --t*t)},circInOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},elasticIn: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))},elasticOut: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)},elasticInOut: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)},backIn:function(t){return t*t*(2.70158*t-1.70158)},backOut:function(t){return--t*t*(2.70158*t+1.70158)+1},backInOut:function(t){return(t*=2)<1?t*t*(3.5949095*t-2.5949095)*.5:.5*((t-=2)*t*(3.5949095*t+2.5949095)+2)},bounceOut: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},smooth:function(t){return t<=0?0:t>=1?1:t*t*(3-2*t)},fade:function(t){return t<=0?0:t>=1?1:t*t*t*(t*(6*t-15)+10)}};r.quadOutIn=n(r.quadIn,r.quadOut),r.cubicOutIn=n(r.cubicIn,r.cubicOut),r.quartOutIn=n(r.quartIn,r.quartOut),r.quintOutIn=n(r.quintIn,r.quintOut),r.sineOutIn=n(r.sineIn,r.sineOut),r.expoOutIn=n(r.expoIn,r.expoOut),r.circOutIn=n(r.circIn,r.circOut),r.backOutIn=n(r.backIn,r.backOut),r.backOutIn=n(r.backIn,r.backOut),r.bounceIn=function(t){return 1-r.bounceOut(1-t)},r.bounceInOut=function(t){return t<.5?.5*r.bounceIn(2*t):.5*r.bounceOut(2*t-1)+.5},r.bounceOutIn=n(r.bounceIn,r.bounceOut),cc.Easing=e.exports=r}),{}],18:[(function(t,e,i){t("./bezier"),t("./easing"),t("./types"),t("./motion-path-helper"),t("./animation-curves"),t("./animation-clip"),t("./animation-manager"),t("./animation-state"),t("./animation-animator")}),{"./animation-animator":11,"./animation-clip":12,"./animation-curves":13,"./animation-manager":14,"./animation-state":15,"./bezier":16,"./easing":17,"./motion-path-helper":19,"./types":21}],19:[(function(t,e,i){function n(t){this.points=t||[],this.beziers=[],this.ratios=[],this.progresses=[],this.length=0,this.computeBeziers()}function r(){this.start=l(),this.end=l(),this.startCtrlPoint=l(),this.endCtrlPoint=l()}function s(t,e,i,r){function s(t){return t instanceof cc.Vec2?{in:t,pos:t,out:t}:Array.isArray(t)&&6===t.length?{in:l(t[2],t[3]),pos:l(t[0],t[1]),out:l(t[4],t[5])}:{in:cc.Vec2.ZERO,pos:cc.Vec2.ZERO,out:cc.Vec2.ZERO}}function c(t,e,i){f.push(t),p.push(e),m.push(i)}var u=e.values;if(0!==t.length&&0!==u.length)if(1!==(u=u.map((function(t){return l(t[0],t[1])}))).length){for(var _=e.types,d=e.ratios,f=e.values=[],p=e.types=[],m=e.ratios=[],g=0,y=o.Linear,v=0,x=t.length;v0){var O=[];O.push(s(S));for(var B=0,D=T.length;B1e-6;){var F,k,z,V;if((C=a(C=R,E))<0)V=(0-C)*(k=L.beziers[0]).getLength(),z=k.start.sub(k.endCtrlPoint).normalize(),F=k.start.add(z.mul(V));else if(C>1)V=(C-1)*(k=L.beziers[L.beziers.length-1]).getLength(),z=k.end.sub(k.startCtrlPoint).normalize(),F=k.end.add(z.mul(V));else{var G=h(N,C);G<0&&(G=~G),C-=G>0?N[G-1]:0,C/=L.ratios[G],F=L.beziers[G].getPointAt(C)}I.push(F),R+=P}}else for(;1-R>1e-6;)C=a(C=R,E),I.push(S.lerp(w,C)),R+=P;y="constant"===E?E:o.Linear;for(B=0,D=I.length;B1e-6?(R-1)*A:0}d[d.length-1]!==m[m.length-1]&&c(u[u.length-1],y,d[d.length-1])}else e.values=u}var o=t("./animation-curves").DynamicAnimCurve,a=t("./animation-curves").computeRatioByType,c=t("./bezier").bezier,h=t("../core/utils/binary-search").binarySearchEpsilon,l=cc.v2;n.prototype.computeBeziers=function(){this.beziers.length=0,this.ratios.length=0,this.progresses.length=0,this.length=0;for(var t,e=1;e0)){c=r;break}c=r-1}if(r=c,n[r]===i){return r/(s-1)}var h=n[r];return(r+(i-h)/(n[r+1]-h))/(s-1)},e.exports={sampleMotionPaths:s,Curve:n,Bezier:r}}),{"../core/utils/binary-search":222,"./animation-curves":13,"./bezier":16}],20:[(function(t,e,i){function n(){this._isPlaying=!1,this._isPaused=!1,this._stepOnce=!1}var r=cc.js,s=n.prototype;r.get(s,"isPlaying",(function(){return this._isPlaying}),!0),r.get(s,"isPaused",(function(){return this._isPaused}),!0);var o=function(){};s.onPlay=o,s.onPause=o,s.onResume=o,s.onStop=o,s.onError=o,s.play=function(){this._isPlaying?this._isPaused?(this._isPaused=!1,this.onResume()):this.onError("already-playing"):(this._isPlaying=!0,this.onPlay())},s.stop=function(){this._isPlaying&&(this._isPlaying=!1,this.onStop(),this._isPaused=!1)},s.pause=function(){this._isPlaying&&!this._isPaused&&(this._isPaused=!0,this.onPause())},s.resume=function(){this._isPlaying&&this._isPaused&&(this._isPaused=!1,this.onResume())},s.step=function(){this.pause(),this._stepOnce=!0,this._isPlaying||this.play()},e.exports=n}),{}],21:[(function(t,e,i){function n(t){t?this.set(t):(this.ratio=0,this.time=0,this.direction=1,this.stopped=!0,this.iterations=0,this.frameIndex=void 0)}cc.js;var r={Loop:2,ShouldWrap:4,PingPong:22,Reverse:36},s=cc.Enum({Default:0,Normal:1,Reverse:r.Reverse,Loop:r.Loop,LoopReverse:r.Loop|r.Reverse,PingPong:r.PingPong,PingPongReverse:r.PingPong|r.Reverse});cc.WrapMode=s,n.prototype.set=function(t){this.ratio=t.ratio,this.time=t.time,this.direction=t.direction,this.stopped=t.stopped,this.iterations=t.iterations,this.frameIndex=t.frameIndex},e.exports={WrapModeMask:r,WrapMode:s,WrappedInfo:n}}),{}],22:[(function(t,e,i){var n=t("../core/event/event-target"),r=t("../core/platform/CCSys"),s=!1,o=[],a=function(t){n.call(this),this._src=t,this._audioType=a.Type.UNKNOWN,this._element=null,this._eventList={},this._state=a.State.INITIALZING,this._loaded=!1,this._onended=function(){this.emit("ended")}.bind(this)};cc.js.extend(a,n),a.Type={DOM:"AUDIO",WEBAUDIO:"WEBAUDIO",NATIVE:"NATIVE",UNKNOWN:"UNKNOWN"},a.State={ERROR:-1,INITIALZING:0,PLAYING:1,PAUSED:2},(function(t){t.preload=function(){var t=this._src,e=this;if(!t)return this._src="",this._audioType=a.Type.UNKNOWN,this._element=null,this._state=a.State.INITIALZING,void(this._loaded=!1);var i=cc.loader.getItem(t);if(i||(i=cc.loader.getItem(t+"?useDom=1")),!i||!i.complete)return cc.loader.load(t,(function(i){if(!i){var n=cc.loader.getItem(t);e.mount(n.element||n.buffer),e.emit("load")}}));e.mount(i.element||i.buffer),e.emit("load")},t._bindEnded=function(t){t=t||this._onended,this._audioType===a.Type.DOM?this._element.addEventListener("ended",t):this._element.onended=t},t._unbindEnded=function(){this._audioType===a.Type.DOM?this._element.removeEventListener("ended",this._onended):this._element.onended=null},t.mount=function(t){r.platform===r.WECHAT_GAME||t instanceof HTMLElement?(this._element=document.createElement("audio"),this._element.src=t.src,this._audioType=a.Type.DOM):(this._element=new c(t,this),this._audioType=a.Type.WEBAUDIO),this._state=a.State.INITIALZING,this._loaded=!0},t.play=function(){this._element&&(this._bindEnded(),this._element.play(),this.emit("play"),this._state=a.State.PLAYING,r.platform!==r.WECHAT_GAME&&this._audioType===a.Type.DOM&&this._element.paused&&o.push({instance:this,offset:0,audio:this._element}),s||(s=!0,cc.game.canvas.addEventListener("touchstart",(function(){for(var t;t=o.pop();)t.audio.play(t.offset)}))))},t.destroy=function(){0},t.pause=function(){this._element&&(this._unbindEnded(),this._element.pause(),this.emit("pause"),this._state=a.State.PAUSED)},t.resume=function(){this._element&&0!==this._element.currentTime&&(this._bindEnded(),this._element.play(),this.emit("resume"),this._state=a.State.PLAYING)},t.stop=function(){if(this._element){try{this._element.currentTime=0}catch(t){}this._element.pause();for(var t=0;tthis._buffer.duration)})),t.__defineGetter__("loop",(function(){return this._loop})),t.__defineSetter__("loop",(function(t){return this._currentSource&&(this._currentSource.loop=t),this._loop=t})),t.__defineGetter__("volume",(function(){return this._volume})),t.__defineSetter__("volume",(function(t){return this._volume=t,this._gainObj.gain.setTargetAtTime?this._gainObj.gain.setTargetAtTime(this._volume,this._context.currentTime,.01):this._volume.gain.value=t,r.os===r.OS_IOS&&!this.paused&&this._currentSource&&(this._currentSource.onended=null,this.pause(),this.play()),t})),t.__defineGetter__("currentTime",(function(){return this.paused?this.playedLength:(this.playedLength=this._context.currentTime-this._startTime,this.playedLength%=this._buffer.duration,this.playedLength)})),t.__defineSetter__("currentTime",(function(t){return this.paused?this.playedLength=t:(this.pause(),this.playedLength=t,this.play()),t})),t.__defineGetter__("duration",(function(){return this._buffer.duration}))})(c.prototype),e.exports=cc.Audio=a}),{"../core/event/event-target":112,"../core/platform/CCSys":185}],23:[(function(t,e,i){var n=t("./CCAudio"),r=0,s={},o={},a=function(t){return s[t]},c={AudioState:n.State,_maxWebAudioSize:2097152,_maxAudioInstance:24,_id2audio:s,play:function(t,e,i){var a=(function(t){var e=r++,i=o[t];i||(i=o[t]=[]);var a;if(c._maxAudioInstance<=i.length){var h=i.shift(),l=s[h];l.stop(),l.destroy()}var u=function(){var t=this.instanceId;delete s[t];var e=i.indexOf(t);cc.js.array.fastRemoveAt(i,e)};return(a=new n(t)).on("ended",u),a.on("stop",u),s[e]=a,a.instanceId=e,i.push(e),a})(t),h=function(){a.setLoop(e||!1),("number"!=typeof i||isNaN(i))&&(i=1),a.setVolume(i),a.play()};return a.__callback=h,a.on("load",h),a.preload(),a.instanceId},setLoop:function(t,e){var i=a(t);i&&i.setLoop&&i.setLoop(e)},isLoop:function(t){var e=a(t);return!(!e||!e.isLoop)&&e.isLoop()},setVolume:function(t,e){var i=a(t);i&&(i._loaded||i.once("load",(function(){i.setVolume&&i.setVolume(e)})),i.setVolume&&i.setVolume(e))},getVolume:function(t){var e=a(t);return e&&e.getVolume?e.getVolume():1},setCurrentTime:function(t,e){var i=a(t);return!!i&&(i._loaded?(i.setCurrentTime&&i.setCurrentTime(e),!0):(i.once("load",(function(){i.setCurrentTime&&i.setCurrentTime(e)})),!0))},getCurrentTime:function(t){var e=a(t);return e&&e.getCurrentTime?e.getCurrentTime():0},getDuration:function(t){var e=a(t);return e&&e.getDuration?e.getDuration():0},getState:function(t){var e=a(t);return e&&e.getState?e.getState():this.AudioState.ERROR},setFinishCallback:function(t,e){var i=a(t);i&&(i.off("ended",i._finishCallback),i._finishCallback=e,i.on("ended",i._finishCallback))},pause:function(t){var e=a(t);return!(!e||!e.pause)&&(e.pause(),!0)},_pauseIDCache:[],pauseAll:function(){for(var t in s){var e=s[t];e.getState()===n.State.PLAYING&&(this._pauseIDCache.push(t),e.pause())}},resume:function(t){var e=a(t);if(!e||!e.resume)return!1;0===e.getCurrentTime()?e.play():e.resume()},resumeAll:function(){for(;this._pauseIDCache.length>0;){var t=this._pauseIDCache.pop(),e=a(t);e&&e.resume&&e.resume()}},stop:function(t){var e=a(t);return!(!e||!e.stop)&&(e.off("load",e.__callback),e.stop(),e.destroy(),!0)},stopAll:function(){for(var t in s){var e=s[t];e&&e.stop&&(e.stop(),e.destroy(),e.off("load",e.__callback))}},setMaxAudioInstance:function(t){return this._maxAudioInstance=t},getMaxAudioInstance:function(){return this._maxAudioInstance},uncache:function(t){var e=o[t];if(e)for(;e.length>0;){var i=e.pop(),n=s[i];n&&(n.stop(),n.destroy(),delete s[i])}},uncacheAll:function(){this.stopAll();for(var t in s){var e=s[t];e&&e.destroy()}s={},o={}},getProfile:function(t){},preload:function(t,e){cc.loader.load(t,e&&function(t){t||e()})},setMaxWebAudioSize:function(t){this._maxWebAudioSize=1024*t},_breakCache:null,_break:function(){this._breakCache=[];for(var t in s){var e=s[t];e.getState()===n.State.PLAYING&&(this._breakCache.push(t),e.pause())}},_restore:function(){if(this._breakCache){for(;this._breakCache.length>0;){var t=this._breakCache.pop(),e=a(t);e&&e.resume&&e.resume()}this._breakCache=null}}};e.exports=cc.audioEngine=c;var h=t("./deprecated");h.removed(c),h.deprecated(c)}),{"./CCAudio":22,"./deprecated":24}],24:[(function(t,e,i){var n=cc.js;i.removed=function(t){function e(){cc.errorID(1403)}n.getset(t,"willPlayMusic",e,e)},i.deprecated=function(t){var e=-1,i=1,r=1,s=[];n.get(t,"playMusic",(function(){return function(n,r){return t.stop(e),e=t.play(n,r,i),n,r,e}})),n.get(t,"stopMusic",(function(){return function(){return t.stop(e),e}})),n.get(t,"pauseMusic",(function(){return function(){return t.pause(e),e}})),n.get(t,"resumeMusic",(function(){return function(){return t.resume(e),e}})),n.get(t,"rewindMusic",(function(){return function(){return t.setCurrentTime(e,0),e}})),n.get(t,"getMusicVolume",(function(){return function(){return i}})),n.get(t,"setMusicVolume",(function(){return function(n){return i=n,t.setVolume(e,i),i}})),n.get(t,"isMusicPlaying",(function(){return function(){return t.getState(e)===t.AudioState.PLAYING}})),n.get(t,"playEffect",(function(){return function(e,i,n){return t.play(e,i||!1,void 0===n?r:n)}})),n.get(t,"setEffectsVolume",(function(i){return function(i){r=i;var n=t._id2audio;for(var s in n)s!==e&&t.setVolume(s,i)}})),n.get(t,"getEffectsVolume",(function(){return function(){return r}})),n.get(t,"pauseEffect",(function(){return function(e){return t.pause(e)}})),n.get(t,"pauseAllEffects",(function(){return function(){s.length=0;var i=t._id2audio;for(var n in i)if(n!==e){var r=i[n];r.getState()===t.AudioState.PLAYING&&(s.push(n),r.pause())}}})),n.get(t,"resumeEffect",(function(){return function(e){t.resume(e)}})),n.get(t,"resumeAllEffects",(function(){return function(){for(var e=t._id2audio;s.length>0;){var i=e[s.pop()];i&&i.resume&&i.resume()}}})),n.get(t,"stopEffect",(function(){return function(e){return t.stop(e)}})),n.get(t,"stopAllEffects",(function(){return function(){var i=t._id2audio;for(var n in i)if(n!==e){var r=i[n];r.getState()===t.AudioState.PLAYING&&r.stop()}}})),n.get(t,"unloadEffect",(function(){return function(e){return t.stop(e)}})),n.get(t,"end",(function(){return function(){return t.stopAll()}}))}}),{}],25:[(function(t,e,i){cc.ClippingNode=_ccsg.Node.extend({inverted:!1,_alphaThreshold:0,_stencil:null,_className:"ClippingNode",_originStencilProgram:null,ctor:function(t){t=t||null,_ccsg.Node.prototype.ctor.call(this),this._stencil=t,t&&(this._originStencilProgram=t.getShaderProgram()),this.alphaThreshold=1,this.inverted=!1,this._renderCmd.initStencilBits()},onEnter:function(){_ccsg.Node.prototype.onEnter.call(this),this._stencil&&this._stencil.performRecursive(_ccsg.Node.performType.onEnter)},onEnterTransitionDidFinish:function(){_ccsg.Node.prototype.onEnterTransitionDidFinish.call(this),this._stencil&&this._stencil.performRecursive(_ccsg.Node.performType.onEnterTransitionDidFinish)},onExitTransitionDidStart:function(){this._stencil&&this._stencil.performRecursive(_ccsg.Node.performType.onExitTransitionDidStart),_ccsg.Node.prototype.onExitTransitionDidStart.call(this)},onExit:function(){this._stencil&&this._stencil.performRecursive(_ccsg.Node.performType.onExit),_ccsg.Node.prototype.onExit.call(this)},visit:function(t){this._renderCmd.clippingVisit(t&&t._renderCmd)},_visitChildren:function(){this._reorderChildDirty&&this.sortAllChildren();for(var t,e=this._children,i=0,n=e.length;i0)for(e.sortAllChildren(),i=0;i0){var n=i.length;e.sortAllChildren();for(var r=0;r=0;--n)o[i]+=s.charCodeAt(i*e+n)<<8*n;return o},cc.Codec.unzipAsArray=function(t,e){e=e||1;var i,n,r,s=this.unzip(t),o=[];for(i=0,r=s.length/e;i=0;--n)o[i]+=s.charCodeAt(i*e+n)<<8*n;return o}}),{"./base64":29,"./gzip":30}],29:[(function(t,e,i){var n=t("../core/utils/misc").BASE64_VALUES,r={name:"Jacob__Codec__Base64"};r.decode=function(t){var e,i,r,s,o,a,c=[],h=0;for(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");h>4,i=(15&s)<<4|(o=n[t.charCodeAt(h++)])>>2,r=(3&o)<<6|(a=n[t.charCodeAt(h++)]),c.push(String.fromCharCode(e)),64!==o&&c.push(String.fromCharCode(i)),64!==a&&c.push(String.fromCharCode(r));return c=c.join("")},r.decodeAsArray=function(t,e){var i,n,r,s=this.decode(t),o=[];for(i=0,r=s.length/e;i=0;--n)o[i]+=s.charCodeAt(i*e+n)<<8*n;return o},e.exports=r}),{"../core/utils/misc":226}],30:[(function(t,e,i){var n=function(t){this.data=t,this.debug=!1,this.gpflags=void 0,this.files=0,this.unzipped=[],this.buf32k=new Array(32768),this.bIdx=0,this.modeZIP=!1,this.bytepos=0,this.bb=1,this.bits=0,this.nameBuf=[],this.fileout=void 0,this.literalTree=new Array(n.LITERALS),this.distanceTree=new Array(32),this.treepos=0,this.Places=null,this.len=0,this.fpos=new Array(17),this.fpos[0]=0,this.flens=void 0,this.fmax=void 0};n.gunzip=function(t){t.constructor===Array||(t.constructor,String);return new n(t).gunzip()[0][0]},n.HufNode=function(){this.b0=0,this.b1=0,this.jump=null,this.jumppos=-1},n.LITERALS=288,n.NAMEMAX=256,n.bitReverse=[0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243,11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251,7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247,15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255],n.cplens=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],n.cplext=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,99,99],n.cpdist=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],n.cpdext=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],n.border=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],n.prototype.gunzip=function(){return this.outputArr=[],this.nextFile(),this.unzipped},n.prototype.readByte=function(){return this.bits+=8,this.bytepos>=1,0===this.bb&&(this.bb=this.readByte(),t=1&this.bb,this.bb=this.bb>>1|128),t},n.prototype.readBits=function(t){for(var e=0,i=t;i--;)e=e<<1|this.readBit();return t&&(e=n.bitReverse[e]>>8-t),e},n.prototype.flushBuffer=function(){this.bIdx=0},n.prototype.addBuffer=function(t){this.buf32k[this.bIdx++]=t,this.outputArr.push(String.fromCharCode(t)),32768===this.bIdx&&(this.bIdx=0)},n.prototype.IsPat=function(){for(;;){if(this.fpos[this.len]>=this.fmax)return-1;if(this.flens[this.fpos[this.len]]===this.len)return this.fpos[this.len]++;this.fpos[this.len]++}},n.prototype.Rec=function(){var t,e=this.Places[this.treepos];if(17===this.len)return-1;if(this.treepos++,this.len++,(t=this.IsPat())>=0)e.b0=t;else if(e.b0=32768,this.Rec())return-1;if((t=this.IsPat())>=0)e.b1=t,e.jump=null;else if(e.b1=32768,e.jump=this.Places[this.treepos],e.jumppos=this.treepos,this.Rec())return-1;return this.len--,0},n.prototype.CreateTree=function(t,e,i,n){var r;for(this.Places=t,this.treepos=0,this.flens=i,this.fmax=e,r=0;r<17;r++)this.fpos[r]=0;return this.len=0,this.Rec()?-1:0},n.prototype.DecodeValue=function(t){for(var e,i,n=0,r=t[n];;)if(this.readBit()){if(!(32768&r.b1))return r.b1;for(r=r.jump,e=t.length,i=0;i>1)>23?(a=a<<1|this.readBit())>199?a=(a-=128)<<1|this.readBit():(a-=48)>143&&(a+=136):a+=256,a<256)this.addBuffer(a);else{if(256===a)break;for(a-=257,p=this.readBits(n.cplext[a])+n.cplens[a],a=n.bitReverse[this.readBits(5)]>>3,n.cpdext[a]>8?(m=this.readBits(8),m|=this.readBits(n.cpdext[a]-8)<<8):m=this.readBits(n.cpdext[a]),m+=n.cpdist[a],a=0;ac)return this.flushBuffer(),1;for(d=i?_[i-1]:0;a--;)_[i++]=d}else{if(a=17===a?3+this.readBits(3):11+this.readBits(7),i+a>c)return this.flushBuffer(),1;for(;a--;)_[i++]=0}for(p=this.literalTree.length,i=0;i=256){var p,m;if(0==(a-=256))break;for(a--,p=this.readBits(n.cplext[a])+n.cplens[a],a=this.DecodeValue(this.distanceTree),n.cpdext[a]>8?(m=this.readBits(8),m|=this.readBits(n.cpdext[a]-8)<<8):m=this.readBits(n.cpdext[a]),m+=n.cpdist[a];p--;){o=this.buf32k[this.bIdx-m&32767];this.addBuffer(o)}}else this.addBuffer(a)}}while(!t);return this.flushBuffer(),this.byteAlign(),0},n.prototype.unzipFile=function(t){var e;for(this.gunzip(),e=0;e>>0;t=n}for(var r,s=1,o=0,a=t.length,c=0;0>>0}function n(e,i){this.index="number"==typeof i?i:0,this.i=0,this.buffer=e instanceof(x?Uint8Array:Array)?e:new(x?Uint8Array:Array)(32768),2*this.buffer.length<=this.index&&t(Error("invalid index")),this.buffer.length<=this.index&&this.f()}function r(t){this.buffer=new(x?Uint16Array:Array)(2*t),this.length=0}function s(t){var e,i,n,r,s,o,a,c,h,l=t.length,u=0,_=Number.POSITIVE_INFINITY;for(c=0;cu&&(u=t[c]),t[c]<_&&(_=t[c]);for(e=1<>=1;for(h=o;h=e:return[265,e-11,1];case 14>=e:return[266,e-13,1];case 16>=e:return[267,e-15,1];case 18>=e:return[268,e-17,1];case 22>=e:return[269,e-19,2];case 26>=e:return[270,e-23,2];case 30>=e:return[271,e-27,2];case 34>=e:return[272,e-31,2];case 42>=e:return[273,e-35,3];case 50>=e:return[274,e-43,3];case 58>=e:return[275,e-51,3];case 66>=e:return[276,e-59,3];case 82>=e:return[277,e-67,4];case 98>=e:return[278,e-83,4];case 114>=e:return[279,e-99,4];case 130>=e:return[280,e-115,4];case 162>=e:return[281,e-131,5];case 194>=e:return[282,e-163,5];case 226>=e:return[283,e-195,5];case 257>=e:return[284,e-227,5];case 258===e:return[285,e-258,0];default:t("invalid length: "+e)}}function h(e,i){function n(e,i){var n,r=e.G,s=[],o=0;n=M[e.length],s[o++]=65535&n,s[o++]=n>>16&255,s[o++]=n>>24;var a;switch(y){case 1===r:a=[0,r-1,0];break;case 2===r:a=[1,r-2,0];break;case 3===r:a=[2,r-3,0];break;case 4===r:a=[3,r-4,0];break;case 6>=r:a=[4,r-5,1];break;case 8>=r:a=[5,r-7,1];break;case 12>=r:a=[6,r-9,2];break;case 16>=r:a=[7,r-13,2];break;case 24>=r:a=[8,r-17,3];break;case 32>=r:a=[9,r-25,3];break;case 48>=r:a=[10,r-33,4];break;case 64>=r:a=[11,r-49,4];break;case 96>=r:a=[12,r-65,5];break;case 128>=r:a=[13,r-97,5];break;case 192>=r:a=[14,r-129,6];break;case 256>=r:a=[15,r-193,6];break;case 384>=r:a=[16,r-257,7];break;case 512>=r:a=[17,r-385,7];break;case 768>=r:a=[18,r-513,8];break;case 1024>=r:a=[19,r-769,8];break;case 1536>=r:a=[20,r-1025,9];break;case 2048>=r:a=[21,r-1537,9];break;case 3072>=r:a=[22,r-2049,10];break;case 4096>=r:a=[23,r-3073,10];break;case 6144>=r:a=[24,r-4097,11];break;case 8192>=r:a=[25,r-6145,11];break;case 12288>=r:a=[26,r-8193,12];break;case 16384>=r:a=[27,r-12289,12];break;case 24576>=r:a=[28,r-16385,13];break;case 32768>=r:a=[29,r-24577,13];break;default:t("invalid distance")}n=a,s[o++]=n[0],s[o++]=n[1],s[o++]=n[2];var c,h;for(c=0,h=s.length;c=o;)C[o++]=0;for(o=0;29>=o;)T[o++]=0}for(C[256]=1,r=0,s=i.length;r=s){for(_&&n(_,-1),o=0,c=s-r;oE&&r+Ew&&(S=A,w=E),258===E)break}u=new a(w,r-S),_?_.length2*y[d-1]+v[d]&&(y[d]=2*y[d-1]+v[d]),T[d]=Array(y[d]),b[d]=Array(y[d]);for(_=0;_s[_]?(T[d][f]=p,b[d][f]=g,m+=2):(T[d][f]=s[_],b[d][f]=_,++_);A[d]=0,1===v[d]&&i(d)}for(o=C,a=0,c=n.length;a1<h&&t("undercommitted"),i=0,n=e.length;i>>=1;return o}function _(t,e){this.input=t,this.a=new(x?Uint8Array:Array)(32768),this.h=L.j;var i,n={};!e&&(e={})||"number"!=typeof e.compressionType||(this.h=e.compressionType);for(i in e)n[i]=e[i];n.outputBuffer=this.a,this.z=new o(this.input,n)}function d(e,i){switch(this.k=[],this.l=32768,this.e=this.g=this.c=this.q=0,this.input=x?new Uint8Array(e):e,this.s=!1,this.m=F,this.B=!1,!i&&(i={})||(i.index&&(this.c=i.index),i.bufferSize&&(this.l=i.bufferSize),i.bufferType&&(this.m=i.bufferType),i.resize&&(this.B=i.resize)),this.m){case N:this.b=32768,this.a=new(x?Uint8Array:Array)(32768+this.l+258);break;case F:this.b=0,this.a=new(x?Uint8Array:Array)(this.l),this.f=this.J,this.t=this.H,this.o=this.I;break;default:t(Error("invalid inflate mode"))}}function f(e,i){for(var n,r=e.g,s=e.e,o=e.input,a=e.c;s>>i,e.e=s-i,e.c=a,n}function p(e,i){for(var n,r,s,o=e.g,a=e.e,c=e.input,h=e.c,l=i[0],u=i[1];a>>16,e.g=o>>s,e.e=a-s,e.c=h,65535&r}function m(e,i){var n,r;switch(this.input=e,this.c=0,!i&&(i={})||(i.index&&(this.c=i.index),i.verify&&(this.M=i.verify)),n=e[this.c++],r=e[this.c++],15&n){case ht:this.method=ht;break;default:t(Error("unsupported compression method"))}0!=((n<<8)+r)%31&&t(Error("invalid fcheck flag:"+((n<<8)+r)%31)),32&r&&t(Error("fdict flag is not supported")),this.A=new d(e,{index:this.c,bufferSize:i.bufferSize,bufferType:i.bufferType,resize:i.resize})}var g=void 0,y=!0,v=this,x="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array;n.prototype.f=function(){var t,e=this.buffer,i=e.length,n=new(x?Uint8Array:Array)(i<<1);if(x)n.set(e);else for(t=0;t>>8&255]<<16|w[t>>>16&255]<<8|w[t>>>24&255])>>32-e:w[t]>>8-e),8>e+o)a=a<>e-n-1&1,8==++o&&(o=0,r[s++]=w[a],a=0,s===r.length&&(r=this.f()));r[s]=a,this.buffer=r,this.i=o,this.index=s},n.prototype.finish=function(){var t,e=this.buffer,i=this.index;return 0C;++C){for(var b=S=C,A=7,S=S>>>1;S;S>>>=1)b<<=1,b|=1&S,--A;T[C]=(b<>>0}var w=T;x&&new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]),r.prototype.getParent=function(t){return 2*((t-2)/4|0)},r.prototype.push=function(t,e){var i,n,r,s=this.buffer;for(i=this.length,s[this.length++]=e,s[this.length++]=t;0s[n]);)r=s[i],s[i]=s[n],s[n]=r,r=s[i+1],s[i+1]=s[n+1],s[n+1]=r,i=n;return this.length},r.prototype.pop=function(){var t,e,i,n,r,s=this.buffer;for(e=s[0],t=s[1],this.length-=2,s[0]=s[this.length],s[1]=s[this.length+1],r=0;!((n=2*r+2)>=this.length)&&(n+2s[n]&&(n+=2),s[n]>s[r]);)i=s[r],s[r]=s[n],s[n]=i,i=s[r+1],s[r+1]=s[n+1],s[n+1]=i,r=n;return{index:t,value:e,length:this.length}};var E,I=2,R={NONE:0,r:1,j:I,N:3},P=[];for(E=0;288>E;E++)switch(y){case 143>=E:P.push([E+48,8]);break;case 255>=E:P.push([E-144+400,9]);break;case 279>=E:P.push([E-256+0,7]);break;case 287>=E:P.push([E-280+192,8]);break;default:t("invalid literal: "+E)}o.prototype.n=function(){var e,i,r,s,o=this.input;switch(this.h){case 0:for(r=0,s=o.length;r>>8&255,v[C++]=255&f,v[C++]=f>>>8&255,x)v.set(a,C),C+=a.length,v=v.subarray(0,C);else{for(p=0,m=a.length;pJ)for(;0J?J:138)>J-3&&K=K?(it[Q++]=17,it[Q++]=K-3,nt[17]++):(it[Q++]=18,it[Q++]=K-11,nt[18]++),J-=K;else if(it[Q++]=et[H],nt[et[H]]++,3>--J)for(;0J?J:6)>J-3&&KW;W++)Y[W]=k[X[W]];for(D=19;4=O;O++)B=c(),D[O]=B[2]<<24|B[1]<<16|B[0];var M=x?new Uint32Array(D):D,L=R;_.prototype.n=function(){var e,n,r,s,o,a,c,h=0;switch(c=this.a,e=ht){case ht:n=Math.LOG2E*Math.log(32768)-8;break;default:t(Error("invalid compression method"))}switch(r=n<<4|e,c[h++]=r,e){case ht:switch(this.h){case L.NONE:o=0;break;case L.r:o=1;break;case L.j:o=2;break;default:t(Error("unsupported compression type"))}break;default:t(Error("invalid compression method"))}return s=o<<6|0,c[h++]=s|31-(256*r+s)%31,a=i(this.input),this.z.b=h,c=this.z.n(),h=c.length,x&&((c=new Uint8Array(c.buffer)).length<=h+4&&(this.a=new Uint8Array(c.length+4),this.a.set(c),c=this.a),c=c.subarray(0,h+4)),c[h++]=a>>24&255,c[h++]=a>>16&255,c[h++]=a>>8&255,c[h++]=255&a,c},e("Zlib.Deflate",_),e("Zlib.Deflate.compress",(function(t,e){return new _(t,e).n()})),e("Zlib.Deflate.CompressionType",L),e("Zlib.Deflate.CompressionType.NONE",L.NONE),e("Zlib.Deflate.CompressionType.FIXED",L.r),e("Zlib.Deflate.CompressionType.DYNAMIC",L.j);var N=0,F=1,k={D:N,C:F};d.prototype.p=function(){for(;!this.s;){var e=f(this,3);switch(1&e&&(this.s=y),e>>>=1){case 0:var i=this.input,n=this.c,r=this.a,o=this.b,a=g,c=g,h=g,l=r.length,u=g;switch(this.e=this.g=0,(a=i[n++])===g&&t(Error("invalid uncompressed block header: LEN (first byte)")),c=a,(a=i[n++])===g&&t(Error("invalid uncompressed block header: LEN (second byte)")),c|=a<<8,(a=i[n++])===g&&t(Error("invalid uncompressed block header: NLEN (first byte)")),h=a,(a=i[n++])===g&&t(Error("invalid uncompressed block header: NLEN (second byte)")),h|=a<<8,c===~h&&t(Error("invalid uncompressed block header: length verify")),n+c>i.length&&t(Error("input buffer is broken")),this.m){case N:for(;o+c>r.length;){if(u=l-o,c-=u,x)r.set(i.subarray(n,n+u),o),o+=u,n+=u;else for(;u--;)r[o++]=i[n++];this.b=o,r=this.f(),o=this.b}break;case F:for(;o+c>r.length;)r=this.f({v:2});break;default:t(Error("invalid inflate mode"))}if(x)r.set(i.subarray(n,n+c),o),o+=c,n+=c;else for(;c--;)r[o++]=i[n++];this.c=n,this.b=o,this.a=r;break;case 1:this.o(tt,it);break;case 2:(function(t){function e(t,e,i){var n,r,s,o;for(o=0;o=z?8:255>=z?9:279>=z?7:8;var K,$,tt=s(Q),et=new(x?Uint8Array:Array)(30);for(K=0,$=et.length;K<$;++K)et[K]=5;var it=s(et);d.prototype.o=function(t,e){var i=this.a,n=this.b;this.u=t;for(var r,s,o,a,c=i.length-258;256!==(r=p(this,t));)if(256>r)n>=c&&(this.b=n,i=this.f(),n=this.b),i[n++]=r;else for(a=j[s=r-257],0=c&&(this.b=n,i=this.f(),n=this.b);a--;)i[n]=i[n++-o];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},d.prototype.I=function(t,e){var i=this.a,n=this.b;this.u=t;for(var r,s,o,a,c=i.length;256!==(r=p(this,t));)if(256>r)n>=c&&(i=this.f(),c=i.length),i[n++]=r;else for(a=j[s=r-257],0c&&(i=this.f(),c=i.length);a--;)i[n]=i[n++-o];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},d.prototype.f=function(){var t,e,i=new(x?Uint8Array:Array)(this.b-32768),n=this.b-32768,r=this.a;if(x)i.set(r.subarray(32768,i.length));else for(t=0,e=i.length;tt;++t)r[t]=r[n+t];return this.b=32768,r},d.prototype.J=function(t){var e,i,n,r,s=this.input.length/this.c+1|0,o=this.input,a=this.a;return t&&("number"==typeof t.v&&(s=t.v),"number"==typeof t.F&&(s+=t.F)),2>s?(i=(o.length-this.c)/this.u[2],r=i/2*258|0,n=re&&(this.a.length=e),t=this.a),this.buffer=t},m.prototype.p=function(){var e,n=this.input;return e=this.A.p(),this.c=this.A.c,this.M&&(n[this.c++]<<24|n[this.c++]<<16|n[this.c++]<<8|n[this.c++])>>>0!==i(e)&&t(Error("invalid adler-32 checksum")),e},e("Zlib.Inflate",m),e("Zlib.Inflate.BufferType",k),k.ADAPTIVE=k.C,k.BLOCK=k.D,e("Zlib.Inflate.prototype.decompress",m.prototype.p);x&&new Uint16Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);x&&new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258]);x&&new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0]);x&&new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577]);x&&new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]);var nt,rt,st=new(x?Uint8Array:Array)(288);for(nt=0,rt=st.length;nt=nt?8:255>=nt?9:279>=nt?7:8;s(st);var ot,at,ct=new(x?Uint8Array:Array)(30);for(ot=0,at=ct.length;ot-1},getValue:function(t,e){this._inited||this._init();var i=this._valueDict;return i[t]?i[t]:e},setValue:function(t,e){this._valueDict[t]=e},gatherGPUInfo:function(){if(cc._renderType!==cc.game.RENDER_TYPE_CANVAS){this._inited||this._init();var t=cc._renderContext,e=this._valueDict;e["gl.vendor"]=t.getParameter(t.VENDOR),e["gl.renderer"]=t.getParameter(t.RENDERER),e["gl.version"]=t.getParameter(t.VERSION),this._GlExtensions="";for(var i=t.getSupportedExtensions(),n=0;n0&&this._deltaTime>1&&(this._deltaTime=1/60)),this._lastUpdate=t},convertToGL:function(t){var e=cc.game.container,i=cc.view,n=e.getBoundingClientRect(),r=n.left+window.pageXOffset-e.clientLeft,s=n.top+window.pageYOffset-e.clientTop,o=i._devicePixelRatio*(t.x-r),a=i._devicePixelRatio*(s+n.height-t.y);return i._isRotated?{x:i._viewPortRect.width-a,y:o}:{x:o,y:a}},convertToUI:function(t){var e=cc.game.container,i=cc.view,n=e.getBoundingClientRect(),r=n.left+window.pageXOffset-e.clientLeft,s=n.top+window.pageYOffset-e.clientTop,o={x:0,y:0};return i._isRotated?(o.x=r+t.y/i._devicePixelRatio,o.y=s+n.height-(i._viewPortRect.width-t.x)/i._devicePixelRatio):(o.x=r+t.x*i._devicePixelRatio,o.y=s+n.height-t.y*i._devicePixelRatio),o},_visitScene:function(){if(this._runningScene){var t=cc.renderer;t.childrenOrderDirty?(t.clearRenderCommands(),cc.renderer.assignedZ=0,this._runningScene._renderCmd._curLevel=0,this._runningScene.visit(),t.resetFlag()):t.transformDirty()&&t.transform()}},end:function(){this._purgeDirectorInNextLoop=!0},getContentScaleFactor:function(){return this._contentScaleFactor},getWinSize:function(){return cc.size(this._winSizeInPoints)},getWinSizeInPixels:function(){return cc.size(this._winSizeInPoints.width*this._contentScaleFactor,this._winSizeInPoints.height*this._contentScaleFactor)},getVisibleSize:null,getVisibleOrigin:null,getZEye:null,pause:function(){this._paused||(this._oldAnimationInterval=this._animationInterval,this.setAnimationInterval(.25),this._paused=!0)},popScene:function(){cc.assertID(this._runningScene,1204),this._scenesStack.pop();var t=this._scenesStack.length;0===t?this.end():(this._sendCleanupToScene=!0,this._nextScene=this._scenesStack[t-1])},purgeCachedData:function(){cc.textureCache._clear(),cc.loader.releaseAll()},purgeDirector:function(){this.getScheduler().unscheduleAll(),this._compScheduler.unscheduleAll(),this._nodeActivator.reset(),h&&h.setEnabled(!1),this._runningScene&&(this._runningScene.performRecursive(_ccsg.Node.performType.onExitTransitionDidStart),this._runningScene.performRecursive(_ccsg.Node.performType.onExit),this._runningScene.performRecursive(_ccsg.Node.performType.cleanup),cc.renderer.clearRenderCommands()),this._runningScene=null,this._nextScene=null,this._scenesStack.length=0,this.stopAnimation(),this.purgeCachedData()},reset:function(){this.purgeDirector(),h&&h.setEnabled(!0),this._actionManager&&this._scheduler.scheduleUpdate(this._actionManager,cc.Scheduler.PRIORITY_SYSTEM,!1),this._animationManager&&this._scheduler.scheduleUpdate(this._animationManager,cc.Scheduler.PRIORITY_SYSTEM,!1),this._collisionManager&&this._scheduler.scheduleUpdate(this._collisionManager,cc.Scheduler.PRIORITY_SYSTEM,!1),this._physicsManager&&this._scheduler.scheduleUpdate(this._physicsManager,cc.Scheduler.PRIORITY_SYSTEM,!1),this.startAnimation()},pushScene:function(t){cc.assertID(t,1205),this._sendCleanupToScene=!1,this._scenesStack.push(t),this._nextScene=t},runSceneImmediate:function(t,e,i){t instanceof cc.Scene&&t._load();for(var n=cc.game,r=Object.keys(n._persistRootNodes).map((function(t){return n._persistRootNodes[t]})),o=0;oi)){for(;i>t;){var n=e.pop();n.running&&(n.performRecursive(_ccsg.Node.performType.onExitTransitionDidStart),n.performRecursive(_ccsg.Node.performType.onExit)),n.performRecursive(_ccsg.Node.performType.cleanup),i--}this._nextScene=e[e.length-1],this._sendCleanupToScene=!0}}else this.end()},getScheduler:function(){return this._scheduler},setScheduler:function(t){this._scheduler!==t&&(this._scheduler=t)},getActionManager:function(){return this._actionManager},setActionManager:function(t){this._actionManager!==t&&(this._actionManager&&this._scheduler.unscheduleUpdate(this._actionManager),this._actionManager=t,this._scheduler.scheduleUpdate(this._actionManager,cc.Scheduler.PRIORITY_SYSTEM,!1))},getAnimationManager:function(){return this._animationManager},getCollisionManager:function(){return this._collisionManager},getPhysicsManager:function(){return this._physicsManager},getDeltaTime:function(){return this._deltaTime}}),cc.js.addon(cc.Director.prototype,n.prototype),cc.Director.EVENT_PROJECTION_CHANGED="director_projection_changed",cc.Director.EVENT_BEFORE_SCENE_LOADING="director_before_scene_loading",cc.Director.EVENT_BEFORE_SCENE_LAUNCH="director_before_scene_launch",cc.Director.EVENT_AFTER_SCENE_LAUNCH="director_after_scene_launch",cc.Director.EVENT_BEFORE_UPDATE="director_before_update",cc.Director.EVENT_AFTER_UPDATE="director_after_update",cc.Director.EVENT_BEFORE_VISIT="director_before_visit",cc.Director.EVENT_AFTER_VISIT="director_after_visit",cc.Director.EVENT_AFTER_DRAW="director_after_draw",cc.DisplayLinkDirector=cc.Director.extend({invalid:!1,startAnimation:function(){this._nextDeltaTimeZero=!0,this.invalid=!1},mainLoop:function(){this._purgeDirectorInNextLoop?(this._purgeDirectorInNextLoop=!1,this.purgeDirector()):this.invalid||(this.calculateDeltaTime(),this._paused||(this.emit(cc.Director.EVENT_BEFORE_UPDATE),this._compScheduler.startPhase(),this._compScheduler.updatePhase(this._deltaTime),this._scheduler.update(this._deltaTime),this._compScheduler.lateUpdatePhase(this._deltaTime),this.emit(cc.Director.EVENT_AFTER_UPDATE),cc.Object._deferredDestroy()),this._nextScene&&this.setNextScene(),this.emit(cc.Director.EVENT_BEFORE_VISIT),this._visitScene(),this.emit(cc.Director.EVENT_AFTER_VISIT),cc.g_NumberOfDraws=0,cc.renderer.clear(),cc.renderer.rendering(cc._renderContext),this._totalFrames++,this.emit(cc.Director.EVENT_AFTER_DRAW),h.frameUpdateListeners())},stopAnimation:function(){this.invalid=!0},setAnimationInterval:function(t){this._animationInterval=t,this.invalid||(this.stopAnimation(),this.startAnimation())},__fastOn:function(t,e,i){var n=this._bubblingListeners;n||(n=this._bubblingListeners=new c),n.add(t,e,i),this._addEventFlag(t,n,!1)},__fastOff:function(t,e,i){var n=this._bubblingListeners;n&&(n.remove(t,e,i),this._purgeEventFlag(t,n,!1))}}),cc.Director.sharedDirector=null,cc.Director.firstUseDirector=!0,cc.Director._getInstance=function(){return cc.Director.firstUseDirector&&(cc.Director.firstUseDirector=!1,cc.Director.sharedDirector=new cc.DisplayLinkDirector,cc.Director.sharedDirector.init()),cc.Director.sharedDirector},cc.defaultFPS=60,cc.Director.PROJECTION_2D=0,cc.Director.PROJECTION_3D=1,cc.Director.PROJECTION_CUSTOM=3,cc.Director.PROJECTION_DEFAULT=cc.Director.PROJECTION_2D}),{"./component-scheduler":70,"./event-manager":110,"./event/event-listeners":111,"./event/event-target":112,"./load-pipeline/auto-release-utils":134,"./node-activator":147,"./platform/_CCClass":188}],34:[(function(t,e,i){t("./CCDirector"),t("./CCGame");var n=t("./event-manager");cc.game.once(cc.game.EVENT_RENDERER_INITED,(function(){if(cc._renderType===cc.game.RENDER_TYPE_CANVAS){var t=cc.Director.prototype;t.getProjection=function(t){return this._projection},t.setProjection=function(t){this._projection=t,this.emit(cc.Director.EVENT_PROJECTION_CHANGED,this)},t.setDepthTest=function(){},t.setClearColor=function(t){cc.renderer._clearColor=t,cc.renderer._clearFillStyle="rgb("+t.r+","+t.g+","+t.b+")"},t.setOpenGLView=function(t){this._winSizeInPoints.width=cc._canvas.width,this._winSizeInPoints.height=cc._canvas.height,this._openGLView=t||cc.view,n&&n.setEnabled(!0)},t.getVisibleSize=function(){return this.getWinSize()},t.getVisibleOrigin=function(){return cc.p(0,0)}}}))}),{"./CCDirector":33,"./CCGame":39,"./event-manager":110}],35:[(function(t,e,i){t("./CCDirector"),t("./CCGame"),t("../kazmath");var n=t("./event-manager"),r=cc.math;cc.game.once(cc.game.EVENT_RENDERER_INITED,(function(){if(cc._renderType===cc.game.RENDER_TYPE_WEBGL){cc.DirectorDelegate=cc._Class.extend({updateProjection:function(){}});var t=cc.Director.prototype,e=function(t){if(t&&t._renderCmd){t._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty);var i,n=t._children;for(i=0;i0?cc.loader.load(s,(function(i){if(i)throw new Error(JSON.stringify(i));e._prepared=!0,t&&t(),e.emit(e.EVENT_GAME_INITED)})):(t&&t(),e.emit(e.EVENT_GAME_INITED))}else cc.initEngine(this.config,(function(){e.prepare(t)}))}else this._loadConfig((function(){e.prepare(t)}))},run:function(t,e){"function"==typeof t?o.onStart=t:(t&&(o.config=t),"function"==typeof e&&(o.onStart=e)),this.prepare(o.onStart&&o.onStart.bind(o))},addPersistRootNode:function(t){if(cc.Node.isNode(t)&&t.uuid){var e=t.uuid;if(!this._persistRootNodes[e]){var i=cc.director._scene;if(cc.isValid(i)){if(t.parent){if(!(t.parent instanceof cc.Scene))return void cc.warnID(3801);if(t.parent!==i)return void cc.warnID(3802)}else t.parent=i;this._persistRootNodes[e]=t,t._persistNode=!0}}}else cc.warnID(3800)},removePersistRootNode:function(t){if(t!==this._ignoreRemovePersistNode){var e=t.uuid||"";t===this._persistRootNodes[e]&&(delete this._persistRootNodes[e],t._persistNode=!1)}},isPersistRootNode:function(t){return t._persistNode},_setAnimFrame:function(){this._lastTime=new Date;var t=o.config[o.CONFIG_KEY.frameRate];this._frameTime=1e3/t,60!==t&&30!==t?(window.requestAnimFrame=this._stTime,window.cancelAnimFrame=this._ctTime):(window.requestAnimFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||this._stTime,window.cancelAnimFrame=window.cancelAnimationFrame||window.cancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.oCancelAnimationFrame||this._ctTime)},_stTime:function(t){var e=(new Date).getTime(),i=Math.max(0,o._frameTime-(e-o._lastTime)),n=window.setTimeout((function(){t()}),i);return o._lastTime=e+i,n},_ctTime:function(t){window.clearTimeout(t)},_runMainLoop:function(){var t,e=this,i=e.config,n=e.CONFIG_KEY,r=cc.director,s=!0,o=i[n.frameRate];r.setDisplayStats(i[n.showFPS]),t=function(){if(!e._paused){if(e._intervalId=window.requestAnimFrame(t),30===o&&(s=!s))return;r.mainLoop()}},e._intervalId=window.requestAnimFrame(t),e._paused=!1},_loadConfig:function(t){if(this.config)return this._initConfig(this.config),void(t&&t());if(document.ccConfig)return this._initConfig(document.ccConfig),void(t&&t());var e=this;cc.loader.load("project.json",(function(i,n){i&&cc.logID(3818),e._initConfig(n||{}),t&&t()}))},_initConfig:function(t){var e=this.CONFIG_KEY;"number"!=typeof t[e.debugMode]&&(t[e.debugMode]=0),t[e.exposeClassName]=!!t[e.exposeClassName],"number"!=typeof t[e.frameRate]&&(t[e.frameRate]=60),"number"!=typeof t[e.renderMode]&&(t[e.renderMode]=0),"boolean"!=typeof t[e.registerSystemEvent]&&(t[e.registerSystemEvent]=!0),t[e.showFPS]=!(e.showFPS in t)||!!t[e.showFPS],this._sceneInfos=t[e.scenes]||[],this.collisionMatrix=t.collisionMatrix||[],this.groupList=t.groupList||[],cc._initDebugSetting(t[e.debugMode]),this.config=t,this._configLoaded=!0},_initRenderer:function(t,e){if(!this._rendererInitialized){if(!cc._supportRender)throw new Error("The renderer doesn't support the renderMode "+this.config[this.CONFIG_KEY.renderMode]);var i,n,r=this.config[o.CONFIG_KEY.id],s=window,a=cc.sys.platform===cc.sys.WECHAT_GAME,c=cc.sys.platform===cc.sys.QQ_PLAY;if(a)this.container=cc.container=n=document.createElement("DIV"),this.frame=n.parentNode===document.body?document.documentElement:n.parentNode,i=cc.sys.browserType===cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB?wx.getSharedCanvas():canvas,this.canvas=cc._canvas=i;else if(c)this.container=cc.container=document.createElement("DIV"),this.frame=document.documentElement,this.canvas=cc._canvas=i=canvas;else{var h=r instanceof HTMLElement?r:document.querySelector(r)||document.querySelector("#"+r);"CANVAS"===h.tagName?(t=t||h.width,e=e||h.height,this.canvas=cc._canvas=i=h,this.container=cc.container=n=document.createElement("DIV"),i.parentNode&&i.parentNode.insertBefore(n,i)):("DIV"!==h.tagName&&cc.warnID(3819),t=t||h.clientWidth,e=e||h.clientHeight,this.canvas=cc._canvas=i=document.createElement("CANVAS"),this.container=cc.container=n=document.createElement("DIV"),h.appendChild(n)),n.setAttribute("id","Cocos2dGameContainer"),n.appendChild(i),this.frame=n.parentNode===document.body?document.documentElement:n.parentNode;(function(t,e){(" "+t.className+" ").indexOf(" "+e+" ")>-1||(t.className&&(t.className+=" "),t.className+=e)})(i,"gameCanvas"),i.setAttribute("width",t||480),i.setAttribute("height",e||320),i.setAttribute("tabindex",99)}if(cc._renderType===o.RENDER_TYPE_WEBGL){var l={stencil:!0,antialias:cc.macro.ENABLE_WEBGL_ANTIALIAS,alpha:cc.macro.ENABLE_TRANSPARENT_CANVAS};a&&(l.preserveDrawingBuffer=!0),this._renderContext=cc._renderContext=cc.webglContext=cc.create3DContext(i,l)}this._renderContext?(cc.renderer=cc.rendererWebGL,s.gl=this._renderContext,cc.renderer.init()):(cc._renderType=o.RENDER_TYPE_CANVAS,cc.renderer=cc.rendererCanvas,cc.renderer.init(),this._renderContext=cc._renderContext=new cc.CanvasContextWrapper(i.getContext("2d"))),cc._gameDiv=n,o.canvas.oncontextmenu=function(){if(!cc._isContextMenuEnable)return!1},this.emit(this.EVENT_RENDERER_INITED,!0),this._rendererInitialized=!0}},_initEvents:function(){var t,e=window;this.config[this.CONFIG_KEY.registerSystemEvent]&&s.registerSystemEvent(this.canvas),void 0!==document.hidden?t="hidden":void 0!==document.mozHidden?t="mozHidden":void 0!==document.msHidden?t="msHidden":void 0!==document.webkitHidden&&(t="webkitHidden");var i=["visibilitychange","mozvisibilitychange","msvisibilitychange","webkitvisibilitychange","qbrowserVisibilityChange"],n=function(){o.emit(o.EVENT_HIDE,o)},r=function(){o.emit(o.EVENT_SHOW,o)};if(t)for(var a=0;a-1&&(e.onfocus=r),"onpageshow"in window&&"onpagehide"in window&&(e.addEventListener("pagehide",n,!1),e.addEventListener("pageshow",r,!1)),this.on(o.EVENT_HIDE,(function(){o.pause()})),this.on(o.EVENT_SHOW,(function(){o.resume()}))}};r.call(o),cc.js.addon(o,r.prototype),cc.game=e.exports=o}),{"../audio/CCAudioEngine":23,"./event/event-target":112,"./platform/BKInputManager":174,"./platform/CCInputManager":180,"./platform/CCView":186}],40:[(function(t,e,i){"use strict";function n(t){var e=cc.Mask;if(e)for(var i=0,n=t;n&&cc.Node.isNode(n);n=n._parent,++i)if(n.getComponent(e))return{index:i,node:n};return null}var r=t("./utils/prefab-helper"),s=t("./utils/scene-graph-helper"),o=t("./event-manager"),a=cc.Object.Flags.Destroying,c="position-changed",h="size-changed",l="anchor-changed",u="rotation-changed",_="scale-changed",d=t("./utils/misc"),f=(t("./event/event"),!!cc.ActionManager),p=function(){},m=cc.Enum({TOUCH_START:"touchstart",TOUCH_MOVE:"touchmove",TOUCH_END:"touchend",TOUCH_CANCEL:"touchcancel",MOUSE_DOWN:"mousedown",MOUSE_MOVE:"mousemove",MOUSE_ENTER:"mouseenter",MOUSE_LEAVE:"mouseleave",MOUSE_UP:"mouseup",MOUSE_WHEEL:"mousewheel"}),g=[m.TOUCH_START,m.TOUCH_MOVE,m.TOUCH_END,m.TOUCH_CANCEL],y=[m.MOUSE_DOWN,m.MOUSE_ENTER,m.MOUSE_MOVE,m.MOUSE_LEAVE,m.MOUSE_UP,m.MOUSE_WHEEL],v=null,x=function(t,e){var i=t.getLocation(),n=this.owner;return!!n._hitTest(i,this)&&(e.type=m.TOUCH_START,e.touch=t,e.bubbles=!0,n.dispatchEvent(e),!0)},C=function(t,e){var i=this.owner;e.type=m.TOUCH_MOVE,e.touch=t,e.bubbles=!0,i.dispatchEvent(e)},T=function(t,e){var i=t.getLocation(),n=this.owner;n._hitTest(i,this)?e.type=m.TOUCH_END:e.type=m.TOUCH_CANCEL,e.touch=t,e.bubbles=!0,n.dispatchEvent(e)},b=function(t,e){t.getLocation();var i=this.owner;e.type=m.TOUCH_CANCEL,e.touch=t,e.bubbles=!0,i.dispatchEvent(e)},A=function(t){var e=t.getLocation(),i=this.owner;i._hitTest(e,this)&&(t.type=m.MOUSE_DOWN,t.bubbles=!0,i.dispatchEvent(t),t.stopPropagation())},S=function(t){var e=t.getLocation(),i=this.owner,n=i._hitTest(e,this);if(n)this._previousIn||(v&&(t.type=m.MOUSE_LEAVE,v.dispatchEvent(t),v._mouseListener._previousIn=!1),v=this.owner,t.type=m.MOUSE_ENTER,i.dispatchEvent(t),this._previousIn=!0),t.type=m.MOUSE_MOVE,t.bubbles=!0,i.dispatchEvent(t);else{if(!this._previousIn)return;t.type=m.MOUSE_LEAVE,i.dispatchEvent(t),this._previousIn=!1,v=null}t.stopPropagation()},w=function(t){var e=t.getLocation(),i=this.owner;i._hitTest(e,this)&&(t.type=m.MOUSE_UP,t.bubbles=!0,i.dispatchEvent(t),t.stopPropagation())},E=function(t){var e=t.getLocation(),i=this.owner;i._hitTest(e,this)&&(t.type=m.MOUSE_WHEEL,t.bubbles=!0,i.dispatchEvent(t),t.stopPropagation())},I=cc.Class({name:"cc.Node",extends:t("./utils/base-node"),properties:{_opacity:255,_color:cc.Color.WHITE,_cascadeOpacityEnabled:!0,_anchorPoint:cc.p(.5,.5),_contentSize:cc.size(0,0),_rotationX:0,_rotationY:0,_scaleX:1,_scaleY:1,_position:cc.p(0,0),_skewX:0,_skewY:0,_localZOrder:0,_globalZOrder:0,_opacityModifyRGB:!1,groupIndex:{default:0,type:cc.Integer},group:{get:function(){return cc.game.groupList[this.groupIndex]||""},set:function(t){this.groupIndex=cc.game.groupList.indexOf(t),this.emit("group-changed")}},x:{get:function(){return this._position.x},set:function(t){var e=this._position;if(t!==e.x){e.x=t,this._sgNode.setPositionX(t);var i=this._hasListenerCache;i&&i[c]&&this.emit(c)}}},y:{get:function(){return this._position.y},set:function(t){var e=this._position;if(t!==e.y){e.y=t,this._sgNode.setPositionY(t);var i=this._hasListenerCache;i&&i[c]&&this.emit(c)}}},rotation:{get:function(){return this._rotationX!==this._rotationY&&cc.logID(1602),this._rotationX},set:function(t){if(this._rotationX!==t||this._rotationY!==t){this._rotationX=this._rotationY=t,this._sgNode.rotation=t;var e=this._hasListenerCache;e&&e[u]&&this.emit(u)}}},rotationX:{get:function(){return this._rotationX},set:function(t){if(this._rotationX!==t){this._rotationX=t,this._sgNode.rotationX=t;var e=this._hasListenerCache;e&&e[u]&&this.emit(u)}}},rotationY:{get:function(){return this._rotationY},set:function(t){if(this._rotationY!==t){this._rotationY=t,this._sgNode.rotationY=t;var e=this._hasListenerCache;e&&e[u]&&this.emit(u)}}},scaleX:{get:function(){return this._scaleX},set:function(t){if(this._scaleX!==t){this._scaleX=t,this._sgNode.scaleX=t;var e=this._hasListenerCache;e&&e[_]&&this.emit(_)}}},scaleY:{get:function(){return this._scaleY},set:function(t){if(this._scaleY!==t){this._scaleY=t,this._sgNode.scaleY=t;var e=this._hasListenerCache;e&&e[_]&&this.emit(_)}}},skewX:{get:function(){return this._skewX},set:function(t){this._skewX=t,this._sgNode.skewX=t}},skewY:{get:function(){return this._skewY},set:function(t){this._skewY=t,this._sgNode.skewY=t}},opacity:{get:function(){return this._opacity},set:function(t){if(this._opacity!==t&&(this._opacity=t,this._sgNode.setOpacity(t),!this._cascadeOpacityEnabled)){var e=this._sizeProvider;e instanceof _ccsg.Node&&e!==this._sgNode&&e.setOpacity(t)}},range:[0,255]},cascadeOpacity:{get:function(){return this._cascadeOpacityEnabled},set:function(t){if(this._cascadeOpacityEnabled!==t){this._cascadeOpacityEnabled=t,this._sgNode.cascadeOpacity=t;var e=t?255:this._opacity,i=this._sizeProvider;i instanceof _ccsg.Node&&i.setOpacity(e)}}},color:{get:function(){return this._color.clone()},set:function(t){this._color.equals(t)||(this._color.fromColor(t),this._sizeProvider instanceof _ccsg.Node&&this._sizeProvider.setColor(t))}},anchorX:{get:function(){return this._anchorPoint.x},set:function(t){var e=this._anchorPoint;if(e.x!==t){e.x=t;var i=this._sizeProvider;i instanceof _ccsg.Node&&i.setAnchorPoint(e),this.emit(l)}}},anchorY:{get:function(){return this._anchorPoint.y},set:function(t){var e=this._anchorPoint;if(e.y!==t){e.y=t;var i=this._sizeProvider;i instanceof _ccsg.Node&&i.setAnchorPoint(e),this.emit(l)}}},width:{get:function(){if(this._sizeProvider){var t=this._sizeProvider._getWidth();return this._contentSize.width=t,t}return this._contentSize.width},set:function(t){if(t!==this._contentSize.width){var e=this._sizeProvider;e&&e.setContentSize(t,e._getHeight());this._contentSize.width=t,this.emit(h)}}},height:{get:function(){if(this._sizeProvider){var t=this._sizeProvider._getHeight();return this._contentSize.height=t,t}return this._contentSize.height},set:function(t){if(t!==this._contentSize.height){var e=this._sizeProvider;e&&e.setContentSize(e._getWidth(),t);this._contentSize.height=t,this.emit(h)}}},zIndex:{get:function(){return this._localZOrder},set:function(t){this._localZOrder!==t&&(this._localZOrder=t,this._sgNode.zIndex=t,this._parent&&(function(t){t._parent._delaySort(),o._setDirtyForNode(t)})(this))}}},ctor:function(t){var e=this._sgNode=new _ccsg.Node;cc.game._isCloning||(e.cascadeOpacity=!0),this._sizeProvider=null,this._reorderChildDirty=!1,this._widget=null,this._touchListener=null,this._mouseListener=null},statics:{isNode:function(t){return t instanceof I&&(t.constructor===I||!(t instanceof cc.Scene))}},_onSetParent:function(t){var e=this._sgNode;e.parent&&e.parent.removeChild(e,!1),t&&(t._sgNode.addChild(e),t._delaySort())},_onSiblingIndexChanged:function(t){var e=this._parent,i=e._children,n=0,r=i.length;for(0;n=0&&c>=0&&l>=0&&h>=0){if(e&&e.mask){for(var u=e.mask,_=this,d=0;_&&d1){var e,i,n,r=t.length;for(e=1;e=0;){if(n._localZOrder0,this._repeat=r,this._runForever=this._repeat===cc.macro.REPEAT_FOREVER,!0},l.getInterval=function(){return this._interval},l.setInterval=function(t){this._interval=t},l.update=function(t){-1===this._elapsed?(this._elapsed=0,this._timesExecuted=0):(this._elapsed+=t,this._runForever&&!this._useDelay?this._elapsed>=this._interval&&(this.trigger(),this._elapsed=0):(this._useDelay?this._elapsed>=this._delay&&(this.trigger(),this._elapsed-=this._delay,this._timesExecuted+=1,this._useDelay=!1):this._elapsed>=this._interval&&(this.trigger(),this._elapsed=0,this._timesExecuted+=1),this._callback&&!this._runForever&&this._timesExecuted>this._repeat&&this.cancel()))},l.getCallback=function(){return this._callback},l.trigger=function(){this._target&&this._callback&&(this._lock=!0,this._callback.call(this._target,this._elapsed),this._lock=!1)},l.cancel=function(){this._scheduler.unschedule(this._callback,this._target)};var u=[];n.get=function(){return u.pop()||new n},n.put=function(t){u.length<20&&!t._lock&&(t._scheduler=t._target=t._callback=null,u.push(t))};var _=function(t){return t.__instanceId||t.uuid};cc.Scheduler=cc._Class.extend({ctor:function(){this._timeScale=1,this._updatesNegList=[],this._updates0List=[],this._updatesPosList=[],this._hashForUpdates={},this._hashForTimers={},this._currentTarget=null,this._currentTargetSalvaged=!1,this._updateHashLocked=!1,this._arrayForTimers=[]},_removeHashElement:function(t){delete this._hashForTimers[_(t.target)];for(var e=this._arrayForTimers,i=0,n=e.length;i=o&&r.timerIndex--,void(0===s.length&&(this._currentTarget===r?this._currentTargetSalvaged=!0:this._removeHashElement(r)))}}},unscheduleUpdate:function(t){if(t){var e=_(t);cc.assertID(e,1510);var i=this._hashForUpdates[e];i&&(this._updateHashLocked?i.entry.markedForDeletion=!0:this._removeUpdateFromHash(i.entry))}},unscheduleAllForTarget:function(t){if(t){var e=_(t);cc.assertID(e,1510);var i=this._hashForTimers[e];if(i){var r=i.timers;r.indexOf(i.currentTimer)>-1&&!i.currentTimerSalvaged&&(i.currentTimerSalvaged=!0);for(var s=0,o=r.length;s=0;e--)i=n[e],this.unscheduleAllForTarget(i.target);var r,s=0;if(t<0)for(e=0;e=t&&this.unscheduleUpdate(r.target),s==this._updatesNegList.length&&e++;if(t<=0)for(e=0;e=t&&this.unscheduleUpdate(r.target),s==this._updatesPosList.length&&e++},isScheduled:function(t,e){cc.assertID(t,1508),cc.assertID(e,1509);var i=_(e);cc.assertID(i,1510);var n=this._hashForTimers[i];if(!n)return!1;if(null==n.timers)return!1;for(var r=n.timers,s=0;s=t&&(o.paused=!0,r.push(o.target));if(t<=0)for(i=0;i=t&&(o.paused=!0,r.push(o.target));return r},resumeTargets:function(t){if(t)for(var e=0;e0?t:null},_preloadRawFiles:null}),e.exports=cc.Asset}),{"./CCRawAsset":49}],44:[(function(t,e,i){var n=cc.Class({name:"cc.AudioClip",extends:cc.RawAsset});cc.AudioClip=n,e.exports=n}),{}],45:[(function(t,e,i){var n=cc.Class({name:"cc.BitmapFont",extends:cc.Font,properties:{fntDataStr:{default:""},spriteFrame:{default:null,type:cc.SpriteFrame},fontSize:{default:-1},_fntConfig:null}});cc.BitmapFont=n,e.exports=n}),{}],46:[(function(t,e,i){var n=cc.Class({name:"cc.Font",extends:cc.Asset});cc.Font=n,e.exports=n}),{}],47:[(function(t,e,i){var n=cc.Class({name:"cc.LabelAtlas",extends:cc.BitmapFont});cc.LabelAtlas=n,e.exports=n}),{}],48:[(function(t,e,i){var n=cc.Class({name:"cc.Prefab",extends:cc.Asset,properties:{data:null,asyncLoadAssets:void 0,_createFunction:{default:null,serializable:!1}},createNode:!1,compileCreateFunction:function(){var e=t("../platform/instantiate-jit");this._createFunction=e.compile(this.data)},_doInstantiate:function(t){return this.data._prefab?this.data._prefab._synced=!0:cc.warnID(3700),this._createFunction||this.compileCreateFunction(),this._createFunction(t)},_instantiate:function(){var t;return t=this._doInstantiate(),this.data._instantiate(t),t}});cc.Prefab=e.exports=n,cc.js.obsolete(cc,"cc._Prefab","Prefab")}),{"../platform/instantiate-jit":195}],49:[(function(t,e,i){var n=t("../platform/CCObject");cc.RawAsset=cc.Class({name:"cc.RawAsset",extends:n,ctor:function(){Object.defineProperty(this,"_uuid",{value:"",writable:!0})},statics:{createNodeByInfo:null}}),Object.defineProperty(cc.RawAsset,"isRawAssetType",{value:function(t){return cc.isChildClassOf(t,cc.RawAsset)&&!cc.isChildClassOf(t,cc.Asset)}}),e.exports=cc.RawAsset}),{"../platform/CCObject":182}],50:[(function(t,e,i){var n=cc.Class({name:"cc.SceneAsset",extends:cc.Asset,properties:{scene:null,asyncLoadAssets:void 0}});cc.SceneAsset=n,e.exports=n}),{}],51:[(function(t,e,i){var n=cc.Class({name:"cc.Script",extends:cc.Asset});cc._Script=n;var r=cc.Class({name:"cc.JavaScript",extends:n});cc._JavaScript=r;var s=cc.Class({name:"cc.CoffeeScript",extends:n});cc._CoffeeScript=s;var o=cc.Class({name:"cc.TypeScript",extends:n});cc._TypeScript=o}),{}],52:[(function(t,e,i){var n=cc.Class({name:"cc.SpriteAtlas",extends:cc.Asset,properties:{_spriteFrames:{default:{}}},getTexture:function(){var t=Object.keys(this._spriteFrames);if(t.length>0){var e=this._spriteFrames[t[0]];return e?e.getTexture():null}return null},getSpriteFrame:function(t){return this._spriteFrames[t]},getSpriteFrames:function(){var t=[],e=this._spriteFrames;for(var i in e)t.push(e[i]);return t}});cc.SpriteAtlas=n,e.exports=n}),{}],53:[(function(t,e,i){var n=cc.Class({name:"cc.TTFFont",extends:cc.Font});cc.TTFFont=n,e.exports=n}),{}],54:[(function(t,e,i){t("./CCRawAsset"),t("./CCAsset"),t("./CCFont"),t("./CCPrefab"),t("./CCAudioClip"),t("./CCScripts"),t("./CCSceneAsset"),t("../sprites/CCSpriteFrame"),t("../textures/CCTexture2D"),t("./CCTTFFont"),t("./CCSpriteAtlas"),t("./CCBitmapFont"),t("./CCLabelAtlas")}),{"../sprites/CCSpriteFrame":215,"../textures/CCTexture2D":216,"./CCAsset":43,"./CCAudioClip":44,"./CCBitmapFont":45,"./CCFont":46,"./CCLabelAtlas":47,"./CCPrefab":48,"./CCRawAsset":49,"./CCSceneAsset":50,"./CCScripts":51,"./CCSpriteAtlas":52,"./CCTTFFont":53}],55:[(function(t,e,i){var n=t("../utils/misc"),r=t("../event-manager"),s=!!cc.ActionManager,o=function(){};cc.s_globalOrderOfArrival=1,_ccsg.Node=cc.Class({name:"ccsg.Node",properties:{_running:!1,_localZOrder:0,_globalZOrder:0,_arrivalOrder:0,_reorderChildDirty:!1,_vertexZ:0,_customZ:void 0,_rotationX:0,_rotationY:0,_scaleX:1,_scaleY:1,_position:cc.p(0,0),_skewX:0,_skewY:0,_children:[],_visible:!0,_anchorPoint:cc.p(0,0),_contentSize:cc.size(0,0),_parent:null,_ignoreAnchorPointForPosition:!1,tag:cc.macro.NODE_TAG_INVALID,_name:"",_realOpacity:255,_realColor:cc.Color.WHITE,_cascadeColorEnabled:!1,_cascadeOpacityEnabled:!1,_isTransitionFinished:!1,_actionManager:null,_scheduler:null,_renderCmd:null},ctor:function(){this.__instanceId=cc.ClassManager.getNewInstanceId(),this._renderCmd=this._createRenderCmd()},init:function(){return!0},attr:function(t){for(var e in t)this[e]=t[e]},getSkewX:function(){return this._skewX},setSkewX:function(t){this._skewX=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getSkewY:function(){return this._skewY},setSkewY:function(t){this._skewY=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},setLocalZOrder:function(t){this._parent?this._parent.reorderChild(this,t):this._localZOrder=t,r._setDirtyForNode(this)},_setLocalZOrder:function(t){this._localZOrder=t},getLocalZOrder:function(){return this._localZOrder},getZOrder:function(){return cc.logID(1600),this.getLocalZOrder()},setZOrder:function(t){cc.logID(1601),this.setLocalZOrder(t)},setGlobalZOrder:function(t){this._globalZOrder!==t&&(this._globalZOrder=t,r._setDirtyForNode(this))},getGlobalZOrder:function(){return this._globalZOrder},getVertexZ:function(){return this._vertexZ},setVertexZ:function(t){this._customZ=this._vertexZ=t},getRotation:function(){return this._rotationX!==this._rotationY&&cc.logID(1602),this._rotationX},setRotation:function(t){this._rotationX=this._rotationY=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getRotationX:function(){return this._rotationX},setRotationX:function(t){this._rotationX=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getRotationY:function(){return this._rotationY},setRotationY:function(t){this._rotationY=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getScale:function(){return this._scaleX!==this._scaleY&&cc.logID(1603),this._scaleX},setScale:function(t,e){this._scaleX=t,this._scaleY=e||0===e?e:t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getScaleX:function(){return this._scaleX},setScaleX:function(t){this._scaleX=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getScaleY:function(){return this._scaleY},setScaleY:function(t){this._scaleY=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},setPosition:function(t,e){var i=this._position;if(void 0===e){if(i.x===t.x&&i.y===t.y)return;i.x=t.x,i.y=t.y}else{if(i.x===t&&i.y===e)return;i.x=t,i.y=e}this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getPosition:function(){return cc.p(this._position)},getPositionX:function(){return this._position.x},setPositionX:function(t){this._position.x=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getPositionY:function(){return this._position.y},setPositionY:function(t){this._position.y=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty)},getChildrenCount:function(){return this._children.length},getChildren:function(){return this._children},isVisible:function(){return this._visible},setVisible:function(t){this._visible!==t&&(this._visible=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty),cc.renderer.childrenOrderDirty=!0)},getAnchorPoint:function(){return cc.p(this._anchorPoint)},setAnchorPoint:function(t,e){var i=this._anchorPoint;if(void 0===e){if(t.x===i.x&&t.y===i.y)return;i.x=t.x,i.y=t.y}else{if(t===i.x&&e===i.y)return;i.x=t,i.y=e}this._renderCmd._updateAnchorPointInPoint()},_getAnchorX:function(){return this._anchorPoint.x},_setAnchorX:function(t){this._anchorPoint.x!==t&&(this._anchorPoint.x=t,this._renderCmd._updateAnchorPointInPoint())},_getAnchorY:function(){return this._anchorPoint.y},_setAnchorY:function(t){this._anchorPoint.y!==t&&(this._anchorPoint.y=t,this._renderCmd._updateAnchorPointInPoint())},getAnchorPointInPoints:function(){return this._renderCmd.getAnchorPointInPoints()},_getWidth:function(){return this._contentSize.width},_setWidth:function(t){this._contentSize.width=t,this._renderCmd._updateAnchorPointInPoint()},_getHeight:function(){return this._contentSize.height},_setHeight:function(t){this._contentSize.height=t,this._renderCmd._updateAnchorPointInPoint()},getContentSize:function(){return cc.size(this._contentSize)},setContentSize:function(t,e){var i=this._contentSize;if(void 0===e){if(t.width===i.width&&t.height===i.height)return;i.width=t.width,i.height=t.height}else{if(t===i.width&&e===i.height)return;i.width=t,i.height=e}this._renderCmd._updateAnchorPointInPoint()},isRunning:function(){return this._running},getParent:function(){return this._parent},setParent:function(t){this._parent=t;var e=_ccsg.Node._dirtyFlags;this._renderCmd.setDirtyFlag(e.transformDirty|e.opacityDirty)},isIgnoreAnchorPointForPosition:function(){return this._ignoreAnchorPointForPosition},setIgnoreAnchorPointForPosition:function(t){t!==this._ignoreAnchorPointForPosition&&(this._ignoreAnchorPointForPosition=t,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty))},getTag:function(){return this.tag},setTag:function(t){this.tag=t},setName:function(t){this._name=t},getName:function(){return this._name},updateOrderOfArrival:function(){this._arrivalOrder=++cc.s_globalOrderOfArrival},getScheduler:function(){return this._scheduler||cc.director.getScheduler()},setScheduler:function(t){this._scheduler!==t&&(this.unscheduleAllCallbacks(),this._scheduler=t)},boundingBox:function(){return cc.logID(1608),this.getBoundingBox()},getBoundingBox:function(){var t=cc.rect(0,0,this._contentSize.width,this._contentSize.height);return cc._rectApplyAffineTransformIn(t,this.getNodeToParentTransform())},cleanup:function(){this.stopAllActions(),this.unscheduleAllCallbacks(),r.removeListeners(this)},getChildByTag:function(t){var e=this._children;if(null!==e)for(var i=0;i-1&&this._detachChild(t,e),cc.renderer.childrenOrderDirty=!0)},removeChildByTag:function(t,e){t===cc.macro.NODE_TAG_INVALID&&cc.logID(1609);var i=this.getChildByTag(t);i?this.removeChild(i,e):cc.logID(1610,t)},removeAllChildrenWithCleanup:function(t){this.removeAllChildren(t)},removeAllChildren:function(t){var e=this._children;if(null!==e){void 0===t&&(t=!0);for(var i=0;i=0;){if(i._localZOrder=e.max)){var i,n,r,s,o,a=0,c=_ccsg.Node._performStacks[_ccsg.Node._performing];for(c||(c=[],_ccsg.Node._performStacks.push(c)),c.length=0,_ccsg.Node._performing++,r=c[0]=this;r;){if((i=r._children)&&i.length>0)for(s=0,o=i.length;s=0;--s)r=c[s],c[s]=null,r&&r.onEnter();break;case e.onExit:for(s=c.length-1;s>=0;--s)r=c[s],c[s]=null,r&&r.onExit();break;case e.onEnterTransitionDidFinish:for(s=c.length-1;s>=0;--s)r=c[s],c[s]=null,r&&r.onEnterTransitionDidFinish();break;case e.cleanup:for(s=c.length-1;s>=0;--s)r=c[s],c[s]=null,r&&r.cleanup();break;case e.onExitTransitionDidStart:for(s=c.length-1;s>=0;--s)r=c[s],c[s]=null,r&&r.onExitTransitionDidStart()}_ccsg.Node._performing--}},onEnterTransitionDidFinish:function(){this._isTransitionFinished=!0},onExitTransitionDidStart:function(){},onExit:function(){this._running=!1,this.pause()},runAction:s?function(t){return cc.assertID(t,1618),cc.director.getActionManager().addAction(t,this,!this._running),t}:o,stopAllActions:s?function(){cc.director.getActionManager().removeAllActionsFromTarget(this)}:o,stopAction:s?function(t){cc.director.getActionManager().removeAction(t)}:o,stopActionByTag:s?function(t){t!==cc.Action.TAG_INVALID?cc.director.getActionManager().removeActionByTag(t,this):cc.logID(1612)}:o,getActionByTag:s?function(t){return t===cc.Action.TAG_INVALID?(cc.logID(1613),null):cc.director.getActionManager().getActionByTag(t,this)}:function(){return null},getNumberOfRunningActions:s?function(){return cc.director.getActionManager().getNumberOfRunningActionsInTarget(this)}:function(){return 0},scheduleUpdate:function(){this.scheduleUpdateWithPriority(0)},scheduleUpdateWithPriority:function(t){this.scheduler.scheduleUpdate(this,t,!this._running)},unscheduleUpdate:function(){this.scheduler.unscheduleUpdate(this)},schedule:function(t,e,i,n,r){var s=arguments.length;"function"==typeof t?1===s?(e=0,i=cc.macro.REPEAT_FOREVER,n=0,r=this.__instanceId):2===s?"number"==typeof e?(i=cc.macro.REPEAT_FOREVER,n=0,r=this.__instanceId):(r=e,e=0,i=cc.macro.REPEAT_FOREVER,n=0):3===s?("string"==typeof i?(r=i,i=cc.macro.REPEAT_FOREVER):r=this.__instanceId,n=0):4===s&&(r=this.__instanceId):1===s?(e=0,i=cc.macro.REPEAT_FOREVER,n=0):2===s&&(i=cc.macro.REPEAT_FOREVER,n=0),cc.assertID(t,1619),cc.assertID(e>=0,1620),e=e||0,i=isNaN(i)?cc.macro.REPEAT_FOREVER:i,n=n||0,this.scheduler.schedule(t,this,e,i,n,!this._running,r)},scheduleOnce:function(t,e,i){void 0===i&&(i=this.__instanceId),this.schedule(t,0,0,e,i)},unschedule:function(t){t&&this.scheduler.unschedule(t,this)},unscheduleAllCallbacks:function(){this.scheduler.unscheduleAllForTarget(this)},resumeSchedulerAndActions:function(){cc.logID(1614),this.resume()},resume:function(){this.scheduler.resumeTarget(this),s&&cc.director.getActionManager().resumeTarget(this),r.resumeTarget(this)},pauseSchedulerAndActions:function(){cc.logID(1615),this.pause()},pause:function(){this.scheduler.pauseTarget(this),s&&cc.director.getActionManager().pauseTarget(this),r.pauseTarget(this)},getParentToNodeTransform:function(){return this._renderCmd.getParentToNodeTransform()},parentToNodeTransform:function(){return this.getParentToNodeTransform()},getNodeToWorldTransform:function(){for(var t=this.getNodeToParentTransform(),e=this._parent;null!==e;e=e.parent)t=cc.affineTransformConcat(t,e.getNodeToParentTransform());return t},nodeToWorldTransform:function(){return this.getNodeToWorldTransform()},getWorldToNodeTransform:function(){return cc.affineTransformInvert(this.getNodeToWorldTransform())},worldToNodeTransform:function(){return this.getWorldToNodeTransform()},convertToNodeSpace:function(t){return cc.pointApplyAffineTransform(t,this.getWorldToNodeTransform())},convertToWorldSpace:function(t){return t=t||cc.v2(0,0),cc.pointApplyAffineTransform(t,this.getNodeToWorldTransform())},convertToNodeSpaceAR:function(t){return cc.pSub(this.convertToNodeSpace(t),this._renderCmd.getAnchorPointInPoints())},convertToWorldSpaceAR:function(t){t=t||cc.v2(0,0);var e=cc.pAdd(t,this._renderCmd.getAnchorPointInPoints());return this.convertToWorldSpace(e)},_convertToWindowSpace:function(t){var e=this.convertToWorldSpace(t);return cc.director.convertToUI(e)},convertTouchToNodeSpace:function(t){var e=t.getLocation();return this.convertToNodeSpace(e)},convertTouchToNodeSpaceAR:function(t){var e=cc.director.convertToGL(t.getLocation());return this.convertToNodeSpaceAR(e)},updateTransform:function(){for(var t=this._children,e=0;e0){for(this._reorderChildDirty&&this.sortAllChildren(),r=0;r0)for(s=r._renderCmd,o=0,a=i.length;o0?e.flags.ParentInCamera:0)},culling:function(t,e){cc.macro.ENABLE_CULLING?(this._updateCameraFlag(t),this._doCulling&&this._doCulling(),e&&n(this._node,"culling")):this._doCulling&&(this._needDraw=!0)},getNodeToParentTransform:function(){return this._dirtyFlag&r.transformDirty&&this.transform(),this._transform},setNodeToParentTransform:function(t){t?(this._transform=t,this._transformUpdated=!0):this._transformUpdated=!1,this.setDirtyFlag(r.transformDirty)},_propagateFlagsDown:function(t){if(t){var e=this._dirtyFlag,i=t._node,n=t._dirtyFlag;i._cascadeColorEnabled&&n&r.colorDirty&&(e|=r.colorDirty),i._cascadeOpacityEnabled&&n&r.opacityDirty&&(e|=r.opacityDirty),n&r.transformDirty&&(e|=r.transformDirty),n&r.cullingDirty&&(e|=r.cullingDirty),this._dirtyFlag=e}},visit:function(t){var e=this._node,i=cc.renderer;t&&(this._curLevel=t._curLevel+1),this._propagateFlagsDown(t),isNaN(e._customZ)&&(e._vertexZ=i.assignedZ,i.assignedZ+=i.assignedZStep),this._syncStatus(t)},_updateDisplayColor:function(t){var e,i,n,s,o=this._node,a=this._displayedColor,c=o._realColor;if(this._notifyRegionStatus&&this._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.Dirty),this._cascadeColorEnabledDirty&&!o._cascadeColorEnabled){a.r=c.r,a.g=c.g,a.b=c.b;var h=new cc.Color(255,255,255,255);for(e=0,i=(n=o._children).length;e=0;e--)this._removeTargetInSg(t[e])}},addTarget:function(t){-1===this._targets.indexOf(t)&&(this._addSgTargetInSg(t),this._targets.push(t))},removeTarget:function(t){-1!==this._targets.indexOf(t)&&(this._removeTargetInSg(t),cc.js.array.remove(this._targets,t))},getTargets:function(){return this._targets},getNodeToCameraTransform:function(t){var e=t.getNodeToWorldTransform();return this.containsNode(t)&&(e=cc.affineTransformConcatIn(e,cc.Camera.main.viewMatrix)),e},getCameraToWorldPoint:function(t){return cc.Camera.main&&(t=cc.pointApplyAffineTransform(t,cc.Camera.main.invertViewMatrix)),t},containsNode:function(t){t instanceof cc.Node&&(t=t._sgNode);for(var e=this._sgTarges;t;){if(-1!==e.indexOf(t))return!0;t=t.parent}return!1},_setSgNodesCullingDirty:function(){for(var t=this._sgTarges,e=0;e=0;a--){var c=e[a];c._cameraInfo.touched!==i&&this._removeTargetInSg(c)}},lateUpdate:function(){this._checkSgTargets();var t=this.viewMatrix,e=this.invertViewMatrix,i=this.viewPort,n=cc.visibleRect,r=this.visibleRect,s=this.node.getNodeToWorldTransformAR(),o=.5*-(Math.atan2(s.b,s.a)+Math.atan2(-s.c,s.d)),a=1,c=0,h=0,l=1;o&&(h=Math.sin(o),a=l=Math.cos(o),c=-h);var u=this.zoomRatio;a*=u,c*=u,h*=u,l*=u,t.a=a,t.b=c,t.c=h,t.d=l;var _=n.center;t.tx=_.x-(a*s.tx+h*s.ty),t.ty=_.y-(c*s.tx+l*s.ty),cc.affineTransformInvertOut(t,e),i.x=n.bottomLeft.x,i.y=n.bottomLeft.y,i.width=n.width,i.height=n.height,cc._rectApplyAffineTransformIn(i,e),r.left.x=i.xMin,r.right.x=i.xMax,r.bottom.y=i.yMin,r.top.y=i.yMax,this._sgNode.setTransform(a,c,h,l,t.tx,t.ty);var d=this._lastViewMatrix;d.a===t.a&&d.b===t.b&&d.c===t.c&&d.d===t.d&&d.tx===t.tx&&d.ty===t.ty||(this._setSgNodesCullingDirty(),d.a=t.a,d.b=t.b,d.c=t.c,d.d=t.d,d.tx=t.tx,d.ty=t.ty)}});r.flags=cc.Enum({InCamera:1,ParentInCamera:2}),e.exports=cc.Camera=r}),{"./CCSGCameraNode":61}],61:[(function(t,e,i){var n=new cc.math.Matrix4,r=_ccsg.Node.extend({ctor:function(){this._super(),this._mat=new cc.math.Matrix4,this._mat.identity(),this._beforeVisitCmd=new cc.CustomRenderCmd(this,this._onBeforeVisit),this._afterVisitCmd=new cc.CustomRenderCmd(this,this._onAfterVisit)},setTransform:function(t,e,i,n,r,s){var o=this._mat.mat;o[0]=t,o[1]=e,o[4]=i,o[5]=n,o[12]=r,o[13]=s},addTarget:function(t){var e=t._cameraInfo;e.sgCameraNode=this,e.originVisit=t.visit,t.visit=this._visit},removeTarget:function(t){t.visit=t._cameraInfo.originVisit},_visit:function(t){var e=this._cameraInfo,i=e.sgCameraNode;cc.renderer.pushRenderCommand(i._beforeVisitCmd),e.originVisit.call(this,t),cc.renderer.pushRenderCommand(i._afterVisitCmd)},_onBeforeVisit:function(){cc.renderer._breakBatch(),cc.math.glMatrixMode(cc.math.KM_GL_PROJECTION),n.assignFrom(cc.current_stack.top),n.multiply(this._mat),cc.current_stack.push(n)},_onAfterVisit:function(){cc.renderer._breakBatch(),cc.math.glMatrixMode(cc.math.KM_GL_PROJECTION),cc.current_stack.pop()}});e.exports=_ccsg.CameraNode=r}),{}],62:[(function(t,e,i){cc.Collider.Box=cc.Class({properties:{_offset:cc.v2(0,0),_size:cc.size(100,100),offset:{tooltip:!1,get:function(){return this._offset},set:function(t){this._offset=t},type:cc.Vec2},size:{tooltip:!1,get:function(){return this._size},set:function(t){this._size.width=t.width<0?0:t.width,this._size.height=t.height<0?0:t.height},type:cc.Size}},resetInEditor:!1});var n=cc.Class({name:"cc.BoxCollider",extends:cc.Collider,mixins:[cc.Collider.Box],editor:!1});cc.BoxCollider=e.exports=n}),{}],63:[(function(t,e,i){cc.Collider.Circle=cc.Class({properties:{_offset:cc.v2(0,0),_radius:50,offset:{get:function(){return this._offset},set:function(t){this._offset=t},type:cc.Vec2},radius:{tooltip:!1,get:function(){return this._radius},set:function(t){this._radius=t<0?0:t}}},resetInEditor:!1});var n=cc.Class({name:"cc.CircleCollider",extends:cc.Collider,mixins:[cc.Collider.Circle],editor:!1});cc.CircleCollider=e.exports=n}),{}],64:[(function(t,e,i){var n=cc.Class({name:"cc.Collider",extends:cc.Component,properties:{editing:{default:!1,serializable:!1,tooltip:!1},tag:{tooltip:!1,default:0,range:[0,1e7],type:cc.Integer}},onDisable:function(){cc.director.getCollisionManager().removeCollider(this)},onEnable:function(){cc.director.getCollisionManager().addCollider(this)}});cc.Collider=e.exports=n}),{}],65:[(function(t,e,i){var n=t("./CCContact"),r=n.CollisionType,s=cc.rect(),o=cc.v2(),a=cc.Class({mixins:[cc.EventTarget],properties:{enabled:!1,enabledDrawBoundingBox:!1},ctor:function(){this.__instanceId=cc.ClassManager.getNewInstanceId(),this._contacts=[],this._colliders=[],this._debugDrawer=null,this._enabledDebugDraw=!1},update:function(t){if(this.enabled){var e,i,n=this._colliders;for(e=0,i=n.length;em&&(m=y.x),y.xg&&(g=y.y),y.y=0){e.splice(i,1);for(var n=this._contacts,s=n.length-1;s>=0;s--){var o=n[s];o.collider1!==t&&o.collider2!==t||(o.touching&&this._doCollide(r.CollisionExit,o),n.splice(s,1))}t.node.off("group-changed",this.onNodeGroupChanged,this)}else cc.errorID(6600)},attachDebugDrawToCamera:function(t){this._debugDrawer&&t.addTarget(this._debugDrawer)},detachDebugDrawFromCamera:function(t){this._debugDrawer&&t.removeTarget(this._debugDrawer)},onNodeGroupChanged:function(t){for(var e=t.currentTarget.getComponents(cc.Collider),i=0,n=e.length;i0){t.strokeColor=cc.Color.WHITE,t.moveTo(s[0].x,s[0].y);for(var o=1;or!=u>r&&n<(l-c)*(r-h)/(u-h)+c&&(i=!i)}return i}function o(t,e,i,n){var r,s=i.x-e.x,o=i.y-e.y,a=s*s+o*o,c=((t.x-e.x)*s+(t.y-e.y)*o)/a;return r=n?a?c<0?e:c>1?i:cc.v2(e.x+c*s,e.y+c*o):e:cc.v2(e.x+c*s,e.y+c*o),s=t.x-r.x,o=t.y-r.y,Math.sqrt(s*s+o*o)}var a={};a.lineLine=n,a.lineRect=function(t,e,i){var r=new cc.Vec2(i.x,i.y),s=new cc.Vec2(i.x,i.yMax),o=new cc.Vec2(i.xMax,i.yMax),a=new cc.Vec2(i.xMax,i.y);return!!(n(t,e,r,s)||n(t,e,s,o)||n(t,e,o,a)||n(t,e,a,r))},a.linePolygon=r,a.rectRect=function(t,e){var i=t.x,n=t.y,r=t.x+t.width,s=t.y+t.height,o=e.x,a=e.y,c=e.x+e.width,h=e.y+e.height;return i<=c&&r>=o&&n<=h&&s>=a},a.rectPolygon=function(t,e){var i,n,o=new cc.Vec2(t.x,t.y),a=new cc.Vec2(t.x,t.yMax),c=new cc.Vec2(t.xMax,t.yMax),h=new cc.Vec2(t.xMax,t.y);if(r(o,a,e))return!0;if(r(a,c,e))return!0;if(r(c,h,e))return!0;if(r(h,o,e))return!0;for(i=0,n=e.length;i>>1;r<=s;o=r+s>>>1){var a=t[o],c=a.constructor._executionOrder;if(c>i)s=o-1;else if(cn)s=o-1;else{if(!(h0&&(t.array.sort(s),this._invoke(t),t.array.length=0),this._invoke(this._zero),this._zero.array.length=0;var e=this._pos;e.array.length>0&&(e.array.sort(s),this._invoke(e),e.array.length=0)}}),g=cc.Class({extends:p,add:function(t){var e=t.constructor._executionOrder;if(0===e)this._zero.array.push(t);else{var i=e<0?this._neg.array:this._pos.array,r=n(i,t);r<0&&i.splice(~r,0,t)}},remove:function(t){var e=t.constructor._executionOrder;if(0===e)this._zero.fastRemove(t);else{var i=e<0?this._neg:this._pos,r=n(i.array,t);r>=0&&i.removeAt(r)}},invoke:function(t){this._neg.array.length>0&&this._invoke(this._neg,t),this._invoke(this._zero,t),this._pos.array.length>0&&this._invoke(this._pos,t)}}),y=cc.Class({ctor:a,unscheduleAll:a,statics:{LifeCycleInvoker:p,OneOffInvoker:m,createInvokeImpl:o,invokeOnEnable:function(t){var e=cc.director._compScheduler,i=t.array;for(t.i=0;t.i=0?h.fastRemoveAt(this.scheduleInNextFrame,e):(!t.start||t._objFlags&l||this.startInvoker.remove(t),t.update&&this.updateInvoker.remove(t),t.lateUpdate&&this.lateUpdateInvoker.remove(t))},enableComp:function(t,e){if(!(t._objFlags&u)){if(t.onEnable){if(e)return void e.add(t);t.onEnable();if(!t.node._activeInHierarchy)return}this._onEnabled(t)}},disableComp:function(t){t._objFlags&u&&(t.onDisable&&t.onDisable(),this._onDisabled(t))},_scheduleImmediate:function(t){!t.start||t._objFlags&l||this.startInvoker.add(t),t.update&&this.updateInvoker.add(t),t.lateUpdate&&this.lateUpdateInvoker.add(t)},_deferredSchedule:function(){for(var t=this.scheduleInNextFrame,e=0,i=t.length;e0&&this._deferredSchedule(),this.startInvoker.invoke()},updatePhase:function(t){this.updateInvoker.invoke(t)},lateUpdatePhase:function(t){this.lateUpdateInvoker.invoke(t),this._updating=!1}});e.exports=y}),{"./platform/CCClass":176,"./platform/CCObject":182,"./platform/js":197,"./utils/misc":226}],71:[(function(t,e,i){function n(t,e){return t===e||t&&e&&(t.name===e.name||t._uuid===e._uuid)}var r=t("../../animation/animation-animator"),s=t("../../animation/animation-clip"),o=cc.Class({name:"cc.Animation",extends:t("./CCComponent"),mixins:[cc.EventTarget],editor:!1,ctor:function(){cc.EventTarget.call(this),this._animator=null,this._nameToState={},this._didInit=!1,this._currentClip=null},properties:{_defaultClip:{default:null,type:s},defaultClip:{type:s,get:function(){return this._defaultClip},set:function(t){return void 0},tooltip:!1},currentClip:{get:function(){return this._currentClip},set:function(t){this._currentClip=t},type:s,visible:!1},_clips:{default:[],type:[s],tooltip:!1,visible:!0},playOnLoad:{default:!1,tooltip:!1}},start:function(){if(this.playOnLoad&&this._defaultClip){if(!(this._animator&&this._animator.isPlaying)){var t=this.getAnimationState(this._defaultClip.name);this._animator.playState(t)}}},onEnable:function(){this._animator&&this._animator.resume()},onDisable:function(){this._animator&&this._animator.pause()},onDestroy:function(){this.stop()},getClips:function(){return this._clips},play:function(t,e){var i=this.playAdditive(t,e);return this._animator.stopStatesExcept(i),i},playAdditive:function(t,e){this._init();var i=this.getAnimationState(t||this._defaultClip&&this._defaultClip.name);if(i){this.enabled=!0;var n=this._animator;n.isPlaying&&i.isPlaying?i.isPaused?n.resumeState(i):(n.stopState(i),n.playState(i,e)):n.playState(i,e),this.currentClip=i.clip}return i},stop:function(t){if(this._didInit)if(t){var e=this._nameToState[t];e&&this._animator.stopState(e)}else this._animator.stop()},pause:function(t){if(this._didInit)if(t){var e=this._nameToState[t];e&&this._animator.pauseState(e)}else this.enabled=!1},resume:function(t){if(this._didInit)if(t){var e=this._nameToState[t];e&&this._animator.resumeState(e)}else this.enabled=!0},setCurrentTime:function(t,e){if(this._init(),e){var i=this._nameToState[e];i&&this._animator.setStateTime(i,t)}else this._animator.setStateTime(t)},getAnimationState:function(t){this._init();var e=this._nameToState[t];return e&&!e.curveLoaded&&this._animator._reloadClip(e),e||null},addClip:function(t,e){if(t){this._init(),cc.js.array.contains(this._clips,t)||this._clips.push(t),e=e||t.name;var i=this._nameToState[e];if(i){if(i.clip===t)return i;var n=this._clips.indexOf(i.clip);-1!==n&&this._clips.splice(n,1)}var r=new cc.AnimationState(t,e);return this._nameToState[e]=r,r}cc.warnID(3900)},removeClip:function(t,e){if(t){this._init();var i;for(var n in this._nameToState){if((i=this._nameToState[n]).clip===t)break}if(t===this._defaultClip){if(!e)return void cc.warnID(3902);this._defaultClip=null}if(i&&i.isPlaying){if(!e)return void cc.warnID(3903);this.stop(i.name)}this._clips=this._clips.filter((function(e){return e!==t})),i&&delete this._nameToState[i.name]}else cc.warnID(3901)},sample:function(t){if(this._init(),t){var e=this._nameToState[t];e&&e.sample()}else this._animator.sample()},on:function(t,e,i,n){this._init();for(var r=cc.EventTarget.prototype.on.call(this,t,e,i,n),s=this._animator._anims.array,o=0;o0&&(i=this.time/this.duration),i>=1&&(i=1,this._transitionFinished=!0),this.transition===n.COLOR?e.color=this._fromColor.lerp(this._toColor,i):this.transition===n.SCALE&&(e.scale=cc.lerp(this._fromScale,this._toScale,i))}},_registerEvent:function(){this.node.on(cc.Node.EventType.TOUCH_START,this._onTouchBegan,this),this.node.on(cc.Node.EventType.TOUCH_MOVE,this._onTouchMove,this),this.node.on(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this),this.node.on(cc.Node.EventType.TOUCH_CANCEL,this._onTouchCancel,this),this.node.on(cc.Node.EventType.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.on(cc.Node.EventType.MOUSE_LEAVE,this._onMouseMoveOut,this)},_getTargetSprite:function(t){var e=null;return t&&(e=t.getComponent(cc.Sprite)),e},_applyTarget:function(){this._sprite=this._getTargetSprite(this.target),this.target&&(this._originalScale=this.target.scale)},_onTouchBegan:function(t){this.interactable&&this.enabledInHierarchy&&(this._pressed=!0,this._updateState(),t.stopPropagation())},_onTouchMove:function(t){if(this.interactable&&this.enabledInHierarchy&&this._pressed){var e=t.touch,i=this.node._hitTest(e.getLocation());if(this.transition===n.SCALE&&this.target)i?(this._fromScale=this._originalScale,this._toScale=this._originalScale*this.zoomScale,this._transitionFinished=!1):(this.time=0,this._transitionFinished=!0,this.target.scale=this._originalScale);else{var r;r=i?"pressed":"normal",this._applyTransition(r)}t.stopPropagation()}},_onTouchEnded:function(t){this.interactable&&this.enabledInHierarchy&&(this._pressed&&(cc.Component.EventHandler.emitEvents(this.clickEvents,t),this.node.emit("click",this)),this._pressed=!1,this._updateState(),t.stopPropagation())},_zoomUp:function(){this._fromScale=this._originalScale,this._toScale=this._originalScale*this.zoomScale,this.time=0,this._transitionFinished=!1},_zoomBack:function(){this._fromScale=this.target.scale,this._toScale=this._originalScale,this.time=0,this._transitionFinished=!1},_onTouchCancel:function(){this.interactable&&this.enabledInHierarchy&&(this._pressed=!1,this._updateState())},_onMouseMoveIn:function(){!this._pressed&&this.interactable&&this.enabledInHierarchy&&(this.transition!==n.SPRITE||this.hoverSprite)&&(this._hovered||(this._hovered=!0,this._updateState()))},_onMouseMoveOut:function(){this._hovered&&(this._hovered=!1,this._updateState())},_updateState:function(){var t=this._getButtonState();this._applyTransition(t),this._updateDisabledState()},onDisable:function(){this._hovered=!1,this._pressed=!1,this.node.off(cc.Node.EventType.TOUCH_START,this._onTouchBegan,this),this.node.off(cc.Node.EventType.TOUCH_MOVE,this._onTouchMove,this),this.node.off(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this),this.node.off(cc.Node.EventType.TOUCH_CANCEL,this._onTouchCancel,this),this.node.off(cc.Node.EventType.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.off(cc.Node.EventType.MOUSE_LEAVE,this._onMouseMoveOut,this)},_getButtonState:function(){return this.interactable?this._pressed?"pressed":this._hovered?"hover":"normal":"disabled"},_updateColorTransition:function(t){var e=this[t+"Color"],i=this.target;this._fromColor=i.color.clone(),this._toColor=e,this.time=0,this._transitionFinished=!1},_updateSpriteTransition:function(t){var e=this[t+"Sprite"];this._sprite&&e&&(this._sprite.spriteFrame=e)},_updateScaleTransition:function(t){"pressed"===t?this._zoomUp():this._zoomBack()},_applyTransition:function(t){var e=this.transition;e===n.COLOR?this._updateColorTransition(t):e===n.SPRITE?this._updateSpriteTransition(t):e===n.SCALE&&this._updateScaleTransition(t)},_resizeNodeToTargetNode:!1,_updateDisabledState:function(){this._sprite&&this._sprite._sgNode.setState(0),this.enableAutoGrayEffect&&this.transition!==n.COLOR&&(this.transition===n.SPRITE&&this.disabledSprite||this._sprite&&!this.interactable&&this._sprite._sgNode.setState(1))}});cc.Button=e.exports=r}),{"./CCComponent":76}],75:[(function(t,e,i){var n=t("../event-manager"),r={getContentSize:function(){return cc.visibleRect},setContentSize:function(t){},_getWidth:function(){return this.getContentSize().width},_getHeight:function(){return this.getContentSize().height}},s=cc.Class({name:"cc.Canvas",extends:t("./CCComponent"),editor:!1,resetInEditor:!1,statics:{instance:null},properties:{_designResolution:cc.size(960,640),designResolution:{get:function(){return cc.size(this._designResolution)},set:function(t){this._designResolution.width=t.width,this._designResolution.height=t.height,this.applySettings()},tooltip:!1},_fitWidth:!1,_fitHeight:!0,fitHeight:{get:function(){return this._fitHeight},set:function(t){this._fitHeight!==t&&(this._fitHeight=t,this.applySettings())},tooltip:!1},fitWidth:{get:function(){return this._fitWidth},set:function(t){this._fitWidth!==t&&(this._fitWidth=t,this.applySettings())},tooltip:!1}},ctor:function(){this._thisOnResized=this.onResized.bind(this)},__preload:function(){if(s.instance)return cc.errorID(6700,this.node.name,s.instance.node.name);if(s.instance=this,this.node._sizeProvider){}else this.node._sizeProvider=r;cc.director.on(cc.Director.EVENT_BEFORE_VISIT,this.alignWithScreen,this),cc.sys.isMobile?window.addEventListener("resize",this._thisOnResized):n.addCustomListener("canvas-resize",this._thisOnResized),this.applySettings(),this.onResized()},onDestroy:function(){this.node._sizeProvider===r&&(this.node._sizeProvider=null),cc.director.off(cc.Director.EVENT_BEFORE_VISIT,this.alignWithScreen,this),cc.sys.isMobile?window.removeEventListener("resize",this._thisOnResized):n.removeCustomListeners("canvas-resize",this._thisOnResized),s.instance===this&&(s.instance=null)},alignWithScreen:function(){var t,e=cc.visibleRect,i=0,n=0;!this.fitHeight&&!this.fitWidth&&(i=.5*((t=cc.view.getDesignResolutionSize()).width-e.width),n=.5*(t.height-e.height)),this.node.setPosition(.5*e.width+i,.5*e.height+n)},onResized:function(){this.alignWithScreen()},applySettings:function(){var t,e=cc.ResolutionPolicy;t=this.fitHeight&&this.fitWidth?e.SHOW_ALL:this.fitHeight||this.fitWidth?this.fitWidth?e.FIXED_WIDTH:e.FIXED_HEIGHT:e.NO_BORDER;var i=this._designResolution;cc.view.setDesignResolutionSize(i.width,i.height,t)}});cc.Canvas=e.exports=s}),{"../event-manager":110,"./CCComponent":76}],76:[(function(t,e,i){var n=t("../platform/CCObject"),r=t("../platform/js"),s=new(t("../platform/id-generater"))("Comp"),o=n.Flags.IsOnEnableCalled,a=n.Flags.IsOnLoadCalled,c=cc.Class({name:"cc.Component",extends:n,ctor:function(){this.__instanceId=cc.ClassManager.getNewInstanceId(),this.__eventTargets=[]},properties:{node:{default:null,visible:!1},name:{get:function(){if(this._name)return this._name;var t=cc.js.getClassName(this),e=t.lastIndexOf(".");return e>=0&&(t=t.slice(e+1)),this.node.name+"<"+t+">"},set:function(t){this._name=t},visible:!1},_id:{default:"",serializable:!1},uuid:{get:function(){var t=this._id;return t||(t=this._id=s.getNewId()),t},visible:!1},__scriptAsset:!1,_enabled:!0,enabled:{get:function(){return this._enabled},set:function(t){if(this._enabled!==t&&(this._enabled=t,this.node._activeInHierarchy)){var e=cc.director._compScheduler;t?e.enableComp(this):e.disableComp(this)}},visible:!1},enabledInHierarchy:{get:function(){return(this._objFlags&o)>0},visible:!1},_isOnLoadCalled:{get:function(){return this._objFlags&a}}},update:null,lateUpdate:null,__preload:null,onLoad:null,start:null,onEnable:null,onDisable:null,onDestroy:null,onFocusInEditor:null,onLostFocusInEditor:null,resetInEditor:null,addComponent:function(t){return this.node.addComponent(t)},getComponent:function(t){return this.node.getComponent(t)},getComponents:function(t){return this.node.getComponents(t)},getComponentInChildren:function(t){return this.node.getComponentInChildren(t)},getComponentsInChildren:function(t){return this.node.getComponentsInChildren(t)},_getLocalBounds:null,onRestore:null,destroy:function(){this._super()&&this._enabled&&this.node._activeInHierarchy&&cc.director._compScheduler.disableComp(this)},_onPreDestroy:function(){this.unscheduleAllCallbacks();for(var t=this.__eventTargets,e=0,i=t.length;e=0,1620),e=e||0,i=isNaN(i)?cc.macro.REPEAT_FOREVER:i,n=n||0;var r=cc.director.getScheduler(),s=r.isTargetPaused(this);r.schedule(t,this,e,i,n,s)},scheduleOnce:function(t,e){this.schedule(t,0,0,e)},unschedule:function(t){t&&cc.director.getScheduler().unschedule(t,this)},unscheduleAllCallbacks:function(){cc.director.getScheduler().unscheduleAllForTarget(this)}});c._requireComponent=null,c._executionOrder=0,r.value(c,"_registerEditorProps",(function(t,e){var i=e.requireComponent;i&&(t._requireComponent=i);var n=e.executionOrder;n&&"number"==typeof n&&(t._executionOrder=n)})),c.prototype.__scriptUuid="",cc.Component=e.exports=c}),{"../platform/CCObject":182,"../platform/id-generater":193,"../platform/js":197}],77:[(function(t,e,i){cc.Component.EventHandler=cc.Class({name:"cc.ClickEvent",properties:{target:{default:null,type:cc.Node},component:{default:""},handler:{default:""},customEventData:{default:""}},statics:{emitEvents:function(t){"use strict";var e,i,n;if(arguments.length>0)for(i=0,n=(e=new Array(arguments.length-1)).length;ip&&(p=m),h.height>=p&&(m=p,p=h.height,v=h.getAnchorPoint().y),this.horizontalDirection===a.RIGHT_TO_LEFT&&(C=1-h.anchorX),d=d+l*C*h.width+l*this.spacingX;var T=l*(1-C)*h.width;if(e){var b=d+T+l*(l>0?this.paddingRight:this.paddingLeft),A=this.horizontalDirection===a.LEFT_TO_RIGHT&&b>(1-c.x)*t,S=this.horizontalDirection===a.RIGHT_TO_LEFT&&b<-c.x*t;(A||S)&&(h.height>=p?(0===m&&(m=p),f+=m,m=p):(f+=p,m=h.height,p=0),d=_+l*(u+C*h.width),g++)}var w=i(h,f,g);t>=h.width+this.paddingLeft+this.paddingRight&&s&&h.setPosition(cc.p(d,w));var E,I=1,R=0===p?h.height:p;this.verticalDirection===o.TOP_TO_BOTTOM?(y=y||this.node._contentSize.height,(E=w+(I=-1)*(R*v+this.paddingBottom))y&&(y=E)),d+=T}}.bind(this)),y},_getVerticalBaseHeight:function(t){var e=0,i=0;return this.resizeMode===r.CONTAINER?(t.forEach((function(t){t.activeInHierarchy&&(i++,e+=t.height)})),e+=(i-1)*this.spacingY+this.paddingBottom+this.paddingTop):e=this.node.getContentSize().height,e},_doLayoutVertically:function(t,e,i,s){var c=this.node.getAnchorPoint(),h=this.node.children,l=1,u=this.paddingBottom,_=-c.y*t;this.verticalDirection===o.TOP_TO_BOTTOM&&(l=-1,_=(1-c.y)*t,u=this.paddingTop);var d=_+l*u-l*this.spacingY,f=0,p=0,m=0,g=0,y=0,v=0,x=this.cellSize.height;return this.type!==n.GRID&&this.resizeMode===r.CHILDREN&&(x=(t-(this.paddingTop+this.paddingBottom)-(h.length-1)*this.spacingY)/h.length),h.forEach(function(h){if(h.activeInHierarchy){this.resizeMode===r.CHILDREN&&(h.height=x,this.type===n.GRID&&(h.width=this.cellSize.width));var C=h.anchorY;m>p&&(p=m),h.width>=p&&(m=p,p=h.width,v=h.getAnchorPoint().x),this.verticalDirection===o.TOP_TO_BOTTOM&&(C=1-h.anchorY),d=d+l*C*h.height+l*this.spacingY;var T=l*(1-C)*h.height;if(e){var b=d+T+l*(l>0?this.paddingTop:this.paddingBottom),A=this.verticalDirection===o.BOTTOM_TO_TOP&&b>(1-c.y)*t,S=this.verticalDirection===o.TOP_TO_BOTTOM&&b<-c.y*t;(A||S)&&(h.width>=p?(0===m&&(m=p),f+=m,m=p):(f+=p,m=h.width,p=0),d=_+l*(u+C*h.height),g++)}var w=i(h,f,g);t>=h.height+(this.paddingTop+this.paddingBottom)&&s&&h.setPosition(cc.p(w,d));var E,I=1,R=0===p?h.width:p;this.horizontalDirection===a.RIGHT_TO_LEFT?(I=-1,y=y||this.node._contentSize.width,(E=w+I*(R*v+this.paddingLeft))y&&(y=E)),d+=T}}.bind(this)),y},_doLayoutBasic:function(){var t=null;if(this.node.children.forEach((function(e){e.activeInHierarchy&&(t=t?cc.rectUnion(t,e.getBoundingBoxToWorld()):e.getBoundingBoxToWorld())})),t){var e=this.node.parent.convertToNodeSpaceAR(cc.p(t.x,t.y));e=cc.pAdd(e,cc.p(-this.paddingLeft,-this.paddingBottom));var i=this.node.parent.convertToNodeSpaceAR(cc.p(t.x+t.width,t.y+t.height));i=cc.pAdd(i,cc.p(this.paddingRight,this.paddingTop));var n=cc.size(parseFloat((i.x-e.x).toFixed(2)),parseFloat((i.y-e.y).toFixed(2))),r=this.node.getPosition(),s=(r.x-e.x)/n.width,o=(r.y-e.y)/n.height,a=cc.p(parseFloat(s.toFixed(2)),parseFloat(o.toFixed(2)));this.node.setAnchorPoint(a),this.node.setContentSize(n)}},_doLayoutGridAxisHorizontal:function(t,e){var i=e.width,n=1,s=-t.y*e.height,a=this.paddingBottom;this.verticalDirection===o.TOP_TO_BOTTOM&&(n=-1,s=(1-t.y)*e.height,a=this.paddingTop);var c=function(t,e,i){return s+n*(e+t.anchorY*t.height+a+i*this.spacingY)}.bind(this),h=0;if(this.resizeMode===r.CONTAINER){var l=this._doLayoutHorizontally(i,!0,c,!1);(h=s-l)<0&&(h*=-1),s=-t.y*h,this.verticalDirection===o.TOP_TO_BOTTOM&&(n=-1,s=(1-t.y)*h)}this._doLayoutHorizontally(i,!0,c,!0),this.resizeMode===r.CONTAINER&&this.node.setContentSize(i,h)},_doLayoutGridAxisVertical:function(t,e){var i=e.height,n=1,s=-t.x*e.width,o=this.paddingLeft;this.horizontalDirection===a.RIGHT_TO_LEFT&&(n=-1,s=(1-t.x)*e.width,o=this.paddingRight);var c=function(t,e,i){return s+n*(e+t.anchorX*t.width+o+i*this.spacingX)}.bind(this),h=0;if(this.resizeMode===r.CONTAINER){var l=this._doLayoutVertically(i,!0,c,!1);(h=s-l)<0&&(h*=-1),s=-t.x*h,this.horizontalDirection===a.RIGHT_TO_LEFT&&(n=-1,s=(1-t.x)*h)}this._doLayoutVertically(i,!0,c,!0),this.resizeMode===r.CONTAINER&&this.node.setContentSize(h,i)},_doLayoutGrid:function(){var t=this.node.getAnchorPoint(),e=this.node.getContentSize();this.startAxis===s.HORIZONTAL?this._doLayoutGridAxisHorizontal(t,e):this.startAxis===s.VERTICAL&&this._doLayoutGridAxisVertical(t,e)},_getHorizontalBaseWidth:function(t){var e=0,i=0;return this.resizeMode===r.CONTAINER?(t.forEach((function(t){t.activeInHierarchy&&(i++,e+=t.width)})),e+=(i-1)*this.spacingX+this.paddingLeft+this.paddingRight):e=this.node.getContentSize().width,e},_doLayout:function(){if(this.type===n.HORIZONTAL){var t=this._getHorizontalBaseWidth(this.node.children),e=function(t){return t.y};this._doLayoutHorizontally(t,!1,e,!0),this.node.width=t}else if(this.type===n.VERTICAL){var i=this._getVerticalBaseHeight(this.node.children),s=function(t){return t.x};this._doLayoutVertically(i,!1,s,!0),this.node.height=i}else this.type===n.NONE?this.resizeMode===r.CONTAINER&&this._doLayoutBasic():this.type===n.GRID&&this._doLayoutGrid()},updateLayout:function(){this._layoutDirty&&this.node.children.length>0&&(this._doLayout(),this._layoutDirty=!1)}});Object.defineProperty(c.prototype,"padding",{get:function(){return cc.warnID(4100),this.paddingLeft},set:function(t){this._N$padding=t,this._migratePaddingData(),this._doLayoutDirty()}}),cc.Layout=e.exports=c}),{"./CCComponent":76}],82:[(function(t,e,i){t("../../clipping-nodes/CCClippingNode"),t("../../clipping-nodes/CCClippingNodeCanvasRenderCmd"),t("../../clipping-nodes/CCClippingNodeWebGLRenderCmd"),t("../../shape-nodes/CCDrawNode");var n=cc._RendererInSG,r=cc.Enum({RECT:0,ELLIPSE:1,IMAGE_STENCIL:2}),s=cc.Class({name:"cc.Mask",extends:n,editor:!1,properties:{_clippingStencil:{default:null,serializable:!1},_type:r.RECT,type:{get:function(){return this._type},set:function(t){this._type=t,this._refreshStencil()},type:r,tooltip:!1},spriteFrame:{default:null,type:cc.SpriteFrame,tooltip:!1,notify:function(){this._refreshStencil()}},alphaThreshold:{default:1,type:cc.Float,range:[0,1,.1],slide:!0,tooltip:!1,notify:function(){cc._renderType!==cc.game.RENDER_TYPE_CANVAS?this._sgNode.setAlphaThreshold(this.alphaThreshold):cc.warnID(4201)}},inverted:{default:!1,type:cc.Boolean,tooltip:!1,notify:function(){cc._renderType!==cc.game.RENDER_TYPE_CANVAS?this._sgNode.setInverted(this.inverted):cc.warnID(4202)}},_segements:64,segements:{get:function(){return this._segements},set:function(t){this._segements=cc.clampf(t,3,1e4),this._refreshStencil()},tooltip:!1},_resizeToTarget:{animatable:!1,set:function(t){t&&this._resizeNodeToTargetNode()}}},statics:{Type:r},_resizeNodeToTargetNode:!1,_initSgNode:function(){},_createSgNode:function(){return new cc.ClippingNode},_hitTest:function(t){var e=this.node.getContentSize(),i=e.width,n=e.height,s=this.node.getNodeToWorldTransform();if(this.type===r.RECT||this.type===r.IMAGE_STENCIL){var o=cc.rect(0,0,i,n);cc._rectApplyAffineTransformIn(o,s);var a=t.x-o.x,c=o.x+o.width-t.x,h=t.y-o.y,l=o.y+o.height-t.y;return a>=0&&c>=0&&l>=0&&h>=0}if(this.type===r.ELLIPSE){var u=i/2,_=n/2,d=s.a*u+s.c*_+s.tx,f=s.b*u+s.d*_+s.ty,p=t.x-d,m=t.y-f;return p*p/(u*u)+m*m/(_*_)<1}},onEnable:function(){this._super(),this.spriteFrame&&this.spriteFrame.ensureLoadTexture(),this._refreshStencil(),this.node.on("size-changed",this._refreshStencil,this),this.node.on("anchor-changed",this._refreshStencil,this)},onDisable:function(){this._super(),this.node.off("size-changed",this._refreshStencil,this),this.node.off("anchor-changed",this._refreshStencil,this)},_calculateCircle:function(t,e,i){for(var n=[],r=2*Math.PI/i,s=0;s=this._pages.length?this.addPage(t):(this._pages.splice(e,0,t),this.content.addChild(t),this._updatePageView())}},removePage:function(t){if(t&&this.content){var e=this._pages.indexOf(t);-1!==e?this.removePageAtIndex(e):cc.warnID(4300,t.name)}},removePageAtIndex:function(t){var e=this._pages;if(!(t<0||t>=e.length)){var i=e[t];i&&(this.content.removeChild(i),e.splice(t,1),this._updatePageView())}},removeAllPages:function(){if(this.content){for(var t=this._pages,e=0,i=t.length;e=this._pages.length||(e=void 0!==e?e:.3,this._curPageIdx=t,this.scrollToOffset(this._moveOffsetValue(t),e,!0),this.indicator&&this.indicator._changedState())},getScrollEndedEventTiming:function(){return this.pageTurningEventTiming},_syncScrollDirection:function(){this.horizontal=this.direction===r.Horizontal,this.vertical=this.direction===r.Vertical},_syncSizeMode:function(){if(this.content){var t=this.content.getComponent(cc.Layout);if(t){if(0===this._pages.length)t.padding=0;else{var e=this._pages[this._pages.length-1];this.sizeMode===n.Free&&(this.direction===r.Horizontal?(t.paddingLeft=(this.node.width-this._pages[0].width)/2,t.paddingRight=(this.node.width-e.width)/2):this.direction===r.Vertical&&(t.paddingTop=(this.node.height-this._pages[0].height)/2,t.paddingBottom=(this.node.height-e.height)/2))}t.updateLayout()}}},_updatePageView:function(){var t=this._pages.length;this._curPageIdx>=t&&(this._curPageIdx=0===t?0:t-1,this._lastPageIdx=this._curPageIdx);for(var e=0;e=0||this._pages.push(i)}this._syncScrollDirection(),this._syncSizeMode(),this._updatePageView()}},_dispatchPageTurningEvent:function(){this._lastPageIdx!==this._curPageIdx&&(this._lastPageIdx=this._curPageIdx,cc.Component.EventHandler.emitEvents(this.pageEvents,this,s.PAGE_TURNING),this.node.emit("page-turning",this))},_isScrollable:function(t,e,i){if(this.sizeMode===n.Free){var s,o;if(this.direction===r.Horizontal)return s=this._scrollCenterOffsetX[e],o=this._scrollCenterOffsetX[i],Math.abs(t.x)>=Math.abs(s-o)*this.scrollThreshold;if(this.direction===r.Vertical)return s=this._scrollCenterOffsetY[e],o=this._scrollCenterOffsetY[i],Math.abs(t.y)>=Math.abs(s-o)*this.scrollThreshold}else{if(this.direction===r.Horizontal)return Math.abs(t.x)>=this.node.width*this.scrollThreshold;if(this.direction===r.Vertical)return Math.abs(t.y)>=this.node.height*this.scrollThreshold}},_isQuicklyScrollable:function(t){if(this.direction===r.Horizontal){if(Math.abs(t.x)>this.autoPageTurningThreshold)return!0}else if(this.direction===r.Vertical&&Math.abs(t.y)>this.autoPageTurningThreshold)return!0;return!1},_moveOffsetValue:function(t){var e=cc.p(0,0);return this.sizeMode===n.Free?this.direction===r.Horizontal?e.x=this._scrollCenterOffsetX[t]:this.direction===r.Vertical&&(e.y=this._scrollCenterOffsetY[t]):this.direction===r.Horizontal?e.x=t*this.node.width:this.direction===r.Vertical&&(e.y=t*this.node.height),e},_getDragDirection:function(t){return this.direction===r.Horizontal?0===t.x?0:t.x>0?1:-1:this.direction===r.Vertical?0===t.y?0:t.y<0?1:-1:void 0},_handleReleaseLogic:function(t){var e=this._startBounceBackIfNeeded(),i=cc.pSub(this._touchBeganPosition,this._touchEndPosition);if(e){var n=this._getDragDirection(i);if(0===n)return;this._curPageIdx=n>0?this._pages.length-1:0,this.indicator&&this.indicator._changedState()}else{var r=this._curPageIdx,s=r+this._getDragDirection(i),o=this.pageTurningSpeed*Math.abs(r-s);if(s=t.length)){for(var i=0;it.length)for(i=0;i0;--i){var n=t[i-1];this.node.removeChild(n),t.splice(i-1,1)}}this._layout&&this._layout.enabledInHierarchy&&this._layout.updateLayout(),this._changedState()}}}});cc.PageViewIndicator=e.exports=r}),{"./CCComponent":76}],85:[(function(t,e,i){var n=cc.Enum({HORIZONTAL:0,VERTICAL:1,FILLED:2}),r=cc.Class({name:"cc.ProgressBar",extends:t("./CCComponent"),editor:!1,_initBarSprite:function(){if(this.barSprite){var t=this.barSprite.node;if(!t)return;var e=this.node.getContentSize(),i=this.node.getAnchorPoint(),r=t.getContentSize();t.parent===this.node&&this.node.setContentSize(r),this.barSprite.fillType===cc.Sprite.FillType.RADIAL&&(this.mode=n.FILLED);var s=t.getContentSize();if(this.mode===n.HORIZONTAL?this.totalLength=s.width:this.mode===n.VERTICAL?this.totalLength=s.height:this.totalLength=this.barSprite.fillRange,t.parent===this.node){var o=-e.width*i.x;t.setPosition(cc.p(o,0))}}},_updateBarStatus:function(){if(this.barSprite){var t=this.barSprite.node;if(!t)return;var e,i,r,s=t.getAnchorPoint(),o=t.getContentSize(),a=t.getPosition(),c=cc.p(0,.5),h=cc.clamp01(this.progress),l=this.totalLength*h;switch(this.mode){case n.HORIZONTAL:this.reverse&&(c=cc.p(1,.5)),e=cc.size(l,o.height),i=this.totalLength,r=o.height;break;case n.VERTICAL:c=this.reverse?cc.p(.5,1):cc.p(.5,0),e=cc.size(o.width,l),i=o.width,r=this.totalLength}if(this.mode===n.FILLED)this.barSprite.type!==cc.Sprite.Type.FILLED?cc.warn("ProgressBar FILLED mode only works when barSprite's Type is FILLED!"):(this.reverse&&(l*=-1),this.barSprite.fillRange=l);else if(this.barSprite.type!==cc.Sprite.Type.FILLED){var u=c.x-s.x,_=c.y-s.y,d=cc.p(i*u,r*_);t.setPosition(cc.pAdd(a,d)),t.setAnchorPoint(c),t.setContentSize(e)}else cc.warn("ProgressBar non-FILLED mode only works when barSprite's Type is non-FILLED!")}},properties:{barSprite:{default:null,type:cc.Sprite,tooltip:!1,notify:function(){this._initBarSprite()},animatable:!1},mode:{default:n.HORIZONTAL,type:n,tooltip:!1,notify:function(){if(this.barSprite){var t=this.barSprite.node;if(!t)return;var e=t.getContentSize();this.mode===n.HORIZONTAL?this.totalLength=e.width:this.mode===n.VERTICAL?this.totalLength=e.height:this.mode===n.FILLED&&(this.totalLength=this.barSprite.fillRange)}},animatable:!1},_N$totalLength:1,totalLength:{range:[0,Number.MAX_VALUE],tooltip:!1,get:function(){return this._N$totalLength},set:function(t){this.mode===n.FILLED&&(t=cc.clamp01(t)),this._N$totalLength=t,this._updateBarStatus()}},progress:{default:1,type:"Float",range:[0,1,.1],slide:!0,tooltip:!1,notify:function(){this._updateBarStatus()}},reverse:{default:!1,tooltip:!1,notify:function(){this.barSprite&&(this.barSprite.fillStart=1-this.barSprite.fillStart),this._updateBarStatus()},animatable:!1}},statics:{Mode:n}});cc.ProgressBar=e.exports=r}),{"./CCComponent":76}],86:[(function(t,e,i){var n=cc.Class({extends:t("./CCSGComponent"),name:"cc._RendererInSG",ctor:function(){var t=this._sgNode=this._createSgNode();t.setVisible(!1),this._plainNode=new _ccsg.Node},__preload:function(){this._initSgNode()},onEnable:function(){this._replaceSgNode(this._sgNode)},onDisable:function(){this._replaceSgNode(this._plainNode)},onDestroy:function(){this._removeSgNode()},_replaceSgNode:function(t){var e=this.node,i=e._sgNode;i._entity=null;var n=i.getChildren().slice();i.removeAllChildren(!1),t.getChildrenCount()>0&&t.removeAllChildren(!1);for(var r=0,s=n.length;rRichText",multiline:!0,tooltip:!1,notify:function(){this._updateRichTextStatus()}},horizontalAlign:{default:n.LEFT,type:n,tooltip:!1,animatable:!1,notify:function(t){this.horizontalAlign!==t&&(this._layoutDirty=!0,this._updateRichTextStatus())}},fontSize:{default:40,tooltip:!1,notify:function(t){this.fontSize!==t&&(this._layoutDirty=!0,this._updateRichTextStatus())}},font:{default:null,type:cc.TTFFont,tooltip:!1,notify:function(t){this.font!==t&&(this._layoutDirty=!0,this.font&&this._onTTFLoaded(),this._updateRichTextStatus())}},maxWidth:{default:0,tooltip:!1,notify:function(t){this.maxWidth!==t&&(this._layoutDirty=!0,this._updateRichTextStatus())}},lineHeight:{default:40,tooltip:!1,notify:function(t){this.lineHeight!==t&&(this._layoutDirty=!0,this._updateRichTextStatus())}},imageAtlas:{default:null,type:cc.SpriteAtlas,tooltip:!1,notify:function(t){this.imageAtlas!==t&&(this._layoutDirty=!0,this._updateRichTextStatus())}},handleTouchEvent:{default:!0,tooltip:!1,notify:function(t){this.handleTouchEvent!==t&&this.enabledInHierarchy&&(this.handleTouchEvent?this._addEventListeners():this._removeEventListeners())}}},statics:{HorizontalAlign:n,VerticalAlign:r},onEnable:function(){this._super(),this.handleTouchEvent&&this._addEventListeners()},onDisable:function(){this._super(),this.handleTouchEvent&&this._removeEventListeners()},_addEventListeners:function(){this.node.on(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this)},_removeEventListeners:function(){this.node.off(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this)},_createSgNode:function(){var t=new _ccsg.Node;t.setCascadeOpacityEnabled(!0);var e=this;return t.setColor=function(){e._updateLabelSegmentTextAttributes()},t._setContentSize=t.setContentSize,t.setContentSize=function(){},t},_updateLabelSegmentTextAttributes:function(){this._labelSegments.forEach(function(t){this._applyTextAttribute(t)}.bind(this))},_initSgNode:function(){this._updateRichText(),this._onTTFLoaded()},_createFontLabel:function(t){return _ccsg.Label.pool.get(t,this.font,null,this.fontSize)},_getFontRawUrl:function(){return this.font instanceof cc.TTFFont?this.font.rawUrl:""},_onTTFLoaded:function(){var t=this._getFontRawUrl();if(t){var e=this;cc.CustomFontLoader.loadTTF(t,(function(){e._layoutDirty=!0,e._updateRichText()}))}},_measureText:function(t,e){var i=this,n=function(e){var n;0===i._labelSegmentsCache.length?(n=i._createFontLabel(e),i._labelSegmentsCache.push(n)):(n=i._labelSegmentsCache[0]).setString(e),n._styleIndex=t,i._applyTextAttribute(n);return n.getContentSize().width};return e?n(e):n},_onTouchEnded:function(t){for(var e=this.node.getComponents(cc.Component),i=0;i0&&n+this._lineOffsetX>this.maxWidth)for(var r=0;this._lineOffsetX<=this.maxWidth;){var s=this._getFirstWordLen(t,r,t.length),o=t.substr(r,s),a=this._measureText(i,o);if(!(this._lineOffsetX+a<=this.maxWidth)){if(r>0){var c=t.substr(0,r);this._addLabelSegment(c,i),t=t.substr(r,t.length),n=this._measureText(i,t)}this._updateLineInfo();break}this._lineOffsetX+=a,r+=s}if(n>this.maxWidth)for(var h=cc.TextUtils.fragmentText(t,n,this.maxWidth,this._measureText(i)),l=0;l1&&l0&&h0&&(o=c),this.maxWidth>0?(this._lineOffsetX+o>this.maxWidth&&this._updateLineInfo(),this._lineOffsetX+=o):(this._lineOffsetX+=o,this._lineOffsetX>this._labelWidth&&(this._labelWidth=this._lineOffsetX)),this._applySpriteFrame(i),n.setContentSize(o,a),n._lineCount=this._lineCount,t.style.event&&t.style.event.click&&(n._clickHandler=t.style.event.click)}else cc.warnID(4400)},_updateRichText:function(){if(this.enabled){var t=cc.htmlTextParser.parse(this.string);if(!this._needsUpdateTextLayout(t))return this._textArray=t,void this._updateLabelSegmentTextAttributes();this._textArray=t,this._resetState();for(var e,i=!1,n=0;n0){var h=this._measureText(n,c);this._updateRichTextWithMaxWidth(c,h,n),o.length>1&&athis._labelWidth&&(this._labelWidth=this._lineOffsetX),o.length>1&&a0&&(this._labelWidth=this.maxWidth),this._labelHeight=this._lineCount*this.lineHeight,this.node.setContentSize(this._labelWidth,this._labelHeight),this._sgNode._setContentSize(this._labelWidth,this._labelHeight),this._updateRichTextPosition(),this._layoutDirty=!1}},_getFirstWordLen:function(t,e,i){var n=t.charAt(e);if(cc.TextUtils.isUnicodeCJK(n)||cc.TextUtils.isUnicodeSpace(n))return 1;for(var r=1,s=e+1;se&&(t=0,e=s);var o=0;switch(this.horizontalAlign){case cc.TextAlignment.LEFT:o=0;break;case cc.TextAlignment.CENTER:o=(this._labelWidth-this._linesWidth[s-1])/2;break;case cc.TextAlignment.RIGHT:o=this._labelWidth-this._linesWidth[s-1]}r.setPositionX(t+o);var a=r.getContentSize(),c=(i-s)*this.lineHeight;r instanceof cc.Scale9Sprite&&(c+=(this.lineHeight-r.getContentSize().height)/2),r.setPositionY(c),s===e&&(t+=a.width)}},_convertLiteralColorValue:function(t){var e=t.toUpperCase();return cc.Color[e]?cc.Color[e]:cc.hexToColor(t)},_applyTextAttribute:function(t){if(!(t instanceof cc.Scale9Sprite)){var e=t._styleIndex;t.setLineHeight(this.lineHeight),t.setVerticalAlign(r.CENTER);var i=null;this._textArray[e]&&(i=this._textArray[e].style),i&&i.color?t.setColor(this._convertLiteralColorValue(i.color)):t.setColor(this.node.color),i&&i.bold?t.enableBold(!0):t.enableBold(!1),i&&i.italic?t.enableItalics(!0):t.enableItalics(!1),i&&i.underline?t.enableUnderline(!0):t.enableUnderline(!1),i&&i.outline?(t.setOutlined(!0),t.setOutlineColor(this._convertLiteralColorValue(i.outline.color)),t.setOutlineWidth(i.outline.width),t.setMargin(i.outline.width)):(t.setOutlined(!1),t.setMargin(0)),i&&i.size?t.setFontSize(i.size):t.setFontSize(this.fontSize),i&&i.event&&i.event.click&&(t._clickHandler=i.event.click)}},onDestroy:function(){this._super();for(var t=0;t0?n:-n));return i*(e/r)},_calculatePosition:function(t,e,i,r,s,o){var a=t-e;s&&(a+=Math.abs(s));var c=0;a&&(c=r/a,c=cc.clamp01(c));var h=(i-o)*c;return this.direction===n.VERTICAL?cc.p(0,h):cc.p(h,0)},_updateLength:function(t){if(this.handle){var e=this.handle.node,i=e.getContentSize();e.setAnchorPoint(cc.p(0,0)),this.direction===n.HORIZONTAL?e.setContentSize(t,i.height):e.setContentSize(i.width,t)}},_processAutoHide:function(t){if(this.enableAutoHide&&!(this._autoHideRemainingTime<=0)&&!this._touching&&(this._autoHideRemainingTime-=t,this._autoHideRemainingTime<=this.autoHideTime)){this._autoHideRemainingTime=Math.max(0,this._autoHideRemainingTime);var e=this._opacity*(this._autoHideRemainingTime/this.autoHideTime);this._setOpacity(e)}},start:function(){this.enableAutoHide&&this._setOpacity(0)},hide:function(){this._autoHideRemainingTime=0,this._setOpacity(0)},show:function(){this._autoHideRemainingTime=this.autoHideTime,this._setOpacity(this._opacity)},update:function(t){this._processAutoHide(t)}});cc.Scrollbar=e.exports=r}),{"./CCComponent":76}],91:[(function(t,e,i){var n=function(){return(new Date).getMilliseconds()},r=cc.Enum({SCROLL_TO_TOP:0,SCROLL_TO_BOTTOM:1,SCROLL_TO_LEFT:2,SCROLL_TO_RIGHT:3,SCROLLING:4,BOUNCE_TOP:5,BOUNCE_BOTTOM:6,BOUNCE_LEFT:7,BOUNCE_RIGHT:8,SCROLL_ENDED:9,TOUCH_UP:10,AUTOSCROLL_ENDED_WITH_THRESHOLD:11,SCROLL_BEGAN:12}),s={"scroll-to-top":r.SCROLL_TO_TOP,"scroll-to-bottom":r.SCROLL_TO_BOTTOM,"scroll-to-left":r.SCROLL_TO_LEFT,"scroll-to-right":r.SCROLL_TO_RIGHT,scrolling:r.SCROLLING,"bounce-bottom":r.BOUNCE_BOTTOM,"bounce-left":r.BOUNCE_LEFT,"bounce-right":r.BOUNCE_RIGHT,"bounce-top":r.BOUNCE_TOP,"scroll-ended":r.SCROLL_ENDED,"touch-up":r.TOUCH_UP,"scroll-ended-with-threshold":r.AUTOSCROLL_ENDED_WITH_THRESHOLD,"scroll-began":r.SCROLL_BEGAN},o=cc.Class({name:"cc.ScrollView",extends:t("./CCViewGroup"),editor:!1,ctor:function(){this._topBoundary=0,this._bottomBoundary=0,this._leftBoundary=0,this._rightBoundary=0,this._touchMoveDisplacements=[],this._touchMoveTimeDeltas=[],this._touchMovePreviousTimestamp=0,this._touchMoved=!1,this._autoScrolling=!1,this._autoScrollAttenuate=!1,this._autoScrollStartPosition=cc.p(0,0),this._autoScrollTargetDelta=cc.p(0,0),this._autoScrollTotalTime=0,this._autoScrollAccumulatedTime=0,this._autoScrollCurrentlyOutOfBoundary=!1,this._autoScrollBraking=!1,this._autoScrollBrakingStartPosition=cc.p(0,0),this._outOfBoundaryAmount=cc.p(0,0),this._outOfBoundaryAmountDirty=!0,this._stopMouseWheel=!1,this._mouseWheelEventElapsedTime=0,this._isScrollEndedWithThresholdEventFired=!1,this._scrollEventEmitMask=0,this._isBouncing=!1,this._scrolling=!1},properties:{content:{default:void 0,type:cc.Node,tooltip:!1},horizontal:{default:!0,animatable:!1,tooltip:!1},vertical:{default:!0,animatable:!1,tooltip:!1},inertia:{default:!0,tooltip:!1},brake:{default:.5,type:"Float",range:[0,1,.1],tooltip:!1},elastic:{default:!0,animatable:!1,tooltip:!1},bounceDuration:{default:1,range:[0,10],tooltip:!1},horizontalScrollBar:{default:void 0,type:cc.Scrollbar,tooltip:!1,notify:function(){this.horizontalScrollBar&&(this.horizontalScrollBar.setTargetScrollView(this),this._updateScrollBar(0))},animatable:!1},verticalScrollBar:{default:void 0,type:cc.Scrollbar,tooltip:!1,notify:function(){this.verticalScrollBar&&(this.verticalScrollBar.setTargetScrollView(this),this._updateScrollBar(0))},animatable:!1},scrollEvents:{default:[],type:cc.Component.EventHandler,tooltip:!1},cancelInnerEvents:{default:!0,animatable:!1,tooltip:!1}},statics:{EventType:r},scrollToBottom:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.p(0,0),applyToHorizontal:!1,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i,!0)},scrollToTop:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.p(0,1),applyToHorizontal:!1,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToLeft:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.p(0,0),applyToHorizontal:!0,applyToVertical:!1});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToRight:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.p(1,0),applyToHorizontal:!0,applyToVertical:!1});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToTopLeft:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.p(0,1),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToTopRight:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.p(1,1),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToBottomLeft:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.p(0,0),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToBottomRight:function(t,e){var i=this._calculateMovePercentDelta({anchor:cc.p(1,0),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},scrollToOffset:function(t,e,i){var n=this.getMaxScrollOffset(),r=cc.p(0,0);0===n.x?r.x=0:r.x=t.x/n.x,0===n.y?r.y=1:r.y=(n.y-t.y)/n.y,this.scrollTo(r,e,i)},getScrollOffset:function(){var t=this._getContentTopBoundary()-this._topBoundary,e=this._getContentLeftBoundary()-this._leftBoundary;return cc.p(e,t)},getMaxScrollOffset:function(){var t=this.node.getContentSize(),e=this.content.getContentSize(),i=e.width-t.width,n=e.height-t.height;return i=i>=0?i:0,n=n>=0?n:0,cc.p(i,n)},scrollToPercentHorizontal:function(t,e,i){var n=this._calculateMovePercentDelta({anchor:cc.p(t,0),applyToHorizontal:!0,applyToVertical:!1});e?this._startAutoScroll(n,e,!1!==i):this._moveContent(n)},scrollTo:function(t,e,i){var n=this._calculateMovePercentDelta({anchor:t,applyToHorizontal:!0,applyToVertical:!0});e?this._startAutoScroll(n,e,!1!==i):this._moveContent(n)},scrollToPercentVertical:function(t,e,i){var n=this._calculateMovePercentDelta({anchor:cc.p(0,t),applyToHorizontal:!1,applyToVertical:!0});e?this._startAutoScroll(n,e,!1!==i):this._moveContent(n)},stopAutoScroll:function(){this._autoScrolling=!1,this._autoScrollAccumulatedTime=this._autoScrollTotalTime},setContentPosition:function(t){cc.pFuzzyEqual(t,this.getContentPosition(),1e-4)||(this.content.setPosition(t),this._outOfBoundaryAmountDirty=!0)},getContentPosition:function(){return this.content.getPosition()},isScrolling:function(){return this._scrolling},isAutoScrolling:function(){return this._autoScrolling},_registerEvent:function(){this.node.on(cc.Node.EventType.TOUCH_START,this._onTouchBegan,this,!0),this.node.on(cc.Node.EventType.TOUCH_MOVE,this._onTouchMoved,this,!0),this.node.on(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this,!0),this.node.on(cc.Node.EventType.TOUCH_CANCEL,this._onTouchCancelled,this,!0),this.node.on(cc.Node.EventType.MOUSE_WHEEL,this._onMouseWheel,this,!0)},_unregisterEvent:function(){this.node.off(cc.Node.EventType.TOUCH_START,this._onTouchBegan,this,!0),this.node.off(cc.Node.EventType.TOUCH_MOVE,this._onTouchMoved,this,!0),this.node.off(cc.Node.EventType.TOUCH_END,this._onTouchEnded,this,!0),this.node.off(cc.Node.EventType.TOUCH_CANCEL,this._onTouchCancelled,this,!0),this.node.off(cc.Node.EventType.MOUSE_WHEEL,this._onMouseWheel,this,!0)},_onMouseWheel:function(t,e){if(this.enabledInHierarchy&&!this._hasNestedViewGroup(t,e)){var i=cc.p(0,0),n=-.1;0,this.vertical?i=cc.p(0,t.getScrollY()*n):this.horizontal&&(i=cc.p(t.getScrollY()*n,0)),this._mouseWheelEventElapsedTime=0,this._processDeltaMove(i),this._stopMouseWheel||(this._handlePressLogic(),this.schedule(this._checkMouseWheel,1/60),this._stopMouseWheel=!0),this._stopPropagationIfTargetIsMe(t)}},_checkMouseWheel:function(t){var e=this._getHowMuchOutOfBoundary();if(!cc.pFuzzyEqual(e,cc.p(0,0),1e-4))return this._processInertiaScroll(),this.unschedule(this._checkMouseWheel),void(this._stopMouseWheel=!1);this._mouseWheelEventElapsedTime+=t,this._mouseWheelEventElapsedTime>.1&&(this._onScrollBarTouchEnded(),this.unschedule(this._checkMouseWheel),this._stopMouseWheel=!1)},_calculateMovePercentDelta:function(t){var e=t.anchor,i=t.applyToHorizontal,n=t.applyToVertical;this._calculateBoundary(),e=cc.pClamp(e,cc.p(0,0),cc.p(1,1));var r=this.node.getContentSize(),s=this.content.getContentSize(),o=this._getContentBottomBoundary()-this._bottomBoundary;o=-o;var a=this._getContentLeftBoundary()-this._leftBoundary;a=-a;var c=cc.p(0,0),h=0;return i&&(h=s.width-r.width,c.x=a-h*e.x),n&&(h=s.height-r.height,c.y=o-h*e.y),c},_moveContentToTopLeft:function(t){var e=this.content.getContentSize(),i=this._getContentBottomBoundary()-this._bottomBoundary;i=-i;var n=cc.p(0,0),r=0,s=this._getContentLeftBoundary()-this._leftBoundary;s=-s,e.height7&&!this._touchMoved&&t.target!==this.node){var r=new cc.Event.EventTouch(t.getTouches(),t.bubbles);r.type=cc.Node.EventType.TOUCH_CANCEL,r.touch=t.touch,r.simulate=!0,t.target.dispatchEvent(r),this._touchMoved=!0}this._stopPropagationIfTargetIsMe(t)}}},_onTouchEnded:function(t,e){if(this.enabledInHierarchy&&!this._hasNestedViewGroup(t,e)){this._dispatchEvent("touch-up");var i=t.touch;this.content&&this._handleReleaseLogic(i),this._touchMoved?t.stopPropagation():this._stopPropagationIfTargetIsMe(t)}},_onTouchCancelled:function(t,e){if(this.enabledInHierarchy&&!this._hasNestedViewGroup(t,e)){if(!t.simulate){var i=t.touch;this.content&&this._handleReleaseLogic(i)}this._stopPropagationIfTargetIsMe(t)}},_processDeltaMove:function(t){this._scrollChildren(t),this._gatherTouchMove(t)},_handleMoveLogic:function(t){var e=t.getDelta();this._processDeltaMove(e)},_scrollChildren:function(t){var e,i=t=this._clampDelta(t);this.elastic&&(e=this._getHowMuchOutOfBoundary(),i.x*=0===e.x?1:.5,i.y*=0===e.y?1:.5),this.elastic||(e=this._getHowMuchOutOfBoundary(i),i=cc.pAdd(i,e));var n=-1;if(i.y>0){this.content.y-this.content.anchorY*this.content.height+i.y>this._bottomBoundary&&(n="scroll-to-bottom")}else if(i.y<0){this.content.y-this.content.anchorY*this.content.height+this.content.height+i.y<=this._topBoundary&&(n="scroll-to-top")}else if(i.x<0){this.content.x-this.content.anchorX*this.content.width+this.content.width+i.x<=this._rightBoundary&&(n="scroll-to-right")}else if(i.x>0){this.content.x-this.content.anchorX*this.content.width+i.x>=this._leftBoundary&&(n="scroll-to-left")}this._moveContent(i,!1),0===i.x&&0===i.y||(this._scrolling||(this._scrolling=!0,this._dispatchEvent("scroll-began")),this._dispatchEvent("scrolling")),-1!==n&&this._dispatchEvent(n)},_handlePressLogic:function(){this._autoScrolling&&this._dispatchEvent("scroll-ended"),this._autoScrolling=!1,this._isBouncing=!1,this._touchMovePreviousTimestamp=n(),this._touchMoveDisplacements.length=0,this._touchMoveTimeDeltas.length=0,this._onScrollBarTouchBegan()},_clampDelta:function(t){var e=this.content.getContentSize(),i=this.node.getContentSize();return e.width=5;)this._touchMoveDisplacements.shift(),this._touchMoveTimeDeltas.shift();this._touchMoveDisplacements.push(t);var e=n();this._touchMoveTimeDeltas.push((e-this._touchMovePreviousTimestamp)/1e3),this._touchMovePreviousTimestamp=e},_startBounceBackIfNeeded:function(){if(!this.elastic)return!1;var t=this._getHowMuchOutOfBoundary();if(t=this._clampDelta(t),cc.pFuzzyEqual(t,cc.p(0,0),1e-4))return!1;var e=Math.max(this.bounceDuration,0);return this._startAutoScroll(t,e,!0),this._isBouncing||(t.y>0&&this._dispatchEvent("bounce-top"),t.y<0&&this._dispatchEvent("bounce-bottom"),t.x>0&&this._dispatchEvent("bounce-right"),t.x<0&&this._dispatchEvent("bounce-left"),this._isBouncing=!0),!0},_processInertiaScroll:function(){if(!this._startBounceBackIfNeeded()&&this.inertia){var t=this._calculateTouchMoveVelocity();!cc.pFuzzyEqual(t,cc.p(0,0),1e-4)&&this.brake<1&&this._startInertiaScroll(t)}this._onScrollBarTouchEnded()},_handleReleaseLogic:function(t){var e=t.getDelta();this._gatherTouchMove(e),this._processInertiaScroll(),this._scrolling&&(this._scrolling=!1,this._autoScrolling||this._dispatchEvent("scroll-ended"))},_isOutOfBoundary:function(){var t=this._getHowMuchOutOfBoundary();return!cc.pFuzzyEqual(t,cc.p(0,0),1e-4)},_isNecessaryAutoScrollBrake:function(){if(this._autoScrollBraking)return!0;if(this._isOutOfBoundary()){if(!this._autoScrollCurrentlyOutOfBoundary)return this._autoScrollCurrentlyOutOfBoundary=!0,this._autoScrollBraking=!0,this._autoScrollBrakingStartPosition=this.getContentPosition(),!0}else this._autoScrollCurrentlyOutOfBoundary=!1;return!1},getScrollEndedEventTiming:function(){return 1e-4},_processAutoScrolling:function(t){var e=this._isNecessaryAutoScrollBrake(),i=e?.05:1;this._autoScrollAccumulatedTime+=t*(1/i);var n=Math.min(1,this._autoScrollAccumulatedTime/this._autoScrollTotalTime);this._autoScrollAttenuate&&(n=(function(t){return(t-=1)*t*t*t*t+1})(n));var r=cc.pAdd(this._autoScrollStartPosition,cc.pMult(this._autoScrollTargetDelta,n)),s=Math.abs(n-1)<=1e-4;if(Math.abs(n-1)<=this.getScrollEndedEventTiming()&&!this._isScrollEndedWithThresholdEventFired&&(this._dispatchEvent("scroll-ended-with-threshold"),this._isScrollEndedWithThresholdEventFired=!0),this.elastic){var o=cc.pSub(r,this._autoScrollBrakingStartPosition);e&&(o=cc.pMult(o,i)),r=cc.pAdd(this._autoScrollBrakingStartPosition,o)}else{var a=cc.pSub(r,this.getContentPosition()),c=this._getHowMuchOutOfBoundary(a);cc.pFuzzyEqual(c,cc.p(0,0),1e-4)||(r=cc.pAdd(r,c),s=!0)}s&&(this._autoScrolling=!1);var h=cc.pSub(r,this.getContentPosition());this._moveContent(h,s),this._dispatchEvent("scrolling"),this._autoScrolling||(this._isBouncing=!1,this._dispatchEvent("scroll-ended"))},_startInertiaScroll:function(t){var e=cc.pMult(t,.7);this._startAttenuatingAutoScroll(e,t)},_calculateAttenuatedFactor:function(t){if(this.brake<=0)return 1-this.brake;return(1-this.brake)*(1/(1+14e-6*t+t*t*8e-9))},_startAttenuatingAutoScroll:function(t,e){var i=this._calculateAutoScrollTimeByInitalSpeed(cc.pLength(e)),n=cc.pNormalize(t),r=this.content.getContentSize(),s=this.node.getContentSize(),o=r.width-s.width,a=r.height-s.height,c=this._calculateAttenuatedFactor(o),h=this._calculateAttenuatedFactor(a);n=cc.p(n.x*o*(1-this.brake)*c,n.y*a*h*(1-this.brake));var l=cc.pLength(t),u=cc.pLength(n)/l;n=cc.pAdd(n,t),this.brake>0&&u>7&&(u=Math.sqrt(u),n=cc.pAdd(cc.pMult(t,u),t)),this.brake>0&&u>3&&(i*=u=3),0===this.brake&&u>1&&(i*=u),this._startAutoScroll(n,i,!0)},_calculateAutoScrollTimeByInitalSpeed:function(t){return Math.sqrt(Math.sqrt(t/5))},_startAutoScroll:function(t,e,i){var n=this._flattenVectorByDirection(t);this._autoScrolling=!0,this._autoScrollTargetDelta=n,this._autoScrollAttenuate=i,this._autoScrollStartPosition=this.getContentPosition(),this._autoScrollTotalTime=e,this._autoScrollAccumulatedTime=0,this._autoScrollBraking=!1,this._isScrollEndedWithThresholdEventFired=!1,this._autoScrollBrakingStartPosition=cc.p(0,0);var r=this._getHowMuchOutOfBoundary();if(!cc.pFuzzyEqual(r,cc.p(0,0),1e-4)){this._autoScrollCurrentlyOutOfBoundary=!0;var s=this._getHowMuchOutOfBoundary(n);(r.x*s.x>0||r.y*s.y>0)&&(this._autoScrollBraking=!0)}},_calculateTouchMoveVelocity:function(){var t=0;if((t=this._touchMoveTimeDeltas.reduce((function(t,e){return t+e}),t))<=0||t>=.5)return cc.p(0,0);var e=cc.p(0,0);return e=this._touchMoveDisplacements.reduce((function(t,e){return cc.pAdd(t,e)}),e),cc.p(e.x*(1-this.brake)/t,e.y*(1-this.brake)/t)},_flattenVectorByDirection:function(t){var e=t;return e.x=this.horizontal?e.x:0,e.y=this.vertical?e.y:0,e},_moveContent:function(t,e){var i=this._flattenVectorByDirection(t),n=cc.pAdd(this.getContentPosition(),i);this.setContentPosition(n);var r=this._getHowMuchOutOfBoundary();this._updateScrollBar(r),this.elastic&&e&&this._startBounceBackIfNeeded()},_getContentLeftBoundary:function(){return this.getContentPosition().x-this.content.getAnchorPoint().x*this.content.getContentSize().width},_getContentRightBoundary:function(){var t=this.content.getContentSize();return this._getContentLeftBoundary()+t.width},_getContentTopBoundary:function(){var t=this.content.getContentSize();return this._getContentBottomBoundary()+t.height},_getContentBottomBoundary:function(){return this.getContentPosition().y-this.content.getAnchorPoint().y*this.content.getContentSize().height},_getHowMuchOutOfBoundary:function(t){if(t=t||cc.p(0,0),cc.pFuzzyEqual(t,cc.p(0,0),1e-4)&&!this._outOfBoundaryAmountDirty)return this._outOfBoundaryAmount;var e=cc.p(0,0);return this._getContentLeftBoundary()+t.x>this._leftBoundary?e.x=this._leftBoundary-(this._getContentLeftBoundary()+t.x):this._getContentRightBoundary()+t.xthis._bottomBoundary&&(e.y=this._bottomBoundary-(this._getContentBottomBoundary()+t.y)),cc.pFuzzyEqual(t,cc.p(0,0),1e-4)&&(this._outOfBoundaryAmount=e,this._outOfBoundaryAmountDirty=!1),e=this._clampDelta(e)},_updateScrollBar:function(t){this.horizontalScrollBar&&this.horizontalScrollBar._onScroll(t),this.verticalScrollBar&&this.verticalScrollBar._onScroll(t)},_onScrollBarTouchBegan:function(){this.horizontalScrollBar&&this.horizontalScrollBar._onTouchBegan(),this.verticalScrollBar&&this.verticalScrollBar._onTouchBegan()},_onScrollBarTouchEnded:function(){this.horizontalScrollBar&&this.horizontalScrollBar._onTouchEnded(),this.verticalScrollBar&&this.verticalScrollBar._onTouchEnded()},_dispatchEvent:function(t){if("scroll-ended"===t)this._scrollEventEmitMask=0;else if("scroll-to-top"===t||"scroll-to-bottom"===t||"scroll-to-left"===t||"scroll-to-right"===t){var e=1<0&&t[0].check()}},onEnable:function(){this.node.on("child-added",this._allowOnlyOneToggleChecked,this),this.node.on("child-removed",this._makeAtLeastOneToggleChecked,this)},onDisable:function(){this.node.off("child-added",this._allowOnlyOneToggleChecked,this),this.node.off("child-removed",this._makeAtLeastOneToggleChecked,this)},start:function(){this._makeAtLeastOneToggleChecked()}});t("../platform/js").get(n.prototype,"toggleItems",(function(){return this.node.getComponentsInChildren(cc.Toggle)})),cc.ToggleContainer=e.exports=n}),{"../platform/js":197}],98:[(function(t,e,i){var n=cc.Class({name:"cc.ToggleGroup",extends:cc.Component,ctor:function(){this._toggleItems=[]},editor:!1,properties:{allowSwitchOff:{tooltip:!1,default:!1},toggleItems:{get:function(){return this._toggleItems}}},updateToggles:function(t){this.enabledInHierarchy&&this._toggleItems.forEach((function(e){t.isChecked&&e!==t&&e.isChecked&&e.enabled&&(e.isChecked=!1)}))},addToggle:function(t){-1===this._toggleItems.indexOf(t)&&this._toggleItems.push(t),this._allowOnlyOneToggleChecked()},removeToggle:function(t){var e=this._toggleItems.indexOf(t);e>-1&&this._toggleItems.splice(e,1),this._makeAtLeastOneToggleChecked()},_allowOnlyOneToggleChecked:function(){var t=!1;return this._toggleItems.forEach((function(e){t&&e.enabled&&(e.isChecked=!1),e.isChecked&&e.enabled&&(t=!0)})),t},_makeAtLeastOneToggleChecked:function(){this._allowOnlyOneToggleChecked()||this.allowSwitchOff||this._toggleItems.length>0&&(this._toggleItems[0].isChecked=!0)},start:function(){this._makeAtLeastOneToggleChecked()}}),r=(t("../platform/js"),!1);cc.js.get(cc,"ToggleGroup",(function(){return r||(cc.logID(1405,"cc.ToggleGroup","cc.ToggleContainer"),r=!0),n})),cc.ToggleGroup=e.exports=n}),{"../platform/js":197}],99:[(function(t,e,i){t("../videoplayer/CCSGVideoPlayer");var n=_ccsg.VideoPlayer.EventType,r=cc.Enum({REMOTE:0,LOCAL:1}),s=cc.Class({name:"cc.VideoPlayer",extends:cc._RendererUnderSG,editor:!1,properties:{_resourceType:r.REMOTE,resourceType:{tooltip:!1,type:r,set:function(t){this._resourceType=t,this._updateVideoSource()},get:function(){return this._resourceType}},_remoteURL:"",remoteURL:{tooltip:!1,type:cc.String,set:function(t){this._remoteURL=t,this._updateVideoSource()},get:function(){return this._remoteURL}},_clip:{default:null,url:cc.RawAsset},clip:{tooltip:!1,get:function(){return this._clip},set:function(t){"string"!=typeof t&&(t=""),this._clip=t,this._updateVideoSource()},url:cc.RawAsset},currentTime:{tooltip:!1,type:cc.Float,set:function(t){this._sgNode&&this._sgNode.seekTo(t)},get:function(){return this._sgNode?this._sgNode.currentTime():-1}},keepAspectRatio:{tooltip:!1,default:!0,type:cc.Boolean,notify:function(){this._sgNode.setKeepAspectRatioEnabled(this.keepAspectRatio)}},isFullscreen:{tooltip:!1,default:!1,type:cc.Boolean,notify:function(){this._sgNode.setFullScreenEnabled(this.isFullscreen)}},videoPlayerEvent:{default:[],type:cc.Component.EventHandler}},statics:{EventType:n,ResourceType:r},onLoad:function(){0},_createSgNode:function(){return new _ccsg.VideoPlayer},_updateVideoSource:function(){var t=this._sgNode;this.resourceType===r.REMOTE?t.setURL(this.remoteURL):t.setURL(this._clip||"")},_initSgNode:function(){var t=this._sgNode;t&&(t.createDomElementIfNeeded(),this._updateVideoSource(),t.seekTo(this.currentTime),t.setKeepAspectRatioEnabled(this.keepAspectRatio),t.setFullScreenEnabled(this.isFullscreen),t.setContentSize(this.node.getContentSize()),this.pause(),t.setEventListener(n.PLAYING,this.onPlaying.bind(this)),t.setEventListener(n.PAUSED,this.onPasued.bind(this)),t.setEventListener(n.STOPPED,this.onStopped.bind(this)),t.setEventListener(n.COMPLETED,this.onCompleted.bind(this)),t.setEventListener(n.META_LOADED,this.onMetaLoaded.bind(this)),t.setEventListener(n.CLICKED,this.onClicked.bind(this)),t.setEventListener(n.READY_TO_PLAY,this.onReadyToPlay.bind(this)))},onReadyToPlay:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,n.READY_TO_PLAY),this.node.emit("ready-to-play",this)},onMetaLoaded:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,n.META_LOADED),this.node.emit("meta-loaded",this)},onClicked:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,n.CLICKED),this.node.emit("clicked",this)},onPlaying:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,n.PLAYING),this.node.emit("playing",this)},onPasued:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,n.PAUSED),this.node.emit("paused",this)},onStopped:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,n.STOPPED),this.node.emit("stopped",this)},onCompleted:function(){cc.Component.EventHandler.emitEvents(this.videoPlayerEvent,this,n.COMPLETED),this.node.emit("completed",this)},play:function(){this._sgNode&&this._sgNode.play()},resume:function(){this._sgNode&&this._sgNode.resume()},pause:function(){this._sgNode&&this._sgNode.pause()},stop:function(){this._sgNode&&this._sgNode.stop()},getDuration:function(){return this._sgNode?this._sgNode.duration():-1},isPlaying:function(){return!!this._sgNode&&this._sgNode.isPlaying()}});cc.VideoPlayer=e.exports=s}),{"../videoplayer/CCSGVideoPlayer":240}],100:[(function(t,e,i){var n=cc.Class({name:"cc.ViewGroup",extends:t("./CCComponent")});cc.ViewGroup=e.exports=n}),{"./CCComponent":76}],101:[(function(t,e,i){function n(){}t("../webview/CCSGWebView");var r=_ccsg.WebView.EventType,s=cc.Class({name:"cc.WebView",extends:cc._RendererUnderSG,editor:!1,properties:{_useOriginalSize:!0,_url:"",url:{type:String,tooltip:!1,get:function(){return this._url},set:function(t){this._url=t;var e=this._sgNode;e&&e.loadURL(t)}},webviewEvents:{default:[],type:cc.Component.EventHandler}},statics:{EventType:r},onLoad:!1,_createSgNode:function(){return new _ccsg.WebView},_initSgNode:function(){var t=this._sgNode;t&&(t.createDomElementIfNeeded(),t.loadURL(this._url),t.setContentSize(this.node.getContentSize()))},onEnable:function(){this._super();var t=this._sgNode;t.setEventListener(r.LOADED,this._onWebViewLoaded.bind(this)),t.setEventListener(r.LOADING,this._onWebViewLoading.bind(this)),t.setEventListener(r.ERROR,this._onWebViewLoadError.bind(this))},onDisable:function(){this._super();var t=this._sgNode;t.setEventListener(r.LOADED,n),t.setEventListener(r.LOADING,n),t.setEventListener(r.ERROR,n)},_onWebViewLoaded:function(){cc.Component.EventHandler.emitEvents(this.webviewEvents,this,r.LOADED),this.node.emit("loaded",this)},_onWebViewLoading:function(){return cc.Component.EventHandler.emitEvents(this.webviewEvents,this,r.LOADING),this.node.emit("loading",this),!0},_onWebViewLoadError:function(){cc.Component.EventHandler.emitEvents(this.webviewEvents,this,r.ERROR),this.node.emit("error",this)},setJavascriptInterfaceScheme:function(t){this._sgNode&&this._sgNode.setJavascriptInterfaceScheme(t)},setOnJSCallback:function(t){this._sgNode&&this._sgNode.setOnJSCallback(t)},evaluateJS:function(t){this._sgNode&&this._sgNode.evaluateJS(t)}});cc.WebView=e.exports=s}),{"../webview/CCSGWebView":241}],102:[(function(t,e,i){var n=t("../base-ui/CCWidgetManager"),r=n._AlignFlags,s=r.TOP,o=r.MID,a=r.BOT,c=r.LEFT,h=r.CENTER,l=r.RIGHT,u=s|a,_=c|l,d=cc.Class({name:"cc.Widget",extends:t("./CCComponent"),editor:!1,properties:{target:{get:function(){return this._target},set:function(t){this._target=t},type:cc.Node,tooltip:!1},isAlignTop:{get:function(){return(this._alignFlags&s)>0},set:function(t){this._setAlign(s,t)},animatable:!1,tooltip:!1},isAlignVerticalCenter:{get:function(){return(this._alignFlags&o)>0},set:function(t){t?(this.isAlignTop=!1,this.isAlignBottom=!1,this._alignFlags|=o):this._alignFlags&=~o},animatable:!1,tooltip:!1},isAlignBottom:{get:function(){return(this._alignFlags&a)>0},set:function(t){this._setAlign(a,t)},animatable:!1,tooltip:!1},isAlignLeft:{get:function(){return(this._alignFlags&c)>0},set:function(t){this._setAlign(c,t)},animatable:!1,tooltip:!1},isAlignHorizontalCenter:{get:function(){return(this._alignFlags&h)>0},set:function(t){t?(this.isAlignLeft=!1,this.isAlignRight=!1,this._alignFlags|=h):this._alignFlags&=~h},animatable:!1,tooltip:!1},isAlignRight:{get:function(){return(this._alignFlags&l)>0},set:function(t){this._setAlign(l,t)},animatable:!1,tooltip:!1},isStretchWidth:{get:function(){return(this._alignFlags&_)===_},visible:!1},isStretchHeight:{get:function(){return(this._alignFlags&u)===u},visible:!1},top:{get:function(){return this._top},set:function(t){this._top=t},tooltip:!1},bottom:{get:function(){return this._bottom},set:function(t){this._bottom=t},tooltip:!1},left:{get:function(){return this._left},set:function(t){this._left=t},tooltip:!1},right:{get:function(){return this._right},set:function(t){this._right=t},tooltip:!1},horizontalCenter:{get:function(){return this._horizontalCenter},set:function(t){this._horizontalCenter=t},tooltip:!1},verticalCenter:{get:function(){return this._verticalCenter},set:function(t){this._verticalCenter=t},tooltip:!1},isAbsoluteHorizontalCenter:{get:function(){return this._isAbsHorizontalCenter},set:function(t){this._isAbsHorizontalCenter=t},animatable:!1},isAbsoluteVerticalCenter:{get:function(){return this._isAbsVerticalCenter},set:function(t){this._isAbsVerticalCenter=t},animatable:!1},isAbsoluteTop:{get:function(){return this._isAbsTop},set:function(t){this._isAbsTop=t},animatable:!1},isAbsoluteBottom:{get:function(){return this._isAbsBottom},set:function(t){this._isAbsBottom=t},animatable:!1},isAbsoluteLeft:{get:function(){return this._isAbsLeft},set:function(t){this._isAbsLeft=t},animatable:!1},isAbsoluteRight:{get:function(){return this._isAbsRight},set:function(t){this._isAbsRight=t},animatable:!1},isAlignOnce:{default:!0,tooltip:!1,displayName:"AlignOnce"},_target:null,_alignFlags:0,_left:0,_right:0,_top:0,_bottom:0,_verticalCenter:0,_horizontalCenter:0,_isAbsLeft:!0,_isAbsRight:!0,_isAbsTop:!0,_isAbsBottom:!0,_isAbsHorizontalCenter:!0,_isAbsVerticalCenter:!0,_originalWidth:0,_originalHeight:0},onEnable:function(){n.add(this)},onDisable:function(){n.remove(this)},_setAlign:function(t,e){if(e!=(this._alignFlags&t)>0){var i=(t&_)>0;e?(this._alignFlags|=t,i?(this.isAlignHorizontalCenter=!1,this.isStretchWidth&&(this._originalWidth=this.node.width)):(this.isAlignVerticalCenter=!1,this.isStretchHeight&&(this._originalHeight=this.node.height))):(i?this.isStretchWidth&&(this.node.width=this._originalWidth):this.isStretchHeight&&(this.node.height=this._originalHeight),this._alignFlags&=~t)}},updateAlignment:function(){n.updateAlignment(this.node)}});cc.Widget=e.exports=d}),{"../base-ui/CCWidgetManager":59,"./CCComponent":76}],103:[(function(t,e,i){t("./CCComponent"),t("./CCRendererInSG"),t("./CCRendererUnderSG"),t("./CCComponentEventHandler"),t("./missing-script"),e.exports=[t("./CCSprite"),t("./CCWidget"),t("./CCCanvas"),t("./CCAudioSource"),t("./CCAnimation"),t("./CCButton"),t("./CCLabel"),t("./CCProgressBar"),t("./CCMask"),t("./CCScrollBar"),t("./CCScrollView"),t("./CCPageViewIndicator"),t("./CCPageView"),t("./CCSlider"),t("./CCLayout"),t("./CCEditBox"),t("./CCVideoPlayer"),t("./CCWebView"),t("./CCSpriteDistortion"),t("./CCLabelOutline"),t("./CCRichText"),t("./CCToggleContainer"),t("./CCToggleGroup"),t("./CCToggle"),t("./CCBlockInputEvents")]}),{"./CCAnimation":71,"./CCAudioSource":72,"./CCBlockInputEvents":73,"./CCButton":74,"./CCCanvas":75,"./CCComponent":76,"./CCComponentEventHandler":77,"./CCEditBox":78,"./CCLabel":79,"./CCLabelOutline":80,"./CCLayout":81,"./CCMask":82,"./CCPageView":83,"./CCPageViewIndicator":84,"./CCProgressBar":85,"./CCRendererInSG":86,"./CCRendererUnderSG":87,"./CCRichText":88,"./CCScrollBar":90,"./CCScrollView":91,"./CCSlider":92,"./CCSprite":93,"./CCSpriteDistortion":94,"./CCToggle":96,"./CCToggleContainer":97,"./CCToggleGroup":98,"./CCVideoPlayer":99,"./CCWebView":101,"./CCWidget":102,"./missing-script":104}],104:[(function(t,e,i){var n=cc.js,r=t("../utils/misc").BUILTIN_CLASSID_RE,s=cc.Class({name:"cc.MissingClass",properties:{_$erialized:{default:null,visible:!1,editorOnly:!0}}}),o=cc.Class({name:"cc.MissingScript",extends:cc.Component,editor:{inspector:"packages://inspector/inspectors/comps/missing-script.js"},properties:{compiled:{default:!1,serializable:!1},_$erialized:{default:null,visible:!1,editorOnly:!0}},ctor:!1,statics:{safeFindClass:function(t,e){var i=n._getClassById(t);return i||(t?(cc.deserialize.reportMissingClass(t),o.getMissingWrapper(t,e)):null)},getMissingWrapper:function(t,e){return e.node&&(/^[0-9a-zA-Z+/]{23}$/.test(t)||r.test(t))?o:s}},onLoad:function(){cc.warnID(4600,this.node.name)}});cc._MissingScript=e.exports=o}),{"../utils/misc":226}],105:[(function(t,e,i){function n(t){var e=t.convertToWorldSpace(cc.p(0,0)),i=cc.visibleRect.height,n=.5;cc.visibleRect.width>i&&(n=.7),setTimeout((function(){if(window.scrollY320&&(t=320),window.scrollTo(t,t)}}),s)}var r=40,s=400,o=t("../platform/utils"),a=t("../platform/CCSys"),c=cc.Enum({DEFAULT:0,DONE:1,SEND:2,SEARCH:3,GO:4}),h=cc.Enum({ANY:0,EMAIL_ADDR:1,NUMERIC:2,PHONE_NUMBER:3,URL:4,DECIMAL:5,SINGLE_LINE:6}),l=cc.Enum({PASSWORD:0,SENSITIVE:1,INITIAL_CAPS_WORD:2,INITIAL_CAPS_SENTENCE:3,INITIAL_CAPS_ALL_CHARACTERS:4,DEFAULT:5});cc.EditBoxDelegate=cc._Class.extend({editBoxEditingDidBegan:function(t){},editBoxEditingDidEnded:function(t){},editBoxTextChanged:function(t,e){},editBoxEditingReturn:function(t){}}),_ccsg.EditBox=_ccsg.Node.extend({_backgroundSprite:null,_delegate:null,_editBoxInputMode:h.ANY,_editBoxInputFlag:l.DEFAULT,_keyboardReturnType:c.DEFAULT,_maxLength:50,_text:"",_placeholderText:"",_alwaysOnTop:!1,_placeholderFontName:"",_placeholderFontSize:14,__fullscreen:!1,__autoResize:!1,_placeholderColor:null,_className:"EditBox",ctor:function(t,e){_ccsg.Node.prototype.ctor.call(this),this._textColor=cc.Color.WHITE,this._placeholderColor=cc.Color.GRAY,this.initWithSizeAndBackgroundSprite(t,e),this._renderCmd._createLabels()},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new _ccsg.EditBox.CanvasRenderCmd(this):new _ccsg.EditBox.WebGLRenderCmd(this)},setContentSize:function(t,e){void 0!==t.width&&void 0!==t.height&&(e=t.height,t=t.width),_ccsg.Node.prototype.setContentSize.call(this,t,e),this._updateEditBoxSize(t,e)},setVisible:function(t){_ccsg.Node.prototype.setVisible.call(this,t),this._renderCmd.updateVisibility()},createDomElementIfNeeded:function(){this._renderCmd._edTxt||this._renderCmd.setInputMode(this._editBoxInputMode)},setTabIndex:function(t){this._renderCmd._edTxt&&(this._renderCmd._edTxt.tabIndex=t)},getTabIndex:function(){return this._renderCmd._edTxt?this._renderCmd._edTxt.tabIndex:(cc.warnID(4700),-1)},setFocus:function(){this._renderCmd._edTxt&&this._renderCmd._edTxt.focus()},isFocused:function(){return this._renderCmd._edTxt?document.activeElement===this._renderCmd._edTxt:(cc.warnID(4700),!1)},stayOnTop:function(t){this._alwaysOnTop!==t&&(this._alwaysOnTop=t,this._renderCmd.stayOnTop(this._alwaysOnTop))},cleanup:function(){this._super(),this._renderCmd.removeDom()},_onTouchBegan:function(t){var e=t.getLocation(),i=cc.rect(0,0,this._contentSize.width,this._contentSize.height);return!!cc.rectContainsPoint(i,this.convertToNodeSpace(e))||(this._renderCmd._endEditing(),!1)},_onTouchEnded:function(){this._renderCmd._beginEditing()},_updateBackgroundSpriteSize:function(t,e){this._backgroundSprite&&this._backgroundSprite.setContentSize(t,e)},_updateEditBoxSize:function(t,e){var i="number"==typeof t.width?t.width:t,n="number"==typeof t.height?t.height:e;this._updateBackgroundSpriteSize(i,n),this._renderCmd.updateSize(i,n)},setLineHeight:function(t){this._renderCmd.setLineHeight(t)},setFont:function(t,e){this._renderCmd.setFont(t,e)},_setFont:function(t){this._renderCmd._setFont(t)},getBackgroundSprite:function(){return this._backgroundSprite},setFontName:function(t){this._renderCmd.setFontName(t)},setFontSize:function(t){this._renderCmd.setFontSize(t)},setString:function(t){t.length>=this._maxLength&&(t=t.slice(0,this._maxLength)),this._text=t,this._renderCmd.setString(t)},setFontColor:function(t){this._textColor=t,this._renderCmd.setFontColor(t)},setMaxLength:function(t){isNaN(t)||(t<0&&(t=65535),this._maxLength=t,this._renderCmd.setMaxLength(t))},getMaxLength:function(){return this._maxLength},setPlaceHolder:function(t){null!==t&&(this._renderCmd.setPlaceHolder(t),this._placeholderText=t)},setPlaceholderFont:function(t,e){this._placeholderFontName=t,this._placeholderFontSize=e,this._renderCmd._updateDOMPlaceholderFontStyle()},_setPlaceholderFont:function(t){var e=cc.LabelTTF._fontStyleRE.exec(t);e&&(this._placeholderFontName=e[2],this._placeholderFontSize=parseInt(e[1]),this._renderCmd._updateDOMPlaceholderFontStyle())},setPlaceholderFontName:function(t){this._placeholderFontName=t,this._renderCmd._updateDOMPlaceholderFontStyle()},setPlaceholderFontSize:function(t){this._placeholderFontSize=t,this._renderCmd._updateDOMPlaceholderFontStyle()},setPlaceholderFontColor:function(t){this._placeholderColor=t,this._renderCmd.setPlaceholderFontColor(t)},setInputFlag:function(t){this._editBoxInputFlag=t,this._renderCmd.setInputFlag(t)},getString:function(){return this._text},initWithSizeAndBackgroundSprite:function(t,e){return this._backgroundSprite&&this._backgroundSprite.removeFromParent(),this._backgroundSprite=e,_ccsg.Node.prototype.setContentSize.call(this,t),this._backgroundSprite&&!this._backgroundSprite.parent&&(this._backgroundSprite.setAnchorPoint(cc.p(0,0)),this.addChild(this._backgroundSprite),this._updateBackgroundSpriteSize(t.width,t.height)),this.x=0,this.y=0,!0},setDelegate:function(t){this._delegate=t},getPlaceHolder:function(){return this._placeholderText},setInputMode:function(t){if(this._editBoxInputMode!==t){var e=this.getString();this._editBoxInputMode=t,this._renderCmd.setInputMode(t),this._renderCmd.transform(),this.setString(e),this._renderCmd._updateLabelPosition(this.getContentSize())}},setReturnType:function(t){this._keyboardReturnType=t,this._renderCmd._updateDomInputType()},initWithBackgroundColor:function(t,e){this._edWidth=t.width,this.dom.style.width=this._edWidth.toString()+"px",this._edHeight=t.height,this.dom.style.height=this._edHeight.toString()+"px",this.dom.style.backgroundColor=cc.colorToHex(e)}});var u=_ccsg.EditBox.prototype;cc.defineGetterSetter(u,"font",null,u._setFont),cc.defineGetterSetter(u,"fontName",null,u.setFontName),cc.defineGetterSetter(u,"fontSize",null,u.setFontSize),cc.defineGetterSetter(u,"fontColor",null,u.setFontColor),cc.defineGetterSetter(u,"string",u.getString,u.setString),cc.defineGetterSetter(u,"maxLength",u.getMaxLength,u.setMaxLength),cc.defineGetterSetter(u,"placeholder",u.getPlaceHolder,u.setPlaceHolder),cc.defineGetterSetter(u,"placeholderFont",null,u._setPlaceholderFont),cc.defineGetterSetter(u,"placeholderFontName",null,u.setPlaceholderFontName),cc.defineGetterSetter(u,"placeholderFontSize",null,u.setPlaceholderFontSize),cc.defineGetterSetter(u,"placeholderFontColor",null,u.setPlaceholderFontColor),cc.defineGetterSetter(u,"inputFlag",null,u.setInputFlag),cc.defineGetterSetter(u,"delegate",null,u.setDelegate),cc.defineGetterSetter(u,"inputMode",null,u.setInputMode),cc.defineGetterSetter(u,"returnType",null,u.setReturnType),u=null,_ccsg.EditBox.InputMode=h,_ccsg.EditBox.InputFlag=l,_ccsg.EditBox.KeyboardReturnType=c,(function(t){t._polyfill={zoomInvalid:!1},a.OS_ANDROID!==a.os||a.browserType!==a.BROWSER_TYPE_SOUGOU&&a.browserType!==a.BROWSER_TYPE_360||(t._polyfill.zoomInvalid=!0)})(_ccsg.EditBox),(function(t){var e=function(){}.prototype=Object.create(Object.prototype);e.updateMatrix=function(){if(this._edTxt){var e=this._node,i=cc.view._scaleX,n=cc.view._scaleY,r=cc.view._devicePixelRatio,s=this._worldTransform;i/=r,n/=r;var o=cc.game.container,a=s.a*i,c=s.b,h=s.c,l=s.d*n,u=o&&o.style.paddingLeft&&parseInt(o.style.paddingLeft),_=o&&o.style.paddingBottom&&parseInt(o.style.paddingBottom),d=s.tx*i+u,f=s.ty*n+_;t.zoomInvalid&&(this.updateSize(e._contentSize.width*a,e._contentSize.height*l),a=1,l=1);var p="matrix("+a+","+-c+","+-h+","+l+","+d+","+-f+")";this._edTxt.style.transform=p,this._edTxt.style["-webkit-transform"]=p,this._edTxt.style["transform-origin"]="0px 100% 0px",this._edTxt.style["-webkit-transform-origin"]="0px 100% 0px"}},e.updateVisibility=function(){this._edTxt&&(this._node.visible?this._edTxt.style.visibility="visible":this._edTxt.style.visibility="hidden")},e.stayOnTop=function(t){t?(this._removeLabels(),this._edTxt.style.display=""):(this._createLabels(),this._edTxt.style.display="none",this._showLabels())},e._beginEditingOnMobile=function(t){this.__orientationChanged=function(){n(t)},window.addEventListener("orientationchange",this.__orientationChanged),cc.view.isAutoFullScreenEnabled()?(this.__fullscreen=!0,cc.view.enableAutoFullScreen(!1),cc.screen.exitFullScreen()):this.__fullscreen=!1,this.__autoResize=cc.view.__resizeWithBrowserSize,cc.view.resizeWithBrowserSize(!1)},e._endEditingOnMobile=function(){if(this.__rotateScreen){cc.container.style["-webkit-transform"]="rotate(90deg)",cc.container.style.transform="rotate(90deg)";var t=cc.view,e=t._originalDesignResolutionSize.width,i=t._originalDesignResolutionSize.height;e>0&&t.setDesignResolutionSize(e,i,t._resolutionPolicy),this.__rotateScreen=!1}window.removeEventListener("orientationchange",this.__orientationChanged),window.scrollTo(0,0),this.__fullscreen&&cc.view.enableAutoFullScreen(!0),this.__autoResize&&cc.view.resizeWithBrowserSize(!0)},e._onFocusOnMobile=function(t){if(cc.view._isRotated){cc.container.style["-webkit-transform"]="rotate(0deg)",cc.container.style.transform="rotate(0deg)",cc.view._isRotated=!1;cc.view.getResolutionPolicy().apply(cc.view,cc.view.getDesignResolutionSize()),cc.view._isRotated=!0,window.scrollTo(35,35),this.__rotateScreen=!0}else this.__rotateScreen=!1;n(t)},e._createDomInput=function(){function t(t){var i=e._editBox;t.value.length>t.maxLength&&(t.value=t.value.slice(0,t.maxLength)),i._delegate&&i._delegate.editBoxTextChanged&&i._text!==t.value&&(i._text=t.value,e._updateDomTextCases(),i._delegate.editBoxTextChanged(i,i._text))}this.removeDom();var e=this,i=this._edTxt=document.createElement("input");i.type="text",i.style.fontSize=this._edFontSize+"px",i.style.color="#000000",i.style.border=0,i.style.background="transparent",i.style.width="100%",i.style.height="100%",i.style.active=0,i.style.outline="medium",i.style.padding="0",i.style.textTransform="uppercase",i.style.display="none",i.style.position="absolute",i.style.bottom="0px",i.style.left="2px",i.style["-moz-appearance"]="textfield",i.style.className="cocosEditBox";var n=!1;return i.addEventListener("compositionstart",(function(){n=!0})),i.addEventListener("compositionend",(function(){n=!1,t(this)})),i.addEventListener("input",(function(){n||t(this)})),i.addEventListener("keypress",(function(t){var i=e._editBox;t.keyCode===cc.KEY.enter&&(t.stopPropagation(),t.preventDefault(),""===this.value&&(this.style.fontSize=i._placeholderFontSize+"px",this.style.color=cc.colorToHex(i._placeholderColor)),i._text=this.value,e._updateDomTextCases(),e._endEditing(),i._delegate&&i._delegate.editBoxEditingReturn&&i._delegate.editBoxEditingReturn(i),cc._canvas.focus())})),i.addEventListener("focus",(function(){var t=e._editBox;this.style.fontSize=e._edFontSize+"px",this.style.color=cc.colorToHex(t._textColor),e._hiddenLabels(),a.isMobile&&e._onFocusOnMobile(t),t._delegate&&t._delegate.editBoxEditingDidBegan&&t._delegate.editBoxEditingDidBegan(t)})),i.addEventListener("blur",(function(){var t=e._editBox;t._text=this.value,e._updateDomTextCases(),t._delegate&&t._delegate.editBoxEditingDidEnded&&t._delegate.editBoxEditingDidEnded(t),""===this.value&&(this.style.fontSize=t._placeholderFontSize+"px",this.style.color=cc.colorToHex(t._placeholderColor)),e._endEditing()})),this._addDomToGameContainer(),i},e._createDomTextArea=function(){function t(t){t.value.length>t.maxLength&&(t.value=t.value.slice(0,t.maxLength));var i=e._editBox;i._delegate&&i._delegate.editBoxTextChanged&&i._text.toLowerCase()!==t.value.toLowerCase()&&(i._text=t.value,e._updateDomTextCases(),i._delegate.editBoxTextChanged(i,i._text))}this.removeDom();var e=this,i=this._edTxt=document.createElement("textarea");i.type="text",i.style.fontSize=this._edFontSize+"px",i.style.color="#000000",i.style.border=0,i.style.background="transparent",i.style.width="100%",i.style.height="100%",i.style.active=0,i.style.outline="medium",i.style.padding="0",i.style.resize="none",i.style.textTransform="uppercase",i.style.overflow_y="scroll",i.style.display="none",i.style.position="absolute",i.style.bottom="0px",i.style.left="2px",i.style.className="cocosEditBox";var n=!1;return i.addEventListener("compositionstart",(function(){n=!0})),i.addEventListener("compositionend",(function(){n=!1,t(this)})),i.addEventListener("input",(function(){n||t(this)})),i.addEventListener("focus",(function(){var t=e._editBox;e._hiddenLabels(),this.style.fontSize=e._edFontSize+"px",this.style.color=cc.colorToHex(t._textColor),a.isMobile&&e._onFocusOnMobile(t),t._delegate&&t._delegate.editBoxEditingDidBegan&&t._delegate.editBoxEditingDidBegan(t)})),i.addEventListener("keypress",(function(t){var i=e._editBox;t.keyCode===cc.KEY.enter&&(t.stopPropagation(),i._delegate&&i._delegate.editBoxEditingReturn&&i._delegate.editBoxEditingReturn(i))})),i.addEventListener("blur",(function(){var t=e._editBox;t._text=this.value,e._updateDomTextCases(),t._delegate&&t._delegate.editBoxEditingDidEnded&&t._delegate.editBoxEditingDidEnded(t),""===this.value&&(this.style.fontSize=t._placeholderFontSize+"px",this.style.color=cc.colorToHex(t._placeholderColor)),e._endEditing()})),this._addDomToGameContainer(),i},e._createWXInput=function(t){this.removeDom();var e=this,i=this._edTxt=document.createElement("input");i.type="text",i.focus=function(){var i=e._editBox;wx.showKeyboard({defaultValue:i._text,maxLength:140,multiple:t,confirmHold:!0,confirmType:"done",success:function(t){i._delegate&&i._delegate.editBoxEditingDidBegan&&i._delegate.editBoxEditingDidBegan(i)},fail:function(t){cc.warn(t.errMsg),e._endEditing()}}),wx.onKeyboardConfirm((function(t){i._text=t.value,e._updateDomTextCases(),i._delegate&&i._delegate.editBoxEditingReturn&&i._delegate.editBoxEditingReturn(i),wx.hideKeyboard({success:function(t){i._delegate&&i._delegate.editBoxEditingDidEnded&&i._delegate.editBoxEditingDidEnded(i)},fail:function(t){cc.warn(t.errMsg)}})})),wx.onKeyboardInput((function(t){i._delegate&&i._delegate.editBoxTextChanged&&i._text!==t.value&&(i._text=t.value,e._updateDomTextCases(),i._delegate.editBoxTextChanged(i,i._text))})),wx.onKeyboardComplete((function(){e._endEditing(),wx.offKeyboardConfirm(),wx.offKeyboardInput(),wx.offKeyboardComplete()}))}},e._createLabels=function(){var t=this._editBox.getContentSize();this._textLabel||(this._textLabel=_ccsg.Label.pool.get(),this._textLabel.setAnchorPoint(cc.p(0,1)),this._textLabel.setOverflow(_ccsg.Label.Overflow.CLAMP),this._editBox.addChild(this._textLabel,100)),this._placeholderLabel||(this._placeholderLabel=_ccsg.Label.pool.get(),this._placeholderLabel.setAnchorPoint(cc.p(0,1)),this._placeholderLabel.setColor(cc.Color.GRAY),this._editBox.addChild(this._placeholderLabel,100)),this._updateLabelPosition(t)},e._removeLabels=function(){this._textLabel&&(this._editBox.removeChild(this._textLabel),this._textLabel=null)},e._updateLabelPosition=function(t){if(this._textLabel&&this._placeholderLabel){var e=cc.size(t.width-2,t.height);this._textLabel.setContentSize(e),this._placeholderLabel.setLineHeight(t.height);var i=this._placeholderLabel.getContentSize();this._editBox._editBoxInputMode===h.ANY?(this._textLabel.setPosition(2,t.height),this._placeholderLabel.setPosition(2,t.height),this._placeholderLabel.setVerticalAlign(cc.VerticalTextAlignment.TOP),this._textLabel.setVerticalAlign(cc.VerticalTextAlignment.TOP),this._textLabel.enableWrapText(!0)):(this._textLabel.enableWrapText(!1),this._textLabel.setPosition(2,t.height),this._placeholderLabel.setPosition(2,(t.height+i.height)/2),this._placeholderLabel.setVerticalAlign(cc.VerticalTextAlignment.CENTER),this._textLabel.setVerticalAlign(cc.VerticalTextAlignment.CENTER))}},e.setLineHeight=function(t){this._textLabel&&this._textLabel.setLineHeight(t)},e._hiddenLabels=function(){this._textLabel&&this._textLabel.setVisible(!1),this._placeholderLabel&&this._placeholderLabel.setVisible(!1)},e._updateDomTextCases=function(){var t=this._editBox._editBoxInputFlag;t===l.INITIAL_CAPS_ALL_CHARACTERS?this._editBox._text=this._editBox._text.toUpperCase():t===l.INITIAL_CAPS_WORD?this._editBox._text=(function(t){return t.replace(/(?:^|\s)\S/g,(function(t){return t.toUpperCase()}))})(this._editBox._text):t===l.INITIAL_CAPS_SENTENCE&&(this._editBox._text=(function(t){return t.charAt(0).toUpperCase()+t.slice(1)})(this._editBox._text))},e._updateLabelStringStyle=function(){if("password"===this._edTxt.type){for(var t="",e=this._editBox._text.length,i=0;i=0);)++n;e.gt0Index=n}}},_sortListenersOfFixedPriorityAsc:function(t,e){return t._getFixedPriority()-e._getFixedPriority()},_onUpdateListeners:function(t){var e,i,n,r=t.getFixedPriorityListeners(),s=t.getSceneGraphPriorityListeners(),o=this._toRemovedListeners;if(s)for(e=0;e0,3508),!(e>1)){var i;(i=this._listenersMap[cc._EventListenerTouchOneByOne.LISTENER_ID])&&this._onUpdateListeners(i),(i=this._listenersMap[cc._EventListenerTouchAllAtOnce.LISTENER_ID])&&this._onUpdateListeners(i),cc.assertID(1===e,3509);var n=this._toAddedListeners;if(0!==n.length){for(var r=0,s=n.length;r0&&-1!==(r=t._claimedTouches.indexOf(n))&&(o=!0,a===c.MOVED&&t.onTouchMoved?t.onTouchMoved(n,i):a===c.ENDED?(t.onTouchEnded&&t.onTouchEnded(n,i),t._registered&&t._claimedTouches.splice(r,1)):a===c.CANCELLED&&(t.onTouchCancelled&&t.onTouchCancelled(n,i),t._registered&&t._claimedTouches.splice(r,1))),i.isStopped()?(s._updateTouchListeners(i),!0):!!(o&&t._registered&&t.swallowTouches)&&(e.needsMutableSet&&e.touches.splice(n,1),!0)},_dispatchTouchEvent:function(t){this._sortEventListeners(cc._EventListenerTouchOneByOne.LISTENER_ID),this._sortEventListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);var e=this._getListeners(cc._EventListenerTouchOneByOne.LISTENER_ID),i=this._getListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);if(null!==e||null!==i){var n=t.getTouches(),r=cc.js.array.copy(n),s={event:t,needsMutableSet:e&&i,touches:r,selTouch:null};if(e)for(var o=0;o0&&(this._dispatchEventToListeners(i,this._onTouchesEventCallback,{event:t,touches:r}),t.isStopped())||this._updateTouchListeners(t)}},_onTouchesEventCallback:function(t,e){if(!t._registered)return!1;var i=cc.Event.EventTouch,n=e.event,r=e.touches,o=n.getEventCode();return n.currentTarget=t._node,o===i.BEGAN&&t.onTouchesBegan?t.onTouchesBegan(r,n):o===i.MOVED&&t.onTouchesMoved?t.onTouchesMoved(r,n):o===i.ENDED&&t.onTouchesEnded?t.onTouchesEnded(r,n):o===i.CANCELLED&&t.onTouchesCancelled&&t.onTouchesCancelled(r,n),!!n.isStopped()&&(s._updateTouchListeners(n),!0)},_associateNodeAndEventListener:function(t,e){var i=this._nodeListenersMap[t.__instanceId];i||(i=[],this._nodeListenersMap[t.__instanceId]=i),i.push(e)},_dissociateNodeAndEventListener:function(t,e){var i=this._nodeListenersMap[t.__instanceId];i&&(cc.js.array.remove(i,e),0===i.length&&delete this._nodeListenersMap[t.__instanceId])},_dispatchEventToListeners:function(t,e,i){var n,r,s=!1,o=t.getFixedPriorityListeners(),a=t.getSceneGraphPriorityListeners(),c=0;if(o&&0!==o.length)for(;c0){for(var a;n0},a.on=function(t,e,i,n){"boolean"==typeof i?(n=i,i=void 0):n=!!n;if(e){var s=null;return(s=n?this._capturingListeners=this._capturingListeners||new r:this._bubblingListeners=this._bubblingListeners||new r).has(t,e,i)||(s.add(t,e,i),i&&i.__eventTargets&&i.__eventTargets.push(this),this._addEventFlag(t,s,n)),e}cc.errorID(6800)},a.off=function(t,e,i,n){if("boolean"==typeof i?(n=i,i=void 0):n=!!n,e){var r=n?this._capturingListeners:this._bubblingListeners;r&&(r.remove(t,e,i),i&&i.__eventTargets&&s(i.__eventTargets,this),this._purgeEventFlag(t,r,n))}else this._capturingListeners&&this._capturingListeners.removeAll(t),this._bubblingListeners&&this._bubblingListeners.removeAll(t),this._hasListenerCache&&delete this._hasListenerCache[t]},a.targetOff=function(t){this._capturingListeners&&(this._capturingListeners.removeAll(t),this._resetFlagForTarget(t,this._capturingListeners,!0)),this._bubblingListeners&&(this._bubblingListeners.removeAll(t),this._resetFlagForTarget(t,this._bubblingListeners,!1))},a.once=function(t,e,i,n){var r="__ONCE_FLAG:"+t,s=n?this._capturingListeners:this._bubblingListeners;if(!(s&&s.has(r,e,i))){var o=this,a=function(c){o.off(t,a,i,n),s.remove(r,e,i),e.call(this,c)};this.on(t,a,i,n),s||(s=n?this._capturingListeners:this._bubblingListeners),s.add(r,e,i)}},a.dispatchEvent=function(t){(function(t,e){var i,n;for(e.target=t,o.length=0,t._getCapturingTargets(e.type,o),e.eventPhase=1,n=o.length-1;n>=0;--n)if((i=o[n])._isTargetActive(e.type)&&i._capturingListeners&&(e.currentTarget=i,i._capturingListeners.invoke(e,o),e._propagationStopped))return void(o.length=0);if(o.length=0,t._isTargetActive(e.type)&&(e.eventPhase=2,e.currentTarget=t,t._capturingListeners&&t._capturingListeners.invoke(e),!e._propagationImmediateStopped&&t._bubblingListeners&&t._bubblingListeners.invoke(e)),!e._propagationStopped&&e.bubbles)for(t._getBubblingTargets(e.type,o),e.eventPhase=3,n=0;n=n.next.y){var a=n.x+(s-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=r&&a>o){if(o=a,a===r){if(s===n.y)return n;if(s===n.next.y)return n.next}i=n.x=n.x&&n.x>=u&&h(s<_?r:o,s,u,_,s<_?o:r,s,n.x,n.y)&&((c=Math.abs(s-n.y)/(r-n.x))i.x)&&d(n,t)&&(i=n,f=c),n=n.next;return i})(t,e)){var i=f(e,t);s(i,i.next)}})(p[o],i),i=s(i,i.next);return i})(t,e,l,i)),t.length>80*i){_=m=t[0],p=g=t[1];for(var C=i;Cm&&(m=y),v>g&&(g=v);x=Math.max(m-_,g-p)}return o(l,u,i,_,p,x),u}function r(t,e,i,n,r){var s,o;if(r===y(t,e,i,n)>0)for(s=e;s=e;s-=n)o=p(s,t[s],t[s+1],o);return o&&u(o,o.next)&&(m(o),o=o.next),o}function s(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!u(n,n.next)&&0!==l(n.prev,n,n.next))n=n.next;else{if(m(n),(n=e=n.prev)===n.next)return null;i=!0}}while(i||n!==e);return e}function o(t,e,i,n,r,a,p){if(t){!p&&a&&(function(t,e,i,n){var r=t;do{null===r.z&&(r.z=c(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,(function(t){var e,i,n,r,s,o,a,c,h=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,n=i,a=0,e=0;e0||c>0&&n;)0===a?(r=n,n=n.nextZ,c--):0!==c&&n?i.z<=n.z?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,c--):(r=i,i=i.nextZ,a--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;i=n}s.nextZ=null,h*=2}while(o>1)})(r)})(t,n,r,a);for(var g,y,v=t;t.prev!==t.next;)if(g=t.prev,y=t.next,a?(function(t,e,i,n){var r=t.prev,s=t,o=t.next;if(l(r,s,o)>=0)return!1;var a=r.xs.x?r.x>o.x?r.x:o.x:s.x>o.x?s.x:o.x,d=r.y>s.y?r.y>o.y?r.y:o.y:s.y>o.y?s.y:o.y,f=c(a,u,e,i,n),p=c(_,d,e,i,n),m=t.nextZ;for(;m&&m.z<=p;){if(m!==t.prev&&m!==t.next&&h(r.x,r.y,s.x,s.y,o.x,o.y,m.x,m.y)&&l(m.prev,m,m.next)>=0)return!1;m=m.nextZ}m=t.prevZ;for(;m&&m.z>=f;){if(m!==t.prev&&m!==t.next&&h(r.x,r.y,s.x,s.y,o.x,o.y,m.x,m.y)&&l(m.prev,m,m.next)>=0)return!1;m=m.prevZ}return!0})(t,n,r,a):(function(t){var e=t.prev,i=t,n=t.next;if(l(e,i,n)>=0)return!1;var r=t.next.next;for(;r!==t.prev;){if(h(e.x,e.y,i.x,i.y,n.x,n.y,r.x,r.y)&&l(r.prev,r,r.next)>=0)return!1;r=r.next}return!0})(t))e.push(g.i/i),e.push(t.i/i),e.push(y.i/i),m(t),t=y.next,v=y.next;else if((t=y)===v){p?1===p?o(t=(function(t,e,i){var n=t;do{var r=n.prev,s=n.next.next;!u(r,s)&&_(r,n,n.next,s)&&d(r,s)&&d(s,r)&&(e.push(r.i/i),e.push(n.i/i),e.push(s.i/i),m(n),m(n.next),n=t=s),n=n.next}while(n!==t);return n})(t,e,i),e,i,n,r,a,2):2===p&&(function(t,e,i,n,r,a){var c=t;do{for(var h=c.next.next;h!==c.prev;){if(c.i!==h.i&&(function(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!(function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&_(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1})(t,e)&&d(t,e)&&d(e,t)&&(function(t,e){var i=t,n=!1,r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n})(t,e)})(c,h)){var l=f(c,h);return c=s(c,c.next),l=s(l,l.next),o(c,e,i,n,r,a),void o(l,e,i,n,r,a)}h=h.next}c=c.next}while(c!==t)})(t,e,i,n,r,a):o(s(t),e,i,n,r,a,1);break}}}function a(t,e){return t.x-e.x}function c(t,e,i,n,r){return t=32767*(t-i)/r,e=32767*(e-n)/r,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}function h(t,e,i,n,r,s,o,a){return(r-o)*(e-a)-(t-o)*(s-a)>=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(s-a)-(r-o)*(n-a)>=0}function l(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function u(t,e){return t.x===e.x&&t.y===e.y}function _(t,e,i,n){return!!(u(t,e)&&u(i,n)||u(t,n)&&u(i,e))||l(t,e,i)>0!=l(t,e,n)>0&&l(i,n,t)>0!=l(i,n,e)>0}function d(t,e){return l(t.prev,t,t.next)<0?l(t,e,t.next)>=0&&l(t,t.prev,e)>=0:l(t,e,t.prev)<0||l(t,t.next,e)<0}function f(t,e){var i=new g(t.i,t.x,t.y),n=new g(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function p(t,e,i,n){var r=new g(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function m(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)}function g(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}function y(t,e,i,n){for(var r=0,s=e,o=i-n;s0&&(n+=t[r-1].length,i.holes.push(n))}return i}}),{}],117:[(function(t,e,i){cc.js;var n=t("./types").LineCap,r=t("./types").LineJoin,s=t("./helper"),o=function(t){this._rootCtor(t),this._needDraw=!0,this.cmds=[],this.style={strokeStyle:"black",fillStyle:"white",lineCap:"butt",lineJoin:"miter",miterLimit:10}},a=o.prototype=Object.create(_ccsg.Node.CanvasRenderCmd.prototype);a.constructor=o,a._updateCurrentRegions=function(){var t=this._currentRegion;this._currentRegion=this._oldRegion,this._oldRegion=t,this._currentRegion.setTo(0,0,cc.visibleRect.width,cc.visibleRect.height)},a.rendering=function(t,e,i){var n=t||cc._renderContext,r=n.getContext();n.setTransform(this._worldTransform,e,i),r.save(),r.scale(1,-1);var s=this.style;r.strokeStyle=s.strokeStyle,r.fillStyle=s.fillStyle,r.lineWidth=s.lineWidth,r.lineJoin=s.lineJoin,r.miterLimit=s.miterLimit;for(var o=!0,a=this.cmds,c=0,h=a.length;ci?i:t}function r(t,e){_.call(this,t,e),this.reset()}function s(){this.reset()}function o(){this.vertsOffset=0,this.vertsVBO=gl.createBuffer(),this.vertsBuffer=null,this.uint32VertsBuffer=null,this.vertsDirty=!1,this.indicesOffset=0,this.indicesVBO=gl.createBuffer(),this.indicesBuffer=null,this.indicesDirty=!1}function a(t){this._rootCtor(t),this._needDraw=!0;cc._renderContext;this._buffers=[],this._buffer=null,this._allocBuffer(),this._matrix=new cc.math.Matrix4,this._matrix.identity(),this._paths=[],this._points=[],this._curColorValue=0,this._blendFunc=new cc.BlendFunc(cc.macro.BLEND_SRC,cc.macro.BLEND_DST);var e=new cc.GLProgram;e.initWithVertexShaderByteArray(cc.PresetShaders.POSITION_COLOR_VERT,cc.PresetShaders.POSITION_COLOR_FRAG),e.retain(),e.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION,cc.macro.VERTEX_ATTRIB_POSITION),e.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR,cc.macro.VERTEX_ATTRIB_COLOR),e.link(),e.updateUniforms(),this._shaderProgram=e,this._allocVerts(f)}var c=t("./types").LineCap,h=t("./types").LineJoin,l=t("./earcut"),u=t("./helper"),_=cc.Vec2,d=cc.js,f=32,p=Math.PI,m=Math.min,g=Math.max,y=Math.ceil,v=Math.acos,x=Math.cos,C=Math.sin,T=Math.atan2,b=Math.abs,A=cc.Enum({PT_CORNER:1,PT_LEFT:2,PT_BEVEL:4,PT_INNERBEVEL:8});d.extend(r,_),r.prototype.reset=function(){this.dx=0,this.dy=0,this.dmx=0,this.dmy=0,this.flags=0,this.len=0},s.prototype.reset=function(){this.closed=!1,this.nbevel=0,this.complex=!0,this.points?this.points.length=0:this.points=[]},o.prototype.clear=function(){this.vertsOffset=0,this.indicesOffset=0},o.prototype.alloc=function(t,e){var i=this.vertsOffset+t;if(i>65535)return!1;var n=this.vertsBuffer,r=n?n.length/3:0;if(i>r){for(0===r&&(r=f);i>r;)r*=2;var s=new Float32Array(3*r),o=new Uint32Array(s.buffer);if(n)for(var a=this.uint32VertsBuffer,c=0,h=n.length;c_){for(0===_&&(_=3*f);u>_;)_*=2;var d=new Uint16Array(_);if(l)for(c=0,h=l.length;c>>0)+(t.b<<16)+(t.g<<8)+t.r,this._expandStroke(),this._updatePathOffset=!0},S.fill=function(){var t=this._fillColor;this._curColorValue=(t.a<<24>>>0)+(t.b<<16)+(t.g<<8)+t.r,this._expandFill(),this._updatePathOffset=!0,this._filling=!1},S._strokeColor=null,S._fillColor=null,S.setStrokeColor=function(t){this._strokeColor=t},S.getStrokeColor=function(){return this._strokeColor},S.setFillColor=function(t){this._fillColor=t},S.getFillColor=function(){return this._fillColor},S.setLineWidth=function(t){this.lineWidth=t},S.setLineJoin=function(t){this.lineJoin=t},S.setLineCap=function(t){this.lineCap=t},S.setMiterLimit=function(t){this.miterLimit=t},d.getset(S,"strokeColor",S.getStrokeColor,S.setStrokeColor),d.getset(S,"fillColor",S.getFillColor,S.setFillColor),S._render=function(){var t=this._buffers;if(0!==t.length){for(var e=cc._renderContext,i=0,n=t.length;i0&&(n=1/t);for(var r=this._paths,s=this._pathOffset,o=this._pathLength;s1e-6){var T=1/f;T>600&&(T=600),_.dmx*=T,_.dmy*=T}_.dx*u.dy-u.dx*_.dy>0&&(0,_.flags|=A.PT_LEFT),f*(p=g(11,m(u.len,_.len)*n))*p<1&&(_.flags|=A.PT_INNERBEVEL),_.flags&A.PT_CORNER&&(f*i*i<1||e===h.BEVEL||e===h.ROUND)&&(_.flags|=A.PT_BEVEL),0!=(_.flags&(A.PT_BEVEL|A.PT_INNERBEVEL))&&a.nbevel++,u=_,_=c[d+1]}}},S._vset=function(t,e){var i=this._buffer,n=3*i.vertsOffset,r=i.vertsBuffer;r[n]=t,r[n+1]=e,i.uint32VertsBuffer[n+2]=this._curColorValue,i.vertsOffset++},S._chooseBevel=function(t,e,i,n){var r,s,o,a,c=i.x,h=i.y;return 0!==t?(r=c+e.dy*n,s=h-e.dx*n,o=c+i.dy*n,a=h-i.dx*n):(r=o=c+i.dmx*n,s=a=h+i.dmy*n),[r,s,o,a]},S._buttCap=function(t,e,i,n,r){var s=t.x-e*r,o=t.y-i*r,a=i,c=-e;this._vset(s+a*n,o+c*n),this._vset(s-a*n,o-c*n)},S._roundCapStart=function(t,e,i,n,r){for(var s=t.x,o=t.y,a=i,c=-e,h=0;hg&&(I-=2*p),this._vset(_,d),this._vset(l-o*r,e.y-a*r);for(var v=n(y((g-I)/p)*s,2,s),b=0;b10||(f=.5*(r+o),p=.5*(s+a),m=.5*((l=.5*(t+i))+(_=.5*(i+r))),g=.5*((u=.5*(e+n))+(d=.5*(n+s))),((w=b((i-o)*(S=a-e)-(n-a)*(T=o-t)))+(E=b((r-o)*S-(s-a)*T)))*(w+E)=2*n)m=2*n;else for(;m<0;)m+=2*n;else if(c(m)>=2*n)m=2*-n;else for(;m>0;)m-=2*n;for(f=0|s(1,r(c(m)/(.5*n)+.5,5)),y=c(4/3*(1-o(g=m/f/2))/a(g)),_||(y=-y),d=0;d<=f;d++)C=e+(v=o(p=l+m*(d/f)))*h,T=i+(x=a(p))*h,b=-x*h*y,A=v*h*y,0===d?t.moveTo(C,T):t.bezierCurveTo(S+E,w+I,C-b,T-A,C,T),S=C,w=T,E=b,I=A},ellipse:function(t,e,i,n,r){t.moveTo(e-n,i),t.bezierCurveTo(e-n,i+r*l,e-n*l,i+r,e,i+r),t.bezierCurveTo(e+n*l,i+r,e+n,i+r*l,e+n,i),t.bezierCurveTo(e+n,i-r*l,e+n*l,i-r,e,i-r),t.bezierCurveTo(e-n*l,i-r,e-n,i-r*l,e-n,i),t.close()},roundRect:function(t,e,i,n,s,o){if(o<.1)t.rect(e,i,n,s);else{var a=r(o,.5*c(n))*h(n),u=r(o,.5*c(s))*h(s);t.moveTo(e,i+u),t.lineTo(e,i+s-u),t.bezierCurveTo(e,i+s-u*(1-l),e+a*(1-l),i+s,e+a,i+s),t.lineTo(e+n-a,i+s),t.bezierCurveTo(e+n-a*(1-l),i+s,e+n,i+s-u*(1-l),e+n,i+s-u),t.lineTo(e+n,i+u),t.bezierCurveTo(e+n,i+u*(1-l),e+n-a*(1-l),i,e+n-a,i),t.lineTo(e+a,i),t.bezierCurveTo(e+a*(1-l),i,e,i+u*(1-l),e,i+u),t.close()}}}}),{}],122:[(function(t,e,i){"use strict";var n;if(n=_ccsg.GraphicsNode=t("./graphics-node")){t("../utils/misc").propertyDefine(n,["lineWidth","lineCap","lineJoin","miterLimit","strokeColor","fillColor"],{})}t("./graphics")}),{"../utils/misc":226,"./graphics":120,"./graphics-node":118}],123:[(function(t,e,i){"use strict";var n=cc.Enum({BUTT:0,ROUND:1,SQUARE:2}),r=cc.Enum({BEVEL:0,ROUND:1,MITER:2});e.exports={LineCap:n,LineJoin:r}}),{}],124:[(function(t,e,i){t("./platform"),t("./assets"),t("./CCNode"),t("./CCScene"),t("./components"),t("./graphics"),t("./collider"),t("./collider/CCIntersection"),t("./physics"),t("./camera/CCCamera"),t("./base-ui/CCWidgetManager")}),{"./CCNode":40,"./CCScene":41,"./assets":54,"./base-ui/CCWidgetManager":59,"./camera/CCCamera":60,"./collider":69,"./collider/CCIntersection":67,"./components":103,"./graphics":122,"./physics":158,"./platform":194}],125:[(function(t,e,i){var n=/^(click)(\s)*=/,r=/(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=/;cc.HtmlTextParser=function(){this._parsedObject={},this._specialSymbolArray=[],this._specialSymbolArray.push([/</g,"<"]),this._specialSymbolArray.push([/>/g,">"]),this._specialSymbolArray.push([/&/g,"&"]),this._specialSymbolArray.push([/"/g,'"']),this._specialSymbolArray.push([/'/g,"'"])},cc.HtmlTextParser.prototype={constructor:cc.HtmlTextParser,parse:function(t){this._resultObjectArray=[],this._stack=[];for(var e=0,i=t.length;e",e);-1===r?r=n:"/"===t.charAt(n+1)?this._stack.pop():this._addToStack(t.substring(n+1,r)),e=r+1}}return this._resultObjectArray},_attributeToObject:function(t){var e,i,n,s,o={},a=(t=t.trim()).match(/^(color|size)(\s)*=/);if(a){if(e=a[0],""===(t=t.substring(e.length).trim()))return o;switch(i=t.indexOf(" "),e[0]){case"c":o.color=i>-1?t.substring(0,i).trim():t;break;case"s":o.size=parseInt(t)}return i>-1&&(s=t.substring(i+1).trim(),n=this._processEventHandler(s),o.event=n),o}if((a=t.match(/^(br(\s)*\/)/))&&a[0].length>0&&(e=a[0].trim()).startsWith("br")&&"/"===e[e.length-1])return o.isNewLine=!0,this._resultObjectArray.push({text:"",style:{newline:!0}}),o;if((a=t.match(/^(img(\s)*src(\s)*=[^>]+\/)/))&&a[0].length>0&&(e=a[0].trim()).startsWith("img")&&"/"===e[e.length-1]){a=t.match(r);for(var c,h=!1;a;)e=(t=t.substring(t.indexOf(a[0]))).substr(0,a[0].length),_=(i=(c=t.substring(e.length).trim()).indexOf(" "))>-1?c.substr(0,i):c,e=(e=e.replace(/[^a-zA-Z]/g,"").trim()).toLocaleLowerCase(),t=c.substring(i).trim(),"src"===e?(o.isImage=!0,_.endsWith("/")&&(_=_.substring(0,_.length-1)),0===_.indexOf("'")?(h=!0,_=_.substring(1,_.length-1)):0===_.indexOf('"')&&(h=!0,_=_.substring(1,_.length-1)),o.src=_):"height"===e?o.imageHeight=parseInt(_):"width"===e?o.imageWidth=parseInt(_):"click"===e&&(o.event=this._processEventHandler(e+"="+_)),a=t.match(r);return h&&o.isImage&&this._resultObjectArray.push({text:"",style:o}),{}}if(a=t.match(/^(outline(\s)*[^>]*)/)){var l={color:"#ffffff",width:1};if(t=a[0].substring("outline".length).trim()){var u=/(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=/;a=t.match(u);for(var _;a;)e=(t=t.substring(t.indexOf(a[0]))).substr(0,a[0].length),_=(i=(c=t.substring(e.length).trim()).indexOf(" "))>-1?c.substr(0,i):c,e=(e=e.replace(/[^a-zA-Z]/g,"").trim()).toLocaleLowerCase(),t=c.substring(i).trim(),"click"===e?o.event=this._processEventHandler(e+"="+_):"color"===e?l.color=_:"width"===e&&(l.width=parseInt(_)),a=t.match(u)}o.outline=l}if((a=t.match(/^(on|u|b|i)(\s)*/))&&a[0].length>0){switch(e=a[0],t=t.substring(e.length).trim(),e[0]){case"u":o.underline=!0;break;case"i":o.italic=!0;break;case"b":o.bold=!0}if(""===t)return o;n=this._processEventHandler(t),o.event=n}return o},_processEventHandler:function(t){for(var e=0,i={},r=t.match(n),s=!1;r;){var o=r[0],a="";if(s=!1,'"'===(t=t.substring(o.length).trim()).charAt(0))(e=t.indexOf('"',1))>-1&&(a=t.substring(1,e).trim(),s=!0),e++;else if("'"===t.charAt(0))(e=t.indexOf("'",1))>-1&&(a=t.substring(1,e).trim(),s=!0),e++;else{var c=t.match(/(\S)+/);e=(a=c?c[0]:"").length}s&&(i[o=o.substring(0,o.length-1).trim()]=a),r=(t=t.substring(e).trim()).match(n)}return i},_addToStack:function(t){var e=this._attributeToObject(t);if(0===this._stack.length)this._stack.push(e);else{if(e.isNewLine||e.isImage)return;var i=this._stack[this._stack.length-1];for(var n in i)e[n]||(e[n]=i[n]);this._stack.push(e)}},_processResult:function(t){""!==t&&(t=this._escapeSpecialSymbol(t),this._stack.length>0?this._resultObjectArray.push({text:t,style:this._stack[this._stack.length-1]}):this._resultObjectArray.push({text:t}))},_escapeSpecialSymbol:function(t){for(var e=0;e0&&this._isVerticalClamp()&&this._shrinkLabelToContentSize(this._isVerticalClamp.bind(this))}if(!this._updateQuads()){t=!1,this._overFlow===_ccsg.Label.Overflow.SHRINK&&this._shrinkLabelToContentSize(this._isHorizontalClamp.bind(this));break}}while(0);return t},_isHorizontalClamped:function(t,e){var i=this._linesWidth[e],n=t>this._contentSize.width||t<0;return this._isWrapText?i>this._contentSize.width&&n:n},_updateQuads:function(){var t=!0;this._spriteBatchNode.removeAllChildren();for(var e=0;e0){if(n>this._tailoredTopY){var r=n-this._tailoredTopY;this._reusedRect.y+=r,this._reusedRect.height-=r,n-=r}n-i._height*this._bmfontScale0&&this._isHorizontalClamped(o,s))if(this._overFlow===_ccsg.Label.Overflow.CLAMP)this._reusedRect.width=0;else if(this._overFlow===_ccsg.Label.Overflow.SHRINK){if(this._contentSize.width>i._width){t=!1;break}this._reusedRect.width=0}if(this._reusedRect.height>0&&this._reusedRect.width>0){var a=this.getChildByTag(e),c=this._spriteBatchNode._texture,h=this._spriteFrame,l=this._spriteFrame.isRotated(),u=h._originalSize,_=h._rect,d=h._offset,f=d.x+(u.width-_.width)/2,p=d.y-(u.height-_.height)/2;if(l){var m=this._reusedRect.x;this._reusedRect.x=_.x+_.height-this._reusedRect.y-this._reusedRect.height-p,this._reusedRect.y=m+_.y-f,this._reusedRect.y<0&&(this._reusedRect.height=this._reusedRect.height+p)}else this._reusedRect.x+=_.x-f,this._reusedRect.y+=_.y+p;a?a.setTextureRect(this._reusedRect,l):((a=new _ccsg.Sprite).initWithTexture(c,this._reusedRect,l),a.setAnchorPoint(cc.p(0,1)));var g=this._lettersInfo[e]._positionX+this._linesOffsetX[this._lettersInfo[e]._lineIndex];a.setPosition(g,n),this._updateLetterSpriteScale(a),this._spriteBatchNode.addChild(a)}}return t},_updateLetterSpriteScale:function(t){this._labelType===_ccsg.Label.Type.BMFont&&this._fontSize>0&&t.setScale(this._bmfontScale)},_recordPlaceholderInfo:function(t,e){if(t>=this._lettersInfo.length){var i=new o;this._lettersInfo.push(i)}this._lettersInfo[t]._char=e,this._lettersInfo[t]._valid=!1},_recordLetterInfo:function(t,e,i,n){if(i>=this._lettersInfo.length){var r=new o;this._lettersInfo.push(r)}e=e.charCodeAt(0),this._lettersInfo[i]._lineIndex=n,this._lettersInfo[i]._char=e,this._lettersInfo[i]._valid=this._fontAtlas._letterDefinitions[e]._validDefinition,this._lettersInfo[i]._positionX=t.x,this._lettersInfo[i]._positionY=t.y},_setDimensions:function(t,e){var i="number"==typeof t.width?t.width:t,n="number"==typeof t.height?t.height:e,r=this.getContentSize();_ccsg.Node.prototype.setContentSize.call(this,t,e),n===r.height&&i===r.width||(this._setupBMFontOverflowMetrics(i,n),this._drawFontsize>0&&this._restoreFontSize(),this._notifyLabelSkinDirty())},_restoreFontSize:function(){this._fontSize=this._drawFontsize},_multilineTextWrap:function(t){var e=this.getStringLength(),i=0,n=0,r=0,s=0,o=0,a=this._lineSpacing,c=0,h=0,l=null,u=cc.p(0,0);this._updateBMFontScale();for(var _=0;_0&&n>0&&T+l._width*this._bmfontScale>this._maxLineWidth&&!cc.TextUtils.isUnicodeSpace(d)){this._linesWidth.push(o),o=0,i++,n=0,r-=this._lineHeight*this._bmfontScale+a,v=!0;break}u.x=T,u.y=r-l._offsetY*this._bmfontScale,this._recordLetterInfo(u,d,C,i),C+1u.y-l._height*this._bmfontScale&&(m=u.y-l._height*this._bmfontScale)}else this._recordPlaceholderInfo(C,d),console.log("Can't find letter definition in texture atlas "+this._config.atlasName+" for letter:"+d);else this._recordPlaceholderInfo(C,d)}v||(n=y,o=g,cm&&(h=m),s1&&(this._textDesiredHeight+=(this._numberOfLines-1)*this._lineSpacing);var b=cc.size(this._labelWidth,this._labelHeight);return this._labelWidth<=0&&(b.width=parseFloat(s.toFixed(2))),this._labelHeight<=0&&(b.height=parseFloat(this._textDesiredHeight.toFixed(2))),_ccsg.Node.prototype.setContentSize.call(this,b),this._tailoredTopY=b.height,this._tailoredBottomY=0,c>0&&(this._tailoredTopY=b.height+c),h<-this._textDesiredHeight&&(this._tailoredBottomY=this._textDesiredHeight+h),!0},_multilineTextWrapByWord:function(){return this._multilineTextWrap(this._getFirstWordLen.bind(this))},_multilineTextWrapByChar:function(){return this._multilineTextWrap(this._getFirstCharLen.bind(this))},_isVerticalClamp:function(){return this._textDesiredHeight>this._contentSize.height},_isHorizontalClamp:function(){for(var t=!1,e=0;e0)if(this._isWrapText){if(this._linesWidth[r]>this._contentSize.width&&(n>this._contentSize.width||n<0)){t=!0;break}}else if(n>this._contentSize.width){t=!0;break}}return t},_shrinkLabelToContentSize:function(t){for(var e=this.getFontSize(),i=0,n=this._fontAtlas.cloneLetterDefinition(),r=this._lineHeight,s=!0;t();){var o=e-++i;if(s=!1,o<=0)break;var a=o/e;this._fontAtlas.assignLetterDefinitions(n),this._fontAtlas.scaleFontLetterDefinition(a),this._lineHeight=r*a,this._lineBreakWithoutSpaces?this._multilineTextWrapByChar():this._multilineTextWrapByWord(),this._computeAlignmentOffset()}this._lineHeight=r,this._fontAtlas.assignLetterDefinitions(n),s||e-i>=0&&this._scaleFontSizeDown(e-i)},_scaleFontSizeDown:function(t){var e=!0;this._labelType===_ccsg.Label.Type.BMFont&&(t||(t=.1,e=!1),this._fontSize=t,e&&this._updateContent())},_updateContent:function(){this._fontAtlas&&(this._computeHorizontalKerningForText(this._string),this._alignText())},_computeAlignmentOffset:function(){switch(this._linesOffsetX=[],this._hAlign){case cc.TextAlignment.LEFT:for(var t=0;tthis._maxLineWidth&&!cc.TextUtils.isUnicodeSpace(n)&&this._maxLineWidth>0)return r;if(o+=s._xAdvance*this._bmfontScale+this._spacingX,"\n"===n||cc.TextUtils.isUnicodeSpace(n)||cc.TextUtils.isUnicodeCJK(n))break;r++}return r},_updateBMFontScale:function(){if(this._labelType===_ccsg.Label.Type.BMFont){var t=this._fontAtlas._fontSize;this._bmfontScale=this._fontSize/t}else this._bmfontScale=1},_initBMFontWithString:function(t,e){if(this._config)return cc.logID(4002),!1;this._string=t,this._setBMFontFile(e)},_createSpriteBatchNode:function(t){this._spriteBatchNode=new cc.SpriteBatchNode(t,this._string.length),this._spriteBatchNode.setCascadeColorEnabled(!0),this._spriteBatchNode.setCascadeOpacityEnabled(!0),this.addChild(this._spriteBatchNode),this._updateContent(),this.setColor(this.color)},_createFontChars:function(){if(this._config){this._fontAtlas=new cc.FontAtlas(this._config),this._lineHeight||(this._lineHeight=this._fontAtlas._lineHeight);var t=this._config.fontDefDictionary;for(var e in t){var i=new s,n=t[e].rect;i._offsetX=parseInt(t[e].xOffset),i._offsetY=parseInt(t[e].yOffset),i._width=parseInt(n.width),i._height=parseInt(n.height),i._u=parseInt(n.x)+this._imageOffset.x,i._v=parseInt(n.y)+this._imageOffset.y,i._textureID=0,i._validDefinition=!0,i._xAdvance=parseInt(t[e].xAdvance),this._fontAtlas.addLetterDefinitions(e,i)}}},_rescaleWithOriginalFontSize:function(){var t=this.getFontSize();this._drawFontsize-t>=1&&this._overFlow===_ccsg.Label.Overflow.SHRINK&&(this._labelType===_ccsg.Label.Type.BMFont?this._scaleFontSizeDown(this._drawFontsize):this._fontSize=this._drawFontsize)},_computeHorizontalKerningForText:function(){for(var t=this.getStringLength(),e=this._config.kerningDict,i=-1,n=0;nc||o>a;){if(u?h=_/2|0:_=h=_-1,h<=0){cc.logID(4003);break}for(t._fontSize=h,i=this._constructFontDesc(),this._labelContext.font=i,this._splitedStrings=[],s=0,r=0;rc?_=0|h:(u=!1,s=c+1))}}else{for(s=e.length*this._getLineHeight(),r=0;ro?r:o}s=this._splitedStrings.length*this._getLineHeight(),this._canvasSize.width=Math.round(r.toFixed(2))+2*this._getMargin(),this._canvasSize.height=Math.round(s.toFixed(2)),e._isItalic&&(this._canvasSize.width+=e._drawFontsize*Math.tan(.20943951)),_ccsg.Node.prototype.setContentSize.call(e,this._canvasSize)}this._labelCanvas.width=this._canvasSize.width,this._labelCanvas.height=this._canvasSize.height},t._calculateFillTextStartPosition=function(){var t,e,i=this._node,n=this._getLineHeight(),r=this._splitedStrings.length;return t=cc.TextAlignment.RIGHT===i._hAlign?this._canvasSize.width-this._getMargin():cc.TextAlignment.CENTER===i._hAlign?this._canvasSize.width/2:0+this._getMargin(),e=cc.VerticalTextAlignment.TOP===i._vAlign?0:cc.VerticalTextAlignment.CENTER===i._vAlign?this._canvasSize.height/2-n*(r-1)/2:this._canvasSize.height-n*(r-1),cc.p(t,e)},t._calculateTextBaseline=function(){var t,e,i=this._node;t=cc.TextAlignment.RIGHT===i._hAlign?"right":cc.TextAlignment.CENTER===i._hAlign?"center":"left",this._labelContext.textAlign=t,e=cc.VerticalTextAlignment.TOP===i._vAlign?"top":cc.VerticalTextAlignment.CENTER===i._vAlign?"middle":"bottom",this._labelContext.textBaseline=e},t._bakeLabel=function(){var t=this._node;this._drawFontsize=t._drawFontsize,this._canvasSize=this._calculateCanvasSize(),this._fontDesc=this._calculateLabelFont(),this._calculateSplitedStrings(),this._updateLabelDimensions(),this._calculateTextBaseline(),this._updateTexture()},t._calculateUnderlineStartPosition=function(){var t,e,i=this._node,n=this._getLineHeight(),r=this._splitedStrings.length;return t=0+this._getMargin(),e=cc.VerticalTextAlignment.TOP===i._vAlign?i._fontSize:cc.VerticalTextAlignment.CENTER===i._vAlign?this._canvasSize.height/2-n*(r-1)/2+i._fontSize/2:this._canvasSize.height-n*(r-1),cc.p(t,e)},t._updateTexture=function(){this._labelContext.clearRect(0,0,this._labelCanvas.width,this._labelCanvas.height),this._labelContext.font=this._fontDesc;var t=this._calculateFillTextStartPosition(),e=this._getLineHeight();this._labelContext.lineJoin="round";var i=this._displayedColor;this._labelContext.fillStyle="rgb("+i.r+","+i.g+","+i.b+")";for(var n,r=0;ra||sc)},t.rendering=function(t,e,i){var n=this._node;if(n._labelType===_ccsg.Label.Type.TTF||n._labelType===_ccsg.Label.Type.SystemFont){var r=this._displayedOpacity,s=r/255;if(0===r)return;var o=t||cc._renderContext,a=o.getContext();if(o.setTransform(this._worldTransform,e,i),o.setCompositeOperation(_ccsg.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(n._blendFunc)),o.setGlobalAlpha(s),this._texture){var c,h,l,u,_;0,l=-this._node._contentSize.height,u=this._node._contentSize.width,_=this._node._contentSize.height;0,0,c=this._texture.getPixelWidth(),h=this._texture.getPixelHeight();var d=this._texture._image;""!==this._texture._pattern?(o.setFillStyle(a.createPattern(d,this._texture._pattern)),a.fillRect(0,l,u,_)):0!==c&&0!==h&&0!==u&&0!==_&&a.drawImage(d,0,0,c,h,0,l,u,_)}cc.g_NumberOfDraws=cc.g_NumberOfDraws+1}}})()}),{}],128:[(function(t,e,i){_ccsg.Label.WebGLRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,this._texture=new cc.Texture2D,this._labelCanvas=document.createElement("canvas"),this._texture.initWithElement(this._labelCanvas),this._labelContext=this._labelCanvas.getContext("2d"),this._labelCanvas.width=1,this._labelCanvas.height=1,this._splitedStrings=null,this._drawFontsize=0,this._vertices=[{x:0,y:0,u:0,v:0},{x:0,y:0,u:0,v:1},{x:0,y:0,u:1,v:0},{x:0,y:0,u:1,v:1}],this._color=new Uint32Array(1),this._dirty=!1,this._shaderProgram=cc.shaderCache.programForKey(cc.macro.SHADER_SPRITE_POSITION_TEXTURECOLOR)};var n=_ccsg.Label.WebGLRenderCmd.prototype=Object.create(_ccsg.Node.WebGLRenderCmd.prototype);cc.js.mixin(n,_ccsg.Label.TTFLabelBaker.prototype),n.constructor=_ccsg.Label.WebGLRenderCmd,n.updateTransform=function(t){this.originUpdateTransform(t);this._node;var e=this._labelCanvas.width,i=this._labelCanvas.height,n=this._worldTransform,r=this._vertices;r[0].x=0*n.a+i*n.c+n.tx,r[0].y=0*n.b+i*n.d+n.ty,r[1].x=0*n.a+0*n.c+n.tx,r[1].y=0*n.b+0*n.d+n.ty,r[2].x=e*n.a+i*n.c+n.tx,r[2].y=e*n.b+i*n.d+n.ty,r[3].x=e*n.a+0*n.c+n.tx,r[3].y=e*n.b+0*n.d+n.ty},n._doCulling=function(){var t=this._node;if(t._string&&(t._labelType===_ccsg.Label.Type.TTF||t._labelType===_ccsg.Label.Type.SystemFont)){var e=cc.visibleRect;this._cameraFlag>0&&(e=cc.Camera.main.visibleRect);var i=e.left.x,n=e.right.x,r=e.top.y,s=e.bottom.y,o=this._vertices;(o[0].x-i&o[1].x-i&o[2].x-i&o[3].x-i)>>31||(n-o[0].x&n-o[1].x&n-o[2].x&n-o[3].x)>>31||(o[0].y-s&o[1].y-s&o[2].y-s&o[3].y-s)>>31||(r-o[0].y&r-o[1].y&r-o[2].y&r-o[3].y)>>31?this._needDraw=!1:this._needDraw=!0}},n.uploadData=function(t,e,i){var n=this._node;if(!n._string||n._labelType!==_ccsg.Label.Type.TTF&&n._labelType!==_ccsg.Label.Type.SystemFont)return 0;var r=this._displayedOpacity;this._color[0]=~~r<<24>>>0|~~r<<16|~~r<<8|~~r;var s,o,a=n._vertexZ,c=this._vertices,h=c.length,l=i;for(s=0;s、‘“》?。,!]/,label_lastWordRex:/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]+|\S)$/,label_lastEnglish:/[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]+$/,label_firstEnglish:/^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]/,label_wrapinspection:!0,isUnicodeCJK:function(t){return/^[\u4E00-\u9FFF\u3400-\u4DFF]+$/.test(t)||/[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B/g.test(t)||/^[\u1100-\u11FF]|[\u3130-\u318F]|[\uA960-\uA97F]|[\uAC00-\uD7AF]|[\uD7B0-\uD7FF]+$/.test(t)},isUnicodeSpace:function(t){return(t=t.charCodeAt(0))>=9&&t<=13||32===t||133===t||160===t||5760===t||t>=8192&&t<=8202||8232===t||8233===t||8239===t||8287===t||12288===t},fragmentText:function(t,e,i,n){var r=[];if(0===t.length||i<0)return r.push(""),r;for(var s=t;e>i&&s.length>1;){for(var o=s.length*(i/e)|0,a=s.substr(o),c=e-n(a),h=a,l=0,u=0;c>i&&u++<10;)o*=i/c,o|=0,c=e-n(a=s.substr(o));for(u=0;c<=i&&u++<10;){if(a){var _=this.label_wordRex.exec(a);l=_?_[0].length:1,h=a}o+=l,c=e-n(a=s.substr(o))}0==(o-=l)&&(o=1,h=h.substr(1));var d,f=s.substr(0,o);this.label_wrapinspection&&this.label_symbolRex.test(h||a)&&(0==(o-=(d=this.label_lastWordRex.exec(f))?d[0].length:0)&&(o=1),h=s.substr(o),f=s.substr(0,o)),this.label_firstEnglish.test(h)&&(d=this.label_lastEnglish.exec(f))&&f!==d[0]&&(o-=d[0].length,h=s.substr(o),f=s.substr(0,o)),0===r.length?r.push(f):(f=f.trim()).length>0&&r.push(f),e=n(s=h||a)}return 0===r.length?r.push(s):(s=s.trim()).length>0&&r.push(s),r}},cc.CustomFontLoader=e.exports=r}),{}],130:[(function(t,e,i){function n(t){var e,i,n;if("object"==typeof t){if(i=t,t.url)return i;e=t.uuid}else i={},e=t;return n=i.type?"uuid"===i.type:cc.AssetLibrary._getAssetUrl(e),cc.AssetLibrary._getAssetInfoInRuntime(e,m),i.url=n?m.url:e,m.url&&"uuid"===i.type&&m.raw?(i.type=null,i.isRawAsset=!0):n||(i.isRawAsset=!0),i}function r(){var t=new c,e=new h,i=new l;o.call(this,[t,e,i]),this.assetLoader=t,this.downloader=e,this.loader=i,this.onProgress=null,this._autoReleaseSetting={}}var s=t("../platform/js"),o=t("./pipeline"),a=t("./loading-items"),c=t("./asset-loader"),h=t("./downloader"),l=t("./loader"),u=t("./asset-table"),_=t("../platform/utils").callInNextTick,d=t("./auto-release-utils"),f=new u,p=["mp3","ogg","wav","m4a"],m={url:null,raw:!1},g=[],y=[];s.extend(r,o);var v=r.prototype;v.init=function(t){},v.getXMLHttpRequest=function(){return window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP")},v.addDownloadHandlers=function(t){this.downloader.addHandlers(t)},v.addLoadHandlers=function(t){this.loader.addHandlers(t)},v.load=function(t,e,i){void 0===i&&(i=e,e=this.onProgress||null);var r=this,s=!1;t instanceof Array||(s=!0,t=t?[t]:[]),g.length=0;for(var o=0;o0){var r=this,s=t.map((function(t){return{type:"uuid",uuid:t}}));this.load(s,e,(function(t,e){if(i){for(var o=[],a=n&&[],c=0;ce.length){var i=t.charCodeAt(e.length);return 46===i||47===i}return!0}var s=t("../utils/misc").pushToMap,o=n.prototype;o.getUuid=function(t,e){t=cc.url.normalize(t);var i=this._pathToUuid[t];if(i)if(Array.isArray(i)){if(!e)return i[0].uuid;for(var n=0;n0&&r.src===s)return r;(function(){function i(){r.removeEventListener("load",i),r.removeEventListener("error",o),e(null,r)}function o(){r.removeEventListener("load",i),r.removeEventListener("error",o),"https:"!==window.location.protocol&&r.crossOrigin&&"anonymous"===r.crossOrigin.toLowerCase()?n(t,e,!1,r):e(new Error("Load image ("+s+") failed"))}r.addEventListener("load",i),r.addEventListener("error",o),r.src=s})()}function r(t,e,i){var n=document,r=document.createElement("style");r.type="text/css",n.body.appendChild(r);var s="";if(isNaN(t-0)?s+="@font-face { font-family:"+t+"; src:":s+="@font-face { font-family:'"+t+"'; src:",e instanceof Array)for(var o=0,a=e.length;o=0)&&(o.deps&&s(t,o,!0))){n=!0;break}}}return i||(f.length=0),n}var o=t("../platform/callbacks-invoker"),a=t("../utils/CCPath"),c=t("../platform/js"),h=0|998*Math.random(),l={},u=[],_={WORKING:1,COMPLETE:2,ERROR:3},d={},f=[],p=function(t,e,i,n){o.call(this),this._id=++h,l[this._id]=this,this._pipeline=t,this._errorUrls=[],this._appending=!1,this._ownerQueue=null,this.onProgress=i,this.onComplete=n,this.map={},this.completed={},this.totalCount=0,this.completedCount=0,this._pipeline?this.active=!0:this.active=!1,e&&(e.length>0?this.append(e):this.allComplete())};p.ItemState=new cc.Enum(_),p.create=function(t,e,i,n){void 0===i?"function"==typeof e&&(n=e,e=i=null):void 0===n&&("function"==typeof e?(n=i,i=e,e=null):(n=i,i=null));var r=u.pop();return r?(r._pipeline=t,r.onProgress=i,r.onComplete=n,l[r._id]=r,r._pipeline&&(r.active=!0),e&&r.append(e)):r=new p(t,e,i,n),r},p.getQueue=function(t){return t.queueId?l[t.queueId]:null},p.itemComplete=function(t){var e=l[t.queueId];e&&e.itemComplete(t.id)},p.initQueueDeps=function(t){var e=d[t._id];e?(e.completed.length=0,e.deps.length=0):e=d[t._id]={completed:[],deps:[]}},p.registerQueueDep=function(t,e){var i=t.queueId||t;if(!i)return!1;var n=d[i];if(n)-1===n.deps.indexOf(e)&&n.deps.push(e);else if(t.id)for(var r in d){var s=d[r];-1!==s.deps.indexOf(t.id)&&-1===s.deps.indexOf(e)&&s.deps.push(e)}},p.finishDep=function(t){for(var e in d){var i=d[e];-1!==i.deps.indexOf(t)&&-1===i.completed.indexOf(t)&&i.completed.push(t)}};var m=p.prototype;c.mixin(m,o.prototype),m.append=function(t,e){if(!this.active)return[];e&&!e.deps&&(e.deps=[]),this._appending=!0;var i,o,a,c=[];for(i=0;i=this.totalCount},m.isItemCompleted=function(t){return!!this.completed[t]},m.exists=function(t){return!!this.map[t]},m.getContent=function(t){var e=this.map[t],i=null;return e&&(e.content?i=e.content:e.alias&&(i=e.alias.content)),i},m.getError=function(t){var e=this.map[t],i=null;return e&&(e.error?i=e.error:e.alias&&(i=e.alias.error)),i},m.addListener=o.prototype.add,m.hasListener=o.prototype.has,m.removeListener=o.prototype.remove,m.removeAllListeners=o.prototype.removeAll,m.removeItem=function(t){var e=this.map[t];e&&this.completed[e.alias||t]&&(delete this.completed[t],delete this.map[t],e.alias&&(delete this.completed[e.alias.id],delete this.map[e.alias.id]),this.completedCount--,this.totalCount--)},m.itemComplete=function(t){var e=this.map[t];if(e){var i=this._errorUrls.indexOf(t);if(e.error&&-1===i?this._errorUrls.push(t):e.error||-1===i||this._errorUrls.splice(i,1),this.completed[t]=e,this.completedCount++,p.finishDep(e.id),this.onProgress){var n=d[this._id];this.onProgress(n?n.completed.length:this.completedCount,n?n.deps.length:this.totalCount,e)}this.invoke(t,e),this.removeAll(t),!this._appending&&this.completedCount>=this.totalCount&&this.allComplete()}},m.destroy=function(){this.active=!1,this._appending=!1,this._pipeline=null,this._ownerQueue=null,this._errorUrls.length=0,this.onProgress=null,this.onComplete=null,this.map={},this.completed={},this.totalCount=0,this.completedCount=0,o.call(this),l[this._id]=null,d[this._id]&&(d[this._id].completed.length=0,d[this._id].deps.length=0),-1===u.indexOf(this)&&u.length<10&&u.push(this)},cc.LoadingItems=e.exports=p}),{"../platform/callbacks-invoker":190,"../platform/js":197,"../utils/CCPath":219}],140:[(function(t,e,i){var n=t("./pipeline"),r=/(\.[^.\n\\/]*)$/,s=function(t,e,i){this.id="MD5Pipe",this.async=!1,this.pipeline=null,this.md5AssetsMap=t,this.libraryBase=e,this.rawAssetsBase=i};s.ID="MD5Pipe",s.prototype.handle=function(t){return t.url=this.transformURL(t.url),t},s.prototype.transformURL=function(t){var e=t.indexOf("?"),i=t;if(-1!==e&&(i=t.substr(0,e)),i.startsWith(this.libraryBase))i=i.slice(this.libraryBase.length);else{if(!i.startsWith(this.rawAssetsBase))return t;i=i.slice(this.rawAssetsBase.length)}var n=this.md5AssetsMap[i];if(n){var s=!1;t=t.replace(r,(function(t,e){return s=!0,"."+n+e})),s||(t=t+"."+n)}return t},n.MD5Pipe=e.exports=s}),{"./pipeline":142}],141:[(function(t,e,i){function n(t,e){return new Error("Can not retrieve "+t+" from packer "+e)}var r=t("./json-unpacker"),s=t("../utils/misc").pushToMap,o={},a={},c={},h=0,l=2,u=3;e.exports={initPacks:function(t){a=t;for(var e in t)for(var i=t[e],n=0;ne&&(e=o,i=r)}}return e!==h?i:t[0]},load:function(t,e){var i=t.uuid,s=o[i];if(s){Array.isArray(s)&&(s=this._selectLoadedPack(s));var a=c[s];if(a&&a.state===u){var h=a.retrieve(i);return h||n(i,s)}return a||(console.log("Create unpacker %s for %s",s,i),(a=c[s]=new r).state=l),this._loadNewPack(i,s,e),null}}}}),{"../utils/misc":226,"./json-unpacker":137}],142:[(function(t,e,i){function n(t,e){var i=t.id,r=e.states[i],o=t.next,a=t.pipeline;if(!e.error&&r!==s.WORKING&&r!==s.ERROR)if(r===s.COMPLETE)o?n(o,e):a.flowOut(e);else{e.states[i]=s.WORKING;var c=t.handle(e,(function(t,r){t?(e.error=t,e.states[i]=s.ERROR,a.flowOut(e)):(r&&(e.content=r),e.states[i]=s.COMPLETE,o?n(o,e):a.flowOut(e))}));c instanceof Error?(e.error=c,e.states[i]=s.ERROR,a.flowOut(e)):void 0!==c&&(null!==c&&(e.content=c),e.states[i]=s.COMPLETE,o?n(o,e):a.flowOut(e))}}t("../platform/js");var r=t("./loading-items"),s=r.ItemState,o=function(t){this._pipes=t,this._cache={};for(var e=0;ethis._pipes.length)cc.warnID(4921);else if(this._pipes.indexOf(t)>0)cc.warnID(4922);else{t.pipeline=this;var i=null;e0&&(n=this._pipes[e-1]),n&&(n.next=t),t.next=i,this._pipes.splice(e,0,t)}},a.insertPipeAfter=function(t,e){var i=this._pipes.indexOf(t);i<0||this.insertPipe(e,i+1)},a.appendPipe=function(t){t.handle&&t.id&&(t.pipeline=this,t.next=null,this._pipes.length>0&&(this._pipes[this._pipes.length-1].next=t),this._pipes.push(t))},a.flowIn=function(t){var e,i,r=this._pipes[0];if(r){for(e=0;es&&(this._accumulator=s);this._accumulator>r;)e.Step(r,i,n),this._accumulator-=r}else{var o=1/cc.game.config.frameRate;e.Step(o,i,n)}e.DrawDebugData(),this._steping=!1;for(var a=this._delayEvents,c=0,h=a.length;c0){for(var a=n.getPoints(),l=n.getNormals(),u=n.getFractions(),_=[],d=0,f=r.length;dw&&(E=A,w=I)}m=r(b,E,t),g=r(E,b,t)}return y=y.concat(s(m)),y=y.concat(s(g))}y.push(t);for(b=y.length-1;b>=0;b--)0==y[b].length&&y.splice(b,0);return y}function o(t,e){return a(t,e)}function a(t,e,i){if(void 0===i){var r=t,s=e;t=n(r-1,s),e=n(r,s),i=n(r+1,s)}return p(t,e,i)<0}function c(t,e,i){return p(t,e,i)>0}function h(t,e,i){return p(t,e,i)>=0}function l(t,e,i){return p(t,e,i)<=0}function u(t,e){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n}function _(t){d(t)||t.reverse()}function d(t){return t.length<3||(function(t){var e,i=0;for(e=0;e0}function f(t,e,i,n){var r=cc.v2(),s=e.y-t.y,o=t.x-e.x,a=s*t.x+o*t.y,c=n.y-i.y,h=i.x-n.x,l=c*i.x+h*i.y,u=s*h-c*o;return (function(t,e){return Math.abs(t-e)<=1e-6})(u,0)||(r.x=(h*a-o*l)/u,r.y=(s*l-c*a)/u),r}function p(t,e,i){return t.x*(e.y-i.y)+e.x*(i.y-t.y)+i.x*(t.y-e.y)}e.exports={ConvexPartition:s,ForceCounterClockWise:_,IsCounterClockWise:d}}),{}],152:[(function(t,e,i){var n=t("./CCPhysicsTypes").PTM_RATIO,r=t("./CCPhysicsTypes").ANGLE_TO_PHYSICS_ANGLE,s=t("./CCPhysicsTypes").PHYSICS_ANGLE_TO_ANGLE,o=t("./utils").getWorldRotation,a=t("./CCPhysicsTypes").BodyType,c=new b2.Vec2,h=new b2.Vec2,l=cc.Vec2.ZERO,u=cc.Class({name:"cc.RigidBody",extends:cc.Component,editor:!1,properties:{_type:a.Dynamic,_allowSleep:!0,_gravityScale:1,_linearDamping:0,_angularDamping:0,_linearVelocity:cc.v2(0,0),_angularVelocity:0,_fixedRotation:!1,enabled:{get:function(){return this._enabled},set:function(){cc.warnID("8200")},visible:!1,override:!0},enabledContactListener:{default:!1,tooltip:!1},bullet:{default:!1,tooltip:!1},type:{type:a,tooltip:!1,get:function(){return this._type},set:function(t){this._type=t,this._b2Body&&(t===a.Animated?this._b2Body.SetType(a.Kinematic):this._b2Body.SetType(t))}},allowSleep:{tooltip:!1,get:function(){return this._b2Body?this._b2Body.IsSleepingAllowed():this._allowSleep},set:function(t){this._allowSleep=t,this._b2Body&&this._b2Body.SetSleepingAllowed(t)}},gravityScale:{tooltip:!1,get:function(){return this._gravityScale},set:function(t){this._gravityScale=t,this._b2Body&&this._b2Body.SetGravityScale(t)}},linearDamping:{tooltip:!1,get:function(){return this._linearDamping},set:function(t){this._linearDamping=t,this._b2Body&&this._b2Body.SetLinearDamping(this._linearDamping)}},angularDamping:{tooltip:!1,get:function(){return this._angularDamping},set:function(t){this._angularDamping=t,this._b2Body&&this._b2Body.SetAngularDamping(t)}},linearVelocity:{tooltip:!1,type:cc.Vec2,get:function(){var t=this._linearVelocity;if(this._b2Body){var e=this._b2Body.GetLinearVelocity();t.x=e.x*n,t.y=e.y*n}return t},set:function(t){this._linearVelocity=t;var e=this._b2Body;if(e){var i=e.m_linearVelocity;i.Set(t.x/n,t.y/n),e.SetLinearVelocity(i)}}},angularVelocity:{tooltip:!1,get:function(){return this._b2Body?this._b2Body.GetAngularVelocity()*s:this._angularVelocity},set:function(t){this._angularVelocity=t,this._b2Body&&this._b2Body.SetAngularVelocity(t*r)}},fixedRotation:{tooltip:!1,get:function(){return this._fixedRotation},set:function(t){this._fixedRotation=t,this._b2Body&&this._b2Body.SetFixedRotation(t)}},awake:{tooltip:!1,get:function(){return!!this._b2Body&&this._b2Body.IsAwake()},set:function(t){this._b2Body&&this._b2Body.SetAwake(t)}},active:{visible:!1,get:function(){return!!this._b2Body&&this._b2Body.IsActive()},set:function(t){this._b2Body&&this._b2Body.SetActive(t)}}},getLocalPoint:function(t,e){if(e=e||cc.v2(),this._b2Body){c.Set(t.x/n,t.y/n);var i=this._b2Body.GetLocalPoint(c);e.x=i.x*n,e.y=i.y*n}return e},getWorldPoint:function(t,e){if(e=e||cc.v2(),this._b2Body){c.Set(t.x/n,t.y/n);var i=this._b2Body.GetWorldPoint(c);e.x=i.x*n,e.y=i.y*n}return e},getWorldVector:function(t,e){if(e=e||cc.v2(),this._b2Body){c.Set(t.x/n,t.y/n);var i=this._b2Body.GetWorldVector(c);e.x=i.x*n,e.y=i.y*n}return e},getLocalVector:function(t,e){if(e=e||cc.v2(),this._b2Body){c.Set(t.x/n,t.y/n);var i=this._b2Body.GetLocalVector(c);e.x=i.x*n,e.y=i.y*n}return e},getWorldPosition:function(t){if(t=t||cc.v2(),this._b2Body){var e=this._b2Body.GetPosition();t.x=e.x*n,t.y=e.y*n}return t},getWorldRotation:function(){return this._b2Body?this._b2Body.GetAngle()*s:0},getLocalCenter:function(t){if(t=t||cc.v2(),this._b2Body){var e=this._b2Body.GetLocalCenter();t.x=e.x*n,t.y=e.y*n}return t},getWorldCenter:function(t){if(t=t||cc.v2(),this._b2Body){var e=this._b2Body.GetWorldCenter();t.x=e.x*n,t.y=e.y*n}return t},getLinearVelocityFromWorldPoint:function(t,e){if(e=e||cc.v2(),this._b2Body){c.Set(t.x/n,t.y/n);var i=this._b2Body.GetLinearVelocityFromWorldPoint(c);e.x=i.x*n,e.y=i.y*n}return e},getMass:function(){return this._b2Body?this._b2Body.GetMass():0},getInertia:function(){return this._b2Body?this._b2Body.GetInertia()*n*n:0},getJointList:function(){if(!this._b2Body)return[];var t=[],e=this._b2Body.GetJointList();if(!e)return[];t.push(e.joint._joint);for(var i=e.prev;i;)t.push(i.joint._joint),i=i.prev;for(var n=e.next;n;)t.push(n.joint._joint),n=n.next;return t},applyForce:function(t,e,i){this._b2Body&&(c.Set(t.x/n,t.y/n),h.Set(e.x/n,e.y/n),this._b2Body.ApplyForce(c,h,i))},applyForceToCenter:function(t,e){this._b2Body&&(c.Set(t.x/n,t.y/n),this._b2Body.ApplyForceToCenter(c,e))},applyTorque:function(t,e){this._b2Body&&this._b2Body.ApplyTorque(t/n,e)},applyLinearImpulse:function(t,e,i){this._b2Body&&(c.Set(t.x/n,t.y/n),h.Set(e.x/n,e.y/n),this._b2Body.ApplyLinearImpulse(c,h,i))},applyAngularImpulse:function(t,e){this._b2Body&&this._b2Body.ApplyAngularImpulse(t/n/n,e)},syncPosition:function(t){var e=this._b2Body;if(e){var i,r=this.node.convertToWorldSpaceAR(l);if(i=this.type===a.Animated?e.GetLinearVelocity():e.GetPosition(),i.x=r.x/n,i.y=r.y/n,this.type===a.Animated&&t){var s=e.GetPosition(),o=cc.game.config.frameRate;i.x=(i.x-s.x)*o,i.y=(i.y-s.y)*o,e.SetAwake(!0),e.SetLinearVelocity(i)}else e.SetTransform(i,e.GetAngle())}},syncRotation:function(t){var e=this._b2Body;if(e){var i=r*o(this.node);if(this.type===a.Animated&&t){var n=e.GetAngle(),s=cc.game.config.frameRate;e.SetAwake(!0),e.SetAngularVelocity((i-n)*s)}else e.SetTransform(e.GetPosition(),i)}},resetVelocity:function(){var t=this._b2Body;if(t){var e=t.m_linearVelocity;e.Set(0,0),t.SetLinearVelocity(e),t.SetAngularVelocity(0)}},onEnable:function(){this._init()},onDisable:function(){this._destroy()},_registerNodeEvents:function(){var t=this.node;t.on("position-changed",this._onNodePositionChanged,this),t.on("rotation-changed",this._onNodeRotationChanged,this),t.on("scale-changed",this._onNodeScaleChanged,this)},_unregisterNodeEvents:function(){var t=this.node;t.off("position-changed",this._onNodePositionChanged,this),t.off("rotation-changed",this._onNodeRotationChanged,this),t.off("scale-changed",this._onNodeScaleChanged,this)},_onNodePositionChanged:function(){this.syncPosition(!0)},_onNodeRotationChanged:function(t){this.syncRotation(!0)},_onNodeScaleChanged:function(t){if(this._b2Body)for(var e=this.getComponents(cc.PhysicsCollider),i=0;i=0;n--){var r=t[n];r.collider=null,i._unregisterContactFixture(r),e&&e.DestroyFixture(r)}this.body=null,this._fixtures.length=0,this._shapes.length=0,this._inited=!1}},_createShape:function(){},apply:function(){this._destroy(),this._init()},getAABB:function(){for(var t=1e7,e=1e7,i=-1e7,r=-1e7,s=this._fixtures,o=0;oi&&(i=l.upperBound.x),l.upperBound.y>r&&(r=l.upperBound.y)}t*=n,e*=n,i*=n,r*=n;var u=this._rect;return u.x=t,u.y=e,u.width=i-t,u.height=r-e,u}});cc.PhysicsCollider=e.exports=s}),{"../CCPhysicsTypes":150,"../utils":173}],157:[(function(t,e,i){var n=t("../CCPhysicsTypes").PTM_RATIO,r=t("../CCPolygonSeparator"),s=cc.Class({name:"cc.PhysicsPolygonCollider",extends:cc.PhysicsCollider,mixins:[cc.Collider.Polygon],editor:{menu:!1,inspector:!1,requireComponent:cc.RigidBody},_createShape:function(t){var e=[],i=this.points;i.length>0&&i[0].equals(i[i.length-1])&&(i.length-=1);for(var s=r.ConvexPartition(i),o=this.offset,a=0;a=2?1:n)},n.prototype.getFixtures=function(){return this._fixtures},n.prototype.getPoints=function(){return this._points},n.prototype.getNormals=function(){return this._normals},n.prototype.getFractions=function(){return this._fractions},cc.PhysicsRayCastCallback=e.exports=n}),{}],172:[(function(t,e,i){function n(){}var r=t("../CCPhysicsTypes").PHYSICS_ANGLE_TO_ANGLE,s=t("../CCPhysicsTypes").PTM_RATIO,o=t("../utils").convertToNodeRotation,a=cc.v2();n.prototype.addB2Body=function(t){},n.prototype.removeB2Body=function(t){},n.prototype.syncNode=function(){for(var t=cc.director.getPhysicsManager()._bodies,e=0,i=t.length;e0?s:null,!0);var u=o.prototype;if(e&&(l||(g.extend(o,e),u=o.prototype),g.value(o,"$super",e)),i){for(var d=i.length-1;d>=0;d--){var f=i[d];c(u,f.prototype),c(o,f,(function(t){return f.hasOwnProperty(t)&&!0})),p._isCCClass(f)&&c(x.getClassAttrs(o).constructor.prototype,x.getClassAttrs(f).constructor.prototype)}u.constructor=o}return l||(u.__initProps__=_),g.setClassName(t,o),o}function l(t){for(var e=g.getClassName(t),i=t.constructor,n="new "+e+"(",r=0;r=0)){var s=e[r];if("function"==typeof s){var o=g.getPropertyDescriptor(t.prototype,r);if(o){var a=o.value;if("function"==typeof a){R.test(s)&&(n=!0,e[r]=(function(t,e){return function(){var i=this._super;this._super=t;var n=e.apply(this,arguments);return this._super=i,n}})(a,s));continue}}0}}return n}function f(t,e,i,n,r,a){if(t.__props__=[],n&&n.__props__&&(t.__props__=n.__props__.slice()),r)for(var c=0;c=0)){var l=t[c];b.validateMethodWithProps(l,c,e,r,i)&&g.value(r.prototype,c,l,!0,!0)}var u=t.editor;return u&&cc.isChildClassOf(i,cc.Component)&&cc.Component._registerEditorProps(r,u),r}function m(t,e,i,n,r){function s(){return c=n+C,a=x.getClassAttrsProto(t)}function o(t,i){if(t in e){var n=e[t];typeof n===i&&((a||s())[c+t]=n)}}var a=null,c="";O.length=0;var h=O,l=e.type;if(l){var u=P[l];if(u)h.push({type:l,_onAfterProp:T(u,"cc."+l)});else if("Object"===l)0;else if(l===x.ScriptUuid){var _=x.ObjectType(cc.ScriptAsset);_.type="Script",h.push(_)}else"object"==typeof l?y.isEnum(l)&&h.push({type:"Enum",enumList:y.getList(l)}):"function"==typeof l&&(e.url?h.push({type:"Object",ctor:l,_onAfterProp:T("String","cc.String")}):h.push(e._short?{type:"Object",ctor:l}:x.ObjectType(l)))}e.editorOnly&&((a||s())[c+"editorOnly"]=!0),e.url&&((a||s())[c+"saveUrlAsAsset"]=!0),!1===e.serializable&&((a||s())[c+"serializable"]=!1),o("formerlySerializedAs","string");var d=e.range;return d&&Array.isArray(d)&&d.length>=2&&((a||s())[c+"min"]=d[0],a[c+"max"]=d[1],d.length>2&&(a[c+"step"]=d[2])),o("min","number"),o("max","number"),o("step","number"),h}var g=t("./js"),y=t("./CCEnum"),v=t("./utils"),x=(v.isPlainEmptyObj_DEV,v.cloneable_DEV,t("./attribute")),C=x.DELIMETER,T=x.getTypeChecker,b=t("./preprocess-class");t("./requiring-frame");var A=["name","extends","mixins","ctor","__ctor__","properties","statics","editor","__ES6__"],S={datas:null,push:function(t){if(this.datas)this.datas.push(t);else{this.datas=[t];var e=this;setTimeout((function(){e.init()}),0)}},init:function(){var t=this.datas;if(t){for(var e=0;e0){var o=!(i&&i.startsWith("cc."));o&&(r+="try{\n");var a="].apply(this,arguments);\n";if(1===s)r+="CCClass.__ctors__[0"+a;else{r+="var cs=CCClass.__ctors__;\n";for(var c=0;ca)return this._removeUsedIndexBit(i),delete this._touchesIntegerDict[n.getID()],i;t>>=1}return-1},_removeUsedIndexBit:function(t){if(!(t<0||t>=this._maxTouches)){var e=1<0){this._glView._convertTouchesWithScale(r);var _=new cc.Event.EventTouch(r);_._eventCode=cc.Event.EventTouch.BEGAN,o.dispatchEvent(_)}},handleTouchesMove:function(t){for(var e,i,n,r=[],a=this._touches,c=s.now(),h=0,l=t.length;h0){this._glView._convertTouchesWithScale(r);var u=new cc.Event.EventTouch(r);u._eventCode=cc.Event.EventTouch.MOVED,o.dispatchEvent(u)}},handleTouchesEnd:function(t){var e=this.getSetOfTouchesEndOrCancel(t);if(e.length>0){this._glView._convertTouchesWithScale(e);var i=new cc.Event.EventTouch(e);i._eventCode=cc.Event.EventTouch.ENDED,o.dispatchEvent(i)}},handleTouchesCancel:function(t){var e=this.getSetOfTouchesEndOrCancel(t);if(e.length>0){this._glView._convertTouchesWithScale(e);var i=new cc.Event.EventTouch(e);i._eventCode=cc.Event.EventTouch.CANCELLED,o.dispatchEvent(i)}},getSetOfTouchesEndOrCancel:function(t){for(var e,i,n,r=[],s=this._touches,o=this._touchesIntegerDict,a=0,c=t.length;a=0;r--)if(i[r].getID()===n){e=i[r];break}return e||(e=t),e},setPreTouch:function(t){for(var e=!1,i=this._preTouchPool,n=t.getID(),r=i.length-1;r>=0;r--)if(i[r].getID()===n){i[r]=t,e=!0;break}e||(i.length<=50?i.push(t):(i[this._preTouchPoolPointer]=t,this._preTouchPoolPointer=(this._preTouchPoolPointer+1)%50))},getTouchByXY:function(t,e,i){var n=this._preTouchPoint,r=this._glView.convertToLocationInView(t,e,i),s=new cc.Touch(r.x,r.y);return s._setPrevPoint(n.x,n.y),n.x=r.x,n.y=r.y,s},getMouseEvent:function(t,e,i){var n=this._prevMousePoint,r=new cc.Event.EventMouse(i);return r._setPrevCursor(n.x,n.y),n.x=t.x,n.y=t.y,this._glView._convertMouseToLocationInView(n,e),r.setLocation(n.x,n.y),r},getPointByEvent:function(t,e){return null!=t.pageX?{x:t.pageX,y:t.pageY}:(s.platform===s.WECHAT_GAME?(e.left=0,e.top=0):(e.left-=document.body.scrollLeft,e.top-=document.body.scrollTop),{x:t.clientX,y:t.clientY})},getTouchesByEvent:function(t,e){for(var i,n,r,o=[],a=this._glView,c=this._preTouchPoint,h=t.changedTouches.length,l=0;lthis._accelInterval&&(this._accelCurTime-=this._accelInterval,o.dispatchEvent(new cc.Event.EventAcceleration(this._acceleration))),this._accelCurTime+=t}};n.get(cc,"inputManager",(function(){return cc.warnID(1405,"cc.inputManager","cc.systemEvent"),c})),e.exports=c}),{"../event-manager":110,"../platform/js":197,"./CCMacro":181,"./CCSys":185}],181:[(function(t,e,i){t("./_CCClass"),cc.KEY={none:0,back:6,menu:18,backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,pause:19,capslock:20,escape:27,space:32,pageup:33,pagedown:34,end:35,home:36,left:37,up:38,right:39,down:40,select:41,insert:45,Delete:46,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,num0:96,num1:97,num2:98,num3:99,num4:100,num5:101,num6:102,num7:103,num8:104,num9:105,"*":106,"+":107,"-":109,numdel:110,"/":111,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,numlock:144,scrolllock:145,";":186,semicolon:186,equal:187,"=":187,",":188,comma:188,dash:189,".":190,period:190,forwardslash:191,grave:192,"[":219,openbracket:219,backslash:220,"]":221,closebracket:221,quote:222,dpadLeft:1e3,dpadRight:1001,dpadUp:1003,dpadDown:1004,dpadCenter:1005},cc.ImageFormat=cc.Enum({JPG:0,PNG:1,TIFF:2,WEBP:3,PVR:4,ETC:5,S3TC:6,ATITC:7,TGA:8,RAWDATA:9,UNKNOWN:10}),cc.getImageFormatByData=function(t){return t.length>8&&137===t[0]&&80===t[1]&&78===t[2]&&71===t[3]&&13===t[4]&&10===t[5]&&26===t[6]&&10===t[7]?cc.ImageFormat.PNG:t.length>2&&(73===t[0]&&73===t[1]||77===t[0]&&77===t[1]||255===t[0]&&216===t[1])?cc.ImageFormat.TIFF:cc.ImageFormat.UNKNOWN},cc.macro={INVALID_INDEX:-1,NODE_TAG_INVALID:-1,PI:Math.PI,PI2:2*Math.PI,FLT_MAX:parseFloat("3.402823466e+38F"),FLT_MIN:parseFloat("1.175494351e-38F"),RAD:Math.PI/180,DEG:180/Math.PI,UINT_MAX:4294967295,REPEAT_FOREVER:Number.MAX_VALUE-1,FLT_EPSILON:1.192092896e-7,ONE:1,ZERO:0,SRC_ALPHA:770,SRC_ALPHA_SATURATE:776,SRC_COLOR:768,DST_ALPHA:772,DST_COLOR:774,ONE_MINUS_SRC_ALPHA:771,ONE_MINUS_SRC_COLOR:769,ONE_MINUS_DST_ALPHA:773,ONE_MINUS_DST_COLOR:775,ONE_MINUS_CONSTANT_ALPHA:32772,ONE_MINUS_CONSTANT_COLOR:32770,LINEAR:9729,BLEND_DST:771,WEB_ORIENTATION_PORTRAIT:0,WEB_ORIENTATION_LANDSCAPE_LEFT:-90,WEB_ORIENTATION_PORTRAIT_UPSIDE_DOWN:180,WEB_ORIENTATION_LANDSCAPE_RIGHT:90,ORIENTATION_PORTRAIT:1,ORIENTATION_LANDSCAPE:2,ORIENTATION_AUTO:3,DENSITYDPI_DEVICE:"device-dpi",DENSITYDPI_HIGH:"high-dpi",DENSITYDPI_MEDIUM:"medium-dpi",DENSITYDPI_LOW:"low-dpi",VERTEX_ATTRIB_FLAG_NONE:0,VERTEX_ATTRIB_FLAG_POSITION:1,VERTEX_ATTRIB_FLAG_COLOR:2,VERTEX_ATTRIB_FLAG_TEX_COORDS:4,VERTEX_ATTRIB_FLAG_POS_COLOR_TEX:7,GL_ALL:0,VERTEX_ATTRIB_POSITION:0,VERTEX_ATTRIB_COLOR:1,VERTEX_ATTRIB_TEX_COORDS:2,VERTEX_ATTRIB_MAX:3,UNIFORM_PMATRIX:0,UNIFORM_MVMATRIX:1,UNIFORM_MVPMATRIX:2,UNIFORM_TIME:3,UNIFORM_SINTIME:4,UNIFORM_COSTIME:5,UNIFORM_RANDOM01:6,UNIFORM_SAMPLER:7,UNIFORM_MAX:8,SHADER_POSITION_TEXTURECOLOR:"ShaderPositionTextureColor",SHADER_SPRITE_POSITION_TEXTURECOLOR:"ShaderSpritePositionTextureColor",SHADER_POSITION_TEXTURECOLORALPHATEST:"ShaderPositionTextureColorAlphaTest",SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST:"ShaderSpritePositionTextureColorAlphaTest",SHADER_POSITION_COLOR:"ShaderPositionColor",SHADER_SPRITE_POSITION_COLOR:"ShaderSpritePositionColor",SHADER_POSITION_TEXTURE:"ShaderPositionTexture",SHADER_POSITION_TEXTURE_UCOLOR:"ShaderPositionTexture_uColor",SHADER_POSITION_TEXTUREA8COLOR:"ShaderPositionTextureA8Color",SHADER_POSITION_UCOLOR:"ShaderPosition_uColor",SHADER_POSITION_LENGTHTEXTURECOLOR:"ShaderPositionLengthTextureColor",UNIFORM_PMATRIX_S:"CC_PMatrix",UNIFORM_MVMATRIX_S:"CC_MVMatrix",UNIFORM_MVPMATRIX_S:"CC_MVPMatrix",UNIFORM_TIME_S:"CC_Time",UNIFORM_SINTIME_S:"CC_SinTime",UNIFORM_COSTIME_S:"CC_CosTime",UNIFORM_RANDOM01_S:"CC_Random01",UNIFORM_SAMPLER_S:"CC_Texture0",UNIFORM_ALPHA_TEST_VALUE_S:"CC_alpha_value",ATTRIBUTE_NAME_COLOR:"a_color",ATTRIBUTE_NAME_POSITION:"a_position",ATTRIBUTE_NAME_TEX_COORD:"a_texCoord",ITEM_SIZE:32,CURRENT_ITEM:3233828865,ZOOM_ACTION_TAG:3233828866,NORMAL_TAG:8801,SELECTED_TAG:8802,DISABLE_TAG:8803,FIX_ARTIFACTS_BY_STRECHING_TEXEL:0,FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX:1,DIRECTOR_STATS_POSITION:cc.p(0,0),DIRECTOR_FPS_INTERVAL:.5,COCOSNODE_RENDER_SUBPIXEL:1,SPRITEBATCHNODE_RENDER_SUBPIXEL:1,AUTO_PREMULTIPLIED_ALPHA_FOR_PNG:0,OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA:0,TEXTURE_NPOT_SUPPORT:0,USE_LA88_LABELS:1,SPRITE_DEBUG_DRAW:0,LABELBMFONT_DEBUG_DRAW:0,LABELATLAS_DEBUG_DRAW:0,ENABLE_STACKABLE_ACTIONS:1,ENABLE_GL_STATE_CACHE:1,TOUCH_TIMEOUT:5e3,BATCH_VERTEX_COUNT:2e4,ENABLE_GC_FOR_NATIVE_OBJECTS:!0,ENABLE_TILEDMAP_CULLING:!0,DOWNLOAD_MAX_CONCURRENT:64,ENABLE_TRANSPARENT_CANVAS:!1,ENABLE_WEBGL_ANTIALIAS:!1};var n=!0;cc.defineGetterSetter(cc.macro,"ENABLE_CULLING",(function(){return n}),(function(t){n=t;var e=cc.director.getScene();e&&(e._sgNode._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.cullingDirty),cc.renderer.childrenOrderDirty=!0)})),cc.defineGetterSetter(cc.macro,"BLEND_SRC",(function(){return cc._renderType===cc.game.RENDER_TYPE_WEBGL&&cc.macro.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA?cc.macro.ONE:cc.macro.SRC_ALPHA})),cc.lerp=function(t,e,i){return t+(e-t)*i},cc.rand=function(){return 16777215*Math.random()},cc.randomMinus1To1=function(){return 2*(Math.random()-.5)},cc.random0To1=Math.random,cc.degreesToRadians=function(t){return t*cc.macro.RAD},cc.radiansToDegrees=function(t){return t*cc.macro.DEG},cc.nodeDrawSetup=function(t){t._shaderProgram&&(t._shaderProgram.use(),t._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4())},cc.incrementGLDraws=function(t){cc.g_NumberOfDraws+=t},cc.checkGLErrorDebug=function(){if(cc._renderType===cc.game.RENDER_TYPE_WEBGL){var t=cc._renderContext.getError();t&&cc.logID(2400,t)}},e.exports=cc.macro}),{"./_CCClass":188}],182:[(function(t,e,i){function n(){this._name="",this._objFlags=0}function r(){for(var t=c.length,e=0;e=6.2;break;case n.BROWSER_TYPE_ANDROID:n.osMainVersion&&n.osMainVersion>=5&&(w=!0);break;case n.BROWSER_TYPE_CHROME:w=E>=30;break;case n.BROWSER_TYPE_UC:w=E>11;case n.BROWSER_TYPE_360:w=!1}}var I=n.capabilities={canvas:S,opengl:w,webp:A};(void 0!==a.ontouchstart||void 0!==o.ontouchstart||s.msPointerEnabled)&&(I.touches=!0),void 0!==a.onmouseup&&(I.mouse=!0),void 0!==a.onkeyup&&(I.keyboard=!0),(r.DeviceMotionEvent||r.DeviceOrientationEvent)&&(I.accelerometer=!0);var R;(function(){n.browserVersion;var t=!!(window.AudioContext||window.webkitAudioContext||window.mozAudioContext);R={ONLY_ONE:!1,WEB_AUDIO:t,DELAY_CREATE_CTX:!1},n.os===n.OS_IOS&&(R.USE_LOADER_EVENT="loadedmetadata"),n.browserType===n.BROWSER_TYPE_FIREFOX&&(R.DELAY_CREATE_CTX=!0,R.USE_LOADER_EVENT="canplay"),n.os===n.OS_ANDROID&&n.browserType===n.BROWSER_TYPE_UC&&(R.ONE_SOURCE=!0)})();try{R.WEB_AUDIO&&(R.context=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext),R.DELAY_CREATE_CTX&&setTimeout((function(){R.context=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext)}),0))}catch(t){R.WEB_AUDIO=!1,cc.logID(5201)}R.format=(function(){var t=[],e=document.createElement("audio");e.canPlayType&&(e.canPlayType('audio/ogg; codecs="vorbis"')&&t.push(".ogg"),e.canPlayType("audio/mpeg")&&t.push(".mp3"),e.canPlayType('audio/wav; codecs="1"')&&t.push(".wav"),e.canPlayType("audio/mp4")&&t.push(".mp4"),e.canPlayType("audio/x-m4a")&&t.push(".m4a"));return t})(),n.__audioSupport=R;n.garbageCollect=function(){},n.dumpRoot=function(){},n.restartVM=function(){},n.cleanScript=function(t){},n.isObjectValid=function(t){return!!t},n.dump=function(){var t="";t+="isMobile : "+this.isMobile+"\r\n",t+="language : "+this.language+"\r\n",t+="browserType : "+this.browserType+"\r\n",t+="browserVersion : "+this.browserVersion+"\r\n",t+="capabilities : "+JSON.stringify(this.capabilities)+"\r\n",t+="os : "+this.os+"\r\n",t+="osVersion : "+this.osVersion+"\r\n",t+="platform : "+this.platform+"\r\n",t+="Using "+(cc._renderType===cc.game.RENDER_TYPE_WEBGL?"WEBGL":"CANVAS")+" renderer.\r\n",cc.log(t)},n.openURL=function(t){window.open(t)},n.now=function(){return Date.now?Date.now():+new Date},e.exports=n}}),{}],186:[(function(t,e,i){var n=t("../event-manager"),r={init:function(){this.html=document.getElementsByTagName("html")[0]},availWidth:function(t){return t&&t!==this.html?t.clientWidth:window.innerWidth},availHeight:function(t){return t&&t!==this.html?t.clientHeight:window.innerHeight},meta:{width:"device-width"},adaptationType:cc.sys.browserType};switch(cc.sys.os===cc.sys.OS_IOS&&(r.adaptationType=cc.sys.BROWSER_TYPE_SAFARI),r.adaptationType){case cc.sys.BROWSER_TYPE_SAFARI:r.meta["minimal-ui"]="true",r.availWidth=function(t){return t.clientWidth},r.availHeight=function(t){return t.clientHeight};break;case cc.sys.BROWSER_TYPE_CHROME:r.__defineGetter__("target-densitydpi",(function(){return cc.view._targetDensityDPI}));break;case cc.sys.BROWSER_TYPE_SOUGOU:case cc.sys.BROWSER_TYPE_UC:r.availWidth=function(t){return t.clientWidth},r.availHeight=function(t){return t.clientHeight};break;case cc.sys.BROWSER_TYPE_MIUI:r.init=function(t){if(!t.__resizeWithBrowserSize){var e=function(){t.setDesignResolutionSize(t._designResolutionSize.width,t._designResolutionSize.height,t._resolutionPolicy),window.removeEventListener("resize",e,!1)};window.addEventListener("resize",e,!1)}};break;case cc.sys.BROWSER_TYPE_WECHAT_GAME:r.availWidth=function(){return window.innerWidth},r.availHeight=function(){return window.innerHeight};break;case cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB:var s=wx.getSharedCanvas();r.availWidth=function(){return s.width},r.availHeight=function(){return s.height}}var o=null,a=cc._Class.extend({ctor:function(){var t=cc.ContainerStrategy,e=cc.ContentStrategy;r.init(this),this._frameSize=cc.size(0,0),this._initFrameSize();var i=cc.game.canvas.width,n=cc.game.canvas.height;this._designResolutionSize=cc.size(i,n),this._originalDesignResolutionSize=cc.size(i,n),this._viewPortRect=cc.rect(0,0,i,n),this._visibleRect=cc.rect(0,0,i,n),this._contentTranslateLeftTop={left:0,top:0},this._autoFullScreen=!1,this._devicePixelRatio=1,this._viewName="Cocos2dHTML5",this._resizeCallback=null,this._orientationChanging=!0,this._resizing=!1,this._scaleX=1,this._originalScaleX=1,this._scaleY=1,this._originalScaleY=1,this._isRotated=!1,this._orientation=3;var s=cc.sys;this.enableRetina(s.os===s.OS_IOS||s.os===s.OS_OSX),cc.visibleRect&&cc.visibleRect.init(this._visibleRect),this._resolutionPolicy=null,this._rpExactFit=new cc.ResolutionPolicy(t.EQUAL_TO_FRAME,e.EXACT_FIT),this._rpShowAll=new cc.ResolutionPolicy(t.PROPORTION_TO_FRAME,e.SHOW_ALL),this._rpNoBorder=new cc.ResolutionPolicy(t.EQUAL_TO_FRAME,e.NO_BORDER),this._rpFixedHeight=new cc.ResolutionPolicy(t.EQUAL_TO_FRAME,e.FIXED_HEIGHT),this._rpFixedWidth=new cc.ResolutionPolicy(t.EQUAL_TO_FRAME,e.FIXED_WIDTH),this._initialized=!1,this._contentTranslateLeftTop=null,this._frameZoomFactor=1,this.__resizeWithBrowserSize=!1,this._isAdjustViewPort=!0,this._targetDensityDPI=cc.macro.DENSITYDPI_HIGH,this.enableAntiAlias(!0)},_resizeEvent:function(){var t,e=(t=this.setDesignResolutionSize?this:cc.view)._frameSize.width,i=t._frameSize.height,r=t._isRotated;if(cc.sys.isMobile){var s=cc.game.container.style,o=s.margin;s.margin="0",s.display="none",t._initFrameSize(),s.margin=o,s.display="block"}else t._initFrameSize();if(t._isRotated!==r||t._frameSize.width!==e||t._frameSize.height!==i){var a=t._originalDesignResolutionSize.width,c=t._originalDesignResolutionSize.height;t._resizing=!0,a>0&&t.setDesignResolutionSize(a,c,t._resolutionPolicy),t._resizing=!1,n.dispatchCustomEvent("canvas-resize"),t._resizeCallback&&t._resizeCallback.call()}},_orientationChange:function(){cc.view._orientationChanging=!0,cc.view._resizeEvent()},setTargetDensityDPI:function(t){this._targetDensityDPI=t,this._adjustViewportMeta()},getTargetDensityDPI:function(){return this._targetDensityDPI},resizeWithBrowserSize:function(t){t?this.__resizeWithBrowserSize||(this.__resizeWithBrowserSize=!0,window.addEventListener("resize",this._resizeEvent),window.addEventListener("orientationchange",this._orientationChange)):this.__resizeWithBrowserSize&&(this.__resizeWithBrowserSize=!1,window.removeEventListener("resize",this._resizeEvent),window.removeEventListener("orientationchange",this._orientationChange))},setResizeCallback:function(t){"function"!=typeof t&&null!=t||(this._resizeCallback=t)},setOrientation:function(t){if((t&=cc.macro.ORIENTATION_AUTO)&&this._orientation!==t){this._orientation=t;var e=this._originalDesignResolutionSize.width,i=this._originalDesignResolutionSize.height;this.setDesignResolutionSize(e,i,this._resolutionPolicy)}},_initFrameSize:function(){var t=this._frameSize,e=r.availWidth(cc.game.frame),i=r.availHeight(cc.game.frame),n=e>=i;!cc.sys.isMobile||n&&this._orientation&cc.macro.ORIENTATION_LANDSCAPE||!n&&this._orientation&cc.macro.ORIENTATION_PORTRAIT?(t.width=e,t.height=i,cc.container.style["-webkit-transform"]="rotate(0deg)",cc.container.style.transform="rotate(0deg)",this._isRotated=!1):(t.width=i,t.height=e,cc.container.style["-webkit-transform"]="rotate(90deg)",cc.container.style.transform="rotate(90deg)",cc.container.style["-webkit-transform-origin"]="0px 0px 0px",cc.container.style.transformOrigin="0px 0px 0px",this._isRotated=!0),this._orientationChanging&&setTimeout((function(){cc.view._orientationChanging=!1}),1e3)},_adjustSizeKeepCanvasSize:function(){var t=this._originalDesignResolutionSize.width,e=this._originalDesignResolutionSize.height;t>0&&this.setDesignResolutionSize(t,e,this._resolutionPolicy)},_setViewportMeta:function(t,e){var i=document.getElementById("cocosMetaElement");i&&e&&document.head.removeChild(i);var n,r,s,o=document.getElementsByName("viewport"),a=o?o[0]:null;n=a?a.content:"",(i=i||document.createElement("meta")).id="cocosMetaElement",i.name="viewport",i.content="";for(r in t)-1==n.indexOf(r)?n+=","+r+"="+t[r]:e&&(s=new RegExp(r+"s*=s*[^,]+"),n.replace(s,r+"="+t[r]));/^,/.test(n)&&(n=n.substr(1)),i.content=n,a&&(a.content=n),document.head.appendChild(i)},_adjustViewportMeta:function(){this._isAdjustViewPort&&(this._setViewportMeta(r.meta,!1),this._isAdjustViewPort=!1)},_resetScale:function(){this._scaleX=this._originalScaleX,this._scaleY=this._originalScaleY},_adjustSizeToBrowser:function(){},initialize:function(){this._initialized=!0},adjustViewPort:function(t){this._isAdjustViewPort=t},enableRetina:function(t){this._retinaEnabled=!!t},isRetinaEnabled:function(){return this._retinaEnabled},enableAntiAlias:function(t){if(this._antiAliasEnabled!==t)if(this._antiAliasEnabled=t,cc._renderType===cc.game.RENDER_TYPE_WEBGL){var e=cc.loader._cache;for(var i in e){var n=e[i],r=n&&n.content instanceof cc.Texture2D?n.content:null;r&&(t?r.setAntiAliasTexParameters():r.setAliasTexParameters())}}else if(cc._renderType===cc.game.RENDER_TYPE_CANVAS){var s=cc._canvas.getContext("2d");s.imageSmoothingEnabled=t,s.mozImageSmoothingEnabled=t;var o=cc.rendererCanvas._dirtyRegion;if(o){var a=new cc.Region;a.setTo(0,0,cc.visibleRect.width,cc.visibleRect.height),o.addRegion(a)}}},isAntiAliasEnabled:function(){return this._antiAliasEnabled},enableAutoFullScreen:function(t){t&&t!==this._autoFullScreen&&cc.sys.isMobile&&cc.sys.browserType!==cc.sys.BROWSER_TYPE_WECHAT?(this._autoFullScreen=!0,cc.screen.autoFullScreen(cc.game.frame)):this._autoFullScreen=!1},isAutoFullScreenEnabled:function(){return this._autoFullScreen},isViewReady:function(){return cc.game.canvas&&cc._renderContext},setFrameZoomFactor:function(t){this._frameZoomFactor=t,cc.director.setProjection(cc.director.getProjection())},setContentTranslateLeftTop:function(t,e){this._contentTranslateLeftTop={left:t,top:e}},getContentTranslateLeftTop:function(){return this._contentTranslateLeftTop},setCanvasSize:function(t,e){var i=cc.game.canvas,n=cc.game.container;i.width=t*this._devicePixelRatio,i.height=e*this._devicePixelRatio,i.style.width=t+"px",i.style.height=e+"px",n.style.width=t+"px",n.style.height=e+"px",this._resizeEvent()},getCanvasSize:function(){return cc.size(cc.game.canvas.width,cc.game.canvas.height)},getFrameSize:function(){return cc.size(this._frameSize.width,this._frameSize.height)},setFrameSize:function(t,e){this._frameSize.width=t,this._frameSize.height=e,cc.game.frame.style.width=t+"px",cc.game.frame.style.height=e+"px",this._resizeEvent(),cc.director.setProjection(cc.director.getProjection())},getVisibleSize:function(){return cc.size(this._visibleRect.width,this._visibleRect.height)},getVisibleSizeInPixel:function(){return cc.size(this._visibleRect.width*this._scaleX,this._visibleRect.height*this._scaleY)},getVisibleOrigin:function(){return cc.p(this._visibleRect.x,this._visibleRect.y)},getVisibleOriginInPixel:function(){return cc.p(this._visibleRect.x*this._scaleX,this._visibleRect.y*this._scaleY)},canSetContentScaleFactor:function(){return!0},getResolutionPolicy:function(){return this._resolutionPolicy},setResolutionPolicy:function(t){if(t instanceof cc.ResolutionPolicy)this._resolutionPolicy=t;else{var e=cc.ResolutionPolicy;t===e.EXACT_FIT&&(this._resolutionPolicy=this._rpExactFit),t===e.SHOW_ALL&&(this._resolutionPolicy=this._rpShowAll),t===e.NO_BORDER&&(this._resolutionPolicy=this._rpNoBorder),t===e.FIXED_HEIGHT&&(this._resolutionPolicy=this._rpFixedHeight),t===e.FIXED_WIDTH&&(this._resolutionPolicy=this._rpFixedWidth)}},setDesignResolutionSize:function(t,e,i){if(t>0||e>0){this.setResolutionPolicy(i);var n=this._resolutionPolicy;if(n&&n.preApply(this),cc.sys.isMobile&&this._adjustViewportMeta(),this._orientationChanging=!0,this._resizing||this._initFrameSize(),n){this._originalDesignResolutionSize.width=this._designResolutionSize.width=t,this._originalDesignResolutionSize.height=this._designResolutionSize.height=e;var r=n.apply(this,this._designResolutionSize);if(r.scale&&2===r.scale.length&&(this._scaleX=r.scale[0],this._scaleY=r.scale[1]),r.viewport){var s=this._viewPortRect,o=this._visibleRect,a=r.viewport;s.x=a.x,s.y=a.y,s.width=a.width,s.height=a.height,o.x=-s.x/this._scaleX,o.y=-s.y/this._scaleY,o.width=cc.game.canvas.width/this._scaleX,o.height=cc.game.canvas.height/this._scaleY,cc._renderContext.setOffset&&cc._renderContext.setOffset(s.x,-s.y)}var c=cc.director;c._winSizeInPoints.width=this._designResolutionSize.width,c._winSizeInPoints.height=this._designResolutionSize.height,n.postApply(this),cc.winSize.width=c._winSizeInPoints.width,cc.winSize.height=c._winSizeInPoints.height,cc._renderType===cc.game.RENDER_TYPE_WEBGL?c.setGLDefaultValues():cc._renderType===cc.game.RENDER_TYPE_CANVAS&&(cc.renderer._allNeedDraw=!0),this._originalScaleX=this._scaleX,this._originalScaleY=this._scaleY,cc.visibleRect&&cc.visibleRect.init(this._visibleRect)}else cc.logID(2201)}else cc.logID(2200)},getDesignResolutionSize:function(){return cc.size(this._designResolutionSize.width,this._designResolutionSize.height)},setRealPixelResolution:function(t,e,i){this._setViewportMeta({width:t},!0),document.documentElement.style.width=t+"px",document.body.style.width=t+"px",document.body.style.left="0px",document.body.style.top="0px",this.setDesignResolutionSize(t,e,i)},setViewPortInPoints:function(t,e,i,n){var r=this._frameZoomFactor,s=this._scaleX,o=this._scaleY;cc._renderContext.viewport(t*s*r+this._viewPortRect.x*r,e*o*r+this._viewPortRect.y*r,i*s*r,n*o*r)},setScissorInPoints:function(t,e,i,n){var r=this._frameZoomFactor,s=this._scaleX,a=this._scaleY,c=Math.ceil(t*s*r+this._viewPortRect.x*r),h=Math.ceil(e*a*r+this._viewPortRect.y*r),l=Math.ceil(i*s*r),u=Math.ceil(n*a*r);if(!o){var _=gl.getParameter(gl.SCISSOR_BOX);o=cc.rect(_[0],_[1],_[2],_[3])}o.x===c&&o.y===h&&o.width===l&&o.height===u||(o.x=c,o.y=h,o.width=l,o.height=u,cc._renderContext.scissor(c,h,l,u))},isScissorEnabled:function(){return cc._renderContext.isEnabled(gl.SCISSOR_TEST)},getScissorRect:function(){if(!o){var t=gl.getParameter(gl.SCISSOR_BOX);o=cc.rect(t[0],t[1],t[2],t[3])}var e=1/this._scaleX,i=1/this._scaleY;return cc.rect((o.x-this._viewPortRect.x)*e,(o.y-this._viewPortRect.y)*i,o.width*e,o.height*i)},setViewName:function(t){null!=t&&t.length>0&&(this._viewName=t)},getViewName:function(){return this._viewName},getViewPortRect:function(){return this._viewPortRect},getScaleX:function(){return this._scaleX},getScaleY:function(){return this._scaleY},getDevicePixelRatio:function(){return this._devicePixelRatio},convertToLocationInView:function(t,e,i){var n=this._devicePixelRatio*(t-i.left),r=this._devicePixelRatio*(i.top+i.height-e);return this._isRotated?{x:this._viewPortRect.width-r,y:n}:{x:n,y:r}},_convertMouseToLocationInView:function(t,e){var i=this._viewPortRect;t.x=(this._devicePixelRatio*(t.x-e.left)-i.x)/this._scaleX,t.y=(this._devicePixelRatio*(e.top+e.height-t.y)-i.y)/this._scaleY},_convertPointWithScale:function(t){var e=this._viewPortRect;t.x=(t.x-e.x)/this._scaleX,t.y=(t.y-e.y)/this._scaleY},_convertTouchesWithScale:function(t){for(var e,i,n,r=this._viewPortRect,s=this._scaleX,o=this._scaleY,a=0;a=0;r--){var s=i[r];s.hasOwnProperty("__attrs__")&&s.__attrs__||n(s,0,(e=i[r+1])&&e.__attrs__)}return e=i[0],n(t,0,e&&e.__attrs__),t.__attrs__})(t)}function o(t){return s(t).constructor.prototype}function a(t,e){0}var c=t("./js"),h=(t("./utils").isPlainEmptyObj_DEV,"$_$");cc.Integer="Integer",cc.Float="Float",cc.Boolean="Boolean",cc.String="String",e.exports={attr:r,getClassAttrs:s,getClassAttrsProto:o,setClassAttr:function(t,e,i,n){o(t)[e+h+i]=n},DELIMETER:h,getTypeChecker:a,ObjectType:function(t){return{type:"Object",ctor:t,_onAfterProp:!1}},ScriptUuid:{}}}),{"./CCClass":176,"./js":197,"./utils":201}],190:[(function(t,e,i){function n(){this.callbacks=[],this.targets=[],this.isInvoking=!1,this.containCanceled=!1}function r(){this._callbackTable=s.createMap(!0)}var s=t("./js"),o=s.array.fastRemoveAt,a=n.prototype;a.removeBy=function(t,e){for(var i=this.callbacks,n=this.targets,r=0;r0?this.deserializedList[0]:[]}else this.deserializedList.length=1,this.deserializedData=t?this._deserializeObject(t):null,this.deserializedList[0]=this.deserializedData;return (function(t){var e,i,n,r=t.deserializedList,s=t._idPropList,o=t._idList,a=t._idObjList;for(t._classFinder&&t._classFinder.onDereferenced,e=0;e0&&(i=C+this.globalVariables.join(",")+";");var n=m.flattenCodeArray(["return (function(R){",i||[],this.codeArray,"return o;","})"]);this.result=Function("O","F",n)(this.objs,this.funcs);for(var r=0,s=this.objsToClear_iN$t.length;r1)t.push(b+"="+this._targetExp+";"),e=b;else{if(1!==this._exps.length)return;e=this._targetExp}for(var i=0;i=0&&(s(t,i),!0)}function a(t,e){"number"==typeof t&&(e=t,t=null),this.get=null,this.count=0,this._pool=new Array(e),this._cleanup=t}var c=new(t("./id-generater"))("TmpCId."),h={isNumber:function(t){return"number"==typeof t||t instanceof Number},isString:function(t){return"string"==typeof t||t instanceof String},addon:function(t){"use strict";t=t||{};for(var e=1,i=arguments.length;e=0&&(t[i]=t[t.length-1],--t.length)},removeAt:s,fastRemoveAt:function(t,e){var i=t.length;e<0||e>=i||(t[e]=t[i-1],t.length=i-1)},contains:function(t,e){return t.indexOf(e)>=0},verifyType:function(t,e){if(t&&t.length>0)for(var i=0;i0){--this.count;var t=this._pool[this.count];return this._pool[this.count]=null,t}return null},a.prototype.put=function(t){var e=this._pool;if(this.count=0&&(this._pool.length=t,this.count>t&&(this.count=t))},h.Pool=a,cc.js=h,e.exports=h}),{"../utils/mutable-forward-iterator":227,"./id-generater":193}],198:[(function(t,e,i){function n(t,e,i,n){if(!t.get&&!t.set)if(t.hasOwnProperty("default")){var r="_N$"+e;t.get=function(){return this[r]},t.set=function(t){var e=this[r];this[r]=t,i.call(this,e)};var s={};n[r]=s;for(var o in a){var c=a[o];t.hasOwnProperty(o)&&(s[o]=t[o],c.canUsedInGet||delete t[o])}}else 0}function r(t,e,i,n){Array.isArray(n)&&n.length>0&&(n=n[0]),t.type=n}function s(t,e,i,n){if(Array.isArray(e)){if(!(e.length>0))return cc.errorID(5508,i,n);if(cc.RawAsset.isRawAssetType(e[0]))return t.url=e[0],void delete t.type;t.type=e=e[0]}}function o(t,e,i,n){0}var a={url:{canUsedInGet:!0},default:{},serializable:{},editorOnly:{},rawType:{},formerlySerializedAs:{}};i.getFullFormOfProperty=function(t){if(!(t&&t.constructor===Object)){if(Array.isArray(t)&&t.length>0)return{default:[],type:t,_short:!0};if("function"==typeof t){var e=t;return cc.RawAsset.isRawAssetType(e)?{default:"",url:e,_short:!0}:{default:cc.isChildClassOf(e,cc.ValueType)?new e:null,type:e,_short:!0}}return{default:t,_short:!0}}return null},i.preprocessAttrs=function(t,e,a,c){for(var h in t){var l=t[h],u=i.getFullFormOfProperty(l);if(u&&(l=t[h]=u),l){var _=l.notify;_&&n(l,h,_,t),"type"in l&&s(l,l.type,e,h),"url"in l&&r(l,0,0,l.url),"type"in l&&o(0,l.type)}}},i.validateMethodWithProps=function(t,e,i,n,r){if("function"!=typeof t&&null!==t){return!1}return!0}}),{"./CCClass":176}],199:[(function(t,e,i){var n=[];cc._RF={push:function(t,e,i){void 0===i&&(i=e,e=""),n.push({uuid:e,script:i,module:t,exports:t.exports,beh:null})},pop:function(){var t=n.pop(),e=t.module,i=e.exports;if(i===t.exports){for(var r in i)return;e.exports=i=t.cls}},peek:function(){return n[n.length-1]}}}),{}],200:[(function(t,e,i){var n={};cc.url={_rawAssets:"",_builtinRawAssets:"",normalize:function(t){return 46===t.charCodeAt(0)&&47===t.charCodeAt(1)?t=t.slice(2):47===t.charCodeAt(0)&&(t=t.slice(1)),t},raw:function(t){return(t=this.normalize(t)).startsWith("resources/")||cc.errorID(7002,t),this._rawAssets+t},builtinRaw:!1,_init:function(t){for(var e in t){var i=t[e];i=cc.path.stripSep(i)+"/",n[e]=i}this._rawAssets=n.assets,this._builtinRawAssets=n.internal}},e.exports=cc.url}),{}],201:[(function(t,e,i){e.exports={contains:function(t,e){if("function"==typeof t.contains)return t.contains(e);if("function"==typeof t.compareDocumentPosition)return!!(16&t.compareDocumentPosition(e));var i=e.parentNode;if(i)do{if(i===t)return!0;i=i.parentNode}while(null!==i);return!1},isDomNode:"object"==typeof window&&("function"==typeof Node?function(t){return t instanceof Node}:function(t){return t&&"object"==typeof t&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName}),callInNextTick:function(t,e,i){t&&setTimeout((function(){t(e,i)}),0)}}}),{}],202:[(function(t,e,i){t("./platform/js"),t("./value-types"),t("./utils"),t("./platform/CCInputManager"),t("./platform/CCInputExtension"),t("./event"),t("./platform/CCSys"),t("./platform/CCMacro"),t("./load-pipeline"),t("./textures"),t("./CCDirector"),t("./CCDirectorWebGL"),t("./CCDirectorCanvas"),t("./platform/CCSAXParser"),t("./platform/CCView"),t("./platform/CCScreen"),t("./CCScheduler"),t("./event-manager"),t("./renderer")}),{"./CCDirector":33,"./CCDirectorCanvas":34,"./CCDirectorWebGL":35,"./CCScheduler":42,"./event":114,"./event-manager":110,"./load-pipeline":136,"./platform/CCInputExtension":179,"./platform/CCInputManager":180,"./platform/CCMacro":181,"./platform/CCSAXParser":183,"./platform/CCScreen":184,"./platform/CCSys":185,"./platform/CCView":186,"./platform/js":197,"./renderer":206,"./textures":218,"./utils":225,"./value-types":239}],203:[(function(t,e,i){function n(){var t=c.pop();return t||(t=new o),t}function r(t){c.push(t)}function s(t,e){var i=t._minXe._maxX?t._maxX:e._maxX)-i)*((t._maxY>e._maxY?t._maxY:e._maxY)-n)}var o=function(){this._minX=0,this._minY=0,this._maxX=0,this._maxY=0,this._width=0,this._height=0,this._area=0},a=o.prototype,c=[];a.setTo=function(t,e,i,n){return this._minX=t,this._minY=e,this._maxX=i,this._maxY=n,this.updateArea(),this},a.intValues=function(){this._minX=Math.floor(this._minX),this._minY=Math.floor(this._minY),this._maxX=Math.ceil(this._maxX),this._maxY=Math.ceil(this._maxY),this.updateArea()},a.updateArea=function(){this._width=this._maxX-this._minX,this._height=this._maxY-this._minY,this._area=this._width*this._height},a.union=function(t){this.isEmpty()?this.setTo(t._minX,t._minY,t._maxX,t._maxY):(this._minX>t._minX&&(this._minX=t._minX),this._minY>t._minY&&(this._minY=t._minY),this._maxXt._minX?this._minX:t._minX,i=this._maxXi)&&(e=this._minY>t._minY?this._minY:t._minY,i=this._maxYv&&(S=g,g=v,v=S),C>b&&(S=C,C=b,b=S),i=(gb?v:b)+1,y>x&&(S=y,y=x,x=S),T>A&&(S=T,T=A,A=S),n=(yA?x:A)+1}this._minX=i,this._minY=n,this._maxX=r,this._maxY=s,this._width=r-i,this._height=s-n,this._area=this._width*this._height}else this.setEmpty()};var h=function(){this.dirtyList=[],this.hasClipRect=!1,this.clipWidth=0,this.clipHeight=0,this.clipArea=0,this.clipRectChanged=!1},l=h.prototype;l.setClipRect=function(t,e){this.hasClipRect=!0,this.clipRectChanged=!0,this.clipWidth=Math.ceil(t),this.clipHeight=Math.ceil(e),this.clipArea=this.clipWidth*this.clipHeight},l.addRegion=function(t){var e=t._minX,i=t._minY,r=t._maxX,s=t._maxY;if(this.hasClipRect&&(e<0&&(e=0),i<0&&(i=0),r>this.clipWidth&&(r=this.clipWidth),s>this.clipHeight&&(s=this.clipHeight)),e>=r||i>=s)return!1;if(this.clipRectChanged)return!0;var o=this.dirtyList,a=n();return o.push(a.setTo(e,i,r,s)),this.mergeDirtyList(o),!0},l.clear=function(){for(var t=this.dirtyList,e=t.length,i=0;i0)for(var r=0;r3?Number.POSITIVE_INFINITY:0,o=0,a=0,c=0,h=0;hd&&(o=h,a=u,n=d)}}if(i&&c/this.clipArea>.95&&(this.clipRectChanged=!0),o!==a){var f=t[a];return t[o].union(f),r(f),t.splice(a,1),!0}return!1},cc.Region=o,cc.DirtyRegion=h}),{}],204:[(function(t,e,i){cc.rendererCanvas={childrenOrderDirty:!0,assignedZ:0,assignedZStep:1e-4,_transformNodePool:[],_renderCmds:[],_isCacheToCanvasOn:!1,_cacheToCanvasCmds:{},_cacheInstanceIds:[],_currentID:0,_clearColor:cc.color(),_clearFillStyle:"rgb(0, 0, 0)",_dirtyRegion:null,_allNeedDraw:!0,_enableDirtyRegion:!1,_debugDirtyRegion:!1,_dirtyRegionCountThreshold:10,init:function(){cc.sys.browserType!==cc.sys.BROWSER_TYPE_IE&&cc.sys.browserType!==cc.sys.BROWSER_TYPE_UC||this.enableDirtyRegion(!1)},getRenderCmd:function(t){return t._createRenderCmd()},enableDirtyRegion:function(t){this._enableDirtyRegion=t},isDirtyRegionEnabled:function(){return this._enableDirtyRegion},setDirtyRegionCountThreshold:function(t){this._dirtyRegionCountThreshold=t},_collectDirtyRegion:function(){var t,e,i=this._renderCmds,n=this._dirtyRegion,r=_ccsg.Node.CanvasRenderCmd.RegionStatus,s=0,o=!0;for(t=0,e=i.length;tr.NotDirty&&(++s>this._dirtyRegionCountThreshold&&(o=!1),o&&(!l.isEmpty()&&n.addRegion(l),a._regionFlag>r.Dirty&&!h.isEmpty()&&n.addRegion(h)),a._regionFlag=r.NotDirty)}return o},_beginDrawDirtyRegion:function(t){var e=t.getContext(),i=this._dirtyRegion.getDirtyRegions();e.save(),t.setTransform({a:1,b:0,c:0,d:1,tx:0,ty:0},1,1),e.beginPath();for(var n=0,r=0,s=0,o=0,a=t._scaleX,c=t._scaleY,h=0,l=i.length;h0},_sortNodeByLevelAsc:function(t,e){return t._curLevel-e._curLevel},pushDirtyNode:function(t){this._transformNodePool.push(t)},clear:function(){},clearRenderCommands:function(){this._renderCmds.length=0,this._cacheInstanceIds.length=0,this._isCacheToCanvasOn=!1,this._allNeedDraw=!0},pushRenderCommand:function(t){if(t.rendering)if(this._isCacheToCanvasOn){var e=this._currentID,i=this._cacheToCanvasCmds[e];-1===i.indexOf(t)&&i.push(t)}else-1===this._renderCmds.indexOf(t)&&this._renderCmds.push(t)}},(function(){cc.CanvasContextWrapper=function(t){this._context=t,this._saveCount=0,this._currentAlpha=t.globalAlpha,this._currentCompositeOperation=t.globalCompositeOperation,this._currentFillStyle=t.fillStyle,this._currentStrokeStyle=t.strokeStyle,this._offsetX=0,this._offsetY=0,this._realOffsetY=this.height,this._armatureMode=0};var t=cc.CanvasContextWrapper.prototype;t.resetCache=function(){var t=this._context;this._currentAlpha=t.globalAlpha,this._currentCompositeOperation=t.globalCompositeOperation,this._currentFillStyle=t.fillStyle,this._currentStrokeStyle=t.strokeStyle,this._realOffsetY=this._context.canvas.height+this._offsetY},t.setOffset=function(t,e){this._offsetX=t,this._offsetY=e,this._realOffsetY=this._context.canvas.height+this._offsetY},t.computeRealOffsetY=function(){this._realOffsetY=this._context.canvas.height+this._offsetY},t.setViewScale=function(t,e){this._scaleX=t,this._scaleY=e},t.getContext=function(){return this._context},t.save=function(){this._context.save(),this._saveCount++},t.restore=function(){this._context.restore(),this._currentAlpha=this._context.globalAlpha,this._saveCount--},t.setGlobalAlpha=function(t){this._saveCount>0?this._context.globalAlpha=t:this._currentAlpha!==t&&(this._currentAlpha=t,this._context.globalAlpha=t)},t.setCompositeOperation=function(t){this._saveCount>0?this._context.globalCompositeOperation=t:this._currentCompositeOperation!==t&&(this._currentCompositeOperation=t,this._context.globalCompositeOperation=t)},t.setFillStyle=function(t){this._context.fillStyle=t},t.setStrokeStyle=function(t){this._saveCount>0?this._context.strokeStyle=t:this._currentStrokeStyle!==t&&(this._currentStrokeStyle=t,this._context.strokeStyle=t)},t.setTransform=function(t,e,i){this._armatureMode>0?(this.restore(),this.save(),this._context.transform(t.a,-t.b,-t.c,t.d,t.tx*e,-t.ty*i)):this._context.setTransform(t.a*e,-t.b*i,-t.c*e,t.d*i,this._offsetX+t.tx*e,this._realOffsetY-t.ty*i)},t._switchToArmatureMode=function(t,e,i,n){t?(this._armatureMode++,this._context.setTransform(e.a,e.c,e.b,e.d,this._offsetX+e.tx*i,this._realOffsetY-e.ty*n),this.save()):(this._armatureMode--,this.restore())}})()}),{}],205:[(function(t,e,i){function n(t){var e=cc._renderContext;null===o&&(a=e.createBuffer(),o=e.createBuffer()),(function(t){var e=cc._renderContext;if(o){var i=6*Math.ceil(t/4);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o),p=new Uint16Array(i);for(var n=0,r=0,s=i;r0},_sortNodeByLevelAsc:function(t,e){return t._curLevel-e._curLevel},pushDirtyNode:function(t){this._transformNodePool.push(t)},clearRenderCommands:function(){this._renderCmds.length=0},clear:function(){var t=cc._renderContext;t.clearColor(this._clearColor.r,this._clearColor.g,this._clearColor.b,this._clearColor.a),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)},setDepthTest:function(t){var e=cc._renderContext;t?(e.clearDepth(1),e.enable(e.DEPTH_TEST),e.depthFunc(e.LEQUAL)):e.disable(e.DEPTH_TEST)},pushRenderCommand:function(t){if(t.rendering||t.uploadData)if(this._isCacheToBufferOn){var e=this._currentID,i=this._cacheToBufferCmds[e];-1===i.indexOf(t)&&i.push(t)}else this._renderCmds.push(t)},_increaseBatchingSize:function(t,e,i){var n,r;switch(e=e||y.QUAD){case y.QUAD:for(n=0;n=c&&this._batchRendering();var e=t._node,i=t._texture||e._texture||e._spriteFrame&&e._spriteFrame._texture,n=e._blendFunc.src,o=e._blendFunc.dst,a=t._shaderProgram;(s||r.texture!==i||r.blendSrc!==n||r.blendDst!==o||r.shader!==a)&&(this._batchRendering(),r.texture=i,r.blendSrc=n,r.blendDst=o,r.shader=a,s=!1);var _=t.uploadData(d,f,h*u);if(_>0){var m,v;switch(t.vertexType||y.QUAD){case y.QUAD:for(m=0;m<_;m+=4)v=h+m,p[l++]=v+0,p[l++]=v+1,p[l++]=v+2,p[l++]=v+1,p[l++]=v+2,p[l++]=v+3;break;case y.TRIANGLE:for(g=!1,m=0;m<_;m+=3)v=h+m,p[l++]=v+0,p[l++]=v+1,p[l++]=v+2;break;case y.CUSTOM:g=!1,t.uploadIndexData&&(l+=t.uploadIndexData(p,l,h));break;default:return}h+=_}},_batchRendering:function(){if(0!==h&&r.texture){var t=cc._renderContext,e=r.texture,i=r.shader,n=h>.5*c;if(i&&(i.use(),i._updateProjectionUniform()),cc.gl.blendFunc(r.blendSrc,r.blendDst),cc.gl.bindTexture2DN(0,e),t.bindBuffer(t.ARRAY_BUFFER,a),n)t.bufferData(t.ARRAY_BUFFER,d,t.DYNAMIC_DRAW);else{var s=d.subarray(0,h*u);t.bufferData(t.ARRAY_BUFFER,s,t.DYNAMIC_DRAW)}t.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_POSITION),t.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_COLOR),t.enableVertexAttribArray(cc.macro.VERTEX_ATTRIB_TEX_COORDS),t.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_POSITION,3,t.FLOAT,!1,24,0),t.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_COLOR,4,t.UNSIGNED_BYTE,!0,24,12),t.vertexAttribPointer(cc.macro.VERTEX_ATTRIB_TEX_COORDS,2,t.FLOAT,!1,24,16),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,o),(!m||!g||l>m)&&(n?t.bufferData(t.ELEMENT_ARRAY_BUFFER,p,t.DYNAMIC_DRAW):t.bufferData(t.ELEMENT_ARRAY_BUFFER,p.subarray(0,l),t.DYNAMIC_DRAW)),t.drawElements(t.TRIANGLES,l,t.UNSIGNED_SHORT,0),cc.g_NumberOfDraws++,g?m=l:(m=0,g=!0),h=0,l=0}},rendering:function(t,e){var i,n,s,o=e||this._renderCmds,a=t||cc._renderContext;for(a.bindBuffer(a.ARRAY_BUFFER,null),cc.gl.bindTexture2DN(0,null),i=0,n=o.length;i0&&this._batchRendering(),s.rendering(a)));this._batchRendering(),r.texture=null}}}),{}],206:[(function(t,e,i){t("./RendererCanvas"),t("./RendererWebGL"),t("./DirtyRegion")}),{"./DirtyRegion":203,"./RendererCanvas":204,"./RendererWebGL":205}],207:[(function(t,e,i){_ccsg.Scene=_ccsg.Node.extend({_className:"Scene",ctor:function(){_ccsg.Node.prototype.ctor.call(this),this._ignoreAnchorPointForPosition=!0,this.setAnchorPoint(.5,.5),this.setContentSize(cc.director.getWinSize())}})}),{}],208:[(function(t,e,i){var n=t("../event/event-target"),r=t("../utils/misc");_ccsg.Sprite=_ccsg.Node.extend({dirty:!1,_recursiveDirty:null,_shouldBeHidden:!1,_transformToBatch:null,_blendFunc:null,_texture:null,_rect:null,_rectRotated:!1,_offsetPosition:null,_unflippedOffsetPositionFromCenter:null,_opacityModifyRGB:!1,_flippedX:!1,_flippedY:!1,_textureLoaded:!1,_className:"Sprite",ctor:function(t,e,i){_ccsg.Node.prototype.ctor.call(this),n.call(this),this._shouldBeHidden=!1,this._offsetPosition=cc.p(0,0),this._unflippedOffsetPositionFromCenter=cc.p(0,0),this._blendFunc={src:cc.macro.BLEND_SRC,dst:cc.macro.BLEND_DST},this._rect=cc.rect(0,0,0,0),this._softInit(t,e,i)},textureLoaded:function(){return this._textureLoaded},addLoadedEventListener:function(t,e){this.once("load",t,e)},isDirty:function(){return this.dirty},setDirty:function(t){this.dirty=t},isTextureRectRotated:function(){return this._rectRotated},getTextureRect:function(){return cc.rect(this._rect)},getOffsetPosition:function(){return cc.p(this._offsetPosition)},_getOffsetX:function(){return this._offsetPosition.x},_getOffsetY:function(){return this._offsetPosition.y},getBlendFunc:function(){return this._blendFunc},initWithSpriteFrame:function(t){cc.assertID(t,2606),t.textureLoaded()||(this._textureLoaded=!1,t.once("load",this._renderCmd._spriteFrameLoadedCallback,this._renderCmd));var e=cc._renderType!==cc.game.RENDER_TYPE_CANVAS&&t._rotated,i=this.initWithTexture(t.getTexture(),t.getRect(),e);return this.setSpriteFrame(t),i},initWithSpriteFrameName:function(){cc.warnID(2608)},setVertexRect:function(t){var e=this._rect;e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height},setFlippedX:function(t){this._flippedX!==t&&(this._flippedX=t,this.setTextureRect(this._rect,this._rectRotated,this._contentSize),this.setNodeDirty(!0))},setFlippedY:function(t){this._flippedY!==t&&(this._flippedY=t,this.setTextureRect(this._rect,this._rectRotated,this._contentSize),this.setNodeDirty(!0))},isFlippedX:function(){return this._flippedX},isFlippedY:function(){return this._flippedY},setOpacityModifyRGB:function(t){this._opacityModifyRGB!==t&&(this._opacityModifyRGB=t,this._renderCmd._setColorDirty())},isOpacityModifyRGB:function(){return this._opacityModifyRGB},setDisplayFrameWithAnimationName:function(t,e){cc.assertID(t,2610);var i=cc.spriteFrameAnimationCache.getAnimation(t);if(i){var n=i.getFrames()[e];n?this.setSpriteFrame(n.getSpriteFrame()):cc.logID(2603)}else cc.logID(2602)},getTexture:function(){return this._texture},_softInit:function(t,e,i){if(void 0===t)_ccsg.Sprite.prototype.init.call(this);else if(cc.js.isString(t))"#"===t[0]?cc.logID(2728,t):_ccsg.Sprite.prototype.init.call(this,t,e);else if("object"==typeof t)if(t instanceof cc.Texture2D)this.initWithTexture(t,e,i);else if(t instanceof cc.SpriteFrame)this.initWithSpriteFrame(t);else if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var n=new cc.Texture2D;n.initWithElement(t),n.handleLoadedTexture(),this.initWithTexture(n)}},getQuad:function(){return null},setBlendFunc:function(t,e){var i=this._blendFunc;void 0===e?(i.src=t.src,i.dst=t.dst):(i.src=t,i.dst=e),this._renderCmd.updateBlendFunc(i)},init:function(){return arguments.length>0?this.initWithFile(arguments[0],arguments[1]):(this.dirty=this._recursiveDirty=!1,this._blendFunc.src=cc.macro.BLEND_SRC,this._blendFunc.dst=cc.macro.BLEND_DST,this.texture=null,this._flippedX=this._flippedY=!1,this.anchorX=.5,this.anchorY=.5,this._offsetPosition.x=0,this._offsetPosition.y=0,this.setTextureRect(cc.rect(0,0,0,0),!1,cc.size(0,0)),!0)},initWithFile:function(t,e){cc.assertID(t,2609);var i=cc.textureCache.getTextureForKey(t);if(i){if(!e){var n=i.getContentSize();e=cc.rect(0,0,n.width,n.height)}return this.initWithTexture(i,e)}return i=cc.textureCache.addImage(t),this.initWithTexture(i,e||cc.rect(0,0,i.width,i.height))},initWithTexture:function(t,e,i,n){cc.assertID(0!==arguments.length,2710),i=i||!1,t=this._renderCmd._handleTextureForRotatedTexture(t,e,i,n),this._recursiveDirty=!1,this.dirty=!1,this._opacityModifyRGB=!0,this._blendFunc.src=cc.macro.BLEND_SRC,this._blendFunc.dst=cc.macro.BLEND_DST,this._flippedX=this._flippedY=!1,this.setAnchorPoint(.5,.5),this._offsetPosition.x=0,this._offsetPosition.y=0;var r=t.loaded;return this._textureLoaded=r,r?(e||(e=cc.rect(0,0,t.width,t.height)),this._renderCmd._checkTextureBoundary(t,e,i),this.setTexture(t),this.setTextureRect(e,i),this.emit("load"),!0):(this._rectRotated=i,e&&(this._rect.x=e.x,this._rect.y=e.y,this._rect.width=e.width,this._rect.height=e.height),this.texture&&this.texture.off("load",this._renderCmd._textureLoadedCallback,this._renderCmd),t.once("load",this._renderCmd._textureLoadedCallback,this._renderCmd),this.setTexture(t),!0)},setTextureRect:function(t,e,i,n){this._rectRotated=e||!1,this.setContentSize(i||t),this.setVertexRect(t),this._renderCmd._setTextureCoords(t,n);var r=this._unflippedOffsetPositionFromCenter.x,s=this._unflippedOffsetPositionFromCenter.y;this._flippedX&&(r=-r),this._flippedY&&(s=-s);var o=this._rect;this._offsetPosition.x=r+(this._contentSize.width-o.width)/2,this._offsetPosition.y=s+(this._contentSize.height-o.height)/2},setSpriteFrame:function(t){var e=this;cc.assertID(t,2712),this.setNodeDirty(!0);var i=t.getOffset();e._unflippedOffsetPositionFromCenter.x=i.x,e._unflippedOffsetPositionFromCenter.y=i.y;var n=t.getTexture();t.textureLoaded()?(e._textureLoaded=!0,n!==e._texture&&(e._setTexture(n),e.setColor(e._realColor)),e.setTextureRect(t.getRect(),t.isRotated(),t.getOriginalSize())):(e._textureLoaded=!1,t.once("load",(function(t){var i=t.currentTarget;e._textureLoaded=!0;var n=i.getTexture();n!==e._texture&&e._setTexture(n),e.setTextureRect(i.getRect(),i.isRotated(),i.getOriginalSize()),e.emit("load"),e.setColor(e._realColor)}),e)),this._renderCmd._updateForSetSpriteFrame(n)},setDisplayFrame:function(t){cc.logID(2604),this.setSpriteFrame(t)},isFrameDisplayed:function(t){return this._renderCmd.isFrameDisplayed(t)},displayFrame:function(){return this.getSpriteFrame()},getSpriteFrame:function(){return new cc.SpriteFrame(this._texture,this._rect,this._rectRotated,this._unflippedOffsetPositionFromCenter,this._contentSize)},setTexture:function(t){if(!t)return this._renderCmd._setTexture(null);var e=cc.js.isString(t);e&&(t=cc.textureCache.addImage(t)),t.loaded?(this._setTexture(t,e),this.setColor(this._realColor),this._textureLoaded=!0,this.emit("load")):(this._renderCmd._setTexture(t),t.once("load",(function(i){this._setTexture(t,e),this.setColor(this._realColor),this._textureLoaded=!0,this.emit("load")}),this))},_setTexture:function(t,e){this._renderCmd._setTexture(t),e&&this._changeRectWithTexture(t)},_changeRectWithTexture:function(t){var e=cc.rect(0,0,t.width,t.height);this.setTextureRect(e)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new _ccsg.Sprite.CanvasRenderCmd(this):new _ccsg.Sprite.WebGLRenderCmd(this)}}),cc.js.addon(_ccsg.Sprite.prototype,n.prototype);r.propertyDefine(_ccsg.Sprite,["opacity","color","texture","quad"],{opacityModifyRGB:["isOpacityModifyRGB","setOpacityModifyRGB"],flippedX:["isFlippedX","setFlippedX"],flippedY:["isFlippedY","setFlippedY"],offsetX:["_getOffsetX"],offsetY:["_getOffsetY"],textureRectRotated:["isTextureRectRotated"]})}),{"../event/event-target":112,"../utils/misc":226}],209:[(function(t,e,i){_ccsg.Sprite.CanvasRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,this._textureCoord={renderX:0,renderY:0,x:0,y:0,width:0,height:0,validRect:!1},this._blendFuncStr="source-over",this._colorized=!1,this._textureToRender=null};var n=_ccsg.Sprite.CanvasRenderCmd.prototype=Object.create(_ccsg.Node.CanvasRenderCmd.prototype);n.constructor=_ccsg.Sprite.CanvasRenderCmd,n.setDirtyRecursively=function(t){},n._setTexture=function(t){var e=this._node;if(e._texture!==t){e._textureLoaded=!!t&&t.loaded,e._texture=t;var i=cc.rect(0,0,t.width,t.height);e.setTextureRect(i),this._updateColor()}},n._setColorDirty=function(){this.setDirtyFlag(_ccsg.Node._dirtyFlags.colorDirty|_ccsg.Node._dirtyFlags.opacityDirty)},n.isFrameDisplayed=function(t){var e=this._node;return t.getTexture()===e._texture&&cc.rectEqualToRect(t.getRect(),e._rect)},n.updateBlendFunc=function(t){this._blendFuncStr=_ccsg.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(t)},n._handleTextureForRotatedTexture=function(t,e,i,n){if(i&&t.isLoaded()){var r=t.getHtmlElementObj();r=_ccsg.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(r,e,n);var s=new cc.Texture2D;s.initWithElement(r),s.handleLoadedTexture(),t=s,e.x=e.y=0,this._node._rect=cc.rect(0,0,e.width,e.height)}return t},n._checkTextureBoundary=function(t,e,i){if(t&&t.url){var n=e.x+e.width,r=e.y+e.height;n>t.width&&cc.errorID(3300,t.url),r>t.height&&cc.errorID(3400,t.url)}},n.rendering=function(t,e,i){var n=this._node,r=this._textureCoord,s=this._displayedOpacity/255,o=this._textureToRender||n._texture;if((!o||0!==r.width&&0!==r.height&&o.loaded)&&0!==s){var a,c=t||cc._renderContext,h=c.getContext(),l=n._offsetPosition.x,u=n._rect.height,_=n._rect.width,d=-n._offsetPosition.y-u;c.setTransform(this._worldTransform,e,i),c.setCompositeOperation(this._blendFuncStr),c.setGlobalAlpha(s),(n._flippedX||n._flippedY)&&c.save(),n._flippedX&&(l=-l-_,h.scale(-1,1)),n._flippedY&&(d=n._offsetPosition.y,h.scale(1,-1));var f,p,m,g,y,v,x,C;if(this._colorized?(f=0,p=0):(f=r.renderX,p=r.renderY),m=r.width,g=r.height,y=l,v=d,x=_,C=u,o&&o._image)a=o._image,""!==o._pattern?(c.setFillStyle(h.createPattern(a,o._pattern)),h.fillRect(y,v,x,C)):h.drawImage(a,f,p,m,g,y,v,x,C);else{var T=n._contentSize;if(r.validRect){var b=this._displayedColor;c.setFillStyle("rgba("+b.r+","+b.g+","+b.b+",1)"),h.fillRect(y,v,T.width,T.height)}}(n._flippedX||n._flippedY)&&c.restore(),cc.g_NumberOfDraws++}},n._updateColor=function(){var t=this._node._texture,e=this._textureCoord,i=this._displayedColor;t&&(255!==i.r||255!==i.g||255!==i.b?(this._textureToRender=t._generateColorTexture(i.r,i.g,i.b,e),this._colorized=!0):t&&(this._textureToRender=t,this._colorized=!1))},n._updateForSetSpriteFrame=function(t,e){if(this._colorized=!1,this._textureCoord.renderX=this._textureCoord.x,this._textureCoord.renderY=this._textureCoord.y,e=e||t.loaded){var i=this._node.getColor();255===i.r&&255===i.g&&255===i.b||this._updateColor()}},n._spriteFrameLoadedCallback=function(t){var e=this._node,i=t.currentTarget;e.setTextureRect(i.getRect(),i.isRotated(),i.getOriginalSize()),this._updateColor(),e.emit("load")},n._textureLoadedCallback=function(t){var e=this._node,i=t.currentTarget;if(!e._textureLoaded){e._textureLoaded=!0;var n=e._rect;n?cc._rectEqualToZero(n)&&(n.width=i.width,n.height=i.height):n=cc.rect(0,0,i.width,i.height),e.texture=i,e.setTextureRect(n,e._rectRotated);var r=this._displayedColor;255===r.r&&255===r.g&&255===r.b||this._updateColor(),e.emit("load")}},n._setTextureCoords=function(t){var e=this._textureCoord;e.renderX=e.x=0|t.x,e.renderY=e.y=0|t.y,e.width=0|t.width,e.height=0|t.height,e.validRect=!(0===e.width||0===e.height||e.x<0||e.y<0)},_ccsg.Sprite.CanvasRenderCmd._cutRotateImageToCanvas=function(t,e,i){if(!t)return null;if(!e)return t;i=null==i||i;var n=document.createElement("canvas");n.width=e.width,n.height=e.height;var r=n.getContext("2d");return r.translate(n.width/2,n.height/2),i?r.rotate(-1.5707963267948966):r.rotate(1.5707963267948966),r.drawImage(t,e.x,e.y,e.height,e.width,-e.height/2,-e.width/2,e.height,e.width),n}}),{}],210:[(function(t,e,i){var n=cc.macro;_ccsg.Sprite.WebGLRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,this._vertices=[{x:0,y:0,u:0,v:0},{x:0,y:0,u:0,v:0},{x:0,y:0,u:0,v:0},{x:0,y:0,u:0,v:0}],this._dirty=!1,this._recursiveDirty=!1,this._shaderProgram=cc.shaderCache.programForKey(n.SHADER_SPRITE_POSITION_TEXTURECOLOR)};var r=_ccsg.Sprite.WebGLRenderCmd.prototype=Object.create(_ccsg.Node.WebGLRenderCmd.prototype);r.constructor=_ccsg.Sprite.WebGLRenderCmd,r.updateBlendFunc=function(t){},r.setDirtyFlag=function(t){_ccsg.Node.WebGLRenderCmd.prototype.setDirtyFlag.call(this,t),this._dirty=!0},r.setDirtyRecursively=function(t){this._recursiveDirty=t,this._dirty=t;for(var e,i=this._node._children,n=i?i.length:0,r=0;rt.width&&cc.errorID(3300,t.url),r>t.height&&cc.errorID(3400,t.url)}},r.transform=function(t,e){this.originTransform(t,e);var i=this._node,n=i._offsetPosition.x,r=n+i._rect.width,s=i._offsetPosition.y,o=s+i._rect.height,a=this._worldTransform,c=this._vertices;c[0].x=n*a.a+o*a.c+a.tx,c[0].y=n*a.b+o*a.d+a.ty,c[1].x=n*a.a+s*a.c+a.tx,c[1].y=n*a.b+s*a.d+a.ty,c[2].x=r*a.a+o*a.c+a.tx,c[2].y=r*a.b+o*a.d+a.ty,c[3].x=r*a.a+s*a.c+a.tx,c[3].y=r*a.b+s*a.d+a.ty},r.needDraw=function(){var t=this._node._texture;return this._needDraw&&t},r.uploadData=function(t,e,i){var n=this._node,r=n._texture;if(!(r&&r.loaded&&n._rect.width&&n._rect.height&&this._displayedOpacity))return 0;var s,o=this._displayedOpacity,a=this._displayedColor._val;if(n._opacityModifyRGB){var c=o/255,h=this._displayedColor.r*c,l=this._displayedColor.g*c;s=(o<<24>>>0)+(this._displayedColor.b*c<<16)+(l<<8)+h}else s=(o<<24>>>0)+((65280&a)<<8)+((16711680&a)>>8)+(a>>>24);var u,_,d=n._vertexZ,f=this._vertices,p=f.length,m=i;for(u=0;u=t){e=this._lengths[i];break}return e?this._pool[e].pop():void 0}},a=cc.macro,c={_rebuildQuads_base:function(t){var e,i,n,s,a=t._spriteFrame,c=t._contentSize,h=t._isTrimmedContentSize,l=t._vertices,u=t._corner;if(h)e=0,i=0,n=c.width,s=c.height;else{var _=a._originalSize,d=a._rect,f=a._offset,p=c.width,m=c.height,g=_.width,y=_.height,v=d.width,x=d.height,C=p/g,T=m/y,b=f.x+(g-v)/2,A=f.x-(g-v)/2;e=b*C,i=(f.y+(y-x)/2)*T,n=p+A*C,s=m+(f.y-(y-x)/2)*T}if(l.length<8&&(o.put(l),l=o.get(8)||new Float32Array(8),t._vertices=l),r){var S=t._renderCmd._worldTransform,w=S.a,E=S.b,I=S.c,R=S.d,P=S.tx,O=S.ty,B=e*w,D=e*E,M=n*w,L=n*E,N=s*I+P,F=s*R+O,k=i*I+P,z=i*R+O;l[0]=B+k,l[1]=D+z,l[2]=M+k,l[3]=L+z,l[4]=B+N,l[5]=D+F,l[6]=M+N,l[7]=L+F}else l[0]=e,l[1]=i,l[2]=n,l[3]=i,l[4]=e,l[5]=s,l[6]=n,l[7]=s;u[0]=0,u[1]=2,u[2]=4,u[3]=6,t._uvsDirty&&this._calculateUVs(t,a),t._vertCount=4},_calculateUVs:function(t,e){var i=t._uvs,n=e._texture.width,r=e._texture.height,s=e._rect;i.length<8&&(o.put(i),i=o.get(8)||new Float32Array(8),t._uvs=i);var c,h,l,u,_=a.FIX_ARTIFACTS_BY_STRECHING_TEXEL?.5:0;e._rotated?(c=(s.x+_)/n,h=(s.y+s.width-_)/r,l=(s.x+s.height-_)/n,u=(s.y+_)/r,i[0]=c,i[1]=u,i[2]=c,i[3]=h,i[4]=l,i[5]=u,i[6]=l,i[7]=h):(c=(s.x+_)/n,h=(s.y+s.height-_)/r,l=(s.x+s.width-_)/n,u=(s.y+_)/r,i[0]=c,i[1]=h,i[2]=l,i[3]=h,i[4]=c,i[5]=u,i[6]=l,i[7]=u)}},h={x:new Array(4),y:new Array(4),_rebuildQuads_base:function(t){var e,i,n,s,a=t._spriteFrame,c=t._contentSize,h=t._insetLeft,l=t._insetRight,u=t._insetTop,_=t._insetBottom,d=t._vertices,f=t._renderCmd._worldTransform,p=a._rect,m=t._corner;e=h,i=l,p.width,n=u,s=_,p.height;var g=c,y=g.width-e-i,v=g.height-n-s,x=g.width/(e+i),C=g.height/(n+s);x=isNaN(x)||x>1?1:x,C=isNaN(C)||C>1?1:C,y=y<0?0:y,v=v<0?0:v;var T=this.x,b=this.y;T[0]=0,T[1]=e*x,T[2]=T[1]+y,T[3]=g.width,b[0]=0,b[1]=s*C,b[2]=b[1]+v,b[3]=g.height,d.length<32&&(o.put(d),d=o.get(32)||new Float32Array(32),t._vertices=d);var A,S,w=0;if(r)for(A=0;A<4;A++)for(S=0;S<4;S++)d[w]=T[S]*f.a+b[A]*f.c+f.tx,d[w+1]=T[S]*f.b+b[A]*f.d+f.ty,w+=2;else for(A=0;A<4;A++)for(S=0;S<4;S++)d[w]=T[S],d[w+1]=b[A],w+=2;m[0]=0,m[1]=6,m[2]=24,m[3]=30,t._uvsDirty&&this._calculateUVs(t,a,h,l,u,_)},_calculateUVs:function(t,e,i,n,r,s){var c,h,l,u,_,d,f=t._uvs,p=e._rect,m=e._texture.width,g=e._texture.height,y=e._rect;c=i,l=n,h=p.width-c-l,u=r,d=s,_=p.height-u-d,f.length<32&&(o.put(f),f=o.get(32)||new Float32Array(32),t._uvs=f);var v,x,C=this.x,T=this.y,b=a.FIX_ARTIFACTS_BY_STRECHING_TEXEL?.5:0,A=0;if(e._rotated)for(C[0]=(y.x+b)/m,C[1]=(d+y.x)/m,C[2]=(d+_+y.x)/m,C[3]=(y.x+y.height-b)/m,T[3]=(y.y+b)/g,T[2]=(c+y.y)/g,T[1]=(c+h+y.y)/g,T[0]=(y.y+y.width-b)/g,v=0;v<4;v++)for(x=0;x<4;x++)f[A]=C[v],f[A+1]=T[3-x],A+=2;else for(C[0]=(y.x+b)/m,C[1]=(c+y.x)/m,C[2]=(c+h+y.x)/m,C[3]=(y.x+y.width-b)/m,T[3]=(y.y+b)/g,T[2]=(u+y.y)/g,T[1]=(u+_+y.y)/g,T[0]=(y.y+y.height-b)/g,v=0;v<4;v++)for(x=0;x<4;x++)f[A]=C[x],f[A+1]=T[v],A+=2}},l={_rebuildQuads_base:function(t,e,i){e=t._spriteFrame,i=t._contentSize;var n,s,c,h,l=t._vertices,u=t._corner,_=t._renderCmd._worldTransform,d=t._uvs,f=e._texture.width,p=e._texture.height,m=e._rect,g=a.FIX_ARTIFACTS_BY_STRECHING_TEXEL?.5:0;e._rotated?(n=(m.x+g)/f,c=(m.x+m.height-g)/f,s=(m.y+m.width-g)/p,h=(m.y+g)/p):(n=(m.x+g)/f,c=(m.x+m.width-g)/f,s=(m.y+m.height-g)/p,h=(m.y+g)/p);var y=m.width,v=m.height,x=i.width/y,C=i.height/v,T=Math.ceil(C),b=Math.ceil(x);T*b>16384&&cc.errorID(2625);var A=T*b*4*2;l.lengthA)return}u[0]=0,u[1]=8*(b-1)+2,u[2]=(T-1)*b*8+4,u[3]=A-2}},u={_rebuildQuads_base:function(t){var e=t._spriteFrame,i=t._contentSize,n=t._fillStart,s=t._fillRange;s<0&&(n+=s,s=-s),s=n+s,n=(n=n>1?1:n)<0?0:n,s=(s=s>1?1:s)<0?0:s,s-=n;var c,h,l,u,_,d=t._fillType,f=t._vertices,p=t._corner,g=t._renderCmd._worldTransform,y=t._uvs,v=0,x=0,C=i.width,T=i.height,b=e._texture.width,A=e._texture.height,S=e._rect,w=a.FIX_ARTIFACTS_BY_STRECHING_TEXEL?.5:0;e._rotated?(h=(S.x+w)/b,l=(S.y+S.width-w)/A,u=(S.x+S.height-w)/b,_=(S.y+w)/A):(h=(S.x+w)/b,l=(S.y+S.height-w)/A,u=(S.x+S.width-w)/b,_=(S.y+w)/A),f.length<8&&(o.put(f),f=o.get(8)||new Float32Array(8),t._vertices=f),y.length<8&&(o.put(y),y=o.get(8)||new Float32Array(8),t._uvs=y);var E=new Array(8);e._rotated?(E[0]=E[2]=h,E[4]=E[6]=u,E[3]=E[7]=l,E[1]=E[5]=_):(E[0]=E[4]=h,E[2]=E[6]=u,E[1]=E[3]=l,E[5]=E[7]=_),c=(c=(n=(n=n>1?1:n)<0?0:n)+(s=s<0?0:s))>1?1:c;var I;switch(d){case m.HORIZONTAL:I=v+(C-v)*c,v=v+(C-v)*n,C=I,y[0]=E[0]+(E[2]-E[0])*n,y[1]=E[1],y[2]=E[0]+(E[2]-E[0])*c,y[3]=E[3],y[4]=E[4]+(E[6]-E[4])*n,y[5]=E[5],y[6]=E[4]+(E[6]-E[4])*c,y[7]=E[7];break;case m.VERTICAL:I=x+(T-x)*c,x=x+(T-x)*n,T=I,y[0]=E[0],y[1]=E[1]+(E[5]-E[1])*n,y[2]=E[2],y[3]=E[3]+(E[7]-E[3])*n,y[4]=E[4],y[5]=E[1]+(E[5]-E[1])*c,y[6]=E[6],y[7]=E[3]+(E[7]-E[3])*c;break;default:cc.errorID(2626)}if(r){var R=v*g.a,P=v*g.b,O=C*g.a,B=C*g.b,D=T*g.c+g.tx,M=T*g.d+g.ty,L=x*g.c+g.tx,N=x*g.d+g.ty;f[0]=R+L,f[1]=P+N,f[2]=O+L,f[3]=B+N,f[4]=R+D,f[5]=P+M,f[6]=O+D,f[7]=B+M}else f[0]=v,f[1]=x,f[2]=C,f[3]=x,f[4]=v,f[5]=T,f[6]=C,f[7]=T;t._vertCount=4,p[0]=0,p[1]=2,p[2]=4,p[3]=6}},_={_vertPos:[cc.v2(0,0),cc.v2(0,0),cc.v2(0,0),cc.v2(0,0)],_vertices:[cc.v2(0,0),cc.v2(0,0)],_uvs:[cc.v2(0,0),cc.v2(0,0)],_intersectPoint_1:[cc.v2(0,0),cc.v2(0,0),cc.v2(0,0),cc.v2(0,0)],_intersectPoint_2:[cc.v2(0,0),cc.v2(0,0),cc.v2(0,0),cc.v2(0,0)],outVerts:null,outUvs:null,rawVerts:null,rawUvs:null,_rebuildQuads_base:function(t){var e=t._spriteFrame,i=t._contentSize,n=t._fillStart,r=t._fillRange;r<0&&(n+=r,r=-r),t._isTriangle=!0,t._rawVerts||(t._rawVerts=o.get(8)||new Float32Array(8),t._rawUvs=o.get(8)||new Float32Array(8));for(var s=t._fillCenter,a=t._vertices,c=t._corner,h=t._uvs,l=t._rawVerts,u=t._rawUvs,_=t._renderCmd._worldTransform;n>=1;)n-=1;for(;n<0;)n+=1;var d=s.x*i.width,f=s.y*i.height,p=cc.v2(d,f),m=(n*=2*Math.PI)+(r*=2*Math.PI);this.outVerts=a,this.outUvs=h,this.rawVerts=l,this.rawUvs=u,this._calculateVertices(_,e,i),this._calculateUVs(e);var g=this._vertPos,y=this._vertices;g[0].x=g[3].x=y[0].x,g[1].x=g[2].x=y[1].x,g[0].y=g[1].y=y[0].y,g[2].y=g[3].y=y[1].y,p.x>y[1].x&&(p.x=y[1].x),p.xy[1].y&&(p.y=y[1].y),l[0]=l[4]=this._vertices[0].x,l[2]=l[6]=this._vertices[1].x,l[1]=l[3]=this._vertices[0].y,l[5]=l[7]=this._vertices[1].y,e._rotated?(u[0]=u[2]=this._uvs[0].x,u[4]=u[6]=this._uvs[1].x,u[3]=u[7]=this._uvs[0].y,u[1]=u[5]=this._uvs[1].y):(u[0]=u[4]=this._uvs[0].x,u[2]=u[6]=this._uvs[1].x,u[1]=u[3]=this._uvs[0].y,u[5]=u[7]=this._uvs[1].y);var v=[null,null,null,null];p.x!==this._vertices[0].x&&(v[0]=[3,0]),p.x!==this._vertices[1].x&&(v[2]=[1,2]),p.y!==this._vertices[0].y&&(v[1]=[0,1]),p.y!==this._vertices[1].y&&(v[3]=[2,3]),this._getInsectedPoints(this._vertices[0].x,this._vertices[1].x,this._vertices[0].y,this._vertices[1].y,p,n,this._intersectPoint_1),this._getInsectedPoints(this._vertices[0].x,this._vertices[1].x,this._vertices[0].y,this._vertices[1].y,p,n+r,this._intersectPoint_2);a.length<30&&(o.put(a),a=o.get(30)||new Float32Array(30),this.outVerts=t._vertices=a),h.length<30&&(o.put(h),h=o.get(30)||new Float32Array(30),this.outUvs=t._uvs=h);for(var x=0,C=0,T=0;T<4;++T){var b=v[T];if(null!==b)if(r>=2*Math.PI)this._generateTriangle(_,x,p,this._vertPos[b[0]],this._vertPos[b[1]]),x+=6,C+=3;else{var A=this._getVertAngle(p,this._vertPos[b[0]]),S=this._getVertAngle(p,this._vertPos[b[1]]);S=m||(A>=n?(S>=m?this._generateTriangle(_,x,p,this._vertPos[b[0]],this._intersectPoint_2[T]):this._generateTriangle(_,x,p,this._vertPos[b[0]],this._vertPos[b[1]]),x+=6,C+=3):S<=n||(S<=m?(this._generateTriangle(_,x,p,this._intersectPoint_1[T],this._vertPos[b[1]]),x+=6,C+=3):(this._generateTriangle(_,x,p,this._intersectPoint_1[T],this._intersectPoint_2[T]),x+=6,C+=3))),A+=2*Math.PI,S+=2*Math.PI}}t._vertCount=C;for(var E,I,R=1/0,P=1/0,O=-1/0,B=-1/0,D=0,M=x;D=O&&(O=E,c[1]=D),I<=P?(P=I,c[2]=D):I>=B&&(B=I,c[3]=D)},_generateTriangle:function(t,e,i,n,s){var o,a,c=this.rawVerts,h=this.rawUvs,l=this.outVerts,u=c[0],_=c[1],d=c[6],f=c[7];r?(l[e]=i.x*t.a+i.y*t.c+t.tx,l[e+1]=i.x*t.b+i.y*t.d+t.ty,l[e+2]=n.x*t.a+n.y*t.c+t.tx,l[e+3]=n.x*t.b+n.y*t.d+t.ty,l[e+4]=s.x*t.a+s.y*t.c+t.tx,l[e+5]=s.x*t.b+s.y*t.d+t.ty):(l[e]=i.x,l[e+1]=i.y,l[e+2]=n.x,l[e+3]=n.y,l[e+4]=s.x,l[e+5]=s.y),o=(i.x-u)/(d-u),a=(i.y-_)/(f-_),this._generateUV(o,a,h,e),o=(n.x-u)/(d-u),a=(n.y-_)/(f-_),this._generateUV(o,a,h,e+2),o=(s.x-u)/(d-u),a=(s.y-_)/(f-_),this._generateUV(o,a,h,e+4)},_generateUV:function(t,e,i,n){var r=this.outUvs,s=i[0]+(i[2]-i[0])*t,o=i[4]+(i[6]-i[4])*t,a=i[1]+(i[3]-i[1])*t,c=i[5]+(i[7]-i[5])*t;r[n]=s+(o-s)*e,r[n+1]=a+(c-a)*e},_isAngleIn:function(t,e,i){for(var n=2*Math.PI;t=e+n;)t=e+n&&(t-=n);return t<=e+i},_getVertAngle:function(t,e){var i,n;if(i=e.x-t.x,n=e.y-t.y,0!==i||0!==n){if(0===i)return n>0?.5*Math.PI:1.5*Math.PI;var r=Math.atan(n/i);return i<0&&(r+=Math.PI),r}},_getInsectedPoints:function(t,e,i,n,r,s,o){var a,c,h=Math.sin(s),l=Math.cos(s);if(0!==Math.cos(s)){if(a=h/l,(t-r.x)*l>0){var u=r.y+a*(t-r.x);o[0].x=t,o[0].y=u}if((e-r.x)*l>0){var _=r.y+a*(e-r.x);o[2].x=e,o[2].y=_}}if(0!==Math.sin(s)){if(c=l/h,(n-r.y)*h>0){var d=r.x+c*(n-r.y);o[3].x=d,o[3].y=n}if((i-r.y)*h>0){var f=r.x+c*(i-r.y);o[1].x=f,o[1].y=i}}return[null,null,null,null]},_calculateVertices:function(t,e,i){var n,r;n=i.width,r=i.height,this._vertices[0].x=0,this._vertices[0].y=0,this._vertices[1].x=n,this._vertices[1].y=r},_calculateUVs:function(t){var e,i,n,r,s=t._texture.width,o=t._texture.height,c=t._rect,h=a.FIX_ARTIFACTS_BY_STRECHING_TEXEL?.5:0;t._rotated?(e=(c.x+h)/s,i=(c.x+c.height-h)/s,n=(c.y+h)/o,r=(c.y+c.width-h)/o):(e=(c.x+h)/s,i=(c.x+c.width-h)/s,n=(c.y+h)/o,r=(c.y+c.height-h)/o),this._uvs[0].x=e,this._uvs[0].y=r,this._uvs[1].x=i,this._uvs[1].y=n}},d={_rebuildQuads_base:function(t,e,i){if(cc._renderType!==cc.game.RENDER_TYPE_CANVAS){t._spriteFrame;if(i=t._meshPolygonInfo){var n=t._renderCmd._worldTransform,r=i.triangles.verts,s=t._vertices,a=t._uvs,c=r.length,h=t._corner,l=2*c;s.lengthd&&(d=m,h[1]=2*p),g<_&&(_=g,h[2]=2*p),g>f&&(f=g,h[3]=2*p)}t._vertCount=c}}}};cc.Scale9Sprite=_ccsg.Node.extend({_spriteFrame:null,_insetLeft:0,_insetRight:0,_insetTop:0,_insetBottom:0,_blendFunc:null,_renderingType:1,_brightState:0,_rawVerts:null,_rawUvs:null,_vertices:null,_uvs:null,_vertCount:0,_quadsDirty:!0,_uvsDirty:!0,_isTriangle:!1,_isTrimmedContentSize:!0,_fillType:0,_fillCenter:null,_fillStart:0,_fillRange:2*Math.PI,_distortionOffset:null,_distortionTiling:null,_meshPolygonInfo:null,ctor:function(t){_ccsg.Node.prototype.ctor.call(this),this._renderCmd.setState(this._brightState),this._blendFunc=cc.BlendFunc._alphaNonPremultiplied(),this._fillCenter=cc.v2(0,0),this.setAnchorPoint(cc.p(.5,.5)),this._rawVerts=null,this._rawUvs=null,this._vertices=o.get(8)||new Float32Array(8),this._uvs=o.get(8)||new Float32Array(8),"string"==typeof t||t instanceof cc.Texture2D?this.initWithTexture(t):t instanceof cc.SpriteFrame&&this.initWithSpriteFrame(t),void 0===r&&(r=cc._renderType===cc.game.RENDER_TYPE_WEBGL),this._corner=[]},loaded:function(){return null!==this._spriteFrame&&this._spriteFrame.textureLoaded()},initWithTexture:function(t){this.setTexture(t)},initWithSpriteFrame:function(t){this.setSpriteFrame(t)},setTexture:function(t){var e=new cc.SpriteFrame(t);this.setSpriteFrame(e)},setSpriteFrame:function(t){if(t){this._spriteFrame=t,this._quadsDirty=!0,this._uvsDirty=!0,this._renderCmd._needDraw=!1;var e=this,i=function(){cc.sizeEqualToSize(e._contentSize,cc.size(0,0))&&e.setContentSize(e._spriteFrame._rect),e._renderCmd._needDraw=!0,e._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)};t.textureLoaded()?i():t.once("load",i,this)}},setBlendFunc:function(t,e){void 0===e?(this._blendFunc.src=t.src||cc.macro.BLEND_SRC,this._blendFunc.dst=t.dst||cc.macro.BLEND_DST):(this._blendFunc.src=t||cc.macro.BLEND_SRC,this._blendFunc.dst=e||cc.macro.BLEND_DST),this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)},getBlendFunc:function(){return new cc.BlendFunc(this._blendFunc.src,this._blendFunc.dst)},setContentSize:function(t,e){void 0===e&&(e=t.height,t=t.width),t===this._contentSize.width&&e===this._contentSize.height||(_ccsg.Node.prototype.setContentSize.call(this,t,e),this._quadsDirty=!0)},enableTrimmedContentSize:function(t){this._isTrimmedContentSize!==t&&(this._isTrimmedContentSize=t,this._quadsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty))},isTrimmedContentSizeEnabled:function(){return this._isTrimmedContentSize},setState:function(t){this._brightState=t,this._renderCmd.setState(t),this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)},getState:function(){return this._brightState},setRenderingType:function(t){this._renderingType!==t&&(this._renderingType=t,this._quadsDirty=!0,this._uvsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty))},getRenderingType:function(){return this._renderingType},setInsetLeft:function(t){this._insetLeft=t,this._quadsDirty=!0,this._uvsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)},getInsetLeft:function(){return this._insetLeft},setInsetTop:function(t){this._insetTop=t,this._quadsDirty=!0,this._uvsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)},getInsetTop:function(){return this._insetTop},setInsetRight:function(t){this._insetRight=t,this._quadsDirty=!0,this._uvsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)},getInsetRight:function(){return this._insetRight},setInsetBottom:function(t){this._insetBottom=t,this._quadsDirty=!0,this._uvsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)},getInsetBottom:function(){return this._insetBottom},setFillType:function(t){this._fillType!==t&&(this._fillType=t,this._renderingType===p.FILLED&&(this._quadsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)))},getFillType:function(){return this._fillType},setFillCenter:function(t,e){this._fillCenter=cc.v2(t,e),this._renderingType===p.FILLED&&this._fillType===m.RADIAL&&(this._quadsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty))},setDistortionTiling:function(t,e){void 0===e&&(e=t.y,t=t.x),this._distortionTiling=this._distortionTiling||cc.v2(0,0),this._distortionTiling.x=t,this._distortionTiling.y=e},setDistortionOffset:function(t,e){void 0===e&&(e=t.y,t=t.x),this._distortionOffset=this._distortionOffset||cc.v2(0,0),this._distortionOffset.x=t,this._distortionOffset.y=e},getFillCenter:function(){return cc.v2(this._fillCenter)},setFillStart:function(t){this._fillStart!==t&&(this._fillStart=t,this._renderingType===p.FILLED&&(this._quadsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)))},getFillStart:function(){return this._fillStart},setFillRange:function(t){this._fillRange!==t&&(this._fillRange=t,this._renderingType===p.FILLED&&(this._quadsDirty=!0,this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty)))},getFillRange:function(){return this._fillRange},_rebuildQuads:function(){if(this._spriteFrame&&this._spriteFrame._textureLoaded){this._isTriangle=!1;var t;switch(this._renderingType){case p.SIMPLE:t=c;break;case p.SLICED:t=h;break;case p.TILED:t=l;break;case p.FILLED:t=this._fillType===m.RADIAL?_:u;break;case p.MESH:t=d}t?t._rebuildQuads_base(this):(this._quadsDirty=!1,this._uvsDirty=!1,this._renderCmd._needDraw=!1,cc.errorID(2627)),this._quadsDirty=!1,this._uvsDirty=!1}else this._renderCmd._needDraw=!1},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.Scale9Sprite.CanvasRenderCmd(this):new cc.Scale9Sprite.WebGLRenderCmd(this)},setMeshPolygonInfo:function(t){this.setRenderingType(p.MESH),this._meshPolygonInfo=t,this._quadsDirty=!0,this._uvsDirty=!0},getMeshPolygonInfo:function(){return this._meshPolygonInfo}});var f=cc.Scale9Sprite.prototype;cc.js.addon(f,s.prototype),cc.defineGetterSetter(f,"insetLeft",f.getInsetLeft,f.setInsetLeft),cc.defineGetterSetter(f,"insetTop",f.getInsetTop,f.setInsetTop),cc.defineGetterSetter(f,"insetRight",f.getInsetRight,f.setInsetRight),cc.defineGetterSetter(f,"insetBottom",f.getInsetBottom,f.setInsetBottom),cc.Scale9Sprite.state={NORMAL:0,GRAY:1,DISTORTION:2};var p=cc.Scale9Sprite.RenderingType=cc.Enum({SIMPLE:0,SLICED:1,TILED:2,FILLED:3,MESH:4}),m=cc.Scale9Sprite.FillType=cc.Enum({HORIZONTAL:0,VERTICAL:1,RADIAL:2})}),{"../event/event-target":112}],212:[(function(t,e,i){cc.Scale9Sprite.CanvasRenderCmd=function(t){this._rootCtor(t),this._node.loaded()?this._needDraw=!0:this._needDraw=!1,this._state=cc.Scale9Sprite.state.NORMAL,this._originalTexture=this._textureToRender=null};var n=cc.Scale9Sprite.CanvasRenderCmd.prototype=Object.create(_ccsg.Node.CanvasRenderCmd.prototype);n.constructor=cc.Scale9Sprite.CanvasRenderCmd,n.updateTransform=function(t){this.originUpdateTransform(t),this._node._rebuildQuads()},n._doCulling=function(){var t=cc.visibleRect,e=this._currentRegion,i=e._minX,n=e._maxX,r=e._minY,s=e._maxY,o=t.left.x,a=t.right.x,c=t.top.y,h=t.bottom.y;this._needDraw=!(na||sc)},n._updateDisplayColor=function(t){_ccsg.Node.WebGLRenderCmd.prototype._updateDisplayColor.call(this,t),this._originalTexture=this._textureToRender=null},n._syncDisplayColor=function(t){_ccsg.Node.WebGLRenderCmd.prototype._syncDisplayColor.call(this,t),this._originalTexture=this._textureToRender=null},n.setState=function(t){this._state!==t&&(this._state=t,this._originalTexture=this._textureToRender=null)},n.rendering=function(t,e,i){var n=this._node,r=this._displayedOpacity,s=r/255,o=null;if(n._spriteFrame&&(o=n._spriteFrame._texture),n.loaded()&&0!==r){if((null===this._textureToRender||this._originalTexture!==o)&&(this._textureToRender=this._originalTexture=o,cc.Scale9Sprite.state.GRAY===this._state&&(this._textureToRender=this._textureToRender._generateGrayTexture()),cc.sys.browserType!==cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB)){var a=n.getDisplayedColor();!o||255===a.r&&255===a.g&&255===a.b||(this._textureToRender=this._textureToRender._generateColorTexture(a.r,a.g,a.b))}var c=t||cc._renderContext,h=c.getContext();if(c.setTransform(this._worldTransform,e,i),c.setCompositeOperation(_ccsg.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(n._blendFunc)),c.setGlobalAlpha(s),this._textureToRender){n._quadsDirty&&n._rebuildQuads();var l,u,_,d,f,p,m,g,y=this._textureToRender.width,v=this._textureToRender.height,x=this._textureToRender._image,C=n._vertices,T=n._uvs,b=0,A=0;if(n._isTriangle){var S=n._rawVerts,w=n._rawUvs;f=S[0],p=S[1],m=S[6]-f,p=-p-(g=S[7]-p),l=w[4]*y,u=w[5]*v,_=(w[6]-w[0])*y,d=(w[1]-w[7])*v,c.save(),h.beginPath();var E=Math.floor(n._vertCount/3);for(b=0,A=0;b0&&d>0&&m>0&&g>0&&h.drawImage(x,l,u,_,d,f,p,m,g),c.restore(),cc.g_NumberOfDraws+=E}else if(n._renderingType===cc.Scale9Sprite.RenderingType.SLICED){for(var I=0;I<3;++I)for(var R=0;R<3;++R)f=C[A=8*I+2*R],p=C[A+1],m=C[A+10]-f,p=-p-(g=C[A+11]-p),l=T[A]*y,u=T[A+11]*v,_=(T[A+10]-T[A])*y,d=(T[A+1]-T[A+11])*v,_>0&&d>0&&m>0&&g>0&&h.drawImage(x,l,u,_,d,f,p,m,g);cc.g_NumberOfDraws+=9}else{var P=Math.floor(n._vertCount/4);for(b=0,A=0;b0&&d>0&&m>0&&g>0&&h.drawImage(x,l,u,_,d,f,p,m,g),A+=8;cc.g_NumberOfDraws+=P}}}}}),{}],213:[(function(t,e,i){cc.gl;cc.Scale9Sprite.WebGLRenderCmd=function(t){this._rootCtor(t),this._node.loaded()?this._needDraw=!0:this._needDraw=!1,this.vertexType=cc.renderer.VertexType.QUAD,this._dirty=!1,this._shaderProgram=cc.shaderCache.programForKey(cc.macro.SHADER_SPRITE_POSITION_TEXTURECOLOR)};var n=cc.Scale9Sprite,r=n.WebGLRenderCmd.prototype=Object.create(_ccsg.Node.WebGLRenderCmd.prototype);r.constructor=n.WebGLRenderCmd,r._uploadSliced=function(t,e,i,n,r,s,o){for(var a,c=0;c<3;++c)for(var h=0;h<3;++h)a=8*c+2*h,r[o]=t[a],r[o+1]=t[a+1],r[o+2]=n,s[o+3]=i,r[o+4]=e[a],r[o+5]=e[a+1],r[o+=6]=t[a+2],r[o+1]=t[a+3],r[o+2]=n,s[o+3]=i,r[o+4]=e[a+2],r[o+5]=e[a+3],r[o+=6]=t[a+8],r[o+1]=t[a+9],r[o+2]=n,s[o+3]=i,r[o+4]=e[a+8],r[o+5]=e[a+9],r[o+=6]=t[a+10],r[o+1]=t[a+11],r[o+2]=n,s[o+3]=i,r[o+4]=e[a+10],r[o+5]=e[a+11],o+=6;return 36},r.updateTransform=function(t){this.originUpdateTransform(t),this._node._rebuildQuads()},r._doCulling=function(){var t=this._node,e=cc.visibleRect;this._cameraFlag>0&&(e=cc.Camera.main.visibleRect);var i=e.left.x,n=e.right.x,r=e.top.y,s=e.bottom.y,o=t._vertices,a=t._corner,c=a[0],h=a[1],l=a[2],u=a[3],_=o[c],d=o[h],f=o[l],p=o[u],m=o[c+1],g=o[h+1],y=o[l+1],v=o[u+1];this._needDraw=!((_-i&d-i&f-i&p-i)>>31||(n-_&n-d&n-f&n-p)>>31||(m-s&g-s&y-s&v-s)>>31||(r-m&r-g&r-y&r-v)>>31)},r.uploadData=function(t,e,i){var r=this._node;if(0===this._displayedOpacity)return 0;r._quadsDirty&&r._rebuildQuads(),r._distortionOffset&&this._shaderProgram===n.WebGLRenderCmd._distortionProgram&&(this._shaderProgram.use(),this._shaderProgram.setUniformLocationWith2f(n.WebGLRenderCmd._distortionOffset,r._distortionOffset.x,r._distortionOffset.y),this._shaderProgram.setUniformLocationWith2f(n.WebGLRenderCmd._distortionTiling,r._distortionTiling.x,r._distortionTiling.y),cc.renderer._breakBatch());var s,o=this._displayedOpacity,a=this._displayedColor._val;if(r._opacityModifyRGB){var c=o/255,h=this._displayedColor.r*c,l=this._displayedColor.g*c;s=(o<<24>>>0)+(this._displayedColor.b*c<<16)+(l<<8)+h}else s=(o<<24>>>0)+((65280&a)<<8)+((16711680&a)>>8)+(a>>>24);var u=r._vertexZ,_=r._vertices,d=r._uvs,f=n.RenderingType,p=i,m=0;switch(r._renderingType){case f.SIMPLE:case f.TILED:case f.FILLED:case f.MESH:m=this._node._vertCount;for(var g=0,y=0;gt.getPixelWidth()&&cc.errorID(3300,t.url+"/"+this.name),n>t.getPixelHeight()&&cc.errorID(3400,t.url+"/"+this.name)},_serialize:!1,_deserialize:function(t,e){var i=t.rect;i&&this.setRect(new cc.Rect(i[0],i[1],i[2],i[3])),t.offset&&this.setOffset(new cc.Vec2(t.offset[0],t.offset[1])),t.originalSize&&this.setOriginalSize(new cc.Size(t.originalSize[0],t.originalSize[1])),this._rotated=1===t.rotated,this._name=t.name;var n=t.capInsets;n&&(this.insetLeft=n[0],this.insetTop=n[1],this.insetRight=n[2],this.insetBottom=n[3]);var r=t.texture;if(r){var s=e.customEnv&&e.customEnv.deferredLoadRaw?"_textureFilename":"_textureFilenameSetter";e.result.push(this,s,r)}}});var r=cc.SpriteFrame.prototype;r.copyWithZone=r.clone,r.copy=r.clone,r.initWithTexture=r.setTexture}),{"../assets/CCAsset":43,"../event/event-target":112}],216:[(function(t,e,i){var n=t("../event/event-target"),r=t("../platform/CCSys"),s=(t("../platform/js"),t("../utils/misc"),t("../CCGame"));t("../platform/_CCClass"),t("../platform/CCClass");var o=[{format:6407,internalFormat:6407,pixelType:33635},{format:6408,internalFormat:6408,pixelType:32820},{format:6408,internalFormat:6408,pixelType:32819},{format:6407,internalFormat:6407,pixelType:5121},{format:6408,internalFormat:6408,pixelType:5121},{format:6406,internalFormat:6406,pixelType:5121},{format:6409,internalFormat:6409,pixelType:5121},{format:6410,internalFormat:6410,pixelType:5121}],a=cc.Enum({RGB565:0,RGB5A1:1,RGBA4444:2,RGB888:3,RGBA8888:4,A8:5,I8:6,AI8:7}),c=cc.Enum({REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648}),h=cc.Enum({LINEAR:9729,NEAREST:9728}),l=cc.Class({name:"cc.Texture2D",extends:t("../assets/CCRawAsset"),mixins:[n],properties:{_hasMipmap:!1,_format:a.RGBA8888,_compressed:!1,_premultiplyAlpha:!1,_minFilter:h.LINEAR,_magFilter:h.LINEAR,_wrapS:c.CLAMP_TO_EDGE,_wrapT:c.CLAMP_TO_EDGE},statics:{PixelFormat:a,WrapMode:c,Filter:h},ctor:function(t){this.url=null,this.loaded=!1,this.width=0,this.height=0,this._image=null,cc._renderType===s.RENDER_TYPE_CANVAS?(this._pattern="",this._grayElementObj=null,this._backupElement=null,this._isGray=!1):cc._renderType===s.RENDER_TYPE_WEBGL&&(this._gl=t||cc._renderContext,this._glID=null)},update:function(t){},getPixelWidth:function(){return this.width},getPixelHeight:function(){return this.height},getContentSize:function(){return cc.size(this.width,this.height)},getContentSizeInPixels:function(){return this.getContentSize()},initWithElement:function(t){t&&(this._image=t,this.width=t.width,this.height=t.height,this.loaded=!0)},initWithData:function(t,e,i,n,r){return!1},initWithImage:function(t){return!1},getHtmlElementObj:function(){return this._image},isLoaded:function(){return this.loaded},handleLoadedTexture:function(){if(this._image&&this._image.width&&this._image.height){var t=this._image;this.width=t.width,this.height=t.height,this.loaded=!0,this.emit("load")}},description:function(){return""},releaseTexture:function(){this._gl&&null!==this._glID&&this._gl.deleteTexture(this._glID)},getPixelFormat:function(){return this._format},hasPremultipliedAlpha:function(){return this._premultiplyAlpha||!1},hasMipmaps:function(){return this._hasMipmap||!1},setTexParameters:function(t,e,i,n){void 0!==e&&(t={minFilter:t,magFilter:e,wrapS:i,wrapT:n}),t.wrapS!==c.REPEAT||t.wrapT!==c.REPEAT?t.wrapS!==c.REPEAT?t.wrapT!==c.REPEAT?this._pattern="":this._pattern="repeat-y":this._pattern="repeat-x":this._pattern="repeat"},setAntiAliasTexParameters:function(){},setAliasTexParameters:function(){}}),u=l.prototype;u.pixelFormat,cc.defineGetterSetter(u,"pixelFormat",u.getPixelFormat),u.pixelWidth,cc.defineGetterSetter(u,"pixelWidth",u.getPixelWidth),u.pixelHeight,cc.defineGetterSetter(u,"pixelHeight",u.getPixelHeight),s.once(s.EVENT_RENDERER_INITED,(function(){if(cc._renderType===s.RENDER_TYPE_CANVAS){var t=function(t,e,i){if(null===t)return null;i=i||document.createElement("canvas"),e=e||cc.rect(0,0,t.width,t.height),i.width=e.width,i.height=e.height;var n=i.getContext("2d");n.drawImage(t,e.x,e.y,e.width,e.height,0,0,e.width,e.height);for(var r=n.getImageData(0,0,e.width,e.height),s=r.data,o=0,a=s.length;o"},textureForKey:function(t){return cc.logID(3002),this.getTextureForKey(t)},getTextureForKey:function(t){return this._textures[t]},getKeyByTexture:function(t){for(var e in this._textures)if(this._textures[e]===t)return e;return null},_generalTextureKey:function(t){return"_textureKey_"+t},getTextureColors:function(t){var e=t._image,i=this.getKeyByTexture(e);return i||(i=e instanceof HTMLImageElement?e.src:this._generalTextureKey(t.__instanceId)),this._textureColorsCache[i]||(this._textureColorsCache[i]=t._generateTextureCacheForColor()),this._textureColorsCache[i]},getAllTextures:function(){var t=[];for(var e in this._textures){var i=this._textures[e];t.push(i)}return t},removeAllTextures:function(){var t=this._textures;for(var e in t)t[e]&&t[e].releaseTexture();this._textures={}},removeTexture:function(t){if(t){var e=this._textures;for(var i in e)e[i]===t&&(e[i].releaseTexture(),delete e[i])}},removeTextureForKey:function(t){if("string"==typeof t){var e=this._textures;e[t]&&(e[t].releaseTexture(),delete e[t])}},addImage:null,addImageAsync:null,cacheImage:function(t,e){if(cc.assertID(t,3009),e instanceof r)this._textures[t]=e;else{var i=new r;i.initWithElement(e),i.handleLoadedTexture(),this._textures[t]=i}},dumpCachedTextureInfo:function(){var t=0,e=0,i=this._textures;for(var n in i){var r=i[n];t++,r.getHtmlElementObj()instanceof HTMLImageElement?cc.logID(3005,n,r.getHtmlElementObj().src,r.getPixelWidth(),r.getPixelHeight()):cc.logID(3006,n,r.getPixelWidth(),r.getPixelHeight()),e+=r.getPixelWidth()*r.getPixelHeight()*4}var s=this._textureColorsCache;for(n in s){var o=s[n];for(var a in o){var c=o[a];t++,cc.logID(3006,n,c.width,c.height),e+=c.width*c.height*4}}cc.logID(3007,t,e/1024,(e/1048576).toFixed(2))},_clear:function(){this._textures={},this._textureColorsCache={},this._textureKeySeq=0|1e3*Math.random()}};n.once(n.EVENT_RENDERER_INITED,(function(){var t=s;cc._renderType===n.RENDER_TYPE_CANVAS?(t.handleLoadedTexture=function(t){var e=this._textures,i=e[t];i||(cc.assertID(t,3009),(i=e[t]=new r).url=t),i.handleLoadedTexture()},t.addImage=function(t,e,i){cc.assertID(t,3103);var n=this._textures,o=n[t];return o?o.isLoaded()?(e&&e.call(i,o),o):(o.once("load",(function(){e&&e.call(i,o)}),i),o):(o=n[t]=new r,o.url=t,cc.loader.load(t,(function(n,r){if(n)return e&&e.call(i,n||new Error("Unknown error"));s.handleLoadedTexture(t),e&&e.call(i,o)})),o)},t.addImageAsync=t.addImage):cc._renderType===n.RENDER_TYPE_WEBGL&&(t.handleLoadedTexture=function(t){var e,i=this._textures;(e=i[t])||(cc.assertID(t,3009),(e=i[t]=new r).url=t),e.handleLoadedTexture()},t.addImage=function(t,e,i){cc.assertID(t,3112);var n=this._textures,o=n[t];return o?o.isLoaded()?(e&&e.call(i,o),o):(o.once("load",(function(){e&&e.call(i,o)}),i),o):(o=n[t]=new r,o.url=t,cc.loader.load(t,(function(n,r){if(n)return e&&e.call(i,n||new Error("Unknown error"));s.handleLoadedTexture(t),e&&e.call(i,o)})),o)},t.addImageAsync=t.addImage)})),cc.textureCache=e.exports=s}),{"../CCGame":39,"./CCTexture2D":216}],218:[(function(t,e,i){t("./CCTexture2D"),t("./CCTextureCache")}),{"./CCTexture2D":216,"./CCTextureCache":217}],219:[(function(t,e,i){t("../platform/CCSys");var n=/(\.[^\.\/\?\\]*)(\?.*)?$/,r=/((.*)(\/|\\|\\\\))?(.*?\..*$)?/,s=/[^\.\/]+\/\.\.\//;cc.path={join:function(){for(var t=arguments.length,e="",i=0;i0&&(t=t.substring(0,i));var n=/(\/|\\\\)([^(\/|\\\\)]+)$/g.exec(t.replace(/(\/|\\\\)$/,""));if(!n)return null;var r=n[2];return e&&t.substring(t.length-e.length).toLowerCase()===e.toLowerCase()?r.substring(0,r.length-e.length):r},dirname:function(t){var e=r.exec(t);return e?e[2]:""},changeExtname:function(t,e){e=e||"";var i=t.indexOf("?"),n="";return i>0&&(n=t.substring(i),t=t.substring(0,i)),(i=t.lastIndexOf("."))<0?t+e+n:t.substring(0,i)+e+n},changeBasename:function(t,e,i){if(0===e.indexOf("."))return this.changeExtname(t,e);var n=t.indexOf("?"),r="",s=i?this.extname(t):"";return n>0&&(r=t.substring(n),t=t.substring(0,n)),n=t.lastIndexOf("/"),n=n<=0?0:n+1,t.substring(0,n)+e+s+r},_normalize:function(t){var e=t=String(t);do{e=t,t=t.replace(s,"")}while(e.length!==t.length);return t},sep:cc.sys.os===cc.sys.OS_WINDOWS?"\\":"/",stripSep:function(t){return t.replace(/[\/\\]$/,"")}},e.exports=cc.path}),{"../platform/CCSys":185}],220:[(function(t,e,i){function n(){h("frame").start(),h("logic").start()}function r(){cc.director.isPaused()?h("frame").start():h("logic").end(),h("render").start()}function s(){h("render").end(),h("draws").value=cc.g_NumberOfDraws,h("frame").end(),h("fps").frame(),h().tick()}var o=t("../../../external/pstats/pstats"),a=t("../platform/CCMacro"),c=document.createElement("div");c.id="fps";var h=null,l=!1;cc.profiler=e.exports={isShowingStats:function(){return l},hideStats:function(){l&&(c.parentElement===document.body&&document.body.removeChild(c),cc.director.off(cc.Director.EVENT_BEFORE_UPDATE,n),cc.director.off(cc.Director.EVENT_AFTER_VISIT,r),cc.director.off(cc.Director.EVENT_AFTER_DRAW,s),l=!1)},showStats:function(){l||(h||(h=o.new(c,{showGraph:!1,values:{frame:{desc:"Frame time (ms)",min:0,max:50,average:500},fps:{desc:"Framerate (FPS)",below:30,average:500},draws:{desc:"Draw call"},logic:{desc:"Game Logic (ms)",min:0,max:50,average:500,color:"#080"},render:{desc:"Renderer (ms)",min:0,max:50,average:500,color:"#f90"},mode:{desc:cc._renderType===cc.game.RENDER_TYPE_WEBGL?"WebGL":"Canvas",min:1}},css:".pstats {left: "+a.DIRECTOR_STATS_POSITION.x+"px; bottom: "+a.DIRECTOR_STATS_POSITION.y+"px;}"})),null===c.parentElement&&document.body.appendChild(c),cc.director.on(cc.Director.EVENT_BEFORE_UPDATE,n),cc.director.on(cc.Director.EVENT_AFTER_VISIT,r),cc.director.on(cc.Director.EVENT_AFTER_DRAW,s),l=!0)}}}),{"../../../external/pstats/pstats":312,"../platform/CCMacro":181}],221:[(function(t,e,i){function n(t){return t?"string"==typeof t?_.getClassByName(t):t:(cc.errorID(3804),null)}function r(t,e){if(e._sealed)for(var i=0;i0&&(s=o(n._children,e)))return s}return null}function a(t,e,i){for(var n=0;n0&&a(r._children,e,i)}}var c=t("../platform/CCObject").Flags,h=t("./misc"),l=t("../platform/id-generater"),u=t("../event-manager"),_=cc.js,d=c.Destroying,f=c.DontDestroy,p=new l("Node"),m=cc.Class({name:"cc._BaseNode",extends:cc.Object,mixins:[cc.EventTarget],properties:{_parent:null,_children:[],_tag:cc.macro.NODE_TAG_INVALID,_active:!0,_components:[],_prefab:null,_persistNode:{get:function(){return(this._objFlags&f)>0},set:function(t){t?this._objFlags|=f:this._objFlags&=~f}},name:{get:function(){return this._name},set:function(t){this._name=t}},_id:{default:"",editorOnly:!0},uuid:{get:function(){var t=this._id;return t||(t=this._id=p.getNewId()),t}},children:{get:function(){return this._children}},childrenCount:{get:function(){return this._children.length}},active:{get:function(){return this._active},set:function(t){if(t=!!t,this._active!==t){this._active=t;var e=this._parent;if(e){e._activeInHierarchy&&cc.director._nodeActivator.activateNode(this,t)}}}},activeInHierarchy:{get:function(){return this._activeInHierarchy}}},ctor:function(t){this._name=void 0!==t?t:"New Node",this._activeInHierarchy=!1,this.__instanceId=this._id||cc.ClassManager.getNewInstanceId(),this.__eventTargets=[]},getTag:function(){return this._tag},setTag:function(t){this._tag=t},getParent:function(){return this._parent},setParent:function(t){if(this._parent!==t){0;var e=this._parent;if(this._parent=t||null,this._onSetParent(t),t&&(u._setDirtyForNode(this),t._children.push(this),t.emit("child-added",this)),e){if(!(e._objFlags&d)){var i=e._children.indexOf(this);0,e._children.splice(i,1),e.emit("child-removed",this),this._onHierarchyChanged(e)}}else t&&this._onHierarchyChanged(null)}},init:function(){return!0},attr:function(t){_.mixin(this,t)},getChildByTag:function(t){var e=this._children;if(null!==e)for(var i=0;i-1&&((e||void 0===e)&&t.cleanup(),t.parent=null)},removeChildByTag:function(t,e){t===cc.macro.NODE_TAG_INVALID&&cc.logID(1609);var i=this.getChildByTag(t);i?this.removeChild(i,e):cc.logID(1610,t)},removeAllChildren:function(t){var e=this._children;void 0===t&&(t=!0);for(var i=e.length-1;i>=0;i--){var n=e[i];n&&(t&&n.cleanup(),n.parent=null)}this._children.length=0},isChildOf:function(t){var e=this;do{if(e===t)return!0;e=e._parent}while(e);return!1},getComponent:function(t){var e=n(t);return e?r(this,e):null},getComponents:function(t){var e=n(t),i=[];return e&&s(this,e,i),i},getComponentInChildren:function(t){var e=n(t);return e?o(this._children,e):null},getComponentsInChildren:function(t){var e=n(t),i=[];return e&&(s(this,e,i),a(this._children,e,i)),i},_checkMultipleComp:!1,addComponent:function(t){var e;if("string"==typeof t){if(!(e=_.getClassByName(t)))return cc.errorID(3807,t),cc._RFpeek()&&cc.errorID(3808,t),null}else{if(!t)return cc.errorID(3804),null;e=t}if("function"!=typeof e)return cc.errorID(3809),null;if(!cc.isChildClassOf(e,cc.Component))return cc.errorID(3810),null;var i=e._requireComponent;if(i&&!this.getComponent(i)){if(!this.addComponent(i))return null}var n=new e;return n.node=this,this._components.push(n),this._activeInHierarchy&&cc.director._nodeActivator.activateComp(n),n},_addComponentAt:!1,removeComponent:function(t){t?(t instanceof cc.Component||(t=this.getComponent(t)),t&&t.destroy()):cc.errorID(3813)},_getDependComponent:!1,_removeComponent:function(t){if(t){if(!(this._objFlags&d)){var e=this._components.indexOf(t);-1!==e?this._components.splice(e,1):t.node!==this&&cc.errorID(3815)}}else cc.errorID(3814)},_disableChildComps:function(){var t,e=this._components.length;for(t=0;t>>1;i<=r;s=i+r>>>1){var o=t[s];if(o>e+n)r=s-1;else{if(!(o>2],o[a[i++]]=r[(3&s)<<2|c>>4],o[a[i++]]=r[15&c]}return o.join("")}}),{"./misc":226}],224:[(function(t,e,i){cc.find=e.exports=function(t,e){if(null==t)return cc.errorID(5600),null;if(e)0;else{var i=cc.director.getScene();if(!i)return null;e=i}for(var n=e,r="/"!==t[0]?0:1,s=t.split("/"),o=r;o>1,t|=t>>2,t|=t>>4,t|=t>>8,(t|=t>>16)+1},s.imagePool=new n.Pool(function(t){return t instanceof HTMLImageElement&&(t.src=this._smallImg,!0)},10),s.imagePool.get=function(){return this._get()||new Image},s.imagePool._smallImg="data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA=",r.os!==r.OS_WINDOWS&&r.os!==r.OS_LINUX||r.browserType===r.BROWSER_TYPE_CHROME||s.imagePool.resize(0),s.BUILTIN_CLASSID_RE=/^(?:cc|dragonBones|sp|ccsg)\..+/;for(var o=new Array(123),a=0;a<123;++a)o[a]=64;for(var c=0;c<64;++c)o["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charCodeAt(c)]=c;s.BASE64_VALUES=o,s.pushToMap=function(t,e,i,n){var r=t[e];r?Array.isArray(r)?n?(r.push(r[0]),r[0]=i):r.push(i):t[e]=n?[i,r]:[r,i]:t[e]=i}}),{"../platform/CCSys":185,"../platform/js":197}],227:[(function(t,e,i){function n(t){this.i=0,this.array=t}var r=n.prototype;r.remove=function(t){var e=this.array.indexOf(t);e>=0&&this.removeAt(e)},r.removeAt=function(t){this.array.splice(t,1),t<=this.i&&--this.i},r.fastRemove=function(t){var e=this.array.indexOf(t);e>=0&&this.fastRemoveAt(e)},r.fastRemoveAt=function(t){var e=this.array;e[t]=e[e.length-1],--e.length,t<=this.i&&--this.i},r.push=function(t){this.array.push(t)},e.exports=n}),{}],228:[(function(t,e,i){cc._PrefabInfo=cc.Class({name:"cc.PrefabInfo",properties:{root:null,asset:null,fileId:"",sync:!1,_synced:{default:!1,serializable:!1}}}),e.exports={syncWithPrefab:function(t){var e=t._prefab;if(e._synced=!0,!e.asset)return cc.errorID(3701,t.name),void(t._prefab=null);var i=t._objFlags,n=t._parent,r=t._id,s=t._name,o=t._active,a=t._position.x,c=t._position.y,h=t._rotationX,l=t._rotationY,u=t._localZOrder,_=t._globalZOrder;cc.game._isCloning=!0;e.asset._doInstantiate(t),cc.game._isCloning=!1,t._objFlags=i,t._parent=n,t._id=r,t._prefab=e,t._name=s,t._active=o,t._position.x=a,t._position.y=c,t._rotationX=h,t._rotationY=l,t._localZOrder=u,t._globalZOrder=_}}}),{}],229:[(function(t,e,i){var n={removeSgNode:function(){var t=this._sgNode;if(t){var e=t._parent;e?e.removeChild(t):t.performRecursive(_ccsg.Node.performType.cleanup),t._entity&&(t._entity=null)}}};e.exports=n}),{}],230:[(function(t,e,i){cc.AffineTransform=function(t,e,i,n,r,s){this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,this.ty=s},cc.affineTransformMake=function(t,e,i,n,r,s){return{a:t,b:e,c:i,d:n,tx:r,ty:s}},cc.affineTransformClone=function(t){return{a:t.a,b:t.b,c:t.c,d:t.d,tx:t.tx,ty:t.ty}},cc.pointApplyAffineTransform=function(t,e,i){var n,r;return void 0===i?(i=e,n=t.x,r=t.y):(n=t,r=e),{x:i.a*n+i.c*r+i.tx,y:i.b*n+i.d*r+i.ty}},cc._pointApplyAffineTransformIn=function(t,e,i,n){var r,s,o;void 0===n?(o=e,r=t.x,s=t.y,n=i):(r=t,s=e,o=i),n.x=o.a*r+o.c*s+o.tx,n.y=o.b*r+o.d*s+o.ty},cc._pointApplyAffineTransform=function(t,e,i){return cc.pointApplyAffineTransform(t,e,i)},cc.sizeApplyAffineTransform=function(t,e){return{width:e.a*t.width+e.c*t.height,height:e.b*t.width+e.d*t.height}},cc.affineTransformMakeIdentity=function(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}},cc.affineTransformIdentity=function(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}},cc.rectApplyAffineTransform=function(t,e){var i=t.x,n=t.y,r=i+t.width,s=n+t.height,o=e.a*i+e.c*n+e.tx,a=e.b*i+e.d*n+e.ty,c=e.a*r+e.c*n+e.tx,h=e.b*r+e.d*n+e.ty,l=e.a*i+e.c*s+e.tx,u=e.b*i+e.d*s+e.ty,_=e.a*r+e.c*s+e.tx,d=e.b*r+e.d*s+e.ty,f=Math.min(o,c,l,_),p=Math.max(o,c,l,_),m=Math.min(a,h,u,d),g=Math.max(a,h,u,d);return cc.rect(f,m,p-f,g-m)},cc._rectApplyAffineTransformIn=function(t,e){var i=t.x,n=t.y,r=i+t.width,s=n+t.height,o=e.a*i+e.c*n+e.tx,a=e.b*i+e.d*n+e.ty,c=e.a*r+e.c*n+e.tx,h=e.b*r+e.d*n+e.ty,l=e.a*i+e.c*s+e.tx,u=e.b*i+e.d*s+e.ty,_=e.a*r+e.c*s+e.tx,d=e.b*r+e.d*s+e.ty,f=Math.min(o,c,l,_),p=Math.max(o,c,l,_),m=Math.min(a,h,u,d),g=Math.max(a,h,u,d);return t.x=f,t.y=m,t.width=p-f,t.height=g-m,t},cc.obbApplyAffineTransform=function(t,e,i,n,r,s){var o=t.x,a=t.y,c=t.width,h=t.height,l=e.a*o+e.c*a+e.tx,u=e.b*o+e.d*a+e.ty,_=e.a*c,d=e.b*c,f=e.c*h,p=e.d*h;n.x=l,n.y=u,r.x=_+l,r.y=d+u,i.x=f+l,i.y=p+u,s.x=_+f+l,s.y=d+p+u},cc.affineTransformTranslate=function(t,e,i){return{a:t.a,b:t.b,c:t.c,d:t.d,tx:t.tx+t.a*e+t.c*i,ty:t.ty+t.b*e+t.d*i}},cc.affineTransformScale=function(t,e,i){return{a:t.a*e,b:t.b*e,c:t.c*i,d:t.d*i,tx:t.tx,ty:t.ty}},cc.affineTransformRotate=function(t,e){var i=Math.sin(e),n=Math.cos(e);return{a:t.a*n+t.c*i,b:t.b*n+t.d*i,c:t.c*n-t.a*i,d:t.d*n-t.b*i,tx:t.tx,ty:t.ty}},cc.affineTransformConcat=function(t,e){return{a:t.a*e.a+t.b*e.c,b:t.a*e.b+t.b*e.d,c:t.c*e.a+t.d*e.c,d:t.c*e.b+t.d*e.d,tx:t.tx*e.a+t.ty*e.c+e.tx,ty:t.tx*e.b+t.ty*e.d+e.ty}},cc.affineTransformConcatIn=function(t,e){var i=t.a,n=t.b,r=t.c,s=t.d,o=t.tx,a=t.ty;return t.a=i*e.a+n*e.c,t.b=i*e.b+n*e.d,t.c=r*e.a+s*e.c,t.d=r*e.b+s*e.d,t.tx=o*e.a+a*e.c+e.tx,t.ty=o*e.b+a*e.d+e.ty,t},cc.affineTransformEqualToTransform=function(t,e){return t.a===e.a&&t.b===e.b&&t.c===e.c&&t.d===e.d&&t.tx===e.tx&&t.ty===e.ty},cc.affineTransformInvert=function(t){var e=1/(t.a*t.d-t.b*t.c);return{a:e*t.d,b:-e*t.b,c:-e*t.c,d:e*t.a,tx:e*(t.c*t.ty-t.d*t.tx),ty:e*(t.b*t.tx-t.a*t.ty)}},cc.affineTransformInvertIn=function(t){var e=t.a,i=t.b,n=t.c,r=t.d,s=1/(e*r-i*n),o=t.tx,a=t.ty;return t.a=s*r,t.b=-s*i,t.c=-s*n,t.d=s*e,t.tx=s*(n*a-r*o),t.ty=s*(i*o-e*a),t},cc.affineTransformInvertOut=function(t,e){var i=t.a,n=t.b,r=t.c,s=t.d,o=1/(i*s-n*r);e.a=o*s,e.b=-o*n,e.c=-o*r,e.d=o*i,e.tx=o*(r*t.ty-s*t.tx),e.ty=o*(n*t.tx-i*t.ty)}}),{}],231:[(function(t,e,i){var n=t("./CCValueType"),r=t("../platform/js"),s=(function(){function e(t,e,i,n){"object"==typeof t&&(e=t.g,i=t.b,n=t.a,t=t.r),t=t||0,e=e||0,i=i||0,n="number"==typeof n?n:255,this._val=(~~t<<24>>>0)+(~~e<<16)+(~~i<<8)+~~n}r.extend(e,n),t("../platform/CCClass").fastDefine("cc.Color",e,{r:0,g:0,b:0,a:255});var i={WHITE:[255,255,255,255],BLACK:[0,0,0,255],TRANSPARENT:[0,0,0,0],GRAY:[127.5,127.5,127.5],RED:[255,0,0],GREEN:[0,255,0],BLUE:[0,0,255],YELLOW:[255,235,4],ORANGE:[255,127,0],CYAN:[0,255,255],MAGENTA:[255,0,255]};for(var s in i)r.get(e,s,(function(t){return function(){return new e(t[0],t[1],t[2],t[3])}})(i[s]));var o=e.prototype;return o.clone=function(){var t=new e;return t._val=this._val,t},o.equals=function(t){return t&&this._val===t._val},o.lerp=function(t,i,n){n=n||new e;var r=this.r,s=this.g,o=this.b,a=this.a;return n.r=r+(t.r-r)*i,n.g=s+(t.g-s)*i,n.b=o+(t.b-o)*i,n.a=a+(t.a-a)*i,n},o.toString=function(){return"rgba("+this.r.toFixed()+", "+this.g.toFixed()+", "+this.b.toFixed()+", "+this.a.toFixed()+")"},o.getR=function(){return(4278190080&this._val)>>>24},o.setR=function(t){return this._val=(16777215&this._val|~~t<<24>>>0)>>>0,this},o.getG=function(){return(16711680&this._val)>>16},o.setG=function(t){return this._val=(4278255615&this._val|~~t<<16)>>>0,this},o.getB=function(){return(65280&this._val)>>8},o.setB=function(t){return this._val=(4294902015&this._val|~~t<<8)>>>0,this},o.getA=function(){return 255&this._val},o.setA=function(t){return this._val=(4294967040&this._val|~~t)>>>0,this},r.getset(o,"r",o.getR,o.setR,!0),r.getset(o,"g",o.getG,o.setG,!0),r.getset(o,"b",o.getB,o.setB,!0),r.getset(o,"a",o.getA,o.setA,!0),o.toCSS=function(t){return"rgba"===t?"rgba("+(0|this.r)+","+(0|this.g)+","+(0|this.b)+","+(this.a/255).toFixed(2)+")":"rgb"===t?"rgb("+(0|this.r)+","+(0|this.g)+","+(0|this.b)+")":"#"+this.toHEX(t)},o.clamp=function(){},o.fromHEX=function(t){t.length<8&&(t+="FF");var e=parseInt(t.indexOf("#")>-1?t.substring(1):t,16);return this._val=(0&this._val|e)>>>0,this},o.toHEX=function(t){var e=[(0|this.r).toString(16),(0|this.g).toString(16),(0|this.b).toString(16)],i=-1;if("#rgb"===t)for(i=0;i1&&(e[i]=e[i][0]);else if("#rrggbb"===t)for(i=0;i>>0)+(r.g<<16)+(r.b<<8)+this.a,this},o.toHSV=function(){return e.rgb2hsv(this.r,this.g,this.b)},o.fromColor=function(t){t._val?this._val=t._val:(this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a)},e})();s.rgb2hsv=function(t,e,i){t/=255,e/=255,i/=255;var n={h:0,s:0,v:0},r=Math.max(t,e,i),s=Math.min(t,e,i),o=0;return n.v=r,n.s=r?(r-s)/r:0,n.s?(o=r-s,n.h=t===r?(e-i)/o:e===r?2+(i-t)/o:4+(t-e)/o,n.h/=6,n.h<0&&(n.h+=1)):n.h=0,n},s.hsv2rgb=function(t,e,i){var n={r:0,g:0,b:0};if(0===e)n.r=n.g=n.b=i;else if(0===i)n.r=n.g=n.b=0;else{1===t&&(t=0),t*=6,e=e,i=i;var r=Math.floor(t),s=t-r,o=i*(1-e),a=i*(1-e*s),c=i*(1-e*(1-s));switch(r){case 0:n.r=i,n.g=c,n.b=o;break;case 1:n.r=a,n.g=i,n.b=o;break;case 2:n.r=o,n.g=i,n.b=c;break;case 3:n.r=o,n.g=a,n.b=i;break;case 4:n.r=c,n.g=o,n.b=i;break;case 5:n.r=i,n.g=o,n.b=a}}return n.r*=255,n.g*=255,n.b*=255,n},cc.Color=s,cc.color=function(t,e,i,n){if("string"==typeof t){return(new cc.Color).fromHEX(t)}return"object"==typeof t?new cc.Color(t.r,t.g,t.b,t.a):new cc.Color(t,e,i,n)},cc.colorEqual=function(t,e){return void 0!==t._val&&void 0!==e._val?t._val===e._val:t.r===e.r&&t.g===e.g&&t.b===e.b},cc.hexToColor=function(t){t=t.replace(/^#?/,"0x");var e=parseInt(t),i=e>>16,n=(65280&e)>>8,r=255&e;return cc.color(i,n,r)},cc.colorToHex=function(t){var e=t.r.toString(16),i=t.g.toString(16),n=t.b.toString(16);return"#"+(t.r<16?"0"+e:e)+(t.g<16?"0"+i:i)+(t.b<16?"0"+n:n)},e.exports=cc.Color}),{"../platform/CCClass":176,"../platform/js":197,"./CCValueType":237}],232:[(function(t,e,i){var n=parseFloat("1.192092896e-07F");cc.pNeg=function(t){return cc.p(-t.x,-t.y)},cc.pAdd=function(t,e){return cc.p(t.x+e.x,t.y+e.y)},cc.pSub=function(t,e){return cc.p(t.x-e.x,t.y-e.y)},cc.pMult=function(t,e){return cc.p(t.x*e,t.y*e)},cc.pMidpoint=function(t,e){return cc.pMult(cc.pAdd(t,e),.5)},cc.pDot=function(t,e){return t.x*e.x+t.y*e.y},cc.pCross=function(t,e){return t.x*e.y-t.y*e.x},cc.pPerp=function(t){return cc.p(-t.y,t.x)},cc.pRPerp=function(t){return cc.p(t.y,-t.x)},cc.pProject=function(t,e){return cc.pMult(e,cc.pDot(t,e)/cc.pDot(e,e))},cc.pLengthSQ=function(t){return cc.pDot(t,t)},cc.pDistanceSQ=function(t,e){return cc.pLengthSQ(cc.pSub(t,e))},cc.pLength=function(t){return Math.sqrt(cc.pLengthSQ(t))},cc.pDistance=function(t,e){return cc.pLength(cc.pSub(t,e))},cc.pNormalize=function(t){var e=cc.pLength(t);return 0===e?cc.p(t):cc.pMult(t,1/e)},cc.pForAngle=function(t){return cc.p(Math.cos(t),Math.sin(t))},cc.pToAngle=function(t){return Math.atan2(t.y,t.x)},cc.clampf=function(t,e,i){if(e>i){var n=e;e=i,i=n}return t=0&&r.x<=1&&r.y>=0&&r.y<=1)},cc.pIntersectPoint=function(t,e,i,n){var r=cc.p(0,0);if(cc.pLineIntersect(t,e,i,n,r)){var s=cc.p(0,0);return s.x=t.x+r.x*(e.x-t.x),s.y=t.y+r.x*(e.y-t.y),s}return cc.p(0,0)},cc.pSameAs=function(t,e){return null!=t&&null!=e&&(t.x===e.x&&t.y===e.y)},cc.pZeroIn=function(t){t.x=0,t.y=0},cc.pIn=function(t,e){t.x=e.x,t.y=e.y},cc.pMultIn=function(t,e){t.x*=e,t.y*=e},cc.pSubIn=function(t,e){t.x-=e.x,t.y-=e.y},cc.pAddIn=function(t,e){t.x+=e.x,t.y+=e.y},cc.pNormalizeIn=function(t){cc.pMultIn(t,1/Math.sqrt(t.x*t.x+t.y*t.y))}}),{}],233:[(function(t,e,i){function n(t,e,i,n){t&&"object"==typeof t&&(e=t.y,i=t.width,n=t.height,t=t.x),this.x=t||0,this.y=e||0,this.width=i||0,this.height=n||0}var r=t("./CCValueType"),s=t("../platform/js");s.extend(n,r),t("../platform/CCClass").fastDefine("cc.Rect",n,{x:0,y:0,width:0,height:0}),n.fromMinMax=function(t,e){var i=Math.min(t.x,e.x),r=Math.min(t.y,e.y);return new n(i,r,Math.max(t.x,e.x)-i,Math.max(t.y,e.y)-r)},n.contain=function(t,e){return t.xe.x+e.width&&t.ye.y+e.height?1:e.xt.x+t.width&&e.yt.y+t.height?-1:0};var o=n.prototype;o.clone=function(){return new n(this.x,this.y,this.width,this.height)},o.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height},o.lerp=function(t,e,i){i=i||new n;var r=this.x,s=this.y,o=this.width,a=this.height;return i.x=r+(t.x-r)*e,i.y=s+(t.y-s)*e,i.width=o+(t.width-o)*e,i.height=a+(t.height-a)*e,i},o.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.width.toFixed(2)+", "+this.height.toFixed(2)+")"},s.getset(o,"xMin",(function(){return this.x}),(function(t){this.width+=this.x-t,this.x=t})),s.getset(o,"yMin",(function(){return this.y}),(function(t){this.height+=this.y-t,this.y=t})),s.getset(o,"xMax",(function(){return this.x+this.width}),(function(t){this.width=t-this.x})),s.getset(o,"yMax",(function(){return this.y+this.height}),(function(t){this.height=t-this.y})),s.getset(o,"center",(function(){return new cc.Vec2(this.x+.5*this.width,this.y+.5*this.height)}),(function(t){this.x=t.x-.5*this.width,this.y=t.y-.5*this.height})),s.getset(o,"origin",(function(){return new cc.Vec2(this.x,this.y)}),(function(t){this.x=t.x,this.y=t.y})),s.getset(o,"size",(function(){return new cc.Size(this.width,this.height)}),(function(t){this.width=t.width,this.height=t.height})),o.intersects=function(t){return cc.rectIntersectsRect(this,t)},o.contains=function(t){return this.x<=t.x&&this.x+this.width>=t.x&&this.y<=t.y&&this.y+this.height>=t.y},o.containsRect=function(t){return this.x<=t.x&&this.x+this.width>=t.x+t.width&&this.y<=t.y&&this.y+this.height>=t.y+t.height},cc.Rect=n,cc.rect=function(t,e,i,r){return new n(t,e,i,r)},cc.rectEqualToRect=function(t,e){return t&&e&&t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height},cc._rectEqualToZero=function(t){return t&&0===t.x&&0===t.y&&0===t.width&&0===t.height},cc.rectContainsRect=function(t,e){return!(!t||!e)&&!(t.x>=e.x||t.y>=e.y||t.x+t.width<=e.x+e.width||t.y+t.height<=e.y+e.height)},cc.rectGetMaxX=function(t){return t.x+t.width},cc.rectGetMidX=function(t){return t.x+t.width/2},cc.rectGetMinX=function(t){return t.x},cc.rectGetMaxY=function(t){return t.y+t.height},cc.rectGetMidY=function(t){return t.y+t.height/2},cc.rectGetMinY=function(t){return t.y},cc.rectContainsPoint=function(t,e){return e.x>=cc.rectGetMinX(t)&&e.x<=cc.rectGetMaxX(t)&&e.y>=cc.rectGetMinY(t)&&e.y<=cc.rectGetMaxY(t)},cc.rectIntersectsRect=function(t,e){var i=t.x+t.width,n=t.y+t.height,r=e.x+e.width,s=e.y+e.height;return!(i=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z},cc.math.AABB.containsPoint=function(t,e){return t.x>=e.min.x&&t.x<=e.max.x&&t.y>=e.min.y&&t.y<=e.max.y&&t.z>=e.min.z&&t.z<=e.max.z},cc.math.AABB.prototype.assignFrom=function(t){this.min.assignFrom(t.min),this.max.assignFrom(t.max)},cc.math.AABB.assign=function(t,e){return t.min.assignFrom(e.min),t.max.assignFrom(e.max),t}}),{}],245:[(function(t,e,i){cc.math.Matrix4Stack=function(t,e){this.top=t,this.stack=e||[],this.lastUpdated=0};var n=cc.math.Matrix4Stack.prototype;n.initialize=function(){this.stack.length=0,this.top=null},n.push=function(t){t=t||this.top,this.stack.push(this.top),this.top=new cc.math.Matrix4(t),this.update()},n.pop=function(){this.top=this.stack.pop(),this.update()},n.update=function(){this.lastUpdated++},n.release=function(){this.stack=null,this.top=null,this._matrixPool=null},n._getFromPool=function(t){var e=this._matrixPool;if(0===e.length)return new cc.math.Matrix4(t);var i=e.pop();return i.assignFrom(t),i},n._putInPool=function(t){this._matrixPool.push(t)}}),{}],246:[(function(t,e,i){var n=cc.math;n.KM_GL_MODELVIEW=5888,n.KM_GL_PROJECTION=5889,n.KM_GL_TEXTURE=5890,n.modelview_matrix_stack=new n.Matrix4Stack,n.projection_matrix_stack=new n.Matrix4Stack,n.texture_matrix_stack=new n.Matrix4Stack,cc.current_stack=null;var r=!1;(function(){if(!r){var t=new n.Matrix4;n.modelview_matrix_stack.initialize(),n.projection_matrix_stack.initialize(),n.texture_matrix_stack.initialize(),cc.current_stack=n.modelview_matrix_stack,r=!0,t.identity(),n.modelview_matrix_stack.push(t),n.projection_matrix_stack.push(t),n.texture_matrix_stack.push(t)}})(),n.glFreeAll=function(){n.modelview_matrix_stack.release(),n.modelview_matrix_stack=null,n.projection_matrix_stack.release(),n.projection_matrix_stack=null,n.texture_matrix_stack.release(),n.texture_matrix_stack=null,r=!1,cc.current_stack=null},n.glPushMatrix=function(){cc.current_stack.push(cc.current_stack.top),cc.current_stack.update()},n.glPushMatrixWitMat4=function(t){cc.current_stack.stack.push(cc.current_stack.top),t.assignFrom(cc.current_stack.top),cc.current_stack.top=t,cc.current_stack.update()},n.glPopMatrix=function(){cc.current_stack.top=cc.current_stack.stack.pop(),cc.current_stack.update()},n.glMatrixMode=function(t){switch(t){case n.KM_GL_MODELVIEW:cc.current_stack=n.modelview_matrix_stack;break;case n.KM_GL_PROJECTION:cc.current_stack=n.projection_matrix_stack;break;case n.KM_GL_TEXTURE:cc.current_stack=n.texture_matrix_stack;break;default:throw new Error("Invalid matrix mode specified")}},n.glLoadIdentity=function(){cc.current_stack.top.identity(),cc.current_stack.update()},n.glLoadMatrix=function(t){cc.current_stack.top.assignFrom(t),cc.current_stack.update()},n.glMultMatrix=function(t){cc.current_stack.top.multiply(t),cc.current_stack.update()};var s=new n.Matrix4;n.glTranslatef=function(t,e,i){var r=n.Matrix4.createByTranslation(t,e,i,s);cc.current_stack.top.multiply(r),cc.current_stack.update()};var o=new n.Vec3;n.glRotatef=function(t,e,i,r){o.fill(e,i,r);var a=n.Matrix4.createByAxisAndAngle(o,cc.degreesToRadians(t),s);cc.current_stack.top.multiply(a),cc.current_stack.update()},n.glScalef=function(t,e,i){var r=n.Matrix4.createByScale(t,e,i,s);cc.current_stack.top.multiply(r),cc.current_stack.update()},n.glGetMatrix=function(t,e){switch(t){case n.KM_GL_MODELVIEW:e.assignFrom(n.modelview_matrix_stack.top);break;case n.KM_GL_PROJECTION:e.assignFrom(n.projection_matrix_stack.top);break;case n.KM_GL_TEXTURE:e.assignFrom(n.texture_matrix_stack.top);break;default:throw new Error("Invalid matrix mode specified")}}}),{}],247:[(function(t,e,i){t("./utility"),t("./vec2"),t("./vec3"),t("./vec4"),t("./ray2"),t("./mat3"),t("./mat4"),t("./plane"),t("./quaternion"),t("./aabb"),t("./gl/mat4stack"),t("./gl/matrix")}),{"./aabb":244,"./gl/mat4stack":245,"./gl/matrix":246,"./mat3":248,"./mat4":249,"./plane":250,"./quaternion":251,"./ray2":252,"./utility":253,"./vec2":254,"./vec3":255,"./vec4":256}],248:[(function(t,e,i){window.Uint16Array=window.Uint16Array||window.Array,window.Float32Array=window.Float32Array||window.Array,cc.math.Matrix3=function(t){t&&t.mat?this.mat=new Float32Array(t.mat):this.mat=new Float32Array(9)};var n=cc.math.Matrix3.prototype;n.fill=function(t){var e=this.mat,i=t.mat;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},n.adjugate=function(){var t=this.mat,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],o=t[5],a=t[6],c=t[7],h=t[8];return t[0]=s*h-o*c,t[1]=n*c-i*h,t[2]=i*o-n*s,t[3]=o*a-r*h,t[4]=e*h-n*a,t[5]=n*r-e*o,t[6]=r*c-s*a,t[8]=e*s-i*r,this},n.identity=function(){var t=this.mat;return t[1]=t[2]=t[3]=t[5]=t[6]=t[7]=0,t[0]=t[4]=t[8]=1,this};var r=new cc.math.Matrix3;n.inverse=function(t){if(0===t)return this;r.assignFrom(this);var e=1/t;return this.adjugate(),this.multiplyScalar(e),this},n.isIdentity=function(){var t=this.mat;return 1===t[0]&&0===t[1]&&0===t[2]&&0===t[3]&&1===t[4]&&0===t[5]&&0===t[6]&&0===t[7]&&1===t[8]},n.transpose=function(){var t=this.mat,e=t[1],i=t[2],n=t[3],r=t[5],s=t[6],o=t[7];return t[1]=n,t[2]=s,t[3]=e,t[5]=o,t[6]=i,t[7]=r,this},n.determinant=function(){var t=this.mat,e=t[0]*t[4]*t[8]+t[1]*t[5]*t[6]+t[2]*t[3]*t[7];return e-=t[2]*t[4]*t[6]+t[0]*t[5]*t[7]+t[1]*t[3]*t[8]},n.multiply=function(t){var e=this.mat,i=t.mat,n=e[0],r=e[1],s=e[2],o=e[3],a=e[4],c=e[5],h=e[6],l=e[7],u=e[8],_=i[0],d=i[1],f=i[2],p=i[3],m=i[4],g=i[5],y=i[6],v=i[7],x=i[8];return e[0]=n*_+o*d+h*f,e[1]=r*_+a*d+l*f,e[2]=s*_+c*d+u*f,e[3]=s*_+c*d+u*f,e[4]=r*p+a*m+l*g,e[5]=s*p+c*m+u*g,e[6]=n*y+o*v+h*x,e[7]=r*y+a*v+l*x,e[8]=s*y+c*v+u*x,this},n.multiplyScalar=function(t){var e=this.mat;return e[0]*=t,e[1]*=t,e[2]*=t,e[3]*=t,e[4]*=t,e[5]*=t,e[6]*=t,e[7]*=t,e[8]*=t,this},cc.math.Matrix3.rotationAxisAngle=function(t,e){var i=Math.cos(e),n=Math.sin(e),r=new cc.math.Matrix3,s=r.mat;return s[0]=i+t.x*t.x*(1-i),s[1]=t.z*n+t.y*t.x*(1-i),s[2]=-t.y*n+t.z*t.x*(1-i),s[3]=-t.z*n+t.x*t.y*(1-i),s[4]=i+t.y*t.y*(1-i),s[5]=t.x*n+t.z*t.y*(1-i),s[6]=t.y*n+t.x*t.z*(1-i),s[7]=-t.x*n+t.y*t.z*(1-i),s[8]=i+t.z*t.z*(1-i),r},n.assignFrom=function(t){if(this===t)return cc.logID(7900),this;var e=this.mat,i=t.mat;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},n.equals=function(t){if(this===t)return!0;for(var e=cc.math.EPSILON,i=this.mat,n=t.mat,r=0;r<9;++r)if(!(i[r]+e>n[r]&&i[r]-e=c&&(c=a,_=n,u=r);if(++p[u],_!==u){for(s=0;s<4;s++)t.swap(_,s,u,s);for(s=0;s<4;s++)e.swap(_,s,u,s)}if(f[i]=_,d[i]=u,0===t.get(u,u))return!1;for(l=1/t.get(u,u),t.set(u,u,1),s=0;s<4;s++)t.set(u,s,t.get(u,s)*l);for(s=0;s<4;s++)e.set(u,s,e.get(u,s)*l);for(o=0;o<4;o++)if(o!==u){for(h=t.get(o,u),t.set(o,u,0),s=0;s<4;s++)t.set(o,s,t.get(o,s)-t.get(u,s)*h);for(s=0;s<4;s++)e.set(o,s,t.get(o,s)-e.get(u,s)*h)}}for(s=3;s>=0;s--)if(f[s]!==d[s])for(r=0;r<4;r++)t.swap(r,f[s],r,d[s]);return!0};var r=(new cc.math.Matrix4).identity();cc.math.mat4Inverse=function(t,e){var i=new cc.math.Matrix4(e),n=new cc.math.Matrix4(r);return!1===cc.math.Matrix4._gaussj(i,n)?null:(t.assignFrom(i),t)},n.inverse=function(){var t=new cc.math.Matrix4(this),e=new cc.math.Matrix4(r);return!1===cc.math.Matrix4._gaussj(t,e)?null:t},n.isIdentity=function(){var t=this.mat;return 1===t[0]&&0===t[1]&&0===t[2]&&0===t[3]&&0===t[4]&&1===t[5]&&0===t[6]&&0===t[7]&&0===t[8]&&0===t[9]&&1===t[10]&&0===t[11]&&0===t[12]&&0===t[13]&&0===t[14]&&1===t[15]},n.transpose=function(){var t=this.mat,e=t[1],i=t[2],n=t[3],r=t[4],s=t[6],o=t[7],a=t[8],c=t[9],h=t[11],l=t[12],u=t[13],_=t[14];return t[1]=r,t[2]=a,t[3]=l,t[4]=e,t[6]=c,t[7]=u,t[8]=i,t[9]=s,t[11]=_,t[12]=n,t[13]=o,t[14]=h,this},cc.math.mat4Multiply=function(t,e,i){var n=t.mat,r=e.mat,s=i.mat,o=r[0],a=r[1],c=r[2],h=r[3],l=r[4],u=r[5],_=r[6],d=r[7],f=r[8],p=r[9],m=r[10],g=r[11],y=r[12],v=r[13],x=r[14],C=r[15],T=s[0],b=s[1],A=s[2],S=s[3],w=s[4],E=s[5],I=s[6],R=s[7],P=s[8],O=s[9],B=s[10],D=s[11],M=s[12],L=s[13],N=s[14],F=s[15];return n[0]=T*o+b*l+A*f+S*y,n[1]=T*a+b*u+A*p+S*v,n[2]=T*c+b*_+A*m+S*x,n[3]=T*h+b*d+A*g+S*C,n[4]=w*o+E*l+I*f+R*y,n[5]=w*a+E*u+I*p+R*v,n[6]=w*c+E*_+I*m+R*x,n[7]=w*h+E*d+I*g+R*C,n[8]=P*o+O*l+B*f+D*y,n[9]=P*a+O*u+B*p+D*v,n[10]=P*c+O*_+B*m+D*x,n[11]=P*h+O*d+B*g+D*C,n[12]=M*o+L*l+N*f+F*y,n[13]=M*a+L*u+N*p+F*v,n[14]=M*c+L*_+N*m+F*x,n[15]=M*h+L*d+N*g+F*C,t},n.multiply=function(t){var e=this.mat,i=t.mat,n=e[0],r=e[1],s=e[2],o=e[3],a=e[4],c=e[5],h=e[6],l=e[7],u=e[8],_=e[9],d=e[10],f=e[11],p=e[12],m=e[13],g=e[14],y=e[15],v=i[0],x=i[1],C=i[2],T=i[3],b=i[4],A=i[5],S=i[6],w=i[7],E=i[8],I=i[9],R=i[10],P=i[11],O=i[12],B=i[13],D=i[14],M=i[15];return e[0]=v*n+x*a+C*u+T*p,e[1]=v*r+x*c+C*_+T*m,e[2]=v*s+x*h+C*d+T*g,e[3]=v*o+x*l+C*f+T*y,e[4]=b*n+A*a+S*u+w*p,e[5]=b*r+A*c+S*_+w*m,e[6]=b*s+A*h+S*d+w*g,e[7]=b*o+A*l+S*f+w*y,e[8]=E*n+I*a+R*u+P*p,e[9]=E*r+I*c+R*_+P*m,e[10]=E*s+I*h+R*d+P*g,e[11]=E*o+I*l+R*f+P*y,e[12]=O*n+B*a+D*u+M*p,e[13]=O*r+B*c+D*_+M*m,e[14]=O*s+B*h+D*d+M*g,e[15]=O*o+B*l+D*f+M*y,this},cc.math.getMat4MultiplyValue=function(t,e){var i=t.mat,n=e.mat,r=new Float32Array(16);return r[0]=i[0]*n[0]+i[4]*n[1]+i[8]*n[2]+i[12]*n[3],r[1]=i[1]*n[0]+i[5]*n[1]+i[9]*n[2]+i[13]*n[3],r[2]=i[2]*n[0]+i[6]*n[1]+i[10]*n[2]+i[14]*n[3],r[3]=i[3]*n[0]+i[7]*n[1]+i[11]*n[2]+i[15]*n[3],r[4]=i[0]*n[4]+i[4]*n[5]+i[8]*n[6]+i[12]*n[7],r[5]=i[1]*n[4]+i[5]*n[5]+i[9]*n[6]+i[13]*n[7],r[6]=i[2]*n[4]+i[6]*n[5]+i[10]*n[6]+i[14]*n[7],r[7]=i[3]*n[4]+i[7]*n[5]+i[11]*n[6]+i[15]*n[7],r[8]=i[0]*n[8]+i[4]*n[9]+i[8]*n[10]+i[12]*n[11],r[9]=i[1]*n[8]+i[5]*n[9]+i[9]*n[10]+i[13]*n[11],r[10]=i[2]*n[8]+i[6]*n[9]+i[10]*n[10]+i[14]*n[11],r[11]=i[3]*n[8]+i[7]*n[9]+i[11]*n[10]+i[15]*n[11],r[12]=i[0]*n[12]+i[4]*n[13]+i[8]*n[14]+i[12]*n[15],r[13]=i[1]*n[12]+i[5]*n[13]+i[9]*n[14]+i[13]*n[15],r[14]=i[2]*n[12]+i[6]*n[13]+i[10]*n[14]+i[14]*n[15],r[15]=i[3]*n[12]+i[7]*n[13]+i[11]*n[14]+i[15]*n[15],r},cc.math.mat4Assign=function(t,e){if(t===e)return cc.logID(7901),t;var i=t.mat,n=e.mat;return i[0]=n[0],i[1]=n[1],i[2]=n[2],i[3]=n[3],i[4]=n[4],i[5]=n[5],i[6]=n[6],i[7]=n[7],i[8]=n[8],i[9]=n[9],i[10]=n[10],i[11]=n[11],i[12]=n[12],i[13]=n[13],i[14]=n[14],i[15]=n[15],t},n.assignFrom=function(t){if(this===t)return cc.logID(7902),this;var e=this.mat,i=t.mat;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this},n.equals=function(t){if(this===t)return cc.logID(7903),!0;for(var e=this.mat,i=t.mat,n=cc.math.EPSILON,r=0;r<16;r++)if(!(e[r]+n>i[r]&&e[r]-n.001?cc.math.Plane.POINT_INFRONT_OF_PLANE:e<-.001?cc.math.Plane.POINT_BEHIND_PLANE:cc.math.Plane.POINT_ON_PLANE}}),{}],251:[(function(t,e,i){cc.math.Quaternion=function(t,e,i,n){t&&void 0===e?(this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0)};var n=cc.math.Quaternion.prototype;n.conjugate=function(t){return this.x=-t.x,this.y=-t.y,this.z=-t.z,this.w=t.w,this},n.dot=function(t){return this.w*t.w+this.x*t.x+this.y*t.y+this.z*t.z},n.exponential=function(){return this},n.identity=function(){return this.x=0,this.y=0,this.z=0,this.w=1,this},n.inverse=function(){var t=this.length();return Math.abs(t)>cc.math.EPSILON?(this.x=0,this.y=0,this.z=0,this.w=0,this):(this.conjugate(this).scale(1/t),this)},n.isIdentity=function(){return 0===this.x&&0===this.y&&0===this.z&&1===this.w},n.length=function(){return Math.sqrt(this.lengthSq())},n.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},n.multiply=function(t){var e=this.x,i=this.y,n=this.z,r=this.w;return this.w=r*t.w-e*t.x-i*t.y-n*t.z,this.x=r*t.x+e*t.w+i*t.z-n*t.y,this.y=r*t.y+i*t.w+n*t.x-e*t.z,this.z=r*t.z+n*t.w+e*t.y-i*t.x,this},n.normalize=function(){var t=this.length();if(Math.abs(t)<=cc.math.EPSILON)throw new Error("current quaternion is an invalid value");return this.scale(1/t),this},n.rotationAxis=function(t,e){var i=.5*e,n=Math.sin(i);return this.w=Math.cos(i),this.x=t.x*n,this.y=t.y*n,this.z=t.z*n,this},cc.math.Quaternion.rotationMatrix=function(t){if(!t)return null;var e,i,n,r,s=[],o=t.mat,a=0;s[0]=o[0],s[1]=o[3],s[2]=o[6],s[4]=o[1],s[5]=o[4],s[6]=o[7],s[8]=o[2],s[9]=o[5],s[10]=o[8],s[15]=1;var c=s[0],h=c[0]+c[5]+c[10]+1;return h>cc.math.EPSILON?(a=2*Math.sqrt(h),e=(c[9]-c[6])/a,i=(c[2]-c[8])/a,n=(c[4]-c[1])/a,r=.25*a):c[0]>c[5]&&c[0]>c[10]?(e=.25*(a=2*Math.sqrt(1+c[0]-c[5]-c[10])),i=(c[4]+c[1])/a,n=(c[2]+c[8])/a,r=(c[9]-c[6])/a):c[5]>c[10]?(a=2*Math.sqrt(1+c[5]-c[0]-c[10]),e=(c[4]+c[1])/a,i=.25*a,n=(c[9]+c[6])/a,r=(c[2]-c[8])/a):(a=2*Math.sqrt(1+c[10]-c[0]-c[5]),e=(c[2]+c[8])/a,i=(c[9]+c[6])/a,n=.25*a,r=(c[4]-c[1])/a),new cc.math.Quaternion(e,i,n,r)},cc.math.Quaternion.rotationYawPitchRoll=function(t,e,i){var n,r,s,o,a,c,h,l,u,_,d;n=cc.degreesToRadians(e)/2,r=cc.degreesToRadians(t)/2,s=cc.degreesToRadians(i)/2,o=Math.cos(n),a=Math.cos(r),c=Math.cos(s),h=Math.sin(n),_=a*c,d=(l=Math.sin(r))*(u=Math.sin(s));var f=new cc.math.Quaternion;return f.w=o*_+h*d,f.x=h*_-o*d,f.y=o*l*c+h*a*u,f.z=o*a*u-h*l*c,f.normalize(),f},n.slerp=function(t,e){if(this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w)return this;var i=this.dot(t),n=Math.acos(i),r=Math.sqrt(1-cc.math.square(i)),s=Math.sin(e*n)/r,o=Math.sin((1-e)*n)/r,a=new cc.math.Quaternion(t);return this.scale(o),a.scale(s),this.add(a),this},n.toAxisAndAngle=function(){var t,e,i,n=new cc.math.Vec3;return t=Math.acos(this.w),(e=Math.sqrt(cc.math.square(this.x)+cc.math.square(this.y)+cc.math.square(this.z)))>-cc.math.EPSILON&&e2*Math.PI-cc.math.EPSILON?(i=0,n.x=0,n.y=0,n.z=1):(i=2*t,n.x=this.x/e,n.y=this.y/e,n.z=this.z/e,n.normalize()),{axis:n,angle:i}},n.scale=function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},n.assignFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},n.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},cc.math.Quaternion.rotationBetweenVec3=function(t,e,i){var n=new cc.math.Vec3(t),r=new cc.math.Vec3(e);n.normalize(),r.normalize();var s=n.dot(r),o=new cc.math.Quaternion;if(s>=1)return o.identity(),o;if(s<1e-6-1)if(Math.abs(i.lengthSq())-cc.math.EPSILON&&fMath.max(t.x,e.x)+cc.math.EPSILON||sMath.max(t.y,e.y)+cc.math.EPSILON)&&(!(rMath.max(o,c)+cc.math.EPSILON||sMath.max(a,h)+cc.math.EPSILON)&&(i.x=r,i.y=s,!0)))},cc.math.Ray2.prototype.intersectTriangle=function(t,e,i,r,s){var o,a=new cc.math.Vec2,c=new cc.math.Vec2,h=new cc.math.Vec2,l=1e4,u=!1;return this.intersectLineSegment(t,e,a)&&(u=!0,(o=a.subtract(this.start).length())e&&t-cc.math.EPSILONt.x-cc.math.EPSILON&&this.yt.y-cc.math.EPSILON}}),{}],255:[(function(t,e,i){cc.math.Vec3=cc.math.Vec3=function(t,e,i){t&&void 0===e?(this.x=t.x,this.y=t.y,this.z=t.z):(this.x=t||0,this.y=e||0,this.z=i||0)},cc.math.vec3=function(t,e,i){return new cc.math.Vec3(t,e,i)};var n=cc.math.Vec3.prototype;n.fill=function(t,e,i){return t&&void 0===e?(this.x=t.x,this.y=t.y,this.z=t.z):(this.x=t,this.y=e,this.z=i),this},n.length=function(){return Math.sqrt(cc.math.square(this.x)+cc.math.square(this.y)+cc.math.square(this.z))},n.lengthSq=function(){return cc.math.square(this.x)+cc.math.square(this.y)+cc.math.square(this.z)},n.normalize=function(){var t=1/this.length();return this.x*=t,this.y*=t,this.z*=t,this},n.cross=function(t){var e=this.x,i=this.y,n=this.z;return this.x=i*t.z-n*t.y,this.y=n*t.x-e*t.z,this.z=e*t.y-i*t.x,this},n.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},n.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},n.subtract=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},n.transform=function(t){var e=this.x,i=this.y,n=this.z,r=t.mat;return this.x=e*r[0]+i*r[4]+n*r[8]+r[12],this.y=e*r[1]+i*r[5]+n*r[9]+r[13],this.z=e*r[2]+i*r[6]+n*r[10]+r[14],this},n.transformNormal=function(t){var e=this.x,i=this.y,n=this.z,r=t.mat;return this.x=e*r[0]+i*r[4]+n*r[8],this.y=e*r[1]+i*r[5]+n*r[9],this.z=e*r[2]+i*r[6]+n*r[10],this},n.transformCoord=function(t){var e=new cc.math.Vec4(this.x,this.y,this.z,1);return e.transform(t),this.x=e.x/e.w,this.y=e.y/e.w,this.z=e.z/e.w,this},n.scale=function(t){return this.x*=t,this.y*=t,this.z*=t,this},n.equals=function(t){var e=cc.math.EPSILON;return this.xt.x-e&&this.yt.y-e&&this.zt.z-e},n.inverseTransform=function(t){var e=t.mat,i=new cc.math.Vec3(this.x-e[12],this.y-e[13],this.z-e[14]);return this.x=i.x*e[0]+i.y*e[1]+i.z*e[2],this.y=i.x*e[4]+i.y*e[5]+i.z*e[6],this.z=i.x*e[8]+i.y*e[9]+i.z*e[10],this},n.inverseTransformNormal=function(t){var e=this.x,i=this.y,n=this.z,r=t.mat;return this.x=e*r[0]+i*r[1]+n*r[2],this.y=e*r[4]+i*r[5]+n*r[6],this.z=e*r[8]+i*r[9]+n*r[10],this},n.assignFrom=function(t){return t?(this.x=t.x,this.y=t.y,this.z=t.z,this):this},cc.math.Vec3.zero=function(t){return t.x=t.y=t.z=0,t},n.toTypeArray=function(){var t=new Float32Array(3);return t[0]=this.x,t[1]=this.y,t[2]=this.z,t}}),{}],256:[(function(t,e,i){cc.math.Vec4=function(t,e,i,n){t&&void 0===e?(this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0)};var n=cc.math.Vec4.prototype;n.fill=function(t,e,i,n){t&&void 0===e?(this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w):(this.x=t,this.y=e,this.z=i,this.w=n)},n.add=function(t){return t?(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this):this},n.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},n.length=function(){return Math.sqrt(cc.math.square(this.x)+cc.math.square(this.y)+cc.math.square(this.z)+cc.math.square(this.w))},n.lengthSq=function(){return cc.math.square(this.x)+cc.math.square(this.y)+cc.math.square(this.z)+cc.math.square(this.w)},n.lerp=function(t,e){return this},n.normalize=function(){var t=1/this.length();return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},n.scale=function(t){return this.normalize(),this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},n.subtract=function(t){this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w},n.transform=function(t){var e=this.x,i=this.y,n=this.z,r=this.w,s=t.mat;return this.x=e*s[0]+i*s[4]+n*s[8]+r*s[12],this.y=e*s[1]+i*s[5]+n*s[9]+r*s[13],this.z=e*s[2]+i*s[6]+n*s[10]+r*s[14],this.w=e*s[3]+i*s[7]+n*s[11]+r*s[15],this},cc.math.Vec4.transformArray=function(t,e){for(var i=[],n=0;nt.x-e&&this.yt.y-e&&this.zt.z-e&&this.wt.w-e},n.assignFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},n.toTypeArray=function(){var t=new Float32Array(4);return t[0]=this.x,t[1]=this.y,t[2]=this.z,t[3]=this.w,t}}),{}],257:[(function(t,e,i){t("./CCSGMotionStreak"),t("./CCSGMotionStreakWebGLRenderCmd");var n=cc.Class({name:"cc.MotionStreak",extends:cc.Component,editor:!1,ctor:function(){this._root=null,this._motionStreak=null},properties:{preview:{default:!1,editorOnly:!0,notify:!1,animatable:!1},_fadeTime:1,fadeTime:{get:function(){return this._fadeTime},set:function(t){this._fadeTime=t,this._motionStreak&&this._motionStreak.setFadeTime(t)},animatable:!1,tooltip:!1},_minSeg:1,minSeg:{get:function(){return this._minSeg},set:function(t){this._minSeg=t,this._motionStreak&&this._motionStreak.setMinSeg(t)},animatable:!1,tooltip:!1},_stroke:64,stroke:{get:function(){return this._stroke},set:function(t){this._stroke=t,this._motionStreak&&this._motionStreak.setStroke(t)},animatable:!1,tooltip:!1},_texture:{default:"",url:cc.Texture2D},texture:{get:function(){return this._texture},set:function(t){this._texture=t,this._motionStreak&&(t&&cc.js.isString(t)&&(t=cc.textureCache.addImage(t)),this._motionStreak.setTexture(t))},url:cc.Texture2D,animatable:!1,tooltip:!1},_color:cc.Color.WHITE,color:{get:function(){return this._color},set:function(t){this._color=t,this._motionStreak&&this._motionStreak.tintWithColor(t)},tooltip:!1},_fastMode:!1,fastMode:{get:function(){return this._fastMode},set:function(t){this._fastMode=t,this._motionStreak&&this._motionStreak.setFastMode(t)},animatable:!1,tooltip:!1}},onFocusInEditor:!1,onLostFocusInEditor:!1,reset:function(){this._motionStreak.reset()},__preload:function(){if(cc._renderType===cc.game.RENDER_TYPE_WEBGL){this._root=new _ccsg.Node;var t=new _ccsg.MotionStreak;t.initWithFade(this._fadeTime,this._minSeg,this._stroke,this.node.color,this._texture||null),t.setFastMode(this._fastMode),this._root.addChild(t);var e=this.node._sgNode;e&&e.addChild(this._root,-10),this._motionStreak=t}else cc.warnID(5900)},onEnable:function(){this.node.on("position-changed",this._onNodePositionChanged,this)},onDisable:function(){this.node.off("position-changed",this._onNodePositionChanged,this)},_onNodePositionChanged:function(){if(this._motionStreak){var t=this.node,e=t.getNodeToWorldTransform(),i=e.tx-(t.width/2+t.anchorX*t.width),n=e.ty-(t.height/2+t.anchorY*t.height);this._root.setPosition(-i,-n),this._motionStreak.setPosition(i,n)}}});cc.MotionStreak=e.exports=n}),{"./CCSGMotionStreak":258,"./CCSGMotionStreakWebGLRenderCmd":259}],258:[(function(t,e,i){function n(t,e,i,n,r){if(!((r+=n)<=1)){e*=.5;for(var s,o=r-1,a=n;a1)&&(C=!0),C&&(i[2*p]=v.x,i[2*p+1]=v.y,i[2*(p+1)]=y.x,i[2*(p+1)+1]=y.y)}}}_ccsg.MotionStreak=_ccsg.Node.extend({texture:null,fastMode:!1,startingPositionInitialized:!1,_blendFunc:null,_stroke:0,_fadeDelta:0,_minSeg:0,_maxPoints:0,_nuPoints:0,_previousNuPoints:0,_pointVertexes:null,_pointState:null,_vertices:null,_colorPointer:null,_texCoords:null,_verticesBuffer:null,_colorPointerBuffer:null,_texCoordsBuffer:null,_className:"MotionStreak",ctor:function(t,e,i,n,r){_ccsg.Node.prototype.ctor.call(this),this._positionR=cc.p(0,0),this._blendFunc=new cc.BlendFunc(cc.SRC_ALPHA,cc.ONE_MINUS_SRC_ALPHA),this.fastMode=!1,this.startingPositionInitialized=!1,this.texture=null,this._stroke=0,this._fadeDelta=0,this._minSeg=0,this._maxPoints=0,this._nuPoints=0,this._previousNuPoints=0,this._pointVertexes=null,this._pointState=null,this._vertices=null,this._colorPointer=null,this._texCoords=null,this._verticesBuffer=null,this._colorPointerBuffer=null,this._texCoordsBuffer=null,void 0!==r&&this.initWithFade(t,e,i,n,r)},initWithFade:function(t,e,i,n,r){return cc.js.isString(r)&&(r=cc.textureCache.addImage(r)),this.anchorX=0,this.anchorY=0,this.ignoreAnchor=!0,this.startingPositionInitialized=!1,this.fastMode=!0,this._stroke=i,this.setMinSeg(e),this.setFadeTime(t),this._blendFunc.src=gl.SRC_ALPHA,this._blendFunc.dst=gl.ONE_MINUS_SRC_ALPHA,this.setTexture(r),this.color=n,this.scheduleUpdate(),!0},getTexture:function(){return this.texture},setTexture:function(t){this.texture!==t&&(this.texture=t)},getBlendFunc:function(){return this._blendFunc},setBlendFunc:function(t,e){void 0===e?this._blendFunc=t:(this._blendFunc.src=t,this._blendFunc.dst=e)},getOpacity:function(){return cc.logID(5901),0},setOpacity:function(t){cc.logID(5902)},setOpacityModifyRGB:function(t){},isOpacityModifyRGB:function(){return!1},getFadeTime:function(){return 1/this._fadeDelta},setFadeTime:function(t){this._fadeDelta=1/t;var e=2+(0|60*t);this._maxPoints=e,this._nuPoints=0,this._pointState=new Float32Array(e),this._pointVertexes=new Float32Array(2*e),this._vertices=new Float32Array(4*e),this._texCoords=new Float32Array(4*e),this._colorPointer=new Uint8Array(8*e),this._verticesBuffer=gl.createBuffer(),this._texCoordsBuffer=gl.createBuffer(),this._colorPointerBuffer=gl.createBuffer(),gl.bindBuffer(gl.ARRAY_BUFFER,this._verticesBuffer),gl.bufferData(gl.ARRAY_BUFFER,this._vertices,gl.DYNAMIC_DRAW),gl.bindBuffer(gl.ARRAY_BUFFER,this._texCoordsBuffer),gl.bufferData(gl.ARRAY_BUFFER,this._texCoords,gl.DYNAMIC_DRAW),gl.bindBuffer(gl.ARRAY_BUFFER,this._colorPointerBuffer),gl.bufferData(gl.ARRAY_BUFFER,this._colorPointer,gl.DYNAMIC_DRAW)},getMinSeg:function(){return this._minSeg},setMinSeg:function(t){this._minSeg=-1===t?this._stroke/5:t,this._minSeg*=this._minSeg},isFastMode:function(){return this.fastMode},setFastMode:function(t){this.fastMode=t},isStartingPositionInitialized:function(){return this.startingPositionInitialized},setStartingPositionInitialized:function(t){this.startingPositionInitialized=t},getStroke:function(){return this._stroke},setStroke:function(t){this._stroke=t},tintWithColor:function(t){this.color=t;for(var e=this._colorPointer,i=0,n=2*this._nuPoints;i0?(c[e]=c[r],h[2*e]=h[2*r],h[2*e+1]=h[2*r+1],s=2*r,l[2*(i=2*e)]=l[2*s],l[2*i+1]=l[2*s+1],l[2*(i+1)]=l[2*(s+1)],l[2*(i+1)+1]=l[2*(s+1)+1],s*=4,u[(i*=4)+0]=u[s+0],u[i+1]=u[s+1],u[i+2]=u[s+2],u[i+4]=u[s+4],u[i+5]=u[s+5],u[i+6]=u[s+6]):i=8*e;var _=255*c[e];u[i+3]=_,u[i+7]=_}var d=!0;if((a-=o)>=this._maxPoints)d=!1;else if(a>0){var f=cc.p(h[2*(a-1)],h[2*(a-1)+1]),p=cc.pDistanceSQ(f,this._positionR)0&&this.fastMode&&(a>1?n(h,this._stroke,this._vertices,a,1):n(h,this._stroke,this._vertices,0,2)),a++}if(this.fastMode||n(h,this._stroke,this._vertices,0,a),a&&this._previousNuPoints!==a){var x=1/a,C=this._texCoords;for(r=0;re;0<=e?++u:--u)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),(h=255-this.transparency.indexed.length)>0)for(_=0;0<=h?_h;0<=h?++_:--_)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":o=(l=this.read(e)).indexOf(0),a=String.fromCharCode.apply(String,l.slice(0,o)),this.text[a]=String.fromCharCode.apply(String,l.slice(o+1));break;case"IEND":return s&&this.animation.frames.push(s),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(d=this.colorType)||6===d,i=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*i,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(Uint8Array!=Array&&(this.imgData=new Uint8Array(this.imgData)));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}},read:function(t){var e,i;for(i=[],e=0;0<=t?et;0<=t?++e:--e)i.push(this.data[this.pos++]);return i},readUInt32:function(){var t,e,i,n;return t=this.data[this.pos++]<<24,e=this.data[this.pos++]<<16,i=this.data[this.pos++]<<8,n=this.data[this.pos++],t|e|i|n},readUInt16:function(){var t,e;return t=this.data[this.pos++]<<8,e=this.data[this.pos++],t|e},decodePixels:function(t){var e,i,r,s,o,a,c,h,l,u,_,d,f,p,m,g,y,v,x,C,T,b,A;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=new n.Inflate(t,{index:0,verify:!1}).decompress(),g=(d=this.pixelBitlength/8)*this.width,f=new Uint8Array(g*this.height),a=t.length,m=0,p=0,i=0;p=this._totalParticles},setDisplayFrame:function(t){if(t){var e=t.getTexture();e&&(this._texture=e.url),this._sgNode.setDisplayFrame(t)}},setTextureWithRect:function(t,e){t instanceof cc.Texture2D&&(this._texture=t.url),this._sgNode.setTextureWithRect(t,e)},_applyFile:function(){var t=this._file;if(t){var e=this;cc.loader.load(t,(function(i,n){if(i||!n)throw i||new Error("Unkown error");if(e.isValid){var r=e._sgNode;r.particleCount=0;var s=r.isActive();r.initWithFile(t),n.textureUuid&&cc.AssetLibrary.queryAssetInfo(n.textureUuid,(function(t,i,n){t?cc.error(t):e.texture=i})),n.emissionRate&&(e.emissionRate=n.emissionRate),r.setPosition(0,0),s||r.stopSystem(),e._applyAutoRemove(),e._custom&&e._applyCustoms()}}))}},_applyCustoms:function(){for(var t=this._sgNode,e=t.isActive(),i=0;i=this._totalParticles},updateQuadWithParticle:function(t,e){this._renderCmd.updateQuadWithParticle(t,e)},postStep:function(){this._renderCmd.postStep()},update:function(t){if(this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty),this._isActive&&this.emissionRate){var e=1/this.emissionRate;for(this.particleCounte;)this.addParticle(),this._emitCounter-=e;this._elapsed+=t,-1!==this.duration&&this.duration0){if(this.emitterMode===_ccsg.ParticleSystem.Mode.GRAVITY){var h=o,l=r,u=s;c.pos.x||c.pos.y?(cc.pIn(l,c.pos),cc.pNormalizeIn(l)):cc.pZeroIn(l),cc.pIn(u,l),cc.pMultIn(l,c.modeA.radialAccel);var _=u.x;u.x=-u.y,u.y=_,cc.pMultIn(u,c.modeA.tangentialAccel),cc.pIn(h,l),cc.pAddIn(h,u),cc.pAddIn(h,this.modeA.gravity),cc.pMultIn(h,t),cc.pAddIn(c.modeA.dir,h),cc.pIn(h,c.modeA.dir),cc.pMultIn(h,t),cc.pAddIn(c.pos,h)}else{var d=c.modeB;d.angle+=d.degreesPerSecond*t,d.radius+=d.deltaRadius*t,c.pos.x=-Math.cos(d.angle)*d.radius,c.pos.y=-Math.sin(d.angle)*d.radius}this._renderCmd._updateDeltaColor(c,t),c.size+=c.deltaSize*t,c.size=Math.max(0,c.size),c.rotation+=c.deltaRotation*t;var f=r;if(this.positionType===_ccsg.ParticleSystem.Type.FREE||this.positionType===_ccsg.ParticleSystem.Type.RELATIVE){var p=s,m=o;cc._pointApplyAffineTransformIn(n,i,p),cc._pointApplyAffineTransformIn(c.startPos,i,m),cc.pSubIn(p,m),cc.pIn(f,c.pos),cc.pSubIn(f,p)}else cc.pIn(f,c.pos);this._renderCmd.updateParticlePosition(c,f),++this._particleIdx}else{if(this._particleIdx!==this.particleCount-1){var g=a[this._particleIdx];a[this._particleIdx]=a[this.particleCount-1],a[this.particleCount-1]=g}if(--this.particleCount,0===this.particleCount&&this.autoRemoveOnFinish)return this.unscheduleUpdate(),this._parent.removeChild(this,!0),void(this._renderCmd.updateLocalBB&&this._renderCmd.updateLocalBB())}}this._renderCmd.updateLocalBB&&this._renderCmd.updateLocalBB()}this.postStep()},updateWithNoTime:function(){this.update(0)},_valueForKey:function(t,e){if(e){var i=e[t];return null!=i?i:""}return""},_updateBlendFunc:function(){var t=this._texture;if(t&&t instanceof cc.Texture2D){this._opacityModifyRGB=!1;var e=this._blendFunc;e.src===cc.macro.BLEND_SRC&&e.dst===cc.macro.BLEND_DST&&(t.hasPremultipliedAlpha()?this._opacityModifyRGB=!0:(e.src=cc.macro.SRC_ALPHA,e.dst=cc.macro.ONE_MINUS_SRC_ALPHA))}},clone:function(){var t=new _ccsg.ParticleSystem;if(t.initWithTotalParticles(this.getTotalParticles())){t.setAngle(this.getAngle()),t.setAngleVar(this.getAngleVar()),t.setDuration(this.getDuration());var e=this.getBlendFunc();if(t.setBlendFunc(e.src,e.dst),t.setStartColor(this.getStartColor()),t.setStartColorVar(this.getStartColorVar()),t.setEndColor(this.getEndColor()),t.setEndColorVar(this.getEndColorVar()),t.setStartSize(this.getStartSize()),t.setStartSizeVar(this.getStartSizeVar()),t.setEndSize(this.getEndSize()),t.setEndSizeVar(this.getEndSizeVar()),t.setPosition(cc.p(this.x,this.y)),t.setPosVar(cc.p(this.getPosVar().x,this.getPosVar().y)),t.setPositionType(this.getPositionType()),t.setStartSpin(this.getStartSpin()||0),t.setStartSpinVar(this.getStartSpinVar()||0),t.setEndSpin(this.getEndSpin()||0),t.setEndSpinVar(this.getEndSpinVar()||0),t.setEmitterMode(this.getEmitterMode()),this.getEmitterMode()===_ccsg.ParticleSystem.Mode.GRAVITY){var i=this.getGravity();t.setGravity(cc.p(i.x,i.y)),t.setSpeed(this.getSpeed()),t.setSpeedVar(this.getSpeedVar()),t.setRadialAccel(this.getRadialAccel()),t.setRadialAccelVar(this.getRadialAccelVar()),t.setTangentialAccel(this.getTangentialAccel()),t.setTangentialAccelVar(this.getTangentialAccelVar())}else this.getEmitterMode()===_ccsg.ParticleSystem.Mode.RADIUS&&(t.setStartRadius(this.getStartRadius()),t.setStartRadiusVar(this.getStartRadiusVar()),t.setEndRadius(this.getEndRadius()),t.setEndRadiusVar(this.getEndRadiusVar()),t.setRotatePerSecond(this.getRotatePerSecond()),t.setRotatePerSecondVar(this.getRotatePerSecondVar()));t.setLife(this.getLife()),t.setLifeVar(this.getLifeVar()),t.setEmissionRate(this.getEmissionRate()),t.setOpacityModifyRGB(this.isOpacityModifyRGB());var n=this.getTexture();if(n){var r=n.getContentSize();t.setTextureWithRect(n,cc.rect(0,0,r.width,r.height))}}return t},setDisplayFrame:function(t){if(t){var e=t.getOffset();0===e.x&&0===e.y||cc.logID(6015);var i=t.getTexture();this._texture!==i&&this.setTexture(i)}},setTextureWithRect:function(t,e){this._texture!==t&&(this._texture=t,this._updateBlendFunc()),this.initTexCoordsWithRect(e)},listenBackToForeground:function(t){}});var s=_ccsg.ParticleSystem.prototype;s.opacityModifyRGB,cc.defineGetterSetter(s,"opacityModifyRGB",s.isOpacityModifyRGB,s.setOpacityModifyRGB),s.active,cc.defineGetterSetter(s,"active",s.isActive),s.sourcePos,cc.defineGetterSetter(s,"sourcePos",s.getSourcePosition,s.setSourcePosition),s.posVar,cc.defineGetterSetter(s,"posVar",s.getPosVar,s.setPosVar),s.gravity,cc.defineGetterSetter(s,"gravity",s.getGravity,s.setGravity),s.speed,cc.defineGetterSetter(s,"speed",s.getSpeed,s.setSpeed),s.speedVar,cc.defineGetterSetter(s,"speedVar",s.getSpeedVar,s.setSpeedVar),s.tangentialAccel,cc.defineGetterSetter(s,"tangentialAccel",s.getTangentialAccel,s.setTangentialAccel),s.tangentialAccelVar,cc.defineGetterSetter(s,"tangentialAccelVar",s.getTangentialAccelVar,s.setTangentialAccelVar),s.radialAccel,cc.defineGetterSetter(s,"radialAccel",s.getRadialAccel,s.setRadialAccel),s.radialAccelVar,cc.defineGetterSetter(s,"radialAccelVar",s.getRadialAccelVar,s.setRadialAccelVar),s.rotationIsDir,cc.defineGetterSetter(s,"rotationIsDir",s.getRotationIsDir,s.setRotationIsDir),s.startRadius,cc.defineGetterSetter(s,"startRadius",s.getStartRadius,s.setStartRadius),s.startRadiusVar,cc.defineGetterSetter(s,"startRadiusVar",s.getStartRadiusVar,s.setStartRadiusVar),s.endRadius,cc.defineGetterSetter(s,"endRadius",s.getEndRadius,s.setEndRadius),s.endRadiusVar,cc.defineGetterSetter(s,"endRadiusVar",s.getEndRadiusVar,s.setEndRadiusVar),s.rotatePerS,cc.defineGetterSetter(s,"rotatePerS",s.getRotatePerSecond,s.setRotatePerSecond),s.rotatePerSVar,cc.defineGetterSetter(s,"rotatePerSVar",s.getRotatePerSecondVar,s.setRotatePerSecondVar),s.startColor,cc.defineGetterSetter(s,"startColor",s.getStartColor,s.setStartColor),s.startColorVar,cc.defineGetterSetter(s,"startColorVar",s.getStartColorVar,s.setStartColorVar),s.endColor,cc.defineGetterSetter(s,"endColor",s.getEndColor,s.setEndColor),s.endColorVar,cc.defineGetterSetter(s,"endColorVar",s.getEndColorVar,s.setEndColorVar),s.totalParticles,cc.defineGetterSetter(s,"totalParticles",s.getTotalParticles,s.setTotalParticles),s.texture,cc.defineGetterSetter(s,"texture",s.getTexture,s.setTexture),_ccsg.ParticleSystem.ModeA=function(t,e,i,n,r,s,o,a){this.gravity=t||cc.p(0,0),this.speed=e||0,this.speedVar=i||0,this.tangentialAccel=n||0,this.tangentialAccelVar=r||0,this.radialAccel=s||0,this.radialAccelVar=o||0,this.rotationIsDir=a||!1},_ccsg.ParticleSystem.ModeB=function(t,e,i,n,r,s){this.startRadius=t||0,this.startRadiusVar=e||0,this.endRadius=i||0,this.endRadiusVar=n||0,this.rotatePerSecond=r||0,this.rotatePerSecondVar=s||0},_ccsg.ParticleSystem.DURATION_INFINITY=-1,_ccsg.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE=-1,_ccsg.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS=-1,_ccsg.ParticleSystem.Mode=cc.Enum({GRAVITY:0,RADIUS:1}),_ccsg.ParticleSystem.Type=cc.Enum({FREE:0,RELATIVE:1,GROUPED:2})}),{"../compression/ZipUtils":28,"./CCPNGReader":260,"./CCTIFFReader":266}],264:[(function(t,e,i){_ccsg.ParticleSystem.CanvasRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,this._pointRect=cc.rect(0,0,0,0),this._localRegion=new cc.Region,this._tintCache=null};var n=_ccsg.ParticleSystem.CanvasRenderCmd.prototype=Object.create(_ccsg.Node.CanvasRenderCmd.prototype);n.constructor=_ccsg.ParticleSystem.CanvasRenderCmd,n.updateQuadWithParticle=function(t,e){},n.updateParticlePosition=function(t,e){cc.pIn(t.drawPos,e)};var r=new cc.Region,s=new cc.Rect;n.updateLocalBB=function(){var t=this._localRegion,e=this._node._particles;t.setEmpty();for(var i=e.length-1;i>=0;--i){var n=e[i],o=n.drawPos,a=1.415*n.size;r.setTo(o.x-a,o.y-a,o.x+a,o.y+a),t.union(r)}s.x=t._minX,s.y=t._minY,s.width=t._maxX-t._minX,s.height=t._maxY-t._minY},n.getLocalBB=function(){return s},n.updateStatus=function(){this.originUpdateStatus(),this._updateCurrentRegions(),this._regionFlag=_ccsg.Node.CanvasRenderCmd.RegionStatus.DirtyDouble,this._dirtyFlag&=~_ccsg.Node._dirtyFlags.contentDirty},n.rendering=function(t,e,i){var n=t||cc._renderContext,r=n.getContext(),s=this._node,o=this._pointRect;n.setTransform(this._worldTransform,e,i),n.save(),s.isBlendAdditive()?r.globalCompositeOperation="lighter":r.globalCompositeOperation="source-over";var a,c,h,l=this._node.particleCount,u=this._node._particles;if(s._texture){if(!s._texture.loaded)return void n.restore();var _=s._texture.getHtmlElementObj();if(!_.width||!_.height)return void n.restore();var d=_;for(a=0;ae._allocatedParticles){var i=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;this._indices=new Uint16Array(6*t);var n=new ArrayBuffer(t*i),r=e._particles;r.length=0;var s=this._quads;s.length=0;for(var o=0;o>>8*(4-s)):r.push(n);else for(var o=0;o=8?-1!==["RATIONAL","SRATIONAL"].indexOf(e)?(r.push(this.getUint32(n+a)),r.push(this.getUint32(n+a+4))):cc.logID(8e3):r.push(this.getBytes(s,n+a))}return"ASCII"===e&&r.forEach((function(t,e,i){i[e]=String.fromCharCode(t)})),r},getBytes:function(t,e){if(t<=0)cc.logID(8001);else{if(t<=1)return this.getUint8(e);if(t<=2)return this.getUint16(e);if(t<=3)return this.getUint32(e)>>>8;if(t<=4)return this.getUint32(e);cc.logID(8002)}},getBits:function(t,e,i){i=i||0;var n,r,s=e+Math.floor(i/8),o=i+t,a=32-t;return o<=0?console.log("No bits requested"):o<=8?(n=24+i,r=this.getUint8(s)):o<=16?(n=16+i,r=this.getUint16(s)):o<=32?(n=i,r=this.getUint32(s)):console.log("Too many bits requested"),{bits:r<>>a,byteOffset:s+Math.floor(o/8),bitOffset:o%8}},parseFileDirectory:function(t){for(var e=this.getUint16(t),i=[],n=t+2,r=0;r=0&&B<=127?P=B+1:B>=-127&&B<=-1?O=1-B:T=!0}else{var D=this.getUint8(g+v);for(E=0;E0)for(var it=0;it"},_compileShader:function(t,e,i){if(!i||!t)return!1;i=(cc.GLProgram._isHighpSupported()?"precision highp float;\n":"precision mediump float;\n")+"uniform mat4 CC_PMatrix;\nuniform mat4 CC_MVMatrix;\nuniform mat4 CC_MVPMatrix;\nuniform vec4 CC_Time;\nuniform vec4 CC_SinTime;\nuniform vec4 CC_CosTime;\nuniform vec4 CC_Random01;\nuniform sampler2D CC_Texture0;\n//CC INCLUDES END\n"+i,this._glContext.shaderSource(t,i),this._glContext.compileShader(t);var n=this._glContext.getShaderParameter(t,this._glContext.COMPILE_STATUS);return n||(cc.logID(8100,this._glContext.getShaderSource(t)),e===this._glContext.VERTEX_SHADER?cc.log("cocos2d: \n"+this.vertexShaderLog()):cc.log("cocos2d: \n"+this.fragmentShaderLog())),!!n},ctor:function(t,e,i){this._uniforms={},this._hashForUniforms={},this._glContext=i||cc._renderContext,this._programObj=null,this._vertShader=null,this._fragShader=null,this._usesTime=!1,this._projectionUpdated=-1,t&&e&&this.init(t,e)},destroyProgram:function(){this._vertShader=null,this._fragShader=null,this._uniforms=null,this._hashForUniforms=null,this._glContext.deleteProgram(this._programObj)},initWithVertexShaderByteArray:function(t,e){var i=this._glContext;this._programObj=i.createProgram(),this._projectionUpdated=-1,this._vertShader=null,this._fragShader=null,t&&(this._vertShader=i.createShader(i.VERTEX_SHADER),this._compileShader(this._vertShader,i.VERTEX_SHADER,t)||cc.logID(8101)),e&&(this._fragShader=i.createShader(i.FRAGMENT_SHADER),this._compileShader(this._fragShader,i.FRAGMENT_SHADER,e)||cc.logID(8102)),this._vertShader&&i.attachShader(this._programObj,this._vertShader),this._fragShader&&i.attachShader(this._programObj,this._fragShader);for(var n in this._hashForUniforms)delete this._hashForUniforms[n];return!0},initWithString:function(t,e){return this.initWithVertexShaderByteArray(t,e)},initWithVertexShaderFilename:function(t,e){var i=cc.loader.getRes(t);if(!i)throw new Error("Please load the resource firset : "+t);var n=cc.loader.getRes(e);if(!n)throw new Error("Please load the resource firset : "+e);return this.initWithVertexShaderByteArray(i,n)},init:function(t,e){return this.initWithVertexShaderFilename(t,e)},addAttribute:function(t,e){this._glContext.bindAttribLocation(this._programObj,e,t)},link:function(){if(!this._programObj)return cc.logID(8103),!1;if(this._glContext.linkProgram(this._programObj),this._vertShader&&this._glContext.deleteShader(this._vertShader),this._fragShader&&this._glContext.deleteShader(this._fragShader),this._vertShader=null,this._fragShader=null,cc.game.config[cc.game.CONFIG_KEY.debugMode]){if(!this._glContext.getProgramParameter(this._programObj,this._glContext.LINK_STATUS))return cc.logID(8104,this._glContext.getProgramInfoLog(this._programObj)),cc.gl.deleteProgram(this._programObj),this._programObj=null,!1}return!0},use:function(){cc.gl.useProgram(this._programObj)},updateUniforms:function(){this._uniforms[n.UNIFORM_PMATRIX]=this._glContext.getUniformLocation(this._programObj,n.UNIFORM_PMATRIX_S),this._uniforms[n.UNIFORM_MVMATRIX]=this._glContext.getUniformLocation(this._programObj,n.UNIFORM_MVMATRIX_S),this._uniforms[n.UNIFORM_MVPMATRIX]=this._glContext.getUniformLocation(this._programObj,n.UNIFORM_MVPMATRIX_S),this._uniforms[n.UNIFORM_TIME]=this._glContext.getUniformLocation(this._programObj,n.UNIFORM_TIME_S),this._uniforms[n.UNIFORM_SINTIME]=this._glContext.getUniformLocation(this._programObj,n.UNIFORM_SINTIME_S),this._uniforms[n.UNIFORM_COSTIME]=this._glContext.getUniformLocation(this._programObj,n.UNIFORM_COSTIME_S),this._usesTime=null!=this._uniforms[n.UNIFORM_TIME]||null!=this._uniforms[n.UNIFORM_SINTIME]||null!=this._uniforms[n.UNIFORM_COSTIME],this._uniforms[n.UNIFORM_RANDOM01]=this._glContext.getUniformLocation(this._programObj,n.UNIFORM_RANDOM01_S),this._uniforms[n.UNIFORM_SAMPLER]=this._glContext.getUniformLocation(this._programObj,n.UNIFORM_SAMPLER_S),this.use(),this.setUniformLocationWith1i(this._uniforms[n.UNIFORM_SAMPLER],0)},_addUniformLocation:function(t){var e=this._glContext.getUniformLocation(this._programObj,t);this._uniforms[t]=e},getUniformLocationForName:function(t){if(!t)throw new Error("cc.GLProgram.getUniformLocationForName(): uniform name should be non-null");if(!this._programObj)throw new Error("cc.GLProgram.getUniformLocationForName(): Invalid operation. Cannot get uniform location when program is not initialized");return this._uniforms[t]||this._glContext.getUniformLocation(this._programObj,t)},getUniformMVPMatrix:function(){return this._uniforms[n.UNIFORM_MVPMATRIX]},getUniformSampler:function(){return this._uniforms[n.UNIFORM_SAMPLER]},setUniformLocationWith1i:function(t,e){var i=this._glContext;if("string"==typeof t){if(this._updateUniformLocation(t,e)){var n=this.getUniformLocationForName(t);i.uniform1i(n,e)}}else i.uniform1i(t,e)},setUniformLocationWith2i:function(t,e,i){var n=this._glContext;if("string"==typeof t){if(this._updateUniformLocation(t,e,i)){var r=this.getUniformLocationForName(t);n.uniform2i(r,e,i)}}else n.uniform2i(t,e,i)},setUniformLocationWith3i:function(t,e,i,n){var r=this._glContext;if("string"==typeof t){if(this._updateUniformLocation(t,e,i,n)){var s=this.getUniformLocationForName(t);r.uniform3i(s,e,i,n)}}else r.uniform3i(t,e,i,n)},setUniformLocationWith4i:function(t,e,i,n,r){var s=this._glContext;if("string"==typeof t){if(this._updateUniformLocation(t,e,i,n,r)){var o=this.getUniformLocationForName(t);s.uniform4i(o,e,i,n,r)}}else s.uniform4i(t,e,i,n,r)},setUniformLocationWith2iv:function(t,e){var i="string"==typeof t?this.getUniformLocationForName(t):t;this._glContext.uniform2iv(i,e)},setUniformLocationWith3iv:function(t,e){var i="string"==typeof t?this.getUniformLocationForName(t):t;this._glContext.uniform3iv(i,e)},setUniformLocationWith4iv:function(t,e){var i="string"==typeof t?this.getUniformLocationForName(t):t;this._glContext.uniform4iv(i,e)},setUniformLocationI32:function(t,e){this.setUniformLocationWith1i(t,e)},setUniformLocationWith1f:function(t,e){var i=this._glContext;if("string"==typeof t){if(this._updateUniformLocation(t,e)){var n=this.getUniformLocationForName(t);i.uniform1f(n,e)}}else i.uniform1f(t,e)},setUniformLocationWith2f:function(t,e,i){var n=this._glContext;if("string"==typeof t){if(this._updateUniformLocation(t,e,i)){var r=this.getUniformLocationForName(t);n.uniform2f(r,e,i)}}else n.uniform2f(t,e,i)},setUniformLocationWith3f:function(t,e,i,n){var r=this._glContext;if("string"==typeof t){if(this._updateUniformLocation(t,e,i,n)){var s=this.getUniformLocationForName(t);r.uniform3f(s,e,i,n)}}else r.uniform3f(t,e,i,n)},setUniformLocationWith4f:function(t,e,i,n,r){var s=this._glContext;if("string"==typeof t){if(this._updateUniformLocation(t,e,i,n,r)){var o=this.getUniformLocationForName(t);s.uniform4f(o,e,i,n,r)}}else s.uniform4f(t,e,i,n,r)},setUniformLocationWith2fv:function(t,e){var i="string"==typeof t?this.getUniformLocationForName(t):t;this._glContext.uniform2fv(i,e)},setUniformLocationWith3fv:function(t,e){var i="string"==typeof t?this.getUniformLocationForName(t):t;this._glContext.uniform3fv(i,e)},setUniformLocationWith4fv:function(t,e){var i="string"==typeof t?this.getUniformLocationForName(t):t;this._glContext.uniform4fv(i,e)},setUniformLocationWithMatrix3fv:function(t,e){var i="string"==typeof t?this.getUniformLocationForName(t):t;this._glContext.uniformMatrix3fv(i,!1,e)},setUniformLocationWithMatrix4fv:function(t,e){var i="string"==typeof t?this.getUniformLocationForName(t):t;this._glContext.uniformMatrix4fv(i,!1,e)},setUniformLocationF32:function(t,e,i,n,r){"use strict";switch(arguments.length){case 0:case 1:return;case 2:this.setUniformLocationWith1f(t,e);break;case 3:this.setUniformLocationWith2f(t,e,i);break;case 4:this.setUniformLocationWith3f(t,e,i,n);break;case 5:this.setUniformLocationWith4f(t,e,i,n,r)}},setUniformsForBuiltins:function(){var t=new r.Matrix4,e=new r.Matrix4,i=new r.Matrix4;if(r.glGetMatrix(r.KM_GL_PROJECTION,t),r.glGetMatrix(r.KM_GL_MODELVIEW,e),r.mat4Multiply(i,t,e),this.setUniformLocationWithMatrix4fv(this._uniforms[n.UNIFORM_PMATRIX],t.mat,1),this.setUniformLocationWithMatrix4fv(this._uniforms[n.UNIFORM_MVMATRIX],e.mat,1),this.setUniformLocationWithMatrix4fv(this._uniforms[n.UNIFORM_MVPMATRIX],i.mat,1),this._usesTime){var s=cc.director,o=s.getTotalFrames()*s.getAnimationInterval();this.setUniformLocationWith4f(this._uniforms[n.UNIFORM_TIME],o/10,o,2*o,4*o),this.setUniformLocationWith4f(this._uniforms[n.UNIFORM_SINTIME],o/8,o/4,o/2,Math.sin(o)),this.setUniformLocationWith4f(this._uniforms[n.UNIFORM_COSTIME],o/8,o/4,o/2,Math.cos(o))}-1!==this._uniforms[n.UNIFORM_RANDOM01]&&this.setUniformLocationWith4f(this._uniforms[n.UNIFORM_RANDOM01],Math.random(),Math.random(),Math.random(),Math.random())},_setUniformsForBuiltinsForRenderer:function(t){if(t&&t._renderCmd){var e=new r.Matrix4,i=new r.Matrix4;if(r.glGetMatrix(r.KM_GL_PROJECTION,e),r.mat4Multiply(i,e,t._renderCmd._stackMatrix),this.setUniformLocationWithMatrix4fv(this._uniforms[n.UNIFORM_PMATRIX],e.mat,1),this.setUniformLocationWithMatrix4fv(this._uniforms[n.UNIFORM_MVMATRIX],t._renderCmd._stackMatrix.mat,1),this.setUniformLocationWithMatrix4fv(this._uniforms[n.UNIFORM_MVPMATRIX],i.mat,1),this._usesTime){var s=cc.director,o=s.getTotalFrames()*s.getAnimationInterval();this.setUniformLocationWith4f(this._uniforms[n.UNIFORM_TIME],o/10,o,2*o,4*o),this.setUniformLocationWith4f(this._uniforms[n.UNIFORM_SINTIME],o/8,o/4,o/2,Math.sin(o)),this.setUniformLocationWith4f(this._uniforms[n.UNIFORM_COSTIME],o/8,o/4,o/2,Math.cos(o))}-1!==this._uniforms[n.UNIFORM_RANDOM01]&&this.setUniformLocationWith4f(this._uniforms[n.UNIFORM_RANDOM01],Math.random(),Math.random(),Math.random(),Math.random())}},setUniformForModelViewProjectionMatrix:function(){this._glContext.uniformMatrix4fv(this._uniforms[n.UNIFORM_MVPMATRIX],!1,r.getMat4MultiplyValue(r.projection_matrix_stack.top,r.modelview_matrix_stack.top))},setUniformForModelViewProjectionMatrixWithMat4:function(t){r.mat4Multiply(t,r.projection_matrix_stack.top,r.modelview_matrix_stack.top),this._glContext.uniformMatrix4fv(this._uniforms[n.UNIFORM_MVPMATRIX],!1,t.mat)},setUniformForModelViewAndProjectionMatrixWithMat4:function(){this._glContext.uniformMatrix4fv(this._uniforms[n.UNIFORM_MVMATRIX],!1,r.modelview_matrix_stack.top.mat),this._glContext.uniformMatrix4fv(this._uniforms[n.UNIFORM_PMATRIX],!1,r.projection_matrix_stack.top.mat)},_setUniformForMVPMatrixWithMat4:function(t){if(!t)throw new Error("modelView matrix is undefined.");this._glContext.uniformMatrix4fv(this._uniforms[n.UNIFORM_MVMATRIX],!1,t.mat),this._glContext.uniformMatrix4fv(this._uniforms[n.UNIFORM_PMATRIX],!1,r.projection_matrix_stack.top.mat)},_updateProjectionUniform:function(){var t=r.projection_matrix_stack;t.lastUpdated!==this._projectionUpdated&&(this._glContext.uniformMatrix4fv(this._uniforms[n.UNIFORM_PMATRIX],!1,t.top.mat),this._projectionUpdated=t.lastUpdated)},vertexShaderLog:function(){return this._glContext.getShaderInfoLog(this._vertShader)},getVertexShaderLog:function(){return this._glContext.getShaderInfoLog(this._vertShader)},getFragmentShaderLog:function(){return this._glContext.getShaderInfoLog(this._vertShader)},fragmentShaderLog:function(){return this._glContext.getShaderInfoLog(this._fragShader)},programLog:function(){return this._glContext.getProgramInfoLog(this._programObj)},getProgramLog:function(){return this._glContext.getProgramInfoLog(this._programObj)},reset:function(){this._vertShader=null,this._fragShader=null,this._uniforms.length=0,this._glContext.deleteProgram(this._programObj),this._programObj=null;for(var t in this._hashForUniforms)this._hashForUniforms[t].length=0,delete this._hashForUniforms[t]},getProgram:function(){return this._programObj},retain:function(){},release:function(){}}),cc.GLProgram._highpSupported=null,cc.GLProgram._isHighpSupported=function(){var t=cc._renderContext;if(t.getShaderPrecisionFormat&&null==cc.GLProgram._highpSupported){var e=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT);cc.GLProgram._highpSupported=0!==e.precision}return cc.GLProgram._highpSupported}}),{}],271:[(function(t,e,i){var n=cc.macro.ENABLE_GL_STATE_CACHE,r=0,s=0,o=null,a=0,c=0;n&&(r=16,s=-1,o=new Array(r),a=-1,c=-1),cc.gl={},cc.gl.invalidateStateCache=function(){if(cc.math.glFreeAll(),-1,n){s=-1;for(var t=0;tthis._bufferCapacity){var i=cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT;if(this._bufferCapacity+=Math.max(this._bufferCapacity,t),null==e||0===e.length)this._buffer=[],this._trianglesArrayBuffer=new ArrayBuffer(i*this._bufferCapacity),this._trianglesReader=new Uint8Array(this._trianglesArrayBuffer);else{for(var n=[],r=new ArrayBuffer(i*this._bufferCapacity),s=0;s0,y=3*(3*d-2);this._ensureCapacity(y);var v,x,C,T=cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT,b=this._trianglesArrayBuffer,A=this._buffer;for(o=0;o0){var i=this._worldTransform,n=this._matrix.mat;n[0]=i.a,n[4]=i.c,n[12]=i.tx,n[1]=i.b,n[5]=i.d,n[13]=i.ty,cc.gl.blendFunc(e._blendFunc.src,e._blendFunc.dst),this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._matrix),e._render()}}}),{}],278:[(function(t,e,i){_ccsg.TMXLayer=_ccsg.Node.extend({tiles:null,tileset:null,layerOrientation:null,properties:null,layerName:"",_texture:null,_textures:null,_texGrids:null,_spriteTiles:null,_layerSize:null,_mapTileSize:null,_opacity:255,_minGID:null,_maxGID:null,_vertexZvalue:null,_useAutomaticVertexZ:null,_reusedTile:null,_contentScaleFactor:null,_staggerAxis:null,_staggerIndex:null,_hexSideLength:0,_className:"TMXLayer",ctor:function(t,e,i){cc.SpriteBatchNode.prototype.ctor.call(this),this._layerSize=cc.size(0,0),this._mapTileSize=cc.size(0,0),this._spriteTiles={},this._staggerAxis=cc.TiledMap.StaggerAxis.STAGGERAXIS_Y,this._staggerIndex=cc.TiledMap.StaggerIndex.STAGGERINDEX_EVEN,void 0!==i&&this.initWithTilesetInfo(t,e,i)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new _ccsg.TMXLayer.CanvasRenderCmd(this):new _ccsg.TMXLayer.WebGLRenderCmd(this)},_fillTextureGrids:function(t,e){var i=this._textures[e];if(i.isLoaded()){t.imageSize.width&&t.imageSize.height||(t.imageSize.width=i.width,t.imageSize.height=i.height);for(var n=t._tileSize.width,r=t._tileSize.height,s=i.width,o=i.height,a=t.spacing,c=t.margin,h=Math.floor((s-2*c+a)/(n+a)),l=Math.floor((o-2*c+a)/(r+a))*h,u=t.firstGid,_=t.firstGid+l,d=this._texGrids,f=null,p=!!d[u],m=cc.macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX?.5:0;u<_&&(p&&!d[u]&&(p=!1),p||!d[u]);++u)f={texId:e,x:0,y:0,width:n,height:r,t:0,l:0,r:0,b:0},t.rectForGID(u,f),f.x+=m,f.y+=m,f.width-=2*m,f.height-=2*m,f.t=f.y/o,f.l=f.x/s,f.r=(f.x+f.width)/s,f.b=(f.y+f.height)/o,d[u]=f}else i.once("load",(function(){this._fillTextureGrids(t,e)}),this)},initWithTilesetInfo:function(t,e,i){var n=e._layerSize;this.layerName=e.name,this.tiles=e._tiles,this.properties=e.properties,this._layerSize=n,this._minGID=e._minGID,this._maxGID=e._maxGID,this._opacity=e._opacity,this._staggerAxis=i.getStaggerAxis(),this._staggerIndex=i.getStaggerIndex(),this._hexSideLength=i.getHexSideLength(),this.tileset=t,this.layerOrientation=i.orientation,this._mapTileSize=i.getTileSize();var r=i._tilesets;if(r){var s,o,a,c=r.length;for(this._textures=new Array(c),this._texGrids=[],s=0;s0){for(this._reorderChildDirty&&this.sortAllChildren(),r=0;r=this._layerSize.width||e>=this._layerSize.height||i<0||e<0)throw new Error("_ccsg.TMXLayer.getTileAt(): invalid position");if(!this.tiles)return cc.logID(7204),null;var n=null,r=this.getTileGIDAt(i,e);if(0===r)return n;var s=Math.floor(i)+Math.floor(e)*this._layerSize.width;if(!(n=this._spriteTiles[s])){var o=this._texGrids[r],a=this._textures[o.texId];(n=new _ccsg.Sprite(a,o)).setPosition(this.getPositionAt(i,e));var c=this._vertexZForPos(i,e);n.setVertexZ(c),n.setAnchorPoint(0,0),n.setOpacity(this._opacity),this.addChild(n,c,s)}return n},getTileGIDAt:function(t,e){if(void 0===t)throw new Error("_ccsg.TMXLayer.getTileGIDAt(): pos should be non-null");var i=t;if(void 0===e&&(i=t.x,e=t.y),i>=this._layerSize.width||e>=this._layerSize.height||i<0||e<0)throw new Error("_ccsg.TMXLayer.getTileGIDAt(): invalid position");if(!this.tiles)return cc.logID(7205),null;var n=Math.floor(i)+Math.floor(e)*this._layerSize.width;return(this.tiles[n]&cc.TiledMap.TileFlag.FLIPPED_MASK)>>>0},setTileGID:function(t,e,i,n){if(void 0===e)throw new Error("_ccsg.TMXLayer.setTileGID(): pos should be non-null");var r;if(void 0===n&&e instanceof cc.Vec2?(r=e,n=i):r=cc.p(e,i),r.x=Math.floor(r.x),r.y=Math.floor(r.y),r.x>=this._layerSize.width||r.y>=this._layerSize.height||r.x<0||r.y<0)throw new Error("_ccsg.TMXLayer.setTileGID(): invalid position");if(this.tiles)if(0!==t&&t>>0;if(0===t)this.removeTileAt(r);else if(0===o)this._updateTileForGID(a,r);else{var c=r.x+r.y*this._layerSize.width,h=this.getChildByTag(c);if(h){var l=this._texGrids[t],u=this._textures[l.texId];h.setTexture(u),h.setTextureRect(l,!1),null!=n&&this._setupTileSprite(h,r,a),this.tiles[c]=a}else this._updateTileForGID(a,r)}}}else cc.logID(7206)},addChild:function(t,e,i){_ccsg.Node.prototype.addChild.call(this,t,e,i),void 0!==i&&(this._spriteTiles[i]=t,t._vertexZ=this._vertexZ+cc.renderer.assignedZStep*i/this.tiles.length)},removeChild:function(t,e){this._spriteTiles[t.tag]&&(this._spriteTiles[t.tag]=null),_ccsg.Node.prototype.removeChild.call(this,t,e)},getTileFlagsAt:function(t,e){if(!t)throw new Error("_ccsg.TMXLayer.getTileFlagsAt(): pos should be non-null");if(void 0!==e&&(t=cc.p(t,e)),t.x>=this._layerSize.width||t.y>=this._layerSize.height||t.x<0||t.y<0)throw new Error("_ccsg.TMXLayer.getTileFlagsAt(): invalid position");if(!this.tiles)return cc.logID(7208),null;var i=Math.floor(t.x)+Math.floor(t.y)*this._layerSize.width;return(this.tiles[i]&cc.TiledMap.TileFlag.FLIPPED_ALL)>>>0},removeTileAt:function(t,e){if(!t)throw new Error("_ccsg.TMXLayer.removeTileAt(): pos should be non-null");if(void 0!==e&&(t=cc.p(t,e)),t.x>=this._layerSize.width||t.y>=this._layerSize.height||t.x<0||t.y<0)throw new Error("_ccsg.TMXLayer.removeTileAt(): invalid position");if(this.tiles){if(0!==this.getTileGIDAt(t)){var i=Math.floor(t.x)+Math.floor(t.y)*this._layerSize.width;this.tiles[i]=0;var n=this._spriteTiles[i];n&&this.removeChild(n,!0)}}else cc.logID(7209)},getPositionAt:function(t,e){void 0!==e&&(t=cc.p(t,e)),t.x=Math.floor(t.x),t.y=Math.floor(t.y);var i=cc.p(0,0);switch(this.layerOrientation){case cc.TiledMap.Orientation.ORTHO:i=this._positionForOrthoAt(t);break;case cc.TiledMap.Orientation.ISO:i=this._positionForIsoAt(t);break;case cc.TiledMap.Orientation.HEX:i=this._positionForHexAt(t)}return i},_positionForIsoAt:function(t){return cc.p(this._mapTileSize.width/2*(this._layerSize.width+t.x-t.y-1),this._mapTileSize.height/2*(2*this._layerSize.height-t.x-t.y-2))},_positionForOrthoAt:function(t){return cc.p(t.x*this._mapTileSize.width,(this._layerSize.height-t.y-1)*this._mapTileSize.height)},_positionForHexAt:function(t){var e=cc.p(0,0),i=this.tileset.tileOffset,n=this._staggerIndex===cc.TiledMap.StaggerIndex.STAGGERINDEX_ODD?1:-1;switch(this._staggerAxis){case cc.TiledMap.StaggerAxis.STAGGERAXIS_Y:var r=0;t.y%2==1&&(r=this._mapTileSize.width/2*n),e=cc.p(t.x*this._mapTileSize.width+r+i.x,(this._layerSize.height-t.y-1)*(this._mapTileSize.height-(this._mapTileSize.height-this._hexSideLength)/2)-i.y);break;case cc.TiledMap.StaggerAxis.STAGGERAXIS_X:var s=0;t.x%2==1&&(s=this._mapTileSize.height/2*-n),e=cc.p(t.x*(this._mapTileSize.width-(this._mapTileSize.width-this._hexSideLength)/2)+i.x,(this._layerSize.height-t.y-1)*this._mapTileSize.height+s-i.y)}return e},_calculateLayerOffset:function(t){var e=cc.p(0,0);switch(this.layerOrientation){case cc.TiledMap.Orientation.ORTHO:e=cc.p(t.x*this._mapTileSize.width,-t.y*this._mapTileSize.height);break;case cc.TiledMap.Orientation.ISO:e=cc.p(this._mapTileSize.width/2*(t.x-t.y),this._mapTileSize.height/2*(-t.x-t.y));break;case cc.TiledMap.Orientation.HEX:if(this._staggerAxis===cc.TiledMap.StaggerAxis.STAGGERAXIS_Y){var i=this._staggerIndex===cc.TiledMap.StaggerIndex.STAGGERINDEX_EVEN?this._mapTileSize.width/2:0;e=cc.p(t.x*this._mapTileSize.width+i,-t.y*(this._mapTileSize.height-(this._mapTileSize.width-this._hexSideLength)/2))}else if(this._staggerAxis===cc.TiledMap.StaggerAxis.STAGGERAXIS_X){var n=this._staggerIndex===cc.TiledMap.StaggerIndex.STAGGERINDEX_ODD?this._mapTileSize.height/2:0;e=cc.p(t.x*(this._mapTileSize.width-(this._mapTileSize.width-this._hexSideLength)/2),-t.y*this._mapTileSize.height+n)}}return e},_updateTileForGID:function(t,e){if(this._texGrids[t]){var i=0|e.x+e.y*this._layerSize.width;i>>0){t.setAnchorPoint(.5,.5),t.setPosition(n.x+t.width/2,n.y+t.height/2);var r=(i&(cc.TiledMap.TileFlag.HORIZONTAL|cc.TiledMap.TileFlag.VERTICAL)>>>0)>>>0;r===cc.TiledMap.TileFlag.HORIZONTAL?t.setRotation(90):r===cc.TiledMap.TileFlag.VERTICAL?t.setRotation(270):r===(cc.TiledMap.TileFlag.VERTICAL|cc.TiledMap.TileFlag.HORIZONTAL)>>>0?(t.setRotation(90),t.setFlippedX(!0)):(t.setRotation(270),t.setFlippedX(!0))}else(i&cc.TiledMap.TileFlag.HORIZONTAL)>>>0&&t.setFlippedX(!0),(i&cc.TiledMap.TileFlag.VERTICAL)>>>0&&t.setFlippedY(!0)},_vertexZForPos:function(t,e){void 0===e&&(e=t.y,t=t.x);var i=0;if(this._useAutomaticVertexZ)switch(this.layerOrientation){case cc.TiledMap.Orientation.ISO:i=-(this._layerSize.width+this._layerSize.height-(t+e));break;case cc.TiledMap.Orientation.ORTHO:i=-(this._layerSize.height-e);break;case cc.TiledMap.Orientation.HEX:cc.logID(7210);break;default:cc.logID(7211)}else i=this._vertexZvalue;return i}})}),{}],279:[(function(t,e,i){t("../shape-nodes/CCDrawNode"),_ccsg.TMXObject=cc.Class({properties:{sgNode:null,offset:cc.p(0,0),gid:0,name:"",type:null,id:0,objectVisible:!0,objectSize:cc.size(0,0),objectRotation:0,_properties:null,_groupSize:cc.size(0,0)},initWithInfo:function(t,e,i,n){this.setProperties(t),this.setObjectName(t.name),this.id=t.id,this.gid=t.gid,this.type=t.type,this.offset=cc.p(t.x,t.y),this.objectSize=cc.size(t.width,t.height),this.objectVisible=t.visible,this.objectRotation=t.rotation,this._groupSize=i,this.type===cc.TiledMap.TMXObjectType.IMAGE?this.sgNode=new _ccsg.TMXObjectImage(this,e):this.sgNode=new _ccsg.TMXObjectShape(this,e,n)},getObjectName:function(){return this.name},getProperty:function(t){return this._properties[t]},getProperties:function(){return this._properties},setObjectName:function(t){this.name=t},setProperties:function(t){this._properties=t}}),_ccsg.TMXObjectImage=_ccsg.Sprite.extend({_container:null,ctor:function(t,e){_ccsg.Sprite.prototype.ctor.call(this),this._container=t,this.initWithMapInfo(e)},initWithMapInfo:function(t){if(!this._container.gid)return!1;for(var e,i=t.getTilesets(),n=i.length-1;n>=0;n--){var r=i[n];if((this._container.gid&cc.TiledMap.TileFlag.FLIPPED_MASK)>>>0>=r.firstGid){e=r;break}}if(!e)return!1;this.setVisible(this._container.objectVisible);var s=cc.textureCache.addImage(cc.path._normalize(r.sourceImage));return this._initWithTileset(s,e),this._initPosWithMapInfo(t),this.setRotation(this._container.objectRotation),(this._container.gid&cc.TiledMap.TileFlag.HORIZONTAL)>>>0&&this.setFlippedX(!0),(this._container.gid&cc.TiledMap.TileFlag.VERTICAL)>>>0&&this.setFlippedY(!0),!0},_initWithTileset:function(t,e){if(t.isLoaded()){e.imageSize.width=t.width,e.imageSize.height=t.height;var i=e.rectForGID(this._container.gid);this.initWithTexture(t,i),this.setScaleX(this._container.objectSize.width/i.size.width),this.setScaleY(this._container.objectSize.height/i.size.height)}else t.once("load",(function(){this._initWithTileset(t,e)}),this)},_initPosWithMapInfo:function(t){switch(t.getOrientation()){case cc.TiledMap.Orientation.ORTHO:case cc.TiledMap.Orientation.HEX:this.setAnchorPoint(cc.p(0,0)),this.setPosition(this._container.offset.x,this._container._groupSize.height-this._container.offset.y);break;case cc.TiledMap.Orientation.ISO:this.setAnchorPoint(cc.p(.5,0));var e=cc.p(this._container.offset.x/t._tileSize.height,this._container.offset.y/t._tileSize.height),i=cc.p(t._tileSize.width/2*(t._mapSize.width+e.x-e.y),t._tileSize.height/2*(2*t._mapSize.height-e.x-e.y));this.setPosition(i)}}}),_ccsg.TMXObjectShape=cc.DrawNode.extend({_container:null,_color:cc.Color.WHITE,_mapOrientation:0,_mapInfo:null,ctor:function(t,e,i){cc.DrawNode.prototype.ctor.call(this),this.setLineWidth(1),this._container=t,this._color=i,this._mapInfo=e,this._mapOrientation=e.getOrientation(),this._initShape()},_initShape:function(){var t;if(cc.TiledMap.Orientation.ISO!==this._mapOrientation){var e=cc.p(0,this._container._groupSize.height);t=cc.p(e.x+this._container.offset.x,e.y-this._container.offset.y)}else t=this._getPosByOffset(cc.p(0,0));switch(this.setPosition(t),this.setRotation(this._container.objectRotation),this._container.type){case cc.TiledMap.TMXObjectType.RECT:this._drawRect();break;case cc.TiledMap.TMXObjectType.ELLIPSE:this._drawEllipse();break;case cc.TiledMap.TMXObjectType.POLYGON:this._drawPoly(t,!0);break;case cc.TiledMap.TMXObjectType.POLYLINE:this._drawPoly(t,!1)}this.setVisible(this._container.objectVisible)},_getPosByOffset:function(t){var e=this._mapInfo.getMapSize(),i=this._mapInfo.getTileSize(),n=cc.p((this._container.offset.x+t.x)/i.width*2,(this._container.offset.y+t.y)/i.height);return cc.p(i.width/2*(e.width+n.x-n.y),i.height/2*(2*e.height-n.x-n.y))},_drawRect:function(){if(cc.TiledMap.Orientation.ISO!==this._mapOrientation){var t=this._container.objectSize;t.equals(cc.Size.ZERO)?(t=cc.size(20,20),this.setAnchorPoint(cc.p(.5,.5))):this.setAnchorPoint(cc.p(0,1));var e=cc.p(0,0),i=cc.p(t.width,t.height);this.drawRect(e,i,null,this.getLineWidth(),this._color),this.setContentSize(t)}else{if(this._container.objectSize.equals(cc.Size.ZERO))return;var n=this._getPosByOffset(cc.p(0,0)),r=this._getPosByOffset(cc.p(this._container.objectSize.width,0)),s=this._getPosByOffset(cc.p(this._container.objectSize.width,this._container.objectSize.height)),o=this._getPosByOffset(cc.p(0,this._container.objectSize.height)),a=r.x-o.x,c=n.y-s.y;this.setContentSize(cc.size(a,c)),this.setAnchorPoint(cc.p((n.x-o.x)/a,1));var h=cc.p(o.x,s.y);n.subSelf(h),r.subSelf(h),s.subSelf(h),o.subSelf(h),this._container.objectSize.width>0&&(this.drawSegment(n,r,this.getLineWidth(),this._color),this.drawSegment(s,o,this.getLineWidth(),this._color)),this._container.objectSize.height>0&&(this.drawSegment(n,o,this.getLineWidth(),this._color),this.drawSegment(s,r,this.getLineWidth(),this._color))}},_drawEllipse:function(){var t=1,e=1,i=0,n=cc.p(0,0),r=null;if(cc.TiledMap.Orientation.ISO!==this._mapOrientation){var s=this._container.objectSize;s.equals(cc.Size.ZERO)?(s=cc.size(20,20),this.setAnchorPoint(cc.p(.5,.5))):this.setAnchorPoint(cc.p(0,1)),n=cc.p(s.width/2,s.height/2),s.width>s.height?(t=s.width/s.height,i=s.height/2):(e=s.height/s.width,i=s.width/2),r=this,this.setContentSize(s)}else{if(this._container.objectSize.equals(cc.Size.ZERO))return;var o=this._getPosByOffset(cc.p(0,0)),a=this._getPosByOffset(cc.p(this._container.objectSize.width,0)),c=this._getPosByOffset(cc.p(this._container.objectSize.width,this._container.objectSize.height)),h=this._getPosByOffset(cc.p(0,this._container.objectSize.height)),l=a.x-h.x,u=o.y-c.y;this.setContentSize(cc.size(l,u)),this.setAnchorPoint(cc.p((o.x-h.x)/l,1));var _=cc.p(h.x,c.y);o.subSelf(_),a.subSelf(_),c.subSelf(_),h.subSelf(_),this._container.objectSize.width>0&&(this.drawSegment(o,a,this.getLineWidth(),this._color),this.drawSegment(c,h,this.getLineWidth(),this._color)),this._container.objectSize.height>0&&(this.drawSegment(o,h,this.getLineWidth(),this._color),this.drawSegment(c,a,this.getLineWidth(),this._color)),(n=this._getPosByOffset(cc.p(this._container.objectSize.width/2,this._container.objectSize.height/2))).subSelf(_),(r=new cc.DrawNode).setLineWidth(this.getLineWidth()),r.setContentSize(cc.size(l,u)),r.setAnchorPoint(cc.p(.5,.5)),r.setPosition(n),this.addChild(r),this._container.objectSize.width>this._container.objectSize.height?(t=this._container.objectSize.width/this._container.objectSize.height,i=this._container.objectSize.height/2):(e=this._container.objectSize.height/this._container.objectSize.width,i=this._container.objectSize.width/2);var d=this._mapInfo.getTileSize(),f=Math.atan(d.width/d.height);i/=Math.sin(f),r.setRotationX(cc.radiansToDegrees(f)),r.setRotationY(90-cc.radiansToDegrees(f))}r.drawCircle(n,i,0,50,!1,this.getLineWidth(),this._color),r.setScaleX(t),r.setScaleY(e)},_drawPoly:function(t,e){for(var i,n=this._container.getProperties(),r=[],s=0,o=0,a=0,c=0,h=0,l=(i=e?n.points:n.polylinePoints).length;h=0;i--){var n=e[i];n&&(n instanceof _ccsg.TMXLayer||n instanceof _ccsg.TMXObjectGroup)&&this.removeChild(n)}var r=0,s=t.getAllChildren();if(s&&s.length>0)for(var o=0,a=s.length;o=0;r--){var s=n[r];if(s)for(var o=0;o>>0>=s.firstGid)return s}}return cc.logID(7215,t.name),null}});var n=_ccsg.TMXTiledMap.prototype;n.mapWidth,cc.defineGetterSetter(n,"mapWidth",n._getMapWidth,n._setMapWidth),n.mapHeight,cc.defineGetterSetter(n,"mapHeight",n._getMapHeight,n._setMapHeight),n.tileWidth,cc.defineGetterSetter(n,"tileWidth",n._getTileWidth,n._setTileWidth),n.tileHeight,cc.defineGetterSetter(n,"tileHeight",n._getTileHeight,n._setTileHeight)}),{"./CCSGTMXObject":279,"./CCTMXXMLParser":284}],282:[(function(t,e,i){var n=null,r=null,s=null,o=null,a=null;_ccsg.TMXLayer.CanvasRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,n||(n=cc.TiledMap.Orientation,r=cc.TiledMap.TileFlag,s=r.FLIPPED_MASK,o=cc.TiledMap.StaggerAxis,a=cc.TiledMap.StaggerIndex)};var c=_ccsg.TMXLayer.CanvasRenderCmd.prototype=Object.create(_ccsg.Node.CanvasRenderCmd.prototype);c.constructor=_ccsg.TMXLayer.CanvasRenderCmd,c.rendering=function(t,e,i){var c=this._node,h=c.layerOrientation,l=c.tiles,u=c._opacity/255;if(l&&!(u<=0)&&c.tileset){var _=c._mapTileSize.width,d=c._mapTileSize.height,f=c.tileset._tileSize.width/cc.director._contentScaleFactor,p=c.tileset._tileSize.height/cc.director._contentScaleFactor,m=f-_,g=p-d,y=cc.winSize.width,v=cc.winSize.height,x=c._layerSize.height,C=c._layerSize.width,T=c._texGrids,b=c._spriteTiles,A=this._worldTransform,S=c._position.x,w=c._position.y,E=A.a,I=A.b,R=A.c,P=A.d,O=S*E+w*R+A.tx,B=S*I+w*P+A.ty,D=t||cc._renderContext,M=D.getContext(),L=0,N=0,F=C,k=x;cc.macro.ENABLE_TILEDMAP_CULLING&&h===n.ORTHO&&(L=Math.floor(-(O-m*E)/(_*E)),N=Math.floor((B-g*P+d*x*P-v)/(d*P)),F=Math.ceil((y-O+m*E)/(_*E)),k=x-Math.floor(-(B+g*P)/(d*P)),L<0&&(L=0),N<0&&(N=0),F>C&&(F=C),k>x&&(k=x));var z,V,G,W,U,j,X,Y,H,q,J,Z,Q,K,$,tt,et=N*C,it=f,nt=p,rt=f*E,st=p*P,ot=!1,at=!1;W=et+L;for(z in b)if(z=W)break;D.setTransform(A,e,i),D.setGlobalAlpha(u);var ct,ht,lt,ut,_t;if(h===n.HEX){var dt=c._staggerIndex,ft=c._hexSideLength;ct=c._staggerAxis,ht=c.tileset.tileOffset,lt=dt===a.STAGGERINDEX_ODD?1:-1,ut=ct===o.STAGGERAXIS_X?(_-ft)/2:0,_t=ct===o.STAGGERAXIS_Y?(d-ft)/2:0}for(V=N;V>>0])&&(X=c._textures[j.texId])&&X._image){switch(h){case n.ORTHO:q=G*_,J=-(x-V-1)*d;break;case n.ISO:q=_/2*(C+G-V-1),J=-d/2*(2*x-G-V-2);break;case n.HEX:q=G*(_-ut)+(ct===o.STAGGERAXIS_Y&&V%2==1?_/2*lt:0)+ht.x;J=-(x-V-1)*(d-_t)-(ct===o.STAGGERAXIS_X&&G%2==1?d/2*-lt:0)+ht.y}if(Z=q+f,H=J-p,h===n.ISO){if(($=J*P-B)<-v-st){G+=Math.floor(2*(-v-$)/st)-1;continue}if((tt=O+Z*E)<-rt){G+=Math.floor(2*-tt/rt)-1;continue}if(K=O+q*E,Q=H*P-B,K>y||Q>0){G=F;continue}}U>r.DIAGONAL&&(ot=(U&r.HORIZONTAL)>>>0,at=(U&r.VERTICAL)>>>0),ot&&(q=-Z,M.scale(-1,1)),at&&(H=-J,M.scale(1,-1)),M.drawImage(X._image,j.x,j.y,j.width,j.height,q,H,it,nt),ot&&M.scale(-1,1),at&&M.scale(1,-1),cc.g_NumberOfDraws++}et+=C}for(z in b)z>W&&b[z]&&(Y=b[z]._renderCmd,0===b[z]._localZOrder&&Y.rendering&&b[z]._visible&&Y.rendering(t,e,i))}}}),{}],283:[(function(t,e,i){function n(){cc.renderer.setDepthTest(!1)}var r=null,s=null,o=null,a=null,c=null;_ccsg.TMXLayer.WebGLRenderCmd=function(t){this._rootCtor(t),this._needDraw=!0,this._vertices=[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}],this._color=new Uint32Array(1),this._shaderProgram=cc.shaderCache.programForKey(cc.macro.SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST);var e=90*Math.PI/180;this._sin90=Math.sin(e),this._cos90=Math.cos(e),e*=3,this._sin270=Math.sin(e),this._cos270=Math.cos(e),r||(r=cc.TiledMap.Orientation,s=cc.TiledMap.TileFlag,o=s.FLIPPED_MASK,a=cc.TiledMap.StaggerAxis,c=cc.TiledMap.StaggerIndex),this._disableDepthTestCmd=new cc.CustomRenderCmd(this,n)};var h=_ccsg.TMXLayer.WebGLRenderCmd.prototype=Object.create(_ccsg.Node.WebGLRenderCmd.prototype);h.constructor=_ccsg.TMXLayer.WebGLRenderCmd,h.uploadData=function(t,e,i){var n=this._node,h=n.layerOrientation,l=n.tiles,u=n._opacity/255;if(cc.renderer.setDepthTest(n.layerOrientation===r.ORTHO),!l||u<=0||!n.tileset)return 0;var _=n._mapTileSize.width,d=n._mapTileSize.height,f=n.tileset._tileSize.width/cc.director._contentScaleFactor,p=n.tileset._tileSize.height/cc.director._contentScaleFactor,m=f-_,g=p-d,y=cc.winSize.width,v=cc.winSize.height,x=n._layerSize.height,C=n._layerSize.width,T=n._texGrids,b=n._spriteTiles,A=this._worldTransform,S=A.a,w=A.b,E=A.c,I=A.d,R=A.tx,P=A.ty,O=n._position.x,B=n._position.y,D=O*S+B*E+R,M=O*w+B*I+P,L=f*S,N=p*I,F=n._opacity,k=this._displayedColor.r,z=this._displayedColor.g,V=this._displayedColor.b;if(n._opacityModifyRGB){var G=F/255;k*=G,z*=G,V*=G}this._color[0]=F<<24|V<<16|z<<8|k;var W=0,U=0,j=C,X=x,Y=S,H=I,q=D,J=M,Z=L,Q=N,K=cc.macro.ENABLE_TILEDMAP_CULLING;if(K){if(this._cameraFlag>0){var $=cc.affineTransformConcat(A,cc.Camera.main.viewMatrix);Y=$.a,H=$.d,q=O*Y+B*$.c+$.tx,J=O*$.b+B*H+$.ty,Z=f*Y,Q=p*H}h===r.ORTHO&&(W=Math.floor(-(q-m*Y)/(_*Y)),U=Math.floor((J-g*H+d*x*H-v)/(d*H)),j=Math.ceil((y-q+m*Y)/(_*Y)),X=x-Math.floor(-(J+g*H)/(d*H)),W<0&&(W=0),U<0&&(U=0),j>C&&(j=C),X>x&&(X=x))}var tt,et,it,nt,rt,st,ot,at,ct,ht,lt,ut,_t,dt,ft,pt,mt,gt,yt,vt=i,xt=U*C,Ct=S,Tt=w,bt=E,At=I,St=R,wt=P,Et=!1,It=!1,Rt=!1,Pt=this._vertices;if(h===r.HEX){var Ot=n._staggerIndex,Bt=n._hexSideLength;ft=n._staggerAxis,pt=n.tileset.tileOffset,yt=Ot===c.STAGGERINDEX_ODD?1:-1,mt=ft===a.STAGGERAXIS_X?(_-Bt)/2:0,gt=ft===a.STAGGERAXIS_Y?(d-Bt)/2:0}for(tt=U;ttt.length&&(cc.renderer._increaseBatchingSize((vt-i)/6,cc.renderer.VertexType.QUAD),cc.renderer._batchRendering(),i=0,vt=0),it=xt+et,b[it])b[it]._vertexZ=n._vertexZ+cc.renderer.assignedZStep*it/l.length;else if(nt=n.tiles[it],rt=T[(nt&o)>>>0]){switch(h){case r.ORTHO:at=et*_,ct=(x-tt-1)*d,it=n._vertexZ+cc.renderer.assignedZStep*it/l.length;break;case r.ISO:at=_/2*(C+et-tt-1),ct=d/2*(2*x-et-tt-2),it=n._vertexZ+cc.renderer.assignedZStep*(n.height-ct)/n.height;break;case r.HEX:at=et*(_-mt)+(ft===a.STAGGERAXIS_Y&&tt%2==1?_/2*yt:0)+pt.x;ct=(x-tt-1)*(d-gt)+(ft===a.STAGGERAXIS_X&&et%2==1?d/2*-yt:0)-pt.y,it=n._vertexZ+cc.renderer.assignedZStep*(n.height-ct)/n.height}if(ht=at+f,ot=ct+p,K&&h===r.ISO){if((_t=J+ct*H)>v+Q){et+=Math.floor(2*(_t-v)/Q)-1;continue}if((dt=q+ht*Y)<-Z){et+=Math.floor(2*-dt/Z)-1;continue}if(ut=q+at*Y,lt=J+ot*H,ut>y||lt<0){et=j;continue}}for(nt>s.DIAGONAL&&(Et=!0,It=(nt&s.HORIZONTAL)>>>0,Rt=(nt&s.VERTICAL)>>>0),Pt[0].x=at*Ct+ot*bt+St,Pt[0].y=at*Tt+ot*At+wt,Pt[1].x=at*Ct+ct*bt+St,Pt[1].y=at*Tt+ct*At+wt,Pt[2].x=ht*Ct+ot*bt+St,Pt[2].y=ht*Tt+ot*At+wt,Pt[3].x=ht*Ct+ct*bt+St,Pt[3].y=ht*Tt+ct*At+wt,st=0;st<4;++st){switch(t[vt]=Pt[st].x,t[vt+1]=Pt[st].y,t[vt+2]=it,e[vt+3]=this._color[0],st){case 0:t[vt+4]=It?rt.r:rt.l,t[vt+5]=Rt?rt.b:rt.t;break;case 1:t[vt+4]=It?rt.r:rt.l,t[vt+5]=Rt?rt.t:rt.b;break;case 2:t[vt+4]=It?rt.l:rt.r,t[vt+5]=Rt?rt.b:rt.t;break;case 3:t[vt+4]=It?rt.l:rt.r,t[vt+5]=Rt?rt.t:rt.b}vt+=6}Et&&(Ct=S,Tt=w,bt=E,At=I,St=R,wt=P,It=!1,Rt=!1,Et=!1)}xt+=C}return(vt-i)/6}}),{}],284:[(function(t,e,i){function n(t){for(var e=[],i=t.getElementsByTagName("properties"),n=0;n0&&(f.type=cc.TiledMap.TMXObjectType.ELLIPSE);var x=d.getElementsByTagName("polygon");if(x&&x.length>0){f.type=cc.TiledMap.TMXObjectType.POLYGON;var C=x[0].getAttribute("points");C&&(f.points=this._parsePointsString(C))}var T=d.getElementsByTagName("polyline");if(T&&T.length>0){f.type=cc.TiledMap.TMXObjectType.POLYLINE;var b=T[0].getAttribute("points");b&&(f.polylinePoints=this._parsePointsString(b))}f.type||(f.type=cc.TiledMap.TMXObjectType.RECT),e._objects.push(f)}return e},_parsePointsString:function(t){if(!t)return null;for(var e=[],i=t.split(" "),n=0;n=0;i--){var n=e[i].getComponent(cc.TiledLayer);n&&(n.enabled=t)}},_moveLayersInSgNode:function(t){this._detachedChildren.length=0;for(var e=t.getChildren(),i=e.length-1;i>=0;i--){var n=e[i];if(n instanceof _ccsg.TMXLayer||n instanceof _ccsg.TMXObjectGroup){t.removeChild(n);var r=n.getLocalZOrder();this._detachedChildren.push({sgNode:n,zorder:r})}}},_removeLayerEntities:function(){for(var t=this.node.getChildren(),e=t.length-1;e>=0;e--){var i=t[e];if(i.isValid){var n=i.getComponent(cc.TiledLayer);n&&n._tryRemoveNode();var r=i.getComponent(cc.TiledObjectGroup);r&&r._tryRemoveNode()}}},_refreshLayerEntities:function(){var t,e,i=this.node.getChildren(),n=[],r=[],s=[];for(t=0;t=0;t--){var h=i[t],l=h.getComponent(cc.TiledLayer),u=h.getComponent(cc.TiledObjectGroup);if(l){var _=l.getLayerName();if(_||(_=h._name),a.indexOf(_)<0)l._tryRemoveNode();else{n.push(h);var d=this._sgNode.getLayer(_);l._replaceSgNode(d),l.enabled=!0}}else if(u){var f=u.getGroupName();if(f||(f=h._name),c.indexOf(f)<0)u._tryRemoveNode();else{r.push(h);var p=this._sgNode.getObjectGroup(f);u._replaceSgNode(p),u.enabled=p.isVisible()}}else s.push({child:h,index:h.getSiblingIndex()})}var m=n.map((function(t){return t.getComponent(cc.TiledLayer).getLayerName()}));for(t=0,e=a.length;t=0;t--){var P=E[t];if(t!==w.indexOf(P)){this.node.getChildByName(P).setSiblingIndex(I[t].getLocalZOrder())}}for(t=0,e=s.length;t":0});dragonBones.ArmatureDisplay=cc.Class({name:"dragonBones.ArmatureDisplay",extends:cc._RendererUnderSG,editor:!1,properties:{_factory:{default:null,type:dragonBones.CCFactory,serializable:!1},_dragonBonesData:{default:null,type:dragonBones.DragonBonesData,serializable:!1},dragonAsset:{default:null,type:dragonBones.DragonBonesAsset,notify:function(){this._parseDragonAsset(),this._refresh()},tooltip:!1},dragonAtlasAsset:{default:null,type:dragonBones.DragonBonesAtlasAsset,notify:function(){this._parseDragonAtlasAsset(),this._refreshSgNode()},tooltip:!1},_armatureName:"",armatureName:{get:function(){return this._armatureName},set:function(t){this._armatureName=t;var e=this.getAnimationNames(this._armatureName);(!this.animationName||e.indexOf(this.animationName)<0)&&(this.animationName=""),this._refresh()},visible:!1},_animationName:"",animationName:{get:function(){return this._animationName},set:function(t){this._animationName=t},visible:!1},_defaultArmatureIndex:{default:0,notify:function(){var t="";if(this.dragonAsset){var e;if(this.dragonAsset&&(e=this.dragonAsset.getArmatureEnum()),!e)return cc.errorID(7400,this.name);t=e[this._defaultArmatureIndex]}void 0!==t?this.armatureName=t:cc.errorID(7401,this.name)},type:n,visible:!0,editorOnly:!0,displayName:"Armature",tooltip:!1},_animationIndex:{default:0,notify:function(){if(0!==this._animationIndex){var t;if(this.dragonAsset&&(t=this.dragonAsset.getAnimsEnum(this.armatureName)),t){var e=t[this._animationIndex];void 0!==e?this.animationName=e:cc.errorID(7402,this.name)}}else this.animationName=""},type:r,visible:!0,editorOnly:!0,displayName:"Animation",tooltip:!1},timeScale:{default:1,notify:function(){this._sgNode&&(this._sgNode.animation().timeScale=this.timeScale)},tooltip:!1},playTimes:{default:-1,tooltip:!1},debugBones:{default:!1,notify:function(){this._sgNode&&this._sgNode.setDebugBones(this.debugBones)},editorOnly:!0,tooltip:!1}},ctor:function(){this._factory=dragonBones.CCFactory.getInstance()},__preload:function(){this._parseDragonAsset(),this._parseDragonAtlasAsset(),this._refresh()},_createSgNode:function(){return this.dragonAsset&&this.dragonAtlasAsset&&this.armatureName?this._factory.buildArmatureDisplay(this.armatureName,this._dragonBonesData.name):null},_initSgNode:function(){var t=this._sgNode;t.animation().timeScale=this.timeScale,this.animationName&&this.playAnimation(this.animationName,this.playTimes)},_removeSgNode:function(){var t=this._sgNode;this._super(),t&&t.armature().dispose()},_parseDragonAsset:function(){if(this.dragonAsset){var t=JSON.parse(this.dragonAsset.dragonBonesJson),e=this._factory.getDragonBonesData(t.name);if(e){for(var i,n,r=0,s=t.armature.length;r0)for(var s in n){var o=n[s];if(o&&o.texture&&o.texture.url===r){i=o;break}}var a=cc.textureCache.getTextureForKey(r);i?i.texture=a:this._factory.parseTextureAtlasData(t,a)}},_refreshSgNode:function(){var t=null,e=null;this._sgNode&&(t=this._sgNode._bubblingListeners,e=this._sgNode._hasListenerCache,this.node._sizeProvider===this._sgNode&&(this.node._sizeProvider=null),this._removeSgNode(),this._sgNode=null);var i=this._sgNode=this._createSgNode();i&&(this.enabledInHierarchy||i.setVisible(!1),t&&(i._bubblingListeners=t,i._hasListenerCache=e),this._initSgNode(),this._appendSgNode(i),this._registSizeProvider())},_refresh:function(){this._refreshSgNode()},_updateAnimEnum:!1,_updateArmatureEnum:!1,playAnimation:function(t,e){return this._sgNode?(this.playTimes=void 0===e?-1:e,this.animationName=t,this._sgNode.animation().play(t,this.playTimes)):null},getArmatureNames:function(){return this._dragonBonesData?this._dragonBonesData.armatureNames:[]},getAnimationNames:function(t){var e=[];if(this._dragonBonesData){var i=this._dragonBonesData.getArmature(t);if(i)for(var n in i.animations)i.animations.hasOwnProperty(n)&&e.push(n)}return e},addEventListener:function(t,e,i){this._sgNode&&this._sgNode.addEvent(t,e,i)},removeEventListener:function(t,e,i){this._sgNode&&this._sgNode.removeEvent(t,e,i)},buildArmature:function(t){return this._factory?this._factory.buildArmature(t):null},armature:function(){return this._sgNode?this._sgNode.armature():null}})}),{}],293:[(function(t,e,i){var n=t("../../cocos2d/core/event/event-target");t("../../cocos2d/shape-nodes/CCDrawNode"),dragonBones.CCArmatureDisplay=cc.Class({name:"dragonBones.CCArmatureDisplay",extends:_ccsg.Node,mixins:[n],_armature:null,_debugDrawer:null,_onClear:function(){this._armature=null},_dispatchEvent:function(t){this.emit(t.type,t)},_debugDraw:function(){if(this._armature){this._debugDrawer||(this._debugDrawer=new cc.DrawNode,this.addChild(this._debugDrawer),this._debugDrawer.setDrawColor(cc.color(255,0,0,255)),this._debugDrawer.setLineWidth(1)),this._debugDrawer.clear();for(var t=this._armature.getBones(),e=0,i=t.length;e0?r.actions:h.armatureData.actions;if(l.length>0)for(var u=0,_=l.length;u<_;++u)h._bufferAction(l[u]);else h.animation.play()}c.armature=h.armatureData}s.push(h);break;default:s.push(null)}}return i._setDisplayList(s),i._rawDisplay.setLocalZOrder(r.zOrder),i},getTextureDisplay:function(t,e){var i=this._getTextureData(e,t);if(i){if(!i.texture){var n=i.parent.texture,r=cc.rect(i.region.x,i.region.y,i.region.width,i.region.height),s=cc.p(0,0),o=cc.size(i.region.width,i.region.height);i.texture=new cc.SpriteFrame,i.texture.setTexture(n,r,i.rotated,s,o)}var a=new cc.Scale9Sprite;return a.initWithSpriteFrame(i.texture),a}return null}}),dragonBones.CCFactory._factory=null,dragonBones.CCFactory.getInstance=function(){return dragonBones.CCFactory._factory||(dragonBones.CCFactory._factory=new dragonBones.CCFactory),dragonBones.CCFactory._factory}}),{}],295:[(function(t,e,i){dragonBones.CCSlot=cc.Class({name:"dragonBones.CCSlot",extends:dragonBones.Slot,_renderDisplay:null,statics:{toString:function(){return"[class dragonBones.CCSlot]"}},_onClear:function(){dragonBones.Slot.prototype._onClear.call(this),this._renderDisplay=null},_onUpdateDisplay:function(){this._rawDisplay||(this._rawDisplay=new cc.Scale9Sprite),this._renderDisplay=this._display||this._rawDisplay},_initDisplay:function(t){},_addDisplay:function(){this._armature._display.addChild(this._renderDisplay)},_replaceDisplay:function(t){var e=this._armature._display,i=t;e.addChild(this._renderDisplay,i.getLocalZOrder()),e.removeChild(i)},_removeDisplay:function(){this._renderDisplay.removeFromParent()},_disposeDisplay:function(t){},_updateVisible:function(){this._renderDisplay.setVisible(this._parent.visible)},_updateZOrder:function(){if(this._renderDisplay._parent)this._renderDisplay.setLocalZOrder(this._zOrder);else{this._armature._display.addChild(this._renderDisplay,this._zOrder)}},_updateBlendMode:function(){if(this._renderDisplay instanceof cc.Scale9Sprite)switch(this._blendMode){case 0:break;case 1:var t=this._renderDisplay._spriteFrame.getTexture();t&&t.hasPremultipliedAlpha()?this._renderDisplay.setBlendFunc(cc.BlendFunc.BlendFactor.ONE,cc.BlendFunc.BlendFactor.ONE):this._renderDisplay.setBlendFunc(cc.BlendFunc.BlendFactor.SRC_ALPHA,cc.BlendFunc.BlendFactor.ONE)}else if(this._childArmature)for(var e=this._childArmature.getSlots(),i=0,n=e.length;i=0){var t=this._displayIndexp&&(_.x=p),_.width-m&&(_.y=-m),_.height<-m&&(_.height=-m)}for(_.width-=_.x,_.height-=_.y,d=0,f=this._meshData.vertexIndices.length;d0,s=e.triangles.verts,o=cc.rect(999999,999999,-999999,-999999),a=0,c=0,h=0;if(this._meshData.skinned){var l=0;for(i=0,n=this._meshData.vertices.length;ic&&(o.x=c),o.width-h&&(o.y=-h),o.height<-h&&(o.height=-h)}}else if(r){var x=this._meshData.vertices;for(i=0,n=this._meshData.vertices.length;ic&&(o.x=c),o.width-h&&(o.y=-h),o.height<-h&&(o.height=-h)}o.width-=o.x,o.height-=o.y,e.rect=o;var C=t.getNodeToParentTransform();t.setContentSize(cc.size(o.width,o.height)),t.setMeshPolygonInfo(e),this._renderDisplay._renderCmd.setNodeToParentTransform(C)}},_updateTransform:function(){var t={a:this.globalTransformMatrix.a,b:-this.globalTransformMatrix.b,c:-this.globalTransformMatrix.c,d:this.globalTransformMatrix.d,tx:this.globalTransformMatrix.tx-(this.globalTransformMatrix.a*this._pivotX+this.globalTransformMatrix.c*this._pivotY),ty:-(this.globalTransformMatrix.ty-(this.globalTransformMatrix.b*this._pivotX+this.globalTransformMatrix.d*this._pivotY))};this._renderDisplay._renderCmd.setNodeToParentTransform(t)}})}),{}],296:[(function(t,e,i){dragonBones.CCTextureAtlasData=cc.Class({name:"dragonBones.CCTextureAtlasData",extends:dragonBones.TextureAtlasData,texture:null,statics:{toString:function(){return"[class dragonBones.CCTextureAtlasData]"}},_onClear:function(){dragonBones.TextureAtlasData.prototype._onClear.call(this),this.texture=null},generateTextureData:function(){return dragonBones.BaseObject.borrowObject(dragonBones.CCTextureData)}}),dragonBones.CCTextureData=cc.Class({name:"dragonBones.CCTextureData",extends:dragonBones.TextureData,texture:null,statics:{toString:function(){return"[class dragonBones.CCTextureData]"}},_onClear:function(){dragonBones.TextureData.prototype._onClear.call(this),this.texture&&(this.texture.dispose(),this.texture=null)}})}),{}],297:[(function(t,e,i){var n=cc.Class({name:"dragonBones.DragonBonesAsset",extends:cc.Asset,properties:{_dragonBonesJson:"",dragonBonesJson:{get:function(){return this._dragonBonesJson},set:function(t){this._dragonBonesJson=t,this.reset()}}},statics:{preventDeferredLoadDependents:!0},createNode:!1,reset:function(){0},getRuntimeData:!1,getArmatureEnum:!1,getAnimsEnum:!1});dragonBones.DragonBonesAsset=e.exports=n}),{}],298:[(function(t,e,i){var n=cc.Class({name:"dragonBones.DragonBonesAtlasAsset",extends:cc.Asset,properties:{_atlasJson:"",atlasJson:{get:function(){return this._atlasJson},set:function(t){this._atlasJson=t}},texture:{default:"",url:cc.Texture2D}},statics:{preventDeferredLoadDependents:!0},createNode:!1});dragonBones.DragonBonesAtlasAsset=e.exports=n}),{}],299:[(function(t,e,i){dragonBones=t("./lib/dragonBones"),dragonBones.DisplayType={Image:0,Armature:1,Mesh:2},dragonBones.ArmatureType={Armature:0,MovieClip:1,Stage:2},dragonBones.ExtensionType={FFD:0,AdjustColor:10,BevelFilter:11,BlurFilter:12,DropShadowFilter:13,GlowFilter:14,GradientBevelFilter:15,GradientGlowFilter:16},dragonBones.EventType={Frame:0,Sound:1},dragonBones.ActionType={Play:0,Stop:1,GotoAndPlay:2,GotoAndStop:3,FadeIn:4,FadeOut:5},dragonBones.AnimationFadeOutMode={None:0,SameLayer:1,SameGroup:2,SameLayerAndGroup:3,All:4},t("./CCFactory"),t("./CCSlot"),t("./CCTextureData"),t("./CCArmatureDisplay"),t("./DragonBonesAsset"),t("./DragonBonesAtlasAsset"),t("./ArmatureDisplay")}),{"./ArmatureDisplay":292,"./CCArmatureDisplay":293,"./CCFactory":294,"./CCSlot":295,"./CCTextureData":296,"./DragonBonesAsset":297,"./DragonBonesAtlasAsset":298,"./lib/dragonBones":300}],300:[(function(t,e,i){var n=this&&this.__extends||function(t,e){function i(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)};(function(t){var e=(function(){function t(){}return t.hasArmature=function(e){return t._armatures.indexOf(e)>=0},t.addArmature=function(e){e&&t._armatures.indexOf(e)<0&&t._armatures.push(e)},t.removeArmature=function(e){if(e){var i=t._armatures.indexOf(e);i>=0&&t._armatures.splice(i,1)}},t.PI_D=2*Math.PI,t.PI_H=Math.PI/2,t.PI_Q=Math.PI/4,t.ANGLE_TO_RADIAN=Math.PI/180,t.RADIAN_TO_ANGLE=180/Math.PI,t.SECOND_TO_MILLISECOND=1e3,t.NO_TWEEN=100,t.VERSION="4.7.2",t.debug=!1,t.debugDraw=!1,t._armatures=[],t})();t.DragonBones=e})(r||(r={}));(function(t){var e=(function(){function t(){this.hashCode=t._hashCode++}return t._returnObject=function(e){var i=String(e.constructor),n=null==t._maxCountMap[i]?t._defaultMaxCount:t._maxCountMap[i],r=t._poolsMap[i]=t._poolsMap[i]||[];if(r.lengthi&&(r.length=i)}else{t._defaultMaxCount=i;for(var n in t._poolsMap)if(null!=t._maxCountMap[n]){t._maxCountMap[n]=i;var r;(r=t._poolsMap[n]).length>i&&(r.length=i)}}},t.clearPool=function(e){if(void 0===e&&(e=null),e){(n=t._poolsMap[String(e)])&&n.length&&(n.length=0)}else for(var i in t._poolsMap){var n;(n=t._poolsMap[i]).length=0}},t.borrowObject=function(e){var i=t._poolsMap[String(e)];if(i&&i.length)return i.pop();var n=new e;return n._onClear(),n},t.prototype.returnToPool=function(){this._onClear(),t._returnObject(this)},t._hashCode=0,t._defaultMaxCount=5e3,t._maxCountMap={},t._poolsMap={},t})();t.BaseObject=e})(r||(r={}));(function(t){var e=(function(){function t(t,e,i,n,r,s,o,a){void 0===t&&(t=1),void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===a&&(a=0),this.alphaMultiplier=t,this.redMultiplier=e,this.greenMultiplier=i,this.blueMultiplier=n,this.alphaOffset=r,this.redOffset=s,this.greenOffset=o,this.blueOffset=a}return t.prototype.copyFrom=function(t){this.alphaMultiplier=t.alphaMultiplier,this.redMultiplier=t.redMultiplier,this.greenMultiplier=t.greenMultiplier,this.blueMultiplier=t.blueMultiplier,this.alphaOffset=t.alphaOffset,this.redOffset=t.redOffset,this.redOffset=t.redOffset,this.greenOffset=t.blueOffset},t.prototype.identity=function(){this.alphaMultiplier=this.redMultiplier=this.greenMultiplier=this.blueMultiplier=1,this.alphaOffset=this.redOffset=this.greenOffset=this.blueOffset=0},t})();t.ColorTransform=e})(r||(r={}));(function(t){var e=(function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e}return t.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y},t.prototype.clear=function(){this.x=this.y=0},t})();t.Point=e})(r||(r={}));(function(t){var e=(function(){function t(t,e,i,n,r,s){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=0),void 0===s&&(s=0),this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,this.ty=s}return t.prototype.toString=function(){return"[object dragonBones.Matrix] a:"+this.a+" b:"+this.b+" c:"+this.c+" d:"+this.d+" tx:"+this.tx+" ty:"+this.ty},t.prototype.copyFrom=function(t){this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty},t.prototype.identity=function(){this.a=this.d=1,this.b=this.c=0,this.tx=this.ty=0},t.prototype.concat=function(t){var e=this.a,i=this.b,n=this.c,r=this.d,s=this.tx,o=this.ty,a=t.a,c=t.b,h=t.c,l=t.d,u=t.tx,_=t.ty;this.a=e*a+i*h,this.b=e*c+i*l,this.c=n*a+r*h,this.d=n*c+r*l,this.tx=a*s+h*o+u,this.ty=l*o+c*s+_},t.prototype.invert=function(){var t=this.a,e=this.b,i=this.c,n=this.d,r=this.tx,s=this.ty,o=t*n-e*i;this.a=n/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*s-n*r)/o,this.ty=-(t*s-e*r)/o},t.prototype.transformPoint=function(t,e,i,n){void 0===n&&(n=!1),i.x=this.a*t+this.c*e,i.y=this.b*t+this.d*e,n||(i.x+=this.tx,i.y+=this.ty)},t})();t.Matrix=e})(r||(r={}));(function(t){var e=(function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.width=i,this.height=n}return t.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height},t.prototype.clear=function(){this.x=this.y=0,this.width=this.height=0},t})();t.Rectangle=e})(r||(r={}));(function(t){var e=(function(){function t(t,e,i,n,r,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=1),void 0===s&&(s=1),this.x=t,this.y=e,this.skewX=i,this.skewY=n,this.scaleX=r,this.scaleY=s}return t.normalizeRadian=function(t){return t=(t+Math.PI)%(2*Math.PI),t+=t>0?-Math.PI:Math.PI},t.prototype.toString=function(){return"[object dragonBones.Transform] x:"+this.x+" y:"+this.y+" skewX:"+180*this.skewX/Math.PI+" skewY:"+180*this.skewY/Math.PI+" scaleX:"+this.scaleX+" scaleY:"+this.scaleY},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.skewX=t.skewX,this.skewY=t.skewY,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this},t.prototype.identity=function(){return this.x=this.y=this.skewX=this.skewY=0,this.scaleX=this.scaleY=1,this},t.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this.skewX+=t.skewX,this.skewY+=t.skewY,this.scaleX*=t.scaleX,this.scaleY*=t.scaleY,this},t.prototype.minus=function(e){return this.x-=e.x,this.y-=e.y,this.skewX=t.normalizeRadian(this.skewX-e.skewX),this.skewY=t.normalizeRadian(this.skewY-e.skewY),this.scaleX/=e.scaleX,this.scaleY/=e.scaleY,this},t.prototype.fromMatrix=function(t){var e=.25*Math.PI,i=this.scaleX,n=this.scaleY;return this.x=t.tx,this.y=t.ty,this.skewX=Math.atan(-t.c/t.d),this.skewY=Math.atan(t.b/t.a),this.skewX!=this.skewX&&(this.skewX=0),this.skewY!=this.skewY&&(this.skewY=0),this.scaleY=this.skewX>-e&&this.skewX-e&&this.skewY=0&&this.scaleX<0&&(this.scaleX=-this.scaleX,this.skewY=this.skewY-Math.PI),n>=0&&this.scaleY<0&&(this.scaleY=-this.scaleY,this.skewX=this.skewX-Math.PI),this},t.prototype.toMatrix=function(t){return t.a=this.scaleX*Math.cos(this.skewY),t.b=this.scaleX*Math.sin(this.skewY),t.c=-this.scaleY*Math.sin(this.skewX),t.d=this.scaleY*Math.cos(this.skewX),t.tx=this.x,t.ty=this.y,this},Object.defineProperty(t.prototype,"rotation",{get:function(){return this.skewY},set:function(t){var e=t-this.skewY;this.skewX+=e,this.skewY+=e},enumerable:!0,configurable:!0}),t})();t.Transform=e})(r||(r={}));(function(t){var e=(function(t){function e(){t.call(this)}return n(e,t),e.prototype._onClear=function(){this._isCompleted=!1,this._currentPlayTimes=0,this._currentTime=-1,this._timeline=null,this._isReverse=!1,this._hasAsynchronyTimeline=!1,this._frameRate=0,this._keyFrameCount=0,this._frameCount=0,this._position=0,this._duration=0,this._animationDutation=0,this._timeScale=1,this._timeOffset=0,this._currentFrame=null,this._armature=null,this._animationState=null},e.prototype._onUpdateFrame=function(t){},e.prototype._onArriveAtFrame=function(t){},e.prototype._setCurrentTime=function(t){var e=0;if(1==this._keyFrameCount&&this!=this._animationState._timeline)this._isCompleted=this._animationState._fadeState>=0,e=1;else if(this._hasAsynchronyTimeline){var i=this._animationState.playTimes,n=i*this._duration;t*=this._timeScale,0!=this._timeOffset&&(t+=this._timeOffset*this._animationDutation),i>0&&(t>=n||t<=-n)?(this._isCompleted=!0,e=i,t=t<0?0:this._duration):(this._isCompleted=!1,t<0?(e=Math.floor(-t/this._duration),t=this._duration- -t%this._duration):(e=Math.floor(t/this._duration),t%=this._duration),i>0&&e>i&&(e=i)),t+=this._position}else this._isCompleted=this._animationState._timeline._isCompleted,e=this._animationState._timeline._currentPlayTimes;return this._currentTime!=t&&(this._isReverse=this._currentTime>t&&this._currentPlayTimes==e,this._currentTime=t,this._currentPlayTimes=e,this._animationState._onFadeInComplete&&(this._currentFrame=null),!0)},e.prototype.fadeIn=function(t,e,i,n){this._armature=t,this._animationState=e,this._timeline=i;var r=this==this._animationState._timeline;this._hasAsynchronyTimeline=r||this._animationState.animationData.hasAsynchronyTimeline,this._frameRate=this._armature.armatureData.frameRate,this._keyFrameCount=this._timeline.frames.length,this._frameCount=this._animationState.animationData.frameCount,this._position=this._animationState._position,this._duration=this._animationState._duration,this._animationDutation=this._animationState.animationData.duration,this._timeScale=r?1:1/this._timeline.scale,this._timeOffset=r?0:this._timeline.offset},e.prototype.fadeOut=function(){},e.prototype.update=function(t){if(!this._isCompleted&&this._setCurrentTime(t)){var e=this._keyFrameCount>1?Math.floor(this._currentTime*this._frameRate):0,i=this._timeline.frames[e];this._currentFrame!=i&&(this._currentFrame=i,this._onArriveAtFrame(!0)),this._onUpdateFrame(!0)}},e})(t.BaseObject);t.TimelineState=e;var i=(function(e){function i(){e.call(this)}return n(i,e),i._getEasingValue=function(t,e){if(t<=0)return 0;if(t>=1)return 1;var i=1;if(e>2)return t;if(e>1)i=.5*(1-Math.cos(t*Math.PI)),e-=1;else if(e>0)i=1-Math.pow(1-t,2);else if(e>=-1)e*=-1,i=Math.pow(t,2);else{if(!(e>=-2))return t;e*=-1,i=Math.acos(1-2*t)/Math.PI,e-=1}return(i-t)*e+t},i._getEasingCurveValue=function(t,e){if(t<=0)return 0;if(t>=1)return 1;var i=e.length+1,n=Math.floor(t*i),r=0==n?0:e[n-1];return r+((n==i-1?1:e[n])-r)*(t-n/i)},i.prototype._onClear=function(){e.prototype._onClear.call(this),this._tweenProgress=0,this._tweenEasing=t.DragonBones.NO_TWEEN,this._curve=null},i.prototype._onArriveAtFrame=function(e){this._tweenEasing=this._currentFrame.tweenEasing,this._curve=this._currentFrame.curve,(this._keyFrameCount<=1||this._currentFrame.next==this._timeline.frames[0]&&(this._tweenEasing!=t.DragonBones.NO_TWEEN||this._curve)&&this._animationState.playTimes>0&&this._animationState.currentPlayTimes==this._animationState.playTimes-1)&&(this._tweenEasing=t.DragonBones.NO_TWEEN,this._curve=null)},i.prototype._onUpdateFrame=function(e){this._tweenEasing!=t.DragonBones.NO_TWEEN?(this._tweenProgress=(this._currentTime-this._currentFrame.position+this._position)/this._currentFrame.duration,0!=this._tweenEasing&&(this._tweenProgress=i._getEasingValue(this._tweenProgress,this._tweenEasing))):this._curve?(this._tweenProgress=(this._currentTime-this._currentFrame.position+this._position)/this._currentFrame.duration,this._tweenProgress=i._getEasingCurveValue(this._tweenProgress,this._curve)):this._tweenProgress=0},i.prototype._updateExtensionKeyFrame=function(t,e,i){var n=0;if(t.type==e.type)for(var r=0,s=t.tweens.length;r0&&(n=2)}if(0==n){i.type!=t.type&&(n=1,i.type=t.type),i.tweens.length!=t.tweens.length&&(n=1,i.tweens.length=t.tweens.length),i.keys.length!=t.keys.length&&(n=1,i.keys.length=t.keys.length);for(r=0,s=t.keys.length;re.layer?-1:1},i.toString=function(){return"[class dragonBones.Animation]"},i.prototype._onClear=function(){for(var t in this._animations)delete this._animations[t];t=0;for(var e=this._animationStates.length;t0&&c._fadeProgress<=0?(c.returnToPool(),this._animationStates.length=0,this._animationStateDirty=!0,this._lastAnimationState=null):c._advanceTime(t,1,0)}else if(e>1)for(var i=this._animationStates[0]._layer,n=1,r=0,s=1,o=0,a=0;o0&&c._fadeProgress<=0?(a++,c.returnToPool(),this._animationStateDirty=!0,this._lastAnimationState==c&&(this._lastAnimationState=o-a>=0?this._animationStates[o-a]:null)):(a>0&&(this._animationStates[o-a]=c),i!=c._layer&&(i=c._layer,r>=n?n=0:n-=r,r=0),c._advanceTime(t,n,s),c._weightResult>0&&(r+=c._weightResult,s++)),o==e-1&&a>0&&(this._animationStates.length-=a)}}},i.prototype.reset=function(){for(var t=0,e=this._animationStates.length;t0?0:this._time,f=this._duration>0?this._time:_.position,p=this._duration>0?this._duration:_.duration;this._lastAnimationState=t.BaseObject.borrowObject(t.AnimationState),this._lastAnimationState._layer=s,this._lastAnimationState._group=o,this._lastAnimationState.additiveBlending=c,this._lastAnimationState.displayControl=h,this._lastAnimationState._fadeIn(this._armature,_.animation||_,e,r,f,p,d,1/_.scale,n,u),this._animationStates.push(this._lastAnimationState),this._animationStateDirty=!0,this._time=0,this._duration=0,this._armature._cacheFrameIndex=-1,this._animationStates.length>1&&this._animationStates.sort(i._sortAnimationState);for(var m=this._armature.getSlots(),g=0,y=m.length;gr.duration-this._time&&(this._duration=r.duration-this._time)),this.fadeIn(t,0,i,0,null,4)},i.prototype.gotoAndPlayByFrame=function(t,e,i,n){void 0===e&&(e=0),void 0===i&&(i=-1),void 0===n&&(n=0);var r=this._animations[t];return r&&(this._time=r.duration*e/r.frameCount,this._duration<0?this._duration=0:this._duration>r.duration-this._time&&(this._duration=r.duration-this._time)),this.fadeIn(t,0,i,0,null,4)},i.prototype.gotoAndPlayByProgress=function(t,e,i,n){void 0===e&&(e=0),void 0===i&&(i=-1),void 0===n&&(n=0);var r=this._animations[t];return r&&(this._time=r.duration*(e>0?e:0),this._duration<0?this._duration=0:this._duration>r.duration-this._time&&(this._duration=r.duration-this._time)),this.fadeIn(t,0,i,0,null,4)},i.prototype.gotoAndStopByTime=function(t,e){void 0===e&&(e=0);var i=this.gotoAndPlayByTime(t,e,1);return i&&i.stop(),i},i.prototype.gotoAndStopByFrame=function(t,e){void 0===e&&(e=0);var i=this.gotoAndPlayByFrame(t,e,1);return i&&i.stop(),i},i.prototype.gotoAndStopByProgress=function(t,e){void 0===e&&(e=0);var i=this.gotoAndPlayByProgress(t,e,1);return i&&i.stop(),i},i.prototype.getState=function(t){for(var e=0,i=this._animationStates.length;e1?this._isPlaying&&!this.isCompleted:this._lastAnimationState?this._isPlaying&&this._lastAnimationState.isPlaying:this._isPlaying},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isCompleted",{get:function(){if(this._lastAnimationState){if(!this._lastAnimationState.isCompleted)return!1;for(var t=0,e=this._animationStates.length;t0&&(h.timeScale=h.totalTime/i),h},i.prototype.gotoAndStop=function(t,e){return void 0===e&&(e=0),this.gotoAndStopByTime(t,e)},Object.defineProperty(i.prototype,"animationList",{get:function(){return this._animationNames},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationDataList",{get:function(){for(var t=[],e=0,i=this._animationNames.length;e=this.fadeTotalTime?this._fadeState>0?0:1:this._fadeTime>0?this._fadeState>0?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime:this._fadeState>0?1:0,this._fadeProgress!=i){this._fadeProgress=i;var n=this._armature._display;if(this._fadeTime<=e)if(this._fadeState>0){if(n.hasEvent(t.EventObject.FADE_OUT)){var r=t.BaseObject.borrowObject(t.EventObject);r.animationState=this,this._armature._bufferEvent(r,t.EventObject.FADE_OUT)}}else if(n.hasEvent(t.EventObject.FADE_IN)){var s=t.BaseObject.borrowObject(t.EventObject);s.animationState=this,this._armature._bufferEvent(s,t.EventObject.FADE_IN)}if(this._fadeTime>=this.fadeTotalTime)if(this._fadeState>0){if(n.hasEvent(t.EventObject.FADE_OUT_COMPLETE)){var o=t.BaseObject.borrowObject(t.EventObject);o.animationState=this,this._armature._bufferEvent(o,t.EventObject.FADE_OUT_COMPLETE)}}else if(this._onFadeInComplete=!0,this._isPausePlayhead=!1,this._fadeState=0,n.hasEvent(t.EventObject.FADE_IN_COMPLETE)){var a=t.BaseObject.borrowObject(t.EventObject);a.animationState=this,this._armature._bufferEvent(a,t.EventObject.FADE_IN_COMPLETE)}}},i.prototype._isDisabled=function(t){return!(this.displayControl&&(!t.displayController||t.displayController==this._name||t.displayController==this._group))},i.prototype._fadeIn=function(e,n,r,s,o,a,c,h,l,u){this._armature=e,this._animationData=n,this._name=r,this.actionEnabled=i.stateActionEnabled,this.playTimes=s,this.timeScale=h,this.fadeTotalTime=l,this._fadeState=-1,this._position=o,this._duration=a,this._time=c,this._isPausePlayhead=u,this.fadeTotalTime<=0&&(this._fadeProgress=.999999),this._timeline=t.BaseObject.borrowObject(t.AnimationTimelineState),this._timeline.fadeIn(this._armature,this,this._animationData,this._time),this._animationData.zOrderTimeline&&(this._zOrderTimeline=t.BaseObject.borrowObject(t.ZOrderTimelineState),this._zOrderTimeline.fadeIn(this._armature,this,this._animationData.zOrderTimeline,this._time)),this._updateTimelineStates()},i.prototype._updateFFDTimelineStates=function(){var e=this._time;this._animationData.hasAsynchronyTimeline||(e=this._timeline._currentTime);for(var i={},n=0,r=this._ffdTimelines.length;n=1&&0==i&&n>0,s=!0,o=!0,a=2*n;if(a=r?Math.floor(this._time*a)/a:this._time,this._timeline.update(a),this._animationData.hasAsynchronyTimeline||(a=this._timeline._currentTime),this._zOrderTimeline&&this._zOrderTimeline.update(a),r){var c=Math.floor(this._timeline._currentTime*n);if(this._armature._cacheFrameIndex==c)s=!1,o=!1;else{if(this._armature._cacheFrameIndex=c,this._armature._animation._animationStateDirty){this._armature._animation._animationStateDirty=!1;for(var h=0,l=this._boneTimelines.length;h=0&&this._fadeProgress>=1&&this._timeline._isCompleted&&this.fadeOut(this.autoFadeOutTime)},i.prototype.play=function(){this._isPlaying=!0},i.prototype.stop=function(){this._isPlaying=!1},i.prototype.fadeOut=function(t,e){if(void 0===e&&(e=!0),(t<0||t!=t)&&(t=0),this._isPausePlayhead=e,this._fadeState>0){if(t>t-this._fadeTime)return}else{this._fadeState=1,(t<=0||this._fadeProgress<=0)&&(this._fadeProgress=1e-6);for(var i=0,n=this._boneTimelines.length;i1e-6?t/this._fadeProgress:0,this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)},i.prototype.containsBoneMask=function(t){return!this._boneMask.length||this._boneMask.indexOf(t)>=0},i.prototype.addBoneMask=function(t,e){void 0===e&&(e=!0);var i=this._armature.getBone(t);if(i){if(this._boneMask.indexOf(t)<0&&this._animationData.getBoneTimeline(t)&&this._boneMask.push(t),e)for(var n=this._armature.getBones(),r=0,s=n.length;r=0&&this._boneMask.splice(i,1),e){var n=this._armature.getBone(t);if(n)for(var r=this._armature.getBones(),s=0,o=r.length;s=0&&n.contains(a)&&this._boneMask.splice(h,1)}}this._updateTimelineStates()},i.prototype.removeAllBoneMask=function(){this._boneMask.length=0,this._updateTimelineStates()},Object.defineProperty(i.prototype,"layer",{get:function(){return this._layer},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"group",{get:function(){return this._group},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationData",{get:function(){return this._animationData},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isCompleted",{get:function(){return this._timeline._isCompleted},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isPlaying",{get:function(){return this._isPlaying&&!this._timeline._isCompleted},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"currentPlayTimes",{get:function(){return this._timeline._currentPlayTimes},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"totalTime",{get:function(){return this._duration},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"currentTime",{get:function(){return this._timeline._currentTime},set:function(t){(t<0||t!=t)&&(t=0);var e=this._timeline._currentPlayTimes-(this._timeline._isCompleted?1:0);if(t=t%this._duration+e*this._duration,this._time!=t){this._time=t,this._timeline.setCurrentTime(this._time),this._zOrderTimeline&&(this._zOrderTimeline._isCompleted=!1);for(var i=0,n=this._boneTimelines.length;i0){var s=this._keyFrameCount>1?Math.floor(this._currentTime*this._frameRate):0,o=this._timeline.frames[s];if(this._currentFrame!=o)if(this._keyFrameCount>1){var a=this._currentFrame;if(this._currentFrame=o,!a){var c=Math.floor(i*this._frameRate);a=this._timeline.frames[c],this._isReverse||(i<=a.position||n!=this._currentPlayTimes)&&(a=a.prev)}if(this._isReverse)for(;a!=o;)this._onCrossFrame(a),a=a.prev;else for(;a!=o;)a=a.next,this._onCrossFrame(a)}else this._currentFrame=o,this._onCrossFrame(this._currentFrame)}if(n!=this._currentPlayTimes){if(r.hasEvent(t.EventObject.LOOP_COMPLETE)){(h=t.BaseObject.borrowObject(t.EventObject)).animationState=this._animationState,this._armature._bufferEvent(h,t.EventObject.LOOP_COMPLETE)}if(this._isCompleted&&r.hasEvent(t.EventObject.COMPLETE)){var h;(h=t.BaseObject.borrowObject(t.EventObject)).animationState=this._animationState,this._armature._bufferEvent(h,t.EventObject.COMPLETE)}this._currentFrame=null}}},i.prototype.setCurrentTime=function(t){this._setCurrentTime(t),this._currentFrame=null},i})(t.TimelineState);t.AnimationTimelineState=e;var i=(function(t){function e(){t.call(this)}return n(e,t),e.toString=function(){return"[class dragonBones.ZOrderTimelineState]"},e.prototype._onArriveAtFrame=function(e){t.prototype._onArriveAtFrame.call(this,e),this._armature._sortZOrder(this._currentFrame.zOrder)},e})(t.TimelineState);t.ZOrderTimelineState=i;var r=(function(e){function i(){e.call(this),this._transform=new t.Transform,this._currentTransform=new t.Transform,this._durationTransform=new t.Transform}return n(i,e),i.toString=function(){return"[class dragonBones.BoneTimelineState]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.bone=null,this._tweenTransform=0,this._tweenRotate=0,this._tweenScale=0,this._boneTransform=null,this._originalTransform=null,this._transform.identity(),this._currentTransform.identity(),this._durationTransform.identity()},i.prototype._onArriveAtFrame=function(i){if(e.prototype._onArriveAtFrame.call(this,i),this._currentTransform.copyFrom(this._currentFrame.transform),this._tweenTransform=1,this._tweenRotate=1,this._tweenScale=1,this._keyFrameCount>1&&(this._tweenEasing!=t.DragonBones.NO_TWEEN||this._curve)){var n=this._currentFrame.next.transform;this._durationTransform.x=n.x-this._currentTransform.x,this._durationTransform.y=n.y-this._currentTransform.y,0==this._durationTransform.x&&0==this._durationTransform.y||(this._tweenTransform=2);var r=this._currentFrame.tweenRotate;if(r==r){if(r)if(r>0?n.skewY>=this._currentTransform.skewY:n.skewY<=this._currentTransform.skewY){var s=r>0?r-1:r+1;this._durationTransform.skewX=n.skewX-this._currentTransform.skewX+t.DragonBones.PI_D*s,this._durationTransform.skewY=n.skewY-this._currentTransform.skewY+t.DragonBones.PI_D*s}else this._durationTransform.skewX=n.skewX-this._currentTransform.skewX+t.DragonBones.PI_D*r,this._durationTransform.skewY=n.skewY-this._currentTransform.skewY+t.DragonBones.PI_D*r;else this._durationTransform.skewX=t.Transform.normalizeRadian(n.skewX-this._currentTransform.skewX),this._durationTransform.skewY=t.Transform.normalizeRadian(n.skewY-this._currentTransform.skewY);0==this._durationTransform.skewX&&0==this._durationTransform.skewY||(this._tweenRotate=2)}else this._durationTransform.skewX=0,this._durationTransform.skewY=0;this._currentFrame.tweenScale?(this._durationTransform.scaleX=n.scaleX-this._currentTransform.scaleX,this._durationTransform.scaleY=n.scaleY-this._currentTransform.scaleY,0==this._durationTransform.scaleX&&0==this._durationTransform.scaleY||(this._tweenScale=2)):(this._durationTransform.scaleX=0,this._durationTransform.scaleY=0)}else this._durationTransform.x=0,this._durationTransform.y=0,this._durationTransform.skewX=0,this._durationTransform.skewY=0,this._durationTransform.scaleX=0,this._durationTransform.scaleY=0},i.prototype._onUpdateFrame=function(t){if(this._tweenTransform||this._tweenRotate||this._tweenScale){e.prototype._onUpdateFrame.call(this,t);var i=0;this._tweenTransform&&(1==this._tweenTransform?(this._tweenTransform=0,i=0):i=this._tweenProgress,this._animationState.additiveBlending?(this._transform.x=this._currentTransform.x+this._durationTransform.x*i,this._transform.y=this._currentTransform.y+this._durationTransform.y*i):(this._transform.x=this._originalTransform.x+this._currentTransform.x+this._durationTransform.x*i,this._transform.y=this._originalTransform.y+this._currentTransform.y+this._durationTransform.y*i)),this._tweenRotate&&(1==this._tweenRotate?(this._tweenRotate=0,i=0):i=this._tweenProgress,this._animationState.additiveBlending?(this._transform.skewX=this._currentTransform.skewX+this._durationTransform.skewX*i,this._transform.skewY=this._currentTransform.skewY+this._durationTransform.skewY*i):(this._transform.skewX=this._originalTransform.skewX+this._currentTransform.skewX+this._durationTransform.skewX*i,this._transform.skewY=this._originalTransform.skewY+this._currentTransform.skewY+this._durationTransform.skewY*i)),this._tweenScale&&(1==this._tweenScale?(this._tweenScale=0,i=0):i=this._tweenProgress,this._animationState.additiveBlending?(this._transform.scaleX=this._currentTransform.scaleX+this._durationTransform.scaleX*i,this._transform.scaleY=this._currentTransform.scaleY+this._durationTransform.scaleY*i):(this._transform.scaleX=this._originalTransform.scaleX*(this._currentTransform.scaleX+this._durationTransform.scaleX*i),this._transform.scaleY=this._originalTransform.scaleY*(this._currentTransform.scaleY+this._durationTransform.scaleY*i))),this.bone.invalidUpdate()}},i.prototype.fadeIn=function(t,i,n,r){e.prototype.fadeIn.call(this,t,i,n,r),this._originalTransform=this._timeline.originalTransform,this._boneTransform=this.bone._animationPose},i.prototype.fadeOut=function(){this._transform.skewX=t.Transform.normalizeRadian(this._transform.skewX),this._transform.skewY=t.Transform.normalizeRadian(this._transform.skewY)},i.prototype.update=function(t){e.prototype.update.call(this,t);var i=this._animationState._weightResult;i>0&&(0==this.bone._blendIndex?(this._boneTransform.x=this._transform.x*i,this._boneTransform.y=this._transform.y*i,this._boneTransform.skewX=this._transform.skewX*i,this._boneTransform.skewY=this._transform.skewY*i,this._boneTransform.scaleX=(this._transform.scaleX-1)*i+1,this._boneTransform.scaleY=(this._transform.scaleY-1)*i+1):(this._boneTransform.x+=this._transform.x*i,this._boneTransform.y+=this._transform.y*i,this._boneTransform.skewX+=this._transform.skewX*i,this._boneTransform.skewY+=this._transform.skewY*i,this._boneTransform.scaleX+=(this._transform.scaleX-1)*i,this._boneTransform.scaleY+=(this._transform.scaleY-1)*i),this.bone._blendIndex++,0!=this._animationState._fadeState&&this.bone.invalidUpdate())},i})(t.TweenTimelineState);t.BoneTimelineState=r;var s=(function(e){function i(){e.call(this),this._color=new t.ColorTransform,this._durationColor=new t.ColorTransform}return n(i,e),i.toString=function(){return"[class dragonBones.SlotTimelineState]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.slot=null,this._colorDirty=!1,this._tweenColor=0,this._slotColor=null,this._color.identity(),this._durationColor.identity()},i.prototype._onArriveAtFrame=function(i){if(e.prototype._onArriveAtFrame.call(this,i),this._animationState._isDisabled(this.slot))return this._tweenEasing=t.DragonBones.NO_TWEEN,this._curve=null,void(this._tweenColor=0);this._animationState._fadeState>=0&&(this.slot._setDisplayIndex(this._currentFrame.displayIndex),this.slot._updateMeshData(!0)),this._tweenColor=0;var n=this._currentFrame.color;if(this._keyFrameCount>1&&(this._tweenEasing!=t.DragonBones.NO_TWEEN||this._curve)){var r=this._currentFrame.next,s=r.color;n!=s&&r.displayIndex>=0&&(this._durationColor.alphaMultiplier=s.alphaMultiplier-n.alphaMultiplier,this._durationColor.redMultiplier=s.redMultiplier-n.redMultiplier,this._durationColor.greenMultiplier=s.greenMultiplier-n.greenMultiplier,this._durationColor.blueMultiplier=s.blueMultiplier-n.blueMultiplier,this._durationColor.alphaOffset=s.alphaOffset-n.alphaOffset,this._durationColor.redOffset=s.redOffset-n.redOffset,this._durationColor.greenOffset=s.greenOffset-n.greenOffset,this._durationColor.blueOffset=s.blueOffset-n.blueOffset,0==this._durationColor.alphaMultiplier&&0==this._durationColor.redMultiplier&&0==this._durationColor.greenMultiplier&&0==this._durationColor.blueMultiplier&&0==this._durationColor.alphaOffset&&0==this._durationColor.redOffset&&0==this._durationColor.greenOffset&&0==this._durationColor.blueOffset||(this._tweenColor=2))}0==this._tweenColor&&(this._slotColor.alphaMultiplier==n.alphaMultiplier&&this._slotColor.redMultiplier==n.redMultiplier&&this._slotColor.greenMultiplier==n.greenMultiplier&&this._slotColor.blueMultiplier==n.blueMultiplier&&this._slotColor.alphaOffset==n.alphaOffset&&this._slotColor.redOffset==n.redOffset&&this._slotColor.greenOffset==n.greenOffset&&this._slotColor.blueOffset==n.blueOffset||(this._tweenColor=1))},i.prototype._onUpdateFrame=function(t){e.prototype._onUpdateFrame.call(this,t);var i=0;if(this._tweenColor){1==this._tweenColor?(this._tweenColor=0,i=0):i=this._tweenProgress;var n=this._currentFrame.color;this._color.alphaMultiplier=n.alphaMultiplier+this._durationColor.alphaMultiplier*i,this._color.redMultiplier=n.redMultiplier+this._durationColor.redMultiplier*i,this._color.greenMultiplier=n.greenMultiplier+this._durationColor.greenMultiplier*i,this._color.blueMultiplier=n.blueMultiplier+this._durationColor.blueMultiplier*i,this._color.alphaOffset=n.alphaOffset+this._durationColor.alphaOffset*i,this._color.redOffset=n.redOffset+this._durationColor.redOffset*i,this._color.greenOffset=n.greenOffset+this._durationColor.greenOffset*i,this._color.blueOffset=n.blueOffset+this._durationColor.blueOffset*i,this._colorDirty=!0}},i.prototype.fadeIn=function(t,i,n,r){e.prototype.fadeIn.call(this,t,i,n,r),this._slotColor=this.slot._colorTransform},i.prototype.fadeOut=function(){this._tweenColor=0},i.prototype.update=function(t){if(e.prototype.update.call(this,t),0!=this._tweenColor||this._colorDirty){if(this._animationState._weightResult>0)if(0!=this._animationState._fadeState){var i=Math.pow(this._animationState._fadeProgress,4);this._slotColor.alphaMultiplier+=(this._color.alphaMultiplier-this._slotColor.alphaMultiplier)*i,this._slotColor.redMultiplier+=(this._color.redMultiplier-this._slotColor.redMultiplier)*i,this._slotColor.greenMultiplier+=(this._color.greenMultiplier-this._slotColor.greenMultiplier)*i,this._slotColor.blueMultiplier+=(this._color.blueMultiplier-this._slotColor.blueMultiplier)*i,this._slotColor.alphaOffset+=(this._color.alphaOffset-this._slotColor.alphaOffset)*i,this._slotColor.redOffset+=(this._color.redOffset-this._slotColor.redOffset)*i,this._slotColor.greenOffset+=(this._color.greenOffset-this._slotColor.greenOffset)*i,this._slotColor.blueOffset+=(this._color.blueOffset-this._slotColor.blueOffset)*i,this.slot._colorDirty=!0}else this._colorDirty&&(this._colorDirty=!1,this._slotColor.alphaMultiplier=this._color.alphaMultiplier,this._slotColor.redMultiplier=this._color.redMultiplier,this._slotColor.greenMultiplier=this._color.greenMultiplier,this._slotColor.blueMultiplier=this._color.blueMultiplier,this._slotColor.alphaOffset=this._color.alphaOffset,this._slotColor.redOffset=this._color.redOffset,this._slotColor.greenOffset=this._color.greenOffset,this._slotColor.blueOffset=this._color.blueOffset,this.slot._colorDirty=!0)}},i})(t.TweenTimelineState);t.SlotTimelineState=s;var o=(function(e){function i(){e.call(this),this._ffdVertices=[]}return n(i,e),i.toString=function(){return"[class dragonBones.FFDTimelineState]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.slot=null,this._tweenFFD=0,this._slotFFDVertices=null,this._durationFFDFrame&&(this._durationFFDFrame.returnToPool(),this._durationFFDFrame=null),this._ffdVertices.length=0},i.prototype._onArriveAtFrame=function(i){if(e.prototype._onArriveAtFrame.call(this,i),this._tweenFFD=0,(this._tweenEasing!=t.DragonBones.NO_TWEEN||this._curve)&&(this._tweenFFD=this._updateExtensionKeyFrame(this._currentFrame,this._currentFrame.next,this._durationFFDFrame)),0==this._tweenFFD)for(var n=this._currentFrame.tweens,r=0,s=n.length;r0){if(0==this.slot._blendIndex)for(var n=0,r=this._ffdVertices.length;n0&&(this._animatebles[i-n]=s,this._animatebles[i]=null),s.advanceTime(e)):n++}if(n>0){for(r=this._animatebles.length;i=0},e.prototype.add=function(e){e&&this._animatebles.indexOf(e)<0&&(this._animatebles.push(e),t.DragonBones.debug&&e instanceof t.Armature&&t.DragonBones.addArmature(e))},e.prototype.remove=function(e){var i=this._animatebles.indexOf(e);i>=0&&(this._animatebles[i]=null,t.DragonBones.debug&&e instanceof t.Armature&&t.DragonBones.removeArmature(e))},e.prototype.clear=function(){for(var t=0,e=this._animatebles.length;te._zOrder?1:-1},i.prototype._onClear=function(){for(var t=0,e=this._bones.length;t=t&&(i=0),this._bones.indexOf(r)>=0||(r.parent&&this._bones.indexOf(r.parent)<0||r.ik&&this._bones.indexOf(r.ik)<0||(r.ik&&r.ikChain>0&&r.ikChainIndex==r.ikChain?this._bones.splice(this._bones.indexOf(r.parent)+1,0,r):this._bones.push(r),n++))}}},i.prototype._sortSlots=function(){this._slots.sort(i._onSortSlots)},i.prototype._doAction=function(t){switch(t.type){case 0:this._animation.play(t.data[0],t.data[1]);break;case 1:this._animation.stop(t.data[0]);break;case 2:this._animation.gotoAndPlayByTime(t.data[0],t.data[1],t.data[2]);break;case 3:this._animation.gotoAndStopByTime(t.data[0],t.data[1]);break;case 4:this._animation.fadeIn(t.data[0],t.data[1],t.data[2])}},i.prototype._addBoneToBoneList=function(t){this._bones.indexOf(t)<0&&(this._bonesDirty=!0,this._bones.push(t))},i.prototype._removeBoneFromBoneList=function(t){var e=this._bones.indexOf(t);e>=0&&this._bones.splice(e,1)},i.prototype._addSlotToSlotList=function(t){this._slots.indexOf(t)<0&&(this._slotsDirty=!0,this._slots.push(t))},i.prototype._removeSlotFromSlotList=function(t){var e=this._slots.indexOf(t);e>=0&&this._slots.splice(e,1)},i.prototype._sortZOrder=function(t){for(var e=this._armatureData.sortedSlots,i=t.length<1,n=0,r=e.length;n0){for(n=0,r=this._events.length;n0){for(n=0,r=this._actions.length;n0){if(!s&&!o){g=C;break}if(s){(T=c?s.y-e:s.x-t)<0&&(T=-T),(!g||Tl)&&(l=T,d=o.x,f=o.y,y=C,a&&(m=a.y))}}}return g&&s&&(s.x=u,s.y=_,a&&(a.x=p)),y&&o&&(o.x=d,o.y=f,a&&(a.y=m)),g},i.prototype.invalidUpdate=function(t,e){if(void 0===t&&(t=null),void 0===e&&(e=!1),t){var i=this.getBone(t);if(i&&(i.invalidUpdate(),e))for(var n=0,r=this._slots.length;n=0){var i=this._cacheFrames[e];this.globalTransformMatrix==i?this._transformDirty=0:i?(this._transformDirty=2,this.globalTransformMatrix=i):2==this._transformDirty||this._parent&&0!=this._parent._transformDirty||this._ik&&this.ikWeight>0&&0!=this._ik._transformDirty?(this._transformDirty=2,this.globalTransformMatrix=this._globalTransformMatrix):this.globalTransformMatrix!=this._globalTransformMatrix?(this._transformDirty=0,this._cacheFrames[e]=this.globalTransformMatrix):(this._transformDirty=2,this.globalTransformMatrix=this._globalTransformMatrix)}else(2==this._transformDirty||this._parent&&0!=this._parent._transformDirty||this._ik&&this.ikWeight>0&&0!=this._ik._transformDirty)&&(this._transformDirty=2,this.globalTransformMatrix=this._globalTransformMatrix);0!=this._transformDirty&&(2==this._transformDirty?(this._transformDirty=1,this.globalTransformMatrix==this._globalTransformMatrix&&(this.global.x=this.origin.x+this.offset.x+this._animationPose.x,this.global.y=this.origin.y+this.offset.y+this._animationPose.y,this.global.skewX=this.origin.skewX+this.offset.skewX+this._animationPose.skewX,this.global.skewY=this.origin.skewY+this.offset.skewY+this._animationPose.skewY,this.global.scaleX=this.origin.scaleX*this.offset.scaleX*this._animationPose.scaleX,this.global.scaleY=this.origin.scaleY*this.offset.scaleY*this._animationPose.scaleY,this._updateGlobalTransformMatrix(),this._ik&&this._ikChainIndex==this._ikChain&&this.ikWeight>0&&(this.inheritTranslation&&this._ikChain>0&&this._parent?this._computeIKB():this._computeIKA()),e>=0&&!this._cacheFrames[e]&&(this.globalTransformMatrix=t.BoneTimelineData.cacheFrame(this._cacheFrames,e,this._globalTransformMatrix)))):this._transformDirty=0)},i.prototype.invalidUpdate=function(){this._transformDirty=2},i.prototype.contains=function(t){if(t){if(t==this)return!1;for(var e=t;e!=this&&e;)e=e.parent;return e==this}return!1},i.prototype.getBones=function(){this._bones.length=0;for(var t=this._armature.getBones(),e=0,i=t.length;e=0&&this._displayIndex=0&&this._displayIndex0?s.actions:this._childArmature.armatureData.actions;if(o.length>0)for(var a=0,c=o.length;a=0){i=this._displayDataSet&&this._displayIndex=0&&this._cacheFrames){var i=this._cacheFrames[e];this.globalTransformMatrix==i?this._transformDirty=!1:i?(this._transformDirty=!0,this.globalTransformMatrix=i):this._transformDirty||0!=this._parent._transformDirty?(this._transformDirty=!0,this.globalTransformMatrix=this._globalTransformMatrix):this.globalTransformMatrix!=this._globalTransformMatrix?(this._transformDirty=!1,this._cacheFrames[e]=this.globalTransformMatrix):(this._transformDirty=!0,this.globalTransformMatrix=this._globalTransformMatrix)}else(this._transformDirty||0!=this._parent._transformDirty)&&(this._transformDirty=!0,this.globalTransformMatrix=this._globalTransformMatrix);this._transformDirty&&(this._transformDirty=!1,this.globalTransformMatrix==this._globalTransformMatrix&&(this._updateGlobalTransformMatrix(),e>=0&&this._cacheFrames&&!this._cacheFrames[e]&&(this.globalTransformMatrix=t.SlotTimelineData.cacheFrame(this._cacheFrames,e,this._globalTransformMatrix))),this._updateTransform())}},i.prototype._setDisplayList=function(e){if(e&&e.length>0){this._displayList.length!=e.length&&(this._displayList.length=e.length);for(var i=0,n=e.length;i0&&(this._displayList.length=0);return this._displayIndex>=0&&this._displayIndex0&&(1==l||2==l?o?(this.globalTransformMatrix.transformPoint(o.x,o.y,o),a&&(a.x=o.x,a.y=o.y)):a&&this.globalTransformMatrix.transformPoint(a.x,a.y,a):(o&&this.globalTransformMatrix.transformPoint(o.x,o.y,o),a&&this.globalTransformMatrix.transformPoint(a.x,a.y,a)),c&&(this.globalTransformMatrix.transformPoint(Math.cos(c.x),Math.sin(c.x),i._helpPoint,!0),c.x=Math.atan2(i._helpPoint.y,i._helpPoint.x),this.globalTransformMatrix.transformPoint(Math.cos(c.y),Math.sin(c.y),i._helpPoint,!0),c.y=Math.atan2(i._helpPoint.y,i._helpPoint.x))),l},i.prototype.invalidUpdate=function(){this._displayDirty=!0},Object.defineProperty(i.prototype,"displayData",{get:function(){return this._displayIndex<0||this._displayIndex>=this._displayDataSet.displays.length?null:this._displayDataSet.displays[this._displayIndex]},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rawDisplay",{get:function(){return this._rawDisplay},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"meshDisplay",{get:function(){return this._meshDisplay},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"displayIndex",{get:function(){return this._displayIndex},set:function(t){this._setDisplayIndex(t)&&this._update(-1)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"displayList",{get:function(){return this._displayList.concat()},set:function(e){var i=this._displayList.concat(),n=[];this._setDisplayList(e)&&this._update(-1);for(var r=0,s=i.length;re.zOrder?1:-1},i.toString=function(){return"[class dragonBones.ArmatureData]"},i.prototype._onClear=function(){for(var t in this.bones)this.bones[t].returnToPool(),delete this.bones[t];for(var t in this.slots)this.slots[t].returnToPool(),delete this.slots[t];for(var t in this.skins)this.skins[t].returnToPool(),delete this.skins[t];for(var t in this.animations)this.animations[t].returnToPool(),delete this.animations[t];t=0;for(var e=this.actions.length;t=t&&(i=0),this._sortedBones.indexOf(r)>=0||(r.parent&&this._sortedBones.indexOf(r.parent)<0||r.ik&&this._sortedBones.indexOf(r.ik)<0||(r.ik&&r.chain>0&&r.chainIndex==r.chain?this._sortedBones.splice(this._sortedBones.indexOf(r.parent)+1,0,r):this._sortedBones.push(r),n++))}}},i.prototype._sortSlots=function(){this._sortedSlots.sort(i._onSortSlots)},i.prototype.cacheFrames=function(t){if(this.cacheFrameRate!=t){this.cacheFrameRate=t;for(var e in this.animations)this.animations[e].cacheFrames(this.cacheFrameRate)}},i.prototype.addBone=function(t,e){if(!t||!t.name||this.bones[t.name])throw new Error;if(e){var i=this.getBone(e);i?t.parent=i:(this._bonesChildren[e]=this._bonesChildren[e]||[]).push(t)}var n=this._bonesChildren[t.name];if(n){for(var r=0,s=n.length;rr&&(o|=2),es&&(o|=8),o},e.segmentIntersectsRectangle=function(t,i,n,r,s,o,a,c,h,l,u){void 0===h&&(h=null),void 0===l&&(l=null),void 0===u&&(u=null);var _=t>s&&to&&is&&no&&r=0){var T=Math.sqrt(x),b=y-T,A=y+T,S=b<0?-1:b<=p?0:1,w=A<0?-1:A<=p?0:1,E=S*w;if(E<0)return-1;0==E&&(-1==S?(C=2,i=t+A*m,n=(e+A*g)/u,c&&(c.x=i,c.y=n),h&&(h.x=i,h.y=n),l&&(l.x=Math.atan2(n/v*_,i/v),l.y=l.x+Math.PI)):1==w?(C=1,t+=b*m,e=(e+b*g)/u,c&&(c.x=t,c.y=e),h&&(h.x=t,h.y=e),l&&(l.x=Math.atan2(e/v*_,t/v),l.y=l.x+Math.PI)):(C=3,c&&(c.x=t+b*m,c.y=(e+b*g)/u,l&&(l.x=Math.atan2(c.y/v*_,c.x/v))),h&&(h.x=t+A*m,h.y=(e+A*g)/u,l&&(l.y=Math.atan2(h.y/v*_,h.x/v)))))}return C},e.segmentIntersectsPolygon=function(t,e,i,n,r,s,o,a){void 0===s&&(s=null),void 0===o&&(o=null),void 0===a&&(a=null),t==i&&(t=i+.01),e==n&&(e=n+.01);for(var c=r.length,h=t-i,l=e-n,u=t*n-e*i,_=0,d=r[c-2],f=r[c-1],p=0,m=0,g=0,y=0,v=0,x=0,C=0;C=d&&I<=T||I>=T&&I<=d)&&(0==h||I>=t&&I<=i||I>=i&&I<=t)){var R=(u*S-l*w)/E;if((R>=f&&R<=b||R>=b&&R<=f)&&(0==l||R>=e&&R<=n||R>=n&&R<=e)){if(!o){g=I,y=R,v=I,x=R,_++,a&&(a.x=Math.atan2(b-f,T-d)-.5*Math.PI,a.y=a.x);break}var P=I-t;P<0&&(P=-P),0==_?(p=P,m=P,g=I,y=R,v=I,x=R,a&&(a.x=Math.atan2(b-f,T-d)-.5*Math.PI,a.y=a.x)):(Pm&&(m=P,v=I,x=R,a&&(a.y=Math.atan2(b-f,T-d)-.5*Math.PI))),_++}}d=T,f=b}return 1==_?(s&&(s.x=g,s.y=y),o&&(o.x=g,o.y=y),a&&(a.y=a.x+Math.PI)):_>1&&(_++,s&&(s.x=g,s.y=y),o&&(o.x=v,o.y=x)),_},e.prototype._onClear=function(){this.type=-1,this.x=0,this.y=0,this.width=0,this.height=0,this.vertices.length=0},e.prototype.containsPoint=function(t,e){var i=!1;if(2==this.type){if(t>=this.x&&t<=this.width&&e>=this.y&&e<=this.height)for(var n=0,r=this.vertices.length,s=r-2;n=e||o=e){var c=this.vertices[s],h=this.vertices[n];(e-a)*(c-h)/(o-a)+h=-l&&t<=l){var u=.5*this.height;e>=-u&&e<=u&&(1==this.type?(e*=l/u,i=Math.sqrt(t*t+e*e)<=l):i=!0)}}return i},e.prototype.intersectsSegment=function(t,i,n,r,s,o,a){void 0===s&&(s=null),void 0===o&&(o=null),void 0===a&&(a=null);var c=0;switch(this.type){case 0:var h=.5*this.width,l=.5*this.height;c=e.segmentIntersectsRectangle(t,i,n,r,-h,-l,h,l,s,o,a);break;case 1:c=e.segmentIntersectsEllipse(t,i,n,r,0,0,.5*this.width,.5*this.height,s,o,a);break;case 2:0!=e.segmentIntersectsRectangle(t,i,n,r,this.x,this.y,this.width,this.height,null,null)&&(c=e.segmentIntersectsPolygon(t,i,n,r,this.vertices,s,o,a))}return c},e})(t.BaseObject);t.BoundingBoxData=h})(r||(r={}));(function(t){var e=(function(t){function e(){t.call(this),this.armatures={},this._armatureNames=[]}return n(e,t),e.toString=function(){return"[class dragonBones.DragonBonesData]"},e.prototype._onClear=function(){for(var t in this.armatures)this.armatures[t].returnToPool(),delete this.armatures[t];this.autoSearch=!1,this.frameRate=0,this.name=null,this._armatureNames.length=0},e.prototype.getArmature=function(t){return this.armatures[t]},e.prototype.addArmature=function(t){if(!t||!t.name||this.armatures[t.name])throw new Error;this.armatures[t.name]=t,this._armatureNames.push(t.name),t.parent=this},Object.defineProperty(e.prototype,"armatureNames",{get:function(){return this._armatureNames},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.returnToPool()},e})(t.BaseObject);t.DragonBonesData=e})(r||(r={}));(function(t){var e=(function(t){function e(){t.call(this),this.data=[]}return n(e,t),e.toString=function(){return"[class dragonBones.ActionData]"},e.prototype._onClear=function(){this.type=-1,this.bone=null,this.slot=null,this.data.length=0},e})(t.BaseObject);t.ActionData=e;var i=(function(t){function e(){t.call(this),this.ints=[],this.floats=[],this.strings=[]}return n(e,t),e.toString=function(){return"[class dragonBones.EventData]"},e.prototype._onClear=function(){this.type=-1,this.name=null,this.ints.length=0,this.floats.length=0,this.strings.length=0,this.bone=null,this.slot=null},e})(t.BaseObject);t.EventData=i;var r=(function(t){function e(){t.call(this)}return n(e,t),e.prototype._onClear=function(){this.position=0,this.duration=0,this.prev=null,this.next=null},e})(t.BaseObject);t.FrameData=r;var s=(function(e){function i(){e.call(this)}return n(i,e),i._getCurvePoint=function(t,e,i,n,r,s,o,a,c,h){var l=1-c,u=l*l,_=c*c,d=l*u,f=3*c*u,p=3*l*_,m=c*_;h.x=d*t+f*i+p*r+m*o,h.y=d*e+f*n+p*s+m*a},i.samplingEasingCurve=function(e,n){for(var r=e.length,s=new t.Point,o=-2,a=0,c=n.length;a=0&&o+6.01;){var C=(x+v)/2;i._getCurvePoint(u,_,d,f,p,m,g,y,C,s),h-s.x>0?v=C:x=C}n[a]=s.y}},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.tweenEasing=0,this.curve=null},i})(r);t.TweenFrameData=s;var o=(function(t){function e(){t.call(this),this.actions=[],this.events=[]}return n(e,t),e.toString=function(){return"[class dragonBones.AnimationFrameData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this);for(var e=0,i=this.actions.length;e=i.frames.length)r.copyFrom(i.frames[0].transform);else{var o=i.frames[s],a=0;o.tweenEasing!=t.DragonBones.NO_TWEEN?(a=(n-o.position)/o.duration,0!=o.tweenEasing&&(a=t.TweenTimelineState._getEasingValue(a,o.tweenEasing))):o.curve&&(a=(n-o.position)/o.duration,a=t.TweenTimelineState._getEasingCurveValue(a,o.curve));var c=o.next;r.x=c.transform.x-o.transform.x,r.y=c.transform.y-o.transform.y,r.skewX=t.Transform.normalizeRadian(c.transform.skewX-o.transform.skewX),r.skewY=t.Transform.normalizeRadian(c.transform.skewY-o.transform.skewY),r.scaleX=c.transform.scaleX-o.transform.scaleX,r.scaleY=c.transform.scaleY-o.transform.scaleY,r.x=o.transform.x+r.x*a,r.y=o.transform.y+r.y*a,r.skewX=o.transform.skewX+r.skewX*a,r.skewY=o.transform.skewY+r.skewY*a,r.scaleX=o.transform.scaleX+r.scaleX*a,r.scaleY=o.transform.scaleY+r.scaleY*a}r.add(i.originalTransform)},e.prototype._globalToLocal=function(t){for(var e=new Array,i=t.sortedBones.concat().reverse(),n=0,r=i.length;n=0||(e.push(_),h?(this._getTimelineFrameMatrix(a,h,_.position,this._helpTransformA),_.transform.add(this._helpTransformB),this._helpTransformA.toMatrix(this._helpMatrix),this._helpMatrix.invert(),this._helpMatrix.transformPoint(_.transform.x,_.transform.y,this._helpPoint),_.transform.x=this._helpPoint.x,_.transform.y=this._helpPoint.y,_.transform.rotation-=this._helpTransformA.rotation):_.transform.add(this._helpTransformB),_.transform.minus(s.transform),0==l?(c.originalTransform.copyFrom(_.transform),_.transform.identity()):_.transform.minus(c.originalTransform))}}}}},e.prototype._mergeFrameToAnimationTimeline=function(e,i,n){var r=Math.floor(e*this._armature.frameRate),s=this._animation.frames;if(0==s.length){var o=t.BaseObject.borrowObject(t.AnimationFrameData);if(o.position=0,this._animation.frameCount>1){s.length=this._animation.frameCount+1;var a=t.BaseObject.borrowObject(t.AnimationFrameData);a.position=this._animation.frameCount/this._armature.frameRate,s[0]=o,s[this._animation.frameCount]=a}}var c=null,h=s[r];if(!h||0!=r&&s[r-1]!=h.prev){(c=t.BaseObject.borrowObject(t.AnimationFrameData)).position=r/this._armature.frameRate,s[r]=c;for(var l=r+1,u=s.length;le?t[e]:i},i.prototype._parseArmature=function(e,n){var r=t.BaseObject.borrowObject(t.ArmatureData);if(r.name=i._getString(e,i.NAME,null),r.frameRate=i._getNumber(e,i.FRAME_RATE,this._data.frameRate)||this._data.frameRate,r.scale=n,i.TYPE in e&&"string"==typeof e[i.TYPE]?r.type=i._getArmatureType(e[i.TYPE]):r.type=i._getNumber(e,i.TYPE,0),this._armature=r,this._rawBones.length=0,i.AABB in e){var s=e[i.AABB];r.aabb.x=i._getNumber(s,i.X,0),r.aabb.y=i._getNumber(s,i.Y,0),r.aabb.width=i._getNumber(s,i.WIDTH,0),r.aabb.height=i._getNumber(s,i.HEIGHT,0)}if(i.BONE in e)for(var o=e[i.BONE],a=0,c=o.length;a0&&e.parent&&!e.parent.ik?(e.parent.ik=e.ik,e.parent.chainIndex=0,e.parent.chain=0,e.chainIndex=1):(e.chain=0,e.chainIndex=0))},i.prototype._parseSlot=function(e,n){var r=t.BaseObject.borrowObject(t.SlotData);return r.name=i._getString(e,i.NAME,null),r.parent=this._armature.getBone(i._getString(e,i.PARENT,null)),r.displayIndex=i._getNumber(e,i.DISPLAY_INDEX,0),r.zOrder=i._getNumber(e,i.Z,n),i.COLOR in e||i.COLOR_TRANSFORM in e?(r.color=t.SlotData.generateColor(),this._parseColorTransform(e[i.COLOR]||e[i.COLOR_TRANSFORM],r.color)):r.color=t.SlotData.DEFAULT_COLOR,i.BLEND_MODE in e&&"string"==typeof e[i.BLEND_MODE]?r.blendMode=i._getBlendMode(e[i.BLEND_MODE]):r.blendMode=i._getNumber(e,i.BLEND_MODE,0),(i.ACTIONS in e||i.DEFAULT_ACTIONS in e)&&this._parseActionData(e,r.actions,null,null),this._isOldData&&(i.COLOR_TRANSFORM in e?(r.color=t.SlotData.generateColor(),this._parseColorTransform(e[i.COLOR_TRANSFORM],r.color)):r.color=t.SlotData.DEFAULT_COLOR),r},i.prototype._parseSkin=function(e){var n=t.BaseObject.borrowObject(t.SkinData);if(n.name=i._getString(e,i.NAME,"__default")||"__default",i.SLOT in e){this._skin=n;for(var r=e[i.SLOT],s=0,o=0,a=r.length;on.width&&(n.width=c),hn.height&&(n.height=h))}}}return n},i.prototype._parseMesh=function(e){var n=t.BaseObject.borrowObject(t.MeshData),r=e[i.VERTICES],s=e[i.UVS],o=e[i.TRIANGLES],a=Math.floor(r.length/2),c=Math.floor(o.length/3),h=new Array(this._armature.sortedBones.length);if(n.skinned=i.WEIGHTS in e&&e[i.WEIGHTS].length>0,n.uvs.length=2*a,n.vertices.length=2*a,n.vertexIndices.length=3*c,n.skinned){if(n.boneIndices.length=a,n.weights.length=a,n.boneVertices.length=a,i.SLOT_POSE in e){var l=e[i.SLOT_POSE];n.slotPose.a=l[0],n.slotPose.b=l[1],n.slotPose.c=l[2],n.slotPose.d=l[3],n.slotPose.tx=l[4]*this._armature.scale,n.slotPose.ty=l[5]*this._armature.scale}if(i.BONE_POSE in e)for(var u=e[i.BONE_POSE],_=0,d=u.length;_0){var a=this._armature.sortedSlots.length,c=new Array(a-o.length/2);s.zOrder.length=a;for(var h=0;h0||h.length>0)&&this._mergeFrameToAnimationTimeline(s.position,c,h),s},i.prototype._parseSlotFrame=function(e,n,r){var s=t.BaseObject.borrowObject(t.SlotFrameData);if(s.displayIndex=i._getNumber(e,i.DISPLAY_INDEX,0),this._parseTweenFrame(e,s,n,r),i.COLOR in e||i.COLOR_TRANSFORM in e?(s.color=t.SlotFrameData.generateColor(),this._parseColorTransform(e[i.COLOR]||e[i.COLOR_TRANSFORM],s.color)):s.color=t.SlotFrameData.DEFAULT_COLOR,this._isOldData)i._getBoolean(e,i.HIDE,!1)&&(s.displayIndex=-1);else if(i.ACTION in e||i.ACTIONS in e){var o=this._timeline.slot,a=new Array;this._parseActionData(e,a,o.parent,o),this._mergeFrameToAnimationTimeline(s.position,a,null)}return s},i.prototype._parseFFDFrame=function(e,n,r){var s=this._timeline.display.mesh,o=t.BaseObject.borrowObject(t.ExtensionFrameData);o.type=i._getNumber(e,i.TYPE,0),this._parseTweenFrame(e,o,n,r);for(var a=e[i.VERTICES],c=i._getNumber(e,i.OFFSET,0),h=0,l=0,u=0,_=s.vertices.length;u<_;u+=2)if(!a||u=a.length?(h=0,l=0):(h=a[u-c]*this._armature.scale,l=a[u+1-c]*this._armature.scale),s.skinned){s.slotPose.transformPoint(h,l,this._helpPoint,!0),h=this._helpPoint.x,l=this._helpPoint.y;for(var d=s.boneIndices[u/2],f=0,p=d.length;f0?(i.TWEEN_EASING in e?n.tweenEasing=i._getNumber(e,i.TWEEN_EASING,t.DragonBones.NO_TWEEN):this._isOldData?n.tweenEasing=this._isAutoTween?this._animationTweenEasing:t.DragonBones.NO_TWEEN:n.tweenEasing=t.DragonBones.NO_TWEEN,this._isOldData&&1==this._animation.scale&&1==this._timeline.scale&&n.duration*this._armature.frameRate<2&&(n.tweenEasing=t.DragonBones.NO_TWEEN),s>0&&i.CURVE in e&&(n.curve=new Array(2*s-1),t.TweenFrameData.samplingEasingCurve(e[i.CURVE],n.curve))):(n.tweenEasing=t.DragonBones.NO_TWEEN,n.curve=null)},i.prototype._parseFrame=function(t,e,i,n){e.position=i/this._armature.frameRate,e.duration=n/this._armature.frameRate},i.prototype._parseTimeline=function(e,n,r){if(n.scale=i._getNumber(e,i.SCALE,1),n.offset=i._getNumber(e,i.OFFSET,0),i.FRAME in e){this._timeline=n;var s=e[i.FRAME];if(1==s.length)n.frames.length=1,n.frames[0]=r.call(this,s[0],0,i._getNumber(s[0],i.DURATION,1));else if(s.length>1){n.frames.length=this._animation.frameCount+1;for(var o=0,a=0,c=null,h=null,l=0,u=0,_=n.frames.length;l<_;++l){if(o+a<=l&&u0?n.scale=r:r=n.scale=i._getNumber(e,i.SCALE,n.scale),r=1/r,i.SUB_TEXTURE in e)for(var s=e[i.SUB_TEXTURE],o=0,a=s.length;o0&&u>0&&(h.frame=t.TextureData.generateRectangle(),h.frame.x=i._getNumber(c,i.FRAME_X,0)*r,h.frame.y=i._getNumber(c,i.FRAME_Y,0)*r,h.frame.width=l*r,h.frame.height=u*r),n.addTexture(h)}},i.getInstance=function(){return i._instance||(i._instance=new i),i._instance},i._instance=null,i})(t.DataParser);t.ObjectDataParser=e})(r||(r={}));(function(t){var e=(function(t){function e(){t.call(this),this.textures={}}return n(e,t),e.prototype._onClear=function(){for(var t in this.textures)this.textures[t].returnToPool(),delete this.textures[t];this.autoSearch=!1,this.scale=1,this.name=null,this.imagePath=null},e.prototype.addTexture=function(t){if(!t||!t.name||this.textures[t.name])throw new Error;this.textures[t.name]=t,t.parent=this},e.prototype.getTexture=function(t){return this.textures[t]},e})(t.BaseObject);t.TextureAtlasData=e;var i=(function(e){function i(){e.call(this),this.region=new t.Rectangle}return n(i,e),i.generateRectangle=function(){return new t.Rectangle},i.prototype._onClear=function(){this.rotated=!1,this.name=null,this.frame=null,this.parent=null,this.region.clear()},i})(t.BaseObject);t.TextureData=i})(r||(r={}));var r;(function(t){var e=(function(){function e(i){void 0===i&&(i=null),this.autoSearch=!1,this._dataParser=null,this._dragonBonesDataMap={},this._textureAtlasDataMap={},this._dataParser=i,this._dataParser||(e._defaultParser||(e._defaultParser=new t.ObjectDataParser),this._dataParser=e._defaultParser)}return e.prototype._getTextureData=function(t,e){var i=this._textureAtlasDataMap[t];if(i)for(var n=0,r=i.length;n=0){var r=i.displayList;if(r.length<=n&&(r.length=n+1),i._replacedDisplayDataSet.length<=n&&(i._replacedDisplayDataSet.length=n+1),i._replacedDisplayDataSet[n]=e,1==e.type){var s=this.buildArmature(e.path,t.dataName,null,t.textureAtlasName);r[n]=s}else e.texture&&!t.textureAtlasName||(e.texture=this._getTextureData(t.textureAtlasName||t.dataName,e.path)),e.mesh||nt.length&&(cc.renderer._batchRendering(),p=!0),p&&(i=0);var m=null;if(r instanceof n.RegionAttachment)m=this._uploadRegionAttachmentData(r,s,u,t,e,i);else{if(!(r instanceof n.MeshAttachment))continue;this._uploadMeshAttachmentData(r,s,u,t,e,i)}this._node._debugSlots&&(_[o]=m),r instanceof n.RegionAttachment?cc.renderer._increaseBatchingSize(d,cc.renderer.VertexType.TRIANGLE):cc.renderer._increaseBatchingSize(d,cc.renderer.VertexType.CUSTOM,r.triangles),i+=6*d}}if(c._debugBones||c._debugSlots){cc.renderer._batchRendering();var g=this._worldTransform,y=this._matrix.mat;y[0]=g.a,y[4]=g.c,y[12]=g.tx,y[1]=g.b,y[5]=g.d,y[13]=g.ty,cc.math.glMatrixMode(cc.math.KM_GL_MODELVIEW),cc.current_stack.stack.push(cc.current_stack.top),cc.current_stack.top=this._matrix;var v=cc._drawingUtil;if(c._debugSlots&&_&&_.length>0)for(v.setDrawColor(0,0,255,255),v.setLineWidth(1),o=0,a=l.slots.length;o":0});sp.Skeleton=cc.Class({name:"sp.Skeleton",extends:cc._RendererUnderSG,editor:!1,properties:{_startListener:{default:null,serializable:!1},_endListener:{default:null,serializable:!1},_completeListener:{default:null,serializable:!1},_eventListener:{default:null,serializable:!1},_disposeListener:{default:null,serializable:!1},_interruptListener:{default:null,serializable:!1},_paused:!1,paused:{get:function(){return this._paused},set:function(t){this._paused=t,this._sgNode&&(t?this._sgNode.pause():this._sgNode.resume())},visible:!1},skeletonData:{default:null,type:sp.SkeletonData,notify:function(){this.defaultSkin="",this.defaultAnimation="",this._refresh()},tooltip:!1},defaultSkin:{default:"",visible:!1},defaultAnimation:{default:"",visible:!1},animation:{get:function(){var t=this.getCurrent(0);return t&&t.animation.name||""},set:function(t){this.defaultAnimation=t,t?this.setAnimation(0,t,this.loop):(this.clearTrack(0),this.setToSetupPose())},visible:!1},_defaultSkinIndex:{get:function(){if(this.skeletonData&&this.defaultSkin){var t=this.skeletonData.getSkinsEnum();if(t){var e=t[this.defaultSkin];if(void 0!==e)return e}}return 0},set:function(t){var e;if(this.skeletonData&&(e=this.skeletonData.getSkinsEnum()),!e)return cc.errorID("",this.name);var i=e[t];void 0!==i?this.defaultSkin=i:cc.errorID(7501,this.name)},type:n,visible:!0,displayName:"Default Skin",tooltip:!1},_animationIndex:{get:function(){var t=this.animation;if(this.skeletonData&&t){var e=this.skeletonData.getAnimsEnum();if(e){var i=e[t];if(void 0!==i)return i}}return 0},set:function(t){if(0!==t){var e;if(this.skeletonData&&(e=this.skeletonData.getAnimsEnum()),!e)return cc.errorID(7502,this.name);var i=e[t];void 0!==i?this.animation=i:cc.errorID(7503,this.name)}else this.animation=""},type:r,visible:!0,displayName:"Animation",tooltip:!1},loop:{default:!0,tooltip:!1},_premultipliedAlpha:!0,premultipliedAlpha:{get:function(){return this._premultipliedAlpha},set:function(t){this._premultipliedAlpha=t,this._sgNode&&this._sgNode.setPremultipliedAlpha(t)},tooltip:!1},timeScale:{default:1,notify:function(){this._sgNode&&this._sgNode.setTimeScale(this.timeScale)},tooltip:!1},debugSlots:{default:!1,notify:function(){this._sgNode&&this._sgNode.setDebugSlotsEnabled(this.debugSlots)},editorOnly:!0,tooltip:!1},debugBones:{default:!1,notify:function(){this._sgNode&&this._sgNode.setDebugBonesEnabled(this.debugBones)},editorOnly:!0,tooltip:!1}},__preload:function(){this.node.setContentSize(0,0),this._refresh()},_createSgNode:function(){if(this.skeletonData){var t=this.skeletonData.getRuntimeData();if(t)try{return new sp._SGSkeletonAnimation(t,null,this.skeletonData.scale)}catch(t){cc._throw(t)}}return null},_initSgNode:function(){var t=this._sgNode;t.setTimeScale(this.timeScale);var e=this;if(t.onEnter=function(){_ccsg.Node.prototype.onEnter.call(this),e._paused&&this.pause()},this._startListener&&this.setStartListener(this._startListener),this._endListener&&this.setEndListener(this._endListener),this._completeListener&&this.setCompleteListener(this._completeListener),this._eventListener&&this.setEventListener(this._eventListener),this._interruptListener&&this.setInterruptListener(this._interruptListener),this._disposeListener&&this.setDisposeListener(this._disposeListener),this.defaultSkin)try{t.setSkin(this.defaultSkin)}catch(t){cc._throw(t)}t.setPremultipliedAlpha(this._premultipliedAlpha),this.animation=this.defaultAnimation},_getLocalBounds:!1,updateWorldTransform:function(){this._sgNode&&this._sgNode.updateWorldTransform()},setToSetupPose:function(){this._sgNode&&this._sgNode.setToSetupPose()},setBonesToSetupPose:function(){this._sgNode&&this._sgNode.setBonesToSetupPose()},setSlotsToSetupPose:function(){this._sgNode&&this._sgNode.setSlotsToSetupPose()},findBone:function(t){return this._sgNode?this._sgNode.findBone(t):null},findSlot:function(t){return this._sgNode?this._sgNode.findSlot(t):null},setSkin:function(t){return this._sgNode?this._sgNode.setSkin(t):null},getAttachment:function(t,e){return this._sgNode?this._sgNode.getAttachment(t,e):null},setAttachment:function(t,e){this._sgNode&&this._sgNode.setAttachment(t,e)},setSkeletonData:function(t,e){this._sgNode&&this._sgNode.setSkeletonData(t,e)},setAnimationStateData:function(t){if(this._sgNode)return this._sgNode.setAnimationStateData(t)},setMix:function(t,e,i){this._sgNode&&this._sgNode.setMix(t,e,i)},setAnimationListener:function(t,e){this._sgNode&&this._sgNode.setAnimationListener(t,e)},setAnimation:function(t,e,i){if(this._sgNode){return this._sgNode.setAnimation(t,e,i)}return null},_sample:function(){this._sgNode&&this._sgNode.update(0)},addAnimation:function(t,e,i,n){return this._sgNode?this._sgNode.addAnimation(t,e,i,n||0):null},findAnimation:function(t){return this._sgNode?this._sgNode.findAnimation(t):null},getCurrent:function(t){return this._sgNode?this._sgNode.getCurrent(t):null},clearTracks:function(){this._sgNode&&this._sgNode.clearTracks()},clearTrack:function(t){this._sgNode&&this._sgNode.clearTrack(t)},_updateAnimEnum:!1,_updateSkinEnum:!1,setStartListener:function(t){this._startListener=t,this._sgNode&&this._sgNode.setStartListener(t)},setInterruptListener:function(t){this._interruptListener=t,this._sgNode&&this._sgNode.setInterruptListener(t)},setEndListener:function(t){this._endListener=t,this._sgNode&&this._sgNode.setEndListener(t)},setDisposeListener:function(t){this._disposeListener=t,this._sgNode&&this._sgNode.setDisposeListener(t)},setCompleteListener:function(t){this._completeListener=t,this._sgNode&&this._sgNode.setCompleteListener(t)},setEventListener:function(t){this._eventListener=t,this._sgNode&&this._sgNode.setEventListener(t)},setTrackStartListener:function(t,e){this._sgNode&&this._sgNode.setTrackStartListener(t,e)},setTrackInterruptListener:function(t,e){this._sgNode&&this._sgNode.setTrackInterruptListener(t,e)},setTrackEndListener:function(t,e){this._sgNode&&this._sgNode.setTrackEndListener(t,e)},setTrackDisposeListener:function(t,e){this._sgNode&&this._sgNode.setTrackDisposeListener(t,e)},setTrackCompleteListener:function(t,e){this._sgNode&&this._sgNode.setTrackCompleteListener(t,e)},setTrackEventListener:function(t,e){this._sgNode&&this._sgNode.setTrackEventListener(t,e)},getState:function(){if(this._sgNode)return this._sgNode.getState()},_refresh:function(){this._sgNode&&(this.node._sizeProvider===this._sgNode&&(this.node._sizeProvider=null),this._removeSgNode(),this._sgNode=null);var t=this._sgNode=this._createSgNode();t&&(this.enabledInHierarchy||t.setVisible(!1),t.setContentSize(0,0),this._initSgNode(),this._appendSgNode(t),this._registSizeProvider())}})}),{}],307:[(function(t,e,i){var n=cc.Class({ctor:function(){this.asset=arguments[0]},getTexture:function(t){for(var e=this.asset.textures,i=0;i0))return t||cc.errorID(7507,this.name),null;var e=this._getAtlas(t);if(!e)return null;var i=new sp.spine.AtlasAttachmentLoader(e),n=new sp.spine.SkeletonJson(i);n.scale=this.scale;var r=this.skeletonJson;return this._skeletonCache=n.readSkeletonData(r),e.dispose(n),this._skeletonCache},getSkinsEnum:!1,getAnimsEnum:!1,_getAtlas:function(t){if(this._atlasCache)return this._atlasCache;if(!this.atlasText)return t||cc.errorID(7508,this.name),null;var e=new n(this);return this._atlasCache=new sp.spine.TextureAtlas(this.atlasText,e.load.bind(e))}});sp.SkeletonData=e.exports=r}),{}],308:[(function(t,e,i){sp={},sp.VERTEX_INDEX={X1:0,Y1:1,X2:2,Y2:3,X3:4,Y3:5,X4:6,Y4:7},sp.ATTACHMENT_TYPE={REGION:0,BOUNDING_BOX:1,MESH:2,SKINNED_MESH:3},sp.AnimationEventType=cc.Enum({START:0,INTERRUPT:1,END:2,DISPOSE:3,COMPLETE:4,EVENT:5}),sp.spine=t("./lib/spine"),t("./SGSkeletonTexture"),t("./SGSkeleton"),t("./SGSkeletonCanvasRenderCmd"),t("./SGSkeletonWebGLRenderCmd"),t("./SGSkeletonAnimation"),t("./SkeletonData"),t("./Skeleton")}),{"./SGSkeleton":301,"./SGSkeletonAnimation":302,"./SGSkeletonCanvasRenderCmd":303,"./SGSkeletonTexture":304,"./SGSkeletonWebGLRenderCmd":305,"./Skeleton":306,"./SkeletonData":307,"./lib/spine":309}],309:[(function(t,e,i){var n=this&&this.__extends||function(t,e){function i(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)};(function(t){var e=(function(){function t(t,e,i){if(null==t)throw new Error("name cannot be null.");if(null==e)throw new Error("timelines cannot be null.");this.name=t,this.timelines=e,this.duration=i}return t.prototype.apply=function(t,e,i,n,r,s,o,a){if(null==t)throw new Error("skeleton cannot be null.");n&&0!=this.duration&&(i%=this.duration,e>0&&(e%=this.duration));for(var c=this.timelines,h=0,l=c.length;h>>1;;){if(t[(s+1)*i]<=e?n=s+1:r=s,n==r)return(n+1)*i;s=n+r>>>1}},t.linearSearch=function(t,e,i){for(var n=0,r=t.length-i;n<=r;n+=i)if(t[n]>e)return n;return-1},t})();t.Animation=e,(function(t){t[t.rotate=0]="rotate",t[t.translate=1]="translate",t[t.scale=2]="scale",t[t.shear=3]="shear",t[t.attachment=4]="attachment",t[t.color=5]="color",t[t.deform=6]="deform",t[t.event=7]="event",t[t.drawOrder=8]="drawOrder",t[t.ikConstraint=9]="ikConstraint",t[t.transformConstraint=10]="transformConstraint",t[t.pathConstraintPosition=11]="pathConstraintPosition",t[t.pathConstraintSpacing=12]="pathConstraintSpacing",t[t.pathConstraintMix=13]="pathConstraintMix"})(t.TimelineType||(t.TimelineType={}));var i=t.TimelineType,r=(function(){function e(i){if(i<=0)throw new Error("frameCount must be > 0: "+i);this.curves=t.Utils.newFloatArray((i-1)*e.BEZIER_SIZE)}return e.prototype.getFrameCount=function(){return this.curves.length/e.BEZIER_SIZE+1},e.prototype.setLinear=function(t){this.curves[t*e.BEZIER_SIZE]=e.LINEAR},e.prototype.setStepped=function(t){this.curves[t*e.BEZIER_SIZE]=e.STEPPED},e.prototype.getCurveType=function(t){var i=t*e.BEZIER_SIZE;if(i==this.curves.length)return e.LINEAR;var n=this.curves[i];return n==e.LINEAR?e.LINEAR:n==e.STEPPED?e.STEPPED:e.BEZIER},e.prototype.setCurve=function(t,i,n,r,s){var o=.03*(2*-i+r),a=.03*(2*-n+s),c=.006*(3*(i-r)+1),h=.006*(3*(n-s)+1),l=2*o+c,u=2*a+h,_=.3*i+o+.16666667*c,d=.3*n+a+.16666667*h,f=t*e.BEZIER_SIZE,p=this.curves;p[f++]=e.BEZIER;for(var m=_,g=d,y=f+e.BEZIER_SIZE-1;f=n){var l=void 0,u=void 0;return s==c?(l=0,u=0):(l=r[s-2],u=r[s-1]),u+(r[s+1]-u)*(n-l)/(a-l)}var _=r[s-1];return _+(1-_)*(n-a)/(1-a)},e.LINEAR=0,e.STEPPED=1,e.BEZIER=2,e.BEZIER_SIZE=19,e})();t.CurveTimeline=r;var s=(function(r){function s(e){r.call(this,e),this.frames=t.Utils.newFloatArray(e<<1)}return n(s,r),s.prototype.getPropertyId=function(){return(i.rotate<<24)+this.boneIndex},s.prototype.setFrame=function(t,e,i){t<<=1,this.frames[t]=e,this.frames[t+s.ROTATION]=i},s.prototype.apply=function(t,i,n,r,o,a,c){var h=this.frames,l=t.bones[this.boneIndex];if(n=h[h.length-s.ENTRIES])if(a)l.rotation=l.data.rotation+h[h.length+s.PREV_ROTATION]*o;else{var u=l.data.rotation+h[h.length+s.PREV_ROTATION]-l.rotation;u-=360*(16384-(16384.499999999996-u/360|0)),l.rotation+=u*o}else{var _=e.binarySearch(h,n,s.ENTRIES),d=h[_+s.PREV_ROTATION],f=h[_],p=this.getCurvePercent((_>>1)-1,1-(n-f)/(h[_+s.PREV_TIME]-f)),m=h[_+s.ROTATION]-d;m=d+(m-=360*(16384-(16384.499999999996-m/360|0)))*p,a?(m-=360*(16384-(16384.499999999996-m/360|0)),l.rotation=l.data.rotation+m*o):(m=l.data.rotation+m-l.rotation,m-=360*(16384-(16384.499999999996-m/360|0)),l.rotation+=m*o)}},s.ENTRIES=2,s.PREV_TIME=-2,s.PREV_ROTATION=-1,s.ROTATION=1,s})(r);t.RotateTimeline=s;var o=(function(r){function s(e){r.call(this,e),this.frames=t.Utils.newFloatArray(e*s.ENTRIES)}return n(s,r),s.prototype.getPropertyId=function(){return(i.translate<<24)+this.boneIndex},s.prototype.setFrame=function(t,e,i,n){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.X]=i,this.frames[t+s.Y]=n},s.prototype.apply=function(t,i,n,r,o,a,c){var h=this.frames,l=t.bones[this.boneIndex];if(n=h[h.length-s.ENTRIES])u=h[h.length+s.PREV_X],_=h[h.length+s.PREV_Y];else{var d=e.binarySearch(h,n,s.ENTRIES);u=h[d+s.PREV_X],_=h[d+s.PREV_Y];var f=h[d],p=this.getCurvePercent(d/s.ENTRIES-1,1-(n-f)/(h[d+s.PREV_TIME]-f));u+=(h[d+s.X]-u)*p,_+=(h[d+s.Y]-_)*p}a?(l.x=l.data.x+u*o,l.y=l.data.y+_*o):(l.x+=(l.data.x+u-l.x)*o,l.y+=(l.data.y+_-l.y)*o)}},s.ENTRIES=3,s.PREV_TIME=-3,s.PREV_X=-2,s.PREV_Y=-1,s.X=1,s.Y=2,s})(r);t.TranslateTimeline=o;var a=(function(r){function s(t){r.call(this,t)}return n(s,r),s.prototype.getPropertyId=function(){return(i.scale<<24)+this.boneIndex},s.prototype.apply=function(i,n,r,o,a,c,h){var l=this.frames,u=i.bones[this.boneIndex];if(r=l[l.length-s.ENTRIES])_=l[l.length+s.PREV_X]*u.data.scaleX,d=l[l.length+s.PREV_Y]*u.data.scaleY;else{var f=e.binarySearch(l,r,s.ENTRIES);_=l[f+s.PREV_X],d=l[f+s.PREV_Y];var p=l[f],m=this.getCurvePercent(f/s.ENTRIES-1,1-(r-p)/(l[f+s.PREV_TIME]-p));_=(_+(l[f+s.X]-_)*m)*u.data.scaleX,d=(d+(l[f+s.Y]-d)*m)*u.data.scaleY}if(1==a)u.scaleX=_,u.scaleY=d;else{var g=0,y=0;c?(g=u.data.scaleX,y=u.data.scaleY):(g=u.scaleX,y=u.scaleY),h?(_=Math.abs(_)*t.MathUtils.signum(g),d=Math.abs(d)*t.MathUtils.signum(y)):(g=Math.abs(g)*t.MathUtils.signum(_),y=Math.abs(y)*t.MathUtils.signum(d)),u.scaleX=g+(_-g)*a,u.scaleY=y+(d-y)*a}}},s})(o);t.ScaleTimeline=a;var c=(function(t){function r(e){t.call(this,e)}return n(r,t),r.prototype.getPropertyId=function(){return(i.shear<<24)+this.boneIndex},r.prototype.apply=function(t,i,n,s,o,a,c){var h=this.frames,l=t.bones[this.boneIndex];if(n=h[h.length-r.ENTRIES])u=h[h.length+r.PREV_X],_=h[h.length+r.PREV_Y];else{var d=e.binarySearch(h,n,r.ENTRIES);u=h[d+r.PREV_X],_=h[d+r.PREV_Y];var f=h[d],p=this.getCurvePercent(d/r.ENTRIES-1,1-(n-f)/(h[d+r.PREV_TIME]-f));u+=(h[d+r.X]-u)*p,_+=(h[d+r.Y]-_)*p}a?(l.shearX=l.data.shearX+u*o,l.shearY=l.data.shearY+_*o):(l.shearX+=(l.data.shearX+u-l.shearX)*o,l.shearY+=(l.data.shearY+_-l.shearY)*o)}},r})(o);t.ShearTimeline=c;var h=(function(r){function s(e){r.call(this,e),this.frames=t.Utils.newFloatArray(e*s.ENTRIES)}return n(s,r),s.prototype.getPropertyId=function(){return(i.color<<24)+this.slotIndex},s.prototype.setFrame=function(t,e,i,n,r,o){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.R]=i,this.frames[t+s.G]=n,this.frames[t+s.B]=r,this.frames[t+s.A]=o},s.prototype.apply=function(t,i,n,r,o,a,c){var h=t.slots[this.slotIndex],l=this.frames;if(n=l[l.length-s.ENTRIES]){var p=l.length;u=l[p+s.PREV_R],_=l[p+s.PREV_G],d=l[p+s.PREV_B],f=l[p+s.PREV_A]}else{var m=e.binarySearch(l,n,s.ENTRIES);u=l[m+s.PREV_R],_=l[m+s.PREV_G],d=l[m+s.PREV_B],f=l[m+s.PREV_A];var g=l[m],y=this.getCurvePercent(m/s.ENTRIES-1,1-(n-g)/(l[m+s.PREV_TIME]-g));u+=(l[m+s.R]-u)*y,_+=(l[m+s.G]-_)*y,d+=(l[m+s.B]-d)*y,f+=(l[m+s.A]-f)*y}if(1==o)h.color.set(u,_,d,f);else{var v=h.color;a&&v.setFromColor(h.data.color),v.add((u-v.r)*o,(_-v.g)*o,(d-v.b)*o,(f-v.a)*o)}}},s.ENTRIES=5,s.PREV_TIME=-5,s.PREV_R=-4,s.PREV_G=-3,s.PREV_B=-2,s.PREV_A=-1,s.R=1,s.G=2,s.B=3,s.A=4,s})(r);t.ColorTimeline=h;var l=(function(){function n(e){this.frames=t.Utils.newFloatArray(e),this.attachmentNames=new Array(e)}return n.prototype.getPropertyId=function(){return(i.attachment<<24)+this.slotIndex},n.prototype.getFrameCount=function(){return this.frames.length},n.prototype.setFrame=function(t,e,i){this.frames[t]=e,this.attachmentNames[t]=i},n.prototype.apply=function(t,i,n,r,s,o,a){var c=t.slots[this.slotIndex];if(a&&o){var h=c.data.attachmentName;c.setAttachment(null==h?null:t.getAttachment(this.slotIndex,h))}else{var l=this.frames;if(n=l[l.length-1]?l.length-1:e.binarySearch(l,n,1)-1;var d=this.attachmentNames[_];t.slots[this.slotIndex].setAttachment(null==d?null:t.getAttachment(this.slotIndex,d))}}},n})();t.AttachmentTimeline=l;var u=(function(r){function s(e){r.call(this,e),this.frames=t.Utils.newFloatArray(e),this.frameVertices=new Array(e)}return n(s,r),s.prototype.getPropertyId=function(){return(i.deform<<24)+this.slotIndex},s.prototype.setFrame=function(t,e,i){this.frames[t]=e,this.frameVertices[t]=i},s.prototype.apply=function(i,n,r,s,o,a,c){var h=i.slots[this.slotIndex],l=h.getAttachment();if(l instanceof t.VertexAttachment&&l.applyDeform(this.attachment)){var u=this.frames,_=h.attachmentVertices;if(r=u[u.length-1]){var m=d[u.length-1];if(1==o)t.Utils.arrayCopy(m,0,p,0,f);else if(a){if(null==(w=l).bones)for(var g=w.vertices,y=0;yn)this.apply(t,i,Number.MAX_VALUE,r,s,o,a),i=-1;else if(i>=c[h-1])return;if(!(n0&&c[l-1]==u;)l--;for(;l=c[l];l++)r.push(this.events[l])}}},n})();t.EventTimeline=_;var d=(function(){function n(e){this.frames=t.Utils.newFloatArray(e),this.drawOrders=new Array(e)}return n.prototype.getPropertyId=function(){return i.drawOrder<<24},n.prototype.getFrameCount=function(){return this.frames.length},n.prototype.setFrame=function(t,e,i){this.frames[t]=e,this.drawOrders[t]=i},n.prototype.apply=function(i,n,r,s,o,a,c){var h=i.drawOrder,l=i.slots;if(c&&a)t.Utils.arrayCopy(i.slots,0,i.drawOrder,0,i.slots.length);else{var u=this.frames;if(r=u[u.length-1]?u.length-1:e.binarySearch(u,r)-1;var d=this.drawOrders[_];if(null==d)t.Utils.arrayCopy(l,0,h,0,l.length);else for(var f=0,p=d.length;f=h[h.length-s.ENTRIES])a?(l.mix=l.data.mix+(h[h.length+s.PREV_MIX]-l.data.mix)*o,l.bendDirection=c?l.data.bendDirection:h[h.length+s.PREV_BEND_DIRECTION]):(l.mix+=(h[h.length+s.PREV_MIX]-l.mix)*o,c||(l.bendDirection=h[h.length+s.PREV_BEND_DIRECTION]));else{var u=e.binarySearch(h,n,s.ENTRIES),_=h[u+s.PREV_MIX],d=h[u],f=this.getCurvePercent(u/s.ENTRIES-1,1-(n-d)/(h[u+s.PREV_TIME]-d));a?(l.mix=l.data.mix+(_+(h[u+s.MIX]-_)*f-l.data.mix)*o,l.bendDirection=c?l.data.bendDirection:h[u+s.PREV_BEND_DIRECTION]):(l.mix+=(_+(h[u+s.MIX]-_)*f-l.mix)*o,c||(l.bendDirection=h[u+s.PREV_BEND_DIRECTION]))}},s.ENTRIES=3,s.PREV_TIME=-3,s.PREV_MIX=-2,s.PREV_BEND_DIRECTION=-1,s.MIX=1,s.BEND_DIRECTION=2,s})(r);t.IkConstraintTimeline=f;var p=(function(r){function s(e){r.call(this,e),this.frames=t.Utils.newFloatArray(e*s.ENTRIES)}return n(s,r),s.prototype.getPropertyId=function(){return(i.transformConstraint<<24)+this.transformConstraintIndex},s.prototype.setFrame=function(t,e,i,n,r,o){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.ROTATE]=i,this.frames[t+s.TRANSLATE]=n,this.frames[t+s.SCALE]=r,this.frames[t+s.SHEAR]=o},s.prototype.apply=function(t,i,n,r,o,a,c){var h=this.frames,l=t.transformConstraints[this.transformConstraintIndex];if(n=h[h.length-s.ENTRIES]){var m=h.length;_=h[m+s.PREV_ROTATE],d=h[m+s.PREV_TRANSLATE],f=h[m+s.PREV_SCALE],p=h[m+s.PREV_SHEAR]}else{var g=e.binarySearch(h,n,s.ENTRIES);_=h[g+s.PREV_ROTATE],d=h[g+s.PREV_TRANSLATE],f=h[g+s.PREV_SCALE],p=h[g+s.PREV_SHEAR];var y=h[g],v=this.getCurvePercent(g/s.ENTRIES-1,1-(n-y)/(h[g+s.PREV_TIME]-y));_+=(h[g+s.ROTATE]-_)*v,d+=(h[g+s.TRANSLATE]-d)*v,f+=(h[g+s.SCALE]-f)*v,p+=(h[g+s.SHEAR]-p)*v}if(a){u=l.data;l.rotateMix=u.rotateMix+(_-u.rotateMix)*o,l.translateMix=u.translateMix+(d-u.translateMix)*o,l.scaleMix=u.scaleMix+(f-u.scaleMix)*o,l.shearMix=u.shearMix+(p-u.shearMix)*o}else l.rotateMix+=(_-l.rotateMix)*o,l.translateMix+=(d-l.translateMix)*o,l.scaleMix+=(f-l.scaleMix)*o,l.shearMix+=(p-l.shearMix)*o}},s.ENTRIES=5,s.PREV_TIME=-5,s.PREV_ROTATE=-4,s.PREV_TRANSLATE=-3,s.PREV_SCALE=-2,s.PREV_SHEAR=-1,s.ROTATE=1,s.TRANSLATE=2,s.SCALE=3,s.SHEAR=4,s})(r);t.TransformConstraintTimeline=p;var m=(function(r){function s(e){r.call(this,e),this.frames=t.Utils.newFloatArray(e*s.ENTRIES)}return n(s,r),s.prototype.getPropertyId=function(){return(i.pathConstraintPosition<<24)+this.pathConstraintIndex},s.prototype.setFrame=function(t,e,i){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.VALUE]=i},s.prototype.apply=function(t,i,n,r,o,a,c){var h=this.frames,l=t.pathConstraints[this.pathConstraintIndex];if(n=h[h.length-s.ENTRIES])u=h[h.length+s.PREV_VALUE];else{var _=e.binarySearch(h,n,s.ENTRIES);u=h[_+s.PREV_VALUE];var d=h[_],f=this.getCurvePercent(_/s.ENTRIES-1,1-(n-d)/(h[_+s.PREV_TIME]-d));u+=(h[_+s.VALUE]-u)*f}a?l.position=l.data.position+(u-l.data.position)*o:l.position+=(u-l.position)*o}},s.ENTRIES=2,s.PREV_TIME=-2,s.PREV_VALUE=-1,s.VALUE=1,s})(r);t.PathConstraintPositionTimeline=m;var g=(function(t){function r(e){t.call(this,e)}return n(r,t),r.prototype.getPropertyId=function(){return(i.pathConstraintSpacing<<24)+this.pathConstraintIndex},r.prototype.apply=function(t,i,n,s,o,a,c){var h=this.frames,l=t.pathConstraints[this.pathConstraintIndex];if(n=h[h.length-r.ENTRIES])u=h[h.length+r.PREV_VALUE];else{var _=e.binarySearch(h,n,r.ENTRIES);u=h[_+r.PREV_VALUE];var d=h[_],f=this.getCurvePercent(_/r.ENTRIES-1,1-(n-d)/(h[_+r.PREV_TIME]-d));u+=(h[_+r.VALUE]-u)*f}a?l.spacing=l.data.spacing+(u-l.data.spacing)*o:l.spacing+=(u-l.spacing)*o}},r})(m);t.PathConstraintSpacingTimeline=g;var y=(function(r){function s(e){r.call(this,e),this.frames=t.Utils.newFloatArray(e*s.ENTRIES)}return n(s,r),s.prototype.getPropertyId=function(){return(i.pathConstraintMix<<24)+this.pathConstraintIndex},s.prototype.setFrame=function(t,e,i,n){t*=s.ENTRIES,this.frames[t]=e,this.frames[t+s.ROTATE]=i,this.frames[t+s.TRANSLATE]=n},s.prototype.apply=function(t,i,n,r,o,a,c){var h=this.frames,l=t.pathConstraints[this.pathConstraintIndex];if(n=h[h.length-s.ENTRIES])u=h[h.length+s.PREV_ROTATE],_=h[h.length+s.PREV_TRANSLATE];else{var d=e.binarySearch(h,n,s.ENTRIES);u=h[d+s.PREV_ROTATE],_=h[d+s.PREV_TRANSLATE];var f=h[d],p=this.getCurvePercent(d/s.ENTRIES-1,1-(n-f)/(h[d+s.PREV_TIME]-f));u+=(h[d+s.ROTATE]-u)*p,_+=(h[d+s.TRANSLATE]-_)*p}a?(l.rotateMix=l.data.rotateMix+(u-l.data.rotateMix)*o,l.translateMix=l.data.translateMix+(_-l.data.translateMix)*o):(l.rotateMix+=(u-l.rotateMix)*o,l.translateMix+=(_-l.translateMix)*o)}},s.ENTRIES=3,s.PREV_TIME=-3,s.PREV_ROTATE=-2,s.PREV_TRANSLATE=-1,s.ROTATE=1,s.TRANSLATE=2,s})(r);t.PathConstraintMixTimeline=y})(r||(r={}));(function(t){var e=(function(){function e(e){this.tracks=new Array,this.events=new Array,this.listeners=new Array,this.queue=new n(this),this.propertyIDs=new t.IntSet,this.animationsChanged=!1,this.timeScale=1,this.trackEntryPool=new t.Pool(function(){return new i}),this.data=e}return e.prototype.update=function(t){t*=this.timeScale;for(var e=this.tracks,i=0,n=e.length;i0){if(r.delay-=s,r.delay>0)continue;s=-r.delay,r.delay=0}var o=r.next;if(null!=o){var a=r.trackLast-o.delay;if(a>=0){for(o.delay=0,o.trackTime=a+t*o.timeScale,r.trackTime+=s,this.setCurrent(i,o,!0);null!=o.mixingFrom;)o.mixTime+=s,o=o.mixingFrom;continue}}else if(r.trackLast>=r.trackEnd&&null==r.mixingFrom){e[i]=null,this.queue.end(r),this.disposeNext(r);continue}this.updateMixingFrom(r,t),r.trackTime+=s}}this.queue.drain()},e.prototype.updateMixingFrom=function(t,e){var i=t.mixingFrom;if(null!=i){if(this.updateMixingFrom(i,e),t.mixTime>=t.mixDuration&&null!=i.mixingFrom&&t.mixTime>0)return t.mixingFrom=null,void this.queue.end(i);i.animationLast=i.nextAnimationLast,i.trackLast=i.nextTrackLast,i.trackTime+=e*i.timeScale,t.mixTime+=e*i.timeScale}},e.prototype.apply=function(e){if(null==e)throw new Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();for(var i=this.events,n=this.tracks,r=0,s=n.length;r0)){var a=o.alpha;null!=o.mixingFrom?a*=this.applyMixingFrom(o,e):o.trackTime>=o.trackEnd&&(a=0);var c=o.animationLast,h=o.getAnimationTime(),l=o.animation.timelines.length,u=o.animation.timelines;if(1==a)for(var _=0;_1&&(r=1);var s=r0&&this.queueEvents(n,h),this.events.length=0,n.nextAnimationLast=h,n.nextTrackLast=n.trackTime,r},e.prototype.applyRotateTimeline=function(e,i,n,r,s,o,a,c){if(c&&(o[a]=0),1!=r){var h=e,l=h.frames,u=i.bones[h.boneIndex];if(n=l[l.length-t.RotateTimeline.ENTRIES])_=u.data.rotation+l[l.length+t.RotateTimeline.PREV_ROTATION];else{var d=t.Animation.binarySearch(l,n,t.RotateTimeline.ENTRIES),f=l[d+t.RotateTimeline.PREV_ROTATION],p=l[d],m=h.getCurvePercent((d>>1)-1,1-(n-p)/(l[d+t.RotateTimeline.PREV_TIME]-p));_=l[d+t.RotateTimeline.ROTATION]-f,_=f+(_-=360*(16384-(16384.499999999996-_/360|0)))*m+u.data.rotation,_-=360*(16384-(16384.499999999996-_/360|0))}var g=s?u.data.rotation:u.rotation,y=0,v=_-g;if(0==v)y=o[a];else{v-=360*(16384-(16384.499999999996-v/360|0));var x=0,C=0;c?(x=0,C=v):(x=o[a],C=o[a+1]);var T=v>0,b=x>=0;t.MathUtils.signum(C)!=t.MathUtils.signum(v)&&Math.abs(C)<=90&&(Math.abs(x)>180&&(x+=360*t.MathUtils.signum(x)),b=T),y=v+x-x%360,b!=T&&(y+=360*t.MathUtils.signum(x)),o[a]=y}o[a+1]=v,g+=y*r,u.rotation=g-360*(16384-(16384.499999999996-g/360|0))}}else e.apply(i,0,n,null,1,s,!1)},e.prototype.queueEvents=function(t,e){for(var i=t.animationStart,n=t.animationEnd,r=n-i,s=t.trackLast%r,o=this.events,a=0,c=o.length;an||this.queue.event(t,h)}for((t.loop?s>t.trackTime%r:e>=n&&t.animationLast=this.tracks.length)){var e=this.tracks[t];if(null!=e){this.queue.end(e),this.disposeNext(e);for(var i=e;;){var n=i.mixingFrom;if(null==n)break;this.queue.end(n),i.mixingFrom=null,i=n}this.tracks[e.trackIndex]=null,this.queue.drain()}}},e.prototype.setCurrent=function(t,e,i){var n=this.expandToIndex(t);this.tracks[t]=e,null!=n&&(i&&this.queue.interrupt(n),e.mixingFrom=n,e.mixTime=0,n.timelinesRotation.length=0,null!=n.mixingFrom&&n.mixDuration>0&&(e.mixAlpha*=Math.min(n.mixTime/n.mixDuration,1))),this.queue.start(e)},e.prototype.setAnimation=function(t,e,i){var n=this.data.skeletonData.findAnimation(e);if(null==n)throw new Error("Animation not found: "+e);return this.setAnimationWith(t,n,i)},e.prototype.setAnimationWith=function(t,e,i){if(null==e)throw new Error("animation cannot be null.");var n=!0,r=this.expandToIndex(t);null!=r&&(-1==r.nextTrackLast?(this.tracks[t]=r.mixingFrom,this.queue.interrupt(r),this.queue.end(r),this.disposeNext(r),r=r.mixingFrom,n=!1):this.disposeNext(r));var s=this.trackEntry(t,e,i,r);return this.setCurrent(t,s,n),this.queue.drain(),s},e.prototype.addAnimation=function(t,e,i,n){var r=this.data.skeletonData.findAnimation(e);if(null==r)throw new Error("Animation not found: "+e);return this.addAnimationWith(t,r,i,n)},e.prototype.addAnimationWith=function(t,e,i,n){if(null==e)throw new Error("animation cannot be null.");var r=this.expandToIndex(t);if(null!=r)for(;null!=r.next;)r=r.next;var s=this.trackEntry(t,e,i,r);if(null==r)this.setCurrent(t,s,!0),this.queue.drain();else if(r.next=s,n<=0){var o=r.animationEnd-r.animationStart;0!=o?n+=o*(1+(r.trackTime/o|0))-this.data.getMix(r.animation,e):n=0}return s.delay=n,s},e.prototype.setEmptyAnimation=function(t,i){var n=this.setAnimationWith(t,e.emptyAnimation,!1);return n.mixDuration=i,n.trackEnd=i,n},e.prototype.addEmptyAnimation=function(t,i,n){n<=0&&(n-=i);var r=this.addAnimationWith(t,e.emptyAnimation,!1,n);return r.mixDuration=i,r.trackEnd=i,r},e.prototype.setEmptyAnimations=function(t){this.queue.drainDisabled=!0;for(var e=0,i=this.tracks.length;e=this.tracks.length?null:this.tracks[t]},e.prototype.addListener=function(t){if(null==t)throw new Error("listener cannot be null.");this.listeners.push(t)},e.prototype.removeListener=function(t){var e=this.listeners.indexOf(t);e>=0&&this.listeners.splice(e,1)},e.prototype.clearListeners=function(){this.listeners.length=0},e.prototype.clearListenerNotifications=function(){this.queue.clear()},e.emptyAnimation=new t.Animation("",[],0),e})();t.AnimationState=e;var i=(function(){function t(){this.timelinesFirst=new Array,this.timelinesRotation=new Array}return t.prototype.reset=function(){this.next=null,this.mixingFrom=null,this.animation=null,this.listener=null,this.timelinesFirst.length=0,this.timelinesRotation.length=0},t.prototype.getAnimationTime=function(){if(this.loop){var t=this.animationEnd-this.animationStart;return 0==t?this.animationStart:this.trackTime%t+this.animationStart}return Math.min(this.trackTime+this.animationStart,this.animationEnd)},t.prototype.setAnimationLast=function(t){this.animationLast=t,this.nextAnimationLast=t},t.prototype.isComplete=function(){return this.trackTime>=this.animationEnd-this.animationStart},t.prototype.resetRotationDirections=function(){this.timelinesRotation.length=0},t})();t.TrackEntry=i;var n=(function(){function t(t){this.objects=[],this.drainDisabled=!1,this.animState=t}return t.prototype.start=function(t){this.objects.push(r.start),this.objects.push(t),this.animState.animationsChanged=!0},t.prototype.interrupt=function(t){this.objects.push(r.interrupt),this.objects.push(t)},t.prototype.end=function(t){this.objects.push(r.end),this.objects.push(t),this.animState.animationsChanged=!0},t.prototype.dispose=function(t){this.objects.push(r.dispose),this.objects.push(t)},t.prototype.complete=function(t){this.objects.push(r.complete),this.objects.push(t)},t.prototype.event=function(t,e){this.objects.push(r.event),this.objects.push(t),this.objects.push(e)},t.prototype.drain=function(){if(!this.drainDisabled){this.drainDisabled=!0;for(var t=this.objects,e=this.animState.listeners,i=0;i=200&&r.status<300?(n.assets[t]=r.responseText,e&&e(t,r.responseText)):(n.errors[t]="Couldn't load text "+t+": status "+r.status+", "+r.responseText,i&&i(t,"Couldn't load text "+t+": status "+r.status+", "+r.responseText)),n.toLoad--,n.loaded++)},r.open("GET",t,!0),r.send()},t.prototype.loadTexture=function(t,e,i){var n=this;void 0===e&&(e=null),void 0===i&&(i=null),t=this.pathPrefix+t,this.toLoad++;var r=new Image;r.crossOrigin="anonymous",r.src=t,r.onload=function(i){var s=n.textureLoader(r);n.assets[t]=s,n.toLoad--,n.loaded++,e&&e(t,r)},r.onerror=function(e){n.errors[t]="Couldn't load image "+t,n.toLoad--,n.loaded++,i&&i(t,"Couldn't load image "+t)}},t.prototype.get=function(t){return t=this.pathPrefix+t,this.assets[t]},t.prototype.remove=function(t){t=this.pathPrefix+t;var e=this.assets[t];e.dispose&&e.dispose(),this.assets[t]=null},t.prototype.removeAll=function(){for(var t in this.assets){var e=this.assets[t];e.dispose&&e.dispose()}this.assets={}},t.prototype.isLoadingComplete=function(){return 0==this.toLoad},t.prototype.getToLoad=function(){return this.toLoad},t.prototype.getLoaded=function(){return this.loaded},t.prototype.dispose=function(){this.removeAll()},t.prototype.hasErrors=function(){return Object.keys(this.errors).length>0},t.prototype.getErrors=function(){return this.errors},t})();t.AssetManager=e})(r||(r={}));(function(t){var e=(function(){function e(t){this.atlas=t}return e.prototype.newRegionAttachment=function(e,i,n){var r=this.atlas.findRegion(n);if(null==r)throw new Error("Region not found in atlas: "+n+" (region attachment: "+i+")");r.renderObject=r;var s=new t.RegionAttachment(i);return s.setRegion(r),s},e.prototype.newMeshAttachment=function(e,i,n){var r=this.atlas.findRegion(n);if(null==r)throw new Error("Region not found in atlas: "+n+" (mesh attachment: "+i+")");r.renderObject=r;var s=new t.MeshAttachment(i);return s.region=r,s},e.prototype.newBoundingBoxAttachment=function(e,i){return new t.BoundingBoxAttachment(i)},e.prototype.newPathAttachment=function(e,i){return new t.PathAttachment(i)},e})();t.AtlasAttachmentLoader=e})(r||(r={}));(function(t){var e=(function(){return function(t){if(null==t)throw new Error("name cannot be null.");this.name=t}})();t.Attachment=e;var i=(function(t){function e(e){t.call(this,e),this.worldVerticesLength=0}return n(e,t),e.prototype.computeWorldVertices=function(t,e){this.computeWorldVerticesWith(t,0,this.worldVerticesLength,e,0)},e.prototype.computeWorldVerticesWith=function(t,e,i,n,r){i+=r;var s=t.bone.skeleton,o=t.attachmentVertices,a=this.vertices,c=this.bones;if(null!=c){for(var h=0,l=0,u=0;u0&&(a=o);for(var v,x=(v=t.bone).worldX,C=v.worldY,T=v.a,b=v.b,A=v.c,S=v.d,w=e,E=r;E>1);null!=this.worldVertices&&this.worldVertices.length==n||(this.worldVertices=t.Utils.newFloatArray(n));var r=0,s=0,o=0,a=0;if(null==this.region?(r=s=0,o=a=1):(r=this.region.u,s=this.region.v,o=this.region.u2-r,a=this.region.v2-s),this.region.rotate)for(var c=0,h=6;c0&&(l=h);for(var f=(R=t.bone).worldX,p=R.worldY,m=R.a,g=R.b,y=R.c,v=R.d,x=0,C=0;x1e-4?(m=g*(T=Math.abs(p*y-m*g)/T),y=p*T,v=Math.atan2(g,p)*t.MathUtils.radDeg):(p=0,g=0,v=90-Math.atan2(y,m)*t.MathUtils.radDeg);var x=n+o-v,C=n+a-v+90;l=t.MathUtils.cosDeg(x)*r,u=t.MathUtils.cosDeg(C)*s,_=t.MathUtils.sinDeg(x)*r,d=t.MathUtils.sinDeg(C)*s;this.a=p*l-m*_,this.b=p*u-m*d,this.c=g*l+y*_,this.d=g*u+y*d;break;case t.TransformMode.NoScale:case t.TransformMode.NoScaleOrReflection:var T,b=t.MathUtils.cosDeg(n),A=t.MathUtils.sinDeg(n),S=p*b+m*A,w=g*b+y*A;(T=Math.sqrt(S*S+w*w))>1e-5&&(T=1/T),S*=T,w*=T,T=Math.sqrt(S*S+w*w);var E=Math.PI/2+Math.atan2(w,S),I=Math.cos(E)*T,R=Math.sin(E)*T;l=t.MathUtils.cosDeg(o)*r,u=t.MathUtils.cosDeg(90+a)*s,_=t.MathUtils.sinDeg(o)*r,d=t.MathUtils.sinDeg(90+a)*s;return this.a=S*l+I*_,this.b=S*u+I*d,this.c=w*l+R*_,this.d=w*u+R*d,void((this.data.transformMode!=t.TransformMode.NoScaleOrReflection?p*y-m*g<0:this.skeleton.flipX!=this.skeleton.flipY)&&(this.b=-this.b,this.d=-this.d))}this.skeleton.flipX&&(this.a=-this.a,this.b=-this.b),this.skeleton.flipY&&(this.c=-this.c,this.d=-this.d)},e.prototype.setToSetupPose=function(){var t=this.data;this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this.shearX=t.shearX,this.shearY=t.shearY},e.prototype.getWorldRotationX=function(){return Math.atan2(this.c,this.a)*t.MathUtils.radDeg},e.prototype.getWorldRotationY=function(){return Math.atan2(this.d,this.b)*t.MathUtils.radDeg},e.prototype.getWorldScaleX=function(){return Math.sqrt(this.a*this.a+this.c*this.c)},e.prototype.getWorldScaleY=function(){return Math.sqrt(this.b*this.b+this.d*this.d)},e.prototype.worldToLocalRotationX=function(){var e=this.parent;if(null==e)return this.arotation;var i=e.a,n=e.b,r=e.c,s=e.d,o=this.a,a=this.c;return Math.atan2(i*a-r*o,s*o-n*a)*t.MathUtils.radDeg},e.prototype.worldToLocalRotationY=function(){var e=this.parent;if(null==e)return this.arotation;var i=e.a,n=e.b,r=e.c,s=e.d,o=this.b,a=this.d;return Math.atan2(i*a-r*o,s*o-n*a)*t.MathUtils.radDeg},e.prototype.rotateWorld=function(e){var i=this.a,n=this.b,r=this.c,s=this.d,o=t.MathUtils.cosDeg(e),a=t.MathUtils.sinDeg(e);this.a=o*i-a*r,this.b=o*n-a*s,this.c=a*i+o*r,this.d=a*n+o*s,this.appliedValid=!1},e.prototype.updateAppliedTransform=function(){this.appliedValid=!0;var e=this.parent;if(null==e)return this.ax=this.worldX,this.ay=this.worldY,this.arotation=Math.atan2(this.c,this.a)*t.MathUtils.radDeg,this.ascaleX=Math.sqrt(this.a*this.a+this.c*this.c),this.ascaleY=Math.sqrt(this.b*this.b+this.d*this.d),this.ashearX=0,void(this.ashearY=Math.atan2(this.a*this.b+this.c*this.d,this.a*this.d-this.b*this.c)*t.MathUtils.radDeg);var i=e.a,n=e.b,r=e.c,s=e.d,o=1/(i*s-n*r),a=this.worldX-e.worldX,c=this.worldY-e.worldY;this.ax=a*s*o-c*n*o,this.ay=c*i*o-a*r*o;var h=o*s,l=o*i,u=o*n,_=o*r,d=h*this.a-u*this.c,f=h*this.b-u*this.d,p=l*this.c-_*this.a,m=l*this.d-_*this.b;if(this.ashearX=0,this.ascaleX=Math.sqrt(d*d+p*p),this.ascaleX>1e-4){var g=d*m-f*p;this.ascaleY=g/this.ascaleX,this.ashearY=Math.atan2(d*f+p*m,g)*t.MathUtils.radDeg,this.arotation=Math.atan2(p,d)*t.MathUtils.radDeg}else this.ascaleX=0,this.ascaleY=Math.sqrt(f*f+m*m),this.ashearY=0,this.arotation=90-Math.atan2(m,f)*t.MathUtils.radDeg},e.prototype.worldToLocal=function(t){var e=this.a,i=this.b,n=this.c,r=this.d,s=1/(e*r-i*n),o=t.x-this.worldX,a=t.y-this.worldY;return t.x=o*r*s-a*i*s,t.y=a*e*s-o*n*s,t},e.prototype.localToWorld=function(t){var e=t.x,i=t.y;return t.x=e*this.a+i*this.b+this.worldX,t.y=e*this.c+i*this.d+this.worldY,t},e})();t.Bone=e})(r||(r={}));(function(t){var e=(function(){return function(t,e,n){if(this.x=0,this.y=0,this.rotation=0,this.scaleX=1,this.scaleY=1,this.shearX=0,this.shearY=0,this.transformMode=i.Normal,t<0)throw new Error("index must be >= 0.");if(null==e)throw new Error("name cannot be null.");this.index=t,this.name=e,this.parent=n}})();t.BoneData=e,(function(t){t[t.Normal=0]="Normal",t[t.OnlyTranslation=1]="OnlyTranslation",t[t.NoRotationOrReflection=2]="NoRotationOrReflection",t[t.NoScale=3]="NoScale",t[t.NoScaleOrReflection=4]="NoScaleOrReflection"})(t.TransformMode||(t.TransformMode={}));var i=t.TransformMode})(r||(r={}));(function(t){var e=(function(){return function(t,e){if(null==e)throw new Error("data cannot be null.");this.time=t,this.data=e}})();t.Event=e})(r||(r={}));(function(t){var e=(function(){return function(t){this.name=t}})();t.EventData=e})(r||(r={}));(function(t){var e=(function(){function e(t,e){if(this.mix=1,this.bendDirection=0,null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.mix=t.mix,this.bendDirection=t.bendDirection,this.bones=new Array;for(var i=0;i180?u-=360:u<-180&&(u+=360),e.updateWorldTransformWith(e.ax,e.ay,e.arotation+u*r,e.ascaleX,e.ascaleY,e.ashearX,e.ashearY)},e.prototype.apply2=function(e,i,n,r,s,o){if(0!=o){e.appliedValid||e.updateAppliedTransform(),i.appliedValid||i.updateAppliedTransform();var a=e.ax,c=e.ay,h=e.ascaleX,l=e.ascaleY,u=i.ascaleX,_=0,d=0,f=0;h<0?(h=-h,_=180,f=-1):(_=0,f=1),l<0&&(l=-l,f=-f),u<0?(u=-u,d=180):d=0;var p=i.ax,m=0,g=0,y=0,v=e.a,x=e.b,C=e.c,T=e.d,b=Math.abs(h-l)<=1e-4;b?(g=v*p+x*(m=i.ay)+e.worldX,y=C*p+T*m+e.worldY):(m=0,g=v*p+e.worldX,y=C*p+e.worldY);var A=e.parent;v=A.a,x=A.b,C=A.c;var S=1/(v*(T=A.d)-x*C),w=n-A.worldX,E=r-A.worldY,I=(w*T-E*x)*S-a,R=(E*v-w*C)*S-c,P=((w=g-A.worldX)*T-(E=y-A.worldY)*x)*S-a,O=(E*v-w*C)*S-c,B=Math.sqrt(P*P+O*O),D=i.data.length*u,M=0,L=0;t:if(b){var N=(I*I+R*R-B*B-(D*=h)*D)/(2*B*D);N<-1?N=-1:N>1&&(N=1),L=Math.acos(N)*s,v=B+D*N,x=D*Math.sin(L),M=Math.atan2(R*v-I*x,I*v+R*x)}else{var F=(v=h*D)*v,k=(x=l*D)*x,z=I*I+R*R,V=Math.atan2(R,I),G=-2*k*B,W=k-F;if((T=G*G-4*W*(C=k*B*B+F*z-F*k))>=0){var U=Math.sqrt(T);G<0&&(U=-U);var j=(U=-(G+U)/2)/W,X=C/U,Y=Math.abs(j)K&&(Q=0,K=T,$=w),(T=(w=B-v)*w)K&&(Q=et,K=T,$=w,tt=E),z<=(q+K)/2?(M=V-Math.atan2(Z*s,J),L=H*s):(M=V-Math.atan2(tt*s,$),L=Q*s)}var it=Math.atan2(m,p)*f,nt=e.arotation;(M=(M-it)*t.MathUtils.radDeg+_-nt)>180?M-=360:M<-180&&(M+=360),e.updateWorldTransformWith(a,c,nt+M*o,e.ascaleX,e.ascaleY,0,0),nt=i.arotation,(L=((L+it)*t.MathUtils.radDeg-i.ashearX)*f+d-nt)>180?L-=360:L<-180&&(L+=360),i.updateWorldTransformWith(p,m,nt+L*o,i.ascaleX,i.ascaleY,i.ashearX,i.ashearY)}else i.updateWorldTransform()},e})();t.IkConstraint=e})(r||(r={}));(function(t){var e=(function(){return function(t){this.order=0,this.bones=new Array,this.bendDirection=1,this.mix=1,this.name=t}})();t.IkConstraintData=e})(r||(r={}));(function(t){var e=(function(){function e(t,e){if(this.position=0,this.spacing=0,this.rotateMix=0,this.translateMix=0,this.spaces=new Array,this.positions=new Array,this.world=new Array,this.curves=new Array,this.lengths=new Array,this.segments=new Array,null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(var i=0,n=t.bones.length;i0;if(n>0||r){var s=this.data,o=s.spacingMode,a=o==t.SpacingMode.Length,c=s.rotateMode,h=c==t.RotateMode.Tangent,l=c==t.RotateMode.ChainScale,u=this.bones.length,_=h?u:u+1,d=this.bones,f=t.Utils.setArraySize(this.spaces,_),p=null,m=this.spacing;if(l||a){l&&(p=t.Utils.setArraySize(this.lengths,u));for(var g=0,y=_-1;g0?t.MathUtils.degRad:-t.MathUtils.degRad}g=0;for(var E=3;gt.MathUtils.PI?F-=t.MathUtils.PI2:F<-t.MathUtils.PI&&(F+=t.MathUtils.PI2),F*=i,k=Math.cos(F),z=Math.sin(F),I.a=k*D-z*L,I.b=k*M-z*N,I.c=z*D+k*L,I.d=z*M+k*N}I.appliedValid=!1}}}},e.prototype.computeWorldPositions=function(i,n,r,s,o){var a=this.target,c=this.position,h=this.spaces,l=t.Utils.setArraySize(this.positions,3*n+2),u=null,_=i.closed,d=i.worldVerticesLength,f=d/6,p=e.NONE;if(!i.constantSpeed){var m=i.lengths,g=m[f-=_?1:2];if(s&&(c*=g),o)for(var y=0;yg){p!=e.AFTER&&(p=e.AFTER,i.computeWorldVerticesWith(a,d-6,4,u,0)),this.addAfterPosition(C-g,u,0,l,v);continue}}for(;;x++){var T=m[x];if(!(C>T)){if(0==x)C/=T;else{C=(C-(J=m[x-1]))/(T-J)}break}}x!=p&&(p=x,_&&x==f?(i.computeWorldVerticesWith(a,d-4,4,u,0),i.computeWorldVerticesWith(a,0,4,u,4)):i.computeWorldVerticesWith(a,6*x+2,8,u,0)),this.addCurvePosition(C,u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],l,v,r||y>0&&0==X)}return l}_?(d+=2,u=t.Utils.setArraySize(this.world,d),i.computeWorldVerticesWith(a,2,d-4,u,0),i.computeWorldVerticesWith(a,0,2,u,d-4),u[d-2]=u[0],u[d-1]=u[1]):(f--,d-=4,u=t.Utils.setArraySize(this.world,d),i.computeWorldVerticesWith(a,2,d,u,0));for(var b=t.Utils.setArraySize(this.curves,f),A=0,S=u[0],w=u[1],E=0,I=0,R=0,P=0,O=0,B=0,D=0,M=0,L=0,N=0,F=0,k=0,z=0,V=0,G=(y=0,2);yA){this.addAfterPosition(C-A,u,d-4,l,v);continue}}for(;;x++){var Y=b[x];if(!(C>Y)){if(0==x)C/=Y;else{C=(C-(J=b[x-1]))/(Y-J)}break}}if(x!=p){p=x;var H=6*x;for(S=u[H],w=u[H+1],E=u[H+2],I=u[H+3],R=u[H+4],P=u[H+5],F=2*(D=.03*(S-2*E+R))+(L=.006*(3*(E-R)-S+(O=u[H+6]))),k=2*(M=.03*(w-2*I+P))+(N=.006*(3*(I-P)-w+(B=u[H+7]))),z=.3*(E-S)+D+.16666667*L,V=.3*(I-w)+M+.16666667*N,U=Math.sqrt(z*z+V*V),W[0]=U,H=1;H<8;H++)z+=F,V+=k,F+=L,k+=N,U+=Math.sqrt(z*z+V*V),W[H]=U;z+=F,V+=k,U+=Math.sqrt(z*z+V*V),W[8]=U,z+=F+L,V+=k+N,U+=Math.sqrt(z*z+V*V),W[9]=U,j=0}for(C*=U;;j++){var q=W[j];if(!(C>q)){if(0==j)C/=q;else{var J;C=j+(C-(J=W[j-1]))/(q-J)}break}}this.addCurvePosition(.1*C,S,w,E,I,R,P,O,B,l,v,r||y>0&&0==X)}return l},e.prototype.addBeforePosition=function(t,e,i,n,r){var s=e[i],o=e[i+1],a=e[i+2]-s,c=e[i+3]-o,h=Math.atan2(c,a);n[r]=s+t*Math.cos(h),n[r+1]=o+t*Math.sin(h),n[r+2]=h},e.prototype.addAfterPosition=function(t,e,i,n,r){var s=e[i+2],o=e[i+3],a=s-e[i],c=o-e[i+1],h=Math.atan2(c,a);n[r]=s+t*Math.cos(h),n[r+1]=o+t*Math.sin(h),n[r+2]=h},e.prototype.addCurvePosition=function(t,e,i,n,r,s,o,a,c,h,l,u){(0==t||isNaN(t))&&(t=1e-4);var _=t*t,d=_*t,f=1-t,p=f*f,m=p*f,g=f*t,y=3*g,v=f*y,x=y*t,C=e*m+n*v+s*x+a*d,T=i*m+r*v+o*x+c*d;h[l]=C,h[l+1]=T,u&&(h[l+2]=Math.atan2(T-(i*p+r*g*2+o*_),C-(e*p+n*g*2+s*_)))},e.prototype.getOrder=function(){return this.data.order},e.NONE=-1,e.BEFORE=-2,e.AFTER=-3,e})();t.PathConstraint=e})(r||(r={}));(function(t){var e=(function(){return function(t){this.order=0,this.bones=new Array,this.name=t}})();t.PathConstraintData=e,(function(t){t[t.Fixed=0]="Fixed",t[t.Percent=1]="Percent"})(t.PositionMode||(t.PositionMode={}));t.PositionMode;(function(t){t[t.Length=0]="Length",t[t.Fixed=1]="Fixed",t[t.Percent=2]="Percent"})(t.SpacingMode||(t.SpacingMode={}));t.SpacingMode;(function(t){t[t.Tangent=0]="Tangent",t[t.Chain=1]="Chain",t[t.ChainScale=2]="ChainScale"})(t.RotateMode||(t.RotateMode={}));t.RotateMode})(r||(r={}));(function(t){var e=(function(){function t(t){this.toLoad=new Array,this.assets={},this.clientId=t}return t.prototype.loaded=function(){var t=0;for(var e in this.assets)t++;return t},t})(),i=(function(){function t(t){void 0===t&&(t=""),this.clientAssets={},this.queuedAssets={},this.rawAssets={},this.errors={},this.pathPrefix=t}return t.prototype.queueAsset=function(t,i,n){var r=this.clientAssets[t];return null!==r&&void 0!==r||(r=new e(t),this.clientAssets[t]=r),null!==i&&(r.textureLoader=i),r.toLoad.push(n),this.queuedAssets[n]!==n&&(this.queuedAssets[n]=n,!0)},t.prototype.loadText=function(t,e){var i=this;if(e=this.pathPrefix+e,this.queueAsset(t,null,e)){var n=new XMLHttpRequest;n.onreadystatechange=function(){n.readyState==XMLHttpRequest.DONE&&(n.status>=200&&n.status<300?i.rawAssets[e]=n.responseText:i.errors[e]="Couldn't load text "+e+": status "+n.status+", "+n.responseText)},n.open("GET",e,!0),n.send()}},t.prototype.loadJson=function(t,e){var i=this;if(e=this.pathPrefix+e,this.queueAsset(t,null,e)){var n=new XMLHttpRequest;n.onreadystatechange=function(){n.readyState==XMLHttpRequest.DONE&&(n.status>=200&&n.status<300?i.rawAssets[e]=JSON.parse(n.responseText):i.errors[e]="Couldn't load text "+e+": status "+n.status+", "+n.responseText)},n.open("GET",e,!0),n.send()}},t.prototype.loadTexture=function(t,e,i){var n=this;if(i=this.pathPrefix+i,this.queueAsset(t,e,i)){var r=new Image;r.src=i,r.crossOrigin="anonymous",r.onload=function(t){n.rawAssets[i]=r},r.onerror=function(t){n.errors[i]="Couldn't load image "+i}}},t.prototype.get=function(t,e){e=this.pathPrefix+e;var i=this.clientAssets[t];return null===i||void 0===i||i.assets[e]},t.prototype.updateClientAssets=function(t){for(var e=0;e0},t.prototype.getErrors=function(){return this.errors},t})();t.SharedAssetManager=i})(r||(r={}));(function(t){var e=(function(){function e(e){if(this._updateCache=new Array,this.updateCacheReset=new Array,this.time=0,this.flipX=!1,this.flipY=!1,this.x=0,this.y=0,null==e)throw new Error("data cannot be null.");this.data=e,this.bones=new Array;for(var i=0;i1){var r=i[i.length-1];this._updateCache.indexOf(r)>-1||this.updateCacheReset.push(r)}this._updateCache.push(t),this.sortReset(n.children),i[i.length-1].sorted=!0},e.prototype.sortPathConstraint=function(e){var i=e.target,n=i.data.index,r=i.bone;null!=this.skin&&this.sortPathConstraintAttachment(this.skin,n,r),null!=this.data.defaultSkin&&this.data.defaultSkin!=this.skin&&this.sortPathConstraintAttachment(this.data.defaultSkin,n,r);for(var s=0,o=this.data.skins.length;s=this.minX&&t<=this.maxX&&e>=this.minY&&e<=this.maxY},e.prototype.aabbIntersectsSegment=function(t,e,i,n){var r=this.minX,s=this.minY,o=this.maxX,a=this.maxY;if(t<=r&&i<=r||e<=s&&n<=s||t>=o&&i>=o||e>=a&&n>=a)return!1;var c=(n-e)/(i-t),h=c*(r-t)+e;if(h>s&&hs&&hr&&lr&&lt.minX&&this.minYt.minY},e.prototype.containsPoint=function(t,e){for(var i=this.polygons,n=0,r=i.length;n=i||h=i){var l=n[a];l+(i-c)/(h-c)*(n[s]-l)=l&&v<=d||v>=d&&v<=l)&&(v>=e&&v<=n||v>=n&&v<=e)){var x=(h*g-c*p)/y;if((x>=u&&x<=f||x>=f&&x<=u)&&(x>=i&&x<=r||x>=r&&x<=i))return!0}l=d,u=f}return!1},e.prototype.getPolygon=function(t){if(null==t)throw new Error("boundingBox cannot be null.");var e=this.boundingBoxes.indexOf(t);return-1==e?null:this.polygons[e]},e.prototype.getWidth=function(){return this.maxX-this.minX},e.prototype.getHeight=function(){return this.maxY-this.minY},e})();t.SkeletonBounds=e})(r||(r={}));(function(t){var e=(function(){function t(){this.bones=new Array,this.slots=new Array,this.skins=new Array,this.events=new Array,this.animations=new Array,this.ikConstraints=new Array,this.transformConstraints=new Array,this.pathConstraints=new Array,this.fps=0}return t.prototype.findBone=function(t){if(null==t)throw new Error("boneName cannot be null.");for(var e=this.bones,i=0,n=e.length;i=0;_--)-1==W[_]&&(W[_]=j[--Y])}y.setFrame(u++,G.time,W)}s.push(y),o=Math.max(o,y.frames[y.getFrameCount()-1])}if(e.events){for(y=new t.EventTimeline(e.events.length),u=0,_=0;_=n.length&&(n.length=t+1),n[t]||(n[t]={}),n[t][e]=i},t.prototype.getAttachment=function(t,e){var i=this.attachments[t];return i?i[e]:null},t.prototype.attachAll=function(t,e){for(var i=0,n=0;n= 0.");if(null==i)throw new Error("name cannot be null.");if(null==n)throw new Error("boneData cannot be null.");this.index=e,this.name=i,this.boneData=n}})();t.SlotData=e})(r||(r={}));(function(t){var e=(function(){function t(t){this._image=t}return t.prototype.getImage=function(){return this._image},t.filterFromString=function(t){switch(t.toLowerCase()){case"nearest":return i.Nearest;case"linear":return i.Linear;case"mipmap":return i.MipMap;case"mipmapnearestnearest":return i.MipMapNearestNearest;case"mipmaplinearnearest":return i.MipMapLinearNearest;case"mipmapnearestlinear":return i.MipMapNearestLinear;case"mipmaplinearlinear":return i.MipMapLinearLinear;default:throw new Error("Unknown texture filter "+t)}},t.wrapFromString=function(t){switch(t.toLowerCase()){case"mirroredtepeat":return n.MirroredRepeat;case"clamptoedge":return n.ClampToEdge;case"repeat":return n.Repeat;default:throw new Error("Unknown texture wrap "+t)}},t})();t.Texture=e,(function(t){t[t.Nearest=9728]="Nearest",t[t.Linear=9729]="Linear",t[t.MipMap=9987]="MipMap",t[t.MipMapNearestNearest=9984]="MipMapNearestNearest",t[t.MipMapLinearNearest=9985]="MipMapLinearNearest",t[t.MipMapNearestLinear=9986]="MipMapNearestLinear",t[t.MipMapLinearLinear=9987]="MipMapLinearLinear"})(t.TextureFilter||(t.TextureFilter={}));var i=t.TextureFilter;(function(t){t[t.MirroredRepeat=33648]="MirroredRepeat",t[t.ClampToEdge=33071]="ClampToEdge",t[t.Repeat=10497]="Repeat"})(t.TextureWrap||(t.TextureWrap={}));var n=t.TextureWrap,r=(function(){return function(){this.u=0,this.v=0,this.u2=0,this.v2=0,this.width=0,this.height=0,this.rotate=!1,this.offsetX=0,this.offsetY=0,this.originalWidth=0,this.originalHeight=0}})();t.TextureRegion=r})(r||(r={}));(function(t){var e=(function(){function e(t,e){this.pages=new Array,this.regions=new Array,this.load(t,e)}return e.prototype.load=function(e,n){if(null==n)throw new Error("textureLoader cannot be null.");for(var o=new i(e),a=new Array(4),c=null;;){var h=o.readLine();if(null==h)break;if(0==(h=h.trim()).length)c=null;else if(c){var l=new s;l.name=h,l.page=c,l.rotate="true"==o.readValue(),o.readTuple(a);var u=parseInt(a[0]),_=parseInt(a[1]);o.readTuple(a);var d=parseInt(a[0]),f=parseInt(a[1]);l.u=u/c.width,l.v=_/c.height,l.rotate?(l.u2=(u+f)/c.width,l.v2=(_+d)/c.height):(l.u2=(u+d)/c.width,l.v2=(_+f)/c.height),l.x=u,l.y=_,l.width=Math.abs(d),l.height=Math.abs(f),4==o.readTuple(a)&&4==o.readTuple(a)&&o.readTuple(a),l.originalWidth=parseInt(a[0]),l.originalHeight=parseInt(a[1]),o.readTuple(a),l.offsetX=parseInt(a[0]),l.offsetY=parseInt(a[1]),l.index=parseInt(o.readValue()),l.texture=c.texture,this.regions.push(l)}else{(c=new r).name=h,2==o.readTuple(a)&&(c.width=parseInt(a[0]),c.height=parseInt(a[1]),o.readTuple(a)),o.readTuple(a),c.minFilter=t.Texture.filterFromString(a[0]),c.magFilter=t.Texture.filterFromString(a[1]);var p=o.readValue();c.uWrap=t.TextureWrap.ClampToEdge,c.vWrap=t.TextureWrap.ClampToEdge,"x"==p?c.uWrap=t.TextureWrap.Repeat:"y"==p?c.vWrap=t.TextureWrap.Repeat:"xy"==p&&(c.uWrap=c.vWrap=t.TextureWrap.Repeat),c.texture=n(h),c.texture.setFilters(c.minFilter,c.magFilter),c.texture.setWraps(c.uWrap,c.vWrap),c.width=c.texture.getImage().width,c.height=c.texture.getImage().height,this.pages.push(c)}}},e.prototype.findRegion=function(t){for(var e=0;e=this.lines.length?null:this.lines[this.index++]},t.prototype.readValue=function(){var t=this.readLine(),e=t.indexOf(":");if(-1==e)throw new Error("Invalid line: "+t);return t.substring(e+1).trim()},t.prototype.readTuple=function(t){var e=this.readLine(),i=e.indexOf(":");if(-1==i)throw new Error("Invalid line: "+e);for(var n=0,r=i+1;n<3;n++){var s=e.indexOf(",",r);if(-1==s)break;t[n]=e.substr(r,s-r).trim(),r=s+1}return t[n]=e.substring(r).trim(),n+1},t})(),r=(function(){return function(){}})();t.TextureAtlasPage=r;var s=(function(t){function e(){t.apply(this,arguments)}return n(e,t),e})(t.TextureRegion);t.TextureAtlasRegion=s})(r||(r={}));(function(t){var e=(function(){function e(e,i){if(this.rotateMix=0,this.translateMix=0,this.scaleMix=0,this.shearMix=0,this.temp=new t.Vector2,null==e)throw new Error("data cannot be null.");if(null==i)throw new Error("skeleton cannot be null.");this.data=e,this.rotateMix=e.rotateMix,this.translateMix=e.translateMix,this.scaleMix=e.scaleMix,this.shearMix=e.shearMix,this.bones=new Array;for(var n=0;n0?t.MathUtils.degRad:-t.MathUtils.degRad,u=this.data.offsetRotation*l,_=this.data.offsetShearY*l,d=this.bones,f=0,p=d.length;ft.MathUtils.PI?E-=t.MathUtils.PI2:E<-t.MathUtils.PI&&(E+=t.MathUtils.PI2),E*=e;var T=Math.cos(E),b=Math.sin(E);m.a=T*y-b*x,m.b=T*v-b*C,m.c=b*y+T*x,m.d=b*v+T*C,g=!0}if(0!=i){var A=this.temp;s.localToWorld(A.set(this.data.offsetX,this.data.offsetY)),m.worldX+=(A.x-m.worldX)*i,m.worldY+=(A.y-m.worldY)*i,g=!0}if(n>0){var S=Math.sqrt(m.a*m.a+m.c*m.c),w=Math.sqrt(o*o+c*c);S>1e-5&&(S=(S+(w-S+this.data.offsetScaleX)*n)/S),m.a*=S,m.c*=S,S=Math.sqrt(m.b*m.b+m.d*m.d),w=Math.sqrt(a*a+h*h),S>1e-5&&(S=(S+(w-S+this.data.offsetScaleY)*n)/S),m.b*=S,m.d*=S,g=!0}if(r>0){v=m.b,C=m.d;var E,I=Math.atan2(C,v);(E=Math.atan2(h,a)-Math.atan2(c,o)-(I-Math.atan2(m.c,m.a)))>t.MathUtils.PI?E-=t.MathUtils.PI2:E<-t.MathUtils.PI&&(E+=t.MathUtils.PI2),E=I+(E+_)*r;S=Math.sqrt(v*v+C*C);m.b=Math.cos(E)*S,m.d=Math.sin(E)*S,g=!0}g&&(m.appliedValid=!1)}},e.prototype.getOrder=function(){return this.data.order},e})();t.TransformConstraint=e})(r||(r={}));(function(t){var e=(function(){return function(t){if(this.order=0,this.bones=new Array,this.rotateMix=0,this.translateMix=0,this.scaleMix=0,this.shearMix=0,this.offsetRotation=0,this.offsetX=0,this.offsetY=0,this.offsetScaleX=0,this.offsetScaleY=0,this.offsetShearY=0,null==t)throw new Error("name cannot be null.");this.name=t}})();t.TransformConstraintData=e})(r||(r={}));var r;(function(t){var e=(function(){function t(){this.array=new Array}return t.prototype.add=function(t){var e=this.contains(t);return this.array[0|t]=0|t,!e},t.prototype.contains=function(t){return void 0!=this.array[0|t]},t.prototype.remove=function(t){this.array[0|t]=void 0},t.prototype.clear=function(){this.array.length=0},t})();t.IntSet=e;var i=(function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.r=t,this.g=e,this.b=i,this.a=n}return t.prototype.set=function(t,e,i,n){return this.r=t,this.g=e,this.b=i,this.a=n,this.clamp(),this},t.prototype.setFromColor=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this},t.prototype.setFromString=function(t){return t="#"==t.charAt(0)?t.substr(1):t,this.r=parseInt(t.substr(0,2),16)/255,this.g=parseInt(t.substr(2,2),16)/255,this.b=parseInt(t.substr(4,2),16)/255,this.a=(8!=t.length?255:parseInt(t.substr(6,2),16))/255,this},t.prototype.add=function(t,e,i,n){return this.r+=t,this.g+=e,this.b+=i,this.a+=n,this.clamp(),this},t.prototype.clamp=function(){return this.r<0?this.r=0:this.r>1&&(this.r=1),this.g<0?this.g=0:this.g>1&&(this.g=1),this.b<0?this.b=0:this.b>1&&(this.b=1),this.a<0?this.a=0:this.a>1&&(this.a=1),this},t.WHITE=new t(1,1,1,1),t.RED=new t(1,0,0,1),t.GREEN=new t(0,1,0,1),t.BLUE=new t(0,0,1,1),t.MAGENTA=new t(1,0,1,1),t})();t.Color=i;var n=(function(){function t(){}return t.clamp=function(t,e,i){return ti?i:t},t.cosDeg=function(e){return Math.cos(e*t.degRad)},t.sinDeg=function(e){return Math.sin(e*t.degRad)},t.signum=function(t){return t>0?1:t<0?-1:0},t.toInt=function(t){return t>0?Math.floor(t):Math.ceil(t)},t.cbrt=function(t){var e=Math.pow(Math.abs(t),1/3);return t<0?-e:e},t.PI=3.1415927,t.PI2=2*t.PI,t.radiansToDegrees=180/t.PI,t.radDeg=t.radiansToDegrees,t.degreesToRadians=t.PI/180,t.degRad=t.degreesToRadians,t})();t.MathUtils=n;var r=(function(){function t(){}return t.arrayCopy=function(t,e,i,n,r){for(var s=e,o=n;s=i?e:t.setArraySize(e,i,n)},t.newArray=function(t,e){for(var i=new Array(t),n=0;n0?this.items.pop():this.instantiator()},t.prototype.free=function(t){t.reset&&t.reset(),this.items.push(t)},t.prototype.freeAll=function(t){for(var e=0;ethis.maxDelta&&(this.delta=this.maxDelta),this.lastTime=t,this.frameCount++,this.frameTime>1&&(this.framesPerSecond=this.frameCount/this.frameTime,this.frameTime=0,this.frameCount=0)},t})();t.TimeKeeper=c})(r||(r={})),e.exports=r}),{}],310:[(function(t,e,i){(function(){"use strict";function t(t){t||console.log("Assertion failed! Pls debug.")}function i(t,e,i){this.major=t,this.minor=e,this.revision=i}function n(t){return isFinite(t)&&!isNaN(t)}function r(t,e){void 0!==t?(this.x=t,this.y=e):this.x=this.y=0}function s(t,e,i){void 0!==t&&(this.x=t,this.y=e,this.z=i)}function o(t,e){this.ex=t?t.Clone():new r,this.ey=e?e.Clone():new r}function a(t,e,i){this.ex=t?t.Clone():new s,this.ey=e?e.Clone():new s,this.ez=i?i.Clone():new s}function c(t,e){void 0!==e?(this.s=t,this.c=e):void 0!==t&&this.Set(t)}function h(t,e){this.p=new r,this.q=new c,t&&(this.p.Assign(t),this.q.Assign(e))}function l(){this.localCenter=new r,this.c0=new r,this.c=new r}function u(t,e){return t.x*e.x+t.y*e.y}function _(t,e){return t.x*e.y-t.y*e.x}function d(t,e){return new r(e*t.y,-e*t.x)}function f(t,e){return new r(-t*e.y,t*e.x)}function p(t,e){return new r(t.ex.x*e.x+t.ey.x*e.y,t.ex.y*e.x+t.ey.y*e.y)}function m(t,e){return r.Subtract(t,e).Length()}function g(t,e){var i=r.Subtract(t,e);return u(i,i)}function y(t,e){return t.x*e.x+t.y*e.y+t.z*e.z}function v(t,e){return new s(t.y*e.z-t.z*e.y,t.z*e.x-t.x*e.z,t.x*e.y-t.y*e.x)}function x(t,e){return s.Add(s.Add(s.Multiply(e.x,t.ex),s.Multiply(e.y,t.ey)),s.Multiply(e.z,t.ez))}function C(t,e){return new r(t.ex.x*e.x+t.ey.x*e.y,t.ex.y*e.x+t.ey.y*e.y)}function T(t,e){var i=new c;return i.s=t.s*e.c+t.c*e.s,i.c=t.c*e.c-t.s*e.s,i}function b(t,e){var i=new c;return i.s=t.c*e.s-t.s*e.c,i.c=t.c*e.c+t.s*e.s,i}function A(t,e){return new r(t.c*e.x-t.s*e.y,t.s*e.x+t.c*e.y)}function S(t,e){return new r(t.c*e.x+t.s*e.y,-t.s*e.x+t.c*e.y)}function w(t,e){return new r(t.q.c*e.x-t.q.s*e.y+t.p.x,t.q.s*e.x+t.q.c*e.y+t.p.y)}function E(t,e){var i=e.x-t.p.x,n=e.y-t.p.y;return new r(t.q.c*i+t.q.s*n,-t.q.s*i+t.q.c*n)}function I(t,e){var i=new h;i.q=b(t.q,e.q);var n=e.p.x-t.p.x,r=e.p.y-t.p.y;return i.p.x=t.q.c*n+t.q.s*r,i.p.y=-t.q.s*n+t.q.c*r,i}function R(t){return new r(ri(t.x),ri(t.y))}function P(t,e){return new r(si(t.x,e.x),si(t.y,e.y))}function O(t,e){return new r(oi(t.x,e.x),oi(t.y,e.y))}function B(t,e,i){return oi(e,si(t,i))}function D(t,e,i){this.r=t||0,this.g=e||0,this.b=i||0}function M(){}function L(){this.Reset()}function N(){this.mass=0,this.center=new r,this.I=0}function F(){this.m_type=0,this.m_radius=0}function k(){this.parent.call(this),this.m_type=F.e_circle,this.m_radius=0,this.m_p=new r,Object.seal(this)}function z(){this.parent.call(this),this.m_type=F.e_edge,this.m_radius=Xe,this.m_vertex0=new r,this.m_vertex1=new r,this.m_vertex2=new r,this.m_vertex3=new r,this.m_hasVertex0=!1,this.m_hasVertex3=!1,Object.seal(this)}function V(){this.parent.call(this),this.m_type=F.e_chain,this.m_radius=Xe,this.m_prevVertex=new r,this.m_nextVertex=new r,this.m_hasPrevVertex=!1,this.m_hasNextVertex=!1,this.Clear(),Object.seal(this)}function G(){this.parent.call(this),this.m_type=F.e_polygon,this.m_radius=Xe,this.m_count=0,this.m_centroid=new r,this.m_vertices=new Array(We),this.m_normals=new Array(We),Object.seal(this)}function W(){this.proxyIdA=0,this.proxyIdB=0}function U(t,e){return t.proxyIdA==e.proxyIdA?t.proxyIdB-e.proxyIdB:t.proxyIdA-e.proxyIdA}function j(){this.m_tree=new Ct,this.m_queryProxyId=0,this.m_proxyCount=0,this.m_pairCount=0,this.m_pairBuffer=[],this.m_moveCount=0,this.m_moveBuffer=[]}function X(){this.m_vertices=null,this.m_count=0,this.m_radius=0}function Y(){this.metric=0,this.count=0,this.indexA=[0,0,0],this.indexB=[0,0,0]}function H(){this.proxyA=new X,this.proxyB=new X,this.transformA=new h,this.transformB=new h,this.useRadii=!1}function q(){this.pointA=new r,this.pointB=new r,this.distance=0,this.iterations=0}function J(){this.wA=new r,this.wB=new r,this.w=new r,this.a=0,this.indexA=0,this.indexB=0}function Z(){this.m_v=[new J,new J,new J],this.m_count=0}function Q(e,i,n){++Q.b2_gjkCalls;var r=n.proxyA,s=n.proxyB,o=n.transformA,a=n.transformB;ai.ReadCache(i,r,o,s,a);for(var c=ai.m_v,h=[0,0,0],l=[0,0,0],u=0,_=ke,d=_,f=0;f<20;){u=ai.m_count;for(var p=0;pC+T&&e.distance>ze)e.distance-=C+T,ci.x=e.pointB.x-e.pointA.x,ci.y=e.pointB.y-e.pointA.y,ci.Normalize(),e.pointA.x+=C*ci.x,e.pointA.y+=C*ci.y,e.pointB.x-=T*ci.x,e.pointB.y-=T*ci.y;else{var b=.5*(e.pointA.x+e.pointB.x),A=.5*(e.pointA.y+e.pointB.y);e.pointA.x=b,e.pointA.y=A,e.pointB.x=b,e.pointB.y=A,e.distance=0}}}function K(){}function $(){this.localPoint=new r,this.normalImpulse=0,this.tangentImpulse=0,this.id=new K}function tt(){this.points=new Array(Ge),this.localNormal=new r,this.localPoint=new r,this.type=0,this.pointCount=0}function et(){this.normal=new r,this.points=new Array(Ge),this.separations=new Array(Ge)}function it(){this.v=new r,this.id=new K}function nt(){this.p1=new r,this.p2=new r,this.maxFraction=0}function rt(){this.normal=new r,this.fraction=0}function st(){this.lowerBound=new r,this.upperBound=new r}function ot(t,e,i,n,r){t.pointCount=0;var s=w(i,e.m_p),o=w(r,n.m_p),a=o.x-s.x,c=o.y-s.y,h=a*a+c*c,l=e.m_radius+n.m_radius;h>l*l||(t.type=tt.e_circles,t.localPoint.x=e.m_p.x,t.localPoint.y=e.m_p.y,t.localNormal.x=t.localNormal.y=0,t.pointCount=1,t.points[0]=new $,t.points[0].localPoint.x=n.m_p.x,t.points[0].localPoint.y=n.m_p.y,t.points[0].id.Reset())}function at(t,e,i,n,r){t.pointCount=0;for(var s=E(i,w(r,n.m_p)),o=0,a=-ke,c=e.m_radius+n.m_radius,h=e.m_count,l=e.m_vertices,u=e.m_normals,_=0;_c)return;d>a&&(a=d,o=_)}var f=o,p=f+1c*c)return;t.pointCount=1,t.type=tt.e_faceA,t.localNormal.x=s.x-m.x,t.localNormal.y=s.y-m.y,t.localNormal.Normalize(),t.localPoint.x=m.x,t.localPoint.y=m.y,t.points[0]=new $,t.points[0].localPoint.x=n.m_p.x,t.points[0].localPoint.y=n.m_p.y,t.points[0].id.Reset()}else if(x<=0){if(g(s,y)>c*c)return;t.pointCount=1,t.type=tt.e_faceA,t.localNormal.x=s.x-y.x,t.localNormal.y=s.y-y.y,t.localNormal.Normalize(),t.localPoint.x=y.x,t.localPoint.y=y.y,t.points[0]=new $,t.points[0].localPoint.x=n.m_p.x,t.points[0].localPoint.y=n.m_p.y,t.points[0].id.Reset()}else{var C=.5*(m.x+y.x),T=.5*(m.y+y.y);if((a=(s.x-C)*u[f].x+(s.y-T)*u[f].y)>c)return;t.pointCount=1,t.type=tt.e_faceA,t.localNormal.x=u[f].x,t.localNormal.y=u[f].y,t.localPoint.x=C,t.localPoint.y=T,t.points[0]=new $,t.points[0].localPoint.x=n.m_p.x,t.points[0].localPoint.y=n.m_p.y,t.points[0].id.Reset()}}function ct(t,e,i,n,r){for(var s=e.m_count,o=n.m_count,a=e.m_normals,c=e.m_vertices,h=n.m_vertices,l=I(r,i),u=0,_=-ke,d=0;d_&&(_=y,u=d)}return t[0]=u,_}function ht(e,i,n,r,s,o){var a=i.m_normals,c=s.m_count,h=s.m_vertices,l=s.m_normals;t(0<=r&&rs)){var c=[0],h=ct(c,n,r,e,i);if(!(h>s)){var l,u,_,d,f=0,p=0;h>a+.1*Ue?(l=n,u=e,_=r,d=i,f=c[0],t.type=tt.e_faceB,p=1):(l=e,u=n,_=i,d=r,f=o[0],t.type=tt.e_faceA,p=0),ht(lt._local_incidentEdges,l,_,f,u,d);var m=l.m_count,g=l.m_vertices,y=f,v=f+1d*d)return;if(i.m_hasVertex0){var m=i.m_vertex0,g=a,y=g.x-m.x,v=g.y-m.y;if(y*(g.x-o.x)+v*(g.y-o.y)>0)return}return f.indexA=0,f.typeA=K.e_vertex,e.pointCount=1,e.type=tt.e_circles,e.localNormal.x=e.localNormal.y=0,e.localPoint.x=p.x,e.localPoint.y=p.y,e.points[0]=new $,e.points[0].id.Assign(f),e.points[0].localPoint.x=r.m_p.x,void(e.points[0].localPoint.y=r.m_p.y)}if(u<=0){p=c;if((S=o.x-p.x)*S+(I=o.y-p.y)*I>d*d)return;if(i.m_hasVertex3){var x=i.m_vertex3,C=c,T=x.x-C.x,b=x.y-C.y;if(T*(o.x-C.x)+b*(o.y-C.y)>0)return}return f.indexA=1,f.typeA=K.e_vertex,e.pointCount=1,e.type=tt.e_circles,e.localNormal.x=e.localNormal.y=0,e.localPoint.x=p.x,e.localPoint.y=p.y,e.points[0]=new $,e.points[0].id.Assign(f),e.points[0].localPoint.x=r.m_p.x,void(e.points[0].localPoint.y=r.m_p.y)}var A=h*h+l*l;t(A>0);var S,I,R=1/A*(u*a.x+_*c.x),P=1/A*(u*a.y+_*c.y);if(!((S=o.x-R)*S+(I=o.y-P)*I>d*d)){var O=-l,B=h;O*(o.x-a.x)+B*(o.y-a.y)<0&&(O=-O,B=-B),f.indexA=0,f.typeA=K.e_face,e.pointCount=1,e.type=tt.e_faceA,e.localNormal.x=O,e.localNormal.y=B,e.localNormal.Normalize(),e.localPoint.x=a.x,e.localPoint.y=a.y,e.points[0]=new $,e.points[0].id.Assign(f),e.points[0].localPoint.x=r.m_p.x,e.points[0].localPoint.y=r.m_p.y}}function _t(){this.type=0,this.index=0,this.separation=0}function dt(){this.vertices=new Array(We),this.normals=new Array(We),this.count=0}function ft(){this.i1=0,this.i2=0,this.v1=new r,this.v2=new r,this.normal=new r,this.sideNormal1=new r,this.sideOffset1=0,this.sideNormal2=new r,this.sideOffset2=0}function pt(){this.m_polygonB=new dt,this.m_xf=new h,this.m_centroidB=new r,this.m_v0=new r,this.m_v1=new r,this.m_v2=new r,this.m_v3=new r,this.m_normal0=new r,this.m_normal1=new r,this.m_normal2=new r,this.m_normal=new r,this.m_type1=0,this.m_type2=0,this.m_lowerLimit=new r,this.m_upperLimit=new r,this.m_radius=0,this.m_front=!1}function mt(t,e,i,n,r){mt.collider.Collide(t,e,i,n,r)}function gt(t,e,i,n,r,s){var o=0,a=i*e[0].v.x+n*e[0].v.y-r,c=i*e[1].v.x+n*e[1].v.y-r;if(a<=0&&(t[o++]=e[0]),c<=0&&(t[o++]=e[1]),a*c<0){var h=a/(a-c);t[o]=new it,t[o].v.x=e[0].v.x+h*(e[1].v.x-e[0].v.x),t[o].v.y=e[0].v.y+h*(e[1].v.y-e[0].v.y),t[o].id.indexA=s,t[o].id.indexB=e[0].id.indexB,t[o].id.typeA=K.e_vertex,t[o].id.typeB=K.e_face,++o}return o}function yt(t,e,i,n,r,s){return yt.input.proxyA.Set(t,e),yt.input.proxyB.Set(i,n),yt.input.transformA=r,yt.input.transformB=s,yt.input.useRadii=!0,yt.cache.count=0,Q(yt.output,yt.cache,yt.input),yt.output.distance<10*ze}function vt(t,e){return!(e.lowerBound.x-t.upperBound.x>0||e.lowerBound.y-t.upperBound.y>0||t.lowerBound.x-e.upperBound.x>0||t.lowerBound.y-e.upperBound.y>0)}function xt(){this.aabb=new st,this.userData=null,this.parent=0,this.child1=this.child2=this.height=0}function Ct(){this.m_root=li,this.m_nodeCapacity=16,this.m_nodeCount=0,this.m_nodes=new Array(this.m_nodeCapacity);for(var t=0;tc);var h=0,l=0,u=new Y;u.count=0;var _=new H;for(_.proxyA.Assign(i.proxyA),_.proxyB.Assign(i.proxyB),_.useRadii=!1;;){St._temp_sweepA.GetTransform(_.transformA,h),St._temp_sweepB.GetTransform(_.transformB,h);var d=new q;if(Q(d,u,_),d.distance<=0){e.state=bt.e_overlapped,e.t=0;break}if(d.distancea+c){e.state=bt.e_separated,e.t=s,p=!0;break}if(v>a-c){h=m;break}var x=f.Evaluate(y[0],y[1],h);if(xa?(T=A,x=S):(b=A,v=S),50==C)break}if(St.b2_toiMaxRootIters=oi(St.b2_toiMaxRootIters,C),++g==We)break}if(++l,++St.b2_toiIters,p)break;if(20==l){e.state=bt.e_failed,e.t=h;break}}St.b2_toiMaxIters=oi(St.b2_toiMaxIters,l),di.stop(),St.b2_toiMaxTime=oi(St.b2_toiMaxTime,di.elapsedTime),St.b2_toiTime+=di.elapsedTime}function wt(){this.type=Et.b2_staticBody,this.position=new r(0,0),this.angle=0,this.linearVelocity=new r(0,0),this.angularVelocity=0,this.linearDamping=0,this.angularDamping=0,this.allowSleep=!0,this.awake=!0,this.fixedRotation=!1,this.bullet=!1,this.active=!0,this.userData=null,this.gravityScale=1,Object.seal(this)}function Et(e,i){t(e.position.IsValid()),t(e.linearVelocity.IsValid()),t(n(e.angle)),t(n(e.angularVelocity)),t(n(e.angularDamping)&&e.angularDamping>=0),t(n(e.linearDamping)&&e.linearDamping>=0),this.m_islandIndex=0,this.m_flags=0,e.bullet&&(this.m_flags|=Et.e_bulletFlag),e.fixedRotation&&(this.m_flags|=Et.e_fixedRotationFlag),e.allowSleep&&(this.m_flags|=Et.e_autoSleepFlag),e.awake&&(this.m_flags|=Et.e_awakeFlag),e.active&&(this.m_flags|=Et.e_activeFlag),this.m_world=i,this.m_xf=new h,this.m_xf.p.Assign(e.position),this.m_xf.q.Set(e.angle),this.m_sweep=new l,this.m_sweep.localCenter.SetZero(),this.m_sweep.c0.Assign(this.m_xf.p),this.m_sweep.c.Assign(this.m_xf.p),this.m_sweep.a0=e.angle,this.m_sweep.a=e.angle,this.m_sweep.alpha0=0,this.m_jointList=null,this.m_contactList=null,this.m_prev=null,this.m_next=null,this.m_linearVelocity=e.linearVelocity.Clone(),this.m_angularVelocity=e.angularVelocity,this.m_linearDamping=e.linearDamping,this.m_angularDamping=e.angularDamping,this.m_gravityScale=e.gravityScale,this.m_force=new r,this.m_torque=0,this.m_sleepTime=0,this.m_type=e.type,this.m_type==Et.b2_dynamicBody?(this.m_mass=1,this.m_invMass=1):(this.m_mass=0,this.m_invMass=0),this.m_I=0,this.m_invI=0,this.m_userData=e.userData,this.m_fixtureList=null,this.m_fixtureCount=0}function It(){this.categoryBits=1,this.maskBits=65535,this.groupIndex=0}function Rt(){this.shape=null,this.userData=null,this.friction=.2,this.restitution=0,this.density=0,this.isSensor=!1,this.filter=new It,Object.seal(this)}function Pt(){this.aabb=new st,this.fixture=null,this.childIndex=0,this.proxyId=0}function Ot(){this.m_userData=null,this.m_body=null,this.m_next=null,this.m_proxies=null,this.m_proxyCount=0,this.m_shape=null,this.m_density=0,this.m_filter=new It,this.m_isSensor=!1,this.m_friction=0,this.m_restitution=0}function Bt(){}function Dt(){}function Mt(){this.normalImpulses=new Array(Ge),this.tangentImpulses=new Array(Ge),this.count=0}function Lt(){}function Nt(){}function Ft(){}function kt(){this.dt=0,this.inv_dt=0,this.dtRatio=0,this.velocityIterations=0,this.positionIterations=0,this.warmStarting=!1}function zt(){this.c=new r,this.a=0}function Vt(){this.v=new r,this.w=0}function Gt(){this.step=new kt,this.positions=null,this.velocities=null}function Wt(t){this.m_contactManager=new ne,this.m_destructionListener=null,this.g_debugDraw=null,this.m_bodyList=null,this.m_jointList=null,this.m_bodyCount=0,this.m_jointCount=0,this.m_warmStarting=!0,this.m_continuousPhysics=!0,this.m_subStepping=!1,this.m_stepComplete=!0,this.m_allowSleep=!0,this.m_gravity=t,this.m_flags=Wt.e_clearForces,this.m_inv_dt0=0,this.p_step=new kt,this.p_island=new le}function Ut(){this.broadPhase=null,this.callback=null}function jt(){this.broadPhase=null,this.callback=null}function Xt(t,e){return ii(t*e)}function Yt(t,e){return t>e?t:e}function Ht(){this.fcn=null,this.primary=!1}function qt(){this.other=null,this.contact=null,this.prev=null,this.next=null}function Jt(){this.m_nodeA=new qt,this.m_nodeB=new qt,this.m_manifold=new tt}function Zt(){this.parent.call(this)}function Qt(){this.parent.call(this)}function Kt(){this.parent.call(this)}function $t(){this.parent.call(this)}function te(){this.parent.call(this)}function ee(){this.parent.call(this)}function ie(){this.parent.call(this)}function ne(){this.m_broadPhase=new j,this.m_contactList=null,this.m_contactCount=0,this.m_contactFilter=xi,this.m_contactListener=Ci}function re(){this.rA=new r,this.rB=new r,this.normalImpulse=0,this.tangentImpulse=0,this.normalMass=0,this.tangentMass=0,this.velocityBias=0}function se(){this.localPoints=new Array(Ge),this.localNormal=new r,this.localPoint=new r,this.indexA=0,this.indexB=0,this.invMassA=0,this.invMassB=0,this.localCenterA=new r,this.localCenterB=new r,this.invIA=0,this.invIB=0,this.type=0,this.radiusA=0,this.radiusB=0,this.pointCount=0}function oe(){this.points=new Array(Ge);for(var t=0;t=0),t(n(e.frequencyHz)&&e.frequencyHz>=0),t(n(e.dampingRatio)&&e.dampingRatio>=0),this.m_targetA=e.target.Clone(),this.m_localAnchorB=E(this.m_bodyB.GetTransform(),this.m_targetA),this.m_maxForce=e.maxForce,this.m_impulse=new r,this.m_frequencyHz=e.frequencyHz,this.m_dampingRatio=e.dampingRatio,this.m_beta=0,this.m_gamma=0,this.m_indexA=0,this.m_indexB=0,this.m_rB=new r,this.m_localCenterB=new r,this.m_invMassB=0,this.m_invIB=0,this.m_mass=new o,this.m_C=new r}function ye(){this.parent.call(this),this.type=de.e_distanceJoint,this.localAnchorA=new r(0,0),this.localAnchorB=new r(0,0),this.length=1,this.frequencyHz=0,this.dampingRatio=0,Object.seal(this)}function ve(t){this.parent.call(this,t),this.m_localAnchorA=t.localAnchorA.Clone(),this.m_localAnchorB=t.localAnchorB.Clone(),this.m_length=t.length,this.m_frequencyHz=t.frequencyHz,this.m_dampingRatio=t.dampingRatio,this.m_impulse=0,this.m_gamma=0,this.m_bias=0,this.m_indexA=0,this.m_indexB=0,this.m_u=new r,this.m_rA=new r,this.m_rB=new r,this.m_localCenterA=new r,this.m_localCenterB=new r,this.m_invMassA=0,this.m_invMassB=0,this.m_invIA=0,this.m_invIB=0,this.m_mass=0}function xe(){this.parent.call(this),this.type=de.e_prismaticJoint,this.localAnchorA=new r,this.localAnchorB=new r,this.localAxisA=new r(1,0),this.referenceAngle=0,this.enableLimit=!1,this.lowerTranslation=0,this.upperTranslation=0,this.enableMotor=!1,this.maxMotorForce=0,this.motorSpeed=0,Object.seal(this)}function Ce(t){this.parent.call(this,t),this.m_localAnchorA=t.localAnchorA.Clone(),this.m_localAnchorB=t.localAnchorB.Clone(),this.m_localXAxisA=t.localAxisA.Clone(),this.m_localXAxisA.Normalize(),this.m_localYAxisA=f(1,this.m_localXAxisA),this.m_referenceAngle=t.referenceAngle,this.m_impulse=new s,this.m_motorMass=0,this.m_motorImpulse=0,this.m_lowerTranslation=t.lowerTranslation,this.m_upperTranslation=t.upperTranslation,this.m_maxMotorForce=t.maxMotorForce,this.m_motorSpeed=t.motorSpeed,this.m_enableLimit=t.enableLimit,this.m_enableMotor=t.enableMotor,this.m_limitState=de.e_inactiveLimit,this.m_axis=new r,this.m_perp=new r,this.m_indexA=0,this.m_indexB=0,this.m_localCenterA=new r,this.m_localCenterB=new r,this.m_invMassA=0,this.m_invMassB=0,this.m_invIA=0,this.m_invIB=0,this.m_s1=0,this.m_s2=0,this.m_a1=0,this.m_a2=0,this.m_K=new a,this.m_motorMass=0}function Te(){this.parent.call(this),this.type=de.e_frictionJoint,this.localAnchorA=new r,this.localAnchorB=new r,this.maxForce=0,this.maxTorque=0,Object.seal(this)}function be(t){this.parent.call(this,t),this.m_localAnchorA=t.localAnchorA.Clone(),this.m_localAnchorB=t.localAnchorB.Clone(),this.m_linearImpulse=new r,this.m_angularImpulse=0,this.m_maxForce=t.maxForce,this.m_maxTorque=t.maxTorque,this.m_indexA=0,this.m_indexB=0,this.m_rA=new r,this.m_rB=new r,this.m_localCenterA=new r,this.m_localCenterB=new r,this.m_invMassA=0,this.m_invMassB=0,this.m_invIA=0,this.m_invIB=0,this.m_linearMass=new o,this.m_angularMass=0}function Ae(){this.parent.call(this),this.type=de.e_weldJoint,this.localAnchorA=new r(0,0),this.localAnchorB=new r(0,0),this.referenceAngle=0,this.frequencyHz=0,this.dampingRatio=0,Object.seal(this)}function Se(t){this.parent.call(this,t),this.m_bias=0,this.m_gamma=0,this.m_indexA=0,this.m_indexB=0,this.m_rA=new r,this.m_rB=new r,this.m_localCenterA=new r,this.m_localCenterB=new r,this.m_invMassA=0,this.m_invMassB=0,this.m_invIA=0,this.m_invIB=0,this.m_mass=new a,this.m_localAnchorA=t.localAnchorA.Clone(),this.m_localAnchorB=t.localAnchorB.Clone(),this.m_referenceAngle=t.referenceAngle,this.m_frequencyHz=t.frequencyHz,this.m_dampingRatio=t.dampingRatio,this.m_impulse=new s}function we(){this.parent.call(this),this.type=de.e_wheelJoint,this.localAnchorA=new r,this.localAnchorB=new r,this.localAxisA=new r(1,0),this.enableMotor=!1,this.maxMotorTorque=0,this.motorSpeed=0,this.frequencyHz=2,this.dampingRatio=.7,Object.seal(this)}function Ee(t){this.parent.call(this,t),this.m_indexA=0,this.m_indexB=0,this.m_localCenterA=new r,this.m_localCenterB=new r,this.m_invMassA=0,this.m_invMassB=0,this.m_invIA=0,this.m_invIB=0,this.m_localAnchorA=t.localAnchorA.Clone(),this.m_localAnchorB=t.localAnchorB.Clone(),this.m_localXAxisA=t.localAxisA.Clone(),this.m_localYAxisA=f(1,this.m_localXAxisA),this.m_mass=0,this.m_impulse=0,this.m_motorMass=0,this.m_motorImpulse=0,this.m_springMass=0,this.m_springImpulse=0,this.m_maxMotorTorque=t.maxMotorTorque,this.m_motorSpeed=t.motorSpeed,this.m_enableMotor=t.enableMotor,this.m_frequencyHz=t.frequencyHz,this.m_dampingRatio=t.dampingRatio,this.m_bias=0,this.m_gamma=0,this.m_ax=new r,this.m_ay=new r,this.m_sAx=this.m_sBx=0,this.m_sAy=this.m_sBy=0}function Ie(){this.parent.call(this),this.type=de.e_gearJoint,this.joint1=null,this.joint2=null,this.ratio=1,Object.seal(this)}function Re(e){this.parent.call(this,e),this.m_joint1=e.joint1,this.m_joint2=e.joint2,this.m_typeA=this.m_joint1.GetType(),this.m_typeB=this.m_joint2.GetType(),t(this.m_typeA==de.e_revoluteJoint||this.m_typeA==de.e_prismaticJoint),t(this.m_typeB==de.e_revoluteJoint||this.m_typeB==de.e_prismaticJoint);var i,n;this.m_bodyC=this.m_joint1.GetBodyA(),this.m_bodyA=this.m_joint1.GetBodyB();var s=this.m_bodyA.m_xf,o=this.m_bodyA.m_sweep.a,a=this.m_bodyC.m_xf,c=this.m_bodyC.m_sweep.a;if(this.m_localAnchorA=new r,this.m_localAnchorB=new r,this.m_localAnchorC=new r,this.m_localAnchorD=new r,this.m_localAxisC=new r,this.m_localAxisD=new r,this.m_typeA==de.e_revoluteJoint){var h=e.joint1;this.m_localAnchorC.Assign(h.m_localAnchorA),this.m_localAnchorA.Assign(h.m_localAnchorB),this.m_referenceAngleA=h.m_referenceAngle,this.m_localAxisC.SetZero(),i=o-c-this.m_referenceAngleA}else{var l=e.joint1;this.m_localAnchorC.Assign(l.m_localAnchorA),this.m_localAnchorA.Assign(l.m_localAnchorB),this.m_referenceAngleA=l.m_referenceAngle,this.m_localAxisC.Assign(l.m_localXAxisA);var _=this.m_localAnchorC,d=S(a.q,r.Add(A(s.q,this.m_localAnchorA),r.Subtract(s.p,a.p)));i=u(r.Subtract(d,_),this.m_localAxisC)}this.m_bodyD=this.m_joint2.GetBodyA(),this.m_bodyB=this.m_joint2.GetBodyB();var f=this.m_bodyB.m_xf,p=this.m_bodyB.m_sweep.a,m=this.m_bodyD.m_xf,g=this.m_bodyD.m_sweep.a;if(this.m_typeB==de.e_revoluteJoint){h=e.joint2;this.m_localAnchorD.Assign(h.m_localAnchorA),this.m_localAnchorB.Assign(h.m_localAnchorB),this.m_referenceAngleB=h.m_referenceAngle,this.m_localAxisD.SetZero(),n=p-g-this.m_referenceAngleB}else{l=e.joint2;this.m_localAnchorD.Assign(l.m_localAnchorA),this.m_localAnchorB.Assign(l.m_localAnchorB),this.m_referenceAngleB=l.m_referenceAngle,this.m_localAxisD.Assign(l.m_localXAxisA);var y=this.m_localAnchorD,v=S(m.q,r.Add(A(f.q,this.m_localAnchorB),r.Subtract(f.p,m.p)));n=u(r.Subtract(v,y),this.m_localAxisD)}this.m_ratio=e.ratio,this.m_constant=i+this.m_ratio*n,this.m_impulse=0,this.m_indexA=this.m_indexB=this.m_indexC=this.m_indexD=0,this.m_lcA=new r,this.m_lcB=new r,this.m_lcC=new r,this.m_lcD=new r,this.m_mA=this.m_mB=this.m_mC=this.m_mD=0,this.m_iA=this.m_iB=this.m_iC=this.m_iD=0,this.m_JvAC=new r,this.m_JvBD=new r,this.m_JwA=this.m_JwB=this.m_JwC=this.m_JwD=0,this.m_mass=0}function Pe(){this.parent.call(this),this.type=de.e_motorJoint,this.linearOffset=new r,this.angularOffset=0,this.maxForce=1,this.maxTorque=1,this.correctionFactor=.3,Object.seal(this)}function Oe(t){this.parent.call(this,t),this.m_linearOffset=t.linearOffset.Clone(),this.m_angularOffset=t.angularOffset,this.m_linearImpulse=new r,this.m_angularImpulse=0,this.m_maxForce=t.maxForce,this.m_maxTorque=t.maxTorque,this.m_correctionFactor=t.correctionFactor,this.m_indexA=0,this.m_indexB=0,this.m_rA=new r,this.m_rB=new r,this.m_localCenterA=new r,this.m_localCenterB=new r,this.m_linearError=new r,this.m_angularError=0,this.m_invMassA=0,this.m_invMassB=0,this.m_invIA=0,this.m_invIB=0,this.m_linearMass=new o,this.m_angularMass=0}function Be(){this.parent.call(this),this.type=de.e_pulleyJoint,this.groundAnchorA=new r(-1,1),this.groundAnchorB=new r(1,1),this.localAnchorA=new r(-1,0),this.localAnchorB=new r(1,0),this.lengthA=0,this.lengthB=0,this.ratio=1,this.collideConnected=!0,Object.seal(this)}function De(e){this.parent.call(this,e),this.m_indexA=0,this.m_indexB=0,this.m_uA=new r,this.m_uB=new r,this.m_rA=new r,this.m_rB=new r,this.m_localCenterA=new r,this.m_localCenterB=new r,this.m_invMassA=0,this.m_invMassB=0,this.m_invIA=0,this.m_invIB=0,this.m_mass=0,this.m_groundAnchorA=e.groundAnchorA.Clone(),this.m_groundAnchorB=e.groundAnchorB.Clone(),this.m_localAnchorA=e.localAnchorA.Clone(),this.m_localAnchorB=e.localAnchorB.Clone(),this.m_lengthA=e.lengthA,this.m_lengthB=e.lengthB,t(0!=e.ratio),this.m_ratio=e.ratio,this.m_constant=e.lengthA+this.m_ratio*e.lengthB,this.m_impulse=0}function Me(){this.parent.call(this),this.type=de.e_ropeJoint,this.localAnchorA=new r(-1,0),this.localAnchorB=new r(1,0),this.maxLength=0,Object.seal(this)}function Le(t){this.parent.call(this,t),this.m_localAnchorA=t.localAnchorA.Clone(),this.m_localAnchorB=t.localAnchorB.Clone(),this.m_maxLength=t.maxLength,this.m_mass=0,this.m_impulse=0,this.m_state=de.e_inactiveLimit,this.m_length=0,this.m_indexA=0,this.m_indexB=0,this.m_u=new r,this.m_rA=new r,this.m_rB=new r,this.m_localCenterA=new r,this.m_localCenterB=new r,this.m_invMassA=0,this.m_invMassB=0,this.m_invIA=0,this.m_invIB=0}function Ne(){this.m_count=0,this.m_ps=null,this.m_p0s=null,this.m_vs=null,this.m_ims=null,this.m_Ls=null,this.m_as=null,this.m_damping=0,this.m_gravity=new r,this.m_k2=1,this.m_k3=.1}Function.prototype._extend=function(t){this.prototype.parent=t;for(var e in t.prototype)this.prototype[e]||(this.prototype[e]=t.prototype[e])},Function.prototype._implement=function(t){return this._extend(t)};var Fe=(function(){function t(t,e){this.name=t,this.parent=e,this.children={},this.startTime=0,this.elapsedTime=0,this.totalTime=0,this.running=!1,this.childrenCount=0}function e(t,i){if(t.name===i.parent)return t;for(var n in t.children){var r;if(r=e(t.children[n],i))return r}return null}"undefined"==typeof performance&&(window.performance={now:function(){return+new Date}}),t.prototype={start:function(){this.startTime=performance.now(),this.running=!0},stop:function(t){if(this.running){this.running=!1,this.elapsedTime+=performance.now()-this.startTime,t&&this.start();for(var e in this.children)this.children[e].stop()}},reset:function(t){t||(this.running=!0,this.totalTime+=this.elapsedTime,this.start()),this.elapsedTime=0;for(var e in this.children)this.children[e].reset(!0)}};var i=[],n=new t("root");return{create:function(e,n){if(!i)throw new Error("late profile creation not allowed");var r=new t(e,n||"root");return i.push(r),r},destroy:function(t){t.childrenCount--,delete t.children[t.name]},init:function(){for(;i.length;){var t=i.pop();(t.parentNode=e(n,t))?(t.parentNode.children[t.name]=t,t.parentNode.childrenCount++):i.unshift(t)}i=null},reset:function(){n.reset(!0)},profileRoot:n}})(),ke=Number.MAX_VALUE,ze=2.220446049250313e-16,Ve=Math.PI,Ge=2,We=8,Ue=.005,je=2/180*Ve,Xe=2*Ue,Ye=8/180*Ve,He=.5*Ve,qe=He*He,Je=2/180*Ve;i.prototype={toString:function(){return this.major+"."+this.minor+"."+this.revision}};var Ze=new i(2,3,1),Qe=Math.sqrt,Ke=Math.atan2,$e=Math.sin,ti=Math.cos,ei=Math.floor,ii=(Math.ceil,Qe),ni=Ke;r.prototype={Clone:function(){return new r(this.x,this.y)},SetZero:function(){return this.x=0,this.y=0,this},Set:function(t,e){return this.x=t,this.y=e,this},Assign:function(t){return this.x=t.x,this.y=t.y,this},Negate:function(){var t=new r;return t.Set(-this.x,-this.y),t},get_i:function(t){switch(t){case 0:return this.x;case 1:return this.y}},set_i:function(t,e){switch(t){case 0:return this.x=e;case 1:return this.y=e}},Add:function(t){return this.x+=t.x,this.y+=t.y,this},Subtract:function(t){return this.x-=t.x,this.y-=t.y,this},Multiply:function(t){return this.x*=t,this.y*=t,this},Length:function(){return ii(this.x*this.x+this.y*this.y)},LengthSquared:function(){return this.x*this.x+this.y*this.y},Normalize:function(){var t=this.Length();if(t0?A(i.q,_).Negate():A(i.q,_),!0)},ComputeAABB:function(t,e,i){var n=e.q.c*this.m_vertex1.x-e.q.s*this.m_vertex1.y+e.p.x,r=e.q.s*this.m_vertex1.x+e.q.c*this.m_vertex1.y+e.p.y,s=e.q.c*this.m_vertex2.x-e.q.s*this.m_vertex2.y+e.p.x,o=e.q.s*this.m_vertex2.x+e.q.c*this.m_vertex2.y+e.p.y,a=si(n,s),c=si(r,o),h=oi(n,s),l=oi(r,o);t.lowerBound.x=a-this.m_radius,t.lowerBound.y=c-this.m_radius,t.upperBound.x=h+this.m_radius,t.upperBound.y=l+this.m_radius},ComputeMass:function(t,e){t.mass=0,t.center=r.Multiply(.5,r.Add(this.m_vertex1,this.m_vertex2)),t.I=0},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.m_vertex1=this.m_vertex1._serialize(),e.m_vertex2=this.m_vertex2._serialize(),e.m_hasVertex0=this.m_hasVertex0,this.m_hasVertex0&&(e.m_vertex0=this.m_vertex0._serialize()),e.m_hasVertex3=this.m_hasVertex3,this.m_hasVertex3&&(e.m_vertex3=this.m_vertex3._serialize()),e},_deserialize:function(t){this.parent.prototype._deserialize.call(this,t),this.m_vertex1._deserialize(t.m_vertex1),this.m_vertex2._deserialize(t.m_vertex2),this.m_hasVertex0=t.m_hasVertex0,this.m_hasVertex0&&this.m_vertex0._deserialize(t.m_vertex0),this.m_hasVertex3=t.m_hasVertex3,this.m_hasVertex3&&this.m_vertex3._deserialize(t.m_vertex3)}},z._extend(F),V._tempEdge=new z,V.prototype={Clear:function(){this.m_vertices=null,this.m_count=0},CreateLoop:function(e,i){t(null==this.m_vertices&&0==this.m_count),t(i>=3);for(var n=1;nUe*Ue);this.m_count=i+1,this.m_vertices=new Array(this.m_count);for(n=0;n=2);for(var n=1;nUe*Ue)}this.m_count=i,this.m_vertices=new Array(i);for(n=0;n0?(e.m_vertex0=this.m_vertices[i-1],e.m_hasVertex0=!0):(e.m_vertex0=this.m_prevVertex,e.m_hasVertex0=this.m_hasPrevVertex),if||p==f&&s[a].yC.LengthSquared()&&(x=l)}else x=l;if(++y,v=x,x==u)break}if(y<3)return t(!1),void this.SetAsBox(1,1);for(this.m_count=y,a=0;aze*ze),this.m_normals[a]=d(S,1).Clone(),this.m_normals[a].Normalize()}this.m_centroid=G.ComputeCentroid(this.m_vertices,y)}},SetAsBox:function(t,e,i,n){if(this.m_count=4,this.m_vertices[0]=new r(-t,-e),this.m_vertices[1]=new r(t,-e),this.m_vertices[2]=new r(t,e),this.m_vertices[3]=new r(-t,e),this.m_normals[0]=new r(0,-1),this.m_normals[1]=new r(1,0),this.m_normals[2]=new r(0,1),this.m_normals[3]=new r(-1,0),i){this.m_centroid.Assign(i);var s=new h;s.p=i,s.q.Set(n);for(var o=0;o0)return!1}return!0},RayCast:function(e,i,n,s){for(var o=S(n.q,r.Subtract(i.p1,n.p)),a=S(n.q,r.Subtract(i.p2,n.p)),c=r.Subtract(a,o),h=0,l=i.maxFraction,_=-1,d=0;d0&&f=0&&(e.fraction=h,e.normal=A(n.q,this.m_normals[_]),!0)},ComputeAABB:function(t,e,i){for(var n=e.q.c*this.m_vertices[0].x-e.q.s*this.m_vertices[0].y+e.p.x,r=e.q.s*this.m_vertices[0].x+e.q.c*this.m_vertices[0].y+e.p.y,s=n,o=r,a=1;a=3);for(var n=new r(0,0),s=0,o=0,a=new r(0,0),c=0;cze),n.Multiply(1/s),e.center=r.Add(n,a),e.I=i*o,e.I+=e.mass*(u(e.center,e.center)-u(n,n))},GetVertexCount:function(){return this.m_count},GetVertex:function(e){return t(0<=e&&e=3);for(var n=new r,s=0,o=new r(0,0),a=0;aze),n.Multiply(1/s),n},G._extend(F),j.prototype={CreateProxy:function(t,e){var i=this.m_tree.CreateProxy(t,e);return++this.m_proxyCount,this.BufferMove(i),i},DestroyProxy:function(t){this.UnBufferMove(t),--this.m_proxyCount,this.m_tree.DestroyProxy(t)},MoveProxy:function(t,e,i){this.m_tree.MoveProxy(t,e,i)&&this.BufferMove(t)},TouchProxy:function(t){this.BufferMove(t)},GetFatAABB:function(t){return this.m_tree.GetFatAABB(t)},GetUserData:function(t){return this.m_tree.GetUserData(t)},TestOverlap:function(t,e){return vt(this.m_tree.GetFatAABB(t),this.m_tree.GetFatAABB(e))},GetProxyCount:function(){return this.m_proxyCount},UpdatePairs:function(t){this.m_pairCount=0,this.m_pairBuffer.length=0;for(var e=0;en&&(i=r,n=s)}return i},GetSupportVertex:function(t,e){return this.m_vertices[this.GetSupport(t,e)]},GetVertexCount:function(){return this.m_count},GetVertex:function(e){return t(0<=e&&e1){var l=e.metric,u=this.GetMetric();(u<.5*l||2*l0?(e.x=-1*n,e.y=1*i):(e.x=1*n,e.y=-1*i);break;default:t(!1),e.x=e.y=0}},GetClosestPoint:function(e){switch(this.m_count){case 1:e.x=this.m_v[0].w.x,e.y=this.m_v[0].w.y;break;case 2:e.x=this.m_v[0].a*this.m_v[0].w.x+this.m_v[1].a*this.m_v[1].w.x,e.y=this.m_v[0].a*this.m_v[0].w.y+this.m_v[1].a*this.m_v[1].w.y;break;case 3:e.x=e.y=0;break;default:t(!1),e.x=e.y=0}},GetWitnessPoints:function(e,i){switch(this.m_count){case 1:e.x=this.m_v[0].wA.x,e.y=this.m_v[0].wA.y,i.x=this.m_v[0].wB.x,i.y=this.m_v[0].wB.y;break;case 2:e.x=this.m_v[0].a*this.m_v[0].wA.x+this.m_v[1].a*this.m_v[1].wA.x,e.y=this.m_v[0].a*this.m_v[0].wA.y+this.m_v[1].a*this.m_v[1].wA.y,i.x=this.m_v[0].a*this.m_v[0].wB.x+this.m_v[1].a*this.m_v[1].wB.x,i.y=this.m_v[0].a*this.m_v[0].wB.y+this.m_v[1].a*this.m_v[1].wB.y;break;case 3:e.x=this.m_v[0].a*this.m_v[0].wA.x+this.m_v[1].a*this.m_v[1].wA.x+this.m_v[2].a*this.m_v[2].wA.x,e.y=this.m_v[0].a*this.m_v[0].wA.y+this.m_v[1].a*this.m_v[1].wA.y+this.m_v[2].a*this.m_v[2].wA.y,i.x=e.x,i.y=e.y;break;default:t(!1)}},GetMetric:function(){switch(this.m_count){case 1:return 0;case 2:return m(this.m_v[0].w,this.m_v[1].w);case 3:return(this.m_v[1].w.x-this.m_v[0].w.x)*(this.m_v[2].w.y-this.m_v[0].w.y)-(this.m_v[1].w.y-this.m_v[0].w.y)*(this.m_v[2].w.x-this.m_v[0].w.x);default:return t(!1),0}},Solve2:function(){var t=this.m_v[0].w,e=this.m_v[1].w,i=e.x-t.x,n=e.y-t.y,r=-(t.x*i+t.y*n);if(r<=0)return this.m_v[0].a=1,void(this.m_count=1);var s=e.x*i+e.y*n;if(s<=0)return this.m_v[1].a=1,this.m_count=1,void this.m_v[0].Assign(this.m_v[1]);var o=1/(s+r);this.m_v[0].a=s*o,this.m_v[1].a=r*o,this.m_count=2},Solve3:function(){var t=this.m_v[0].w,e=this.m_v[1].w,i=this.m_v[2].w,n=e.x-t.x,r=e.y-t.y,s=t.x*n+t.y*r,o=e.x*n+e.y*r,a=-s,c=i.x-t.x,h=i.y-t.y,l=t.x*c+t.y*h,u=i.x*c+i.y*h,_=-l,d=i.x-e.x,f=i.y-e.y,p=e.x*d+e.y*f,m=i.x*d+i.y*f,g=-p,y=n*h-r*c,v=y*(e.x*i.y-e.y*i.x),x=y*(i.x*t.y-i.y*t.x),C=y*(t.x*e.y-t.y*e.x);if(a<=0&&_<=0)return this.m_v[0].a=1,void(this.m_count=1);if(o>0&&a>0&&C<=0){var T=1/(o+a);return this.m_v[0].a=o*T,this.m_v[1].a=a*T,void(this.m_count=2)}if(u>0&&_>0&&x<=0){var b=1/(u+_);return this.m_v[0].a=u*b,this.m_v[2].a=_*b,this.m_count=2,void this.m_v[1].Assign(this.m_v[2])}if(o<=0&&g<=0)return this.m_v[1].a=1,this.m_count=1,void this.m_v[0].Assign(this.m_v[1]);if(u<=0&&m<=0)return this.m_v[2].a=1,this.m_count=1,void this.m_v[0].Assign(this.m_v[2]);if(m>0&&g>0&&v<=0){var A=1/(m+g);return this.m_v[1].a=m*A,this.m_v[2].a=g*A,this.m_count=2,void this.m_v[0].Assign(this.m_v[2])}var S=1/(v+x+C);this.m_v[0].a=v*S,this.m_v[1].a=x*S,this.m_v[2].a=C*S,this.m_count=3}};var ai=new Z,ci=new r,hi=new r;Q.b2_gjkCalls=0,Q.b2_gjkIters=0,Q.b2_gjkMaxIters=0;K.prototype={indexA:0,indexB:0,typeA:0,typeB:0,Reset:function(){this.indexA=this.indexB=this.typeA=this.typeB=0},Get:function(){return this.indexA|this.indexB<<8|this.typeA<<16|this.typeB<<24},Assign:function(t){this.indexA=t.indexA,this.indexB=t.indexB,this.typeA=t.typeA,this.typeB=t.typeB}},K.e_vertex=0,K.e_face=1,$.prototype={Clone:function(){var t=new $;return t.localPoint.x=this.localPoint.x,t.localPoint.y=this.localPoint.y,t.normalImpulse=this.normalImpulse,t.tangentImpulse=this.tangentImpulse,t.id.Assign(this.id),t}},tt.prototype={Clone:function(){var t=new tt;t.pointCount=this.pointCount,t.type=this.type,t.localPoint.x=this.localPoint.x,t.localPoint.y=this.localPoint.y,t.localNormal.x=this.localNormal.x,t.localNormal.y=this.localNormal.y;for(var e=0;eze*ze&&(this.normal.x=c-o,this.normal.y=h-a,this.normal.Normalize());var _=o+i*this.normal.x,d=a+i*this.normal.y,f=c-s*this.normal.x,p=h-s*this.normal.y;this.points[0]=new r(.5*(_+f),.5*(d+p)),this.separations[0]=(f-_)*this.normal.x+(p-d)*this.normal.y;break;case tt.e_faceA:this.normal.x=e.q.c*t.localNormal.x-e.q.s*t.localNormal.y,this.normal.y=e.q.s*t.localNormal.x+e.q.c*t.localNormal.y;for(var m=e.q.c*t.localPoint.x-e.q.s*t.localPoint.y+e.p.x,g=e.q.s*t.localPoint.x+e.q.c*t.localPoint.y+e.p.y,y=0;y=0&&this.upperBound.y-this.lowerBound.y>=0&&this.lowerBound.IsValid()&&this.upperBound.IsValid()},GetCenter:function(){return new r(.5*(this.lowerBound.x+this.upperBound.x),.5*(this.lowerBound.y+this.upperBound.y))},GetExtents:function(){return new r(.5*(this.upperBound.x-this.lowerBound.x),.5*(this.upperBound.y-this.lowerBound.y))},GetPerimeter:function(){return 2*(this.upperBound.x-this.lowerBound.x+(this.upperBound.y-this.lowerBound.y))},Combine:function(t,e){e?(this.lowerBound.x=si(t.lowerBound.x,e.lowerBound.x),this.lowerBound.y=si(t.lowerBound.y,e.lowerBound.y),this.upperBound.x=oi(t.upperBound.x,e.upperBound.x),this.upperBound.y=oi(t.upperBound.y,e.upperBound.y)):(this.lowerBound.x=si(this.lowerBound.x,t.lowerBound.x),this.lowerBound.y=si(this.lowerBound.y,t.lowerBound.y),this.upperBound.x=oi(this.upperBound.x,t.upperBound.x),this.upperBound.y=oi(this.upperBound.y,t.upperBound.y))},Contains:function(t){return this.lowerBound.x<=t.lowerBound.x&&this.lowerBound.y<=t.lowerBound.y&&t.upperBound.x<=this.upperBound.x&&t.upperBound.y<=this.upperBound.y},RayCast:function(t,e){for(var i=-ke,n=ke,s=e.p1,o=r.Subtract(e.p2,e.p1),a=R(o),c=new r,h=0;h<2;++h)if(a.get_i(h)_){var f=_;_=u,u=f,d=1}if(u>i&&(c.x=c.y=0,c.set_i(h,d),i=u),n=si(n,_),i>n)return!1}return!(i<0||e.maxFraction=0,c=this.m_normal0.x*(this.m_centroidB.x-this.m_v0.x)+this.m_normal0.y*(this.m_centroidB.y-this.m_v0.y)),o&&(pt._temp_edge2.x=this.m_v3.x-this.m_v2.x,pt._temp_edge2.y=this.m_v3.y-this.m_v2.y,pt._temp_edge2.Normalize(),this.m_normal2.x=pt._temp_edge2.y,this.m_normal2.y=-pt._temp_edge2.x,u=pt._temp_edge.x*pt._temp_edge2.y-pt._temp_edge.y*pt._temp_edge2.x>0,h=this.m_normal2.x*(this.m_centroidB.x-this.m_v2.x)+this.m_normal2.y*(this.m_centroidB.y-this.m_v2.y)),s&&o?l&&u?(this.m_front=c>=0||a>=0||h>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=this.m_normal0.x,this.m_lowerLimit.y=this.m_normal0.y,this.m_upperLimit.x=this.m_normal2.x,this.m_upperLimit.y=this.m_normal2.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal1.x,this.m_lowerLimit.y=-this.m_normal1.y,this.m_upperLimit.x=-this.m_normal1.x,this.m_upperLimit.y=-this.m_normal1.y)):l?(this.m_front=c>=0||a>=0&&h>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=this.m_normal0.x,this.m_lowerLimit.y=this.m_normal0.y,this.m_upperLimit.x=this.m_normal1.x,this.m_upperLimit.y=this.m_normal1.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal2.x,this.m_lowerLimit.y=-this.m_normal2.y,this.m_upperLimit.x=-this.m_normal1.x,this.m_upperLimit.y=-this.m_normal1.y)):u?(this.m_front=h>=0||c>=0&&a>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=this.m_normal1.x,this.m_lowerLimit.y=this.m_normal1.y,this.m_upperLimit.x=this.m_normal2.x,this.m_upperLimit.y=this.m_normal2.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal1.x,this.m_lowerLimit.y=-this.m_normal1.y,this.m_upperLimit.x=-this.m_normal0.x,this.m_upperLimit.y=-this.m_normal0.y)):(this.m_front=c>=0&&a>=0&&h>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=this.m_normal1.x,this.m_lowerLimit.y=this.m_normal1.y,this.m_upperLimit.x=this.m_normal1.x,this.m_upperLimit.y=this.m_normal1.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal2.x,this.m_lowerLimit.y=-this.m_normal2.y,this.m_upperLimit.x=-this.m_normal0.x,this.m_upperLimit.y=-this.m_normal0.y)):s?l?(this.m_front=c>=0||a>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=this.m_normal0.x,this.m_lowerLimit.y=this.m_normal0.y,this.m_upperLimit.x=-this.m_normal1.x,this.m_upperLimit.y=-this.m_normal1.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=this.m_normal1.x,this.m_lowerLimit.y=this.m_normal1.y,this.m_upperLimit.x=-this.m_normal1.x,this.m_upperLimit.y=-this.m_normal1.y)):(this.m_front=c>=0&&a>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=this.m_normal1.x,this.m_lowerLimit.y=this.m_normal1.y,this.m_upperLimit.x=-this.m_normal1.x,this.m_upperLimit.y=-this.m_normal1.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=this.m_normal1.x,this.m_lowerLimit.y=this.m_normal1.y,this.m_upperLimit.x=-this.m_normal0.x,this.m_upperLimit.y=-this.m_normal0.y)):o?u?(this.m_front=a>=0||h>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal1.x,this.m_lowerLimit.y=-this.m_normal1.y,this.m_upperLimit.x=this.m_normal2.x,this.m_upperLimit.y=this.m_normal2.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal1.x,this.m_lowerLimit.y=-this.m_normal1.y,this.m_upperLimit.x=this.m_normal1.x,this.m_upperLimit.y=this.m_normal1.y)):(this.m_front=a>=0&&h>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal1.x,this.m_lowerLimit.y=-this.m_normal1.y,this.m_upperLimit.x=this.m_normal1.x,this.m_upperLimit.y=this.m_normal1.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal2.x,this.m_lowerLimit.y=-this.m_normal2.y,this.m_upperLimit.x=this.m_normal1.x,this.m_upperLimit.y=this.m_normal1.y)):(this.m_front=a>=0,this.m_front?(this.m_normal.x=this.m_normal1.x,this.m_normal.y=this.m_normal1.y,this.m_lowerLimit.x=-this.m_normal1.x,this.m_lowerLimit.y=-this.m_normal1.y,this.m_upperLimit.x=-this.m_normal1.x,this.m_upperLimit.y=-this.m_normal1.y):(this.m_normal.x=-this.m_normal1.x,this.m_normal.y=-this.m_normal1.y,this.m_lowerLimit.x=this.m_normal1.x,this.m_lowerLimit.y=this.m_normal1.y,this.m_upperLimit.x=this.m_normal1.x,this.m_upperLimit.y=this.m_normal1.y)),this.m_polygonB.count=n.m_count;for(var _=0;_this.m_radius)){var f=this.ComputePolygonSeparation();if(!(f.type!=_t.e_unknown&&f.separation>this.m_radius)){var p=new _t;p=f.type==_t.e_unknown?d:f.separation>.98*d.separation+.001?f:d;var m=new Array(2),g=new ft;if(p.type==_t.e_edgeA){t.type=tt.e_faceA;var y=0,v=this.m_normal.x*this.m_polygonB.normals[0].x+this.m_normal.y*this.m_polygonB.normals[0].y;for(_=1;_this.m_radius)return t.type=_t.e_edgeB,t.index=n,t.separation=c,t;if(r*e+s*i>=0){if((r-this.m_upperLimit.x)*this.m_normal.x+(s-this.m_upperLimit.y)*this.m_normal.y<-je)continue}else if((r-this.m_lowerLimit.x)*this.m_normal.x+(s-this.m_lowerLimit.y)*this.m_normal.y<-je)continue;c>t.separation&&(t.type=_t.e_edgeB,t.index=n,t.separation=c)}return t}},pt.e_isolated=0,pt.e_concave=1,pt.e_convex=2,mt.collider=new pt,yt.input=new H,yt.cache=new Y,yt.output=new q;var li=-1;xt.prototype={IsLeaf:function(){return this.child1==li}},Ct.aabbExtensionFattener=new r(.1,.1),Ct.prototype={CreateProxy:function(t,e){var i=this.AllocateNode();return this.m_nodes[i].aabb.lowerBound.Assign(r.Subtract(t.lowerBound,Ct.aabbExtensionFattener)),this.m_nodes[i].aabb.upperBound.Assign(r.Add(t.upperBound,Ct.aabbExtensionFattener)),this.m_nodes[i].userData=e,this.m_nodes[i].height=0,this.InsertLeaf(i),i},DestroyProxy:function(e){t(0<=e&&e0;){var n=i.pop();if(n!=li){var r=this.m_nodes[n];if(vt(r.aabb,e))if(r.IsLeaf()){if(0==t.QueryCallback(n))return}else i.push(r.child1),i.push(r.child2)}}},RayCast:function(e,i){var n=i.p1,s=i.p2,o=r.Subtract(s,n);t(o.LengthSquared()>0),o.Normalize();var a=f(1,o),c=R(a),h=i.maxFraction,l=new st,_=r.Add(n,r.Multiply(h,r.Subtract(s,n)));l.lowerBound.Assign(P(n,_)),l.upperBound.Assign(O(n,_));var d=[];for(d.push(this.m_root);d.length>0;){var p=d.pop();if(p!=li){var m=this.m_nodes[p];if(0!=vt(m.aabb,l)){var g=m.aabb.GetCenter(),y=m.aabb.GetExtents();if(!(ri(u(a,r.Subtract(n,g)))-u(c,y)>0))if(m.IsLeaf()){var v=new nt;v.p1.Assign(i.p1),v.p2.Assign(i.p2),v.maxFraction=h;var x=e.RayCastCallback(v,p);if(0==x)return;if(x>0){_=r.Add(n,r.Multiply(h=x,r.Subtract(s,n)));l.lowerBound.Assign(P(n,_)),l.upperBound.Assign(O(n,_))}}else d.push(m.child1),d.push(m.child2)}}}},Validate:function(){this.ValidateStructure(this.m_root),this.ValidateMetrics(this.m_root);for(var e=0,i=this.m_freeList;i!=li;)t(0<=i&&i1;){var n=ke,r=-1,s=-1;for(i=0;i1){var c=o.child1,h=o.child2,l=this.m_nodes[c],u=this.m_nodes[h];return t(0<=c&&cu.height?(o.child2=c,i.child2=h,u.parent=e,i.aabb.Combine(s.aabb,u.aabb),o.aabb.Combine(i.aabb,l.aabb),i.height=1+oi(s.height,u.height),o.height=1+oi(i.height,l.height)):(o.child2=h,i.child2=c,l.parent=e,i.aabb.Combine(s.aabb,l.aabb),o.aabb.Combine(i.aabb,u.aabb),i.height=1+oi(s.height,l.height),o.height=1+oi(i.height,u.height)),r}if(a<-1){var _=s.child1,d=s.child2,f=this.m_nodes[_],p=this.m_nodes[d];return t(0<=_&&_p.height?(s.child2=_,i.child1=d,p.parent=e,i.aabb.Combine(o.aabb,p.aabb),s.aabb.Combine(i.aabb,f.aabb),i.height=1+oi(o.height,p.height),s.height=1+oi(i.height,f.height)):(s.child2=d,i.child1=_,f.parent=e,i.aabb.Combine(o.aabb,f.aabb),s.aabb.Combine(i.aabb,p.aabb),i.height=1+oi(o.height,f.height),s.height=1+oi(i.height,p.height)),n}return e},ComputeHeight:function(e){void 0===e&&(e=this.m_root),t(0<=e&&e0&&this.ResetMassData(),this.m_world.m_flags|=Wt.e_newFixture,r},DestroyFixture:function(e){if(t(0==this.m_world.IsLocked()),1!=this.m_world.IsLocked()){t(e.m_body==this),t(this.m_fixtureCount>0);for(var i=this.m_fixtureList,n=!1;null!=i;){if(i==e){this.m_fixtureList=i=e.m_next,n=!0;break}i=i.m_next}t(n);for(var r=this.m_contactList;r;){var s=r.contact;r=r.next;var o=s.GetFixtureA(),a=s.GetFixtureB();e!=o&&e!=a||this.m_world.m_contactManager.Destroy(s)}if(this.m_flags&Et.e_activeFlag){var c=this.m_world.m_contactManager.m_broadPhase;e.DestroyProxies(c)}e.Destroy(),e.m_body=null,e.m_next=null,--this.m_fixtureCount,this.ResetMassData()}},SetTransform:function(e,i){if(t(0==this.m_world.IsLocked()),1!=this.m_world.IsLocked()){this.m_xf.q.Set(i),this.m_xf.p.Assign(e),this.m_sweep.c.Assign(w(this.m_xf,this.m_sweep.localCenter)),this.m_sweep.a=i,this.m_sweep.c0.Assign(this.m_sweep.c),this.m_sweep.a0=i;for(var n=this.m_world.m_contactManager.m_broadPhase,r=this.m_fixtureList;r;r=r.m_next)r.Synchronize(n,this.m_xf,this.m_xf)}},GetTransform:function(){return this.m_xf},GetPosition:function(){return this.m_xf.p},GetAngle:function(){return this.m_sweep.a},GetWorldCenter:function(){return this.m_sweep.c},GetLocalCenter:function(){return this.m_sweep.localCenter},SetLinearVelocity:function(t){this.m_type!=Et.b2_staticBody&&(u(t,t)>0&&this.SetAwake(!0),this.m_linearVelocity=t)},GetLinearVelocity:function(){return this.m_linearVelocity},SetAngularVelocity:function(t){this.m_type!=Et.b2_staticBody&&(t*t>0&&this.SetAwake(!0),this.m_angularVelocity=t)},GetAngularVelocity:function(){return this.m_angularVelocity},ApplyForce:function(t,e,i){this.m_type==Et.b2_dynamicBody&&(i&&0==(this.m_flags&Et.e_awakeFlag)&&this.SetAwake(!0),this.m_flags&Et.e_awakeFlag&&(this.m_force.Add(t),this.m_torque+=_(r.Subtract(e,this.m_sweep.c),t)))},ApplyForceToCenter:function(t,e){this.m_type==Et.b2_dynamicBody&&(e&&0==(this.m_flags&Et.e_awakeFlag)&&this.SetAwake(!0),this.m_flags&Et.e_awakeFlag&&this.m_force.Add(t))},ApplyTorque:function(t,e){this.m_type==Et.b2_dynamicBody&&(e&&0==(this.m_flags&Et.e_awakeFlag)&&this.SetAwake(!0),this.m_flags&Et.e_awakeFlag&&(this.m_torque+=t))},ApplyLinearImpulse:function(t,e,i){this.m_type==Et.b2_dynamicBody&&(i&&0==(this.m_flags&Et.e_awakeFlag)&&this.SetAwake(!0),this.m_flags&Et.e_awakeFlag&&(this.m_linearVelocity.Add(r.Multiply(this.m_invMass,t)),this.m_angularVelocity+=this.m_invI*_(r.Subtract(e,this.m_sweep.c),t)))},ApplyAngularImpulse:function(t,e){this.m_type==Et.b2_dynamicBody&&(e&&0==(this.m_flags&Et.e_awakeFlag)&&this.SetAwake(!0),this.m_flags&Et.e_awakeFlag&&(this.m_angularVelocity+=this.m_invI*t))},GetMass:function(){return this.m_mass},GetInertia:function(){return this.m_I+this.m_mass*u(this.m_sweep.localCenter,this.m_sweep.localCenter)},GetMassData:function(t){t.mass=this.m_mass,t.I=this.m_I+this.m_mass*u(this.m_sweep.localCenter,this.m_sweep.localCenter),t.center=this.m_sweep.localCenter},SetMassData:function(e){t(0==this.m_world.IsLocked()),1!=this.m_world.IsLocked()&&this.m_type==Et.b2_dynamicBody&&(this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_mass=e.mass,this.m_mass<=0&&(this.m_mass=1),this.m_invMass=1/this.m_mass,e.I>0&&0==(this.m_flags&Et.e_fixedRotationFlag)&&(this.m_I=e.I-this.m_mass*u(e.center,e.center),t(this.m_I>0),this.m_invI=1/this.m_I),Et.m_local_oldCenter.Assign(this.m_sweep.c),this.m_sweep.localCenter.Assign(e.center),this.m_sweep.c0.Assign(w(this.m_xf,this.m_sweep.localCenter)),this.m_sweep.c.Assign(this.m_sweep.c0),this.m_linearVelocity.Add(f(this.m_angularVelocity,r.Subtract(this.m_sweep.c,Et.m_local_oldCenter))))},ResetMassData:function(){if(this.m_mass=0,this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_sweep.localCenter.SetZero(),this.m_type==Et.b2_staticBody||this.m_type==Et.b2_kinematicBody)return this.m_sweep.c0.Assign(this.m_xf.p),this.m_sweep.c.Assign(this.m_xf.p),void(this.m_sweep.a0=this.m_sweep.a);t(this.m_type==Et.b2_dynamicBody);for(var e=new r(0,0),i=this.m_fixtureList;i;i=i.m_next)if(0!=i.m_density){var n=new N;i.GetMassData(n),this.m_mass+=n.mass,e.Add(r.Multiply(n.mass,n.center)),this.m_I+=n.I}this.m_mass>0?(this.m_invMass=1/this.m_mass,e.Multiply(this.m_invMass)):(this.m_mass=1,this.m_invMass=1),this.m_I>0&&0==(this.m_flags&Et.e_fixedRotationFlag)?(this.m_I-=this.m_mass*u(e,e),t(this.m_I>0),this.m_invI=1/this.m_I):(this.m_I=0,this.m_invI=0),Et.m_local_oldCenter.Assign(this.m_sweep.c),this.m_sweep.localCenter.Assign(e),this.m_sweep.c0.Assign(w(this.m_xf,this.m_sweep.localCenter)),this.m_sweep.c.Assign(this.m_sweep.c0),this.m_linearVelocity.Add(f(this.m_angularVelocity,r.Subtract(this.m_sweep.c,Et.m_local_oldCenter)))},GetWorldPoint:function(t){return w(this.m_xf,t)},GetWorldVector:function(t){return A(this.m_xf.q,t)},GetLocalPoint:function(t){return E(this.m_xf,t)},GetLocalVector:function(t){return S(this.m_xf.q,t)},GetLinearVelocityFromWorldPoint:function(t){return r.Add(this.m_linearVelocity,f(this.m_angularVelocity,r.Subtract(t,this.m_sweep.c)))},GetLinearVelocityFromLocalPoint:function(t){return this.GetLinearVelocityFromWorldPoint(this.GetWorldPoint(t))},GetLinearDamping:function(){return this.m_linearDamping},SetLinearDamping:function(t){this.m_linearDamping=t},GetAngularDamping:function(){return this.m_angularDamping},SetAngularDamping:function(t){this.m_angularDamping=t},GetGravityScale:function(){return this.m_gravityScale},SetGravityScale:function(t){this.m_gravityScale=t},SetType:function(e){if(t(0==this.m_world.IsLocked()),1!=this.m_world.IsLocked()&&this.m_type!=e){this.m_type=e,this.ResetMassData(),this.m_type==Et.b2_staticBody&&(this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_sweep.a0=this.m_sweep.a,this.m_sweep.c0.Assign(this.m_sweep.c),this.SynchronizeFixtures()),this.SetAwake(!0),this.m_force.SetZero(),this.m_torque=0;for(var i=this.m_contactList;i;){var n=i;i=i.next,this.m_world.m_contactManager.Destroy(n.contact)}this.m_contactList=null;for(var r=this.m_world.m_contactManager.m_broadPhase,s=this.m_fixtureList;s;s=s.m_next)for(var o=s.m_proxyCount,a=0;a=0),this.m_density=e},GetDensity:function(){return this.m_density},GetFriction:function(){return this.m_friction},SetFriction:function(t){this.m_friction=t},GetRestitution:function(){return this.m_restitution},SetRestitution:function(t){this.m_restitution=t},GetAABB:function(e){return t(0<=e&&e0;return 0!=(i.maskBits&n.categoryBits)&&0!=(i.categoryBits&n.maskBits)}},Lt.prototype={BeginContact:function(t){},EndContact:function(t){},PreSolve:function(t,e){},PostSolve:function(t,e){}},Nt.prototype={ReportFixture:function(t){return!1}},Ft.prototype={ReportFixture:function(t,e,i,n){}};var fi=Fe.create("step"),pi=Fe.create("collide","step"),mi=Fe.create("solve","step"),gi=Fe.create("solveTOI","step"),yi=Fe.create("broadphase","step");Ut.prototype={QueryCallback:function(t){var e=this.broadPhase.GetUserData(t);return this.callback.ReportFixture(e.fixture)}},jt.prototype={RayCastCallback:function(t,e){var i=this.broadPhase.GetUserData(e),n=i.fixture,s=i.childIndex,o=new rt;if(n.RayCast(o,t,s)){var a=o.fraction,c=r.Add(r.Multiply(1-a,t.p1),r.Multiply(a,t.p2));return this.callback.ReportFixture(n,c,o.normal,a)}return t.maxFraction}},Wt.m_local_sweep_backupA=new l,Wt.m_local_sweep_backupB=new l,Wt.m_local_sweep_backupC=new l,Wt.prototype={Destroy:function(){for(var t=this.m_bodyList;t;){for(var e=t.m_next,i=t.m_fixtureList;i;){var n=i.m_next;i.m_proxyCount=0,i.Destroy(),i=n}t=e}},SetDestructionListener:function(t){this.m_destructionListener=t},SetContactFilter:function(t){this.m_contactManager.m_contactFilter=t},SetContactListener:function(t){this.m_contactManager.m_contactListener=t},SetDebugDraw:function(t){this.g_debugDraw=t},CreateBody:function(e){if(t(0==this.IsLocked()),this.IsLocked())return null;var i=new Et(e,this);return i.m_prev=null,i.m_next=this.m_bodyList,this.m_bodyList&&(this.m_bodyList.m_prev=i),this.m_bodyList=i,++this.m_bodyCount,i},DestroyBody:function(e){if(t(this.m_bodyCount>0),t(0==this.IsLocked()),!this.IsLocked()){for(var i=e.m_jointList;i;){var n=i;i=i.next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeJoint(n.joint),this.DestroyJoint(n.joint),e.m_jointList=i}e.m_jointList=null;for(var r=e.m_contactList;r;){var s=r;r=r.next,this.m_contactManager.Destroy(s.contact)}e.m_contactList=null;for(var o=e.m_fixtureList;o;){var a=o;o=o.m_next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeFixture(a),a.DestroyProxies(this.m_contactManager.m_broadPhase),a.Destroy(),e.m_fixtureList=o,e.m_fixtureCount-=1}e.m_fixtureList=null,e.m_fixtureCount=0,e.m_prev&&(e.m_prev.m_next=e.m_next),e.m_next&&(e.m_next.m_prev=e.m_prev),e==this.m_bodyList&&(this.m_bodyList=e.m_next),e.m_destroyed=!0,--this.m_bodyCount}},CreateJoint:function(e){if(t(0==this.IsLocked()),this.IsLocked())return null;var i=de.Create(e);i.m_prev=null,i.m_next=this.m_jointList,this.m_jointList&&(this.m_jointList.m_prev=i),this.m_jointList=i,++this.m_jointCount,i.m_edgeA.joint=i,i.m_edgeA.other=i.m_bodyB,i.m_edgeA.prev=null,i.m_edgeA.next=i.m_bodyA.m_jointList,i.m_bodyA.m_jointList&&(i.m_bodyA.m_jointList.prev=i.m_edgeA),i.m_bodyA.m_jointList=i.m_edgeA,i.m_edgeB.joint=i,i.m_edgeB.other=i.m_bodyA,i.m_edgeB.prev=null,i.m_edgeB.next=i.m_bodyB.m_jointList,i.m_bodyB.m_jointList&&(i.m_bodyB.m_jointList.prev=i.m_edgeB),i.m_bodyB.m_jointList=i.m_edgeB;var n=e.bodyA,r=e.bodyB;if(0==e.collideConnected)for(var s=r.GetContactList();s;)s.other==n&&s.contact.FlagForFiltering(),s=s.next;return i},DestroyJoint:function(e){if(t(0==this.IsLocked()),!this.IsLocked()){var i=e.m_collideConnected;e.m_prev&&(e.m_prev.m_next=e.m_next),e.m_next&&(e.m_next.m_prev=e.m_prev),e==this.m_jointList&&(this.m_jointList=e.m_next);var n=e.m_bodyA,r=e.m_bodyB;if(n.SetAwake(!0),r.SetAwake(!0),e.m_edgeA.prev&&(e.m_edgeA.prev.next=e.m_edgeA.next),e.m_edgeA.next&&(e.m_edgeA.next.prev=e.m_edgeA.prev),e.m_edgeA==n.m_jointList&&(n.m_jointList=e.m_edgeA.next),e.m_edgeA.prev=null,e.m_edgeA.next=null,e.m_edgeB.prev&&(e.m_edgeB.prev.next=e.m_edgeB.next),e.m_edgeB.next&&(e.m_edgeB.next.prev=e.m_edgeB.prev),e.m_edgeB==r.m_jointList&&(r.m_jointList=e.m_edgeB.next),e.m_edgeB.prev=null,e.m_edgeB.next=null,de.Destroy(e),t(this.m_jointCount>0),--this.m_jointCount,0==i)for(var s=r.GetContactList();s;)s.other==n&&s.contact.FlagForFiltering(),s=s.next}},Step:function(t,e,i){fi.start(),this.m_flags&Wt.e_newFixture&&(this.m_contactManager.FindNewContacts(),this.m_flags&=~Wt.e_newFixture),this.m_flags|=Wt.e_locked,this.p_step.dt=t,this.p_step.velocityIterations=e,this.p_step.positionIterations=i,this.p_step.inv_dt=t>0?1/t:0,this.p_step.dtRatio=this.m_inv_dt0*t,this.p_step.warmStarting=this.m_warmStarting,pi.start(),this.m_contactManager.Collide(),pi.stop(),this.m_stepComplete&&this.p_step.dt>0&&(mi.start(),this.Solve(this.p_step),mi.stop()),this.m_continuousPhysics&&this.p_step.dt>0&&(gi.start(),this.SolveTOI(this.p_step),gi.stop()),this.p_step.dt>0&&(this.m_inv_dt0=this.p_step.inv_dt),this.m_flags&Wt.e_clearForces&&this.ClearForces(),this.m_flags&=~Wt.e_locked,fi.stop()},ClearForces:function(){for(var t=this.m_bodyList;t;t=t.GetNext())t.m_force.x=t.m_force.y=0,t.m_torque=0},DrawDebugData:function(){if(null!=this.g_debugDraw){this.g_debugDraw.ClearDraw();var t=this.g_debugDraw.GetFlags();if(t&M.e_shapeBit)for(var e=this.m_bodyList;e;e=e.GetNext())for(var i=e.GetTransform(),n=e.GetFixtureList();n;n=n.GetNext())0==e.IsActive()?this.DrawShape(n,i,new D(.5,.5,.3)):e.GetType()==Et.b2_staticBody?this.DrawShape(n,i,new D(.5,.9,.5)):e.GetType()==Et.b2_kinematicBody?this.DrawShape(n,i,new D(.5,.5,.9)):0==e.IsAwake()?this.DrawShape(n,i,new D(.6,.6,.6)):this.DrawShape(n,i,new D(.9,.7,.7));if(t&M.e_jointBit)for(var s=this.m_jointList;s;s=s.GetNext())this.DrawJoint(s);if(t&M.e_pairBit)for(var o=new D(.3,.9,.9),a=this.m_contactManager.m_contactList;a;a=a.GetNext()){var c=a.GetFixtureA(),h=a.GetFixtureB(),l=c.GetAABB(a.GetChildIndexA()).GetCenter(),u=h.GetAABB(a.GetChildIndexB()).GetCenter();this.g_debugDraw.DrawSegment(l,u,o)}if(t&M.e_aabbBit){o=new D(.9,.3,.9);var _=new D(.3,.3,.9),d=this.m_contactManager.m_broadPhase;for(e=this.m_bodyList;e;e=e.GetNext())if(0!=e.IsActive())for(n=e.GetFixtureList();n;n=n.GetNext())for(var f=0;f0;){if(t(1==(i=o[--c]).IsActive()),this.p_island.AddBody(i),i.SetAwake(!0),i.GetType()!=Et.b2_staticBody){for(var h=i.m_contactList;h;h=h.next){var l=h.contact;if(!(l.m_flags&Jt.e_islandFlag)&&(0!=l.IsEnabled()&&0!=l.IsTouching())){var u=l.m_fixtureA.m_isSensor,_=l.m_fixtureB.m_isSensor;if(!u&&!_){this.p_island.AddContact(l),l.m_flags|=Jt.e_islandFlag;(f=h.other).m_flags&Et.e_islandFlag||(t(c8)){var o=1;if(n.m_flags&Jt.e_toiFlag)o=n.m_toi;else{var a=n.GetFixtureA(),c=n.GetFixtureB();if(a.IsSensor()||c.IsSensor())continue;var h=a.GetBody(),l=c.GetBody(),u=h.m_type,_=l.m_type;t(u==Et.b2_dynamicBody||_==Et.b2_dynamicBody);var d=h.IsAwake()&&u!=Et.b2_staticBody,f=l.IsAwake()&&_!=Et.b2_staticBody;if(0==d&&0==f)continue;var p=h.IsBullet()||u!=Et.b2_dynamicBody,m=l.IsBullet()||_!=Et.b2_dynamicBody;if(0==p&&0==m)continue;var g=h.m_sweep.alpha0;h.m_sweep.alpha00;for(var _=0;_0&&0==i.IsSensor()&&0==n.IsSensor()&&(i.GetBody().SetAwake(!0),n.GetBody().SetAwake(!0));var r=i.GetType(),s=n.GetType();t(0<=r&&s0),e.type){case tt.e_circles:var s=i.q.c*e.localPoint.x-i.q.s*e.localPoint.y+i.p.x,o=i.q.s*e.localPoint.x+i.q.c*e.localPoint.y+i.p.y,a=n.q.c*e.localPoints[0].x-n.q.s*e.localPoints[0].y+n.p.x,c=n.q.s*e.localPoints[0].x+n.q.c*e.localPoints[0].y+n.p.y;this.point.x=.5*(s+a),this.point.y=.5*(o+c),this.normal.x=a-s,this.normal.y=c-o;var h=this.normal.x,l=this.normal.y;this.normal.Normalize(),this.separation=h*this.normal.x+l*this.normal.y-e.radiusA-e.radiusB;break;case tt.e_faceA:this.normal.x=i.q.c*e.localNormal.x-i.q.s*e.localNormal.y,this.normal.y=i.q.s*e.localNormal.x+i.q.c*e.localNormal.y;var u=i.q.c*e.localPoint.x-i.q.s*e.localPoint.y+i.p.x,_=i.q.s*e.localPoint.x+i.q.c*e.localPoint.y+i.p.y,d=n.q.c*e.localPoints[r].x-n.q.s*e.localPoints[r].y+n.p.x,f=n.q.s*e.localPoints[r].x+n.q.c*e.localPoints[r].y+n.p.y;this.separation=(d-u)*this.normal.x+(f-_)*this.normal.y-e.radiusA-e.radiusB,this.point.x=d,this.point.y=f;break;case tt.e_faceB:this.normal.x=n.q.c*e.localNormal.x-n.q.s*e.localNormal.y,this.normal.y=n.q.s*e.localNormal.x+n.q.c*e.localNormal.y;u=n.q.c*e.localPoint.x-n.q.s*e.localPoint.y+n.p.x,_=n.q.s*e.localPoint.x+n.q.c*e.localPoint.y+n.p.y,d=i.q.c*e.localPoints[r].x-i.q.s*e.localPoints[r].y+i.p.x,f=i.q.s*e.localPoints[r].x+i.q.c*e.localPoints[r].y+i.p.y;this.separation=(d-u)*this.normal.x+(f-_)*this.normal.y-e.radiusA-e.radiusB,this.point.x=d,this.point.y=f,this.normal.x=-this.normal.x,this.normal.y=-this.normal.y}}},he.cs_xfA=new h,he.cs_xfB=new h,he.temp_solver_manifold=new ae,he.prototype={Init:function(e){this.m_step=e.step,this.m_count=e.count,this.m_positionConstraints.length=this.m_count,this.m_velocityConstraints.length=this.m_count,this.m_positions=e.positions,this.m_velocities=e.velocities,this.m_contacts=e.contacts;for(var i=0;i0);var f=this.m_velocityConstraints[i]||new oe;f.friction=n.m_friction,f.restitution=n.m_restitution,f.tangentSpeed=n.m_tangentSpeed,f.indexA=l.m_islandIndex,f.indexB=u.m_islandIndex,f.invMassA=l.m_invMass,f.invMassB=u.m_invMass,f.invIA=l.m_invI,f.invIB=u.m_invI,f.contactIndex=i,f.pointCount=d,f.K.SetZero(),f.normalMass.SetZero(),this.m_velocityConstraints[i]=f;var p=this.m_positionConstraints[i]||new se;p.indexA=l.m_islandIndex,p.indexB=u.m_islandIndex,p.invMassA=l.m_invMass,p.invMassB=u.m_invMass,p.localCenterA.x=l.m_sweep.localCenter.x,p.localCenterA.y=l.m_sweep.localCenter.y,p.localCenterB.x=u.m_sweep.localCenter.x,p.localCenterB.y=u.m_sweep.localCenter.y,p.invIA=l.m_invI,p.invIB=u.m_invI,p.localNormal.x=_.localNormal.x,p.localNormal.y=_.localNormal.y,p.localPoint.x=_.localPoint.x,p.localPoint.y=_.localPoint.y,p.pointCount=d,p.radiusA=c,p.radiusB=h,p.type=_.type,this.m_positionConstraints[i]=p;for(var m=0;m0),he.cs_xfA.q.Set(m),he.cs_xfB.q.Set(x),he.cs_xfA.p.x=p.x-(he.cs_xfA.q.c*d.x-he.cs_xfA.q.s*d.y),he.cs_xfA.p.y=p.y-(he.cs_xfA.q.s*d.x+he.cs_xfA.q.c*d.y),he.cs_xfB.p.x=v.x-(he.cs_xfB.q.c*f.x-he.cs_xfB.q.s*f.y),he.cs_xfB.p.y=v.y-(he.cs_xfB.q.s*f.x+he.cs_xfB.q.c*f.y);var b=new et;b.Initialize(o,he.cs_xfA,r,he.cs_xfB,s),i.normal.x=b.normal.x,i.normal.y=b.normal.y;for(var A=i.pointCount,S=0;S0?1/R:0;var P=1*i.normal.y,O=-1*i.normal.x,B=w.rA.x*O-w.rA.y*P,D=w.rB.x*O-w.rB.y*P,M=h+l+u*B*B+_*D*D;w.tangentMass=M>0?1/M:0,w.velocityBias=0;var L=i.normal.x*(C.x+-T*w.rB.y-g.x- -y*w.rA.y)+i.normal.y*(C.y+T*w.rB.x-g.y-y*w.rA.x);L<-1&&(w.velocityBias=-i.restitution*L)}if(2==i.pointCount){var N=i.points[0],F=i.points[1],k=N.rA.x*i.normal.y-N.rA.y*i.normal.x,z=N.rB.x*i.normal.y-N.rB.y*i.normal.x,V=F.rA.x*i.normal.y-F.rA.y*i.normal.x,G=F.rB.x*i.normal.y-F.rB.y*i.normal.x,W=h+l+u*k*k+_*z*z,U=h+l+u*V*V+_*G*G,j=h+l+u*k*V+_*z*G;W*W<1e3*(W*U-j*j)?(i.K.ex.x=W,i.K.ex.y=j,i.K.ey.x=j,i.K.ey.y=U,i.normalMass.Assign(i.K.GetInverse())):i.pointCount=1}}},WarmStart:function(){for(var t=0;t=0&&D>=0);var M=_.x+-d*R.rB.y-l.x- -u*R.rA.y,L=_.y+d*R.rB.x-l.y-u*R.rA.x,N=_.x+-d*P.rB.y-l.x- -u*P.rA.y,F=_.y+d*P.rB.x-l.y-u*P.rA.x,k=M*f.x+L*f.y,z=N*f.x+F*f.y,V=k-R.velocityBias,G=z-P.velocityBias;for(V-=i.K.ex.x*O+i.K.ey.x*D,G-=i.K.ex.y*O+i.K.ey.y*D;;){var W=-(i.normalMass.ex.x*V+i.normalMass.ey.x*G),U=-(i.normalMass.ex.y*V+i.normalMass.ey.y*G);if(W>=0&&U>=0){var j=W-O,X=U-D,Y=j*f.x,H=j*f.y,q=X*f.x,J=X*f.y;l.x-=s*(Y+q),l.y-=s*(H+J),u-=o*(R.rA.x*H-R.rA.y*Y+(P.rA.x*J-P.rA.y*q)),_.x+=a*(Y+q),_.y+=a*(H+J),d+=c*(R.rB.x*H-R.rB.y*Y+(P.rB.x*J-P.rB.y*q)),R.normalImpulse=W,P.normalImpulse=U;break}if(W=-R.normalMass*V,U=0,k=0,z=i.K.ex.y*W+G,W>=0&&z>=0){X=U-D,Y=(j=W-O)*f.x,H=j*f.y,q=X*f.x,J=X*f.y,l.x-=s*(Y+q),l.y-=s*(H+J),u-=o*(R.rA.x*H-R.rA.y*Y+(P.rA.x*J-P.rA.y*q)),_.x+=a*(Y+q),_.y+=a*(H+J),d+=c*(R.rB.x*H-R.rB.y*Y+(P.rB.x*J-P.rB.y*q)),R.normalImpulse=W,P.normalImpulse=U;break}if(W=0,U=-P.normalMass*G,k=i.K.ey.x*U+V,z=0,U>=0&&k>=0){X=U-D,Y=(j=W-O)*f.x,H=j*f.y,q=X*f.x,J=X*f.y,l.x-=s*(Y+q),l.y-=s*(H+J),u-=o*(R.rA.x*H-R.rA.y*Y+(P.rA.x*J-P.rA.y*q)),_.x+=a*(Y+q),_.y+=a*(H+J),d+=c*(R.rB.x*H-R.rB.y*Y+(P.rB.x*J-P.rB.y*q)),R.normalImpulse=W,P.normalImpulse=U;break}if(W=0,U=0,k=V,z=G,k>=0&&z>=0){X=U-D,Y=(j=W-O)*f.x,H=j*f.y,q=X*f.x,J=X*f.y,l.x-=s*(Y+q),l.y-=s*(H+J),u-=o*(R.rA.x*H-R.rA.y*Y+(P.rA.x*J-P.rA.y*q)),_.x+=a*(Y+q),_.y+=a*(H+J),d+=c*(R.rB.x*H-R.rB.y*Y+(P.rB.x*J-P.rB.y*q)),R.normalImpulse=W,P.normalImpulse=U;break}break}}this.m_velocities[n].w=u,this.m_velocities[r].w=d}},StoreImpulses:function(){for(var t=0;t0?-A/E:0,R=I*g.x,P=I*g.y;_.x-=o*R,_.y-=o*P,d-=a*(x*P-C*R),f.x+=h*R,f.y+=h*P,p+=l*(T*P-b*R)}this.m_positions[n].a=d,this.m_positions[r].a=p}return t>=-3*Ue},SolveTOIPositionConstraints:function(t,e){for(var i=0,n=0;n0?-E/P:0,C);m.Subtract(r.Multiply(u,O)),g-=d*_(S,O),y.Add(r.Multiply(f,O)),v+=p*_(w,O)}this.m_positions[o].a=g,this.m_positions[a].a=v}return i>=-1.5*Ue}};var Ti=Fe.create("solve initialization","solve"),bi=Fe.create("warm starting","solve initialization"),Ai=Fe.create("solve velocities","solve"),Si=Fe.create("solve positions","solve");le._solverData=new Gt,le._solverDef=new ce,le._solver=new he,le.prototype={Clear:function(){this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0},Initialize:function(t,e,i,n){this.m_listener=n,this.m_bodyCapacity=t,this.m_contactCapacity=e,this.m_jointCapacity=i,this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0,this.m_bodies.length=t,this.m_contacts.length=e,this.m_joints.length=i,this.m_velocities.length=t,this.m_positions.length=t},Solve:function(t,e,i){Ti.start();for(var n=t.dt,r=0;r4){var p=2/ii(f);l.x*=p,l.y*=p}var m=n*a;if(m*m>qe){a*=p=He/ri(m)}h.x+=n*l.x,h.y+=n*l.y,o+=n*a,this.m_positions[r].a=o,this.m_velocities[r].w=a}var g=!1;for(r=0;rb||u(s.m_linearVelocity,s.m_linearVelocity)>1e-4?(s.m_sleepTime=0,T=0):(s.m_sleepTime+=n,T=si(T,s.m_sleepTime)))}if(T>=.5&&g)for(r=0;r4){var f=2/d.Length();l.Multiply(f)}var p=a*_;if(p*p>qe){_*=f=He/ri(p)}c.Add(r.Multiply(a,l)),h+=a*_,this.m_positions[s].a=h,this.m_velocities[s].w=_;var m=this.m_bodies[s];m.m_sweep.c.Assign(c),m.m_sweep.a=h,m.m_linearVelocity.Assign(l),m.m_angularVelocity=_,m.SynchronizeTransform()}this.Report(le._solver.m_velocityConstraints)},AddBody:function(e){t(this.m_bodyCount0&&(this.m_motorMass=1/this.m_motorMass),(0==this.m_enableMotor||m)&&(this.m_motorImpulse=0),this.m_enableLimit&&0==m){var g=s-e-this.m_referenceAngle;ri(this.m_upperAngle-this.m_lowerAngle)<2*je?this.m_limitState=de.e_equalLimits:g<=this.m_lowerAngle?(this.m_limitState!=de.e_atLowerLimit&&(this.m_impulse.z=0),this.m_limitState=de.e_atLowerLimit):g>=this.m_upperAngle?(this.m_limitState!=de.e_atUpperLimit&&(this.m_impulse.z=0),this.m_limitState=de.e_atUpperLimit):(this.m_limitState=de.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=de.e_inactiveLimit;if(t.step.warmStarting){this.m_impulse.Multiply(t.step.dtRatio),this.m_motorImpulse*=t.step.dtRatio;var y=new r(this.m_impulse.x,this.m_impulse.y);i.Subtract(r.Multiply(u,y)),n-=f*(_(this.m_rA,y)+this.m_motorImpulse+this.m_impulse.z),o.Add(r.Multiply(d,y)),a+=p*(_(this.m_rB,y)+this.m_motorImpulse+this.m_impulse.z)}else this.m_impulse.SetZero(),this.m_motorImpulse=0;t.velocities[this.m_indexA].v.Assign(i),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].v.Assign(o),t.velocities[this.m_indexB].w=a},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),o=t.velocities[this.m_indexB].w,a=this.m_invMassA,c=this.m_invMassB,h=this.m_invIA,l=this.m_invIB,u=h+l==0;if(this.m_enableMotor&&this.m_limitState!=de.e_equalLimits&&0==u){var d=o-i-this.m_motorSpeed,p=-this.m_motorMass*d,m=this.m_motorImpulse,g=t.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=B(this.m_motorImpulse+p,-g,g),i-=h*(p=this.m_motorImpulse-m),o+=l*p}if(this.m_enableLimit&&this.m_limitState!=de.e_inactiveLimit&&0==u){var y=r.Subtract(r.Subtract(r.Add(n,f(o,this.m_rB)),e),f(i,this.m_rA)),v=o-i;d=new s(y.x,y.y,v),p=this.m_mass.Solve33(d).Negate();if(this.m_limitState==de.e_equalLimits)this.m_impulse.Add(p);else if(this.m_limitState==de.e_atLowerLimit){if(this.m_impulse.z+p.z<0){var x=r.Add(y.Negate(),r.Multiply(this.m_impulse.z,new r(this.m_mass.ez.x,this.m_mass.ez.y))),C=this.m_mass.Solve22(x);p.x=C.x,p.y=C.y,p.z=-this.m_impulse.z,this.m_impulse.x+=C.x,this.m_impulse.y+=C.y,this.m_impulse.z=0}else this.m_impulse.Add(p)}else if(this.m_limitState==de.e_atUpperLimit){if(this.m_impulse.z+p.z>0){x=r.Add(y.Negate(),r.Multiply(this.m_impulse.z,new r(this.m_mass.ez.x,this.m_mass.ez.y))),C=this.m_mass.Solve22(x);p.x=C.x,p.y=C.y,p.z=-this.m_impulse.z,this.m_impulse.x+=C.x,this.m_impulse.y+=C.y,this.m_impulse.z=0}else this.m_impulse.Add(p)}var T=new r(p.x,p.y);e.Subtract(r.Multiply(a,T)),i-=h*(_(this.m_rA,T)+p.z),n.Add(r.Multiply(c,T)),o+=l*(_(this.m_rB,T)+p.z)}else{d=r.Subtract(r.Subtract(r.Add(n,f(o,this.m_rB)),e),f(i,this.m_rA)),p=this.m_mass.Solve22(d.Negate());this.m_impulse.x+=p.x,this.m_impulse.y+=p.y,e.Subtract(r.Multiply(a,p)),i-=h*_(this.m_rA,p),n.Add(r.Multiply(c,p)),o+=l*_(this.m_rB,p)}t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=o},SolvePositionConstraints:function(t){var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.positions[this.m_indexB].c.Clone(),s=t.positions[this.m_indexB].a,a=new c(i),h=new c(s),l=0,u=0,d=this.m_invIA+this.m_invIB==0;if(this.m_enableLimit&&this.m_limitState!=de.e_inactiveLimit&&0==d){var f=s-i-this.m_referenceAngle,p=0;if(this.m_limitState==de.e_equalLimits){var m=B(f-this.m_lowerAngle,-Ye,Ye);p=-this.m_motorMass*m,l=ri(m)}else if(this.m_limitState==de.e_atLowerLimit){l=-(m=f-this.m_lowerAngle),m=B(m+je,-Ye,0),p=-this.m_motorMass*m}else if(this.m_limitState==de.e_atUpperLimit){l=m=f-this.m_upperAngle,m=B(m-je,0,Ye),p=-this.m_motorMass*m}i-=this.m_invIA*p,s+=this.m_invIB*p}a.Set(i),h.Set(s);var g=A(a,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),y=A(h,r.Subtract(this.m_localAnchorB,this.m_localCenterB));u=(m=r.Subtract(r.Subtract(r.Add(n,y),e),g)).Length();var v=this.m_invMassA,x=this.m_invMassB,C=this.m_invIA,T=this.m_invIB,b=new o;b.ex.x=v+x+C*g.y*g.y+T*y.y*y.y,b.ex.y=-C*g.x*g.y-T*y.x*y.y,b.ey.x=b.ex.y,b.ey.y=v+x+C*g.x*g.x+T*y.x*y.x;var S=b.Solve(m).Negate();return e.Subtract(r.Multiply(v,S)),i-=C*_(g,S),n.Add(r.Multiply(x,S)),s+=T*_(y,S),t.positions[this.m_indexA].c.Assign(e),t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].c.Assign(n),t.positions[this.m_indexB].a=s,u<=Ue&&l<=je},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.localAnchorA=this.m_localAnchorA._serialize(),e.localAnchorB=this.m_localAnchorB._serialize(),e.referenceAngle=this.m_referenceAngle,e.lowerAngle=this.m_lowerAngle,e.upperAngle=this.m_upperAngle,e.maxMotorTorque=this.m_maxMotorTorque,e.motorSpeed=this.m_motorSpeed,e.enableLimit=this.m_enableLimit,e.enableMotor=this.m_enableMotor,e}},pe._extend(de),me._extend(_e),ge.prototype={GetAnchorA:function(){return this.m_targetA},GetAnchorB:function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},GetReactionForce:function(t){return r.Multiply(t,this.m_impulse)},GetReactionTorque:function(t){return 0*t},SetTarget:function(t){0==this.m_bodyB.IsAwake()&&this.m_bodyB.SetAwake(!0),this.m_targetA.Assign(t)},GetTarget:function(){return this.m_targetA},SetMaxForce:function(t){this.m_maxForce=t},GetMaxForce:function(){return this.m_maxForce},SetFrequency:function(t){this.m_frequencyHz=t},GetFrequency:function(){return this.m_frequencyHz},SetDampingRatio:function(t){this.m_dampingRatio=t},GetDampingRatio:function(){return this.m_dampingRatio},ShiftOrigin:function(t){this.m_targetA.Subtract(t)},InitVelocityConstraints:function(e){this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterB.Assign(this.m_bodyB.m_sweep.localCenter),this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIB=this.m_bodyB.m_invI;var i=e.positions[this.m_indexB].c.Clone(),n=e.positions[this.m_indexB].a,s=e.velocities[this.m_indexB].v.Clone(),a=e.velocities[this.m_indexB].w,h=new c(n),l=this.m_bodyB.GetMass(),u=2*Ve*this.m_frequencyHz,d=2*l*this.m_dampingRatio*u,f=l*(u*u),p=e.step.dt;t(d+p*f>ze),this.m_gamma=p*(d+p*f),0!=this.m_gamma&&(this.m_gamma=1/this.m_gamma),this.m_beta=p*f*this.m_gamma,this.m_rB.Assign(A(h,r.Subtract(this.m_localAnchorB,this.m_localCenterB)));var m=new o;m.ex.x=this.m_invMassB+this.m_invIB*this.m_rB.y*this.m_rB.y+this.m_gamma,m.ex.y=-this.m_invIB*this.m_rB.x*this.m_rB.y,m.ey.x=m.ex.y,m.ey.y=this.m_invMassB+this.m_invIB*this.m_rB.x*this.m_rB.x+this.m_gamma,this.m_mass.Assign(m.GetInverse()),this.m_C.Assign(r.Subtract(r.Add(i,this.m_rB),this.m_targetA)),this.m_C.Multiply(this.m_beta),a*=.98,e.step.warmStarting?(this.m_impulse.Multiply(e.step.dtRatio),s.Add(r.Multiply(this.m_invMassB,this.m_impulse)),a+=this.m_invIB*_(this.m_rB,this.m_impulse)):this.m_impulse.SetZero(),e.velocities[this.m_indexB].v.Assign(s),e.velocities[this.m_indexB].w=a},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexB].v.Clone(),i=t.velocities[this.m_indexB].w,n=r.Add(e,f(i,this.m_rB)),s=p(this.m_mass,r.Add(r.Add(n,this.m_C),r.Multiply(this.m_gamma,this.m_impulse)).Negate()),o=this.m_impulse.Clone();this.m_impulse.Add(s);var a=t.step.dt*this.m_maxForce;this.m_impulse.LengthSquared()>a*a&&this.m_impulse.Multiply(a/this.m_impulse.Length()),s.Assign(r.Subtract(this.m_impulse,o)),e.Add(r.Multiply(this.m_invMassB,s)),i+=this.m_invIB*_(this.m_rB,s),t.velocities[this.m_indexB].v.Assign(e),t.velocities[this.m_indexB].w=i},SolvePositionConstraints:function(t){return!0}},ge._extend(de),ye.prototype={Initialize:function(t,e,i,n){this.bodyA=t,this.bodyB=e,this.localAnchorA=this.bodyA.GetLocalPoint(i),this.localAnchorB=this.bodyB.GetLocalPoint(n);var s=r.Subtract(n,i);this.length=s.Length()},_deserialize:function(t,e,i){this.parent.prototype._deserialize.call(this,t,e,i),this.localAnchorA._deserialize(t.localAnchorA),this.localAnchorB._deserialize(t.localAnchorB),this.length=t.length,this.frequencyHz=t.frequencyHz,this.dampingRatio=t.dampingRatio}},ye._extend(_e),ve.prototype={GetAnchorA:function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},GetAnchorB:function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},GetReactionForce:function(t){return r.Multiply(t*this.m_impulse,this.m_u)},GetReactionTorque:function(t){return 0},GetLocalAnchorA:function(){return this.m_localAnchorA},GetLocalAnchorB:function(){return this.m_localAnchorB},SetLength:function(t){this.m_length=t},GetLength:function(){return this.m_length},SetFrequency:function(t){this.m_frequencyHz=t},GetFrequency:function(){return this.m_frequencyHz},SetDampingRatio:function(t){this.m_dampingRatio=t},GetDampingRatio:function(){return this.m_dampingRatio},InitVelocityConstraints:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Assign(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Assign(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.velocities[this.m_indexA].v.Clone(),s=t.velocities[this.m_indexA].w,o=t.positions[this.m_indexB].c.Clone(),a=t.positions[this.m_indexB].a,h=t.velocities[this.m_indexB].v.Clone(),l=t.velocities[this.m_indexB].w,u=new c(i),d=new c(a);this.m_rA=A(u,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),this.m_rB=A(d,r.Subtract(this.m_localAnchorB,this.m_localCenterB)),this.m_u=r.Subtract(r.Subtract(r.Add(o,this.m_rB),e),this.m_rA);var f=this.m_u.Length();f>Ue?this.m_u.Multiply(1/f):this.m_u.Set(0,0);var p=_(this.m_rA,this.m_u),m=_(this.m_rB,this.m_u),g=this.m_invMassA+this.m_invIA*p*p+this.m_invMassB+this.m_invIB*m*m;if(this.m_mass=0!=g?1/g:0,this.m_frequencyHz>0){var y=f-this.m_length,v=2*Ve*this.m_frequencyHz,x=2*this.m_mass*this.m_dampingRatio*v,C=this.m_mass*v*v,T=t.step.dt;this.m_gamma=T*(x+T*C),this.m_gamma=0!=this.m_gamma?1/this.m_gamma:0,this.m_bias=y*T*C*this.m_gamma,g+=this.m_gamma,this.m_mass=0!=g?1/g:0}else this.m_gamma=0,this.m_bias=0;if(t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var b=r.Multiply(this.m_impulse,this.m_u);n.Subtract(r.Multiply(this.m_invMassA,b)),s-=this.m_invIA*_(this.m_rA,b),h.Add(r.Multiply(this.m_invMassB,b)),l+=this.m_invIB*_(this.m_rB,b)}else this.m_impulse=0;t.velocities[this.m_indexA].v.Assign(n),t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].v.Assign(h),t.velocities[this.m_indexB].w=l},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),s=t.velocities[this.m_indexB].w,o=r.Add(e,f(i,this.m_rA)),a=r.Add(n,f(s,this.m_rB)),c=u(this.m_u,r.Subtract(a,o)),h=-this.m_mass*(c+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=h;var l=r.Multiply(h,this.m_u);e.Subtract(r.Multiply(this.m_invMassA,l)),i-=this.m_invIA*_(this.m_rA,l),n.Add(r.Multiply(this.m_invMassB,l)),s+=this.m_invIB*_(this.m_rB,l),t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=s},SolvePositionConstraints:function(t){if(this.m_frequencyHz>0)return!0;var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.positions[this.m_indexB].c.Clone(),s=t.positions[this.m_indexB].a,o=new c(i),a=new c(s),h=A(o,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),l=A(a,r.Subtract(this.m_localAnchorB,this.m_localCenterB)),u=r.Subtract(r.Subtract(r.Add(n,l),e),h),d=u.Normalize()-this.m_length;d=B(d,-.2,.2);var f=-this.m_mass*d,p=r.Multiply(f,u);return e.Subtract(r.Multiply(this.m_invMassA,p)),i-=this.m_invIA*_(h,p),n.Add(r.Multiply(this.m_invMassB,p)),s+=this.m_invIB*_(l,p),t.positions[this.m_indexA].c.Assign(e),t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].c.Assign(n),t.positions[this.m_indexB].a=s,ri(d)0&&(this.m_motorMass=1/this.m_motorMass),this.m_perp=A(d,this.m_localYAxisA),this.m_s1=_(r.Add(g,p),this.m_perp),this.m_s2=_(m,this.m_perp);var T=y+v+x*this.m_s1*this.m_s1+C*this.m_s2*this.m_s2,b=x*this.m_s1+C*this.m_s2,S=x*this.m_s1*this.m_a1+C*this.m_s2*this.m_a2,w=x+C;0==w&&(w=1);var E=x*this.m_a1+C*this.m_a2,I=y+v+x*this.m_a1*this.m_a1+C*this.m_a2*this.m_a2;if(this.m_K.ex.Set(T,b,S),this.m_K.ey.Set(b,w,E),this.m_K.ez.Set(S,E,I),this.m_enableLimit){var R=u(this.m_axis,g);ri(this.m_upperTranslation-this.m_lowerTranslation)<2*Ue?this.m_limitState=de.e_equalLimits:R<=this.m_lowerTranslation?this.m_limitState!=de.e_atLowerLimit&&(this.m_limitState=de.e_atLowerLimit,this.m_impulse.z=0):R>=this.m_upperTranslation?this.m_limitState!=de.e_atUpperLimit&&(this.m_limitState=de.e_atUpperLimit,this.m_impulse.z=0):(this.m_limitState=de.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=de.e_inactiveLimit,this.m_impulse.z=0;if(0==this.m_enableMotor&&(this.m_motorImpulse=0),t.step.warmStarting){this.m_impulse.Multiply(t.step.dtRatio),this.m_motorImpulse*=t.step.dtRatio;var P=r.Add(r.Multiply(this.m_impulse.x,this.m_perp),r.Multiply(this.m_motorImpulse+this.m_impulse.z,this.m_axis)),O=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1,B=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2;n.Subtract(r.Multiply(y,P)),s-=x*O,h.Add(r.Multiply(v,P)),l+=C*B}else this.m_impulse.SetZero(),this.m_motorImpulse=0;t.velocities[this.m_indexA].v.Assign(n),t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].v.Assign(h),t.velocities[this.m_indexB].w=l},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),o=t.velocities[this.m_indexB].w,a=this.m_invMassA,c=this.m_invMassB,h=this.m_invIA,l=this.m_invIB;if(this.m_enableMotor&&this.m_limitState!=de.e_equalLimits){var _=u(this.m_axis,r.Subtract(n,e))+this.m_a2*o-this.m_a1*i,d=this.m_motorMass*(this.m_motorSpeed-_),f=this.m_motorImpulse,p=t.step.dt*this.m_maxMotorForce;this.m_motorImpulse=B(this.m_motorImpulse+d,-p,p),d=this.m_motorImpulse-f;var m=r.Multiply(d,this.m_axis),g=d*this.m_a1,y=d*this.m_a2;e.Subtract(r.Multiply(a,m)),i-=h*g,n.Add(r.Multiply(c,m)),o+=l*y}var v=new r;if(v.x=u(this.m_perp,r.Subtract(n,e))+this.m_s2*o-this.m_s1*i,v.y=o-i,this.m_enableLimit&&this.m_limitState!=de.e_inactiveLimit){var x;x=u(this.m_axis,r.Subtract(n,e))+this.m_a2*o-this.m_a1*i;_=new s(v.x,v.y,x);var C=this.m_impulse.Clone(),T=this.m_K.Solve33(_.Negate());this.m_impulse.Add(T),this.m_limitState==de.e_atLowerLimit?this.m_impulse.z=oi(this.m_impulse.z,0):this.m_limitState==de.e_atUpperLimit&&(this.m_impulse.z=si(this.m_impulse.z,0));var b=r.Subtract(v.Negate(),r.Multiply(this.m_impulse.z-C.z,new r(this.m_K.ez.x,this.m_K.ez.y))),A=r.Add(this.m_K.Solve22(b),new r(C.x,C.y));this.m_impulse.x=A.x,this.m_impulse.y=A.y,T=s.Subtract(this.m_impulse,C);m=r.Add(r.Multiply(T.x,this.m_perp),r.Multiply(T.z,this.m_axis)),g=T.x*this.m_s1+T.y+T.z*this.m_a1,y=T.x*this.m_s2+T.y+T.z*this.m_a2;e.Subtract(r.Multiply(a,m)),i-=h*g,n.Add(r.Multiply(c,m)),o+=l*y}else{T=this.m_K.Solve22(v.Negate());this.m_impulse.x+=T.x,this.m_impulse.y+=T.y;m=r.Multiply(T.x,this.m_perp),g=T.x*this.m_s1+T.y,y=T.x*this.m_s2+T.y;e.Subtract(r.Multiply(a,m)),i-=h*g,n.Add(r.Multiply(c,m)),o+=l*y}t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=o},SolvePositionConstraints:function(t){var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.positions[this.m_indexB].c.Clone(),h=t.positions[this.m_indexB].a,l=new c(i),d=new c(h),f=this.m_invMassA,p=this.m_invMassB,m=this.m_invIA,g=this.m_invIB,y=A(l,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),v=A(d,r.Subtract(this.m_localAnchorB,this.m_localCenterB)),x=r.Subtract(r.Subtract(r.Add(n,v),e),y),C=A(l,this.m_localXAxisA),T=_(r.Add(x,y),C),b=_(v,C),S=A(l,this.m_localYAxisA),w=_(r.Add(x,y),S),E=_(v,S),I=new s,R=new r;R.x=u(S,x),R.y=h-i-this.m_referenceAngle;var P=ri(R.x),O=ri(R.y),D=!1,M=0;if(this.m_enableLimit){var L=u(C,x);ri(this.m_upperTranslation-this.m_lowerTranslation)<2*Ue?(M=B(L,-.2,.2),P=oi(P,ri(L)),D=!0):L<=this.m_lowerTranslation?(M=B(L-this.m_lowerTranslation+Ue,-.2,0),P=oi(P,this.m_lowerTranslation-L),D=!0):L>=this.m_upperTranslation&&(M=B(L-this.m_upperTranslation-Ue,0,.2),P=oi(P,L-this.m_upperTranslation),D=!0)}if(D){var N=f+p+m*w*w+g*E*E,F=m*w+g*E,k=m*w*T+g*E*b;0==(W=m+g)&&(W=1);var z=m*T+g*b,V=f+p+m*T*T+g*b*b;(U=new a).ex.Set(N,F,k),U.ey.Set(F,W,z),U.ez.Set(k,z,V);var G=new s;G.x=R.x,G.y=R.y,G.z=M,I=U.Solve33(G.Negate())}else{var W;N=f+p+m*w*w+g*E*E,F=m*w+g*E;0==(W=m+g)&&(W=1);var U;(U=new o).ex.Set(N,F),U.ey.Set(F,W);var j=U.Solve(R.Negate());I.x=j.x,I.y=j.y,I.z=0}var X=r.Add(r.Multiply(I.x,S),r.Multiply(I.z,C)),Y=I.x*w+I.y+I.z*T,H=I.x*E+I.y+I.z*b;return e.Subtract(r.Multiply(f,X)),i-=m*Y,n.Add(r.Multiply(p,X)),h+=g*H,t.positions[this.m_indexA].c.Assign(e),t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].c.Assign(n),t.positions[this.m_indexB].a=h,P<=Ue&&O<=je},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.localAnchorA=this.m_localAnchorA._serialize(),e.localAnchorB=this.m_localAnchorB._serialize(),e.localAxisA=this.m_localXAxisA._serialize(),e.referenceAngle=this.m_referenceAngle,e.enableLimit=this.m_enableLimit,e.lowerTranslation=this.m_lowerTranslation,e.upperTranslation=this.m_upperTranslation,e.enableMotor=this.m_enableMotor,e.maxMotorForce=this.m_maxMotorForce,e.motorSpeed=this.m_motorSpeed,e}},Ce._extend(de),Te.prototype={Initialize:function(t,e,i){this.bodyA=t,this.bodyB=e,this.localAnchorA.Assign(this.bodyA.GetLocalPoint(i)),this.localAnchorB.Assign(this.bodyB.GetLocalPoint(i))},_deserialize:function(t,e,i){this.parent.prototype._deserialize.call(this,t,e,i),this.localAnchorA._deserialize(t.localAnchorA),this.localAnchorB._deserialize(t.localAnchorB),this.maxForce=t.maxForce,this.maxTorque=t.maxTorque}},Te._extend(_e),be.prototype={GetAnchorA:function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},GetAnchorB:function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},GetReactionForce:function(t){return r.Multiply(t,this.m_linearImpulse)},GetReactionTorque:function(t){return t*this.m_angularImpulse},GetLocalAnchorA:function(){return this.m_localAnchorA},GetLocalAnchorB:function(){return this.m_localAnchorB},SetMaxForce:function(e){t(n(e)&&e>=0),this.m_maxForce=e},GetMaxForce:function(){return this.m_maxForce},SetMaxTorque:function(e){t(n(e)&&e>=0),this.m_maxTorque=e},GetMaxTorque:function(){return this.m_maxTorque},InitVelocityConstraints:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Assign(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Assign(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].a,i=t.velocities[this.m_indexA].v.Clone(),n=t.velocities[this.m_indexA].w,s=t.positions[this.m_indexB].a,a=t.velocities[this.m_indexB].v.Clone(),h=t.velocities[this.m_indexB].w,l=new c(e),u=new c(s);this.m_rA=A(l,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),this.m_rB=A(u,r.Subtract(this.m_localAnchorB,this.m_localCenterB));var d=this.m_invMassA,f=this.m_invMassB,p=this.m_invIA,m=this.m_invIB,g=new o;if(g.ex.x=d+f+p*this.m_rA.y*this.m_rA.y+m*this.m_rB.y*this.m_rB.y,g.ex.y=-p*this.m_rA.x*this.m_rA.y-m*this.m_rB.x*this.m_rB.y,g.ey.x=g.ex.y,g.ey.y=d+f+p*this.m_rA.x*this.m_rA.x+m*this.m_rB.x*this.m_rB.x,this.m_linearMass=g.GetInverse(),this.m_angularMass=p+m,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass),t.step.warmStarting){this.m_linearImpulse.Multiply(t.step.dtRatio),this.m_angularImpulse*=t.step.dtRatio;var y=new r(this.m_linearImpulse.x,this.m_linearImpulse.y);i.Subtract(r.Multiply(d,y)),n-=p*(_(this.m_rA,y)+this.m_angularImpulse),a.Add(r.Multiply(f,y)),h+=m*(_(this.m_rB,y)+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0;t.velocities[this.m_indexA].v.Assign(i),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].v.Assign(a),t.velocities[this.m_indexB].w=h},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),s=t.velocities[this.m_indexB].w,o=this.m_invMassA,a=this.m_invMassB,c=this.m_invIA,h=this.m_invIB,l=t.step.dt,u=s-i,d=-this.m_angularMass*u,m=this.m_angularImpulse,g=l*this.m_maxTorque;this.m_angularImpulse=B(this.m_angularImpulse+d,-g,g),i-=c*(d=this.m_angularImpulse-m);u=r.Add(n,r.Subtract(f(s+=h*d,this.m_rB),r.Subtract(e,f(i,this.m_rA)))),d=p(this.m_linearMass,u).Negate(),m=this.m_linearImpulse.Clone();this.m_linearImpulse.Add(d);g=l*this.m_maxForce;this.m_linearImpulse.LengthSquared()>g*g&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.Multiply(g)),d=r.Subtract(this.m_linearImpulse,m),e.Subtract(r.Multiply(o,d)),i-=c*_(this.m_rA,d),n.Add(r.Multiply(a,d)),s+=h*_(this.m_rB,d),t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=s},SolvePositionConstraints:function(t){return!0},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.localAnchorA=this.m_localAnchorA._serialize(),e.localAnchorB=this.m_localAnchorB._serialize(),e.maxForce=this.m_maxForce,e.maxTorque=this.m_maxTorque,e}},be._extend(de),Ae.prototype={Initialize:function(t,e,i){this.bodyA=t,this.bodyB=e,this.localAnchorA.Assign(this.bodyA.GetLocalPoint(i)),this.localAnchorB.Assign(this.bodyB.GetLocalPoint(i)),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()},_deserialize:function(t,e,i){this.parent.prototype._deserialize.call(this,t,e,i),this.localAnchorA._deserialize(t.localAnchorA),this.localAnchorB._deserialize(t.localAnchorB),this.referenceAngle=t.referenceAngle,this.frequencyHz=t.frequencyHz,this.dampingRatio=t.dampingRatio}},Ae._extend(_e),Se.prototype={GetAnchorA:function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},GetAnchorB:function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},GetReactionForce:function(t){var e=new r(this.m_impulse.x,this.m_impulse.y);return r.Multiply(t,e)},GetReactionTorque:function(t){return t*this.m_impulse.z},GetLocalAnchorA:function(){return this.m_localAnchorA},GetLocalAnchorB:function(){return this.m_localAnchorB},GetReferenceAngle:function(){return this.m_referenceAngle},SetFrequency:function(t){this.m_frequencyHz=t},GetFrequency:function(){return this.m_frequencyHz},SetDampingRatio:function(t){this.m_dampingRatio=t},GetDampingRatio:function(){return this.m_dampingRatio},InitVelocityConstraints:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Assign(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Assign(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].a,i=t.velocities[this.m_indexA].v.Clone(),n=t.velocities[this.m_indexA].w,s=t.positions[this.m_indexB].a,o=t.velocities[this.m_indexB].v.Clone(),h=t.velocities[this.m_indexB].w,l=new c(e),u=new c(s);this.m_rA.Assign(A(l,r.Subtract(this.m_localAnchorA,this.m_localCenterA))),this.m_rB.Assign(A(u,r.Subtract(this.m_localAnchorB,this.m_localCenterB)));var d=this.m_invMassA,f=this.m_invMassB,p=this.m_invIA,m=this.m_invIB,g=new a;if(g.ex.x=d+f+this.m_rA.y*this.m_rA.y*p+this.m_rB.y*this.m_rB.y*m,g.ey.x=-this.m_rA.y*this.m_rA.x*p-this.m_rB.y*this.m_rB.x*m,g.ez.x=-this.m_rA.y*p-this.m_rB.y*m,g.ex.y=g.ey.x,g.ey.y=d+f+this.m_rA.x*this.m_rA.x*p+this.m_rB.x*this.m_rB.x*m,g.ez.y=this.m_rA.x*p+this.m_rB.x*m,g.ex.z=g.ez.x,g.ey.z=g.ez.y,g.ez.z=p+m,this.m_frequencyHz>0){g.GetInverse22(this.m_mass);var y=p+m,v=y>0?1/y:0,x=s-e-this.m_referenceAngle,C=2*Ve*this.m_frequencyHz,T=2*v*this.m_dampingRatio*C,b=v*C*C,S=t.step.dt;this.m_gamma=S*(T+S*b),this.m_gamma=0!=this.m_gamma?1/this.m_gamma:0,this.m_bias=x*S*b*this.m_gamma,y+=this.m_gamma,this.m_mass.ez.z=0!=y?1/y:0}else 0==g.ez.z?(g.GetInverse22(this.m_mass),this.m_gamma=0,this.m_bias=0):(g.GetSymInverse33(this.m_mass),this.m_gamma=0,this.m_bias=0);if(t.step.warmStarting){this.m_impulse.Multiply(t.step.dtRatio);var w=new r(this.m_impulse.x,this.m_impulse.y);i.Subtract(r.Multiply(d,w)),n-=p*(_(this.m_rA,w)+this.m_impulse.z),o.Add(r.Multiply(f,w)),h+=m*(_(this.m_rB,w)+this.m_impulse.z)}else this.m_impulse.SetZero();t.velocities[this.m_indexA].v.Assign(i),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].v.Assign(o),t.velocities[this.m_indexB].w=h},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),o=t.velocities[this.m_indexB].w,a=this.m_invMassA,c=this.m_invMassB,h=this.m_invIA,l=this.m_invIB;if(this.m_frequencyHz>0){var u=o-i,d=-this.m_mass.ez.z*(u+this.m_bias+this.m_gamma*this.m_impulse.z);this.m_impulse.z+=d,i-=h*d;var p=r.Subtract(r.Subtract(r.Add(n,f(o+=l*d,this.m_rB)),e),f(i,this.m_rA)),m=C(this.m_mass,p).Negate();this.m_impulse.x+=m.x,this.m_impulse.y+=m.y;var g=m.Clone();e.Subtract(r.Multiply(a,g)),i-=h*_(this.m_rA,g),n.Add(r.Multiply(c,g)),o+=l*_(this.m_rB,g)}else{u=o-i;var y=new s((p=r.Subtract(r.Subtract(r.Add(n,f(o,this.m_rB)),e),f(i,this.m_rA))).x,p.y,u),v=x(this.m_mass,y).Negate();this.m_impulse.Add(v);g=new r(v.x,v.y);e.Subtract(r.Multiply(a,g)),i-=h*(_(this.m_rA,g)+v.z),n.Add(r.Multiply(c,g)),o+=l*(_(this.m_rB,g)+v.z)}t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=o},SolvePositionConstraints:function(t){var e,i,n=t.positions[this.m_indexA].c.Clone(),o=t.positions[this.m_indexA].a,h=t.positions[this.m_indexB].c.Clone(),l=t.positions[this.m_indexB].a,u=new c(o),d=new c(l),f=this.m_invMassA,p=this.m_invMassB,m=this.m_invIA,g=this.m_invIB,y=A(u,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),v=A(d,r.Subtract(this.m_localAnchorB,this.m_localCenterB)),x=new a;if(x.ex.x=f+p+y.y*y.y*m+v.y*v.y*g,x.ey.x=-y.y*y.x*m-v.y*v.x*g,x.ez.x=-y.y*m-v.y*g,x.ex.y=x.ey.x,x.ey.y=f+p+y.x*y.x*m+v.x*v.x*g,x.ez.y=y.x*m+v.x*g,x.ex.z=x.ez.x,x.ey.z=x.ez.y,x.ez.z=m+g,this.m_frequencyHz>0){e=(T=r.Subtract(r.Subtract(r.Add(h,v),n),y)).Length(),i=0;var C=x.Solve22(T).Negate();n.Subtract(r.Multiply(f,C)),o-=m*_(y,C),h.Add(r.Multiply(p,C)),l+=g*_(v,C)}else{var T=r.Subtract(r.Subtract(r.Add(h,v),n),y),b=l-o-this.m_referenceAngle;e=T.Length(),i=ri(b);var S,w=new s(T.x,T.y,b);if(x.ez.z>0)S=x.Solve33(w).Invert();else{var E=x.Solve22(T).Invert();S=new s(E.x,E.y,0)}C=new r(S.x,S.y);n.Subtract(r.Multiply(f,C)),o-=m*(_(y,C)+S.z),h.Add(r.Multiply(p,C)),l+=g*(_(v,C)+S.z)}return t.positions[this.m_indexA].c.Assign(n),t.positions[this.m_indexA].a=o,t.positions[this.m_indexB].c.Assign(h),t.positions[this.m_indexB].a=l,e<=Ue&&i<=je},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.localAnchorA=this.m_localAnchorA._serialize(),e.localAnchorB=this.m_localAnchorB._serialize(),e.referenceAngle=this.m_referenceAngle,e.frequencyHz=this.m_frequencyHz,e.dampingRatio=this.m_dampingRatio,e}},Se._extend(de),we.prototype={Initialize:function(t,e,i,n){this.bodyA=t,this.bodyB=e,this.localAnchorA.Assign(this.bodyA.GetLocalPoint(i)),this.localAnchorB.Assign(this.bodyB.GetLocalPoint(i)),this.localAxisA.Assign(this.bodyA.GetLocalVector(n))},_deserialize:function(t,e,i){this.parent.prototype._deserialize.call(this,t,e,i),this.localAnchorA._deserialize(t.localAnchorA),this.localAnchorB._deserialize(t.localAnchorB),this.localAxisA._deserialize(t.localAxisA),this.enableMotor=t.enableMotor,this.maxMotorTorque=t.maxMotorTorque,this.motorSpeed=t.motorSpeed,this.frequencyHz=t.frequencyHz,this.dampingRatio=t.dampingRatio}},we._extend(_e),Ee.prototype={GetAnchorA:function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},GetAnchorB:function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},GetReactionForce:function(t){return r.Multiply(t,r.Add(r.Multiply(this.m_impulse,this.m_ay),r.Multiply(this.m_springImpulse,this.m_ax)))},GetReactionTorque:function(t){return t*this.m_motorImpulse},GetLocalAnchorA:function(){return this.m_localAnchorA},GetLocalAnchorB:function(){return this.m_localAnchorB},GetLocalAxisA:function(){return this.m_localXAxisA},GetJointTranslation:function(){var t=this.m_bodyA,e=this.m_bodyB,i=t.GetWorldPoint(this.m_localAnchorA),n=e.GetWorldPoint(this.m_localAnchorB);return u(r.Subtract(n,i),t.GetWorldVector(this.m_localXAxisA))},GetJointSpeed:function(){var t=this.m_bodyA.m_angularVelocity;return this.m_bodyB.m_angularVelocity-t},IsMotorEnabled:function(){return this.m_enableMotor},EnableMotor:function(t){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t},SetMotorSpeed:function(t){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t},GetMotorSpeed:function(){return this.m_motorSpeed},SetMaxMotorTorque:function(t){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorTorque=t},GetMaxMotorTorque:function(){return this.m_maxMotorTorque},GetMotorTorque:function(t){return t*this.m_motorImpulse},SetSpringFrequencyHz:function(t){this.m_frequencyHz=t},GetSpringFrequencyHz:function(){return this.m_frequencyHz},SetSpringDampingRatio:function(t){this.m_dampingRatio=t},GetSpringDampingRatio:function(){return this.m_dampingRatio},InitVelocityConstraints:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Assign(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Assign(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=this.m_invMassA,i=this.m_invMassB,n=this.m_invIA,s=this.m_invIB,o=t.positions[this.m_indexA].c.Clone(),a=t.positions[this.m_indexA].a,h=t.velocities[this.m_indexA].v.Clone(),l=t.velocities[this.m_indexA].w,d=t.positions[this.m_indexB].c.Clone(),f=t.positions[this.m_indexB].a,p=t.velocities[this.m_indexB].v.Clone(),m=t.velocities[this.m_indexB].w,g=new c(a),y=new c(f),v=A(g,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),x=A(y,r.Subtract(this.m_localAnchorB,this.m_localCenterB)),C=r.Subtract(r.Subtract(r.Add(d,x),o),v);if(this.m_ay.Assign(A(g,this.m_localYAxisA)),this.m_sAy=_(r.Add(C,v),this.m_ay),this.m_sBy=_(x,this.m_ay),this.m_mass=e+i+n*this.m_sAy*this.m_sAy+s*this.m_sBy*this.m_sBy,this.m_mass>0&&(this.m_mass=1/this.m_mass),this.m_springMass=0,this.m_bias=0,this.m_gamma=0,this.m_frequencyHz>0){this.m_ax.Assign(A(g,this.m_localXAxisA)),this.m_sAx=_(r.Add(C,v),this.m_ax),this.m_sBx=_(x,this.m_ax);var T=e+i+n*this.m_sAx*this.m_sAx+s*this.m_sBx*this.m_sBx;if(T>0){this.m_springMass=1/T;var b=u(C,this.m_ax),S=2*Ve*this.m_frequencyHz,w=(C=2*this.m_springMass*this.m_dampingRatio*S,this.m_springMass*S*S),E=t.step.dt;this.m_gamma=E*(C+E*w),this.m_gamma>0&&(this.m_gamma=1/this.m_gamma),this.m_bias=b*E*w*this.m_gamma,this.m_springMass=T+this.m_gamma,this.m_springMass>0&&(this.m_springMass=1/this.m_springMass)}}else this.m_springImpulse=0;if(this.m_enableMotor?(this.m_motorMass=n+s,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass)):(this.m_motorMass=0,this.m_motorImpulse=0),t.step.warmStarting){this.m_impulse*=t.step.dtRatio,this.m_springImpulse*=t.step.dtRatio,this.m_motorImpulse*=t.step.dtRatio;var I=r.Add(r.Multiply(this.m_impulse,this.m_ay),r.Multiply(this.m_springImpulse,this.m_ax)),R=this.m_impulse*this.m_sAy+this.m_springImpulse*this.m_sAx+this.m_motorImpulse,P=this.m_impulse*this.m_sBy+this.m_springImpulse*this.m_sBx+this.m_motorImpulse;h.Subtract(r.Multiply(this.m_invMassA,I)),l-=this.m_invIA*R,p.Add(r.Multiply(this.m_invMassB,I)),m+=this.m_invIB*P}else this.m_impulse=0,this.m_springImpulse=0,this.m_motorImpulse=0;t.velocities[this.m_indexA].v.Assign(h),t.velocities[this.m_indexA].w=l,t.velocities[this.m_indexB].v.Assign(p),t.velocities[this.m_indexB].w=m},SolveVelocityConstraints:function(t){var e=this.m_invMassA,i=this.m_invMassB,n=this.m_invIA,s=this.m_invIB,o=t.velocities[this.m_indexA].v.Clone(),a=t.velocities[this.m_indexA].w,c=t.velocities[this.m_indexB].v.Clone(),h=t.velocities[this.m_indexB].w,l=u(this.m_ax,r.Subtract(c,o))+this.m_sBx*h-this.m_sAx*a,_=-this.m_springMass*(l+this.m_bias+this.m_gamma*this.m_springImpulse);this.m_springImpulse+=_;var d=r.Multiply(_,this.m_ax),f=_*this.m_sAx,p=_*this.m_sBx;o.Subtract(r.Multiply(e,d)),a-=n*f,c.Add(r.Multiply(i,d));l=(h+=s*p)-a-this.m_motorSpeed,_=-this.m_motorMass*l;var m=this.m_motorImpulse,g=t.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=B(this.m_motorImpulse+_,-g,g),a-=n*(_=this.m_motorImpulse-m),h+=s*_;l=u(this.m_ay,r.Subtract(c,o))+this.m_sBy*h-this.m_sAy*a,_=-this.m_mass*l;this.m_impulse+=_;d=r.Multiply(_,this.m_ay),f=_*this.m_sAy,p=_*this.m_sBy;o.Subtract(r.Multiply(e,d)),a-=n*f,c.Add(r.Multiply(i,d)),h+=s*p,t.velocities[this.m_indexA].v.Assign(o),t.velocities[this.m_indexA].w=a,t.velocities[this.m_indexB].v.Assign(c),t.velocities[this.m_indexB].w=h},SolvePositionConstraints:function(t){var e,i=t.positions[this.m_indexA].c.Clone(),n=t.positions[this.m_indexA].a,s=t.positions[this.m_indexB].c.Clone(),o=t.positions[this.m_indexB].a,a=new c(n),h=new c(o),l=A(a,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),d=A(h,r.Subtract(this.m_localAnchorB,this.m_localCenterB)),f=r.Add(r.Subtract(s,i),r.Subtract(d,l)),p=A(a,this.m_localYAxisA),m=_(r.Add(f,l),p),g=_(d,p),y=u(f,p),v=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_sAy*this.m_sAy+this.m_invIB*this.m_sBy*this.m_sBy,x=r.Multiply(e=0!=v?-y/v:0,p),C=e*m,T=e*g;return i.Subtract(r.Multiply(this.m_invMassA,x)),n-=this.m_invIA*C,s.Add(r.Multiply(this.m_invMassB,x)),o+=this.m_invIB*T,t.positions[this.m_indexA].c.Assign(i),t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].c.Assign(s),t.positions[this.m_indexB].a=o,ri(y)<=Ue},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.localAnchorA=this.m_localAnchorA._serialize(),e.localAnchorB=this.m_localAnchorB._serialize(),e.localAxisA=this.m_localAxisA._serialize(),e.enableMotor=this.m_enableMotor,e.maxMotorTorque=this.m_maxMotorTorque,e.motorSpeed=this.m_motorSpeed,e.frequencyHz=this.m_frequencyHz,e.dampingRatio=this.m_dampingRatio,e}},Ee._extend(de),Ie.prototype={_deserialize:function(t,e,i){this.parent.prototype._deserialize.call(this,t,e,i),this.joint1=t.joint1,this.joint2=t.joint2,this.ratio=t.ratio}},Ie._extend(_e),Re.prototype={GetAnchorA:function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},GetAnchorB:function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},GetReactionForce:function(t){var e=r.Multiply(this.m_impulse,this.m_JvAC);return r.Multiply(t,e)},GetReactionTorque:function(t){return t*(this.m_impulse*this.m_JwA)},GetJoint1:function(){return this.m_joint1},GetJoint2:function(){return this.m_joint2},SetRatio:function(e){t(n(e)),this.m_ratio=e},GetRatio:function(){return this.m_ratio},InitVelocityConstraints:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_indexC=this.m_bodyC.m_islandIndex,this.m_indexD=this.m_bodyD.m_islandIndex,this.m_lcA.Assign(this.m_bodyA.m_sweep.localCenter),this.m_lcB.Assign(this.m_bodyB.m_sweep.localCenter),this.m_lcC.Assign(this.m_bodyC.m_sweep.localCenter),this.m_lcD.Assign(this.m_bodyD.m_sweep.localCenter),this.m_mA=this.m_bodyA.m_invMass,this.m_mB=this.m_bodyB.m_invMass,this.m_mC=this.m_bodyC.m_invMass,this.m_mD=this.m_bodyD.m_invMass,this.m_iA=this.m_bodyA.m_invI,this.m_iB=this.m_bodyB.m_invI,this.m_iC=this.m_bodyC.m_invI,this.m_iD=this.m_bodyD.m_invI;var e=t.positions[this.m_indexA].a,i=t.velocities[this.m_indexA].v.Clone(),n=t.velocities[this.m_indexA].w,s=t.positions[this.m_indexB].a,o=t.velocities[this.m_indexB].v.Clone(),a=t.velocities[this.m_indexB].w,h=t.positions[this.m_indexC].a,l=t.velocities[this.m_indexC].v.Clone(),u=t.velocities[this.m_indexC].w,d=t.positions[this.m_indexD].a,f=t.velocities[this.m_indexD].v.Clone(),p=t.velocities[this.m_indexD].w,m=new c(e),g=new c(s),y=new c(h),v=new c(d);if(this.m_mass=0,this.m_typeA==de.e_revoluteJoint)this.m_JvAC.SetZero(),this.m_JwA=1,this.m_JwC=1,this.m_mass+=this.m_iA+this.m_iC;else{var x=A(y,this.m_localAxisC),C=A(y,r.Subtract(this.m_localAnchorC,this.m_lcC)),T=A(m,r.Subtract(this.m_localAnchorA,this.m_lcA));this.m_JvAC.Assign(x),this.m_JwC=_(C,x),this.m_JwA=_(T,x),this.m_mass+=this.m_mC+this.m_mA+this.m_iC*this.m_JwC*this.m_JwC+this.m_iA*this.m_JwA*this.m_JwA}if(this.m_typeB==de.e_revoluteJoint)this.m_JvBD.SetZero(),this.m_JwB=this.m_ratio,this.m_JwD=this.m_ratio,this.m_mass+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD);else{x=A(v,this.m_localAxisD);var b=A(v,r.Subtract(this.m_localAnchorD,this.m_lcD)),S=A(g,r.Subtract(this.m_localAnchorB,this.m_lcB));this.m_JvBD.Assign(r.Multiply(this.m_ratio,x)),this.m_JwD=this.m_ratio*_(b,x),this.m_JwB=this.m_ratio*_(S,x),this.m_mass+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*this.m_JwD*this.m_JwD+this.m_iB*this.m_JwB*this.m_JwB}this.m_mass=this.m_mass>0?1/this.m_mass:0,t.step.warmStarting?(i.Add(r.Multiply(this.m_mA*this.m_impulse,this.m_JvAC)),n+=this.m_iA*this.m_impulse*this.m_JwA,o.Add(r.Multiply(this.m_mB*this.m_impulse,this.m_JvBD)),a+=this.m_iB*this.m_impulse*this.m_JwB,l.Subtract(r.Multiply(this.m_mC*this.m_impulse,this.m_JvAC)),u-=this.m_iC*this.m_impulse*this.m_JwC,f.Subtract(r.Multiply(this.m_mD*this.m_impulse,this.m_JvBD)),p-=this.m_iD*this.m_impulse*this.m_JwD):this.m_impulse=0,t.velocities[this.m_indexA].v.Assign(i),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].v.Assign(o),t.velocities[this.m_indexB].w=a,t.velocities[this.m_indexC].v.Assign(l),t.velocities[this.m_indexC].w=u,t.velocities[this.m_indexD].v.Assign(f),t.velocities[this.m_indexD].w=p},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),s=t.velocities[this.m_indexB].w,o=t.velocities[this.m_indexC].v.Clone(),a=t.velocities[this.m_indexC].w,c=t.velocities[this.m_indexD].v.Clone(),h=t.velocities[this.m_indexD].w,l=u(this.m_JvAC,r.Subtract(e,o))+u(this.m_JvBD,r.Subtract(n,c));l+=this.m_JwA*i-this.m_JwC*a+(this.m_JwB*s-this.m_JwD*h);var _=-this.m_mass*l;this.m_impulse+=_,e.Add(r.Multiply(this.m_mA*_,this.m_JvAC)),i+=this.m_iA*_*this.m_JwA,n.Add(r.Multiply(this.m_mB*_,this.m_JvBD)),s+=this.m_iB*_*this.m_JwB,o.Subtract(r.Multiply(this.m_mC*_,this.m_JvAC)),a-=this.m_iC*_*this.m_JwC,c.Subtract(r.Multiply(this.m_mD*_,this.m_JvBD)),h-=this.m_iD*_*this.m_JwD,t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=s,t.velocities[this.m_indexC].v.Assign(o),t.velocities[this.m_indexC].w=a,t.velocities[this.m_indexD].v.Assign(c),t.velocities[this.m_indexD].w=h},SolvePositionConstraints:function(t){var e,i,n,s,o,a,h=t.positions[this.m_indexA].c.Clone(),l=t.positions[this.m_indexA].a,d=t.positions[this.m_indexB].c.Clone(),f=t.positions[this.m_indexB].a,p=t.positions[this.m_indexC].c.Clone(),m=t.positions[this.m_indexC].a,g=t.positions[this.m_indexD].c.Clone(),y=t.positions[this.m_indexD].a,v=new c(l),x=new c(f),C=new c(m),T=new c(y),b=new r,w=new r,E=0;if(this.m_typeA==de.e_revoluteJoint)b.SetZero(),n=1,o=1,E+=this.m_iA+this.m_iC,e=l-m-this.m_referenceAngleA;else{var I=A(C,this.m_localAxisC),R=A(C,r.Subtract(this.m_localAnchorC,this.m_lcC)),P=A(v,r.Subtract(this.m_localAnchorA,this.m_lcA));b.Assign(I),o=_(R,I),n=_(P,I),E+=this.m_mC+this.m_mA+this.m_iC*o*o+this.m_iA*n*n;var O=r.Subtract(this.m_localAnchorC,this.m_lcC),B=S(C,r.Add(P,r.Subtract(h,p)));e=u(r.Subtract(B,O),this.m_localAxisC)}if(this.m_typeB==de.e_revoluteJoint)w.SetZero(),s=this.m_ratio,a=this.m_ratio,E+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD),i=f-y-this.m_referenceAngleB;else{I=A(T,this.m_localAxisD);var D=A(T,r.Subtract(this.m_localAnchorD,this.m_lcD)),M=A(x,r.Subtract(this.m_localAnchorB,this.m_lcB));w.Assign(r.Multiply(this.m_ratio,I)),a=this.m_ratio*_(D,I),s=this.m_ratio*_(M,I),E+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*a*a+this.m_iB*s*s;var L=r.Subtract(this.m_localAnchorD,this.m_lcD),N=S(T,r.Add(M,r.Subtract(d,g)));i=u(r.Subtract(N,L),this.m_localAxisD)}var F=e+this.m_ratio*i-this.m_constant,k=0;return E>0&&(k=-F/E),h.Add(r.Multiply(this.m_mA,r.Multiply(k,b))),l+=this.m_iA*k*n,d.Add(r.Multiply(this.m_mB,r.Multiply(k,w))),f+=this.m_iB*k*s,p.Subtract(r.Multiply(this.m_mC,r.Multiply(k,b))),m-=this.m_iC*k*o,g.Subtract(r.Multiply(this.m_mD,r.Multiply(k,w))),y-=this.m_iD*k*a,t.positions[this.m_indexA].c.Assign(h),t.positions[this.m_indexA].a=l,t.positions[this.m_indexB].c.Assign(d),t.positions[this.m_indexB].a=f,t.positions[this.m_indexC].c.Assign(p),t.positions[this.m_indexC].a=m,t.positions[this.m_indexD].c.Assign(g),t.positions[this.m_indexD].a=y,0=0),this.m_maxForce=e},GetMaxForce:function(){return this.m_maxForce},SetMaxTorque:function(e){t(n(e)&&e>=0),this.m_maxTorque=e},GetMaxTorque:function(){return this.m_maxTorque},SetCorrectionFactor:function(e){t(n(e)&&0<=e&&e<=1),this.m_correctionFactor=e},GetCorrectionFactor:function(){return this.m_correctionFactor},InitVelocityConstraints:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Assign(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Assign(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.velocities[this.m_indexA].v.Clone(),s=t.velocities[this.m_indexA].w,a=t.positions[this.m_indexB].c.Clone(),h=t.positions[this.m_indexB].a,l=t.velocities[this.m_indexB].v.Clone(),u=t.velocities[this.m_indexB].w,d=new c(i),f=new c(h);this.m_rA.Assign(A(d,this.m_localCenterA.Negate())),this.m_rB.Assign(A(f,this.m_localCenterB.Negate()));var p=this.m_invMassA,m=this.m_invMassB,g=this.m_invIA,y=this.m_invIB,v=new o;if(v.ex.x=p+m+g*this.m_rA.y*this.m_rA.y+y*this.m_rB.y*this.m_rB.y,v.ex.y=-g*this.m_rA.x*this.m_rA.y-y*this.m_rB.x*this.m_rB.y,v.ey.x=v.ex.y,v.ey.y=p+m+g*this.m_rA.x*this.m_rA.x+y*this.m_rB.x*this.m_rB.x,this.m_linearMass.Assign(v.GetInverse()),this.m_angularMass=g+y,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass),this.m_linearError.x=a.x+this.m_rB.x-e.x-this.m_rA.x-(d.c*this.m_linearOffset.x-d.s*this.m_linearOffset.y),this.m_linearError.y=a.y+this.m_rB.y-e.y-this.m_rA.y-(d.s*this.m_linearOffset.x+d.c*this.m_linearOffset.y),this.m_angularError=h-i-this.m_angularOffset,t.step.warmStarting){this.m_linearImpulse.Multiply(t.step.dtRatio),this.m_angularImpulse*=t.step.dtRatio;var x=new r(this.m_linearImpulse.x,this.m_linearImpulse.y);n.Subtract(r.Multiply(p,x)),s-=g*(_(this.m_rA,x)+this.m_angularImpulse),l.Add(r.Multiply(m,x)),u+=y*(_(this.m_rB,x)+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0;t.velocities[this.m_indexA].v.Assign(n),t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].v.Assign(l),t.velocities[this.m_indexB].w=u},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),s=t.velocities[this.m_indexB].w,o=this.m_invMassA,a=this.m_invMassB,c=this.m_invIA,h=this.m_invIB,l=t.step.dt,u=t.step.inv_dt,d=s-i+u*this.m_correctionFactor*this.m_angularError,f=-this.m_angularMass*d,m=this.m_angularImpulse,g=l*this.m_maxTorque;this.m_angularImpulse=B(this.m_angularImpulse+f,-g,g),i-=c*(f=this.m_angularImpulse-m),s+=h*f;d=new r(n.x+-s*this.m_rB.x-e.x- -i*this.m_rA.x+u*this.m_correctionFactor*this.m_linearError.x,n.y+s*this.m_rB.y-e.y-i*this.m_rA.y+u*this.m_correctionFactor*this.m_linearError.y),f=p(this.m_linearMass,d).Negate(),m=this.m_linearImpulse.Clone();this.m_linearImpulse.Add(f);g=l*this.m_maxForce;this.m_linearImpulse.LengthSquared()>g*g&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.Multiply(g)),f.Assign(r.Subtract(this.m_linearImpulse,m)),e.Subtract(r.Multiply(o,f)),i-=c*_(this.m_rA,f),n.Add(r.Multiply(a,f)),s+=h*_(this.m_rB,f),t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=s},SolvePositionConstraints:function(t){return!0},_serialize:function(t){var e=t||{};return this.parent.prototype._serialize.call(this,e),e.linearOffset=this.m_linearOffset._serialize(),e.angularOffset=this.m_angularOffset,e.maxForce=this.m_maxForce,e.maxTorque=this.m_maxTorque,e.correctionFactor=this.m_correctionFactor,e}},Oe._extend(de);Be.prototype={Initialize:function(e,i,n,s,o,a,c){this.bodyA=e,this.bodyB=i,this.groundAnchorA.Assign(n),this.groundAnchorB.Assign(s),this.localAnchorA.Assign(this.bodyA.GetLocalPoint(o)),this.localAnchorB.Assign(this.bodyB.GetLocalPoint(a));var h=r.Subtract(o,n);this.lengthA=h.Length();var l=r.Subtract(a,s);this.lengthB=l.Length(),this.ratio=c,t(this.ratio>ze)},_deserialize:function(t,e,i){this.parent.prototype._deserialize.call(this,t,e,i),this.groundAnchorA._deserialize(t.groundAnchorA),this.groundAnchorB._deserialize(t.groundAnchorB),this.localAnchorA._deserialize(t.localAnchorA),this.localAnchorB._deserialize(t.localAnchorB),this.lengthA=t.lengthA,this.lengthB=t.lengthB,this.ratio=t.ratio}},Be._extend(_e),De.prototype={GetAnchorA:function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},GetAnchorB:function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},GetReactionForce:function(t){var e=r.Multiply(this.m_impulse,this.m_uB);return r.Multiply(t,e)},GetReactionTorque:function(t){return 0},GetGroundAnchorA:function(){return this.m_groundAnchorA},GetGroundAnchorB:function(){return this.m_groundAnchorB},GetLengthA:function(){return this.m_lengthA},GetLengthB:function(){return this.m_lengthB},GetRatio:function(){return this.m_ratio},GetCurrentLengthA:function(){var t=this.m_bodyA.GetWorldPoint(this.m_localAnchorA),e=this.m_groundAnchorA;return r.Subtract(t,e).Length()},GetCurrentLengthB:function(){var t=this.m_bodyB.GetWorldPoint(this.m_localAnchorB),e=this.m_groundAnchorB;return r.Subtract(t,e).Length()},ShiftOrigin:function(t){this.m_groundAnchorA.Subtract(t),this.m_groundAnchorB.Subtract(t)},InitVelocityConstraints:function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Assign(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Assign(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.velocities[this.m_indexA].v.Clone(),s=t.velocities[this.m_indexA].w,o=t.positions[this.m_indexB].c.Clone(),a=t.positions[this.m_indexB].a,h=t.velocities[this.m_indexB].v.Clone(),l=t.velocities[this.m_indexB].w,u=new c(i),d=new c(a);this.m_rA.Assign(A(u,r.Subtract(this.m_localAnchorA,this.m_localCenterA))),this.m_rB.Assign(A(d,r.Subtract(this.m_localAnchorB,this.m_localCenterB))),this.m_uA.Assign(r.Add(e,r.Subtract(this.m_rA,this.m_groundAnchorA))),this.m_uB.Assign(r.Add(o,r.Subtract(this.m_rB,this.m_groundAnchorB)));var f=this.m_uA.Length(),p=this.m_uB.Length();f>10*Ue?this.m_uA.Multiply(1/f):this.m_uA.SetZero(),p>10*Ue?this.m_uB.Multiply(1/p):this.m_uB.SetZero();var m=_(this.m_rA,this.m_uA),g=_(this.m_rB,this.m_uB),y=this.m_invMassA+this.m_invIA*m*m,v=this.m_invMassB+this.m_invIB*g*g;if(this.m_mass=y+this.m_ratio*this.m_ratio*v,this.m_mass>0&&(this.m_mass=1/this.m_mass),t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var x=r.Multiply(-this.m_impulse,this.m_uA),C=r.Multiply(-this.m_ratio*this.m_impulse,this.m_uB);n.Add(r.Multiply(this.m_invMassA,x)),s+=this.m_invIA*_(this.m_rA,x),h.Add(r.Multiply(this.m_invMassB,C)),l+=this.m_invIB*_(this.m_rB,C)}else this.m_impulse=0;t.velocities[this.m_indexA].v.Assign(n),t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].v.Assign(h),t.velocities[this.m_indexB].w=l},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),s=t.velocities[this.m_indexB].w,o=r.Add(e,f(i,this.m_rA)),a=r.Add(n,f(s,this.m_rB)),c=-u(this.m_uA,o)-this.m_ratio*u(this.m_uB,a),h=-this.m_mass*c;this.m_impulse+=h;var l=r.Multiply(-h,this.m_uA),d=r.Multiply(-this.m_ratio,r.Multiply(h,this.m_uB));e.Add(r.Multiply(this.m_invMassA,l)),i+=this.m_invIA*_(this.m_rA,l),n.Add(r.Multiply(this.m_invMassB,d)),s+=this.m_invIB*_(this.m_rB,d),t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=s},SolvePositionConstraints:function(t){var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.positions[this.m_indexB].c.Clone(),s=t.positions[this.m_indexB].a,o=new c(i),a=new c(s),h=A(o,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),l=A(a,r.Subtract(this.m_localAnchorB,this.m_localCenterB)),u=r.Add(e,r.Subtract(h,this.m_groundAnchorA)),d=r.Add(n,r.Subtract(l,this.m_groundAnchorB)),f=u.Length(),p=d.Length();f>10*Ue?u.Multiply(1/f):u.SetZero(),p>10*Ue?d.Multiply(1/p):d.SetZero();var m=_(h,u),g=_(l,d),y=this.m_invMassA+this.m_invIA*m*m,v=this.m_invMassB+this.m_invIB*g*g,x=y+this.m_ratio*this.m_ratio*v;x>0&&(x=1/x);var C=this.m_constant-f-this.m_ratio*p,T=ri(C),b=-x*C,S=r.Multiply(-b,u),w=r.Multiply(-this.m_ratio,r.Multiply(b,d));return e.Add(r.Multiply(this.m_invMassA,S)),i+=this.m_invIA*_(h,S),n.Add(r.Multiply(this.m_invMassB,w)),s+=this.m_invIB*_(l,w),t.positions[this.m_indexA].c.Assign(e),t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].c.Assign(n),t.positions[this.m_indexB].a=s,T0?de.e_atUpperLimit:de.e_inactiveLimit,!(this.m_length>Ue))return this.m_u.SetZero(),this.m_mass=0,void(this.m_impulse=0);this.m_u.Multiply(1/this.m_length);var p=_(this.m_rA,this.m_u),m=_(this.m_rB,this.m_u),g=this.m_invMassA+this.m_invIA*p*p+this.m_invMassB+this.m_invIB*m*m;if(this.m_mass=0!=g?1/g:0,t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var y=r.Multiply(this.m_impulse,this.m_u);n.Subtract(r.Multiply(this.m_invMassA,y)),s-=this.m_invIA*_(this.m_rA,y),h.Add(r.Multiply(this.m_invMassB,y)),l+=this.m_invIB*_(this.m_rB,y)}else this.m_impulse=0;t.velocities[this.m_indexA].v.Assign(n),t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].v.Assign(h),t.velocities[this.m_indexB].w=l},SolveVelocityConstraints:function(t){var e=t.velocities[this.m_indexA].v.Clone(),i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v.Clone(),s=t.velocities[this.m_indexB].w,o=r.Add(e,f(i,this.m_rA)),a=r.Add(n,f(s,this.m_rB)),c=this.m_length-this.m_maxLength,h=u(this.m_u,r.Subtract(a,o));c<0&&(h+=t.step.inv_dt*c);var l=-this.m_mass*h,d=this.m_impulse;this.m_impulse=si(0,this.m_impulse+l),l=this.m_impulse-d;var p=r.Multiply(l,this.m_u);e.Subtract(r.Multiply(this.m_invMassA,p)),i-=this.m_invIA*_(this.m_rA,p),n.Add(r.Multiply(this.m_invMassB,p)),s+=this.m_invIB*_(this.m_rB,p),t.velocities[this.m_indexA].v.Assign(e),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].v.Assign(n),t.velocities[this.m_indexB].w=s},SolvePositionConstraints:function(t){var e=t.positions[this.m_indexA].c.Clone(),i=t.positions[this.m_indexA].a,n=t.positions[this.m_indexB].c.Clone(),s=t.positions[this.m_indexB].a,o=new c(i),a=new c(s),h=A(o,r.Subtract(this.m_localAnchorA,this.m_localCenterA)),l=A(a,r.Subtract(this.m_localAnchorB,this.m_localCenterB)),u=r.Subtract(r.Subtract(r.Add(n,l),e),h),d=u.Normalize(),f=d-this.m_maxLength;f=B(f,0,.2);var p=-this.m_mass*f,m=r.Multiply(p,u);return e.Subtract(r.Multiply(this.m_invMassA,m)),i-=this.m_invIA*_(h,m),n.Add(r.Multiply(this.m_invMassB,m)),s+=this.m_invIB*_(l,m),t.positions[this.m_indexA].c.Assign(e),t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].c.Assign(n),t.positions[this.m_indexB].a=s,d-this.m_maxLength=3),this.m_count=e.count,this.m_ps=new Array(this.m_count),this.m_p0s=new Array(this.m_count),this.m_vs=new Array(this.m_count),this.m_ims=new Array(this.m_count);for(var i=0;i0?1/n:0}var s=this.m_count-1,o=this.m_count-2;this.m_Ls=new Array(s),this.m_as=new Array(o);for(i=0;i0&&this.m_vs[n].Add(r.Multiply(t,this.m_gravity)),this.m_vs[n].Multiply(i),this.m_ps[n].Add(r.Multiply(t,this.m_vs[n]));for(n=0;nVe;)A=(g-=2*Ve)-this.m_as[e];for(;A<-Ve;)A=(g+=2*Ve)-this.m_as[e];var S=-this.m_k3*b*A;i.Add(r.Multiply(o*S,x)),n.Add(r.Multiply(a*S,C)),s.Add(r.Multiply(c*S,T))}}}}};var Ei={serialize:function(t){var e,i,n,r,s,o=[];for(n=t.GetBodyList();n;n=n.GetNext())for(r=n.GetFixtureList();r;r=r.GetNext())s=r.GetShape(),r.__temp_shape_id=o.length,o.push(s._serialize());var a=[];for(n=t.GetBodyList();n;n=n.GetNext())for(n.__temp_fixture_ids=[],r=n.GetFixtureList();r;r=r.GetNext())(i=r._serialize()).shape=r.__temp_shape_id,delete r.__temp_shape_id,n.__temp_fixture_ids.push(a.length),a.push(i);var c=[];for(n=t.GetBodyList();n;n=n.GetNext()){for((i=n._serialize()).fixtures=[],e=0;e>1,t|=t>>2,t|=t>>4,t|=t>>8,1+(t|=t>>16)}},{trimmed:"Abs_v2",name:"b2Abs_v2",def:R},{trimmed:"Abs_m22",name:"b2Abs_m22",def:function(t){return new o(R(t.ex),R(t.ey))}},{trimmed:"IsPowerOfTwo",name:"b2IsPowerOfTwo",def:function(t){return t>0&&0==(t&t-1)}},{trimmed:"RandomFloat",name:"b2RandomFloat",def:function(t,e){var i=Math.random();return i=void 0!==t?(e-t)*i+t:2*i-1}},{trimmed:"Timer",name:"b2Timer",def:L},{trimmed:"Color",name:"b2Color",def:D},{trimmed:"Draw",name:"b2Draw",def:M},{trimmed:"ContactID",name:"b2ContactID",def:K},{trimmed:"ManifoldPoint",name:"b2ManifoldPoint",def:$},{trimmed:"Manifold",name:"b2Manifold",def:tt},{trimmed:"WorldManifold",name:"b2WorldManifold",def:et},{trimmed:"GetPointStates",name:"b2GetPointStates",def:function(t,e,i,n){for(var r=0;re?t:e};"object"==typeof window&&window.navigator.userAgent.indexOf("Firefox")>-1?(n=Math.min,r=Math.max):(n=a,r=c);var h=function(t,e){return t>1,c=1;cn||h==n&&l>r)&&(n=h,r=l,o=c)}return[s,o]},d=function(t,e,i){var n=t[2*e];t[2*e]=t[2*i],t[2*i]=n,n=t[2*e+1],t[2*e+1]=t[2*i+1],t[2*i+1]=n},f=function(t,e,i,n,r,s){if(0===i)return 0;for(var o=0,a=e,c=S(r,n),h=s*T(c),l=e,u=e+i-1;l<=u;){var _=new y(t[2*l],t[2*l+1]),f=I(c,S(_,n));f>h?(f>o&&(o=f,a=l),l++):(d(t,l,u),u--)}return a!=e&&d(t,e,a),l-e},p=function(t,e,i,n,r,s,o,a){if(n<0)return 0;if(0==n)return e[2*a]=s.x,e[2*a+1]=s.y,1;var c=f(e,i,n,r,s,t),h=new y(e[2*i],e[2*i+1]),l=p(t,e,i+1,c-1,r,h,s,a),u=a+l++;e[2*u]=s.x,e[2*u+1]=s.y;var _=f(e,i+c,n-c,s,o,t),d=new y(e[2*(i+c)],e[2*(i+c)+1]);return l+p(t,e,i+c+1,_-1,s,d,o,a+l)};cp.convexHull=function(t,e,i){if(e)for(var n=0;n>1,u=p(i,e,2,l-2,c,h,c,1)+1;return e.length=2*u,o($(e),"Internal error: cpConvexHull() and cpPolyValidate() did not agree.Please report this error with as much info as you can."),e};var m=function(t,e,i){return n(r(t,e),i)},g=function(t){return r(0,n(t,1))},y=cp.Vect=function(t,e){this.x=t,this.y=e};cp.v=function(t,e){return new y(t,e)};var v=cp.vzero=new y(0,0),x=cp.v.dot=function(t,e){return t.x*e.x+t.y*e.y},C=function(t,e,i,n){return t*i+e*n},T=cp.v.len=function(t){return Math.sqrt(x(t,t))},b=cp.v.len2=function(t,e){return Math.sqrt(t*t+e*e)},A=(cp.v.eql=function(t,e){return t.x===e.x&&t.y===e.y},cp.v.add=function(t,e){return new y(t.x+e.x,t.y+e.y)});y.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this};var S=cp.v.sub=function(t,e){return new y(t.x-e.x,t.y-e.y)};y.prototype.sub=function(t){return this.x-=t.x,this.y-=t.y,this};var w=cp.v.neg=function(t){return new y(-t.x,-t.y)};y.prototype.neg=function(){return this.x=-this.x,this.y=-this.y,this};var E=cp.v.mult=function(t,e){return new y(t.x*e,t.y*e)};y.prototype.mult=function(t){return this.x*=t,this.y*=t,this};var I=cp.v.cross=function(t,e){return t.x*e.y-t.y*e.x},R=function(t,e,i,n){return t*n-e*i},P=cp.v.perp=function(t){return new y(-t.y,t.x)},O=(cp.v.pvrperp=function(t){return new y(t.y,-t.x)},cp.v.project=function(t,e){return E(e,x(t,e)/M(e))});y.prototype.project=function(t){return this.mult(x(this,t)/M(t)),this};var B=cp.v.rotate=function(t,e){return new y(t.x*e.x-t.y*e.y,t.x*e.y+t.y*e.x)};y.prototype.rotate=function(t){return this.x=this.x*t.x-this.y*t.y,this.y=this.x*t.y+this.y*t.x,this};var D=cp.v.unrotate=function(t,e){return new y(t.x*e.x+t.y*e.y,t.y*e.x-t.x*e.y)},M=cp.v.lengthsq=function(t){return x(t,t)},L=cp.v.lengthsq2=function(t,e){return t*t+e*e},N=cp.v.lerp=function(t,e,i){return A(E(t,1-i),E(e,i))},F=cp.v.normalize=function(t){return E(t,1/T(t))},k=cp.v.normalize_safe=function(t){return 0===t.x&&0===t.y?v:F(t)},z=cp.v.clamp=function(t,e){return x(t,t)>e*e?E(F(t),e):t},V=(cp.v.lerpconst=function(t,e,i){return A(t,z(S(e,t),i))},cp.v.dist=function(t,e){return T(S(t,e))}),G=cp.v.distsq=function(t,e){return M(S(t,e))},W=(cp.v.near=function(t,e,i){return G(t,e)=0){var h=(-a-Math.sqrt(c))/(2*o);if(0<=h&&h<=1)return new J(t,h,F(N(n,r,h)))}};Z.prototype.segmentQuery=function(t,e){return Q(this,this.tc,this.r,t,e)};var K=cp.SegmentShape=function(t,e,i,n){this.a=e,this.b=i,this.n=P(F(S(i,e))),this.ta=this.tb=this.tn=null,this.r=n,this.a_tangent=v,this.b_tangent=v,this.type="segment",H.call(this,t)};K.prototype=Object.create(H.prototype),K.prototype.cacheData=function(t,e){this.ta=A(t,B(this.a,e)),this.tb=A(t,B(this.b,e)),this.tn=B(this.n,e);var i,n,r,s;this.ta.x0?w(i):i,o=S(E(s,r),t),a=A(this.ta,o),c=A(this.tb,o),h=S(e,t);if(I(h,a)*I(h,c)<=0){var l=n+(n>0?-r:r),u=-l,_=x(h,i)-l;if(u*_<0)return new J(this,u/(u-_),s)}else if(0!==r){var d=Q(this,this.ta,this.r,t,e),f=Q(this,this.tb,this.r,t,e);return d?f&&f.t0)return!1}return!0},tt=cp.PolyShape=function(t,e,i){this.setVerts(e,i),this.type="poly",H.call(this,t)};tt.prototype=Object.create(H.prototype);var et=function(t,e){this.n=t,this.d=e};et.prototype.compare=function(t){return x(this.n,t)-this.d},tt.prototype.setVerts=function(t,e){s(t.length>=4,"Polygons require some verts"),s("number"==typeof t[0],"Polygon verticies should be specified in a flattened list (eg [x1,y1,x2,y2,x3,y3,...])"),s($(t),"Polygon is concave or has a reversed winding. Consider using cpConvexHull()");var i=t.length,n=i>>1;this.verts=new Array(i),this.tVerts=new Array(i),this.planes=new Array(n),this.tPlanes=new Array(n);for(var r=0;r>1]=new et(l,C(l.x,l.y,o,a)),this.tPlanes[r>>1]=new et(new y(0,0),0)}};cp.BoxShape=function(t,e,i){var n=e/2,r=i/2;return it(t,new U(-n,-r,n,r))};var it=cp.BoxShape2=function(t,e){var i=[e.l,e.b,e.l,e.t,e.r,e.t,e.r,e.b];return new tt(t,i,v)};tt.prototype.transformVerts=function(t,e){for(var i=this.verts,s=this.tVerts,o=1/0,a=-1/0,c=1/0,h=-1/0,l=0;l0&&(a=!0);var h=i[2*c],l=i[2*c+1],_=u(t.x,t.y,n,r,h,l),d=V(t,_);dc)){var h=x(e,a),l=(i[o].d-c)/(h-c);if(!(l<0||10)return!1}return!0},tt.prototype.containsVertPartial=function(t,e,i){for(var n=this.tPlanes,r=0;r0)return!1}}return!0},tt.prototype.getNumVerts=function(){return this.verts.length/2},tt.prototype.getVert=function(t){return new y(this.verts[2*t],this.verts[2*t+1])};var nt=cp.Body=function(t,e){this.p=new y(0,0),this.vx=this.vy=0,this.f=new y(0,0),this.w=0,this.t=0,this.v_limit=1/0,this.w_limit=1/0,this.v_biasx=this.v_biasy=0,this.w_bias=0,this.space=null,this.shapeList=[],this.arbiterList=null,this.constraintList=null,this.nodeRoot=null,this.nodeNext=null,this.nodeIdleTime=0,this.setMass(t),this.setMoment(e),this.rot=new y(0,0),this.setAngle(0)};if(cp.StaticBody=function(){var t=new nt(1/0,1/0);return t.nodeIdleTime=1/0,t},"undefined"!=typeof DEBUG&&DEBUG){var rt=function(t,e){(function(t,e){s(t.x==t.x&&t.y==t.y,e)})(t,e),(function(t,e){s(Math.abs(t.x)!==1/0&&Math.abs(t.y)!==1/0,e)})(t,e)};nt.prototype.sanityCheck=function(){s(this.m==this.m&&this.m_inv==this.m_inv,"Body's mass is invalid."),s(this.i==this.i&&this.i_inv==this.i_inv,"Body's moment is invalid."),rt(this.p,"Body's position is invalid."),rt(this.f,"Body's force is invalid."),s(this.vx==this.vx&&Math.abs(this.vx)!==1/0,"Body's velocity is invalid."),s(this.vy==this.vy&&Math.abs(this.vy)!==1/0,"Body's velocity is invalid."),s(this.a==this.a&&Math.abs(this.a)!==1/0,"Body's angle is invalid."),s(this.w==this.w&&Math.abs(this.w)!==1/0,"Body's angular velocity is invalid."),s(this.t==this.t&&Math.abs(this.t)!==1/0,"Body's torque is invalid."),rt(this.rot,"Body's rotation vector is invalid."),s(this.v_limit==this.v_limit,"Body's velocity limit is invalid."),s(this.w_limit==this.w_limit,"Body's angular velocity limit is invalid.")}}else nt.prototype.sanityCheck=function(){};nt.prototype.getPos=function(){return this.p},nt.prototype.getVel=function(){return new y(this.vx,this.vy)},nt.prototype.getAngVel=function(){return this.w},nt.prototype.isSleeping=function(){return null!==this.nodeRoot},nt.prototype.isStatic=function(){return this.nodeIdleTime===1/0},nt.prototype.isRogue=function(){return null===this.space},nt.prototype.setMass=function(t){s(t>0,"Mass must be positive and non-zero."),this.activate(),this.m=t,this.m_inv=1/t},nt.prototype.setMoment=function(t){s(t>0,"Moment of Inertia must be positive and non-zero."),this.activate(),this.i=t,this.i_inv=1/t},nt.prototype.addShape=function(t){this.shapeList.push(t)},nt.prototype.removeShape=function(t){l(this.shapeList,t)};var st=function(t,e,i){return t===i?t.next(e):(t.a===e?t.next_a=st(t.next_a,e,i):t.next_b=st(t.next_b,e,i),t)};nt.prototype.removeConstraint=function(t){this.constraintList=st(this.constraintList,this,t)},nt.prototype.setPos=function(t){this.activate(),this.sanityCheck(),t===v&&(t=cp.v(0,0)),this.p=t},nt.prototype.setVel=function(t){this.activate(),this.vx=t.x,this.vy=t.y},nt.prototype.setAngVel=function(t){this.activate(),this.w=t},nt.prototype.setAngleInternal=function(t){s(!isNaN(t),"Internal Error: Attempting to set body's angle to NaN"),this.a=t,this.rot.x=Math.cos(t),this.rot.y=Math.sin(t)},nt.prototype.setAngle=function(t){this.activate(),this.sanityCheck(),this.setAngleInternal(t)},nt.prototype.velocity_func=function(t,e,i){var n=this.vx*e+(t.x+this.f.x*this.m_inv)*i,r=this.vy*e+(t.y+this.f.y*this.m_inv)*i,s=this.v_limit,o=n*n+r*r,a=o>s*s?s/Math.sqrt(o):1;this.vx=n*a,this.vy=r*a;var c=this.w_limit;this.w=m(this.w*e+this.t*this.i_inv*i,-c,c),this.sanityCheck()},nt.prototype.position_func=function(t){this.p.x+=(this.vx+this.v_biasx)*t,this.p.y+=(this.vy+this.v_biasy)*t,this.setAngleInternal(this.a+(this.w+this.w_bias)*t),this.v_biasx=this.v_biasy=0,this.w_bias=0,this.sanityCheck()},nt.prototype.resetForces=function(){this.activate(),this.f=new y(0,0),this.t=0},nt.prototype.applyForce=function(t,e){this.activate(),this.f=A(this.f,t),this.t+=I(e,t)},nt.prototype.applyImpulse=function(t,e){this.activate(),Ht(this,t.x,t.y,e)},nt.prototype.getVelAtPoint=function(t){return A(new y(this.vx,this.vy),E(P(t),this.w))},nt.prototype.getVelAtWorldPoint=function(t){return this.getVelAtPoint(S(t,this.p))},nt.prototype.getVelAtLocalPoint=function(t){return this.getVelAtPoint(B(t,this.rot))},nt.prototype.eachShape=function(t){for(var e=0,i=this.shapeList.length;e0){var i=t.query;this.each((function(t){i(t,new U(t.bb_l,t.bb_b,t.bb_r,t.bb_t),e)}))}};var at=cp.BBTree=function(t){ot.call(this,t),this.velocityFunc=null,this.leaves={},this.count=0,this.root=null,this.pooledNodes=null,this.pooledPairs=null,this.stamp=0};at.prototype=Object.create(ot.prototype);var ct=function(t,e,i){this.obj=null,this.bb_l=n(e.bb_l,i.bb_l),this.bb_b=n(e.bb_b,i.bb_b),this.bb_r=r(e.bb_r,i.bb_r),this.bb_t=r(e.bb_t,i.bb_t),this.parent=null,this.setA(e),this.setB(i)};at.prototype.makeNode=function(t,e){var i=this.pooledNodes;return i?(this.pooledNodes=i.parent,i.constructor(this,t,e),i):(0,new ct(this,t,e))};var ht=function(t,e){this.obj=e,t.getBB(e,this),this.parent=null,this.stamp=1,this.pairs=null,0};at.prototype.getBB=function(t,e){var i=this.velocityFunc;if(i){var s=.1*(t.bb_r-t.bb_l),o=.1*(t.bb_t-t.bb_b),a=E(i(t),.1);e.bb_l=t.bb_l+n(-s,a.x),e.bb_b=t.bb_b+n(-o,a.y),e.bb_r=t.bb_r+r(s,a.x),e.bb_t=t.bb_t+r(o,a.y)}else e.bb_l=t.bb_l,e.bb_b=t.bb_b,e.bb_r=t.bb_r,e.bb_t=t.bb_t},at.prototype.getStamp=function(){var t=this.dynamicIndex;return t&&t.stamp?t.stamp:this.stamp},at.prototype.incrementStamp=function(){this.dynamicIndex&&this.dynamicIndex.stamp?this.dynamicIndex.stamp++:this.stamp++};var lt=function(t,e,i,n){this.prevA=null,this.leafA=t,this.nextA=e,this.prevB=null,this.leafB=i,this.nextB=n};at.prototype.makePair=function(t,e,i,n){var r=this.pooledPairs;return r?(this.pooledPairs=r.prevA,r.prevA=null,r.leafA=t,r.nextA=e,r.prevB=null,r.leafB=i,r.nextB=n,r):(0,new lt(t,e,i,n))},lt.prototype.recycle=function(t){this.prevA=t.pooledPairs,t.pooledPairs=this};var ut=function(t,e,i){i&&(i.leafA===e?i.prevA=t:i.prevB=t),t?t.leafA===e?t.nextA=i:t.nextB=i:e.pairs=i};ht.prototype.clearPairs=function(t){var e,i=this.pairs;for(this.pairs=null;i;)i.leafA===this?(e=i.nextA,ut(i.prevB,i.leafB,i.nextB)):(e=i.nextB,ut(i.prevA,i.leafA,i.nextA)),i.recycle(t),i=e};var _t=function(t,e,i){var n=t.pairs,r=e.pairs,s=i.makePair(t,n,e,r);t.pairs=e.pairs=s,n&&(n.leafA===t?n.prevA=s:n.prevB=s),r&&(r.leafA===e?r.prevA=s:r.prevB=s)};ct.prototype.recycle=function(t){this.parent=t.pooledNodes,t.pooledNodes=this},ht.prototype.recycle=function(t){},ct.prototype.setA=function(t){this.A=t,t.parent=this},ct.prototype.setB=function(t){this.B=t,t.parent=this},ht.prototype.isLeaf=!0,ct.prototype.isLeaf=!1,ct.prototype.otherChild=function(t){return this.A==t?this.B:this.A},ct.prototype.replaceChild=function(t,e,i){o(t==this.A||t==this.B,"Node is not a child of parent."),this.A==t?(this.A.recycle(i),this.setA(e)):(this.B.recycle(i),this.setB(e));for(var s=this;s;s=s.parent){var a=s.A,c=s.B;s.bb_l=n(a.bb_l,c.bb_l),s.bb_b=n(a.bb_b,c.bb_b),s.bb_r=r(a.bb_r,c.bb_r),s.bb_t=r(a.bb_t,c.bb_t)}},ct.prototype.bbArea=ht.prototype.bbArea=function(){return(this.bb_r-this.bb_l)*(this.bb_t-this.bb_b)};var dt=function(t,e){return(r(t.bb_r,e.bb_r)-n(t.bb_l,e.bb_l))*(r(t.bb_t,e.bb_t)-n(t.bb_b,e.bb_b))},ft=function(t,e){return Math.abs(t.bb_l+t.bb_r-e.bb_l-e.bb_r)+Math.abs(t.bb_b+t.bb_t-e.bb_b-e.bb_t)},pt=function(t,e,i){if(null==t)return e;if(t.isLeaf)return i.makeNode(e,t);var s=t.B.bbArea()+dt(t.A,e),o=t.A.bbArea()+dt(t.B,e);return s===o&&(s=ft(t.A,e),o=ft(t.B,e)),o=t.bb_r&&this.bb_b<=t.bb_b&&this.bb_t>=t.bb_t},ht.prototype.update=function(t){var e=t.root,i=this.obj;return!this.containsObj(i)&&(t.getBB(this.obj,this),e=vt(e,this,t),t.root=pt(e,this,t),this.clearPairs(t),this.stamp=t.getStamp(),!0)},ht.prototype.addPairs=function(t){var e=t.dynamicIndex;if(e){var i=e.root;i&&i.markLeafQuery(this,!0,e,null)}else{var n=t.staticIndex.root;this.markSubtree(t,n,null)}},at.prototype.insert=function(t,e){var i=new ht(this,t);this.leaves[e]=i,this.root=pt(this.root,i,this),this.count++,i.stamp=this.getStamp(),i.addPairs(this),this.incrementStamp()},at.prototype.remove=function(t,e){var i=this.leaves[e];delete this.leaves[e],this.root=vt(this.root,i,this),this.count--,i.clearPairs(this),i.recycle(this)},at.prototype.contains=function(t,e){return null!=this.leaves[e]};var Ct=function(t,e){};at.prototype.reindexQuery=function(t){if(this.root){var e,i=this.leaves;for(e in i)i[e].update(this);var n=this.staticIndex,r=n&&n.root;this.root.markSubtree(this,r,t),n&&!r&&this.collideStatic(this,n,t),this.incrementStamp()}},at.prototype.reindex=function(){this.reindexQuery(Ct)},at.prototype.reindexObject=function(t,e){var i=this.leaves[e];i&&(i.update(this)&&i.addPairs(this),this.incrementStamp())},at.prototype.pointQuery=function(t,e){this.query(new U(t.x,t.y,t.x,t.y),e)},at.prototype.segmentQuery=function(t,e,i,n){this.root&&yt(this.root,t,e,i,n)},at.prototype.query=function(t,e){this.root&&mt(this.root,t,e)},at.prototype.count=function(){return this.count},at.prototype.each=function(t){var e;for(e in this.leaves)t(this.leaves[e].obj)};var Tt=function(t,e,i,s,o){return(r(t.bb_r,s)-n(t.bb_l,e))*(r(t.bb_t,o)-n(t.bb_b,i))},bt=function(t,e,i,s){if(1==s)return e[i];if(2==s)return t.makeNode(e[i],e[i+1]);for(var o=(S=e[i]).bb_l,a=S.bb_b,c=S.bb_r,h=S.bb_t,l=i+s,u=i+1;uh-a,d=new Array(2*s);if(_)for(u=i;u=r*r)){var a=Math.sqrt(o);return new Rt(A(t,E(s,.5+(i-.5*r)/(a||1/0))),a?E(s,1/a):new y(1,0),a-r,0)}},Bt=0,Dt=function(t,e){var i=0,n=t.valueOnAxis(e[0].n,e[0].d);if(n>0)return-1;for(var r=1;r0)return-1;s>n&&(n=s,i=r)}return Bt=n,i},Mt=function(t,e,i,n){for(var r=[],s=t.tVerts,o=0;o>1)))}var l=e.tVerts;for(o=0;o>1)))}return r.length?r:(function(t,e,i,n){for(var r=[],s=t.tVerts,o=0;o=d&&d>=o&&t.push(new Rt(new y(u,_),a,n,h(i.hashid,l)))}}};Z.prototype.collisionCode=0,K.prototype.collisionCode=1,tt.prototype.collisionCode=2,Z.prototype.collisionTable=[function(t,e){var i=Ot(t.tc,e.tc,t.r,e.r);return i?[i]:Pt},function(t,e){var i=e.ta,n=e.tb,r=t.tc,s=S(n,i),o=g(x(s,S(r,i))/M(s)),a=A(i,E(s,o)),c=Ot(r,a,t.r,e.r);if(c){var h=c.n;return 0===o&&x(h,e.a_tangent)<0||1===o&&x(h,e.b_tangent)<0?Pt:[c]}return Pt},function(t,e){for(var i=e.tPlanes,n=0,r=x(i[0].n,t.tc)-i[0].d-t.r,s=0;s0)return Pt;o>r&&(r=o,n=s)}var a=i[n].n,c=e.tVerts,h=c.length,l=n<<1,u=c[l],_=c[l+1],d=c[(l+2)%h],f=c[(l+3)%h],p=R(a.x,a.y,u,_),m=R(a.x,a.y,d,f),g=I(a,t.tc);if(g0||o>0)return Pt;var c=0,l=Lt(t,n[0].n,n[0].d);if(l>0)return Pt;for(var u=0;u0)return Pt;_>l&&(l=_,c=u)}var d=w(n[c].n),f=A(t.ta,E(d,t.r)),p=A(t.tb,E(d,t.r));if(e.containsVert(f.x,f.y)&&i.push(new Rt(f,d,l,h(t.hashid,0))),e.containsVert(p.x,p.y)&&i.push(new Rt(p,d,l,h(t.hashid,1))),(o>=l||a>=l)&&(o>a?Nt(i,t,e,o,1):Nt(i,t,e,a,-1)),0===i.length){var m,g=2*c,v=e.tVerts,C=new y(v[g],v[g+1]);if(m=Ot(t.ta,C,t.r,0))return[m];if(m=Ot(t.tb,C,t.r,0))return[m];var T=2*r,b=new y(v[(g+2)%T],v[(g+3)%T]);if(m=Ot(t.ta,b,t.r,0))return[m];if(m=Ot(t.tb,b,t.r,0))return[m]}return i}],tt.prototype.collisionTable=[null,null,function(t,e){var i=Dt(e,t.tPlanes);if(-1==i)return Pt;var n=Bt,r=Dt(t,e.tPlanes);if(-1==r)return Pt;var s=Bt;return n>s?Mt(t,e,t.tPlanes[i].n,n):Mt(t,e,w(e.tPlanes[r].n),s)}];var Ft=cp.collideShapes=function(t,e){return s(t.collisionCode<=e.collisionCode,"Collided shapes must be sorted by type"),t.collisionTable[e.collisionCode](t,e)},kt=new St,zt=cp.Space=function(){this.stamp=0,this.curr_dt=0,this.bodies=[],this.rousedBodies=[],this.sleepingComponents=[],this.staticShapes=new at(null),this.activeShapes=new at(this.staticShapes),this.arbiters=[],this.contactBuffersHead=null,this.cachedArbiters={},this.constraints=[],this.locked=0,this.collisionHandlers={},this.defaultHandler=kt,this.postStepCallbacks=[],this.iterations=10,this.gravity=v,this.damping=1,this.idleSpeedThreshold=0,this.sleepTimeThreshold=1/0,this.collisionSlop=.1,this.collisionBias=Math.pow(.9,60),this.collisionPersistence=3,this.enableContactGraph=!1,this.staticBody=new nt(1/0,1/0),this.staticBody.nodeIdleTime=1/0,this.collideShapes=this.makeCollideShapes()};zt.prototype.getCurrentTimeStep=function(){return this.curr_dt},zt.prototype.setIterations=function(t){this.iterations=t},zt.prototype.isLocked=function(){return this.locked};var Vt=function(t){s(!t.locked,"This addition/removal cannot be done safely during a call to cpSpaceStep() or during a query. Put these calls into a post-step callback.")};zt.prototype.addCollisionHandler=function(t,e,i,n,r,s){Vt(this),this.removeCollisionHandler(t,e);var o=new St;o.a=t,o.b=e,i&&(o.begin=i),n&&(o.preSolve=n),r&&(o.postSolve=r),s&&(o.separate=s),this.collisionHandlers[h(t,e)]=o},zt.prototype.removeCollisionHandler=function(t,e){Vt(this),delete this.collisionHandlers[h(t,e)]},zt.prototype.setDefaultCollisionHandler=function(t,e,i,n){Vt(this);var r=new St;t&&(r.begin=t),e&&(r.preSolve=e),i&&(r.postSolve=i),n&&(r.separate=n),this.defaultHandler=r},zt.prototype.lookupHandler=function(t,e){return this.collisionHandlers[h(t,e)]||this.defaultHandler},zt.prototype.addShape=function(t){var e=t.body;return e.isStatic()?this.addStaticShape(t):(s(!t.space,"This shape is already added to a space and cannot be added to another."),Vt(this),e.activate(),e.addShape(t),t.update(e.p,e.rot),this.activeShapes.insert(t,t.hashid),t.space=this,t)},zt.prototype.addStaticShape=function(t){s(!t.space,"This shape is already added to a space and cannot be added to another."),Vt(this);var e=t.body;return e.addShape(t),t.update(e.p,e.rot),this.staticShapes.insert(t,t.hashid),t.space=this,t},zt.prototype.addBody=function(t){return s(!t.isStatic(),"Static bodies cannot be added to a space as they are not meant to be simulated."),s(!t.space,"This body is already added to a space and cannot be added to another."),Vt(this),this.bodies.push(t),t.space=this,t},zt.prototype.addConstraint=function(t){s(!t.space,"This shape is already added to a space and cannot be added to another."),Vt(this);var e=t.a,i=t.b;return e.activate(),i.activate(),this.constraints.push(t),t.next_a=e.constraintList,e.constraintList=t,t.next_b=i.constraintList,i.constraintList=t,t.space=this,t},zt.prototype.filterArbiters=function(t,e){for(var i in this.cachedArbiters){var n=this.cachedArbiters[i];(t!==n.body_a||e!==n.a&&null!==e)&&(t!==n.body_b||e!==n.b&&null!==e)||(e&&"cached"!==n.state&&n.callSeparate(this),n.unthread(),l(this.arbiters,n),delete this.cachedArbiters[i])}},zt.prototype.removeShape=function(t){var e=t.body;e.isStatic()?this.removeStaticShape(t):(s(this.containsShape(t),"Cannot remove a shape that was not added to the space. (Removed twice maybe?)"),Vt(this),e.activate(),e.removeShape(t),this.filterArbiters(e,t),this.activeShapes.remove(t,t.hashid),t.space=null)},zt.prototype.removeStaticShape=function(t){s(this.containsShape(t),"Cannot remove a static or sleeping shape that was not added to the space. (Removed twice maybe?)"),Vt(this);var e=t.body;e.isStatic()&&e.activateStatic(t),e.removeShape(t),this.filterArbiters(e,t),this.staticShapes.remove(t,t.hashid),t.space=null},zt.prototype.removeBody=function(t){s(this.containsBody(t),"Cannot remove a body that was not added to the space. (Removed twice maybe?)"),Vt(this),t.activate(),l(this.bodies,t),t.space=null},zt.prototype.removeConstraint=function(t){s(this.containsConstraint(t),"Cannot remove a constraint that was not added to the space. (Removed twice maybe?)"),Vt(this),t.a.activate(),t.b.activate(),l(this.constraints,t),t.a.removeConstraint(t),t.b.removeConstraint(t),t.space=null},zt.prototype.containsShape=function(t){return t.space===this},zt.prototype.containsBody=function(t){return t.space==this},zt.prototype.containsConstraint=function(t){return t.space==this},zt.prototype.uncacheArbiter=function(t){delete this.cachedArbiters[h(t.a.hashid,t.b.hashid)],l(this.arbiters,t)},zt.prototype.eachBody=function(t){this.lock();for(var e=this.bodies,i=0;ic?0:r.nodeIdleTime+t}}for(var h=this.arbiters,l=(n=0,h.length);n=0,"Internal Error: Space lock underflow."),0===this.locked&&t){for(var e=this.rousedBodies,i=0;ii.collisionCode){var o=e;e=i,i=o}var a=Ft(e,i);if(0!==a.length){var c=h(e.hashid,i.hashid),l=n.cachedArbiters[c];l||(l=n.cachedArbiters[c]=new wt(e,i)),l.update(a,r,e,i),"first coll"!=l.state||r.begin(l,n)||l.ignore(),"ignore"!==l.state&&r.preSolve(l,n)&&!s?n.arbiters.push(l):(l.contacts=null,"ignore"!==l.state&&(l.state="normal")),l.stamp=n.stamp}}}}},zt.prototype.arbiterSetFilter=function(t){var e=this.stamp-t.stamp,i=t.body_a,n=t.body_b;return!(!i.isStatic()&&!i.isSleeping()||!n.isStatic()&&!n.isSleeping())||(e>=1&&"cached"!=t.state&&(t.callSeparate(this),t.state="cached"),!(e>=this.collisionPersistence)||(t.contacts=null,!1))};var jt=function(t){var e=t.body;t.update(e.p,e.rot)};zt.prototype.step=function(t){if(0!==t){s(0===v.x&&0===v.y,"vzero is invalid"),this.stamp++;var e=this.curr_dt;this.curr_dt=t;var i,n,r,o=this.bodies,a=this.constraints,c=this.arbiters;for(i=0;i0,"You created a 0 length pin joint. A pivot joint will be much more stable."),this.r1=this.r2=null,this.n=null,this.nMass=0,this.jnAcc=this.jnMax=0,this.bias=0};ie.prototype=Object.create(ee.prototype),ie.prototype.preStep=function(t){var e=this.a,i=this.b;this.r1=B(this.anchr1,e.rot),this.r2=B(this.anchr2,i.rot);var n=S(A(i.p,this.r2),A(e.p,this.r1)),r=T(n);this.n=E(n,1/(r||1/0)),this.nMass=1/Qt(e,i,this.r1,this.r2,this.n);var s=this.maxBias;this.bias=m(-te(this.errorBias,t)*(r-this.dist)/t,-s,s),this.jnMax=this.maxForce*t},ie.prototype.applyCachedImpulse=function(t){var e=E(this.n,this.jnAcc*t);qt(this.a,this.b,this.r1,this.r2,e.x,e.y)},ie.prototype.applyImpulse=function(){var t=this.a,e=this.b,i=this.n,n=Yt(t,e,this.r1,this.r2,i),r=(this.bias-n)*this.nMass,s=this.jnAcc;this.jnAcc=m(s+r,-this.jnMax,this.jnMax),r=this.jnAcc-s,qt(t,e,this.r1,this.r2,i.x*r,i.y*r)},ie.prototype.getImpulse=function(){return Math.abs(this.jnAcc)};var ne=cp.SlideJoint=function(t,e,i,n,r,s){ee.call(this,t,e),this.anchr1=i,this.anchr2=n,this.min=r,this.max=s,this.r1=this.r2=this.n=null,this.nMass=0,this.jnAcc=this.jnMax=0,this.bias=0};ne.prototype=Object.create(ee.prototype),ne.prototype.preStep=function(t){var e=this.a,i=this.b;this.r1=B(this.anchr1,e.rot),this.r2=B(this.anchr2,i.rot);var n=S(A(i.p,this.r2),A(e.p,this.r1)),r=T(n),s=0;r>this.max?(s=r-this.max,this.n=k(n)):r=I(r,s)?(this.clamp=-1,this.r1=S(r,e.p)):(this.clamp=0,this.r1=S(A(E(P(s),-a),E(s,o)),e.p)),Kt(e,i,this.r1,this.r2,this.k1,this.k2),this.jMaxLen=this.maxForce*t;var c=S(A(i.p,this.r2),A(e.p,this.r1));this.bias=z(E(c,-te(this.errorBias,t)/t),this.maxBias)},se.prototype.applyCachedImpulse=function(t){qt(this.a,this.b,this.r1,this.r2,this.jAcc.x*t,this.jAcc.y*t)},se.prototype.grooveConstrain=function(t){var e=this.grv_tn,i=this.clamp*I(t,e)>0?t:O(t,e);return z(i,this.jMaxLen)},se.prototype.applyImpulse=function(){var t=this.a,e=this.b,i=this.r1,n=this.r2,r=Xt(t,e,i,n),s=$t(S(this.bias,r),this.k1,this.k2),o=this.jAcc;this.jAcc=this.grooveConstrain(A(o,s)),qt(t,e,this.r1,this.r2,this.jAcc.x-o.x,this.jAcc.y-o.y)},se.prototype.getImpulse=function(){return T(this.jAcc)},se.prototype.setGrooveA=function(t){this.grv_a=t,this.grv_n=P(F(S(this.grv_b,t))),this.activateBodies()},se.prototype.setGrooveB=function(t){this.grv_b=t,this.grv_n=P(F(S(t,this.grv_a))),this.activateBodies()};var oe=function(t,e){return(t.restLength-e)*t.stiffness},ae=cp.DampedSpring=function(t,e,i,n,r,s,o){ee.call(this,t,e),this.anchr1=i,this.anchr2=n,this.restLength=r,this.stiffness=s,this.damping=o,this.springForceFunc=oe,this.target_vrn=this.v_coef=0,this.r1=this.r2=null,this.nMass=0,this.n=null};ae.prototype=Object.create(ee.prototype),ae.prototype.preStep=function(t){var e=this.a,i=this.b;this.r1=B(this.anchr1,e.rot),this.r2=B(this.anchr2,i.rot);var n=S(A(i.p,this.r2),A(e.p,this.r1)),r=T(n);this.n=E(n,1/(r||1/0));var s=Qt(e,i,this.r1,this.r2,this.n);o(0!==s,"Unsolvable this."),this.nMass=1/s,this.target_vrn=0,this.v_coef=1-Math.exp(-this.damping*t*s);var a=this.springForceFunc(this,r);qt(e,i,this.r1,this.r2,this.n.x*a*t,this.n.y*a*t)},ae.prototype.applyCachedImpulse=function(t){},ae.prototype.applyImpulse=function(){var t=this.a,e=this.b,i=this.n,n=this.r1,r=this.r2,s=Yt(t,e,n,r,i),o=(this.target_vrn-s)*this.v_coef;this.target_vrn=s+o,o*=this.nMass,qt(t,e,this.r1,this.r2,this.n.x*o,this.n.y*o)},ae.prototype.getImpulse=function(){return 0};var ce=function(t,e){return(e-t.restAngle)*t.stiffness},he=cp.DampedRotarySpring=function(t,e,i,n,r){ee.call(this,t,e),this.restAngle=i,this.stiffness=n,this.damping=r,this.springTorqueFunc=ce,this.target_wrn=0,this.w_coef=0,this.iSum=0};he.prototype=Object.create(ee.prototype),he.prototype.preStep=function(t){var e=this.a,i=this.b,n=e.i_inv+i.i_inv;o(0!==n,"Unsolvable spring."),this.iSum=1/n,this.w_coef=1-Math.exp(-this.damping*t*n),this.target_wrn=0;var r=this.springTorqueFunc(this,e.a-i.a)*t;e.w-=r*e.i_inv,i.w+=r*i.i_inv},he.prototype.applyImpulse=function(){var t=this.a,e=this.b,i=t.w-e.w,n=(this.target_wrn-i)*this.w_coef;this.target_wrn=i+n;var r=n*this.iSum;t.w+=r*t.i_inv,e.w-=r*e.i_inv};var le=cp.RotaryLimitJoint=function(t,e,i,n){ee.call(this,t,e),this.min=i,this.max=n,this.jAcc=0,this.iSum=this.bias=this.jMax=0};le.prototype=Object.create(ee.prototype),le.prototype.preStep=function(t){var e=this.a,i=this.b,n=i.a-e.a,r=0;n>this.max?r=this.max-n:n0?c=a:this.angle=Math.floor((o-r)/s)*s+r,this.iSum=1/(e.i_inv+i.i_inv);var h=this.maxBias;this.bias=m(-te(this.errorBias,t)*c/t,-h,h),this.jMax=this.maxForce*t,this.bias||(this.jAcc=0)},ue.prototype.applyCachedImpulse=function(t){var e=this.a,i=this.b,n=this.jAcc*t;e.w-=n*e.i_inv,i.w+=n*i.i_inv},ue.prototype.applyImpulse=function(){if(this.bias){var t=this.a,e=this.b,i=e.w-t.w,n=this.ratchet,r=-(this.bias+i)*this.iSum,s=this.jAcc;this.jAcc=m((s+r)*n,0,this.jMax*Math.abs(n))/n,r=this.jAcc-s,t.w-=r*t.i_inv,e.w+=r*e.i_inv}},ue.prototype.getImpulse=function(t){return Math.abs(t.jAcc)};var _e=cp.GearJoint=function(t,e,i,n){ee.call(this,t,e),this.phase=i,this.ratio=n,this.ratio_inv=1/n,this.jAcc=0,this.iSum=this.bias=this.jMax=0};_e.prototype=Object.create(ee.prototype),_e.prototype.preStep=function(t){var e=this.a,i=this.b;this.iSum=1/(e.i_inv*this.ratio_inv+this.ratio*i.i_inv);var n=this.maxBias;this.bias=m(-te(this.errorBias,t)*(i.a*this.ratio-e.a-this.phase)/t,-n,n),this.jMax=this.maxForce*t},_e.prototype.applyCachedImpulse=function(t){var e=this.a,i=this.b,n=this.jAcc*t;e.w-=n*e.i_inv*this.ratio_inv,i.w+=n*i.i_inv},_e.prototype.applyImpulse=function(){var t=this.a,e=this.b,i=e.w*this.ratio-t.w,n=(this.bias-i)*this.iSum,r=this.jAcc;this.jAcc=m(r+n,-this.jMax,this.jMax),n=this.jAcc-r,t.w-=n*t.i_inv*this.ratio_inv,e.w+=n*e.i_inv},_e.prototype.getImpulse=function(){return Math.abs(this.jAcc)},_e.prototype.setRatio=function(t){this.ratio=t,this.ratio_inv=1/t,this.activateBodies()};var de=cp.SimpleMotor=function(t,e,i){ee.call(this,t,e),this.rate=i,this.jAcc=0,this.iSum=this.jMax=0};de.prototype=Object.create(ee.prototype),de.prototype.preStep=function(t){this.iSum=1/(this.a.i_inv+this.b.i_inv),this.jMax=this.maxForce*t},de.prototype.applyCachedImpulse=function(t){var e=this.a,i=this.b,n=this.jAcc*t;e.w-=n*e.i_inv,i.w+=n*i.i_inv},de.prototype.applyImpulse=function(){var t=this.a,e=this.b,i=-(e.w-t.w+this.rate)*this.iSum,n=this.jAcc;this.jAcc=m(n+i,-this.jMax,this.jMax),i=this.jAcc-n,t.w-=i*t.i_inv,e.w+=i*e.i_inv},de.prototype.getImpulse=function(){return Math.abs(this.jAcc)}}),{}],312:[(function(t,e,i){e.exports=(function(){"use strict";var t=Math.round(window.devicePixelRatio||1),e=function(t,e){this._color=e||"#666",this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),this._canvas.className="pstats-canvas",t.appendChild(this._canvas)};e.prototype.init=function(e,i){var n=e*t,r=i*t;this._canvas.width=n,this._canvas.height=r,this._canvas.style.width=e+"px",this._canvas.style.height=i+"px",this._ctx.globalAlpha=1,this._ctx.fillStyle="#444",this._ctx.fillRect(0,0,n,r)};var i=Math.round(window.devicePixelRatio||1),n=(function(t){function e(e,i){t.call(this,e,i),this._current=0,this._max=0}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.draw=function(t,e){var n=this._canvas.width,r=this._canvas.height;this._current+=.1*(t-this._current),this._max*=.99,this._current>this._max&&(this._max=this._current);var s=Math.round((1-this._current/this._max)*r);this._ctx.globalAlpha=1,this._ctx.drawImage(this._canvas,i,0,n-i,r,0,0,n-i,r),e?(this._ctx.fillStyle="#444",this._ctx.fillRect(n-i,0,i,r),this._ctx.fillStyle="#b70000",this._ctx.fillRect(n-i,s,i,r-s),this._ctx.globalAlpha=.5,this._ctx.fillStyle="#fff",this._ctx.fillRect(n-i,s,i,i)):(this._ctx.fillStyle="#444",this._ctx.fillRect(n-i,0,i,r),this._ctx.fillStyle=this._color,this._ctx.fillRect(n-i,s,i,r-s),this._ctx.globalAlpha=.5,this._ctx.fillStyle="#fff",this._ctx.fillRect(n-i,s,i,i))},e})(e),r=Math.round(window.devicePixelRatio||1),s=(function(t){function e(e,i){t.call(this,e,i),this._threshold=0,this._canvas2=document.createElement("canvas"),this._ctx2=this._canvas2.getContext("2d")}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e,i){t.prototype.init.call(this,e,i);var n=e*r,s=i*r;this._canvas2.width=n,this._canvas2.height=s,this._canvas2.style.width=e+"px",this._canvas2.style.height=i+"px",this._ctx2.globalAlpha=1,this._ctx2.fillStyle="#444",this._ctx2.fillRect(0,0,n,s)},e.prototype.draw=function(t,e){var i=this._canvas.width,n=this._canvas.height;if(this._ctx.globalAlpha=1,this._ctx2.globalAlpha=1,t>this._threshold){var s=n*((t-t%n)/n+1),o=this._threshold;this._threshold=s;var a=o/s;this._ctx2.drawImage(this._canvas,0,0),this._ctx.fillStyle="#444",this._ctx.fillRect(0,0,i,n),this._ctx.drawImage(this._canvas2,r,0,i-r,n,0,Math.round((1-a)*n),i-r,n)}else this._ctx.drawImage(this._canvas,r,0,i-r,n,0,0,i-r,n);var c=Math.round(n*(1-t/this._threshold));e?(this._ctx.fillStyle="#444",this._ctx.fillRect(i-r,0,r,n),this._ctx.fillStyle="#b70000",this._ctx.fillRect(i-r,c,r,n-c),this._ctx.globalAlpha=.5,this._ctx.fillStyle="#fff",this._ctx.fillRect(i-r,c,r,r)):(this._ctx.fillStyle="#444",this._ctx.fillRect(i-r,0,r,n),this._ctx.fillStyle=this._color,this._ctx.fillRect(i-r,c,r,n-c),this._ctx.globalAlpha=.5,this._ctx.fillStyle="#fff",this._ctx.fillRect(i-r,c,r,r))},e})(e),o=Math.round(window.devicePixelRatio||1),a=(function(t){function e(e,i,n,r){t.call(this,e,i),this._min=n,this._max=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.draw=function(t,e){var i=this._canvas.width,n=this._canvas.height,r=(t-this._min)/(this._max-this._min),s=Math.round((1-r)*n);this._ctx.globalAlpha=1,this._ctx.drawImage(this._canvas,o,0,i-o,n,0,0,i-o,n),e?(this._ctx.fillStyle="#444",this._ctx.fillRect(i-o,0,o,n),this._ctx.fillStyle="#b70000",this._ctx.fillRect(i-o,s,o,n-s),this._ctx.globalAlpha=.5,this._ctx.fillStyle="#fff",this._ctx.fillRect(i-o,s,o,o)):(this._ctx.fillStyle="#444",this._ctx.fillRect(i-o,0,o,n),this._ctx.fillStyle=this._color,this._ctx.fillRect(i-o,s,o,n-s),this._ctx.globalAlpha=.5,this._ctx.fillStyle="#fff",this._ctx.fillRect(i-o,s,o,o))},e})(e),c=Math.round(window.devicePixelRatio||1),h=function(t,e){this._colors=e,this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),this._canvas.className="pstats-canvas",t.appendChild(this._canvas)};h.prototype.init=function(t,e,i){var n=t*c,r=e*c;this._canvas.width=n,this._canvas.height=r*i,this._canvas.style.width=t+"px",this._canvas.style.height=e*i+"px",this._ctx.globalAlpha=1,this._ctx.fillStyle="#444",this._ctx.fillRect(0,0,n,r*i)},h.prototype.draw=function(t){var e=this._canvas.width,i=this._canvas.height;this._ctx.globalAlpha=1,this._ctx.drawImage(this._canvas,c,0,e-c,i,0,0,e-c,i);for(var n=0,r=0;r=this._opts.average&&(this._averageValue=this._accumValue/this._accumSamples,this._accumValue=0,this._accumStart=e,this._accumSamples=0)}},u.value.get=function(){return this._value},u.value.set=function(t){this._value=t},l.prototype.sample=function(){this._average(this._value)},l.prototype.human=function(){var t=this._opts.average?this._averageValue:this._value;return Math.round(100*t)/100},l.prototype.alarm=function(){return this._opts.below&&this._valuethis._opts.over},Object.defineProperties(l.prototype,u);var _=(function(t){function e(e,i){t.call(this,e,i),this._time=window.performance.now()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.start=function(){this._time=window.performance.now()},e.prototype.end=function(){this._value=window.performance.now()-this._time,this._average(this._value)},e.prototype.tick=function(){this.end(),this.start()},e.prototype.frame=function(){var t=window.performance.now(),e=t-this._time;this._total++;e>(this._opts.average||1e3)&&(this._value=1e3*this._total/e,this._total=0,this._time=t,this._average(this._value))},e})(l),d=Math.log(1024),f=["Bytes","KB","MB","GB","TB"],p=(function(t){function e(e,i,n){t.call(this,i,n),this._stats=e,this._start=0,0===n.extension.indexOf("memory.")&&(this._field=n.extension.substring(7))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.snapshot=function(){this._value=this._stats[this._field]},e.prototype.start=function(){this._start=this._stats[this._field]},e.prototype.end=function(){this._value=this._stats[this._field]-this._start},e.prototype.human=function(){return (function(t){var e=Math.floor(Math.log(t)/d);return 0===t?"n/a":Math.round(100*t/Math.pow(1024,e))/100+" "+f[e]})(t.prototype.human.call(this))},e})(l),m=function(){0===window.performance.memory.totalJSHeapSize&&console.warn("totalJSHeapSize === 0, performance.memory is only available in Chrome."),this._used=0,this._total=0,this._lastUsed=0},g={alarm:{},used:{},total:{}};m.prototype.tick=function(){this._lastUsed=this._used,this._used=window.performance.memory.usedJSHeapSize,this._total=window.performance.memory.totalJSHeapSize},g.alarm.get=function(){return this._used-this._lastUsed<0},g.used.get=function(){return window.performance.memory.usedJSHeapSize},g.total.get=function(){return this._total},m.prototype.counter=function(t,e){return new p(this,t,e)},Object.defineProperties(m.prototype,g);var y={memory:m},v=document.createElement("style");v.type="text/css",v.textContent="\n .pstats {\n position: fixed;\n z-index: 9999;\n\n padding: 5px;\n width: 250px;\n right: 5px;\n bottom: 5px;\n\n font-size: 10px;\n font-family: 'Roboto Condensed', tahoma, sans-serif;\n overflow: hidden;\n user-select: none;\n cursor: default;\n\n background: #222;\n border-radius: 3px;\n }\n\n .pstats-container {\n display: block;\n position: relative;\n color: #888;\n white-space: nowrap;\n }\n\n .pstats-item {\n position: absolute;\n width: 250px;\n height: 12px;\n left: 0px;\n }\n\n .pstats-label {\n position: absolute;\n width: 150px;\n height: 12px;\n text-align: left;\n transition: background 0.3s;\n }\n\n .pstats-label.alarm {\n color: #ccc;\n background: #800;\n\n transition: background 0s;\n }\n\n .pstats-counter-id {\n position: absolute;\n width: 90px;\n left: 0px;\n }\n\n .pstats-counter-value {\n position: absolute;\n width: 60px;\n left: 90px;\n text-align: right;\n }\n\n .pstats-canvas {\n display: block;\n position: absolute;\n right: 0px;\n top: 1px;\n }\n\n .pstats-fraction {\n position: absolute;\n width: 250px;\n left: 0px;\n }\n\n .pstats-legend {\n position: absolute;\n width: 150px;\n\n text-align: right;\n }\n\n .pstats-legend > span {\n position: absolute;\n right: 0px;\n }\n",document.head.appendChild(v);var x=function(t,e){if(e=e||{},this._showGraph=void 0===e.showGraph||e._showGraph,this._values=e.values||{},this._fractions=e.fractions||[],this._id2counter={},this._id2item={},this._name2extStats={},e.css){var i=document.createElement("style");i.type="text/css",i.textContent=e.css,document.head.appendChild(i)}if(e.extensions)for(var r=0;r0),s.valueText.nodeValue=r,this._showGraph&&s.graph.draw(i.value,n)}}if(this._showGraph)for(var o=0;o0?1:-1}),Number.isInteger||(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t}),!console.time){var n=window.performance||Date,r=Object.create(null);console.time=function(t){r[t]=n.now()},console.timeEnd=function(t){var e=r[t],i=n.now()-e;console.log(t+": "+i+"ms")}}}),{}],316:[(function(t,e,i){String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.lastIndexOf(t,e)===e}),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){(void 0===e||e>this.length)&&(e=this.length),e-=t.length;var i=this.indexOf(t,e);return-1!==i&&i===e})}),{}],317:[(function(t,e,i){var n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};window.__extends=function(t,e){function i(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)},window.__assign=Object.assign||function(t){for(var e,i=1,n=arguments.length;i=0;a--)(r=t[a])&&(o=(s<3?r(o):s>3?r(e,i,o):r(e,i))||o);return s>3&&o&&Object.defineProperty(e,i,o),o},window.__param=function(t,e){return function(i,n){e(i,n,t)}},window.__metadata=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},window.__awaiter=function(t,e,i,n){return new(i||(i=Promise))(function(r,s){function o(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){t.done?r(t.value):new i(function(e){e(t.value)}).then(o,a)}c((n=n.apply(t,e||[])).next())})},window.__generator=function(t,e){function i(i){return function(o){return (function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(s=r[2&i[0]?"return":i[0]?"throw":"next"])&&!(s=s.call(r,i[1])).done)return s;switch(r=0,s&&(i=[0,s.value]),i[0]){case 0:case 1:s=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(s=a.trys,!(s=s.length>0&&s[s.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!s||i[1]>s[0]&&i[1]=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}}},window.__read=function(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var n,r,s=i.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(t){r={error:t}}finally{try{n&&!n.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return o},window.__spread=function(){for(var t=[],e=0;e1||r(t,e)})})}function r(t,e){try{(function(t){t.value instanceof __await?Promise.resolve(t.value.v).then(s,o):a(l[0][2],t)})(h[t](e))}catch(t){a(l[0][3],t)}}function s(t){r("next",t)}function o(t){r("throw",t)}function a(t,e){t(e),l.shift(),l.length&&r(l[0][0],l[0][1])}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var c,h=i.apply(t,e||[]),l=[];return c={},n("next"),n("throw"),n("return"),c[Symbol.asyncIterator]=function(){return this},c},window.__asyncDelegator=function(t){function e(e,r){t[e]&&(i[e]=function(i){return(n=!n)?{value:__await(t[e](i)),done:"return"===e}:r?r(i):i})}var i,n;return i={},e("next"),e("throw",(function(t){throw t})),e("return"),i[Symbol.iterator]=function(){return this},i},window.__asyncValues=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator];return e?e.call(t):"function"==typeof __values?__values(t):t[Symbol.iterator]()}}),{}]},{},[313]); \ No newline at end of file diff --git a/bounce/build/web-mobile/index.html b/bounce/build/web-mobile/index.html new file mode 100644 index 0000000..1712cf7 --- /dev/null +++ b/bounce/build/web-mobile/index.html @@ -0,0 +1,54 @@ + + + + + + Cocos Creator | PJGame + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ + + + + diff --git a/bounce/build/web-mobile/main.js b/bounce/build/web-mobile/main.js new file mode 100644 index 0000000..ee5bb21 --- /dev/null +++ b/bounce/build/web-mobile/main.js @@ -0,0 +1,238 @@ +(function () { + + function boot () { + + var settings = window._CCSettings; + window._CCSettings = undefined; + + if ( !settings.debug ) { + var uuids = settings.uuids; + + var rawAssets = settings.rawAssets; + var assetTypes = settings.assetTypes; + var realRawAssets = settings.rawAssets = {}; + for (var mount in rawAssets) { + var entries = rawAssets[mount]; + var realEntries = realRawAssets[mount] = {}; + for (var id in entries) { + var entry = entries[id]; + var type = entry[1]; + // retrieve minified raw asset + if (typeof type === 'number') { + entry[1] = assetTypes[type]; + } + // retrieve uuid + realEntries[uuids[id] || id] = entry; + } + } + + var scenes = settings.scenes; + for (var i = 0; i < scenes.length; ++i) { + var scene = scenes[i]; + if (typeof scene.uuid === 'number') { + scene.uuid = uuids[scene.uuid]; + } + } + + var packedAssets = settings.packedAssets; + for (var packId in packedAssets) { + var packedIds = packedAssets[packId]; + for (var j = 0; j < packedIds.length; ++j) { + if (typeof packedIds[j] === 'number') { + packedIds[j] = uuids[packedIds[j]]; + } + } + } + } + + // init engine + var canvas; + + if (cc.sys.isBrowser) { + canvas = document.getElementById('GameCanvas'); + } + + if (false) { + var ORIENTATIONS = { + 'portrait': 1, + 'landscape left': 2, + 'landscape right': 3 + }; + BK.Director.screenMode = ORIENTATIONS[settings.orientation]; + initAdapter(); + } + + function setLoadingDisplay () { + // Loading splash scene + var splash = document.getElementById('splash'); + var progressBar = splash.querySelector('.progress-bar span'); + cc.loader.onProgress = function (completedCount, totalCount, item) { + var percent = 100 * completedCount / totalCount; + if (progressBar) { + progressBar.style.width = percent.toFixed(2) + '%'; + } + }; + splash.style.display = 'block'; + progressBar.style.width = '0%'; + + cc.director.once(cc.Director.EVENT_AFTER_SCENE_LAUNCH, function () { + splash.style.display = 'none'; + }); + } + + var onStart = function () { + cc.view.resizeWithBrowserSize(true); + + if (!false && !false) { + // UC browser on many android devices have performance issue with retina display + if (cc.sys.os !== cc.sys.OS_ANDROID || cc.sys.browserType !== cc.sys.BROWSER_TYPE_UC) { + cc.view.enableRetina(true); + } + if (cc.sys.isBrowser) { + setLoadingDisplay(); + } + + if (cc.sys.isMobile) { + if (settings.orientation === 'landscape') { + cc.view.setOrientation(cc.macro.ORIENTATION_LANDSCAPE); + } + else if (settings.orientation === 'portrait') { + cc.view.setOrientation(cc.macro.ORIENTATION_PORTRAIT); + } + cc.view.enableAutoFullScreen([ + cc.sys.BROWSER_TYPE_BAIDU, + cc.sys.BROWSER_TYPE_WECHAT, + cc.sys.BROWSER_TYPE_MOBILE_QQ, + cc.sys.BROWSER_TYPE_MIUI, + ].indexOf(cc.sys.browserType) < 0); + } + + // Limit downloading max concurrent task to 2, + // more tasks simultaneously may cause performance draw back on some android system / brwosers. + // You can adjust the number based on your own test result, you have to set it before any loading process to take effect. + if (cc.sys.isBrowser && cc.sys.os === cc.sys.OS_ANDROID) { + cc.macro.DOWNLOAD_MAX_CONCURRENT = 2; + } + } + + // init assets + cc.AssetLibrary.init({ + libraryPath: 'res/import', + rawAssetsBase: 'res/raw-', + rawAssets: settings.rawAssets, + packedAssets: settings.packedAssets, + md5AssetsMap: settings.md5AssetsMap + }); + + if (false) { + cc.Pipeline.Downloader.PackDownloader._doPreload("WECHAT_SUBDOMAIN", settings.WECHAT_SUBDOMAIN_DATA); + } + + var launchScene = settings.launchScene; + + // load scene + cc.director.loadScene(launchScene, null, + function () { + if (cc.sys.isBrowser) { + // show canvas + canvas.style.visibility = ''; + var div = document.getElementById('GameDiv'); + if (div) { + div.style.backgroundImage = ''; + } + } + cc.loader.onProgress = null; + console.log('Success to load scene: ' + launchScene); + } + ); + }; + + // jsList + var jsList = settings.jsList; + + if (false) { + BK.Script.loadlib(); + } + else + { + var bundledScript = settings.debug ? 'src/project.dev.js' : 'src/project.js'; + if (jsList) { + jsList = jsList.map(function (x) { + return 'src/' + x; + }); + jsList.push(bundledScript); + } + else { + jsList = [bundledScript]; + } + } + + // anysdk scripts + if (cc.sys.isNative && cc.sys.isMobile) { + jsList = jsList.concat(['src/anysdk/jsb_anysdk.js', 'src/anysdk/jsb_anysdk_constants.js']); + } + + var option = { + //width: width, + //height: height, + id: 'GameCanvas', + scenes: settings.scenes, + debugMode: settings.debug ? cc.DebugMode.INFO : cc.DebugMode.ERROR, + showFPS: (!false && !false) && settings.debug, + frameRate: 60, + jsList: jsList, + groupList: settings.groupList, + collisionMatrix: settings.collisionMatrix, + renderMode: 0 + } + + cc.game.run(option, onStart); + } + + if (false) { + BK.Script.loadlib('GameRes://libs/qqplay-adapter.js'); + BK.Script.loadlib('GameRes://src/settings.js'); + BK.Script.loadlib(); + BK.Script.loadlib('GameRes://libs/qqplay-downloader.js'); + qqPlayDownloader.REMOTE_SERVER_ROOT = ""; + var prevPipe = cc.loader.md5Pipe || cc.loader.assetLoader; + cc.loader.insertPipeAfter(prevPipe, qqPlayDownloader); + // + boot(); + return; + } + + if (false) { + require(window._CCSettings.debug ? 'cocos2d-js.js' : 'cocos2d-js-min.js'); + var prevPipe = cc.loader.md5Pipe || cc.loader.assetLoader; + cc.loader.insertPipeAfter(prevPipe, wxDownloader); + boot(); + return; + } + + if (window.jsb) { + require('src/settings.js'); + require('src/jsb_polyfill.js'); + boot(); + return; + } + + if (window.document) { + var splash = document.getElementById('splash'); + splash.style.display = 'block'; + + var cocos2d = document.createElement('script'); + cocos2d.async = true; + cocos2d.src = window._CCSettings.debug ? 'cocos2d-js.js' : 'cocos2d-js-min.js'; + + var engineLoaded = function () { + document.body.removeChild(cocos2d); + cocos2d.removeEventListener('load', engineLoaded, false); + window.eruda && eruda.init() && eruda.get('console').config.set('displayUnenumerable', false); + boot(); + }; + cocos2d.addEventListener('load', engineLoaded, false); + document.body.appendChild(cocos2d); + } + +})(); diff --git a/bounce/build/web-mobile/res/import/0b/0b5feed4e.json b/bounce/build/web-mobile/res/import/0b/0b5feed4e.json new file mode 100644 index 0000000..2926745 --- /dev/null +++ b/bounce/build/web-mobile/res/import/0b/0b5feed4e.json @@ -0,0 +1 @@ +[[{"__type__":"cc.Prefab","_name":"boxSprite","data":{"__id__":1},"asyncLoadAssets":null},{"__type__":"cc.Node","_name":"boxSprite","_children":[{"__id__":2}],"_components":[{"__type__":"cc.Sprite","node":{"__id__":1},"_spriteFrame":{"__uuid__":"96TWNUYnxAy5TPj5Wd+Pa3"},"_sizeMode":0},{"__type__":"cc.BoxCollider","node":{"__id__":1},"_size":{"__type__":"cc.Size","width":95,"height":95}},{"__type__":"cc.RigidBody","node":{"__id__":1},"_type":0,"_gravityScale":0,"enabledContactListener":true},{"__type__":"cc.PhysicsBoxCollider","node":{"__id__":1},"_density":0,"_friction":0,"_restitution":1,"_size":{"__type__":"cc.Size","width":95,"height":95}},{"__type__":"64d28CtzUZHU6zwDKNtyRk2","node":{"__id__":1}}],"_prefab":{"__type__":"cc.PrefabInfo","root":{"__id__":1},"asset":{"__uuid__":"06SZlzMX9JzbgSJGMRioYE"},"fileId":"72YhDWrjxBVZNied6Q2vpO"},"_contentSize":{"__type__":"cc.Size","width":95,"height":95},"groupIndex":3},{"__type__":"cc.Node","_name":"scoreLabel","_parent":{"__id__":1},"_components":[{"__type__":"cc.Label","node":{"__id__":2},"_useOriginalSize":false,"_N$string":"1","_N$horizontalAlign":1,"_N$verticalAlign":1}],"_prefab":{"__type__":"cc.PrefabInfo","root":{"__id__":1},"asset":{"__uuid__":"06SZlzMX9JzbgSJGMRioYE"},"fileId":"9ciegPAaFE+4mOsyisfsWa"},"_color":{"__type__":"cc.Color"},"_contentSize":{"__type__":"cc.Size","width":22,"height":40}}],{"__type__":"cc.SpriteFrame","content":{"name":"ball","texture":"4dtkUOdCtM76zN9MOSl+LS","rect":[0,0,32,32],"offset":[0,0],"originalSize":[32,32]}},[{"__type__":"cc.Prefab","_name":"lifeBox","data":{"__id__":1},"asyncLoadAssets":null},{"__type__":"cc.Node","_name":"lifeBox","_components":[{"__type__":"cc.Sprite","node":{"__id__":1},"_spriteFrame":{"__uuid__":"f0Hk2N+XFA9oJ/HrvegLw9"}},{"__type__":"cc.CircleCollider","node":{"__id__":1},"_radius":33},{"__type__":"cc.RigidBody","node":{"__id__":1},"_type":0,"_gravityScale":0,"enabledContactListener":true},{"__type__":"cc.PhysicsCircleCollider","node":{"__id__":1},"_density":0,"_sensor":true,"_friction":0,"_restitution":1,"_radius":33},{"__type__":"6700apouQpBKYVEhPCOXU/q","node":{"__id__":1}}],"_prefab":{"__type__":"cc.PrefabInfo","root":{"__id__":1},"asset":{"__uuid__":"1dWY0WNbZEfIhm1jk7tza5"},"fileId":"c6426sd8hMqL5mbeJh7B/N"},"_contentSize":{"__type__":"cc.Size","width":66,"height":66},"groupIndex":3}],{"__type__":"cc.SpriteFrame","content":{"name":"bababa3","texture":"aa/aV4es1AdJlUA3gHsdCG","rect":[15,0,22,1357],"offset":[1,71.5],"originalSize":[50,1500]}},{"__type__":"cc.SpriteFrame","content":{"name":"groundBgView","texture":"ddWi4ip+ZAkYr3U3SwW/8G","rect":[0,0,4,6],"offset":[0,0],"originalSize":[4,6]}},{"__type__":"cc.SpriteFrame","content":{"name":"bgView","texture":"4c+DAzRWZOUpEywAce7WPg","rect":[0,0,6,8],"offset":[0,0],"originalSize":[6,8]}},{"__type__":"cc.SpriteFrame","content":{"name":"boxBgView","texture":"3fObasaRJLm6Uc1Z36fZ+7","rect":[0,0,4,5],"offset":[0,0],"originalSize":[4,5]}},[{"__type__":"cc.SceneAsset","_name":"bounceGame","scene":{"__id__":1},"asyncLoadAssets":null},{"__type__":"cc.Scene","_name":"New Node","_children":[{"__id__":2},{"__id__":14}],"_anchorPoint":{"__type__":"cc.Vec2"},"autoReleaseAssets":false},{"__type__":"cc.Node","_name":"Canvas","_parent":{"__id__":1},"_children":[{"__id__":3},{"__id__":4},{"__id__":5},{"__id__":6},{"__id__":8},{"__id__":10},{"__id__":12}],"_components":[{"__type__":"cc.Canvas","node":{"__id__":2},"_designResolution":{"__type__":"cc.Size","width":640,"height":1136},"_fitWidth":true},{"__type__":"9ee48eR4DtEmZNt1HYcUdPD","node":{"__id__":2},"level":0,"indexBoll":{"__id__":9},"boxPrefab":{"__uuid__":"06SZlzMX9JzbgSJGMRioYE"},"bollPrefab":{"__uuid__":"eePPcWdl5AmLJ8hGsWEpmU"},"lifePrefab":{"__uuid__":"1dWY0WNbZEfIhm1jk7tza5"},"ground":{"__id__":4},"ballLink":{"__id__":7},"levelLabel":{"__id__":11},"allBollsLabel":{"__id__":13},"rockAudio":{"__uuid__":"e8J8rdsf1CPI9+hUrT0ZpE"},"circleAudio":{"__uuid__":"32rPK1EDZPkZCDyz2qJu6B"}}],"_id":"dcAkwOsGZPrYn8CaXgNDbX","_contentSize":{"__type__":"cc.Size","width":640,"height":1136},"_position":{"__type__":"cc.Vec2","x":320,"y":568}},{"__type__":"cc.Node","_name":"bgView","_parent":{"__id__":2},"_components":[{"__type__":"cc.Sprite","node":{"__id__":3},"_spriteFrame":{"__uuid__":"83oRAJHONP4692DgfEbsjA"},"_sizeMode":0}],"_contentSize":{"__type__":"cc.Size","width":640,"height":1136}},{"__type__":"cc.Node","_name":"groundSprite","_parent":{"__id__":2},"_components":[{"__type__":"cc.Sprite","node":{"__id__":4},"_spriteFrame":{"__uuid__":"68btUeEPdKL5C2OhjnHP2+"},"_sizeMode":0},{"__type__":"cc.BoxCollider","node":{"__id__":4},"_size":{"__type__":"cc.Size","width":640,"height":200}},{"__type__":"cc.RigidBody","node":{"__id__":4},"_type":0,"enabledContactListener":true},{"__type__":"cc.PhysicsBoxCollider","node":{"__id__":4},"_density":0,"_friction":0,"_restitution":1,"_size":{"__type__":"cc.Size","width":640,"height":200}},{"__type__":"7061e552B9BQZZm3GGw6d+3","node":{"__id__":4}}],"_contentSize":{"__type__":"cc.Size","width":640,"height":200},"_position":{"__type__":"cc.Vec2","y":-468},"groupIndex":1},{"__type__":"cc.Node","_name":"tipsLabel","_parent":{"__id__":2},"_components":[{"__type__":"cc.Label","node":{"__id__":5},"_useOriginalSize":false,"_actualFontSize":30,"_fontSize":30,"_N$string":"手指触摸屏幕滑动\n\n小球沿着轨迹发射","_N$horizontalAlign":1,"_N$verticalAlign":1}],"_color":{"__type__":"cc.Color","r":192,"g":187,"b":187},"_contentSize":{"__type__":"cc.Size","width":240,"height":120},"_position":{"__type__":"cc.Vec2","y":-476}},{"__type__":"cc.Node","_name":"ballLink","_parent":{"__id__":2},"_components":[{"__id__":7}],"_anchorPoint":{"__type__":"cc.Vec2","x":0.5},"_contentSize":{"__type__":"cc.Size","width":22,"height":1357},"_scaleX":0.65,"_scaleY":0.65,"_position":{"__type__":"cc.Vec2","y":-348}},{"__type__":"cc.Sprite","node":{"__id__":6},"_spriteFrame":{"__uuid__":"3ayC2XrmpCzpOiZvavS65i"},"_sizeMode":0},{"__type__":"cc.Node","_name":"bollSprite","_parent":{"__id__":2},"_components":[{"__id__":9},{"__type__":"cc.CircleCollider","node":{"__id__":8},"tag":1,"_radius":15},{"__type__":"cc.RigidBody","node":{"__id__":8},"_gravityScale":0,"_fixedRotation":true,"enabledContactListener":true},{"__type__":"cc.PhysicsCircleCollider","node":{"__id__":8},"_radius":15},{"__type__":"46e33Lf/o1NJrSwDSrTdW6w","node":{"__id__":8}}],"_prefab":{"__type__":"cc.PrefabInfo","root":{"__id__":8},"asset":{"__uuid__":"eePPcWdl5AmLJ8hGsWEpmU"},"fileId":"32lyQQDp1GOKsvP8LL5ah+"},"_contentSize":{"__type__":"cc.Size","width":30,"height":30},"_position":{"__type__":"cc.Vec2","y":-348},"groupIndex":2},{"__type__":"cc.Sprite","node":{"__id__":8},"_spriteFrame":{"__uuid__":"16sRvk5jBGGqCKbzkJiw7t"},"_sizeMode":0},{"__type__":"cc.Node","_name":"levelLabel","_parent":{"__id__":2},"_components":[{"__id__":11}],"_contentSize":{"__type__":"cc.Size","width":107,"height":40},"_position":{"__type__":"cc.Vec2","x":-245,"y":536}},{"__type__":"cc.Label","node":{"__id__":10},"_useOriginalSize":false,"_actualFontSize":30,"_fontSize":30,"_N$string":"分数:1","_N$horizontalAlign":1,"_N$verticalAlign":1},{"__type__":"cc.Node","_name":"allBollsLabel","_parent":{"__id__":2},"_components":[{"__id__":13}],"_contentSize":{"__type__":"cc.Size","width":27,"height":40},"_position":{"__type__":"cc.Vec2","x":-31,"y":-311}},{"__type__":"cc.Label","node":{"__id__":12},"_useOriginalSize":false,"_actualFontSize":20,"_fontSize":20,"_N$string":"x 1","_N$horizontalAlign":2,"_N$verticalAlign":1},{"__type__":"cc.Node","_name":"wall","_parent":{"__id__":1},"_children":[{"__id__":15},{"__id__":16},{"__id__":17}],"_id":"9ePWJCiuVNzKE5Y5X4g407"},{"__type__":"cc.Node","_name":"right_wall","_parent":{"__id__":14},"_components":[{"__type__":"cc.Sprite","node":{"__id__":15},"_spriteFrame":{"__uuid__":"96TWNUYnxAy5TPj5Wd+Pa3"},"_sizeMode":0},{"__type__":"cc.RigidBody","node":{"__id__":15},"_type":0,"_gravityScale":0,"enabledContactListener":true},{"__type__":"cc.PhysicsBoxCollider","node":{"__id__":15},"_density":0,"_friction":0,"_restitution":1,"_offset":{"__type__":"cc.Vec2","x":17.457650986212002,"y":465},"_size":{"__type__":"cc.Size","width":10,"height":930}}],"_anchorPoint":{"__type__":"cc.Vec2","x":-1.2457650986212},"_contentSize":{"__type__":"cc.Size","width":10,"height":930},"_position":{"__type__":"cc.Vec2","x":629,"y":201},"groupIndex":1},{"__type__":"cc.Node","_name":"left_wall","_parent":{"__id__":14},"_components":[{"__type__":"cc.Sprite","node":{"__id__":16},"_spriteFrame":{"__uuid__":"96TWNUYnxAy5TPj5Wd+Pa3"},"_sizeMode":0},{"__type__":"cc.RigidBody","node":{"__id__":16},"_type":0,"_gravityScale":0,"enabledContactListener":true},{"__type__":"cc.PhysicsBoxCollider","node":{"__id__":16},"_density":0,"_friction":0,"_restitution":1,"_offset":{"__type__":"cc.Vec2","x":17.457650986212002,"y":470},"_size":{"__type__":"cc.Size","width":10,"height":940}}],"_anchorPoint":{"__type__":"cc.Vec2","x":-1.2457650986212},"_contentSize":{"__type__":"cc.Size","width":10,"height":940},"_position":{"__type__":"cc.Vec2","x":-22,"y":199},"groupIndex":1},{"__type__":"cc.Node","_name":"top_wall","_parent":{"__id__":14},"_components":[{"__type__":"cc.Sprite","node":{"__id__":17},"_spriteFrame":{"__uuid__":"96TWNUYnxAy5TPj5Wd+Pa3"},"_sizeMode":0},{"__type__":"cc.RigidBody","node":{"__id__":17},"_type":0,"_gravityScale":0,"enabledContactListener":true},{"__type__":"cc.PhysicsBoxCollider","node":{"__id__":17},"_density":0,"_friction":0,"_restitution":1,"_offset":{"__type__":"cc.Vec2","x":17.457650986212002,"y":325},"_size":{"__type__":"cc.Size","width":10,"height":650}}],"_anchorPoint":{"__type__":"cc.Vec2","x":-1.2457650986212},"_contentSize":{"__type__":"cc.Size","width":10,"height":650},"_rotationX":-90,"_rotationY":-90,"_position":{"__type__":"cc.Vec2","x":647,"y":1124},"groupIndex":1}],[{"__type__":"cc.Prefab","_name":"bollSprite","data":{"__id__":1},"asyncLoadAssets":null},{"__type__":"cc.Node","_name":"bollSprite","_components":[{"__type__":"cc.Sprite","node":{"__id__":1},"_spriteFrame":{"__uuid__":"16sRvk5jBGGqCKbzkJiw7t"},"_sizeMode":0},{"__type__":"cc.CircleCollider","node":{"__id__":1},"tag":1,"_radius":15},{"__type__":"cc.RigidBody","node":{"__id__":1},"_gravityScale":0.0025,"_fixedRotation":true,"enabledContactListener":true},{"__type__":"cc.PhysicsCircleCollider","node":{"__id__":1},"_radius":15},{"__type__":"46e33Lf/o1NJrSwDSrTdW6w","node":{"__id__":1}}],"_prefab":{"__type__":"cc.PrefabInfo","root":{"__id__":1},"asset":{"__uuid__":"eePPcWdl5AmLJ8hGsWEpmU"},"fileId":"32lyQQDp1GOKsvP8LL5ah+"},"_contentSize":{"__type__":"cc.Size","width":30,"height":30},"_position":{"__type__":"cc.Vec2","y":-348},"groupIndex":2}],{"__type__":"cc.SpriteFrame","content":{"name":"lifeBox","texture":"9cZX30zRxKQ4/wLm37XsrR","rect":[0,0,66,66],"offset":[0,0],"originalSize":[66,66]}}] \ No newline at end of file diff --git a/bounce/build/web-mobile/res/raw-assets/bababa3.png b/bounce/build/web-mobile/res/raw-assets/bababa3.png new file mode 100755 index 0000000..1080de6 Binary files /dev/null and b/bounce/build/web-mobile/res/raw-assets/bababa3.png differ diff --git a/bounce/build/web-mobile/res/raw-assets/ball.png b/bounce/build/web-mobile/res/raw-assets/ball.png new file mode 100755 index 0000000..282a3e4 Binary files /dev/null and b/bounce/build/web-mobile/res/raw-assets/ball.png differ diff --git a/bounce/build/web-mobile/res/raw-assets/ball_Boom.mp3 b/bounce/build/web-mobile/res/raw-assets/ball_Boom.mp3 new file mode 100644 index 0000000..19b6bd4 Binary files /dev/null and b/bounce/build/web-mobile/res/raw-assets/ball_Boom.mp3 differ diff --git a/bounce/build/web-mobile/res/raw-assets/bgView.png b/bounce/build/web-mobile/res/raw-assets/bgView.png new file mode 100644 index 0000000..f482ee3 Binary files /dev/null and b/bounce/build/web-mobile/res/raw-assets/bgView.png differ diff --git a/bounce/build/web-mobile/res/raw-assets/boxBgView.png b/bounce/build/web-mobile/res/raw-assets/boxBgView.png new file mode 100644 index 0000000..4b472bb Binary files /dev/null and b/bounce/build/web-mobile/res/raw-assets/boxBgView.png differ diff --git a/bounce/build/web-mobile/res/raw-assets/circle_Boom.mp3 b/bounce/build/web-mobile/res/raw-assets/circle_Boom.mp3 new file mode 100644 index 0000000..5947de4 Binary files /dev/null and b/bounce/build/web-mobile/res/raw-assets/circle_Boom.mp3 differ diff --git a/bounce/build/web-mobile/res/raw-assets/groundBgView.png b/bounce/build/web-mobile/res/raw-assets/groundBgView.png new file mode 100644 index 0000000..4573d46 Binary files /dev/null and b/bounce/build/web-mobile/res/raw-assets/groundBgView.png differ diff --git a/bounce/build/web-mobile/res/raw-assets/lifeBox.png b/bounce/build/web-mobile/res/raw-assets/lifeBox.png new file mode 100644 index 0000000..995b9de Binary files /dev/null and b/bounce/build/web-mobile/res/raw-assets/lifeBox.png differ diff --git a/bounce/build/web-mobile/splash.png b/bounce/build/web-mobile/splash.png new file mode 100644 index 0000000..cfb96fe Binary files /dev/null and b/bounce/build/web-mobile/splash.png differ diff --git a/bounce/build/web-mobile/src/project.js b/bounce/build/web-mobile/src/project.js new file mode 100644 index 0000000..5242d8e --- /dev/null +++ b/bounce/build/web-mobile/src/project.js @@ -0,0 +1 @@ +require=function l(s,c,a){function r(i,t){if(!c[i]){if(!s[i]){var e="function"==typeof require&&require;if(!t&&e)return e(i,!0);if(h)return h(i,!0);var o=new Error("Cannot find module '"+i+"'");throw o.code="MODULE_NOT_FOUND",o}var n=c[i]={exports:{}};s[i][0].call(n.exports,function(t){return r(s[i][1][t]||t)},n,n.exports,l,s,c,a)}return c[i].exports}for(var h="function"==typeof require&&require,t=0;t