var cc=cc||{};cc._tmp=cc._tmp||{};cc._LogInfos={};window._p;_p=window;_p.gl;_p.WebGLRenderingContext;_p.DeviceOrientationEvent;_p.DeviceMotionEvent;_p.AudioContext;_p.webkitAudioContext;_p.mozAudioContext;_p=Object.prototype;_p._super;_p.ctor;delete window._p;cc.newElement=function(a){return document.createElement(a)};cc._addEventListener=function(a,b,c,d){a.addEventListener(b,c,d)};cc._isNodeJs="undefined"!=typeof require&&require("fs");
cc.each=function(a,b,c){if(a)if(a instanceof Array)for(var d=0,e=a.length;e>d&&!1!==b.call(c,a[d],d);d++);else for(d in a)if(!1===b.call(c,a[d],d))break};cc.extend=function(a){var b=2<=arguments.length?Array.prototype.slice.call(arguments,1):[];return cc.each(b,function(b){for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d])}),a};cc.isFunction=function(a){return"function"==typeof a};cc.isNumber=function(a){return"number"==typeof a||"[object Number]"===Object.prototype.toString.call(a)};
cc.isString=function(a){return"string"==typeof a||"[object String]"===Object.prototype.toString.call(a)};cc.isArray=function(a){return Array.isArray(a)||"object"==typeof a&&"[object Array]"===Object.prototype.toString.call(a)};cc.isUndefined=function(a){return"undefined"==typeof a};cc.isObject=function(a){return"object"==typeof a&&"[object Object]"===Object.prototype.toString.call(a)};
cc.isCrossOrigin=function(a){if(!a)return cc.log("invalid URL"),!1;var b=a.indexOf("://");if(-1===b)return!1;b=a.indexOf("/",b+3);return(-1===b?a:a.substring(0,b))!==location.origin};
cc.AsyncPool=function(a,b,c,d,e){var f=this;f._srcObj=a;f._limit=b;f._pool=[];f._iterator=c;f._iteratorTarget=e;f._onEnd=d;f._onEndTarget=e;f._results=a instanceof Array?[]:{};f._isErr=!1;cc.each(a,function(a,b){f._pool.push({index:b,value:a})});f.size=f._pool.length;f.finishedSize=0;f._workingSize=0;f._limit=f._limit||f.size;f.onIterator=function(a,b){f._iterator=a;f._iteratorTarget=b};f.onEnd=function(a,b){f._onEnd=a;f._onEndTarget=b};f._handleItem=function(){var a=this;if(!(0===a._pool.length||
a._workingSize>=a._limit)){var b=a._pool.shift(),c=b.value,d=b.index;a._workingSize++;a._iterator.call(a._iteratorTarget,c,d,function(b){if(!a._isErr){if(a.finishedSize++,a._workingSize--,b)return a._isErr=!0,void(a._onEnd&&a._onEnd.call(a._onEndTarget,b));var c=Array.prototype.slice.call(arguments,1);return a._results[this.index]=c[0],a.finishedSize===a.size?void(a._onEnd&&a._onEnd.call(a._onEndTarget,null,a._results)):void a._handleItem()}}.bind(b),a)}};f.flow=function(){if(0===this._pool.length)return void(this._onEnd&&
this._onEnd.call(this._onEndTarget,null,[]));for(var a=0;a<this._limit;a++)this._handleItem()}};
cc.async={series:function(a,b,c){a=new cc.AsyncPool(a,1,function(a,b,f){a.call(c,f)},b,c);return a.flow(),a},parallel:function(a,b,c){a=new cc.AsyncPool(a,0,function(a,b,f){a.call(c,f)},b,c);return a.flow(),a},waterfall:function(a,b,c){var d=[],e=[null],f=new cc.AsyncPool(a,1,function(b,f,k){d.push(function(b){d=Array.prototype.slice.call(arguments,1);a.length-1===f&&(e=e.concat(d));k.apply(null,arguments)});b.apply(c,d)},function(a){return b?a?b.call(c,a):void b.apply(c,e):void 0});return f.flow(),
f},map:function(a,b,c,d){var e=b;"object"==typeof b&&(c=b.cb,d=b.iteratorTarget,e=b.iterator);a=new cc.AsyncPool(a,0,e,c,d);return a.flow(),a},mapLimit:function(a,b,c,d,e){a=new cc.AsyncPool(a,b,c,d,e);return a.flow(),a}};
cc.path={join:function(){for(var a=arguments.length,b="",c=0;a>c;c++)b=(b+(""===b?"":"/")+arguments[c]).replace(/(\/|\\\\)$/,"");return b},extname:function(a){return(a=/(\.[^\.\/\?\\]*)(\?.*)?$/.exec(a))?a[1]:null},mainFileName:function(a){if(a){var b=a.lastIndexOf(".");if(-1!==b)return a.substring(0,b)}return a},basename:function(a,b){var c=a.indexOf("?");0<c&&(a=a.substring(0,c));c=/(\/|\\\\)([^(\/|\\\\)]+)$/g.exec(a.replace(/(\/|\\\\)$/,""));if(!c)return null;c=c[2];return b&&a.substring(a.length-
b.length).toLowerCase()===b.toLowerCase()?c.substring(0,c.length-b.length):c},dirname:function(a){return a.replace(/((.*)(\/|\\|\\\\))?(.*?\..*$)?/,"$2")},changeExtname:function(a,b){b=b||"";var c=a.indexOf("?"),d="";return 0<c&&(d=a.substring(c),a=a.substring(0,c)),c=a.lastIndexOf("."),0>c?a+b+d:a.substring(0,c)+b+d},changeBasename:function(a,b,c){if(0===b.indexOf("."))return this.changeExtname(a,b);var d=a.indexOf("?"),e="";c=c?this.extname(a):"";return 0<d&&(e=a.substring(d),a=a.substring(0,d)),
d=a.lastIndexOf("/"),d=0>=d?0:d+1,a.substring(0,d)+b+c+e}};
cc.loader={_jsCache:{},_register:{},_langPathCache:{},_aliases:{},resPath:"",audioPath:"",cache:{},getXMLHttpRequest:function(){return window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP")},_getArgs4Js:function(a){var b=a[0],c=a[1],d=a[2],e=["",null,null];if(1===a.length)e[1]=b instanceof Array?b:[b];else if(2===a.length)"function"==typeof c?(e[1]=b instanceof Array?b:[b],e[2]=c):(e[0]=b||"",e[1]=c instanceof Array?c:[c]);else{if(3!==a.length)throw"arguments error to load js!";
e[0]=b||"";e[1]=c instanceof Array?c:[c];e[2]=d}return e},loadJs:function(a,b,c){var d=this,e=d._jsCache,f=d._getArgs4Js(arguments),g=f[0],h=f[1],f=f[2];-1<navigator.userAgent.indexOf("Trident/5")?d._loadJs4Dependency(g,h,0,f):cc.async.map(h,function(a,b,c){a=cc.path.join(g,a);return e[a]?c(null):void d._createScript(a,!1,c)},f)},loadJsWithImg:function(a,b,c){var d=this._loadJsImg(),e=this._getArgs4Js(arguments);this.loadJs(e[0],e[1],function(a){if(a)throw a;d.parentNode.removeChild(d);e[2]&&e[2]()})},
_createScript:function(a,b,c){var d=document,e=cc.newElement("script");e.async=b;this._jsCache[a]=!0;cc.game.config.noCache&&"string"==typeof a?this._noCacheRex.test(a)?e.src=a+"\x26_t\x3d"+(new Date-0):e.src=a+"?_t\x3d"+(new Date-0):e.src=a;cc._addEventListener(e,"load",function(){e.parentNode.removeChild(e);this.removeEventListener("load",arguments.callee,!1);c()},!1);cc._addEventListener(e,"error",function(){e.parentNode.removeChild(e);c("Load "+a+" failed!")},!1);d.body.appendChild(e)},_loadJs4Dependency:function(a,
b,c,d){if(c>=b.length)return void(d&&d());var e=this;e._createScript(cc.path.join(a,b[c]),!1,function(f){return f?d(f):void e._loadJs4Dependency(a,b,c+1,d)})},_loadJsImg:function(){var a=document,b=a.getElementById("cocos2d_loadJsImg");if(!b){b=cc.newElement("img");cc._loadingImage&&(b.src=cc._loadingImage);a=a.getElementById(cc.game.config.id);a.style.backgroundColor="black";a.parentNode.appendChild(b);var c=getComputedStyle?getComputedStyle(a):a.currentStyle;c||(c={width:a.width,height:a.height});
b.style.left=a.offsetLeft+(parseFloat(c.width)-b.width)/2+"px";b.style.top=a.offsetTop+(parseFloat(c.height)-b.height)/2+"px";b.style.position="absolute"}return b},loadTxt:function(a,b){if(cc._isNodeJs)require("fs").readFile(a,function(a,c){a?b(a):b(null,c.toString())});else{var c=this.getXMLHttpRequest(),d="load "+a+" failed!";c.open("GET",a,!0);/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)?(c.setRequestHeader("Accept-Charset","utf-8"),c.onreadystatechange=function(){4===
c.readyState&&(200===c.status?b(null,c.responseText):b(d))}):(c.overrideMimeType&&c.overrideMimeType("text/plain; charset\x3dutf-8"),c.onload=function(){4===c.readyState&&(200===c.status?b(null,c.responseText):b(d))});c.send(null)}},_loadTxtSync:function(a){if(cc._isNodeJs)return require("fs").readFileSync(a).toString();var b=this.getXMLHttpRequest();return b.open("GET",a,!1),/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)?b.setRequestHeader("Accept-Charset","utf-8"):b.overrideMimeType&&
b.overrideMimeType("text/plain; charset\x3dutf-8"),b.send(null),4===!b.readyState||200!==b.status?null:b.responseText},loadCsb:function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="arraybuffer";c.onload=function(){var d=c.response;d&&(window.msg=d);4===c.readyState&&(200===c.status?b(null,c.response):b("load "+a+" failed!"))};c.send(null)},loadJson:function(a,b){this.loadTxt(a,function(c,d){if(c)b(c);else{try{var e=JSON.parse(d)}catch(f){throw"parse json ["+a+"] failed : "+f;}b(null,
e)}})},_checkIsImageURL:function(a){return null!=/(\.png)|(\.jpg)|(\.bmp)|(\.jpeg)|(\.gif)/.exec(a)},loadImg:function(a,b,c){var d={isCrossOrigin:!0};void 0!==c?d.isCrossOrigin=null===b.isCrossOrigin?d.isCrossOrigin:b.isCrossOrigin:void 0!==b&&(c=b);var e=this.getRes(a);if(e)return c&&c(null,e),e;e=new Image;d.isCrossOrigin&&"file://"!==location.origin&&(e.crossOrigin="Anonymous");var f=function(){this.removeEventListener("load",f,!1);this.removeEventListener("error",h,!1);cc.loader.cache[a]=e;c&&
c(null,e)},g=this,h=function(){this.removeEventListener("error",h,!1);e.crossOrigin&&"anonymous"===e.crossOrigin.toLowerCase()?(d.isCrossOrigin=!1,g.release(a),cc.loader.loadImg(a,d,c)):"function"==typeof c&&c("load image failed")};return cc._addEventListener(e,"load",f),cc._addEventListener(e,"error",h),e.src=a,e},_loadResIterator:function(a,b,c){var d=this,e=null,f=a.type;f?(f="."+f.toLowerCase(),e=a.src?a.src:a.name+f):(e=a,f=cc.path.extname(e));if(b=d.getRes(e))return c(null,b);b=null;if(f&&(b=
d._register[f.toLowerCase()]),!b)return cc.error("loader for ["+f+"] not exists!"),c();f=b.getBasePath?b.getBasePath():d.resPath;f=d.getUrl(f,e);cc.game.config.noCache&&"string"==typeof f&&(f+=d._noCacheRex.test(f)?"\x26_t\x3d"+(new Date-0):"?_t\x3d"+(new Date-0));b.load(f,e,a,function(a,b){a?(cc.log(a),d.cache[e]=null,delete d.cache[e],c()):(d.cache[e]=b,c(null,b))})},_noCacheRex:/\?/,getUrl:function(a,b){var c=this._langPathCache,d=cc.path;if(void 0!==a&&void 0===b){b=a;var e=d.extname(b),e=e?e.toLowerCase():
"";a=(e=this._register[e])&&e.getBasePath?e.getBasePath():this.resPath}if(b=cc.path.join(a||"",b),b.match(/[\/(\\\\)]lang[\/(\\\\)]/i)){if(c[b])return c[b];d=d.extname(b)||"";b=c[b]=b.substring(0,b.length-d.length)+"_"+cc.sys.language+d}return b},load:function(a,b,c){var d=this,e=arguments.length;if(0===e)throw"arguments error!";3===e?"function"==typeof b&&(b="function"==typeof c?{trigger:b,cb:c}:{cb:b,cbTarget:c}):2===e?"function"==typeof b&&(b={cb:b}):1===e&&(b={});a instanceof Array||(a=[a]);e=
new cc.AsyncPool(a,0,function(a,c,e,k){d._loadResIterator(a,c,function(a){if(a)return e(a);var c=Array.prototype.slice.call(arguments,1);b.trigger&&b.trigger.call(b.triggerTarget,c[0],k.size,k.finishedSize);e(null,c[0])})},b.cb,b.cbTarget);return e.flow(),e},_handleAliases:function(a,b){var c=this._aliases,d=[],e;for(e in a){var f=a[e];c[e]=f;d.push(f)}this.load(d,b)},loadAliases:function(a,b){var c=this,d=c.getRes(a);d?c._handleAliases(d.filenames,b):c.load(a,function(a,d){c._handleAliases(d[0].filenames,
b)})},register:function(a,b){if(a&&b){if("string"==typeof a)return this._register[a.trim().toLowerCase()]=b;for(var c=0,d=a.length;d>c;c++)this._register["."+a[c].trim().toLowerCase()]=b}},getRes:function(a){return this.cache[a]||this.cache[this._aliases[a]]},release:function(a){var b=this.cache,c=this._aliases;delete b[a];delete b[c[a]];delete c[a]},releaseAll:function(){var a=this.cache,b=this._aliases,c;for(c in a)delete a[c];for(c in b)delete b[c]}};
cc.formatStr=function(){var a=arguments,b=a.length;if(1>b)return"";var c=a[0],d=!0;"object"==typeof c&&(d=!1);for(var e=1;b>e;++e){var f=a[e];if(d)for(;;){var g=null;if("number"==typeof f&&c.match(/(%d)|(%s)/)){c=c.replace(/(%d)|(%s)/,f);break}(g=c.match(/%s/))?c=c.replace(/%s/,f):c+="    "+f;break}else c+="    "+f}return c};
(function(){var a,b,c=window;cc.isUndefined(document.hidden)?cc.isUndefined(document.mozHidden)?cc.isUndefined(document.msHidden)?cc.isUndefined(document.webkitHidden)||(a="webkitHidden",b="webkitvisibilitychange"):(a="msHidden",b="msvisibilitychange"):(a="mozHidden",b="mozvisibilitychange"):(a="hidden",b="visibilitychange");var d=function(){cc.eventManager&&cc.game._eventHide&&cc.eventManager.dispatchEvent(cc.game._eventHide)},e=function(){cc.eventManager&&cc.game._eventShow&&cc.eventManager.dispatchEvent(cc.game._eventShow);
cc.game._intervalId&&(window.cancelAnimationFrame(cc.game._intervalId),cc.game._runMainLoop())};a?cc._addEventListener(document,b,function(){document[a]?d():e()},!1):(cc._addEventListener(c,"blur",d,!1),cc._addEventListener(c,"focus",e,!1));-1<navigator.userAgent.indexOf("MicroMessenger")&&(c.onfocus=function(){e()});"onpageshow"in window&&"onpagehide"in window&&(cc._addEventListener(c,"pagehide",d,!1),cc._addEventListener(c,"pageshow",e,!1));b=c=null})();cc.log=cc.warn=cc.error=cc.assert=function(){};
cc.create3DContext=function(a,b){for(var c=["webgl","experimental-webgl","webkit-3d","moz-webgl"],d=null,e=0;e<c.length;++e){try{d=a.getContext(c[e],b)}catch(f){}if(d)break}return d};
cc._initSys=function(a,b){cc._RENDER_TYPE_CANVAS=0;cc._RENDER_TYPE_WEBGL=1;cc.sys={};var c=cc.sys;c.LANGUAGE_ENGLISH="en";c.LANGUAGE_CHINESE="zh";c.LANGUAGE_FRENCH="fr";c.LANGUAGE_ITALIAN="it";c.LANGUAGE_GERMAN="de";c.LANGUAGE_SPANISH="es";c.LANGUAGE_DUTCH="du";c.LANGUAGE_RUSSIAN="ru";c.LANGUAGE_KOREAN="ko";c.LANGUAGE_JAPANESE="ja";c.LANGUAGE_HUNGARIAN="hu";c.LANGUAGE_PORTUGUESE="pt";c.LANGUAGE_ARABIC="ar";c.LANGUAGE_NORWEGIAN="no";c.LANGUAGE_POLISH="pl";c.OS_IOS="iOS";c.OS_ANDROID="Android";c.OS_WINDOWS=
"Windows";c.OS_MARMALADE="Marmalade";c.OS_LINUX="Linux";c.OS_BADA="Bada";c.OS_BLACKBERRY="Blackberry";c.OS_OSX="OS X";c.OS_WP8="WP8";c.OS_WINRT="WINRT";c.OS_UNKNOWN="Unknown";c.UNKNOWN=0;c.IOS=1;c.ANDROID=2;c.WIN32=3;c.MARMALADE=4;c.LINUX=5;c.BADA=6;c.BLACKBERRY=7;c.MACOS=8;c.NACL=9;c.EMSCRIPTEN=10;c.TIZEN=11;c.QT5=12;c.WP8=13;c.WINRT=14;c.MOBILE_BROWSER=100;c.DESKTOP_BROWSER=101;c.BROWSER_TYPE_WECHAT="wechat";c.BROWSER_TYPE_ANDROID="androidbrowser";c.BROWSER_TYPE_IE="ie";c.BROWSER_TYPE_QQ="qqbrowser";
c.BROWSER_TYPE_MOBILE_QQ="mqqbrowser";c.BROWSER_TYPE_UC="ucbrowser";c.BROWSER_TYPE_360="360browser";c.BROWSER_TYPE_BAIDU_APP="baiduboxapp";c.BROWSER_TYPE_BAIDU="baidubrowser";c.BROWSER_TYPE_MAXTHON="maxthon";c.BROWSER_TYPE_OPERA="opera";c.BROWSER_TYPE_OUPENG="oupeng";c.BROWSER_TYPE_MIUI="miuibrowser";c.BROWSER_TYPE_FIREFOX="firefox";c.BROWSER_TYPE_SAFARI="safari";c.BROWSER_TYPE_CHROME="chrome";c.BROWSER_TYPE_LIEBAO="liebao";c.BROWSER_TYPE_QZONE="qzone";c.BROWSER_TYPE_SOUGOU="sogou";c.BROWSER_TYPE_UNKNOWN=
"unknown";c.isNative=!1;var d=window,e=d.navigator,f=document,g=f.documentElement,h=e.userAgent.toLowerCase();c.isMobile=-1!==h.indexOf("mobile")||-1!==h.indexOf("android");c.platform=c.isMobile?c.MOBILE_BROWSER:c.DESKTOP_BROWSER;var k=e.language,k=(k=k?k:e.browserLanguage)?k.split("-")[0]:c.LANGUAGE_ENGLISH;c.language=k;var k=c.BROWSER_TYPE_UNKNOWN,m=h.match(/sogou|qzone|liebao|micromessenger|qqbrowser|ucbrowser|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|trident|oupeng|opera|miuibrowser|firefox/i)||
h.match(/chrome|safari/i);m&&0<m.length?(k=m[0],"micromessenger"===k?k=c.BROWSER_TYPE_WECHAT:"safari"===k&&h.match(/android.*applewebkit/)?k=c.BROWSER_TYPE_ANDROID:"trident"===k?k=c.BROWSER_TYPE_IE:"360 aphone"===k&&(k=c.BROWSER_TYPE_360)):h.indexOf("iphone")&&h.indexOf("mobile")&&(k="safari");c.browserType=k;k=h.match(/(iPad|iPhone|iPod)/i)?!0:!1;h=h.match(/android/i)||e.platform.match(/android/i)?!0:!1;m=c.OS_UNKNOWN;-1!==e.appVersion.indexOf("Win")?m=c.OS_WINDOWS:k?m=c.OS_IOS:-1!==e.appVersion.indexOf("Mac")?
m=c.OS_OSX:-1!==e.appVersion.indexOf("X11")&&-1===e.appVersion.indexOf("Linux")?m=c.OS_UNIX:h?m=c.OS_ANDROID:-1!==e.appVersion.indexOf("Linux")&&(m=c.OS_LINUX);c.os=m;c._supportMultipleAudio=-1<[c.BROWSER_TYPE_BAIDU,c.BROWSER_TYPE_OPERA,c.BROWSER_TYPE_FIREFOX,c.BROWSER_TYPE_CHROME,c.BROWSER_TYPE_BAIDU_APP,c.BROWSER_TYPE_SAFARI,c.BROWSER_TYPE_UC,c.BROWSER_TYPE_QQ,c.BROWSER_TYPE_MOBILE_QQ,c.BROWSER_TYPE_IE].indexOf(c.browserType);(function(a,c){var e=c[b.renderMode]-0;(isNaN(e)||2<e||0>e)&&(e=0);var f=
[a.OS_ANDROID],g=[],h=cc.newElement("canvas");cc._renderType=cc._RENDER_TYPE_CANVAS;cc._supportRender=!1;var k=d.WebGLRenderingContext;if(2===e||0===e&&k&&-1===f.indexOf(a.os)&&-1===g.indexOf(a.browserType))try{cc.create3DContext(h,{stencil:!0,preserveDrawingBuffer:!0})&&(cc._renderType=cc._RENDER_TYPE_WEBGL,cc._supportRender=!0)}catch(m){}if(1===e||0===e&&!1===cc._supportRender)try{h.getContext("2d"),cc._renderType=cc._RENDER_TYPE_CANVAS,cc._supportRender=!0}catch(p){}})(c,a);c._canUseCanvasNewBlendModes=
function(){var a=document.createElement("canvas");a.width=1;a.height=1;a=a.getContext("2d");a.fillStyle="#000";a.fillRect(0,0,1,1);a.globalCompositeOperation="multiply";var b=document.createElement("canvas");b.width=1;b.height=1;var c=b.getContext("2d");return c.fillStyle="#fff",c.fillRect(0,0,1,1),a.drawImage(b,0,0,1,1),0===a.getImageData(0,0,1,1).data[0]};c._supportCanvasNewBlendModes=c._canUseCanvasNewBlendModes();try{c._supportWebAudio=!(!d.AudioContext&&!d.webkitAudioContext&&!d.mozAudioContext)}catch(n){c._supportWebAudio=
!1}try{var p=c.localStorage=d.localStorage;p.setItem("storage","");p.removeItem("storage");p=null}catch(r){("SECURITY_ERR"===r.name||"QuotaExceededError"===r.name)&&cc.warn("Warning: localStorage isn't enabled. Please confirm browser cookie or privacy option"),c.localStorage=function(){}}p=c.capabilities={canvas:!0};cc._renderType===cc._RENDER_TYPE_WEBGL&&(p.opengl=!0);(void 0!==g.ontouchstart||void 0!==f.ontouchstart||e.msPointerEnabled)&&(p.touches=!0);void 0!==g.onmouseup&&(p.mouse=!0);void 0!==
g.onkeyup&&(p.keyboard=!0);(d.DeviceMotionEvent||d.DeviceOrientationEvent)&&(p.accelerometer=!0);c.garbageCollect=function(){};c.dumpRoot=function(){};c.restartVM=function(){};c.cleanScript=function(a){};c.isObjectValid=function(a){return a?!0:!1};c.dump=function(){var a;a=""+("isMobile : "+this.isMobile+"\r\n");a+="language : "+this.language+"\r\n";a+="browserType : "+this.browserType+"\r\n";a+="capabilities : "+JSON.stringify(this.capabilities)+"\r\n";a+="os : "+this.os+"\r\n";a+="platform : "+
this.platform+"\r\n";cc.log(a)};c.openURL=function(a){window.open(a)}};cc.ORIENTATION_PORTRAIT=0;cc.ORIENTATION_PORTRAIT_UPSIDE_DOWN=1;cc.ORIENTATION_LANDSCAPE_LEFT=2;cc.ORIENTATION_LANDSCAPE_RIGHT=3;cc._drawingUtil=null;cc._renderContext=null;cc._canvas=null;cc._gameDiv=null;cc._rendererInitialized=!1;cc._setupCalled=!1;
cc._setup=function(a,b,c){if(!cc._setupCalled){cc._setupCalled=!0;var d,e,f,g=window;a=cc.$(a)||cc.$("#"+a);if(cc.game._setAnimFrame(),"CANVAS"===a.tagName?(b=b||a.width,c=c||a.height,e=cc.container=cc.newElement("DIV"),d=cc._canvas=a,d.parentNode.insertBefore(e,d),d.appendTo(e),e.setAttribute("id","Cocos2dGameContainer")):("DIV"!==a.tagName&&cc.log("Warning: target element is not a DIV or CANVAS"),b=b||a.clientWidth,c=c||a.clientHeight,e=cc.container=a,d=cc._canvas=cc.$(cc.newElement("CANVAS")),
a.appendChild(d)),d.addClass("gameCanvas"),d.setAttribute("width",b||480),d.setAttribute("height",c||320),d.setAttribute("tabindex",99),d.style.outline="none",f=e.style,f.width=(b||480)+"px",f.height=(c||320)+"px",f.margin="0 auto",f.position="relative",f.overflow="hidden",e.top="100%",cc._renderType===cc._RENDER_TYPE_WEBGL&&(cc._renderContext=cc.webglContext=cc.create3DContext(d,{stencil:!0,preserveDrawingBuffer:!0,antialias:!cc.sys.isMobile,alpha:!1})),cc._renderContext?(g.gl=cc._renderContext,
cc._drawingUtil=new cc.DrawingPrimitiveWebGL(cc._renderContext),cc._rendererInitialized=!0,cc.textureCache._initializingRenderer(),cc.shaderCache._init()):(cc._renderContext=new cc.CanvasContextWrapper(d.getContext("2d")),cc._drawingUtil=cc.DrawingPrimitiveCanvas?new cc.DrawingPrimitiveCanvas(cc._renderContext):null),cc._gameDiv=e,cc.log(cc.ENGINE_VERSION),cc._setContextMenuEnable(!1),cc.sys.isMobile)b=cc.newElement("style"),b.type="text/css",document.body.appendChild(b),b.textContent="body,canvas,div{ -moz-user-select: none;-webkit-user-select: none;-ms-user-select: none;-khtml-user-select: none;-webkit-tap-highlight-color:rgba(0,0,0,0);}";
cc.view=cc.EGLView._getInstance();cc.inputManager.registerSystemEvent(cc._canvas);cc.director=cc.Director._getInstance();cc.director.setOpenGLView&&cc.director.setOpenGLView(cc.view);cc.winSize=cc.director.getWinSize();cc.saxParser=new cc.SAXParser;cc.plistParser=new cc.PlistParser}};cc._checkWebGLRenderMode=function(){if(cc._renderType!==cc._RENDER_TYPE_WEBGL)throw"This feature supports WebGL render mode only.";};cc._isContextMenuEnable=!1;
cc._setContextMenuEnable=function(a){cc._isContextMenuEnable=a;cc._canvas.oncontextmenu=function(){return cc._isContextMenuEnable?void 0:!1}};
cc.game={DEBUG_MODE_NONE:0,DEBUG_MODE_INFO:1,DEBUG_MODE_WARN:2,DEBUG_MODE_ERROR:3,DEBUG_MODE_INFO_FOR_WEB_PAGE:4,DEBUG_MODE_WARN_FOR_WEB_PAGE:5,DEBUG_MODE_ERROR_FOR_WEB_PAGE:6,EVENT_HIDE:"game_on_hide",EVENT_SHOW:"game_on_show",_eventHide:null,_eventShow:null,_onBeforeStartArr:[],CONFIG_KEY:{engineDir:"engineDir",dependencies:"dependencies",debugMode:"debugMode",showFPS:"showFPS",frameRate:"frameRate",id:"id",renderMode:"renderMode",jsList:"jsList",classReleaseMode:"classReleaseMode"},_prepareCalled:!1,
_prepared:!1,_paused:!0,_intervalId:null,_lastTime:null,_frameTime:null,config:null,onStart:null,onStop:null,setFrameRate:function(a){this.config[this.CONFIG_KEY.frameRate]=a;this._intervalId&&window.cancelAnimationFrame(this._intervalId);this._paused=!0;this._setAnimFrame();this._runMainLoop()},_setAnimFrame:function(){this._lastTime=new Date;this._frameTime=1E3/cc.game.config[cc.game.CONFIG_KEY.frameRate];cc.sys.os===cc.sys.OS_IOS&&cc.sys.browserType===cc.sys.BROWSER_TYPE_WECHAT||60!==cc.game.config[cc.game.CONFIG_KEY.frameRate]?
(window.requestAnimFrame=this._stTime,window.cancelAnimationFrame=this._ctTime):(window.requestAnimFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||this._stTime,window.cancelAnimationFrame=window.cancelAnimationFrame||window.cancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.webkitCancelRequestAnimationFrame||
window.msCancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.oCancelAnimationFrame||this._ctTime)},_stTime:function(a){var b=(new Date).getTime(),c=Math.max(0,cc.game._frameTime-(b-cc.game._lastTime)),d=window.setTimeout(function(){a()},c);return cc.game._lastTime=b+c,d},_ctTime:function(a){window.clearTimeout(a)},_runMainLoop:function(){var a,b=this,c=cc.director;c.setDisplayStats(b.config[b.CONFIG_KEY.showFPS]);a=function(){b._paused||(c.mainLoop(),b._intervalId&&
window.cancelAnimationFrame(b._intervalId),b._intervalId=window.requestAnimFrame(a))};window.requestAnimFrame(a);b._paused=!1},restart:function(){cc.director.popToSceneStackLevel(0);cc.audioEngine&&cc.audioEngine.end();cc.game.onStart()},run:function(a){var b=this,c=function(){a&&(b.config[b.CONFIG_KEY.id]=a);b._prepareCalled||b.prepare(function(){b._prepared=!0});cc._supportRender&&(b._checkPrepare=setInterval(function(){b._prepared&&(cc._setup(b.config[b.CONFIG_KEY.id]),b._runMainLoop(),b._eventHide=
b._eventHide||new cc.EventCustom(b.EVENT_HIDE),b._eventHide.setUserData(b),b._eventShow=b._eventShow||new cc.EventCustom(b.EVENT_SHOW),b._eventShow.setUserData(b),b.onStart(),clearInterval(b._checkPrepare))},10))};document.body?c():cc._addEventListener(window,"load",function(){this.removeEventListener("load",arguments.callee,!1);c()},!1)},_initConfig:function(){var a=this.CONFIG_KEY,b=function(b){return b[a.engineDir]=b[a.engineDir]||"frameworks/cocos2d-html5",null==b[a.debugMode]&&(b[a.debugMode]=
0),b[a.frameRate]=b[a.frameRate]||60,null==b[a.renderMode]&&(b[a.renderMode]=1),b};if(document.ccConfig)this.config=b(document.ccConfig);else try{for(var c=document.getElementsByTagName("script"),d=0;d<c.length;d++){var e=c[d].getAttribute("cocos");if(""===e||e)break}var f,g,h;d<c.length&&(f=c[d].src,f&&(h=/(.*)\//.exec(f)[0],cc.loader.resPath=h,f=cc.path.join(h,"project.json")),g=cc.loader._loadTxtSync(f));g||(g=cc.loader._loadTxtSync("project.json"));var k=JSON.parse(g);this.config=b(k||{})}catch(m){cc.log("Failed to read or parse project.json"),
this.config=b({})}cc._initSys(this.config,a)},_jsAddedCache:{},_getJsListOfModule:function(a,b,c){var d=this._jsAddedCache;if(d[b])return null;c=c||"";var e=[],f=a[b];if(!f)throw"can not find module ["+b+"]";b=cc.path;for(var g=0,h=f.length;h>g;g++){var k=f[g];if(!d[k]){var m=b.extname(k);m?".js"===m.toLowerCase()&&e.push(b.join(c,k)):(m=this._getJsListOfModule(a,k,c))&&(e=e.concat(m));d[k]=1}}return e},prepare:function(a){var b=this,c=b.config,d=b.CONFIG_KEY,e=c[d.engineDir],f=cc.loader;if(!cc._supportRender)throw"The renderer doesn't support the renderMode "+
c[d.renderMode];b._prepareCalled=!0;var g=c[d.jsList]||[];cc.Class?f.loadJsWithImg("",g,function(c){if(c)throw c;b._prepared=!0;a&&a()}):(d=cc.path.join(e,"moduleConfig.json"),f.loadJson(d,function(d,f){if(d)throw d;var m=c.modules||[],n=f.module,p=[];cc._renderType===cc._RENDER_TYPE_WEBGL?m.splice(0,0,"shaders"):0>m.indexOf("core")&&m.splice(0,0,"core");for(var r=0,s=m.length;s>r;r++){var v=b._getJsListOfModule(n,m[r],e);v&&(p=p.concat(v))}p=p.concat(g);cc.loader.loadJsWithImg(p,function(c){if(c)throw c;
b._prepared=!0;a&&a()})}))}};cc.game._initConfig();Function.prototype.bind=Function.prototype.bind||function(a){if(!cc.isFunction(this))throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d&&a?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e};cc=cc||{};cc._loadingImage="data:image/gif;base64,R0lGODlhEAAQALMNAD8/P7+/vyoqKlVVVX9/fxUVFUBAQGBgYMDAwC8vL5CQkP///wAAAP///wAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFAAANACwAAAAAEAAQAAAEO5DJSau9OOvNex0IMnDIsiCkiW6g6BmKYlBFkhSUEgQKlQCARG6nEBwOgl+QApMdCIRD7YZ5RjlGpCUCACH5BAUAAA0ALAAAAgAOAA4AAAQ6kLGB0JA4M7QW0hrngRllkYyhKAYqKUGguAws0ypLS8JxCLQDgXAIDg+FRKIA6v0SAECCBpXSkstMBAAh+QQFAAANACwAAAAACgAQAAAEOJDJORAac6K1kDSKYmydpASBUl0mqmRfaGTCcQgwcxDEke+9XO2WkxQSiUIuAQAkls0n7JgsWq8RACH5BAUAAA0ALAAAAAAOAA4AAAQ6kMlplDIzTxWC0oxwHALnDQgySAdBHNWFLAvCukc215JIZihVIZEogDIJACBxnCSXTcmwGK1ar1hrBAAh+QQFAAANACwAAAAAEAAKAAAEN5DJKc4RM+tDyNFTkSQF5xmKYmQJACTVpQSBwrpJNteZSGYoFWjIGCAQA2IGsVgglBOmEyoxIiMAIfkEBQAADQAsAgAAAA4ADgAABDmQSVZSKjPPBEDSGucJxyGA1XUQxAFma/tOpDlnhqIYN6MEAUXvF+zldrMBAjHoIRYLhBMqvSmZkggAIfkEBQAADQAsBgAAAAoAEAAABDeQyUmrnSWlYhMASfeFVbZdjHAcgnUQxOHCcqWylKEohqUEAYVkgEAMfkEJYrFA6HhKJsJCNFoiACH5BAUAAA0ALAIAAgAOAA4AAAQ3kMlJq704611SKloCAEk4lln3DQgyUMJxCBKyLAh1EMRR3wiDQmHY9SQslyIQUMRmlmVTIyRaIgA7";
cc._fpsImage="data:image/png;base64, \x3d";
cc._loaderImage="data:image/jpeg;base64, \x3d";
cc.loader.loadBinary=function(a,b){var c=this,d=this.getXMLHttpRequest(),e="load "+a+" failed!";d.open("GET",a,!0);/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)?(d.setRequestHeader("Accept-Charset","x-user-defined"),d.onreadystatechange=function(){if(4===d.readyState&&200===d.status){var a=cc._convertResponseBodyToText(d.responseBody);b(null,c._str2Uint8Array(a))}else b(e)}):(d.overrideMimeType&&d.overrideMimeType("text/plain; charset\x3dx-user-defined"),d.onload=function(){4===
d.readyState&&200===d.status?b(null,c._str2Uint8Array(d.responseText)):b(e)});d.send(null)};cc.loader._str2Uint8Array=function(a){if(!a)return null;for(var b=new Uint8Array(a.length),c=0;c<a.length;c++)b[c]=255&a.charCodeAt(c);return b};
cc.loader.loadBinarySync=function(a){var b=this.getXMLHttpRequest(),c="load "+a+" failed!";b.open("GET",a,!1);a=null;if(/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)){if(b.setRequestHeader("Accept-Charset","x-user-defined"),b.send(null),200!==b.status)return cc.log(c),null;(b=cc._convertResponseBodyToText(b.responseBody))&&(a=this._str2Uint8Array(b))}else{if(b.overrideMimeType&&b.overrideMimeType("text/plain; charset\x3dx-user-defined"),b.send(null),200!==b.status)return cc.log(c),
null;a=this._str2Uint8Array(b.responseText)}return a};var Uint8Array=Uint8Array||Array;
if(/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)){var IEBinaryToArray_ByteStr_Script='\x3c!-- IEBinaryToArray_ByteStr --\x3e\r\nFunction IEBinaryToArray_ByteStr(Binary)\r\n   IEBinaryToArray_ByteStr \x3d CStr(Binary)\r\nEnd Function\r\nFunction IEBinaryToArray_ByteStr_Last(Binary)\r\n   Dim lastIndex\r\n   lastIndex \x3d LenB(Binary)\r\n   if lastIndex mod 2 Then\r\n       IEBinaryToArray_ByteStr_Last \x3d Chr( AscB( MidB( Binary, lastIndex, 1 ) ) )\r\n   Else\r\n       IEBinaryToArray_ByteStr_Last \x3d ""\r\n   End If\r\nEnd Function\r\n',myVBScript=
cc.newElement("script");myVBScript.type="text/vbscript";myVBScript.textContent=IEBinaryToArray_ByteStr_Script;document.body.appendChild(myVBScript);cc._convertResponseBodyToText=function(a){for(var b={},c=0;256>c;c++)for(var d=0;256>d;d++)b[String.fromCharCode(c+256*d)]=String.fromCharCode(c)+String.fromCharCode(d);c=IEBinaryToArray_ByteStr(a);a=IEBinaryToArray_ByteStr_Last(a);return c.replace(/[\s\S]/g,function(a){return b[a]})+a}}
var cc=cc||{},ClassManager={id:0|998*Math.random(),instanceId:0|998*Math.random(),compileSuper:function(a,b,c){a=a.toString();var d=a.indexOf("("),e=a.indexOf(")"),d=a.substring(d+1,e),d=d.trim(),e=a.indexOf("{"),f=a.lastIndexOf("}");for(a=a.substring(e+1,f);-1!==a.indexOf("this._super");){var e=a.indexOf("this._super"),f=a.indexOf("(",e),g=a.indexOf(")",f),g=a.substring(f+1,g),g=(g=g.trim())?",":"";a=a.substring(0,e)+"ClassManager["+c+"]."+b+".call(this"+g+a.substring(f+1)}return Function(d,a)},
getNewID:function(){return this.id++},getNewInstanceId:function(){return this.instanceId++}};
switch(ClassManager.compileSuper.ClassManager=ClassManager,function(){var a=/\b_super\b/,b=cc.game.config[cc.game.CONFIG_KEY.classReleaseMode];b&&console.log("release Mode");cc.Class=function(){};cc.Class.extend=function(c){function d(){this.__instanceId=ClassManager.getNewInstanceId();this.ctor&&this.ctor.apply(this,arguments)}var e=this.prototype,f=Object.create(e),g=ClassManager.getNewID();ClassManager[g]=e;var h={writable:!0,enumerable:!1,configurable:!0};f.__instanceId=null;d.id=g;h.value=g;
Object.defineProperty(f,"__pid",h);d.prototype=f;h.value=d;Object.defineProperty(d.prototype,"constructor",h);this.__getters__&&(d.__getters__=cc.clone(this.__getters__));this.__setters__&&(d.__setters__=cc.clone(this.__setters__));for(var k=0,m=arguments.length;m>k;++k){var n=arguments[k],p;for(p in n){var r="function"==typeof n[p],s="function"==typeof e[p],v=a.test(n[p]);if(b&&r&&s&&v?(h.value=ClassManager.compileSuper(n[p],p,g),Object.defineProperty(f,p,h)):r&&s&&v?(h.value=function(a,b){return function(){var c=
this._super;this._super=e[a];var d=b.apply(this,arguments);return this._super=c,d}}(p,n[p]),Object.defineProperty(f,p,h)):r?(h.value=n[p],Object.defineProperty(f,p,h)):f[p]=n[p],r){var u,t;if(this.__getters__&&this.__getters__[p]){var r=this.__getters__[p],x;for(x in this.__setters__)if(this.__setters__[x]===r){t=x;break}cc.defineGetterSetter(f,r,n[p],n[t]?n[t]:f[t],p,t)}if(this.__setters__&&this.__setters__[p]){r=this.__setters__[p];for(x in this.__getters__)if(this.__getters__[x]===r){u=x;break}cc.defineGetterSetter(f,
r,n[u]?n[u]:f[u],n[p],u,p)}}}}return d.extend=cc.Class.extend,d.implement=function(a){for(var b in a)f[b]=a[b]},d}}(),cc.defineGetterSetter=function(a,b,c,d,e,f){if(a.__defineGetter__)c&&a.__defineGetter__(b,c),d&&a.__defineSetter__(b,d);else{if(!Object.defineProperty)throw Error("browser does not support getters");var g={enumerable:!1,configurable:!0};c&&(g.get=c);d&&(g.set=d);Object.defineProperty(a,b,g)}if(!e&&!f)for(var g=null!=c,h=void 0!=d,k=Object.getOwnPropertyNames(a),m=0;m<k.length;m++){var n=
k[m];if((a.__lookupGetter__?!a.__lookupGetter__(n):!Object.getOwnPropertyDescriptor(a,n))&&"function"==typeof a[n]){var p=a[n];if(g&&p===c&&(e=n,!h||f))break;if(h&&p===d&&(f=n,!g||e))break}}a=a.constructor;e&&(a.__getters__||(a.__getters__={}),a.__getters__[e]=b);f&&(a.__setters__||(a.__setters__={}),a.__setters__[f]=b)},cc.clone=function(a){var b=a.constructor?new a.constructor:{},c;for(c in a){var d=a[c];"object"!=typeof d||!d||d instanceof cc.Node||d instanceof HTMLElement?b[c]=d:b[c]=cc.clone(d)}return b},
cc.inject=function(a,b){for(var c in a)b[c]=a[c]},cc.Point=function(a,b){this.x=a||0;this.y=b||0},cc.p=function(a,b){return void 0===a?{x:0,y:0}:void 0===b?{x:a.x,y:a.y}:{x:a,y:b}},cc.pointEqualToPoint=function(a,b){return a&&b&&a.x===b.x&&a.y===b.y},cc.Size=function(a,b){this.width=a||0;this.height=b||0},cc.size=function(a,b){return void 0===a?{width:0,height:0}:void 0===b?{width:a.width,height:a.height}:{width:a,height:b}},cc.sizeEqualToSize=function(a,b){return a&&b&&a.width===b.width&&a.height===
b.height},cc.Rect=function(a,b,c,d){this.x=a||0;this.y=b||0;this.width=c||0;this.height=d||0},cc.rect=function(a,b,c,d){return void 0===a?{x:0,y:0,width:0,height:0}:void 0===b?{x:a.x,y:a.y,width:a.width,height:a.height}:{x:a,y:b,width:c,height:d}},cc.rectEqualToRect=function(a,b){return a&&b&&a.x===b.x&&a.y===b.y&&a.width===b.width&&a.height===b.height},cc._rectEqualToZero=function(a){return a&&0===a.x&&0===a.y&&0===a.width&&0===a.height},cc.rectContainsRect=function(a,b){return a&&b?!(a.x>=b.x||
a.y>=b.y||a.x+a.width<=b.x+b.width||a.y+a.height<=b.y+b.height):!1},cc.rectGetMaxX=function(a){return a.x+a.width},cc.rectGetMidX=function(a){return a.x+a.width/2},cc.rectGetMinX=function(a){return a.x},cc.rectGetMaxY=function(a){return a.y+a.height},cc.rectGetMidY=function(a){return a.y+a.height/2},cc.rectGetMinY=function(a){return a.y},cc.rectContainsPoint=function(a,b){return b.x>=cc.rectGetMinX(a)&&b.x<=cc.rectGetMaxX(a)&&b.y>=cc.rectGetMinY(a)&&b.y<=cc.rectGetMaxY(a)},cc.rectIntersectsRect=function(a,
b){var c=a.y+a.height,d=b.x+b.width,e=b.y+b.height;return!(a.x+a.width<b.x||d<a.x||c<b.y||e<a.y)},cc.rectOverlapsRect=function(a,b){return!(a.x+a.width<b.x||b.x+b.width<a.x||a.y+a.height<b.y||b.y+b.height<a.y)},cc.rectUnion=function(a,b){var c=cc.rect(0,0,0,0);return c.x=Math.min(a.x,b.x),c.y=Math.min(a.y,b.y),c.width=Math.max(a.x+a.width,b.x+b.width)-c.x,c.height=Math.max(a.y+a.height,b.y+b.height)-c.y,c},cc.rectIntersection=function(a,b){var c=cc.rect(Math.max(cc.rectGetMinX(a),cc.rectGetMinX(b)),
Math.max(cc.rectGetMinY(a),cc.rectGetMinY(b)),0,0);return c.width=Math.min(cc.rectGetMaxX(a),cc.rectGetMaxX(b))-cc.rectGetMinX(c),c.height=Math.min(cc.rectGetMaxY(a),cc.rectGetMaxY(b))-cc.rectGetMinY(c),c},cc.SAXParser=cc.Class.extend({_parser:null,_isSupportDOMParser:null,ctor:function(){window.DOMParser?(this._isSupportDOMParser=!0,this._parser=new DOMParser):this._isSupportDOMParser=!1},parse:function(a){return this._parseXML(a)},_parseXML:function(a){var b;return this._isSupportDOMParser?b=this._parser.parseFromString(a,
"text/xml"):(b=new ActiveXObject("Microsoft.XMLDOM"),b.async="false",b.loadXML(a)),b}}),cc.PlistParser=cc.SAXParser.extend({parse:function(a){a=this._parseXML(a).documentElement;if("plist"!==a.tagName)throw"Not a plist file!";for(var b=null,c=0,d=a.childNodes.length;d>c&&(b=a.childNodes[c],1!==b.nodeType);c++);return this._parseNode(b)},_parseNode:function(a){var b=null,c=a.tagName;if("dict"===c)b=this._parseDict(a);else if("array"===c)b=this._parseArray(a);else if("string"===c)if(1===a.childNodes.length)b=
a.firstChild.nodeValue;else{b="";for(c=0;c<a.childNodes.length;c++)b+=a.childNodes[c].nodeValue}else"false"===c?b=!1:"true"===c?b=!0:"real"===c?b=parseFloat(a.firstChild.nodeValue):"integer"===c&&(b=parseInt(a.firstChild.nodeValue,10));return b},_parseArray:function(a){for(var b=[],c=0,d=a.childNodes.length;d>c;c++){var e=a.childNodes[c];1===e.nodeType&&b.push(this._parseNode(e))}return b},_parseDict:function(a){for(var b={},c=null,d=0,e=a.childNodes.length;e>d;d++){var f=a.childNodes[d];1===f.nodeType&&
("key"===f.tagName?c=f.firstChild.nodeValue:b[c]=this._parseNode(f))}return b}}),cc._txtLoader={load:function(a,b,c,d){cc.loader.loadTxt(a,d)}},cc.loader.register(["txt","xml","vsh","fsh","atlas"],cc._txtLoader),cc._jsonLoader={load:function(a,b,c,d){cc.loader.loadJson(a,d)}},cc.loader.register(["json","ExportJson"],cc._jsonLoader),cc._jsLoader={load:function(a,b,c,d){cc.loader.loadJs(a,d)}},cc.loader.register(["js"],cc._jsLoader),cc._imgLoader={load:function(a,b,c,d){cc.loader.cache[b]=cc.loader.loadImg(a,
function(a,c){return a?d(a):(cc.textureCache.handleLoadedTexture(b),void d(null,c))})}},cc.loader.register("png jpg bmp jpeg gif ico".split(" "),cc._imgLoader),cc._serverImgLoader={load:function(a,b,c,d){cc.loader.cache[b]=cc.loader.loadImg(c.src,function(a,c){return a?d(a):(cc.textureCache.handleLoadedTexture(b),void d(null,c))})}},cc.loader.register(["serverImg"],cc._serverImgLoader),cc._plistLoader={load:function(a,b,c,d){cc.loader.loadTxt(a,function(a,b){return a?d(a):void d(null,cc.plistParser.parse(b))})}},
cc.loader.register(["plist"],cc._plistLoader),cc._fontLoader={TYPE:{".eot":"embedded-opentype",".ttf":"truetype",".woff":"woff",".svg":"svg"},_loadFont:function(a,b,c){var d=document,e=cc.path,f=this.TYPE,g=cc.newElement("style");g.type="text/css";d.body.appendChild(g);var h="@font-face { font-family:"+a+"; src:";if(b instanceof Array)for(var k=0,m=b.length;m>k;k++)c=e.extname(b[k]).toLowerCase(),h+="url('"+b[k]+"') format('"+f[c]+"')",h+=k===m-1?";":",";else h+="url('"+b+"') format('"+f[c]+"');";
g.textContent+=h+"};";b=cc.newElement("div");c=b.style;c.fontFamily=a;b.innerHTML=".";c.position="absolute";c.left="-100px";c.top="-100px";d.body.appendChild(b)},load:function(a,b,c,d){a=c.type;b=c.name;var e=c.srcs;cc.isString(c)?(a=cc.path.extname(c),b=cc.path.basename(c,a),this._loadFont(b,c,a)):this._loadFont(b,e);d(null,!0)}},cc.loader.register(["font","eot","ttf","woff","svg"],cc._fontLoader),cc._binaryLoader={load:function(a,b,c,d){cc.loader.loadBinary(a,d)}},cc._csbLoader={load:function(a,
b,c,d){cc.loader.loadCsb(a,d)}},cc.loader.register(["csb"],cc._csbLoader),window.CocosEngine=cc.ENGINE_VERSION="Cocos2d-JS v3.6",cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL=0,cc.DIRECTOR_STATS_POSITION=cc.p(0,0),cc.DIRECTOR_FPS_INTERVAL=0.5,cc.COCOSNODE_RENDER_SUBPIXEL=1,cc.SPRITEBATCHNODE_RENDER_SUBPIXEL=1,cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA=0,cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP=0,cc.TEXTURE_ATLAS_USE_VAO=0,cc.TEXTURE_NPOT_SUPPORT=0,cc.RETINA_DISPLAY_SUPPORT=1,cc.RETINA_DISPLAY_FILENAME_SUFFIX=
"-hd",cc.USE_LA88_LABELS=1,cc.SPRITE_DEBUG_DRAW=0,cc.SPRITEBATCHNODE_DEBUG_DRAW=0,cc.LABELBMFONT_DEBUG_DRAW=0,cc.LABELATLAS_DEBUG_DRAW=0,cc.IS_RETINA_DISPLAY_SUPPORTED=1,cc.DEFAULT_ENGINE=cc.ENGINE_VERSION+"-canvas",cc.ENABLE_STACKABLE_ACTIONS=1,cc.ENABLE_GL_STATE_CACHE=1,cc.$=function(a){var b=this===cc?document:this;a=a instanceof HTMLElement?a:b.querySelector(a);return a&&(a.find=a.find||cc.$,a.hasClass=a.hasClass||function(a){return this.className.match(RegExp("(\\s|^)"+a+"(\\s|$)"))},a.addClass=
a.addClass||function(a){return this.hasClass(a)||(this.className&&(this.className+=" "),this.className+=a),this},a.removeClass=a.removeClass||function(a){return this.hasClass(a)&&(this.className=this.className.replace(a,"")),this},a.remove=a.remove||function(){return this.parentNode&&this.parentNode.removeChild(this),this},a.appendTo=a.appendTo||function(a){return a.appendChild(this),this},a.prependTo=a.prependTo||function(a){return a.childNodes[0]?a.insertBefore(this,a.childNodes[0]):a.appendChild(this),
this},a.transforms=a.transforms||function(){return this.style[cc.$.trans]=cc.$.translate(this.position)+cc.$.rotate(this.rotation)+cc.$.scale(this.scale)+cc.$.skew(this.skew),this},a.position=a.position||{x:0,y:0},a.rotation=a.rotation||0,a.scale=a.scale||{x:1,y:1},a.skew=a.skew||{x:0,y:0},a.translates=function(a,b){return this.position.x=a,this.position.y=b,this.transforms(),this},a.rotate=function(a){return this.rotation=a,this.transforms(),this},a.resize=function(a,b){return this.scale.x=a,this.scale.y=
b,this.transforms(),this},a.setSkew=function(a,b){return this.skew.x=a,this.skew.y=b,this.transforms(),this}),a},cc.sys.browserType){case cc.sys.BROWSER_TYPE_FIREFOX:cc.$.pfx="Moz";cc.$.hd=!0;break;case cc.sys.BROWSER_TYPE_CHROME:case cc.sys.BROWSER_TYPE_SAFARI:cc.$.pfx="webkit";cc.$.hd=!0;break;case cc.sys.BROWSER_TYPE_OPERA:cc.$.pfx="O";cc.$.hd=!1;break;case cc.sys.BROWSER_TYPE_IE:cc.$.pfx="ms";cc.$.hd=!1;break;default:cc.$.pfx="webkit",cc.$.hd=!0}cc.$.trans=cc.$.pfx+"Transform";
cc.$.translate=cc.$.hd?function(a){return"translate3d("+a.x+"px, "+a.y+"px, 0) "}:function(a){return"translate("+a.x+"px, "+a.y+"px) "};cc.$.rotate=cc.$.hd?function(a){return"rotateZ("+a+"deg) "}:function(a){return"rotate("+a+"deg) "};cc.$.scale=function(a){return"scale("+a.x+", "+a.y+") "};cc.$.skew=function(a){return"skewX("+-a.x+"deg) skewY("+a.y+"deg)"};cc.$new=function(a){return cc.$(document.createElement(a))};
cc.$.findpos=function(a){var b=0,c=0;do b+=a.offsetLeft,c+=a.offsetTop;while(a=a.offsetParent);return{x:b,y:c}};cc.INVALID_INDEX=-1;cc.PI=Math.PI;cc.FLT_MAX=parseFloat("3.402823466e+38F");cc.FLT_MIN=parseFloat("1.175494351e-38F");cc.RAD=cc.PI/180;cc.DEG=180/cc.PI;cc.UINT_MAX=4294967295;cc.swap=function(a,b,c){if(!cc.isObject(c)||cc.isUndefined(c.x)||cc.isUndefined(c.y))cc.log(cc._LogInfos.swap);else{var d=c[a];c[a]=c[b];c[b]=d}};cc.lerp=function(a,b,c){return a+(b-a)*c};
cc.rand=function(){return 16777215*Math.random()};cc.randomMinus1To1=function(){return 2*(Math.random()-0.5)};cc.random0To1=Math.random;cc.degreesToRadians=function(a){return a*cc.RAD};cc.radiansToDegrees=function(a){return a*cc.DEG};cc.radiansToDegress=function(a){return cc.log(cc._LogInfos.radiansToDegress),a*cc.DEG};cc.REPEAT_FOREVER=Number.MAX_VALUE-1;cc.BLEND_SRC=cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA?1:770;cc.BLEND_DST=771;
cc.nodeDrawSetup=function(a){a._shaderProgram&&(a._shaderProgram.use(),a._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4())};cc.enableDefaultGLStates=function(){};cc.disableDefaultGLStates=function(){};cc.incrementGLDraws=function(a){cc.g_NumberOfDraws+=a};cc.FLT_EPSILON=1.192092896E-7;cc.contentScaleFactor=cc.IS_RETINA_DISPLAY_SUPPORTED?function(){return cc.director.getContentScaleFactor()}:function(){return 1};
cc.pointPointsToPixels=function(a){var b=cc.contentScaleFactor();return cc.p(a.x*b,a.y*b)};cc.pointPixelsToPoints=function(a){var b=cc.contentScaleFactor();return cc.p(a.x/b,a.y/b)};cc._pointPixelsToPointsOut=function(a,b){var c=cc.contentScaleFactor();b.x=a.x/c;b.y=a.y/c};cc.sizePointsToPixels=function(a){var b=cc.contentScaleFactor();return cc.size(a.width*b,a.height*b)};cc.sizePixelsToPoints=function(a){var b=cc.contentScaleFactor();return cc.size(a.width/b,a.height/b)};
cc._sizePixelsToPointsOut=function(a,b){var c=cc.contentScaleFactor();b.width=a.width/c;b.height=a.height/c};cc.rectPixelsToPoints=cc.IS_RETINA_DISPLAY_SUPPORTED?function(a){var b=cc.contentScaleFactor();return cc.rect(a.x/b,a.y/b,a.width/b,a.height/b)}:function(a){return a};cc.rectPointsToPixels=cc.IS_RETINA_DISPLAY_SUPPORTED?function(a){var b=cc.contentScaleFactor();return cc.rect(a.x*b,a.y*b,a.width*b,a.height*b)}:function(a){return a};cc.ONE=1;cc.ZERO=0;cc.SRC_ALPHA=770;
cc.SRC_ALPHA_SATURATE=776;cc.SRC_COLOR=768;cc.DST_ALPHA=772;cc.DST_COLOR=774;cc.ONE_MINUS_SRC_ALPHA=771;cc.ONE_MINUS_SRC_COLOR=769;cc.ONE_MINUS_DST_ALPHA=773;cc.ONE_MINUS_DST_COLOR=775;cc.ONE_MINUS_CONSTANT_ALPHA=32772;cc.ONE_MINUS_CONSTANT_COLOR=32770;cc.LINEAR=9729;cc.REPEAT=10497;cc.CLAMP_TO_EDGE=33071;cc.MIRRORED_REPEAT=33648;cc.checkGLErrorDebug=function(){if(cc.renderMode===cc._RENDER_TYPE_WEBGL){var a=cc._renderContext.getError();a&&cc.log(cc._LogInfos.checkGLErrorDebug,a)}};
cc.DEVICE_ORIENTATION_PORTRAIT=0;cc.DEVICE_ORIENTATION_LANDSCAPE_LEFT=1;cc.DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN=2;cc.DEVICE_ORIENTATION_LANDSCAPE_RIGHT=3;cc.DEVICE_MAX_ORIENTATIONS=2;cc.VERTEX_ATTRIB_FLAG_NONE=0;cc.VERTEX_ATTRIB_FLAG_POSITION=1;cc.VERTEX_ATTRIB_FLAG_COLOR=2;cc.VERTEX_ATTRIB_FLAG_TEX_COORDS=4;cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX=cc.VERTEX_ATTRIB_FLAG_POSITION|cc.VERTEX_ATTRIB_FLAG_COLOR|cc.VERTEX_ATTRIB_FLAG_TEX_COORDS;cc.GL_ALL=0;cc.VERTEX_ATTRIB_POSITION=0;
cc.VERTEX_ATTRIB_COLOR=1;cc.VERTEX_ATTRIB_TEX_COORDS=2;cc.VERTEX_ATTRIB_MAX=3;cc.UNIFORM_PMATRIX=0;cc.UNIFORM_MVMATRIX=1;cc.UNIFORM_MVPMATRIX=2;cc.UNIFORM_TIME=3;cc.UNIFORM_SINTIME=4;cc.UNIFORM_COSTIME=5;cc.UNIFORM_RANDOM01=6;cc.UNIFORM_SAMPLER=7;cc.UNIFORM_MAX=8;cc.SHADER_POSITION_TEXTURECOLOR="ShaderPositionTextureColor";cc.SHADER_POSITION_TEXTURECOLORALPHATEST="ShaderPositionTextureColorAlphaTest";cc.SHADER_POSITION_COLOR="ShaderPositionColor";cc.SHADER_POSITION_TEXTURE="ShaderPositionTexture";
cc.SHADER_POSITION_TEXTURE_UCOLOR="ShaderPositionTexture_uColor";cc.SHADER_POSITION_TEXTUREA8COLOR="ShaderPositionTextureA8Color";cc.SHADER_POSITION_UCOLOR="ShaderPosition_uColor";cc.SHADER_POSITION_LENGTHTEXTURECOLOR="ShaderPositionLengthTextureColor";cc.UNIFORM_PMATRIX_S="CC_PMatrix";cc.UNIFORM_MVMATRIX_S="CC_MVMatrix";cc.UNIFORM_MVPMATRIX_S="CC_MVPMatrix";cc.UNIFORM_TIME_S="CC_Time";cc.UNIFORM_SINTIME_S="CC_SinTime";cc.UNIFORM_COSTIME_S="CC_CosTime";cc.UNIFORM_RANDOM01_S="CC_Random01";
cc.UNIFORM_SAMPLER_S="CC_Texture0";cc.UNIFORM_ALPHA_TEST_VALUE_S="CC_alpha_value";cc.ATTRIBUTE_NAME_COLOR="a_color";cc.ATTRIBUTE_NAME_POSITION="a_position";cc.ATTRIBUTE_NAME_TEX_COORD="a_texCoord";cc.ITEM_SIZE=32;cc.CURRENT_ITEM=3233828865;cc.ZOOM_ACTION_TAG=3233828866;cc.NORMAL_TAG=8801;cc.SELECTED_TAG=8802;cc.DISABLE_TAG=8803;cc.arrayVerifyType=function(a,b){if(a&&0<a.length)for(var c=0;c<a.length;c++)if(!(a[c]instanceof b))return cc.log("element type is wrong!"),!1;return!0};
cc.arrayRemoveObject=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b){a.splice(c,1);break}};cc.arrayRemoveArray=function(a,b){for(var c=0,d=b.length;d>c;c++)cc.arrayRemoveObject(a,b[c])};cc.arrayAppendObjectsToIndex=function(a,b,c){return a.splice.apply(a,[c,0].concat(b)),a};cc.copyArray=function(a){var b,c=a.length,d=Array(c);for(b=0;c>b;b+=1)d[b]=a[b];return d};
cc._tmp.PrototypeColor=function(){var a=cc.color;a._getWhite=function(){return a(255,255,255)};a._getYellow=function(){return a(255,255,0)};a._getBlue=function(){return a(0,0,255)};a._getGreen=function(){return a(0,255,0)};a._getRed=function(){return a(255,0,0)};a._getMagenta=function(){return a(255,0,255)};a._getBlack=function(){return a(0,0,0)};a._getOrange=function(){return a(255,127,0)};a._getGray=function(){return a(166,166,166)};a.WHITE;cc.defineGetterSetter(a,"WHITE",a._getWhite);a.YELLOW;
cc.defineGetterSetter(a,"YELLOW",a._getYellow);a.BLUE;cc.defineGetterSetter(a,"BLUE",a._getBlue);a.GREEN;cc.defineGetterSetter(a,"GREEN",a._getGreen);a.RED;cc.defineGetterSetter(a,"RED",a._getRed);a.MAGENTA;cc.defineGetterSetter(a,"MAGENTA",a._getMagenta);a.BLACK;cc.defineGetterSetter(a,"BLACK",a._getBlack);a.ORANGE;cc.defineGetterSetter(a,"ORANGE",a._getOrange);a.GRAY;cc.defineGetterSetter(a,"GRAY",a._getGray);cc.BlendFunc._disable=function(){return new cc.BlendFunc(cc.ONE,cc.ZERO)};cc.BlendFunc._alphaPremultiplied=
function(){return new cc.BlendFunc(cc.ONE,cc.ONE_MINUS_SRC_ALPHA)};cc.BlendFunc._alphaNonPremultiplied=function(){return new cc.BlendFunc(cc.SRC_ALPHA,cc.ONE_MINUS_SRC_ALPHA)};cc.BlendFunc._additive=function(){return new cc.BlendFunc(cc.SRC_ALPHA,cc.ONE)};cc.BlendFunc.DISABLE;cc.defineGetterSetter(cc.BlendFunc,"DISABLE",cc.BlendFunc._disable);cc.BlendFunc.ALPHA_PREMULTIPLIED;cc.defineGetterSetter(cc.BlendFunc,"ALPHA_PREMULTIPLIED",cc.BlendFunc._alphaPremultiplied);cc.BlendFunc.ALPHA_NON_PREMULTIPLIED;
cc.defineGetterSetter(cc.BlendFunc,"ALPHA_NON_PREMULTIPLIED",cc.BlendFunc._alphaNonPremultiplied);cc.BlendFunc.ADDITIVE;cc.defineGetterSetter(cc.BlendFunc,"ADDITIVE",cc.BlendFunc._additive)};cc=cc||{};
switch(cc._tmp=cc._tmp||{},cc._tmp.WebGLColor=function(){cc.color=function(a,c,d,e,f,g){return void 0===a?new cc.Color(0,0,0,255,f,g):cc.isString(a)?(a=cc.hexToColor(a),new cc.Color(a.r,a.g,a.b,a.a)):cc.isObject(a)?new cc.Color(a.r,a.g,a.b,a.a,a.arrayBuffer,a.offset):new cc.Color(a,c,d,e,f,g)};cc.Color=function(a,c,d,e,f,g){this._arrayBuffer=f||new ArrayBuffer(cc.Color.BYTES_PER_ELEMENT);this._offset=g||0;f=this._arrayBuffer;g=this._offset;var h=Uint8Array.BYTES_PER_ELEMENT;this._rU8=new Uint8Array(f,
g,1);this._gU8=new Uint8Array(f,g+h,1);this._bU8=new Uint8Array(f,g+2*h,1);this._aU8=new Uint8Array(f,g+3*h,1);this._rU8[0]=a||0;this._gU8[0]=c||0;this._bU8[0]=d||0;this._aU8[0]=null==e?255:e;void 0===e&&(this.a_undefined=!0)};cc.Color.BYTES_PER_ELEMENT=4;var a=cc.Color.prototype;a._getR=function(){return this._rU8[0]};a._setR=function(a){this._rU8[0]=0>a?0:a};a._getG=function(){return this._gU8[0]};a._setG=function(a){this._gU8[0]=0>a?0:a};a._getB=function(){return this._bU8[0]};a._setB=function(a){this._bU8[0]=
0>a?0:a};a._getA=function(){return this._aU8[0]};a._setA=function(a){this._aU8[0]=0>a?0:a};a.r;cc.defineGetterSetter(a,"r",a._getR,a._setR);a.g;cc.defineGetterSetter(a,"g",a._getG,a._setG);a.b;cc.defineGetterSetter(a,"b",a._getB,a._setB);a.a;cc.defineGetterSetter(a,"a",a._getA,a._setA);cc.Vertex2F=function(a,c,d,e){this._arrayBuffer=d||new ArrayBuffer(cc.Vertex2F.BYTES_PER_ELEMENT);this._offset=e||0;this._xF32=new Float32Array(this._arrayBuffer,this._offset,1);this._yF32=new Float32Array(this._arrayBuffer,
this._offset+4,1);this._xF32[0]=a||0;this._yF32[0]=c||0};cc.Vertex2F.BYTES_PER_ELEMENT=8;a=cc.Vertex2F.prototype;a._getX=function(){return this._xF32[0]};a._setX=function(a){this._xF32[0]=a};a._getY=function(){return this._yF32[0]};a._setY=function(a){this._yF32[0]=a};a.x;cc.defineGetterSetter(a,"x",a._getX,a._setX);a.y;cc.defineGetterSetter(a,"y",a._getY,a._setY);cc.Vertex3F=function(a,c,d,e,f){this._arrayBuffer=e||new ArrayBuffer(cc.Vertex3F.BYTES_PER_ELEMENT);this._offset=f||0;e=this._arrayBuffer;
f=this._offset;this._xF32=new Float32Array(e,f,1);this._xF32[0]=a||0;this._yF32=new Float32Array(e,f+Float32Array.BYTES_PER_ELEMENT,1);this._yF32[0]=c||0;this._zF32=new Float32Array(e,f+2*Float32Array.BYTES_PER_ELEMENT,1);this._zF32[0]=d||0};cc.Vertex3F.BYTES_PER_ELEMENT=12;a=cc.Vertex3F.prototype;a._getX=function(){return this._xF32[0]};a._setX=function(a){this._xF32[0]=a};a._getY=function(){return this._yF32[0]};a._setY=function(a){this._yF32[0]=a};a._getZ=function(){return this._zF32[0]};a._setZ=
function(a){this._zF32[0]=a};a.x;cc.defineGetterSetter(a,"x",a._getX,a._setX);a.y;cc.defineGetterSetter(a,"y",a._getY,a._setY);a.z;cc.defineGetterSetter(a,"z",a._getZ,a._setZ);cc.Tex2F=function(a,c,d,e){this._arrayBuffer=d||new ArrayBuffer(cc.Tex2F.BYTES_PER_ELEMENT);this._offset=e||0;this._uF32=new Float32Array(this._arrayBuffer,this._offset,1);this._vF32=new Float32Array(this._arrayBuffer,this._offset+4,1);this._uF32[0]=a||0;this._vF32[0]=c||0};cc.Tex2F.BYTES_PER_ELEMENT=8;a=cc.Tex2F.prototype;
a._getU=function(){return this._uF32[0]};a._setU=function(a){this._uF32[0]=a};a._getV=function(){return this._vF32[0]};a._setV=function(a){this._vF32[0]=a};a.u;cc.defineGetterSetter(a,"u",a._getU,a._setU);a.v;cc.defineGetterSetter(a,"v",a._getV,a._setV);cc.Quad2=function(a,c,d,e,f,g){this._arrayBuffer=f||new ArrayBuffer(cc.Quad2.BYTES_PER_ELEMENT);this._offset=g||0;f=this._arrayBuffer;g=cc.Vertex2F.BYTES_PER_ELEMENT;this._tl=a?new cc.Vertex2F(a.x,a.y,f,0):new cc.Vertex2F(0,0,f,0);this._tr=c?new cc.Vertex2F(c.x,
c.y,f,g):new cc.Vertex2F(0,0,f,g);this._bl=d?new cc.Vertex2F(d.x,d.y,f,2*g):new cc.Vertex2F(0,0,f,2*g);this._br=e?new cc.Vertex2F(e.x,e.y,f,3*g):new cc.Vertex2F(0,0,f,3*g)};cc.Quad2.BYTES_PER_ELEMENT=32;a=cc.Quad2.prototype;a._getTL=function(){return this._tl};a._setTL=function(a){this._tl.x=a.x;this._tl.y=a.y};a._getTR=function(){return this._tr};a._setTR=function(a){this._tr.x=a.x;this._tr.y=a.y};a._getBL=function(){return this._bl};a._setBL=function(a){this._bl.x=a.x;this._bl.y=a.y};a._getBR=function(){return this._br};
a._setBR=function(a){this._br.x=a.x;this._br.y=a.y};a.tl;cc.defineGetterSetter(a,"tl",a._getTL,a._setTL);a.tr;cc.defineGetterSetter(a,"tr",a._getTR,a._setTR);a.bl;cc.defineGetterSetter(a,"bl",a._getBL,a._setBL);a.br;cc.defineGetterSetter(a,"br",a._getBR,a._setBR);cc.Quad3=function(a,c,d,e){this.bl=a||new cc.Vertex3F(0,0,0);this.br=c||new cc.Vertex3F(0,0,0);this.tl=d||new cc.Vertex3F(0,0,0);this.tr=e||new cc.Vertex3F(0,0,0)};cc.V3F_C4B_T2F=function(a,c,d,e,f){this._arrayBuffer=e||new ArrayBuffer(cc.V3F_C4B_T2F.BYTES_PER_ELEMENT);
this._offset=f||0;e=this._arrayBuffer;f=this._offset;var g=cc.Vertex3F.BYTES_PER_ELEMENT;this._vertices=a?new cc.Vertex3F(a.x,a.y,a.z,e,f):new cc.Vertex3F(0,0,0,e,f);this._colors=c?cc.color(c.r,c.g,c.b,c.a,e,f+g):cc.color(0,0,0,0,e,f+g);this._texCoords=d?new cc.Tex2F(d.u,d.v,e,f+g+cc.Color.BYTES_PER_ELEMENT):new cc.Tex2F(0,0,e,f+g+cc.Color.BYTES_PER_ELEMENT)};cc.V3F_C4B_T2F.BYTES_PER_ELEMENT=24;a=cc.V3F_C4B_T2F.prototype;a._getVertices=function(){return this._vertices};a._setVertices=function(a){var c=
this._vertices;c.x=a.x;c.y=a.y;c.z=a.z};a._getColor=function(){return this._colors};a._setColor=function(a){var c=this._colors;c.r=a.r;c.g=a.g;c.b=a.b;c.a=a.a};a._getTexCoords=function(){return this._texCoords};a._setTexCoords=function(a){this._texCoords.u=a.u;this._texCoords.v=a.v};a.vertices;cc.defineGetterSetter(a,"vertices",a._getVertices,a._setVertices);a.colors;cc.defineGetterSetter(a,"colors",a._getColor,a._setColor);a.texCoords;cc.defineGetterSetter(a,"texCoords",a._getTexCoords,a._setTexCoords);
cc.V3F_C4B_T2F_Quad=function(a,c,d,e,f,g){this._arrayBuffer=f||new ArrayBuffer(cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT);this._offset=g||0;f=this._arrayBuffer;g=this._offset;var h=cc.V3F_C4B_T2F.BYTES_PER_ELEMENT;this._tl=a?new cc.V3F_C4B_T2F(a.vertices,a.colors,a.texCoords,f,g):new cc.V3F_C4B_T2F(null,null,null,f,g);this._bl=c?new cc.V3F_C4B_T2F(c.vertices,c.colors,c.texCoords,f,g+h):new cc.V3F_C4B_T2F(null,null,null,f,g+h);this._tr=d?new cc.V3F_C4B_T2F(d.vertices,d.colors,d.texCoords,f,g+2*h):new cc.V3F_C4B_T2F(null,
null,null,f,g+2*h);this._br=e?new cc.V3F_C4B_T2F(e.vertices,e.colors,e.texCoords,f,g+3*h):new cc.V3F_C4B_T2F(null,null,null,f,g+3*h)};cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT=96;a=cc.V3F_C4B_T2F_Quad.prototype;a._getTL=function(){return this._tl};a._setTL=function(a){var c=this._tl;c.vertices=a.vertices;c.colors=a.colors;c.texCoords=a.texCoords};a._getBL=function(){return this._bl};a._setBL=function(a){var c=this._bl;c.vertices=a.vertices;c.colors=a.colors;c.texCoords=a.texCoords};a._getTR=function(){return this._tr};
a._setTR=function(a){var c=this._tr;c.vertices=a.vertices;c.colors=a.colors;c.texCoords=a.texCoords};a._getBR=function(){return this._br};a._setBR=function(a){var c=this._br;c.vertices=a.vertices;c.colors=a.colors;c.texCoords=a.texCoords};a._getArrayBuffer=function(){return this._arrayBuffer};a.tl;cc.defineGetterSetter(a,"tl",a._getTL,a._setTL);a.tr;cc.defineGetterSetter(a,"tr",a._getTR,a._setTR);a.bl;cc.defineGetterSetter(a,"bl",a._getBL,a._setBL);a.br;cc.defineGetterSetter(a,"br",a._getBR,a._setBR);
a.arrayBuffer;cc.defineGetterSetter(a,"arrayBuffer",a._getArrayBuffer,null);cc.V3F_C4B_T2F_QuadZero=function(){return new cc.V3F_C4B_T2F_Quad};cc.V3F_C4B_T2F_QuadCopy=function(a){if(!a)return cc.V3F_C4B_T2F_QuadZero();var c=a.tl,d=a.bl,e=a.tr;a=a.br;return{tl:{vertices:{x:c.vertices.x,y:c.vertices.y,z:c.vertices.z},colors:{r:c.colors.r,g:c.colors.g,b:c.colors.b,a:c.colors.a},texCoords:{u:c.texCoords.u,v:c.texCoords.v}},bl:{vertices:{x:d.vertices.x,y:d.vertices.y,z:d.vertices.z},colors:{r:d.colors.r,
g:d.colors.g,b:d.colors.b,a:d.colors.a},texCoords:{u:d.texCoords.u,v:d.texCoords.v}},tr:{vertices:{x:e.vertices.x,y:e.vertices.y,z:e.vertices.z},colors:{r:e.colors.r,g:e.colors.g,b:e.colors.b,a:e.colors.a},texCoords:{u:e.texCoords.u,v:e.texCoords.v}},br:{vertices:{x:a.vertices.x,y:a.vertices.y,z:a.vertices.z},colors:{r:a.colors.r,g:a.colors.g,b:a.colors.b,a:a.colors.a},texCoords:{u:a.texCoords.u,v:a.texCoords.v}}}};cc.V3F_C4B_T2F_QuadsCopy=function(a){if(!a)return[];for(var c=[],d=0;d<a.length;d++)c.push(cc.V3F_C4B_T2F_QuadCopy(a[d]));
return c};cc.V2F_C4B_T2F=function(a,c,d,e,f){this._arrayBuffer=e||new ArrayBuffer(cc.V2F_C4B_T2F.BYTES_PER_ELEMENT);this._offset=f||0;e=this._arrayBuffer;f=this._offset;var g=cc.Vertex2F.BYTES_PER_ELEMENT;this._vertices=a?new cc.Vertex2F(a.x,a.y,e,f):new cc.Vertex2F(0,0,e,f);this._colors=c?cc.color(c.r,c.g,c.b,c.a,e,f+g):cc.color(0,0,0,0,e,f+g);this._texCoords=d?new cc.Tex2F(d.u,d.v,e,f+g+cc.Color.BYTES_PER_ELEMENT):new cc.Tex2F(0,0,e,f+g+cc.Color.BYTES_PER_ELEMENT)};cc.V2F_C4B_T2F.BYTES_PER_ELEMENT=
20;a=cc.V2F_C4B_T2F.prototype;a._getVertices=function(){return this._vertices};a._setVertices=function(a){this._vertices.x=a.x;this._vertices.y=a.y};a._getColor=function(){return this._colors};a._setColor=function(a){var c=this._colors;c.r=a.r;c.g=a.g;c.b=a.b;c.a=a.a};a._getTexCoords=function(){return this._texCoords};a._setTexCoords=function(a){this._texCoords.u=a.u;this._texCoords.v=a.v};a.vertices;cc.defineGetterSetter(a,"vertices",a._getVertices,a._setVertices);a.colors;cc.defineGetterSetter(a,
"colors",a._getColor,a._setColor);a.texCoords;cc.defineGetterSetter(a,"texCoords",a._getTexCoords,a._setTexCoords);cc.V2F_C4B_T2F_Triangle=function(a,c,d,e,f){this._arrayBuffer=e||new ArrayBuffer(cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT);this._offset=f||0;e=this._arrayBuffer;f=this._offset;var g=cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;this._a=a?new cc.V2F_C4B_T2F(a.vertices,a.colors,a.texCoords,e,f):new cc.V2F_C4B_T2F(null,null,null,e,f);this._b=c?new cc.V2F_C4B_T2F(c.vertices,c.colors,c.texCoords,e,f+
g):new cc.V2F_C4B_T2F(null,null,null,e,f+g);this._c=d?new cc.V2F_C4B_T2F(d.vertices,d.colors,d.texCoords,e,f+2*g):new cc.V2F_C4B_T2F(null,null,null,e,f+2*g)};cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT=60;a=cc.V2F_C4B_T2F_Triangle.prototype;a._getA=function(){return this._a};a._setA=function(a){var c=this._a;c.vertices=a.vertices;c.colors=a.colors;c.texCoords=a.texCoords};a._getB=function(){return this._b};a._setB=function(a){var c=this._b;c.vertices=a.vertices;c.colors=a.colors;c.texCoords=a.texCoords};
a._getC=function(){return this._c};a._setC=function(a){var c=this._c;c.vertices=a.vertices;c.colors=a.colors;c.texCoords=a.texCoords};a.a;cc.defineGetterSetter(a,"a",a._getA,a._setA);a.b;cc.defineGetterSetter(a,"b",a._getB,a._setB);a.c;cc.defineGetterSetter(a,"c",a._getC,a._setC)},cc.Color=function(a,b,c,d){this.r=a||0;this.g=b||0;this.b=c||0;this.a=null==d?255:d},cc.color=function(a,b,c,d){return void 0===a?{r:0,g:0,b:0,a:255}:cc.isString(a)?cc.hexToColor(a):cc.isObject(a)?{r:a.r,g:a.g,b:a.b,a:null==
a.a?255:a.a}:{r:a,g:b,b:c,a:null==d?255:d}},cc.colorEqual=function(a,b){return a.r===b.r&&a.g===b.g&&a.b===b.b},cc.Acceleration=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.timestamp=d||0},cc.Vertex2F=function(a,b){this.x=a||0;this.y=b||0},cc.vertex2=function(a,b){return new cc.Vertex2F(a,b)},cc.Vertex3F=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0},cc.vertex3=function(a,b,c){return new cc.Vertex3F(a,b,c)},cc.Tex2F=function(a,b){this.u=a||0;this.v=b||0},cc.tex2=function(a,b){return new cc.Tex2F(a,
b)},cc.BlendFunc=function(a,b){this.src=a;this.dst=b},cc.blendFuncDisable=function(){return new cc.BlendFunc(cc.ONE,cc.ZERO)},cc.hexToColor=function(a){a=a.replace(/^#?/,"0x");a=parseInt(a);return cc.color(a>>16,(a>>8)%256,a%256)},cc.colorToHex=function(a){var b=a.r.toString(16),c=a.g.toString(16),d=a.b.toString(16);return"#"+(16>a.r?"0"+b:b)+(16>a.g?"0"+c:c)+(16>a.b?"0"+d:d)},cc.TEXT_ALIGNMENT_LEFT=0,cc.TEXT_ALIGNMENT_CENTER=1,cc.TEXT_ALIGNMENT_RIGHT=2,cc.VERTICAL_TEXT_ALIGNMENT_TOP=0,cc.VERTICAL_TEXT_ALIGNMENT_CENTER=
1,cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM=2,cc._Dictionary=cc.Class.extend({_keyMapTb:null,_valueMapTb:null,__currId:0,ctor:function(){this._keyMapTb={};this._valueMapTb={};this.__currId=2<<(0|10*Math.random())},__getKey:function(){return this.__currId++,"key_"+this.__currId},setObject:function(a,b){if(null!=b){var c=this.__getKey();this._keyMapTb[c]=b;this._valueMapTb[c]=a}},objectForKey:function(a){if(null==a)return null;var b=this._keyMapTb,c;for(c in b)if(b[c]===a)return this._valueMapTb[c];return null},
valueForKey:function(a){return this.objectForKey(a)},removeObjectForKey:function(a){if(null!=a){var b=this._keyMapTb,c;for(c in b)if(b[c]===a)return delete this._valueMapTb[c],void delete b[c]}},removeObjectsForKeys:function(a){if(null!=a)for(var b=0;b<a.length;b++)this.removeObjectForKey(a[b])},allKeys:function(){var a=[],b=this._keyMapTb,c;for(c in b)a.push(b[c]);return a},removeAllObjects:function(){this._keyMapTb={};this._valueMapTb={}},count:function(){return this.allKeys().length}}),cc.FontDefinition=
function(a){if(this.fontName="Arial",this.fontSize=12,this.textAlign=cc.TEXT_ALIGNMENT_CENTER,this.verticalAlign=cc.VERTICAL_TEXT_ALIGNMENT_TOP,this.fillStyle=cc.color(255,255,255,255),this.boundingWidth=0,this.boundingHeight=0,this.strokeEnabled=!1,this.strokeStyle=cc.color(255,255,255,255),this.lineWidth=1,this.lineHeight="normal",this.fontStyle="normal",this.fontWeight="normal",this.shadowEnabled=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0,this.shadowOpacity=1,a&&a instanceof
Object)for(var b in a)this[b]=a[b]},cc.FontDefinition.prototype._getCanvasFontStr=function(){return this.fontStyle+" "+this.fontWeight+" "+this.fontSize+"px/"+(this.lineHeight.charAt?this.lineHeight:this.lineHeight+"px")+" '"+this.fontName+"'"},cc._renderType===cc._RENDER_TYPE_WEBGL&&(cc.assert(cc.isFunction(cc._tmp.WebGLColor),cc._LogInfos.MissingFile,"CCTypesWebGL.js"),cc._tmp.WebGLColor(),delete cc._tmp.WebGLColor),cc.assert(cc.isFunction(cc._tmp.PrototypeColor),cc._LogInfos.MissingFile,"CCTypesPropertyDefine.js"),
cc._tmp.PrototypeColor(),delete cc._tmp.PrototypeColor,cc.Touches=[],cc.TouchesIntergerDict={},cc.DENSITYDPI_DEVICE="device-dpi",cc.DENSITYDPI_HIGH="high-dpi",cc.DENSITYDPI_MEDIUM="medium-dpi",cc.DENSITYDPI_LOW="low-dpi",cc.__BrowserGetter={init:function(){this.html=document.getElementsByTagName("html")[0]},availWidth:function(a){return a&&a!==this.html?a.clientWidth:window.innerWidth},availHeight:function(a){return a&&a!==this.html?a.clientHeight:window.innerHeight},meta:{width:"device-width","user-scalable":"no"},
adaptationType:cc.sys.browserType},-1<window.navigator.userAgent.indexOf("OS 8_1_")&&(cc.__BrowserGetter.adaptationType=cc.sys.BROWSER_TYPE_MIUI),cc.sys.os===cc.sys.OS_IOS&&(cc.__BrowserGetter.adaptationType=cc.sys.BROWSER_TYPE_SAFARI),cc.__BrowserGetter.adaptationType){case cc.sys.BROWSER_TYPE_SAFARI:cc.__BrowserGetter.meta["minimal-ui"]="true";cc.__BrowserGetter.availWidth=function(a){return a.clientWidth};cc.__BrowserGetter.availHeight=function(a){return a.clientHeight};break;case cc.sys.BROWSER_TYPE_CHROME:cc.__BrowserGetter.__defineGetter__("target-densitydpi",
function(){return cc.view._targetDensityDPI});case cc.sys.BROWSER_TYPE_SOUGOU:case cc.sys.BROWSER_TYPE_UC:cc.__BrowserGetter.availWidth=function(a){return a.clientWidth};cc.__BrowserGetter.availHeight=function(a){return a.clientHeight};break;case cc.sys.BROWSER_TYPE_MIUI:cc.__BrowserGetter.init=function(a){if(!a.__resizeWithBrowserSize){var b=function(){a.setDesignResolutionSize(a._designResolutionSize.width,a._designResolutionSize.height,a._resolutionPolicy);window.removeEventListener("resize",b,
!1)};window.addEventListener("resize",b,!1)}}}
if(cc.EGLView=cc.Class.extend({_delegate:null,_frameSize:null,_designResolutionSize:null,_originalDesignResolutionSize:null,_viewPortRect:null,_visibleRect:null,_retinaEnabled:!1,_autoFullScreen:!0,_devicePixelRatio:1,_viewName:"",_resizeCallback:null,_scaleX:1,_originalScaleX:1,_scaleY:1,_originalScaleY:1,_indexBitsUsed:0,_maxTouches:5,_resolutionPolicy:null,_rpExactFit:null,_rpShowAll:null,_rpNoBorder:null,_rpFixedHeight:null,_rpFixedWidth:null,_initialized:!1,_captured:!1,_wnd:null,_hDC:null,_hRC:null,
_supportTouch:!1,_contentTranslateLeftTop:null,_frame:null,_frameZoomFactor:1,__resizeWithBrowserSize:!1,_isAdjustViewPort:!0,_targetDensityDPI:null,ctor:function(){var a=document,b=cc.ContainerStrategy,c=cc.ContentStrategy;cc.__BrowserGetter.init(this);this._frame=cc.container.parentNode===a.body?a.documentElement:cc.container.parentNode;this._frameSize=cc.size(0,0);this._initFrameSize();var a=cc._canvas.width,d=cc._canvas.height;this._designResolutionSize=cc.size(a,d);this._originalDesignResolutionSize=
cc.size(a,d);this._viewPortRect=cc.rect(0,0,a,d);this._visibleRect=cc.rect(0,0,a,d);this._contentTranslateLeftTop={left:0,top:0};this._viewName="Cocos2dHTML5";a=cc.sys;this.enableRetina(a.os===a.OS_IOS||a.os===a.OS_OSX);cc.visibleRect&&cc.visibleRect.init(this._visibleRect);this._rpExactFit=new cc.ResolutionPolicy(b.EQUAL_TO_FRAME,c.EXACT_FIT);this._rpShowAll=new cc.ResolutionPolicy(b.PROPORTION_TO_FRAME,c.SHOW_ALL);this._rpNoBorder=new cc.ResolutionPolicy(b.EQUAL_TO_FRAME,c.NO_BORDER);this._rpFixedHeight=
new cc.ResolutionPolicy(b.EQUAL_TO_FRAME,c.FIXED_HEIGHT);this._rpFixedWidth=new cc.ResolutionPolicy(b.EQUAL_TO_FRAME,c.FIXED_WIDTH);this._hDC=cc._canvas;this._hRC=cc._renderContext;this._targetDensityDPI=cc.DENSITYDPI_HIGH},_resizeEvent:function(){var a;a=this.setDesignResolutionSize?this:cc.view;var b=a._frameSize.width,c=a._frameSize.height;if(a._initFrameSize(),a._frameSize.width!==b||a._frameSize.height!==c)a._resizeCallback&&a._resizeCallback.call(),b=a._originalDesignResolutionSize.width,c=
a._originalDesignResolutionSize.height,0<b&&a.setDesignResolutionSize(b,c,a._resolutionPolicy)},setTargetDensityDPI:function(a){this._targetDensityDPI=a;this._setViewPortMeta()},getTargetDensityDPI:function(){return this._targetDensityDPI},resizeWithBrowserSize:function(a){a?this.__resizeWithBrowserSize||(this.__resizeWithBrowserSize=!0,cc._addEventListener(window,"resize",this._resizeEvent),cc._addEventListener(window,"orientationchange",this._resizeEvent)):this.__resizeWithBrowserSize&&(this.__resizeWithBrowserSize=
!1,window.removeEventListener("resize",this._resizeEvent),window.removeEventListener("orientationchange",this._resizeEvent))},setResizeCallback:function(a){(cc.isFunction(a)||null==a)&&(this._resizeCallback=a)},_initFrameSize:function(){var a=this._frameSize;a.width=cc.__BrowserGetter.availWidth(this._frame);a.height=cc.__BrowserGetter.availHeight(this._frame)},_adjustSizeKeepCanvasSize:function(){var a=this._originalDesignResolutionSize.width,b=this._originalDesignResolutionSize.height;0<a&&this.setDesignResolutionSize(a,
b,this._resolutionPolicy)},_setViewPortMeta:function(){if(this._isAdjustViewPort){var a=document.getElementById("cocosMetaElement");a&&document.head.removeChild(a);var b,c,d=(a=document.getElementsByName("viewport"))?a[0]:null,a=cc.newElement("meta");a.id="cocosMetaElement";a.name="viewport";a.content="";b=cc.__BrowserGetter.meta;c=d?d.content:"";for(var e in b)RegExp(e).test(c)||(c+=","+e+"\x3d"+b[e]);/^,/.test(c)&&(c=c.substr(1));a.content=c;d&&(d.content=c);document.head.appendChild(a)}},_setScaleXYForRenderTexture:function(){var a=
cc.contentScaleFactor();this._scaleY=this._scaleX=a},_resetScale:function(){this._scaleX=this._originalScaleX;this._scaleY=this._originalScaleY},_adjustSizeToBrowser:function(){},initialize:function(){this._initialized=!0},adjustViewPort:function(a){this._isAdjustViewPort=a},enableRetina:function(a){this._retinaEnabled=a?!0:!1},isRetinaEnabled:function(){return this._retinaEnabled},enableAutoFullScreen:function(a){this._autoFullScreen=a?!0:!1},isAutoFullScreenEnabled:function(){return this._autoFullScreen},
end:function(){},isOpenGLReady:function(){return null!==this._hDC&&null!==this._hRC},setFrameZoomFactor:function(a){this._frameZoomFactor=a;this.centerWindow();cc.director.setProjection(cc.director.getProjection())},swapBuffers:function(){},setIMEKeyboardState:function(a){},setContentTranslateLeftTop:function(a,b){this._contentTranslateLeftTop={left:a,top:b}},getContentTranslateLeftTop:function(){return this._contentTranslateLeftTop},getFrameSize:function(){return cc.size(this._frameSize.width,this._frameSize.height)},
setFrameSize:function(a,b){this._frameSize.width=a;this._frameSize.height=b;this._frame.style.width=a+"px";this._frame.style.height=b+"px";this._resizeEvent();cc.director.setProjection(cc.director.getProjection())},centerWindow:function(){},getVisibleSize:function(){return cc.size(this._visibleRect.width,this._visibleRect.height)},getVisibleOrigin:function(){return cc.p(this._visibleRect.x,this._visibleRect.y)},canSetContentScaleFactor:function(){return!0},getResolutionPolicy:function(){return this._resolutionPolicy},
setResolutionPolicy:function(a){if(a instanceof cc.ResolutionPolicy)this._resolutionPolicy=a;else{var b=cc.ResolutionPolicy;a===b.EXACT_FIT&&(this._resolutionPolicy=this._rpExactFit);a===b.SHOW_ALL&&(this._resolutionPolicy=this._rpShowAll);a===b.NO_BORDER&&(this._resolutionPolicy=this._rpNoBorder);a===b.FIXED_HEIGHT&&(this._resolutionPolicy=this._rpFixedHeight);a===b.FIXED_WIDTH&&(this._resolutionPolicy=this._rpFixedWidth)}},setDesignResolutionSize:function(a,b,c){if(!(0<a||0<b))return void cc.log(cc._LogInfos.EGLView_setDesignResolutionSize);
this.setResolutionPolicy(c);c=this._resolutionPolicy;if(!c)return void cc.log(cc._LogInfos.EGLView_setDesignResolutionSize_2);c.preApply(this);cc.sys.isMobile&&this._setViewPortMeta();this._initFrameSize();this._originalDesignResolutionSize.width=this._designResolutionSize.width=a;this._originalDesignResolutionSize.height=this._designResolutionSize.height=b;var d=c.apply(this,this._designResolutionSize);if(d.scale&&2===d.scale.length&&(this._scaleX=d.scale[0],this._scaleY=d.scale[1]),d.viewport)a=
this._viewPortRect,b=this._visibleRect,d=d.viewport,a.x=d.x,a.y=d.y,a.width=d.width,a.height=d.height,b.x=-a.x/this._scaleX,b.y=-a.y/this._scaleY,b.width=cc._canvas.width/this._scaleX,b.height=cc._canvas.height/this._scaleY,cc._renderContext.setOffset&&cc._renderContext.setOffset(a.x,-a.y);a=cc.director;a._winSizeInPoints.width=this._designResolutionSize.width;a._winSizeInPoints.height=this._designResolutionSize.height;c.postApply(this);cc.winSize.width=a._winSizeInPoints.width;cc.winSize.height=
a._winSizeInPoints.height;cc._renderType===cc._RENDER_TYPE_WEBGL&&(a._createStatsLabel(),a.setGLDefaultValues());this._originalScaleX=this._scaleX;this._originalScaleY=this._scaleY;cc.DOM&&cc.DOM._resetEGLViewDiv();cc.visibleRect&&cc.visibleRect.init(this._visibleRect)},getDesignResolutionSize:function(){return cc.size(this._designResolutionSize.width,this._designResolutionSize.height)},setViewPortInPoints:function(a,b,c,d){var e=this._frameZoomFactor,f=this._scaleX,g=this._scaleY;cc._renderContext.viewport(a*
f*e+this._viewPortRect.x*e,b*g*e+this._viewPortRect.y*e,c*f*e,d*g*e)},setScissorInPoints:function(a,b,c,d){var e=this._frameZoomFactor,f=this._scaleX,g=this._scaleY;cc._renderContext.scissor(a*f*e+this._viewPortRect.x*e,b*g*e+this._viewPortRect.y*e,c*f*e,d*g*e)},isScissorEnabled:function(){var a=cc._renderContext;return a.isEnabled(a.SCISSOR_TEST)},getScissorRect:function(){var a=cc._renderContext,b=this._scaleX,c=this._scaleY,a=a.getParameter(a.SCISSOR_BOX);return cc.rect((a[0]-this._viewPortRect.x)/
b,(a[1]-this._viewPortRect.y)/c,a[2]/b,a[3]/c)},setViewName:function(a){null!=a&&0<a.length&&(this._viewName=a)},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(a,b,c){return{x:this._devicePixelRatio*(a-c.left),y:this._devicePixelRatio*(c.top+c.height-b)}},_convertMouseToLocationInView:function(a,
b){var c=this._viewPortRect;a.x=(this._devicePixelRatio*(a.x-b.left)-c.x)/this._scaleX;a.y=(this._devicePixelRatio*(b.top+b.height-a.y)-c.y)/this._scaleY},_convertTouchesWithScale:function(a){for(var b,c,d,e=this._viewPortRect,f=this._scaleX,g=this._scaleY,h=0;h<a.length;h++)b=a[h],c=b._point,d=b._prevPoint,b._setPoint((c.x-e.x)/f,(c.y-e.y)/g),b._setPrevPoint((d.x-e.x)/f,(d.y-e.y)/g)}}),cc.EGLView._getInstance=function(){return this._instance||(this._instance=this._instance||new cc.EGLView,this._instance.initialize()),
this._instance},cc.ContainerStrategy=cc.Class.extend({preApply:function(a){},apply:function(a,b){},postApply:function(a){},_setupContainer:function(a,b,c){var d=a._frame;cc.view._autoFullScreen&&cc.sys.isMobile&&d===document.documentElement&&cc.screen.autoFullScreen(d);var d=cc._canvas,e=cc.container;e.style.width=d.style.width=b+"px";e.style.height=d.style.height=c+"px";e=a._devicePixelRatio=1;a.isRetinaEnabled()&&(e=a._devicePixelRatio=window.devicePixelRatio||1);d.width=b*e;d.height=c*e;cc._renderContext.resetCache&&
cc._renderContext.resetCache();var f;(a=document.body)&&(f=a.style)&&(f.paddingTop=f.paddingTop||"0px",f.paddingRight=f.paddingRight||"0px",f.paddingBottom=f.paddingBottom||"0px",f.paddingLeft=f.paddingLeft||"0px",f.borderTop=f.borderTop||"0px",f.borderRight=f.borderRight||"0px",f.borderBottom=f.borderBottom||"0px",f.borderLeft=f.borderLeft||"0px",f.marginTop=f.marginTop||"0px",f.marginRight=f.marginRight||"0px",f.marginBottom=f.marginBottom||"0px",f.marginLeft=f.marginLeft||"0px")},_fixContainer:function(){document.body.insertBefore(cc.container,
document.body.firstChild);var a=document.body.style;a.width=window.innerWidth+"px";a.height=window.innerHeight+"px";a.overflow="hidden";a=cc.container.style;a.position="fixed";a.left=a.top="0px";document.body.scrollTop=0}}),cc.ContentStrategy=cc.Class.extend({_result:{scale:[1,1],viewport:null},_buildResult:function(a,b,c,d,e,f){2>Math.abs(a-c)&&(c=a);2>Math.abs(b-d)&&(d=b);a=cc.rect(Math.round((a-c)/2),Math.round((b-d)/2),c,d);return cc._renderType===cc._RENDER_TYPE_CANVAS,this._result.scale=[e,
f],this._result.viewport=a,this._result},preApply:function(a){},apply:function(a,b){return{scale:[1,1]}},postApply:function(a){}}),function(){var a=cc.ContainerStrategy.extend({apply:function(a){this._setupContainer(a,a._frameSize.width,a._frameSize.height)}}),b=cc.ContainerStrategy.extend({apply:function(a,b){var c,d,e=a._frameSize.width,n=a._frameSize.height,p=cc.container.style,r=b.width,s=b.height,v=e/r,u=n/s;u>v?(c=e,d=s*v):(c=r*u,d=n);c=Math.round((e-c)/2);d=Math.round((n-d)/2);this._setupContainer(a,
e-2*c,n-2*d);p.marginLeft=c+"px";p.marginRight=c+"px";p.marginTop=d+"px";p.marginBottom=d+"px"}}),c=(a.extend({preApply:function(a){this._super(a);a._frame=document.documentElement},apply:function(a){this._super(a);this._fixContainer()}}),b.extend({preApply:function(a){this._super(a);a._frame=document.documentElement},apply:function(a,b){this._super(a,b);this._fixContainer()}}),cc.ContainerStrategy.extend({apply:function(a){this._setupContainer(a,cc._canvas.width,cc._canvas.height)}}));cc.ContainerStrategy.EQUAL_TO_FRAME=
new a;cc.ContainerStrategy.PROPORTION_TO_FRAME=new b;cc.ContainerStrategy.ORIGINAL_CONTAINER=new c;var a=cc.ContentStrategy.extend({apply:function(a,b){var c=cc._canvas.width,d=cc._canvas.height;return this._buildResult(c,d,c,d,c/b.width,d/b.height)}}),b=cc.ContentStrategy.extend({apply:function(a,b){var c,d,e=cc._canvas.width,n=cc._canvas.height,p=b.width,r=b.height,s=e/p,v=n/r,u=0;return v>s?(u=s,c=e,d=r*u):(u=v,c=p*u,d=n),this._buildResult(e,n,c,d,u,u)}}),c=cc.ContentStrategy.extend({apply:function(a,
b){var c,d,e,n=cc._canvas.width,p=cc._canvas.height,r=b.width,s=b.height,v=n/r,u=p/s;return u>v?(c=u,d=r*c,e=p):(c=v,d=n,e=s*c),this._buildResult(n,p,d,e,c,c)}}),d=cc.ContentStrategy.extend({apply:function(a,b){var c=cc._canvas.width,d=cc._canvas.height,e=d/b.height;return this._buildResult(c,d,c,d,e,e)},postApply:function(a){cc.director._winSizeInPoints=a.getVisibleSize()}}),e=cc.ContentStrategy.extend({apply:function(a,b){var c=cc._canvas.width,d=cc._canvas.height,e=c/b.width;return this._buildResult(c,
d,c,d,e,e)},postApply:function(a){cc.director._winSizeInPoints=a.getVisibleSize()}});cc.ContentStrategy.EXACT_FIT=new a;cc.ContentStrategy.SHOW_ALL=new b;cc.ContentStrategy.NO_BORDER=new c;cc.ContentStrategy.FIXED_HEIGHT=new d;cc.ContentStrategy.FIXED_WIDTH=new e}(),cc.ResolutionPolicy=cc.Class.extend({_containerStrategy:null,_contentStrategy:null,ctor:function(a,b){this.setContainerStrategy(a);this.setContentStrategy(b)},preApply:function(a){this._containerStrategy.preApply(a);this._contentStrategy.preApply(a)},
apply:function(a,b){return this._containerStrategy.apply(a,b),this._contentStrategy.apply(a,b)},postApply:function(a){this._containerStrategy.postApply(a);this._contentStrategy.postApply(a)},setContainerStrategy:function(a){a instanceof cc.ContainerStrategy&&(this._containerStrategy=a)},setContentStrategy:function(a){a instanceof cc.ContentStrategy&&(this._contentStrategy=a)}}),cc.ResolutionPolicy.EXACT_FIT=0,cc.ResolutionPolicy.NO_BORDER=1,cc.ResolutionPolicy.SHOW_ALL=2,cc.ResolutionPolicy.FIXED_HEIGHT=
3,cc.ResolutionPolicy.FIXED_WIDTH=4,cc.ResolutionPolicy.UNKNOWN=5,cc.screen={_supportsFullScreen:!1,_preOnFullScreenChange:null,_touchEvent:"",_fn:null,_fnMap:[["requestFullscreen","exitFullscreen","fullscreenchange","fullscreenEnabled","fullscreenElement"],["requestFullScreen","exitFullScreen","fullScreenchange","fullScreenEnabled","fullScreenElement"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitfullscreenchange","webkitIsFullScreen","webkitCurrentFullScreenElement"],["mozRequestFullScreen",
"mozCancelFullScreen","mozfullscreenchange","mozFullScreen","mozFullScreenElement"],["msRequestFullscreen","msExitFullscreen","MSFullscreenChange","msFullscreenEnabled","msFullscreenElement"]],init:function(){this._fn={};var a,b,c,d=this._fnMap;a=0;for(l=d.length;a<l;a++)if(b=d[a],b&&b[1]in document){a=0;for(c=b.length;c>a;a++)this._fn[d[0][a]]=b[a];break}this._supportsFullScreen="undefined"!=typeof this._fn.requestFullscreen;this._touchEvent="ontouchstart"in window?"touchstart":"mousedown"},fullScreen:function(){return this._supportsFullScreen&&
document[this._fn.fullscreenElement]},requestFullScreen:function(a,b){if(this._supportsFullScreen){if(a=a||document.documentElement,b){var c=this._fn.fullscreenchange;this._preOnFullScreenChange&&document.removeEventListener(c,this._preOnFullScreenChange);this._preOnFullScreenChange=b;cc._addEventListener(document,c,b,!1)}return a[this._fn.requestFullscreen]()}},exitFullScreen:function(){return this._supportsFullScreen?document[this._fn.exitFullscreen]():!0},autoFullScreen:function(a,b){function c(){e.requestFullScreen(a,
b);d.removeEventListener(e._touchEvent,c)}a=a||document.body;var d=cc._canvas||a,e=this;this.requestFullScreen(a,b);cc._addEventListener(d,this._touchEvent,c)}},cc.screen.init(),cc.visibleRect={topLeft:cc.p(0,0),topRight:cc.p(0,0),top:cc.p(0,0),bottomLeft:cc.p(0,0),bottomRight:cc.p(0,0),bottom:cc.p(0,0),center:cc.p(0,0),left:cc.p(0,0),right:cc.p(0,0),width:0,height:0,init:function(a){var b=this.width=a.width,c=this.height=a.height,d=a.x;a=a.y;var e=a+c,f=d+b;this.topLeft.x=d;this.topLeft.y=e;this.topRight.x=
f;this.topRight.y=e;this.top.x=d+b/2;this.top.y=e;this.bottomLeft.x=d;this.bottomLeft.y=a;this.bottomRight.x=f;this.bottomRight.y=a;this.bottom.x=d+b/2;this.bottom.y=a;this.center.x=d+b/2;this.center.y=a+c/2;this.left.x=d;this.left.y=a+c/2;this.right.x=f;this.right.y=a+c/2}},cc.UIInterfaceOrientationLandscapeLeft=-90,cc.UIInterfaceOrientationLandscapeRight=90,cc.UIInterfaceOrientationPortraitUpsideDown=180,cc.UIInterfaceOrientationPortrait=0,cc.inputManager={_mousePressed:!1,_isRegisterEvent:!1,_preTouchPoint:cc.p(0,
0),_prevMousePoint:cc.p(0,0),_preTouchPool:[],_preTouchPoolPointer:0,_touches:[],_touchesIntegerDict:{},_indexBitsUsed:0,_maxTouches:5,_accelEnabled:!1,_accelInterval:1/30,_accelMinus:1,_accelCurTime:0,_acceleration:null,_accelDeviceEvent:null,_getUnUsedIndex:function(){for(var a=this._indexBitsUsed,b=0;b<this._maxTouches;b++){if(!(1&a))return this._indexBitsUsed|=1<<b,b;a>>=1}return-1},_removeUsedIndexBit:function(a){0>a||a>=this._maxTouches||(a=~(1<<a),this._indexBitsUsed&=a)},_glView:null,handleTouchesBegin:function(a){for(var b,
c,d,e,f=[],g=this._touchesIntegerDict,h=0,k=a.length;k>h;h++)if(b=a[h],e=b.getID(),c=g[e],null==c){var m=this._getUnUsedIndex();-1===m?cc.log(cc._LogInfos.inputManager_handleTouchesBegin,m):(d=this._touches[m]=new cc.Touch(b._point.x,b._point.y,b.getID()),d._setPrevPoint(b._prevPoint),g[e]=m,f.push(d))}0<f.length&&(this._glView._convertTouchesWithScale(f),a=new cc.EventTouch(f),a._eventCode=cc.EventTouch.EventCode.BEGAN,cc.eventManager.dispatchEvent(a))},handleTouchesMove:function(a){for(var b,c,
d=[],e=this._touches,f=0,g=a.length;g>f;f++)b=a[f],c=b.getID(),c=this._touchesIntegerDict[c],null!=c&&e[c]&&(e[c]._setPoint(b._point),e[c]._setPrevPoint(b._prevPoint),d.push(e[c]));0<d.length&&(this._glView._convertTouchesWithScale(d),a=new cc.EventTouch(d),a._eventCode=cc.EventTouch.EventCode.MOVED,cc.eventManager.dispatchEvent(a))},handleTouchesEnd:function(a){a=this.getSetOfTouchesEndOrCancel(a);0<a.length&&(this._glView._convertTouchesWithScale(a),a=new cc.EventTouch(a),a._eventCode=cc.EventTouch.EventCode.ENDED,
cc.eventManager.dispatchEvent(a))},handleTouchesCancel:function(a){a=this.getSetOfTouchesEndOrCancel(a);0<a.length&&(this._glView._convertTouchesWithScale(a),a=new cc.EventTouch(a),a._eventCode=cc.EventTouch.EventCode.CANCELLED,cc.eventManager.dispatchEvent(a))},getSetOfTouchesEndOrCancel:function(a){for(var b,c,d,e=[],f=this._touches,g=this._touchesIntegerDict,h=0,k=a.length;k>h;h++)b=a[h],d=b.getID(),c=g[d],null!=c&&f[c]&&(f[c]._setPoint(b._point),f[c]._setPrevPoint(b._prevPoint),e.push(f[c]),this._removeUsedIndexBit(c),
delete g[d]);return e},getHTMLElementPosition:function(a){var b=document.documentElement,c=window,d=null;return d=cc.isFunction(a.getBoundingClientRect)?a.getBoundingClientRect():a instanceof HTMLCanvasElement?{left:0,top:0,width:a.width,height:a.height}:{left:0,top:0,width:parseInt(a.style.width),height:parseInt(a.style.height)},{left:d.left+c.pageXOffset-b.clientLeft,top:d.top+c.pageYOffset-b.clientTop,width:d.width,height:d.height}},getPreTouch:function(a){for(var b=null,c=this._preTouchPool,d=
a.getID(),e=c.length-1;0<=e;e--)if(c[e].getID()===d){b=c[e];break}return b||(b=a),b},setPreTouch:function(a){for(var b=!1,c=this._preTouchPool,d=a.getID(),e=c.length-1;0<=e;e--)if(c[e].getID()===d){c[e]=a;b=!0;break}b||(50>=c.length?c.push(a):(c[this._preTouchPoolPointer]=a,this._preTouchPoolPointer=(this._preTouchPoolPointer+1)%50))},getTouchByXY:function(a,b,c){var d=this._preTouchPoint;a=this._glView.convertToLocationInView(a,b,c);b=new cc.Touch(a.x,a.y);return b._setPrevPoint(d.x,d.y),d.x=a.x,
d.y=a.y,b},getMouseEvent:function(a,b,c){var d=this._prevMousePoint;this._glView._convertMouseToLocationInView(a,b);b=new cc.EventMouse(c);return b.setLocation(a.x,a.y),b._setPrevCursor(d.x,d.y),d.x=a.x,d.y=a.y,b},getPointByEvent:function(a,b){return null!=a.pageX?{x:a.pageX,y:a.pageY}:(b.left-=document.body.scrollLeft,b.top-=document.body.scrollTop,{x:a.clientX,y:a.clientY})},getTouchesByEvent:function(a,b){for(var c,d,e,f=[],g=this._glView,h=this._preTouchPoint,k=a.changedTouches.length,m=0;k>m;m++)if(c=
a.changedTouches[m]){var n;n=cc.sys.BROWSER_TYPE_FIREFOX===cc.sys.browserType?g.convertToLocationInView(c.pageX,c.pageY,b):g.convertToLocationInView(c.clientX,c.clientY,b);null!=c.identifier?(d=new cc.Touch(n.x,n.y,c.identifier),e=this.getPreTouch(d).getLocation(),d._setPrevPoint(e.x,e.y),this.setPreTouch(d)):(d=new cc.Touch(n.x,n.y),d._setPrevPoint(h.x,h.y));h.x=n.x;h.y=n.y;f.push(d)}return f},registerSystemEvent:function(a){if(!this._isRegisterEvent){var b=(this._glView=cc.view,this),c="mouse"in
cc.sys.capabilities,d="touches"in cc.sys.capabilities,e=!1;if(cc.sys.isMobile&&(e=!0),c&&(cc._addEventListener(window,"mousedown",function(){b._mousePressed=!0},!1),cc._addEventListener(window,"mouseup",function(c){if(!e){var d=b._mousePressed;if(b._mousePressed=!1,d){var d=b.getHTMLElementPosition(a),f=b.getPointByEvent(c,d);cc.rectContainsPoint(new cc.Rect(d.left,d.top,d.width,d.height),f)||(b.handleTouchesEnd([b.getTouchByXY(f.x,f.y,d)]),d=b.getMouseEvent(f,d,cc.EventMouse.UP),d.setButton(c.button),
cc.eventManager.dispatchEvent(d))}}},!1),cc._addEventListener(a,"mousedown",function(c){if(!e){b._mousePressed=!0;var d=b.getHTMLElementPosition(a),f=b.getPointByEvent(c,d);b.handleTouchesBegin([b.getTouchByXY(f.x,f.y,d)]);d=b.getMouseEvent(f,d,cc.EventMouse.DOWN);d.setButton(c.button);cc.eventManager.dispatchEvent(d);c.stopPropagation();c.preventDefault();a.focus()}},!1),cc._addEventListener(a,"mouseup",function(c){if(!e){b._mousePressed=!1;var d=b.getHTMLElementPosition(a),f=b.getPointByEvent(c,
d);b.handleTouchesEnd([b.getTouchByXY(f.x,f.y,d)]);d=b.getMouseEvent(f,d,cc.EventMouse.UP);d.setButton(c.button);cc.eventManager.dispatchEvent(d);c.stopPropagation();c.preventDefault()}},!1),cc._addEventListener(a,"mousemove",function(c){if(!e){var d=b.getHTMLElementPosition(a),f=b.getPointByEvent(c,d);b.handleTouchesMove([b.getTouchByXY(f.x,f.y,d)]);d=b.getMouseEvent(f,d,cc.EventMouse.MOVE);d.setButton(b._mousePressed?c.button:null);cc.eventManager.dispatchEvent(d);c.stopPropagation();c.preventDefault()}},
!1),cc._addEventListener(a,"mousewheel",function(c){var d=b.getHTMLElementPosition(a),e=b.getPointByEvent(c,d),d=b.getMouseEvent(e,d,cc.EventMouse.SCROLL);d.setButton(c.button);d.setScrollData(0,c.wheelDelta);cc.eventManager.dispatchEvent(d);c.stopPropagation();c.preventDefault()},!1),cc._addEventListener(a,"DOMMouseScroll",function(c){var d=b.getHTMLElementPosition(a),e=b.getPointByEvent(c,d),d=b.getMouseEvent(e,d,cc.EventMouse.SCROLL);d.setButton(c.button);d.setScrollData(0,-120*c.detail);cc.eventManager.dispatchEvent(d);
c.stopPropagation();c.preventDefault()},!1)),window.navigator.msPointerEnabled){var c={MSPointerDown:b.handleTouchesBegin,MSPointerMove:b.handleTouchesMove,MSPointerUp:b.handleTouchesEnd,MSPointerCancel:b.handleTouchesCancel},f;for(f in c)!function(c,d){cc._addEventListener(a,c,function(c){var e=b.getHTMLElementPosition(a);e.left-=document.documentElement.scrollLeft;e.top-=document.documentElement.scrollTop;d.call(b,[b.getTouchByXY(c.clientX,c.clientY,e)]);c.stopPropagation()},!1)}(f,c[f])}d&&(cc._addEventListener(a,
"touchstart",function(c){if(c.changedTouches){var d=b.getHTMLElementPosition(a);d.left-=document.body.scrollLeft;d.top-=document.body.scrollTop;b.handleTouchesBegin(b.getTouchesByEvent(c,d));c.stopPropagation();c.preventDefault();a.focus()}},!1),cc._addEventListener(a,"touchmove",function(c){if(c.changedTouches){var d=b.getHTMLElementPosition(a);d.left-=document.body.scrollLeft;d.top-=document.body.scrollTop;b.handleTouchesMove(b.getTouchesByEvent(c,d));c.stopPropagation();c.preventDefault()}},!1),
cc._addEventListener(a,"touchend",function(c){if(c.changedTouches){var d=b.getHTMLElementPosition(a);d.left-=document.body.scrollLeft;d.top-=document.body.scrollTop;b.handleTouchesEnd(b.getTouchesByEvent(c,d));c.stopPropagation();c.preventDefault()}},!1),cc._addEventListener(a,"touchcancel",function(c){if(c.changedTouches){var d=b.getHTMLElementPosition(a);d.left-=document.body.scrollLeft;d.top-=document.body.scrollTop;b.handleTouchesCancel(b.getTouchesByEvent(c,d));c.stopPropagation();c.preventDefault()}},
!1));this._registerKeyboardEvent();this._registerAccelerometerEvent();this._isRegisterEvent=!0}},_registerKeyboardEvent:function(){},_registerAccelerometerEvent:function(){},update:function(a){this._accelCurTime>this._accelInterval&&(this._accelCurTime-=this._accelInterval,cc.eventManager.dispatchEvent(new cc.EventAcceleration(this._acceleration)));this._accelCurTime+=a}},cc.AffineTransform=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.d=d;this.tx=e;this.ty=f},cc.affineTransformMake=function(a,
b,c,d,e,f){return{a:a,b:b,c:c,d:d,tx:e,ty:f}},cc.pointApplyAffineTransform=function(a,b,c){var d,e;return void 0===c?(c=b,d=a.x,e=a.y):(d=a,e=b),{x:c.a*d+c.c*e+c.tx,y:c.b*d+c.d*e+c.ty}},cc._pointApplyAffineTransform=function(a,b,c){return cc.pointApplyAffineTransform(a,b,c)},cc.sizeApplyAffineTransform=function(a,b){return{width:b.a*a.width+b.c*a.height,height:b.b*a.width+b.d*a.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(a,b){var c=cc.rectGetMinY(a),d=cc.rectGetMinX(a),e=cc.rectGetMaxX(a),f=cc.rectGetMaxY(a),g=cc.pointApplyAffineTransform(d,c,b),c=cc.pointApplyAffineTransform(e,c,b),d=cc.pointApplyAffineTransform(d,f,b),h=cc.pointApplyAffineTransform(e,f,b),e=Math.min(g.x,c.x,d.x,h.x),f=Math.max(g.x,c.x,d.x,h.x),k=Math.min(g.y,c.y,d.y,h.y),g=Math.max(g.y,c.y,d.y,h.y);return cc.rect(e,k,f-e,g-k)},cc._rectApplyAffineTransformIn=function(a,b){var c=cc.rectGetMinY(a),
d=cc.rectGetMinX(a),e=cc.rectGetMaxX(a),f=cc.rectGetMaxY(a),g=cc.pointApplyAffineTransform(d,c,b),c=cc.pointApplyAffineTransform(e,c,b),d=cc.pointApplyAffineTransform(d,f,b),h=cc.pointApplyAffineTransform(e,f,b),e=Math.min(g.x,c.x,d.x,h.x),f=Math.max(g.x,c.x,d.x,h.x),k=Math.min(g.y,c.y,d.y,h.y),g=Math.max(g.y,c.y,d.y,h.y);return a.x=e,a.y=k,a.width=f-e,a.height=g-k,a},cc.affineTransformTranslate=function(a,b,c){return{a:a.a,b:a.b,c:a.c,d:a.d,tx:a.tx+a.a*b+a.c*c,ty:a.ty+a.b*b+a.d*c}},cc.affineTransformScale=
function(a,b,c){return{a:a.a*b,b:a.b*b,c:a.c*c,d:a.d*c,tx:a.tx,ty:a.ty}},cc.affineTransformRotate=function(a,b){var c=Math.sin(b),d=Math.cos(b);return{a:a.a*d+a.c*c,b:a.b*d+a.d*c,c:a.c*d-a.a*c,d:a.d*d-a.b*c,tx:a.tx,ty:a.ty}},cc.affineTransformConcat=function(a,b){return{a:a.a*b.a+a.b*b.c,b:a.a*b.b+a.b*b.d,c:a.c*b.a+a.d*b.c,d:a.c*b.b+a.d*b.d,tx:a.tx*b.a+a.ty*b.c+b.tx,ty:a.tx*b.b+a.ty*b.d+b.ty}},cc.affineTransformEqualToTransform=function(a,b){return a.a===b.a&&a.b===b.b&&a.c===b.c&&a.d===b.d&&a.tx===
b.tx&&a.ty===b.ty},cc.affineTransformInvert=function(a){var b=1/(a.a*a.d-a.b*a.c);return{a:b*a.d,b:-b*a.b,c:-b*a.c,d:b*a.a,tx:b*(a.c*a.ty-a.d*a.tx),ty:b*(a.b*a.tx-a.a*a.ty)}},cc.POINT_EPSILON=parseFloat("1.192092896e-07F"),cc.pNeg=function(a){return cc.p(-a.x,-a.y)},cc.pAdd=function(a,b){return cc.p(a.x+b.x,a.y+b.y)},cc.pSub=function(a,b){return cc.p(a.x-b.x,a.y-b.y)},cc.pMult=function(a,b){return cc.p(a.x*b,a.y*b)},cc.pMidpoint=function(a,b){return cc.pMult(cc.pAdd(a,b),0.5)},cc.pDot=function(a,
b){return a.x*b.x+a.y*b.y},cc.pCross=function(a,b){return a.x*b.y-a.y*b.x},cc.pPerp=function(a){return cc.p(-a.y,a.x)},cc.pRPerp=function(a){return cc.p(a.y,-a.x)},cc.pProject=function(a,b){return cc.pMult(b,cc.pDot(a,b)/cc.pDot(b,b))},cc.pRotate=function(a,b){return cc.p(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x)},cc.pUnrotate=function(a,b){return cc.p(a.x*b.x+a.y*b.y,a.y*b.x-a.x*b.y)},cc.pLengthSQ=function(a){return cc.pDot(a,a)},cc.pDistanceSQ=function(a,b){return cc.pLengthSQ(cc.pSub(a,b))},cc.pLength=
function(a){return Math.sqrt(cc.pLengthSQ(a))},cc.pDistance=function(a,b){return cc.pLength(cc.pSub(a,b))},cc.pNormalize=function(a){var b=cc.pLength(a);return 0===b?cc.p(a):cc.pMult(a,1/b)},cc.pForAngle=function(a){return cc.p(Math.cos(a),Math.sin(a))},cc.pToAngle=function(a){return Math.atan2(a.y,a.x)},cc.clampf=function(a,b,c){if(b>c){var d=b;b=c;c=d}return b>a?b:c>a?a:c},cc.pClamp=function(a,b,c){return cc.p(cc.clampf(a.x,b.x,c.x),cc.clampf(a.y,b.y,c.y))},cc.pFromSize=function(a){return cc.p(a.width,
a.height)},cc.pCompOp=function(a,b){return cc.p(b(a.x),b(a.y))},cc.pLerp=function(a,b,c){return cc.pAdd(cc.pMult(a,1-c),cc.pMult(b,c))},cc.pFuzzyEqual=function(a,b,c){return a.x-c<=b.x&&b.x<=a.x+c&&a.y-c<=b.y&&b.y<=a.y+c?!0:!1},cc.pCompMult=function(a,b){return cc.p(a.x*b.x,a.y*b.y)},cc.pAngleSigned=function(a,b){var c=cc.pNormalize(a),d=cc.pNormalize(b),c=Math.atan2(c.x*d.y-c.y*d.x,cc.pDot(c,d));return Math.abs(c)<cc.POINT_EPSILON?0:c},cc.pAngle=function(a,b){var c=Math.acos(cc.pDot(cc.pNormalize(a),
cc.pNormalize(b)));return Math.abs(c)<cc.POINT_EPSILON?0:c},cc.pRotateByAngle=function(a,b,c){a=cc.pSub(a,b);var d=Math.cos(c);c=Math.sin(c);var e=a.x;return a.x=e*d-a.y*c+b.x,a.y=e*c+a.y*d+b.y,a},cc.pLineIntersect=function(a,b,c,d,e){if(a.x===b.x&&a.y===b.y||c.x===d.x&&c.y===d.y)return!1;var f=b.x-a.x;b=b.y-a.y;var g=d.x-c.x;d=d.y-c.y;var h=a.x-c.x;a=a.y-c.y;c=d*f-g*b;return e.x=g*a-d*h,e.y=f*a-b*h,0===c?0===e.x||0===e.y?!0:!1:(e.x/=c,e.y/=c,!0)},cc.pSegmentIntersect=function(a,b,c,d){var e=cc.p(0,
0);return cc.pLineIntersect(a,b,c,d,e)&&0<=e.x&&1>=e.x&&0<=e.y&&1>=e.y?!0:!1},cc.pIntersectPoint=function(a,b,c,d){var e=cc.p(0,0);return cc.pLineIntersect(a,b,c,d,e)?(c=cc.p(0,0),c.x=a.x+e.x*(b.x-a.x),c.y=a.y+e.x*(b.y-a.y),c):cc.p(0,0)},cc.pSameAs=function(a,b){return null!=a&&null!=b?a.x===b.x&&a.y===b.y:!1},cc.pZeroIn=function(a){a.x=0;a.y=0},cc.pIn=function(a,b){a.x=b.x;a.y=b.y},cc.pMultIn=function(a,b){a.x*=b;a.y*=b},cc.pSubIn=function(a,b){a.x-=b.x;a.y-=b.y},cc.pAddIn=function(a,b){a.x+=b.x;
a.y+=b.y},cc.pNormalizeIn=function(a){cc.pMultIn(a,1/Math.sqrt(a.x*a.x+a.y*a.y))},cc.Touch=cc.Class.extend({_point:null,_prevPoint:null,_id:0,_startPointCaptured:!1,_startPoint:null,ctor:function(a,b,c){this._point=cc.p(a||0,b||0);this._id=c||0},getLocation:function(){return{x:this._point.x,y:this._point.y}},getLocationX:function(){return this._point.x},getLocationY:function(){return this._point.y},getPreviousLocation:function(){return{x:this._prevPoint.x,y:this._prevPoint.y}},getStartLocation:function(){return{x:this._startPoint.x,
y:this._startPoint.y}},getDelta:function(){return cc.pSub(this._point,this._prevPoint)},getLocationInView:function(){return{x:this._point.x,y:this._point.y}},getPreviousLocationInView:function(){return{x:this._prevPoint.x,y:this._prevPoint.y}},getStartLocationInView:function(){return{x:this._startPoint.x,y:this._startPoint.y}},getID:function(){return this._id},getId:function(){return cc.log("getId is deprecated. Please use getID instead."),this._id},setTouchInfo:function(a,b,c){this._prevPoint=this._point;
this._point=cc.p(b||0,c||0);this._id=a;this._startPointCaptured||(this._startPoint=cc.p(this._point),this._startPointCaptured=!0)},_setPoint:function(a,b){void 0===b?(this._point.x=a.x,this._point.y=a.y):(this._point.x=a,this._point.y=b)},_setPrevPoint:function(a,b){void 0===b?this._prevPoint=cc.p(a.x,a.y):this._prevPoint=cc.p(a||0,b||0)}}),cc.Event=cc.Class.extend({_type:0,_isStopped:!1,_currentTarget:null,_setCurrentTarget:function(a){this._currentTarget=a},ctor:function(a){this._type=a},getType:function(){return this._type},
stopPropagation:function(){this._isStopped=!0},isStopped:function(){return this._isStopped},getCurrentTarget:function(){return this._currentTarget}}),cc.Event.TOUCH=0,cc.Event.KEYBOARD=1,cc.Event.ACCELERATION=2,cc.Event.MOUSE=3,cc.Event.FOCUS=4,cc.Event.CUSTOM=6,cc.EventCustom=cc.Event.extend({_eventName:null,_userData:null,ctor:function(a){cc.Event.prototype.ctor.call(this,cc.Event.CUSTOM);this._eventName=a},setUserData:function(a){this._userData=a},getUserData:function(){return this._userData},
getEventName:function(){return this._eventName}}),cc.EventMouse=cc.Event.extend({_eventType:0,_button:0,_x:0,_y:0,_prevX:0,_prevY:0,_scrollX:0,_scrollY:0,ctor:function(a){cc.Event.prototype.ctor.call(this,cc.Event.MOUSE);this._eventType=a},setScrollData:function(a,b){this._scrollX=a;this._scrollY=b},getScrollX:function(){return this._scrollX},getScrollY:function(){return this._scrollY},setLocation:function(a,b){this._x=a;this._y=b},getLocation:function(){return{x:this._x,y:this._y}},getLocationInView:function(){return{x:this._x,
y:cc.view._designResolutionSize.height-this._y}},_setPrevCursor:function(a,b){this._prevX=a;this._prevY=b},getDelta:function(){return{x:this._x-this._prevX,y:this._y-this._prevY}},getDeltaX:function(){return this._x-this._prevX},getDeltaY:function(){return this._y-this._prevY},setButton:function(a){this._button=a},getButton:function(){return this._button},getLocationX:function(){return this._x},getLocationY:function(){return this._y}}),cc.EventMouse.NONE=0,cc.EventMouse.DOWN=1,cc.EventMouse.UP=2,
cc.EventMouse.MOVE=3,cc.EventMouse.SCROLL=4,cc.EventMouse.BUTTON_LEFT=0,cc.EventMouse.BUTTON_RIGHT=2,cc.EventMouse.BUTTON_MIDDLE=1,cc.EventMouse.BUTTON_4=3,cc.EventMouse.BUTTON_5=4,cc.EventMouse.BUTTON_6=5,cc.EventMouse.BUTTON_7=6,cc.EventMouse.BUTTON_8=7,cc.EventTouch=cc.Event.extend({_eventCode:0,_touches:null,ctor:function(a){cc.Event.prototype.ctor.call(this,cc.Event.TOUCH);this._touches=a||[]},getEventCode:function(){return this._eventCode},getTouches:function(){return this._touches},_setEventCode:function(a){this._eventCode=
a},_setTouches:function(a){this._touches=a}}),cc.EventTouch.MAX_TOUCHES=5,cc.EventTouch.EventCode={BEGAN:0,MOVED:1,ENDED:2,CANCELLED:3},cc.EventFocus=cc.Event.extend({_widgetGetFocus:null,_widgetLoseFocus:null,ctor:function(a,b){cc.Event.prototype.ctor.call(this,cc.Event.FOCUS);this._widgetGetFocus=b;this._widgetLoseFocus=a}}),cc.EventListener=cc.Class.extend({_onEvent:null,_type:0,_listenerID:null,_registered:!1,_fixedPriority:0,_node:null,_paused:!0,_isEnabled:!0,ctor:function(a,b,c){this._onEvent=
c;this._type=a||0;this._listenerID=b||""},_setPaused:function(a){this._paused=a},_isPaused:function(){return this._paused},_setRegistered:function(a){this._registered=a},_isRegistered:function(){return this._registered},_getType:function(){return this._type},_getListenerID:function(){return this._listenerID},_setFixedPriority:function(a){this._fixedPriority=a},_getFixedPriority:function(){return this._fixedPriority},_setSceneGraphPriority:function(a){this._node=a},_getSceneGraphPriority:function(){return this._node},
checkAvailable:function(){return null!==this._onEvent},clone:function(){return null},setEnabled:function(a){this._isEnabled=a},isEnabled:function(){return this._isEnabled},retain:function(){},release:function(){}}),cc.EventListener.UNKNOWN=0,cc.EventListener.TOUCH_ONE_BY_ONE=1,cc.EventListener.TOUCH_ALL_AT_ONCE=2,cc.EventListener.KEYBOARD=3,cc.EventListener.MOUSE=4,cc.EventListener.ACCELERATION=5,cc.EventListener.ACCELERATION=6,cc.EventListener.CUSTOM=8,cc.EventListener.FOCUS=7,cc._EventListenerCustom=
cc.EventListener.extend({_onCustomEvent:null,ctor:function(a,b){this._onCustomEvent=b;var c=this;cc.EventListener.prototype.ctor.call(this,cc.EventListener.CUSTOM,a,function(a){null!==c._onCustomEvent&&c._onCustomEvent(a)})},checkAvailable:function(){return cc.EventListener.prototype.checkAvailable.call(this)&&null!==this._onCustomEvent},clone:function(){return new cc._EventListenerCustom(this._listenerID,this._onCustomEvent)}}),cc._EventListenerCustom.create=function(a,b){return new cc._EventListenerCustom(a,
b)},cc._EventListenerMouse=cc.EventListener.extend({onMouseDown:null,onMouseUp:null,onMouseMove:null,onMouseScroll:null,ctor:function(){var a=this;cc.EventListener.prototype.ctor.call(this,cc.EventListener.MOUSE,cc._EventListenerMouse.LISTENER_ID,function(b){var c=cc.EventMouse;switch(b._eventType){case c.DOWN:a.onMouseDown&&a.onMouseDown(b);break;case c.UP:a.onMouseUp&&a.onMouseUp(b);break;case c.MOVE:a.onMouseMove&&a.onMouseMove(b);break;case c.SCROLL:a.onMouseScroll&&a.onMouseScroll(b)}})},clone:function(){var a=
new cc._EventListenerMouse;return a.onMouseDown=this.onMouseDown,a.onMouseUp=this.onMouseUp,a.onMouseMove=this.onMouseMove,a.onMouseScroll=this.onMouseScroll,a},checkAvailable:function(){return!0}}),cc._EventListenerMouse.LISTENER_ID="__cc_mouse",cc._EventListenerMouse.create=function(){return new cc._EventListenerMouse},cc._EventListenerTouchOneByOne=cc.EventListener.extend({_claimedTouches:null,swallowTouches:!1,onTouchBegan:null,onTouchMoved:null,onTouchEnded:null,onTouchCancelled:null,ctor:function(){cc.EventListener.prototype.ctor.call(this,
cc.EventListener.TOUCH_ONE_BY_ONE,cc._EventListenerTouchOneByOne.LISTENER_ID,null);this._claimedTouches=[]},setSwallowTouches:function(a){this.swallowTouches=a},isSwallowTouches:function(){return this.swallowTouches},clone:function(){var a=new cc._EventListenerTouchOneByOne;return a.onTouchBegan=this.onTouchBegan,a.onTouchMoved=this.onTouchMoved,a.onTouchEnded=this.onTouchEnded,a.onTouchCancelled=this.onTouchCancelled,a.swallowTouches=this.swallowTouches,a},checkAvailable:function(){return this.onTouchBegan?
!0:(cc.log(cc._LogInfos._EventListenerTouchOneByOne_checkAvailable),!1)}}),cc._EventListenerTouchOneByOne.LISTENER_ID="__cc_touch_one_by_one",cc._EventListenerTouchOneByOne.create=function(){return new cc._EventListenerTouchOneByOne},cc._EventListenerTouchAllAtOnce=cc.EventListener.extend({onTouchesBegan:null,onTouchesMoved:null,onTouchesEnded:null,onTouchesCancelled:null,ctor:function(){cc.EventListener.prototype.ctor.call(this,cc.EventListener.TOUCH_ALL_AT_ONCE,cc._EventListenerTouchAllAtOnce.LISTENER_ID,
null)},clone:function(){var a=new cc._EventListenerTouchAllAtOnce;return a.onTouchesBegan=this.onTouchesBegan,a.onTouchesMoved=this.onTouchesMoved,a.onTouchesEnded=this.onTouchesEnded,a.onTouchesCancelled=this.onTouchesCancelled,a},checkAvailable:function(){return null===this.onTouchesBegan&&null===this.onTouchesMoved&&null===this.onTouchesEnded&&null===this.onTouchesCancelled?(cc.log(cc._LogInfos._EventListenerTouchAllAtOnce_checkAvailable),!1):!0}}),cc._EventListenerTouchAllAtOnce.LISTENER_ID="__cc_touch_all_at_once",
cc._EventListenerTouchAllAtOnce.create=function(){return new cc._EventListenerTouchAllAtOnce},cc.EventListener.create=function(a){cc.assert(a&&a.event,cc._LogInfos.EventListener_create);var b=a.event;delete a.event;var c=null;b===cc.EventListener.TOUCH_ONE_BY_ONE?c=new cc._EventListenerTouchOneByOne:b===cc.EventListener.TOUCH_ALL_AT_ONCE?c=new cc._EventListenerTouchAllAtOnce:b===cc.EventListener.MOUSE?c=new cc._EventListenerMouse:b===cc.EventListener.CUSTOM?(c=new cc._EventListenerCustom(a.eventName,
a.callback),delete a.eventName,delete a.callback):b===cc.EventListener.KEYBOARD?c=new cc._EventListenerKeyboard:b===cc.EventListener.ACCELERATION?(c=new cc._EventListenerAcceleration(a.callback),delete a.callback):b===cc.EventListener.FOCUS&&(c=new cc._EventListenerFocus);for(var d in a)c[d]=a[d];return c},cc._EventListenerFocus=cc.EventListener.extend({clone:function(){var a=new cc._EventListenerFocus;return a.onFocusChanged=this.onFocusChanged,a},checkAvailable:function(){return this.onFocusChanged?
!0:(cc.log("Invalid EventListenerFocus!"),!1)},onFocusChanged:null,ctor:function(){cc.EventListener.prototype.ctor.call(this,cc.EventListener.FOCUS,cc._EventListenerFocus.LISTENER_ID,function(a){this.onFocusChanged&&this.onFocusChanged(a._widgetLoseFocus,a._widgetGetFocus)})}}),cc._EventListenerFocus.LISTENER_ID="__cc_focus_event",cc._EventListenerVector=cc.Class.extend({_fixedListeners:null,_sceneGraphListeners:null,gt0Index:0,ctor:function(){this._fixedListeners=[];this._sceneGraphListeners=[]},
size:function(){return this._fixedListeners.length+this._sceneGraphListeners.length},empty:function(){return 0===this._fixedListeners.length&&0===this._sceneGraphListeners.length},push:function(a){0===a._getFixedPriority()?this._sceneGraphListeners.push(a):this._fixedListeners.push(a)},clearSceneGraphListeners:function(){this._sceneGraphListeners.length=0},clearFixedListeners:function(){this._fixedListeners.length=0},clear:function(){this._sceneGraphListeners.length=0;this._fixedListeners.length=
0},getFixedPriorityListeners:function(){return this._fixedListeners},getSceneGraphPriorityListeners:function(){return this._sceneGraphListeners}}),cc.__getListenerID=function(a){var b=cc.Event,c=a.getType();return c===b.ACCELERATION?cc._EventListenerAcceleration.LISTENER_ID:c===b.CUSTOM?a.getEventName():c===b.KEYBOARD?cc._EventListenerKeyboard.LISTENER_ID:c===b.MOUSE?cc._EventListenerMouse.LISTENER_ID:c===b.FOCUS?cc._EventListenerFocus.LISTENER_ID:(c===b.TOUCH&&cc.log(cc._LogInfos.__getListenerID),
"")},cc.eventManager={DIRTY_NONE:0,DIRTY_FIXED_PRIORITY:1,DIRTY_SCENE_GRAPH_PRIORITY:2,DIRTY_ALL:3,_listenersMap:{},_priorityDirtyFlagMap:{},_nodeListenersMap:{},_nodePriorityMap:{},_globalZOrderNodeMap:{},_toAddedListeners:[],_dirtyNodes:[],_inDispatch:0,_isEnabled:!1,_nodePriorityIndex:0,_internalCustomListenerIDs:[cc.game.EVENT_HIDE,cc.game.EVENT_SHOW],_setDirtyForNode:function(a){null!=this._nodeListenersMap[a.__instanceId]&&this._dirtyNodes.push(a);a=a.getChildren();for(var b=0,c=a.length;c>
b;b++)this._setDirtyForNode(a[b])},pauseTarget:function(a,b){var c,d,e=this._nodeListenersMap[a.__instanceId];if(e){c=0;for(d=e.length;d>c;c++)e[c]._setPaused(!0)}if(!0===b){e=a.getChildren();c=0;for(d=e.length;d>c;c++)this.pauseTarget(e[c],!0)}},resumeTarget:function(a,b){var c,d,e=this._nodeListenersMap[a.__instanceId];if(e){c=0;for(d=e.length;d>c;c++)e[c]._setPaused(!1)}if(this._setDirtyForNode(a),!0===b){e=a.getChildren();c=0;for(d=e.length;d>c;c++)this.resumeTarget(e[c],!0)}},_addListener:function(a){0===
this._inDispatch?this._forceAddEventListener(a):this._toAddedListeners.push(a)},_forceAddEventListener:function(a){var b=a._getListenerID(),c=this._listenersMap[b];(c||(c=new cc._EventListenerVector,this._listenersMap[b]=c),c.push(a),0===a._getFixedPriority())?(this._setDirty(b,this.DIRTY_SCENE_GRAPH_PRIORITY),b=a._getSceneGraphPriority(),null===b&&cc.log(cc._LogInfos.eventManager__forceAddEventListener),this._associateNodeAndEventListener(b,a),b.isRunning()&&this.resumeTarget(b)):this._setDirty(b,
this.DIRTY_FIXED_PRIORITY)},_getListeners:function(a){return this._listenersMap[a]},_updateDirtyFlagForSceneGraph:function(){if(0!==this._dirtyNodes.length){for(var a,b,c=this._dirtyNodes,d=this._nodeListenersMap,e=0,f=c.length;f>e;e++)if(a=d[c[e].__instanceId])for(var g=0,h=a.length;h>g;g++)(b=a[g])&&this._setDirty(b._getListenerID(),this.DIRTY_SCENE_GRAPH_PRIORITY);this._dirtyNodes.length=0}},_removeAllListenersInVector:function(a){if(a)for(var b,c=0;c<a.length;)b=a[c],b._setRegistered(!1),null!=
b._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(b._getSceneGraphPriority(),b),b._setSceneGraphPriority(null)),0===this._inDispatch?cc.arrayRemoveObject(a,b):++c},_removeListenersForListenerID:function(a){var b;if(b=this._listenersMap[a]){var c=b.getFixedPriorityListeners(),d=b.getSceneGraphPriorityListeners();this._removeAllListenersInVector(d);this._removeAllListenersInVector(c);delete this._priorityDirtyFlagMap[a];this._inDispatch||(b.clear(),delete this._listenersMap[a])}d=this._toAddedListeners;
for(b=0;b<d.length;)(c=d[b])&&c._getListenerID()===a?cc.arrayRemoveObject(d,c):++b},_sortEventListeners:function(a){var b=this.DIRTY_NONE,c=this._priorityDirtyFlagMap;if(c[a]&&(b=c[a]),b!==this.DIRTY_NONE&&(c[a]=this.DIRTY_NONE,b&this.DIRTY_FIXED_PRIORITY&&this._sortListenersOfFixedPriority(a),b&this.DIRTY_SCENE_GRAPH_PRIORITY))(b=cc.director.getRunningScene())?this._sortListenersOfSceneGraphPriority(a,b):c[a]=this.DIRTY_SCENE_GRAPH_PRIORITY},_sortListenersOfSceneGraphPriority:function(a,b){var c=
this._getListeners(a);if(c){var d=c.getSceneGraphPriorityListeners();d&&0!==d.length&&(this._nodePriorityIndex=0,this._nodePriorityMap={},this._visitTarget(b,!0),c.getSceneGraphPriorityListeners().sort(this._sortEventListenersOfSceneGraphPriorityDes))}},_sortEventListenersOfSceneGraphPriorityDes:function(a,b){var c=cc.eventManager._nodePriorityMap,d=a._getSceneGraphPriority(),e=b._getSceneGraphPriority();return a&&b&&d&&e&&c[d.__instanceId]&&c[e.__instanceId]?c[b._getSceneGraphPriority().__instanceId]-
c[a._getSceneGraphPriority().__instanceId]:-1},_sortListenersOfFixedPriority:function(a){if(a=this._listenersMap[a]){var b=a.getFixedPriorityListeners();if(b&&0!==b.length){b.sort(this._sortListenersOfFixedPriorityAsc);for(var c=0,d=b.length;d>c&&!(0<=b[c]._getFixedPriority());)++c;a.gt0Index=c}}},_sortListenersOfFixedPriorityAsc:function(a,b){return a._getFixedPriority()-b._getFixedPriority()},_onUpdateListeners:function(a){if(a=this._listenersMap[a]){var b,c,d=a.getFixedPriorityListeners(),e=a.getSceneGraphPriorityListeners();
if(e)for(b=0;b<e.length;)c=e[b],c._isRegistered()?++b:cc.arrayRemoveObject(e,c);if(d)for(b=0;b<d.length;)c=d[b],c._isRegistered()?++b:cc.arrayRemoveObject(d,c);e&&0===e.length&&a.clearSceneGraphListeners();d&&0===d.length&&a.clearFixedListeners()}},_updateListeners:function(a){var b=this._inDispatch;if(cc.assert(0<b,cc._LogInfos.EventManager__updateListeners),!(1<b)){a.getType()===cc.Event.TOUCH?(this._onUpdateListeners(cc._EventListenerTouchOneByOne.LISTENER_ID),this._onUpdateListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID)):
this._onUpdateListeners(cc.__getListenerID(a));cc.assert(1===b,cc._LogInfos.EventManager__updateListeners_2);a=this._listenersMap;var b=this._priorityDirtyFlagMap,c;for(c in a)a[c].empty()&&(delete b[c],delete a[c]);c=this._toAddedListeners;if(0!==c.length){a=0;for(b=c.length;b>a;a++)this._forceAddEventListener(c[a]);this._toAddedListeners.length=0}}},_onTouchEventCallback:function(a,b){if(!a._isRegistered)return!1;var c=b.event,d=b.selTouch;c._setCurrentTarget(a._node);var e,f=!1,g=c.getEventCode(),
h=cc.EventTouch.EventCode;return g===h.BEGAN?a.onTouchBegan&&(f=a.onTouchBegan(d,c),f&&a._registered&&a._claimedTouches.push(d)):0<a._claimedTouches.length&&-1!==(e=a._claimedTouches.indexOf(d))&&(f=!0,g===h.MOVED&&a.onTouchMoved?a.onTouchMoved(d,c):g===h.ENDED?(a.onTouchEnded&&a.onTouchEnded(d,c),a._registered&&a._claimedTouches.splice(e,1)):g===h.CANCELLED&&(a.onTouchCancelled&&a.onTouchCancelled(d,c),a._registered&&a._claimedTouches.splice(e,1))),c.isStopped()?(cc.eventManager._updateListeners(c),
!0):f&&a._registered&&a.swallowTouches?(b.needsMutableSet&&b.touches.splice(d,1),!0):!1},_dispatchTouchEvent:function(a){this._sortEventListeners(cc._EventListenerTouchOneByOne.LISTENER_ID);this._sortEventListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);var b=this._getListeners(cc._EventListenerTouchOneByOne.LISTENER_ID),c=this._getListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);if(null!==b||null!==c){var d=a.getTouches(),e=cc.copyArray(d),f={event:a,needsMutableSet:b&&c,touches:e,selTouch:null};
if(b)for(var g=0;g<d.length;g++)if(f.selTouch=d[g],this._dispatchEventToListeners(b,this._onTouchEventCallback,f),a.isStopped())return;c&&0<e.length&&(this._dispatchEventToListeners(c,this._onTouchesEventCallback,{event:a,touches:e}),a.isStopped())||this._updateListeners(a)}},_onTouchesEventCallback:function(a,b){if(!a._registered)return!1;var c=cc.EventTouch.EventCode,d=b.event,e=b.touches,f=d.getEventCode();return d._setCurrentTarget(a._node),f===c.BEGAN&&a.onTouchesBegan?a.onTouchesBegan(e,d):
f===c.MOVED&&a.onTouchesMoved?a.onTouchesMoved(e,d):f===c.ENDED&&a.onTouchesEnded?a.onTouchesEnded(e,d):f===c.CANCELLED&&a.onTouchesCancelled&&a.onTouchesCancelled(e,d),d.isStopped()?(cc.eventManager._updateListeners(d),!0):!1},_associateNodeAndEventListener:function(a,b){var c=this._nodeListenersMap[a.__instanceId];c||(c=[],this._nodeListenersMap[a.__instanceId]=c);c.push(b)},_dissociateNodeAndEventListener:function(a,b){var c=this._nodeListenersMap[a.__instanceId];c&&(cc.arrayRemoveObject(c,b),
0===c.length&&delete this._nodeListenersMap[a.__instanceId])},_dispatchEventToListeners:function(a,b,c){var d,e=!1,f=a.getFixedPriorityListeners(),g=a.getSceneGraphPriorityListeners(),h=0;if(f&&0!==f.length)for(;h<a.gt0Index;++h)if(d=f[h],d.isEnabled()&&!d._isPaused()&&d._isRegistered()&&b(d,c)){e=!0;break}if(g&&!e)for(a=0;a<g.length;a++)if(d=g[a],d.isEnabled()&&!d._isPaused()&&d._isRegistered()&&b(d,c)){e=!0;break}if(f&&!e)for(;h<f.length&&!(d=f[h],d.isEnabled()&&!d._isPaused()&&d._isRegistered()&&
b(d,c));++h);},_setDirty:function(a,b){var c=this._priorityDirtyFlagMap;null==c[a]?c[a]=b:c[a]|=b},_visitTarget:function(a,b){var c=a.getChildren(),d=0,e=c.length,f=this._globalZOrderNodeMap,g=this._nodeListenersMap;if(0<e){for(var h;e>d&&(h=c[d],h&&0>h.getLocalZOrder());d++)this._visitTarget(h,!1);for(null!=g[a.__instanceId]&&(f[a.getGlobalZOrder()]||(f[a.getGlobalZOrder()]=[]),f[a.getGlobalZOrder()].push(a.__instanceId));e>d;d++)(h=c[d])&&this._visitTarget(h,!1)}else null!=g[a.__instanceId]&&(f[a.getGlobalZOrder()]||
(f[a.getGlobalZOrder()]=[]),f[a.getGlobalZOrder()].push(a.__instanceId));if(b){var c=[],k;for(k in f)c.push(k);c.sort(this._sortNumberAsc);g=c.length;h=this._nodePriorityMap;for(d=0;g>d;d++){k=f[c[d]];for(e=0;e<k.length;e++)h[k[e]]=++this._nodePriorityIndex}this._globalZOrderNodeMap={}}},_sortNumberAsc:function(a,b){return a-b},addListener:function(a,b){if(cc.assert(a&&b,cc._LogInfos.eventManager_addListener_2),a instanceof cc.EventListener){if(a._isRegistered())return void cc.log(cc._LogInfos.eventManager_addListener_4)}else cc.assert(!cc.isNumber(b),
cc._LogInfos.eventManager_addListener_3),a=cc.EventListener.create(a);if(a.checkAvailable()){if(cc.isNumber(b)){if(0===b)return void cc.log(cc._LogInfos.eventManager_addListener);a._setSceneGraphPriority(null);a._setFixedPriority(b);a._setRegistered(!0);a._setPaused(!1)}else a._setSceneGraphPriority(b),a._setFixedPriority(0),a._setRegistered(!0);this._addListener(a);return a}},addCustomListener:function(a,b){var c=new cc._EventListenerCustom(a,b);return this.addListener(c,1),c},removeListener:function(a){if(null!=
a){var b,c=this._listenersMap,d;for(d in c){var e=c[d],f=e.getFixedPriorityListeners(),g=e.getSceneGraphPriorityListeners();if(b=this._removeListenerInVector(g,a),b?this._setDirty(a._getListenerID(),this.DIRTY_SCENE_GRAPH_PRIORITY):(b=this._removeListenerInVector(f,a),b&&this._setDirty(a._getListenerID(),this.DIRTY_FIXED_PRIORITY)),e.empty()&&(delete this._priorityDirtyFlagMap[a._getListenerID()],delete c[d]),b)break}if(!b){b=this._toAddedListeners;c=0;for(d=b.length;d>c;c++)if(e=b[c],e===a){cc.arrayRemoveObject(b,
e);e._setRegistered(!1);break}}}},_removeListenerInVector:function(a,b){if(null==a)return!1;for(var c=0,d=a.length;d>c;c++){var e=a[c];if(e===b)return e._setRegistered(!1),null!=e._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(e._getSceneGraphPriority(),e),e._setSceneGraphPriority(null)),0===this._inDispatch&&cc.arrayRemoveObject(a,e),!0}return!1},removeListeners:function(a,b){if(a instanceof cc.Node){delete this._nodePriorityMap[a.__instanceId];cc.arrayRemoveObject(this._dirtyNodes,
a);var c;if(c=this._nodeListenersMap[a.__instanceId]){var d=cc.copyArray(c);for(c=0;c<d.length;c++)this.removeListener(d[c]);d.length=0}d=this._toAddedListeners;for(c=0;c<d.length;){var e=d[c];e._getSceneGraphPriority()===a?(e._setSceneGraphPriority(null),e._setRegistered(!1),d.splice(c,1)):++c}if(!0===b){e=a.getChildren();c=0;for(d=e.length;d>c;c++)this.removeListeners(e[c],!0)}}else a===cc.EventListener.TOUCH_ONE_BY_ONE?this._removeListenersForListenerID(cc._EventListenerTouchOneByOne.LISTENER_ID):
a===cc.EventListener.TOUCH_ALL_AT_ONCE?this._removeListenersForListenerID(cc._EventListenerTouchAllAtOnce.LISTENER_ID):a===cc.EventListener.MOUSE?this._removeListenersForListenerID(cc._EventListenerMouse.LISTENER_ID):a===cc.EventListener.ACCELERATION?this._removeListenersForListenerID(cc._EventListenerAcceleration.LISTENER_ID):a===cc.EventListener.KEYBOARD?this._removeListenersForListenerID(cc._EventListenerKeyboard.LISTENER_ID):cc.log(cc._LogInfos.eventManager_removeListeners)},removeCustomListeners:function(a){this._removeListenersForListenerID(a)},
removeAllListeners:function(){var a=this._listenersMap,b=this._internalCustomListenerIDs,c;for(c in a)-1===b.indexOf(c)&&this._removeListenersForListenerID(c)},setPriority:function(a,b){if(null!=a){var c=this._listenersMap,d;for(d in c){var e=c[d].getFixedPriorityListeners();if(e&&-1!==e.indexOf(a))return null!=a._getSceneGraphPriority()&&cc.log(cc._LogInfos.eventManager_setPriority),void(a._getFixedPriority()!==b&&(a._setFixedPriority(b),this._setDirty(a._getListenerID(),this.DIRTY_FIXED_PRIORITY)))}}},
setEnabled:function(a){this._isEnabled=a},isEnabled:function(){return this._isEnabled},dispatchEvent:function(a){if(this._isEnabled){if(this._updateDirtyFlagForSceneGraph(),this._inDispatch++,!a||!a.getType)throw"event is undefined";if(a.getType()===cc.Event.TOUCH)return this._dispatchTouchEvent(a),void this._inDispatch--;var b=cc.__getListenerID(a);this._sortEventListeners(b);b=this._listenersMap[b];null!=b&&this._dispatchEventToListeners(b,this._onListenerCallback,a);this._updateListeners(a);this._inDispatch--}},
_onListenerCallback:function(a,b){return b._setCurrentTarget(a._getSceneGraphPriority()),a._onEvent(b),b.isStopped()},dispatchCustomEvent:function(a,b){var c=new cc.EventCustom(a);c.setUserData(b);this.dispatchEvent(c)}},cc.EventHelper=function(){},cc.EventHelper.prototype={constructor:cc.EventHelper,apply:function(a){a.addEventListener=cc.EventHelper.prototype.addEventListener;a.hasEventListener=cc.EventHelper.prototype.hasEventListener;a.removeEventListener=cc.EventHelper.prototype.removeEventListener;
a.dispatchEvent=cc.EventHelper.prototype.dispatchEvent},addEventListener:function(a,b,c){if("load"===a&&this._textureLoaded)return void setTimeout(function(){b.call(c)},0);void 0===this._listeners&&(this._listeners={});var d=this._listeners;void 0===d[a]&&(d[a]=[]);this.hasEventListener(a,b,c)||d[a].push({callback:b,eventTarget:c})},hasEventListener:function(a,b,c){if(void 0===this._listeners)return!1;var d=this._listeners;if(void 0!==d[a]){a=0;for(var e=d.length;e>a;a++){var f=d[a];if(f.callback===
b&&f.eventTarget===c)return!0}}return!1},removeEventListener:function(a,b){if(void 0!==this._listeners){var c=this._listeners[a];if(void 0!==c)for(var d=0;d<c.length;)c[d].eventTarget===b?c.splice(d,1):d++}},dispatchEvent:function(a,b){if(void 0!==this._listeners){null==b&&(b=!0);var c=this._listeners[a];if(void 0!==c){for(var d=[],e=c.length,f=0;e>f;f++)d[f]=c[f];for(f=0;e>f;f++)d[f].callback.call(d[f].eventTarget,this);b&&(c.length=0)}}}},cc._tmp.PrototypeCCNode=function(){var a=cc.Node.prototype;
cc.defineGetterSetter(a,"x",a.getPositionX,a.setPositionX);cc.defineGetterSetter(a,"y",a.getPositionY,a.setPositionY);a.width;cc.defineGetterSetter(a,"width",a._getWidth,a._setWidth);a.height;cc.defineGetterSetter(a,"height",a._getHeight,a._setHeight);a.anchorX;cc.defineGetterSetter(a,"anchorX",a._getAnchorX,a._setAnchorX);a.anchorY;cc.defineGetterSetter(a,"anchorY",a._getAnchorY,a._setAnchorY);a.skewX;cc.defineGetterSetter(a,"skewX",a.getSkewX,a.setSkewX);a.skewY;cc.defineGetterSetter(a,"skewY",
a.getSkewY,a.setSkewY);a.zIndex;cc.defineGetterSetter(a,"zIndex",a.getLocalZOrder,a.setLocalZOrder);a.vertexZ;cc.defineGetterSetter(a,"vertexZ",a.getVertexZ,a.setVertexZ);a.rotation;cc.defineGetterSetter(a,"rotation",a.getRotation,a.setRotation);a.rotationX;cc.defineGetterSetter(a,"rotationX",a.getRotationX,a.setRotationX);a.rotationY;cc.defineGetterSetter(a,"rotationY",a.getRotationY,a.setRotationY);a.scale;cc.defineGetterSetter(a,"scale",a.getScale,a.setScale);a.scaleX;cc.defineGetterSetter(a,"scaleX",
a.getScaleX,a.setScaleX);a.scaleY;cc.defineGetterSetter(a,"scaleY",a.getScaleY,a.setScaleY);a.children;cc.defineGetterSetter(a,"children",a.getChildren);a.childrenCount;cc.defineGetterSetter(a,"childrenCount",a.getChildrenCount);a.parent;cc.defineGetterSetter(a,"parent",a.getParent,a.setParent);a.visible;cc.defineGetterSetter(a,"visible",a.isVisible,a.setVisible);a.running;cc.defineGetterSetter(a,"running",a.isRunning);a.ignoreAnchor;cc.defineGetterSetter(a,"ignoreAnchor",a.isIgnoreAnchorPointForPosition,
a.ignoreAnchorPointForPosition);a.tag;a.userData;a.userObject;a.arrivalOrder;a.actionManager;cc.defineGetterSetter(a,"actionManager",a.getActionManager,a.setActionManager);a.scheduler;cc.defineGetterSetter(a,"scheduler",a.getScheduler,a.setScheduler);a.shaderProgram;cc.defineGetterSetter(a,"shaderProgram",a.getShaderProgram,a.setShaderProgram);a.opacity;cc.defineGetterSetter(a,"opacity",a.getOpacity,a.setOpacity);a.opacityModifyRGB;cc.defineGetterSetter(a,"opacityModifyRGB",a.isOpacityModifyRGB);
a.cascadeOpacity;cc.defineGetterSetter(a,"cascadeOpacity",a.isCascadeOpacityEnabled,a.setCascadeOpacityEnabled);a.color;cc.defineGetterSetter(a,"color",a.getColor,a.setColor);a.cascadeColor;cc.defineGetterSetter(a,"cascadeColor",a.isCascadeColorEnabled,a.setCascadeColorEnabled)},cc.NODE_TAG_INVALID=-1,cc.s_globalOrderOfArrival=1,cc.Node=cc.Class.extend({_localZOrder:0,_globalZOrder:0,_vertexZ:0,_rotationX:0,_rotationY:0,_scaleX:1,_scaleY:1,_position:null,_normalizedPosition:null,_usingNormalizedPosition:!1,
_normalizedPositionDirty:!1,_skewX:0,_skewY:0,_children:null,_visible:!0,_anchorPoint:null,_contentSize:null,_running:!1,_parent:null,_ignoreAnchorPointForPosition:!1,tag:cc.NODE_TAG_INVALID,userData:null,userObject:null,_reorderChildDirty:!1,_shaderProgram:null,arrivalOrder:0,_actionManager:null,_scheduler:null,_eventDispatcher:null,_additionalTransformDirty:!1,_additionalTransform:null,_componentContainer:null,_isTransitionFinished:!1,_className:"Node",_showNode:!1,_name:"",_realOpacity:255,_realColor:null,
_cascadeColorEnabled:!1,_cascadeOpacityEnabled:!1,_renderCmd:null,_camera:null,ctor:function(){this._initNode();this._initRendererCmd()},_initNode:function(){this._anchorPoint=cc.p(0,0);this._contentSize=cc.size(0,0);this._position=cc.p(0,0);this._normalizedPosition=cc.p(0,0);this._children=[];var a=cc.director;this._actionManager=a.getActionManager();this._scheduler=a.getScheduler();this._additionalTransform=cc.affineTransformMakeIdentity();cc.ComponentContainer&&(this._componentContainer=new cc.ComponentContainer(this));
this._realOpacity=255;this._realColor=cc.color(255,255,255,255);this._cascadeOpacityEnabled=this._cascadeColorEnabled=!1},init:function(){return!0},_arrayMakeObjectsPerformSelector:function(a,b){if(a&&0!==a.length){var c,d,e=a.length;c=cc.Node._stateCallbackType;switch(b){case c.onEnter:for(c=0;e>c;c++)(d=a[c])&&d.onEnter();break;case c.onExit:for(c=0;e>c;c++)(d=a[c])&&d.onExit();break;case c.onEnterTransitionDidFinish:for(c=0;e>c;c++)(d=a[c])&&d.onEnterTransitionDidFinish();break;case c.cleanup:for(c=
0;e>c;c++)(d=a[c])&&d.cleanup();break;case c.updateTransform:for(c=0;e>c;c++)(d=a[c])&&d.updateTransform();break;case c.onExitTransitionDidStart:for(c=0;e>c;c++)(d=a[c])&&d.onExitTransitionDidStart();break;case c.sortAllChildren:for(c=0;e>c;c++)(d=a[c])&&d.sortAllChildren();break;default:cc.assert(0,cc._LogInfos.Node__arrayMakeObjectsPerformSelector)}}},attr:function(a){for(var b in a)this[b]=a[b]},getSkewX:function(){return this._skewX},setSkewX:function(a){this._skewX=a;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},
getSkewY:function(){return this._skewY},setSkewY:function(a){this._skewY=a;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},setLocalZOrder:function(a){this._localZOrder=a;this._parent&&this._parent.reorderChild(this,a);cc.eventManager._setDirtyForNode(this)},_setLocalZOrder:function(a){this._localZOrder=a},getLocalZOrder:function(){return this._localZOrder},getZOrder:function(){return cc.log(cc._LogInfos.Node_getZOrder),this.getLocalZOrder()},setZOrder:function(a){cc.log(cc._LogInfos.Node_setZOrder);
this.setLocalZOrder(a)},setGlobalZOrder:function(a){this._globalZOrder!==a&&(this._globalZOrder=a,cc.eventManager._setDirtyForNode(this))},getGlobalZOrder:function(){return this._globalZOrder},getVertexZ:function(){return this._vertexZ},setVertexZ:function(a){this._vertexZ=a},getRotation:function(){return this._rotationX!==this._rotationY&&cc.log(cc._LogInfos.Node_getRotation),this._rotationX},setRotation:function(a){this._rotationX=this._rotationY=a;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},
getRotationX:function(){return this._rotationX},setRotationX:function(a){this._rotationX=a;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getRotationY:function(){return this._rotationY},setRotationY:function(a){this._rotationY=a;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getScale:function(){return this._scaleX!==this._scaleY&&cc.log(cc._LogInfos.Node_getScale),this._scaleX},setScale:function(a,b){this._scaleX=a;this._scaleY=b||0===b?b:a;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},
getScaleX:function(){return this._scaleX},setScaleX:function(a){this._scaleX=a;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getScaleY:function(){return this._scaleY},setScaleY:function(a){this._scaleY=a;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},setPosition:function(a,b){var c=this._position;if(void 0===b){if(c.x===a.x&&c.y===a.y)return;c.x=a.x;c.y=a.y}else{if(c.x===a&&c.y===b)return;c.x=a;c.y=b}this._usingNormalizedPosition=!1;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},
setNormalizedPosition:function(a,b){var c=this._normalizedPosition;void 0===b?(c.x=a.x,c.y=a.y):(c.x=a,c.y=b);this._normalizedPositionDirty=this._usingNormalizedPosition=!0;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getPosition:function(){return cc.p(this._position)},getNormalizedPosition:function(){return cc.p(this._normalizedPosition)},getPositionX:function(){return this._position.x},setPositionX:function(a){this._position.x=a;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},
getPositionY:function(){return this._position.y},setPositionY:function(a){this._position.y=a;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getChildrenCount:function(){return this._children.length},getChildren:function(){return this._children},isVisible:function(){return this._visible},setVisible:function(a){this._visible!==a&&(this._visible=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty),cc.renderer.childrenOrderDirty=!0)},getAnchorPoint:function(){return cc.p(this._anchorPoint)},
setAnchorPoint:function(a,b){var c=this._anchorPoint;if(void 0===b){if(a.x===c.x&&a.y===c.y)return;c.x=a.x;c.y=a.y}else{if(a===c.x&&b===c.y)return;c.x=a;c.y=b}this._renderCmd._updateAnchorPointInPoint()},_getAnchorX:function(){return this._anchorPoint.x},_setAnchorX:function(a){this._anchorPoint.x!==a&&(this._anchorPoint.x=a,this._renderCmd._updateAnchorPointInPoint())},_getAnchorY:function(){return this._anchorPoint.y},_setAnchorY:function(a){this._anchorPoint.y!==a&&(this._anchorPoint.y=a,this._renderCmd._updateAnchorPointInPoint())},
getAnchorPointInPoints:function(){return this._renderCmd.getAnchorPointInPoints()},_getWidth:function(){return this._contentSize.width},_setWidth:function(a){this._contentSize.width=a;this._renderCmd._updateAnchorPointInPoint()},_getHeight:function(){return this._contentSize.height},_setHeight:function(a){this._contentSize.height=a;this._renderCmd._updateAnchorPointInPoint()},getContentSize:function(){return cc.size(this._contentSize)},setContentSize:function(a,b){var c=this._contentSize;if(void 0===
b){if(a.width===c.width&&a.height===c.height)return;c.width=a.width;c.height=a.height}else{if(a===c.width&&b===c.height)return;c.width=a;c.height=b}this._renderCmd._updateAnchorPointInPoint()},isRunning:function(){return this._running},getParent:function(){return this._parent},setParent:function(a){this._parent=a},isIgnoreAnchorPointForPosition:function(){return this._ignoreAnchorPointForPosition},ignoreAnchorPointForPosition:function(a){a!==this._ignoreAnchorPointForPosition&&(this._ignoreAnchorPointForPosition=
a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty))},getTag:function(){return this.tag},setTag:function(a){this.tag=a},setName:function(a){this._name=a},getName:function(){return this._name},getUserData:function(){return this.userData},setUserData:function(a){this.userData=a},getUserObject:function(){return this.userObject},setUserObject:function(a){this.userObject!==a&&(this.userObject=a)},getOrderOfArrival:function(){return this.arrivalOrder},setOrderOfArrival:function(a){this.arrivalOrder=
a},getActionManager:function(){return this._actionManager||(this._actionManager=cc.director.getActionManager()),this._actionManager},setActionManager:function(a){this._actionManager!==a&&(this.stopAllActions(),this._actionManager=a)},getScheduler:function(){return this._scheduler||(this._scheduler=cc.director.getScheduler()),this._scheduler},setScheduler:function(a){this._scheduler!==a&&(this.unscheduleAllCallbacks(),this._scheduler=a)},boundingBox:function(){return cc.log(cc._LogInfos.Node_boundingBox),
this.getBoundingBox()},getBoundingBox:function(){var a=cc.rect(0,0,this._contentSize.width,this._contentSize.height);return cc._rectApplyAffineTransformIn(a,this.getNodeToParentTransform())},cleanup:function(){this.stopAllActions();this.unscheduleAllCallbacks();cc.eventManager.removeListeners(this);this._arrayMakeObjectsPerformSelector(this._children,cc.Node._stateCallbackType.cleanup)},getChildByTag:function(a){var b=this._children;if(null!==b)for(var c=0;c<b.length;c++){var d=b[c];if(d&&d.tag===
a)return d}return null},getChildByName:function(a){if(!a)return cc.log("Invalid name"),null;for(var b=this._children,c=0,d=b.length;d>c;c++)if(b[c]._name===a)return b[c];return null},addChild:function(a,b,c){b=void 0===b?a._localZOrder:b;var d,e=!1;cc.isUndefined(c)?(c=void 0,d=a._name):cc.isString(c)?(d=c,c=void 0):cc.isNumber(c)&&(e=!0,d="");cc.assert(a,cc._LogInfos.Node_addChild_3);cc.assert(null===a._parent,"child already added. It can't be added again");this._addChildHelper(a,b,c,d,e)},_addChildHelper:function(a,
b,c,d,e){this._children||(this._children=[]);this._insertChild(a,b);e?a.setTag(c):a.setName(d);a.setParent(this);a.setOrderOfArrival(cc.s_globalOrderOfArrival++);this._running&&(a.onEnter(),this._isTransitionFinished&&a.onEnterTransitionDidFinish());this._cascadeColorEnabled&&a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty);this._cascadeOpacityEnabled&&a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)},removeFromParent:function(a){this._parent&&(void 0===a&&(a=!0),this._parent.removeChild(this,
a))},removeFromParentAndCleanup:function(a){cc.log(cc._LogInfos.Node_removeFromParentAndCleanup);this.removeFromParent(a)},removeChild:function(a,b){0!==this._children.length&&(void 0===b&&(b=!0),-1<this._children.indexOf(a)&&this._detachChild(a,b),cc.renderer.childrenOrderDirty=!0)},removeChildByTag:function(a,b){a===cc.NODE_TAG_INVALID&&cc.log(cc._LogInfos.Node_removeChildByTag);var c=this.getChildByTag(a);c?this.removeChild(c,b):cc.log(cc._LogInfos.Node_removeChildByTag_2,a)},removeAllChildrenWithCleanup:function(a){this.removeAllChildren(a)},
removeAllChildren:function(a){var b=this._children;if(null!==b){void 0===a&&(a=!0);for(var c=0;c<b.length;c++){var d=b[c];d&&(this._running&&(d.onExitTransitionDidStart(),d.onExit()),a&&d.cleanup(),d.parent=null,d._renderCmd.detachFromParent())}this._children.length=0;cc.renderer.childrenOrderDirty=!0}},_detachChild:function(a,b){this._running&&(a.onExitTransitionDidStart(),a.onExit());b&&a.cleanup();a.parent=null;a._renderCmd.detachFromParent();cc.arrayRemoveObject(this._children,a)},_insertChild:function(a,
b){cc.renderer.childrenOrderDirty=this._reorderChildDirty=!0;this._children.push(a);a._setLocalZOrder(b)},setNodeDirty:function(){this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},reorderChild:function(a,b){cc.assert(a,cc._LogInfos.Node_reorderChild);cc.renderer.childrenOrderDirty=this._reorderChildDirty=!0;a.arrivalOrder=cc.s_globalOrderOfArrival;cc.s_globalOrderOfArrival++;a._setLocalZOrder(b)},sortAllChildren:function(){if(this._reorderChildDirty){var a,b,c,d=this._children,e=d.length;
for(a=1;e>a;a++){c=d[a];for(b=a-1;0<=b&&(c._localZOrder<d[b]._localZOrder||c._localZOrder===d[b]._localZOrder&&c.arrivalOrder<d[b].arrivalOrder);)d[b+1]=d[b],b--;d[b+1]=c}this._reorderChildDirty=!1}},draw:function(a){},transformAncestors:function(){null!==this._parent&&(this._parent.transformAncestors(),this._parent.transform())},onEnter:function(){this._isTransitionFinished=!1;this._running=!0;this._arrayMakeObjectsPerformSelector(this._children,cc.Node._stateCallbackType.onEnter);this.resume()},
onEnterTransitionDidFinish:function(){this._isTransitionFinished=!0;this._arrayMakeObjectsPerformSelector(this._children,cc.Node._stateCallbackType.onEnterTransitionDidFinish)},onExitTransitionDidStart:function(){this._arrayMakeObjectsPerformSelector(this._children,cc.Node._stateCallbackType.onExitTransitionDidStart)},onExit:function(){this._running=!1;this.pause();this._arrayMakeObjectsPerformSelector(this._children,cc.Node._stateCallbackType.onExit);this.removeAllComponents()},runAction:function(a){return cc.assert(a,
cc._LogInfos.Node_runAction),this.actionManager.addAction(a,this,!this._running),a},stopAllActions:function(){this.actionManager&&this.actionManager.removeAllActionsFromTarget(this)},stopAction:function(a){this.actionManager.removeAction(a)},stopActionByTag:function(a){return a===cc.ACTION_TAG_INVALID?void cc.log(cc._LogInfos.Node_stopActionByTag):void this.actionManager.removeActionByTag(a,this)},getActionByTag:function(a){return a===cc.ACTION_TAG_INVALID?(cc.log(cc._LogInfos.Node_getActionByTag),
null):this.actionManager.getActionByTag(a,this)},getNumberOfRunningActions:function(){return this.actionManager.numberOfRunningActionsInTarget(this)},scheduleUpdate:function(){this.scheduleUpdateWithPriority(0)},scheduleUpdateWithPriority:function(a){this.scheduler.scheduleUpdate(this,a,!this._running)},unscheduleUpdate:function(){this.scheduler.unscheduleUpdate(this)},schedule:function(a,b,c,d,e){var f=arguments.length;"function"==typeof a?1===f?(b=0,c=cc.REPEAT_FOREVER,d=0,e=this.__instanceId):
2===f?"number"==typeof b?(c=cc.REPEAT_FOREVER,d=0,e=this.__instanceId):(e=b,b=0,c=cc.REPEAT_FOREVER,d=0):3===f?("string"==typeof c?(e=c,c=cc.REPEAT_FOREVER):e=this.__instanceId,d=0):4===f&&(e=this.__instanceId):1===f?(b=0,c=cc.REPEAT_FOREVER,d=0):2===f&&(c=cc.REPEAT_FOREVER,d=0);cc.assert(a,cc._LogInfos.Node_schedule);cc.assert(0<=b,cc._LogInfos.Node_schedule_2);c=null==c?cc.REPEAT_FOREVER:c;this.scheduler.schedule(a,this,b||0,c,d||0,!this._running,e)},scheduleOnce:function(a,b,c){void 0===c&&(c=
this.__instanceId);this.schedule(a,0,0,b,c)},unschedule:function(a){a&&this.scheduler.unschedule(a,this)},unscheduleAllCallbacks:function(){this.scheduler.unscheduleAllForTarget(this)},resumeSchedulerAndActions:function(){cc.log(cc._LogInfos.Node_resumeSchedulerAndActions);this.resume()},resume:function(){this.scheduler.resumeTarget(this);this.actionManager&&this.actionManager.resumeTarget(this);cc.eventManager.resumeTarget(this)},pauseSchedulerAndActions:function(){cc.log(cc._LogInfos.Node_pauseSchedulerAndActions);
this.pause()},pause:function(){this.scheduler.pauseTarget(this);this.actionManager&&this.actionManager.pauseTarget(this);cc.eventManager.pauseTarget(this)},setAdditionalTransform:function(a){return void 0===a?this._additionalTransformDirty=!1:(this._additionalTransform=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty),void(this._additionalTransformDirty=!0))},getParentToNodeTransform:function(){this._renderCmd.getParentToNodeTransform()},parentToNodeTransform:function(){return this.getParentToNodeTransform()},
getNodeToWorldTransform:function(){for(var a=this.getNodeToParentTransform(),b=this._parent;null!==b;b=b.parent)a=cc.affineTransformConcat(a,b.getNodeToParentTransform());return a},nodeToWorldTransform:function(){return this.getNodeToWorldTransform()},getWorldToNodeTransform:function(){return cc.affineTransformInvert(this.getNodeToWorldTransform())},worldToNodeTransform:function(){return this.getWorldToNodeTransform()},convertToNodeSpace:function(a){return cc.pointApplyAffineTransform(a,this.getWorldToNodeTransform())},
convertToWorldSpace:function(a){return a=a||cc.p(0,0),cc.pointApplyAffineTransform(a,this.getNodeToWorldTransform())},convertToNodeSpaceAR:function(a){return cc.pSub(this.convertToNodeSpace(a),this._renderCmd.getAnchorPointInPoints())},convertToWorldSpaceAR:function(a){a=a||cc.p(0,0);a=cc.pAdd(a,this._renderCmd.getAnchorPointInPoints());return this.convertToWorldSpace(a)},_convertToWindowSpace:function(a){a=this.convertToWorldSpace(a);return cc.director.convertToUI(a)},convertTouchToNodeSpace:function(a){a=
a.getLocation();return this.convertToNodeSpace(a)},convertTouchToNodeSpaceAR:function(a){a=cc.director.convertToGL(a.getLocation());return this.convertToNodeSpaceAR(a)},update:function(a){this._componentContainer&&!this._componentContainer.isEmpty()&&this._componentContainer.visit(a)},updateTransform:function(){this._arrayMakeObjectsPerformSelector(this._children,cc.Node._stateCallbackType.updateTransform)},retain:function(){},release:function(){},getComponent:function(a){return this._componentContainer?
this._componentContainer.getComponent(a):null},addComponent:function(a){this._componentContainer&&this._componentContainer.add(a)},removeComponent:function(a){return this._componentContainer?this._componentContainer.remove(a):!1},removeAllComponents:function(){this._componentContainer&&this._componentContainer.removeAll()},grid:null,visit:function(a){this._renderCmd.visit(a)},transform:function(a,b){this._renderCmd.transform(a,b)},nodeToParentTransform:function(){return this.getNodeToParentTransform()},
getNodeToParentTransform:function(){return this._renderCmd.getNodeToParentTransform()},getCamera:function(){return this._camera||(this._camera=new cc.Camera),this._camera},getGrid:function(){return this.grid},setGrid:function(a){this.grid=a},getShaderProgram:function(){return this._renderCmd.getShaderProgram()},setShaderProgram:function(a){this._renderCmd.setShaderProgram(a)},getGLServerState:function(){return 0},setGLServerState:function(a){},getBoundingBoxToWorld:function(){var a=cc.rect(0,0,this._contentSize.width,
this._contentSize.height),b=this.getNodeToWorldTransform();if(a=cc.rectApplyAffineTransform(a,b),!this._children)return a;for(var c=this._children,d=0;d<c.length;d++){var e=c[d];e&&e._visible&&(e=e._getBoundingBoxToCurrentNode(b))&&(a=cc.rectUnion(a,e))}return a},_getBoundingBoxToCurrentNode:function(a){var b=cc.rect(0,0,this._contentSize.width,this._contentSize.height);a=void 0===a?this.getNodeToParentTransform():cc.affineTransformConcat(this.getNodeToParentTransform(),a);if(b=cc.rectApplyAffineTransform(b,
a),!this._children)return b;for(var c=this._children,d=0;d<c.length;d++){var e=c[d];e&&e._visible&&(e=e._getBoundingBoxToCurrentNode(a))&&(b=cc.rectUnion(b,e))}return b},getOpacity:function(){return this._realOpacity},getDisplayedOpacity:function(){return this._renderCmd.getDisplayedOpacity()},setOpacity:function(a){this._realOpacity=a;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)},updateDisplayedOpacity:function(a){this._renderCmd._updateDisplayOpacity(a)},isCascadeOpacityEnabled:function(){return this._cascadeOpacityEnabled},
setCascadeOpacityEnabled:function(a){this._cascadeOpacityEnabled!==a&&(this._cascadeOpacityEnabled=a,this._renderCmd.setCascadeOpacityEnabledDirty())},getColor:function(){var a=this._realColor;return cc.color(a.r,a.g,a.b,a.a)},getDisplayedColor:function(){return this._renderCmd.getDisplayedColor()},setColor:function(a){var b=this._realColor;b.r=a.r;b.g=a.g;b.b=a.b;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty)},updateDisplayedColor:function(a){this._renderCmd._updateDisplayColor(a)},
isCascadeColorEnabled:function(){return this._cascadeColorEnabled},setCascadeColorEnabled:function(a){this._cascadeColorEnabled!==a&&(this._cascadeColorEnabled=a,this._renderCmd.setCascadeColorEnabledDirty())},setOpacityModifyRGB:function(a){},isOpacityModifyRGB:function(){return!1},_initRendererCmd:function(){this._renderCmd=cc.renderer.getRenderCmd(this)},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.Node.CanvasRenderCmd(this):new cc.Node.WebGLRenderCmd(this)},
enumerateChildren:function(a,b){cc.assert(a&&0!=a.length,"Invalid name");cc.assert(null!=b,"Invalid callback function");var c=a.length,d=0,e=c,f=!1;2<c&&"/"===a[0]&&"/"===a[1]&&(f=!0,d=2,e-=2);var g=!1;3<c&&"/"===a[c-3]&&"."===a[c-2]&&"."===a[c-1]&&(g=!0,e-=3);c=a.substr(d,e);g&&(c="[[:alnum:]]+/"+c);f?this.doEnumerateRecursive(this,c,b):this.doEnumerate(c,b)},doEnumerateRecursive:function(a,b,c){if(!a.doEnumerate(b,c)){var d;a=a.getChildren();for(var e=a.length,f=0;e>f&&!(d=a[f],this.doEnumerateRecursive(d,
b,c));f++);}},doEnumerate:function(a,b){var c=a.indexOf("/"),d=a,e=!1;-1!==c&&(d=a.substr(0,c),e=!0);for(var f,c=!1,g=this._children,h=g.length,k=0;h>k;k++)if(f=g[k],-1!==f._name.indexOf(d))if(e){if(c=f.doEnumerate(a,b))break}else if(b(f)){c=!0;break}return c}}),cc.Node.create=function(){return new cc.Node},cc.Node._stateCallbackType={onEnter:1,onExit:2,cleanup:3,onEnterTransitionDidFinish:4,updateTransform:5,onExitTransitionDidStart:6,sortAllChildren:7},cc.assert(cc.isFunction(cc._tmp.PrototypeCCNode),
cc._LogInfos.MissingFile,"BaseNodesPropertyDefine.js"),cc._tmp.PrototypeCCNode(),delete cc._tmp.PrototypeCCNode,cc.CustomRenderCmd=function(a,b){this._needDraw=!0;this._target=a;this._callback=b;this.rendering=function(a,b,e){this._callback&&this._callback.call(this._target,a,b,e)}},cc.Node._dirtyFlags={transformDirty:1,visibleDirty:2,colorDirty:4,opacityDirty:8,cacheDirty:16,orderDirty:32,textDirty:64,gradientDirty:128,all:255},cc.Node.RenderCmd=function(a){this._dirtyFlag=1;this._node=a;this._needDraw=
!1;this._anchorPointInPoints=new cc.Point(0,0);this._transform={a:1,b:0,c:0,d:1,tx:0,ty:0};this._worldTransform={a:1,b:0,c:0,d:1,tx:0,ty:0};this._inverse={a:1,b:0,c:0,d:1,tx:0,ty:0};this._displayedOpacity=255;this._displayedColor=cc.color(255,255,255,255);this._cascadeOpacityEnabledDirty=this._cascadeColorEnabledDirty=!1;this._curLevel=-1},cc.Node.RenderCmd.prototype={constructor:cc.Node.RenderCmd,getAnchorPointInPoints:function(){return cc.p(this._anchorPointInPoints)},getDisplayedColor:function(){var a=
this._displayedColor;return cc.color(a.r,a.g,a.b,a.a)},getDisplayedOpacity:function(){return this._displayedOpacity},setCascadeColorEnabledDirty:function(){this._cascadeColorEnabledDirty=!0;this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty)},setCascadeOpacityEnabledDirty:function(){this._cascadeOpacityEnabledDirty=!0;this.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)},getParentToNodeTransform:function(){return this._dirtyFlag&cc.Node._dirtyFlags.transformDirty&&(this._inverse=cc.affineTransformInvert(this.getNodeToParentTransform())),
this._inverse},detachFromParent:function(){},_updateAnchorPointInPoint:function(){var a=this._anchorPointInPoints,b=this._node._contentSize,c=this._node._anchorPoint;a.x=b.width*c.x;a.y=b.height*c.y;this.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},setDirtyFlag:function(a){0===this._dirtyFlag&&0!==a&&cc.renderer.pushDirtyNode(this);this._dirtyFlag|=a},getParentRenderCmd:function(){return this._node&&this._node._parent&&this._node._parent._renderCmd?this._node._parent._renderCmd:null},_updateDisplayColor:function(a){var b,
c,d;b=this._node;var e=this._displayedColor;c=b._realColor;if(this._cascadeColorEnabledDirty&&!b._cascadeColorEnabled){e.r=c.r;e.g=c.g;e.b=c.b;e=new cc.Color(255,255,255,255);a=b._children;b=0;for(c=a.length;c>b;b++)(d=a[b])&&d._renderCmd&&d._renderCmd._updateDisplayColor(e);this._cascadeColorEnabledDirty=!1}else if(void 0===a&&(a=(a=b._parent)&&a._cascadeColorEnabled?a.getDisplayedColor():cc.color.WHITE),e.r=0|c.r*a.r/255,e.g=0|c.g*a.g/255,e.b=0|c.b*a.b/255,b._cascadeColorEnabled){a=b._children;
b=0;for(c=a.length;c>b;b++)(d=a[b])&&d._renderCmd&&(d._renderCmd._updateDisplayColor(e),d._renderCmd._updateColor())}this._dirtyFlag^=this._dirtyFlag&cc.Node._dirtyFlags.colorDirty},_updateDisplayOpacity:function(a){var b,c,d;b=this._node;if(this._cascadeOpacityEnabledDirty&&!b._cascadeOpacityEnabled){this._displayedOpacity=b._realOpacity;c=b._children;a=0;for(b=c.length;b>a;a++)(d=c[a])&&d._renderCmd&&d._renderCmd._updateDisplayOpacity(255);this._cascadeOpacityEnabledDirty=!1}else if(void 0===a&&
(c=b._parent,a=255,c&&c._cascadeOpacityEnabled&&(a=c.getDisplayedOpacity())),this._displayedOpacity=b._realOpacity*a/255,b._cascadeOpacityEnabled){c=b._children;a=0;for(b=c.length;b>a;a++)(d=c[a])&&d._renderCmd&&(d._renderCmd._updateDisplayOpacity(this._displayedOpacity),d._renderCmd._updateColor())}this._dirtyFlag^=this._dirtyFlag&cc.Node._dirtyFlags.opacityDirty},_syncDisplayColor:function(a){var b=this._node,c=this._displayedColor,d=b._realColor;void 0===a&&(a=(a=b._parent)&&a._cascadeColorEnabled?
a.getDisplayedColor():cc.color.WHITE);c.r=0|d.r*a.r/255;c.g=0|d.g*a.g/255;c.b=0|d.b*a.b/255},_syncDisplayOpacity:function(a){var b=this._node;if(void 0===a){var c=b._parent;a=255;c&&c._cascadeOpacityEnabled&&(a=c.getDisplayedOpacity())}this._displayedOpacity=b._realOpacity*a/255},_updateColor:function(){},updateStatus:function(){var a=cc.Node._dirtyFlags,b=this._dirtyFlag,c=b&a.colorDirty,d=b&a.opacityDirty;c&&this._updateDisplayColor();d&&this._updateDisplayOpacity();(c||d)&&this._updateColor();
b&a.transformDirty&&(this.transform(this.getParentRenderCmd(),!0),this._dirtyFlag^=this._dirtyFlag&cc.Node._dirtyFlags.transformDirty)}},function(){cc.Node.CanvasRenderCmd=function(a){cc.Node.RenderCmd.call(this,a);this._cachedParent=null;this._cacheDirty=!1};var a=cc.Node.CanvasRenderCmd.prototype=Object.create(cc.Node.RenderCmd.prototype);a.constructor=cc.Node.CanvasRenderCmd;a.transform=function(a,c){var d=this.getNodeToParentTransform(),e=this._worldTransform;if(this._cacheDirty=!0,a){var f=a._worldTransform;
e.a=d.a*f.a+d.b*f.c;e.b=d.a*f.b+d.b*f.d;e.c=d.c*f.a+d.d*f.c;e.d=d.c*f.b+d.d*f.d;e.tx=f.a*d.tx+f.c*d.ty+f.tx;e.ty=f.d*d.ty+f.ty+f.b*d.tx}else e.a=d.a,e.b=d.b,e.c=d.c,e.d=d.d,e.tx=d.tx,e.ty=d.ty;if(c&&(d=this._node._children)&&0!==d.length){e=0;for(f=d.length;f>e;e++)d[e]._renderCmd.transform(this,c)}};a.getNodeToParentTransform=function(){var a=this._node,c=!1;a._usingNormalizedPosition&&a._parent&&(c=a._parent._contentSize,a._position.x=a._normalizedPosition.x*c.width,a._position.y=a._normalizedPosition.y*
c.height,a._normalizedPositionDirty=!1,c=!0);if(c||this._dirtyFlag&cc.Node._dirtyFlags.transformDirty){c=this._transform;c.tx=a._position.x;c.ty=a._position.y;var d=1,e=0,f=0,g=1;a._rotationX&&(g=0.017453292519943295*a._rotationX,f=Math.sin(g),g=Math.cos(g));a._rotationY&&(e=0.017453292519943295*a._rotationY,d=Math.cos(e),e=-Math.sin(e));c.a=d;c.b=e;c.c=f;c.d=g;var h=a._scaleX,k=a._scaleY,m=this._anchorPointInPoints.x,n=this._anchorPointInPoints.y,p=1E-6>h&&-1E-6<h?1E-6:h,r=1E-6>k&&-1E-6<k?1E-6:k;
if((1!==h||1!==k)&&(d=c.a*=p,e=c.b*=p,f=c.c*=r,g=c.d*=r),a._skewX||a._skewY)h=Math.tan(-a._skewX*Math.PI/180),k=Math.tan(-a._skewY*Math.PI/180),h===1/0&&(h=99999999),k===1/0&&(k=99999999),p=n*h,r=m*k,c.a=d-f*k,c.b=e-g*k,c.c=f-d*h,c.d=g-e*h,c.tx+=d*p+f*r,c.ty+=e*p+g*r;c.tx-=d*m+f*n;c.ty-=e*m+g*n;a._ignoreAnchorPointForPosition&&(c.tx+=m,c.ty+=n);a._additionalTransformDirty&&(this._transform=cc.affineTransformConcat(c,a._additionalTransform))}return this._transform};a.visit=function(a){var c=this._node;
if(c._visible){(a=a||this.getParentRenderCmd())&&(this._curLevel=a._curLevel+1);var d,e=c._children;this._syncStatus(a);a=e.length;if(0<a){c.sortAllChildren();for(c=0;a>c&&(d=e[c],0>d._localZOrder);c++)d._renderCmd.visit(this);for(cc.renderer.pushRenderCommand(this);a>c;c++)e[c]._renderCmd.visit(this)}else cc.renderer.pushRenderCommand(this);this._dirtyFlag=0}};a._syncStatus=function(a){var c=cc.Node._dirtyFlags,d=this._dirtyFlag,e=a?a._node:null;e&&e._cascadeColorEnabled&&a._dirtyFlag&c.colorDirty&&
(d|=c.colorDirty);e&&e._cascadeOpacityEnabled&&a._dirtyFlag&c.opacityDirty&&(d|=c.opacityDirty);a&&a._dirtyFlag&c.transformDirty&&(d|=c.transformDirty);var e=d&c.colorDirty,f=d&c.opacityDirty,c=d&c.transformDirty;this._dirtyFlag=d;e&&this._syncDisplayColor();f&&this._syncDisplayOpacity();e&&this._updateColor();c&&this.transform(a)};a.setDirtyFlag=function(a){cc.Node.RenderCmd.prototype.setDirtyFlag.call(this,a);this._setCacheDirty();this._cachedParent&&this._cachedParent.setDirtyFlag(a)};a._setCacheDirty=
function(){if(!1===this._cacheDirty){this._cacheDirty=!0;var a=this._cachedParent;a&&a!==this&&a._setNodeDirtyForCache&&a._setNodeDirtyForCache()}};a._setCachedParent=function(a){if(this._cachedParent!==a){this._cachedParent=a;for(var c=this._node._children,d=0,e=c.length;e>d;d++)c[d]._renderCmd._setCachedParent(a)}};a.detachFromParent=function(){this._cachedParent=null;for(var a,c=this._node._children,d=0,e=c.length;e>d;d++)(a=c[d])&&a._renderCmd&&a._renderCmd.detachFromParent()};a.setShaderProgram=
function(a){};a.getShaderProgram=function(){return null};cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc=function(a){return a?a.src===cc.SRC_ALPHA&&a.dst===cc.ONE||a.src===cc.ONE&&a.dst===cc.ONE?"lighter":a.src===cc.ZERO&&a.dst===cc.SRC_ALPHA?"destination-in":a.src===cc.ZERO&&a.dst===cc.ONE_MINUS_SRC_ALPHA?"destination-out":"source-over":"source-over"}}(),cc._tmp.PrototypeTexture2D=function(){var a=cc.Texture2D;a.PVRImagesHavePremultipliedAlpha=function(a){cc.PVRHaveAlphaPremultiplied_=
a};a.PIXEL_FORMAT_RGBA8888=2;a.PIXEL_FORMAT_RGB888=3;a.PIXEL_FORMAT_RGB565=4;a.PIXEL_FORMAT_A8=5;a.PIXEL_FORMAT_I8=6;a.PIXEL_FORMAT_AI88=7;a.PIXEL_FORMAT_RGBA4444=8;a.PIXEL_FORMAT_RGB5A1=7;a.PIXEL_FORMAT_PVRTC4=9;a.PIXEL_FORMAT_PVRTC2=10;a.PIXEL_FORMAT_DEFAULT=a.PIXEL_FORMAT_RGBA8888;var b=cc.Texture2D._M={};b[a.PIXEL_FORMAT_RGBA8888]="RGBA8888";b[a.PIXEL_FORMAT_RGB888]="RGB888";b[a.PIXEL_FORMAT_RGB565]="RGB565";b[a.PIXEL_FORMAT_A8]="A8";b[a.PIXEL_FORMAT_I8]="I8";b[a.PIXEL_FORMAT_AI88]="AI88";b[a.PIXEL_FORMAT_RGBA4444]=
"RGBA4444";b[a.PIXEL_FORMAT_RGB5A1]="RGB5A1";b[a.PIXEL_FORMAT_PVRTC4]="PVRTC4";b[a.PIXEL_FORMAT_PVRTC2]="PVRTC2";b=cc.Texture2D._B={};b[a.PIXEL_FORMAT_RGBA8888]=32;b[a.PIXEL_FORMAT_RGB888]=24;b[a.PIXEL_FORMAT_RGB565]=16;b[a.PIXEL_FORMAT_A8]=8;b[a.PIXEL_FORMAT_I8]=8;b[a.PIXEL_FORMAT_AI88]=16;b[a.PIXEL_FORMAT_RGBA4444]=16;b[a.PIXEL_FORMAT_RGB5A1]=16;b[a.PIXEL_FORMAT_PVRTC4]=4;b[a.PIXEL_FORMAT_PVRTC2]=3;b=cc.Texture2D.prototype;b.name;cc.defineGetterSetter(b,"name",b.getName);b.pixelFormat;cc.defineGetterSetter(b,
"pixelFormat",b.getPixelFormat);b.pixelsWidth;cc.defineGetterSetter(b,"pixelsWidth",b.getPixelsWide);b.pixelsHeight;cc.defineGetterSetter(b,"pixelsHeight",b.getPixelsHigh);b.width;cc.defineGetterSetter(b,"width",b._getWidth);b.height;cc.defineGetterSetter(b,"height",b._getHeight);a.defaultPixelFormat=a.PIXEL_FORMAT_DEFAULT},cc._tmp.PrototypeTextureAtlas=function(){var a=cc.TextureAtlas.prototype;a.totalQuads;cc.defineGetterSetter(a,"totalQuads",a.getTotalQuads);a.capacity;cc.defineGetterSetter(a,
"capacity",a.getCapacity);a.quads;cc.defineGetterSetter(a,"quads",a.getQuads,a.setQuads)},cc._tmp.WebGLTexture2D=function(){cc.Texture2D=cc.Class.extend({_pVRHaveAlphaPremultiplied:!0,_pixelFormat:null,_pixelsWide:0,_pixelsHigh:0,_name:"",_contentSize:null,maxS:0,maxT:0,_hasPremultipliedAlpha:!1,_hasMipmaps:!1,shaderProgram:null,_textureLoaded:!1,_htmlElementObj:null,_webTextureObj:null,url:null,ctor:function(){this._contentSize=cc.size(0,0);this._pixelFormat=cc.Texture2D.defaultPixelFormat},releaseTexture:function(){this._webTextureObj&&
cc._renderContext.deleteTexture(this._webTextureObj);cc.loader.release(this.url)},getPixelFormat:function(){return this._pixelFormat},getPixelsWide:function(){return this._pixelsWide},getPixelsHigh:function(){return this._pixelsHigh},getName:function(){return this._webTextureObj},getContentSize:function(){return cc.size(this._contentSize.width/cc.contentScaleFactor(),this._contentSize.height/cc.contentScaleFactor())},_getWidth:function(){return this._contentSize.width/cc.contentScaleFactor()},_getHeight:function(){return this._contentSize.height/
cc.contentScaleFactor()},getContentSizeInPixels:function(){return this._contentSize},getMaxS:function(){return this.maxS},setMaxS:function(a){this.maxS=a},getMaxT:function(){return this.maxT},setMaxT:function(a){this.maxT=a},getShaderProgram:function(){return this.shaderProgram},setShaderProgram:function(a){this.shaderProgram=a},hasPremultipliedAlpha:function(){return this._hasPremultipliedAlpha},hasMipmaps:function(){return this._hasMipmaps},description:function(){return"\x3ccc.Texture2D | Name \x3d "+
this._name+" | Dimensions \x3d "+this._pixelsWide+" x "+this._pixelsHigh+" | Coordinates \x3d ("+this.maxS+", "+this.maxT+")\x3e"},releaseData:function(a){},keepData:function(a,b){return a},initWithData:function(a,b,c,d,e){var f=cc.Texture2D,g=cc._renderContext,h=g.RGBA,k=g.UNSIGNED_BYTE,m=c*cc.Texture2D._B[b]/8;switch(0===m%8?g.pixelStorei(g.UNPACK_ALIGNMENT,8):0===m%4?g.pixelStorei(g.UNPACK_ALIGNMENT,4):0===m%2?g.pixelStorei(g.UNPACK_ALIGNMENT,2):g.pixelStorei(g.UNPACK_ALIGNMENT,1),this._webTextureObj=
g.createTexture(),cc.glBindTexture2D(this),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MIN_FILTER,g.LINEAR),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MAG_FILTER,g.LINEAR),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_S,g.CLAMP_TO_EDGE),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_T,g.CLAMP_TO_EDGE),b){case f.PIXEL_FORMAT_RGBA8888:h=g.RGBA;break;case f.PIXEL_FORMAT_RGB888:h=g.RGB;break;case f.PIXEL_FORMAT_RGBA4444:k=g.UNSIGNED_SHORT_4_4_4_4;break;case f.PIXEL_FORMAT_RGB5A1:k=g.UNSIGNED_SHORT_5_5_5_1;break;case f.PIXEL_FORMAT_RGB565:k=
g.UNSIGNED_SHORT_5_6_5;break;case f.PIXEL_FORMAT_AI88:h=g.LUMINANCE_ALPHA;break;case f.PIXEL_FORMAT_A8:h=g.ALPHA;break;case f.PIXEL_FORMAT_I8:h=g.LUMINANCE;break;default:cc.assert(0,cc._LogInfos.Texture2D_initWithData)}return g.texImage2D(g.TEXTURE_2D,0,h,c,d,0,h,k,a),this._contentSize.width=e.width,this._contentSize.height=e.height,this._pixelsWide=c,this._pixelsHigh=d,this._pixelFormat=b,this.maxS=e.width/c,this.maxT=e.height/d,this._hasPremultipliedAlpha=!1,this._hasMipmaps=!1,this.shaderProgram=
cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE),this._textureLoaded=!0,!0},drawAtPoint:function(a){var b=[0,this.maxT,this.maxS,this.maxT,0,0,this.maxS,0],c=this._pixelsWide*this.maxS,d=this._pixelsHigh*this.maxT;a=[a.x,a.y,0,c+a.x,a.y,0,a.x,d+a.y,0,c+a.x,d+a.y,0];cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION|cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);this._shaderProgram.use();this._shaderProgram.setUniformsForBuiltins();cc.glBindTexture2D(this);c=cc._renderContext;c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,
2,c.FLOAT,!1,0,a);c.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,c.FLOAT,!1,0,b);c.drawArrays(c.TRIANGLE_STRIP,0,4)},drawInRect:function(a){var b=[0,this.maxT,this.maxS,this.maxT,0,0,this.maxS,0];a=[a.x,a.y,a.x+a.width,a.y,a.x,a.y+a.height,a.x+a.width,a.y+a.height];cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION|cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);this._shaderProgram.use();this._shaderProgram.setUniformsForBuiltins();cc.glBindTexture2D(this);var c=cc._renderContext;c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,
2,c.FLOAT,!1,0,a);c.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,c.FLOAT,!1,0,b);c.drawArrays(c.TRIANGLE_STRIP,0,4)},initWithImage:function(a){if(null==a)return cc.log(cc._LogInfos.Texture2D_initWithImage),!1;var b=a.getWidth(),c=a.getHeight(),d=cc.configuration.getMaxTextureSize();return b>d||c>d?(cc.log(cc._LogInfos.Texture2D_initWithImage_2,b,c,d,d),!1):(this._textureLoaded=!0,this._initPremultipliedATextureWithImage(a,b,c))},initWithElement:function(a){a&&(this._webTextureObj=cc._renderContext.createTexture(),
this._htmlElementObj=a,this._textureLoaded=!0)},getHtmlElementObj:function(){return this._htmlElementObj},isLoaded:function(){return this._textureLoaded},handleLoadedTexture:function(a){a=void 0===a?!1:a;if(cc._rendererInitialized){if(!this._htmlElementObj){var b=cc.loader.getRes(this.url);if(!b)return;this.initWithElement(b)}this._htmlElementObj.width&&this._htmlElementObj.height&&(b=cc._renderContext,cc.glBindTexture2D(this),b.pixelStorei(b.UNPACK_ALIGNMENT,4),a&&b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL,
1),b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,this._htmlElementObj),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE),this.shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE),cc.glBindTexture2D(null),a&&b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),b=this._htmlElementObj.height,
this._pixelsWide=this._contentSize.width=this._htmlElementObj.width,this._pixelsHigh=this._contentSize.height=b,this._pixelFormat=cc.Texture2D.PIXEL_FORMAT_RGBA8888,this.maxT=this.maxS=1,this._hasPremultipliedAlpha=a,this._hasMipmaps=!1,this.dispatchEvent("load"))}},initWithString:function(a,b,c,d,e,f){return cc.log(cc._LogInfos.Texture2D_initWithString),null},initWithETCFile:function(a){return cc.log(cc._LogInfos.Texture2D_initWithETCFile_2),!1},initWithPVRFile:function(a){return cc.log(cc._LogInfos.Texture2D_initWithPVRFile_2),
!1},initWithPVRTCData:function(a,b,c,d,e,f){return cc.log(cc._LogInfos.Texture2D_initWithPVRTCData_2),!1},setTexParameters:function(a,b,c,d){var e=cc._renderContext;void 0!==b&&(a={minFilter:a,magFilter:b,wrapS:c,wrapT:d});cc.assert(this._pixelsWide===cc.NextPOT(this._pixelsWide)&&this._pixelsHigh===cc.NextPOT(this._pixelsHigh)||a.wrapS===e.CLAMP_TO_EDGE&&a.wrapT===e.CLAMP_TO_EDGE,"WebGLRenderingContext.CLAMP_TO_EDGE should be used in NPOT textures");cc.glBindTexture2D(this);e.texParameteri(e.TEXTURE_2D,
e.TEXTURE_MIN_FILTER,a.minFilter);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,a.magFilter);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,a.wrapS);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,a.wrapT)},setAntiAliasTexParameters:function(){var a=cc._renderContext;cc.glBindTexture2D(this);this._hasMipmaps?a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR_MIPMAP_NEAREST):a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR)},
setAliasTexParameters:function(){var a=cc._renderContext;cc.glBindTexture2D(this);this._hasMipmaps?a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST_MIPMAP_NEAREST):a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST)},generateMipmap:function(){cc.assert(this._pixelsWide===cc.NextPOT(this._pixelsWide)&&this._pixelsHigh===cc.NextPOT(this._pixelsHigh),"Mimpap texture only works in POT textures");cc.glBindTexture2D(this);
cc._renderContext.generateMipmap(cc._renderContext.TEXTURE_2D);this._hasMipmaps=!0},stringForFormat:function(){return cc.Texture2D._M[this._pixelFormat]},bitsPerPixelForFormat:function(a){a=a||this._pixelFormat;var b=cc.Texture2D._B[a];return null!=b?b:(cc.log(cc._LogInfos.Texture2D_bitsPerPixelForFormat,a),-1)},_initPremultipliedATextureWithImage:function(a,b,c){var d,e=cc.Texture2D,f=a.getData(),g=null,g=null,h=a.hasAlpha(),k=cc.size(a.getWidth(),a.getHeight()),m=e.defaultPixelFormat;d=a.getBitsPerComponent();
h||(8<=d?m=e.PIXEL_FORMAT_RGB888:(cc.log(cc._LogInfos.Texture2D__initPremultipliedATextureWithImage),m=e.PIXEL_FORMAT_RGB565));var n=b*c;if(m===e.PIXEL_FORMAT_RGB565)if(h){f=new Uint16Array(b*c);g=a.getData();for(d=0;n>d;++d)f[d]=(g[d]>>0&255)>>3<<11|(g[d]>>8&255)>>2<<5|(g[d]>>16&255)>>3<<0}else{f=new Uint16Array(b*c);g=a.getData();for(d=0;n>d;++d)f[d]=(255&g[d])>>3<<11|(255&g[d])>>2<<5|(255&g[d])>>3<<0}else if(m===e.PIXEL_FORMAT_RGBA4444){f=new Uint16Array(b*c);g=a.getData();for(d=0;n>d;++d)f[d]=
(g[d]>>0&255)>>4<<12|(g[d]>>8&255)>>4<<8|(g[d]>>16&255)>>4<<4|(g[d]>>24&255)>>4<<0}else if(m===e.PIXEL_FORMAT_RGB5A1){f=new Uint16Array(b*c);g=a.getData();for(d=0;n>d;++d)f[d]=(g[d]>>0&255)>>3<<11|(g[d]>>8&255)>>3<<6|(g[d]>>16&255)>>3<<1|(g[d]>>24&255)>>7<<0}else if(m===e.PIXEL_FORMAT_A8){f=new Uint8Array(b*c);g=a.getData();for(d=0;n>d;++d)f[d]=g>>24&255}if(h&&m===e.PIXEL_FORMAT_RGB888){g=a.getData();f=new Uint8Array(3*b*c);for(d=0;n>d;++d)f[3*d]=g>>0&255,f[3*d+1]=g>>8&255,f[3*d+2]=g>>16&255}return this.initWithData(f,
m,b,c,k),a.getData(),this._hasPremultipliedAlpha=a.isPremultipliedAlpha(),!0},addLoadedEventListener:function(a,b){this.addEventListener("load",a,b)},removeLoadedEventListener:function(a){this.removeEventListener("load",a)}})},cc._tmp.WebGLTextureAtlas=function(){var a=cc.TextureAtlas.prototype;a._setupVBO=function(){var a=cc._renderContext;this._buffersVBO[0]=a.createBuffer();this._buffersVBO[1]=a.createBuffer();this._quadsWebBuffer=a.createBuffer();this._mapBuffers()};a._mapBuffers=function(){var a=
cc._renderContext;a.bindBuffer(a.ARRAY_BUFFER,this._quadsWebBuffer);a.bufferData(a.ARRAY_BUFFER,this._quadsArrayBuffer,a.DYNAMIC_DRAW);a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this._buffersVBO[1]);a.bufferData(a.ELEMENT_ARRAY_BUFFER,this._indices,a.STATIC_DRAW)};a.drawNumberOfQuads=function(a,c){if(c=c||0,0!==a&&this.texture&&this.texture.isLoaded()){var d=cc._renderContext;cc.glBindTexture2D(this.texture);cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);d.bindBuffer(d.ARRAY_BUFFER,this._quadsWebBuffer);
this.dirty&&(d.bufferData(d.ARRAY_BUFFER,this._quadsArrayBuffer,d.DYNAMIC_DRAW),this.dirty=!1);d.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,3,d.FLOAT,!1,24,0);d.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,d.UNSIGNED_BYTE,!0,24,12);d.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,d.FLOAT,!1,24,16);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,this._buffersVBO[1]);cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP?d.drawElements(d.TRIANGLE_STRIP,6*a,d.UNSIGNED_SHORT,6*c*this._indices.BYTES_PER_ELEMENT):d.drawElements(d.TRIANGLES,
6*a,d.UNSIGNED_SHORT,6*c*this._indices.BYTES_PER_ELEMENT);cc.g_NumberOfDraws++}}},cc._tmp.WebGLTextureCache=function(){var a=cc.textureCache;a.handleLoadedTexture=function(a){var c=this._textures;cc._rendererInitialized||(c=this._loadedTexturesBefore);var d=c[a];d||(d=c[a]=new cc.Texture2D,d.url=a);d.handleLoadedTexture()};a.addImage=function(a,c,d){cc.assert(a,cc._LogInfos.Texture2D_addImage_2);var e=this._textures;cc._rendererInitialized||(e=this._loadedTexturesBefore);var f=e[a]||e[cc.loader._aliases[a]];
if(f)return c&&c.call(d,f),f;f=e[a]=new cc.Texture2D;f.url=a;return(cc.loader._checkIsImageURL(a)?cc.loader.load:cc.loader.loadImg).call(cc.loader,a,function(f,h){if(f)return c&&c.call(d,f);cc.textureCache.handleLoadedTexture(a);var k=e[a];c&&c.call(d,k)}),f};a.addImageAsync=a.addImage;a=null},cc.ALIGN_CENTER=51,cc.ALIGN_TOP=19,cc.ALIGN_TOP_RIGHT=18,cc.ALIGN_RIGHT=50,cc.ALIGN_BOTTOM_RIGHT=34,cc.ALIGN_BOTTOM=35,cc.ALIGN_BOTTOM_LEFT=33,cc.ALIGN_LEFT=49,cc.ALIGN_TOP_LEFT=17,cc.PVRHaveAlphaPremultiplied_=
!1,cc._renderType===cc._RENDER_TYPE_CANVAS?(cc.Texture2D=cc.Class.extend({_contentSize:null,_textureLoaded:!1,_htmlElementObj:null,url:null,_pattern:null,ctor:function(){this._contentSize=cc.size(0,0);this._textureLoaded=!1;this._htmlElementObj=null;this._pattern=""},getPixelsWide:function(){return this._contentSize.width},getPixelsHigh:function(){return this._contentSize.height},getContentSize:function(){var a=cc.contentScaleFactor();return cc.size(this._contentSize.width/a,this._contentSize.height/
a)},_getWidth:function(){return this._contentSize.width/cc.contentScaleFactor()},_getHeight:function(){return this._contentSize.height/cc.contentScaleFactor()},getContentSizeInPixels:function(){return this._contentSize},initWithElement:function(a){a&&(this._htmlElementObj=a,this._contentSize.width=a.width,this._contentSize.height=a.height,this._textureLoaded=!0)},getHtmlElementObj:function(){return this._htmlElementObj},isLoaded:function(){return this._textureLoaded},handleLoadedTexture:function(){if(!this._textureLoaded){if(!this._htmlElementObj){var a=
cc.loader.getRes(this.url);if(!a)return;this.initWithElement(a)}a=this._htmlElementObj;this._contentSize.width=a.width;this._contentSize.height=a.height;this.dispatchEvent("load")}},description:function(){return"\x3ccc.Texture2D | width \x3d "+this._contentSize.width+" height "+this._contentSize.height+"\x3e"},initWithData:function(a,b,c,d,e){return!1},initWithImage:function(a){return!1},initWithString:function(a,b,c,d,e,f){return!1},releaseTexture:function(){cc.loader.release(this.url)},getName:function(){return null},
getMaxS:function(){return 1},setMaxS:function(a){},getMaxT:function(){return 1},setMaxT:function(a){},getPixelFormat:function(){return null},getShaderProgram:function(){return null},setShaderProgram:function(a){},hasPremultipliedAlpha:function(){return!1},hasMipmaps:function(){return!1},releaseData:function(a){},keepData:function(a,b){return a},drawAtPoint:function(a){},drawInRect:function(a){},initWithETCFile:function(a){return cc.log(cc._LogInfos.Texture2D_initWithETCFile),!1},initWithPVRFile:function(a){return cc.log(cc._LogInfos.Texture2D_initWithPVRFile),
!1},initWithPVRTCData:function(a,b,c,d,e,f){return cc.log(cc._LogInfos.Texture2D_initWithPVRTCData),!1},setTexParameters:function(a,b,c,d){return void 0!==b&&(a={minFilter:a,magFilter:b,wrapS:c,wrapT:d}),a.wrapS===cc.REPEAT&&a.wrapT===cc.REPEAT?void(this._pattern="repeat"):a.wrapS===cc.REPEAT?void(this._pattern="repeat-x"):a.wrapT===cc.REPEAT?void(this._pattern="repeat-y"):void(this._pattern="")},setAntiAliasTexParameters:function(){},setAliasTexParameters:function(){},generateMipmap:function(){},
stringForFormat:function(){return""},bitsPerPixelForFormat:function(a){return-1},addLoadedEventListener:function(a,b){this.addEventListener("load",a,b)},removeLoadedEventListener:function(a){this.removeEventListener("load",a)},_grayElementObj:null,_backupElement:null,_isGray:!1,_switchToGray:function(a){this._textureLoaded&&this._isGray!==a&&(this._isGray=a,this._isGray?(this._backupElement=this._htmlElementObj,this._grayElementObj||(this._grayElementObj=cc.Texture2D._generateGrayTexture(this._htmlElementObj)),
this._htmlElementObj=this._grayElementObj):null!==this._backupElement&&(this._htmlElementObj=this._backupElement))}}),cc.Texture2D._generateGrayTexture=function(a,b,c){if(null===a)return null;c=c||cc.newElement("canvas");b=b||cc.rect(0,0,a.width,a.height);c.width=b.width;c.height=b.height;var d=c.getContext("2d");d.drawImage(a,b.x,b.y,b.width,b.height,0,0,b.width,b.height);a=d.getImageData(0,0,b.width,b.height);b=a.data;for(var e=0,f=b.length;f>e;e+=4)b[e]=b[e+1]=b[e+2]=0.34*b[e]+0.5*b[e+1]+0.16*
b[e+2];return d.putImageData(a,0,0),c}):(cc.assert(cc.isFunction(cc._tmp.WebGLTexture2D),cc._LogInfos.MissingFile,"TexturesWebGL.js"),cc._tmp.WebGLTexture2D(),delete cc._tmp.WebGLTexture2D),cc.EventHelper.prototype.apply(cc.Texture2D.prototype),cc.assert(cc.isFunction(cc._tmp.PrototypeTexture2D),cc._LogInfos.MissingFile,"TexturesPropertyDefine.js"),cc._tmp.PrototypeTexture2D(),delete cc._tmp.PrototypeTexture2D,cc.textureCache={_textures:{},_textureColorsCache:{},_textureKeySeq:0|1E3*Math.random(),
_loadedTexturesBefore:{},_initializingRenderer:function(){var a,b=this._loadedTexturesBefore,c=this._textures;for(a in b){var d=b[a];d.handleLoadedTexture();c[a]=d}this._loadedTexturesBefore={}},addPVRTCImage:function(a){cc.log(cc._LogInfos.textureCache_addPVRTCImage)},addETCImage:function(a){cc.log(cc._LogInfos.textureCache_addETCImage)},description:function(){return"\x3cTextureCache | Number of textures \x3d "+this._textures.length+"\x3e"},textureForKey:function(a){return cc.log(cc._LogInfos.textureCache_textureForKey),
this.getTextureForKey(a)},getTextureForKey:function(a){return this._textures[a]||this._textures[cc.loader._aliases[a]]},getKeyByTexture:function(a){for(var b in this._textures)if(this._textures[b]===a)return b;return null},_generalTextureKey:function(){return this._textureKeySeq++,"_textureKey_"+this._textureKeySeq},getTextureColors:function(a){var b=this.getKeyByTexture(a);return b||(b=a instanceof HTMLImageElement?a.src:this._generalTextureKey()),this._textureColorsCache[b]||(this._textureColorsCache[b]=
cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor(a)),this._textureColorsCache[b]},addPVRImage:function(a){cc.log(cc._LogInfos.textureCache_addPVRImage)},removeAllTextures:function(){var a=this._textures,b;for(b in a)a[b]&&a[b].releaseTexture();this._textures={}},removeTexture:function(a){if(a){var b=this._textures,c;for(c in b)b[c]===a&&(b[c].releaseTexture(),delete b[c])}},removeTextureForKey:function(a){null!=a&&this._textures[a]&&delete this._textures[a]},cacheImage:function(a,b){if(b instanceof
cc.Texture2D)return void(this._textures[a]=b);var c=new cc.Texture2D;c.initWithElement(b);c.handleLoadedTexture();this._textures[a]=c},addUIImage:function(a,b){if(cc.assert(a,cc._LogInfos.textureCache_addUIImage_2),b&&this._textures[b])return this._textures[b];var c=new cc.Texture2D;return c.initWithImage(a),null!=b?this._textures[b]=c:cc.log(cc._LogInfos.textureCache_addUIImage),c},dumpCachedTextureInfo:function(){var a=0,b=0,c=this._textures,d;for(d in c){var e=c[d];a++;e.getHtmlElementObj()instanceof
HTMLImageElement?cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo,d,e.getHtmlElementObj().src,e.pixelsWidth,e.pixelsHeight):cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2,d,e.pixelsWidth,e.pixelsHeight);b+=4*e.pixelsWidth*e.pixelsHeight}c=this._textureColorsCache;for(d in c){var e=c[d],f;for(f in e){var g=e[f];a++;cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2,d,g.width,g.height);b+=4*g.width*g.height}}cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_3,a,b/1024,(b/
1048576).toFixed(2))},_clear:function(){this._textures={};this._textureColorsCache={};this._textureKeySeq=0|1E3*Math.random();this._loadedTexturesBefore={}}},cc._renderType===cc._RENDER_TYPE_CANVAS){var _p=cc.textureCache;_p.handleLoadedTexture=function(a){var b=this._textures,c=b[a];c||(c=b[a]=new cc.Texture2D,c.url=a);c.handleLoadedTexture()};_p.addImage=function(a,b,c){cc.assert(a,cc._LogInfos.Texture2D_addImage);var d=this._textures,e=d[a]||d[cc.loader._aliases[a]];if(e)return b&&b.call(c,e),
e;e=d[a]=new cc.Texture2D;e.url=a;return(cc.loader._checkIsImageURL(a)?cc.loader.load:cc.loader.loadImg).call(cc.loader,a,function(e,g){if(e)return b&&b.call(c,e);cc.textureCache.handleLoadedTexture(a);var h=d[a];b&&b.call(c,h)}),e};_p.addImageAsync=_p.addImage;_p=null}else cc.assert(cc.isFunction(cc._tmp.WebGLTextureCache),cc._LogInfos.MissingFile,"TexturesWebGL.js"),cc._tmp.WebGLTextureCache(),delete cc._tmp.WebGLTextureCache;
(cc.Scene=cc.Node.extend({_className:"Scene",ctor:function(){cc.Node.prototype.ctor.call(this);this._ignoreAnchorPointForPosition=!0;this.setAnchorPoint(0.5,0.5);this.setContentSize(cc.director.getWinSize())}}),cc.Scene.create=function(){return new cc.Scene},cc.LoaderScene=cc.Scene.extend({_interval:null,_label:null,_className:"LoaderScene",cb:null,target:null,init:function(){var a=this,b=200,c=a._bgLayer=new cc.LayerColor(cc.color(32,32,32,255));a.addChild(c,0);var d=24,e=-b/2+100;cc._loaderImage&&
(cc.loader.loadImg(cc._loaderImage,{isCrossOrigin:!1},function(c,d){b=d.height;a._initStage(d,cc.visibleRect.center)}),d=14,e=-b/2-10);d=a._label=new cc.LabelTTF("Loading... 0%","Arial",d);return d.setPosition(cc.pAdd(cc.visibleRect.center,cc.p(0,e))),d.setColor(cc.color(180,180,180)),c.addChild(this._label,10),!0},_initStage:function(a,b){var c=this._texture2d=new cc.Texture2D;c.initWithElement(a);c.handleLoadedTexture();c=this._logo=new cc.Sprite(c);c.setScale(cc.contentScaleFactor());c.x=b.x;c.y=
b.y;this._bgLayer.addChild(c,10)},onEnter:function(){cc.Node.prototype.onEnter.call(this);this.schedule(this._startLoading,0.3)},onExit:function(){cc.Node.prototype.onExit.call(this);this._label.setString("Loading... 0%")},initWithResources:function(a,b,c){cc.isString(a)&&(a=[a]);this.resources=a||[];this.cb=b;this.target=c},_startLoading:function(){var a=this;a.unschedule(a._startLoading);cc.loader.load(a.resources,function(b,c,d){b=Math.min(100*(d/c)|0,100);a._label.setString("Loading... "+b+"%")},
function(){a.cb&&a.cb.call(a.target)})}}),cc.LoaderScene.preload=function(a,b,c){var d=cc;return d.loaderScene||(d.loaderScene=new cc.LoaderScene,d.loaderScene.init()),d.loaderScene.initWithResources(a,b,c),cc.director.runScene(d.loaderScene),d.loaderScene},cc.Layer=cc.Node.extend({_className:"Layer",ctor:function(){var a=cc.Node.prototype;a.ctor.call(this);this._ignoreAnchorPointForPosition=!0;a.setAnchorPoint.call(this,0.5,0.5);a.setContentSize.call(this,cc.winSize)},init:function(){return this._ignoreAnchorPointForPosition=
!0,this.setAnchorPoint(0.5,0.5),this.setContentSize(cc.winSize),this._cascadeColorEnabled=!1,this._cascadeOpacityEnabled=!1,!0},bake:function(){this._renderCmd.bake()},unbake:function(){this._renderCmd.unbake()},isBaked:function(){return this._isBaked},addChild:function(a,b,c){cc.Node.prototype.addChild.call(this,a,b,c);this._renderCmd._bakeForAddChild(a)},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.Layer.CanvasRenderCmd(this):new cc.Layer.WebGLRenderCmd(this)}}),
cc.Layer.create=function(){return new cc.Layer},cc.LayerColor=cc.Layer.extend({_blendFunc:null,_className:"LayerColor",getBlendFunc:function(){return this._blendFunc},changeWidthAndHeight:function(a,b){this.width=a;this.height=b},changeWidth:function(a){this.width=a},changeHeight:function(a){this.height=a},setOpacityModifyRGB:function(a){},isOpacityModifyRGB:function(){return!1},ctor:function(a,b,c){cc.Layer.prototype.ctor.call(this);this._blendFunc=new cc.BlendFunc(cc.BLEND_SRC,cc.BLEND_DST);cc.LayerColor.prototype.init.call(this,
a,b,c)},init:function(a,b,c){cc._renderType!==cc._RENDER_TYPE_CANVAS&&(this.shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR));var d=cc.director.getWinSize();a=a||cc.color(0,0,0,255);b=void 0===b?d.width:b;c=void 0===c?d.height:c;d=this._realColor;return d.r=a.r,d.g=a.g,d.b=a.b,this._realOpacity=a.a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty|cc.Node._dirtyFlags.opacityDirty),cc.LayerColor.prototype.setContentSize.call(this,b,c),!0},setBlendFunc:function(a,b){var c=
this._blendFunc;void 0===b?(c.src=a.src,c.dst=a.dst):(c.src=a,c.dst=b);this._renderCmd.updateBlendFunc(c)},_setWidth:function(a){cc.Node.prototype._setWidth.call(this,a);this._renderCmd._updateSquareVerticesWidth(a)},_setHeight:function(a){cc.Node.prototype._setHeight.call(this,a);this._renderCmd._updateSquareVerticesHeight(a)},setContentSize:function(a,b){cc.Layer.prototype.setContentSize.call(this,a,b);this._renderCmd._updateSquareVertices(a,b)},_createRenderCmd:function(){return cc._renderType===
cc._RENDER_TYPE_CANVAS?new cc.LayerColor.CanvasRenderCmd(this):new cc.LayerColor.WebGLRenderCmd(this)}}),cc.LayerColor.create=function(a,b,c){return new cc.LayerColor(a,b,c)},function(){var a=cc.LayerColor.prototype;cc.defineGetterSetter(a,"width",a._getWidth,a._setWidth);cc.defineGetterSetter(a,"height",a._getHeight,a._setHeight)}(),cc.LayerGradient=cc.LayerColor.extend({_endColor:null,_startOpacity:255,_endOpacity:255,_alongVector:null,_compressedInterpolation:!1,_className:"LayerGradient",_colorStops:[],
ctor:function(a,b,c,d){cc.LayerColor.prototype.ctor.call(this);this._endColor=cc.color(0,0,0,255);this._alongVector=cc.p(0,-1);this._endOpacity=this._startOpacity=255;d&&d instanceof Array?(this._colorStops=d,d.splice(0,0,{p:0,color:a||cc.color.BLACK}),d.push({p:1,color:b||cc.color.BLACK})):this._colorStops=[{p:0,color:a||cc.color.BLACK},{p:1,color:b||cc.color.BLACK}];cc.LayerGradient.prototype.init.call(this,a,b,c,d)},init:function(a,b,c,d){a=a||cc.color(0,0,0,255);b=b||cc.color(0,0,0,255);c=c||
cc.p(0,-1);d=this._endColor;return this._startOpacity=a.a,d.r=b.r,d.g=b.g,d.b=b.b,this._endOpacity=b.a,this._alongVector=c,this._compressedInterpolation=!0,cc.LayerColor.prototype.init.call(this,cc.color(a.r,a.g,a.b,255)),this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty|cc.Node._dirtyFlags.opacityDirty|cc.Node._dirtyFlags.gradientDirty),!0},setContentSize:function(a,b){cc.LayerColor.prototype.setContentSize.call(this,a,b);this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty)},
_setWidth:function(a){cc.LayerColor.prototype._setWidth.call(this,a);this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty)},_setHeight:function(a){cc.LayerColor.prototype._setHeight.call(this,a);this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty)},getStartColor:function(){return cc.color(this._realColor)},setStartColor:function(a){this.color=a;var b=this._colorStops;b&&0<b.length&&(b=b[0].color,b.r=a.r,b.g=a.g,b.b=a.b)},setEndColor:function(a){var b=this._endColor;b.r=a.r;b.g=
a.g;b.b=a.b;if((b=this._colorStops)&&0<b.length)b=b[b.length-1].color,b.r=a.r,b.g=a.g,b.b=a.b;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty)},getEndColor:function(){return cc.color(this._endColor)},setStartOpacity:function(a){this._startOpacity=a;var b=this._colorStops;b&&0<b.length&&(b[0].color.a=a);this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)},getStartOpacity:function(){return this._startOpacity},setEndOpacity:function(a){this._endOpacity=a;var b=this._colorStops;
b&&0<b.length&&(b[b.length-1].color.a=a);this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)},getEndOpacity:function(){return this._endOpacity},setVector:function(a){this._alongVector.x=a.x;this._alongVector.y=a.y;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty)},getVector:function(){return cc.p(this._alongVector.x,this._alongVector.y)},isCompressedInterpolation:function(){return this._compressedInterpolation},setCompressedInterpolation:function(a){this._compressedInterpolation=
a;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty)},getColorStops:function(){return this._colorStops},setColorStops:function(a){this._colorStops=a;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty|cc.Node._dirtyFlags.opacityDirty|cc.Node._dirtyFlags.gradientDirty)},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.LayerGradient.CanvasRenderCmd(this):new cc.LayerGradient.WebGLRenderCmd(this)}}),cc.LayerGradient.create=function(a,b,c,d){return new cc.LayerGradient(a,
b,c,d)},function(){var a=cc.LayerGradient.prototype;a.startColor;cc.defineGetterSetter(a,"startColor",a.getStartColor,a.setStartColor);a.endColor;cc.defineGetterSetter(a,"endColor",a.getEndColor,a.setEndColor);a.startOpacity;cc.defineGetterSetter(a,"startOpacity",a.getStartOpacity,a.setStartOpacity);a.endOpacity;cc.defineGetterSetter(a,"endOpacity",a.getEndOpacity,a.setEndOpacity);a.vector;cc.defineGetterSetter(a,"vector",a.getVector,a.setVector);a.colorStops;cc.defineGetterSetter(a,"colorStops",
a.getColorStops,a.setColorStops)}(),cc.LayerMultiplex=cc.Layer.extend({_enabledLayer:0,_layers:null,_className:"LayerMultiplex",ctor:function(a){cc.Layer.prototype.ctor.call(this);a instanceof Array?cc.LayerMultiplex.prototype.initWithLayers.call(this,a):cc.LayerMultiplex.prototype.initWithLayers.call(this,Array.prototype.slice.call(arguments))},initWithLayers:function(a){return 0<a.length&&null==a[a.length-1]&&cc.log(cc._LogInfos.LayerMultiplex_initWithLayers),this._layers=a,this._enabledLayer=0,
this.addChild(this._layers[this._enabledLayer]),!0},switchTo:function(a){return a>=this._layers.length?void cc.log(cc._LogInfos.LayerMultiplex_switchTo):(this.removeChild(this._layers[this._enabledLayer],!0),this._enabledLayer=a,void this.addChild(this._layers[a]))},switchToAndReleaseMe:function(a){return a>=this._layers.length?void cc.log(cc._LogInfos.LayerMultiplex_switchToAndReleaseMe):(this.removeChild(this._layers[this._enabledLayer],!0),this._layers[this._enabledLayer]=null,this._enabledLayer=
a,void this.addChild(this._layers[a]))},addLayer:function(a){return a?void this._layers.push(a):void cc.log(cc._LogInfos.LayerMultiplex_addLayer)}}),cc.LayerMultiplex.create=function(){return new cc.LayerMultiplex(Array.prototype.slice.call(arguments))},function(){cc.Layer.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._isBaked=!1;this._bakeSprite=null};var a=cc.Layer.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.Layer.CanvasRenderCmd;
a.bake=function(){if(!this._isBaked){this._needDraw=!0;this._isBaked=this._cacheDirty=cc.renderer.childrenOrderDirty=!0;for(var a=this._node._children,c=0,d=a.length;d>c;c++)a[c]._renderCmd._setCachedParent(this);this._bakeSprite||(this._bakeSprite=new cc.BakeSprite,this._bakeSprite.setAnchorPoint(0,0))}};a.unbake=function(){if(this._isBaked){cc.renderer.childrenOrderDirty=!0;this._isBaked=this._needDraw=!1;this._cacheDirty=!0;for(var a=this._node._children,c=0,d=a.length;d>c;c++)a[c]._renderCmd._setCachedParent(null)}};
a.isBaked=function(){return this._isBaked};a.rendering=function(){if(this._cacheDirty){var a=this._node,c=a._children,d=this._bakeSprite;this.transform(this.getParentRenderCmd(),!0);var e=this._getBoundingBoxForBake();e.width=0|e.width+0.5;e.height=0|e.height+0.5;var f=d.getCacheContext(),g=f.getContext();d.resetCanvasSize(e.width,e.height);f.setOffset(0-e.x,g.canvas.height-e.height+e.y);d.setPosition(e.x,e.y);a.sortAllChildren();cc.renderer._turnToCacheMode(this.__instanceId);a=0;for(e=c.length;e>
a;a++)c[a].visit(this);cc.renderer._renderingToCacheCanvas(f,this.__instanceId);d.transform();this._cacheDirty=!1}};a.visit=function(a){if(!this._isBaked)return void cc.Node.CanvasRenderCmd.prototype.visit.call(this,a);var c=this._node,d=c._children.length;c._visible&&0!==d&&(this._syncStatus(a),cc.renderer.pushRenderCommand(this),this._bakeSprite.visit(this),this._dirtyFlag=0)};a._bakeForAddChild=function(a){a._parent===this._node&&this._isBaked&&a._renderCmd._setCachedParent(this)};a._getBoundingBoxForBake=
function(){var a=null,c=this._node;if(!c._children||0===c._children.length)return cc.rect(0,0,10,10);for(var d=c.getNodeToWorldTransform(),c=c._children,e=0,f=c.length;f>e;e++){var g=c[e];g&&g._visible&&(a?(g=g._getBoundingBoxToCurrentNode(d))&&(a=cc.rectUnion(a,g)):a=g._getBoundingBoxToCurrentNode(d))}return a}}(),function(){cc.LayerColor.CanvasRenderCmd=function(a){cc.Layer.CanvasRenderCmd.call(this,a);this._needDraw=!0;this._blendFuncStr="source-over";this._bakeRenderCmd=new cc.CustomRenderCmd(this,
this._bakeRendering)};var a=cc.LayerColor.CanvasRenderCmd.prototype=Object.create(cc.Layer.CanvasRenderCmd.prototype);a.constructor=cc.LayerColor.CanvasRenderCmd;a.unbake=function(){cc.Layer.CanvasRenderCmd.prototype.unbake.call(this);this._needDraw=!0};a.rendering=function(a,c,d){a=a||cc._renderContext;var e=a.getContext(),f=this._node,g=this._displayedColor,h=this._displayedOpacity/255,k=f._contentSize.width,f=f._contentSize.height;0!==h&&(a.setCompositeOperation(this._blendFuncStr),a.setGlobalAlpha(h),
a.setFillStyle("rgba("+(0|g.r)+","+(0|g.g)+","+(0|g.b)+", 1)"),a.setTransform(this._worldTransform,c,d),e.fillRect(0,0,k*c,-f*d),cc.g_NumberOfDraws++)};a.updateBlendFunc=function(a){this._blendFuncStr=cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(a)};a._updateSquareVertices=a._updateSquareVerticesWidth=a._updateSquareVerticesHeight=function(){};a._bakeRendering=function(){if(this._cacheDirty){var a;a=this._node;var c=this._bakeSprite,d=a._children,e=d.length;this.transform(this.getParentRenderCmd(),
!0);var f=this._getBoundingBoxForBake();f.width=0|f.width+0.5;f.height=0|f.height+0.5;var g=c.getCacheContext(),h=g.getContext();c.resetCanvasSize(f.width,f.height);g.setOffset(0-f.x,h.canvas.height-f.height+f.y);c.setPosition(f.x,f.y);var k;if(cc.renderer._turnToCacheMode(this.__instanceId),0<e){a.sortAllChildren();for(a=0;e>a&&(k=d[a],0>k._localZOrder);a++)k._renderCmd.visit(this);for(cc.renderer.pushRenderCommand(this);e>a;a++)d[a]._renderCmd.visit(this)}else cc.renderer.pushRenderCommand(this);
cc.renderer._renderingToCacheCanvas(g,this.__instanceId);c.transform();this._cacheDirty=!1}};a.visit=function(a){if(!this._isBaked)return void cc.Node.CanvasRenderCmd.prototype.visit.call(this);this._node._visible&&(this._syncStatus(a),cc.renderer.pushRenderCommand(this._bakeRenderCmd),this._bakeSprite._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty),this._bakeSprite.visit(this),this._dirtyFlag=0)};a._getBoundingBoxForBake=function(){var a=this._node,c=cc.rect(0,0,a._contentSize.width,
a._contentSize.height),d=a.getNodeToWorldTransform();if(c=cc.rectApplyAffineTransform(c,a.getNodeToWorldTransform()),!a._children||0===a._children.length)return c;for(var a=a._children,e=0;e<a.length;e++){var f=a[e];f&&f._visible&&(f=f._getBoundingBoxToCurrentNode(d),c=cc.rectUnion(c,f))}return c}}(),function(){cc.LayerGradient.RenderCmd={updateStatus:function(){var a=cc.Node._dirtyFlags,b=this._dirtyFlag,c=b&a.colorDirty,d=b&a.opacityDirty;c&&this._updateDisplayColor();d&&this._updateDisplayOpacity();
b&a.transformDirty&&this.transform(null,!0);(c||d||b&a.gradientDirty)&&this._updateColor();this._dirtyFlag=0}}}(),function(){cc.LayerGradient.CanvasRenderCmd=function(a){cc.LayerColor.CanvasRenderCmd.call(this,a);this._needDraw=!0;this._startPoint=cc.p(0,0);this._endPoint=cc.p(0,0);this._endStopStr=this._startStopStr=null};var a=cc.LayerGradient.CanvasRenderCmd.prototype=Object.create(cc.LayerColor.CanvasRenderCmd.prototype);cc.inject(cc.LayerGradient.RenderCmd,a);a.constructor=cc.LayerGradient.CanvasRenderCmd;
a.rendering=function(a,c,d){a=a||cc._renderContext;var e=a.getContext(),f=this._node,g=this._displayedOpacity/255;if(0!==g){var h=f._contentSize.width,k=f._contentSize.height;a.setCompositeOperation(this._blendFuncStr);a.setGlobalAlpha(g);g=e.createLinearGradient(this._startPoint.x*c,this._startPoint.y*d,this._endPoint.x*c,this._endPoint.y*d);if(f._colorStops)for(var m=0;m<f._colorStops.length;m++)g.addColorStop(f._colorStops[m].p,this._colorStopsStr[m]);else g.addColorStop(0,this._startStopStr),
g.addColorStop(1,this._endStopStr);a.setFillStyle(g);a.setTransform(this._worldTransform,c,d);e.fillRect(0,0,h*c,-k*d);cc.g_NumberOfDraws++}};a._syncStatus=function(a){var c=cc.Node._dirtyFlags,d=this._dirtyFlag,e=a?a._node:null;e&&e._cascadeColorEnabled&&a._dirtyFlag&c.colorDirty&&(d|=c.colorDirty);e&&e._cascadeOpacityEnabled&&a._dirtyFlag&c.opacityDirty&&(d|=c.opacityDirty);a&&a._dirtyFlag&c.transformDirty&&(d|=c.transformDirty);var e=d&c.colorDirty,f=d&c.opacityDirty;this._dirtyFlag=d;e&&this._syncDisplayColor();
f&&this._syncDisplayOpacity();d&c.transformDirty&&this.transform(a);(e||f||d&c.gradientDirty)&&this._updateColor()};a._updateColor=function(){var a=this._node,c=a._contentSize,d=0.5*c.width,c=0.5*c.height;this._dirtyFlag^=this._dirtyFlag&cc.Node._dirtyFlags.gradientDirty;var e=cc.pAngleSigned(cc.p(0,-1),a._alongVector),e=cc.pRotateByAngle(cc.p(0,-1),cc.p(0,0),e),f=Math.min(Math.abs(1/e.x),Math.abs(1/e.y));this._startPoint.x=d*-e.x*f+d;this._startPoint.y=c*e.y*f-c;this._endPoint.x=d*e.x*f+d;this._endPoint.y=
c*-e.y*f-c;d=this._displayedColor;c=a._endColor;e=a._startOpacity/255;f=a._endOpacity/255;if(this._startStopStr="rgba("+Math.round(d.r)+","+Math.round(d.g)+","+Math.round(d.b)+","+e.toFixed(4)+")",this._endStopStr="rgba("+Math.round(c.r)+","+Math.round(c.g)+","+Math.round(c.b)+","+f.toFixed(4)+")",a._colorStops){this._endOpacity=this._startOpacity=0;this._colorStopsStr=[];for(d=0;d<a._colorStops.length;d++)c=a._colorStops[d].color,e=null==c.a?1:c.a/255,this._colorStopsStr.push("rgba("+Math.round(c.r)+
","+Math.round(c.g)+","+Math.round(c.b)+","+e.toFixed(4)+")")}}}(),cc._tmp.PrototypeSprite=function(){var a=cc.Sprite.prototype;cc.defineGetterSetter(a,"opacityModifyRGB",a.isOpacityModifyRGB,a.setOpacityModifyRGB);cc.defineGetterSetter(a,"opacity",a.getOpacity,a.setOpacity);cc.defineGetterSetter(a,"color",a.getColor,a.setColor);a.dirty;a.flippedX;cc.defineGetterSetter(a,"flippedX",a.isFlippedX,a.setFlippedX);a.flippedY;cc.defineGetterSetter(a,"flippedY",a.isFlippedY,a.setFlippedY);a.offsetX;cc.defineGetterSetter(a,
"offsetX",a._getOffsetX);a.offsetY;cc.defineGetterSetter(a,"offsetY",a._getOffsetY);a.atlasIndex;a.texture;cc.defineGetterSetter(a,"texture",a.getTexture,a.setTexture);a.textureRectRotated;cc.defineGetterSetter(a,"textureRectRotated",a.isTextureRectRotated);a.textureAtlas;a.batchNode;cc.defineGetterSetter(a,"batchNode",a.getBatchNode,a.setBatchNode);a.quad;cc.defineGetterSetter(a,"quad",a.getQuad)},cc.Sprite=cc.Node.extend({dirty:!1,atlasIndex:0,textureAtlas:null,_batchNode:null,_recursiveDirty:null,
_hasChildren: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(a,b,c){cc.Node.prototype.ctor.call(this);this._shouldBeHidden=!1;this._offsetPosition=cc.p(0,0);this._unflippedOffsetPositionFromCenter=cc.p(0,0);this._blendFunc={src:cc.BLEND_SRC,dst:cc.BLEND_DST};this._rect=cc.rect(0,0,0,0);
this._softInit(a,b,c)},textureLoaded:function(){return this._textureLoaded},addLoadedEventListener:function(a,b){this.addEventListener("load",a,b)},isDirty:function(){return this.dirty},setDirty:function(a){this.dirty=a},isTextureRectRotated:function(){return this._rectRotated},getAtlasIndex:function(){return this.atlasIndex},setAtlasIndex:function(a){this.atlasIndex=a},getTextureRect:function(){return cc.rect(this._rect)},getTextureAtlas:function(){return this.textureAtlas},setTextureAtlas:function(a){this.textureAtlas=
a},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(a){cc.assert(a,cc._LogInfos.Sprite_initWithSpriteFrame);a.textureLoaded()||(this._textureLoaded=!1,a.addEventListener("load",this._renderCmd._spriteFrameLoadedCallback,this));var b=cc._renderType===cc._RENDER_TYPE_CANVAS?!1:a._rotated,b=this.initWithTexture(a.getTexture(),
a.getRect(),b);return this.setSpriteFrame(a),b},initWithSpriteFrameName:function(a){cc.assert(a,cc._LogInfos.Sprite_initWithSpriteFrameName);var b=cc.spriteFrameCache.getSpriteFrame(a);return cc.assert(b,a+cc._LogInfos.Sprite_initWithSpriteFrameName1),this.initWithSpriteFrame(b)},useBatchNode:function(a){this.textureAtlas=a.getTextureAtlas();this._batchNode=a},setVertexRect:function(a){var b=this._rect;b.x=a.x;b.y=a.y;b.width=a.width;b.height=a.height},sortAllChildren:function(){if(this._reorderChildDirty){var a,
b,c,d=this._children,e=d.length;for(a=1;e>a;a++){c=d[a];for(b=a-1;0<=b&&(c._localZOrder<d[b]._localZOrder||c._localZOrder===d[b]._localZOrder&&c.arrivalOrder<d[b].arrivalOrder);)d[b+1]=d[b],b--;d[b+1]=c}this._batchNode&&this._arrayMakeObjectsPerformSelector(d,cc.Node._stateCallbackType.sortAllChildren);this._reorderChildDirty=!1}},reorderChild:function(a,b){return cc.assert(a,cc._LogInfos.Sprite_reorderChild_2),-1===this._children.indexOf(a)?void cc.log(cc._LogInfos.Sprite_reorderChild):void(b!==
a.zIndex&&(this._batchNode&&!this._reorderChildDirty&&(this._setReorderChildDirtyRecursively(),this._batchNode.reorderBatch(!0)),cc.Node.prototype.reorderChild.call(this,a,b)))},removeChild:function(a,b){this._batchNode&&this._batchNode.removeSpriteFromAtlas(a);cc.Node.prototype.removeChild.call(this,a,b)},setVisible:function(a){cc.Node.prototype.setVisible.call(this,a);this._renderCmd.setDirtyRecursively(!0)},removeAllChildren:function(a){var b=this._children,c=this._batchNode;if(c&&null!=b)for(var d=
0,e=b.length;e>d;d++)c.removeSpriteFromAtlas(b[d]);cc.Node.prototype.removeAllChildren.call(this,a);this._hasChildren=!1},ignoreAnchorPointForPosition:function(a){return this._batchNode?void cc.log(cc._LogInfos.Sprite_ignoreAnchorPointForPosition):void cc.Node.prototype.ignoreAnchorPointForPosition.call(this,a)},setFlippedX:function(a){this._flippedX!==a&&(this._flippedX=a,this.setTextureRect(this._rect,this._rectRotated,this._contentSize),this.setNodeDirty(!0))},setFlippedY:function(a){this._flippedY!==
a&&(this._flippedY=a,this.setTextureRect(this._rect,this._rectRotated,this._contentSize),this.setNodeDirty(!0))},isFlippedX:function(){return this._flippedX},isFlippedY:function(){return this._flippedY},setOpacityModifyRGB:function(a){this._opacityModifyRGB!==a&&(this._opacityModifyRGB=a,this._renderCmd._setColorDirty())},isOpacityModifyRGB:function(){return this._opacityModifyRGB},setDisplayFrameWithAnimationName:function(a,b){cc.assert(a,cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_3);var c=
cc.animationCache.getAnimation(a);return!c?void cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName):(c=c.getFrames()[b])?void this.setSpriteFrame(c.getSpriteFrame()):void cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_2)},getBatchNode:function(){return this._batchNode},_setReorderChildDirtyRecursively:function(){if(!this._reorderChildDirty){this._reorderChildDirty=!0;for(var a=this._parent;a&&a!==this._batchNode;)a._setReorderChildDirtyRecursively(),a=a.parent}},getTexture:function(){return this._texture},
_softInit:function(a,b,c){if(void 0===a)cc.Sprite.prototype.init.call(this);else if(cc.isString(a))"#"===a[0]?(b=a.substr(1,a.length-1),(b=cc.spriteFrameCache.getSpriteFrame(b))?this.initWithSpriteFrame(b):cc.log("%s does not exist",a)):cc.Sprite.prototype.init.call(this,a,b);else if("object"==typeof a)if(a instanceof cc.Texture2D)this.initWithTexture(a,b,c);else if(a instanceof cc.SpriteFrame)this.initWithSpriteFrame(a);else if(a instanceof HTMLImageElement||a instanceof HTMLCanvasElement)b=new cc.Texture2D,
b.initWithElement(a),b.handleLoadedTexture(),this.initWithTexture(b)},getQuad:function(){return this._renderCmd.getQuad()},setBlendFunc:function(a,b){var c=this._blendFunc;void 0===b?(c.src=a.src,c.dst=a.dst):(c.src=a,c.dst=b);this._renderCmd.updateBlendFunc(c)},init:function(){return 0<arguments.length?this.initWithFile(arguments[0],arguments[1]):(cc.Node.prototype.init.call(this),this.dirty=this._recursiveDirty=!1,this._blendFunc.src=cc.BLEND_SRC,this._blendFunc.dst=cc.BLEND_DST,this.texture=null,
this._flippedX=this._flippedY=!1,this.anchorX=0.5,this.anchorY=0.5,this._offsetPosition.x=0,this._offsetPosition.y=0,this._hasChildren=!1,this._renderCmd._init(),this.setTextureRect(cc.rect(0,0,0,0),!1,cc.size(0,0)),!0)},initWithFile:function(a,b){cc.assert(a,cc._LogInfos.Sprite_initWithFile);var c=cc.textureCache.getTextureForKey(a);if(c){if(!b){var d=c.getContentSize();b=cc.rect(0,0,d.width,d.height)}return this.initWithTexture(c,b)}return c=cc.textureCache.addImage(a),this.initWithTexture(c,b||
cc.rect(0,0,c._contentSize.width,c._contentSize.height))},initWithTexture:function(a,b,c,d){if(cc.assert(0!==arguments.length,cc._LogInfos.CCSpriteBatchNode_initWithTexture),c=c||!1,a=this._renderCmd._handleTextureForRotatedTexture(a,b,c,d),!cc.Node.prototype.init.call(this))return!1;this._batchNode=null;this.dirty=this._recursiveDirty=!1;this._opacityModifyRGB=!0;this._blendFunc.src=cc.BLEND_SRC;this._blendFunc.dst=cc.BLEND_DST;this._flippedX=this._flippedY=!1;this.setAnchorPoint(0.5,0.5);this._offsetPosition.x=
0;this._offsetPosition.y=0;this._hasChildren=!1;this._renderCmd._init();var e=a.isLoaded();return this._textureLoaded=e,e?(b||(b=cc.rect(0,0,a.width,a.height)),this._renderCmd._checkTextureBoundary(a,b,c),this.texture=a,this.setTextureRect(b,c),this.setBatchNode(null),!0):(this._rectRotated=c,b&&(this._rect.x=b.x,this._rect.y=b.y,this._rect.width=b.width,this._rect.height=b.height),this.texture&&this.texture.removeEventListener("load",this),a.addEventListener("load",this._renderCmd._textureLoadedCallback,
this),this.texture=a,!0)},setTextureRect:function(a,b,c,d){this._rectRotated=b||!1;this.setContentSize(c||a);this.setVertexRect(a);this._renderCmd._setTextureCoords(a,d);a=this._unflippedOffsetPositionFromCenter.x;b=this._unflippedOffsetPositionFromCenter.y;this._flippedX&&(a=-a);this._flippedY&&(b=-b);c=this._rect;this._offsetPosition.x=a+(this._contentSize.width-c.width)/2;this._offsetPosition.y=b+(this._contentSize.height-c.height)/2;this._batchNode?this.dirty=!0:this._renderCmd._resetForBatchNode()},
updateTransform:function(){this._renderCmd.updateTransform()},addChild:function(a,b,c){cc.assert(a,cc._LogInfos.CCSpriteBatchNode_addChild_2);null==b&&(b=a._localZOrder);null==c&&(c=a.tag);this._renderCmd._setBatchNodeForAddChild(a)&&(cc.Node.prototype.addChild.call(this,a,b,c),this._hasChildren=!0)},setSpriteFrame:function(a){var b=this;cc.isString(a)&&(a=cc.spriteFrameCache.getSpriteFrame(a),cc.assert(a,cc._LogInfos.Sprite_setSpriteFrame));this.setNodeDirty(!0);var c=a.getOffset();b._unflippedOffsetPositionFromCenter.x=
c.x;b._unflippedOffsetPositionFromCenter.y=c.y;c=a.getTexture();a.textureLoaded()?(c!==b._texture&&(b.texture=c),b.setTextureRect(a.getRect(),a.isRotated(),a.getOriginalSize())):(b._textureLoaded=!1,a.addEventListener("load",function(a){b._textureLoaded=!0;var c=a.getTexture();c!==b._texture&&(b.texture=c);b.setTextureRect(a.getRect(),a.isRotated(),a.getOriginalSize());b.dispatchEvent("load");b.setColor(b.color)},b));this._renderCmd._updateForSetSpriteFrame(c)},setDisplayFrame:function(a){cc.log(cc._LogInfos.Sprite_setDisplayFrame);
this.setSpriteFrame(a)},isFrameDisplayed:function(a){return this._renderCmd.isFrameDisplayed(a)},displayFrame:function(){return this.getSpriteFrame()},getSpriteFrame:function(){return new cc.SpriteFrame(this._texture,cc.rectPointsToPixels(this._rect),this._rectRotated,cc.pointPointsToPixels(this._unflippedOffsetPositionFromCenter),cc.sizePointsToPixels(this._contentSize))},setBatchNode:function(a){(this._batchNode=a)?(this._transformToBatch=cc.affineTransformIdentity(),this.textureAtlas=this._batchNode.getTextureAtlas()):
(this.atlasIndex=cc.Sprite.INDEX_NOT_INITIALIZED,this.textureAtlas=null,this._recursiveDirty=!1,this.dirty=!1,this._renderCmd._resetForBatchNode())},setTexture:function(a){return a?void(cc.isString(a)?(a=cc.textureCache.addImage(a),a._textureLoaded?(this._clearRect(),this._renderCmd._setTexture(a),this._changeRectWithTexture(a.getContentSize()),this.setColor(this._realColor),this._textureLoaded=!0):a.addEventListener("load",function(){this._clearRect();this._renderCmd._setTexture(a);this._changeRectWithTexture(a.getContentSize());
this.setColor(this._realColor);this._textureLoaded=!0},this)):(cc.assert(a instanceof cc.Texture2D,cc._LogInfos.Sprite_setTexture_2),this._clearRect(),this._changeRectWithTexture(a.getContentSize()),this._renderCmd._setTexture(a))):this._renderCmd._setTexture(null)},_clearRect:function(){var a=this._texture;if(a){var a=a._contentSize,b=this._rect;a.width===b.width&&a.height===b.height&&(b.width=b.height=0)}},_changeRectWithTexture:function(a){if(a&&(a.width||a.height)){var b=this.getTextureRect();
b.height||b.width||(a.x=a.x||0,a.y=a.y||0,a.width=a.width||0,a.height=a.height||0,this.setTextureRect(a))}},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.Sprite.CanvasRenderCmd(this):new cc.Sprite.WebGLRenderCmd(this)}}),cc.Sprite.create=function(a,b,c){return new cc.Sprite(a,b,c)},cc.Sprite.createWithTexture=cc.Sprite.create,cc.Sprite.createWithSpriteFrameName=cc.Sprite.create,cc.Sprite.createWithSpriteFrame=cc.Sprite.create,cc.Sprite.INDEX_NOT_INITIALIZED=-1,
cc.EventHelper.prototype.apply(cc.Sprite.prototype),cc.assert(cc.isFunction(cc._tmp.PrototypeSprite),cc._LogInfos.MissingFile,"SpritesPropertyDefine.js"),cc._tmp.PrototypeSprite(),delete cc._tmp.PrototypeSprite,function(){cc.Sprite.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);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._originalTexture=null};var a=cc.Sprite.CanvasRenderCmd.prototype=
Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.Sprite.CanvasRenderCmd;a._init=function(){};a.setDirtyRecursively=function(a){};a._resetForBatchNode=function(){};a._setTexture=function(a){var c=this._node;c._texture!==a&&(a?(a.getHtmlElementObj()instanceof HTMLImageElement&&(this._originalTexture=a),c._textureLoaded=a._textureLoaded):c._textureLoaded=!1,c._texture=a)};a._setColorDirty=function(){this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty|cc.Node._dirtyFlags.opacityDirty)};
a.isFrameDisplayed=function(a){var c=this._node;return a.getTexture()!==c._texture?!1:cc.rectEqualToRect(a.getRect(),c._rect)};a.updateBlendFunc=function(a){this._blendFuncStr=cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(a)};a._setBatchNodeForAddChild=function(a){return!0};a._handleTextureForRotatedTexture=function(a,c,d,e){d&&a.isLoaded()&&(a=a.getHtmlElementObj(),a=cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(a,c,e),e=new cc.Texture2D,e.initWithElement(a),e.handleLoadedTexture(),
a=e,c.x=c.y=0,this._node._rect=cc.rect(0,0,c.width,c.height));return a};a._checkTextureBoundary=function(a,c,d){a&&a.url&&(d=c.y+c.height,c.x+c.width>a.width&&cc.error(cc._LogInfos.RectWidth,a.url),d>a.height&&cc.error(cc._LogInfos.RectHeight,a.url));this._node._originalTexture=a};a.rendering=function(a,c,d){var e=this._node,f=this._textureCoord,g=this._displayedOpacity/255;if((!e._texture||0!==f.width&&0!==f.height&&e._texture._textureLoaded)&&0!==g){a=a||cc._renderContext;var h=a.getContext(),k=
e._offsetPosition.x,m=e._rect.height,n=e._rect.width,p=-e._offsetPosition.y-m;(a.setTransform(this._worldTransform,c,d),a.setCompositeOperation(this._blendFuncStr),a.setGlobalAlpha(g),(e._flippedX||e._flippedY)&&a.save(),e._flippedX&&(k=-k-n,h.scale(-1,1)),e._flippedY&&(p=e._offsetPosition.y,h.scale(1,-1)),e._texture)?(g=e._texture._htmlElementObj,""!==e._texture._pattern?(a.setFillStyle(h.createPattern(g,e._texture._pattern)),h.fillRect(k*c,p*d,n*c,m*d)):this._colorized?h.drawImage(g,0,0,f.width,
f.height,k*c,p*d,n*c,m*d):h.drawImage(g,f.renderX,f.renderY,f.width,f.height,k*c,p*d,n*c,m*d)):(g=e._contentSize,f.validRect&&(f=this._displayedColor,a.setFillStyle("rgba("+f.r+","+f.g+","+f.b+",1)"),h.fillRect(k*c,p*d,g.width*c,g.height*d)));(e._flippedX||e._flippedY)&&a.restore();cc.g_NumberOfDraws++}};cc.sys._supportCanvasNewBlendModes?a._updateColor=function(){var a=this._node,c=this._displayedColor;if(255===c.r&&255===c.g&&255===c.b)return void(this._colorized&&(this._colorized=!1,a.texture=
this._originalTexture));var d,e=a._texture,f=this._textureCoord;if(e&&(f.validRect&&this._originalTexture)&&!(d=e.getHtmlElementObj(),!d))this._colorized=!0,d instanceof HTMLCanvasElement&&!this._rectRotated&&!this._newTextureWhenChangeColor&&this._originalTexture._htmlElementObj!==d?cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj,c,f,d):(d=cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj,c,f),e=new cc.Texture2D,
e.initWithElement(d),e.handleLoadedTexture(),a.texture=e)}:a._updateColor=function(){var a=this._node,c=this._displayedColor;if(255===c.r&&255===c.g&&255===c.b)return void(this._colorized&&(this._colorized=!1,a.texture=this._originalTexture));var d,e=a._texture,f=this._textureCoord;if(e&&(f.validRect&&this._originalTexture)&&!(d=e.getHtmlElementObj(),!d)){var g=cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj());g&&(this._colorized=!0,d instanceof HTMLCanvasElement&&!this._rectRotated&&
!this._newTextureWhenChangeColor?cc.Sprite.CanvasRenderCmd._generateTintImage(d,g,c,f,d):(d=cc.Sprite.CanvasRenderCmd._generateTintImage(d,g,c,f),e=new cc.Texture2D,e.initWithElement(d),e.handleLoadedTexture(),a.texture=e))}};a.getQuad=function(){return null};a._updateForSetSpriteFrame=function(a,c){var d=this._node;if(d._rectRotated&&(d._originalTexture=a),this._colorized=!1,this._textureCoord.renderX=this._textureCoord.x,this._textureCoord.renderY=this._textureCoord.y,c)d=d.getColor(),(255!==d.r||
255!==d.g||255!==d.b)&&this._updateColor()};a.updateTransform=function(){var a=this._node;if(a.dirty){var c=a._parent;!a._visible||c&&c!==a._batchNode&&c._shouldBeHidden?a._shouldBeHidden=!0:(a._shouldBeHidden=!1,c&&c!==a._batchNode?a._transformToBatch=cc.affineTransformConcat(this.getNodeToParentTransform(),c._transformToBatch):a._transformToBatch=this.getNodeToParentTransform());a._recursiveDirty=!1;a.dirty=!1}a._hasChildren&&a._arrayMakeObjectsPerformSelector(a._children,cc.Node._stateCallbackType.updateTransform)};
a._updateDisplayColor=function(a){cc.Node.CanvasRenderCmd.prototype._updateDisplayColor.call(this,a)};a._spriteFrameLoadedCallback=function(a){this.setTextureRect(a.getRect(),a.isRotated(),a.getOriginalSize());this._renderCmd._updateColor();this.dispatchEvent("load")};a._textureLoadedCallback=function(a){if(!this._textureLoaded){this._textureLoaded=!0;var c=this._rect,d=this._renderCmd;c?cc._rectEqualToZero(c)&&(c.width=a.width,c.height=a.height):c=cc.rect(0,0,a.width,a.height);this.texture=d._originalTexture=
a;this.setTextureRect(c,this._rectRotated);a=d._displayedColor;(255!==a.r||255!==a.g||255!==a.b)&&d._updateColor();this.setBatchNode(this._batchNode);this.dispatchEvent("load")}};a._setTextureCoords=function(a,c){void 0===c&&(c=!0);var d=this._textureCoord,e=c?cc.contentScaleFactor():1;d.renderX=d.x=0|a.x*e;d.renderY=d.y=0|a.y*e;d.width=0|a.width*e;d.height=0|a.height*e;d.validRect=!(0===d.width||0===d.height||0>d.x||0>d.y);this._colorized&&(this._node._texture=this._originalTexture,this._colorized=
!1)};cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply=function(a,c,d,e){e=e||cc.newElement("canvas");d=d||cc.rect(0,0,a.width,a.height);var f=e.getContext("2d");return e.width!==d.width||e.height!==d.height?(e.width=d.width,e.height=d.height):f.globalCompositeOperation="source-over",f.fillStyle="rgb("+(0|c.r)+","+(0|c.g)+","+(0|c.b)+")",f.fillRect(0,0,d.width,d.height),f.globalCompositeOperation="multiply",f.drawImage(a,d.x,d.y,d.width,d.height,0,0,d.width,d.height),f.globalCompositeOperation=
"destination-atop",f.drawImage(a,d.x,d.y,d.width,d.height,0,0,d.width,d.height),e};cc.Sprite.CanvasRenderCmd._generateTintImage=function(a,c,d,e,f){e||(e=cc.rect(0,0,a.width,a.height));var g;a=d.r/255;var h=d.g/255;d=d.b/255;var k=Math.min(e.width,c[0].width),m=Math.min(e.height,c[0].height);f?(g=f.getContext("2d"),g.clearRect(0,0,k,m)):(f=cc.newElement("canvas"),f.width=k,f.height=m,g=f.getContext("2d"));g.save();g.globalCompositeOperation="lighter";var n=g.globalAlpha;return 0<a&&(g.globalAlpha=
a*n,g.drawImage(c[0],e.x,e.y,k,m,0,0,k,m)),0<h&&(g.globalAlpha=h*n,g.drawImage(c[1],e.x,e.y,k,m,0,0,k,m)),0<d&&(g.globalAlpha=d*n,g.drawImage(c[2],e.x,e.y,k,m,0,0,k,m)),1>a+h+d&&(g.globalAlpha=n,g.drawImage(c[3],e.x,e.y,k,m,0,0,k,m)),g.restore(),f};cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor=function(a){function c(){var c=cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor,e=a.width,h=a.height;d[0].width=e;d[0].height=h;d[1].width=e;d[1].height=h;d[2].width=e;d[2].height=h;d[3].width=
e;d[3].height=h;c.canvas.width=e;c.canvas.height=h;var k=c.canvas.getContext("2d");k.drawImage(a,0,0);c.tempCanvas.width=e;c.tempCanvas.height=h;for(var k=k.getImageData(0,0,e,h).data,m=0;4>m;m++){var n=d[m].getContext("2d");n.getImageData(0,0,e,h).data;c.tempCtx.drawImage(a,0,0);for(var p=c.tempCtx.getImageData(0,0,e,h),r=p.data,s=0;s<k.length;s+=4)r[s]=0===m?k[s]:0,r[s+1]=1===m?k[s+1]:0,r[s+2]=2===m?k[s+2]:0,r[s+3]=k[s+3];n.putImageData(p,0,0)}a.onload=null}if(a.channelCache)return a.channelCache;
var d=[cc.newElement("canvas"),cc.newElement("canvas"),cc.newElement("canvas"),cc.newElement("canvas")];try{c()}catch(e){a.onload=c}return a.channelCache=d,d};cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.canvas=cc.newElement("canvas");cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCanvas=cc.newElement("canvas");cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCtx=cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCanvas.getContext("2d");cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas=
function(a,c,d){if(!a)return null;if(!c)return a;d=null==d?!0:d;var e=cc.newElement("canvas");e.width=c.width;e.height=c.height;var f=e.getContext("2d");return f.translate(e.width/2,e.height/2),f.rotate(d?-1.5707963267948966:1.5707963267948966),f.drawImage(a,c.x,c.y,c.height,c.width,-c.height/2,-c.width/2,c.height,c.width),e}}(),cc.BakeSprite=cc.Sprite.extend({_cacheCanvas:null,_cacheContext:null,ctor:function(){cc.Sprite.prototype.ctor.call(this);var a=document.createElement("canvas");a.width=a.height=
10;this._cacheCanvas=a;this._cacheContext=new cc.CanvasContextWrapper(a.getContext("2d"));var b=new cc.Texture2D;b.initWithElement(a);b.handleLoadedTexture();this.setTexture(b)},getCacheContext:function(){return this._cacheContext},getCacheCanvas:function(){return this._cacheCanvas},resetCanvasSize:function(a,b){void 0===b&&(b=a.height,a=a.width);var c=this._cacheCanvas;c.width=a;c.height=b;this.getTexture().handleLoadedTexture();this.setTextureRect(cc.rect(0,0,a,b),!1)}}),cc.AnimationFrame=cc.Class.extend({_spriteFrame:null,
_delayPerUnit:0,_userInfo:null,ctor:function(a,b,c){this._spriteFrame=a||null;this._delayPerUnit=b||0;this._userInfo=c||null},clone:function(){var a=new cc.AnimationFrame;return a.initWithSpriteFrame(this._spriteFrame.clone(),this._delayPerUnit,this._userInfo),a},copyWithZone:function(a){return cc.clone(this)},copy:function(a){a=new cc.AnimationFrame;return a.initWithSpriteFrame(this._spriteFrame.clone(),this._delayPerUnit,this._userInfo),a},initWithSpriteFrame:function(a,b,c){return this._spriteFrame=
a,this._delayPerUnit=b,this._userInfo=c,!0},getSpriteFrame:function(){return this._spriteFrame},setSpriteFrame:function(a){this._spriteFrame=a},getDelayUnits:function(){return this._delayPerUnit},setDelayUnits:function(a){this._delayPerUnit=a},getUserInfo:function(){return this._userInfo},setUserInfo:function(a){this._userInfo=a}}),cc.AnimationFrame.create=function(a,b,c){return new cc.AnimationFrame(a,b,c)},cc.Animation=cc.Class.extend({_frames:null,_loops:0,_restoreOriginalFrame:!1,_duration:0,
_delayPerUnit:0,_totalDelayUnits:0,ctor:function(a,b,c){if(this._frames=[],void 0===a)this.initWithSpriteFrames(null,0);else{var d=a[0];d&&(d instanceof cc.SpriteFrame?this.initWithSpriteFrames(a,b,c):d instanceof cc.AnimationFrame&&this.initWithAnimationFrames(a,b,c))}},getFrames:function(){return this._frames},setFrames:function(a){this._frames=a},addSpriteFrame:function(a){var b=new cc.AnimationFrame;b.initWithSpriteFrame(a,1,null);this._frames.push(b);this._totalDelayUnits++},addSpriteFrameWithFile:function(a){a=
cc.textureCache.addImage(a);var b=cc.rect(0,0,0,0);b.width=a.width;b.height=a.height;a=new cc.SpriteFrame(a,b);this.addSpriteFrame(a)},addSpriteFrameWithTexture:function(a,b){var c=new cc.SpriteFrame(a,b);this.addSpriteFrame(c)},initWithAnimationFrames:function(a,b,c){cc.arrayVerifyType(a,cc.AnimationFrame);this._delayPerUnit=b;this._loops=void 0===c?1:c;this._totalDelayUnits=0;b=this._frames;for(c=b.length=0;c<a.length;c++){var d=a[c];b.push(d);this._totalDelayUnits+=d.getDelayUnits()}return!0},
clone:function(){var a=new cc.Animation;return a.initWithAnimationFrames(this._copyFrames(),this._delayPerUnit,this._loops),a.setRestoreOriginalFrame(this._restoreOriginalFrame),a},copyWithZone:function(a){a=new cc.Animation;return a.initWithAnimationFrames(this._copyFrames(),this._delayPerUnit,this._loops),a.setRestoreOriginalFrame(this._restoreOriginalFrame),a},_copyFrames:function(){for(var a=[],b=0;b<this._frames.length;b++)a.push(this._frames[b].clone());return a},copy:function(a){return this.copyWithZone(null)},
getLoops:function(){return this._loops},setLoops:function(a){this._loops=a},setRestoreOriginalFrame:function(a){this._restoreOriginalFrame=a},getRestoreOriginalFrame:function(){return this._restoreOriginalFrame},getDuration:function(){return this._totalDelayUnits*this._delayPerUnit},getDelayPerUnit:function(){return this._delayPerUnit},setDelayPerUnit:function(a){this._delayPerUnit=a},getTotalDelayUnits:function(){return this._totalDelayUnits},initWithSpriteFrames:function(a,b,c){cc.arrayVerifyType(a,
cc.SpriteFrame);this._loops=void 0===c?1:c;this._delayPerUnit=b||0;this._totalDelayUnits=0;b=this._frames;if(b.length=0,a){for(c=0;c<a.length;c++){var d=a[c],e=new cc.AnimationFrame;e.initWithSpriteFrame(d,1,null);b.push(e)}this._totalDelayUnits+=a.length}return!0},retain:function(){},release:function(){}}),cc.Animation.create=function(a,b,c){return new cc.Animation(a,b,c)},cc.Animation.createWithAnimationFrames=cc.Animation.create,cc.animationCache={_animations:{},addAnimation:function(a,b){this._animations[b]=
a},removeAnimation:function(a){a&&this._animations[a]&&delete this._animations[a]},getAnimation:function(a){return this._animations[a]?this._animations[a]:null},_addAnimationsWithDictionary:function(a,b){var c=a.animations;if(!c)return void cc.log(cc._LogInfos.animationCache__addAnimationsWithDictionary);var d=1,e=a.properties;if(e)for(var d=null!=e.format?parseInt(e.format):d,e=e.spritesheets,f=cc.spriteFrameCache,g=cc.path,h=0;h<e.length;h++)f.addSpriteFrames(g.changeBasename(b,e[h]));switch(d){case 1:this._parseVersion1(c);
break;case 2:this._parseVersion2(c);break;default:cc.log(cc._LogInfos.animationCache__addAnimationsWithDictionary_2)}},addAnimations:function(a){cc.assert(a,cc._LogInfos.animationCache_addAnimations_2);var b=cc.loader.getRes(a);return b?void this._addAnimationsWithDictionary(b,a):void cc.log(cc._LogInfos.animationCache_addAnimations)},_parseVersion1:function(a){var b=cc.spriteFrameCache,c;for(c in a){var d=a[c],e=d.frames,d=parseFloat(d.delay)||0,f=null;if(e){for(var g=[],h=0;h<e.length;h++){var k=
b.getSpriteFrame(e[h]);if(k){var m=new cc.AnimationFrame;m.initWithSpriteFrame(k,1,null);g.push(m)}else cc.log(cc._LogInfos.animationCache__parseVersion1_2,c,e[h])}0!==g.length?(g.length!==e.length&&cc.log(cc._LogInfos.animationCache__parseVersion1_4,c),f=new cc.Animation(g,d,1),cc.animationCache.addAnimation(f,c)):cc.log(cc._LogInfos.animationCache__parseVersion1_3,c)}else cc.log(cc._LogInfos.animationCache__parseVersion1,c)}},_parseVersion2:function(a){var b=cc.spriteFrameCache,c;for(c in a){var d=
a[c],e=d.loop,f=parseInt(d.loops),e=e?cc.REPEAT_FOREVER:isNaN(f)?1:f,f=d.restoreOriginalFrame&&1==d.restoreOriginalFrame?!0:!1,g=d.frames;if(g){for(var h=[],k=0;k<g.length;k++){var m=g[k],n=m.spriteframe,p=b.getSpriteFrame(n);if(p){var n=parseFloat(m.delayUnits)||0,m=m.notification,r=new cc.AnimationFrame;r.initWithSpriteFrame(p,n,m);h.push(r)}else cc.log(cc._LogInfos.animationCache__parseVersion2_2,c,n)}d=parseFloat(d.delayPerUnit)||0;g=new cc.Animation;g.initWithAnimationFrames(h,d,e);g.setRestoreOriginalFrame(f);
cc.animationCache.addAnimation(g,c)}else cc.log(cc._LogInfos.animationCache__parseVersion2,c)}},_clear:function(){this._animations={}}},cc.SpriteFrame=cc.Class.extend({_offset:null,_originalSize:null,_rectInPixels:null,_rotated:!1,_rect:null,_offsetInPixels:null,_originalSizeInPixels:null,_texture:null,_textureFilename:"",_textureLoaded:!1,ctor:function(a,b,c,d,e){this._offset=cc.p(0,0);this._offsetInPixels=cc.p(0,0);this._originalSize=cc.size(0,0);this._rotated=!1;this._originalSizeInPixels=cc.size(0,
0);this._textureFilename="";this._texture=null;this._textureLoaded=!1;void 0!==a&&void 0!==b&&(void 0===c||void 0===d||void 0===e?this.initWithTexture(a,b):this.initWithTexture(a,b,c,d,e))},textureLoaded:function(){return this._textureLoaded},addLoadedEventListener:function(a,b){this.addEventListener("load",a,b)},getRectInPixels:function(){var a=this._rectInPixels;return cc.rect(a.x,a.y,a.width,a.height)},setRectInPixels:function(a){this._rectInPixels||(this._rectInPixels=cc.rect(0,0,0,0));this._rectInPixels.x=
a.x;this._rectInPixels.y=a.y;this._rectInPixels.width=a.width;this._rectInPixels.height=a.height;this._rect=cc.rectPixelsToPoints(a)},isRotated:function(){return this._rotated},setRotated:function(a){this._rotated=a},getRect:function(){var a=this._rect;return cc.rect(a.x,a.y,a.width,a.height)},setRect:function(a){this._rect||(this._rect=cc.rect(0,0,0,0));this._rect.x=a.x;this._rect.y=a.y;this._rect.width=a.width;this._rect.height=a.height;this._rectInPixels=cc.rectPointsToPixels(this._rect)},getOffsetInPixels:function(){return cc.p(this._offsetInPixels)},
setOffsetInPixels:function(a){this._offsetInPixels.x=a.x;this._offsetInPixels.y=a.y;cc._pointPixelsToPointsOut(this._offsetInPixels,this._offset)},getOriginalSizeInPixels:function(){return cc.size(this._originalSizeInPixels)},setOriginalSizeInPixels:function(a){this._originalSizeInPixels.width=a.width;this._originalSizeInPixels.height=a.height},getOriginalSize:function(){return cc.size(this._originalSize)},setOriginalSize:function(a){this._originalSize.width=a.width;this._originalSize.height=a.height},
getTexture:function(){if(this._texture)return this._texture;if(""!==this._textureFilename){var a=cc.textureCache.addImage(this._textureFilename);return a&&(this._textureLoaded=a.isLoaded()),a}return null},setTexture:function(a){if(this._texture!==a){var b=a.isLoaded();this._textureLoaded=b;this._texture=a;b||a.addEventListener("load",function(a){if(this._textureLoaded=!0,this._rotated&&cc._renderType===cc._RENDER_TYPE_CANVAS){var b=a.getHtmlElementObj(),b=cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(b,
this.getRect()),e=new cc.Texture2D;e.initWithElement(b);e.handleLoadedTexture();this.setTexture(e);b=this.getRect();this.setRect(cc.rect(0,0,b.width,b.height))}b=this._rect;0===b.width&&0===b.height&&(b=a.width,a=a.height,this._rect.width=b,this._rect.height=a,this._rectInPixels=cc.rectPointsToPixels(this._rect),this._originalSizeInPixels.width=this._rectInPixels.width,this._originalSizeInPixels.height=this._rectInPixels.height,this._originalSize.width=b,this._originalSize.height=a);this.dispatchEvent("load")},
this)}},getOffset:function(){return cc.p(this._offset)},setOffset:function(a){this._offset.x=a.x;this._offset.y=a.y},clone:function(){var a=new cc.SpriteFrame;return a.initWithTexture(this._textureFilename,this._rectInPixels,this._rotated,this._offsetInPixels,this._originalSizeInPixels),a.setTexture(this._texture),a},copyWithZone:function(){var a=new cc.SpriteFrame;return a.initWithTexture(this._textureFilename,this._rectInPixels,this._rotated,this._offsetInPixels,this._originalSizeInPixels),a.setTexture(this._texture),
a},copy:function(){return this.copyWithZone()},initWithTexture:function(a,b,c,d,e){if(2===arguments.length&&(b=cc.rectPointsToPixels(b)),d=d||cc.p(0,0),e=e||b,c=c||!1,cc.isString(a)?(this._texture=null,this._textureFilename=a):a instanceof cc.Texture2D&&this.setTexture(a),a=this.getTexture(),this._rectInPixels=b,b=this._rect=cc.rectPixelsToPoints(b),a&&a.url&&a.isLoaded()){var f,g;c?(f=b.x+b.height,g=b.y+b.width):(f=b.x+b.width,g=b.y+b.height);f>a.getPixelsWide()&&cc.error(cc._LogInfos.RectWidth,
a.url);g>a.getPixelsHigh()&&cc.error(cc._LogInfos.RectHeight,a.url)}return this._offsetInPixels.x=d.x,this._offsetInPixels.y=d.y,cc._pointPixelsToPointsOut(d,this._offset),this._originalSizeInPixels.width=e.width,this._originalSizeInPixels.height=e.height,cc._sizePixelsToPointsOut(e,this._originalSize),this._rotated=c,!0}}),cc.EventHelper.prototype.apply(cc.SpriteFrame.prototype),cc.SpriteFrame.create=function(a,b,c,d,e){return new cc.SpriteFrame(a,b,c,d,e)},cc.SpriteFrame.createWithTexture=cc.SpriteFrame.create,
cc.SpriteFrame._frameWithTextureForCanvas=function(a,b,c,d,e){var f=new cc.SpriteFrame;return f._texture=a,f._rectInPixels=b,f._rect=cc.rectPixelsToPoints(b),f._offsetInPixels.x=d.x,f._offsetInPixels.y=d.y,cc._pointPixelsToPointsOut(f._offsetInPixels,f._offset),f._originalSizeInPixels.width=e.width,f._originalSizeInPixels.height=e.height,cc._sizePixelsToPointsOut(f._originalSizeInPixels,f._originalSize),f._rotated=c,f},cc.spriteFrameCache={_CCNS_REG1:/^\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*$/,
_CCNS_REG2:/^\s*\{\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*,\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*\}\s*$/,_spriteFrames:{},_spriteFramesAliases:{},_frameConfigCache:{},_rectFromString:function(a){return(a=this._CCNS_REG2.exec(a))?cc.rect(parseFloat(a[1]),parseFloat(a[2]),parseFloat(a[3]),parseFloat(a[4])):cc.rect(0,0,0,0)},_pointFromString:function(a){return(a=this._CCNS_REG1.exec(a))?cc.p(parseFloat(a[1]),parseFloat(a[2])):cc.p(0,0)},_sizeFromString:function(a){return(a=
this._CCNS_REG1.exec(a))?cc.size(parseFloat(a[1]),parseFloat(a[2])):cc.size(0,0)},_getFrameConfig:function(a){var b=cc.loader.getRes(a);return cc.assert(b,cc._LogInfos.spriteFrameCache__getFrameConfig_2,a),cc.loader.release(a),b._inited?(this._frameConfigCache[a]=b,b):(this._frameConfigCache[a]=this._parseFrameConfig(b),this._frameConfigCache[a])},_getFrameConfigByJsonObject:function(a,b){return cc.assert(b,cc._LogInfos.spriteFrameCache__getFrameConfig_2,a),this._frameConfigCache[a]=this._parseFrameConfig(b),
this._frameConfigCache[a]},_parseFrameConfig:function(a){var b=a.frames,c=a.metadata||a.meta;a={};var d={},e=0;c&&(e=c.format,e=1>=e.length?parseInt(e):e,d.image=c.textureFileName||c.textureFileName||c.image);for(var f in b){var g=b[f];if(g){c={};if(0==e){c.rect=cc.rect(g.x,g.y,g.width,g.height);c.rotated=!1;c.offset=cc.p(g.offsetX,g.offsetY);var h=g.originalWidth,g=g.originalHeight;h&&g||cc.log(cc._LogInfos.spriteFrameCache__getFrameConfig);h=Math.abs(h);g=Math.abs(g);c.size=cc.size(h,g)}else if(1==
e||2==e)c.rect=this._rectFromString(g.frame),c.rotated=g.rotated||!1,c.offset=this._pointFromString(g.offset),c.size=this._sizeFromString(g.sourceSize);else if(3==e){var h=this._sizeFromString(g.spriteSize),k=this._rectFromString(g.textureRect);h&&(k=cc.rect(k.x,k.y,h.width,h.height));c.rect=k;c.rotated=g.textureRotated||!1;c.offset=this._pointFromString(g.spriteOffset);c.size=this._sizeFromString(g.spriteSourceSize);c.aliases=g.aliases}else h=g.frame,k=g.sourceSize,f=g.filename||f,c.rect=cc.rect(h.x,
h.y,h.w,h.h),c.rotated=g.rotated||!1,c.offset=cc.p(0,0),c.size=cc.size(k.w,k.h);a[f]=c}}return{_inited:!0,frames:a,meta:d}},_addSpriteFramesByObject:function(a,b,c){if(cc.assert(a,cc._LogInfos.spriteFrameCache_addSpriteFrames_2),b&&b.frames)b=this._frameConfigCache[a]||this._getFrameConfigByJsonObject(a,b),this._createSpriteFrames(a,b,c)},_createSpriteFrames:function(a,b,c){var d=b.frames;b=b.meta;c?c instanceof cc.Texture2D||(cc.isString(c)?c=cc.textureCache.addImage(c):cc.assert(0,cc._LogInfos.spriteFrameCache_addSpriteFrames_3)):
(c=cc.path.changeBasename(a,b.image||".png"),c=cc.textureCache.addImage(c));a=this._spriteFramesAliases;b=this._spriteFrames;for(var e in d){var f=d[e],g=b[e];if(!g){g=new cc.SpriteFrame(c,f.rect,f.rotated,f.offset,f.size);if(f=f.aliases)for(var h=0,k=f.length;k>h;h++){var m=f[h];a[m]&&cc.log(cc._LogInfos.spriteFrameCache_addSpriteFrames,m);a[m]=e}cc._renderType===cc._RENDER_TYPE_CANVAS&&g.isRotated()&&g.getTexture().isLoaded()&&(f=g.getTexture().getHtmlElementObj(),f=cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(f,
g.getRectInPixels()),h=new cc.Texture2D,h.initWithElement(f),h.handleLoadedTexture(),g.setTexture(h),f=g._rect,g.setRect(cc.rect(0,0,f.width,f.height)));b[e]=g}}},addSpriteFrames:function(a,b){cc.assert(a,cc._LogInfos.spriteFrameCache_addSpriteFrames_2);var c=this._frameConfigCache[a]||cc.loader.getRes(a);c&&c.frames&&(c=this._frameConfigCache[a]||this._getFrameConfig(a),this._createSpriteFrames(a,c,b))},_checkConflict:function(a){a=a.frames;for(var b in a)this._spriteFrames[b]&&cc.log(cc._LogInfos.spriteFrameCache__checkConflict,
b)},addSpriteFrame:function(a,b){this._spriteFrames[b]=a},removeSpriteFrames:function(){this._spriteFrames={};this._spriteFramesAliases={}},removeSpriteFrameByName:function(a){a&&(this._spriteFramesAliases[a]&&delete this._spriteFramesAliases[a],this._spriteFrames[a]&&delete this._spriteFrames[a])},removeSpriteFramesFromFile:function(a){var b=this._spriteFrames,c=this._spriteFramesAliases;if(a=this._frameConfigCache[a]){a=a.frames;for(var d in a)if(b[d]){delete b[d];for(var e in c)c[e]===d&&delete c[e]}}},
removeSpriteFramesFromTexture:function(a){var b=this._spriteFrames,c=this._spriteFramesAliases,d;for(d in b){var e=b[d];if(e&&e.getTexture()===a){delete b[d];for(var f in c)c[f]===d&&delete c[f]}}},getSpriteFrame:function(a){var b=this._spriteFrames[a];if(!b){var c=this._spriteFramesAliases[a];c&&(b=this._spriteFrames[c.toString()],b||delete this._spriteFramesAliases[a])}return b},_clear:function(){this._spriteFrames={};this._spriteFramesAliases={};this._frameConfigCache={}}},cc.g_NumberOfDraws=0,
cc.GLToClipTransform=function(a){cc.kmGLGetMatrix(cc.KM_GL_PROJECTION,a);var b=new cc.math.Matrix4;cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW,b);a.multiply(b)},cc.Director=cc.Class.extend({_landscape:!1,_nextDeltaTimeZero:!1,_paused:!1,_purgeDirectorInNextLoop:!1,_sendCleanupToScene:!1,_animationInterval:0,_oldAnimationInterval:0,_projection:0,_accumDt:0,_contentScaleFactor:1,_displayStats:!1,_deltaTime:0,_frameRate:0,_FPSLabel:null,_SPFLabel:null,_drawsLabel:null,_winSizeInPoints:null,_lastUpdate:null,
_nextScene:null,_notificationNode:null,_openGLView:null,_scenesStack:null,_projectionDelegate:null,_runningScene:null,_frames:0,_totalFrames:0,_secondsPerFrame:0,_dirtyRegion:null,_scheduler:null,_actionManager:null,_eventProjectionChanged:null,_eventAfterDraw:null,_eventAfterVisit:null,_eventAfterUpdate:null,ctor:function(){var a=this;a._lastUpdate=Date.now();cc.eventManager.addCustomListener(cc.game.EVENT_SHOW,function(){a._lastUpdate=Date.now()})},init:function(){return this._oldAnimationInterval=
this._animationInterval=1/cc.defaultFPS,this._scenesStack=[],this._projection=cc.Director.PROJECTION_DEFAULT,this._projectionDelegate=null,this._accumDt=0,this._frameRate=0,this._displayStats=!1,this._totalFrames=this._frames=0,this._lastUpdate=Date.now(),this._paused=!1,this._purgeDirectorInNextLoop=!1,this._winSizeInPoints=cc.size(0,0),this._openGLView=null,this._contentScaleFactor=1,this._scheduler=new cc.Scheduler,cc.ActionManager?(this._actionManager=new cc.ActionManager,this._scheduler.scheduleUpdate(this._actionManager,
cc.Scheduler.PRIORITY_SYSTEM,!1)):this._actionManager=null,this._eventAfterDraw=new cc.EventCustom(cc.Director.EVENT_AFTER_DRAW),this._eventAfterDraw.setUserData(this),this._eventAfterVisit=new cc.EventCustom(cc.Director.EVENT_AFTER_VISIT),this._eventAfterVisit.setUserData(this),this._eventAfterUpdate=new cc.EventCustom(cc.Director.EVENT_AFTER_UPDATE),this._eventAfterUpdate.setUserData(this),this._eventProjectionChanged=new cc.EventCustom(cc.Director.EVENT_PROJECTION_CHANGED),this._eventProjectionChanged.setUserData(this),
!0},calculateDeltaTime:function(){var a=Date.now();this._nextDeltaTimeZero?(this._deltaTime=0,this._nextDeltaTimeZero=!1):this._deltaTime=(a-this._lastUpdate)/1E3;0<cc.game.config[cc.game.CONFIG_KEY.debugMode]&&0.2<this._deltaTime&&(this._deltaTime=1/60);this._lastUpdate=a},convertToGL:null,convertToUI:null,drawScene:function(){var a=cc.renderer;this.calculateDeltaTime();this._paused||(this._scheduler.update(this._deltaTime),cc.eventManager.dispatchEvent(this._eventAfterUpdate));this._clear();this._nextScene&&
this.setNextScene();this._beforeVisitScene&&this._beforeVisitScene();this._runningScene&&(!0===a.childrenOrderDirty?(cc.renderer.clearRenderCommands(),this._runningScene._renderCmd._curLevel=0,this._runningScene.visit(),a.resetFlag()):!0===a.transformDirty()&&a.transform(),cc.eventManager.dispatchEvent(this._eventAfterVisit));this._notificationNode&&this._notificationNode.visit();this._displayStats&&this._showStats();this._afterVisitScene&&this._afterVisitScene();a.rendering(cc._renderContext);cc.eventManager.dispatchEvent(this._eventAfterDraw);
this._totalFrames++;this._displayStats&&this._calculateMPF()},_beforeVisitScene:null,_afterVisitScene:null,end:function(){this._purgeDirectorInNextLoop=!0},getContentScaleFactor:function(){return this._contentScaleFactor},getNotificationNode:function(){return this._notificationNode},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(0.25),this._paused=!0)},popScene:function(){cc.assert(this._runningScene,cc._LogInfos.Director_popScene);this._scenesStack.pop();var a=this._scenesStack.length;0===a?this.end():(this._sendCleanupToScene=!0,this._nextScene=this._scenesStack[a-1])},purgeCachedData:function(){cc.animationCache._clear();cc.spriteFrameCache._clear();cc.textureCache._clear()},purgeDirector:function(){this.getScheduler().unscheduleAll();
cc.eventManager&&cc.eventManager.setEnabled(!1);this._runningScene&&(this._runningScene.onExitTransitionDidStart(),this._runningScene.onExit(),this._runningScene.cleanup());this._nextScene=this._runningScene=null;this._scenesStack.length=0;this.stopAnimation();this.purgeCachedData();cc.checkGLErrorDebug()},pushScene:function(a){cc.assert(a,cc._LogInfos.Director_pushScene);this._sendCleanupToScene=!1;this._scenesStack.push(a);this._nextScene=a},runScene:function(a){if(cc.assert(a,cc._LogInfos.Director_pushScene),
this._runningScene){var b=this._scenesStack.length;0===b?(this._sendCleanupToScene=!0,this._scenesStack[b]=a,this._nextScene=a):(this._sendCleanupToScene=!0,this._scenesStack[b-1]=a,this._nextScene=a)}else this.pushScene(a),this.startAnimation()},resume:function(){this._paused&&(this.setAnimationInterval(this._oldAnimationInterval),this._lastUpdate=Date.now(),this._lastUpdate||cc.log(cc._LogInfos.Director_resume),this._paused=!1,this._deltaTime=0)},setContentScaleFactor:function(a){a!==this._contentScaleFactor&&
(this._contentScaleFactor=a,this._createStatsLabel())},setDepthTest:null,setDefaultValues:function(){},setNextDeltaTimeZero:function(a){this._nextDeltaTimeZero=a},setNextScene:function(){var a=!1;cc.TransitionScene&&(a=this._runningScene?this._runningScene instanceof cc.TransitionScene:!1);var b=this._runningScene;b&&(b.onExitTransitionDidStart(),b.onExit());this._sendCleanupToScene&&b&&b.cleanup();this._runningScene=this._nextScene;cc.renderer.childrenOrderDirty=!0;this._nextScene=null;a||null===
this._runningScene||(this._runningScene.onEnter(),this._runningScene.onEnterTransitionDidFinish())},setNotificationNode:function(a){this._notificationNode=a},getDelegate:function(){return this._projectionDelegate},setDelegate:function(a){this._projectionDelegate=a},setOpenGLView:null,setProjection:null,setViewport:null,getOpenGLView:null,getProjection:null,setAlphaBlending:null,_showStats:function(){this._frames++;this._accumDt+=this._deltaTime;this._FPSLabel&&this._SPFLabel&&this._drawsLabel?(this._accumDt>
cc.DIRECTOR_FPS_INTERVAL&&(this._SPFLabel.string=this._secondsPerFrame.toFixed(3),this._frameRate=this._frames/this._accumDt,this._frames=0,this._accumDt=0,this._FPSLabel.string=this._frameRate.toFixed(1),this._drawsLabel.string=(0|cc.g_NumberOfDraws).toString()),this._FPSLabel.visit(),this._SPFLabel.visit(),this._drawsLabel.visit()):this._createStatsLabel();cc.g_NumberOfDraws=0},isSendCleanupToScene:function(){return this._sendCleanupToScene},getRunningScene:function(){return this._runningScene},
getAnimationInterval:function(){return this._animationInterval},isDisplayStats:function(){return this._displayStats},setDisplayStats:function(a){this._displayStats=a},getSecondsPerFrame:function(){return this._secondsPerFrame},isNextDeltaTimeZero:function(){return this._nextDeltaTimeZero},isPaused:function(){return this._paused},getTotalFrames:function(){return this._totalFrames},popToRootScene:function(){this.popToSceneStackLevel(1)},popToSceneStackLevel:function(a){cc.assert(this._runningScene,
cc._LogInfos.Director_popToSceneStackLevel_2);var b=this._scenesStack,c=b.length;if(0===c)return void this.end();if(!(a>c)){for(;c>a;){var d=b.pop();d.running&&(d.onExitTransitionDidStart(),d.onExit());d.cleanup();c--}this._nextScene=b[b.length-1];this._sendCleanupToScene=!1}},getScheduler:function(){return this._scheduler},setScheduler:function(a){this._scheduler!==a&&(this._scheduler=a)},getActionManager:function(){return this._actionManager},setActionManager:function(a){this._actionManager!==a&&
(this._actionManager=a)},getDeltaTime:function(){return this._deltaTime},_createStatsLabel:null,_calculateMPF:function(){this._secondsPerFrame=(Date.now()-this._lastUpdate)/1E3}}),cc.Director.EVENT_PROJECTION_CHANGED="director_projection_changed",cc.Director.EVENT_AFTER_DRAW="director_after_draw",cc.Director.EVENT_AFTER_VISIT="director_after_visit",cc.Director.EVENT_AFTER_UPDATE="director_after_update",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.drawScene()},stopAnimation:function(){this.invalid=!0},setAnimationInterval:function(a){this._animationInterval=a;this.invalid||(this.stopAnimation(),this.startAnimation())}}),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_3D,cc._renderType===cc._RENDER_TYPE_CANVAS)?(_p=cc.Director.prototype,_p.setProjection=function(a){this._projection=a;cc.eventManager.dispatchEvent(this._eventProjectionChanged)},_p.setDepthTest=function(){},_p.setOpenGLView=function(a){this._winSizeInPoints.width=
cc._canvas.width;this._winSizeInPoints.height=cc._canvas.height;this._openGLView=a||cc.view;cc.eventManager&&cc.eventManager.setEnabled(!0)},_p._clear=function(){var a=this._openGLView.getViewPortRect(),b=cc._renderContext.getContext();b.setTransform(1,0,0,1,0,0);b.clearRect(-a.x,a.y,a.width,a.height)},_p._createStatsLabel=function(){var a=0,a=this._winSizeInPoints.width>this._winSizeInPoints.height?0|24*(this._winSizeInPoints.height/320):0|24*(this._winSizeInPoints.width/320);this._FPSLabel=new cc.LabelTTF("000.0",
"Arial",a);this._SPFLabel=new cc.LabelTTF("0.000","Arial",a);this._drawsLabel=new cc.LabelTTF("0000","Arial",a);a=cc.DIRECTOR_STATS_POSITION;this._drawsLabel.setPosition(this._drawsLabel.width/2+a.x,5*this._drawsLabel.height/2+a.y);this._SPFLabel.setPosition(this._SPFLabel.width/2+a.x,3*this._SPFLabel.height/2+a.y);this._FPSLabel.setPosition(this._FPSLabel.width/2+a.x,this._FPSLabel.height/2+a.y)},_p.getVisibleSize=function(){return this.getWinSize()},_p.getVisibleOrigin=function(){return cc.p(0,
0)}):(cc.Director._fpsImage=new Image,cc._addEventListener(cc.Director._fpsImage,"load",function(){cc.Director._fpsImageLoaded=!0}),cc._fpsImage&&(cc.Director._fpsImage.src=cc._fpsImage));cc.PRIORITY_NON_SYSTEM=cc.PRIORITY_SYSTEM+1;cc.ListEntry=function(a,b,c,d,e,f,g){this.prev=a;this.next=b;this.callback=c;this.target=d;this.priority=e;this.paused=f;this.markedForDeletion=g};cc.HashUpdateEntry=function(a,b,c,d,e){this.list=a;this.entry=b;this.target=c;this.callback=d;this.hh=e};
cc.HashTimerEntry=cc.hashSelectorEntry=function(a,b,c,d,e,f,g){this.timers=a;this.target=b;this.timerIndex=c;this.currentTimer=d;this.currentTimerSalvaged=e;this.paused=f;this.hh=g};
cc.Timer=cc.Class.extend({_scheduler:null,_elapsed:0,_runForever:!1,_useDelay:!1,_timesExecuted:0,_repeat:0,_delay:0,_interval:0,getInterval:function(){return this._interval},setInterval:function(a){this._interval=a},setupTimerWithInterval:function(a,b,c){this._elapsed=-1;this._interval=a;this._delay=c;this._useDelay=0<this._delay;this._repeat=b;this._runForever=this._repeat===cc.REPEAT_FOREVER},trigger:function(){return 0},cancel:function(){return 0},ctor:function(){this._scheduler=null;this._elapsed=
-1;this._useDelay=this._runForever=!1;this._interval=this._delay=this._repeat=this._timesExecuted=0},update:function(a){-1===this._elapsed?(this._elapsed=0,this._timesExecuted=0):(this._elapsed+=a,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._runForever&&this._timesExecuted>this._repeat&&this.cancel()))}});
cc.TimerTargetSelector=cc.Timer.extend({_target:null,_selector:null,ctor:function(){this._selector=this._target=null},initWithSelector:function(a,b,c,d,e,f){return this._scheduler=a,this._target=c,this._selector=b,this.setupTimerWithInterval(d,e,f),!0},getSelector:function(){return this._selector},trigger:function(){this._target&&this._selector&&this._target.call(this._selector,this._elapsed)},cancel:function(){this._scheduler.unschedule(this._selector,this._target)}});
cc.TimerTargetCallback=cc.Timer.extend({_target:null,_callback:null,_key:null,ctor:function(){this._callback=this._target=null},initWithCallback:function(a,b,c,d,e,f,g){return this._scheduler=a,this._target=c,this._callback=b,this._key=d,this.setupTimerWithInterval(e,f,g),!0},getCallback:function(){return this._callback},getKey:function(){return this._key},trigger:function(){this._callback&&this._callback.call(this._target,this._elapsed)},cancel:function(){this._scheduler.unschedule(this._callback,
this._target)}});
cc.Scheduler=cc.Class.extend({_timeScale:1,_updatesNegList:null,_updates0List:null,_updatesPosList:null,_hashForTimers:null,_arrayForTimers:null,_hashForUpdates:null,_currentTarget:null,_currentTargetSalvaged:!1,_updateHashLocked:!1,ctor:function(){this._timeScale=1;this._updatesNegList=[];this._updates0List=[];this._updatesPosList=[];this._hashForUpdates={};this._hashForTimers={};this._currentTarget=null;this._updateHashLocked=this._currentTargetSalvaged=!1;this._arrayForTimers=[]},_schedulePerFrame:function(a,
b,c,d){var e=this._hashForUpdates[b.__instanceId];if(e&&e.entry){if(e.entry.priority===c)return e.entry.markedForDeletion=!1,void(e.entry.paused=d);if(this._updateHashLocked)return cc.log("warning: you CANNOT change update priority in scheduled function"),e.entry.markedForDeletion=!1,void(e.entry.paused=d);this.unscheduleUpdate(b)}0===c?this._appendIn(this._updates0List,a,b,d):0>c?this._priorityIn(this._updatesNegList,a,b,c,d):this._priorityIn(this._updatesPosList,a,b,c,d)},_removeHashElement:function(a){delete this._hashForTimers[a.target.__instanceId];
cc.arrayRemoveObject(this._arrayForTimers,a);a.Timer=null;a.target=null},_removeUpdateFromHash:function(a){(a=this._hashForUpdates[a.target.__instanceId])&&(cc.arrayRemoveObject(a.list,a.entry),delete this._hashForUpdates[a.target.__instanceId],a.entry=null,a.target=null)},_priorityIn:function(a,b,c,d,e){b=new cc.ListEntry(null,null,b,c,d,e,!1);if(a){e=a.length-1;for(var f=0;e>=f&&!(d<a[f].priority);f++);a.splice(f,0,b)}else a=[],a.push(b);return this._hashForUpdates[c.__instanceId]=new cc.HashUpdateEntry(a,
b,c,null),a},_appendIn:function(a,b,c,d){b=new cc.ListEntry(null,null,b,c,0,d,!1);a.push(b);this._hashForUpdates[c.__instanceId]=new cc.HashUpdateEntry(a,b,c,null,null)},setTimeScale:function(a){this._timeScale=a},getTimeScale:function(){return this._timeScale},update:function(a){this._updateHashLocked=!0;1!==this._timeScale&&(a*=this._timeScale);var b,c,d,e;b=0;c=this._updatesNegList;for(d=c.length;d>b;b++)e=c[b],e.paused||e.markedForDeletion||e.callback(a);b=0;c=this._updates0List;for(d=c.length;d>
b;b++)e=c[b],e.paused||e.markedForDeletion||e.callback(a);b=0;c=this._updatesPosList;for(d=c.length;d>b;b++)e=c[b],e.paused||e.markedForDeletion||e.callback(a);var f;c=this._arrayForTimers;for(b=0;b<c.length;b++){if(f=c[b],this._currentTarget=f,this._currentTargetSalvaged=!1,!f.paused)for(f.timerIndex=0;f.timerIndex<f.timers.length;++f.timerIndex)f.currentTimer=f.timers[f.timerIndex],f.currentTimerSalvaged=!1,f.currentTimer.update(a),f.currentTimer=null;this._currentTargetSalvaged&&0===this._currentTarget.timers.length&&
this._removeHashElement(this._currentTarget)}b=0;for(c=this._updatesNegList;b<c.length;)e=c[b],e.markedForDeletion?this._removeUpdateFromHash(e):b++;b=0;for(c=this._updates0List;b<c.length;)e=c[b],e.markedForDeletion?this._removeUpdateFromHash(e):b++;b=0;for(c=this._updatesPosList;b<c.length;)e=c[b],e.markedForDeletion?this._removeUpdateFromHash(e):b++;this._updateHashLocked=!1;this._currentTarget=null},scheduleCallbackForTarget:function(a,b,c,d,e,f){this.schedule(b,a,c,d,e,f,a.__instanceId+"")},
schedule:function(a,b,c,d,e,f,g){var h=!1;if("function"!=typeof a)var k=a,h=!0;!1===h?5===arguments.length&&(g=e,f=d,e=0,d=cc.REPEAT_FOREVER):4===arguments.length&&(f=d,d=cc.REPEAT_FOREVER,e=0);cc.assert(b,cc._LogInfos.Scheduler_scheduleCallbackForTarget_3);!1===h&&cc.assert(g,"key should not be empty!");var m=this._hashForTimers[b.__instanceId];m?cc.assert(m.paused===f,""):(m=new cc.HashTimerEntry(null,b,0,null,null,f,null),this._arrayForTimers.push(m),this._hashForTimers[b.__instanceId]=m);var n,
p;if(null==m.timers)m.timers=[];else if(!1===h)for(p=0;p<m.timers.length;p++){if(n=m.timers[p],a===n._callback)return cc.log(cc._LogInfos.Scheduler_scheduleCallbackForTarget,n.getInterval().toFixed(4),c.toFixed(4)),void(n._interval=c)}else for(p=0;p<m.timers.length;++p)if(n=m.timers[p],n&&k===n.getSelector())return cc.log("CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f",n.getInterval(),c),void n.setInterval(c);!1===h?(n=new cc.TimerTargetCallback,n.initWithCallback(this,
a,b,g,c,d,e),m.timers.push(n)):(n=new cc.TimerTargetSelector,n.initWithSelector(this,k,b,c,d,e),m.timers.push(n))},scheduleUpdate:function(a,b,c){this._schedulePerFrame(function(b){a.update(b)},a,b,c)},_getUnscheduleMark:function(a,b){switch(typeof a){case "number":case "string":return a===b.getKey();case "function":return a===b._callback;default:return a===b.getSelector()}},unschedule:function(a,b){if(b&&a){var c=this._hashForTimers[b.__instanceId];if(c)for(var d=c.timers,e=0,f=d.length;f>e;e++){var g=
d[e];if(this._getUnscheduleMark(a,g))return g!==c.currentTimer||c.currentTimerSalvaged||(c.currentTimerSalvaged=!0),d.splice(e,1),c.timerIndex>=e&&c.timerIndex--,void(0===d.length&&(this._currentTarget===c?this._currentTargetSalvaged=!0:this._removeHashElement(c)))}}},unscheduleUpdate:function(a){null!=a&&(a=this._hashForUpdates[a.__instanceId])&&(this._updateHashLocked?a.entry.markedForDeletion=!0:this._removeUpdateFromHash(a.entry))},unscheduleAllForTarget:function(a){if(null!=a){var b=this._hashForTimers[a.__instanceId];
b&&(-1<b.timers.indexOf(b.currentTimer)&&!b.currentTimerSalvaged&&(b.currentTimerSalvaged=!0),b.timers.length=0,this._currentTarget===b?this._currentTargetSalvaged=!0:this._removeHashElement(b));this.unscheduleUpdate(a)}},unscheduleAll:function(){this.unscheduleAllWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)},unscheduleAllWithMinPriority:function(a){var b,c,d=this._arrayForTimers;for(b=0;b<d.length;b++)c=d[b],this.unscheduleAllForTarget(c.target);d=0;if(0>a)for(b=0;b<this._updatesNegList.length;)d=
this._updatesNegList.length,(c=this._updatesNegList[b])&&c.priority>=a&&this.unscheduleUpdate(c.target),d==this._updatesNegList.length&&b++;if(0>=a)for(b=0;b<this._updates0List.length;)d=this._updates0List.length,(c=this._updates0List[b])&&this.unscheduleUpdate(c.target),d==this._updates0List.length&&b++;for(b=0;b<this._updatesPosList.length;)d=this._updatesPosList.length,(c=this._updatesPosList[b])&&c.priority>=a&&this.unscheduleUpdate(c.target),d==this._updatesPosList.length&&b++},isScheduled:function(a,
b){cc.assert(a,"Argument key must not be empty");cc.assert(b,"Argument target must be non-nullptr");var c=this._hashForUpdates[b.__instanceId];if(!c||null==c.timers)return!1;for(var c=c.timers,d=0;d<c.length;++d)if(a===c[d].getKey())return!0;return!1},pauseAllTargets:function(){return this.pauseAllTargetsWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)},pauseAllTargetsWithMinPriority:function(a){var b,c,d,e=[],f=this._arrayForTimers;c=0;for(d=f.length;d>c;c++)(b=f[c])&&(b.paused=!0,e.push(b.target));
if(0>a)for(c=0;c<this._updatesNegList.length;c++)(b=this._updatesNegList[c])&&b.priority>=a&&(b.paused=!0,e.push(b.target));if(0>=a)for(c=0;c<this._updates0List.length;c++)(b=this._updates0List[c])&&(b.paused=!0,e.push(b.target));for(c=0;c<this._updatesPosList.length;c++)(b=this._updatesPosList[c])&&b.priority>=a&&(b.paused=!0,e.push(b.target));return e},resumeTargets:function(a){if(a)for(var b=0;b<a.length;b++)this.resumeTarget(a[b])},pauseTarget:function(a){cc.assert(a,cc._LogInfos.Scheduler_pauseTarget);
var b=this._hashForTimers[a.__instanceId];b&&(b.paused=!0);(a=this._hashForUpdates[a.__instanceId])&&(a.entry.paused=!0)},resumeTarget:function(a){cc.assert(a,cc._LogInfos.Scheduler_resumeTarget);var b=this._hashForTimers[a.__instanceId];b&&(b.paused=!1);(a=this._hashForUpdates[a.__instanceId])&&(a.entry.paused=!1)},isTargetPaused:function(a){cc.assert(a,cc._LogInfos.Scheduler_isTargetPaused);var b=this._hashForTimers[a.__instanceId];return b?b.paused:(a=this._hashForUpdates[a.__instanceId])?a.entry.paused:
!1},scheduleUpdateForTarget:function(a,b,c){this.scheduleUpdate(a,b,c)},unscheduleCallbackForTarget:function(a,b){this.unschedule(b,a)},unscheduleUpdateForTarget:function(a){this.unscheduleUpdate(a)},unscheduleAllCallbacksForTarget:function(a){this.unschedule(a.__instanceId+"",a)},unscheduleAllCallbacks:function(){this.unscheduleAllWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)},unscheduleAllCallbacksWithMinPriority:function(a){this.unscheduleAllWithMinPriority(a)}});cc.Scheduler.PRIORITY_SYSTEM=-2147483648;
cc._tmp.PrototypeLabelTTF=function(){var a=cc.LabelTTF.prototype;cc.defineGetterSetter(a,"color",a.getColor,a.setColor);cc.defineGetterSetter(a,"opacity",a.getOpacity,a.setOpacity);a.string;cc.defineGetterSetter(a,"string",a.getString,a.setString);a.textAlign;cc.defineGetterSetter(a,"textAlign",a.getHorizontalAlignment,a.setHorizontalAlignment);a.verticalAlign;cc.defineGetterSetter(a,"verticalAlign",a.getVerticalAlignment,a.setVerticalAlignment);a.fontSize;cc.defineGetterSetter(a,"fontSize",a.getFontSize,
a.setFontSize);a.fontName;cc.defineGetterSetter(a,"fontName",a.getFontName,a.setFontName);a.font;cc.defineGetterSetter(a,"font",a._getFont,a._setFont);a.boundingSize;a.boundingWidth;cc.defineGetterSetter(a,"boundingWidth",a._getBoundingWidth,a._setBoundingWidth);a.boundingHeight;cc.defineGetterSetter(a,"boundingHeight",a._getBoundingHeight,a._setBoundingHeight);a.fillStyle;cc.defineGetterSetter(a,"fillStyle",a._getFillStyle,a.setFontFillColor);a.strokeStyle;cc.defineGetterSetter(a,"strokeStyle",a._getStrokeStyle,
a._setStrokeStyle);a.lineWidth;cc.defineGetterSetter(a,"lineWidth",a._getLineWidth,a._setLineWidth);a.shadowOffset;a.shadowOffsetX;cc.defineGetterSetter(a,"shadowOffsetX",a._getShadowOffsetX,a._setShadowOffsetX);a.shadowOffsetY;cc.defineGetterSetter(a,"shadowOffsetY",a._getShadowOffsetY,a._setShadowOffsetY);a.shadowOpacity;cc.defineGetterSetter(a,"shadowOpacity",a._getShadowOpacity,a._setShadowOpacity);a.shadowBlur;cc.defineGetterSetter(a,"shadowBlur",a._getShadowBlur,a._setShadowBlur)};
cc.LabelTTF=cc.Sprite.extend({_dimensions:null,_hAlignment:cc.TEXT_ALIGNMENT_CENTER,_vAlignment:cc.VERTICAL_TEXT_ALIGNMENT_TOP,_fontName:null,_fontSize:0,_string:"",_originalText:null,_shadowEnabled:!1,_shadowOffset:null,_shadowOpacity:0,_shadowBlur:0,_shadowColor:null,_strokeEnabled:!1,_strokeColor:null,_strokeSize:0,_textFillColor:null,_strokeShadowOffsetX:0,_strokeShadowOffsetY:0,_needUpdateTexture:!1,_lineWidths:null,_className:"LabelTTF",_fontStyle:"normal",_fontWeight:"normal",_lineHeight:"normal",
initWithString:function(a,b,c,d,e,f){var g;return g=a?a+"":"",c=c||16,d=d||cc.size(0,0),e=e||cc.TEXT_ALIGNMENT_LEFT,f=f||cc.VERTICAL_TEXT_ALIGNMENT_TOP,this._opacityModifyRGB=!1,this._dimensions=cc.size(d.width,d.height),this._fontName=b||"Arial",this._hAlignment=e,this._vAlignment=f,this._fontSize=c,this._renderCmd._setFontStyle(this._fontName,c,this._fontStyle,this._fontWeight),this.string=g,this._renderCmd._setColorsString(),this._renderCmd._updateTexture(),this._setUpdateTextureDirty(),!0},_setUpdateTextureDirty:function(){this._needUpdateTexture=
!0;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.textDirty)},ctor:function(a,b,c,d,e,f){cc.Sprite.prototype.ctor.call(this);this._dimensions=cc.size(0,0);this._hAlignment=cc.TEXT_ALIGNMENT_LEFT;this._vAlignment=cc.VERTICAL_TEXT_ALIGNMENT_TOP;this._opacityModifyRGB=!1;this._fontName="Arial";this._shadowEnabled=!1;this._shadowOffset=cc.p(0,0);this._shadowBlur=this._shadowOpacity=0;this._strokeEnabled=!1;this._strokeColor=cc.color(255,255,255,255);this._strokeSize=0;this._textFillColor=cc.color(255,
255,255,255);this._strokeShadowOffsetY=this._strokeShadowOffsetX=0;this._needUpdateTexture=!1;this._lineWidths=[];this._renderCmd._setColorsString();this._textureLoaded=!0;b&&b instanceof cc.FontDefinition?this.initWithStringAndTextDefinition(a,b):cc.LabelTTF.prototype.initWithString.call(this,a,b,c,d,e,f)},init:function(){return this.initWithString(" ",this._fontName,this._fontSize)},description:function(){return"\x3ccc.LabelTTF | FontName \x3d"+this._fontName+" FontSize \x3d "+this._fontSize.toFixed(1)+
"\x3e"},getLineHeight:function(){return!this._lineHeight||this._lineHeight.charAt?this._renderCmd._getFontClientHeight():this._lineHeight||this._renderCmd._getFontClientHeight()},setLineHeight:function(a){this._lineHeight=a},getString:function(){return this._string},getHorizontalAlignment:function(){return this._hAlignment},getVerticalAlignment:function(){return this._vAlignment},getDimensions:function(){return cc.size(this._dimensions)},getFontSize:function(){return this._fontSize},getFontName:function(){return this._fontName},
initWithStringAndTextDefinition:function(a,b){return this._updateWithTextDefinition(b,!1),this.string=a,!0},setTextDefinition:function(a){a&&this._updateWithTextDefinition(a,!0)},getTextDefinition:function(){return this._prepareTextDefinition(!1)},enableShadow:function(a,b,c,d){null!=a.r&&null!=a.g&&null!=a.b&&null!=a.a?this._enableShadow(a,b,c):this._enableShadowNoneColor(a,b,c,d)},_enableShadowNoneColor:function(a,b,c,d){c=c||0.5;!1===this._shadowEnabled&&(this._shadowEnabled=!0);var e=this._shadowOffset;
(e&&e.x!==a||e._y!==b)&&(e.x=a,e.y=b);this._shadowOpacity!==c&&(this._shadowOpacity=c);this._renderCmd._setColorsString();this._shadowBlur!==d&&(this._shadowBlur=d);this._setUpdateTextureDirty()},_enableShadow:function(a,b,c){this._shadowColor||(this._shadowColor=cc.color(255,255,255,128));this._shadowColor.r=a.r;this._shadowColor.g=a.g;this._shadowColor.b=a.b;this._enableShadowNoneColor(b.width||b.x||0,b.height||b.y||0,null!=a.a?a.a/255:0.5,c)},_getShadowOffsetX:function(){return this._shadowOffset.x},
_setShadowOffsetX:function(a){!1===this._shadowEnabled&&(this._shadowEnabled=!0);this._shadowOffset.x!==a&&(this._shadowOffset.x=a,this._setUpdateTextureDirty())},_getShadowOffsetY:function(){return this._shadowOffset._y},_setShadowOffsetY:function(a){!1===this._shadowEnabled&&(this._shadowEnabled=!0);this._shadowOffset._y!==a&&(this._shadowOffset._y=a,this._setUpdateTextureDirty())},_getShadowOffset:function(){return cc.p(this._shadowOffset.x,this._shadowOffset.y)},_setShadowOffset:function(a){!1===
this._shadowEnabled&&(this._shadowEnabled=!0);(this._shadowOffset.x!==a.x||this._shadowOffset.y!==a.y)&&(this._shadowOffset.x=a.x,this._shadowOffset.y=a.y,this._setUpdateTextureDirty())},_getShadowOpacity:function(){return this._shadowOpacity},_setShadowOpacity:function(a){!1===this._shadowEnabled&&(this._shadowEnabled=!0);this._shadowOpacity!==a&&(this._shadowOpacity=a,this._renderCmd._setColorsString(),this._setUpdateTextureDirty())},_getShadowBlur:function(){return this._shadowBlur},_setShadowBlur:function(a){!1===
this._shadowEnabled&&(this._shadowEnabled=!0);this._shadowBlur!==a&&(this._shadowBlur=a,this._setUpdateTextureDirty())},disableShadow:function(){this._shadowEnabled&&(this._shadowEnabled=!1,this._setUpdateTextureDirty())},enableStroke:function(a,b){!1===this._strokeEnabled&&(this._strokeEnabled=!0);var c=this._strokeColor;(c.r!==a.r||c.g!==a.g||c.b!==a.b)&&(c.r=a.r,c.g=a.g,c.b=a.b,this._renderCmd._setColorsString());this._strokeSize!==b&&(this._strokeSize=b||0);this._setUpdateTextureDirty()},_getStrokeStyle:function(){return this._strokeColor},
_setStrokeStyle:function(a){!1===this._strokeEnabled&&(this._strokeEnabled=!0);var b=this._strokeColor;(b.r!==a.r||b.g!==a.g||b.b!==a.b)&&(b.r=a.r,b.g=a.g,b.b=a.b,this._renderCmd._setColorsString(),this._setUpdateTextureDirty())},_getLineWidth:function(){return this._strokeSize},_setLineWidth:function(a){!1===this._strokeEnabled&&(this._strokeEnabled=!0);this._strokeSize!==a&&(this._strokeSize=a||0,this._setUpdateTextureDirty())},disableStroke:function(){this._strokeEnabled&&(this._strokeEnabled=
!1,this._setUpdateTextureDirty())},setFontFillColor:function(a){var b=this._textFillColor;(b.r!==a.r||b.g!==a.g||b.b!==a.b)&&(b.r=a.r,b.g=a.g,b.b=a.b,this._renderCmd._setColorsString(),this._needUpdateTexture=!0)},_getFillStyle:function(){return this._textFillColor},_updateWithTextDefinition:function(a,b){a.fontDimensions?(this._dimensions.width=a.boundingWidth,this._dimensions.height=a.boundingHeight):(this._dimensions.width=0,this._dimensions.height=0);this._hAlignment=a.textAlign;this._vAlignment=
a.verticalAlign;this._fontName=a.fontName;this._fontSize=a.fontSize||12;a.lineHeight?this._lineHeight=a.lineHeight:this._lineHeight=this._fontSize;this._renderCmd._setFontStyle(a);a.shadowEnabled&&this.enableShadow(a.shadowOffsetX,a.shadowOffsetY,a.shadowOpacity,a.shadowBlur);a.strokeEnabled&&this.enableStroke(a.strokeStyle,a.lineWidth);this.setFontFillColor(a.fillStyle);b&&this._renderCmd._updateTexture();var c=cc.Node._dirtyFlags;this._renderCmd.setDirtyFlag(c.colorDirty|c.opacityDirty|c.textDirty)},
_prepareTextDefinition:function(a){var b=new cc.FontDefinition;if(a?(b.fontSize=this._fontSize,b.boundingWidth=cc.contentScaleFactor()*this._dimensions.width,b.boundingHeight=cc.contentScaleFactor()*this._dimensions.height):(b.fontSize=this._fontSize,b.boundingWidth=this._dimensions.width,b.boundingHeight=this._dimensions.height),b.fontName=this._fontName,b.textAlign=this._hAlignment,b.verticalAlign=this._vAlignment,this._strokeEnabled){b.strokeEnabled=!0;var c=this._strokeColor;b.strokeStyle=cc.color(c.r,
c.g,c.b);b.lineWidth=this._strokeSize}else b.strokeEnabled=!1;this._shadowEnabled?(b.shadowEnabled=!0,b.shadowBlur=this._shadowBlur,b.shadowOpacity=this._shadowOpacity,b.shadowOffsetX=(a?cc.contentScaleFactor():1)*this._shadowOffset.x,b.shadowOffsetY=(a?cc.contentScaleFactor():1)*this._shadowOffset.y):b._shadowEnabled=!1;a=this._textFillColor;return b.fillStyle=cc.color(a.r,a.g,a.b),b},setString:function(a){a=String(a);this._originalText!==a&&(this._originalText=a+"",this._updateString(),this._setUpdateTextureDirty(),
this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty))},_updateString:function(){this._string&&""!==this._string||this._string===this._originalText||(cc.renderer.childrenOrderDirty=!0);this._string=this._originalText},setHorizontalAlignment:function(a){a!==this._hAlignment&&(this._hAlignment=a,this._setUpdateTextureDirty())},setVerticalAlignment:function(a){a!==this._vAlignment&&(this._vAlignment=a,this._setUpdateTextureDirty())},setDimensions:function(a,b){var c;void 0===b?(c=a.width,
b=a.height):c=a;(c!==this._dimensions.width||b!==this._dimensions.height)&&(this._dimensions.width=c,this._dimensions.height=b,this._updateString(),this._setUpdateTextureDirty())},_getBoundingWidth:function(){return this._dimensions.width},_setBoundingWidth:function(a){a!==this._dimensions.width&&(this._dimensions.width=a,this._updateString(),this._setUpdateTextureDirty())},_getBoundingHeight:function(){return this._dimensions.height},_setBoundingHeight:function(a){a!==this._dimensions.height&&(this._dimensions.height=
a,this._updateString(),this._setUpdateTextureDirty())},setFontSize:function(a){this._fontSize!==a&&(this._fontSize=a,this._renderCmd._setFontStyle(this._fontName,this._fontSize,this._fontStyle,this._fontWeight),this._setUpdateTextureDirty())},setFontName:function(a){this._fontName&&this._fontName!==a&&(this._fontName=a,this._renderCmd._setFontStyle(this._fontName,this._fontSize,this._fontStyle,this._fontWeight),this._setUpdateTextureDirty())},_getFont:function(){return this._renderCmd._getFontStyle()},
_setFont:function(a){(a=cc.LabelTTF._fontStyleRE.exec(a))&&(this._fontSize=parseInt(a[1]),this._fontName=a[2],this._renderCmd._setFontStyle(this._fontName,this._fontSize,this._fontStyle,this._fontWeight),this._setUpdateTextureDirty())},getContentSize:function(){return this._needUpdateTexture&&this._renderCmd._updateTTF(),cc.Sprite.prototype.getContentSize.call(this)},_getWidth:function(){return this._needUpdateTexture&&this._renderCmd._updateTTF(),cc.Sprite.prototype._getWidth.call(this)},_getHeight:function(){return this._needUpdateTexture&&
this._renderCmd._updateTTF(),cc.Sprite.prototype._getHeight.call(this)},setTextureRect:function(a,b,c){cc.Sprite.prototype.setTextureRect.call(this,a,b,c,!1)},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.LabelTTF.CanvasRenderCmd(this):new cc.LabelTTF.WebGLRenderCmd(this)},_setFontStyle:function(a){this._fontStyle!==a&&(this._fontStyle=a,this._renderCmd._setFontStyle(this._fontName,this._fontSize,this._fontStyle,this._fontWeight),this._setUpdateTextureDirty())},
_getFontStyle:function(){return this._fontStyle},_setFontWeight:function(a){this._fontWeight!==a&&(this._fontWeight=a,this._renderCmd._setFontStyle(this._fontName,this._fontSize,this._fontStyle,this._fontWeight),this._setUpdateTextureDirty())},_getFontWeight:function(){return this._fontWeight}});cc.assert(cc.isFunction(cc._tmp.PrototypeLabelTTF),cc._LogInfos.MissingFile,"LabelTTFPropertyDefine.js");cc._tmp.PrototypeLabelTTF();delete cc._tmp.PrototypeLabelTTF;cc.LabelTTF._fontStyleRE=/^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/;
cc.LabelTTF.create=function(a,b,c,d,e,f){return new cc.LabelTTF(a,b,c,d,e,f)};cc.LabelTTF.createWithFontDefinition=cc.LabelTTF.create;cc.USE_LA88_LABELS?cc.LabelTTF._SHADER_PROGRAM=cc.SHADER_POSITION_TEXTURECOLOR:cc.LabelTTF._SHADER_PROGRAM=cc.SHADER_POSITION_TEXTUREA8COLOR;cc.LabelTTF.__labelHeightDiv=cc.newElement("div");cc.LabelTTF.__labelHeightDiv.style.fontFamily="Arial";cc.LabelTTF.__labelHeightDiv.style.position="absolute";cc.LabelTTF.__labelHeightDiv.style.left="-100px";
cc.LabelTTF.__labelHeightDiv.style.top="-100px";cc.LabelTTF.__labelHeightDiv.style.lineHeight="normal";document.body?document.body.appendChild(cc.LabelTTF.__labelHeightDiv):cc._addEventListener(window,"load",function(){this.removeEventListener("load",arguments.callee,!1);document.body.appendChild(cc.LabelTTF.__labelHeightDiv)},!1);
cc.LabelTTF.__getFontHeightByDiv=function(a,b){if(a instanceof cc.FontDefinition){var c=cc.LabelTTF.__fontHeightCache[a._getCanvasFontStr()];if(0<c)return c;var d=cc.LabelTTF.__labelHeightDiv;return d.innerHTML="ajghl~!",d.style.fontFamily=a.fontName,d.style.fontSize=a.fontSize+"px",d.style.fontStyle=a.fontStyle,d.style.fontWeight=a.fontWeight,c=d.clientHeight,cc.LabelTTF.__fontHeightCache[a._getCanvasFontStr()]=c,d.innerHTML="",c}c=cc.LabelTTF.__fontHeightCache[a+"."+b];if(0<c)return c;d=cc.LabelTTF.__labelHeightDiv;
return d.innerHTML="ajghl~!",d.style.fontFamily=a,d.style.fontSize=b+"px",c=d.clientHeight,cc.LabelTTF.__fontHeightCache[a+"."+b]=c,d.innerHTML="",c};cc.LabelTTF.__fontHeightCache={};cc.LabelTTF._textAlign=["left","center","right"];cc.LabelTTF._textBaseline=["top","middle","bottom"];cc.LabelTTF.wrapInspection=!0;cc.LabelTTF._wordRex=/([a-zA-Z0-9\u00c4\u00d6\u00dc\u00e4\u00f6\u00fc\u00df\u00e9\u00e8\u00e7\u00e0\u00f9\u00ea\u00e2\u00ee\u00f4\u00fb]+|\S)/;cc.LabelTTF._symbolRex=/^[!,.:;}\]%\?>\u3001\u2018\u201c\u300b\uff1f\u3002\uff0c\uff01]/;
cc.LabelTTF._lastWordRex=/([a-zA-Z0-9\u00c4\u00d6\u00dc\u00e4\u00f6\u00fc\u00df\u00e9\u00e8\u00e7\u00e0\u00f9\u00ea\u00e2\u00ee\u00f4\u00fb]+|\S)$/;cc.LabelTTF._lastEnglish=/[a-zA-Z0-9\u00c4\u00d6\u00dc\u00e4\u00f6\u00fc\u00df\u00e9\u00e8\u00e7\u00e0\u00f9\u00ea\u00e2\u00ee\u00f4\u00fb]+$/;cc.LabelTTF._firsrEnglish=/^[a-zA-Z0-9\u00c4\u00d6\u00dc\u00e4\u00f6\u00fc\u00df\u00e9\u00e8\u00e7\u00e0\u00f9\u00ea\u00e2\u00ee\u00f4\u00fb]/;
(function(){cc.LabelTTF.RenderCmd=function(){this._fontClientHeight=18;this._fontStyleStr="";this._shadowColorStr="rgba(128, 128, 128, 0.5)";this._strokeColorStr="";this._fillColorStr="rgba(255,255,255,1)";this._labelContext=this._labelCanvas=null;this._lineWidths=[];this._strings=[];this._isMultiLine=!1};var a=cc.LabelTTF.RenderCmd.prototype;a.constructor=cc.LabelTTF.RenderCmd;a._getLabelContext=function(){if(this._labelContext)return this._labelContext;var a=this._node;if(!this._labelCanvas){var c=
cc.newElement("canvas");c.width=1;c.height=1;var d=new cc.Texture2D;d.initWithElement(c);a.setTexture(d);this._labelCanvas=c}return this._labelContext=this._labelCanvas.getContext("2d"),this._labelContext};a._setFontStyle=function(a,c,d,e){a instanceof cc.FontDefinition?(this._fontStyleStr=a._getCanvasFontStr(),this._fontClientHeight=cc.LabelTTF.__getFontHeightByDiv(a)):(this._fontStyleStr=d+" "+e+" "+c+"px '"+a+"'",this._fontClientHeight=cc.LabelTTF.__getFontHeightByDiv(a,c))};a._getFontStyle=function(){return this._fontStyleStr};
a._getFontClientHeight=function(){return this._fontClientHeight};a._updateTexture=function(){this._dirtyFlag^=this._dirtyFlag&cc.Node._dirtyFlags.textDirty;var a=this._node,c=this._getLabelContext(),d=this._labelCanvas,e=a._contentSize;if(0===a._string.length)return d.width=1,d.height=e.height||1,a._texture&&a._texture.handleLoadedTexture(),a.setTextureRect(cc.rect(0,0,1,e.height)),!0;c.font=this._fontStyleStr;this._updateTTF();var f=e.width,e=e.height,g=d.width===f&&d.height===e;return d.width=f,
d.height=e,g&&c.clearRect(0,0,f,e),this._drawTTFInCanvas(c),a._texture&&a._texture.handleLoadedTexture(),a.setTextureRect(cc.rect(0,0,f,e)),!0};a._measureConfig=function(){this._getLabelContext().font=this._fontStyleStr};a._measure=function(a){return this._getLabelContext().measureText(a).width};a._updateTTF=function(){var a,c,d=this._node,e=d._dimensions.width,f=this._lineWidths;if(f.length=0,this._isMultiLine=!1,this._measureConfig(),0!==e){this._strings=d._string.split("\n");for(a=0;a<this._strings.length;a++)this._checkWarp(this._strings,
a,e)}else{this._strings=d._string.split("\n");a=0;for(c=this._strings.length;c>a;a++)f.push(this._measure(this._strings[a]))}0<this._strings.length&&(this._isMultiLine=!0);c=a=0;if(d._strokeEnabled&&(a=c=2*d._strokeSize),d._shadowEnabled){var g=d._shadowOffset;a+=2*Math.abs(g.x);c+=2*Math.abs(g.y)}e=0===e?this._isMultiLine?cc.size(Math.ceil(Math.max.apply(Math,f)+a),Math.ceil(this._fontClientHeight*this._strings.length+c)):cc.size(Math.ceil(this._measure(d._string)+a),Math.ceil(this._fontClientHeight+
c)):0===d._dimensions.height?this._isMultiLine?cc.size(Math.ceil(e+a),Math.ceil(d.getLineHeight()*this._strings.length+c)):cc.size(Math.ceil(e+a),Math.ceil(d.getLineHeight()+c)):cc.size(Math.ceil(e+a),Math.ceil(d._dimensions.height+c));"normal"!==d._getFontStyle()&&(e.width=Math.ceil(e.width+0.3*d._fontSize));d.setContentSize(e);d._strokeShadowOffsetX=a;d._strokeShadowOffsetY=c;d=d._anchorPoint;this._anchorPointInPoints.x=0.5*a+(e.width-a)*d.x;this._anchorPointInPoints.y=0.5*c+(e.height-c)*d.y};a._drawTTFInCanvas=
function(a){if(a){var c=this._node,d=c._strokeShadowOffsetX,e=c._strokeShadowOffsetY,f=c._contentSize.height-e,g=c._vAlignment,h=c._hAlignment,k=c._strokeSize;a.setTransform(1,0,0,1,0.5*d,f+0.5*e);a.font!==this._fontStyleStr&&(a.font=this._fontStyleStr);a.fillStyle=this._fillColorStr;var m=e=0,n=c._strokeEnabled;if(n&&(a.lineWidth=2*k,a.strokeStyle=this._strokeColorStr),c._shadowEnabled)k=c._shadowOffset,a.shadowColor=this._shadowColorStr,a.shadowOffsetX=k.x,a.shadowOffsetY=-k.y,a.shadowBlur=c._shadowBlur;
a.textBaseline=cc.LabelTTF._textBaseline[g];a.textAlign=cc.LabelTTF._textAlign[h];var p=c._contentSize.width-d,d=c.getLineHeight(),k=(d-this._fontClientHeight)/2;if(e+=h===cc.TEXT_ALIGNMENT_RIGHT?p:h===cc.TEXT_ALIGNMENT_CENTER?p/2:0,this._isMultiLine){c=this._strings.length;g===cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM?m=d-2*k+f-d*c:g===cc.VERTICAL_TEXT_ALIGNMENT_CENTER&&(m=(d-2*k)/2+(f-d*c)/2);for(g=0;c>g;g++)h=this._strings[g],p=-f+(d*g+k)+m,n&&a.strokeText(h,e,p),a.fillText(h,e,p)}else g===cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM||
(m-=g===cc.VERTICAL_TEXT_ALIGNMENT_TOP?f:0.5*f),n&&a.strokeText(c._string,e,m),a.fillText(c._string,e,m)}};a._checkWarp=function(a,c,d){var e=a[c],f=this._measure(e);if(f>d&&1<e.length){for(var g,h=e.length*(d/f)|0,k=e.substr(h),m=f-this._measure(k),n=0,p=0;m>d&&100>p++;)h*=d/m,h|=0,k=e.substr(h),m=f-this._measure(k);for(p=0;d>m&&100>p++;)k&&(n=(g=cc.LabelTTF._wordRex.exec(k))?g[0].length:1,g=k),h+=n,k=e.substr(h),m=f-this._measure(k);h-=n;0===h&&(h=1,g=g.substr(1));var r;d=e.substr(0,h);cc.LabelTTF.wrapInspection&&
cc.LabelTTF._symbolRex.test(g||k)&&(r=cc.LabelTTF._lastWordRex.exec(d),h-=r?r[0].length:0,g=e.substr(h),d=e.substr(0,h));cc.LabelTTF._firsrEnglish.test(g)&&(r=cc.LabelTTF._lastEnglish.exec(d),r&&d!==r[0]&&(h-=r[0].length,g=e.substr(h),d=e.substr(0,h)));a[c]=g||k;a.splice(c,0,d)}}})();
(function(){cc.LabelTTF.CanvasRenderCmd=function(a){cc.Sprite.CanvasRenderCmd.call(this,a);cc.LabelTTF.RenderCmd.call(this)};cc.LabelTTF.CanvasRenderCmd.prototype=Object.create(cc.Sprite.CanvasRenderCmd.prototype);cc.inject(cc.LabelTTF.RenderCmd.prototype,cc.LabelTTF.CanvasRenderCmd.prototype);var a=cc.LabelTTF.CanvasRenderCmd.prototype;a.constructor=cc.LabelTTF.CanvasRenderCmd;a.updateStatus=function(){var a=cc.Node._dirtyFlags,c=this._dirtyFlag,d=c&a.colorDirty,e=c&a.opacityDirty;d&&this._updateDisplayColor();
e&&this._updateDisplayOpacity();d?this._updateColor():c&a.textDirty&&this._updateTexture();this._dirtyFlag&a.transformDirty&&(this.transform(this.getParentRenderCmd(),!0),this._dirtyFlag^=this._dirtyFlag&cc.Node._dirtyFlags.transformDirty)};a._syncStatus=function(a){var c=cc.Node._dirtyFlags,d=this._dirtyFlag,e=a?a._node:null;e&&e._cascadeColorEnabled&&a._dirtyFlag&c.colorDirty&&(d|=c.colorDirty);e&&e._cascadeOpacityEnabled&&a._dirtyFlag&c.opacityDirty&&(d|=c.opacityDirty);a&&a._dirtyFlag&c.transformDirty&&
(d|=c.transformDirty);var e=d&c.colorDirty,f=d&c.opacityDirty;this._dirtyFlag=d;e&&this._syncDisplayColor();f&&this._syncDisplayOpacity();e?this._updateColor():d&c.textDirty&&this._updateTexture();d&c.transformDirty&&this.transform(a)};a._setColorsString=function(){var a=this._displayedColor,c=this._node,d=c._shadowColor||this._displayedColor,e=c._strokeColor,f=c._textFillColor,g=a.r/255,h=a.g/255,a=a.b/255;this._shadowColorStr="rgba("+(0|g*d.r)+","+(0|h*d.g)+","+(0|a*d.b)+","+c._shadowOpacity+")";
this._fillColorStr="rgba("+(0|g*f.r)+","+(0|h*f.g)+","+(0|a*f.b)+", 1)";this._strokeColorStr="rgba("+(0|g*e.r)+","+(0|h*e.g)+","+(0|a*e.b)+", 1)"};a._updateColor=function(){this._setColorsString();this._updateTexture()}})();cc=cc||{};cc._tmp=cc._tmp||{};cc.associateWithNative=function(a,b){};
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,"\x3d":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.FMT_JPG=0;cc.FMT_PNG=1;cc.FMT_TIFF=2;cc.FMT_RAWDATA=3;cc.FMT_WEBP=4;cc.FMT_UNKNOWN=5;
cc.getImageFormatByData=function(a){return 8<a.length&&137===a[0]&&80===a[1]&&78===a[2]&&71===a[3]&&13===a[4]&&10===a[5]&&26===a[6]&&10===a[7]?cc.FMT_PNG:2<a.length&&(73===a[0]&&73===a[1]||77===a[0]&&77===a[1]||255===a[0]&&216===a[1])?cc.FMT_TIFF:cc.FMT_UNKNOWN};cc.inherits=function(a,b){function c(){}c.prototype=b.prototype;a.superClass_=b.prototype;a.prototype=new c;a.prototype.constructor=a};
cc.base=function(a,b,c){var d=arguments.callee.caller;if(d.superClass_)return ret=d.superClass_.constructor.apply(a,Array.prototype.slice.call(arguments,1)),ret;for(var e=Array.prototype.slice.call(arguments,2),f=!1,g=a.constructor;g;g=g.superClass_&&g.superClass_.constructor)if(g.prototype[b]===d)f=!0;else if(f)return g.prototype[b].apply(a,e);if(a[b]===d)return a.constructor.prototype[b].apply(a,e);throw Error("cc.base called from a method of one name to a method of a different name");};
cc.rendererCanvas={childrenOrderDirty:!0,_transformNodePool:[],_renderCmds:[],_isCacheToCanvasOn:!1,_cacheToCanvasCmds:{},_cacheInstanceIds:[],_currentID:0,getRenderCmd:function(a){return a._createRenderCmd()},rendering:function(a){var b,c=this._renderCmds,d=cc.view.getScaleX(),e=cc.view.getScaleY(),f=a||cc._renderContext;f.computeRealOffsetY();a=0;for(b=c.length;b>a;a++)c[a].rendering(f,d,e)},_renderingToCacheCanvas:function(a,b,c,d){a||cc.log("The context of RenderTexture is invalid.");c=cc.isUndefined(c)?
1:c;d=cc.isUndefined(d)?1:d;b=b||this._currentID;var e,f,g=this._cacheToCanvasCmds[b];a.computeRealOffsetY();e=0;for(f=g.length;f>e;e++)g[e].rendering(a,c,d);g.length=0;a=this._cacheInstanceIds;delete this._cacheToCanvasCmds[b];cc.arrayRemoveObject(a,b);0===a.length?this._isCacheToCanvasOn=!1:this._currentID=a[a.length-1]},_turnToCacheMode:function(a){this._isCacheToCanvasOn=!0;a=a||0;this._cacheToCanvasCmds[a]=[];-1===this._cacheInstanceIds.indexOf(a)&&this._cacheInstanceIds.push(a);this._currentID=
a},_turnToNormalMode:function(){this._isCacheToCanvasOn=!1},resetFlag:function(){this.childrenOrderDirty=!1;this._transformNodePool.length=0},transform:function(){var a=this._transformNodePool;a.sort(this._sortNodeByLevelAsc);for(var b=0,c=a.length;c>b;b++)0!==a[b]._dirtyFlag&&a[b].updateStatus();a.length=0},transformDirty:function(){return 0<this._transformNodePool.length},_sortNodeByLevelAsc:function(a,b){return a._curLevel-b._curLevel},pushDirtyNode:function(a){this._transformNodePool.push(a)},
clearRenderCommands:function(){this._renderCmds.length=0},pushRenderCommand:function(a){if(a._needDraw)if(this._isCacheToCanvasOn){var b=this._cacheToCanvasCmds[this._currentID];-1===b.indexOf(a)&&b.push(a)}else-1===this._renderCmds.indexOf(a)&&this._renderCmds.push(a)}};cc._renderType===cc._RENDER_TYPE_CANVAS&&(cc.renderer=cc.rendererCanvas);
(function(){cc.CanvasContextWrapper=function(a){this._context=a;this._saveCount=0;this._currentAlpha=a.globalAlpha;this._currentCompositeOperation=a.globalCompositeOperation;this._currentFillStyle=a.fillStyle;this._currentStrokeStyle=a.strokeStyle;this._offsetY=this._offsetX=0;this._realOffsetY=this.height;this._armatureMode=0};var a=cc.CanvasContextWrapper.prototype;a.resetCache=function(){var a=this._context;this._currentAlpha=a.globalAlpha;this._currentCompositeOperation=a.globalCompositeOperation;
this._currentFillStyle=a.fillStyle;this._currentStrokeStyle=a.strokeStyle;this._realOffsetY=this._context.canvas.height+this._offsetY};a.setOffset=function(a,c){this._offsetX=a;this._offsetY=c;this._realOffsetY=this._context.canvas.height+this._offsetY};a.computeRealOffsetY=function(){this._realOffsetY=this._context.canvas.height+this._offsetY};a.setViewScale=function(a,c){this._scaleX=a;this._scaleY=c};a.getContext=function(){return this._context};a.save=function(){this._context.save();this._saveCount++};
a.restore=function(){this._context.restore();this._saveCount--};a.setGlobalAlpha=function(a){0<this._saveCount?this._context.globalAlpha=a:this._currentAlpha!==a&&(this._currentAlpha=a,this._context.globalAlpha=a)};a.setCompositeOperation=function(a){0<this._saveCount?this._context.globalCompositeOperation=a:this._currentCompositeOperation!==a&&(this._currentCompositeOperation=a,this._context.globalCompositeOperation=a)};a.setFillStyle=function(a){0<this._saveCount?this._context.fillStyle=a:this._currentFillStyle!==
a&&(this._currentFillStyle=a,this._context.fillStyle=a)};a.setStrokeStyle=function(a){0<this._saveCount?this._context.strokeStyle=a:this._currentStrokeStyle!==a&&(this._currentStrokeStyle=a,this._context.strokeStyle=a)};a.setTransform=function(a,c,d){0<this._armatureMode?(this.restore(),this.save(),this._context.transform(a.a,-a.b,-a.c,a.d,a.tx*c,-(a.ty*d))):this._context.setTransform(a.a,-a.b,-a.c,a.d,this._offsetX+a.tx*c,this._realOffsetY-a.ty*d)};a._switchToArmatureMode=function(a,c,d,e){a?(this._armatureMode++,
this._context.setTransform(c.a,c.c,c.b,c.d,this._offsetX+c.tx*d,this._realOffsetY-c.ty*e),this.save()):(this._armatureMode--,this.restore())}})();
cc._renderType===cc._RENDER_TYPE_WEBGL&&!function(){cc.DirectorDelegate=cc.Class.extend({updateProjection:function(){}});var a=cc.Director.prototype;a.setProjection=function(a){var c=this._winSizeInPoints;this.setViewport();var d=this._openGLView,e=d._viewPortRect.x/d._scaleX,f=d._viewPortRect.y/d._scaleY;switch(a){case cc.Director.PROJECTION_2D:cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);cc.kmGLLoadIdentity();d=cc.math.Matrix4.createOrthographicProjection(-e,c.width-e,-f,c.height-f,-1024,1024);cc.kmGLMultMatrix(d);
cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);cc.kmGLLoadIdentity();break;case cc.Director.PROJECTION_3D:var g=this.getZEye(),h=new cc.math.Matrix4,d=new cc.math.Matrix4;cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);cc.kmGLLoadIdentity();h=cc.math.Matrix4.createPerspectiveProjection(60,c.width/c.height,0.1,2*g);cc.kmGLMultMatrix(h);cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);cc.kmGLLoadIdentity();g=new cc.math.Vec3(-e+c.width/2,-f+c.height/2,g);c=new cc.math.Vec3(-e+c.width/2,-f+c.height/2,0);e=new cc.math.Vec3(0,1,0);
d.lookAt(g,c,e);cc.kmGLMultMatrix(d);break;case cc.Director.PROJECTION_CUSTOM:this._projectionDelegate&&this._projectionDelegate.updateProjection();break;default:cc.log(cc._LogInfos.Director_setProjection)}this._projection=a;cc.eventManager.dispatchEvent(this._eventProjectionChanged);cc.setProjectionMatrixDirty();cc.renderer.childrenOrderDirty=!0};a.setDepthTest=function(a){var c=cc._renderContext;a?(c.clearDepth(1),c.enable(c.DEPTH_TEST),c.depthFunc(c.LEQUAL)):c.disable(c.DEPTH_TEST)};a.setOpenGLView=
function(a){this._winSizeInPoints.width=cc._canvas.width;this._winSizeInPoints.height=cc._canvas.height;this._openGLView=a||cc.view;a=cc.configuration;a.gatherGPUInfo();a.dumpInfo();this._createStatsLabel();this.setGLDefaultValues();cc.eventManager&&cc.eventManager.setEnabled(!0)};a._clear=function(){var a=cc._renderContext;a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT)};a._beforeVisitScene=function(){cc.kmGLPushMatrix()};a._afterVisitScene=function(){cc.kmGLPopMatrix()};a._createStatsLabel=function(){if(!cc.LabelAtlas)return void this._createStatsLabelForCanvas();
if(null!=cc.Director._fpsImageLoaded&&!1!==cc.Director._fpsImageLoaded){var a=new cc.Texture2D;a.initWithElement(cc.Director._fpsImage);a.handleLoadedTexture();var c=cc.view.getDesignResolutionSize().height/320;0===c&&(c=this._winSizeInPoints.height/320);var d=new cc.LabelAtlas;d._setIgnoreContentScaleFactor(!0);d.initWithString("00.0",a,12,32,".");d.scale=c;this._FPSLabel=d;d=new cc.LabelAtlas;d._setIgnoreContentScaleFactor(!0);d.initWithString("0.000",a,12,32,".");d.scale=c;this._SPFLabel=d;d=new cc.LabelAtlas;
d._setIgnoreContentScaleFactor(!0);d.initWithString("000",a,12,32,".");d.scale=c;this._drawsLabel=d;a=cc.DIRECTOR_STATS_POSITION;this._drawsLabel.setPosition(a.x,34*c+a.y);this._SPFLabel.setPosition(a.x,17*c+a.y);this._FPSLabel.setPosition(a)}};a._createStatsLabelForCanvas=function(){var a=0,a=this._winSizeInPoints.width>this._winSizeInPoints.height?0|24*(this._winSizeInPoints.height/320):0|24*(this._winSizeInPoints.width/320);this._FPSLabel=new cc.LabelTTF("000.0","Arial",a);this._SPFLabel=new cc.LabelTTF("0.000",
"Arial",a);this._drawsLabel=new cc.LabelTTF("0000","Arial",a);a=cc.DIRECTOR_STATS_POSITION;this._drawsLabel.setPosition(this._drawsLabel.width/2+a.x,5*this._drawsLabel.height/2+a.y);this._SPFLabel.setPosition(this._SPFLabel.width/2+a.x,3*this._SPFLabel.height/2+a.y);this._FPSLabel.setPosition(this._FPSLabel.width/2+a.x,this._FPSLabel.height/2+a.y)};a.convertToGL=function(a){var c=new cc.math.Matrix4;cc.GLToClipTransform(c);var d=c.inverse(),c=c.mat[14]/c.mat[15],e=this._openGLView.getDesignResolutionSize();
a=new cc.math.Vec3(2*a.x/e.width-1,1-2*a.y/e.height,c);return a.transformCoord(d),cc.p(a.x,a.y)};a.convertToUI=function(a){var c=new cc.math.Matrix4;cc.GLToClipTransform(c);a=new cc.math.Vec3(a.x,a.y,0);a.transformCoord(c);c=this._openGLView.getDesignResolutionSize();return cc.p(c.width*(0.5*a.x+0.5),c.height*(0.5*-a.y+0.5))};a.getVisibleSize=function(){return this._openGLView.getVisibleSize()};a.getVisibleOrigin=function(){return this._openGLView.getVisibleOrigin()};a.getZEye=function(){return this._winSizeInPoints.height/
1.1566};a.setViewport=function(){var a=this._openGLView;if(a){var c=this._winSizeInPoints;a.setViewPortInPoints(-a._viewPortRect.x/a._scaleX,-a._viewPortRect.y/a._scaleY,c.width,c.height)}};a.getOpenGLView=function(){return this._openGLView};a.getProjection=function(){return this._projection};a.setAlphaBlending=function(a){a?cc.glBlendFunc(cc.BLEND_SRC,cc.BLEND_DST):cc.glBlendFunc(cc._renderContext.ONE,cc._renderContext.ZERO)};a.setGLDefaultValues=function(){this.setAlphaBlending(!0);this.setDepthTest(!1);
this.setProjection(this._projection);cc._renderContext.clearColor(0,0,0,1)}}();
cc.configuration={ERROR:0,STRING:1,INT:2,DOUBLE:3,BOOLEAN:4,_maxTextureSize:0,_maxModelviewStackDepth:0,_supportsPVRTC:!1,_supportsNPOT:!1,_supportsBGRA8888:!1,_supportsDiscardFramebuffer:!1,_supportsShareableVAO:!1,_maxSamplesAllowed:0,_maxTextureUnits:0,_GlExtensions:"",_valueDict:{},_inited:!1,_init:function(){var a=this._valueDict;a["cocos2d.x.version"]=cc.ENGINE_VERSION;a["cocos2d.x.compiled_with_profiler"]=!1;a["cocos2d.x.compiled_with_gl_state_cache"]=cc.ENABLE_GL_STATE_CACHE;this._inited=
!0},getMaxTextureSize:function(){return this._maxTextureSize},getMaxModelviewStackDepth:function(){return this._maxModelviewStackDepth},getMaxTextureUnits:function(){return this._maxTextureUnits},supportsNPOT:function(){return this._supportsNPOT},supportsPVRTC:function(){return this._supportsPVRTC},supportsETC:function(){return!1},supportsS3TC:function(){return!1},supportsATITC:function(){return!1},supportsBGRA8888:function(){return this._supportsBGRA8888},supportsDiscardFramebuffer:function(){return this._supportsDiscardFramebuffer},
supportsShareableVAO:function(){return this._supportsShareableVAO},checkForGLExtension:function(a){return-1<this._GlExtensions.indexOf(a)},getValue:function(a,b){this._inited||this._init();var c=this._valueDict;return c[a]?c[a]:b},setValue:function(a,b){this._valueDict[a]=b},dumpInfo:function(){0===cc.ENABLE_GL_STATE_CACHE&&(cc.log(""),cc.log(cc._LogInfos.configuration_dumpInfo),cc.log(""))},gatherGPUInfo:function(){if(cc._renderType!==cc._RENDER_TYPE_CANVAS){this._inited||this._init();var a=cc._renderContext,
b=this._valueDict;b["gl.vendor"]=a.getParameter(a.VENDOR);b["gl.renderer"]=a.getParameter(a.RENDERER);b["gl.version"]=a.getParameter(a.VERSION);this._GlExtensions="";for(var c=a.getSupportedExtensions(),d=0;d<c.length;d++)this._GlExtensions+=c[d]+" ";this._maxTextureSize=a.getParameter(a.MAX_TEXTURE_SIZE);b["gl.max_texture_size"]=this._maxTextureSize;this._maxTextureUnits=a.getParameter(a.MAX_COMBINED_TEXTURE_IMAGE_UNITS);b["gl.max_texture_units"]=this._maxTextureUnits;this._supportsPVRTC=this.checkForGLExtension("GL_IMG_texture_compression_pvrtc");
b["gl.supports_PVRTC"]=this._supportsPVRTC;this._supportsNPOT=!1;b["gl.supports_NPOT"]=this._supportsNPOT;this._supportsBGRA8888=this.checkForGLExtension("GL_IMG_texture_format_BGRA888");b["gl.supports_BGRA8888"]=this._supportsBGRA8888;this._supportsDiscardFramebuffer=this.checkForGLExtension("GL_EXT_discard_framebuffer");b["gl.supports_discard_framebuffer"]=this._supportsDiscardFramebuffer;this._supportsShareableVAO=this.checkForGLExtension("vertex_array_object");b["gl.supports_vertex_array_object"]=
this._supportsShareableVAO;cc.checkGLErrorDebug()}},loadConfigFile:function(a){this._inited||this._init();var b=cc.loader.getRes(a);if(!b)throw"Please load the resource first : "+a;cc.assert(b,cc._LogInfos.configuration_loadConfigFile_2,a);b=b.data;if(!b)return void cc.log(cc._LogInfos.configuration_loadConfigFile,a);for(var c in b)this._valueDict[c]=b[c]}};
cc.rendererWebGL={childrenOrderDirty:!0,_transformNodePool:[],_renderCmds:[],_isCacheToBufferOn:!1,_cacheToBufferCmds:{},_cacheInstanceIds:[],_currentID:0,getRenderCmd:function(a){return a._createRenderCmd()},rendering:function(a){var b,c=this._renderCmds,d=a||cc._renderContext;a=0;for(b=c.length;b>a;a++)c[a].rendering(d)},_turnToCacheMode:function(a){this._isCacheToBufferOn=!0;a=a||0;this._cacheToBufferCmds[a]=[];this._cacheInstanceIds.push(a);this._currentID=a},_turnToNormalMode:function(){this._isCacheToBufferOn=
!1},_renderingToBuffer:function(a){a=a||this._currentID;var b,c,d=this._cacheToBufferCmds[a],e=cc._renderContext,f=this._cacheInstanceIds;b=0;for(c=d.length;c>b;b++)d[b].rendering(e);d.length=0;delete this._cacheToBufferCmds[a];cc.arrayRemoveObject(f,a);0===f.length?this._isCacheToBufferOn=!1:this._currentID=f[f.length-1]},resetFlag:function(){this.childrenOrderDirty=!1;this._transformNodePool.length=0},transform:function(){var a=this._transformNodePool;a.sort(this._sortNodeByLevelAsc);for(var b=
0,c=a.length;c>b;b++)a[b].updateStatus();a.length=0},transformDirty:function(){return 0<this._transformNodePool.length},_sortNodeByLevelAsc:function(a,b){return a._curLevel-b._curLevel},pushDirtyNode:function(a){this._transformNodePool.push(a)},clearRenderCommands:function(){this._renderCmds.length=0},pushRenderCommand:function(a){if(a._needDraw)if(this._isCacheToBufferOn){var b=this._cacheToBufferCmds[this._currentID];-1===b.indexOf(a)&&b.push(a)}else-1===this._renderCmds.indexOf(a)&&this._renderCmds.push(a)}};
cc._renderType===cc._RENDER_TYPE_WEBGL&&(cc.renderer=cc.rendererWebGL);
(function(){cc.Node.WebGLRenderCmd=function(a){cc.Node.RenderCmd.call(this,a);a=new cc.math.Matrix4;var c=a.mat;c[2]=c[3]=c[6]=c[7]=c[8]=c[9]=c[11]=c[14]=0;c[10]=c[15]=1;this._transform4x4=a;this._stackMatrix=new cc.math.Matrix4;this._camera=this._shaderProgram=null};var a=cc.Node.WebGLRenderCmd.prototype=Object.create(cc.Node.RenderCmd.prototype);a.constructor=cc.Node.WebGLRenderCmd;a.getNodeToParentTransform=function(){var a=this._node;if(a._usingNormalizedPosition&&a._parent){var c=a._parent._contentSize;
a._position.x=a._normalizedPosition.x*c.width;a._position.y=a._normalizedPosition.y*c.height;a._normalizedPositionDirty=!1}if(this._dirtyFlag&cc.Node._dirtyFlags.transformDirty){var c=a._position.x,d=a._position.y,e=this._anchorPointInPoints.x,f=-e,g=this._anchorPointInPoints.y,h=-g,k=a._scaleX,m=a._scaleY,n=0.017453292519943295*a._rotationX,p=0.017453292519943295*a._rotationY;a._ignoreAnchorPointForPosition&&(c+=e,d+=g);var r=1,s=0,v=1,u=0;(0!==a._rotationX||0!==a._rotationY)&&(r=Math.cos(-n),s=
Math.sin(-n),v=Math.cos(-p),u=Math.sin(-p));(n=a._skewX||a._skewY)||0===e&&0===g||(c+=v*f*k+-s*h*m,d+=u*f*k+r*h*m);p=this._transform;p.a=v*k;p.b=u*k;p.c=-s*m;p.d=r*m;p.tx=c;p.ty=d;n&&(p=cc.affineTransformConcat({a:1,b:Math.tan(cc.degreesToRadians(a._skewY)),c:Math.tan(cc.degreesToRadians(a._skewX)),d:1,tx:0,ty:0},p),(0!==e||0!==g)&&(p=cc.affineTransformTranslate(p,f,h)));a._additionalTransformDirty&&(p=cc.affineTransformConcat(p,a._additionalTransform),a._additionalTransformDirty=!1);this._transform=
p}return this._transform};a._syncStatus=function(a){var c=cc.Node._dirtyFlags,d=this._dirtyFlag,e=a?a._node:null;e&&e._cascadeColorEnabled&&a._dirtyFlag&c.colorDirty&&(d|=c.colorDirty);e&&e._cascadeOpacityEnabled&&a._dirtyFlag&c.opacityDirty&&(d|=c.opacityDirty);a&&a._dirtyFlag&c.transformDirty&&(d|=c.transformDirty);e=d&c.colorDirty;c=d&c.opacityDirty;this._dirtyFlag=d;e&&this._syncDisplayColor();c&&this._syncDisplayOpacity();(e||c)&&this._updateColor();this.transform(a)};a._updateColor=function(){};
a.visit=function(a){var c=this._node;if(c._visible){a=a||this.getParentRenderCmd();c._parent&&c._parent._renderCmd&&(this._curLevel=c._parent._renderCmd._curLevel+1);var d=cc.current_stack;d.stack.push(d.top);this._syncStatus(a);d.top=this._stackMatrix;if((a=c._children)&&0<a.length){var e=a.length;c.sortAllChildren();for(c=0;e>c&&a[c]&&0>a[c]._localZOrder;c++)a[c]._renderCmd.visit(this);for(cc.renderer.pushRenderCommand(this);e>c;c++)a[c]&&a[c]._renderCmd.visit(this)}else cc.renderer.pushRenderCommand(this);
this._dirtyFlag=0;d.top=d.stack.pop()}};a.transform=function(a,c){var d=this._transform4x4,e=this._stackMatrix,f=this._node,g=(a=a||this.getParentRenderCmd())?a._stackMatrix:cc.current_stack.top,h=this.getNodeToParentTransform();this._dirtyFlag^=this._dirtyFlag&cc.Node._dirtyFlags.transformDirty;var k=d.mat;if(k[0]=h.a,k[4]=h.c,k[12]=h.tx,k[1]=h.b,k[5]=h.d,k[13]=h.ty,k[14]=f._vertexZ,cc.kmMat4Multiply(e,g,d),null!==f._camera&&(null===f.grid||!f.grid.isActive()))g=this._anchorPointInPoints.x,h=this._anchorPointInPoints.y,
0!==g||0!==h?(cc.SPRITEBATCHNODE_RENDER_SUBPIXEL||(g|=0,h|=0),k=cc.math.Matrix4.createByTranslation(g,h,0,d),e.multiply(k),f._camera._locateForRenderer(e),k=cc.math.Matrix4.createByTranslation(-g,-h,0,k),e.multiply(k),d.identity()):f._camera._locateForRenderer(e);if(c&&f._children&&0!==f._children.length){f=f._children;d=0;for(e=f.length;e>d;d++)f[d]._renderCmd.transform(this,c)}};a.setShaderProgram=function(a){this._shaderProgram=a};a.getShaderProgram=function(){return this._shaderProgram}})();
(function(){cc.Layer.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a)};var a=cc.Layer.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.Layer.WebGLRenderCmd;a.bake=function(){};a.unbake=function(){};a._bakeForAddChild=function(){}})();
(function(){cc.LayerColor.WebGLRenderCmd=function(a){cc.Layer.WebGLRenderCmd.call(this,a);this._needDraw=!0;this._squareVerticesAB=new ArrayBuffer(32);this._squareColorsAB=new ArrayBuffer(16);a=this._squareVerticesAB;var c=this._squareColorsAB,d=cc.Vertex2F.BYTES_PER_ELEMENT,e=cc.Color.BYTES_PER_ELEMENT;this._squareVertices=[new cc.Vertex2F(0,0,a,0),new cc.Vertex2F(0,0,a,d),new cc.Vertex2F(0,0,a,2*d),new cc.Vertex2F(0,0,a,3*d)];this._squareColors=[cc.color(0,0,0,255,c,0),cc.color(0,0,0,255,c,e),cc.color(0,
0,0,255,c,2*e),cc.color(0,0,0,255,c,3*e)];this._verticesFloat32Buffer=cc._renderContext.createBuffer();this._colorsUint8Buffer=cc._renderContext.createBuffer()};var a=cc.LayerColor.WebGLRenderCmd.prototype=Object.create(cc.Layer.WebGLRenderCmd.prototype);a.constructor=cc.LayerColor.WebGLRenderCmd;a.rendering=function(a){a=a||cc._renderContext;var c=this._node;this._shaderProgram.use();this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix);cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION|
cc.VERTEX_ATTRIB_FLAG_COLOR);cc.glBlendFunc(c._blendFunc.src,c._blendFunc.dst);a.bindBuffer(a.ARRAY_BUFFER,this._verticesFloat32Buffer);a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,a.FLOAT,!1,0,0);a.bindBuffer(a.ARRAY_BUFFER,this._colorsUint8Buffer);a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,a.UNSIGNED_BYTE,!0,0,0);a.drawArrays(a.TRIANGLE_STRIP,0,this._squareVertices.length)};a._updateSquareVertices=function(a,c){var d=this._squareVertices;void 0===c?(d[1].x=a.width,d[2].y=a.height,d[3].x=
a.width,d[3].y=a.height):(d[1].x=a,d[2].y=c,d[3].x=a,d[3].y=c);this._bindLayerVerticesBufferData()};a._updateSquareVerticesWidth=function(a){var c=this._squareVertices;c[1].x=a;c[3].x=a;this._bindLayerVerticesBufferData()};a._updateSquareVerticesHeight=function(a){var c=this._squareVertices;c[2].y=a;c[3].y=a;this._bindLayerVerticesBufferData()};a._updateColor=function(){for(var a=this._displayedColor,c=this._displayedOpacity,d=this._squareColors,e=0;4>e;e++)d[e].r=a.r,d[e].g=a.g,d[e].b=a.b,d[e].a=
c;this._bindLayerColorsBufferData()};a._bindLayerVerticesBufferData=function(){var a=cc._renderContext;a.bindBuffer(a.ARRAY_BUFFER,this._verticesFloat32Buffer);a.bufferData(a.ARRAY_BUFFER,this._squareVerticesAB,a.STATIC_DRAW)};a._bindLayerColorsBufferData=function(){var a=cc._renderContext;a.bindBuffer(a.ARRAY_BUFFER,this._colorsUint8Buffer);a.bufferData(a.ARRAY_BUFFER,this._squareColorsAB,a.STATIC_DRAW)};a.updateBlendFunc=function(a){}})();
(function(){cc.LayerGradient.WebGLRenderCmd=function(a){cc.LayerColor.WebGLRenderCmd.call(this,a);this._needDraw=!0;this._clipRect=new cc.Rect;this._clippingRectDirty=!1};var a=cc.LayerGradient.WebGLRenderCmd.prototype=Object.create(cc.LayerColor.WebGLRenderCmd.prototype);cc.inject(cc.LayerGradient.RenderCmd,a);a.constructor=cc.LayerGradient.WebGLRenderCmd;a._syncStatus=function(a){var c=cc.Node._dirtyFlags,d=this._dirtyFlag,e=a?a._node:null;e&&e._cascadeColorEnabled&&a._dirtyFlag&c.colorDirty&&(d|=
c.colorDirty);e&&e._cascadeOpacityEnabled&&a._dirtyFlag&c.opacityDirty&&(d|=c.opacityDirty);a&&a._dirtyFlag&c.transformDirty&&(d|=c.transformDirty);var e=d&c.colorDirty,f=d&c.opacityDirty;this._dirtyFlag=d;e&&this._syncDisplayColor();f&&this._syncDisplayOpacity();this.transform(a);(e||f||d&c.gradientDirty)&&this._updateColor()};a._updateColor=function(){this._dirtyFlag^=this._dirtyFlag&cc.Node._dirtyFlags.gradientDirty;var a=this._node,c=a._colorStops;if(c&&!(2>c.length)){this._clippingRectDirty=
!0;var d,e=c.length,f=2*e,g=a._contentSize;this._squareVerticesAB=new ArrayBuffer(8*f);this._squareColorsAB=new ArrayBuffer(4*f);var h=this._squareVertices,k=this._squareColors;h.length=0;k.length=0;var m=this._squareVerticesAB,n=this._squareColorsAB,p=cc.Vertex2F.BYTES_PER_ELEMENT,r=cc.Color.BYTES_PER_ELEMENT;for(d=0;f>d;d++)h.push(new cc.Vertex2F(0,0,m,p*d)),k.push(cc.color(0,0,0,255,n,r*d));m=Math.PI+cc.pAngleSigned(cc.p(0,-1),a._alongVector);a=cc.p(g.width/2,g.height/2);d=Math.round(cc.radiansToDegrees(m));
var f=cc.affineTransformMake(1,0,0,1,a.x,a.y),f=cc.affineTransformRotate(f,m),s,v;90>d?(s=cc.p(-a.x,a.y),v=cc.p(a.x,a.y)):180>d?(s=cc.p(a.x,a.y),v=cc.p(a.x,-a.y)):270>d?(s=cc.p(a.x,-a.y),v=cc.p(-a.x,-a.y)):(s=cc.p(-a.x,-a.y),v=cc.p(-a.x,a.y));d=Math.sin(m);m=Math.cos(m);s=Math.abs((s.x*m-s.y*d)/a.x);d=Math.abs((v.x*d+v.y*m)/a.y);f=cc.affineTransformScale(f,s,d);for(d=0;e>d;d++)v=c[d].p*g.height,s=cc.pointApplyAffineTransform(-a.x,v-a.y,f),h[2*d].x=s.x,h[2*d].y=s.y,v=cc.pointApplyAffineTransform(g.width-
a.x,v-a.y,f),h[2*d+1].x=v.x,h[2*d+1].y=v.y;g=this._displayedOpacity/255;for(d=0;e>d;d++)h=c[d].color,v=k[2*d],s=k[2*d+1],v.r=h.r,v.g=h.g,v.b=h.b,v.a=h.a*g,s.r=h.r,s.g=h.g,s.b=h.b,s.a=h.a*g;this._bindLayerVerticesBufferData();this._bindLayerColorsBufferData()}};a.rendering=function(a){a=a||cc._renderContext;var c=this._node,d=this._getClippingRect();a.enable(a.SCISSOR_TEST);cc.view.setScissorInPoints(d.x,d.y,d.width,d.height);this._shaderProgram.use();this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix);
cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION|cc.VERTEX_ATTRIB_FLAG_COLOR);cc.glBlendFunc(c._blendFunc.src,c._blendFunc.dst);a.bindBuffer(a.ARRAY_BUFFER,this._verticesFloat32Buffer);a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,a.FLOAT,!1,0,0);a.bindBuffer(a.ARRAY_BUFFER,this._colorsUint8Buffer);a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,a.UNSIGNED_BYTE,!0,0,0);a.drawArrays(a.TRIANGLE_STRIP,0,this._squareVertices.length);a.disable(a.SCISSOR_TEST)};a._getClippingRect=function(){if(this._clippingRectDirty){var a=
this._node,c=cc.rect(0,0,a._contentSize.width,a._contentSize.height),a=a.getNodeToWorldTransform();this._clipRect=cc._rectApplyAffineTransformIn(c,a)}return this._clipRect}})();
(function(){cc.Sprite.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._needDraw=!0;this._quad=new cc.V3F_C4B_T2F_Quad;this._quadWebBuffer=cc._renderContext.createBuffer();this._quadDirty=!0;this._recursiveDirty=this._dirty=!1};var a=cc.Sprite.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.Sprite.WebGLRenderCmd;a.updateBlendFunc=function(a){};a.setDirtyFlag=function(a){cc.Node.WebGLRenderCmd.prototype.setDirtyFlag.call(this,a);this._dirty=
!0};a.setDirtyRecursively=function(a){this._dirty=this._recursiveDirty=a;for(var c,d=this._node._children,e=d?d.length:0,f=0;e>f;f++)c=d[f],c instanceof cc.Sprite&&c._renderCmd.setDirtyRecursively(a)};a._setBatchNodeForAddChild=function(a){var c=this._node;if(c._batchNode){if(!(a instanceof cc.Sprite))return cc.log(cc._LogInfos.Sprite_addChild),!1;a.texture._webTextureObj!==c.textureAtlas.texture._webTextureObj&&cc.log(cc._LogInfos.Sprite_addChild_2);c._batchNode.appendChild(a);c._reorderChildDirty||
c._setReorderChildDirtyRecursively()}return!0};a._handleTextureForRotatedTexture=function(a){return a};a.isFrameDisplayed=function(a){var c=this._node;return cc.rectEqualToRect(a.getRect(),c._rect)&&a.getTexture().getName()===c._texture.getName()&&cc.pointEqualToPoint(a.getOffset(),c._unflippedOffsetPositionFromCenter)};a._init=function(){var a={r:255,g:255,b:255,a:255},c=this._quad;c.bl.colors=a;c.br.colors=a;c.tl.colors=a;c.tr.colors=a;this._quadDirty=!0};a._resetForBatchNode=function(){var a=this._node,
c=a._offsetPosition.x,d=a._offsetPosition.y,e=c+a._rect.width,a=d+a._rect.height,f=this._quad;f.bl.vertices={x:c,y:d,z:0};f.br.vertices={x:e,y:d,z:0};f.tl.vertices={x:c,y:a,z:0};f.tr.vertices={x:e,y:a,z:0};this._quadDirty=!0};a.getQuad=function(){return this._quad};a._updateForSetSpriteFrame=function(){};a._spriteFrameLoadedCallback=function(a){this.setTextureRect(a.getRect(),a.isRotated(),a.getOriginalSize());this.dispatchEvent("load")};a._textureLoadedCallback=function(a){var c=this._renderCmd;
if(!this._textureLoaded){this._textureLoaded=!0;var d=this._rect;d?cc._rectEqualToZero(d)&&(d.width=a.width,d.height=a.height):d=cc.rect(0,0,a.width,a.height);this.texture=a;this.setTextureRect(d,this._rectRotated);this.setBatchNode(this._batchNode);c._quadDirty=!0;this.dispatchEvent("load")}};a._setTextureCoords=function(a,c){void 0===c&&(c=!0);c&&(a=cc.rectPointsToPixels(a));var d=this._node,e=d._batchNode?d.textureAtlas.texture:d._texture;if(e){var f,g,h,k,m,n=e.pixelsWidth,e=e.pixelsHeight,p=
this._quad;d._rectRotated?(cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL?(f=(2*a.x+1)/(2*n),g=f+(2*a.height-2)/(2*n),h=(2*a.y+1)/(2*e),k=h+(2*a.width-2)/(2*e)):(f=a.x/n,g=(a.x+a.height)/n,h=a.y/e,k=(a.y+a.width)/e),d._flippedX&&(m=h,h=k,k=m),d._flippedY&&(m=f,f=g,g=m),p.bl.texCoords.u=f,p.bl.texCoords.v=h,p.br.texCoords.u=f,p.br.texCoords.v=k,p.tl.texCoords.u=g,p.tl.texCoords.v=h,p.tr.texCoords.u=g,p.tr.texCoords.v=k):(cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL?(f=(2*a.x+1)/(2*n),g=f+(2*a.width-2)/(2*n),h=(2*a.y+
1)/(2*e),k=h+(2*a.height-2)/(2*e)):(f=a.x/n,g=(a.x+a.width)/n,h=a.y/e,k=(a.y+a.height)/e),d._flippedX&&(m=f,f=g,g=m),d._flippedY&&(m=h,h=k,k=m),p.bl.texCoords.u=f,p.bl.texCoords.v=k,p.br.texCoords.u=g,p.br.texCoords.v=k,p.tl.texCoords.u=f,p.tl.texCoords.v=h,p.tr.texCoords.u=g,p.tr.texCoords.v=h);this._quadDirty=!0}};a.transform=function(a,c){cc.Node.WebGLRenderCmd.prototype.transform.call(this,a,c);this._dirty=!0};a._setColorDirty=function(){};a._updateColor=function(){var a=this._displayedColor,
c=this._displayedOpacity,d=this._node,a={r:a.r,g:a.g,b:a.b,a:c};d._opacityModifyRGB&&(a.r*=c/255,a.g*=c/255,a.b*=c/255);c=this._quad;c.bl.colors=a;c.br.colors=a;c.tl.colors=a;c.tr.colors=a;d._batchNode&&(d.atlasIndex!==cc.Sprite.INDEX_NOT_INITIALIZED?d.textureAtlas.updateQuad(c,d.atlasIndex):this._dirty=!0);this._quadDirty=!0};a._updateBlendFunc=function(){if(this._batchNode)return void cc.log(cc._LogInfos.Sprite__updateBlendFunc);var a=this._node;a._texture&&a._texture.hasPremultipliedAlpha()?(a._blendFunc.src=
cc.BLEND_SRC,a._blendFunc.dst=cc.BLEND_DST,a.opacityModifyRGB=!0):(a._blendFunc.src=cc.SRC_ALPHA,a._blendFunc.dst=cc.ONE_MINUS_SRC_ALPHA,a.opacityModifyRGB=!1)};a._setTexture=function(a){var c=this._node;if(c._batchNode){if(c._batchNode.texture!==a)return void cc.log(cc._LogInfos.Sprite_setTexture)}else c._texture!==a&&(c._textureLoaded=a?a._textureLoaded:!1,c._texture=a,this._updateBlendFunc());a?this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR):this._shaderProgram=
cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR)};a.updateTransform=function(){var a=this._node;if(this._dirty){var c=this._quad,d=a._parent;if(!a._visible||d&&d!==a._batchNode&&d._shouldBeHidden)c.br.vertices=c.tl.vertices=c.tr.vertices=c.bl.vertices={x:0,y:0,z:0},a._shouldBeHidden=!0;else{a._shouldBeHidden=!1;0!==this._dirtyFlag&&(this.updateStatus(),this._dirtyFlag=0);d&&d!==a._batchNode?a._transformToBatch=cc.affineTransformConcat(this.getNodeToParentTransform(),d._transformToBatch):a._transformToBatch=
this.getNodeToParentTransform();var e=a._transformToBatch,f=a._rect,d=a._offsetPosition.x,g=a._offsetPosition.y,h=d+f.width,k=g+f.height,m=e.tx,n=e.ty,p=e.a,r=e.b,s=e.d,v=-e.c,e=d*p-g*v+m,f=d*r+g*s+n,u=h*p-g*v+m,g=h*r+g*s+n,t=h*p-k*v+m,h=h*r+k*s+n,m=d*p-k*v+m,d=d*r+k*s+n,k=a._vertexZ;cc.SPRITEBATCHNODE_RENDER_SUBPIXEL||(e|=0,f|=0,u|=0,g|=0,t|=0,h|=0,m|=0,d|=0);c.bl.vertices={x:e,y:f,z:k};c.br.vertices={x:u,y:g,z:k};c.tl.vertices={x:m,y:d,z:k};c.tr.vertices={x:t,y:h,z:k}}a.textureAtlas.updateQuad(c,
a.atlasIndex);this._dirty=a._recursiveDirty=!1}a._hasChildren&&a._arrayMakeObjectsPerformSelector(a._children,cc.Node._stateCallbackType.updateTransform)};a._checkTextureBoundary=function(a,c,d){if(a&&a.url){var e,f;d?(e=c.x+c.height,f=c.y+c.width):(e=c.x+c.width,f=c.y+c.height);e>a.width&&cc.error(cc._LogInfos.RectWidth,a.url);f>a.height&&cc.error(cc._LogInfos.RectHeight,a.url)}};a.rendering=function(a){var c=this._node,d=c._texture;if((!d||d._textureLoaded)&&0!==this._displayedOpacity)if(a=a||cc._renderContext,
d?d._textureLoaded&&(this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),cc.glBlendFunc(c._blendFunc.src,c._blendFunc.dst),cc.glBindTexture2DN(0,d),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX),a.bindBuffer(a.ARRAY_BUFFER,this._quadWebBuffer),this._quadDirty&&(a.bufferData(a.ARRAY_BUFFER,this._quad.arrayBuffer,a.DYNAMIC_DRAW),this._quadDirty=!1),a.vertexAttribPointer(0,3,a.FLOAT,!1,24,0),a.vertexAttribPointer(1,4,a.UNSIGNED_BYTE,!0,24,12),
a.vertexAttribPointer(2,2,a.FLOAT,!1,24,16),a.drawArrays(a.TRIANGLE_STRIP,0,4)):(this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),cc.glBlendFunc(c._blendFunc.src,c._blendFunc.dst),cc.glBindTexture2D(null),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION|cc.VERTEX_ATTRIB_FLAG_COLOR),a.bindBuffer(a.ARRAY_BUFFER,this._quadWebBuffer),this._quadDirty&&(a.bufferData(a.ARRAY_BUFFER,this._quad.arrayBuffer,a.STATIC_DRAW),this._quadDirty=!1),a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,
3,a.FLOAT,!1,24,0),a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,a.UNSIGNED_BYTE,!0,24,12),a.drawArrays(a.TRIANGLE_STRIP,0,4)),cc.g_NumberOfDraws++,0!==cc.SPRITE_DEBUG_DRAW||c._showNode)(cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW),cc.current_stack.stack.push(cc.current_stack.top),cc.current_stack.top=this._stackMatrix,1===cc.SPRITE_DEBUG_DRAW||c._showNode)?(c=this._quad,c=[cc.p(c.tl.vertices.x,c.tl.vertices.y),cc.p(c.bl.vertices.x,c.bl.vertices.y),cc.p(c.br.vertices.x,c.br.vertices.y),cc.p(c.tr.vertices.x,
c.tr.vertices.y)],cc._drawingUtil.drawPoly(c,4,!0)):2===cc.SPRITE_DEBUG_DRAW&&(d=c.getTextureRect(),c=c.getOffsetPosition(),c=[cc.p(c.x,c.y),cc.p(c.x+d.width,c.y),cc.p(c.x+d.width,c.y+d.height),cc.p(c.x,c.y+d.height)],cc._drawingUtil.drawPoly(c,4,!0)),cc.current_stack.top=cc.current_stack.stack.pop()}})();
(function(){cc.LabelTTF.WebGLRenderCmd=function(a){cc.Sprite.WebGLRenderCmd.call(this,a);cc.LabelTTF.RenderCmd.call(this);this.setShaderProgram(cc.shaderCache.programForKey(cc.LabelTTF._SHADER_PROGRAM))};var a=cc.LabelTTF.WebGLRenderCmd.prototype=Object.create(cc.Sprite.WebGLRenderCmd.prototype);cc.inject(cc.LabelTTF.RenderCmd.prototype,a);a.constructor=cc.LabelTTF.WebGLRenderCmd;a._setColorsString=function(){this.setDirtyFlag(cc.Node._dirtyFlags.textDirty);var a=this._node,c=a._strokeColor,d=a._textFillColor,
e=a._shadowColor||this._displayedColor;this._shadowColorStr="rgba("+(0|e.r)+","+(0|e.g)+","+(0|e.b)+","+a._shadowOpacity+")";this._fillColorStr="rgba("+(0|d.r)+","+(0|d.g)+","+(0|d.b)+", 1)";this._strokeColorStr="rgba("+(0|c.r)+","+(0|c.g)+","+(0|c.b)+", 1)"};a.updateStatus=function(){var a=cc.Node._dirtyFlags,c=this._dirtyFlag,d=c&a.colorDirty,e=c&a.opacityDirty;d&&this._updateDisplayColor();e&&this._updateDisplayOpacity();d||e?(this._setColorsString(),this._updateColor(),this._updateTexture()):
c&a.textDirty&&this._updateTexture();this._dirtyFlag&a.transformDirty&&(this.transform(this.getParentRenderCmd(),!0),this._dirtyFlag^=this._dirtyFlag&cc.Node._dirtyFlags.transformDirty)};a._syncStatus=function(a){var c=cc.Node._dirtyFlags,d=this._dirtyFlag,e=a?a._node:null;e&&e._cascadeColorEnabled&&a._dirtyFlag&c.colorDirty&&(d|=c.colorDirty);e&&e._cascadeOpacityEnabled&&a._dirtyFlag&c.opacityDirty&&(d|=c.opacityDirty);a&&a._dirtyFlag&c.transformDirty&&(d|=c.transformDirty);var e=d&c.colorDirty,
f=d&c.opacityDirty;this._dirtyFlag=d;e&&this._syncDisplayColor();f&&this._syncDisplayOpacity();e||f?(this._setColorsString(),this._updateColor(),this._updateTexture()):d&c.textDirty&&this._updateTexture();this.transform(a)}})();
cc.DrawingPrimitiveWebGL=cc.Class.extend({_renderContext:null,_initialized:!1,_shader:null,_colorLocation:-1,_colorArray:null,_pointSizeLocation:-1,_pointSize:-1,ctor:function(a){if(null==a&&(a=cc._renderContext),!a instanceof WebGLRenderingContext)throw"Can't initialise DrawingPrimitiveWebGL. context need is WebGLRenderingContext";this._renderContext=a;this._colorArray=new Float32Array([1,1,1,1])},lazy_init:function(){this._initialized||(this._shader=cc.shaderCache.programForKey(cc.SHADER_POSITION_UCOLOR),
this._colorLocation=this._renderContext.getUniformLocation(this._shader.getProgram(),"u_color"),this._pointSizeLocation=this._renderContext.getUniformLocation(this._shader.getProgram(),"u_pointSize"),this._initialized=!0)},drawInit:function(){this._initialized=!1},drawPoint:function(a){this.lazy_init();var b=this._renderContext;this._shader.use();this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);b.uniform4fv(this._colorLocation,
this._colorArray);this._shader.setUniformLocationWith1f(this._pointSizeLocation,this._pointSize);var c=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,c);b.bufferData(b.ARRAY_BUFFER,new Float32Array([a.x,a.y]),b.STATIC_DRAW);b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,b.FLOAT,!1,0,0);b.drawArrays(b.POINTS,0,1);b.deleteBuffer(c);cc.incrementGLDraws(1)},drawPoints:function(a,b){if(a&&0!==a.length){this.lazy_init();var c=this._renderContext;this._shader.use();this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);c.uniform4fv(this._colorLocation,this._colorArray);this._shader.setUniformLocationWith1f(this._pointSizeLocation,this._pointSize);var d=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,d);c.bufferData(c.ARRAY_BUFFER,this._pointsToTypeArray(a),c.STATIC_DRAW);c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,c.FLOAT,!1,0,0);c.drawArrays(c.POINTS,0,a.length);c.deleteBuffer(d);cc.incrementGLDraws(1)}},_pointsToTypeArray:function(a){for(var b=new Float32Array(2*
a.length),c=0;c<a.length;c++)b[2*c]=a[c].x,b[2*c+1]=a[c].y;return b},drawLine:function(a,b){this.lazy_init();var c=this._renderContext;this._shader.use();this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);c.uniform4fv(this._colorLocation,this._colorArray);var d=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,d);c.bufferData(c.ARRAY_BUFFER,this._pointsToTypeArray([a,b]),c.STATIC_DRAW);c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,
2,c.FLOAT,!1,0,0);c.drawArrays(c.LINES,0,2);c.deleteBuffer(d);cc.incrementGLDraws(1)},drawRect:function(a,b){this.drawLine(cc.p(a.x,a.y),cc.p(b.x,a.y));this.drawLine(cc.p(b.x,a.y),cc.p(b.x,b.y));this.drawLine(cc.p(b.x,b.y),cc.p(a.x,b.y));this.drawLine(cc.p(a.x,b.y),cc.p(a.x,a.y))},drawSolidRect:function(a,b,c){a=[a,cc.p(b.x,a.y),b,cc.p(a.x,b.y)];this.drawSolidPoly(a,4,c)},drawPoly:function(a,b,c){this.lazy_init();b=this._renderContext;this._shader.use();this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);b.uniform4fv(this._colorLocation,this._colorArray);var d=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,d);b.bufferData(b.ARRAY_BUFFER,this._pointsToTypeArray(a),b.STATIC_DRAW);b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,b.FLOAT,!1,0,0);c?b.drawArrays(b.LINE_LOOP,0,a.length):b.drawArrays(b.LINE_STRIP,0,a.length);b.deleteBuffer(d);cc.incrementGLDraws(1)},drawSolidPoly:function(a,b,c){this.lazy_init();c&&this.setDrawColor(c.r,c.g,c.b,c.a);
b=this._renderContext;this._shader.use();this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);b.uniform4fv(this._colorLocation,this._colorArray);c=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,c);b.bufferData(b.ARRAY_BUFFER,this._pointsToTypeArray(a),b.STATIC_DRAW);b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,b.FLOAT,!1,0,0);b.drawArrays(b.TRIANGLE_FAN,0,a.length);b.deleteBuffer(c);cc.incrementGLDraws(1)},drawCircle:function(a,
b,c,d,e){this.lazy_init();var f=1;e&&f++;var g=2*Math.PI/d;if(e=new Float32Array(2*(d+2))){for(var h=0;d>=h;h++){var k=h*g,m=b*Math.cos(k+c)+a.x,k=b*Math.sin(k+c)+a.y;e[2*h]=m;e[2*h+1]=k}e[2*(d+1)]=a.x;e[2*(d+1)+1]=a.y;a=this._renderContext;this._shader.use();this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);a.uniform4fv(this._colorLocation,this._colorArray);b=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,b);a.bufferData(a.ARRAY_BUFFER,
e,a.STATIC_DRAW);a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,a.FLOAT,!1,0,0);a.drawArrays(a.LINE_STRIP,0,d+f);a.deleteBuffer(b);cc.incrementGLDraws(1)}},drawQuadBezier:function(a,b,c,d){this.lazy_init();for(var e=new Float32Array(2*(d+1)),f=0,g=0;d>g;g++)e[2*g]=Math.pow(1-f,2)*a.x+2*(1-f)*f*b.x+f*f*c.x,e[2*g+1]=Math.pow(1-f,2)*a.y+2*(1-f)*f*b.y+f*f*c.y,f+=1/d;e[2*d]=c.x;e[2*d+1]=c.y;a=this._renderContext;this._shader.use();this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
a.uniform4fv(this._colorLocation,this._colorArray);b=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,b);a.bufferData(a.ARRAY_BUFFER,e,a.STATIC_DRAW);a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,a.FLOAT,!1,0,0);a.drawArrays(a.LINE_STRIP,0,d+1);a.deleteBuffer(b);cc.incrementGLDraws(1)},drawCubicBezier:function(a,b,c,d,e){this.lazy_init();for(var f=new Float32Array(2*(e+1)),g=0,h=0;e>h;h++)f[2*h]=Math.pow(1-g,3)*a.x+3*Math.pow(1-g,2)*g*b.x+3*(1-g)*g*g*c.x+g*g*g*d.x,f[2*h+1]=Math.pow(1-g,3)*a.y+3*Math.pow(1-
g,2)*g*b.y+3*(1-g)*g*g*c.y+g*g*g*d.y,g+=1/e;f[2*e]=d.x;f[2*e+1]=d.y;a=this._renderContext;this._shader.use();this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);a.uniform4fv(this._colorLocation,this._colorArray);b=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,b);a.bufferData(a.ARRAY_BUFFER,f,a.STATIC_DRAW);a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,a.FLOAT,!1,0,0);a.drawArrays(a.LINE_STRIP,0,e+1);a.deleteBuffer(b);cc.incrementGLDraws(1)},
drawCatmullRom:function(a,b){this.drawCardinalSpline(a,0.5,b)},drawCardinalSpline:function(a,b,c){this.lazy_init();for(var d,e,f=new Float32Array(2*(c+1)),g=1/a.length,h=0;c+1>h;h++){var k=h/c;1===k?(d=a.length-1,e=1):(d=0|k/g,e=(k-g*d)/g);k=cc.cardinalSplineAt(cc.getControlPointAt(a,d-1),cc.getControlPointAt(a,d),cc.getControlPointAt(a,d+1),cc.getControlPointAt(a,d+2),b,e);f[2*h]=k.x;f[2*h+1]=k.y}a=this._renderContext;this._shader.use();this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);a.uniform4fv(this._colorLocation,this._colorArray);b=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,b);a.bufferData(a.ARRAY_BUFFER,f,a.STATIC_DRAW);a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,a.FLOAT,!1,0,0);a.drawArrays(a.LINE_STRIP,0,c+1);a.deleteBuffer(b);cc.incrementGLDraws(1)},setDrawColor:function(a,b,c,d){this._colorArray[0]=a/255;this._colorArray[1]=b/255;this._colorArray[2]=c/255;this._colorArray[3]=d/255},setPointSize:function(a){this._pointSize=
a*cc.contentScaleFactor()},setLineWidth:function(a){this._renderContext.lineWidth&&this._renderContext.lineWidth(a)}});_p=cc.inputManager;_p.setAccelerometerEnabled=function(a){this._accelEnabled!==a&&(this._accelEnabled=a,a=cc.director.getScheduler(),this._accelCurTime=0,a.scheduleUpdate(this))};_p.setAccelerometerInterval=function(a){this._accelInterval!==a&&(this._accelInterval=a)};
_p._registerKeyboardEvent=function(){cc._addEventListener(cc._canvas,"keydown",function(a){cc.eventManager.dispatchEvent(new cc.EventKeyboard(a.keyCode,!0));a.stopPropagation();a.preventDefault()},!1);cc._addEventListener(cc._canvas,"keyup",function(a){cc.eventManager.dispatchEvent(new cc.EventKeyboard(a.keyCode,!1));a.stopPropagation();a.preventDefault()},!1)};
_p._registerAccelerometerEvent=function(){var a=window;this._acceleration=new cc.Acceleration;this._accelDeviceEvent=a.DeviceMotionEvent||a.DeviceOrientationEvent;cc.sys.browserType===cc.sys.BROWSER_TYPE_MOBILE_QQ&&(this._accelDeviceEvent=window.DeviceOrientationEvent);var b=this._accelDeviceEvent===a.DeviceMotionEvent?"devicemotion":"deviceorientation",c=navigator.userAgent;(/Android/.test(c)||/Adr/.test(c)&&cc.sys.browserType===cc.BROWSER_TYPE_UC)&&(this._minus=-1);cc._addEventListener(a,b,this.didAccelerate.bind(this),
!1)};
_p.didAccelerate=function(a){var b=window;if(this._accelEnabled){var c,d,e,f=this._acceleration;this._accelDeviceEvent===window.DeviceMotionEvent?(e=a.accelerationIncludingGravity,c=0.1*this._accelMinus*e.x,d=0.1*this._accelMinus*e.y,e=0.1*e.z):(c=0.981*(a.gamma/90),d=0.981*-(a.beta/90),e=0.981*(a.alpha/90));cc.sys.os===cc.sys.OS_ANDROID?(f.x=-c,f.y=-d):(f.x=c,f.y=d);f.z=e;f.timestamp=a.timeStamp||Date.now();a=f.x;b.orientation===cc.UIInterfaceOrientationLandscapeRight?(f.x=-f.y,f.y=a):b.orientation===cc.UIInterfaceOrientationLandscapeLeft?
(f.x=f.y,f.y=-a):b.orientation===cc.UIInterfaceOrientationPortraitUpsideDown&&(f.x=-f.x,f.y=-f.y)}};delete _p;
cc.vertexLineToPolygon=function(a,b,c,d,e){if(e+=d,!(1>=e)){b*=0.5;for(var f,g=e-1,h=d;e>h;h++){f=2*h;var k,m=cc.p(a[2*h],a[2*h+1]);if(0===h)k=cc.pPerp(cc.pNormalize(cc.pSub(m,cc.p(a[2*(h+1)],a[2*(h+1)+1]))));else if(h===g)k=cc.pPerp(cc.pNormalize(cc.pSub(cc.p(a[2*(h-1)],a[2*(h-1)+1]),m)));else{k=cc.p(a[2*(h-1)],a[2*(h-1)+1]);var n=cc.p(a[2*(h+1)],a[2*(h+1)+1]),p=cc.pNormalize(cc.pSub(n,m)),r=cc.pNormalize(cc.pSub(k,m)),s=Math.acos(cc.pDot(p,r));k=s<cc.degreesToRadians(70)?cc.pPerp(cc.pNormalize(cc.pMidpoint(p,
r))):s<cc.degreesToRadians(170)?cc.pNormalize(cc.pMidpoint(p,r)):cc.pPerp(cc.pNormalize(cc.pSub(n,k)))}k=cc.pMult(k,b);c[2*f]=m.x+k.x;c[2*f+1]=m.y+k.y;c[2*(f+1)]=m.x-k.x;c[2*(f+1)+1]=m.y-k.y}for(h=0===d?0:d-1;g>h;h++)f=2*h,a=f+2,b=cc.vertex2(c[2*f],c[2*f+1]),e=cc.vertex2(c[2*(f+1)],c[2*(f+1)+1]),f=cc.vertex2(c[2*a],c[2*a]),d=cc.vertex2(c[2*(a+1)],c[2*(a+1)+1]),b=!cc.vertexLineIntersect(b.x,b.y,d.x,d.y,e.x,e.y,f.x,f.y),b.isSuccess||(0>b.value||1<b.value)&&(b.isSuccess=!0),b.isSuccess&&(c[2*a]=d.x,
c[2*a+1]=d.y,c[2*(a+1)]=f.x,c[2*(a+1)+1]=f.y)}};cc.vertexLineIntersect=function(a,b,c,d,e,f,g,h){var k,m,n,p;return a===c&&b===d||e===g&&f===h||(c-=a,d-=b,e-=a,f-=b,g-=a,h-=b,k=Math.sqrt(c*c+d*d),m=c/k,n=d/k,p=e*m+f*n,f=f*m-e*n,e=p,p=g*m+h*n,h=h*m-g*n,g=p,f===h)?{isSuccess:!1,value:0}:{isSuccess:!0,value:(g+(e-g)*h/(h-f))/k}};cc.vertexListIsClockwise=function(a){for(var b=0,c=a.length;c>b;b++){var d=a[(b+1)%c],e=a[(b+2)%c];if(0<cc.pCross(cc.pSub(d,a[b]),cc.pSub(e,d)))return!1}return!0};
cc.CGAffineToGL=function(a,b){b[2]=b[3]=b[6]=b[7]=b[8]=b[9]=b[11]=b[14]=0;b[10]=b[15]=1;b[0]=a.a;b[4]=a.c;b[12]=a.tx;b[1]=a.b;b[5]=a.d;b[13]=a.ty};cc.GLToCGAffine=function(a,b){b.a=a[0];b.c=a[4];b.tx=a[12];b.b=a[1];b.d=a[5];b.ty=a[13]};cc.EventAcceleration=cc.Event.extend({_acc:null,ctor:function(a){cc.Event.prototype.ctor.call(this,cc.Event.ACCELERATION);this._acc=a}});
cc.EventKeyboard=cc.Event.extend({_keyCode:0,_isPressed:!1,ctor:function(a,b){cc.Event.prototype.ctor.call(this,cc.Event.KEYBOARD);this._keyCode=a;this._isPressed=b}});
cc._EventListenerAcceleration=cc.EventListener.extend({_onAccelerationEvent:null,ctor:function(a){this._onAccelerationEvent=a;var b=this;cc.EventListener.prototype.ctor.call(this,cc.EventListener.ACCELERATION,cc._EventListenerAcceleration.LISTENER_ID,function(a){b._onAccelerationEvent(a._acc,a)})},checkAvailable:function(){return cc.assert(this._onAccelerationEvent,cc._LogInfos._EventListenerAcceleration_checkAvailable),!0},clone:function(){return new cc._EventListenerAcceleration(this._onAccelerationEvent)}});
cc._EventListenerAcceleration.LISTENER_ID="__cc_acceleration";cc._EventListenerAcceleration.create=function(a){return new cc._EventListenerAcceleration(a)};
cc._EventListenerKeyboard=cc.EventListener.extend({onKeyPressed:null,onKeyReleased:null,ctor:function(){var a=this;cc.EventListener.prototype.ctor.call(this,cc.EventListener.KEYBOARD,cc._EventListenerKeyboard.LISTENER_ID,function(b){b._isPressed?a.onKeyPressed&&a.onKeyPressed(b._keyCode,b):a.onKeyReleased&&a.onKeyReleased(b._keyCode,b)})},clone:function(){var a=new cc._EventListenerKeyboard;return a.onKeyPressed=this.onKeyPressed,a.onKeyReleased=this.onKeyReleased,a},checkAvailable:function(){return null===
this.onKeyPressed&&null===this.onKeyReleased?(cc.log(cc._LogInfos._EventListenerKeyboard_checkAvailable),!1):!0}});cc._EventListenerKeyboard.LISTENER_ID="__cc_keyboard";cc._EventListenerKeyboard.create=function(){return new cc._EventListenerKeyboard};
cc.AtlasNode=cc.Node.extend({textureAtlas:null,quadsToDraw:0,_itemsPerRow:0,_itemsPerColumn:0,_itemWidth:0,_itemHeight:0,_opacityModifyRGB:!1,_blendFunc:null,_ignoreContentScaleFactor:!1,_className:"AtlasNode",_textureForCanvas:null,ctor:function(a,b,c,d){cc.Node.prototype.ctor.call(this);this._blendFunc={src:cc.BLEND_SRC,dst:cc.BLEND_DST};this._ignoreContentScaleFactor=!1;void 0!==d&&this.initWithTileFile(a,b,c,d)},_createRenderCmd:function(){cc._renderType===cc._RENDER_TYPE_CANVAS?this._renderCmd=
new cc.AtlasNode.CanvasRenderCmd(this):this._renderCmd=new cc.AtlasNode.WebGLRenderCmd(this)},updateAtlasValues:function(){cc.log(cc._LogInfos.AtlasNode_updateAtlasValues)},getColor:function(){return this._opacityModifyRGB?this._renderCmd._colorUnmodified:cc.Node.prototype.getColor.call(this)},setOpacityModifyRGB:function(a){var b=this.color;this._opacityModifyRGB=a;this.setColor(b)},isOpacityModifyRGB:function(){return this._opacityModifyRGB},getBlendFunc:function(){return this._blendFunc},setBlendFunc:function(a,
b){void 0===b?this._blendFunc=a:this._blendFunc={src:a,dst:b}},setTextureAtlas:function(a){this.textureAtlas=a},getTextureAtlas:function(){return this.textureAtlas},getQuadsToDraw:function(){return this.quadsToDraw},setQuadsToDraw:function(a){this.quadsToDraw=a},initWithTileFile:function(a,b,c,d){if(!a)throw"cc.AtlasNode.initWithTileFile(): title should not be null";a=cc.textureCache.addImage(a);return this.initWithTexture(a,b,c,d)},initWithTexture:function(a,b,c,d){return this._renderCmd.initWithTexture(a,
b,c,d)},setColor:function(a){this._renderCmd.setColor(a)},setOpacity:function(a){this._renderCmd.setOpacity(a)},getTexture:function(){return this._renderCmd.getTexture()},setTexture:function(a){this._renderCmd.setTexture(a)},_setIgnoreContentScaleFactor:function(a){this._ignoreContentScaleFactor=a}});_p=cc.AtlasNode.prototype;cc.defineGetterSetter(_p,"opacity",_p.getOpacity,_p.setOpacity);cc.defineGetterSetter(_p,"color",_p.getColor,_p.setColor);_p.texture;
cc.defineGetterSetter(_p,"texture",_p.getTexture,_p.setTexture);_p.textureAtlas;_p.quadsToDraw;cc.EventHelper.prototype.apply(_p);cc.AtlasNode.create=function(a,b,c,d){return new cc.AtlasNode(a,b,c,d)};
(function(){cc.AtlasNode.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._needDraw=!1;this._colorUnmodified=cc.color.WHITE;this._texture=this._originalTexture=null};var a=cc.AtlasNode.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.AtlasNode.CanvasRenderCmd;a.initWithTexture=function(a,c,d,e){var f=this._node;return f._itemWidth=c,f._itemHeight=d,f._opacityModifyRGB=!0,this._originalTexture=a,this._originalTexture?(this._texture=this._originalTexture,
this._calculateMaxItems(),f.quadsToDraw=e,!0):(cc.log(cc._LogInfos.AtlasNode__initWithTexture),!1)};a.setColor=function(a){var c=this._node._realColor;(c.r!==a.r||c.g!==a.g||c.b!==a.b)&&(this._colorUnmodified=a,this._changeTextureColor())};cc.sys._supportCanvasNewBlendModes?a._changeTextureColor=function(){var a=this._node,c=a.getTexture();if(c&&this._originalTexture){var d=this._originalTexture.getHtmlElementObj();if(d){var e=c.getHtmlElementObj(),f=cc.rect(0,0,d.width,d.height);e instanceof HTMLCanvasElement?
cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(d,this._colorUnmodified,f,e):(e=cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(d,this._colorUnmodified,f),c=new cc.Texture2D,c.initWithElement(e),c.handleLoadedTexture(),a.setTexture(c))}}}:a._changeTextureColor=function(){var a,c=this._node,d=c.getTexture();if(d&&this._originalTexture&&!(a=d.getHtmlElementObj(),!a)){var e=this._originalTexture.getHtmlElementObj(),f=cc.textureCache.getTextureColors(e);f&&(e=cc.rect(0,0,e.width,e.height),
a instanceof HTMLCanvasElement?cc.Sprite.CanvasRenderCmd._generateTintImage(a,f,this._displayedColor,e,a):(a=cc.Sprite.CanvasRenderCmd._generateTintImage(a,f,this._displayedColor,e),d=new cc.Texture2D,d.initWithElement(a),d.handleLoadedTexture(),c.setTexture(d)))}};a.setOpacity=function(a){cc.Node.prototype.setOpacity.call(this._node,a)};a.getTexture=function(){return this._texture};a.setTexture=function(a){this._texture=a};a._calculateMaxItems=function(){var a=this._node,c=this._texture.getContentSize();
a._itemsPerColumn=0|c.height/a._itemHeight;a._itemsPerRow=0|c.width/a._itemWidth}})();
cc.TextureAtlas=cc.Class.extend({dirty:!1,texture:null,_indices:null,_buffersVBO:null,_capacity:0,_quads:null,_quadsArrayBuffer:null,_quadsWebBuffer:null,_quadsReader:null,ctor:function(a,b){this._buffersVBO=[];cc.isString(a)?this.initWithFile(a,b):a instanceof cc.Texture2D&&this.initWithTexture(a,b)},getTotalQuads:function(){return this._totalQuads},getCapacity:function(){return this._capacity},getTexture:function(){return this.texture},setTexture:function(a){this.texture=a},setDirty:function(a){this.dirty=
a},isDirty:function(){return this.dirty},getQuads:function(){return this._quads},setQuads:function(a){this._quads=a},_copyQuadsToTextureAtlas:function(a,b){if(a)for(var c=0;c<a.length;c++)this._setQuadToArray(a[c],b+c)},_setQuadToArray:function(a,b){var c=this._quads;return c[b]?(c[b].bl=a.bl,c[b].br=a.br,c[b].tl=a.tl,void(c[b].tr=a.tr)):void(c[b]=new cc.V3F_C4B_T2F_Quad(a.tl,a.bl,a.tr,a.br,this._quadsArrayBuffer,b*cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT))},description:function(){return"\x3ccc.TextureAtlas | totalQuads \x3d"+
this._totalQuads+"\x3e"},_setupIndices:function(){if(0!==this._capacity)for(var a=this._indices,b=this._capacity,c=0;b>c;c++)cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP?(a[6*c+0]=4*c+0,a[6*c+1]=4*c+0,a[6*c+2]=4*c+2,a[6*c+3]=4*c+1,a[6*c+4]=4*c+3,a[6*c+5]=4*c+3):(a[6*c+0]=4*c+0,a[6*c+1]=4*c+1,a[6*c+2]=4*c+2,a[6*c+3]=4*c+3,a[6*c+4]=4*c+2,a[6*c+5]=4*c+1)},_setupVBO:function(){var a=cc._renderContext;this._buffersVBO[0]=a.createBuffer();this._buffersVBO[1]=a.createBuffer();this._quadsWebBuffer=a.createBuffer();
this._mapBuffers()},_mapBuffers:function(){var a=cc._renderContext;a.bindBuffer(a.ARRAY_BUFFER,this._quadsWebBuffer);a.bufferData(a.ARRAY_BUFFER,this._quadsArrayBuffer,a.DYNAMIC_DRAW);a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this._buffersVBO[1]);a.bufferData(a.ELEMENT_ARRAY_BUFFER,this._indices,a.STATIC_DRAW)},initWithFile:function(a,b){var c=cc.textureCache.addImage(a);return c?this.initWithTexture(c,b):(cc.log(cc._LogInfos.TextureAtlas_initWithFile,a),!1)},initWithTexture:function(a,b){cc.assert(a,cc._LogInfos.TextureAtlas_initWithTexture);
this._capacity=b|=0;this._totalQuads=0;this.texture=a;this._quads=[];this._indices=new Uint16Array(6*b);var c=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;if(this._quadsArrayBuffer=new ArrayBuffer(c*b),this._quadsReader=new Uint8Array(this._quadsArrayBuffer),(!this._quads||!this._indices)&&0<b)return!1;for(var d=this._quads,e=0;b>e;e++)d[e]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,this._quadsArrayBuffer,e*c);return this._setupIndices(),this._setupVBO(),this.dirty=!0,!0},updateQuad:function(a,b){cc.assert(a,
cc._LogInfos.TextureAtlas_updateQuad);cc.assert(0<=b&&b<this._capacity,cc._LogInfos.TextureAtlas_updateQuad_2);this._totalQuads=Math.max(b+1,this._totalQuads);this._setQuadToArray(a,b);this.dirty=!0},insertQuad:function(a,b){if(cc.assert(b<this._capacity,cc._LogInfos.TextureAtlas_insertQuad_2),this._totalQuads++,this._totalQuads>this._capacity)return void cc.log(cc._LogInfos.TextureAtlas_insertQuad);var c=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,d=b*c,e=(this._totalQuads-1-b)*c;this._quads[this._totalQuads-
1]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,this._quadsArrayBuffer,(this._totalQuads-1)*c);this._quadsReader.set(this._quadsReader.subarray(d,d+e),d+c);this._setQuadToArray(a,b);this.dirty=!0},insertQuads:function(a,b,c){c=c||a.length;cc.assert(b+c<=this._capacity,cc._LogInfos.TextureAtlas_insertQuads);var d=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;if(this._totalQuads+=c,this._totalQuads>this._capacity)return void cc.log(cc._LogInfos.TextureAtlas_insertQuad);var e,f=b*d,g=(this._totalQuads-1-b-c)*
d,h=this._totalQuads-1-c;for(e=0;c>e;e++)this._quads[h+e]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,this._quadsArrayBuffer,(this._totalQuads-1)*d);this._quadsReader.set(this._quadsReader.subarray(f,f+g),f+d*c);for(e=0;c>e;e++)this._setQuadToArray(a[e],b+e);this.dirty=!0},insertQuadFromIndex:function(a,b){if(a!==b){cc.assert(0<=b||b<this._totalQuads,cc._LogInfos.TextureAtlas_insertQuadFromIndex);cc.assert(0<=a||a<this._totalQuads,cc._LogInfos.TextureAtlas_insertQuadFromIndex_2);var c,d,e=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
f=this._quadsReader,g=f.subarray(a*e,e);a>b?(c=b*e,d=(a-b)*e,f.set(f.subarray(c,c+d),c+e),f.set(g,c)):(c=(a+1)*e,d=(b-a)*e,f.set(f.subarray(c,c+d),c-e),f.set(g,b*e));this.dirty=!0}},removeQuadAtIndex:function(a){cc.assert(a<this._totalQuads,cc._LogInfos.TextureAtlas_removeQuadAtIndex);var b=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;if(this._totalQuads--,this._quads.length=this._totalQuads,a!==this._totalQuads){var c=(a+1)*b;this._quadsReader.set(this._quadsReader.subarray(c,c+(this._totalQuads-a)*b),
c-b)}this.dirty=!0},removeQuadsAtIndex:function(a,b){if(cc.assert(a+b<=this._totalQuads,cc._LogInfos.TextureAtlas_removeQuadsAtIndex),this._totalQuads-=b,a!==this._totalQuads){var c=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,d=(a+b)*c;this._quadsReader.set(this._quadsReader.subarray(d,d+(this._totalQuads-a)*c),a*c)}this.dirty=!0},removeAllQuads:function(){this._totalQuads=this._quads.length=0},_setDirty:function(a){this.dirty=a},resizeCapacity:function(a){if(a===this._capacity)return!0;var b=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
c=this._capacity;this._totalQuads=Math.min(this._totalQuads,a);var d=this._capacity=0|a,e=this._totalQuads;if(null===this._quads){this._quads=[];this._quadsArrayBuffer=new ArrayBuffer(b*d);this._quadsReader=new Uint8Array(this._quadsArrayBuffer);for(a=0;d>a;a++)this._quads=new cc.V3F_C4B_T2F_Quad(null,null,null,null,this._quadsArrayBuffer,a*b)}else{var f,g,h=this._quads;if(d>c){f=[];g=new ArrayBuffer(b*d);for(a=0;e>a;a++)f[a]=new cc.V3F_C4B_T2F_Quad(h[a].tl,h[a].bl,h[a].tr,h[a].br,g,a*b);for(;d>a;a++)f[a]=
new cc.V3F_C4B_T2F_Quad(null,null,null,null,g,a*b)}else{e=Math.max(e,d);f=[];g=new ArrayBuffer(b*d);for(a=0;e>a;a++)f[a]=new cc.V3F_C4B_T2F_Quad(h[a].tl,h[a].bl,h[a].tr,h[a].br,g,a*b)}this._quadsReader=new Uint8Array(g);this._quads=f;this._quadsArrayBuffer=g}null===this._indices?this._indices=new Uint16Array(6*d):d>c?(b=new Uint16Array(6*d),b.set(this._indices,0),this._indices=b):this._indices=this._indices.subarray(0,6*d);return this._setupIndices(),this._mapBuffers(),this.dirty=!0,!0},increaseTotalQuadsWith:function(a){this._totalQuads+=
a},moveQuadsFromIndex:function(a,b,c){if(void 0===c){if(c=b,b=this._totalQuads-a,cc.assert(c+(this._totalQuads-a)<=this._capacity,cc._LogInfos.TextureAtlas_moveQuadsFromIndex),0===b)return}else if(cc.assert(c+b<=this._totalQuads,cc._LogInfos.TextureAtlas_moveQuadsFromIndex_2),cc.assert(a<this._totalQuads,cc._LogInfos.TextureAtlas_moveQuadsFromIndex_3),a===c)return;var d,e,f=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,g=a*f,h=b*f,k=this._quadsReader,m=k.subarray(g,g+h),n=c*f;a>c?(d=(a-c)*f,e=c*f,k.set(k.subarray(e,
e+d),e+h)):(d=(c-a)*f,e=(a+b)*f,k.set(k.subarray(e,e+d),g));k.set(m,n);this.dirty=!0},fillWithEmptyQuadsFromIndex:function(a,b){for(var c=b*cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,d=new Uint8Array(this._quadsArrayBuffer,a*cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,c),e=0;c>e;e++)d[e]=0},drawQuads:function(){this.drawNumberOfQuads(this._totalQuads,0)},_releaseBuffer:function(){var a=cc._renderContext;this._buffersVBO&&(this._buffersVBO[0]&&a.deleteBuffer(this._buffersVBO[0]),this._buffersVBO[1]&&a.deleteBuffer(this._buffersVBO[1]));
this._quadsWebBuffer&&a.deleteBuffer(this._quadsWebBuffer)}});_p=cc.TextureAtlas.prototype;_p.totalQuads;cc.defineGetterSetter(_p,"totalQuads",_p.getTotalQuads);_p.capacity;cc.defineGetterSetter(_p,"capacity",_p.getCapacity);_p.quads;cc.defineGetterSetter(_p,"quads",_p.getQuads,_p.setQuads);cc.TextureAtlas.create=function(a,b){return new cc.TextureAtlas(a,b)};cc.TextureAtlas.createWithTexture=cc.TextureAtlas.create;
cc._renderType===cc._RENDER_TYPE_WEBGL&&(cc.assert(cc.isFunction(cc._tmp.WebGLTextureAtlas),cc._LogInfos.MissingFile,"TexturesWebGL.js"),cc._tmp.WebGLTextureAtlas(),delete cc._tmp.WebGLTextureAtlas);cc.assert(cc.isFunction(cc._tmp.PrototypeTextureAtlas),cc._LogInfos.MissingFile,"TexturesPropertyDefine.js");cc._tmp.PrototypeTextureAtlas();delete cc._tmp.PrototypeTextureAtlas;
cc.Camera=cc.Class.extend({_eyeX:null,_eyeY:null,_eyeZ:null,_centerX:null,_centerY:null,_centerZ:null,_upX:null,_upY:null,_upZ:null,_dirty:!1,_lookupMatrix:null,ctor:function(){this._lookupMatrix=new cc.math.Matrix4;this.restore()},description:function(){return"\x3cCCCamera | center \x3d("+this._centerX+","+this._centerY+","+this._centerZ+")\x3e"},setDirty:function(a){this._dirty=a},isDirty:function(){return this._dirty},restore:function(){this._eyeX=this._eyeY=0;this._eyeZ=cc.Camera.getZEye();this._upX=
this._centerX=this._centerY=this._centerZ=0;this._upY=1;this._upZ=0;this._lookupMatrix.identity();this._dirty=!1},locate:function(){if(this._dirty){var a=new cc.math.Vec3(this._eyeX,this._eyeY,this._eyeZ),b=new cc.math.Vec3(this._centerX,this._centerY,this._centerZ),c=new cc.math.Vec3(this._upX,this._upY,this._upZ);this._lookupMatrix.lookAt(a,b,c);this._dirty=!1}cc.kmGLMultMatrix(this._lookupMatrix)},_locateForRenderer:function(a){if(this._dirty){var b=new cc.math.Vec3(this._eyeX,this._eyeY,this._eyeZ),
c=new cc.math.Vec3(this._centerX,this._centerY,this._centerZ),d=new cc.math.Vec3(this._upX,this._upY,this._upZ);this._lookupMatrix.lookAt(b,c,d);this._dirty=!1}a.multiply(this._lookupMatrix)},setEyeXYZ:function(a,b,c){this.setEye(a,b,c)},setEye:function(a,b,c){this._eyeX=a;this._eyeY=b;this._eyeZ=c;this._dirty=!0},setCenterXYZ:function(a,b,c){this.setCenter(a,b,c)},setCenter:function(a,b,c){this._centerX=a;this._centerY=b;this._centerZ=c;this._dirty=!0},setUpXYZ:function(a,b,c){this.setUp(a,b,c)},
setUp:function(a,b,c){this._upX=a;this._upY=b;this._upZ=c;this._dirty=!0},getEyeXYZ:function(a,b,c){return{x:this._eyeX,y:this._eyeY,z:this._eyeZ}},getEye:function(){return{x:this._eyeX,y:this._eyeY,z:this._eyeZ}},getCenterXYZ:function(a,b,c){return{x:this._centerX,y:this._centerY,z:this._centerZ}},getCenter:function(){return{x:this._centerX,y:this._centerY,z:this._centerZ}},getUpXYZ:function(a,b,c){return{x:this._upX,y:this._upY,z:this._upZ}},getUp:function(){return{x:this._upX,y:this._upY,z:this._upZ}},
_DISALLOW_COPY_AND_ASSIGN:function(a){}});cc.Camera.getZEye=function(){return cc.FLT_EPSILON};cc.PI2=2*Math.PI;
cc.DrawingPrimitiveCanvas=cc.Class.extend({_cacheArray:[],_renderContext:null,ctor:function(a){this._renderContext=a},drawPoint:function(a,b){b||(b=1);var c=cc.view.getScaleX(),d=cc.view.getScaleY(),d=cc.p(a.x*c,a.y*d),e=this._renderContext.getContext();e.beginPath();e.arc(d.x,-d.y,b*c,0,2*Math.PI,!1);e.closePath();e.fill()},drawPoints:function(a,b,c){if(null!=a){c||(c=1);b=this._renderContext.getContext();var d=cc.view.getScaleX(),e=cc.view.getScaleY();b.beginPath();for(var f=0,g=a.length;g>f;f++)b.arc(a[f].x*
d,-a[f].y*e,c*d,0,2*Math.PI,!1);b.closePath();b.fill()}},drawLine:function(a,b){var c=this._renderContext.getContext(),d=cc.view.getScaleX(),e=cc.view.getScaleY();c.beginPath();c.moveTo(a.x*d,-a.y*e);c.lineTo(b.x*d,-b.y*e);c.closePath();c.stroke()},drawRect:function(a,b){this.drawLine(cc.p(a.x,a.y),cc.p(b.x,a.y));this.drawLine(cc.p(b.x,a.y),cc.p(b.x,b.y));this.drawLine(cc.p(b.x,b.y),cc.p(a.x,b.y));this.drawLine(cc.p(a.x,b.y),cc.p(a.x,a.y))},drawSolidRect:function(a,b,c){a=[a,cc.p(b.x,a.y),b,cc.p(a.x,
b.y)];this.drawSolidPoly(a,4,c)},drawPoly:function(a,b,c,d){if(d=d||!1,null!=a){if(3>a.length)throw Error("Polygon's point must greater than 2");var e=a[0];b=this._renderContext.getContext();var f=cc.view.getScaleX(),g=cc.view.getScaleY();b.beginPath();b.moveTo(e.x*f,-e.y*g);for(var e=1,h=a.length;h>e;e++)b.lineTo(a[e].x*f,-a[e].y*g);c&&b.closePath();d?b.fill():b.stroke()}},drawSolidPoly:function(a,b,c){this.setDrawColor(c.r,c.g,c.b,c.a);this.drawPoly(a,b,!0,!0)},drawCircle:function(a,b,c,d,e){e=
e||!1;d=this._renderContext.getContext();var f=cc.view.getScaleX(),g=cc.view.getScaleY();d.beginPath();d.arc(0|a.x*f,0|-(a.y*g),b*f,-c,-(c-2*Math.PI),!1);e&&d.lineTo(0|a.x*f,0|-(a.y*g));d.stroke()},drawQuadBezier:function(a,b,c,d){for(var e=this._cacheArray,f=e.length=0,g=0;d>g;g++){var h=Math.pow(1-f,2)*a.x+2*(1-f)*f*b.x+f*f*c.x,k=Math.pow(1-f,2)*a.y+2*(1-f)*f*b.y+f*f*c.y;e.push(cc.p(h,k));f+=1/d}e.push(cc.p(c.x,c.y));this.drawPoly(e,d+1,!1,!1)},drawCubicBezier:function(a,b,c,d,e){for(var f=this._cacheArray,
g=f.length=0,h=0;e>h;h++){var k=Math.pow(1-g,3)*a.x+3*Math.pow(1-g,2)*g*b.x+3*(1-g)*g*g*c.x+g*g*g*d.x,m=Math.pow(1-g,3)*a.y+3*Math.pow(1-g,2)*g*b.y+3*(1-g)*g*g*c.y+g*g*g*d.y;f.push(cc.p(k,m));g+=1/e}f.push(cc.p(d.x,d.y));this.drawPoly(f,e+1,!1,!1)},drawCatmullRom:function(a,b){this.drawCardinalSpline(a,0.5,b)},drawCardinalSpline:function(a,b,c){cc._renderContext.setStrokeStyle("rgba(255,255,255,1)");var d=this._cacheArray;d.length=0;for(var e,f,g=1/a.length,h=0;c+1>h;h++){var k=h/c;1===k?(e=a.length-
1,f=1):(e=0|k/g,f=(k-g*e)/g);k=cc.CardinalSplineAt(cc.getControlPointAt(a,e-1),cc.getControlPointAt(a,e-0),cc.getControlPointAt(a,e+1),cc.getControlPointAt(a,e+2),b,f);d.push(k)}this.drawPoly(d,c+1,!1,!1)},drawImage:function(a,b,c,d,e){var f=arguments.length,g=this._renderContext.getContext();switch(f){case 2:g.drawImage(a,b.x,-(b.y+a.height));break;case 3:g.drawImage(a,b.x,-(b.y+c.height),c.width,c.height);break;case 5:g.drawImage(a,b.x,b.y,c.width,c.height,d.x,-(d.y+e.height),e.width,e.height);
break;default:throw Error("Argument must be non-nil");}},drawStar:function(a,b,c){a=a||this._renderContext;var d=a.getContext();b*=cc.view.getScaleX();c="rgba("+(0|c.r)+","+(0|c.g)+","+(0|c.b);a.setFillStyle(c+",1)");var e=b/10;d.beginPath();d.moveTo(-b,b);d.lineTo(0,e);d.lineTo(b,b);d.lineTo(e,0);d.lineTo(b,-b);d.lineTo(0,-e);d.lineTo(-b,-b);d.lineTo(-e,0);d.lineTo(-b,b);d.closePath();d.fill();var f=d.createRadialGradient(0,0,e,0,0,b);f.addColorStop(0,c+", 1)");f.addColorStop(0.3,c+", 0.8)");f.addColorStop(1,
c+", 0.0)");a.setFillStyle(f);d.beginPath();d.arc(0,0,b-e,0,cc.PI2,!1);d.closePath();d.fill()},drawColorBall:function(a,b,c){a=a||this._renderContext;var d=a.getContext();b*=cc.view.getScaleX();c="rgba("+(0|c.r)+","+(0|c.g)+","+(0|c.b);var e=d.createRadialGradient(0,0,b/10,0,0,b);e.addColorStop(0,c+", 1)");e.addColorStop(0.3,c+", 0.8)");e.addColorStop(0.6,c+", 0.4)");e.addColorStop(1,c+", 0.0)");a.setFillStyle(e);d.beginPath();d.arc(0,0,b,0,cc.PI2,!1);d.closePath();d.fill()},fillText:function(a,b,
c){this._renderContext.getContext().fillText(a,b,-c)},setDrawColor:function(a,b,c,d){this._renderContext.setFillStyle("rgba("+a+","+b+","+c+","+d/255+")");this._renderContext.setStrokeStyle("rgba("+a+","+b+","+c+","+d/255+")")},setPointSize:function(a){},setLineWidth:function(a){this._renderContext.getContext().lineWidth=a*cc.view.getScaleX()}});
!function(){cc.AtlasNode.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._needDraw=!0;this._textureAtlas=null;this._colorUnmodified=cc.color.WHITE;this._uniformColor=this._colorF32Array=null;this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR);this._uniformColor=cc._renderContext.getUniformLocation(this._shaderProgram.getProgram(),"u_color")};var a=cc.AtlasNode.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=
cc.AtlasNode.WebGLRenderCmd;a._updateBlendFunc=function(){var a=this._node;this._textureAtlas.texture.hasPremultipliedAlpha()||(a._blendFunc.src=cc.SRC_ALPHA,a._blendFunc.dst=cc.ONE_MINUS_SRC_ALPHA)};a._updateOpacityModifyRGB=function(){this._node._opacityModifyRGB=this._textureAtlas.texture.hasPremultipliedAlpha()};a.rendering=function(a){a=a||cc._renderContext;var c=this._node;this._shaderProgram.use();this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix);cc.glBlendFunc(c._blendFunc.src,
c._blendFunc.dst);this._uniformColor&&this._colorF32Array&&(a.uniform4fv(this._uniformColor,this._colorF32Array),this._textureAtlas.drawNumberOfQuads(c.quadsToDraw,0))};a.initWithTexture=function(a,c,d,e){var f=this._node;f._itemWidth=c;f._itemHeight=d;this._colorUnmodified=cc.color.WHITE;f._opacityModifyRGB=!0;f._blendFunc.src=cc.BLEND_SRC;f._blendFunc.dst=cc.BLEND_DST;c=f._realColor;return this._colorF32Array=new Float32Array([c.r/255,c.g/255,c.b/255,f._realOpacity/255]),this._textureAtlas=new cc.TextureAtlas,
this._textureAtlas.initWithTexture(a,e),this._textureAtlas?(this._updateBlendFunc(),this._updateOpacityModifyRGB(),this._calculateMaxItems(),f.quadsToDraw=e,!0):(cc.log(cc._LogInfos.AtlasNode__initWithTexture),!1)};a.setColor=function(a){var c=cc.color(a.r,a.g,a.b),d=this._node;this._colorUnmodified=a;a=this._displayedOpacity;d._opacityModifyRGB&&(c.r=c.r*a/255,c.g=c.g*a/255,c.b=c.b*a/255);cc.Node.prototype.setColor.call(d,c)};a.setOpacity=function(a){var c=this._node;cc.Node.prototype.setOpacity.call(c,
a);c._opacityModifyRGB&&(c.color=this._colorUnmodified)};a._updateColor=function(){var a=this._displayedColor;this._colorF32Array=new Float32Array([a.r/255,a.g/255,a.b/255,this._displayedOpacity/255])};a.getTexture=function(){return this._textureAtlas.texture};a.setTexture=function(a){this._textureAtlas.texture=a;this._updateBlendFunc();this._updateOpacityModifyRGB()};a._calculateMaxItems=function(){var a=this._node,c=this._textureAtlas.texture,d=c.getContentSize();a._ignoreContentScaleFactor&&(d=
c.getContentSizeInPixels());a._itemsPerColumn=0|d.height/a._itemHeight;a._itemsPerRow=0|d.width/a._itemWidth}}();
cc._LogInfos={ActionManager_addAction:"cc.ActionManager.addAction(): action must be non-null",ActionManager_removeAction:"cocos2d: removeAction: Target not found",ActionManager_removeActionByTag:"cc.ActionManager.removeActionByTag(): an invalid tag",ActionManager_removeActionByTag_2:"cc.ActionManager.removeActionByTag(): target must be non-null",ActionManager_getActionByTag:"cc.ActionManager.getActionByTag(): an invalid tag",ActionManager_getActionByTag_2:"cocos2d : getActionByTag(tag \x3d %s): Action not found",
configuration_dumpInfo:"cocos2d: **** WARNING **** CC_ENABLE_PROFILERS is defined. Disable it when you finish profiling (from ccConfig.js)",configuration_loadConfigFile:"Expected 'data' dict, but not found. Config file: %s",configuration_loadConfigFile_2:"Please load the resource first : %s",Director_resume:"cocos2d: Director: Error in gettimeofday",Director_setProjection:"cocos2d: Director: unrecognized projection",Director_popToSceneStackLevel:"cocos2d: Director: unrecognized projection",Director_popToSceneStackLevel_2:"cocos2d: Director: Error in gettimeofday",
Director_popScene:"running scene should not null",Director_pushScene:"the scene should not null",arrayVerifyType:"element type is wrong!",Scheduler_scheduleCallbackForTarget:"CCSheduler#scheduleCallback. Callback already scheduled. Updating interval from:%s to %s",Scheduler_scheduleCallbackForTarget_2:"cc.scheduler.scheduleCallbackForTarget(): callback_fn should be non-null.",Scheduler_scheduleCallbackForTarget_3:"cc.scheduler.scheduleCallbackForTarget(): target should be non-null.",Scheduler_pauseTarget:"cc.Scheduler.pauseTarget():target should be non-null",
Scheduler_resumeTarget:"cc.Scheduler.resumeTarget():target should be non-null",Scheduler_isTargetPaused:"cc.Scheduler.isTargetPaused():target should be non-null",Node_getZOrder:"getZOrder is deprecated. Please use getLocalZOrder instead.",Node_setZOrder:"setZOrder is deprecated. Please use setLocalZOrder instead.",Node_getRotation:"RotationX !\x3d RotationY. Don't know which one to return",Node_getScale:"ScaleX !\x3d ScaleY. Don't know which one to return",Node_addChild:"An Node can't be added as a child of itself.",
Node_addChild_2:"child already added. It can't be added again",Node_addChild_3:"child must be non-null",Node_removeFromParentAndCleanup:"removeFromParentAndCleanup is deprecated. Use removeFromParent instead",Node_boundingBox:"boundingBox is deprecated. Use getBoundingBox instead",Node_removeChildByTag:"argument tag is an invalid tag",Node_removeChildByTag_2:"cocos2d: removeChildByTag(tag \x3d %s): child not found!",Node_removeAllChildrenWithCleanup:"removeAllChildrenWithCleanup is deprecated. Use removeAllChildren instead",
Node_stopActionByTag:"cc.Node.stopActionBy(): argument tag an invalid tag",Node_getActionByTag:"cc.Node.getActionByTag(): argument tag is an invalid tag",Node_resumeSchedulerAndActions:"resumeSchedulerAndActions is deprecated, please use resume instead.",Node_pauseSchedulerAndActions:"pauseSchedulerAndActions is deprecated, please use pause instead.",Node__arrayMakeObjectsPerformSelector:"Unknown callback function",Node_reorderChild:"child must be non-null",Node_runAction:"cc.Node.runAction(): action must be non-null",
Node_schedule:"callback function must be non-null",Node_schedule_2:"interval must be positive",Node_initWithTexture:"cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.",AtlasNode_updateAtlasValues:"cc.AtlasNode.updateAtlasValues(): Shall be overridden in subclasses",AtlasNode_initWithTileFile:"",AtlasNode__initWithTexture:"cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.",_EventListenerKeyboard_checkAvailable:"cc._EventListenerKeyboard.checkAvailable(): Invalid EventListenerKeyboard!",
_EventListenerTouchOneByOne_checkAvailable:"cc._EventListenerTouchOneByOne.checkAvailable(): Invalid EventListenerTouchOneByOne!",_EventListenerTouchAllAtOnce_checkAvailable:"cc._EventListenerTouchAllAtOnce.checkAvailable(): Invalid EventListenerTouchAllAtOnce!",_EventListenerAcceleration_checkAvailable:"cc._EventListenerAcceleration.checkAvailable(): _onAccelerationEvent must be non-nil",EventListener_create:"Invalid parameter.",__getListenerID:"Don't call this method if the event is for touch.",
eventManager__forceAddEventListener:"Invalid scene graph priority!",eventManager_addListener:"0 priority is forbidden for fixed priority since it's used for scene graph based priority.",eventManager_removeListeners:"Invalid listener type!",eventManager_setPriority:"Can't set fixed priority with scene graph based listener.",eventManager_addListener_2:"Invalid parameters.",eventManager_addListener_3:"listener must be a cc.EventListener object when adding a fixed priority listener",eventManager_addListener_4:"The listener has been registered, please don't register it again.",
LayerMultiplex_initWithLayers:"parameters should not be ending with null in Javascript",LayerMultiplex_switchTo:"Invalid index in MultiplexLayer switchTo message",LayerMultiplex_switchToAndReleaseMe:"Invalid index in MultiplexLayer switchTo message",LayerMultiplex_addLayer:"cc.Layer.addLayer(): layer should be non-null",EGLView_setDesignResolutionSize:"Resolution not valid",EGLView_setDesignResolutionSize_2:"should set resolutionPolicy",inputManager_handleTouchesBegin:"The touches is more than MAX_TOUCHES, nUnusedIndex \x3d %s",
swap:"cc.swap is being modified from original macro, please check usage",checkGLErrorDebug:"WebGL error %s",animationCache__addAnimationsWithDictionary:"cocos2d: cc.AnimationCache: No animations were found in provided dictionary.",animationCache__addAnimationsWithDictionary_2:"cc.AnimationCache. Invalid animation format",animationCache_addAnimations:"cc.AnimationCache.addAnimations(): File could not be found",animationCache__parseVersion1:"cocos2d: cc.AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.",
animationCache__parseVersion1_2:"cocos2d: cc.AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the cc.SpriteFrameCache. This frame will not be added to the animation.",animationCache__parseVersion1_3:"cocos2d: cc.AnimationCache: None of the frames for animation '%s' were found in the cc.SpriteFrameCache. Animation is not being added to the Animation Cache.",animationCache__parseVersion1_4:"cocos2d: cc.AnimationCache: An animation in your dictionary refers to a frame which is not in the cc.SpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.",
animationCache__parseVersion2:"cocos2d: CCAnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.",animationCache__parseVersion2_2:"cocos2d: cc.AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the cc.SpriteFrameCache. This frame will not be added to the animation.",animationCache_addAnimations_2:"cc.AnimationCache.addAnimations(): Invalid texture file name",Sprite_reorderChild:"cc.Sprite.reorderChild(): this child is not in children list",
Sprite_ignoreAnchorPointForPosition:"cc.Sprite.ignoreAnchorPointForPosition(): it is invalid in cc.Sprite when using SpriteBatchNode",Sprite_setDisplayFrameWithAnimationName:"cc.Sprite.setDisplayFrameWithAnimationName(): Frame not found",Sprite_setDisplayFrameWithAnimationName_2:"cc.Sprite.setDisplayFrameWithAnimationName(): Invalid frame index",Sprite_setDisplayFrame:"setDisplayFrame is deprecated, please use setSpriteFrame instead.",Sprite__updateBlendFunc:"cc.Sprite._updateBlendFunc(): _updateBlendFunc doesn't work when the sprite is rendered using a cc.CCSpriteBatchNode",
Sprite_initWithSpriteFrame:"cc.Sprite.initWithSpriteFrame(): spriteFrame should be non-null",Sprite_initWithSpriteFrameName:"cc.Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null",Sprite_initWithSpriteFrameName1:" is null, please check.",Sprite_initWithFile:"cc.Sprite.initWithFile(): filename should be non-null",Sprite_setDisplayFrameWithAnimationName_3:"cc.Sprite.setDisplayFrameWithAnimationName(): animationName must be non-null",Sprite_reorderChild_2:"cc.Sprite.reorderChild(): child should be non-null",
Sprite_addChild:"cc.Sprite.addChild(): cc.Sprite only supports cc.Sprites as children when using cc.SpriteBatchNode",Sprite_addChild_2:"cc.Sprite.addChild(): cc.Sprite only supports a sprite using same texture as children when using cc.SpriteBatchNode",Sprite_addChild_3:"cc.Sprite.addChild(): child should be non-null",Sprite_setTexture:"cc.Sprite.texture setter: Batched sprites should use the same texture as the batchnode",Sprite_updateQuadFromSprite:"cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",
Sprite_insertQuadFromSprite:"cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",Sprite_addChild_4:"cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children",Sprite_addChild_5:"cc.SpriteBatchNode.addChild(): cc.Sprite is not using the same texture",Sprite_initWithTexture:"Sprite.initWithTexture(): Argument must be non-nil ",Sprite_setSpriteFrame:"Invalid spriteFrameName",Sprite_setTexture_2:"Invalid argument: cc.Sprite.texture setter expects a CCTexture2D.",
Sprite_updateQuadFromSprite_2:"cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null",Sprite_insertQuadFromSprite_2:"cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null",SpriteBatchNode_addSpriteWithoutQuad:"cc.SpriteBatchNode.addQuadFromSprite(): SpriteBatchNode only supports cc.Sprites as children",SpriteBatchNode_increaseAtlasCapacity:"cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from %s to %s.",SpriteBatchNode_increaseAtlasCapacity_2:"cocos2d: WARNING: Not enough memory to resize the atlas",
SpriteBatchNode_reorderChild:"cc.SpriteBatchNode.addChild(): Child doesn't belong to Sprite",SpriteBatchNode_removeChild:"cc.SpriteBatchNode.addChild(): sprite batch node should contain the child",SpriteBatchNode_addSpriteWithoutQuad_2:"cc.SpriteBatchNode.addQuadFromSprite(): child should be non-null",SpriteBatchNode_reorderChild_2:"cc.SpriteBatchNode.addChild(): child should be non-null",spriteFrameCache__getFrameConfig:"cocos2d: WARNING: originalWidth/Height not found on the cc.SpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist",
spriteFrameCache_addSpriteFrames:"cocos2d: WARNING: an alias with name %s already exists",spriteFrameCache__checkConflict:"cocos2d: WARNING: Sprite frame: %s has already been added by another source, please fix name conflit",spriteFrameCache_getSpriteFrame:"cocos2d: cc.SpriteFrameCahce: Frame %s not found",spriteFrameCache__getFrameConfig_2:"Please load the resource first : %s",spriteFrameCache_addSpriteFrames_2:"cc.SpriteFrameCache.addSpriteFrames(): plist should be non-null",spriteFrameCache_addSpriteFrames_3:"Argument must be non-nil",
CCSpriteBatchNode_updateQuadFromSprite:"cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",CCSpriteBatchNode_insertQuadFromSprite:"cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",CCSpriteBatchNode_addChild:"cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children",CCSpriteBatchNode_initWithTexture:"Sprite.initWithTexture(): Argument must be non-nil ",CCSpriteBatchNode_addChild_2:"cc.Sprite.addChild(): child should be non-null",
CCSpriteBatchNode_setSpriteFrame:"Invalid spriteFrameName",CCSpriteBatchNode_setTexture:"Invalid argument: cc.Sprite texture setter expects a CCTexture2D.",CCSpriteBatchNode_updateQuadFromSprite_2:"cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null",CCSpriteBatchNode_insertQuadFromSprite_2:"cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null",CCSpriteBatchNode_addChild_3:"cc.SpriteBatchNode.addChild(): child should be non-null",TextureAtlas_initWithFile:"cocos2d: Could not open file: %s",
TextureAtlas_insertQuad:"cc.TextureAtlas.insertQuad(): invalid totalQuads",TextureAtlas_initWithTexture:"cc.TextureAtlas.initWithTexture():texture should be non-null",TextureAtlas_updateQuad:"cc.TextureAtlas.updateQuad(): quad should be non-null",TextureAtlas_updateQuad_2:"cc.TextureAtlas.updateQuad(): Invalid index",TextureAtlas_insertQuad_2:"cc.TextureAtlas.insertQuad(): Invalid index",TextureAtlas_insertQuads:"cc.TextureAtlas.insertQuad(): Invalid index + amount",TextureAtlas_insertQuadFromIndex:"cc.TextureAtlas.insertQuadFromIndex(): Invalid newIndex",
TextureAtlas_insertQuadFromIndex_2:"cc.TextureAtlas.insertQuadFromIndex(): Invalid fromIndex",TextureAtlas_removeQuadAtIndex:"cc.TextureAtlas.removeQuadAtIndex(): Invalid index",TextureAtlas_removeQuadsAtIndex:"cc.TextureAtlas.removeQuadsAtIndex(): index + amount out of bounds",TextureAtlas_moveQuadsFromIndex:"cc.TextureAtlas.moveQuadsFromIndex(): move is out of bounds",TextureAtlas_moveQuadsFromIndex_2:"cc.TextureAtlas.moveQuadsFromIndex(): Invalid newIndex",TextureAtlas_moveQuadsFromIndex_3:"cc.TextureAtlas.moveQuadsFromIndex(): Invalid oldIndex",
textureCache_addPVRTCImage:"TextureCache:addPVRTCImage does not support on HTML5",textureCache_addETCImage:"TextureCache:addPVRTCImage does not support on HTML5",textureCache_textureForKey:"textureForKey is deprecated. Please use getTextureForKey instead.",textureCache_addPVRImage:"addPVRImage does not support on HTML5",textureCache_addUIImage:"cocos2d: Couldn't add UIImage in TextureCache",textureCache_dumpCachedTextureInfo:"cocos2d: '%s' id\x3d%s %s x %s",textureCache_dumpCachedTextureInfo_2:"cocos2d: '%s' id\x3d HTMLCanvasElement %s x %s",
textureCache_dumpCachedTextureInfo_3:"cocos2d: TextureCache dumpDebugInfo: %s textures, HTMLCanvasElement for %s KB (%s MB)",textureCache_addUIImage_2:"cc.Texture.addUIImage(): image should be non-null",Texture2D_initWithETCFile:"initWithETCFile does not support on HTML5",Texture2D_initWithPVRFile:"initWithPVRFile does not support on HTML5",Texture2D_initWithPVRTCData:"initWithPVRTCData does not support on HTML5",Texture2D_addImage:"cc.Texture.addImage(): path should be non-null",Texture2D_initWithImage:"cocos2d: cc.Texture2D. Can't create Texture. UIImage is nil",
Texture2D_initWithImage_2:"cocos2d: WARNING: Image (%s x %s) is bigger than the supported %s x %s",Texture2D_initWithString:"initWithString isn't supported on cocos2d-html5",Texture2D_initWithETCFile_2:"initWithETCFile does not support on HTML5",Texture2D_initWithPVRFile_2:"initWithPVRFile does not support on HTML5",Texture2D_initWithPVRTCData_2:"initWithPVRTCData does not support on HTML5",Texture2D_bitsPerPixelForFormat:"bitsPerPixelForFormat: %s, cannot give useful result, it's a illegal pixel format",
Texture2D__initPremultipliedATextureWithImage:"cocos2d: cc.Texture2D: Using RGB565 texture since image has no alpha",Texture2D_addImage_2:"cc.Texture.addImage(): path should be non-null",Texture2D_initWithData:"NSInternalInconsistencyException",MissingFile:"Missing file: %s",radiansToDegress:"cc.radiansToDegress() should be called cc.radiansToDegrees()",RectWidth:"Rect width exceeds maximum margin: %s",RectHeight:"Rect height exceeds maximum margin: %s",EventManager__updateListeners:"If program goes here, there should be event in dispatch.",
EventManager__updateListeners_2:"_inDispatch should be 1 here."};
cc._logToWebPage=function(a){if(cc._canvas){var b=cc._logList,c=document;if(!b){var d=c.createElement("Div"),b=d.style;d.setAttribute("id","logInfoDiv");cc._canvas.parentNode.appendChild(d);d.setAttribute("width","200");d.setAttribute("height",cc._canvas.height);b.zIndex="99999";b.position="absolute";b.top="0";b.left="0";b=cc._logList=c.createElement("textarea");c=b.style;b.setAttribute("rows","20");b.setAttribute("cols","30");b.setAttribute("disabled",!0);d.appendChild(b);c.backgroundColor="transparent";
c.borderBottom="1px solid #cccccc";c.borderRightWidth="0px";c.borderLeftWidth="0px";c.borderTopWidth="0px";c.borderTopStyle="none";c.borderRightStyle="none";c.borderLeftStyle="none";c.padding="0px";c.margin=0}b.value=b.value+a+"\r\n";b.scrollTop=b.scrollHeight}};cc._formatString=function(a){if(!cc.isObject(a))return a;try{return JSON.stringify(a)}catch(b){return""}};
cc._initDebugSetting=function(a){var b=cc.game;if(a!==b.DEBUG_MODE_NONE){var c;a>b.DEBUG_MODE_ERROR?(c=cc._logToWebPage.bind(cc),cc.error=function(){c("ERROR :  "+cc.formatStr.apply(cc,arguments))},cc.assert=function(a,b){if(!a&&b){for(var f=2;f<arguments.length;f++)b=b.replace(/(%s)|(%d)/,cc._formatString(arguments[f]));c("Assert: "+b)}},a!==b.DEBUG_MODE_ERROR_FOR_WEB_PAGE&&(cc.warn=function(){c("WARN :  "+cc.formatStr.apply(cc,arguments))}),a===b.DEBUG_MODE_INFO_FOR_WEB_PAGE&&(cc.log=function(){c(cc.formatStr.apply(cc,
arguments))})):console&&console.log.apply&&(cc.error=function(){return console.error.apply(console,arguments)},cc.assert=function(a,b){if(!a&&b){for(var c=2;c<arguments.length;c++)b=b.replace(/(%s)|(%d)/,cc._formatString(arguments[c]));throw b;}},a!==b.DEBUG_MODE_ERROR&&(cc.warn=function(){return console.warn.apply(console,arguments)}),a===b.DEBUG_MODE_INFO&&(cc.log=function(){return console.log.apply(console,arguments)}))}};cc._initDebugSetting(cc.game.config[cc.game.CONFIG_KEY.debugMode]);
cc.HashElement=cc.Class.extend({actions:null,target:null,actionIndex:0,currentAction:null,currentActionSalvaged:!1,paused:!1,hh:null,ctor:function(){this.actions=[];this.target=null;this.actionIndex=0;this.currentAction=null;this.paused=this.currentActionSalvaged=!1;this.hh=null}});
cc.ActionManager=cc.Class.extend({_hashTargets:null,_arrayTargets:null,_currentTarget:null,_currentTargetSalvaged:!1,_searchElementByTarget:function(a,b){for(var c=0;c<a.length;c++)if(b===a[c].target)return a[c];return null},ctor:function(){this._hashTargets={};this._arrayTargets=[];this._currentTarget=null;this._currentTargetSalvaged=!1},addAction:function(a,b,c){if(!a)throw"cc.ActionManager.addAction(): action must be non-null";if(!b)throw"cc.ActionManager.addAction(): action must be non-null";
var d=this._hashTargets[b.__instanceId];d||(d=new cc.HashElement,d.paused=c,d.target=b,this._hashTargets[b.__instanceId]=d,this._arrayTargets.push(d));this._actionAllocWithHashElement(d);d.actions.push(a);a.startWithTarget(b)},removeAllActions:function(){for(var a=this._arrayTargets,b=0;b<a.length;b++){var c=a[b];c&&this.removeAllActionsFromTarget(c.target,!0)}},removeAllActionsFromTarget:function(a,b){if(null!=a){var c=this._hashTargets[a.__instanceId];c&&(-1===c.actions.indexOf(c.currentAction)||
c.currentActionSalvaged||(c.currentActionSalvaged=!0),c.actions.length=0,this._currentTarget!==c||b?this._deleteHashElement(c):this._currentTargetSalvaged=!0)}},removeAction:function(a){if(null!=a){var b=a.getOriginalTarget();if(b=this._hashTargets[b.__instanceId])for(var c=0;c<b.actions.length;c++){if(b.actions[c]===a){b.actions.splice(c,1);break}}else cc.log(cc._LogInfos.ActionManager_removeAction)}},removeActionByTag:function(a,b){a===cc.ACTION_TAG_INVALID&&cc.log(cc._LogInfos.ActionManager_addAction);
cc.assert(b,cc._LogInfos.ActionManager_addAction);var c=this._hashTargets[b.__instanceId];if(c)for(var d=c.actions.length,e=0;d>e;++e){var f=c.actions[e];if(f&&f.getTag()===a&&f.getOriginalTarget()===b){this._removeActionAtIndex(e,c);break}}},getActionByTag:function(a,b){a===cc.ACTION_TAG_INVALID&&cc.log(cc._LogInfos.ActionManager_getActionByTag);var c=this._hashTargets[b.__instanceId];if(c){if(null!=c.actions)for(var d=0;d<c.actions.length;++d){var e=c.actions[d];if(e&&e.getTag()===a)return e}cc.log(cc._LogInfos.ActionManager_getActionByTag_2,
a)}return null},numberOfRunningActionsInTarget:function(a){return(a=this._hashTargets[a.__instanceId])&&a.actions?a.actions.length:0},pauseTarget:function(a){(a=this._hashTargets[a.__instanceId])&&(a.paused=!0)},resumeTarget:function(a){(a=this._hashTargets[a.__instanceId])&&(a.paused=!1)},pauseAllRunningActions:function(){for(var a=[],b=this._arrayTargets,c=0;c<b.length;c++){var d=b[c];d&&!d.paused&&(d.paused=!0,a.push(d.target))}return a},resumeTargets:function(a){if(a)for(var b=0;b<a.length;b++)a[b]&&
this.resumeTarget(a[b])},purgeSharedManager:function(){cc.director.getScheduler().unscheduleUpdate(this)},_removeActionAtIndex:function(a,b){b.actions[a]!==b.currentAction||b.currentActionSalvaged||(b.currentActionSalvaged=!0);b.actions.splice(a,1);b.actionIndex>=a&&b.actionIndex--;0===b.actions.length&&(this._currentTarget===b?this._currentTargetSalvaged=!0:this._deleteHashElement(b))},_deleteHashElement:function(a){a&&(delete this._hashTargets[a.target.__instanceId],cc.arrayRemoveObject(this._arrayTargets,
a),a.actions=null,a.target=null)},_actionAllocWithHashElement:function(a){null==a.actions&&(a.actions=[])},update:function(a){for(var b,c=this._arrayTargets,d=0;d<c.length;d++){if(this._currentTarget=c[d],b=this._currentTarget,!b.paused)for(b.actionIndex=0;b.actionIndex<(b.actions?b.actions.length:0);b.actionIndex++)if(b.currentAction=b.actions[b.actionIndex],b.currentAction){if(b.currentActionSalvaged=!1,b.currentAction.step(a*(b.currentAction._speedMethod?b.currentAction._speed:1)),b.currentActionSalvaged)b.currentAction=
null;else if(b.currentAction.isDone()){b.currentAction.stop();var e=b.currentAction;b.currentAction=null;this.removeAction(e)}b.currentAction=null}this._currentTargetSalvaged&&0===b.actions.length&&this._deleteHashElement(b)}}});cc.ACTION_TAG_INVALID=-1;
cc.Action=cc.Class.extend({originalTarget:null,target:null,tag:cc.ACTION_TAG_INVALID,ctor:function(){this.target=this.originalTarget=null;this.tag=cc.ACTION_TAG_INVALID},copy:function(){return cc.log("copy is deprecated. Please use clone instead."),this.clone()},clone:function(){var a=new cc.Action;return a.originalTarget=null,a.target=null,a.tag=this.tag,a},isDone:function(){return!0},startWithTarget:function(a){this.target=this.originalTarget=a},stop:function(){this.target=null},step:function(a){cc.log("[Action step]. override me")},
update:function(a){cc.log("[Action update]. override me")},getTarget:function(){return this.target},setTarget:function(a){this.target=a},getOriginalTarget:function(){return this.originalTarget},setOriginalTarget:function(a){this.originalTarget=a},getTag:function(){return this.tag},setTag:function(a){this.tag=a},retain:function(){},release:function(){}});cc.action=function(){return new cc.Action};cc.Action.create=cc.action;
cc.FiniteTimeAction=cc.Action.extend({_duration:0,ctor:function(){cc.Action.prototype.ctor.call(this);this._duration=0},getDuration:function(){return this._duration*(this._timesForRepeat||1)},setDuration:function(a){this._duration=a},reverse:function(){return cc.log("cocos2d: FiniteTimeAction#reverse: Implement me"),null},clone:function(){return new cc.FiniteTimeAction}});
cc.Speed=cc.Action.extend({_speed:0,_innerAction:null,ctor:function(a,b){cc.Action.prototype.ctor.call(this);this._speed=0;this._innerAction=null;a&&this.initWithAction(a,b)},getSpeed:function(){return this._speed},setSpeed:function(a){this._speed=a},initWithAction:function(a,b){if(!a)throw"cc.Speed.initWithAction(): action must be non nil";return this._innerAction=a,this._speed=b,!0},clone:function(){var a=new cc.Speed;return a.initWithAction(this._innerAction.clone(),this._speed),a},startWithTarget:function(a){cc.Action.prototype.startWithTarget.call(this,
a);this._innerAction.startWithTarget(a)},stop:function(){this._innerAction.stop();cc.Action.prototype.stop.call(this)},step:function(a){this._innerAction.step(a*this._speed)},isDone:function(){return this._innerAction.isDone()},reverse:function(){return new cc.Speed(this._innerAction.reverse(),this._speed)},setInnerAction:function(a){this._innerAction!==a&&(this._innerAction=a)},getInnerAction:function(){return this._innerAction}});cc.speed=function(a,b){return new cc.Speed(a,b)};
cc.Speed.create=cc.speed;
cc.Follow=cc.Action.extend({_followedNode:null,_boundarySet:!1,_boundaryFullyCovered:!1,_halfScreenSize:null,_fullScreenSize:null,_worldRect:null,leftBoundary:0,rightBoundary:0,topBoundary:0,bottomBoundary:0,ctor:function(a,b){cc.Action.prototype.ctor.call(this);this._followedNode=null;this._boundaryFullyCovered=this._boundarySet=!1;this._fullScreenSize=this._halfScreenSize=null;this.bottomBoundary=this.topBoundary=this.rightBoundary=this.leftBoundary=0;this._worldRect=cc.rect(0,0,0,0);a&&(b?this.initWithTarget(a,
b):this.initWithTarget(a))},clone:function(){var a=new cc.Follow,b=this._worldRect,b=new cc.Rect(b.x,b.y,b.width,b.height);return a.initWithTarget(this._followedNode,b),a},isBoundarySet:function(){return this._boundarySet},setBoudarySet:function(a){this._boundarySet=a},initWithTarget:function(a,b){if(!a)throw"cc.Follow.initWithAction(): followedNode must be non nil";b=b||cc.rect(0,0,0,0);this._followedNode=a;this._worldRect=b;this._boundarySet=!cc._rectEqualToZero(b);this._boundaryFullyCovered=!1;
var c=cc.director.getWinSize();return this._fullScreenSize=cc.p(c.width,c.height),this._halfScreenSize=cc.pMult(this._fullScreenSize,0.5),this._boundarySet&&(this.leftBoundary=-(b.x+b.width-this._fullScreenSize.x),this.rightBoundary=-b.x,this.topBoundary=-b.y,this.bottomBoundary=-(b.y+b.height-this._fullScreenSize.y),this.rightBoundary<this.leftBoundary&&(this.rightBoundary=this.leftBoundary=(this.leftBoundary+this.rightBoundary)/2),this.topBoundary<this.bottomBoundary&&(this.topBoundary=this.bottomBoundary=
(this.topBoundary+this.bottomBoundary)/2),this.topBoundary===this.bottomBoundary&&this.leftBoundary===this.rightBoundary&&(this._boundaryFullyCovered=!0)),!0},step:function(a){a=this._followedNode.x;var b=this._followedNode.y;(a=this._halfScreenSize.x-a,b=this._halfScreenSize.y-b,this.target._renderCmd._dirtyFlag=0,this._boundarySet)?this._boundaryFullyCovered||this.target.setPosition(cc.clampf(a,this.leftBoundary,this.rightBoundary),cc.clampf(b,this.bottomBoundary,this.topBoundary)):this.target.setPosition(a,
b)},isDone:function(){return!this._followedNode.running},stop:function(){this.target=null;cc.Action.prototype.stop.call(this)}});cc.follow=function(a,b){return new cc.Follow(a,b)};cc.Follow.create=cc.follow;
cc.ActionInterval=cc.FiniteTimeAction.extend({_elapsed:0,_firstTick:!1,_easeList:null,_timesForRepeat:1,_repeatForever:!1,_repeatMethod:!1,_speed:1,_speedMethod:!1,ctor:function(a){this._timesForRepeat=this._speed=1;this._repeatForever=!1;this.MAX_VALUE=2;this._speedMethod=this._repeatMethod=!1;cc.FiniteTimeAction.prototype.ctor.call(this);void 0!==a&&this.initWithDuration(a)},getElapsed:function(){return this._elapsed},initWithDuration:function(a){return this._duration=0===a?cc.FLT_EPSILON:a,this._elapsed=
0,this._firstTick=!0,!0},isDone:function(){return this._elapsed>=this._duration},_cloneDecoration:function(a){a._repeatForever=this._repeatForever;a._speed=this._speed;a._timesForRepeat=this._timesForRepeat;a._easeList=this._easeList;a._speedMethod=this._speedMethod;a._repeatMethod=this._repeatMethod},_reverseEaseList:function(a){if(this._easeList){a._easeList=[];for(var b=0;b<this._easeList.length;b++)a._easeList.push(this._easeList[b].reverse())}},clone:function(){var a=new cc.ActionInterval(this._duration);
return this._cloneDecoration(a),a},easing:function(a){this._easeList?this._easeList.length=0:this._easeList=[];for(var b=0;b<arguments.length;b++)this._easeList.push(arguments[b]);return this},_computeEaseTime:function(a){var b=this._easeList;if(!b||0===b.length)return a;for(var c=0,d=b.length;d>c;c++)a=b[c].easing(a);return a},step:function(a){this._firstTick?(this._firstTick=!1,this._elapsed=0):this._elapsed+=a;a=this._elapsed/(1.192092896E-7<this._duration?this._duration:1.192092896E-7);a=1>a?
a:1;this.update(0<a?a:0);this._repeatMethod&&1<this._timesForRepeat&&this.isDone()&&(this._repeatForever||this._timesForRepeat--,this.startWithTarget(this.target),this.step(this._elapsed-this._duration))},startWithTarget:function(a){cc.Action.prototype.startWithTarget.call(this,a);this._elapsed=0;this._firstTick=!0},reverse:function(){return cc.log("cc.IntervalAction: reverse not implemented."),null},setAmplitudeRate:function(a){cc.log("cc.ActionInterval.setAmplitudeRate(): it should be overridden in subclass.")},
getAmplitudeRate:function(){return cc.log("cc.ActionInterval.getAmplitudeRate(): it should be overridden in subclass."),0},speed:function(a){return 0>=a?(cc.log("The speed parameter error"),this):(this._speedMethod=!0,this._speed*=a,this)},getSpeed:function(){return this._speed},setSpeed:function(a){return this._speed=a,this},repeat:function(a){return a=Math.round(a),isNaN(a)||1>a?(cc.log("The repeat parameter error"),this):(this._repeatMethod=!0,this._timesForRepeat*=a,this)},repeatForever:function(){return this._repeatMethod=
!0,this._timesForRepeat=this.MAX_VALUE,this._repeatForever=!0,this}});cc.actionInterval=function(a){return new cc.ActionInterval(a)};cc.ActionInterval.create=cc.actionInterval;
cc.Sequence=cc.ActionInterval.extend({_actions:null,_split:null,_last:0,ctor:function(a){cc.ActionInterval.prototype.ctor.call(this);this._actions=[];var b=a instanceof Array?a:arguments,c=b.length-1;if(0<=c&&null==b[c]&&cc.log("parameters should not be ending with null in Javascript"),0<=c){for(var d,e=b[0],f=1;c>f;f++)b[f]&&(d=e,e=cc.Sequence._actionOneTwo(d,b[f]));this.initWithTwoActions(e,b[c])}},initWithTwoActions:function(a,b){if(!a||!b)throw"cc.Sequence.initWithTwoActions(): arguments must all be non nil";
return this.initWithDuration(a._duration+b._duration),this._actions[0]=a,this._actions[1]=b,!0},clone:function(){var a=new cc.Sequence;return this._cloneDecoration(a),a.initWithTwoActions(this._actions[0].clone(),this._actions[1].clone()),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._split=this._actions[0]._duration/this._duration;this._last=-1},stop:function(){-1!==this._last&&this._actions[this._last].stop();cc.Action.prototype.stop.call(this)},update:function(a){var b,
c=0,d=this._split,e=this._actions,f=this._last;a=this._computeEaseTime(a);d>a?(b=0!==d?a/d:1,0===c&&1===f&&(e[1].update(0),e[1].stop())):(c=1,b=1===d?1:(a-d)/(1-d),-1===f&&(e[0].startWithTarget(this.target),e[0].update(1),e[0].stop()),f||(e[0].update(1),e[0].stop()));a=e[c];f===c&&a.isDone()||(f!==c&&a.startWithTarget(this.target),b*=a._timesForRepeat,a.update(1<b?b%1:b),this._last=c)},reverse:function(){var a=cc.Sequence._actionOneTwo(this._actions[1].reverse(),this._actions[0].reverse());return this._cloneDecoration(a),
this._reverseEaseList(a),a}});cc.sequence=function(a){var b=a instanceof Array?a:arguments;0<b.length&&null==b[b.length-1]&&cc.log("parameters should not be ending with null in Javascript");for(var c,d,e,f;b&&0<b.length;){d=Array.prototype.shift.call(b);f=d._timesForRepeat||1;d._repeatMethod=!1;d._timesForRepeat=1;e=0;c||(c=d,e=1);for(e;f>e;e++)c=cc.Sequence._actionOneTwo(c,d)}return c};cc.Sequence.create=cc.sequence;
cc.Sequence._actionOneTwo=function(a,b){var c=new cc.Sequence;return c.initWithTwoActions(a,b),c};
cc.Repeat=cc.ActionInterval.extend({_times:0,_total:0,_nextDt:0,_actionInstant:!1,_innerAction:null,ctor:function(a,b){cc.ActionInterval.prototype.ctor.call(this);void 0!==b&&this.initWithAction(a,b)},initWithAction:function(a,b){return this.initWithDuration(a._duration*b)?(this._times=b,this._innerAction=a,a instanceof cc.ActionInstant&&(this._actionInstant=!0,this._times-=1),this._total=0,!0):!1},clone:function(){var a=new cc.Repeat;return this._cloneDecoration(a),a.initWithAction(this._innerAction.clone(),
this._times),a},startWithTarget:function(a){this._total=0;this._nextDt=this._innerAction._duration/this._duration;cc.ActionInterval.prototype.startWithTarget.call(this,a);this._innerAction.startWithTarget(a)},stop:function(){this._innerAction.stop();cc.Action.prototype.stop.call(this)},update:function(a){a=this._computeEaseTime(a);var b=this._innerAction,c=this._duration,d=this._times,e=this._nextDt;if(a>=e){for(;a>e&&this._total<d;)b.update(1),this._total++,b.stop(),b.startWithTarget(this.target),
this._nextDt=e+=b._duration/c;1<=a&&this._total<d&&this._total++;this._actionInstant||(this._total===d?(b.update(1),b.stop()):b.update(a-(e-b._duration/c)))}else b.update(a*d%1)},isDone:function(){return this._total===this._times},reverse:function(){var a=new cc.Repeat(this._innerAction.reverse(),this._times);return this._cloneDecoration(a),this._reverseEaseList(a),a},setInnerAction:function(a){this._innerAction!==a&&(this._innerAction=a)},getInnerAction:function(){return this._innerAction}});
cc.repeat=function(a,b){return new cc.Repeat(a,b)};cc.Repeat.create=cc.repeat;
cc.RepeatForever=cc.ActionInterval.extend({_innerAction:null,ctor:function(a){cc.ActionInterval.prototype.ctor.call(this);this._innerAction=null;a&&this.initWithAction(a)},initWithAction:function(a){if(!a)throw"cc.RepeatForever.initWithAction(): action must be non null";return this._innerAction=a,!0},clone:function(){var a=new cc.RepeatForever;return this._cloneDecoration(a),a.initWithAction(this._innerAction.clone()),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,
a);this._innerAction.startWithTarget(a)},step:function(a){var b=this._innerAction;b.step(a);b.isDone()&&(b.startWithTarget(this.target),b.step(b.getElapsed()-b._duration))},isDone:function(){return!1},reverse:function(){var a=new cc.RepeatForever(this._innerAction.reverse());return this._cloneDecoration(a),this._reverseEaseList(a),a},setInnerAction:function(a){this._innerAction!==a&&(this._innerAction=a)},getInnerAction:function(){return this._innerAction}});cc.repeatForever=function(a){return new cc.RepeatForever(a)};
cc.RepeatForever.create=cc.repeatForever;
cc.Spawn=cc.ActionInterval.extend({_one:null,_two:null,ctor:function(a){cc.ActionInterval.prototype.ctor.call(this);this._two=this._one=null;var b=a instanceof Array?a:arguments,c=b.length-1;if(0<=c&&null==b[c]&&cc.log("parameters should not be ending with null in Javascript"),0<=c){for(var d,e=b[0],f=1;c>f;f++)b[f]&&(d=e,e=cc.Spawn._actionOneTwo(d,b[f]));this.initWithTwoActions(e,b[c])}},initWithTwoActions:function(a,b){if(!a||!b)throw"cc.Spawn.initWithTwoActions(): arguments must all be non null";var c=
a._duration,d=b._duration;return this.initWithDuration(Math.max(c,d))&&(this._one=a,this._two=b,c>d?this._two=cc.Sequence._actionOneTwo(b,cc.delayTime(c-d)):d>c&&(this._one=cc.Sequence._actionOneTwo(a,cc.delayTime(d-c)))),!1},clone:function(){var a=new cc.Spawn;return this._cloneDecoration(a),a.initWithTwoActions(this._one.clone(),this._two.clone()),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._one.startWithTarget(a);this._two.startWithTarget(a)},stop:function(){this._one.stop();
this._two.stop();cc.Action.prototype.stop.call(this)},update:function(a){a=this._computeEaseTime(a);this._one&&this._one.update(a);this._two&&this._two.update(a)},reverse:function(){var a=cc.Spawn._actionOneTwo(this._one.reverse(),this._two.reverse());return this._cloneDecoration(a),this._reverseEaseList(a),a}});
cc.spawn=function(a){var b=a instanceof Array?a:arguments;0<b.length&&null==b[b.length-1]&&cc.log("parameters should not be ending with null in Javascript");for(var c=b[0],d=1;d<b.length;d++)null!=b[d]&&(c=cc.Spawn._actionOneTwo(c,b[d]));return c};cc.Spawn.create=cc.spawn;cc.Spawn._actionOneTwo=function(a,b){var c=new cc.Spawn;return c.initWithTwoActions(a,b),c};
cc.RotateTo=cc.ActionInterval.extend({_dstAngleX:0,_startAngleX:0,_diffAngleX:0,_dstAngleY:0,_startAngleY:0,_diffAngleY:0,ctor:function(a,b,c){cc.ActionInterval.prototype.ctor.call(this);void 0!==b&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._dstAngleX=b||0,this._dstAngleY=c||this._dstAngleX,!0):!1},clone:function(){var a=new cc.RotateTo;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._dstAngleX,
this._dstAngleY),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);var b=a.rotationX%360,c=this._dstAngleX-b;180<c&&(c-=360);-180>c&&(c+=360);this._startAngleX=b;this._diffAngleX=c;this._startAngleY=a.rotationY%360;a=this._dstAngleY-this._startAngleY;180<a&&(a-=360);-180>a&&(a+=360);this._diffAngleY=a},reverse:function(){cc.log("cc.RotateTo.reverse(): it should be overridden in subclass.")},update:function(a){a=this._computeEaseTime(a);this.target&&(this.target.rotationX=
this._startAngleX+this._diffAngleX*a,this.target.rotationY=this._startAngleY+this._diffAngleY*a)}});cc.rotateTo=function(a,b,c){return new cc.RotateTo(a,b,c)};cc.RotateTo.create=cc.rotateTo;
cc.RotateBy=cc.ActionInterval.extend({_angleX:0,_startAngleX:0,_angleY:0,_startAngleY:0,ctor:function(a,b,c){cc.ActionInterval.prototype.ctor.call(this);void 0!==b&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._angleX=b||0,this._angleY=c||this._angleX,!0):!1},clone:function(){var a=new cc.RotateBy;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._angleX,this._angleY),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,
a);this._startAngleX=a.rotationX;this._startAngleY=a.rotationY},update:function(a){a=this._computeEaseTime(a);this.target&&(this.target.rotationX=this._startAngleX+this._angleX*a,this.target.rotationY=this._startAngleY+this._angleY*a)},reverse:function(){var a=new cc.RotateBy(this._duration,-this._angleX,-this._angleY);return this._cloneDecoration(a),this._reverseEaseList(a),a}});cc.rotateBy=function(a,b,c){return new cc.RotateBy(a,b,c)};cc.RotateBy.create=cc.rotateBy;
cc.MoveBy=cc.ActionInterval.extend({_positionDelta:null,_startPosition:null,_previousPosition:null,ctor:function(a,b,c){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!==b&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(void 0!==b.x&&(c=b.y,b=b.x),this._positionDelta.x=b,this._positionDelta.y=c,!0):!1},clone:function(){var a=
new cc.MoveBy;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._positionDelta),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);var b=a.getPositionX();a=a.getPositionY();this._previousPosition.x=b;this._previousPosition.y=a;this._startPosition.x=b;this._startPosition.y=a},update:function(a){if(a=this._computeEaseTime(a),this.target){var b=this._positionDelta.x*a;a*=this._positionDelta.y;var c=this._startPosition;if(cc.ENABLE_STACKABLE_ACTIONS){var d=
this.target.getPositionX(),e=this.target.getPositionY(),f=this._previousPosition;c.x=c.x+d-f.x;c.y=c.y+e-f.y;b+=c.x;a+=c.y;f.x=b;f.y=a;this.target.setPosition(b,a)}else this.target.setPosition(c.x+b,c.y+a)}},reverse:function(){var a=new cc.MoveBy(this._duration,cc.p(-this._positionDelta.x,-this._positionDelta.y));return this._cloneDecoration(a),this._reverseEaseList(a),a}});cc.moveBy=function(a,b,c){return new cc.MoveBy(a,b,c)};cc.MoveBy.create=cc.moveBy;
cc.MoveTo=cc.MoveBy.extend({_endPosition:null,ctor:function(a,b,c){cc.MoveBy.prototype.ctor.call(this);this._endPosition=cc.p(0,0);void 0!==b&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){return cc.MoveBy.prototype.initWithDuration.call(this,a,b,c)?(void 0!==b.x&&(c=b.y,b=b.x),this._endPosition.x=b,this._endPosition.y=c,!0):!1},clone:function(){var a=new cc.MoveTo;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._endPosition),a},startWithTarget:function(a){cc.MoveBy.prototype.startWithTarget.call(this,
a);this._positionDelta.x=this._endPosition.x-a.getPositionX();this._positionDelta.y=this._endPosition.y-a.getPositionY()}});cc.moveTo=function(a,b,c){return new cc.MoveTo(a,b,c)};cc.MoveTo.create=cc.moveTo;
cc.SkewTo=cc.ActionInterval.extend({_skewX:0,_skewY:0,_startSkewX:0,_startSkewY:0,_endSkewX:0,_endSkewY:0,_deltaX:0,_deltaY:0,ctor:function(a,b,c){cc.ActionInterval.prototype.ctor.call(this);void 0!==c&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){return cc.ActionInterval.prototype.initWithDuration.call(this,a)&&(this._endSkewX=b,this._endSkewY=c),!1},clone:function(){var a=new cc.SkewTo;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._endSkewX,this._endSkewY),
a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._startSkewX=a.skewX%180;this._deltaX=this._endSkewX-this._startSkewX;180<this._deltaX&&(this._deltaX-=360);-180>this._deltaX&&(this._deltaX+=360);this._startSkewY=a.skewY%360;this._deltaY=this._endSkewY-this._startSkewY;180<this._deltaY&&(this._deltaY-=360);-180>this._deltaY&&(this._deltaY+=360)},update:function(a){a=this._computeEaseTime(a);this.target.skewX=this._startSkewX+this._deltaX*a;this.target.skewY=
this._startSkewY+this._deltaY*a}});cc.skewTo=function(a,b,c){return new cc.SkewTo(a,b,c)};cc.SkewTo.create=cc.skewTo;
cc.SkewBy=cc.SkewTo.extend({ctor:function(a,b,c){cc.SkewTo.prototype.ctor.call(this);void 0!==c&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){return cc.SkewTo.prototype.initWithDuration.call(this,a,b,c)&&(this._skewX=b,this._skewY=c),!1},clone:function(){var a=new cc.SkewBy;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._skewX,this._skewY),a},startWithTarget:function(a){cc.SkewTo.prototype.startWithTarget.call(this,a);this._deltaX=this._skewX;this._deltaY=
this._skewY;this._endSkewX=this._startSkewX+this._deltaX;this._endSkewY=this._startSkewY+this._deltaY},reverse:function(){var a=new cc.SkewBy(this._duration,-this._skewX,-this._skewY);return this._cloneDecoration(a),this._reverseEaseList(a),a}});cc.skewBy=function(a,b,c){return new cc.SkewBy(a,b,c)};cc.SkewBy.create=cc.skewBy;
cc.JumpBy=cc.ActionInterval.extend({_startPosition:null,_delta:null,_height:0,_jumps:0,_previousPosition:null,ctor:function(a,b,c,d,e){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!==d&&this.initWithDuration(a,b,c,d,e)},initWithDuration:function(a,b,c,d,e){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(void 0===e&&(e=d,d=c,c=b.y,b=b.x),this._delta.x=b,this._delta.y=c,this._height=d,this._jumps=
e,!0):!1},clone:function(){var a=new cc.JumpBy;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._delta,this._height,this._jumps),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);var b=a.getPositionX();a=a.getPositionY();this._previousPosition.x=b;this._previousPosition.y=a;this._startPosition.x=b;this._startPosition.y=a},update:function(a){if(a=this._computeEaseTime(a),this.target){var b=a*this._jumps%1,b=4*this._height*b*(1-b),b=b+this._delta.y*
a;a*=this._delta.x;var c=this._startPosition;if(cc.ENABLE_STACKABLE_ACTIONS){var d=this.target.getPositionX(),e=this.target.getPositionY(),f=this._previousPosition;c.x=c.x+d-f.x;c.y=c.y+e-f.y;a+=c.x;b+=c.y;f.x=a;f.y=b;this.target.setPosition(a,b)}else this.target.setPosition(c.x+a,c.y+b)}},reverse:function(){var a=new cc.JumpBy(this._duration,cc.p(-this._delta.x,-this._delta.y),this._height,this._jumps);return this._cloneDecoration(a),this._reverseEaseList(a),a}});
cc.jumpBy=function(a,b,c,d,e){return new cc.JumpBy(a,b,c,d,e)};cc.JumpBy.create=cc.jumpBy;
cc.JumpTo=cc.JumpBy.extend({_endPosition:null,ctor:function(a,b,c,d,e){cc.JumpBy.prototype.ctor.call(this);this._endPosition=cc.p(0,0);void 0!==d&&this.initWithDuration(a,b,c,d,e)},initWithDuration:function(a,b,c,d,e){return cc.JumpBy.prototype.initWithDuration.call(this,a,b,c,d,e)?(void 0===e&&(c=b.y,b=b.x),this._endPosition.x=b,this._endPosition.y=c,!0):!1},startWithTarget:function(a){cc.JumpBy.prototype.startWithTarget.call(this,a);this._delta.x=this._endPosition.x-this._startPosition.x;this._delta.y=
this._endPosition.y-this._startPosition.y},clone:function(){var a=new cc.JumpTo;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._endPosition,this._height,this._jumps),a}});cc.jumpTo=function(a,b,c,d,e){return new cc.JumpTo(a,b,c,d,e)};cc.JumpTo.create=cc.jumpTo;cc.bezierAt=function(a,b,c,d,e){return Math.pow(1-e,3)*a+3*e*Math.pow(1-e,2)*b+3*Math.pow(e,2)*(1-e)*c+Math.pow(e,3)*d};
cc.BezierBy=cc.ActionInterval.extend({_config:null,_startPosition:null,_previousPosition:null,ctor:function(a,b){cc.ActionInterval.prototype.ctor.call(this);this._config=[];this._startPosition=cc.p(0,0);this._previousPosition=cc.p(0,0);b&&this.initWithDuration(a,b)},initWithDuration:function(a,b){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._config=b,!0):!1},clone:function(){var a=new cc.BezierBy;this._cloneDecoration(a);for(var b=[],c=0;c<this._config.length;c++){var d=
this._config[c];b.push(cc.p(d.x,d.y))}return a.initWithDuration(this._duration,b),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);var b=a.getPositionX();a=a.getPositionY();this._previousPosition.x=b;this._previousPosition.y=a;this._startPosition.x=b;this._startPosition.y=a},update:function(a){if(a=this._computeEaseTime(a),this.target){var b=this._config,c=b[0].y,d=b[1].y,e=b[2].y,b=cc.bezierAt(0,b[0].x,b[1].x,b[2].x,a);a=cc.bezierAt(0,c,d,e,a);c=this._startPosition;
if(cc.ENABLE_STACKABLE_ACTIONS){var d=this.target.getPositionX(),e=this.target.getPositionY(),f=this._previousPosition;c.x=c.x+d-f.x;c.y=c.y+e-f.y;b+=c.x;a+=c.y;f.x=b;f.y=a;this.target.setPosition(b,a)}else this.target.setPosition(c.x+b,c.y+a)}},reverse:function(){var a=this._config,a=[cc.pAdd(a[1],cc.pNeg(a[2])),cc.pAdd(a[0],cc.pNeg(a[2])),cc.pNeg(a[2])],a=new cc.BezierBy(this._duration,a);return this._cloneDecoration(a),this._reverseEaseList(a),a}});
cc.bezierBy=function(a,b){return new cc.BezierBy(a,b)};cc.BezierBy.create=cc.bezierBy;
cc.BezierTo=cc.BezierBy.extend({_toConfig:null,ctor:function(a,b){cc.BezierBy.prototype.ctor.call(this);this._toConfig=[];b&&this.initWithDuration(a,b)},initWithDuration:function(a,b){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._toConfig=b,!0):!1},clone:function(){var a=new cc.BezierTo;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._toConfig),a},startWithTarget:function(a){cc.BezierBy.prototype.startWithTarget.call(this,a);a=this._startPosition;var b=
this._toConfig,c=this._config;c[0]=cc.pSub(b[0],a);c[1]=cc.pSub(b[1],a);c[2]=cc.pSub(b[2],a)}});cc.bezierTo=function(a,b){return new cc.BezierTo(a,b)};cc.BezierTo.create=cc.bezierTo;
cc.ScaleTo=cc.ActionInterval.extend({_scaleX:1,_scaleY:1,_startScaleX:1,_startScaleY:1,_endScaleX:0,_endScaleY:0,_deltaX:0,_deltaY:0,ctor:function(a,b,c){cc.ActionInterval.prototype.ctor.call(this);void 0!==b&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._endScaleX=b,this._endScaleY=null!=c?c:b,!0):!1},clone:function(){var a=new cc.ScaleTo;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._endScaleX,
this._endScaleY),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._startScaleX=a.scaleX;this._startScaleY=a.scaleY;this._deltaX=this._endScaleX-this._startScaleX;this._deltaY=this._endScaleY-this._startScaleY},update:function(a){a=this._computeEaseTime(a);this.target&&(this.target.scaleX=this._startScaleX+this._deltaX*a,this.target.scaleY=this._startScaleY+this._deltaY*a)}});cc.scaleTo=function(a,b,c){return new cc.ScaleTo(a,b,c)};cc.ScaleTo.create=cc.scaleTo;
cc.ScaleBy=cc.ScaleTo.extend({startWithTarget:function(a){cc.ScaleTo.prototype.startWithTarget.call(this,a);this._deltaX=this._startScaleX*this._endScaleX-this._startScaleX;this._deltaY=this._startScaleY*this._endScaleY-this._startScaleY},reverse:function(){var a=new cc.ScaleBy(this._duration,1/this._endScaleX,1/this._endScaleY);return this._cloneDecoration(a),this._reverseEaseList(a),a},clone:function(){var a=new cc.ScaleBy;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._endScaleX,
this._endScaleY),a}});cc.scaleBy=function(a,b,c){return new cc.ScaleBy(a,b,c)};cc.ScaleBy.create=cc.scaleBy;
cc.Blink=cc.ActionInterval.extend({_times:0,_originalState:!1,ctor:function(a,b){cc.ActionInterval.prototype.ctor.call(this);void 0!==b&&this.initWithDuration(a,b)},initWithDuration:function(a,b){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._times=b,!0):!1},clone:function(){var a=new cc.Blink;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._times),a},update:function(a){if(a=this._computeEaseTime(a),this.target&&!this.isDone()){var b=1/this._times;this.target.visible=
a%b>b/2}},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._originalState=a.visible},stop:function(){this.target.visible=this._originalState;cc.ActionInterval.prototype.stop.call(this)},reverse:function(){var a=new cc.Blink(this._duration,this._times);return this._cloneDecoration(a),this._reverseEaseList(a),a}});cc.blink=function(a,b){return new cc.Blink(a,b)};cc.Blink.create=cc.blink;
cc.FadeTo=cc.ActionInterval.extend({_toOpacity:0,_fromOpacity:0,ctor:function(a,b){cc.ActionInterval.prototype.ctor.call(this);void 0!==b&&this.initWithDuration(a,b)},initWithDuration:function(a,b){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._toOpacity=b,!0):!1},clone:function(){var a=new cc.FadeTo;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._toOpacity),a},update:function(a){a=this._computeEaseTime(a);var b=void 0!==this._fromOpacity?this._fromOpacity:
255;this.target.opacity=b+(this._toOpacity-b)*a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._fromOpacity=a.opacity}});cc.fadeTo=function(a,b){return new cc.FadeTo(a,b)};cc.FadeTo.create=cc.fadeTo;
cc.FadeIn=cc.FadeTo.extend({_reverseAction:null,ctor:function(a){cc.FadeTo.prototype.ctor.call(this);null==a&&(a=0);this.initWithDuration(a,255)},reverse:function(){var a=new cc.FadeOut;return a.initWithDuration(this._duration,0),this._cloneDecoration(a),this._reverseEaseList(a),a},clone:function(){var a=new cc.FadeIn;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._toOpacity),a},startWithTarget:function(a){this._reverseAction&&(this._toOpacity=this._reverseAction._fromOpacity);
cc.FadeTo.prototype.startWithTarget.call(this,a)}});cc.fadeIn=function(a){return new cc.FadeIn(a)};cc.FadeIn.create=cc.fadeIn;
cc.FadeOut=cc.FadeTo.extend({ctor:function(a){cc.FadeTo.prototype.ctor.call(this);null==a&&(a=0);this.initWithDuration(a,0)},reverse:function(){var a=new cc.FadeIn;return a._reverseAction=this,a.initWithDuration(this._duration,255),this._cloneDecoration(a),this._reverseEaseList(a),a},clone:function(){var a=new cc.FadeOut;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._toOpacity),a}});cc.fadeOut=function(a){return new cc.FadeOut(a)};cc.FadeOut.create=cc.fadeOut;
cc.TintTo=cc.ActionInterval.extend({_to:null,_from:null,ctor:function(a,b,c,d){cc.ActionInterval.prototype.ctor.call(this);this._to=cc.color(0,0,0);this._from=cc.color(0,0,0);void 0!==d&&this.initWithDuration(a,b,c,d)},initWithDuration:function(a,b,c,d){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._to=cc.color(b,c,d),!0):!1},clone:function(){var a=new cc.TintTo;this._cloneDecoration(a);var b=this._to;return a.initWithDuration(this._duration,b.r,b.g,b.b),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,
a);this._from=this.target.color},update:function(a){a=this._computeEaseTime(a);var b=this._from,c=this._to;b&&(this.target.color=cc.color(b.r+(c.r-b.r)*a,b.g+(c.g-b.g)*a,b.b+(c.b-b.b)*a))}});cc.tintTo=function(a,b,c,d){return new cc.TintTo(a,b,c,d)};cc.TintTo.create=cc.tintTo;
cc.TintBy=cc.ActionInterval.extend({_deltaR:0,_deltaG:0,_deltaB:0,_fromR:0,_fromG:0,_fromB:0,ctor:function(a,b,c,d){cc.ActionInterval.prototype.ctor.call(this);void 0!==d&&this.initWithDuration(a,b,c,d)},initWithDuration:function(a,b,c,d){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._deltaR=b,this._deltaG=c,this._deltaB=d,!0):!1},clone:function(){var a=new cc.TintBy;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._deltaR,this._deltaG,this._deltaB),
a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);a=a.color;this._fromR=a.r;this._fromG=a.g;this._fromB=a.b},update:function(a){a=this._computeEaseTime(a);this.target.color=cc.color(this._fromR+this._deltaR*a,this._fromG+this._deltaG*a,this._fromB+this._deltaB*a)},reverse:function(){var a=new cc.TintBy(this._duration,-this._deltaR,-this._deltaG,-this._deltaB);return this._cloneDecoration(a),this._reverseEaseList(a),a}});
cc.tintBy=function(a,b,c,d){return new cc.TintBy(a,b,c,d)};cc.TintBy.create=cc.tintBy;cc.DelayTime=cc.ActionInterval.extend({update:function(a){},reverse:function(){var a=new cc.DelayTime(this._duration);return this._cloneDecoration(a),this._reverseEaseList(a),a},clone:function(){var a=new cc.DelayTime;return this._cloneDecoration(a),a.initWithDuration(this._duration),a}});cc.delayTime=function(a){return new cc.DelayTime(a)};cc.DelayTime.create=cc.delayTime;
cc.ReverseTime=cc.ActionInterval.extend({_other:null,ctor:function(a){cc.ActionInterval.prototype.ctor.call(this);this._other=null;a&&this.initWithAction(a)},initWithAction:function(a){if(!a)throw"cc.ReverseTime.initWithAction(): action must be non null";if(a===this._other)throw"cc.ReverseTime.initWithAction(): the action was already passed in.";return cc.ActionInterval.prototype.initWithDuration.call(this,a._duration)?(this._other=a,!0):!1},clone:function(){var a=new cc.ReverseTime;return this._cloneDecoration(a),
a.initWithAction(this._other.clone()),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._other.startWithTarget(a)},update:function(a){a=this._computeEaseTime(a);this._other&&this._other.update(1-a)},reverse:function(){return this._other.clone()},stop:function(){this._other.stop();cc.Action.prototype.stop.call(this)}});cc.reverseTime=function(a){return new cc.ReverseTime(a)};cc.ReverseTime.create=cc.reverseTime;
cc.Animate=cc.ActionInterval.extend({_animation:null,_nextFrame:0,_origFrame:null,_executedLoops:0,_splitTimes:null,ctor:function(a){cc.ActionInterval.prototype.ctor.call(this);this._splitTimes=[];a&&this.initWithAnimation(a)},getAnimation:function(){return this._animation},setAnimation:function(a){this._animation=a},initWithAnimation:function(a){if(!a)throw"cc.Animate.initWithAnimation(): animation must be non-NULL";var b=a.getDuration();if(this.initWithDuration(b*a.getLoops())){this._nextFrame=
0;this.setAnimation(a);this._origFrame=null;this._executedLoops=0;var c=this._splitTimes,d=c.length=0,e=b/a.getTotalDelayUnits();a=a.getFrames();cc.arrayVerifyType(a,cc.AnimationFrame);for(var f=0;f<a.length;f++){var g=d*e/b,d=d+a[f].getDelayUnits();c.push(g)}return!0}return!1},clone:function(){var a=new cc.Animate;return this._cloneDecoration(a),a.initWithAnimation(this._animation.clone()),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._animation.getRestoreOriginalFrame()&&
(this._origFrame=a.displayFrame());this._executedLoops=this._nextFrame=0},update:function(a){if(a=this._computeEaseTime(a),1>a)a*=this._animation.getLoops(),(0|a)>this._executedLoops&&(this._nextFrame=0,this._executedLoops++),a%=1;for(var b=this._animation.getFrames(),c=b.length,d=this._splitTimes,e=this._nextFrame;c>e&&d[e]<=a;e++)this.target.setSpriteFrame(b[e].getSpriteFrame()),this._nextFrame=e+1},reverse:function(){var a=this._animation,b=a.getFrames(),c=[];if(cc.arrayVerifyType(b,cc.AnimationFrame),
0<b.length)for(var d=b.length-1;0<=d;d--){var e=b[d];if(!e)break;c.push(e.clone())}b=new cc.Animation(c,a.getDelayPerUnit(),a.getLoops());b.setRestoreOriginalFrame(a.getRestoreOriginalFrame());a=new cc.Animate(b);return this._cloneDecoration(a),this._reverseEaseList(a),a},stop:function(){this._animation.getRestoreOriginalFrame()&&this.target&&this.target.setSpriteFrame(this._origFrame);cc.Action.prototype.stop.call(this)}});cc.animate=function(a){return new cc.Animate(a)};cc.Animate.create=cc.animate;
cc.TargetedAction=cc.ActionInterval.extend({_action:null,_forcedTarget:null,ctor:function(a,b){cc.ActionInterval.prototype.ctor.call(this);b&&this.initWithTarget(a,b)},initWithTarget:function(a,b){return this.initWithDuration(b._duration)?(this._forcedTarget=a,this._action=b,!0):!1},clone:function(){var a=new cc.TargetedAction;return this._cloneDecoration(a),a.initWithTarget(this._forcedTarget,this._action.clone()),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,
a);this._action.startWithTarget(this._forcedTarget)},stop:function(){this._action.stop()},update:function(a){a=this._computeEaseTime(a);this._action.update(a)},getForcedTarget:function(){return this._forcedTarget},setForcedTarget:function(a){this._forcedTarget!==a&&(this._forcedTarget=a)}});cc.targetedAction=function(a,b){return new cc.TargetedAction(a,b)};cc.TargetedAction.create=cc.targetedAction;
cc.ActionInstant=cc.FiniteTimeAction.extend({isDone:function(){return!0},step:function(a){this.update(1)},update:function(a){},reverse:function(){return this.clone()},clone:function(){return new cc.ActionInstant}});cc.Show=cc.ActionInstant.extend({update:function(a){this.target.visible=!0},reverse:function(){return new cc.Hide},clone:function(){return new cc.Show}});cc.show=function(){return new cc.Show};cc.Show.create=cc.show;
cc.Hide=cc.ActionInstant.extend({update:function(a){this.target.visible=!1},reverse:function(){return new cc.Show},clone:function(){return new cc.Hide}});cc.hide=function(){return new cc.Hide};cc.Hide.create=cc.hide;cc.ToggleVisibility=cc.ActionInstant.extend({update:function(a){this.target.visible=!this.target.visible},reverse:function(){return new cc.ToggleVisibility},clone:function(){return new cc.ToggleVisibility}});cc.toggleVisibility=function(){return new cc.ToggleVisibility};
cc.ToggleVisibility.create=cc.toggleVisibility;cc.RemoveSelf=cc.ActionInstant.extend({_isNeedCleanUp:!0,ctor:function(a){cc.FiniteTimeAction.prototype.ctor.call(this);void 0!==a&&this.init(a)},update:function(a){this.target.removeFromParent(this._isNeedCleanUp)},init:function(a){return this._isNeedCleanUp=a,!0},reverse:function(){return new cc.RemoveSelf(this._isNeedCleanUp)},clone:function(){return new cc.RemoveSelf(this._isNeedCleanUp)}});cc.removeSelf=function(a){return new cc.RemoveSelf(a)};
cc.RemoveSelf.create=cc.removeSelf;cc.FlipX=cc.ActionInstant.extend({_flippedX:!1,ctor:function(a){cc.FiniteTimeAction.prototype.ctor.call(this);this._flippedX=!1;void 0!==a&&this.initWithFlipX(a)},initWithFlipX:function(a){return this._flippedX=a,!0},update:function(a){this.target.flippedX=this._flippedX},reverse:function(){return new cc.FlipX(!this._flippedX)},clone:function(){var a=new cc.FlipX;return a.initWithFlipX(this._flippedX),a}});cc.flipX=function(a){return new cc.FlipX(a)};
cc.FlipX.create=cc.flipX;cc.FlipY=cc.ActionInstant.extend({_flippedY:!1,ctor:function(a){cc.FiniteTimeAction.prototype.ctor.call(this);this._flippedY=!1;void 0!==a&&this.initWithFlipY(a)},initWithFlipY:function(a){return this._flippedY=a,!0},update:function(a){this.target.flippedY=this._flippedY},reverse:function(){return new cc.FlipY(!this._flippedY)},clone:function(){var a=new cc.FlipY;return a.initWithFlipY(this._flippedY),a}});cc.flipY=function(a){return new cc.FlipY(a)};cc.FlipY.create=cc.flipY;
cc.Place=cc.ActionInstant.extend({_x:0,_y:0,ctor:function(a,b){cc.FiniteTimeAction.prototype.ctor.call(this);this._y=this._x=0;void 0!==a&&(void 0!==a.x&&(b=a.y,a=a.x),this.initWithPosition(a,b))},initWithPosition:function(a,b){return this._x=a,this._y=b,!0},update:function(a){this.target.setPosition(this._x,this._y)},clone:function(){var a=new cc.Place;return a.initWithPosition(this._x,this._y),a}});cc.place=function(a,b){return new cc.Place(a,b)};cc.Place.create=cc.place;
cc.CallFunc=cc.ActionInstant.extend({_selectorTarget:null,_callFunc:null,_function:null,_data:null,ctor:function(a,b,c){cc.FiniteTimeAction.prototype.ctor.call(this);void 0!==a&&(void 0===b?this.initWithFunction(a):this.initWithFunction(a,b,c))},initWithFunction:function(a,b,c){return b?(this._data=c,this._callFunc=a,this._selectorTarget=b):a&&(this._function=a),!0},execute:function(){null!=this._callFunc?this._callFunc.call(this._selectorTarget,this.target,this._data):this._function&&this._function.call(null,
this.target)},update:function(a){this.execute()},getTargetCallback:function(){return this._selectorTarget},setTargetCallback:function(a){a!==this._selectorTarget&&(this._selectorTarget&&(this._selectorTarget=null),this._selectorTarget=a)},clone:function(){var a=new cc.CallFunc;return this._selectorTarget?a.initWithFunction(this._callFunc,this._selectorTarget,this._data):this._function&&a.initWithFunction(this._function),a}});cc.callFunc=function(a,b,c){return new cc.CallFunc(a,b,c)};
cc.CallFunc.create=cc.callFunc;
cc.ActionCamera=cc.ActionInterval.extend({_centerXOrig:0,_centerYOrig:0,_centerZOrig:0,_eyeXOrig:0,_eyeYOrig:0,_eyeZOrig:0,_upXOrig:0,_upYOrig:0,_upZOrig:0,ctor:function(){cc.ActionInterval.prototype.ctor.call(this);this._upZOrig=this._upYOrig=this._upXOrig=this._eyeZOrig=this._eyeYOrig=this._eyeXOrig=this._centerZOrig=this._centerYOrig=this._centerXOrig=0},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);a=a.getCamera();var b=a.getCenter();this._centerXOrig=b.x;
this._centerYOrig=b.y;this._centerZOrig=b.z;b=a.getEye();this._eyeXOrig=b.x;this._eyeYOrig=b.y;this._eyeZOrig=b.z;a=a.getUp();this._upXOrig=a.x;this._upYOrig=a.y;this._upZOrig=a.z},clone:function(){return new cc.ActionCamera},reverse:function(){return new cc.ReverseTime(this)}});
cc.OrbitCamera=cc.ActionCamera.extend({_radius:0,_deltaRadius:0,_angleZ:0,_deltaAngleZ:0,_angleX:0,_deltaAngleX:0,_radZ:0,_radDeltaZ:0,_radX:0,_radDeltaX:0,ctor:function(a,b,c,d,e,f,g){cc.ActionCamera.prototype.ctor.call(this);void 0!==g&&this.initWithDuration(a,b,c,d,e,f,g)},initWithDuration:function(a,b,c,d,e,f,g){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._radius=b,this._deltaRadius=c,this._angleZ=d,this._deltaAngleZ=e,this._angleX=f,this._deltaAngleX=g,this._radDeltaZ=
cc.degreesToRadians(e),this._radDeltaX=cc.degreesToRadians(g),!0):!1},sphericalRadius:function(){var a,b,c,d=this.target.getCamera(),e=d.getEye(),f=d.getCenter(),d=e.x-f.x,g=e.y-f.y,e=e.z-f.z,f=Math.sqrt(Math.pow(d,2)+Math.pow(g,2)+Math.pow(e,2)),h=Math.sqrt(Math.pow(d,2)+Math.pow(g,2));return 0===h&&(h=cc.FLT_EPSILON),0===f&&(f=cc.FLT_EPSILON),b=Math.acos(e/f),c=0>d?Math.PI-Math.asin(g/h):Math.asin(g/h),a=f/cc.Camera.getZEye(),{newRadius:a,zenith:b,azimuth:c}},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,
a);a=this.sphericalRadius();isNaN(this._radius)&&(this._radius=a.newRadius);isNaN(this._angleZ)&&(this._angleZ=cc.radiansToDegrees(a.zenith));isNaN(this._angleX)&&(this._angleX=cc.radiansToDegrees(a.azimuth));this._radZ=cc.degreesToRadians(this._angleZ);this._radX=cc.degreesToRadians(this._angleX)},clone:function(){var a=new cc.OrbitCamera;return a.initWithDuration(this._duration,this._radius,this._deltaRadius,this._angleZ,this._deltaAngleZ,this._angleX,this._deltaAngleX),a},update:function(a){a=
this._computeEaseTime(a);var b=(this._radius+this._deltaRadius*a)*cc.Camera.getZEye(),c=this._radZ+this._radDeltaZ*a,d=this._radX+this._radDeltaX*a;a=Math.sin(c)*Math.cos(d)*b+this._centerXOrig;d=Math.sin(c)*Math.sin(d)*b+this._centerYOrig;b=Math.cos(c)*b+this._centerZOrig;this.target.getCamera().setEye(a,d,b);this.target.setNodeDirty()}});cc.orbitCamera=function(a,b,c,d,e,f,g){return new cc.OrbitCamera(a,b,c,d,e,f,g)};cc.OrbitCamera.create=cc.orbitCamera;
cc.ActionEase=cc.ActionInterval.extend({_inner:null,ctor:function(a){cc.ActionInterval.prototype.ctor.call(this);a&&this.initWithAction(a)},initWithAction:function(a){if(!a)throw"cc.ActionEase.initWithAction(): action must be non nil";return this.initWithDuration(a.getDuration())?(this._inner=a,!0):!1},clone:function(){var a=new cc.ActionEase;return a.initWithAction(this._inner.clone()),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._inner.startWithTarget(this.target)},
stop:function(){this._inner.stop();cc.ActionInterval.prototype.stop.call(this)},update:function(a){this._inner.update(a)},reverse:function(){return new cc.ActionEase(this._inner.reverse())},getInnerAction:function(){return this._inner}});cc.actionEase=function(a){return new cc.ActionEase(a)};cc.ActionEase.create=cc.actionEase;
cc.EaseRateAction=cc.ActionEase.extend({_rate:0,ctor:function(a,b){cc.ActionEase.prototype.ctor.call(this);void 0!==b&&this.initWithAction(a,b)},setRate:function(a){this._rate=a},getRate:function(){return this._rate},initWithAction:function(a,b){return cc.ActionEase.prototype.initWithAction.call(this,a)?(this._rate=b,!0):!1},clone:function(){var a=new cc.EaseRateAction;return a.initWithAction(this._inner.clone(),this._rate),a},reverse:function(){return new cc.EaseRateAction(this._inner.reverse(),
1/this._rate)}});cc.easeRateAction=function(a,b){return new cc.EaseRateAction(a,b)};cc.EaseRateAction.create=cc.easeRateAction;cc.EaseIn=cc.EaseRateAction.extend({update:function(a){this._inner.update(Math.pow(a,this._rate))},reverse:function(){return new cc.EaseIn(this._inner.reverse(),1/this._rate)},clone:function(){var a=new cc.EaseIn;return a.initWithAction(this._inner.clone(),this._rate),a}});cc.EaseIn.create=function(a,b){return new cc.EaseIn(a,b)};
cc.easeIn=function(a){return{_rate:a,easing:function(a){return Math.pow(a,this._rate)},reverse:function(){return cc.easeIn(1/this._rate)}}};cc.EaseOut=cc.EaseRateAction.extend({update:function(a){this._inner.update(Math.pow(a,1/this._rate))},reverse:function(){return new cc.EaseOut(this._inner.reverse(),1/this._rate)},clone:function(){var a=new cc.EaseOut;return a.initWithAction(this._inner.clone(),this._rate),a}});cc.EaseOut.create=function(a,b){return new cc.EaseOut(a,b)};
cc.easeOut=function(a){return{_rate:a,easing:function(a){return Math.pow(a,1/this._rate)},reverse:function(){return cc.easeOut(1/this._rate)}}};cc.EaseInOut=cc.EaseRateAction.extend({update:function(a){a*=2;this._inner.update(1>a?0.5*Math.pow(a,this._rate):1-0.5*Math.pow(2-a,this._rate))},clone:function(){var a=new cc.EaseInOut;return a.initWithAction(this._inner.clone(),this._rate),a},reverse:function(){return new cc.EaseInOut(this._inner.reverse(),this._rate)}});
cc.EaseInOut.create=function(a,b){return new cc.EaseInOut(a,b)};cc.easeInOut=function(a){return{_rate:a,easing:function(a){return a*=2,1>a?0.5*Math.pow(a,this._rate):1-0.5*Math.pow(2-a,this._rate)},reverse:function(){return cc.easeInOut(this._rate)}}};
cc.EaseExponentialIn=cc.ActionEase.extend({update:function(a){this._inner.update(0===a?0:Math.pow(2,10*(a-1)))},reverse:function(){return new cc.EaseExponentialOut(this._inner.reverse())},clone:function(){var a=new cc.EaseExponentialIn;return a.initWithAction(this._inner.clone()),a}});cc.EaseExponentialIn.create=function(a){return new cc.EaseExponentialIn(a)};cc._easeExponentialInObj={easing:function(a){return 0===a?0:Math.pow(2,10*(a-1))},reverse:function(){return cc._easeExponentialOutObj}};
cc.easeExponentialIn=function(){return cc._easeExponentialInObj};cc.EaseExponentialOut=cc.ActionEase.extend({update:function(a){this._inner.update(1===a?1:-Math.pow(2,-10*a)+1)},reverse:function(){return new cc.EaseExponentialIn(this._inner.reverse())},clone:function(){var a=new cc.EaseExponentialOut;return a.initWithAction(this._inner.clone()),a}});cc.EaseExponentialOut.create=function(a){return new cc.EaseExponentialOut(a)};
cc._easeExponentialOutObj={easing:function(a){return 1===a?1:-Math.pow(2,-10*a)+1},reverse:function(){return cc._easeExponentialInObj}};cc.easeExponentialOut=function(){return cc._easeExponentialOutObj};
cc.EaseExponentialInOut=cc.ActionEase.extend({update:function(a){1!==a&&0!==a&&(a*=2,a=1>a?0.5*Math.pow(2,10*(a-1)):0.5*(-Math.pow(2,-10*(a-1))+2));this._inner.update(a)},reverse:function(){return new cc.EaseExponentialInOut(this._inner.reverse())},clone:function(){var a=new cc.EaseExponentialInOut;return a.initWithAction(this._inner.clone()),a}});cc.EaseExponentialInOut.create=function(a){return new cc.EaseExponentialInOut(a)};
cc._easeExponentialInOutObj={easing:function(a){return 1!==a&&0!==a?(a*=2,1>a?0.5*Math.pow(2,10*(a-1)):0.5*(-Math.pow(2,-10*(a-1))+2)):a},reverse:function(){return cc._easeExponentialInOutObj}};cc.easeExponentialInOut=function(){return cc._easeExponentialInOutObj};
cc.EaseSineIn=cc.ActionEase.extend({update:function(a){a=0===a||1===a?a:-1*Math.cos(a*Math.PI/2)+1;this._inner.update(a)},reverse:function(){return new cc.EaseSineOut(this._inner.reverse())},clone:function(){var a=new cc.EaseSineIn;return a.initWithAction(this._inner.clone()),a}});cc.EaseSineIn.create=function(a){return new cc.EaseSineIn(a)};cc._easeSineInObj={easing:function(a){return 0===a||1===a?a:-1*Math.cos(a*Math.PI/2)+1},reverse:function(){return cc._easeSineOutObj}};cc.easeSineIn=function(){return cc._easeSineInObj};
cc.EaseSineOut=cc.ActionEase.extend({update:function(a){a=0===a||1===a?a:Math.sin(a*Math.PI/2);this._inner.update(a)},reverse:function(){return new cc.EaseSineIn(this._inner.reverse())},clone:function(){var a=new cc.EaseSineOut;return a.initWithAction(this._inner.clone()),a}});cc.EaseSineOut.create=function(a){return new cc.EaseSineOut(a)};cc._easeSineOutObj={easing:function(a){return 0===a||1===a?a:Math.sin(a*Math.PI/2)},reverse:function(){return cc._easeSineInObj}};cc.easeSineOut=function(){return cc._easeSineOutObj};
cc.EaseSineInOut=cc.ActionEase.extend({update:function(a){a=0===a||1===a?a:-0.5*(Math.cos(Math.PI*a)-1);this._inner.update(a)},clone:function(){var a=new cc.EaseSineInOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseSineInOut(this._inner.reverse())}});cc.EaseSineInOut.create=function(a){return new cc.EaseSineInOut(a)};cc._easeSineInOutObj={easing:function(a){return 0===a||1===a?a:-0.5*(Math.cos(Math.PI*a)-1)},reverse:function(){return cc._easeSineInOutObj}};
cc.easeSineInOut=function(){return cc._easeSineInOutObj};
cc.EaseElastic=cc.ActionEase.extend({_period:0.3,ctor:function(a,b){cc.ActionEase.prototype.ctor.call(this);a&&this.initWithAction(a,b)},getPeriod:function(){return this._period},setPeriod:function(a){this._period=a},initWithAction:function(a,b){return cc.ActionEase.prototype.initWithAction.call(this,a),this._period=null==b?0.3:b,!0},reverse:function(){return cc.log("cc.EaseElastic.reverse(): it should be overridden in subclass."),null},clone:function(){var a=new cc.EaseElastic;return a.initWithAction(this._inner.clone(),
this._period),a}});cc.EaseElastic.create=function(a,b){return new cc.EaseElastic(a,b)};cc.EaseElasticIn=cc.EaseElastic.extend({update:function(a){var b=0;0===a||1===a?b=a:(b=this._period/4,a-=1,b=-Math.pow(2,10*a)*Math.sin(2*(a-b)*Math.PI/this._period));this._inner.update(b)},reverse:function(){return new cc.EaseElasticOut(this._inner.reverse(),this._period)},clone:function(){var a=new cc.EaseElasticIn;return a.initWithAction(this._inner.clone(),this._period),a}});
cc.EaseElasticIn.create=function(a,b){return new cc.EaseElasticIn(a,b)};cc._easeElasticInObj={easing:function(a){return 0===a||1===a?a:(a-=1,-Math.pow(2,10*a)*Math.sin(2*(a-0.075)*Math.PI/0.3))},reverse:function(){return cc._easeElasticOutObj}};cc.easeElasticIn=function(a){return a&&0.3!==a?{_period:a,easing:function(a){return 0===a||1===a?a:(a-=1,-Math.pow(2,10*a)*Math.sin(2*(a-this._period/4)*Math.PI/this._period))},reverse:function(){return cc.easeElasticOut(this._period)}}:cc._easeElasticInObj};
cc.EaseElasticOut=cc.EaseElastic.extend({update:function(a){var b=0;0===a||1===a?b=a:(b=this._period/4,b=Math.pow(2,-10*a)*Math.sin(2*(a-b)*Math.PI/this._period)+1);this._inner.update(b)},reverse:function(){return new cc.EaseElasticIn(this._inner.reverse(),this._period)},clone:function(){var a=new cc.EaseElasticOut;return a.initWithAction(this._inner.clone(),this._period),a}});cc.EaseElasticOut.create=function(a,b){return new cc.EaseElasticOut(a,b)};
cc._easeElasticOutObj={easing:function(a){return 0===a||1===a?a:Math.pow(2,-10*a)*Math.sin(2*(a-0.075)*Math.PI/0.3)+1},reverse:function(){return cc._easeElasticInObj}};cc.easeElasticOut=function(a){return a&&0.3!==a?{_period:a,easing:function(a){return 0===a||1===a?a:Math.pow(2,-10*a)*Math.sin(2*(a-this._period/4)*Math.PI/this._period)+1},reverse:function(){return cc.easeElasticIn(this._period)}}:cc._easeElasticOutObj};
cc.EaseElasticInOut=cc.EaseElastic.extend({update:function(a){var b=0,b=this._period;if(0===a||1===a)b=a;else{b||(b=this._period=0.3*1.5);var c=b/4;a=2*a-1;b=0>a?-0.5*Math.pow(2,10*a)*Math.sin(2*(a-c)*Math.PI/b):0.5*Math.pow(2,-10*a)*Math.sin(2*(a-c)*Math.PI/b)+1}this._inner.update(b)},reverse:function(){return new cc.EaseElasticInOut(this._inner.reverse(),this._period)},clone:function(){var a=new cc.EaseElasticInOut;return a.initWithAction(this._inner.clone(),this._period),a}});
cc.EaseElasticInOut.create=function(a,b){return new cc.EaseElasticInOut(a,b)};cc.easeElasticInOut=function(a){return a=a||0.3,{_period:a,easing:function(a){var c=0,c=this._period;if(0===a||1===a)c=a;else{c||(c=this._period=0.3*1.5);var d=c/4;a=2*a-1;c=0>a?-0.5*Math.pow(2,10*a)*Math.sin(2*(a-d)*Math.PI/c):0.5*Math.pow(2,-10*a)*Math.sin(2*(a-d)*Math.PI/c)+1}return c},reverse:function(){return cc.easeElasticInOut(this._period)}}};
cc.EaseBounce=cc.ActionEase.extend({bounceTime:function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?(a-=1.5/2.75,7.5625*a*a+0.75):2.5/2.75>a?(a-=2.25/2.75,7.5625*a*a+0.9375):(a-=2.625/2.75,7.5625*a*a+0.984375)},clone:function(){var a=new cc.EaseBounce;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseBounce(this._inner.reverse())}});cc.EaseBounce.create=function(a){return new cc.EaseBounce(a)};
cc.EaseBounceIn=cc.EaseBounce.extend({update:function(a){a=1-this.bounceTime(1-a);this._inner.update(a)},reverse:function(){return new cc.EaseBounceOut(this._inner.reverse())},clone:function(){var a=new cc.EaseBounceIn;return a.initWithAction(this._inner.clone()),a}});cc.EaseBounceIn.create=function(a){return new cc.EaseBounceIn(a)};cc._bounceTime=function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?(a-=1.5/2.75,7.5625*a*a+0.75):2.5/2.75>a?(a-=2.25/2.75,7.5625*a*a+0.9375):(a-=2.625/2.75,7.5625*a*a+0.984375)};
cc._easeBounceInObj={easing:function(a){return 1-cc._bounceTime(1-a)},reverse:function(){return cc._easeBounceOutObj}};cc.easeBounceIn=function(){return cc._easeBounceInObj};cc.EaseBounceOut=cc.EaseBounce.extend({update:function(a){a=this.bounceTime(a);this._inner.update(a)},reverse:function(){return new cc.EaseBounceIn(this._inner.reverse())},clone:function(){var a=new cc.EaseBounceOut;return a.initWithAction(this._inner.clone()),a}});cc.EaseBounceOut.create=function(a){return new cc.EaseBounceOut(a)};
cc._easeBounceOutObj={easing:function(a){return cc._bounceTime(a)},reverse:function(){return cc._easeBounceInObj}};cc.easeBounceOut=function(){return cc._easeBounceOutObj};cc.EaseBounceInOut=cc.EaseBounce.extend({update:function(a){var b=0;0.5>a?(a*=2,b=0.5*(1-this.bounceTime(1-a))):b=0.5*this.bounceTime(2*a-1)+0.5;this._inner.update(b)},clone:function(){var a=new cc.EaseBounceInOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseBounceInOut(this._inner.reverse())}});
cc.EaseBounceInOut.create=function(a){return new cc.EaseBounceInOut(a)};cc._easeBounceInOutObj={easing:function(a){var b;return 0.5>a?(a*=2,b=0.5*(1-cc._bounceTime(1-a))):b=0.5*cc._bounceTime(2*a-1)+0.5,b},reverse:function(){return cc._easeBounceInOutObj}};cc.easeBounceInOut=function(){return cc._easeBounceInOutObj};
cc.EaseBackIn=cc.ActionEase.extend({update:function(a){this._inner.update(0===a||1===a?a:a*a*(2.70158*a-1.70158))},reverse:function(){return new cc.EaseBackOut(this._inner.reverse())},clone:function(){var a=new cc.EaseBackIn;return a.initWithAction(this._inner.clone()),a}});cc.EaseBackIn.create=function(a){return new cc.EaseBackIn(a)};cc._easeBackInObj={easing:function(a){return 0===a||1===a?a:a*a*(2.70158*a-1.70158)},reverse:function(){return cc._easeBackOutObj}};cc.easeBackIn=function(){return cc._easeBackInObj};
cc.EaseBackOut=cc.ActionEase.extend({update:function(a){a-=1;this._inner.update(a*a*(2.70158*a+1.70158)+1)},reverse:function(){return new cc.EaseBackIn(this._inner.reverse())},clone:function(){var a=new cc.EaseBackOut;return a.initWithAction(this._inner.clone()),a}});cc.EaseBackOut.create=function(a){return new cc.EaseBackOut(a)};cc._easeBackOutObj={easing:function(a){return a-=1,a*a*(2.70158*a+1.70158)+1},reverse:function(){return cc._easeBackInObj}};cc.easeBackOut=function(){return cc._easeBackOutObj};
cc.EaseBackInOut=cc.ActionEase.extend({update:function(a){a*=2;1>a?this._inner.update(a*a*(3.5949095*a-2.5949095)/2):(a-=2,this._inner.update(a*a*(3.5949095*a+2.5949095)/2+1))},clone:function(){var a=new cc.EaseBackInOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseBackInOut(this._inner.reverse())}});cc.EaseBackInOut.create=function(a){return new cc.EaseBackInOut(a)};
cc._easeBackInOutObj={easing:function(a){return a*=2,1>a?a*a*(3.5949095*a-2.5949095)/2:(a-=2,a*a*(3.5949095*a+2.5949095)/2+1)},reverse:function(){return cc._easeBackInOutObj}};cc.easeBackInOut=function(){return cc._easeBackInOutObj};
cc.EaseBezierAction=cc.ActionEase.extend({_p0:null,_p1:null,_p2:null,_p3:null,ctor:function(a){cc.ActionEase.prototype.ctor.call(this,a)},_updateTime:function(a,b,c,d,e){return Math.pow(1-e,3)*a+3*e*Math.pow(1-e,2)*b+3*Math.pow(e,2)*(1-e)*c+Math.pow(e,3)*d},update:function(a){a=this._updateTime(this._p0,this._p1,this._p2,this._p3,a);this._inner.update(a)},clone:function(){var a=new cc.EaseBezierAction;return a.initWithAction(this._inner.clone()),a.setBezierParamer(this._p0,this._p1,this._p2,this._p3),
a},reverse:function(){var a=new cc.EaseBezierAction(this._inner.reverse());return a.setBezierParamer(this._p3,this._p2,this._p1,this._p0),a},setBezierParamer:function(a,b,c,d){this._p0=a||0;this._p1=b||0;this._p2=c||0;this._p3=d||0}});cc.EaseBezierAction.create=function(a){return new cc.EaseBezierAction(a)};cc.easeBezierAction=function(a,b,c,d){return{easing:function(e){return cc.EaseBezierAction.prototype._updateTime(a,b,c,d,e)},reverse:function(){return cc.easeBezierAction(d,c,b,a)}}};
cc.EaseQuadraticActionIn=cc.ActionEase.extend({_updateTime:function(a){return Math.pow(a,2)},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuadraticActionIn;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseQuadraticActionIn(this._inner.reverse())}});cc.EaseQuadraticActionIn.create=function(a){return new cc.EaseQuadraticActionIn(a)};cc._easeQuadraticActionIn={easing:cc.EaseQuadraticActionIn.prototype._updateTime,reverse:function(){return cc._easeQuadraticActionIn}};
cc.easeQuadraticActionIn=function(){return cc._easeQuadraticActionIn};cc.EaseQuadraticActionOut=cc.ActionEase.extend({_updateTime:function(a){return-a*(a-2)},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuadraticActionOut;return a.initWithAction(),a},reverse:function(){return new cc.EaseQuadraticActionOut(this._inner.reverse())}});cc.EaseQuadraticActionOut.create=function(a){return new cc.EaseQuadraticActionOut(a)};
cc._easeQuadraticActionOut={easing:cc.EaseQuadraticActionOut.prototype._updateTime,reverse:function(){return cc._easeQuadraticActionOut}};cc.easeQuadraticActionOut=function(){return cc._easeQuadraticActionOut};cc.EaseQuadraticActionInOut=cc.ActionEase.extend({_updateTime:function(a){return a*=2,1>a||--a,a},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuadraticActionInOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseQuadraticActionInOut(this._inner.reverse())}});
cc.EaseQuadraticActionInOut.create=function(a){return new cc.EaseQuadraticActionInOut(a)};cc._easeQuadraticActionInOut={easing:cc.EaseQuadraticActionInOut.prototype._updateTime,reverse:function(){return cc._easeQuadraticActionInOut}};cc.easeQuadraticActionInOut=function(){return cc._easeQuadraticActionInOut};
cc.EaseQuarticActionIn=cc.ActionEase.extend({_updateTime:function(a){return a*a*a*a},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuarticActionIn;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseQuarticActionIn(this._inner.reverse())}});cc.EaseQuarticActionIn.create=function(a){return new cc.EaseQuarticActionIn(a)};cc._easeQuarticActionIn={easing:cc.EaseQuarticActionIn.prototype._updateTime,reverse:function(){return cc._easeQuarticActionIn}};
cc.easeQuarticActionIn=function(){return cc._easeQuarticActionIn};cc.EaseQuarticActionOut=cc.ActionEase.extend({_updateTime:function(a){return a-=1,-(a*a*a*a-1)},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuarticActionOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseQuarticActionOut(this._inner.reverse())}});cc.EaseQuarticActionOut.create=function(a){return new cc.EaseQuarticActionOut(a)};
cc._easeQuarticActionOut={easing:cc.EaseQuarticActionOut.prototype._updateTime,reverse:function(){return cc._easeQuarticActionOut}};cc.easeQuarticActionOut=function(){return cc._easeQuarticActionOut};cc.EaseQuarticActionInOut=cc.ActionEase.extend({_updateTime:function(a){return a*=2,1>a?0.5*a*a*a*a:(a-=2,-0.5*(a*a*a*a-2))},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuarticActionInOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseQuarticActionInOut(this._inner.reverse())}});
cc.EaseQuarticActionInOut.create=function(a){return new cc.EaseQuarticActionInOut(a)};cc._easeQuarticActionInOut={easing:cc.EaseQuarticActionInOut.prototype._updateTime,reverse:function(){return cc._easeQuarticActionInOut}};cc.easeQuarticActionInOut=function(){return cc._easeQuarticActionInOut};
cc.EaseQuinticActionIn=cc.ActionEase.extend({_updateTime:function(a){return a*a*a*a*a},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuinticActionIn;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseQuinticActionIn(this._inner.reverse())}});cc.EaseQuinticActionIn.create=function(a){return new cc.EaseQuinticActionIn(a)};cc._easeQuinticActionIn={easing:cc.EaseQuinticActionIn.prototype._updateTime,reverse:function(){return cc._easeQuinticActionIn}};
cc.easeQuinticActionIn=function(){return cc._easeQuinticActionIn};cc.EaseQuinticActionOut=cc.ActionEase.extend({_updateTime:function(a){return a-=1,a*a*a*a*a+1},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuinticActionOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseQuinticActionOut(this._inner.reverse())}});cc.EaseQuinticActionOut.create=function(a){return new cc.EaseQuinticActionOut(a)};
cc._easeQuinticActionOut={easing:cc.EaseQuinticActionOut.prototype._updateTime,reverse:function(){return cc._easeQuinticActionOut}};cc.easeQuinticActionOut=function(){return cc._easeQuinticActionOut};cc.EaseQuinticActionInOut=cc.ActionEase.extend({_updateTime:function(a){return a*=2,1>a?0.5*a*a*a*a*a:(a-=2,0.5*(a*a*a*a*a+2))},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuinticActionInOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseQuinticActionInOut(this._inner.reverse())}});
cc.EaseQuinticActionInOut.create=function(a){return new cc.EaseQuinticActionInOut(a)};cc._easeQuinticActionInOut={easing:cc.EaseQuinticActionInOut.prototype._updateTime,reverse:function(){return cc._easeQuinticActionInOut}};cc.easeQuinticActionInOut=function(){return cc._easeQuinticActionInOut};
cc.EaseCircleActionIn=cc.ActionEase.extend({_updateTime:function(a){return-1*(Math.sqrt(1-a*a)-1)},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseCircleActionIn;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseCircleActionIn(this._inner.reverse())}});cc.EaseCircleActionIn.create=function(a){return new cc.EaseCircleActionIn(a)};cc._easeCircleActionIn={easing:cc.EaseCircleActionIn.prototype._updateTime,reverse:function(){return cc._easeCircleActionIn}};
cc.easeCircleActionIn=function(){return cc._easeCircleActionIn};cc.EaseCircleActionOut=cc.ActionEase.extend({_updateTime:function(a){return a-=1,Math.sqrt(1-a*a)},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseCircleActionOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseCircleActionOut(this._inner.reverse())}});cc.EaseCircleActionOut.create=function(a){return new cc.EaseCircleActionOut(a)};
cc._easeCircleActionOut={easing:cc.EaseCircleActionOut.prototype._updateTime,reverse:function(){return cc._easeCircleActionOut}};cc.easeCircleActionOut=function(){return cc._easeCircleActionOut};
cc.EaseCircleActionInOut=cc.ActionEase.extend({_updateTime:function(a){return a*=2,1>a?-0.5*(Math.sqrt(1-a*a)-1):(a-=2,0.5*(Math.sqrt(1-a*a)+1))},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseCircleActionInOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseCircleActionInOut(this._inner.reverse())}});cc.EaseCircleActionInOut.create=function(a){return new cc.EaseCircleActionInOut(a)};
cc._easeCircleActionInOut={easing:cc.EaseCircleActionInOut.prototype._updateTime,reverse:function(){return cc._easeCircleActionInOut}};cc.easeCircleActionInOut=function(){return cc._easeCircleActionInOut};cc.EaseCubicActionIn=cc.ActionEase.extend({_updateTime:function(a){return a*a*a},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseCubicActionIn;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseCubicActionIn(this._inner.reverse())}});
cc.EaseCubicActionIn.create=function(a){return new cc.EaseCubicActionIn(a)};cc._easeCubicActionIn={easing:cc.EaseCubicActionIn.prototype._updateTime,reverse:function(){return cc._easeCubicActionIn}};cc.easeCubicActionIn=function(){return cc._easeCubicActionIn};
cc.EaseCubicActionOut=cc.ActionEase.extend({_updateTime:function(a){return a-=1,a*a*a+1},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseCubicActionOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseCubicActionOut(this._inner.reverse())}});cc.EaseCubicActionOut.create=function(a){return new cc.EaseCubicActionOut(a)};cc._easeCubicActionOut={easing:cc.EaseCubicActionOut.prototype._updateTime,reverse:function(){return cc._easeCubicActionOut}};
cc.easeCubicActionOut=function(){return cc._easeCubicActionOut};cc.EaseCubicActionInOut=cc.ActionEase.extend({_updateTime:function(a){return a*=2,1>a?0.5*a*a*a:(a-=2,0.5*(a*a*a+2))},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseCubicActionInOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseCubicActionInOut(this._inner.reverse())}});cc.EaseCubicActionInOut.create=function(a){return new cc.EaseCubicActionInOut(a)};
cc._easeCubicActionInOut={easing:cc.EaseCubicActionInOut.prototype._updateTime,reverse:function(){return cc._easeCubicActionInOut}};cc.easeCubicActionInOut=function(){return cc._easeCubicActionInOut};cc.cardinalSplineAt=function(a,b,c,d,e,f){var g=f*f,h=g*f,k=(1-e)/2;e=k*(-h+2*g-f);var m=k*(-h+g)+(2*h-3*g+1);f=k*(h-2*g+f)+(-2*h+3*g);g=k*(h-g);return cc.p(a.x*e+b.x*m+c.x*f+d.x*g,a.y*e+b.y*m+c.y*f+d.y*g)};
cc.reverseControlPoints=function(a){for(var b=[],c=a.length-1;0<=c;c--)b.push(cc.p(a[c].x,a[c].y));return b};cc.cloneControlPoints=function(a){for(var b=[],c=0;c<a.length;c++)b.push(cc.p(a[c].x,a[c].y));return b};cc.copyControlPoints=cc.cloneControlPoints;cc.getControlPointAt=function(a,b){var c=Math.min(a.length-1,Math.max(b,0));return a[c]};cc.reverseControlPointsInline=function(a){for(var b=a.length,c=0|b/2,d=0;c>d;++d){var e=a[d];a[d]=a[b-d-1];a[b-d-1]=e}};
cc.CardinalSplineTo=cc.ActionInterval.extend({_points:null,_deltaT:0,_tension:0,_previousPosition:null,_accumulatedDiff:null,ctor:function(a,b,c){cc.ActionInterval.prototype.ctor.call(this);this._points=[];void 0!==c&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){if(!b||0===b.length)throw"Invalid configuration. It must at least have one control point";return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this.setPoints(b),this._tension=c,!0):!1},clone:function(){var a=
new cc.CardinalSplineTo;return a.initWithDuration(this._duration,cc.copyControlPoints(this._points),this._tension),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._deltaT=1/(this._points.length-1);this._previousPosition=cc.p(this.target.getPositionX(),this.target.getPositionY());this._accumulatedDiff=cc.p(0,0)},update:function(a){a=this._computeEaseTime(a);var b,c=this._points;if(1===a)b=c.length-1,a=1;else{var d=this._deltaT;b=0|a/d;a=(a-d*b)/d}b=cc.cardinalSplineAt(cc.getControlPointAt(c,
b-1),cc.getControlPointAt(c,b-0),cc.getControlPointAt(c,b+1),cc.getControlPointAt(c,b+2),this._tension,a);if(cc.ENABLE_STACKABLE_ACTIONS){var e,f;if(e=this.target.getPositionX()-this._previousPosition.x,f=this.target.getPositionY()-this._previousPosition.y,0!==e||0!==f)c=this._accumulatedDiff,e=c.x+e,f=c.y+f,c.x=e,c.y=f,b.x+=e,b.y+=f}this.updatePosition(b)},reverse:function(){var a=cc.reverseControlPoints(this._points);return cc.cardinalSplineTo(this._duration,a,this._tension)},updatePosition:function(a){this.target.setPosition(a);
this._previousPosition=a},getPoints:function(){return this._points},setPoints:function(a){this._points=a}});cc.cardinalSplineTo=function(a,b,c){return new cc.CardinalSplineTo(a,b,c)};cc.CardinalSplineTo.create=cc.cardinalSplineTo;
cc.CardinalSplineBy=cc.CardinalSplineTo.extend({_startPosition:null,ctor:function(a,b,c){cc.CardinalSplineTo.prototype.ctor.call(this);this._startPosition=cc.p(0,0);void 0!==c&&this.initWithDuration(a,b,c)},startWithTarget:function(a){cc.CardinalSplineTo.prototype.startWithTarget.call(this,a);this._startPosition.x=a.getPositionX();this._startPosition.y=a.getPositionY()},reverse:function(){for(var a,b=this._points.slice(),c=b[0],d=1;d<b.length;++d)a=b[d],b[d]=cc.pSub(a,c),c=a;b=cc.reverseControlPoints(b);
c=b[b.length-1];b.pop();c.x=-c.x;c.y=-c.y;b.unshift(c);for(d=1;d<b.length;++d)a=b[d],a.x=-a.x,a.y=-a.y,a.x+=c.x,a.y+=c.y,c=b[d]=a;return cc.cardinalSplineBy(this._duration,b,this._tension)},updatePosition:function(a){var b=this._startPosition,c=a.x+b.x;a=a.y+b.y;this._previousPosition.x=c;this._previousPosition.y=a;this.target.setPosition(c,a)},clone:function(){var a=new cc.CardinalSplineBy;return a.initWithDuration(this._duration,cc.copyControlPoints(this._points),this._tension),a}});
cc.cardinalSplineBy=function(a,b,c){return new cc.CardinalSplineBy(a,b,c)};cc.CardinalSplineBy.create=cc.cardinalSplineBy;cc.CatmullRomTo=cc.CardinalSplineTo.extend({ctor:function(a,b){b&&this.initWithDuration(a,b)},initWithDuration:function(a,b){return cc.CardinalSplineTo.prototype.initWithDuration.call(this,a,b,0.5)},clone:function(){var a=new cc.CatmullRomTo;return a.initWithDuration(this._duration,cc.copyControlPoints(this._points)),a}});
cc.catmullRomTo=function(a,b){return new cc.CatmullRomTo(a,b)};cc.CatmullRomTo.create=cc.catmullRomTo;cc.CatmullRomBy=cc.CardinalSplineBy.extend({ctor:function(a,b){cc.CardinalSplineBy.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},initWithDuration:function(a,b){return cc.CardinalSplineTo.prototype.initWithDuration.call(this,a,b,0.5)},clone:function(){var a=new cc.CatmullRomBy;return a.initWithDuration(this._duration,cc.copyControlPoints(this._points)),a}});
cc.catmullRomBy=function(a,b){return new cc.CatmullRomBy(a,b)};cc.CatmullRomBy.create=cc.catmullRomBy;cc.ActionTweenDelegate=cc.Class.extend({updateTweenAction:function(a,b){}});
cc.ActionTween=cc.ActionInterval.extend({key:"",from:0,to:0,delta:0,ctor:function(a,b,c,d){cc.ActionInterval.prototype.ctor.call(this);this.key="";void 0!==d&&this.initWithDuration(a,b,c,d)},initWithDuration:function(a,b,c,d){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this.key=b,this.to=d,this.from=c,!0):!1},startWithTarget:function(a){if(!a||!a.updateTweenAction)throw"cc.ActionTween.startWithTarget(): target must be non-null, and target must implement updateTweenAction function";
cc.ActionInterval.prototype.startWithTarget.call(this,a);this.delta=this.to-this.from},update:function(a){this.target.updateTweenAction(this.to-this.delta*(1-a),this.key)},reverse:function(){return new cc.ActionTween(this.duration,this.key,this.to,this.from)},clone:function(){var a=new cc.ActionTween;return a.initWithDuration(this._duration,this.key,this.from,this.to),a}});cc.actionTween=function(a,b,c,d){return new cc.ActionTween(a,b,c,d)};cc.ActionTween.create=cc.actionTween;
!function(){var a=cc.sys,b={common:{multichannel:!0,webAudio:cc.sys._supportWebAudio,auto:!0}};b[a.BROWSER_TYPE_IE]={multichannel:!0,webAudio:cc.sys._supportWebAudio,auto:!0,emptied:!0};b[a.BROWSER_TYPE_ANDROID]={multichannel:!1,webAudio:!1,auto:!1};b[a.BROWSER_TYPE_CHROME]={multichannel:!0,webAudio:!0,auto:!1};b[a.BROWSER_TYPE_FIREFOX]={multichannel:!0,webAudio:!0,auto:!0,delay:!0};b[a.BROWSER_TYPE_UC]={multichannel:!0,webAudio:!1,auto:!1};b[a.BROWSER_TYPE_QQ]={multichannel:!1,webAudio:!1,auto:!0};
b[a.BROWSER_TYPE_OUPENG]={multichannel:!1,webAudio:!1,auto:!1,replay:!0,emptied:!0};b[a.BROWSER_TYPE_WECHAT]={multichannel:!1,webAudio:!1,auto:!1,replay:!0,emptied:!0};b[a.BROWSER_TYPE_360]={multichannel:!1,webAudio:!1,auto:!0};b[a.BROWSER_TYPE_MIUI]={multichannel:!1,webAudio:!1,auto:!0};b[a.BROWSER_TYPE_LIEBAO]={multichannel:!1,webAudio:!1,auto:!1,replay:!0,emptied:!0};b[a.BROWSER_TYPE_SOUGOU]={multichannel:!1,webAudio:!1,auto:!1,replay:!0,emptied:!0};b[a.BROWSER_TYPE_BAIDU]={multichannel:!1,webAudio:!1,
auto:!1,replay:!0,emptied:!0};b[a.BROWSER_TYPE_BAIDU_APP]={multichannel:!1,webAudio:!1,auto:!1,replay:!0,emptied:!0};b[a.BROWSER_TYPE_SAFARI]={multichannel:!0,webAudio:!0,auto:!1,webAudioCallback:function(a){document.createElement("audio").src=a}};var c,d;try{var e=navigator.userAgent.toLowerCase();switch(a.browserType){case a.BROWSER_TYPE_IE:d=e.match(/(msie |rv:)([\d.]+)/);break;case a.BROWSER_TYPE_FIREFOX:d=e.match(/(firefox\/|rv:)([\d.]+)/);break;case a.BROWSER_TYPE_CHROME:d=e.match(/chrome\/([\d.]+)/);
break;case a.BROWSER_TYPE_BAIDU:d=e.match(/baidubrowser\/([\d.]+)/);break;case a.BROWSER_TYPE_UC:d=e.match(/ucbrowser\/([\d.]+)/);break;case a.BROWSER_TYPE_QQ:d=e.match(/qqbrowser\/([\d.]+)/);break;case a.BROWSER_TYPE_OUPENG:d=e.match(/oupeng\/([\d.]+)/);break;case a.BROWSER_TYPE_WECHAT:d=e.match(/micromessenger\/([\d.]+)/);break;case a.BROWSER_TYPE_SAFARI:d=e.match(/safari\/([\d.]+)/);break;case a.BROWSER_TYPE_MIUI:d=e.match(/miuibrowser\/([\d.]+)/)}c=d?d[1]:""}catch(f){console.log(f)}if(c)switch(a.browserType){case a.BROWSER_TYPE_CHROME:30>
parseInt(c)&&(b[a.BROWSER_TYPE_CHROME]={multichannel:!1,webAudio:!0,auto:!1});break;case a.BROWSER_TYPE_MIUI:c=c.match(/\d+/g),(2>c[0]||2===c[0]&&0===c[1]&&1>=c[2])&&(b[a.BROWSER_TYPE_MIUI].auto=!1)}if(cc.sys.isMobile)cc.sys.os!==cc.sys.OS_IOS?cc.__audioSupport=b[a.browserType]||b.common:cc.__audioSupport=b[a.BROWSER_TYPE_SAFARI];else switch(a.browserType){case a.BROWSER_TYPE_IE:cc.__audioSupport=b[a.BROWSER_TYPE_IE];break;case a.BROWSER_TYPE_FIREFOX:cc.__audioSupport=b[a.BROWSER_TYPE_FIREFOX];break;
default:cc.__audioSupport=b.common}}();
cc.Audio=cc.Class.extend({volume:1,loop:!1,src:null,_touch:!1,_playing:!1,_AUDIO_TYPE:"AUDIO",_pause:!1,_buffer:null,_currentSource:null,_startTime:null,_currentTime:null,_context:null,_volume:null,_ignoreEnded:!1,_element:null,ctor:function(a,b,c){a&&(this._context=a);b&&(this._volume=b);a&&b&&(this._AUDIO_TYPE="WEBAUDIO");this.src=c},_setBufferCallback:null,setBuffer:function(a){if(a){var b=this._playing;this._AUDIO_TYPE="WEBAUDIO";this._buffer&&this._buffer!==a&&this.getPlaying()&&this.stop();
this._buffer=a;b&&this.play();this._volume.gain.value=this.volume;this._setBufferCallback&&this._setBufferCallback(a)}},_setElementCallback:null,setElement:function(a){if(a){var b=this._playing;this._AUDIO_TYPE="AUDIO";this._element&&this._element!==a&&this.getPlaying()&&this.stop();this._element=a;b&&this.play();a.volume=this.volume;a.loop=this.loop;this._setElementCallback&&this._setElementCallback(a)}},play:function(a,b){this._playing=!0;this.loop=void 0===b?this.loop:b;"AUDIO"===this._AUDIO_TYPE?
this._playOfAudio(a):this._playOfWebAudio(a)},getPlaying:function(){if(!this._playing)return this._playing;if("AUDIO"===this._AUDIO_TYPE){var a=this._element;return!a||this._pause?(this._playing=!1,!1):a.ended?(this._playing=!1,!1):!0}return(a=this._currentSource)?null==a.playbackState?this._playing:this._currentTime+this._context.currentTime-this._startTime<this._currentSource.buffer.duration:!0},_playOfWebAudio:function(a){var b=this._currentSource;if(this._buffer){if(!this._pause&&b){if(!(0===
this._context.currentTime||this._currentTime+this._context.currentTime-this._startTime>this._currentSource.buffer.duration))return;this._stopOfWebAudio()}b=this._context.createBufferSource();if(b.buffer=this._buffer,b.connect(this._volume),b.loop=this.loop,this._startTime=this._context.currentTime,this._currentTime=a||0,b.start)b.start(0,a||0);else if(b.noteGrainOn){var c=b.buffer.duration;this.loop?b.noteGrainOn(0,a,c):b.noteGrainOn(0,a,c-a)}else b.noteOn(0);this._currentSource=b;var d=this;b.onended=
function(){d._ignoreEnded?d._ignoreEnded=!1:d._playing=!1}}},_playOfAudio:function(){var a=this._element;a&&(a.loop=this.loop,a.play())},stop:function(){this._playing=!1;"AUDIO"===this._AUDIO_TYPE?this._stopOfAudio():this._stopOfWebAudio()},_stopOfWebAudio:function(){var a=this._currentSource;this._ignoreEnded=!0;a&&(a.stop(0),this._currentSource=null)},_stopOfAudio:function(){var a=this._element;a&&(a.pause(),a.duration&&a.duration!==1/0&&(a.currentTime=0))},pause:function(){!1!==this.getPlaying()&&
(this._playing=!1,this._pause=!0,"AUDIO"===this._AUDIO_TYPE?this._pauseOfAudio():this._pauseOfWebAudio())},_pauseOfWebAudio:function(){this._currentTime+=this._context.currentTime-this._startTime;var a=this._currentSource;a&&a.stop(0)},_pauseOfAudio:function(){var a=this._element;a&&a.pause()},resume:function(){this._pause&&("AUDIO"===this._AUDIO_TYPE?this._resumeOfAudio():this._resumeOfWebAudio(),this._pause=!1,this._playing=!0)},_resumeOfWebAudio:function(){var a=this._currentSource;a&&(this._startTime=
this._context.currentTime,this._playOfWebAudio(this._currentTime%a.buffer.duration))},_resumeOfAudio:function(){var a=this._element;a&&a.play()},setVolume:function(a){1<a&&(a=1);0>a&&(a=0);this.volume=a;"AUDIO"===this._AUDIO_TYPE?this._element&&(this._element.volume=a):this._volume&&(this._volume.gain.value=a)},getVolume:function(){return this.volume},cloneNode:function(){var a,b;if("AUDIO"===this._AUDIO_TYPE){a=new cc.Audio;var c=document.createElement("audio");c.src=this.src;a.setElement(c)}else c=
this._context.createGain(),c.gain.value=1,c.connect(this._context.destination),a=new cc.Audio(this._context,c,this.src),this._buffer?a.setBuffer(this._buffer):(b=this,this._setBufferCallback=function(c){a.setBuffer(c);b._setBufferCallback=null});return a._AUDIO_TYPE=this._AUDIO_TYPE,a}});
(function(a){var b=a.webAudio,c=a.multichannel,d=a.auto,e=[];!function(){var a=document.createElement("audio");if(a.canPlayType){var b=a.canPlayType('audio/ogg; codecs\x3d"vorbis"');b&&""!==b&&e.push(".ogg");(b=a.canPlayType("audio/mpeg"))&&""!==b&&e.push(".mp3");(b=a.canPlayType('audio/wav; codecs\x3d"1"'))&&""!==b&&e.push(".wav");(b=a.canPlayType("audio/mp4"))&&""!==b&&e.push(".mp4");(a=a.canPlayType("audio/x-m4a"))&&""!==a&&e.push(".m4a")}}();try{if(b){var f=new (window.AudioContext||window.webkitAudioContext||
window.mozAudioContext);a.delay&&setTimeout(function(){f=new (window.AudioContext||window.webkitAudioContext||window.mozAudioContext)},0)}}catch(g){b=!1,cc.log("browser don't support webAudio")}var h={cache:{},load:function(a,c,d,g){if(0===e.length)return g("can not support audio!");var k=cc.path.extname(a),v=[k];for(d=0;d<e.length;d++)k!==e[d]&&v.push(e[d]);var u;if(h.cache[c])return g(null,h.cache[c]);if(b)try{var t=f.createGain();t.gain.value=1;t.connect(f.destination);u=new cc.Audio(f,t,a)}catch(x){b=
!1,cc.log("browser don't support webAudio"),u=new cc.Audio(null,null,a)}else u=new cc.Audio(null,null,a);this.loadAudioFromExtList(a,v,u,g);h.cache[c]=u},loadAudioFromExtList:function(c,d,g,k){if(0===d.length){var s="can not found the resource of audio! Last match url is : ";return s+=c.replace(/\.(.*)?$/,"("),e.forEach(function(a){s+=a+"|"}),s=s.replace(/\|$/,")"),k(s)}if(c=cc.path.changeExtname(c,d.splice(0,1)),b){a.webAudioCallback&&a.webAudioCallback(c);var v=new XMLHttpRequest;v.open("GET",c,
!0);v.responseType="arraybuffer";v.onload=function(){f.decodeAudioData(v.response,function(a){g.setBuffer(a);k(null,g)},function(){h.loadAudioFromExtList(c,d,g,k)})};v.send()}else{var u=document.createElement("audio"),t=!1,x=!1,A=setTimeout(function(){0===u.readyState?w():(x=!0,u.pause(),document.body.removeChild(u),k("audio load timeout : "+c,g))},1E4),F=function(){if(!t){u.pause();try{u.currentTime=0,u.volume=1}catch(a){}document.body.removeChild(u);g.setElement(u);u.removeEventListener("canplaythrough",
F,!1);u.removeEventListener("error",z,!1);u.removeEventListener("emptied",w,!1);!x&&k(null,g);t=!0;clearTimeout(A)}},z=function(){t&&(u.pause(),document.body.removeChild(u),u.removeEventListener("canplaythrough",F,!1),u.removeEventListener("error",z,!1),u.removeEventListener("emptied",w,!1),!x&&h.loadAudioFromExtList(c,d,g,k),t=!0,clearTimeout(A))},w=function(){x=!0;F();k(null,g)};cc._addEventListener(u,"canplaythrough",F,!1);cc._addEventListener(u,"error",z,!1);a.emptied&&cc._addEventListener(u,
"emptied",w,!1);u.src=c;document.body.appendChild(u);u.volume=0;u.play()}}};if(cc.loader.register(["mp3","ogg","wav","mp4","m4a"],h),cc.audioEngine={_currMusic:null,_musicVolume:1,willPlayMusic:function(){return!1},playMusic:function(a,b){var c=this._currMusic;c&&c.src!==a&&c.getPlaying()&&c.stop();(c=h.cache[a])||(cc.loader.load(a),c=h.cache[a]);c.play(0,b);c.setVolume(this._musicVolume);this._currMusic=c},stopMusic:function(a){var b=this._currMusic;b&&(b.stop(),a&&cc.loader.release(b.src))},pauseMusic:function(){var a=
this._currMusic;a&&a.pause()},resumeMusic:function(){var a=this._currMusic;a&&a.resume()},rewindMusic:function(){var a=this._currMusic;a&&(a.stop(),a.play())},getMusicVolume:function(){return this._musicVolume},setMusicVolume:function(a){a-=0;isNaN(a)&&(a=1);1<a&&(a=1);0>a&&(a=0);this._musicVolume=a;var b=this._currMusic;b&&b.setVolume(a)},isMusicPlaying:function(){var a=this._currMusic;return a?a.getPlaying():!1},_audioPool:{},_maxAudioInstance:5,_effectVolume:1,playEffect:function(a,d){if(!c)return null;
var e=this._audioPool[a];e||(e=this._audioPool[a]=[]);var f;for(f=0;f<e.length&&e[f].getPlaying();f++);if(e[f])g=e[f],g.setVolume(this._effectVolume),g.play(0,d);else if(!b&&f>this._maxAudioInstance)cc.log("Error: %s greater than %d",a,this._maxAudioInstance);else{var g=h.cache[a];g||(cc.loader.load(a),g=h.cache[a]);g=g.cloneNode();g.setVolume(this._effectVolume);g.loop=d||!1;g.play();e.push(g)}return g},setEffectsVolume:function(a){a-=0;isNaN(a)&&(a=1);1<a&&(a=1);0>a&&(a=0);this._effectVolume=a;
var b=this._audioPool,c;for(c in b){var d=b[c];if(Array.isArray(d))for(var e=0;e<d.length;e++)d[e].setVolume(a)}},getEffectsVolume:function(){return this._effectVolume},pauseEffect:function(a){a&&a.pause()},pauseAllEffects:function(){var a=this._audioPool,b;for(b in a)for(var c=a[b],d=0;d<a[b].length;d++)c[d].getPlaying()&&c[d].pause()},resumeEffect:function(a){a&&a.resume()},resumeAllEffects:function(){var a=this._audioPool,b;for(b in a)for(var c=a[b],d=0;d<a[b].length;d++)c[d].resume()},stopEffect:function(a){a&&
a.stop()},stopAllEffects:function(){var a=this._audioPool,b;for(b in a)for(var c=a[b],d=0;d<a[b].length;d++)c[d].stop()},unloadEffect:function(a){if(a){cc.loader.release(a);var b=this._audioPool[a];b&&(b.length=0);delete this._audioPool[a];delete h.cache[a]}},end:function(){this.stopMusic();this.stopAllEffects()},_pauseCache:[],_pausePlaying:function(){var a=this._currMusic;a&&a.getPlaying()&&(a.pause(),this._pauseCache.push(a));var a=this._audioPool,b;for(b in a)for(var c=a[b],d=0;d<a[b].length;d++)c[d].getPlaying()&&
(c[d].pause(),this._pauseCache.push(c[d]))},_resumePlaying:function(){for(var a=this._pauseCache,b=0;b<a.length;b++)a[b].resume();a.length=0}},!d){var k=function(){var b=cc.audioEngine._currMusic;b&&!1===b._touch&&b._playing&&b.getPlaying()&&(b._touch=!0,b.play(0,b.loop),!a.replay&&cc._canvas.removeEventListener("touchstart",k))};setTimeout(function(){cc._canvas&&cc._canvas.addEventListener("touchstart",k,!1)},150)}cc.eventManager.addCustomListener(cc.game.EVENT_HIDE,function(){cc.audioEngine._pausePlaying()});
cc.eventManager.addCustomListener(cc.game.EVENT_SHOW,function(){cc.audioEngine._resumePlaying()})})(cc.__audioSupport);cc._globalFontSize=cc.ITEM_SIZE;cc._globalFontName="Arial";cc._globalFontNameRelease=!1;
cc.MenuItem=cc.Node.extend({_enabled:!1,_target:null,_callback:null,_isSelected:!1,_className:"MenuItem",ctor:function(a,b){var c=cc.Node.prototype;c.ctor.call(this);this._callback=this._target=null;this._enabled=this._isSelected=!1;c.setAnchorPoint.call(this,0.5,0.5);this._target=b||null;(this._callback=a||null)&&(this._enabled=!0)},isSelected:function(){return this._isSelected},setOpacityModifyRGB:function(a){},isOpacityModifyRGB:function(){return!1},setTarget:function(a,b){this._target=b;this._callback=
a},isEnabled:function(){return this._enabled},setEnabled:function(a){this._enabled=a},initWithCallback:function(a,b){return this.anchorX=0.5,this.anchorY=0.5,this._target=b,this._callback=a,this._enabled=!0,this._isSelected=!1,!0},rect:function(){var a=this._position,b=this._contentSize,c=this._anchorPoint;return cc.rect(a.x-b.width*c.x,a.y-b.height*c.y,b.width,b.height)},selected:function(){this._isSelected=!0},unselected:function(){this._isSelected=!1},setCallback:function(a,b){this._target=b;this._callback=
a},activate:function(){if(this._enabled){var a=this._target,b=this._callback;b&&(a&&cc.isString(b)?a[b](this):a&&cc.isFunction(b)?b.call(a,this):b(this))}}});_p=cc.MenuItem.prototype;_p.enabled;cc.defineGetterSetter(_p,"enabled",_p.isEnabled,_p.setEnabled);cc.MenuItem.create=function(a,b){return new cc.MenuItem(a,b)};
cc.MenuItemLabel=cc.MenuItem.extend({_disabledColor:null,_label:null,_originalScale:0,_colorBackup:null,ctor:function(a,b,c){cc.MenuItem.prototype.ctor.call(this,b,c);this._colorBackup=this._label=this._disabledColor=null;a&&(this._originalScale=1,this._colorBackup=cc.color.WHITE,this._disabledColor=cc.color(126,126,126),this.setLabel(a),this.cascadeColor=!0,this.cascadeOpacity=!0)},getDisabledColor:function(){return this._disabledColor},setDisabledColor:function(a){this._disabledColor=a},getLabel:function(){return this._label},
setLabel:function(a){a&&(this.addChild(a),a.anchorX=0,a.anchorY=0,this.width=a.width,this.height=a.height);this._label&&this.removeChild(this._label,!0);this._label=a},setEnabled:function(a){if(this._enabled!==a){var b=this._label;a?b.color=this._colorBackup:(this._colorBackup=b.color,b.color=this._disabledColor)}cc.MenuItem.prototype.setEnabled.call(this,a)},setOpacity:function(a){this._label.opacity=a},getOpacity:function(){return this._label.opacity},setColor:function(a){this._label.color=a},getColor:function(){return this._label.color},
initWithLabel:function(a,b,c){return this.initWithCallback(b,c),this._originalScale=1,this._colorBackup=cc.color.WHITE,this._disabledColor=cc.color(126,126,126),this.setLabel(a),this.cascadeColor=!0,this.cascadeOpacity=!0,!0},setString:function(a){this._label.string=a;this.width=this._label.width;this.height=this._label.height},getString:function(){return this._label.string},activate:function(){this._enabled&&(this.stopAllActions(),this.scale=this._originalScale,cc.MenuItem.prototype.activate.call(this))},
selected:function(){if(this._enabled){cc.MenuItem.prototype.selected.call(this);var a=this.getActionByTag(cc.ZOOM_ACTION_TAG);a?this.stopAction(a):this._originalScale=this.scale;a=cc.scaleTo(0.1,1.2*this._originalScale);a.setTag(cc.ZOOM_ACTION_TAG);this.runAction(a)}},unselected:function(){if(this._enabled){cc.MenuItem.prototype.unselected.call(this);this.stopActionByTag(cc.ZOOM_ACTION_TAG);var a=cc.scaleTo(0.1,this._originalScale);a.setTag(cc.ZOOM_ACTION_TAG);this.runAction(a)}}});_p=cc.MenuItemLabel.prototype;
_p.string;cc.defineGetterSetter(_p,"string",_p.getString,_p.setString);_p.disabledColor;cc.defineGetterSetter(_p,"disabledColor",_p.getDisabledColor,_p.setDisabledColor);_p.label;cc.defineGetterSetter(_p,"label",_p.getLabel,_p.setLabel);cc.MenuItemLabel.create=function(a,b,c){return new cc.MenuItemLabel(a,b,c)};
cc.MenuItemAtlasFont=cc.MenuItemLabel.extend({ctor:function(a,b,c,d,e,f,g){var h;a&&0<a.length&&(h=new cc.LabelAtlas(a,b,c,d,e));cc.MenuItemLabel.prototype.ctor.call(this,h,f,g)},initWithString:function(a,b,c,d,e,f,g){if(!a||0===a.length)throw"cc.MenuItemAtlasFont.initWithString(): value should be non-null and its length should be greater than 0";var h=new cc.LabelAtlas;return h.initWithString(a,b,c,d,e),this.initWithLabel(h,f,g),!0}});
cc.MenuItemAtlasFont.create=function(a,b,c,d,e,f,g){return new cc.MenuItemAtlasFont(a,b,c,d,e,f,g)};
cc.MenuItemFont=cc.MenuItemLabel.extend({_fontSize:null,_fontName:null,ctor:function(a,b,c){var d;a&&0<a.length?(this._fontName=cc._globalFontName,this._fontSize=cc._globalFontSize,d=new cc.LabelTTF(a,this._fontName,this._fontSize)):(this._fontSize=0,this._fontName="");cc.MenuItemLabel.prototype.ctor.call(this,d,b,c)},initWithString:function(a,b,c){if(!a||0===a.length)throw"Value should be non-null and its length should be greater than 0";this._fontName=cc._globalFontName;this._fontSize=cc._globalFontSize;
a=new cc.LabelTTF(a,this._fontName,this._fontSize);return this.initWithLabel(a,b,c),!0},setFontSize:function(a){this._fontSize=a;this._recreateLabel()},getFontSize:function(){return this._fontSize},setFontName:function(a){this._fontName=a;this._recreateLabel()},getFontName:function(){return this._fontName},_recreateLabel:function(){var a=new cc.LabelTTF(this._label.string,this._fontName,this._fontSize);this.setLabel(a)}});cc.MenuItemFont.setFontSize=function(a){cc._globalFontSize=a};
cc.MenuItemFont.fontSize=function(){return cc._globalFontSize};cc.MenuItemFont.setFontName=function(a){cc._globalFontNameRelease&&(cc._globalFontName="");cc._globalFontName=a;cc._globalFontNameRelease=!0};_p=cc.MenuItemFont.prototype;_p.fontSize;cc.defineGetterSetter(_p,"fontSize",_p.getFontSize,_p.setFontSize);_p.fontName;cc.defineGetterSetter(_p,"fontName",_p.getFontName,_p.setFontName);cc.MenuItemFont.fontName=function(){return cc._globalFontName};
cc.MenuItemFont.create=function(a,b,c){return new cc.MenuItemFont(a,b,c)};
cc.MenuItemSprite=cc.MenuItem.extend({_normalImage:null,_selectedImage:null,_disabledImage:null,ctor:function(a,b,c,d,e){if(cc.MenuItem.prototype.ctor.call(this),this._normalImage=null,this._selectedImage=null,this._disabledImage=null,void 0!==b){var f,g,h;void 0!==e?(f=c,h=d,g=e):void 0!==d&&cc.isFunction(d)?(f=c,h=d):void 0!==d&&cc.isFunction(c)?(g=d,h=c,f=null):void 0===c&&(f=null);this.initWithNormalSprite(a,b,f,h,g)}},getNormalImage:function(){return this._normalImage},setNormalImage:function(a){this._normalImage!==
a&&(a&&(this.addChild(a,0,cc.NORMAL_TAG),a.anchorX=0,a.anchorY=0),this._normalImage&&this.removeChild(this._normalImage,!0),this._normalImage=a,this.width=this._normalImage.width,this.height=this._normalImage.height,this._updateImagesVisibility(),a.textureLoaded&&!a.textureLoaded()&&a.addEventListener("load",function(a){this.width=a.width;this.height=a.height},this))},getSelectedImage:function(){return this._selectedImage},setSelectedImage:function(a){this._selectedImage!==a&&(a&&(this.addChild(a,
0,cc.SELECTED_TAG),a.anchorX=0,a.anchorY=0),this._selectedImage&&this.removeChild(this._selectedImage,!0),this._selectedImage=a,this._updateImagesVisibility())},getDisabledImage:function(){return this._disabledImage},setDisabledImage:function(a){this._disabledImage!==a&&(a&&(this.addChild(a,0,cc.DISABLE_TAG),a.anchorX=0,a.anchorY=0),this._disabledImage&&this.removeChild(this._disabledImage,!0),this._disabledImage=a,this._updateImagesVisibility())},initWithNormalSprite:function(a,b,c,d,e){this.initWithCallback(d,
e);this.setNormalImage(a);this.setSelectedImage(b);this.setDisabledImage(c);a=this._normalImage;return a&&(this.width=a.width,this.height=a.height,a.textureLoaded&&!a.textureLoaded()&&a.addEventListener("load",function(a){this.width=a.width;this.height=a.height;this.cascadeOpacity=this.cascadeColor=!0},this)),this.cascadeColor=!0,this.cascadeOpacity=!0,!0},setColor:function(a){this._normalImage.color=a;this._selectedImage&&(this._selectedImage.color=a);this._disabledImage&&(this._disabledImage.color=
a)},getColor:function(){return this._normalImage.color},setOpacity:function(a){this._normalImage.opacity=a;this._selectedImage&&(this._selectedImage.opacity=a);this._disabledImage&&(this._disabledImage.opacity=a)},getOpacity:function(){return this._normalImage.opacity},selected:function(){cc.MenuItem.prototype.selected.call(this);this._normalImage&&(this._disabledImage&&(this._disabledImage.visible=!1),this._selectedImage?(this._normalImage.visible=!1,this._selectedImage.visible=!0):this._normalImage.visible=
!0)},unselected:function(){cc.MenuItem.prototype.unselected.call(this);this._normalImage&&(this._normalImage.visible=!0,this._selectedImage&&(this._selectedImage.visible=!1),this._disabledImage&&(this._disabledImage.visible=!1))},setEnabled:function(a){this._enabled!==a&&(cc.MenuItem.prototype.setEnabled.call(this,a),this._updateImagesVisibility())},_updateImagesVisibility:function(){var a=this._normalImage,b=this._selectedImage,c=this._disabledImage;this._enabled?(a&&(a.visible=!0),b&&(b.visible=
!1),c&&(c.visible=!1)):c?(a&&(a.visible=!1),b&&(b.visible=!1),c&&(c.visible=!0)):(a&&(a.visible=!0),b&&(b.visible=!1))}});_p=cc.MenuItemSprite.prototype;_p.normalImage;cc.defineGetterSetter(_p,"normalImage",_p.getNormalImage,_p.setNormalImage);_p.selectedImage;cc.defineGetterSetter(_p,"selectedImage",_p.getSelectedImage,_p.setSelectedImage);_p.disabledImage;cc.defineGetterSetter(_p,"disabledImage",_p.getDisabledImage,_p.setDisabledImage);
cc.MenuItemSprite.create=function(a,b,c,d,e){return new cc.MenuItemSprite(a,b,c,d,e||void 0)};
cc.MenuItemImage=cc.MenuItemSprite.extend({ctor:function(a,b,c,d,e){var f=null,g=null,h=null,k=null,m=null;void 0===a?cc.MenuItemSprite.prototype.ctor.call(this):(f=new cc.Sprite(a),b&&(g=new cc.Sprite(b)),void 0===d?k=c:void 0===e?(k=c,m=d):e&&(h=new cc.Sprite(c),k=d,m=e),cc.MenuItemSprite.prototype.ctor.call(this,f,g,h,k,m))},setNormalSpriteFrame:function(a){this.setNormalImage(new cc.Sprite(a))},setSelectedSpriteFrame:function(a){this.setSelectedImage(new cc.Sprite(a))},setDisabledSpriteFrame:function(a){this.setDisabledImage(new cc.Sprite(a))},
initWithNormalImage:function(a,b,c,d,e){var f=null,g=null,h=null;return a&&(f=new cc.Sprite(a)),b&&(g=new cc.Sprite(b)),c&&(h=new cc.Sprite(c)),this.initWithNormalSprite(f,g,h,d,e)}});cc.MenuItemImage.create=function(a,b,c,d,e){return new cc.MenuItemImage(a,b,c,d,e)};
cc.MenuItemToggle=cc.MenuItem.extend({subItems:null,_selectedIndex:0,_opacity:null,_color:null,ctor:function(){cc.MenuItem.prototype.ctor.call(this);this._selectedIndex=0;this.subItems=[];this._opacity=0;this._color=cc.color.WHITE;0<arguments.length&&this.initWithItems(Array.prototype.slice.apply(arguments))},getOpacity:function(){return this._opacity},setOpacity:function(a){if(this._opacity=a,this.subItems&&0<this.subItems.length)for(var b=0;b<this.subItems.length;b++)this.subItems[b].opacity=a;
this._color.a=a},getColor:function(){var a=this._color;return cc.color(a.r,a.g,a.b,a.a)},setColor:function(a){var b=this._color;if(b.r=a.r,b.g=a.g,b.b=a.b,this.subItems&&0<this.subItems.length)for(b=0;b<this.subItems.length;b++)this.subItems[b].setColor(a);void 0===a.a||a.a_undefined||this.setOpacity(a.a)},getSelectedIndex:function(){return this._selectedIndex},setSelectedIndex:function(a){if(a!==this._selectedIndex){this._selectedIndex=a;(a=this.getChildByTag(cc.CURRENT_ITEM))&&a.removeFromParent(!1);
a=this.subItems[this._selectedIndex];this.addChild(a,0,cc.CURRENT_ITEM);var b=a.width,c=a.height;this.width=b;this.height=c;a.setPosition(b/2,c/2)}},getSubItems:function(){return this.subItems},setSubItems:function(a){this.subItems=a},initWithItems:function(a){var b=a.length;cc.isFunction(a[a.length-2])?(this.initWithCallback(a[a.length-2],a[a.length-1]),b-=2):cc.isFunction(a[a.length-1])?(this.initWithCallback(a[a.length-1],null),b-=1):this.initWithCallback(null,null);for(var c=this.subItems,d=c.length=
0;b>d;d++)a[d]&&c.push(a[d]);return this._selectedIndex=cc.UINT_MAX,this.setSelectedIndex(0),this.cascadeColor=!0,this.cascadeOpacity=!0,!0},addSubItem:function(a){this.subItems.push(a)},activate:function(){this._enabled&&this.setSelectedIndex((this._selectedIndex+1)%this.subItems.length);cc.MenuItem.prototype.activate.call(this)},selected:function(){cc.MenuItem.prototype.selected.call(this);this.subItems[this._selectedIndex].selected()},unselected:function(){cc.MenuItem.prototype.unselected.call(this);
this.subItems[this._selectedIndex].unselected()},setEnabled:function(a){if(this._enabled!==a){cc.MenuItem.prototype.setEnabled.call(this,a);var b=this.subItems;if(b&&0<b.length)for(var c=0;c<b.length;c++)b[c].enabled=a}},selectedItem:function(){return this.subItems[this._selectedIndex]},getSelectedItem:function(){return this.subItems[this._selectedIndex]},onEnter:function(){cc.Node.prototype.onEnter.call(this);this.setSelectedIndex(this._selectedIndex)}});_p=cc.MenuItemToggle.prototype;_p.selectedIndex;
cc.defineGetterSetter(_p,"selectedIndex",_p.getSelectedIndex,_p.setSelectedIndex);cc.MenuItemToggle.create=function(){0<arguments.length&&null==arguments[arguments.length-1]&&cc.log("parameters should not be ending with null in Javascript");var a=new cc.MenuItemToggle;return a.initWithItems(Array.prototype.slice.apply(arguments)),a};cc.MENU_STATE_WAITING=0;cc.MENU_STATE_TRACKING_TOUCH=1;cc.MENU_HANDLER_PRIORITY=-128;cc.DEFAULT_PADDING=5;
cc.Menu=cc.Layer.extend({enabled:!1,_selectedItem:null,_state:-1,_touchListener:null,_className:"Menu",ctor:function(a){cc.Layer.prototype.ctor.call(this);this._color=cc.color.WHITE;this.enabled=!1;this._opacity=255;this._selectedItem=null;this._state=-1;this._touchListener=cc.EventListener.create({event:cc.EventListener.TOUCH_ONE_BY_ONE,swallowTouches:!0,onTouchBegan:this._onTouchBegan,onTouchMoved:this._onTouchMoved,onTouchEnded:this._onTouchEnded,onTouchCancelled:this._onTouchCancelled});0<arguments.length&&
null==arguments[arguments.length-1]&&cc.log("parameters should not be ending with null in Javascript");var b,c=arguments.length;if(0===c)b=[];else if(1===c)b=a instanceof Array?a:[a];else if(1<c){b=[];for(var d=0;c>d;d++)arguments[d]&&b.push(arguments[d])}this.initWithArray(b)},onEnter:function(){var a=this._touchListener;a._isRegistered()||cc.eventManager.addListener(a,this);cc.Node.prototype.onEnter.call(this)},isEnabled:function(){return this.enabled},setEnabled:function(a){this.enabled=a},initWithItems:function(a){var b=
[];if(a)for(var c=0;c<a.length;c++)a[c]&&b.push(a[c]);return this.initWithArray(b)},initWithArray:function(a){if(cc.Layer.prototype.init.call(this)){this.enabled=!0;var b=cc.winSize;if(this.setPosition(b.width/2,b.height/2),this.setContentSize(b),this.setAnchorPoint(0.5,0.5),this.ignoreAnchorPointForPosition(!0),a)for(b=0;b<a.length;b++)this.addChild(a[b],b);return this._selectedItem=null,this._state=cc.MENU_STATE_WAITING,this.cascadeColor=!0,this.cascadeOpacity=!0,!0}return!1},addChild:function(a,
b,c){if(!(a instanceof cc.MenuItem))throw"cc.Menu.addChild() : Menu only supports MenuItem objects as children";cc.Layer.prototype.addChild.call(this,a,b,c)},alignItemsVertically:function(){this.alignItemsVerticallyWithPadding(cc.DEFAULT_PADDING)},alignItemsVerticallyWithPadding:function(a){var b,c,d,e,f;d=-a;var g=this._children;if(g&&0<g.length){c=0;for(b=g.length;b>c;c++)d+=g[c].height*g[c].scaleY+a;var h=d/2;c=0;for(b=g.length;b>c;c++)f=g[c],e=f.height,d=f.scaleY,f.setPosition(0,h-e*d/2),h-=e*
d+a}},alignItemsHorizontally:function(){this.alignItemsHorizontallyWithPadding(cc.DEFAULT_PADDING)},alignItemsHorizontallyWithPadding:function(a){var b,c,d,e,f;d=-a;var g=this._children;if(g&&0<g.length){b=0;for(c=g.length;c>b;b++)d+=g[b].width*g[b].scaleX+a;var h=-d/2;b=0;for(c=g.length;c>b;b++)f=g[b],d=f.scaleX,e=g[b].width,f.setPosition(h+e*d/2,0),h+=e*d+a}},alignItemsInColumns:function(){0<arguments.length&&null==arguments[arguments.length-1]&&cc.log("parameters should not be ending with null in Javascript");
for(var a=[],b=0;b<arguments.length;b++)a.push(arguments[b]);var c,d,e,f=-5,g=0,h=0,k=0,m=this._children;if(m&&0<m.length){b=0;for(e=m.length;e>b;b++)g>=a.length||(c=a[g],c&&(d=m[b].height,h=h>=d||isNaN(d)?h:d,++k,k>=c&&(f+=h+5,k=0,h=0,++g)))}var n=cc.director.getWinSize(),p=c=h=g=0,r=0,f=f/2;if(m&&0<m.length){b=0;for(e=m.length;e>b;b++){var s=m[b];0===c&&(c=a[g],p=n.width/(1+c),r=p);d=s._getHeight();h=h>=d||isNaN(d)?h:d;s.setPosition(r-n.width/2,f-d/2);r+=p;++k;k>=c&&(f-=h+5,k=0,c=0,h=0,++g)}}},
alignItemsInRows:function(){0<arguments.length&&null==arguments[arguments.length-1]&&cc.log("parameters should not be ending with null in Javascript");var a,b=[];for(a=0;a<arguments.length;a++)b.push(arguments[a]);var c,d,e,f,g=[],h=[],k=-10,m=-5,n=0,p=0,r=0,s=this._children;if(s&&0<s.length){a=0;for(e=s.length;e>a;a++)d=s[a],n>=b.length||(c=b[n],c&&(f=d.width,p=p>=f||isNaN(f)?p:f,m+=d.height+5,++r,r>=c&&(g.push(p),h.push(m),k+=p+10,r=0,p=0,m=-5,++n)))}m=cc.director.getWinSize();c=p=n=0;var k=-k/
2,v=0;if(s&&0<s.length){a=0;for(e=s.length;e>a;a++)d=s[a],0===c&&(c=b[n],v=h[n]),f=d._getWidth(),p=p>=f||isNaN(f)?p:f,d.setPosition(k+g[n]/2,v-m.height/2),v-=d.height+10,++r,r>=c&&(k+=p+5,r=0,c=0,p=0,++n)}},removeChild:function(a,b){if(null!=a){if(!(a instanceof cc.MenuItem))return void cc.log("cc.Menu.removeChild():Menu only supports MenuItem objects as children");this._selectedItem===a&&(this._selectedItem=null);cc.Node.prototype.removeChild.call(this,a,b)}},_onTouchBegan:function(a,b){var c=b.getCurrentTarget();
if(c._state!==cc.MENU_STATE_WAITING||!c._visible||!c.enabled)return!1;for(var d=c.parent;null!=d;d=d.parent)if(!d.isVisible())return!1;return c._selectedItem=c._itemForTouch(a),c._selectedItem?(c._state=cc.MENU_STATE_TRACKING_TOUCH,c._selectedItem.selected(),c._selectedItem.setNodeDirty(),!0):!1},_onTouchEnded:function(a,b){var c=b.getCurrentTarget();return c._state!==cc.MENU_STATE_TRACKING_TOUCH?void cc.log("cc.Menu.onTouchEnded(): invalid state"):(c._selectedItem&&(c._selectedItem.unselected(),
c._selectedItem.setNodeDirty(),c._selectedItem.activate()),void(c._state=cc.MENU_STATE_WAITING))},_onTouchCancelled:function(a,b){var c=b.getCurrentTarget();return c._state!==cc.MENU_STATE_TRACKING_TOUCH?void cc.log("cc.Menu.onTouchCancelled(): invalid state"):(this._selectedItem&&(c._selectedItem.unselected(),c._selectedItem.setNodeDirty()),void(c._state=cc.MENU_STATE_WAITING))},_onTouchMoved:function(a,b){var c=b.getCurrentTarget();if(c._state!==cc.MENU_STATE_TRACKING_TOUCH)return void cc.log("cc.Menu.onTouchMoved(): invalid state");
var d=c._itemForTouch(a);d!==c._selectedItem&&(c._selectedItem&&(c._selectedItem.unselected(),c._selectedItem.setNodeDirty()),c._selectedItem=d,c._selectedItem&&(c._selectedItem.selected(),c._selectedItem.setNodeDirty()))},onExit:function(){this._state===cc.MENU_STATE_TRACKING_TOUCH&&(this._selectedItem&&(this._selectedItem.unselected(),this._selectedItem=null),this._state=cc.MENU_STATE_WAITING);cc.Node.prototype.onExit.call(this)},setOpacityModifyRGB:function(a){},isOpacityModifyRGB:function(){return!1},
_itemForTouch:function(a){var b;a=a.getLocation();var c=this._children;if(c&&0<c.length)for(var d=c.length-1;0<=d;d--)if(b=c[d],b.isVisible()&&b.isEnabled()){var e=b.convertToNodeSpace(a),f=b.rect();if(f.x=0,f.y=0,cc.rectContainsPoint(f,e))return b}return null}});_p=cc.Menu.prototype;_p.enabled;
cc.Menu.create=function(a){var b=arguments.length;0<b&&null==arguments[b-1]&&cc.log("parameters should not be ending with null in Javascript");return 0===b?new cc.Menu:new cc.Menu(1===b?a:Array.prototype.slice.call(arguments,0))};cc.math=cc.math||{};cc.math.EPSILON=0.015625;cc.math.square=function(a){return a*a};cc.math.almostEqual=function(a,b){return a+cc.math.EPSILON>b&&a-cc.math.EPSILON<b};
(function(a){a.math.Vec2=function(a,b){void 0===b?(this.x=a.x,this.y=a.y):(this.x=a||0,this.y=b||0)};var b=a.math.Vec2.prototype;b.fill=function(a,b){this.x=a;this.y=b};b.length=function(){return Math.sqrt(a.math.square(this.x)+a.math.square(this.y))};b.lengthSq=function(){return a.math.square(this.x)+a.math.square(this.y)};b.normalize=function(){var a=1/this.length();return this.x*=a,this.y*=a,this};a.math.Vec2.add=function(a,b,e){return a.x=b.x+e.x,a.y=b.y+e.y,a};b.add=function(a){return this.x+=
a.x,this.y+=a.y,this};b.dot=function(a){return this.x*a.x+this.y*a.y};a.math.Vec2.subtract=function(a,b,e){return a.x=b.x-e.x,a.y=b.y-e.y,a};b.subtract=function(a){return this.x-=a.x,this.y-=a.y,this};b.transform=function(a){var b=this.x,e=this.y;return this.x=b*a.mat[0]+e*a.mat[3]+a.mat[6],this.y=b*a.mat[1]+e*a.mat[4]+a.mat[7],this};a.math.Vec2.scale=function(a,b,e){return a.x=b.x*e,a.y=b.y*e,a};b.scale=function(a){return this.x*=a,this.y*=a,this};b.equals=function(b){return this.x<b.x+a.math.EPSILON&&
this.x>b.x-a.math.EPSILON&&this.y<b.y+a.math.EPSILON&&this.y>b.y-a.math.EPSILON}})(cc);
(function(a){a.kmVec3=a.math.Vec3=function(a,b,e){a&&void 0===b?(this.x=a.x,this.y=a.y,this.z=a.z):(this.x=a||0,this.y=b||0,this.z=e||0)};a.math.vec3=function(b,d,e){return new a.math.Vec3(b,d,e)};var b=a.math.Vec3.prototype;b.fill=function(a,b,e){return a&&void 0===b?(this.x=a.x,this.y=a.y,this.z=a.z):(this.x=a,this.y=b,this.z=e),this};b.length=function(){return Math.sqrt(a.math.square(this.x)+a.math.square(this.y)+a.math.square(this.z))};b.lengthSq=function(){return a.math.square(this.x)+a.math.square(this.y)+
a.math.square(this.z)};b.normalize=function(){var a=1/this.length();return this.x*=a,this.y*=a,this.z*=a,this};b.cross=function(a){var b=this.x,e=this.y,f=this.z;return this.x=e*a.z-f*a.y,this.y=f*a.x-b*a.z,this.z=b*a.y-e*a.x,this};b.dot=function(a){return this.x*a.x+this.y*a.y+this.z*a.z};b.add=function(a){return this.x+=a.x,this.y+=a.y,this.z+=a.z,this};b.subtract=function(a){return this.x-=a.x,this.y-=a.y,this.z-=a.z,this};b.transform=function(a){var b=this.x,e=this.y,f=this.z;a=a.mat;return this.x=
b*a[0]+e*a[4]+f*a[8]+a[12],this.y=b*a[1]+e*a[5]+f*a[9]+a[13],this.z=b*a[2]+e*a[6]+f*a[10]+a[14],this};b.transformNormal=function(a){var b=this.x,e=this.y,f=this.z;a=a.mat;return this.x=b*a[0]+e*a[4]+f*a[8],this.y=b*a[1]+e*a[5]+f*a[9],this.z=b*a[2]+e*a[6]+f*a[10],this};b.transformCoord=function(b){var d=new a.math.Vec4(this.x,this.y,this.z,1);return d.transform(b),this.x=d.x/d.w,this.y=d.y/d.w,this.z=d.z/d.w,this};b.scale=function(a){return this.x*=a,this.y*=a,this.z*=a,this};b.equals=function(b){var d=
a.math.EPSILON;return this.x<b.x+d&&this.x>b.x-d&&this.y<b.y+d&&this.y>b.y-d&&this.z<b.z+d&&this.z>b.z-d};b.inverseTransform=function(b){b=b.mat;var d=new a.math.Vec3(this.x-b[12],this.y-b[13],this.z-b[14]);return this.x=d.x*b[0]+d.y*b[1]+d.z*b[2],this.y=d.x*b[4]+d.y*b[5]+d.z*b[6],this.z=d.x*b[8]+d.y*b[9]+d.z*b[10],this};b.inverseTransformNormal=function(a){var b=this.x,e=this.y,f=this.z;a=a.mat;return this.x=b*a[0]+e*a[1]+f*a[2],this.y=b*a[4]+e*a[5]+f*a[6],this.z=b*a[8]+e*a[9]+f*a[10],this};b.assignFrom=
function(a){return a?(this.x=a.x,this.y=a.y,this.z=a.z,this):this};a.math.Vec3.zero=function(a){return a.x=a.y=a.z=0,a};b.toTypeArray=function(){var a=new Float32Array(3);return a[0]=this.x,a[1]=this.y,a[2]=this.z,a}})(cc);
(function(a){a.math.Vec4=function(a,b,e,f){a&&void 0===b?(this.x=a.x,this.y=a.y,this.z=a.z,this.w=a.w):(this.x=a||0,this.y=b||0,this.z=e||0,this.w=f||0)};a.kmVec4=a.math.Vec4;var b=a.math.Vec4.prototype;b.fill=function(a,b,e,f){a&&void 0===b?(this.x=a.x,this.y=a.y,this.z=a.z,this.w=a.w):(this.x=a,this.y=b,this.z=e,this.w=f)};b.add=function(a){return a?(this.x+=a.x,this.y+=a.y,this.z+=a.z,this.w+=a.w,this):this};b.dot=function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w};b.length=function(){return Math.sqrt(a.math.square(this.x)+
a.math.square(this.y)+a.math.square(this.z)+a.math.square(this.w))};b.lengthSq=function(){return a.math.square(this.x)+a.math.square(this.y)+a.math.square(this.z)+a.math.square(this.w)};b.lerp=function(a,b){return this};b.normalize=function(){var a=1/this.length();return this.x*=a,this.y*=a,this.z*=a,this.w*=a,this};b.scale=function(a){return this.normalize(),this.x*=a,this.y*=a,this.z*=a,this.w*=a,this};b.subtract=function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w};b.transform=function(a){var b=
this.x,e=this.y,f=this.z,g=this.w;a=a.mat;return this.x=b*a[0]+e*a[4]+f*a[8]+g*a[12],this.y=b*a[1]+e*a[5]+f*a[9]+g*a[13],this.z=b*a[2]+e*a[6]+f*a[10]+g*a[14],this.w=b*a[3]+e*a[7]+f*a[11]+g*a[15],this};a.math.Vec4.transformArray=function(b,d){for(var e=[],f=0;f<b.length;f++){var g=new a.math.Vec4(b[f]);g.transform(d);e.push(g)}return e};b.equals=function(b){var d=a.math.EPSILON;return this.x<b.x+d&&this.x>b.x-d&&this.y<b.y+d&&this.y>b.y-d&&this.z<b.z+d&&this.z>b.z-d&&this.w<b.w+d&&this.w>b.w-d};b.assignFrom=
function(a){return this.x=a.x,this.y=a.y,this.z=a.z,this.w=a.w,this};b.toTypeArray=function(){var a=new Float32Array(4);return a[0]=this.x,a[1]=this.y,a[2]=this.z,a[3]=this.w,a}})(cc);
(function(a){function b(b,d,e){d=new a.math.Vec2(d);d.subtract(b);e.x=-d.y;e.y=d.x;e.normalize()}a.math.Ray2=function(b,d){this.start=b||new a.math.Vec2;this.dir=d||new a.math.Vec2};a.math.Ray2.prototype.fill=function(a,b,e,f){this.start.x=a;this.start.y=b;this.dir.x=e;this.dir.y=f};a.math.Ray2.prototype.intersectLineSegment=function(b,d,e){var f,g,h,k=this.start.x,m=this.start.y,n=this.start.x+this.dir.x,p=this.start.y+this.dir.y,r=b.x,s=b.y,v=d.x,u=d.y,t=(u-s)*(n-k)-(v-r)*(p-m);return t>-a.math.EPSILON&&
t<a.math.EPSILON?!1:(f=((v-r)*(m-s)-(u-s)*(k-r))/t,g=k+f*(n-k),h=m+f*(p-m),g<Math.min(b.x,d.x)-a.math.EPSILON||g>Math.max(b.x,d.x)+a.math.EPSILON||h<Math.min(b.y,d.y)-a.math.EPSILON||h>Math.max(b.y,d.y)+a.math.EPSILON?!1:g<Math.min(k,n)-a.math.EPSILON||g>Math.max(k,n)+a.math.EPSILON||h<Math.min(m,p)-a.math.EPSILON||h>Math.max(m,p)+a.math.EPSILON?!1:(e.x=g,e.y=h,!0))};a.math.Ray2.prototype.intersectTriangle=function(c,d,e,f,g){var h,k=new a.math.Vec2,m=new a.math.Vec2,n=new a.math.Vec2,p=1E4,r=!1;
return this.intersectLineSegment(c,d,k)&&(r=!0,h=k.subtract(this.start).length(),p>h&&(m.x=k.x,m.y=k.y,p=h,b(c,d,n))),this.intersectLineSegment(d,e,k)&&(r=!0,h=k.subtract(this.start).length(),p>h&&(m.x=k.x,m.y=k.y,p=h,b(d,e,n))),this.intersectLineSegment(e,c,k)&&(r=!0,h=k.subtract(this.start).length(),p>h&&(m.x=k.x,m.y=k.y,b(e,c,n))),r&&(f.x=m.x,f.y=m.y,g&&(g.x=n.x,g.y=n.y)),r}})(cc);var Float32Array=Float32Array||Array;
!function(a){a.math.Matrix3=function(a){a&&a.mat?this.mat=new Float32Array(a.mat):this.mat=new Float32Array(9)};a.kmMat3=a.math.Matrix3;var b=a.math.Matrix3.prototype;b.fill=function(a){var b=this.mat;a=a.mat;return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],this};b.adjugate=function(){var a=this.mat,b=a[0],c=a[1],g=a[2],h=a[3],k=a[4],m=a[5],n=a[6],p=a[7],r=a[8];return a[0]=k*r-m*p,a[1]=g*p-c*r,a[2]=c*m-g*k,a[3]=m*n-h*r,a[4]=b*r-g*n,a[5]=g*h-b*m,a[6]=
h*p-k*n,a[8]=b*k-c*h,this};b.identity=function(){var a=this.mat;return a[1]=a[2]=a[3]=a[5]=a[6]=a[7]=0,a[0]=a[4]=a[8]=1,this};var c=new a.math.Matrix3;b.inverse=function(a){if(0===a)return this;c.assignFrom(this);a=1/a;return this.adjugate(),this.multiplyScalar(a),this};b.isIdentity=function(){var a=this.mat;return 1===a[0]&&0===a[1]&&0===a[2]&&0===a[3]&&1===a[4]&&0===a[5]&&0===a[6]&&0===a[7]&&1===a[8]};b.transpose=function(){var a=this.mat,b=a[1],c=a[2],g=a[5],h=a[6],k=a[7];return a[1]=a[3],a[2]=
h,a[3]=b,a[5]=k,a[6]=c,a[7]=g,this};b.determinant=function(){var a=this.mat;return a[0]*a[4]*a[8]+a[1]*a[5]*a[6]+a[2]*a[3]*a[7]-(a[2]*a[4]*a[6]+a[0]*a[5]*a[7]+a[1]*a[3]*a[8])};b.multiply=function(a){var b=this.mat,c=a.mat;a=b[0];var g=b[1],h=b[2],k=b[3],m=b[4],n=b[5],p=b[6],r=b[7],s=b[8],v=c[0],u=c[1],t=c[2],x=c[3],A=c[4],F=c[5],z=c[6],w=c[7],c=c[8];return b[0]=a*v+k*u+p*t,b[1]=g*v+m*u+r*t,b[2]=h*v+n*u+s*t,b[3]=h*v+n*u+s*t,b[4]=g*x+m*A+r*F,b[5]=h*x+n*A+s*F,b[6]=a*z+k*w+p*c,b[7]=g*z+m*w+r*c,b[8]=h*
z+n*w+s*c,this};b.multiplyScalar=function(a){var b=this.mat;return b[0]*=a,b[1]*=a,b[2]*=a,b[3]*=a,b[4]*=a,b[5]*=a,b[6]*=a,b[7]*=a,b[8]*=a,this};a.math.Matrix3.rotationAxisAngle=function(b,c){var f=Math.cos(c),g=Math.sin(c),h=new a.math.Matrix3,k=h.mat;return k[0]=f+b.x*b.x*(1-f),k[1]=b.z*g+b.y*b.x*(1-f),k[2]=-b.y*g+b.z*b.x*(1-f),k[3]=-b.z*g+b.x*b.y*(1-f),k[4]=f+b.y*b.y*(1-f),k[5]=b.x*g+b.z*b.y*(1-f),k[6]=b.y*g+b.x*b.z*(1-f),k[7]=-b.x*g+b.y*b.z*(1-f),k[8]=f+b.z*b.z*(1-f),h};b.assignFrom=function(b){if(this===
b)return a.log("cc.math.Matrix3.assign(): current matrix equals matIn"),this;var c=this.mat;b=b.mat;return c[0]=b[0],c[1]=b[1],c[2]=b[2],c[3]=b[3],c[4]=b[4],c[5]=b[5],c[6]=b[6],c[7]=b[7],c[8]=b[8],this};b.equals=function(b){if(this===b)return!0;var c=a.math.EPSILON,f=this.mat;b=b.mat;for(var g=0;9>g;++g)if(!(f[g]+c>b[g]&&f[g]-c<b[g]))return!1;return!0};a.math.Matrix3.createByRotationX=function(b){var c=new a.math.Matrix3,f=c.mat;return f[0]=1,f[1]=0,f[2]=0,f[3]=0,f[4]=Math.cos(b),f[5]=Math.sin(b),
f[6]=0,f[7]=-Math.sin(b),f[8]=Math.cos(b),c};a.math.Matrix3.createByRotationY=function(b){var c=new a.math.Matrix3,f=c.mat;return f[0]=Math.cos(b),f[1]=0,f[2]=-Math.sin(b),f[3]=0,f[4]=1,f[5]=0,f[6]=Math.sin(b),f[7]=0,f[8]=Math.cos(b),c};a.math.Matrix3.createByRotationZ=function(b){var c=new a.math.Matrix3,f=c.mat;return f[0]=Math.cos(b),f[1]=-Math.sin(b),f[2]=0,f[3]=Math.sin(b),f[4]=Math.cos(b),f[5]=0,f[6]=0,f[7]=0,f[8]=1,c};a.math.Matrix3.createByRotation=function(b){var c=new a.math.Matrix3,f=c.mat;
return f[0]=Math.cos(b),f[1]=Math.sin(b),f[2]=0,f[3]=-Math.sin(b),f[4]=Math.cos(b),f[5]=0,f[6]=0,f[7]=0,f[8]=1,c};a.math.Matrix3.createByScale=function(b,c){var f=new a.math.Matrix3;return f.identity(),f.mat[0]=b,f.mat[4]=c,f};a.math.Matrix3.createByTranslation=function(b,c){var f=new a.math.Matrix3;return f.identity(),f.mat[6]=b,f.mat[7]=c,f};a.math.Matrix3.createByQuaternion=function(b){if(!b)return null;var c=new a.math.Matrix3,f=c.mat;return f[0]=1-2*(b.y*b.y+b.z*b.z),f[1]=2*(b.x*b.y-b.w*b.z),
f[2]=2*(b.x*b.z+b.w*b.y),f[3]=2*(b.x*b.y+b.w*b.z),f[4]=1-2*(b.x*b.x+b.z*b.z),f[5]=2*(b.y*b.z-b.w*b.x),f[6]=2*(b.x*b.z-b.w*b.y),f[7]=2*(b.y*b.z+b.w*b.x),f[8]=1-2*(b.x*b.x+b.y*b.y),c};b.rotationToAxisAngle=function(){return a.math.Quaternion.rotationMatrix(this).toAxisAndAngle()}}(cc);
(function(a){a.math.Matrix4=function(a){a&&a.mat?this.mat=new Float32Array(a.mat):this.mat=new Float32Array(16)};a.kmMat4=a.math.Matrix4;var b=a.math.Matrix4.prototype;b.fill=function(a){for(var b=this.mat,c=0;16>c;c++)b[c]=a[c];return this};a.kmMat4Identity=function(a){var b=a.mat;return b[1]=b[2]=b[3]=b[4]=b[6]=b[7]=b[8]=b[9]=b[11]=b[12]=b[13]=b[14]=0,b[0]=b[5]=b[10]=b[15]=1,a};b.identity=function(){var a=this.mat;return a[1]=a[2]=a[3]=a[4]=a[6]=a[7]=a[8]=a[9]=a[11]=a[12]=a[13]=a[14]=0,a[0]=a[5]=
a[10]=a[15]=1,this};b.get=function(a,b){return this.mat[a+4*b]};b.set=function(a,b,c){this.mat[a+4*b]=c};b.swap=function(a,b,c,d){var k=this.mat,m=k[a+4*b];k[a+4*b]=k[c+4*d];k[c+4*d]=m};a.math.Matrix4._gaussj=function(a,b){var c,d,k,m,n,p=0,r=0,s=[0,0,0,0],v=[0,0,0,0],u=[0,0,0,0];for(c=0;4>c;c++){for(d=n=0;4>d;d++)if(1!==u[d])for(k=0;4>k;k++)0===u[k]&&(m=Math.abs(a.get(d,k)),m>=n&&(n=m,r=d,p=k));if(++u[p],r!==p){for(d=0;4>d;d++)a.swap(r,d,p,d);for(d=0;4>d;d++)b.swap(r,d,p,d)}if(v[c]=r,s[c]=p,0===
a.get(p,p))return!1;k=1/a.get(p,p);a.set(p,p,1);for(d=0;4>d;d++)a.set(p,d,a.get(p,d)*k);for(d=0;4>d;d++)b.set(p,d,b.get(p,d)*k);for(k=0;4>k;k++)if(k!==p){n=a.get(k,p);a.set(k,p,0);for(d=0;4>d;d++)a.set(k,d,a.get(k,d)-a.get(p,d)*n);for(d=0;4>d;d++)b.set(k,d,a.get(k,d)-b.get(p,d)*n)}}for(d=3;0<=d;d--)if(v[d]!==s[d])for(k=0;4>k;k++)a.swap(k,v[d],k,s[d]);return!0};var c=(new a.math.Matrix4).identity();a.kmMat4Inverse=function(b,d){var g=new a.math.Matrix4(d);return!1===a.math.Matrix4._gaussj(g,c)?null:
(b.assignFrom(g),b)};b.inverse=function(){var b=new a.math.Matrix4(this);return!1===a.math.Matrix4._gaussj(b,c)?null:b};b.isIdentity=function(){var a=this.mat;return 1===a[0]&&0===a[1]&&0===a[2]&&0===a[3]&&0===a[4]&&1===a[5]&&0===a[6]&&0===a[7]&&0===a[8]&&0===a[9]&&1===a[10]&&0===a[11]&&0===a[12]&&0===a[13]&&0===a[14]&&1===a[15]};b.transpose=function(){var a=this.mat,b=a[1],c=a[2],d=a[3],k=a[6],m=a[7],n=a[8],p=a[9],r=a[11],s=a[12],v=a[13],u=a[14];return a[1]=a[4],a[2]=n,a[3]=s,a[4]=b,a[6]=p,a[7]=
v,a[8]=c,a[9]=k,a[11]=u,a[12]=d,a[13]=m,a[14]=r,this};a.kmMat4Multiply=function(a,b,c){var d=a.mat,k=b.mat,m=c.mat;c=k[0];b=k[1];var n=k[2],p=k[3],r=k[4],s=k[5],v=k[6],u=k[7],t=k[8],x=k[9],A=k[10],F=k[11],z=k[12],w=k[13],B=k[14],k=k[15],E=m[0],I=m[1],J=m[2],O=m[3],L=m[4],D=m[5],y=m[6],H=m[7],K=m[8],N=m[9],W=m[10],U=m[11],C=m[12],G=m[13],T=m[14],m=m[15];return d[0]=E*c+I*r+J*t+O*z,d[1]=E*b+I*s+J*x+O*w,d[2]=E*n+I*v+J*A+O*B,d[3]=E*p+I*u+J*F+O*k,d[4]=L*c+D*r+y*t+H*z,d[5]=L*b+D*s+y*x+H*w,d[6]=L*n+D*v+
y*A+H*B,d[7]=L*p+D*u+y*F+H*k,d[8]=K*c+N*r+W*t+U*z,d[9]=K*b+N*s+W*x+U*w,d[10]=K*n+N*v+W*A+U*B,d[11]=K*p+N*u+W*F+U*k,d[12]=C*c+G*r+T*t+m*z,d[13]=C*b+G*s+T*x+m*w,d[14]=C*n+G*v+T*A+m*B,d[15]=C*p+G*u+T*F+m*k,a};b.multiply=function(a){var b=this.mat,c=a.mat;a=b[0];var d=b[1],k=b[2],m=b[3],n=b[4],p=b[5],r=b[6],s=b[7],v=b[8],u=b[9],t=b[10],x=b[11],A=b[12],F=b[13],z=b[14],w=b[15],B=c[0],E=c[1],I=c[2],J=c[3],O=c[4],L=c[5],D=c[6],y=c[7],H=c[8],K=c[9],N=c[10],W=c[11],U=c[12],C=c[13],G=c[14],c=c[15];return b[0]=
B*a+E*n+I*v+J*A,b[1]=B*d+E*p+I*u+J*F,b[2]=B*k+E*r+I*t+J*z,b[3]=B*m+E*s+I*x+J*w,b[4]=O*a+L*n+D*v+y*A,b[5]=O*d+L*p+D*u+y*F,b[6]=O*k+L*r+D*t+y*z,b[7]=O*m+L*s+D*x+y*w,b[8]=H*a+K*n+N*v+W*A,b[9]=H*d+K*p+N*u+W*F,b[10]=H*k+K*r+N*t+W*z,b[11]=H*m+K*s+N*x+W*w,b[12]=U*a+C*n+G*v+c*A,b[13]=U*d+C*p+G*u+c*F,b[14]=U*k+C*r+G*t+c*z,b[15]=U*m+C*s+G*x+c*w,this};a.getMat4MultiplyValue=function(a,b){var c=a.mat,d=b.mat,k=new Float32Array(16);return k[0]=c[0]*d[0]+c[4]*d[1]+c[8]*d[2]+c[12]*d[3],k[1]=c[1]*d[0]+c[5]*d[1]+
c[9]*d[2]+c[13]*d[3],k[2]=c[2]*d[0]+c[6]*d[1]+c[10]*d[2]+c[14]*d[3],k[3]=c[3]*d[0]+c[7]*d[1]+c[11]*d[2]+c[15]*d[3],k[4]=c[0]*d[4]+c[4]*d[5]+c[8]*d[6]+c[12]*d[7],k[5]=c[1]*d[4]+c[5]*d[5]+c[9]*d[6]+c[13]*d[7],k[6]=c[2]*d[4]+c[6]*d[5]+c[10]*d[6]+c[14]*d[7],k[7]=c[3]*d[4]+c[7]*d[5]+c[11]*d[6]+c[15]*d[7],k[8]=c[0]*d[8]+c[4]*d[9]+c[8]*d[10]+c[12]*d[11],k[9]=c[1]*d[8]+c[5]*d[9]+c[9]*d[10]+c[13]*d[11],k[10]=c[2]*d[8]+c[6]*d[9]+c[10]*d[10]+c[14]*d[11],k[11]=c[3]*d[8]+c[7]*d[9]+c[11]*d[10]+c[15]*d[11],k[12]=
c[0]*d[12]+c[4]*d[13]+c[8]*d[14]+c[12]*d[15],k[13]=c[1]*d[12]+c[5]*d[13]+c[9]*d[14]+c[13]*d[15],k[14]=c[2]*d[12]+c[6]*d[13]+c[10]*d[14]+c[14]*d[15],k[15]=c[3]*d[12]+c[7]*d[13]+c[11]*d[14]+c[15]*d[15],k};a.kmMat4Assign=function(b,c){if(b===c)return a.log("cc.kmMat4Assign(): pOut equals pIn"),b;var d=b.mat,h=c.mat;return d[0]=h[0],d[1]=h[1],d[2]=h[2],d[3]=h[3],d[4]=h[4],d[5]=h[5],d[6]=h[6],d[7]=h[7],d[8]=h[8],d[9]=h[9],d[10]=h[10],d[11]=h[11],d[12]=h[12],d[13]=h[13],d[14]=h[14],d[15]=h[15],b};b.assignFrom=
function(b){if(this===b)return a.log("cc.mat.Matrix4.assignFrom(): mat4 equals current matrix"),this;var c=this.mat;b=b.mat;return c[0]=b[0],c[1]=b[1],c[2]=b[2],c[3]=b[3],c[4]=b[4],c[5]=b[5],c[6]=b[6],c[7]=b[7],c[8]=b[8],c[9]=b[9],c[10]=b[10],c[11]=b[11],c[12]=b[12],c[13]=b[13],c[14]=b[14],c[15]=b[15],this};b.equals=function(b){if(this===b)return a.log("cc.kmMat4AreEqual(): pMat1 and pMat2 are same object."),!0;var c=this.mat;b=b.mat;for(var d=a.math.EPSILON,h=0;16>h;h++)if(!(c[h]+d>b[h]&&c[h]-d<
b[h]))return!1;return!0};a.math.Matrix4.createByRotationX=function(b,c){c=c||new a.math.Matrix4;var d=c.mat;return d[0]=1,d[3]=d[2]=d[1]=0,d[4]=0,d[5]=Math.cos(b),d[6]=Math.sin(b),d[7]=0,d[8]=0,d[9]=-Math.sin(b),d[10]=Math.cos(b),d[11]=0,d[14]=d[13]=d[12]=0,d[15]=1,c};a.math.Matrix4.createByRotationY=function(b,c){c=c||new a.math.Matrix4;var d=c.mat;return d[0]=Math.cos(b),d[1]=0,d[2]=-Math.sin(b),d[3]=0,d[7]=d[6]=d[4]=0,d[5]=1,d[8]=Math.sin(b),d[9]=0,d[10]=Math.cos(b),d[11]=0,d[14]=d[13]=d[12]=0,
d[15]=1,c};a.math.Matrix4.createByRotationZ=function(b,c){c=c||new a.math.Matrix4;var d=c.mat;return d[0]=Math.cos(b),d[1]=Math.sin(b),d[3]=d[2]=0,d[4]=-Math.sin(b),d[5]=Math.cos(b),d[7]=d[6]=0,d[11]=d[9]=d[8]=0,d[10]=1,d[14]=d[13]=d[12]=0,d[15]=1,c};a.math.Matrix4.createByPitchYawRoll=function(b,c,d,h){h=h||new a.math.Matrix4;var k=Math.cos(b);b=Math.sin(b);var m=Math.cos(c);c=Math.sin(c);var n=Math.cos(d);d=Math.sin(d);var p=b*c,r=k*c,s=h.mat;return s[0]=m*n,s[4]=m*d,s[8]=-c,s[1]=p*n-k*d,s[5]=p*
d+k*n,s[9]=b*m,s[2]=r*n+b*d,s[6]=r*d-b*n,s[10]=k*m,s[3]=s[7]=s[11]=0,s[15]=1,h};a.math.Matrix4.createByQuaternion=function(b,c){c=c||new a.math.Matrix4;var d=c.mat;return d[0]=1-2*(b.y*b.y+b.z*b.z),d[1]=2*(b.x*b.y+b.z*b.w),d[2]=2*(b.x*b.z-b.y*b.w),d[3]=0,d[4]=2*(b.x*b.y-b.z*b.w),d[5]=1-2*(b.x*b.x+b.z*b.z),d[6]=2*(b.z*b.y+b.x*b.w),d[7]=0,d[8]=2*(b.x*b.z+b.y*b.w),d[9]=2*(b.y*b.z-b.x*b.w),d[10]=1-2*(b.x*b.x+b.y*b.y),d[11]=0,d[14]=d[13]=d[12]=0,d[15]=1,c};a.math.Matrix4.createByRotationTranslation=function(b,
c,d){d=d||new a.math.Matrix4;var h=d.mat;b=b.mat;return h[0]=b[0],h[1]=b[1],h[2]=b[2],h[3]=0,h[4]=b[3],h[5]=b[4],h[6]=b[5],h[7]=0,h[8]=b[6],h[9]=b[7],h[10]=b[8],h[11]=0,h[12]=c.x,h[13]=c.y,h[14]=c.z,h[15]=1,d};a.math.Matrix4.createByScale=function(b,c,d,h){h=h||new a.math.Matrix4;var k=h.mat;return k[0]=b,k[5]=c,k[10]=d,k[15]=1,k[1]=k[2]=k[3]=k[4]=k[6]=k[7]=k[8]=k[9]=k[11]=k[12]=k[13]=k[14]=0,h};a.kmMat4Translation=function(a,b,c,d){return a.mat[0]=a.mat[5]=a.mat[10]=a.mat[15]=1,a.mat[1]=a.mat[2]=
a.mat[3]=a.mat[4]=a.mat[6]=a.mat[7]=a.mat[8]=a.mat[9]=a.mat[11]=0,a.mat[12]=b,a.mat[13]=c,a.mat[14]=d,a};a.math.Matrix4.createByTranslation=function(b,c,d,h){return h=h||new a.math.Matrix4,h.identity(),h.mat[12]=b,h.mat[13]=c,h.mat[14]=d,h};b.getUpVec3=function(){var b=this.mat;return(new a.math.Vec3(b[4],b[5],b[6])).normalize()};b.getRightVec3=function(){var b=this.mat;return(new a.math.Vec3(b[0],b[1],b[2])).normalize()};b.getForwardVec3=function(){var b=this.mat;return(new a.math.Vec3(b[8],b[9],
b[10])).normalize()};a.kmMat4PerspectiveProjection=function(b,c,d,h,k){var m=a.degreesToRadians(c/2);c=k-h;var n=Math.sin(m);if(0===c||0===n||0===d)return null;m=Math.cos(m)/n;return b.identity(),b.mat[0]=m/d,b.mat[5]=m,b.mat[10]=-(k+h)/c,b.mat[11]=-1,b.mat[14]=-2*h*k/c,b.mat[15]=0,b};a.math.Matrix4.createPerspectiveProjection=function(b,c,d,h){var k=a.degreesToRadians(b/2);b=h-d;var m=Math.sin(k);if(0===b||0===m||0===c)return null;var k=Math.cos(k)/m,m=new a.math.Matrix4,n=m.mat;return m.identity(),
n[0]=k/c,n[5]=k,n[10]=-(h+d)/b,n[11]=-1,n[14]=-2*d*h/b,n[15]=0,m};a.kmMat4OrthographicProjection=function(a,b,c,d,k,m,n){return a.identity(),a.mat[0]=2/(c-b),a.mat[5]=2/(k-d),a.mat[10]=-2/(n-m),a.mat[12]=-((c+b)/(c-b)),a.mat[13]=-((k+d)/(k-d)),a.mat[14]=-((n+m)/(n-m)),a};a.math.Matrix4.createOrthographicProjection=function(b,c,d,h,k,m){var n=new a.math.Matrix4,p=n.mat;return n.identity(),p[0]=2/(c-b),p[5]=2/(h-d),p[10]=-2/(m-k),p[12]=-((c+b)/(c-b)),p[13]=-((h+d)/(h-d)),p[14]=-((m+k)/(m-k)),n};a.kmMat4LookAt=
function(b,c,d,h){d=new a.math.Vec3(d);var k=new a.math.Vec3(h);d.subtract(c);d.normalize();k.normalize();h=new a.math.Vec3(d);h.cross(k);h.normalize();k=new a.math.Vec3(h);k.cross(d);h.normalize();b.identity();b.mat[0]=h.x;b.mat[4]=h.y;b.mat[8]=h.z;b.mat[1]=k.x;b.mat[5]=k.y;b.mat[9]=k.z;b.mat[2]=-d.x;b.mat[6]=-d.y;b.mat[10]=-d.z;c=a.math.Matrix4.createByTranslation(-c.x,-c.y,-c.z);return b.multiply(c),b};var d=new a.math.Matrix4;b.lookAt=function(b,c,g){c=new a.math.Vec3(c);var h=new a.math.Vec3(g);
g=this.mat;c.subtract(b);c.normalize();h.normalize();var k=new a.math.Vec3(c);k.cross(h);k.normalize();h=new a.math.Vec3(k);return h.cross(c),k.normalize(),this.identity(),g[0]=k.x,g[4]=k.y,g[8]=k.z,g[1]=h.x,g[5]=h.y,g[9]=h.z,g[2]=-c.x,g[6]=-c.y,g[10]=-c.z,d=a.math.Matrix4.createByTranslation(-b.x,-b.y,-b.z,d),this.multiply(d),this};a.kmMat4RotationAxisAngle=function(b,c,d){var h=Math.cos(d);d=Math.sin(d);c=new a.math.Vec3(c);return c.normalize(),b.mat[0]=h+c.x*c.x*(1-h),b.mat[1]=c.z*d+c.y*c.x*(1-
h),b.mat[2]=-c.y*d+c.z*c.x*(1-h),b.mat[3]=0,b.mat[4]=-c.z*d+c.x*c.y*(1-h),b.mat[5]=h+c.y*c.y*(1-h),b.mat[6]=c.x*d+c.z*c.y*(1-h),b.mat[7]=0,b.mat[8]=c.y*d+c.x*c.z*(1-h),b.mat[9]=-c.x*d+c.y*c.z*(1-h),b.mat[10]=h+c.z*c.z*(1-h),b.mat[11]=0,b.mat[12]=0,b.mat[13]=0,b.mat[14]=0,b.mat[15]=1,b};a.math.Matrix4.createByAxisAndAngle=function(b,c,d){d=d||new a.math.Matrix4;var h=this.mat,k=Math.cos(c);c=Math.sin(c);b=new a.math.Vec3(b);return b.normalize(),h[0]=k+b.x*b.x*(1-k),h[1]=b.z*c+b.y*b.x*(1-k),h[2]=-b.y*
c+b.z*b.x*(1-k),h[3]=0,h[4]=-b.z*c+b.x*b.y*(1-k),h[5]=k+b.y*b.y*(1-k),h[6]=b.x*c+b.z*b.y*(1-k),h[7]=0,h[8]=b.y*c+b.x*b.z*(1-k),h[9]=-b.x*c+b.y*b.z*(1-k),h[10]=k+b.z*b.z*(1-k),h[11]=0,h[12]=h[13]=h[14]=0,h[15]=1,d};b.extractRotation=function(){var b=new a.math.Matrix3,c=this.mat,d=b.mat;return d[0]=c[0],d[1]=c[1],d[2]=c[2],d[3]=c[4],d[4]=c[5],d[5]=c[6],d[6]=c[8],d[7]=c[9],d[8]=c[10],b};b.extractPlane=function(b){var c=new a.math.Plane,d=this.mat;switch(b){case a.math.Plane.RIGHT:c.a=d[3]-d[0];c.b=
d[7]-d[4];c.c=d[11]-d[8];c.d=d[15]-d[12];break;case a.math.Plane.LEFT:c.a=d[3]+d[0];c.b=d[7]+d[4];c.c=d[11]+d[8];c.d=d[15]+d[12];break;case a.math.Plane.BOTTOM:c.a=d[3]+d[1];c.b=d[7]+d[5];c.c=d[11]+d[9];c.d=d[15]+d[13];break;case a.math.Plane.TOP:c.a=d[3]-d[1];c.b=d[7]-d[5];c.c=d[11]-d[9];c.d=d[15]-d[13];break;case a.math.Plane.FAR:c.a=d[3]-d[2];c.b=d[7]-d[6];c.c=d[11]-d[10];c.d=d[15]-d[14];break;case a.math.Plane.NEAR:c.a=d[3]+d[2];c.b=d[7]+d[6];c.c=d[11]+d[10];c.d=d[15]+d[14];break;default:a.log("cc.math.Matrix4.extractPlane: Invalid plane index")}b=
Math.sqrt(c.a*c.a+c.b*c.b+c.c*c.c);return c.a/=b,c.b/=b,c.c/=b,c.d/=b,c};b.toAxisAndAngle=function(){var b=this.extractRotation();return a.math.Quaternion.rotationMatrix(b).toAxisAndAngle()}})(cc);
(function(a){a.math.Plane=function(a,b,e,f){a&&void 0===b?(this.a=a.a,this.b=a.b,this.c=a.c,this.d=a.d):(this.a=a||0,this.b=b||0,this.c=e||0,this.d=f||0)};a.kmPlane=a.math.Plane;var b=a.math.Plane.prototype;a.math.Plane.LEFT=0;a.math.Plane.RIGHT=1;a.math.Plane.BOTTOM=2;a.math.Plane.TOP=3;a.math.Plane.NEAR=4;a.math.Plane.FAR=5;a.math.Plane.POINT_INFRONT_OF_PLANE=0;a.math.Plane.POINT_BEHIND_PLANE=1;a.math.Plane.POINT_ON_PLANE=2;b.dot=function(a){return this.a*a.x+this.b*a.y+this.c*a.z+this.d*a.w};b.dotCoord=
function(a){return this.a*a.x+this.b*a.y+this.c*a.z+this.d};b.dotNormal=function(a){return this.a*a.x+this.b*a.y+this.c*a.z};a.math.Plane.fromPointNormal=function(b,d){return new a.math.Plane(d.x,d.y,d.z,-d.dot(b))};a.math.Plane.fromPoints=function(b,d,e){d=new a.math.Vec3(d);e=new a.math.Vec3(e);var f=new a.math.Plane;return d.subtract(b),e.subtract(b),d.cross(e),d.normalize(),f.a=d.x,f.b=d.y,f.c=d.z,f.d=d.scale(-1).dot(b),f};b.normalize=function(){var b=new a.math.Vec3(this.a,this.b,this.c),d=1/
b.length();return b.normalize(),this.a=b.x,this.b=b.y,this.c=b.z,this.d*=d,this};b.classifyPoint=function(b){b=this.a*b.x+this.b*b.y+this.c*b.z+this.d;return 0.001<b?a.math.Plane.POINT_INFRONT_OF_PLANE:-0.001>b?a.math.Plane.POINT_BEHIND_PLANE:a.math.Plane.POINT_ON_PLANE}})(cc);
(function(a){a.math.Quaternion=function(a,b,e,f){a&&void 0===b?(this.x=a.x,this.y=a.y,this.z=a.z,this.w=a.w):(this.x=a||0,this.y=b||0,this.z=e||0,this.w=f||0)};a.kmQuaternion=a.math.Quaternion;var b=a.math.Quaternion.prototype;b.conjugate=function(a){return this.x=-a.x,this.y=-a.y,this.z=-a.z,this.w=a.w,this};b.dot=function(a){return this.w*a.w+this.x*a.x+this.y*a.y+this.z*a.z};b.exponential=function(){return this};b.identity=function(){return this.x=0,this.y=0,this.z=0,this.w=1,this};b.inverse=function(){var b=
this.length();return Math.abs(b)>a.math.EPSILON?(this.x=0,this.y=0,this.z=0,this.w=0,this):(this.conjugate(this).scale(1/b),this)};b.isIdentity=function(){return 0===this.x&&0===this.y&&0===this.z&&1===this.w};b.length=function(){return Math.sqrt(this.lengthSq())};b.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w};b.multiply=function(a){var b=this.x,e=this.y,f=this.z,g=this.w;return this.w=g*a.w-b*a.x-e*a.y-f*a.z,this.x=g*a.x+b*a.w+e*a.z-f*a.y,this.y=g*a.y+e*a.w+
f*a.x-b*a.z,this.z=g*a.z+f*a.w+b*a.y-e*a.x,this};b.normalize=function(){var b=this.length();if(Math.abs(b)<=a.math.EPSILON)throw"current quaternion is an invalid value";return this.scale(1/b),this};b.rotationAxis=function(a,b){var e=0.5*b,f=Math.sin(e);return this.w=Math.cos(e),this.x=a.x*f,this.y=a.y*f,this.z=a.z*f,this};a.math.Quaternion.rotationMatrix=function(b){if(!b)return null;var d,e,f,g,h=[],k=b.mat;b=0;h[0]=k[0];h[1]=k[3];h[2]=k[6];h[4]=k[1];h[5]=k[4];h[6]=k[7];h[8]=k[2];h[9]=k[5];h[10]=
k[8];h[15]=1;h=h[0];k=h[0]+h[5]+h[10]+1;return k>a.math.EPSILON?(b=2*Math.sqrt(k),d=(h[9]-h[6])/b,e=(h[2]-h[8])/b,f=(h[4]-h[1])/b,g=0.25*b):h[0]>h[5]&&h[0]>h[10]?(b=2*Math.sqrt(1+h[0]-h[5]-h[10]),d=0.25*b,e=(h[4]+h[1])/b,f=(h[2]+h[8])/b,g=(h[9]-h[6])/b):h[5]>h[10]?(b=2*Math.sqrt(1+h[5]-h[0]-h[10]),d=(h[4]+h[1])/b,e=0.25*b,f=(h[9]+h[6])/b,g=(h[2]-h[8])/b):(b=2*Math.sqrt(1+h[10]-h[0]-h[5]),d=(h[2]+h[8])/b,e=(h[9]+h[6])/b,f=0.25*b,g=(h[4]-h[1])/b),new a.math.Quaternion(d,e,f,g)};a.math.Quaternion.rotationYawPitchRoll=
function(b,d,e){var f,g,h,k,m;f=a.degreesToRadians(d)/2;g=a.degreesToRadians(b)/2;h=a.degreesToRadians(e)/2;e=Math.cos(f);b=Math.cos(g);d=Math.cos(h);f=Math.sin(f);g=Math.sin(g);h=Math.sin(h);k=b*d;m=g*h;var n=new a.math.Quaternion;return n.w=e*k+f*m,n.x=f*k-e*m,n.y=e*g*d+f*b*h,n.z=e*b*h-f*g*d,n.normalize(),n};b.slerp=function(b,d){if(this.x===b.x&&this.y===b.y&&this.z===b.z&&this.w===b.w)return this;var e=this.dot(b),f=Math.acos(e),g=Math.sqrt(1-a.math.square(e)),e=Math.sin(d*f)/g,f=Math.sin((1-
d)*f)/g,g=new a.math.Quaternion(b);return this.scale(f),g.scale(e),this.add(g),this};b.toAxisAndAngle=function(){var b,d,e,f=new a.math.Vec3;return b=Math.acos(this.w),d=Math.sqrt(a.math.square(this.x)+a.math.square(this.y)+a.math.square(this.z)),d>-a.math.EPSILON&&d<a.math.EPSILON||d<2*Math.PI+a.math.EPSILON&&d>2*Math.PI-a.math.EPSILON?(e=0,f.x=0,f.y=0,f.z=1):(e=2*b,f.x=this.x/d,f.y=this.y/d,f.z=this.z/d,f.normalize()),{axis:f,angle:e}};b.scale=function(a){return this.x*=a,this.y*=a,this.z*=a,this.w*=
a,this};b.assignFrom=function(a){return this.x=a.x,this.y=a.y,this.z=a.z,this.w=a.w,this};b.add=function(a){return this.x+=a.x,this.y+=a.y,this.z+=a.z,this.w+=a.w,this};a.math.Quaternion.rotationBetweenVec3=function(b,d,e){var f=new a.math.Vec3(b),g=new a.math.Vec3(d);f.normalize();g.normalize();var h=f.dot(g);d=new a.math.Quaternion;if(1<=h)return d.identity(),d;-0.999999>h?Math.abs(e.lengthSq())<a.math.EPSILON?d.rotationAxis(e,Math.PI):(f=new a.math.Vec3(1,0,0),f.cross(b),Math.abs(f.lengthSq())<
a.math.EPSILON&&(f.fill(0,1,0),f.cross(b)),f.normalize(),d.rotationAxis(f,Math.PI)):(b=Math.sqrt(2*(1+h)),e=1/b,f.cross(g),d.x=f.x*e,d.y=f.y*e,d.z=f.z*e,d.w=0.5*b,d.normalize());return d};b.multiplyVec3=function(b){var d=this.x,e=this.y,f=this.z,g=new a.math.Vec3(b),h=new a.math.Vec3(d,e,f),d=new a.math.Vec3(d,e,f);return h.cross(b),d.cross(h),h.scale(2*q.w),d.scale(2),g.add(h),g.add(d),g}})(cc);cc.math.AABB=function(a,b){this.min=a||new cc.math.Vec3;this.max=b||new cc.math.Vec3};
cc.math.AABB.prototype.containsPoint=function(a){return a.x>=this.min.x&&a.x<=this.max.x&&a.y>=this.min.y&&a.y<=this.max.y&&a.z>=this.min.z&&a.z<=this.max.z};cc.math.AABB.containsPoint=function(a,b){return a.x>=b.min.x&&a.x<=b.max.x&&a.y>=b.min.y&&a.y<=b.max.y&&a.z>=b.min.z&&a.z<=b.max.z};cc.math.AABB.prototype.assignFrom=function(a){this.min.assignFrom(a.min);this.max.assignFrom(a.max)};cc.math.AABB.assign=function(a,b){return a.min.assignFrom(b.min),a.max.assignFrom(b.max),a};
(function(a){a.math.Matrix4Stack=function(a,b){this.top=a;this.stack=b||[]};a.km_mat4_stack=a.math.Matrix4Stack;var b=a.math.Matrix4Stack.prototype;b.initialize=function(){this.stack.length=0;this.top=null};a.km_mat4_stack_push=function(b,d){b.stack.push(b.top);b.top=new a.math.Matrix4(d)};a.km_mat4_stack_pop=function(a,b){a.top=a.stack.pop()};a.km_mat4_stack_release=function(a){a.stack=null;a.top=null};b.push=function(b){b=b||this.top;this.stack.push(this.top);this.top=new a.math.Matrix4(b)};b.pop=
function(){this.top=this.stack.pop()};b.release=function(){this._matrixPool=this.top=this.stack=null};b._getFromPool=function(b){var d=this._matrixPool;if(0===d.length)return new a.math.Matrix4(b);d=d.pop();return d.assignFrom(b),d};b._putInPool=function(a){this._matrixPool.push(a)}})(cc);
(function(a){a.KM_GL_MODELVIEW=5888;a.KM_GL_PROJECTION=5889;a.KM_GL_TEXTURE=5890;a.modelview_matrix_stack=new a.math.Matrix4Stack;a.projection_matrix_stack=new a.math.Matrix4Stack;a.texture_matrix_stack=new a.math.Matrix4Stack;a.current_stack=null;a.lazyInitialize=function(){var b=new a.math.Matrix4;a.modelview_matrix_stack.initialize();a.projection_matrix_stack.initialize();a.texture_matrix_stack.initialize();a.current_stack=a.modelview_matrix_stack;a.initialized=!0;b.identity();a.modelview_matrix_stack.push(b);
a.projection_matrix_stack.push(b);a.texture_matrix_stack.push(b)};a.lazyInitialize();a.kmGLFreeAll=function(){a.modelview_matrix_stack.release();a.modelview_matrix_stack=null;a.projection_matrix_stack.release();a.projection_matrix_stack=null;a.texture_matrix_stack.release();a.texture_matrix_stack=null;a.initialized=!1;a.current_stack=null};a.kmGLPushMatrix=function(){a.current_stack.push(a.current_stack.top)};a.kmGLPushMatrixWitMat4=function(b){a.current_stack.stack.push(a.current_stack.top);b.assignFrom(a.current_stack.top);
a.current_stack.top=b};a.kmGLPopMatrix=function(){a.current_stack.top=a.current_stack.stack.pop()};a.kmGLMatrixMode=function(b){switch(b){case a.KM_GL_MODELVIEW:a.current_stack=a.modelview_matrix_stack;break;case a.KM_GL_PROJECTION:a.current_stack=a.projection_matrix_stack;break;case a.KM_GL_TEXTURE:a.current_stack=a.texture_matrix_stack;break;default:throw"Invalid matrix mode specified";}};a.kmGLLoadIdentity=function(){a.current_stack.top.identity()};a.kmGLLoadMatrix=function(b){a.current_stack.top.assignFrom(b)};
a.kmGLMultMatrix=function(b){a.current_stack.top.multiply(b)};var b=new a.math.Matrix4;a.kmGLTranslatef=function(c,e,f){c=a.math.Matrix4.createByTranslation(c,e,f,b);a.current_stack.top.multiply(c)};var c=new a.math.Vec3;a.kmGLRotatef=function(d,e,f,g){c.fill(e,f,g);d=a.math.Matrix4.createByAxisAndAngle(c,a.degreesToRadians(d),b);a.current_stack.top.multiply(d)};a.kmGLScalef=function(c,e,f){c=a.math.Matrix4.createByScale(c,e,f,b);a.current_stack.top.multiply(c)};a.kmGLGetMatrix=function(b,c){switch(b){case a.KM_GL_MODELVIEW:c.assignFrom(a.modelview_matrix_stack.top);
break;case a.KM_GL_PROJECTION:c.assignFrom(a.projection_matrix_stack.top);break;case a.KM_GL_TEXTURE:c.assignFrom(a.texture_matrix_stack.top);break;default:throw"Invalid matrix mode specified";}}})(cc);cc.SHADER_POSITION_UCOLOR_FRAG="precision lowp float;\nvarying vec4 v_fragmentColor;\nvoid main()                              \n{ \n    gl_FragColor \x3d v_fragmentColor;      \n}\n";cc.SHADER_POSITION_UCOLOR_VERT="attribute vec4 a_position;\nuniform    vec4 u_color;\nuniform float u_pointSize;\nvarying lowp vec4 v_fragmentColor; \nvoid main(void)   \n{\n    gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position;  \n    gl_PointSize \x3d u_pointSize;          \n    v_fragmentColor \x3d u_color;           \n}";
cc.SHADER_POSITION_COLOR_FRAG="precision lowp float; \nvarying vec4 v_fragmentColor; \nvoid main() \n{ \n     gl_FragColor \x3d v_fragmentColor; \n} ";cc.SHADER_POSITION_COLOR_VERT="attribute vec4 a_position;\nattribute vec4 a_color;\nvarying lowp vec4 v_fragmentColor;\nvoid main()\n{\n    gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position;  \n    v_fragmentColor \x3d a_color;             \n}";cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_FRAG="// #extension GL_OES_standard_derivatives : enable\nvarying mediump vec4 v_color;\nvarying mediump vec2 v_texcoord;\nvoid main()\t\n{ \n// #if defined GL_OES_standard_derivatives\t\n// gl_FragColor \x3d v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0 - length(v_texcoord)); \n// #else\t\ngl_FragColor \x3d v_color * step(0.0, 1.0 - length(v_texcoord)); \n// #endif \n}";
cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_VERT="attribute mediump vec4 a_position; \nattribute mediump vec2 a_texcoord; \nattribute mediump vec4 a_color;\t\nvarying mediump vec4 v_color; \nvarying mediump vec2 v_texcoord;\t\nvoid main() \n{ \n     v_color \x3d a_color;//vec4(a_color.rgb * a_color.a, a_color.a); \n     v_texcoord \x3d a_texcoord; \n    gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position;  \n}";cc.SHADER_POSITION_TEXTURE_FRAG="precision lowp float;   \nvarying vec2 v_texCoord;  \nvoid main() \n{  \n    gl_FragColor \x3d  texture2D(CC_Texture0, v_texCoord);   \n}";
cc.SHADER_POSITION_TEXTURE_VERT="attribute vec4 a_position; \nattribute vec2 a_texCoord; \nvarying mediump vec2 v_texCoord; \nvoid main() \n{ \n    gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position;  \n    v_texCoord \x3d a_texCoord;               \n}";cc.SHADER_POSITION_TEXTURE_UCOLOR_FRAG="precision lowp float;  \nuniform vec4 u_color; \nvarying vec2 v_texCoord; \nvoid main() \n{  \n    gl_FragColor \x3d  texture2D(CC_Texture0, v_texCoord) * u_color;    \n}";
cc.SHADER_POSITION_TEXTURE_UCOLOR_VERT="attribute vec4 a_position;\nattribute vec2 a_texCoord; \nvarying mediump vec2 v_texCoord; \nvoid main() \n{ \n    gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position;  \n    v_texCoord \x3d a_texCoord;                 \n}";cc.SHADER_POSITION_TEXTURE_A8COLOR_FRAG="precision lowp float;  \nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nvoid main() \n{ \n    gl_FragColor \x3d vec4( v_fragmentColor.rgb,         \n        v_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a   \n    ); \n}";
cc.SHADER_POSITION_TEXTURE_A8COLOR_VERT="attribute vec4 a_position; \nattribute vec2 a_texCoord; \nattribute vec4 a_color;  \nvarying lowp vec4 v_fragmentColor; \nvarying mediump vec2 v_texCoord; \nvoid main() \n{ \n    gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position;  \n    v_fragmentColor \x3d a_color; \n    v_texCoord \x3d a_texCoord; \n}";cc.SHADER_POSITION_TEXTURE_COLOR_FRAG="precision lowp float;\nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nvoid main() \n{ \n    gl_FragColor \x3d v_fragmentColor * texture2D(CC_Texture0, v_texCoord); \n}";
cc.SHADER_POSITION_TEXTURE_COLOR_VERT="attribute vec4 a_position; \nattribute vec2 a_texCoord; \nattribute vec4 a_color;  \nvarying lowp vec4 v_fragmentColor; \nvarying mediump vec2 v_texCoord; \nvoid main() \n{ \n    gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position;  \n    v_fragmentColor \x3d a_color; \n    v_texCoord \x3d a_texCoord; \n}";cc.SHADER_POSITION_TEXTURE_COLOR_ALPHATEST_FRAG="precision lowp float;   \nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord;   \nuniform float CC_alpha_value; \nvoid main() \n{  \n    vec4 texColor \x3d texture2D(CC_Texture0, v_texCoord);  \n    if ( texColor.a \x3c\x3d CC_alpha_value )          \n        discard; \n    gl_FragColor \x3d texColor * v_fragmentColor;  \n}";
cc.SHADEREX_SWITCHMASK_FRAG="precision lowp float; \nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nuniform sampler2D u_texture;  \nuniform sampler2D   u_mask;   \nvoid main()  \n{  \n    vec4 texColor   \x3d texture2D(u_texture, v_texCoord);  \n    vec4 maskColor  \x3d texture2D(u_mask, v_texCoord); \n    vec4 finalColor \x3d vec4(texColor.r, texColor.g, texColor.b, maskColor.a * texColor.a);        \n    gl_FragColor    \x3d v_fragmentColor * finalColor; \n}";
cc.shaderCache={TYPE_POSITION_TEXTURECOLOR:0,TYPE_POSITION_TEXTURECOLOR_ALPHATEST:1,TYPE_POSITION_COLOR:2,TYPE_POSITION_TEXTURE:3,TYPE_POSITION_TEXTURE_UCOLOR:4,TYPE_POSITION_TEXTURE_A8COLOR:5,TYPE_POSITION_UCOLOR:6,TYPE_POSITION_LENGTH_TEXTURECOLOR:7,TYPE_MAX:8,_programs:{},_init:function(){return this.loadDefaultShaders(),!0},_loadDefaultShader:function(a,b){switch(b){case this.TYPE_POSITION_TEXTURECOLOR:a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT,cc.SHADER_POSITION_TEXTURE_COLOR_FRAG);
a.addAttribute(cc.ATTRIBUTE_NAME_POSITION,cc.VERTEX_ATTRIB_POSITION);a.addAttribute(cc.ATTRIBUTE_NAME_COLOR,cc.VERTEX_ATTRIB_COLOR);a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD,cc.VERTEX_ATTRIB_TEX_COORDS);break;case this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST:a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT,cc.SHADER_POSITION_TEXTURE_COLOR_ALPHATEST_FRAG);a.addAttribute(cc.ATTRIBUTE_NAME_POSITION,cc.VERTEX_ATTRIB_POSITION);a.addAttribute(cc.ATTRIBUTE_NAME_COLOR,cc.VERTEX_ATTRIB_COLOR);
a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD,cc.VERTEX_ATTRIB_TEX_COORDS);break;case this.TYPE_POSITION_COLOR:a.initWithVertexShaderByteArray(cc.SHADER_POSITION_COLOR_VERT,cc.SHADER_POSITION_COLOR_FRAG);a.addAttribute(cc.ATTRIBUTE_NAME_POSITION,cc.VERTEX_ATTRIB_POSITION);a.addAttribute(cc.ATTRIBUTE_NAME_COLOR,cc.VERTEX_ATTRIB_COLOR);break;case this.TYPE_POSITION_TEXTURE:a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_VERT,cc.SHADER_POSITION_TEXTURE_FRAG);a.addAttribute(cc.ATTRIBUTE_NAME_POSITION,
cc.VERTEX_ATTRIB_POSITION);a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD,cc.VERTEX_ATTRIB_TEX_COORDS);break;case this.TYPE_POSITION_TEXTURE_UCOLOR:a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_UCOLOR_VERT,cc.SHADER_POSITION_TEXTURE_UCOLOR_FRAG);a.addAttribute(cc.ATTRIBUTE_NAME_POSITION,cc.VERTEX_ATTRIB_POSITION);a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD,cc.VERTEX_ATTRIB_TEX_COORDS);break;case this.TYPE_POSITION_TEXTURE_A8COLOR:a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_A8COLOR_VERT,
cc.SHADER_POSITION_TEXTURE_A8COLOR_FRAG);a.addAttribute(cc.ATTRIBUTE_NAME_POSITION,cc.VERTEX_ATTRIB_POSITION);a.addAttribute(cc.ATTRIBUTE_NAME_COLOR,cc.VERTEX_ATTRIB_COLOR);a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD,cc.VERTEX_ATTRIB_TEX_COORDS);break;case this.TYPE_POSITION_UCOLOR:a.initWithVertexShaderByteArray(cc.SHADER_POSITION_UCOLOR_VERT,cc.SHADER_POSITION_UCOLOR_FRAG);a.addAttribute("aVertex",cc.VERTEX_ATTRIB_POSITION);break;case this.TYPE_POSITION_LENGTH_TEXTURECOLOR:a.initWithVertexShaderByteArray(cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_VERT,
cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_FRAG);a.addAttribute(cc.ATTRIBUTE_NAME_POSITION,cc.VERTEX_ATTRIB_POSITION);a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD,cc.VERTEX_ATTRIB_TEX_COORDS);a.addAttribute(cc.ATTRIBUTE_NAME_COLOR,cc.VERTEX_ATTRIB_COLOR);break;default:return void cc.log("cocos2d: cc.shaderCache._loadDefaultShader, error shader type")}a.link();a.updateUniforms()},loadDefaultShaders:function(){var a=new cc.GLProgram;this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURECOLOR);this._programs[cc.SHADER_POSITION_TEXTURECOLOR]=
a;this._programs.ShaderPositionTextureColor=a;a=new cc.GLProgram;this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST);this._programs[cc.SHADER_POSITION_TEXTURECOLORALPHATEST]=a;this._programs.ShaderPositionTextureColorAlphaTest=a;a=new cc.GLProgram;this._loadDefaultShader(a,this.TYPE_POSITION_COLOR);this._programs[cc.SHADER_POSITION_COLOR]=a;this._programs.ShaderPositionColor=a;a=new cc.GLProgram;this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURE);this._programs[cc.SHADER_POSITION_TEXTURE]=
a;this._programs.ShaderPositionTexture=a;a=new cc.GLProgram;this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURE_UCOLOR);this._programs[cc.SHADER_POSITION_TEXTURE_UCOLOR]=a;this._programs.ShaderPositionTextureUColor=a;a=new cc.GLProgram;this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURE_A8COLOR);this._programs[cc.SHADER_POSITION_TEXTUREA8COLOR]=a;this._programs.ShaderPositionTextureA8Color=a;a=new cc.GLProgram;this._loadDefaultShader(a,this.TYPE_POSITION_UCOLOR);this._programs[cc.SHADER_POSITION_UCOLOR]=
a;this._programs.ShaderPositionUColor=a;a=new cc.GLProgram;this._loadDefaultShader(a,this.TYPE_POSITION_LENGTH_TEXTURECOLOR);this._programs[cc.SHADER_POSITION_LENGTHTEXTURECOLOR]=a;this._programs.ShaderPositionLengthTextureColor=a},reloadDefaultShaders:function(){var a=this.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);a.reset();this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURECOLOR);a=this.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST);a.reset();this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST);
a=this.programForKey(cc.SHADER_POSITION_COLOR);a.reset();this._loadDefaultShader(a,this.TYPE_POSITION_COLOR);a=this.programForKey(cc.SHADER_POSITION_TEXTURE);a.reset();this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURE);a=this.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR);a.reset();this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURE_UCOLOR);a=this.programForKey(cc.SHADER_POSITION_TEXTUREA8COLOR);a.reset();this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURE_A8COLOR);a=this.programForKey(cc.SHADER_POSITION_UCOLOR);
a.reset();this._loadDefaultShader(a,this.TYPE_POSITION_UCOLOR)},programForKey:function(a){return this._programs[a]},getProgram:function(a){return this._programs[a]},addProgram:function(a,b){this._programs[b]=a}};cc.HashUniformEntry=function(a,b,c){this.value=a;this.location=b;this.hh=c||{}};
cc.GLProgram=cc.Class.extend({_glContext:null,_programObj:null,_vertShader:null,_fragShader:null,_uniforms:null,_hashForUniforms:null,_usesTime:!1,_updateUniformLocation:function(a,b,c){if(null==a)return!1;c=null;for(var d=0;d<this._hashForUniforms.length;d++)this._hashForUniforms[d].location==a&&(c=this._hashForUniforms[d]);return c?c.value==b||(c.value=b):(c=new cc.HashUniformEntry,c.location=a,c.value=b,this._hashForUniforms.push(c)),!0},_description:function(){return"\x3cCCGLProgram \x3d "+this.toString()+
" | Program \x3d "+this._programObj.toString()+", VertexShader \x3d "+this._vertShader.toString()+", FragmentShader \x3d "+this._fragShader.toString()+"\x3e"},_compileShader:function(a,b,c){if(!c||!a)return!1;c=(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"+
c;this._glContext.shaderSource(a,c);this._glContext.compileShader(a);c=this._glContext.getShaderParameter(a,this._glContext.COMPILE_STATUS);return c||(cc.log("cocos2d: ERROR: Failed to compile shader:\n"+this._glContext.getShaderSource(a)),cc.log(b===this._glContext.VERTEX_SHADER?"cocos2d: \n"+this.vertexShaderLog():"cocos2d: \n"+this.fragmentShaderLog())),!0===c},ctor:function(a,b,c){this._uniforms=[];this._hashForUniforms=[];this._glContext=c||cc._renderContext;a&&b&&this.init(a,b)},destroyProgram:function(){this._hashForUniforms=
this._uniforms=this._fragShader=this._vertShader=null;this._glContext.deleteProgram(this._programObj)},initWithVertexShaderByteArray:function(a,b){var c=this._glContext;return this._programObj=c.createProgram(),this._vertShader=null,this._fragShader=null,a&&(this._vertShader=c.createShader(c.VERTEX_SHADER),this._compileShader(this._vertShader,c.VERTEX_SHADER,a)||cc.log("cocos2d: ERROR: Failed to compile vertex shader")),b&&(this._fragShader=c.createShader(c.FRAGMENT_SHADER),this._compileShader(this._fragShader,
c.FRAGMENT_SHADER,b)||cc.log("cocos2d: ERROR: Failed to compile fragment shader")),this._vertShader&&c.attachShader(this._programObj,this._vertShader),cc.checkGLErrorDebug(),this._fragShader&&c.attachShader(this._programObj,this._fragShader),this._hashForUniforms.length=0,cc.checkGLErrorDebug(),!0},initWithString:function(a,b){return this.initWithVertexShaderByteArray(a,b)},initWithVertexShaderFilename:function(a,b){var c=cc.loader.getRes(a);if(!c)throw"Please load the resource firset : "+a;var d=
cc.loader.getRes(b);if(!d)throw"Please load the resource firset : "+b;return this.initWithVertexShaderByteArray(c,d)},init:function(a,b){return this.initWithVertexShaderFilename(a,b)},addAttribute:function(a,b){this._glContext.bindAttribLocation(this._programObj,b,a)},link:function(){return!this._programObj?(cc.log("cc.GLProgram.link(): Cannot link invalid program"),!1):(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])&&!this._glContext.getProgramParameter(this._programObj,this._glContext.LINK_STATUS)?(cc.log("cocos2d: ERROR: Failed to link program: "+this._glContext.getProgramInfoLog(this._programObj)),cc.glDeleteProgram(this._programObj),this._programObj=null,!1):!0},use:function(){cc.glUseProgram(this._programObj)},updateUniforms:function(){this._uniforms[cc.UNIFORM_PMATRIX]=
this._glContext.getUniformLocation(this._programObj,cc.UNIFORM_PMATRIX_S);this._uniforms[cc.UNIFORM_MVMATRIX]=this._glContext.getUniformLocation(this._programObj,cc.UNIFORM_MVMATRIX_S);this._uniforms[cc.UNIFORM_MVPMATRIX]=this._glContext.getUniformLocation(this._programObj,cc.UNIFORM_MVPMATRIX_S);this._uniforms[cc.UNIFORM_TIME]=this._glContext.getUniformLocation(this._programObj,cc.UNIFORM_TIME_S);this._uniforms[cc.UNIFORM_SINTIME]=this._glContext.getUniformLocation(this._programObj,cc.UNIFORM_SINTIME_S);
this._uniforms[cc.UNIFORM_COSTIME]=this._glContext.getUniformLocation(this._programObj,cc.UNIFORM_COSTIME_S);this._usesTime=null!=this._uniforms[cc.UNIFORM_TIME]||null!=this._uniforms[cc.UNIFORM_SINTIME]||null!=this._uniforms[cc.UNIFORM_COSTIME];this._uniforms[cc.UNIFORM_RANDOM01]=this._glContext.getUniformLocation(this._programObj,cc.UNIFORM_RANDOM01_S);this._uniforms[cc.UNIFORM_SAMPLER]=this._glContext.getUniformLocation(this._programObj,cc.UNIFORM_SAMPLER_S);this.use();this.setUniformLocationWith1i(this._uniforms[cc.UNIFORM_SAMPLER],
0)},getUniformLocationForName:function(a){if(!a)throw"cc.GLProgram.getUniformLocationForName(): uniform name should be non-null";if(!this._programObj)throw"cc.GLProgram.getUniformLocationForName(): Invalid operation. Cannot get uniform location when program is not initialized";return this._glContext.getUniformLocation(this._programObj,a)},getUniformMVPMatrix:function(){return this._uniforms[cc.UNIFORM_MVPMATRIX]},getUniformSampler:function(){return this._uniforms[cc.UNIFORM_SAMPLER]},setUniformLocationWith1i:function(a,
b){this._updateUniformLocation(a,b)&&this._glContext.uniform1i(a,b)},setUniformLocationWith2i:function(a,b,c){this._updateUniformLocation(a,[b,c])&&this._glContext.uniform2i(a,b,c)},setUniformLocationWith3i:function(a,b,c,d){this._updateUniformLocation(a,[b,c,d])&&this._glContext.uniform3i(a,b,c,d)},setUniformLocationWith4i:function(a,b,c,d,e){this._updateUniformLocation(a,[b,c,d,e])&&this._glContext.uniform4i(a,b,c,d,e)},setUniformLocationWith2iv:function(a,b,c){this._updateUniformLocation(a,b)&&
this._glContext.uniform2iv(a,b)},setUniformLocationWith3iv:function(a,b,c){this._updateUniformLocation(a,b)&&this._glContext.uniform3iv(a,b)},setUniformLocationWith4iv:function(a,b,c){this._updateUniformLocation(a,b)&&this._glContext.uniform4iv(a,b)},setUniformLocationI32:function(a,b){this.setUniformLocationWith1i(a,b)},setUniformLocationWith1f:function(a,b){this._updateUniformLocation(a,b)&&this._glContext.uniform1f(a,b)},setUniformLocationWith2f:function(a,b,c){this._updateUniformLocation(a,[b,
c])&&this._glContext.uniform2f(a,b,c)},setUniformLocationWith3f:function(a,b,c,d){this._updateUniformLocation(a,[b,c,d])&&this._glContext.uniform3f(a,b,c,d)},setUniformLocationWith4f:function(a,b,c,d,e){this._updateUniformLocation(a,[b,c,d,e])&&this._glContext.uniform4f(a,b,c,d,e)},setUniformLocationWith2fv:function(a,b,c){this._updateUniformLocation(a,b)&&this._glContext.uniform2fv(a,b)},setUniformLocationWith3fv:function(a,b,c){this._updateUniformLocation(a,b)&&this._glContext.uniform3fv(a,b)},
setUniformLocationWith4fv:function(a,b,c){this._updateUniformLocation(a,b)&&this._glContext.uniform4fv(a,b)},setUniformLocationWithMatrix4fv:function(a,b,c){this._updateUniformLocation(a,b)&&this._glContext.uniformMatrix4fv(a,!1,b)},setUniformLocationF32:function(){if(!(2>arguments.length))switch(arguments.length){case 2:this.setUniformLocationWith1f(arguments[0],arguments[1]);break;case 3:this.setUniformLocationWith2f(arguments[0],arguments[1],arguments[2]);break;case 4:this.setUniformLocationWith3f(arguments[0],
arguments[1],arguments[2],arguments[3]);break;case 5:this.setUniformLocationWith4f(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4])}},setUniformsForBuiltins:function(){var a=new cc.math.Matrix4,b=new cc.math.Matrix4,c=new cc.math.Matrix4;if(cc.kmGLGetMatrix(cc.KM_GL_PROJECTION,a),cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW,b),cc.kmMat4Multiply(c,a,b),this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX],a.mat,1),this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX],
b.mat,1),this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX],c.mat,1),this._usesTime)a=cc.director,a=a.getTotalFrames()*a.getAnimationInterval(),this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_TIME],a/10,a,2*a,4*a),this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_SINTIME],a/8,a/4,a/2,Math.sin(a)),this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_COSTIME],a/8,a/4,a/2,Math.cos(a));-1!==this._uniforms[cc.UNIFORM_RANDOM01]&&this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_RANDOM01],
Math.random(),Math.random(),Math.random(),Math.random())},_setUniformsForBuiltinsForRenderer:function(a){if(a&&a._renderCmd){var b=new cc.math.Matrix4,c=new cc.math.Matrix4;if(cc.kmGLGetMatrix(cc.KM_GL_PROJECTION,b),cc.kmMat4Multiply(c,b,a._renderCmd._stackMatrix),this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX],b.mat,1),this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX],a._renderCmd._stackMatrix.mat,1),this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX],
c.mat,1),this._usesTime)a=cc.director,a=a.getTotalFrames()*a.getAnimationInterval(),this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_TIME],a/10,a,2*a,4*a),this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_SINTIME],a/8,a/4,a/2,Math.sin(a)),this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_COSTIME],a/8,a/4,a/2,Math.cos(a));-1!==this._uniforms[cc.UNIFORM_RANDOM01]&&this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_RANDOM01],Math.random(),Math.random(),Math.random(),Math.random())}},
setUniformForModelViewProjectionMatrix:function(){this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX],!1,cc.getMat4MultiplyValue(cc.projection_matrix_stack.top,cc.modelview_matrix_stack.top))},setUniformForModelViewProjectionMatrixWithMat4:function(a){cc.kmMat4Multiply(a,cc.projection_matrix_stack.top,cc.modelview_matrix_stack.top);this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX],!1,a.mat)},setUniformForModelViewAndProjectionMatrixWithMat4:function(){this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX],
!1,cc.modelview_matrix_stack.top.mat);this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX],!1,cc.projection_matrix_stack.top.mat)},_setUniformForMVPMatrixWithMat4:function(a){if(!a)throw"modelView matrix is undefined.";this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX],!1,a.mat);this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX],!1,cc.projection_matrix_stack.top.mat)},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._fragShader=this._vertShader=null;this._uniforms.length=
0;this._glContext.deleteProgram(this._programObj);this._programObj=null;for(var a=0;a<this._hashForUniforms.length;a++)this._hashForUniforms[a].value=null,this._hashForUniforms[a]=null;this._hashForUniforms.length=0},getProgram:function(){return this._programObj},retain:function(){},release:function(){}});cc.GLProgram.create=function(a,b){return new cc.GLProgram(a,b)};cc.GLProgram._highpSupported=null;
cc.GLProgram._isHighpSupported=function(){if(null==cc.GLProgram._highpSupported){var a=cc._renderContext,a=a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.HIGH_FLOAT);cc.GLProgram._highpSupported=0!==a.precision}return cc.GLProgram._highpSupported};cc.setProgram=function(a,b){a.shaderProgram=b;var c=a.children;if(c)for(var d=0;d<c.length;d++)cc.setProgram(c[d],b)};cc._currentProjectionMatrix=-1;cc._vertexAttribPosition=!1;cc._vertexAttribColor=!1;cc._vertexAttribTexCoords=!1;
cc.ENABLE_GL_STATE_CACHE&&(cc.MAX_ACTIVETEXTURE=16,cc._currentShaderProgram=-1,cc._currentBoundTexture=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],cc._blendingSource=-1,cc._blendingDest=-1,cc._GLServerState=0,cc.TEXTURE_ATLAS_USE_VAO&&(cc._uVAO=0));
cc.glInvalidateStateCache=function(){if(cc.kmGLFreeAll(),cc._currentProjectionMatrix=-1,cc._vertexAttribPosition=!1,cc._vertexAttribColor=!1,cc._vertexAttribTexCoords=!1,cc.ENABLE_GL_STATE_CACHE){cc._currentShaderProgram=-1;for(var a=0;a<cc.MAX_ACTIVETEXTURE;a++)cc._currentBoundTexture[a]=-1;cc._blendingSource=-1;cc._blendingDest=-1;cc._GLServerState=0}};cc.glUseProgram=function(a){a!==cc._currentShaderProgram&&(cc._currentShaderProgram=a,cc._renderContext.useProgram(a))};
cc.ENABLE_GL_STATE_CACHE||(cc.glUseProgram=function(a){cc._renderContext.useProgram(a)});cc.glDeleteProgram=function(a){cc.ENABLE_GL_STATE_CACHE&&a===cc._currentShaderProgram&&(cc._currentShaderProgram=-1);gl.deleteProgram(a)};cc.glBlendFunc=function(a,b){(a!==cc._blendingSource||b!==cc._blendingDest)&&(cc._blendingSource=a,cc._blendingDest=b,cc.setBlending(a,b))};
cc.setBlending=function(a,b){var c=cc._renderContext;a===c.ONE&&b===c.ZERO?c.disable(c.BLEND):(c.enable(c.BLEND),cc._renderContext.blendFunc(a,b))};cc.glBlendFuncForParticle=function(a,b){if(a!==cc._blendingSource||b!==cc._blendingDest){cc._blendingSource=a;cc._blendingDest=b;var c=cc._renderContext;a===c.ONE&&b===c.ZERO?c.disable(c.BLEND):(c.enable(c.BLEND),c.blendFuncSeparate(c.SRC_ALPHA,b,a,b))}};cc.ENABLE_GL_STATE_CACHE||(cc.glBlendFunc=cc.setBlending);
cc.glBlendResetToCache=function(){var a=cc._renderContext;a.blendEquation(a.FUNC_ADD);cc.ENABLE_GL_STATE_CACHE?cc.setBlending(cc._blendingSource,cc._blendingDest):cc.setBlending(a.BLEND_SRC,a.BLEND_DST)};cc.setProjectionMatrixDirty=function(){cc._currentProjectionMatrix=-1};
cc.glEnableVertexAttribs=function(a){var b=cc._renderContext,c=a&cc.VERTEX_ATTRIB_FLAG_POSITION;c!==cc._vertexAttribPosition&&(c?b.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION):b.disableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION),cc._vertexAttribPosition=c);c=a&cc.VERTEX_ATTRIB_FLAG_COLOR;c!==cc._vertexAttribColor&&(c?b.enableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR):b.disableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR),cc._vertexAttribColor=c);a&=cc.VERTEX_ATTRIB_FLAG_TEX_COORDS;a!==cc._vertexAttribTexCoords&&
(a?b.enableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS):b.disableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS),cc._vertexAttribTexCoords=a)};cc.glBindTexture2D=function(a){cc.glBindTexture2DN(0,a)};cc.glBindTexture2DN=function(a,b){if(cc._currentBoundTexture[a]!==b){cc._currentBoundTexture[a]=b;var c=cc._renderContext;c.activeTexture(c.TEXTURE0+a);b?c.bindTexture(c.TEXTURE_2D,b._webTextureObj):c.bindTexture(c.TEXTURE_2D,null)}};
cc.ENABLE_GL_STATE_CACHE||(cc.glBindTexture2DN=function(a,b){var c=cc._renderContext;c.activeTexture(c.TEXTURE0+a);b?c.bindTexture(c.TEXTURE_2D,b._webTextureObj):c.bindTexture(c.TEXTURE_2D,null)});cc.glDeleteTexture=function(a){cc.glDeleteTextureN(0,a)};cc.glDeleteTextureN=function(a,b){cc.ENABLE_GL_STATE_CACHE&&b===cc._currentBoundTexture[a]&&(cc._currentBoundTexture[a]=-1);cc._renderContext.deleteTexture(b)};
cc.glBindVAO=function(a){cc.TEXTURE_ATLAS_USE_VAO&&cc.ENABLE_GL_STATE_CACHE&&cc._uVAO!==a&&(cc._uVAO=a)};cc.glEnable=function(a){cc.ENABLE_GL_STATE_CACHE};cc.IMAGE_FORMAT_JPEG=0;cc.IMAGE_FORMAT_PNG=1;cc.IMAGE_FORMAT_RAWDATA=9;cc.NextPOT=function(a){return a-=1,a|=a>>1,a|=a>>2,a|=a>>4,a|=a>>8,a|=a>>16,a+1};
cc.RenderTexture=cc.Node.extend({sprite:null,clearFlags:0,clearDepthVal:0,autoDraw:!1,_texture:null,_pixelFormat:cc.Texture2D.PIXEL_FORMAT_RGBA8888,clearStencilVal:0,_clearColor:null,_className:"RenderTexture",ctor:function(a,b,c,d){cc.Node.prototype.ctor.call(this);this._cascadeOpacityEnabled=this._cascadeColorEnabled=!0;this._clearColor=new cc.Color(0,0,0,255);void 0!==a&&void 0!==b&&(c=c||cc.Texture2D.PIXEL_FORMAT_RGBA8888,d=d||0,this.initWithWidthAndHeight(a,b,c,d));this.setAnchorPoint(0,0)},
_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.RenderTexture.CanvasRenderCmd(this):new cc.RenderTexture.WebGLRenderCmd(this)},cleanup:function(){cc.Node.prototype.onExit.call(this);this._renderCmd.cleanup()},getSprite:function(){return this.sprite},setSprite:function(a){this.sprite=a},setVirtualViewport:function(a,b,c){this._renderCmd.setVirtualViewport(a,b,c)},initWithWidthAndHeight:function(a,b,c,d){return this._renderCmd.initWithWidthAndHeight(a,b,c,d)},begin:function(){cc.renderer._turnToCacheMode(this.__instanceId);
this._renderCmd.begin()},beginWithClear:function(a,b,c,d,e,f){var g=cc._renderContext;e=e||g.COLOR_BUFFER_BIT;f=f||g.COLOR_BUFFER_BIT|g.DEPTH_BUFFER_BIT;this._beginWithClear(a,b,c,d,e,f,g.COLOR_BUFFER_BIT|g.DEPTH_BUFFER_BIT|g.STENCIL_BUFFER_BIT)},_beginWithClear:function(a,b,c,d,e,f,g){this.begin();this._renderCmd._beginWithClear(a,b,c,d,e,f,g)},end:function(){this._renderCmd.end()},clear:function(a,b,c,d){this.beginWithClear(a,b,c,d);this.end()},clearRect:function(a,b,c,d){this._renderCmd.clearRect(a,
b,c,d)},clearDepth:function(a){this._renderCmd.clearDepth(a)},clearStencil:function(a){this._renderCmd.clearStencil(a)},getClearFlags:function(){return this.clearFlags},setClearFlags:function(a){this.clearFlags=a},getClearColor:function(){return this._clearColor},setClearColor:function(a){var b=this._clearColor;b.r=a.r;b.g=a.g;b.b=a.b;b.a=a.a;this._renderCmd.updateClearColor(a)},getClearDepth:function(){return this.clearDepthVal},setClearDepth:function(a){this.clearDepthVal=a},getClearStencil:function(){return this.clearStencilVal},
setClearStencil:function(a){this.clearStencilVal=a},isAutoDraw:function(){return this.autoDraw},setAutoDraw:function(a){this.autoDraw=a},saveToFile:function(a,b){cc.log("saveToFile isn't supported on Cocos2d-Html5")},newCCImage:function(a){return cc.log("saveToFile isn't supported on cocos2d-html5"),null},listenToBackground:function(a){},listenToForeground:function(a){}});_p=cc.RenderTexture.prototype;_p.clearColorVal;cc.defineGetterSetter(_p,"clearColorVal",_p.getClearColor,_p.setClearColor);
cc.RenderTexture.create=function(a,b,c,d){return new cc.RenderTexture(a,b,c,d)};
(function(){cc.RenderTexture.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._needDraw=!0;this._clearColorStr="rgba(255,255,255,1)";this._cacheCanvas=cc.newElement("canvas");this._cacheContext=new cc.CanvasContextWrapper(this._cacheCanvas.getContext("2d"))};var a=cc.RenderTexture.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.RenderTexture.CanvasRenderCmd;a.cleanup=function(){this._cacheCanvas=this._cacheContext=null};a.clearStencil=
function(a){};a.setVirtualViewport=function(a,c,d){};a.updateClearColor=function(a){this._clearColorStr="rgba("+(0|a.r)+","+(0|a.g)+","+(0|a.b)+","+a.a/255+")"};a.initWithWidthAndHeight=function(a,c,d,e){d=this._node;e=this._cacheCanvas;var f=cc.contentScaleFactor();e.width=0|a*f;e.height=0|c*f;a=new cc.Texture2D;a.initWithElement(e);a.handleLoadedTexture();a=d.sprite=new cc.Sprite(a);return a.setBlendFunc(cc.ONE,cc.ONE_MINUS_SRC_ALPHA),d.autoDraw=!1,d.addChild(a),!0};a.begin=function(){};a._beginWithClear=
function(a,c,d,e,f,g,h){a=a||0;c=c||0;d=d||0;e=isNaN(e)?255:e;f=this._cacheContext.getContext();g=this._cacheCanvas;f.setTransform(1,0,0,1,0,0);this._cacheContext.setFillStyle("rgba("+(0|a)+","+(0|c)+","+(0|d)+","+e/255+")");f.clearRect(0,0,g.width,g.height);f.fillRect(0,0,g.width,g.height)};a.end=function(){var a=this._node,c=cc.contentScaleFactor();cc.renderer._renderingToCacheCanvas(this._cacheContext,a.__instanceId,c,c)};a.clearRect=function(a,c,d,e){this._cacheContext.clearRect(a,c,d,-e)};a.clearDepth=
function(a){cc.log("clearDepth isn't supported on Cocos2d-Html5")};a.visit=function(a){var c=this._node;this._syncStatus(a);c.sprite.visit(this);this._dirtyFlag=0}})();
!function(){cc.RenderTexture.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._needDraw=!0;this._depthRenderBuffer=this._textureCopy=this._oldFBO=this._fBO=null;this._rtTextureRect=new cc.Rect;this._fullRect=new cc.Rect;this._fullViewport=new cc.Rect};var a=cc.RenderTexture.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.RenderTexture.WebGLRenderCmd;a.setVirtualViewport=function(a,c,d){this._rtTextureRect.x=a.x;this._rtTextureRect.y=a.y;
this._fullRect=c;this._fullViewport=d};a.rendering=function(a){var c=a||cc._renderContext;a=this._node;if(a.autoDraw){a.begin();var d=a.clearFlags;if(d){var e=[0,0,0,0],f=0,g=0;d&c.COLOR_BUFFER_BIT&&(e=c.getParameter(c.COLOR_CLEAR_VALUE),c.clearColor(a._clearColor.r/255,a._clearColor.g/255,a._clearColor.b/255,a._clearColor.a/255));d&c.DEPTH_BUFFER_BIT&&(f=c.getParameter(c.DEPTH_CLEAR_VALUE),c.clearDepth(a.clearDepthVal));d&c.STENCIL_BUFFER_BIT&&(g=c.getParameter(c.STENCIL_CLEAR_VALUE),c.clearStencil(a.clearStencilVal));
c.clear(d);d&c.COLOR_BUFFER_BIT&&c.clearColor(e[0],e[1],e[2],e[3]);d&c.DEPTH_BUFFER_BIT&&c.clearDepth(f);d&c.STENCIL_BUFFER_BIT&&c.clearStencil(g)}a.sortAllChildren();c=a._children;for(d=0;d<c.length;d++)e=c[d],e!==a.sprite&&e._renderCmd.visit(a.sprite._renderCmd);a.end()}};a.clearStencil=function(a){var c=cc._renderContext,d=c.getParameter(c.STENCIL_CLEAR_VALUE);c.clearStencil(a);c.clear(c.STENCIL_BUFFER_BIT);c.clearStencil(d)};a.cleanup=function(){this._node;this._textureCopy=null;var a=cc._renderContext;
a.deleteFramebuffer(this._fBO);this._depthRenderBuffer&&a.deleteRenderbuffer(this._depthRenderBuffer)};a.updateClearColor=function(a){};a.initWithWidthAndHeight=function(a,c,d,e){var f=this._node;d===cc.Texture2D.PIXEL_FORMAT_A8&&cc.log("cc.RenderTexture._initWithWidthAndHeightForWebGL() : only RGB and RGBA formats are valid for a render texture;");var g=cc._renderContext,h=cc.contentScaleFactor();this._fullRect=new cc.Rect(0,0,a,c);this._fullViewport=new cc.Rect(0,0,a,c);a=0|a*h;c=0|c*h;this._oldFBO=
g.getParameter(g.FRAMEBUFFER_BINDING);var k,m;cc.configuration.supportsNPOT()?(k=a,m=c):(k=cc.NextPOT(a),m=cc.NextPOT(c));for(var h=new Uint8Array(4*k*m),n=0;4*k*m>n;n++)h[n]=0;this._pixelFormat=d;n=f._texture=new cc.Texture2D;if(!f._texture)return!1;n.initWithData(h,f._pixelFormat,k,m,cc.size(a,c));d=g.getParameter(g.RENDERBUFFER_BINDING);if(cc.configuration.checkForGLExtension("GL_QCOM")){if(this._textureCopy=new cc.Texture2D,!this._textureCopy)return!1;this._textureCopy.initWithData(h,f._pixelFormat,
k,m,cc.size(a,c))}this._fBO=g.createFramebuffer();g.bindFramebuffer(g.FRAMEBUFFER,this._fBO);g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,g.TEXTURE_2D,n._webTextureObj,0);0!==e&&(this._depthRenderBuffer=g.createRenderbuffer(),g.bindRenderbuffer(g.RENDERBUFFER,this._depthRenderBuffer),g.renderbufferStorage(g.RENDERBUFFER,e,k,m),e===g.DEPTH_STENCIL?g.framebufferRenderbuffer(g.FRAMEBUFFER,g.DEPTH_STENCIL_ATTACHMENT,g.RENDERBUFFER,this._depthRenderBuffer):e===g.STENCIL_INDEX||e===g.STENCIL_INDEX8?
g.framebufferRenderbuffer(g.FRAMEBUFFER,g.STENCIL_ATTACHMENT,g.RENDERBUFFER,this._depthRenderBuffer):e===g.DEPTH_COMPONENT16&&g.framebufferRenderbuffer(g.FRAMEBUFFER,g.DEPTH_ATTACHMENT,g.RENDERBUFFER,this._depthRenderBuffer));g.checkFramebufferStatus(g.FRAMEBUFFER)!==g.FRAMEBUFFER_COMPLETE&&cc.log("Could not attach texture to the framebuffer");n.setAliasTexParameters();a=f.sprite=new cc.Sprite(n);return a.scaleY=-1,a.setBlendFunc(g.ONE,g.ONE_MINUS_SRC_ALPHA),g.bindRenderbuffer(g.RENDERBUFFER,d),g.bindFramebuffer(g.FRAMEBUFFER,
this._oldFBO),f.autoDraw=!1,f.addChild(a),!0};a.begin=function(){var a=this._node;cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);cc.kmGLPushMatrix();cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);cc.kmGLPushMatrix();var c=cc._renderContext,d=cc.director;d.setProjection(d.getProjection());var e=a._texture.getContentSizeInPixels(),f=cc.director.getWinSizeInPixels(),d=f.width/e.width,e=f.height/e.height,d=cc.math.Matrix4.createOrthographicProjection(-1/d,1/d,-1/e,1/e,-1,1);cc.kmGLMultMatrix(d);d=new cc.Rect(0,0,0,0);
d.width=this._fullViewport.width;d.height=this._fullViewport.height;e=d.height/this._fullRect.height;d.x=(this._fullRect.x-this._rtTextureRect.x)*(d.width/this._fullRect.width);d.y=(this._fullRect.y-this._rtTextureRect.y)*e;c.viewport(d.x,d.y,d.width,d.height);this._oldFBO=c.getParameter(c.FRAMEBUFFER_BINDING);c.bindFramebuffer(c.FRAMEBUFFER,this._fBO);cc.configuration.checkForGLExtension("GL_QCOM")&&(c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,this._textureCopy._webTextureObj,
0),c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT),c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,a._texture._webTextureObj,0))};a._beginWithClear=function(a,c,d,e,f,g,h){a/=255;c/=255;d/=255;e/=255;var k=cc._renderContext,m=[0,0,0,0],n=0,p=0;h&k.COLOR_BUFFER_BIT&&(m=k.getParameter(k.COLOR_CLEAR_VALUE),k.clearColor(a,c,d,e));h&k.DEPTH_BUFFER_BIT&&(n=k.getParameter(k.DEPTH_CLEAR_VALUE),k.clearDepth(f));h&k.STENCIL_BUFFER_BIT&&(p=k.getParameter(k.STENCIL_CLEAR_VALUE),k.clearStencil(g));
k.clear(h);h&k.COLOR_BUFFER_BIT&&k.clearColor(m[0],m[1],m[2],m[3]);h&k.DEPTH_BUFFER_BIT&&k.clearDepth(n);h&k.STENCIL_BUFFER_BIT&&k.clearStencil(p)};a.end=function(){cc.renderer._renderingToBuffer(this._node.__instanceId);var a=cc._renderContext,c=cc.director;a.bindFramebuffer(a.FRAMEBUFFER,this._oldFBO);c.setViewport();cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);cc.kmGLPopMatrix();cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);cc.kmGLPopMatrix()};a.clearRect=function(a,c,d,e){};a.clearDepth=function(a){var c=this._node;
c.begin();var d=cc._renderContext,e=d.getParameter(d.DEPTH_CLEAR_VALUE);d.clearDepth(a);d.clear(d.DEPTH_BUFFER_BIT);d.clearDepth(e);c.end()};a.visit=function(a){var c=this._node;c._visible&&(cc.kmGLPushMatrix(),this._syncStatus(a),cc.renderer.pushRenderCommand(this),c.sprite.visit(this),this._dirtyFlag=0,cc.kmGLPopMatrix())}}();
cc.SpriteBatchNode=cc.Node.extend({_blendFunc:null,_descendants:null,_className:"SpriteBatchNode",ctor:function(a,b){cc.Node.prototype.ctor.call(this);this._descendants=[];this._blendFunc=new cc.BlendFunc(cc.BLEND_SRC,cc.BLEND_DST);var c;b=b||cc.SpriteBatchNode.DEFAULT_CAPACITY;cc.isString(a)?(c=cc.textureCache.getTextureForKey(a),c||(c=cc.textureCache.addImage(a))):a instanceof cc.Texture2D&&(c=a);c&&this.initWithTexture(c,b)},addSpriteWithoutQuad:function(a,b,c){if(cc.assert(a,cc._LogInfos.SpriteBatchNode_addSpriteWithoutQuad_2),
!(a instanceof cc.Sprite))return cc.log(cc._LogInfos.SpriteBatchNode_addSpriteWithoutQuad),null;a.atlasIndex=b;var d,e=0,f=this._descendants;if(f&&0<f.length){e=0;for(d=f.length;d>e;e++){var g=f[e];if(g&&g.atlasIndex>=b)break}}return f.splice(e,0,a),cc.Node.prototype.addChild.call(this,a,b,c),this.reorderBatch(!1),this},getTextureAtlas:function(){return this._renderCmd.getTextureAtlas()},setTextureAtlas:function(a){this._renderCmd.getTextureAtlas(a)},getDescendants:function(){return this._descendants},
initWithFile:function(a,b){var c=cc.textureCache.getTextureForKey(a);return c||(c=cc.textureCache.addImage(a)),this.initWithTexture(c,b)},_setNodeDirtyForCache:function(){this._renderCmd&&this._renderCmd._setNodeDirtyForCache&&this._renderCmd._setNodeDirtyForCache()},init:function(a,b){var c=cc.textureCache.getTextureForKey(a);return c||(c=cc.textureCache.addImage(a)),this.initWithTexture(c,b)},increaseAtlasCapacity:function(){this._renderCmd.increaseAtlasCapacity()},removeChildAtIndex:function(a,
b){this.removeChild(this._children[a],b)},rebuildIndexInOrder:function(a,b){var c=a.children;if(c&&0<c.length)for(var d=0;d<c.length;d++){var e=c[d];e&&0>e.zIndex&&(b=this.rebuildIndexInOrder(e,b))}if(!a===this&&(a.atlasIndex=b,b++),c&&0<c.length)for(d=0;d<c.length;d++)(e=c[d])&&0<=e.zIndex&&(b=this.rebuildIndexInOrder(e,b));return b},highestAtlasIndexInChild:function(a){var b=a.children;return b&&0!==b.length?this.highestAtlasIndexInChild(b[b.length-1]):a.atlasIndex},lowestAtlasIndexInChild:function(a){var b=
a.children;return b&&0!==b.length?this.lowestAtlasIndexInChild(b[b.length-1]):a.atlasIndex},atlasIndexForChild:function(a,b){var c=a.parent,d=c.children,e=d.indexOf(a),f=null;return 0<e&&e<cc.UINT_MAX&&(f=d[e-1]),c===this?0===e?0:this.highestAtlasIndexInChild(f)+1:0===e?0>b?c.atlasIndex:c.atlasIndex+1:0>f.zIndex&&0>b||0<=f.zIndex&&0<=b?this.highestAtlasIndexInChild(f)+1:c.atlasIndex+1},reorderBatch:function(a){this._reorderChildDirty=a},setBlendFunc:function(a,b){void 0===b?this._blendFunc=a:this._blendFunc=
{src:a,dst:b}},getBlendFunc:function(){return new cc.BlendFunc(this._blendFunc.src,this._blendFunc.dst)},reorderChild:function(a,b){return cc.assert(a,cc._LogInfos.SpriteBatchNode_reorderChild_2),-1===this._children.indexOf(a)?void cc.log(cc._LogInfos.SpriteBatchNode_reorderChild):void(b!==a.zIndex&&cc.Node.prototype.reorderChild.call(this,a,b))},removeChild:function(a,b){if(null!=a){if(-1===this._children.indexOf(a))return void cc.log(cc._LogInfos.SpriteBatchNode_removeChild);this.removeSpriteFromAtlas(a);
cc.Node.prototype.removeChild.call(this,a,b)}},updateQuadFromSprite:function(a,b){return cc.assert(a,cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite_2),a instanceof cc.Sprite?(this._renderCmd.checkAtlasCapacity(),a.batchNode=this,a.atlasIndex=b,a.dirty=!0,void a.updateTransform()):void cc.log(cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite)},insertQuadFromSprite:function(a,b){return cc.assert(a,cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite_2),a instanceof cc.Sprite?(this._renderCmd.insertQuad(a,
b),a.batchNode=this,a.atlasIndex=b,a.dirty=!0,a.updateTransform(),void this._renderCmd.cutting(a,b)):void cc.log(cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite)},initWithTexture:function(a,b){return this._children.length=0,this._descendants.length=0,b=b||cc.SpriteBatchNode.DEFAULT_CAPACITY,this._renderCmd.initWithTexture(a,b),!0},insertChild:function(a,b){a.batchNode=this;a.atlasIndex=b;a.dirty=!0;this._renderCmd.insertQuad(a,b);this._descendants.splice(b,0,a);var c=b+1,d=this._descendants;if(d&&
0<d.length)for(;c<d.length;c++)d[c].atlasIndex++;var e,f=a.children;if(f){c=0;for(e=f.length||0;e>c;c++)if(d=f[c]){var g=this.atlasIndexForChild(d,d.zIndex);this.insertChild(d,g)}}},appendChild:function(a){this._reorderChildDirty=!0;a.batchNode=this;a.dirty=!0;this._descendants.push(a);var b=this._descendants.length-1;a.atlasIndex=b;this._renderCmd.insertQuad(a,b);a=a.children;for(var b=0,c=a.length||0;c>b;b++)this.appendChild(a[b])},removeSpriteFromAtlas:function(a){this._renderCmd.removeQuadAtIndex(a.atlasIndex);
a.batchNode=null;var b=this._descendants,c=b.indexOf(a);if(-1!==c){b.splice(c,1);for(var d=b.length;d>c;++c)b[c].atlasIndex--}if(a=a.children){b=0;for(c=a.length||0;c>b;b++)a[b]&&this.removeSpriteFromAtlas(a[b])}},getTexture:function(){return this._renderCmd.getTexture()},setTexture:function(a){this._renderCmd.setTexture(a)},addChild:function(a,b,c){cc.assert(null!=a,cc._LogInfos.CCSpriteBatchNode_addChild_3);this._renderCmd.isValidChild(a)&&(b=null==b?a.zIndex:b,c=null==c?a.tag:c,cc.Node.prototype.addChild.call(this,
a,b,c),this.appendChild(a))},removeAllChildren:function(a){var b=this._descendants;if(b&&0<b.length)for(var c=0,d=b.length;d>c;c++)b[c]&&(b[c].batchNode=null);cc.Node.prototype.removeAllChildren.call(this,a);this._descendants.length=0;this._renderCmd.removeAllQuads()},sortAllChildren:function(){if(this._reorderChildDirty){var a,b,c=this._children,d=0,e=c.length;for(a=1;e>a;a++){var f=c[a],d=a-1;for(b=c[d];0<=d&&(f._localZOrder<b._localZOrder||f._localZOrder===b._localZOrder&&f.arrivalOrder<b.arrivalOrder);)c[d+
1]=b,d-=1,b=c[d];c[d+1]=f}0<c.length&&(this._arrayMakeObjectsPerformSelector(c,cc.Node._stateCallbackType.sortAllChildren),this._renderCmd.updateChildrenAtlasIndex(c));this._reorderChildDirty=!1}},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.SpriteBatchNode.CanvasRenderCmd(this):new cc.SpriteBatchNode.WebGLRenderCmd(this)}});_p=cc.SpriteBatchNode.prototype;cc.defineGetterSetter(_p,"texture",_p.getTexture,_p.setTexture);
cc.defineGetterSetter(_p,"textureAtlas",_p.getTextureAtlas,_p.setTextureAtlas);_p.descendants;cc.defineGetterSetter(_p,"descendants",_p.getDescendants);cc.SpriteBatchNode.DEFAULT_CAPACITY=29;cc.SpriteBatchNode.create=function(a,b){return new cc.SpriteBatchNode(a,b)};cc.SpriteBatchNode.createWithTexture=cc.SpriteBatchNode.create;
(function(){cc.SpriteBatchNode.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._originalTexture=this._texture=null};var a=cc.SpriteBatchNode.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.SpriteBatchNode.CanvasRenderCmd;a.checkAtlasCapacity=function(){};a.isValidChild=function(a){return a instanceof cc.Sprite?!0:(cc.log(cc._LogInfos.Sprite_addChild_4),!1)};a.initWithTexture=function(a,c){this._texture=this._originalTexture=a};a.insertQuad=
function(a,c){};a.increaseAtlasCapacity=function(){};a.removeQuadAtIndex=function(){};a.removeAllQuads=function(){};a.getTexture=function(){return this._texture};a.setTexture=function(a){this._texture=a;for(var c=this._node._children,d=0;d<c.length;d++)c[d].setTexture(a)};a.updateChildrenAtlasIndex=function(a){for(var c=this._node._descendants.length=0,d=a.length;d>c;c++)this._updateAtlasIndex(a[c])};a._updateAtlasIndex=function(a){var c,d=this._node._descendants,e=a.children,f=e.length;for(c=0;f>
c&&0>e[c]._localZOrder;c++)d.push(e[c]);for(d.push(a);f>c;c++)d.push(e[c])};a.getTextureAtlas=function(){};a.setTextureAtlas=function(a){};a.cutting=function(a,c){this._node._children.splice(c,0,a)}})();
!function(){cc.SpriteBatchNode.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._needDraw=!0;this._textureAtlas=null};var a=cc.SpriteBatchNode.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.SpriteBatchNode.WebGLRenderCmd;a.isValidChild=function(a){return a instanceof cc.Sprite?a.texture!=this.getTexture()?(cc.log(cc._LogInfos.Sprite_addChild_5),!1):!0:(cc.log(cc._LogInfos.Sprite_addChild_4),!1)};a.rendering=function(){var a=this._node;
0!==this._textureAtlas.totalQuads&&(this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),a._arrayMakeObjectsPerformSelector(a._children,cc.Node._stateCallbackType.updateTransform),cc.glBlendFunc(a._blendFunc.src,a._blendFunc.dst),this._textureAtlas.drawQuads())};a.visit=function(a){var c=this._node;if(c._visible){c._parent&&c._parent._renderCmd&&(this._curLevel=c._parent._renderCmd._curLevel+1);var d=cc.current_stack;d.stack.push(d.top);this._dirtyFlag&
cc.Node._dirtyFlags.transformDirty||this.transform(a);this.updateStatus(a);d.top=this._stackMatrix;c.sortAllChildren();cc.renderer.pushRenderCommand(this);this._dirtyFlag=0;d.top=d.stack.pop()}};a.checkAtlasCapacity=function(a){for(var c=this._textureAtlas;a>=c.capacity||c.capacity===c.totalQuads;)this.increaseAtlasCapacity()};a.increaseAtlasCapacity=function(){var a=this._textureAtlas.capacity,c=Math.floor(4*(a+1)/3);cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity,a,c);this._textureAtlas.resizeCapacity(c)||
cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity_2)};a.initWithTexture=function(a,c){this._textureAtlas=new cc.TextureAtlas;this._textureAtlas.initWithTexture(a,c);this._updateBlendFunc();this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)};a.insertQuad=function(a,c){var d=this._textureAtlas;d.totalQuads>=d.capacity&&this.increaseAtlasCapacity();d.insertQuad(a.quad,c)};a.removeQuadAtIndex=function(a){this._textureAtlas.removeQuadAtIndex(a)};a.getTexture=function(){return this._textureAtlas.texture};
a.setTexture=function(a){this._textureAtlas.setTexture(a);a&&this._updateBlendFunc()};a.removeAllQuads=function(){this._textureAtlas.removeAllQuads()};a._swap=function(a,c){var d=this._node._descendants,e=this._textureAtlas,f=e.quads,g=d[a],h=cc.V3F_C4B_T2F_QuadCopy(f[a]);d[c].atlasIndex=a;d[a]=d[c];e.updateQuad(f[c],a);d[c]=g;e.updateQuad(h,c)};a._updateAtlasIndex=function(a,c){var d=0,e=a.children;e&&(d=e.length);var f=0;if(0===d)f=a.atlasIndex,a.atlasIndex=c,a.arrivalOrder=0,f!==c&&this._swap(f,
c),c++;else{d=!0;0<=e[0].zIndex&&(f=a.atlasIndex,a.atlasIndex=c,a.arrivalOrder=0,f!==c&&this._swap(f,c),c++,d=!1);for(var g=0;g<e.length;g++){var h=e[g];d&&0<=h.zIndex&&(f=a.atlasIndex,a.atlasIndex=c,a.arrivalOrder=0,f!==c&&this._swap(f,c),c++,d=!1);c=this._updateAtlasIndex(h,c)}d&&(f=a.atlasIndex,a.atlasIndex=c,a.arrivalOrder=0,f!==c&&this._swap(f,c),c++)}return c};a.updateChildrenAtlasIndex=function(a){for(var c=0,d=0;d<a.length;d++)c=this._updateAtlasIndex(a[d],c)};a._updateBlendFunc=function(){if(!this._textureAtlas.texture.hasPremultipliedAlpha()){var a=
this._node._blendFunc;a.src=cc.SRC_ALPHA;a.dst=cc.ONE_MINUS_SRC_ALPHA}};a.getTextureAtlas=function(){return this._textureAtlas};a.setTextureAtlas=function(a){a!==this._textureAtlas&&(this._textureAtlas=a)};a.cutting=function(){}}();
cc.LabelAtlas=cc.AtlasNode.extend({_string:null,_mapStartChar:null,_textureLoaded:!1,_className:"LabelAtlas",ctor:function(a,b,c,d,e){cc.AtlasNode.prototype.ctor.call(this);this._renderCmd.setCascade();b&&cc.LabelAtlas.prototype.initWithString.call(this,a,b,c,d,e)},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_WEBGL?new cc.LabelAtlas.WebGLRenderCmd(this):new cc.LabelAtlas.CanvasRenderCmd(this)},textureLoaded:function(){return this._textureLoaded},addLoadedEventListener:function(a,
b){this.addEventListener("load",a,b)},initWithString:function(a,b,c,d,e){var f,g,h=a+"";if(void 0===c){c=cc.loader.getRes(b);if(1!==parseInt(c.version,10))return cc.log("cc.LabelAtlas.initWithString(): Unsupported version. Upgrade cocos2d version"),!1;b=cc.path.changeBasename(b,c.textureFilename);d=cc.contentScaleFactor();f=parseInt(c.itemWidth,10)/d;g=parseInt(c.itemHeight,10)/d;c=String.fromCharCode(parseInt(c.firstChar,10))}else f=c||0,g=d||0,c=e||" ";var k=null,k=b instanceof cc.Texture2D?b:cc.textureCache.addImage(b);
b=k.isLoaded();return this._textureLoaded=b,b||(this._string=h,k.addEventListener("load",function(a){this.initWithTexture(k,f,g,h.length);this.string=this._string;this.setColor(this._renderCmd._displayedColor);this.dispatchEvent("load")},this)),this.initWithTexture(k,f,g,h.length)?(this._mapStartChar=c,this.string=h,!0):!1},setColor:function(a){cc.AtlasNode.prototype.setColor.call(this,a);this._renderCmd.updateAtlasValues()},getString:function(){return this._string},addChild:function(a,b,c){this._renderCmd._addChild(a);
cc.Node.prototype.addChild.call(this,a,b,c)},updateAtlasValues:function(){this._renderCmd.updateAtlasValues()},setString:function(a){a=String(a);var b=a.length;this._string=a;this.setContentSize(b*this._itemWidth,this._itemHeight);this._renderCmd.setString(a);this._renderCmd.updateAtlasValues();this.quadsToDraw=b}});
(function(){var a=cc.LabelAtlas.prototype;cc.defineGetterSetter(a,"opacity",a.getOpacity,a.setOpacity);cc.defineGetterSetter(a,"color",a.getColor,a.setColor);a.string;cc.defineGetterSetter(a,"string",a.getString,a.setString)})();cc.LabelAtlas.create=function(a,b,c,d,e){return new cc.LabelAtlas(a,b,c,d,e)};
(function(){cc.LabelAtlas.CanvasRenderCmd=function(a){cc.AtlasNode.CanvasRenderCmd.call(this,a);this._needDraw=!1};var a=cc.LabelAtlas.CanvasRenderCmd.prototype=Object.create(cc.AtlasNode.CanvasRenderCmd.prototype);a.constructor=cc.LabelAtlas.CanvasRenderCmd;a.setCascade=function(){var a=this._node;a._cascadeOpacityEnabled=!0;a._cascadeColorEnabled=!1};a.updateAtlasValues=function(){for(var a=this._node,c=a._string||"",d=c.length,e=this._texture,f=a._itemWidth,g=a._itemHeight,h=0;d>h;h++){var k=c.charCodeAt(h)-
a._mapStartChar.charCodeAt(0),m=parseInt(k%a._itemsPerRow,10),k=parseInt(k/a._itemsPerRow,10),m=cc.rect(m*f,k*g,f,g),k=c.charCodeAt(h),n=a.getChildByTag(h);n?32===k?(n.init(),n.setTextureRect(cc.rect(0,0,10,10),!1,cc.size(0,0))):(n.initWithTexture(e,m),n.visible=!0):(n=new cc.Sprite,32===k?(n.init(),n.setTextureRect(cc.rect(0,0,10,10),!1,cc.size(0,0))):n.initWithTexture(e,m),cc.Node.prototype.addChild.call(a,n,0,h));n.setPosition(h*f+f/2,g/2)}};a.setString=function(a){a=this._node;if(a._children){a=
a._children;for(var c=a.length,d=0;c>d;d++){var e=a[d];e&&!e._lateChild&&(e.visible=!1)}}};a._addChild=function(){child._lateChild=!0}})();cc.LABEL_AUTOMATIC_WIDTH=-1;
cc.LabelBMFont=cc.SpriteBatchNode.extend({_opacityModifyRGB:!1,_string:"",_config:null,_fntFile:"",_initialString:"",_alignment:cc.TEXT_ALIGNMENT_CENTER,_width:-1,_lineBreakWithoutSpaces:!1,_imageOffset:null,_reusedChar:null,_textureLoaded:!1,_className:"LabelBMFont",_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_WEBGL?new cc.LabelBMFont.WebGLRenderCmd(this):new cc.LabelBMFont.CanvasRenderCmd(this)},_setString:function(a,b){b?this._initialString=a:this._string=a;var c=this._children;
if(c)for(var d=0;d<c.length;d++){var e=c[d];e&&e.setVisible(!1)}this._textureLoaded&&(this.createFontChars(),b&&this.updateLabel())},ctor:function(a,b,c,d,e){cc.SpriteBatchNode.prototype.ctor.call(this);this._imageOffset=cc.p(0,0);this._reusedChar=[];this._cascadeOpacityEnabled=this._cascadeColorEnabled=!0;this.initWithString(a,b,c,d,e)},textureLoaded:function(){return this._textureLoaded},addLoadedEventListener:function(a,b){this.addEventListener("load",a,b)},isOpacityModifyRGB:function(){return this._opacityModifyRGB},
setOpacityModifyRGB:function(a){this._opacityModifyRGB=a;if(a=this._children)for(var b=0;b<a.length;b++){var c=a[b];c&&(c.opacityModifyRGB=this._opacityModifyRGB)}},_changeTextureColor:function(){this._renderCmd._changeTextureColor()},init:function(){return this.initWithString(null,null,null,null,null)},initWithString:function(a,b,c,d,e){a=a||"";this._renderCmd;this._config&&cc.log("cc.LabelBMFont.initWithString(): re-init is no longer supported");if(b){var f=cc.loader.getRes(b);if(!f)return cc.log("cc.LabelBMFont.initWithString(): Impossible to create font. Please check file"),
!1;this._config=f;this._fntFile=b;b=cc.textureCache.addImage(f.atlasName);(this._textureLoaded=f=b.isLoaded())||b.addEventListener("load",function(a){this._textureLoaded=!0;this.initWithTexture(a,this._initialString.length);this.setString(this._initialString,!0);this.dispatchEvent("load")},this)}else b=new cc.Texture2D,f=new Image,b.initWithElement(f),this._textureLoaded=!1;return this.initWithTexture(b,a.length)?(this._alignment=d||cc.TEXT_ALIGNMENT_LEFT,this._imageOffset=e||cc.p(0,0),this._width=
null==c?-1:c,this._realOpacity=255,this._realColor=cc.color(255,255,255,255),this._contentSize.width=0,this._contentSize.height=0,this.setAnchorPoint(0.5,0.5),this._renderCmd._initBatchTexture(),this.setString(a,!0),!0):!1},createFontChars:function(){var a=this._renderCmd._texture||this.textureAtlas.texture,b=0,c=cc.size(0,0),d=0,e=1,f=this._string,g=f?f.length:0;if(0!==g){var h,k=this._config,m=k.kerningDict,n=k.commonHeight,p=k.fontDefDictionary;for(h=0;g-1>h;h++)10===f.charCodeAt(h)&&e++;var r=
n*e,e=-(n-n*e),s=-1;for(h=0;g>h;h++)if(n=f.charCodeAt(h),0!==n)if(10!==n){var v=m[s<<16|65535&n]||0,u=p[n];if(u){var t=cc.rect(u.rect.x,u.rect.y,u.rect.width,u.rect.height),t=cc.rectPixelsToPoints(t);t.x+=this._imageOffset.x;t.y+=this._imageOffset.y;(s=this.getChildByTag(h))?this._renderCmd._updateCharTexture(s,t,n):(s=new cc.Sprite,s.initWithTexture(a,t,!1),s._newTextureWhenChangeColor=!0,this.addChild(s,0,h));s.opacityModifyRGB=this._opacityModifyRGB;this._renderCmd._updateCharColorAndOpacity(s);
t=cc.p(b+u.xOffset+0.5*u.rect.width+v,e+(k.commonHeight-u.yOffset)-0.5*t.height*cc.contentScaleFactor());s.setPosition(cc.pointPixelsToPoints(t));b+=u.xAdvance+v;s=n;b>d&&(d=b)}else cc.log("cocos2d: LabelBMFont: character not found "+f[h])}else b=0,e-=k.commonHeight;u&&u.xAdvance<u.rect.width?c.width=d-u.xAdvance+u.rect.width:c.width=d;c.height=r;this.setContentSize(cc.sizePixelsToPoints(c))}},updateString:function(a){var b=this._children;if(b)for(var c=0,d=b.length;d>c;c++){var e=b[c];e&&(e.visible=
!1)}this._config&&this.createFontChars();a||this.updateLabel()},getString:function(){return this._initialString},setString:function(a,b){a=String(a);null==b&&(b=!0);null!=a&&cc.isString(a)||(a+="");this._initialString=a;this._setString(a,b)},_setStringForSetter:function(a){this.setString(a,!1)},setCString:function(a){this.setString(a,!0)},_getCharsWidth:function(a,b){if(0>=b)return 0;var c=this.getChildByTag(a),d=this.getChildByTag(a+b);return this._getLetterPosXLeft(d)-this._getLetterPosXLeft(c)},
_checkWarp:function(a,b,c,d){for(var e=a[b],f=0,g=0;b>g;g++)f+=a[g].length;var f=f+b-d,h=this._getCharsWidth(f,a[b].length-1);if(h>c&&1<e.length){var k;d=e.length*(c/h)|0;for(var g=e.substr(d),m=h-this._getCharsWidth(f+d,g.length-1),n=0,p=0;m>c&&100>p++;)d*=c/m,d|=0,g=e.substr(d),m=h-this._getCharsWidth(f+d,g.length-1);for(p=0;c>m&&100>p++;)g&&(n=(k=cc.LabelTTF._wordRex.exec(g))?k[0].length:1,k=g),this._lineBreakWithoutSpaces&&(n=0),d+=n,g=e.substr(d),m=h-this._getCharsWidth(f+d,g.length-1);d-=n;
0===d&&(d=1,k=k.substr(1));var r;c=e.substr(0,d);cc.LabelTTF.wrapInspection&&cc.LabelTTF._symbolRex.test(k||g)&&(r=cc.LabelTTF._lastWordRex.exec(c),n=r?r[0].length:0,this._lineBreakWithoutSpaces&&(n=0),d-=n,k=e.substr(d),c=e.substr(0,d));cc.LabelTTF._firsrEnglish.test(k)&&(r=cc.LabelTTF._lastEnglish.exec(c),r&&c!==r[0]&&(n=r[0].length,this._lineBreakWithoutSpaces&&(n=0),d-=n,k=e.substr(d),c=e.substr(0,d)));a[b]=k||g;a.splice(b,0,c)}},updateLabel:function(){this.string=this._initialString;var a,b,
c;if(0<this._width){var d=this.string.split("\n"),e="",f=0,g=0;for(a=0;a<d.length;a++)g=d.length,this._checkWarp(d,a,this._width*this._scaleX,f),g<d.length&&f++,0<a&&(e+="\n"),e+=d[a];e+=String.fromCharCode(0);this._setString(e,!1)}if(this._alignment!==cc.TEXT_ALIGNMENT_LEFT){d=a=0;e=this._string.length;f=[];for(g=0;e>g;g++)if(10!==this._string[g].charCodeAt(0)&&0!==this._string[g].charCodeAt(0))f.push(this._string[a]);else{b=0;var h=f.length;if(0===h)d++;else{var k=a+h-1+d;if(!(0>k)){var m=this.getChildByTag(k);
if(null!=m){b=m.getPositionX()+m._getWidth()/2;m=0;switch(this._alignment){case cc.TEXT_ALIGNMENT_CENTER:m=this.width/2-b/2;break;case cc.TEXT_ALIGNMENT_RIGHT:m=this.width-b}if(0!==m)for(b=0;h>b;b++)k=a+b+d,0>k||(c=this.getChildByTag(k),c&&(c.x+=m));a+=h;d++;f.length=0}}}}}},setAlignment:function(a){this._alignment=a;this.updateLabel()},_getAlignment:function(){return this._alignment},setBoundingWidth:function(a){this._width=a;this.updateLabel()},_getBoundingWidth:function(){return this._width},setLineBreakWithoutSpace:function(a){this._lineBreakWithoutSpaces=
a;this.updateLabel()},setScale:function(a,b){cc.Node.prototype.setScale.call(this,a,b);this.updateLabel()},setScaleX:function(a){cc.Node.prototype.setScaleX.call(this,a);this.updateLabel()},setScaleY:function(a){cc.Node.prototype.setScaleY.call(this,a);this.updateLabel()},setFntFile:function(a){if(null!=a&&a!==this._fntFile){var b=cc.loader.getRes(a);if(!b)return void cc.log("cc.LabelBMFont.setFntFile() : Impossible to create font. Please check file");this._fntFile=a;this._config=b;a=cc.textureCache.addImage(b.atlasName);
this._textureLoaded=b=a.isLoaded();this.texture=a;this._renderCmd._updateFntFileTexture();b?this.createFontChars():a.addEventListener("load",function(a){this._textureLoaded=!0;this.texture=a;this.createFontChars();this._changeTextureColor();this.updateLabel();this.dispatchEvent("load")},this)}},getFntFile:function(){return this._fntFile},setTexture:function(a){this._renderCmd.setTexture(a)},setAnchorPoint:function(a,b){cc.Node.prototype.setAnchorPoint.call(this,a,b);this.updateLabel()},_setAnchorX:function(a){cc.Node.prototype._setAnchorX.call(this,
a);this.updateLabel()},_setAnchorY:function(a){cc.Node.prototype._setAnchorY.call(this,a);this.updateLabel()},_atlasNameFromFntFile:function(a){},_kerningAmountForFirst:function(a,b){var c=0;if(this._configuration.kerningDictionary){var d=this._configuration.kerningDictionary[(a<<16|65535&b).toString()];d&&(c=d.amount)}return c},_getLetterPosXLeft:function(a){return a.getPositionX()*this._scaleX-a._getWidth()*this._scaleX*a._getAnchorX()},_getLetterPosXRight:function(a){return a.getPositionX()*this._scaleX+
a._getWidth()*this._scaleX*a._getAnchorX()},_isspace_unicode:function(a){return a=a.charCodeAt(0),9<=a&&13>=a||32===a||133===a||160===a||5760===a||8192<=a&&8202>=a||8232===a||8233===a||8239===a||8287===a||12288===a},_utf8_trim_ws:function(a){var b=a.length;if(!(0>=b)&&(b-=1,this._isspace_unicode(a[b]))){for(var c=b-1;0<=c&&this._isspace_unicode(a[c]);--c)b=c;this._utf8_trim_from(a,b)}},_utf8_trim_from:function(a,b){var c=a.length;b>=c||0>b||a.splice(b,c)}});
(function(){var a=cc.LabelBMFont.prototype;cc.EventHelper.prototype.apply(a);a.string;cc.defineGetterSetter(a,"string",a.getString,a._setStringForSetter);a.boundingWidth;cc.defineGetterSetter(a,"boundingWidth",a._getBoundingWidth,a.setBoundingWidth);a.textAlign;cc.defineGetterSetter(a,"textAlign",a._getAlignment,a.setAlignment)})();cc.LabelBMFont.create=function(a,b,c,d,e){return new cc.LabelBMFont(a,b,c,d,e)};
cc._fntLoader={INFO_EXP:/info [^\n]*(\n|$)/gi,COMMON_EXP:/common [^\n]*(\n|$)/gi,PAGE_EXP:/page [^\n]*(\n|$)/gi,CHAR_EXP:/char [^\n]*(\n|$)/gi,KERNING_EXP:/kerning [^\n]*(\n|$)/gi,ITEM_EXP:/\w+=[^ \r\n]+/gi,INT_EXP:/^[\-]?\d+$/,_parseStrToObj:function(a){a=a.match(this.ITEM_EXP);var b={};if(a)for(var c=0,d=a.length;d>c;c++){var e=a[c],f=e.indexOf("\x3d"),g=e.substring(0,f),e=e.substring(f+1);e.match(this.INT_EXP)?e=parseInt(e):'"'===e[0]&&(e=e.substring(1,e.length-1));b[g]=e}return b},parseFnt:function(a,
b){var c={},d=this._parseStrToObj(a.match(this.INFO_EXP)[0]).padding.split(","),d=(parseInt(d[0]),parseInt(d[1]),parseInt(d[2]),parseInt(d[3]),this._parseStrToObj(a.match(this.COMMON_EXP)[0]));if(c.commonHeight=d.lineHeight,cc._renderType===cc._RENDER_TYPE_WEBGL){var e=cc.configuration.getMaxTextureSize();(d.scaleW>e.width||d.scaleH>e.height)&&cc.log("cc.LabelBMFont._parseCommonArguments(): page can't be larger than supported")}1!==d.pages&&cc.log("cc.LabelBMFont._parseCommonArguments(): only supports 1 page");
d=this._parseStrToObj(a.match(this.PAGE_EXP)[0]);0!==d.id&&cc.log("cc.LabelBMFont._parseImageFileName() : file could not be found");c.atlasName=cc.path.changeBasename(b,d.file);for(var f=a.match(this.CHAR_EXP),g=c.fontDefDictionary={},d=0,e=f.length;e>d;d++){var h=this._parseStrToObj(f[d]);g[h.id]={rect:{x:h.x,y:h.y,width:h.width,height:h.height},xOffset:h.xoffset,yOffset:h.yoffset,xAdvance:h.xadvance}}f=c.kerningDict={};if(g=a.match(this.KERNING_EXP)){d=0;for(e=g.length;e>d;d++)h=this._parseStrToObj(g[d]),
f[h.first<<16|65535&h.second]=h.amount}return c},load:function(a,b,c,d){var e=this;cc.loader.loadTxt(a,function(a,c){return a?d(a):void d(null,e.parseFnt(c,b))})}};cc.loader.register(["fnt"],cc._fntLoader);
(function(){cc.LabelBMFont.CanvasRenderCmd=function(a){cc.SpriteBatchNode.CanvasRenderCmd.call(this,a);this._needDraw=!0};var a=cc.LabelBMFont.CanvasRenderCmd.prototype=Object.create(cc.SpriteBatchNode.CanvasRenderCmd.prototype);a.constructor=cc.LabelBMFont.CanvasRenderCmd;a.rendering=function(){};a._updateCharTexture=function(a,c,d){32===d?a.setTextureRect(c,!1,cc.size(0,0)):(a.setTextureRect(c,!1),a.visible=!0)};a._updateCharColorAndOpacity=function(a){a._displayedColor=this._displayedColor;a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty);
a._displayedOpacity=this._displayedOpacity;a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)};a._updateFntFileTexture=function(){var a=this._node;a._originalTexture=a.texture};a.setTexture=function(a){for(var c=this._node._children,d=this._displayedColor,e=0;e<c.length;e++){var f=c[e],g=f._renderCmd,h=g._displayedColor;(this._texture===g._texture||h.r===d.r&&h.g===d.g&&h.b===d.b)&&(f.texture=a)}this._texture=a};cc.sys._supportCanvasNewBlendModes?a._changeTextureColor=function(){var a=this._node,
c=a.getTexture();if(c&&0<c.getContentSize().width){var d=this._originalTexture.getHtmlElementObj();if(d){var e=c.getHtmlElementObj(),f=cc.rect(0,0,d.width,d.height);e instanceof HTMLCanvasElement&&!a._rectRotated?(cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(d,this._displayedColor,f,e),a.setTexture(c)):(e=cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(d,this._displayedColor,f),c=new cc.Texture2D,c.initWithElement(e),c.handleLoadedTexture(),a.setTexture(c))}}}:a._changeTextureColor=
function(){var a,c=this._node,d=c.getTexture();if(d&&0<d.getContentSize().width&&!(a=d.getHtmlElementObj(),!a)){var e=cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj());e&&(a instanceof HTMLCanvasElement&&!this._rectRotated?(cc.Sprite.CanvasRenderCmd._generateTintImage(a,e,this._displayedColor,null,a),this.setTexture(d)):(a=cc.Sprite.CanvasRenderCmd._generateTintImage(a,e,this._displayedColor),d=new cc.Texture2D,d.initWithElement(a),d.handleLoadedTexture(),c.setTexture(d)))}};
a._updateChildrenDisplayedOpacity=function(a){cc.Node.prototype.updateDisplayedOpacity.call(a,this._displayedOpacity)};a._updateChildrenDisplayedColor=function(a){cc.Node.prototype.updateDisplayedColor.call(a,this._displayedColor)};a._initBatchTexture=function(){}})();
!function(){cc.LabelAtlas.WebGLRenderCmd=function(a){cc.AtlasNode.WebGLRenderCmd.call(this,a);this._needDraw=!0};var a=cc.LabelAtlas.WebGLRenderCmd.prototype=Object.create(cc.AtlasNode.WebGLRenderCmd.prototype);a.constructor=cc.LabelAtlas.WebGLRenderCmd;a.setCascade=function(){var a=this._node;a._cascadeOpacityEnabled=!0;a._cascadeColorEnabled=!0};a.rendering=function(a){if(cc.AtlasNode.WebGLRenderCmd.prototype.rendering.call(this,a),cc.LABELATLAS_DEBUG_DRAW)a=this._node.getContentSize(),a=[cc.p(0,
0),cc.p(a.width,0),cc.p(a.width,a.height),cc.p(0,a.height)],cc._drawingUtil.drawPoly(a,4,!0)};a.updateAtlasValues=function(){var a=this._node,c=a._string,d=c.length,e=this._textureAtlas,f=e.texture,g=f.pixelsWidth,f=f.pixelsHeight,h=a._itemWidth,k=a._itemHeight;a._ignoreContentScaleFactor||(h=a._itemWidth*cc.contentScaleFactor(),k=a._itemHeight*cc.contentScaleFactor());d>e.getCapacity()&&cc.log("cc.LabelAtlas._updateAtlasValues(): Invalid String length");for(var m=e.quads,n=this._displayedColor,n=
{r:n.r,g:n.g,b:n.b,a:a._displayedOpacity},p=a._itemWidth,r=0;d>r;r++){var s,v,u,t,x=c.charCodeAt(r)-a._mapStartChar.charCodeAt(0),A=x%a._itemsPerRow,x=0|x/a._itemsPerRow;cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL?(s=(2*A*h+1)/(2*g),v=s+(2*h-2)/(2*g),u=(2*x*k+1)/(2*f),t=u+(2*k-2)/(2*f)):(s=A*h/g,v=s+h/g,u=x*k/f,t=u+k/f);var F=m[r],A=F.tl,x=F.tr,z=F.bl,F=F.br;A.texCoords.u=s;A.texCoords.v=u;x.texCoords.u=v;x.texCoords.v=u;z.texCoords.u=s;z.texCoords.v=t;F.texCoords.u=v;F.texCoords.v=t;z.vertices.x=r*p;z.vertices.y=
0;z.vertices.z=0;F.vertices.x=r*p+p;F.vertices.y=0;F.vertices.z=0;A.vertices.x=r*p;A.vertices.y=a._itemHeight;A.vertices.z=0;x.vertices.x=r*p+p;x.vertices.y=a._itemHeight;x.vertices.z=0;A.colors=n;x.colors=n;z.colors=n;F.colors=n}0<d&&(e.dirty=!0,a=e.totalQuads,d>a&&e.increaseTotalQuadsWith(d-a))};a.setString=function(a){a=a.length;a>this._textureAtlas.totalQuads&&this._textureAtlas.resizeCapacity(a)};a._addChild=function(){}}();
(function(){cc.LabelBMFont.WebGLRenderCmd=function(a){cc.SpriteBatchNode.WebGLRenderCmd.call(this,a);this._needDraw=!0};var a=cc.LabelBMFont.WebGLRenderCmd.prototype=Object.create(cc.SpriteBatchNode.WebGLRenderCmd.prototype);a.constructor=cc.LabelBMFont.WebGLRenderCmd;a._updateCharTexture=function(a,c,d){a.setTextureRect(c,!1);a.visible=!0};a._updateFntFileTexture=function(){};a._changeTextureColor=function(){};a._updateChildrenDisplayedOpacity=function(a){a.updateDisplayedOpacity(this._displayedOpacity)};
a._updateChildrenDisplayedColor=function(a){a.updateDisplayedColor(this._displayedColor)};a._initBatchTexture=function(){var a=this._node,c=a.textureAtlas.texture;a._opacityModifyRGB=c.hasPremultipliedAlpha();var d=a._reusedChar=new cc.Sprite;d.initWithTexture(c,cc.rect(0,0,0,0),!1);d.batchNode=a};a.rendering=function(a){cc.SpriteBatchNode.WebGLRenderCmd.prototype.rendering.call(this,a);a=this._node;if(cc.LABELBMFONT_DEBUG_DRAW){a=a.getContentSize();var c=cc.p(0|-this._anchorPointInPoints.x,0|-this._anchorPointInPoints.y);
a=[cc.p(c.x,c.y),cc.p(c.x+a.width,c.y),cc.p(c.x+a.width,c.y+a.height),cc.p(c.x,c.y+a.height)];cc._drawingUtil.setDrawColor(0,255,0,255);cc._drawingUtil.drawPoly(a,4,!0)}};a._updateCharColorAndOpacity=function(){}})();
cc.MotionStreak=cc.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(a,b,c,d,e){cc.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.startingPositionInitialized=this.fastMode=!1;this.texture=null;this._previousNuPoints=this._nuPoints=this._maxPoints=this._minSeg=this._fadeDelta=this._stroke=0;this._texCoordsBuffer=this._colorPointerBuffer=this._verticesBuffer=this._texCoords=this._colorPointer=this._vertices=this._pointState=this._pointVertexes=null;void 0!==e&&this.initWithFade(a,b,c,d,e)},getTexture:function(){return this.texture},setTexture:function(a){this.texture!==a&&(this.texture=a)},getBlendFunc:function(){return this._blendFunc},
setBlendFunc:function(a,b){void 0===b?this._blendFunc=a:(this._blendFunc.src=a,this._blendFunc.dst=b)},getOpacity:function(){return cc.log("cc.MotionStreak.getOpacity has not been supported."),0},setOpacity:function(a){cc.log("cc.MotionStreak.setOpacity has not been supported.")},setOpacityModifyRGB:function(a){},isOpacityModifyRGB:function(){return!1},isFastMode:function(){return this.fastMode},setFastMode:function(a){this.fastMode=a},isStartingPositionInitialized:function(){return this.startingPositionInitialized},
setStartingPositionInitialized:function(a){this.startingPositionInitialized=a},getStroke:function(){return this._stroke},setStroke:function(a){this._stroke=a},initWithFade:function(a,b,c,d,e){if(!e)throw"cc.MotionStreak.initWithFade(): Invalid filename or texture";cc.isString(e)&&(e=cc.textureCache.addImage(e));cc.Node.prototype.setPosition.call(this,cc.p(0,0));this.anchorY=this.anchorX=0;this.ignoreAnchor=!0;this.startingPositionInitialized=!1;this.fastMode=!0;this._minSeg=-1===b?c/5:b;this._minSeg*=
this._minSeg;this._stroke=c;this._fadeDelta=1/a;a=(0|60*a)+2;return this._maxPoints=a,this._nuPoints=0,this._pointState=new Float32Array(a),this._pointVertexes=new Float32Array(2*a),this._vertices=new Float32Array(4*a),this._texCoords=new Float32Array(4*a),this._colorPointer=new Uint8Array(8*a),this._verticesBuffer=gl.createBuffer(),this._texCoordsBuffer=gl.createBuffer(),this._colorPointerBuffer=gl.createBuffer(),this._blendFunc.src=gl.SRC_ALPHA,this._blendFunc.dst=gl.ONE_MINUS_SRC_ALPHA,this.texture=
e,this.color=d,this.scheduleUpdate(),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),!0},tintWithColor:function(a){this.color=a;for(var b=this._colorPointer,c=0,d=2*this._nuPoints;d>c;c++)b[4*c]=a.r,
b[4*c+1]=a.g,b[4*c+2]=a.b},reset:function(){this._nuPoints=0},setPosition:function(a,b){this.startingPositionInitialized=!0;void 0===b?(this._positionR.x=a.x,this._positionR.y=a.y):(this._positionR.x=a,this._positionR.y=b)},getPositionX:function(){return this._positionR.x},setPositionX:function(a){this._positionR.x=a;this.startingPositionInitialized||(this.startingPositionInitialized=!0)},getPositionY:function(){return this._positionR.y},setPositionY:function(a){this._positionR.y=a;this.startingPositionInitialized||
(this.startingPositionInitialized=!0)},update:function(a){if(this.startingPositionInitialized){this._renderCmd._updateDisplayColor();a*=this._fadeDelta;var b,c,d,e,f=0,g=this._nuPoints,h=this._pointState,k=this._pointVertexes,m=this._vertices,n=this._colorPointer;for(d=0;g>d;d++)(h[d]-=a,0>=h[d])?f++:(b=d-f,0<f?(h[b]=h[d],k[2*b]=k[2*d],k[2*b+1]=k[2*d+1],e=2*d,c=2*b,m[2*c]=m[2*e],m[2*c+1]=m[2*e+1],m[2*(c+1)]=m[2*(e+1)],m[2*(c+1)+1]=m[2*(e+1)+1],e*=4,c*=4,n[c+0]=n[e+0],n[c+1]=n[e+1],n[c+2]=n[e+2],n[c+
4]=n[e+4],n[c+5]=n[e+5],n[c+6]=n[e+6]):c=8*b,b=255*h[b],n[c+3]=b,n[c+7]=b);g-=f;d=!0;g>=this._maxPoints?d=!1:0<g&&(a=cc.pDistanceSQ(cc.p(k[2*(g-1)],k[2*(g-1)+1]),this._positionR)<this._minSeg,c=1===g?!1:cc.pDistanceSQ(cc.p(k[2*(g-2)],k[2*(g-2)+1]),this._positionR)<2*this._minSeg,(a||c)&&(d=!1));d&&(k[2*g]=this._positionR.x,k[2*g+1]=this._positionR.y,h[g]=1,h=8*g,d=this.getDisplayedColor(),n[h]=d.r,n[h+1]=d.g,n[h+2]=d.b,n[h+4]=d.r,n[h+5]=d.g,n[h+6]=d.b,n[h+3]=255,n[h+7]=255,0<g&&this.fastMode&&(1<
g?cc.vertexLineToPolygon(k,this._stroke,this._vertices,g,1):cc.vertexLineToPolygon(k,this._stroke,this._vertices,0,2)),g++);if(this.fastMode||cc.vertexLineToPolygon(k,this._stroke,this._vertices,0,g),g&&this._previousNuPoints!==g){k=1/g;n=this._texCoords;for(d=0;g>d;d++)n[4*d]=0,n[4*d+1]=k*d,n[2*(2*d+1)]=1,n[2*(2*d+1)+1]=k*d;this._previousNuPoints=g}this._nuPoints=g}},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_WEBGL?new cc.MotionStreak.WebGLRenderCmd(this):null}});
cc.MotionStreak.create=function(a,b,c,d,e){return new cc.MotionStreak(a,b,c,d,e)};cc.MotionStreak.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._needDraw=!0;this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)};cc.MotionStreak.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);cc.MotionStreak.WebGLRenderCmd.prototype.constructor=cc.Sprite.WebGLRenderCmd;
cc.MotionStreak.WebGLRenderCmd.prototype.rendering=function(a){var b=this._node;1>=b._nuPoints||b.texture&&b.texture.isLoaded()&&(a=a||cc._renderContext,this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX),cc.glBlendFunc(b._blendFunc.src,b._blendFunc.dst),cc.glBindTexture2D(b.texture),a.bindBuffer(a.ARRAY_BUFFER,b._verticesBuffer),a.bufferData(a.ARRAY_BUFFER,b._vertices,a.DYNAMIC_DRAW),a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,
2,a.FLOAT,!1,0,0),a.bindBuffer(a.ARRAY_BUFFER,b._texCoordsBuffer),a.bufferData(a.ARRAY_BUFFER,b._texCoords,a.DYNAMIC_DRAW),a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,a.FLOAT,!1,0,0),a.bindBuffer(a.ARRAY_BUFFER,b._colorPointerBuffer),a.bufferData(a.ARRAY_BUFFER,b._colorPointer,a.DYNAMIC_DRAW),a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,a.UNSIGNED_BYTE,!0,0,0),a.drawArrays(a.TRIANGLE_STRIP,0,2*b._nuPoints),cc.g_NumberOfDraws++)};
cc.NodeGrid=cc.Node.extend({grid:null,_target:null,getGrid:function(){return this.grid},setGrid:function(a){this.grid=a},setTarget:function(a){this._target=a},_transformForWebGL:function(){var a=this._transform4x4,b=cc.current_stack.top,c=this.getNodeToParentTransform(),d=a.mat;if(d[0]=c.a,d[4]=c.c,d[12]=c.tx,d[1]=c.b,d[5]=c.d,d[13]=c.ty,d[14]=this._vertexZ,b.multiply(a),!(null===this._camera||this.grid&&this.grid.isActive()))b=this._renderCmd._anchorPointInPoints,a=b.x,b=b.y,0!==a||0!==b?(cc.SPRITEBATCHNODE_RENDER_SUBPIXEL||
(a|=0,b|=0),cc.kmGLTranslatef(a,b,0),this._camera.locate(),cc.kmGLTranslatef(-a,-b,0)):this._camera.locate()},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_WEBGL?new cc.NodeGrid.WebGLRenderCmd(this):new cc.Node.CanvasRenderCmd(this)}});_p=cc.NodeGrid.prototype;_p.grid;_p.target;cc.defineGetterSetter(_p,"target",null,_p.setTarget);cc.NodeGrid.create=function(){return new cc.NodeGrid};
(function(){cc.NodeGrid.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._needDraw=!1;this._gridBeginCommand=new cc.CustomRenderCmd(this,this.onGridBeginDraw);this._gridEndCommand=new cc.CustomRenderCmd(this,this.onGridEndDraw)};var a=cc.NodeGrid.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.NodeGrid.WebGLRenderCmd;a.visit=function(a){var c=this._node;if(c._visible){a=a||this.getParentRenderCmd();c._parent&&c._parent._renderCmd&&(this._curLevel=
c._parent._renderCmd._curLevel+1);var d=cc.current_stack;d.stack.push(d.top);this._syncStatus(a);d.top=this._stackMatrix;cc.renderer.pushRenderCommand(this._gridBeginCommand);c._target&&c._target.visit();if((a=c._children)&&0<a.length){var e=a.length;c.sortAllChildren();for(c=0;e>c;c++){var f=a[c];f&&f.visit()}}cc.renderer.pushRenderCommand(this._gridEndCommand);this._dirtyFlag=0;d.top=d.stack.pop()}};a.onGridBeginDraw=function(){var a=this._node.grid;a&&a._active&&a.beforeDraw()};a.onGridEndDraw=
function(){var a=this._node.grid;a&&a._active&&a.afterDraw(this._node)}})();cc.v2fzero=function(){return{x:0,y:0}};cc.v2f=function(a,b){return{x:a,y:b}};cc.v2fadd=function(a,b){return cc.v2f(a.x+b.x,a.y+b.y)};cc.v2fsub=function(a,b){return cc.v2f(a.x-b.x,a.y-b.y)};cc.v2fmult=function(a,b){return cc.v2f(a.x*b,a.y*b)};cc.v2fperp=function(a){return cc.v2f(-a.y,a.x)};cc.v2fneg=function(a){return cc.v2f(-a.x,-a.y)};cc.v2fdot=function(a,b){return a.x*b.x+a.y*b.y};
cc.v2fforangle=function(a){return cc.v2f(Math.cos(a),Math.sin(a))};cc.v2fnormalize=function(a){a=cc.pNormalize(cc.p(a.x,a.y));return cc.v2f(a.x,a.y)};cc.__v2f=function(a){return cc.v2f(a.x,a.y)};cc.__t=function(a){return{u:a.x,v:a.y}};
cc.DrawNodeCanvas=cc.Node.extend({_buffer:null,_blendFunc:null,_lineWidth:1,_drawColor:null,_className:"DrawNodeCanvas",ctor:function(){cc.Node.prototype.ctor.call(this);var a=this._renderCmd;a._buffer=this._buffer=[];a._drawColor=this._drawColor=cc.color(255,255,255,255);a._blendFunc=this._blendFunc=new cc.BlendFunc(cc.BLEND_SRC,cc.BLEND_DST);this.init()},getBlendFunc:function(){return this._blendFunc},setBlendFunc:function(a,b){void 0===b?(this._blendFunc.src=a.src,this._blendFunc.dst=a.dst):(this._blendFunc.src=
a,this._blendFunc.dst=b)},setLineWidth:function(a){this._lineWidth=a},getLineWidth:function(){return this._lineWidth},setDrawColor:function(a){var b=this._drawColor;b.r=a.r;b.g=a.g;b.b=a.b;b.a=null==a.a?255:a.a},getDrawColor:function(){return cc.color(this._drawColor.r,this._drawColor.g,this._drawColor.b,this._drawColor.a)},drawRect:function(a,b,c,d,e){d=null==d?this._lineWidth:d;e=e||this.getDrawColor();null==e.a&&(e.a=255);a=[a,cc.p(b.x,a.y),b,cc.p(a.x,b.y)];b=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
b.verts=a;b.lineWidth=d;b.lineColor=e;b.isClosePolygon=!0;b.isStroke=!0;b.lineCap="butt";(b.fillColor=c)&&(null==c.a&&(c.a=255),b.isFill=!0);this._buffer.push(b)},drawCircle:function(a,b,c,d,e,f,g){f=f||this._lineWidth;g=g||this.getDrawColor();null==g.a&&(g.a=255);for(var h=2*Math.PI/d,k=[],m=0;d>=m;m++){var n=m*h,p=b*Math.cos(n+c)+a.x,n=b*Math.sin(n+c)+a.y;k.push(cc.p(p,n))}e&&k.push(cc.p(a.x,a.y));a=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);a.verts=k;a.lineWidth=f;a.lineColor=g;a.isClosePolygon=
!0;a.isStroke=!0;this._buffer.push(a)},drawQuadBezier:function(a,b,c,d,e,f){e=e||this._lineWidth;f=f||this.getDrawColor();null==f.a&&(f.a=255);for(var g=[],h=0,k=0;d>k;k++){var m=Math.pow(1-h,2)*a.x+2*(1-h)*h*b.x+h*h*c.x,n=Math.pow(1-h,2)*a.y+2*(1-h)*h*b.y+h*h*c.y;g.push(cc.p(m,n));h+=1/d}g.push(cc.p(c.x,c.y));a=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);a.verts=g;a.lineWidth=e;a.lineColor=f;a.isStroke=!0;a.lineCap="round";this._buffer.push(a)},drawCubicBezier:function(a,b,c,d,e,f,g){f=f||this._lineWidth;
g=g||this.getDrawColor();null==g.a&&(g.a=255);for(var h=[],k=0,m=0;e>m;m++){var n=Math.pow(1-k,3)*a.x+3*Math.pow(1-k,2)*k*b.x+3*(1-k)*k*k*c.x+k*k*k*d.x,p=Math.pow(1-k,3)*a.y+3*Math.pow(1-k,2)*k*b.y+3*(1-k)*k*k*c.y+k*k*k*d.y;h.push(cc.p(n,p));k+=1/e}h.push(cc.p(d.x,d.y));a=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);a.verts=h;a.lineWidth=f;a.lineColor=g;a.isStroke=!0;a.lineCap="round";this._buffer.push(a)},drawCatmullRom:function(a,b,c,d){this.drawCardinalSpline(a,0.5,b,c,d)},drawCardinalSpline:function(a,
b,c,d,e){d=d||this._lineWidth;e=e||this.getDrawColor();null==e.a&&(e.a=255);for(var f,g,h=[],k=1/a.length,m=0;c+1>m;m++){var n=m/c;1===n?(f=a.length-1,g=1):(f=0|n/k,g=(n-k*f)/k);n=cc.cardinalSplineAt(cc.getControlPointAt(a,f-1),cc.getControlPointAt(a,f-0),cc.getControlPointAt(a,f+1),cc.getControlPointAt(a,f+2),b,g);h.push(n)}a=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);a.verts=h;a.lineWidth=d;a.lineColor=e;a.isStroke=!0;a.lineCap="round";this._buffer.push(a)},drawDot:function(a,b,c){c=c||this.getDrawColor();
null==c.a&&(c.a=255);var d=new cc._DrawNodeElement(cc.DrawNode.TYPE_DOT);d.verts=[a];d.lineWidth=b;d.fillColor=c;this._buffer.push(d)},drawDots:function(a,b,c){if(a&&0!=a.length){c=c||this.getDrawColor();null==c.a&&(c.a=255);for(var d=0,e=a.length;e>d;d++)this.drawDot(a[d],b,c)}},drawSegment:function(a,b,c,d){c=c||this._lineWidth;d=d||this.getDrawColor();null==d.a&&(d.a=255);var e=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);e.verts=[a,b];e.lineWidth=2*c;e.lineColor=d;e.isStroke=!0;e.lineCap="round";
this._buffer.push(e)},drawPoly_:function(a,b,c,d){c=null==c?this._lineWidth:c;d=d||this.getDrawColor();null==d.a&&(d.a=255);var e=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);e.verts=a;e.fillColor=b;e.lineWidth=c;e.lineColor=d;e.isClosePolygon=!0;e.isStroke=!0;e.lineCap="round";b&&(e.isFill=!0);this._buffer.push(e)},drawPoly:function(a,b,c,d){for(var e=[],f=0;f<a.length;f++)e.push(cc.p(a[f].x,a[f].y));return this.drawPoly_(e,b,c,d)},clear:function(){this._buffer.length=0},_createRenderCmd:function(){return new cc.DrawNode.CanvasRenderCmd(this)}});
cc.DrawNodeWebGL=cc.Node.extend({_bufferCapacity:0,_buffer:null,_trianglesArrayBuffer:null,_trianglesWebBuffer:null,_trianglesReader:null,_lineWidth:1,_drawColor:null,_blendFunc:null,_dirty:!1,_className:"DrawNodeWebGL",getBlendFunc:function(){return this._blendFunc},setBlendFunc:function(a,b){void 0===b?(this._blendFunc.src=a.src,this._blendFunc.dst=a.dst):(this._blendFunc.src=a,this._blendFunc.dst=b)},ctor:function(){cc.Node.prototype.ctor.call(this);this._buffer=[];this._blendFunc=new cc.BlendFunc(cc.BLEND_SRC,
cc.BLEND_DST);this._drawColor=cc.color(255,255,255,255);this.init()},init:function(){return cc.Node.prototype.init.call(this)?(this.shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_LENGTHTEXTURECOLOR),this._ensureCapacity(64),this._trianglesWebBuffer=cc._renderContext.createBuffer(),this._dirty=!0,!0):!1},setLineWidth:function(a){this._lineWidth=a},getLineWidth:function(){return this._lineWidth},setDrawColor:function(a){var b=this._drawColor;b.r=a.r;b.g=a.g;b.b=a.b;b.a=a.a},getDrawColor:function(){return cc.color(this._drawColor.r,
this._drawColor.g,this._drawColor.b,this._drawColor.a)},drawRect:function(a,b,c,d,e){d=null==d?this._lineWidth:d;e=e||this.getDrawColor();null==e.a&&(e.a=255);a=[a,cc.p(b.x,a.y),b,cc.p(a.x,b.y)];null==c?this._drawSegments(a,d,e,!0):this.drawPoly(a,c,d,e)},drawCircle:function(a,b,c,d,e,f,g){f=f||this._lineWidth;g=g||this.getDrawColor();null==g.a&&(g.a=255);var h,k=2*Math.PI/d,m=[];for(h=0;d>=h;h++){var n=h*k,p=b*Math.cos(n+c)+a.x,n=b*Math.sin(n+c)+a.y;m.push(cc.p(p,n))}e&&m.push(cc.p(a.x,a.y));f*=
0.5;h=0;for(a=m.length;a-1>h;h++)this.drawSegment(m[h],m[h+1],f,g)},drawQuadBezier:function(a,b,c,d,e,f){e=e||this._lineWidth;f=f||this.getDrawColor();null==f.a&&(f.a=255);for(var g=[],h=0,k=0;d>k;k++){var m=Math.pow(1-h,2)*a.x+2*(1-h)*h*b.x+h*h*c.x,n=Math.pow(1-h,2)*a.y+2*(1-h)*h*b.y+h*h*c.y;g.push(cc.p(m,n));h+=1/d}g.push(cc.p(c.x,c.y));this._drawSegments(g,e,f,!1)},drawCubicBezier:function(a,b,c,d,e,f,g){f=f||this._lineWidth;g=g||this.getDrawColor();null==g.a&&(g.a=255);for(var h=[],k=0,m=0;e>
m;m++){var n=Math.pow(1-k,3)*a.x+3*Math.pow(1-k,2)*k*b.x+3*(1-k)*k*k*c.x+k*k*k*d.x,p=Math.pow(1-k,3)*a.y+3*Math.pow(1-k,2)*k*b.y+3*(1-k)*k*k*c.y+k*k*k*d.y;h.push(cc.p(n,p));k+=1/e}h.push(cc.p(d.x,d.y));this._drawSegments(h,f,g,!1)},drawCatmullRom:function(a,b,c,d){this.drawCardinalSpline(a,0.5,b,c,d)},drawCardinalSpline:function(a,b,c,d,e){d=d||this._lineWidth;e=e||this.getDrawColor();null==e.a&&(e.a=255);for(var f,g,h=[],k=1/a.length,m=0;c+1>m;m++){var n=m/c;1===n?(f=a.length-1,g=1):(f=0|n/k,g=(n-
k*f)/k);n=cc.cardinalSplineAt(cc.getControlPointAt(a,f-1),cc.getControlPointAt(a,f-0),cc.getControlPointAt(a,f+1),cc.getControlPointAt(a,f+2),b,g);h.push(n)}d*=0.5;a=0;for(b=h.length;b-1>a;a++)this.drawSegment(h[a],h[a+1],d,e)},_render:function(){var a=cc._renderContext;cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);a.bindBuffer(a.ARRAY_BUFFER,this._trianglesWebBuffer);this._dirty&&(a.bufferData(a.ARRAY_BUFFER,this._trianglesArrayBuffer,a.STREAM_DRAW),this._dirty=!1);var b=cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,a.FLOAT,!1,b,0);a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,a.UNSIGNED_BYTE,!0,b,8);a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,a.FLOAT,!1,b,12);a.drawArrays(a.TRIANGLES,0,3*this._buffer.length);cc.incrementGLDraws(1)},_ensureCapacity:function(a){var b=this._buffer;if(b.length+a>this._bufferCapacity){var c=cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT;if(this._bufferCapacity+=Math.max(this._bufferCapacity,a),null==b||0===b.length)this._buffer=
[],this._trianglesArrayBuffer=new ArrayBuffer(c*this._bufferCapacity),this._trianglesReader=new Uint8Array(this._trianglesArrayBuffer);else{a=[];for(var d=new ArrayBuffer(c*this._bufferCapacity),e=0;e<b.length;e++)a[e]=new cc.V2F_C4B_T2F_Triangle(b[e].a,b[e].b,b[e].c,d,e*c);this._trianglesReader=new Uint8Array(d);this._trianglesArrayBuffer=d;this._buffer=a}}},drawDot:function(a,b,c){c=c||this.getDrawColor();null==c.a&&(c.a=255);var d={r:0|c.r,g:0|c.g,b:0|c.b,a:0|c.a};c={vertices:{x:a.x-b,y:a.y-b},
colors:d,texCoords:{u:-1,v:-1}};var e={vertices:{x:a.x-b,y:a.y+b},colors:d,texCoords:{u:-1,v:1}},f={vertices:{x:a.x+b,y:a.y+b},colors:d,texCoords:{u:1,v:1}};a={vertices:{x:a.x+b,y:a.y-b},colors:d,texCoords:{u:1,v:-1}};this._ensureCapacity(6);this._buffer.push(new cc.V2F_C4B_T2F_Triangle(c,e,f,this._trianglesArrayBuffer,this._buffer.length*cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT));this._buffer.push(new cc.V2F_C4B_T2F_Triangle(c,f,a,this._trianglesArrayBuffer,this._buffer.length*cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT));
this._dirty=!0},drawDots:function(a,b,c){if(a&&0!==a.length){c=c||this.getDrawColor();null==c.a&&(c.a=255);for(var d=0,e=a.length;e>d;d++)this.drawDot(a[d],b,c)}},drawSegment:function(a,b,c,d){d=d||this.getDrawColor();null==d.a&&(d.a=255);c=c||0.5*this._lineWidth;this._ensureCapacity(18);d={r:0|d.r,g:0|d.g,b:0|d.b,a:0|d.a};var e=cc.__v2f(a),f=cc.__v2f(b);b=cc.v2fnormalize(cc.v2fperp(cc.v2fsub(f,e)));a=cc.v2fperp(b);var g=cc.v2fmult(b,c),h=cc.v2fmult(a,c);c=cc.v2fsub(f,cc.v2fadd(g,h));var k=cc.v2fadd(f,
cc.v2fsub(g,h)),m=cc.v2fsub(f,g),f=cc.v2fadd(f,g),n=cc.v2fsub(e,g),p=cc.v2fadd(e,g),r=cc.v2fsub(e,cc.v2fsub(g,h)),e=cc.v2fadd(e,cc.v2fadd(g,h)),g=cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT,h=this._trianglesArrayBuffer,s=this._buffer;s.push(new cc.V2F_C4B_T2F_Triangle({vertices:c,colors:d,texCoords:cc.__t(cc.v2fneg(cc.v2fadd(b,a)))},{vertices:k,colors:d,texCoords:cc.__t(cc.v2fsub(b,a))},{vertices:m,colors:d,texCoords:cc.__t(cc.v2fneg(b))},h,s.length*g));s.push(new cc.V2F_C4B_T2F_Triangle({vertices:f,
colors:d,texCoords:cc.__t(b)},{vertices:k,colors:d,texCoords:cc.__t(cc.v2fsub(b,a))},{vertices:m,colors:d,texCoords:cc.__t(cc.v2fneg(b))},h,s.length*g));s.push(new cc.V2F_C4B_T2F_Triangle({vertices:f,colors:d,texCoords:cc.__t(b)},{vertices:n,colors:d,texCoords:cc.__t(cc.v2fneg(b))},{vertices:m,colors:d,texCoords:cc.__t(cc.v2fneg(b))},h,s.length*g));s.push(new cc.V2F_C4B_T2F_Triangle({vertices:f,colors:d,texCoords:cc.__t(b)},{vertices:n,colors:d,texCoords:cc.__t(cc.v2fneg(b))},{vertices:p,colors:d,
texCoords:cc.__t(b)},h,s.length*g));s.push(new cc.V2F_C4B_T2F_Triangle({vertices:r,colors:d,texCoords:cc.__t(cc.v2fsub(a,b))},{vertices:n,colors:d,texCoords:cc.__t(cc.v2fneg(b))},{vertices:p,colors:d,texCoords:cc.__t(b)},h,s.length*g));s.push(new cc.V2F_C4B_T2F_Triangle({vertices:r,colors:d,texCoords:cc.__t(cc.v2fsub(a,b))},{vertices:e,colors:d,texCoords:cc.__t(cc.v2fadd(b,a))},{vertices:p,colors:d,texCoords:cc.__t(b)},h,s.length*g));this._dirty=!0},drawPoly:function(a,b,c,d){if(null==b)return void this._drawSegments(a,
c,d,!0);null==b.a&&(b.a=255);null==d.a&&(d.a=255);c=null==c?this._lineWidth:c;c*=0.5;var e,f,g;b={r:0|b.r,g:0|b.g,b:0|b.b,a:0|b.a};var h={r:0|d.r,g:0|d.g,b:0|d.b,a:0|d.a},k=[],m=a.length;for(d=0;m>d;d++){e=cc.__v2f(a[(d-1+m)%m]);f=cc.__v2f(a[d]);g=cc.__v2f(a[(d+1)%m]);var n=cc.v2fnormalize(cc.v2fperp(cc.v2fsub(f,e)));f=cc.v2fnormalize(cc.v2fperp(cc.v2fsub(g,f)));n=cc.v2fmult(cc.v2fadd(n,f),1/(cc.v2fdot(n,f)+1));k[d]={offset:n,n:f}}n=0<c;this._ensureCapacity(3*(3*m-2));var p=cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT,
r=this._trianglesArrayBuffer,s=this._buffer,v=0==n?0.5:0;for(d=0;m-2>d;d++)e=cc.v2fsub(cc.__v2f(a[0]),cc.v2fmult(k[0].offset,v)),f=cc.v2fsub(cc.__v2f(a[d+1]),cc.v2fmult(k[d+1].offset,v)),g=cc.v2fsub(cc.__v2f(a[d+2]),cc.v2fmult(k[d+2].offset,v)),s.push(new cc.V2F_C4B_T2F_Triangle({vertices:e,colors:b,texCoords:cc.__t(cc.v2fzero())},{vertices:f,colors:b,texCoords:cc.__t(cc.v2fzero())},{vertices:g,colors:b,texCoords:cc.__t(cc.v2fzero())},r,s.length*p));for(d=0;m>d;d++){v=(d+1)%m;e=cc.__v2f(a[d]);f=cc.__v2f(a[v]);
g=k[d].n;var u=k[d].offset,t=k[v].offset,v=n?cc.v2fsub(e,cc.v2fmult(u,c)):cc.v2fsub(e,cc.v2fmult(u,0.5)),x=n?cc.v2fsub(f,cc.v2fmult(t,c)):cc.v2fsub(f,cc.v2fmult(t,0.5));e=n?cc.v2fadd(e,cc.v2fmult(u,c)):cc.v2fadd(e,cc.v2fmult(u,0.5));f=n?cc.v2fadd(f,cc.v2fmult(t,c)):cc.v2fadd(f,cc.v2fmult(t,0.5));n?(s.push(new cc.V2F_C4B_T2F_Triangle({vertices:v,colors:h,texCoords:cc.__t(cc.v2fneg(g))},{vertices:x,colors:h,texCoords:cc.__t(cc.v2fneg(g))},{vertices:f,colors:h,texCoords:cc.__t(g)},r,s.length*p)),s.push(new cc.V2F_C4B_T2F_Triangle({vertices:v,
colors:h,texCoords:cc.__t(cc.v2fneg(g))},{vertices:e,colors:h,texCoords:cc.__t(g)},{vertices:f,colors:h,texCoords:cc.__t(g)},r,s.length*p))):(s.push(new cc.V2F_C4B_T2F_Triangle({vertices:v,colors:b,texCoords:cc.__t(cc.v2fzero())},{vertices:x,colors:b,texCoords:cc.__t(cc.v2fzero())},{vertices:f,colors:b,texCoords:cc.__t(g)},r,s.length*p)),s.push(new cc.V2F_C4B_T2F_Triangle({vertices:v,colors:b,texCoords:cc.__t(cc.v2fzero())},{vertices:e,colors:b,texCoords:cc.__t(g)},{vertices:f,colors:b,texCoords:cc.__t(g)},
r,s.length*p)))}this._dirty=!0},_drawSegments:function(a,b,c,d){if(b=null==b?this._lineWidth:b,c=c||this._drawColor,null==c.a&&(c.a=255),b*=0.5,!(0>=b)){var e,f,g,h={r:0|c.r,g:0|c.g,b:0|c.b,a:0|c.a},k=[],m=a.length;for(c=0;m>c;c++){e=cc.__v2f(a[(c-1+m)%m]);f=cc.__v2f(a[c]);g=cc.__v2f(a[(c+1)%m]);var n=cc.v2fnormalize(cc.v2fperp(cc.v2fsub(f,e)));f=cc.v2fnormalize(cc.v2fperp(cc.v2fsub(g,f)));g=cc.v2fmult(cc.v2fadd(n,f),1/(cc.v2fdot(n,f)+1));k[c]={offset:g,n:f}}this._ensureCapacity(3*(3*m-2));g=cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT;
var n=this._trianglesArrayBuffer,p=this._buffer;d=d?m:m-1;for(c=0;d>c;c++){var r=(c+1)%m;e=cc.__v2f(a[c]);f=cc.__v2f(a[r]);var s=k[c].n,v=k[c].offset,u=k[r].offset,r=cc.v2fsub(e,cc.v2fmult(v,b)),t=cc.v2fsub(f,cc.v2fmult(u,b));e=cc.v2fadd(e,cc.v2fmult(v,b));f=cc.v2fadd(f,cc.v2fmult(u,b));p.push(new cc.V2F_C4B_T2F_Triangle({vertices:r,colors:h,texCoords:cc.__t(cc.v2fneg(s))},{vertices:t,colors:h,texCoords:cc.__t(cc.v2fneg(s))},{vertices:f,colors:h,texCoords:cc.__t(s)},n,p.length*g));p.push(new cc.V2F_C4B_T2F_Triangle({vertices:r,
colors:h,texCoords:cc.__t(cc.v2fneg(s))},{vertices:e,colors:h,texCoords:cc.__t(s)},{vertices:f,colors:h,texCoords:cc.__t(s)},n,p.length*g))}this._dirty=!0}},clear:function(){this._buffer.length=0;this._dirty=!0},_createRenderCmd:function(){return new cc.DrawNode.WebGLRenderCmd(this)}});cc.DrawNode=cc._renderType===cc._RENDER_TYPE_WEBGL?cc.DrawNodeWebGL:cc.DrawNodeCanvas;cc.DrawNode.create=function(){return new cc.DrawNode};
cc._DrawNodeElement=function(a,b,c,d,e,f,g,h,k){this.type=a;this.verts=b||null;this.fillColor=c||null;this.lineWidth=d||0;this.lineColor=e||null;this.lineCap=f||"butt";this.isClosePolygon=g||!1;this.isFill=h||!1;this.isStroke=k||!1};cc.DrawNode.TYPE_DOT=0;cc.DrawNode.TYPE_SEGMENT=1;cc.DrawNode.TYPE_POLY=2;
(function(){cc.DrawNode.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._needDraw=!0;this._blendFunc=this._drawColor=this._buffer=null};cc.DrawNode.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);cc.DrawNode.CanvasRenderCmd.prototype.constructor=cc.DrawNode.CanvasRenderCmd;cc.DrawNode.CanvasRenderCmd.prototype.rendering=function(a,b,c){a=a||cc._renderContext;var d=(a.getContext(),this._node)._displayedOpacity/255;if(0!==d){a.setTransform(this._worldTransform,
b,c);a.setGlobalAlpha(d);this._blendFunc&&this._blendFunc.src===cc.SRC_ALPHA&&this._blendFunc.dst===cc.ONE&&a.setCompositeOperation("lighter");for(var d=this._buffer,e=0,f=d.length;f>e;e++){var g=d[e];switch(g.type){case cc.DrawNode.TYPE_DOT:this._drawDot(a,g,b,c);break;case cc.DrawNode.TYPE_SEGMENT:this._drawSegment(a,g,b,c);break;case cc.DrawNode.TYPE_POLY:this._drawPoly(a,g,b,c)}}}};cc.DrawNode.CanvasRenderCmd.prototype._drawDot=function(a,b,c,d){var e=b.fillColor,f=b.verts[0];b=b.lineWidth;var g=
a.getContext();a.setFillStyle("rgba("+(0|e.r)+","+(0|e.g)+","+(0|e.b)+","+e.a/255+")");g.beginPath();g.arc(f.x*c,-f.y*d,b*c,0,2*Math.PI,!1);g.closePath();g.fill()};cc.DrawNode.CanvasRenderCmd.prototype._drawSegment=function(a,b,c,d){var e=b.lineColor,f=b.verts[0],g=b.verts[1],h=b.lineWidth;b=b.lineCap;var k=a.getContext();a.setStrokeStyle("rgba("+(0|e.r)+","+(0|e.g)+","+(0|e.b)+","+e.a/255+")");k.lineWidth=h*c;k.beginPath();k.lineCap=b;k.moveTo(f.x*c,-f.y*d);k.lineTo(g.x*c,-g.y*d);k.stroke()};cc.DrawNode.CanvasRenderCmd.prototype._drawPoly=
function(a,b,c,d){var e=b.verts,f=b.lineCap;if(null!=e){var g=b.fillColor,h=b.lineWidth,k=b.lineColor,m=b.isClosePolygon,n=b.isFill;b=b.isStroke;var p=a.getContext(),r=e[0];p.lineCap=f;g&&a.setFillStyle("rgba("+(0|g.r)+","+(0|g.g)+","+(0|g.b)+","+g.a/255+")");h&&(p.lineWidth=h*c);k&&a.setStrokeStyle("rgba("+(0|k.r)+","+(0|k.g)+","+(0|k.b)+","+k.a/255+")");p.beginPath();p.moveTo(r.x*c,-r.y*d);a=1;for(f=e.length;f>a;a++)p.lineTo(e[a].x*c,-e[a].y*d);m&&p.closePath();n&&p.fill();b&&p.stroke()}}})();
!function(){cc.DrawNode.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._needDraw=!0};cc.DrawNode.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);cc.DrawNode.WebGLRenderCmd.prototype.constructor=cc.DrawNode.WebGLRenderCmd;cc.DrawNode.WebGLRenderCmd.prototype.rendering=function(a){a=this._node;cc.glBlendFunc(a._blendFunc.src,a._blendFunc.dst);this._shaderProgram.use();this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix);a._render()}}();
cc.stencilBits=-1;
cc.ClippingNode=cc.Node.extend({alphaThreshold:0,inverted:!1,_stencil:null,_className:"ClippingNode",ctor:function(a){a=a||null;cc.Node.prototype.ctor.call(this);this._stencil=a;this.alphaThreshold=1;this.inverted=!1;this._renderCmd.initStencilBits()},init:function(a){return this._stencil=a,this.alphaThreshold=1,this.inverted=!1,this._renderCmd.initStencilBits(),!0},onEnter:function(){cc.Node.prototype.onEnter.call(this);this._stencil.onEnter()},onEnterTransitionDidFinish:function(){cc.Node.prototype.onEnterTransitionDidFinish.call(this);this._stencil.onEnterTransitionDidFinish()},
onExitTransitionDidStart:function(){this._stencil.onExitTransitionDidStart();cc.Node.prototype.onExitTransitionDidStart.call(this)},onExit:function(){this._stencil.onExit();cc.Node.prototype.onExit.call(this)},getAlphaThreshold:function(){return this.alphaThreshold},setAlphaThreshold:function(a){this.alphaThreshold=a},isInverted:function(){return this.inverted},setInverted:function(a){this.inverted=a},getStencil:function(){return this._stencil},setStencil:function(a){this._stencil!==a&&this._renderCmd.setStencil(a)},
_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.ClippingNode.CanvasRenderCmd(this):new cc.ClippingNode.WebGLRenderCmd(this)}});_p=cc.ClippingNode.prototype;cc.defineGetterSetter(_p,"stencil",_p.getStencil,_p.setStencil);_p.stencil;cc.ClippingNode.create=function(a){return new cc.ClippingNode(a)};
(function(){cc.ClippingNode.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._clipElemType=this._godhelpme=this._needDraw=!1;this._rendererSaveCmd=new cc.CustomRenderCmd(this,this._saveCmdCallback);this._rendererClipCmd=new cc.CustomRenderCmd(this,this._clipCmdCallback);this._rendererRestoreCmd=new cc.CustomRenderCmd(this,this._restoreCmdCallback)};var a=cc.ClippingNode.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.ClippingNode.CanvasRenderCmd;
a.initStencilBits=function(){};a.setStencil=function(a){if(null!=a)if(this._node._stencil=a,a instanceof cc.DrawNode){if(a._buffer)for(var c=0;c<a._buffer.length;c++)a._buffer[c].isFill=!1,a._buffer[c].isStroke=!1;a._renderCmd.rendering=function(c,e,f){e=e||cc.view.getScaleX();f=f||cc.view.getScaleY();c=c||cc._renderContext;var g=c.getContext(),h=this._transform;c.save();g.transform(h.a,h.b,h.c,h.d,h.tx*e,-h.ty*f);g.beginPath();for(h=0;h<a._buffer.length;h++){var k=a._buffer[h].verts,m=k[0];g.moveTo(m.x*
e,-m.y*f);for(var m=1,n=k.length;n>m;m++)g.lineTo(k[m].x*e,-k[m].y*f)}c.restore()}}else a._parent=this._node};a._saveCmdCallback=function(a,c,d){var e=a||cc._renderContext;a=e.getContext();this._clipElemType?(c=cc.ClippingNode.CanvasRenderCmd._getSharedCache(),d=a.canvas,c.width=d.width,c.height=d.height,c.getContext("2d").drawImage(d,0,0)):(e.save(),e.save(),e.setTransform(this._worldTransform,c,d))};a._setStencilCompositionOperation=function(a){if(a){var c=this._node;if(a._renderCmd&&a._renderCmd._blendFuncStr&&
(a._renderCmd._blendFuncStr=c.inverted?"destination-out":"destination-in"),a._children){a=a._children;for(var c=0,d=a.length;d>c;c++)this._setStencilCompositionOperation(a[c])}}};a._clipCmdCallback=function(a){var c=this._node;a=a||cc._renderContext;var d=a.getContext();if(this._clipElemType)this._setStencilCompositionOperation(c._stencil);else{if(a.restore(),c.inverted)c=d.canvas,a.save(),d.setTransform(1,0,0,1,0,0),d.moveTo(0,0),d.lineTo(0,c.height),d.lineTo(c.width,c.height),d.lineTo(c.width,0),
d.lineTo(0,0),a.restore();d.closePath();d.clip()}};a._restoreCmdCallback=function(a){var c=cc.ClippingNode.CanvasRenderCmd._getSharedCache();a=a||cc._renderContext;var d=a.getContext();this._clipElemType?(d.save(),d.setTransform(1,0,0,1,0,0),d.globalCompositeOperation="destination-over",d.drawImage(c,0,0),d.restore(),this._dirtyFlag=0):a.restore()};a.transform=function(a,c){cc.Node.CanvasRenderCmd.prototype.transform.call(this,a,c);var d=this._node;d._stencil&&d._stencil._renderCmd&&d._stencil._renderCmd.transform(this,
c)};a._cangodhelpme=function(a){return(!0===a||!1===a)&&(cc.ClippingNode.CanvasRenderCmd.prototype._godhelpme=a),cc.ClippingNode.CanvasRenderCmd.prototype._godhelpme};a.visit=function(a){var c=this._node;if(c._visible){(a=a||this.getParentRenderCmd())&&(this._curLevel=a._curLevel+1);if(this._clipElemType=!(!this._cangodhelpme()&&c._stencil instanceof cc.DrawNode),!c._stencil||!c._stencil.visible)return void(this.inverted&&cc.Node.CanvasRenderCmd.prototype.visit.call(this,a));if(this._syncStatus(a),
cc.renderer.pushRenderCommand(this._rendererSaveCmd),this._clipElemType?cc.Node.CanvasRenderCmd.prototype.visit.call(this,a):c._stencil.visit(this),cc.renderer.pushRenderCommand(this._rendererClipCmd),this._clipElemType)c._stencil.visit(this);else{a=c._children;this._cangodhelpme(!0);var d=a.length;if(0<d){c.sortAllChildren();for(c=0;d>c;c++)a[c]._renderCmd.visit(this)}this._cangodhelpme(!1)}cc.renderer.pushRenderCommand(this._rendererRestoreCmd);this._dirtyFlag=0}};cc.ClippingNode.CanvasRenderCmd._sharedCache=
null;cc.ClippingNode.CanvasRenderCmd._getSharedCache=function(){return cc.ClippingNode.CanvasRenderCmd._sharedCache||(cc.ClippingNode.CanvasRenderCmd._sharedCache=document.createElement("canvas"))}})();
!function(){cc.ClippingNode.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._needDraw=!1;this._beforeVisitCmd=new cc.CustomRenderCmd(this,this._onBeforeVisit);this._afterDrawStencilCmd=new cc.CustomRenderCmd(this,this._onAfterDrawStencil);this._afterVisitCmd=new cc.CustomRenderCmd(this,this._onAfterVisit);this._mask_layer_le=this._currentDepthWriteMask=this._currentStencilEnabled=this._currentStencilWriteMask=this._currentStencilPassDepthPass=this._currentStencilPassDepthFail=
this._currentStencilFail=this._currentStencilValueMask=this._currentStencilRef=this._currentStencilFunc=null};var a=cc.ClippingNode.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.ClippingNode.WebGLRenderCmd;cc.ClippingNode.WebGLRenderCmd._init_once=null;cc.ClippingNode.WebGLRenderCmd._visit_once=null;cc.ClippingNode.WebGLRenderCmd._layer=-1;a.initStencilBits=function(){cc.ClippingNode.WebGLRenderCmd._init_once=!0;cc.ClippingNode.WebGLRenderCmd._init_once&&
(cc.stencilBits=cc._renderContext.getParameter(cc._renderContext.STENCIL_BITS),0>=cc.stencilBits&&cc.log("Stencil buffer is not enabled."),cc.ClippingNode.WebGLRenderCmd._init_once=!1)};a.transform=function(a,c){var d=this._node;cc.Node.WebGLRenderCmd.prototype.transform.call(this,a,c);d._stencil&&d._stencil._renderCmd.transform(this,c)};a.visit=function(a){var c=this._node;if(c._visible){if(c._parent&&c._parent._renderCmd&&(this._curLevel=c._parent._renderCmd._curLevel+1),1>cc.stencilBits)return void cc.Node.WebGLRenderCmd.prototype.visit.call(this,
a);if(!c._stencil||!c._stencil.visible)return void(c.inverted&&cc.Node.WebGLRenderCmd.prototype.visit.call(this,a));if(cc.ClippingNode.WebGLRenderCmd._layer+1===cc.stencilBits)return cc.ClippingNode.WebGLRenderCmd._visit_once=!0,cc.ClippingNode.WebGLRenderCmd._visit_once&&(cc.log("Nesting more than "+cc.stencilBits+"stencils is not supported. Everything will be drawn without stencil for this node and its children."),cc.ClippingNode.WebGLRenderCmd._visit_once=!1),void cc.Node.WebGLRenderCmd.prototype.visit.call(this,
a);cc.renderer.pushRenderCommand(this._beforeVisitCmd);var d=cc.current_stack;d.stack.push(d.top);this._syncStatus(a);d.top=this._stackMatrix;c._stencil._renderCmd.visit(this);cc.renderer.pushRenderCommand(this._afterDrawStencilCmd);if((a=c._children)&&0<a.length){var e=a.length;c.sortAllChildren();for(c=0;e>c;c++)a[c]._renderCmd.visit(this)}cc.renderer.pushRenderCommand(this._afterVisitCmd);this._dirtyFlag=0;d.top=d.stack.pop()}};a.setStencil=function(a){var c=this._node;c._stencil&&(c._stencil._parent=
null);c._stencil=a;c._stencil&&(c._stencil._parent=c)};a._drawFullScreenQuadClearStencil=function(){var a=cc.projection_matrix_stack;a.push();a.top.identity();var c=cc.modelview_matrix_stack;c.push();c.top.identity();cc._drawingUtil.drawSolidRect(cc.p(-1,-1),cc.p(1,1),cc.color(255,255,255,255));a.pop();c.pop()};a._onBeforeVisit=function(a){var c=a||cc._renderContext;a=this._node;cc.ClippingNode.WebGLRenderCmd._layer++;var d=1<<cc.ClippingNode.WebGLRenderCmd._layer;if(this._mask_layer_le=d|d-1,this._currentStencilEnabled=
c.isEnabled(c.STENCIL_TEST),this._currentStencilWriteMask=c.getParameter(c.STENCIL_WRITEMASK),this._currentStencilFunc=c.getParameter(c.STENCIL_FUNC),this._currentStencilRef=c.getParameter(c.STENCIL_REF),this._currentStencilValueMask=c.getParameter(c.STENCIL_VALUE_MASK),this._currentStencilFail=c.getParameter(c.STENCIL_FAIL),this._currentStencilPassDepthFail=c.getParameter(c.STENCIL_PASS_DEPTH_FAIL),this._currentStencilPassDepthPass=c.getParameter(c.STENCIL_PASS_DEPTH_PASS),c.enable(c.STENCIL_TEST),
c.stencilMask(d),this._currentDepthWriteMask=c.getParameter(c.DEPTH_WRITEMASK),c.depthMask(!1),c.stencilFunc(c.NEVER,d,d),c.stencilOp(a.inverted?c.REPLACE:c.ZERO,c.KEEP,c.KEEP),this._drawFullScreenQuadClearStencil(),c.stencilFunc(c.NEVER,d,d),c.stencilOp(a.inverted?c.ZERO:c.REPLACE,c.KEEP,c.KEEP),1>a.alphaThreshold)d=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST),c=c.getUniformLocation(d.getProgram(),cc.UNIFORM_ALPHA_TEST_VALUE_S),cc.glUseProgram(d.getProgram()),d.setUniformLocationWith1f(c,
a.alphaThreshold),cc.setProgram(a._stencil,d)};a._onAfterDrawStencil=function(a){a=a||cc._renderContext;a.depthMask(this._currentDepthWriteMask);a.stencilFunc(a.EQUAL,this._mask_layer_le,this._mask_layer_le);a.stencilOp(a.KEEP,a.KEEP,a.KEEP)};a._onAfterVisit=function(a){a=a||cc._renderContext;a.stencilFunc(this._currentStencilFunc,this._currentStencilRef,this._currentStencilValueMask);a.stencilOp(this._currentStencilFail,this._currentStencilPassDepthFail,this._currentStencilPassDepthPass);a.stencilMask(this._currentStencilWriteMask);
this._currentStencilEnabled||a.disable(a.STENCIL_TEST);cc.ClippingNode.WebGLRenderCmd._layer--}}();
cc.GridBase=cc.Class.extend({_active:!1,_reuseGrid:0,_gridSize:null,_texture:null,_step:null,_grabber:null,_isTextureFlipped:!1,_shaderProgram:null,_directorProjection:0,_dirty:!1,ctor:function(a,b,c){cc._checkWebGLRenderMode();this._active=!1;this._reuseGrid=0;this._texture=this._gridSize=null;this._step=cc.p(0,0);this._grabber=null;this._isTextureFlipped=!1;this._shaderProgram=null;this._directorProjection=0;this._dirty=!1;void 0!==a&&this.initWithSize(a,b,c)},isActive:function(){return this._active},
setActive:function(a){if(this._active=a,!a){a=cc.director;var b=a.getProjection();a.setProjection(b)}},getReuseGrid:function(){return this._reuseGrid},setReuseGrid:function(a){this._reuseGrid=a},getGridSize:function(){return cc.size(this._gridSize.width,this._gridSize.height)},setGridSize:function(a){this._gridSize.width=parseInt(a.width);this._gridSize.height=parseInt(a.height)},getStep:function(){return cc.p(this._step.x,this._step.y)},setStep:function(a){this._step.x=a.x;this._step.y=a.y},isTextureFlipped:function(){return this._isTextureFlipped},
setTextureFlipped:function(a){this._isTextureFlipped!==a&&(this._isTextureFlipped=a,this.calculateVertexPoints())},initWithSize:function(a,b,c){if(!b){var d=cc.director.getWinSizeInPixels(),e=cc.NextPOT(d.width),f=cc.NextPOT(d.height),g=new Uint8Array(4*e*f);if(!g)return cc.log("cocos2d: CCGrid: not enough memory."),!1;if(b=new cc.Texture2D,b.initWithData(g,cc.Texture2D.PIXEL_FORMAT_RGBA8888,e,f,d),!b)return cc.log("cocos2d: CCGrid: error creating texture"),!1}return c=c||!1,this._active=!1,this._reuseGrid=
0,this._gridSize=a,this._texture=b,this._isTextureFlipped=c,this._step.x=this._texture.width/a.width,this._step.y=this._texture.height/a.height,this._grabber=new cc.Grabber,this._grabber?(this._grabber.grab(this._texture),this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE),this.calculateVertexPoints(),!0):!1},beforeDraw:function(){this._directorProjection=cc.director.getProjection();this._grabber.beforeRender(this._texture)},afterDraw:function(a){if(this._grabber.afterRender(this._texture),
a&&a.getCamera().isDirty()){var b=a.getAnchorPointInPoints(),c=a._renderCmd._stackMatrix,d=cc.math.Matrix4.createByTranslation(b.x,b.y,0);c.multiply(d);a._camera._locateForRenderer(c);d=cc.math.Matrix4.createByTranslation(-b.x,-b.y,0,d);c.multiply(d)}cc.glBindTexture2D(this._texture);this.beforeBlit();this.blit(a);this.afterBlit()},beforeBlit:function(){},afterBlit:function(){},blit:function(){cc.log("cc.GridBase.blit(): Shall be overridden in subclass.")},reuse:function(){cc.log("cc.GridBase.reuse(): Shall be overridden in subclass.")},
calculateVertexPoints:function(){cc.log("cc.GridBase.calculateVertexPoints(): Shall be overridden in subclass.")},set2DProjection:function(){var a=cc.director.getWinSizeInPixels();cc._renderContext.viewport(0,0,a.width,a.height);cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);cc.kmGLLoadIdentity();a=cc.math.Matrix4.createOrthographicProjection(0,a.width,0,a.height,-1,1);cc.kmGLMultMatrix(a);cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);cc.kmGLLoadIdentity();cc.setProjectionMatrixDirty()}});
cc.GridBase.create=function(a,b,c){return new cc.GridBase(a,b,c)};
cc.Grid3D=cc.GridBase.extend({_texCoordinates:null,_vertices:null,_originalVertices:null,_indices:null,_texCoordinateBuffer:null,_verticesBuffer:null,_indicesBuffer:null,_needDepthTestForBlit:!1,_oldDepthTestValue:!1,_oldDepthWriteValue:!1,ctor:function(a,b,c){cc.GridBase.prototype.ctor.call(this);this._indicesBuffer=this._verticesBuffer=this._texCoordinateBuffer=this._indices=this._originalVertices=this._vertices=this._texCoordinates=null;void 0!==a&&this.initWithSize(a,b,c)},vertex:function(a){return this.getVertex(a)},
getVertex:function(a){(a.x!==(0|a.x)||a.y!==(0|a.y))&&cc.log("cc.Grid3D.vertex() : Numbers must be integers");a=0|3*(a.x*(this._gridSize.height+1)+a.y);var b=this._vertices;return new cc.Vertex3F(b[a],b[a+1],b[a+2])},originalVertex:function(a){return this.getOriginalVertex(a)},getOriginalVertex:function(a){(a.x!==(0|a.x)||a.y!==(0|a.y))&&cc.log("cc.Grid3D.originalVertex() : Numbers must be integers");a=0|3*(a.x*(this._gridSize.height+1)+a.y);var b=this._originalVertices;return new cc.Vertex3F(b[a],
b[a+1],b[a+2])},setVertex:function(a,b){(a.x!==(0|a.x)||a.y!==(0|a.y))&&cc.log("cc.Grid3D.setVertex() : Numbers must be integers");var c=0|3*(a.x*(this._gridSize.height+1)+a.y),d=this._vertices;d[c]=b.x;d[c+1]=b.y;d[c+2]=b.z;this._dirty=!0},beforeBlit:function(){if(this._needDepthTestForBlit){var a=cc._renderContext;this._oldDepthTestValue=a.isEnabled(a.DEPTH_TEST);this._oldDepthWriteValue=a.getParameter(a.DEPTH_WRITEMASK);a.enable(a.DEPTH_TEST);a.depthMask(!0)}},afterBlit:function(){if(this._needDepthTestForBlit){var a=
cc._renderContext;this._oldDepthTestValue?a.enable(a.DEPTH_TEST):a.disable(a.DEPTH_TEST);a.depthMask(this._oldDepthWriteValue)}},blit:function(a){var b=this._gridSize.width*this._gridSize.height;cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION|cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);this._shaderProgram.use();this._shaderProgram._setUniformForMVPMatrixWithMat4(a._renderCmd._stackMatrix);a=cc._renderContext;var c=this._dirty;a.bindBuffer(a.ARRAY_BUFFER,this._verticesBuffer);c&&a.bufferData(a.ARRAY_BUFFER,
this._vertices,a.DYNAMIC_DRAW);a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,3,a.FLOAT,!1,0,0);a.bindBuffer(a.ARRAY_BUFFER,this._texCoordinateBuffer);c&&a.bufferData(a.ARRAY_BUFFER,this._texCoordinates,a.DYNAMIC_DRAW);a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,a.FLOAT,!1,0,0);a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this._indicesBuffer);c&&a.bufferData(a.ELEMENT_ARRAY_BUFFER,this._indices,a.STATIC_DRAW);a.drawElements(a.TRIANGLES,6*b,a.UNSIGNED_SHORT,0);c&&(this._dirty=!1);cc.incrementGLDraws(1)},
reuse:function(){if(0<this._reuseGrid){for(var a=this._originalVertices,b=this._vertices,c=0,d=this._vertices.length;d>c;c++)a[c]=b[c];--this._reuseGrid}},calculateVertexPoints:function(){var a=cc._renderContext,b=this._texture.pixelsWidth,c=this._texture.pixelsHeight,d=this._texture.getContentSizeInPixels().height,e=this._gridSize,f=(e.width+1)*(e.height+1);this._vertices=new Float32Array(3*f);this._texCoordinates=new Float32Array(2*f);this._indices=new Uint16Array(6*e.width*e.height);this._verticesBuffer&&
a.deleteBuffer(this._verticesBuffer);this._verticesBuffer=a.createBuffer();this._texCoordinateBuffer&&a.deleteBuffer(this._texCoordinateBuffer);this._texCoordinateBuffer=a.createBuffer();this._indicesBuffer&&a.deleteBuffer(this._indicesBuffer);this._indicesBuffer=a.createBuffer();for(var g,h,k=this._indices,m=this._texCoordinates,n=this._isTextureFlipped,p=this._vertices,f=0;f<e.width;++f)for(g=0;g<e.height;++g){var r=g*e.width+f;h=f*this._step.x;var s=h+this._step.x,v=g*this._step.y,u=v+this._step.y,
t=f*(e.height+1)+g,x=(f+1)*(e.height+1)+g,A=(f+1)*(e.height+1)+(g+1),F=f*(e.height+1)+(g+1);k[6*r]=t;k[6*r+1]=x;k[6*r+2]=F;k[6*r+3]=x;k[6*r+4]=A;k[6*r+5]=F;var r=[3*t,3*x,3*A,3*F],z=[{x:h,y:v,z:0},{x:s,y:v,z:0},{x:s,y:u,z:0},{x:h,y:u,z:0}],t=[2*t,2*x,2*A,2*F],s=[cc.p(h,v),cc.p(s,v),cc.p(s,u),cc.p(h,u)];for(h=0;4>h;++h)p[r[h]]=z[h].x,p[r[h]+1]=z[h].y,p[r[h]+2]=z[h].z,m[t[h]]=s[h].x/b,n?m[t[h]+1]=(d-s[h].y)/c:m[t[h]+1]=s[h].y/c}this._originalVertices=new Float32Array(this._vertices);a.bindBuffer(a.ARRAY_BUFFER,
this._verticesBuffer);a.bufferData(a.ARRAY_BUFFER,this._vertices,a.DYNAMIC_DRAW);a.bindBuffer(a.ARRAY_BUFFER,this._texCoordinateBuffer);a.bufferData(a.ARRAY_BUFFER,this._texCoordinates,a.DYNAMIC_DRAW);a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this._indicesBuffer);a.bufferData(a.ELEMENT_ARRAY_BUFFER,this._indices,a.STATIC_DRAW);this._dirty=!0},setNeedDepthTestForBlit:function(a){this._needDepthTestForBlit=a},getNeedDepthTestForBlit:function(){return this._needDepthTestForBlit}});
cc.Grid3D.create=function(a,b,c){return new cc.Grid3D(a,b,c)};
cc.TiledGrid3D=cc.GridBase.extend({_texCoordinates:null,_vertices:null,_originalVertices:null,_indices:null,_texCoordinateBuffer:null,_verticesBuffer:null,_indicesBuffer:null,ctor:function(a,b,c){cc.GridBase.prototype.ctor.call(this);this._indicesBuffer=this._verticesBuffer=this._texCoordinateBuffer=this._indices=this._originalVertices=this._vertices=this._texCoordinates=null;void 0!==a&&this.initWithSize(a,b,c)},tile:function(a){return this.getTile(a)},getTile:function(a){(a.x!==(0|a.x)||a.y!==(0|
a.y))&&cc.log("cc.TiledGrid3D.tile() : Numbers must be integers");a=12*(this._gridSize.height*a.x+a.y);var b=this._vertices;return new cc.Quad3(new cc.Vertex3F(b[a],b[a+1],b[a+2]),new cc.Vertex3F(b[a+3],b[a+4],b[a+5]),new cc.Vertex3F(b[a+6],b[a+7],b[a+8]),new cc.Vertex3F(b[a+9],b[a+10],b[a+11]))},getOriginalTile:function(a){(a.x!==(0|a.x)||a.y!==(0|a.y))&&cc.log("cc.TiledGrid3D.originalTile() : Numbers must be integers");a=12*(this._gridSize.height*a.x+a.y);var b=this._originalVertices;return new cc.Quad3(new cc.Vertex3F(b[a],
b[a+1],b[a+2]),new cc.Vertex3F(b[a+3],b[a+4],b[a+5]),new cc.Vertex3F(b[a+6],b[a+7],b[a+8]),new cc.Vertex3F(b[a+9],b[a+10],b[a+11]))},originalTile:function(a){return this.getOriginalTile(a)},setTile:function(a,b){(a.x!==(0|a.x)||a.y!==(0|a.y))&&cc.log("cc.TiledGrid3D.setTile() : Numbers must be integers");var c=12*(this._gridSize.height*a.x+a.y),d=this._vertices;d[c]=b.bl.x;d[c+1]=b.bl.y;d[c+2]=b.bl.z;d[c+3]=b.br.x;d[c+4]=b.br.y;d[c+5]=b.br.z;d[c+6]=b.tl.x;d[c+7]=b.tl.y;d[c+8]=b.tl.z;d[c+9]=b.tr.x;
d[c+10]=b.tr.y;d[c+11]=b.tr.z;this._dirty=!0},blit:function(a){var b=this._gridSize.width*this._gridSize.height;this._shaderProgram.use();this._shaderProgram._setUniformForMVPMatrixWithMat4(a._renderCmd._stackMatrix);a=cc._renderContext;var c=this._dirty;cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION|cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);a.bindBuffer(a.ARRAY_BUFFER,this._verticesBuffer);c&&a.bufferData(a.ARRAY_BUFFER,this._vertices,a.DYNAMIC_DRAW);a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,
3,a.FLOAT,!1,0,this._vertices);a.bindBuffer(a.ARRAY_BUFFER,this._texCoordinateBuffer);c&&a.bufferData(a.ARRAY_BUFFER,this._texCoordinates,a.DYNAMIC_DRAW);a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,a.FLOAT,!1,0,this._texCoordinates);a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this._indicesBuffer);c&&a.bufferData(a.ELEMENT_ARRAY_BUFFER,this._indices,a.STATIC_DRAW);a.drawElements(a.TRIANGLES,6*b,a.UNSIGNED_SHORT,0);c&&(this._dirty=!1);cc.incrementGLDraws(1)},reuse:function(){if(0<this._reuseGrid){for(var a=
this._vertices,b=this._originalVertices,c=0;c<a.length;c++)b[c]=a[c];--this._reuseGrid}},calculateVertexPoints:function(){var a=this._texture.pixelsWidth,b=this._texture.pixelsHeight,c=this._texture.getContentSizeInPixels().height,d=this._gridSize,e=d.width*d.height;this._vertices=new Float32Array(12*e);this._texCoordinates=new Float32Array(8*e);this._indices=new Uint16Array(6*e);var f=cc._renderContext;this._verticesBuffer&&f.deleteBuffer(this._verticesBuffer);this._verticesBuffer=f.createBuffer();
this._texCoordinateBuffer&&f.deleteBuffer(this._texCoordinateBuffer);this._texCoordinateBuffer=f.createBuffer();this._indicesBuffer&&f.deleteBuffer(this._indicesBuffer);this._indicesBuffer=f.createBuffer();var g,h,k=0,m=this._step,n=this._vertices,p=this._texCoordinates,r=this._isTextureFlipped;for(g=0;g<d.width;g++)for(h=0;h<d.height;h++){var s=g*m.x,v=s+m.x,u=h*m.y,t=u+m.y;n[12*k]=s;n[12*k+1]=u;n[12*k+2]=0;n[12*k+3]=v;n[12*k+4]=u;n[12*k+5]=0;n[12*k+6]=s;n[12*k+7]=t;n[12*k+8]=0;n[12*k+9]=v;n[12*
k+10]=t;n[12*k+11]=0;var x=u,A=t;r&&(x=c-u,A=c-t);p[8*k]=s/a;p[8*k+1]=x/b;p[8*k+2]=v/a;p[8*k+3]=x/b;p[8*k+4]=s/a;p[8*k+5]=A/b;p[8*k+6]=v/a;p[8*k+7]=A/b;k++}a=this._indices;for(g=0;e>g;g++)a[6*g+0]=4*g+0,a[6*g+1]=4*g+1,a[6*g+2]=4*g+2,a[6*g+3]=4*g+1,a[6*g+4]=4*g+2,a[6*g+5]=4*g+3;this._originalVertices=new Float32Array(this._vertices);f.bindBuffer(f.ARRAY_BUFFER,this._verticesBuffer);f.bufferData(f.ARRAY_BUFFER,this._vertices,f.DYNAMIC_DRAW);f.bindBuffer(f.ARRAY_BUFFER,this._texCoordinateBuffer);f.bufferData(f.ARRAY_BUFFER,
this._texCoordinates,f.DYNAMIC_DRAW);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,this._indicesBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,this._indices,f.DYNAMIC_DRAW);this._dirty=!0}});cc.TiledGrid3D.create=function(a,b,c){return new cc.TiledGrid3D(a,b,c)};
cc.Grabber=cc.Class.extend({_FBO:null,_oldFBO:null,_oldClearColor:null,_gl:null,ctor:function(){cc._checkWebGLRenderMode();this._gl=cc._renderContext;this._oldClearColor=[0,0,0,0];this._oldFBO=null;this._FBO=this._gl.createFramebuffer()},grab:function(a){var b=this._gl;this._oldFBO=b.getParameter(b.FRAMEBUFFER_BINDING);b.bindFramebuffer(b.FRAMEBUFFER,this._FBO);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,a._webTextureObj,0);b.checkFramebufferStatus(b.FRAMEBUFFER)!==b.FRAMEBUFFER_COMPLETE&&
cc.log("Frame Grabber: could not attach texture to frmaebuffer");b.bindFramebuffer(b.FRAMEBUFFER,this._oldFBO)},beforeRender:function(a){a=this._gl;this._oldFBO=a.getParameter(a.FRAMEBUFFER_BINDING);a.bindFramebuffer(a.FRAMEBUFFER,this._FBO);this._oldClearColor=a.getParameter(a.COLOR_CLEAR_VALUE);a.clearColor(0,0,0,0);a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT)},afterRender:function(a){a=this._gl;a.bindFramebuffer(a.FRAMEBUFFER,this._oldFBO);a.colorMask(!0,!0,!0,!0)},destroy:function(){this._gl.deleteFramebuffer(this._FBO)}});
cc.GridAction=cc.ActionInterval.extend({_gridSize:null,_gridNodeTarget:null,ctor:function(a,b){cc._checkWebGLRenderMode();cc.ActionInterval.prototype.ctor.call(this);this._gridSize=cc.size(0,0);b&&this.initWithDuration(a,b)},_cacheTargetAsGridNode:function(){},clone:function(){var a=new cc.GridAction,b=this._gridSize;return a.initWithDuration(this._duration,cc.size(b.width,b.height)),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);cc.renderer.childrenOrderDirty=
!0;var b=this.getGrid(),c=this.target;(a=c.grid)&&0<a.getReuseGrid()?(b=a.getGridSize(),a.isActive()&&b.width===this._gridSize.width&&b.height===this._gridSize.height&&a.reuse()):(a&&a.isActive()&&a.setActive(!1),c.grid=b,c.grid.setActive(!0))},reverse:function(){return new cc.ReverseTime(this)},initWithDuration:function(a,b){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._gridSize.width=b.width,this._gridSize.height=b.height,!0):!1},getGrid:function(){cc.log("cc.GridAction.getGrid(): it should be overridden in subclass.")}});
cc.gridAction=function(a,b){return new cc.GridAction(a,b)};cc.GridAction.create=cc.gridAction;cc.Grid3DAction=cc.GridAction.extend({getGrid:function(){return new cc.Grid3D(this._gridSize)},vertex:function(a){return this.getVertex(a)},getVertex:function(a){return this.target.grid.getVertex(a)},originalVertex:function(a){return this.getOriginalVertex(a)},getOriginalVertex:function(a){return this.target.grid.originalVertex(a)},setVertex:function(a,b){this.target.grid.setVertex(a,b)}});
cc.grid3DAction=function(a,b){return new cc.Grid3DAction(a,b)};cc.Grid3DAction.create=cc.grid3DAction;cc.TiledGrid3DAction=cc.GridAction.extend({tile:function(a){return this.getTile(a)},getTile:function(a){return this.target.grid.tile(a)},originalTile:function(a){return this.getOriginalTile(a)},getOriginalTile:function(a){return this.target.grid.originalTile(a)},setTile:function(a,b){this.target.grid.setTile(a,b)},getGrid:function(){return new cc.TiledGrid3D(this._gridSize)}});
cc.tiledGrid3DAction=function(a,b){return new cc.TiledGrid3DAction(a,b)};cc.TiledGrid3DAction.create=cc.tiledGrid3DAction;cc.StopGrid=cc.ActionInstant.extend({startWithTarget:function(a){cc.ActionInstant.prototype.startWithTarget.call(this,a);cc.renderer.childrenOrderDirty=!0;(a=this.target.grid)&&a.isActive()&&a.setActive(!1)}});cc.stopGrid=function(){return new cc.StopGrid};cc.StopGrid.create=cc.stopGrid;
cc.ReuseGrid=cc.ActionInstant.extend({_times:null,ctor:function(a){cc.ActionInstant.prototype.ctor.call(this);void 0!==a&&this.initWithTimes(a)},initWithTimes:function(a){return this._times=a,!0},startWithTarget:function(a){cc.ActionInstant.prototype.startWithTarget.call(this,a);cc.renderer.childrenOrderDirty=!0;this.target.grid&&this.target.grid.isActive()&&this.target.grid.setReuseGrid(this.target.grid.getReuseGrid()+this._times)}});cc.reuseGrid=function(a){return new cc.ReuseGrid(a)};
cc.ReuseGrid.create=cc.reuseGrid;
cc.Waves3D=cc.Grid3DAction.extend({_waves:0,_amplitude:0,_amplitudeRate:0,ctor:function(a,b,c,d){cc.GridAction.prototype.ctor.call(this);void 0!==d&&this.initWithDuration(a,b,c,d)},getAmplitude:function(){return this._amplitude},setAmplitude:function(a){this._amplitude=a},getAmplitudeRate:function(){return this._amplitudeRate},setAmplitudeRate:function(a){this._amplitudeRate=a},initWithDuration:function(a,b,c,d){return cc.Grid3DAction.prototype.initWithDuration.call(this,a,b)?(this._waves=c,this._amplitude=
d,this._amplitudeRate=1,!0):!1},update:function(a){for(var b=this._gridSize,c=this._amplitude,d=cc.p(0,0),e=this._amplitudeRate,f=this._waves,g=0;g<b.width+1;++g)for(var h=0;h<b.height+1;++h){d.x=g;d.y=h;var k=this.originalVertex(d);k.z+=Math.sin(2*Math.PI*a*f+0.01*(k.y+k.x))*c*e;this.setVertex(d,k)}}});cc.waves3D=function(a,b,c,d){return new cc.Waves3D(a,b,c,d)};cc.Waves3D.create=cc.waves3D;
cc.FlipX3D=cc.Grid3DAction.extend({ctor:function(a){void 0!==a?cc.GridAction.prototype.ctor.call(this,a,cc.size(1,1)):cc.GridAction.prototype.ctor.call(this)},initWithDuration:function(a){return cc.Grid3DAction.prototype.initWithDuration.call(this,a,cc.size(1,1))},initWithSize:function(a,b){return 1!==a.width||1!==a.height?(cc.log("Grid size must be (1,1)"),!1):cc.Grid3DAction.prototype.initWithDuration.call(this,b,a)},update:function(a){var b=Math.PI*a;a=Math.sin(b);var c=Math.cos(b/2),b=new cc.Vertex3F,
d=cc.p(0,0);d.x=d.y=1;var e=this.originalVertex(d);d.x=d.y=0;var f,g,h,k,m,d=this.originalVertex(d),e=e.x,d=d.x;e>d?(g=cc.p(0,0),h=cc.p(0,1),k=cc.p(1,0),m=cc.p(1,1),f=e):(k=cc.p(0,0),m=cc.p(0,1),g=cc.p(1,0),h=cc.p(1,1),f=d);b.x=f-f*c;b.z=Math.abs(parseFloat(f*a/4));f=this.originalVertex(g);f.x=b.x;f.z+=b.z;this.setVertex(g,f);f=this.originalVertex(h);f.x=b.x;f.z+=b.z;this.setVertex(h,f);f=this.originalVertex(k);f.x-=b.x;f.z-=b.z;this.setVertex(k,f);f=this.originalVertex(m);f.x-=b.x;f.z-=b.z;this.setVertex(m,
f)}});cc.flipX3D=function(a){return new cc.FlipX3D(a)};cc.FlipX3D.create=cc.flipX3D;
cc.FlipY3D=cc.FlipX3D.extend({ctor:function(a){void 0!==a?cc.GridAction.prototype.ctor.call(this,a,cc.size(1,1)):cc.GridAction.prototype.ctor.call(this)},update:function(a){var b=Math.PI*a;a=Math.sin(b);var c=Math.cos(b/2),b=new cc.Vertex3F,d=cc.p(0,0);d.x=d.y=1;var e=this.originalVertex(d);d.x=d.y=0;var f,g,h,k,m,d=this.originalVertex(d),e=e.y,d=d.y;e>d?(g=cc.p(0,0),h=cc.p(0,1),k=cc.p(1,0),m=cc.p(1,1),f=e):(h=cc.p(0,0),g=cc.p(0,1),m=cc.p(1,0),k=cc.p(1,1),f=d);b.y=f-f*c;b.z=Math.abs(parseFloat(f*
a)/4);f=this.originalVertex(g);f.y=b.y;f.z+=b.z;this.setVertex(g,f);f=this.originalVertex(h);f.y-=b.y;f.z-=b.z;this.setVertex(h,f);f=this.originalVertex(k);f.y=b.y;f.z+=b.z;this.setVertex(k,f);f=this.originalVertex(m);f.y-=b.y;f.z-=b.z;this.setVertex(m,f)}});cc.flipY3D=function(a){return new cc.FlipY3D(a)};cc.FlipY3D.create=cc.flipY3D;
cc.Lens3D=cc.Grid3DAction.extend({_position:null,_radius:0,_lensEffect:0,_concave:!1,_dirty:!1,ctor:function(a,b,c,d){cc.GridAction.prototype.ctor.call(this);this._position=cc.p(0,0);void 0!==d&&this.initWithDuration(a,b,c,d)},getLensEffect:function(){return this._lensEffect},setLensEffect:function(a){this._lensEffect=a},setConcave:function(a){this._concave=a},getPosition:function(){return this._position},setPosition:function(a){cc.pointEqualToPoint(a,this._position)||(this._position.x=a.x,this._position.y=
a.y,this._dirty=!0)},initWithDuration:function(a,b,c,d){return cc.Grid3DAction.prototype.initWithDuration.call(this,a,b)?(this.setPosition(c),this._radius=d,this._lensEffect=0.7,this._dirty=!0,!0):!1},update:function(a){if(this._dirty){for(var b,c,d,e,f=this._gridSize.width,g=this._gridSize.height,h=this._radius,k=this._lensEffect,m=cc.p(0,0),n=cc.p(0,0),p=0;f+1>p;++p)for(var r=0;g+1>r;++r)m.x=p,m.y=r,a=this.originalVertex(m),n.x=this._position.x-a.x,n.y=this._position.y-a.y,b=cc.pLength(n),h>b&&
(b=h-b,e=b/h,0===e&&(e=0.001),c=Math.log(e)*k,d=Math.exp(c)*h,b=cc.pLength(n),0<b&&(n.x/=b,n.y/=b,n.x*=d,n.y*=d,a.z+=cc.pLength(n)*k)),this.setVertex(m,a);this._dirty=!1}}});cc.lens3D=function(a,b,c,d){return new cc.Lens3D(a,b,c,d)};cc.Lens3D.create=cc.lens3D;
cc.Ripple3D=cc.Grid3DAction.extend({_position:null,_radius:0,_waves:0,_amplitude:0,_amplitudeRate:0,ctor:function(a,b,c,d,e,f){cc.GridAction.prototype.ctor.call(this);this._position=cc.p(0,0);void 0!==f&&this.initWithDuration(a,b,c,d,e,f)},getPosition:function(){return this._position},setPosition:function(a){this._position.x=a.x;this._position.y=a.y},getAmplitude:function(){return this._amplitude},setAmplitude:function(a){this._amplitude=a},getAmplitudeRate:function(){return this._amplitudeRate},
setAmplitudeRate:function(a){this._amplitudeRate=a},initWithDuration:function(a,b,c,d,e,f){return cc.Grid3DAction.prototype.initWithDuration.call(this,a,b)?(this.setPosition(c),this._radius=d,this._waves=e,this._amplitude=f,this._amplitudeRate=1,!0):!1},update:function(a){for(var b,c,d=this._gridSize.width,e=this._gridSize.height,f=cc.p(0,0),g=this._radius,h=this._waves,k=this._amplitude,m=this._amplitudeRate,n=cc.p(0,0),p=0;d+1>p;++p)for(var r=0;e+1>r;++r){if(f.x=p,f.y=r,b=this.originalVertex(f),
n.x=this._position.x-b.x,n.y=this._position.y-b.y,c=cc.pLength(n),g>c){c=g-c;var s=Math.pow(c/g,2);b.z+=Math.sin(2*a*Math.PI*h+0.1*c)*k*m*s}this.setVertex(f,b)}}});cc.ripple3D=function(a,b,c,d,e,f){return new cc.Ripple3D(a,b,c,d,e,f)};cc.Ripple3D.create=cc.ripple3D;
cc.Shaky3D=cc.Grid3DAction.extend({_randRange:0,_shakeZ:!1,ctor:function(a,b,c,d){cc.GridAction.prototype.ctor.call(this);void 0!==d&&this.initWithDuration(a,b,c,d)},initWithDuration:function(a,b,c,d){return cc.Grid3DAction.prototype.initWithDuration.call(this,a,b)?(this._randRange=c,this._shakeZ=d,!0):!1},update:function(a){for(var b=this._gridSize.width,c=this._gridSize.height,d=this._randRange,e=this._shakeZ,f=cc.p(0,0),g=0;b+1>g;++g)for(var h=0;c+1>h;++h)f.x=g,f.y=h,a=this.originalVertex(f),a.x+=
cc.rand()%(2*d)-d,a.y+=cc.rand()%(2*d)-d,e&&(a.z+=cc.rand()%(2*d)-d),this.setVertex(f,a)}});cc.shaky3D=function(a,b,c,d){return new cc.Shaky3D(a,b,c,d)};cc.Shaky3D.create=cc.shaky3D;
cc.Liquid=cc.Grid3DAction.extend({_waves:0,_amplitude:0,_amplitudeRate:0,ctor:function(a,b,c,d){cc.GridAction.prototype.ctor.call(this);void 0!==d&&this.initWithDuration(a,b,c,d)},getAmplitude:function(){return this._amplitude},setAmplitude:function(a){this._amplitude=a},getAmplitudeRate:function(){return this._amplitudeRate},setAmplitudeRate:function(a){this._amplitudeRate=a},initWithDuration:function(a,b,c,d){return cc.Grid3DAction.prototype.initWithDuration.call(this,a,b)?(this._waves=c,this._amplitude=
d,this._amplitudeRate=1,!0):!1},update:function(a){for(var b,c=this._gridSize.width,d=this._gridSize.height,e=cc.p(0,0),f=this._waves,g=this._amplitude,h=this._amplitudeRate,k=1;c>k;++k)for(var m=1;d>m;++m)e.x=k,e.y=m,b=this.originalVertex(e),b.x+=Math.sin(2*a*Math.PI*f+0.01*b.x)*g*h,b.y+=Math.sin(2*a*Math.PI*f+0.01*b.y)*g*h,this.setVertex(e,b)}});cc.liquid=function(a,b,c,d){return new cc.Liquid(a,b,c,d)};cc.Liquid.create=cc.liquid;
cc.Waves=cc.Grid3DAction.extend({_waves:0,_amplitude:0,_amplitudeRate:0,_vertical:!1,_horizontal:!1,ctor:function(a,b,c,d,e,f){cc.GridAction.prototype.ctor.call(this);void 0!==f&&this.initWithDuration(a,b,c,d,e,f)},getAmplitude:function(){return this._amplitude},setAmplitude:function(a){this._amplitude=a},getAmplitudeRate:function(){return this._amplitudeRate},setAmplitudeRate:function(a){this._amplitudeRate=a},initWithDuration:function(a,b,c,d,e,f){return cc.Grid3DAction.prototype.initWithDuration.call(this,
a,b)?(this._waves=c,this._amplitude=d,this._amplitudeRate=1,this._horizontal=e,this._vertical=f,!0):!1},update:function(a){for(var b,c=this._gridSize.width,d=this._gridSize.height,e=cc.p(0,0),f=this._vertical,g=this._horizontal,h=this._waves,k=this._amplitude,m=this._amplitudeRate,n=0;c+1>n;++n)for(var p=0;d+1>p;++p)e.x=n,e.y=p,b=this.originalVertex(e),f&&(b.x+=Math.sin(2*a*Math.PI*h+0.01*b.y)*k*m),g&&(b.y+=Math.sin(2*a*Math.PI*h+0.01*b.x)*k*m),this.setVertex(e,b)}});
cc.waves=function(a,b,c,d,e,f){return new cc.Waves(a,b,c,d,e,f)};cc.Waves.create=cc.waves;
cc.Twirl=cc.Grid3DAction.extend({_position:null,_twirls:0,_amplitude:0,_amplitudeRate:0,ctor:function(a,b,c,d,e){cc.GridAction.prototype.ctor.call(this);this._position=cc.p(0,0);void 0!==e&&this.initWithDuration(a,b,c,d,e)},getPosition:function(){return this._position},setPosition:function(a){this._position.x=a.x;this._position.y=a.y},getAmplitude:function(){return this._amplitude},setAmplitude:function(a){this._amplitude=a},getAmplitudeRate:function(){return this._amplitudeRate},setAmplitudeRate:function(a){this._amplitudeRate=
a},initWithDuration:function(a,b,c,d,e){return cc.Grid3DAction.prototype.initWithDuration.call(this,a,b)?(this.setPosition(c),this._twirls=d,this._amplitude=e,this._amplitudeRate=1,!0):!1},update:function(a){for(var b,c,d,e=this._position,f=this._gridSize.width,g=this._gridSize.height,h=cc.p(0,0),k=0.1*this._amplitude*this._amplitudeRate,m=this._twirls,n=cc.p(0,0),p=0;f+1>p;++p)for(var r=0;g+1>r;++r)h.x=p,h.y=r,b=this.originalVertex(h),n.x=p-f/2,n.y=r-g/2,c=cc.pLength(n)*Math.cos(Math.PI/2+2*a*Math.PI*
m)*k,d=Math.sin(c)*(b.y-e.y)+Math.cos(c)*(b.x-e.x),c=Math.cos(c)*(b.y-e.y)-Math.sin(c)*(b.x-e.x),b.x=e.x+d,b.y=e.y+c,this.setVertex(h,b)}});cc.twirl=function(a,b,c,d,e){return new cc.Twirl(a,b,c,d,e)};cc.Twirl.create=cc.twirl;
cc.ShakyTiles3D=cc.TiledGrid3DAction.extend({_randRange:0,_shakeZ:!1,ctor:function(a,b,c,d){cc.GridAction.prototype.ctor.call(this);void 0!==d&&this.initWithDuration(a,b,c,d)},initWithDuration:function(a,b,c,d){return cc.TiledGrid3DAction.prototype.initWithDuration.call(this,a,b)?(this._randRange=c,this._shakeZ=d,!0):!1},update:function(a){a=this._gridSize;for(var b=this._randRange,c=cc.p(0,0),d=0;d<a.width;++d)for(var e=0;e<a.height;++e){c.x=d;c.y=e;var f=this.originalTile(c);f.bl.x+=cc.rand()%(2*
b)-b;f.br.x+=cc.rand()%(2*b)-b;f.tl.x+=cc.rand()%(2*b)-b;f.tr.x+=cc.rand()%(2*b)-b;f.bl.y+=cc.rand()%(2*b)-b;f.br.y+=cc.rand()%(2*b)-b;f.tl.y+=cc.rand()%(2*b)-b;f.tr.y+=cc.rand()%(2*b)-b;this._shakeZ&&(f.bl.z+=cc.rand()%(2*b)-b,f.br.z+=cc.rand()%(2*b)-b,f.tl.z+=cc.rand()%(2*b)-b,f.tr.z+=cc.rand()%(2*b)-b);this.setTile(c,f)}}});cc.shakyTiles3D=function(a,b,c,d){return new cc.ShakyTiles3D(a,b,c,d)};cc.ShakyTiles3D.create=cc.shakyTiles3D;
cc.ShatteredTiles3D=cc.TiledGrid3DAction.extend({_randRange:0,_once:!1,_shatterZ:!1,ctor:function(a,b,c,d){cc.GridAction.prototype.ctor.call(this);void 0!==d&&this.initWithDuration(a,b,c,d)},initWithDuration:function(a,b,c,d){return cc.TiledGrid3DAction.prototype.initWithDuration.call(this,a,b)?(this._once=!1,this._randRange=c,this._shatterZ=d,!0):!1},update:function(a){if(!1===this._once){for(var b=this._gridSize,c=this._randRange,d=cc.p(0,0),e=0;e<b.width;++e)for(var f=0;f<b.height;++f)d.x=e,d.y=
f,a=this.originalTile(d),a.bl.x+=cc.rand()%(2*c)-c,a.br.x+=cc.rand()%(2*c)-c,a.tl.x+=cc.rand()%(2*c)-c,a.tr.x+=cc.rand()%(2*c)-c,a.bl.y+=cc.rand()%(2*c)-c,a.br.y+=cc.rand()%(2*c)-c,a.tl.y+=cc.rand()%(2*c)-c,a.tr.y+=cc.rand()%(2*c)-c,this._shatterZ&&(a.bl.z+=cc.rand()%(2*c)-c,a.br.z+=cc.rand()%(2*c)-c,a.tl.z+=cc.rand()%(2*c)-c,a.tr.z+=cc.rand()%(2*c)-c),this.setTile(d,a);this._once=!0}}});cc.shatteredTiles3D=function(a,b,c,d){return new cc.ShatteredTiles3D(a,b,c,d)};cc.ShatteredTiles3D.create=cc.shatteredTiles3D;
cc.Tile=function(a,b,c){this.position=a||cc.p(0,0);this.startPosition=b||cc.p(0,0);this.delta=c||cc.p(0,0)};
cc.ShuffleTiles=cc.TiledGrid3DAction.extend({_seed:0,_tilesCount:0,_tilesOrder:null,_tiles:null,ctor:function(a,b,c){cc.GridAction.prototype.ctor.call(this);this._tilesOrder=[];this._tiles=[];void 0!==c&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){return cc.TiledGrid3DAction.prototype.initWithDuration.call(this,a,b)?(this._seed=c,this._tilesOrder.length=0,this._tiles.length=0,!0):!1},shuffle:function(a,b){for(var c=b-1;0<=c;c--){var d=0|cc.rand()%(c+1),e=a[c];a[c]=a[d];a[d]=e}},
getDelta:function(a){var b=this._gridSize,c=a.width*b.height+a.height;return cc.size(this._tilesOrder[c]/b.height-a.width,this._tilesOrder[c]%b.height-a.height)},placeTile:function(a,b){var c=this.originalTile(a),d=this.target.grid.getStep(),e=b.position;c.bl.x+=e.x*d.x;c.bl.y+=e.y*d.y;c.br.x+=e.x*d.x;c.br.y+=e.y*d.y;c.tl.x+=e.x*d.x;c.tl.y+=e.y*d.y;c.tr.x+=e.x*d.x;c.tr.y+=e.y*d.y;this.setTile(a,c)},startWithTarget:function(a){cc.TiledGrid3DAction.prototype.startWithTarget.call(this,a);a=this._gridSize;
this._tilesCount=a.width*a.height;for(var b=this._tilesOrder,c=b.length=0;c<this._tilesCount;++c)b[c]=c;this.shuffle(b,this._tilesCount);for(var b=this._tiles,c=b.length=0,d=cc.size(0,0),e=0;e<a.width;++e)for(var f=0;f<a.height;++f)b[c]=new cc.Tile,b[c].position=cc.p(e,f),b[c].startPosition=cc.p(e,f),d.width=e,d.height=f,b[c].delta=this.getDelta(d),++c},update:function(a){for(var b,c=0,d=this._gridSize,e=this._tiles,f=cc.p(0,0),g=0;g<d.width;++g)for(var h=0;h<d.height;++h)f.x=g,f.y=h,b=e[c],b.position.x=
b.delta.width*a,b.position.y=b.delta.height*a,this.placeTile(f,b),++c}});cc.shuffleTiles=function(a,b,c){return new cc.ShuffleTiles(a,b,c)};cc.ShuffleTiles.create=cc.shuffleTiles;
cc.FadeOutTRTiles=cc.TiledGrid3DAction.extend({testFunc:function(a,b){var c=this._gridSize.width*b,d=this._gridSize.height*b;return 0===c+d?1:Math.pow((a.width+a.height)/(c+d),6)},turnOnTile:function(a){this.setTile(a,this.originalTile(a))},turnOffTile:function(a){this.setTile(a,new cc.Quad3)},transformTile:function(a,b){var c=this.originalTile(a),d=this.target.grid.getStep();c.bl.x+=d.x/2*(1-b);c.bl.y+=d.y/2*(1-b);c.br.x-=d.x/2*(1-b);c.br.y+=d.y/2*(1-b);c.tl.x+=d.x/2*(1-b);c.tl.y-=d.y/2*(1-b);c.tr.x-=
d.x/2*(1-b);c.tr.y-=d.y/2*(1-b);this.setTile(a,c)},update:function(a){for(var b,c=this._gridSize,d=cc.p(0,0),e=cc.size(0,0),f=0;f<c.width;++f)for(var g=0;g<c.height;++g)d.x=f,d.y=g,e.width=f,e.height=g,b=this.testFunc(e,a),0===b?this.turnOffTile(d):1>b?this.transformTile(d,b):this.turnOnTile(d)}});cc.fadeOutTRTiles=function(a,b){return new cc.FadeOutTRTiles(a,b)};cc.FadeOutTRTiles.create=cc.fadeOutTRTiles;
cc.FadeOutBLTiles=cc.FadeOutTRTiles.extend({testFunc:function(a,b){var c=this._gridSize.width*(1-b),d=this._gridSize.height*(1-b);return 0===a.width+a.height?1:Math.pow((c+d)/(a.width+a.height),6)}});cc.fadeOutBLTiles=function(a,b){return new cc.FadeOutBLTiles(a,b)};cc.FadeOutBLTiles.create=cc.fadeOutBLTiles;
cc.FadeOutUpTiles=cc.FadeOutTRTiles.extend({testFunc:function(a,b){var c=this._gridSize.height*b;return 0===c?1:Math.pow(a.height/c,6)},transformTile:function(a,b){var c=this.originalTile(a),d=this.target.grid.getStep();c.bl.y+=d.y/2*(1-b);c.br.y+=d.y/2*(1-b);c.tl.y-=d.y/2*(1-b);c.tr.y-=d.y/2*(1-b);this.setTile(a,c)}});cc.fadeOutUpTiles=function(a,b){return new cc.FadeOutUpTiles(a,b)};cc.FadeOutUpTiles.create=cc.fadeOutUpTiles;
cc.FadeOutDownTiles=cc.FadeOutUpTiles.extend({testFunc:function(a,b){var c=this._gridSize.height*(1-b);return 0===a.height?1:Math.pow(c/a.height,6)}});cc.fadeOutDownTiles=function(a,b){return new cc.FadeOutDownTiles(a,b)};cc.FadeOutDownTiles.create=cc.fadeOutDownTiles;
cc.TurnOffTiles=cc.TiledGrid3DAction.extend({_seed:null,_tilesCount:0,_tilesOrder:null,ctor:function(a,b,c){cc.GridAction.prototype.ctor.call(this);this._tilesOrder=[];void 0!==b&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){return cc.TiledGrid3DAction.prototype.initWithDuration.call(this,a,b)?(this._seed=c||0,this._tilesOrder.length=0,!0):!1},shuffle:function(a,b){for(var c=b-1;0<=c;c--){var d=0|cc.rand()%(c+1),e=a[c];a[c]=a[d];a[d]=e}},turnOnTile:function(a){this.setTile(a,this.originalTile(a))},
turnOffTile:function(a){this.setTile(a,new cc.Quad3)},startWithTarget:function(a){cc.TiledGrid3DAction.prototype.startWithTarget.call(this,a);this._tilesCount=this._gridSize.width*this._gridSize.height;a=this._tilesOrder;for(var b=a.length=0;b<this._tilesCount;++b)a[b]=b;this.shuffle(a,this._tilesCount)},update:function(a){for(var b=0|a*this._tilesCount,c=this._gridSize,d=cc.p(0,0),e=this._tilesOrder,f=0;f<this._tilesCount;f++)a=e[f],d.x=0|a/c.height,d.y=a%(0|c.height),b>f?this.turnOffTile(d):this.turnOnTile(d)}});
cc.turnOffTiles=function(a,b,c){return new cc.TurnOffTiles(a,b,c)};cc.TurnOffTiles.create=cc.turnOffTiles;
cc.WavesTiles3D=cc.TiledGrid3DAction.extend({_waves:0,_amplitude:0,_amplitudeRate:0,ctor:function(a,b,c,d){cc.GridAction.prototype.ctor.call(this);void 0!==d&&this.initWithDuration(a,b,c,d)},getAmplitude:function(){return this._amplitude},setAmplitude:function(a){this._amplitude=a},getAmplitudeRate:function(){return this._amplitudeRate},setAmplitudeRate:function(a){this._amplitudeRate=a},initWithDuration:function(a,b,c,d){return cc.TiledGrid3DAction.prototype.initWithDuration.call(this,a,b)?(this._waves=
c,this._amplitude=d,this._amplitudeRate=1,!0):!1},update:function(a){for(var b,c=this._gridSize,d=this._waves,e=this._amplitude,f=this._amplitudeRate,g=cc.p(0,0),h=0;h<c.width;h++)for(var k=0;k<c.height;k++)g.x=h,g.y=k,b=this.originalTile(g),b.bl.z=Math.sin(2*a*Math.PI*d+0.01*(b.bl.y+b.bl.x))*e*f,b.br.z=b.bl.z,b.tl.z=b.bl.z,b.tr.z=b.bl.z,this.setTile(g,b)}});cc.wavesTiles3D=function(a,b,c,d){return new cc.WavesTiles3D(a,b,c,d)};cc.WavesTiles3D.create=cc.wavesTiles3D;
cc.JumpTiles3D=cc.TiledGrid3DAction.extend({_jumps:0,_amplitude:0,_amplitudeRate:0,ctor:function(a,b,c,d){cc.GridAction.prototype.ctor.call(this);void 0!==d&&this.initWithDuration(a,b,c,d)},getAmplitude:function(){return this._amplitude},setAmplitude:function(a){this._amplitude=a},getAmplitudeRate:function(){return this._amplitudeRate},setAmplitudeRate:function(a){this._amplitudeRate=a},initWithDuration:function(a,b,c,d){return cc.TiledGrid3DAction.prototype.initWithDuration.call(this,a,b)?(this._jumps=
c,this._amplitude=d,this._amplitudeRate=1,!0):!1},update:function(a){for(var b=Math.sin(2*Math.PI*a*this._jumps)*this._amplitude*this._amplitudeRate,c=Math.sin(Math.PI*(2*a*this._jumps+1))*this._amplitude*this._amplitudeRate,d=this._gridSize,e=this.target.grid,f=cc.p(0,0),g=0;g<d.width;g++)for(var h=0;h<d.height;h++)f.x=g,f.y=h,a=e.originalTile(f),0===(g+h)%2?(a.bl.z+=b,a.br.z+=b,a.tl.z+=b,a.tr.z+=b):(a.bl.z+=c,a.br.z+=c,a.tl.z+=c,a.tr.z+=c),e.setTile(f,a)}});
cc.jumpTiles3D=function(a,b,c,d){return new cc.JumpTiles3D(a,b,c,d)};cc.JumpTiles3D.create=cc.jumpTiles3D;
cc.SplitRows=cc.TiledGrid3DAction.extend({_rows:0,_winSize:null,ctor:function(a,b){cc.GridAction.prototype.ctor.call(this);void 0!==b&&this.initWithDuration(a,b)},initWithDuration:function(a,b){return this._rows=b,cc.TiledGrid3DAction.prototype.initWithDuration.call(this,a,cc.size(1,b))},update:function(a){for(var b,c,d=this._gridSize,e=this._winSize.width,f=cc.p(0,0),g=0;g<d.height;++g)f.y=g,b=this.originalTile(f),c=1,0===g%2&&(c=-1),b.bl.x+=c*e*a,b.br.x+=c*e*a,b.tl.x+=c*e*a,b.tr.x+=c*e*a,this.setTile(f,
b)},startWithTarget:function(a){cc.TiledGrid3DAction.prototype.startWithTarget.call(this,a);this._winSize=cc.director.getWinSizeInPixels()}});cc.splitRows=function(a,b){return new cc.SplitRows(a,b)};cc.SplitRows.create=cc.splitRows;
cc.SplitCols=cc.TiledGrid3DAction.extend({_cols:0,_winSize:null,ctor:function(a,b){cc.GridAction.prototype.ctor.call(this);void 0!==b&&this.initWithDuration(a,b)},initWithDuration:function(a,b){return this._cols=b,cc.TiledGrid3DAction.prototype.initWithDuration.call(this,a,cc.size(b,1))},update:function(a){for(var b,c,d=this._gridSize.width,e=this._winSize.height,f=cc.p(0,0),g=0;d>g;++g)f.x=g,b=this.originalTile(f),c=1,0===g%2&&(c=-1),b.bl.y+=c*e*a,b.br.y+=c*e*a,b.tl.y+=c*e*a,b.tr.y+=c*e*a,this.setTile(f,
b);cc.renderer.childrenOrderDirty=!0},startWithTarget:function(a){cc.TiledGrid3DAction.prototype.startWithTarget.call(this,a);this._winSize=cc.director.getWinSizeInPixels()}});cc.splitCols=function(a,b){return new cc.SplitCols(a,b)};cc.SplitCols.create=cc.splitCols;
cc.PageTurn3D=cc.Grid3DAction.extend({getGrid:function(){var a=new cc.Grid3D(this._gridSize);return a.setNeedDepthTestForBlit(!0),a},clone:function(){var a=new cc.PageTurn3D;return a.initWithDuration(this._duration,this._gridSize),a},update:function(a){var b=Math.max(0,a-0.25),b=-100-500*b*b;a=-Math.PI/2*Math.sqrt(a);var c=+Math.PI/2+a;a=Math.sin(c);for(var c=Math.cos(c),d=this._gridSize,e=cc.p(0,0),f=0;f<=d.width;++f)for(var g=0;g<=d.height;++g){e.x=f;e.y=g;var h=this.getOriginalVertex(e),k=Math.sqrt(h.x*
h.x+(h.y-b)*(h.y-b)),m=k*a,n=Math.asin(h.x/k)/a,p=Math.cos(n);n<=Math.PI?h.x=m*Math.sin(n):h.x=0;h.y=k+b-m*(1-p)*a;h.z=m*(1-p)*c/7;0.5>h.z&&(h.z=0.5);this.setVertex(e,h)}}});cc.pageTurn3D=function(a,b){return new cc.PageTurn3D(a,b)};cc.PageTurn3D.create=cc.pageTurn3D;
cc.ProgressTimer=cc.Node.extend({_type:null,_percentage:0,_sprite:null,_midPoint:null,_barChangeRate:null,_reverseDirection:!1,_className:"ProgressTimer",ctor:function(a){cc.Node.prototype.ctor.call(this);this._type=cc.ProgressTimer.TYPE_RADIAL;this._percentage=0;this._midPoint=cc.p(0,0);this._barChangeRate=cc.p(0,0);this._reverseDirection=!1;this._sprite=null;a&&this.initWithSprite(a)},getMidpoint:function(){return cc.p(this._midPoint.x,this._midPoint.y)},setMidpoint:function(a){this._midPoint=cc.pClamp(a,
cc.p(0,0),cc.p(1,1))},getBarChangeRate:function(){return cc.p(this._barChangeRate.x,this._barChangeRate.y)},setBarChangeRate:function(a){this._barChangeRate=cc.pClamp(a,cc.p(0,0),cc.p(1,1))},getType:function(){return this._type},getPercentage:function(){return this._percentage},getSprite:function(){return this._sprite},setPercentage:function(a){this._percentage!==a&&(this._percentage=cc.clampf(a,0,100),this._renderCmd._updateProgress())},setOpacityModifyRGB:function(a){},isOpacityModifyRGB:function(){return!1},
isReverseDirection:function(){return this._reverseDirection},setColor:function(a){this._sprite.color=a;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty)},setOpacity:function(a){this._sprite.opacity=a;this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)},getColor:function(){return this._sprite.color},getOpacity:function(){return this._sprite.opacity},setReverseProgress:function(a){this._reverseDirection!==a&&(this._reverseDirection=a,this._renderCmd.releaseData())},setSprite:function(a){this._sprite!==
a&&(this._sprite=a,a?this.setContentSize(a.width,a.height):this.setContentSize(0,0),this._renderCmd.releaseData())},setType:function(a){a!==this._type&&(this._type=a,this._renderCmd.releaseData())},setReverseDirection:function(a){this._reverseDirection!==a&&(this._reverseDirection=a,this._renderCmd.releaseData())},initWithSprite:function(a){return this.percentage=0,this.setAnchorPoint(0.5,0.5),this._type=cc.ProgressTimer.TYPE_RADIAL,this._reverseDirection=!1,this.midPoint=cc.p(0.5,0.5),this.barChangeRate=
cc.p(1,1),this.setSprite(a),this._renderCmd.initCmd(),!0},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.ProgressTimer.CanvasRenderCmd(this):new cc.ProgressTimer.WebGLRenderCmd(this)}});_p=cc.ProgressTimer.prototype;_p.midPoint;cc.defineGetterSetter(_p,"midPoint",_p.getMidpoint,_p.setMidpoint);_p.barChangeRate;cc.defineGetterSetter(_p,"barChangeRate",_p.getBarChangeRate,_p.setBarChangeRate);_p.type;cc.defineGetterSetter(_p,"type",_p.getType,_p.setType);_p.percentage;
cc.defineGetterSetter(_p,"percentage",_p.getPercentage,_p.setPercentage);_p.sprite;cc.defineGetterSetter(_p,"sprite",_p.getSprite,_p.setSprite);_p.reverseDir;cc.defineGetterSetter(_p,"reverseDir",_p.isReverseDirection,_p.setReverseDirection);cc.ProgressTimer.create=function(a){return new cc.ProgressTimer(a)};cc.ProgressTimer.TEXTURE_COORDS_COUNT=4;cc.ProgressTimer.TEXTURE_COORDS=75;cc.ProgressTimer.TYPE_RADIAL=0;cc.ProgressTimer.TYPE_BAR=1;
(function(){cc.ProgressTimer.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._needDraw=!0;this._PI180=Math.PI/180;this._barRect=cc.rect(0,0,0,0);this._origin=cc.p(0,0);this._radius=0;this._endAngle=this._startAngle=270;this._counterClockWise=!1};var a=cc.ProgressTimer.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.ProgressTimer.CanvasRenderCmd;a.rendering=function(a,c,d){a=a||cc._renderContext;var e=a.getContext(),f=this._node,g=f._sprite,
h=g._renderCmd._textureCoord,k=g._renderCmd._displayedOpacity/255;if(0!==h.width&&0!==h.height&&g._texture&&h.validRect&&0!==k){a.setTransform(this._worldTransform,c,d);a.setCompositeOperation(g._blendFuncStr);a.setGlobalAlpha(k);var m=g._rect,n=g._offsetPosition,k=n.x,p=-n.y-m.height,r=m.width,m=m.height;(a.save(),g._flippedX&&(k=-k-r,e.scale(-1,1)),g._flippedY&&(p=n.y,e.scale(1,-1)),f._type===cc.ProgressTimer.TYPE_BAR)?(f=this._barRect,e.beginPath(),e.rect(f.x*c,f.y*d,f.width*c,f.height*d),e.clip(),
e.closePath()):f._type===cc.ProgressTimer.TYPE_RADIAL&&(f=this._origin.x*c,n=this._origin.y*d,e.beginPath(),e.arc(f,n,this._radius*d,this._PI180*this._startAngle,this._PI180*this._endAngle,this._counterClockWise),e.lineTo(f,n),e.clip(),e.closePath());f=g._texture.getHtmlElementObj();g._colorized?e.drawImage(f,0,0,h.width,h.height,k*c,p*d,r*c,m*d):e.drawImage(f,h.renderX,h.renderY,h.width,h.height,k*c,p*d,r*c,m*d);a.restore();cc.g_NumberOfDraws++}};a.releaseData=function(){};a.initCmd=function(){};
a._updateProgress=function(){var a=this._node,c=a._sprite,d=c.width,e=c.height,f=a._midPoint;if(a._type===cc.ProgressTimer.TYPE_RADIAL){this._radius=Math.round(Math.sqrt(d*d+e*e));var g,h,k=!1,m=this._origin;m.x=d*f.x;m.y=-e*f.y;a._reverseDirection?(h=270,g=270-3.6*a._percentage):(g=-90,h=-90+3.6*a._percentage);c._flippedX&&(m.x-=2*d*a._midPoint.x,g=-g,h=-h,g-=180,h-=180,k=!k);c._flippedY&&(m.y+=2*e*a._midPoint.y,k=!k,g=-g,h=-h);this._startAngle=g;this._endAngle=h;this._counterClockWise=k}else g=
a._barChangeRate,h=a._percentage/100,a=this._barRect,g=cc.size(d*(1-g.x),e*(1-g.y)),h=cc.size((d-g.width)*h,(e-g.height)*h),g=cc.size(g.width+h.width,g.height+h.height),k=cc.p(d*f.x,e*f.y),h=k.x-g.width/2,0.5<f.x&&g.width/2>=d-k.x&&(h=d-g.width),d=k.y-g.height/2,0.5<f.y&&g.height/2>=e-k.y&&(d=e-g.height),a.x=0,e=1,c._flippedX&&(a.x-=g.width,e=-1),0<h&&(a.x+=h*e),a.y=0,e=1,c._flippedY&&(a.y+=g.height,e=-1),0<d&&(a.y-=d*e),a.width=g.width,a.height=-g.height};a._updateColor=function(){};a._syncStatus=
function(a){var c=this._node;if(c._sprite){var d=cc.Node._dirtyFlags,e=this._dirtyFlag,f=a?a._node:null;f&&f._cascadeColorEnabled&&a._dirtyFlag&d.colorDirty&&(e|=d.colorDirty);f&&f._cascadeOpacityEnabled&&a._dirtyFlag&d.opacityDirty&&(e|=d.opacityDirty);a&&a._dirtyFlag&d.transformDirty&&(e|=d.transformDirty);this._dirtyFlag=e;var c=c._sprite._renderCmd,f=c._dirtyFlag,g=f&d.opacityDirty;f&d.colorDirty&&c._syncDisplayColor();g&&c._syncDisplayOpacity();e&d.transformDirty&&this.transform(a)}};a.updateStatus=
function(){var a=this._node;if(a._sprite){var c=cc.Node._dirtyFlags,d=this._dirtyFlag,a=a._sprite._renderCmd,e=a._dirtyFlag,f=e&c.opacityDirty;e&c.colorDirty&&a._updateDisplayColor();f&&a._updateDisplayOpacity();d&c.transformDirty&&this.transform(this.getParentRenderCmd(),!0);this._dirtyFlag=0}}})();
cc.ProgressTo=cc.ActionInterval.extend({_to:0,_from:0,ctor:function(a,b){cc.ActionInterval.prototype.ctor.call(this);this._from=this._to=0;void 0!==b&&this.initWithDuration(a,b)},initWithDuration:function(a,b){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._to=b,!0):!1},clone:function(){var a=new cc.ProgressTo;return a.initWithDuration(this._duration,this._to),a},reverse:function(){return cc.log("cc.ProgressTo.reverse(): reverse hasn't been supported."),null},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,
a);this._from=a.percentage},update:function(a){this.target instanceof cc.ProgressTimer&&(this.target.percentage=this._from+(this._to-this._from)*a)}});cc.progressTo=function(a,b){return new cc.ProgressTo(a,b)};cc.ProgressTo.create=cc.progressTo;
cc.ProgressFromTo=cc.ActionInterval.extend({_to:0,_from:0,ctor:function(a,b,c){cc.ActionInterval.prototype.ctor.call(this);this._from=this._to=0;void 0!==c&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._to=c,this._from=b,!0):!1},clone:function(){var a=new cc.ProgressFromTo;return a.initWithDuration(this._duration,this._from,this._to),a},reverse:function(){return cc.progressFromTo(this._duration,this._to,this._from)},
startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a)},update:function(a){this.target instanceof cc.ProgressTimer&&(this.target.percentage=this._from+(this._to-this._from)*a)}});cc.progressFromTo=function(a,b,c){return new cc.ProgressFromTo(a,b,c)};cc.ProgressFromTo.create=cc.progressFromTo;
!function(){cc.ProgressTimer.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._needDraw=!0;this._vertexWebGLBuffer=cc._renderContext.createBuffer();this._vertexDataCount=0;this._vertexArrayBuffer=this._vertexData=null;this._vertexDataDirty=!1};var a=cc.ProgressTimer.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.ProgressTimer.WebGLRenderCmd;a.rendering=function(a){var c=this._node;a=a||cc._renderContext;if(this._vertexData&&c._sprite){this._shaderProgram.use();
this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix);var d=c._sprite._blendFunc;cc.glBlendFunc(d.src,d.dst);cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);cc.glBindTexture2D(c._sprite.texture);a.bindBuffer(a.ARRAY_BUFFER,this._vertexWebGLBuffer);this._vertexDataDirty&&(a.bufferData(a.ARRAY_BUFFER,this._vertexArrayBuffer,a.DYNAMIC_DRAW),this._vertexDataDirty=!1);d=cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,a.FLOAT,!1,d,0);a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,
4,a.UNSIGNED_BYTE,!0,d,8);a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,a.FLOAT,!1,d,12);c._type===cc.ProgressTimer.TYPE_RADIAL?a.drawArrays(a.TRIANGLE_FAN,0,this._vertexDataCount):c._type===cc.ProgressTimer.TYPE_BAR&&(c._reverseDirection?(a.drawArrays(a.TRIANGLE_STRIP,0,this._vertexDataCount/2),a.drawArrays(a.TRIANGLE_STRIP,4,this._vertexDataCount/2),cc.g_NumberOfDraws++):a.drawArrays(a.TRIANGLE_STRIP,0,this._vertexDataCount));cc.g_NumberOfDraws++}};a._syncStatus=function(a){var c=this._node;
if(c._sprite){var d=cc.Node._dirtyFlags,e=this._dirtyFlag,f=a?a._node:null;f&&f._cascadeColorEnabled&&a._dirtyFlag&d.colorDirty&&(e|=d.colorDirty);f&&f._cascadeOpacityEnabled&&a._dirtyFlag&d.opacityDirty&&(e|=d.opacityDirty);a&&a._dirtyFlag&d.transformDirty&&(e|=d.transformDirty);this._dirtyFlag=e;c=c._sprite._renderCmd;f=c._dirtyFlag;e=f&d.colorDirty;d=f&d.opacityDirty;e&&c._syncDisplayColor();d&&c._syncDisplayOpacity();(e||d)&&(c._updateColor(),this._updateColor());this.transform(a);c._dirtyFlag=
0}};a.updateStatus=function(){var a=this._node;if(a._sprite){var c=cc.Node._dirtyFlags,d=this._dirtyFlag,a=a._sprite._renderCmd,e=a._dirtyFlag,f=e&c.colorDirty,e=e&c.opacityDirty;f&&(a._updateDisplayColor(),this._dirtyFlag^=this._dirtyFlag&c.colorDirty);e&&(a._updateDisplayOpacity(),this._dirtyFlag^=this._dirtyFlag&c.opacityDirty);(f||e)&&(a._updateColor(),this._updateColor());d&c.transformDirty&&this.transform(this.getParentRenderCmd(),!0)}};a.releaseData=function(){this._vertexData&&(this._vertexData=
null,this._vertexArrayBuffer=null,this._vertexDataCount=0)};a.initCmd=function(){this._vertexArrayBuffer=this._vertexData=null;this._vertexDataCount=0;this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)};a._updateProgress=function(){var a=this._node._type;a===cc.ProgressTimer.TYPE_RADIAL?this._updateRadial():a===cc.ProgressTimer.TYPE_BAR&&this._updateBar();this._vertexDataDirty=!0};a._updateBar=function(){var a=this._node;if(a._sprite){var c,d=a._percentage/100;c=a._barChangeRate;
c=cc.pMult(cc.p(1-c.x+d*c.x,1-c.y+d*c.y),0.5);d=cc.pSub(a._midPoint,c);a=cc.pAdd(a._midPoint,c);0>d.x&&(a.x+=-d.x,d.x=0);1<a.x&&(d.x-=a.x-1,a.x=1);0>d.y&&(a.y+=-d.y,d.y=0);1<a.y&&(d.y-=a.y-1,a.y=1);if(this._reverseDirection){if(!this._vertexData){this._vertexDataCount=8;var e=cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;this._vertexArrayBuffer=new ArrayBuffer(8*e);var f=[];for(c=0;8>c;c++)f[c]=new cc.V2F_C4B_T2F(null,null,null,this._vertexArrayBuffer,c*e);f[0].texCoords=this._textureCoordFromAlphaPoint(cc.p(0,
1));f[0].vertices=this._vertexFromAlphaPoint(cc.p(0,1));f[1].texCoords=this._textureCoordFromAlphaPoint(cc.p(0,0));f[1].vertices=this._vertexFromAlphaPoint(cc.p(0,0));f[6].texCoords=this._textureCoordFromAlphaPoint(cc.p(1,1));f[6].vertices=this._vertexFromAlphaPoint(cc.p(1,1));f[7].texCoords=this._textureCoordFromAlphaPoint(cc.p(1,0));f[7].vertices=this._vertexFromAlphaPoint(cc.p(1,0));this._vertexData=f}c=this._vertexData;c[2].texCoords=this._textureCoordFromAlphaPoint(cc.p(d.x,a.y));c[2].vertices=
this._vertexFromAlphaPoint(cc.p(d.x,a.y));c[3].texCoords=this._textureCoordFromAlphaPoint(cc.p(d.x,d.y));c[3].vertices=this._vertexFromAlphaPoint(cc.p(d.x,d.y));c[4].texCoords=this._textureCoordFromAlphaPoint(cc.p(a.x,a.y));c[4].vertices=this._vertexFromAlphaPoint(cc.p(a.x,a.y));c[5].texCoords=this._textureCoordFromAlphaPoint(cc.p(a.x,d.y));c[5].vertices=this._vertexFromAlphaPoint(cc.p(a.x,d.y))}else{if(!this._vertexData){this._vertexDataCount=4;e=cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;this._vertexArrayBuffer=
new ArrayBuffer(4*e);this._vertexData=[];for(c=0;4>c;c++)this._vertexData[c]=new cc.V2F_C4B_T2F(null,null,null,this._vertexArrayBuffer,c*e)}c=this._vertexData;c[0].texCoords=this._textureCoordFromAlphaPoint(cc.p(d.x,a.y));c[0].vertices=this._vertexFromAlphaPoint(cc.p(d.x,a.y));c[1].texCoords=this._textureCoordFromAlphaPoint(cc.p(d.x,d.y));c[1].vertices=this._vertexFromAlphaPoint(cc.p(d.x,d.y));c[2].texCoords=this._textureCoordFromAlphaPoint(cc.p(a.x,a.y));c[2].vertices=this._vertexFromAlphaPoint(cc.p(a.x,
a.y));c[3].texCoords=this._textureCoordFromAlphaPoint(cc.p(a.x,d.y));c[3].vertices=this._vertexFromAlphaPoint(cc.p(a.x,d.y))}this._updateColor()}};a._updateRadial=function(){var a=this._node;if(a._sprite){var c,d,e=a._midPoint;c=a._percentage/100;var f=2*cc.PI*(a._reverseDirection?c:1-c),a=cc.p(e.x,1);d=cc.pRotateByAngle(a,e,f);f=0;if(0===c)d=a,f=0;else if(1===c)d=a,f=4;else{var g=cc.FLT_MAX,h=cc.ProgressTimer.TEXTURE_COORDS_COUNT;for(c=0;h>=c;++c){var k=(c+(h-1))%h,m=this._boundaryTexCoord(c%h),
k=this._boundaryTexCoord(k);0===c?k=cc.pLerp(m,k,1-e.x):4===c&&(m=cc.pLerp(m,k,1-e.x));var n=cc.p(0,0);if(cc.pLineIntersect(m,k,e,d,n)&&(0!==c&&4!==c||0<=n.x&&1>=n.x))0<=n.y&&n.y<g&&(g=n.y,f=c)}d=cc.pAdd(e,cc.pMult(cc.pSub(d,e),g))}g=!0;if(this._vertexDataCount!==f+3&&(g=!1,this._vertexData=null,this._vertexArrayBuffer=null,this._vertexDataCount=0),!this._vertexData){h=this._vertexDataCount=f+3;m=cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;this._vertexArrayBuffer=new ArrayBuffer(h*m);k=[];for(c=0;h>c;c++)k[c]=
new cc.V2F_C4B_T2F(null,null,null,this._vertexArrayBuffer,c*m);if(this._vertexData=k,!this._vertexData)return void cc.log("cc.ProgressTimer._updateRadial() : Not enough memory")}this._updateColor();h=this._vertexData;if(!g){h[0].texCoords=this._textureCoordFromAlphaPoint(e);h[0].vertices=this._vertexFromAlphaPoint(e);h[1].texCoords=this._textureCoordFromAlphaPoint(a);h[1].vertices=this._vertexFromAlphaPoint(a);for(c=0;f>c;c++)e=this._boundaryTexCoord(c),h[c+2].texCoords=this._textureCoordFromAlphaPoint(e),
h[c+2].vertices=this._vertexFromAlphaPoint(e)}h[this._vertexDataCount-1].texCoords=this._textureCoordFromAlphaPoint(d);h[this._vertexDataCount-1].vertices=this._vertexFromAlphaPoint(d)}};a._boundaryTexCoord=function(a){if(a<cc.ProgressTimer.TEXTURE_COORDS_COUNT){var c=cc.ProgressTimer.TEXTURE_COORDS;return this._node._reverseDirection?cc.p(c>>7-(a<<1)&1,c>>7-((a<<1)+1)&1):cc.p(c>>(a<<1)+1&1,c>>(a<<1)&1)}return cc.p(0,0)};a._textureCoordFromAlphaPoint=function(a){var c=this._node._sprite;if(!c)return{u:0,
v:0};var d=c.quad,e=cc.p(d.bl.texCoords.u,d.bl.texCoords.v),d=cc.p(d.tr.texCoords.u,d.tr.texCoords.v);c.textureRectRotated&&(c=a.x,a.x=a.y,a.y=c);return{u:e.x*(1-a.x)+d.x*a.x,v:e.y*(1-a.y)+d.y*a.y}};a._vertexFromAlphaPoint=function(a){var c=this._node._sprite;if(!c)return{x:0,y:0};var d=c.quad,c=cc.p(d.bl.vertices.x,d.bl.vertices.y),d=cc.p(d.tr.vertices.x,d.tr.vertices.y);return{x:c.x*(1-a.x)+d.x*a.x,y:c.y*(1-a.y)+d.y*a.y}};a._updateColor=function(){var a=this._node;if(a._sprite&&this._vertexData){for(var a=
a._sprite.quad.tl.colors,c=this._vertexData,d=0,e=this._vertexDataCount;e>d;++d)c[d].colors=a;this._vertexDataDirty=!0}}}();cc.SCENE_FADE=4208917214;cc.TRANSITION_ORIENTATION_LEFT_OVER=0;cc.TRANSITION_ORIENTATION_RIGHT_OVER=1;cc.TRANSITION_ORIENTATION_UP_OVER=0;cc.TRANSITION_ORIENTATION_DOWN_OVER=1;
cc.TransitionScene=cc.Scene.extend({_inScene:null,_outScene:null,_duration:null,_isInSceneOnTop:!1,_isSendCleanupToScene:!1,_className:"TransitionScene",ctor:function(a,b){cc.Scene.prototype.ctor.call(this);void 0!==a&&void 0!==b&&this.initWithDuration(a,b)},_setNewScene:function(a){this.unschedule(this._setNewScene);a=cc.director;this._isSendCleanupToScene=a.isSendCleanupToScene();a.runScene(this._inScene);cc.eventManager.setEnabled(!0);this._outScene.visible=!0},_sceneOrder:function(){this._isInSceneOnTop=
!0},visit:function(){this._isInSceneOnTop?(this._outScene.visit(),this._inScene.visit()):(this._inScene.visit(),this._outScene.visit());cc.Node.prototype.visit.call(this)},onEnter:function(){cc.Node.prototype.onEnter.call(this);cc.eventManager.setEnabled(!1);this._outScene.onExitTransitionDidStart();this._inScene.onEnter()},onExit:function(){cc.Node.prototype.onExit.call(this);cc.eventManager.setEnabled(!0);this._outScene.onExit();this._inScene.onEnterTransitionDidFinish()},cleanup:function(){cc.Node.prototype.cleanup.call(this);
this._isSendCleanupToScene&&this._outScene.cleanup()},initWithDuration:function(a,b){if(!b)throw"cc.TransitionScene.initWithDuration(): Argument scene must be non-nil";if(this.init()){if(this._duration=a,this.attr({x:0,y:0,anchorX:0,anchorY:0}),this._inScene=b,this._outScene=cc.director.getRunningScene(),this._outScene||(this._outScene=new cc.Scene,this._outScene.init()),this._inScene===this._outScene)throw"cc.TransitionScene.initWithDuration(): Incoming scene must be different from the outgoing scene";
return this._sceneOrder(),!0}return!1},finish:function(){this._inScene.attr({visible:!0,x:0,y:0,scale:1,rotation:0});cc._renderType===cc._RENDER_TYPE_WEBGL&&this._inScene.getCamera().restore();this._outScene.attr({visible:!1,x:0,y:0,scale:1,rotation:0});cc._renderType===cc._RENDER_TYPE_WEBGL&&this._outScene.getCamera().restore();this.schedule(this._setNewScene,0)},hideOutShowIn:function(){this._inScene.visible=!0;this._outScene.visible=!1}});
cc.TransitionScene.create=function(a,b){return new cc.TransitionScene(a,b)};cc.TransitionSceneOriented=cc.TransitionScene.extend({_orientation:0,ctor:function(a,b,c){cc.TransitionScene.prototype.ctor.call(this);void 0!=c&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){return cc.TransitionScene.prototype.initWithDuration.call(this,a,b)&&(this._orientation=c),!0}});cc.TransitionSceneOriented.create=function(a,b,c){return new cc.TransitionSceneOriented(a,b,c)};
cc.TransitionRotoZoom=cc.TransitionScene.extend({ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);this._inScene.attr({scale:0.001,anchorX:0.5,anchorY:0.5});this._outScene.attr({scale:1,anchorX:0.5,anchorY:0.5});var a=cc.sequence(cc.spawn(cc.scaleBy(this._duration/2,0.001),cc.rotateBy(this._duration/2,720)),cc.delayTime(this._duration/2));this._outScene.runAction(a);this._inScene.runAction(cc.sequence(a.reverse(),
cc.callFunc(this.finish,this)))}});cc.TransitionRotoZoom.create=function(a,b){return new cc.TransitionRotoZoom(a,b)};
cc.TransitionJumpZoom=cc.TransitionScene.extend({ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a=cc.director.getWinSize();this._inScene.attr({scale:0.5,x:a.width,y:0,anchorX:0.5,anchorY:0.5});this._outScene.anchorX=0.5;this._outScene.anchorY=0.5;var b=cc.jumpBy(this._duration/4,cc.p(-a.width,0),a.width/4,2),c=cc.scaleTo(this._duration/4,1),a=cc.scaleTo(this._duration/4,0.5),a=cc.sequence(a,
b),b=cc.sequence(b,c),c=cc.delayTime(this._duration/2);this._outScene.runAction(a);this._inScene.runAction(cc.sequence(c,b,cc.callFunc(this.finish,this)))}});cc.TransitionJumpZoom.create=function(a,b){return new cc.TransitionJumpZoom(a,b)};
cc.TransitionMoveInL=cc.TransitionScene.extend({ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);this.initScenes();var a=this.action();this._inScene.runAction(cc.sequence(this.easeActionWithAction(a),cc.callFunc(this.finish,this)))},initScenes:function(){this._inScene.setPosition(-cc.director.getWinSize().width,0)},action:function(){return cc.moveTo(this._duration,cc.p(0,0))},easeActionWithAction:function(a){return new cc.EaseOut(a,
2)}});cc.TransitionMoveInL.create=function(a,b){return new cc.TransitionMoveInL(a,b)};cc.TransitionMoveInR=cc.TransitionMoveInL.extend({ctor:function(a,b){cc.TransitionMoveInL.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},initScenes:function(){this._inScene.setPosition(cc.director.getWinSize().width,0)}});cc.TransitionMoveInR.create=function(a,b){return new cc.TransitionMoveInR(a,b)};
cc.TransitionMoveInT=cc.TransitionMoveInL.extend({ctor:function(a,b){cc.TransitionMoveInL.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},initScenes:function(){this._inScene.setPosition(0,cc.director.getWinSize().height)}});cc.TransitionMoveInT.create=function(a,b){return new cc.TransitionMoveInT(a,b)};
cc.TransitionMoveInB=cc.TransitionMoveInL.extend({ctor:function(a,b){cc.TransitionMoveInL.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},initScenes:function(){this._inScene.setPosition(0,-cc.director.getWinSize().height)}});cc.TransitionMoveInB.create=function(a,b){return new cc.TransitionMoveInB(a,b)};cc.ADJUST_FACTOR=0.5;
cc.TransitionSlideInL=cc.TransitionScene.extend({ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},_sceneOrder:function(){this._isInSceneOnTop=!1},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);this.initScenes();var a=this.action(),b=this.action(),a=this.easeActionWithAction(a),b=cc.sequence(this.easeActionWithAction(b),cc.callFunc(this.finish,this));this._inScene.runAction(a);this._outScene.runAction(b)},initScenes:function(){this._inScene.setPosition(-cc.director.getWinSize().width+
cc.ADJUST_FACTOR,0)},action:function(){return cc.moveBy(this._duration,cc.p(cc.director.getWinSize().width-cc.ADJUST_FACTOR,0))},easeActionWithAction:function(a){return new cc.EaseInOut(a,2)}});cc.TransitionSlideInL.create=function(a,b){return new cc.TransitionSlideInL(a,b)};
cc.TransitionSlideInR=cc.TransitionSlideInL.extend({ctor:function(a,b){cc.TransitionSlideInL.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},_sceneOrder:function(){this._isInSceneOnTop=!0},initScenes:function(){this._inScene.setPosition(cc.director.getWinSize().width-cc.ADJUST_FACTOR,0)},action:function(){return cc.moveBy(this._duration,cc.p(-(cc.director.getWinSize().width-cc.ADJUST_FACTOR),0))}});cc.TransitionSlideInR.create=function(a,b){return new cc.TransitionSlideInR(a,b)};
cc.TransitionSlideInB=cc.TransitionSlideInL.extend({ctor:function(a,b){cc.TransitionSlideInL.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},_sceneOrder:function(){this._isInSceneOnTop=!1},initScenes:function(){this._inScene.setPosition(0,-(cc.director.getWinSize().height-cc.ADJUST_FACTOR))},action:function(){return cc.moveBy(this._duration,cc.p(0,cc.director.getWinSize().height-cc.ADJUST_FACTOR))}});cc.TransitionSlideInB.create=function(a,b){return new cc.TransitionSlideInB(a,b)};
cc.TransitionSlideInT=cc.TransitionSlideInL.extend({ctor:function(a,b){cc.TransitionSlideInL.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},_sceneOrder:function(){this._isInSceneOnTop=!0},initScenes:function(){this._inScene.setPosition(0,cc.director.getWinSize().height-cc.ADJUST_FACTOR)},action:function(){return cc.moveBy(this._duration,cc.p(0,-(cc.director.getWinSize().height-cc.ADJUST_FACTOR)))}});cc.TransitionSlideInT.create=function(a,b){return new cc.TransitionSlideInT(a,b)};
cc.TransitionShrinkGrow=cc.TransitionScene.extend({ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);this._inScene.attr({scale:0.001,anchorX:2/3,anchorY:0.5});this._outScene.attr({scale:1,anchorX:1/3,anchorY:0.5});var a=cc.scaleTo(this._duration,0.01),b=cc.scaleTo(this._duration,1);this._inScene.runAction(this.easeActionWithAction(b));this._outScene.runAction(cc.sequence(this.easeActionWithAction(a),
cc.callFunc(this.finish,this)))},easeActionWithAction:function(a){return new cc.EaseOut(a,2)}});cc.TransitionShrinkGrow.create=function(a,b){return new cc.TransitionShrinkGrow(a,b)};
cc.TransitionFlipX=cc.TransitionSceneOriented.extend({ctor:function(a,b,c){cc.TransitionSceneOriented.prototype.ctor.call(this);null==c&&(c=cc.TRANSITION_ORIENTATION_RIGHT_OVER);b&&this.initWithDuration(a,b,c)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a,b;this._inScene.visible=!1;var c,d;this._orientation===cc.TRANSITION_ORIENTATION_RIGHT_OVER?(a=90,c=270,b=90,d=0):(a=-90,c=90,b=-90,d=0);a=cc.sequence(cc.delayTime(this._duration/2),cc.show(),cc.orbitCamera(this._duration/
2,1,0,c,a,0,0),cc.callFunc(this.finish,this));b=cc.sequence(cc.orbitCamera(this._duration/2,1,0,d,b,0,0),cc.hide(),cc.delayTime(this._duration/2));this._inScene.runAction(a);this._outScene.runAction(b)}});cc.TransitionFlipX.create=function(a,b,c){return new cc.TransitionFlipX(a,b,c)};
cc.TransitionFlipY=cc.TransitionSceneOriented.extend({ctor:function(a,b,c){cc.TransitionSceneOriented.prototype.ctor.call(this);null==c&&(c=cc.TRANSITION_ORIENTATION_UP_OVER);b&&this.initWithDuration(a,b,c)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a,b;this._inScene.visible=!1;var c,d;this._orientation===cc.TRANSITION_ORIENTATION_UP_OVER?(a=90,c=270,b=90,d=0):(a=-90,c=90,b=-90,d=0);a=cc.sequence(cc.delayTime(this._duration/2),cc.show(),cc.orbitCamera(this._duration/2,
1,0,c,a,90,0),cc.callFunc(this.finish,this));b=cc.sequence(cc.orbitCamera(this._duration/2,1,0,d,b,90,0),cc.hide(),cc.delayTime(this._duration/2));this._inScene.runAction(a);this._outScene.runAction(b)}});cc.TransitionFlipY.create=function(a,b,c){return new cc.TransitionFlipY(a,b,c)};
cc.TransitionFlipAngular=cc.TransitionSceneOriented.extend({ctor:function(a,b,c){cc.TransitionSceneOriented.prototype.ctor.call(this);null==c&&(c=cc.TRANSITION_ORIENTATION_RIGHT_OVER);b&&this.initWithDuration(a,b,c)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a,b;this._inScene.visible=!1;var c,d;this._orientation===cc.TRANSITION_ORIENTATION_RIGHT_OVER?(a=90,c=270,b=90,d=0):(a=-90,c=90,b=-90,d=0);a=cc.sequence(cc.delayTime(this._duration/2),cc.show(),cc.orbitCamera(this._duration/
2,1,0,c,a,-45,0),cc.callFunc(this.finish,this));b=cc.sequence(cc.orbitCamera(this._duration/2,1,0,d,b,45,0),cc.hide(),cc.delayTime(this._duration/2));this._inScene.runAction(a);this._outScene.runAction(b)}});cc.TransitionFlipAngular.create=function(a,b,c){return new cc.TransitionFlipAngular(a,b,c)};
cc.TransitionZoomFlipX=cc.TransitionSceneOriented.extend({ctor:function(a,b,c){cc.TransitionSceneOriented.prototype.ctor.call(this);null==c&&(c=cc.TRANSITION_ORIENTATION_RIGHT_OVER);b&&this.initWithDuration(a,b,c)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a,b;this._inScene.visible=!1;var c,d;this._orientation===cc.TRANSITION_ORIENTATION_RIGHT_OVER?(a=90,c=270,b=90,d=0):(a=-90,c=90,b=-90,d=0);a=cc.sequence(cc.delayTime(this._duration/2),cc.spawn(cc.orbitCamera(this._duration/
2,1,0,c,a,0,0),cc.scaleTo(this._duration/2,1),cc.show()),cc.callFunc(this.finish,this));b=cc.sequence(cc.spawn(cc.orbitCamera(this._duration/2,1,0,d,b,0,0),cc.scaleTo(this._duration/2,0.5)),cc.hide(),cc.delayTime(this._duration/2));this._inScene.scale=0.5;this._inScene.runAction(a);this._outScene.runAction(b)}});cc.TransitionZoomFlipX.create=function(a,b,c){return new cc.TransitionZoomFlipX(a,b,c)};
cc.TransitionZoomFlipY=cc.TransitionSceneOriented.extend({ctor:function(a,b,c){cc.TransitionSceneOriented.prototype.ctor.call(this);null==c&&(c=cc.TRANSITION_ORIENTATION_UP_OVER);b&&this.initWithDuration(a,b,c)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a,b;this._inScene.visible=!1;var c,d;this._orientation===cc.TRANSITION_ORIENTATION_UP_OVER?(a=90,c=270,b=90,d=0):(a=-90,c=90,b=-90,d=0);a=cc.sequence(cc.delayTime(this._duration/2),cc.spawn(cc.orbitCamera(this._duration/
2,1,0,c,a,90,0),cc.scaleTo(this._duration/2,1),cc.show()),cc.callFunc(this.finish,this));b=cc.sequence(cc.spawn(cc.orbitCamera(this._duration/2,1,0,d,b,90,0),cc.scaleTo(this._duration/2,0.5)),cc.hide(),cc.delayTime(this._duration/2));this._inScene.scale=0.5;this._inScene.runAction(a);this._outScene.runAction(b)}});cc.TransitionZoomFlipY.create=function(a,b,c){return new cc.TransitionZoomFlipY(a,b,c)};
cc.TransitionZoomFlipAngular=cc.TransitionSceneOriented.extend({ctor:function(a,b,c){cc.TransitionSceneOriented.prototype.ctor.call(this);null==c&&(c=cc.TRANSITION_ORIENTATION_RIGHT_OVER);b&&this.initWithDuration(a,b,c)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a,b;this._inScene.visible=!1;var c,d;this._orientation===cc.TRANSITION_ORIENTATION_RIGHT_OVER?(a=90,c=270,b=90,d=0):(a=-90,c=90,b=-90,d=0);a=cc.sequence(cc.delayTime(this._duration/2),cc.spawn(cc.orbitCamera(this._duration/
2,1,0,c,a,-45,0),cc.scaleTo(this._duration/2,1),cc.show()),cc.show(),cc.callFunc(this.finish,this));b=cc.sequence(cc.spawn(cc.orbitCamera(this._duration/2,1,0,d,b,45,0),cc.scaleTo(this._duration/2,0.5)),cc.hide(),cc.delayTime(this._duration/2));this._inScene.scale=0.5;this._inScene.runAction(a);this._outScene.runAction(b)}});cc.TransitionZoomFlipAngular.create=function(a,b,c){return new cc.TransitionZoomFlipAngular(a,b,c)};
cc.TransitionFade=cc.TransitionScene.extend({_color:null,ctor:function(a,b,c){cc.TransitionScene.prototype.ctor.call(this);this._color=cc.color();b&&this.initWithDuration(a,b,c)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a=new cc.LayerColor(this._color);this._inScene.visible=!1;this.addChild(a,2,cc.SCENE_FADE);var a=this.getChildByTag(cc.SCENE_FADE),b=cc.sequence(cc.fadeIn(this._duration/2),cc.callFunc(this.hideOutShowIn,this),cc.fadeOut(this._duration/2),cc.callFunc(this.finish,
this));a.runAction(b)},onExit:function(){cc.TransitionScene.prototype.onExit.call(this);this.removeChildByTag(cc.SCENE_FADE,!1)},initWithDuration:function(a,b,c){return c=c||cc.color.BLACK,cc.TransitionScene.prototype.initWithDuration.call(this,a,b)&&(this._color.r=c.r,this._color.g=c.g,this._color.b=c.b,this._color.a=0),!0}});cc.TransitionFade.create=function(a,b,c){return new cc.TransitionFade(a,b,c)};
cc.TransitionCrossFade=cc.TransitionScene.extend({ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a=cc.color(0,0,0,0),b=cc.director.getWinSize(),a=new cc.LayerColor(a),c=new cc.RenderTexture(b.width,b.height);c.sprite.anchorX=0.5;c.sprite.anchorY=0.5;c.attr({x:b.width/2,y:b.height/2,anchorX:0.5,anchorY:0.5});c.begin();this._inScene.visit();c.end();var d=new cc.RenderTexture(b.width,
b.height);d.setPosition(b.width/2,b.height/2);d.sprite.anchorX=d.anchorX=0.5;d.sprite.anchorY=d.anchorY=0.5;d.begin();this._outScene.visit();d.end();c.sprite.setBlendFunc(cc.ONE,cc.ONE);d.sprite.setBlendFunc(cc.SRC_ALPHA,cc.ONE_MINUS_SRC_ALPHA);a.addChild(c);a.addChild(d);c.sprite.opacity=255;d.sprite.opacity=255;b=cc.sequence(cc.fadeTo(this._duration,0),cc.callFunc(this.hideOutShowIn,this),cc.callFunc(this.finish,this));d.sprite.runAction(b);this.addChild(a,2,cc.SCENE_FADE)},onExit:function(){this.removeChildByTag(cc.SCENE_FADE,
!1);cc.TransitionScene.prototype.onExit.call(this)},visit:function(){cc.Node.prototype.visit.call(this)},draw:function(){}});cc.TransitionCrossFade.create=function(a,b){return new cc.TransitionCrossFade(a,b)};
cc.TransitionTurnOffTiles=cc.TransitionScene.extend({_gridProxy:null,ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this);this._gridProxy=new cc.NodeGrid;b&&this.initWithDuration(a,b)},_sceneOrder:function(){this._isInSceneOnTop=!1},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);this._gridProxy.setTarget(this._outScene);this._gridProxy.onEnter();var a=cc.director.getWinSize(),a=cc.turnOffTiles(this._duration,cc.size(0|12*(a.width/a.height),12)),a=this.easeActionWithAction(a);
this._gridProxy.runAction(cc.sequence(a,cc.callFunc(this.finish,this),cc.stopGrid()))},visit:function(){this._inScene.visit();this._gridProxy.visit()},easeActionWithAction:function(a){return a}});cc.TransitionTurnOffTiles.create=function(a,b){return new cc.TransitionTurnOffTiles(a,b)};
cc.TransitionSplitCols=cc.TransitionScene.extend({_gridProxy:null,_switchTargetToInscene:function(){this._gridProxy.setTarget(this._inScene)},ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this);this._gridProxy=new cc.NodeGrid;b&&this.initWithDuration(a,b)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);this._gridProxy.setTarget(this._outScene);this._gridProxy.onEnter();var a=this.action(),a=cc.sequence(a,cc.callFunc(this._switchTargetToInscene,this),a.reverse());this._gridProxy.runAction(cc.sequence(this.easeActionWithAction(a),
cc.callFunc(this.finish,this),cc.stopGrid()))},onExit:function(){this._gridProxy.setTarget(null);this._gridProxy.onExit();cc.TransitionScene.prototype.onExit.call(this)},visit:function(){this._gridProxy.visit()},easeActionWithAction:function(a){return new cc.EaseInOut(a,3)},action:function(){return cc.splitCols(this._duration/2,3)}});cc.TransitionSplitCols.create=function(a,b){return new cc.TransitionSplitCols(a,b)};
cc.TransitionSplitRows=cc.TransitionSplitCols.extend({ctor:function(a,b){cc.TransitionSplitCols.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},action:function(){return cc.splitRows(this._duration/2,3)}});cc.TransitionSplitRows.create=function(a,b){return new cc.TransitionSplitRows(a,b)};
cc.TransitionFadeTR=cc.TransitionScene.extend({_gridProxy:null,ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this);this._gridProxy=new cc.NodeGrid;b&&this.initWithDuration(a,b)},_sceneOrder:function(){this._isInSceneOnTop=!1},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);this._gridProxy.setTarget(this._outScene);this._gridProxy.onEnter();var a=cc.director.getWinSize(),a=this.actionWithSize(cc.size(0|12*(a.width/a.height),12));this._gridProxy.runAction(cc.sequence(this.easeActionWithAction(a),
cc.callFunc(this.finish,this),cc.stopGrid()))},visit:function(){this._inScene.visit();this._gridProxy.visit()},easeActionWithAction:function(a){return a},actionWithSize:function(a){return cc.fadeOutTRTiles(this._duration,a)}});cc.TransitionFadeTR.create=function(a,b){return new cc.TransitionFadeTR(a,b)};
cc.TransitionFadeBL=cc.TransitionFadeTR.extend({ctor:function(a,b){cc.TransitionFadeTR.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},actionWithSize:function(a){return cc.fadeOutBLTiles(this._duration,a)}});cc.TransitionFadeBL.create=function(a,b){return new cc.TransitionFadeBL(a,b)};
cc.TransitionFadeUp=cc.TransitionFadeTR.extend({ctor:function(a,b){cc.TransitionFadeTR.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},actionWithSize:function(a){return new cc.FadeOutUpTiles(this._duration,a)}});cc.TransitionFadeUp.create=function(a,b){return new cc.TransitionFadeUp(a,b)};
cc.TransitionFadeDown=cc.TransitionFadeTR.extend({ctor:function(a,b){cc.TransitionFadeTR.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},actionWithSize:function(a){return cc.fadeOutDownTiles(this._duration,a)}});cc.TransitionFadeDown.create=function(a,b){return new cc.TransitionFadeDown(a,b)};cc.SCENE_RADIAL=49153;
cc.TransitionProgress=cc.TransitionScene.extend({_to:0,_from:0,_sceneToBeModified:null,_className:"TransitionProgress",ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},_setAttrs:function(a,b,c){a.attr({x:b,y:c,anchorX:0.5,anchorY:0.5})},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);this._setupTransition();var a=cc.director.getWinSize(),b=new cc.RenderTexture(a.width,a.height);b.sprite.anchorX=0.5;b.sprite.anchorY=0.5;this._setAttrs(b,
a.width/2,a.height/2);b.clear(0,0,0,1);b.begin();this._sceneToBeModified.visit();b.end();this._sceneToBeModified===this._outScene&&this.hideOutShowIn();a=this._progressTimerNodeWithRenderTexture(b);b=cc.sequence(cc.progressFromTo(this._duration,this._from,this._to),cc.callFunc(this.finish,this));a.runAction(b);this.addChild(a,2,cc.SCENE_RADIAL)},onExit:function(){this.removeChildByTag(cc.SCENE_RADIAL,!0);cc.TransitionScene.prototype.onExit.call(this)},_setupTransition:function(){this._sceneToBeModified=
this._outScene;this._from=100;this._to=0},_progressTimerNodeWithRenderTexture:function(a){return cc.log("cc.TransitionProgress._progressTimerNodeWithRenderTexture(): should be overridden in subclass"),null},_sceneOrder:function(){this._isInSceneOnTop=!1}});cc.TransitionProgress.create=function(a,b){return new cc.TransitionProgress(a,b)};
cc.TransitionProgressRadialCCW=cc.TransitionProgress.extend({ctor:function(a,b){cc.TransitionProgress.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},_progressTimerNodeWithRenderTexture:function(a){var b=cc.director.getWinSize();a=new cc.ProgressTimer(a.sprite);return cc._renderType===cc._RENDER_TYPE_WEBGL&&(a.sprite.flippedY=!0),a.type=cc.ProgressTimer.TYPE_RADIAL,a.reverseDir=!1,a.percentage=100,this._setAttrs(a,b.width/2,b.height/2),a}});
cc.TransitionProgressRadialCCW.create=function(a,b){return new cc.TransitionProgressRadialCCW(a,b)};
cc.TransitionProgressRadialCW=cc.TransitionProgress.extend({ctor:function(a,b){cc.TransitionProgress.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},_progressTimerNodeWithRenderTexture:function(a){var b=cc.director.getWinSize();a=new cc.ProgressTimer(a.sprite);return cc._renderType===cc._RENDER_TYPE_WEBGL&&(a.sprite.flippedY=!0),a.type=cc.ProgressTimer.TYPE_RADIAL,a.reverseDir=!0,a.percentage=100,this._setAttrs(a,b.width/2,b.height/2),a}});
cc.TransitionProgressRadialCW.create=function(a,b){var c=new cc.TransitionProgressRadialCW;return null!==c&&c.initWithDuration(a,b)?c:new cc.TransitionProgressRadialCW(a,b)};
cc.TransitionProgressHorizontal=cc.TransitionProgress.extend({ctor:function(a,b){cc.TransitionProgress.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},_progressTimerNodeWithRenderTexture:function(a){var b=cc.director.getWinSize();a=new cc.ProgressTimer(a.sprite);return cc._renderType===cc._RENDER_TYPE_WEBGL&&(a.sprite.flippedY=!0),a.type=cc.ProgressTimer.TYPE_BAR,a.midPoint=cc.p(1,0),a.barChangeRate=cc.p(1,0),a.percentage=100,this._setAttrs(a,b.width/2,b.height/2),a}});
cc.TransitionProgressHorizontal.create=function(a,b){return new cc.TransitionProgressHorizontal(a,b)};
cc.TransitionProgressVertical=cc.TransitionProgress.extend({ctor:function(a,b){cc.TransitionProgress.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},_progressTimerNodeWithRenderTexture:function(a){var b=cc.director.getWinSize();a=new cc.ProgressTimer(a.sprite);return cc._renderType===cc._RENDER_TYPE_WEBGL&&(a.sprite.flippedY=!0),a.type=cc.ProgressTimer.TYPE_BAR,a.midPoint=cc.p(0,0),a.barChangeRate=cc.p(0,1),a.percentage=100,this._setAttrs(a,b.width/2,b.height/2),a}});
cc.TransitionProgressVertical.create=function(a,b){return new cc.TransitionProgressVertical(a,b)};
cc.TransitionProgressInOut=cc.TransitionProgress.extend({ctor:function(a,b){cc.TransitionProgress.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},_progressTimerNodeWithRenderTexture:function(a){var b=cc.director.getWinSize();a=new cc.ProgressTimer(a.sprite);return cc._renderType===cc._RENDER_TYPE_WEBGL&&(a.sprite.flippedY=!0),a.type=cc.ProgressTimer.TYPE_BAR,a.midPoint=cc.p(0.5,0.5),a.barChangeRate=cc.p(1,1),a.percentage=0,this._setAttrs(a,b.width/2,b.height/2),a},_sceneOrder:function(){this._isInSceneOnTop=
!1},_setupTransition:function(){this._sceneToBeModified=this._inScene;this._from=0;this._to=100}});cc.TransitionProgressInOut.create=function(a,b){return new cc.TransitionProgressInOut(a,b)};
cc.TransitionProgressOutIn=cc.TransitionProgress.extend({ctor:function(a,b){cc.TransitionProgress.prototype.ctor.call(this);b&&this.initWithDuration(a,b)},_progressTimerNodeWithRenderTexture:function(a){var b=cc.director.getWinSize();a=new cc.ProgressTimer(a.sprite);return cc._renderType===cc._RENDER_TYPE_WEBGL&&(a.sprite.flippedY=!0),a.type=cc.ProgressTimer.TYPE_BAR,a.midPoint=cc.p(0.5,0.5),a.barChangeRate=cc.p(1,1),a.percentage=100,this._setAttrs(a,b.width/2,b.height/2),a}});
cc.TransitionProgressOutIn.create=function(a,b){return new cc.TransitionProgressOutIn(a,b)};
cc.TransitionPageTurn=cc.TransitionScene.extend({ctor:function(a,b,c){cc.TransitionScene.prototype.ctor.call(this);this._gridProxy=new cc.NodeGrid;this.initWithDuration(a,b,c)},_back:!0,_gridProxy:null,_className:"TransitionPageTurn",initWithDuration:function(a,b,c){return this._back=c,cc.TransitionScene.prototype.initWithDuration.call(this,a,b),!0},actionWithSize:function(a){return this._back?cc.reverseTime(cc.pageTurn3D(this._duration,a)):cc.pageTurn3D(this._duration,a)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);
var a,b,c=cc.director.getWinSize();c.width>c.height?(a=16,b=12):(a=12,b=16);a=this.actionWithSize(cc.size(a,b));b=this._gridProxy;this._back?(b.setTarget(this._inScene),b.onEnter(),this._inScene.visible=!1,b.runAction(cc.sequence(a,cc.callFunc(this.finish,this),cc.stopGrid())),this._inScene.runAction(cc.show())):(b.setTarget(this._outScene),b.onEnter(),b.runAction(cc.sequence(a,cc.callFunc(this.finish,this),cc.stopGrid())))},visit:function(){this._back?this._outScene.visit():this._inScene.visit();
this._gridProxy.visit()},_sceneOrder:function(){this._isInSceneOnTop=this._back}});cc.TransitionPageTurn.create=function(a,b,c){return new cc.TransitionPageTurn(a,b,c)};cc.Codec={name:"Jacob__Codec"};cc.unzip=function(){return cc.Codec.GZip.gunzip.apply(cc.Codec.GZip,arguments)};cc.unzipBase64=function(){var a=cc.Codec.Base64.decode.apply(cc.Codec.Base64,arguments);return cc.Codec.GZip.gunzip.apply(cc.Codec.GZip,[a])};
cc.unzipBase64AsArray=function(a,b){b=b||1;var c,d,e,f=this.unzipBase64(a),g=[];c=0;for(e=f.length/b;e>c;c++){g[c]=0;for(d=b-1;0<=d;--d)g[c]+=f.charCodeAt(c*b+d)<<8*d}return g};cc.unzipAsArray=function(a,b){b=b||1;var c,d,e,f=this.unzip(a),g=[];c=0;for(e=f.length/b;e>c;c++){g[c]=0;for(d=b-1;0<=d;--d)g[c]+=f.charCodeAt(c*b+d)<<8*d}return g};cc.StringToArray=function(a){var b=a.split(","),c=[];for(a=0;a<b.length;a++)c.push(parseInt(b[a]));return c};cc.Codec.Base64={name:"Jacob__Codec__Base64"};
cc.Codec.Base64._keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\x3d";
cc.Codec.Base64.decode=function(a){var b,c,d,e,f,g=[],h=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");h<a.length;)b=this._keyStr.indexOf(a.charAt(h++)),c=this._keyStr.indexOf(a.charAt(h++)),e=this._keyStr.indexOf(a.charAt(h++)),f=this._keyStr.indexOf(a.charAt(h++)),b=b<<2|c>>4,c=(15&c)<<4|e>>2,d=(3&e)<<6|f,g.push(String.fromCharCode(b)),64!==e&&g.push(String.fromCharCode(c)),64!==f&&g.push(String.fromCharCode(d));return g.join("")};
cc.Codec.Base64.decodeAsArray=function(a,b){var c,d,e,f=this.decode(a),g=[];c=0;for(e=f.length/b;e>c;c++){g[c]=0;for(d=b-1;0<=d;--d)g[c]+=f.charCodeAt(c*b+d)<<8*d}return g};cc.uint8ArrayToUint32Array=function(a){if(0!==a.length%4)return null;for(var b=a.length/4,c=window.Uint32Array?new Uint32Array(b):[],d=0;b>d;d++){var e=4*d;c[d]=a[e]+256*a[e+1]+65536*a[e+2]+16777216*a[e+3]}return c};
cc.Codec.GZip=function(a){this.data=a;this.debug=!1;this.gpflags=void 0;this.files=0;this.unzipped=[];this.buf32k=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=Array(cc.Codec.GZip.LITERALS);this.distanceTree=Array(32);this.treepos=0;this.Places=null;this.len=0;this.fpos=Array(17);this.fpos[0]=0;this.fmax=this.flens=void 0};cc.Codec.GZip.gunzip=function(a){a.constructor===Array||a.constructor===String;return(new cc.Codec.GZip(a)).gunzip()[0][0]};
cc.Codec.GZip.HufNode=function(){this.b1=this.b0=0;this.jump=null;this.jumppos=-1};cc.Codec.GZip.LITERALS=288;cc.Codec.GZip.NAMEMAX=256;
cc.Codec.GZip.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];
cc.Codec.GZip.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];cc.Codec.GZip.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];cc.Codec.GZip.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];cc.Codec.GZip.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];cc.Codec.GZip.border=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];
cc.Codec.GZip.prototype.gunzip=function(){return this.outputArr=[],this.nextFile(),this.unzipped};cc.Codec.GZip.prototype.readByte=function(){return this.bits+=8,this.bytepos<this.data.length?this.data.charCodeAt(this.bytepos++):-1};cc.Codec.GZip.prototype.byteAlign=function(){this.bb=1};cc.Codec.GZip.prototype.readBit=function(){var a;return this.bits++,a=1&this.bb,this.bb>>=1,0===this.bb&&(this.bb=this.readByte(),a=1&this.bb,this.bb=this.bb>>1|128),a};
cc.Codec.GZip.prototype.readBits=function(a){for(var b=0,c=a;c--;)b=b<<1|this.readBit();return a&&(b=cc.Codec.GZip.bitReverse[b]>>8-a),b};cc.Codec.GZip.prototype.flushBuffer=function(){this.bIdx=0};cc.Codec.GZip.prototype.addBuffer=function(a){this.buf32k[this.bIdx++]=a;this.outputArr.push(String.fromCharCode(a));32768===this.bIdx&&(this.bIdx=0)};
cc.Codec.GZip.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]++}};
cc.Codec.GZip.prototype.Rec=function(){var a,b=this.Places[this.treepos];if(17===this.len)return-1;if(this.treepos++,this.len++,a=this.IsPat(),0<=a)b.b0=a;else if(b.b0=32768,this.Rec())return-1;if(a=this.IsPat(),0<=a)b.b1=a,b.jump=null;else if(b.b1=32768,b.jump=this.Places[this.treepos],b.jumppos=this.treepos,this.Rec())return-1;return this.len--,0};
cc.Codec.GZip.prototype.CreateTree=function(a,b,c,d){this.Places=a;this.treepos=0;this.flens=c;this.fmax=b;for(a=0;17>a;a++)this.fpos[a]=0;return this.len=0,this.Rec()?-1:0};cc.Codec.GZip.prototype.DecodeValue=function(a){for(var b,c,d=0,e=a[d];;)if(this.readBit()){if(!(32768&e.b1))return e.b1;e=e.jump;b=a.length;for(c=0;b>c;c++)if(a[c]===e){d=c;break}}else{if(!(32768&e.b0))return e.b0;d++;e=a[d]}return-1};
cc.Codec.GZip.prototype.DeflateLoop=function(){var a,b,c,d,e;do if(a=this.readBit(),c=this.readBits(2),0===c){var f;this.byteAlign();f=this.readByte();f|=this.readByte()<<8;b=this.readByte();b|=this.readByte()<<8;for(65535&(f^~b)&&document.write("BlockLen checksum mismatch\n");f--;)b=this.readByte(),this.addBuffer(b)}else if(1===c)for(var g;;)if(g=cc.Codec.GZip.bitReverse[this.readBits(7)]>>1,23<g?(g=g<<1|this.readBit(),199<g?(g-=128,g=g<<1|this.readBit()):(g-=48,143<g&&(g+=136))):g+=256,256>g)this.addBuffer(g);
else{if(256===g)break;var h;g-=257;e=this.readBits(cc.Codec.GZip.cplext[g])+cc.Codec.GZip.cplens[g];g=cc.Codec.GZip.bitReverse[this.readBits(5)]>>3;8<cc.Codec.GZip.cpdext[g]?(h=this.readBits(8),h|=this.readBits(cc.Codec.GZip.cpdext[g]-8)<<8):h=this.readBits(cc.Codec.GZip.cpdext[g]);h+=cc.Codec.GZip.cpdist[g];for(g=0;e>g;g++)b=this.buf32k[this.bIdx-h&32767],this.addBuffer(b)}else if(2===c){var k=Array(320);b=257+this.readBits(5);f=1+this.readBits(5);d=4+this.readBits(4);for(g=0;19>g;g++)k[g]=0;for(g=
0;d>g;g++)k[cc.Codec.GZip.border[g]]=this.readBits(3);e=this.distanceTree.length;for(d=0;e>d;d++)this.distanceTree[d]=new cc.Codec.GZip.HufNode;if(this.CreateTree(this.distanceTree,19,k,0))return this.flushBuffer(),1;e=b+f;d=0;for(var m=-1;e>d;)if(m++,g=this.DecodeValue(this.distanceTree),16>g)k[d++]=g;else if(16===g){var n;if(g=3+this.readBits(2),d+g>e)return this.flushBuffer(),1;for(n=d?k[d-1]:0;g--;)k[d++]=n}else{if(g=17===g?3+this.readBits(3):11+this.readBits(7),d+g>e)return this.flushBuffer(),
1;for(;g--;)k[d++]=0}e=this.literalTree.length;for(d=0;e>d;d++)this.literalTree[d]=new cc.Codec.GZip.HufNode;if(this.CreateTree(this.literalTree,b,k,0))return this.flushBuffer(),1;e=this.literalTree.length;for(d=0;e>d;d++)this.distanceTree[d]=new cc.Codec.GZip.HufNode;e=[];for(d=b;d<k.length;d++)e[d-b]=k[d];if(this.CreateTree(this.distanceTree,f,e,0))return this.flushBuffer(),1;for(;;)if(g=this.DecodeValue(this.literalTree),256<=g){if(g-=256,0===g)break;g--;e=this.readBits(cc.Codec.GZip.cplext[g])+
cc.Codec.GZip.cplens[g];g=this.DecodeValue(this.distanceTree);8<cc.Codec.GZip.cpdext[g]?(h=this.readBits(8),h|=this.readBits(cc.Codec.GZip.cpdext[g]-8)<<8):h=this.readBits(cc.Codec.GZip.cpdext[g]);for(h+=cc.Codec.GZip.cpdist[g];e--;)b=this.buf32k[this.bIdx-h&32767],this.addBuffer(b)}else this.addBuffer(g)}while(!a);return this.flushBuffer(),this.byteAlign(),0};cc.Codec.GZip.prototype.unzipFile=function(a){var b;this.gunzip();for(b=0;b<this.unzipped.length;b++)if(this.unzipped[b][1]===a)return this.unzipped[b][0]};
cc.Codec.GZip.prototype.nextFile=function(){this.outputArr=[];this.modeZIP=!1;var a=[];if(a[0]=this.readByte(),a[1]=this.readByte(),120===a[0]&&218===a[1]&&(this.DeflateLoop(),this.unzipped[this.files]=[this.outputArr.join(""),"geonext.gxt"],this.files++),31===a[0]&&139===a[1]&&(this.skipdir(),this.unzipped[this.files]=[this.outputArr.join(""),"file"],this.files++),80===a[0]&&75===a[1]&&(this.modeZIP=!0,a[2]=this.readByte(),a[3]=this.readByte(),3===a[2]&&4===a[3])){a[0]=this.readByte();a[1]=this.readByte();
this.gpflags=this.readByte();this.gpflags|=this.readByte()<<8;a=this.readByte();a|=this.readByte()<<8;this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();this.readByte();var b=this.readByte(),b=b|this.readByte()<<8,c=this.readByte(),c=c|this.readByte()<<8,d=0;for(this.nameBuf=[];b--;){var e=this.readByte();"/"===e|":"===e?d=0:d<cc.Codec.GZip.NAMEMAX-1&&(this.nameBuf[d++]=String.fromCharCode(e))}this.fileout||
(this.fileout=this.nameBuf);for(var d=0;c>d;)this.readByte(),d++;8===a&&(this.DeflateLoop(),this.unzipped[this.files]=[this.outputArr.join(""),this.nameBuf.join("")],this.files++);this.skipdir()}};
cc.Codec.GZip.prototype.skipdir=function(){var a,b;a=[];if(8&this.gpflags&&(a[0]=this.readByte(),a[1]=this.readByte(),a[2]=this.readByte(),a[3]=this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte()),this.modeZIP&&this.nextFile(),a[0]=this.readByte(),8!==a[0])return 0;if(this.gpflags=this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),4&this.gpflags){a[0]=
this.readByte();a[2]=this.readByte();this.len=a[0]+256*a[1];for(a=0;a<this.len;a++)this.readByte()}if(8&this.gpflags){a=0;for(this.nameBuf=[];b=this.readByte();)("7"===b||":"===b)&&(a=0),a<cc.Codec.GZip.NAMEMAX-1&&(this.nameBuf[a++]=b)}if(16&this.gpflags)for(;this.readByte(););2&this.gpflags&&(this.readByte(),this.readByte());this.DeflateLoop();this.readByte();this.readByte();this.readByte();this.readByte();this.modeZIP&&this.nextFile()};
(function(){function a(a){throw a;}function b(a,b){var c=a.split("."),d=z;!(c[0]in d)&&d.execScript&&d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)c.length||b===A?d=d[e]?d[e]:d[e]={}:d[e]=b}function c(a){if("string"==typeof a){var b,c=a.split("");a=0;for(b=c.length;b>a;a++)c[a]=(255&c[a].charCodeAt(0))>>>0;a=c}for(var c=1,d=0,e=a.length,f=0;0<e;){b=1024<e?1024:e;e-=b;do c+=a[f++],d+=c;while(--b);c%=65521;d%=65521}return(d<<16|c)>>>0}function d(b,c){this.index="number"==typeof c?c:0;
this.i=0;this.buffer=b instanceof(w?Uint8Array:Array)?b:new (w?Uint8Array:Array)(32768);2*this.buffer.length<=this.index&&a(Error("invalid index"));this.buffer.length<=this.index&&this.f()}function e(a){this.buffer=new (w?Uint16Array:Array)(2*a);this.length=0}function f(a){var b,c,d,e,f,g,h,k,m,p=a.length,n=0,C=Number.POSITIVE_INFINITY;for(k=0;p>k;++k)a[k]>n&&(n=a[k]),a[k]<C&&(C=a[k]);b=1<<n;c=new (w?Uint32Array:Array)(b);d=1;e=0;for(f=2;n>=d;){for(k=0;p>k;++k)if(a[k]===d){g=0;h=e;for(m=0;d>m;++m)g=
g<<1|1&h,h>>=1;for(m=g;b>m;m+=f)c[m]=d<<16|k;++e}++d;e<<=1;f<<=1}return[c,n,C]}function g(a,b){this.h=D;this.w=0;this.input=a;this.b=0;b&&(b.lazy&&(this.w=b.lazy),"number"==typeof b.compressionType&&(this.h=b.compressionType),b.outputBuffer&&(this.a=w&&b.outputBuffer instanceof Array?new Uint8Array(b.outputBuffer):b.outputBuffer),"number"==typeof b.outputIndex&&(this.b=b.outputIndex));this.a||(this.a=new (w?Uint8Array:Array)(32768))}function h(a,b){this.length=a;this.G=b}function k(){var b=H;switch(F){case 3===
b:return[257,b-3,0];case 4===b:return[258,b-4,0];case 5===b:return[259,b-5,0];case 6===b:return[260,b-6,0];case 7===b:return[261,b-7,0];case 8===b:return[262,b-8,0];case 9===b:return[263,b-9,0];case 10===b:return[264,b-10,0];case 12>=b:return[265,b-11,1];case 14>=b:return[266,b-13,1];case 16>=b:return[267,b-15,1];case 18>=b:return[268,b-17,1];case 22>=b:return[269,b-19,2];case 26>=b:return[270,b-23,2];case 30>=b:return[271,b-27,2];case 34>=b:return[272,b-31,2];case 42>=b:return[273,b-35,3];case 50>=
b:return[274,b-43,3];case 58>=b:return[275,b-51,3];case 66>=b:return[276,b-59,3];case 82>=b:return[277,b-67,4];case 98>=b:return[278,b-83,4];case 114>=b:return[279,b-99,4];case 130>=b:return[280,b-115,4];case 162>=b:return[281,b-131,5];case 194>=b:return[282,b-163,5];case 226>=b:return[283,b-195,5];case 257>=b:return[284,b-227,5];case 258===b:return[285,b-258,0];default:a("invalid length: "+b)}}function m(b,c){function d(b,c){var e,f=b.G,g=[],h=0;e=K[b.length];g[h++]=65535&e;g[h++]=e>>16&255;g[h++]=
e>>24;var k;switch(F){case 1===f:k=[0,f-1,0];break;case 2===f:k=[1,f-2,0];break;case 3===f:k=[2,f-3,0];break;case 4===f:k=[3,f-4,0];break;case 6>=f:k=[4,f-5,1];break;case 8>=f:k=[5,f-7,1];break;case 12>=f:k=[6,f-9,2];break;case 16>=f:k=[7,f-13,2];break;case 24>=f:k=[8,f-17,3];break;case 32>=f:k=[9,f-25,3];break;case 48>=f:k=[10,f-33,4];break;case 64>=f:k=[11,f-49,4];break;case 96>=f:k=[12,f-65,5];break;case 128>=f:k=[13,f-97,5];break;case 192>=f:k=[14,f-129,6];break;case 256>=f:k=[15,f-193,6];break;
case 384>=f:k=[16,f-257,7];break;case 512>=f:k=[17,f-385,7];break;case 768>=f:k=[18,f-513,8];break;case 1024>=f:k=[19,f-769,8];break;case 1536>=f:k=[20,f-1025,9];break;case 2048>=f:k=[21,f-1537,9];break;case 3072>=f:k=[22,f-2049,10];break;case 4096>=f:k=[23,f-3073,10];break;case 6144>=f:k=[24,f-4097,11];break;case 8192>=f:k=[25,f-6145,11];break;case 12288>=f:k=[26,f-8193,12];break;case 16384>=f:k=[27,f-12289,12];break;case 24576>=f:k=[28,f-16385,13];break;case 32768>=f:k=[29,f-24577,13];break;default:a("invalid distance")}e=
k;g[h++]=e[0];g[h++]=e[1];g[h++]=e[2];e=0;for(f=g.length;f>e;++e)P[s++]=g[e];r[g[0]]++;G[g[3]]++;D=b.length+c-1;p=null}var e,f,g,k,m,p,n,C={},P=w?new Uint16Array(2*c.length):[],s=0,D=0,r=new (w?Uint32Array:Array)(286),G=new (w?Uint32Array:Array)(30),t=b.w;if(!w){for(g=0;285>=g;)r[g++]=0;for(g=0;29>=g;)G[g++]=0}r[256]=1;e=0;for(f=c.length;f>e;++e){g=m=0;for(k=3;k>g&&e+g!==f;++g)m=m<<8|c[e+g];if(C[m]===A&&(C[m]=[]),g=C[m],!(0<D--)){for(;0<g.length&&32768<e-g[0];)g.shift();if(e+3>=f){p&&d(p,-1);g=0;
for(k=f-e;k>g;++g)n=c[e+g],P[s++]=n,++r[n];break}if(0<g.length){m=k=A;var M=0,y=A,Y=A,u=y=A,R=c.length,Y=0,u=g.length;a:for(;u>Y;Y++){if(k=g[u-Y-1],y=3,3<M){for(y=M;3<y;y--)if(c[k+y-1]!==c[e+y-1])continue a;y=M}for(;258>y&&R>e+y&&c[k+y]===c[e+y];)++y;if(y>M&&(m=k,M=y),258===y)break}k=new h(M,e-m);p?p.length<k.length?(n=c[e-1],P[s++]=n,++r[n],d(k,0)):d(p,-1):k.length<t?p=k:d(k,0)}else p?d(p,-1):(n=c[e],P[s++]=n,++r[n])}g.push(e)}return P[s++]=256,r[256]++,b.L=r,b.K=G,w?P.subarray(0,s):P}function n(a,
b){function c(a){var b=G[a][t[a]];b===s?(c(a+1),c(a+1)):--D[b];++t[a]}var d,f,g,h;f=a.length;var k=new e(572),m=new (w?Uint8Array:Array)(f);if(!w)for(g=0;f>g;g++)m[g]=0;for(g=0;f>g;++g)0<a[g]&&k.push(g,a[g]);if(d=Array(k.length/2),f=new (w?Uint32Array:Array)(k.length/2),1===d.length)return m[k.pop().index]=1,m;g=0;for(h=k.length/2;h>g;++g)d[g]=k.pop(),f[g]=d[g].value;var p,n,C,P,s=f.length;h=new (w?Uint16Array:Array)(b);var k=new (w?Uint8Array:Array)(b),D=new (w?Uint8Array:Array)(s),r=Array(b),G=
Array(b),t=Array(b);p=(1<<b)-s;n=1<<b-1;h[b-1]=s;for(g=0;b>g;++g)n>p?k[g]=0:(k[g]=1,p-=n),p<<=1,h[b-2-g]=(h[b-1-g]/2|0)+s;h[0]=k[0];r[0]=Array(h[0]);G[0]=Array(h[0]);for(g=1;b>g;++g)h[g]>2*h[g-1]+k[g]&&(h[g]=2*h[g-1]+k[g]),r[g]=Array(h[g]),G[g]=Array(h[g]);for(p=0;s>p;++p)D[p]=b;for(n=0;n<h[b-1];++n)r[b-1][n]=f[n],G[b-1][n]=n;for(p=0;b>p;++p)t[p]=0;1===k[b-1]&&(--D[0],++t[b-1]);for(g=b-2;0<=g;--g){C=p=0;P=t[g+1];for(n=0;n<h[g];n++)C=r[g+1][P]+r[g+1][P+1],C>f[p]?(r[g][n]=C,G[g][n]=s,P+=2):(r[g][n]=
f[p],G[g][n]=p,++p);t[g]=0;1===k[g]&&c(g)}f=D;g=0;for(h=d.length;h>g;++g)m[d[g].index]=f[g];return m}function p(b){var c,d,e,f,g=new (w?Uint16Array:Array)(b.length);e=[];var h=[],k=0;c=0;for(d=b.length;d>c;c++)e[b[c]]=(0|e[b[c]])+1;c=1;for(d=16;d>=c;c++)h[c]=k,k+=0|e[c],k>1<<c&&a("overcommitted"),k<<=1;65536>k&&a("undercommitted");c=0;for(d=b.length;d>c;c++){k=h[b[c]];h[b[c]]+=1;e=g[c]=0;for(f=b[c];f>e;e++)g[c]=g[c]<<1|1&k,k>>>=1}return g}function r(a,b){this.input=a;this.a=new (w?Uint8Array:Array)(32768);
this.h=N.j;var c,d={};!b&&(b={})||"number"!=typeof b.compressionType||(this.h=b.compressionType);for(c in b)d[c]=b[c];d.outputBuffer=this.a;this.z=new g(this.input,d)}function s(b,c){switch(this.k=[],this.l=32768,this.e=this.g=this.c=this.q=0,this.input=w?new Uint8Array(b):b,this.s=!1,this.m=U,this.B=!1,(c||!(c={}))&&(c.index&&(this.c=c.index),c.bufferSize&&(this.l=c.bufferSize),c.bufferType&&(this.m=c.bufferType),c.resize&&(this.B=c.resize)),this.m){case W:this.b=32768;this.a=new (w?Uint8Array:Array)(32768+
this.l+258);break;case U:this.b=0;this.a=new (w?Uint8Array:Array)(this.l);this.f=this.J;this.t=this.H;this.o=this.I;break;default:a(Error("invalid inflate mode"))}}function v(b,c){for(var d,e=b.g,f=b.e,g=b.input,h=b.c;c>f;)d=g[h++],d===A&&a(Error("input buffer is broken")),e|=d<<f,f+=8;return d=e&(1<<c)-1,b.g=e>>>c,b.e=f-c,b.c=h,d}function u(b,c){for(var d,e,f,g=b.g,h=b.e,k=b.input,m=b.c,p=c[0],n=c[1];n>h;)d=k[m++],d===A&&a(Error("input buffer is broken")),g|=d<<h,h+=8;return e=p[g&(1<<n)-1],f=e>>>
16,b.g=g>>f,b.e=h-f,b.c=m,65535&e}function t(a){function b(a,c,d){var e,f,g;for(g=0;a>g;)switch(e=u(this,c)){case 16:for(e=3+v(this,2);e--;)d[g++]=f;break;case 17:for(e=3+v(this,3);e--;)d[g++]=0;f=0;break;case 18:for(e=11+v(this,7);e--;)d[g++]=0;f=0;break;default:f=d[g++]=e}return d}var c,d,e,g=v(a,5)+257,h=v(a,5)+1;d=v(a,4)+4;e=new (w?Uint8Array:Array)(C.length);for(c=0;d>c;++c)e[C[c]]=v(a,3);c=f(e);d=new (w?Uint8Array:Array)(g);e=new (w?Uint8Array:Array)(h);a.o(f(b.call(a,g,c,d)),f(b.call(a,h,c,
e)))}function x(b,c){var d,e;switch(this.input=b,this.c=0,(c||!(c={}))&&(c.index&&(this.c=c.index),c.verify&&(this.M=c.verify)),d=b[this.c++],e=b[this.c++],15&d){case V:this.method=V;break;default:a(Error("unsupported compression method"))}0!==((d<<8)+e)%31&&a(Error("invalid fcheck flag:"+((d<<8)+e)%31));32&e&&a(Error("fdict flag is not supported"));this.A=new s(b,{index:this.c,bufferSize:c.bufferSize,bufferType:c.bufferType,resize:c.resize})}var A=void 0,F=!0,z=this,w="undefined"!=typeof Uint8Array&&
"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array;d.prototype.f=function(){var a,b=this.buffer,c=b.length,d=new (w?Uint8Array:Array)(c<<1);if(w)d.set(b);else for(a=0;c>a;++a)d[a]=b[a];return this.buffer=d};d.prototype.d=function(a,b,c){var d=this.buffer,e=this.index,f=this.i,g=d[e];if(c&&1<b&&(a=8<b?(L[255&a]<<24|L[a>>>8&255]<<16|L[a>>>16&255]<<8|L[a>>>24&255])>>32-b:L[a]>>8-b),8>b+f)g=g<<b|a,f+=b;else for(c=0;b>c;++c)g=g<<1|a>>b-c-1&1,8===++f&&(f=0,d[e++]=L[g],g=0,e===d.length&&(d=
this.f()));d[e]=g;this.buffer=d;this.i=f;this.index=e};d.prototype.finish=function(){var a,b=this.buffer,c=this.index;return 0<this.i&&(b[c]<<=8-this.i,b[c]=L[b[c]],c++),w?a=b.subarray(0,c):(b.length=c,a=b),a};var B,E=new (w?Uint8Array:Array)(256);for(B=0;256>B;++B){for(var I=B,J=I,O=7,I=I>>>1;I;I>>>=1)J<<=1,J|=1&I,--O;E[B]=(J<<O&255)>>>0}var L=E;B=[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];w&&new Uint32Array(B);e.prototype.getParent=function(a){return 2*((a-2)/4|0)};e.prototype.push=function(a,b){var c,d,e,f=this.buffer;c=this.length;f[this.length++]=b;for(f[this.length++]=a;0<c&&(d=this.getParent(c),f[c]>f[d]);)e=f[c],f[c]=f[d],f[d]=e,e=f[c+1],f[c+1]=f[d+1],f[d+1]=e,c=d;return this.length};e.prototype.pop=function(){var a,b,c,d,e,f=this.buffer;b=f[0];a=f[1];this.length-=2;f[0]=f[this.length];f[1]=f[this.length+1];for(e=
0;(d=2*e+2,!(d>=this.length))&&(d+2<this.length&&f[d+2]>f[d]&&(d+=2),f[d]>f[e]);)c=f[e],f[e]=f[d],f[d]=c,c=f[e+1],f[e+1]=f[d+1],f[d+1]=c,e=d;return{index:a,value:b,length:this.length}};var D=2;B={NONE:0,r:1,j:D,N:3};for(var y=[],E=0;288>E;E++)switch(F){case 143>=E:y.push([E+48,8]);break;case 255>=E:y.push([E-144+400,9]);break;case 279>=E:y.push([E-256+0,7]);break;case 287>=E:y.push([E-280+192,8]);break;default:a("invalid literal: "+E)}g.prototype.n=function(){var b,c,e,f,g=this.input;switch(this.h){case 0:e=
0;for(f=g.length;f>e;){c=w?g.subarray(e,e+65535):g.slice(e,e+65535);e+=c.length;var h=e===f,k=A,C=A,P=A,s=A,r=A,G=this.a,t=this.b;if(w){for(G=new Uint8Array(this.a.buffer);G.length<=t+c.length+5;)G=new Uint8Array(G.length<<1);G.set(this.a)}if(k=h?1:0,G[t++]=0|k,C=c.length,P=~C+65536&65535,G[t++]=255&C,G[t++]=C>>>8&255,G[t++]=255&P,G[t++]=P>>>8&255,w)G.set(c,t),t+=c.length,G=G.subarray(0,t);else{s=0;for(r=c.length;r>s;++s)G[t++]=c[s];G.length=t}this.b=t;this.a=G}break;case 1:e=new d(new Uint8Array(this.a.buffer),
this.b);e.d(1,1,F);e.d(1,2,F);h=m(this,g);g=0;for(c=h.length;c>g;g++)if(f=h[g],d.prototype.d.apply(e,y[f]),256<f)e.d(h[++g],h[++g],F),e.d(h[++g],5),e.d(h[++g],h[++g],F);else if(256===f)break;this.a=e.finish();this.b=this.a.length;break;case D:var M,Y,u,K;f=new d(new Uint8Array(this.a),this.b);u=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];P=Array(19);k=D;f.d(1,1,F);f.d(k,2,F);g=m(this,g);s=n(this.L,15);r=p(s);k=n(this.K,7);C=p(k);for(G=286;257<G&&0===s[G-1];G--);for(t=30;1<t&&0===k[t-1];t--);
var R,V,H,T;R=G;V=t;M=new (w?Uint32Array:Array)(R+V);var v=new (w?Uint32Array:Array)(316);Y=new (w?Uint8Array:Array)(19);for(b=K=0;R>b;b++)M[K++]=s[b];for(b=0;V>b;b++)M[K++]=k[b];if(!w){b=0;for(V=Y.length;V>b;++b)Y[b]=0}b=H=0;for(V=M.length;V>b;b+=K){for(K=1;V>b+K&&M[b+K]===M[b];++K);if(R=K,0===M[b])if(3>R)for(;0<R--;)v[H++]=0,Y[0]++;else for(;0<R;)T=138>R?R:138,T>R-3&&R>T&&(T=R-3),10>=T?(v[H++]=17,v[H++]=T-3,Y[17]++):(v[H++]=18,v[H++]=T-11,Y[18]++),R-=T;else if(v[H++]=M[b],Y[M[b]]++,R--,3>R)for(;0<
R--;)v[H++]=M[b],Y[M[b]]++;else for(;0<R;)T=6>R?R:6,T>R-3&&R>T&&(T=R-3),v[H++]=16,v[H++]=T-3,Y[16]++,R-=T}b=w?v.subarray(0,H):v.slice(0,H);Y=n(Y,7);for(K=0;19>K;K++)P[K]=Y[u[K]];for(M=19;4<M&&0===P[M-1];M--);u=p(Y);f.d(G-257,5,F);f.d(t-1,5,F);f.d(M-4,4,F);for(K=0;M>K;K++)f.d(P[K],3,F);K=0;for(P=b.length;P>K;K++)if(c=b[K],f.d(u[c],Y[c],F),16<=c){switch(K++,c){case 16:h=2;break;case 17:h=3;break;case 18:h=7;break;default:a("invalid code: "+c)}f.d(b[K],h,F)}h=[r,s];C=[C,k];c=h[0];h=h[1];k=C[0];r=C[1];
C=0;for(P=g.length;P>C;++C)if(e=g[C],f.d(c[e],h[e],F),256<e)f.d(g[++C],g[++C],F),s=g[++C],f.d(k[s],r[s],F),f.d(g[++C],g[++C],F);else if(256===e)break;this.a=f.finish();this.b=this.a.length;break;default:a("invalid compression type")}return this.a};var H,I=[];for(H=3;258>=H;H++)E=k(),I[H]=E[2]<<24|E[1]<<16|E[0];var K=w?new Uint32Array(I):I,N=B;r.prototype.n=function(){var b,d,e,f,g,h,k,m=0;switch(k=this.a,b=V){case V:d=Math.LOG2E*Math.log(32768)-8;break;default:a(Error("invalid compression method"))}switch(e=
d<<4|b,k[m++]=e,b){case V:switch(this.h){case N.NONE:g=0;break;case N.r:g=1;break;case N.j:g=2;break;default:a(Error("unsupported compression type"))}break;default:a(Error("invalid compression method"))}return f=g<<6|0,k[m++]=f|31-(256*e+f)%31,h=c(this.input),this.z.b=m,k=this.z.n(),m=k.length,w&&(k=new Uint8Array(k.buffer),k.length<=m+4&&(this.a=new Uint8Array(k.length+4),this.a.set(k),k=this.a),k=k.subarray(0,m+4)),k[m++]=h>>24&255,k[m++]=h>>16&255,k[m++]=h>>8&255,k[m++]=255&h,k};b("Zlib.Deflate",
r);b("Zlib.Deflate.compress",function(a,b){return(new r(a,b)).n()});b("Zlib.Deflate.CompressionType",N);b("Zlib.Deflate.CompressionType.NONE",N.NONE);b("Zlib.Deflate.CompressionType.FIXED",N.r);b("Zlib.Deflate.CompressionType.DYNAMIC",N.j);var W=0,U=1;B={D:W,C:U};s.prototype.p=function(){for(;!this.s;){var b=v(this,3);switch(1&b&&(this.s=F),b>>>=1){case 0:var b=this.input,c=this.c,d=this.a,e=this.b,f=A,g=A,h=A,k=d.length,m=A;switch(this.e=this.g=0,f=b[c++],f===A&&a(Error("invalid uncompressed block header: LEN (first byte)")),
g=f,f=b[c++],f===A&&a(Error("invalid uncompressed block header: LEN (second byte)")),g|=f<<8,f=b[c++],f===A&&a(Error("invalid uncompressed block header: NLEN (first byte)")),h=f,f=b[c++],f===A&&a(Error("invalid uncompressed block header: NLEN (second byte)")),h|=f<<8,g===~h&&a(Error("invalid uncompressed block header: length verify")),c+g>b.length&&a(Error("input buffer is broken")),this.m){case W:for(;e+g>d.length;){if(m=k-e,g-=m,w)d.set(b.subarray(c,c+m),e),e+=m,c+=m;else for(;m--;)d[e++]=b[c++];
this.b=e;d=this.f();e=this.b}break;case U:for(;e+g>d.length;)d=this.f({v:2});break;default:a(Error("invalid inflate mode"))}if(w)d.set(b.subarray(c,c+g),e),e+=g,c+=g;else for(;g--;)d[e++]=b[c++];this.c=c;this.b=e;this.a=d;break;case 1:this.o(M,Y);break;case 2:t(this);break;default:a(Error("unknown BTYPE: "+b))}}return this.t()};for(var E=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],C=w?new Uint16Array(E):E,E=[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],G=w?new Uint16Array(E):E,E=[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],T=w?new Uint8Array(E):E,E=[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],P=w?new Uint16Array(E):E,E=[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],R=w?new Uint8Array(E):E,J=new (w?Uint8Array:Array)(288),E=0,I=J.length;I>E;++E)J[E]=143>=E?8:255>=E?9:279>=E?7:8;for(var M=f(J),J=new (w?Uint8Array:Array)(30),E=0,I=
J.length;I>E;++E)J[E]=5;var Y=f(J);s.prototype.o=function(a,b){var c=this.a,d=this.b;this.u=a;for(var e,f,g,h=c.length-258;256!==(e=u(this,a));)if(256>e)d>=h&&(this.b=d,c=this.f(),d=this.b),c[d++]=e;else{e-=257;g=G[e];0<T[e]&&(g+=v(this,T[e]));e=u(this,b);f=P[e];0<R[e]&&(f+=v(this,R[e]));for(d>=h&&(this.b=d,c=this.f(),d=this.b);g--;)c[d]=c[d++-f]}for(;8<=this.e;)this.e-=8,this.c--;this.b=d};s.prototype.I=function(a,b){var c=this.a,d=this.b;this.u=a;for(var e,f,g,h=c.length;256!==(e=u(this,a));)if(256>
e)d>=h&&(c=this.f(),h=c.length),c[d++]=e;else{e-=257;g=G[e];0<T[e]&&(g+=v(this,T[e]));e=u(this,b);f=P[e];0<R[e]&&(f+=v(this,R[e]));for(d+g>h&&(c=this.f(),h=c.length);g--;)c[d]=c[d++-f]}for(;8<=this.e;)this.e-=8,this.c--;this.b=d};s.prototype.f=function(){var a,b,c=new (w?Uint8Array:Array)(this.b-32768),d=this.b-32768,e=this.a;if(w)c.set(e.subarray(32768,c.length));else{a=0;for(b=c.length;b>a;++a)c[a]=e[a+32768]}if(this.k.push(c),this.q+=c.length,w)e.set(e.subarray(d,d+32768));else for(a=0;32768>a;++a)e[a]=
e[d+a];return this.b=32768,e};s.prototype.J=function(a){var b,c,d,e,f=this.input.length/this.c+1|0,g=this.input,h=this.a;return a&&("number"==typeof a.v&&(f=a.v),"number"==typeof a.F&&(f+=a.F)),2>f?(c=(g.length-this.c)/this.u[2],e=258*(c/2)|0,d=e<h.length?h.length+e:h.length<<1):d=h.length*f,w?(b=new Uint8Array(d),b.set(h)):b=h,this.a=b};s.prototype.t=function(){var a,b,c,d,e,f=0,g=this.a,h=this.k,k=new (w?Uint8Array:Array)(this.q+(this.b-32768));if(0===h.length)return w?this.a.subarray(32768,this.b):
this.a.slice(32768,this.b);b=0;for(c=h.length;c>b;++b){a=h[b];d=0;for(e=a.length;e>d;++d)k[f++]=a[d]}b=32768;for(c=this.b;c>b;++b)k[f++]=g[b];return this.k=[],this.buffer=k};s.prototype.H=function(){var a,b=this.b;return w?this.B?(a=new Uint8Array(b),a.set(this.a.subarray(0,b))):a=this.a.subarray(0,b):(this.a.length>b&&(this.a.length=b),a=this.a),this.buffer=a};x.prototype.p=function(){var b,d,e=this.input;return b=this.A.p(),this.c=this.A.c,this.M&&(d=(e[this.c++]<<24|e[this.c++]<<16|e[this.c++]<<
8|e[this.c++])>>>0,d!==c(b)&&a(Error("invalid adler-32 checksum"))),b};b("Zlib.Inflate",x);b("Zlib.Inflate.BufferType",B);B.ADAPTIVE=B.C;B.BLOCK=B.D;b("Zlib.Inflate.prototype.decompress",x.prototype.p);B=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];w&&new Uint16Array(B);B=[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];w&&new Uint16Array(B);B=[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];w&&new Uint8Array(B);B=[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];w&&new Uint16Array(B);B=[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];w&&new Uint8Array(B);I=new (w?Uint8Array:Array)(288);B=0;for(E=I.length;E>B;++B)I[B]=143>=B?8:255>=B?9:279>=B?7:8;f(I);I=new (w?Uint8Array:Array)(30);B=0;for(E=I.length;E>B;++B)I[B]=5;f(I);var V=8}).call(this);_p=window;_p=_p.Zlib=_p.Zlib;_p.Deflate=_p.Deflate;_p.Deflate.compress=_p.Deflate.compress;
_p.Inflate=_p.Inflate;_p.Inflate.BufferType=_p.Inflate.BufferType;_p.Inflate.prototype.decompress=_p.Inflate.prototype.decompress;
cc.PNGReader=cc.Class.extend({ctor:function(a){var b,c,d,e,f;this.data=a;this.pos=8;this.palette=[];this.imgData=[];this.transparency={};this.animation=null;this.text={};for(d=null;;){b=this.readUInt32();f=a=void 0;f=[];for(a=0;4>a;++a)f.push(String.fromCharCode(this.data[this.pos++]));switch(a=f.join("")){case "IHDR":this.width=this.readUInt32();this.height=this.readUInt32();this.bits=this.data[this.pos++];this.colorType=this.data[this.pos++];this.compressionMethod=this.data[this.pos++];this.filterMethod=
this.data[this.pos++];this.interlaceMethod=this.data[this.pos++];break;case "acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case "PLTE":this.palette=this.read(b);break;case "fcTL":d&&this.animation.frames.push(d);this.pos+=4;d={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()};a=this.readUInt16();b=this.readUInt16()||100;d.delay=1E3*a/b;d.disposeOp=this.data[this.pos++];d.blendOp=this.data[this.pos++];
d.data=[];break;case "IDAT":case "fdAT":"fdAT"===a&&(this.pos+=4,b-=4);a=(null!=d?d.data:void 0)||this.imgData;for(f=0;0<=b?b>f:f>b;0<=b?++f:--f)a.push(this.data[this.pos++]);break;case "tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(b),e=255-this.transparency.indexed.length,0<e)for(b=0;0<=e?e>b:b>e;0<=e?++b:--b)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(b)[0];break;case 2:this.transparency.rgb=this.read(b)}break;
case "tEXt":f=this.read(b);b=f.indexOf(0);a=String.fromCharCode.apply(String,f.slice(0,b));this.text[a]=String.fromCharCode.apply(String,f.slice(b+1));break;case "IEND":d&&this.animation.frames.push(d);a:{switch(this.colorType){case 0:case 3:case 4:d=1;break a;case 2:case 6:d=3;break a}d=void 0}this.colors=d;this.hasAlphaChannel=4===(c=this.colorType)||6===c;c=this.colors+(this.hasAlphaChannel?1:0);this.pixelBitlength=this.bits*c;a:{switch(this.colors){case 1:c="DeviceGray";break a;case 3:c="DeviceRGB";
break a}c=void 0}return this.colorSpace=c,void(Uint8Array!=Array&&(this.imgData=new Uint8Array(this.imgData)));default:this.pos+=b}if(this.pos+=4,this.pos>this.data.length)throw Error("Incomplete or corrupt PNG file");}},read:function(a){var b,c;c=[];for(b=0;0<=a?a>b:b>a;0<=a?++b:--b)c.push(this.data[this.pos++]);return c},readUInt32:function(){var a,b,c,d;return a=this.data[this.pos++]<<24,b=this.data[this.pos++]<<16,c=this.data[this.pos++]<<8,d=this.data[this.pos++],a|b|c|d},readUInt16:function(){var a,
b;return a=this.data[this.pos++]<<8,b=this.data[this.pos++],a|b},decodePixels:function(a){var b,c,d,e,f,g,h,k,m,n,p,r,s,v,u;if(null==a&&(a=this.imgData),0===a.length)return new Uint8Array(0);a=(new Zlib.Inflate(a,{index:0,verify:!1})).decompress();k=this.pixelBitlength/8;r=k*this.width;m=new Uint8Array(r*this.height);g=a.length;for(c=n=p=0;g>n;){switch(a[n++]){case 0:for(b=0;r>b;b+=1)m[c++]=a[n++];break;case 1:for(e=u=0;r>u;e=u+=1)b=a[n++],f=k>e?0:m[c-k],m[c++]=(b+f)%256;break;case 2:for(e=f=0;r>
f;e=f+=1)b=a[n++],d=(e-e%k)/k,s=p&&m[(p-1)*r+d*k+e%k],m[c++]=(s+b)%256;break;case 3:for(e=u=0;r>u;e=u+=1)b=a[n++],d=(e-e%k)/k,f=k>e?0:m[c-k],s=p&&m[(p-1)*r+d*k+e%k],m[c++]=(b+Math.floor((f+s)/2))%256;break;case 4:for(e=u=0;r>u;e=u+=1)b=a[n++],d=(e-e%k)/k,f=k>e?0:m[c-k],0===p?s=v=0:(s=m[(p-1)*r+d*k+e%k],v=d&&m[(p-1)*r+(d-1)*k+e%k]),h=f+s-v,e=Math.abs(h-f),d=Math.abs(h-s),h=Math.abs(h-v),f=d>=e&&h>=e?f:h>=d?s:v,m[c++]=(b+f)%256;break;default:throw Error("Invalid filter algorithm: "+a[n-1]);}p++}return m},
copyToImageData:function(a,b){var c,d,e,f,g,h,k,m,n;if(d=this.colors,m=null,c=this.hasAlphaChannel,this.palette.length&&(m=null!=(n=this._decodedPalette)?n:this._decodedPalette=this.decodePalette(),d=4,c=!0),e=a.data||a,k=e.length,g=m||b,f=h=0,1===d)for(;k>f;)d=m?4*b[f/4]:h,h=g[d++],e[f++]=h,e[f++]=h,e[f++]=h,e[f++]=c?g[d++]:255,h=d;else for(;k>f;)d=m?4*b[f/4]:h,e[f++]=g[d++],e[f++]=g[d++],e[f++]=g[d++],e[f++]=c?g[d++]:255,h=d},decodePalette:function(){var a,b,c,d,e,f,g,h,k;c=this.palette;f=this.transparency.indexed||
[];e=new Uint8Array((f.length||0)+c.length);b=g=a=d=0;for(h=c.length;h>g;b=g+=3)e[d++]=c[b],e[d++]=c[b+1],e[d++]=c[b+2],e[d++]=null!=(k=f[a++])?k:255;return e},render:function(a){var b,c;return a.width=this.width,a.height=this.height,b=a.getContext("2d"),c=b.createImageData(this.width,this.height),this.copyToImageData(c,this.decodePixels()),b.putImageData(c,0,0)}});
cc.tiffReader={_littleEndian:!1,_tiffData:null,_fileDirectories:[],getUint8:function(a){return this._tiffData[a]},getUint16:function(a){return this._littleEndian?this._tiffData[a+1]<<8|this._tiffData[a]:this._tiffData[a]<<8|this._tiffData[a+1]},getUint32:function(a){var b=this._tiffData;return this._littleEndian?b[a+3]<<24|b[a+2]<<16|b[a+1]<<8|b[a]:b[a]<<24|b[a+1]<<16|b[a+2]<<8|b[a+3]},checkLittleEndian:function(){var a=this.getUint16(0);if(18761===a)this.littleEndian=!0;else{if(19789!==a)throw console.log(a),
TypeError("Invalid byte order value.");this.littleEndian=!1}return this.littleEndian},hasTowel:function(){if(42!==this.getUint16(2))throw RangeError("You forgot your towel!");return!0},getFieldTypeName:function(a){var b=this.fieldTypeNames;return a in b?b[a]:null},getFieldTagName:function(a){var b=this.fieldTagNames;return a in b?b[a]:(console.log("Unknown Field Tag:",a),"Tag"+a)},getFieldTypeLength:function(a){return-1!==["BYTE","ASCII","SBYTE","UNDEFINED"].indexOf(a)?1:-1!==["SHORT","SSHORT"].indexOf(a)?
2:-1!==["LONG","SLONG","FLOAT"].indexOf(a)?4:-1!==["RATIONAL","SRATIONAL","DOUBLE"].indexOf(a)?8:null},getFieldValues:function(a,b,c,d){a=[];var e=this.getFieldTypeLength(b);if(4>=e*c)a.push(!1===this.littleEndian?d>>>8*(4-e):d);else for(var f=0;c>f;f++){var g=e*f;8<=e?-1!==["RATIONAL","SRATIONAL"].indexOf(b)?(a.push(this.getUint32(d+g)),a.push(this.getUint32(d+g+4))):cc.log("Can't handle this field type or size"):a.push(this.getBytes(e,d+g))}return"ASCII"===b&&a.forEach(function(a,b,c){c[b]=String.fromCharCode(a)}),
a},getBytes:function(a,b){if(0>=a)cc.log("No bytes requested");else{if(1>=a)return this.getUint8(b);if(2>=a)return this.getUint16(b);if(3>=a)return this.getUint32(b)>>>8;if(4>=a)return this.getUint32(b);cc.log("Too many bytes requested")}},getBits:function(a,b,c){c=c||0;var d,e;b+=Math.floor(c/8);var f=c+a;a=32-a;return 0>=f?console.log("No bits requested"):8>=f?(d=24+c,e=this.getUint8(b)):16>=f?(d=16+c,e=this.getUint16(b)):32>=f?(d=c,e=this.getUint32(b)):console.log("Too many bits requested"),{bits:e<<
d>>>a,byteOffset:b+Math.floor(f/8),bitOffset:f%8}},parseFileDirectory:function(a){var b=this.getUint16(a),c=[];a+=2;for(var d=0;b>d;a+=12,d++){var e=this.getUint16(a),f=this.getUint16(a+2),g=this.getUint32(a+4),h=this.getUint32(a+8),e=this.getFieldTagName(e),f=this.getFieldTypeName(f),g=this.getFieldValues(e,f,g,h);c[e]={type:f,values:g}}this._fileDirectories.push(c);b=this.getUint32(a);0!==b&&this.parseFileDirectory(b)},clampColorSample:function(a,b){var c=Math.pow(2,8-b);return Math.floor(a*c+(c-
1))},parseTIFF:function(a,b){if(b=b||cc.newElement("canvas"),this._tiffData=a,this.canvas=b,this.checkLittleEndian(),this.hasTowel()){var c=this.getUint32(4);this._fileDirectories.length=0;this.parseFileDirectory(c);var d=this._fileDirectories[0],c=d.ImageWidth.values[0],e=d.ImageLength.values[0];this.canvas.width=c;this.canvas.height=e;var f=[],g=d.Compression?d.Compression.values[0]:1,h=d.SamplesPerPixel.values[0],k=[],m=0,n=!1;if(d.BitsPerSample.values.forEach(function(a,b,c){k[b]={bitsPerSample:a,
hasBytesPerSample:!1,bytesPerSample:void 0};0===a%8&&(k[b].hasBytesPerSample=!0,k[b].bytesPerSample=a/8);m+=a},this),0===m%8)var n=!0,p=m/8;var r=d.StripOffsets.values,s=r.length;if(d.StripByteCounts)var v=d.StripByteCounts.values;else{if(cc.log("Missing StripByteCounts!"),1!==s)throw Error("Cannot recover from missing StripByteCounts");v=[Math.ceil(c*e*m/8)]}for(var u=0;s>u;u++){var t=r[u];f[u]=[];for(var x=v[u],A=0,F=0,z=1,w=!0,B=[],E=0,I=0,J=0;x>A;A+=z)switch(g){case 1:z=0;for(B=[];h>z;z++){if(!k[z].hasBytesPerSample){var O=
this.getBits(k[z].bitsPerSample,t+A,F);throw B.push(O.bits),A=O.byteOffset-t,F=O.bitOffset,RangeError("Cannot handle sub-byte bits per sample");}B.push(this.getBytes(k[z].bytesPerSample,t+A+k[z].bytesPerSample*z))}if(f[u].push(B),!n)throw z=0,RangeError("Cannot handle sub-byte bits per pixel");z=p;break;case 32773:if(w){var w=!1,L=1,D=1,z=this.getInt8(t+A);0<=z&&127>=z?L=z+1:-127<=z&&-1>=z?D=-z+1:w=!0}else{for(var y=this.getUint8(t+A),z=0;D>z;z++){if(!k[I].hasBytesPerSample)throw RangeError("Cannot handle sub-byte bits per sample");
J=J<<8*E|y;E++;E===k[I].bytesPerSample&&(B.push(J),J=E=0,I++);I===h&&(f[u].push(B),B=[],I=0)}L--;0===L&&(w=!0)}z=1}}if(b.getContext){p=this.canvas.getContext("2d");p.fillStyle="rgba(255, 255, 255, 0)";u=d.RowsPerStrip?d.RowsPerStrip.values[0]:e;t=f.length;e%=u;e=0===e?u:e;A=u;g=0;B=d.PhotometricInterpretation.values[0];L=[];D=0;if(d.ExtraSamples&&(L=d.ExtraSamples.values,D=L.length),d.ColorMap)var O=d.ColorMap.values,H=Math.pow(2,k[0].bitsPerSample);for(u=0;t>u;u++){u+1===t&&(A=e);d=f[u].length;g*=
u;for(n=h=0;d>n;h++)for(r=0;c>r;r++,n++){v=f[u][n];w=F=x=0;s=1;if(0<D)for(x=0;D>x;x++)if(1===L[x]||2===L[x]){s=v[3+x]/256;break}switch(B){case 0:if(k[0].hasBytesPerSample)var K=Math.pow(16,2*k[0].bytesPerSample);v.forEach(function(a,b,c){c[b]=K-a});case 1:x=F=w=this.clampColorSample(v[0],k[0].bitsPerSample);break;case 2:x=this.clampColorSample(v[0],k[0].bitsPerSample);F=this.clampColorSample(v[1],k[1].bitsPerSample);w=this.clampColorSample(v[2],k[2].bitsPerSample);break;case 3:if(void 0===O)throw Error("Palette image missing color map");
v=v[0];x=this.clampColorSample(O[v],16);F=this.clampColorSample(O[H+v],16);w=this.clampColorSample(O[2*H+v],16);break;default:throw RangeError("Unknown Photometric Interpretation:",B);}p.fillStyle="rgba("+x+", "+F+", "+w+", "+s+")";p.fillRect(r,g+h,1,1)}g=A}}return this.canvas}},fieldTagNames:{315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",
291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",
343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",
529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",
42113:"GDAL_NODATA",34377:"Photoshop"},fieldTypeNames:{1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE"}};
cc.Particle=function(a,b,c,d,e,f,g,h,k,m,n,p){this.pos=a?a:cc.p(0,0);this.startPos=b?b:cc.p(0,0);this.color=c?c:{r:0,g:0,b:0,a:255};this.deltaColor=d?d:{r:0,g:0,b:0,a:255};this.size=e||0;this.deltaSize=f||0;this.rotation=g||0;this.deltaRotation=h||0;this.timeToLive=k||0;this.atlasIndex=m||0;this.modeA=n?n:new cc.Particle.ModeA;this.modeB=p?p:new cc.Particle.ModeB;this.isChangeColor=!1;this.drawPos=cc.p(0,0)};
cc.Particle.ModeA=function(a,b,c){this.dir=a?a:cc.p(0,0);this.radialAccel=b||0;this.tangentialAccel=c||0};cc.Particle.ModeB=function(a,b,c,d){this.angle=a||0;this.degreesPerSecond=b||0;this.radius=c||0;this.deltaRadius=d||0};cc.Particle.TemporaryPoints=[cc.p(),cc.p(),cc.p(),cc.p()];
cc.ParticleSystem=cc.Node.extend({_className:"ParticleSystem",_plistFile:"",_elapsed:0,_dontTint:!1,modeA:null,modeB:null,_pointZeroForParticle:cc.p(0,0),_particles:null,_emitCounter:0,_particleIdx:0,_batchNode:null,atlasIndex:0,_transformSystemDirty:!1,_allocatedParticles:0,_isActive:!1,particleCount:0,duration:0,_sourcePosition:null,_posVar:null,life:0,lifeVar:0,angle:0,angleVar:0,startSize:0,startSizeVar:0,endSize:0,endSizeVar:0,_startColor:null,_startColorVar:null,_endColor:null,_endColorVar:null,
startSpin:0,startSpinVar:0,endSpin:0,endSpinVar:0,emissionRate:0,_totalParticles:0,_texture:null,_blendFunc:null,_opacityModifyRGB:!1,positionType:null,autoRemoveOnFinish:!1,emitterMode:0,_textureLoaded:null,ctor:function(a){(cc.Node.prototype.ctor.call(this),this.emitterMode=cc.ParticleSystem.MODE_GRAVITY,this.modeA=new cc.ParticleSystem.ModeA,this.modeB=new cc.ParticleSystem.ModeB,this._blendFunc={src:cc.BLEND_SRC,dst:cc.BLEND_DST},this._particles=[],this._sourcePosition=cc.p(0,0),this._posVar=
cc.p(0,0),this._startColor=cc.color(255,255,255,255),this._startColorVar=cc.color(255,255,255,255),this._endColor=cc.color(255,255,255,255),this._endColorVar=cc.color(255,255,255,255),this._plistFile="",this._elapsed=0,this._dontTint=!1,this._pointZeroForParticle=cc.p(0,0),this._emitCounter=0,this._particleIdx=0,this._batchNode=null,this.atlasIndex=0,this._transformSystemDirty=!1,this._allocatedParticles=0,this._isActive=!1,this.particleCount=0,this.duration=0,this.life=0,this.lifeVar=0,this.angle=
0,this.angleVar=0,this.startSize=0,this.startSizeVar=0,this.endSize=0,this.endSizeVar=0,this.startSpin=0,this.startSpinVar=0,this.endSpin=0,this.endSpinVar=0,this.emissionRate=0,this._totalParticles=0,this._texture=null,this._opacityModifyRGB=!1,this.positionType=cc.ParticleSystem.TYPE_FREE,this.autoRemoveOnFinish=!1,this._textureLoaded=!0,!a||cc.isNumber(a))?(a=a||100,this.setDrawMode(cc.ParticleSystem.TEXTURE_MODE),this.initWithTotalParticles(a)):cc.isString(a)?this.initWithFile(a):cc.isObject(a)&&
this.initWithDictionary(a,"")},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.ParticleSystem.CanvasRenderCmd(this):new cc.ParticleSystem.WebGLRenderCmd(this)},ignoreColor:function(a){this._dontTint=a},initTexCoordsWithRect:function(a){this._renderCmd.initTexCoordsWithRect(a)},getBatchNode:function(){return this._batchNode},setBatchNode:function(a){this._renderCmd.setBatchNode(a)},getAtlasIndex:function(){return this.atlasIndex},setAtlasIndex:function(a){this.atlasIndex=
a},getDrawMode:function(){return this._renderCmd.getDrawMode()},setDrawMode:function(a){this._renderCmd.setDrawMode(a)},getShapeType:function(){return this._renderCmd.getShapeType()},setShapeType:function(a){this._renderCmd.setShapeType(a)},isActive:function(){return this._isActive},getParticleCount:function(){return this.particleCount},setParticleCount:function(a){this.particleCount=a},getDuration:function(){return this.duration},setDuration:function(a){this.duration=a},getSourcePosition:function(){return{x:this._sourcePosition.x,
y:this._sourcePosition.y}},setSourcePosition:function(a){this._sourcePosition=a},getPosVar:function(){return{x:this._posVar.x,y:this._posVar.y}},setPosVar:function(a){this._posVar=a},getLife:function(){return this.life},setLife:function(a){this.life=a},getLifeVar:function(){return this.lifeVar},setLifeVar:function(a){this.lifeVar=a},getAngle:function(){return this.angle},setAngle:function(a){this.angle=a},getAngleVar:function(){return this.angleVar},setAngleVar:function(a){this.angleVar=a},getGravity:function(){this.emitterMode!==
cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getGravity() : Particle Mode should be Gravity");var a=this.modeA.gravity;return cc.p(a.x,a.y)},setGravity:function(a){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.setGravity() : Particle Mode should be Gravity");this.modeA.gravity=a},getSpeed:function(){return this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getSpeed() : Particle Mode should be Gravity"),this.modeA.speed},
setSpeed:function(a){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.setSpeed() : Particle Mode should be Gravity");this.modeA.speed=a},getSpeedVar:function(){return this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getSpeedVar() : Particle Mode should be Gravity"),this.modeA.speedVar},setSpeedVar:function(a){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.setSpeedVar() : Particle Mode should be Gravity");
this.modeA.speedVar=a},getTangentialAccel:function(){return this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getTangentialAccel() : Particle Mode should be Gravity"),this.modeA.tangentialAccel},setTangentialAccel:function(a){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.setTangentialAccel() : Particle Mode should be Gravity");this.modeA.tangentialAccel=a},getTangentialAccelVar:function(){return this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&
cc.log("cc.ParticleBatchNode.getTangentialAccelVar() : Particle Mode should be Gravity"),this.modeA.tangentialAccelVar},setTangentialAccelVar:function(a){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.setTangentialAccelVar() : Particle Mode should be Gravity");this.modeA.tangentialAccelVar=a},getRadialAccel:function(){return this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getRadialAccel() : Particle Mode should be Gravity"),this.modeA.radialAccel},
setRadialAccel:function(a){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.setRadialAccel() : Particle Mode should be Gravity");this.modeA.radialAccel=a},getRadialAccelVar:function(){return this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getRadialAccelVar() : Particle Mode should be Gravity"),this.modeA.radialAccelVar},setRadialAccelVar:function(a){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.setRadialAccelVar() : Particle Mode should be Gravity");
this.modeA.radialAccelVar=a},getRotationIsDir:function(){return this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getRotationIsDir() : Particle Mode should be Gravity"),this.modeA.rotationIsDir},setRotationIsDir:function(a){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.setRotationIsDir() : Particle Mode should be Gravity");this.modeA.rotationIsDir=a},getStartRadius:function(){return this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getStartRadius() : Particle Mode should be Radius"),
this.modeB.startRadius},setStartRadius:function(a){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.setStartRadius() : Particle Mode should be Radius");this.modeB.startRadius=a},getStartRadiusVar:function(){return this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getStartRadiusVar() : Particle Mode should be Radius"),this.modeB.startRadiusVar},setStartRadiusVar:function(a){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.setStartRadiusVar() : Particle Mode should be Radius");
this.modeB.startRadiusVar=a},getEndRadius:function(){return this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getEndRadius() : Particle Mode should be Radius"),this.modeB.endRadius},setEndRadius:function(a){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.setEndRadius() : Particle Mode should be Radius");this.modeB.endRadius=a},getEndRadiusVar:function(){return this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getEndRadiusVar() : Particle Mode should be Radius"),
this.modeB.endRadiusVar},setEndRadiusVar:function(a){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.setEndRadiusVar() : Particle Mode should be Radius");this.modeB.endRadiusVar=a},getRotatePerSecond:function(){return this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getRotatePerSecond() : Particle Mode should be Radius"),this.modeB.rotatePerSecond},setRotatePerSecond:function(a){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.setRotatePerSecond() : Particle Mode should be Radius");
this.modeB.rotatePerSecond=a},getRotatePerSecondVar:function(){return this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getRotatePerSecondVar() : Particle Mode should be Radius"),this.modeB.rotatePerSecondVar},setRotatePerSecondVar:function(a){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.setRotatePerSecondVar() : Particle Mode should be Radius");this.modeB.rotatePerSecondVar=a},setScale:function(a,b){this._transformSystemDirty=!0;cc.Node.prototype.setScale.call(this,
a,b)},setRotation:function(a){this._transformSystemDirty=!0;cc.Node.prototype.setRotation.call(this,a)},setScaleX:function(a){this._transformSystemDirty=!0;cc.Node.prototype.setScaleX.call(this,a)},setScaleY:function(a){this._transformSystemDirty=!0;cc.Node.prototype.setScaleY.call(this,a)},getStartSize:function(){return this.startSize},setStartSize:function(a){this.startSize=a},getStartSizeVar:function(){return this.startSizeVar},setStartSizeVar:function(a){this.startSizeVar=a},getEndSize:function(){return this.endSize},
setEndSize:function(a){this.endSize=a},getEndSizeVar:function(){return this.endSizeVar},setEndSizeVar:function(a){this.endSizeVar=a},getStartColor:function(){return cc.color(this._startColor.r,this._startColor.g,this._startColor.b,this._startColor.a)},setStartColor:function(a){this._startColor=cc.color(a)},getStartColorVar:function(){return cc.color(this._startColorVar.r,this._startColorVar.g,this._startColorVar.b,this._startColorVar.a)},setStartColorVar:function(a){this._startColorVar=cc.color(a)},
getEndColor:function(){return cc.color(this._endColor.r,this._endColor.g,this._endColor.b,this._endColor.a)},setEndColor:function(a){this._endColor=cc.color(a)},getEndColorVar:function(){return cc.color(this._endColorVar.r,this._endColorVar.g,this._endColorVar.b,this._endColorVar.a)},setEndColorVar:function(a){this._endColorVar=cc.color(a)},getStartSpin:function(){return this.startSpin},setStartSpin:function(a){this.startSpin=a},getStartSpinVar:function(){return this.startSpinVar},setStartSpinVar:function(a){this.startSpinVar=
a},getEndSpin:function(){return this.endSpin},setEndSpin:function(a){this.endSpin=a},getEndSpinVar:function(){return this.endSpinVar},setEndSpinVar:function(a){this.endSpinVar=a},getEmissionRate:function(){return this.emissionRate},setEmissionRate:function(a){this.emissionRate=a},getTotalParticles:function(){return this._totalParticles},setTotalParticles:function(a){this._renderCmd.setTotalParticles(a)},getTexture:function(){return this._texture},setTexture:function(a){a&&(a.isLoaded()?this.setTextureWithRect(a,
cc.rect(0,0,a.width,a.height)):(this._textureLoaded=!1,a.addEventListener("load",function(a){this._textureLoaded=!0;this.setTextureWithRect(a,cc.rect(0,0,a.width,a.height))},this)))},getBlendFunc:function(){return this._blendFunc},setBlendFunc:function(a,b){void 0===b?this._blendFunc!==a&&(this._blendFunc=a,this._updateBlendFunc()):(this._blendFunc.src!==a||this._blendFunc.dst!==b)&&(this._blendFunc={src:a,dst:b},this._updateBlendFunc())},isOpacityModifyRGB:function(){return this._opacityModifyRGB},
setOpacityModifyRGB:function(a){this._opacityModifyRGB=a},isBlendAdditive:function(){return this._blendFunc.src===cc.SRC_ALPHA&&this._blendFunc.dst===cc.ONE||this._blendFunc.src===cc.ONE&&this._blendFunc.dst===cc.ONE},setBlendAdditive:function(a){var b=this._blendFunc;a?(b.src=cc.SRC_ALPHA,b.dst=cc.ONE):this._renderCmd._setBlendAdditive()},getPositionType:function(){return this.positionType},setPositionType:function(a){this.positionType=a},isAutoRemoveOnFinish:function(){return this.autoRemoveOnFinish},
setAutoRemoveOnFinish:function(a){this.autoRemoveOnFinish=a},getEmitterMode:function(){return this.emitterMode},setEmitterMode:function(a){this.emitterMode=a},init:function(){return this.initWithTotalParticles(150)},initWithFile:function(a){this._plistFile=a;return(a=cc.loader.getRes(a))?this.initWithDictionary(a,""):(cc.log("cc.ParticleSystem.initWithFile(): Particles: file not found"),!1)},getBoundingBoxToWorld:function(){return cc.rect(0,0,cc._canvas.width,cc._canvas.height)},initWithDictionary:function(a,
b){var c=!1,d=null,e=this._valueForKey,f=parseInt(e("maxParticles",a));if(this.initWithTotalParticles(f)){this.angle=parseFloat(e("angle",a));this.angleVar=parseFloat(e("angleVariance",a));this.duration=parseFloat(e("duration",a));this._blendFunc.src=parseInt(e("blendFuncSource",a));this._blendFunc.dst=parseInt(e("blendFuncDestination",a));c=this._startColor;c.r=255*parseFloat(e("startColorRed",a));c.g=255*parseFloat(e("startColorGreen",a));c.b=255*parseFloat(e("startColorBlue",a));c.a=255*parseFloat(e("startColorAlpha",
a));c=this._startColorVar;c.r=255*parseFloat(e("startColorVarianceRed",a));c.g=255*parseFloat(e("startColorVarianceGreen",a));c.b=255*parseFloat(e("startColorVarianceBlue",a));c.a=255*parseFloat(e("startColorVarianceAlpha",a));c=this._endColor;c.r=255*parseFloat(e("finishColorRed",a));c.g=255*parseFloat(e("finishColorGreen",a));c.b=255*parseFloat(e("finishColorBlue",a));c.a=255*parseFloat(e("finishColorAlpha",a));c=this._endColorVar;if(c.r=255*parseFloat(e("finishColorVarianceRed",a)),c.g=255*parseFloat(e("finishColorVarianceGreen",
a)),c.b=255*parseFloat(e("finishColorVarianceBlue",a)),c.a=255*parseFloat(e("finishColorVarianceAlpha",a)),this.startSize=parseFloat(e("startParticleSize",a)),this.startSizeVar=parseFloat(e("startParticleSizeVariance",a)),this.endSize=parseFloat(e("finishParticleSize",a)),this.endSizeVar=parseFloat(e("finishParticleSizeVariance",a)),this.setPosition(parseFloat(e("sourcePositionx",a)),parseFloat(e("sourcePositiony",a))),this._posVar.x=parseFloat(e("sourcePositionVariancex",a)),this._posVar.y=parseFloat(e("sourcePositionVariancey",
a)),this.startSpin=parseFloat(e("rotationStart",a)),this.startSpinVar=parseFloat(e("rotationStartVariance",a)),this.endSpin=parseFloat(e("rotationEnd",a)),this.endSpinVar=parseFloat(e("rotationEndVariance",a)),this.emitterMode=parseInt(e("emitterType",a)),this.emitterMode===cc.ParticleSystem.MODE_GRAVITY)c=this.modeA,c.gravity.x=parseFloat(e("gravityx",a)),c.gravity.y=parseFloat(e("gravityy",a)),c.speed=parseFloat(e("speed",a)),c.speedVar=parseFloat(e("speedVariance",a)),f=e("radialAcceleration",
a),c.radialAccel=f?parseFloat(f):0,f=e("radialAccelVariance",a),c.radialAccelVar=f?parseFloat(f):0,f=e("tangentialAcceleration",a),c.tangentialAccel=f?parseFloat(f):0,f=e("tangentialAccelVariance",a),c.tangentialAccelVar=f?parseFloat(f):0,f=e("rotationIsDir",a).toLowerCase(),c.rotationIsDir=null!=f&&("true"===f||"1"===f);else{if(this.emitterMode!==cc.ParticleSystem.MODE_RADIUS)return cc.log("cc.ParticleSystem.initWithDictionary(): Invalid emitterType in config file"),!1;c=this.modeB;c.startRadius=
parseFloat(e("maxRadius",a));c.startRadiusVar=parseFloat(e("maxRadiusVariance",a));c.endRadius=parseFloat(e("minRadius",a));c.endRadiusVar=0;c.rotatePerSecond=parseFloat(e("rotatePerSecond",a));c.rotatePerSecondVar=parseFloat(e("rotatePerSecondVariance",a))}if(this.life=parseFloat(e("particleLifespan",a)),this.lifeVar=parseFloat(e("particleLifespanVariance",a)),this.emissionRate=this._totalParticles/this.life,!this._batchNode)if(this._opacityModifyRGB=!1,c=e("textureFileName",a),c=cc.path.changeBasename(this._plistFile,
c),f=cc.textureCache.getTextureForKey(c))this.setTexture(f);else if((e=e("textureImageData",a))&&0!==e.length){if(d=cc.unzipBase64AsArray(e,1),!d)return cc.log("cc.ParticleSystem: error decoding or ungzipping textureImageData"),!1;e=cc.getImageFormatByData(d);if(e!==cc.FMT_TIFF&&e!==cc.FMT_PNG)return cc.log("cc.ParticleSystem: unknown image format with Data"),!1;f=cc.newElement("canvas");e===cc.FMT_PNG?(new cc.PNGReader(d)).render(f):cc.tiffReader.parseTIFF(d,f);cc.textureCache.cacheImage(c,f);(d=
cc.textureCache.getTextureForKey(c))||cc.log("cc.ParticleSystem.initWithDictionary() : error loading the texture");this.setTexture(d)}else{if(f=cc.textureCache.addImage(c),!f)return!1;this.setTexture(f)}c=!0}return c},initWithTotalParticles:function(a){this._totalParticles=a;var b,c=this._particles;for(b=c.length=0;a>b;b++)c[b]=new cc.Particle;if(!c)return cc.log("Particle system: not enough memory"),!1;if(this._allocatedParticles=a,this._batchNode)for(b=0;b<this._totalParticles;b++)c[b].atlasIndex=
b;return this._isActive=!0,this._blendFunc.src=cc.BLEND_SRC,this._blendFunc.dst=cc.BLEND_DST,this.positionType=cc.ParticleSystem.TYPE_FREE,this.emitterMode=cc.ParticleSystem.MODE_GRAVITY,this.autoRemoveOnFinish=!1,this._transformSystemDirty=!1,this.scheduleUpdateWithPriority(1),this._renderCmd._initWithTotalParticles(a),!0},destroyParticleSystem:function(){this.unscheduleUpdate()},addParticle:function(){if(this.isFull())return!1;var a=this._renderCmd.addParticle();return this.initParticle(a),++this.particleCount,
!0},initParticle:function(a){var b,c,d,e,f=cc.randomMinus1To1;a.timeToLive=this.life+this.lifeVar*f();a.timeToLive=Math.max(0,a.timeToLive);a.pos.x=this._sourcePosition.x+this._posVar.x*f();a.pos.y=this._sourcePosition.y+this._posVar.y*f();var g;b=this._startColor;c=this._startColorVar;var h=this._endColor;e=this._endColorVar;g={r:cc.clampf(b.r+c.r*f(),0,255),g:cc.clampf(b.g+c.g*f(),0,255),b:cc.clampf(b.b+c.b*f(),0,255),a:cc.clampf(b.a+c.a*f(),0,255)};b=cc.clampf(h.r+e.r*f(),0,255);c=cc.clampf(h.g+
e.g*f(),0,255);d=cc.clampf(h.b+e.b*f(),0,255);e=cc.clampf(h.a+e.a*f(),0,255);a.color=g;var k=a.deltaColor,h=a.timeToLive;k.r=(b-g.r)/h;k.g=(c-g.g)/h;k.b=(d-g.b)/h;k.a=(e-g.a)/h;b=this.startSize+this.startSizeVar*f();(b=Math.max(0,b),a.size=b,this.endSize===cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE)?a.deltaSize=0:(c=this.endSize+this.endSizeVar*f(),c=Math.max(0,c),a.deltaSize=(c-b)/h);b=this.startSpin+this.startSpinVar*f();c=this.endSpin+this.endSpinVar*f();a.rotation=b;a.deltaRotation=(c-b)/
h;this.positionType===cc.ParticleSystem.TYPE_FREE?a.startPos=this.convertToWorldSpace(this._pointZeroForParticle):this.positionType===cc.ParticleSystem.TYPE_RELATIVE&&(a.startPos.x=this._position.x,a.startPos.y=this._position.y);b=cc.degreesToRadians(this.angle+this.angleVar*f());this.emitterMode===cc.ParticleSystem.MODE_GRAVITY?(h=this.modeA,c=a.modeA,d=h.speed+h.speedVar*f(),c.dir.x=Math.cos(b),c.dir.y=Math.sin(b),cc.pMultIn(c.dir,d),c.radialAccel=h.radialAccel+h.radialAccelVar*f(),c.tangentialAccel=
h.tangentialAccel+h.tangentialAccelVar*f(),h.rotationIsDir&&(a.rotation=-cc.radiansToDegrees(cc.pToAngle(c.dir)))):(c=this.modeB,a=a.modeB,d=c.startRadius+c.startRadiusVar*f(),g=c.endRadius+c.endRadiusVar*f(),a.radius=d,a.deltaRadius=c.endRadius===cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS?0:(g-d)/h,a.angle=b,a.degreesPerSecond=cc.degreesToRadians(c.rotatePerSecond+c.rotatePerSecondVar*f()))},stopSystem:function(){this._isActive=!1;this._elapsed=this.duration;this._emitCounter=0},resetSystem:function(){this._isActive=
!0;this._elapsed=0;var a=this._particles;for(this._particleIdx=0;this._particleIdx<this.particleCount;++this._particleIdx)a[this._particleIdx].timeToLive=0},isFull:function(){return this.particleCount>=this._totalParticles},updateQuadWithParticle:function(a,b){this._renderCmd.updateQuadWithParticle(a,b)},postStep:function(){this._renderCmd.postStep()},update:function(a){if(this._isActive&&this.emissionRate){var b=1/this.emissionRate;for(this.particleCount<this._totalParticles&&(this._emitCounter+=
a);this.particleCount<this._totalParticles&&this._emitCounter>b;)this.addParticle(),this._emitCounter-=b;this._elapsed+=a;-1!==this.duration&&this.duration<this._elapsed&&this.stopSystem()}this._particleIdx=0;b=cc.Particle.TemporaryPoints[0];if(this.positionType===cc.ParticleSystem.TYPE_FREE?cc.pIn(b,this.convertToWorldSpace(this._pointZeroForParticle)):this.positionType===cc.ParticleSystem.TYPE_RELATIVE&&(b.x=this._position.x,b.y=this._position.y),this._visible){for(var c=cc.Particle.TemporaryPoints[1],
d=cc.Particle.TemporaryPoints[2],e=cc.Particle.TemporaryPoints[3],f=this._particles;this._particleIdx<this.particleCount;){cc.pZeroIn(c);cc.pZeroIn(d);cc.pZeroIn(e);var g=f[this._particleIdx];if(g.timeToLive-=a,0<g.timeToLive){if(this.emitterMode===cc.ParticleSystem.MODE_GRAVITY){var h=e,k=c,m=d;g.pos.x||g.pos.y?(cc.pIn(k,g.pos),cc.pNormalizeIn(k)):cc.pZeroIn(k);cc.pIn(m,k);cc.pMultIn(k,g.modeA.radialAccel);var n=m.x;m.x=-m.y;m.y=n;cc.pMultIn(m,g.modeA.tangentialAccel);cc.pIn(h,k);cc.pAddIn(h,m);
cc.pAddIn(h,this.modeA.gravity);cc.pMultIn(h,a);cc.pAddIn(g.modeA.dir,h);cc.pIn(h,g.modeA.dir);cc.pMultIn(h,a);cc.pAddIn(g.pos,h)}else h=g.modeB,h.angle+=h.degreesPerSecond*a,h.radius+=h.deltaRadius*a,g.pos.x=-Math.cos(h.angle)*h.radius,g.pos.y=-Math.sin(h.angle)*h.radius;this._renderCmd._updateDeltaColor(g,a);g.size+=g.deltaSize*a;g.size=Math.max(0,g.size);g.rotation+=g.deltaRotation*a;h=c;this.positionType===cc.ParticleSystem.TYPE_FREE||this.positionType===cc.ParticleSystem.TYPE_RELATIVE?(k=d,cc.pIn(k,
b),cc.pSubIn(k,g.startPos),cc.pIn(h,g.pos),cc.pSubIn(h,k)):cc.pIn(h,g.pos);this._batchNode&&(h.x+=this._position.x,h.y+=this._position.y);this._renderCmd.updateParticlePosition(g,h);++this._particleIdx}else if(g=g.atlasIndex,this._particleIdx!==this.particleCount-1&&(h=f[this._particleIdx],f[this._particleIdx]=f[this.particleCount-1],f[this.particleCount-1]=h),this._batchNode&&(this._batchNode.disableParticle(this.atlasIndex+g),f[this.particleCount-1].atlasIndex=g),--this.particleCount,0===this.particleCount&&
this.autoRemoveOnFinish)return this.unscheduleUpdate(),void this._parent.removeChild(this,!0)}this._transformSystemDirty=!1}this._batchNode||this.postStep()},updateWithNoTime:function(){this.update(0)},_valueForKey:function(a,b){if(b){var c=b[a];return null!=c?c:""}return""},_updateBlendFunc:function(){if(this._batchNode)return void cc.log("Can't change blending functions when the particle is being batched");var a=this._texture;if(a&&a instanceof cc.Texture2D){this._opacityModifyRGB=!1;var b=this._blendFunc;
b.src===cc.BLEND_SRC&&b.dst===cc.BLEND_DST&&(a.hasPremultipliedAlpha()?this._opacityModifyRGB=!0:(b.src=cc.SRC_ALPHA,b.dst=cc.ONE_MINUS_SRC_ALPHA))}},clone:function(){var a=new cc.ParticleSystem;if(a.initWithTotalParticles(this.getTotalParticles())){a.setAngle(this.getAngle());a.setAngleVar(this.getAngleVar());a.setDuration(this.getDuration());var b=this.getBlendFunc();(a.setBlendFunc(b.src,b.dst),a.setStartColor(this.getStartColor()),a.setStartColorVar(this.getStartColorVar()),a.setEndColor(this.getEndColor()),
a.setEndColorVar(this.getEndColorVar()),a.setStartSize(this.getStartSize()),a.setStartSizeVar(this.getStartSizeVar()),a.setEndSize(this.getEndSize()),a.setEndSizeVar(this.getEndSizeVar()),a.setPosition(cc.p(this.x,this.y)),a.setPosVar(cc.p(this.getPosVar().x,this.getPosVar().y)),a.setPositionType(this.getPositionType()),a.setStartSpin(this.getStartSpin()||0),a.setStartSpinVar(this.getStartSpinVar()||0),a.setEndSpin(this.getEndSpin()||0),a.setEndSpinVar(this.getEndSpinVar()||0),a.setEmitterMode(this.getEmitterMode()),
this.getEmitterMode()===cc.ParticleSystem.MODE_GRAVITY)?(b=this.getGravity(),a.setGravity(cc.p(b.x,b.y)),a.setSpeed(this.getSpeed()),a.setSpeedVar(this.getSpeedVar()),a.setRadialAccel(this.getRadialAccel()),a.setRadialAccelVar(this.getRadialAccelVar()),a.setTangentialAccel(this.getTangentialAccel()),a.setTangentialAccelVar(this.getTangentialAccelVar())):this.getEmitterMode()===cc.ParticleSystem.MODE_RADIUS&&(a.setStartRadius(this.getStartRadius()),a.setStartRadiusVar(this.getStartRadiusVar()),a.setEndRadius(this.getEndRadius()),
a.setEndRadiusVar(this.getEndRadiusVar()),a.setRotatePerSecond(this.getRotatePerSecond()),a.setRotatePerSecondVar(this.getRotatePerSecondVar()));if(a.setLife(this.getLife()),a.setLifeVar(this.getLifeVar()),a.setEmissionRate(this.getEmissionRate()),!this.getBatchNode())if(a.setOpacityModifyRGB(this.isOpacityModifyRGB()),b=this.getTexture()){var c=b.getContentSize();a.setTextureWithRect(b,cc.rect(0,0,c.width,c.height))}}return a},setDisplayFrame:function(a){if(a){var b=a.getOffsetInPixels();(0!==b.x||
0!==b.y)&&cc.log("cc.ParticleSystem.setDisplayFrame(): QuadParticle only supports SpriteFrames with no offsets");a=a.getTexture();this._texture!==a&&this.setTexture(a)}},setTextureWithRect:function(a,b){this._texture!==a&&(this._texture=a,this._updateBlendFunc());this.initTexCoordsWithRect(b)},listenBackToForeground:function(a){}});_p=cc.ParticleSystem.prototype;_p.opacityModifyRGB;cc.defineGetterSetter(_p,"opacityModifyRGB",_p.isOpacityModifyRGB,_p.setOpacityModifyRGB);_p.batchNode;
cc.defineGetterSetter(_p,"batchNode",_p.getBatchNode,_p.setBatchNode);_p.drawMode;cc.defineGetterSetter(_p,"drawMode",_p.getDrawMode,_p.setDrawMode);_p.shapeType;cc.defineGetterSetter(_p,"shapeType",_p.getShapeType,_p.setShapeType);_p.active;cc.defineGetterSetter(_p,"active",_p.isActive);_p.sourcePos;cc.defineGetterSetter(_p,"sourcePos",_p.getSourcePosition,_p.setSourcePosition);_p.posVar;cc.defineGetterSetter(_p,"posVar",_p.getPosVar,_p.setPosVar);_p.gravity;
cc.defineGetterSetter(_p,"gravity",_p.getGravity,_p.setGravity);_p.speed;cc.defineGetterSetter(_p,"speed",_p.getSpeed,_p.setSpeed);_p.speedVar;cc.defineGetterSetter(_p,"speedVar",_p.getSpeedVar,_p.setSpeedVar);_p.tangentialAccel;cc.defineGetterSetter(_p,"tangentialAccel",_p.getTangentialAccel,_p.setTangentialAccel);_p.tangentialAccelVar;cc.defineGetterSetter(_p,"tangentialAccelVar",_p.getTangentialAccelVar,_p.setTangentialAccelVar);_p.radialAccel;
cc.defineGetterSetter(_p,"radialAccel",_p.getRadialAccel,_p.setRadialAccel);_p.radialAccelVar;cc.defineGetterSetter(_p,"radialAccelVar",_p.getRadialAccelVar,_p.setRadialAccelVar);_p.rotationIsDir;cc.defineGetterSetter(_p,"rotationIsDir",_p.getRotationIsDir,_p.setRotationIsDir);_p.startRadius;cc.defineGetterSetter(_p,"startRadius",_p.getStartRadius,_p.setStartRadius);_p.startRadiusVar;cc.defineGetterSetter(_p,"startRadiusVar",_p.getStartRadiusVar,_p.setStartRadiusVar);_p.endRadius;
cc.defineGetterSetter(_p,"endRadius",_p.getEndRadius,_p.setEndRadius);_p.endRadiusVar;cc.defineGetterSetter(_p,"endRadiusVar",_p.getEndRadiusVar,_p.setEndRadiusVar);_p.rotatePerS;cc.defineGetterSetter(_p,"rotatePerS",_p.getRotatePerSecond,_p.setRotatePerSecond);_p.rotatePerSVar;cc.defineGetterSetter(_p,"rotatePerSVar",_p.getRotatePerSecondVar,_p.setRotatePerSecondVar);_p.startColor;cc.defineGetterSetter(_p,"startColor",_p.getStartColor,_p.setStartColor);_p.startColorVar;
cc.defineGetterSetter(_p,"startColorVar",_p.getStartColorVar,_p.setStartColorVar);_p.endColor;cc.defineGetterSetter(_p,"endColor",_p.getEndColor,_p.setEndColor);_p.endColorVar;cc.defineGetterSetter(_p,"endColorVar",_p.getEndColorVar,_p.setEndColorVar);_p.totalParticles;cc.defineGetterSetter(_p,"totalParticles",_p.getTotalParticles,_p.setTotalParticles);_p.texture;cc.defineGetterSetter(_p,"texture",_p.getTexture,_p.setTexture);cc.ParticleSystem.create=function(a){return new cc.ParticleSystem(a)};
cc.ParticleSystem.createWithTotalParticles=cc.ParticleSystem.create;cc.ParticleSystem.ModeA=function(a,b,c,d,e,f,g,h){this.gravity=a?a:cc.p(0,0);this.speed=b||0;this.speedVar=c||0;this.tangentialAccel=d||0;this.tangentialAccelVar=e||0;this.radialAccel=f||0;this.radialAccelVar=g||0;this.rotationIsDir=h||!1};cc.ParticleSystem.ModeB=function(a,b,c,d,e,f){this.startRadius=a||0;this.startRadiusVar=b||0;this.endRadius=c||0;this.endRadiusVar=d||0;this.rotatePerSecond=e||0;this.rotatePerSecondVar=f||0};
cc.ParticleSystem.SHAPE_MODE=0;cc.ParticleSystem.TEXTURE_MODE=1;cc.ParticleSystem.STAR_SHAPE=0;cc.ParticleSystem.BALL_SHAPE=1;cc.ParticleSystem.DURATION_INFINITY=-1;cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE=-1;cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS=-1;cc.ParticleSystem.MODE_GRAVITY=0;cc.ParticleSystem.MODE_RADIUS=1;cc.ParticleSystem.TYPE_FREE=0;cc.ParticleSystem.TYPE_RELATIVE=1;cc.ParticleSystem.TYPE_GROUPED=2;
(function(){cc.ParticleSystem.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._needDraw=!0;this._drawMode=cc.ParticleSystem.TEXTURE_MODE;this._shapeType=cc.ParticleSystem.BALL_SHAPE;this._pointRect=cc.rect(0,0,0,0)};var a=cc.ParticleSystem.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.ParticleSystem.CanvasRenderCmd;a.getDrawMode=function(){return this._drawMode};a.setDrawMode=function(a){this._drawMode=a};a.getShapeType=function(){return this._shapeType};
a.setShapeType=function(a){this._shapeType=a};a.setBatchNode=function(a){this._batchNode!==a&&(this._node._batchNode=a)};a.updateQuadWithParticle=function(a,c){};a.updateParticlePosition=function(a,c){cc.pIn(a.drawPos,c)};a.rendering=function(a,c,d){a=a||cc._renderContext;var e=a.getContext(),f=this._node,g=this._pointRect;a.setTransform(this._worldTransform,c,d);a.save();f.isBlendAdditive()?e.globalCompositeOperation="lighter":e.globalCompositeOperation="source-over";var h,k;d=this._node.particleCount;
var m=this._node._particles;if(f.drawMode!==cc.ParticleSystem.SHAPE_MODE&&f._texture){if(!f._texture._textureLoaded)return void a.restore();f=f._texture.getHtmlElementObj();if(!f.width||!f.height)return void a.restore();var n=f;for(c=0;d>c;c++)if(h=m[c],k=h.color.a/255,0!==k){e.globalAlpha=k;e.save();e.translate(0|h.drawPos.x,-(0|h.drawPos.y));var n=4*Math.floor(h.size/4),p=g.width,r=g.height;e.scale(Math.max(1/p*n,1E-6),Math.max(1/r*n,1E-6));h.rotation&&e.rotate(cc.degreesToRadians(h.rotation));
n=h.isChangeColor?this._changeTextureColor(f,h.color,this._pointRect):f;e.drawImage(n,-(0|p/2),-(0|r/2));e.restore()}}else{p=cc._drawingUtil;for(c=0;d>c;c++)h=m[c],g=0|0.5*h.size,k=h.color.a/255,0!==k&&(e.globalAlpha=k,e.save(),e.translate(0|h.drawPos.x,-(0|h.drawPos.y)),f.shapeType===cc.ParticleSystem.STAR_SHAPE?(h.rotation&&e.rotate(cc.degreesToRadians(h.rotation)),p.drawStar(a,g,h.color)):p.drawColorBall(a,g,h.color),e.restore())}a.restore();cc.g_NumberOfDraws++};cc.sys._supportCanvasNewBlendModes?
a._changeTextureColor=function(a,c,d){return a.tintCache||(a.tintCache=document.createElement("canvas"),a.tintCache.width=a.width,a.tintCache.height=a.height),cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(a,c,d,a.tintCache)}:a._changeTextureColor=function(a,c,d){var e=cc.textureCache.getTextureColors(a);return e?(e.tintCache||(e.tintCache=document.createElement("canvas"),e.tintCache.width=a.width,e.tintCache.height=a.height),cc.Sprite.CanvasRenderCmd._generateTintImage(a,e,c,d,e.tintCache),
e.tintCache):null};a.initTexCoordsWithRect=function(a){this._pointRect=a};a.setTotalParticles=function(a){this._node._totalParticles=200>a?a:200};a.addParticle=function(){var a,c=this._node,d=c._particles;return c.particleCount<d.length?a=d[c.particleCount]:(a=new cc.Particle,d.push(a)),a};a._setupVBO=function(){};a._allocMemory=function(){return!0};a.postStep=function(){};a._setBlendAdditive=function(){var a=this._node._blendFunc;a.src=cc.BLEND_SRC;a.dst=cc.BLEND_DST};a._initWithTotalParticles=function(a){};
a._updateDeltaColor=function(a,c){this._node._dontTint||(a.color.r+=a.deltaColor.r*c,a.color.g+=a.deltaColor.g*c,a.color.b+=a.deltaColor.b*c,a.color.a+=a.deltaColor.a*c,a.isChangeColor=!0)}})();
cc.ParticleFire=cc.ParticleSystem.extend({ctor:function(){cc.ParticleSystem.prototype.ctor.call(this,cc._renderType===cc._RENDER_TYPE_WEBGL?300:150)},initWithTotalParticles:function(a){return cc.ParticleSystem.prototype.initWithTotalParticles.call(this,a)?(this.setDuration(cc.ParticleSystem.DURATION_INFINITY),this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY),this.setGravity(cc.p(0,0)),this.setRadialAccel(0),this.setRadialAccelVar(0),this.setSpeed(60),this.setSpeedVar(20),this.setAngle(90),this.setAngleVar(10),
a=cc.director.getWinSize(),this.setPosition(a.width/2,60),this.setPosVar(cc.p(40,20)),this.setLife(3),this.setLifeVar(0.25),this.setStartSize(54),this.setStartSizeVar(10),this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE),this.setEmissionRate(this.getTotalParticles()/this.getLife()),this.setStartColor(cc.color(194,64,31,255)),this.setStartColorVar(cc.color(0,0,0,0)),this.setEndColor(cc.color(0,0,0,255)),this.setEndColorVar(cc.color(0,0,0,0)),this.setBlendAdditive(!0),!0):!1}});
cc.ParticleFire.create=function(){return new cc.ParticleFire};
cc.ParticleFireworks=cc.ParticleSystem.extend({ctor:function(){cc.ParticleSystem.prototype.ctor.call(this,cc._renderType===cc._RENDER_TYPE_WEBGL?1500:150)},initWithTotalParticles:function(a){return cc.ParticleSystem.prototype.initWithTotalParticles.call(this,a)?(this.setDuration(cc.ParticleSystem.DURATION_INFINITY),this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY),this.setGravity(cc.p(0,-90)),this.setRadialAccel(0),this.setRadialAccelVar(0),this.setSpeed(180),this.setSpeedVar(50),a=cc.director.getWinSize(),
this.setPosition(a.width/2,a.height/2),this.setAngle(90),this.setAngleVar(20),this.setLife(3.5),this.setLifeVar(1),this.setEmissionRate(this.getTotalParticles()/this.getLife()),this.setStartColor(cc.color(128,128,128,255)),this.setStartColorVar(cc.color(128,128,128,255)),this.setEndColor(cc.color(26,26,26,51)),this.setEndColorVar(cc.color(26,26,26,51)),this.setStartSize(8),this.setStartSizeVar(2),this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE),this.setBlendAdditive(!1),!0):!1}});
cc.ParticleFireworks.create=function(){return new cc.ParticleFireworks};
cc.ParticleSun=cc.ParticleSystem.extend({ctor:function(){cc.ParticleSystem.prototype.ctor.call(this,cc._renderType===cc._RENDER_TYPE_WEBGL?350:150)},initWithTotalParticles:function(a){return cc.ParticleSystem.prototype.initWithTotalParticles.call(this,a)?(this.setBlendAdditive(!0),this.setDuration(cc.ParticleSystem.DURATION_INFINITY),this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY),this.setGravity(cc.p(0,0)),this.setRadialAccel(0),this.setRadialAccelVar(0),this.setSpeed(20),this.setSpeedVar(5),
this.setAngle(90),this.setAngleVar(360),a=cc.director.getWinSize(),this.setPosition(a.width/2,a.height/2),this.setPosVar(cc.p(0,0)),this.setLife(1),this.setLifeVar(0.5),this.setStartSize(30),this.setStartSizeVar(10),this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE),this.setEmissionRate(this.getTotalParticles()/this.getLife()),this.setStartColor(cc.color(194,64,31,255)),this.setStartColorVar(cc.color(0,0,0,0)),this.setEndColor(cc.color(0,0,0,255)),this.setEndColorVar(cc.color(0,0,0,0)),
!0):!1}});cc.ParticleSun.create=function(){return new cc.ParticleSun};
cc.ParticleGalaxy=cc.ParticleSystem.extend({ctor:function(){cc.ParticleSystem.prototype.ctor.call(this,cc._renderType===cc._RENDER_TYPE_WEBGL?200:100)},initWithTotalParticles:function(a){return cc.ParticleSystem.prototype.initWithTotalParticles.call(this,a)?(this.setDuration(cc.ParticleSystem.DURATION_INFINITY),this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY),this.setGravity(cc.p(0,0)),this.setSpeed(60),this.setSpeedVar(10),this.setRadialAccel(-80),this.setRadialAccelVar(0),this.setTangentialAccel(80),
this.setTangentialAccelVar(0),this.setAngle(90),this.setAngleVar(360),a=cc.director.getWinSize(),this.setPosition(a.width/2,a.height/2),this.setPosVar(cc.p(0,0)),this.setLife(4),this.setLifeVar(1),this.setStartSize(37),this.setStartSizeVar(10),this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE),this.setEmissionRate(this.getTotalParticles()/this.getLife()),this.setStartColor(cc.color(31,64,194,255)),this.setStartColorVar(cc.color(0,0,0,0)),this.setEndColor(cc.color(0,0,0,255)),this.setEndColorVar(cc.color(0,
0,0,0)),this.setBlendAdditive(!0),!0):!1}});cc.ParticleGalaxy.create=function(){return new cc.ParticleGalaxy};
cc.ParticleFlower=cc.ParticleSystem.extend({ctor:function(){cc.ParticleSystem.prototype.ctor.call(this,cc._renderType===cc._RENDER_TYPE_WEBGL?250:100)},initWithTotalParticles:function(a){return cc.ParticleSystem.prototype.initWithTotalParticles.call(this,a)?(this.setDuration(cc.ParticleSystem.DURATION_INFINITY),this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY),this.setGravity(cc.p(0,0)),this.setSpeed(80),this.setSpeedVar(10),this.setRadialAccel(-60),this.setRadialAccelVar(0),this.setTangentialAccel(15),
this.setTangentialAccelVar(0),this.setAngle(90),this.setAngleVar(360),a=cc.director.getWinSize(),this.setPosition(a.width/2,a.height/2),this.setPosVar(cc.p(0,0)),this.setLife(4),this.setLifeVar(1),this.setStartSize(30),this.setStartSizeVar(10),this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE),this.setEmissionRate(this.getTotalParticles()/this.getLife()),this.setStartColor(cc.color(128,128,128,255)),this.setStartColorVar(cc.color(128,128,128,128)),this.setEndColor(cc.color(0,0,0,255)),
this.setEndColorVar(cc.color(0,0,0,0)),this.setBlendAdditive(!0),!0):!1}});cc.ParticleFlower.create=function(){return new cc.ParticleFlower};
cc.ParticleMeteor=cc.ParticleSystem.extend({ctor:function(){cc.ParticleSystem.prototype.ctor.call(this,cc._renderType===cc._RENDER_TYPE_WEBGL?150:100)},initWithTotalParticles:function(a){return cc.ParticleSystem.prototype.initWithTotalParticles.call(this,a)?(this.setDuration(cc.ParticleSystem.DURATION_INFINITY),this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY),this.setGravity(cc.p(-200,200)),this.setSpeed(15),this.setSpeedVar(5),this.setRadialAccel(0),this.setRadialAccelVar(0),this.setTangentialAccel(0),
this.setTangentialAccelVar(0),this.setAngle(90),this.setAngleVar(360),a=cc.director.getWinSize(),this.setPosition(a.width/2,a.height/2),this.setPosVar(cc.p(0,0)),this.setLife(2),this.setLifeVar(1),this.setStartSize(60),this.setStartSizeVar(10),this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE),this.setEmissionRate(this.getTotalParticles()/this.getLife()),this.setStartColor(cc.color(51,102,179)),this.setStartColorVar(cc.color(0,0,51,26)),this.setEndColor(cc.color(0,0,0,255)),this.setEndColorVar(cc.color(0,
0,0,0)),this.setBlendAdditive(!0),!0):!1}});cc.ParticleMeteor.create=function(){return new cc.ParticleMeteor};
cc.ParticleSpiral=cc.ParticleSystem.extend({ctor:function(){cc.ParticleSystem.prototype.ctor.call(this,cc._renderType===cc._RENDER_TYPE_WEBGL?500:100)},initWithTotalParticles:function(a){return cc.ParticleSystem.prototype.initWithTotalParticles.call(this,a)?(this.setDuration(cc.ParticleSystem.DURATION_INFINITY),this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY),this.setGravity(cc.p(0,0)),this.setSpeed(150),this.setSpeedVar(0),this.setRadialAccel(-380),this.setRadialAccelVar(0),this.setTangentialAccel(45),
this.setTangentialAccelVar(0),this.setAngle(90),this.setAngleVar(0),a=cc.director.getWinSize(),this.setPosition(a.width/2,a.height/2),this.setPosVar(cc.p(0,0)),this.setLife(12),this.setLifeVar(0),this.setStartSize(20),this.setStartSizeVar(0),this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE),this.setEmissionRate(this.getTotalParticles()/this.getLife()),this.setStartColor(cc.color(128,128,128,255)),this.setStartColorVar(cc.color(128,128,128,0)),this.setEndColor(cc.color(128,128,128,255)),
this.setEndColorVar(cc.color(128,128,128,0)),this.setBlendAdditive(!1),!0):!1}});cc.ParticleSpiral.create=function(){return new cc.ParticleSpiral};
cc.ParticleExplosion=cc.ParticleSystem.extend({ctor:function(){cc.ParticleSystem.prototype.ctor.call(this,cc._renderType===cc._RENDER_TYPE_WEBGL?700:300)},initWithTotalParticles:function(a){return cc.ParticleSystem.prototype.initWithTotalParticles.call(this,a)?(this.setDuration(0.1),this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY),this.setGravity(cc.p(0,0)),this.setSpeed(70),this.setSpeedVar(40),this.setRadialAccel(0),this.setRadialAccelVar(0),this.setTangentialAccel(0),this.setTangentialAccelVar(0),
this.setAngle(90),this.setAngleVar(360),a=cc.director.getWinSize(),this.setPosition(a.width/2,a.height/2),this.setPosVar(cc.p(0,0)),this.setLife(5),this.setLifeVar(2),this.setStartSize(15),this.setStartSizeVar(10),this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE),this.setEmissionRate(this.getTotalParticles()/this.getDuration()),this.setStartColor(cc.color(179,26,51,255)),this.setStartColorVar(cc.color(128,128,128,0)),this.setEndColor(cc.color(128,128,128,0)),this.setEndColorVar(cc.color(128,
128,128,0)),this.setBlendAdditive(!1),!0):!1}});cc.ParticleExplosion.create=function(){return new cc.ParticleExplosion};
cc.ParticleSmoke=cc.ParticleSystem.extend({ctor:function(){cc.ParticleSystem.prototype.ctor.call(this,cc._renderType===cc._RENDER_TYPE_WEBGL?200:100)},initWithTotalParticles:function(a){return cc.ParticleSystem.prototype.initWithTotalParticles.call(this,a)?(this.setDuration(cc.ParticleSystem.DURATION_INFINITY),this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY),this.setGravity(cc.p(0,0)),this.setRadialAccel(0),this.setRadialAccelVar(0),this.setSpeed(25),this.setSpeedVar(10),this.setAngle(90),this.setAngleVar(5),
a=cc.director.getWinSize(),this.setPosition(a.width/2,0),this.setPosVar(cc.p(20,0)),this.setLife(4),this.setLifeVar(1),this.setStartSize(60),this.setStartSizeVar(10),this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE),this.setEmissionRate(this.getTotalParticles()/this.getLife()),this.setStartColor(cc.color(204,204,204,255)),this.setStartColorVar(cc.color(5,5,5,0)),this.setEndColor(cc.color(0,0,0,255)),this.setEndColorVar(cc.color(0,0,0,0)),this.setBlendAdditive(!1),!0):!1}});
cc.ParticleSmoke.create=function(){return new cc.ParticleSmoke};
cc.ParticleSnow=cc.ParticleSystem.extend({ctor:function(){cc.ParticleSystem.prototype.ctor.call(this,cc._renderType===cc._RENDER_TYPE_WEBGL?700:250)},initWithTotalParticles:function(a){return cc.ParticleSystem.prototype.initWithTotalParticles.call(this,a)?(this.setDuration(cc.ParticleSystem.DURATION_INFINITY),this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY),this.setGravity(cc.p(0,-1)),this.setSpeed(5),this.setSpeedVar(1),this.setRadialAccel(0),this.setRadialAccelVar(1),this.setTangentialAccel(0),
this.setTangentialAccelVar(1),a=cc.director.getWinSize(),this.setPosition(a.width/2,a.height+10),this.setPosVar(cc.p(a.width/2,0)),this.setAngle(-90),this.setAngleVar(5),this.setLife(45),this.setLifeVar(15),this.setStartSize(10),this.setStartSizeVar(5),this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE),this.setEmissionRate(10),this.setStartColor(cc.color(255,255,255,255)),this.setStartColorVar(cc.color(0,0,0,0)),this.setEndColor(cc.color(255,255,255,0)),this.setEndColorVar(cc.color(0,
0,0,0)),this.setBlendAdditive(!1),!0):!1}});cc.ParticleSnow.create=function(){return new cc.ParticleSnow};
cc.ParticleRain=cc.ParticleSystem.extend({ctor:function(){cc.ParticleSystem.prototype.ctor.call(this,cc._renderType===cc._RENDER_TYPE_WEBGL?1E3:300)},initWithTotalParticles:function(a){return cc.ParticleSystem.prototype.initWithTotalParticles.call(this,a)?(this.setDuration(cc.ParticleSystem.DURATION_INFINITY),this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY),this.setGravity(cc.p(10,-10)),this.setRadialAccel(0),this.setRadialAccelVar(1),this.setTangentialAccel(0),this.setTangentialAccelVar(1),this.setSpeed(130),
this.setSpeedVar(30),this.setAngle(-90),this.setAngleVar(5),a=cc.director.getWinSize(),this.setPosition(a.width/2,a.height),this.setPosVar(cc.p(a.width/2,0)),this.setLife(4.5),this.setLifeVar(0),this.setStartSize(4),this.setStartSizeVar(2),this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE),this.setEmissionRate(20),this.setStartColor(cc.color(179,204,255,255)),this.setStartColorVar(cc.color(0,0,0,0)),this.setEndColor(cc.color(179,204,255,128)),this.setEndColorVar(cc.color(0,0,0,0)),this.setBlendAdditive(!1),
!0):!1}});cc.ParticleRain.create=function(){return new cc.ParticleRain};cc.PARTICLE_DEFAULT_CAPACITY=500;
cc.ParticleBatchNode=cc.Node.extend({textureAtlas:null,_blendFunc:null,_className:"ParticleBatchNode",ctor:function(a,b){cc.Node.prototype.ctor.call(this);this._blendFunc={src:cc.BLEND_SRC,dst:cc.BLEND_DST};cc.isString(a)?this.init(a,b):a instanceof cc.Texture2D&&this.initWithTexture(a,b)},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.ParticleBatchNode.CanvasRenderCmd(this):new cc.ParticleBatchNode.WebGLRenderCmd(this)},initWithTexture:function(a,b){return this.textureAtlas=
new cc.TextureAtlas,this.textureAtlas.initWithTexture(a,b),this._children.length=0,this._renderCmd._initWithTexture(),!0},initWithFile:function(a,b){var c=cc.textureCache.addImage(a);return this.initWithTexture(c,b)},init:function(a,b){var c=cc.textureCache.addImage(a);return this.initWithTexture(c,b)},addChild:function(a,b,c){if(!a)throw"cc.ParticleBatchNode.addChild() : child should be non-null";if(!(a instanceof cc.ParticleSystem))throw"cc.ParticleBatchNode.addChild() : only supports cc.ParticleSystem as children";
if(b=null==b?a.zIndex:b,c=null==c?a.tag:c,a.getTexture()!==this.textureAtlas.texture)throw"cc.ParticleSystem.addChild() : the child is not using the same texture id";var d=a.getBlendFunc();if(0===this._children.length)this.setBlendFunc(d);else if(d.src!==this._blendFunc.src||d.dst!==this._blendFunc.dst)return void cc.log("cc.ParticleSystem.addChild() : Can't add a ParticleSystem that uses a different blending function");b=this._addChildHelper(a,b,c);c=0;0!==b?(b=this._children[b-1],c=b.getAtlasIndex()+
b.getTotalParticles()):c=0;this.insertChild(a,c);a.setBatchNode(this)},insertChild:function(a,b){var c=a.getTotalParticles(),d=this.textureAtlas,e=d.totalQuads;a.setAtlasIndex(b);e+c>d.getCapacity()&&(this._increaseAtlasCapacityTo(e+c),d.fillWithEmptyQuadsFromIndex(d.getCapacity()-c,c));a.getAtlasIndex()+c!==e&&d.moveQuadsFromIndex(b,b+c);d.increaseTotalQuadsWith(c);this._updateAllAtlasIndexes()},removeChild:function(a,b){if(null!=a){if(!(a instanceof cc.ParticleSystem))throw"cc.ParticleBatchNode.removeChild(): only supports cc.ParticleSystem as children";
if(-1===this._children.indexOf(a))return void cc.log("cc.ParticleBatchNode.removeChild(): doesn't contain the sprite. Can't remove it");cc.Node.prototype.removeChild.call(this,a,b);var c=this.textureAtlas;c.removeQuadsAtIndex(a.getAtlasIndex(),a.getTotalParticles());c.fillWithEmptyQuadsFromIndex(c.totalQuads,a.getTotalParticles());a.setBatchNode(null);this._updateAllAtlasIndexes()}},reorderChild:function(a,b){if(!a)throw"cc.ParticleBatchNode.reorderChild(): child should be non-null";if(!(a instanceof
cc.ParticleSystem))throw"cc.ParticleBatchNode.reorderChild(): only supports cc.QuadParticleSystems as children";if(-1===this._children.indexOf(a))return void cc.log("cc.ParticleBatchNode.reorderChild(): Child doesn't belong to batch");if(b!==a.zIndex){if(1<this._children.length){var c=this._getCurrentIndex(a,b);if(c.oldIndex!==c.newIndex){this._children.splice(c.oldIndex,1);this._children.splice(c.newIndex,0,a);c=a.getAtlasIndex();this._updateAllAtlasIndexes();for(var d=0,e=this._children,f=0;f<e.length;f++)if(e[f]===
a){d=a.getAtlasIndex();break}this.textureAtlas.moveQuadsFromIndex(c,a.getTotalParticles(),d);a.updateWithNoTime()}}a._setLocalZOrder(b)}},removeChildAtIndex:function(a,b){this.removeChild(this._children[i],b)},removeAllChildren:function(a){for(var b=this._children,c=0;c<b.length;c++)b[c].setBatchNode(null);cc.Node.prototype.removeAllChildren.call(this,a);this.textureAtlas.removeAllQuads()},disableParticle:function(a){a=this.textureAtlas.quads[a];a.br.vertices.x=a.br.vertices.y=a.tr.vertices.x=a.tr.vertices.y=
a.tl.vertices.x=a.tl.vertices.y=a.bl.vertices.x=a.bl.vertices.y=0;this.textureAtlas._setDirty(!0)},getTexture:function(){return this.textureAtlas.texture},setTexture:function(a){this.textureAtlas.texture=a;var b=this._blendFunc;a&&!a.hasPremultipliedAlpha()&&b.src===cc.BLEND_SRC&&b.dst===cc.BLEND_DST&&(b.src=cc.SRC_ALPHA,b.dst=cc.ONE_MINUS_SRC_ALPHA)},setBlendFunc:function(a,b){void 0===b?(this._blendFunc.src=a.src,this._blendFunc.dst=a.dst):(this._blendFunc.src=a,this._blendFunc.src=b)},getBlendFunc:function(){return new cc.BlendFunc(this._blendFunc.src,
this._blendFunc.dst)},_updateAllAtlasIndexes:function(){for(var a=0,b=this._children,c=0;c<b.length;c++){var d=b[c];d.setAtlasIndex(a);a+=d.getTotalParticles()}},_increaseAtlasCapacityTo:function(a){cc.log("cocos2d: cc.ParticleBatchNode: resizing TextureAtlas capacity from ["+this.textureAtlas.getCapacity()+"] to ["+a+"].");this.textureAtlas.resizeCapacity(a)||cc.log("cc.ParticleBatchNode._increaseAtlasCapacityTo() : WARNING: Not enough memory to resize the atlas")},_searchNewPositionInChildrenForZ:function(a){for(var b=
this._children,c=b.length,d=0;c>d;d++)if(b[d].zIndex>a)return d;return c},_getCurrentIndex:function(a,b){for(var c=!1,d=!1,e=0,f=0,g=0,h=this._children,k=h.length,m=0;k>m;m++){var n=h[m];if(n.zIndex>b&&!d&&(e=m,d=!0,c&&d))break;if(a===n&&(f=m,c=!0,d||(g=-1),c&&d))break}return d||(e=k),e+=g,{newIndex:e,oldIndex:f}},_addChildHelper:function(a,b,c){if(!a)throw"cc.ParticleBatchNode._addChildHelper(): child should be non-null";if(a.parent)return cc.log("cc.ParticleBatchNode._addChildHelper(): child already added. It can't be added again"),
null;this._children||(this._children=[]);var d=this._searchNewPositionInChildrenForZ(b);return this._children.splice(d,0,a),a.tag=c,a._setLocalZOrder(b),a.parent=this,this._running&&(a.onEnter(),a.onEnterTransitionDidFinish()),d},_updateBlendFunc:function(){this.textureAtlas.texture.hasPremultipliedAlpha()||(this._blendFunc.src=cc.SRC_ALPHA,this._blendFunc.dst=cc.ONE_MINUS_SRC_ALPHA)},getTextureAtlas:function(){return this.textureAtlas},setTextureAtlas:function(a){this.textureAtlas=a}});_p=cc.ParticleBatchNode.prototype;
_p.texture;cc.defineGetterSetter(_p,"texture",_p.getTexture,_p.setTexture);cc.ParticleBatchNode.create=function(a,b){return new cc.ParticleBatchNode(a,b)};(function(){cc.ParticleBatchNode.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._needDraw=!1};var a=cc.ParticleBatchNode.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.ParticleBatchNode.CanvasRenderCmd;a._initWithTexture=function(){}})();
!function(){cc.ParticleBatchNode.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._needDraw=!0};var a=cc.ParticleBatchNode.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.ParticleBatchNode.WebGLRenderCmd;a.rendering=function(a){a=this._node;0!==a.textureAtlas.totalQuads&&(this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),cc.glBlendFuncForParticle(a._blendFunc.src,a._blendFunc.dst),a.textureAtlas.drawQuads())};
a._initWithTexture=function(){this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)};a.visit=function(a){if(this._node._visible){var c=cc.current_stack;c.stack.push(c.top);this._syncStatus(a);c.top=this._stackMatrix;cc.renderer.pushRenderCommand(this);this._dirtyFlag=0;cc.kmGLPopMatrix()}}}();
(function(){cc.ParticleSystem.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._needDraw=!0;this._buffersVBO=[0,0];this._quads=[];this._indices=[];this._quadsArrayBuffer=null};var a=cc.ParticleSystem.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.ParticleSystem.WebGLRenderCmd;a.getDrawMode=function(){};a.setDrawMode=function(a){};a.getShapeType=function(){};a.setShapeType=function(a){};a.setBatchNode=function(a){var c=this._node;if(c._batchNode!==
a){var d=c._batchNode;if(c._batchNode=a,a)for(var e=c._particles,f=0;f<c._totalParticles;f++)e[f].atlasIndex=f;a?d||(c._batchNode.textureAtlas._copyQuadsToTextureAtlas(this._quads,c.atlasIndex),cc._renderContext.deleteBuffer(this._buffersVBO[1])):(this._allocMemory(),this.initIndices(c._totalParticles),c.setTexture(d.getTexture()),this._setupVBO())}};a.initIndices=function(a){for(var c=this._indices,d=0;a>d;++d){var e=6*d,f=4*d;c[e+0]=f+0;c[e+1]=f+1;c[e+2]=f+2;c[e+5]=f+1;c[e+4]=f+2;c[e+3]=f+3}};a.isDifferentTexture=
function(a,c){return a===c};a.updateParticlePosition=function(a,c){this.updateQuadWithParticle(a,c)};a.updateQuadWithParticle=function(a,c){var d=null,e=this._node;e._batchNode?(d=e._batchNode.textureAtlas.quads[e.atlasIndex+a.atlasIndex],e._batchNode.textureAtlas.dirty=!0):d=this._quads[e._particleIdx];var f,g,h;e._opacityModifyRGB?(f=0|a.color.r*a.color.a/255,g=0|a.color.g*a.color.a/255,h=0|a.color.b*a.color.a/255):(f=0|a.color.r,g=0|a.color.g,h=0|a.color.b);var e=0|a.color.a,k=d.bl.colors,m=d.br.colors,
n=d.tl.colors,p=d.tr.colors;k.r=m.r=n.r=p.r=f;k.g=m.g=n.g=p.g=g;k.b=m.b=n.b=p.b=h;k.a=m.a=n.a=p.a=e;f=a.size/2;a.rotation?(g=-f,h=-f,e=c.x,k=c.y,n=-cc.degreesToRadians(a.rotation),m=Math.cos(n),n=Math.sin(n),d.bl.vertices.x=g*m-h*n+e,d.bl.vertices.y=g*n+h*m+k,d.br.vertices.x=f*m-h*n+e,d.br.vertices.y=f*n+h*m+k,d.tl.vertices.x=g*m-f*n+e,d.tl.vertices.y=g*n+f*m+k,d.tr.vertices.x=f*m-f*n+e,d.tr.vertices.y=f*n+f*m+k):(d.bl.vertices.x=c.x-f,d.bl.vertices.y=c.y-f,d.br.vertices.x=c.x+f,d.br.vertices.y=c.y-
f,d.tl.vertices.x=c.x-f,d.tl.vertices.y=c.y+f,d.tr.vertices.x=c.x+f,d.tr.vertices.y=c.y+f)};a.rendering=function(a){var c=this._node;c._texture&&(a=a||cc._renderContext,this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),cc.glBindTexture2D(c._texture),cc.glBlendFuncForParticle(c._blendFunc.src,c._blendFunc.dst),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX),a.bindBuffer(a.ARRAY_BUFFER,this._buffersVBO[0]),a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,
3,a.FLOAT,!1,24,0),a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,a.UNSIGNED_BYTE,!0,24,12),a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,a.FLOAT,!1,24,16),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this._buffersVBO[1]),a.drawElements(a.TRIANGLES,6*c._particleIdx,a.UNSIGNED_SHORT,0))};a.initTexCoordsWithRect=function(a){var c=this._node,d=c.texture,e=cc.contentScaleFactor(),e=cc.rect(a.x*e,a.y*e,a.width*e,a.height*e),f=a.width;a=a.height;d&&(f=d.pixelsWidth,a=d.pixelsHeight);var g,h,k,m;cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL?
(g=(2*e.x+1)/(2*f),h=(2*e.y+1)/(2*a),k=g+(2*e.width-2)/(2*f),m=h+(2*e.height-2)/(2*a)):(g=e.x/f,h=e.y/a,k=g+e.width/f,m=h+e.height/a);d=m;m=h;h=d;var n,d=a=0;c._batchNode?(n=c._batchNode.textureAtlas.quads,a=c.atlasIndex,d=c.atlasIndex+c._totalParticles):(n=this._quads,a=0,d=c._totalParticles);for(c=a;d>c;c++)n[c]||(n[c]=cc.V3F_C4B_T2F_QuadZero()),a=n[c],a.bl.texCoords.u=g,a.bl.texCoords.v=h,a.br.texCoords.u=k,a.br.texCoords.v=h,a.tl.texCoords.u=g,a.tl.texCoords.v=m,a.tr.texCoords.u=k,a.tr.texCoords.v=
m};a.setTotalParticles=function(a){var c=this._node;if(a>c._allocatedParticles){var d=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;this._indices=new Uint16Array(6*a);var e=new ArrayBuffer(a*d),f=c._particles;f.length=0;for(var g=this._quads,h=g.length=0;a>h;h++)f[h]=new cc.Particle,g[h]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,e,h*d);if(c._allocatedParticles=a,c._totalParticles=a,c._batchNode)for(d=0;a>d;d++)f[d].atlasIndex=d;this._quadsArrayBuffer=e;this.initIndices(a);this._setupVBO();c._texture&&this.initTexCoordsWithRect(cc.rect(0,
0,c._texture.width,c._texture.height))}else c._totalParticles=a;c.resetSystem()};a.addParticle=function(){var a=this._node;return a._particles[a.particleCount]};a._setupVBO=function(){var a=cc._renderContext;this._buffersVBO[0]=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,this._buffersVBO[0]);a.bufferData(a.ARRAY_BUFFER,this._quadsArrayBuffer,a.DYNAMIC_DRAW);this._buffersVBO[1]=a.createBuffer();a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this._buffersVBO[1]);a.bufferData(a.ELEMENT_ARRAY_BUFFER,this._indices,
a.STATIC_DRAW)};a._allocMemory=function(){var a=this._node;if(a._batchNode)return cc.log("cc.ParticleSystem._allocMemory(): Memory should not be allocated when not using batchNode"),!1;var c=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,a=a._totalParticles,d=this._quads;d.length=0;this._indices=new Uint16Array(6*a);for(var e=new ArrayBuffer(c*a),f=0;a>f;f++)d[f]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,e,f*c);return d&&this._indices?(this._quadsArrayBuffer=e,!0):(cc.log("cocos2d: Particle system: not enough memory"),
!1)};a.postStep=function(){var a=cc._renderContext;a.bindBuffer(a.ARRAY_BUFFER,this._buffersVBO[0]);a.bufferData(a.ARRAY_BUFFER,this._quadsArrayBuffer,a.DYNAMIC_DRAW)};a._setBlendAdditive=function(){var a=this._node._blendFunc;this._texture&&!this._texture.hasPremultipliedAlpha()?(a.src=cc.SRC_ALPHA,a.dst=cc.ONE_MINUS_SRC_ALPHA):(a.src=cc.BLEND_SRC,a.dst=cc.BLEND_DST)};a._initWithTotalParticles=function(a){return this._allocMemory()?(this.initIndices(a),this._setupVBO(),void(this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR))):
!1};a._updateDeltaColor=function(a,c){a.color.r+=a.deltaColor.r*c;a.color.g+=a.deltaColor.g*c;a.color.b+=a.deltaColor.b*c;a.color.a+=a.deltaColor.a*c;a.isChangeColor=!0}})();cc.IMEKeyboardNotificationInfo=function(a,b,c){this.begin=a||cc.rect(0,0,0,0);this.end=b||cc.rect(0,0,0,0);this.duration=c||0};
cc.IMEDelegate=cc.Class.extend({ctor:function(){cc.imeDispatcher.addDelegate(this)},removeDelegate:function(){cc.imeDispatcher.removeDelegate(this)},attachWithIME:function(){return cc.imeDispatcher.attachDelegateWithIME(this)},detachWithIME:function(){return cc.imeDispatcher.detachDelegateWithIME(this)},canAttachWithIME:function(){return!1},didAttachWithIME:function(){},canDetachWithIME:function(){return!1},didDetachWithIME:function(){},insertText:function(a,b){},deleteBackward:function(){},getContentText:function(){return""},
keyboardWillShow:function(a){},keyboardDidShow:function(a){},keyboardWillHide:function(a){},keyboardDidHide:function(a){}});
cc.IMEDispatcher=cc.Class.extend({_domInputControl:null,impl:null,_currentInputString:"",_lastClickPosition:null,ctor:function(){this.impl=new cc.IMEDispatcher.Impl;this._lastClickPosition=cc.p(0,0)},init:function(){if(!cc.sys.isMobile){(this._domInputControl=cc.$("#imeDispatcherInput"))||(this._domInputControl=cc.$new("input"),this._domInputControl.setAttribute("type","text"),this._domInputControl.setAttribute("id","imeDispatcherInput"),this._domInputControl.resize(0,0),this._domInputControl.translates(0,
0),this._domInputControl.style.opacity="0",this._domInputControl.style.fontSize="1px",this._domInputControl.setAttribute("tabindex",2),this._domInputControl.style.position="absolute",this._domInputControl.style.top=0,this._domInputControl.style.left=0,document.body.appendChild(this._domInputControl));var a=this;cc._addEventListener(this._domInputControl,"input",function(){a._processDomInputString(a._domInputControl.value)},!1);cc._addEventListener(this._domInputControl,"keydown",function(b){b.keyCode===
cc.KEY.tab?(b.stopPropagation(),b.preventDefault()):b.keyCode===cc.KEY.enter&&(a.dispatchInsertText("\n",1),b.stopPropagation(),b.preventDefault())},!1);/msie/i.test(navigator.userAgent)&&cc._addEventListener(this._domInputControl,"keyup",function(b){b.keyCode===cc.KEY.backspace&&a._processDomInputString(a._domInputControl.value)},!1);cc._addEventListener(window,"mousedown",function(b){var c=b.pageY||0;a._lastClickPosition.x=b.pageX||0;a._lastClickPosition.y=c},!1)}},_processDomInputString:function(a){var b,
c;b=this._currentInputString.length<a.length?this._currentInputString.length:a.length;for(c=0;b>c&&a[c]===this._currentInputString[c];c++);var d=this._currentInputString.length-c,e=a.length-c;for(b=0;d>b;b++)this.dispatchDeleteBackward();for(b=0;e>b;b++)this.dispatchInsertText(a[c+b],1);this._currentInputString=a},dispatchInsertText:function(a,b){!this.impl||!a||0>=b||this.impl._delegateWithIme&&this.impl._delegateWithIme.insertText(a,b)},dispatchDeleteBackward:function(){this.impl&&this.impl._delegateWithIme&&
this.impl._delegateWithIme.deleteBackward()},getContentText:function(){if(this.impl&&this.impl._delegateWithIme){var a=this.impl._delegateWithIme.getContentText();return a?a:""}return""},dispatchKeyboardWillShow:function(a){if(this.impl)for(var b=0;b<this.impl._delegateList.length;b++){var c=this.impl._delegateList[b];c&&c.keyboardWillShow(a)}},dispatchKeyboardDidShow:function(a){if(this.impl)for(var b=0;b<this.impl._delegateList.length;b++){var c=this.impl._delegateList[b];c&&c.keyboardDidShow(a)}},
dispatchKeyboardWillHide:function(a){if(this.impl)for(var b=0;b<this.impl._delegateList.length;b++){var c=this.impl._delegateList[b];c&&c.keyboardWillHide(a)}},dispatchKeyboardDidHide:function(a){if(this.impl)for(var b=0;b<this.impl._delegateList.length;b++){var c=this.impl._delegateList[b];c&&c.keyboardDidHide(a)}},addDelegate:function(a){a&&this.impl&&(-1<this.impl._delegateList.indexOf(a)||this.impl._delegateList.splice(0,0,a))},attachDelegateWithIME:function(a){if(!this.impl||!a||-1===this.impl._delegateList.indexOf(a))return!1;
if(this.impl._delegateWithIme){if(!this.impl._delegateWithIme.canDetachWithIME()||!a.canAttachWithIME())return!1;var b=this.impl._delegateWithIme;return this.impl._delegateWithIme=null,b.didDetachWithIME(),this._focusDomInput(a),!0}return a.canAttachWithIME()?(this._focusDomInput(a),!0):!1},_focusDomInput:function(a){cc.sys.isMobile?(this.impl._delegateWithIme=a,a.didAttachWithIME(),this._currentInputString=a.string||"",a=a.getTipMessage?a.getTipMessage():"please enter your word:",a=prompt(a,this._currentInputString),
null!=a&&this._processDomInputString(a),this.dispatchInsertText("\n",1)):(this.impl._delegateWithIme=a,this._currentInputString=a.string||"",a.didAttachWithIME(),this._domInputControl.focus(),this._domInputControl.value=this._currentInputString,this._domInputControlTranslate())},_domInputControlTranslate:function(){/msie/i.test(navigator.userAgent)?(this._domInputControl.style.left=this._lastClickPosition.x+"px",this._domInputControl.style.top=this._lastClickPosition.y+"px"):this._domInputControl.translates(this._lastClickPosition.x,
this._lastClickPosition.y)},detachDelegateWithIME:function(a){return this.impl&&a?this.impl._delegateWithIme!==a?!1:a.canDetachWithIME()?(this.impl._delegateWithIme=null,a.didDetachWithIME(),cc._canvas.focus(),!0):!1:!1},removeDelegate:function(a){this.impl&&a&&-1!==this.impl._delegateList.indexOf(a)&&(this.impl._delegateWithIme&&a===this.impl._delegateWithIme&&(this.impl._delegateWithIme=null),cc.arrayRemoveObject(this.impl._delegateList,a))},processKeycode:function(a){32>a?a===cc.KEY.backspace?
this.dispatchDeleteBackward():a===cc.KEY.enter?this.dispatchInsertText("\n",1):a===cc.KEY.tab||a===cc.KEY.escape:255>a&&this.dispatchInsertText(String.fromCharCode(a),1)}});cc.IMEDispatcher.Impl=cc.Class.extend({_delegateWithIme:null,_delegateList:null,ctor:function(){this._delegateList=[]},findDelegate:function(a){for(var b=0;b<this._delegateList.length;b++)if(this._delegateList[b]===a)return b;return null}});cc.imeDispatcher=new cc.IMEDispatcher;
document.body?cc.imeDispatcher.init():cc._addEventListener(window,"load",function(){cc.imeDispatcher.init()},!1);cc.TextFieldDelegate=cc.Class.extend({onTextFieldAttachWithIME:function(a){return!1},onTextFieldDetachWithIME:function(a){return!1},onTextFieldInsertText:function(a,b,c){return!1},onTextFieldDeleteBackward:function(a,b,c){return!1},onDraw:function(a){return!1}});
cc.TextFieldTTF=cc.LabelTTF.extend({delegate:null,colorSpaceHolder:null,_colorText:null,_lens:null,_inputText:"",_placeHolder:"",_charCount:0,_className:"TextFieldTTF",ctor:function(a,b,c,d,e){this.colorSpaceHolder=cc.color(127,127,127);this._colorText=cc.color(255,255,255,255);cc.imeDispatcher.addDelegate(this);cc.LabelTTF.prototype.ctor.call(this);void 0!==e?(this.initWithPlaceHolder("",b,c,d,e),a&&this.setPlaceHolder(a)):void 0===d&&void 0!==c&&(this.initWithString("",b,c),a&&this.setPlaceHolder(a))},
getDelegate:function(){return this.delegate},setDelegate:function(a){this.delegate=a},getCharCount:function(){return this._charCount},getColorSpaceHolder:function(){return cc.color(this.colorSpaceHolder)},setColorSpaceHolder:function(a){this.colorSpaceHolder.r=a.r;this.colorSpaceHolder.g=a.g;this.colorSpaceHolder.b=a.b;this.colorSpaceHolder.a=cc.isUndefined(a.a)?255:a.a;this._inputText.length||this.setColor(this.colorSpaceHolder)},setTextColor:function(a){this._colorText.r=a.r;this._colorText.g=a.g;
this._colorText.b=a.b;this._colorText.a=cc.isUndefined(a.a)?255:a.a;this._inputText.length&&this.setColor(this._colorText)},initWithPlaceHolder:function(a,b,c,d,e){switch(arguments.length){case 5:return a&&this.setPlaceHolder(a),this.initWithString(this._placeHolder,d,e,b,c);case 3:return a&&this.setPlaceHolder(a),this.initWithString(this._placeHolder,arguments[1],arguments[2]);default:throw"Argument must be non-nil ";}},setString:function(a){this._inputText=(a=String(a))||"";this._inputText.length?
(cc.LabelTTF.prototype.setString.call(this,this._inputText),this.setColor(this._colorText)):(cc.LabelTTF.prototype.setString.call(this,this._placeHolder),this.setColor(this.colorSpaceHolder));cc._renderType===cc._RENDER_TYPE_CANVAS&&this._renderCmd._updateTexture();this._charCount=this._inputText.length},getString:function(){return this._inputText},setPlaceHolder:function(a){this._placeHolder=a||"";this._inputText.length||(cc.LabelTTF.prototype.setString.call(this,this._placeHolder),this.setColor(this.colorSpaceHolder))},
getPlaceHolder:function(){return this._placeHolder},draw:function(a){a=a||cc._renderContext;this.delegate&&this.delegate.onDraw(this)||cc.LabelTTF.prototype.draw.call(this,a)},visit:function(a){this._super(a)},attachWithIME:function(){return cc.imeDispatcher.attachDelegateWithIME(this)},detachWithIME:function(){return cc.imeDispatcher.detachDelegateWithIME(this)},canAttachWithIME:function(){return this.delegate?!this.delegate.onTextFieldAttachWithIME(this):!0},didAttachWithIME:function(){},canDetachWithIME:function(){return this.delegate?
!this.delegate.onTextFieldDetachWithIME(this):!0},didDetachWithIME:function(){},deleteBackward:function(){var a=this._inputText.length;if(0!==a&&(!this.delegate||!this.delegate.onTextFieldDeleteBackward(this,this._inputText[a-1],1)))return 1>=a?(this._inputText="",this._charCount=0,cc.LabelTTF.prototype.setString.call(this,this._placeHolder),void this.setColor(this.colorSpaceHolder)):void(this.string=this._inputText.substring(0,a-1))},removeDelegate:function(){cc.imeDispatcher.removeDelegate(this)},
_tipMessage:"please enter your word:",setTipMessage:function(a){null!=a&&(this._tipMessage=a)},getTipMessage:function(){return this._tipMessage},insertText:function(a,b){var c=a,d=c.indexOf("\n");if(-1<d&&(c=c.substring(0,d)),0<c.length){if(this.delegate&&this.delegate.onTextFieldInsertText(this,c,c.length))return;c=this._inputText+c;this._charCount=c.length;this.string=c}-1!==d&&(this.delegate&&this.delegate.onTextFieldInsertText(this,"\n",1)||this.detachWithIME())},getContentText:function(){return this._inputText},
keyboardWillShow:function(a){},keyboardDidShow:function(a){},keyboardWillHide:function(a){},keyboardDidHide:function(a){}});_p=cc.TextFieldTTF.prototype;_p.charCount;cc.defineGetterSetter(_p,"charCount",_p.getCharCount);_p.placeHolder;cc.defineGetterSetter(_p,"placeHolder",_p.getPlaceHolder,_p.setPlaceHolder);cc.TextFieldTTF.create=function(a,b,c,d,e){return new cc.TextFieldTTF(a,b,c,d,e)};cc.TGA_OK=0;cc.TGA_ERROR_FILE_OPEN=1;cc.TGA_ERROR_READING_FILE=2;cc.TGA_ERROR_INDEXED_COLOR=3;
cc.TGA_ERROR_MEMORY=4;cc.TGA_ERROR_COMPRESSED_FILE=5;cc.ImageTGA=function(a,b,c,d,e,f,g){this.status=a||0;this.type=b||0;this.pixelDepth=c||0;this.width=d||0;this.height=e||0;this.imageData=f||[];this.flipped=g||0};
cc.tgaLoadHeader=function(a,b,c){var d=2;if(d+1>b)return!1;a=new cc.BinaryStreamReader(a);if((a.setOffset(d),c.type=a.readByte(),d+=10,d+4+1>b)||(a.setOffset(d),c.width=a.readUnsignedShort(),c.height=a.readUnsignedInteger(),c.pixelDepth=a.readByte(),d+=5,d+1>b))return!1;b=a.readByte();return c.flipped=0,32&b&&(c.flipped=1),!0};
cc.tgaLoadImageData=function(a,b,c){var d,e;if(d=0|c.pixelDepth/2,e=c.height*c.width*d,18+e>b)return!1;if(c.imageData=cc.__getSubArray(a,18,18+e),3<=d)for(a=0;e>a;a+=d)b=c.imageData[a],c.imageData[a]=c.imageData[a+2],c.imageData[a+2]=b;return!0};
cc.tgaRGBtogreyscale=function(a){var b,c;if(8!==a.pixelDepth){var d=a.pixelDepth/8,e=new Uint8Array(a.height*a.width);if(null!==e){for(c=b=0;c<a.width*a.height;b+=d,c++)e[c]=0.3*a.imageData[b]+0.59*a.imageData[b+1]+0.11*a.imageData[b+2];a.pixelDepth=8;a.type=3;a.imageData=e}}};cc.tgaDestroy=function(a){a&&(a.imageData=null)};
cc.tgaLoadRLEImageData=function(a,b,c){var d,e,f,g=0,h=0,k=0,m=[],n=0,p=18;d=c.pixelDepth/8;e=c.height*c.width;for(f=0;e>f;f++){if(0!==n)n--,h=0!==k;else{if(p+1>b)break;n=a[p];p+=1;(k=128&n)&&(n-=128);h=0}if(!h){if(p+d>b)break;if(m=cc.__getSubArray(a,p,p+d),p+=d,3<=d)h=m[0],m[0]=m[2],m[2]=h}for(h=0;d>h;h++)c.imageData[g+h]=m[h];g+=d}return!0};
cc.tgaFlipImage=function(a){for(var b=a.width*(a.pixelDepth/8),c=0;c<a.height/2;c++){var d=cc.__getSubArray(a.imageData,c*b,c*b+b);cc.__setDataToArray(cc.__getSubArray(a.imageData,(a.height-(c+1))*b,b),a.imageData,c*b);cc.__setDataToArray(d,a.imageData,(a.height-(c+1))*b)}a.flipped=0};cc.__getSubArray=function(a,b,c){return a instanceof Array?a.slice(b,c):a.subarray(b,c)};cc.__setDataToArray=function(a,b,c){for(var d=0;d<a.length;d++)b[c+d]=a[d]};
cc.BinaryStreamReader=cc.Class.extend({_binaryData:null,_offset:0,ctor:function(a){this._binaryData=a},setBinaryData:function(a){this._binaryData=a;this._offset=0},getBinaryData:function(){return this._binaryData},_checkSize:function(a){if(!(this._offset+Math.ceil(a/8)<this._data.length))throw Error("Index out of bound");},_decodeFloat:function(a,b){var c=a+b+1,d=c>>3;this._checkSize(c);var c=Math.pow(2,b-1)-1,e=this._readBits(a+b,1,d),f=this._readBits(a,b,d),g=0,h=2,k=0;do for(var m=this._readByte(++k,
d),n=a%8||8,p=1<<n;p>>=1;)m&p&&(g+=1/h),h*=2;while(a-=n);return this._offset+=d,f===(c<<1)+1?g?0/0:e?-(1/0):+(1/0):(1+-2*e)*(f||g?f?Math.pow(2,f-c)*(1+g):Math.pow(2,-c+1)*g:0)},_readByte:function(a,b){return this._data[this._offset+b-a-1]},_decodeInt:function(a,b){var c=this._readBits(0,a,a/8),d=Math.pow(2,a);return this._offset+=a/8,b&&c>=d/2?c-d:c},_shl:function(a,b){for(++b;--b;a=1073741824===(1073741824&(a%=2147483648))?2*a:2*(a-1073741824)+2147483648);return a},_readBits:function(a,b,c){var d=
(a+b)%8,e=a%8,f=c-(a>>3)-1;a=c+(-(a+b)>>3);var g=f-a;b=this._readByte(f,c)>>e&(1<<(g?8-e:b))-1;for(g&&d&&(b+=(this._readByte(a++,c)&(1<<d)-1)<<(g--<<3)-e);g;)b+=this._shl(this._readByte(a++,c),(g--<<3)-e);return b},readInteger:function(){return this._decodeInt(32,!0)},readUnsignedInteger:function(){return this._decodeInt(32,!1)},readSingle:function(){return this._decodeFloat(23,8)},readShort:function(){return this._decodeInt(16,!0)},readUnsignedShort:function(){return this._decodeInt(16,!1)},readByte:function(){var a=
this._data[this._offset];return this._offset+=1,a},readData:function(a,b){return this._binaryData instanceof Array?this._binaryData.slice(a,b):this._binaryData.subarray(a,b)},setOffset:function(a){this._offset=a},getOffset:function(){return this._offset}});cc.TMX_ORIENTATION_ORTHO=0;cc.TMX_ORIENTATION_HEX=1;cc.TMX_ORIENTATION_ISO=2;
cc.TMXTiledMap=cc.Node.extend({properties:null,mapOrientation:null,objectGroups:null,_mapSize:null,_tileSize:null,_tileProperties:null,_className:"TMXTiledMap",ctor:function(a,b){cc.Node.prototype.ctor.call(this);this._mapSize=cc.size(0,0);this._tileSize=cc.size(0,0);void 0!==b?this.initWithXML(a,b):void 0!==a&&this.initWithTMXFile(a)},getMapSize:function(){return cc.size(this._mapSize.width,this._mapSize.height)},setMapSize:function(a){this._mapSize.width=a.width;this._mapSize.height=a.height},_getMapWidth:function(){return this._mapSize.width},
_setMapWidth:function(a){this._mapSize.width=a},_getMapHeight:function(){return this._mapSize.height},_setMapHeight:function(a){this._mapSize.height=a},getTileSize:function(){return cc.size(this._tileSize.width,this._tileSize.height)},setTileSize:function(a){this._tileSize.width=a.width;this._tileSize.height=a.height},_getTileWidth:function(){return this._tileSize.width},_setTileWidth:function(a){this._tileSize.width=a},_getTileHeight:function(){return this._tileSize.height},_setTileHeight:function(a){this._tileSize.height=
a},getMapOrientation:function(){return this.mapOrientation},setMapOrientation:function(a){this.mapOrientation=a},getObjectGroups:function(){return this.objectGroups},setObjectGroups:function(a){this.objectGroups=a},getProperties:function(){return this.properties},setProperties:function(a){this.properties=a},initWithTMXFile:function(a){if(!a||0===a.length)throw"cc.TMXTiledMap.initWithTMXFile(): tmxFile should be non-null or non-empty string.";this.height=this.width=0;a=new cc.TMXMapInfo(a);if(!a)return!1;
var b=a.getTilesets();return b&&0!==b.length||cc.log("cc.TMXTiledMap.initWithTMXFile(): Map not found. Please check the filename."),this._buildWithMapInfo(a),!0},initWithXML:function(a,b){this.height=this.width=0;var c=new cc.TMXMapInfo(a,b),d=c.getTilesets();return d&&0!==d.length||cc.log("cc.TMXTiledMap.initWithXML(): Map not found. Please check the filename."),this._buildWithMapInfo(c),!0},_buildWithMapInfo:function(a){this._mapSize=a.getMapSize();this._tileSize=a.getTileSize();this.mapOrientation=
a.orientation;this.objectGroups=a.getObjectGroups();this.properties=a.properties;this._tileProperties=a.getTileProperties();var b=0,c=a.getLayers();if(c)for(var d=null,e=0,f=c.length;f>e;e++)if(d=c[e],d&&d.visible){var g=this._parseLayer(d,a);this.addChild(g,b,b);this.width=Math.max(this.width,g.width);this.height=Math.max(this.height,g.height);b++}},allLayers:function(){for(var a=[],b=this._children,c=0,d=b.length;d>c;c++){var e=b[c];e&&e instanceof cc.TMXLayer&&a.push(e)}return a},getLayer:function(a){if(!a||
0===a.length)throw"cc.TMXTiledMap.getLayer(): layerName should be non-null or non-empty string.";for(var b=this._children,c=0;c<b.length;c++){var d=b[c];if(d&&d.layerName===a)return d}return null},getObjectGroup:function(a){if(!a||0===a.length)throw"cc.TMXTiledMap.getObjectGroup(): groupName should be non-null or non-empty string.";if(this.objectGroups)for(var b=0;b<this.objectGroups.length;b++){var c=this.objectGroups[b];if(c&&c.groupName===a)return c}return null},getProperty:function(a){return this.properties[a.toString()]},
propertiesForGID:function(a){return cc.log("propertiesForGID is deprecated. Please use getPropertiesForGID instead."),this.getPropertiesForGID[a]},getPropertiesForGID:function(a){return this._tileProperties[a]},_parseLayer:function(a,b){var c=this._tilesetForLayer(a,b),c=new cc.TMXLayer(c,a,b);return a.ownTiles=!1,c.setupTiles(),c},_tilesetForLayer:function(a,b){var c=a._layerSize,d=b.getTilesets();if(d)for(var e=d.length-1;0<=e;e--){var f=d[e];if(f)for(var g=0;g<c.height;g++)for(var h=0;h<c.width;h++){var k=
a._tiles[h+c.width*g];if(0!==k&&(k&cc.TMX_TILE_FLIPPED_MASK)>>>0>=f.firstGid)return f}}return cc.log("cocos2d: Warning: TMX Layer "+a.name+" has no tiles"),null}});_p=cc.TMXTiledMap.prototype;_p.mapWidth;cc.defineGetterSetter(_p,"mapWidth",_p._getMapWidth,_p._setMapWidth);_p.mapHeight;cc.defineGetterSetter(_p,"mapHeight",_p._getMapHeight,_p._setMapHeight);_p.tileWidth;cc.defineGetterSetter(_p,"tileWidth",_p._getTileWidth,_p._setTileWidth);_p.tileHeight;
cc.defineGetterSetter(_p,"tileHeight",_p._getTileHeight,_p._setTileHeight);cc.TMXTiledMap.create=function(a,b){return new cc.TMXTiledMap(a,b)};cc.TMX_PROPERTY_NONE=0;cc.TMX_PROPERTY_MAP=1;cc.TMX_PROPERTY_LAYER=2;cc.TMX_PROPERTY_OBJECTGROUP=3;cc.TMX_PROPERTY_OBJECT=4;cc.TMX_PROPERTY_TILE=5;cc.TMX_TILE_HORIZONTAL_FLAG=2147483648;cc.TMX_TILE_VERTICAL_FLAG=1073741824;cc.TMX_TILE_DIAGONAL_FLAG=536870912;
cc.TMX_TILE_FLIPPED_ALL=(cc.TMX_TILE_HORIZONTAL_FLAG|cc.TMX_TILE_VERTICAL_FLAG|cc.TMX_TILE_DIAGONAL_FLAG)>>>0;cc.TMX_TILE_FLIPPED_MASK=~cc.TMX_TILE_FLIPPED_ALL>>>0;
cc.TMXLayerInfo=cc.Class.extend({properties:null,name:"",_layerSize:null,_tiles:null,visible:null,_opacity:null,ownTiles:!0,_minGID:1E5,_maxGID:0,offset:null,ctor:function(){this.properties=[];this.name="";this._layerSize=null;this._tiles=[];this.visible=!0;this._opacity=0;this.ownTiles=!0;this._minGID=1E5;this._maxGID=0;this.offset=cc.p(0,0)},getProperties:function(){return this.properties},setProperties:function(a){this.properties=a}});
cc.TMXTilesetInfo=cc.Class.extend({name:"",firstGid:0,_tileSize:null,spacing:0,margin:0,sourceImage:"",imageSize:null,ctor:function(){this._tileSize=cc.size(0,0);this.imageSize=cc.size(0,0)},rectForGID:function(a){var b=cc.rect(0,0,0,0);b.width=this._tileSize.width;b.height=this._tileSize.height;a&=cc.TMX_TILE_FLIPPED_MASK;a-=parseInt(this.firstGid,10);var c=parseInt((this.imageSize.width-2*this.margin+this.spacing)/(this._tileSize.width+this.spacing),10);return b.x=parseInt(a%c*(this._tileSize.width+
this.spacing)+this.margin,10),b.y=parseInt(parseInt(a/c,10)*(this._tileSize.height+this.spacing)+this.margin,10),b}});
cc.TMXMapInfo=cc.SAXParser.extend({properties:null,orientation:null,parentElement:null,parentGID:null,layerAttrs:0,storingCharacters:!1,tmxFileName:null,currentString:null,_objectGroups:null,_mapSize:null,_tileSize:null,_layers:null,_tilesets:null,_tileProperties:null,_resources:"",_currentFirstGID:0,ctor:function(a,b){cc.SAXParser.prototype.ctor.apply(this);this._mapSize=cc.size(0,0);this._tileSize=cc.size(0,0);this._layers=[];this._tilesets=[];this._objectGroups=[];this.properties=[];this._tileProperties=
{};this._currentFirstGID=0;void 0!==b?this.initWithXML(a,b):void 0!==a&&this.initWithTMXFile(a)},getOrientation:function(){return this.orientation},setOrientation:function(a){this.orientation=a},getMapSize:function(){return cc.size(this._mapSize.width,this._mapSize.height)},setMapSize:function(a){this._mapSize.width=a.width;this._mapSize.height=a.height},_getMapWidth:function(){return this._mapSize.width},_setMapWidth:function(a){this._mapSize.width=a},_getMapHeight:function(){return this._mapSize.height},
_setMapHeight:function(a){this._mapSize.height=a},getTileSize:function(){return cc.size(this._tileSize.width,this._tileSize.height)},setTileSize:function(a){this._tileSize.width=a.width;this._tileSize.height=a.height},_getTileWidth:function(){return this._tileSize.width},_setTileWidth:function(a){this._tileSize.width=a},_getTileHeight:function(){return this._tileSize.height},_setTileHeight:function(a){this._tileSize.height=a},getLayers:function(){return this._layers},setLayers:function(a){this._layers.push(a)},
getTilesets:function(){return this._tilesets},setTilesets:function(a){this._tilesets.push(a)},getObjectGroups:function(){return this._objectGroups},setObjectGroups:function(a){this._objectGroups.push(a)},getParentElement:function(){return this.parentElement},setParentElement:function(a){this.parentElement=a},getParentGID:function(){return this.parentGID},setParentGID:function(a){this.parentGID=a},getLayerAttribs:function(){return this.layerAttrs},setLayerAttribs:function(a){this.layerAttrs=a},getStoringCharacters:function(){return this.storingCharacters},
setStoringCharacters:function(a){this.storingCharacters=a},getProperties:function(){return this.properties},setProperties:function(a){this.properties=a},initWithTMXFile:function(a){return this._internalInit(a,null),this.parseXMLFile(a)},initWithXML:function(a,b){return this._internalInit(null,b),this.parseXMLString(a)},parseXMLFile:function(a,b){var c=(b=b||!1)?a:cc.loader.getRes(a);if(!c)throw"Please load the resource first : "+a;var d,e,c=this._parseXML(c).documentElement;d=c.getAttribute("version");
e=c.getAttribute("orientation");if("map"===c.nodeName&&("1.0"!==d&&null!==d&&cc.log("cocos2d: TMXFormat: Unsupported TMX version:"+d),"orthogonal"===e?this.orientation=cc.TMX_ORIENTATION_ORTHO:"isometric"===e?this.orientation=cc.TMX_ORIENTATION_ISO:"hexagonal"===e?this.orientation=cc.TMX_ORIENTATION_HEX:null!==e&&cc.log("cocos2d: TMXFomat: Unsupported orientation:"+e),d=cc.size(0,0),d.width=parseFloat(c.getAttribute("width")),d.height=parseFloat(c.getAttribute("height")),this.setMapSize(d),d=cc.size(0,
0),d.width=parseFloat(c.getAttribute("tilewidth")),d.height=parseFloat(c.getAttribute("tileheight")),this.setTileSize(d),e=c.querySelectorAll("map \x3e properties \x3e  property"))){var f={};for(d=0;d<e.length;d++)f[e[d].getAttribute("name")]=e[d].getAttribute("value");this.properties=f}f=c.getElementsByTagName("tileset");"map"!==c.nodeName&&(f=[],f.push(c));for(d=0;d<f.length;d++){e=f[d];var g=e.getAttribute("source");if(g)e=b?cc.path.join(this._resources,g):cc.path.changeBasename(a,g),this.parseXMLFile(e);
else{g=new cc.TMXTilesetInfo;g.name=e.getAttribute("name")||"";g.firstGid=parseInt(e.getAttribute("firstgid"))||0;g.spacing=parseInt(e.getAttribute("spacing"))||0;g.margin=parseInt(e.getAttribute("margin"))||0;var h=cc.size(0,0);h.width=parseFloat(e.getAttribute("tilewidth"));h.height=parseFloat(e.getAttribute("tileheight"));g._tileSize=h;var h=e.getElementsByTagName("image")[0].getAttribute("source"),k=-1;(this.tmxFileName&&(k=this.tmxFileName.lastIndexOf("/")),-1!==k)?(k=this.tmxFileName.substr(0,
k+1),g.sourceImage=k+h):g.sourceImage=this._resources+(this._resources?"/":"")+h;this.setTilesets(g);if(h=e.getElementsByTagName("tile"))for(k=0;k<h.length;k++){e=h[k];this.parentGID=parseInt(g.firstGid)+parseInt(e.getAttribute("id")||0);var m=e.querySelectorAll("properties \x3e property");if(m){var n={};for(e=0;e<m.length;e++){var p=m[e].getAttribute("name");n[p]=m[e].getAttribute("value")}this._tileProperties[this.parentGID]=n}}}}if(f=c.getElementsByTagName("layer"))for(d=0;d<f.length;d++){h=f[d];
k=h.getElementsByTagName("data")[0];g=new cc.TMXLayerInfo;g.name=h.getAttribute("name");e=cc.size(0,0);e.width=parseFloat(h.getAttribute("width"));e.height=parseFloat(h.getAttribute("height"));g._layerSize=e;e=h.getAttribute("visible");g.visible="0"!=e;e=h.getAttribute("opacity")||1;g._opacity=parseInt(255*parseFloat(e));g.offset=cc.p(parseFloat(h.getAttribute("x"))||0,parseFloat(h.getAttribute("y"))||0);m="";for(e=0;e<k.childNodes.length;e++)m+=k.childNodes[e].nodeValue;m=m.trim();e=k.getAttribute("compression");
n=k.getAttribute("encoding");if(e&&"gzip"!==e&&"zlib"!==e)return cc.log("cc.TMXMapInfo.parseXMLFile(): unsupported compression method"),null;switch(e){case "gzip":g._tiles=cc.unzipBase64AsArray(m,4);break;case "zlib":e=new Zlib.Inflate(cc.Codec.Base64.decodeAsArray(m,1));g._tiles=cc.uint8ArrayToUint32Array(e.decompress());break;case null:case "":if("base64"===n)g._tiles=cc.Codec.Base64.decodeAsArray(m,4);else if("csv"===n){g._tiles=[];e=m.split(",");for(k=0;k<e.length;k++)g._tiles.push(parseInt(e[k]))}else{e=
k.getElementsByTagName("tile");g._tiles=[];for(k=0;k<e.length;k++)g._tiles.push(parseInt(e[k].getAttribute("gid")))}break;default:this.layerAttrs===cc.TMXLayerInfo.ATTRIB_NONE&&cc.log("cc.TMXMapInfo.parseXMLFile(): Only base64 and/or gzip/zlib maps are supported")}if(h=h.querySelectorAll("properties \x3e property")){k={};for(e=0;e<h.length;e++)k[h[e].getAttribute("name")]=h[e].getAttribute("value");g.properties=k}this.setLayers(g)}if(f=c.getElementsByTagName("objectgroup"))for(d=0;d<f.length;d++){h=
f[d];g=new cc.TMXObjectGroup;g.groupName=h.getAttribute("name");g.setPositionOffset(cc.p(parseFloat(h.getAttribute("x"))*this.getTileSize().width||0,parseFloat(h.getAttribute("y"))*this.getTileSize().height||0));if(k=h.querySelectorAll("objectgroup \x3e properties \x3e property"))for(e=0;e<k.length;e++)m={},m[k[e].getAttribute("name")]=k[e].getAttribute("value"),g.properties=m;h=h.querySelectorAll("object");k=cc.director.getContentScaleFactor();if(h)for(e=0;e<h.length;e++){n=h[e];m={};m.name=n.getAttribute("name")||
"";m.type=n.getAttribute("type")||"";m.width=parseInt(n.getAttribute("width"))||0;m.height=parseInt(n.getAttribute("height"))||0;m.x=((0|(n.getAttribute("x")||0))+g.getPositionOffset().x)/k;p=(0|(n.getAttribute("y")||0))+g.getPositionOffset().y/k;m.y=(parseInt(this.getMapSize().height*this.getTileSize().height)-p-m.height)/cc.director.getContentScaleFactor();m.rotation=parseInt(n.getAttribute("rotation"))||0;if(p=n.querySelectorAll("properties \x3e property"))for(var r=0;r<p.length;r++)m[p[r].getAttribute("name")]=
p[r].getAttribute("value");if((p=n.querySelectorAll("polygon"))&&0<p.length)(p=p[0].getAttribute("points"))&&(m.polygonPoints=this._parsePointsString(p));if((n=n.querySelectorAll("polyline"))&&0<n.length)(n=n[0].getAttribute("points"))&&(m.polylinePoints=this._parsePointsString(n));g.setObjects(m)}this.setObjectGroups(g)}return c},_parsePointsString:function(a){if(!a)return null;var b=[];a=a.split(" ");for(var c=0;c<a.length;c++){var d=a[c].split(",");b.push({x:d[0],y:d[1]})}return b},parseXMLString:function(a){return this.parseXMLFile(a,
!0)},getTileProperties:function(){return this._tileProperties},setTileProperties:function(a){this._tileProperties.push(a)},getCurrentString:function(){return this.currentString},setCurrentString:function(a){this.currentString=a},getTMXFileName:function(){return this.tmxFileName},setTMXFileName:function(a){this.tmxFileName=a},_internalInit:function(a,b){this._tilesets.length=0;this._layers.length=0;this.tmxFileName=a;b&&(this._resources=b);this._objectGroups.length=0;this.properties.length=0;this._tileProperties.length=
0;this.currentString="";this.storingCharacters=!1;this.layerAttrs=cc.TMXLayerInfo.ATTRIB_NONE;this.parentElement=cc.TMX_PROPERTY_NONE;this._currentFirstGID=0}});_p=cc.TMXMapInfo.prototype;_p.mapWidth;cc.defineGetterSetter(_p,"mapWidth",_p._getMapWidth,_p._setMapWidth);_p.mapHeight;cc.defineGetterSetter(_p,"mapHeight",_p._getMapHeight,_p._setMapHeight);_p.tileWidth;cc.defineGetterSetter(_p,"tileWidth",_p._getTileWidth,_p._setTileWidth);_p.tileHeight;
cc.defineGetterSetter(_p,"tileHeight",_p._getTileHeight,_p._setTileHeight);cc.TMXMapInfo.create=function(a,b){return new cc.TMXMapInfo(a,b)};cc.loader.register(["tmx","tsx"],cc._txtLoader);cc.TMXLayerInfo.ATTRIB_NONE=1;cc.TMXLayerInfo.ATTRIB_BASE64=2;cc.TMXLayerInfo.ATTRIB_GZIP=4;cc.TMXLayerInfo.ATTRIB_ZLIB=8;
cc.TMXObjectGroup=cc.Class.extend({properties:null,groupName:"",_positionOffset:null,_objects:null,ctor:function(){this.groupName="";this._positionOffset=cc.p(0,0);this.properties=[];this._objects=[]},getPositionOffset:function(){return cc.p(this._positionOffset)},setPositionOffset:function(a){this._positionOffset.x=a.x;this._positionOffset.y=a.y},getProperties:function(){return this.properties},setProperties:function(a){this.properties.push(a)},getGroupName:function(){return this.groupName.toString()},
setGroupName:function(a){this.groupName=a},propertyNamed:function(a){return this.properties[a]},objectNamed:function(a){this.getObject(a)},getObject:function(a){if(this._objects&&0<this._objects.length)for(var b=this._objects,c=0,d=b.length;d>c;c++){var e=b[c].name;if(e&&e===a)return b[c]}return null},getObjects:function(){return this._objects},setObjects:function(a){this._objects.push(a)}});
cc.TMXLayer=cc.SpriteBatchNode.extend({tiles:null,tileset:null,layerOrientation:null,properties:null,layerName:"",_layerSize:null,_mapTileSize:null,_opacity:255,_minGID:null,_maxGID:null,_vertexZvalue:null,_useAutomaticVertexZ:null,_reusedTile:null,_atlasIndexArray:null,_contentScaleFactor:null,_className:"TMXLayer",ctor:function(a,b,c){cc.SpriteBatchNode.prototype.ctor.call(this);this._descendants=[];this._layerSize=cc.size(0,0);this._mapTileSize=cc.size(0,0);void 0!==c&&this.initWithTilesetInfo(a,
b,c)},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.TMXLayer.CanvasRenderCmd(this):new cc.TMXLayer.WebGLRenderCmd(this)},setContentSize:function(a,b){cc.Node.prototype.setContentSize.call(this,a,b);this._renderCmd._updateCacheContext(a,b)},getTexture:function(){return this._renderCmd.getTexture()},getLayerSize:function(){return cc.size(this._layerSize.width,this._layerSize.height)},setLayerSize:function(a){this._layerSize.width=a.width;this._layerSize.height=a.height},
_getLayerWidth:function(){return this._layerSize.width},_setLayerWidth:function(a){this._layerSize.width=a},_getLayerHeight:function(){return this._layerSize.height},_setLayerHeight:function(a){this._layerSize.height=a},getMapTileSize:function(){return cc.size(this._mapTileSize.width,this._mapTileSize.height)},setMapTileSize:function(a){this._mapTileSize.width=a.width;this._mapTileSize.height=a.height},_getTileWidth:function(){return this._mapTileSize.width},_setTileWidth:function(a){this._mapTileSize.width=
a},_getTileHeight:function(){return this._mapTileSize.height},_setTileHeight:function(a){this._mapTileSize.height=a},getTiles:function(){return this.tiles},setTiles:function(a){this.tiles=a},getTileset:function(){return this.tileset},setTileset:function(a){this.tileset=a},getLayerOrientation:function(){return this.layerOrientation},setLayerOrientation:function(a){this.layerOrientation=a},getProperties:function(){return this.properties},setProperties:function(a){this.properties=a},initWithTilesetInfo:function(a,
b,c){var d,e=b._layerSize,f=0.35*parseInt(e.width*e.height)+1;return(a&&(d=cc.textureCache.addImage(a.sourceImage)),this.initWithTexture(d,f))?(this.layerName=b.name,this._layerSize=e,this.tiles=b._tiles,this._minGID=b._minGID,this._maxGID=b._maxGID,this._opacity=b._opacity,this.properties=b.properties,this._contentScaleFactor=cc.director.getContentScaleFactor(),this.tileset=a,this._mapTileSize=c.getTileSize(),this.layerOrientation=c.orientation,a=this._calculateLayerOffset(b.offset),this.setPosition(cc.pointPixelsToPoints(a)),
this._atlasIndexArray=[],this.setContentSize(cc.sizePixelsToPoints(cc.size(this._layerSize.width*this._mapTileSize.width,this._layerSize.height*this._mapTileSize.height))),this._useAutomaticVertexZ=!1,this._vertexZvalue=0,!0):!1},releaseMap:function(){this.tiles&&(this.tiles=null);this._atlasIndexArray&&(this._atlasIndexArray=null)},getTileAt:function(a,b){if(!a)throw"cc.TMXLayer.getTileAt(): pos should be non-null";if(void 0!==b&&(a=cc.p(a,b)),a.x>=this._layerSize.width||a.y>=this._layerSize.height||
0>a.x||0>a.y)throw"cc.TMXLayer.getTileAt(): invalid position";if(!this.tiles||!this._atlasIndexArray)return cc.log("cc.TMXLayer.getTileAt(): TMXLayer: the tiles map has been released"),null;var c=null,d=this.getTileGIDAt(a);if(0===d)return c;var e=0|a.x+a.y*this._layerSize.width;if(c=this.getChildByTag(e),!c)d=this.tileset.rectForGID(d),d=cc.rectPixelsToPoints(d),c=new cc.Sprite,c.initWithTexture(this.texture,d),c.batchNode=this,c.setPosition(this.getPositionAt(a)),c.vertexZ=this._vertexZForPos(a),
c.anchorX=0,c.anchorY=0,c.opacity=this._opacity,d=this._atlasIndexForExistantZ(e),this.addSpriteWithoutQuad(c,d,e);return c},getTileGIDAt:function(a,b){if(null==a)throw"cc.TMXLayer.getTileGIDAt(): pos should be non-null";if(void 0!==b&&(a=cc.p(a,b)),a.x>=this._layerSize.width||a.y>=this._layerSize.height||0>a.x||0>a.y)throw"cc.TMXLayer.getTileGIDAt(): invalid position";return!this.tiles||!this._atlasIndexArray?(cc.log("cc.TMXLayer.getTileGIDAt(): TMXLayer: the tiles map has been released"),null):
(this.tiles[0|a.x+a.y*this._layerSize.width]&cc.TMX_TILE_FLIPPED_MASK)>>>0},getTileFlagsAt:function(a,b){if(!a)throw"cc.TMXLayer.getTileFlagsAt(): pos should be non-null";if(void 0!==b&&(a=cc.p(a,b)),a.x>=this._layerSize.width||a.y>=this._layerSize.height||0>a.x||0>a.y)throw"cc.TMXLayer.getTileFlagsAt(): invalid position";return!this.tiles||!this._atlasIndexArray?(cc.log("cc.TMXLayer.getTileFlagsAt(): TMXLayer: the tiles map has been released"),null):(this.tiles[0|a.x+a.y*this._layerSize.width]&cc.TMX_TILE_FLIPPED_ALL)>>>
0},setTileGID:function(a,b,c,d){if(!b)throw"cc.TMXLayer.setTileGID(): pos should be non-null";var e;if(void 0!==d?e=cc.p(b,c):(e=b,d=c),e.x>=this._layerSize.width||e.y>=this._layerSize.height||0>e.x||0>e.y)throw"cc.TMXLayer.setTileGID(): invalid position";if(!this.tiles||!this._atlasIndexArray)return void cc.log("cc.TMXLayer.setTileGID(): TMXLayer: the tiles map has been released");if(0!==a&&a<this.tileset.firstGid)return void cc.log("cc.TMXLayer.setTileGID(): invalid gid:"+a);d=d||0;this._setNodeDirtyForCache();
b=this.getTileFlagsAt(e);c=this.getTileGIDAt(e);if(c!==a||b!==d)if(b=(a|d)>>>0,0===a)this.removeTileAt(e);else if(0===c)this._insertTileForGID(b,e);else{c=e.x+e.y*this._layerSize.width;var f=this.getChildByTag(c);f?(a=this.tileset.rectForGID(a),a=cc.rectPixelsToPoints(a),f.setTextureRect(a,!1),null!=d&&this._setupTileSprite(f,e,b),this.tiles[c]=b):this._updateTileForGID(b,e)}},removeTileAt:function(a,b){if(!a)throw"cc.TMXLayer.removeTileAt(): pos should be non-null";if(void 0!==b&&(a=cc.p(a,b)),a.x>=
this._layerSize.width||a.y>=this._layerSize.height||0>a.x||0>a.y)throw"cc.TMXLayer.removeTileAt(): invalid position";if(!this.tiles||!this._atlasIndexArray)return void cc.log("cc.TMXLayer.removeTileAt(): TMXLayer: the tiles map has been released");if(0!==this.getTileGIDAt(a)){cc._renderType===cc._RENDER_TYPE_CANVAS&&this._setNodeDirtyForCache();var c=0|a.x+a.y*this._layerSize.width,d=this._atlasIndexForExistantZ(c);this.tiles[c]=0;this._atlasIndexArray.splice(d,1);if(c=this.getChildByTag(c))cc.SpriteBatchNode.prototype.removeChild.call(this,
c,!0);else if(cc._renderType===cc._RENDER_TYPE_WEBGL&&this.textureAtlas.removeQuadAtIndex(d),this._children)for(var c=this._children,e=0,f=c.length;f>e;e++){var g=c[e];if(g){var h=g.atlasIndex;h>=d&&(g.atlasIndex=h-1)}}}},getPositionAt:function(a,b){void 0!==b&&(a=cc.p(a,b));var c=cc.p(0,0);switch(this.layerOrientation){case cc.TMX_ORIENTATION_ORTHO:c=this._positionForOrthoAt(a);break;case cc.TMX_ORIENTATION_ISO:c=this._positionForIsoAt(a);break;case cc.TMX_ORIENTATION_HEX:c=this._positionForHexAt(a)}return cc.pointPixelsToPoints(c)},
getProperty:function(a){return this.properties[a]},setupTiles:function(){this._renderCmd.initImageSize();this._parseInternalProperties();cc._renderType===cc._RENDER_TYPE_CANVAS&&this._setNodeDirtyForCache();for(var a=this._layerSize.height,b=this._layerSize.width,c=0;a>c;c++)for(var d=0;b>d;d++){var e=this.tiles[d+b*c];0!==e&&(this._appendTileForGID(e,cc.p(d,c)),this._minGID=Math.min(e,this._minGID),this._maxGID=Math.max(e,this._maxGID))}this._maxGID>=this.tileset.firstGid&&this._minGID>=this.tileset.firstGid||
cc.log("cocos2d:TMX: Only 1 tileset per layer is supported")},addChild:function(a,b,c){cc.log("addChild: is not supported on cc.TMXLayer. Instead use setTileGID or tileAt.")},removeChild:function(a,b){if(a){if(-1===this._children.indexOf(a))return void cc.log("cc.TMXLayer.removeChild(): Tile does not belong to TMXLayer");cc._renderType===cc._RENDER_TYPE_CANVAS&&this._setNodeDirtyForCache();var c=a.atlasIndex;this.tiles[this._atlasIndexArray[c]]=0;this._atlasIndexArray.splice(c,1);cc.SpriteBatchNode.prototype.removeChild.call(this,
a,b);cc.renderer.childrenOrderDirty=!0}},getLayerName:function(){return this.layerName},setLayerName:function(a){this.layerName=a},_positionForIsoAt:function(a){return cc.p(this._mapTileSize.width/2*(this._layerSize.width+a.x-a.y-1),this._mapTileSize.height/2*(2*this._layerSize.height-a.x-a.y-2))},_positionForOrthoAt:function(a){return cc.p(a.x*this._mapTileSize.width,(this._layerSize.height-a.y-1)*this._mapTileSize.height)},_positionForHexAt:function(a){return cc.p(3*a.x*this._mapTileSize.width/
4,(this._layerSize.height-a.y-1)*this._mapTileSize.height+(1===a.x%2?-this._mapTileSize.height/2:0))},_calculateLayerOffset:function(a){var b=cc.p(0,0);switch(this.layerOrientation){case cc.TMX_ORIENTATION_ORTHO:b=cc.p(a.x*this._mapTileSize.width,-a.y*this._mapTileSize.height);break;case cc.TMX_ORIENTATION_ISO:b=cc.p(this._mapTileSize.width/2*(a.x-a.y),this._mapTileSize.height/2*(-a.x-a.y));break;case cc.TMX_ORIENTATION_HEX:(0!==a.x||0!==a.y)&&cc.log("offset for hexagonal map not implemented yet")}return b},
_appendTileForGID:function(a,b){var c=this.tileset.rectForGID(a),c=cc.rectPixelsToPoints(c),d=0|b.x+b.y*this._layerSize.width,c=this._renderCmd._reusedTileWithRect(c);this._setupTileSprite(c,b,a);var e=this._atlasIndexArray.length;return this.insertQuadFromSprite(c,e),this._atlasIndexArray.splice(e,0,d),c},_insertTileForGID:function(a,b){var c=this.tileset.rectForGID(a),c=cc.rectPixelsToPoints(c),d=0|b.x+b.y*this._layerSize.width,c=this._renderCmd._reusedTileWithRect(c);this._setupTileSprite(c,b,
a);var e=this._atlasIndexForNewZ(d);if(this.insertQuadFromSprite(c,e),this._atlasIndexArray.splice(e,0,d),this._children)for(var f=this._children,g=0,h=f.length;h>g;g++){var k=f[g];if(k){var m=k.atlasIndex;m>=e&&(k.atlasIndex=m+1)}}return this.tiles[d]=a,c},_updateTileForGID:function(a,b){var c=this.tileset.rectForGID(a),d=this._contentScaleFactor,c=cc.rect(c.x/d,c.y/d,c.width/d,c.height/d),d=b.x+b.y*this._layerSize.width,c=this._renderCmd._reusedTileWithRect(c);return this._setupTileSprite(c,b,a),
c.atlasIndex=this._atlasIndexForExistantZ(d),c.dirty=!0,c.updateTransform(),this.tiles[d]=a,c},_parseInternalProperties:function(){var a=this.getProperty("cc_vertexz");if(a)if("automatic"===a){this._useAutomaticVertexZ=!0;var b=this.getProperty("cc_alpha_func"),a=0;if(b&&(a=parseFloat(b)),cc._renderType===cc._RENDER_TYPE_WEBGL)this.shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST),b=cc._renderContext.getUniformLocation(this.shaderProgram.getProgram(),cc.UNIFORM_ALPHA_TEST_VALUE_S),
this.shaderProgram.use(),this.shaderProgram.setUniformLocationWith1f(b,a)}else this._vertexZvalue=parseInt(a,10)},_setupTileSprite:function(a,b,c){var d=b.x+b.y*this._layerSize.width;(a.setPosition(this.getPositionAt(b)),cc._renderType===cc._RENDER_TYPE_WEBGL?a.vertexZ=this._vertexZForPos(b):a.tag=d,a.anchorX=0,a.anchorY=0,a.opacity=this._opacity,cc._renderType===cc._RENDER_TYPE_WEBGL&&(a.rotation=0),a.setFlippedX(!1),a.setFlippedY(!1),(c&cc.TMX_TILE_DIAGONAL_FLAG)>>>0)?(a.anchorX=0.5,a.anchorY=0.5,
a.x=this.getPositionAt(b).x+a.width/2,a.y=this.getPositionAt(b).y+a.height/2,b=(c&(cc.TMX_TILE_HORIZONTAL_FLAG|cc.TMX_TILE_VERTICAL_FLAG)>>>0)>>>0,b===cc.TMX_TILE_HORIZONTAL_FLAG?a.rotation=90:b===cc.TMX_TILE_VERTICAL_FLAG?a.rotation=270:b===(cc.TMX_TILE_VERTICAL_FLAG|cc.TMX_TILE_HORIZONTAL_FLAG)>>>0?(a.rotation=90,a.setFlippedX(!0)):(a.rotation=270,a.setFlippedX(!0))):((c&cc.TMX_TILE_HORIZONTAL_FLAG)>>>0&&a.setFlippedX(!0),(c&cc.TMX_TILE_VERTICAL_FLAG)>>>0&&a.setFlippedY(!0))},_vertexZForPos:function(a){var b=
0,c=0;if(this._useAutomaticVertexZ)switch(this.layerOrientation){case cc.TMX_ORIENTATION_ISO:c=this._layerSize.width+this._layerSize.height;b=-(c-(a.x+a.y));break;case cc.TMX_ORIENTATION_ORTHO:b=-(this._layerSize.height-a.y);break;case cc.TMX_ORIENTATION_HEX:cc.log("TMX Hexa zOrder not supported");break;default:cc.log("TMX invalid value")}else b=this._vertexZvalue;return b},_atlasIndexForExistantZ:function(a){var b;if(this._atlasIndexArray)for(var c=this._atlasIndexArray,d=0,e=c.length;e>d&&(b=c[d],
b!==a);d++);return cc.isNumber(b)||cc.log("cc.TMXLayer._atlasIndexForExistantZ(): TMX atlas index not found. Shall not happen"),d},_atlasIndexForNewZ:function(a){for(var b=this._atlasIndexArray,c=0,d=b.length;d>c&&!(b[c]>a);c++);return c}});_p=cc.TMXLayer.prototype;cc.defineGetterSetter(_p,"texture",_p.getTexture,_p.setTexture);_p.layerWidth;cc.defineGetterSetter(_p,"layerWidth",_p._getLayerWidth,_p._setLayerWidth);_p.layerHeight;cc.defineGetterSetter(_p,"layerHeight",_p._getLayerHeight,_p._setLayerHeight);
_p.tileWidth;cc.defineGetterSetter(_p,"tileWidth",_p._getTileWidth,_p._setTileWidth);_p.tileHeight;cc.defineGetterSetter(_p,"tileHeight",_p._getTileHeight,_p._setTileHeight);cc.TMXLayer.create=function(a,b,c){return new cc.TMXLayer(a,b,c)};
(function(){cc.TMXLayer.CanvasRenderCmd=function(a){cc.SpriteBatchNode.CanvasRenderCmd.call(this,a);this._needDraw=!0;this._realWorldTransform={a:1,b:0,c:0,d:1,tx:0,ty:0};var c=cc._canvas;a=cc.newElement("canvas");a.width=c.width;a.height=c.height;this._cacheCanvas=a;this._cacheContext=new cc.CanvasContextWrapper(this._cacheCanvas.getContext("2d"));c=new cc.Texture2D;c.initWithElement(a);c.handleLoadedTexture();this._cacheTexture=c;this._cacheDirty=!1};var a=cc.TMXLayer.CanvasRenderCmd.prototype=
Object.create(cc.SpriteBatchNode.CanvasRenderCmd.prototype);a.constructor=cc.TMXLayer.CanvasRenderCmd;a._setNodeDirtyForCache=function(){this._cacheDirty=!0};a._renderingChildToCache=function(){if(this._cacheDirty){var a=this._cacheContext,c=a.getContext(),d=this._cacheCanvas;c.setTransform(1,0,0,1,0,0);c.clearRect(0,0,d.width,d.height);for(var c=this._node._children,d=0,e=c.length;e>d;d++)if(c[d]){var f=c[d]._renderCmd;f&&(f.rendering(a,1,1),f._cacheDirty=!1)}this._cacheDirty=!1}};a.rendering=function(a,
c,d){var e=this._displayedOpacity/255;if(!(0>=e)){var f=this._node;this._renderingChildToCache();var g=a||cc._renderContext;a=g.getContext();g.setGlobalAlpha(e);if((e=this._cacheCanvas)&&0!==e.width&&0!==e.height)g.setTransform(this._realWorldTransform,c,d),g=e.height*d,f.layerOrientation===cc.TMX_ORIENTATION_HEX?a.drawImage(e,0,0,e.width,e.height,0,-g+0.5*f._mapTileSize.height*d,e.width*c,g):a.drawImage(e,0,0,e.width,e.height,0,-g,e.width*c,g);cc.g_NumberOfDraws++}};a._updateCacheContext=function(a,
c){var d=this._node,e=d._contentSize,f=this._cacheCanvas,g=cc.contentScaleFactor();f.width=0|1.5*e.width*g;f.height=0|1.5*e.height*g;d.layerOrientation===cc.TMX_ORIENTATION_HEX?this._cacheContext.setOffset(0,0.5*-d._mapTileSize.height):this._cacheContext.setOffset(0,0);d=this._cacheTexture._contentSize;d.width=f.width;d.height=f.height};a.getTexture=function(){return this._cacheTexture};a.visit=function(a){var c,d;c=this._node;var e=c._children;if(c._visible&&e&&0!==e.length){if(a=a||this.getParentRenderCmd(),
a&&(this._curLevel=a._curLevel+1),this._syncStatus(a),this._cacheDirty){a=this._cacheContext;var f=this._cacheCanvas,g=a.getContext(),h=c.__instanceId,k=cc.renderer;k._turnToCacheMode(h);c.sortAllChildren();c=0;for(d=e.length;d>c;c++)if(e[c]){var m=e[c]._renderCmd;m&&(m.visit(this),m._cacheDirty=!1)}g.setTransform(1,0,0,1,0,0);g.clearRect(0,0,f.width,f.height);k._renderingToCacheCanvas(a,h);this._cacheDirty=!1}cc.renderer.pushRenderCommand(this);this._dirtyFlag=0}};a.transform=function(a,c){var d=
this.getNodeToParentTransform(),e=this._realWorldTransform;if(a){var f=a._worldTransform;e.a=d.a*f.a+d.b*f.c;e.b=d.a*f.b+d.b*f.d;e.c=d.c*f.a+d.d*f.c;e.d=d.c*f.b+d.d*f.d;e.tx=f.a*d.tx+f.c*d.ty+f.tx;e.ty=f.d*d.ty+f.ty+f.b*d.tx}else e.a=d.a,e.b=d.b,e.c=d.c,e.d=d.d,e.tx=d.tx,e.ty=d.ty;if(c&&(d=this._node._children)&&0!==d.length){e=0;for(f=d.length;f>e;e++)d[e]._renderCmd.transform(this,c)}};a.initImageSize=function(){this._node.tileset.imageSize=this._originalTexture.getContentSizeInPixels()};a._reusedTileWithRect=
function(a){var c=this._node;return c._reusedTile=new cc.Sprite,c._reusedTile.initWithTexture(c._renderCmd._texture,a,!1),c._reusedTile.batchNode=c,c._reusedTile.parent=c,c._reusedTile._renderCmd._cachedParent=c._renderCmd,c._reusedTile}})();
!function(){cc.TMXLayer.WebGLRenderCmd=function(a){cc.SpriteBatchNode.WebGLRenderCmd.call(this,a);this._needDraw=!0};var a=cc.TMXLayer.WebGLRenderCmd.prototype=Object.create(cc.SpriteBatchNode.WebGLRenderCmd.prototype);a.constructor=cc.TMXLayer.WebGLRenderCmd;a._updateCacheContext=function(){};a.initImageSize=function(){this._node.tileset.imageSize=this._textureAtlas.texture.getContentSizeInPixels();this._textureAtlas.texture.setAliasTexParameters()};a._reusedTileWithRect=function(a){var c=this._node;
return c._reusedTile?(c._reusedTile.batchNode=null,c._reusedTile.setTextureRect(a,!1),c._reusedTile.batchNode=c):(c._reusedTile=new cc.Sprite,c._reusedTile.initWithTexture(c.texture,a,!1),c._reusedTile.batchNode=c),c._reusedTile}}();
cc.PointObject=cc.Class.extend({_ratio:null,_offset:null,_child:null,ctor:function(a,b){this.initWithCCPoint(a,b)},getRatio:function(){return this._ratio},setRatio:function(a){this._ratio=a},getOffset:function(){return this._offset},setOffset:function(a){this._offset=a},getChild:function(){return this._child},setChild:function(a){this._child=a},initWithCCPoint:function(a,b){return this._ratio=a,this._offset=b,this._child=null,!0}});cc.PointObject.create=function(a,b){return new cc.PointObject(a,b)};
cc.ParallaxNode=cc.Node.extend({parallaxArray:null,_lastPosition:null,_className:"ParallaxNode",getParallaxArray:function(){return this.parallaxArray},setParallaxArray:function(a){this.parallaxArray=a},ctor:function(){cc.Node.prototype.ctor.call(this);this.parallaxArray=[];this._lastPosition=cc.p(-100,-100)},addChild:function(a,b,c,d){if(3===arguments.length)return void cc.log("ParallaxNode: use addChild(child, z, ratio, offset) instead");if(!a)throw"cc.ParallaxNode.addChild(): child should be non-null";
var e=new cc.PointObject(c,d);e.setChild(a);this.parallaxArray.push(e);a.setPosition(this._position.x*c.x+d.x,this._position.y*c.y+d.y);cc.Node.prototype.addChild.call(this,a,b,a.tag)},removeChild:function(a,b){for(var c=this.parallaxArray,d=0;d<c.length;d++)if(c[d].getChild()===a){c.splice(d,1);break}cc.Node.prototype.removeChild.call(this,a,b)},removeAllChildren:function(a){this.parallaxArray.length=0;cc.Node.prototype.removeAllChildren.call(this,a)},_updateParallaxPosition:function(){var a=this._absolutePosition();
if(!cc.pointEqualToPoint(a,this._lastPosition)){for(var b=this.parallaxArray,c=0,d=b.length;d>c;c++){var e=b[c];e.getChild().setPosition(-a.x+a.x*e.getRatio().x+e.getOffset().x,-a.y+a.y*e.getRatio().y+e.getOffset().y)}this._lastPosition=a}},_absolutePosition:function(){for(var a=this._position,b=this;null!==b.parent;)b=b.parent,a=cc.pAdd(a,b.getPosition());return a},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.ParallaxNode.CanvasRenderCmd(this):new cc.ParallaxNode.WebGLRenderCmd(this)}});
cc.ParallaxNode.create=function(){return new cc.ParallaxNode};
(function(){cc.ParallaxNode.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._needDraw=!1};var a=cc.ParallaxNode.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.ParallaxNode.CanvasRenderCmd;a.updateStatus=function(){this._node._updateParallaxPosition();cc.Node.CanvasRenderCmd.prototype.updateStatus.call(this)};a._syncStatus=function(a){this._node._updateParallaxPosition();cc.Node.CanvasRenderCmd.prototype._syncStatus.call(this,a)}})();
(function(){if(cc._renderType===cc._RENDER_TYPE_WEBGL){cc.ParallaxNode.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._needDraw=!1};var a=cc.ParallaxNode.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.ParallaxNode.WebGLRenderCmd;a.updateStatus=function(){this._node._updateParallaxPosition();cc.Node.WebGLRenderCmd.prototype.updateStatus.call(this)};a._syncStatus=function(a){this._node._updateParallaxPosition();cc.Node.WebGLRenderCmd.prototype._syncStatus.call(this,
a)}}})();cc.CONTROL_EVENT_TOTAL_NUMBER=9;cc.CONTROL_EVENT_TOUCH_DOWN=1;cc.CONTROL_EVENT_TOUCH_DRAG_INSIDE=2;cc.CONTROL_EVENT_TOUCH_DRAG_OUTSIDE=4;cc.CONTROL_EVENT_TOUCH_DRAG_ENTER=8;cc.CONTROL_EVENT_TOUCH_DRAG_EXIT=16;cc.CONTROL_EVENT_TOUCH_UP_INSIDE=32;cc.CONTROL_EVENT_TOUCH_UP_OUTSIDE=64;cc.CONTROL_EVENT_TOUCH_CANCEL=128;cc.CONTROL_EVENT_VALUECHANGED=256;cc.CONTROL_STATE_NORMAL=1;cc.CONTROL_STATE_HIGHLIGHTED=2;cc.CONTROL_STATE_DISABLED=4;cc.CONTROL_STATE_SELECTED=8;cc.CONTROL_STATE_INITIAL=8;
cc.Control=cc.Layer.extend({_isOpacityModifyRGB:!1,_hasVisibleParents:!1,_touchListener:null,_className:"Control",isOpacityModifyRGB:function(){return this._isOpacityModifyRGB},setOpacityModifyRGB:function(a){this._isOpacityModifyRGB=a;for(var b=this.getChildren(),c=0,d=b.length;d>c;c++){var e=b[c];e&&e.setOpacityModifyRGB(a)}},_state:cc.CONTROL_STATE_NORMAL,getState:function(){return this._state},_enabled:!1,_selected:!1,_highlighted:!1,_dispatchTable:null,setEnabled:function(a){this._state=(this._enabled=
a)?cc.CONTROL_STATE_NORMAL:cc.CONTROL_STATE_DISABLED;this.needsLayout()},isEnabled:function(){return this._enabled},setSelected:function(a){this._selected=a;this.needsLayout()},isSelected:function(){return this._selected},setHighlighted:function(a){this._highlighted=a;this.needsLayout()},isHighlighted:function(){return this._highlighted},hasVisibleParents:function(){for(var a=this.getParent();null!=a;a=a.getParent())if(!a.isVisible())return!1;return!0},ctor:function(){cc.Layer.prototype.ctor.call(this);
this._dispatchTable={};this._color=cc.color.WHITE},init:function(){if(cc.Layer.prototype.init.call(this)){this._state=cc.CONTROL_STATE_NORMAL;this._enabled=!0;this._highlighted=this._selected=!1;var a=cc.EventListener.create({event:cc.EventListener.TOUCH_ONE_BY_ONE,swallowTouches:!0});return this.onTouchBegan&&(a.onTouchBegan=this.onTouchBegan.bind(this)),this.onTouchMoved&&(a.onTouchMoved=this.onTouchMoved.bind(this)),this.onTouchEnded&&(a.onTouchEnded=this.onTouchEnded.bind(this)),this.onTouchCancelled&&
(a.onTouchCancelled=this.onTouchCancelled.bind(this)),this._touchListener=a,!0}return!1},onEnter:function(){var a=this._touchListener;a._isRegistered()||cc.eventManager.addListener(a,this);cc.Node.prototype.onEnter.call(this)},sendActionsForControlEvents:function(a){for(var b=0,c=cc.CONTROL_EVENT_TOTAL_NUMBER;c>b;b++)if(a&1<<b)for(var d=this._dispatchListforControlEvent(1<<b),e=0,f=d.length;f>e;e++)d[e].invoke(this)},addTargetWithActionForControlEvents:function(a,b,c){for(var d=0,e=cc.CONTROL_EVENT_TOTAL_NUMBER;e>
d;d++)c&1<<d&&this._addTargetWithActionForControlEvent(a,b,1<<d)},removeTargetWithActionForControlEvents:function(a,b,c){for(var d=0,e=cc.CONTROL_EVENT_TOTAL_NUMBER;e>d;d++)c&1<<d&&this._removeTargetWithActionForControlEvent(a,b,1<<d)},getTouchLocation:function(a){a=a.getLocation();return this.convertToNodeSpace(a)},isTouchInside:function(a){a=a.getLocation();return a=this.getParent().convertToNodeSpace(a),cc.rectContainsPoint(this.getBoundingBox(),a)},_invocationWithTargetAndActionForControlEvent:function(a,
b,c){return null},_dispatchListforControlEvent:function(a){return a=a.toString(),this._dispatchTable[a]||(this._dispatchTable[a]=[]),this._dispatchTable[a]},_addTargetWithActionForControlEvent:function(a,b,c){a=new cc.Invocation(a,b,c);this._dispatchListforControlEvent(c).push(a)},_removeTargetWithActionForControlEvent:function(a,b,c){c=this._dispatchListforControlEvent(c);if(a||b)for(var d=0;d<c.length;){var e=c[d],f=!0;a&&(f=a===e.getTarget());b&&(f=f&&b===e.getAction());f?cc.arrayRemoveObject(c,
e):d++}else c.length=0},needsLayout:function(){}});_p=cc.Control.prototype;_p.state;cc.defineGetterSetter(_p,"state",_p.getState);_p.enabled;cc.defineGetterSetter(_p,"enabled",_p.isEnabled,_p.setEnabled);_p.selected;cc.defineGetterSetter(_p,"selected",_p.isSelected,_p.setSelected);_p.highlighted;cc.defineGetterSetter(_p,"highlighted",_p.isHighlighted,_p.setHighlighted);_p=null;cc.Control.create=function(){var a=new cc.Control;return a&&a.init()?a:null};cc.CONTROL_ZOOM_ACTION_TAG=3435855873;
cc.ControlButton=cc.Control.extend({_doesAdjustBackgroundImage:!1,zoomOnTouchDown:!1,_preferredSize:null,_labelAnchorPoint:null,_currentTitle:null,_currentTitleColor:null,_titleLabel:null,_backgroundSprite:null,_opacity:0,_isPushed:!1,_titleDispatchTable:null,_titleColorDispatchTable:null,_titleLabelDispatchTable:null,_backgroundSpriteDispatchTable:null,_parentInited:!1,_marginV:0,_marginH:0,_className:"ControlButton",ctor:function(a,b,c){cc.Control.prototype.ctor.call(this);this._preferredSize=cc.size(0,
0);this._labelAnchorPoint=cc.p(0,0);this._currentTitle="";this._currentTitleColor=cc.color.WHITE;this._titleDispatchTable={};this._titleColorDispatchTable={};this._titleLabelDispatchTable={};this._backgroundSpriteDispatchTable={};void 0!=c?this.initWithTitleAndFontNameAndFontSize(a,b,c):void 0!=b?this.initWithLabelAndBackgroundSprite(a,b):void 0!=a?this.initWithBackgroundSprite(a):this.init()},init:function(){return this.initWithLabelAndBackgroundSprite(new cc.LabelTTF("","Arial",12),new cc.Scale9Sprite)},
needsLayout:function(){if(this._parentInited){this._titleLabel&&this._titleLabel.setVisible(!1);this._backgroundSprite&&this._backgroundSprite.setVisible(!1);this.setLabelAnchorPoint(this._labelAnchorPoint);var a=this._state;this._currentTitle=this.getTitleForState(a);this._currentTitleColor=this.getTitleColorForState(a);var b=this._titleLabel=this.getTitleLabelForState(a);b&&b.setString&&b.setString(this._currentTitle);b&&b.setColor(this._currentTitleColor);var c=this.getContentSize();b&&b.setPosition(c.width/
2,c.height/2);(a=this._backgroundSprite=this.getBackgroundSpriteForState(a))&&a.setPosition(c.width/2,c.height/2);c=cc.size(0,0);if(b){var d=b.getBoundingBox();c.width=d.width;c.height=d.height}this._doesAdjustBackgroundImage?a&&a.setContentSize(c.width+2*this._marginH,c.height+2*this._marginV):a&&(d=a.getPreferredSize(),d=cc.size(d.width,d.height),0>=d.width&&(d.width=c.width),0>=d.height&&(d.height=c.height),a.setContentSize(d));c=b?b.getBoundingBox():cc.rect(0,0,0,0);d=a?a.getBoundingBox():cc.rect(0,
0,0,0);c=cc.rectUnion(c,d);this.setContentSize(c.width,c.height);c=this.getContentSize();b&&(b.setPosition(c.width/2,c.height/2),b.setVisible(!0));a&&(a.setPosition(c.width/2,c.height/2),a.setVisible(!0))}},initWithLabelAndBackgroundSprite:function(a,b){if(!a)throw"cc.ControlButton.initWithLabelAndBackgroundSprite(): label should be non-null";if(!b)throw"cc.ControlButton.initWithLabelAndBackgroundSprite(): backgroundSprite should be non-null";if(cc.Control.prototype.init.call(this,!0)){this._parentInited=
!0;this._titleDispatchTable={};this._titleColorDispatchTable={};this._titleLabelDispatchTable={};this._backgroundSpriteDispatchTable={};this._isPushed=!1;this.zoomOnTouchDown=!0;this._currentTitle=null;this.setAdjustBackgroundImage(!0);this.setPreferredSize(cc.size(0,0));this.zoomOnTouchDown=!0;this.ignoreAnchorPointForPosition(!1);this.setAnchorPoint(0.5,0.5);this._titleLabel=a;this._backgroundSprite=b;this.setOpacity(255);this.setOpacityModifyRGB(!0);var c=a.getString();return this.setTitleForState(c,
cc.CONTROL_STATE_NORMAL),this.setTitleColorForState(a.getColor(),cc.CONTROL_STATE_NORMAL),this.setTitleLabelForState(a,cc.CONTROL_STATE_NORMAL),this.setBackgroundSpriteForState(b,cc.CONTROL_STATE_NORMAL),this._state=cc.CONTROL_STATE_NORMAL,this._marginH=24,this._marginV=12,this._labelAnchorPoint=cc.p(0.5,0.5),this.setPreferredSize(cc.size(0,0)),this.needsLayout(),!0}return!1},initWithTitleAndFontNameAndFontSize:function(a,b,c){a=new cc.LabelTTF(a,b,c);return this.initWithLabelAndBackgroundSprite(a,
new cc.Scale9Sprite)},initWithBackgroundSprite:function(a){var b=new cc.LabelTTF("","Arial",30);return this.initWithLabelAndBackgroundSprite(b,a)},doesAdjustBackgroundImage:function(){return this._doesAdjustBackgroundImage},setAdjustBackgroundImage:function(a){this._doesAdjustBackgroundImage=a;this.needsLayout()},getZoomOnTouchDown:function(){return this.zoomOnTouchDown},setZoomOnTouchDown:function(a){return this.zoomOnTouchDown=a},getPreferredSize:function(){return this._preferredSize},setPreferredSize:function(a){if(0===
a.width&&0===a.height)this._doesAdjustBackgroundImage=!0;else{this._doesAdjustBackgroundImage=!1;var b=this._backgroundSpriteDispatchTable,c;for(c in b)b[c].setPreferredSize(a)}this._preferredSize=a;this.needsLayout()},getLabelAnchorPoint:function(){return this._labelAnchorPoint},setLabelAnchorPoint:function(a){this._labelAnchorPoint=a;this._titleLabel&&this._titleLabel.setAnchorPoint(a)},_getCurrentTitle:function(){return this._currentTitle},_getCurrentTitleColor:function(){return this._currentTitleColor},
getOpacity:function(){return this._opacity},setOpacity:function(a){cc.Control.prototype.setOpacity.call(this,a);var b=this._backgroundSpriteDispatchTable,c;for(c in b)b[c].setOpacity(a)},setColor:function(a){cc.Control.prototype.setColor.call(this,a);var b=this._backgroundSpriteDispatchTable,c;for(c in b)b[c].setColor(a)},getColor:function(){var a=this._realColor;return cc.color(a.r,a.g,a.b,a.a)},isPushed:function(){return this._isPushed},_getVerticalMargin:function(){return this._marginV},_getHorizontalOrigin:function(){return this._marginH},
setMargins:function(a,b){this._marginV=b;this._marginH=a;this.needsLayout()},setEnabled:function(a){cc.Control.prototype.setEnabled.call(this,a);this.needsLayout()},setSelected:function(a){cc.Control.prototype.setSelected.call(this,a);this.needsLayout()},setHighlighted:function(a){this._state=a?cc.CONTROL_STATE_HIGHLIGHTED:cc.CONTROL_STATE_NORMAL;cc.Control.prototype.setHighlighted.call(this,a);a=this.getActionByTag(cc.CONTROL_ZOOM_ACTION_TAG);if(a&&this.stopAction(a),this.zoomOnTouchDown)a=this.isHighlighted()&&
this.isEnabled()&&!this.isSelected()?1.1:1,a=cc.scaleTo(0.05,a),a.setTag(cc.CONTROL_ZOOM_ACTION_TAG),this.runAction(a)},onTouchBegan:function(a,b){return this.isTouchInside(a)&&this.isEnabled()&&this.isVisible()&&this.hasVisibleParents()?(this._isPushed=!0,this.setHighlighted(!0),this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_DOWN),!0):!1},onTouchMoved:function(a,b){if(!this._enabled||!this._isPushed||this._selected)return void(this._highlighted&&this.setHighlighted(!1));var c=this.isTouchInside(a);
c&&!this._highlighted?(this.setHighlighted(!0),this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_DRAG_ENTER)):c&&this._highlighted?this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_DRAG_INSIDE):!c&&this._highlighted?(this.setHighlighted(!1),this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_DRAG_EXIT)):c||this._highlighted||this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_DRAG_OUTSIDE)},onTouchEnded:function(a,b){this._isPushed=!1;this.setHighlighted(!1);this.sendActionsForControlEvents(this.isTouchInside(a)?
cc.CONTROL_EVENT_TOUCH_UP_INSIDE:cc.CONTROL_EVENT_TOUCH_UP_OUTSIDE)},onTouchCancelled:function(a,b){this._isPushed=!1;this.setHighlighted(!1);this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_CANCEL)},getTitleForState:function(a){var b=this._titleDispatchTable;return b?b[a]?b[a]:b[cc.CONTROL_STATE_NORMAL]:""},setTitleForState:function(a,b){this._titleDispatchTable[b]=a||"";this.getState()===b&&this.needsLayout()},getTitleColorForState:function(a){return(a=this._titleColorDispatchTable[a])?a:
(a=this._titleColorDispatchTable[cc.CONTROL_STATE_NORMAL],a?a:cc.color.WHITE)},setTitleColorForState:function(a,b){this._titleColorDispatchTable[b]=a;this.getState()===b&&this.needsLayout()},getTitleLabelForState:function(a){var b=this._titleLabelDispatchTable;return b[a]?b[a]:b[cc.CONTROL_STATE_NORMAL]},setTitleLabelForState:function(a,b){var c=this._titleLabelDispatchTable;if(c[b]){var d=c[b];d&&this.removeChild(d,!0)}c[b]=a;a.setVisible(!1);a.setAnchorPoint(0.5,0.5);this.addChild(a,1);this.getState()===
b&&this.needsLayout()},setTitleTTFForState:function(a,b){var c=this.getTitleForState(b);c||(c="");this.setTitleLabelForState(new cc.LabelTTF(c,a,12),b)},getTitleTTFForState:function(a){a=this.getTitleLabelForState(a);return null!=a&&a instanceof cc.LabelTTF?a.getFontName():""},setTitleTTFSizeForState:function(a,b){var c=this.getTitleLabelForState(b);null!=c&&c instanceof cc.LabelTTF&&c.setFontSize(a)},getTitleTTFSizeForState:function(a){a=this.getTitleLabelForState(a);return null!=a&&a instanceof
cc.LabelTTF?a.getFontSize():0},setTitleBMFontForState:function(a,b){var c=this.getTitleForState(b);c||(c="");this.setTitleLabelForState(new cc.LabelBMFont(c,a),b)},getTitleBMFontForState:function(a){a=this.getTitleLabelForState(a);return null!=a&&a instanceof cc.LabelBMFont?a.getFntFile():""},getBackgroundSpriteForState:function(a){var b=this._backgroundSpriteDispatchTable;return b[a]?b[a]:b[cc.CONTROL_STATE_NORMAL]},setBackgroundSpriteForState:function(a,b){var c=this._backgroundSpriteDispatchTable;
if(c[b]){var d=c[b];d&&this.removeChild(d,!0)}c[b]=a;a.setVisible(!1);a.setAnchorPoint(0.5,0.5);this.addChild(a);c=this._preferredSize;(0!==c.width||0!==c.height)&&a.setPreferredSize(c);this._state===b&&this.needsLayout()},setBackgroundSpriteFrameForState:function(a,b){var c=cc.Scale9Sprite.createWithSpriteFrame(a);this.setBackgroundSpriteForState(c,b)}});_p=cc.ControlButton.prototype;_p.adjustBackground;cc.defineGetterSetter(_p,"adjustBackground",_p.getAdjustBackgroundImage,_p.setAdjustBackgroundImage);
_p.preferredSize;cc.defineGetterSetter(_p,"preferredSize",_p.getPreferredSize,_p.setPreferredSize);_p.labelAnchor;cc.defineGetterSetter(_p,"labelAnchor",_p.getLabelAnchorPoint,_p.setLabelAnchorPoint);_p=null;cc.ControlButton.create=function(a,b,c){return new cc.ControlButton(a,b,c)};cc.RGBA=function(a,b,c,d){this.r=a;this.g=b;this.b=c;this.a=d};cc.HSV=function(a,b,c){this.h=a;this.s=b;this.v=c};cc.ControlUtils={};
cc.ControlUtils.addSpriteToTargetWithPosAndAnchor=function(a,b,c,d){return(a=new cc.Sprite("#"+a))?(a.setPosition(c),a.setAnchorPoint(d),b.addChild(a),a):null};cc.ControlUtils.HSVfromRGB=function(a){var b,c,d,e=new cc.HSV;return b=a.r<a.g?a.r:a.g,b=b<a.b?b:a.b,c=a.r>a.g?a.r:a.g,c=c>a.b?c:a.b,e.v=c,d=c-b,0<c?(e.s=d/c,a.r>=c?e.h=(a.g-a.b)/d:a.g>=c?e.h=2+(a.b-a.r)/d:e.h=4+(a.r-a.g)/d,e.h*=60,0>e.h&&(e.h+=360),e):(e.s=0,e.h=-1,e)};
cc.ControlUtils.RGBfromHSV=function(a){var b,c,d,e,f,g,h=new cc.RGBA;if(h.a=1,0>=a.s)return a.h?(h.r=0,h.g=0,h.b=0,h):(h.r=a.v,h.g=a.v,h.b=a.v,h);switch(b=a.h,360<=b&&(b=0),b/=60,g=0|b,f=b-g,c=a.v*(1-a.s),d=a.v*(1-a.s*f),e=a.v*(1-a.s*(1-f)),g){case 0:h.r=a.v;h.g=e;h.b=c;break;case 1:h.r=d;h.g=a.v;h.b=c;break;case 2:h.r=c;h.g=a.v;h.b=e;break;case 3:h.r=c;h.g=d;h.b=a.v;break;case 4:h.r=e;h.g=c;h.b=a.v;break;default:h.r=a.v,h.g=c,h.b=d}return h};
cc.ControlUtils.CCRectUnion=function(a,b){return cc.rectUnion(a,b)};
cc.Invocation=cc.Class.extend({_action:null,_target:null,_controlEvent:null,ctor:function(a,b,c){this._target=a;this._action=b;this._controlEvent=c},getAction:function(){return this._action},getTarget:function(){return this._target},getControlEvent:function(){return this._controlEvent},invoke:function(a){this._target&&this._action&&(cc.isString(this._action)?this._target[this._action](a,this._controlEvent):this._action.call(this._target,a,this._controlEvent))}});
cc.Scale9Sprite=cc.Node.extend({_spriteRect:null,_capInsetsInternal:null,_positionsAreDirty:!1,_scale9Image:null,_topLeft:null,_top:null,_topRight:null,_left:null,_centre:null,_right:null,_bottomLeft:null,_bottom:null,_bottomRight:null,_scale9Dirty:!0,_opacityModifyRGB:!1,_originalSize:null,_preferredSize:null,_opacity:0,_color:null,_capInsets:null,_insetLeft:0,_insetTop:0,_insetRight:0,_insetBottom:0,_spritesGenerated:!1,_spriteFrameRotated:!1,_textureLoaded:!1,_className:"Scale9Sprite",_flippedX:!1,
_flippedY:!1,textureLoaded:function(){return this._textureLoaded},addLoadedEventListener:function(a,b){this.addEventListener("load",a,b)},_updateCapInset:function(){var a;a=this._insetLeft;var b=this._insetTop,c=this._insetRight,d=this._spriteRect,e=this._insetBottom;a=0===a&&0===b&&0===c&&0===e?cc.rect(0,0,0,0):this._spriteFrameRotated?cc.rect(e,a,d.width-c-a,d.height-b-e):cc.rect(a,b,d.width-a-c,d.height-b-e);this.setCapInsets(a)},_updatePositions:function(){if(this._topLeft&&this._topRight&&this._bottomRight&&
this._bottomLeft&&this._centre){var a=this._contentSize,b=this._topLeft,c=this._topRight,d=this._bottomRight,e=this._bottomLeft,f=this._centre,g=this._centre.getContentSize(),h=b.getContentSize(),k=e.getContentSize(),m=a.width-h.width-c.getContentSize().width,a=a.height-h.height-d.getContentSize().height,m=m/g.width,a=a/g.height,h=g.width*m,n=g.height*a,p=k.width,k=k.height;if(cc._renderType===cc._RENDER_TYPE_WEBGL){var r=Math.round(h);h!==r&&(h=r,m=h/g.width);r=Math.round(n);n!==r&&(n=r,a=n/g.height)}f.setScaleX(m);
f.setScaleY(a);var g=this._left,r=this._right,s=this._top,v=this._bottom,u=cc.p(0,0);e.setAnchorPoint(u);d.setAnchorPoint(u);b.setAnchorPoint(u);c.setAnchorPoint(u);g.setAnchorPoint(u);r.setAnchorPoint(u);s.setAnchorPoint(u);v.setAnchorPoint(u);f.setAnchorPoint(u);e.setPosition(0,0);d.setPosition(p+h,0);b.setPosition(0,k+n);c.setPosition(p+h,k+n);g.setPosition(0,k);g.setScaleY(a);r.setPosition(p+h,k);r.setScaleY(a);v.setPosition(p,0);v.setScaleX(m);s.setPosition(p,k+n);s.setScaleX(m);f.setPosition(p,
k)}},ctor:function(a,b,c){if(cc.Node.prototype.ctor.call(this),this._spriteRect=cc.rect(0,0,0,0),this._capInsetsInternal=cc.rect(0,0,0,0),this._originalSize=cc.size(0,0),this._preferredSize=cc.size(0,0),this._capInsets=cc.rect(0,0,0,0),void 0!=a)if(a instanceof cc.SpriteFrame)this.initWithSpriteFrame(a,b);else{var d=cc.spriteFrameCache.getSpriteFrame(a);null!=d?this.initWithSpriteFrame(d,b):this.initWithFile(a,b,c)}else this.init()},getSprite:function(){return this._scale9Image},getOriginalSize:function(){return cc.size(this._originalSize)},
getPreferredSize:function(){return cc.size(this._preferredSize)},_getPreferredWidth:function(){return this._preferredSize.width},_getPreferredHeight:function(){return this._preferredSize.height},setPreferredSize:function(a){this.setContentSize(a);this._preferredSize=a;this._positionsAreDirty&&(this._updatePositions(),this._positionsAreDirty=!1,this._scale9Dirty=!0)},_setPreferredWidth:function(a){this._setWidth(a);this._preferredSize.width=a},_setPreferredHeight:function(a){this._setHeight(a);this._preferredSize.height=
a},setOpacity:function(a){if(this._scale9Image){cc.Node.prototype.setOpacity.call(this,a);for(var b=this._scale9Image.getChildren(),c=0;c<b.length;c++){var d=b[c];d&&d.setOpacity(a)}this._scale9Dirty=!0}},setColor:function(a){if(this._scale9Image){cc.Node.prototype.setColor.call(this,a);for(var b=this._scale9Image.getChildren(),c=0;c<b.length;c++){var d=b[c];d&&d.setColor(a)}this._scale9Dirty=!0}},getCapInsets:function(){return cc.rect(this._capInsets)},setCapInsets:function(a){if(this._scale9Image){var b=
this._contentSize,c=b.width,b=b.height;this.updateWithBatchNode(this._scale9Image,this._spriteRect,this._spriteFrameRotated,a);this.setContentSize(c,b)}},getInsetLeft:function(){return this._insetLeft},setInsetLeft:function(a){this._insetLeft=a;this._updateCapInset()},getInsetTop:function(){return this._insetTop},setInsetTop:function(a){this._insetTop=a;this._updateCapInset()},getInsetRight:function(){return this._insetRight},setInsetRight:function(a){this._insetRight=a;this._updateCapInset()},getInsetBottom:function(){return this._insetBottom},
setInsetBottom:function(a){this._insetBottom=a;this._updateCapInset()},setContentSize:function(a,b){cc.Node.prototype.setContentSize.call(this,a,b);this._positionsAreDirty=!0},_setWidth:function(a){cc.Node.prototype._setWidth.call(this,a);this._positionsAreDirty=!0},_setHeight:function(a){cc.Node.prototype._setHeight.call(this,a);this._positionsAreDirty=!0},init:function(){return this.initWithBatchNode(null,cc.rect(0,0,0,0),!1,cc.rect(0,0,0,0))},initWithBatchNode:function(a,b,c,d){return void 0===
d&&(d=c,c=!1),a&&this.updateWithBatchNode(a,b,c,d),this.setCascadeColorEnabled(!0),this.setCascadeOpacityEnabled(!0),this.setAnchorPoint(0.5,0.5),this._positionsAreDirty=!0,!0},initWithFile:function(a,b,c){if(a instanceof cc.Rect?(a=b,c=a,b=cc.rect(0,0,0,0)):(b=b||cc.rect(0,0,0,0),c=c||cc.rect(0,0,0,0)),!a)throw"cc.Scale9Sprite.initWithFile(): file should be non-null";var d=cc.textureCache.getTextureForKey(a);d||(d=cc.textureCache.addImage(a));var e=d.isLoaded();return this._textureLoaded=e,e||d.addEventListener("load",
function(a){var b=this._preferredSize,c=0!==b.width||0!==b.height;c&&(b=cc.size(b.width,b.height));a=a.getContentSize();this.updateWithBatchNode(this._scale9Image,cc.rect(0,0,a.width,a.height),!1,this._capInsets);c&&this.setPreferredSize(b);this._positionsAreDirty=!0;this.dispatchEvent("load")},this),this.initWithBatchNode(new cc.SpriteBatchNode(a,9),b,!1,c)},initWithSpriteFrame:function(a,b){if(!a||!a.getTexture())throw"cc.Scale9Sprite.initWithSpriteFrame(): spriteFrame should be non-null and its texture should be non-null";
b=b||cc.rect(0,0,0,0);var c=a.textureLoaded();(this._textureLoaded=c)||a.addEventListener("load",function(a){var b=this._preferredSize,c=0!==b.width||0!==b.height;c&&(b=cc.size(b.width,b.height));this.updateWithBatchNode(this._scale9Image,a.getRect(),cc._renderType===cc._RENDER_TYPE_WEBGL&&a.isRotated(),this._capInsets);c&&this.setPreferredSize(b);this._positionsAreDirty=!0;this.dispatchEvent("load")},this);c=new cc.SpriteBatchNode(a.getTexture(),9);return this.initWithBatchNode(c,a.getRect(),cc._renderType===
cc._RENDER_TYPE_WEBGL&&a.isRotated(),b)},initWithSpriteFrameName:function(a,b){if(!a)throw"cc.Scale9Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null";b=b||cc.rect(0,0,0,0);var c=cc.spriteFrameCache.getSpriteFrame(a);return null==c?(cc.log("cc.Scale9Sprite.initWithSpriteFrameName(): can't find the sprite frame by spriteFrameName"),!1):this.initWithSpriteFrame(c,b)},resizableSpriteWithCapInsets:function(a){var b=new cc.Scale9Sprite;return b&&b.initWithBatchNode(this._scale9Image,
this._spriteRect,!1,a)?b:null},setOpacityModifyRGB:function(a){if(this._scale9Image){this._opacityModifyRGB=a;var b=this._scale9Image.getChildren();if(b)for(var c=0,d=b.length;d>c;c++)b[c].setOpacityModifyRGB(a)}},isOpacityModifyRGB:function(){return this._opacityModifyRGB},updateWithBatchNode:function(a,b,c,d){var e=this.getOpacity(),f=this.getColor();b=cc.rect(b.x,b.y,b.width,b.height);if(this.removeAllChildren(!0),this._scale9Image!==a&&(this._scale9Image=a),!this._scale9Image)return!1;a=a.getTexture();
var g=a.isLoaded();this._textureLoaded=g;var h=this._capInsets;if(h.x=d.x,h.y=d.y,h.width=d.width,h.height=d.height,!g)return a.addEventListener("load",function(a){this._positionsAreDirty=!0;this.dispatchEvent("load")},this),!0;a=this._scale9Image;a.removeAllChildren(!0);this._spriteFrameRotated=c;g=a.getTexture();cc._rectEqualToZero(b)&&(b=g.getContentSize(),b=cc.rect(0,0,b.width,b.height));h=this._spriteRect=b;h.x=b.x;h.y=b.y;h.width=b.width;h.height=b.height;this._originalSize.width=b.width;this._originalSize.height=
b.height;h=this._preferredSize;0===h.width&&0===h.height&&(h.width=b.width,h.height=b.height);h=this._capInsetsInternal;d&&(h.x=d.x,h.y=d.y,h.width=d.width,h.height=d.height);var k=b.width;d=b.height;cc._rectEqualToZero(h)&&(h.x=k/3,h.y=d/3,h.width=k/3,h.height=d/3);var m=h.x,n=h.width,p=k-(m+n),r=h.y,s=h.height,v=d-(r+s),u=0,t=0;d=cc.rect(u+0.5|0,t+0.5|0,m+0.5|0,r+0.5|0);var u=u+m,h=cc.rect(u+0.5|0,t+0.5|0,n+0.5|0,r+0.5|0),k=cc.rect(u+n+0.5|0,t+0.5|0,p+0.5|0,r+0.5|0),u=0,t=0+r,x=cc.rect(u+0.5|0,
t+0.5|0,m+0.5|0,s+0.5|0),u=u+m,A=cc.rect(u+0.5|0,t+0.5|0,n+0.5|0,s+0.5|0),u=u+n,F=cc.rect(u+0.5|0,t+0.5|0,p+0.5|0,s+0.5|0),u=0,t=0+r+s,r=cc.rect(u+0.5|0,t+0.5|0,m+0.5|0,v+0.5|0),u=u+m,m=cc.rect(u+0.5|0,t+0.5|0,n+0.5|0,v+0.5|0),u=u+n,n=cc.rect(u+0.5|0,t+0.5|0,p+0.5|0,v+0.5|0),p=cc.affineTransformMakeIdentity();if(c){c=A;var v=n,u=r,t=k,s=d,z=F,w=x,B=m,E=h,p=cc.affineTransformTranslate(p,b.height+b.x,b.y),p=cc.affineTransformRotate(p,1.57079633),A=cc.rectApplyAffineTransform(A,p),n=cc.rectApplyAffineTransform(n,
p),r=cc.rectApplyAffineTransform(r,p),k=cc.rectApplyAffineTransform(k,p);d=cc.rectApplyAffineTransform(d,p);F=cc.rectApplyAffineTransform(F,p);x=cc.rectApplyAffineTransform(x,p);m=cc.rectApplyAffineTransform(m,p);h=cc.rectApplyAffineTransform(h,p);c.x=A.x;c.y=A.y;v.x=n.x;v.y=n.y;u.x=r.x;u.y=r.y;t.x=k.x;t.y=k.y;s.x=d.x;s.y=d.y;z.x=F.x;z.y=F.y;w.x=x.x;w.y=x.y;B.x=m.x;B.y=m.y;E.x=h.x;E.y=h.y;this._centre=new cc.Sprite;this._centre.initWithTexture(g,c,!0);a.addChild(this._centre,0,cc.Scale9Sprite.POSITIONS_CENTRE);
this._top=new cc.Sprite;this._top.initWithTexture(g,E,!0);a.addChild(this._top,1,cc.Scale9Sprite.POSITIONS_TOP);this._bottom=new cc.Sprite;this._bottom.initWithTexture(g,B,!0);a.addChild(this._bottom,1,cc.Scale9Sprite.POSITIONS_BOTTOM);this._left=new cc.Sprite;this._left.initWithTexture(g,w,!0);a.addChild(this._left,1,cc.Scale9Sprite.POSITIONS_LEFT);this._right=new cc.Sprite;this._right.initWithTexture(g,z,!0);a.addChild(this._right,1,cc.Scale9Sprite.POSITIONS_RIGHT);this._topLeft=new cc.Sprite;this._topLeft.initWithTexture(g,
s,!0);a.addChild(this._topLeft,2,cc.Scale9Sprite.POSITIONS_TOPLEFT);this._topRight=new cc.Sprite;this._topRight.initWithTexture(g,t,!0);a.addChild(this._topRight,2,cc.Scale9Sprite.POSITIONS_TOPRIGHT);this._bottomLeft=new cc.Sprite;this._bottomLeft.initWithTexture(g,u,!0);a.addChild(this._bottomLeft,2,cc.Scale9Sprite.POSITIONS_BOTTOMLEFT);this._bottomRight=new cc.Sprite;this._bottomRight.initWithTexture(g,v,!0)}else p=cc.affineTransformTranslate(p,b.x,b.y),cc._rectApplyAffineTransformIn(A,p),cc._rectApplyAffineTransformIn(n,
p),cc._rectApplyAffineTransformIn(r,p),cc._rectApplyAffineTransformIn(k,p),cc._rectApplyAffineTransformIn(d,p),cc._rectApplyAffineTransformIn(F,p),cc._rectApplyAffineTransformIn(x,p),cc._rectApplyAffineTransformIn(m,p),cc._rectApplyAffineTransformIn(h,p),this._centre=new cc.Sprite,this._centre.initWithTexture(g,A),a.addChild(this._centre,0,cc.Scale9Sprite.POSITIONS_CENTRE),this._top=new cc.Sprite,this._top.initWithTexture(g,h),a.addChild(this._top,1,cc.Scale9Sprite.POSITIONS_TOP),this._bottom=new cc.Sprite,
this._bottom.initWithTexture(g,m),a.addChild(this._bottom,1,cc.Scale9Sprite.POSITIONS_BOTTOM),this._left=new cc.Sprite,this._left.initWithTexture(g,x),a.addChild(this._left,1,cc.Scale9Sprite.POSITIONS_LEFT),this._right=new cc.Sprite,this._right.initWithTexture(g,F),a.addChild(this._right,1,cc.Scale9Sprite.POSITIONS_RIGHT),this._topLeft=new cc.Sprite,this._topLeft.initWithTexture(g,d),a.addChild(this._topLeft,2,cc.Scale9Sprite.POSITIONS_TOPLEFT),this._topRight=new cc.Sprite,this._topRight.initWithTexture(g,
k),a.addChild(this._topRight,2,cc.Scale9Sprite.POSITIONS_TOPRIGHT),this._bottomLeft=new cc.Sprite,this._bottomLeft.initWithTexture(g,r),a.addChild(this._bottomLeft,2,cc.Scale9Sprite.POSITIONS_BOTTOMLEFT),this._bottomRight=new cc.Sprite,this._bottomRight.initWithTexture(g,n);a.addChild(this._bottomRight,2,cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT);return this.setContentSize(b.width,b.height),cc._renderType===cc._RENDER_TYPE_WEBGL&&this.addChild(a),this._spritesGenerated&&(this.setOpacity(e),this.setColor(f)),
this._spritesGenerated=!0,!0},setSpriteFrame:function(a){var b=new cc.SpriteBatchNode(a.getTexture(),9),c=a.textureLoaded();(this._textureLoaded=c)||a.addEventListener("load",function(a){var b=this._preferredSize,c=0!==b.width||0!==b.height;c&&(b=cc.size(b.width,b.height));this.updateWithBatchNode(this._scale9Image,a.getRect(),cc._renderType===cc._RENDER_TYPE_WEBGL&&a.isRotated(),this._capInsets);c&&this.setPreferredSize(b);this._positionsAreDirty=!0;this.dispatchEvent("load")},this);this.updateWithBatchNode(b,
a.getRect(),cc._renderType===cc._RENDER_TYPE_WEBGL&&a.isRotated(),cc.rect(0,0,0,0));this._insetBottom=this._insetRight=this._insetTop=this._insetLeft=0},setState:function(a){this._renderCmd.setState(a)},setFlippedX:function(a){var b=this.getScaleX();this._flippedX=a;this.setScaleX(b)},isFlippedX:function(){return this._flippedX},setFlippedY:function(a){var b=this.getScaleY();this._flippedY=a;this.setScaleY(b)},isFlippedY:function(){return this._flippedY},setScaleX:function(a){this._flippedX&&(a*=
-1);cc.Node.prototype.setScaleX.call(this,a)},setScaleY:function(a){this._flippedY&&(a*=-1);cc.Node.prototype.setScaleY.call(this,a)},setScale:function(a,b){void 0===b&&(b=a);this.setScaleX(a);this.setScaleY(b)},getScaleX:function(){var a=cc.Node.prototype.getScaleX.call(this);return this._flippedX&&(a*=-1),a},getScaleY:function(){var a=cc.Node.prototype.getScaleY.call(this);return this._flippedY&&(a*=-1),a},getScale:function(){return this.getScaleX()!==this.getScaleY()&&cc.log("Scale9Sprite#scale. ScaleX !\x3d ScaleY. Don't know which one to return"),
this.getScaleX()},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.Scale9Sprite.CanvasRenderCmd(this):new cc.Scale9Sprite.WebGLRenderCmd(this)}});_p=cc.Scale9Sprite.prototype;cc.EventHelper.prototype.apply(_p);_p.preferredSize;cc.defineGetterSetter(_p,"preferredSize",_p.getPreferredSize,_p.setPreferredSize);_p.capInsets;cc.defineGetterSetter(_p,"capInsets",_p.getCapInsets,_p.setCapInsets);_p.insetLeft;cc.defineGetterSetter(_p,"insetLeft",_p.getInsetLeft,_p.setInsetLeft);
_p.insetTop;cc.defineGetterSetter(_p,"insetTop",_p.getInsetTop,_p.setInsetTop);_p.insetRight;cc.defineGetterSetter(_p,"insetRight",_p.getInsetRight,_p.setInsetRight);_p.insetBottom;cc.defineGetterSetter(_p,"insetBottom",_p.getInsetBottom,_p.setInsetBottom);_p=null;cc.Scale9Sprite.create=function(a,b,c){return new cc.Scale9Sprite(a,b,c)};cc.Scale9Sprite.createWithSpriteFrame=function(a,b){return new cc.Scale9Sprite(a,b)};
cc.Scale9Sprite.createWithSpriteFrameName=function(a,b){return new cc.Scale9Sprite(a,b)};cc.Scale9Sprite.POSITIONS_CENTRE=0;cc.Scale9Sprite.POSITIONS_TOP=1;cc.Scale9Sprite.POSITIONS_LEFT=2;cc.Scale9Sprite.POSITIONS_RIGHT=3;cc.Scale9Sprite.POSITIONS_BOTTOM=4;cc.Scale9Sprite.POSITIONS_TOPRIGHT=5;cc.Scale9Sprite.POSITIONS_TOPLEFT=6;cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT=7;cc.Scale9Sprite.state={NORMAL:0,GRAY:1};
(function(){cc.Scale9Sprite.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._cachedParent=null;this._cacheDirty=!1;this._state=cc.Scale9Sprite.state.NORMAL;a=this._node;var c=this._cacheCanvas=cc.newElement("canvas");c.width=1;c.height=1;this._cacheContext=new cc.CanvasContextWrapper(c.getContext("2d"));var d=this._cacheTexture=new cc.Texture2D;d.initWithElement(c);d.handleLoadedTexture();this._cacheSprite=new cc.Sprite(d);this._cacheSprite.setAnchorPoint(0,0);a.addChild(this._cacheSprite)};
var a=cc.Scale9Sprite.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.Scale9Sprite.CanvasRenderCmd;a.visit=function(a){var c=this._node;c._visible&&(c._positionsAreDirty&&(c._updatePositions(),c._positionsAreDirty=!1,c._scale9Dirty=!0),c._scale9Dirty=!1,this._cacheScale9Sprite(),cc.Node.CanvasRenderCmd.prototype.visit.call(this,a))};a.transform=function(a){var c=this._node;cc.Node.CanvasRenderCmd.prototype.transform.call(this,a);c._positionsAreDirty&&(c._updatePositions(),
c._positionsAreDirty=!1,c._scale9Dirty=!0);this._cacheScale9Sprite();a=c._children;for(c=0;c<a.length;c++)a[c].transform(this,!0)};a._updateDisplayColor=function(a){cc.Node.CanvasRenderCmd.prototype._updateDisplayColor.call(this,a);var c=this._node._scale9Image;if(c){for(var c=c.getChildren(),d=0;d<c.length;d++){var e=c[d];e&&(e._renderCmd._updateDisplayColor(a),e._renderCmd._updateColor())}this._cacheScale9Sprite()}};a._cacheScale9Sprite=function(){var a=this._node;if(a._scale9Image){var c=cc.contentScaleFactor(),
d=a._contentSize,e=cc.size(d.width*c,d.height*c),f=this._cacheCanvas,g=this._cacheContext,h=g.getContext(),k=!1;(f.width!==e.width||f.height!==e.height)&&(f.width=e.width,f.height=e.height,k=!0);cc.renderer._turnToCacheMode(a.__instanceId);a._scale9Image.visit();(f=a._scale9Image.getTexture())&&this._state===cc.Scale9Sprite.state.GRAY&&f._switchToGray(!0);h.setTransform(1,0,0,1,0,0);h.clearRect(0,0,e.width,e.height);cc.renderer._renderingToCacheCanvas(g,a.__instanceId,c,c);f&&this._state===cc.Scale9Sprite.state.GRAY&&
f._switchToGray(!1);k&&this._cacheSprite.setTextureRect(cc.rect(0,0,d.width,d.height));this._cacheSprite.getParent()||a.addChild(this._cacheSprite,-1)}};a.setState=function(a){this._node._scale9Image&&(this._state=a,this._cacheScale9Sprite())}})();cc.Spacer=cc.Layer.extend({});cc.Spacer.verticalSpacer=function(a){var b=new cc.Spacer;return b.init(),b.setContentSize(0,a),b};cc.Spacer.horizontalSpacer=function(a){var b=new cc.Spacer;return b.init(),b.setContentSize(a,0),b};
cc.MenuPassive=cc.Layer.extend({_color:null,_opacity:0,_className:"MenuPassive",ctor:function(){},getColor:function(){var a=this._color;return cc.color(a.r,a.g,a.b,a.a)},setColor:function(a){var b=this._color;if(b.r=a.r,b.g=a.g,b.b=a.b,this._children&&0<this._children.length)for(b=0;b<this._children.length;b++)this._children[b]&&this._children[b].setColor(a);void 0===a.a||a.a_undefined||this.setOpacity(a.a)},getOpacity:function(){return this._opacity},setOpacity:function(a){if(this._opacity=a,this._children&&
0<this._children.length)for(var b=0;b<this._children.length;b++)this._children[b]&&this._children[b].setOpacity(a);this._color.a=a},initWithItems:function(a,b){if(this.init()){var c=cc.director.getWinSize();this.ignoreAnchorPointForPosition(!0);this.setAnchorPoint(0.5,0.5);this.setContentSize(c);this.setPosition(c.width/2,c.height/2);c=0;if(a){this.addChild(a,c);for(var d=0;d<b.length;d++)b[d]&&(c++,this.addChild(b[d],c))}return!0}return!1},alignItemsVertically:function(){this.alignItemsVerticallyWithPadding(cc.DEFAULT_PADDING)},
alignItemsVerticallyWithPadding:function(a){var b,c=-a;if(this._children&&0<this._children.length)for(b=0;b<this._children.length;b++)this._children[b]&&(c+=this._children[b].getContentSize().height*this._children[b].getScaleY()+a);var d=0,e=c/2;if(this._children&&0<this._children.length)for(b=0;b<this._children.length;b++)this._children[b]&&(d=Math.max(d,this._children[b].getContentSize().width),this._children[b].setPosition(0,e-this._children[b].getContentSize().height*this._children[b].getScaleY()/
2),e-=this._children[b].getContentSize().height*this._children[b].getScaleY()+a);this.setContentSize(d,c)},alignItemsHorizontally:function(){this.alignItemsHorizontallyWithPadding(cc.DEFAULT_PADDING)},alignItemsHorizontallyWithPadding:function(a){var b,c=-a;if(this._children&&0<this._children.length)for(b=0;b<this._children.length;b++)this._children[b]&&(c+=this._children[b].getContentSize().width*this._children[b].getScaleX()+a);var d=0,e=-c/2;if(this._children&&0<this._children.length)for(b=0;b<
this._children.length;b++)this._children[b]&&(d=Math.max(d,this._children[b].getContentSize().height),this._children[b].setPosition(e+this._children[b].getContentSize().width*this._children[b].getScaleX()/2,0),e+=this._children[b].getContentSize().width*this._children[b].getScaleX()+a);this.setContentSize(c,d)},alignItemsInColumns:function(a){var b,c=[];for(b=1;b<arguments.length;b++)c.push(arguments[b]);var d,e,f=-5,g=0,h=0,k=0;if(this._children&&0<this._children.length)for(b=0;b<this._children.length;b++)this._children[b]&&
(g>=c.length?cc.log("cc.MenuPassive.alignItemsInColumns(): invalid row index"):(d=c[g],!d)?cc.log("cc.MenuPassive.alignItemsInColumns(): can not have zero columns on a row"):(e=this._children[b].getContentSize().height,h=0|(h>=e||null==e?h:e),++k,k>=d&&(f+=h+5,k=0,h=0,++g)));var m=cc.director.getWinSize(),n=d=h=g=0,p=0,f=f/2;if(this._children&&0<this._children.length)for(b=0;b<this._children.length;b++)this._children[b]&&(0===d&&(d=c[g],n=m.width/(1+d),p=n),e=this._children[b].getContentSize().height,
h=0|(h>=e||null==e?h:e),this._children[b].setPosition(p-m.width/2,f-this._children[b].getContentSize().height/2),p+=n,++k,k>=d&&(f-=h+5,k=0,d=0,h=0,++g))},alignItemsInRows:function(a){var b,c=[];for(b=1;b<arguments.length;b++)c.push(arguments[b]);var d,e,f=[],g=[],h=-10,k=-5,m=0,n=0,p=0;if(this._children&&0<this._children.length)for(b=0;b<this._children.length;b++)this._children[b]&&(m>=c.length?cc.log("cc.MenuPassive.alignItemsInRows(): invalid row index"):(d=c[m],!d)?cc.log("cc.MenuPassive.alignItemsInColumns(): can't have zero rows on a column"):
(e=this._children[b].getContentSize().width,n=0|(n>=e||null==e?n:e),k+=0|this._children[b].getContentSize().height+5,++p,p>=d&&(f.push(n),g.push(k),h+=n+10,p=0,n=0,k=-5,++m)));k=cc.director.getWinSize();n=m=0;d=null;var h=-h/2,r=0;if(this._children&&0<this._children.length)for(b=0;b<this._children.length;b++)this._children[b]&&(null==d&&(d=c[m],r=g[m]),e=this._children[b].getContentSize().width,n=0|(n>=e||null==e?n:e),this._children[b].setPosition(h+f[m]/2,r-k.height/2),r-=this._children[b].getContentSize().height+
10,++p,p>=d&&(h+=n+5,p=0,d=0,n=0,++m))},setOpacityModifyRGB:function(a){},isOpacityModifyRGB:function(){return!1}});cc.MenuPassive.create=function(a){a||(a=null);for(var b=[],c=1;c<arguments.length;c++)b.push(arguments[c]);return(c=new cc.MenuPassive)&&c.initWithItems(a,b)?c:null};cc.MenuPassive.createWithItem=function(a){return cc.MenuPassive.create(a,null)};
cc.ControlSaturationBrightnessPicker=cc.Control.extend({_saturation:0,_brightness:0,_background:null,_overlay:null,_shadow:null,_slider:null,_startPos:null,_boxPos:0,_boxSize:0,_className:"ControlSaturationBrightnessPicker",ctor:function(a,b){cc.Control.prototype.ctor.call(this);b&&this.initWithTargetAndPos(a,b)},getSaturation:function(){return this._saturation},getBrightness:function(){return this._brightness},getBackground:function(){return this._background},getOverlay:function(){return this._brightness},
getShadow:function(){return this._shadow},getSlider:function(){return this._slider},getStartPos:function(){return this._startPos},initWithTargetAndPos:function(a,b){return cc.Control.prototype.init.call(this)?(this._background=cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("colourPickerBackground.png",a,b,cc.p(0,0)),this._overlay=cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("colourPickerOverlay.png",a,b,cc.p(0,0)),this._shadow=cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("colourPickerShadow.png",
a,b,cc.p(0,0)),this._slider=cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("colourPicker.png",a,b,cc.p(0.5,0.5)),this._startPos=b,this._boxPos=35,this._boxSize=this._background.getContentSize().width/2,!0):!1},setEnabled:function(a){cc.Control.prototype.setEnabled.call(this,a);this._slider&&this._slider.setOpacity(a?255:128)},updateWithHSV:function(a){var b=new cc.HSV;b.s=1;b.h=a.h;b.v=1;a=cc.ControlUtils.RGBfromHSV(b);this._background.setColor(cc.color(0|255*a.r,0|255*a.g,0|255*a.b))},updateDraggerWithHSV:function(a){a=
cc.p(this._startPos.x+this._boxPos+this._boxSize*(1-a.s),this._startPos.y+this._boxPos+this._boxSize*a.v);this._updateSliderPosition(a)},_updateSliderPosition:function(a){var b=this._startPos.x+0.5*this._background.getBoundingBox().width,c=this._startPos.y+0.5*this._background.getBoundingBox().height,d=a.x-b,e=a.y-c,f=Math.sqrt(d*d+e*e),d=Math.atan2(e,d),e=0.5*this._background.getBoundingBox().width;f>e&&(a.x=b+e*Math.cos(d),a.y=c+e*Math.sin(d));this._slider.setPosition(a);a.x<this._startPos.x+this._boxPos?
a.x=this._startPos.x+this._boxPos:a.x>this._startPos.x+this._boxPos+this._boxSize-1&&(a.x=this._startPos.x+this._boxPos+this._boxSize-1);a.y<this._startPos.y+this._boxPos?a.y=this._startPos.y+this._boxPos:a.y>this._startPos.y+this._boxPos+this._boxSize&&(a.y=this._startPos.y+this._boxPos+this._boxSize);this._saturation=1-Math.abs((this._startPos.x+this._boxPos-a.x)/this._boxSize);this._brightness=Math.abs((this._startPos.y+this._boxPos-a.y)/this._boxSize)},_checkSliderPosition:function(a){var b=this._startPos.x+
0.5*this._background.getBoundingBox().width,c=this._startPos.y+0.5*this._background.getBoundingBox().height,b=a.x-b,c=a.y-c;return Math.sqrt(b*b+c*c)<=0.5*this._background.getBoundingBox().width?(this._updateSliderPosition(a),this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED),!0):!1},onTouchBegan:function(a,b){if(!this.isEnabled()||!this.isVisible())return!1;var c=this.getTouchLocation(a);return this._checkSliderPosition(c)},onTouchMoved:function(a,b){var c=this.getTouchLocation(a);this._checkSliderPosition(c)}});
_p=cc.ControlSaturationBrightnessPicker.prototype;_p.saturation;cc.defineGetterSetter(_p,"saturation",_p.getSaturation);_p.brightness;cc.defineGetterSetter(_p,"brightness",_p.getBrightness);_p.background;cc.defineGetterSetter(_p,"background",_p.getBackground);_p.overlay;cc.defineGetterSetter(_p,"overlay",_p.getOverlay);_p.shadow;cc.defineGetterSetter(_p,"shadow",_p.getShadow);_p.slider;cc.defineGetterSetter(_p,"slider",_p.getSlider);_p.startPos;cc.defineGetterSetter(_p,"startPos",_p.getStartPos);
_p=null;cc.ControlSaturationBrightnessPicker.create=function(a,b){return new cc.ControlSaturationBrightnessPicker(a,b)};
cc.ControlHuePicker=cc.Control.extend({_hue:0,_huePercentage:0,_background:null,_slider:null,_startPos:null,_className:"ControlHuePicker",ctor:function(a,b){cc.Control.prototype.ctor.call(this);b&&this.initWithTargetAndPos(a,b)},getHue:function(){return this._hue},setHue:function(a){this._hue=a;this.setHuePercentage(this._hue/360)},getHuePercentage:function(){return this._huePercentage},setHuePercentage:function(a){this._huePercentage=a;this._hue=360*this._huePercentage;var b=this._background.getBoundingBox(),
c=this._startPos.x+0.5*b.width;a=this._startPos.y+0.5*b.height;var b=0.5*b.width-15,d=cc.degreesToRadians(360*this._huePercentage-180),c=c+b*Math.cos(d);a+=b*Math.sin(d);this._slider.setPosition(c,a)},setEnabled:function(a){cc.Control.prototype.setEnabled.call(this,a);this._slider&&this._slider.setOpacity(a?255:128)},getBackground:function(){return this._background},getSlider:function(){return this._slider},getStartPos:function(){return this._startPos},initWithTargetAndPos:function(a,b){return cc.Control.prototype.init.call(this)?
(this._background=cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("huePickerBackground.png",a,b,cc.p(0,0)),this._slider=cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("colourPicker.png",a,b,cc.p(0.5,0.5)),this._slider.setPosition(b.x,b.y+0.5*this._background.getBoundingBox().height),this._startPos=b,this._hue=0,this._huePercentage=0,!0):!1},_updateSliderPosition:function(a){var b=this._background.getBoundingBox();a=Math.atan2(a.y-(this._startPos.y+0.5*b.height),a.x-(this._startPos.x+0.5*b.width));
a=cc.radiansToDegrees(a)+180;this.setHue(a);this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)},_checkSliderPosition:function(a){var b=Math.sqrt(Math.pow(a.x+10,2)+Math.pow(a.y,2));return 80>b&&59<b?(this._updateSliderPosition(a),!0):!1},onTouchBegan:function(a,b){if(!this.isEnabled()||!this.isVisible())return!1;var c=this.getTouchLocation(a);return this._checkSliderPosition(c)},onTouchMoved:function(a,b){var c=this.getTouchLocation(a);this._checkSliderPosition(c)}});_p=cc.ControlHuePicker.prototype;
_p.hue;cc.defineGetterSetter(_p,"hue",_p.getHue,_p.setHue);_p.huePercent;cc.defineGetterSetter(_p,"huePercent",_p.getHuePercentage,_p.setHuePercentage);_p.background;cc.defineGetterSetter(_p,"background",_p.getBackground);_p.slider;cc.defineGetterSetter(_p,"slider",_p.getSlider);_p.startPos;cc.defineGetterSetter(_p,"startPos",_p.getStartPos);_p=null;cc.ControlHuePicker.create=function(a,b){return new cc.ControlHuePicker(a,b)};
cc.ControlColourPicker=cc.Control.extend({_hsv:null,_colourPicker:null,_huePicker:null,_background:null,_className:"ControlColourPicker",ctor:function(){cc.Control.prototype.ctor.call(this);this.init()},hueSliderValueChanged:function(a,b){this._hsv.h=a.getHue();var c=cc.ControlUtils.RGBfromHSV(this._hsv);cc.Control.prototype.setColor.call(this,cc.color(0|255*c.r,0|255*c.g,0|255*c.b));this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED);this._updateControlPicker()},colourSliderValueChanged:function(a,
b){this._hsv.s=a.getSaturation();this._hsv.v=a.getBrightness();var c=cc.ControlUtils.RGBfromHSV(this._hsv);cc.Control.prototype.setColor.call(this,cc.color(0|255*c.r,0|255*c.g,0|255*c.b));this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)},setColor:function(a){cc.Control.prototype.setColor.call(this,a);var b=new cc.RGBA;b.r=a.r/255;b.g=a.g/255;b.b=a.b/255;b.a=1;this._hsv=cc.ControlUtils.HSVfromRGB(b);this._updateHueAndControlPicker()},getBackground:function(){return this._background},
init:function(){if(cc.Control.prototype.init.call(this)){cc.spriteFrameCache.addSpriteFrames(res.CCControlColourPickerSpriteSheet_plist);var a=new cc.SpriteBatchNode(res.CCControlColourPickerSpriteSheet_png);this.addChild(a);this._hsv=new cc.HSV(0,0,0);this._background=cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png",a,cc.p(0,0),cc.p(0.5,0.5));var b=cc.pSub(this._background.getPosition(),cc.p(this._background.getContentSize().width/2,this._background.getContentSize().height/
2));return this._huePicker=new cc.ControlHuePicker(a,cc.p(b.x+8,b.y+8)),this._colourPicker=new cc.ControlSaturationBrightnessPicker(a,cc.p(b.x+28,b.y+28)),this._huePicker.addTargetWithActionForControlEvents(this,this.hueSliderValueChanged,cc.CONTROL_EVENT_VALUECHANGED),this._colourPicker.addTargetWithActionForControlEvents(this,this.colourSliderValueChanged,cc.CONTROL_EVENT_VALUECHANGED),this._updateHueAndControlPicker(),this.addChild(this._huePicker),this.addChild(this._colourPicker),this.setContentSize(this._background.getContentSize()),
!0}return!1},_updateControlPicker:function(){this._huePicker.setHue(this._hsv.h);this._colourPicker.updateWithHSV(this._hsv)},_updateHueAndControlPicker:function(){this._huePicker.setHue(this._hsv.h);this._colourPicker.updateWithHSV(this._hsv);this._colourPicker.updateDraggerWithHSV(this._hsv)},setEnabled:function(a){cc.Control.prototype.setEnabled.call(this,a);null!==this._huePicker&&this._huePicker.setEnabled(a);this._colourPicker&&this._colourPicker.setEnabled(a)},onTouchBegan:function(){return!1}});
_p=cc.ControlColourPicker.prototype;_p.background;cc.defineGetterSetter(_p,"background",_p.getBackground);_p=null;cc.ControlColourPicker.create=function(){return new cc.ControlColourPicker};var res=res||{};res.CCControlColourPickerSpriteSheet_plist=res.CCControlColourPickerSpriteSheet_plist||"res/extensions/CCControlColourPickerSpriteSheet.plist";res.CCControlColourPickerSpriteSheet_png=res.CCControlColourPickerSpriteSheet_png||"res/extensions/CCControlColourPickerSpriteSheet.png";
cc.SLIDER_MARGIN_H=24;cc.SLIDER_MARGIN_V=8;
cc.ControlSlider=cc.Control.extend({_value:0,_minimumValue:0,_maximumValue:0,_minimumAllowedValue:0,_maximumAllowedValue:0,_thumbSprite:null,_progressSprite:null,_backgroundSprite:null,_className:"ControlSlider",ctor:function(a,b,c){if(cc.Control.prototype.ctor.call(this),void 0!=c)a=new cc.Sprite(a),b=new cc.Sprite(b),c=new cc.Sprite(c),this.initWithSprites(a,b,c)},getValue:function(){return this._value},setValue:function(a){a=Math.max(a,this._minimumValue);this._value=a=Math.min(a,this._maximumValue);
this.needsLayout();this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)},getMinimumValue:function(){return this._minimumValue},setMinimumValue:function(a){this._minimumAllowedValue=this._minimumValue=a;this._minimumValue>=this._maximumValue&&(this._maximumValue=this._minimumValue+1);this.setValue(this._value)},getMaximumValue:function(){return this._maximumValue},setMaximumValue:function(a){this._maximumAllowedValue=this._maximumValue=a;this._maximumValue<=this._minimumValue&&(this._minimumValue=
this._maximumValue-1);this.setValue(this._value)},isTouchInside:function(a){a=a.getLocation();a=this.getParent().convertToNodeSpace(a);var b=this.getBoundingBox();return b.width+=this._thumbSprite.getContentSize().width,b.x-=this._thumbSprite.getContentSize().width/2,cc.rectContainsPoint(b,a)},locationFromTouch:function(a){a=a.getLocation();return a=this.convertToNodeSpace(a),0>a.x?a.x=0:a.x>this._backgroundSprite.getContentSize().width&&(a.x=this._backgroundSprite.getContentSize().width),a},getMinimumAllowedValue:function(){return this._minimumAllowedValue},
setMinimumAllowedValue:function(a){this._minimumAllowedValue=a},getMaximumAllowedValue:function(){return this._maximumAllowedValue},setMaximumAllowedValue:function(a){this._maximumAllowedValue=a},getThumbSprite:function(){return this._thumbSprite},getProgressSprite:function(){return this._progressSprite},getBackgroundSprite:function(){return this._backgroundSprite},initWithSprites:function(a,b,c){return cc.Control.prototype.init.call(this)?(this.ignoreAnchorPointForPosition(!1),this._backgroundSprite=
a,this._progressSprite=b,this._thumbSprite=c,a=cc.ControlUtils.CCRectUnion(a.getBoundingBox(),c.getBoundingBox()),this.setContentSize(a.width,a.height),this._backgroundSprite.setAnchorPoint(0.5,0.5),this._backgroundSprite.setPosition(a.width/2,a.height/2),this.addChild(this._backgroundSprite),this._progressSprite.setAnchorPoint(0,0.5),this._progressSprite.setPosition(0,a.height/2),this.addChild(this._progressSprite),this._thumbSprite.setPosition(0,a.height/2),this.addChild(this._thumbSprite),this._minimumValue=
0,this._maximumValue=1,this.setValue(this._minimumValue),!0):!1},setEnabled:function(a){cc.Control.prototype.setEnabled.call(this,a);this._thumbSprite&&this._thumbSprite.setOpacity(a?255:128)},sliderBegan:function(a){this.setSelected(!0);this._thumbSprite.setColor(cc.color.GRAY);this.setValue(this.valueForLocation(a))},sliderMoved:function(a){this.setValue(this.valueForLocation(a))},sliderEnded:function(a){this.isSelected()&&this.setValue(this.valueForLocation(this._thumbSprite.getPosition()));this._thumbSprite.setColor(cc.color.WHITE);
this.setSelected(!1)},getTouchLocationInControl:function(a){a=a.getLocation();return a=this.convertToNodeSpace(a),0>a.x?a.x=0:a.x>this._backgroundSprite.getContentSize().width+cc.SLIDER_MARGIN_H&&(a.x=this._backgroundSprite.getContentSize().width+cc.SLIDER_MARGIN_H),a},onTouchBegan:function(a,b){if(!this.isTouchInside(a)||!this.isEnabled()||!this.isVisible())return!1;var c=this.locationFromTouch(a);return this.sliderBegan(c),!0},onTouchMoved:function(a,b){var c=this.locationFromTouch(a);this.sliderMoved(c)},
onTouchEnded:function(a,b){this.sliderEnded(cc.p(0,0))},needsLayout:function(){this._thumbSprite.setPositionX((this._value-this._minimumValue)/(this._maximumValue-this._minimumValue)*this._backgroundSprite.getContentSize().width);var a=this._progressSprite.getTextureRect(),a=cc.rect(a.x,a.y,this._thumbSprite.getPositionX(),a.height);this._progressSprite.setTextureRect(a,this._progressSprite.isTextureRectRotated());this._thumbSprite._renderCmd.transform(this._renderCmd)},valueForLocation:function(a){a=
a.x/this._backgroundSprite.getContentSize().width;return Math.max(Math.min(this._minimumValue+a*(this._maximumValue-this._minimumValue),this._maximumAllowedValue),this._minimumAllowedValue)}});_p=cc.ControlSlider.prototype;_p.value;cc.defineGetterSetter(_p,"value",_p.getValue,_p.setValue);_p.minValue;cc.defineGetterSetter(_p,"minValue",_p.getMinimumValue,_p.setMinimumValue);_p.maxValue;cc.defineGetterSetter(_p,"maxValue",_p.getMaximumValue,_p.setMaximumValue);_p.minAllowedValue;
cc.defineGetterSetter(_p,"minAllowedValue",_p.getMinimumAllowedValue,_p.setMinimumAllowedValue);_p.maxAllowedValue;cc.defineGetterSetter(_p,"maxAllowedValue",_p.getMaximumAllowedValue,_p.setMaximumAllowedValue);_p.thumbSprite;cc.defineGetterSetter(_p,"thumbSprite",_p.getThumbSprite);_p.progressSprite;cc.defineGetterSetter(_p,"progressSprite",_p.getProgressSprite);_p.backgroundSprite;cc.defineGetterSetter(_p,"backgroundSprite",_p.getBackgroundSprite);_p=null;
cc.ControlSlider.create=function(a,b,c){return new cc.ControlSlider(a,b,c)};
cc.ControlSwitch=cc.Control.extend({_switchSprite:null,_initialTouchXPosition:0,_moved:!1,_on:!1,_className:"ControlSwitch",ctor:function(a,b,c,d,e,f){cc.Control.prototype.ctor.call(this);f&&this.initWithMaskSprite(a,b,c,d,e,f)},initWithMaskSprite:function(a,b,c,d,e,f){if(!a)throw"cc.ControlSwitch.initWithMaskSprite(): maskSprite should be non-null.";if(!b)throw"cc.ControlSwitch.initWithMaskSprite(): onSprite should be non-null.";if(!c)throw"cc.ControlSwitch.initWithMaskSprite(): offSprite should be non-null.";
if(!d)throw"cc.ControlSwitch.initWithMaskSprite(): thumbSprite should be non-null.";return this.init()?(this._on=!0,this._switchSprite=new cc.ControlSwitchSprite,this._switchSprite.initWithMaskSprite(a,b,c,d,e,f),this._switchSprite.setPosition(this._switchSprite.getContentSize().width/2,this._switchSprite.getContentSize().height/2),this.addChild(this._switchSprite),this.ignoreAnchorPointForPosition(!1),this.setAnchorPoint(0.5,0.5),this.setContentSize(this._switchSprite.getContentSize()),!0):!1},setOn:function(a,
b){b=b||!1;var c=(this._on=a)?this._switchSprite.getOnPosition():this._switchSprite.getOffPosition();b?this._switchSprite.runAction(new cc.ActionTween(0.2,"sliderXPosition",this._switchSprite.getSliderXPosition(),c)):this._switchSprite.setSliderXPosition(c);this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)},isOn:function(){return this._on},hasMoved:function(){return this._moved},setEnabled:function(a){this._enabled=a;this._switchSprite.setOpacity(a?255:128)},locationFromTouch:function(a){a=
a.getLocation();return this.convertToNodeSpace(a)},onTouchBegan:function(a,b){if(!this.isTouchInside(a)||!this.isEnabled()||!this.isVisible())return!1;this._moved=!1;return this._initialTouchXPosition=this.locationFromTouch(a).x-this._switchSprite.getSliderXPosition(),this._switchSprite.getThumbSprite().setColor(cc.color.GRAY),this._switchSprite.needsLayout(),!0},onTouchMoved:function(a,b){var c=this.locationFromTouch(a),c=cc.p(c.x-this._initialTouchXPosition,0);this._moved=!0;this._switchSprite.setSliderXPosition(c.x)},
onTouchEnded:function(a,b){var c=this.locationFromTouch(a);this._switchSprite.getThumbSprite().setColor(cc.color.WHITE);this.hasMoved()?this.setOn(!(c.x<this._switchSprite.getContentSize().width/2),!0):this.setOn(!this._on,!0)},onTouchCancelled:function(a,b){var c=this.locationFromTouch(a);this._switchSprite.getThumbSprite().setColor(cc.color.WHITE);this.hasMoved()?this.setOn(!(c.x<this._switchSprite.getContentSize().width/2),!0):this.setOn(!this._on,!0)}});
cc.ControlSwitch.create=function(a,b,c,d,e,f){return new cc.ControlSwitch(a,b,c,d,e,f)};
cc.ControlSwitchSprite=cc.Sprite.extend({_sliderXPosition:0,_onPosition:0,_offPosition:0,_textureLocation:0,_maskLocation:0,_maskSize:null,_onSprite:null,_offSprite:null,_thumbSprite:null,_onLabel:null,_offLabel:null,_clipper:null,_stencil:null,_backRT:null,ctor:function(){cc.Sprite.prototype.ctor.call(this);this._maskLocation=this._offPosition=this._onPosition=this._sliderXPosition=0;this._maskSize=cc.size(0,0);this._offLabel=this._onLabel=this._thumbSprite=this._offSprite=this._onSprite=null},initWithMaskSprite:function(a,
b,c,d,e,f){return cc.Sprite.prototype.init.call(this)?(this.setSpriteFrame(a.displayFrame()),this._onPosition=0,this._offPosition=-b.getContentSize().width+d.getContentSize().width/2,this._sliderXPosition=this._onPosition,this.setOnSprite(b),this.setOffSprite(c),this.setThumbSprite(d),this.setOnLabel(e),this.setOffLabel(f),this._stencil=a,a=this._maskSize=this._stencil.getContentSize(),this._stencil.setPosition(0,0),this._clipper=new cc.ClippingNode,this._clipper.setAnchorPoint(0.5,0.5),this._clipper.setPosition(a.width/
2,a.height/2),this._clipper.setStencil(this._stencil),this.addChild(this._clipper),this._clipper.addChild(b),this._clipper.addChild(c),this._clipper.addChild(e),this._clipper.addChild(f),this.addChild(this._thumbSprite),this.needsLayout(),!0):!1},needsLayout:function(){var a=this._maskSize;this._onSprite.setPosition(this._onSprite.getContentSize().width/2+this._sliderXPosition-a.width/2,this._onSprite.getContentSize().height/2-a.height/2);this._offSprite.setPosition(this._onSprite.getContentSize().width+
this._offSprite.getContentSize().width/2+this._sliderXPosition-a.width/2,this._offSprite.getContentSize().height/2-a.height/2);this._onLabel&&this._onLabel.setPosition(this._onSprite.getPositionX()-this._thumbSprite.getContentSize().width/6,this._onSprite.getContentSize().height/2-a.height/2);this._offLabel&&this._offLabel.setPosition(this._offSprite.getPositionX()+this._thumbSprite.getContentSize().width/6,this._offSprite.getContentSize().height/2-a.height/2);this._thumbSprite.setPosition(this._onSprite.getContentSize().width+
this._sliderXPosition,this._maskSize.height/2)},setSliderXPosition:function(a){a<=this._offPosition?a=this._offPosition:a>=this._onPosition&&(a=this._onPosition);this._sliderXPosition=a;this.needsLayout()},getSliderXPosition:function(){return this._sliderXPosition},_getOnSideWidth:function(){return this._onSprite.getContentSize().width},_getOffSideWidth:function(){return this._offSprite.getContentSize().height},updateTweenAction:function(a,b){"sliderXPosition"===b&&this.setSliderXPosition(a)},setOnPosition:function(a){this._onPosition=
a},getOnPosition:function(){return this._onPosition},setOffPosition:function(a){this._offPosition=a},getOffPosition:function(){return this._offPosition},setMaskTexture:function(a){this._stencil.setTexture(a)},getMaskTexture:function(){return this._stencil.getTexture()},setTextureLocation:function(a){this._textureLocation=a},getTextureLocation:function(){return this._textureLocation},setMaskLocation:function(a){this._maskLocation=a},getMaskLocation:function(){return this._maskLocation},setOnSprite:function(a){this._onSprite=
a},getOnSprite:function(){return this._onSprite},setOffSprite:function(a){this._offSprite=a},getOffSprite:function(){return this._offSprite},setThumbSprite:function(a){this._thumbSprite=a},getThumbSprite:function(){return this._thumbSprite},setOnLabel:function(a){this._onLabel=a},getOnLabel:function(){return this._onLabel},setOffLabel:function(a){this._offLabel=a},getOffLabel:function(){return this._offLabel}});_p=cc.ControlSwitchSprite.prototype;_p.sliderX;
cc.defineGetterSetter(_p,"sliderX",_p.getSliderXPosition,_p.setSliderXPosition);_p.onPos;cc.defineGetterSetter(_p,"onPos",_p.getOnPosition,_p.setOnPosition);_p.offPos;cc.defineGetterSetter(_p,"offPos",_p.getOffPosition,_p.setOffPosition);_p.maskTexture;cc.defineGetterSetter(_p,"maskTexture",_p.getMaskTexture,_p.setMaskTexture);_p.maskPos;cc.defineGetterSetter(_p,"maskPos",_p.getMaskLocation,_p.setMaskLocation);_p.onSprite;cc.defineGetterSetter(_p,"onSprite",_p.getOnSprite,_p.setOnSprite);_p.offSprite;
cc.defineGetterSetter(_p,"offSprite",_p.getOffSprite,_p.setOffSprite);_p.thumbSprite;cc.defineGetterSetter(_p,"thumbSprite",_p.getThumbSprite,_p.setThumbSprite);_p.onLabel;cc.defineGetterSetter(_p,"onLabel",_p.getOnLabel,_p.setOnLabel);_p.offLabel;cc.defineGetterSetter(_p,"offLabel",_p.getOffLabel,_p.setOffLabel);_p.onSideWidth;cc.defineGetterSetter(_p,"onSideWidth",_p._getOnSideWidth);_p.offSideWidth;cc.defineGetterSetter(_p,"offSideWidth",_p._getOffSideWidth);_p=null;
cc.CONTROL_STEPPER_PARTMINUS=0;cc.CONTROL_STEPPER_PARTPLUS=1;cc.CONTROL_STEPPER_PARTNONE=2;cc.CONTROL_STEPPER_LABELCOLOR_ENABLED=cc.color(55,55,55);cc.CONTROL_STEPPER_LABELCOLOR_DISABLED=cc.color(147,147,147);cc.CONTROL_STEPPER_LABELFONT="CourierNewPSMT";cc.AUTOREPEAT_DELTATIME=0.15;cc.AUTOREPEAT_INCREASETIME_INCREMENT=12;
cc.ControlStepper=cc.Control.extend({_minusSprite:null,_plusSprite:null,_minusLabel:null,_plusLabel:null,_value:0,_continuous:!1,_autorepeat:!1,_wraps:!1,_minimumValue:0,_maximumValue:0,_stepValue:0,_touchInsideFlag:!1,_touchedPart:cc.CONTROL_STEPPER_PARTNONE,_autorepeatCount:0,_className:"ControlStepper",ctor:function(a,b){cc.Control.prototype.ctor.call(this);this._plusLabel=this._minusLabel=this._plusSprite=this._minusSprite=null;this._value=0;this._wraps=this._autorepeat=this._continuous=!1;this._stepValue=
this._maximumValue=this._minimumValue=0;this._touchInsideFlag=!1;this._touchedPart=cc.CONTROL_STEPPER_PARTNONE;this._autorepeatCount=0;b&&this.initWithMinusSpriteAndPlusSprite(a,b)},initWithMinusSpriteAndPlusSprite:function(a,b){if(!a)throw"cc.ControlStepper.initWithMinusSpriteAndPlusSprite(): Minus sprite should be non-null.";if(!b)throw"cc.ControlStepper.initWithMinusSpriteAndPlusSprite(): Plus sprite should be non-null.";if(this.init()){this._continuous=this._autorepeat=!0;this._minimumValue=0;
this._maximumValue=100;this._value=0;this._stepValue=1;this._wraps=!1;this.ignoreAnchorPointForPosition(!1);this.setMinusSprite(a);this._minusSprite.setPosition(a.getContentSize().width/2,a.getContentSize().height/2);this.addChild(this._minusSprite);this.setMinusLabel(new cc.LabelTTF("-",cc.CONTROL_STEPPER_LABELFONT,40,cc.size(40,40),cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER));this._minusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_DISABLED);this._minusLabel.setPosition(this._minusSprite.getContentSize().width/
2,this._minusSprite.getContentSize().height/2);this._minusSprite.addChild(this._minusLabel);this.setPlusSprite(b);this._plusSprite.setPosition(a.getContentSize().width+b.getContentSize().width/2,a.getContentSize().height/2);this.addChild(this._plusSprite);this.setPlusLabel(new cc.LabelTTF("+",cc.CONTROL_STEPPER_LABELFONT,40,cc.size(40,40),cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER));this._plusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_ENABLED);this._plusLabel.setPosition(this._plusSprite.getContentSize().width/
2,this._plusSprite.getContentSize().height/2);this._plusSprite.addChild(this._plusLabel);var c=cc.ControlUtils.CCRectUnion(this._minusSprite.getBoundingBox(),this._plusSprite.getBoundingBox());return this.setContentSize(this._minusSprite.getContentSize().width+this._plusSprite.getContentSize().height,c.height),!0}return!1},setWraps:function(a){(this._wraps=a)&&(this._minusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_ENABLED),this._plusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_ENABLED));this.setValue(this._value)},
getWraps:function(){return this._wraps},setMinimumValue:function(a){if(a>=this._maximumValue)throw"cc.ControlStepper.setMinimumValue(): minimumValue should be numerically less than maximumValue.";this._minimumValue=a;this.setValue(this._value)},getMinimumValue:function(){return this._minimumValue},setMaximumValue:function(a){if(a<=this._minimumValue)throw"cc.ControlStepper.setMaximumValue(): maximumValue should be numerically less than maximumValue.";this._maximumValue=a;this.setValue(this._value)},
getMaximumValue:function(){return this._maximumValue},setValue:function(a){this.setValueWithSendingEvent(a,!0)},getValue:function(){return this._value},setStepValue:function(a){if(0>=a)throw"cc.ControlStepper.setMaximumValue(): stepValue should be numerically greater than 0.";this._stepValue=a},getStepValue:function(){return this._stepValue},isContinuous:function(){return this._continuous},setValueWithSendingEvent:function(a,b){a<this._minimumValue?a=this._wraps?this._maximumValue:this._minimumValue:
a>this._maximumValue&&(a=this._wraps?this._minimumValue:this._maximumValue);this._value=a;this._wraps||(this._minusLabel.setColor(a===this._minimumValue?cc.CONTROL_STEPPER_LABELCOLOR_DISABLED:cc.CONTROL_STEPPER_LABELCOLOR_ENABLED),this._plusLabel.setColor(a===this._maximumValue?cc.CONTROL_STEPPER_LABELCOLOR_DISABLED:cc.CONTROL_STEPPER_LABELCOLOR_ENABLED));b&&this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)},startAutorepeat:function(){this._autorepeatCount=-1;this.schedule(this.update,
cc.AUTOREPEAT_DELTATIME,cc.REPEAT_FOREVER,3*cc.AUTOREPEAT_DELTATIME)},stopAutorepeat:function(){this.unschedule(this.update)},update:function(a){this._autorepeatCount++;this._autorepeatCount<cc.AUTOREPEAT_INCREASETIME_INCREMENT&&0!==this._autorepeatCount%3||(this._touchedPart===cc.CONTROL_STEPPER_PARTMINUS?this.setValueWithSendingEvent(this._value-this._stepValue,this._continuous):this._touchedPart===cc.CONTROL_STEPPER_PARTPLUS&&this.setValueWithSendingEvent(this._value+this._stepValue,this._continuous))},
updateLayoutUsingTouchLocation:function(a){a.x<this._minusSprite.getContentSize().width&&this._value>this._minimumValue?(this._touchedPart=cc.CONTROL_STEPPER_PARTMINUS,this._minusSprite.setColor(cc.color.GRAY),this._plusSprite.setColor(cc.color.WHITE)):a.x>=this._minusSprite.getContentSize().width&&this._value<this._maximumValue?(this._touchedPart=cc.CONTROL_STEPPER_PARTPLUS,this._minusSprite.setColor(cc.color.WHITE),this._plusSprite.setColor(cc.color.GRAY)):(this._touchedPart=cc.CONTROL_STEPPER_PARTNONE,
this._minusSprite.setColor(cc.color.WHITE),this._plusSprite.setColor(cc.color.WHITE))},onTouchBegan:function(a,b){if(!this.isTouchInside(a)||!this.isEnabled()||!this.isVisible())return!1;var c=this.getTouchLocation(a);return this.updateLayoutUsingTouchLocation(c),this._touchInsideFlag=!0,this._autorepeat&&this.startAutorepeat(),!0},onTouchMoved:function(a,b){if(this.isTouchInside(a)){var c=this.getTouchLocation(a);this.updateLayoutUsingTouchLocation(c);this._touchInsideFlag||(this._touchInsideFlag=
!0,this._autorepeat&&this.startAutorepeat())}else this._touchInsideFlag=!1,this._touchedPart=cc.CONTROL_STEPPER_PARTNONE,this._minusSprite.setColor(cc.color.WHITE),this._plusSprite.setColor(cc.color.WHITE),this._autorepeat&&this.stopAutorepeat()},onTouchEnded:function(a,b){if(this._minusSprite.setColor(cc.color.WHITE),this._plusSprite.setColor(cc.color.WHITE),this._autorepeat&&this.stopAutorepeat(),this.isTouchInside(a)){var c=this.getTouchLocation(a);this.setValue(this._value+(c.x<this._minusSprite.getContentSize().width?
0-this._stepValue:this._stepValue))}},setMinusSprite:function(a){this._minusSprite=a},getMinusSprite:function(){return this._minusSprite},setPlusSprite:function(a){this._plusSprite=a},getPlusSprite:function(){return this._plusSprite},setMinusLabel:function(a){this._minusLabel=a},getMinusLabel:function(){return this._minusLabel},setPlusLabel:function(a){this._plusLabel=a},getPlusLabel:function(){return this._plusLabel}});_p=cc.ControlStepper.prototype;_p.wraps;
cc.defineGetterSetter(_p,"wraps",_p.getWraps,_p.setWraps);_p.value;cc.defineGetterSetter(_p,"value",_p.getValue,_p.setValue);_p.minValue;cc.defineGetterSetter(_p,"minValue",_p.getMinimumValue,_p.setMinimumValue);_p.maxValue;cc.defineGetterSetter(_p,"maxValue",_p.getMaximumValue,_p.setMaximumValue);_p.stepValue;cc.defineGetterSetter(_p,"stepValue",_p.getStepValue,_p.setStepValue);_p.continuous;cc.defineGetterSetter(_p,"continuous",_p.isContinuous);_p.minusSprite;
cc.defineGetterSetter(_p,"minusSprite",_p.getMinusSprite,_p.setMinusSprite);_p.plusSprite;cc.defineGetterSetter(_p,"plusSprite",_p.getPlusSprite,_p.setPlusSprite);_p.minusLabel;cc.defineGetterSetter(_p,"minusLabel",_p.getMinusLabel,_p.setMinusLabel);_p.plusLabel;cc.defineGetterSetter(_p,"plusLabel",_p.getPlusLabel,_p.setPlusLabel);_p=null;cc.ControlStepper.create=function(a,b){return new cc.ControlStepper(a,b)};
cc.ControlPotentiometer=cc.Control.extend({_thumbSprite:null,_progressTimer:null,_previousLocation:null,_value:0,_minimumValue:0,_maximumValue:1,_className:"ControlPotentiometer",ctor:function(a,b,c){if(cc.Control.prototype.ctor.call(this),void 0!=c)a=new cc.Sprite(a),c=new cc.Sprite(c),b=new cc.ProgressTimer(new cc.Sprite(b)),this.initWithTrackSprite_ProgressTimer_ThumbSprite(a,b,c)},initWithTrackSprite_ProgressTimer_ThumbSprite:function(a,b,c){return this.init()?(this.setProgressTimer(b),this.setThumbSprite(c),
this._thumbSprite.setPosition(b.getPosition()),this.addChild(c,2),this.addChild(b,1),this.addChild(a),this.setContentSize(a.getContentSize()),this._minimumValue=0,this._maximumValue=1,this.setValue(this._minimumValue),!0):!1},setEnabled:function(a){this.setEnabled(a);null!==this._thumbSprite&&this._thumbSprite.setOpacity(a?255:128)},setValue:function(a){a<this._minimumValue&&(a=this._minimumValue);a>this._maximumValue&&(a=this._maximumValue);this._value=a;a=(a-this._minimumValue)/(this._maximumValue-
this._minimumValue);this._progressTimer.setPercentage(100*a);this._thumbSprite.setRotation(360*a);this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)},getValue:function(){return this._value},setMinimumValue:function(a){this._minimumValue=a;this._minimumValue>=this._maximumValue&&(this._maximumValue=this._minimumValue+1);this.setValue(this._maximumValue)},getMinimumValue:function(){return this._minimumValue},setMaximumValue:function(a){this._maximumValue=a;this._maximumValue<=this._minimumValue&&
(this._minimumValue=this._maximumValue-1);this.setValue(this._minimumValue)},getMaximumValue:function(){return this._maximumValue},isTouchInside:function(a){a=this.getTouchLocation(a);return this.distanceBetweenPointAndPoint(this._progressTimer.getPosition(),a)<Math.min(this.getContentSize().width/2,this.getContentSize().height/2)},onTouchBegan:function(a,b){return this.isTouchInside(a)&&this.isEnabled()&&this.isVisible()?(this._previousLocation=this.getTouchLocation(a),this.potentiometerBegan(this._previousLocation),
!0):!1},onTouchMoved:function(a,b){var c=this.getTouchLocation(a);this.potentiometerMoved(c)},onTouchEnded:function(a,b){this.potentiometerEnded(cc.p(0,0))},distanceBetweenPointAndPoint:function(a,b){var c=a.x-b.x,d=a.y-b.y;return Math.sqrt(c*c+d*d)},angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint:function(a,b,c,d){var e=d.x-c.x;c=d.y-c.y;a=Math.atan2(b.x-a.x,b.y-a.y);e=Math.atan2(e,c);return 180*(a-e)/Math.PI},potentiometerBegan:function(a){this.setSelected(!0);this.getThumbSprite().setColor(cc.color.GRAY)},
potentiometerMoved:function(a){var b=this.angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint(this._progressTimer.getPosition(),a,this._progressTimer.getPosition(),this._previousLocation);180<b?b-=360:-180>b&&(b+=360);this.setValue(this._value+b/360*(this._maximumValue-this._minimumValue));this._previousLocation=a},potentiometerEnded:function(a){this.getThumbSprite().setColor(cc.color.WHITE);this.setSelected(!1)},setThumbSprite:function(a){this._thumbSprite=a},getThumbSprite:function(){return this._thumbSprite},
setProgressTimer:function(a){this._progressTimer=a},getProgressTimer:function(){return this._progressTimer},setPreviousLocation:function(a){this._previousLocation=a},getPreviousLocation:function(){return this._previousLocation}});_p=cc.ControlPotentiometer.prototype;_p.value;cc.defineGetterSetter(_p,"value",_p.getValue,_p.setValue);_p.minValue;cc.defineGetterSetter(_p,"minValue",_p.getMinimumValue,_p.setMinimumValue);_p.maxValue;cc.defineGetterSetter(_p,"maxValue",_p.getMaximumValue,_p.setMaximumValue);
_p.progressTimer;cc.defineGetterSetter(_p,"progressTimer",_p.getProgressTimer,_p.setProgressTimer);_p.thumbSprite;cc.defineGetterSetter(_p,"thumbSprite",_p.getThumbSprite,_p.setThumbSprite);_p.prevLocation;cc.defineGetterSetter(_p,"prevLocation",_p.getPreviousLocation,_p.setPreviousLocation);_p=null;cc.ControlPotentiometer.create=function(a,b,c){return new cc.ControlPotentiometer(a,b,c)};cc.SCROLLVIEW_DIRECTION_NONE=-1;cc.SCROLLVIEW_DIRECTION_HORIZONTAL=0;cc.SCROLLVIEW_DIRECTION_VERTICAL=1;
cc.SCROLLVIEW_DIRECTION_BOTH=2;var SCROLL_DEACCEL_RATE=0.95,SCROLL_DEACCEL_DIST=1,BOUNCE_DURATION=0.15,INSET_RATIO=0.2,MOVE_INCH=0.04375,BOUNCE_BACK_FACTOR=0.35;cc.convertDistanceFromPointToInch=function(a){var b=cc.view,b=(b.getScaleX()+b.getScaleY())/2;return a*b/160};cc.ScrollViewDelegate=cc.Class.extend({scrollViewDidScroll:function(a){},scrollViewDidZoom:function(a){}});
cc.ScrollView=cc.Layer.extend({_zoomScale:0,_minZoomScale:0,_maxZoomScale:0,_delegate:null,_direction:cc.SCROLLVIEW_DIRECTION_BOTH,_dragging:!1,_contentOffset:null,_container:null,_touchMoved:!1,_maxInset:null,_minInset:null,_bounceable:!1,_clippingToBounds:!1,_scrollDistance:null,_touchPoint:null,_touchLength:0,_touches:null,_viewSize:null,_minScale:0,_maxScale:0,_parentScissorRect:null,_scissorRestored:!1,_tmpViewRect:null,_touchListener:null,_className:"ScrollView",ctor:function(a,b){cc.Layer.prototype.ctor.call(this);
this._contentOffset=cc.p(0,0);this._maxInset=cc.p(0,0);this._minInset=cc.p(0,0);this._scrollDistance=cc.p(0,0);this._touchPoint=cc.p(0,0);this._touches=[];this._viewSize=cc.size(0,0);this._parentScissorRect=new cc.Rect(0,0,0,0);this._tmpViewRect=new cc.Rect(0,0,0,0);void 0!=b?this.initWithViewSize(a,b):this.initWithViewSize(cc.size(200,200),null)},init:function(){return this.initWithViewSize(cc.size(200,200),null)},initWithViewSize:function(a,b){var c=cc.p(0,0);return cc.Layer.prototype.init.call(this)?
(this._container=b,this._container||(this._container=new cc.Layer,this._container.ignoreAnchorPointForPosition(!1),this._container.setAnchorPoint(c)),this.setViewSize(a),this.setTouchEnabled(!0),this._touches.length=0,this._delegate=null,this._bounceable=!0,this._clippingToBounds=!0,this._direction=cc.SCROLLVIEW_DIRECTION_BOTH,this._container.setPosition(c),this._touchLength=0,this.addChild(this._container),this._minScale=this._maxScale=1,!0):!1},setContentOffset:function(a,b){if(b)return void this.setContentOffsetInDuration(a,
BOUNCE_DURATION);if(!this._bounceable){var c=this.minContainerOffset(),d=this.maxContainerOffset();a.x=Math.max(c.x,Math.min(d.x,a.x));a.y=Math.max(c.y,Math.min(d.y,a.y))}this._container.setPosition(a);c=this._delegate;null!=c&&c.scrollViewDidScroll&&c.scrollViewDidScroll(this)},getContentOffset:function(){var a=this._container.getPosition();return cc.p(a.x,a.y)},setContentOffsetInDuration:function(a,b){var c=cc.moveTo(b,a),d=cc.callFunc(this._stoppedAnimatedScroll,this);this._container.runAction(cc.sequence(c,
d));this.schedule(this._performedAnimatedScroll)},setZoomScale:function(a,b){if(b)return void this.setZoomScaleInDuration(a,BOUNCE_DURATION);var c=this._container;if(c.getScale()!==a){var d,e;0===this._touchLength?(e=this._viewSize,e=cc.p(0.5*e.width,0.5*e.height),e=this.convertToWorldSpace(e)):e=this._touchPoint;d=c.convertToNodeSpace(e);c.setScale(Math.max(this._minScale,Math.min(this._maxScale,a)));d=c.convertToWorldSpace(d);e=cc.pSub(e,d);this._delegate&&this._delegate.scrollViewDidZoom&&this._delegate.scrollViewDidZoom(this);
this.setContentOffset(cc.pAdd(c.getPosition(),e))}},getZoomScale:function(){return this._container.getScale()},setZoomScaleInDuration:function(a,b){if(0<b){var c=this._container.getScale();c!==a&&(c=cc.actionTween(b,"zoomScale",c,a),this.runAction(c))}else this.setZoomScale(a)},minContainerOffset:function(){var a=this._container,b=a.getContentSize(),c=this._viewSize;return cc.p(c.width-b.width*a.getScaleX(),c.height-b.height*a.getScaleY())},maxContainerOffset:function(){return cc.p(0,0)},isNodeVisible:function(a){var b=
this.getContentOffset(),c=this.getViewSize(),d=this.getZoomScale(),b=cc.rect(-b.x/d,-b.y/d,c.width/d,c.height/d);return cc.rectIntersectsRect(b,a.getBoundingBox())},pause:function(a){this._container.pause();a=this._container.getChildren();for(var b=0;b<a.length;b++)a[b].pause();this._super()},resume:function(a){a=this._container.getChildren();for(var b=0,c=a.length;c>b;b++)a[b].resume();this._container.resume();this._super()},isDragging:function(){return this._dragging},isTouchMoved:function(){return this._touchMoved},
isBounceable:function(){return this._bounceable},setBounceable:function(a){this._bounceable=a},getViewSize:function(){return this._viewSize},setViewSize:function(a){this._viewSize=a;cc.Node.prototype.setContentSize.call(this,a)},getContainer:function(){return this._container},setContainer:function(a){a&&(this.removeAllChildren(!0),this._container=a,a.ignoreAnchorPointForPosition(!1),a.setAnchorPoint(0,0),this.addChild(a),this.setViewSize(this._viewSize))},getDirection:function(){return this._direction},
setDirection:function(a){this._direction=a},getDelegate:function(){return this._delegate},setDelegate:function(a){this._delegate=a},onTouchBegan:function(a,b){if(!this.isVisible())return!1;var c=this._getViewRect(),d=this._container,e=d.convertToWorldSpace(d.convertTouchToNodeSpace(a)),f=this._touches;return 2<f.length||this._touchMoved||!cc.rectContainsPoint(c,e)?!1:(f.push(a),1===f.length?(this._touchPoint=this.convertTouchToNodeSpace(a),this._touchMoved=!1,this._dragging=!0,this._scrollDistance.x=
0,this._scrollDistance.y=0,this._touchLength=0):2===f.length&&(this._touchPoint=cc.pMidpoint(this.convertTouchToNodeSpace(f[0]),this.convertTouchToNodeSpace(f[1])),this._touchLength=cc.pDistance(d.convertTouchToNodeSpace(f[0]),d.convertTouchToNodeSpace(f[1])),this._dragging=!1),!0)},onTouchMoved:function(a,b){if(this.isVisible())if(this.setNodeDirty(),1===this._touches.length&&this._dragging){this._touchMoved=!0;var c,d=(this._getViewRect(),this.convertTouchToNodeSpace(a)),e=cc.pSub(d,this._touchPoint),
f=0,g=this._direction;if(g===cc.SCROLLVIEW_DIRECTION_VERTICAL)f=e.y,c=this._container.getPositionY(),this.minContainerOffset().y<=c&&c<=this.maxContainerOffset().y||(e.y*=BOUNCE_BACK_FACTOR);else if(g===cc.SCROLLVIEW_DIRECTION_HORIZONTAL)f=e.x,c=this._container.getPositionX(),this.minContainerOffset().x<=c&&c<=this.maxContainerOffset().x||(e.x*=BOUNCE_BACK_FACTOR);else{f=Math.sqrt(e.x*e.x+e.y*e.y);c=this._container.getPositionY();var h=this.minContainerOffset(),k=this.maxContainerOffset();h.y<=c&&
c<=k.y||(e.y*=BOUNCE_BACK_FACTOR);c=this._container.getPositionX();h.x<=c&&c<=k.x||(e.x*=BOUNCE_BACK_FACTOR)}if(this._touchMoved||!(Math.abs(cc.convertDistanceFromPointToInch(f))<MOVE_INCH))if(this._touchMoved||(e.x=0,e.y=0),this._touchPoint=d,this._touchMoved=!0,this._dragging){switch(g){case cc.SCROLLVIEW_DIRECTION_VERTICAL:e.x=0;break;case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:e.y=0}d=this._container.getPosition();c=d.x+e.x;d=d.y+e.y;this._scrollDistance=e;this.setContentOffset(cc.p(c,d))}}else 2===
this._touches.length&&!this._dragging&&(e=cc.pDistance(this._container.convertTouchToNodeSpace(this._touches[0]),this._container.convertTouchToNodeSpace(this._touches[1])),this.setZoomScale(this.getZoomScale()*e/this._touchLength))},onTouchEnded:function(a,b){this.isVisible()&&(1===this._touches.length&&this._touchMoved&&this.schedule(this._deaccelerateScrolling),this._touches.length=0,this._dragging=!1,this._touchMoved=!1)},onTouchCancelled:function(a,b){this.isVisible()&&(this._touches.length=0,
this._dragging=!1,this._touchMoved=!1)},setContentSize:function(a,b){null!==this.getContainer()&&(void 0===b?this.getContainer().setContentSize(a):this.getContainer().setContentSize(a,b),this.updateInset())},_setWidth:function(a){var b=this.getContainer();null!==b&&(b._setWidth(a),this.updateInset())},_setHeight:function(a){var b=this.getContainer();null!==b&&(b._setHeight(a),this.updateInset())},getContentSize:function(){return this._container.getContentSize()},updateInset:function(){if(null!==this.getContainer()){var a=
this._viewSize,b=this.maxContainerOffset();this._maxInset.x=b.x+a.width*INSET_RATIO;this._maxInset.y=b.y+a.height*INSET_RATIO;b=this.minContainerOffset();this._minInset.x=b.x-a.width*INSET_RATIO;this._minInset.y=b.y-a.height*INSET_RATIO}},isClippingToBounds:function(){return this._clippingToBounds},setClippingToBounds:function(a){this._clippingToBounds=a},visit:function(a){this.isVisible()&&this._renderCmd.visit(a)},addChild:function(a,b,c){if(!a)throw Error("child must not nil!");b=b||a.getLocalZOrder();
c=c||a.getTag();this._container!==a?this._container.addChild(a,b,c):cc.Layer.prototype.addChild.call(this,a,b,c)},isTouchEnabled:function(){return null!==this._touchListener},setTouchEnabled:function(a){(this._touchListener&&cc.eventManager.removeListener(this._touchListener),this._touchListener=null,a)?(a=cc.EventListener.create({event:cc.EventListener.TOUCH_ONE_BY_ONE}),this.onTouchBegan&&(a.onTouchBegan=this.onTouchBegan.bind(this)),this.onTouchMoved&&(a.onTouchMoved=this.onTouchMoved.bind(this)),
this.onTouchEnded&&(a.onTouchEnded=this.onTouchEnded.bind(this)),this.onTouchCancelled&&(a.onTouchCancelled=this.onTouchCancelled.bind(this)),this._touchListener=a,cc.eventManager.addListener(a,this)):(this._touchMoved=this._dragging=!1,this._touches.length=0)},_initWithViewSize:function(a){return null},_relocateContainer:function(a){var b=this.minContainerOffset(),c=this.maxContainerOffset(),d=this._direction,e=this._container.getPosition(),f=e.x,g=e.y;(d===cc.SCROLLVIEW_DIRECTION_BOTH||d===cc.SCROLLVIEW_DIRECTION_HORIZONTAL)&&
(f=Math.max(f,b.x),f=Math.min(f,c.x));(d===cc.SCROLLVIEW_DIRECTION_BOTH||d===cc.SCROLLVIEW_DIRECTION_VERTICAL)&&(g=Math.min(g,c.y),g=Math.max(g,b.y));(g!==e.y||f!==e.x)&&this.setContentOffset(cc.p(f,g),a)},_deaccelerateScrolling:function(a){if(this._dragging)return void this.unschedule(this._deaccelerateScrolling);var b,c,d=this._container.getPosition();a=this._scrollDistance;this._container.setPosition(d.x+a.x,d.y+a.y);this._bounceable?(b=this._maxInset,c=this._minInset):(b=this.maxContainerOffset(),
c=this.minContainerOffset());var d=this._container.getPositionX(),e=this._container.getPositionY();a.x*=SCROLL_DEACCEL_RATE;a.y*=SCROLL_DEACCEL_RATE;this.setContentOffset(cc.p(d,e));(Math.abs(a.x)<=SCROLL_DEACCEL_DIST&&Math.abs(a.y)<=SCROLL_DEACCEL_DIST||e>b.y||e<c.y||d>b.x||d<c.x||d===b.x||d===c.x||e===b.y||e===c.y)&&(this.unschedule(this._deaccelerateScrolling),this._relocateContainer(!0))},_performedAnimatedScroll:function(a){return this._dragging?void this.unschedule(this._performedAnimatedScroll):
void(this._delegate&&this._delegate.scrollViewDidScroll&&this._delegate.scrollViewDidScroll(this))},_stoppedAnimatedScroll:function(a){this.unschedule(this._performedAnimatedScroll);this._delegate&&this._delegate.scrollViewDidScroll&&this._delegate.scrollViewDidScroll(this)},_handleZoom:function(){},_getViewRect:function(){for(var a=this.convertToWorldSpace(cc.p(0,0)),b=this._viewSize,c=this.getScaleX(),d=this.getScaleY(),e=this._parent;null!=e;e=e.getParent())c*=e.getScaleX(),d*=e.getScaleY();0>
c&&(a.x+=b.width*c,c=-c);0>d&&(a.y+=b.height*d,d=-d);e=this._tmpViewRect;return e.x=a.x,e.y=a.y,e.width=b.width*c,e.height=b.height*d,e},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.ScrollView.CanvasRenderCmd(this):new cc.ScrollView.WebGLRenderCmd(this)}});_p=cc.ScrollView.prototype;_p.minOffset;cc.defineGetterSetter(_p,"minOffset",_p.minContainerOffset);_p.maxOffset;cc.defineGetterSetter(_p,"maxOffset",_p.maxContainerOffset);_p.bounceable;
cc.defineGetterSetter(_p,"bounceable",_p.isBounceable,_p.setBounceable);_p.viewSize;cc.defineGetterSetter(_p,"viewSize",_p.getViewSize,_p.setViewSize);_p.container;cc.defineGetterSetter(_p,"container",_p.getContainer,_p.setContainer);_p.direction;cc.defineGetterSetter(_p,"direction",_p.getDirection,_p.setDirection);_p.delegate;cc.defineGetterSetter(_p,"delegate",_p.getDelegate,_p.setDelegate);_p.clippingToBounds;cc.defineGetterSetter(_p,"clippingToBounds",_p.isClippingToBounds,_p.setClippingToBounds);
_p=null;cc.ScrollView.create=function(a,b){return new cc.ScrollView(a,b)};
(function(){cc.ScrollView.CanvasRenderCmd=function(a){cc.Layer.CanvasRenderCmd.call(this,a);this._needDraw=!1;this.startCmd=new cc.CustomRenderCmd(this,this._startCmd);this.endCmd=new cc.CustomRenderCmd(this,this._endCmd)};var a=cc.ScrollView.CanvasRenderCmd.prototype=Object.create(cc.Layer.CanvasRenderCmd.prototype);a.constructor=cc.ScrollView.CanvasRenderCmd;a._startCmd=function(a,c,d){var e=this._node,f=a||cc._renderContext;a=f.getContext();if(f.save(),e._clippingToBounds){this._scissorRestored=
!1;f.setTransform(this._worldTransform,c,d);var g=e.getScaleX(),f=e.getScaleY();c*=e._viewSize.width*g;d*=e._viewSize.height*f;a.beginPath();a.rect(0,0,c,-d);a.closePath();a.clip()}};a._endCmd=function(a){a=a||cc._renderContext;a.restore()};a.visit=function(a){var c;c=this._node;var d=c._children;if(this.transform(a),cc.renderer.pushRenderCommand(this.startCmd),d&&0<d.length){a=d.length;c.sortAllChildren();for(c=0;a>c;c++)d[c]._renderCmd.visit(this)}cc.renderer.pushRenderCommand(this.endCmd)}})();
cc.SortableObject=cc.Class.extend({setObjectID:function(a){},getObjectID:function(){return 0}});cc.SortedObject=cc.SortableObject.extend({_objectID:0,ctor:function(){this._objectID=0},setObjectID:function(a){this._objectID=a},getObjectID:function(){return this._objectID}});var _compareObject=function(a,b){return a.getObjectID()-b.getObjectID()};
cc.ArrayForObjectSorting=cc.Class.extend({_saveObjectArr:null,ctor:function(){this._saveObjectArr=[]},insertSortedObject:function(a){if(!a)throw"cc.ArrayForObjectSorting.insertSortedObject(): addObject should be non-null.";var b=this.indexOfSortedObject(a);this.insertObject(a,b)},removeSortedObject:function(a){if(0!==this.count()){var b=this.indexOfSortedObject(a);b<this.count()&&b!==cc.INVALID_INDEX&&this.objectAtIndex(b).getObjectID()===a.getObjectID()&&this.removeObjectAtIndex(b)}},setObjectID_ofSortedObject:function(a,
b){var c=this.indexOfSortedObject(b);if(c<this.count()&&c!==cc.INVALID_INDEX){var d=this.objectAtIndex(c);d.getObjectID()===b.getObjectID()&&(this.removeObjectAtIndex(c),d.setObjectID(a),this.insertSortedObject(d))}},objectWithObjectID:function(a){if(0===this.count())return null;var b=new cc.SortedObject;b.setObjectID(a);var c=this.indexOfSortedObject(b);return c<this.count()&&c!==cc.INVALID_INDEX&&(b=this.objectAtIndex(c),b.getObjectID()!==a&&(b=null)),b},getObjectWithObjectID:function(a){return null},
indexOfSortedObject:function(a){var b=0;if(a){var c=0;a=a.getObjectID();for(var d=this._saveObjectArr,e=0;e<d.length;e++){var f=d[e].getObjectID();if(a===f||a>=c&&f>a)break;c=f;b++}}else b=cc.INVALID_INDEX;return b},count:function(){return this._saveObjectArr.length},lastObject:function(){var a=this._saveObjectArr;return 0===a.length?null:a[a.length-1]},objectAtIndex:function(a){return this._saveObjectArr[a]},addObject:function(a){this._saveObjectArr.push(a);this._saveObjectArr.sort(_compareObject)},
removeObjectAtIndex:function(a){this._saveObjectArr.splice(a,1);this._saveObjectArr.sort(_compareObject)},insertObject:function(a,b){this._saveObjectArr.splice(b,0,a);this._saveObjectArr.sort(_compareObject)}});cc.TABLEVIEW_FILL_TOPDOWN=0;cc.TABLEVIEW_FILL_BOTTOMUP=1;cc.TableViewCell=cc.Node.extend({_idx:0,_className:"TableViewCell",getIdx:function(){return this._idx},setIdx:function(a){this._idx=a},reset:function(){this._idx=cc.INVALID_INDEX},setObjectID:function(a){this._idx=a},getObjectID:function(){return this._idx}});
_p=cc.TableViewCell.prototype;_p.objectId;cc.defineGetterSetter(_p,"objectId",_p.getObjectID,_p.setObjectID);_p=null;cc.TableViewDelegate=cc.ScrollViewDelegate.extend({tableCellTouched:function(a,b){},tableCellHighlight:function(a,b){},tableCellUnhighlight:function(a,b){},tableCellWillRecycle:function(a,b){}});
cc.TableViewDataSource=cc.Class.extend({tableCellSizeForIndex:function(a,b){return this.cellSizeForTable(a)},cellSizeForTable:function(a){return cc.size(0,0)},tableCellAtIndex:function(a,b){return null},numberOfCellsInTableView:function(a){return 0}});
cc.TableView=cc.ScrollView.extend({_vOrdering:null,_indices:null,_cellsFreed:null,_dataSource:null,_tableViewDelegate:null,_oldDirection:null,_cellsPositions:null,_touchedCell:null,ctor:function(a,b,c){cc.ScrollView.prototype.ctor.call(this);this._oldDirection=cc.SCROLLVIEW_DIRECTION_NONE;this._cellsPositions=[];this.initWithViewSize(b,c);this.setDataSource(a);this._updateCellPositions();this._updateContentSize()},__indexFromOffset:function(a){var b=0,c=this._dataSource.numberOfCellsInTableView(this)-
1;switch(this.getDirection()){case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:a=a.x;break;default:a=a.y}for(var d=this._cellsPositions;c>=b;){var e=0|b+(c-b)/2,f=d[e],g=d[e+1];if(a>=f&&g>=a)return e;f>a?c=e-1:b=e+1}return 0>=b?0:-1},_indexFromOffset:function(a){var b={x:a.x,y:a.y};a=this._dataSource.numberOfCellsInTableView(this)-1;this._vOrdering===cc.TABLEVIEW_FILL_TOPDOWN&&(b.y=this.getContainer().getContentSize().height-b.y);b=this.__indexFromOffset(b);return-1!==b&&(b=Math.max(0,b),b>a&&(b=cc.INVALID_INDEX)),
b},__offsetFromIndex:function(a){switch(this.getDirection()){case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:a=cc.p(this._cellsPositions[a],0);break;default:a=cc.p(0,this._cellsPositions[a])}return a},_offsetFromIndex:function(a){var b=this.__offsetFromIndex(a);a=this._dataSource.tableCellSizeForIndex(this,a);return this._vOrdering===cc.TABLEVIEW_FILL_TOPDOWN&&(b.y=this.getContainer().getContentSize().height-b.y-a.height),b},_updateCellPositions:function(){var a=this._dataSource.numberOfCellsInTableView(this),
b=this._cellsPositions;if(0<a){for(var c,d=0,e=this._dataSource,f=0;a>f;f++)switch(b[f]=d,c=e.tableCellSizeForIndex(this,f),this.getDirection()){case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:d+=c.width;break;default:d+=c.height}this._cellsPositions[a]=d}},_updateContentSize:function(){var a=cc.size(0,0),b=this._dataSource.numberOfCellsInTableView(this);if(0<b)switch(a=this._cellsPositions[b],this.getDirection()){case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:a=cc.size(a,this._viewSize.height);break;default:a=
cc.size(this._viewSize.width,a)}this.setContentSize(a);this._oldDirection!==this._direction&&(this.setContentOffset(this._direction===cc.SCROLLVIEW_DIRECTION_HORIZONTAL?cc.p(0,0):cc.p(0,this.minContainerOffset().y)),this._oldDirection=this._direction)},_moveCellOutOfSight:function(a){this._tableViewDelegate&&this._tableViewDelegate.tableCellWillRecycle&&this._tableViewDelegate.tableCellWillRecycle(this,a);this._cellsFreed.addObject(a);this._cellsUsed.removeSortedObject(a);cc.arrayRemoveObject(this._indices,
a.getIdx());a.reset();a.getParent()===this.getContainer()&&this.getContainer().removeChild(a,!0)},_setIndexForCell:function(a,b){b.setAnchorPoint(0,0);b.setPosition(this._offsetFromIndex(a));b.setIdx(a)},_addCellIfNecessary:function(a){a.getParent()!==this.getContainer()&&this.getContainer().addChild(a);this._cellsUsed.insertSortedObject(a);var b=this._indices;a=a.getIdx();-1===b.indexOf(a)&&(b.push(a),b.sort(function(a,b){return a-b}))},getDataSource:function(){return this._dataSource},setDataSource:function(a){this._dataSource=
a},getDelegate:function(){return this._tableViewDelegate},setDelegate:function(a){this._tableViewDelegate=a},setVerticalFillOrder:function(a){this._vOrdering!==a&&(this._vOrdering=a,0<this._cellsUsed.count()&&this.reloadData())},getVerticalFillOrder:function(){return this._vOrdering},initWithViewSize:function(a,b){return cc.ScrollView.prototype.initWithViewSize.call(this,a,b)?(this._cellsUsed=new cc.ArrayForObjectSorting,this._cellsFreed=new cc.ArrayForObjectSorting,this._indices=[],this._tableViewDelegate=
null,this._vOrdering=cc.TABLEVIEW_FILL_BOTTOMUP,this.setDirection(cc.SCROLLVIEW_DIRECTION_VERTICAL),cc.ScrollView.prototype.setDelegate.call(this,this),!0):!1},updateCellAtIndex:function(a){if(!(a===cc.INVALID_INDEX||a>this._dataSource.numberOfCellsInTableView(this)-1)){var b=this.cellAtIndex(a);b&&this._moveCellOutOfSight(b);b=this._dataSource.tableCellAtIndex(this,a);this._setIndexForCell(a,b);this._addCellIfNecessary(b)}},insertCellAtIndex:function(a){if(!(a===cc.INVALID_INDEX||a>this._dataSource.numberOfCellsInTableView(this)-
1)){var b,c=this._cellsUsed;if(b=c.objectWithObjectID(a))for(var d=b=c.indexOfSortedObject(b);d<c.count();d++)b=c.objectAtIndex(d),this._setIndexForCell(b.getIdx()+1,b);b=this._dataSource.tableCellAtIndex(this,a);this._setIndexForCell(a,b);this._addCellIfNecessary(b);this._updateCellPositions();this._updateContentSize()}},removeCellAtIndex:function(a){if(!(a===cc.INVALID_INDEX||a>this._dataSource.numberOfCellsInTableView(this)-1)){var b=this.cellAtIndex(a);if(b){var c=this._cellsUsed,d=c.indexOfSortedObject(b);
this._moveCellOutOfSight(b);cc.arrayRemoveObject(this._indices,a);this._updateCellPositions();for(a=c.count()-1;a>d;a--)b=c.objectAtIndex(a),this._setIndexForCell(b.getIdx()-1,b)}}},reloadData:function(){this._oldDirection=cc.SCROLLVIEW_DIRECTION_NONE;for(var a=this._cellsUsed,b=this._cellsFreed,c=this.getContainer(),d=0,e=a.count();e>d;d++){var f=a.objectAtIndex(d);this._tableViewDelegate&&this._tableViewDelegate.tableCellWillRecycle&&this._tableViewDelegate.tableCellWillRecycle(this,f);b.addObject(f);
f.reset();f.getParent()===c&&c.removeChild(f,!0)}this._indices=[];this._cellsUsed=new cc.ArrayForObjectSorting;this._updateCellPositions();this._updateContentSize();0<this._dataSource.numberOfCellsInTableView(this)&&this.scrollViewDidScroll(this)},dequeueCell:function(){if(0===this._cellsFreed.count())return null;var a=this._cellsFreed.objectAtIndex(0);return this._cellsFreed.removeObjectAtIndex(0),a},cellAtIndex:function(a){return-1===this._indices.indexOf(a)?null:this._cellsUsed.objectWithObjectID(a)},
scrollViewDidScroll:function(a){var b=this._dataSource.numberOfCellsInTableView(this);if(0!==b){null!==this._tableViewDelegate&&this._tableViewDelegate.scrollViewDidScroll&&this._tableViewDelegate.scrollViewDidScroll(this);var c=0,d=this._viewSize,c=this.getContainer(),e=this.getContentOffset();e.x*=-1;e.y*=-1;var f=Math.max(b-1,0);this._vOrdering===cc.TABLEVIEW_FILL_TOPDOWN&&(e.y+=d.height/c.getScaleY());a=this._indexFromOffset(e);a===cc.INVALID_INDEX&&(a=b-1);this._vOrdering===cc.TABLEVIEW_FILL_TOPDOWN?
e.y-=d.height/c.getScaleY():e.y+=d.height/c.getScaleY();e.x+=d.width/c.getScaleX();d=this._indexFromOffset(e);d===cc.INVALID_INDEX&&(d=b-1);e=this._cellsUsed;if(0<e.count()){b=e.objectAtIndex(0);for(c=b.getIdx();a>c&&(this._moveCellOutOfSight(b),0<e.count());)b=e.objectAtIndex(0),c=b.getIdx()}if(0<e.count()){b=e.lastObject();for(c=b.getIdx();f>=c&&c>d&&(this._moveCellOutOfSight(b),0<e.count());)b=e.lastObject(),c=b.getIdx()}for(f=this._indices;d>=a;a++)-1===f.indexOf(a)&&this.updateCellAtIndex(a)}},
scrollViewDidZoom:function(a){},onTouchEnded:function(a,b){if(this.isVisible()){if(this._touchedCell){var c=this.getBoundingBox(),d=cc.p(c.x,c.y),d=this._parent.convertToWorldSpace(d);c.x=d.x;c.y=d.y;d=this._tableViewDelegate;cc.rectContainsPoint(c,a.getLocation())&&null!==d&&(d.tableCellUnhighlight&&d.tableCellUnhighlight(this,this._touchedCell),d.tableCellTouched&&d.tableCellTouched(this,this._touchedCell));this._touchedCell=null}cc.ScrollView.prototype.onTouchEnded.call(this,a,b)}},onTouchBegan:function(a,
b){if(!this.isVisible())return!1;var c=cc.ScrollView.prototype.onTouchBegan.call(this,a,b);if(1===this._touches.length){var d;d=this.getContainer().convertTouchToNodeSpace(a);d=this._indexFromOffset(d);d===cc.INVALID_INDEX?this._touchedCell=null:this._touchedCell=this.cellAtIndex(d);this._touchedCell&&null!==this._tableViewDelegate&&this._tableViewDelegate.tableCellHighlight&&this._tableViewDelegate.tableCellHighlight(this,this._touchedCell)}else this._touchedCell&&(null!==this._tableViewDelegate&&
this._tableViewDelegate.tableCellUnhighlight&&this._tableViewDelegate.tableCellUnhighlight(this,this._touchedCell),this._touchedCell=null);return c},onTouchMoved:function(a,b){cc.ScrollView.prototype.onTouchMoved.call(this,a,b);this._touchedCell&&this.isTouchMoved()&&(null!==this._tableViewDelegate&&this._tableViewDelegate.tableCellUnhighlight&&this._tableViewDelegate.tableCellUnhighlight(this,this._touchedCell),this._touchedCell=null)},onTouchCancelled:function(a,b){cc.ScrollView.prototype.onTouchCancelled.call(this,
a,b);this._touchedCell&&(null!==this._tableViewDelegate&&this._tableViewDelegate.tableCellUnhighlight&&this._tableViewDelegate.tableCellUnhighlight(this,this._touchedCell),this._touchedCell=null)}});_p=cc.TableView.prototype;_p.dataSource;cc.defineGetterSetter(_p,"dataSource",_p.getDataSource,_p.setDataSource);_p.delegate;cc.defineGetterSetter(_p,"delegate",_p.getDelegate,_p.setDelegate);_p.verticalFillOrder;cc.defineGetterSetter(_p,"verticalFillOrder",_p.getVerticalFillOrder,_p.setVerticalFillOrder);
_p=null;cc.TableView.create=function(a,b,c){return new cc.TableView(a,b,c)};
!function(){cc.Scale9Sprite.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._cachedParent=null;this._cacheDirty=!1};var a=cc.Scale9Sprite.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.Scale9Sprite.WebGLRenderCmd;a.visit=function(a){var c=this._node;c._visible&&(c._positionsAreDirty&&(c._updatePositions(),c._positionsAreDirty=!1,c._scale9Dirty=!0),cc.Node.WebGLRenderCmd.prototype.visit.call(this,a))};a.transform=function(a,c){var d=this._node;
cc.Node.WebGLRenderCmd.prototype.transform.call(this,a,c);d._positionsAreDirty&&(d._updatePositions(),d._positionsAreDirty=!1,d._scale9Dirty=!0)};a._updateDisplayColor=function(a){cc.Node.WebGLRenderCmd.prototype._updateDisplayColor.call(this,a);var c=this._node._scale9Image;if(c)for(var c=c.getChildren(),d=0;d<c.length;d++){var e=c[d];e&&(e._renderCmd._updateDisplayColor(a),e._renderCmd._updateColor())}};a._updateDisplayOpacity=function(a){cc.Node.WebGLRenderCmd.prototype._updateDisplayOpacity.call(this,
a);var c=this._node._scale9Image;if(c)for(var c=c.getChildren(),d=0;d<c.length;d++){var e=c[d];e&&(e._renderCmd._updateDisplayOpacity(a),e._renderCmd._updateColor())}};a.setState=function(a){var c=this._node._scale9Image;null!==c&&(a===cc.Scale9Sprite.state.NORMAL?c.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)):a===cc.Scale9Sprite.state.GRAY&&c.setShaderProgram(cc.Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram()))};cc.Scale9Sprite.WebGLRenderCmd._grayShaderProgram=
null;cc.Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram=function(){var a=cc.Scale9Sprite.WebGLRenderCmd._grayShaderProgram;return a?a:(a=new cc.GLProgram,a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT,cc.Scale9Sprite.WebGLRenderCmd._grayShaderFragment),a.addAttribute(cc.ATTRIBUTE_NAME_POSITION,cc.VERTEX_ATTRIB_POSITION),a.addAttribute(cc.ATTRIBUTE_NAME_COLOR,cc.VERTEX_ATTRIB_COLOR),a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD,cc.VERTEX_ATTRIB_TEX_COORDS),a.link(),a.updateUniforms(),
cc.Scale9Sprite.WebGLRenderCmd._grayShaderProgram=a,a)};cc.Scale9Sprite.WebGLRenderCmd._grayShaderFragment="precision lowp float;\nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nvoid main() \n{ \n    vec4 c \x3d texture2D(CC_Texture0, v_texCoord); \n    gl_FragColor.xyz \x3d vec3(0.2126*c.r + 0.7152*c.g + 0.0722*c.b); \n     gl_FragColor.w \x3d c.w ; \n}"}();
(function(){cc.ScrollView.WebGLRenderCmd=function(a){cc.Layer.WebGLRenderCmd.call(this,a);this._needDraw=!1;this.startCmd=new cc.CustomRenderCmd(this,this._startCmd);this.endCmd=new cc.CustomRenderCmd(this,this._endCmd)};var a=cc.ScrollView.WebGLRenderCmd.prototype=Object.create(cc.Layer.WebGLRenderCmd.prototype);a.constructor=cc.ScrollView.WebGLRenderCmd;a._startCmd=function(){var a=this._node,c=cc.view,d=a._getViewRect();if(c.isScissorEnabled()){if(a._scissorRestored=!0,a._parentScissorRect=c.getScissorRect(),
cc.rectIntersection(d,a._parentScissorRect)){var e=a._parentScissorRect,a=Math.max(d.x,e.x),f=Math.max(d.y,e.y),g=Math.min(d.x+d.width,e.x+e.width),d=Math.min(d.y+d.height,e.y+e.height);c.setScissorInPoints(a,f,g-a,d-f)}}else a=cc._renderContext,a.enable(a.SCISSOR_TEST),c.setScissorInPoints(d.x,d.y,d.width,d.height)};a._endCmd=function(){var a=this._node;a._scissorRestored?(a=a._parentScissorRect,cc.view.setScissorInPoints(a.x,a.y,a.width,a.height)):(a=cc._renderContext,a.disable(a.SCISSOR_TEST))};
a.visit=function(a){var c,d,e=this._node,f=e._children;if(cc.kmGLPushMatrix(),this.transform(a),e._clippingToBounds&&cc.renderer.pushRenderCommand(this.startCmd),f&&0<f.length){d=f.length;for(a=0;d>a&&(c=f[a],c&&0>c._localZOrder);a++)c._renderCmd.visit();for(;d>a;a++)f[a]._renderCmd.visit()}e._clippingToBounds&&cc.renderer.pushRenderCommand(this.endCmd);this._dirtyFlag=0;cc.kmGLPopMatrix()}})();function BlockData(a,b){this.selMenuHander=a;this.target=b}
function BlockCCControlData(a,b,c){this.selCCControlHandler=a;this.target=b;this.controlEvents=c}
var PROPERTY_POSITION="position",PROPERTY_CONTENTSIZE="contentSize",PROPERTY_SKEW="skew",PROPERTY_ANCHORPOINT="anchorPoint",PROPERTY_SCALE="scale",PROPERTY_ROTATION="rotation",PROPERTY_TAG="tag",PROPERTY_IGNOREANCHORPOINTFORPOSITION="ignoreAnchorPointForPosition",PROPERTY_VISIBLE="visible",ASSERT_FAIL_UNEXPECTED_PROPERTY=function(a){cc.log("Unexpected property: '"+a+"'!")},ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE=function(a){cc.log("Unexpected property type: '"+a+"'!")};
cc.NodeLoader=cc.Class.extend({_customProperties:null,ctor:function(){this._customProperties=new cc._Dictionary},loadCCNode:function(a,b){return this._createCCNode(a,b)},parseProperties:function(a,b,c){for(var d=c.readInt(!1),e=c.readInt(!1),e=d+e,f=0;e>f;f++){var g=f>=d,h=c.readInt(!1),k=c.readCachedString(),m=!1,n=c.readByte();((n===CCB_PLATFORM_ALL||n===CCB_PLATFORM_IOS||n===CCB_PLATFORM_MAC)&&(m=!0),a instanceof cc.BuilderFile)?a.getCCBFileNode()&&g&&(a=a.getCCBFileNode(),m=-1!==a.userObject.indexOf(k)):
g&&a===c.getAnimationManager().getRootNode()&&((g=a.userObject)||(g=[],a.userObject=g),g.push(k));switch(h){case CCB_PROPTYPE_POSITION:h=this.parsePropTypePosition(a,b,c,k);m&&this.onHandlePropTypePosition(a,b,k,h,c);break;case CCB_PROPTYPE_POINT:h=this.parsePropTypePoint(a,b,c);m&&this.onHandlePropTypePoint(a,b,k,h,c);break;case CCB_PROPTYPE_POINTLOCK:h=this.parsePropTypePointLock(a,b,c);m&&this.onHandlePropTypePointLock(a,b,k,h,c);break;case CCB_PROPTYPE_SIZE:h=this.parsePropTypeSize(a,b,c);m&&
this.onHandlePropTypeSize(a,b,k,h,c);break;case CCB_PROPTYPE_SCALELOCK:h=this.parsePropTypeScaleLock(a,b,c,k);m&&this.onHandlePropTypeScaleLock(a,b,k,h,c);break;case CCB_PROPTYPE_FLOATXY:h=this.parsePropTypeFloatXY(a,b,c);m&&this.onHandlePropTypeFloatXY(a,b,k,h,c);break;case CCB_PROPTYPE_FLOAT:h=this.parsePropTypeFloat(a,b,c);m&&this.onHandlePropTypeFloat(a,b,k,h,c);break;case CCB_PROPTYPE_DEGREES:h=this.parsePropTypeDegrees(a,b,c,k);m&&this.onHandlePropTypeDegrees(a,b,k,h,c);break;case CCB_PROPTYPE_FLOATSCALE:h=
this.parsePropTypeFloatScale(a,b,c);m&&this.onHandlePropTypeFloatScale(a,b,k,h,c);break;case CCB_PROPTYPE_INTEGER:h=this.parsePropTypeInteger(a,b,c);m&&this.onHandlePropTypeInteger(a,b,k,h,c);break;case CCB_PROPTYPE_INTEGERLABELED:h=this.parsePropTypeIntegerLabeled(a,b,c);m&&this.onHandlePropTypeIntegerLabeled(a,b,k,h,c);break;case CCB_PROPTYPE_FLOATVAR:h=this.parsePropTypeFloatVar(a,b,c);m&&this.onHandlePropTypeFloatVar(a,b,k,h,c);break;case CCB_PROPTYPE_CHECK:h=this.parsePropTypeCheck(a,b,c,k);
m&&this.onHandlePropTypeCheck(a,b,k,h,c);break;case CCB_PROPTYPE_SPRITEFRAME:h=this.parsePropTypeSpriteFrame(a,b,c,k);m&&this.onHandlePropTypeSpriteFrame(a,b,k,h,c);break;case CCB_PROPTYPE_ANIMATION:h=this.parsePropTypeAnimation(a,b,c);m&&this.onHandlePropTypeAnimation(a,b,k,h,c);break;case CCB_PROPTYPE_TEXTURE:h=this.parsePropTypeTexture(a,b,c);m&&this.onHandlePropTypeTexture(a,b,k,h,c);break;case CCB_PROPTYPE_BYTE:h=this.parsePropTypeByte(a,b,c,k);m&&this.onHandlePropTypeByte(a,b,k,h,c);break;case CCB_PROPTYPE_COLOR3:h=
this.parsePropTypeColor3(a,b,c,k);m&&this.onHandlePropTypeColor3(a,b,k,h,c);break;case CCB_PROPTYPE_COLOR4VAR:h=this.parsePropTypeColor4FVar(a,b,c);m&&this.onHandlePropTypeColor4FVar(a,b,k,h,c);break;case CCB_PROPTYPE_FLIP:h=this.parsePropTypeFlip(a,b,c);m&&this.onHandlePropTypeFlip(a,b,k,h,c);break;case CCB_PROPTYPE_BLENDMODE:h=this.parsePropTypeBlendFunc(a,b,c);m&&this.onHandlePropTypeBlendFunc(a,b,k,h,c);break;case CCB_PROPTYPE_FNTFILE:h=c.getCCBRootPath()+this.parsePropTypeFntFile(a,b,c);m&&this.onHandlePropTypeFntFile(a,
b,k,h,c);break;case CCB_PROPTYPE_FONTTTF:h=this.parsePropTypeFontTTF(a,b,c);m&&this.onHandlePropTypeFontTTF(a,b,k,h,c);break;case CCB_PROPTYPE_STRING:h=this.parsePropTypeString(a,b,c);m&&this.onHandlePropTypeString(a,b,k,h,c);break;case CCB_PROPTYPE_TEXT:h=this.parsePropTypeText(a,b,c);m&&this.onHandlePropTypeText(a,b,k,h,c);break;case CCB_PROPTYPE_BLOCK:h=this.parsePropTypeBlock(a,b,c);m&&this.onHandlePropTypeBlock(a,b,k,h,c);break;case CCB_PROPTYPE_BLOCKCCCONTROL:h=this.parsePropTypeBlockCCControl(a,
b,c);m&&null!=h&&this.onHandlePropTypeBlockCCControl(a,b,k,h,c);break;case CCB_PROPTYPE_CCBFILE:h=this.parsePropTypeCCBFile(a,b,c);m&&this.onHandlePropTypeCCBFile(a,b,k,h,c);break;default:ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(h)}}},getCustomProperties:function(){return this._customProperties},_createCCNode:function(a,b){return new cc.Node},parsePropTypePosition:function(a,b,c,d){var e=c.readFloat(),f=c.readFloat(),g=c.readInt(!1),h=c.getAnimationManager().getContainerSize(b);b=cc._getAbsolutePosition(e,
f,g,h,d);if(a.setPosition(cc.getAbsolutePosition(b,g,h,d)),-1<c.getAnimatedProperties().indexOf(d))e=[e,f,g],c.getAnimationManager().setBaseValue(e,a,d);return b},parsePropTypePoint:function(a,b,c){a=c.readFloat();c=c.readFloat();return cc.p(a,c)},parsePropTypePointLock:function(a,b,c){a=c.readFloat();c=c.readFloat();return cc.p(a,c)},parsePropTypeSize:function(a,b,c){a=c.readFloat();var d=c.readFloat(),e=c.readInt(!1);b=c.getAnimationManager().getContainerSize(b);switch(e){case CCB_SIZETYPE_ABSOLUTE:break;
case CCB_SIZETYPE_RELATIVE_CONTAINER:a=b.width-a;d=b.height-d;break;case CCB_SIZETYPE_PERCENT:a=b.width*a/100;d=b.height*d/100;break;case CCB_SIZETYPE_HORIZONTAL_PERCENT:a=b.width*a/100;break;case CCB_SIZETYPE_VERTICAL_PERCENT:d=b.height*d/100;break;case CCB_SIZETYPE_MULTIPLY_RESOLUTION:b=cc.BuilderReader.getResolutionScale();a*=b;d*=b;break;default:cc.log("Unknown CCB type.")}return cc.size(a,d)},parsePropTypeScaleLock:function(a,b,c,d){b=c.readFloat();var e=c.readFloat(),f=c.readInt(!1);return cc.setRelativeScale(a,
b,e,f,d),-1<c.getAnimatedProperties().indexOf(d)&&c.getAnimationManager().setBaseValue([b,e,f],a,d),f===CCB_SCALETYPE_MULTIPLY_RESOLUTION&&(b*=cc.BuilderReader.getResolutionScale(),e*=cc.BuilderReader.getResolutionScale()),[b,e]},parsePropTypeFloat:function(a,b,c){return c.readFloat()},parsePropTypeDegrees:function(a,b,c,d){b=c.readFloat();return-1<c.getAnimatedProperties().indexOf(d)&&c.getAnimationManager().setBaseValue(b,a,d),b},parsePropTypeFloatScale:function(a,b,c){a=c.readFloat();return c.readInt(!1)===
CCB_SCALETYPE_MULTIPLY_RESOLUTION&&(a*=cc.BuilderReader.getResolutionScale()),a},parsePropTypeInteger:function(a,b,c){return c.readInt(!0)},parsePropTypeIntegerLabeled:function(a,b,c){return c.readInt(!0)},parsePropTypeFloatVar:function(a,b,c){a=c.readFloat();c=c.readFloat();return[a,c]},parsePropTypeCheck:function(a,b,c,d){b=c.readBool();return-1<c.getAnimatedProperties().indexOf(d)&&c.getAnimationManager().setBaseValue(b,a,d),b},parsePropTypeSpriteFrame:function(a,b,c,d){var e;b=c.readCachedString();
var f=c.readCachedString();null!=f&&0!==f.length&&(0===b.length?(f=c.getCCBRootPath()+f,e=cc.textureCache.addImage(f),b=e.getContentSize(),b=cc.rect(0,0,b.width,b.height),e=new cc.SpriteFrame(e,b)):(e=cc.spriteFrameCache,b=c.getCCBRootPath()+b,-1===c.getLoadedSpriteSheet().indexOf(b)&&(e.addSpriteFrames(b),c.getLoadedSpriteSheet().push(b)),e=e.getSpriteFrame(f)),-1<c.getAnimatedProperties().indexOf(d)&&c.getAnimationManager().setBaseValue(e,a,d));return e},parsePropTypeAnimation:function(a,b,c){a=
c.getCCBRootPath()+c.readCachedString();c=c.readCachedString();b=null;if(c=cc.BuilderReader.lastPathComponent(c),a=cc.BuilderReader.lastPathComponent(a),null!=c&&""!==c)b=cc.animationCache,b.addAnimations(a),b=b.getAnimation(c);return b},parsePropTypeTexture:function(a,b,c){a=c.getCCBRootPath()+c.readCachedString();return""!==a?cc.textureCache.addImage(a):null},parsePropTypeByte:function(a,b,c,d){b=c.readByte();return-1<c.getAnimatedProperties().indexOf(d)&&c.getAnimationManager().setBaseValue(b,
a,d),b},parsePropTypeColor3:function(a,b,c,d){b=c.readByte();var e=c.readByte(),f=c.readByte();b={r:b,g:e,b:f};return-1<c.getAnimatedProperties().indexOf(d)&&c.getAnimationManager().setBaseValue(cc.Color3BWapper.create(b),a,d),b},parsePropTypeColor4FVar:function(a,b,c){a=0|255*c.readFloat();b=0|255*c.readFloat();var d=0|255*c.readFloat(),e=c.readFloat(),e=1>=e?0|255*e:e,f=0|255*c.readFloat(),g=0|255*c.readFloat(),h=0|255*c.readFloat();c=c.readFloat();var k=[];return k[0]={r:a,g:b,b:d,a:e},k[1]={r:f,
g:g,b:h,a:1>=c?0|255*c:c},k},parsePropTypeFlip:function(a,b,c){a=c.readBool();c=c.readBool();return[a,c]},parsePropTypeBlendFunc:function(a,b,c){a=c.readInt(!1);c=c.readInt(!1);return new cc.BlendFunc(a,c)},parsePropTypeFntFile:function(a,b,c){return c.readCachedString()},parsePropTypeString:function(a,b,c){return c.readCachedString()},parsePropTypeText:function(a,b,c){return c.readCachedString()},parsePropTypeFontTTF:function(a,b,c){return c.readCachedString()},parsePropTypeBlock:function(a,b,c){b=
c.readCachedString();var d=c.readInt(!1);if(d!==CCB_TARGETTYPE_NONE){var e=null;if(c.isJSControlled())d===CCB_TARGETTYPE_DOCUMENTROOT?(c.addDocumentCallbackNode(a),c.addDocumentCallbackName(b),c.addDocumentCallbackControlEvents(0)):(c.addOwnerCallbackNode(a),c.addOwnerCallbackName(b),c.addOwnerCallbackControlEvents(0));else if(d===CCB_TARGETTYPE_DOCUMENTROOT?e=c.getAnimationManager().getRootNode():d===CCB_TARGETTYPE_OWNER&&(e=c.getOwner()),null!==e)if(0<b.length){a=0;if(e.onResolveCCBCCMenuItemSelector&&
(a=e.onResolveCCBCCMenuItemSelector(e,b)),0===a)c=c.getCCBSelectorResolver(),null!=c&&(a=c.onResolveCCBCCMenuItemSelector(e,b));if(0!==a)return new BlockData(a,e);cc.log("Skipping selector '"+b+"' since no CCBSelectorResolver is present.")}else cc.log("Unexpected empty selector.");else cc.log("Unexpected NULL target for selector.")}return null},parsePropTypeBlockCCControl:function(a,b,c){b=c.readCachedString();var d=c.readInt(!1),e=c.readInt(!1);if(d!==CCB_TARGETTYPE_NONE)if(c.isJSControlled())d===
CCB_TARGETTYPE_DOCUMENTROOT?(c.addDocumentCallbackNode(a),c.addDocumentCallbackName(b),c.addDocumentCallbackControlEvents(e)):(c.addOwnerCallbackNode(a),c.addOwnerCallbackName(b),c.addOwnerCallbackControlEvents(e));else if(a=null,d===CCB_TARGETTYPE_DOCUMENTROOT?a=c.getAnimationManager().getRootNode():d===CCB_TARGETTYPE_OWNER&&(a=c.getOwner()),null!==a)if(0<b.length){d=0;if(a.onResolveCCBCCControlSelector&&(d=a.onResolveCCBCCControlSelector(a,b)),0===d)c=c.getCCBSelectorResolver(),null!=c&&(d=c.onResolveCCBCCControlSelector(a,
b));if(0!==d)return new BlockCCControlData(d,a,e);cc.log("Skipping selector '"+b+"' since no CCBSelectorResolver is present.")}else cc.log("Unexpected empty selector.");else cc.log("Unexpected NULL target for selector.");return null},parsePropTypeCCBFile:function(a,b,c){var d=c.getCCBRootPath()+c.readCachedString(),d=cc.BuilderReader.deletePathExtension(d)+".ccbi";a=new cc.BuilderReader(c);var e=cc.loader.getRes(d);e||(e=cc.loader.getUrl(d),e=cc.loader.loadBinarySync(e),cc.loader.cache[d]=e);a.initWithData(e,
c.getOwner());a.getAnimationManager().setRootContainerSize(b.getContentSize());a.setAnimationManagers(c.getAnimationManagers());a.getAnimationManager().setOwner(c.getOwner());b=a.readFileWithCleanUp(!1);return c.setAnimationManagers(a.getAnimationManagers()),b&&-1!==a.getAnimationManager().getAutoPlaySequenceId()&&a.getAnimationManager().runAnimations(a.getAnimationManager().getAutoPlaySequenceId(),0),b},parsePropTypeFloatXY:function(a,b,c){a=c.readFloat();c=c.readFloat();return[a,c]},onHandlePropTypePosition:function(a,
b,c,d,e){c===PROPERTY_POSITION?a.setPosition(d):ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypePoint:function(a,b,c,d,e){c===PROPERTY_ANCHORPOINT?a.setAnchorPoint(d):ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypePointLock:function(a,b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeSize:function(a,b,c,d,e){c===PROPERTY_CONTENTSIZE?a.setContentSize(d):ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeScaleLock:function(a,b,c,d,e){c===PROPERTY_SCALE?(a.setScaleX(d[0]),a.setScaleY(d[1])):
ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeFloatXY:function(a,b,c,d,e){c===PROPERTY_SKEW?(a.setSkewX(d[0]),a.setSkewY(d[1])):(b=c+"X",e=c+"Y",a[b]&&a[e]||ASSERT_FAIL_UNEXPECTED_PROPERTY(c),a[b](d[0]),a[e](d[1]))},onHandlePropTypeFloat:function(a,b,c,d,e){this._customProperties.setObject(d,c)},onHandlePropTypeDegrees:function(a,b,c,d,e){c===PROPERTY_ROTATION?a.setRotation(d):ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeFloatScale:function(a,b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},
onHandlePropTypeInteger:function(a,b,c,d,e){c===PROPERTY_TAG?a.setTag(d):ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeIntegerLabeled:function(a,b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeFloatVar:function(a,b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeCheck:function(a,b,c,d,e){c===PROPERTY_VISIBLE?a.setVisible(d):c===PROPERTY_IGNOREANCHORPOINTFORPOSITION?a.ignoreAnchorPointForPosition(d):ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeSpriteFrame:function(a,
b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeAnimation:function(a,b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeTexture:function(a,b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeByte:function(a,b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeColor3:function(a,b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeColor4FVar:function(a,b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeFlip:function(a,b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},
onHandlePropTypeBlendFunc:function(a,b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeFntFile:function(a,b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeString:function(a,b,c,d,e){this._customProperties.setObject(d,c)},onHandlePropTypeText:function(a,b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeFontTTF:function(a,b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeBlock:function(a,b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeBlockCCControl:function(a,
b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)},onHandlePropTypeCCBFile:function(a,b,c,d,e){ASSERT_FAIL_UNEXPECTED_PROPERTY(c)}});cc.NodeLoader.loader=function(){return new cc.NodeLoader};cc.NodeLoaderListener=cc.Class.extend({onNodeLoaded:function(a,b){}});cc.BuilderSelectorResolver=cc.Class.extend({onResolveCCBCCMenuItemSelector:function(a,b){},onResolveCCBCCCallFuncSelector:function(a,b){},onResolveCCBCCControlSelector:function(a,b){}});cc.BuilderScriptOwnerProtocol=cc.Class.extend({createNew:function(){}});
cc.BuilderMemberVariableAssigner=cc.Class.extend({onAssignCCBMemberVariable:function(a,b,c){return!1},onAssignCCBCustomProperty:function(a,b,c){return!1}});var PROPERTY_CCBFILE="ccbFile";cc.BuilderFileLoader=cc.NodeLoader.extend({_createCCNode:function(a,b){return cc.BuilderFile.create()},onHandlePropTypeCCBFile:function(a,b,c,d,e){c===PROPERTY_CCBFILE?a.setCCBFileNode(d):cc.NodeLoader.prototype.onHandlePropTypeCCBFile.call(this,a,b,c,d,e)}});cc.BuilderFileLoader.loader=function(){return new cc.BuilderFileLoader};
var PROPERTY_ENABLED="enabled",PROPERTY_SELECTED="selected",PROPERTY_CCCONTROL="ccControl";
cc.ControlLoader=cc.NodeLoader.extend({_createCCNode:function(a,b){},onHandlePropTypeBlockCCControl:function(a,b,c,d,e){c===PROPERTY_CCCONTROL?a.addTargetWithActionForControlEvents(d.target,d.selCCControlHandler,d.controlEvents):cc.NodeLoader.prototype.onHandlePropTypeBlockCCControl.call(this,a,b,c,d,e)},onHandlePropTypeCheck:function(a,b,c,d,e){c===PROPERTY_ENABLED?a.setEnabled(d):c===PROPERTY_SELECTED?a.setSelected(d):cc.NodeLoader.prototype.onHandlePropTypeCheck.call(this,a,b,c,d,e)}});
var PROPERTY_ZOOMONTOUCHDOWN="zoomOnTouchDown",PROPERTY_TITLE_NORMAL="title|1",PROPERTY_TITLE_HIGHLIGHTED="title|2",PROPERTY_TITLE_DISABLED="title|3",PROPERTY_TITLECOLOR_NORMAL="titleColor|1",PROPERTY_TITLECOLOR_HIGHLIGHTED="titleColor|2",PROPERTY_TITLECOLOR_DISABLED="titleColor|3",PROPERTY_TITLETTF_NORMAL="titleTTF|1",PROPERTY_TITLETTF_HIGHLIGHTED="titleTTF|2",PROPERTY_TITLETTF_DISABLED="titleTTF|3",PROPERTY_TITLETTFSIZE_NORMAL="titleTTFSize|1",PROPERTY_TITLETTFSIZE_HIGHLIGHTED="titleTTFSize|2",
PROPERTY_TITLETTFSIZE_DISABLED="titleTTFSize|4",PROPERTY_LABELANCHORPOINT="labelAnchorPoint",PROPERTY_PREFEREDSIZE="preferedSize",PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL="backgroundSpriteFrame|1",PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED="backgroundSpriteFrame|2",PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED="backgroundSpriteFrame|3";
cc.ControlButtonLoader=cc.ControlLoader.extend({_createCCNode:function(a,b){return new cc.ControlButton},onHandlePropTypeCheck:function(a,b,c,d,e){c===PROPERTY_ZOOMONTOUCHDOWN?a.setZoomOnTouchDown(d):cc.ControlLoader.prototype.onHandlePropTypeCheck.call(this,a,b,c,d,e)},onHandlePropTypeString:function(a,b,c,d,e){c===PROPERTY_TITLE_NORMAL?a.setTitleForState(d,cc.CONTROL_STATE_NORMAL):c===PROPERTY_TITLE_HIGHLIGHTED?a.setTitleForState(d,cc.CONTROL_STATE_HIGHLIGHTED):c===PROPERTY_TITLE_DISABLED?a.setTitleForState(d,
cc.CONTROL_STATE_DISABLED):cc.ControlLoader.prototype.onHandlePropTypeString.call(this,a,b,c,d,e)},onHandlePropTypeFontTTF:function(a,b,c,d,e){c===PROPERTY_TITLETTF_NORMAL?a.setTitleTTFForState(d,cc.CONTROL_STATE_NORMAL):c===PROPERTY_TITLETTF_HIGHLIGHTED?a.setTitleTTFForState(d,cc.CONTROL_STATE_HIGHLIGHTED):c===PROPERTY_TITLETTF_DISABLED?a.setTitleTTFForState(d,cc.CONTROL_STATE_DISABLED):cc.ControlLoader.prototype.onHandlePropTypeFontTTF.call(this,a,b,c,d,e)},onHandlePropTypeFloatScale:function(a,
b,c,d,e){c===PROPERTY_TITLETTFSIZE_NORMAL?a.setTitleTTFSizeForState(d,cc.CONTROL_STATE_NORMAL):c===PROPERTY_TITLETTFSIZE_HIGHLIGHTED?a.setTitleTTFSizeForState(d,cc.CONTROL_STATE_HIGHLIGHTED):c===PROPERTY_TITLETTFSIZE_DISABLED?a.setTitleTTFSizeForState(d,cc.CONTROL_STATE_DISABLED):cc.ControlLoader.prototype.onHandlePropTypeFloatScale.call(this,a,b,c,d,e)},onHandlePropTypePoint:function(a,b,c,d,e){c===PROPERTY_LABELANCHORPOINT?a.setLabelAnchorPoint(d):cc.ControlLoader.prototype.onHandlePropTypePoint.call(this,
a,b,c,d,e)},onHandlePropTypeSize:function(a,b,c,d,e){c===PROPERTY_PREFEREDSIZE?a.setPreferredSize(d):cc.ControlLoader.prototype.onHandlePropTypeSize.call(this,a,b,c,d,e)},onHandlePropTypeSpriteFrame:function(a,b,c,d,e){c===PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL?null!=d&&a.setBackgroundSpriteFrameForState(d,cc.CONTROL_STATE_NORMAL):c===PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED?null!=d&&a.setBackgroundSpriteFrameForState(d,cc.CONTROL_STATE_HIGHLIGHTED):c===PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED?null!=
d&&a.setBackgroundSpriteFrameForState(d,cc.CONTROL_STATE_DISABLED):cc.ControlLoader.prototype.onHandlePropTypeSpriteFrame.call(this,a,b,c,d,e)},onHandlePropTypeColor3:function(a,b,c,d,e){c===PROPERTY_TITLECOLOR_NORMAL?a.setTitleColorForState(d,cc.CONTROL_STATE_NORMAL):c===PROPERTY_TITLECOLOR_HIGHLIGHTED?a.setTitleColorForState(d,cc.CONTROL_STATE_HIGHLIGHTED):c===PROPERTY_TITLECOLOR_DISABLED?a.setTitleColorForState(d,cc.CONTROL_STATE_DISABLED):cc.ControlLoader.prototype.onHandlePropTypeColor3.call(this,
a,b,c,d,e)}});cc.ControlButtonLoader.loader=function(){return new cc.ControlButtonLoader};var PROPERTY_CONTAINER="container",PROPERTY_DIRECTION="direction",PROPERTY_CLIPSTOBOUNDS="clipsToBounds",PROPERTY_BOUNCES="bounces",PROPERTY_SCALE="scale";
cc.ScrollViewLoader=cc.NodeLoader.extend({_createCCNode:function(a,b){return new cc.ScrollView},onHandlePropTypeSize:function(a,b,c,d,e){c===PROPERTY_CONTENTSIZE?a.setViewSize(d):cc.NodeLoader.prototype.onHandlePropTypeSize.call(this,a,b,c,d,e)},onHandlePropTypeCCBFile:function(a,b,c,d,e){c===PROPERTY_CONTAINER?(a.setContainer(d),a.updateInset()):cc.NodeLoader.prototype.onHandlePropTypeCCBFile.call(this,a,b,c,d,e)},onHandlePropTypeCheck:function(a,b,c,d,e){c===PROPERTY_CLIPSTOBOUNDS?a.setClippingToBounds(d):
c===PROPERTY_BOUNCES?a.setBounceable(d):cc.NodeLoader.prototype.onHandlePropTypeCheck.call(this,a,b,c,d,e)},onHandlePropTypeFloat:function(a,b,c,d,e){c===PROPERTY_SCALE?a.setScale(d):cc.NodeLoader.prototype.onHandlePropTypeFloat.call(this,a,b,c,d,e)},onHandlePropTypeIntegerLabeled:function(a,b,c,d,e){c===PROPERTY_DIRECTION?a.setDirection(d):cc.NodeLoader.prototype.onHandlePropTypeIntegerLabeled.call(this,a,b,c,d,e)}});cc.ScrollViewLoader.loader=function(){return new cc.ScrollViewLoader};
var PROPERTY_CONTENTSIZE="contentSize",PROPERTY_SPRITEFRAME="spriteFrame",PROPERTY_COLOR="color",PROPERTY_OPACITY="opacity",PROPERTY_BLENDFUNC="blendFunc",PROPERTY_INSETLEFT="insetLeft",PROPERTY_INSETTOP="insetTop",PROPERTY_INSETRIGHT="insetRight",PROPERTY_INSETBOTTOM="insetBottom";
cc.Scale9SpriteLoader=cc.NodeLoader.extend({_createCCNode:function(a,b){var c=new cc.Scale9Sprite;return c.setAnchorPoint(0,0),c},onHandlePropTypeColor3:function(a,b,c,d,e){c===PROPERTY_COLOR?(255!==d.r||255!==d.g||255!==d.b)&&a.setColor(d):cc.NodeLoader.prototype.onHandlePropTypeColor3.call(this,a,b,c,d,e)},onHandlePropTypeByte:function(a,b,c,d,e){c===PROPERTY_OPACITY?a.setOpacity(d):cc.NodeLoader.prototype.onHandlePropTypeByte.call(this,a,b,c,d,e)},onHandlePropTypeBlendFunc:function(a,b,c,d,e){c===
PROPERTY_BLENDFUNC||cc.NodeLoader.prototype.onHandlePropTypeBlendFunc.call(this,a,b,c,d,e)},onHandlePropTypeSpriteFrame:function(a,b,c,d,e){c===PROPERTY_SPRITEFRAME?a.setSpriteFrame(d):cc.NodeLoader.prototype.onHandlePropTypeSpriteFrame.call(this,a,b,c,d,e)},onHandlePropTypeSize:function(a,b,c,d,e){c===PROPERTY_CONTENTSIZE||(c===PROPERTY_PREFEREDSIZE?a.setPreferredSize(d):cc.NodeLoader.prototype.onHandlePropTypeSize.call(this,a,b,c,d,e))},onHandlePropTypeFloat:function(a,b,c,d,e){c===PROPERTY_INSETLEFT?
a.setInsetLeft(d):c===PROPERTY_INSETTOP?a.setInsetTop(d):c===PROPERTY_INSETRIGHT?a.setInsetRight(d):c===PROPERTY_INSETBOTTOM?a.setInsetBottom(d):cc.NodeLoader.prototype.onHandlePropTypeFloat.call(this,a,b,c,d,e)}});cc.Scale9SpriteLoader.loader=function(){return new cc.Scale9SpriteLoader};var PROPERTY_FLIP="flip",PROPERTY_DISPLAYFRAME="displayFrame",PROPERTY_COLOR="color",PROPERTY_OPACITY="opacity",PROPERTY_BLENDFUNC="blendFunc";
cc.SpriteLoader=cc.NodeLoader.extend({_createCCNode:function(a,b){return new cc.Sprite},onHandlePropTypeColor3:function(a,b,c,d,e){c===PROPERTY_COLOR?(255!==d.r||255!==d.g||255!==d.b)&&a.setColor(d):cc.NodeLoader.prototype.onHandlePropTypeColor3.call(this,a,b,c,d,e)},onHandlePropTypeByte:function(a,b,c,d,e){c===PROPERTY_OPACITY?a.setOpacity(d):cc.NodeLoader.prototype.onHandlePropTypeByte.call(this,a,b,c,d,e)},onHandlePropTypeBlendFunc:function(a,b,c,d,e){c===PROPERTY_BLENDFUNC?a.setBlendFunc(d):cc.NodeLoader.prototype.onHandlePropTypeBlendFunc.call(this,
a,b,c,d,e)},onHandlePropTypeSpriteFrame:function(a,b,c,d,e){c===PROPERTY_DISPLAYFRAME?d?a.setSpriteFrame(d):cc.log("ERROR: SpriteFrame is null"):cc.NodeLoader.prototype.onHandlePropTypeSpriteFrame.call(this,a,b,c,d,e)},onHandlePropTypeFlip:function(a,b,c,d,e){c===PROPERTY_FLIP?(a.setFlippedX(d[0]),a.setFlippedY(d[1])):cc.NodeLoader.prototype.onHandlePropTypeFlip.call(this,a,b,c,d,e)}});cc.SpriteLoader.loader=function(){return new cc.SpriteLoader};
var PROPERTY_TOUCH_ENABLED="touchEnabled",PROPERTY_IS_TOUCH_ENABLED="isTouchEnabled",PROPERTY_ACCELEROMETER_ENABLED="accelerometerEnabled",PROPERTY_IS_ACCELEROMETER_ENABLED="isAccelerometerEnabled",PROPERTY_IS_MOUSE_ENABLED="isMouseEnabled",PROPERTY_MOUSE_ENABLED="mouseEnabled",PROPERTY_KEYBOARD_ENABLED="keyboardEnabled",PROPERTY_IS_KEYBOARD_ENABLED="isKeyboardEnabled";
cc.LayerLoader=cc.NodeLoader.extend({_createCCNode:function(a,b){var c=new cc.Layer;return c.setContentSize(0,0),c},onHandlePropTypeCheck:function(a,b,c,d,e){c===PROPERTY_TOUCH_ENABLED||c===PROPERTY_IS_TOUCH_ENABLED||c===PROPERTY_ACCELEROMETER_ENABLED||c===PROPERTY_IS_ACCELEROMETER_ENABLED||c===PROPERTY_MOUSE_ENABLED||c===PROPERTY_IS_MOUSE_ENABLED||(c===PROPERTY_KEYBOARD_ENABLED||c===PROPERTY_IS_KEYBOARD_ENABLED?a.setKeyboardEnabled&&!cc.sys.isNative?a.setKeyboardEnabled(d):cc.log("The property '"+
PROPERTY_IS_KEYBOARD_ENABLED+"' is not supported!"):cc.NodeLoader.prototype.onHandlePropTypeCheck.call(this,a,b,c,d,e))}});cc.LayerLoader.loader=function(){return new cc.LayerLoader};
cc.LayerColorLoader=cc.LayerLoader.extend({_createCCNode:function(a,b){return new cc.LayerColor},onHandlePropTypeColor3:function(a,b,c,d,e){c===PROPERTY_COLOR?a.setColor(d):cc.LayerLoader.prototype.onHandlePropTypeColor3.call(this,a,b,c,d,e)},onHandlePropTypeByte:function(a,b,c,d,e){c===PROPERTY_OPACITY?a.setOpacity(d):cc.LayerLoader.prototype.onHandlePropTypeByte.call(this,a,b,c,d,e)},onHandlePropTypeBlendFunc:function(a,b,c,d,e){c===PROPERTY_BLENDFUNC?a.setBlendFunc(d):cc.LayerLoader.prototype.onHandlePropTypeBlendFunc.call(this,
a,b,c,d,e)}});cc.LayerColorLoader.loader=function(){return new cc.LayerColorLoader};var PROPERTY_STARTCOLOR="startColor",PROPERTY_ENDCOLOR="endColor",PROPERTY_STARTOPACITY="startOpacity",PROPERTY_ENDOPACITY="endOpacity",PROPERTY_VECTOR="vector";
cc.LayerGradientLoader=cc.LayerLoader.extend({_createCCNode:function(a,b){return new cc.LayerGradient},onHandlePropTypeColor3:function(a,b,c,d,e){c===PROPERTY_STARTCOLOR?a.setStartColor(d):c===PROPERTY_ENDCOLOR?a.setEndColor(d):cc.LayerLoader.prototype.onHandlePropTypeColor3.call(this,a,b,c,d,e)},onHandlePropTypeByte:function(a,b,c,d,e){c===PROPERTY_STARTOPACITY?a.setStartOpacity(d):c===PROPERTY_ENDOPACITY?a.setEndOpacity(d):cc.LayerLoader.prototype.onHandlePropTypeByte.call(this,a,b,c,d,e)},onHandlePropTypePoint:function(a,
b,c,d,e){c===PROPERTY_VECTOR?a.setVector(d):cc.LayerLoader.prototype.onHandlePropTypePoint.call(this,a,b,c,d,e)},onHandlePropTypeBlendFunc:function(a,b,c,d,e){c===PROPERTY_BLENDFUNC?a.setBlendFunc(d):cc.LayerLoader.prototype.onHandlePropTypeBlendFunc.call(this,a,b,c,d,e)}});cc.LayerGradientLoader.loader=function(){return new cc.LayerGradientLoader};cc.MenuLoader=cc.LayerLoader.extend({_createCCNode:function(a,b){var c=new cc.Menu;return c.setContentSize(0,0),c}});cc.MenuLoader.loader=function(){return new cc.MenuLoader};
var PROPERTY_BLOCK="block",PROPERTY_ISENABLED="isEnabled";cc.MenuItemLoader=cc.NodeLoader.extend({_createCCNode:function(a,b){return null},onHandlePropTypeBlock:function(a,b,c,d,e){c===PROPERTY_BLOCK?null!=d&&a.setTarget(d.selMenuHander,d.target):cc.NodeLoader.prototype.onHandlePropTypeBlock.call(this,a,b,c,d,e)},onHandlePropTypeCheck:function(a,b,c,d,e){c===PROPERTY_ISENABLED?a.setEnabled(d):cc.NodeLoader.prototype.onHandlePropTypeCheck.call(this,a,b,c,d,e)}});
var PROPERTY_NORMALDISPLAYFRAME="normalSpriteFrame",PROPERTY_SELECTEDDISPLAYFRAME="selectedSpriteFrame",PROPERTY_DISABLEDDISPLAYFRAME="disabledSpriteFrame";
cc.MenuItemImageLoader=cc.MenuItemLoader.extend({_createCCNode:function(a,b){return new cc.MenuItemImage},onHandlePropTypeSpriteFrame:function(a,b,c,d,e){c===PROPERTY_NORMALDISPLAYFRAME?null!=d&&a.setNormalSpriteFrame(d):c===PROPERTY_SELECTEDDISPLAYFRAME?null!=d&&a.setSelectedSpriteFrame(d):c===PROPERTY_DISABLEDDISPLAYFRAME?null!=d&&a.setDisabledSpriteFrame(d):cc.MenuItemLoader.prototype.onHandlePropTypeSpriteFrame.call(this,a,b,c,d,e)}});cc.MenuItemImageLoader.loader=function(){return new cc.MenuItemImageLoader};
var PROPERTY_FONTNAME="fontName",PROPERTY_FONTSIZE="fontSize",PROPERTY_HORIZONTALALIGNMENT="horizontalAlignment",PROPERTY_VERTICALALIGNMENT="verticalAlignment",PROPERTY_STRING="string",PROPERTY_DIMENSIONS="dimensions";
cc.LabelTTFLoader=cc.NodeLoader.extend({_createCCNode:function(a,b){return new cc.LabelTTF},onHandlePropTypeColor3:function(a,b,c,d,e){c===PROPERTY_COLOR?(255!==d.r||255!==d.g||255!==d.b)&&a.setColor(d):cc.NodeLoader.prototype.onHandlePropTypeColor3.call(this,a,b,c,d,e)},onHandlePropTypeByte:function(a,b,c,d,e){c===PROPERTY_OPACITY?a.setOpacity(d):cc.NodeLoader.prototype.onHandlePropTypeByte.call(this,a,b,c,d,e)},onHandlePropTypeBlendFunc:function(a,b,c,d,e){c===PROPERTY_BLENDFUNC?a.setBlendFunc(d):
cc.NodeLoader.prototype.onHandlePropTypeBlendFunc.call(this,a,b,c,d,e)},onHandlePropTypeFontTTF:function(a,b,c,d,e){c===PROPERTY_FONTNAME?a.setFontName(d):cc.NodeLoader.prototype.onHandlePropTypeFontTTF.call(this,a,b,c,d,e)},onHandlePropTypeText:function(a,b,c,d,e){c===PROPERTY_STRING?a.setString(d):cc.NodeLoader.prototype.onHandlePropTypeText.call(this,a,b,c,d,e)},onHandlePropTypeFloatScale:function(a,b,c,d,e){c===PROPERTY_FONTSIZE?a.setFontSize(d):cc.NodeLoader.prototype.onHandlePropTypeFloatScale.call(this,
a,b,c,d,e)},onHandlePropTypeIntegerLabeled:function(a,b,c,d,e){c===PROPERTY_HORIZONTALALIGNMENT?a.setHorizontalAlignment(d):c===PROPERTY_VERTICALALIGNMENT?a.setVerticalAlignment(d):cc.NodeLoader.prototype.onHandlePropTypeIntegerLabeled.call(this,a,b,c,d,e)},onHandlePropTypeSize:function(a,b,c,d,e){c===PROPERTY_DIMENSIONS?a.setDimensions(d):cc.NodeLoader.prototype.onHandlePropTypeSize.call(this,a,b,c,d,e)}});cc.LabelTTFLoader.loader=function(){return new cc.LabelTTFLoader};var PROPERTY_FNTFILE="fntFile";
cc.LabelBMFontLoader=cc.NodeLoader.extend({_createCCNode:function(a,b){return new cc.LabelBMFont},onHandlePropTypeColor3:function(a,b,c,d,e){c===PROPERTY_COLOR?(255!==d.r||255!==d.g||255!==d.b)&&a.setColor(d):cc.NodeLoader.prototype.onHandlePropTypeColor3.call(this,a,b,c,d,e)},onHandlePropTypeByte:function(a,b,c,d,e){c===PROPERTY_OPACITY?a.setOpacity(d):cc.NodeLoader.prototype.onHandlePropTypeByte.call(this,a,b,c,d,e)},onHandlePropTypeBlendFunc:function(a,b,c,d,e){c===PROPERTY_BLENDFUNC?a.setBlendFunc(d):
cc.NodeLoader.prototype.onHandlePropTypeBlendFunc.call(this,a,b,c,d,e)},onHandlePropTypeFntFile:function(a,b,c,d,e){c===PROPERTY_FNTFILE?a.setFntFile(d):cc.NodeLoader.prototype.onHandlePropTypeFntFile.call(this,a,b,c,d,e)},onHandlePropTypeText:function(a,b,c,d,e){c===PROPERTY_STRING?a.setString(d):cc.NodeLoader.prototype.onHandlePropTypeText.call(this,a,b,c,d,e)}});cc.LabelBMFontLoader.loader=function(){return new cc.LabelBMFontLoader};
var PROPERTY_EMITERMODE="emitterMode",PROPERTY_POSVAR="posVar",PROPERTY_EMISSIONRATE="emissionRate",PROPERTY_DURATION="duration",PROPERTY_TOTALPARTICLES="totalParticles",PROPERTY_LIFE="life",PROPERTY_STARTSIZE="startSize",PROPERTY_ENDSIZE="endSize",PROPERTY_STARTSPIN="startSpin",PROPERTY_ENDSPIN="endSpin",PROPERTY_ANGLE="angle",PROPERTY_GRAVITY="gravity",PROPERTY_SPEED="speed",PROPERTY_TANGENTIALACCEL="tangentialAccel",PROPERTY_RADIALACCEL="radialAccel",PROPERTY_TEXTURE="texture",PROPERTY_STARTRADIUS=
"startRadius",PROPERTY_ENDRADIUS="endRadius",PROPERTY_ROTATEPERSECOND="rotatePerSecond";
cc.ParticleSystemLoader=cc.NodeLoader.extend({_createCCNode:function(a,b){return new cc.ParticleSystem},onHandlePropTypeIntegerLabeled:function(a,b,c,d,e){c===PROPERTY_EMITERMODE?a.setEmitterMode(d):cc.NodeLoader.prototype.onHandlePropTypeIntegerLabeled.call(this,a,b,c,d,e)},onHandlePropTypePoint:function(a,b,c,d,e){c===PROPERTY_POSVAR?a.setPosVar(d):c===PROPERTY_GRAVITY?a.setGravity(d):cc.NodeLoader.prototype.onHandlePropTypePoint.call(this,a,b,c,d,e)},onHandlePropTypeFloat:function(a,b,c,d,e){c===
PROPERTY_EMISSIONRATE?a.setEmissionRate(d):c===PROPERTY_DURATION?a.setDuration(d):cc.NodeLoader.prototype.onHandlePropTypeFloat.call(this,a,b,c,d,e)},onHandlePropTypeInteger:function(a,b,c,d,e){c===PROPERTY_TOTALPARTICLES?a.setTotalParticles(d):cc.NodeLoader.prototype.onHandlePropTypeInteger.call(this,a,b,c,d,e)},onHandlePropTypeFloatVar:function(a,b,c,d,e){c===PROPERTY_LIFE?(a.setLife(d[0]),a.setLifeVar(d[1])):c===PROPERTY_STARTSIZE?(a.setStartSize(d[0]),a.setStartSizeVar(d[1])):c===PROPERTY_ENDSIZE?
(a.setEndSize(d[0]),a.setEndSizeVar(d[1])):c===PROPERTY_STARTSPIN?(a.setStartSpin(d[0]),a.setStartSpinVar(d[1])):c===PROPERTY_ENDSPIN?(a.setEndSpin(d[0]),a.setEndSpinVar(d[1])):c===PROPERTY_ANGLE?(a.setAngle(d[0]),a.setAngleVar(d[1])):c===PROPERTY_SPEED?(a.setSpeed(d[0]),a.setSpeedVar(d[1])):c===PROPERTY_TANGENTIALACCEL?(a.setTangentialAccel(d[0]),a.setTangentialAccelVar(d[1])):c===PROPERTY_RADIALACCEL?(a.setRadialAccel(d[0]),a.setRadialAccelVar(d[1])):c===PROPERTY_STARTRADIUS?(a.setStartRadius(d[0]),
a.setStartRadiusVar(d[1])):c===PROPERTY_ENDRADIUS?(a.setEndRadius(d[0]),a.setEndRadiusVar(d[1])):c===PROPERTY_ROTATEPERSECOND?(a.setRotatePerSecond(d[0]),a.setRotatePerSecondVar(d[1])):cc.NodeLoader.prototype.onHandlePropTypeFloatVar.call(this,a,b,c,d,e)},onHandlePropTypeColor4FVar:function(a,b,c,d,e){c===PROPERTY_STARTCOLOR?(a.setStartColor(d[0]),a.setStartColorVar(d[1])):c===PROPERTY_ENDCOLOR?(a.setEndColor(d[0]),a.setEndColorVar(d[1])):cc.NodeLoader.prototype.onHandlePropTypeColor4FVar.call(this,
a,b,c,d,e)},onHandlePropTypeBlendFunc:function(a,b,c,d,e){c===PROPERTY_BLENDFUNC?a.setBlendFunc(d):cc.NodeLoader.prototype.onHandlePropTypeBlendFunc.call(this,a,b,c,d,e)},onHandlePropTypeTexture:function(a,b,c,d,e){c===PROPERTY_TEXTURE?a.setTexture(d):cc.NodeLoader.prototype.onHandlePropTypeTexture.call(this,a,b,c,d,e)}});cc.ParticleSystemLoader.loader=function(){return new cc.ParticleSystemLoader};
cc.NodeLoaderLibrary=cc.Class.extend({_ccNodeLoaders:null,ctor:function(){this._ccNodeLoaders={}},registerDefaultCCNodeLoaders:function(){this.registerCCNodeLoader("CCNode",cc.NodeLoader.loader());this.registerCCNodeLoader("CCLayer",cc.LayerLoader.loader());this.registerCCNodeLoader("CCLayerColor",cc.LayerColorLoader.loader());this.registerCCNodeLoader("CCLayerGradient",cc.LayerGradientLoader.loader());this.registerCCNodeLoader("CCSprite",cc.SpriteLoader.loader());this.registerCCNodeLoader("CCLabelBMFont",
cc.LabelBMFontLoader.loader());this.registerCCNodeLoader("CCLabelTTF",cc.LabelTTFLoader.loader());this.registerCCNodeLoader("CCScale9Sprite",cc.Scale9SpriteLoader.loader());this.registerCCNodeLoader("CCScrollView",cc.ScrollViewLoader.loader());this.registerCCNodeLoader("CCBFile",cc.BuilderFileLoader.loader());this.registerCCNodeLoader("CCMenu",cc.MenuLoader.loader());this.registerCCNodeLoader("CCMenuItemImage",cc.MenuItemImageLoader.loader());this.registerCCNodeLoader("CCControlButton",cc.ControlButtonLoader.loader());
this.registerCCNodeLoader("CCParticleSystemQuad",cc.ParticleSystemLoader.loader())},registerCCNodeLoader:function(a,b){this._ccNodeLoaders[a]=b},unregisterCCNodeLoader:function(a){this._ccNodeLoaders[a]&&delete this._ccNodeLoaders[a]},getCCNodeLoader:function(a){return this._ccNodeLoaders[a]?this._ccNodeLoaders[a]:null},purge:function(a){if(a)for(var b in this._ccNodeLoaders)delete this._ccNodeLoaders[b];this._ccNodeLoaders={}}});cc.NodeLoaderLibrary.sSharedCCNodeLoaderLibrary=null;
cc.NodeLoaderLibrary.library=function(){return new cc.NodeLoaderLibrary};cc.NodeLoaderLibrary.sharedCCNodeLoaderLibrary=function(){return null==cc.NodeLoaderLibrary.sSharedCCNodeLoaderLibrary&&(cc.NodeLoaderLibrary.sSharedCCNodeLoaderLibrary=new cc.NodeLoaderLibrary,cc.NodeLoaderLibrary.sSharedCCNodeLoaderLibrary.registerDefaultCCNodeLoaders()),cc.NodeLoaderLibrary.sSharedCCNodeLoaderLibrary};
cc.NodeLoaderLibrary.purgeSharedCCNodeLoaderLibrary=function(){cc.NodeLoaderLibrary.sSharedCCNodeLoaderLibrary=null};cc.NodeLoaderLibrary.newDefaultCCNodeLoaderLibrary=function(){var a=cc.NodeLoaderLibrary.library();return a.registerDefaultCCNodeLoaders(),a};
var CCB_VERSION=5,CCB_PROPTYPE_POSITION=0,CCB_PROPTYPE_SIZE=1,CCB_PROPTYPE_POINT=2,CCB_PROPTYPE_POINTLOCK=3,CCB_PROPTYPE_SCALELOCK=4,CCB_PROPTYPE_DEGREES=5,CCB_PROPTYPE_INTEGER=6,CCB_PROPTYPE_FLOAT=7,CCB_PROPTYPE_FLOATVAR=8,CCB_PROPTYPE_CHECK=9,CCB_PROPTYPE_SPRITEFRAME=10,CCB_PROPTYPE_TEXTURE=11,CCB_PROPTYPE_BYTE=12,CCB_PROPTYPE_COLOR3=13,CCB_PROPTYPE_COLOR4VAR=14,CCB_PROPTYPE_FLIP=15,CCB_PROPTYPE_BLENDMODE=16,CCB_PROPTYPE_FNTFILE=17,CCB_PROPTYPE_TEXT=18,CCB_PROPTYPE_FONTTTF=19,CCB_PROPTYPE_INTEGERLABELED=
20,CCB_PROPTYPE_BLOCK=21,CCB_PROPTYPE_ANIMATION=22,CCB_PROPTYPE_CCBFILE=23,CCB_PROPTYPE_STRING=24,CCB_PROPTYPE_BLOCKCCCONTROL=25,CCB_PROPTYPE_FLOATSCALE=26,CCB_PROPTYPE_FLOATXY=27,CCB_FLOAT0=0,CCB_FLOAT1=1,CCB_FLOAT_MINUS1=2,CCB_FLOAT05=3,CCB_FLOAT_INTEGER=4,CCB_FLOAT_FULL=5,CCB_PLATFORM_ALL=0,CCB_PLATFORM_IOS=1,CCB_PLATFORM_MAC=2,CCB_TARGETTYPE_NONE=0,CCB_TARGETTYPE_DOCUMENTROOT=1,CCB_TARGETTYPE_OWNER=2,CCB_KEYFRAME_EASING_INSTANT=0,CCB_KEYFRAME_EASING_LINEAR=1,CCB_KEYFRAME_EASING_CUBIC_IN=2,CCB_KEYFRAME_EASING_CUBIC_OUT=
3,CCB_KEYFRAME_EASING_CUBIC_INOUT=4,CCB_KEYFRAME_EASING_ELASTIC_IN=5,CCB_KEYFRAME_EASING_ELASTIC_OUT=6,CCB_KEYFRAME_EASING_ELASTIC_INOUT=7,CCB_KEYFRAME_EASING_BOUNCE_IN=8,CCB_KEYFRAME_EASING_BOUNCE_OUT=9,CCB_KEYFRAME_EASING_BOUNCE_INOUT=10,CCB_KEYFRAME_EASING_BACK_IN=11,CCB_KEYFRAME_EASING_BACK_OUT=12,CCB_KEYFRAME_EASING_BACK_INOUT=13,CCB_POSITIONTYPE_RELATIVE_BOTTOM_LEFT=0,CCB_POSITIONTYPE_RELATIVE_TOP_LEFT=1,CCB_POSITIONTYPE_RELATIVE_TOP_RIGHT=2,CCB_POSITIONTYPE_RELATIVE_BOTTOM_RIGHT=3,CCB_POSITIONTYPE_PERCENT=
4,CCB_POSITIONTYPE_MULTIPLY_RESOLUTION=5,CCB_SIZETYPE_ABSOLUTE=0,CCB_SIZETYPE_PERCENT=1,CCB_SIZETYPE_RELATIVE_CONTAINER=2,CCB_SIZETYPE_HORIZONTAL_PERCENT=3,CCB_SIZETYPE_VERTICAL_PERCENT=4,CCB_SIZETYPE_MULTIPLY_RESOLUTION=5,CCB_SCALETYPE_ABSOLUTE=0,CCB_SCALETYPE_MULTIPLY_RESOLUTION=1;cc.BuilderFile=cc.Node.extend({_ccbFileNode:null,getCCBFileNode:function(){return this._ccbFileNode},setCCBFileNode:function(a){this._ccbFileNode=a}});cc.BuilderFile.create=function(){return new cc.BuilderFile};
cc.BuilderReader=cc.Class.extend({_jsControlled:!1,_data:null,_ccbRootPath:"",_bytes:0,_currentByte:0,_currentBit:0,_stringCache:null,_loadedSpriteSheets:null,_owner:null,_animationManager:null,_animationManagers:null,_animatedProps:null,_ccNodeLoaderLibrary:null,_ccNodeLoaderListener:null,_ccbMemberVariableAssigner:null,_ccbSelectorResolver:null,_ownerOutletNames:null,_ownerOutletNodes:null,_nodesWithAnimationManagers:null,_animationManagerForNodes:null,_ownerCallbackNames:null,_ownerCallbackNodes:null,
_ownerCallbackEvents:null,_readNodeGraphFromData:!1,ctor:function(a,b,c,d){if(this._stringCache=[],this._loadedSpriteSheets=[],this._currentBit=-1,this._currentByte=-1,0!==arguments.length)a instanceof cc.BuilderReader?(this._loadedSpriteSheets=a._loadedSpriteSheets,this._ccNodeLoaderLibrary=a._ccNodeLoaderLibrary,this._ccbMemberVariableAssigner=a._ccbMemberVariableAssigner,this._ccbSelectorResolver=a._ccbSelectorResolver,this._ccNodeLoaderListener=a._ccNodeLoaderListener,this._ownerCallbackNames=
a._ownerCallbackNames,this._ownerCallbackNodes=a._ownerCallbackNodes,this._ownerCallbackEvents=a._ownerCallbackEvents,this._ownerOutletNames=a._ownerOutletNames,this._ownerOutletNodes=a._ownerOutletNodes,this._ccbRootPath=a._ccbRootPath):(this._ccNodeLoaderLibrary=a,this._ccbMemberVariableAssigner=b,this._ccbSelectorResolver=c,this._ccNodeLoaderListener=d)},getCCBRootPath:function(){return this._ccbRootPath},setCCBRootPath:function(a){this._ccbRootPath=a},initWithData:function(a,b){return this._animationManager=
new cc.BuilderAnimationManager,this._data=a,this._bytes=a.length,this._currentBit=0,this._currentByte=0,this._owner=b,this._animationManager.setRootContainerSize(cc.director.getWinSize()),!0},_loadBinarySync:function(a){var b=this.getXMLHttpRequest(),c="load "+a+" failed!";b.open("GET",a,!1);var d=null;if(/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)){if(b.setRequestHeader("Accept-Charset","x-user-defined"),b.send(null),200!==b.status)return cc.log(c),null;(b=cc._convertResponseBodyToText(b.responseBody))&&
(d=this._stringConvertToArray(b),this._fileDataCache[a]=d)}else{if(b.overrideMimeType&&b.overrideMimeType("text/plain; charset\x3dx-user-defined"),b.send(null),200!==b.status)return cc.log(c),null;d=this._stringConvertToArray(b.responseText);this._fileDataCache[a]=d}return d},readNodeGraphFromFile:function(a,b,c,d){null==c?c=cc.director.getWinSize():c instanceof cc.BuilderAnimationManager&&(d=c,c=cc.director.getWinSize());var e=cc.loader.getRes(a);e||(e=cc.loader.getUrl(a),e=cc.loader.loadBinarySync(e),
cc.loader.cache[a]=e);return this.readNodeGraphFromData(e,b,c,d)},readNodeGraphFromData:function(a,b,c){this.initWithData(a,b);a=this._animationManager;a.setRootContainerSize(c);a.setOwner(b);this._ownerOutletNames=[];this._ownerOutletNodes=[];this._ownerCallbackNames=[];this._ownerCallbackNodes=[];this._ownerCallbackEvents=[];this._animationManagers=new cc._Dictionary;b=this.readFileWithCleanUp(!0);if(b&&-1!==a.getAutoPlaySequenceId()&&a.runAnimations(a.getAutoPlaySequenceId(),0),this._jsControlled){c=
[];a=[];for(var d=this._animationManagers,e=d.allKeys(),f=0;f<e.length;f++)c.push(e[f]),a.push(d.objectForKey(e[f]));this._nodesWithAnimationManagers=c;this._animationManagerForNodes=a}return b},createSceneWithNodeGraphFromFile:function(a,b,c,d){a=this.readNodeGraphFromFile(a,b,c,d);b=new cc.Scene;return b.addChild(a),b},getCCBMemberVariableAssigner:function(){return this._ccbMemberVariableAssigner},getCCBSelectorResolver:function(){return this._ccbSelectorResolver},getAnimationManager:function(){return this._animationManager},
setAnimationManager:function(a){this._animationManager=a},getAnimatedProperties:function(){return this._animatedProps},getLoadedSpriteSheet:function(){return this._loadedSpriteSheets},getOwner:function(){return this._owner},readInt:function(a){for(var b=0;!this._getBit();)b++;for(var c=0,d=b-1;0<=d;d--)this._getBit()&&(c|=1<<d);c|=1<<b;return this._alignBits(),a?c%2?0|c/2:0|-c/2:c-1},readByte:function(){var a=this._data[this._currentByte];return this._currentByte++,a},readBool:function(){return 0!==
this.readByte()},readFloat:function(){switch(this.readByte()){case CCB_FLOAT0:return 0;case CCB_FLOAT1:return 1;case CCB_FLOAT_MINUS1:return-1;case CCB_FLOAT05:return 0.5;case CCB_FLOAT_INTEGER:return this.readInt(!0);default:return this._decodeFloat(23,8)}},_decodeFloat:function(a,b){var c=a+b+1,d=c>>3;this._checkSize(c);var c=Math.pow(2,b-1)-1,e=this._readBitsOnly(a+b,1,d),f=this._readBitsOnly(a,b,d),g=0,h=2,k=0;do for(var m=this._readByteOnly(++k,d),n=a%8||8,p=1<<n;p>>=1;)m&p&&(g+=1/h),h*=2;while(a-=
n);return this._currentByte+=d,f===(c<<1)+1?g?0/0:e?-(1/0):+(1/0):(1+-2*e)*(f||g?f?Math.pow(2,f-c)*(1+g):Math.pow(2,-c+1)*g:0)},_readBitsOnly:function(a,b,c){var d=(a+b)%8,e=a%8,f=c-(a>>3)-1;a=c+(-(a+b)>>3);var g=f-a;b=this._readByteOnly(f,c)>>e&(1<<(g?8-e:b))-1;for(g&&d&&(b+=(this._readByteOnly(a++,c)&(1<<d)-1)<<(g--<<3)-e);g;)b+=this._shl(this._readByteOnly(a++,c),(g--<<3)-e);return b},_readByteOnly:function(a,b){return this._data[this._currentByte+b-a-1]},_shl:function(a,b){for(++b;--b;a=1073741824===
(1073741824&(a%=2147483648))?2*a:2*(a-1073741824)+2147483648);return a},_checkSize:function(a){if(!(this._currentByte+Math.ceil(a/8)<this._data.length))throw Error("Index out of bound");},readCachedString:function(){return this._stringCache[this.readInt(!1)]},isJSControlled:function(){return this._jsControlled},getOwnerCallbackNames:function(){return this._ownerCallbackNames},getOwnerCallbackNodes:function(){return this._ownerCallbackNodes},getOwnerCallbackControlEvents:function(){return this._ownerCallbackEvents},
getOwnerOutletNames:function(){return this._ownerOutletNames},getOwnerOutletNodes:function(){return this._ownerOutletNodes},getNodesWithAnimationManagers:function(){return this._nodesWithAnimationManagers},getAnimationManagersForNodes:function(){return this._animationManagerForNodes},getAnimationManagers:function(){return this._animationManagers},setAnimationManagers:function(a){this._animationManagers=a},addOwnerCallbackName:function(a){this._ownerCallbackNames.push(a)},addOwnerCallbackNode:function(a){this._ownerCallbackNodes.push(a)},
addOwnerCallbackControlEvents:function(a){this._ownerCallbackEvents.push(a)},addDocumentCallbackName:function(a){this._animationManager.addDocumentCallbackName(a)},addDocumentCallbackNode:function(a){this._animationManager.addDocumentCallbackNode(a)},addDocumentCallbackControlEvents:function(a){this._animationManager.addDocumentCallbackControlEvents(a)},readFileWithCleanUp:function(a){if(!this._readHeader()||!this._readStringCache()||!this._readSequences())return null;var b=this._readNodeGraph();
return this._animationManagers.setObject(this._animationManager,b),a&&this._cleanUpNodeGraph(b),b},addOwnerOutletName:function(a){this._ownerOutletNames.push(a)},addOwnerOutletNode:function(a){null!=a&&this._ownerOutletNodes.push(a)},_cleanUpNodeGraph:function(a){a.userObject=null;a=a.getChildren();for(var b=0,c=a.length;c>b;b++)this._cleanUpNodeGraph(a[b])},_readCallbackKeyframesForSeq:function(a){var b=this.readInt(!1);if(!b)return!0;for(var c=new cc.BuilderSequenceProperty,d=this._jsControlled,
e=this._animationManager,f=c.getKeyframes(),g=0;b>g;g++){var h=this.readFloat(),k=this.readCachedString(),m=this.readInt(!1),n=[k,m],p=new cc.BuilderKeyframe;p.setTime(h);p.setValue(n);d&&e.getKeyframeCallbacks().push(m+":"+k);f.push(p)}return a.setCallbackChannel(c),!0},_readSoundKeyframesForSeq:function(a){var b=this.readInt(!1);if(!b)return!0;for(var c=new cc.BuilderSequenceProperty,d=c.getKeyframes(),e=0;b>e;e++){var f=this.readFloat(),g=this.readCachedString(),h=this.readFloat(),k=this.readFloat(),
m=this.readFloat(),g=[g,h,k,m],h=new cc.BuilderKeyframe;h.setTime(f);h.setValue(g);d.push(h)}return a.setSoundChannel(c),!0},_readSequences:function(){for(var a=this._animationManager.getSequences(),b=this.readInt(!1),c=0;b>c;c++){var d=new cc.BuilderSequence;if((d.setDuration(this.readFloat()),d.setName(this.readCachedString()),d.setSequenceId(this.readInt(!1)),d.setChainedSequenceId(this.readInt(!0)),!this._readCallbackKeyframesForSeq(d))||!this._readSoundKeyframesForSeq(d))return!1;a.push(d)}return this._animationManager.setAutoPlaySequenceId(this.readInt(!0)),
!0},readKeyframe:function(a){var b=new cc.BuilderKeyframe;b.setTime(this.readFloat());var c=this.readInt(!1),d=0,e=null;((c===CCB_KEYFRAME_EASING_CUBIC_IN||c===CCB_KEYFRAME_EASING_CUBIC_OUT||c===CCB_KEYFRAME_EASING_CUBIC_INOUT||c===CCB_KEYFRAME_EASING_ELASTIC_IN||c===CCB_KEYFRAME_EASING_ELASTIC_OUT||c===CCB_KEYFRAME_EASING_ELASTIC_INOUT)&&(d=this.readFloat()),b.setEasingType(c),b.setEasingOpt(d),a===CCB_PROPTYPE_CHECK)?e=this.readBool():a===CCB_PROPTYPE_BYTE?e=this.readByte():a===CCB_PROPTYPE_COLOR3?
(a=cc.color(this.readByte(),this.readByte(),this.readByte()),e=cc.Color3BWapper.create(a)):a===CCB_PROPTYPE_FLOATXY?e=[this.readFloat(),this.readFloat()]:a===CCB_PROPTYPE_DEGREES?e=this.readFloat():a===CCB_PROPTYPE_SCALELOCK||a===CCB_PROPTYPE_POSITION||a===CCB_PROPTYPE_FLOATXY?e=[this.readFloat(),this.readFloat()]:a===CCB_PROPTYPE_SPRITEFRAME&&(a=this.readCachedString(),c=this.readCachedString(),""===a?(c=this._ccbRootPath+c,a=cc.textureCache.addImage(c),c=a.getContentSize(),c=cc.rect(0,0,c.width,
c.height),e=new cc.SpriteFrame(a,c)):(a=this._ccbRootPath+a,d=cc.spriteFrameCache,-1===this._loadedSpriteSheets.indexOf(a)&&(d.addSpriteFrames(a),this._loadedSpriteSheets.push(a)),e=d.getSpriteFrame(c)));return b.setValue(e),b},_readHeader:function(){if(!this._data)return!1;var a=this._readStringFromBytes(this._currentByte,4,!0);if(this._currentByte+=4,"ccbi"!==a)return!1;a=this.readInt(!1);return a!==CCB_VERSION?(cc.log("WARNING! Incompatible ccbi file version (file: "+a+" reader: "+CCB_VERSION+
")"),!1):(this._jsControlled=this.readBool(),this._animationManager._jsControlled=this._jsControlled,!0)},_readStringFromBytes:function(a,b,c){a="";var d=this._data,e=this._currentByte;if(c)for(c=b-1;0<=c;c--)a+=String.fromCharCode(d[e+c]);else for(c=0;b>c;c++)a+=String.fromCharCode(d[e+c]);return a},_readStringCache:function(){for(var a=this.readInt(!1),b=0;a>b;b++)this._readStringCacheEntry();return!0},_readStringCacheEntry:function(){for(var a=this.readByte(),b=this.readByte(),a=a<<8|b,b="",c=
this._data,d=this._currentByte,e=0;a>e;e++)var f=c[d+e].toString("16").toUpperCase(),f=1<f.length?f:"0"+f,b=b+("%"+f);b=decodeURIComponent(b);this._currentByte+=a;this._stringCache.push(b)},_readNodeGraph:function(a){var b,c=this.readCachedString(),d=this._jsControlled,e=this._animationManager;d&&(b=this.readCachedString());var f,g=this.readInt(!1);g!==CCB_TARGETTYPE_NONE&&(f=this.readCachedString());(c=this._ccNodeLoaderLibrary.getCCNodeLoader(c))||(c=this._ccNodeLoaderLibrary.getCCNodeLoader("CCNode"));
var h=c.loadCCNode(a,this);e.getRootNode()||e.setRootNode(h);d&&h===e.getRootNode()&&e.setDocumentControllerName(b);var k=new cc._Dictionary,m=this._animatedProps=[],n=this.readInt(!1);for(b=0;n>b;++b){for(var p=this.readInt(!1),r=new cc._Dictionary,s=this.readInt(!1),v=0;s>v;++v){var u=new cc.BuilderSequenceProperty;u.setName(this.readCachedString());u.setType(this.readInt(!1));m.push(u.getName());for(var t=this.readInt(!1),x=u.getKeyframes(),A=0;t>A;++A){var F=this.readKeyframe(u.getType());x.push(F)}r.setObject(u,
u.getName())}k.setObject(r,p)}0<k.count()&&e.addNode(h,k);c.parseProperties(h,a,this);if(a=h instanceof cc.BuilderFile)b=h.getCCBFileNode(),b.setPosition(h.getPosition()),b.setRotation(h.getRotation()),b.setScaleX(h.getScaleX()),b.setScaleY(h.getScaleY()),b.setTag(h.getTag()),b.setVisible(!0),e.moveAnimationsFromNode(h,b),h.setCCBFileNode(null),h=b;m=k=null;if(g!==CCB_TARGETTYPE_NONE)if(d)g===CCB_TARGETTYPE_DOCUMENTROOT?(e.addDocumentOutletName(f),e.addDocumentOutletNode(h)):(this._ownerOutletNames.push(f),
this._ownerOutletNodes.push(h));else if(g===CCB_TARGETTYPE_DOCUMENTROOT?k=e.getRootNode():g===CCB_TARGETTYPE_OWNER&&(k=this._owner),!k)b=!1,k.onAssignCCBMemberVariable&&(b=k.onAssignCCBMemberVariable(k,f,h)),m=this._ccbMemberVariableAssigner,!b&&null!=m&&m.onAssignCCBMemberVariable&&m.onAssignCCBMemberVariable(k,f,h);if(0<c.getCustomProperties().length&&(f=!1,!d&&(k=h,null!=k&&null!=k.onAssignCCBCustomProperty))){d=c.getCustomProperties();e=d.allKeys();for(b=0;b<e.length;b++)g=d.objectForKey(e[b]),
f=k.onAssignCCBCustomProperty(k,e[b],g),m=this._ccbMemberVariableAssigner,f||null==m||null==m.onAssignCCBCustomProperty||m.onAssignCCBCustomProperty(k,e[b],g)}this._animatedProps=null;d=this.readInt(!1);for(b=0;d>b;b++)f=this._readNodeGraph(h),h.addChild(f);return a||(null!=h&&h.onNodeLoaded?h.onNodeLoaded(h,c):null!=this._ccNodeLoaderListener&&this._ccNodeLoaderListener.onNodeLoaded(h,c)),h},_getBit:function(){var a=0!==(this._data[this._currentByte]&1<<this._currentBit);if(this._currentBit++,8<=
this._currentBit&&(this._currentBit=0,this._currentByte++,this._currentByte>this._data.length))throw"out of the data bound";return a},_alignBits:function(){this._currentBit&&(this._currentBit=0,this._currentByte++)},_readUTF8:function(){}});cc.BuilderReader._ccbResolutionScale=1;cc.BuilderReader.setResolutionScale=function(a){cc.BuilderReader._ccbResolutionScale=a};cc.BuilderReader.getResolutionScale=function(){return cc.BuilderReader._ccbResolutionScale};
cc.BuilderReader.loadAsScene=function(a,b,c,d){d=d||cc.BuilderReader.getResourcePath();a=cc.BuilderReader.load(a,b,c,d);b=new cc.Scene;return b.addChild(a),b};cc.BuilderReader._controllerClassCache={};cc.BuilderReader.registerController=function(a,b){cc.BuilderReader._controllerClassCache[a]=cc.Class.extend(b)};
cc.BuilderReader.load=function(a,b,c,d){d=d||cc.BuilderReader.getResourcePath();var e=new cc.BuilderReader(cc.NodeLoaderLibrary.newDefaultCCNodeLoaderLibrary());e.setCCBRootPath(d);(5>a.length||a.toLowerCase().lastIndexOf(".ccbi")!==a.length-5)&&(a+=".ccbi");var f,g,h;c=e.readNodeGraphFromFile(a,b,c);if(b){d=e.getOwnerCallbackNames();var k=e.getOwnerCallbackNodes(),m=e.getOwnerCallbackControlEvents();for(a=0;a<d.length;a++)f=d[a],g=k[a],h=m[a],g instanceof cc.ControlButton?g.addTargetWithActionForControlEvents(b,
b[f],h):g.setCallback(b[f],b);d=e.getOwnerOutletNames();k=e.getOwnerOutletNodes();for(a=0;a<d.length;a++)f=d[a],g=k[a],b[f]=g}d=e.getNodesWithAnimationManagers();e=e.getAnimationManagersForNodes();if(!d||!e)return c;k=cc.BuilderReader._controllerClassCache;for(a=0;a<d.length;a++){var n;n=d[a];var p=e[a];n.animationManager=p;if(f=p.getDocumentControllerName()){m=k[f];if(!m)throw"Can not find controller : "+f;m=new m;m.controllerName=f;n.controller=m;m.rootNode=n;var r=p.getDocumentCallbackNames(),
s=p.getDocumentCallbackNodes(),v=p.getDocumentCallbackControlEvents();for(n=0;n<r.length;n++)f=r[n],g=s[n],h=v[n],g instanceof cc.ControlButton?g.addTargetWithActionForControlEvents(m,m[f],h):g.setCallback(m[f],m);h=p.getDocumentOutletNames();r=p.getDocumentOutletNodes();for(n=0;n<h.length;n++)f=h[n],g=r[n],m[f]=g;m.onDidLoadFromCCB&&cc.isFunction(m.onDidLoadFromCCB)&&m.onDidLoadFromCCB();f=p.getKeyframeCallbacks();for(n=0;n<f.length;n++)h=f[n].split(":"),g=h[0],h=h[1],1==g?p.setCallFunc(cc.callFunc(m[h],
m),f[n]):2==g&&b&&p.setCallFunc(cc.callFunc(b[h],b),f[n])}}return p.runAnimations(p.getAutoPlaySequenceId(),0),c};cc.BuilderReader._resourcePath="";cc.BuilderReader.setResourcePath=function(a){cc.BuilderReader._resourcePath=a};cc.BuilderReader.getResourcePath=function(){return cc.BuilderReader._resourcePath};cc.BuilderReader.lastPathComponent=function(a){var b=a.lastIndexOf("/");return-1!==b?a.substring(b+1,a.length-b):a};
cc.BuilderReader.deletePathExtension=function(a){var b=a.lastIndexOf(".");return-1!==b?a.substring(0,b):a};cc.BuilderReader.toLowerCase=function(a){return a.toLowerCase()};cc.BuilderReader.endsWith=function(a,b){return a.length>=b.length?0===a.lastIndexOf(b):!1};cc.BuilderReader.concat=function(a,b){return a+b};cc.loader.register(["ccbi"],cc._binaryLoader);cc.INT_VALUE=0;cc.FLOAT_VALUE=1;cc.POINTER_VALUE=2;cc.BOOL_VALUE=3;cc.UNSIGNEDCHAR_VALUE=4;
cc.Color3BWapper=cc.Class.extend({_color:null,ctor:function(){this._color=cc.color(0,0,0)},getColor:function(){return this._color}});cc.Color3BWapper.create=function(a){var b=new cc.Color3BWapper;return b&&(b._color.r=a.r,b._color.g=a.g,b._color.b=a.b),b};cc.BuilderValue=cc.Class.extend({_value:null,_type:0,getIntValue:function(){},getFloatValue:function(){},getBoolValue:function(){},getByteValue:function(){},getPointer:function(){},getValue:function(){return this._value}});
cc.BuilderValue.create=function(a){return new cc.BuilderValue};cc.BuilderKeyframe=cc.Class.extend({_value:null,_time:0,_easingType:0,_easingOpt:0,getValue:function(){return this._value},setValue:function(a){this._value=a},getTime:function(){return this._time},setTime:function(a){this._time=a},getEasingType:function(){return this._easingType},setEasingType:function(a){this._easingType=a},getEasingOpt:function(){return this._easingOpt},setEasingOpt:function(a){this._easingOpt=a}});
cc.BuilderSequence=cc.Class.extend({_duration:0,_name:"",_sequenceId:0,_chainedSequenceId:0,_callbackChannel:null,_soundChannel:null,ctor:function(){this._name=""},getDuration:function(){return this._duration},setDuration:function(a){this._duration=a},getName:function(){return this._name},setName:function(a){this._name=a},getSequenceId:function(){return this._sequenceId},setSequenceId:function(a){this._sequenceId=a},getChainedSequenceId:function(){return this._chainedSequenceId},setChainedSequenceId:function(a){this._chainedSequenceId=
a},getCallbackChannel:function(){return this._callbackChannel},setCallbackChannel:function(a){this._callbackChannel=a},getSoundChannel:function(){return this._soundChannel},setSoundChannel:function(a){this._soundChannel=a}});
cc.BuilderSequenceProperty=cc.Class.extend({_name:null,_type:0,_keyFrames:null,ctor:function(){this.init()},init:function(){this._keyFrames=[];this._name=""},getName:function(){return this._name},setName:function(a){this._name=a},getType:function(){return this._type},setType:function(a){this._type=a},getKeyframes:function(){return this._keyFrames}});
cc.getAbsolutePosition=function(a,b,c,d){d=cc.p(0,0);b===CCB_POSITIONTYPE_RELATIVE_BOTTOM_LEFT?d=a:b===CCB_POSITIONTYPE_RELATIVE_TOP_LEFT?(d.x=a.x,d.y=c.height-a.y):b===CCB_POSITIONTYPE_RELATIVE_TOP_RIGHT?(d.x=c.width-a.x,d.y=c.height-a.y):b===CCB_POSITIONTYPE_RELATIVE_BOTTOM_RIGHT?(d.x=c.width-a.x,d.y=a.y):b===CCB_POSITIONTYPE_PERCENT?(d.x=c.width*a.x/100,d.y=c.height*a.y/100):b===CCB_POSITIONTYPE_MULTIPLY_RESOLUTION&&(b=cc.BuilderReader.getResolutionScale(),d.x=a.x*b,d.y=a.y*b);return d};
cc._getAbsolutePosition=function(a,b,c,d,e){e=cc.p(0,0);c===CCB_POSITIONTYPE_RELATIVE_BOTTOM_LEFT?(e.x=a,e.y=b):c===CCB_POSITIONTYPE_RELATIVE_TOP_LEFT?(e.x=a,e.y=d.height-b):c===CCB_POSITIONTYPE_RELATIVE_TOP_RIGHT?(e.x=d.width-a,e.y=d.height-b):c===CCB_POSITIONTYPE_RELATIVE_BOTTOM_RIGHT?(e.x=d.width-a,e.y=b):c===CCB_POSITIONTYPE_PERCENT?(e.x=d.width*a/100,e.y=d.height*b/100):c===CCB_POSITIONTYPE_MULTIPLY_RESOLUTION&&(c=cc.BuilderReader.getResolutionScale(),e.x=a*c,e.y=b*c);return e};
cc.setRelativeScale=function(a,b,c,d,e){if(!a)throw"cc.setRelativeScale(): node should be non-null";d===CCB_POSITIONTYPE_MULTIPLY_RESOLUTION&&(d=cc.BuilderReader.getResolutionScale(),b*=d,c*=d);a.setScaleX(b);a.setScaleY(c)};cc.BuilderAnimationManagerDelegate=cc.Class.extend({completedAnimationSequenceNamed:function(a){}});
cc.BuilderAnimationManager=cc.Class.extend({_sequences:null,_nodeSequences:null,_baseValues:null,_autoPlaySequenceId:0,_rootNode:null,_owner:null,_rootContainerSize:null,_delegate:null,_runningSequence:null,_documentOutletNames:null,_documentOutletNodes:null,_documentCallbackNames:null,_documentCallbackNodes:null,_documentCallbackControlEvents:null,_documentControllerName:"",_lastCompletedSequenceName:"",_keyframeCallbacks:null,_keyframeCallFuncs:null,_animationCompleteCallbackFunc:null,_target:null,
_jsControlled:!1,ctor:function(){this._rootContainerSize=cc.size(0,0);this.init()},init:function(){return this._sequences=[],this._nodeSequences=new cc._Dictionary,this._baseValues=new cc._Dictionary,this._documentOutletNames=[],this._documentOutletNodes=[],this._documentCallbackNames=[],this._documentCallbackNodes=[],this._documentCallbackControlEvents=[],this._keyframeCallbacks=[],this._keyframeCallFuncs={},!0},getSequences:function(){return this._sequences},setSequences:function(a){this._sequences=
a},getAutoPlaySequenceId:function(){return this._autoPlaySequenceId},setAutoPlaySequenceId:function(a){this._autoPlaySequenceId=a},getRootNode:function(){return this._rootNode},setRootNode:function(a){this._rootNode=a},getOwner:function(){return this._owner},setOwner:function(a){this._owner=a},addDocumentCallbackNode:function(a){this._documentCallbackNodes.push(a)},addDocumentCallbackName:function(a){this._documentCallbackNames.push(a)},addDocumentCallbackControlEvents:function(a){this._documentCallbackControlEvents.push(a)},
addDocumentOutletNode:function(a){this._documentOutletNodes.push(a)},addDocumentOutletName:function(a){this._documentOutletNames.push(a)},setDocumentControllerName:function(a){this._documentControllerName=a},getDocumentControllerName:function(){return this._documentControllerName},getDocumentCallbackNames:function(){return this._documentCallbackNames},getDocumentCallbackNodes:function(){return this._documentCallbackNodes},getDocumentCallbackControlEvents:function(){return this._documentCallbackControlEvents},
getDocumentOutletNames:function(){return this._documentOutletNames},getDocumentOutletNodes:function(){return this._documentOutletNodes},getLastCompletedSequenceName:function(){return this._lastCompletedSequenceName},getKeyframeCallbacks:function(){return this._keyframeCallbacks},getRootContainerSize:function(){return this._rootContainerSize},setRootContainerSize:function(a){this._rootContainerSize=cc.size(a.width,a.height)},getDelegate:function(){return this._delegate},setDelegate:function(a){this._delegate=
a},getRunningSequenceName:function(){return this._runningSequence?this._runningSequence.getName():null},getContainerSize:function(a){return a?a.getContentSize():this._rootContainerSize},addNode:function(a,b){this._nodeSequences.setObject(b,a)},setBaseValue:function(a,b,c){var d=this._baseValues.objectForKey(b);d||(d=new cc._Dictionary,this._baseValues.setObject(d,b));d.setObject(a,c)},moveAnimationsFromNode:function(a,b){var c=this._baseValues,d=c.objectForKey(a);null!==d&&(c.setObject(d,b),c.removeObjectForKey(a));
c=this._nodeSequences;d=c.objectForKey(a);null!=d&&(c.setObject(d,b),c.removeObjectForKey(a))},getActionForCallbackChannel:function(a){var b=0,c=[];a=a.getKeyframes();for(var d=a.length,e=0;d>e;++e){var f=a[e],g=f.getTime()-b,b=f.getTime();0<g&&c.push(cc.delayTime(g));g=f.getValue();f=g[0];g=g[1];if(this._jsControlled)f=this._keyframeCallFuncs[g+":"+f],null!=f&&c.push(f);else{var h;if(g===CCB_TARGETTYPE_DOCUMENTROOT?h=this._rootNode:g===CCB_TARGETTYPE_OWNER&&(h=this._owner),null!=h)0<f.length?(g=
0,null!=h.onResolveCCBCCCallFuncSelector&&(g=h.onResolveCCBCCCallFuncSelector(h,f)),0===g?cc.log("Skipping selector '"+f+"' since no CCBSelectorResolver is present."):c.push(cc.callFunc(g,h))):cc.log("Unexpected empty selector.")}}return 1>c.length?null:cc.sequence(c)},getActionForSoundChannel:function(a){var b=0,c=[];a=a.getKeyframes();for(var d=a.length,e=0;d>e;++e){var f=a[e],g=f.getTime()-b,b=f.getTime();0<g&&c.push(cc.delayTime(g));var h=f.getValue(),f=cc.BuilderReader.getResourcePath()+h[0],
g=parseFloat(h[1]),k=parseFloat(h[2]),h=parseFloat(h[3]);c.push(cc.BuilderSoundEffect.create(f,g,k,h))}return 1>c.length?null:cc.sequence(c)},runAnimationsForSequenceNamed:function(a){this.runAnimationsForSequenceIdTweenDuration(this._getSequenceId(a),0)},runAnimationsForSequenceNamedTweenDuration:function(a,b){this.runAnimationsForSequenceIdTweenDuration(this._getSequenceId(a),b)},runAnimationsForSequenceIdTweenDuration:function(a,b){if(-1===a)throw"cc.BuilderAnimationManager.runAnimationsForSequenceIdTweenDuration(): Sequence id should not be -1";
b=b||0;this._rootNode.stopAllActions();for(var c=this._nodeSequences.allKeys(),d=0,e=c.length;e>d;d++){var f=c[d];f.stopAllActions();var g,h=this._nodeSequences.objectForKey(f).objectForKey(a),k=[];if(h){var m=h.allKeys();for(g=0;g<m.length;g++){var n=m[g],p=h.objectForKey(n);k.push(n);this._setFirstFrame(f,p,b);this._runAction(f,p,b)}}if(h=this._baseValues.objectForKey(f)){m=h.allKeys();for(g=0;g<m.length;g++)n=m[g],-1===k.indexOf(n)&&(p=h.objectForKey(n),null!=p&&this._setAnimatedProperty(n,f,p,
b))}}c=this._getSequence(a);d=cc.sequence(cc.delayTime(c.getDuration()+b),cc.callFunc(this._sequenceCompleted,this));this._rootNode.runAction(d);var r;c.getCallbackChannel()&&(r=this.getActionForCallbackChannel(c.getCallbackChannel()),r&&this._rootNode.runAction(r));c.getSoundChannel()&&(r=this.getActionForSoundChannel(c.getSoundChannel()),r&&this._rootNode.runAction(r));this._runningSequence=this._getSequence(a)},runAnimations:function(a,b){b=b||0;var c;c=cc.isString(a)?this._getSequenceId(a):a;
this.runAnimationsForSequenceIdTweenDuration(c,b)},setAnimationCompletedCallback:function(a,b){this._target=a;this._animationCompleteCallbackFunc=b},setCompletedAnimationCallback:function(a,b){this.setAnimationCompletedCallback(a,b)},setCallFunc:function(a,b){this._keyframeCallFuncs[b]=a},debug:function(){},_getBaseValue:function(a,b){var c=this._baseValues.objectForKey(a);return c?c.objectForKey(b):null},_getSequenceId:function(a){for(var b=null,c=this._sequences,d=0,e=c.length;e>d;d++)if(b=c[d],
b&&b.getName()===a)return b.getSequenceId();return-1},_getSequence:function(a){for(var b=null,c=this._sequences,d=0,e=c.length;e>d;d++)if(b=c[d],b&&b.getSequenceId()===a)return b;return null},_getAction:function(a,b,c,d){var e,f,g,h,k;a=b.getTime()-(a?a.getTime():0);if("rotation"===c)return cc.BuilderRotateTo.create(a,b.getValue());if("rotationX"===c)return cc.BuilderRotateXTo.create(a,b.getValue());if("rotationY"===c)return cc.BuilderRotateYTo.create(a,b.getValue());if("opacity"===c)return cc.fadeTo(a,
b.getValue());if("color"===c)return h=b.getValue().getColor(),cc.tintTo(a,h.r,h.g,h.b);if("visible"===c)return b.getValue()?cc.sequence(cc.delayTime(a),cc.show()):cc.sequence(cc.delayTime(a),cc.hide());if("displayFrame"===c)return cc.sequence(cc.delayTime(a),cc.BuilderSetSpriteFrame.create(b.getValue()));if("position"===c)return e=this._getBaseValue(d,c),f=e[2],g=b.getValue(),h=g[0],k=g[1],b=this.getContainerSize(d.getParent()),h=cc._getAbsolutePosition(h,k,f,b,c),cc.moveTo(a,h);if("scale"===c){if(e=
this._getBaseValue(d,c),f=e[2],g=b.getValue(),h=g[0],k=g[1],f===CCB_SCALETYPE_MULTIPLY_RESOLUTION)c=cc.BuilderReader.getResolutionScale(),h*=c,k*=c;return cc.scaleTo(a,h,k)}return"skew"===c?(g=b.getValue(),h=g[0],k=g[1],cc.skewTo(a,h,k)):(cc.log("BuilderReader: Failed to create animation for property: "+c),null)},_setAnimatedProperty:function(a,b,c,d){if(0<d){var e=new cc.BuilderKeyframe;e.setValue(c);e.setTime(d);e.setEasingType(CCB_KEYFRAME_EASING_LINEAR);a=this._getAction(null,e,a,b);b.runAction(a)}else"position"===
a?(d=this._getBaseValue(b,a),d=d[2],e=c[0],c=c[1],b.setPosition(cc._getAbsolutePosition(e,c,d,this.getContainerSize(b.getParent()),a))):"scale"===a?(d=this._getBaseValue(b,a),d=d[2],e=c[0],c=c[1],cc.setRelativeScale(b,e,c,d,a)):"skew"===a?(e=c[0],c=c[1],b.setSkewX(e),b.setSkewY(c)):"rotation"===a?b.setRotation(c):"rotationX"===a?b.setRotationSkewX(c):"rotationY"===a?b.setRotationSkewY(c):"opacity"===a?b.setOpacity(c):"displayFrame"===a?b.setSpriteFrame(c):"color"===a?(a=c.getColor(),(255!==a.r||255!==
a.g||255!==a.b)&&b.setColor(a)):"visible"===a?(c=c||!1,b.setVisible(c)):cc.log("unsupported property name is "+a)},_setFirstFrame:function(a,b,c){var d=b.getKeyframes();0===d.length?((d=this._getBaseValue(a,b.getName()))||cc.log("cc.BuilderAnimationManager._setFirstFrame(): No baseValue found for property"),this._setAnimatedProperty(b.getName(),a,d,c)):(d=d[0],this._setAnimatedProperty(b.getName(),a,d.getValue(),c))},_getEaseAction:function(a,b,c){return b===CCB_KEYFRAME_EASING_LINEAR||b===CCB_KEYFRAME_EASING_INSTANT?
a:b===CCB_KEYFRAME_EASING_CUBIC_IN?a.easing(cc.easeIn(c)):b===CCB_KEYFRAME_EASING_CUBIC_OUT?a.easing(cc.easeOut(c)):b===CCB_KEYFRAME_EASING_CUBIC_INOUT?a.easing(cc.easeInOut(c)):b===CCB_KEYFRAME_EASING_BACK_IN?a.easing(cc.easeBackIn()):b===CCB_KEYFRAME_EASING_BACK_OUT?a.easing(cc.easeBackOut()):b===CCB_KEYFRAME_EASING_BACK_INOUT?a.easing(cc.easeBackInOut()):b===CCB_KEYFRAME_EASING_BOUNCE_IN?a.easing(cc.easeBounceIn()):b===CCB_KEYFRAME_EASING_BOUNCE_OUT?a.easing(cc.easeBounceOut()):b===CCB_KEYFRAME_EASING_BOUNCE_INOUT?
a.easing(cc.easeBounceInOut()):b===CCB_KEYFRAME_EASING_ELASTIC_IN?a.easing(cc.easeElasticIn(c)):b===CCB_KEYFRAME_EASING_ELASTIC_OUT?a.easing(cc.easeElasticOut(c)):b===CCB_KEYFRAME_EASING_ELASTIC_INOUT?a.easing(cc.easeElasticInOut(c)):(cc.log("BuilderReader: Unkown easing type "+b),a)},_runAction:function(a,b,c){var d=b.getKeyframes(),e=d.length;if(1<e){var f=[];c=d[0].getTime()+c;0<c&&f.push(cc.delayTime(c));for(c=0;e-1>c;++c){var g=d[c],h=this._getAction(g,d[c+1],b.getName(),a);h&&(h=this._getEaseAction(h,
g.getEasingType(),g.getEasingOpt()),f.push(h))}a.runAction(cc.sequence(f))}},_sequenceCompleted:function(){var a=this._runningSequence,b=a.getName();this._lastCompletedSequenceName!=a.getName()&&(this._lastCompletedSequenceName=a.getName());a=a.getChainedSequenceId();this._runningSequence=null;-1!==a&&this.runAnimations(a,0);this._delegate&&this._delegate.completedAnimationSequenceNamed(b);this._target&&this._animationCompleteCallbackFunc&&this._animationCompleteCallbackFunc.call(this._target)}});
cc.BuilderSetSpriteFrame=cc.ActionInstant.extend({_spriteFrame:null,initWithSpriteFrame:function(a){return this._spriteFrame=a,!0},update:function(a){this.target.setSpriteFrame(this._spriteFrame)}});cc.BuilderSetSpriteFrame.create=function(a){var b=new cc.BuilderSetSpriteFrame;return b&&b.initWithSpriteFrame(a)?b:null};
cc.BuilderRotateTo=cc.ActionInterval.extend({_startAngle:0,_dstAngle:0,_diffAngle:0,initWithDuration:function(a,b){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._dstAngle=b,!0):!1},update:function(a){this.target.setRotation(this._startAngle+this._diffAngle*a)},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._startAngle=this.target.getRotation();this._diffAngle=this._dstAngle-this._startAngle}});
cc.BuilderRotateTo.create=function(a,b){var c=new cc.BuilderRotateTo;return c&&c.initWithDuration(a,b)?c:null};cc.BuilderRotateXTo=cc.ActionInterval.extend({});cc.BuilderRotateXTo.create=function(a,b){throw"rotationX has not been implemented in cocos2d-html5";};cc.BuilderRotateYTo=cc.ActionInterval.extend({});cc.BuilderRotateYTo.create=function(a,b){throw"rotationY has not been implemented in cocos2d-html5";};
cc.BuilderSoundEffect=cc.ActionInstant.extend({init:function(a){return this._file=a,!0},update:function(a){cc.audioEngine.playEffect(this._file)}});cc.BuilderSoundEffect.create=function(a,b,c,d){return(b=new cc.BuilderSoundEffect)&&b.init(a)?b:null};cc.DOM={};
cc.DOM._addMethods=function(a){for(var b in cc.DOM.methods)a[b]=cc.DOM.methods[b];cc.defineGetterSetter(a,"x",a.getPositionX,a.setPositionX);cc.defineGetterSetter(a,"y",a.getPositionY,a.setPositionY);cc.defineGetterSetter(a,"width",a._getWidth,a._setWidth);cc.defineGetterSetter(a,"height",a._getHeight,a._setHeight);cc.defineGetterSetter(a,"anchorX",a._getAnchorX,a._setAnchorX);cc.defineGetterSetter(a,"anchorY",a._getAnchorY,a._setAnchorY);cc.defineGetterSetter(a,"scale",a.getScale,a.setScale);cc.defineGetterSetter(a,
"scaleX",a.getScaleX,a.setScaleX);cc.defineGetterSetter(a,"scaleY",a.getScaleY,a.setScaleY);cc.defineGetterSetter(a,"rotation",a.getRotation,a.setRotation);cc.defineGetterSetter(a,"skewX",a.getSkewX,a.setSkewX);cc.defineGetterSetter(a,"skewY",a.getSkewY,a.setSkewY);cc.defineGetterSetter(a,"visible",a.isVisible,a.setVisible);cc.defineGetterSetter(a,"parent",a.getParent,a.setParent);cc.defineGetterSetter(a,"opacity",a.getOpacity,a.setOpacity)};
cc.DOM.methods={setPosition:function(a,b){void 0===b?(this._position.x=a.x,this._position.y=a.y):(this._position.x=a,this._position.y=b);this.setNodeDirty();this.dom.translates(this._position.x,-this._position.y)},setPositionY:function(a){this._position.y=a;this.setNodeDirty();this.dom.translates(this._position.x,-this._position.y)},setPositionX:function(a){this._position.x=a;this.setNodeDirty();this.dom.translates(this._position.x,-this._position.y)},setScale:function(a,b){this._scaleX=a;this._scaleY=
b||a;this.setNodeDirty();this.dom.resize(this._scaleX,this._scaleY)},setScaleX:function(a){this._scaleX=a;this.setNodeDirty();this.dom.resize(this._scaleX,this._scaleY)},setScaleY:function(a){this._scaleY=a;this.setNodeDirty();this.dom.resize(this._scaleX,this._scaleY)},setAnchorPoint:function(a,b){var c=this._renderCmd,d=this._anchorPoint;void 0===b?(d.x=a.x,d.y=a.y):(d.x=a,d.y=b);var c=c._anchorPointInPoints,e=this._contentSize;c.x=e.width*d.x;c.y=e.height*d.y;this.dom.style[cc.$.pfx+"TransformOrigin"]=
""+c.x+"px "+-c.y+"px";this.ignoreAnchor?(this.dom.style.marginLeft=0,this.dom.style.marginBottom=0):(this.dom.style.marginLeft=this.isToggler?0:-c.x+"px",this.dom.style.marginBottom=-c.y+"px");this.setNodeDirty()},_setAnchorX:function(a){var b=this._anchorPoint,c=this._renderCmd;a!==b.x&&(b.x=a,a=c._anchorPointInPoints,a.x=this._contentSize.width*b.x,this.dom.style[cc.$.pfx+"TransformOrigin"]=""+a.x+"px "+-a.y+"px",this.ignoreAnchor?(this.dom.style.marginLeft=0,this.dom.style.marginBottom=0):this.dom.style.marginLeft=
this.isToggler?0:-a.x+"px",this.setNodeDirty())},_setAnchorY:function(a){var b=this._anchorPoint,c=this._renderCmd;a!==b.y&&(b.y=a,a=c._anchorPointInPoints,a.y=this._contentSize.height*b.y,this.dom.style[cc.$.pfx+"TransformOrigin"]=""+a.x+"px "+-a.y+"px",this.ignoreAnchor?(this.dom.style.marginLeft=0,this.dom.style.marginBottom=0):this.dom.style.marginBottom=-a.y+"px",this.setNodeDirty())},setContentSize:function(a,b){var c=this._renderCmd,d=this._contentSize;void 0===b?(d.width=a.width,d.height=
a.height):(d.width=a,d.height=b);var c=c._anchorPointInPoints,e=this._anchorPoint;c.x=d.width*e.x;c.y=d.height*e.y;this.dom.width=d.width;this.dom.height=d.height;this.setAnchorPoint(this.getAnchorPoint());this.canvas&&(this.canvas.width=d.width,this.canvas.height=d.height);this.setNodeDirty();this.redraw()},_setWidth:function(a){var b=this._contentSize,c=this._renderCmd;a!==b.width&&(b.width=a,a=this._anchorPoint,c._anchorPointInPoints.x=b.width*a.x,this.dom.width=b.width,this.anchorX=a.x,this.canvas&&
(this.canvas.width=b.width),this.setNodeDirty(),this.redraw())},_setHeight:function(a){var b=this._contentSize,c=this._renderCmd;a!==b.height&&(b.height=a,a=this._anchorPoint,c._anchorPointInPoints.y=b.height*a.y,this.dom.height=b.height,this.anchorY=a.y,this.canvas&&(this.canvas.height=b.height),this.setNodeDirty(),this.redraw())},setRotation:function(a){this._rotation!==a&&(this._rotationX=this._rotationY=a,this.setNodeDirty(),this.dom.rotate(a))},setSkewX:function(a){this._skewX=a;this.setNodeDirty();
this.dom.setSkew(this._skewX,this._skewY)},setSkewY:function(a){this._skewY=a;this.setNodeDirty();this.dom.setSkew(this._skewX,this._skewY)},setVisible:function(a){this._visible=a;this.setNodeDirty();this.dom&&(this.dom.style.display=a?"block":"none")},_setLocalZOrder:function(a){this._localZOrder=a;this.setNodeDirty();this.dom&&(this.dom.zIndex=a)},setParent:function(a){this._parent=a;null!==a&&(a.setAnchorPoint(a.getAnchorPoint()),this.setNodeDirty(),cc.DOM.parentDOM(this))},resume:function(){this.getScheduler().resumeTarget(this);
this.getActionManager().resumeTarget(this);cc.eventManager.resumeTarget(this);this.dom&&!this.dom.parentNode&&(this.getParent()?cc.DOM.parentDOM(this):""===this.dom.id?cc.DOM._createEGLViewDiv(this):this.dom.appendTo(cc.container));this.dom&&(this.dom.style.visibility="visible")},pause:function(){this.getScheduler().pauseTarget(this);this.getActionManager().pauseTarget(this);cc.eventManager.pauseTarget(this);this.dom&&(this.dom.style.visibility="hidden")},cleanup:function(){this.stopAllActions();
this.unscheduleAllCallbacks();this._arrayMakeObjectsPerformSelector(this._children,cc.Node._stateCallbackType.cleanup);this.dom&&this.dom.remove()},removeFromParentAndCleanup:function(){this.dom.remove()},setOpacity:function(a){this._opacity=a;this.dom.style.opacity=a/255},redraw:function(){if(this.isSprite){var a=this._children;this._children=[];cc.Sprite.prototype.visit.call(this,this.ctx);this._children=a}else cc.Sprite.prototype.visit.call(this,this.ctx)}};
cc.DOM._resetEGLViewDiv=function(){var a=cc.$("#EGLViewDiv");if(a){var b=cc.view,c=b.getDesignResolutionSize();b.getViewPortRect();var d=b.getFrameSize(),e=b.getDevicePixelRatio(),f=c.width,g=c.height;0===c.width&&0===c.height&&(f=d.width,g=d.height);a.style.position="absolute";a.style.width=f+"px";a.style.maxHeight=g+"px";a.style.margin=0;a.resize(b.getScaleX()/e,b.getScaleY()/e);b.getResolutionPolicy()===b._rpNoBorder?(a.style.left=(b.getFrameSize().width-f)/2+"px",a.style.bottom=(b.getFrameSize().height-
g*b.getScaleY()/e)/2+"px"):(a.style.left=(f*b.getScaleX()/e-f)/2+"px",a.style.bottom="0px")}};cc.DOM.parentDOM=function(a){var b=a.getParent();if(!b||!a.dom)return!1;(b.dom||(cc.DOM.placeHolder(b),b.setParent=cc.DOM.methods.setParent),a.dom.appendTo(b.dom),b.setAnchorPoint(b.getAnchorPoint()),b.getParent())?cc.DOM.parentDOM(b):b.isRunning()&&((a=cc.$("#EGLViewDiv"))?b.dom.appendTo(a):cc.DOM._createEGLViewDiv(b));return!0};
cc.DOM._createEGLViewDiv=function(a){var b=cc.$("#EGLViewDiv");b||(b=cc.$new("div"),b.id="EGLViewDiv");var c=cc.view,d=c.getDesignResolutionSize();c.getViewPortRect();var e=c.getFrameSize(),f=c.getDevicePixelRatio(),g=d.width,h=d.height;0===d.width&&0===d.height&&(g=e.width,h=e.height);b.style.position="absolute";b.style.width=g+"px";b.style.maxHeight=h+"px";b.style.margin=0;b.resize(c.getScaleX()/f,c.getScaleY()/f);c.getResolutionPolicy()===c._rpNoBorder?(b.style.left=(e.width-g)/2+"px",b.style.bottom=
(e.height-h*c.getScaleY()/f)/2+"px"):(b.style.left=(g*c.getScaleX()/f-g)/2+"px",b.style.bottom="0px");a.dom.appendTo(b);b.appendTo(cc.container)};
cc.DOM.setTransform=function(a){if(a.ctx)if(a.ctx.translate(a.getAnchorPointInPoints().x,a.getAnchorPointInPoints().y),a.isSprite){var b=a._children;a._children=[];cc.Sprite.prototype.visit.call(a);a._children=b}else cc.Sprite.prototype.visit.call(a);a.dom&&(a.dom.position.x=a.getPositionX(),a.dom.position.y=-a.getPositionY(),a.dom.rotation=a.getRotation(),a.dom.scale={x:a.getScaleX(),y:a.getScaleY()},a.dom.skew={x:a.getSkewX(),y:a.getSkewY()},a.setAnchorPoint&&a.setAnchorPoint(a.getAnchorPoint()),
a.dom.transforms())};cc.DOM.forSprite=function(a){a.dom=cc.$new("div");a.canvas=cc.$new("canvas");var b=a.getContentSize();a.canvas.width=b.width;a.canvas.height=b.height;a.dom.style.position="absolute";a.dom.style.bottom=0;a.ctx=a.canvas.getContext("2d");a.dom.appendChild(a.canvas);a.getParent()&&cc.DOM.parentDOM(a);a.isSprite=!0};
cc.DOM.placeHolder=function(a){a.dom=cc.$new("div");a.placeholder=!0;a.dom.style.position="absolute";a.dom.style.bottom=0;a.dom.style.width=(a.getContentSize().width||cc.director.getWinSize().width)+"px";a.dom.style.maxHeight=(a.getContentSize().height||cc.director.getWinSize().height)+"px";a.dom.style.margin=0;cc.DOM.setTransform(a);a.dom.transforms();cc.DOM._addMethods(a)};
cc.DOM.convert=function(a){if(1<arguments.length)return void cc.DOM.convert(arguments);if(1===arguments.length&&!arguments[0].length)return void cc.DOM.convert([arguments[0]]);for(var b=arguments[0],c=0;c<b.length;c++)b[c]instanceof cc.Sprite?b[c].dom||cc.DOM.forSprite(b[c]):cc.log("DOM converter only supports sprite and menuitems yet"),cc.DOM._addMethods(b[c]),b[c].visit=function(){},b[c].transform=function(){},cc.DOM.setTransform(b[c]),b[c].setVisible(b[c].isVisible())};
cc.KEYBOARD_RETURNTYPE_DEFAULT=0;cc.KEYBOARD_RETURNTYPE_DONE=1;cc.KEYBOARD_RETURNTYPE_SEND=2;cc.KEYBOARD_RETURNTYPE_SEARCH=3;cc.KEYBOARD_RETURNTYPE_GO=4;cc.EDITBOX_INPUT_MODE_ANY=0;cc.EDITBOX_INPUT_MODE_EMAILADDR=1;cc.EDITBOX_INPUT_MODE_NUMERIC=2;cc.EDITBOX_INPUT_MODE_PHONENUMBER=3;cc.EDITBOX_INPUT_MODE_URL=4;cc.EDITBOX_INPUT_MODE_DECIMAL=5;cc.EDITBOX_INPUT_MODE_SINGLELINE=6;cc.EDITBOX_INPUT_FLAG_PASSWORD=0;cc.EDITBOX_INPUT_FLAG_SENSITIVE=1;cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_WORD=2;
cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_SENTENCE=3;cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_ALL_CHARACTERS=4;cc.EditBoxDelegate=cc.Class.extend({editBoxEditingDidBegin:function(a){},editBoxEditingDidEnd:function(a){},editBoxTextChanged:function(a,b){},editBoxReturn:function(a){}});
cc.EditBox=cc.ControlButton.extend({_domInputSprite:null,_delegate:null,_editBoxInputMode:cc.EDITBOX_INPUT_MODE_ANY,_editBoxInputFlag:cc.EDITBOX_INPUT_FLAG_SENSITIVE,_keyboardReturnType:cc.KEYBOARD_RETURNTYPE_DEFAULT,_text:"",_placeholderText:"",_textColor:null,_placeholderColor:null,_maxLength:50,_adjustHeight:18,_edTxt:null,_edFontSize:14,_edFontName:"Arial",_placeholderFontName:"",_placeholderFontSize:14,_tooltip:!1,_className:"EditBox",ctor:function(a,b,c,d){cc.ControlButton.prototype.ctor.call(this);
this._textColor=cc.color.WHITE;this._placeholderColor=cc.color.GRAY;this.setContentSize(a);var e=this._domInputSprite=new cc.Sprite;e.draw=function(){};this.addChild(e);var f=this,g=this._edTxt=cc.newElement("input");g.type="text";g.style.fontSize=this._edFontSize+"px";g.style.color="#000000";g.style.border=0;g.style.background="transparent";g.style.width="100%";g.style.height="100%";g.style.active=0;g.style.outline="medium";g.style.padding="0";var h=function(){g.blur()};cc._addEventListener(g,"input",
function(){f._delegate&&f._delegate.editBoxTextChanged&&f._delegate.editBoxTextChanged(f,this.value)});cc._addEventListener(g,"keypress",function(a){a.keyCode===cc.KEY.enter&&(a.stopPropagation(),a.preventDefault(),cc._canvas.focus())});cc._addEventListener(g,"focus",function(){this.value===f._placeholderText&&(this.value="",this.style.fontSize=f._edFontSize+"px",this.style.color=cc.colorToHex(f._textColor),f._editBoxInputFlag===cc.EDITBOX_INPUT_FLAG_PASSWORD?f._edTxt.type="password":f._edTxt.type=
"text");f._delegate&&f._delegate.editBoxEditingDidBegin&&f._delegate.editBoxEditingDidBegin(f);cc._addEventListener(cc._canvas,"click",h)});cc._addEventListener(g,"blur",function(){""===this.value&&(this.value=f._placeholderText,this.style.fontSize=f._placeholderFontSize+"px",this.style.color=cc.colorToHex(f._placeholderColor),f._edTxt.type="text");f._delegate&&f._delegate.editBoxEditingDidEnd&&f._delegate.editBoxEditingDidEnd(f);f._delegate&&f._delegate.editBoxReturn&&f._delegate.editBoxReturn(f);
cc._canvas.removeEventListener("click",h)});cc.DOM.convert(e);e.dom.appendChild(g);e.dom.showTooltipDiv=!1;e.dom.style.width=a.width-6+"px";e.dom.style.height=a.height-6+"px";e.canvas.remove();this.initWithSizeAndBackgroundSprite(a,b)&&(c&&this.setBackgroundSpriteForState(c,cc.CONTROL_STATE_HIGHLIGHTED),d&&this.setBackgroundSpriteForState(d,cc.CONTROL_STATE_DISABLED))},setFont:function(a,b){this._edFontSize=b;this._edFontName=a;this._setFontToEditBox()},_setFont:function(a){(a=cc.LabelTTF._fontStyleRE.exec(a))&&
(this._edFontSize=parseInt(a[1]),this._edFontName=a[2],this._setFontToEditBox())},setFontName:function(a){this._edFontName=a;this._setFontToEditBox()},setFontSize:function(a){this._edFontSize=a;this._setFontToEditBox()},_setFontToEditBox:function(){this._edTxt.value!==this._placeholderText&&(this._edTxt.style.fontFamily=this._edFontName,this._edTxt.style.fontSize=this._edFontSize+"px",this._editBoxInputFlag===cc.EDITBOX_INPUT_FLAG_PASSWORD?this._edTxt.type="password":this._edTxt.type="text")},setText:function(a){cc.log("Please use the setString");
this.setString(a)},setString:function(a){null!=a&&(""===a?(this._edTxt.value=this._placeholderText,this._edTxt.style.color=cc.colorToHex(this._placeholderColor),this._edTxt.type="text"):(this._edTxt.value=a,this._edTxt.style.color=cc.colorToHex(this._textColor),this._editBoxInputFlag===cc.EDITBOX_INPUT_FLAG_PASSWORD?this._edTxt.type="password":this._edTxt.type="text"))},setFontColor:function(a){this._textColor=a;this._edTxt.value!==this._placeholderText&&(this._edTxt.style.color=cc.colorToHex(a))},
setMaxLength:function(a){!isNaN(a)&&0<a&&(this._maxLength=a,this._edTxt.maxLength=a)},getMaxLength:function(){return this._maxLength},setPlaceHolder:function(a){if(null!=a){var b=this._placeholderText;this._placeholderText=a;this._edTxt.value===b&&(this._edTxt.value=a,this._edTxt.style.color=cc.colorToHex(this._placeholderColor),this._setPlaceholderFontToEditText())}},setPlaceholderFont:function(a,b){this._placeholderFontName=a;this._placeholderFontSize=b;this._setPlaceholderFontToEditText()},_setPlaceholderFont:function(a){(a=
cc.LabelTTF._fontStyleRE.exec(a))&&(this._placeholderFontName=a[2],this._placeholderFontSize=parseInt(a[1]),this._setPlaceholderFontToEditText())},setPlaceholderFontName:function(a){this._placeholderFontName=a;this._setPlaceholderFontToEditText()},setPlaceholderFontSize:function(a){this._placeholderFontSize=a;this._setPlaceholderFontToEditText()},_setPlaceholderFontToEditText:function(){this._edTxt.value===this._placeholderText&&(this._edTxt.style.fontFamily=this._placeholderFontName,this._edTxt.style.fontSize=
this._placeholderFontSize+"px",this._edTxt.type="text")},setPlaceholderFontColor:function(a){this._placeholderColor=a;this._edTxt.value===this._placeholderText&&(this._edTxt.style.color=cc.colorToHex(a))},setInputFlag:function(a){this._editBoxInputFlag=a;this._edTxt.value!==this._placeholderText&&a===cc.EDITBOX_INPUT_FLAG_PASSWORD?this._edTxt.type="password":this._edTxt.type="text"},getText:function(){return cc.log("Please use the getString"),this._edTxt.value},getString:function(){return this._edTxt.value===
this._placeholderText?"":this._edTxt.value},initWithSizeAndBackgroundSprite:function(a,b){return this.initWithBackgroundSprite(b)?(this._domInputSprite.x=3,this._domInputSprite.y=3,this.setZoomOnTouchDown(!1),this.setPreferredSize(a),this.x=0,this.y=0,this._addTargetWithActionForControlEvent(this,this.touchDownAction,cc.CONTROL_EVENT_TOUCH_UP_INSIDE),!0):!1},setDelegate:function(a){this._delegate=a},getPlaceHolder:function(){return this._placeholderText},setInputMode:function(a){this._editBoxInputMode=
a},setReturnType:function(a){this._keyboardReturnType=a},keyboardWillShow:function(a){var b=cc.EditBox.getRect(this);return b.y-=4,b.intersectsRect(a.end)?void(this._adjustHeight=a.end.getMaxY()-b.getMinY()):void cc.log("needn't to adjust view layout.")},keyboardDidShow:function(a){},keyboardWillHide:function(a){},keyboardDidHide:function(a){},touchDownAction:function(a,b){},initWithBackgroundColor:function(a,b){this._edWidth=a.width;this.dom.style.width=this._edWidth.toString()+"px";this._edHeight=
a.height;this.dom.style.height=this._edHeight.toString()+"px";this.dom.style.backgroundColor=cc.colorToHex(b)}});_p=cc.EditBox.prototype;_p.font;cc.defineGetterSetter(_p,"font",null,_p._setFont);_p.fontName;cc.defineGetterSetter(_p,"fontName",null,_p.setFontName);_p.fontSize;cc.defineGetterSetter(_p,"fontSize",null,_p.setFontSize);_p.fontColor;cc.defineGetterSetter(_p,"fontColor",null,_p.setFontColor);_p.string;cc.defineGetterSetter(_p,"string",_p.getString,_p.setString);_p.maxLength;
cc.defineGetterSetter(_p,"maxLength",_p.getMaxLength,_p.setMaxLength);_p.placeHolder;cc.defineGetterSetter(_p,"placeHolder",_p.getPlaceHolder,_p.setPlaceHolder);_p.placeHolderFont;cc.defineGetterSetter(_p,"placeHolderFont",null,_p._setPlaceholderFont);_p.placeHolderFontName;cc.defineGetterSetter(_p,"placeHolderFontName",null,_p.setPlaceholderFontName);_p.placeHolderFontSize;cc.defineGetterSetter(_p,"placeHolderFontSize",null,_p.setPlaceholderFontSize);_p.placeHolderFontColor;
cc.defineGetterSetter(_p,"placeHolderFontColor",null,_p.setPlaceholderFontColor);_p.inputFlag;cc.defineGetterSetter(_p,"inputFlag",null,_p.setInputFlag);_p.delegate;cc.defineGetterSetter(_p,"delegate",null,_p.setDelegate);_p.inputMode;cc.defineGetterSetter(_p,"inputMode",null,_p.setInputMode);_p.returnType;cc.defineGetterSetter(_p,"returnType",null,_p.setReturnType);_p=null;
cc.EditBox.getRect=function(a){var b=a.getContentSize(),b=cc.rect(0,0,b.width,b.height);return cc.rectApplyAffineTransform(b,a.getNodeToWorldTransform())};cc.EditBox.create=function(a,b,c,d){return new cc.EditBox(a,b,c,d)};
cc.ProtectedNode=cc.Node.extend({_protectedChildren:null,_reorderProtectedChildDirty:!1,_insertProtectedChild:function(a,b){this._reorderProtectedChildDirty=!0;this._protectedChildren.push(a);a._setLocalZOrder(b)},ctor:function(){cc.Node.prototype.ctor.call(this);this._protectedChildren=[]},addProtectedChild:function(a,b,c){cc.assert(null!=a,"child must be non-nil");cc.assert(!a.parent,"child already added. It can't be added again");b=b||a.getLocalZOrder();c&&a.setTag(c);this._insertProtectedChild(a,
b);a.setParent(this);a.setOrderOfArrival(cc.s_globalOrderOfArrival);this._running&&(a.onEnter(),this._isTransitionFinished&&a.onEnterTransitionDidFinish());this._cascadeColorEnabled&&this._renderCmd.setCascadeColorEnabledDirty();this._cascadeOpacityEnabled&&this._renderCmd.setCascadeOpacityEnabledDirty()},getProtectedChildByTag:function(a){cc.assert(a!==cc.NODE_TAG_INVALID,"Invalid tag");for(var b=this._protectedChildren,c=0,d=b.length;d>c;c++)if(b.getTag()===a)return b[c];return null},removeProtectedChild:function(a,
b){null==b&&(b=!0);var c=this._protectedChildren;if(0!==c.length){var d=c.indexOf(a);-1<d&&(this._running&&(a.onExitTransitionDidStart(),a.onExit()),b&&a.cleanup(),a.setParent(null),c.splice(d,1))}},removeProtectedChildByTag:function(a,b){cc.assert(a!==cc.NODE_TAG_INVALID,"Invalid tag");null==b&&(b=!0);var c=this.getProtectedChildByTag(a);null==c?cc.log("cocos2d: removeChildByTag(tag \x3d %d): child not found!",a):this.removeProtectedChild(c,b)},removeAllProtectedChildren:function(){this.removeAllProtectedChildrenWithCleanup(!0)},
removeAllProtectedChildrenWithCleanup:function(a){null==a&&(a=!0);for(var b=this._protectedChildren,c=0,d=b.length;d>c;c++){var e=b[c];this._running&&(e.onExitTransitionDidStart(),e.onExit());a&&e.cleanup();e.setParent(null)}b.length=0},reorderProtectedChild:function(a,b){cc.assert(null!=a,"Child must be non-nil");this._reorderProtectedChildDirty=!0;a.setOrderOfArrival(cc.s_globalOrderOfArrival++);a._setLocalZOrder(b)},sortAllProtectedChildren:function(){if(this._reorderProtectedChildDirty){var a,
b,c,d=this._protectedChildren,e=d.length;for(a=1;e>a;a++){c=d[a];for(b=a-1;0<=b&&(c._localZOrder<d[b]._localZOrder||c._localZOrder===d[b]._localZOrder&&c.arrivalOrder<d[b].arrivalOrder);)d[b+1]=d[b],b--;d[b+1]=c}this._reorderProtectedChildDirty=!1}},_changePosition:function(){},cleanup:function(){cc.Node.prototype.cleanup.call(this);for(var a=this._protectedChildren,b=0,c=a.length;c>b;b++)a[b].cleanup()},onEnter:function(){cc.Node.prototype.onEnter.call(this);for(var a=this._protectedChildren,b=0,
c=a.length;c>b;b++)a[b].onEnter()},onEnterTransitionDidFinish:function(){cc.Node.prototype.onEnterTransitionDidFinish.call(this);for(var a=this._protectedChildren,b=0,c=a.length;c>b;b++)a[b].onEnterTransitionDidFinish()},onExit:function(){cc.Node.prototype.onExit.call(this);for(var a=this._protectedChildren,b=0,c=a.length;c>b;b++)a[b].onExit()},onExitTransitionDidStart:function(){cc.Node.prototype.onExitTransitionDidStart.call(this);for(var a=this._protectedChildren,b=0,c=a.length;c>b;b++)a[b].onExitTransitionDidStart()},
_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.ProtectedNode.CanvasRenderCmd(this):new cc.ProtectedNode.WebGLRenderCmd(this)}});cc.ProtectedNode.create=function(){return new cc.ProtectedNode};
(function(){cc.ProtectedNode.RenderCmd={_updateDisplayColor:function(a){var c,d,e,f=this._node,g=this._displayedColor;c=f._realColor;if(this._cascadeColorEnabledDirty&&!f._cascadeColorEnabled){g.r=c.r;g.g=c.g;g.b=c.b;g=new cc.Color(255,255,255,255);d=f._children;c=0;for(a=d.length;a>c;c++)(e=d[c])&&e._renderCmd&&e._renderCmd._updateDisplayColor(g);this._cascadeColorEnabledDirty=!1}else{void 0===a&&(a=(a=f._parent)&&a._cascadeColorEnabled?a.getDisplayedColor():cc.color.WHITE);if(g.r=0|c.r*a.r/255,
g.g=0|c.g*a.g/255,g.b=0|c.b*a.b/255,f._cascadeColorEnabled){d=f._children;c=0;for(a=d.length;a>c;c++)(e=d[c])&&e._renderCmd&&(e._renderCmd._updateDisplayColor(g),e._renderCmd._updateColor())}d=f._protectedChildren;c=0;for(a=d.length;a>c;c++)(e=d[c])&&e._renderCmd&&(e._renderCmd._updateDisplayColor(g),e._renderCmd._updateColor())}this._dirtyFlag^=this._dirtyFlag&cc.Node._dirtyFlags.colorDirty},_updateDisplayOpacity:function(a){var c,d,e,f=this._node;if(this._cascadeOpacityEnabledDirty&&!f._cascadeOpacityEnabled){this._displayedOpacity=
f._realOpacity;d=f._children;a=0;for(c=d.length;c>a;a++)(e=d[a])&&e._renderCmd&&e._renderCmd._updateDisplayOpacity(255);this._cascadeOpacityEnabledDirty=!1}else{void 0===a&&(c=f._parent,a=255,c&&c._cascadeOpacityEnabled&&(a=c.getDisplayedOpacity()));if(this._displayedOpacity=f._realOpacity*a/255,f._cascadeOpacityEnabled){d=f._children;a=0;for(c=d.length;c>a;a++)(e=d[a])&&e._renderCmd&&(e._renderCmd._updateDisplayOpacity(this._displayedOpacity),e._renderCmd._updateColor())}d=f._protectedChildren;a=
0;for(c=d.length;c>a;a++)(e=d[a])&&e._renderCmd&&(e._renderCmd._updateDisplayOpacity(this._displayedOpacity),e._renderCmd._updateColor())}this._dirtyFlag^=this._dirtyFlag&cc.Node._dirtyFlags.opacityDirty},_changeProtectedChild:function(a){a=a._renderCmd;var c=a._dirtyFlag,d=cc.Node._dirtyFlags;this._dirtyFlag&d.colorDirty&&(c|=d.colorDirty);this._dirtyFlag&d.opacityDirty&&(c|=d.opacityDirty);var e=c&d.colorDirty,c=c&d.opacityDirty;e&&a._updateDisplayColor(this._displayedColor);c&&a._updateDisplayOpacity(this._displayedOpacity);
(e||c)&&a._updateColor()}};cc.ProtectedNode.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._cachedParent=null;this._cacheDirty=!1};var a=cc.ProtectedNode.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);cc.inject(cc.ProtectedNode.RenderCmd,a);a.constructor=cc.ProtectedNode.CanvasRenderCmd;a.visit=function(a){var c=this._node;if(c._visible){var d,e=c._children,f=c._protectedChildren,g=c._children.length,h=f.length;this._syncStatus(a);c.sortAllChildren();
c.sortAllProtectedChildren();var k;for(a=0;g>a&&(d=e[a],0>d._localZOrder);a++)d.visit(this);for(d=0;h>d&&(k=f[d],k&&0>k._localZOrder);d++)this._changeProtectedChild(k),k.visit(this);for(cc.renderer.pushRenderCommand(this);g>a;a++)e[a]&&e[a].visit(this);for(;h>d;d++)(k=f[d])&&(this._changeProtectedChild(k),k.visit(this));this._dirtyFlag=0;this._cacheDirty=!1}};a.transform=function(a,c){var d=this._node;d._changePosition&&d._changePosition();var e=d.getNodeToParentTransform(),f=this._worldTransform;
if(a){var g=a._worldTransform;f.a=e.a*g.a+e.b*g.c;f.b=e.a*g.b+e.b*g.d;f.c=e.c*g.a+e.d*g.c;f.d=e.c*g.b+e.d*g.d;f.tx=g.a*e.tx+g.c*e.ty+g.tx;f.ty=g.d*e.ty+g.ty+g.b*e.tx}else f.a=e.a,f.b=e.b,f.c=e.c,f.d=e.d,f.tx=e.tx,f.ty=e.ty;g=d._children;if(c&&g&&0!==g.length){e=0;for(f=g.length;f>e;e++)g[e]._renderCmd.transform(this,c)}if(g=d._protectedChildren,c&&g&&0!==g.length){e=0;for(f=g.length;f>e;e++)g[e]._renderCmd.transform(this,c)}}})();
(function(){if(cc.Node.WebGLRenderCmd){cc.ProtectedNode.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a)};var a=cc.ProtectedNode.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);cc.inject(cc.ProtectedNode.RenderCmd,a);a.constructor=cc.ProtectedNode.WebGLRenderCmd;a.visit=function(a){var c=this._node;if(c._visible){var d,e=cc.current_stack;e.stack.push(e.top);this._syncStatus(a);e.top=this._stackMatrix;var f=c.grid;f&&f._active&&f.beforeDraw();var g=c._children,
h=c._protectedChildren,k=g.length,m=h.length;c.sortAllChildren();c.sortAllProtectedChildren();var n;for(a=0;k>a&&g[a]&&0>g[a]._localZOrder;a++)g[a].visit(this);for(d=0;m>d&&(n=h[d],n&&0>n._localZOrder);d++)this._changeProtectedChild(n),n.visit(this);for(cc.renderer.pushRenderCommand(this);k>a;a++)g[a]&&g[a].visit(this);for(;m>d;d++)(n=h[d])&&(this._changeProtectedChild(n),n.visit(this));f&&f._active&&f.afterDraw(c);this._dirtyFlag=0;e.top=e.stack.pop()}};a.transform=function(a,c){var d=this._node,
e=this._transform4x4,f=this._stackMatrix,g=a?a._stackMatrix:cc.current_stack.top,h=d.getNodeToParentTransform();d._changePosition&&d._changePosition();this._dirtyFlag^=this._dirtyFlag&cc.Node._dirtyFlags.transformDirty;var k=e.mat;if(k[0]=h.a,k[4]=h.c,k[12]=h.tx,k[1]=h.b,k[5]=h.d,k[13]=h.ty,k[14]=d._vertexZ,cc.kmMat4Multiply(f,g,e),null!==d._camera&&(null===d.grid||!d.grid.isActive()))if(g=this._anchorPointInPoints.x,h=this._anchorPointInPoints.y,k=0!==g||0!==h){cc.SPRITEBATCHNODE_RENDER_SUBPIXEL||
(g|=0,h|=0);var m=cc.math.Matrix4.createByTranslation(g,h,0,e);f.multiply(k);d._camera._locateForRenderer(f);m=cc.math.Matrix4.createByTranslation(-g,-h,0,m);f.multiply(m);e.identity()}else d._camera._locateForRenderer(f);g=d._children;if(c&&g&&0!==g.length){e=0;for(f=g.length;f>e;e++)g[e]._renderCmd.transform(this,c)}if(g=d._protectedChildren,c&&g&&0!==g.length){e=0;for(f=g.length;f>e;e++)g[e]._renderCmd.transform(this,c)}}}})();var ccui=ccui||{};ccui.Class=ccui.Class||cc.Class;
ccui.Class.extend=ccui.Class.extend||cc.Class.extend;ccui.Node=ccui.Node||cc.Node;ccui.Node.extend=ccui.Node.extend||cc.Node.extend;ccui.ProtectedNode=ccui.ProtectedNode||cc.ProtectedNode;ccui.ProtectedNode.extend=ccui.ProtectedNode.extend||cc.ProtectedNode.extend;ccui.cocosGUIVersion="CocosGUI v1.0.0.0";
ccui._FocusNavigationController=cc.Class.extend({_keyboardListener:null,_firstFocusedWidget:null,_enableFocusNavigation:!1,_keyboardEventPriority:1,enableFocusNavigation:function(a){this._enableFocusNavigation!==a&&(this._enableFocusNavigation=a,a?this._addKeyboardEventListener():this._removeKeyboardEventListener())},_setFirstFocsuedWidget:function(a){this._firstFocusedWidget=a},_onKeyPressed:function(a,b){this._enableFocusNavigation&&this._firstFocusedWidget&&(a===cc.KEY.dpadDown&&(this._firstFocusedWidget=
this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.DOWN,this._firstFocusedWidget)),a===cc.KEY.dpadUp&&(this._firstFocusedWidget=this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.UP,this._firstFocusedWidget)),a===cc.KEY.dpadLeft&&(this._firstFocusedWidget=this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.LEFT,this._firstFocusedWidget)),a===cc.KEY.dpadRight&&(this._firstFocusedWidget=this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.RIGHT,this._firstFocusedWidget)))},
_addKeyboardEventListener:function(){this._keyboardListener||(this._keyboardListener=cc.EventListener.create({event:cc.EventListener.KEYBOARD,onKeyReleased:this._onKeyPressed.bind(this)}),cc.eventManager.addListener(this._keyboardListener,this._keyboardEventPriority))},_removeKeyboardEventListener:function(){this._keyboardListener&&(cc.eventManager.removeEventListener(this._keyboardListener),this._keyboardListener=null)}});ccui.__LAYOUT_COMPONENT_NAME="__ui_layout";
ccui.Widget=ccui.ProtectedNode.extend({_enabled:!0,_bright:!0,_touchEnabled:!1,_brightStyle:null,_touchBeganPosition:null,_touchMovePosition:null,_touchEndPosition:null,_touchEventListener:null,_touchEventSelector:null,_name:"default",_widgetType:null,_actionTag:0,_customSize:null,_layoutParameterDictionary:null,_layoutParameterType:0,_focused:!1,_focusEnabled:!0,_ignoreSize:!1,_affectByClipping:!1,_sizeType:null,_sizePercent:null,_positionType:null,_positionPercent:null,_hit:!1,_nodes:null,_touchListener:null,
_className:"Widget",_flippedX:!1,_flippedY:!1,_opacity:255,_highlight:!1,_touchEventCallback:null,_clickEventListener:null,_propagateTouchEvents:!0,_unifySize:!1,_callbackName:null,_callbackType:null,_usingLayoutComponent:!1,ctor:function(){cc.ProtectedNode.prototype.ctor.call(this);this._brightStyle=ccui.Widget.BRIGHT_STYLE_NONE;this._touchBeganPosition=cc.p(0,0);this._touchMovePosition=cc.p(0,0);this._touchEndPosition=cc.p(0,0);this._widgetType=ccui.Widget.TYPE_WIDGET;this._customSize=cc.size(0,
0);this._layoutParameterDictionary={};this._sizeType=ccui.Widget.SIZE_ABSOLUTE;this._sizePercent=cc.p(0,0);this._positionType=ccui.Widget.POSITION_ABSOLUTE;this._positionPercent=cc.p(0,0);this._nodes=[];this._layoutParameterType=ccui.LayoutParameter.NONE;this.init()},init:function(){return cc.ProtectedNode.prototype.init.call(this)?(this._layoutParameterDictionary={},this._initRenderer(),this.setBright(!0),this.onFocusChanged=this.onFocusChange.bind(this),this.onNextFocusedWidget=null,this.setAnchorPoint(cc.p(0.5,
0.5)),this.ignoreContentAdaptWithSize(!0),!0):!1},onEnter:function(){var a=this._touchListener;a&&!a._isRegistered()&&this._touchEnabled&&cc.eventManager.addListener(a,this);this._usingLayoutComponent||this.updateSizeAndPosition();cc.ProtectedNode.prototype.onEnter.call(this)},onExit:function(){this.unscheduleUpdate();cc.ProtectedNode.prototype.onExit.call(this)},_getOrCreateLayoutComponent:function(){var a=this.getComponent(ccui.__LAYOUT_COMPONENT_NAME);return null==a&&(a=new ccui.LayoutComponent,
this.addComponent(a)),a},getWidgetParent:function(){var a=this.getParent();return a instanceof ccui.Widget?a:null},_updateContentSizeWithTextureSize:function(a){return this._unifySize?void this.setContentSize(a):void this.setContentSize(this._ignoreSize?a:this._customSize)},_isAncestorsEnabled:function(){var a=this._getAncensterWidget(this);return null==a?!0:a&&!a.isEnabled()?!1:a._isAncestorsEnabled()},setPropagateTouchEvents:function(a){this._propagateTouchEvents=a},isPropagateTouchEvents:function(){return this._propagateTouchEvents},
setSwallowTouches:function(a){this._touchListener&&this._touchListener.setSwallowTouches(a)},isSwallowTouches:function(){return this._touchListener?this._touchListener.isSwallowTouches():!1},_getAncensterWidget:function(a){if(null==a)return null;a=a.getParent();return null==a?null:a instanceof ccui.Widget?a:this._getAncensterWidget(a.getParent())},_isAncestorsVisible:function(a){return null==a?!0:(a=a.getParent())&&!a.isVisible()?!1:this._isAncestorsVisible(a)},_cleanupWidget:function(){this._eventDispatcher.removeEventListener(this._touchListener);
this._touchEnabled=!1;this._touchListener=null;ccui.Widget._focusedWidget===this&&(ccui.Widget._focusedWidget=null,ccui.Widget._focusNavigationController=null)},setEnabled:function(a){this._enabled=a},_initRenderer:function(){},setContentSize:function(a,b){var c=void 0===b?a.width:a,d=void 0===b?a.height:b;if(cc.Node.prototype.setContentSize.call(this,c,d),this._customSize.width=c,this._customSize.height=d,this._unifySize||this._ignoreSize&&(this._contentSize=this.getVirtualRendererSize()),!this._usingLayoutComponent&&
this._running){var e=this.getWidgetParent(),e=e?e.getContentSize():this._parent.getContentSize();this._sizePercent.x=0<e.width?c/e.width:0;this._sizePercent.y=0<e.height?d/e.height:0}this._onSizeChanged()},_setWidth:function(a){if(cc.Node.prototype._setWidth.call(this,a),this._customSize.width=a,this._unifySize||this._ignoreSize&&(this._contentSize=this.getVirtualRendererSize()),!this._usingLayoutComponent&&this._running)a=(a=this.getWidgetParent())?a.width:this._parent.width,this._sizePercent.x=
0<a?this._customSize.width/a:0;this._onSizeChanged()},_setHeight:function(a){if(cc.Node.prototype._setHeight.call(this,a),this._customSize.height=a,this._unifySize||this._ignoreSize&&(this._contentSize=this.getVirtualRendererSize()),!this._usingLayoutComponent&&this._running)a=(a=this.getWidgetParent())?a.height:this._parent.height,this._sizePercent.y=0<a?this._customSize.height/a:0;this._onSizeChanged()},setSizePercent:function(a){if(this._usingLayoutComponent){var b=this._getOrCreateLayoutComponent();
return b.setUsingPercentContentSize(!0),b.setPercentContentSize(a),void b.refreshLayout()}this._sizePercent.x=a.x;this._sizePercent.y=a.y;var b=this._customSize.width,c=this._customSize.height;if(this._running){var d=this.getWidgetParent();d?(b=d.width*a.x,c=d.height*a.y):(b=this._parent.width*a.x,c=this._parent.height*a.y)}this._ignoreSize?this.setContentSize(this.getVirtualRendererSize()):this.setContentSize(b,c);this._customSize.width=b;this._customSize.height=c},_setWidthPercent:function(a){this._sizePercent.x=
a;var b=this._customSize.width;this._running&&(b=this.getWidgetParent(),b=(b?b.width:this._parent.width)*a);this._setWidth(this._ignoreSize?this.getVirtualRendererSize().width:b);this._customSize.width=b},_setHeightPercent:function(a){this._sizePercent.y=a;var b=this._customSize.height;this._running&&(b=this.getWidgetParent(),b=(b?b.height:this._parent.height)*a);this._setHeight(this._ignoreSize?this.getVirtualRendererSize().height:b);this._customSize.height=b},updateSizeAndPosition:function(a){a||
(a=(a=this.getWidgetParent())?a.getLayoutSize():this._parent.getContentSize());switch(this._sizeType){case ccui.Widget.SIZE_ABSOLUTE:this.setContentSize(this._ignoreSize?this.getVirtualRendererSize():this._customSize);this._sizePercent.x=0<a.width?this._customSize.width/a.width:0;this._sizePercent.y=0<a.height?this._customSize.height/a.height:0;break;case ccui.Widget.SIZE_PERCENT:var b=cc.size(a.width*this._sizePercent.x,a.height*this._sizePercent.y);this.setContentSize(this._ignoreSize?this.getVirtualRendererSize():
b);this._customSize.width=b.width;this._customSize.height=b.height}this._onSizeChanged();b=this.getPosition();switch(this._positionType){case ccui.Widget.POSITION_ABSOLUTE:0>=a.width||0>=a.height?this._positionPercent.x=this._positionPercent.y=0:(this._positionPercent.x=b.x/a.width,this._positionPercent.y=b.y/a.height);break;case ccui.Widget.POSITION_PERCENT:b=cc.p(a.width*this._positionPercent.x,a.height*this._positionPercent.y)}if(this._parent instanceof ccui.ImageView&&(a=this._parent._imageRenderer)&&
!a._textureLoaded)return;this.setPosition(b)},setSizeType:function(a){(this._sizeType=a,this._usingLayoutComponent)&&this._getOrCreateLayoutComponent().setUsingPercentContentSize(this._sizeType===ccui.SIZE_PERCENT)},getSizeType:function(){return this._sizeType},ignoreContentAdaptWithSize:function(a){return this._unifySize?void this.setContentSize(this._customSize):void(this._ignoreSize!==a&&(this._ignoreSize=a,this.setContentSize(a?this.getVirtualRendererSize():this._customSize)))},isIgnoreContentAdaptWithSize:function(){return this._ignoreSize},
getCustomSize:function(){return cc.size(this._customSize)},getLayoutSize:function(){return cc.size(this._contentSize)},getSizePercent:function(){this._usingLayoutComponent&&(this._sizePercent=this._getOrCreateLayoutComponent().getPercentContentSize());return this._sizePercent},_getWidthPercent:function(){return this._sizePercent.x},_getHeightPercent:function(){return this._sizePercent.y},getWorldPosition:function(){return this.convertToWorldSpace(cc.p(this._anchorPoint.x*this._contentSize.width,this._anchorPoint.y*
this._contentSize.height))},getVirtualRenderer:function(){return this},getVirtualRendererSize:function(){return cc.size(this._contentSize)},_onSizeChanged:function(){if(!this._usingLayoutComponent)for(var a=this.getChildren(),b=0,c=a.length;c>b;b++){var d=a[b];d instanceof ccui.Widget&&d.updateSizeAndPosition()}},setTouchEnabled:function(a){this._touchEnabled!==a&&(this._touchEnabled=a,this._touchEnabled?(this._touchListener||(this._touchListener=cc.EventListener.create({event:cc.EventListener.TOUCH_ONE_BY_ONE,
swallowTouches:!0,onTouchBegan:this.onTouchBegan.bind(this),onTouchMoved:this.onTouchMoved.bind(this),onTouchEnded:this.onTouchEnded.bind(this)})),cc.eventManager.addListener(this._touchListener,this)):cc.eventManager.removeListener(this._touchListener))},isTouchEnabled:function(){return this._touchEnabled},isHighlighted:function(){return this._highlight},setHighlighted:function(a){a!==this._highlight&&(this._highlight=a,this._bright?this.setBrightStyle(this._highlight?ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT:
ccui.Widget.BRIGHT_STYLE_NORMAL):this._onPressStateChangedToDisabled())},isFocused:function(){return this._focused},setFocused:function(a){(this._focused=a)&&(ccui.Widget._focusedWidget=this,ccui.Widget._focusNavigationController&&ccui.Widget._focusNavigationController._setFirstFocsuedWidget(this))},isFocusEnabled:function(){return this._focusEnabled},setFocusEnabled:function(a){this._focusEnabled=a},findNextFocusedWidget:function(a,b){if(null===this.onNextFocusedWidget||null==this.onNextFocusedWidget(a)){var c=
b instanceof ccui.Layout;if(this.isFocused()||c){var d=this.getParent();return null!==d&&d instanceof ccui.Layout?d.findNextFocusedWidget(a,b):c?b.findNextFocusedWidget(a,b):b}return b}c=this.onNextFocusedWidget(a);return this.dispatchFocusEvent(this,c),c},requestFocus:function(){this!==ccui.Widget._focusedWidget&&this.dispatchFocusEvent(ccui.Widget._focusedWidget,this)},getCurrentFocusedWidget:function(){return ccui.Widget._focusedWidget},onFocusChanged:null,onNextFocusedWidget:null,interceptTouchEvent:function(a,
b,c){var d=this.getWidgetParent();d&&d.interceptTouchEvent(a,b,c)},onFocusChange:function(a,b){a&&a.setFocused(!1);b&&b.setFocused(!0)},dispatchFocusEvent:function(a,b){a&&!a.isFocused()&&(a=ccui.Widget._focusedWidget);b!==a&&(b&&b.onFocusChanged&&b.onFocusChanged(a,b),a&&b.onFocusChanged&&a.onFocusChanged(a,b),cc.eventManager.dispatchEvent(new cc.EventFocus(a,b)))},setBright:function(a){(this._bright=a)?(this._brightStyle=ccui.Widget.BRIGHT_STYLE_NONE,this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_NORMAL)):
this._onPressStateChangedToDisabled()},setBrightStyle:function(a){if(this._brightStyle!==a)switch(a=a||ccui.Widget.BRIGHT_STYLE_NORMAL,this._brightStyle=a,this._brightStyle){case ccui.Widget.BRIGHT_STYLE_NORMAL:this._onPressStateChangedToNormal();break;case ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT:this._onPressStateChangedToPressed()}},_onPressStateChangedToNormal:function(){},_onPressStateChangedToPressed:function(){},_onPressStateChangedToDisabled:function(){},_updateChildrenDisplayedRGBA:function(){this.setColor(this.getColor());
this.setOpacity(this.getOpacity())},didNotSelectSelf:function(){},onTouchBegan:function(a,b){if(this._hit=!1,this.isVisible()&&this.isEnabled()&&this._isAncestorsEnabled()&&this._isAncestorsVisible(this)){var c=a.getLocation();this._touchBeganPosition.x=c.x;this._touchBeganPosition.y=c.y;this.hitTest(this._touchBeganPosition)&&this.isClippingParentContainsPoint(this._touchBeganPosition)&&(this._hit=!0)}return this._hit?(this.setHighlighted(!0),this._propagateTouchEvents&&this.propagateTouchEvent(ccui.Widget.TOUCH_BEGAN,
this,a),this._pushDownEvent(),!0):!1},propagateTouchEvent:function(a,b,c){var d=this.getWidgetParent();d&&d.interceptTouchEvent(a,b,c)},onTouchMoved:function(a,b){var c=a.getLocation();this._touchMovePosition.x=c.x;this._touchMovePosition.y=c.y;this.setHighlighted(this.hitTest(c));this._propagateTouchEvents&&this.propagateTouchEvent(ccui.Widget.TOUCH_MOVED,this,a);this._moveEvent()},onTouchEnded:function(a,b){var c=a.getLocation();this._touchEndPosition.x=c.x;this._touchEndPosition.y=c.y;this._propagateTouchEvents&&
this.propagateTouchEvent(ccui.Widget.TOUCH_ENDED,this,a);c=this._highlight;this.setHighlighted(!1);c?this._releaseUpEvent():this._cancelUpEvent()},onTouchCancelled:function(a){this.setHighlighted(!1);this._cancelUpEvent()},onTouchLongClicked:function(a){this.longClickEvent()},_pushDownEvent:function(){this._touchEventCallback&&this._touchEventCallback(this,ccui.Widget.TOUCH_BEGAN);this._touchEventListener&&this._touchEventSelector&&this._touchEventSelector.call(this._touchEventListener,this,ccui.Widget.TOUCH_BEGAN)},
_moveEvent:function(){this._touchEventCallback&&this._touchEventCallback(this,ccui.Widget.TOUCH_MOVED);this._touchEventListener&&this._touchEventSelector&&this._touchEventSelector.call(this._touchEventListener,this,ccui.Widget.TOUCH_MOVED)},_releaseUpEvent:function(){this._touchEventCallback&&this._touchEventCallback(this,ccui.Widget.TOUCH_ENDED);this._touchEventListener&&this._touchEventSelector&&this._touchEventSelector.call(this._touchEventListener,this,ccui.Widget.TOUCH_ENDED);this._clickEventListener&&
this._clickEventListener(this)},_cancelUpEvent:function(){this._touchEventCallback&&this._touchEventCallback(this,ccui.Widget.TOUCH_CANCELED);this._touchEventListener&&this._touchEventSelector&&this._touchEventSelector.call(this._touchEventListener,this,ccui.Widget.TOUCH_CANCELED)},longClickEvent:function(){},addTouchEventListener:function(a,b){void 0===b?this._touchEventCallback=a:(this._touchEventSelector=a,this._touchEventListener=b)},addClickEventListener:function(a){this._clickEventListener=
a},hitTest:function(a){var b=cc.rect(0,0,this._contentSize.width,this._contentSize.height);return cc.rectContainsPoint(b,this.convertToNodeSpace(a))},isClippingParentContainsPoint:function(a){this._affectByClipping=!1;for(var b=this.getParent(),c=null;b;){if(b instanceof ccui.Layout&&b.isClippingEnabled()){this._affectByClipping=!0;c=b;break}b=b.getParent()}return this._affectByClipping&&c?c.hitTest(a)?c.isClippingParentContainsPoint(a):!1:!0},checkChildInfo:function(a,b,c){var d=this.getWidgetParent();
d&&d.checkChildInfo(a,b,c)},setPosition:function(a,b){if(!this._usingLayoutComponent&&this._running){var c=this.getWidgetParent();c&&(c=c.getContentSize(),0>=c.width||0>=c.height?(this._positionPercent.x=0,this._positionPercent.y=0):void 0===b?(this._positionPercent.x=a.x/c.width,this._positionPercent.y=a.y/c.height):(this._positionPercent.x=a/c.width,this._positionPercent.y=b/c.height))}cc.Node.prototype.setPosition.call(this,a,b)},setPositionX:function(a){if(this._running){var b=this.getWidgetParent();
b&&(b=b.width,0>=b?this._positionPercent.x=0:this._positionPercent.x=a/b)}cc.Node.prototype.setPositionX.call(this,a)},setPositionY:function(a){if(this._running){var b=this.getWidgetParent();b&&(b=b.height,0>=b?this._positionPercent.y=0:this._positionPercent.y=a/b)}cc.Node.prototype.setPositionY.call(this,a)},setPositionPercent:function(a){if(this._usingLayoutComponent){var b=this._getOrCreateLayoutComponent();return b.setPositionPercentX(a.x),b.setPositionPercentY(a.y),void b.refreshLayout()}this._setXPercent(a.x);
this._setYPercent(a.y);this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},_setXPercent:function(a){if(this._usingLayoutComponent){var b=this._getOrCreateLayoutComponent();return b.setPositionPercentX(a.x),void b.refreshLayout()}this._positionPercent.x=a},_setYPercent:function(a){if(this._usingLayoutComponent){var b=this._getOrCreateLayoutComponent();return b.setPositionPercentY(a.x),void b.refreshLayout()}this._positionPercent.y=a},getPositionPercent:function(){if(this._usingLayoutComponent){var a=
this._getOrCreateLayoutComponent();this._positionPercent.x=a.getPositionPercentX();this._positionPercent.y=a.getPositionPercentY()}return cc.p(this._positionPercent)},_getXPercent:function(){if(this._usingLayoutComponent){var a=this._getOrCreateLayoutComponent();this._positionPercent.x=a.getPositionPercentX();this._positionPercent.y=a.getPositionPercentY()}return this._positionPercent.x},_getYPercent:function(){if(this._usingLayoutComponent){var a=this._getOrCreateLayoutComponent();this._positionPercent.x=
a.getPositionPercentX();this._positionPercent.y=a.getPositionPercentY()}return this._positionPercent.y},setPositionType:function(a){if(this._positionType=a,this._usingLayoutComponent){var b=this._getOrCreateLayoutComponent();a===ccui.POSITION_ABSOLUTE?(b.setPositionPercentXEnabled(!1),b.setPositionPercentYEnabled(!1)):(b.setPositionPercentXEnabled(!0),b.setPositionPercentYEnabled(!0))}this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getPositionType:function(){return this._positionType},
setFlippedX:function(a){var b=this.getScaleX();this._flippedX=a;this.setScaleX(b)},isFlippedX:function(){return this._flippedX},setFlippedY:function(a){var b=this.getScaleY();this._flippedY=a;this.setScaleY(b)},isFlippedY:function(){return this._flippedY},_adaptRenderers:function(){},isBright:function(){return this._bright},isEnabled:function(){return this._enabled},getLeftBoundary:function(){return this.getPositionX()-this._getAnchorX()*this._contentSize.width},getBottomBoundary:function(){return this.getPositionY()-
this._getAnchorY()*this._contentSize.height},getRightBoundary:function(){return this.getLeftBoundary()+this._contentSize.width},getTopBoundary:function(){return this.getBottomBoundary()+this._contentSize.height},getTouchBeganPosition:function(){return cc.p(this._touchBeganPosition)},getTouchMovePosition:function(){return cc.p(this._touchMovePosition)},getTouchEndPosition:function(){return cc.p(this._touchEndPosition)},getWidgetType:function(){return this._widgetType},setLayoutParameter:function(a){a&&
(this._layoutParameterDictionary[a.getLayoutType()]=a,this._layoutParameterType=a.getLayoutType())},getLayoutParameter:function(a){return a=a||this._layoutParameterType,this._layoutParameterDictionary[a]},getDescription:function(){return"Widget"},clone:function(){var a=this._createCloneInstance();return a._copyProperties(this),a._copyClonedWidgetChildren(this),a},_createCloneInstance:function(){return new ccui.Widget},_copyClonedWidgetChildren:function(a){a=a.getChildren();for(var b=0;b<a.length;b++){var c=
a[b];c instanceof ccui.Widget&&this.addChild(c.clone())}},_copySpecialProperties:function(a){},_copyProperties:function(a){this.setEnabled(a.isEnabled());this.setVisible(a.isVisible());this.setBright(a.isBright());this.setTouchEnabled(a.isTouchEnabled());this.setLocalZOrder(a.getLocalZOrder());this.setTag(a.getTag());this.setName(a.getName());this.setActionTag(a.getActionTag());this._ignoreSize=a._ignoreSize;this.setContentSize(a._contentSize);this._customSize.width=a._customSize.width;this._customSize.height=
a._customSize.height;this._copySpecialProperties(a);this._sizeType=a.getSizeType();this._sizePercent.x=a._sizePercent.x;this._sizePercent.y=a._sizePercent.y;this._positionType=a._positionType;this._positionPercent.x=a._positionPercent.x;this._positionPercent.y=a._positionPercent.y;this.setPosition(a.getPosition());this.setAnchorPoint(a.getAnchorPoint());this.setScaleX(a.getScaleX());this.setScaleY(a.getScaleY());this.setRotation(a.getRotation());this.setRotationX(a.getRotationX());this.setRotationY(a.getRotationY());
this.setFlippedX(a.isFlippedX());this.setFlippedY(a.isFlippedY());this.setColor(a.getColor());this.setOpacity(a.getOpacity());this._touchEventCallback=a._touchEventCallback;this._touchEventListener=a._touchEventListener;this._touchEventSelector=a._touchEventSelector;this._clickEventListener=a._clickEventListener;this._focused=a._focused;this._focusEnabled=a._focusEnabled;this._propagateTouchEvents=a._propagateTouchEvents;for(var b in a._layoutParameterDictionary){var c=a._layoutParameterDictionary[b];
c&&this.setLayoutParameter(c.clone())}this._onSizeChanged()},setActionTag:function(a){this._actionTag=a},getActionTag:function(){return this._actionTag},getLeftInParent:function(){return cc.log("getLeftInParent is deprecated. Please use getLeftBoundary instead."),this.getLeftBoundary()},getBottomInParent:function(){return cc.log("getBottomInParent is deprecated. Please use getBottomBoundary instead."),this.getBottomBoundary()},getRightInParent:function(){return cc.log("getRightInParent is deprecated. Please use getRightBoundary instead."),
this.getRightBoundary()},getTopInParent:function(){return cc.log("getTopInParent is deprecated. Please use getTopBoundary instead."),this.getTopBoundary()},getTouchEndPos:function(){return cc.log("getTouchEndPos is deprecated. Please use getTouchEndPosition instead."),this.getTouchEndPosition()},getTouchMovePos:function(){return cc.log("getTouchMovePos is deprecated. Please use getTouchMovePosition instead."),this.getTouchMovePosition()},clippingParentAreaContainPoint:function(a){cc.log("clippingParentAreaContainPoint is deprecated. Please use isClippingParentContainsPoint instead.");
this.isClippingParentContainsPoint(a)},getTouchStartPos:function(){return cc.log("getTouchStartPos is deprecated. Please use getTouchBeganPosition instead."),this.getTouchBeganPosition()},setSize:function(a){this.setContentSize(a)},getSize:function(){return this.getContentSize()},addNode:function(a,b,c){return a instanceof ccui.Widget?void cc.log("Please use addChild to add a Widget."):(cc.Node.prototype.addChild.call(this,a,b,c),void this._nodes.push(a))},getNodeByTag:function(a){for(var b=this._nodes,
c=0;c<b.length;c++){var d=b[c];if(d&&d.getTag()===a)return d}return null},getNodes:function(){return this._nodes},removeNode:function(a,b){cc.Node.prototype.removeChild.call(this,a,b);cc.arrayRemoveObject(this._nodes,a)},removeNodeByTag:function(a,b){var c=this.getChildByTag(a);c?this.removeChild(c,b):cc.log("cocos2d: removeNodeByTag(tag \x3d %d): child not found!",a)},removeAllNodes:function(){for(var a=0;a<this._nodes.length;a++)cc.Node.prototype.removeChild.call(this,this._nodes[a]);this._nodes.length=
0},_findLayout:function(){cc.renderer.childrenOrderDirty=!0;for(var a=this._parent;a;){if(a._doLayout){a._doLayoutDirty=!0;break}a=a._parent}},isUnifySizeEnabled:function(){return this._unifySize},setUnifySizeEnabled:function(a){this._unifySize=a},_ccEventCallback:null,addCCSEventListener:function(a){this._ccEventCallback=a},setScaleX:function(a){this._flippedX&&(a*=-1);cc.Node.prototype.setScaleX.call(this,a)},setScaleY:function(a){this._flippedY&&(a*=-1);cc.Node.prototype.setScaleY.call(this,a)},
setScale:function(a,b){void 0===b&&(b=a);this.setScaleX(a);this.setScaleY(b)},getScaleX:function(){var a=cc.Node.prototype.getScaleX.call(this);return this._flippedX&&(a*=-1),a},getScaleY:function(){var a=cc.Node.prototype.getScaleY.call(this);return this._flippedY&&(a*=-1),a},getScale:function(){return this.getScaleX()===this.getScaleY()&&cc.log("Widget#scale. ScaleX !\x3d ScaleY. Don't know which one to return"),this.getScaleX()},setCallbackName:function(a){this._callbackName=a},getCallbackName:function(){return this._callbackName},
setCallbackType:function(a){this._callbackType=a},getCallbackType:function(){return this._callbackType},setLayoutComponentEnabled:function(a){this._usingLayoutComponent=a},isLayoutComponentEnabled:function(){return this._usingLayoutComponent},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_WEBGL?new ccui.Widget.WebGLRenderCmd(this):new ccui.Widget.CanvasRenderCmd(this)}});_p=ccui.Widget.prototype;_p.xPercent;cc.defineGetterSetter(_p,"xPercent",_p._getXPercent,_p._setXPercent);
_p.yPercent;cc.defineGetterSetter(_p,"yPercent",_p._getYPercent,_p._setYPercent);_p.widthPercent;cc.defineGetterSetter(_p,"widthPercent",_p._getWidthPercent,_p._setWidthPercent);_p.heightPercent;cc.defineGetterSetter(_p,"heightPercent",_p._getHeightPercent,_p._setHeightPercent);_p.widgetParent;cc.defineGetterSetter(_p,"widgetParent",_p.getWidgetParent);_p.enabled;cc.defineGetterSetter(_p,"enabled",_p.isEnabled,_p.setEnabled);_p.focused;cc.defineGetterSetter(_p,"focused",_p.isFocused,_p.setFocused);
_p.sizeType;cc.defineGetterSetter(_p,"sizeType",_p.getSizeType,_p.setSizeType);_p.widgetType;cc.defineGetterSetter(_p,"widgetType",_p.getWidgetType);_p.touchEnabled;cc.defineGetterSetter(_p,"touchEnabled",_p.isTouchEnabled,_p.setTouchEnabled);_p.updateEnabled;cc.defineGetterSetter(_p,"updateEnabled",_p.isUpdateEnabled,_p.setUpdateEnabled);_p.bright;cc.defineGetterSetter(_p,"bright",_p.isBright,_p.setBright);_p.name;cc.defineGetterSetter(_p,"name",_p.getName,_p.setName);_p.actionTag;
cc.defineGetterSetter(_p,"actionTag",_p.getActionTag,_p.setActionTag);_p.opacity;cc.defineGetterSetter(_p,"opacity",_p.getOpacity,_p.setOpacity);_p=null;ccui.Widget.create=function(){return new ccui.Widget};ccui.Widget._focusedWidget=null;ccui.Widget._focusNavigationController=null;
ccui.Widget.enableDpadNavigation=function(a){a?(null==ccui.Widget._focusNavigationController&&(ccui.Widget._focusNavigationController=new ccui._FocusNavigationController,ccui.Widget._focusedWidget&&ccui.Widget._focusNavigationController._setFirstFocsuedWidget(ccui.Widget._focusedWidget)),ccui.Widget._focusNavigationController.enableFocusNavigation(!0)):ccui.Widget._focusNavigationController&&(ccui.Widget._focusNavigationController.enableFocusNavigation(!1),ccui.Widget._focusNavigationController=null)};
ccui.Widget.getCurrentFocusedWidget=function(){return ccui.Widget._focusedWidget};ccui.Widget.BRIGHT_STYLE_NONE=-1;ccui.Widget.BRIGHT_STYLE_NORMAL=0;ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT=1;ccui.Widget.TYPE_WIDGET=0;ccui.Widget.TYPE_CONTAINER=1;ccui.Widget.LEFT=0;ccui.Widget.RIGHT=1;ccui.Widget.UP=2;ccui.Widget.DOWN=3;ccui.Widget.LOCAL_TEXTURE=0;ccui.Widget.PLIST_TEXTURE=1;ccui.Widget.TOUCH_BEGAN=0;ccui.Widget.TOUCH_MOVED=1;ccui.Widget.TOUCH_ENDED=2;ccui.Widget.TOUCH_CANCELED=3;
ccui.Widget.SIZE_ABSOLUTE=0;ccui.Widget.SIZE_PERCENT=1;ccui.Widget.POSITION_ABSOLUTE=0;ccui.Widget.POSITION_PERCENT=1;
cc._renderType===cc._RENDER_TYPE_CANVAS?!function(){ccui.Widget.CanvasRenderCmd=function(a){cc.ProtectedNode.CanvasRenderCmd.call(this,a);this._needDraw=!1};var a=ccui.Widget.CanvasRenderCmd.prototype=Object.create(cc.ProtectedNode.CanvasRenderCmd.prototype);a.constructor=ccui.Widget.CanvasRenderCmd;a.visit=function(a){var c=this._node;c._visible&&(c._adaptRenderers(),cc.ProtectedNode.CanvasRenderCmd.prototype.visit.call(this,a))};a.transform=function(a,c){var d=this._node;if(d._visible){if(d._adaptRenderers(),
!this._usingLayoutComponent){var e=d.getWidgetParent();e&&(e=e.getContentSize(),0!==e.width&&0!==e.height&&(d._position.x=e.width*d._positionPercent.x,d._position.y=e.height*d._positionPercent.y))}cc.ProtectedNode.CanvasRenderCmd.prototype.transform.call(this,a,c)}}}():!function(){ccui.Widget.WebGLRenderCmd=function(a){cc.ProtectedNode.WebGLRenderCmd.call(this,a);this._needDraw=!1};var a=ccui.Widget.WebGLRenderCmd.prototype=Object.create(cc.ProtectedNode.WebGLRenderCmd.prototype);a.constructor=ccui.Widget.WebGLRenderCmd;
a.visit=function(a){var c=this._node;c._visible&&(c._adaptRenderers(),cc.ProtectedNode.WebGLRenderCmd.prototype.visit.call(this,a))};a.transform=function(a,c){var d=this._node;if(d._visible){if(d._adaptRenderers(),!this._usingLayoutComponent){var e=d.getWidgetParent();e&&(e=e.getContentSize(),0!==e.width&&0!==e.height&&(d._position.x=e.width*d._positionPercent.x,d._position.y=e.height*d._positionPercent.y))}cc.ProtectedNode.WebGLRenderCmd.prototype.transform.call(this,a,c)}}}();
ccui.Scale9Sprite=cc.Node.extend({_spriteRect:null,_capInsetsInternal:null,_positionsAreDirty:!1,_scale9Image:null,_topLeft:null,_top:null,_topRight:null,_left:null,_centre:null,_right:null,_bottomLeft:null,_bottom:null,_bottomRight:null,_scale9Dirty:!0,_opacityModifyRGB:!1,_originalSize:null,_preferredSize:null,_opacity:0,_color:null,_capInsets:null,_insetLeft:0,_insetTop:0,_insetRight:0,_insetBottom:0,_spritesGenerated:!1,_spriteFrameRotated:!1,_textureLoaded:!1,_className:"Scale9Sprite",_flippedX:!1,
_flippedY:!1,textureLoaded:function(){return this._textureLoaded},addLoadedEventListener:function(a,b){this.addEventListener("load",a,b)},_updateCapInset:function(){var a;a=this._insetLeft;var b=this._insetTop,c=this._insetRight,d=this._spriteRect,e=this._insetBottom;a=0===a&&0===b&&0===c&&0===e?cc.rect(0,0,0,0):this._spriteFrameRotated?cc.rect(e,a,d.width-c-a,d.height-b-e):cc.rect(a,b,d.width-a-c,d.height-b-e);this.setCapInsets(a)},_updatePositions:function(){if(this._topLeft&&this._topRight&&this._bottomRight&&
this._bottomLeft&&this._centre){var a=this._contentSize,b=this._topLeft,c=this._topRight,d=this._bottomRight,e=this._bottomLeft,f=this._centre,g=this._centre.getContentSize(),h=b.getContentSize(),k=e.getContentSize(),m=a.width-h.width-c.getContentSize().width,a=a.height-h.height-d.getContentSize().height,m=m/g.width,a=a/g.height,h=g.width*m,n=g.height*a,p=k.width,k=k.height;if(cc._renderType===cc._RENDER_TYPE_WEBGL){var r=Math.round(h);h!==r&&(h=r,m=h/g.width);r=Math.round(n);n!==r&&(n=r,a=n/g.height)}f.setScaleX(m);
f.setScaleY(a);var g=this._left,r=this._right,s=this._top,v=this._bottom,u=cc.p(0,0);e.setAnchorPoint(u);d.setAnchorPoint(u);b.setAnchorPoint(u);c.setAnchorPoint(u);g.setAnchorPoint(u);r.setAnchorPoint(u);s.setAnchorPoint(u);v.setAnchorPoint(u);f.setAnchorPoint(u);e.setPosition(0,0);d.setPosition(p+h,0);b.setPosition(0,k+n);c.setPosition(p+h,k+n);g.setPosition(0,k);g.setScaleY(a);r.setPosition(p+h,k);r.setScaleY(a);v.setPosition(p,0);v.setScaleX(m);s.setPosition(p,k+n);s.setScaleX(m);f.setPosition(p,
k)}},ctor:function(a,b,c){if(cc.Node.prototype.ctor.call(this),this._spriteRect=cc.rect(0,0,0,0),this._capInsetsInternal=cc.rect(0,0,0,0),this._originalSize=cc.size(0,0),this._preferredSize=cc.size(0,0),this._capInsets=cc.rect(0,0,0,0),void 0!=a)if(a instanceof cc.SpriteFrame)this.initWithSpriteFrame(a,b);else{var d=cc.spriteFrameCache.getSpriteFrame(a);null!=d?this.initWithSpriteFrame(d,b):this.initWithFile(a,b,c)}else this.init()},getSprite:function(){return this._scale9Image},getOriginalSize:function(){return cc.size(this._originalSize)},
getPreferredSize:function(){return cc.size(this._preferredSize)},_getPreferredWidth:function(){return this._preferredSize.width},_getPreferredHeight:function(){return this._preferredSize.height},setPreferredSize:function(a){this.setContentSize(a);this._preferredSize=a;this._positionsAreDirty&&(this._updatePositions(),this._positionsAreDirty=!1,this._scale9Dirty=!0)},_setPreferredWidth:function(a){this._setWidth(a);this._preferredSize.width=a},_setPreferredHeight:function(a){this._setHeight(a);this._preferredSize.height=
a},setOpacity:function(a){if(this._scale9Image){cc.Node.prototype.setOpacity.call(this,a);for(var b=this._scale9Image.getChildren(),c=0;c<b.length;c++){var d=b[c];d&&d.setOpacity(a)}this._scale9Dirty=!0}},setColor:function(a){if(this._scale9Image){cc.Node.prototype.setColor.call(this,a);for(var b=this._scale9Image.getChildren(),c=0;c<b.length;c++){var d=b[c];d&&d.setColor(a)}this._scale9Dirty=!0}},getCapInsets:function(){return cc.rect(this._capInsets)},setCapInsets:function(a){if(this._scale9Image){var b=
this._contentSize,c=b.width,b=b.height;this.updateWithBatchNode(this._scale9Image,this._spriteRect,this._spriteFrameRotated,a);this.setContentSize(c,b)}},getInsetLeft:function(){return this._insetLeft},setInsetLeft:function(a){this._insetLeft=a;this._updateCapInset()},getInsetTop:function(){return this._insetTop},setInsetTop:function(a){this._insetTop=a;this._updateCapInset()},getInsetRight:function(){return this._insetRight},setInsetRight:function(a){this._insetRight=a;this._updateCapInset()},getInsetBottom:function(){return this._insetBottom},
setInsetBottom:function(a){this._insetBottom=a;this._updateCapInset()},setContentSize:function(a,b){cc.Node.prototype.setContentSize.call(this,a,b);this._positionsAreDirty=!0},_setWidth:function(a){cc.Node.prototype._setWidth.call(this,a);this._positionsAreDirty=!0},_setHeight:function(a){cc.Node.prototype._setHeight.call(this,a);this._positionsAreDirty=!0},init:function(){return this.initWithBatchNode(null,cc.rect(0,0,0,0),!1,cc.rect(0,0,0,0))},initWithBatchNode:function(a,b,c,d){return void 0===
d&&(d=c,c=!1),a&&this.updateWithBatchNode(a,b,c,d),this.setCascadeColorEnabled(!0),this.setCascadeOpacityEnabled(!0),this.setAnchorPoint(0.5,0.5),this._positionsAreDirty=!0,!0},initWithFile:function(a,b,c){if(a instanceof cc.Rect?(a=b,c=a,b=cc.rect(0,0,0,0)):(b=b||cc.rect(0,0,0,0),c=c||cc.rect(0,0,0,0)),!a)throw"ccui.Scale9Sprite.initWithFile(): file should be non-null";var d=cc.textureCache.getTextureForKey(a);d||(d=cc.textureCache.addImage(a));var e=d.isLoaded();return this._textureLoaded=e,e||
d.addEventListener("load",function(a){var b=this._preferredSize,c=0!==b.width&&0!==b.height;c&&(b=cc.size(b.width,b.height));a=a.getContentSize();this.updateWithBatchNode(this._scale9Image,cc.rect(0,0,a.width,a.height),!1,this._capInsets);c&&this.setPreferredSize(b);this._positionsAreDirty=!0;this.dispatchEvent("load")},this),this.initWithBatchNode(new cc.SpriteBatchNode(a,9),b,!1,c)},initWithSpriteFrame:function(a,b){if(!a||!a.getTexture())throw"ccui.Scale9Sprite.initWithSpriteFrame(): spriteFrame should be non-null and its texture should be non-null";
b=b||cc.rect(0,0,0,0);var c=a.textureLoaded();(this._textureLoaded=c)||a.addEventListener("load",function(a){var b=this._preferredSize,c=0!==b.width&&0!==b.height;c&&(b=cc.size(b.width,b.height));this.updateWithBatchNode(this._scale9Image,a.getRect(),cc._renderType===cc._RENDER_TYPE_WEBGL&&a.isRotated(),this._capInsets);c&&this.setPreferredSize(b);this._positionsAreDirty=!0;this.dispatchEvent("load")},this);c=new cc.SpriteBatchNode(a.getTexture(),9);return this.initWithBatchNode(c,a.getRect(),cc._renderType===
cc._RENDER_TYPE_WEBGL&&a.isRotated(),b)},initWithSpriteFrameName:function(a,b){if(!a)throw"ccui.Scale9Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null";b=b||cc.rect(0,0,0,0);var c=cc.spriteFrameCache.getSpriteFrame(a);return null==c?(cc.log("ccui.Scale9Sprite.initWithSpriteFrameName(): can't find the sprite frame by spriteFrameName"),!1):this.initWithSpriteFrame(c,b)},resizableSpriteWithCapInsets:function(a){var b=new ccui.Scale9Sprite;return b&&b.initWithBatchNode(this._scale9Image,
this._spriteRect,!1,a)?b:null},setOpacityModifyRGB:function(a){if(this._scale9Image){this._opacityModifyRGB=a;var b=this._scale9Image.getChildren();if(b)for(var c=0,d=b.length;d>c;c++)b[c].setOpacityModifyRGB(a)}},isOpacityModifyRGB:function(){return this._opacityModifyRGB},updateWithBatchNode:function(a,b,c,d){var e=this.getOpacity(),f=this.getColor();b=cc.rect(b.x,b.y,b.width,b.height);if(this.removeAllChildren(!0),this._scale9Image!==a&&(this._scale9Image=a),!this._scale9Image)return!1;a=a.getTexture();
var g=a.isLoaded();this._textureLoaded=g;var h=this._capInsets;if(h.x=d.x,h.y=d.y,h.width=d.width,h.height=d.height,!g)return a.addEventListener("load",function(a){this._positionsAreDirty=!0;this.dispatchEvent("load")},this),!0;a=this._scale9Image;a.removeAllChildren(!0);this._spriteFrameRotated=c;g=a.getTexture();cc._rectEqualToZero(b)&&(b=g.getContentSize(),b=cc.rect(0,0,b.width,b.height));h=this._spriteRect=b;h.x=b.x;h.y=b.y;h.width=b.width;h.height=b.height;this._originalSize.width=b.width;this._originalSize.height=
b.height;h=this._preferredSize;0===h.width&&0===h.height&&(h.width=b.width,h.height=b.height);h=this._capInsetsInternal;d&&(h.x=d.x,h.y=d.y,h.width=d.width,h.height=d.height);var k=b.width;d=b.height;cc._rectEqualToZero(h)&&(h.x=k/3,h.y=d/3,h.width=k/3,h.height=d/3);var m=h.x,n=h.width,p=k-(m+n),r=h.y,s=h.height,v=d-(r+s),u=0,t=0;d=cc.rect(u+0.5|0,t+0.5|0,m+0.5|0,r+0.5|0);var u=u+m,h=cc.rect(u+0.5|0,t+0.5|0,n+0.5|0,r+0.5|0),k=cc.rect(u+n+0.5|0,t+0.5|0,p+0.5|0,r+0.5|0),u=0,t=0+r,x=cc.rect(u+0.5|0,
t+0.5|0,m+0.5|0,s+0.5|0),u=u+m,A=cc.rect(u+0.5|0,t+0.5|0,n+0.5|0,s+0.5|0),u=u+n,F=cc.rect(u+0.5|0,t+0.5|0,p+0.5|0,s+0.5|0),u=0,t=0+r+s,r=cc.rect(u+0.5|0,t+0.5|0,m+0.5|0,v+0.5|0),u=u+m,m=cc.rect(u+0.5|0,t+0.5|0,n+0.5|0,v+0.5|0),u=u+n,n=cc.rect(u+0.5|0,t+0.5|0,p+0.5|0,v+0.5|0),p=cc.affineTransformMakeIdentity();if(c){c=A;var v=n,u=r,t=k,s=d,z=F,w=x,B=m,E=h,p=cc.affineTransformTranslate(p,b.height+b.x,b.y),p=cc.affineTransformRotate(p,1.57079633),A=cc.rectApplyAffineTransform(A,p),n=cc.rectApplyAffineTransform(n,
p),r=cc.rectApplyAffineTransform(r,p),k=cc.rectApplyAffineTransform(k,p);d=cc.rectApplyAffineTransform(d,p);F=cc.rectApplyAffineTransform(F,p);x=cc.rectApplyAffineTransform(x,p);m=cc.rectApplyAffineTransform(m,p);h=cc.rectApplyAffineTransform(h,p);c.x=A.x;c.y=A.y;v.x=n.x;v.y=n.y;u.x=r.x;u.y=r.y;t.x=k.x;t.y=k.y;s.x=d.x;s.y=d.y;z.x=F.x;z.y=F.y;w.x=x.x;w.y=x.y;B.x=m.x;B.y=m.y;E.x=h.x;E.y=h.y;this._centre=new cc.Sprite;this._centre.initWithTexture(g,c,!0);a.addChild(this._centre,0,ccui.Scale9Sprite.POSITIONS_CENTRE);
this._top=new cc.Sprite;this._top.initWithTexture(g,E,!0);a.addChild(this._top,1,ccui.Scale9Sprite.POSITIONS_TOP);this._bottom=new cc.Sprite;this._bottom.initWithTexture(g,B,!0);a.addChild(this._bottom,1,ccui.Scale9Sprite.POSITIONS_BOTTOM);this._left=new cc.Sprite;this._left.initWithTexture(g,w,!0);a.addChild(this._left,1,ccui.Scale9Sprite.POSITIONS_LEFT);this._right=new cc.Sprite;this._right.initWithTexture(g,z,!0);a.addChild(this._right,1,ccui.Scale9Sprite.POSITIONS_RIGHT);this._topLeft=new cc.Sprite;
this._topLeft.initWithTexture(g,s,!0);a.addChild(this._topLeft,2,ccui.Scale9Sprite.POSITIONS_TOPLEFT);this._topRight=new cc.Sprite;this._topRight.initWithTexture(g,t,!0);a.addChild(this._topRight,2,ccui.Scale9Sprite.POSITIONS_TOPRIGHT);this._bottomLeft=new cc.Sprite;this._bottomLeft.initWithTexture(g,u,!0);a.addChild(this._bottomLeft,2,ccui.Scale9Sprite.POSITIONS_BOTTOMLEFT);this._bottomRight=new cc.Sprite;this._bottomRight.initWithTexture(g,v,!0)}else p=cc.affineTransformTranslate(p,b.x,b.y),cc._rectApplyAffineTransformIn(A,
p),cc._rectApplyAffineTransformIn(n,p),cc._rectApplyAffineTransformIn(r,p),cc._rectApplyAffineTransformIn(k,p),cc._rectApplyAffineTransformIn(d,p),cc._rectApplyAffineTransformIn(F,p),cc._rectApplyAffineTransformIn(x,p),cc._rectApplyAffineTransformIn(m,p),cc._rectApplyAffineTransformIn(h,p),this._centre=new cc.Sprite,this._centre.initWithTexture(g,A),a.addChild(this._centre,0,ccui.Scale9Sprite.POSITIONS_CENTRE),this._top=new cc.Sprite,this._top.initWithTexture(g,h),a.addChild(this._top,1,ccui.Scale9Sprite.POSITIONS_TOP),
this._bottom=new cc.Sprite,this._bottom.initWithTexture(g,m),a.addChild(this._bottom,1,ccui.Scale9Sprite.POSITIONS_BOTTOM),this._left=new cc.Sprite,this._left.initWithTexture(g,x),a.addChild(this._left,1,ccui.Scale9Sprite.POSITIONS_LEFT),this._right=new cc.Sprite,this._right.initWithTexture(g,F),a.addChild(this._right,1,ccui.Scale9Sprite.POSITIONS_RIGHT),this._topLeft=new cc.Sprite,this._topLeft.initWithTexture(g,d),a.addChild(this._topLeft,2,ccui.Scale9Sprite.POSITIONS_TOPLEFT),this._topRight=new cc.Sprite,
this._topRight.initWithTexture(g,k),a.addChild(this._topRight,2,ccui.Scale9Sprite.POSITIONS_TOPRIGHT),this._bottomLeft=new cc.Sprite,this._bottomLeft.initWithTexture(g,r),a.addChild(this._bottomLeft,2,ccui.Scale9Sprite.POSITIONS_BOTTOMLEFT),this._bottomRight=new cc.Sprite,this._bottomRight.initWithTexture(g,n);a.addChild(this._bottomRight,2,ccui.Scale9Sprite.POSITIONS_BOTTOMRIGHT);return this.setContentSize(b.width,b.height),cc._renderType===cc._RENDER_TYPE_WEBGL&&this.addChild(a),this._spritesGenerated&&
(this.setOpacity(e),this.setColor(f)),this._spritesGenerated=!0,!0},setSpriteFrame:function(a){var b=new cc.SpriteBatchNode(a.getTexture(),9),c=a.textureLoaded();(this._textureLoaded=c)||a.addEventListener("load",function(a){var b=this._preferredSize,c=0!==b.width&&0!==b.height;c&&(b=cc.size(b.width,b.height));this.updateWithBatchNode(this._scale9Image,a.getRect(),cc._renderType===cc._RENDER_TYPE_WEBGL&&a.isRotated(),this._capInsets);c&&this.setPreferredSize(b);this._positionsAreDirty=!0;this.dispatchEvent("load")},
this);this.updateWithBatchNode(b,a.getRect(),cc._renderType===cc._RENDER_TYPE_WEBGL&&a.isRotated(),cc.rect(0,0,0,0));this._insetBottom=this._insetRight=this._insetTop=this._insetLeft=0},setState:function(a){this._renderCmd.setState(a)},setFlippedX:function(a){var b=this.getScaleX();this._flippedX=a;this.setScaleX(b)},isFlippedX:function(){return this._flippedX},setFlippedY:function(a){var b=this.getScaleY();this._flippedY=a;this.setScaleY(b)},isFlippedY:function(){return this._flippedY},setScaleX:function(a){this._flippedX&&
(a*=-1);cc.Node.prototype.setScaleX.call(this,a)},setScaleY:function(a){this._flippedY&&(a*=-1);cc.Node.prototype.setScaleY.call(this,a)},setScale:function(a,b){void 0===b&&(b=a);this.setScaleX(a);this.setScaleY(b)},getScaleX:function(){var a=cc.Node.prototype.getScaleX.call(this);return this._flippedX&&(a*=-1),a},getScaleY:function(){var a=cc.Node.prototype.getScaleY.call(this);return this._flippedY&&(a*=-1),a},getScale:function(){return this.getScaleX()!==this.getScaleY()&&cc.log("Scale9Sprite#scale. ScaleX !\x3d ScaleY. Don't know which one to return"),
this.getScaleX()},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new ccui.Scale9Sprite.CanvasRenderCmd(this):new ccui.Scale9Sprite.WebGLRenderCmd(this)}});_p=ccui.Scale9Sprite.prototype;cc.EventHelper.prototype.apply(_p);_p.preferredSize;cc.defineGetterSetter(_p,"preferredSize",_p.getPreferredSize,_p.setPreferredSize);_p.capInsets;cc.defineGetterSetter(_p,"capInsets",_p.getCapInsets,_p.setCapInsets);_p.insetLeft;cc.defineGetterSetter(_p,"insetLeft",_p.getInsetLeft,_p.setInsetLeft);
_p.insetTop;cc.defineGetterSetter(_p,"insetTop",_p.getInsetTop,_p.setInsetTop);_p.insetRight;cc.defineGetterSetter(_p,"insetRight",_p.getInsetRight,_p.setInsetRight);_p.insetBottom;cc.defineGetterSetter(_p,"insetBottom",_p.getInsetBottom,_p.setInsetBottom);_p=null;ccui.Scale9Sprite.create=function(a,b,c){return new ccui.Scale9Sprite(a,b,c)};ccui.Scale9Sprite.createWithSpriteFrame=function(a,b){return new ccui.Scale9Sprite(a,b)};
ccui.Scale9Sprite.createWithSpriteFrameName=function(a,b){return new ccui.Scale9Sprite(a,b)};ccui.Scale9Sprite.POSITIONS_CENTRE=0;ccui.Scale9Sprite.POSITIONS_TOP=1;ccui.Scale9Sprite.POSITIONS_LEFT=2;ccui.Scale9Sprite.POSITIONS_RIGHT=3;ccui.Scale9Sprite.POSITIONS_BOTTOM=4;ccui.Scale9Sprite.POSITIONS_TOPRIGHT=5;ccui.Scale9Sprite.POSITIONS_TOPLEFT=6;ccui.Scale9Sprite.POSITIONS_BOTTOMRIGHT=7;ccui.Scale9Sprite.state={NORMAL:0,GRAY:1};
(function(){ccui.Scale9Sprite.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._cachedParent=null;this._cacheDirty=!1;this._state=ccui.Scale9Sprite.state.NORMAL;a=this._node;var c=this._cacheCanvas=cc.newElement("canvas");c.width=1;c.height=1;this._cacheContext=new cc.CanvasContextWrapper(c.getContext("2d"));var d=this._cacheTexture=new cc.Texture2D;d.initWithElement(c);d.handleLoadedTexture();this._cacheSprite=new cc.Sprite(d);this._cacheSprite.setAnchorPoint(0,0);a.addChild(this._cacheSprite)};
var a=ccui.Scale9Sprite.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=ccui.Scale9Sprite.CanvasRenderCmd;a.visit=function(a){var c=this._node;c._visible&&(c._positionsAreDirty&&(c._updatePositions(),c._positionsAreDirty=!1,c._scale9Dirty=!0),c._scale9Dirty=!1,this._cacheScale9Sprite(),cc.Node.CanvasRenderCmd.prototype.visit.call(this,a))};a.transform=function(a){var c=this._node;cc.Node.CanvasRenderCmd.prototype.transform.call(this,a);c._positionsAreDirty&&
(c._updatePositions(),c._positionsAreDirty=!1,c._scale9Dirty=!0);this._cacheScale9Sprite();a=c._children;for(c=0;c<a.length;c++)a[c].transform(this,!0)};a._updateDisplayColor=function(a){cc.Node.CanvasRenderCmd.prototype._updateDisplayColor.call(this,a);var c=this._node._scale9Image;if(c){for(var c=c.getChildren(),d=0;d<c.length;d++){var e=c[d];e&&(e._renderCmd._updateDisplayColor(a),e._renderCmd._updateColor())}this._cacheScale9Sprite()}};a._cacheScale9Sprite=function(){var a=this._node;if(a._scale9Image){var c=
cc.contentScaleFactor(),d=a._contentSize,e=cc.size(d.width*c,d.height*c),f=this._cacheCanvas,g=this._cacheContext,h=g.getContext(),k=!1;(f.width!==e.width||f.height!==e.height)&&(f.width=e.width,f.height=e.height,k=!0);cc.renderer._turnToCacheMode(a.__instanceId);a._scale9Image.visit();(f=a._scale9Image.getTexture())&&this._state===ccui.Scale9Sprite.state.GRAY&&f._switchToGray(!0);h.setTransform(1,0,0,1,0,0);h.clearRect(0,0,e.width,e.height);cc.renderer._renderingToCacheCanvas(g,a.__instanceId,c,
c);f&&this._state===ccui.Scale9Sprite.state.GRAY&&f._switchToGray(!1);k&&this._cacheSprite.setTextureRect(cc.rect(0,0,d.width,d.height));this._cacheSprite.getParent()||a.addChild(this._cacheSprite,-1)}};a.setState=function(a){this._node._scale9Image&&(this._state=a,this._cacheScale9Sprite())}})();
(function(){if(cc.Node.WebGLRenderCmd){ccui.Scale9Sprite.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._cachedParent=null;this._cacheDirty=!1};var a=ccui.Scale9Sprite.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=ccui.Scale9Sprite.WebGLRenderCmd;a.visit=function(a){var c=this._node;c._visible&&(c._positionsAreDirty&&(c._updatePositions(),c._positionsAreDirty=!1,c._scale9Dirty=!0),cc.Node.WebGLRenderCmd.prototype.visit.call(this,a))};a.transform=
function(a,c){var d=this._node;cc.Node.WebGLRenderCmd.prototype.transform.call(this,a,c);d._positionsAreDirty&&(d._updatePositions(),d._positionsAreDirty=!1,d._scale9Dirty=!0)};a._updateDisplayColor=function(a){cc.Node.WebGLRenderCmd.prototype._updateDisplayColor.call(this,a);var c=this._node._scale9Image;if(c)for(var c=c.getChildren(),d=0;d<c.length;d++){var e=c[d];e&&(e._renderCmd._updateDisplayColor(a),e._renderCmd._updateColor())}};a._updateDisplayOpacity=function(a){cc.Node.WebGLRenderCmd.prototype._updateDisplayOpacity.call(this,
a);var c=this._node._scale9Image;if(c)for(var c=c.getChildren(),d=0;d<c.length;d++){var e=c[d];e&&(e._renderCmd._updateDisplayOpacity(a),e._renderCmd._updateColor())}};a.setState=function(a){var c=this._node._scale9Image;null!=c&&(a===ccui.Scale9Sprite.state.NORMAL?c.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)):a===ccui.Scale9Sprite.state.GRAY&&c.setShaderProgram(ccui.Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram()))};ccui.Scale9Sprite.WebGLRenderCmd._grayShaderProgram=
null;ccui.Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram=function(){var a=ccui.Scale9Sprite.WebGLRenderCmd._grayShaderProgram;return a?a:(a=new cc.GLProgram,a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT,ccui.Scale9Sprite.WebGLRenderCmd._grayShaderFragment),a.addAttribute(cc.ATTRIBUTE_NAME_POSITION,cc.VERTEX_ATTRIB_POSITION),a.addAttribute(cc.ATTRIBUTE_NAME_COLOR,cc.VERTEX_ATTRIB_COLOR),a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD,cc.VERTEX_ATTRIB_TEX_COORDS),a.link(),a.updateUniforms(),
ccui.Scale9Sprite.WebGLRenderCmd._grayShaderProgram=a,a)};ccui.Scale9Sprite.WebGLRenderCmd._grayShaderFragment="precision lowp float;\nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nvoid main() \n{ \n    vec4 c \x3d texture2D(CC_Texture0, v_texCoord); \n    gl_FragColor.xyz \x3d vec3(0.2126*c.r + 0.7152*c.g + 0.0722*c.b); \n     gl_FragColor.w \x3d c.w ; \n}"}})();
ccui.Layout=ccui.Widget.extend({_clippingEnabled:!1,_backGroundScale9Enabled:null,_backGroundImage:null,_backGroundImageFileName:null,_backGroundImageCapInsets:null,_colorType:null,_bgImageTexType:ccui.Widget.LOCAL_TEXTURE,_colorRender:null,_gradientRender:null,_color:null,_startColor:null,_endColor:null,_alongVector:null,_opacity:255,_backGroundImageTextureSize:null,_layoutType:null,_doLayoutDirty:!0,_clippingRectDirty:!0,_clippingType:null,_clippingStencil:null,_scissorRectDirty:!1,_clippingRect:null,
_clippingParent:null,_className:"Layout",_backGroundImageColor:null,_finalPositionX:0,_finalPositionY:0,_backGroundImageOpacity:0,_loopFocus:!1,__passFocusToChild:!0,_isFocusPassing:!1,_isInterceptTouch:!1,ctor:function(){this._layoutType=ccui.Layout.ABSOLUTE;this._widgetType=ccui.Widget.TYPE_CONTAINER;this._clippingType=ccui.Layout.CLIPPING_STENCIL;this._colorType=ccui.Layout.BG_COLOR_NONE;ccui.Widget.prototype.ctor.call(this);this._backGroundImageCapInsets=cc.rect(0,0,0,0);this._color=cc.color(255,
255,255,255);this._startColor=cc.color(255,255,255,255);this._endColor=cc.color(255,255,255,255);this._alongVector=cc.p(0,-1);this._backGroundImageTextureSize=cc.size(0,0);this._clippingRect=cc.rect(0,0,0,0);this._backGroundImageColor=cc.color(255,255,255,255)},onEnter:function(){ccui.Widget.prototype.onEnter.call(this);this._clippingStencil&&this._clippingStencil.onEnter();this._clippingRectDirty=this._doLayoutDirty=!0},onExit:function(){ccui.Widget.prototype.onExit.call(this);this._clippingStencil&&
this._clippingStencil.onExit()},setLoopFocus:function(a){this._loopFocus=a},isLoopFocus:function(){return this._loopFocus},setPassFocusToChild:function(a){this.__passFocusToChild=a},isPassFocusToChild:function(){return this.__passFocusToChild},findNextFocusedWidget:function(a,b){if(this._isFocusPassing||this.isFocused()){var c=this.getParent();if(this._isFocusPassing=!1,this.__passFocusToChild){var d=this._passFocusToChild(a,b);return d instanceof ccui.Layout&&c?(c._isFocusPassing=!0,c.findNextFocusedWidget(a,
this)):d}return null!=c&&c instanceof ccui.Layout?(c._isFocusPassing=!0,c.findNextFocusedWidget(a,this)):this}if(!(b.isFocused()||b instanceof ccui.Layout))return b;if(this._layoutType===ccui.Layout.LINEAR_HORIZONTAL)switch(a){case ccui.Widget.LEFT:return this._getPreviousFocusedWidget(a,b);case ccui.Widget.RIGHT:return this._getNextFocusedWidget(a,b);case ccui.Widget.DOWN:case ccui.Widget.UP:return this._isLastWidgetInContainer(this,a)?this._isWidgetAncestorSupportLoopFocus(b,a)?ccui.Widget.prototype.findNextFocusedWidget.call(this,
a,this):b:ccui.Widget.prototype.findNextFocusedWidget.call(this,a,this);default:return cc.assert(0,"Invalid Focus Direction"),b}else{if(this._layoutType!==ccui.Layout.LINEAR_VERTICAL)return cc.assert(0,"Un Supported Layout type, please use VBox and HBox instead!!!"),b;switch(a){case ccui.Widget.LEFT:case ccui.Widget.RIGHT:return this._isLastWidgetInContainer(this,a)?this._isWidgetAncestorSupportLoopFocus(b,a)?ccui.Widget.prototype.findNextFocusedWidget.call(this,a,this):b:ccui.Widget.prototype.findNextFocusedWidget.call(this,
a,this);case ccui.Widget.DOWN:return this._getNextFocusedWidget(a,b);case ccui.Widget.UP:return this._getPreviousFocusedWidget(a,b);default:return cc.assert(0,"Invalid Focus Direction"),b}}},onPassFocusToChild:null,init:function(){return ccui.Widget.prototype.init.call(this)?(this.ignoreContentAdaptWithSize(!1),this.setContentSize(cc.size(0,0)),this.setAnchorPoint(0,0),this.onPassFocusToChild=this._findNearestChildWidgetIndex.bind(this),!0):!1},addChild:function(a,b,c){a instanceof ccui.Widget&&this._supplyTheLayoutParameterLackToChild(a);
ccui.Widget.prototype.addChild.call(this,a,b,c);this._doLayoutDirty=!0},removeChild:function(a,b){ccui.Widget.prototype.removeChild.call(this,a,b);this._doLayoutDirty=!0},removeAllChildren:function(a){ccui.Widget.prototype.removeAllChildren.call(this,a);this._doLayoutDirty=!0},removeAllChildrenWithCleanup:function(a){ccui.Widget.prototype.removeAllChildrenWithCleanup.call(this,a);this._doLayoutDirty=!0},isClippingEnabled:function(){return this._clippingEnabled},visit:function(a){if(this._visible)if(this._adaptRenderers(),
this._doLayout(),this._clippingEnabled)switch(this._clippingType){case ccui.Layout.CLIPPING_STENCIL:this._renderCmd.stencilClippingVisit(a);break;case ccui.Layout.CLIPPING_SCISSOR:this._renderCmd.scissorClippingVisit(a)}else ccui.Widget.prototype.visit.call(this,a)},setClippingEnabled:function(a){if(a!==this._clippingEnabled)switch(this._clippingEnabled=a,this._clippingType){case ccui.Layout.CLIPPING_STENCIL:a?(this._clippingStencil=new cc.DrawNode,this._renderCmd.rebindStencilRendering(this._clippingStencil),
this._running&&this._clippingStencil.onEnter(),this._setStencilClippingSize(this._contentSize)):(this._running&&this._clippingStencil&&this._clippingStencil.onExit(),this._clippingStencil=null)}},setClippingType:function(a){if(a!==this._clippingType){if(cc._renderType===cc._RENDER_TYPE_CANVAS&&a===ccui.Layout.CLIPPING_SCISSOR)return void cc.log("Only supports STENCIL on canvas mode.");var b=this.isClippingEnabled();this.setClippingEnabled(!1);this._clippingType=a;this.setClippingEnabled(b)}},getClippingType:function(){return this._clippingType},
_setStencilClippingSize:function(a){if(this._clippingEnabled&&this._clippingType===ccui.Layout.CLIPPING_STENCIL){var b=[];b[0]=cc.p(0,0);b[1]=cc.p(a.width,0);b[2]=cc.p(a.width,a.height);b[3]=cc.p(0,a.height);a=cc.color.GREEN;this._clippingStencil.clear();this._clippingStencil.drawPoly(b,4,a,0,a)}},_getClippingRect:function(){if(this._clippingRectDirty){var a,b=this.convertToWorldSpace(cc.p(0,0));a=this.getNodeToWorldTransform();var c=this._contentSize.width*a.a,d=this._contentSize.height*a.d;for(a=
this;a;)if(a=a.getParent(),a&&a instanceof ccui.Layout&&a.isClippingEnabled()){this._clippingParent=a;break}if(this._clippingParent){a=this._clippingParent._getClippingRect();var e=b.x-c*this._anchorPoint.x,f=b.y-d*this._anchorPoint.y,g=c,h=d,k=b.x-a.x;0>k&&(e=a.x,g+=k);c=b.x+c-(a.x+a.width);0<c&&(g-=c);c=b.y+d-(a.y+a.height);0<c&&(h-=c);b=b.y-a.y;0>b&&(f=a.x,h+=b);0>g&&(g=0);0>h&&(h=0);this._clippingRect.x=e;this._clippingRect.y=f;this._clippingRect.width=g;this._clippingRect.height=h}else this._clippingRect.x=
b.x-c*this._anchorPoint.x,this._clippingRect.y=b.y-d*this._anchorPoint.y,this._clippingRect.width=c,this._clippingRect.height=d;this._clippingRectDirty=!1}return this._clippingRect},_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this);var a=this._contentSize;this._setStencilClippingSize(a);this._clippingRectDirty=this._doLayoutDirty=!0;this._backGroundImage&&(this._backGroundImage.setPosition(0.5*a.width,0.5*a.height),this._backGroundScale9Enabled&&this._backGroundImage instanceof
ccui.Scale9Sprite&&this._backGroundImage.setPreferredSize(a));this._colorRender&&this._colorRender.setContentSize(a);this._gradientRender&&this._gradientRender.setContentSize(a)},setBackGroundImageScale9Enabled:function(a){this._backGroundScale9Enabled!==a&&(this.removeProtectedChild(this._backGroundImage),this._backGroundImage=null,this._backGroundScale9Enabled=a,this._addBackGroundImage(),this.setBackGroundImage(this._backGroundImageFileName,this._bgImageTexType),this.setBackGroundImageCapInsets(this._backGroundImageCapInsets))},
isBackGroundImageScale9Enabled:function(){return this._backGroundScale9Enabled},setBackGroundImage:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE;null===this._backGroundImage&&(this._addBackGroundImage(),this.setBackGroundImageScale9Enabled(this._backGroundScale9Enabled));this._backGroundImageFileName=a;this._bgImageTexType=b;var c=this._backGroundImage;switch(this._bgImageTexType){case ccui.Widget.LOCAL_TEXTURE:c.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:c.initWithSpriteFrameName(a)}this._backGroundScale9Enabled&&
c.setPreferredSize(this._contentSize);this._backGroundImageTextureSize=c.getContentSize();c.setPosition(0.5*this._contentSize.width,0.5*this._contentSize.height);this._updateBackGroundImageColor()}},setBackGroundImageCapInsets:function(a){if(a){var b=this._backGroundImageCapInsets;b.x=a.x;b.y=a.y;b.width=a.width;b.height=a.height;this._backGroundScale9Enabled&&this._backGroundImage.setCapInsets(a)}},getBackGroundImageCapInsets:function(){return cc.rect(this._backGroundImageCapInsets)},_supplyTheLayoutParameterLackToChild:function(a){if(a)switch(this._layoutType){case ccui.Layout.LINEAR_HORIZONTAL:case ccui.Layout.LINEAR_VERTICAL:var b=
a.getLayoutParameter(ccui.LayoutParameter.LINEAR);b||a.setLayoutParameter(new ccui.LinearLayoutParameter);break;case ccui.Layout.RELATIVE:(b=a.getLayoutParameter(ccui.LayoutParameter.RELATIVE))||a.setLayoutParameter(new ccui.RelativeLayoutParameter)}},_addBackGroundImage:function(){var a=this._contentSize;this._backGroundScale9Enabled?(this._backGroundImage=new ccui.Scale9Sprite,this._backGroundImage.setPreferredSize(a)):this._backGroundImage=new cc.Sprite;this.addProtectedChild(this._backGroundImage,
ccui.Layout.BACKGROUND_IMAGE_ZORDER,-1);this._backGroundImage.setPosition(0.5*a.width,0.5*a.height)},removeBackGroundImage:function(){this._backGroundImage&&(this.removeProtectedChild(this._backGroundImage),this._backGroundImage=null,this._backGroundImageFileName="",this._backGroundImageTextureSize.width=0,this._backGroundImageTextureSize.height=0)},setBackGroundColorType:function(a){if(this._colorType!==a){switch(this._colorType){case ccui.Layout.BG_COLOR_NONE:this._colorRender&&(this.removeProtectedChild(this._colorRender),
this._colorRender=null);this._gradientRender&&(this.removeProtectedChild(this._gradientRender),this._gradientRender=null);break;case ccui.Layout.BG_COLOR_SOLID:this._colorRender&&(this.removeProtectedChild(this._colorRender),this._colorRender=null);break;case ccui.Layout.BG_COLOR_GRADIENT:this._gradientRender&&(this.removeProtectedChild(this._gradientRender),this._gradientRender=null)}switch(this._colorType=a,this._colorType){case ccui.Layout.BG_COLOR_SOLID:this._colorRender=new cc.LayerColor;this._colorRender.setContentSize(this._contentSize);
this._colorRender.setOpacity(this._opacity);this._colorRender.setColor(this._color);this.addProtectedChild(this._colorRender,ccui.Layout.BACKGROUND_RENDERER_ZORDER,-1);break;case ccui.Layout.BG_COLOR_GRADIENT:this._gradientRender=new cc.LayerGradient(cc.color(255,0,0,255),cc.color(0,255,0,255)),this._gradientRender.setContentSize(this._contentSize),this._gradientRender.setOpacity(this._opacity),this._gradientRender.setStartColor(this._startColor),this._gradientRender.setEndColor(this._endColor),this._gradientRender.setVector(this._alongVector),
this.addProtectedChild(this._gradientRender,ccui.Layout.BACKGROUND_RENDERER_ZORDER,-1)}}},getBackGroundColorType:function(){return this._colorType},setBackGroundColor:function(a,b){b?(this._startColor.r=a.r,this._startColor.g=a.g,this._startColor.b=a.b,this._gradientRender&&this._gradientRender.setStartColor(a),this._endColor.r=b.r,this._endColor.g=b.g,this._endColor.b=b.b,this._gradientRender&&this._gradientRender.setEndColor(b)):(this._color.r=a.r,this._color.g=a.g,this._color.b=a.b,this._colorRender&&
this._colorRender.setColor(a))},getBackGroundColor:function(){var a=this._color;return cc.color(a.r,a.g,a.b,a.a)},getBackGroundStartColor:function(){var a=this._startColor;return cc.color(a.r,a.g,a.b,a.a)},getBackGroundEndColor:function(){var a=this._endColor;return cc.color(a.r,a.g,a.b,a.a)},setBackGroundColorOpacity:function(a){switch(this._opacity=a,this._colorType){case ccui.Layout.BG_COLOR_SOLID:this._colorRender.setOpacity(a);break;case ccui.Layout.BG_COLOR_GRADIENT:this._gradientRender.setOpacity(a)}},
getBackGroundColorOpacity:function(){return this._opacity},setBackGroundColorVector:function(a){this._alongVector.x=a.x;this._alongVector.y=a.y;this._gradientRender&&this._gradientRender.setVector(a)},getBackGroundColorVector:function(){return this._alongVector},setBackGroundImageColor:function(a){this._backGroundImageColor.r=a.r;this._backGroundImageColor.g=a.g;this._backGroundImageColor.b=a.b;this._updateBackGroundImageColor()},setBackGroundImageOpacity:function(a){this._backGroundImageColor.a=
a;this.getBackGroundImageColor()},getBackGroundImageColor:function(){var a=this._backGroundImageColor;return cc.color(a.r,a.g,a.b,a.a)},getBackGroundImageOpacity:function(){return this._backGroundImageColor.a},_updateBackGroundImageColor:function(){this._backGroundImage&&this._backGroundImage.setColor(this._backGroundImageColor)},getBackGroundImageTextureSize:function(){return this._backGroundImageTextureSize},setLayoutType:function(a){this._layoutType=a;a=this._children;for(var b=null,c=0;c<a.length;c++)b=
a[c],b instanceof ccui.Widget&&this._supplyTheLayoutParameterLackToChild(b);this._doLayoutDirty=!0},getLayoutType:function(){return this._layoutType},requestDoLayout:function(){this._doLayoutDirty=!0},_doLayout:function(){if(this._doLayoutDirty){this.sortAllChildren();var a=ccui.getLayoutManager(this._layoutType);a&&a._doLayout(this);this._doLayoutDirty=!1}},_getLayoutContentSize:function(){return this.getContentSize()},_getLayoutElements:function(){return this.getChildren()},_updateBackGroundImageOpacity:function(){this._backGroundImage&&
this._backGroundImage.setOpacity(this._backGroundImageOpacity)},_updateBackGroundImageRGBA:function(){this._backGroundImage&&(this._backGroundImage.setColor(this._backGroundImageColor),this._backGroundImage.setOpacity(this._backGroundImageOpacity))},_getLayoutAccumulatedSize:function(){for(var a,b=this.getChildren(),c=cc.size(0,0),d=0,e=0,f=b.length;f>e;e++)if(a=b[e],null!==a&&a instanceof ccui.Layout)a=a._getLayoutAccumulatedSize(),c.width+=a.width,c.height+=a.height;else if(a instanceof ccui.Widget){d++;
var g=a.getLayoutParameter().getMargin();a=a.getContentSize();c.width+=a.width+0.5*(g.right+g.left);c.height+=a.height+0.5*(g.top+g.bottom)}b=this.getLayoutType();return b===ccui.Layout.LINEAR_HORIZONTAL&&(c.height-=c.height/d*(d-1)),b===ccui.Layout.LINEAR_VERTICAL&&(c.width-=c.width/d*(d-1)),c},_findNearestChildWidgetIndex:function(a,b){if(null==b||b===this)return this._findFirstFocusEnabledWidgetIndex();var c,d=0,e=this.getChildren(),f=e.length,g=cc.FLT_MAX,h=0;if(a===ccui.Widget.LEFT||a===ccui.Widget.RIGHT||
a===ccui.Widget.DOWN||a===ccui.Widget.UP){for(c=this._getWorldCenterPoint(b);f>d;){var k=e[d];k&&(k instanceof ccui.Widget&&k.isFocusEnabled())&&(k=k instanceof ccui.Layout?k._calculateNearestDistance(b):cc.pLength(cc.pSub(this._getWorldCenterPoint(k),c)),g>k&&(h=d,g=k));d++}return h}return cc.log("invalid focus direction!"),0},_findFarthestChildWidgetIndex:function(a,b){if(null==b||b===this)return this._findFirstFocusEnabledWidgetIndex();var c=0,d=this.getChildren(),e=d.length,f=-cc.FLT_MAX,g=0;
if(a===ccui.Widget.LEFT||a===ccui.Widget.RIGHT||a===ccui.Widget.DOWN||a===ccui.Widget.UP){for(var h=this._getWorldCenterPoint(b);e>c;){var k=d[c];k&&(k instanceof ccui.Widget&&k.isFocusEnabled())&&(k=k instanceof ccui.Layout?k._calculateFarthestDistance(b):cc.pLength(cc.pSub(this._getWorldCenterPoint(k),h)),k>f&&(g=c,f=k));c++}return g}return cc.log("invalid focus direction!!!"),0},_calculateNearestDistance:function(a){for(var b=cc.FLT_MAX,c=this._getWorldCenterPoint(a),d=this._children,e=0,f=d.length;f>
e;e++){var g;g=d[e];if(g instanceof ccui.Layout)g=g._calculateNearestDistance(a);else{if(!(g instanceof ccui.Widget&&g.isFocusEnabled()))continue;g=cc.pLength(cc.pSub(this._getWorldCenterPoint(g),c))}b>g&&(b=g)}return b},_calculateFarthestDistance:function(a){for(var b=-cc.FLT_MAX,c=this._getWorldCenterPoint(a),d=this._children,e=0,f=d.length;f>e;e++){var g;g=d[e];if(g instanceof ccui.Layout)g=g._calculateFarthestDistance(a);else{if(!(g instanceof ccui.Widget&&g.isFocusEnabled()))continue;g=this._getWorldCenterPoint(g);
g=cc.pLength(cc.pSub(g,c))}g>b&&(b=g)}return b},_findProperSearchingFunctor:function(a,b){if(null!=b){var c=this._getWorldCenterPoint(b),d=this._getWorldCenterPoint(this._findFirstNonLayoutWidget());a===ccui.Widget.LEFT?this.onPassFocusToChild=c.x>d.x?this._findNearestChildWidgetIndex.bind(this):this._findFarthestChildWidgetIndex.bind(this):a===ccui.Widget.RIGHT?this.onPassFocusToChild=c.x>d.x?this._findFarthestChildWidgetIndex.bind(this):this._findNearestChildWidgetIndex.bind(this):a===ccui.Widget.DOWN?
this.onPassFocusToChild=c.y>d.y?this._findNearestChildWidgetIndex.bind(this):this._findFarthestChildWidgetIndex.bind(this):a===ccui.Widget.UP?this.onPassFocusToChild=c.y<d.y?this._findNearestChildWidgetIndex.bind(this):this._findFarthestChildWidgetIndex.bind(this):cc.log("invalid direction!")}},_findFirstNonLayoutWidget:function(){for(var a=this._children,b=0,c=a.length;c>b;b++){var d=a[b];if(d instanceof ccui.Layout){if(d=d._findFirstNonLayoutWidget())return d}else if(d instanceof ccui.Widget)return d}return null},
_findFirstFocusEnabledWidgetIndex:function(){for(var a=0,b=this.getChildren(),c=b.length;c>a;){var d=b[a];if(d&&d instanceof ccui.Widget&&d.isFocusEnabled())return a;a++}return 0},_findFocusEnabledChildWidgetByIndex:function(a){var b=this._getChildWidgetByIndex(a);return b?b.isFocusEnabled()?b:(a+=1,this._findFocusEnabledChildWidgetByIndex(a)):null},_getWorldCenterPoint:function(a){var b=a instanceof ccui.Layout?a._getLayoutAccumulatedSize():a.getContentSize();return a.convertToWorldSpace(cc.p(b.width/
2,b.height/2))},_getNextFocusedWidget:function(a,b){var c=null,d=this._children,e=d.indexOf(b);return e+=1,e<d.length?(c=this._getChildWidgetByIndex(e),c?c.isFocusEnabled()?c instanceof ccui.Layout?(c._isFocusPassing=!0,c.findNextFocusedWidget(a,c)):(this.dispatchFocusEvent(b,c),c):this._getNextFocusedWidget(a,c):b):this._loopFocus?this._checkFocusEnabledChild()?(e=0,c=this._getChildWidgetByIndex(e),c.isFocusEnabled()?c instanceof ccui.Layout?(c._isFocusPassing=!0,c.findNextFocusedWidget(a,c)):(this.dispatchFocusEvent(b,
c),c):this._getNextFocusedWidget(a,c)):b instanceof ccui.Layout?b:ccui.Widget._focusedWidget:this._isLastWidgetInContainer(b,a)?this._isWidgetAncestorSupportLoopFocus(this,a)?ccui.Widget.prototype.findNextFocusedWidget.call(this,a,this):b instanceof ccui.Layout?b:ccui.Widget._focusedWidget:ccui.Widget.prototype.findNextFocusedWidget.call(this,a,this)},_getPreviousFocusedWidget:function(a,b){var c=null,d=this._children,e=d.indexOf(b);return e-=1,0<=e?(c=this._getChildWidgetByIndex(e),c.isFocusEnabled()?
c instanceof ccui.Layout?(c._isFocusPassing=!0,c.findNextFocusedWidget(a,c)):(this.dispatchFocusEvent(b,c),c):this._getPreviousFocusedWidget(a,c)):this._loopFocus?this._checkFocusEnabledChild()?(e=d.length-1,c=this._getChildWidgetByIndex(e),c.isFocusEnabled()?c instanceof ccui.Layout?(c._isFocusPassing=!0,c.findNextFocusedWidget(a,c)):(this.dispatchFocusEvent(b,c),c):this._getPreviousFocusedWidget(a,c)):b instanceof ccui.Layout?b:ccui.Widget._focusedWidget:this._isLastWidgetInContainer(b,a)?this._isWidgetAncestorSupportLoopFocus(this,
a)?ccui.Widget.prototype.findNextFocusedWidget.call(this,a,this):b instanceof ccui.Layout?b:ccui.Widget._focusedWidget:ccui.Widget.prototype.findNextFocusedWidget.call(this,a,this)},_getChildWidgetByIndex:function(a){for(var b=this._children,c=b.length,d=0,e=a;c>a;){var f=b[a];if(f&&f instanceof ccui.Widget)return f;d++;a++}for(a=0;e>a;){if((c=b[a])&&c instanceof ccui.Widget)return c;d++;a++}return null},_isLastWidgetInContainer:function(a,b){var c=a.getParent();if(null==c||!(c instanceof ccui.Layout))return!0;
var d=c.getChildren(),e=d.indexOf(a);if(c.getLayoutType()===ccui.Layout.LINEAR_HORIZONTAL){if(b===ccui.Widget.LEFT)return 0===e?this._isLastWidgetInContainer(c,b):!1;if(b===ccui.Widget.RIGHT)return e===d.length-1?this._isLastWidgetInContainer(c,b):!1;if(b===ccui.Widget.DOWN||b===ccui.Widget.UP)return this._isLastWidgetInContainer(c,b)}else{if(c.getLayoutType()!==ccui.Layout.LINEAR_VERTICAL)return cc.log("invalid layout Type"),!1;if(b===ccui.Widget.UP)return 0===e?this._isLastWidgetInContainer(c,b):
!1;if(b===ccui.Widget.DOWN)return e===d.length-1?this._isLastWidgetInContainer(c,b):!1;if(b===ccui.Widget.LEFT||b===ccui.Widget.RIGHT)return this._isLastWidgetInContainer(c,b)}},_isWidgetAncestorSupportLoopFocus:function(a,b){var c=a.getParent();if(null==c||!(c instanceof ccui.Layout))return!1;if(c.isLoopFocus()){var d=c.getLayoutType();return d===ccui.Layout.LINEAR_HORIZONTAL?b===ccui.Widget.LEFT||b===ccui.Widget.RIGHT?!0:this._isWidgetAncestorSupportLoopFocus(c,b):d===ccui.Layout.LINEAR_VERTICAL?
b===ccui.Widget.DOWN||b===ccui.Widget.UP?!0:this._isWidgetAncestorSupportLoopFocus(c,b):(cc.assert(0,"invalid layout type"),!1)}return this._isWidgetAncestorSupportLoopFocus(c,b)},_passFocusToChild:function(a,b){if(this._checkFocusEnabledChild()){var c=ccui.Widget.getCurrentFocusedWidget();this._findProperSearchingFunctor(a,c);c=this.onPassFocusToChild(a,c);c=this._getChildWidgetByIndex(c);return c instanceof ccui.Layout?(c._isFocusPassing=!0,c.findNextFocusedWidget(a,c)):(this.dispatchFocusEvent(b,
c),c)}return this},_checkFocusEnabledChild:function(){for(var a=this._children,b=0,c=a.length;c>b;b++){var d=a[b];if(d&&d instanceof ccui.Widget&&d.isFocusEnabled())return!0}return!1},getDescription:function(){return"Layout"},_createCloneInstance:function(){return new ccui.Layout},_copyClonedWidgetChildren:function(a){ccui.Widget.prototype._copyClonedWidgetChildren.call(this,a)},_copySpecialProperties:function(a){a instanceof ccui.Layout&&(this.setBackGroundImageScale9Enabled(a._backGroundScale9Enabled),
this.setBackGroundImage(a._backGroundImageFileName,a._bgImageTexType),this.setBackGroundImageCapInsets(a._backGroundImageCapInsets),this.setBackGroundColorType(a._colorType),this.setBackGroundColor(a._color),this.setBackGroundColor(a._startColor,a._endColor),this.setBackGroundColorOpacity(a._opacity),this.setBackGroundColorVector(a._alongVector),this.setLayoutType(a._layoutType),this.setClippingEnabled(a._clippingEnabled),this.setClippingType(a._clippingType),this._loopFocus=a._loopFocus,this.__passFocusToChild=
a.__passFocusToChild,this._isInterceptTouch=a._isInterceptTouch)},forceDoLayout:function(){this.requestDoLayout();this._doLayout()},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_WEBGL?new ccui.Layout.WebGLRenderCmd(this):new ccui.Layout.CanvasRenderCmd(this)}});_p=ccui.Layout.prototype;_p.clippingEnabled;cc.defineGetterSetter(_p,"clippingEnabled",_p.isClippingEnabled,_p.setClippingEnabled);_p.clippingType;cc.defineGetterSetter(_p,"clippingType",null,_p.setClippingType);_p.layoutType;
cc.defineGetterSetter(_p,"layoutType",_p.getLayoutType,_p.setLayoutType);_p=null;ccui.Layout.create=function(){return new ccui.Layout};ccui.Layout.BG_COLOR_NONE=0;ccui.Layout.BG_COLOR_SOLID=1;ccui.Layout.BG_COLOR_GRADIENT=2;ccui.Layout.ABSOLUTE=0;ccui.Layout.LINEAR_VERTICAL=1;ccui.Layout.LINEAR_HORIZONTAL=2;ccui.Layout.RELATIVE=3;ccui.Layout.CLIPPING_STENCIL=0;ccui.Layout.CLIPPING_SCISSOR=1;ccui.Layout.BACKGROUND_IMAGE_ZORDER=-2;ccui.Layout.BACKGROUND_RENDERER_ZORDER=-2;
(function(){ccui.Layout.CanvasRenderCmd=function(a){ccui.ProtectedNode.CanvasRenderCmd.call(this,a);this._clipElemType=this._needDraw=!1;this._locCache=null;this._rendererSaveCmd=new cc.CustomRenderCmd(this,this._onRenderSaveCmd);this._rendererSaveCmdSprite=new cc.CustomRenderCmd(this,this._onRenderSaveSpriteCmd);this._rendererClipCmd=new cc.CustomRenderCmd(this,this._onRenderClipCmd);this._rendererRestoreCmd=new cc.CustomRenderCmd(this,this._onRenderRestoreCmd)};var a=ccui.Layout.CanvasRenderCmd.prototype=
Object.create(ccui.ProtectedNode.CanvasRenderCmd.prototype);a.constructor=ccui.Layout.CanvasRenderCmd;a.visit=function(a){var c=this._node;if(c._visible)if(c._adaptRenderers(),c._doLayout(),c._clippingEnabled)switch(c._clippingType){case ccui.Layout.CLIPPING_STENCIL:this.stencilClippingVisit(a);break;case ccui.Layout.CLIPPING_SCISSOR:this.scissorClippingVisit(a)}else ccui.Widget.CanvasRenderCmd.prototype.visit.call(this,a)};a._onRenderSaveCmd=function(a,c,d){a=a||cc._renderContext;var e=a.getContext();
this._clipElemType?(c=e.canvas,this._locCache=ccui.Layout.CanvasRenderCmd._getSharedCache(),this._locCache.width=c.width,this._locCache.height=c.height,this._locCache.getContext("2d").drawImage(c,0,0)):(a.save(),a.save(),a.setTransform(this._worldTransform,c,d))};a._onRenderSaveSpriteCmd=function(a){a=a||cc._renderContext;this._clipElemType&&a.setCompositeOperation("destination-in")};a._onRenderClipCmd=function(a){a=a||cc._renderContext;var c=a.getContext();this._clipElemType||(a.restore(),c.clip())};
a._onRenderRestoreCmd=function(a){a=a||cc._renderContext;var c=a.getContext();this._clipElemType?(c.save(),c.setTransform(1,0,0,1,0,0),c.globalCompositeOperation="destination-over",c.drawImage(this._locCache,0,0),c.restore()):a.restore()};a.rebindStencilRendering=function(a){a._renderCmd.rendering=this.__stencilDraw};a.__stencilDraw=function(a,c,d){a=(a||cc._renderContext).getContext();for(var e=this._buffer,f=0,g=e.length;g>f;f++){var h=e[f].verts,k=h[0];a.beginPath();a.moveTo(k.x*c,-k.y*d);for(var k=
1,m=h.length;m>k;k++)a.lineTo(h[k].x*c,-h[k].y*d);a.closePath()}};a.stencilClippingVisit=a.scissorClippingVisit=function(a){var c=this._node;if(c._clippingStencil&&c._clippingStencil.isVisible()&&(this._clipElemType=c._stencil instanceof cc.Sprite,this._syncStatus(a),this._dirtyFlag=0,cc.renderer.pushRenderCommand(this._rendererSaveCmd),this._clipElemType&&(cc.ProtectedNode.prototype.visit.call(c,a),cc.renderer.pushRenderCommand(this._rendererSaveCmdSprite)),c._clippingStencil.visit(this),cc.renderer.pushRenderCommand(this._rendererClipCmd),
!this._clipElemType)){c.sortAllChildren();c.sortAllProtectedChildren();var d;a=c._children;for(var e=0,c=c._protectedChildren,f=0,g=a.length,h=c.length;g>f&&(d=a[f],d&&0>d.getLocalZOrder());f++)d.visit(this);for(;h>e&&(d=c[e],d&&0>d.getLocalZOrder());e++)d.visit(this);for(;g>f;f++)a[f].visit(this);for(;h>e;e++)c[e].visit(this);cc.renderer.pushRenderCommand(this._rendererRestoreCmd)}};ccui.Layout.CanvasRenderCmd._getSharedCache=function(){return cc.ClippingNode._sharedCache||(cc.ClippingNode._sharedCache=
cc.newElement("canvas"))}})();
(function(){if(ccui.ProtectedNode.WebGLRenderCmd){ccui.Layout.WebGLRenderCmd=function(a){ccui.ProtectedNode.WebGLRenderCmd.call(this,a);this._needDraw=!1;this._currentStencilPassDepthPass=this._currentStencilPassDepthFail=this._currentStencilFail=this._currentStencilValueMask=this._currentStencilRef=this._currentStencilFunc=this._currentStencilWriteMask=this._currentStencilEnabled=0;this._currentDepthWriteMask=!1;this._mask_layer_le=0;this._beforeVisitCmdStencil=new cc.CustomRenderCmd(this,this._onBeforeVisitStencil);
this._afterDrawStencilCmd=new cc.CustomRenderCmd(this,this._onAfterDrawStencil);this._afterVisitCmdStencil=new cc.CustomRenderCmd(this,this._onAfterVisitStencil);this._beforeVisitCmdScissor=new cc.CustomRenderCmd(this,this._onBeforeVisitScissor);this._afterVisitCmdScissor=new cc.CustomRenderCmd(this,this._onAfterVisitScissor)};var a=ccui.Layout.WebGLRenderCmd.prototype=Object.create(ccui.ProtectedNode.WebGLRenderCmd.prototype);a.constructor=ccui.Layout.WebGLRenderCmd;a.visit=function(a){var c=this._node;
if(c._visible)if(c._adaptRenderers(),c._doLayout(),c._clippingEnabled)switch(c._clippingType){case ccui.Layout.CLIPPING_STENCIL:this.stencilClippingVisit(a);break;case ccui.Layout.CLIPPING_SCISSOR:this.scissorClippingVisit(a)}else ccui.Widget.WebGLRenderCmd.prototype.visit.call(this,a)};a._onBeforeVisitStencil=function(a){a=a||cc._renderContext;ccui.Layout.WebGLRenderCmd._layer++;var c=1<<ccui.Layout.WebGLRenderCmd._layer;this._mask_layer_le=c|c-1;this._currentStencilEnabled=a.isEnabled(a.STENCIL_TEST);
this._currentStencilWriteMask=a.getParameter(a.STENCIL_WRITEMASK);this._currentStencilFunc=a.getParameter(a.STENCIL_FUNC);this._currentStencilRef=a.getParameter(a.STENCIL_REF);this._currentStencilValueMask=a.getParameter(a.STENCIL_VALUE_MASK);this._currentStencilFail=a.getParameter(a.STENCIL_FAIL);this._currentStencilPassDepthFail=a.getParameter(a.STENCIL_PASS_DEPTH_FAIL);this._currentStencilPassDepthPass=a.getParameter(a.STENCIL_PASS_DEPTH_PASS);a.enable(a.STENCIL_TEST);a.stencilMask(c);this._currentDepthWriteMask=
a.getParameter(a.DEPTH_WRITEMASK);a.depthMask(!1);a.stencilFunc(a.NEVER,c,c);a.stencilOp(a.ZERO,a.KEEP,a.KEEP);this._drawFullScreenQuadClearStencil();a.stencilFunc(a.NEVER,c,c);a.stencilOp(a.REPLACE,a.KEEP,a.KEEP)};a._onAfterDrawStencil=function(a){a=a||cc._renderContext;a.depthMask(this._currentDepthWriteMask);a.stencilFunc(a.EQUAL,this._mask_layer_le,this._mask_layer_le);a.stencilOp(a.KEEP,a.KEEP,a.KEEP)};a._onAfterVisitStencil=function(a){a=a||cc._renderContext;a.stencilFunc(this._currentStencilFunc,
this._currentStencilRef,this._currentStencilValueMask);a.stencilOp(this._currentStencilFail,this._currentStencilPassDepthFail,this._currentStencilPassDepthPass);a.stencilMask(this._currentStencilWriteMask);this._currentStencilEnabled||a.disable(a.STENCIL_TEST);ccui.Layout.WebGLRenderCmd._layer--};a._onBeforeVisitScissor=function(a){var c=this._getClippingRect();a=a||cc._renderContext;a.enable(a.SCISSOR_TEST);cc.view.setScissorInPoints(c.x,c.y,c.width,c.height)};a._onAfterVisitScissor=function(a){a=
a||cc._renderContext;a.disable(a.SCISSOR_TEST)};a._drawFullScreenQuadClearStencil=function(){cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);cc.kmGLPushMatrix();cc.kmGLLoadIdentity();cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);cc.kmGLPushMatrix();cc.kmGLLoadIdentity();cc._drawingUtil.drawSolidRect(cc.p(-1,-1),cc.p(1,1),cc.color(255,255,255,255));cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);cc.kmGLPopMatrix();cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);cc.kmGLPopMatrix()};a.rebindStencilRendering=function(a){};a.transform=function(a,
c){var d=this._node;ccui.ProtectedNode.WebGLRenderCmd.prototype.transform.call(this,a,c);d._clippingStencil&&d._clippingStencil._renderCmd.transform(this,c)};a.stencilClippingVisit=function(a){var c=this._node;if(c._clippingStencil&&c._clippingStencil.isVisible()){if(ccui.Layout.WebGLRenderCmd._layer+1===cc.stencilBits)return ccui.Layout.WebGLRenderCmd._visit_once=!0,ccui.Layout.WebGLRenderCmd._visit_once&&(cc.log("Nesting more than "+cc.stencilBits+"stencils is not supported. Everything will be drawn without stencil for this node and its childs."),
ccui.Layout.WebGLRenderCmd._visit_once=!1),void cc.Node.prototype.visit.call(c,a);cc.renderer.pushRenderCommand(this._beforeVisitCmdStencil);var d=cc.current_stack;d.stack.push(d.top);this._syncStatus(a);this._dirtyFlag=0;d.top=this._stackMatrix;c._clippingStencil.visit(this);cc.renderer.pushRenderCommand(this._afterDrawStencilCmd);var e=a=0;c.sortAllChildren();c.sortAllProtectedChildren();for(var f,g=c._children,c=c._protectedChildren,h=g.length,k=c.length;h>a&&(f=g[a],f&&0>f.getLocalZOrder());a++)f.visit(this);
for(;k>e&&(f=c[e],f&&0>f.getLocalZOrder());e++)f.visit(this);for(;h>a;a++)g[a].visit(this);for(;k>e;e++)c[e].visit(this);cc.renderer.pushRenderCommand(this._afterVisitCmdStencil);d.top=d.stack.pop()}};a.scissorClippingVisit=function(a){cc.renderer.pushRenderCommand(this._beforeVisitCmdScissor);cc.ProtectedNode.prototype.visit.call(this._node,a);cc.renderer.pushRenderCommand(this._afterVisitCmdScissor)};ccui.Layout.WebGLRenderCmd._layer=-1;ccui.Layout.WebGLRenderCmd._visit_once=null}})();
ccui.Margin=ccui.Class.extend({left:0,top:0,right:0,bottom:0,ctor:function(a,b,c,d){void 0!==a&&void 0===b&&(this.left=a.left,this.top=a.top,this.right=a.right,this.bottom=a.bottom);void 0!==d&&(this.left=a,this.top=b,this.right=c,this.bottom=d)},setMargin:function(a,b,c,d){this.left=a;this.top=b;this.right=c;this.bottom=d},equals:function(a){return this.left===a.left&&this.top===a.top&&this.right===a.right&&this.bottom===a.bottom}});ccui.MarginZero=function(){return new ccui.Margin(0,0,0,0)};
ccui.LayoutParameter=ccui.Class.extend({_margin:null,_layoutParameterType:null,ctor:function(){this._margin=new ccui.Margin;this._layoutParameterType=ccui.LayoutParameter.NONE},setMargin:function(a,b,c,d){cc.isObject(a)?(this._margin.left=a.left,this._margin.top=a.top,this._margin.right=a.right,this._margin.bottom=a.bottom):(this._margin.left=a,this._margin.top=b,this._margin.right=c,this._margin.bottom=d)},getMargin:function(){return this._margin},getLayoutType:function(){return this._layoutParameterType},
clone:function(){var a=this._createCloneInstance();return a._copyProperties(this),a},_createCloneInstance:function(){return new ccui.LayoutParameter},_copyProperties:function(a){this._margin.bottom=a._margin.bottom;this._margin.left=a._margin.left;this._margin.right=a._margin.right;this._margin.top=a._margin.top}});ccui.LayoutParameter.create=function(){return new ccui.LayoutParameter};ccui.LayoutParameter.NONE=0;ccui.LayoutParameter.LINEAR=1;ccui.LayoutParameter.RELATIVE=2;
ccui.LinearLayoutParameter=ccui.LayoutParameter.extend({_linearGravity:null,ctor:function(){ccui.LayoutParameter.prototype.ctor.call(this);this._linearGravity=ccui.LinearLayoutParameter.NONE;this._layoutParameterType=ccui.LayoutParameter.LINEAR},setGravity:function(a){this._linearGravity=a},getGravity:function(){return this._linearGravity},_createCloneInstance:function(){return new ccui.LinearLayoutParameter},_copyProperties:function(a){ccui.LayoutParameter.prototype._copyProperties.call(this,a);
a instanceof ccui.LinearLayoutParameter&&this.setGravity(a._linearGravity)}});ccui.LinearLayoutParameter.create=function(){return new ccui.LinearLayoutParameter};ccui.LinearLayoutParameter.NONE=0;ccui.LinearLayoutParameter.LEFT=1;ccui.LinearLayoutParameter.TOP=2;ccui.LinearLayoutParameter.RIGHT=3;ccui.LinearLayoutParameter.BOTTOM=4;ccui.LinearLayoutParameter.CENTER_VERTICAL=5;ccui.LinearLayoutParameter.CENTER_HORIZONTAL=6;
ccui.RelativeLayoutParameter=ccui.LayoutParameter.extend({_relativeAlign:null,_relativeWidgetName:"",_relativeLayoutName:"",_put:!1,ctor:function(){ccui.LayoutParameter.prototype.ctor.call(this);this._relativeAlign=ccui.RelativeLayoutParameter.NONE;this._relativeLayoutName=this._relativeWidgetName="";this._put=!1;this._layoutParameterType=ccui.LayoutParameter.RELATIVE},setAlign:function(a){this._relativeAlign=a},getAlign:function(){return this._relativeAlign},setRelativeToWidgetName:function(a){this._relativeWidgetName=
a},getRelativeToWidgetName:function(){return this._relativeWidgetName},setRelativeName:function(a){this._relativeLayoutName=a},getRelativeName:function(){return this._relativeLayoutName},_createCloneInstance:function(){return new ccui.RelativeLayoutParameter},_copyProperties:function(a){ccui.LayoutParameter.prototype._copyProperties.call(this,a);a instanceof ccui.RelativeLayoutParameter&&(this.setAlign(a._relativeAlign),this.setRelativeToWidgetName(a._relativeWidgetName),this.setRelativeName(a._relativeLayoutName))}});
ccui.RelativeLayoutParameter.create=function(){return new ccui.RelativeLayoutParameter};ccui.RelativeLayoutParameter.NONE=0;ccui.RelativeLayoutParameter.PARENT_TOP_LEFT=1;ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL=2;ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT=3;ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL=4;ccui.RelativeLayoutParameter.CENTER_IN_PARENT=5;ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL=6;ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM=7;
ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL=8;ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM=9;ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN=10;ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER=11;ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN=12;ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN=13;ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER=14;ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN=15;
ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN=16;ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER=17;ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN=18;ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN=19;ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER=20;ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN=21;ccui.LINEAR_GRAVITY_NONE=0;ccui.LINEAR_GRAVITY_LEFT=1;ccui.LINEAR_GRAVITY_TOP=2;ccui.LINEAR_GRAVITY_RIGHT=3;ccui.LINEAR_GRAVITY_BOTTOM=4;
ccui.LINEAR_GRAVITY_CENTER_VERTICAL=5;ccui.LINEAR_GRAVITY_CENTER_HORIZONTAL=6;ccui.RELATIVE_ALIGN_NONE=0;ccui.RELATIVE_ALIGN_PARENT_TOP_LEFT=1;ccui.RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL=2;ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT=3;ccui.RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL=4;ccui.RELATIVE_ALIGN_PARENT_CENTER=5;ccui.RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL=6;ccui.RELATIVE_ALIGN_PARENT_LEFT_BOTTOM=7;ccui.RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL=8;
ccui.RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM=9;ccui.RELATIVE_ALIGN_LOCATION_ABOVE_LEFT=10;ccui.RELATIVE_ALIGN_LOCATION_ABOVE_CENTER=11;ccui.RELATIVE_ALIGN_LOCATION_ABOVE_RIGHT=12;ccui.RELATIVE_ALIGN_LOCATION_LEFT_TOP=13;ccui.RELATIVE_ALIGN_LOCATION_LEFT_CENTER=14;ccui.RELATIVE_ALIGN_LOCATION_LEFT_BOTTOM=15;ccui.RELATIVE_ALIGN_LOCATION_RIGHT_TOP=16;ccui.RELATIVE_ALIGN_LOCATION_RIGHT_CENTER=17;ccui.RELATIVE_ALIGN_LOCATION_RIGHT_BOTTOM=18;ccui.RELATIVE_ALIGN_LOCATION_BELOW_TOP=19;
ccui.RELATIVE_ALIGN_LOCATION_BELOW_CENTER=20;ccui.RELATIVE_ALIGN_LOCATION_BELOW_BOTTOM=21;ccui.getLayoutManager=function(a){switch(a){case ccui.Layout.LINEAR_VERTICAL:return ccui.linearVerticalLayoutManager;case ccui.Layout.LINEAR_HORIZONTAL:return ccui.linearHorizontalLayoutManager;case ccui.Layout.RELATIVE:return ccui.relativeLayoutManager}return null};
ccui.linearVerticalLayoutManager={_doLayout:function(a){var b=a._getLayoutContentSize();a=a._getLayoutElements();for(var c=b.height,d=0,e=a.length;e>d;d++){var f=a[d];if(f){var g=f.getLayoutParameter();if(g){var h=g.getGravity(),k=f.getAnchorPoint(),m=f.getContentSize(),n=k.x*m.width,c=c-(1-k.y)*m.height;switch(h){case ccui.LinearLayoutParameter.RIGHT:n=b.width-(1-k.x)*m.width;break;case ccui.LinearLayoutParameter.CENTER_HORIZONTAL:n=b.width/2-m.width*(0.5-k.x)}g=g.getMargin();n+=g.left;c-=g.top;
f.setPosition(n,c);c=f.getPositionY()-k.y*m.height-g.bottom}}}}};
ccui.linearHorizontalLayoutManager={_doLayout:function(a){var b=a._getLayoutContentSize();a=a._getLayoutElements();for(var c=0,d=0,e=a.length;e>d;d++){var f=a[d];if(f){var g=f.getLayoutParameter();if(g){var h=g.getGravity(),k=f.getAnchorPoint(),m=f.getContentSize(),c=c+k.x*m.width,n=b.height-(1-k.y)*m.height;switch(h){case ccui.LinearLayoutParameter.BOTTOM:n=k.y*m.height;break;case ccui.LinearLayoutParameter.CENTER_VERTICAL:n=b.height/2-m.height*(0.5-k.y)}g=g.getMargin();c+=g.left;n-=g.top;f.setPosition(c,
n);c=f.getRightBoundary()+g.right}}}}};
ccui.relativeLayoutManager={_unlayoutChildCount:0,_widgetChildren:[],_widget:null,_finalPositionX:0,_finalPositionY:0,_relativeWidgetLP:null,_doLayout:function(a){for(var b=this._widgetChildren=this._getAllWidgets(a);0<this._unlayoutChildCount;){for(var c=0,d=b.length;d>c;c++){this._widget=b[c];var e=this._widget.getLayoutParameter();e&&!e._put&&this._calculateFinalPositionWithRelativeWidget(a)&&(this._calculateFinalPositionWithRelativeAlign(),this._widget.setPosition(this._finalPositionX,this._finalPositionY),
e._put=!0)}this._unlayoutChildCount--}this._widgetChildren.length=0},_getAllWidgets:function(a){a=a._getLayoutElements();for(var b=this._widgetChildren,c=b.length=0,d=a.length;d>c;c++){var e=a[c];e&&(e.getLayoutParameter()._put=!1,this._unlayoutChildCount++,b.push(e))}return b},_getRelativeWidget:function(a){var b=null;if((a=a.getLayoutParameter().getRelativeToWidgetName())&&0!==a.length)for(var c=this._widgetChildren,d=0,e=c.length;e>d;d++){var f=c[d];if(f){var g=f.getLayoutParameter();if(g&&g.getRelativeName()===
a){b=f;this._relativeWidgetLP=g;break}}}return b},_calculateFinalPositionWithRelativeWidget:function(a){var b=this._widget,c=b.getAnchorPoint(),d=b.getContentSize();this._finalPositionY=this._finalPositionX=0;var e=this._getRelativeWidget(b),b=b.getLayoutParameter().getAlign();a=a._getLayoutContentSize();switch(b){case ccui.RelativeLayoutParameter.NONE:case ccui.RelativeLayoutParameter.PARENT_TOP_LEFT:this._finalPositionX=c.x*d.width;this._finalPositionY=a.height-(1-c.y)*d.height;break;case ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL:this._finalPositionX=
0.5*a.width-d.width*(0.5-c.x);this._finalPositionY=a.height-(1-c.y)*d.height;break;case ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT:this._finalPositionX=a.width-(1-c.x)*d.width;this._finalPositionY=a.height-(1-c.y)*d.height;break;case ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL:this._finalPositionX=c.x*d.width;this._finalPositionY=0.5*a.height-d.height*(0.5-c.y);break;case ccui.RelativeLayoutParameter.CENTER_IN_PARENT:this._finalPositionX=0.5*a.width-d.width*(0.5-c.x);this._finalPositionY=
0.5*a.height-d.height*(0.5-c.y);break;case ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL:this._finalPositionX=a.width-(1-c.x)*d.width;this._finalPositionY=0.5*a.height-d.height*(0.5-c.y);break;case ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM:this._finalPositionX=c.x*d.width;this._finalPositionY=c.y*d.height;break;case ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL:this._finalPositionX=0.5*a.width-d.width*(0.5-c.x);this._finalPositionY=c.y*d.height;break;case ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM:this._finalPositionX=
a.width-(1-c.x)*d.width;this._finalPositionY=c.y*d.height;break;case ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;this._finalPositionY=e.getTopBoundary()+c.y*d.height;this._finalPositionX=e.getLeftBoundary()+c.x*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;a=e.getContentSize();this._finalPositionY=e.getTopBoundary()+c.y*d.height;
this._finalPositionX=e.getLeftBoundary()+0.5*a.width+c.x*d.width-0.5*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;this._finalPositionY=e.getTopBoundary()+c.y*d.height;this._finalPositionX=e.getRightBoundary()-(1-c.x)*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;this._finalPositionY=e.getTopBoundary()-
(1-c.y)*d.height;this._finalPositionX=e.getLeftBoundary()-(1-c.x)*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;a=e.getContentSize();this._finalPositionX=e.getLeftBoundary()-(1-c.x)*d.width;this._finalPositionY=e.getBottomBoundary()+0.5*a.height+c.y*d.height-0.5*d.height}break;case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;
this._finalPositionY=e.getBottomBoundary()+c.y*d.height;this._finalPositionX=e.getLeftBoundary()-(1-c.x)*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;this._finalPositionY=e.getTopBoundary()-(1-c.y)*d.height;this._finalPositionX=e.getRightBoundary()+c.x*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;a=e.getContentSize();
this._finalPositionX=e.getRightBoundary()+c.x*d.width;this._finalPositionY=e.getBottomBoundary()+0.5*a.height+c.y*d.height-0.5*d.height}break;case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;this._finalPositionY=e.getBottomBoundary()+c.y*d.height;this._finalPositionX=e.getRightBoundary()+c.x*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;
this._finalPositionY=e.getBottomBoundary()-(1-c.y)*d.height;this._finalPositionX=e.getLeftBoundary()+c.x*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;a=e.getContentSize();this._finalPositionY=e.getBottomBoundary()-(1-c.y)*d.height;this._finalPositionX=e.getLeftBoundary()+0.5*a.width+c.x*d.width-0.5*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN:if(e){if(this._relativeWidgetLP&&
!this._relativeWidgetLP._put)return!1;this._finalPositionY=e.getBottomBoundary()-(1-c.y)*d.height;this._finalPositionX=e.getRightBoundary()-(1-c.x)*d.width}}return!0},_calculateFinalPositionWithRelativeAlign:function(){var a=this._widget.getLayoutParameter(),b=a.getMargin();switch(a.getAlign()){case ccui.RelativeLayoutParameter.NONE:case ccui.RelativeLayoutParameter.PARENT_TOP_LEFT:this._finalPositionX+=b.left;this._finalPositionY-=b.top;break;case ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL:this._finalPositionY-=
b.top;break;case ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT:this._finalPositionX-=b.right;this._finalPositionY-=b.top;break;case ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL:this._finalPositionX+=b.left;break;case ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL:this._finalPositionX-=b.right;break;case ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM:this._finalPositionX+=b.left;this._finalPositionY+=b.bottom;break;case ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL:this._finalPositionY+=
b.bottom;break;case ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM:this._finalPositionX-=b.right;this._finalPositionY+=b.bottom;break;case ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN:this._finalPositionY+=b.bottom;this._finalPositionX+=b.left;break;case ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN:this._finalPositionY+=b.bottom;this._finalPositionX-=b.right;break;case ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER:this._finalPositionY+=b.bottom;break;case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN:this._finalPositionX-=
b.right;this._finalPositionY-=b.top;break;case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN:this._finalPositionX-=b.right;this._finalPositionY+=b.bottom;break;case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER:this._finalPositionX-=b.right;break;case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN:this._finalPositionX+=b.left;this._finalPositionY-=b.top;break;case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN:this._finalPositionX+=b.left;this._finalPositionY+=
b.bottom;break;case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER:this._finalPositionX+=b.left;break;case ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN:this._finalPositionY-=b.top;this._finalPositionX+=b.left;break;case ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN:this._finalPositionY-=b.top;this._finalPositionX-=b.right;break;case ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER:this._finalPositionY-=b.top}}};
ccui.HBox=ccui.Layout.extend({ctor:function(a){ccui.Layout.prototype.ctor.call(this,a);void 0!==a?this.initWithSize(a):this.init()},init:function(){return ccui.Layout.prototype.init.call(this)?(this.setLayoutType(ccui.Layout.LINEAR_HORIZONTAL),!0):!1},initWithSize:function(a){return this.init()?(this.setContentSize(a),!0):!1}});ccui.HBox.create=function(a){return new ccui.HBox(a)};
ccui.RelativeBox=ccui.Layout.extend({ctor:function(a){a?this.initWithSize(a):this.init()},init:function(){return ccui.Layout.prototype.init.call(this)?(this.setLayoutType(ccui.Layout.RELATIVE),!0):!1},initWithSize:function(a){return this.init()?(this.setContentSize(a),!0):!1}});ccui.RelativeBox.create=function(a){return new ccui.RelativeBox(a)};
ccui.VBox=ccui.Layout.extend({ctor:function(a){ccui.Layout.prototype.ctor.call(this,a);void 0!==a?this.initWithSize(a):this.init()},init:function(){return ccui.Layout.prototype.init.call(this)?(this.setLayoutType(ccui.Layout.LINEAR_VERTICAL),!0):!1},initWithSize:function(a){return this.init()?(this.setContentSize(a),!0):!1}});ccui.VBox.create=function(a){return new ccui.VBox(a)};
ccui.helper={seekWidgetByTag:function(a,b){if(!a)return null;if(a.getTag()===b)return a;for(var c=a.getChildren(),d=c.length,e=0;d>e;e++){var f=ccui.helper.seekWidgetByTag(c[e],b);if(null!==f)return f}return null},seekWidgetByName:function(a,b){if(!a)return null;if(a.getName()===b)return a;for(var c=a.getChildren(),d=c.length,e=0;d>e;e++){var f=ccui.helper.seekWidgetByName(c[e],b);if(null!==f)return f}return null},seekWidgetByRelativeName:function(a,b){if(!a)return null;for(var c=a.getChildren(),
d=c.length,e=0;d>e;e++){var f=c[e],g=f.getLayoutParameter(ccui.LayoutParameter.RELATIVE);if(g&&g.getRelativeName()===b)return f}return null},seekActionWidgetByActionTag:function(a,b){if(!a)return null;if(a.getActionTag()===b)return a;for(var c=a.getChildren(),d=0;d<c.length;d++){var e=ccui.helper.seekActionWidgetByActionTag(c[d],b);if(null!==e)return e}return null},_activeLayout:!0,doLayout:function(a){if(this._activeLayout){var b;a=a.getChildren();for(var c=0,d=a.length;d>c;c++){b=a[c];var e=b.getComponent(ccui.LayoutComponent.NAME);
b=b.getParent();null!=e&&null!==b&&e.refreshLayout&&e.refreshLayout()}}},changeLayoutSystemActiveState:function(a){this._activeLayout=a},restrictCapInsetRect:function(a,b){var c=a.x,d=a.y,e=a.width,f=a.height;return b.width<e&&(c=0,e=0),b.height<f&&(d=0,f=0),cc.rect(c,d,e,f)}};
ccui.Button=ccui.Widget.extend({_buttonNormalRenderer:null,_buttonClickedRenderer:null,_buttonDisableRenderer:null,_titleRenderer:null,_normalFileName:"",_clickedFileName:"",_disabledFileName:"",_prevIgnoreSize:!0,_scale9Enabled:!1,_capInsetsNormal:null,_capInsetsPressed:null,_capInsetsDisabled:null,_normalTexType:ccui.Widget.LOCAL_TEXTURE,_pressedTexType:ccui.Widget.LOCAL_TEXTURE,_disabledTexType:ccui.Widget.LOCAL_TEXTURE,_normalTextureSize:null,_pressedTextureSize:null,_disabledTextureSize:null,
pressedActionEnabled:!1,_titleColor:null,_normalTextureScaleXInSize:1,_normalTextureScaleYInSize:1,_pressedTextureScaleXInSize:1,_pressedTextureScaleYInSize:1,_zoomScale:0.1,_normalTextureLoaded:!1,_pressedTextureLoaded:!1,_disabledTextureLoaded:!1,_className:"Button",_normalTextureAdaptDirty:!0,_pressedTextureAdaptDirty:!0,_disabledTextureAdaptDirty:!0,_fontName:"Thonburi",_fontSize:12,_type:0,ctor:function(a,b,c,d){this._capInsetsNormal=cc.rect(0,0,0,0);this._capInsetsPressed=cc.rect(0,0,0,0);this._capInsetsDisabled=
cc.rect(0,0,0,0);this._normalTextureSize=cc.size(0,0);this._pressedTextureSize=cc.size(0,0);this._disabledTextureSize=cc.size(0,0);this._titleColor=cc.color.WHITE;ccui.Widget.prototype.ctor.call(this);this.setTouchEnabled(!0);this.init(a,b,c,d)},init:function(a,b,c,d){if(ccui.Widget.prototype.init.call(this)){if(void 0===a)return!0;this.loadTextures(a,b,c,d)}return!1},_initRenderer:function(){this._buttonNormalRenderer=new cc.Sprite;this._buttonClickedRenderer=new cc.Sprite;this._buttonDisableRenderer=
new cc.Sprite;this._titleRenderer=new cc.LabelTTF("");this._titleRenderer.setAnchorPoint(0.5,0.5);this.addProtectedChild(this._buttonNormalRenderer,ccui.Button.NORMAL_RENDERER_ZORDER,-1);this.addProtectedChild(this._buttonClickedRenderer,ccui.Button.PRESSED_RENDERER_ZORDER,-1);this.addProtectedChild(this._buttonDisableRenderer,ccui.Button.DISABLED_RENDERER_ZORDER,-1);this.addProtectedChild(this._titleRenderer,ccui.Button.TITLE_RENDERER_ZORDER,-1)},setScale9Enabled:function(a){this._scale9Enabled!==
a&&((this._brightStyle=ccui.Widget.BRIGHT_STYLE_NONE,this._scale9Enabled=a,this.removeProtectedChild(this._buttonNormalRenderer),this.removeProtectedChild(this._buttonClickedRenderer),this.removeProtectedChild(this._buttonDisableRenderer),this._scale9Enabled?(this._buttonNormalRenderer=new ccui.Scale9Sprite,this._buttonClickedRenderer=new ccui.Scale9Sprite,this._buttonDisableRenderer=new ccui.Scale9Sprite):(this._buttonNormalRenderer=new cc.Sprite,this._buttonClickedRenderer=new cc.Sprite,this._buttonDisableRenderer=
new cc.Sprite),this._buttonClickedRenderer.setVisible(!1),this._buttonDisableRenderer.setVisible(!1),this.loadTextureNormal(this._normalFileName,this._normalTexType),this.loadTexturePressed(this._clickedFileName,this._pressedTexType),this.loadTextureDisabled(this._disabledFileName,this._disabledTexType),this.addProtectedChild(this._buttonNormalRenderer,ccui.Button.NORMAL_RENDERER_ZORDER,-1),this.addProtectedChild(this._buttonClickedRenderer,ccui.Button.PRESSED_RENDERER_ZORDER,-1),this.addProtectedChild(this._buttonDisableRenderer,
ccui.Button.DISABLED_RENDERER_ZORDER,-1),this._scale9Enabled)?(a=this._ignoreSize,this.ignoreContentAdaptWithSize(!1),this._prevIgnoreSize=a):this.ignoreContentAdaptWithSize(this._prevIgnoreSize),this.setCapInsetsNormalRenderer(this._capInsetsNormal),this.setCapInsetsPressedRenderer(this._capInsetsPressed),this.setCapInsetsDisabledRenderer(this._capInsetsDisabled),this.setBright(this._bright),this._disabledTextureAdaptDirty=this._pressedTextureAdaptDirty=this._normalTextureAdaptDirty=!0)},isScale9Enabled:function(){return this._scale9Enabled},
ignoreContentAdaptWithSize:function(a){return this._unifySize?void this._updateContentSize():void((!this._scale9Enabled||this._scale9Enabled&&!a)&&(ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this,a),this._prevIgnoreSize=a))},getVirtualRendererSize:function(){return this._unifySize?this._getNormalSize():!this._normalTextureLoaded&&0<this._titleRenderer.getString().length?this._titleRenderer.getContentSize():cc.size(this._normalTextureSize)},loadTextures:function(a,b,c,d){this.loadTextureNormal(a,
d);this.loadTexturePressed(b,d);this.loadTextureDisabled(c,d)},loadTextureNormal:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE;this._normalFileName=a;this._normalTexType=b;var c=this,d=this._buttonNormalRenderer;switch(d._textureLoaded||d.addEventListener("load",function(){c.loadTextureNormal(c._normalFileName,c._normalTexType)}),this._normalTexType){case ccui.Widget.LOCAL_TEXTURE:d.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:d.initWithSpriteFrameName(a)}this._normalTextureSize=this._buttonNormalRenderer.getContentSize();
this._updateChildrenDisplayedRGBA();this._unifySize?this._scale9Enabled&&(d.setCapInsets(this._capInsetsNormal),this._updateContentSizeWithTextureSize(this._getNormalSize())):this._updateContentSizeWithTextureSize(this._normalTextureSize);this._normalTextureAdaptDirty=this._normalTextureLoaded=!0;this._findLayout()}},loadTexturePressed:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE;this._clickedFileName=a;this._pressedTexType=b;var c=this,d=this._buttonClickedRenderer;switch(d._textureLoaded||
d.addEventListener("load",function(){c.loadTexturePressed(c._clickedFileName,c._pressedTexType)}),this._pressedTexType){case ccui.Widget.LOCAL_TEXTURE:d.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:d.initWithSpriteFrameName(a)}this._scale9Enabled&&d.setCapInsets(this._capInsetsPressed);this._pressedTextureSize=this._buttonClickedRenderer.getContentSize();this._updateChildrenDisplayedRGBA();this._pressedTextureAdaptDirty=this._pressedTextureLoaded=!0;this._findLayout()}},loadTextureDisabled:function(a,
b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE;this._disabledFileName=a;this._disabledTexType=b;var c=this,d=this._buttonDisableRenderer;switch(d._textureLoaded||d.addEventListener("load",function(){c.loadTextureDisabled(c._disabledFileName,c._disabledTexType)}),this._disabledTexType){case ccui.Widget.LOCAL_TEXTURE:d.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:d.initWithSpriteFrameName(a)}this._scale9Enabled&&d.setCapInsets(this._capInsetsDisabled);this._disabledTextureSize=this._buttonDisableRenderer.getContentSize();
this._updateChildrenDisplayedRGBA();this._disabledTextureAdaptDirty=this._disabledTextureLoaded=!0;this._findLayout()}},setCapInsets:function(a){this.setCapInsetsNormalRenderer(a);this.setCapInsetsPressedRenderer(a);this.setCapInsetsDisabledRenderer(a)},setCapInsetsNormalRenderer:function(a){if(a){var b=a.x,c=a.y,d=a.width;a=a.height;this._normalTextureSize.width<d&&(b=0,d=0);this._normalTextureSize.height<a&&(c=0,a=0);var e=this._capInsetsNormal;e.x=b;e.y=c;e.width=d;e.height=a;this._scale9Enabled&&
this._buttonNormalRenderer.setCapInsets(e)}},getCapInsetsNormalRenderer:function(){return cc.rect(this._capInsetsNormal)},setCapInsetsPressedRenderer:function(a){if(a&&this._scale9Enabled){var b=a.x,c=a.y,d=a.width;a=a.height;this._pressedTextureSize.width<d&&(b=0,d=0);this._pressedTextureSize.height<a&&(c=0,a=0);var e=this._capInsetsPressed;e.x=b;e.y=c;e.width=d;e.height=a;this._buttonClickedRenderer.setCapInsets(e)}},getCapInsetsPressedRenderer:function(){return cc.rect(this._capInsetsPressed)},
setCapInsetsDisabledRenderer:function(a){if(a&&this._scale9Enabled){var b=a.x,c=a.y,d=a.width;a=a.height;this._disabledTextureSize.width<d&&(b=0,d=0);this._disabledTextureSize.height<a&&(c=0,a=0);var e=this._capInsetsDisabled;e.x=b;e.y=c;e.width=d;e.height=a;this._buttonDisableRenderer.setCapInsets(e)}},getCapInsetsDisabledRenderer:function(){return cc.rect(this._capInsetsDisabled)},_onPressStateChangedToNormal:function(){if(this._buttonNormalRenderer.setVisible(!0),this._buttonClickedRenderer.setVisible(!1),
this._buttonDisableRenderer.setVisible(!1),this._scale9Enabled&&this._buttonNormalRenderer.setState(ccui.Scale9Sprite.state.NORMAL),this._pressedTextureLoaded){if(this.pressedActionEnabled)if(this._buttonNormalRenderer.stopAllActions(),this._buttonClickedRenderer.stopAllActions(),this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize,this._normalTextureScaleYInSize),this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize,this._pressedTextureScaleYInSize),this._titleRenderer.stopAllActions(),
this._unifySize){var a=cc.scaleTo(ccui.Button.ZOOM_ACTION_TIME_STEP,1,1);this._titleRenderer.runAction(a)}else this._titleRenderer.setScaleX(1),this._titleRenderer.setScaleY(1)}else this._buttonNormalRenderer.stopAllActions(),this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize,this._normalTextureScaleYInSize),this._titleRenderer.stopAllActions(),this._scale9Enabled&&this._buttonNormalRenderer.setColor(cc.color.WHITE),this._titleRenderer.setScaleX(1),this._titleRenderer.setScaleY(1)},
_onPressStateChangedToPressed:function(){var a=this._buttonNormalRenderer;if(this._scale9Enabled&&a.setState(ccui.Scale9Sprite.state.NORMAL),this._pressedTextureLoaded){if(a.setVisible(!1),this._buttonClickedRenderer.setVisible(!0),this._buttonDisableRenderer.setVisible(!1),this.pressedActionEnabled){a.stopAllActions();this._buttonClickedRenderer.stopAllActions();var b=cc.scaleTo(ccui.Button.ZOOM_ACTION_TIME_STEP,this._pressedTextureScaleXInSize+this._zoomScale,this._pressedTextureScaleYInSize+this._zoomScale);
this._buttonClickedRenderer.runAction(b);a.setScale(this._pressedTextureScaleXInSize+this._zoomScale,this._pressedTextureScaleYInSize+this._zoomScale);this._titleRenderer.stopAllActions();this._titleRenderer.runAction(cc.scaleTo(ccui.Button.ZOOM_ACTION_TIME_STEP,1+this._zoomScale,1+this._zoomScale))}}else a.setVisible(!0),this._buttonClickedRenderer.setVisible(!0),this._buttonDisableRenderer.setVisible(!1),a.stopAllActions(),a.setScale(this._normalTextureScaleXInSize+this._zoomScale,this._normalTextureScaleYInSize+
this._zoomScale),this._titleRenderer.stopAllActions(),this._titleRenderer.setScaleX(1+this._zoomScale),this._titleRenderer.setScaleY(1+this._zoomScale)},_onPressStateChangedToDisabled:function(){this._disabledTextureLoaded?(this._buttonNormalRenderer.setVisible(!1),this._buttonDisableRenderer.setVisible(!0)):this._normalTextureLoaded&&this._scale9Enabled&&this._buttonNormalRenderer.setState(ccui.Scale9Sprite.state.GRAY);this._buttonClickedRenderer.setVisible(!1);this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize,
this._normalTextureScaleYInSize);this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize,this._pressedTextureScaleYInSize)},_updateContentSize:function(){if(this._unifySize){if(this._scale9Enabled)ccui.ProtectedNode.setContentSize(this._customSize);else{var a=this._getNormalSize();ccui.ProtectedNode.setContentSize(a)}return void this._onSizeChanged()}this._ignoreSize&&this.setContentSize(this.getVirtualRendererSize())},_updateTexturesRGBA:function(){this._buttonNormalRenderer.setColor(this.getColor());
this._buttonClickedRenderer.setColor(this.getColor());this._buttonDisableRenderer.setColor(this.getColor());this._buttonNormalRenderer.setOpacity(this.getOpacity());this._buttonClickedRenderer.setOpacity(this.getOpacity());this._buttonDisableRenderer.setOpacity(this.getOpacity())},_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this);this._updateTitleLocation();this._disabledTextureAdaptDirty=this._pressedTextureAdaptDirty=this._normalTextureAdaptDirty=!0},getVirtualRenderer:function(){if(!this._bright)return this._buttonDisableRenderer;
switch(this._brightStyle){case ccui.Widget.BRIGHT_STYLE_NORMAL:return this._buttonNormalRenderer;case ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT:return this._buttonClickedRenderer;default:return null}},_normalTextureScaleChangedWithSize:function(){if(this._ignoreSize&&!this._unifySize)this._scale9Enabled||(this._buttonNormalRenderer.setScale(1),this._normalTextureScaleXInSize=this._normalTextureScaleYInSize=1);else if(this._scale9Enabled)this._buttonNormalRenderer.setPreferredSize(this._contentSize),this._normalTextureScaleXInSize=
this._normalTextureScaleYInSize=1,this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize,this._normalTextureScaleYInSize);else{var a=this._normalTextureSize;if(0>=a.width||0>=a.height)return void this._buttonNormalRenderer.setScale(1);var b=this._contentSize.width/a.width,a=this._contentSize.height/a.height;this._buttonNormalRenderer.setScaleX(b);this._buttonNormalRenderer.setScaleY(a);this._normalTextureScaleXInSize=b;this._normalTextureScaleYInSize=a}this._buttonNormalRenderer.setPosition(this._contentSize.width/
2,this._contentSize.height/2)},_pressedTextureScaleChangedWithSize:function(){if(this._ignoreSize&&!this._unifySize)this._scale9Enabled||(this._buttonClickedRenderer.setScale(1),this._pressedTextureScaleXInSize=this._pressedTextureScaleYInSize=1);else if(this._scale9Enabled)this._buttonClickedRenderer.setPreferredSize(this._contentSize),this._pressedTextureScaleXInSize=this._pressedTextureScaleYInSize=1,this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize,this._pressedTextureScaleYInSize);
else{var a=this._pressedTextureSize;if(0>=a.width||0>=a.height)return void this._buttonClickedRenderer.setScale(1);var b=this._contentSize.width/a.width,a=this._contentSize.height/a.height;this._buttonClickedRenderer.setScaleX(b);this._buttonClickedRenderer.setScaleY(a);this._pressedTextureScaleXInSize=b;this._pressedTextureScaleYInSize=a}this._buttonClickedRenderer.setPosition(this._contentSize.width/2,this._contentSize.height/2)},_disabledTextureScaleChangedWithSize:function(){if(this._ignoreSize&&
!this._unifySize)this._scale9Enabled&&this._buttonDisableRenderer.setScale(1);else if(this._scale9Enabled)this._buttonDisableRenderer.setScale(1),this._buttonDisableRenderer.setPreferredSize(this._contentSize);else{var a=this._disabledTextureSize;if(0>=a.width||0>=a.height)return void this._buttonDisableRenderer.setScale(1);var b=this._contentSize.height/a.height;this._buttonDisableRenderer.setScaleX(this._contentSize.width/a.width);this._buttonDisableRenderer.setScaleY(b)}this._buttonDisableRenderer.setPosition(this._contentSize.width/
2,this._contentSize.height/2)},_adaptRenderers:function(){this._normalTextureAdaptDirty&&(this._normalTextureScaleChangedWithSize(),this._normalTextureAdaptDirty=!1);this._pressedTextureAdaptDirty&&(this._pressedTextureScaleChangedWithSize(),this._pressedTextureAdaptDirty=!1);this._disabledTextureAdaptDirty&&(this._disabledTextureScaleChangedWithSize(),this._disabledTextureAdaptDirty=!1)},_updateTitleLocation:function(){this._titleRenderer.setPosition(0.5*this._contentSize.width,0.5*this._contentSize.height)},
setPressedActionEnabled:function(a){this.pressedActionEnabled=a},setTitleText:function(a){a!==this.getTitleText()&&((this._titleRenderer.setString(a),this._ignoreSize)?(a=this.getVirtualRendererSize(),this.setContentSize(a)):this._titleRenderer._renderCmd._updateTTF())},getTitleText:function(){return this._titleRenderer.getString()},setTitleColor:function(a){this._titleRenderer.setFontFillColor(a)},getTitleColor:function(){return this._titleRenderer._getFillStyle()},setTitleFontSize:function(a){this._titleRenderer.setFontSize(a);
this._fontSize=a},getTitleFontSize:function(){return this._titleRenderer.getFontSize()},setZoomScale:function(a){this._zoomScale=a},getZoomScale:function(){return this._zoomScale},getNormalTextureSize:function(){return this._normalTextureSize},setTitleFontName:function(a){this._titleRenderer.setFontName(a);this._fontName=a},getTitleRenderer:function(){return this._titleRenderer},getTitleFontName:function(){return this._titleRenderer.getFontName()},_setTitleFont:function(a){this._titleRenderer.font=
a},_getTitleFont:function(){return this._titleRenderer.font},getDescription:function(){return"Button"},_createCloneInstance:function(){return new ccui.Button},_copySpecialProperties:function(a){this._prevIgnoreSize=a._prevIgnoreSize;this.setScale9Enabled(a._scale9Enabled);this.loadTextureNormal(a._normalFileName,a._normalTexType);this.loadTexturePressed(a._clickedFileName,a._pressedTexType);this.loadTextureDisabled(a._disabledFileName,a._disabledTexType);this.setCapInsetsNormalRenderer(a._capInsetsNormal);
this.setCapInsetsPressedRenderer(a._capInsetsPressed);this.setCapInsetsDisabledRenderer(a._capInsetsDisabled);this.setTitleText(a.getTitleText());this.setTitleFontName(a.getTitleFontName());this.setTitleFontSize(a.getTitleFontSize());this.setTitleColor(a.getTitleColor());this.setPressedActionEnabled(a.pressedActionEnabled);this.setZoomScale(a._zoomScale)},setColor:function(a){cc.ProtectedNode.prototype.setColor.call(this,a);this._updateTexturesRGBA()},_getNormalSize:function(){var a;null!==this._titleRenderer&&
(a=this._titleRenderer.getContentSize());var b;null!==this._buttonNormalRenderer&&(b=this._buttonNormalRenderer.getContentSize());return cc.size(a.width>b.width?a.width:b.width,a.height>b.height?a.height:b.height)}});_p=ccui.Button.prototype;_p.titleText;cc.defineGetterSetter(_p,"titleText",_p.getTitleText,_p.setTitleText);_p.titleFont;cc.defineGetterSetter(_p,"titleFont",_p._getTitleFont,_p._setTitleFont);_p.titleFontSize;cc.defineGetterSetter(_p,"titleFontSize",_p.getTitleFontSize,_p.setTitleFontSize);
_p.titleFontName;cc.defineGetterSetter(_p,"titleFontName",_p.getTitleFontName,_p.setTitleFontName);_p.titleColor;cc.defineGetterSetter(_p,"titleColor",_p.getTitleColor,_p.setTitleColor);_p=null;ccui.Button.create=function(a,b,c,d){return new ccui.Button(a,b,c,d)};ccui.Button.NORMAL_RENDERER_ZORDER=-2;ccui.Button.PRESSED_RENDERER_ZORDER=-2;ccui.Button.DISABLED_RENDERER_ZORDER=-2;ccui.Button.TITLE_RENDERER_ZORDER=-1;ccui.Button.ZOOM_ACTION_TIME_STEP=0.05;ccui.Button.SYSTEM=0;ccui.Button.TTF=1;
ccui.CheckBox=ccui.Widget.extend({_backGroundBoxRenderer:null,_backGroundSelectedBoxRenderer:null,_frontCrossRenderer:null,_backGroundBoxDisabledRenderer:null,_frontCrossDisabledRenderer:null,_isSelected:!0,_checkBoxEventListener:null,_checkBoxEventSelector:null,_backGroundTexType:ccui.Widget.LOCAL_TEXTURE,_backGroundSelectedTexType:ccui.Widget.LOCAL_TEXTURE,_frontCrossTexType:ccui.Widget.LOCAL_TEXTURE,_backGroundDisabledTexType:ccui.Widget.LOCAL_TEXTURE,_frontCrossDisabledTexType:ccui.Widget.LOCAL_TEXTURE,
_backGroundFileName:"",_backGroundSelectedFileName:"",_frontCrossFileName:"",_backGroundDisabledFileName:"",_frontCrossDisabledFileName:"",_className:"CheckBox",_zoomScale:0.1,_backgroundTextureScaleX:0.1,_backgroundTextureScaleY:0.1,_backGroundBoxRendererAdaptDirty:!0,_backGroundSelectedBoxRendererAdaptDirty:!0,_frontCrossRendererAdaptDirty:!0,_backGroundBoxDisabledRendererAdaptDirty:!0,_frontCrossDisabledRendererAdaptDirty:!0,ctor:function(a,b,c,d,e,f){ccui.Widget.prototype.ctor.call(this);this.setTouchEnabled(!0);
for(var g=0,h=0;h<arguments.length;h++){var k=typeof arguments[h];"string"===k?isNaN(arguments[h]-0)?g++:(f=arguments[h],arguments[h]=void 0):"number"===k&&g++}switch(g){case 2:f=c,c=b,b=void 0}this.init(a,b,c,d,e,void 0===f?0:f)},init:function(a,b,c,d,e,f){return ccui.Widget.prototype.init.call(this)?(this._isSelected=!0,this.setSelected(!1),this.loadTextures(a,b,c,d,e,f),!0):!1},_initRenderer:function(){this._backGroundBoxRenderer=new cc.Sprite;this._backGroundSelectedBoxRenderer=new cc.Sprite;
this._frontCrossRenderer=new cc.Sprite;this._backGroundBoxDisabledRenderer=new cc.Sprite;this._frontCrossDisabledRenderer=new cc.Sprite;this.addProtectedChild(this._backGroundBoxRenderer,ccui.CheckBox.BOX_RENDERER_ZORDER,-1);this.addProtectedChild(this._backGroundSelectedBoxRenderer,ccui.CheckBox.BOX_SELECTED_RENDERER_ZORDER,-1);this.addProtectedChild(this._frontCrossRenderer,ccui.CheckBox.FRONT_CROSS_RENDERER_ZORDER,-1);this.addProtectedChild(this._backGroundBoxDisabledRenderer,ccui.CheckBox.BOX_DISABLED_RENDERER_ZORDER,
-1);this.addProtectedChild(this._frontCrossDisabledRenderer,ccui.CheckBox.FRONT_CROSS_DISABLED_RENDERER_ZORDER,-1)},loadTextures:function(a,b,c,d,e,f){a&&this.loadTextureBackGround(a,f);b&&this.loadTextureBackGroundSelected(b,f);c&&this.loadTextureFrontCross(c,f);d&&this.loadTextureBackGroundDisabled(d,f);e&&this.loadTextureFrontCrossDisabled(e,f)},loadTextureBackGround:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE;this._backGroundFileName=a;this._backGroundTexType=b;var c=this._backGroundBoxRenderer;
switch(c._textureLoaded?this._backGroundBoxRenderer.setContentSize(this._customSize):c.addEventListener("load",function(){this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize());this.loadTextureBackGround(this._backGroundFileName,this._backGroundTexType)},this),this._backGroundTexType){case ccui.Widget.LOCAL_TEXTURE:c.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:c.initWithSpriteFrameName(a)}this._updateChildrenDisplayedRGBA();this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize());
this._backGroundBoxRendererAdaptDirty=!0;this._findLayout()}},loadTextureBackGroundSelected:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE;this._backGroundSelectedFileName=a;this._backGroundSelectedTexType=b;var c=this._backGroundSelectedBoxRenderer;switch(c._textureLoaded||c.addEventListener("load",function(){this.loadTextureBackGroundSelected(this._backGroundSelectedFileName,this._backGroundSelectedTexType)},this),this._backGroundSelectedTexType){case ccui.Widget.LOCAL_TEXTURE:c.initWithFile(a);
break;case ccui.Widget.PLIST_TEXTURE:c.initWithSpriteFrameName(a)}this._updateChildrenDisplayedRGBA();this._backGroundSelectedBoxRendererAdaptDirty=!0;this._findLayout()}},loadTextureFrontCross:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE;this._frontCrossFileName=a;this._frontCrossTexType=b;var c=this._frontCrossRenderer;switch(c._textureLoaded||c.addEventListener("load",function(){this.loadTextureFrontCross(this._frontCrossFileName,this._frontCrossTexType)},this),this._frontCrossTexType){case ccui.Widget.LOCAL_TEXTURE:c.initWithFile(a);
break;case ccui.Widget.PLIST_TEXTURE:c.initWithSpriteFrameName(a)}this._updateChildrenDisplayedRGBA();this._frontCrossRendererAdaptDirty=!0;this._findLayout()}},loadTextureBackGroundDisabled:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE;this._backGroundDisabledFileName=a;this._backGroundDisabledTexType=b;var c=this._backGroundBoxDisabledRenderer;switch(c._textureLoaded||c.addEventListener("load",function(){this.loadTextureBackGroundDisabled(this._backGroundDisabledFileName,this._backGroundDisabledTexType)},
this),this._backGroundDisabledTexType){case ccui.Widget.LOCAL_TEXTURE:c.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:c.initWithSpriteFrameName(a)}this._updateChildrenDisplayedRGBA();this._backGroundBoxDisabledRendererAdaptDirty=!0;this._findLayout()}},loadTextureFrontCrossDisabled:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE;this._frontCrossDisabledFileName=a;this._frontCrossDisabledTexType=b;var c=this._frontCrossDisabledRenderer;switch(c._textureLoaded||c.addEventListener("load",function(){this.loadTextureFrontCrossDisabled(this._frontCrossDisabledFileName,
this._frontCrossDisabledTexType)},this),this._frontCrossDisabledTexType){case ccui.Widget.LOCAL_TEXTURE:c.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:c.initWithSpriteFrameName(a)}this._updateChildrenDisplayedRGBA();this._frontCrossDisabledRendererAdaptDirty=!0;this._findLayout()}},_onPressStateChangedToNormal:function(){this._backGroundBoxRenderer.setVisible(!0);this._backGroundSelectedBoxRenderer.setVisible(!1);this._backGroundBoxDisabledRenderer.setVisible(!1);this._frontCrossDisabledRenderer.setVisible(!1);
this._backGroundBoxRenderer.setScale(this._backgroundTextureScaleX,this._backgroundTextureScaleY);this._frontCrossRenderer.setScale(this._backgroundTextureScaleX,this._backgroundTextureScaleY);this._isSelected&&this._frontCrossRenderer.setVisible(!0)},_onPressStateChangedToPressed:function(){this._backGroundSelectedFileName?(this._backGroundBoxRenderer.setVisible(!1),this._backGroundSelectedBoxRenderer.setVisible(!0),this._backGroundBoxDisabledRenderer.setVisible(!1),this._frontCrossDisabledRenderer.setVisible(!1)):
(this._backGroundBoxRenderer.setScale(this._backgroundTextureScaleX+this._zoomScale,this._backgroundTextureScaleY+this._zoomScale),this._frontCrossRenderer.setScale(this._backgroundTextureScaleX+this._zoomScale,this._backgroundTextureScaleY+this._zoomScale))},_onPressStateChangedToDisabled:function(){this._backGroundDisabledFileName&&this._frontCrossDisabledFileName&&(this._backGroundBoxRenderer.setVisible(!1),this._backGroundBoxDisabledRenderer.setVisible(!0));this._backGroundSelectedBoxRenderer.setVisible(!1);
this._frontCrossRenderer.setVisible(!1);this._backGroundBoxRenderer.setScale(this._backgroundTextureScaleX,this._backgroundTextureScaleY);this._frontCrossRenderer.setScale(this._backgroundTextureScaleX,this._backgroundTextureScaleY);this._isSelected&&this._frontCrossDisabledRenderer.setVisible(!0)},setZoomScale:function(a){this._zoomScale=a},getZoomScale:function(){return this._zoomScale},setSelectedState:function(a){this.setSelected(a)},setSelected:function(a){a!==this._isSelected&&(this._isSelected=
a,this._frontCrossRenderer.setVisible(this._isSelected))},getSelectedState:function(){return this.isSelected()},isSelected:function(){return this._isSelected},_selectedEvent:function(){this._checkBoxEventSelector&&(this._checkBoxEventListener?this._checkBoxEventSelector.call(this._checkBoxEventListener,this,ccui.CheckBox.EVENT_SELECTED):this._checkBoxEventSelector(this,ccui.CheckBox.EVENT_SELECTED))},_unSelectedEvent:function(){this._checkBoxEventSelector&&(this._checkBoxEventListener?this._checkBoxEventSelector.call(this._checkBoxEventListener,
this,ccui.CheckBox.EVENT_UNSELECTED):this._checkBoxEventSelector(this,ccui.CheckBox.EVENT_UNSELECTED))},_releaseUpEvent:function(){ccui.Widget.prototype._releaseUpEvent.call(this);this._isSelected?(this.setSelected(!1),this._unSelectedEvent()):(this.setSelected(!0),this._selectedEvent())},addEventListenerCheckBox:function(a,b){this.addEventListener(a,b)},addEventListener:function(a,b){this._checkBoxEventSelector=a;this._checkBoxEventListener=b},getVirtualRendererSize:function(){return this._backGroundBoxRenderer.getContentSize()},
_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this);this._frontCrossDisabledRendererAdaptDirty=this._backGroundBoxDisabledRendererAdaptDirty=this._frontCrossRendererAdaptDirty=this._backGroundSelectedBoxRendererAdaptDirty=this._backGroundBoxRendererAdaptDirty=!0},getVirtualRenderer:function(){return this._backGroundBoxRenderer},_backGroundTextureScaleChangedWithSize:function(){var a=this._backGroundBoxRenderer,b=this._contentSize;if(this._ignoreSize)a.setScale(1),this._backgroundTextureScaleX=
this._backgroundTextureScaleY=1;else{var c=a.getContentSize();if(0>=c.width||0>=c.height)return a.setScale(1),void(this._backgroundTextureScaleX=this._backgroundTextureScaleY=1);var d=b.width/c.width,c=b.height/c.height;this._backgroundTextureScaleX=d;this._backgroundTextureScaleY=c;a.setScaleX(d);a.setScaleY(c)}a.setPosition(0.5*b.width,0.5*b.height)},_backGroundSelectedTextureScaleChangedWithSize:function(){var a=this._backGroundSelectedBoxRenderer,b=this._contentSize;if(this._ignoreSize)a.setScale(1);
else{var c=a.getContentSize();if(0>=c.width||0>=c.height)return void a.setScale(1);var d=b.height/c.height;a.setScaleX(b.width/c.width);a.setScaleY(d)}a.setPosition(0.5*b.width,0.5*b.height)},_frontCrossTextureScaleChangedWithSize:function(){var a=this._frontCrossRenderer,b=this._contentSize;if(this._ignoreSize)a.setScale(1);else{var c=a.getContentSize();if(0>=c.width||0>=c.height)return void a.setScale(1);var d=b.height/c.height;a.setScaleX(b.width/c.width);a.setScaleY(d)}a.setPosition(0.5*b.width,
0.5*b.height)},_backGroundDisabledTextureScaleChangedWithSize:function(){var a=this._backGroundBoxDisabledRenderer,b=this._contentSize;if(this._ignoreSize)a.setScale(1);else{var c=a.getContentSize();if(0>=c.width||0>=c.height)return void a.setScale(1);var d=b.height/c.height;a.setScaleX(b.width/c.width);a.setScaleY(d)}a.setPosition(0.5*b.width,0.5*b.height)},_frontCrossDisabledTextureScaleChangedWithSize:function(){var a=this._frontCrossDisabledRenderer,b=this._contentSize;if(this._ignoreSize)a.setScale(1);
else{var c=a.getContentSize();if(0>=c.width||0>=c.height)return void a.setScale(1);var d=b.height/c.height;a.setScaleX(b.width/c.width);a.setScaleY(d)}a.setPosition(0.5*b.width,0.5*b.height)},getDescription:function(){return"CheckBox"},_createCloneInstance:function(){return new ccui.CheckBox},_copySpecialProperties:function(a){a instanceof ccui.CheckBox&&(this.loadTextureBackGround(a._backGroundFileName,a._backGroundTexType),this.loadTextureBackGroundSelected(a._backGroundSelectedFileName,a._backGroundSelectedTexType),
this.loadTextureFrontCross(a._frontCrossFileName,a._frontCrossTexType),this.loadTextureBackGroundDisabled(a._backGroundDisabledFileName,a._backGroundDisabledTexType),this.loadTextureFrontCrossDisabled(a._frontCrossDisabledFileName,a._frontCrossDisabledTexType),this.setSelected(a._isSelected),this._checkBoxEventListener=a._checkBoxEventListener,this._checkBoxEventSelector=a._checkBoxEventSelector,this._ccEventCallback=a._ccEventCallback,this._zoomScale=a._zoomScale,this._backgroundTextureScaleX=a._backgroundTextureScaleX,
this._backgroundTextureScaleY=a._backgroundTextureScaleY)},_adaptRenderers:function(){this._backGroundBoxRendererAdaptDirty&&(this._backGroundTextureScaleChangedWithSize(),this._backGroundBoxRendererAdaptDirty=!1);this._backGroundSelectedBoxRendererAdaptDirty&&(this._backGroundSelectedTextureScaleChangedWithSize(),this._backGroundSelectedBoxRendererAdaptDirty=!1);this._frontCrossRendererAdaptDirty&&(this._frontCrossTextureScaleChangedWithSize(),this._frontCrossRendererAdaptDirty=!1);this._backGroundBoxDisabledRendererAdaptDirty&&
(this._backGroundDisabledTextureScaleChangedWithSize(),this._backGroundBoxDisabledRendererAdaptDirty=!1);this._frontCrossDisabledRendererAdaptDirty&&(this._frontCrossDisabledTextureScaleChangedWithSize(),this._frontCrossDisabledRendererAdaptDirty=!1)}});_p=ccui.CheckBox.prototype;_p.selected;cc.defineGetterSetter(_p,"selected",_p.isSelected,_p.setSelected);_p=null;ccui.CheckBox.create=function(a,b,c,d,e,f){return new ccui.CheckBox(a,b,c,d,e,f)};ccui.CheckBox.EVENT_SELECTED=0;
ccui.CheckBox.EVENT_UNSELECTED=1;ccui.CheckBox.BOX_RENDERER_ZORDER=-1;ccui.CheckBox.BOX_SELECTED_RENDERER_ZORDER=-1;ccui.CheckBox.BOX_DISABLED_RENDERER_ZORDER=-1;ccui.CheckBox.FRONT_CROSS_RENDERER_ZORDER=-1;ccui.CheckBox.FRONT_CROSS_DISABLED_RENDERER_ZORDER=-1;
ccui.ImageView=ccui.Widget.extend({_scale9Enabled:!1,_prevIgnoreSize:!0,_capInsets:null,_imageRenderer:null,_textureFile:"",_imageTexType:ccui.Widget.LOCAL_TEXTURE,_imageTextureSize:null,_className:"ImageView",_imageRendererAdaptDirty:!0,ctor:function(a,b){this._capInsets=cc.rect(0,0,0,0);this._imageTextureSize=cc.size(this._capInsets.width,this._capInsets.height);ccui.Widget.prototype.ctor.call(this);this.init(a,void 0===b?0:b)},init:function(a,b){return ccui.Widget.prototype.init.call(this)?(void 0===
a?this._imageTexType=ccui.Widget.LOCAL_TEXTURE:this.loadTexture(a,b),!0):!1},_initRenderer:function(){this._imageRenderer=new cc.Sprite;this.addProtectedChild(this._imageRenderer,ccui.ImageView.RENDERER_ZORDER,-1)},setRotation:function(a){this._imageRenderer.setRotation(a)},loadTexture:function(a,b){if(a){var c=this;b=b||ccui.Widget.LOCAL_TEXTURE;this._textureFile=a;this._imageTexType=b;var d=c._imageRenderer;switch(d._textureLoaded||d.addEventListener("load",function(){c.loadTexture(c._textureFile,
c._imageTexType)}),c._imageTexType){case ccui.Widget.LOCAL_TEXTURE:c._scale9Enabled?(d.initWithFile(a),d.setCapInsets(c._capInsets)):d.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:c._scale9Enabled?(d.initWithSpriteFrameName(a),d.setCapInsets(c._capInsets)):d.initWithSpriteFrameName(a)}c._imageTextureSize=d.getContentSize();this._updateChildrenDisplayedRGBA();c._updateContentSizeWithTextureSize(c._imageTextureSize);c._imageRendererAdaptDirty=!0;c._findLayout()}},setTextureRect:function(a){this._scale9Enabled||
this._imageRenderer.setTextureRect(a)},setScale9Enabled:function(a){this._scale9Enabled!==a&&((this._scale9Enabled=a,this.removeProtectedChild(this._imageRenderer),this._imageRenderer=null,this._scale9Enabled?this._imageRenderer=new ccui.Scale9Sprite:this._imageRenderer=new cc.Sprite,this.loadTexture(this._textureFile,this._imageTexType),this.addProtectedChild(this._imageRenderer,ccui.ImageView.RENDERER_ZORDER,-1),this._scale9Enabled)?(a=this._ignoreSize,this.ignoreContentAdaptWithSize(!1),this._prevIgnoreSize=
a):this.ignoreContentAdaptWithSize(this._prevIgnoreSize),this.setCapInsets(this._capInsets),this._imageRendererAdaptDirty=!0)},isScale9Enabled:function(){return this._scale9Enabled},ignoreContentAdaptWithSize:function(a){(!this._scale9Enabled||this._scale9Enabled&&!a)&&(ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this,a),this._prevIgnoreSize=a)},setCapInsets:function(a){if(a){var b=this._capInsets;b.x=a.x;b.y=a.y;b.width=a.width;b.height=a.height;this._scale9Enabled&&this._imageRenderer.setCapInsets(a)}},
getCapInsets:function(){return cc.rect(this._capInsets)},_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this);this._imageRendererAdaptDirty=!0},_adaptRenderers:function(){this._imageRendererAdaptDirty&&(this._imageTextureScaleChangedWithSize(),this._imageRendererAdaptDirty=!1)},getVirtualRendererSize:function(){return cc.size(this._imageTextureSize)},getVirtualRenderer:function(){return this._imageRenderer},_imageTextureScaleChangedWithSize:function(){if(this._ignoreSize)this._scale9Enabled||
this._imageRenderer.setScale(1);else if(this._scale9Enabled)this._imageRenderer.setPreferredSize(this._contentSize),this._imageRenderer.setScale(1);else{var a=this._imageTextureSize;if(0>=a.width||0>=a.height)return void this._imageRenderer.setScale(1);this._imageRenderer.setScaleX(this._contentSize.width/a.width);this._imageRenderer.setScaleY(this._contentSize.height/a.height)}this._imageRenderer.setPosition(this._contentSize.width/2,this._contentSize.height/2)},getDescription:function(){return"ImageView"},
_createCloneInstance:function(){return new ccui.ImageView},_copySpecialProperties:function(a){a instanceof ccui.ImageView&&(this._prevIgnoreSize=a._prevIgnoreSize,this.setScale9Enabled(a._scale9Enabled),this.loadTexture(a._textureFile,a._imageTexType),this.setCapInsets(a._capInsets))},setContentSize:function(a,b){if(null!=b&&(a=cc.size(a,b)),ccui.Widget.prototype.setContentSize.call(this,a),this._scale9Enabled)this._imageRenderer.setContentSize(a);else{var c=this._imageRenderer.getContentSize();this._imageRenderer.setScaleX(a.width/
c.width);this._imageRenderer.setScaleY(a.height/c.height)}}});ccui.ImageView.create=function(a,b){return new ccui.ImageView(a,b)};ccui.ImageView.RENDERER_ZORDER=-1;
ccui.LoadingBar=ccui.Widget.extend({_direction:null,_percent:100,_totalLength:0,_barRenderer:null,_renderBarTexType:ccui.Widget.LOCAL_TEXTURE,_barRendererTextureSize:null,_scale9Enabled:!1,_prevIgnoreSize:!0,_capInsets:null,_textureFile:"",_isTextureLoaded:!1,_className:"LoadingBar",_barRendererAdaptDirty:!0,ctor:function(a,b){this._direction=ccui.LoadingBar.TYPE_LEFT;this._barRendererTextureSize=cc.size(0,0);this._capInsets=cc.rect(0,0,0,0);ccui.Widget.prototype.ctor.call(this);void 0!==a&&this.loadTexture(a);
void 0!==b&&this.setPercent(b)},_initRenderer:function(){this._barRenderer=new cc.Sprite;this.addProtectedChild(this._barRenderer,ccui.LoadingBar.RENDERER_ZORDER,-1);this._barRenderer.setAnchorPoint(0,0.5)},setDirection:function(a){if(this._direction!==a)switch(this._direction=a,this._direction){case ccui.LoadingBar.TYPE_LEFT:this._barRenderer.setAnchorPoint(0,0.5);this._barRenderer.setPosition(0,0.5*this._contentSize.height);this._scale9Enabled||this._barRenderer.setFlippedX(!1);break;case ccui.LoadingBar.TYPE_RIGHT:this._barRenderer.setAnchorPoint(1,
0.5),this._barRenderer.setPosition(this._totalLength,0.5*this._contentSize.height),this._scale9Enabled||this._barRenderer.setFlippedX(!0)}},getDirection:function(){return this._direction},loadTexture:function(a,b){if(a){this._renderBarTexType=b=b||ccui.Widget.LOCAL_TEXTURE;this._textureFile=a;var c=this._barRenderer,d=this;switch(c._textureLoaded||c.addEventListener("load",function(){d.loadTexture(d._textureFile,d._renderBarTexType);d._setPercent(d._percent)}),this._renderBarTexType){case ccui.Widget.LOCAL_TEXTURE:c.initWithFile(a);
break;case ccui.Widget.PLIST_TEXTURE:c.initWithSpriteFrameName(a)}var e=c.getContentSize();switch(this._barRendererTextureSize.width=e.width,this._barRendererTextureSize.height=e.height,this._direction){case ccui.LoadingBar.TYPE_LEFT:c.setAnchorPoint(0,0.5);this._scale9Enabled||c.setFlippedX(!1);break;case ccui.LoadingBar.TYPE_RIGHT:c.setAnchorPoint(1,0.5),this._scale9Enabled||c.setFlippedX(!0)}this._scale9Enabled&&c.setCapInsets(this._capInsets);this._updateChildrenDisplayedRGBA();this._barRendererScaleChangedWithSize();
this._updateContentSizeWithTextureSize(this._barRendererTextureSize);this._barRendererAdaptDirty=!0;this._findLayout()}},setScale9Enabled:function(a){this._scale9Enabled!==a&&((this._scale9Enabled=a,this.removeProtectedChild(this._barRenderer),this._barRenderer=this._scale9Enabled?new ccui.Scale9Sprite:new cc.Sprite,this.loadTexture(this._textureFile,this._renderBarTexType),this.addProtectedChild(this._barRenderer,ccui.LoadingBar.RENDERER_ZORDER,-1),this._scale9Enabled)?(a=this._ignoreSize,this.ignoreContentAdaptWithSize(!1),
this._prevIgnoreSize=a):this.ignoreContentAdaptWithSize(this._prevIgnoreSize),this.setCapInsets(this._capInsets),this.setPercent(this._percent),this._barRendererAdaptDirty=!0)},isScale9Enabled:function(){return this._scale9Enabled},setCapInsets:function(a){if(a){var b=this._capInsets;b.x=a.x;b.y=a.y;b.width=a.width;b.height=a.height;this._scale9Enabled&&this._barRenderer.setCapInsets(a)}},getCapInsets:function(){return cc.rect(this._capInsets)},setPercent:function(a){100<a&&(a=100);0>a&&(a=0);a!==
this._percent&&(this._percent=a,this._setPercent(a))},_setPercent:function(a){if(!(0>=this._totalLength))if(a=this._percent/100,this._scale9Enabled)this._setScale9Scale();else{var b=this._barRenderer.getTextureRect();b.width=this._barRendererTextureSize.width*a;this._barRenderer.setTextureRect(cc.rect(b.x,b.y,this._barRendererTextureSize.width*a,this._barRendererTextureSize.height))}},setContentSize:function(a,b){ccui.Widget.prototype.setContentSize.call(this,a,b);this._totalLength=void 0===b?a.width:
a},getPercent:function(){return this._percent},_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this);this._barRendererAdaptDirty=!0},_adaptRenderers:function(){this._barRendererAdaptDirty&&(this._barRendererScaleChangedWithSize(),this._barRendererAdaptDirty=!1)},ignoreContentAdaptWithSize:function(a){(!this._scale9Enabled||this._scale9Enabled&&!a)&&(ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this,a),this._prevIgnoreSize=a)},getVirtualRendererSize:function(){return cc.size(this._barRendererTextureSize)},
getVirtualRenderer:function(){return this._barRenderer},_barRendererScaleChangedWithSize:function(){var a=this._barRenderer,b=this._contentSize;if(this._unifySize)this._totalLength=this._contentSize.width,this.setPercent(this._percent);else if(this._ignoreSize)this._scale9Enabled||(this._totalLength=this._barRendererTextureSize.width,a.setScale(1));else if(this._totalLength=b.width,this._scale9Enabled)this._setScale9Scale(),a.setScale(1);else{var c=this._barRendererTextureSize;if(0>=c.width||0>=c.height)return void a.setScale(1);
var d=b.height/c.height;a.setScaleX(b.width/c.width);a.setScaleY(d)}switch(this._direction){case ccui.LoadingBar.TYPE_LEFT:a.setPosition(0,0.5*b.height);break;case ccui.LoadingBar.TYPE_RIGHT:a.setPosition(this._totalLength,0.5*b.height)}},_setScale9Scale:function(){this._barRenderer.setPreferredSize(cc.size(this._percent/100*this._totalLength,this._contentSize.height))},getDescription:function(){return"LoadingBar"},_createCloneInstance:function(){return new ccui.LoadingBar},_copySpecialProperties:function(a){a instanceof
ccui.LoadingBar&&(this._prevIgnoreSize=a._prevIgnoreSize,this.setScale9Enabled(a._scale9Enabled),this.loadTexture(a._textureFile,a._renderBarTexType),this.setCapInsets(a._capInsets),this.setPercent(a._percent),this.setDirection(a._direction))}});_p=ccui.LoadingBar.prototype;_p.direction;cc.defineGetterSetter(_p,"direction",_p.getDirection,_p.setDirection);_p.percent;cc.defineGetterSetter(_p,"percent",_p.getPercent,_p.setPercent);_p=null;
ccui.LoadingBar.create=function(a,b){return new ccui.LoadingBar(a,b)};ccui.LoadingBar.TYPE_LEFT=0;ccui.LoadingBar.TYPE_RIGHT=1;ccui.LoadingBar.RENDERER_ZORDER=-1;
ccui.Slider=ccui.Widget.extend({_barRenderer:null,_progressBarRenderer:null,_barTextureSize:null,_progressBarTextureSize:null,_slidBallNormalRenderer:null,_slidBallPressedRenderer:null,_slidBallDisabledRenderer:null,_slidBallRenderer:null,_barLength:0,_percent:0,_scale9Enabled:!1,_prevIgnoreSize:!0,_textureFile:"",_progressBarTextureFile:"",_slidBallNormalTextureFile:"",_slidBallPressedTextureFile:"",_slidBallDisabledTextureFile:"",_capInsetsBarRenderer:null,_capInsetsProgressBarRenderer:null,_sliderEventListener:null,
_sliderEventSelector:null,_barTexType:ccui.Widget.LOCAL_TEXTURE,_progressBarTexType:ccui.Widget.LOCAL_TEXTURE,_ballNTexType:ccui.Widget.LOCAL_TEXTURE,_ballPTexType:ccui.Widget.LOCAL_TEXTURE,_ballDTexType:ccui.Widget.LOCAL_TEXTURE,_isTextureLoaded:!1,_className:"Slider",_barRendererAdaptDirty:!0,_progressBarRendererDirty:!0,_unifySize:!1,_zoomScale:0.1,_sliderBallNormalTextureScaleX:1,_sliderBallNormalTextureScaleY:1,ctor:function(a,b,c){this._barTextureSize=cc.size(0,0);this._progressBarTextureSize=
cc.size(0,0);this._capInsetsBarRenderer=cc.rect(0,0,0,0);this._capInsetsProgressBarRenderer=cc.rect(0,0,0,0);ccui.Widget.prototype.ctor.call(this);c=null==c?0:c;this.setTouchEnabled(!0);a&&this.loadBarTexture(a,c);b&&this.loadSlidBallTextures(b,c)},init:function(){return ccui.Widget.prototype.init.call(this)},_initRenderer:function(){this._barRenderer=new cc.Sprite;this._progressBarRenderer=new cc.Sprite;this._progressBarRenderer.setAnchorPoint(0,0.5);this.addProtectedChild(this._barRenderer,ccui.Slider.BASEBAR_RENDERER_ZORDER,
-1);this.addProtectedChild(this._progressBarRenderer,ccui.Slider.PROGRESSBAR_RENDERER_ZORDER,-1);this._slidBallNormalRenderer=new cc.Sprite;this._slidBallPressedRenderer=new cc.Sprite;this._slidBallPressedRenderer.setVisible(!1);this._slidBallDisabledRenderer=new cc.Sprite;this._slidBallDisabledRenderer.setVisible(!1);this._slidBallRenderer=new cc.Node;this._slidBallRenderer.addChild(this._slidBallNormalRenderer);this._slidBallRenderer.addChild(this._slidBallPressedRenderer);this._slidBallRenderer.addChild(this._slidBallDisabledRenderer);
this._slidBallRenderer.setCascadeColorEnabled(!0);this._slidBallRenderer.setCascadeOpacityEnabled(!0);this.addProtectedChild(this._slidBallRenderer,ccui.Slider.BALL_RENDERER_ZORDER,-1)},loadBarTexture:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE;this._textureFile=a;this._barTexType=b;var c=this._barRenderer,d=this;switch(c._textureLoaded||c.addEventListener("load",function(){d.loadBarTexture(d._textureFile,d._barTexType)}),this._barTexType){case ccui.Widget.LOCAL_TEXTURE:c.initWithFile(a);break;
case ccui.Widget.PLIST_TEXTURE:c.initWithSpriteFrameName(a)}this._updateChildrenDisplayedRGBA();this._progressBarRendererDirty=this._barRendererAdaptDirty=!0;this._updateContentSizeWithTextureSize(this._barRenderer.getContentSize());this._findLayout();this._barTextureSize=this._barRenderer.getContentSize()}},loadProgressBarTexture:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE;this._progressBarTextureFile=a;this._progressBarTexType=b;var c=this._progressBarRenderer,d=this;switch(c._textureLoaded||
c.addEventListener("load",function(){d.loadProgressBarTexture(d._progressBarTextureFile,d._progressBarTexType)}),this._progressBarTexType){case ccui.Widget.LOCAL_TEXTURE:c.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:c.initWithSpriteFrameName(a)}this._updateChildrenDisplayedRGBA();this._progressBarRenderer.setAnchorPoint(cc.p(0,0.5));c=this._progressBarRenderer.getContentSize();this._progressBarTextureSize={width:c.width,height:c.height};this._progressBarRendererDirty=!0;this._findLayout()}},
setScale9Enabled:function(a){this._scale9Enabled!==a&&((this._scale9Enabled=a,this.removeProtectedChild(this._barRenderer,!0),this.removeProtectedChild(this._progressBarRenderer,!0),this._barRenderer=null,this._progressBarRenderer=null,this._scale9Enabled?(this._barRenderer=new ccui.Scale9Sprite,this._progressBarRenderer=new ccui.Scale9Sprite):(this._barRenderer=new cc.Sprite,this._progressBarRenderer=new cc.Sprite),this.loadBarTexture(this._textureFile,this._barTexType),this.loadProgressBarTexture(this._progressBarTextureFile,
this._progressBarTexType),this.addProtectedChild(this._barRenderer,ccui.Slider.BASEBAR_RENDERER_ZORDER,-1),this.addProtectedChild(this._progressBarRenderer,ccui.Slider.PROGRESSBAR_RENDERER_ZORDER,-1),this._scale9Enabled)?(a=this._ignoreSize,this.ignoreContentAdaptWithSize(!1),this._prevIgnoreSize=a):this.ignoreContentAdaptWithSize(this._prevIgnoreSize),this.setCapInsetsBarRenderer(this._capInsetsBarRenderer),this.setCapInsetProgressBarRenderer(this._capInsetsProgressBarRenderer),this._progressBarRendererDirty=
this._barRendererAdaptDirty=!0)},isScale9Enabled:function(){return this._scale9Enabled},ignoreContentAdaptWithSize:function(a){(!this._scale9Enabled||this._scale9Enabled&&!a)&&(ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this,a),this._prevIgnoreSize=a)},setCapInsets:function(a){this.setCapInsetsBarRenderer(a);this.setCapInsetProgressBarRenderer(a)},setCapInsetsBarRenderer:function(a){if(a){var b=this._capInsetsBarRenderer;b.x=a.x;b.y=a.y;b.width=a.width;b.height=a.height;this._scale9Enabled&&
this._barRenderer.setCapInsets(a)}},getCapInsetsBarRenderer:function(){return cc.rect(this._capInsetsBarRenderer)},setCapInsetProgressBarRenderer:function(a){if(a){var b=this._capInsetsProgressBarRenderer;b.x=a.x;b.y=a.y;b.width=a.width;b.height=a.height;this._scale9Enabled&&this._progressBarRenderer.setCapInsets(a)}},getCapInsetsProgressBarRenderer:function(){return cc.rect(this._capInsetsProgressBarRenderer)},loadSlidBallTextures:function(a,b,c,d){this.loadSlidBallTextureNormal(a,d);this.loadSlidBallTexturePressed(b,
d);this.loadSlidBallTextureDisabled(c,d)},loadSlidBallTextureNormal:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE;this._slidBallNormalTextureFile=a;this._ballNTexType=b;var c=this;switch(this._slidBallNormalRenderer._textureLoaded||this._slidBallNormalRenderer.addEventListener("load",function(){c.loadSlidBallTextureNormal(c._slidBallNormalTextureFile,c._ballNTexType)}),this._ballNTexType){case ccui.Widget.LOCAL_TEXTURE:this._slidBallNormalRenderer.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:this._slidBallNormalRenderer.initWithSpriteFrameName(a)}this._updateChildrenDisplayedRGBA();
this._findLayout()}},loadSlidBallTexturePressed:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE;this._slidBallPressedTextureFile=a;this._ballPTexType=b;var c=this;switch(this._slidBallPressedRenderer._textureLoaded||this._slidBallPressedRenderer.addEventListener("load",function(){c.loadSlidBallTexturePressed(c._slidBallPressedTextureFile,c._ballPTexType)}),this._ballPTexType){case ccui.Widget.LOCAL_TEXTURE:this._slidBallPressedRenderer.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:this._slidBallPressedRenderer.initWithSpriteFrameName(a)}this._updateChildrenDisplayedRGBA();
this._findLayout()}},loadSlidBallTextureDisabled:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE;this._slidBallDisabledTextureFile=a;this._ballDTexType=b;var c=this;switch(this._slidBallDisabledRenderer._textureLoaded||this._slidBallDisabledRenderer.addEventListener("load",function(){c.loadSlidBallTextureDisabled(c._slidBallDisabledTextureFile,c._ballDTexType)}),this._ballDTexType){case ccui.Widget.LOCAL_TEXTURE:this._slidBallDisabledRenderer.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:this._slidBallDisabledRenderer.initWithSpriteFrameName(a)}this._updateChildrenDisplayedRGBA();
this._findLayout()}},setPercent:function(a){100<a&&(a=100);0>a&&(a=0);this._percent=a;a=this._barLength*(a/100);if(this._slidBallRenderer.setPosition(a,this._contentSize.height/2),this._scale9Enabled)this._progressBarRenderer.setPreferredSize(cc.size(a,this._contentSize.height));else{var b=this._progressBarRenderer,c=b.getTextureRect();b.setTextureRect(cc.rect(c.x,c.y,a/b._scaleX,c.height),b.isTextureRectRotated())}},hitTest:function(a){a=this._slidBallNormalRenderer.convertToNodeSpace(a);var b=this._slidBallNormalRenderer.getContentSize(),
b=cc.rect(0,0,b.width,b.height);return a.x>=b.x&&a.x<=b.x+b.width&&a.y>=b.y&&a.y<=b.y+b.height},onTouchBegan:function(a,b){var c=ccui.Widget.prototype.onTouchBegan.call(this,a,b);if(this._hit){var d=this.convertToNodeSpace(this._touchBeganPosition);this.setPercent(this._getPercentWithBallPos(d.x));this._percentChangedEvent()}return c},onTouchMoved:function(a,b){var c=a.getLocation(),c=this.convertToNodeSpace(c);this.setPercent(this._getPercentWithBallPos(c.x));this._percentChangedEvent()},onTouchEnded:function(a,
b){ccui.Widget.prototype.onTouchEnded.call(this,a,b)},onTouchCancelled:function(a,b){ccui.Widget.prototype.onTouchCancelled.call(this,a,b)},_getPercentWithBallPos:function(a){return 100*(a/this._barLength)},addEventListenerSlider:function(a,b){this.addEventListener(a,b)},addEventListener:function(a,b){this._sliderEventSelector=a;this._sliderEventListener=b},_percentChangedEvent:function(){this._sliderEventSelector&&(this._sliderEventListener?this._sliderEventSelector.call(this._sliderEventListener,
this,ccui.Slider.EVENT_PERCENT_CHANGED):this._sliderEventSelector(this,ccui.Slider.EVENT_PERCENT_CHANGED));this._ccEventCallback&&this._ccEventCallback(this,ccui.Slider.EVENT_PERCENT_CHANGED)},getPercent:function(){return this._percent},_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this);this._progressBarRendererDirty=this._barRendererAdaptDirty=!0},_adaptRenderers:function(){this._barRendererAdaptDirty&&(this._barRendererScaleChangedWithSize(),this._barRendererAdaptDirty=!1);
this._progressBarRendererDirty&&(this._progressBarRendererScaleChangedWithSize(),this._progressBarRendererDirty=!1)},getVirtualRendererSize:function(){return this._barRenderer.getContentSize()},getVirtualRenderer:function(){return this._barRenderer},_barRendererScaleChangedWithSize:function(){if(this._unifySize)this._barLength=this._contentSize.width,this._barRenderer.setPreferredSize(this._contentSize);else if(this._ignoreSize)this._barRenderer.setScale(1),this._barLength=this._contentSize.width;
else if(this._barLength=this._contentSize.width,this._scale9Enabled)this._barRenderer.setPreferredSize(this._contentSize),this._barRenderer.setScale(1);else{var a=this._barTextureSize;if(0>=a.width||0>=a.height)return void this._barRenderer.setScale(1);var b=this._contentSize.height/a.height;this._barRenderer.setScaleX(this._contentSize.width/a.width);this._barRenderer.setScaleY(b)}this._barRenderer.setPosition(this._contentSize.width/2,this._contentSize.height/2);this.setPercent(this._percent)},
_progressBarRendererScaleChangedWithSize:function(){if(this._unifySize)this._progressBarRenderer.setPreferredSize(this._contentSize);else if(this._ignoreSize){if(!this._scale9Enabled){var a=this._progressBarTextureSize,b=this._contentSize.width/a.width,a=this._contentSize.height/a.height;this._progressBarRenderer.setScaleX(b);this._progressBarRenderer.setScaleY(a)}}else if(this._scale9Enabled)this._progressBarRenderer.setPreferredSize(this._contentSize),this._progressBarRenderer.setScale(1);else{a=
this._progressBarTextureSize;if(0>=a.width||0>=a.height)return void this._progressBarRenderer.setScale(1);b=this._contentSize.width/a.width;a=this._contentSize.height/a.height;this._progressBarRenderer.setScaleX(b);this._progressBarRenderer.setScaleY(a)}this._progressBarRenderer.setPosition(0,this._contentSize.height/2);this.setPercent(this._percent)},_onPressStateChangedToNormal:function(){this._slidBallNormalRenderer.setVisible(!0);this._slidBallPressedRenderer.setVisible(!1);this._slidBallDisabledRenderer.setVisible(!1);
this._slidBallNormalRenderer.setScale(this._sliderBallNormalTextureScaleX,this._sliderBallNormalTextureScaleY)},_onPressStateChangedToPressed:function(){this._slidBallPressedTextureFile?(this._slidBallNormalRenderer.setVisible(!1),this._slidBallPressedRenderer.setVisible(!0),this._slidBallDisabledRenderer.setVisible(!1)):this._slidBallNormalRenderer.setScale(this._sliderBallNormalTextureScaleX+this._zoomScale,this._sliderBallNormalTextureScaleY+this._zoomScale)},_onPressStateChangedToDisabled:function(){this._slidBallDisabledTextureFile&&
(this._slidBallNormalRenderer.setVisible(!1),this._slidBallDisabledRenderer.setVisible(!0));this._slidBallNormalRenderer.setScale(this._sliderBallNormalTextureScaleX,this._sliderBallNormalTextureScaleY);this._slidBallPressedRenderer.setVisible(!1)},setZoomScale:function(a){this._zoomScale=a},getZoomScale:function(){return this._zoomScale},getDescription:function(){return"Slider"},_createCloneInstance:function(){return new ccui.Slider},_copySpecialProperties:function(a){this._prevIgnoreSize=a._prevIgnoreSize;
this.setScale9Enabled(a._scale9Enabled);this.loadBarTexture(a._textureFile,a._barTexType);this.loadProgressBarTexture(a._progressBarTextureFile,a._progressBarTexType);this.loadSlidBallTextureNormal(a._slidBallNormalTextureFile,a._ballNTexType);this.loadSlidBallTexturePressed(a._slidBallPressedTextureFile,a._ballPTexType);this.loadSlidBallTextureDisabled(a._slidBallDisabledTextureFile,a._ballDTexType);this.setPercent(a.getPercent());this._sliderEventListener=a._sliderEventListener;this._sliderEventSelector=
a._sliderEventSelector;this._zoomScale=a._zoomScale;this._ccEventCallback=a._ccEventCallback}});_p=ccui.Slider.prototype;_p.percent;cc.defineGetterSetter(_p,"percent",_p.getPercent,_p.setPercent);_p=null;ccui.Slider.create=function(a,b,c){return new ccui.Slider(a,b,c)};ccui.Slider.EVENT_PERCENT_CHANGED=0;ccui.Slider.BASEBAR_RENDERER_ZORDER=-3;ccui.Slider.PROGRESSBAR_RENDERER_ZORDER=-2;ccui.Slider.BALL_RENDERER_ZORDER=-1;
ccui.Text=ccui.Widget.extend({_touchScaleChangeEnabled:!1,_normalScaleValueX:1,_normalScaleValueY:1,_fontName:"Thonburi",_fontSize:10,_onSelectedScaleOffset:0.5,_labelRenderer:"",_textAreaSize:null,_textVerticalAlignment:0,_textHorizontalAlignment:0,_className:"Text",_type:null,_labelRendererAdaptDirty:!0,ctor:function(a,b,c){this._type=ccui.Text.Type.SYSTEM;this._textAreaSize=cc.size(0,0);ccui.Widget.prototype.ctor.call(this);void 0!==c&&this.init(a,b,c)},init:function(a,b,c){return ccui.Widget.prototype.init.call(this)?
(0<arguments.length?(this.setFontName(b),this.setFontSize(c),this.setString(a)):this.setFontName(this._fontName),!0):!1},_initRenderer:function(){this._labelRenderer=new cc.LabelTTF;this.addProtectedChild(this._labelRenderer,ccui.Text.RENDERER_ZORDER,-1)},setText:function(a){cc.log("Please use the setString");this.setString(a)},setString:function(a){a!==this._labelRenderer.getString()&&(this._labelRenderer.setString(a),this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()),this._labelRendererAdaptDirty=
!0)},getStringValue:function(){return cc.log("Please use the getString"),this._labelRenderer.getString()},getString:function(){return this._labelRenderer.getString()},getStringLength:function(){return this._labelRenderer.getStringLength()},setFontSize:function(a){this._labelRenderer.setFontSize(a);this._fontSize=a;this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize());this._labelRendererAdaptDirty=!0},getFontSize:function(){return this._fontSize},setFontName:function(a){this._fontName=
a;this._labelRenderer.setFontName(a);this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize());this._labelRendererAdaptDirty=!0},getFontName:function(){return this._fontName},_setFont:function(a){var b=cc.LabelTTF._fontStyleRE.exec(a);b&&(this._fontSize=parseInt(b[1]),this._fontName=b[2],this._labelRenderer._setFont(a),this._labelScaleChangedWithSize())},_getFont:function(){return this._labelRenderer._getFont()},getType:function(){return this._type},setTextAreaSize:function(a){this._labelRenderer.setDimensions(a);
this._ignoreSize||(this._customSize=a);this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize());this._labelRendererAdaptDirty=!0},getTextAreaSize:function(){return this._labelRenderer.getDimensions()},setTextHorizontalAlignment:function(a){this._labelRenderer.setHorizontalAlignment(a);this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize());this._labelRendererAdaptDirty=!0},getTextHorizontalAlignment:function(){return this._labelRenderer.getHorizontalAlignment()},
setTextVerticalAlignment:function(a){this._labelRenderer.setVerticalAlignment(a);this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize());this._labelRendererAdaptDirty=!0},getTextVerticalAlignment:function(){return this._labelRenderer.getVerticalAlignment()},setTouchScaleChangeEnabled:function(a){this._touchScaleChangeEnabled=a},isTouchScaleChangeEnabled:function(){return this._touchScaleChangeEnabled},_onPressStateChangedToNormal:function(){this._touchScaleChangeEnabled&&(this._labelRenderer.setScaleX(this._normalScaleValueX),
this._labelRenderer.setScaleY(this._normalScaleValueY))},_onPressStateChangedToPressed:function(){this._touchScaleChangeEnabled&&(this._labelRenderer.setScaleX(this._normalScaleValueX+this._onSelectedScaleOffset),this._labelRenderer.setScaleY(this._normalScaleValueY+this._onSelectedScaleOffset))},_onPressStateChangedToDisabled:function(){},_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this);this._labelRendererAdaptDirty=!0},_adaptRenderers:function(){this._labelRendererAdaptDirty&&
(this._labelScaleChangedWithSize(),this._labelRendererAdaptDirty=!1)},getVirtualRendererSize:function(){return this._labelRenderer.getContentSize()},getVirtualRenderer:function(){return this._labelRenderer},getAutoRenderSize:function(){var a=this._labelRenderer.getContentSize();return this._ignoreSize||(this._labelRenderer.setDimensions(0,0),a=this._labelRenderer.getContentSize(),this._labelRenderer.setDimensions(this._contentSize.width,this._contentSize.height)),a},_labelScaleChangedWithSize:function(){var a=
this._contentSize;if(this._ignoreSize)this._labelRenderer.setDimensions(0,0),this._labelRenderer.setScale(1),this._normalScaleValueX=this._normalScaleValueY=1;else{this._labelRenderer.setDimensions(cc.size(a.width,a.height));var b=this._labelRenderer.getContentSize();if(0>=b.width||0>=b.height)return void this._labelRenderer.setScale(1);var c=a.width/b.width,b=a.height/b.height;this._labelRenderer.setScaleX(c);this._labelRenderer.setScaleY(b);this._normalScaleValueX=c;this._normalScaleValueY=b}this._labelRenderer.setPosition(a.width/
2,a.height/2)},getDescription:function(){return"Label"},enableShadow:function(a,b,c){this._labelRenderer.enableShadow(a,b,c)},enableOutline:function(a,b){this._labelRenderer.enableStroke(a,b)},enableGlow:function(a){this._type===ccui.Text.Type.TTF&&this._labelRenderer.enableGlow(a)},disableEffect:function(){this._labelRenderer.disableEffect&&this._labelRenderer.disableEffect()},_createCloneInstance:function(){return new ccui.Text},_copySpecialProperties:function(a){a instanceof ccui.Text&&(this.setFontName(a._fontName),
this.setFontSize(a.getFontSize()),this.setString(a.getString()),this.setTouchScaleChangeEnabled(a.touchScaleEnabled),this.setTextAreaSize(a._textAreaSize),this.setTextHorizontalAlignment(a._labelRenderer.getHorizontalAlignment()),this.setTextVerticalAlignment(a._labelRenderer.getVerticalAlignment()),this.setContentSize(a.getContentSize()))},_setBoundingWidth:function(a){this._textAreaSize.width=a;this._labelRenderer._setBoundingWidth(a);this._labelScaleChangedWithSize()},_setBoundingHeight:function(a){this._textAreaSize.height=
a;this._labelRenderer._setBoundingHeight(a);this._labelScaleChangedWithSize()},_getBoundingWidth:function(){return this._textAreaSize.width},_getBoundingHeight:function(){return this._textAreaSize.height},_changePosition:function(){this._adaptRenderers()},setColor:function(a){cc.ProtectedNode.prototype.setColor.call(this,a);this._labelRenderer.setColor(a)},setTextColor:function(a){this._labelRenderer.setFontFillColor(a)},getTextColor:function(){return this._labelRenderer._getFillStyle()}});_p=ccui.Text.prototype;
_p.boundingWidth;cc.defineGetterSetter(_p,"boundingWidth",_p._getBoundingWidth,_p._setBoundingWidth);_p.boundingHeight;cc.defineGetterSetter(_p,"boundingHeight",_p._getBoundingHeight,_p._setBoundingHeight);_p.string;cc.defineGetterSetter(_p,"string",_p.getString,_p.setString);_p.stringLength;cc.defineGetterSetter(_p,"stringLength",_p.getStringLength);_p.font;cc.defineGetterSetter(_p,"font",_p._getFont,_p._setFont);_p.fontSize;cc.defineGetterSetter(_p,"fontSize",_p.getFontSize,_p.setFontSize);_p.fontName;
cc.defineGetterSetter(_p,"fontName",_p.getFontName,_p.setFontName);_p.textAlign;cc.defineGetterSetter(_p,"textAlign",_p.getTextHorizontalAlignment,_p.setTextHorizontalAlignment);_p.verticalAlign;cc.defineGetterSetter(_p,"verticalAlign",_p.getTextVerticalAlignment,_p.setTextVerticalAlignment);_p=null;ccui.Label=ccui.Text.create=function(a,b,c){return new ccui.Text(a,b,c)};ccui.Text.RENDERER_ZORDER=-1;ccui.Text.Type={SYSTEM:0,TTF:1};
ccui.TextAtlas=ccui.Widget.extend({_labelAtlasRenderer:null,_stringValue:"",_charMapFileName:"",_itemWidth:0,_itemHeight:0,_startCharMap:"",_className:"TextAtlas",_labelAtlasRendererAdaptDirty:null,ctor:function(a,b,c,d,e){ccui.Widget.prototype.ctor.call(this);void 0!==e&&this.setProperty(a,b,c,d,e)},_initRenderer:function(){this._labelAtlasRenderer=new cc.LabelAtlas;this._labelAtlasRenderer.setAnchorPoint(cc.p(0.5,0.5));this.addProtectedChild(this._labelAtlasRenderer,ccui.TextAtlas.RENDERER_ZORDER,
-1)},setProperty:function(a,b,c,d,e){this._stringValue=a;this._charMapFileName=b;this._itemWidth=c;this._itemHeight=d;this._startCharMap=e;this._labelAtlasRenderer.initWithString(a,this._charMapFileName,this._itemWidth,this._itemHeight,this._startCharMap[0]);this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize());this._labelAtlasRendererAdaptDirty=!0},setString:function(a){a!==this._labelAtlasRenderer.getString()&&(this._stringValue=a,this._labelAtlasRenderer.setString(a),
this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize()),this._labelAtlasRendererAdaptDirty=!0)},setStringValue:function(a){cc.log("Please use the setString");this.setString(a)},getStringValue:function(){return cc.log("Please use the getString"),this.getString()},getString:function(){return this._labelAtlasRenderer.getString()},getStringLength:function(){return this._labelAtlasRenderer.getStringLength()},_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this);
this._labelAtlasRendererAdaptDirty=!0},_adaptRenderers:function(){this._labelAtlasRendererAdaptDirty&&(this._labelAtlasScaleChangedWithSize(),this._labelAtlasRendererAdaptDirty=!1)},getVirtualRendererSize:function(){return this._labelAtlasRenderer.getContentSize()},getVirtualRenderer:function(){return this._labelAtlasRenderer},_labelAtlasScaleChangedWithSize:function(){var a=this._labelAtlasRenderer;if(this._ignoreSize)a.setScale(1);else{var b=a.getContentSize();if(0>=b.width||0>=b.height)return void a.setScale(1);
a.setScaleX(this._contentSize.width/b.width);a.setScaleY(this._contentSize.height/b.height)}a.setPosition(this._contentSize.width/2,this._contentSize.height/2)},getDescription:function(){return"LabelAtlas"},_copySpecialProperties:function(a){a&&this.setProperty(a._stringValue,a._charMapFileName,a._itemWidth,a._itemHeight,a._startCharMap)},_createCloneInstance:function(){return new ccui.TextAtlas}});_p=ccui.TextAtlas.prototype;_p.string;cc.defineGetterSetter(_p,"string",_p.getString,_p.setString);
_p=null;ccui.TextAtlas.create=function(a,b,c,d,e){return new ccui.TextAtlas(a,b,c,d,e)};ccui.TextAtlas.RENDERER_ZORDER=-1;
ccui.LabelBMFont=ccui.TextBMFont=ccui.Widget.extend({_labelBMFontRenderer:null,_fntFileHasInit:!1,_fntFileName:"",_stringValue:"",_className:"TextBMFont",_labelBMFontRendererAdaptDirty:!0,ctor:function(a,b){ccui.Widget.prototype.ctor.call(this);void 0!=b&&(this.setFntFile(b),this.setString(a))},_initRenderer:function(){this._labelBMFontRenderer=new cc.LabelBMFont;this.addProtectedChild(this._labelBMFontRenderer,ccui.TextBMFont.RENDERER_ZORDER,-1)},setFntFile:function(a){if(a){this._fntFileName=a;
this._fntFileHasInit=!0;this._labelBMFontRenderer.initWithString(this._stringValue,a);this._updateContentSizeWithTextureSize(this._labelBMFontRenderer.getContentSize());this._labelBMFontRendererAdaptDirty=!0;var b=this;a=b._labelBMFontRenderer;a._textureLoaded||a.addEventListener("load",function(){b.setFntFile(b._fntFileName)})}},setText:function(a){cc.log("Please use the setString");this.setString(a)},setString:function(a){a!==this._labelBMFontRenderer.getString()&&(this._stringValue=a,this._labelBMFontRenderer.setString(a),
this._fntFileHasInit&&(this._updateContentSizeWithTextureSize(this._labelBMFontRenderer.getContentSize()),this._labelBMFontRendererAdaptDirty=!0))},getString:function(){return this._stringValue},getStringLength:function(){return this._labelBMFontRenderer.getStringLength()},_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this);this._labelBMFontRendererAdaptDirty=!0},_adaptRenderers:function(){this._labelBMFontRendererAdaptDirty&&(this._labelBMFontScaleChangedWithSize(),this._labelBMFontRendererAdaptDirty=
!1)},getVirtualRendererSize:function(){return this._labelBMFontRenderer.getContentSize()},getVirtualRenderer:function(){return this._labelBMFontRenderer},_labelBMFontScaleChangedWithSize:function(){var a=this._labelBMFontRenderer;if(this._ignoreSize)a.setScale(1);else{var b=a.getContentSize();if(0>=b.width||0>=b.height)return void a.setScale(1);a.setScaleX(this._contentSize.width/b.width);a.setScaleY(this._contentSize.height/b.height)}a.setPosition(this._contentSize.width/2,this._contentSize.height/
2)},getDescription:function(){return"TextBMFont"},_createCloneInstance:function(){return new ccui.TextBMFont},_copySpecialProperties:function(a){this.setFntFile(a._fntFileName);this.setString(a._stringValue)}});_p=ccui.TextBMFont.prototype;_p.string;cc.defineGetterSetter(_p,"string",_p.getString,_p.setString);_p=null;ccui.TextBMFont.create=function(a,b){return new ccui.TextBMFont(a,b)};ccui.TextBMFont.RENDERER_ZORDER=-1;
ccui._TextFieldRenderer=cc.TextFieldTTF.extend({_maxLengthEnabled:!1,_maxLength:0,_passwordEnabled:!1,_passwordStyleText:"",_attachWithIME:!1,_detachWithIME:!1,_insertText:!1,_deleteBackward:!1,_className:"_TextFieldRenderer",ctor:function(){cc.TextFieldTTF.prototype.ctor.call(this);this._maxLengthEnabled=!1;this._maxLength=0;this._passwordEnabled=!1;this._passwordStyleText="*";this._deleteBackward=this._insertText=this._detachWithIME=this._attachWithIME=!1},onEnter:function(){cc.TextFieldTTF.prototype.onEnter.call(this);
cc.TextFieldTTF.prototype.setDelegate.call(this,this)},onTextFieldAttachWithIME:function(a){return this.setAttachWithIME(!0),!1},onTextFieldInsertText:function(a,b,c){return 1===c&&"\n"===b?!1:(this.setInsertText(!0),this._maxLengthEnabled&&cc.TextFieldTTF.prototype.getCharCount.call(this)>=this._maxLength)},onTextFieldDeleteBackward:function(a,b,c){return this.setDeleteBackward(!0),!1},onTextFieldDetachWithIME:function(a){return this.setDetachWithIME(!0),!1},insertText:function(a,b){if("\n"!==a&&
this._maxLengthEnabled&&this.getString().length>=this._maxLength)return void(this._passwordEnabled&&this.setPasswordText(this.getString()));cc.TextFieldTTF.prototype.insertText.call(this,a,b);this._passwordEnabled&&0<cc.TextFieldTTF.prototype.getCharCount.call(this)&&this.setPasswordText(this.getString())},deleteBackward:function(){cc.TextFieldTTF.prototype.deleteBackward.call(this);0<cc.TextFieldTTF.prototype.getCharCount.call(this)&&this._passwordEnabled&&this.setPasswordText(this._inputText)},
openIME:function(){cc.TextFieldTTF.prototype.attachWithIME.call(this)},closeIME:function(){cc.TextFieldTTF.prototype.detachWithIME.call(this)},setMaxLengthEnabled:function(a){this._maxLengthEnabled=a},isMaxLengthEnabled:function(){return this._maxLengthEnabled},setMaxLength:function(a){this._maxLength=a},getMaxLength:function(){return this._maxLength},getCharCount:function(){return cc.TextFieldTTF.prototype.getCharCount.call(this)},setPasswordEnabled:function(a){this._passwordEnabled=a},isPasswordEnabled:function(){return this._passwordEnabled},
setPasswordStyleText:function(a){if(!(1<a.length)){var b=a.charCodeAt(0);33>b||126<b||(this._passwordStyleText=a)}},setPasswordText:function(a){var b="",c=a.length;a=c;this._maxLengthEnabled&&c>this._maxLength&&(a=this._maxLength);for(c=0;a>c;++c)b+=this._passwordStyleText;cc.LabelTTF.prototype.setString.call(this,b)},setAttachWithIME:function(a){this._attachWithIME=a},getAttachWithIME:function(){return this._attachWithIME},setDetachWithIME:function(a){this._detachWithIME=a},getDetachWithIME:function(){return this._detachWithIME},
setInsertText:function(a){this._insertText=a},getInsertText:function(){return this._insertText},setDeleteBackward:function(a){this._deleteBackward=a},getDeleteBackward:function(){return this._deleteBackward},onDraw:function(a){return!1}});ccui._TextFieldRenderer.create=function(a,b,c){var d=new ccui._TextFieldRenderer;return d&&d.initWithString("",b,c)?(a&&d.setPlaceHolder(a),d):null};
ccui.TextField=ccui.Widget.extend({_textFieldRenderer:null,_touchWidth:0,_touchHeight:0,_useTouchArea:!1,_textFieldEventListener:null,_textFieldEventSelector:null,_passwordStyleText:"",_textFieldRendererAdaptDirty:!0,_fontName:"",_fontSize:12,_ccEventCallback:null,ctor:function(a,b,c){ccui.Widget.prototype.ctor.call(this);b&&this.setFontName(b);c&&this.setFontSize(c);a&&this.setPlaceHolder(a)},init:function(){return ccui.Widget.prototype.init.call(this)?(this.setTouchEnabled(!0),!0):!1},onEnter:function(){ccui.Widget.prototype.onEnter.call(this);
this.scheduleUpdate()},_initRenderer:function(){this._textFieldRenderer=ccui._TextFieldRenderer.create("input words here","Thonburi",20);this.addProtectedChild(this._textFieldRenderer,ccui.TextField.RENDERER_ZORDER,-1)},setTouchSize:function(a){this._touchWidth=a.width;this._touchHeight=a.height},setTouchAreaEnabled:function(a){this._useTouchArea=a},hitTest:function(a){if(this._useTouchArea){a=this.convertToNodeSpace(a);var b=cc.rect(-this._touchWidth*this._anchorPoint.x,-this._touchHeight*this._anchorPoint.y,
this._touchWidth,this._touchHeight);return a.x>=b.x&&a.x<=b.x+b.width&&a.y>=b.y&&a.y<=b.y+b.height}return ccui.Widget.prototype.hitTest.call(this,a)},getTouchSize:function(){return cc.size(this._touchWidth,this._touchHeight)},setText:function(a){cc.log("Please use the setString");this.setString(a)},setString:function(a){null!=a&&(a=String(a),this.isMaxLengthEnabled()&&(a=a.substr(0,this.getMaxLength())),this.isPasswordEnabled()?(this._textFieldRenderer.setPasswordText(a),this._textFieldRenderer.setString(""),
this._textFieldRenderer.insertText(a,a.length)):this._textFieldRenderer.setString(a),this._textFieldRendererAdaptDirty=!0,this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize()))},setPlaceHolder:function(a){this._textFieldRenderer.setPlaceHolder(a);this._textFieldRendererAdaptDirty=!0;this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize())},getPlaceHolder:function(){return this._textFieldRenderer.getPlaceHolder()},getPlaceHolderColor:function(){return this._textFieldRenderer.getPlaceHolderColor()},
setPlaceHolderColor:function(a){this._textFieldRenderer.setColorSpaceHolder(a)},setTextColor:function(a){this._textFieldRenderer.setTextColor(a)},setFontSize:function(a){this._textFieldRenderer.setFontSize(a);this._fontSize=a;this._textFieldRendererAdaptDirty=!0;this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize())},getFontSize:function(){return this._fontSize},setFontName:function(a){this._textFieldRenderer.setFontName(a);this._fontName=a;this._textFieldRendererAdaptDirty=
!0;this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize())},getFontName:function(){return this._fontName},didNotSelectSelf:function(){this._textFieldRenderer.detachWithIME()},getStringValue:function(){return cc.log("Please use the getString"),this.getString()},getString:function(){return this._textFieldRenderer.getString()},getStringLength:function(){return this._textFieldRenderer.getStringLength()},onTouchBegan:function(a,b){var c=this,d=ccui.Widget.prototype.onTouchBegan.call(c,
a,b);return c._hit?setTimeout(function(){c._textFieldRenderer.attachWithIME()},0):setTimeout(function(){c._textFieldRenderer.detachWithIME()},0),d},setMaxLengthEnabled:function(a){this._textFieldRenderer.setMaxLengthEnabled(a)},isMaxLengthEnabled:function(){return this._textFieldRenderer.isMaxLengthEnabled()},setMaxLength:function(a){this._textFieldRenderer.setMaxLength(a);this.setString(this.getString())},getMaxLength:function(){return this._textFieldRenderer.getMaxLength()},setPasswordEnabled:function(a){this._textFieldRenderer.setPasswordEnabled(a)},
isPasswordEnabled:function(){return this._textFieldRenderer.isPasswordEnabled()},setPasswordStyleText:function(a){this._textFieldRenderer.setPasswordStyleText(a);this._passwordStyleText=a;this.setString(this.getString())},getPasswordStyleText:function(){return this._passwordStyleText},update:function(a){this.getDetachWithIME()&&(this._detachWithIMEEvent(),this.setDetachWithIME(!1));this.getAttachWithIME()&&(this._attachWithIMEEvent(),this.setAttachWithIME(!1));this.getInsertText()&&(this._textFieldRendererAdaptDirty=
!0,this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize()),this._insertTextEvent(),this.setInsertText(!1));this.getDeleteBackward()&&(this._textFieldRendererAdaptDirty=!0,this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize()),this._deleteBackwardEvent(),this.setDeleteBackward(!1))},getAttachWithIME:function(){return this._textFieldRenderer.getAttachWithIME()},setAttachWithIME:function(a){this._textFieldRenderer.setAttachWithIME(a)},getDetachWithIME:function(){return this._textFieldRenderer.getDetachWithIME()},
setDetachWithIME:function(a){this._textFieldRenderer.setDetachWithIME(a)},getInsertText:function(){return this._textFieldRenderer.getInsertText()},setInsertText:function(a){this._textFieldRenderer.setInsertText(a)},getDeleteBackward:function(){return this._textFieldRenderer.getDeleteBackward()},setDeleteBackward:function(a){this._textFieldRenderer.setDeleteBackward(a)},_attachWithIMEEvent:function(){this._textFieldEventSelector&&(this._textFieldEventListener?this._textFieldEventSelector.call(this._textFieldEventListener,
this,ccui.TextField.EVENT_ATTACH_WITH_IME):this._textFieldEventSelector(this,ccui.TextField.EVENT_ATTACH_WITH_IME));this._ccEventCallback&&this._ccEventCallback(this,ccui.TextField.EVENT_ATTACH_WITH_IME)},_detachWithIMEEvent:function(){this._textFieldEventSelector&&(this._textFieldEventListener?this._textFieldEventSelector.call(this._textFieldEventListener,this,ccui.TextField.EVENT_DETACH_WITH_IME):this._textFieldEventSelector(this,ccui.TextField.EVENT_DETACH_WITH_IME));this._ccEventCallback&&this._ccEventCallback(this,
ccui.TextField.EVENT_DETACH_WITH_IME)},_insertTextEvent:function(){this._textFieldEventSelector&&(this._textFieldEventListener?this._textFieldEventSelector.call(this._textFieldEventListener,this,ccui.TextField.EVENT_INSERT_TEXT):this._textFieldEventSelector(this,ccui.TextField.EVENT_INSERT_TEXT));this._ccEventCallback&&this._ccEventCallback(this,ccui.TextField.EVENT_INSERT_TEXT)},_deleteBackwardEvent:function(){this._textFieldEventSelector&&(this._textFieldEventListener?this._textFieldEventSelector.call(this._textFieldEventListener,
this,ccui.TextField.EVENT_DELETE_BACKWARD):this._textFieldEventSelector(this,ccui.TextField.EVENT_DELETE_BACKWARD));this._ccEventCallback&&this._ccEventCallback(this,ccui.TextField.EVENT_DELETE_BACKWARD)},addEventListenerTextField:function(a,b){this.addEventListener(a,b)},addEventListener:function(a,b){this._textFieldEventSelector=a;this._textFieldEventListener=b},_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this);this._textFieldRendererAdaptDirty=!0},_adaptRenderers:function(){this._textFieldRendererAdaptDirty&&
(this._textfieldRendererScaleChangedWithSize(),this._textFieldRendererAdaptDirty=!1)},_textfieldRendererScaleChangedWithSize:function(){this._ignoreSize||this._textFieldRenderer.setDimensions(this._contentSize);this._textFieldRenderer.setPosition(this._contentSize.width/2,this._contentSize.height/2)},getAutoRenderSize:function(){var a=this._textFieldRenderer.getContentSize();return this._ignoreSize||(this._textFieldRenderer.setDimensions(0,0),a=this._textFieldRenderer.getContentSize(),this._textFieldRenderer.setDimensions(this._contentSize.width,
this._contentSize.height)),a},getVirtualRendererSize:function(){return this._textFieldRenderer.getContentSize()},getVirtualRenderer:function(){return this._textFieldRenderer},getDescription:function(){return"TextField"},attachWithIME:function(){this._textFieldRenderer.attachWithIME()},_createCloneInstance:function(){return new ccui.TextField},_copySpecialProperties:function(a){this.setString(a._textFieldRenderer.getString());this.setPlaceHolder(a.getString());this.setFontSize(a._textFieldRenderer.getFontSize());
this.setFontName(a._textFieldRenderer.getFontName());this.setMaxLengthEnabled(a.isMaxLengthEnabled());this.setMaxLength(a.getMaxLength());this.setPasswordEnabled(a.isPasswordEnabled());this.setPasswordStyleText(a._passwordStyleText);this.setAttachWithIME(a.getAttachWithIME());this.setDetachWithIME(a.getDetachWithIME());this.setInsertText(a.getInsertText());this.setDeleteBackward(a.getDeleteBackward());this._ccEventCallback=a._ccEventCallback;this._textFieldEventListener=a._textFieldEventListener;
this._textFieldEventSelector=a._textFieldEventSelector},setTextAreaSize:function(a){this.setContentSize(a)},setTextHorizontalAlignment:function(a){this._textFieldRenderer.setHorizontalAlignment(a)},setTextVerticalAlignment:function(a){this._textFieldRenderer.setVerticalAlignment(a)},_setFont:function(a){this._textFieldRenderer._setFont(a);this._textFieldRendererAdaptDirty=!0},_getFont:function(){return this._textFieldRenderer._getFont()},_changePosition:function(){this._adaptRenderers()}});
ccui.TextField.create=function(a,b,c){return new ccui.TextField(a,b,c)};_p=ccui.TextField.prototype;_p.string;cc.defineGetterSetter(_p,"string",_p.getString,_p.setString);_p.placeHolder;cc.defineGetterSetter(_p,"placeHolder",_p.getPlaceHolder,_p.setPlaceHolder);_p.font;cc.defineGetterSetter(_p,"font",_p._getFont,_p._setFont);_p.fontSize;cc.defineGetterSetter(_p,"fontSize",_p.getFontSize,_p.setFontSize);_p.fontName;cc.defineGetterSetter(_p,"fontName",_p.getFontName,_p.setFontName);_p.maxLengthEnabled;
cc.defineGetterSetter(_p,"maxLengthEnabled",_p.isMaxLengthEnabled,_p.setMaxLengthEnabled);_p.maxLength;cc.defineGetterSetter(_p,"maxLength",_p.getMaxLength,_p.setMaxLength);_p.passwordEnabled;cc.defineGetterSetter(_p,"passwordEnabled",_p.isPasswordEnabled,_p.setPasswordEnabled);_p=null;ccui.TextField.EVENT_ATTACH_WITH_IME=0;ccui.TextField.EVENT_DETACH_WITH_IME=1;ccui.TextField.EVENT_INSERT_TEXT=2;ccui.TextField.EVENT_DELETE_BACKWARD=3;ccui.TextField.RENDERER_ZORDER=-1;
ccui.RichElement=ccui.Class.extend({_type:0,_tag:0,_color:null,_opacity:0,ctor:function(){this._tag=this._type=0;this._color=cc.color(255,255,255,255)},init:function(a,b,c){this._tag=a;this._color.r=b.r;this._color.g=b.g;this._color.b=b.b;this._opacity=c;void 0===c?this._color.a=b.a:this._color.a=c}});
ccui.RichElementText=ccui.RichElement.extend({_text:"",_fontName:"",_fontSize:0,_fontDefinition:null,ctor:function(a,b,c,d,e,f){ccui.RichElement.prototype.ctor.call(this);this._type=ccui.RichElement.TEXT;this._fontName=this._text="";this._fontSize=0;b&&b instanceof cc.FontDefinition?this.initWithStringAndTextDefinition(a,d,b,c):f&&this.init(a,b,c,d,e,f)},init:function(a,b,c,d,e,f){ccui.RichElement.prototype.init.call(this,a,b,c);this._text=d;this._fontName=e;this._fontSize=f},initWithStringAndTextDefinition:function(a,
b,c,d){ccui.RichElement.prototype.init.call(this,a,c.fillStyle,d);this._fontDefinition=c;this._text=b;this._fontName=c.fontName;this._fontSize=c.fontSize}});ccui.RichElementText.create=function(a,b,c,d,e,f){return new ccui.RichElementText(a,b,c,d,e,f)};
ccui.RichElementImage=ccui.RichElement.extend({_filePath:"",_textureRect:null,_textureType:0,ctor:function(a,b,c,d){ccui.RichElement.prototype.ctor.call(this);this._type=ccui.RichElement.IMAGE;this._filePath="";this._textureRect=cc.rect(0,0,0,0);this._textureType=0;void 0!==d&&this.init(a,b,c,d)},init:function(a,b,c,d){ccui.RichElement.prototype.init.call(this,a,b,c);this._filePath=d}});ccui.RichElementImage.create=function(a,b,c,d){return new ccui.RichElementImage(a,b,c,d)};
ccui.RichElementCustomNode=ccui.RichElement.extend({_customNode:null,ctor:function(a,b,c,d){ccui.RichElement.prototype.ctor.call(this);this._type=ccui.RichElement.CUSTOM;this._customNode=null;void 0!==d&&this.init(a,b,c,d)},init:function(a,b,c,d){ccui.RichElement.prototype.init.call(this,a,b,c);this._customNode=d}});ccui.RichElementCustomNode.create=function(a,b,c,d){return new ccui.RichElementCustomNode(a,b,c,d)};
ccui.RichText=ccui.Widget.extend({_formatTextDirty:!1,_richElements:null,_elementRenders:null,_leftSpaceWidth:0,_verticalSpace:0,_elementRenderersContainer:null,_lineBreakOnSpace:!1,_textHorizontalAlignment:null,_textVerticalAlignment:null,ctor:function(){ccui.Widget.prototype.ctor.call(this);this._formatTextDirty=!1;this._richElements=[];this._elementRenders=[];this._verticalSpace=this._leftSpaceWidth=0;this._textHorizontalAlignment=cc.TEXT_ALIGNMENT_LEFT;this._textVerticalAlignment=cc.VERTICAL_TEXT_ALIGNMENT_TOP},
_initRenderer:function(){this._elementRenderersContainer=new cc.Node;this._elementRenderersContainer.setAnchorPoint(0.5,0.5);this.addProtectedChild(this._elementRenderersContainer,0,-1)},insertElement:function(a,b){this._richElements.splice(b,0,a);this._formatTextDirty=!0},pushBackElement:function(a){this._richElements.push(a);this._formatTextDirty=!0},removeElement:function(a){cc.isNumber(a)?this._richElements.splice(a,1):cc.arrayRemoveObject(this._richElements,a);this._formatTextDirty=!0},formatText:function(){if(this._formatTextDirty){this._elementRenderersContainer.removeAllChildren();
this._elementRenders.length=0;var a,b,c=this._richElements;if(this._ignoreSize){this._addNewLine();for(a=0;a<c.length;a++){b=c[a];var d=null;switch(b._type){case ccui.RichElement.TEXT:d=b._fontDefinition?new cc.LabelTTF(b._text,b._fontDefinition):new cc.LabelTTF(b._text,b._fontName,b._fontSize);break;case ccui.RichElement.IMAGE:d=new cc.Sprite(b._filePath);break;case ccui.RichElement.CUSTOM:d=b._customNode}d.setColor(b._color);d.setOpacity(b._color.a);this._pushToContainer(d)}}else{this._addNewLine();
for(a=0;a<c.length;a++)switch(b=c[a],b._type){case ccui.RichElement.TEXT:b._fontDefinition?this._handleTextRenderer(b._text,b._fontDefinition,b._fontDefinition.fontSize,b._fontDefinition.fillStyle):this._handleTextRenderer(b._text,b._fontName,b._fontSize,b._color);break;case ccui.RichElement.IMAGE:this._handleImageRenderer(b._filePath,b._color,b._color.a);break;case ccui.RichElement.CUSTOM:this._handleCustomRenderer(b._customNode)}}this.formatRenderers();this._formatTextDirty=!1}},_handleTextRenderer:function(a,
b,c,d){if(""!==a){if("\n"===a)return void this._addNewLine();var e=b instanceof cc.FontDefinition?new cc.LabelTTF(a,b):new cc.LabelTTF(a,b,c),f=e.getContentSize().width;if(this._leftSpaceWidth-=f,0>this._leftSpaceWidth){var e=a.length*(1- -this._leftSpaceWidth/f),f=a.substr(0,e),g=a.substr(e,a.length-1),h=0<e;this._lineBreakOnSpace&&(g=f.lastIndexOf(" "),e=-1===g?e:g+1,g=a.substr(e,a.length-1),h=0<e&&" "!==g);h&&(a=null,b instanceof cc.FontDefinition?(a=new cc.LabelTTF(f.substr(0,e),b),a.setOpacity(b.fillStyle.a)):
(a=new cc.LabelTTF(f.substr(0,e),b,c),a.setColor(d),a.setOpacity(d.a)),this._pushToContainer(a));this._addNewLine();this._handleTextRenderer(g,b,c,d)}else b instanceof cc.FontDefinition?e.setOpacity(b.fillStyle.a):(e.setColor(d),e.setOpacity(d.a)),this._pushToContainer(e)}},_handleImageRenderer:function(a,b,c){a=new cc.Sprite(a);this._handleCustomRenderer(a)},_handleCustomRenderer:function(a){var b=a.getContentSize();this._leftSpaceWidth-=b.width;0>this._leftSpaceWidth?(this._addNewLine(),this._pushToContainer(a),
this._leftSpaceWidth-=b.width):this._pushToContainer(a)},_addNewLine:function(){this._leftSpaceWidth=this._customSize.width;this._elementRenders.push([])},formatRenderers:function(){var a,b,c,d,e,f=0,g=this._elementRenderersContainer,h=this._elementRenders;if(this._ignoreSize){a=0;c=h[0];for(b=d=0;b<c.length;b++){e=c[b];e.setAnchorPoint(cc.p(0,0));e.setPosition(d,0);g.addChild(e,1,b);var k=e.getLineHeight?e.getLineHeight():f;e=e.getContentSize();a+=e.width;f=Math.max(Math.min(f,k),e.height);d+=e.width}if(this._textHorizontalAlignment!==
cc.TEXT_ALIGNMENT_LEFT){k=0;this._textHorizontalAlignment===cc.TEXT_ALIGNMENT_RIGHT?k=this._contentSize.width-d:this._textHorizontalAlignment===cc.TEXT_ALIGNMENT_CENTER&&(k=(this._contentSize.width-d)/2);for(b=0;b<c.length;b++)c[b].x+=k}g.setContentSize(a,f)}else{var m=[];for(a=0;a<h.length;a++){c=h[a];for(b=d=0;b<c.length;b++)e=c[b],k=e.getLineHeight?e.getLineHeight():e.getContentSize().height,cc.log(k),d=Math.max(Math.min(e.getContentSize().height,k),d);m[a]=d;f+=m[a]}var n=this._customSize.height;
for(a=0;a<h.length;a++){c=h[a];d=0;n-=m[a]+this._verticalSpace;for(b=0;b<c.length;b++)e=c[b],e.setAnchorPoint(cc.p(0,0)),e.setPosition(cc.p(d,n)),g.addChild(e,1),d+=e.getContentSize().width;if(this._textHorizontalAlignment!==cc.TEXT_ALIGNMENT_LEFT||this._textVerticalAlignment!==cc.VERTICAL_TEXT_ALIGNMENT_TOP){k=0;this._textHorizontalAlignment===cc.TEXT_ALIGNMENT_RIGHT?k=this._contentSize.width-d:this._textHorizontalAlignment===cc.TEXT_ALIGNMENT_CENTER&&(k=(this._contentSize.width-d)/2);d=0;this._textVerticalAlignment===
cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM?d=this._customSize.height-f:this._textVerticalAlignment===cc.VERTICAL_TEXT_ALIGNMENT_CENTER&&(d=(this._customSize.height-f)/2);for(b=0;b<c.length;b++)e=c[b],e.x+=k,e.y-=d}}g.setContentSize(this._contentSize)}b=h.length;for(a=0;b>a;a++)h[a].length=0;this._elementRenders.length=0;this.setContentSize(this._ignoreSize?this.getVirtualRendererSize():this._customSize);this._updateContentSizeWithTextureSize(this._contentSize);g.setPosition(0.5*this._contentSize.width,0.5*
this._contentSize.height)},_pushToContainer:function(a){0>=this._elementRenders.length||this._elementRenders[this._elementRenders.length-1].push(a)},_adaptRenderers:function(){this.formatText()},setVerticalSpace:function(a){this._verticalSpace=a},setAnchorPoint:function(a){ccui.Widget.prototype.setAnchorPoint.call(this,a);this._elementRenderersContainer.setAnchorPoint(a)},_setAnchorX:function(a){ccui.Widget.prototype._setAnchorX.call(this,a);this._elementRenderersContainer._setAnchorX(a)},_setAnchorY:function(a){ccui.Widget.prototype._setAnchorY.call(this,
a);this._elementRenderersContainer._setAnchorY(a)},getVirtualRendererSize:function(){return this._elementRenderersContainer.getContentSize()},ignoreContentAdaptWithSize:function(a){this._ignoreSize!==a&&(this._formatTextDirty=!0,ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this,a))},getContentSize:function(){return this.formatText(),cc.Node.prototype.getContentSize.call(this)},_getWidth:function(){return this.formatText(),cc.Node.prototype._getWidth.call(this)},_getHeight:function(){return this.formatText(),
cc.Node.prototype._getHeight.call(this)},setContentSize:function(a,b){ccui.Widget.prototype.setContentSize.call(this,void 0===b?a.width:a,void 0===b?a.height:b);this._formatTextDirty=!0},getDescription:function(){return"RichText"},setCascadeOpacityEnabled:function(a){this._super(a);this._elementRenderersContainer.setCascadeOpacityEnabled(a)},setLineBreakOnSpace:function(a){this._lineBreakOnSpace=a;this._formatTextDirty=!0;this.formatText()},setTextHorizontalAlignment:function(a){a!==this._textHorizontalAlignment&&
(this._textHorizontalAlignment=a,this.formatText())},setTextVerticalAlignment:function(a){a!==this._textVerticalAlignment&&(this._textVerticalAlignment=a,this.formatText())}});ccui.RichText.create=function(){return new ccui.RichText};ccui.RichElement.TEXT=0;ccui.RichElement.IMAGE=1;ccui.RichElement.CUSTOM=2;
ccui.ScrollView=ccui.Layout.extend({_innerContainer:null,direction:null,_autoScrollDir:null,_topBoundary:0,_bottomBoundary:0,_leftBoundary:0,_rightBoundary:0,_bounceTopBoundary:0,_bounceBottomBoundary:0,_bounceLeftBoundary:0,_bounceRightBoundary:0,_autoScroll:!1,_autoScrollAddUpTime:0,_autoScrollOriginalSpeed:0,_autoScrollAcceleration:0,_isAutoScrollSpeedAttenuated:!1,_needCheckAutoScrollDestination:!1,_autoScrollDestination:null,_bePressed:!1,_slidTime:0,_moveChildPoint:null,_childFocusCancelOffset:0,
_leftBounceNeeded:!1,_topBounceNeeded:!1,_rightBounceNeeded:!1,_bottomBounceNeeded:!1,bounceEnabled:!1,_bouncing:!1,_bounceDir:null,_bounceOriginalSpeed:0,inertiaScrollEnabled:!1,_scrollViewEventListener:null,_scrollViewEventSelector:null,_className:"ScrollView",ctor:function(){ccui.Layout.prototype.ctor.call(this);this.direction=ccui.ScrollView.DIR_NONE;this._autoScrollDir=cc.p(0,0);this._autoScrollAcceleration=-1E3;this._autoScrollDestination=cc.p(0,0);this._slidTime=0;this._moveChildPoint=cc.p(0,
0);this._childFocusCancelOffset=5;this._bounceDir=cc.p(0,0);this._bounceOriginalSpeed=0;this.inertiaScrollEnabled=!0;this.setTouchEnabled(!0)},init:function(){return ccui.Layout.prototype.init.call(this)?(this.setClippingEnabled(!0),this._innerContainer.setTouchEnabled(!1),!0):!1},onEnter:function(){ccui.Layout.prototype.onEnter.call(this);this.scheduleUpdate(!0)},findNextFocusedWidget:function(a,b){return this.getLayoutType()===ccui.Layout.LINEAR_VERTICAL||this.getLayoutType()===ccui.Layout.LINEAR_HORIZONTAL?
this._innerContainer.findNextFocusedWidget(a,b):ccui.Widget.prototype.findNextFocusedWidget.call(this,a,b)},_initRenderer:function(){ccui.Layout.prototype._initRenderer.call(this);this._innerContainer=new ccui.Layout;this._innerContainer.setColor(cc.color(255,255,255));this._innerContainer.setOpacity(255);this._innerContainer.setCascadeColorEnabled(!0);this._innerContainer.setCascadeOpacityEnabled(!0);this.addProtectedChild(this._innerContainer,1,1)},_onSizeChanged:function(){ccui.Layout.prototype._onSizeChanged.call(this);
var a=this._contentSize;this._topBoundary=a.height;this._rightBoundary=a.width;var b=a.width/3,c=a.height/3;this._bounceTopBoundary=a.height-c;this._bounceBottomBoundary=c;this._bounceLeftBoundary=b;this._bounceRightBoundary=a.width-b;b=this._innerContainer.getContentSize();this._innerContainer.setContentSize(cc.size(Math.max(b.width,a.width),Math.max(b.height,a.height)));this._innerContainer.setPosition(0,a.height-this._innerContainer.getContentSize().height)},setInnerContainerSize:function(a){var b=
this._innerContainer,c=this._contentSize,d=c.width,e=c.height,f=b.getContentSize();a.width<c.width?cc.log("Inner width \x3c\x3d ScrollView width, it will be force sized!"):d=a.width;a.height<c.height?cc.log("Inner height \x3c\x3d ScrollView height, it will be force sized!"):e=a.height;b.setContentSize(cc.size(d,e));var g,h;switch(this.direction){case ccui.ScrollView.DIR_VERTICAL:g=b.getContentSize();h=f.height-g.height;this._scrollChildren(0,h);break;case ccui.ScrollView.DIR_HORIZONTAL:b.getRightBoundary()<=
c.width&&(g=b.getContentSize(),h=f.width-g.width,this._scrollChildren(h,0));break;case ccui.ScrollView.DIR_BOTH:g=b.getContentSize(),a=f.height-g.height,f=b.getRightBoundary()<=c.width?f.width-g.width:0,this._scrollChildren(f,a)}f=b.getContentSize();g=b.getPosition();a=b.getAnchorPoint();0<b.getLeftBoundary()&&b.setPosition(a.x*f.width,g.y);b.getRightBoundary()<c.width&&b.setPosition(c.width-(1-a.x)*f.width,g.y);0<g.y&&b.setPosition(g.x,a.y*f.height);b.getTopBoundary()<c.height&&b.setPosition(g.x,
c.height-(1-a.y)*f.height)},_setInnerWidth:function(a){var b=this._contentSize.width,c=b,d=this._innerContainer,e=d.width;switch(b>a?cc.log("Inner width \x3c\x3d scrollview width, it will be force sized!"):c=a,d.width=c,this.direction){case ccui.ScrollView.DIR_HORIZONTAL:case ccui.ScrollView.DIR_BOTH:d.getRightBoundary()<=b&&this._scrollChildren(e-d.width,0)}a=d.anchorX;0<d.getLeftBoundary()&&(d.x=a*c);d.getRightBoundary()<b&&(d.x=b-(1-a)*c)},_setInnerHeight:function(a){var b=this._contentSize.height,
c=b,d=this._innerContainer,e=d.height;switch(b>a?cc.log("Inner height \x3c\x3d scrollview height, it will be force sized!"):c=a,d.height=c,this.direction){case ccui.ScrollView.DIR_VERTICAL:case ccui.ScrollView.DIR_BOTH:this._scrollChildren(0,e-c)}a=d.anchorY;0<d.getLeftBoundary()&&(d.y=a*c);d.getRightBoundary()<b&&(d.y=b-(1-a)*c)},getInnerContainerSize:function(){return this._innerContainer.getContentSize()},_getInnerWidth:function(){return this._innerContainer.width},_getInnerHeight:function(){return this._innerContainer.height},
addChild:function(a,b,c){return a?(b=b||a.getLocalZOrder(),c=c||a.getTag(),this._innerContainer.addChild(a,b,c)):!1},removeAllChildren:function(){this.removeAllChildrenWithCleanup(!0)},removeAllChildrenWithCleanup:function(a){this._innerContainer.removeAllChildrenWithCleanup(a)},removeChild:function(a,b){return this._innerContainer.removeChild(a,b)},getChildren:function(){return this._innerContainer.getChildren()},getChildrenCount:function(){return this._innerContainer.getChildrenCount()},getChildByTag:function(a){return this._innerContainer.getChildByTag(a)},
getChildByName:function(a){return this._innerContainer.getChildByName(a)},_moveChildren:function(a,b){var c=this._innerContainer;this._moveChildPoint.x=c.x+a;this._moveChildPoint.y=c.y+b;this._innerContainer.setPosition(this._moveChildPoint)},_autoScrollChildren:function(a){var b=this._autoScrollAddUpTime;if(this._autoScrollAddUpTime+=a,this._isAutoScrollSpeedAttenuated)0>=this._autoScrollOriginalSpeed+this._autoScrollAcceleration*this._autoScrollAddUpTime?(this._stopAutoScrollChildren(),this._checkNeedBounce()):
(b=(this._autoScrollOriginalSpeed+0.5*this._autoScrollAcceleration*(2*b+a))*a,this._scrollChildren(b*this._autoScrollDir.x,b*this._autoScrollDir.y)||(this._stopAutoScrollChildren(),this._checkNeedBounce()));else if(this._needCheckAutoScrollDestination){var b=this._autoScrollDir.x*a*this._autoScrollOriginalSpeed,c=this._autoScrollDir.y*a*this._autoScrollOriginalSpeed;a=this._checkCustomScrollDestination(b,c);b=this._scrollChildren(b,c);a&&b||(this._stopAutoScrollChildren(),this._checkNeedBounce())}else this._scrollChildren(this._autoScrollDir.x*
a*this._autoScrollOriginalSpeed,this._autoScrollDir.y*a*this._autoScrollOriginalSpeed)||(this._stopAutoScrollChildren(),this._checkNeedBounce())},_bounceChildren:function(a){var b=this._bounceOriginalSpeed,c=this._bounceDir;0>=b&&this._stopBounceChildren();this._bounceScrollChildren(c.x*a*b,c.y*a*b)||this._stopBounceChildren()},_checkNeedBounce:function(){if(!this.bounceEnabled)return!1;this._checkBounceBoundary();var a=this._topBounceNeeded,b=this._bottomBounceNeeded,c=this._leftBounceNeeded,d=this._rightBounceNeeded;
if(a||b||c||d){var e,f,g=this._contentSize,h=this._innerContainer;return a&&c?(e=cc.pSub(cc.p(0,g.height),cc.p(h.getLeftBoundary(),h.getTopBoundary())),f=cc.pLength(e)/0.2,this._bounceDir=cc.pNormalize(e),this._startBounceChildren(f)):a&&d?(e=cc.pSub(cc.p(g.width,g.height),cc.p(h.getRightBoundary(),h.getTopBoundary())),f=cc.pLength(e)/0.2,this._bounceDir=cc.pNormalize(e),this._startBounceChildren(f)):b&&c?(e=cc.pSub(cc.p(0,0),cc.p(h.getLeftBoundary(),h.getBottomBoundary())),f=cc.pLength(e)/0.2,this._bounceDir=
cc.pNormalize(e),this._startBounceChildren(f)):b&&d?(e=cc.pSub(cc.p(g.width,0),cc.p(h.getRightBoundary(),h.getBottomBoundary())),f=cc.pLength(e)/0.2,this._bounceDir=cc.pNormalize(e),this._startBounceChildren(f)):a?(e=cc.pSub(cc.p(0,g.height),cc.p(0,h.getTopBoundary())),f=cc.pLength(e)/0.2,this._bounceDir=cc.pNormalize(e),this._startBounceChildren(f)):b?(e=cc.pSub(cc.p(0,0),cc.p(0,h.getBottomBoundary())),f=cc.pLength(e)/0.2,this._bounceDir=cc.pNormalize(e),this._startBounceChildren(f)):c?(e=cc.pSub(cc.p(0,
0),cc.p(h.getLeftBoundary(),0)),f=cc.pLength(e)/0.2,this._bounceDir=cc.pNormalize(e),this._startBounceChildren(f)):d&&(e=cc.pSub(cc.p(g.width,0),cc.p(h.getRightBoundary(),0)),f=cc.pLength(e)/0.2,this._bounceDir=cc.pNormalize(e),this._startBounceChildren(f)),!0}return!1},_checkBounceBoundary:function(){var a=this._innerContainer;a.getBottomBoundary()>this._bottomBoundary?(this._scrollToBottomEvent(),this._bottomBounceNeeded=!0):this._bottomBounceNeeded=!1;a.getTopBoundary()<this._topBoundary?(this._scrollToTopEvent(),
this._topBounceNeeded=!0):this._topBounceNeeded=!1;a.getRightBoundary()<this._rightBoundary?(this._scrollToRightEvent(),this._rightBounceNeeded=!0):this._rightBounceNeeded=!1;a.getLeftBoundary()>this._leftBoundary?(this._scrollToLeftEvent(),this._leftBounceNeeded=!0):this._leftBounceNeeded=!1},_startBounceChildren:function(a){this._bounceOriginalSpeed=a;this._bouncing=!0},_stopBounceChildren:function(){this._bouncing=!1;this._bounceOriginalSpeed=0;this._bottomBounceNeeded=this._topBounceNeeded=this._rightBounceNeeded=
this._leftBounceNeeded=!1},_startAutoScrollChildrenWithOriginalSpeed:function(a,b,c,d){this._stopAutoScrollChildren();this._autoScrollDir.x=a.x;this._autoScrollDir.y=a.y;this._isAutoScrollSpeedAttenuated=c;this._autoScrollOriginalSpeed=b;this._autoScroll=!0;this._autoScrollAcceleration=d},_startAutoScrollChildrenWithDestination:function(a,b,c){this._needCheckAutoScrollDestination=!1;this._autoScrollDestination=a;var d=cc.pSub(a,this._innerContainer.getPosition());a=cc.pNormalize(d);var e=0,f=-1E3,
d=cc.pLength(d);c?(f=-(2*d)/(b*b),e=2*d/b):(this._needCheckAutoScrollDestination=!0,e=d/b);this._startAutoScrollChildrenWithOriginalSpeed(a,e,c,f)},_jumpToDestination:function(a,b){void 0!==a.x&&(b=a.y,a=a.x);var c=a,d=b;switch(this.direction){case ccui.ScrollView.DIR_VERTICAL:0>=b&&(d=Math.max(b,this._contentSize.height-this._innerContainer.getContentSize().height));break;case ccui.ScrollView.DIR_HORIZONTAL:0>=a&&(c=Math.max(a,this._contentSize.width-this._innerContainer.getContentSize().width));
break;case ccui.ScrollView.DIR_BOTH:0>=b&&(d=Math.max(b,this._contentSize.height-this._innerContainer.getContentSize().height)),0>=a&&(c=Math.max(a,this._contentSize.width-this._innerContainer.getContentSize().width))}this._innerContainer.setPosition(c,d)},_stopAutoScrollChildren:function(){this._autoScroll=!1;this._autoScrollAddUpTime=this._autoScrollOriginalSpeed=0},_bounceScrollChildren:function(a,b){var c,d,e,f,g=!0;f=this._innerContainer;0<a&&0<b?(c=a,d=b,e=f.getRightBoundary(),e+c>=this._rightBoundary&&
(c=this._rightBoundary-e,this._bounceRightEvent(),g=!1),f=f.getTopBoundary(),f+b>=this._topBoundary&&(d=this._topBoundary-f,this._bounceTopEvent(),g=!1),this._moveChildren(c,d)):0>a&&0<b?(c=a,d=b,e=f.getLeftBoundary(),e+c<=this._leftBoundary&&(c=this._leftBoundary-e,this._bounceLeftEvent(),g=!1),f=f.getTopBoundary(),f+b>=this._topBoundary&&(d=this._topBoundary-f,this._bounceTopEvent(),g=!1),this._moveChildren(c,d)):0>a&&0>b?(c=a,d=b,e=f.getLeftBoundary(),e+c<=this._leftBoundary&&(c=this._leftBoundary-
e,this._bounceLeftEvent(),g=!1),f=f.getBottomBoundary(),f+b<=this._bottomBoundary&&(d=this._bottomBoundary-f,this._bounceBottomEvent(),g=!1),this._moveChildren(c,d)):0<a&&0>b?(c=a,d=b,e=f.getRightBoundary(),e+c>=this._rightBoundary&&(c=this._rightBoundary-e,this._bounceRightEvent(),g=!1),f=f.getBottomBoundary(),f+b<=this._bottomBoundary&&(d=this._bottomBoundary-f,this._bounceBottomEvent(),g=!1),this._moveChildren(c,d)):0===a&&0<b?(d=b,f=f.getTopBoundary(),f+b>=this._topBoundary&&(d=this._topBoundary-
f,this._bounceTopEvent(),g=!1),this._moveChildren(0,d)):0===a&&0>b?(d=b,f=f.getBottomBoundary(),f+b<=this._bottomBoundary&&(d=this._bottomBoundary-f,this._bounceBottomEvent(),g=!1),this._moveChildren(0,d)):0<a&&0===b?(c=a,e=f.getRightBoundary(),e+c>=this._rightBoundary&&(c=this._rightBoundary-e,this._bounceRightEvent(),g=!1),this._moveChildren(c,0)):0>a&&0===b&&(c=a,d=f.getLeftBoundary(),d+c<=this._leftBoundary&&(c=this._leftBoundary-d,this._bounceLeftEvent(),g=!1),this._moveChildren(c,0));return g},
_checkCustomScrollDestination:function(a,b){var c,d,e,f,g=!0,h=this._innerContainer,k=this._autoScrollDestination;switch(this.direction){case ccui.ScrollView.DIR_VERTICAL:0<this._autoScrollDir.y?(c=h.getBottomBoundary(),c+b>=k.y&&(g=!1)):(c=h.getBottomBoundary(),c+b<=k.y&&(g=!1));break;case ccui.ScrollView.DIR_HORIZONTAL:0<this._autoScrollDir.x?(d=h.getLeftBoundary(),d+a>=k.x&&(g=!1)):(d=h.getLeftBoundary(),d+a<=k.x&&(g=!1));break;case ccui.ScrollView.DIR_BOTH:0<a&&0<b?(d=h.getLeftBoundary(),d+a>=
k.x&&(g=!1),c=h.getBottomBoundary(),c+b>=k.y&&(g=!1)):0>a&&0<b?(e=h.getRightBoundary(),e+a<=k.x&&(g=!1),c=h.getBottomBoundary(),c+b>=k.y&&(g=!1)):0>a&&0>b?(e=h.getRightBoundary(),e+a<=k.x&&(g=!1),f=h.getTopBoundary(),f+b<=k.y&&(g=!1)):0<a&&0>b?(d=h.getLeftBoundary(),d+a>=k.x&&(g=!1),f=h.getTopBoundary(),f+b<=k.y&&(g=!1)):0===a&&0<b?(c=h.getBottomBoundary(),c+b>=k.y&&(g=!1)):0>a&&0===b?(e=h.getRightBoundary(),e+a<=k.x&&(g=!1)):0===a&&0>b?(f=h.getTopBoundary(),f+b<=k.y&&(g=!1)):0<a&&0===b&&(d=h.getLeftBoundary(),
d+a>=k.x&&(g=!1))}return g},_scrollChildren:function(a,b){var c=!0;switch(this._scrollingEvent(),this.direction){case ccui.ScrollView.DIR_VERTICAL:c=this._scrollChildrenVertical(a,b);break;case ccui.ScrollView.DIR_HORIZONTAL:c=this._scrollChildrenHorizontal(a,b);break;case ccui.ScrollView.DIR_BOTH:c=this._scrollChildrenBoth(a,b)}return c},_scrollChildrenVertical:function(a,b){var c,d,e=b,f=this._innerContainer;return this.bounceEnabled?(c=f.getBottomBoundary(),c+b>=this._bounceBottomBoundary&&(e=
this._bounceBottomBoundary-c,this._scrollToBottomEvent()),d=f.getTopBoundary(),d+b<=this._bounceTopBoundary&&(e=this._bounceTopBoundary-d,this._scrollToTopEvent())):(c=f.getBottomBoundary(),c+b>=this._bottomBoundary&&(e=this._bottomBoundary-c,this._scrollToBottomEvent()),d=f.getTopBoundary(),d+b<=this._topBoundary&&(e=this._topBoundary-d,this._scrollToTopEvent())),this._moveChildren(0,e),!0},_scrollChildrenHorizontal:function(a,b){var c,d,e=a,f=this._innerContainer;return this.bounceEnabled?(c=f.getRightBoundary(),
c+a<=this._bounceRightBoundary&&(e=this._bounceRightBoundary-c,this._scrollToRightEvent()),d=f.getLeftBoundary(),d+a>=this._bounceLeftBoundary&&(e=this._bounceLeftBoundary-d,this._scrollToLeftEvent())):(c=f.getRightBoundary(),c+a<=this._rightBoundary&&(e=this._rightBoundary-c,this._scrollToRightEvent()),d=f.getLeftBoundary(),d+a>=this._leftBoundary&&(e=this._leftBoundary-d,this._scrollToLeftEvent())),this._moveChildren(e,0),!0},_scrollChildrenBoth:function(a,b){var c,d,e,f,g=a,h=b,k=this._innerContainer;
return this.bounceEnabled?0<a&&0<b?(c=k.getLeftBoundary(),c+a>=this._bounceLeftBoundary&&(g=this._bounceLeftBoundary-c,this._scrollToLeftEvent()),d=k.getBottomBoundary(),d+b>=this._bounceBottomBoundary&&(h=this._bounceBottomBoundary-d,this._scrollToBottomEvent())):0>a&&0<b?(e=k.getRightBoundary(),e+a<=this._bounceRightBoundary&&(g=this._bounceRightBoundary-e,this._scrollToRightEvent()),d=k.getBottomBoundary(),d+b>=this._bounceBottomBoundary&&(h=this._bounceBottomBoundary-d,this._scrollToBottomEvent())):
0>a&&0>b?(e=k.getRightBoundary(),e+a<=this._bounceRightBoundary&&(g=this._bounceRightBoundary-e,this._scrollToRightEvent()),f=k.getTopBoundary(),f+b<=this._bounceTopBoundary&&(h=this._bounceTopBoundary-f,this._scrollToTopEvent())):0<a&&0>b?(c=k.getLeftBoundary(),c+a>=this._bounceLeftBoundary&&(g=this._bounceLeftBoundary-c,this._scrollToLeftEvent()),f=k.getTopBoundary(),f+b<=this._bounceTopBoundary&&(h=this._bounceTopBoundary-f,this._scrollToTopEvent())):0===a&&0<b?(d=k.getBottomBoundary(),d+b>=this._bounceBottomBoundary&&
(h=this._bounceBottomBoundary-d,this._scrollToBottomEvent())):0>a&&0===b?(e=k.getRightBoundary(),e+a<=this._bounceRightBoundary&&(g=this._bounceRightBoundary-e,this._scrollToRightEvent())):0===a&&0>b?(f=k.getTopBoundary(),f+b<=this._bounceTopBoundary&&(h=this._bounceTopBoundary-f,this._scrollToTopEvent())):0<a&&0===b&&(c=k.getLeftBoundary(),c+a>=this._bounceLeftBoundary&&(g=this._bounceLeftBoundary-c,this._scrollToLeftEvent())):0<a&&0<b?(c=k.getLeftBoundary(),c+a>=this._leftBoundary&&(g=this._leftBoundary-
c,this._scrollToLeftEvent()),d=k.getBottomBoundary(),d+b>=this._bottomBoundary&&(h=this._bottomBoundary-d,this._scrollToBottomEvent())):0>a&&0<b?(e=k.getRightBoundary(),e+a<=this._rightBoundary&&(g=this._rightBoundary-e,this._scrollToRightEvent()),d=k.getBottomBoundary(),d+b>=this._bottomBoundary&&(h=this._bottomBoundary-d,this._scrollToBottomEvent())):0>a&&0>b?(e=k.getRightBoundary(),e+a<=this._rightBoundary&&(g=this._rightBoundary-e,this._scrollToRightEvent()),f=k.getTopBoundary(),f+b<=this._topBoundary&&
(h=this._topBoundary-f,this._scrollToTopEvent())):0<a&&0>b?(c=k.getLeftBoundary(),c+a>=this._leftBoundary&&(g=this._leftBoundary-c,this._scrollToLeftEvent()),f=this._innerContainer.getTopBoundary(),f+b<=this._topBoundary&&(h=this._topBoundary-f,this._scrollToTopEvent())):0===a&&0<b?(d=this._innerContainer.getBottomBoundary(),d+b>=this._bottomBoundary&&(h=this._bottomBoundary-d,this._scrollToBottomEvent())):0>a&&0===b?(e=this._innerContainer.getRightBoundary(),e+a<=this._rightBoundary&&(g=this._rightBoundary-
e,this._scrollToRightEvent())):0===a&&0>b?(f=this._innerContainer.getTopBoundary(),f+b<=this._topBoundary&&(h=this._topBoundary-f,this._scrollToTopEvent())):0<a&&0===b&&(c=this._innerContainer.getLeftBoundary(),c+a>=this._leftBoundary&&(g=this._leftBoundary-c,this._scrollToLeftEvent())),this._moveChildren(g,h),!0},scrollToBottom:function(a,b){this._startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(),0),a,b)},scrollToTop:function(a,b){this._startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(),
this._contentSize.height-this._innerContainer.getContentSize().height),a,b)},scrollToLeft:function(a,b){this._startAutoScrollChildrenWithDestination(cc.p(0,this._innerContainer.getPositionY()),a,b)},scrollToRight:function(a,b){this._startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width-this._innerContainer.getContentSize().width,this._innerContainer.getPositionY()),a,b)},scrollToTopLeft:function(a,b){return this.direction!==ccui.ScrollView.DIR_BOTH?void cc.log("Scroll direction is not both!"):
void this._startAutoScrollChildrenWithDestination(cc.p(0,this._contentSize.height-this._innerContainer.getContentSize().height),a,b)},scrollToTopRight:function(a,b){if(this.direction!==ccui.ScrollView.DIR_BOTH)return void cc.log("Scroll direction is not both!");var c=this._innerContainer.getContentSize();this._startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width-c.width,this._contentSize.height-c.height),a,b)},scrollToBottomLeft:function(a,b){return this.direction!==ccui.ScrollView.DIR_BOTH?
void cc.log("Scroll direction is not both!"):void this._startAutoScrollChildrenWithDestination(cc.p(0,0),a,b)},scrollToBottomRight:function(a,b){return this.direction!==ccui.ScrollView.DIR_BOTH?void cc.log("Scroll direction is not both!"):void this._startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width-this._innerContainer.getContentSize().width,0),a,b)},scrollToPercentVertical:function(a,b,c){var d=this._contentSize.height-this._innerContainer.getContentSize().height,e=-d;this._startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(),
d+a*e/100),b,c)},scrollToPercentHorizontal:function(a,b,c){var d=this._innerContainer.getContentSize().width-this._contentSize.width;this._startAutoScrollChildrenWithDestination(cc.p(-(a*d/100),this._innerContainer.getPositionY()),b,c)},scrollToPercentBothDirection:function(a,b,c){if(this.direction===ccui.ScrollView.DIR_BOTH){var d=this._contentSize.height-this._innerContainer.getContentSize().height,e=-d,f=this._innerContainer.getContentSize().width-this._contentSize.width;this._startAutoScrollChildrenWithDestination(cc.p(-(a.x*
f/100),d+a.y*e/100),b,c)}},jumpToBottom:function(){this._jumpToDestination(this._innerContainer.getPositionX(),0)},jumpToTop:function(){this._jumpToDestination(this._innerContainer.getPositionX(),this._contentSize.height-this._innerContainer.getContentSize().height)},jumpToLeft:function(){this._jumpToDestination(0,this._innerContainer.getPositionY())},jumpToRight:function(){this._jumpToDestination(this._contentSize.width-this._innerContainer.getContentSize().width,this._innerContainer.getPositionY())},
jumpToTopLeft:function(){return this.direction!==ccui.ScrollView.DIR_BOTH?void cc.log("Scroll direction is not both!"):void this._jumpToDestination(0,this._contentSize.height-this._innerContainer.getContentSize().height)},jumpToTopRight:function(){if(this.direction!==ccui.ScrollView.DIR_BOTH)return void cc.log("Scroll direction is not both!");var a=this._innerContainer.getContentSize();this._jumpToDestination(this._contentSize.width-a.width,this._contentSize.height-a.height)},jumpToBottomLeft:function(){return this.direction!==
ccui.ScrollView.DIR_BOTH?void cc.log("Scroll direction is not both!"):void this._jumpToDestination(0,0)},jumpToBottomRight:function(){return this.direction!==ccui.ScrollView.DIR_BOTH?void cc.log("Scroll direction is not both!"):void this._jumpToDestination(this._contentSize.width-this._innerContainer.getContentSize().width,0)},jumpToPercentVertical:function(a){var b=this._contentSize.height-this._innerContainer.getContentSize().height,c=-b;this._jumpToDestination(this._innerContainer.getPositionX(),
b+a*c/100)},jumpToPercentHorizontal:function(a){var b=this._innerContainer.getContentSize().width-this._contentSize.width;this._jumpToDestination(-(a*b/100),this._innerContainer.getPositionY())},jumpToPercentBothDirection:function(a){if(this.direction===ccui.ScrollView.DIR_BOTH){var b=this._innerContainer.getContentSize(),c=this._contentSize.height-b.height;this._jumpToDestination(-(a.x*(b.width-this._contentSize.width)/100),c+a.y*-c/100)}},_startRecordSlidAction:function(){this._autoScroll&&this._stopAutoScrollChildren();
this._bouncing&&this._stopBounceChildren();this._slidTime=0},_endRecordSlidAction:function(){if(!this._checkNeedBounce()&&this.inertiaScrollEnabled&&!(0.016>=this._slidTime)){var a,b=0;a=this.convertToNodeSpace(this._touchEndPosition);var c=this.convertToNodeSpace(this._touchBeganPosition);switch(this.direction){case ccui.ScrollView.DIR_VERTICAL:b=a.y-c.y;a=0>b?ccui.ScrollView.SCROLLDIR_DOWN:ccui.ScrollView.SCROLLDIR_UP;break;case ccui.ScrollView.DIR_HORIZONTAL:b=a.x-c.x;a=0>b?ccui.ScrollView.SCROLLDIR_LEFT:
ccui.ScrollView.SCROLLDIR_RIGHT;break;case ccui.ScrollView.DIR_BOTH:a=cc.pSub(a,c);b=cc.pLength(a);a=cc.pNormalize(a);break;default:a=cc.p(0,0)}b=Math.min(Math.abs(b)/this._slidTime,ccui.ScrollView.AUTO_SCROLL_MAX_SPEED);this._startAutoScrollChildrenWithOriginalSpeed(a,b,!0,-1E3);this._slidTime=0}},_handlePressLogic:function(a){this._startRecordSlidAction();this._bePressed=!0},_handleMoveLogic:function(a){var b=this.convertToNodeSpace(a.getLocation());a=this.convertToNodeSpace(a.getPreviousLocation());
b=cc.pSub(b,a);switch(this.direction){case ccui.ScrollView.DIR_VERTICAL:this._scrollChildren(0,b.y);break;case ccui.ScrollView.DIR_HORIZONTAL:this._scrollChildren(b.x,0);break;case ccui.ScrollView.DIR_BOTH:this._scrollChildren(b.x,b.y)}},_handleReleaseLogic:function(a){this._endRecordSlidAction();this._bePressed=!1},onTouchBegan:function(a,b){var c=ccui.Layout.prototype.onTouchBegan.call(this,a,b);return this._isInterceptTouch||this._hit&&this._handlePressLogic(a),c},onTouchMoved:function(a,b){ccui.Layout.prototype.onTouchMoved.call(this,
a,b);this._isInterceptTouch||this._handleMoveLogic(a)},onTouchEnded:function(a,b){ccui.Layout.prototype.onTouchEnded.call(this,a,b);this._isInterceptTouch||this._handleReleaseLogic(a);this._isInterceptTouch=!1},onTouchCancelled:function(a,b){ccui.Layout.prototype.onTouchCancelled.call(this,a,b);this._isInterceptTouch||this.handleReleaseLogic(a);this._isInterceptTouch=!1},update:function(a){this._autoScroll&&this._autoScrollChildren(a);this._bouncing&&this._bounceChildren(a);this._recordSlidTime(a)},
_recordSlidTime:function(a){this._bePressed&&(this._slidTime+=a)},interceptTouchEvent:function(a,b,c){var d=c.getLocation();switch(a){case ccui.Widget.TOUCH_BEGAN:this._isInterceptTouch=!0;this._touchBeganPosition.x=d.x;this._touchBeganPosition.y=d.y;this._handlePressLogic(c);break;case ccui.Widget.TOUCH_MOVED:a=cc.pLength(cc.pSub(b.getTouchBeganPosition(),d));this._touchMovePosition.x=d.x;this._touchMovePosition.y=d.y;a>this._childFocusCancelOffset&&(b.setHighlighted(!1),this._handleMoveLogic(c));
break;case ccui.Widget.TOUCH_CANCELED:case ccui.Widget.TOUCH_ENDED:this._touchEndPosition.x=d.x,this._touchEndPosition.y=d.y,this._handleReleaseLogic(c),b.isSwallowTouches()&&(this._isInterceptTouch=!1)}},_scrollToTopEvent:function(){this._scrollViewEventSelector&&(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_SCROLL_TO_TOP):this._scrollViewEventSelector(this,ccui.ScrollView.EVENT_SCROLL_TO_TOP));this._ccEventCallback&&this._ccEventCallback(this,
ccui.ScrollView.EVENT_SCROLL_TO_TOP)},_scrollToBottomEvent:function(){this._scrollViewEventSelector&&(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM):this._scrollViewEventSelector(this,ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM));this._ccEventCallback&&this._ccEventCallback(this,ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM)},_scrollToLeftEvent:function(){this._scrollViewEventSelector&&(this._scrollViewEventListener?
this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_SCROLL_TO_LEFT):this._scrollViewEventSelector(this,ccui.ScrollView.EVENT_SCROLL_TO_LEFT));this._ccEventCallback&&this._ccEventCallback(this,ccui.ScrollView.EVENT_SCROLL_TO_LEFT)},_scrollToRightEvent:function(){this._scrollViewEventSelector&&(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_SCROLL_TO_RIGHT):this._scrollViewEventSelector(this,
ccui.ScrollView.EVENT_SCROLL_TO_RIGHT));this._ccEventCallback&&this._ccEventCallback(this,ccui.ScrollView.EVENT_SCROLL_TO_RIGHT)},_scrollingEvent:function(){this._scrollViewEventSelector&&(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_SCROLLING):this._scrollViewEventSelector(this,ccui.ScrollView.EVENT_SCROLLING));this._ccEventCallback&&this._ccEventCallback(this,ccui.ScrollView.EVENT_SCROLLING)},_bounceTopEvent:function(){this._scrollViewEventSelector&&
(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_BOUNCE_TOP):this._scrollViewEventSelector(this,ccui.ScrollView.EVENT_BOUNCE_TOP));this._ccEventCallback&&this._ccEventCallback(this,ccui.ScrollView.EVENT_BOUNCE_TOP)},_bounceBottomEvent:function(){this._scrollViewEventSelector&&(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_BOUNCE_BOTTOM):this._scrollViewEventSelector(this,
ccui.ScrollView.EVENT_BOUNCE_BOTTOM));this._ccEventCallback&&this._ccEventCallback(this,ccui.ScrollView.EVENT_BOUNCE_BOTTOM)},_bounceLeftEvent:function(){this._scrollViewEventSelector&&(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_BOUNCE_LEFT):this._scrollViewEventSelector(this,ccui.ScrollView.EVENT_BOUNCE_LEFT));this._ccEventCallback&&this._ccEventCallback(this,ccui.ScrollView.EVENT_BOUNCE_LEFT)},_bounceRightEvent:function(){this._scrollViewEventSelector&&
(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_BOUNCE_RIGHT):this._scrollViewEventSelector(this,ccui.ScrollView.EVENT_BOUNCE_RIGHT));this._ccEventCallback&&this._ccEventCallback(this,ccui.ScrollView.EVENT_BOUNCE_RIGHT)},addEventListenerScrollView:function(a,b){this.addEventListener(a,b)},addEventListener:function(a,b){this._scrollViewEventSelector=a;this._scrollViewEventListener=b},setDirection:function(a){this.direction=
a},getDirection:function(){return this.direction},setBounceEnabled:function(a){this.bounceEnabled=a},isBounceEnabled:function(){return this.bounceEnabled},setInertiaScrollEnabled:function(a){this.inertiaScrollEnabled=a},isInertiaScrollEnabled:function(){return this.inertiaScrollEnabled},getInnerContainer:function(){return this._innerContainer},setLayoutType:function(a){this._innerContainer.setLayoutType(a)},getLayoutType:function(){return this._innerContainer.getLayoutType()},_doLayout:function(){this._doLayoutDirty&&
(this._doLayoutDirty=!1)},getDescription:function(){return"ScrollView"},_createCloneInstance:function(){return new ccui.ScrollView},_copyClonedWidgetChildren:function(a){ccui.Layout.prototype._copyClonedWidgetChildren.call(this,a)},_copySpecialProperties:function(a){a instanceof ccui.ScrollView&&(ccui.Layout.prototype._copySpecialProperties.call(this,a),this.setInnerContainerSize(a.getInnerContainerSize()),this.setDirection(a.direction),this.setBounceEnabled(a.bounceEnabled),this.setInertiaScrollEnabled(a.inertiaScrollEnabled),
this._scrollViewEventListener=a._scrollViewEventListener,this._scrollViewEventSelector=a._scrollViewEventSelector,this._ccEventCallback=a._ccEventCallback)},getNodeByTag:function(a){return this._innerContainer.getNodeByTag(a)},getNodes:function(){return this._innerContainer.getNodes()},removeNode:function(a){this._innerContainer.removeNode(a)},removeNodeByTag:function(a){this._innerContainer.removeNodeByTag(a)},removeAllNodes:function(){this._innerContainer.removeAllNodes()},addNode:function(a,b,
c){this._innerContainer.addNode(a,b,c)}});_p=ccui.ScrollView.prototype;_p.innerWidth;cc.defineGetterSetter(_p,"innerWidth",_p._getInnerWidth,_p._setInnerWidth);_p.innerHeight;cc.defineGetterSetter(_p,"innerHeight",_p._getInnerHeight,_p._setInnerHeight);_p=null;ccui.ScrollView.create=function(){return new ccui.ScrollView};ccui.ScrollView.DIR_NONE=0;ccui.ScrollView.DIR_VERTICAL=1;ccui.ScrollView.DIR_HORIZONTAL=2;ccui.ScrollView.DIR_BOTH=3;ccui.ScrollView.EVENT_SCROLL_TO_TOP=0;
ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM=1;ccui.ScrollView.EVENT_SCROLL_TO_LEFT=2;ccui.ScrollView.EVENT_SCROLL_TO_RIGHT=3;ccui.ScrollView.EVENT_SCROLLING=4;ccui.ScrollView.EVENT_BOUNCE_TOP=5;ccui.ScrollView.EVENT_BOUNCE_BOTTOM=6;ccui.ScrollView.EVENT_BOUNCE_LEFT=7;ccui.ScrollView.EVENT_BOUNCE_RIGHT=8;ccui.ScrollView.AUTO_SCROLL_MAX_SPEED=1E3;ccui.ScrollView.SCROLLDIR_UP=cc.p(0,1);ccui.ScrollView.SCROLLDIR_DOWN=cc.p(0,-1);ccui.ScrollView.SCROLLDIR_LEFT=cc.p(-1,0);
ccui.ScrollView.SCROLLDIR_RIGHT=cc.p(1,0);
ccui.ListView=ccui.ScrollView.extend({_model:null,_items:null,_gravity:null,_itemsMargin:0,_curSelectedIndex:0,_refreshViewDirty:!0,_listViewEventListener:null,_listViewEventSelector:null,ctor:function(){ccui.ScrollView.prototype.ctor.call(this);this._items=[];this._gravity=ccui.ListView.GRAVITY_CENTER_VERTICAL;this.setTouchEnabled(!0);this.init()},init:function(){return ccui.ScrollView.prototype.init.call(this)?(this.setLayoutType(ccui.Layout.LINEAR_VERTICAL),!0):!1},setItemModel:function(a){return a?
void(this._model=a):void cc.log("Can't set a null to item model!")},_updateInnerContainerSize:function(){var a,b,c=this._items;switch(this.direction){case ccui.ScrollView.DIR_VERTICAL:a=c.length;var d=(a-1)*this._itemsMargin;for(b=0;a>b;b++)d+=c[b].getContentSize().height;this.setInnerContainerSize(cc.size(this._contentSize.width,d));break;case ccui.ScrollView.DIR_HORIZONTAL:a=c.length;d=(a-1)*this._itemsMargin;for(b=0;a>b;b++)d+=c[b].getContentSize().width;this.setInnerContainerSize(cc.size(d,this._contentSize.height))}},
_remedyLayoutParameter:function(a){cc.assert(null!=a,"ListView Item can't be nil!");var b=a.getLayoutParameter(),c=!0;b||(b=new ccui.LinearLayoutParameter,c=!1);var d=this.getIndex(a);switch(this.direction){case ccui.ScrollView.DIR_VERTICAL:this._remedyVerticalLayoutParameter(b,d);break;case ccui.ScrollView.DIR_HORIZONTAL:this._remedyHorizontalLayoutParameter(b,d)}c||a.setLayoutParameter(b)},_remedyVerticalLayoutParameter:function(a,b){switch(cc.assert(null!=a,"Layout parameter can't be nil!"),this._gravity){case ccui.ListView.GRAVITY_LEFT:a.setGravity(ccui.LinearLayoutParameter.LEFT);
break;case ccui.ListView.GRAVITY_RIGHT:a.setGravity(ccui.LinearLayoutParameter.RIGHT);break;case ccui.ListView.GRAVITY_CENTER_HORIZONTAL:a.setGravity(ccui.LinearLayoutParameter.CENTER_HORIZONTAL)}a.setMargin(0===b?ccui.MarginZero():new ccui.Margin(0,this._itemsMargin,0,0))},_remedyHorizontalLayoutParameter:function(a,b){switch(cc.assert(null!=a,"Layout parameter can't be nil!"),this._gravity){case ccui.ListView.GRAVITY_TOP:a.setGravity(ccui.LinearLayoutParameter.TOP);break;case ccui.ListView.GRAVITY_BOTTOM:a.setGravity(ccui.LinearLayoutParameter.BOTTOM);
break;case ccui.ListView.GRAVITY_CENTER_VERTICAL:a.setGravity(ccui.LinearLayoutParameter.CENTER_VERTICAL)}a.setMargin(0===b?ccui.MarginZero():new ccui.Margin(this._itemsMargin,0,0,0))},pushBackDefaultItem:function(){if(null!=this._model){var a=this._model.clone();this._remedyLayoutParameter(a);this.addChild(a);this._refreshViewDirty=!0}},insertDefaultItem:function(a){if(null!=this._model){var b=this._model.clone();this._items.splice(a,0,b);ccui.ScrollView.prototype.addChild.call(this,b);this._remedyLayoutParameter(b);
this._refreshViewDirty=!0}},pushBackCustomItem:function(a){this._remedyLayoutParameter(a);this.addChild(a);this._refreshViewDirty=!0},addChild:function(a,b,c){a&&(b=b||a.getLocalZOrder(),c=c||a.getName(),ccui.ScrollView.prototype.addChild.call(this,a,b,c),a instanceof ccui.Widget&&this._items.push(a))},removeChild:function(a,b){if(a){var c=this._items.indexOf(a);-1<c&&this._items.splice(c,1);ccui.ScrollView.prototype.removeChild.call(this,a,b)}},removeAllChildren:function(){this.removeAllChildrenWithCleanup(!0)},
removeAllChildrenWithCleanup:function(a){ccui.ScrollView.prototype.removeAllChildrenWithCleanup.call(this,a);this._items=[]},insertCustomItem:function(a,b){this._items.splice(b,0,a);ccui.ScrollView.prototype.addChild.call(this,a);this._remedyLayoutParameter(a);this._refreshViewDirty=!0},removeItem:function(a){a=this.getItem(a);null!=a&&(this.removeChild(a,!0),this._refreshViewDirty=!0)},removeLastItem:function(){this.removeItem(this._items.length-1)},removeAllItems:function(){this.removeAllChildren()},
getItem:function(a){return 0>a||a>=this._items.length?null:this._items[a]},getItems:function(){return this._items},getIndex:function(a){return null==a?-1:this._items.indexOf(a)},setGravity:function(a){this._gravity!==a&&(this._gravity=a,this._refreshViewDirty=!0)},setItemsMargin:function(a){this._itemsMargin!==a&&(this._itemsMargin=a,this._refreshViewDirty=!0)},getItemsMargin:function(){return this._itemsMargin},setDirection:function(a){switch(a){case ccui.ScrollView.DIR_VERTICAL:this.setLayoutType(ccui.Layout.LINEAR_VERTICAL);
break;case ccui.ScrollView.DIR_HORIZONTAL:this.setLayoutType(ccui.Layout.LINEAR_HORIZONTAL);break;case ccui.ScrollView.DIR_BOTH:return;default:return}ccui.ScrollView.prototype.setDirection.call(this,a)},requestRefreshView:function(){this._refreshViewDirty=!0},refreshView:function(){for(var a=this._items,b=0;b<a.length;b++){var c=a[b];c.setLocalZOrder(b);this._remedyLayoutParameter(c)}this._updateInnerContainerSize()},doLayout:function(){this._doLayout()},_doLayout:function(){ccui.Layout.prototype._doLayout.call(this);
this._refreshViewDirty&&(this.refreshView(),this._refreshViewDirty=!1)},addEventListenerListView:function(a,b){this.addEventListener(a,b)},addEventListener:function(a,b){this._listViewEventListener=b;this._listViewEventSelector=a},_selectedItemEvent:function(a){a=a===ccui.Widget.TOUCH_BEGAN?ccui.ListView.ON_SELECTED_ITEM_START:ccui.ListView.ON_SELECTED_ITEM_END;this._listViewEventSelector&&(this._listViewEventListener?this._listViewEventSelector.call(this._listViewEventListener,this,a):this._listViewEventSelector(this,
a));this._ccEventCallback&&this._ccEventCallback(this,a)},interceptTouchEvent:function(a,b,c){if(ccui.ScrollView.prototype.interceptTouchEvent.call(this,a,b,c),a!==ccui.Widget.TOUCH_MOVED){for(c=b;c;){if(c&&c.getParent()===this._innerContainer){this._curSelectedIndex=this.getIndex(c);break}c=c.getParent()}b.isHighlighted()&&this._selectedItemEvent(a)}},getCurSelectedIndex:function(){return this._curSelectedIndex},_onSizeChanged:function(){ccui.ScrollView.prototype._onSizeChanged.call(this);this._refreshViewDirty=
!0},getDescription:function(){return"ListView"},_createCloneInstance:function(){return new ccui.ListView},_copyClonedWidgetChildren:function(a){a=a.getItems();for(var b=0;b<a.length;b++)this.pushBackCustomItem(a[b].clone())},_copySpecialProperties:function(a){a instanceof ccui.ListView&&(ccui.ScrollView.prototype._copySpecialProperties.call(this,a),this.setItemModel(a._model),this.setItemsMargin(a._itemsMargin),this.setGravity(a._gravity),this._listViewEventListener=a._listViewEventListener,this._listViewEventSelector=
a._listViewEventSelector)},forceDoLayout:function(){this._refreshViewDirty&&(this.refreshView(),this._refreshViewDirty=!1);this._innerContainer.forceDoLayout()}});ccui.ListView.create=function(){return new ccui.ListView};ccui.ListView.EVENT_SELECTED_ITEM=0;ccui.ListView.ON_SELECTED_ITEM_START=0;ccui.ListView.ON_SELECTED_ITEM_END=1;ccui.ListView.GRAVITY_LEFT=0;ccui.ListView.GRAVITY_RIGHT=1;ccui.ListView.GRAVITY_CENTER_HORIZONTAL=2;ccui.ListView.GRAVITY_TOP=3;ccui.ListView.GRAVITY_BOTTOM=4;
ccui.ListView.GRAVITY_CENTER_VERTICAL=5;
ccui.PageView=ccui.Layout.extend({_curPageIdx:0,_pages:null,_touchMoveDirection:null,_touchStartLocation:0,_touchMoveStartLocation:0,_movePagePoint:null,_leftBoundaryChild:null,_rightBoundaryChild:null,_leftBoundary:0,_rightBoundary:0,_isAutoScrolling:!1,_autoScrollDistance:0,_autoScrollSpeed:0,_autoScrollDirection:0,_childFocusCancelOffset:0,_pageViewEventListener:null,_pageViewEventSelector:null,_className:"PageView",_customScrollThreshold:0,_usingCustomScrollThreshold:!1,ctor:function(){ccui.Layout.prototype.ctor.call(this);
this._pages=[];this._touchMoveDirection=ccui.PageView.TOUCH_DIR_LEFT;this._rightBoundaryChild=this._leftBoundaryChild=this._movePagePoint=null;this._childFocusCancelOffset=5;this._pageViewEventSelector=this._pageViewEventListener=null;this.setTouchEnabled(!0)},init:function(){return ccui.Layout.prototype.init.call(this)?(this.setClippingEnabled(!0),!0):!1},onEnter:function(){ccui.Layout.prototype.onEnter.call(this);this.scheduleUpdate(!0)},addWidgetToPage:function(a,b,c){if(a&&!(0>b)){var d=this._getPageCount();
0>b||b>=d?c&&(b>d&&cc.log("pageIdx is %d, it will be added as page id [%d]",b,d),b=this._createPage(),b.addChild(a),this.addPage(b)):(b=this._pages[b])&&b.addChild(a)}},_createPage:function(){var a=new ccui.Layout;return a.setContentSize(this.getContentSize()),a},addPage:function(a){a&&-1===this._pages.indexOf(a)&&(this.addChild(a),this._pages.push(a),this._doLayoutDirty=!0)},insertPage:function(a,b){if(!(0>b)&&a&&-1===this._pages.indexOf(a)){var c=this._getPageCount();b>=c?this.addPage(a):(this._pages[b]=
a,this.addChild(a));this._doLayoutDirty=!0}},removePage:function(a){a&&(this.removeChild(a),a=this._pages.indexOf(a),-1<a&&this._pages.splice(a,1),this._doLayoutDirty=!0)},removePageAtIndex:function(a){0>a||a>=this._pages.length||(a=this._pages[a])&&this.removePage(a)},removeAllPages:function(){for(var a=this._pages,b=0,c=a.length;c>b;b++)this.removeChild(a[b]);this._pages.length=0},_updateBoundaryPages:function(){var a=this._pages;return 0>=a.length?(this._leftBoundaryChild=null,void(this._rightBoundaryChild=
null)):(this._leftBoundaryChild=a[0],void(this._rightBoundaryChild=a[a.length-1]))},_getPageCount:function(){return this._pages.length},_getPositionXByIndex:function(a){return this.getContentSize().width*(a-this._curPageIdx)},_onSizeChanged:function(){ccui.Layout.prototype._onSizeChanged.call(this);this._rightBoundary=this.getContentSize().width;this._doLayoutDirty=!0},_updateAllPagesSize:function(){for(var a=this.getContentSize(),b=this._pages,c=0,d=b.length;d>c;c++)b[c].setContentSize(a)},_updateAllPagesPosition:function(){var a=
this._getPageCount();if(0>=a)return void(this._curPageIdx=0);this._curPageIdx>=a&&(this._curPageIdx=a-1);for(var b=this.getContentSize().width,c=this._pages,d=0;a>d;d++)c[d].setPosition(cc.p((d-this._curPageIdx)*b,0))},scrollToPage:function(a){0>a||a>=this._pages.length||(this._curPageIdx=a,this._autoScrollDistance=-this._pages[a].getPosition().x,this._autoScrollSpeed=Math.abs(this._autoScrollDistance)/0.2,this._autoScrollDirection=0<this._autoScrollDistance?ccui.PageView.DIRECTION_RIGHT:ccui.PageView.DIRECTION_LEFT,
this._isAutoScrolling=!0)},update:function(a){this._isAutoScrolling&&this._autoScroll(a)},setLayoutType:function(a){},getLayoutType:function(){return ccui.Layout.ABSOLUTE},_autoScroll:function(a){switch(this._autoScrollDirection){case ccui.PageView.DIRECTION_LEFT:a*=this._autoScrollSpeed;0<=this._autoScrollDistance+a?(a=-this._autoScrollDistance,this._autoScrollDistance=0,this._isAutoScrolling=!1):this._autoScrollDistance+=a;this._scrollPages(-a);this._isAutoScrolling||this._pageTurningEvent();break;
case ccui.PageView.DIRECTION_RIGHT:a*=this._autoScrollSpeed,0>=this._autoScrollDistance-a?(a=this._autoScrollDistance,this._autoScrollDistance=0,this._isAutoScrolling=!1):this._autoScrollDistance-=a,this._scrollPages(a),this._isAutoScrolling||this._pageTurningEvent()}},onTouchMoved:function(a,b){ccui.Layout.prototype.onTouchMoved.call(this,a,b);this._isInterceptTouch||this._handleMoveLogic(a)},onTouchEnded:function(a,b){ccui.Layout.prototype.onTouchEnded.call(this,a,b);this._isInterceptTouch||this._handleReleaseLogic(a);
this._isInterceptTouch=!1},onTouchCancelled:function(a,b){ccui.Layout.prototype.onTouchCancelled.call(this,a,b);this._isInterceptTouch||this._handleReleaseLogic(a);this._isInterceptTouch=!1},_doLayout:function(){this._doLayoutDirty&&(this._updateAllPagesPosition(),this._updateAllPagesSize(),this._updateBoundaryPages(),this._doLayoutDirty=!1)},_movePages:function(a){for(var b=this._pages,c=b.length,d=0;c>d;d++){var e=b[d];e.setPositionX(e.getPositionX()+a)}},_scrollPages:function(a){if(0>=this._pages.length||
!this._leftBoundaryChild||!this._rightBoundaryChild)return!1;var b=a;switch(this._touchMoveDirection){case ccui.PageView.TOUCH_DIR_LEFT:var c=this._rightBoundaryChild.getRightBoundary();if(c+a<=this._rightBoundary)return b=this._rightBoundary-c,this._movePages(b),!1;break;case ccui.PageView.TOUCH_DIR_RIGHT:if(c=this._leftBoundaryChild.getLeftBoundary(),c+a>=this._leftBoundary)return b=this._leftBoundary-c,this._movePages(b),!1}return this._movePages(b),!0},_handleMoveLogic:function(a){a=a.getLocation().x-
a.getPreviousLocation().x;0>a?this._touchMoveDirection=ccui.PageView.TOUCH_DIR_LEFT:0<a&&(this._touchMoveDirection=ccui.PageView.TOUCH_DIR_RIGHT);this._scrollPages(a)},setCustomScrollThreshold:function(a){cc.assert(0<a,"Invalid threshold!");this._customScrollThreshold=a;this.setUsingCustomScrollThreshold(!0)},getCustomScrollThreshold:function(){return this._customScrollThreshold},setUsingCustomScrollThreshold:function(a){this._usingCustomScrollThreshold=a},isUsingCustomScrollThreshold:function(){return this._usingCustomScrollThreshold},
_handleReleaseLogic:function(a){if(!(0>=this._pages.length)&&(a=this._pages[this._curPageIdx])){var b=a.getPosition();a=this._pages.length;var b=b.x,c=this.getSize().width;this._usingCustomScrollThreshold||(this._customScrollThreshold=c/2);c=this._customScrollThreshold;-c>=b?this._curPageIdx>=a-1?this._scrollPages(-b):this.scrollToPage(this._curPageIdx+1):b>=c?0>=this._curPageIdx?this._scrollPages(-b):this.scrollToPage(this._curPageIdx-1):this.scrollToPage(this._curPageIdx)}},interceptTouchEvent:function(a,
b,c){var d=c.getLocation();switch(a){case ccui.Widget.TOUCH_BEGAN:this._touchBeganPosition.x=d.x;this._touchBeganPosition.y=d.y;this._isInterceptTouch=!0;break;case ccui.Widget.TOUCH_MOVED:this._touchMovePosition.x=d.x;this._touchMovePosition.y=d.y;a=0;a=Math.abs(b.getTouchBeganPosition().x-d.x);a>this._childFocusCancelOffset&&(b.setHighlighted(!1),this._handleMoveLogic(c));break;case ccui.Widget.TOUCH_ENDED:case ccui.Widget.TOUCH_CANCELED:this._touchEndPosition.x=d.x,this._touchEndPosition.y=d.y,
this._handleReleaseLogic(c),b.isSwallowTouches()&&(this._isInterceptTouch=!1)}},_pageTurningEvent:function(){this._pageViewEventSelector&&(this._pageViewEventListener?this._pageViewEventSelector.call(this._pageViewEventListener,this,ccui.PageView.EVENT_TURNING):this._pageViewEventSelector(this,ccui.PageView.EVENT_TURNING));this._ccEventCallback&&this._ccEventCallback(this,ccui.PageView.EVENT_TURNING)},addEventListenerPageView:function(a,b){this.addEventListener(a,b)},addEventListener:function(a,b){this._pageViewEventSelector=
a;this._pageViewEventListener=b},getCurPageIndex:function(){return this._curPageIdx},getPages:function(){return this._pages},getPage:function(a){return 0>a||a>=this._pages.length?null:this._pages[a]},getDescription:function(){return"PageView"},_createCloneInstance:function(){return new ccui.PageView},_copyClonedWidgetChildren:function(a){a=a.getPages();for(var b=0;b<a.length;b++)this.addPage(a[b].clone())},_copySpecialProperties:function(a){ccui.Layout.prototype._copySpecialProperties.call(this,a);
this._ccEventCallback=a._ccEventCallback;this._pageViewEventListener=a._pageViewEventListener;this._pageViewEventSelector=a._pageViewEventSelector;this._usingCustomScrollThreshold=a._usingCustomScrollThreshold;this._customScrollThreshold=a._customScrollThreshold}});ccui.PageView.create=function(){return new ccui.PageView};ccui.PageView.EVENT_TURNING=0;ccui.PageView.TOUCH_DIR_LEFT=0;ccui.PageView.TOUCH_DIR_RIGHT=1;ccui.PageView.DIRECTION_LEFT=0;ccui.PageView.DIRECTION_RIGHT=1;
cc.Component=cc.Class.extend({_owner:null,_name:"",_enabled:!0,ctor:function(){this._owner=null;this._name="";this._enabled=!0},init:function(){return!0},onEnter:function(){},onExit:function(){},update:function(a){},serialize:function(a){},isEnabled:function(){return this._enabled},setEnabled:function(a){this._enabled=a},getName:function(){return this._name},setName:function(a){this._name=a},setOwner:function(a){this._owner=a},getOwner:function(){return this._owner}});cc.Component.create=function(){return new cc.Component};
ccui.LayoutComponent_ReferencePoint={BOTTOM_LEFT:0,TOP_LEFT:1,BOTTOM_RIGHT:2,TOP_RIGHT:3};ccui.LayoutComponent_PositionType={Position:0,RelativePosition:1,PreRelativePosition:2,PreRelativePositionEnable:3};ccui.LayoutComponent_SizeType={Size:0,PreSize:1,PreSizeEnable:2};
ccui.LayoutComponent=cc.Component.extend({_horizontalEdge:0,_verticalEdge:0,_leftMargin:0,_rightMargin:0,_bottomMargin:0,_topMargin:0,_usingPositionPercentX:!1,_positionPercentX:0,_usingPositionPercentY:!1,_positionPercentY:0,_usingStretchWidth:!1,_usingStretchHeight:!1,_percentWidth:0,_usingPercentWidth:!1,_percentHeight:0,_usingPercentHeight:!1,_actived:!0,_isPercentOnly:!1,ctor:function(){this._name=ccui.LayoutComponent.NAME},init:function(){return cc.Component.prototype.init.call(this)?!0:!1},
getPercentContentSize:function(){return cc.p(this._percentWidth,this._percentHeight)},setPercentContentSize:function(a){this.setPercentWidth(a.x);this.setPercentHeight(a.y)},setUsingPercentContentSize:function(a){this._usingPercentWidth=this._usingPercentHeight=a},SetActiveEnable:function(a){this._actived=a},getUsingPercentContentSize:function(){return this._usingPercentWidth&&this._usingPercentHeight},getAnchorPosition:function(){return this._owner.getAnchorPoint()},setAnchorPosition:function(a,
b){var c=this._owner.getBoundingBox();this._owner.setAnchorPoint(a,b);var d=this._owner.getBoundingBox(),e=c.x-d.x,c=c.y-d.y,d=this._owner.getPosition();d.x+=e;d.y+=c;this.setPosition(d)},getPosition:function(){return this._owner.getPosition()},setPosition:function(a,b){var c,d=this._getOwnerParent();null!=d?(void 0===b?(c=a.x,b=a.y):c=a,d=d.getContentSize(),0!==d.width?this._positionPercentX=c/d.width:(this._positionPercentX=0,this._usingPositionPercentX&&(c=0)),0!==d.height?this._positionPercentY=
b/d.height:(this._positionPercentY=0,this._usingPositionPercentY&&(b=0)),this._owner.setPosition(c,b),this._refreshHorizontalMargin(),this._refreshVerticalMargin()):this._owner.setPosition(a,b)},isPositionPercentXEnabled:function(){return this._usingPositionPercentX},setPositionPercentXEnabled:function(a){(this._usingPositionPercentX=a)&&(this._horizontalEdge=ccui.LayoutComponent.horizontalEdge.NONE)},getPositionPercentX:function(){return this._positionPercentX},setPositionPercentX:function(a){this._positionPercentX=
a;a=this._getOwnerParent();null!==a&&(this._owner.setPositionX(a.width*this._positionPercentX),this._refreshHorizontalMargin())},isPositionPercentYEnabled:function(){return this._usingPositionPercentY},setPositionPercentYEnabled:function(a){(this._usingPositionPercentY=a)&&(this._verticalEdge=ccui.LayoutComponent.verticalEdge.NONE)},getPositionPercentY:function(){return this._positionPercentY},setPositionPercentY:function(a){this._positionPercentY=a;a=this._getOwnerParent();null!==a&&(this._owner.setPositionY(a.height*
this._positionPercentY),this._refreshVerticalMargin())},getHorizontalEdge:function(){return this._horizontalEdge},setHorizontalEdge:function(a){this._horizontalEdge=a;this._horizontalEdge!==ccui.LayoutComponent.horizontalEdge.NONE&&(this._usingPositionPercentX=!1);var b=this._getOwnerParent();null!==b&&(a=this._owner.getPosition(),b=b.getContentSize(),0!==b.width?this._positionPercentX=a.x/b.width:(this._positionPercentX=0,a.x=0,this._usingPositionPercentX&&this._owner.setPosition(a)),this._refreshHorizontalMargin())},
getVerticalEdge:function(){return this._verticalEdge},setVerticalEdge:function(a){this._verticalEdge=a;this._verticalEdge!==ccui.LayoutComponent.verticalEdge.NONE&&(this._usingPositionPercentY=!1);var b=this._getOwnerParent();null!==b&&(a=this._owner.getPosition(),b=b.getContentSize(),0!==b.height?this._positionPercentY=a.y/b.height:(this._positionPercentY=0,a.y=0,this._usingPositionPercentY&&this._owner.setPosition(a)),this._refreshVerticalMargin())},getLeftMargin:function(){return this._leftMargin},
setLeftMargin:function(a){this._leftMargin=a},getRightMargin:function(){return this._rightMargin},setRightMargin:function(a){this._rightMargin=a},getTopMargin:function(){return this._topMargin},setTopMargin:function(a){this._topMargin=a},getBottomMargin:function(){return this._bottomMargin},setBottomMargin:function(a){this._bottomMargin=a},getSize:function(){return this.getOwner().getContentSize()},setSize:function(a){var b=this._getOwnerParent();null!==b?(b=b.getContentSize(),0!==b.width?this._percentWidth=
a.width/b.width:(this._percentWidth=0,this._usingPercentWidth&&(a.width=0)),0!==b.height?this._percentHeight=a.height/b.height:(this._percentHeight=0,this._usingPercentHeight&&(a.height=0)),this._owner.setContentSize(a),this._refreshHorizontalMargin(),this._refreshVerticalMargin()):this._owner.setContentSize(a)},isPercentWidthEnabled:function(){return this._usingPercentWidth},setPercentWidthEnabled:function(a){(this._usingPercentWidth=a)&&(this._usingStretchWidth=!1)},getSizeWidth:function(){return this._owner.width},
setSizeWidth:function(a){var b=this._owner.getContentSize();b.width=a;a=this._getOwnerParent();null!==a?(a=a.getContentSize(),0!==a.width?this._percentWidth=b.width/a.width:(this._percentWidth=0,this._usingPercentWidth&&(b.width=0)),this._owner.setContentSize(b),this._refreshHorizontalMargin()):this._owner.setContentSize(b)},getPercentWidth:function(){return this._percentWidth},setPercentWidth:function(a){this._percentWidth=a;a=this._getOwnerParent();if(null!==a){var b=this._owner.getContentSize();
b.width=a.width*this._percentWidth;this._owner.setContentSize(b);this._refreshHorizontalMargin()}},isPercentHeightEnabled:function(){return this._usingPercentHeight},setPercentHeightEnabled:function(a){(this._usingPercentHeight=a)&&(this._usingStretchHeight=!1)},getSizeHeight:function(){return this._owner.height},setSizeHeight:function(a){var b=this._owner.getContentSize();b.height=a;a=this._getOwnerParent();null!==a?(a=a.getContentSize(),0!==a.height?this._percentHeight=b.height/a.height:(this._percentHeight=
0,this._usingPercentHeight&&(b.height=0)),this._owner.setContentSize(b),this._refreshVerticalMargin()):this._owner.setContentSize(b)},getPercentHeight:function(){return this._percentHeight},setPercentHeight:function(a){this._percentHeight=a;a=this._getOwnerParent();if(null!==a){var b=this._owner.getContentSize();b.height=a.height*this._percentHeight;this._owner.setContentSize(b);this._refreshVerticalMargin()}},isStretchWidthEnabled:function(){return this._usingStretchWidth},setStretchWidthEnabled:function(a){(this._usingStretchWidth=
a)&&(this._usingPercentWidth=!1)},isStretchHeightEnabled:function(){return this._usingStretchHeight},setStretchHeightEnabled:function(a){(this._usingStretchHeight=a)&&(this._usingPercentHeight=!1)},setPercentOnlyEnabled:function(a){this._isPercentOnly=a},setActiveEnabled:function(a){this._actived=a},refreshLayout:function(){if(this._actived){var a=this._getOwnerParent();if(null!==a){var a=a.getContentSize(),b=this._owner,c=b.getAnchorPoint(),d=b.getContentSize(),e=b.getPosition();switch(this._horizontalEdge){case ccui.LayoutComponent.horizontalEdge.NONE:this._usingStretchWidth&&
!this._isPercentOnly?(d.width=a.width*this._percentWidth,e.x=this._leftMargin+c.x*d.width):(this._usingPositionPercentX&&(e.x=a.width*this._positionPercentX),this._usingPercentWidth&&(d.width=a.width*this._percentWidth));break;case ccui.LayoutComponent.horizontalEdge.LEFT:if(this._isPercentOnly)break;(this._usingPercentWidth||this._usingStretchWidth)&&(d.width=a.width*this._percentWidth);e.x=this._leftMargin+c.x*d.width;break;case ccui.LayoutComponent.horizontalEdge.RIGHT:if(this._isPercentOnly)break;
(this._usingPercentWidth||this._usingStretchWidth)&&(d.width=a.width*this._percentWidth);e.x=a.width-(this._rightMargin+(1-c.x)*d.width);break;case ccui.LayoutComponent.horizontalEdge.CENTER:if(this._isPercentOnly)break;this._usingStretchWidth?(d.width=a.width-this._leftMargin-this._rightMargin,0>d.width&&(d.width=0),e.x=this._leftMargin+c.x*d.width):(this._usingPercentWidth&&(d.width=a.width*this._percentWidth),e.x=a.width*this._positionPercentX)}switch(this._verticalEdge){case ccui.LayoutComponent.verticalEdge.NONE:this._usingStretchHeight&&
!this._isPercentOnly?(d.height=a.height*this._percentHeight,e.y=this._bottomMargin+c.y*d.height):(this._usingPositionPercentY&&(e.y=a.height*this._positionPercentY),this._usingPercentHeight&&(d.height=a.height*this._percentHeight));break;case ccui.LayoutComponent.verticalEdge.BOTTOM:if(this._isPercentOnly)break;(this._usingPercentHeight||this._usingStretchHeight)&&(d.height=a.height*this._percentHeight);e.y=this._bottomMargin+c.y*d.height;break;case ccui.LayoutComponent.verticalEdge.TOP:if(this._isPercentOnly)break;
(this._usingPercentHeight||this._usingStretchHeight)&&(d.height=a.height*this._percentHeight);e.y=a.height-(this._topMargin+(1-c.y)*d.height);break;case ccui.LayoutComponent.verticalEdge.CENTER:if(this._isPercentOnly)break;this._usingStretchHeight?(d.height=a.height-this._topMargin-this._bottomMargin,0>d.height&&(d.height=0),e.y=this._bottomMargin+c.y*d.height):(this._usingPercentHeight&&(d.height=a.height*this._percentHeight),e.y=a.height*this._positionPercentY)}b.setPosition(e);b.setContentSize(d);
ccui.helper.doLayout(b)}}},_getOwnerParent:function(){return this._owner?this._owner.getParent():null},_refreshHorizontalMargin:function(){var a=this._getOwnerParent();if(null!==a){var b=this._owner.getPosition(),c=this._owner.getAnchorPoint(),d=this._owner.getContentSize(),a=a.getContentSize();this._leftMargin=b.x-c.x*d.width;this._rightMargin=a.width-(b.x+(1-c.x)*d.width)}},_refreshVerticalMargin:function(){var a=this._getOwnerParent();if(null!==a){var b=this._owner.getPosition(),c=this._owner.getAnchorPoint(),
d=this._owner.getContentSize(),a=a.getContentSize();this._bottomMargin=b.y-c.y*d.height;this._topMargin=a.height-(b.y+(1-c.y)*d.height)}}});ccui.LayoutComponent.horizontalEdge={NONE:0,LEFT:1,RIGHT:2,CENTER:3};ccui.LayoutComponent.verticalEdge={NONE:0,BOTTOM:1,TOP:2,CENTER:3};ccui.LayoutComponent.NAME="__ui_layout";ccui.LayoutComponent.bindLayoutComponent=function(a){var b=a.getComponent(ccui.LayoutComponent.NAME);return void 0!==b?b:(b=new ccui.LayoutComponent,b&&b.init()?(a.addComponent(b),b):null)};
cc.ComponentContainer=cc.Class.extend({_components:null,_owner:null,ctor:function(a){this._components=null;this._owner=a},getComponent:function(a){if(!a)throw"cc.ComponentContainer.getComponent(): name should be non-null";return a=a.trim(),this._components||(this._components={}),this._components[a]},add:function(a){if(!a)throw"cc.ComponentContainer.add(): component should be non-null";if(a.getOwner())return cc.log("cc.ComponentContainer.add(): Component already added. It can't be added again"),!1;
null==this._components&&(this._components={},this._owner.scheduleUpdate());return this._components[a.getName()]?(cc.log("cc.ComponentContainer.add(): Component already added. It can't be added again"),!1):(a.setOwner(this._owner),this._components[a.getName()]=a,a.onEnter(),!0)},remove:function(a){if(!a)throw"cc.ComponentContainer.remove(): name should be non-null";return this._components?a instanceof cc.Component?this._removeByComponent(a):(a=a.trim(),this._removeByComponent(this._components[a])):
!1},_removeByComponent:function(a){return a?(a.onExit(),a.setOwner(null),delete this._components[a.getName()],!0):!1},removeAll:function(){if(this._components){var a=this._components,b;for(b in a){var c=a[b];c.onExit();c.setOwner(null);delete a[b]}this._owner.unscheduleUpdate();this._components=null}},_alloc:function(){this._components={}},visit:function(a){if(this._components){var b=this._components,c;for(c in b)b[c].update(a)}},isEmpty:function(){return this._components?0===this._components.length:
!0}});var ccs=ccs||{};ccs.Class=ccs.Class||cc.Class;ccs.Class.extend=ccs.Class.extend||cc.Class.extend;ccs.Node=ccs.Node||cc.Node;ccs.Node.extend=ccs.Node.extend||cc.Node.extend;ccs.Sprite=ccs.Sprite||cc.Sprite;ccs.Sprite.extend=ccs.Sprite.extend||cc.Sprite.extend;ccs.Component=ccs.Component||cc.Component;ccs.Component.extend=ccs.Component.extend||cc.Component.extend;ccs.cocostudioVersion="v1.3.0.0";ccs.VERSION_COMBINED=0.3;ccs.VERSION_CHANGE_ROTATION_RANGE=1;ccs.VERSION_COLOR_READING=1.1;
ccs.MAX_VERTEXZ_VALUE=5E6;ccs.ARMATURE_MAX_CHILD=50;ccs.ARMATURE_MAX_ZORDER=100;ccs.ARMATURE_MAX_COUNT=ccs.MAX_VERTEXZ_VALUE/ccs.ARMATURE_MAX_CHILD/ccs.ARMATURE_MAX_ZORDER;ccs.AUTO_ADD_SPRITE_FRAME_NAME_PREFIX=!1;ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT=!1;ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX=!1;ccs.armatureVersion=function(){return"v1.1.0.0"};ccs.CONST_VERSION="version";ccs.CONST_VERSION_2_0=2;ccs.CONST_VERSION_COMBINED=0.3;ccs.CONST_ARMATURES="armatures";ccs.CONST_ARMATURE="armature";
ccs.CONST_BONE="b";ccs.CONST_DISPLAY="d";ccs.CONST_ANIMATIONS="animations";ccs.CONST_ANIMATION="animation";ccs.CONST_MOVEMENT="mov";ccs.CONST_FRAME="f";ccs.CONST_TEXTURE_ATLAS="TextureAtlas";ccs.CONST_SUB_TEXTURE="SubTexture";ccs.CONST_SKELETON="skeleton";ccs.CONST_A_NAME="name";ccs.CONST_A_DURATION="dr";ccs.CONST_A_FRAME_INDEX="fi";ccs.CONST_A_DURATION_TO="to";ccs.CONST_A_DURATION_TWEEN="drTW";ccs.CONST_A_LOOP="lp";ccs.CONST_A_MOVEMENT_SCALE="sc";ccs.CONST_A_MOVEMENT_DELAY="dl";
ccs.CONST_A_DISPLAY_INDEX="dI";ccs.CONST_A_PLIST="plist";ccs.CONST_A_PARENT="parent";ccs.CONST_A_SKEW_X="kX";ccs.CONST_A_SKEW_Y="kY";ccs.CONST_A_SCALE_X="cX";ccs.CONST_A_SCALE_Y="cY";ccs.CONST_A_Z="z";ccs.CONST_A_EVENT="evt";ccs.CONST_A_SOUND="sd";ccs.CONST_A_SOUND_EFFECT="sdE";ccs.CONST_A_TWEEN_EASING="twE";ccs.CONST_A_EASING_PARAM="twEP";ccs.CONST_A_TWEEN_ROTATE="twR";ccs.CONST_A_IS_ARMATURE="isArmature";ccs.CONST_A_DISPLAY_TYPE="displayType";ccs.CONST_A_MOVEMENT="mov";ccs.CONST_A_X="x";
ccs.CONST_A_Y="y";ccs.CONST_A_COCOS2DX_X="cocos2d_x";ccs.CONST_A_COCOS2DX_Y="cocos2d_y";ccs.CONST_A_WIDTH="width";ccs.CONST_A_HEIGHT="height";ccs.CONST_A_PIVOT_X="pX";ccs.CONST_A_PIVOT_Y="pY";ccs.CONST_A_COCOS2D_PIVOT_X="cocos2d_pX";ccs.CONST_A_COCOS2D_PIVOT_Y="cocos2d_pY";ccs.CONST_A_BLEND_TYPE="bd";ccs.CONST_A_BLEND_SRC="bd_src";ccs.CONST_A_BLEND_DST="bd_dst";ccs.CONST_A_ALPHA="a";ccs.CONST_A_RED="r";ccs.CONST_A_GREEN="g";ccs.CONST_A_BLUE="b";ccs.CONST_A_ALPHA_OFFSET="aM";
ccs.CONST_A_RED_OFFSET="rM";ccs.CONST_A_GREEN_OFFSET="gM";ccs.CONST_A_BLUE_OFFSET="bM";ccs.CONST_A_COLOR_TRANSFORM="colorTransform";ccs.CONST_A_TWEEN_FRAME="tweenFrame";ccs.CONST_CONTOUR="con";ccs.CONST_CONTOUR_VERTEX="con_vt";ccs.CONST_FL_NAN="NaN";ccs.CONST_FRAME_DATA="frame_data";ccs.CONST_MOVEMENT_BONE_DATA="mov_bone_data";ccs.CONST_MOVEMENT_DATA="mov_data";ccs.CONST_ANIMATION_DATA="animation_data";ccs.CONST_DISPLAY_DATA="display_data";ccs.CONST_SKIN_DATA="skin_data";ccs.CONST_BONE_DATA="bone_data";
ccs.CONST_ARMATURE_DATA="armature_data";ccs.CONST_CONTOUR_DATA="contour_data";ccs.CONST_TEXTURE_DATA="texture_data";ccs.CONST_VERTEX_POINT="vertex";ccs.CONST_COLOR_INFO="color";ccs.CONST_CONFIG_FILE_PATH="config_file_path";ccs.CONST_CONTENT_SCALE="content_scale";ccs.DataInfo=function(){this.asyncStruct=null;this.configFileQueue=[];this.contentScale=1;this.baseFilePath=this.filename="";this.cocoStudioVersion=this.flashToolVersion=0};
ccs.dataReaderHelper={ConfigType:{DragonBone_XML:0,CocoStudio_JSON:1,CocoStudio_Binary:2},_configFileList:[],_flashToolVersion:ccs.CONST_VERSION_2_0,_positionReadScale:1,_asyncRefCount:0,_asyncRefTotalCount:0,_dataQueue:null,setPositionReadScale:function(a){this._positionReadScale=a},getPositionReadScale:function(){return this._positionReadScale},addDataFromFile:function(a){if(-1===this._configFileList.indexOf(a)){this._configFileList.push(a);var b=this._initBaseFilePath(a),c=cc.path.extname(a).toLowerCase(),
d=new ccs.DataInfo;d.filename=a;d.basefilePath=b;".xml"===c?ccs.dataReaderHelper.addDataFromXML(a,d):".json"===c||".exportjson"===c?ccs.dataReaderHelper.addDataFromJson(a,d):".csb"===c&&ccs.dataReaderHelper.addDataFromBinaryCache(a,d)}},addDataFromFileAsync:function(a,b,c,d,e){if(-1!==this._configFileList.indexOf(c))return void(e&&d&&(0===this._asyncRefTotalCount&&0===this._asyncRefCount?this._asyncCallBack(d,e,1):this._asyncCallBack(d,e,(this._asyncRefTotalCount-this._asyncRefCount)/this._asyncRefTotalCount)));
this._asyncRefTotalCount++;this._asyncRefCount++;var f=this;cc.director.getScheduler().schedule(function(){f.addDataFromFile(c);f._asyncRefCount--;f._asyncCallBack(d,e,(f._asyncRefTotalCount-f._asyncRefCount)/f._asyncRefTotalCount)},this,0.1,!1,0,!1,"armatrueDataHelper")},removeConfigFile:function(a){for(var b=this._configFileList,c=b.length,d=b[c],e=0;c>e;e++)b[e]===a&&(d=e);d!==b[c]&&cc.arrayRemoveObject(b,a)},addDataFromCache:function(a,b){if(!a)return void cc.log("XML error  or  XML is empty.");
b.flashToolVersion=parseFloat(a.getAttribute(ccs.CONST_VERSION));var c,d=a.querySelectorAll(ccs.CONST_SKELETON+" \x3e "+ccs.CONST_ARMATURES+" \x3e  "+ccs.CONST_ARMATURE),e=ccs.armatureDataManager;for(c=0;c<d.length;c++){var f=this.decodeArmature(d[c],b);e.addArmatureData(f.name,f,b.filename)}d=a.querySelectorAll(ccs.CONST_SKELETON+" \x3e "+ccs.CONST_ANIMATIONS+" \x3e  "+ccs.CONST_ANIMATION);for(c=0;c<d.length;c++)f=this.decodeAnimation(d[c],b),e.addAnimationData(f.name,f,b.filename);d=a.querySelectorAll(ccs.CONST_SKELETON+
" \x3e "+ccs.CONST_TEXTURE_ATLAS+" \x3e  "+ccs.CONST_SUB_TEXTURE);for(c=0;c<d.length;c++)f=this.decodeTexture(d[c],b),e.addTextureData(f.name,f,b.filename)},decodeArmature:function(a,b){var c=new ccs.ArmatureData;c.init();c.name=a.getAttribute(ccs.CONST_A_NAME);for(var d=a.querySelectorAll(ccs.CONST_ARMATURE+" \x3e "+ccs.CONST_BONE),e=0;e<d.length;e++){var f=d[e],g=f.getAttribute(ccs.CONST_A_PARENT),h=null;if(g)for(var k=0;k<d.length&&(h=d[k],g!=d[k].getAttribute(ccs.CONST_A_NAME));k++);f=this.decodeBone(f,
h,b);c.addBoneData(f)}return c},decodeArmatureFromJSON:function(a,b){var c=new ccs.ArmatureData;c.init();var d=a[ccs.CONST_A_NAME];d&&(c.name=d);b.cocoStudioVersion=c.dataVersion=a[ccs.CONST_VERSION]||0.1;for(var d=a[ccs.CONST_BONE_DATA],e=0;e<d.length;e++){var f=this.decodeBoneFromJson(d[e],b);c.addBoneData(f)}return c},decodeBone:function(a,b,c){b=new ccs.BoneData;b.init();b.name=a.getAttribute(ccs.CONST_A_NAME);b.parentName=a.getAttribute(ccs.CONST_A_PARENT)||"";b.zOrder=parseInt(a.getAttribute(ccs.CONST_A_Z))||
0;a=a.querySelectorAll(ccs.CONST_BONE+" \x3e "+ccs.CONST_DISPLAY);for(var d=0;d<a.length;d++){var e=this.decodeBoneDisplay(a[d],c);b.addDisplayData(e)}return b},decodeBoneFromJson:function(a,b){var c=new ccs.BoneData;c.init();this.decodeNodeFromJson(c,a,b);c.name=a[ccs.CONST_A_NAME]||"";c.parentName=a[ccs.CONST_A_PARENT]||"";for(var d=a[ccs.CONST_DISPLAY_DATA]||[],e=0;e<d.length;e++){var f=this.decodeBoneDisplayFromJson(d[e],b);c.addDisplayData(f)}return c},decodeBoneDisplay:function(a,b){var c=null;
1===(parseFloat(a.getAttribute(ccs.CONST_A_IS_ARMATURE))||0)?(c=new ccs.ArmatureDisplayData,c.displayType=ccs.DISPLAY_TYPE_ARMATURE):(c=new ccs.SpriteDisplayData,c.displayType=ccs.DISPLAY_TYPE_SPRITE);var d=a.getAttribute(ccs.CONST_A_NAME)||"";return d&&(c.displayName=d),c},decodeBoneDisplayFromJson:function(a,b){var c=a[ccs.CONST_A_DISPLAY_TYPE]||ccs.DISPLAY_TYPE_SPRITE,d=null;switch(c){case ccs.DISPLAY_TYPE_SPRITE:var d=new ccs.SpriteDisplayData,e=a[ccs.CONST_A_NAME];null!=e&&(d.displayName=e);
if(e=(a[ccs.CONST_SKIN_DATA]||[])[0]){var f=d.skinData;f.x=e[ccs.CONST_A_X]*this._positionReadScale;f.y=e[ccs.CONST_A_Y]*this._positionReadScale;f.scaleX=null==e[ccs.CONST_A_SCALE_X]?1:e[ccs.CONST_A_SCALE_X];f.scaleY=null==e[ccs.CONST_A_SCALE_Y]?1:e[ccs.CONST_A_SCALE_Y];f.skewX=null==e[ccs.CONST_A_SKEW_X]?1:e[ccs.CONST_A_SKEW_X];f.skewY=null==e[ccs.CONST_A_SKEW_Y]?1:e[ccs.CONST_A_SKEW_Y];f.x*=b.contentScale;f.y*=b.contentScale}break;case ccs.DISPLAY_TYPE_ARMATURE:d=new ccs.ArmatureDisplayData;e=a[ccs.CONST_A_NAME];
null!=e&&(d.displayName=a[ccs.CONST_A_NAME]);break;case ccs.DISPLAY_TYPE_PARTICLE:d=new ccs.ParticleDisplayData;e=a[ccs.CONST_A_PLIST];null!=e&&(b.asyncStruct?d.displayName=b.asyncStruct.basefilePath+e:d.displayName=b.basefilePath+e);break;default:d=new ccs.SpriteDisplayData}return d.displayType=c,d},decodeAnimation:function(a,b){var c=new ccs.AnimationData,d=a.getAttribute(ccs.CONST_A_NAME),e=ccs.armatureDataManager.getArmatureData(d);c.name=d;for(var d=a.querySelectorAll(ccs.CONST_ANIMATION+" \x3e "+
ccs.CONST_MOVEMENT),f=null,g=0;g<d.length;g++)f=d[g],f=this.decodeMovement(f,e,b),c.addMovement(f);return c},decodeAnimationFromJson:function(a,b){var c=new ccs.AnimationData;a[ccs.CONST_A_NAME]&&(c.name=a[ccs.CONST_A_NAME]);for(var d=a[ccs.CONST_MOVEMENT_DATA]||[],e=0;e<d.length;e++){var f=this.decodeMovementFromJson(d[e],b);c.addMovement(f)}return c},decodeMovement:function(a,b,c){var d=new ccs.MovementData;d.name=a.getAttribute(ccs.CONST_A_NAME);var e,f=0;e=a.getAttribute(ccs.CONST_A_DURATION);
d.duration=null==e?0:parseFloat(e);e=a.getAttribute(ccs.CONST_A_DURATION_TO);d.durationTo=null==e?0:parseFloat(e);e=a.getAttribute(ccs.CONST_A_DURATION_TWEEN);d.durationTween=null==e?0:parseFloat(e);e=a.getAttribute(ccs.CONST_A_LOOP);d.loop=e?Boolean(parseFloat(e)):!0;(e=a.getAttribute(ccs.CONST_A_TWEEN_EASING))&&(e!=ccs.CONST_FL_NAN?(f=null==e?0:parseFloat(e),d.tweenEasing=2===f?ccs.TweenType.SINE_EASEINOUT:f):d.tweenEasing=ccs.TweenType.LINEAR);a=a.querySelectorAll(ccs.CONST_MOVEMENT+" \x3e "+ccs.CONST_BONE);
e=null;for(f=0;f<a.length;f++){e=a[f];var g=e.getAttribute(ccs.CONST_A_NAME);if(!d.getMovementBoneData(g)){var g=b.getBoneData(g),h=g.parentName,k=null;if(""!==h)for(var m=0;m<a.length&&(k=a[m],h!==k.getAttribute(ccs.CONST_A_NAME));m++);e=this.decodeMovementBone(e,k,g,c);d.addMovementBoneData(e)}}return d},decodeMovementFromJson:function(a,b){var c=new ccs.MovementData;c.loop=null==a[ccs.CONST_A_LOOP]?!1:a[ccs.CONST_A_LOOP];c.durationTween=a[ccs.CONST_A_DURATION_TWEEN]||0;c.durationTo=a[ccs.CONST_A_DURATION_TO]||
0;c.duration=a[ccs.CONST_A_DURATION]||0;null==a[ccs.CONST_A_DURATION]?c.scale=1:c.scale=null==a[ccs.CONST_A_MOVEMENT_SCALE]?1:a[ccs.CONST_A_MOVEMENT_SCALE];c.tweenEasing=null==a[ccs.CONST_A_TWEEN_EASING]?ccs.TweenType.LINEAR:a[ccs.CONST_A_TWEEN_EASING];var d=a[ccs.CONST_A_NAME];d&&(c.name=d);for(var d=a[ccs.CONST_MOVEMENT_BONE_DATA]||[],e=0;e<d.length;e++){var f=this.decodeMovementBoneFromJson(d[e],b);c.addMovementBoneData(f)}return c},decodeMovementBone:function(a,b,c,d){var e=new ccs.MovementBoneData;
e.init();var f,g;a&&(f=parseFloat(a.getAttribute(ccs.CONST_A_MOVEMENT_SCALE))||0,e.scale=f,g=parseFloat(a.getAttribute(ccs.CONST_A_MOVEMENT_DELAY))||0,0<g&&(g-=1),e.delay=g);var h=0;g=f=0;var k=null,m=[];if(null!=b){for(var n=b.querySelectorAll(ccs.CONST_BONE+" \x3e "+ccs.CONST_FRAME),h=0;h<n.length;h++)m.push(n[h]);h=m.length}e.name=a.getAttribute(ccs.CONST_A_NAME);a=a.querySelectorAll(ccs.CONST_BONE+" \x3e "+ccs.CONST_FRAME);for(var p=n=0,r=0;r<a.length;r++){var s=a[r];if(b)for(;h>n&&(k?f>p||p>=
f+g:1);)k=m[n],f+=g,g=parseFloat(k.getAttribute(ccs.CONST_A_DURATION)),n++;s=this.decodeFrame(s,k,c,d);e.addFrameData(s);s.frameID=p;p+=s.duration;e.duration=p}b=e.frameList;c=Math.PI;for(h=b.length-1;0<=h;h--)0<h&&(d=b[h].skewX-b[h-1].skewX,f=b[h].skewY-b[h-1].skewY,(-c>d||d>c)&&(b[h-1].skewX=0>d?b[h-1].skewX-2*c:b[h-1].skewX+2*c),(-c>f||f>c)&&(b[h-1].skewY=0>f?b[h-1].skewY-2*c:b[h-1].skewY+2*c));b=new ccs.FrameData;return b.copy(e.frameList[e.frameList.length-1]),b.frameID=e.duration,e.addFrameData(b),
e},decodeMovementBoneFromJson:function(a,b){var c=new ccs.MovementBoneData;c.init();c.delay=a[ccs.CONST_A_MOVEMENT_DELAY]||0;var d=a[ccs.CONST_A_NAME];d&&(c.name=d);for(var e=(a[ccs.CONST_FRAME_DATA]||[]).length,d=0;e>d;d++){var f=this.decodeFrameFromJson(a[ccs.CONST_FRAME_DATA][d],b);c.addFrameData(f);b.cocoStudioVersion<ccs.CONST_VERSION_COMBINED&&(f.frameID=c.duration,c.duration+=f.duration)}if(b.cocoStudioVersion<ccs.VERSION_CHANGE_ROTATION_RANGE){e=c.frameList;f=Math.PI;for(d=e.length-1;0<=d;d--)if(0<
d){var g=e[d].skewX-e[d-1].skewX,h=e[d].skewY-e[d-1].skewY;(-f>g||g>f)&&(e[d-1].skewX=0>g?e[d-1].skewX-2*f:e[d-1].skewX+2*f);(-f>h||h>f)&&(e[d-1].skewY=0>h?e[d-1].skewY-2*f:e[d-1].skewY+2*f)}}b.cocoStudioVersion<ccs.CONST_VERSION_COMBINED&&0<c.frameList.length&&(f=new ccs.FrameData,f.copy(c.frameList[c.frameList.length-1]),c.addFrameData(f),f.frameID=c.duration);return c},decodeFrame:function(a,b,c,d){var e=0,f=0,g=0,h=0,k=0,m=0,n=0,p=0,r=0,s=0,v=0,u=0;c=new ccs.FrameData;c.strMovement=a.getAttribute(ccs.CONST_A_MOVEMENT)||
"";c.movement=c.strMovement;c.strEvent=a.getAttribute(ccs.CONST_A_EVENT)||"";c.event=c.strEvent;c.strSound=a.getAttribute(ccs.CONST_A_SOUND)||"";c.sound=c.strSound;c.strSoundEffect=a.getAttribute(ccs.CONST_A_SOUND_EFFECT)||"";c.soundEffect=c.strSoundEffect;var t=a.getAttribute(ccs.CONST_A_TWEEN_FRAME);if(c.isTween=!(void 0!=t&&"false"===t),d.flashToolVersion>=ccs.CONST_VERSION_2_0?(e=a.getAttribute(ccs.CONST_A_COCOS2DX_X),e&&(c.x=parseFloat(e),c.x*=this._positionReadScale),f=a.getAttribute(ccs.CONST_A_COCOS2DX_Y),
f&&(c.y=-parseFloat(f),c.y*=this._positionReadScale)):(e=a.getAttribute(ccs.CONST_A_X),e&&(c.x=parseFloat(e),c.x*=this._positionReadScale),f=a.getAttribute(ccs.CONST_A_Y),f&&(c.y=-parseFloat(f),c.y*=this._positionReadScale)),g=a.getAttribute(ccs.CONST_A_SCALE_X),null!=g&&(c.scaleX=parseFloat(g)),h=a.getAttribute(ccs.CONST_A_SCALE_Y),null!=h&&(c.scaleY=parseFloat(h)),k=a.getAttribute(ccs.CONST_A_SKEW_X),null!=k&&(c.skewX=cc.degreesToRadians(parseFloat(k))),m=a.getAttribute(ccs.CONST_A_SKEW_Y),null!=
m&&(c.skewY=cc.degreesToRadians(-parseFloat(m))),p=a.getAttribute(ccs.CONST_A_DURATION),null!=p&&(c.duration=parseFloat(p)),r=a.getAttribute(ccs.CONST_A_DISPLAY_INDEX),null!=r&&(c.displayIndex=parseFloat(r)),s=a.getAttribute(ccs.CONST_A_Z),null!=s&&(c.zOrder=parseInt(s)),n=a.getAttribute(ccs.CONST_A_TWEEN_ROTATE),null!=n&&(c.tweenRotate=parseFloat(n)),u=a.getAttribute(ccs.CONST_A_BLEND_TYPE),null!=u)switch(e=c.blendFunc,u){case ccs.BLEND_TYPE_NORMAL:e.src=cc.BLEND_SRC;e.dst=cc.BLEND_DST;break;case ccs.BLEND_TYPE_ADD:e.src=
cc.SRC_ALPHA;e.dst=cc.ONE;break;case ccs.BLEND_TYPE_MULTIPLY:e.src=cc.DST_COLOR;e.dst=cc.ONE_MINUS_SRC_ALPHA;break;case ccs.BLEND_TYPE_SCREEN:e.src=cc.ONE;e.dst=cc.ONE_MINUS_DST_COLOR;break;default:c.blendFunc.src=cc.BLEND_SRC,c.blendFunc.dst=cc.BLEND_DST}if((n=a.querySelectorAll(ccs.CONST_FRAME+" \x3e "+ccs.CONST_A_COLOR_TRANSFORM))&&0<n.length)n=n[0],u=parseFloat(n.getAttribute(ccs.CONST_A_ALPHA))||0,e=parseFloat(n.getAttribute(ccs.CONST_A_RED))||0,f=parseFloat(n.getAttribute(ccs.CONST_A_GREEN))||
0,g=parseFloat(n.getAttribute(ccs.CONST_A_BLUE))||0,h=parseFloat(n.getAttribute(ccs.CONST_A_ALPHA_OFFSET))||0,k=parseFloat(n.getAttribute(ccs.CONST_A_RED_OFFSET))||0,m=parseFloat(n.getAttribute(ccs.CONST_A_GREEN_OFFSET))||0,n=parseFloat(n.getAttribute(ccs.CONST_A_BLUE_OFFSET))||0,c.a=2.55*h+u,c.r=2.55*k+e,c.g=2.55*m+f,c.b=2.55*n+g,c.isUseColorInfo=!0;u=a.getAttribute(ccs.CONST_A_TWEEN_EASING);if(null!=u&&(u!=ccs.CONST_FL_NAN?(v=a.getAttribute(ccs.CONST_A_TWEEN_EASING),v&&(c.tweenEasing=2===v?ccs.TweenType.SINE_EASEINOUT:
v)):c.tweenEasing=ccs.TweenType.LINEAR),b)a=new ccs.BaseData,d.flashToolVersion>=ccs.CONST_VERSION_2_0?(a.x=parseFloat(b.getAttribute(ccs.CONST_A_COCOS2DX_X)),a.y=parseFloat(b.getAttribute(ccs.CONST_A_COCOS2DX_Y))):(a.x=parseFloat(b.getAttribute(ccs.CONST_A_X)),a.y=parseFloat(b.getAttribute(ccs.CONST_A_Y))),a.skewX=parseFloat(b.getAttribute(ccs.CONST_A_SKEW_X)),a.skewY=parseFloat(b.getAttribute(ccs.CONST_A_SKEW_Y)),a.y=-a.y,a.skewX=cc.degreesToRadians(a.skewX),a.skewY=cc.degreesToRadians(-a.skewY),
ccs.TransformHelp.transformFromParent(c,a);return c},decodeFrameFromJson:function(a,b){var c=new ccs.FrameData;this.decodeNodeFromJson(c,a,b);c.tweenEasing=a[ccs.CONST_A_TWEEN_EASING]||ccs.TweenType.LINEAR;c.displayIndex=a[ccs.CONST_A_DISPLAY_INDEX];var d=null==a[ccs.CONST_A_BLEND_DST]?cc.BLEND_DST:a[ccs.CONST_A_BLEND_DST];c.blendFunc.src=null==a[ccs.CONST_A_BLEND_SRC]?cc.BLEND_SRC:a[ccs.CONST_A_BLEND_SRC];c.blendFunc.dst=d;c.isTween=null==a[ccs.CONST_A_TWEEN_FRAME]?!0:a[ccs.CONST_A_TWEEN_FRAME];
d=a[ccs.CONST_A_EVENT];null!=d&&(c.strEvent=d,c.event=d);b.cocoStudioVersion<ccs.CONST_VERSION_COMBINED?c.duration=null==a[ccs.CONST_A_DURATION]?1:a[ccs.CONST_A_DURATION]:c.frameID=a[ccs.CONST_A_FRAME_INDEX];for(var d=a[ccs.CONST_A_EASING_PARAM]||[],e=0;e<d.length;e++)c.easingParams[e]=d[e];return c},decodeTexture:function(a,b){var c=new ccs.TextureData;c.init();a.getAttribute(ccs.CONST_A_NAME)&&(c.name=a.getAttribute(ccs.CONST_A_NAME));var d,e;b.flashToolVersion>=ccs.CONST_VERSION_2_0?(d=parseFloat(a.getAttribute(ccs.CONST_A_COCOS2D_PIVOT_X))||
0,e=parseFloat(a.getAttribute(ccs.CONST_A_COCOS2D_PIVOT_Y))||0):(d=parseFloat(a.getAttribute(ccs.CONST_A_PIVOT_X))||0,e=parseFloat(a.getAttribute(ccs.CONST_A_PIVOT_Y))||0);var f=parseFloat(a.getAttribute(ccs.CONST_A_WIDTH))||0,g=parseFloat(a.getAttribute(ccs.CONST_A_HEIGHT))||0;c.pivotX=d/f;c.pivotY=(g-e)/g;d=a.querySelectorAll(ccs.CONST_SUB_TEXTURE+" \x3e "+ccs.CONST_CONTOUR);for(e=0;e<d.length;e++)c.addContourData(this.decodeContour(d[e],b));return c},decodeTextureFromJson:function(a){var b=new ccs.TextureData;
b.init();var c=a[ccs.CONST_A_NAME];null!=c&&(b.name=c);b.width=a[ccs.CONST_A_WIDTH]||0;b.height=a[ccs.CONST_A_HEIGHT]||0;b.pivotX=a[ccs.CONST_A_PIVOT_X]||0;b.pivotY=a[ccs.CONST_A_PIVOT_Y]||0;a=a[ccs.CONST_CONTOUR_DATA]||[];for(c=0;c<a.length;c++)b.contourDataList.push(this.decodeContourFromJson(a[c]));return b},decodeContour:function(a,b){var c=new ccs.ContourData;c.init();for(var d,e=a.querySelectorAll(ccs.CONST_CONTOUR+" \x3e "+ccs.CONST_CONTOUR_VERTEX),f=0;f<e.length;f++){d=e[f];var g=cc.p(0,0);
g.x=parseFloat(d.getAttribute(ccs.CONST_A_X))||0;g.y=parseFloat(d.getAttribute(ccs.CONST_A_Y))||0;g.y=-g.y;c.vertexList.push(g)}return c},decodeContourFromJson:function(a){var b=new ccs.ContourData;b.init();a=a[ccs.CONST_VERTEX_POINT]||[];for(var c=a.length,d=0;c>d;d++){var e=a[d],f=cc.p(0,0);f.x=e[ccs.CONST_A_X]||0;f.y=e[ccs.CONST_A_Y]||0;b.vertexList.push(f)}return b},addDataFromJsonCache:function(a,b){b.contentScale=null==a[ccs.CONST_CONTENT_SCALE]?1:a[ccs.CONST_CONTENT_SCALE];var c,d,e=a[ccs.CONST_ARMATURE_DATA]||
[];for(c=0;c<e.length;c++)d=this.decodeArmatureFromJSON(e[c],b),ccs.armatureDataManager.addArmatureData(d.name,d,b.filename);e=a[ccs.CONST_ANIMATION_DATA]||[];for(c=0;c<e.length;c++)d=this.decodeAnimationFromJson(e[c],b),ccs.armatureDataManager.addAnimationData(d.name,d,b.filename);e=a[ccs.CONST_TEXTURE_DATA]||[];for(c=0;c<e.length;c++)d=this.decodeTextureFromJson(e[c],b),ccs.armatureDataManager.addTextureData(d.name,d,b.filename);if(null==b.asyncStruct?ccs.armatureDataManager.isAutoLoadSpriteFile():
b.asyncStruct.autoLoadSpriteFile){var f;d=a[ccs.CONST_CONFIG_FILE_PATH]||[];for(c=0;c<d.length;c++)e=d[c],f=e.lastIndexOf("."),e=e.substring(0,f),f=b.basefilePath+e+".plist",e=b.basefilePath+e+".png",ccs.armatureDataManager.addSpriteFrameFromFile(f,e,b.filename)}},decodeNodeFromJson:function(a,b,c){a.x=b[ccs.CONST_A_X]*this._positionReadScale;a.y=b[ccs.CONST_A_Y]*this._positionReadScale;a.x*=c.contentScale;a.y*=c.contentScale;a.zOrder=b[ccs.CONST_A_Z];a.skewX=b[ccs.CONST_A_SKEW_X]||0;a.skewY=b[ccs.CONST_A_SKEW_Y]||
0;a.scaleX=null==b[ccs.CONST_A_SCALE_X]?1:b[ccs.CONST_A_SCALE_X];a.scaleY=null==b[ccs.CONST_A_SCALE_Y]?1:b[ccs.CONST_A_SCALE_Y];var d;c.cocoStudioVersion<ccs.VERSION_COLOR_READING?(d=b[0],d&&(a.a=null==d[ccs.CONST_A_ALPHA]?255:d[ccs.CONST_A_ALPHA],a.r=null==d[ccs.CONST_A_RED]?255:d[ccs.CONST_A_RED],a.g=null==d[ccs.CONST_A_GREEN]?255:d[ccs.CONST_A_GREEN],a.b=null==d[ccs.CONST_A_BLUE]?255:d[ccs.CONST_A_BLUE],a.isUseColorInfo=!0)):(d=b[ccs.CONST_COLOR_INFO]||null,d&&(a.a=null==d[ccs.CONST_A_ALPHA]?255:
d[ccs.CONST_A_ALPHA],a.r=null==d[ccs.CONST_A_RED]?255:d[ccs.CONST_A_RED],a.g=null==d[ccs.CONST_A_GREEN]?255:d[ccs.CONST_A_GREEN],a.b=null==d[ccs.CONST_A_BLUE]?255:d[ccs.CONST_A_BLUE],a.isUseColorInfo=!0))},clear:function(){this._configFileList=[];this._asyncRefTotalCount=this._asyncRefCount=0},_asyncCallBack:function(a,b,c){a&&cc.isFunction(a)&&a.call(b,c);b&&a&&"string"==typeof a&&b[a](c)},_initBaseFilePath:function(a){var b=a.lastIndexOf("/");return-1<b?a.substr(0,b+1):""},addDataFromXML:function(a,
b){var c=cc.loader.getRes(a);if(!c)throw"Please load the resource first : "+a;(c=cc.saxParser.parse(c).documentElement)&&this.addDataFromCache(c,b)},addDataFromJson:function(a,b){var c=cc.loader.getRes(a);this.addDataFromJsonCache(c,b)}};ccs.spriteFrameCacheHelper={_textureAtlasDic:{},_imagePaths:[],addSpriteFrameFromFile:function(a,b){cc.spriteFrameCache.addSpriteFrames(a,b)},getTextureAtlasWithTexture:function(a){return null},clear:function(){this._textureAtlasDic={};this._imagePaths=[]}};
ccs.TransformHelp=ccs.TransformHelp||ccs.Class.extend({});ccs.TransformHelp.helpMatrix1=cc.affineTransformMake(1,0,0,1,0,0);ccs.TransformHelp.helpMatrix2=cc.affineTransformMake(1,0,0,1,0,0);ccs.TransformHelp.helpPoint1=cc.p(0,0);ccs.TransformHelp.helpPoint2=cc.p(0,0);ccs.TransformHelp.helpParentNode={};
ccs.TransformHelp.transformFromParent=function(a,b){this.nodeToMatrix(a,this.helpMatrix1);this.nodeToMatrix(b,this.helpMatrix2);this.helpMatrix2=cc.affineTransformInvert(this.helpMatrix2);this.helpMatrix1=cc.affineTransformConcat(this.helpMatrix1,this.helpMatrix2);this.matrixToNode(this.helpMatrix1,a)};
ccs.TransformHelp.transformToParent=function(a,b){this.nodeToMatrix(a,this.helpMatrix1);this.nodeToMatrix(b,this.helpMatrix2);this.helpMatrix1=cc.affineTransformConcat(this.helpMatrix1,this.helpMatrix2);this.matrixToNode(this.helpMatrix1,a)};
ccs.TransformHelp.transformFromParentWithoutScale=function(a,b){for(var c in b)this.helpParentNode[c]=b[c];this.helpParentNode.scaleX=1;this.helpParentNode.scaleY=1;this.nodeToMatrix(a,this.helpMatrix1);this.nodeToMatrix(this.helpParentNode,this.helpMatrix2);this.helpMatrix2=cc.affineTransformInvert(this.helpMatrix2);this.helpMatrix1=cc.affineTransformConcat(this.helpMatrix1,this.helpMatrix2);this.matrixToNode(this.helpMatrix1,a)};
ccs.TransformHelp.transformToParentWithoutScale=function(a,b){for(var c in b)this.helpParentNode[c]=b[c];this.helpParentNode.scaleX=1;this.helpParentNode.scaleY=1;this.nodeToMatrix(a,this.helpMatrix1);this.nodeToMatrix(this.helpParentNode,this.helpMatrix2);this.helpMatrix1=cc.affineTransformConcat(this.helpMatrix1,this.helpMatrix2);this.matrixToNode(this.helpMatrix1,a)};
ccs.TransformHelp.nodeToMatrix=function(a,b){if(a.skewX===-a.skewY){var c=Math.sin(a.skewX),d=Math.cos(a.skewX);b.a=a.scaleX*d;b.b=a.scaleX*-c;b.c=a.scaleY*c;b.d=a.scaleY*d}else b.a=a.scaleX*Math.cos(a.skewY),b.b=a.scaleX*Math.sin(a.skewY),b.c=a.scaleY*Math.sin(a.skewX),b.d=a.scaleY*Math.cos(a.skewX);b.tx=a.x;b.ty=a.y};
ccs.TransformHelp.matrixToNode=function(a,b){this.helpPoint1.x=0;this.helpPoint1.y=1;this.helpPoint1=cc.pointApplyAffineTransform(this.helpPoint1,a);this.helpPoint1.x-=a.tx;this.helpPoint1.y-=a.ty;this.helpPoint2.x=1;this.helpPoint2.y=0;this.helpPoint2=cc.pointApplyAffineTransform(this.helpPoint2,a);this.helpPoint2.x-=a.tx;this.helpPoint2.y-=a.ty;b.skewX=-(Math.atan2(this.helpPoint1.y,this.helpPoint1.x)-1.5707964);b.skewY=Math.atan2(this.helpPoint2.y,this.helpPoint2.x);b.scaleX=Math.sqrt(a.a*a.a+
a.b*a.b);b.scaleY=Math.sqrt(a.c*a.c+a.d*a.d);b.x=a.tx;b.y=a.ty};ccs.TransformHelp.nodeConcat=function(a,b){a.x+=b.x;a.y+=b.y;a.skewX+=b.skewX;a.skewY+=b.skewY;a.scaleX+=b.scaleX;a.scaleY+=b.scaleY};ccs.TransformHelp.nodeSub=function(a,b){a.x-=b.x;a.y-=b.y;a.skewX-=b.skewX;a.skewY-=b.skewY;a.scaleX-=b.scaleX;a.scaleY-=b.scaleY};
ccs.TweenType={CUSTOM_EASING:-1,LINEAR:0,SINE_EASEIN:1,SINE_EASEOUT:2,SINE_EASEINOUT:3,QUAD_EASEIN:4,QUAD_EASEOUT:5,QUAD_EASEINOUT:6,CUBIC_EASEIN:7,CUBIC_EASEOUT:8,CUBIC_EASEINOUT:9,QUART_EASEIN:10,QUART_EASEOUT:11,QUART_EASEINOUT:12,QUINT_EASEIN:13,QUINT_EASEOUT:14,QUINT_EASEINOUT:15,EXPO_EASEIN:16,EXPO_EASEOUT:17,EXPO_EASEINOUT:18,CIRC_EASEIN:19,CIRC_EASEOUT:20,CIRC_EASEINOUT:21,ELASTIC_EASEIN:22,ELASTIC_EASEOUT:23,ELASTIC_EASEINOUT:24,BACK_EASEIN:25,BACK_EASEOUT:26,BACK_EASEINOUT:27,BOUNCE_EASEIN:28,
BOUNCE_EASEOUT:29,BOUNCE_EASEINOUT:30,TWEEN_EASING_MAX:1E4};ccs.TweenFunction=ccs.TweenFunction||ccs.Class.extend({});ccs.DOUBLE_PI=ccs.M_PI_X_2=2*Math.PI;ccs.HALF_PI=ccs.M_PI_2=Math.PI/2;ccs.M_PI=Math.PI;
ccs.TweenFunction.tweenTo=function(a,b,c){var d=0;switch(b){case ccs.TweenType.CUSTOM_EASING:d=this.customEase(a,c);break;case ccs.TweenType.LINEAR:d=this.linear(a);break;case ccs.TweenType.SINE_EASEIN:d=this.sineEaseIn(a);break;case ccs.TweenType.SINE_EASEOUT:d=this.sineEaseOut(a);break;case ccs.TweenType.SINE_EASEINOUT:d=this.sineEaseInOut(a);break;case ccs.TweenType.QUAD_EASEIN:d=this.quadEaseIn(a);break;case ccs.TweenType.QUAD_EASEOUT:d=this.quadEaseOut(a);break;case ccs.TweenType.QUAD_EASEINOUT:d=
this.quadEaseInOut(a);break;case ccs.TweenType.CUBIC_EASEIN:d=this.cubicEaseIn(a);break;case ccs.TweenType.CUBIC_EASEOUT:d=this.cubicEaseOut(a);break;case ccs.TweenType.CUBIC_EASEINOUT:d=this.cubicEaseInOut(a);break;case ccs.TweenType.QUART_EASEIN:d=this.quartEaseIn(a);break;case ccs.TweenType.QUART_EASEOUT:d=this.quartEaseOut(a);break;case ccs.TweenType.QUART_EASEINOUT:d=this.quartEaseInOut(a);break;case ccs.TweenType.QUINT_EASEIN:d=this.quintEaseIn(a);break;case ccs.TweenType.QUINT_EASEOUT:d=this.quintEaseOut(a);
break;case ccs.TweenType.QUINT_EASEINOUT:d=this.quintEaseInOut(a);break;case ccs.TweenType.EXPO_EASEIN:d=this.expoEaseIn(a);break;case ccs.TweenType.EXPO_EASEOUT:d=this.expoEaseOut(a);break;case ccs.TweenType.EXPO_EASEINOUT:d=this.expoEaseInOut(a);break;case ccs.TweenType.CIRC_EASEIN:d=this.circEaseIn(a);break;case ccs.TweenType.CIRC_EASEOUT:d=this.circEaseOut(a);break;case ccs.TweenType.CIRC_EASEINOUT:d=this.circEaseInOut(a);break;case ccs.TweenType.ELASTIC_EASEIN:b=0.3;null!=c&&0<c.length&&(b=c[0]);
d=this.elasticEaseIn(a,b);break;case ccs.TweenType.ELASTIC_EASEOUT:b=0.3;null!=c&&0<c.length&&(b=c[0]);d=this.elasticEaseOut(a,b);break;case ccs.TweenType.ELASTIC_EASEINOUT:b=0.3;null!=c&&0<c.length&&(b=c[0]);d=this.elasticEaseInOut(a,b);break;case ccs.TweenType.BACK_EASEIN:d=this.backEaseIn(a);break;case ccs.TweenType.BACK_EASEOUT:d=this.backEaseOut(a);break;case ccs.TweenType.BACK_EASEINOUT:d=this.backEaseInOut(a);break;case ccs.TweenType.BOUNCE_EASEIN:d=this.bounceEaseIn(a);break;case ccs.TweenType.BOUNCE_EASEOUT:d=
this.bounceEaseOut(a);break;case ccs.TweenType.BOUNCE_EASEINOUT:d=this.bounceEaseInOut(a);break;default:d=this.sineEaseInOut(a)}return d};ccs.TweenFunction.linear=function(a){return a};ccs.TweenFunction.sineEaseIn=function(a){return-1*Math.cos(a*ccs.HALF_PI)+1};ccs.TweenFunction.sineEaseOut=function(a){return Math.sin(a*ccs.HALF_PI)};ccs.TweenFunction.sineEaseInOut=function(a){return-0.5*(Math.cos(ccs.M_PI*a)-1)};ccs.TweenFunction.quadEaseIn=function(a){return a*a};
ccs.TweenFunction.quadEaseOut=function(a){return-1*a*(a-2)};ccs.TweenFunction.quadEaseInOut=function(a){return a*=2,1>a?0.5*a*a:(--a,-0.5*(a*(a-2)-1))};ccs.TweenFunction.cubicEaseIn=function(a){return a*a*a};ccs.TweenFunction.cubicEaseOut=function(a){return a-=1,a*a*a+1};ccs.TweenFunction.cubicEaseInOut=function(a){return a*=2,1>a?0.5*a*a*a:(a-=2,0.5*(a*a*a+2))};ccs.TweenFunction.quartEaseIn=function(a){return a*a*a*a};ccs.TweenFunction.quartEaseOut=function(a){return a-=1,-(a*a*a*a-1)};
ccs.TweenFunction.quartEaseInOut=function(a){return a*=2,1>a?0.5*a*a*a*a:(a-=2,-0.5*(a*a*a*a-2))};ccs.TweenFunction.quintEaseIn=function(a){return a*a*a*a*a};ccs.TweenFunction.quintEaseOut=function(a){return a-=1,a*a*a*a*a+1};ccs.TweenFunction.quintEaseInOut=function(a){return a*=2,1>a?0.5*a*a*a*a*a:(a-=2,0.5*(a*a*a*a*a+2))};ccs.TweenFunction.expoEaseIn=function(a){return 0===a?0:Math.pow(2,10*(a-1))-0.001};ccs.TweenFunction.expoEaseOut=function(a){return 1===a?1:-Math.pow(2,-10*a)+1};
ccs.TweenFunction.expoEaseInOut=function(a){return a/=0.5,1>a?0.5*Math.pow(2,10*(a-1)):0.5*(-Math.pow(2,-10*(a-1))+2)};ccs.TweenFunction.circEaseIn=function(a){return-1*(Math.sqrt(1-a*a)-1)};ccs.TweenFunction.circEaseOut=function(a){return a-=1,Math.sqrt(1-a*a)};ccs.TweenFunction.circEaseInOut=function(a){return a*=2,1>a?-0.5*(Math.sqrt(1-a*a)-1):(a-=2,0.5*(Math.sqrt(1-a*a)+1))};
ccs.TweenFunction.elasticEaseIn=function(a,b){var c=0.3;0<b.length&&(c=b[0]);var d=0;0===a||1===a?d=a:(d=c/4,a-=1,d=-Math.pow(2,10*a)*Math.sin((a-d)*ccs.DOUBLE_PI/c));return d};ccs.TweenFunction.elasticEaseOut=function(a,b){var c=0.3;0<b.length&&(c=b[0]);var d=0;0===a||1===a?d=a:(d=c/4,d=Math.pow(2,-10*a)*Math.sin((a-d)*ccs.DOUBLE_PI/c)+1);return d};
ccs.TweenFunction.elasticEaseInOut=function(a,b){var c=0.3;0<b.length&&(c=b[0]);var d=0;0===a||1===a?d=a:(c||(c=0.3*1.5),d=c/4,a=2*a-1,d=0>a?-0.5*Math.pow(2,10*a)*Math.sin((a-d)*ccs.DOUBLE_PI/c):0.5*Math.pow(2,-10*a)*Math.sin((a-d)*ccs.DOUBLE_PI/c)+1);return d};ccs.TweenFunction.backEaseIn=function(a){return a*a*(2.70158*a-1.70158)};ccs.TweenFunction.backEaseOut=function(a){return a-=1,a*a*(2.70158*a+1.70158)+1};
ccs.TweenFunction.backEaseInOut=function(a){return a*=2,1>a?a*a*(3.5949095*a-2.5949095)/2:(a-=2,a*a*(3.5949095*a+2.5949095)/2+1)};ccs.bounceTime=function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?(a-=1.5/2.75,7.5625*a*a+0.75):2.5/2.75>a?(a-=2.25/2.75,7.5625*a*a+0.9375):(a-=2.625/2.75,7.5625*a*a+0.984375)};ccs.TweenFunction.bounceEaseIn=function(a){return 1-ccs.bounceTime(1-a)};ccs.TweenFunction.bounceEaseOut=function(a){return ccs.bounceTime(a)};
ccs.TweenFunction.bounceEaseInOut=function(a){return 0.5>a?(a*=2,ccs.bounceTime(1-a)):ccs.bounceTime(2*a-1),0};ccs.TweenFunction.customEase=function(a,b){if(0<b.length){var c=1-a;return b[1]*c*c*c+3*b[3]*a*c*c+3*b[5]*a*a*c+b[7]*a*a*a}return a};ccs.TweenFunction.easeIn=function(a,b){return Math.pow(a,b)};ccs.TweenFunction.easeOut=function(a,b){return Math.pow(a,1/b)};ccs.TweenFunction.easeInOut=function(a,b){return a*=2,1>a?0.5*Math.pow(a,b):1-0.5*Math.pow(2-a,b)};
ccs.TweenFunction.quadraticIn=function(a){return Math.pow(a,2)};ccs.TweenFunction.quadraticOut=function(a){return-a*(a-2)};ccs.TweenFunction.bezieratFunction=function(a,b,c,d,e){return Math.pow(1-e,3)*a+3*e*Math.pow(1-e,2)*b+3*Math.pow(e,2)*(1-e)*c+Math.pow(e,3)*d};var ENABLE_PHYSICS_DETECT=!1;ccs.fmodf=function(a,b){for(;a>b;)a-=b;return a};var CC_SAFE_RELEASE=function(a){a&&a.release&&a.release()};
ccs.isSpriteContainPoint=function(a,b,c){b=a.convertToNodeSpace(b);c&&(c.x=b.x,c.y=b.y);a=a.getContentSize();return cc.rectContainsPoint(cc.rect(0,0,a.width,a.height),b)};ccs.SPRITE_CONTAIN_POINT=ccs.isSpriteContainPoint;ccs.SPRITE_CONTAIN_POINT_WITH_RETURN=ccs.isSpriteContainPoint;
ccs.extBezierTo=function(a,b,c,d,e){var f=cc.p(0,0);return d&&!e&&(f.x=Math.pow(1-a,2)*b.x+2*a*(1-a)*c.x+Math.pow(a,2)*d.x,f.y=Math.pow(1-a,2)*b.y+2*a*(1-a)*c.y+Math.pow(a,2)*d.y),e&&(f.x=b.x*Math.pow(1-a,3)+3*a*c.x*Math.pow(1-a,2)+3*d.x*Math.pow(a,2)*(1-a)+e.x*Math.pow(a,3),f.y=b.y*Math.pow(1-a,3)+3*a*c.y*Math.pow(1-a,2)+3*d.y*Math.pow(a,2)*(1-a)+e.y*Math.pow(a,3)),f};ccs.extCircleTo=function(a,b,c,d,e){var f=cc.p(0,0);return f.x=b.x+c*Math.cos(d+e*a),f.y=b.y+c*Math.sin(d+e*a),f};
ccs.RelativeData=function(){this.plistFiles=[];this.armatures=[];this.animations=[];this.textures=[]};
ccs.armatureDataManager={_animationDatas:{},_armatureDatas:{},_textureDatas:{},_autoLoadSpriteFile:!1,_relativeDatas:{},s_sharedArmatureDataManager:null,removeArmatureFileInfo:function(a){var b=this.getRelativeData(a);if(b){var c,d;for(c=0;c<b.armatures.length;c++)d=b.armatures[c],this.removeArmatureData(d);for(c=0;c<b.animations.length;c++)d=b.animations[c],this.removeAnimationData(d);for(c=0;c<b.textures.length;c++)d=b.textures[c],this.removeTextureData(d);for(c=0;c<b.plistFiles.length;c++)d=b.plistFiles[c],
cc.spriteFrameCache.removeSpriteFramesFromFile(d);delete this._relativeDatas[a];ccs.dataReaderHelper.removeConfigFile(a)}},addArmatureData:function(a,b,c){(c=this.getRelativeData(c))&&c.armatures.push(a);this._armatureDatas[a]=b},getArmatureData:function(a){return null},removeArmatureData:function(a){this._armatureDatas[a]&&delete this._armatureDatas[a]},addAnimationData:function(a,b,c){(c=this.getRelativeData(c))&&c.animations.push(a);this._animationDatas[a]=b},getAnimationData:function(a){return null},
removeAnimationData:function(a){this._animationDatas[a]&&delete this._animationDatas[a]},addTextureData:function(a,b,c){(c=this.getRelativeData(c))&&c.textures.push(a);this._textureDatas[a]=b},getTextureData:function(a){return null},removeTextureData:function(a){this._textureDatas[a]&&delete this._textureDatas[a]},addArmatureFileInfo:function(){var a,b,c;switch(arguments.length){case 1:c=arguments[0];this.addRelativeData(c);this._autoLoadSpriteFile=!0;ccs.dataReaderHelper.addDataFromFile(c);break;
case 3:a=arguments[0],b=arguments[1],c=arguments[2],this.addRelativeData(c),this._autoLoadSpriteFile=!1,ccs.dataReaderHelper.addDataFromFile(c),this.addSpriteFrameFromFile(b,a)}},addArmatureFileInfoAsync:function(){var a,b,c,d,e;switch(arguments.length){case 3:c=arguments[0];d=arguments[2];e=arguments[1];this.addRelativeData(c);this._autoLoadSpriteFile=!0;ccs.dataReaderHelper.addDataFromFileAsync("","",c,e,d);break;case 5:a=arguments[0],b=arguments[1],c=arguments[2],d=arguments[4],e=arguments[3],
this.addRelativeData(c),this._autoLoadSpriteFile=!1,ccs.dataReaderHelper.addDataFromFileAsync(a,b,c,e,d),this.addSpriteFrameFromFile(b,a)}},addSpriteFrameFromFile:function(a,b,c){(c=this.getRelativeData(c))&&c.plistFiles.push(a);ccs.spriteFrameCacheHelper.addSpriteFrameFromFile(a,b)},isAutoLoadSpriteFile:function(){return this._autoLoadSpriteFile},getArmatureDatas:function(){return this._armatureDatas},getAnimationDatas:function(){return this._animationDatas},getTextureDatas:function(){return this._textureDatas},
addRelativeData:function(a){this._relativeDatas[a]||(this._relativeDatas[a]=new ccs.RelativeData)},getRelativeData:function(a){return this._relativeDatas[a]},clear:function(){this._animationDatas={};this._armatureDatas={};this._textureDatas={};ccs.spriteFrameCacheHelper.clear();ccs.dataReaderHelper.clear()}};ccs.BLEND_TYPE_NORMAL=0;ccs.BLEND_TYPE_LAYER=1;ccs.BLEND_TYPE_DARKEN=2;ccs.BLEND_TYPE_MULTIPLY=3;ccs.BLEND_TYPE_LIGHTEN=4;ccs.BLEND_TYPE_SCREEN=5;ccs.BLEND_TYPE_OVERLAY=6;
ccs.BLEND_TYPE_HIGHLIGHT=7;ccs.BLEND_TYPE_ADD=8;ccs.BLEND_TYPE_SUBTRACT=9;ccs.BLEND_TYPE_DIFFERENCE=10;ccs.BLEND_TYPE_INVERT=11;ccs.BLEND_TYPE_ALPHA=12;ccs.BLEND_TYPE_ERASE=13;ccs.DISPLAY_TYPE_SPRITE=0;ccs.DISPLAY_TYPE_ARMATURE=1;ccs.DISPLAY_TYPE_PARTICLE=2;ccs.DISPLAY_TYPE_MAX=3;
ccs.BaseData=ccs.Class.extend({x:0,y:0,zOrder:0,skewX:0,skewY:0,scaleX:1,scaleY:1,tweenRotate:0,isUseColorInfo:!1,r:255,g:255,b:255,a:255,ctor:function(){this.skewY=this.skewX=this.zOrder=this.y=this.x=0;this.scaleY=this.scaleX=1;this.tweenRotate=0;this.isUseColorInfo=!1;this.a=this.b=this.g=this.r=255},copy:function(a){this.x=a.x;this.y=a.y;this.zOrder=a.zOrder;this.scaleX=a.scaleX;this.scaleY=a.scaleY;this.skewX=a.skewX;this.skewY=a.skewY;this.tweenRotate=a.tweenRotate;this.isUseColorInfo=a.isUseColorInfo;
this.r=a.r;this.g=a.g;this.b=a.b;this.a=a.a},setColor:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.a=a.a},getColor:function(){return cc.color(this.r,this.g,this.b,this.a)},subtract:function(a,b,c){this.x=b.x-a.x;this.y=b.y-a.y;this.scaleX=b.scaleX-a.scaleX;this.scaleY=b.scaleY-a.scaleY;this.skewX=b.skewX-a.skewX;this.skewY=b.skewY-a.skewY;this.isUseColorInfo||a.isUseColorInfo||b.isUseColorInfo?(this.a=b.a-a.a,this.r=b.r-a.r,this.g=b.g-a.g,this.b=b.b-a.b,this.isUseColorInfo=!0):(this.a=this.r=
this.g=this.b=0,this.isUseColorInfo=!1);c&&(this.skewX>ccs.M_PI&&(this.skewX-=ccs.DOUBLE_PI),this.skewX<-ccs.M_PI&&(this.skewX+=ccs.DOUBLE_PI),this.skewY>ccs.M_PI&&(this.skewY-=ccs.DOUBLE_PI),this.skewY<-ccs.M_PI&&(this.skewY+=ccs.DOUBLE_PI));b.tweenRotate&&(this.skewX+=2*b.tweenRotate*ccs.PI,this.skewY-=2*b.tweenRotate*ccs.PI)}});
ccs.DisplayData=ccs.Class.extend({displayType:ccs.DISPLAY_TYPE_MAX,displayName:"",ctor:function(){this.displayType=ccs.DISPLAY_TYPE_MAX},changeDisplayToTexture:function(a){var b=a.lastIndexOf(".");return-1!==b&&(a=a.substring(0,b)),a},copy:function(a){this.displayName=a.displayName;this.displayType=a.displayType}});
ccs.SpriteDisplayData=ccs.DisplayData.extend({skinData:null,ctor:function(){this.skinData=new ccs.BaseData;this.displayType=ccs.DISPLAY_TYPE_SPRITE},copy:function(a){ccs.DisplayData.prototype.copy.call(this,a);this.skinData=a.skinData}});ccs.ArmatureDisplayData=ccs.DisplayData.extend({ctor:function(){this.displayName="";this.displayType=ccs.DISPLAY_TYPE_ARMATURE}});ccs.ParticleDisplayData=ccs.DisplayData.extend({ctor:function(){this.displayType=ccs.DISPLAY_TYPE_PARTICLE}});
ccs.BoneData=ccs.BaseData.extend({displayDataList:null,name:"",parentName:"",boneDataTransform:null,ctor:function(){this.displayDataList=[];this.parentName=this.name="";this.boneDataTransform=null},init:function(){return this.displayDataList.length=0,!0},addDisplayData:function(a){this.displayDataList.push(a)},getDisplayData:function(a){return this.displayDataList[a]}});
ccs.ArmatureData=ccs.Class.extend({boneDataDic:null,name:"",dataVersion:0.1,ctor:function(){this.boneDataDic={};this.name="";this.dataVersion=0.1},init:function(){return!0},addBoneData:function(a){this.boneDataDic[a.name]=a},getBoneDataDic:function(){return this.boneDataDic},getBoneData:function(a){return this.boneDataDic[a]}});
ccs.FrameData=ccs.BaseData.extend({duration:0,tweenEasing:0,easingParamNumber:0,easingParams:null,displayIndex:-1,movement:"",event:"",sound:"",soundEffect:"",blendFunc:null,frameID:0,isTween:!0,ctor:function(){ccs.BaseData.prototype.ctor.call(this);this.duration=1;this.tweenEasing=ccs.TweenType.LINEAR;this.easingParamNumber=0;this.easingParams=[];this.displayIndex=0;this.soundEffect=this.sound=this.event=this.movement="";this.blendFunc=new cc.BlendFunc(cc.BLEND_SRC,cc.BLEND_DST);this.frameID=0;this.isTween=
!0},copy:function(a){if(ccs.BaseData.prototype.copy.call(this,a),this.duration=a.duration,this.displayIndex=a.displayIndex,this.tweenEasing=a.tweenEasing,this.easingParamNumber=a.easingParamNumber,0!==this.easingParamNumber)for(var b=this.easingParams.length=0;b<this.easingParamNumber;b++)this.easingParams[b]=a.easingParams[b];this.blendFunc=a.blendFunc;this.isTween=a.isTween}});
ccs.MovementBoneData=ccs.Class.extend({delay:0,scale:1,duration:0,frameList:null,name:"",ctor:function(){this.delay=0;this.scale=1;this.duration=0;this.frameList=[];this.name=""},init:function(){return!0},addFrameData:function(a){this.frameList.push(a)},getFrameData:function(a){return this.frameList[a]}});ccs.MovementData=function(){this.name="";this.duration=0;this.scale=1;this.durationTween=this.durationTo=0;this.loop=!0;this.tweenEasing=ccs.TweenType.LINEAR;this.movBoneDataDic={}};
ccs.MovementData.prototype.addMovementBoneData=function(a){this.movBoneDataDic[a.name]=a};ccs.MovementData.prototype.getMovementBoneData=function(a){return this.movBoneDataDic[a]};ccs.AnimationData=function(){this.movementDataDic={};this.movementNames=[];this.name=""};ccs.AnimationData.prototype.addMovement=function(a){this.movementDataDic[a.name]=a;this.movementNames.push(a.name)};ccs.AnimationData.prototype.getMovement=function(a){return this.movementDataDic[a]};
ccs.AnimationData.prototype.getMovementCount=function(){return Object.keys(this.movementDataDic).length};ccs.ContourVertex2=function(a,b){this.x=a||0;this.y=b||0};ccs.ContourData=function(){this.vertexList=[]};ccs.ContourData.prototype.init=function(){return this.vertexList.length=0,!0};ccs.ContourData.prototype.addVertex=function(a){this.vertexList.push(a)};ccs.TextureData=function(){this.width=this.height=0;this.pivotY=this.pivotX=0.5;this.name="";this.contourDataList=[]};
ccs.TextureData.prototype.init=function(){this.contourDataList.length=0};ccs.TextureData.prototype.addContourData=function(a){this.contourDataList.push(a)};ccs.TextureData.prototype.getContourData=function(a){return this.contourDataList[a]};
ccs.DecorativeDisplay=ccs.Class.extend({_display:null,_colliderDetector:null,_displayData:null,ctor:function(){this._displayData=this._colliderDetector=this._display=null},init:function(){return!0},setDisplay:function(a){a._parent&&(a._parent.removeChild(a),delete a._parent);this._display=a},getDisplay:function(){return this._display},setColliderDetector:function(a){this._colliderDetector=a},getColliderDetector:function(){return this._colliderDetector},setDisplayData:function(a){this._displayData=
a},getDisplayData:function(){return this._displayData},release:function(){this._colliderDetector=this._displayData=this._display=null}});ccs.DecorativeDisplay.create=function(){return new ccs.DecorativeDisplay};
ccs.displayFactory={addDisplay:function(a,b,c){switch(c.displayType){case ccs.DISPLAY_TYPE_SPRITE:this.addSpriteDisplay(a,b,c);break;case ccs.DISPLAY_TYPE_PARTICLE:this.addParticleDisplay(a,b,c);break;case ccs.DISPLAY_TYPE_ARMATURE:this.addArmatureDisplay(a,b,c)}},createDisplay:function(a,b){switch(b.getDisplayData().displayType){case ccs.DISPLAY_TYPE_SPRITE:this.createSpriteDisplay(a,b);break;case ccs.DISPLAY_TYPE_PARTICLE:this.createParticleDisplay(a,b);break;case ccs.DISPLAY_TYPE_ARMATURE:this.createArmatureDisplay(a,
b)}},_helpTransform:{a:1,b:0,c:0,d:1,tx:0,ty:0},updateDisplay:function(a,b,c){var d=a.getDisplayRenderNode();if(d){switch(a.getDisplayRenderNodeType()){case ccs.DISPLAY_TYPE_SPRITE:c&&d.updateArmatureTransform();break;case ccs.DISPLAY_TYPE_PARTICLE:this.updateParticleDisplay(a,d,b);break;case ccs.DISPLAY_TYPE_ARMATURE:this.updateArmatureDisplay(a,d,b);break;default:b=a.getNodeToArmatureTransform(),d.setAdditionalTransform(b)}if((ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT||ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX)&&
c)if(d=a.getDisplayManager().getCurrentDecorativeDisplay(),c=d.getColliderDetector()){b=d.getDisplay();var e=b.getNodeToParentTransform(),d=this._helpTransform;d.a=e.a;d.b=e.b;d.c=e.c;d.d=e.d;d.tx=e.tx;d.ty=e.ty;b=cc.pointApplyAffineTransform(b.getAnchorPointInPoints(),d);d.tx=b.x;d.ty=b.y;a=cc.affineTransformConcat(d,a.getArmature().getNodeToParentTransform());c.updateTransform(a)}}},addSpriteDisplay:function(a,b,c){var d=new ccs.SpriteDisplayData;d.copy(c);b.setDisplayData(d);this.createSpriteDisplay(a,
b)},createSpriteDisplay:function(a,b){var c=null,d=b.getDisplayData(),c=d.displayName,e=c.lastIndexOf(".");-1!==e&&(c=c.substring(0,e));c=""===c?new ccs.Skin:new ccs.Skin("#"+c+".png");b.setDisplay(c);c.setBone(a);this.initSpriteDisplay(a,b,d.displayName,c);(e=a.getArmature())&&c.setSkinData(e.getArmatureData().dataVersion>=ccs.CONST_VERSION_COMBINED?d.skinData:a.boneData)},initSpriteDisplay:function(a,b,c,d){var e=c.lastIndexOf(".");-1!==e&&(c=c.substring(0,e));c=ccs.armatureDataManager.getTextureData(c);
if(c&&d.setAnchorPoint(cc.p(c.pivotX,c.pivotY)),(ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT||ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX)&&c&&0<c.contourDataList.length)a=new ccs.ColliderDetector(a),a.addContourDataList(c.contourDataList),b.setColliderDetector(a)},addArmatureDisplay:function(a,b,c){var d=new ccs.ArmatureDisplayData;d.copy(c);b.setDisplayData(d);this.createArmatureDisplay(a,b)},createArmatureDisplay:function(a,b){var c=b.getDisplayData(),c=new ccs.Armature(c.displayName,a);b.setDisplay(c)},
updateArmatureDisplay:function(a,b,c){b&&(b.sortAllChildren(),b.update(c))},addParticleDisplay:function(a,b,c){var d=new ccs.ParticleDisplayData;d.copy(c);b.setDisplayData(d);this.createParticleDisplay(a,b)},createParticleDisplay:function(a,b){var c=b.getDisplayData(),c=new cc.ParticleSystem(c.displayName);c.removeFromParent();c.cleanup();a.getArmature()&&c.setParent(a.getArmature());b.setDisplay(c)},updateParticleDisplay:function(a,b,c){var d=new ccs.BaseData;ccs.TransformHelp.matrixToNode(a.nodeToArmatureTransform(),
d);b.setPosition(d.x,d.y);b.setScaleX(d.scaleX);b.setScaleY(d.scaleY);b.update(c)}};
ccs.DisplayManager=ccs.Class.extend({_decoDisplayList:null,_currentDecoDisplay:null,_displayRenderNode:null,_displayIndex:null,_forceChangeDisplay:!1,_bone:null,_visible:!0,_displayType:null,ctor:function(a){this._decoDisplayList=[];this._displayIndex=this._displayRenderNode=this._currentDecoDisplay=null;this._forceChangeDisplay=!1;this._bone=null;this._visible=!0;this._displayType=ccs.DISPLAY_TYPE_MAX;a&&ccs.DisplayManager.prototype.init.call(this,a)},init:function(a){return this._bone=a,this.initDisplayList(a.getBoneData()),
!0},addDisplay:function(a,b){var c,d=this._decoDisplayList;if(0<=b&&b<d.length?c=d[b]:(c=new ccs.DecorativeDisplay,d.push(c)),a instanceof ccs.DisplayData)return ccs.displayFactory.addDisplay(this._bone,c,a),void(b===this._displayIndex&&(this._displayIndex=-1,this.changeDisplayWithIndex(b,!1)));var e=null;if(a instanceof ccs.Skin){a.setBone(this._bone);e=new ccs.SpriteDisplayData;ccs.displayFactory.initSpriteDisplay(this._bone,c,a.getDisplayName(),a);var f=c.getDisplayData();if(f instanceof ccs.SpriteDisplayData)a.setSkinData(f.skinData),
e.skinData=f.skinData;else{for(var f=!1,g=d.length-2;0<=g;g--){var h=d[g].getDisplayData();if(h instanceof ccs.SpriteDisplayData){f=!0;a.setSkinData(h.skinData);e.skinData=h.skinData;break}}f||a.setSkinData(new ccs.BaseData)}}else a instanceof cc.ParticleSystem?(e=new ccs.ParticleDisplayData,a.removeFromParent(),a.cleanup(),(d=this._bone.getArmature())&&a.setParent(d)):a instanceof ccs.Armature?(e=new ccs.ArmatureDisplayData,e.displayName=a.getName(),a.setParentBone(this._bone)):e=new ccs.DisplayData;
c.setDisplay(a);c.setDisplayData(e);b===this._displayIndex&&(this._displayIndex=-1,this.changeDisplayWithIndex(b,!1))},_addDisplayOther:function(a,b){var c=null;if(b instanceof ccs.Skin){b.setBone(this._bone);c=new ccs.SpriteDisplayData;c.displayName=b.getDisplayName();ccs.displayFactory.initSpriteDisplay(this._bone,a,b.getDisplayName(),b);var d=a.getDisplayData();if(d instanceof ccs.SpriteDisplayData)b.setSkinData(d.skinData);else{for(var d=!1,e=this._decoDisplayList.length-2;0<=e;e--){var f=this._decoDisplayList[e].getDisplayData();
if(f){d=!0;b.setSkinData(f.skinData);c.skinData=f.skinData;break}}d||b.setSkinData(new ccs.BaseData);b.setSkinData(new ccs.BaseData)}}else b instanceof cc.ParticleSystem?(c=new ccs.ParticleDisplayData,c.displayName=b._plistFile):b instanceof ccs.Armature?(c=new ccs.ArmatureDisplayData,c.displayName=b.getName(),b.setParentBone(this._bone)):c=new ccs.DisplayData;a.setDisplay(b);a.setDisplayData(c)},removeDisplay:function(a){this._decoDisplayList.splice(a,1);a===this._displayIndex&&(this.setCurrentDecorativeDisplay(null),
this._displayIndex=-1)},getDecorativeDisplayList:function(){return this._decoDisplayList},changeDisplayWithIndex:function(a,b){return a>=this._decoDisplayList.length?void cc.log("the index value is out of range"):(this._forceChangeDisplay=b,this._displayIndex!==a?(this._displayIndex=a,0>a?void(this._displayRenderNode&&(this._displayRenderNode.removeFromParent(!0),this.setCurrentDecorativeDisplay(null))):void this.setCurrentDecorativeDisplay(this._decoDisplayList[a])):void 0)},changeDisplayWithName:function(a,
b){for(var c=this._decoDisplayList,d=0;d<c.length;d++)if(c[d].getDisplayData().displayName===a){this.changeDisplayWithIndex(d,b);break}},setCurrentDecorativeDisplay:function(a){var b=this._currentDecoDisplay;(ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT||ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX)&&b&&b.getColliderDetector()&&b.getColliderDetector().setActive(!1);b=this._currentDecoDisplay=a;(ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT||ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX)&&b&&b.getColliderDetector()&&b.getColliderDetector().setActive(!0);
a=b?b.getDisplay():null;var b=this._displayRenderNode,c=this._bone;b&&(b instanceof ccs.Armature&&c.setChildArmature(null),b.removeFromParent(!0));(this._displayRenderNode=a)?(a instanceof ccs.Armature?(this._bone.setChildArmature(a),a.setParentBone(this._bone)):a instanceof cc.ParticleSystem&&(a instanceof ccs.Armature?(c.setChildArmature(a),a.setParentBone(c)):a instanceof cc.ParticleSystem&&a.resetSystem()),a.setColor(c.getDisplayedColor()),a.setOpacity(c.getDisplayedOpacity()),this._displayRenderNode.setVisible(this._visible),
this._displayType=this._currentDecoDisplay.getDisplayData().displayType):this._displayType=ccs.DISPLAY_TYPE_MAX;cc.renderer.childrenOrderDirty=!0},getDisplayRenderNode:function(){return this._displayRenderNode},getDisplayRenderNodeType:function(){return this._displayType},getCurrentDisplayIndex:function(){return this._displayIndex},getCurrentDecorativeDisplay:function(){return this._currentDecoDisplay},getDecorativeDisplayByIndex:function(a){return this._decoDisplayList[a]},initDisplayList:function(a){if(this._decoDisplayList.length=
0,a){a=a.displayDataList;for(var b=this._decoDisplayList,c=this._bone,d=0;d<a.length;d++){var e=a[d],f=new ccs.DecorativeDisplay;f.setDisplayData(e);ccs.displayFactory.createDisplay(c,f);b.push(f)}}},containPoint:function(a,b){if(!this._visible||0>this._displayIndex)return!1;if(void 0!==b&&(a=cc.p(a,b)),this._currentDecoDisplay.getDisplayData().displayType===ccs.DISPLAY_TYPE_SPRITE){var c=this._currentDecoDisplay.getDisplay();return c=c.getChildByTag(0),ccs.SPRITE_CONTAIN_POINT_WITH_RETURN(c,a)}return!1},
setVisible:function(a){this._displayRenderNode&&(this._visible=a,this._displayRenderNode.setVisible(a))},isVisible:function(){return this._visible},getContentSize:function(){return this._displayRenderNode?this._displayRenderNode.getContentSize():cc.size(0,0)},getBoundingBox:function(){return this._displayRenderNode?this._displayRenderNode.getBoundingBox():cc.rect(0,0,0,0)},getAnchorPoint:function(){return this._displayRenderNode?this._displayRenderNode.getAnchorPoint():cc.p(0,0)},getAnchorPointInPoints:function(){return this._displayRenderNode?
this._displayRenderNode.getAnchorPointInPoints():cc.p(0,0)},getForceChangeDisplay:function(){return this._forceChangeDisplay},release:function(){this._decoDisplayList=null;this._displayRenderNode&&(this._displayRenderNode.removeFromParent(!0),this._displayRenderNode=null)}});ccs.DisplayManager.create=function(a){return new ccs.DisplayManager(a)};
ccs.Skin=ccs.Sprite.extend({_skinData:null,bone:null,_skinTransform:null,_displayName:"",_armature:null,_className:"Skin",ctor:function(a,b){cc.Sprite.prototype.ctor.call(this);this.bone=this._skinData=null;this._displayName="";this._skinTransform=cc.affineTransformIdentity();this._armature=null;null==a||""===a?ccs.Skin.prototype.init.call(this):"#"===a[0]?ccs.Skin.prototype.initWithSpriteFrameName.call(this,a.substr(1)):ccs.Skin.prototype.initWithFile.call(this,a,b)},initWithSpriteFrameName:function(a){if(""===
a)return!1;var b=cc.spriteFrameCache.getSpriteFrame(a);return b?this.initWithSpriteFrame(b):cc.log("Can't find CCSpriteFrame with %s. Please check your .plist file",a),this._displayName=a,!0},initWithFile:function(a,b){var c=b?cc.Sprite.prototype.initWithFile.call(this,a,b):cc.Sprite.prototype.initWithFile.call(this,a);return this._displayName=a,c},setSkinData:function(a){this._skinData=a;this.setScaleX(a.scaleX);this.setScaleY(a.scaleY);this.setRotationX(cc.radiansToDegrees(a.skewX));this.setRotationY(cc.radiansToDegrees(-a.skewY));
this.setPosition(a.x,a.y);a=this.getNodeToParentTransform?this.getNodeToParentTransform():this.nodeToParentTransform();var b=this._skinTransform;b.a=a.a;b.b=a.b;b.c=a.c;b.d=a.d;b.tx=a.tx;b.ty=a.ty;this.updateArmatureTransform()},getSkinData:function(){return this._skinData},updateArmatureTransform:function(){this._renderCmd.updateArmatureTransform()},getNodeToWorldTransform:function(){return this._renderCmd.getNodeToWorldTransform()},getNodeToWorldTransformAR:function(){return this._renderCmd.getNodeToWorldTransformAR()},
setBone:function(a){this.bone=a;(a=this.bone.getArmature())&&(this._armature=a)},getBone:function(){return this.bone},getDisplayName:function(){return this._displayName},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new ccs.Skin.CanvasRenderCmd(this):new ccs.Skin.WebGLRenderCmd(this)}});_p=ccs.Skin.prototype;_p.skinData;cc.defineGetterSetter(_p,"skinData",_p.getSkinData,_p.setSkinData);_p.displayName;cc.defineGetterSetter(_p,"displayName",_p.getDisplayName);_p=null;
ccs.Skin.create=function(a,b){return new ccs.Skin(a,b)};ccs.Skin.createWithSpriteFrameName=function(a){return new ccs.Skin("#"+a)};
(function(){ccs.Skin.RenderCmd={updateArmatureTransform:function(){var a=this._node;this._transform=cc.affineTransformConcat(a._skinTransform,a.bone.getNodeToArmatureTransform());this._dirtyFlag^=this._dirtyFlag&cc.Node._dirtyFlags.transformDirty},getNodeToWorldTransform:function(){return cc.affineTransformConcat(this._transform,this._node.bone.getArmature().getNodeToWorldTransform())},getNodeToWorldTransformAR:function(){var a=this._transform,c=this._node;return this._anchorPointInPoints=cc.pointApplyAffineTransform(this._anchorPointInPoints,
a),a.tx=this._anchorPointInPoints.x,a.ty=this._anchorPointInPoints.y,cc.affineTransformConcat(a,c.bone.getArmature().getNodeToWorldTransform())}};ccs.Skin.CanvasRenderCmd=function(a){cc.Sprite.CanvasRenderCmd.call(this,a);this._needDraw=!0};var a=ccs.Skin.CanvasRenderCmd.prototype=Object.create(cc.Sprite.CanvasRenderCmd.prototype);cc.inject(ccs.Skin.RenderCmd,a);a.constructor=ccs.Skin.CanvasRenderCmd})();ccs.ANIMATION_TYPE_SINGLE_FRAME=-4;ccs.ANIMATION_TYPE_NO_LOOP=-3;
ccs.ANIMATION_TYPE_TO_LOOP_FRONT=-2;ccs.ANIMATION_TYPE_TO_LOOP_BACK=-1;ccs.ANIMATION_TYPE_LOOP_FRONT=0;ccs.ANIMATION_TYPE_LOOP_BACK=1;ccs.ANIMATION_TYPE_MAX=2;
ccs.ProcessBase=ccs.Class.extend({_processScale:1,_isComplete:!0,_isPause:!0,_isPlaying:!1,_currentPercent:0,_rawDuration:0,_loopType:0,_tweenEasing:0,animationInternal:null,_currentFrame:0,_durationTween:0,_nextFrameIndex:0,_curFrameIndex:null,_isLoopBack:!1,ctor:function(){this._processScale=1;this._isPause=this._isComplete=!0;this._isPlaying=!1;this._rawDuration=this._durationTween=this._currentPercent=this._currentFrame=0;this._loopType=ccs.ANIMATION_TYPE_LOOP_BACK;this._tweenEasing=ccs.TweenType.LINEAR;
this.animationInternal=1/60;this._durationTween=this._curFrameIndex=0;this._isLoopBack=!1},pause:function(){this._isPause=!0;this._isPlaying=!1},resume:function(){this._isPause=!1;this._isPlaying=!0},stop:function(){this._isComplete=!0;this._isPlaying=!1},play:function(a,b,c,d){this._isPause=this._isComplete=!1;this._isPlaying=!0;this._currentFrame=0;this._nextFrameIndex=a;this._tweenEasing=d},update:function(a){if(!this._isComplete&&!this._isPause&&!(0>=this._rawDuration||1<a)){var b=void 0===this._nextFrameIndex?
0:this._nextFrameIndex,c=this._currentFrame;0>=b?(this._currentPercent=1,c=0):(c+=this._processScale*(a/this.animationInternal),this._currentPercent=c/b,c=ccs.fmodf(c,b));this._currentFrame=c;this.updateHandler()}},gotoFrame:function(a){var b=this._loopType;b===ccs.ANIMATION_TYPE_NO_LOOP?b=ccs.ANIMATION_TYPE_MAX:b===ccs.ANIMATION_TYPE_TO_LOOP_FRONT&&(b=ccs.ANIMATION_TYPE_LOOP_FRONT);this._loopType=b;this._curFrameIndex=a;this._nextFrameIndex=this._durationTween},getCurrentFrameIndex:function(){return this._curFrameIndex=
(this._rawDuration-1)*this._currentPercent,this._curFrameIndex},updateHandler:function(){},isPause:function(){return this._isPause},isComplete:function(){return this._isComplete},getCurrentPercent:function(){return this._currentPercent},getRawDuration:function(){return this._rawDuration},getLoop:function(){return this._loopType},getTweenEasing:function(){return this._tweenEasing},getAnimationInternal:function(){return this.animationInternal},setAnimationInternal:function(a){this.animationInternal=
a},getProcessScale:function(){return this._processScale},setProcessScale:function(a){this._processScale=a},isPlaying:function(){return this._isPlaying}});_p=ccs.ProcessBase.prototype;_p.currentFrameIndex;cc.defineGetterSetter(_p,"currentFrameIndex",_p.getCurrentFrameIndex);_p.paused;cc.defineGetterSetter(_p,"paused",_p.isPause);_p.completed;cc.defineGetterSetter(_p,"completed",_p.isComplete);_p.currentPercent;cc.defineGetterSetter(_p,"currentPercent",_p.getCurrentPercent);_p.rawDuration;
cc.defineGetterSetter(_p,"rawDuration",_p.getRawDuration);_p.loop;cc.defineGetterSetter(_p,"loop",_p.getLoop);_p.tweenEasing;cc.defineGetterSetter(_p,"tweenEasing",_p.getTweenEasing);_p.playing;cc.defineGetterSetter(_p,"playing",_p.isPlaying);_p=null;ccs.MovementEventType={start:0,complete:1,loopComplete:2};
ccs.AnimationEvent=ccs.Class.extend({_arguments:null,_callFunc:null,_selectorTarget:null,ctor:function(a,b,c){this._data=c;this._callFunc=a;this._selectorTarget=b},call:function(){this._callFunc&&this._callFunc.apply(this._selectorTarget,this._arguments)},setArguments:function(a){this._arguments=a}});ccs.MovementEvent=function(){this.armature=null;this.movementType=ccs.MovementEventType.start;this.movementID=""};
ccs.FrameEvent=function(){this.bone=null;this.frameEventName="";this.currentFrameIndex=this.originFrameIndex=0};
ccs.ArmatureAnimation=ccs.ProcessBase.extend({_animationData:null,_movementData:null,_armature:null,_movementID:"",_toIndex:0,_tweenList:null,_speedScale:1,_ignoreFrameEvent:!1,_frameEventQueue:null,_movementEventQueue:null,_movementList:null,_onMovementList:!1,_movementListLoop:!1,_movementIndex:0,_movementListDurationTo:-1,_movementEventCallFunc:null,_frameEventCallFunc:null,_movementEventTarget:null,_frameEventTarget:null,_movementEventListener:null,_frameEventListener:null,ctor:function(a){ccs.ProcessBase.prototype.ctor.call(this);
this._tweenList=[];this._movementList=[];this._frameEventQueue=[];this._movementEventQueue=[];this._armature=null;a&&ccs.ArmatureAnimation.prototype.init.call(this,a)},init:function(a){return this._armature=a,this._tweenList.length=0,!0},pause:function(){for(var a=this._tweenList,b=0;b<a.length;b++)a[b].pause();ccs.ProcessBase.prototype.pause.call(this)},resume:function(){for(var a=this._tweenList,b=0;b<a.length;b++)a[b].resume();ccs.ProcessBase.prototype.resume.call(this)},stop:function(){for(var a=
this._tweenList,b=0;b<a.length;b++)a[b].stop();a.length=0;ccs.ProcessBase.prototype.stop.call(this)},setAnimationScale:function(a){this.setSpeedScale(a)},getAnimationScale:function(){return this.getSpeedScale()},setSpeedScale:function(a){if(a!==this._speedScale){this._speedScale=a;this._processScale=this._movementData?this._speedScale*this._movementData.scale:this._speedScale;a=this._armature.getBoneDic();for(var b in a){var c=a[b];c.getTween().setProcessScale(this._processScale);c.getChildArmature()&&
c.getChildArmature().getAnimation().setSpeedScale(this._processScale)}}},getSpeedScale:function(){return this._speedScale},play:function(a,b,c){cc.assert(this._animationData,"this.animationData can not be null");this._movementData=this._animationData.getMovement(a);cc.assert(this._movementData,"this._movementData can not be null");b=void 0===b?-1:b;c=void 0===c?-1:c;this._rawDuration=this._movementData.duration;this._movementID=a;this._processScale=this._speedScale*this._movementData.scale;b=-1===
b?this._movementData.durationTo:b;a=0===this._movementData.durationTween?this._rawDuration:this._movementData.durationTween;var d=this._movementData.tweenEasing;c=0>c?this._movementData.loop:c;this._onMovementList=!1;ccs.ProcessBase.prototype.play.call(this,b,a,c,d);0===this._rawDuration?this._loopType=ccs.ANIMATION_TYPE_SINGLE_FRAME:(this._loopType=c?ccs.ANIMATION_TYPE_TO_LOOP_FRONT:ccs.ANIMATION_TYPE_NO_LOOP,this._durationTween=a);this._tweenList.length=0;var e,f=this._armature.getBoneDic(),g;for(g in f){var h=
f[g];e=this._movementData.movBoneDataDic[h.getName()];var k=h.getTween();e&&0<e.frameList.length?(this._tweenList.push(k),e.duration=this._movementData.duration,k.play(e,b,a,c,d),k.setProcessScale(this._processScale),h.getChildArmature()&&h.getChildArmature().getAnimation().setSpeedScale(this._processScale)):h.isIgnoreMovementBoneData()||(h.getDisplayManager().changeDisplayWithIndex(-1,!1),k.stop())}this._armature.update(0)},playByIndex:function(a,b,c,d,e){cc.log("playByIndex is deprecated. Use playWithIndex instead.");
this.playWithIndex(a,b,d)},playWithIndex:function(a,b,c){var d=this._animationData.movementNames;cc.assert(-1<a&&a<d.length);this.play(d[a],b,c)},playWithNames:function(a,b,c){this._movementListLoop=void 0===c?!0:c;this._movementListDurationTo=void 0===b?-1:b;this._onMovementList=!0;this._movementIndex=0;a instanceof Array?this._movementList=a:this._movementList.length=0;this.updateMovementList()},playWithIndexes:function(a,b,c){this._movementList.length=0;this._movementListLoop=void 0===c?!0:c;this._movementListDurationTo=
void 0===b?-1:b;this._onMovementList=!0;this._movementIndex=0;b=this._animationData.movementNames;for(c=0;c<a.length;c++)this._movementList.push(b[a[c]]);this.updateMovementList()},gotoAndPlay:function(a){if(!this._movementData||0>a||a>=this._movementData.duration)return void cc.log("Please ensure you have played a movement, and the frameIndex is in the range.");var b=this._ignoreFrameEvent;this._isPlaying=this._ignoreFrameEvent=!0;this._isComplete=this._isPause=!1;ccs.ProcessBase.prototype.gotoFrame.call(this,
a);this._currentPercent=this._curFrameIndex/(this._movementData.duration-1);this._currentFrame=this._nextFrameIndex*this._currentPercent;for(var c=this._tweenList,d=0;d<c.length;d++)c[d].gotoAndPlay(a);this._armature.update(0);this._ignoreFrameEvent=b},gotoAndPause:function(a){this.gotoAndPlay(a);this.pause()},getMovementCount:function(){return this._animationData.getMovementCount()},update:function(a){ccs.ProcessBase.prototype.update.call(this,a);for(var b=this._tweenList,c=0;c<b.length;c++)b[c].update(a);
for(b=this._frameEventQueue;0<b.length;)a=b.shift(),this._ignoreFrameEvent=!0,this._frameEventCallFunc&&this._frameEventCallFunc.call(this._frameEventTarget,a.bone,a.frameEventName,a.originFrameIndex,a.currentFrameIndex),this._frameEventListener&&this._frameEventListener(a.bone,a.frameEventName,a.originFrameIndex,a.currentFrameIndex),this._ignoreFrameEvent=!1;for(b=this._movementEventQueue;0<b.length;)a=b.shift(),this._movementEventCallFunc&&this._movementEventCallFunc.call(this._movementEventTarget,
a.armature,a.movementType,a.movementID),this._movementEventListener&&this._movementEventListener(a.armature,a.movementType,a.movementID)},updateHandler:function(){var a=this._currentPercent;if(1<=a){switch(this._loopType){case ccs.ANIMATION_TYPE_NO_LOOP:if(this._loopType=ccs.ANIMATION_TYPE_MAX,this._currentFrame=(a-1)*this._nextFrameIndex,a=this._currentFrame/this._durationTween,1>a){this._nextFrameIndex=this._durationTween;this.movementEvent(this._armature,ccs.MovementEventType.start,this._movementID);
break}break;case ccs.ANIMATION_TYPE_MAX:case ccs.ANIMATION_TYPE_SINGLE_FRAME:a=1;this._isComplete=!0;this._isPlaying=!1;this.movementEvent(this._armature,ccs.MovementEventType.complete,this._movementID);this.updateMovementList();break;case ccs.ANIMATION_TYPE_TO_LOOP_FRONT:this._loopType=ccs.ANIMATION_TYPE_LOOP_FRONT;a=ccs.fmodf(a,1);this._currentFrame=0===this._nextFrameIndex?0:ccs.fmodf(this._currentFrame,this._nextFrameIndex);this._nextFrameIndex=0<this._durationTween?this._durationTween:1;this.movementEvent(this,
ccs.MovementEventType.start,this._movementID);break;default:this._currentFrame=ccs.fmodf(this._currentFrame,this._nextFrameIndex),this._toIndex=0,this.movementEvent(this._armature,ccs.MovementEventType.loopComplete,this._movementID)}this._currentPercent=a}},getCurrentMovementID:function(){return this._isComplete?"":this._movementID},setMovementEventCallFunc:function(a,b){1===arguments.length?this._movementEventListener=a:2===arguments.length&&(this._movementEventTarget=b,this._movementEventCallFunc=
a)},setFrameEventCallFunc:function(a,b){1===arguments.length?this._frameEventListener=a:2===arguments.length&&(this._frameEventTarget=b,this._frameEventCallFunc=a)},setUserObject:function(a){this._userObject=a},frameEvent:function(a,b,c,d){if(this._frameEventTarget&&this._frameEventCallFunc||this._frameEventListener){var e=new ccs.FrameEvent;e.bone=a;e.frameEventName=b;e.originFrameIndex=c;e.currentFrameIndex=d;this._frameEventQueue.push(e)}},movementEvent:function(a,b,c){if(this._movementEventTarget&&
this._movementEventCallFunc||this._movementEventListener){var d=new ccs.MovementEvent;d.armature=a;d.movementType=b;d.movementID=c;this._movementEventQueue.push(d)}},updateMovementList:function(){if(this._onMovementList){var a,b=this._movementList;this._movementListLoop?(a=b[this._movementIndex],this.play(a,a.durationTo,0),this._movementIndex++,this._movementIndex>=b.length&&(this._movementIndex=0)):this._movementIndex<b.length?(a=b[this._movementIndex],this.play(a,a.durationTo,0),this._movementIndex++):
this._onMovementList=!1;this._onMovementList=!0}},setAnimationData:function(a){this._animationData!==a&&(this._animationData=a)},getAnimationData:function(){return this._animationData},getUserObject:function(){return this._userObject},isIgnoreFrameEvent:function(){return this._ignoreFrameEvent}});_p=ccs.ArmatureAnimation.prototype;_p.speedScale;cc.defineGetterSetter(_p,"speedScale",_p.getSpeedScale,_p.setSpeedScale);_p.animationScale;
cc.defineGetterSetter(_p,"animationScale",_p.getAnimationScale,_p.setAnimationScale);_p=null;ccs.ArmatureAnimation.create=function(a){return new ccs.ArmatureAnimation(a)};
ccs.Tween=ccs.ProcessBase.extend({_tweenData:null,_to:null,_from:null,_between:null,_movementBoneData:null,_bone:null,_frameTweenEasing:0,_betweenDuration:0,_totalDuration:0,_toIndex:0,_fromIndex:0,_animation:null,_passLastFrame:!1,ctor:function(a){ccs.ProcessBase.prototype.ctor.call(this);this._frameTweenEasing=ccs.TweenType.LINEAR;ccs.Tween.prototype.init.call(this,a)},init:function(a){return this._from=new ccs.FrameData,this._between=new ccs.FrameData,this._bone=a,this._tweenData=this._bone.getTweenData(),
this._tweenData.displayIndex=-1,this._animation=null!==this._bone&&null!==this._bone.getArmature()?this._bone.getArmature().getAnimation():null,!0},play:function(a,b,c,d,e){ccs.ProcessBase.prototype.play.call(this,b,c,d,e);this._loopType=d?ccs.ANIMATION_TYPE_TO_LOOP_FRONT:ccs.ANIMATION_TYPE_NO_LOOP;this._fromIndex=this._toIndex=this._betweenDuration=this._totalDuration=0;e=a!==this._movementBoneData;this.setMovementBoneData(a);this._rawDuration=this._movementBoneData.duration;a=this._movementBoneData.getFrameData(0);
this._tweenData.displayIndex=a.displayIndex;this._bone.getArmature().getArmatureData().dataVersion>=ccs.CONST_VERSION_COMBINED&&(ccs.TransformHelp.nodeSub(this._tweenData,this._bone.getBoneData()),this._tweenData.scaleX+=1,this._tweenData.scaleY+=1);0===this._rawDuration?(this._loopType=ccs.ANIMATION_TYPE_SINGLE_FRAME,0===b?this.setBetween(a,a):this.setBetween(this._tweenData,a),this._frameTweenEasing=ccs.TweenType.LINEAR):1<this._movementBoneData.frameList.length&&(this._durationTween=c*this._movementBoneData.scale,
d&&0!==this._movementBoneData.delay?this.setBetween(this._tweenData,this.tweenNodeTo(this.updateFrameData(1-this._movementBoneData.delay),this._between)):e&&0!==b?this.setBetween(this._tweenData,a):this.setBetween(a,a));this.tweenNodeTo(0)},gotoAndPlay:function(a){ccs.ProcessBase.prototype.gotoFrame.call(this,a);this._fromIndex=this._toIndex=this._betweenDuration=this._totalDuration=0;this._isPlaying=!0;this._isComplete=this._isPause=!1;this._currentPercent=this._curFrameIndex/(this._rawDuration-
1);this._currentFrame=this._nextFrameIndex*this._currentPercent},gotoAndPause:function(a){this.gotoAndPlay(a);this.pause()},updateHandler:function(){var a=null==this._currentPercent?1:this._currentPercent,b=this._loopType;if(1<=a)switch(b){case ccs.ANIMATION_TYPE_SINGLE_FRAME:a=1;this._isComplete=!0;this._isPlaying=!1;break;case ccs.ANIMATION_TYPE_NO_LOOP:if(b=ccs.ANIMATION_TYPE_MAX,a=0>=this._durationTween?1:(a-1)*this._nextFrameIndex/this._durationTween,1<=a){a=1;this._isComplete=!0;this._isPlaying=
!1;break}this._nextFrameIndex=this._durationTween;this._currentFrame=a*this._nextFrameIndex;this._fromIndex=this._toIndex=this._betweenDuration=this._totalDuration=0;break;case ccs.ANIMATION_TYPE_TO_LOOP_FRONT:b=ccs.ANIMATION_TYPE_LOOP_FRONT;this._nextFrameIndex=0<this._durationTween?this._durationTween:1;0!==this._movementBoneData.delay?(this._currentFrame=(1-this._movementBoneData.delay)*this._nextFrameIndex,a=this._currentFrame/this._nextFrameIndex):(a=0,this._currentFrame=0);this._fromIndex=this._toIndex=
this._betweenDuration=this._totalDuration=0;break;case ccs.ANIMATION_TYPE_MAX:a=1;this._isComplete=!0;this._isPlaying=!1;break;default:this._currentFrame=ccs.fmodf(this._currentFrame,this._nextFrameIndex)}1>a&&b<ccs.ANIMATION_TYPE_TO_LOOP_BACK&&(a=Math.sin(a*cc.PI/2));this._currentPercent=a;this._loopType=b;b>ccs.ANIMATION_TYPE_TO_LOOP_BACK&&(a=this.updateFrameData(a));this._frameTweenEasing!==ccs.TweenType.TWEEN_EASING_MAX&&this.tweenNodeTo(a)},setBetween:function(a,b,c){void 0===c&&(c=!0);0>a.displayIndex&&
0<=b.displayIndex?(this._from.copy(b),this._between.subtract(b,b,c)):0>b.displayIndex&&0<=a.displayIndex?(this._from.copy(a),this._between.subtract(b,b,c)):(this._from.copy(a),this._between.subtract(a,b,c));a.isTween||(this._tweenData.copy(a),this._tweenData.isTween=!0);this.arriveKeyFrame(a)},arriveKeyFrame:function(a){if(a){var b=this._bone,c=b.getDisplayManager(),d=a.displayIndex;c.getForceChangeDisplay()||c.changeDisplayWithIndex(d,!1);this._tweenData.zOrder=a.zOrder;b.updateZOrder();this._bone.setBlendFunc(a.blendFunc);
(b=b.getChildArmature())&&""!==a.movement&&b.getAnimation().play(a.movement)}},tweenNodeTo:function(a,b){b||(b=this._tweenData);var c=this._from,d=this._between;return c.isTween||(a=0),b.x=c.x+a*d.x,b.y=c.y+a*d.y,b.scaleX=c.scaleX+a*d.scaleX,b.scaleY=c.scaleY+a*d.scaleY,b.skewX=c.skewX+a*d.skewX,b.skewY=c.skewY+a*d.skewY,this._bone.setTransformDirty(!0),b&&d.isUseColorInfo&&this.tweenColorTo(a,b),b},tweenColorTo:function(a,b){var c=this._from,d=this._between;b.a=c.a+a*d.a;b.r=c.r+a*d.r;b.g=c.g+a*
d.g;b.b=c.b+a*d.b;this._bone.updateColor()},updateFrameData:function(a){1<a&&0!==this._movementBoneData.delay&&(a=ccs.fmodf(a,1));var b,c;a*=this._rawDuration-1;var d=this._totalDuration,e=this._betweenDuration,f=this._toIndex;if(d>a||a>=d+e){var e=this._movementBoneData.frameList,g=e.length;if(a<e[0].frameID)return b=c=e[0],this.setBetween(b,c),this._currentPercent;if(a>=e[g-1].frameID){if(this._passLastFrame)return b=c=e[g-1],this.setBetween(b,c),this._currentPercent;this._passLastFrame=!0}else this._passLastFrame=
!1;do if(this._fromIndex=f,b=e[this._fromIndex],d=b.frameID,f=this._fromIndex+1,f>=g&&(f=0),c=e[f],b.strEvent&&!this._animation.isIgnoreFrameEvent()&&this._animation.frameEvent(this._bone,b.strEvent,b.frameID,a),a===b.frameID||this._passLastFrame&&this._fromIndex===g-1)break;while(a<b.frameID||a>=c.frameID);e=c.frameID-b.frameID;this._frameTweenEasing=b.tweenEasing;this.setBetween(b,c,!1);this._totalDuration=d;this._betweenDuration=e;this._toIndex=f}a=0===e?0:(a-this._totalDuration)/this._betweenDuration;
b=this._frameTweenEasing!==ccs.TweenType.LINEAR?this._frameTweenEasing:this._tweenEasing;return b===ccs.TweenType.TWEEN_EASING_MAX||b===ccs.TweenType.LINEAR||this._passLastFrame||(a=ccs.TweenFunction.tweenTo(a,b,this._from.easingParams)),a},setAnimation:function(a){this._animation=a},getAnimation:function(){return this._animation},setMovementBoneData:function(a){this._movementBoneData=a}});_p=ccs.Tween.prototype;_p.animation;cc.defineGetterSetter(_p,"animation",_p.getAnimation,_p.setAnimation);
_p=null;ccs.Tween.create=function(a){return new ccs.Tween(a)};ccs.PT_RATIO=32;
ccs.ColliderFilter=ccs.Class.extend({_collisionType:0,_group:0,_categoryBits:0,_groupIndex:0,_maskBits:0,ctor:function(a,b){this._collisionType=a||0;this._group=b||0},updateShape:function(a){if(a instanceof cp.Shape)a.collision_type=this._collisionType,a.group=this._group;else if(a instanceof Box2D.b2FilterData){var b=new Box2D.b2FilterData;b.categoryBits=this._categoryBits;b.groupIndex=this._groupIndex;b.maskBits=this._maskBits;a.SetFilterData(b)}}});
ccs.ColliderBody=ccs.Class.extend({shape:null,coutourData:null,colliderFilter:null,_calculatedVertexList:null,ctor:function(a){this.shape=null;this.coutourData=a;this.colliderFilter=new ccs.ColliderFilter;ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX&&(this._calculatedVertexList=[])},getContourData:function(){return this.coutourData},setColliderFilter:function(a){this.colliderFilter=a},getCalculatedVertexList:function(){return this._calculatedVertexList},setB2Fixture:function(a){this._fixture=a},getB2Fixture:function(){return this._fixture},
setShape:function(a){this.shape=a},getShape:function(){return this.shape},setContourData:function(a){this.coutourData=a},getColliderFilter:function(){return this.colliderFilter}});
ccs.ColliderDetector=ccs.Class.extend({_colliderBodyList:null,_bone:null,_body:null,_active:!1,_filter:null,helpPoint:cc.p(0,0),ctor:function(a){this._colliderBodyList=[];this._body=this._bone=null;this._active=!1;this._filter=null;ccs.ColliderDetector.prototype.init.call(this,a)},init:function(a){return this._colliderBodyList.length=0,a&&(this._bone=a),this._filter=new ccs.ColliderFilter,!0},addContourData:function(a){var b=new ccs.ColliderBody(a);if(this._colliderBodyList.push(b),ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX){b=
b.getCalculatedVertexList();a=a.vertexList;for(var c=0;c<a.length;c++){var d=new ccs.ContourVertex2(0,0);b.push(d)}}},addContourDataList:function(a){for(var b=0;b<a.length;b++)this.addContourData(a[b])},removeContourData:function(a){var b,c=[],d=this._colliderBodyList;for(b=0;b<d.length;b++){var e=d[b];e&&e.getContourData()===a&&c.push(e)}for(b=0;b<c.length;b++)cc.arrayRemoveObject(d,c[b])},removeAll:function(){this._colliderBodyList.length=0},setActive:function(a){if(this._active!==a){this._active=
a;var b;if(a=this._body)if(b=null,this._active)for(var c=0;c<this._colliderBodyList.length;c++)b=this._colliderBodyList[c],b=b.getShape(),a.space.addShape(b);else for(c=0;c<this._colliderBodyList.length;c++)b=this._colliderBodyList[c],b=b.getShape(),a.space.removeShape(b)}},getActive:function(){return this._active},getColliderBodyList:function(){return this._colliderBodyList},setColliderFilter:function(a){this._filter=a;for(var b=this._colliderBodyList,c=0;c<b.length;c++){var d=b[c];d.setColliderFilter(a);
d.getShape()&&d.getColliderFilter().updateShape(d.getShape())}},getColliderFilter:function(){return this._filter},updateTransform:function(a){if(this._active)for(var b=null,c=this._body,d=this.helpPoint,e=0;e<this._colliderBodyList.length;e++){var b=this._colliderBodyList[e],f=b.getContourData(),g=null;c&&(g=b.getShape());for(var f=f.vertexList,h=b.getCalculatedVertexList(),b=0;b<f.length;b++){if(d.x=f[b].x,d.y=f[b].y,d=cc.pointApplyAffineTransform(d,a),ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX){var k=
cc.p(0,0);k.x=d.x;k.y=d.y;h[b]=k}g&&(g.verts[2*b]=d.x,g.verts[2*b+1]=d.y)}if(g)for(b=0;b<f.length;b++)h=cp.v.normalize(cp.v.perp(cp.v.sub(g.verts[(b+1)%g.verts.length],g.verts[b]))),g.planes&&(g.planes[b].n=h,g.planes[b].d=cp.v.dot(h,g.verts[b]))}},setBody:function(a){this._body=a;for(var b=this._colliderBodyList,c=0;c<b.length;c++){a=b[c];for(var d=[],e=a.getContourData().vertexList,f=0;f<e.length;f++){var g=e[f];d.push(g.x);d.push(g.y)}d=new cp.PolyShape(this._body,d,cp.vzero);d.sensor=!0;d.data=
this._bone;this._active&&this._body.space.addShape(d);a.setShape(d);a.getColliderFilter().updateShape(d)}},getBody:function(){return this._body}});_p=ccs.ColliderDetector.prototype;_p.colliderFilter;cc.defineGetterSetter(_p,"colliderFilter",_p.getColliderFilter,_p.setColliderFilter);_p.active;cc.defineGetterSetter(_p,"active",_p.getActive,_p.setActive);_p.body;cc.defineGetterSetter(_p,"body",_p.getBody,_p.setBody);_p=null;ccs.ColliderDetector.create=function(a){return new ccs.ColliderDetector(a)};
ccs.Armature=ccs.Node.extend({animation:null,armatureData:null,batchNode:null,_textureAtlas:null,_parentBone:null,_boneDic:null,_topBoneList:null,_armatureIndexDic:null,_offsetPoint:null,version:0,_armatureTransformDirty:!0,_body:null,_blendFunc:null,_className:"Armature",ctor:function(a,b){cc.Node.prototype.ctor.call(this);this._name="";this._topBoneList=[];this._armatureIndexDic={};this._offsetPoint=cc.p(0,0);this._armatureTransformDirty=!0;this._blendFunc={src:cc.BLEND_SRC,dst:cc.BLEND_DST};a&&
ccs.Armature.prototype.init.call(this,a,b)},init:function(a,b){cc.Node.prototype.init.call(this);b&&(this._parentBone=b);this.removeAllChildren();this.animation=new ccs.ArmatureAnimation;this.animation.init(this);this._boneDic={};this._topBoneList.length=0;var c,d=ccs.armatureDataManager;if(""!==a){c=d.getAnimationData(a);cc.assert(c,"AnimationData not exist!");this.animation.setAnimationData(c);d=d.getArmatureData(a);cc.assert(d,"ArmatureData not exist!");this.armatureData=d;var d=d.getBoneDataDic(),
e;for(e in d){var d=this.createBone(String(e)),f=c.getMovement(c.movementNames[0]);if(f&&(f=f.getMovementBoneData(d.getName()))&&!(0>=f.frameList.length))if(f=f.getFrameData(0))d.getTweenData().copy(f),d.changeDisplayWithIndex(f.displayIndex,!1)}this.update(0);this.updateOffsetPoint()}else a="new_armature",this.armatureData=new ccs.ArmatureData,this.armatureData.name=a,c=new ccs.AnimationData,c.name=a,d.addArmatureData(a,this.armatureData),d.addAnimationData(a,c),this.animation.setAnimationData(c);
return this._renderCmd.initShaderCache(),this.setCascadeOpacityEnabled(!0),this.setCascadeColorEnabled(!0),!0},addChild:function(a,b,c){return a instanceof ccui.Widget?void cc.log("Armature doesn't support to add Widget as its child, it will be fix soon."):void cc.Node.prototype.addChild.call(this,a,b,c)},createBone:function(a){var b=this.getBone(a);if(b)return b;var b=this.armatureData.getBoneData(a),c=b.parentName,d=null;return c?(this.createBone(c),d=new ccs.Bone(a),this.addBone(d,c)):(d=new ccs.Bone(a),
this.addBone(d,"")),d.setBoneData(b),d.getDisplayManager().changeDisplayWithIndex(-1,!1),d},addBone:function(a,b){cc.assert(a,"Argument must be non-nil");var c=this._boneDic;if(a.getName()&&cc.assert(!c[a.getName()],"bone already added. It can't be added again"),b){var d=c[b];d?d.addChildBone(a):this._topBoneList.push(a)}else this._topBoneList.push(a);a.setArmature(this);c[a.getName()]=a;this.addChild(a)},removeBone:function(a,b){cc.assert(a,"bone must be added to the bone dictionary!");a.setArmature(null);
a.removeFromParent(b);cc.arrayRemoveObject(this._topBoneList,a);delete this._boneDic[a.getName()];this.removeChild(a,!0)},getBone:function(a){return this._boneDic[a]},changeBoneParent:function(a,b){cc.assert(a,"bone must be added to the bone dictionary!");var c=a.getParentBone();if(c&&(cc.arrayRemoveObject(c.getChildren(),a),a.setParentBone(null)),b)(c=this._boneDic[b])?(c.addChildBone(a),cc.arrayRemoveObject(this._topBoneList,a)):this._topBoneList.push(a)},getBoneDic:function(){return this._boneDic},
updateOffsetPoint:function(){var a=this.getBoundingBox();this.setContentSize(a);var b=this._offsetPoint;b.x=-a.x;b.y=-a.y;0!==a.width&&0!==a.height&&this.setAnchorPoint(b.x/a.width,b.y/a.height)},getOffsetPoints:function(){return{x:this._offsetPoint.x,y:this._offsetPoint.y}},setAnimation:function(a){this.animation=a},getAnimation:function(){return this.animation},getArmatureTransformDirty:function(){return this._armatureTransformDirty},update:function(a){this.animation.update(a);for(var b=this._topBoneList,
c=0;c<b.length;c++)b[c].update(a);this._armatureTransformDirty=!1},onEnter:function(){cc.Node.prototype.onEnter.call(this);this.scheduleUpdate()},onExit:function(){cc.Node.prototype.onExit.call(this);this.unscheduleUpdate()},getBoundingBox:function(){for(var a,b,c,d=0,e=!0,f=cc.rect(0,0,0,0),g=this._children,h=g.length,k=0;h>k;k++){var m=g[k];m&&(m=m.getDisplayManager().getBoundingBox(),0===m.x&&0===m.y&&0===m.width&&0===m.height||(e?(a=m.x,b=m.y,c=m.x+m.width,d=m.y+m.height,e=!1):(a=m.x<f.x?m.x:
f.x,b=m.y<f.y?m.y:f.y,c=m.x+m.width>f.x+f.width?m.x+m.width:f.x+f.width,d=m.y+m.height>f.y+f.height?m.y+m.height:f.y+f.height),f.x=a,f.y=b,f.width=c-a,f.height=d-b))}return cc.rectApplyAffineTransform(f,this.getNodeToParentTransform())},getBoneAtPoint:function(a,b){for(var c=this._children,d=c.length-1;0<=d;d--){var e=c[d];if(e instanceof ccs.Bone&&e.getDisplayManager().containPoint(a,b))return e}return null},setParentBone:function(a){this._parentBone=a;a=this._boneDic;for(var b in a)a[b].setArmature(this)},
getParentBone:function(){return this._parentBone},drawContour:function(){cc._drawingUtil.setDrawColor(255,255,255,255);cc._drawingUtil.setLineWidth(1);var a=this._boneDic,b;for(b in a){var c=a[b].getColliderDetector();if(c)for(var c=c.getColliderBodyList(),d=0;d<c.length;d++){var e=c[d].getCalculatedVertexList();cc._drawingUtil.drawPoly(e,e.length,!0)}}},setBody:function(a){if(this._body!==a){this._body=a;this._body.data=this;var b,c;a=this._children;for(var d=0;d<a.length;d++)if(b=a[d],b instanceof
ccs.Bone)for(var e=b.getDisplayManager().getDecorativeDisplayList(),f=0;f<e.length;f++)c=e[f],(c=c.getColliderDetector())&&c.setBody(this._body)}},getShapeList:function(){return this._body?this._body.shapeList:null},getBody:function(){return this._body},setBlendFunc:function(a,b){void 0===b?(this._blendFunc.src=a.src,this._blendFunc.dst=a.dst):(this._blendFunc.src=a,this._blendFunc.dst=b)},getBlendFunc:function(){return new cc.BlendFunc(this._blendFunc.src,this._blendFunc.dst)},setColliderFilter:function(a){var b=
this._boneDic,c;for(c in b)b[c].setColliderFilter(a)},getArmatureData:function(){return this.armatureData},setArmatureData:function(a){this.armatureData=a},getBatchNode:function(){return this.batchNode},setBatchNode:function(a){this.batchNode=a},getVersion:function(){return this.version},setVersion:function(a){this.version=a},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new ccs.Armature.CanvasRenderCmd(this):new ccs.Armature.WebGLRenderCmd(this)}});_p=ccs.Armature.prototype;
_p.parentBone;cc.defineGetterSetter(_p,"parentBone",_p.getParentBone,_p.setParentBone);_p.body;cc.defineGetterSetter(_p,"body",_p.getBody,_p.setBody);_p.colliderFilter;cc.defineGetterSetter(_p,"colliderFilter",null,_p.setColliderFilter);_p=null;ccs.Armature.create=function(a,b){return new ccs.Armature(a,b)};
(function(){ccs.Armature.RenderCmd={_updateAnchorPointInPoint:function(){var a=this._node,b=a._contentSize,c=a._anchorPoint,a=a._offsetPoint;this._anchorPointInPoints.x=b.width*c.x-a.x;this._anchorPointInPoints.y=b.height*c.y-a.y;this._realAnchorPointInPoints.x=b.width*c.x;this._realAnchorPointInPoints.y=b.height*c.y;this.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getAnchorPointInPoints:function(){return cc.p(this._realAnchorPointInPoints)}}})();
(function(){ccs.Armature.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._needDraw=!0;this._realAnchorPointInPoints=new cc.Point(0,0);this._startRenderCmd=new cc.CustomRenderCmd(this,this._startCmdCallback);this._RestoreRenderCmd=new cc.CustomRenderCmd(this,this._RestoreCmdCallback)};var a=ccs.Armature.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);cc.inject(ccs.Armature.RenderCmd,a);a.constructor=ccs.Armature.CanvasRenderCmd;a._startCmdCallback=function(a,
c,d){var e=this._node._parent;this.transform(e?e._renderCmd:null);a=a||cc._renderContext;a.save();a._switchToArmatureMode(!0,this._worldTransform,c,d)};a.transform=function(a,c){ccs.Node.CanvasRenderCmd.prototype.transform.call(this,a,c);for(var d=this._node._children,e=0,f=d.length;f>e;e++){var g=d[e];if(g&&g.getDisplayRenderNode){var h=g.getDisplayRenderNode();if(h&&h._renderCmd){h=h._renderCmd;h.transform(null);var k=g._renderCmd._displayedColor,g=g._renderCmd._displayedOpacity,m=cc.Node._dirtyFlags,
n=h._dirtyFlag,p=n&m.opacityDirty;n&m.colorDirty&&h._updateDisplayColor(k);p&&h._updateDisplayOpacity(g)}}}};a._RestoreCmdCallback=function(a){this._cacheDirty=!1;a._switchToArmatureMode(!1);a.restore()};a.initShaderCache=function(){};a.setShaderProgram=function(){};a.updateChildPosition=function(a,c){cc.renderer.pushRenderCommand(c._renderCmd)};a.rendering=function(a,c,d){for(var e=this._node._children,f=cc.BlendFunc.ALPHA_PREMULTIPLIED,g=cc.BlendFunc.ALPHA_NON_PREMULTIPLIED,h=0,k=e.length;k>h;h++){var m=
e[h];if(m&&m.getDisplayRenderNode){var n=m.getDisplayRenderNode();if(null!==n)switch(m.getDisplayRenderNodeType()){case ccs.DISPLAY_TYPE_SPRITE:n instanceof ccs.Skin&&this.updateChildPosition(a,n,m,f,g);break;case ccs.DISPLAY_TYPE_ARMATURE:n._renderCmd.rendering(a,c,d);break;default:n.visit(this)}}else m instanceof cc.Node&&this._visitNormalChild(m)}};a._visitNormalChild=function(a){if(null!=a){var c=a._renderCmd;if(a._visible){c._curLevel=this._curLevel+1;var d,e=a._children;c._syncStatus(this);
c.transform(null);var f=e.length;if(0<f){a.sortAllChildren();for(a=0;f>a&&(d=e[a],0>d._localZOrder);a++)d._renderCmd.visit(c);for(cc.renderer.pushRenderCommand(c);f>a;a++)e[a]._renderCmd.visit(c)}else cc.renderer.pushRenderCommand(c);this._dirtyFlag=0}}};a.visit=function(a){var c=this._node;c._visible&&(this.updateStatus(a),c.sortAllChildren(),cc.renderer.pushRenderCommand(this._startRenderCmd),this.rendering(),cc.renderer.pushRenderCommand(this._RestoreRenderCmd),this._cacheDirty=!1)}})();
ccs.Bone=ccs.Node.extend({_boneData:null,_armature:null,_childArmature:null,_displayManager:null,ignoreMovementBoneData:!1,_tween:null,_tweenData:null,_parentBone:null,_boneTransformDirty:!1,_worldTransform:null,_blendFunc:null,blendDirty:!1,_worldInfo:null,_armatureParentBone:null,_dataVersion:0,_className:"Bone",ctor:function(a){cc.Node.prototype.ctor.call(this);this._displayManager=this._tween=this._boneData=this._childArmature=this._armature=this._parentBone=this._tweenData=null;this.ignoreMovementBoneData=
!1;this._worldTransform=cc.affineTransformMake(1,0,0,1,0,0);this._boneTransformDirty=!0;this._blendFunc=new cc.BlendFunc(cc.BLEND_SRC,cc.BLEND_DST);this.blendDirty=!1;this._armatureParentBone=this._worldInfo=null;this._dataVersion=0;ccs.Bone.prototype.init.call(this,a)},init:function(a){return a&&(this._name=a),this._tweenData=new ccs.FrameData,this._tween=new ccs.Tween(this),this._displayManager=new ccs.DisplayManager(this),this._worldInfo=new ccs.BaseData,this._boneData=new ccs.BaseData,!0},setBoneData:function(a){cc.assert(a,
"_boneData must not be null");this._boneData!==a&&(this._boneData=a);this.setName(this._boneData.name);this._localZOrder=this._boneData.zOrder;this._displayManager.initDisplayList(a)},getBoneData:function(){return this._boneData},setArmature:function(a){(this._armature=a)?(this._tween.setAnimation(this._armature.getAnimation()),this._dataVersion=this._armature.getArmatureData().dataVersion,this._armatureParentBone=this._armature.getParentBone()):this._armatureParentBone=null},getArmature:function(){return this._armature},
update:function(a){if(this._parentBone&&(this._boneTransformDirty=this._boneTransformDirty||this._parentBone.isTransformDirty()),this._armatureParentBone&&!this._boneTransformDirty&&(this._boneTransformDirty=this._armatureParentBone.isTransformDirty()),this._boneTransformDirty){var b=this._tweenData;this._dataVersion>=ccs.CONST_VERSION_COMBINED&&(ccs.TransformHelp.nodeConcat(b,this._boneData),b.scaleX-=1,b.scaleY-=1);var c=this._worldInfo;c.copy(b);c.x=b.x+this._position.x;c.y=b.y+this._position.y;
c.scaleX=b.scaleX*this._scaleX;c.scaleY=b.scaleY*this._scaleY;c.skewX=b.skewX+this._skewX+cc.degreesToRadians(this._rotationX);c.skewY=b.skewY+this._skewY-cc.degreesToRadians(this._rotationY);this._parentBone?this._applyParentTransform(this._parentBone):this._armatureParentBone&&this._applyParentTransform(this._armatureParentBone);ccs.TransformHelp.nodeToMatrix(c,this._worldTransform);this._armatureParentBone&&(this._worldTransform=cc.affineTransformConcat(this._worldTransform,this._armature.getNodeToParentTransform()))}ccs.displayFactory.updateDisplay(this,
a,this._boneTransformDirty||this._armature.getArmatureTransformDirty());for(b=0;b<this._children.length;b++)this._children[b].update(a);this._boneTransformDirty=!1},_applyParentTransform:function(a){var b=this._worldInfo,c=a._worldTransform;a=a._worldInfo;var d=b.x,e=b.y;b.x=d*c.a+e*c.c+a.x;b.y=d*c.b+e*c.d+a.y;b.scaleX*=a.scaleX;b.scaleY*=a.scaleY;b.skewX+=a.skewX;b.skewY+=a.skewY},setBlendFunc:function(a,b){var c,d,e=this._blendFunc;void 0===b?(c=a.src,d=a.dst):(c=a,d=b);(e.src!==c||e.dst!==d)&&
(e.src=c,e.dst=d,this.blendDirty=!0)},updateColor:function(){var a=this._displayManager.getDisplayRenderNode();if(null!==a){var b=this._renderCmd;a.setColor(cc.color(b._displayedColor.r*this._tweenData.r/255,b._displayedColor.g*this._tweenData.g/255,b._displayedColor.b*this._tweenData.b/255));a.setOpacity(b._displayedOpacity*this._tweenData.a/255)}},updateZOrder:function(){this.setLocalZOrder(this._armature.getArmatureData().dataVersion>=ccs.CONST_VERSION_COMBINED?this._tweenData.zOrder+this._boneData.zOrder:
this._tweenData.zOrder)},addChildBone:function(a){cc.assert(a,"Argument must be non-nil");cc.assert(!a.parentBone,"child already added. It can't be added again");0>this._children.indexOf(a)&&(this._children.push(a),a.setParentBone(this))},removeChildBone:function(a,b){if(0<this._children.length&&-1!==this._children.getIndex(a)){if(b)for(var c=a._children,d=0;d<c.length;d++)a.removeChildBone(c[d],b);a.setParentBone(null);a.getDisplayManager().setCurrentDecorativeDisplay(null);cc.arrayRemoveObject(this._children,
a)}},removeFromParent:function(a){this._parentBone&&this._parentBone.removeChildBone(this,a)},setParentBone:function(a){this._parentBone=a},getParentBone:function(){return this._parentBone},setChildArmature:function(a){this._childArmature!==a&&(null==a&&this._childArmature&&this._childArmature.setParentBone(null),this._childArmature=a)},getChildArmature:function(){return this._childArmature},getTween:function(){return this._tween},setLocalZOrder:function(a){this._localZOrder!==a&&cc.Node.prototype.setLocalZOrder.call(this,
a)},getNodeToArmatureTransform:function(){return this._worldTransform},getNodeToWorldTransform:function(){return cc.affineTransformConcat(this._worldTransform,this._armature.getNodeToWorldTransform())},getDisplayRenderNode:function(){return this._displayManager.getDisplayRenderNode()},getDisplayRenderNodeType:function(){return this._displayManager.getDisplayRenderNodeType()},addDisplay:function(a,b){return b=b||0,this._displayManager.addDisplay(a,b)},removeDisplay:function(a){this._displayManager.removeDisplay(a)},
changeDisplayByIndex:function(a,b){cc.log("changeDisplayByIndex is deprecated. Use changeDisplayWithIndex instead.");this.changeDisplayWithIndex(a,b)},changeDisplayByName:function(a,b){cc.log("changeDisplayByName is deprecated. Use changeDisplayWithName instead.");this.changeDisplayWithName(a,b)},changeDisplayWithIndex:function(a,b){this._displayManager.changeDisplayWithIndex(a,b)},changeDisplayWithName:function(a,b){this._displayManager.changeDisplayWithName(a,b)},getColliderDetector:function(){var a=
this._displayManager.getCurrentDecorativeDisplay();return a&&(a=a.getColliderDetector())?a:null},setColliderFilter:function(a){for(var b=this._displayManager.getDecorativeDisplayList(),c=0;c<b.length;c++){var d=b[c].getColliderDetector();d&&d.setColliderFilter(a)}},getColliderFilter:function(){var a=this.displayManager.getCurrentDecorativeDisplay();return a&&(a=a.getColliderDetector())?a.getColliderFilter():null},setTransformDirty:function(a){this._boneTransformDirty=a},isTransformDirty:function(){return this._boneTransformDirty},
getDisplayManager:function(){return this._displayManager},setIgnoreMovementBoneData:function(a){this._ignoreMovementBoneData=a},isIgnoreMovementBoneData:function(){return this._ignoreMovementBoneData},getBlendFunc:function(){return new cc.BlendFunc(this._blendFunc.src,this._blendFunc.dst)},setBlendDirty:function(a){this._blendDirty=a},isBlendDirty:function(){return this._blendDirty},getTweenData:function(){return this._tweenData},getWorldInfo:function(){return this._worldInfo},getChildrenBone:function(){return this._children},
nodeToArmatureTransform:function(){return this.getNodeToArmatureTransform()},nodeToWorldTransform:function(){return this.getNodeToWorldTransform()},getColliderBodyList:function(){var a=this.getColliderDetector();return a?a.getColliderBodyList():null},getIgnoreMovementBoneData:function(){return this.isIgnoreMovementBoneData()},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new ccs.Bone.CanvasRenderCmd(this):new ccs.Bone.WebGLRenderCmd(this)}});_p=ccs.Bone.prototype;_p.boneData;
cc.defineGetterSetter(_p,"boneData",_p.getBoneData,_p.setBoneData);_p.armature;cc.defineGetterSetter(_p,"armature",_p.getArmature,_p.setArmature);_p.childArmature;cc.defineGetterSetter(_p,"childArmature",_p.getChildArmature,_p.setChildArmature);_p.childrenBone;cc.defineGetterSetter(_p,"childrenBone",_p.getChildrenBone);_p.tween;cc.defineGetterSetter(_p,"tween",_p.getTween);_p.tweenData;cc.defineGetterSetter(_p,"tweenData",_p.getTweenData);_p.colliderFilter;
cc.defineGetterSetter(_p,"colliderFilter",_p.getColliderFilter,_p.setColliderFilter);_p=null;ccs.Bone.create=function(a){return new ccs.Bone(a)};ccs.Bone.RenderCmd={_updateColor:function(){var a=this._node,b=a._displayManager.getDisplayRenderNode();if(null!==b){var c=b._renderCmd;b.setColor(cc.color(a._tweenData.r,a._tweenData.g,a._tweenData.g));b.setOpacity(a._tweenData.a);c._syncDisplayColor(this._displayedColor);c._syncDisplayOpacity(this._displayedOpacity);c._updateColor()}}};
(function(){ccs.Bone.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._needDraw=!1};var a=ccs.Bone.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);cc.inject(ccs.Bone.RenderCmd,a);a.constructor=ccs.Bone.CanvasRenderCmd})();
(function(){if(cc.Node.WebGLRenderCmd){ccs.Bone.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._needDraw=!1};var a=ccs.Bone.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);cc.inject(ccs.Bone.RenderCmd,a);a.constructor=ccs.Bone.WebGLRenderCmd}})();ccs.FRAME_TYPE_MOVE=0;ccs.FRAME_TYPE_SCALE=1;ccs.FRAME_TYPE_ROTATE=2;ccs.FRAME_TYPE_TINT=3;ccs.FRAME_TYPE_FADE=4;ccs.FRAME_TYPE_MAX=5;
ccs.FrameEaseType={CUSTOM:-1,LINEAR:0,SINE_EASEIN:1,SINE_EASEOUT:2,SINE_EASEINOUT:3,QUAD_EASEIN:4,QUAD_EASEOUT:5,QUAD_EASEINOUT:6,CUBIC_EASEIN:7,CUBIC_EASEOUT:8,CUBIC_EASEINOUT:9,QUART_EASEIN:10,QUART_EASEOUT:11,QUART_EASEINOUT:12,QUINT_EASEIN:13,QUINT_EASEOUT:14,QUINT_EASEINOUT:15,EXPO_EASEIN:16,EXPO_EASEOUT:17,EXPO_EASEINOUT:18,CIRC_EASEIN:19,CIRC_EASEOUT:20,CIRC_EASEINOUT:21,ELASTIC_EASEIN:22,ELASTIC_EASEOUT:23,ELASTIC_EASEINOUT:24,BACK_EASEIN:25,BACK_EASEOUT:26,BACK_EASEINOUT:27,BOUNCE_EASEIN:28,
BOUNCE_EASEOUT:29,BOUNCE_EASEINOUT:30,TWEEN_EASING_MAX:1E3};
ccs.ActionFrame=ccs.Class.extend({frameType:0,easingType:0,frameIndex:0,_Parameter:null,time:0,ctor:function(){this.frameType=0;this.easingType=ccs.FrameEaseType.LINEAR;this.time=this.frameIndex=0},getAction:function(a,b){return cc.log("Need a definition of \x3cgetAction\x3e for ActionFrame"),null},_getEasingAction:function(a){if(null===a)return console.error("Action cannot be null!"),null;var b;switch(this.easingType){case ccs.FrameEaseType.LINEAR:b=a;break;case ccs.FrameEaseType.SINE_EASEIN:b=a.easing(cc.easeSineIn());
break;case ccs.FrameEaseType.SINE_EASEOUT:b=a.easing(cc.easeSineOut());break;case ccs.FrameEaseType.SINE_EASEINOUT:b=a.easing(cc.easeSineInOut());break;case ccs.FrameEaseType.QUAD_EASEIN:b=a.easing(cc.easeQuadraticActionIn());break;case ccs.FrameEaseType.QUAD_EASEOUT:b=a.easing(cc.easeQuadraticActionOut());break;case ccs.FrameEaseType.QUAD_EASEINOUT:b=a.easing(cc.easeQuadraticActionInOut());break;case ccs.FrameEaseType.CUBIC_EASEIN:b=a.easing(cc.easeCubicActionIn());break;case ccs.FrameEaseType.CUBIC_EASEOUT:b=
a.easing(cc.easeCubicActionOut());break;case ccs.FrameEaseType.CUBIC_EASEINOUT:b=a.easing(cc.easeCubicActionInOut());break;case ccs.FrameEaseType.QUART_EASEIN:b=a.easing(cc.easeQuarticActionIn());break;case ccs.FrameEaseType.QUART_EASEOUT:b=a.easing(cc.easeQuarticActionOut());break;case ccs.FrameEaseType.QUART_EASEINOUT:b=a.easing(cc.easeQuarticActionInOut());break;case ccs.FrameEaseType.QUINT_EASEIN:b=a.easing(cc.easeQuinticActionIn());break;case ccs.FrameEaseType.QUINT_EASEOUT:b=a.easing(cc.easeQuinticActionOut());
break;case ccs.FrameEaseType.QUINT_EASEINOUT:b=a.easing(cc.easeQuinticActionInOut());break;case ccs.FrameEaseType.EXPO_EASEIN:b=a.easing(cc.easeExponentialIn());break;case ccs.FrameEaseType.EXPO_EASEOUT:b=a.easing(cc.easeExponentialOut());break;case ccs.FrameEaseType.EXPO_EASEINOUT:b=a.easing(cc.easeExponentialInOut());break;case ccs.FrameEaseType.CIRC_EASEIN:b=a.easing(cc.easeCircleActionIn());break;case ccs.FrameEaseType.CIRC_EASEOUT:b=a.easing(cc.easeCircleActionOut());break;case ccs.FrameEaseType.CIRC_EASEINOUT:b=
a.easing(cc.easeCircleActionInOut());break;case ccs.FrameEaseType.ELASTIC_EASEIN:b=a.easing(cc.easeElasticIn());break;case ccs.FrameEaseType.ELASTIC_EASEOUT:b=a.easing(cc.easeElasticOut());break;case ccs.FrameEaseType.ELASTIC_EASEINOUT:b=a.easing(cc.easeElasticInOut());break;case ccs.FrameEaseType.BACK_EASEIN:b=a.easing(cc.easeBackIn());break;case ccs.FrameEaseType.BACK_EASEOUT:b=a.easing(cc.easeBackOut());break;case ccs.FrameEaseType.BACK_EASEINOUT:b=a.easing(cc.easeBackInOut());break;case ccs.FrameEaseType.BOUNCE_EASEIN:b=
a.easing(cc.easeBounceIn());break;case ccs.FrameEaseType.BOUNCE_EASEOUT:b=a.easing(cc.easeBounceOut());break;case ccs.FrameEaseType.BOUNCE_EASEINOUT:b=a.easing(cc.easeBounceInOut())}return b},setEasingParameter:function(a){this._Parameter=[];for(var b=0;b<a.length;b++)this._Parameter.push(a[b])},setEasingType:function(a){this.easingType=a}});
ccs.ActionMoveFrame=ccs.ActionFrame.extend({_position:null,ctor:function(){ccs.ActionFrame.prototype.ctor.call(this);this._position=cc.p(0,0);this.frameType=ccs.FRAME_TYPE_MOVE},setPosition:function(a,b){void 0===b?(this._position.x=a.x,this._position.y=a.y):(this._position.x=a,this._position.y=b)},getPosition:function(){return this._position},getAction:function(a){return this._getEasingAction(cc.moveTo(a,this._position))}});
ccs.ActionScaleFrame=ccs.ActionFrame.extend({_scaleX:1,_scaleY:1,ctor:function(){ccs.ActionFrame.prototype.ctor.call(this);this._scaleY=this._scaleX=1;this.frameType=ccs.FRAME_TYPE_SCALE},setScaleX:function(a){this._scaleX=a},getScaleX:function(){return this._scaleX},setScaleY:function(a){this._scaleY=a},getScaleY:function(){return this._scaleY},getAction:function(a){return this._getEasingAction(cc.scaleTo(a,this._scaleX,this._scaleY))}});
ccs.ActionRotationFrame=ccs.ActionFrame.extend({_rotation:0,ctor:function(){ccs.ActionFrame.prototype.ctor.call(this);this._rotation=0;this.frameType=ccs.FRAME_TYPE_ROTATE},setRotation:function(a){this._rotation=a},getRotation:function(){return this._rotation},getAction:function(a,b){return void 0===b?this._getEasingAction(cc.rotateTo(a,this._rotation)):b instanceof cc.ActionRotationFrame?this._getEasingAction(cc.rotateBy(a,this._rotation-b._rotation)):this.getAction(a)}});
ccs.ActionFadeFrame=ccs.ActionFrame.extend({_opacity:255,ctor:function(){ccs.ActionFrame.prototype.ctor.call(this);this._opacity=255;this.frameType=ccs.FRAME_TYPE_FADE},setOpacity:function(a){this._opacity=a},getOpacity:function(){return this._opacity},getAction:function(a){return this._getEasingAction(cc.fadeTo(a,this._opacity))}});
ccs.ActionTintFrame=ccs.ActionFrame.extend({_color:null,ctor:function(){ccs.ActionFrame.prototype.ctor.call(this);this._color=cc.color(255,255,255,255);this.frameType=ccs.FRAME_TYPE_TINT},setColor:function(a){var b=this._color;b.r=a.r;b.g=a.g;b.b=a.b},getColor:function(){var a=this._color;return cc.color(a.r,a.g,a.b,a.a)},getAction:function(a){return this._getEasingAction(cc.tintTo(a,this._color.r,this._color.g,this._color.b))}});
ccs.actionManager={_actionDic:{},initWithDictionary:function(a,b,c){var d=a.lastIndexOf("/");a=a.substr(d+1,a.length);b=b.actionlist;for(var d=[],e=0;e<b.length;e++){var f=new ccs.ActionObject;f.initWithDictionary(b[e],c);d.push(f)}this._actionDic[a]=d},getActionByName:function(a,b){var c=a.lastIndexOf("/"),c=a.substr(c+1,a.length),c=this._actionDic[c];if(!c)return null;for(var d=0;d<c.length;d++){var e=c[d];if(b===e.getName())return e}return null},playActionByName:function(a,b,c){(a=this.getActionByName(a,
b))&&a.play(c)},stopActionByName:function(a,b){var c=this.getActionByName(a,b);c&&c.stop()},releaseActions:function(){this._actionDic={}},clear:function(){this._actionDic={}}};
ccs.ActionNode=ccs.Class.extend({_currentFrameIndex:0,_destFrameIndex:0,_unitTime:0,_actionTag:0,_object:null,_actionSpawn:null,_action:null,_frameArray:null,_frameArrayNum:0,ctor:function(){this._destFrameIndex=this._currentFrameIndex=0;this._unitTime=0.1;this._actionTag=0;this._action=this._actionSpawn=this._object=null;this._frameArray=[];this._frameArrayNum=ccs.FRAME_TYPE_MAX;for(var a=0;a<this._frameArrayNum;a++)this._frameArray.push([])},initWithDictionary:function(a,b){this.setActionTag(a.ActionTag);
for(var c=a.actionframelist,d=0;d<c.length;d++){var e=c[d],f=e.frameid,g=e.tweenType;null==g&&(g=0);for(var h=e.tweenParameter,k=[],m=0;h>m;m++)k.push(e.tweenParameter[m]);if(void 0!==e.positionx){var m=e.positionx,n=e.positiony,h=new ccs.ActionMoveFrame;h.frameIndex=f;h.setEasingType(g);h.setEasingParameter(k);h.setPosition(m,n);m=this._frameArray[ccs.FRAME_TYPE_MOVE];m.push(h)}void 0!==e.scalex&&(m=e.scalex,n=e.scaley,h=new ccs.ActionScaleFrame,h.frameIndex=f,h.setEasingType(g),h.setEasingParameter(k),
h.setScaleX(m),h.setScaleY(n),m=this._frameArray[ccs.FRAME_TYPE_SCALE],m.push(h));void 0!==e.rotation&&(m=e.rotation,h=new ccs.ActionRotationFrame,h.frameIndex=f,h.setEasingType(g),h.setEasingParameter(k),h.setRotation(m),m=this._frameArray[ccs.FRAME_TYPE_ROTATE],m.push(h));void 0!==e.opacity&&(m=e.opacity,h=new ccs.ActionFadeFrame,h.frameIndex=f,h.setEasingType(g),h.setEasingParameter(k),h.setOpacity(m),m=this._frameArray[ccs.FRAME_TYPE_FADE],m.push(h));void 0!==e.colorr&&(m=e.colorr,n=e.colorg,
e=e.colorb,h=new ccs.ActionTintFrame,h.frameIndex=f,h.setEasingType(g),h.setEasingParameter(k),h.setColor(cc.color(m,n,e)),m=this._frameArray[ccs.FRAME_TYPE_TINT],m.push(h))}this._initActionNodeFromRoot(b)},_initActionNodeFromRoot:function(a){a instanceof ccui.Widget&&(a=ccui.helper.seekActionWidgetByActionTag(a,this.getActionTag()))&&this.setObject(a)},setUnitTime:function(a){this._unitTime=a;this._refreshActionProperty()},getUnitTime:function(){return this._unitTime},setActionTag:function(a){this._actionTag=
a},getActionTag:function(){return this._actionTag},setObject:function(a){this._object=a},getObject:function(){return this._object},getActionNode:function(){return this._object instanceof cc.Node?this._object:null},insertFrame:function(a,b){null!=b&&this._frameArray[b.frameType].splice(a,0,b)},addFrame:function(a){a&&this._frameArray[a.frameType].push(a)},deleteFrame:function(a){null!=a&&cc.arrayRemoveObject(this._frameArray[a.frameType],a)},clearAllFrame:function(){for(var a=0;a<this._frameArrayNum;a++)this._frameArray[a].length=
0},_refreshActionProperty:function(){if(null===this._object)return null;for(var a=[],b=0;b<this._frameArrayNum;b++){var c=this._frameArray[b];if(!(0>=c.length)){for(var d=[],e=0;e<c.length;e++){var f=c[e];if(0!==e){var g=(f.frameIndex-c[e-1].frameIndex)*this.getUnitTime();(f=f.getAction(g))&&d.push(f)}}d&&(c=cc.sequence(d),null!==c&&a.push(c))}}return this._action=null,this._actionSpawn=cc.spawn(a),this._actionSpawn},playAction:function(a){null!==this._object&&null!==this._actionSpawn&&(a?this._action=
cc.sequence(this._actionSpawn,a):this._action=cc.sequence(this._actionSpawn),this._runAction())},_runAction:function(){var a=this.getActionNode();null!==a&&null!==this._action&&a.runAction(this._action)},stopAction:function(){var a=this.getActionNode();null!==a&&null!==this._action&&(this._action.isDone()||a.stopAction(this._action))},getFirstFrameIndex:function(){for(var a=99999,b=!1,c=this._frameArray,d=0,e=this._frameArrayNum;e>d;d++){var f=c[d];0>=f.length||(b=!0,f=f[0].frameIndex,a=a>f?f:a)}return b||
(a=0),a},getLastFrameIndex:function(){for(var a=-1,b=!1,c=this._frameArray,d=0,e=this._frameArrayNum;e>d;d++){var f=c[d];0>=f.length||(b=!0,f=f[f.length-1].frameIndex,a=f>a?f:a)}return b||(a=0),a},updateActionToTimeLine:function(a){for(var b=!1,c=this.getUnitTime(),d=0;d<this._frameArrayNum;d++){var e=this._frameArray[d];if(null!==e)for(var f=0;f<e.length;f++){var g=e[f];if(g.frameIndex*c===a){this._easingToFrame(1,1,g);b=!0;break}if(g.frameIndex*c>a){0===f?(this._easingToFrame(1,1,g),b=!1):(b=e[f-
1],e=(g.frameIndex-b.frameIndex)*c,f=a-b.frameIndex*c,this._easingToFrame(e,1,b),this._easingToFrame(e,f/e,g),b=!0);break}}}return b},_easingToFrame:function(a,b,c){a=c.getAction(a);c=this.getActionNode();null!=a&&null!=c&&(a.startWithTarget(c),a.update(b))},isActionDoneOnce:function(){return null===this._action?!0:this._action.isDone()}});
ccs.ActionObject=ccs.Class.extend({_actionNodeList:null,_name:"",_loop:!1,_pause:!1,_playing:!1,_unitTime:0,_currentTime:0,_scheduler:null,_callback:null,_fTotalTime:0,ctor:function(){this._actionNodeList=[];this._name="";this._playing=this._pause=this._loop=!1;this._unitTime=0.1;this._fTotalTime=this._currentTime=0;this._scheduler=cc.director.getScheduler()},setName:function(a){this._name=a},getName:function(){return this._name},setLoop:function(a){this._loop=a},getLoop:function(){return this._loop},
setUnitTime:function(a){this._unitTime=a;a=this._actionNodeList.length;for(var b=0;a>b;b++)this._actionNodeList[b].setUnitTime(this._unitTime)},getUnitTime:function(){return this._unitTime},getCurrentTime:function(){return this._currentTime},setCurrentTime:function(a){this._currentTime=a},getTotalTime:function(){return this._fTotalTime},isPlaying:function(){return this._playing},initWithDictionary:function(a,b){this.setName(a.name);this.setLoop(a.loop);this.setUnitTime(a.unittime);for(var c=a.actionnodelist,
d=0,e=0;e<c.length;e++){var f=new ccs.ActionNode;f.initWithDictionary(c[e],b);f.setUnitTime(this.getUnitTime());this._actionNodeList.push(f);f=f.getLastFrameIndex()-f.getFirstFrameIndex();f>d&&(d=f)}this._fTotalTime=d*this._unitTime},addActionNode:function(a){a&&(this._actionNodeList.push(a),a.setUnitTime(this._unitTime))},removeActionNode:function(a){null!=a&&cc.arrayRemoveObject(this._actionNodeList,a)},play:function(a){this.stop();this.updateToFrameByTime(0);for(var b=this._actionNodeList,c=b.length,
d=0;c>d;d++)b[d].playAction(a);this._loop&&this._scheduler.schedule(this.simulationActionUpdate,this,0,cc.REPEAT_FOREVER,0,!1,this.__instanceId+"");void 0!==a&&(this._callback=a)},pause:function(){this._pause=!0;this._playing=!1},stop:function(){for(var a=this._actionNodeList,b=0;b<a.length;b++)a[b].stopAction();this._scheduler.unschedule(this.simulationActionUpdate,this);this._playing=this._pause=!1},updateToFrameByTime:function(a){this._currentTime=a;for(var b=0;b<this._actionNodeList.length;b++)this._actionNodeList[b].updateActionToTimeLine(a)},
simulationActionUpdate:function(a){a=!0;for(var b=this._actionNodeList,c=0,d=b.length;d>c;c++)if(!b[c].isActionDoneOnce()){a=!1;break}a&&(null!==this._callback&&this._callback.execute(),this._loop?this.play():(this._playing=!1,this._scheduler.unschedule(this.simulationActionUpdate,this)))}});
ccs.ComAttribute=ccs.Component.extend({_jsonDict:null,_filePath:"",ctor:function(){cc.Component.prototype.ctor.call(this);this._jsonDict={};this._filePath="";this._name="CCComAttribute";ccs.ComAttribute.prototype.init.call(this)},init:function(){return this._jsonDict={},!0},setInt:function(a,b){return a?void(this._jsonDict[a]=b):void cc.log("Argument must be non-nil")},setDouble:function(a,b){return a?void(this._jsonDict[a]=b):void cc.log("Argument must be non-nil")},setFloat:function(a,b){return a?
void(this._jsonDict[a]=b):void cc.log("Argument must be non-nil")},setBool:function(a,b){return a?void(this._jsonDict[a]=b):void cc.log("Argument must be non-nil")},setString:function(a,b){return a?void(this._jsonDict[a]=b):void cc.log("Argument must be non-nil")},setObject:function(a,b){return a?void(this._jsonDict[a]=b):void cc.log("Argument must be non-nil")},getInt:function(a){return parseInt(this._jsonDict[a]||0)},getDouble:function(a){return parseFloat(this._jsonDict[a]||0)},getFloat:function(a){return parseFloat(this._jsonDict[a]||
0)},getBool:function(a){return Boolean(this._jsonDict[a]||!1)},getString:function(a){return this._jsonDict[a]||""},getObject:function(a){return this._jsonDict[a]},parse:function(a){this._jsonDict=cc.loader.getRes(a)}});ccs.ComAttribute.create=function(){return new ccs.ComAttribute};
ccs.ComAudio=ccs.Component.extend({_filePath:"",_loop:!1,ctor:function(){cc.Component.prototype.ctor.call(this);this._name="Audio";ccs.ComAudio.prototype.init.call(this)},init:function(){return!0},onExit:function(){this.stopBackgroundMusic(!0);this.stopAllEffects()},end:function(){cc.audioEngine.end()},preloadBackgroundMusic:function(a){cc.loader.load(a)},playBackgroundMusic:function(a,b){a?cc.audioEngine.playMusic(a,b):cc.audioEngine.playMusic(this._filePath,this._loop)},stopBackgroundMusic:function(a){cc.audioEngine.stopMusic(a)},
pauseBackgroundMusic:function(){cc.audioEngine.pauseMusic()},resumeBackgroundMusic:function(){cc.audioEngine.resumeMusic()},rewindBackgroundMusic:function(){cc.audioEngine.rewindMusic()},willPlayBackgroundMusic:function(){return cc.audioEngine.willPlayMusic()},isBackgroundMusicPlaying:function(){return cc.audioEngine.isMusicPlaying()},getBackgroundMusicVolume:function(){return cc.audioEngine.getMusicVolume()},setBackgroundMusicVolume:function(a){cc.audioEngine.setMusicVolume(a)},getEffectsVolume:function(){return cc.audioEngine.getEffectsVolume()},
setEffectsVolume:function(a){cc.audioEngine.setEffectsVolume(a)},playEffect:function(a,b){return a?cc.audioEngine.playEffect(a,b):cc.audioEngine.playEffect(this._filePath,this._loop)},pauseEffect:function(a){cc.audioEngine.pauseEffect(a)},pauseAllEffects:function(){cc.audioEngine.pauseAllEffects()},resumeEffect:function(a){cc.audioEngine.resumeEffect(a)},resumeAllEffects:function(){cc.audioEngine.resumeAllEffects()},stopEffect:function(a){cc.audioEngine.stopEffect(a)},stopAllEffects:function(){cc.audioEngine.stopAllEffects()},
preloadEffect:function(a){cc.loader.getRes(a);this.setFile(a);this.setLoop(!1)},unloadEffect:function(a){cc.audioEngine.unloadEffect(a)},setFile:function(a){this._filePath=a},setLoop:function(a){this._loop=a},getFile:function(){return this._filePath},isLoop:function(){return this._loop}});ccs.ComAudio.create=function(){return new ccs.ComAudio};
ccs.ComController=ccs.Component.extend({ctor:function(){cc.Component.prototype.ctor.call(this);this._name="ComController";ccs.ComController.prototype.init.call(this)},onEnter:function(){null!==this._owner&&this._owner.scheduleUpdate()},isEnabled:function(){return this._enabled},setEnabled:function(a){this._enabled=a}});ccs.ComController.create=function(){return new ccs.ComController};
ccs.ComRender=ccs.Component.extend({_render:null,ctor:function(a,b){cc.Component.prototype.ctor.call(this);this._render=a;this._name=b;this.isRenderer=!0;ccs.ComRender.prototype.init.call(this)},onEnter:function(){this._owner&&this._owner.addChild(this._render)},onExit:function(){this._owner&&(this._owner.removeChild(this._render,!0),this._render=null)},getNode:function(){return this._render},setNode:function(a){this._render=a}});ccs.ComRender.create=function(a,b){return new ccs.ComRender(a,b)};
ccs.objectFactory={_typeMap:{},createObject:function(a){a=this._typeMap[a];return a&&cc.isFunction(a._fun)&&new a._fun,null},registerType:function(a){this._typeMap[a._className]=a},createGUI:function(a){"Panel"===a?a="Layout":"TextArea"===a?a="Label":"TextButton"===a&&(a="Button");a=this._typeMap[a];return null},removeAll:function(){this._typeMap={}}};
ccs.TInfo=ccs.Class.extend({_className:"",_fun:null,ctor:function(a,b){b?(this._className=a,this._fun=b):(this._className=a._className,this._fun=a._fun);ccs.objectFactory.registerType(this)}});ccs.sendEvent=function(a){a=ccs.triggerManager.get(a);if(null!=a)for(var b=0;b<a.length;b++){var c=a[b];null!=c&&c.detect()&&c.done()}};ccs.registerTriggerClass=function(a,b){new ccs.TInfo(a,b)};
ccs.triggerManager={_eventTriggers:{},_triggerObjs:{},_movementDispatches:[],parse:function(a){for(var b=0;b<a.length;++b){var c=a[b],d=new ccs.TriggerObj;d.serialize(c);for(var c=d.getEvents(),e=0;e<c.length;e++)this.add(c[e],d);this._triggerObjs[d.getId()]=d}},get:function(a){return this._eventTriggers[a]},getTriggerObj:function(a){return this._triggerObjs[a]},add:function(a,b){var c=this._eventTriggers[a];c||(c=[]);-1===c.indexOf(b)&&(c.push(b),this._eventTriggers[a]=c)},removeAll:function(){for(var a in this._eventTriggers)for(var b=
this._eventTriggers[a],c=0;c<b.length;c++)b[c].removeAll();this._eventTriggers={}},remove:function(a,b){if(b)return this._removeObj(a,b);var c=!1,d=this._eventTriggers[a];if(d){for(c=0;c<d.length;c++){var e=d[c];e&&e.removeAll()}delete this._eventTriggers[a];c=!0}return c},_removeObj:function(a,b){var c=!1;do{var d=this._eventTriggers[a];if(d){for(c=0;c<d.length;c++){var e=d[c];if(e&&e==b){e.removeAll();d.splice(c,1);break}}c=!0}}while(0);return c},removeTriggerObj:function(a){a=this.getTriggerObj(a);
if(!a)return!1;for(var b=a.getEvents(),c=0;c<b.length;c++)this.remove(b[c],a);return!0},isEmpty:function(){return!this._eventTriggers||0>=this._eventTriggers.length},addArmatureMovementCallBack:function(a,b,c){if(null!=a&&null!=c&&null!=b){for(var d,e=!1,f=0;f<this._movementDispatches.length;f++)(d=this._movementDispatches[f])&&d[0]===a&&(d.addAnimationEventCallBack(b,c),e=!0);e||(d=new ccs.ArmatureMovementDispatcher,a.getAnimation().setMovementEventCallFunc(d.animationEvent,d),d.addAnimationEventCallBack(b,
c),this._movementDispatches.push([a,d]))}},removeArmatureMovementCallBack:function(a,b,c){if(null!=a&&null!=b&&null!=c)for(var d,e=0;e<this._movementDispatches.length;e++)(d=this._movementDispatches[e])&&d[0]===a&&d.removeAnimationEventCallBack(c,b)},removeArmatureAllMovementCallBack:function(a){if(null!=a)for(var b,c=0;c<this._movementDispatches.length;c++)if(b=this._movementDispatches[c],b&&b[0]===a){this._movementDispatches.splice(c,1);break}},removeAllArmatureMovementCallBack:function(){this._movementDispatches.length=
0},version:function(){return"1.2.0.0"}};
ccs.ArmatureMovementDispatcher=ccs.Class.extend({_mapEventAnimation:null,ctor:function(){this._mapEventAnimation=[]},animationEvent:function(a,b,c){for(var d,e,f=0;f<this._mapEventAnimation.length;f++)d=this._mapEventAnimation[f],e=d[0],(d=d[1])&&d.call(e,a,b,c)},addAnimationEventCallBack:function(a,b){this._mapEventAnimation.push([b,a])},removeAnimationEventCallBack:function(a,b){for(var c,d=0;d<this._mapEventAnimation.length;d++)c=this._mapEventAnimation[d],c[0]===b&&this._mapEventAnimation.splice(d,
1)}});ccs.BaseTriggerCondition=ccs.Class.extend({ctor:function(){},init:function(){return!0},detect:function(){return!0},serialize:function(a){},removeAll:function(){}});ccs.BaseTriggerAction=ccs.Class.extend({ctor:function(){},init:function(){return!0},done:function(){},serialize:function(a){},removeAll:function(){}});
ccs.TriggerObj=ccs.Class.extend({_cons:null,_acts:null,_id:0,_enable:!0,_vInt:null,ctor:function(){this._id=0;this._enable=!0;ccs.TriggerObj.prototype.init.call(this)},init:function(){return this._cons=[],this._acts=[],this._vInt=[],!0},detect:function(){if(!this._enable||0===this._cons.length)return!0;for(var a=!0,b=null,c=0;c<this._cons.length;c++)(b=this._cons[c])&&b.detect&&(a=a&&b.detect());return a},done:function(){if(this._enable&&0!==this._acts.length)for(var a,b=0;b<this._acts.length;b++)(a=
this._acts[b])&&a.done&&a.done()},removeAll:function(){for(var a=null,b=0;b<this._cons.length;b++)(a=this._cons[b])&&a.removeAll();this._cons=[];for(b=0;b<this._acts.length;b++)(a=this._acts[b])&&a.removeAll();this._acts=[]},serialize:function(a){this._id=a.id||0;for(var b=a.conditions||[],c=0;c<b.length;c++){var d=b[c],e=d.classname,f=ccs.objectFactory.createObject(e);f?(f.serialize(d),f.init(),this._cons.push(f)):cc.log("class named classname("+e+") can not implement!")}b=a.actions||[];for(c=0;c<
b.length;c++)d=b[c],e=d.classname,(f=ccs.objectFactory.createObject(e))?(f.serialize(d),f.init(),this._acts.push(f)):cc.log("class named classname("+e+") can not implement!");a=a.events||[];for(c=0;c<a.length;c++)d=a[c],d=d.id,0>d||this._vInt.push(d)},getId:function(){return this._id},setEnable:function(a){this._enable=a},getEvents:function(){return this._vInt}});ccs.TriggerObj.create=function(){return new ccs.TriggerObj};
ccs.ActionTimelineData=ccs.Class.extend({_actionTag:0,ctor:function(a){this._init(a)},_init:function(a){return this._actionTag=a,!0},setActionTag:function(a){this._actionTag=a},getActionTag:function(){return this._actionTag}});ccs.ObjectExtensionData=ccs.Class.extend({_customProperty:null,_timelineData:null,ctor:function(){return this._timelineData=new ccs.ActionTimelineData(0),!0},setActionTag:function(a){this._timelineData.setActionTag(a)},getActionTag:function(){return this._timelineData.getActionTag()}});
ccs.ObjectExtensionData.create=function(){return new ccs.ObjectExtensionData};ccs.ActionTimelineData.create=function(a){return new ccs.ActionTimelineData(a)};
ccs.ActionTimeline=cc.Action.extend({_timelineMap:null,_timelineList:null,_duration:0,_time:null,_timeSpeed:1,_frameInternal:1/60,_playing:!1,_currentFrame:0,_startFrame:0,_endFrame:0,_loop:null,_frameEventListener:null,_animationInfos:null,ctor:function(){cc.Action.prototype.ctor.call(this);this._timelineMap={};this._timelineList=[];this._animationInfos={};this.init()},_gotoFrame:function(a){for(var b=this._timelineList.length,c=0;b>c;c++)this._timelineList[c]._gotoFrame(a)},_stepToFrame:function(a){for(var b=
this._timelineList.length,c=0;b>c;c++)this._timelineList[c]._stepToFrame(a)},_emitFrameEvent:function(a){this._frameEventListener&&this._frameEventListener(a)},init:function(){return!0},gotoFrameAndPlay:function(a,b,c,d){var e,f=0,g=arguments.length,h=[];for(f;g>f;f++)"boolean"==typeof arguments[f]?e=arguments[f]:h.push(arguments[f]);a=h[0];b=h[1]||this._duration;c=h[2]||a;this._startFrame=a;this._endFrame=b;this._currentFrame=c;this._loop=null!=e?e:!0;this._time=this._currentFrame*this._frameInternal;
this.resume();this._gotoFrame(this._currentFrame)},gotoFrameAndPause:function(a){this._startFrame=this._currentFrame=a;this._time=this._currentFrame*this._frameInternal;this.pause();this._gotoFrame(this._currentFrame)},pause:function(){this._playing=!1},resume:function(){this._playing=!0},isPlaying:function(){return this._playing},setTimeSpeed:function(a){this._timeSpeed=a},getTimeSpeed:function(){return this._timeSpeed},setDuration:function(a){this._duration=a},getDuration:function(){return this._duration},
getStartFrame:function(){return this._startFrame},getEndFrame:function(){return this._endFrame},setCurrentFrame:function(a){a>=this._startFrame&&a<=this._endFrame?(this._currentFrame=a,this._time=this._currentFrame*this._frameInternal):cc.log("frame index is not between start frame and end frame")},getCurrentFrame:function(){return this._currentFrame},addTimeline:function(a){var b=a.getActionTag();this._timelineMap[b]||(this._timelineMap[b]=[]);this._timelineMap[b].some(function(b){return b===a?!0:
void 0})||(this._timelineList.push(a),this._timelineMap[b].push(a),a.setActionTimeline(this))},removeTimeline:function(a){var b=a.getActionTag();this._timelineMap[b]&&this._timelineMap[b].some(function(b){return b===a?!0:void 0})&&(cc.arrayRemoveObject(this._timelineMap[b],a),cc.arrayRemoveObject(this._timelineList,a),a.setActionTimeline(null))},getTimelines:function(){return this._timelineList},setFrameEventCallFunc:function(a){this._frameEventListener=a},clearFrameEventCallFunc:function(){this._frameEventListener=
null},clone:function(){var a=new ccs.ActionTimeline;a.setDuration(this._duration);a.setTimeSpeed(this._timeSpeed);for(var b in this._timelineMap){var c=this._timelineMap[b],d;for(d in c){var e=c[d].clone();a.addTimeline(e)}}return a},reverse:function(){return null},step:function(a){this._playing&&0!==this._timelineMap.length&&0!==this._duration&&(this._time+=a*this._timeSpeed,this._currentFrame=this._time/this._frameInternal|0,this._stepToFrame(this._currentFrame),this._time>this._endFrame*this._frameInternal&&
(this._playing=this._loop,this._playing?this.gotoFrameAndPlay(this._startFrame,this._endFrame,this._loop):this._time=this._endFrame*this._frameInternal))},_foreachNodeDescendant:function(a,b){b(a);for(var c=a.getChildren(),d=0;d<c.length;d++)this._foreachNodeDescendant(c[d],b)},startWithTarget:function(a){cc.Action.prototype.startWithTarget.call(this,a);var b=this;this._foreachNodeDescendant(a,function(a){var d=a.getUserObject();if(d&&(d=d.getActionTag(),b._timelineMap[d]))for(var d=b._timelineMap[d],
e=0;e<d.length;e++)d[e].setNode(a)})},isDone:function(){return!1},play:function(a,b){var c=this._animationInfos[a];return c?void this.gotoFrameAndPlay(c.startIndex,c.endIndex,b):cc.log("Can't find animation info for %s",a)},addAnimationInfo:function(a){this._animationInfos[a.name]=a},removeAnimationInfo:function(a){delete this._animationInfos[a]},isAnimationInfoExists:function(a){return this._animationInfos[a]},getAnimationInfo:function(a){return this._animationInfos[a]}});
ccs.ActionTimeline.create=function(){return new ccs.ActionTimeline};
ccs.Frame=ccs.Class.extend({_frameIndex:null,_tween:null,_timeline:null,_node:null,_tweenType:null,_easingParam:null,ctor:function(){this._frameIndex=0;this._tween=!0;this._node=this._timeline=null;this._easingParam=[]},_emitEvent:function(){this._timeline&&this._timeline.getActionTimeline()._emitFrameEvent(this)},_cloneProperty:function(a){this._frameIndex=a.getFrameIndex();this._tween=a.isTween();this._tweenType=a.getTweenType();this.setEasingParams(a.getEasingParams())},setFrameIndex:function(a){this._frameIndex=
a},getFrameIndex:function(){return this._frameIndex},setTimeline:function(a){this._timeline=a},getTimeline:function(a){return this._timeline},setNode:function(a){this._node=a},getNode:function(){return this._node},setTween:function(a){this._tween=a},isTween:function(){return this._tween},onEnter:function(a){},apply:function(a){this._tween&&(this._tweenType!==ccs.FrameEaseType.TWEEN_EASING_MAX&&this._tweenType!==ccs.FrameEaseType.LINEAR&&(a=this.tweenPercent(a)),this._onApply(a))},_onApply:function(a){},
clone:function(){},tweenPercent:function(a){var b=ccs.Frame.tweenToMap[this._tweenType];return b?b(a,this._easingParam):a},setEasingParams:function(a){if(a)for(var b=this._easingParam.length=0;b<a.length;b++)this._easingParam[b]=a[b]},getEasingParams:function(){return this._easingParam},setTweenType:function(a){this._tweenType=a},getTweenType:function(){return this._tweenType},isEnterWhenPassed:function(){return this._enterWhenPassed}});
ccs.Frame.tweenToMap={1:cc._easeSineInObj.easing,2:cc._easeSineOutObj.easing,3:cc._easeSineInOutObj.easing,4:cc._easeQuadraticActionIn.easing,5:cc._easeQuadraticActionOut.easing,6:cc._easeQuadraticActionInOut.easing,7:cc._easeCubicActionIn.easing,8:cc._easeCubicActionOut.easing,9:cc._easeCubicActionInOut.easing,10:cc._easeCubicActionIn.easing,11:cc._easeCubicActionOut.easing,12:cc._easeCubicActionInOut.easing,13:cc._easeQuinticActionIn.easing,14:cc._easeQuinticActionOut.easing,15:cc._easeQuinticActionInOut.easing,
16:cc._easeExponentialInObj.easing,17:cc._easeExponentialOutObj.easing,18:cc._easeExponentialInOutObj.easing,19:cc._easeCircleActionIn.easing,20:cc._easeCircleActionOut.easing,21:cc._easeCircleActionInOut.easing,22:function(a,b){return cc.easeElasticIn(0.3).easing(a)},23:function(a,b){return cc.easeElasticOut(0.3).easing(a)},24:function(a,b){return cc.easeElasticInOut(0.3).easing(a)},25:cc._easeBackInObj.easing,26:cc._easeBackOutObj.easing,27:cc._easeBackInOutObj.easing,28:cc._easeBounceInObj.easing,
29:cc._easeBounceOutObj.easing,30:cc._easeBounceInOutObj.easing};ccs.VisibleFrame=ccs.Frame.extend({_visible:!0,ctor:function(){ccs.Frame.prototype.ctor.call(this);this._visible=!0},onEnter:function(a){this._node&&this._node.setVisible(this._visible)},clone:function(){var a=new ccs.VisibleFrame;return a.setVisible(this._visible),a._cloneProperty(this),a},setVisible:function(a){this._visible=a},isVisible:function(){return this._visible}});ccs.VisibleFrame.create=function(){return new ccs.VisibleFrame};
ccs.TextureFrame=ccs.Frame.extend({_sprite:null,_textureName:null,ctor:function(){ccs.Frame.prototype.ctor.call(this);this._textureName=""},setNode:function(a){ccs.Frame.prototype.setNode.call(this,a);this._sprite=a},onEnter:function(a){if(this._sprite){a=this._sprite.getBlendFunc();var b=cc.spriteFrameCache._spriteFrames[this._textureName];null!=b?this._sprite.setSpriteFrame(b):this._sprite.setTexture(this._textureName);this._sprite.getBlendFunc()!==a&&this._sprite.setBlendFunc(a)}},clone:function(){var a=
new ccs.TextureFrame;return a.setTextureName(this._textureName),a._cloneProperty(this),a},setTextureName:function(a){this._textureName=a},getTextureName:function(){return this._textureName}});ccs.TextureFrame.create=function(){return new ccs.TextureFrame};
ccs.RotationFrame=ccs.Frame.extend({_rotation:null,_betwennRotation:null,ctor:function(){ccs.Frame.prototype.ctor.call(this);this._rotation=0},onEnter:function(a){this._node&&(this._node.setRotation(this._rotation),this._tween&&(this._betwennRotation=a._rotation-this._rotation))},_onApply:function(a){0!==this._betwennRotation&&this._node.setRotation(this._rotation+a*this._betwennRotation)},clone:function(){var a=new ccs.RotationFrame;return a.setRotation(this._rotation),a._cloneProperty(this),a},
setRotation:function(a){this._rotation=a},getRotation:function(){return this._rotation}});ccs.RotationFrame.create=function(){return new ccs.RotationFrame};
ccs.SkewFrame=ccs.Frame.extend({_skewX:null,_skewY:null,_betweenSkewX:null,_betweenSkewY:null,ctor:function(){ccs.Frame.prototype.ctor.call(this);this._skewY=this._skewX=0},onEnter:function(a){this._node&&(this._node.setSkewX(this._skewX),this._node.setSkewY(this._skewY),this._tween&&(this._betweenSkewX=a._skewX-this._skewX,this._betweenSkewY=a._skewY-this._skewY))},_onApply:function(a){if(0!==this._betweenSkewX||0!==this._betweenSkewY){var b=this._skewY+a*this._betweenSkewY;this._node.setSkewX(this._skewX+
a*this._betweenSkewX);this._node.setSkewY(b)}},clone:function(){var a=new ccs.SkewFrame;return a.setSkewX(this._skewX),a.setSkewY(this._skewY),a._cloneProperty(this),a},setSkewX:function(a){this._skewX=a},getSkewX:function(){return this._skewX},setSkewY:function(a){this._skewY=a},getSkewY:function(){return this._skewY}});ccs.SkewFrame.create=function(){return new ccs.SkewFrame};
ccs.RotationSkewFrame=ccs.SkewFrame.extend({onEnter:function(a){this._node&&(this._node.setRotationX(this._skewX),this._node.setRotationY(this._skewY),this._tween&&(this._betweenSkewX=a._skewX-this._skewX,this._betweenSkewY=a._skewY-this._skewY))},_onApply:function(a){if(this._node&&(0!==this._betweenSkewX||0!==this._betweenSkewY)){var b=this._skewY+a*this._betweenSkewY;this._node.setRotationX(this._skewX+a*this._betweenSkewX);this._node.setRotationY(b)}},clone:function(){var a=new ccs.RotationSkewFrame;
return a.setSkewX(this._skewX),a.setSkewY(this._skewY),a._cloneProperty(this),a}});ccs.RotationSkewFrame.create=function(){return new ccs.RotationSkewFrame};
ccs.PositionFrame=ccs.Frame.extend({_position:null,_betweenX:null,_betweenY:null,ctor:function(){ccs.Frame.prototype.ctor.call(this);this._position=cc.p(0,0)},onEnter:function(a){this._node&&(this._node.setPosition(this._position),this._tween&&(this._betweenX=a._position.x-this._position.x,this._betweenY=a._position.y-this._position.y))},_onApply:function(a){if(this._node&&(0!==this._betweenX||0!==this._betweenY)){var b=cc.p(0,0);b.x=this._position.x+this._betweenX*a;b.y=this._position.y+this._betweenY*
a;this._node.setPosition(b)}},clone:function(){var a=new ccs.PositionFrame;return a.setPosition(this._position),a._cloneProperty(this),a},setPosition:function(a){this._position=a},getPosition:function(){return this._position},setX:function(a){this._position.x=a},getX:function(){return this._position.x},setY:function(a){this._position.y=a},getY:function(){return this._position.y}});ccs.PositionFrame.create=function(){return new ccs.PositionFrame};
ccs.ScaleFrame=ccs.Frame.extend({_scaleX:null,_scaleY:null,_betweenScaleX:null,_betweenScaleY:null,ctor:function(){ccs.Frame.prototype.ctor.call(this);this._scaleY=this._scaleX=1},onEnter:function(a){this._node&&(this._node.setScaleX(this._scaleX),this._node.setScaleY(this._scaleY),this._tween&&(this._betweenScaleX=a._scaleX-this._scaleX,this._betweenScaleY=a._scaleY-this._scaleY))},_onApply:function(a){if(this._node&&(0!==this._betweenScaleX||0!==this._betweenScaleY)){var b=this._scaleY+this._betweenScaleY*
a;this._node.setScaleX(this._scaleX+this._betweenScaleX*a);this._node.setScaleY(b)}},clone:function(){var a=new ccs.ScaleFrame;return a.setScaleX(this._scaleX),a.setScaleY(this._scaleY),a._cloneProperty(this),a},setScale:function(a){this._scaleY=this._scaleX=a},setScaleX:function(a){this._scaleX=a},getScaleX:function(){return this._scaleX},setScaleY:function(a){this._scaleY=a},getScaleY:function(){return this._scaleY}});ccs.ScaleFrame.create=function(){return new ccs.ScaleFrame};
ccs.AnchorPointFrame=ccs.Frame.extend({_anchorPoint:null,ctor:function(){ccs.Frame.prototype.ctor.call(this);this._anchorPoint=cc.p(0,0)},onEnter:function(a){this._node&&this._node.setAnchorPoint(this._anchorPoint)},clone:function(){var a=new ccs.AnchorPointFrame;return a.setAnchorPoint(this._anchorPoint),a._cloneProperty(this),a},setAnchorPoint:function(a){this._anchorPoint=a},getAnchorPoint:function(){return this._anchorPoint}});ccs.AnchorPointFrame.create=function(){return new ccs.AnchorPointFrame};
ccs.InnerActionType={LoopAction:0,NoLoopAction:1,SingleFrame:2};
ccs.InnerActionFrame=ccs.Frame.extend({_innerActionType:null,_startFrameIndex:null,_endFrameIndex:0,_singleFrameIndex:0,_enterWithName:null,_animationName:"",ctor:function(){ccs.Frame.prototype.ctor.call(this);this._enterWithName=!1;this._innerActionType=ccs.InnerActionType.LoopAction;this._startFrameIndex=0},onEnter:function(a){if(this._node&&(a=this._node.getActionByTag(this._node.getTag()))){if(ccs.InnerActionType.SingleFrame===this._innerActionType)return void a.gotoFrameAndPause(this._singleFrameIndex);var b=
this._startFrameIndex,c=this._endFrameIndex;this._enterWithName&&("-- ALL --"===this._animationName?(b=0,c=a.getDuration()):a.isAnimationInfoExists(this._animationName)?(c=a.getAnimationInfo(this._animationName),b=c.startIndex,c=c.endIndex):cc.log("Animation %s not exists!",this._animationName));var d=this._timeline.getActionTimeline().getDuration()-this._frameIndex-c+b;0>d&&(c+=d);ccs.InnerActionType.NoLoopAction===this._innerActionType?a.gotoFrameAndPlay(b,c,!1):ccs.InnerActionType.LoopAction===
this._innerActionType&&a.gotoFrameAndPlay(b,c,!0)}},setAnimationName:function(a){this._animationName=a},setSingleFrameIndex:function(a){this._singleFrameIndex=a},getSingleFrameIndex:function(){return this._startFrameIndex},setEnterWithName:function(a){this._enterWithName=a},getEnterWithName:function(){return this._enterWithName},clone:function(){var a=new ccs.InnerActionFrame;return a.setInnerActionType(this._innerActionType),a.setStartFrameIndex(this._startFrameIndex),a.setEnterWithName(this._enterWithName),
a.setAnimationName(this._animationName),a.setSingleFrameIndex(this._singleFrameIndex),a._cloneProperty(this),a},setInnerActionType:function(a){this._innerActionType=a},getInnerActionType:function(){return this._innerActionType},setStartFrameIndex:function(a){this._startFrameIndex=a},getStartFrameIndex:function(){return this._startFrameIndex}});ccs.InnerActionFrame.create=function(){return new ccs.InnerActionFrame};
ccs.ColorFrame=ccs.Frame.extend({_alpha:null,_color:null,_betweenAlpha:null,_betweenRed:null,_betweenGreen:null,_betweenBlue:null,ctor:function(){ccs.Frame.prototype.ctor.call(this);this._color=cc.color(255,255,255)},onEnter:function(a){if(this._node&&(this._node.setColor(this._color),this._tween))a=a._color,this._betweenRed=a.r-this._color.r,this._betweenGreen=a.g-this._color.g,this._betweenBlue=a.b-this._color.b},_onApply:function(a){if(this._node&&this._tween&&(0!==this._betweenAlpha||0!==this._betweenRed||
0!==this._betweenGreen||0!==this._betweenBlue)){var b=cc.color(255,255,255);(b.r=this._color.r+this._betweenRed*a,b.g=this._color.g+this._betweenGreen*a,b.b=this._color.b+this._betweenBlue*a,this._node.setColor(b),null!==this._alpha)&&this._node.setOpacity(this._alpha+this._betweenAlpha*a)}},clone:function(){var a=new ccs.ColorFrame;return a.setColor(this._color),a._cloneProperty(this),a},setColor:function(a){this._color=a},getColor:function(){return this._color}});ccs.ColorFrame.create=function(){return new ccs.ColorFrame};
ccs.AlphaFrame=ccs.Frame.extend({_alpha:null,_betweenAlpha:null,ctor:function(){ccs.Frame.prototype.ctor.call(this);this._alpha=255},onEnter:function(a){this._node&&(this._node.setOpacity(this._alpha),this._tween&&(this._betweenAlpha=a._alpha-this._alpha))},_onApply:function(a){this._node&&this._node.setOpacity(this._alpha+this._betweenAlpha*a)},setAlpha:function(a){this._alpha=a},getAlpha:function(){return this._alpha},clone:function(){var a=new ccs.AlphaFrame;return a.setAlpha(this._alpha),a._cloneProperty(this),
a}});ccs.EventFrame=ccs.Frame.extend({_event:null,ctor:function(){ccs.Frame.prototype.ctor.call(this);this._event=""},onEnter:function(a){this._emitEvent()},clone:function(){var a=new ccs.EventFrame;return a.setEvent(this._event),a._cloneProperty(this),a},setEvent:function(a){this._event=a},getEvent:function(){return this._event}});ccs.EventFrame.create=function(){return new ccs.EventFrame};
ccs.ZOrderFrame=ccs.Frame.extend({_zorder:null,onEnter:function(a){this._node&&this._node.setLocalZOrder(this._zorder)},clone:function(){var a=new ccs.ZOrderFrame;return a.setZOrder(this._zorder),a._cloneProperty(this),a},setZOrder:function(a){this._zorder=a},getZOrder:function(){return this._zorder}});ccs.ZOrderFrame.create=function(){return new ccs.ZOrderFrame};
ccs.BlendFuncFrame=ccs.Frame.extend({onEnter:function(a,b){this._node&&this._node.setBlendFunc(this._blendFunc)},clone:function(){var a=new ccs.BlendFuncFrame;return a.setBlendFunc(this._blendFunc),a.cloneProperty(this),a}});ccs.BlendFuncFrame.create=function(){return new ccs.BlendFuncFrame};
ccs.Timeline=ccs.Class.extend({_frames:null,_currentKeyFrame:null,_currentKeyFrameIndex:null,_fromIndex:null,_toIndex:null,_betweenDuration:null,_actionTag:null,_ActionTimeline:null,_node:null,ctor:function(){this._frames=[];this._currentKeyFrame=null;this._actionTag=this._betweenDuration=this._toIndex=this._fromIndex=this._currentKeyFrameIndex=0;this._node=this._ActionTimeline=null},_gotoFrame:function(a){0!==this._frames.length&&(this._binarySearchKeyFrame(a),this._apply(a))},_stepToFrame:function(a){0!==
this._frames.length&&(this._updateCurrentKeyFrame(a),this._apply(a))},getFrames:function(){return this._frames},addFrame:function(a){this._frames.push(a);a.setTimeline(this)},insertFrame:function(a,b){this._frames.splice(b,0,a);a.setTimeline(this)},removeFrame:function(a){cc.arrayRemoveObject(this._frames,a);a.setTimeline(null)},setActionTag:function(a){this._actionTag=a},getActionTag:function(){return this._actionTag},setNode:function(a){for(var b=0;b<this._frames.length;b++)this._frames[b].setNode(a)},
getNode:function(){return this._node},setActionTimeline:function(a){this._ActionTimeline=a},getActionTimeline:function(){return this._ActionTimeline},clone:function(){var a=new ccs.Timeline;a._actionTag=this._actionTag;for(var b=0;b<this._frames.length;b++){var c=this._frames[b].clone();a.addFrame(c)}return a},_apply:function(a){this._currentKeyFrame&&this._currentKeyFrame.apply(0===this._betweenDuration?0:(a-this._currentKeyFrameIndex)/this._betweenDuration)},_binarySearchKeyFrame:function(a){var b=
null,c=null,d=this._frames.length,e=!1;do if(a<=this._frames[0].getFrameIndex())this._currentKeyFrameIndex>=this._frames[0].getFrameIndex()&&(e=!0),b=c=this._frames[0],this._currentKeyFrameIndex=0,this._betweenDuration=this._frames[0].getFrameIndex();else if(a>=this._frames[d-1].getFrameIndex())b=c=this._frames[d-1],this._currentKeyFrameIndex=this._frames[d-1].getFrameIndex(),this._betweenDuration=0;else{for(var f=-1,b=0,c=d-1,g=0;c>=b;){if(g=Math.ceil((b+c)/2),a>=this._frames[g].getFrameIndex()&&
a<this._frames[g+1].getFrameIndex()){f=g;break}this._frames[g].getFrameIndex()>a?c=g-1:b=g+1}b=this._frames[f];c=this._frames[f+1];0===f&&this._currentKeyFrameIndex<b.getFrameIndex()&&(e=!0);this._currentKeyFrameIndex=b.getFrameIndex();this._betweenDuration=c.getFrameIndex()-b.getFrameIndex()}while(0);(e||this._currentKeyFrame!=b)&&(this._currentKeyFrame=b,this._currentKeyFrame.onEnter(c))},_updateCurrentKeyFrame:function(a){if(a<this._currentKeyFrameIndex||a>=this._currentKeyFrameIndex+this._betweenDuration){var b=
null,c=null;do{var d=this._frames.length;if(a<this._frames[0].getFrameIndex())b=c=this._frames[0],this._currentKeyFrameIndex=0,this._betweenDuration=this._frames[0].getFrameIndex();else if(a>=this._frames[d-1].getFrameIndex())b=c=this._frames[d-1],this._currentKeyFrameIndex=this._frames[d-1].getFrameIndex(),this._betweenDuration=0;else{do if(this._fromIndex=this._toIndex,b=this._frames[this._fromIndex],this._currentKeyFrameIndex=b.getFrameIndex(),this._toIndex=this._fromIndex+1,this._toIndex>=d&&
(this._toIndex=0),c=this._frames[this._toIndex],a===b.getFrameIndex())break;while(a<b.getFrameIndex()||a>=c.getFrameIndex());this._betweenDuration=c.getFrameIndex()-b.getFrameIndex()}}while(0);this._currentKeyFrame=b;this._currentKeyFrame.onEnter(c)}}});ccs.Timeline.create=function(){return new ccs.Timeline};
ccs._load=function(){var a=function(a,d,h){var k=cc.loader.getRes(a);if(!k)return cc.log("%s does not exist",a);var m=a.match(c),m=(m&&m[1]?m[1]:null).toLocaleLowerCase();if("json"!==m&&"exportjson"!==m)return cc.log("%s load error, must be json file",a);var n;if(d?n=b[d]:k.widgetTree?n=b.ccui:k.nodeTree?n=b.timeline:k.Content&&k.Content.Content?n=b.timeline:k.gameobjects&&(n=b.scene),!n)return cc.log("Can't find the parser : %s",a),new cc.Node;d=k.version||k.Version;return!d&&k.armature_data?(cc.warn("%s is armature. please use:",
a),cc.warn("    ccs.armatureDataManager.addArmatureFileInfoAsync(%s);",a),cc.warn("    var armature \x3d new ccs.Armature('name');"),new cc.Node):(n=e(n,d))?n.parse(a,k,h)||null:(cc.log("Can't find the parser : %s",a),new cc.Node)},b={ccui:{},timeline:{},action:{},scene:{}};a.registerParser=function(a,c,d){return a&&c&&d?(b[a]||(b[a]={}),void(b[a][c]=d)):cc.log("register parser error")};a.getParser=function(a,c){return a&&c?b[a]?b[a][c]:void 0:a?b[a]:b};var c=/\.([^\.]+)$/,d=/([^\.](\.\*)?)*$/,e=
function(a,b){return a[b]?a[b]:"*"===b?null:e(a,b.replace(d,"*"))};return a}();
ccs._parser=cc.Class.extend({ctor:function(){this.parsers={}},_dirnameReg:/\S*\//,_dirname:function(a){return(a=a.match(this._dirnameReg))&&a[0]?a[0]:""},getClass:function(a){return a.classname},getNodeJson:function(a){return a.widgetTree},parse:function(a,b){var c=this._dirname(a);this.pretreatment(b,c);var d=this.parseNode(this.getNodeJson(b),c,a);return d&&this.deferred(b,c,d,a),d},pretreatment:function(a,b,c){},deferred:function(a,b,c,d){},parseNode:function(a,b){var c=this.parsers[this.getClass(a)];
return c?c.call(this,a,b):cc.log("Can't find the parser : %s",this.getClass(a)),null},registerParser:function(a,b){this.parsers[a]=b}});ccs.load=function(a,b){var c={node:null,action:null};return c.node=ccs._load(a,null,b),c.action=ccs._load(a,"action",b),c.action&&-1===c.action.tag&&c.node&&(c.action.tag=c.node.tag),c};ccs.actionTimelineCache={createAction:function(a){return ccs._load(a,"action")}};ccs.csLoader={createNode:function(a){return ccs._load(a)}};
(function(a,b){var c={},d=new (b.extend({getNodeJson:function(a){return a.action},parseNode:function(a,b,d){if(!a)return null;if(c[d])return c[d].clone();var h=this,k=new ccs.ActionTimeline;k.setDuration(a.duration);k.setTimeSpeed(a.speed||1);return a.timelines.forEach(function(a){var c,d=h.parsers[a.frameType];d?c=d.call(h,a,b):cc.log("parser does not exist : %s",a.frameType);c&&k.addTimeline(c);"ColorFrame"===a.frameType&&k.addTimeline(h.parsers.AlphaFrame.call(h,a,b))}),c[d]=k,c[d].retain(),k.clone()}}));
[{name:"PositionFrame",handle:function(a){var b=new ccs.PositionFrame;return b.setPosition(cc.p(a.x,a.y)),b}},{name:"VisibleFrame",handle:function(a){var b=new ccs.VisibleFrame;return b.setVisible(a.value),b}},{name:"ScaleFrame",handle:function(a){var b=new ccs.ScaleFrame,c=a.y;return b.setScaleX(a.x),b.setScaleY(c),b}},{name:"RotationFrame",handle:function(a){var b=new ccs.RotationFrame;return b.setRotation(a.rotation),b}},{name:"SkewFrame",handle:function(a){var b=new ccs.SkewFrame,c=a.y;return b.setSkewX(a.x),
b.setSkewY(c),b}},{name:"RotationSkewFrame",handle:function(a){var b=new ccs.RotationSkewFrame,c=a.y;return b.setSkewX(a.x),b.setSkewY(c),b}},{name:"AnchorFrame",handle:function(a){var b=new ccs.AnchorPointFrame;return b.setAnchorPoint(cc.p(a.x,a.y)),b}},{name:"InnerActionFrame",handle:function(a){var b=new ccs.InnerActionFrame,c=a.startFrame;return b.setInnerActionType(a.innerActionType),b.setStartFrameIndex(c),b}},{name:"ColorFrame",handle:function(a){var b=new ccs.ColorFrame;b.setColor(cc.color(a.red,
a.green,a.blue));return(new ccs.AlphaFrame).setAlpha(a.alpha),b}},{name:"AlphaFrame",handle:function(a){var b=new ccs.AlphaFrame;return b.setAlpha(a.alpha),b}},{name:"TextureFrame",handle:function(a){var b=new ccs.TextureFrame;a=a.value;if(null!=a){var c=a;null==cc.spriteFrameCache.getSpriteFrame(c)&&(c=ccs.csLoader.getJsonPath()+a);b.setTextureName(c)}return b}},{name:"EventFrame",handle:function(a){var b=new ccs.EventFrame;a=a.value;return null!=a&&b.setEvent(a),b}},{name:"ZOrderFrame",handle:function(a){var b=
new ccs.ZOrderFrame;return b.setZOrder(a.value),b}}].forEach(function(a){d.registerParser(a.name,function(b,c){var d=new ccs.Timeline;d.setActionTag(b.actionTag);var k=b.frames;return k&&k.length&&k.forEach(function(b){var c=a.handle(b);c.setFrameIndex(b.frameIndex);c.setTween(b.tween);d.addFrame(c)}),d})});a.registerParser("action","*",d)})(ccs._load,ccs._parser);
(function(a,b){var c={},d=new (b.extend({getNodeJson:function(a){return a.Content.Content.Animation},parseNode:function(a,b,d){if(!a)return null;if(c[d])return c[d].clone();var e=this,m=new ccs.ActionTimeline;m.setDuration(a.Duration);m.setTimeSpeed(a.Speed||1);return a.Timelines.forEach(function(a){var c,d=e.parsers[a.Property];d?c=d.call(e,a,b):cc.log("parser does not exist : %s",a.Property);c&&m.addTimeline(c)}),c[d]=m,c[d].retain(),m.clone()},deferred:function(a,b,c,d){b=(a=a.Content.Content.AnimationList)?
a.length:0;for(d=0;b>d;d++){var e=a[d],n={name:null,startIndex:null,endIndex:null};n.name=e.Name;n.startIndex=e.StartIndex;n.endIndex=e.EndIndex;c.addAnimationInfo(n)}}})),e=function(a,b){a.setTweenType(b.Type);var c=b.Points;c&&(c=c.map(function(a){return cc.p(a.X,a.Y)}),a.setEasingParams(c))};[{name:"Position",handle:function(a){var b=new ccs.PositionFrame;return b.setPosition(cc.p(a.X,a.Y)),b}},{name:"VisibleForFrame",handle:function(a){var b=new ccs.VisibleFrame;return b.setVisible(a.Value),b}},
{name:"Scale",handle:function(a){var b=new ccs.ScaleFrame,c=a.Y;return b.setScaleX(a.X),b.setScaleY(c),b}},{name:"Rotation",handle:function(a){var b=new ccs.RotationFrame;return b.setRotation(a.Rotation),b}},{name:"Skew",handle:function(a){var b=new ccs.SkewFrame,c=a.Y;return b.setSkewX(a.X),b.setSkewY(c),b}},{name:"RotationSkew",handle:function(a){var b=new ccs.RotationSkewFrame,c=a.Y;return b.setSkewX(a.X),b.setSkewY(c),b}},{name:"Anchor",handle:function(a){var b=new ccs.AnchorPointFrame;return b.setAnchorPoint(cc.p(a.X,
a.Y)),b}},{name:"InnerAction",handle:function(a){var b=new ccs.InnerActionFrame,c=a.StartFrame;return b.setInnerActionType(a.InnerActionType),b.setStartFrameIndex(c),b}},{name:"CColor",handle:function(a){var b=new ccs.ColorFrame;a=a.Color;return a||(a={}),a.R=a.R||255,a.G=a.G||255,a.B=a.B||255,b.setColor(cc.color(a.R,a.G,a.B)),b}},{name:"Alpha",handle:function(a){var b=new ccs.AlphaFrame;return b.setAlpha(a.Value),b}},{name:"FileData",handle:function(a,b){var c=new ccs.TextureFrame,d=a.TextureFile;
null!=d&&(d=d.Path,null==cc.spriteFrameCache.getSpriteFrame(d)&&(d=b+d),c.setTextureName(d));return c}},{name:"FrameEvent",handle:function(a){var b=new ccs.EventFrame;a=a.Value;return null!=a&&b.setEvent(a),b}},{name:"ZOrder",handle:function(a){var b=new ccs.ZOrderFrame;return b.setZOrder(a.Value),b}},{name:"ActionValue",handle:function(a){var b=new ccs.InnerActionFrame,c=a.InnerActionType,d=a.CurrentAniamtionName,e=a.SingleFrameIndex;a=a.FrameIndex;return void 0!==a&&b.setFrameIndex(a),b.setInnerActionType(ccs.InnerActionType[c]),
b.setSingleFrameIndex(e),b.setEnterWithName(!0),d&&b.setAnimationName(d),b}}].forEach(function(a){d.registerParser(a.name,function(b,c){var d=new ccs.Timeline;d.setActionTag(b.ActionTag);var m=b.Frames;return m&&m.length&&m.forEach(function(b){var g=a.handle(b,c);g.setFrameIndex(b.FrameIndex);g.setTween(null!=b.Tween?b.Tween:!0);(b=b.EasingData)&&e(g,b);d.addFrame(g)}),d})});a.registerParser("action","2.*",d)})(ccs._load,ccs._parser);
(function(a,b){var c=new (b.extend({getNodeJson:function(a){return a},parseNode:function(a,b){var c=this.parsers[this.getClass(a)];return c?c.call(this,a,b):cc.log("Can't find the parser : %s",this.getClass(a)),null},deferred:function(a,b,c,d){ccs.triggerManager.parse(a.Triggers||[]);ccs.sceneReader&&(ccs.sceneReader._node=c)},setPropertyFromJsonDict:function(a,b){var c=cc.isUndefined(b.x)?0:b.x,d=cc.isUndefined(b.y)?0:b.y;a.setPosition(c,d);c=Boolean(cc.isUndefined(b.visible)?1:b.visible);a.setVisible(c);
c=cc.isUndefined(b.objecttag)?-1:b.objecttag;a.setTag(c);c=cc.isUndefined(b.zorder)?0:b.zorder;a.setLocalZOrder(c);c=cc.isUndefined(b.scalex)?1:b.scalex;d=cc.isUndefined(b.scaley)?1:b.scaley;a.setScaleX(c);a.setScaleY(d);c=cc.isUndefined(b.rotation)?0:b.rotation;a.setRotation(c);a.setName(b.name||"")}}));c.parseChild=function(a,b,c){for(var d=0;d<b.length;d++){var e,f=b[d];f&&(e=this.parseNode(f,c));e&&a.addChild(e)}};var d={CCSprite:function(a,b,c){var d=new cc.Sprite;f(b.fileData,c,function(a,b){if(0===
b)d.setTexture(a);else if(1===b){var c=cc.spriteFrameCache.getSpriteFrame(a);d.setSpriteFrame(c)}});b=new ccs.ComRender(d,"CCSprite");return a.addComponent(b),b},CCTMXTiledMap:function(a,b,c){var d=null;f(b.fileData,c,function(a,b){0===b&&(d=new cc.TMXTiledMap(a))});b=new ccs.ComRender(d,"CCTMXTiledMap");return a.addComponent(b),b},CCParticleSystemQuad:function(a,b,c){var d=null;f(b.fileData,c,function(a,b){0===b?d=new cc.ParticleSystem(a):cc.log("unknown resourcetype on CCParticleSystemQuad!");d.setPosition(0,
0)});b=new ccs.ComRender(d,"CCParticleSystemQuad");return a.addComponent(b),b},CCArmature:function(a,b,c){var d=null;if(f(b.fileData,c,function(a,b){if(0===b){var c=cc.loader.getRes(a);c||cc.log("Please load the resource [%s] first!",a);c=c.armature_data[0].name;ccs.armatureDataManager.addArmatureFileInfo(a);d=new ccs.Armature(c)}}),d)return c=new ccs.ComRender(d,"CCArmature"),a.addComponent(c),a=b.selectedactionname,a&&d.getAnimation()&&d.getAnimation().play(a),c},CCComAudio:function(a,b,c){var d=
null;f(b.fileData,c,function(c,e){if(0===e){d=new ccs.ComAudio;d.preloadEffect(c);var f=b.name;f&&d.setName(f);a.addComponent(d)}})},CCComAttribute:function(a,b,c){var d=null;return f(b.fileData,c,function(b,c){0===c?(d=new ccs.ComAttribute,""!==b&&d.parse(b),a.addComponent(d)):cc.log("unknown resourcetype on CCComAttribute!")}),d},CCBackgroundAudio:function(a,b,c){var d=null;f(b.fileData,c,function(c,e){if(0===e){d=new ccs.ComAudio;d.preloadBackgroundMusic(c);d.setFile(c);var f=Boolean(b.loop||0);
d.setLoop(f);var k=b.name;k&&d.setName(k);a.addComponent(d);d.playBackgroundMusic(c,f)}})},GUIComponent:function(a,b,c){var d=null;f(b.fileData,c,function(a,b){d=ccs._load(a,"ccui")});b=new ccs.ComRender(d,"GUIComponent");return a.addComponent(b),b},CCScene:function(){}},e={},f=function(a,b,c){if(null!=a){var d=a.path,f=a.resourceType;a=a.plist;d&&(a&&(cc.loader.getRes(b+a)?(e[b+a]=!0,cc.spriteFrameCache.addSpriteFrames(b+a)):e[b+a]||cc.log("%s need to be preloaded",b+a)),0!==f?c(d,f):c(b+d,f))}};
c.parseComponents=function(a,b,c){a&&b&&b.forEach(function(b){var e=d[b.classname],f=null;e?f=e(a,b,c):cc.log("Can't find the component parser : %s",b.classname);b=b.name;f&&b&&f.setName(b)})};c.registerParser("CCNode",function(a,b){var c=new cc.Node;this.setPropertyFromJsonDict(c,a);this.parseChild.call(this,c,a.gameobjects,b);this.parseComponents(c,a.components,b);var d=a.CanvasSize;return d&&c.setContentSize(cc.size(d._width,d._height)),c});a.registerParser("scene","*",c)})(ccs._load,ccs._parser);
(function(a,b){var c={},d=new (b.extend({getNodeJson:function(a){return a.nodeTree},addSpriteFrame:function(a,b,d){if(a&&b&&a.length===b.length)for(var e=0;e<a.length;e++){var m=d+a[e];cc.loader.getRes(m)||c[m]?c[m]=!0:cc.log("%s need to be preloaded",m);cc.spriteFrameCache.addSpriteFrames(m,d+b[e])}},pretreatment:function(a,b,c){this.addSpriteFrame(a.textures,a.texturesPng,b)}}));d.generalAttributes=function(a,b){var c=null!=b.width?b.width:0,d=null!=b.height?b.height:0,e=null!=b.x?b.x:0,n=null!=
b.y?b.y:0,p=null!=b.scaleX?b.scaleX:1,r=null!=b.scaleY?b.scaleY:1,s=null!=b.rotation?b.rotation:0,v=null!=b.rotationSkewX?b.rotationSkewX:0,u=null!=b.rotationSkewY?b.rotationSkewY:0,t=null!=b.skewX?b.skewX:0,x=null!=b.skewY?b.skewY:0,A=null!=b.anchorPointX?b.anchorPointX:0.5,F=null!=b.anchorPointY?b.anchorPointY:0.5,z=null!=b.opacity?b.opacity:255,w=null!=b.colorR?b.colorR:255,B=null!=b.colorG?b.colorG:255,E=null!=b.colorB?b.colorB:255,I=null!=b.colorR?b.colorR:0,J=null!=b.tag?b.tag:0,O=null!=b.actionTag?
b.actionTag:0,L=null!=b.visible?b.visible:!0;(0!=e||0!=n)&&a.setPosition(cc.p(e,n));1!=p&&a.setScaleX(p);1!=r&&a.setScaleY(r);0!=s&&a.setRotation(s);0!=v&&a.setRotationX(v);0!=u&&a.setRotationY(u);0!=t&&a.setSkewX(t);0!=x&&a.setSkewY(x);(0.5!=A||0.5!=F)&&a.setAnchorPoint(cc.p(A,F));(0!=c||0!=d)&&a.setContentSize(cc.size(c,d));0!=I&&a.setLocalZOrder(I);1!=L&&a.setVisible(L);255!=z&&a.setOpacity(z);(255!=w||255!=B||255!=E)&&a.setColor(cc.color(w,B,E));a.setTag(J);a.setUserObject(new ccs.ActionTimelineData(O))};
d.parseComponent=function(a,b){if(b)for(var c=0;c<b.length;++c){var d=this.loadComponent(b[c]);d&&a.addComponent(d)}};d.parseChild=function(a,b,c,d){a=c.children;for(c=0;c<a.length;c++){var e=this.parseNode(a[c],d);if(e)if(b instanceof ccui.PageView)e instanceof ccui.Layout&&b.addPage(e);else if(b instanceof ccui.ListView)e instanceof ccui.Widget&&b.pushBackCustomItem(e);else{if(!(b instanceof ccui.Layout)&&e instanceof ccui.Widget){if(e.getPositionType()===ccui.Widget.POSITION_PERCENT){var n=e.getPositionPercent(),
p=b.getAnchorPoint();e.setPositionPercent(cc.p(n.x+p.x,n.y+p.y))}n=b.getAnchorPointInPoints();e.setPosition(cc.p(e.getPositionX()+n.x,e.getPositionY()+n.y))}b.addChild(e)}}};d.initNode=function(a){var b=new cc.Node;return this.generalAttributes(b,a),b};d.initSubGraph=function(a){var b,c=a.fileName;return b=c&&""!==c?this.createNode(c):new ccs.Node,this.generalAttributes(b,a),b};d.initSprite=function(a,b){var c,d=a.fileName;if(null!=d){var e=cc.spriteFrameCache.getSpriteFrame(d);e?c=ccs.Sprite.createWithSpriteFrame(e):
(d=b+d,c=new ccs.Sprite(d));c||(c=new cc.Sprite,cc.log("filePath is empty. Create a sprite with no texture"))}else c=new ccs.Sprite;this.generalAttributes(c,a);d=a.flipX;e=a.flipY;return 0!=d&&c.setFlippedX(d),0!=e&&c.setFlippedY(e),c};d.initParticle=function(a,b){var c=a.tmxFile,d=new cc.ParticleSystemQuad(a.plistFile);return d.setTotalParticles(c),this.generalAttributes(d,a),d};d.initTMXTiledMap=function(a,b){var c=a.tmxFile,d=a.tmxString,e=a.resourcePath;return c&&""!==c?new cc.TMXTiledMap(c):
d&&""!==d&&e&&""!==e&&new cc.TMXTiledMap(d,e),null};var e=a.getParser("ccui")["*"];d.initWidget=function(a,b){var c=a.classname,d=e.parsers[c];if(!d)return cc.log("%s parser is not found",c);if(c=d.call(e,a,b)){var d=a.rotationSkewX,m=a.rotationSkewY,n=a.skewX,p=a.skewY;0!=d&&c.setRotationX(d);0!=m&&c.setRotationY(m);0!=n&&c.setSkewX(n);0!=p&&c.setSkewY(p);c.setUserObject(new ccs.ActionTimelineData(a.actionTag))}return c};[{name:"Node",handle:d.initNode},{name:"SubGraph",handle:d.initSubGraph},{name:"Sprite",
handle:d.initSprite},{name:"Particle",handle:d.initParticle},{name:"TMXTiledMap",handle:d.initTMXTiledMap},{name:"Widget",handle:d.initWidget},{name:"Panel",handle:d.initWidget},{name:"Button",handle:d.initWidget},{name:"CheckBox",handle:d.initWidget},{name:"ImageView",handle:d.initWidget},{name:"LabelAtlas",handle:d.initWidget},{name:"LabelBMFont",handle:d.initWidget},{name:"Label",handle:d.initWidget},{name:"ListView",handle:d.initWidget},{name:"LoadingBar",handle:d.initWidget},{name:"PageView",
handle:d.initWidget},{name:"ScrollView",handle:d.initWidget},{name:"Slider",handle:d.initWidget},{name:"TextField",handle:d.initWidget}].forEach(function(a){d.registerParser(a.name,function(b,c,d){var e=a.handle.call(this,b.options);return this.parseComponent(e,b.components),this.parseChild(c,e,b,d),e})});a.registerParser("timeline","*",d)})(ccs._load,ccs._parser);
(function(a,b){var c=new (b.extend({parse:function(a,b,c){c=void 0!==c?c:this._dirname(a);this.pretreatment(b,c,a);var d=this.parseNode(this.getNodeJson(b),c);return this.deferred(b,c,d,a),d},getNodeJson:function(a){return a.Content.Content.ObjectData},getClass:function(a){return a.ctype}})),d=function(a,b){return void 0===a?b:a};c.generalAttributes=function(a,b){null!=b.Name&&a.setName(b.Name);var c=b.Position;null==c||null==c.X&&null==c.Y||a.setPosition(cc.p(c.X||0,c.Y||0));c=b.Scale;null!=c&&(null!=
c.ScaleX&&a.setScaleX(c.ScaleX),null!=c.ScaleY&&a.setScaleY(c.ScaleY));c=b.RotationSkewX;null!=c&&a.setRotationX(c);c=b.RotationSkewY;null!=b.RotationSkewY&&a.setRotationY(c);c=b.AnchorPoint;null!=c&&(null==c.ScaleX&&(c.ScaleX=0),null==c.ScaleY&&(c.ScaleY=0),(0.5!=c.ScaleX||0.5!=c.ScaleY)&&a.setAnchorPoint(cc.p(c.ScaleX,c.ScaleY)));null!=b.ZOrder&&a.setLocalZOrder(b.ZOrder);c=d(b.VisibleForFrame,!0);a.setVisible(c);n(a,b.Size);null!=b.Alpha&&a.setOpacity(b.Alpha);a.setTag(b.Tag||0);var c=b.ActionTag||
0,e=new ccs.ObjectExtensionData,f=b.UserData;void 0!==f&&e.setCustomProperty(f);e.setActionTag(c);a.setUserObject(e);a.setCascadeColorEnabled(!0);a.setCascadeOpacityEnabled(!0)};c.parseChild=function(a,b,c){if(a&&b)for(var d=0;d<b.length;d++){var e=this.parseNode(b[d],c);if(e)if(a instanceof ccui.PageView)e instanceof ccui.Layout&&a.addPage(e);else if(a instanceof ccui.ListView)e instanceof ccui.Widget&&a.pushBackCustomItem(e);else{if(!(a instanceof ccui.Layout)&&e instanceof ccui.Widget&&e.getPositionType()===
ccui.Widget.POSITION_PERCENT){var f=e.getPositionPercent(),g=a.getAnchorPoint();e.setPositionPercent(cc.p(f.x+g.x,f.y+g.y))}a.addChild(e)}}};c.initSingleNode=function(a){var b=new cc.Node;return this.generalAttributes(b,a),b};c.initSprite=function(a,b){var c=new cc.Sprite;k(a.FileData,b,function(a,b){if(0===b)c.setTexture(a);else if(1===b){var d=cc.spriteFrameCache.getSpriteFrame(a);c.setSpriteFrame(d)}});var d=a.BlendFunc;if(a.BlendFunc){var e=cc.BlendFunc.ALPHA_PREMULTIPLIED;void 0!==d.Src&&(e.src=
d.Src);void 0!==d.Dst&&(e.dst=d.Dst);c.setBlendFunc(e)}a.FlipX&&c.setFlippedX(!0);a.FlipY&&c.setFlippedY(!0);this.generalAttributes(c,a);d=a.CColor;return null!=d&&c.setColor(m(d)),c};c.initParticle=function(a,b){var c,d=this;return k(a.FileData,b,function(b,e){cc.loader.getRes(b)||cc.log("%s need to be preloaded",b);c=new cc.ParticleSystem(b);d.generalAttributes(c,a);c.setPositionType(cc.ParticleSystem.TYPE_GROUPED);!cc.sys.isNative&&c.setDrawMode(cc.ParticleSystem.TEXTURE_MODE);var f=a.BlendFunc;
if(a.BlendFunc){var g=cc.BlendFunc.ALPHA_PREMULTIPLIED;void 0!==f.Src&&(g.src=f.Src);void 0!==f.Dst&&(g.dst=f.Dst);c.setBlendFunc(g)}}),c};c.widgetAttributes=function(a,b,c){a.setCascadeColorEnabled(!0);a.setCascadeOpacityEnabled(!0);a.setUnifySizeEnabled(!1);a.ignoreContentAdaptWithSize(!1);!c&&n(a,b.Size);(c=b.Name)&&a.setName(c);c=b.ActionTag||0;a.setActionTag(c);var e=new ccs.ObjectExtensionData,f=b.UserData;void 0!==f&&e.setCustomProperty(f);e.setActionTag(c);a.setUserObject(e);(c=b.RotationSkewX)&&
a.setRotationX(c);(c=b.RotationSkewY)&&a.setRotationY(c);b.FlipX&&a.setFlippedX(!0);b.FlipY&&a.setFlippedY(!0);c=b.zOrder;null!=c&&a.setLocalZOrder(c);c=d(b.VisibleForFrame,!0);a.setVisible(c);c=b.Alpha;null!=c&&a.setOpacity(c);a.setTag(b.Tag||0);a.setTouchEnabled(b.TouchEnable||!1);c=b.CallBackType;null!=c&&a.setCallbackType(c);(c=b.CallBackName)&&a.setCallbackName(c);c=b.Position;null!=c&&a.setPosition(c.X||0,c.Y||0);e=b.Scale;null!=e&&(c=d(e.ScaleX,1),e=d(e.ScaleY,1),a.setScaleX(c),a.setScaleY(e));
c=b.AnchorPoint;null!=c&&a.setAnchorPoint(c.ScaleX||0,c.ScaleY||0);c=b.CColor;null!=c&&a.setColor(m(c));if(a=ccui.LayoutComponent.bindLayoutComponent(a)){c=b.PositionPercentXEnable||!1;var e=b.PositionPercentYEnable||!1,g=f=0,h=b.PrePosition;null!=h&&(f=h.X||0,g=h.Y||0);var k=b.PercentWidthEnable||!1,F=b.PercentHeightEnable||!1,z=0,w=0,B=b.PreSize;null!=h&&(z=B.X||0,w=B.Y||0);var E=b.StretchWidthEnable||!1,I=b.StretchHeightEnable||!1,J=b.HorizontalEdge,h=b.VerticalEdge,B=b.LeftMargin||0,O=b.RightMargin||
0,L=b.TopMargin||0;b=b.BottomMargin||0;a.setPositionPercentXEnabled(c);a.setPositionPercentYEnabled(e);a.setPositionPercentX(f);a.setPositionPercentY(g);a.setPercentWidthEnabled(k);a.setPercentHeightEnabled(F);a.setPercentWidth(z);a.setPercentHeight(w);a.setStretchWidthEnabled(E);a.setStretchHeightEnabled(I);c=ccui.LayoutComponent.horizontalEdge.NONE;"LeftEdge"===J?c=ccui.LayoutComponent.horizontalEdge.LEFT:"RightEdge"===J?c=ccui.LayoutComponent.horizontalEdge.RIGHT:"BothEdge"===J&&(c=ccui.LayoutComponent.horizontalEdge.CENTER);
a.setHorizontalEdge(c);c=ccui.LayoutComponent.verticalEdge.NONE;"TopEdge"===h?c=ccui.LayoutComponent.verticalEdge.TOP:"BottomEdge"===h?c=ccui.LayoutComponent.verticalEdge.BOTTOM:"BothEdge"===h&&(c=ccui.LayoutComponent.verticalEdge.CENTER);a.setVerticalEdge(c);a.setTopMargin(L);a.setBottomMargin(b);a.setLeftMargin(B);a.setRightMargin(O);a.setVerticalEdge(c);a.setTopMargin(L);a.setBottomMargin(b);a.setLeftMargin(B);a.setRightMargin(O)}};var e=function(a,b,c,d){2===a.getBackGroundColorType()?(c=c||{},
d=d||{},a.setBackGroundColor(m(c),m(d))):(b=b||{},a.setBackGroundColor(m(b)))},f=function(a,b){a.setBackGroundColorVector(cc.p(b.ScaleX||0,b.ScaleY||0))};c.initPanel=function(a,b){var c=new ccui.Layout;this.widgetAttributes(c,a);var g=a.ClipAble;null!=g&&c.setClippingEnabled(g);g=d(a.ComboBoxIndex,0);c.setBackGroundColorType(g);g=d(a.BackColorAlpha,255);null!=g&&c.setBackGroundColorOpacity(g);g=a.Scale9Enable;null!=g&&c.setBackGroundImageScale9Enabled(g);var h=d(a.Alpha,255);(c.setOpacity(h),k(a.FileData,
b,function(a,b){c.setBackGroundImage(a,b)}),g)?(c.setBackGroundImageCapInsets(cc.rect(a.Scale9OriginX||0,a.Scale9OriginY||0,a.Scale9Width||0,a.Scale9Height||0)),n(c,a.Size)):c.isIgnoreContentAdaptWithSize()||n(c,a.Size);return e(c,a.SingleColor,a.FirstColor,a.EndColor),f(c,a.ColorVector),c};c.initText=function(a,b){var c=new ccui.Text,e=a.TouchScaleChangeAble;null!=e&&c.setTouchScaleChangeEnabled(e);e=a.LabelText;null!=e&&c.setString(e);e=a.FontSize;null!=e&&c.setFontSize(e);e=a.FontName;null!=e&&
c.setFontName(e);var f=a.AreaWidth,g=a.areaHeight;f&&g&&c.setTextAreaSize(cc.size(f,g));f=a.HorizontalAlignmentType||"HT_Left";switch(f){case "HT_Right":f=2;break;case "HT_Center":f=1;break;default:f=0}c.setTextHorizontalAlignment(f);f=a.VerticalAlignmentType||"VT_Top";switch(f){case "VT_Bottom":f=2;break;case "VT_Center":f=1;break;default:f=0}c.setTextVerticalAlignment(f);f=a.FontResource;null!=f&&(f=f.Path,null!=f&&(cc.sys.isNative?e=cc.path.join(cc.loader.resPath,b,f):(e=f.match(/([^\/]+)\.ttf/),
e=e?e[1]:""),c.setFontName(e)));a.OutlineEnabled&&a.OutlineColor&&c.enableOutline&&c.enableOutline(m(a.OutlineColor),d(a.OutlineSize,1));a.ShadowEnabled&&a.ShadowColor&&c.enableShadow&&c.enableShadow(m(a.ShadowColor),cc.size(d(a.ShadowOffsetX,2),d(a.ShadowOffsetY,-2)),a.ShadowBlurRadius||0);e=a.IsCustomSize;return null!=e&&c.ignoreContentAdaptWithSize(!e),c.setUnifySizeEnabled(!1),this.widgetAttributes(c,a,c.isIgnoreContentAdaptWithSize()),c};c.initButton=function(a,b){var c=new ccui.Button;k(a.NormalFileData,
b,function(a,b){c.loadTextureNormal(a,b)});k(a.PressedFileData,b,function(a,b){c.loadTexturePressed(a,b)});k(a.DisabledFileData,b,function(a,b){c.loadTextureDisabled(a,b)});var e=d(a.Scale9Enable,!1);e&&c.setScale9Enabled(e);var f=a.ButtonText;null!=f&&c.setTitleText(f);f=a.FontSize;null!=f&&c.setTitleFontSize(f);f=a.FontName;null!=f&&c.setTitleFontName(f);var g=a.TextColor;null!=g&&c.setTitleColor(m(g));g=d(a.DisplayState,!0);c.setBright(g);c.setEnabled(g);g=a.FontResource;null!=g&&(g=g.Path,null!=
g&&(cc.sys.isNative?f=cc.path.join(cc.loader.resPath,b,g):(f=g.match(/([^\/]+)\.ttf/),f=f?f[1]:""),c.setTitleFontName(f)));f=c.getTitleRenderer();if(f&&a.ShadowEnabled&&a.ShadowColor&&f.enableShadow&&f.enableShadow(m(a.ShadowColor),cc.size(d(a.ShadowOffsetX,2),d(a.ShadowOffsetY,-2)),a.ShadowBlurRadius||0),f&&a.OutlineEnabled&&a.OutlineColor&&f.enableStroke&&f.enableStroke(m(a.OutlineColor),d(a.OutlineSize,1)),this.widgetAttributes(c,a),e)c.setUnifySizeEnabled(!1),c.ignoreContentAdaptWithSize(!1),
e=cc.rect(a.Scale9OriginX||0,a.Scale9OriginY||0,a.Scale9Width||0,a.Scale9Height||0),c.setCapInsets(e);return n(c,a.Size),c};c.initCheckBox=function(a,b){var c=new ccui.CheckBox;this.widgetAttributes(c,a);[{name:"NormalBackFileData",handle:c.loadTextureBackGround},{name:"PressedBackFileData",handle:c.loadTextureBackGroundSelected},{name:"NodeNormalFileData",handle:c.loadTextureFrontCross},{name:"DisableBackFileData",handle:c.loadTextureBackGroundDisabled},{name:"NodeDisableFileData",handle:c.loadTextureFrontCrossDisabled}].forEach(function(d){k(a[d.name],
b,function(a,b){d.handle.call(c,a,b)})});var e=d(a.CheckedState,!1);c.setSelected(e);e=d(a.DisplayState,!0);return c.setBright(e),c.setEnabled(e),c};c.initScrollView=function(a,b){var c=new ccui.ScrollView;this.widgetAttributes(c,a);k(a.FileData,b,function(a,b){c.setBackGroundImage(a,b)});c.setClippingEnabled(a.ClipAble);var g=d(a.ComboBoxIndex,0);c.setBackGroundColorType(g);g=a.BackColorAlpha;null!=g&&c.setBackGroundColorOpacity(g);a.Scale9Enable?(c.setBackGroundImageScale9Enabled(!0),c.setBackGroundImageCapInsets(cc.rect(a.Scale9OriginX||
0,a.Scale9OriginY||0,a.Scale9Width||0,a.Scale9Height||0)),n(c,a.Size)):c.isIgnoreContentAdaptWithSize()||n(c,a.Size);e(c,a.SingleColor,a.FirstColor,a.EndColor);f(c,a.ColorVector);g=a.InnerNodeSize;g=cc.size(g.Width||0,g.Height||0);c.setInnerContainerSize(g);g=0;"Vertical"===a.ScrollDirectionType&&(g=1);"Horizontal"===a.ScrollDirectionType&&(g=2);"Vertical_Horizontal"===a.ScrollDirectionType&&(g=3);c.setDirection(g);g=d(a.IsBounceEnabled,!1);return c.setBounceEnabled(g),c};c.initImageView=function(a,
b){var c=new ccui.ImageView;k(a.FileData,b,function(a,b){c.loadTexture(a,b)});k(a.ImageFileData,b,function(a,b){c.loadTexture(a,b)});a.Scale9Enable?(c.setScale9Enabled(!0),c.setUnifySizeEnabled(!1),c.ignoreContentAdaptWithSize(!1),c.setCapInsets(cc.rect(a.Scale9OriginX||0,a.Scale9OriginY||0,a.Scale9Width||0,a.Scale9Height||0))):n(c,a.Size);return this.widgetAttributes(c,a),c};c.initLoadingBar=function(a,b){var c=new ccui.LoadingBar;this.widgetAttributes(c,a);k(a.ImageFileData,b,function(a,b){c.loadTexture(a,
b)});c.setDirection("Right_To_Left"===a.ProgressType?1:0);var e=d(a.ProgressInfo,80);return null!=e&&c.setPercent(e),c};c.initSlider=function(a,b){var c=new ccui.Slider,e=cc.loader;this.widgetAttributes(c,a);[{name:"BackGroundData",handle:c.loadBarTexture},{name:"BallNormalData",handle:c.loadSlidBallTextureNormal},{name:"BallPressedData",handle:c.loadSlidBallTexturePressed},{name:"BallDisabledData",handle:c.loadSlidBallTextureDisabled},{name:"ProgressBarData",handle:c.loadProgressBarTexture}].forEach(function(d){k(a[d.name],
b,function(a,b){0!==b||e.getRes(a)||cc.log("%s need to be preloaded",a);d.handle.call(c,a,b)})});c.setPercent(a.PercentInfo||0);var f=d(a.DisplayState,!0);return c.setBright(f),c.setEnabled(f),c};c.initPageView=function(a,b){var c=new ccui.PageView;this.widgetAttributes(c,a);k(a.FileData,b,function(a,b){c.setBackGroundImage(a,b)});c.setClippingEnabled(a.ClipAble||!1);a.Scale9Enable&&(c.setBackGroundImageScale9Enabled(!0),c.setBackGroundImageCapInsets(cc.rect(a.Scale9OriginX||0,a.Scale9OriginY||0,
a.Scale9Width||0,a.Scale9Height||0)));var g=d(a.ComboBoxIndex,0);c.setBackGroundColorType(g);e(c,a.SingleColor,a.FirstColor,a.EndColor);f(c,a.ColorVector);g=a.BackColorAlpha;return null!=g&&c.setBackGroundColorOpacity(g),n(c,a.Size),c};c.initListView=function(a,b){var c=new ccui.ListView;this.widgetAttributes(c,a);k(a.FileData,b,function(a,b){c.setBackGroundImage(a,b)});c.setClippingEnabled(a.ClipAble||!1);var g=d(a.ComboBoxIndex,0);c.setBackGroundColorType(g);g=d(a.BackColorAlpha,255);a.Scale9Enable&&
(c.setBackGroundImageScale9Enabled(!0),c.setBackGroundImageCapInsets(cc.rect(a.Scale9OriginX||0,a.Scale9OriginY||0,a.Scale9Width||0,a.Scale9Height||0)));var h=d(a.DirectionType,ccui.ListView.DIR_HORIZONTAL),m=d(a.VerticalType,"Align_Left"),x=d(a.HorizontalType,"Align_Top");h?"Vertical"===h&&(c.setDirection(ccui.ScrollView.DIR_VERTICAL),""===x?c.setGravity(ccui.ListView.GRAVITY_LEFT):"Align_Right"===x?c.setGravity(ccui.ListView.GRAVITY_RIGHT):"Align_HorizontalCenter"===x&&c.setGravity(ccui.ListView.GRAVITY_CENTER_HORIZONTAL)):
(c.setDirection(ccui.ScrollView.DIR_HORIZONTAL),c.setGravity("Align_Bottom"===m?ccui.ListView.GRAVITY_BOTTOM:"Align_VerticalCenter"===m?ccui.ListView.GRAVITY_CENTER_VERTICAL:ccui.ListView.GRAVITY_TOP));h=d(a.IsBounceEnabled,!1);c.setBounceEnabled(h);c.setItemsMargin(a.ItemMargin||0);h=a.InnerNodeSize;return null!=h&&c.setInnerContainerSize(cc.size(h.Widget||0,h.Height||0)),e(c,a.SingleColor,a.FirstColor,a.EndColor),f(c,a.ColorVector),null!=g&&c.setBackGroundColorOpacity(g),n(c,a.Size),c};c.initTextAtlas=
function(a,b){var c=new ccui.TextAtlas,d=a.LabelText,e=a.CharWidth,f=a.CharHeight,g=a.StartChar;return k(a.LabelAtlasFileImage_CNB,b,function(a,b){cc.loader.getRes(a)||cc.log("%s need to be preloaded",a);0===b&&c.setProperty(d,a,e,f,g)}),this.widgetAttributes(c,a),c};c.initTextBMFont=function(a,b){var c=new ccui.TextBMFont;this.widgetAttributes(c,a);return c.setString(a.LabelText),k(a.LabelBMFontFile_CNB,b,function(a,b){cc.loader.getRes(a)||cc.log("%s need to be pre loaded",a);c.setFntFile(a)}),c.ignoreContentAdaptWithSize(!0),
c};c.initTextField=function(a,b){var c=new ccui.TextField;a.PasswordEnable&&(c.setPasswordEnabled(!0),c.setPasswordStyleText(a.PasswordStyleText||"*"));var d=a.PlaceHolderText;null!=d&&c.setPlaceHolder(d);d=a.FontSize;null!=d&&c.setFontSize(d);d=a.FontName;null!=d&&c.setFontName(d);a.MaxLengthEnable&&(c.setMaxLengthEnabled(!0),c.setMaxLength(a.MaxLengthText||0));this.widgetAttributes(c,a);var e=a.LabelText;null!=e&&c.setString(e);e=a.FontResource;null!=e&&(e=e.Path,null!=e&&(cc.sys.isNative?d=cc.path.join(cc.loader.resPath,
b,e):(d=e.match(/([^\/]+)\.ttf/),d=d?d[1]:""),c.setFontName(d)));c.setUnifySizeEnabled(!1);c.ignoreContentAdaptWithSize(!1);d=a.CColor;return null!=d&&c.setTextColor(m(d)),c.isIgnoreContentAdaptWithSize()||(n(c,a.Size),cc.sys.isNative&&c.getVirtualRenderer().setLineBreakWithoutSpace(!0)),c};c.initSimpleAudio=function(a,b){var c=a.Loop||!1;cc.audioEngine.setMusicVolume(a.Volume||0);var d="";cc.loader.resPath&&(d=(cc.loader.resPath+"/").replace(/\/\/$/,"/"));k(a.FileData,b,function(a,b){cc.loader.load(a,
function(){cc.audioEngine.playMusic(d+a,c)})})};c.initGameMap=function(a,b){var d=null;return k(a.FileData,b,function(b,e){0===e&&(d=new cc.TMXTiledMap(b));c.generalAttributes(d,a)}),d};c.initProjectNode=function(a,b){var d=a.FileData;if(null!=d&&d.Path){d=b+d.Path;if(cc.loader.getRes(d)){d=ccs.load(d,b);if(c.generalAttributes(d.node,a),d.action&&d.node){d.action.tag=d.node.tag;var e=a.InnerActionSpeed;void 0!==e&&d.action.setTimeSpeed(e);d.node.runAction(d.action);d.action.gotoFrameAndPause(0)}return d.node}cc.log("%s need to be preloaded",
d)}};var g=function(a){return!a?"":(a=a.match(/([^\/]+)\.[^\/]+$/))&&a[1]?a[1]:""};c.initArmature=function(a,b){var d=new ccs.Armature,e=a.IsLoop,f=a.IsAutoPlay,h=a.CurrentAnimationName;return c.generalAttributes(d,a),k(a.FileData,b,function(a,b){var c,k,m=cc.loader.getRes(a);m?(c=m.config_file_path,k=m.config_png_path,c.forEach(function(a,b){k[b]&&cc.spriteFrameCache.addSpriteFrames(a,k[b])})):cc.log("%s need to be preloaded",a);ccs.armatureDataManager.addArmatureFileInfo(a);d.init(g(a));f&&d.getAnimation().play(h,
-1,e)}),d};var h={},k=function(a,b,c){if(null!=a){var d,e=a.Path;d="Default"===a.Type||"Normal"===a.Type?0:1;(a=a.Plist)&&(cc.loader.getRes(b+a)?(h[b+a]=!0,cc.spriteFrameCache.addSpriteFrames(b+a)):h[b+a]||cc.log("%s need to be preloaded",b+a));0!==d?c(e,d):c(b+e,d)}},m=function(a){if(a)return cc.color(null!=a.R?a.R:255,null!=a.G?a.G:255,null!=a.B?a.B:255,null!=a.A?a.A:255)},n=function(a,b){var c=b.X||0,d=b.Y||0;b&&a.setContentSize(cc.size(c,d))};[{name:"SingleNodeObjectData",handle:c.initSingleNode},
{name:"NodeObjectData",handle:c.initSingleNode},{name:"LayerObjectData",handle:c.initSingleNode},{name:"SpriteObjectData",handle:c.initSprite},{name:"ParticleObjectData",handle:c.initParticle},{name:"PanelObjectData",handle:c.initPanel},{name:"TextObjectData",handle:c.initText},{name:"ButtonObjectData",handle:c.initButton},{name:"CheckBoxObjectData",handle:c.initCheckBox},{name:"ScrollViewObjectData",handle:c.initScrollView},{name:"ImageViewObjectData",handle:c.initImageView},{name:"LoadingBarObjectData",
handle:c.initLoadingBar},{name:"SliderObjectData",handle:c.initSlider},{name:"PageViewObjectData",handle:c.initPageView},{name:"ListViewObjectData",handle:c.initListView},{name:"TextAtlasObjectData",handle:c.initTextAtlas},{name:"TextBMFontObjectData",handle:c.initTextBMFont},{name:"TextFieldObjectData",handle:c.initTextField},{name:"SimpleAudioObjectData",handle:c.initSimpleAudio},{name:"GameMapObjectData",handle:c.initGameMap},{name:"ProjectNodeObjectData",handle:c.initProjectNode},{name:"ArmatureNodeObjectData",
handle:c.initArmature}].forEach(function(a){c.registerParser(a.name,function(b,c){var d=a.handle.call(this,b,c);return this.parseChild(d,b.Children,c),d})});a.registerParser("timeline","2.*",c)})(ccs._load,ccs._parser);
(function(a,b){var c=new (b.extend({addSpriteFrame:function(a,b){if(a)for(var c=0;c<a.length;c++)cc.spriteFrameCache.addSpriteFrames(b+a[c])},pretreatment:function(a,b){this.addSpriteFrame(a.textures,b)},deferred:function(a,b,c,d){c&&(ccs.actionManager.initWithDictionary(d,a.animation,c),c.setContentSize(cc.size(a.designWidth,a.designHeight)))}}));c.generalAttributes=function(a,b){var c=b.ignoreSize;null!=c&&a.ignoreContentAdaptWithSize(c);b.sizeType&&a.setSizeType(b.sizeType);b.positionType&&a.setPositionType(b.positionType);
a.setSizePercent(cc.p(b.sizePercentX,b.sizePercentY));a.setPositionPercent(cc.p(b.positionPercentX,b.positionPercentY));var d=c=0;b.adaptScreen?(d=cc.director.getWinSize(),c=d.width,d=d.height):(c=b.width,d=b.height);a.setContentSize(c,d);a.setTag(b.tag);a.setActionTag(b.actiontag);a.setTouchEnabled(b.touchAble);c=b.name;a.setName(c?c:"default");a.setPosition(b.x,b.y);a.setScaleX(null!=b.scaleX?b.scaleX:1);a.setScaleY(null!=b.scaleY?b.scaleY:1);a.setRotation(b.rotation||0);c=b.visible||!1;null!=c&&
a.setVisible(c);a.setLocalZOrder(b.ZOrder);if(null!=b.layoutParameter){c=b.layoutParameter;d=null;switch(c.type){case 1:d=new ccui.LinearLayoutParameter;d.setGravity(c.gravity);break;case 2:var e=d=new ccui.RelativeLayoutParameter;e.setRelativeName(c.relativeName);e.setRelativeToWidgetName(c.relativeToName);e.setAlign(c.align)}null!=d&&(d.setMargin(c.marginLeft||0,c.marginTop||0,c.marginRight||0,c.marginDown||0),a.setLayoutParameter(d))}};c.colorAttributes=function(a,b){var c=b.opacity;null!=c&&a.setOpacity(c);
var c=b.colorR,d=b.colorG,e=b.colorB;a.setColor(cc.color(null==c?255:c,null==d?255:d,null==e?255:e));a.setFlippedX(b.flipX);a.setFlippedY(b.flipY)};c.anchorPointAttributes=function(a,b){var c,d=b.anchorPointX;c=null!=d?b.anchorPointX:a.getAnchorPoint().x;var e,n=b.anchorPointY;e=null!=n?b.anchorPointY:a.getAnchorPoint().y;(null!=d||null!=n)&&a.setAnchorPoint(cc.p(c,e))};c.parseChild=function(a,b,c){b=b.children;for(var d=0;d<b.length;d++){var e=this.parseNode(b[d],c);if(e)if(a instanceof ccui.PageView)a.addPage(e);
else if(a instanceof ccui.ListView)a.pushBackCustomItem(e);else{if(!(a instanceof ccui.Layout)){if(e.getPositionType()===ccui.Widget.POSITION_PERCENT){var n=e.getPositionPercent(),p=a.getAnchorPoint();e.setPositionPercent(cc.p(n.x+p.x,n.y+p.y))}n=a.getAnchorPointInPoints();e.setPosition(cc.p(e.getPositionX()+n.x,e.getPositionY()+n.y))}a.addChild(e)}}};var d=function(a,b,c,d){c&&(0===b?d(a+c,b):d(c,b))};c.LayoutAttributes=function(a,b,c){var e=0,m=0;b.adaptScreen?(m=cc.director.getWinSize(),e=m.width,
m=m.height):(e=b.width,m=b.height);a.setSize(cc.size(e,m));a.setClippingEnabled(b.clipAble);e=b.backGroundScale9Enable;a.setBackGroundImageScale9Enabled(e);var m=b.bgColorR,n=b.bgColorG,p=b.bgColorB,r=b.bgStartColorR,s=b.bgStartColorG,v=b.bgStartColorB,u=b.bgEndColorR,t=b.bgEndColorG,x=b.bgEndColorB;a.setBackGroundColorVector(cc.p(b.vectorX,b.vectorY));var A=b.bgColorOpacity;a.setBackGroundColorType(b.colorType);a.setBackGroundColor(cc.color(r,s,v),cc.color(u,t,x));a.setBackGroundColor(cc.color(m,
n,p));a.setBackGroundColorOpacity(A);m=b.backGroundImageData;(m&&d(c,m.resourceType,m.path,function(b,c){a.setBackGroundImage(b,c)}),e)&&a.setBackGroundImageCapInsets(cc.rect(b.capInsetsX,b.capInsetsY,b.capInsetsWidth,b.capInsetsHeight));b.layoutType&&a.setLayoutType(b.layoutType)};c.ButtonAttributes=function(a,b,c){var e=b.scale9Enable;a.setScale9Enabled(e);var m=b.normalData;d(c,m.resourceType,m.path,function(b,c){a.loadTextureNormal(b,c)});m=b.pressedData;d(c,m.resourceType,m.path,function(b,c){a.loadTexturePressed(b,
c)});m=b.disabledData;if(d(c,m.resourceType,m.path,function(b,c){a.loadTextureDisabled(b,c)}),e)a.setCapInsets(cc.rect(b.capInsetsX,b.capInsetsY,b.capInsetsWidth,b.capInsetsHeight)),c=b.scale9Width,e=b.scale9Height,null!=c&&null!=e&&a.setSize(cc.size(c,e));c=b.text;null!=c&&a.setTitleText(c);a.setTitleColor(cc.color(null!==b.textColorR?b.textColorR:255,null!==b.textColorG?b.textColorG:255,null!==b.textColorB?b.textColorB:255));null!=b.fontSize&&a.setTitleFontSize(b.fontSize);b.fontName&&a.setTitleFontName(b.fontName)};
c.CheckBoxAttributes=function(a,b,c){var e=b.backGroundBoxData;d(c,e.resourceType,e.path,function(b,c){a.loadTextureBackGround(b,c)});var m=b.backGroundBoxSelectedData;d(c,m.resourceType||e.resourceType,m.path||e.path,function(b,c){a.loadTextureBackGroundSelected(b,c)});e=b.frontCrossData;d(c,e.resourceType,e.path,function(b,c){a.loadTextureFrontCross(b,c)});m=b.backGroundBoxDisabledData;d(c,m.resourceType||e.resourceType,m.path||e.path,function(b,c){a.loadTextureBackGroundDisabled(b,c)});e=b.frontCrossDisabledData;
d(c,e.resourceType,e.path,function(b,c){a.loadTextureFrontCrossDisabled(b,c)});b.selectedState&&a.setSelected(b.selectedState)};c.ImageViewAttributes=function(a,b,c){var e=b.fileNameData;d(c,e.resourceType,e.path,function(b,c){a.loadTexture(b,c)});c=!1;if(b.scale9Enable&&(c=b.scale9Enable),a.setScale9Enabled(c),c)c=b.scale9Height,b.scale9Width&&c&&a.setSize(cc.size(b.scale9Width,b.scale9Height)),a.setCapInsets(cc.rect(b.capInsetsX,b.capInsetsY,b.capInsetsWidth,b.capInsetsHeight))};c.TextAtlasAttributes=
function(a,b,c){var d=b.stringValue,e=b.charMapFileData,n=b.itemWidth,p=b.itemHeight,r=b.startCharMap;if(null!=d&&e&&null!=n&&null!=p&&null!=r)switch(b=b.charMapFileData,b.resourceType){case 0:a.setProperty(d,c+b.path,n,p,r);break;case 1:cc.log("Wrong res type of LabelAtlas!")}};c.TextBMFontAttributes=function(a,b,c){var d=b.fileNameData;switch(d.resourceType){case 0:a.setFntFile(c+d.path);break;case 1:cc.log("Wrong res type of LabelAtlas!")}a.setString(b.text)};var e=/\.ttf$/;c.TextAttributes=function(a,
b,c){a.setTouchScaleChangeEnabled(b.touchScaleEnable);a.setString(b.text);null!=b.fontSize&&a.setFontSize(b.fontSize);var d=b.fontName;null!=d&&a.setFontName(cc.sys.isNative?e.test(d)?cc.path.join(cc.loader.resPath,c,d):d:d.replace(e,""));c=b.areaHeight;null!=b.areaWidth&&null!=c&&(c=cc.size(b.areaWidth,b.areaHeight),a.setTextAreaSize(c));null!=b.hAlignment&&a.setTextHorizontalAlignment(b.hAlignment);null!=b.vAlignment&&a.setTextVerticalAlignment(b.vAlignment)};c.ListViewAttributes=function(a,b,d){c.ScrollViewAttributes(a,
b,d);a.setDirection(b.direction);a.setGravity(b.gravity);a.setItemsMargin(b.itemMargin)};c.LoadingBarAttributes=function(a,b,c){var e=b.textureData;d(c,e.resourceType,e.path,function(b,c){a.loadTexture(b,c)});c=b.scale9Enable;if(a.setScale9Enabled(c),c)a.setCapInsets(cc.rect(b.capInsetsX,b.capInsetsY,b.capInsetsWidth,b.capInsetsHeight)),a.setSize(cc.size(b.width,b.height));a.setDirection(b.direction);a.setPercent(b.percent)};c.PageViewAttributes=c.LayoutAttributes;c.ScrollViewAttributes=function(a,
b,d){c.LayoutAttributes(a,b,d);a.setInnerContainerSize(cc.size(null!=b.innerWidth?b.innerWidth:200,null!=b.innerHeight?b.innerHeight:200));a.setDirection(null!=b.direction?b.direction:1);a.setBounceEnabled(b.bounceEnable)};c.SliderAttributes=function(a,b,c){var e=b.scale9Enable;a.setScale9Enabled(e);var m=b.length,n=b.barFileNameData,p=n.resourceType,n=n.path;null!=b.barFileName?e&&(d(c,p,n,function(b,c){a.loadBarTexture(b,c)}),a.setSize(cc.size(m,a.getContentSize().height))):d(c,p,n,function(b,c){a.loadBarTexture(b,
c)});e=b.ballNormalData;d(c,e.resourceType,e.path,function(b,c){a.loadSlidBallTextureNormal(b,c)});m=b.ballPressedData;d(c,m.resourceType||e.resourceType,m.path||e.path,function(b,c){a.loadSlidBallTexturePressed(b,c)});e=b.ballDisabledData;d(c,e.resourceType,e.path,function(b,c){a.loadSlidBallTextureDisabled(b,c)});b=b.progressBarData;d(c,b.resourceType,b.path,function(b,c){a.loadProgressBarTexture(b,c)})};c.TextFieldAttributes=function(a,b,c){var d=b.placeHolder;d&&a.setPlaceHolder(d);a.setString(b.text||
"");(d=b.fontSize1)&&a.setFontSize(d);d=b.fontName;null!=d&&a.setFontName(cc.sys.isNative?e.test(d)?cc.path.join(cc.loader.resPath,c,d):d:d.replace(e,""));c=b.touchSizeWidth;d=b.touchSizeHeight;null!=c&&null!=d&&a.setTouchSize(c,d);c=(b.width,b.height,b.maxLengthEnable);(a.setMaxLengthEnabled(c),c)&&a.setMaxLength(b.maxLength);c=b.passwordEnable;a.setPasswordEnabled(c);c&&a.setPasswordStyleText(b.passwordStyleText);c=b.areaWidth;d=b.areaHeight;c&&d&&(c=cc.size(c,d),a.setTextAreaSize(c));(c=b.hAlignment)&&
a.setTextHorizontalAlignment(c);(b=b.vAlignment)&&a.setTextVerticalAlignment(b)};[{name:"Panel",object:ccui.Layout,handle:c.LayoutAttributes},{name:"Button",object:ccui.Button,handle:c.ButtonAttributes},{name:"CheckBox",object:ccui.CheckBox,handle:c.CheckBoxAttributes},{name:"ImageView",object:ccui.ImageView,handle:c.ImageViewAttributes},{name:"LabelAtlas",object:ccui.TextAtlas,handle:c.TextAtlasAttributes},{name:"LabelBMFont",object:ccui.TextBMFont,handle:c.TextBMFontAttributes},{name:"Label",object:ccui.Text,
handle:c.TextAttributes},{name:"ListView",object:ccui.ListView,handle:c.ListViewAttributes},{name:"LoadingBar",object:ccui.LoadingBar,handle:c.LoadingBarAttributes},{name:"PageView",object:ccui.PageView,handle:c.PageViewAttributes},{name:"ScrollView",object:ccui.ScrollView,handle:c.ScrollViewAttributes},{name:"Slider",object:ccui.Slider,handle:c.SliderAttributes},{name:"TextField",object:ccui.TextField,handle:c.TextFieldAttributes}].forEach(function(a){c.registerParser(a.name,function(b,d){var e=
new a.object,m=b.options;return c.generalAttributes(e,m),a.handle(e,m,d),c.colorAttributes(e,m),c.anchorPointAttributes(e,m),c.parseChild.call(this,e,b,d),e})});a.registerParser("ccui","*",c)})(ccs._load,ccs._parser);
(function(){ccs.uiReader={_fileDesignSizes:{},widgetFromJsonFile:function(a){var c=cc.loader.getRes(a);c&&(this._fileDesignSizes[a]=cc.size(c.designWidth||0,c.designHeight||0));var c=c.Version||c.version,d=ccs.uiReader.getVersionInteger(c);return!c||1700<=d?(cc.warn("Not supported file types, Please try use the ccs.load"),null):ccs._load(a,"ccui")},registerTypeAndCallBack:function(a,c,d,e){var f=ccs._load.getParser("ccui")["*"],g=e.bind(d);f.registerParser(a,function(e,f){var m=new c,n=e.options;
d.setPropsFromJsonDictionary&&d.setPropsFromJsonDictionary(m,n);this.generalAttributes(m,n);var p=n.customProperty;return p=p?JSON.parse(p):{},g(a,m,p),this.colorAttributes(m,n),this.anchorPointAttributes(m,n),this.parseChild.call(this,m,e,f),m})},getVersionInteger:function(a){if(!a||"string"!=typeof a)return 0;a=a.split(".");if(4!==a.length)return 0;var c=0;return a.forEach(function(a,b){c+=a*Math.pow(10,3-b)}),c},storeFileDesignSize:function(a,c){this._fileDesignSizes[a]=c},getFileDesignSize:function(a){return this._fileDesignSizes[a]},
getFilePath:function(){return this._filePath},setFilePath:function(a){this._filePath=a},getParseObjectMap:function(){return ccs._load.getParser("ccui")["*"].parsers},getParseCallBackMap:function(){return ccs._load.getParser("ccui")["*"].parsers},clear:function(){}};var a=ccs._load.getParser("ccui")["*"];ccs.imageViewReader={setPropsFromJsonDictionary:a.ImageViewAttributes};ccs.buttonReader={setPropsFromJsonDictionary:a.ButtonAttributes};ccs.checkBoxReader={setPropsFromJsonDictionary:a.CheckBoxAttributes};
ccs.labelAtlasReader={setPropsFromJsonDictionary:a.TextAtlasAttributes};ccs.labelBMFontReader={setPropsFromJsonDictionary:a.TextBMFontAttributes};ccs.labelReader={setPropsFromJsonDictionary:a.TextAttributes};ccs.layoutReader={setPropsFromJsonDictionary:a.LayoutAttributes};ccs.listViewReader={setPropsFromJsonDictionary:a.ListViewAttributes};ccs.loadingBarReader={setPropsFromJsonDictionary:a.LoadingBarAttributes};ccs.pageViewReader={setPropsFromJsonDictionary:a.PageViewAttributes};ccs.scrollViewReader=
{setPropsFromJsonDictionary:a.ScrollViewAttributes};ccs.sliderReader={setPropsFromJsonDictionary:a.SliderAttributes};ccs.textFieldReader={setPropsFromJsonDictionary:a.TextFieldAttributes}})();
(function(){ccs.sceneReader={_node:null,createNodeWithSceneFile:function(a){a=ccs._load(a,"scene");return this._node=a,a},getNodeByTag:function(a){return null==this._node?null:this._node.getTag()===a?this._node:this._nodeByTag(this._node,a)},_nodeByTag:function(a,b){if(null==a)return null;for(var c=null,d=a.getChildren(),e=0;e<d.length&&!((c=d[e])&&c.getTag()===b)&&!(c=this._nodeByTag(c,b));e++);return c},version:function(){return"*"},setTarget:function(){},clear:function(){ccs.triggerManager.removeAll();
cc.audioEngine.end()}}})();
!function(){ccs.Skin.WebGLRenderCmd=function(a){cc.Sprite.WebGLRenderCmd.call(this,a)};var a=ccs.Skin.WebGLRenderCmd.prototype=Object.create(cc.Sprite.WebGLRenderCmd.prototype);cc.inject(ccs.Skin.RenderCmd,a);a.constructor=ccs.Skin.WebGLRenderCmd;a.updateTransform=function(){var a=this._node,c=this._quad;if(a._visible){var d=this.getNodeToParentTransform(),e=a._rect,f=a._offsetPosition.x,g=a._offsetPosition.y,h=f+e.width,k=g+e.height,m=d.tx,n=d.ty,p=d.a,r=d.b,s=d.d,v=-d.c,d=f*p-g*v+m,e=f*r+g*s+n,
u=h*p-g*v+m,g=h*r+g*s+n,t=h*p-k*v+m,h=h*r+k*s+n,m=f*p-k*v+m,f=f*r+k*s+n,k=a._vertexZ;cc.SPRITEBATCHNODE_RENDER_SUBPIXEL||(d|=0,e|=0,u|=0,g|=0,t|=0,h|=0,m|=0,f|=0);this.SET_VERTEX3F(c.bl.vertices,d,e,k);this.SET_VERTEX3F(c.br.vertices,u,g,k);this.SET_VERTEX3F(c.tl.vertices,m,f,k);this.SET_VERTEX3F(c.tr.vertices,t,h,k)}else c.br.vertices=c.tl.vertices=c.tr.vertices=c.bl.vertices={x:0,y:0,z:0};a.textureAtlas&&a.textureAtlas.updateQuad(c,a.textureAtlas.getTotalQuads());this._quadDirty=!0};a.SET_VERTEX3F=
function(a,c,d,e){a.x=c;a.y=d;a.z=e};a.rendering=function(a){var c=this._node;if(c._textureLoaded){a=a||cc._renderContext;var d=c._texture;if(d&&d._textureLoaded&&(this._shaderProgram.use(),this._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(),cc.glBlendFunc(c._blendFunc.src,c._blendFunc.dst),cc.glBindTexture2DN(0,d),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX),a.bindBuffer(a.ARRAY_BUFFER,this._quadWebBuffer),this._quadDirty&&(a.bufferData(a.ARRAY_BUFFER,this._quad.arrayBuffer,
a.DYNAMIC_DRAW),this._quadDirty=!1),a.vertexAttribPointer(0,3,a.FLOAT,!1,24,0),a.vertexAttribPointer(1,4,a.UNSIGNED_BYTE,!0,24,12),a.vertexAttribPointer(2,2,a.FLOAT,!1,24,16),a.drawArrays(a.TRIANGLE_STRIP,0,4)),cc.g_NumberOfDraws++,0!==cc.SPRITE_DEBUG_DRAW||c._showNode)1===cc.SPRITE_DEBUG_DRAW||c._showNode?(c=this._quad,c=[cc.p(c.tl.vertices.x,c.tl.vertices.y),cc.p(c.bl.vertices.x,c.bl.vertices.y),cc.p(c.br.vertices.x,c.br.vertices.y),cc.p(c.tr.vertices.x,c.tr.vertices.y)],cc._drawingUtil.drawPoly(c,
4,!0)):2===cc.SPRITE_DEBUG_DRAW&&(a=c.getTextureRect(),c=c.getOffsetPosition(),c=[cc.p(c.x,c.y),cc.p(c.x+a.width,c.y),cc.p(c.x+a.width,c.y+a.height),cc.p(c.x,c.y+a.height)],cc._drawingUtil.drawPoly(c,4,!0))}}}();
(function(){ccs.Armature.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._needDraw=!0;this._realAnchorPointInPoints=new cc.Point(0,0)};var a=ccs.Armature.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);cc.inject(ccs.Armature.RenderCmd,a);a.constructor=ccs.Armature.WebGLRenderCmd;a.rendering=function(a,c){var d=this._node;c||(cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW),cc.kmGLPushMatrix(),cc.kmGLLoadMatrix(this._stackMatrix));for(var e=d._children,f=cc.BlendFunc.ALPHA_PREMULTIPLIED,
g=cc.BlendFunc.ALPHA_NON_PREMULTIPLIED,h=0,k=e.length;k>h;h++){var m=e[h];if(m&&m.getDisplayRenderNode){var n=m.getDisplayRenderNode();if(null!==n)switch(n.setShaderProgram(this._shaderProgram),m.getDisplayRenderNodeType()){case ccs.DISPLAY_TYPE_SPRITE:if(n instanceof ccs.Skin){this._updateColorAndOpacity(n._renderCmd,m);n.updateTransform();var p=m.getBlendFunc();n.setBlendFunc(p.src!==f.src||p.dst!==f.dst?m.getBlendFunc():d._blendFunc.src!==f.src||d._blendFunc.dst!==f.dst||n.getTexture().hasPremultipliedAlpha()?
d._blendFunc:g);n._renderCmd.rendering(a)}break;case ccs.DISPLAY_TYPE_ARMATURE:n._renderCmd.rendering(a,!0);break;default:n._renderCmd.transform(),n._renderCmd.rendering(a)}}else m instanceof cc.Node&&(m.setShaderProgram(this._shaderProgram),m._renderCmd.transform(),m._renderCmd.rendering&&m._renderCmd.rendering(a))}c||cc.kmGLPopMatrix()};a.initShaderCache=function(){this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)};a.setShaderProgram=function(a){this._shaderProgram=
a};a._updateColorAndOpacity=function(a,c){var d=c._renderCmd._displayedColor,e=c._renderCmd._displayedOpacity,f=cc.Node._dirtyFlags,g=a._dirtyFlag,h=g&f.colorDirty,f=g&f.opacityDirty;h&&a._updateDisplayColor(d);f&&a._updateDisplayOpacity(e);(h||f)&&a._updateColor()};a.updateChildPosition=function(a,c,d,e,f){var g=this._node;c.updateTransform();var h=d.getBlendFunc();c.setBlendFunc(h.src!==e.src||h.dst!==e.dst?d.getBlendFunc():g._blendFunc.src!==e.src||node_blendFunc.dst!==e.dst||c.getTexture().hasPremultipliedAlpha()?
g._blendFunc:f);c.rendering(a)};a.updateStatus=function(){var a=cc.Node._dirtyFlags,c=this._dirtyFlag,d=c&a.colorDirty,a=c&a.opacityDirty;d&&this._updateDisplayColor();a&&this._updateDisplayOpacity();(d||a)&&this._updateColor();this.transform(this.getParentRenderCmd(),!0)};a.visit=function(a){var c=this._node;if(c._visible){var d=cc.current_stack;d.stack.push(d.top);this.updateStatus(a);d.top=this._stackMatrix;c.sortAllChildren();cc.renderer.pushRenderCommand(this);this._dirtyFlag=0;d.top=d.stack.pop()}}})();
cc.pool={_pool:{},_releaseCB:function(){this.release()},_autoRelease:function(a){var b=void 0===a._running?!1:!a._running;cc.director.getScheduler().schedule(this._releaseCB,a,0,0,0,b)},putInPool:function(a){var b=a.constructor.prototype.__pid;if(!b){var c={writable:!0,enumerable:!1,configurable:!0};c.value=ClassManager.getNewID();Object.defineProperty(a.constructor.prototype,"__pid",c)}this._pool[b]||(this._pool[b]=[]);a.retain&&a.retain();a.unuse&&a.unuse();this._pool[b].push(a)},hasObject:function(a){return(a=
this._pool[a.prototype.__pid])&&0!==a.length?!0:!1},removeObject:function(a){var b=a.constructor.prototype.__pid;if(b&&(b=this._pool[b]))for(var c=0;c<b.length;c++)a===b[c]&&(a.release&&a.release(),b.splice(c,1))},getFromPool:function(a){if(this.hasObject(a)){var b=this._pool[a.prototype.__pid],c=Array.prototype.slice.call(arguments);c.shift();b=b.pop();return b.reuse&&b.reuse.apply(b,c),cc.sys.isNative&&b.release&&this._autoRelease(b),b}},drainAllPools:function(){for(var a in this._pool)for(var b=
0;b<this._pool[a].length;b++){var c=this._pool[a][b];c.release&&c.release()}this._pool={}}};
!function(){if(void 0!==cc){var a=cc.game.config.plugin||{},b=function(){};b.prototype={constructor:b,getInstance:function(){return this},loadPlugin:function(a){},unloadPlugin:function(a){}};var c=function(){};c.prototype={constructor:c,setDebugMode:function(a){},startSession:function(a){},setCaptureUncaughtException:function(a){},callFuncWithParam:function(a){return"function"==typeof this[a]?this[a].apply(this,Array.prototype.splice.call(arguments,1)):void cc.log("function is not define")},callStringFuncWithParam:function(a){this.callFuncWithParam.apply(arguments)},
getPluginName:function(){return this._name},getPluginVersion:function(){return this._version}};c.extend=function(a,b){var d,e={};for(d in c.prototype)e[d]=c.prototype[d];for(d in b)e[d]=b[d];d=eval("(function "+a+"Plugin(){})");return e.constructor=d,d.prototype=e,d};var d=function(a,b){var c;c=plugin.PluginParam.ParamType;switch(a){case c.TypeInt:c=parseInt(b);break;case c.TypeFloat:c=parseFloat(b);break;case c.TypeBool:c=Boolean(b);break;case c.TypeString:c=String(b);break;case c.TypeStringMap:c=
b;break;default:c=b}return c};d.ParamType={TypeInt:1,TypeFloat:2,TypeBool:3,TypeString:4,TypeStringMap:5};d.AdsResultCode={AdsReceived:0,FullScreenViewShown:1,FullScreenViewDismissed:2,PointsSpendSucceed:3,PointsSpendFailed:4,NetworkError:5,UnknownError:6};d.PayResultCode={PaySuccess:0,PayFail:1,PayCancel:2,PayTimeOut:3};d.ShareResultCode={ShareSuccess:0,ShareFail:1,ShareCancel:2,ShareTimeOut:3};var e={},b={extend:function(b,d){e[b]=new (c.extend(b,d));"function"==typeof e[b].ctor&&e[b].ctor(a[b])},
PluginList:e,PluginParam:d,PluginManager:new b};window.plugin=b}}();
!function(){cc.PhysicsSprite=cc.Sprite.extend({_ignoreBodyRotation:!1,_body:null,_rotation:1,ctor:function(a,c){if(cc.Sprite.prototype.ctor.call(this),void 0===a)cc.PhysicsSprite.prototype.init.call(this);else if(cc.isString(a))if("#"===a[0]){var d=a.substr(1,a.length-1),d=cc.spriteFrameCache.getSpriteFrame(d);this.initWithSpriteFrame(d)}else this.init(a,c);else cc.isObject(a)&&(a instanceof cc.Texture2D?this.initWithTexture(a,c):a instanceof cc.SpriteFrame&&this.initWithSpriteFrame(a));cc.renderer.pushRenderCommand(this._renderCmd)},
visit:function(){cc.renderer.pushRenderCommand(this._renderCmd);cc.Sprite.prototype.visit.call(this)},setBody:function(a){this._body=a},getBody:function(){return this._body},getPosition:function(){var a=this._body;return{x:a.p.x,y:a.p.y}},getPositionX:function(){return this._body.p.x},getPositionY:function(){return this._body.p.y},setPosition:function(a,c){void 0===c?(this._body.p.x=a.x,this._body.p.y=a.y):(this._body.p.x=a,this._body.p.y=c)},setPositionX:function(a){this._body.p.x=a},setPositionY:function(a){this._body.p.y=
a},_syncPosition:function(){var a=this._position,c=this._body;(a.x!==c.p.x||a.y!==c.p.y)&&cc.Sprite.prototype.setPosition.call(this,c.p.x,c.p.y)},getRotation:function(){return this._ignoreBodyRotation?this._rotationX:-cc.radiansToDegrees(this._body.a)},setRotation:function(a){this._ignoreBodyRotation?cc.Sprite.prototype.setRotation.call(this,a):this._body.a=-cc.degreesToRadians(a)},_syncRotation:function(){this._rotationX!==-cc.radiansToDegrees(this._body.a)&&cc.Sprite.prototype.setRotation.call(this,
-cc.radiansToDegrees(this._body.a))},getNodeToParentTransform:function(){return this._renderCmd.getNodeToParentTransform()},isDirty:function(){return!this._body.isSleeping()},setDirty:function(){},setIgnoreBodyRotation:function(a){this._ignoreBodyRotation=a},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.PhysicsSprite.CanvasRenderCmd(this):new cc.PhysicsSprite.WebGLRenderCmd(this)}});cc.PhysicsSprite._className="PhysicsSprite";var a=cc.PhysicsSprite.prototype;a.body;
cc.defineGetterSetter(a,"body",a.getBody,a.setBody);a.dirty;cc.defineGetterSetter(a,"dirty",a.isDirty,a.setDirty);cc.PhysicsSprite.create=function(a,c){return new cc.PhysicsSprite(a,c)};cc.PhysicsSprite.createWithSpriteFrameName=cc.PhysicsSprite.create;cc.PhysicsSprite.createWithSpriteFrame=cc.PhysicsSprite.create}();
(function(){cc.PhysicsSprite.CanvasRenderCmd=function(a){cc.Sprite.CanvasRenderCmd.call(this,a);this._needDraw=!0};var a=cc.PhysicsSprite.CanvasRenderCmd.prototype=Object.create(cc.Sprite.CanvasRenderCmd.prototype);a.constructor=cc.PhysicsSprite.CanvasRenderCmd;a.rendering=function(a,c,d){var e=this._node;e._syncPosition();e._ignoreBodyRotation||e._syncRotation();this.transform(this.getParentRenderCmd());cc.Sprite.CanvasRenderCmd.prototype.rendering.call(this,a,c,d)};a.getNodeToParentTransform=function(){var a=
this._node,c=this._transform,d=a._body,e=a._scaleX,f=a._scaleY,g=this._anchorPointInPoints;c.tx=d.p.x;c.ty=d.p.y;var d=-d.a,h=1,k=0;return d&&!a._ignoreBodyRotation&&(h=Math.cos(d),k=Math.sin(d)),c.a=c.d=h,c.b=-k,c.c=k,(1!==e||1!==f)&&(c.a*=e,c.c*=e,c.b*=f,c.d*=f),c.tx+=h*-g.x*e+-k*g.y*f,c.ty-=k*-g.x*e+h*g.y*f,this._ignoreAnchorPointForPosition&&(c.tx+=g.x,c.ty+=g.y),this._transform}})();cc.__convertVerts=function(a){for(var b=[],c=0;c<a.length/2;c++)b[c]={x:a[2*c],y:a[2*c+1]};return b};
cc.ColorForBody=function(a){return a.isRogue()||a.isSleeping()?cc.color(128,128,128,128):a.nodeIdleTime>a.space.sleepTimeThreshold?cc.color(84,84,84,128):cc.color(255,0,0,128)};
cc.DrawShape=function(a,b){var c=a.body,d=cc.ColorForBody(c);switch(a.collisionCode){case cp.CircleShape.prototype.collisionCode:this.drawDot(a.tc,Math.max(a.r,1),d);this.drawSegment(a.tc,cp.v.add(a.tc,cp.v.mult(c.rot,a.r)),1,d);break;case cp.SegmentShape.prototype.collisionCode:this.drawSegment(a.ta,a.tb,Math.max(a.r,2),d);break;case cp.PolyShape.prototype.collisionCode:c=cc.color(d.r,d.g,d.b,cc.lerp(d.a,255,0.5));this.drawPoly(cc.__convertVerts(a.tVerts),d,1,c);break;default:cc.log("cc.DrawShape(): Bad assertion in DrawShape()")}};
cc.DrawConstraint=function(a,b){var c,d;d=a.a;var e=a.b;a instanceof cp.PinJoint?(c=d.local2World(a.anchr1),d=e.local2World(a.anchr2),this.drawDot(c,3,cc.CONSTRAINT_COLOR),this.drawDot(d,3,cc.CONSTRAINT_COLOR),this.drawSegment(c,d,1,cc.CONSTRAINT_COLOR)):a instanceof cp.SlideJoint?(c=d.local2World(a.anchr1),d=e.local2World(a.anchr2),this.drawDot(c,3,cc.CONSTRAINT_COLOR),this.drawDot(d,3,cc.CONSTRAINT_COLOR),this.drawSegment(c,d,1,cc.CONSTRAINT_COLOR)):a instanceof cp.PivotJoint?(c=d.local2World(a.anchr1),
d=e.local2World(a.anchr2),this.drawDot(c,3,cc.CONSTRAINT_COLOR),this.drawDot(d,3,cc.CONSTRAINT_COLOR)):a instanceof cp.GrooveJoint?(c=d.local2World(a.grv_a),d=d.local2World(a.grv_b),e=e.local2World(a.anchr2),this.drawDot(e,3,cc.CONSTRAINT_COLOR),this.drawSegment(c,d,1,cc.CONSTRAINT_COLOR)):a instanceof cp.DampedSpring};cc.CONSTRAINT_COLOR=cc.color(0,255,0,128);
cc.PhysicsDebugNode=cc.DrawNode.extend({_space:null,_className:"PhysicsDebugNode",ctor:function(a){cc.DrawNode.prototype.ctor.call(this);this._space=a},getSpace:function(){return this._space},setSpace:function(a){this._space=a},draw:function(a){this._space&&(this._space.eachShape(cc.DrawShape.bind(this)),this._space.eachConstraint(cc.DrawConstraint.bind(this)),cc.DrawNode.prototype.draw.call(this),this.clear())},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new cc.PhysicsDebugNode.CanvasRenderCmd(this):
new cc.PhysicsDebugNode.WebGLRenderCmd(this)}});cc.PhysicsDebugNode.create=function(a){return new cc.PhysicsDebugNode(a)};
(function(){cc.PhysicsDebugNode.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._buffer=a._buffer;this._needDraw=!0};var a=cc.PhysicsDebugNode.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.PhysicsDebugNode.CanvasRenderCmd;a.rendering=function(a,c,d){var e=this._node;e._space&&(e._space.eachShape(cc.DrawShape.bind(e)),e._space.eachConstraint(cc.DrawConstraint.bind(e)),cc.DrawNode.CanvasRenderCmd.prototype.rendering.call(this,a,c,d),
e.clear())};a._drawDot=cc.DrawNode.CanvasRenderCmd.prototype._drawDot;a._drawSegment=cc.DrawNode.CanvasRenderCmd.prototype._drawSegment;a._drawPoly=cc.DrawNode.CanvasRenderCmd.prototype._drawPoly})();
!function(){cc.PhysicsDebugNode.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._needDraw=!0};cc.PhysicsDebugNode.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);cc.PhysicsDebugNode.WebGLRenderCmd.prototype.constructor=cc.PhysicsDebugNode.WebGLRenderCmd;cc.PhysicsDebugNode.WebGLRenderCmd.prototype.rendering=function(a){a=this._node;a._space&&(a._space.eachShape(cc.DrawShape.bind(a)),a._space.eachConstraint(cc.DrawConstraint.bind(a)),cc.glBlendFunc(a._blendFunc.src,
a._blendFunc.dst),this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),a._render(),a.clear())}}();
(function(){cc.PhysicsSprite.WebGLRenderCmd=function(a){cc.Sprite.WebGLRenderCmd.call(this,a);this._needDraw=!0};var a=cc.PhysicsSprite.WebGLRenderCmd.prototype=Object.create(cc.Sprite.WebGLRenderCmd.prototype);a.constructor=cc.PhysicsSprite.WebGLRenderCmd;a.rendering=function(a){var c=this._node;c._syncPosition();c._ignoreBodyRotation||c._syncRotation();this.transform(this.getParentRenderCmd());cc.Sprite.WebGLRenderCmd.prototype.rendering.call(this,a)};a.getNodeToParentTransform=function(){var a=
this._node,c=a._body,d=this._anchorPointInPoints,e=a._scaleX,f=a._scaleY,g=c.p.x,h=c.p.y;this._ignoreAnchorPointForPosition&&(g+=d.x,h+=d.y);var c=c.a,k=1,m=0;return c&&!a._ignoreBodyRotation&&(k=Math.cos(c),m=Math.sin(c)),cc._rectEqualToZero(d)||(g+=k*-d.x*e+-m*-d.y*f,h+=m*-d.x*e+k*-d.y*f),this._transform=cc.affineTransformMake(k*e,m*e,-m*f,k*f,g,h),this._transform};a.updateTransform=function(){this._dirty=this._node.isDirty();cc.Sprite.WebGLRenderCmd.prototype.updateTransform.call(this)}})();
var io="undefined"==typeof module?{}:module.exports;
!function(){if(function(a,c){a.version="0.9.16";a.protocol=1;a.transports=[];a.j=[];a.sockets={};a.connect=function(d,e){var f,g,h=a.util.parseUri(d);c&&c.location&&(h.protocol=h.protocol||c.location.protocol.slice(0,-1),h.host=h.host||(c.document?c.document.domain:c.location.hostname),h.port=h.port||c.location.port);f=a.util.uniqueUri(h);var k={host:h.host,secure:"https"==h.protocol,port:h.port||("https"==h.protocol?443:80),query:h.query||""};return a.util.merge(k,e),(k["force new connection"]||
!a.sockets[f])&&(g=new a.Socket(k)),!k["force new connection"]&&g&&(a.sockets[f]=g),g=g||a.sockets[f],g.of(1<h.path.length?h.path:"")}}("object"==typeof module?module.exports:this.io={},this),function(a,c){var d=a.util={},e=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,f="source protocol authority userInfo user password host port relative path directory file query anchor".split(" ");
d.parseUri=function(a){a=e.exec(a||"");for(var b={},c=14;c--;)b[f[c]]=a[c]||"";return b};d.uniqueUri=function(a){var b=a.protocol,d=a.host;a=a.port;return"document"in c?(d=d||document.domain,a=a||("https"==b&&"https:"!==document.location.protocol?443:document.location.port)):(d=d||"localhost",!a&&"https"==b&&(a=443)),(b||"http")+"://"+d+":"+(a||80)};d.query=function(a,b){var c=d.chunkQuery(a||""),e=[];d.merge(c,d.chunkQuery(b||""));for(var f in c)c.hasOwnProperty(f)&&e.push(f+"\x3d"+c[f]);return e.length?
"?"+e.join("\x26"):""};d.chunkQuery=function(a){for(var b={},c=a.split("\x26"),d=0,e=c.length;e>d;++d)a=c[d].split("\x3d"),a[0]&&(b[a[0]]=a[1]);return b};var g=!1;d.load=function(a){return"document"in c&&"complete"===document.readyState||g?a():void d.on(c,"load",a,!1)};d.on=function(a,b,c,d){a.attachEvent?a.attachEvent("on"+b,c):a.addEventListener&&a.addEventListener(b,c,d)};d.request=function(a){if(a&&"undefined"!=typeof XDomainRequest&&!d.ua.hasCORS)return new XDomainRequest;if("undefined"!=typeof XMLHttpRequest&&
(!a||d.ua.hasCORS))return new XMLHttpRequest;if(!a)try{return new (window[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(b){}return null};"undefined"!=typeof window&&d.load(function(){g=!0});d.defer=function(a){return d.ua.webkit&&"undefined"==typeof importScripts?void d.load(function(){setTimeout(a,100)}):a()};d.merge=function(a,b,c,e){var f;e=e||[];c="undefined"==typeof c?2:c;for(f in b)b.hasOwnProperty(f)&&0>d.indexOf(e,f)&&("object"==typeof a[f]&&c?d.merge(a[f],b[f],c-1,e):
(a[f]=b[f],e.push(b[f])));return a};d.mixin=function(a,b){d.merge(a.prototype,b.prototype)};d.inherit=function(a,b){function c(){}c.prototype=b.prototype;a.prototype=new c};d.isArray=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)};d.intersect=function(a,b){for(var c=[],e=a.length>b.length?a:b,f=a.length>b.length?b:a,g=0,s=f.length;s>g;g++)~d.indexOf(e,f[g])&&c.push(f[g]);return c};d.indexOf=function(a,b,c){var d=a.length;for(c=0>c?0>c+d?0:c+d:c||0;d>c&&a[c]!==
b;c++);return c>=d?-1:c};d.toArray=function(a){for(var b=[],c=0,d=a.length;d>c;c++)b.push(a[c]);return b};d.ua={};d.ua.hasCORS="undefined"!=typeof XMLHttpRequest&&function(){try{var a=new XMLHttpRequest}catch(b){return!1}return void 0!=a.withCredentials}();d.ua.webkit="undefined"!=typeof navigator&&/webkit/i.test(navigator.userAgent);d.ua.iDevice="undefined"!=typeof navigator&&/iPad|iPhone|iPod/i.test(navigator.userAgent)}("undefined"!=typeof io?io:module.exports,this),function(a,c){function d(){}
a.EventEmitter=d;d.prototype.on=function(a,b){return this.$events||(this.$events={}),this.$events[a]?c.util.isArray(this.$events[a])?this.$events[a].push(b):this.$events[a]=[this.$events[a],b]:this.$events[a]=b,this};d.prototype.addListener=d.prototype.on;d.prototype.once=function(a,b){function c(){d.removeListener(a,c);b.apply(this,arguments)}var d=this;return c.listener=b,this.on(a,c),this};d.prototype.removeListener=function(a,b){if(this.$events&&this.$events[a]){var d=this.$events[a];if(c.util.isArray(d)){for(var h=
-1,k=0,m=d.length;m>k;k++)if(d[k]===b||d[k].listener&&d[k].listener===b){h=k;break}if(0>h)return this;d.splice(h,1);d.length||delete this.$events[a]}else(d===b||d.listener&&d.listener===b)&&delete this.$events[a]}return this};d.prototype.removeAllListeners=function(a){return void 0===a?(this.$events={},this):(this.$events&&this.$events[a]&&(this.$events[a]=null),this)};d.prototype.listeners=function(a){return this.$events||(this.$events={}),this.$events[a]||(this.$events[a]=[]),c.util.isArray(this.$events[a])||
(this.$events[a]=[this.$events[a]]),this.$events[a]};d.prototype.emit=function(a){if(!this.$events)return!1;var b=this.$events[a];if(!b)return!1;var d=Array.prototype.slice.call(arguments,1);if("function"==typeof b)b.apply(this,d);else{if(!c.util.isArray(b))return!1;for(var b=b.slice(),h=0,k=b.length;k>h;h++)b[h].apply(this,d)}return!0}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,c){function d(a){return 10>a?"0"+a:a}function e(a){return k.lastIndex=
0,k.test(a)?'"'+a.replace(k,function(a){var b=p[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function f(a,b){var c,g,h,k,p,z=m,w=b[a];switch(w instanceof Date&&(w=isFinite(a.valueOf())?a.getUTCFullYear()+"-"+d(a.getUTCMonth()+1)+"-"+d(a.getUTCDate())+"T"+d(a.getUTCHours())+":"+d(a.getUTCMinutes())+":"+d(a.getUTCSeconds())+"Z":null),"function"==typeof r&&(w=r.call(b,a,w)),typeof w){case "string":return e(w);case "number":return isFinite(w)?String(w):
"null";case "boolean":case "null":return String(w);case "object":if(!w)return"null";if(m+=n,p=[],"[object Array]"===Object.prototype.toString.apply(w)){k=w.length;for(c=0;k>c;c+=1)p[c]=f(c,w)||"null";return h=0===p.length?"[]":m?"[\n"+m+p.join(",\n"+m)+"\n"+z+"]":"["+p.join(",")+"]",m=z,h}if(r&&"object"==typeof r){k=r.length;for(c=0;k>c;c+=1)"string"==typeof r[c]&&(g=r[c],h=f(g,w),h&&p.push(e(g)+(m?": ":":")+h))}else for(g in w)Object.prototype.hasOwnProperty.call(w,g)&&(h=f(g,w),h&&p.push(e(g)+(m?
": ":":")+h));return h=0===p.length?"{}":m?"{\n"+m+p.join(",\n"+m)+"\n"+z+"}":"{"+p.join(",")+"}",m=z,h}}if(c&&c.parse)return a.JSON={parse:c.parse,stringify:c.stringify};var g=a.JSON={},h=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,k=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,m,n,p={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},
r;g.stringify=function(a,b,c){var d;if(m="",n="","number"==typeof c)for(d=0;c>d;d+=1)n+=" ";else"string"==typeof c&&(n=c);if(r=b,!b||"function"==typeof b||"object"==typeof b&&"number"==typeof b.length)return f("",{"":a});throw Error("JSON.stringify");};g.parse=function(a,b){function c(a,d){var e,f,g=a[d];if(g&&"object"==typeof g)for(e in g)Object.prototype.hasOwnProperty.call(g,e)&&(f=c(g,e),void 0!==f?g[e]=f:delete g[e]);return b.call(a,d,g)}var d;if(a=String(a),h.lastIndex=0,h.test(a)&&(a=a.replace(h,
function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return d=eval("("+a+")"),"function"==typeof b?c({"":d},""):d;throw new SyntaxError("JSON.parse");}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof JSON?JSON:void 0),function(a,c){var d=a.parser={},e=d.packets="disconnect connect heartbeat message json event ack error noop".split(" "),
f=d.reasons=["transport not supported","client not handshaken","unauthorized"],g=d.advice=["reconnect"],h=c.JSON,k=c.util.indexOf;d.encodePacket=function(a){var b=k(e,a.type),c=a.id||"",d=a.endpoint||"",m=a.ack,u=null;switch(a.type){case "error":var t=a.reason?k(f,a.reason):"";a=a.advice?k(g,a.advice):"";(""!==t||""!==a)&&(u=t+(""!==a?"+"+a:""));break;case "message":""!==a.data&&(u=a.data);break;case "event":u={name:a.name};a.args&&a.args.length&&(u.args=a.args);u=h.stringify(u);break;case "json":u=
h.stringify(a.data);break;case "connect":a.qs&&(u=a.qs);break;case "ack":u=a.ackId+(a.args&&a.args.length?"+"+h.stringify(a.args):"")}b=[b,c+("data"==m?"+":""),d];return null!==u&&void 0!==u&&b.push(u),b.join(":")};d.encodePayload=function(a){var b="";if(1==a.length)return a[0];for(var c=0,d=a.length;d>c;c++)b+="\ufffd"+a[c].length+"\ufffd"+a[c];return b};var m=/([^:]+):([0-9]+)?(\+)?:([^:]+)?:?([\s\S]*)?/;d.decodePacket=function(a){var b=a.match(m);if(!b)return{};var c=b[2]||"";a=b[5]||"";var d=
{type:e[b[1]],endpoint:b[4]||""};switch(c&&(d.id=c,b[3]?d.ack="data":d.ack=!0),d.type){case "error":b=a.split("+");d.reason=f[b[0]]||"";d.advice=g[b[1]]||"";break;case "message":d.data=a||"";break;case "event":try{var k=h.parse(a);d.name=k.name;d.args=k.args}catch(u){}d.args=d.args||[];break;case "json":try{d.data=h.parse(a)}catch(t){}break;case "connect":d.qs=a||"";break;case "ack":if((b=a.match(/^([0-9]+)(\+)?(.*)/))&&(d.ackId=b[1],d.args=[],b[3]))try{d.args=b[3]?h.parse(b[3]):[]}catch(x){}}return d};
d.decodePayload=function(a){if("\ufffd"==a.charAt(0)){for(var b=[],c=1,e="";c<a.length;c++)"\ufffd"==a.charAt(c)?(b.push(d.decodePacket(a.substr(c+1).substr(0,e))),c+=Number(e)+1,e=""):e+=a.charAt(c);return b}return[d.decodePacket(a)]}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,c){function d(a,b){this.socket=a;this.sessid=b}a.Transport=d;c.util.mixin(d,c.EventEmitter);d.prototype.heartbeats=function(){return!0};d.prototype.onData=function(a){if(this.clearCloseTimeout(),
(this.socket.connected||this.socket.connecting||this.socket.reconnecting)&&this.setCloseTimeout(),""!==a)if((a=c.parser.decodePayload(a))&&a.length)for(var b=0,d=a.length;d>b;b++)this.onPacket(a[b]);return this};d.prototype.onPacket=function(a){return this.socket.setHeartbeatTimeout(),"heartbeat"==a.type?this.onHeartbeat():("connect"==a.type&&""==a.endpoint&&this.onConnect(),"error"==a.type&&"reconnect"==a.advice&&(this.isOpen=!1),this.socket.onPacket(a),this)};d.prototype.setCloseTimeout=function(){if(!this.closeTimeout){var a=
this;this.closeTimeout=setTimeout(function(){a.onDisconnect()},this.socket.closeTimeout)}};d.prototype.onDisconnect=function(){return this.isOpen&&this.close(),this.clearTimeouts(),this.socket.onDisconnect(),this};d.prototype.onConnect=function(){return this.socket.onConnect(),this};d.prototype.clearCloseTimeout=function(){this.closeTimeout&&(clearTimeout(this.closeTimeout),this.closeTimeout=null)};d.prototype.clearTimeouts=function(){this.clearCloseTimeout();this.reopenTimeout&&clearTimeout(this.reopenTimeout)};
d.prototype.packet=function(a){this.send(c.parser.encodePacket(a))};d.prototype.onHeartbeat=function(a){this.packet({type:"heartbeat"})};d.prototype.onOpen=function(){this.isOpen=!0;this.clearCloseTimeout();this.socket.onOpen()};d.prototype.onClose=function(){this.isOpen=!1;this.socket.onClose();this.onDisconnect()};d.prototype.prepareUrl=function(){var a=this.socket.options;return this.scheme()+"://"+a.host+":"+a.port+"/"+a.resource+"/"+c.protocol+"/"+this.name+"/"+this.sessid};d.prototype.ready=
function(a,b){b.call(this)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,c,d){function e(a){if(this.options={port:80,secure:!1,document:"document"in d?document:!1,resource:"socket.io",transports:c.transports,"connect timeout":1E4,"try multiple transports":!0,reconnect:!0,"reconnection delay":500,"reconnection limit":1/0,"reopen delay":3E3,"max reconnection attempts":10,"sync disconnect on unload":!1,"auto connect":!0,"flash policy port":10843,
manualFlush:!1},c.util.merge(this.options,a),this.connected=!1,this.open=!1,this.connecting=!1,this.reconnecting=!1,this.namespaces={},this.buffer=[],this.doBuffer=!1,this.options["sync disconnect on unload"]&&(!this.isXDomain()||c.util.ua.hasCORS)){var b=this;c.util.on(d,"beforeunload",function(){b.disconnectSync()},!1)}this.options["auto connect"]&&this.connect()}function f(){}a.Socket=e;c.util.mixin(e,c.EventEmitter);e.prototype.of=function(a){return this.namespaces[a]||(this.namespaces[a]=new c.SocketNamespace(this,
a),""!==a&&this.namespaces[a].packet({type:"connect"})),this.namespaces[a]};e.prototype.publish=function(){this.emit.apply(this,arguments);var a,b;for(b in this.namespaces)this.namespaces.hasOwnProperty(b)&&(a=this.of(b),a.$emit.apply(a,arguments))};e.prototype.handshake=function(a){function b(c){c instanceof Error?(d.connecting=!1,d.onError(c.message)):a.apply(null,c.split(":"))}var d=this,e=this.options,e=["http"+(e.secure?"s":"")+":/",e.host+":"+e.port,e.resource,c.protocol,c.util.query(this.options.query,
"t\x3d"+ +new Date)].join("/");if(this.isXDomain()&&!c.util.ua.hasCORS){var n=document.getElementsByTagName("script")[0],p=document.createElement("script");p.src=e+"\x26jsonp\x3d"+c.j.length;n.parentNode.insertBefore(p,n);c.j.push(function(a){b(a);p.parentNode.removeChild(p)})}else{var r=c.util.request();r.open("GET",e,!0);this.isXDomain()&&(r.withCredentials=!0);r.onreadystatechange=function(){4==r.readyState&&(r.onreadystatechange=f,200==r.status?b(r.responseText):403==r.status?d.onError(r.responseText):
(d.connecting=!1,!d.reconnecting&&d.onError(r.responseText)))};r.send(null)}};e.prototype.getTransport=function(a){for(var b=a||this.transports,d=0;a=b[d];d++)if(c.Transport[a]&&c.Transport[a].check(this)&&(!this.isXDomain()||c.Transport[a].xdomainCheck(this)))return new c.Transport[a](this,this.sessionid);return null};e.prototype.connect=function(a){if(this.connecting)return this;var b=this;return b.connecting=!0,this.handshake(function(d,e,f,p){function r(a){return b.transport&&b.transport.clearTimeouts(),
b.transport=b.getTransport(a),b.transport?void b.transport.ready(b,function(){b.connecting=!0;b.publish("connecting",b.transport.name);b.transport.open();b.options["connect timeout"]&&(b.connectTimeoutTimer=setTimeout(function(){if(!b.connected&&(b.connecting=!1,b.options["try multiple transports"])){for(var a=b.transports;0<a.length&&a.splice(0,1)[0]!=b.transport.name;);a.length?r(a):b.publish("connect_failed")}},b.options["connect timeout"]))}):b.publish("connect_failed")}b.sessionid=d;b.closeTimeout=
1E3*f;b.heartbeatTimeout=1E3*e;b.transports||(b.transports=b.origTransports=p?c.util.intersect(p.split(","),b.options.transports):b.options.transports);b.setHeartbeatTimeout();r(b.transports);b.once("connect",function(){clearTimeout(b.connectTimeoutTimer);a&&"function"==typeof a&&a()})}),this};e.prototype.setHeartbeatTimeout=function(){if(clearTimeout(this.heartbeatTimeoutTimer),!this.transport||this.transport.heartbeats()){var a=this;this.heartbeatTimeoutTimer=setTimeout(function(){a.transport.onClose()},
this.heartbeatTimeout)}};e.prototype.packet=function(a){return this.connected&&!this.doBuffer?this.transport.packet(a):this.buffer.push(a),this};e.prototype.setBuffer=function(a){this.doBuffer=a;!a&&this.connected&&this.buffer.length&&(this.options.manualFlush||this.flushBuffer())};e.prototype.flushBuffer=function(){this.transport.payload(this.buffer);this.buffer=[]};e.prototype.disconnect=function(){return(this.connected||this.connecting)&&(this.open&&this.of("").packet({type:"disconnect"}),this.onDisconnect("booted")),
this};e.prototype.disconnectSync=function(){var a=c.util.request(),b=["http"+(this.options.secure?"s":"")+":/",this.options.host+":"+this.options.port,this.options.resource,c.protocol,"",this.sessionid].join("/")+"/?disconnect\x3d1";a.open("GET",b,!1);a.send(null);this.onDisconnect("booted")};e.prototype.isXDomain=function(){var a=d.location.port||("https:"==d.location.protocol?443:80);return this.options.host!==d.location.hostname||this.options.port!=a};e.prototype.onConnect=function(){this.connected||
(this.connected=!0,this.connecting=!1,this.doBuffer||this.setBuffer(!1),this.emit("connect"))};e.prototype.onOpen=function(){this.open=!0};e.prototype.onClose=function(){this.open=!1;clearTimeout(this.heartbeatTimeoutTimer)};e.prototype.onPacket=function(a){this.of(a.endpoint).onPacket(a)};e.prototype.onError=function(a){a&&a.advice&&"reconnect"===a.advice&&(this.connected||this.connecting)&&(this.disconnect(),this.options.reconnect&&this.reconnect());this.publish("error",a&&a.reason?a.reason:a)};
e.prototype.onDisconnect=function(a){var b=this.connected,c=this.connecting;this.open=this.connecting=this.connected=!1;(b||c)&&(this.transport.close(),this.transport.clearTimeouts(),b&&(this.publish("disconnect",a),"booted"!=a&&this.options.reconnect&&!this.reconnecting&&this.reconnect()))};e.prototype.reconnect=function(){function a(){if(c.connected){for(var d in c.namespaces)c.namespaces.hasOwnProperty(d)&&""!==d&&c.namespaces[d].packet({type:"connect"});c.publish("reconnect",c.transport.name,
c.reconnectionAttempts)}clearTimeout(c.reconnectionTimer);c.removeListener("connect_failed",b);c.removeListener("connect",b);c.reconnecting=!1;delete c.reconnectionAttempts;delete c.reconnectionDelay;delete c.reconnectionTimer;delete c.redoTransports;c.options["try multiple transports"]=e}function b(){return c.reconnecting?c.connected?a():c.connecting&&c.reconnecting?c.reconnectionTimer=setTimeout(b,1E3):void(c.reconnectionAttempts++>=d?c.redoTransports?(c.publish("reconnect_failed"),a()):(c.on("connect_failed",
b),c.options["try multiple transports"]=!0,c.transports=c.origTransports,c.transport=c.getTransport(),c.redoTransports=!0,c.connect()):(c.reconnectionDelay<f&&(c.reconnectionDelay*=2),c.connect(),c.publish("reconnecting",c.reconnectionDelay,c.reconnectionAttempts),c.reconnectionTimer=setTimeout(b,c.reconnectionDelay))):void 0}this.reconnecting=!0;this.reconnectionAttempts=0;this.reconnectionDelay=this.options["reconnection delay"];var c=this,d=this.options["max reconnection attempts"],e=this.options["try multiple transports"],
f=this.options["reconnection limit"];this.options["try multiple transports"]=!1;this.reconnectionTimer=setTimeout(b,this.reconnectionDelay);this.on("connect",b)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports,this),function(a,c){function d(a,b){this.socket=a;this.name=b||"";this.flags={};this.json=new e(this,"json");this.ackPackets=0;this.acks={}}function e(a,b){this.namespace=a;this.name=b}a.SocketNamespace=d;c.util.mixin(d,c.EventEmitter);d.prototype.$emit=
c.EventEmitter.prototype.emit;d.prototype.of=function(){return this.socket.of.apply(this.socket,arguments)};d.prototype.packet=function(a){return a.endpoint=this.name,this.socket.packet(a),this.flags={},this};d.prototype.send=function(a,b){var c={type:this.flags.json?"json":"message",data:a};return"function"==typeof b&&(c.id=++this.ackPackets,c.ack=!0,this.acks[c.id]=b),this.packet(c)};d.prototype.emit=function(a){var b=Array.prototype.slice.call(arguments,1),c=b[b.length-1],d={type:"event",name:a};
return"function"==typeof c&&(d.id=++this.ackPackets,d.ack="data",this.acks[d.id]=c,b=b.slice(0,b.length-1)),d.args=b,this.packet(d)};d.prototype.disconnect=function(){return""===this.name?this.socket.disconnect():(this.packet({type:"disconnect"}),this.$emit("disconnect")),this};d.prototype.onPacket=function(a){function b(){d.packet({type:"ack",args:c.util.toArray(arguments),ackId:a.id})}var d=this;switch(a.type){case "connect":this.$emit("connect");break;case "disconnect":""===this.name?this.socket.onDisconnect(a.reason||
"booted"):this.$emit("disconnect",a.reason);break;case "message":case "json":var e=["message",a.data];"data"==a.ack?e.push(b):a.ack&&this.packet({type:"ack",ackId:a.id});this.$emit.apply(this,e);break;case "event":e=[a.name].concat(a.args);"data"==a.ack&&e.push(b);this.$emit.apply(this,e);break;case "ack":this.acks[a.ackId]&&(this.acks[a.ackId].apply(this,a.args),delete this.acks[a.ackId]);break;case "error":a.advice?this.socket.onError(a):"unauthorized"==a.reason?this.$emit("connect_failed",a.reason):
this.$emit("error",a.reason)}};e.prototype.send=function(){this.namespace.flags[this.name]=!0;this.namespace.send.apply(this.namespace,arguments)};e.prototype.emit=function(){this.namespace.flags[this.name]=!0;this.namespace.emit.apply(this.namespace,arguments)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,c,d){function e(a){c.Transport.apply(this,arguments)}a.websocket=e;c.util.inherit(e,c.Transport);e.prototype.name="websocket";e.prototype.open=
function(){var a,b=c.util.query(this.socket.options.query),e=this;return a||(a=d.MozWebSocket||d.WebSocket),this.websocket=new a(this.prepareUrl()+b),this.websocket.onopen=function(){e.onOpen();e.socket.setBuffer(!1)},this.websocket.onmessage=function(a){e.onData(a.data)},this.websocket.onclose=function(){e.onClose();e.socket.setBuffer(!0)},this.websocket.onerror=function(a){e.onError(a)},this};c.util.ua.iDevice?e.prototype.send=function(a){var b=this;return setTimeout(function(){b.websocket.send(a)},
0),this}:e.prototype.send=function(a){return this.websocket.send(a),this};e.prototype.payload=function(a){for(var b=0,c=a.length;c>b;b++)this.packet(a[b]);return this};e.prototype.close=function(){return this.websocket.close(),this};e.prototype.onError=function(a){this.socket.onError(a)};e.prototype.scheme=function(){return this.socket.options.secure?"wss":"ws"};e.check=function(){return"WebSocket"in d&&!("__addTask"in WebSocket)||"MozWebSocket"in d};e.xdomainCheck=function(){return!0};c.transports.push("websocket")}("undefined"!=
typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports,this),function(b,c){function d(){c.Transport.websocket.apply(this,arguments)}b.flashsocket=d;c.util.inherit(d,c.Transport.websocket);d.prototype.name="flashsocket";d.prototype.open=function(){var a=this,b=arguments;return WebSocket.__addTask(function(){c.Transport.websocket.prototype.open.apply(a,b)}),this};d.prototype.send=function(){var a=this,b=arguments;return WebSocket.__addTask(function(){c.Transport.websocket.prototype.send.apply(a,
b)}),this};d.prototype.close=function(){return WebSocket.__tasks.length=0,c.Transport.websocket.prototype.close.call(this),this};d.prototype.ready=function(a,b){function g(){var c=a.options,g=c["flash policy port"],n=["http"+(c.secure?"s":"")+":/",c.host+":"+c.port,c.resource,"static/flashsocket","WebSocketMain"+(a.isXDomain()?"Insecure":"")+".swf"];d.loaded||("undefined"==typeof WEB_SOCKET_SWF_LOCATION&&(WEB_SOCKET_SWF_LOCATION=n.join("/")),843!==g&&WebSocket.loadFlashPolicyFile("xmlsocket://"+c.host+
":"+g),WebSocket.__initialize(),d.loaded=!0);b.call(h)}var h=this;return document.body?g():void c.util.load(g)};d.check=function(){return"undefined"!=typeof WebSocket&&"__initialize"in WebSocket&&a?10<=a.getFlashPlayerVersion().major:!1};d.xdomainCheck=function(){return!0};"undefined"!=typeof window&&(WEB_SOCKET_DISABLE_AUTO_INITIALIZATION=!0);c.transports.push("flashsocket")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),"undefined"!=typeof window)var a=
function(){function b(){if(!T){try{var a=H.getElementsByTagName("body")[0].appendChild(H.createElement("span"));a.parentNode.removeChild(a)}catch(b){return}T=!0;for(var a=W.length,c=0;a>c;c++)W[c]()}}function c(a){T?a():W[W.length]=a}function d(a){if(typeof y.addEventListener!=J)y.addEventListener("load",a,!1);else if(typeof H.addEventListener!=J)H.addEventListener("load",a,!1);else if(typeof y.attachEvent!=J)v(y,"onload",a);else if("function"==typeof y.onload){var b=y.onload;y.onload=function(){b();
a()}}else y.onload=a}function e(){var a=H.getElementsByTagName("body")[0],b=H.createElement(O);b.setAttribute("type",L);var c=a.appendChild(b);if(c){var d=0;!function(){if(typeof c.GetVariable!=J){var e=c.GetVariable("$version");e&&(e=e.split(" ")[1].split(","),M.pv=[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10)])}else if(10>d)return d++,void setTimeout(arguments.callee,10);a.removeChild(b);c=null;f()}()}else f()}function f(){var a=U.length;if(0<a)for(var b=0;a>b;b++){var c=U[b].id,d=U[b].callbackFn,
e={success:!1,id:c};if(0<M.pv[0]){var f=s(c);if(f)if(!u(U[b].swfVersion)||M.wk&&312>M.wk)if(U[b].expressInstall&&h()){e={};e.data=U[b].expressInstall;e.width=f.getAttribute("width")||"0";e.height=f.getAttribute("height")||"0";f.getAttribute("class")&&(e.styleclass=f.getAttribute("class"));f.getAttribute("align")&&(e.align=f.getAttribute("align"));for(var n={},f=f.getElementsByTagName("param"),C=f.length,P=0;C>P;P++)"movie"!=f[P].getAttribute("name").toLowerCase()&&(n[f[P].getAttribute("name")]=f[P].getAttribute("value"));
k(e,n,c,d)}else m(f),d&&d(e);else x(c,!0),d&&(e.success=!0,e.ref=g(c),d(e))}else if(x(c,!0),d)(c=g(c))&&typeof c.SetVariable!=J&&(e.success=!0,e.ref=c),d(e)}}function g(a){var b=null;if((a=s(a))&&"OBJECT"==a.nodeName)typeof a.SetVariable!=J?b=a:(a=a.getElementsByTagName(O)[0])&&(b=a);return b}function h(){return!P&&u("6.0.65")&&(M.win||M.mac)&&!(M.wk&&312>M.wk)}function k(a,b,c,d){P=!0;w=d||null;B={success:!1,id:c};var e=s(c);if(e){"OBJECT"==e.nodeName?(F=n(e),z=null):(F=e,z=c);a.id=D;(typeof a.width==
J||!/%$/.test(a.width)&&310>parseInt(a.width,10))&&(a.width="310");(typeof a.height==J||!/%$/.test(a.height)&&137>parseInt(a.height,10))&&(a.height="137");H.title=H.title.slice(0,47)+" - Flash Player Installation";d=M.ie&&M.win?["Active"].concat("").join("X"):"PlugIn";d="MMredirectURL\x3d"+y.location.toString().replace(/&/g,"%26")+"\x26MMplayerType\x3d"+d+"\x26MMdoctitle\x3d"+H.title;if(typeof b.flashvars!=J?b.flashvars+="\x26"+d:b.flashvars=d,M.ie&&M.win&&4!=e.readyState)d=H.createElement("div"),
c+="SWFObjectNew",d.setAttribute("id",c),e.parentNode.insertBefore(d,e),e.style.display="none",function(){4==e.readyState?e.parentNode.removeChild(e):setTimeout(arguments.callee,10)}();p(a,b,c)}}function m(a){if(M.ie&&M.win&&4!=a.readyState){var b=H.createElement("div");a.parentNode.insertBefore(b,a);b.parentNode.replaceChild(n(a),b);a.style.display="none";(function(){4==a.readyState?a.parentNode.removeChild(a):setTimeout(arguments.callee,10)})()}else a.parentNode.replaceChild(n(a),a)}function n(a){var b=
H.createElement("div");if(M.win&&M.ie)b.innerHTML=a.innerHTML;else if(a=a.getElementsByTagName(O)[0])if(a=a.childNodes)for(var c=a.length,d=0;c>d;d++)(1!=a[d].nodeType||"PARAM"!=a[d].nodeName)&&8!=a[d].nodeType&&b.appendChild(a[d].cloneNode(!0));return b}function p(a,b,c){var d,e=s(c);if(M.wk&&312>M.wk)return d;if(e)if(typeof a.id==J&&(a.id=c),M.ie&&M.win){var f="",g;for(g in a)a[g]!=Object.prototype[g]&&("data"==g.toLowerCase()?b.movie=a[g]:"styleclass"==g.toLowerCase()?f+=' class\x3d"'+a[g]+'"':
"classid"!=g.toLowerCase()&&(f+=" "+g+'\x3d"'+a[g]+'"'));g="";for(var h in b)b[h]!=Object.prototype[h]&&(g+='\x3cparam name\x3d"'+h+'" value\x3d"'+b[h]+'" /\x3e');e.outerHTML='\x3cobject classid\x3d"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+f+"\x3e"+g+"\x3c/object\x3e";C[C.length]=a.id;d=s(a.id)}else{h=H.createElement(O);h.setAttribute("type",L);for(var k in a)a[k]!=Object.prototype[k]&&("styleclass"==k.toLowerCase()?h.setAttribute("class",a[k]):"classid"!=k.toLowerCase()&&h.setAttribute(k,a[k]));
for(f in b)b[f]!=Object.prototype[f]&&"movie"!=f.toLowerCase()&&(a=h,g=f,k=b[f],c=H.createElement("param"),c.setAttribute("name",g),c.setAttribute("value",k),a.appendChild(c));e.parentNode.replaceChild(h,e);d=h}return d}function r(a){var b=s(a);b&&"OBJECT"==b.nodeName&&(M.ie&&M.win?(b.style.display="none",function(){if(4==b.readyState){var c=s(a);if(c){for(var d in c)"function"==typeof c[d]&&(c[d]=null);c.parentNode.removeChild(c)}}else setTimeout(arguments.callee,10)}()):b.parentNode.removeChild(b))}
function s(a){var b=null;try{b=H.getElementById(a)}catch(c){}return b}function v(a,b,c){a.attachEvent(b,c);G[G.length]=[a,b,c]}function u(a){var b=M.pv;a=a.split(".");return a[0]=parseInt(a[0],10),a[1]=parseInt(a[1],10)||0,a[2]=parseInt(a[2],10)||0,b[0]>a[0]||b[0]==a[0]&&b[1]>a[1]||b[0]==a[0]&&b[1]==a[1]&&b[2]>=a[2]?!0:!1}function t(a,b,c,d){if(!M.ie||!M.mac){var e=H.getElementsByTagName("head")[0];if(e){c=c&&"string"==typeof c?c:"screen";if(d&&(E=null,I=null),!E||I!=c)d=H.createElement("style"),
d.setAttribute("type","text/css"),d.setAttribute("media",c),E=e.appendChild(d),M.ie&&M.win&&typeof H.styleSheets!=J&&0<H.styleSheets.length&&(E=H.styleSheets[H.styleSheets.length-1]),I=c;M.ie&&M.win?E&&typeof E.addRule==O&&E.addRule(a,b):E&&typeof H.createTextNode!=J&&E.appendChild(H.createTextNode(a+" {"+b+"}"))}}}function x(a,b){if(R){var c=b?"visible":"hidden";T&&s(a)?s(a).style.visibility=c:t("#"+a,"visibility:"+c)}}function A(a){return null!=/[\\\"<>\.;]/.exec(a)&&typeof encodeURIComponent!=
J?encodeURIComponent(a):a}var F,z,w,B,E,I,J="undefined",O="object",L="application/x-shockwave-flash",D="SWFObjectExprInst",y=window,H=document,K=navigator,N=!1,W=[function(){N?e():f()}],U=[],C=[],G=[],T=!1,P=!1,R=!0,M=function(){var a=typeof H.getElementById!=J&&typeof H.getElementsByTagName!=J&&typeof H.createElement!=J,b=K.userAgent.toLowerCase(),c=K.platform.toLowerCase(),d=/win/.test(c?c:b),c=/mac/.test(c?c:b),b=/webkit/.test(b)?parseFloat(b.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):!1,e=!1,
f=[0,0,0],g=null;if(typeof K.plugins!=J&&typeof K.plugins["Shockwave Flash"]==O)(g=K.plugins["Shockwave Flash"].description)&&(typeof K.mimeTypes==J||!K.mimeTypes[L]||K.mimeTypes[L].enabledPlugin)&&(N=!0,e=!1,g=g.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),f[0]=parseInt(g.replace(/^(.*)\..*$/,"$1"),10),f[1]=parseInt(g.replace(/^.*\.(.*)\s.*$/,"$1"),10),f[2]=/[a-zA-Z]/.test(g)?parseInt(g.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0);else if(typeof y[["Active"].concat("Object").join("X")]!=J)try{var h=new (window[["Active"].concat("Object").join("X")])("ShockwaveFlash.ShockwaveFlash");
h&&(g=h.GetVariable("$version"),g&&(e=!0,g=g.split(" ")[1].split(","),f=[parseInt(g[0],10),parseInt(g[1],10),parseInt(g[2],10)]))}catch(k){}return{w3:a,pv:f,wk:b,ie:e,win:d,mac:c}}();!function(){M.w3&&((typeof H.readyState!=J&&"complete"==H.readyState||typeof H.readyState==J&&(H.getElementsByTagName("body")[0]||H.body))&&b(),T||(typeof H.addEventListener!=J&&H.addEventListener("DOMContentLoaded",b,!1),M.ie&&M.win&&(H.attachEvent("onreadystatechange",function(){"complete"==H.readyState&&(H.detachEvent("onreadystatechange",
arguments.callee),b())}),y==top&&function(){if(!T){try{H.documentElement.doScroll("left")}catch(a){return void setTimeout(arguments.callee,0)}b()}}()),M.wk&&function(){return T?void 0:/loaded|complete/.test(H.readyState)?void b():void setTimeout(arguments.callee,0)}(),d(b)))}();(function(){M.ie&&M.win&&window.attachEvent("onunload",function(){for(var b=G.length,c=0;b>c;c++)G[c][0].detachEvent(G[c][1],G[c][2]);b=C.length;for(c=0;b>c;c++)r(C[c]);for(var d in M)M[d]=null;M=null;for(var e in a)a[e]=null;
a=null})})();return{registerObject:function(a,b,c,d){if(M.w3&&a&&b){var e={};e.id=a;e.swfVersion=b;e.expressInstall=c;e.callbackFn=d;U[U.length]=e;x(a,!1)}else d&&d({success:!1,id:a})},getObjectById:function(a){return M.w3?g(a):void 0},embedSWF:function(a,b,d,e,f,g,m,n,C,P){var D={success:!1,id:b};M.w3&&!(M.wk&&312>M.wk)&&a&&b&&d&&e&&f?(x(b,!1),c(function(){d+="";e+="";var c={};if(C&&typeof C===O)for(var G in C)c[G]=C[G];c.data=a;c.width=d;c.height=e;G={};if(n&&typeof n===O)for(var M in n)G[M]=n[M];
if(m&&typeof m===O)for(var y in m)typeof G.flashvars!=J?G.flashvars+="\x26"+y+"\x3d"+m[y]:G.flashvars=y+"\x3d"+m[y];if(u(f))M=p(c,G,b),c.id==b&&x(b,!0),D.success=!0,D.ref=M;else{if(g&&h())return c.data=g,void k(c,G,b,P);x(b,!0)}P&&P(D)})):P&&P(D)},switchOffAutoHideShow:function(){R=!1},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:u,createSWF:function(a,b,c){return M.w3?p(a,b,c):void 0},showExpressInstall:function(a,b,c,d){M.w3&&h()&&
k(a,b,c,d)},removeSWF:function(a){M.w3&&r(a)},createCSS:function(a,b,c,d){M.w3&&t(a,b,c,d)},addDomLoadEvent:c,addLoadEvent:d,getQueryParamValue:function(a){var b=H.location.search||H.location.hash;if(b){if(/\?/.test(b)&&(b=b.split("?")[1]),null==a)return A(b);for(var b=b.split("\x26"),c=0;c<b.length;c++)if(b[c].substring(0,b[c].indexOf("\x3d"))==a)return A(b[c].substring(b[c].indexOf("\x3d")+1))}return""},expressInstallCallback:function(){if(P){var a=s(D);a&&F&&(a.parentNode.replaceChild(F,a),z&&
(x(z,!0),M.ie&&M.win&&(F.style.display="block")),w&&w(B));P=!1}}}}();!function(){if("undefined"!=typeof window&&!window.WebSocket){var b=window.console;return b&&b.log&&b.error||(b={log:function(){},error:function(){}}),a.hasFlashPlayerVersion("10.0.0")?("file:"==location.protocol&&b.error("WARNING: web-socket-js doesn't work in file:///... URL unless you set Flash Security Settings properly. Open the page via Web server i.e. http://..."),WebSocket=function(a,b,e,f,g){var h=this;h.__id=WebSocket.__nextId++;
WebSocket.__instances[h.__id]=h;h.readyState=WebSocket.CONNECTING;h.bufferedAmount=0;h.__events={};b?"string"==typeof b&&(b=[b]):b=[];setTimeout(function(){WebSocket.__addTask(function(){WebSocket.__flash.create(h.__id,a,b,e||null,f||0,g||null)})},0)},WebSocket.prototype.send=function(a){if(this.readyState==WebSocket.CONNECTING)throw"INVALID_STATE_ERR: Web Socket connection has not been established";a=WebSocket.__flash.send(this.__id,encodeURIComponent(a));return 0>a?!0:(this.bufferedAmount+=a,!1)},
WebSocket.prototype.close=function(){this.readyState!=WebSocket.CLOSED&&this.readyState!=WebSocket.CLOSING&&(this.readyState=WebSocket.CLOSING,WebSocket.__flash.close(this.__id))},WebSocket.prototype.addEventListener=function(a,b,e){a in this.__events||(this.__events[a]=[]);this.__events[a].push(b)},WebSocket.prototype.removeEventListener=function(a,b,e){if(a in this.__events){a=this.__events[a];for(e=a.length-1;0<=e;--e)if(a[e]===b){a.splice(e,1);break}}},WebSocket.prototype.dispatchEvent=function(a){for(var b=
this.__events[a.type]||[],e=0;e<b.length;++e)b[e](a);(b=this["on"+a.type])&&b(a)},WebSocket.prototype.__handleEvent=function(a){"readyState"in a&&(this.readyState=a.readyState);"protocol"in a&&(this.protocol=a.protocol);if("open"==a.type||"error"==a.type)a=this.__createSimpleEvent(a.type);else if("close"==a.type)a=this.__createSimpleEvent("close");else{if("message"!=a.type)throw"unknown event type: "+a.type;a=decodeURIComponent(a.message);a=this.__createMessageEvent("message",a)}this.dispatchEvent(a)},
WebSocket.prototype.__createSimpleEvent=function(a){if(document.createEvent&&window.Event){var b=document.createEvent("Event");return b.initEvent(a,!1,!1),b}return{type:a,bubbles:!1,cancelable:!1}},WebSocket.prototype.__createMessageEvent=function(a,b){if(document.createEvent&&window.MessageEvent&&!window.opera){var e=document.createEvent("MessageEvent");return e.initMessageEvent("message",!1,!1,b,null,null,window,null),e}return{type:a,data:b,bubbles:!1,cancelable:!1}},WebSocket.CONNECTING=0,WebSocket.OPEN=
1,WebSocket.CLOSING=2,WebSocket.CLOSED=3,WebSocket.__flash=null,WebSocket.__instances={},WebSocket.__tasks=[],WebSocket.__nextId=0,WebSocket.loadFlashPolicyFile=function(a){WebSocket.__addTask(function(){WebSocket.__flash.loadManualPolicyFile(a)})},WebSocket.__initialize=function(){if(!WebSocket.__flash){if(WebSocket.__swfLocation&&(window.WEB_SOCKET_SWF_LOCATION=WebSocket.__swfLocation),!window.WEB_SOCKET_SWF_LOCATION)return void b.error("[WebSocket] set WEB_SOCKET_SWF_LOCATION to location of WebSocketMain.swf");
var c=document.createElement("div");c.id="webSocketContainer";c.style.position="absolute";WebSocket.__isFlashLite()?(c.style.left="0px",c.style.top="0px"):(c.style.left="-100px",c.style.top="-100px");var d=document.createElement("div");d.id="webSocketFlash";c.appendChild(d);document.body.appendChild(c);a.embedSWF(WEB_SOCKET_SWF_LOCATION,"webSocketFlash","1","1","10.0.0",null,null,{hasPriority:!0,swliveconnect:!0,allowScriptAccess:"always"},null,function(a){a.success||b.error("[WebSocket] swfobject.embedSWF failed")})}},
WebSocket.__onFlashInitialized=function(){setTimeout(function(){WebSocket.__flash=document.getElementById("webSocketFlash");WebSocket.__flash.setCallerUrl(location.href);WebSocket.__flash.setDebug(!!window.WEB_SOCKET_DEBUG);for(var a=0;a<WebSocket.__tasks.length;++a)WebSocket.__tasks[a]();WebSocket.__tasks=[]},0)},WebSocket.__onFlashEvent=function(){return setTimeout(function(){try{for(var a=WebSocket.__flash.receiveEvents(),d=0;d<a.length;++d)WebSocket.__instances[a[d].webSocketId].__handleEvent(a[d])}catch(e){b.error(e)}},
0),!0},WebSocket.__log=function(a){b.log(decodeURIComponent(a))},WebSocket.__error=function(a){b.error(decodeURIComponent(a))},WebSocket.__addTask=function(a){WebSocket.__flash?a():WebSocket.__tasks.push(a)},WebSocket.__isFlashLite=function(){if(!window.navigator||!window.navigator.mimeTypes)return!1;var a=window.navigator.mimeTypes["application/x-shockwave-flash"];return a&&a.enabledPlugin&&a.enabledPlugin.filename&&a.enabledPlugin.filename.match(/flashlite/i)?!0:!1},window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION||
(window.addEventListener?window.addEventListener("load",function(){WebSocket.__initialize()},!1):window.attachEvent("onload",function(){WebSocket.__initialize()})),void 0):void b.error("Flash Player \x3e\x3d 10.0.0 is required.")}}();(function(a,c,d){function e(a){a&&(c.Transport.apply(this,arguments),this.sendBuffer=[])}function f(){}a.XHR=e;c.util.inherit(e,c.Transport);e.prototype.open=function(){return this.socket.setBuffer(!1),this.onOpen(),this.get(),this.setCloseTimeout(),this};e.prototype.payload=
function(a){for(var b=[],d=0,e=a.length;e>d;d++)b.push(c.parser.encodePacket(a[d]));this.send(c.parser.encodePayload(b))};e.prototype.send=function(a){return this.post(a),this};e.prototype.post=function(a){function b(){4==this.readyState&&(this.onreadystatechange=f,e.posting=!1,200==this.status?e.socket.setBuffer(!1):e.onClose())}function c(){this.onload=f;e.socket.setBuffer(!1)}var e=this;this.socket.setBuffer(!0);this.sendXHR=this.request("POST");d.XDomainRequest&&this.sendXHR instanceof XDomainRequest?
this.sendXHR.onload=this.sendXHR.onerror=c:this.sendXHR.onreadystatechange=b;this.sendXHR.send(a)};e.prototype.close=function(){return this.onClose(),this};e.prototype.request=function(a){var b=c.util.request(this.socket.isXDomain()),d=c.util.query(this.socket.options.query,"t\x3d"+ +new Date);if(b.open(a||"GET",this.prepareUrl()+d,!0),"POST"==a)try{b.setRequestHeader?b.setRequestHeader("Content-type","text/plain;charset\x3dUTF-8"):b.contentType="text/plain"}catch(e){}return b};e.prototype.scheme=
function(){return this.socket.options.secure?"https":"http"};e.check=function(a,b){try{var e=c.util.request(b),f=d.XDomainRequest&&e instanceof XDomainRequest,n=a&&a.options&&a.options.secure?"https:":"http:",p=d.location&&n!=d.location.protocol;if(e&&(!f||!p))return!0}catch(r){}return!1};e.xdomainCheck=function(a){return e.check(a,!0)}})("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports,this);(function(a,c){function d(a){c.Transport.XHR.apply(this,
arguments)}a.htmlfile=d;c.util.inherit(d,c.Transport.XHR);d.prototype.name="htmlfile";d.prototype.get=function(){this.doc=new (window[["Active"].concat("Object").join("X")])("htmlfile");this.doc.open();this.doc.write("\x3chtml\x3e\x3c/html\x3e");this.doc.close();this.doc.parentWindow.s=this;var a=this.doc.createElement("div");a.className="socketio";this.doc.body.appendChild(a);this.iframe=this.doc.createElement("iframe");a.appendChild(this.iframe);var b=this,a=c.util.query(this.socket.options.query,
"t\x3d"+ +new Date);this.iframe.src=this.prepareUrl()+a;c.util.on(window,"unload",function(){b.destroy()})};d.prototype._=function(a,b){a=a.replace(/\\\//g,"/");this.onData(a);try{var c=b.getElementsByTagName("script")[0];c.parentNode.removeChild(c)}catch(d){}};d.prototype.destroy=function(){if(this.iframe){try{this.iframe.src="about:blank"}catch(a){}this.doc=null;this.iframe.parentNode.removeChild(this.iframe);this.iframe=null;CollectGarbage()}};d.prototype.close=function(){return this.destroy(),
c.Transport.XHR.prototype.close.call(this)};d.check=function(a){if("undefined"!=typeof window&&["Active"].concat("Object").join("X")in window)try{return new (window[["Active"].concat("Object").join("X")])("htmlfile")&&c.Transport.XHR.check(a)}catch(b){}return!1};d.xdomainCheck=function(){return!1};c.transports.push("htmlfile")})("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports);(function(a,c,d){function e(){c.Transport.XHR.apply(this,arguments)}function f(){}
a["xhr-polling"]=e;c.util.inherit(e,c.Transport.XHR);c.util.merge(e,c.Transport.XHR);e.prototype.name="xhr-polling";e.prototype.heartbeats=function(){return!1};e.prototype.open=function(){return c.Transport.XHR.prototype.open.call(this),!1};e.prototype.get=function(){function a(){4==this.readyState&&(this.onreadystatechange=f,200==this.status?(e.onData(this.responseText),e.get()):e.onClose())}function b(){this.onerror=this.onload=f;e.retryCounter=1;e.onData(this.responseText);e.get()}function c(){e.retryCounter++;
!e.retryCounter||3<e.retryCounter?e.onClose():e.get()}if(this.isOpen){var e=this;this.xhr=this.request();d.XDomainRequest&&this.xhr instanceof XDomainRequest?(this.xhr.onload=b,this.xhr.onerror=c):this.xhr.onreadystatechange=a;this.xhr.send(null)}};e.prototype.onClose=function(){if(c.Transport.XHR.prototype.onClose.call(this),this.xhr){this.xhr.onreadystatechange=this.xhr.onload=this.xhr.onerror=f;try{this.xhr.abort()}catch(a){}this.xhr=null}};e.prototype.ready=function(a,b){var d=this;c.util.defer(function(){b.call(d)})};
c.transports.push("xhr-polling")})("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports,this);(function(a,c,d){function e(a){c.Transport["xhr-polling"].apply(this,arguments);this.index=c.j.length;var b=this;c.j.push(function(a){b._(a)})}var f=d.document&&"MozAppearance"in d.document.documentElement.style;a["jsonp-polling"]=e;c.util.inherit(e,c.Transport["xhr-polling"]);e.prototype.name="jsonp-polling";e.prototype.post=function(a){function b(){d();e.socket.setBuffer(!1)}
function d(){e.iframe&&e.form.removeChild(e.iframe);try{p=document.createElement('\x3ciframe name\x3d"'+e.iframeId+'"\x3e')}catch(a){p=document.createElement("iframe"),p.name=e.iframeId}p.id=e.iframeId;e.form.appendChild(p);e.iframe=p}var e=this,f=c.util.query(this.socket.options.query,"t\x3d"+ +new Date+"\x26i\x3d"+this.index);if(!this.form){var p,r=document.createElement("form"),s=document.createElement("textarea"),v=this.iframeId="socketio_iframe_"+this.index;r.className="socketio";r.style.position=
"absolute";r.style.top="0px";r.style.left="0px";r.style.display="none";r.target=v;r.method="POST";r.setAttribute("accept-charset","utf-8");s.name="d";r.appendChild(s);document.body.appendChild(r);this.form=r;this.area=s}this.form.action=this.prepareUrl()+f;d();this.area.value=c.JSON.stringify(a);try{this.form.submit()}catch(u){}this.iframe.attachEvent?p.onreadystatechange=function(){"complete"==e.iframe.readyState&&b()}:this.iframe.onload=b;this.socket.setBuffer(!0)};e.prototype.get=function(){var a=
this,b=document.createElement("script"),d=c.util.query(this.socket.options.query,"t\x3d"+ +new Date+"\x26i\x3d"+this.index);this.script&&(this.script.parentNode.removeChild(this.script),this.script=null);b.async=!0;b.src=this.prepareUrl()+d;b.onerror=function(){a.onClose()};d=document.getElementsByTagName("script")[0];d.parentNode.insertBefore(b,d);this.script=b;f&&setTimeout(function(){var a=document.createElement("iframe");document.body.appendChild(a);document.body.removeChild(a)},100)};e.prototype._=
function(a){return this.onData(a),this.isOpen&&this.get(),this};e.prototype.ready=function(a,b){var d=this;return f?void c.util.load(function(){b.call(d)}):b.call(this)};e.check=function(){return"document"in d};e.xdomainCheck=function(){return!0};c.transports.push("jsonp-polling")})("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports,this);"function"==typeof define&&define.amd&&define([],function(){return io})}();var gaf=gaf||{};
gaf.COMPRESSION_NONE=4669766;gaf.COMPRESSION_ZIP=4669763;gaf.IDNONE=4294967295;gaf.FIRST_FRAME_INDEX=0;gaf.EFFECT_DROP_SHADOW=0;gaf.EFFECT_BLUR=1;gaf.EFFECT_GLOW=2;gaf.EFFECT_COLOR_MATRIX=6;gaf.ACTION_STOP=0;gaf.ACTION_PLAY=1;gaf.ACTION_GO_TO_AND_STOP=2;gaf.ACTION_GO_TO_AND_PLAY=3;gaf.ACTION_DISPATCH_EVENT=4;gaf.PI_FRAME=0;gaf.PI_EVENT_TYPE=0;gaf.TYPE_TEXTURE=0;gaf.TYPE_TEXT_FIELD=1;gaf.TYPE_TIME_LINE=2;gaf.UNIFORM_BLUR_TEXEL_OFFSET="u_step";gaf.UNIFORM_GLOW_TEXEL_OFFSET="u_step";
gaf.UNIFORM_GLOW_COLOR="u_glowColor";gaf.UNIFORM_ALPHA_TINT_MULT="colorTransformMult";gaf.UNIFORM_ALPHA_TINT_OFFSET="colorTransformOffsets";gaf.UNIFORM_ALPHA_COLOR_MATRIX_BODY="colorMatrix";gaf.UNIFORM_ALPHA_COLOR_MATRIX_APPENDIX="colorMatrix2";gaf=gaf||{};gaf._tmp=gaf._tmp||{};gaf._initialized=!1;gaf.CCGAFLoader=function(){this.load=function(a,b,c,d){gaf._initialized||gaf._setup();(new gaf.Loader).LoadFile(a,function(a){d(null,a)})}};gaf._setup=function(){gaf._setupShaders();gaf._initialized=!0};
cc.loader.register(".gaf",new gaf.CCGAFLoader);gaf.CGAffineTransformCocosFormatFromFlashFormat=function(a){var b={};return b.a=a.a,b.b=-a.b,b.c=-a.c,b.d=a.d,b.tx=a.tx,b.ty=-a.ty,b};
gaf._AssetPreload=function(){this[0]=this.End;this[1]=this.Atlases;this[2]=this.AnimationMasks;this[3]=this.AnimationObjects;this[4]=this.AnimationFrames;this[5]=this.NamedParts;this[6]=this.Sequences;this[7]=this.TextFields;this[8]=this.Atlases;this[9]=this.Stage;this[10]=this.AnimationObjects;this[11]=this.AnimationMasks;this[12]=this.AnimationFrames;this[13]=this.TimeLine};gaf._AssetPreload.prototype.End=function(a,b,c){c&&(c.getFps=function(){return a.getSceneFps()})};
gaf._AssetPreload.prototype.Tag=function(a,b,c){this[b.tagId].call(this,a,b.content,c)};gaf._AssetPreload.prototype.Tags=function(a,b,c){var d=this;b.forEach(function(b){d.Tag(a,b,c)})};gaf._AssetPreload.prototype.AtlasCreateFrames=function(a,b,c){a.forEach(function(a){var e=b._atlases[a.atlasId],f=cc.rect(a.origin.x,a.origin.y,a.size.x,a.size.y),e=new cc.SpriteFrame(e,f);e._gafAnchor={x:0-(0-a.pivot.x/a.size.x),y:0+(1-a.pivot.y/a.size.y)};c[a.elementAtlasId]=e})};
gaf._AssetPreload.prototype.Atlases=function(a,b,c){var d=a._atlasScales[b.scale]=a._atlasScales[b.scale]||[],e=cc.Director._getInstance().getContentScaleFactor();b.atlases.forEach(function(c){var g=c.id,h=function(){gaf._AssetPreload.AtlasCreateFrames(b.elements,a,d)},k="";c.sources.forEach(function(a){a.csf===e&&(k=a.source)});cc.assert(k,"GAF Error. Texture for current CSF not found. Reconvert animation with correct parameters.");a._textureLoadDelegate&&(k=a._textureLoadDelegate(k));var m=!1;c=
a._getSearchPaths(k);for(var n=0,p=c.length;p>n;++n){var r=cc.textureCache.getTextureForKey(c[n]);if(r&&r.isLoaded()){r.handleLoadedTexture(!0);m=!0;a._atlases[g]=r;h();break}}m||(m=function(b){b.handleLoadedTexture(!0);a._onAtlasLoaded(g,b)},n=function(){cc.log("GAF Error. Couldn't find `"+k+"` required by `"+a.getGAFFileName()+"`")},a._atlasesToLoad.hasOwnProperty(g)||(gaf._AtlasLoader.loadArray(c,m,n),a._atlasesToLoad[g]={}),a._onLoadTasks.push(h))})};
gaf._AssetPreload.prototype.AnimationObjects=function(a,b,c){b.forEach(function(b){b.type=void 0===b.type?gaf.TYPE_TEXTURE:b.type;c._objects.push(b.objectId);a._objects[b.objectId]=b})};gaf._AssetPreload.prototype.convertTint=function(a,b){return a?{mult:{r:255*a.redMultiplier,g:255*a.greenMultiplier,b:255*a.blueMultiplier,a:255*b},offset:{r:255*a.redOffset,g:255*a.greenOffset,b:255*a.blueOffset,a:255*a.alphaOffset}}:null};
gaf._AssetPreload.prototype.convertState=function(a){return{hasColorTransform:a.hasColorTransform,hasMask:a.hasMask,hasEffect:a.hasEffect,objectIdRef:a.objectIdRef,depth:a.depth,alpha:255*a.alpha,matrix:gaf.CGAffineTransformCocosFormatFromFlashFormat(a.matrix),colorTransform:this.convertTint(a.colorTransform,a.alpha),effect:a.effect,maskObjectIdRef:a.maskObjectIdRef}};
gaf._AssetPreload.prototype.AnimationFrames=function(a,b,c){var d=this;cc.assert(c,"Error. Time Line should not be null.");var e={},f=[];a=0;for(var g=b.length;g>a;++a){var h=b[a];h.state&&h.state.forEach(function(a){0!==a.alpha?e[a.objectIdRef]=d.convertState(a):e[a.objectIdRef]=null});var k=[],m;for(m in e)e.hasOwnProperty(m)&&e[m]&&k.push(e[m]);f[h.frame-1]={states:k,actions:h.actions||null}}c.getFrames=function(){return f}};
gaf._AssetPreload.prototype.NamedParts=function(a,b,c){var d={};b.forEach(function(a){d[a.name]=a.objectId});c.getNamedParts=function(){return d}};gaf._AssetPreload.prototype.Sequences=function(a,b,c){var d={};b.forEach(function(a){d[a.id]={start:a.start-1,end:a.end}});c.getSequences=function(){return d}};gaf._AssetPreload.prototype.TextFields=function(a,b,c){};gaf._AssetPreload.prototype.Stage=function(a,b,c){a._sceneFps=b.fps;a._sceneColor=b.color;a._sceneWidth=b.width;a._sceneHeight=b.height};
gaf._AssetPreload.prototype.AnimationMasks=function(a,b,c){b.forEach(function(b){b.type=void 0===b.type?gaf.TYPE_TEXTURE:b.type;c._objects.push(b.objectId);a._masks[b.objectId]=b})};gaf._AssetPreload.prototype.TimeLine=function(a,b,c){c=new gaf._TimeLineProto(a,b.animationFrameCount,b.boundingBox,b.pivotPoint,b.id,b.linkageName);a._pushTimeLine(c);this.Tags(a,b.tags,c)};gaf._AssetPreload=new gaf._AssetPreload;gaf=gaf||{};
gaf.Asset=cc.Class.extend({_className:"GAFAsset",_header:null,_timeLines:null,_textFields:null,_protos:null,_objects:null,_masks:null,_rootTimeLine:null,_textureLoadDelegate:null,_sceneFps:60,_sceneWidth:0,_sceneHeight:0,_sceneColor:0,_gafData:null,_desiredAtlasScale:1,_usedAtlasScale:0,_atlases:null,_onLoadTasks:null,_atlasScales:null,_textureLoaded:!1,_atlasesToLoad:null,_gafName:null,initWithGAFFile:function(a,b){var c=this;this._textureLoadDelegate=b;this._gafName=a;var d=cc.loader.getRes(a);
return d?this._init(d):(cc.loader.load(a,function(a,b){a||c._init(b[0])}),!1)},initWithGAFBundle:function(a,b,c){return cc.assert(!1,"initWithGAFBundle is not yet implemented"),!1},setRootTimelineWithName:function(a){for(var b=0,c=this._timeLines.length;c>b;++b){var d=this._timeLines[b];if(d&&d.getLinkageName()===a)return void this._setRootTimeline(d)}},isAssetVersionPlayable:function(){return!0},desiredAtlasScale:function(){return this._desiredAtlasScale},setDesiredAtlasScale:function(a){this._desiredAtlasScale=
a;for(var b in this._atlasScales)this._atlasScales.hasOwnProperty(b)&&(0===this._usedAtlasScale||Math.abs(this._usedAtlasScale-a)>Math.abs(b-a))&&(this._usedAtlasScale=b)},createObject:function(){return this._instantiateGaf(this._gafData)},createObjectAndRun:function(a){cc.assert(1===arguments.length,"GAFAsset::createObjectAndRun should have one param");var b=this._instantiateGaf(this._gafData);return b.setLooped(a,!0),b.start(),b},setTextureLoadDelegate:function(a){},getSceneFps:function(){return this._sceneFps},
getSceneWidth:function(){},getSceneHeight:function(){},getSceneColor:function(){},setSceneFps:function(a){this._sceneFps=a},setSceneWidth:function(a){},setSceneHeight:function(a){},setSceneColor:function(a){},getHeader:function(){return this._header},getGAFFileName:function(){return this._gafName},ctor:function(){this._header={};this._timeLines=[];this._textFields=[];this._objects=[];this._masks=[];this._protos=[];this._atlases={};this._onLoadTasks=[];this._atlasScales={};this._atlasesToLoad={};0<
arguments.length&&this.initWithGAFFile.apply(this,arguments)},_getProtos:function(){return this._protos},_setRootTimeline:function(a){this._rootTimeLine=a;this._header.pivot=a.getPivot();this._header.frameSize=a.getRect()},_setHeader:function(a){for(var b in a)a.hasOwnProperty(b)&&(this._header[b]=a[b])},_getMajorVerison:function(){return this._header.versionMajor},_init:function(a){var b=this;this._gafData=a;this._setHeader(a.header);this._timeLinesToLink=[];4>this._getMajorVerison()&&this._pushTimeLine(new gaf._TimeLineProto(this,
this._header.framesCount,this._header.frameSize,this._header.pivot));gaf._AssetPreload.Tags(this,a.tags,this._rootTimeLine);this._objects.forEach(function(a){switch(a.type){case gaf.TYPE_TEXTURE:b._protos[a.objectId]||(b._protos[a.objectId]=new gaf._SpriteProto(b,b._atlasScales,a.elementAtlasIdRef));break;case gaf.TYPE_TIME_LINE:b._protos[a.objectId]=b._timeLines[a.elementAtlasIdRef];break;case gaf.TYPE_TEXT_FIELD:b._protos[a.objectId]=b._textFields[a.elementAtlasIdRef];break;default:cc.log("Unknown object type: "+
a.type)}});this._masks.forEach(function(a){if(!b._protos[a.objectId]){var d=null;switch(a.type){case gaf.TYPE_TEXTURE:d=new gaf._SpriteProto(b,b._atlasScales,a.elementAtlasIdRef);break;case gaf.TYPE_TIME_LINE:d=b._timeLines[a.elementAtlasIdRef];break;case gaf.TYPE_TEXT_FIELD:d=b._textFields[a.elementAtlasIdRef]}b._protos[a.objectId]=new gaf._MaskProto(b,d,a.elementAtlasIdRef)}});this.setDesiredAtlasScale(this._desiredAtlasScale);0===Object.keys(this._atlasesToLoad).length&&(this._textureLoaded=!0,
this.dispatchEvent("load"))},_pushTimeLine:function(a){this._timeLines[a.getId()]=a;0===a.getId()&&this._setRootTimeline(a)},_instantiateGaf:function(){return this._rootTimeLine._gafConstruct()},_onAtlasLoaded:function(a,b){this._atlases[a]=b;delete this._atlasesToLoad[a];0===Object.keys(this._atlasesToLoad).length&&(this._onLoadTasks.forEach(function(a){a()}),this._onLoadTasks.length=0,this._textureLoaded=!0,this.dispatchEvent("load"))},isLoaded:function(){return this._textureLoaded},_getSearchPaths:function(a){var b=
this.getGAFFileName().split("/");b[b.length-1]=a;b=b.join("/");return[a,b]}});gaf.Asset.create=function(a,b){return new gaf.Asset(a,b)};gaf.Asset.createWithBundle=function(a,b,c){var d=new gaf.Asset;return d.initWithGAFBundle(a,b,c),d};cc.EventHelper.prototype.apply(gaf.Asset.prototype);gaf=gaf||{};
gaf._stateHasCtx=function(a){if(a.hasColorTransform&&(0<a.colorTransform.offset.r||0<a.colorTransform.offset.g||0<a.colorTransform.offset.b||0<a.colorTransform.offset.a))return!0;if(a.hasEffect)for(var b=0,c=a.effect.length;c>b;++b)if(a.effect[b].type===gaf.EFFECT_COLOR_MATRIX)return!0;return!1};
gaf.Object=cc.Node.extend({_asset:null,_className:"GAFObject",_id:gaf.IDNONE,_gafproto:null,_parentTimeLine:null,_lastVisibleInFrame:0,_filterStack:null,_cascadeColorMult:null,_cascadeColorOffset:null,_needsCtx:!1,_usedAtlasScale:1,ctor:function(a){1==arguments.length&&(this._usedAtlasScale=a);this._super();this._cascadeColorMult=cc.color(255,255,255,255);this._cascadeColorOffset=cc.color(0,0,0,0);this._filterStack=[]},setAnimationStartedNextLoopDelegate:function(a){},setAnimationFinishedPlayDelegate:function(a){},
setLooped:function(a){},getBoundingBoxForCurrentFrame:function(){return null},setFps:function(a){},getObjectByName:function(a){return null},clearSequence:function(){},getIsAnimationRunning:function(){return!1},getSequences:function(){return[]},gotoAndStop:function(a){},getStartFrame:function(a){return gaf.IDNONE},setFramePlayedDelegate:function(a){},getCurrentFrameIndex:function(){return gaf.IDNONE},getTotalFrameCount:function(){return 0},start:function(){},stop:function(){},isVisibleInCurrentFrame:function(){return!(this._parentTimeLine&&
this._parentTimeLine.getCurrentFrameIndex()+1!=this._lastVisibleInFrame)},isDone:function(){return!0},playSequence:function(a,b,c){return!1},isReversed:function(){return!1},setSequenceDelegate:function(a){},setFrame:function(a){return!1},setControlDelegate:function(a){},getEndFrame:function(a){return gaf.IDNONE},pauseAnimation:function(){},gotoAndPlay:function(a){},isLooped:function(){return!1},resumeAnimation:function(){},setReversed:function(a){},hasSequences:function(){return!1},getFps:function(){return 60},
setLocator:function(a){},setExternalTransform:function(a){cc.affineTransformEqualToTransform(this._additionalTransform,a)||this.setAdditionalTransform(a)},getExternalTransform:function(){return this._additionalTransform},setAnimationRunning:function(){},_enableTick:function(a){},_resetState:function(){},_updateVisibility:function(a,b){this.setOpacity(a.alpha+(a.hasColorTransform?a.colorTransform.offset.a:0))},isVisible:function(){return 0<this.getOpacity()},visit:function(a){this.isVisibleInCurrentFrame()&&
this._super(a)},_getFilters:function(){return null},_processAnimation:function(){},_applyState:function(a,b){this._applyStateSuper(a,b)},_applyStateSuper:function(a,b){if(this._needsCtx=b._needsCtx,this._filterStack.length=0,this._parentTimeLine=b,1!=this._usedAtlasScale){var c=cc.clone(a.matrix);c.tx*=this._usedAtlasScale;c.ty*=this._usedAtlasScale;this.setExternalTransform(c)}else this.setExternalTransform(a.matrix);a.hasEffect&&(this._filterStack=this._filterStack.concat(a.effect),this._needsCtx=
!0);b._filterStack&&0<b._filterStack.length&&(this._filterStack=this._filterStack.concat(b._filterStack));0<this._filterStack.length&&this._filterStack[0].type===gaf.EFFECT_COLOR_MATRIX&&(this._needsCtx=!0);a.hasColorTransform?(this._cascadeColorMult.r=a.colorTransform.mult.r*b._cascadeColorMult.r/255,this._cascadeColorMult.g=a.colorTransform.mult.g*b._cascadeColorMult.g/255,this._cascadeColorMult.b=a.colorTransform.mult.b*b._cascadeColorMult.b/255,this._cascadeColorMult.a=a.colorTransform.mult.a*
b._cascadeColorMult.a/255,this._cascadeColorOffset.r=a.colorTransform.offset.r+b._cascadeColorOffset.r,this._cascadeColorOffset.g=a.colorTransform.offset.g+b._cascadeColorOffset.g,this._cascadeColorOffset.b=a.colorTransform.offset.b+b._cascadeColorOffset.b,this._cascadeColorOffset.a=a.colorTransform.offset.a+b._cascadeColorOffset.a):(this._cascadeColorMult.r=b._cascadeColorMult.r,this._cascadeColorMult.g=b._cascadeColorMult.g,this._cascadeColorMult.b=b._cascadeColorMult.b,this._cascadeColorMult.a=
a.alpha*(b._cascadeColorMult.a/255),this._cascadeColorOffset.r=b._cascadeColorOffset.r,this._cascadeColorOffset.g=b._cascadeColorOffset.g,this._cascadeColorOffset.b=b._cascadeColorOffset.b,this._cascadeColorOffset.a=b._cascadeColorOffset.a);(0<this._cascadeColorOffset.r||0<this._cascadeColorOffset.g||0<this._cascadeColorOffset.b||0<this._cascadeColorOffset.a)&&(this._needsCtx=!0)},_initRendererCmd:function(){this._renderCmd=cc.renderer.getRenderCmd(this);this._renderCmd._visit=this._renderCmd.visit;
var a=this;this._renderCmd.visit=function(b){a.isVisibleInCurrentFrame()&&this._visit(b)}},_getNode:function(){return this},setAnchorPoint:function(a,b){void 0===b?this._super(a.x,a.y-1):this._super(a,b-1)}});gaf.Object._createNullObject=function(){var a=new gaf.Object;return a.isVisible=function(){return!0},a};
gaf.TimeLine=gaf.Object.extend({_className:"GAFTimeLine",_objects:null,_container:null,_animationStartedNextLoopDelegate:null,_animationFinishedPlayDelegate:null,_framePlayedDelegate:null,_sequenceDelegate:null,_fps:60,_frameTime:1/60,_currentSequenceStart:gaf.FIRST_FRAME_INDEX,_currentSequenceEnd:gaf.FIRST_FRAME_INDEX,_totalFrameCount:0,_isRunning:!1,_isLooped:!1,_isReversed:!1,_timeDelta:0,_animationsSelectorScheduled:!1,_currentFrame:gaf.FIRST_FRAME_INDEX,setAnimationStartedNextLoopDelegate:function(a){this._animationStartedNextLoopDelegate=
a},setAnimationFinishedPlayDelegate:function(a){this._animationFinishedPlayDelegate=a},setLooped:function(a,b){this._isLooped=a;b&&this._objects.forEach(function(c){c.setLooped(a,b)})},getBoundingBoxForCurrentFrame:function(){var a=null,b=!0;return this._objects.forEach(function(c){if(c.isVisibleInCurrentFrame()&&c.isVisible()){var d=c.getBoundingBoxForCurrentFrame();d||(d=c.getBoundingBox());b?(b=!1,a=d):a=cc.rectUnion(a,d)}}),cc._rectApplyAffineTransformIn(a,this._container.getNodeToParentTransform())},
setFps:function(a){cc.assert(0!==a,"Error! Fps is set to zero.");this._fps=a;this._frameTime=1/a},getObjectByName:function(a){var b=a.split("."),c=null,d=-1,e=this,f={};try{b.forEach(function(a){var b=e._gafproto.getNamedParts();if(!b.hasOwnProperty(a))throw f.lastElement=a,f;d=b[a];e=c=e._objects[d]})}catch(g){if(g!==f)throw g;return cc.log("Sequence incorrect: `"+a+"` At: `"+f.lastElement+"`"),null}return c},clearSequence:function(){this._currentSequenceStart=gaf.FIRST_FRAME_INDEX;this._currentSequenceEnd=
this._gafproto.getTotalFrames()},getIsAnimationRunning:function(){return this._isRunning},gotoAndStop:function(a){var b=0;return b="string"==typeof a?this.getStartFrame(a):a,this.setFrame(b)?(this.setAnimationRunning(!1,!1),!0):!1},gotoAndPlay:function(a){var b=0;return b="string"==typeof a?this.getStartFrame(a):a,this.setFrame(b)?(this.setAnimationRunning(!0,!1),!0):!1},getStartFrame:function(a){return(a=this._gafproto.getSequences()[a])?a.start:gaf.IDNONE},getEndFrame:function(a){return(a=this._gafproto.getSequences()[a])?
a.end:gaf.IDNONE},setFramePlayedDelegate:function(a){this._framePlayedDelegate=a},getCurrentFrameIndex:function(){return this._showingFrame},getTotalFrameCount:function(){return this._gafproto.getTotalFrames()},start:function(){this._enableTick(!0);this._isRunning||(this._currentFrame=gaf.FIRST_FRAME_INDEX,this.setAnimationRunning(!0,!0))},stop:function(){this._enableTick(!1);this._isRunning&&(this._currentFrame=gaf.FIRST_FRAME_INDEX,this.setAnimationRunning(!1,!0))},isDone:function(){return this._isLooped?
!1:this._isReversed?this._currentFrame<gaf.FIRST_FRAME_INDEX-1:this._currentFrame>this._totalFrameCount},getSequences:function(){return this._gafproto.getSequences()},playSequence:function(a,b){var c=this.getStartFrame(a),d=this.getEndFrame(a);return gaf.IDNONE===c||gaf.IDNONE===d?!1:(this._currentSequenceStart=c,this._currentSequenceEnd=d,this._currentFrame=this._currentSequenceStart,this.setLooped(b,!1),this.resumeAnimation(),!0)},isReversed:function(){return this._isReversed},setSequenceDelegate:function(a){this._sequenceDelegate=
a},setFrame:function(a){return a>=gaf.FIRST_FRAME_INDEX&&a<this._totalFrameCount?(this._showingFrame=a,this._currentFrame=a,this._processAnimation(),!0):!1},pauseAnimation:function(){this._isRunning&&this.setAnimationRunning(!1,!1)},isLooped:function(){return this._isLooped},resumeAnimation:function(){this._isRunning||this.setAnimationRunning(!0,!1)},setReversed:function(a){this._isReversed=a},hasSequences:function(){return 0<this._gafproto.getSequences().length},getFps:function(){return this._fps},
ctor:function(a,b){this._super(b);this._objects=[];cc.assert(a,"Error! Missing mandatory parameter.");this._gafproto=a},setExternalTransform:function(a){cc.affineTransformEqualToTransform(this._container._additionalTransform,a)||this._container.setAdditionalTransform(a)},_init:function(){this.setContentSize(this._gafproto.getBoundingBox());this._totalFrameCount=this._currentSequenceEnd=this._gafproto.getTotalFrames();this.setFps(this._gafproto.getFps());this._container=new cc.Node;this.addChild(this._container);
var a=this,b=this._gafproto.getAsset();this._gafproto.getObjects().forEach(function(c){var d=b._getProtos()[c];cc.assert(d,"Error. GAF proto for type: "+c.type+" and reference id: "+c+" not found.");a._objects[c]=d._gafConstruct()})},_enableTick:function(a){!this._animationsSelectorScheduled&&a?(this.schedule(this._processAnimations),this._animationsSelectorScheduled=!0):this._animationsSelectorScheduled&&!a&&(this.unschedule(this._processAnimations),this._animationsSelectorScheduled=!1)},_processAnimations:function(a){for(this._timeDelta+=
a;this._timeDelta>=this._frameTime;)this._timeDelta-=this._frameTime,this._step()},_step:function(){if(this._showingFrame=this._currentFrame,!this.getIsAnimationRunning())return void this._processAnimation();if(this._sequenceDelegate){var a;(a=this._isReversed?this._getSequenceByFirstFrame(this._currentFrame+1):this._getSequenceByLastFrame(this._currentFrame))&&this._sequenceDelegate(this,a)}this._isCurrentFrameLastInSequence()&&(this._isLooped?this._animationStartedNextLoopDelegate&&this._animationStartedNextLoopDelegate(this):
(this.setAnimationRunning(!1,!1),this._animationFinishedPlayDelegate&&this._animationFinishedPlayDelegate(this)));this._processAnimation();this._currentFrame=this._nextFrame()},_isCurrentFrameLastInSequence:function(){return this._isReversed?this._currentFrame==this._currentSequenceStart:this._currentFrame==this._currentSequenceEnd-1},_nextFrame:function(){return this._isCurrentFrameLastInSequence()?this._isLooped?this._isReversed?this._currentSequenceEnd-1:this._currentSequenceStart:this._currentFrame:
this._currentFrame+(this._isReversed?-1:1)},_processAnimation:function(){this._realizeFrame(this._container,this._currentFrame);this._framePlayedDelegate&&this._framePlayedDelegate(this,this._currentFrame)},_realizeFrame:function(a,b){var c=this._objects,d=this._gafproto.getFrames();if(!(b>d.length)&&(d=d[b]))for(var d=d.states,e=0,f=d.length;f>e;++e){var g=d[e],h=c[g.objectIdRef];if(!h)break;if(0>g.alpha&&h._resetState(),h._updateVisibility(g,this),h.isVisible()){h._applyState(g,this);var k=a;g.hasMask&&
(k=c[g.maskObjectIdRef]._getNode(),cc.assert(k,"Error! Mask not found."));h._lastVisibleInFrame=1+b;gaf.TimeLine.rearrangeSubobject(k,h,g.depth);h._step&&h._step()}}},setAnimationRunning:function(a,b){this._isRunning=a;b&&this._objects.forEach(function(c){c&&c.setAnimationRunning&&c.setAnimationRunning(a,b)})},_getSequenceByLastFrame:function(){var a=this._gafproto.getSequences(),b;for(b in a)if(a.hasOwnProperty(b)&&a[b].end===frame+1)return b;return""},_resetState:function(){this._super();this._currentFrame=
this._currentSequenceStart},_getSequenceByFirstFrame:function(){var a=this._gafproto.getSequences(),b;for(b in a)if(a.hasOwnProperty(b)&&a[b].start===frame)return b;return""}});gaf.TimeLine.rearrangeSubobject=function(a,b,c){b.getParent()!==a?(b.removeFromParent(!1),a.addChild(b,c)):b.setLocalZOrder(c)};gaf.TextField=gaf.Object.extend({_className:"GAFTextField"});
gaf.Sprite=gaf.Object.extend({_className:"GAFSprite",_hasCtx:!1,_hasFilter:!1,ctor:function(a,b){this._super(b);cc.assert(a,"Error! Missing mandatory parameter.");this._gafproto=a},_init:function(){var a=this._gafproto.getFrame();cc.assert(a instanceof cc.SpriteFrame,"Error. Wrong object type.");this._sprite=new cc.Sprite;this._sprite._renderCmd=this._gafCreateRenderCmd(this._sprite);this._sprite.initWithSpriteFrame(a);this._sprite.setAnchorPoint(this._gafproto.getAnchor());this.addChild(this._sprite);
this._sprite.setOpacityModifyRGB(!0);cc._renderType===cc._RENDER_TYPE_WEBGL&&this._sprite.setBlendFunc(gl.ONE,gl.ONE_MINUS_SRC_ALPHA)},_applyState:function(a,b){this._applyStateSuper(a,b);this._needsCtx?(this._hasCtx||(this._enableCtx(),this._hasCtx=!0),this._applyCtxState(a)):(this._hasCtx&&(this._disableCtx(),this._hasCtx=!1),cc.colorEqual(this._sprite._realColor,this._cascadeColorMult)||this._sprite.setColor(this._cascadeColorMult),this._sprite.getOpacity()!=this._cascadeColorMult.a&&this._sprite.setOpacity(this._cascadeColorMult.a))},
_enableCtx:function(){this._sprite._renderCmd._enableCtx()},_disableCtx:function(){this._sprite._renderCmd._disableCtx()},_applyCtxState:function(a){this._sprite._renderCmd._applyCtxState(this)},getBoundingBoxForCurrentFrame:function(){var a=this._sprite.getBoundingBox();return cc._rectApplyAffineTransformIn(a,this.getNodeToParentTransform())},_gafCreateRenderCmd:function(a){return cc._renderType===cc._RENDER_TYPE_CANVAS?new gaf.Sprite.CanvasRenderCmd(a):new gaf.Sprite.WebGLRenderCmd(a)}});
gaf.Mask=gaf.Object.extend({_className:"GAFMask",_clippingNode:null,ctor:function(a){this._super();cc.assert(a,"Error! Missing mandatory parameter.");this._gafproto=a},_init:function(){var a=this._gafproto.getMaskNodeProto();cc.assert(a,"Error. Mask node for id ref "+this._gafproto.getIdRef()+" not found.");this._maskNode=a._gafConstruct();this._clippingNode=cc.ClippingNode.create(this._maskNode);this._clippingNode.setAlphaThreshold(0.5);this.addChild(this._clippingNode)},setExternalTransform:function(a){cc.affineTransformEqualToTransform(this._maskNode._additionalTransform,
a)||this._maskNode.setAdditionalTransform(a)},_getNode:function(){return this._clippingNode}});
(function(){gaf.Sprite.CanvasRenderCmd=function(a){cc.Sprite.CanvasRenderCmd.call(this,a);this._hasCtx=this._hasTintOffset=this._hasTintMult=!1;this._tintMult=cc.color(255,255,255,255);this._tintOffset=cc.color(0,0,0,0);this._textureDirty=!1};var a=gaf.Sprite.CanvasRenderCmd.prototype=Object.create(cc.Sprite.CanvasRenderCmd.prototype);a.constructor=gaf.Sprite.CanvasRenderCmd;a._disableCtx=function(){this._hasCtx=this._hasTintOffset=!1;this._textureDirty=!0;this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty);
this._tintMult=cc.color(255,255,255,255);this._tintOffset=cc.color(0,0,0,0)};a._enableCtx=function(){};a._applyCtxState=function(a){var c=a._cascadeColorMult,d=a._cascadeColorOffset,e=c.a;this._node.getOpacity()!=e&&this._node.setOpacity(e);(e=!cc.colorEqual(this._tintMult,c))&&(this._node.setColor(c),this._tintMult=c,this._hasTintMult=255!==c.r||255!==c.g||255!==c.b);(c=this._tintOffset.r!=d.r||this._tintOffset.g!=d.g||this._tintOffset.b!=d.b||this._tintOffset.a!=d.a)&&(this._tintOffset=d,this._hasTintOffset=
0!==d.r||0!==d.g||0!==d.b||0!==d.a);(this._textureDirty=e||c)&&this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty);this._hasCtx=0<a._filterStack.length&&a._filterStack[0].type===gaf.EFFECT_COLOR_MATRIX};a.rendering=function(a,c,d){var e=this._node,f=this._textureCoord,g=this._displayedOpacity/255;if((!e._texture||0!==f.width&&0!==f.height&&e._texture._textureLoaded)&&0!==g){a=a||cc._renderContext;var h=a.getContext(),k=e._offsetPosition.x,m=e._rect.height,n=e._rect.width,p=-e._offsetPosition.y-m;a.setTransform(this._worldTransform,
c,d);a.setCompositeOperation(this._blendFuncStr);a.setGlobalAlpha(g);(e._flippedX||e._flippedY)&&a.save();e._flippedX&&(k=-k-n,h.scale(-1,1));e._flippedY&&(p=e._offsetPosition.y,h.scale(1,-1));g=e._texture._htmlElementObj;this._colorized?h.drawImage(g,0,0,f.width,f.height,k*c,p*d,n*c,m*d):h.drawImage(g,f.renderX,f.renderY,f.width,f.height,k*c,p*d,n*c,m*d);(e._flippedX||e._flippedY)&&a.restore();cc.g_NumberOfDraws++}};cc.sys._supportCanvasNewBlendModes&&(a._updateColor=function(){var a=this._displayedColor,
c=this._node;if(this._hasTintMult|=255!==a.r||255!==a.g||255!==a.b,this._textureDirty){this._textureDirty=!1;this._colorized&&(this._colorized=!1,c.texture=this._originalTexture);var d,e=c._texture,f=this._textureCoord;if(this._hasTintMult&&e&&f.validRect&&this._originalTexture){if(d=e.getHtmlElementObj(),!d)return;this._colorized=!0;(this._hasTintOffset||this._hasCtx)&&(a=this._tintMult);d=cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj,a,f);e=new cc.Texture2D;
e.initWithElement(d);e.handleLoadedTexture();c.texture=e}if(e=c._texture,this._hasTintOffset)if(a=cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj()),e&&(f.validRect&&this._originalTexture)&&!(d=e.getHtmlElementObj(),!d))d=this._colorized?cc.rect(0,0,f.width,f.height):f,d=this._gafGenerateTintImage(c.texture._htmlElementObj,d,a,this._tintOffset,f),e=new cc.Texture2D,e.initWithElement(d),e.handleLoadedTexture(),c.texture=e,this._colorized=!0}},a._gafGenerateTintImage=function(a,
c,d,e,f,g){f||(f=cc.rect(0,0,a.width,a.height));var h,k=Math.min(f.width,d[0].width),m=Math.min(f.height,d[0].height);return g?(h=g.getContext("2d"),h.clearRect(0,0,k,m)):(g=cc.newElement("canvas"),g.width=k,g.height=m,h=g.getContext("2d")),h.save(),h.globalCompositeOperation="source-over",h.drawImage(d[2],f.x,f.y,k,m,0,0,k,m),h.globalCompositeOperation="source-in",h.fillStyle="rgba("+Math.round(e.r)+","+Math.round(e.g)+","+Math.round(e.b)+",1)",h.fillRect(0,0,k,m),h.globalCompositeOperation="lighter",
h.drawImage(a,c.x,c.y,k,m,0,0,k,m),h.restore(),g})})();
gaf._TimeLineProto=function(a,b,c,d,e,f){e="undefined"!=typeof e?e:0;f=f||"";this._objects=[];this.getTotalFrames=function(){return b};this.getBoundingBox=function(){return c};this.getId=function(){return e};this.getLinkageName=function(){return f};this.getPivot=function(){return d};this.getRect=function(){return c};this.getNamedParts=function(){return{}};this.getSequences=function(){return{}};this.getFrames=function(){return[]};this.getFps=function(){return 60};this.getObjects=function(){return this._objects};
this.getAsset=function(){return a};this._gafConstruct=function(){var a=this.getAsset()._usedAtlasScale,a=new gaf.TimeLine(this,a);return a._init(),a}};gaf._SpriteProto=function(a,b,c){this.getFrames=function(){return b};this.getIdRef=function(){return c};this.getAsset=function(){return a};this._gafConstruct=function(){var a=this.getAsset()._usedAtlasScale,a=new gaf.Sprite(this,a);return a._init(),a}};
gaf._SpriteProto.prototype.getFrame=function(){var a=this.getAsset()._usedAtlasScale;cc.assert(a,"Error. Atlas scale zero.");var b=this.getFrames()[a];return cc.assert(b,"Error. No frames found for used scale `"+a+"`"),b[this.getIdRef()]};gaf._SpriteProto.prototype.getAnchor=function(){return this.getFrame()._gafAnchor};
gaf._MaskProto=function(a,b,c){this.getIdRef=function(){return c};this.getMaskNodeProto=function(){return b};this._gafConstruct=function(){var a=new gaf.Mask(this);return a._init(),a}};gaf.ReadSingleTag=function(a){var b=a.Ushort(),c=gaf.Tags[b],d={};return"undefined"==typeof c?(console.log("GAF. Non implemented tag detected."),gaf.Tags.Default.parse(a,b)):d=c.parse(a,b),d};
gaf.ReadTags=function(a){var b=[];try{do{var c=gaf.ReadSingleTag(a);b.push(c)}while(0!=c.tagId)}catch(d){if(!(d instanceof Error&&"GAF format error"==d.message))throw console.log(d.stack),d;console.log("GAF format error:\n"+d.stack)}return b};
gaf.Tag=function(){this.Default=Object.create(gaf.Tag.base);this[0]=Object.create(gaf.Tag.End);this[1]=Object.create(gaf.Tag.DefineAtlas);this[2]=Object.create(gaf.Tag.DefineAnimationMasks);this[3]=Object.create(gaf.Tag.DefineAnimationObjects);this[4]=Object.create(gaf.Tag.DefineAnimationFrames);this[5]=Object.create(gaf.Tag.DefineNamedParts);this[6]=Object.create(gaf.Tag.DefineSequences);this[7]=Object.create(gaf.Tag.DefineTextFields);this[8]=Object.create(gaf.Tag.DefineAtlas2);this[9]=Object.create(gaf.Tag.DefineStage);
this[10]=Object.create(gaf.Tag.DefineAnimationObjects2);this[11]=Object.create(gaf.Tag.DefineAnimationMasks2);this[12]=Object.create(gaf.Tag.DefineAnimationFrames2);this[13]=Object.create(gaf.Tag.DefineTimeline)};gaf.Tag.base=function(){};gaf.Tag.base.parse=function(a,b){var c=a.Uint();a.startNestedBuffer(c);c=this.doParse(a);return a.endNestedBuffer(),c.tagName=this.tagName,c.tagId=b,c};gaf.Tag.base.doParse=function(a){return{}};gaf.Tag.End=Object.create(gaf.Tag.base);gaf.Tag.End.tagName="TagEnd";
gaf.Tag.DefineAtlas=Object.create(gaf.Tag.base);gaf.Tag.DefineAtlas.tagName="TagDefineAtlas";gaf.Tag.DefineAtlas.doParse=function(a){return{content:a.fields("scale","Float","atlases",a.array("Ubyte",a.fields("id","Uint","sources",a.array("Ubyte",a.fields("source","String","csf","Float")))),"elements",a.array("Uint",a.fields("pivot","Point","origin","Point","scale","Float","size","Point","atlasId","Uint","elementAtlasId","Uint")))()}};gaf.Tag.DefineAnimationMasks=Object.create(gaf.Tag.base);
gaf.Tag.DefineAnimationMasks.tagName="TagDefineAnimationMasks";gaf.Tag.DefineAnimationMasks.doParse=function(a){return{content:a.array("Uint",a.fields("objectId","Uint","elementAtlasIdRef","Uint"))()}};gaf.Tag.DefineAnimationObjects=Object.create(gaf.Tag.base);gaf.Tag.DefineAnimationObjects.tagName="TagDefineAnimationObjects";gaf.Tag.DefineAnimationObjects.doParse=function(a){return{content:a.array("Uint",a.fields("objectId","Uint","elementAtlasIdRef","Uint"))()}};gaf.Tag.DefineAnimationFrames=Object.create(gaf.Tag.base);
gaf.Tag.DefineAnimationFrames.tagName="TagDefineAnimationFrames";
gaf.Tag.DefineAnimationFrames.doParse=function(a){return{content:a.array("Uint",a.fields("frame","Uint","state",a.array("Uint",a.fields("hasColorTransform","Ubyte","hasMask","Ubyte","hasEffect","Ubyte","objectIdRef","Uint","depth","Int","alpha","Float","matrix","Matrix","colorTransform",a.condition("hasColorTransform",1,a.fields("alphaOffset","Float","redMultiplier","Float","redOffset","Float","greenMultiplier","Float","greenOffset","Float","blueMultiplier","Float","blueOffset","Float")),"effect",
a.condition("hasEffect",1,a.array("Ubyte",gaf.Tag._readFilter(a))),"maskObjectIdRef",a.condition("hasMask",1,a.fields("maskObjectIdRef","Uint"))))))()}};gaf.Tag.DefineNamedParts=Object.create(gaf.Tag.base);gaf.Tag.DefineNamedParts.tagName="TagDefineNamedParts";gaf.Tag.DefineNamedParts.doParse=function(a){return{content:a.array("Uint",a.fields("objectId","Uint","name","String"))()}};gaf.Tag.DefineSequences=Object.create(gaf.Tag.base);gaf.Tag.DefineSequences.tagName="TagDefineSequences";
gaf.Tag.DefineSequences.doParse=function(a){return{content:a.array("Uint",a.fields("id","String","start","Ushort","end","Ushort"))()}};gaf.Tag.DefineTextFields=Object.create(gaf.Tag.base);gaf.Tag.DefineTextFields.tagName="TagDefineTextFields";
gaf.Tag.DefineTextFields.doParse=function(a){return{content:a.array("Uint",a.fields("id","Uint","pivot","Point","end","Ushort","width","Float","height","Float","text","String","embedFonts","Boolean","multiline","Boolean","wordWrap","Boolean","hasRestrict","Boolean","restrict",a.condition("hasRestrict",1,function(){return a.String}),"editable","Boolean","selectable","Boolean","displayAsPassword","Boolean","maxChars","Uint","align","Uint","blockIndent","Uint","bold","Boolean","bullet","Boolean","color",
"color","font","String","indent","Uint","italic","Boolean","kerning","Boolean","leading","Uint","leftMargin","Uint","letterSpacing","Float","rightMargin","Uint","size","Uint","tabStops",a.array("Uint",a.fields("value","Uint")),"target","string","underline","Boolean","url","String"))()}};gaf.Tag.DefineAtlas2=Object.create(gaf.Tag.base);gaf.Tag.DefineAtlas2.tagName="TagDefineAtlas2";
gaf.Tag.DefineAtlas2.doParse=function(a){return{content:a.fields("scale","Float","atlases",a.array("Ubyte",a.fields("id","Uint","sources",a.array("Ubyte",a.fields("source","String","csf","Float")))),"elements",a.array("Uint",a.fields("pivot","Point","origin","Point","scale","Float","size","Point","atlasId","Uint","elementAtlasId","Uint","hasScale9Grid","Boolean","scale9GridRect",a.condition("hasScale9Grid",1,function(){return a.Rect()}))))()}};gaf.Tag.DefineStage=Object.create(gaf.Tag.base);
gaf.Tag.DefineStage.tagName="TagDefineStage";gaf.Tag.DefineStage.doParse=function(a){return{content:a.fields("fps","Ubyte","color","color","width","Ushort","height","Ushort")()}};gaf.Tag.DefineAnimationObjects2=Object.create(gaf.Tag.base);gaf.Tag.DefineAnimationObjects2.tagName="TagDefineAnimationObjects2";gaf.Tag.DefineAnimationObjects2.doParse=function(a){return{content:a.array("Uint",a.fields("objectId","Uint","elementAtlasIdRef","Uint","type","Ushort"))()}};gaf.Tag.DefineAnimationMasks2=Object.create(gaf.Tag.base);
gaf.Tag.DefineAnimationMasks2.tagName="TagDefineAnimationMasks2";gaf.Tag.DefineAnimationMasks2.doParse=function(a){return{content:a.array("Uint",a.fields("objectId","Uint","elementAtlasIdRef","Uint","type","Ushort"))()}};gaf.Tag.DefineAnimationFrames2=Object.create(gaf.Tag.base);gaf.Tag.DefineAnimationFrames2.tagName="TagDefineAnimationFrames2";
gaf.Tag.DefineAnimationFrames2.doParse=function(a){return{content:a.array("Uint",a.fields("frame","Uint","hasChangesInDisplayList","Boolean","hasActions","Boolean","state",a.condition("hasChangesInDisplayList",1,a.array("Uint",a.fields("hasColorTransform","Boolean","hasMask","Boolean","hasEffect","Boolean","objectIdRef","Uint","depth","Int","alpha","Float","matrix","Matrix","colorTransform",a.condition("hasColorTransform",1,a.fields("alphaOffset","Float","redMultiplier","Float","redOffset","Float",
"greenMultiplier","Float","greenOffset","Float","blueMultiplier","Float","blueOffset","Float")),"effect",a.condition("hasEffect",1,a.array("Ubyte",gaf.Tag._readFilter(a))),"maskObjectIdRef",a.condition("hasMask",1,function(){return a.Uint()})))),"actions",a.condition("hasActions",1,a.array("Uint",a.fields("type","Uint","scope","String","params",gaf.Tag._readActionArguments(a))))))()}};gaf.Tag.DefineTimeline=Object.create(gaf.Tag.base);gaf.Tag.DefineTimeline.tagName="TagDefineTimeline";
gaf.Tag.DefineTimeline.doParse=function(a){var b={content:a.fields("id","Uint","animationFrameCount","Uint","boundingBox","Rect","pivotPoint","Point","hasLinkage","Boolean","linkageName",a.condition("hasLinkage",1,function(){return a.String()}))()};return b.content.tags=gaf.ReadTags(a),b};gaf.Tag._readActionArguments=function(a){return function(){var b=a.Uint(),c=[];for(a.startNestedBuffer(b);a.maxOffset()<a.tell();)c.push(a.String());return a.endNestedBuffer(),c}};
gaf.Tag._readFilter=function(a){return a.fields("type","Uint","dropShadow",a.condition("type",gaf.EFFECT_DROP_SHADOW,a.fields("color","color","blurX","Float","blurY","Float","angle","Float","distance","Float","strength","Float","inner","Boolean","knockout","Boolean")),"blur",a.condition("type",gaf.EFFECT_BLUR,a.fields("blurX","Float","blurY","Float")),"glow",a.condition("type",gaf.EFFECT_GLOW,a.fields("color","color","blurX","Float","blurY","Float","strength","Float","inner","Boolean","knockout",
"Boolean")),"colorMatrix",a.condition("type",gaf.EFFECT_COLOR_MATRIX,a.fields("rr","Float","gr","Float","br","Float","ar","Float","r","Float","rg","Float","gg","Float","bg","Float","ag","Float","g","Float","rb","Float","gb","Float","bb","Float","ab","Float","b","Float","ra","Float","ga","Float","ba","Float","aa","Float","a","Float")))};gaf.Tags=new gaf.Tag;gaf=gaf||{};
gaf.Loader=function(){this.LoadFile=function(a,b){var c=new XMLHttpRequest;c.open("GET",a,!0);var d=this;c.responseType="arraybuffer";c.onload=function(a){a=new gaf.DataReader(c.response);a=d.LoadStream(a);b&&b(a)};c.send()};this.LoadStream=function(a){var b={},c=a;b.compression=c.Uint();b.versionMajor=c.Ubyte();b.versionMinor=c.Ubyte();b.fileLength=c.Uint();if(b.compression!=gaf.COMPRESSION_NONE){if(b.compression!=gaf.COMPRESSION_ZIP)throw Error("GAF syntax error.");a=a.dataRaw.slice(a.tell());a=
(new window.Zlib.Inflate(new Uint8Array(a))).decompress();a=new gaf.DataReader(a.buffer)}if(4>b.versionMajor)c=a,b.framesCount=c.Ushort(),b.frameSize=c.Rect(),b.pivot=c.Point();else{var c=a,d=c.Uint();b.scaleValues=[];for(var e=0;d>e;++e)b.scaleValues.push(c.Float());d=c.Uint();b.csfValues=[];for(e=0;d>e;++e)b.csfValues.push(c.Float())}a=gaf.ReadTags(a);return{header:b,tags:a}}};gaf.DataReader=function(a){this.dataRaw=a;this.buf=new DataView(a);this.offset=[0]};
gaf.DataReader.prototype.constructor=gaf.DataReader;gaf.DataReader.prototype.newOffset=function(a){if(this.offset[this.offset.length-1]+=a,this.getOffset()>this.maxOffset())throw Error("GAF format error");return this.offset[this.offset.length-1]-a};gaf.DataReader.prototype.maxOffset=function(){return 1==this.offset.length?this.buf.byteLength:this.offset[this.offset.length-2]};gaf.DataReader.prototype.getOffset=function(a){return this.offset[this.offset.length-1]};gaf.DataReader.prototype.Ubyte=function(){return this.buf.getUint8(this.newOffset(1))};
gaf.DataReader.prototype.Boolean=function(){var a=this.buf.getUint8(this.newOffset(1));if(1<a)throw Error("GAF format error");return a};gaf.DataReader.prototype.Uint=function(){return this.buf.getUint32(this.newOffset(4),!0)};gaf.DataReader.prototype.Int=function(){return this.buf.getInt32(this.newOffset(4),!0)};gaf.DataReader.prototype.color=function(){return{b:this.Ubyte(),g:this.Ubyte(),r:this.Ubyte(),a:this.Ubyte()}};
gaf.DataReader.prototype.Ushort=function(){return this.buf.getUint16(this.newOffset(2),!0)};gaf.DataReader.prototype.Float=function(){return this.buf.getFloat32(this.newOffset(4),!0)};
gaf.DataReader.prototype.String=function(){var a=this.Ushort(),b=this.newOffset(a),a=this.getOffset();try{var c=this.dataRaw.slice(b,a)}catch(d){if("Object doesn't support property or method 'slice'"!=d.message)throw d;for(c=[];a>b;++b)c.push(this.buf.getUint8(b))}return decodeURIComponent(escape(String.fromCharCode.apply(null,new Uint8Array(c))))};gaf.DataReader.prototype.startNestedBuffer=function(a){this.offset.push(this.offset[this.offset.length-1]);this.offset[this.offset.length-2]+=a};
gaf.DataReader.prototype.endNestedBuffer=function(){if(1==this.offset.length)throw Error("No nested buffer available");this.offset.pop()};gaf.DataReader.prototype.Point=function(){return{x:this.Float(),y:this.Float()}};gaf.DataReader.prototype.Rect=function(){return{x:this.Float(),y:this.Float(),width:this.Float(),height:this.Float()}};gaf.DataReader.prototype.Matrix=function(){return{a:this.Float(),b:this.Float(),c:this.Float(),d:this.Float(),tx:this.Float(),ty:this.Float()}};
gaf.DataReader.prototype.seek=function(a){this.offset[this.offset.length-1]=a};gaf.DataReader.prototype.tell=function(){return this.offset[this.offset.length-1]};
gaf.DataReader.prototype.fields=function(){var a=this,b=arguments;return function(){arguments.callee.result={};var c=0;if(b.length%2)throw Error("Number of arguments is not even");for(;c<b.length;){var d=b[c++],e=b[c++];if("function"==typeof e)arguments.callee.result[d]=e();else{if(!(e in a&&"function"==typeof a[e]))throw Error("Object DataReader has no function `"+e+"`");arguments.callee.result[d]=a[e].call(a)}}return arguments.callee.result}};
gaf.DataReader.prototype.condition=function(a,b,c){var d=arguments;return function(){if(3!=d.length)throw Error("Condition function");var a=arguments.callee.caller;if(!("result"in a))throw Error("Condition function caller has no key `result`");var b=a.result,c=d[0],h=d[1],a=d[2],k=null;return k="function"==typeof h?function(){return h(b[c])}:function(){return h==b[c]},k()?a():null}};
gaf.DataReader.prototype.array=function(){var a=this,b=arguments;return function(){arguments.callee.result=[];for(var c=a[b[0]].call(a),d=0;c>d;++d){var e=b[1].call();arguments.callee.result.push(e)}return arguments.callee.result}};gaf.SHADER_GAUSSIAN_BLUR_FRAG="varying mediump vec2 v_texCoord;\nuniform mediump vec2 u_step;\nvoid main()\n{ \n    mediump vec4 sum \x3d vec4(0.0);                                      \n    sum +\x3d texture2D(CC_Texture0, v_texCoord - u_step * 4.0) * 0.05;   \n    sum +\x3d texture2D(CC_Texture0, v_texCoord - u_step * 3.0) * 0.09;   \n    sum +\x3d texture2D(CC_Texture0, v_texCoord - u_step * 2.0) * 0.12;   \n    sum +\x3d texture2D(CC_Texture0, v_texCoord - u_step * 1.0) * 0.15;   \n    sum +\x3d texture2D(CC_Texture0, v_texCoord + u_step * 0.0) * 0.18;   \n    sum +\x3d texture2D(CC_Texture0, v_texCoord + u_step * 1.0) * 0.15;   \n    sum +\x3d texture2D(CC_Texture0, v_texCoord + u_step * 2.0) * 0.12;   \n    sum +\x3d texture2D(CC_Texture0, v_texCoord + u_step * 3.0) * 0.09;   \n    sum +\x3d texture2D(CC_Texture0, v_texCoord + u_step * 4.0) * 0.05;   \n    gl_FragColor \x3d sum;                                                \n} \n";
gaf.SHADER_GLOW_FRAG="varying mediump vec2 v_texCoord;\nuniform mediump vec2 u_step;\nuniform mediump vec4 u_glowColor;\nvoid main()\n{ \n    mediump vec4 sum \x3d vec4(0.0);                                      \n    sum +\x3d texture2D(CC_Texture0, v_texCoord - u_step * 4.0) * 0.05;   \n    sum +\x3d texture2D(CC_Texture0, v_texCoord - u_step * 3.0) * 0.09;   \n    sum +\x3d texture2D(CC_Texture0, v_texCoord - u_step * 2.0) * 0.12;   \n    sum +\x3d texture2D(CC_Texture0, v_texCoord - u_step * 1.0) * 0.15;   \n    sum +\x3d texture2D(CC_Texture0, v_texCoord + u_step * 0.0) * 0.18;   \n    sum +\x3d texture2D(CC_Texture0, v_texCoord + u_step * 1.0) * 0.15;   \n    sum +\x3d texture2D(CC_Texture0, v_texCoord + u_step * 2.0) * 0.12;   \n    sum +\x3d texture2D(CC_Texture0, v_texCoord + u_step * 3.0) * 0.09;   \n    sum +\x3d texture2D(CC_Texture0, v_texCoord + u_step * 4.0) * 0.05;   \n    gl_FragColor \x3d sum * u_glowColor;                                  \n} \n";
gaf.SHADER_COLOR_MATRIX_FRAG="varying mediump vec2 v_texCoord;\nvarying mediump vec4 v_fragmentColor;\nuniform mediump vec4 colorTransformMult;\nuniform mediump vec4 colorTransformOffsets;\nuniform mediump mat4 colorMatrix;\nuniform mediump vec4 colorMatrix2;\nvoid main()\n{ \n    vec4 texColor \x3d texture2D(CC_Texture0, v_texCoord);                          \n    const float kMinimalAlphaAllowed \x3d 1.0e-8;                                   \n    if (texColor.a \x3e kMinimalAlphaAllowed)                                       \n    {                                                                            \n        texColor \x3d vec4(texColor.rgb / texColor.a, texColor.a);                  \n        vec4 ctxColor \x3d texColor * colorTransformMult + colorTransformOffsets;   \n        vec4 adjustColor \x3d colorMatrix * ctxColor + colorMatrix2;                \n        adjustColor *\x3d v_fragmentColor;                                          \n        texColor \x3d vec4(adjustColor.rgb * adjustColor.a, adjustColor.a);         \n    }                                                                            \n    gl_FragColor \x3d texColor;                                                     \n}\n";
gaf._glShaderInit=function(){gaf._Uniforms={ColorTransformMult:-1,ColorTransformOffset:-1,ColorMatrixBody:-1,ColorMatrixAppendix:-1,BlurTexelOffset:-1,GlowTexelOffset:-1,GlowColor:-1};gaf._shaderCreate=function(a,b){var c=new cc.GLProgram,d=c.initWithVertexShaderByteArray(b,a);return cc.assert(d,"Shader init error"),c.addAttribute(cc.ATTRIBUTE_NAME_POSITION,cc.VERTEX_ATTRIB_POSITION),c.addAttribute(cc.ATTRIBUTE_NAME_COLOR,cc.VERTEX_ATTRIB_COLOR),c.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD,cc.VERTEX_ATTRIB_TEX_COORDS),
d=c.link(),cc.assert(d,"Shader linking error"),c.updateUniforms(),c};gaf._shaderCreateAlpha=function(){var a=gaf._shaderCreate(gaf.SHADER_COLOR_MATRIX_FRAG,cc.SHADER_POSITION_TEXTURE_COLOR_VERT);return gaf._Uniforms.ColorTransformMult=a.getUniformLocationForName(gaf.UNIFORM_ALPHA_TINT_MULT),gaf._Uniforms.ColorTransformOffset=a.getUniformLocationForName(gaf.UNIFORM_ALPHA_TINT_OFFSET),gaf._Uniforms.ColorMatrixBody=a.getUniformLocationForName(gaf.UNIFORM_ALPHA_COLOR_MATRIX_BODY),gaf._Uniforms.ColorMatrixAppendix=
a.getUniformLocationForName(gaf.UNIFORM_ALPHA_COLOR_MATRIX_APPENDIX),a};gaf._shaderCreateBlur=function(){var a=gaf._shaderCreate(gaf.SHADER_GAUSSIAN_BLUR_FRAG,cc.SHADER_POSITION_TEXTURE_COLOR_VERT);return gaf._Uniforms.BlurTexelOffset=a._glContext.getUniformLocation(a._programObj,gaf.UNIFORM_BLUR_TEXEL_OFFSET),a};gaf._shaderCreateGlow=function(){var a=gaf._shaderCreate(gaf.SHADER_GLOW_FRAG,cc.SHADER_POSITION_TEXTURE_COLOR_VERT);return gaf._Uniforms.GlowTexelOffset=a._glContext.getUniformLocation(a._programObj,
gaf.UNIFORM_GLOW_TEXEL_OFFSET),gaf._Uniforms.GlowColor=a._glContext.getUniformLocation(a._programObj,gaf.UNIFORM_GLOW_COLOR),a};gaf._Shaders={Alpha:gaf._shaderCreateAlpha(),Blur:gaf._shaderCreateBlur(),Glow:gaf._shaderCreateGlow()}};gaf._setupShaders=function(){cc._renderType===cc._RENDER_TYPE_WEBGL?gaf._glShaderInit():delete gaf._glShaderInit};gaf._AtlasLoader={};gaf._AtlasLoader.execute=function(a,b,c){a()?b():c()};
gaf._AtlasLoader.checkAtlas=function(a){return function(){return a&&"string"!=typeof a&&a.isLoaded()}};gaf._AtlasLoader.load=function(a,b,c){cc.textureCache.addImage(a,function(a){gaf._AtlasLoader.execute(gaf._AtlasLoader.checkAtlas(a),function(){b(a)},c)})};gaf._AtlasLoader.loadFront=function(a,b,c){return function(){0<a.length?gaf._AtlasLoader.load(a[0],b,gaf._AtlasLoader.loadFront(a.slice(1),b,c)):c()}};gaf._AtlasLoader.loadArray=function(a,b,c){gaf._AtlasLoader.loadFront(a,b,c)()};var Box2D={};
!function(a,b){function c(){}!(Object.defineProperty instanceof Function)&&Object.prototype.__defineGetter__ instanceof Function&&Object.prototype.__defineSetter__ instanceof Function&&(Object.defineProperty=function(a,b,c){c.get instanceof Function&&a.__defineGetter__(b,c.get);c.set instanceof Function&&a.__defineSetter__(b,c.set)});a.inherit=function(a,b){c.prototype=b.prototype;a.prototype=new c;a.prototype.constructor=a};a.generateCallback=function(a,b){return function(){b.apply(a,arguments)}};
a.NVector=function(a){a===b&&(a=0);for(var c=Array(a||0),f=0;a>f;++f)c[f]=0;return c};a.is=function(a,c){return null===a?!1:c instanceof Function&&a instanceof c?!0:a.constructor.__implements!=b&&a.constructor.__implements[c]?!0:!1};a.parseUInt=function(a){return Math.abs(parseInt(a))}}(Box2D);var Vector=Array,Vector_a2j_Number=Box2D.NVector;"undefined"==typeof Box2D&&(Box2D={});"undefined"==typeof Box2D.Collision&&(Box2D.Collision={});
"undefined"==typeof Box2D.Collision.Shapes&&(Box2D.Collision.Shapes={});"undefined"==typeof Box2D.Common&&(Box2D.Common={});"undefined"==typeof Box2D.Common.Math&&(Box2D.Common.Math={});"undefined"==typeof Box2D.Dynamics&&(Box2D.Dynamics={});"undefined"==typeof Box2D.Dynamics.Contacts&&(Box2D.Dynamics.Contacts={});"undefined"==typeof Box2D.Dynamics.Controllers&&(Box2D.Dynamics.Controllers={});"undefined"==typeof Box2D.Dynamics.Joints&&(Box2D.Dynamics.Joints={});
(function(){function a(){a.b2AABB.apply(this,arguments)}function b(){b.b2Bound.apply(this,arguments)}function c(){c.b2BoundValues.apply(this,arguments);this.constructor===c&&this.b2BoundValues.apply(this,arguments)}function d(){d.b2Collision.apply(this,arguments)}function e(){e.b2ContactID.apply(this,arguments);this.constructor===e&&this.b2ContactID.apply(this,arguments)}function f(){f.b2ContactPoint.apply(this,arguments)}function g(){g.b2Distance.apply(this,arguments)}function h(){h.b2DistanceInput.apply(this,
arguments)}function k(){k.b2DistanceOutput.apply(this,arguments)}function m(){m.b2DistanceProxy.apply(this,arguments)}function n(){n.b2DynamicTree.apply(this,arguments);this.constructor===n&&this.b2DynamicTree.apply(this,arguments)}function p(){p.b2DynamicTreeBroadPhase.apply(this,arguments)}function r(){r.b2DynamicTreeNode.apply(this,arguments)}function s(){s.b2DynamicTreePair.apply(this,arguments)}function v(){v.b2Manifold.apply(this,arguments);this.constructor===v&&this.b2Manifold.apply(this,arguments)}
function u(){u.b2ManifoldPoint.apply(this,arguments);this.constructor===u&&this.b2ManifoldPoint.apply(this,arguments)}function t(){t.b2Point.apply(this,arguments)}function x(){x.b2RayCastInput.apply(this,arguments);this.constructor===x&&this.b2RayCastInput.apply(this,arguments)}function A(){A.b2RayCastOutput.apply(this,arguments)}function F(){F.b2Segment.apply(this,arguments)}function z(){z.b2SeparationFunction.apply(this,arguments)}function w(){w.b2Simplex.apply(this,arguments);this.constructor===
w&&this.b2Simplex.apply(this,arguments)}function B(){B.b2SimplexCache.apply(this,arguments)}function E(){E.b2SimplexVertex.apply(this,arguments)}function I(){I.b2TimeOfImpact.apply(this,arguments)}function J(){J.b2TOIInput.apply(this,arguments)}function O(){O.b2WorldManifold.apply(this,arguments);this.constructor===O&&this.b2WorldManifold.apply(this,arguments)}function L(){L.ClipVertex.apply(this,arguments)}function D(){D.Features.apply(this,arguments)}function y(){y.b2CircleShape.apply(this,arguments);
this.constructor===y&&this.b2CircleShape.apply(this,arguments)}function H(){H.b2EdgeChainDef.apply(this,arguments);this.constructor===H&&this.b2EdgeChainDef.apply(this,arguments)}function K(){K.b2EdgeShape.apply(this,arguments);this.constructor===K&&this.b2EdgeShape.apply(this,arguments)}function N(){N.b2MassData.apply(this,arguments)}function W(){W.b2PolygonShape.apply(this,arguments);this.constructor===W&&this.b2PolygonShape.apply(this,arguments)}function U(){U.b2Shape.apply(this,arguments);this.constructor===
U&&this.b2Shape.apply(this,arguments)}function C(){C.b2Color.apply(this,arguments);this.constructor===C&&this.b2Color.apply(this,arguments)}function G(){G.b2Settings.apply(this,arguments)}function T(){T.b2Mat22.apply(this,arguments);this.constructor===T&&this.b2Mat22.apply(this,arguments)}function P(){P.b2Mat33.apply(this,arguments);this.constructor===P&&this.b2Mat33.apply(this,arguments)}function R(){R.b2Math.apply(this,arguments)}function M(){M.b2Sweep.apply(this,arguments)}function Y(){Y.b2Transform.apply(this,
arguments);this.constructor===Y&&this.b2Transform.apply(this,arguments)}function V(){V.b2Vec2.apply(this,arguments);this.constructor===V&&this.b2Vec2.apply(this,arguments)}function pa(){pa.b2Vec3.apply(this,arguments);this.constructor===pa&&this.b2Vec3.apply(this,arguments)}function la(){la.b2Body.apply(this,arguments);this.constructor===la&&this.b2Body.apply(this,arguments)}function ja(){ja.b2BodyDef.apply(this,arguments);this.constructor===ja&&this.b2BodyDef.apply(this,arguments)}function Aa(){Aa.b2ContactFilter.apply(this,
arguments)}function ha(){ha.b2ContactImpulse.apply(this,arguments)}function Oa(){Oa.b2ContactListener.apply(this,arguments)}function aa(){aa.b2ContactManager.apply(this,arguments);this.constructor===aa&&this.b2ContactManager.apply(this,arguments)}function qa(){qa.b2DebugDraw.apply(this,arguments);this.constructor===qa&&this.b2DebugDraw.apply(this,arguments)}function ib(){ib.b2DestructionListener.apply(this,arguments)}function S(){S.b2FilterData.apply(this,arguments)}function ra(){ra.b2Fixture.apply(this,
arguments);this.constructor===ra&&this.b2Fixture.apply(this,arguments)}function sa(){sa.b2FixtureDef.apply(this,arguments);this.constructor===sa&&this.b2FixtureDef.apply(this,arguments)}function ta(){ta.b2Island.apply(this,arguments);this.constructor===ta&&this.b2Island.apply(this,arguments)}function Da(){Da.b2TimeStep.apply(this,arguments)}function Z(){Z.b2World.apply(this,arguments);this.constructor===Z&&this.b2World.apply(this,arguments)}function jb(){jb.b2CircleContact.apply(this,arguments)}function da(){da.b2Contact.apply(this,
arguments);this.constructor===da&&this.b2Contact.apply(this,arguments)}function Sa(){Sa.b2ContactConstraint.apply(this,arguments);this.constructor===Sa&&this.b2ContactConstraint.apply(this,arguments)}function fa(){fa.b2ContactConstraintPoint.apply(this,arguments)}function kb(){kb.b2ContactEdge.apply(this,arguments)}function Ea(){Ea.b2ContactFactory.apply(this,arguments);this.constructor===Ea&&this.b2ContactFactory.apply(this,arguments)}function Ta(){Ta.b2ContactRegister.apply(this,arguments)}function Pa(){Pa.b2ContactResult.apply(this,
arguments)}function Ba(){Ba.b2ContactSolver.apply(this,arguments);this.constructor===Ba&&this.b2ContactSolver.apply(this,arguments)}function Qa(){Qa.b2EdgeAndCircleContact.apply(this,arguments)}function ma(){ma.b2NullContact.apply(this,arguments);this.constructor===ma&&this.b2NullContact.apply(this,arguments)}function Ca(){Ca.b2PolyAndCircleContact.apply(this,arguments)}function Ra(){Ra.b2PolyAndEdgeContact.apply(this,arguments)}function na(){na.b2PolygonContact.apply(this,arguments)}function Fa(){Fa.b2PositionSolverManifold.apply(this,
arguments);this.constructor===Fa&&this.b2PositionSolverManifold.apply(this,arguments)}function Ua(){Ua.b2BuoyancyController.apply(this,arguments)}function lb(){lb.b2ConstantAccelController.apply(this,arguments)}function Ga(){Ga.b2ConstantForceController.apply(this,arguments)}function Ha(){Ha.b2Controller.apply(this,arguments)}function ka(){ka.b2ControllerEdge.apply(this,arguments)}function $(){$.b2GravityController.apply(this,arguments)}function Va(){Va.b2TensorDampingController.apply(this,arguments)}
function Ia(){Ia.b2DistanceJoint.apply(this,arguments);this.constructor===Ia&&this.b2DistanceJoint.apply(this,arguments)}function Wa(){Wa.b2DistanceJointDef.apply(this,arguments);this.constructor===Wa&&this.b2DistanceJointDef.apply(this,arguments)}function Xa(){Xa.b2FrictionJoint.apply(this,arguments);this.constructor===Xa&&this.b2FrictionJoint.apply(this,arguments)}function Ya(){Ya.b2FrictionJointDef.apply(this,arguments);this.constructor===Ya&&this.b2FrictionJointDef.apply(this,arguments)}function ga(){ga.b2GearJoint.apply(this,
arguments);this.constructor===ga&&this.b2GearJoint.apply(this,arguments)}function ba(){ba.b2GearJointDef.apply(this,arguments);this.constructor===ba&&this.b2GearJointDef.apply(this,arguments)}function ia(){ia.b2Jacobian.apply(this,arguments)}function ua(){ua.b2Joint.apply(this,arguments);this.constructor===ua&&this.b2Joint.apply(this,arguments)}function Ja(){Ja.b2JointDef.apply(this,arguments);this.constructor===Ja&&this.b2JointDef.apply(this,arguments)}function Za(){Za.b2JointEdge.apply(this,arguments)}
function Ka(){Ka.b2LineJoint.apply(this,arguments);this.constructor===Ka&&this.b2LineJoint.apply(this,arguments)}function La(){La.b2LineJointDef.apply(this,arguments);this.constructor===La&&this.b2LineJointDef.apply(this,arguments)}function va(){va.b2MouseJoint.apply(this,arguments);this.constructor===va&&this.b2MouseJoint.apply(this,arguments)}function Ma(){Ma.b2MouseJointDef.apply(this,arguments);this.constructor===Ma&&this.b2MouseJointDef.apply(this,arguments)}function Q(){Q.b2PrismaticJoint.apply(this,
arguments);this.constructor===Q&&this.b2PrismaticJoint.apply(this,arguments)}function ea(){ea.b2PrismaticJointDef.apply(this,arguments);this.constructor===ea&&this.b2PrismaticJointDef.apply(this,arguments)}function wa(){wa.b2PulleyJoint.apply(this,arguments);this.constructor===wa&&this.b2PulleyJoint.apply(this,arguments)}function $a(){$a.b2PulleyJointDef.apply(this,arguments);this.constructor===$a&&this.b2PulleyJointDef.apply(this,arguments)}function xa(){xa.b2RevoluteJoint.apply(this,arguments);
this.constructor===xa&&this.b2RevoluteJoint.apply(this,arguments)}function ya(){ya.b2RevoluteJointDef.apply(this,arguments);this.constructor===ya&&this.b2RevoluteJointDef.apply(this,arguments)}function za(){za.b2WeldJoint.apply(this,arguments);this.constructor===za&&this.b2WeldJoint.apply(this,arguments)}function ca(){ca.b2WeldJointDef.apply(this,arguments);this.constructor===ca&&this.b2WeldJointDef.apply(this,arguments)}Box2D.Collision.IBroadPhase="Box2D.Collision.IBroadPhase";Box2D.Collision.b2AABB=
a;Box2D.Collision.b2Bound=b;Box2D.Collision.b2BoundValues=c;Box2D.Collision.b2Collision=d;Box2D.Collision.b2ContactID=e;Box2D.Collision.b2ContactPoint=f;Box2D.Collision.b2Distance=g;Box2D.Collision.b2DistanceInput=h;Box2D.Collision.b2DistanceOutput=k;Box2D.Collision.b2DistanceProxy=m;Box2D.Collision.b2DynamicTree=n;Box2D.Collision.b2DynamicTreeBroadPhase=p;Box2D.Collision.b2DynamicTreeNode=r;Box2D.Collision.b2DynamicTreePair=s;Box2D.Collision.b2Manifold=v;Box2D.Collision.b2ManifoldPoint=u;Box2D.Collision.b2Point=
t;Box2D.Collision.b2RayCastInput=x;Box2D.Collision.b2RayCastOutput=A;Box2D.Collision.b2Segment=F;Box2D.Collision.b2SeparationFunction=z;Box2D.Collision.b2Simplex=w;Box2D.Collision.b2SimplexCache=B;Box2D.Collision.b2SimplexVertex=E;Box2D.Collision.b2TimeOfImpact=I;Box2D.Collision.b2TOIInput=J;Box2D.Collision.b2WorldManifold=O;Box2D.Collision.ClipVertex=L;Box2D.Collision.Features=D;Box2D.Collision.Shapes.b2CircleShape=y;Box2D.Collision.Shapes.b2EdgeChainDef=H;Box2D.Collision.Shapes.b2EdgeShape=K;Box2D.Collision.Shapes.b2MassData=
N;Box2D.Collision.Shapes.b2PolygonShape=W;Box2D.Collision.Shapes.b2Shape=U;Box2D.Common.b2internal="Box2D.Common.b2internal";Box2D.Common.b2Color=C;Box2D.Common.b2Settings=G;Box2D.Common.Math.b2Mat22=T;Box2D.Common.Math.b2Mat33=P;Box2D.Common.Math.b2Math=R;Box2D.Common.Math.b2Sweep=M;Box2D.Common.Math.b2Transform=Y;Box2D.Common.Math.b2Vec2=V;Box2D.Common.Math.b2Vec3=pa;Box2D.Dynamics.b2Body=la;Box2D.Dynamics.b2BodyDef=ja;Box2D.Dynamics.b2ContactFilter=Aa;Box2D.Dynamics.b2ContactImpulse=ha;Box2D.Dynamics.b2ContactListener=
Oa;Box2D.Dynamics.b2ContactManager=aa;Box2D.Dynamics.b2DebugDraw=qa;Box2D.Dynamics.b2DestructionListener=ib;Box2D.Dynamics.b2FilterData=S;Box2D.Dynamics.b2Fixture=ra;Box2D.Dynamics.b2FixtureDef=sa;Box2D.Dynamics.b2Island=ta;Box2D.Dynamics.b2TimeStep=Da;Box2D.Dynamics.b2World=Z;Box2D.Dynamics.Contacts.b2CircleContact=jb;Box2D.Dynamics.Contacts.b2Contact=da;Box2D.Dynamics.Contacts.b2ContactConstraint=Sa;Box2D.Dynamics.Contacts.b2ContactConstraintPoint=fa;Box2D.Dynamics.Contacts.b2ContactEdge=kb;Box2D.Dynamics.Contacts.b2ContactFactory=
Ea;Box2D.Dynamics.Contacts.b2ContactRegister=Ta;Box2D.Dynamics.Contacts.b2ContactResult=Pa;Box2D.Dynamics.Contacts.b2ContactSolver=Ba;Box2D.Dynamics.Contacts.b2EdgeAndCircleContact=Qa;Box2D.Dynamics.Contacts.b2NullContact=ma;Box2D.Dynamics.Contacts.b2PolyAndCircleContact=Ca;Box2D.Dynamics.Contacts.b2PolyAndEdgeContact=Ra;Box2D.Dynamics.Contacts.b2PolygonContact=na;Box2D.Dynamics.Contacts.b2PositionSolverManifold=Fa;Box2D.Dynamics.Controllers.b2BuoyancyController=Ua;Box2D.Dynamics.Controllers.b2ConstantAccelController=
lb;Box2D.Dynamics.Controllers.b2ConstantForceController=Ga;Box2D.Dynamics.Controllers.b2Controller=Ha;Box2D.Dynamics.Controllers.b2ControllerEdge=ka;Box2D.Dynamics.Controllers.b2GravityController=$;Box2D.Dynamics.Controllers.b2TensorDampingController=Va;Box2D.Dynamics.Joints.b2DistanceJoint=Ia;Box2D.Dynamics.Joints.b2DistanceJointDef=Wa;Box2D.Dynamics.Joints.b2FrictionJoint=Xa;Box2D.Dynamics.Joints.b2FrictionJointDef=Ya;Box2D.Dynamics.Joints.b2GearJoint=ga;Box2D.Dynamics.Joints.b2GearJointDef=ba;
Box2D.Dynamics.Joints.b2Jacobian=ia;Box2D.Dynamics.Joints.b2Joint=ua;Box2D.Dynamics.Joints.b2JointDef=Ja;Box2D.Dynamics.Joints.b2JointEdge=Za;Box2D.Dynamics.Joints.b2LineJoint=Ka;Box2D.Dynamics.Joints.b2LineJointDef=La;Box2D.Dynamics.Joints.b2MouseJoint=va;Box2D.Dynamics.Joints.b2MouseJointDef=Ma;Box2D.Dynamics.Joints.b2PrismaticJoint=Q;Box2D.Dynamics.Joints.b2PrismaticJointDef=ea;Box2D.Dynamics.Joints.b2PulleyJoint=wa;Box2D.Dynamics.Joints.b2PulleyJointDef=$a;Box2D.Dynamics.Joints.b2RevoluteJoint=
xa;Box2D.Dynamics.Joints.b2RevoluteJointDef=ya;Box2D.Dynamics.Joints.b2WeldJoint=za;Box2D.Dynamics.Joints.b2WeldJointDef=ca})();Box2D.postDefs=[];
(function(){var a=Box2D.Collision.Shapes.b2CircleShape,b=(Box2D.Collision.Shapes.b2EdgeChainDef,Box2D.Collision.Shapes.b2EdgeShape,Box2D.Collision.Shapes.b2MassData,Box2D.Collision.Shapes.b2PolygonShape),c=Box2D.Collision.Shapes.b2Shape,d=(Box2D.Common.b2Color,Box2D.Common.b2internal,Box2D.Common.b2Settings),e=(Box2D.Common.Math.b2Mat22,Box2D.Common.Math.b2Mat33,Box2D.Common.Math.b2Math),f=Box2D.Common.Math.b2Sweep,g=Box2D.Common.Math.b2Transform,h=Box2D.Common.Math.b2Vec2,k=(Box2D.Common.Math.b2Vec3,
Box2D.Collision.b2AABB),m=Box2D.Collision.b2Bound,n=Box2D.Collision.b2BoundValues,p=Box2D.Collision.b2Collision,r=Box2D.Collision.b2ContactID,s=Box2D.Collision.b2ContactPoint,v=Box2D.Collision.b2Distance,u=Box2D.Collision.b2DistanceInput,t=Box2D.Collision.b2DistanceOutput,x=Box2D.Collision.b2DistanceProxy,A=Box2D.Collision.b2DynamicTree,F=Box2D.Collision.b2DynamicTreeBroadPhase,z=Box2D.Collision.b2DynamicTreeNode,w=Box2D.Collision.b2DynamicTreePair,B=Box2D.Collision.b2Manifold,E=Box2D.Collision.b2ManifoldPoint,
I=Box2D.Collision.b2Point,J=Box2D.Collision.b2RayCastInput,O=Box2D.Collision.b2RayCastOutput,L=Box2D.Collision.b2Segment,D=Box2D.Collision.b2SeparationFunction,y=Box2D.Collision.b2Simplex,H=Box2D.Collision.b2SimplexCache,K=Box2D.Collision.b2SimplexVertex,N=Box2D.Collision.b2TimeOfImpact,W=Box2D.Collision.b2TOIInput,U=Box2D.Collision.b2WorldManifold,C=Box2D.Collision.ClipVertex,G=Box2D.Collision.Features,T=Box2D.Collision.IBroadPhase;k.b2AABB=function(){this.lowerBound=new h;this.upperBound=new h};
k.prototype.IsValid=function(){var a=this.upperBound.y-this.lowerBound.y;return 0<=this.upperBound.x-this.lowerBound.x&&0<=a&&this.lowerBound.IsValid()&&this.upperBound.IsValid()};k.prototype.GetCenter=function(){return new h((this.lowerBound.x+this.upperBound.x)/2,(this.lowerBound.y+this.upperBound.y)/2)};k.prototype.GetExtents=function(){return new h((this.upperBound.x-this.lowerBound.x)/2,(this.upperBound.y-this.lowerBound.y)/2)};k.prototype.Contains=function(a){var b=!0;return b=b&&this.lowerBound.x<=
a.lowerBound.x,b=b&&this.lowerBound.y<=a.lowerBound.y,b=b&&a.upperBound.x<=this.upperBound.x,b&&a.upperBound.y<=this.upperBound.y};k.prototype.RayCast=function(a,b){var c=-Number.MAX_VALUE,d=Number.MAX_VALUE,e=b.p1.x,f=b.p1.y,g=b.p2.x-b.p1.x,h=b.p2.y-b.p1.y,k=Math.abs(g),m=Math.abs(h),n=a.normal,C=0,p=0,D=0,G=0,y=0;if(k<Number.MIN_VALUE){if(e<this.lowerBound.x||this.upperBound.x<e)return!1}else if(C=1/g,p=(this.lowerBound.x-e)*C,D=(this.upperBound.x-e)*C,y=-1,p>D&&(G=p,p=D,D=G,y=1),p>c&&(n.x=y,n.y=
0,c=p),d=Math.min(d,D),c>d)return!1;if(m<Number.MIN_VALUE){if(f<this.lowerBound.y||this.upperBound.y<f)return!1}else if(C=1/h,p=(this.lowerBound.y-f)*C,D=(this.upperBound.y-f)*C,y=-1,p>D&&(G=p,p=D,D=G,y=1),p>c&&(n.y=y,n.x=0,c=p),d=Math.min(d,D),c>d)return!1;return a.fraction=c,!0};k.prototype.TestOverlap=function(a){var b=a.lowerBound.y-this.upperBound.y,c=this.lowerBound.x-a.upperBound.x,d=this.lowerBound.y-a.upperBound.y;return 0<a.lowerBound.x-this.upperBound.x||0<b?!1:0<c||0<d?!1:!0};k.Combine=
function(a,b){var c=new k;return c.Combine(a,b),c};k.prototype.Combine=function(a,b){this.lowerBound.x=Math.min(a.lowerBound.x,b.lowerBound.x);this.lowerBound.y=Math.min(a.lowerBound.y,b.lowerBound.y);this.upperBound.x=Math.max(a.upperBound.x,b.upperBound.x);this.upperBound.y=Math.max(a.upperBound.y,b.upperBound.y)};m.b2Bound=function(){};m.prototype.IsLower=function(){return 0==(1&this.value)};m.prototype.IsUpper=function(){return 1==(1&this.value)};m.prototype.Swap=function(a){var b=this.value,
c=this.proxy,d=this.stabbingCount;this.value=a.value;this.proxy=a.proxy;this.stabbingCount=a.stabbingCount;a.value=b;a.proxy=c;a.stabbingCount=d};n.b2BoundValues=function(){};n.prototype.b2BoundValues=function(){this.lowerValues=new Vector_a2j_Number;this.lowerValues[0]=0;this.lowerValues[1]=0;this.upperValues=new Vector_a2j_Number;this.upperValues[0]=0;this.upperValues[1]=0};p.b2Collision=function(){};p.ClipSegmentToLine=function(a,b,c,d){void 0===d&&(d=0);var e,f=0;e=b[0];var g=e.v;e=b[1];var h=
e.v,k=c.x*g.x+c.y*g.y-d;e=c.x*h.x+c.y*h.y-d;if(0>=k&&a[f++].Set(b[0]),0>=e&&a[f++].Set(b[1]),0>k*e){c=k/(k-e);e=a[f];e=e.v;e.x=g.x+c*(h.x-g.x);e.y=g.y+c*(h.y-g.y);e=a[f];var m;0<k?(m=b[0],e.id=m.id):(m=b[1],e.id=m.id);++f}return f};p.EdgeSeparation=function(a,b,c,d,e){void 0===c&&(c=0);var f,g,h=(parseInt(a.m_vertexCount),a.m_vertices);a=a.m_normals;var k=parseInt(d.m_vertexCount),m=d.m_vertices;f=b.R;g=a[c];a=f.col1.x*g.x+f.col2.x*g.y;d=f.col1.y*g.x+f.col2.y*g.y;f=e.R;var C=f.col1.x*a+f.col1.y*d;
f=f.col2.x*a+f.col2.y*d;for(var n=0,p=Number.MAX_VALUE,D=0;k>D;++D)g=m[D],g=g.x*C+g.y*f,p>g&&(p=g,n=D);g=h[c];f=b.R;c=b.position.x+(f.col1.x*g.x+f.col2.x*g.y);b=b.position.y+(f.col1.y*g.x+f.col2.y*g.y);g=m[n];f=e.R;h=e.position.x+(f.col1.x*g.x+f.col2.x*g.y);e=e.position.y+(f.col1.y*g.x+f.col2.y*g.y);return(h-c)*a+(e-b)*d};p.FindMaxSeparation=function(a,b,c,d,e){var f,g,h=parseInt(b.m_vertexCount),k=b.m_normals;g=e.R;f=d.m_centroid;var m=e.position.x+(g.col1.x*f.x+g.col2.x*f.y),n=e.position.y+(g.col1.y*
f.x+g.col2.y*f.y);g=c.R;f=b.m_centroid;m-=c.position.x+(g.col1.x*f.x+g.col2.x*f.y);n-=c.position.y+(g.col1.y*f.x+g.col2.y*f.y);g=m*c.R.col1.x+n*c.R.col1.y;for(var n=m*c.R.col2.x+n*c.R.col2.y,m=0,C=-Number.MAX_VALUE,D=0;h>D;++D)f=k[D],f=f.x*g+f.y*n,f>C&&(C=f,m=D);k=p.EdgeSeparation(b,c,m,d,e);f=parseInt(0<=m-1?m-1:h-1);g=p.EdgeSeparation(b,c,f,d,e);var n=parseInt(h>m+1?m+1:0),C=p.EdgeSeparation(b,c,n,d,e),G=D=0,y=0;if(g>k&&g>C)y=-1,D=f,G=g;else{if(!(C>k))return a[0]=m,k;y=1;D=n;G=C}for(;!(m=-1==y?
0<=D-1?D-1:h-1:h>D+1?D+1:0,k=p.EdgeSeparation(b,c,m,d,e),!(k>G));)D=m,G=k;return a[0]=D,G};p.FindIncidentEdge=function(a,b,c,d,e,f){void 0===d&&(d=0);var g,h=(parseInt(b.m_vertexCount),b.m_normals),k=parseInt(e.m_vertexCount);b=e.m_vertices;e=e.m_normals;g=c.R;c=h[d];var h=g.col1.x*c.x+g.col2.x*c.y,m=g.col1.y*c.x+g.col2.y*c.y;g=f.R;c=g.col1.x*h+g.col1.y*m;m=g.col2.x*h+g.col2.y*m;h=c;g=0;for(var n=Number.MAX_VALUE,C=0;k>C;++C)c=e[C],c=h*c.x+m*c.y,n>c&&(n=c,g=C);e=parseInt(g);h=parseInt(k>e+1?e+1:0);
k=a[0];c=b[e];g=f.R;k.v.x=f.position.x+(g.col1.x*c.x+g.col2.x*c.y);k.v.y=f.position.y+(g.col1.y*c.x+g.col2.y*c.y);k.id.features.referenceEdge=d;k.id.features.incidentEdge=e;k.id.features.incidentVertex=0;k=a[1];c=b[h];g=f.R;k.v.x=f.position.x+(g.col1.x*c.x+g.col2.x*c.y);k.v.y=f.position.y+(g.col1.y*c.x+g.col2.y*c.y);k.id.features.referenceEdge=d;k.id.features.incidentEdge=h;k.id.features.incidentVertex=1};p.MakeClipPointVector=function(){var a=new Vector(2);return a[0]=new C,a[1]=new C,a};p.CollidePolygons=
function(a,b,c,e,f){a.m_pointCount=0;var g=b.m_radius+e.m_radius,h;p.s_edgeAO[0]=0;var k=p.FindMaxSeparation(p.s_edgeAO,b,c,e,f);if(h=p.s_edgeAO[0],!(k>g)){var m;p.s_edgeBO[0]=0;var n=p.FindMaxSeparation(p.s_edgeBO,e,f,b,c);if(m=p.s_edgeBO[0],!(n>g)){var C,D,G,y,t=0,K=0;n>0.98*k+0.001?(C=e,D=b,G=f,y=c,t=m,a.m_type=B.e_faceB,K=1):(C=b,D=e,G=c,y=f,t=h,a.m_type=B.e_faceA,K=0);b=p.s_incidentEdge;p.FindIncidentEdge(b,C,G,t,D,y);c=parseInt(C.m_vertexCount);C=C.m_vertices;D=C[t];m=c>t+1?C[parseInt(t+1)]:
C[0];t=p.s_localTangent;t.Set(m.x-D.x,m.y-D.y);t.Normalize();c=p.s_localNormal;c.x=t.y;c.y=-t.x;e=p.s_planePoint;e.Set(0.5*(D.x+m.x),0.5*(D.y+m.y));f=p.s_tangent;C=G.R;f.x=C.col1.x*t.x+C.col2.x*t.y;f.y=C.col1.y*t.x+C.col2.y*t.y;h=p.s_tangent2;h.x=-f.x;h.y=-f.y;t=p.s_normal;t.x=f.y;t.y=-f.x;k=p.s_v11;n=p.s_v12;k.x=G.position.x+(C.col1.x*D.x+C.col2.x*D.y);k.y=G.position.y+(C.col1.y*D.x+C.col2.y*D.y);n.x=G.position.x+(C.col1.x*m.x+C.col2.x*m.y);n.y=G.position.y+(C.col1.y*m.x+C.col2.y*m.y);G=t.x*k.x+
t.y*k.y;C=f.x*n.x+f.y*n.y+g;m=p.s_clipPoints1;D=p.s_clipPoints2;n=0;if(n=p.ClipSegmentToLine(m,b,h,-f.x*k.x-f.y*k.y+g),!(2>n||(n=p.ClipSegmentToLine(D,m,f,C),2>n))){a.m_localPlaneNormal.SetV(c);a.m_localPoint.SetV(e);for(e=c=0;e<d.b2_maxManifoldPoints;++e)b=D[e],g>=t.x*b.v.x+t.y*b.v.y-G&&(f=a.m_points[c],C=y.R,h=b.v.x-y.position.x,k=b.v.y-y.position.y,f.m_localPoint.x=h*C.col1.x+k*C.col1.y,f.m_localPoint.y=h*C.col2.x+k*C.col2.y,f.m_id.Set(b.id),f.m_id.features.flip=K,++c);a.m_pointCount=c}}}};p.CollideCircles=
function(a,b,c,d,e){a.m_pointCount=0;var f,g;f=c.R;g=b.m_p;var h=c.position.x+(f.col1.x*g.x+f.col2.x*g.y);c=c.position.y+(f.col1.y*g.x+f.col2.y*g.y);f=e.R;g=d.m_p;h=e.position.x+(f.col1.x*g.x+f.col2.x*g.y)-h;e=e.position.y+(f.col1.y*g.x+f.col2.y*g.y)-c;f=b.m_radius+d.m_radius;h*h+e*e>f*f||(a.m_type=B.e_circles,a.m_localPoint.SetV(b.m_p),a.m_localPlaneNormal.SetZero(),a.m_pointCount=1,a.m_points[0].m_localPoint.SetV(d.m_p),a.m_points[0].m_id.key=0)};p.CollidePolygonAndCircle=function(a,b,c,d,e){a.m_pointCount=
0;var f,g,h=0,k=0;g=e.R;f=d.m_p;var m=e.position.y+(g.col1.y*f.x+g.col2.y*f.y),h=e.position.x+(g.col1.x*f.x+g.col2.x*f.y)-c.position.x,k=m-c.position.y;g=c.R;c=h*g.col1.x+k*g.col1.y;g=h*g.col2.x+k*g.col2.y;var C=0;e=-Number.MAX_VALUE;var m=b.m_radius+d.m_radius,n=parseInt(b.m_vertexCount),p=b.m_vertices;b=b.m_normals;for(var D=0;n>D;++D){f=p[D];h=c-f.x;k=g-f.y;f=b[D];f=f.x*h+f.y*k;if(f>m)return;f>e&&(e=f,C=D)}f=parseInt(C);k=parseInt(n>f+1?f+1:0);h=p[f];p=p[k];if(e<Number.MIN_VALUE)return a.m_pointCount=
1,a.m_type=B.e_faceA,a.m_localPlaneNormal.SetV(b[C]),a.m_localPoint.x=0.5*(h.x+p.x),a.m_localPoint.y=0.5*(h.y+p.y),a.m_points[0].m_localPoint.SetV(d.m_p),void(a.m_points[0].m_id.key=0);C=(c-p.x)*(h.x-p.x)+(g-p.y)*(h.y-p.y);if(0>=(c-h.x)*(p.x-h.x)+(g-h.y)*(p.y-h.y))(c-h.x)*(c-h.x)+(g-h.y)*(g-h.y)>m*m||(a.m_pointCount=1,a.m_type=B.e_faceA,a.m_localPlaneNormal.x=c-h.x,a.m_localPlaneNormal.y=g-h.y,a.m_localPlaneNormal.Normalize(),a.m_localPoint.SetV(h),a.m_points[0].m_localPoint.SetV(d.m_p),a.m_points[0].m_id.key=
0);else if(0>=C)(c-p.x)*(c-p.x)+(g-p.y)*(g-p.y)>m*m||(a.m_pointCount=1,a.m_type=B.e_faceA,a.m_localPlaneNormal.x=c-p.x,a.m_localPlaneNormal.y=g-p.y,a.m_localPlaneNormal.Normalize(),a.m_localPoint.SetV(p),a.m_points[0].m_localPoint.SetV(d.m_p),a.m_points[0].m_id.key=0);else if(C=0.5*(h.x+p.x),h=0.5*(h.y+p.y),!(e=(c-C)*b[f].x+(g-h)*b[f].y,e>m))a.m_pointCount=1,a.m_type=B.e_faceA,a.m_localPlaneNormal.x=b[f].x,a.m_localPlaneNormal.y=b[f].y,a.m_localPlaneNormal.Normalize(),a.m_localPoint.Set(C,h),a.m_points[0].m_localPoint.SetV(d.m_p),
a.m_points[0].m_id.key=0};p.TestOverlap=function(a,b){var c=b.lowerBound,d=a.upperBound,e=c.x-d.x,f=c.y-d.y,c=a.lowerBound,d=b.upperBound,g=c.x-d.x,c=c.y-d.y;return 0<e||0<f?!1:0<g||0<c?!1:!0};Box2D.postDefs.push(function(){Box2D.Collision.b2Collision.s_incidentEdge=p.MakeClipPointVector();Box2D.Collision.b2Collision.s_clipPoints1=p.MakeClipPointVector();Box2D.Collision.b2Collision.s_clipPoints2=p.MakeClipPointVector();Box2D.Collision.b2Collision.s_edgeAO=new Vector_a2j_Number(1);Box2D.Collision.b2Collision.s_edgeBO=
new Vector_a2j_Number(1);Box2D.Collision.b2Collision.s_localTangent=new h;Box2D.Collision.b2Collision.s_localNormal=new h;Box2D.Collision.b2Collision.s_planePoint=new h;Box2D.Collision.b2Collision.s_normal=new h;Box2D.Collision.b2Collision.s_tangent=new h;Box2D.Collision.b2Collision.s_tangent2=new h;Box2D.Collision.b2Collision.s_v11=new h;Box2D.Collision.b2Collision.s_v12=new h;Box2D.Collision.b2Collision.b2CollidePolyTempVec=new h;Box2D.Collision.b2Collision.b2_nullFeature=255});r.b2ContactID=function(){this.features=
new G};r.prototype.b2ContactID=function(){this.features._m_id=this};r.prototype.Set=function(a){this.key=a._key};r.prototype.Copy=function(){var a=new r;return a.key=this.key,a};Object.defineProperty(r.prototype,"key",{enumerable:!1,configurable:!0,get:function(){return this._key}});Object.defineProperty(r.prototype,"key",{enumerable:!1,configurable:!0,set:function(a){void 0===a&&(a=0);this._key=a;this.features._referenceEdge=255&this._key;this.features._incidentEdge=(65280&this._key)>>8&255;this.features._incidentVertex=
(16711680&this._key)>>16&255;this.features._flip=(4278190080&this._key)>>24&255}});s.b2ContactPoint=function(){this.position=new h;this.velocity=new h;this.normal=new h;this.id=new r};v.b2Distance=function(){};v.Distance=function(a,b,c){++v.b2_gjkCalls;var f=c.proxyA,g=c.proxyB,k=c.transformA,m=c.transformB,C=v.s_simplex;C.ReadCache(b,f,k,g,m);var n,p=C.m_vertices,D=v.s_saveA,G=v.s_saveB,y=0;C.GetClosestPoint().LengthSquared();for(var t=0,K=0;20>K;){y=C.m_count;for(t=0;y>t;t++)D[t]=p[t].indexA,G[t]=
p[t].indexB;switch(C.m_count){case 1:break;case 2:C.Solve2();break;case 3:C.Solve3();break;default:d.b2Assert(!1)}if(3==C.m_count)break;n=C.GetClosestPoint();n.LengthSquared();t=C.GetSearchDirection();if(t.LengthSquared()<Number.MIN_VALUE*Number.MIN_VALUE)break;n=p[C.m_count];n.indexA=f.GetSupport(e.MulTMV(k.R,t.GetNegative()));n.wA=e.MulX(k,f.GetVertex(n.indexA));n.indexB=g.GetSupport(e.MulTMV(m.R,t));n.wB=e.MulX(m,g.GetVertex(n.indexB));n.w=e.SubtractVV(n.wB,n.wA);++K;++v.b2_gjkIters;for(var r=
!1,t=0;y>t;t++)if(n.indexA==D[t]&&n.indexB==G[t]){r=!0;break}if(r)break;++C.m_count}if(v.b2_gjkMaxIters=e.Max(v.b2_gjkMaxIters,K),C.GetWitnessPoints(a.pointA,a.pointB),a.distance=e.SubtractVV(a.pointA,a.pointB).Length(),a.iterations=K,C.WriteCache(b),c.useRadii)b=f.m_radius,g=g.m_radius,a.distance>b+g&&a.distance>Number.MIN_VALUE?(a.distance-=b+g,c=e.SubtractVV(a.pointB,a.pointA),c.Normalize(),a.pointA.x+=b*c.x,a.pointA.y+=b*c.y,a.pointB.x-=g*c.x,a.pointB.y-=g*c.y):(n=new h,n.x=0.5*(a.pointA.x+a.pointB.x),
n.y=0.5*(a.pointA.y+a.pointB.y),a.pointA.x=a.pointB.x=n.x,a.pointA.y=a.pointB.y=n.y,a.distance=0)};Box2D.postDefs.push(function(){Box2D.Collision.b2Distance.s_simplex=new y;Box2D.Collision.b2Distance.s_saveA=new Vector_a2j_Number(3);Box2D.Collision.b2Distance.s_saveB=new Vector_a2j_Number(3)});u.b2DistanceInput=function(){};t.b2DistanceOutput=function(){this.pointA=new h;this.pointB=new h};x.b2DistanceProxy=function(){};x.prototype.Set=function(e){switch(e.GetType()){case c.e_circleShape:e=e instanceof
a?e:null;this.m_vertices=new Vector(1,!0);this.m_vertices[0]=e.m_p;this.m_count=1;this.m_radius=e.m_radius;break;case c.e_polygonShape:e=e instanceof b?e:null;this.m_vertices=e.m_vertices;this.m_count=e.m_vertexCount;this.m_radius=e.m_radius;break;default:d.b2Assert(!1)}};x.prototype.GetSupport=function(a){for(var b=0,c=this.m_vertices[0].x*a.x+this.m_vertices[0].y*a.y,d=1;d<this.m_count;++d){var e=this.m_vertices[d].x*a.x+this.m_vertices[d].y*a.y;e>c&&(b=d,c=e)}return b};x.prototype.GetSupportVertex=
function(a){for(var b=0,c=this.m_vertices[0].x*a.x+this.m_vertices[0].y*a.y,d=1;d<this.m_count;++d){var e=this.m_vertices[d].x*a.x+this.m_vertices[d].y*a.y;e>c&&(b=d,c=e)}return this.m_vertices[b]};x.prototype.GetVertexCount=function(){return this.m_count};x.prototype.GetVertex=function(a){return void 0===a&&(a=0),d.b2Assert(0<=a&&a<this.m_count),this.m_vertices[a]};A.b2DynamicTree=function(){};A.prototype.b2DynamicTree=function(){this.m_freeList=this.m_root=null;this.m_insertionCount=this.m_path=
0};A.prototype.CreateProxy=function(a,b){var c=this.AllocateNode(),e=d.b2_aabbExtension,f=d.b2_aabbExtension;return c.aabb.lowerBound.x=a.lowerBound.x-e,c.aabb.lowerBound.y=a.lowerBound.y-f,c.aabb.upperBound.x=a.upperBound.x+e,c.aabb.upperBound.y=a.upperBound.y+f,c.userData=b,this.InsertLeaf(c),c};A.prototype.DestroyProxy=function(a){this.RemoveLeaf(a);this.FreeNode(a)};A.prototype.MoveProxy=function(a,b,c){if(d.b2Assert(a.IsLeaf()),a.aabb.Contains(b))return!1;this.RemoveLeaf(a);var e=d.b2_aabbExtension+
d.b2_aabbMultiplier*(0<c.x?c.x:-c.x);c=d.b2_aabbExtension+d.b2_aabbMultiplier*(0<c.y?c.y:-c.y);return a.aabb.lowerBound.x=b.lowerBound.x-e,a.aabb.lowerBound.y=b.lowerBound.y-c,a.aabb.upperBound.x=b.upperBound.x+e,a.aabb.upperBound.y=b.upperBound.y+c,this.InsertLeaf(a),!0};A.prototype.Rebalance=function(a){if(void 0===a&&(a=0),null!=this.m_root)for(var b=0;a>b;b++){for(var c=this.m_root,d=0;0==c.IsLeaf();)c=this.m_path>>d&1?c.child2:c.child1,d=d+1&31;++this.m_path;this.RemoveLeaf(c);this.InsertLeaf(c)}};
A.prototype.GetFatAABB=function(a){return a.aabb};A.prototype.GetUserData=function(a){return a.userData};A.prototype.Query=function(a,b){if(null!=this.m_root){var c=new Vector,d=0;for(c[d++]=this.m_root;0<d;){var e=c[--d];if(e.aabb.TestOverlap(b))if(e.IsLeaf()){if(!a(e))break}else c[d++]=e.child1,c[d++]=e.child2}}};A.prototype.RayCast=function(a,b){if(null!=this.m_root){var c=b.p1,d=b.p2,f=e.SubtractVV(c,d);f.Normalize();var f=e.CrossFV(1,f),g=e.AbsV(f),h=b.maxFraction,m=new k,C=0,n=0,C=c.x+h*(d.x-
c.x),n=c.y+h*(d.y-c.y);m.lowerBound.x=Math.min(c.x,C);m.lowerBound.y=Math.min(c.y,n);m.upperBound.x=Math.max(c.x,C);m.upperBound.y=Math.max(c.y,n);var p=new Vector,D=0;for(p[D++]=this.m_root;0<D;){var G=p[--D];if(0!=G.aabb.TestOverlap(m)){var t=G.aabb.GetCenter(),y=G.aabb.GetExtents();if(!(0<Math.abs(f.x*(c.x-t.x)+f.y*(c.y-t.y))-g.x*y.x-g.y*y.y))if(G.IsLeaf()){t=new J;if(t.p1=b.p1,t.p2=b.p2,t.maxFraction=b.maxFraction,h=a(t,G),0==h)break;0<h&&(C=c.x+h*(d.x-c.x),n=c.y+h*(d.y-c.y),m.lowerBound.x=Math.min(c.x,
C),m.lowerBound.y=Math.min(c.y,n),m.upperBound.x=Math.max(c.x,C),m.upperBound.y=Math.max(c.y,n))}else p[D++]=G.child1,p[D++]=G.child2}}}};A.prototype.AllocateNode=function(){if(this.m_freeList){var a=this.m_freeList;return this.m_freeList=a.parent,a.parent=null,a.child1=null,a.child2=null,a}return new z};A.prototype.FreeNode=function(a){a.parent=this.m_freeList;this.m_freeList=a};A.prototype.InsertLeaf=function(a){if(++this.m_insertionCount,null==this.m_root)return this.m_root=a,void(this.m_root.parent=
null);var b=a.aabb.GetCenter(),c=this.m_root;if(0==c.IsLeaf()){do var d=c.child1,c=c.child2,e=Math.abs((d.aabb.lowerBound.x+d.aabb.upperBound.x)/2-b.x)+Math.abs((d.aabb.lowerBound.y+d.aabb.upperBound.y)/2-b.y),c=Math.abs((c.aabb.lowerBound.x+c.aabb.upperBound.x)/2-b.x)+Math.abs((c.aabb.lowerBound.y+c.aabb.upperBound.y)/2-b.y)>e?d:c;while(0==c.IsLeaf())}b=c.parent;d=this.AllocateNode();if(d.parent=b,d.userData=null,d.aabb.Combine(a.aabb,c.aabb),b){c.parent.child1==c?b.child1=d:b.child2=d;d.child1=
c;d.child2=a;c.parent=d;a.parent=d;do{if(b.aabb.Contains(d.aabb))break;b.aabb.Combine(b.child1.aabb,b.child2.aabb);d=b;b=b.parent}while(b)}else d.child1=c,d.child2=a,c.parent=d,this.m_root=a.parent=d};A.prototype.RemoveLeaf=function(a){if(a==this.m_root)return void(this.m_root=null);var b=a.parent,c=b.parent;if(a=b.child1==a?b.child2:b.child1,c){c.child1==b?c.child1=a:c.child2=a;a.parent=c;for(this.FreeNode(b);c;){b=c.aabb;if(c.aabb=k.Combine(c.child1.aabb,c.child2.aabb),b.Contains(c.aabb))break;
c=c.parent}}else this.m_root=a,a.parent=null,this.FreeNode(b)};F.b2DynamicTreeBroadPhase=function(){this.m_tree=new A;this.m_moveBuffer=new Vector;this.m_pairBuffer=new Vector;this.m_pairCount=0};F.prototype.CreateProxy=function(a,b){var c=this.m_tree.CreateProxy(a,b);return++this.m_proxyCount,this.BufferMove(c),c};F.prototype.DestroyProxy=function(a){this.UnBufferMove(a);--this.m_proxyCount;this.m_tree.DestroyProxy(a)};F.prototype.MoveProxy=function(a,b,c){this.m_tree.MoveProxy(a,b,c)&&this.BufferMove(a)};
F.prototype.TestOverlap=function(a,b){var c=this.m_tree.GetFatAABB(a),d=this.m_tree.GetFatAABB(b);return c.TestOverlap(d)};F.prototype.GetUserData=function(a){return this.m_tree.GetUserData(a)};F.prototype.GetFatAABB=function(a){return this.m_tree.GetFatAABB(a)};F.prototype.GetProxyCount=function(){return this.m_proxyCount};F.prototype.UpdatePairs=function(a){function b(a){if(a==d)return!0;c.m_pairCount==c.m_pairBuffer.length&&(c.m_pairBuffer[c.m_pairCount]=new w);var e=c.m_pairBuffer[c.m_pairCount];
return e.proxyA=d>a?a:d,e.proxyB=a>=d?a:d,++c.m_pairCount,!0}var c=this;c.m_pairCount=0;for(var d,e=0,e=0;e<c.m_moveBuffer.length;++e){d=c.m_moveBuffer[e];var f=c.m_tree.GetFatAABB(d);c.m_tree.Query(b,f)}for(e=c.m_moveBuffer.length=0;e<c.m_pairCount;){var f=c.m_pairBuffer[e],g=c.m_tree.GetUserData(f.proxyA),h=c.m_tree.GetUserData(f.proxyB);a(g,h);for(++e;e<c.m_pairCount;){g=c.m_pairBuffer[e];if(g.proxyA!=f.proxyA||g.proxyB!=f.proxyB)break;++e}}};F.prototype.Query=function(a,b){this.m_tree.Query(a,
b)};F.prototype.RayCast=function(a,b){this.m_tree.RayCast(a,b)};F.prototype.Validate=function(){};F.prototype.Rebalance=function(a){void 0===a&&(a=0);this.m_tree.Rebalance(a)};F.prototype.BufferMove=function(a){this.m_moveBuffer[this.m_moveBuffer.length]=a};F.prototype.UnBufferMove=function(a){a=parseInt(this.m_moveBuffer.indexOf(a));this.m_moveBuffer.splice(a,1)};F.prototype.ComparePairs=function(a,b){return 0};F.__implements={};F.__implements[T]=!0;z.b2DynamicTreeNode=function(){this.aabb=new k};
z.prototype.IsLeaf=function(){return null==this.child1};w.b2DynamicTreePair=function(){};B.b2Manifold=function(){this.m_pointCount=0};B.prototype.b2Manifold=function(){this.m_points=new Vector(d.b2_maxManifoldPoints);for(var a=0;a<d.b2_maxManifoldPoints;a++)this.m_points[a]=new E;this.m_localPlaneNormal=new h;this.m_localPoint=new h};B.prototype.Reset=function(){for(var a=0;a<d.b2_maxManifoldPoints;a++)(this.m_points[a]instanceof E?this.m_points[a]:null).Reset();this.m_localPlaneNormal.SetZero();
this.m_localPoint.SetZero();this.m_pointCount=this.m_type=0};B.prototype.Set=function(a){this.m_pointCount=a.m_pointCount;for(var b=0;b<d.b2_maxManifoldPoints;b++)(this.m_points[b]instanceof E?this.m_points[b]:null).Set(a.m_points[b]);this.m_localPlaneNormal.SetV(a.m_localPlaneNormal);this.m_localPoint.SetV(a.m_localPoint);this.m_type=a.m_type};B.prototype.Copy=function(){var a=new B;return a.Set(this),a};Box2D.postDefs.push(function(){Box2D.Collision.b2Manifold.e_circles=1;Box2D.Collision.b2Manifold.e_faceA=
2;Box2D.Collision.b2Manifold.e_faceB=4});E.b2ManifoldPoint=function(){this.m_localPoint=new h;this.m_id=new r};E.prototype.b2ManifoldPoint=function(){this.Reset()};E.prototype.Reset=function(){this.m_localPoint.SetZero();this.m_tangentImpulse=this.m_normalImpulse=0;this.m_id.key=0};E.prototype.Set=function(a){this.m_localPoint.SetV(a.m_localPoint);this.m_normalImpulse=a.m_normalImpulse;this.m_tangentImpulse=a.m_tangentImpulse;this.m_id.Set(a.m_id)};I.b2Point=function(){this.p=new h};I.prototype.Support=
function(a,b,c){return this.p};I.prototype.GetFirstVertex=function(a){return this.p};J.b2RayCastInput=function(){this.p1=new h;this.p2=new h};J.prototype.b2RayCastInput=function(a,b,c){void 0===a&&(a=null);void 0===b&&(b=null);void 0===c&&(c=1);a&&this.p1.SetV(a);b&&this.p2.SetV(b);this.maxFraction=c};O.b2RayCastOutput=function(){this.normal=new h};L.b2Segment=function(){this.p1=new h;this.p2=new h};L.prototype.TestSegment=function(a,b,c,d){void 0===d&&(d=0);var e=c.p1,f=c.p2.x-e.x,g=c.p2.y-e.y;c=
this.p2.y-this.p1.y;var h=-(this.p2.x-this.p1.x),k=100*Number.MIN_VALUE,m=-(f*c+g*h);if(m>k){var C=e.x-this.p1.x,n=e.y-this.p1.y,e=C*c+n*h;if(0<=e&&d*m>=e&&(d=-f*n+g*C,d>=-k*m&&m*(1+k)>=d))return e/=m,d=Math.sqrt(c*c+h*h),c/=d,h/=d,a[0]=e,b.Set(c,h),!0}return!1};L.prototype.Extend=function(a){this.ExtendForward(a);this.ExtendBackward(a)};L.prototype.ExtendForward=function(a){var b=this.p2.x-this.p1.x,c=this.p2.y-this.p1.y;a=Math.min(0<b?(a.upperBound.x-this.p1.x)/b:0>b?(a.lowerBound.x-this.p1.x)/
b:Number.POSITIVE_INFINITY,0<c?(a.upperBound.y-this.p1.y)/c:0>c?(a.lowerBound.y-this.p1.y)/c:Number.POSITIVE_INFINITY);this.p2.x=this.p1.x+b*a;this.p2.y=this.p1.y+c*a};L.prototype.ExtendBackward=function(a){var b=-this.p2.x+this.p1.x,c=-this.p2.y+this.p1.y;a=Math.min(0<b?(a.upperBound.x-this.p2.x)/b:0>b?(a.lowerBound.x-this.p2.x)/b:Number.POSITIVE_INFINITY,0<c?(a.upperBound.y-this.p2.y)/c:0>c?(a.lowerBound.y-this.p2.y)/c:Number.POSITIVE_INFINITY);this.p1.x=this.p2.x+b*a;this.p1.y=this.p2.y+c*a};D.b2SeparationFunction=
function(){this.m_localPoint=new h;this.m_axis=new h};D.prototype.Initialize=function(a,b,c,f,g){this.m_proxyA=b;this.m_proxyB=f;var k=parseInt(a.count);d.b2Assert(0<k&&3>k);var m,C,n,p,G=p=n=f=b=0,t=0,G=0;1==k?(this.m_type=D.e_points,m=this.m_proxyA.GetVertex(a.indexA[0]),C=this.m_proxyB.GetVertex(a.indexB[0]),k=m,a=c.R,b=c.position.x+(a.col1.x*k.x+a.col2.x*k.y),f=c.position.y+(a.col1.y*k.x+a.col2.y*k.y),k=C,a=g.R,n=g.position.x+(a.col1.x*k.x+a.col2.x*k.y),p=g.position.y+(a.col1.y*k.x+a.col2.y*k.y),
this.m_axis.x=n-b,this.m_axis.y=p-f,this.m_axis.Normalize()):a.indexB[0]==a.indexB[1]?(this.m_type=D.e_faceA,b=this.m_proxyA.GetVertex(a.indexA[0]),f=this.m_proxyA.GetVertex(a.indexA[1]),C=this.m_proxyB.GetVertex(a.indexB[0]),this.m_localPoint.x=0.5*(b.x+f.x),this.m_localPoint.y=0.5*(b.y+f.y),this.m_axis=e.CrossVF(e.SubtractVV(f,b),1),this.m_axis.Normalize(),k=this.m_axis,a=c.R,G=a.col1.x*k.x+a.col2.x*k.y,t=a.col1.y*k.x+a.col2.y*k.y,k=this.m_localPoint,a=c.R,b=c.position.x+(a.col1.x*k.x+a.col2.x*
k.y),f=c.position.y+(a.col1.y*k.x+a.col2.y*k.y),k=C,a=g.R,n=g.position.x+(a.col1.x*k.x+a.col2.x*k.y),p=g.position.y+(a.col1.y*k.x+a.col2.y*k.y),0>(n-b)*G+(p-f)*t&&this.m_axis.NegativeSelf()):a.indexA[0]==a.indexA[0]?(this.m_type=D.e_faceB,n=this.m_proxyB.GetVertex(a.indexB[0]),p=this.m_proxyB.GetVertex(a.indexB[1]),m=this.m_proxyA.GetVertex(a.indexA[0]),this.m_localPoint.x=0.5*(n.x+p.x),this.m_localPoint.y=0.5*(n.y+p.y),this.m_axis=e.CrossVF(e.SubtractVV(p,n),1),this.m_axis.Normalize(),k=this.m_axis,
a=g.R,G=a.col1.x*k.x+a.col2.x*k.y,t=a.col1.y*k.x+a.col2.y*k.y,k=this.m_localPoint,a=g.R,n=g.position.x+(a.col1.x*k.x+a.col2.x*k.y),p=g.position.y+(a.col1.y*k.x+a.col2.y*k.y),k=m,a=c.R,b=c.position.x+(a.col1.x*k.x+a.col2.x*k.y),f=c.position.y+(a.col1.y*k.x+a.col2.y*k.y),0>(b-n)*G+(f-p)*t&&this.m_axis.NegativeSelf()):(b=this.m_proxyA.GetVertex(a.indexA[0]),f=this.m_proxyA.GetVertex(a.indexA[1]),n=this.m_proxyB.GetVertex(a.indexB[0]),p=this.m_proxyB.GetVertex(a.indexB[1]),m=(e.MulX(c,m),e.MulMV(c.R,
e.SubtractVV(f,b))),G=(e.MulX(g,C),e.MulMV(g.R,e.SubtractVV(p,n))),g=m.x*m.x+m.y*m.y,C=G.x*G.x+G.y*G.y,a=e.SubtractVV(G,m),c=m.x*a.x+m.y*a.y,a=G.x*a.x+G.y*a.y,m=m.x*G.x+m.y*G.y,t=g*C-m*m,G=0,0!=t&&(G=e.Clamp((m*a-c*C)/t,0,1)),0>(m*G+a)/C&&(G=e.Clamp((m-c)/g,0,1)),m=new h,m.x=b.x+G*(f.x-b.x),m.y=b.y+G*(f.y-b.y),C=new h,C.x=n.x+G*(p.x-n.x),C.y=n.y+G*(p.y-n.y),0==G||1==G?(this.m_type=D.e_faceB,this.m_axis=e.CrossVF(e.SubtractVV(p,n),1),this.m_axis.Normalize(),this.m_localPoint=C,0>G&&this.m_axis.NegativeSelf()):
(this.m_type=D.e_faceA,this.m_axis=e.CrossVF(e.SubtractVV(f,b),1),this.m_localPoint=m,0>G&&this.m_axis.NegativeSelf()))};D.prototype.Evaluate=function(a,b){var c,f,g,h,k,m,C;switch(this.m_type){case D.e_points:return c=e.MulTMV(a.R,this.m_axis),f=e.MulTMV(b.R,this.m_axis.GetNegative()),g=this.m_proxyA.GetSupportVertex(c),h=this.m_proxyB.GetSupportVertex(f),k=e.MulX(a,g),m=e.MulX(b,h),(m.x-k.x)*this.m_axis.x+(m.y-k.y)*this.m_axis.y;case D.e_faceA:return C=e.MulMV(a.R,this.m_axis),k=e.MulX(a,this.m_localPoint),
f=e.MulTMV(b.R,C.GetNegative()),h=this.m_proxyB.GetSupportVertex(f),m=e.MulX(b,h),(m.x-k.x)*C.x+(m.y-k.y)*C.y;case D.e_faceB:return C=e.MulMV(b.R,this.m_axis),m=e.MulX(b,this.m_localPoint),c=e.MulTMV(a.R,C.GetNegative()),g=this.m_proxyA.GetSupportVertex(c),k=e.MulX(a,g),(k.x-m.x)*C.x+(k.y-m.y)*C.y;default:return d.b2Assert(!1),0}};Box2D.postDefs.push(function(){Box2D.Collision.b2SeparationFunction.e_points=1;Box2D.Collision.b2SeparationFunction.e_faceA=2;Box2D.Collision.b2SeparationFunction.e_faceB=
4});y.b2Simplex=function(){this.m_v1=new K;this.m_v2=new K;this.m_v3=new K;this.m_vertices=new Vector(3)};y.prototype.b2Simplex=function(){this.m_vertices[0]=this.m_v1;this.m_vertices[1]=this.m_v2;this.m_vertices[2]=this.m_v3};y.prototype.ReadCache=function(a,b,c,f,g){d.b2Assert(0<=a.count&&3>=a.count);var h,k;this.m_count=a.count;for(var m=this.m_vertices,C=0;C<this.m_count;C++){var n=m[C];n.indexA=a.indexA[C];n.indexB=a.indexB[C];h=b.GetVertex(n.indexA);k=f.GetVertex(n.indexB);n.wA=e.MulX(c,h);
n.wB=e.MulX(g,k);n.w=e.SubtractVV(n.wB,n.wA);n.a=0}1<this.m_count&&(a=a.metric,C=this.GetMetric(),(0.5*a>C||C>2*a||C<Number.MIN_VALUE)&&(this.m_count=0));0==this.m_count&&(n=m[0],n.indexA=0,n.indexB=0,h=b.GetVertex(0),k=f.GetVertex(0),n.wA=e.MulX(c,h),n.wB=e.MulX(g,k),n.w=e.SubtractVV(n.wB,n.wA),this.m_count=1)};y.prototype.WriteCache=function(a){a.metric=this.GetMetric();a.count=Box2D.parseUInt(this.m_count);for(var b=this.m_vertices,c=0;c<this.m_count;c++)a.indexA[c]=Box2D.parseUInt(b[c].indexA),
a.indexB[c]=Box2D.parseUInt(b[c].indexB)};y.prototype.GetSearchDirection=function(){switch(this.m_count){case 1:return this.m_v1.w.GetNegative();case 2:var a=e.SubtractVV(this.m_v2.w,this.m_v1.w);return 0<e.CrossVV(a,this.m_v1.w.GetNegative())?e.CrossFV(1,a):e.CrossVF(a,1);default:return d.b2Assert(!1),new h}};y.prototype.GetClosestPoint=function(){switch(this.m_count){case 0:return d.b2Assert(!1),new h;case 1:return this.m_v1.w;case 2:return new h(this.m_v1.a*this.m_v1.w.x+this.m_v2.a*this.m_v2.w.x,
this.m_v1.a*this.m_v1.w.y+this.m_v2.a*this.m_v2.w.y);default:return d.b2Assert(!1),new h}};y.prototype.GetWitnessPoints=function(a,b){switch(this.m_count){case 0:d.b2Assert(!1);break;case 1:a.SetV(this.m_v1.wA);b.SetV(this.m_v1.wB);break;case 2:a.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x;a.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y;b.x=this.m_v1.a*this.m_v1.wB.x+this.m_v2.a*this.m_v2.wB.x;b.y=this.m_v1.a*this.m_v1.wB.y+this.m_v2.a*this.m_v2.wB.y;break;case 3:b.x=a.x=this.m_v1.a*
this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x+this.m_v3.a*this.m_v3.wA.x;b.y=a.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y+this.m_v3.a*this.m_v3.wA.y;break;default:d.b2Assert(!1)}};y.prototype.GetMetric=function(){switch(this.m_count){case 0:return d.b2Assert(!1),0;case 1:return 0;case 2:return e.SubtractVV(this.m_v1.w,this.m_v2.w).Length();case 3:return e.CrossVV(e.SubtractVV(this.m_v2.w,this.m_v1.w),e.SubtractVV(this.m_v3.w,this.m_v1.w));default:return d.b2Assert(!1),0}};y.prototype.Solve2=
function(){var a=this.m_v1.w,b=this.m_v2.w,c=e.SubtractVV(b,a),a=-(a.x*c.x+a.y*c.y);if(0>=a)return this.m_v1.a=1,void(this.m_count=1);b=b.x*c.x+b.y*c.y;if(0>=b)return this.m_v2.a=1,this.m_count=1,void this.m_v1.Set(this.m_v2);c=1/(b+a);this.m_v1.a=b*c;this.m_v2.a=a*c;this.m_count=2};y.prototype.Solve3=function(){var a=this.m_v1.w,b=this.m_v2.w,c=this.m_v3.w,d=e.SubtractVV(b,a),f=e.Dot(a,d),g=e.Dot(b,d),f=-f,h=e.SubtractVV(c,a),k=e.Dot(a,h),m=e.Dot(c,h),k=-k,C=e.SubtractVV(c,b),n=e.Dot(b,C),C=e.Dot(c,
C),n=-n,h=e.CrossVV(d,h),d=h*e.CrossVV(b,c),c=h*e.CrossVV(c,a),a=h*e.CrossVV(a,b);if(0>=f&&0>=k)return this.m_v1.a=1,void(this.m_count=1);if(0<g&&0<f&&0>=a)return m=1/(g+f),this.m_v1.a=g*m,this.m_v2.a=f*m,void(this.m_count=2);if(0<m&&0<k&&0>=c)return g=1/(m+k),this.m_v1.a=m*g,this.m_v3.a=k*g,this.m_count=2,void this.m_v2.Set(this.m_v3);if(0>=g&&0>=n)return this.m_v2.a=1,this.m_count=1,void this.m_v1.Set(this.m_v2);if(0>=m&&0>=C)return this.m_v3.a=1,this.m_count=1,void this.m_v1.Set(this.m_v3);if(0<
C&&0<n&&0>=d)return g=1/(C+n),this.m_v2.a=C*g,this.m_v3.a=n*g,this.m_count=2,void this.m_v1.Set(this.m_v3);g=1/(d+c+a);this.m_v1.a=d*g;this.m_v2.a=c*g;this.m_v3.a=a*g;this.m_count=3};H.b2SimplexCache=function(){this.indexA=new Vector_a2j_Number(3);this.indexB=new Vector_a2j_Number(3)};K.b2SimplexVertex=function(){};K.prototype.Set=function(a){this.wA.SetV(a.wA);this.wB.SetV(a.wB);this.w.SetV(a.w);this.a=a.a;this.indexA=a.indexA;this.indexB=a.indexB};N.b2TimeOfImpact=function(){};N.TimeOfImpact=function(a){++N.b2_toiCalls;
var b=a.proxyA,c=a.proxyB,f=a.sweepA,g=a.sweepB;d.b2Assert(f.t0==g.t0);d.b2Assert(1-f.t0>Number.MIN_VALUE);var h=b.m_radius+c.m_radius;a=a.tolerance;var k=0,m=0,C=0;N.s_cache.count=0;for(N.s_distanceInput.useRadii=!1;;){if(f.GetTransform(N.s_xfA,k),g.GetTransform(N.s_xfB,k),N.s_distanceInput.proxyA=b,N.s_distanceInput.proxyB=c,N.s_distanceInput.transformA=N.s_xfA,N.s_distanceInput.transformB=N.s_xfB,v.Distance(N.s_distanceOutput,N.s_cache,N.s_distanceInput),0>=N.s_distanceOutput.distance){k=1;break}N.s_fcn.Initialize(N.s_cache,
b,N.s_xfA,c,N.s_xfB);var n=N.s_fcn.Evaluate(N.s_xfA,N.s_xfB);if(0>=n){k=1;break}if(0==m&&(C=n>h?e.Max(h-a,0.75*h):e.Max(n-a,0.02*h)),0.5*a>n-C){if(0==m){k=1;break}break}var p=k,D=k,G=1;f.GetTransform(N.s_xfA,G);g.GetTransform(N.s_xfB,G);var t=N.s_fcn.Evaluate(N.s_xfA,N.s_xfB);if(t>=C){k=1;break}for(var y=0;;){var K=0,K=1&y?D+(C-n)*(G-D)/(t-n):0.5*(D+G);f.GetTransform(N.s_xfA,K);g.GetTransform(N.s_xfB,K);var r=N.s_fcn.Evaluate(N.s_xfA,N.s_xfB);if(e.Abs(r-C)<0.025*a){p=K;break}if(r>C?(D=K,n=r):(G=K,
t=r),++y,++N.b2_toiRootIters,50==y)break}if(N.b2_toiMaxRootIters=e.Max(N.b2_toiMaxRootIters,y),p<(1+100*Number.MIN_VALUE)*k)break;if(k=p,m++,++N.b2_toiIters,1E3==m)break}return N.b2_toiMaxIters=e.Max(N.b2_toiMaxIters,m),k};Box2D.postDefs.push(function(){Box2D.Collision.b2TimeOfImpact.b2_toiCalls=0;Box2D.Collision.b2TimeOfImpact.b2_toiIters=0;Box2D.Collision.b2TimeOfImpact.b2_toiMaxIters=0;Box2D.Collision.b2TimeOfImpact.b2_toiRootIters=0;Box2D.Collision.b2TimeOfImpact.b2_toiMaxRootIters=0;Box2D.Collision.b2TimeOfImpact.s_cache=
new H;Box2D.Collision.b2TimeOfImpact.s_distanceInput=new u;Box2D.Collision.b2TimeOfImpact.s_xfA=new g;Box2D.Collision.b2TimeOfImpact.s_xfB=new g;Box2D.Collision.b2TimeOfImpact.s_fcn=new D;Box2D.Collision.b2TimeOfImpact.s_distanceOutput=new t});W.b2TOIInput=function(){this.proxyA=new x;this.proxyB=new x;this.sweepA=new f;this.sweepB=new f};U.b2WorldManifold=function(){this.m_normal=new h};U.prototype.b2WorldManifold=function(){this.m_points=new Vector(d.b2_maxManifoldPoints);for(var a=0;a<d.b2_maxManifoldPoints;a++)this.m_points[a]=
new h};U.prototype.Initialize=function(a,b,c,d,e){if(void 0===c&&(c=0),void 0===e&&(e=0),0!=a.m_pointCount){var f,g,h=0,k=0,m=0,C=0,n=0,p=0;f=0;switch(a.m_type){case B.e_circles:g=b.R;f=a.m_localPoint;h=b.position.x+g.col1.x*f.x+g.col2.x*f.y;b=b.position.y+g.col1.y*f.x+g.col2.y*f.y;g=d.R;f=a.m_points[0].m_localPoint;a=d.position.x+g.col1.x*f.x+g.col2.x*f.y;d=d.position.y+g.col1.y*f.x+g.col2.y*f.y;f=a-h;g=d-b;k=f*f+g*g;k>Number.MIN_VALUE*Number.MIN_VALUE?(k=Math.sqrt(k),this.m_normal.x=f/k,this.m_normal.y=
g/k):(this.m_normal.x=1,this.m_normal.y=0);f=b+c*this.m_normal.y;d-=e*this.m_normal.y;this.m_points[0].x=0.5*(h+c*this.m_normal.x+(a-e*this.m_normal.x));this.m_points[0].y=0.5*(f+d);break;case B.e_faceA:g=b.R;f=a.m_localPlaneNormal;k=g.col1.x*f.x+g.col2.x*f.y;m=g.col1.y*f.x+g.col2.y*f.y;g=b.R;f=a.m_localPoint;C=b.position.x+g.col1.x*f.x+g.col2.x*f.y;n=b.position.y+g.col1.y*f.x+g.col2.y*f.y;this.m_normal.x=k;this.m_normal.y=m;for(h=0;h<a.m_pointCount;h++)g=d.R,f=a.m_points[h].m_localPoint,p=d.position.x+
g.col1.x*f.x+g.col2.x*f.y,f=d.position.y+g.col1.y*f.x+g.col2.y*f.y,this.m_points[h].x=p+0.5*(c-(p-C)*k-(f-n)*m-e)*k,this.m_points[h].y=f+0.5*(c-(p-C)*k-(f-n)*m-e)*m;break;case B.e_faceB:g=d.R;f=a.m_localPlaneNormal;k=g.col1.x*f.x+g.col2.x*f.y;m=g.col1.y*f.x+g.col2.y*f.y;g=d.R;f=a.m_localPoint;C=d.position.x+g.col1.x*f.x+g.col2.x*f.y;n=d.position.y+g.col1.y*f.x+g.col2.y*f.y;this.m_normal.x=-k;this.m_normal.y=-m;for(h=0;h<a.m_pointCount;h++)g=b.R,f=a.m_points[h].m_localPoint,p=b.position.x+g.col1.x*
f.x+g.col2.x*f.y,f=b.position.y+g.col1.y*f.x+g.col2.y*f.y,this.m_points[h].x=p+0.5*(e-(p-C)*k-(f-n)*m-c)*k,this.m_points[h].y=f+0.5*(e-(p-C)*k-(f-n)*m-c)*m}}};C.ClipVertex=function(){this.v=new h;this.id=new r};C.prototype.Set=function(a){this.v.SetV(a.v);this.id.Set(a.id)};G.Features=function(){};Object.defineProperty(G.prototype,"referenceEdge",{enumerable:!1,configurable:!0,get:function(){return this._referenceEdge}});Object.defineProperty(G.prototype,"referenceEdge",{enumerable:!1,configurable:!0,
set:function(a){void 0===a&&(a=0);this._referenceEdge=a;this._m_id._key=4294967040&this._m_id._key|255&this._referenceEdge}});Object.defineProperty(G.prototype,"incidentEdge",{enumerable:!1,configurable:!0,get:function(){return this._incidentEdge}});Object.defineProperty(G.prototype,"incidentEdge",{enumerable:!1,configurable:!0,set:function(a){void 0===a&&(a=0);this._incidentEdge=a;this._m_id._key=4294902015&this._m_id._key|this._incidentEdge<<8&65280}});Object.defineProperty(G.prototype,"incidentVertex",
{enumerable:!1,configurable:!0,get:function(){return this._incidentVertex}});Object.defineProperty(G.prototype,"incidentVertex",{enumerable:!1,configurable:!0,set:function(a){void 0===a&&(a=0);this._incidentVertex=a;this._m_id._key=4278255615&this._m_id._key|this._incidentVertex<<16&16711680}});Object.defineProperty(G.prototype,"flip",{enumerable:!1,configurable:!0,get:function(){return this._flip}});Object.defineProperty(G.prototype,"flip",{enumerable:!1,configurable:!0,set:function(a){void 0===
a&&(a=0);this._flip=a;this._m_id._key=16777215&this._m_id._key|this._flip<<24&4278190080}})})();
(function(){var a=(Box2D.Common.b2Color,Box2D.Common.b2internal,Box2D.Common.b2Settings),b=Box2D.Collision.Shapes.b2CircleShape,c=Box2D.Collision.Shapes.b2EdgeChainDef,d=Box2D.Collision.Shapes.b2EdgeShape,e=Box2D.Collision.Shapes.b2MassData,f=Box2D.Collision.Shapes.b2PolygonShape,g=Box2D.Collision.Shapes.b2Shape,h=Box2D.Common.Math.b2Mat22,k=(Box2D.Common.Math.b2Mat33,Box2D.Common.Math.b2Math),m=(Box2D.Common.Math.b2Sweep,Box2D.Common.Math.b2Transform),n=Box2D.Common.Math.b2Vec2,p=(Box2D.Common.Math.b2Vec3,
Box2D.Dynamics.b2Body,Box2D.Dynamics.b2BodyDef,Box2D.Dynamics.b2ContactFilter,Box2D.Dynamics.b2ContactImpulse,Box2D.Dynamics.b2ContactListener,Box2D.Dynamics.b2ContactManager,Box2D.Dynamics.b2DebugDraw,Box2D.Dynamics.b2DestructionListener,Box2D.Dynamics.b2FilterData,Box2D.Dynamics.b2Fixture,Box2D.Dynamics.b2FixtureDef,Box2D.Dynamics.b2Island,Box2D.Dynamics.b2TimeStep,Box2D.Dynamics.b2World,Box2D.Collision.b2AABB,Box2D.Collision.b2Bound,Box2D.Collision.b2BoundValues,Box2D.Collision.b2Collision,Box2D.Collision.b2ContactID,
Box2D.Collision.b2ContactPoint,Box2D.Collision.b2Distance),r=Box2D.Collision.b2DistanceInput,s=Box2D.Collision.b2DistanceOutput,v=Box2D.Collision.b2DistanceProxy,u=(Box2D.Collision.b2DynamicTree,Box2D.Collision.b2DynamicTreeBroadPhase,Box2D.Collision.b2DynamicTreeNode,Box2D.Collision.b2DynamicTreePair,Box2D.Collision.b2Manifold,Box2D.Collision.b2ManifoldPoint,Box2D.Collision.b2Point,Box2D.Collision.b2RayCastInput,Box2D.Collision.b2RayCastOutput,Box2D.Collision.b2Segment,Box2D.Collision.b2SeparationFunction,
Box2D.Collision.b2Simplex,Box2D.Collision.b2SimplexCache);Box2D.Collision.b2SimplexVertex;Box2D.Collision.b2TimeOfImpact;Box2D.Collision.b2TOIInput;Box2D.Collision.b2WorldManifold;Box2D.Collision.ClipVertex;Box2D.Collision.Features;Box2D.Collision.IBroadPhase;Box2D.inherit(b,Box2D.Collision.Shapes.b2Shape);b.prototype.__super=Box2D.Collision.Shapes.b2Shape.prototype;b.b2CircleShape=function(){Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this,arguments);this.m_p=new n};b.prototype.Copy=function(){var a=
new b;return a.Set(this),a};b.prototype.Set=function(a){if(this.__super.Set.call(this,a),Box2D.is(a,b))this.m_p.SetV((a instanceof b?a:null).m_p)};b.prototype.TestPoint=function(a,b){var c=a.R,d=a.position.x+(c.col1.x*this.m_p.x+c.col2.x*this.m_p.y),c=a.position.y+(c.col1.y*this.m_p.x+c.col2.y*this.m_p.y);return d=b.x-d,c=b.y-c,d*d+c*c<=this.m_radius*this.m_radius};b.prototype.RayCast=function(a,b,c){var d=c.R,e=b.p1.x-(c.position.x+(d.col1.x*this.m_p.x+d.col2.x*this.m_p.y));c=b.p1.y-(c.position.y+
(d.col1.y*this.m_p.x+d.col2.y*this.m_p.y));var d=b.p2.x-b.p1.x,f=b.p2.y-b.p1.y,g=e*d+c*f,h=d*d+f*f,k=g*g-h*(e*e+c*c-this.m_radius*this.m_radius);if(0>k||h<Number.MIN_VALUE)return!1;g=-(g+Math.sqrt(k));return 0<=g&&g<=b.maxFraction*h?(g/=h,a.fraction=g,a.normal.x=e+g*d,a.normal.y=c+g*f,a.normal.Normalize(),!0):!1};b.prototype.ComputeAABB=function(a,b){var c=b.R,d=b.position.x+(c.col1.x*this.m_p.x+c.col2.x*this.m_p.y),c=b.position.y+(c.col1.y*this.m_p.x+c.col2.y*this.m_p.y);a.lowerBound.Set(d-this.m_radius,
c-this.m_radius);a.upperBound.Set(d+this.m_radius,c+this.m_radius)};b.prototype.ComputeMass=function(b,c){void 0===c&&(c=0);b.mass=c*a.b2_pi*this.m_radius*this.m_radius;b.center.SetV(this.m_p);b.I=b.mass*(0.5*this.m_radius*this.m_radius+(this.m_p.x*this.m_p.x+this.m_p.y*this.m_p.y))};b.prototype.ComputeSubmergedArea=function(a,b,c,d){void 0===b&&(b=0);c=k.MulX(c,this.m_p);var e=-(k.Dot(a,c)-b);if(e<-this.m_radius+Number.MIN_VALUE)return 0;if(e>this.m_radius)return d.SetV(c),Math.PI*this.m_radius*
this.m_radius;b=this.m_radius*this.m_radius;var f=e*e,e=b*(Math.asin(e/this.m_radius)+Math.PI/2)+e*Math.sqrt(b-f);b=-2/3*Math.pow(b-f,1.5)/e;return d.x=c.x+a.x*b,d.y=c.y+a.y*b,e};b.prototype.GetLocalPosition=function(){return this.m_p};b.prototype.SetLocalPosition=function(a){this.m_p.SetV(a)};b.prototype.GetRadius=function(){return this.m_radius};b.prototype.SetRadius=function(a){void 0===a&&(a=0);this.m_radius=a};b.prototype.b2CircleShape=function(a){void 0===a&&(a=0);this.__super.b2Shape.call(this);
this.m_type=g.e_circleShape;this.m_radius=a};c.b2EdgeChainDef=function(){};c.prototype.b2EdgeChainDef=function(){this.vertexCount=0;this.isALoop=!0;this.vertices=[]};Box2D.inherit(d,Box2D.Collision.Shapes.b2Shape);d.prototype.__super=Box2D.Collision.Shapes.b2Shape.prototype;d.b2EdgeShape=function(){Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this,arguments);this.s_supportVec=new n;this.m_v1=new n;this.m_v2=new n;this.m_coreV1=new n;this.m_coreV2=new n;this.m_normal=new n;this.m_direction=new n;this.m_cornerDir1=
new n;this.m_cornerDir2=new n};d.prototype.TestPoint=function(a,b){return!1};d.prototype.RayCast=function(a,b,c){var d,e=b.p2.x-b.p1.x,f=b.p2.y-b.p1.y;d=c.R;var g=c.position.x+(d.col1.x*this.m_v1.x+d.col2.x*this.m_v1.y),h=c.position.y+(d.col1.y*this.m_v1.x+d.col2.y*this.m_v1.y),k=c.position.y+(d.col1.y*this.m_v2.x+d.col2.y*this.m_v2.y)-h;c=-(c.position.x+(d.col1.x*this.m_v2.x+d.col2.x*this.m_v2.y)-g);d=100*Number.MIN_VALUE;var m=-(e*k+f*c);if(m>d){var g=b.p1.x-g,n=b.p1.y-h,h=g*k+n*c;if(0<=h&&h<=b.maxFraction*
m&&(b=-e*n+f*g,b>=-d*m&&m*(1+d)>=b))return a.fraction=h/m,b=Math.sqrt(k*k+c*c),a.normal.x=k/b,a.normal.y=c/b,!0}return!1};d.prototype.ComputeAABB=function(a,b){var c=b.R,d=b.position.x+(c.col1.x*this.m_v1.x+c.col2.x*this.m_v1.y),e=b.position.y+(c.col1.y*this.m_v1.x+c.col2.y*this.m_v1.y),f=b.position.x+(c.col1.x*this.m_v2.x+c.col2.x*this.m_v2.y),c=b.position.y+(c.col1.y*this.m_v2.x+c.col2.y*this.m_v2.y);f>d?(a.lowerBound.x=d,a.upperBound.x=f):(a.lowerBound.x=f,a.upperBound.x=d);c>e?(a.lowerBound.y=
e,a.upperBound.y=c):(a.lowerBound.y=c,a.upperBound.y=e)};d.prototype.ComputeMass=function(a,b){a.mass=0;a.center.SetV(this.m_v1);a.I=0};d.prototype.ComputeSubmergedArea=function(a,b,c,d){void 0===b&&(b=0);var e=new n(a.x*b,a.y*b),f=k.MulX(c,this.m_v1);c=k.MulX(c,this.m_v2);var g=k.Dot(a,f)-b;a=k.Dot(a,c)-b;if(0<g){if(0<a)return 0;f.x=-a/(g-a)*f.x+g/(g-a)*c.x;f.y=-a/(g-a)*f.y+g/(g-a)*c.y}else 0<a&&(c.x=-a/(g-a)*f.x+g/(g-a)*c.x,c.y=-a/(g-a)*f.y+g/(g-a)*c.y);return d.x=(e.x+f.x+c.x)/3,d.y=(e.y+f.y+c.y)/
3,0.5*((f.x-e.x)*(c.y-e.y)-(f.y-e.y)*(c.x-e.x))};d.prototype.GetLength=function(){return this.m_length};d.prototype.GetVertex1=function(){return this.m_v1};d.prototype.GetVertex2=function(){return this.m_v2};d.prototype.GetCoreVertex1=function(){return this.m_coreV1};d.prototype.GetCoreVertex2=function(){return this.m_coreV2};d.prototype.GetNormalVector=function(){return this.m_normal};d.prototype.GetDirectionVector=function(){return this.m_direction};d.prototype.GetCorner1Vector=function(){return this.m_cornerDir1};
d.prototype.GetCorner2Vector=function(){return this.m_cornerDir2};d.prototype.Corner1IsConvex=function(){return this.m_cornerConvex1};d.prototype.Corner2IsConvex=function(){return this.m_cornerConvex2};d.prototype.GetFirstVertex=function(a){var b=a.R;return new n(a.position.x+(b.col1.x*this.m_coreV1.x+b.col2.x*this.m_coreV1.y),a.position.y+(b.col1.y*this.m_coreV1.x+b.col2.y*this.m_coreV1.y))};d.prototype.GetNextEdge=function(){return this.m_nextEdge};d.prototype.GetPrevEdge=function(){return this.m_prevEdge};
d.prototype.Support=function(a,b,c){void 0===b&&(b=0);void 0===c&&(c=0);var d=a.R,e=a.position.x+(d.col1.x*this.m_coreV1.x+d.col2.x*this.m_coreV1.y),f=a.position.y+(d.col1.y*this.m_coreV1.x+d.col2.y*this.m_coreV1.y),g=a.position.x+(d.col1.x*this.m_coreV2.x+d.col2.x*this.m_coreV2.y);a=a.position.y+(d.col1.y*this.m_coreV2.x+d.col2.y*this.m_coreV2.y);return e*b+f*c>g*b+a*c?(this.s_supportVec.x=e,this.s_supportVec.y=f):(this.s_supportVec.x=g,this.s_supportVec.y=a),this.s_supportVec};d.prototype.b2EdgeShape=
function(b,c){this.__super.b2Shape.call(this);this.m_type=g.e_edgeShape;this.m_nextEdge=this.m_prevEdge=null;this.m_v1=b;this.m_v2=c;this.m_direction.Set(this.m_v2.x-this.m_v1.x,this.m_v2.y-this.m_v1.y);this.m_length=this.m_direction.Normalize();this.m_normal.Set(this.m_direction.y,-this.m_direction.x);this.m_coreV1.Set(-a.b2_toiSlop*(this.m_normal.x-this.m_direction.x)+this.m_v1.x,-a.b2_toiSlop*(this.m_normal.y-this.m_direction.y)+this.m_v1.y);this.m_coreV2.Set(-a.b2_toiSlop*(this.m_normal.x+this.m_direction.x)+
this.m_v2.x,-a.b2_toiSlop*(this.m_normal.y+this.m_direction.y)+this.m_v2.y);this.m_cornerDir1=this.m_normal;this.m_cornerDir2.Set(-this.m_normal.x,-this.m_normal.y)};d.prototype.SetPrevEdge=function(a,b,c,d){this.m_prevEdge=a;this.m_coreV1=b;this.m_cornerDir1=c;this.m_cornerConvex1=d};d.prototype.SetNextEdge=function(a,b,c,d){this.m_nextEdge=a;this.m_coreV2=b;this.m_cornerDir2=c;this.m_cornerConvex2=d};e.b2MassData=function(){this.mass=0;this.center=new n(0,0);this.I=0};Box2D.inherit(f,Box2D.Collision.Shapes.b2Shape);
f.prototype.__super=Box2D.Collision.Shapes.b2Shape.prototype;f.b2PolygonShape=function(){Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this,arguments)};f.prototype.Copy=function(){var a=new f;return a.Set(this),a};f.prototype.Set=function(a){if(this.__super.Set.call(this,a),Box2D.is(a,f)){a=a instanceof f?a:null;this.m_centroid.SetV(a.m_centroid);this.m_vertexCount=a.m_vertexCount;this.Reserve(this.m_vertexCount);for(var b=0;b<this.m_vertexCount;b++)this.m_vertices[b].SetV(a.m_vertices[b]),this.m_normals[b].SetV(a.m_normals[b])}};
f.prototype.SetAsArray=function(a,b){void 0===b&&(b=0);for(var c,d=new Vector,e=0,e=0;e<a.length;++e)c=a[e],d.push(c);this.SetAsVector(d,b)};f.AsArray=function(a,b){void 0===b&&(b=0);var c=new f;return c.SetAsArray(a,b),c};f.prototype.SetAsVector=function(b,c){void 0===c&&(c=0);0==c&&(c=b.length);a.b2Assert(2<=c);this.m_vertexCount=c;this.Reserve(c);for(var d=0,d=0;d<this.m_vertexCount;d++)this.m_vertices[d].SetV(b[d]);for(d=0;d<this.m_vertexCount;++d){var e=parseInt(d),g=parseInt(d+1<this.m_vertexCount?
d+1:0),e=k.SubtractVV(this.m_vertices[g],this.m_vertices[e]);a.b2Assert(e.LengthSquared()>Number.MIN_VALUE);this.m_normals[d].SetV(k.CrossVF(e,1));this.m_normals[d].Normalize()}this.m_centroid=f.ComputeCentroid(this.m_vertices,this.m_vertexCount)};f.AsVector=function(a,b){void 0===b&&(b=0);var c=new f;return c.SetAsVector(a,b),c};f.prototype.SetAsBox=function(a,b){void 0===a&&(a=0);void 0===b&&(b=0);this.m_vertexCount=4;this.Reserve(4);this.m_vertices[0].Set(-a,-b);this.m_vertices[1].Set(a,-b);this.m_vertices[2].Set(a,
b);this.m_vertices[3].Set(-a,b);this.m_normals[0].Set(0,-1);this.m_normals[1].Set(1,0);this.m_normals[2].Set(0,1);this.m_normals[3].Set(-1,0);this.m_centroid.SetZero()};f.AsBox=function(a,b){void 0===a&&(a=0);void 0===b&&(b=0);var c=new f;return c.SetAsBox(a,b),c};f.prototype.SetAsOrientedBox=function(a,b,c,d){void 0===a&&(a=0);void 0===b&&(b=0);void 0===c&&(c=null);void 0===d&&(d=0);this.m_vertexCount=4;this.Reserve(4);this.m_vertices[0].Set(-a,-b);this.m_vertices[1].Set(a,-b);this.m_vertices[2].Set(a,
b);this.m_vertices[3].Set(-a,b);this.m_normals[0].Set(0,-1);this.m_normals[1].Set(1,0);this.m_normals[2].Set(0,1);this.m_normals[3].Set(-1,0);this.m_centroid=c;a=new m;a.position=c;a.R.Set(d);for(c=0;c<this.m_vertexCount;++c)this.m_vertices[c]=k.MulX(a,this.m_vertices[c]),this.m_normals[c]=k.MulMV(a.R,this.m_normals[c])};f.AsOrientedBox=function(a,b,c,d){void 0===a&&(a=0);void 0===b&&(b=0);void 0===c&&(c=null);void 0===d&&(d=0);var e=new f;return e.SetAsOrientedBox(a,b,c,d),e};f.prototype.SetAsEdge=
function(a,b){this.m_vertexCount=2;this.Reserve(2);this.m_vertices[0].SetV(a);this.m_vertices[1].SetV(b);this.m_centroid.x=0.5*(a.x+b.x);this.m_centroid.y=0.5*(a.y+b.y);this.m_normals[0]=k.CrossVF(k.SubtractVV(b,a),1);this.m_normals[0].Normalize();this.m_normals[1].x=-this.m_normals[0].x;this.m_normals[1].y=-this.m_normals[0].y};f.AsEdge=function(a,b){var c=new f;return c.SetAsEdge(a,b),c};f.prototype.TestPoint=function(a,b){var c;c=a.R;for(var d=b.x-a.position.x,e=b.y-a.position.y,f=d*c.col1.x+e*
c.col1.y,g=d*c.col2.x+e*c.col2.y,h=0;h<this.m_vertexCount;++h)if(c=this.m_vertices[h],d=f-c.x,e=g-c.y,c=this.m_normals[h],0<c.x*d+c.y*e)return!1;return!0};f.prototype.RayCast=function(a,b,c){var d,e,f=0,g=b.maxFraction,h=0,k=0,h=b.p1.x-c.position.x,k=b.p1.y-c.position.y;d=c.R;var m=h*d.col1.x+k*d.col1.y,n=h*d.col2.x+k*d.col2.y,h=b.p2.x-c.position.x,k=b.p2.y-c.position.y;d=c.R;b=h*d.col1.x+k*d.col1.y-m;for(var p=h*d.col2.x+k*d.col2.y-n,D=-1,y=0;y<this.m_vertexCount;++y){e=this.m_vertices[y];h=e.x-
m;k=e.y-n;e=this.m_normals[y];h=e.x*h+e.y*k;k=e.x*b+e.y*p;if(0==k){if(0>h)return!1}else 0>k&&f*k>h?(f=h/k,D=y):0<k&&g*k>h&&(g=h/k);if(g<f-Number.MIN_VALUE)return!1}return 0<=D?(a.fraction=f,d=c.R,e=this.m_normals[D],a.normal.x=d.col1.x*e.x+d.col2.x*e.y,a.normal.y=d.col1.y*e.x+d.col2.y*e.y,!0):!1};f.prototype.ComputeAABB=function(a,b){for(var c=b.R,d=this.m_vertices[0],e=b.position.x+(c.col1.x*d.x+c.col2.x*d.y),f=b.position.y+(c.col1.y*d.x+c.col2.y*d.y),g=e,h=f,k=1;k<this.m_vertexCount;++k)var d=this.m_vertices[k],
m=b.position.x+(c.col1.x*d.x+c.col2.x*d.y),d=b.position.y+(c.col1.y*d.x+c.col2.y*d.y),e=m>e?e:m,f=d>f?f:d,g=g>m?g:m,h=h>d?h:d;a.lowerBound.x=e-this.m_radius;a.lowerBound.y=f-this.m_radius;a.upperBound.x=g+this.m_radius;a.upperBound.y=h+this.m_radius};f.prototype.ComputeMass=function(a,b){if(void 0===b&&(b=0),2==this.m_vertexCount)return a.center.x=0.5*(this.m_vertices[0].x+this.m_vertices[1].x),a.center.y=0.5*(this.m_vertices[0].y+this.m_vertices[1].y),a.mass=0,void(a.I=0);for(var c=0,d=0,e=0,f=0,
g=1/3,h=0;h<this.m_vertexCount;++h)var k=this.m_vertices[h],m=h+1<this.m_vertexCount?this.m_vertices[parseInt(h+1)]:this.m_vertices[0],n=k.x-0,p=k.y-0,D=m.x-0,y=m.y-0,r=n*y-p*D,K=0.5*r,e=e+K,c=c+K*g*(0+k.x+m.x),d=d+K*g*(0+k.y+m.y),k=n,f=f+r*(g*(0.25*(k*k+D*k+D*D)+(0*k+0*D))+0+(g*(0.25*(p*p+y*p+y*y)+(0*p+0*y))+0));a.mass=b*e;a.center.Set(c*(1/e),d*(1/e));a.I=b*f};f.prototype.ComputeSubmergedArea=function(a,b,c,d){void 0===b&&(b=0);var f=k.MulTMV(c.R,a),g=b-k.Dot(a,c.position),h=new Vector_a2j_Number,
m=0,p=-1;b=-1;var r=!1;for(a=a=0;a<this.m_vertexCount;++a){h[a]=k.Dot(f,this.m_vertices[a])-g;var s=h[a]<-Number.MIN_VALUE;0<a&&(s?r||(p=a-1,m++):r&&(b=a-1,m++));r=s}switch(m){case 0:return r?(a=new e,this.ComputeMass(a,1),d.SetV(k.MulX(c,a.center)),a.mass):0;case 1:-1==p?p=this.m_vertexCount-1:b=this.m_vertexCount-1}a=parseInt((p+1)%this.m_vertexCount);f=parseInt((b+1)%this.m_vertexCount);g=(0-h[p])/(h[a]-h[p]);h=(0-h[b])/(h[f]-h[b]);p=new n(this.m_vertices[p].x*(1-g)+this.m_vertices[a].x*g,this.m_vertices[p].y*
(1-g)+this.m_vertices[a].y*g);b=new n(this.m_vertices[b].x*(1-h)+this.m_vertices[f].x*h,this.m_vertices[b].y*(1-h)+this.m_vertices[f].y*h);h=0;g=new n;for(m=this.m_vertices[a];a!=f;)a=(a+1)%this.m_vertexCount,r=a==f?b:this.m_vertices[a],s=0.5*((m.x-p.x)*(r.y-p.y)-(m.y-p.y)*(r.x-p.x)),h+=s,g.x+=s*(p.x+m.x+r.x)/3,g.y+=s*(p.y+m.y+r.y)/3,m=r;return g.Multiply(1/h),d.SetV(k.MulX(c,g)),h};f.prototype.GetVertexCount=function(){return this.m_vertexCount};f.prototype.GetVertices=function(){return this.m_vertices};
f.prototype.GetNormals=function(){return this.m_normals};f.prototype.GetSupport=function(a){for(var b=0,c=this.m_vertices[0].x*a.x+this.m_vertices[0].y*a.y,d=1;d<this.m_vertexCount;++d){var e=this.m_vertices[d].x*a.x+this.m_vertices[d].y*a.y;e>c&&(b=d,c=e)}return b};f.prototype.GetSupportVertex=function(a){for(var b=0,c=this.m_vertices[0].x*a.x+this.m_vertices[0].y*a.y,d=1;d<this.m_vertexCount;++d){var e=this.m_vertices[d].x*a.x+this.m_vertices[d].y*a.y;e>c&&(b=d,c=e)}return this.m_vertices[b]};f.prototype.Validate=
function(){return!1};f.prototype.b2PolygonShape=function(){this.__super.b2Shape.call(this);this.m_type=g.e_polygonShape;this.m_centroid=new n;this.m_vertices=new Vector;this.m_normals=new Vector};f.prototype.Reserve=function(a){void 0===a&&(a=0);for(var b=parseInt(this.m_vertices.length);a>b;b++)this.m_vertices[b]=new n,this.m_normals[b]=new n};f.ComputeCentroid=function(a,b){void 0===b&&(b=0);for(var c=new n,d=0,e=1/3,f=0;b>f;++f){var g=a[f],h=b>f+1?a[parseInt(f+1)]:a[0],k=0.5*((g.x-0)*(h.y-0)-(g.y-
0)*(h.x-0)),d=d+k;c.x+=k*e*(0+g.x+h.x);c.y+=k*e*(0+g.y+h.y)}return c.x*=1/d,c.y*=1/d,c};f.ComputeOBB=function(a,b,c){void 0===c&&(c=0);for(var d=0,e=new Vector(c+1),d=0;c>d;++d)e[d]=b[d];e[c]=e[0];b=Number.MAX_VALUE;for(d=1;c>=d;++d){for(var f=e[parseInt(d-1)],g=e[d].x-f.x,h=e[d].y-f.y,k=Math.sqrt(g*g+h*h),g=g/k,h=h/k,m=-h,n=g,p=k=Number.MAX_VALUE,D=-Number.MAX_VALUE,y=-Number.MAX_VALUE,r=0;c>r;++r){var K=e[r].x-f.x,s=e[r].y-f.y,u=g*K+h*s,K=m*K+n*s;k>u&&(k=u);p>K&&(p=K);u>D&&(D=u);K>y&&(y=K)}r=(D-
k)*(y-p);0.95*b>r&&(b=r,a.R.col1.x=g,a.R.col1.y=h,a.R.col2.x=m,a.R.col2.y=n,g=0.5*(k+D),h=0.5*(p+y),m=a.R,a.center.x=f.x+(m.col1.x*g+m.col2.x*h),a.center.y=f.y+(m.col1.y*g+m.col2.y*h),a.extents.x=0.5*(D-k),a.extents.y=0.5*(y-p))}};Box2D.postDefs.push(function(){Box2D.Collision.Shapes.b2PolygonShape.s_mat=new h});g.b2Shape=function(){};g.prototype.Copy=function(){return null};g.prototype.Set=function(a){this.m_radius=a.m_radius};g.prototype.GetType=function(){return this.m_type};g.prototype.TestPoint=
function(a,b){return!1};g.prototype.RayCast=function(a,b,c){return!1};g.prototype.ComputeAABB=function(a,b){};g.prototype.ComputeMass=function(a,b){};g.prototype.ComputeSubmergedArea=function(a,b,c,d){return 0};g.TestOverlap=function(a,b,c,d){var e=new r;e.proxyA=new v;e.proxyA.Set(a);e.proxyB=new v;e.proxyB.Set(c);e.transformA=b;e.transformB=d;e.useRadii=!0;a=new u;a.count=0;b=new s;return p.Distance(b,a,e),b.distance<10*Number.MIN_VALUE};g.prototype.b2Shape=function(){this.m_type=g.e_unknownShape;
this.m_radius=a.b2_linearSlop};Box2D.postDefs.push(function(){Box2D.Collision.Shapes.b2Shape.e_unknownShape=-1;Box2D.Collision.Shapes.b2Shape.e_circleShape=0;Box2D.Collision.Shapes.b2Shape.e_polygonShape=1;Box2D.Collision.Shapes.b2Shape.e_edgeShape=2;Box2D.Collision.Shapes.b2Shape.e_shapeTypeCount=3;Box2D.Collision.Shapes.b2Shape.e_hitCollide=1;Box2D.Collision.Shapes.b2Shape.e_missCollide=0;Box2D.Collision.Shapes.b2Shape.e_startsInsideCollide=-1})})();
(function(){var a=Box2D.Common.b2Color,b=(Box2D.Common.b2internal,Box2D.Common.b2Settings),c=(Box2D.Common.Math.b2Mat22,Box2D.Common.Math.b2Mat33,Box2D.Common.Math.b2Math);Box2D.Common.Math.b2Sweep;Box2D.Common.Math.b2Transform;Box2D.Common.Math.b2Vec2;Box2D.Common.Math.b2Vec3;a.b2Color=function(){this._b=this._g=this._r=0};a.prototype.b2Color=function(a,b,f){void 0===a&&(a=0);void 0===b&&(b=0);void 0===f&&(f=0);this._r=Box2D.parseUInt(255*c.Clamp(a,0,1));this._g=Box2D.parseUInt(255*c.Clamp(b,0,1));
this._b=Box2D.parseUInt(255*c.Clamp(f,0,1))};a.prototype.Set=function(a,b,f){void 0===a&&(a=0);void 0===b&&(b=0);void 0===f&&(f=0);this._r=Box2D.parseUInt(255*c.Clamp(a,0,1));this._g=Box2D.parseUInt(255*c.Clamp(b,0,1));this._b=Box2D.parseUInt(255*c.Clamp(f,0,1))};Object.defineProperty(a.prototype,"r",{enumerable:!1,configurable:!0,set:function(a){void 0===a&&(a=0);this._r=Box2D.parseUInt(255*c.Clamp(a,0,1))}});Object.defineProperty(a.prototype,"g",{enumerable:!1,configurable:!0,set:function(a){void 0===
a&&(a=0);this._g=Box2D.parseUInt(255*c.Clamp(a,0,1))}});Object.defineProperty(a.prototype,"b",{enumerable:!1,configurable:!0,set:function(a){void 0===a&&(a=0);this._b=Box2D.parseUInt(255*c.Clamp(a,0,1))}});Object.defineProperty(a.prototype,"color",{enumerable:!1,configurable:!0,get:function(){return this._r<<16|this._g<<8|this._b}});b.b2Settings=function(){};b.b2MixFriction=function(a,b){return void 0===a&&(a=0),void 0===b&&(b=0),Math.sqrt(a*b)};b.b2MixRestitution=function(a,b){return void 0===a&&
(a=0),void 0===b&&(b=0),a>b?a:b};b.b2Assert=function(a){if(!a)throw"Assertion Failed";};Box2D.postDefs.push(function(){Box2D.Common.b2Settings.VERSION="2.1alpha";Box2D.Common.b2Settings.USHRT_MAX=65535;Box2D.Common.b2Settings.b2_pi=Math.PI;Box2D.Common.b2Settings.b2_maxManifoldPoints=2;Box2D.Common.b2Settings.b2_aabbExtension=0.1;Box2D.Common.b2Settings.b2_aabbMultiplier=2;Box2D.Common.b2Settings.b2_polygonRadius=2*b.b2_linearSlop;Box2D.Common.b2Settings.b2_linearSlop=0.005;Box2D.Common.b2Settings.b2_angularSlop=
2/180*b.b2_pi;Box2D.Common.b2Settings.b2_toiSlop=8*b.b2_linearSlop;Box2D.Common.b2Settings.b2_maxTOIContactsPerIsland=32;Box2D.Common.b2Settings.b2_maxTOIJointsPerIsland=32;Box2D.Common.b2Settings.b2_velocityThreshold=1;Box2D.Common.b2Settings.b2_maxLinearCorrection=0.2;Box2D.Common.b2Settings.b2_maxAngularCorrection=8/180*b.b2_pi;Box2D.Common.b2Settings.b2_maxTranslation=2;Box2D.Common.b2Settings.b2_maxTranslationSquared=b.b2_maxTranslation*b.b2_maxTranslation;Box2D.Common.b2Settings.b2_maxRotation=
0.5*b.b2_pi;Box2D.Common.b2Settings.b2_maxRotationSquared=b.b2_maxRotation*b.b2_maxRotation;Box2D.Common.b2Settings.b2_contactBaumgarte=0.2;Box2D.Common.b2Settings.b2_timeToSleep=0.5;Box2D.Common.b2Settings.b2_linearSleepTolerance=0.01;Box2D.Common.b2Settings.b2_angularSleepTolerance=2/180*b.b2_pi})})();
(function(){var a=(Box2D.Collision.b2AABB,Box2D.Common.b2Color,Box2D.Common.b2internal,Box2D.Common.b2Settings,Box2D.Common.Math.b2Mat22),b=Box2D.Common.Math.b2Mat33,c=Box2D.Common.Math.b2Math,d=Box2D.Common.Math.b2Sweep,e=Box2D.Common.Math.b2Transform,f=Box2D.Common.Math.b2Vec2,g=Box2D.Common.Math.b2Vec3;a.b2Mat22=function(){this.col1=new f;this.col2=new f};a.prototype.b2Mat22=function(){this.SetIdentity()};a.FromAngle=function(b){void 0===b&&(b=0);var c=new a;return c.Set(b),c};a.FromVV=function(b,
c){var d=new a;return d.SetVV(b,c),d};a.prototype.Set=function(a){void 0===a&&(a=0);var b=Math.cos(a);a=Math.sin(a);this.col1.x=b;this.col2.x=-a;this.col1.y=a;this.col2.y=b};a.prototype.SetVV=function(a,b){this.col1.SetV(a);this.col2.SetV(b)};a.prototype.Copy=function(){var b=new a;return b.SetM(this),b};a.prototype.SetM=function(a){this.col1.SetV(a.col1);this.col2.SetV(a.col2)};a.prototype.AddM=function(a){this.col1.x+=a.col1.x;this.col1.y+=a.col1.y;this.col2.x+=a.col2.x;this.col2.y+=a.col2.y};a.prototype.SetIdentity=
function(){this.col1.x=1;this.col2.x=0;this.col1.y=0;this.col2.y=1};a.prototype.SetZero=function(){this.col1.x=0;this.col2.x=0;this.col1.y=0;this.col2.y=0};a.prototype.GetAngle=function(){return Math.atan2(this.col1.y,this.col1.x)};a.prototype.GetInverse=function(a){var b=this.col1.x,c=this.col2.x,d=this.col1.y,e=this.col2.y,f=b*e-c*d;return 0!=f&&(f=1/f),a.col1.x=f*e,a.col2.x=-f*c,a.col1.y=-f*d,a.col2.y=f*b,a};a.prototype.Solve=function(a,b,c){void 0===b&&(b=0);void 0===c&&(c=0);var d=this.col1.x,
e=this.col2.x,f=this.col1.y,g=this.col2.y,v=d*g-e*f;return 0!=v&&(v=1/v),a.x=v*(g*b-e*c),a.y=v*(d*c-f*b),a};a.prototype.Abs=function(){this.col1.Abs();this.col2.Abs()};b.b2Mat33=function(){this.col1=new g;this.col2=new g;this.col3=new g};b.prototype.b2Mat33=function(a,b,c){void 0===a&&(a=null);void 0===b&&(b=null);void 0===c&&(c=null);a||b||c?(this.col1.SetV(a),this.col2.SetV(b),this.col3.SetV(c)):(this.col1.SetZero(),this.col2.SetZero(),this.col3.SetZero())};b.prototype.SetVVV=function(a,b,c){this.col1.SetV(a);
this.col2.SetV(b);this.col3.SetV(c)};b.prototype.Copy=function(){return new b(this.col1,this.col2,this.col3)};b.prototype.SetM=function(a){this.col1.SetV(a.col1);this.col2.SetV(a.col2);this.col3.SetV(a.col3)};b.prototype.AddM=function(a){this.col1.x+=a.col1.x;this.col1.y+=a.col1.y;this.col1.z+=a.col1.z;this.col2.x+=a.col2.x;this.col2.y+=a.col2.y;this.col2.z+=a.col2.z;this.col3.x+=a.col3.x;this.col3.y+=a.col3.y;this.col3.z+=a.col3.z};b.prototype.SetIdentity=function(){this.col1.x=1;this.col2.x=0;this.col3.x=
0;this.col1.y=0;this.col2.y=1;this.col3.y=0;this.col1.z=0;this.col2.z=0;this.col3.z=1};b.prototype.SetZero=function(){this.col1.x=0;this.col2.x=0;this.col3.x=0;this.col1.y=0;this.col2.y=0;this.col3.y=0;this.col1.z=0;this.col2.z=0;this.col3.z=0};b.prototype.Solve22=function(a,b,c){void 0===b&&(b=0);void 0===c&&(c=0);var d=this.col1.x,e=this.col2.x,f=this.col1.y,g=this.col2.y,v=d*g-e*f;return 0!=v&&(v=1/v),a.x=v*(g*b-e*c),a.y=v*(d*c-f*b),a};b.prototype.Solve33=function(a,b,c,d){void 0===b&&(b=0);void 0===
c&&(c=0);void 0===d&&(d=0);var e=this.col1.x,f=this.col1.y,g=this.col1.z,v=this.col2.x,u=this.col2.y,t=this.col2.z,x=this.col3.x,A=this.col3.y,F=this.col3.z,z=e*(u*F-t*A)+f*(t*x-v*F)+g*(v*A-u*x);return 0!=z&&(z=1/z),a.x=z*(b*(u*F-t*A)+c*(t*x-v*F)+d*(v*A-u*x)),a.y=z*(e*(c*F-d*A)+f*(d*x-b*F)+g*(b*A-c*x)),a.z=z*(e*(u*d-t*c)+f*(t*b-v*d)+g*(v*c-u*b)),a};c.b2Math=function(){};c.IsValid=function(a){return void 0===a&&(a=0),isFinite(a)};c.Dot=function(a,b){return a.x*b.x+a.y*b.y};c.CrossVV=function(a,b){return a.x*
b.y-a.y*b.x};c.CrossVF=function(a,b){void 0===b&&(b=0);return new f(b*a.y,-b*a.x)};c.CrossFV=function(a,b){void 0===a&&(a=0);return new f(-a*b.y,a*b.x)};c.MulMV=function(a,b){return new f(a.col1.x*b.x+a.col2.x*b.y,a.col1.y*b.x+a.col2.y*b.y)};c.MulTMV=function(a,b){return new f(c.Dot(b,a.col1),c.Dot(b,a.col2))};c.MulX=function(a,b){var d=c.MulMV(a.R,b);return d.x+=a.position.x,d.y+=a.position.y,d};c.MulXT=function(a,b){var d=c.SubtractVV(b,a.position),e=d.x*a.R.col1.x+d.y*a.R.col1.y;return d.y=d.x*
a.R.col2.x+d.y*a.R.col2.y,d.x=e,d};c.AddVV=function(a,b){return new f(a.x+b.x,a.y+b.y)};c.SubtractVV=function(a,b){return new f(a.x-b.x,a.y-b.y)};c.Distance=function(a,b){var c=a.x-b.x,d=a.y-b.y;return Math.sqrt(c*c+d*d)};c.DistanceSquared=function(a,b){var c=a.x-b.x,d=a.y-b.y;return c*c+d*d};c.MulFV=function(a,b){void 0===a&&(a=0);return new f(a*b.x,a*b.y)};c.AddMM=function(b,d){return a.FromVV(c.AddVV(b.col1,d.col1),c.AddVV(b.col2,d.col2))};c.MulMM=function(b,d){return a.FromVV(c.MulMV(b,d.col1),
c.MulMV(b,d.col2))};c.MulTMM=function(b,d){var e=new f(c.Dot(b.col1,d.col1),c.Dot(b.col2,d.col1)),g=new f(c.Dot(b.col1,d.col2),c.Dot(b.col2,d.col2));return a.FromVV(e,g)};c.Abs=function(a){return void 0===a&&(a=0),0<a?a:-a};c.AbsV=function(a){return new f(c.Abs(a.x),c.Abs(a.y))};c.AbsM=function(b){return a.FromVV(c.AbsV(b.col1),c.AbsV(b.col2))};c.Min=function(a,b){return void 0===a&&(a=0),void 0===b&&(b=0),b>a?a:b};c.MinV=function(a,b){return new f(c.Min(a.x,b.x),c.Min(a.y,b.y))};c.Max=function(a,
b){return void 0===a&&(a=0),void 0===b&&(b=0),a>b?a:b};c.MaxV=function(a,b){return new f(c.Max(a.x,b.x),c.Max(a.y,b.y))};c.Clamp=function(a,b,c){return void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),b>a?b:a>c?c:a};c.ClampV=function(a,b,d){return c.MaxV(b,c.MinV(a,d))};c.Swap=function(a,b){var c=a[0];a[0]=b[0];b[0]=c};c.Random=function(){return 2*Math.random()-1};c.RandomRange=function(a,b){void 0===a&&(a=0);void 0===b&&(b=0);var c=Math.random();return(b-a)*c+a};c.NextPowerOfTwo=function(a){return void 0===
a&&(a=0),a|=a>>1&2147483647,a|=a>>2&1073741823,a|=a>>4&268435455,a|=a>>8&16777215,a|=a>>16&65535,a+1};c.IsPowerOfTwo=function(a){void 0===a&&(a=0);return 0<a&&0==(a&a-1)};Box2D.postDefs.push(function(){Box2D.Common.Math.b2Math.b2Vec2_zero=new f(0,0);Box2D.Common.Math.b2Math.b2Mat22_identity=a.FromVV(new f(1,0),new f(0,1));Box2D.Common.Math.b2Math.b2Transform_identity=new e(c.b2Vec2_zero,c.b2Mat22_identity)});d.b2Sweep=function(){this.localCenter=new f;this.c0=new f;this.c=new f};d.prototype.Set=function(a){this.localCenter.SetV(a.localCenter);
this.c0.SetV(a.c0);this.c.SetV(a.c);this.a0=a.a0;this.a=a.a;this.t0=a.t0};d.prototype.Copy=function(){var a=new d;return a.localCenter.SetV(this.localCenter),a.c0.SetV(this.c0),a.c.SetV(this.c),a.a0=this.a0,a.a=this.a,a.t0=this.t0,a};d.prototype.GetTransform=function(a,b){void 0===b&&(b=0);a.position.x=(1-b)*this.c0.x+b*this.c.x;a.position.y=(1-b)*this.c0.y+b*this.c.y;a.R.Set((1-b)*this.a0+b*this.a);var c=a.R;a.position.x-=c.col1.x*this.localCenter.x+c.col2.x*this.localCenter.y;a.position.y-=c.col1.y*
this.localCenter.x+c.col2.y*this.localCenter.y};d.prototype.Advance=function(a){if(void 0===a&&(a=0),this.t0<a&&1-this.t0>Number.MIN_VALUE){var b=(a-this.t0)/(1-this.t0);this.c0.x=(1-b)*this.c0.x+b*this.c.x;this.c0.y=(1-b)*this.c0.y+b*this.c.y;this.a0=(1-b)*this.a0+b*this.a;this.t0=a}};e.b2Transform=function(){this.position=new f;this.R=new a};e.prototype.b2Transform=function(a,b){void 0===a&&(a=null);void 0===b&&(b=null);a&&(this.position.SetV(a),this.R.SetM(b))};e.prototype.Initialize=function(a,
b){this.position.SetV(a);this.R.SetM(b)};e.prototype.SetIdentity=function(){this.position.SetZero();this.R.SetIdentity()};e.prototype.Set=function(a){this.position.SetV(a.position);this.R.SetM(a.R)};e.prototype.GetAngle=function(){return Math.atan2(this.R.col1.y,this.R.col1.x)};f.b2Vec2=function(){};f.prototype.b2Vec2=function(a,b){void 0===a&&(a=0);void 0===b&&(b=0);this.x=a;this.y=b};f.prototype.SetZero=function(){this.y=this.x=0};f.prototype.Set=function(a,b){void 0===a&&(a=0);void 0===b&&(b=0);
this.x=a;this.y=b};f.prototype.SetV=function(a){this.x=a.x;this.y=a.y};f.prototype.GetNegative=function(){return new f(-this.x,-this.y)};f.prototype.NegativeSelf=function(){this.x=-this.x;this.y=-this.y};f.Make=function(a,b){return void 0===a&&(a=0),void 0===b&&(b=0),new f(a,b)};f.prototype.Copy=function(){return new f(this.x,this.y)};f.prototype.Add=function(a){this.x+=a.x;this.y+=a.y};f.prototype.Subtract=function(a){this.x-=a.x;this.y-=a.y};f.prototype.Multiply=function(a){void 0===a&&(a=0);this.x*=
a;this.y*=a};f.prototype.MulM=function(a){var b=this.x;this.x=a.col1.x*b+a.col2.x*this.y;this.y=a.col1.y*b+a.col2.y*this.y};f.prototype.MulTM=function(a){var b=c.Dot(this,a.col1);this.y=c.Dot(this,a.col2);this.x=b};f.prototype.CrossVF=function(a){void 0===a&&(a=0);var b=this.x;this.x=a*this.y;this.y=-a*b};f.prototype.CrossFV=function(a){void 0===a&&(a=0);var b=this.x;this.x=-a*this.y;this.y=a*b};f.prototype.MinV=function(a){this.x=this.x<a.x?this.x:a.x;this.y=this.y<a.y?this.y:a.y};f.prototype.MaxV=
function(a){this.x=this.x>a.x?this.x:a.x;this.y=this.y>a.y?this.y:a.y};f.prototype.Abs=function(){0>this.x&&(this.x=-this.x);0>this.y&&(this.y=-this.y)};f.prototype.Length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};f.prototype.LengthSquared=function(){return this.x*this.x+this.y*this.y};f.prototype.Normalize=function(){var a=Math.sqrt(this.x*this.x+this.y*this.y);if(a<Number.MIN_VALUE)return 0;var b=1/a;return this.x*=b,this.y*=b,a};f.prototype.IsValid=function(){return c.IsValid(this.x)&&
c.IsValid(this.y)};g.b2Vec3=function(){};g.prototype.b2Vec3=function(a,b,c){void 0===a&&(a=0);void 0===b&&(b=0);void 0===c&&(c=0);this.x=a;this.y=b;this.z=c};g.prototype.SetZero=function(){this.x=this.y=this.z=0};g.prototype.Set=function(a,b,c){void 0===a&&(a=0);void 0===b&&(b=0);void 0===c&&(c=0);this.x=a;this.y=b;this.z=c};g.prototype.SetV=function(a){this.x=a.x;this.y=a.y;this.z=a.z};g.prototype.GetNegative=function(){return new g(-this.x,-this.y,-this.z)};g.prototype.NegativeSelf=function(){this.x=
-this.x;this.y=-this.y;this.z=-this.z};g.prototype.Copy=function(){return new g(this.x,this.y,this.z)};g.prototype.Add=function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z};g.prototype.Subtract=function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z};g.prototype.Multiply=function(a){void 0===a&&(a=0);this.x*=a;this.y*=a;this.z*=a}})();
(function(){var a=(Box2D.Dynamics.Controllers.b2ControllerEdge,Box2D.Common.Math.b2Mat22,Box2D.Common.Math.b2Mat33,Box2D.Common.Math.b2Math),b=Box2D.Common.Math.b2Sweep,c=Box2D.Common.Math.b2Transform,d=Box2D.Common.Math.b2Vec2,e=(Box2D.Common.Math.b2Vec3,Box2D.Common.b2Color),f=(Box2D.Common.b2internal,Box2D.Common.b2Settings),g=Box2D.Collision.b2AABB,h=(Box2D.Collision.b2Bound,Box2D.Collision.b2BoundValues,Box2D.Collision.b2Collision,Box2D.Collision.b2ContactID,Box2D.Collision.b2ContactPoint),k=
(Box2D.Collision.b2Distance,Box2D.Collision.b2DistanceInput,Box2D.Collision.b2DistanceOutput,Box2D.Collision.b2DistanceProxy,Box2D.Collision.b2DynamicTree,Box2D.Collision.b2DynamicTreeBroadPhase),m=(Box2D.Collision.b2DynamicTreeNode,Box2D.Collision.b2DynamicTreePair,Box2D.Collision.b2Manifold,Box2D.Collision.b2ManifoldPoint,Box2D.Collision.b2Point,Box2D.Collision.b2RayCastInput),n=Box2D.Collision.b2RayCastOutput,p=(Box2D.Collision.b2Segment,Box2D.Collision.b2SeparationFunction,Box2D.Collision.b2Simplex,
Box2D.Collision.b2SimplexCache,Box2D.Collision.b2SimplexVertex,Box2D.Collision.b2TimeOfImpact,Box2D.Collision.b2TOIInput,Box2D.Collision.b2WorldManifold,Box2D.Collision.ClipVertex,Box2D.Collision.Features,Box2D.Collision.IBroadPhase,Box2D.Collision.Shapes.b2CircleShape),r=(Box2D.Collision.Shapes.b2EdgeChainDef,Box2D.Collision.Shapes.b2EdgeShape),s=Box2D.Collision.Shapes.b2MassData,v=Box2D.Collision.Shapes.b2PolygonShape,u=Box2D.Collision.Shapes.b2Shape,t=Box2D.Dynamics.b2Body,x=Box2D.Dynamics.b2BodyDef,
A=Box2D.Dynamics.b2ContactFilter,F=Box2D.Dynamics.b2ContactImpulse,z=Box2D.Dynamics.b2ContactListener,w=Box2D.Dynamics.b2ContactManager,B=Box2D.Dynamics.b2DebugDraw,E=Box2D.Dynamics.b2DestructionListener,I=Box2D.Dynamics.b2FilterData,J=Box2D.Dynamics.b2Fixture,O=Box2D.Dynamics.b2FixtureDef,L=Box2D.Dynamics.b2Island,D=Box2D.Dynamics.b2TimeStep,y=Box2D.Dynamics.b2World,H=(Box2D.Dynamics.Contacts.b2CircleContact,Box2D.Dynamics.Contacts.b2Contact),K=(Box2D.Dynamics.Contacts.b2ContactConstraint,Box2D.Dynamics.Contacts.b2ContactConstraintPoint,
Box2D.Dynamics.Contacts.b2ContactEdge,Box2D.Dynamics.Contacts.b2ContactFactory),N=(Box2D.Dynamics.Contacts.b2ContactRegister,Box2D.Dynamics.Contacts.b2ContactResult,Box2D.Dynamics.Contacts.b2ContactSolver),W=(Box2D.Dynamics.Contacts.b2EdgeAndCircleContact,Box2D.Dynamics.Contacts.b2NullContact,Box2D.Dynamics.Contacts.b2PolyAndCircleContact,Box2D.Dynamics.Contacts.b2PolyAndEdgeContact,Box2D.Dynamics.Contacts.b2PolygonContact,Box2D.Dynamics.Contacts.b2PositionSolverManifold,Box2D.Dynamics.Controllers.b2Controller,
Box2D.Dynamics.Joints.b2DistanceJoint,Box2D.Dynamics.Joints.b2DistanceJointDef,Box2D.Dynamics.Joints.b2FrictionJoint,Box2D.Dynamics.Joints.b2FrictionJointDef,Box2D.Dynamics.Joints.b2GearJoint,Box2D.Dynamics.Joints.b2GearJointDef,Box2D.Dynamics.Joints.b2Jacobian,Box2D.Dynamics.Joints.b2Joint),U=(Box2D.Dynamics.Joints.b2JointDef,Box2D.Dynamics.Joints.b2JointEdge,Box2D.Dynamics.Joints.b2LineJoint,Box2D.Dynamics.Joints.b2LineJointDef,Box2D.Dynamics.Joints.b2MouseJoint,Box2D.Dynamics.Joints.b2MouseJointDef,
Box2D.Dynamics.Joints.b2PrismaticJoint,Box2D.Dynamics.Joints.b2PrismaticJointDef,Box2D.Dynamics.Joints.b2PulleyJoint);Box2D.Dynamics.Joints.b2PulleyJointDef;Box2D.Dynamics.Joints.b2RevoluteJoint;Box2D.Dynamics.Joints.b2RevoluteJointDef;Box2D.Dynamics.Joints.b2WeldJoint;Box2D.Dynamics.Joints.b2WeldJointDef;t.b2Body=function(){this.m_xf=new c;this.m_sweep=new b;this.m_linearVelocity=new d;this.m_force=new d};t.prototype.connectEdges=function(b,c,d){void 0===d&&(d=0);var e=Math.atan2(c.GetDirectionVector().y,
c.GetDirectionVector().x);d=Math.tan(0.5*(e-d));d=a.MulFV(d,c.GetDirectionVector());d=a.SubtractVV(d,c.GetNormalVector());d=a.MulFV(f.b2_toiSlop,d);d=a.AddVV(d,c.GetVertex1());var g=a.AddVV(b.GetDirectionVector(),c.GetDirectionVector());g.Normalize();var h=0<a.Dot(b.GetDirectionVector(),c.GetNormalVector());return b.SetNextEdge(c,d,g,h),c.SetPrevEdge(b,d,g,h),e};t.prototype.CreateFixture=function(a){if(1==this.m_world.IsLocked())return null;var b=new J;(b.Create(this,this.m_xf,a),this.m_flags&t.e_activeFlag)&&
b.CreateProxy(this.m_world.m_contactManager.m_broadPhase,this.m_xf);return b.m_next=this.m_fixtureList,this.m_fixtureList=b,++this.m_fixtureCount,b.m_body=this,0<b.m_density&&this.ResetMassData(),this.m_world.m_flags|=y.e_newFixture,b};t.prototype.CreateFixture2=function(a,b){void 0===b&&(b=0);var c=new O;return c.shape=a,c.density=b,this.CreateFixture(c)};t.prototype.DestroyFixture=function(a){if(1!=this.m_world.IsLocked()){for(var b=this.m_fixtureList,c=null;null!=b;){if(b==a){c?c.m_next=a.m_next:
this.m_fixtureList=a.m_next;break}c=b;b=b.m_next}for(b=this.m_contactList;b;){var c=b.contact,b=b.next,d=c.GetFixtureA(),e=c.GetFixtureB();(a==d||a==e)&&this.m_world.m_contactManager.Destroy(c)}this.m_flags&t.e_activeFlag&&a.DestroyProxy(this.m_world.m_contactManager.m_broadPhase);a.Destroy();a.m_body=null;a.m_next=null;--this.m_fixtureCount;this.ResetMassData()}};t.prototype.SetPositionAndAngle=function(a,b){void 0===b&&(b=0);var c;if(1!=this.m_world.IsLocked()){this.m_xf.R.Set(b);this.m_xf.position.SetV(a);
c=this.m_xf.R;var d=this.m_sweep.localCenter;this.m_sweep.c.x=c.col1.x*d.x+c.col2.x*d.y;this.m_sweep.c.y=c.col1.y*d.x+c.col2.y*d.y;this.m_sweep.c.x+=this.m_xf.position.x;this.m_sweep.c.y+=this.m_xf.position.y;this.m_sweep.c0.SetV(this.m_sweep.c);this.m_sweep.a0=this.m_sweep.a=b;d=this.m_world.m_contactManager.m_broadPhase;for(c=this.m_fixtureList;c;c=c.m_next)c.Synchronize(d,this.m_xf,this.m_xf);this.m_world.m_contactManager.FindNewContacts()}};t.prototype.SetTransform=function(a){this.SetPositionAndAngle(a.position,
a.GetAngle())};t.prototype.GetTransform=function(){return this.m_xf};t.prototype.GetPosition=function(){return this.m_xf.position};t.prototype.SetPosition=function(a){this.SetPositionAndAngle(a,this.GetAngle())};t.prototype.GetAngle=function(){return this.m_sweep.a};t.prototype.SetAngle=function(a){void 0===a&&(a=0);this.SetPositionAndAngle(this.GetPosition(),a)};t.prototype.GetWorldCenter=function(){return this.m_sweep.c};t.prototype.GetLocalCenter=function(){return this.m_sweep.localCenter};t.prototype.SetLinearVelocity=
function(a){this.m_type!=t.b2_staticBody&&this.m_linearVelocity.SetV(a)};t.prototype.GetLinearVelocity=function(){return this.m_linearVelocity};t.prototype.SetAngularVelocity=function(a){void 0===a&&(a=0);this.m_type!=t.b2_staticBody&&(this.m_angularVelocity=a)};t.prototype.GetAngularVelocity=function(){return this.m_angularVelocity};t.prototype.GetDefinition=function(){var a=new x;return a.type=this.GetType(),a.allowSleep=(this.m_flags&t.e_allowSleepFlag)==t.e_allowSleepFlag,a.angle=this.GetAngle(),
a.angularDamping=this.m_angularDamping,a.angularVelocity=this.m_angularVelocity,a.fixedRotation=(this.m_flags&t.e_fixedRotationFlag)==t.e_fixedRotationFlag,a.bullet=(this.m_flags&t.e_bulletFlag)==t.e_bulletFlag,a.awake=(this.m_flags&t.e_awakeFlag)==t.e_awakeFlag,a.linearDamping=this.m_linearDamping,a.linearVelocity.SetV(this.GetLinearVelocity()),a.position=this.GetPosition(),a.userData=this.GetUserData(),a};t.prototype.ApplyForce=function(a,b){this.m_type==t.b2_dynamicBody&&(0==this.IsAwake()&&this.SetAwake(!0),
this.m_force.x+=a.x,this.m_force.y+=a.y,this.m_torque+=(b.x-this.m_sweep.c.x)*a.y-(b.y-this.m_sweep.c.y)*a.x)};t.prototype.ApplyTorque=function(a){void 0===a&&(a=0);this.m_type==t.b2_dynamicBody&&(0==this.IsAwake()&&this.SetAwake(!0),this.m_torque+=a)};t.prototype.ApplyImpulse=function(a,b){this.m_type==t.b2_dynamicBody&&(0==this.IsAwake()&&this.SetAwake(!0),this.m_linearVelocity.x+=this.m_invMass*a.x,this.m_linearVelocity.y+=this.m_invMass*a.y,this.m_angularVelocity+=this.m_invI*((b.x-this.m_sweep.c.x)*
a.y-(b.y-this.m_sweep.c.y)*a.x))};t.prototype.Split=function(b){for(var c,d=this.GetLinearVelocity().Copy(),e=this.GetAngularVelocity(),f=this.GetWorldCenter(),g=this.m_world.CreateBody(this.GetDefinition()),h=this.m_fixtureList;h;)if(b(h)){var k=h.m_next;c?c.m_next=k:this.m_fixtureList=k;this.m_fixtureCount--;h.m_next=g.m_fixtureList;g.m_fixtureList=h;g.m_fixtureCount++;h.m_body=g;h=k}else c=h,h=h.m_next;this.ResetMassData();g.ResetMassData();c=this.GetWorldCenter();b=g.GetWorldCenter();c=a.AddVV(d,
a.CrossFV(e,a.SubtractVV(c,f)));d=a.AddVV(d,a.CrossFV(e,a.SubtractVV(b,f)));return this.SetLinearVelocity(c),g.SetLinearVelocity(d),this.SetAngularVelocity(e),g.SetAngularVelocity(e),this.SynchronizeFixtures(),g.SynchronizeFixtures(),g};t.prototype.Merge=function(a){var b;for(b=a.m_fixtureList;b;){var c=b.m_next;a.m_fixtureCount--;b.m_next=this.m_fixtureList;this.m_fixtureList=b;this.m_fixtureCount++;b.m_body=e;b=c}d.m_fixtureCount=0;var d=this,e=a;d.GetWorldCenter();e.GetWorldCenter();d.GetLinearVelocity().Copy();
e.GetLinearVelocity().Copy();d.GetAngularVelocity();e.GetAngularVelocity();d.ResetMassData();this.SynchronizeFixtures()};t.prototype.GetMass=function(){return this.m_mass};t.prototype.GetInertia=function(){return this.m_I};t.prototype.GetMassData=function(a){a.mass=this.m_mass;a.I=this.m_I;a.center.SetV(this.m_sweep.localCenter)};t.prototype.SetMassData=function(b){if(f.b2Assert(0==this.m_world.IsLocked()),1!=this.m_world.IsLocked()&&this.m_type==t.b2_dynamicBody){this.m_invI=this.m_I=this.m_invMass=
0;this.m_mass=b.mass;0>=this.m_mass&&(this.m_mass=1);this.m_invMass=1/this.m_mass;0<b.I&&0==(this.m_flags&t.e_fixedRotationFlag)&&(this.m_I=b.I-this.m_mass*(b.center.x*b.center.x+b.center.y*b.center.y),this.m_invI=1/this.m_I);var c=this.m_sweep.c.Copy();this.m_sweep.localCenter.SetV(b.center);this.m_sweep.c0.SetV(a.MulX(this.m_xf,this.m_sweep.localCenter));this.m_sweep.c.SetV(this.m_sweep.c0);this.m_linearVelocity.x+=this.m_angularVelocity*-(this.m_sweep.c.y-c.y);this.m_linearVelocity.y+=this.m_angularVelocity*
+(this.m_sweep.c.x-c.x)}};t.prototype.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!=t.b2_staticBody&&this.m_type!=t.b2_kinematicBody){for(var b=d.Make(0,0),c=this.m_fixtureList;c;c=c.m_next)if(0!=c.m_density){var e=c.GetMassData();this.m_mass+=e.mass;b.x+=e.center.x*e.mass;b.y+=e.center.y*e.mass;this.m_I+=e.I}0<this.m_mass?(this.m_invMass=1/this.m_mass,b.x*=this.m_invMass,b.y*=this.m_invMass):(this.m_mass=1,this.m_invMass=
1);0<this.m_I&&0==(this.m_flags&t.e_fixedRotationFlag)?(this.m_I-=this.m_mass*(b.x*b.x+b.y*b.y),this.m_I*=this.m_inertiaScale,f.b2Assert(0<this.m_I),this.m_invI=1/this.m_I):(this.m_I=0,this.m_invI=0);c=this.m_sweep.c.Copy();this.m_sweep.localCenter.SetV(b);this.m_sweep.c0.SetV(a.MulX(this.m_xf,this.m_sweep.localCenter));this.m_sweep.c.SetV(this.m_sweep.c0);this.m_linearVelocity.x+=this.m_angularVelocity*-(this.m_sweep.c.y-c.y);this.m_linearVelocity.y+=this.m_angularVelocity*+(this.m_sweep.c.x-c.x)}};
t.prototype.GetWorldPoint=function(a){var b=this.m_xf.R;a=new d(b.col1.x*a.x+b.col2.x*a.y,b.col1.y*a.x+b.col2.y*a.y);return a.x+=this.m_xf.position.x,a.y+=this.m_xf.position.y,a};t.prototype.GetWorldVector=function(b){return a.MulMV(this.m_xf.R,b)};t.prototype.GetLocalPoint=function(b){return a.MulXT(this.m_xf,b)};t.prototype.GetLocalVector=function(b){return a.MulTMV(this.m_xf.R,b)};t.prototype.GetLinearVelocityFromWorldPoint=function(a){return new d(this.m_linearVelocity.x-this.m_angularVelocity*
(a.y-this.m_sweep.c.y),this.m_linearVelocity.y+this.m_angularVelocity*(a.x-this.m_sweep.c.x))};t.prototype.GetLinearVelocityFromLocalPoint=function(a){var b=this.m_xf.R;a=new d(b.col1.x*a.x+b.col2.x*a.y,b.col1.y*a.x+b.col2.y*a.y);return a.x+=this.m_xf.position.x,a.y+=this.m_xf.position.y,new d(this.m_linearVelocity.x-this.m_angularVelocity*(a.y-this.m_sweep.c.y),this.m_linearVelocity.y+this.m_angularVelocity*(a.x-this.m_sweep.c.x))};t.prototype.GetLinearDamping=function(){return this.m_linearDamping};
t.prototype.SetLinearDamping=function(a){void 0===a&&(a=0);this.m_linearDamping=a};t.prototype.GetAngularDamping=function(){return this.m_angularDamping};t.prototype.SetAngularDamping=function(a){void 0===a&&(a=0);this.m_angularDamping=a};t.prototype.SetType=function(a){if(void 0===a&&(a=0),this.m_type!=a){this.m_type=a;this.ResetMassData();this.m_type==t.b2_staticBody&&(this.m_linearVelocity.SetZero(),this.m_angularVelocity=0);this.SetAwake(!0);this.m_force.SetZero();this.m_torque=0;for(a=this.m_contactList;a;a=
a.next)a.contact.FlagForFiltering()}};t.prototype.GetType=function(){return this.m_type};t.prototype.SetBullet=function(a){a?this.m_flags|=t.e_bulletFlag:this.m_flags&=~t.e_bulletFlag};t.prototype.IsBullet=function(){return(this.m_flags&t.e_bulletFlag)==t.e_bulletFlag};t.prototype.SetSleepingAllowed=function(a){a?this.m_flags|=t.e_allowSleepFlag:(this.m_flags&=~t.e_allowSleepFlag,this.SetAwake(!0))};t.prototype.SetAwake=function(a){a?(this.m_flags|=t.e_awakeFlag,this.m_sleepTime=0):(this.m_flags&=
~t.e_awakeFlag,this.m_sleepTime=0,this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_force.SetZero(),this.m_torque=0)};t.prototype.IsAwake=function(){return(this.m_flags&t.e_awakeFlag)==t.e_awakeFlag};t.prototype.SetFixedRotation=function(a){a?this.m_flags|=t.e_fixedRotationFlag:this.m_flags&=~t.e_fixedRotationFlag;this.ResetMassData()};t.prototype.IsFixedRotation=function(){return(this.m_flags&t.e_fixedRotationFlag)==t.e_fixedRotationFlag};t.prototype.SetActive=function(a){if(a!=this.IsActive()){var b;
if(a){this.m_flags|=t.e_activeFlag;a=this.m_world.m_contactManager.m_broadPhase;for(b=this.m_fixtureList;b;b=b.m_next)b.CreateProxy(a,this.m_xf)}else{this.m_flags&=~t.e_activeFlag;a=this.m_world.m_contactManager.m_broadPhase;for(b=this.m_fixtureList;b;b=b.m_next)b.DestroyProxy(a);for(a=this.m_contactList;a;)b=a,a=a.next,this.m_world.m_contactManager.Destroy(b.contact);this.m_contactList=null}}};t.prototype.IsActive=function(){return(this.m_flags&t.e_activeFlag)==t.e_activeFlag};t.prototype.IsSleepingAllowed=
function(){return(this.m_flags&t.e_allowSleepFlag)==t.e_allowSleepFlag};t.prototype.GetFixtureList=function(){return this.m_fixtureList};t.prototype.GetJointList=function(){return this.m_jointList};t.prototype.GetControllerList=function(){return this.m_controllerList};t.prototype.GetContactList=function(){return this.m_contactList};t.prototype.GetNext=function(){return this.m_next};t.prototype.GetUserData=function(){return this.m_userData};t.prototype.SetUserData=function(a){this.m_userData=a};t.prototype.GetWorld=
function(){return this.m_world};t.prototype.b2Body=function(a,b){this.m_flags=0;a.bullet&&(this.m_flags|=t.e_bulletFlag);a.fixedRotation&&(this.m_flags|=t.e_fixedRotationFlag);a.allowSleep&&(this.m_flags|=t.e_allowSleepFlag);a.awake&&(this.m_flags|=t.e_awakeFlag);a.active&&(this.m_flags|=t.e_activeFlag);this.m_world=b;this.m_xf.position.SetV(a.position);this.m_xf.R.Set(a.angle);this.m_sweep.localCenter.SetZero();this.m_sweep.t0=1;this.m_sweep.a0=this.m_sweep.a=a.angle;var c=this.m_xf.R,d=this.m_sweep.localCenter;
this.m_sweep.c.x=c.col1.x*d.x+c.col2.x*d.y;this.m_sweep.c.y=c.col1.y*d.x+c.col2.y*d.y;this.m_sweep.c.x+=this.m_xf.position.x;this.m_sweep.c.y+=this.m_xf.position.y;this.m_sweep.c0.SetV(this.m_sweep.c);this.m_contactList=this.m_controllerList=this.m_jointList=null;this.m_controllerCount=0;this.m_next=this.m_prev=null;this.m_linearVelocity.SetV(a.linearVelocity);this.m_angularVelocity=a.angularVelocity;this.m_linearDamping=a.linearDamping;this.m_angularDamping=a.angularDamping;this.m_force.Set(0,0);
this.m_sleepTime=this.m_torque=0;this.m_type=a.type;this.m_type==t.b2_dynamicBody?(this.m_mass=1,this.m_invMass=1):(this.m_mass=0,this.m_invMass=0);this.m_invI=this.m_I=0;this.m_inertiaScale=a.inertiaScale;this.m_userData=a.userData;this.m_fixtureList=null;this.m_fixtureCount=0};t.prototype.SynchronizeFixtures=function(){var a=t.s_xf1;a.R.Set(this.m_sweep.a0);var b=a.R,c=this.m_sweep.localCenter;a.position.x=this.m_sweep.c0.x-(b.col1.x*c.x+b.col2.x*c.y);a.position.y=this.m_sweep.c0.y-(b.col1.y*c.x+
b.col2.y*c.y);c=this.m_world.m_contactManager.m_broadPhase;for(b=this.m_fixtureList;b;b=b.m_next)b.Synchronize(c,a,this.m_xf)};t.prototype.SynchronizeTransform=function(){this.m_xf.R.Set(this.m_sweep.a);var a=this.m_xf.R,b=this.m_sweep.localCenter;this.m_xf.position.x=this.m_sweep.c.x-(a.col1.x*b.x+a.col2.x*b.y);this.m_xf.position.y=this.m_sweep.c.y-(a.col1.y*b.x+a.col2.y*b.y)};t.prototype.ShouldCollide=function(a){if(this.m_type!=t.b2_dynamicBody&&a.m_type!=t.b2_dynamicBody)return!1;for(var b=this.m_jointList;b;b=
b.next)if(b.other==a&&0==b.joint.m_collideConnected)return!1;return!0};t.prototype.Advance=function(a){void 0===a&&(a=0);this.m_sweep.Advance(a);this.m_sweep.c.SetV(this.m_sweep.c0);this.m_sweep.a=this.m_sweep.a0;this.SynchronizeTransform()};Box2D.postDefs.push(function(){Box2D.Dynamics.b2Body.s_xf1=new c;Box2D.Dynamics.b2Body.e_islandFlag=1;Box2D.Dynamics.b2Body.e_awakeFlag=2;Box2D.Dynamics.b2Body.e_allowSleepFlag=4;Box2D.Dynamics.b2Body.e_bulletFlag=8;Box2D.Dynamics.b2Body.e_fixedRotationFlag=16;
Box2D.Dynamics.b2Body.e_activeFlag=32;Box2D.Dynamics.b2Body.b2_staticBody=0;Box2D.Dynamics.b2Body.b2_kinematicBody=1;Box2D.Dynamics.b2Body.b2_dynamicBody=2});x.b2BodyDef=function(){this.position=new d;this.linearVelocity=new d};x.prototype.b2BodyDef=function(){this.userData=null;this.position.Set(0,0);this.angle=0;this.linearVelocity.Set(0,0);this.angularDamping=this.linearDamping=this.angularVelocity=0;this.awake=this.allowSleep=!0;this.bullet=this.fixedRotation=!1;this.type=t.b2_staticBody;this.active=
!0;this.inertiaScale=1};A.b2ContactFilter=function(){};A.prototype.ShouldCollide=function(a,b){var c=a.GetFilterData(),d=b.GetFilterData();return c.groupIndex==d.groupIndex&&0!=c.groupIndex?0<c.groupIndex:0!=(c.maskBits&d.categoryBits)&&0!=(c.categoryBits&d.maskBits)};A.prototype.RayCollide=function(a,b){return a?this.ShouldCollide(a instanceof J?a:null,b):!0};Box2D.postDefs.push(function(){Box2D.Dynamics.b2ContactFilter.b2_defaultFilter=new A});F.b2ContactImpulse=function(){this.normalImpulses=new Vector_a2j_Number(f.b2_maxManifoldPoints);
this.tangentImpulses=new Vector_a2j_Number(f.b2_maxManifoldPoints)};z.b2ContactListener=function(){};z.prototype.BeginContact=function(a){};z.prototype.EndContact=function(a){};z.prototype.PreSolve=function(a,b){};z.prototype.PostSolve=function(a,b){};Box2D.postDefs.push(function(){Box2D.Dynamics.b2ContactListener.b2_defaultListener=new z});w.b2ContactManager=function(){};w.prototype.b2ContactManager=function(){this.m_world=null;this.m_contactCount=0;this.m_contactFilter=A.b2_defaultFilter;this.m_contactListener=
z.b2_defaultListener;this.m_contactFactory=new K(this.m_allocator);this.m_broadPhase=new k};w.prototype.AddPair=function(a,b){var c=a instanceof J?a:null,d=b instanceof J?b:null,e=c.GetBody(),f=d.GetBody();if(e!=f){for(var g=f.GetContactList();g;){if(g.other==e){var h=g.contact.GetFixtureA(),k=g.contact.GetFixtureB();if(h==c&&k==d||h==d&&k==c)return}g=g.next}0!=f.ShouldCollide(e)&&0!=this.m_contactFilter.ShouldCollide(c,d)&&(g=this.m_contactFactory.Create(c,d),c=g.GetFixtureA(),d=g.GetFixtureB(),
e=c.m_body,f=d.m_body,g.m_prev=null,g.m_next=this.m_world.m_contactList,null!=this.m_world.m_contactList&&(this.m_world.m_contactList.m_prev=g),this.m_world.m_contactList=g,g.m_nodeA.contact=g,g.m_nodeA.other=f,g.m_nodeA.prev=null,g.m_nodeA.next=e.m_contactList,null!=e.m_contactList&&(e.m_contactList.prev=g.m_nodeA),e.m_contactList=g.m_nodeA,g.m_nodeB.contact=g,g.m_nodeB.other=e,g.m_nodeB.prev=null,g.m_nodeB.next=f.m_contactList,null!=f.m_contactList&&(f.m_contactList.prev=g.m_nodeB),f.m_contactList=
g.m_nodeB,++this.m_world.m_contactCount)}};w.prototype.FindNewContacts=function(){this.m_broadPhase.UpdatePairs(Box2D.generateCallback(this,this.AddPair))};w.prototype.Destroy=function(a){var b=a.GetFixtureA(),c=a.GetFixtureB(),b=b.GetBody(),c=c.GetBody();a.IsTouching()&&this.m_contactListener.EndContact(a);a.m_prev&&(a.m_prev.m_next=a.m_next);a.m_next&&(a.m_next.m_prev=a.m_prev);a==this.m_world.m_contactList&&(this.m_world.m_contactList=a.m_next);a.m_nodeA.prev&&(a.m_nodeA.prev.next=a.m_nodeA.next);
a.m_nodeA.next&&(a.m_nodeA.next.prev=a.m_nodeA.prev);a.m_nodeA==b.m_contactList&&(b.m_contactList=a.m_nodeA.next);a.m_nodeB.prev&&(a.m_nodeB.prev.next=a.m_nodeB.next);a.m_nodeB.next&&(a.m_nodeB.next.prev=a.m_nodeB.prev);a.m_nodeB==c.m_contactList&&(c.m_contactList=a.m_nodeB.next);this.m_contactFactory.Destroy(a);--this.m_contactCount};w.prototype.Collide=function(){for(var a=this.m_world.m_contactList;a;){var b=a.GetFixtureA(),c=a.GetFixtureB(),d=b.GetBody(),e=c.GetBody();if(0!=d.IsAwake()||0!=e.IsAwake()){if(a.m_flags&
H.e_filterFlag){if(0==e.ShouldCollide(d)){var f=a,a=f.GetNext();this.Destroy(f);continue}if(0==this.m_contactFilter.ShouldCollide(b,c)){f=a;a=f.GetNext();this.Destroy(f);continue}a.m_flags&=~H.e_filterFlag}0!=this.m_broadPhase.TestOverlap(b.m_proxy,c.m_proxy)?(a.Update(this.m_contactListener),a=a.GetNext()):(f=a,a=f.GetNext(),this.Destroy(f))}else a=a.GetNext()}};Box2D.postDefs.push(function(){Box2D.Dynamics.b2ContactManager.s_evalCP=new h});B.b2DebugDraw=function(){};B.prototype.b2DebugDraw=function(){};
B.prototype.SetFlags=function(a){};B.prototype.GetFlags=function(){};B.prototype.AppendFlags=function(a){};B.prototype.ClearFlags=function(a){};B.prototype.SetSprite=function(a){};B.prototype.GetSprite=function(){};B.prototype.SetDrawScale=function(a){};B.prototype.GetDrawScale=function(){};B.prototype.SetLineThickness=function(a){};B.prototype.GetLineThickness=function(){};B.prototype.SetAlpha=function(a){};B.prototype.GetAlpha=function(){};B.prototype.SetFillAlpha=function(a){};B.prototype.GetFillAlpha=
function(){};B.prototype.SetXFormScale=function(a){};B.prototype.GetXFormScale=function(){};B.prototype.DrawPolygon=function(a,b,c){};B.prototype.DrawSolidPolygon=function(a,b,c){};B.prototype.DrawCircle=function(a,b,c){};B.prototype.DrawSolidCircle=function(a,b,c,d){};B.prototype.DrawSegment=function(a,b,c){};B.prototype.DrawTransform=function(a){};Box2D.postDefs.push(function(){Box2D.Dynamics.b2DebugDraw.e_shapeBit=1;Box2D.Dynamics.b2DebugDraw.e_jointBit=2;Box2D.Dynamics.b2DebugDraw.e_aabbBit=4;
Box2D.Dynamics.b2DebugDraw.e_pairBit=8;Box2D.Dynamics.b2DebugDraw.e_centerOfMassBit=16;Box2D.Dynamics.b2DebugDraw.e_controllerBit=32});E.b2DestructionListener=function(){};E.prototype.SayGoodbyeJoint=function(a){};E.prototype.SayGoodbyeFixture=function(a){};I.b2FilterData=function(){this.categoryBits=1;this.maskBits=65535;this.groupIndex=0};I.prototype.Copy=function(){var a=new I;return a.categoryBits=this.categoryBits,a.maskBits=this.maskBits,a.groupIndex=this.groupIndex,a};J.b2Fixture=function(){this.m_filter=
new I};J.prototype.GetType=function(){return this.m_shape.GetType()};J.prototype.GetShape=function(){return this.m_shape};J.prototype.SetSensor=function(a){if(this.m_isSensor!=a&&(this.m_isSensor=a,null!=this.m_body))for(a=this.m_body.GetContactList();a;){var b=a.contact,c=b.GetFixtureA(),d=b.GetFixtureB();(c==this||d==this)&&b.SetSensor(c.IsSensor()||d.IsSensor());a=a.next}};J.prototype.IsSensor=function(){return this.m_isSensor};J.prototype.SetFilterData=function(a){if(this.m_filter=a.Copy(),!this.m_body)for(a=
this.m_body.GetContactList();a;){var b=a.contact,c=b.GetFixtureA(),d=b.GetFixtureB();(c==this||d==this)&&b.FlagForFiltering();a=a.next}};J.prototype.GetFilterData=function(){return this.m_filter.Copy()};J.prototype.GetBody=function(){return this.m_body};J.prototype.GetNext=function(){return this.m_next};J.prototype.GetUserData=function(){return this.m_userData};J.prototype.SetUserData=function(a){this.m_userData=a};J.prototype.TestPoint=function(a){return this.m_shape.TestPoint(this.m_body.GetTransform(),
a)};J.prototype.RayCast=function(a,b){return this.m_shape.RayCast(a,b,this.m_body.GetTransform())};J.prototype.GetMassData=function(a){return void 0===a&&(a=null),null==a&&(a=new s),this.m_shape.ComputeMass(a,this.m_density),a};J.prototype.SetDensity=function(a){void 0===a&&(a=0);this.m_density=a};J.prototype.GetDensity=function(){return this.m_density};J.prototype.GetFriction=function(){return this.m_friction};J.prototype.SetFriction=function(a){void 0===a&&(a=0);this.m_friction=a};J.prototype.GetRestitution=
function(){return this.m_restitution};J.prototype.SetRestitution=function(a){void 0===a&&(a=0);this.m_restitution=a};J.prototype.GetAABB=function(){return this.m_aabb};J.prototype.b2Fixture=function(){this.m_aabb=new g;this.m_shape=this.m_next=this.m_body=this.m_userData=null;this.m_restitution=this.m_friction=this.m_density=0};J.prototype.Create=function(a,b,c){this.m_userData=c.userData;this.m_friction=c.friction;this.m_restitution=c.restitution;this.m_body=a;this.m_next=null;this.m_filter=c.filter.Copy();
this.m_isSensor=c.isSensor;this.m_shape=c.shape.Copy();this.m_density=c.density};J.prototype.Destroy=function(){this.m_shape=null};J.prototype.CreateProxy=function(a,b){this.m_shape.ComputeAABB(this.m_aabb,b);this.m_proxy=a.CreateProxy(this.m_aabb,this)};J.prototype.DestroyProxy=function(a){null!=this.m_proxy&&(a.DestroyProxy(this.m_proxy),this.m_proxy=null)};J.prototype.Synchronize=function(b,c,d){if(this.m_proxy){var e=new g,f=new g;this.m_shape.ComputeAABB(e,c);this.m_shape.ComputeAABB(f,d);this.m_aabb.Combine(e,
f);c=a.SubtractVV(d.position,c.position);b.MoveProxy(this.m_proxy,this.m_aabb,c)}};O.b2FixtureDef=function(){this.filter=new I};O.prototype.b2FixtureDef=function(){this.userData=this.shape=null;this.friction=0.2;this.density=this.restitution=0;this.filter.categoryBits=1;this.filter.maskBits=65535;this.filter.groupIndex=0;this.isSensor=!1};L.b2Island=function(){};L.prototype.b2Island=function(){this.m_bodies=new Vector;this.m_contacts=new Vector;this.m_joints=new Vector};L.prototype.Initialize=function(a,
b,c,d,e,f){void 0===a&&(a=0);void 0===b&&(b=0);void 0===c&&(c=0);var g=0;this.m_bodyCapacity=a;this.m_contactCapacity=b;this.m_jointCapacity=c;this.m_jointCount=this.m_contactCount=this.m_bodyCount=0;this.m_allocator=d;this.m_listener=e;this.m_contactSolver=f;for(g=this.m_bodies.length;a>g;g++)this.m_bodies[g]=null;for(g=this.m_contacts.length;b>g;g++)this.m_contacts[g]=null;for(g=this.m_joints.length;c>g;g++)this.m_joints[g]=null};L.prototype.Clear=function(){this.m_jointCount=this.m_contactCount=
this.m_bodyCount=0};L.prototype.Solve=function(b,c,d){for(var e,g,h=0,k=0,h=0;h<this.m_bodyCount;++h)e=this.m_bodies[h],e.GetType()==t.b2_dynamicBody&&(e.m_linearVelocity.x+=b.dt*(c.x+e.m_invMass*e.m_force.x),e.m_linearVelocity.y+=b.dt*(c.y+e.m_invMass*e.m_force.y),e.m_angularVelocity+=b.dt*e.m_invI*e.m_torque,e.m_linearVelocity.Multiply(a.Clamp(1-b.dt*e.m_linearDamping,0,1)),e.m_angularVelocity*=a.Clamp(1-b.dt*e.m_angularDamping,0,1));this.m_contactSolver.Initialize(b,this.m_contacts,this.m_contactCount,
this.m_allocator);c=this.m_contactSolver;c.InitVelocityConstraints(b);for(h=0;h<this.m_jointCount;++h)g=this.m_joints[h],g.InitVelocityConstraints(b);for(h=0;h<b.velocityIterations;++h){for(k=0;k<this.m_jointCount;++k)g=this.m_joints[k],g.SolveVelocityConstraints(b);c.SolveVelocityConstraints()}for(h=0;h<this.m_jointCount;++h)g=this.m_joints[h],g.FinalizeVelocityConstraints();c.FinalizeVelocityConstraints();for(h=0;h<this.m_bodyCount;++h)if(e=this.m_bodies[h],e.GetType()!=t.b2_staticBody)k=b.dt*e.m_linearVelocity.x,
g=b.dt*e.m_linearVelocity.y,k*k+g*g>f.b2_maxTranslationSquared&&(e.m_linearVelocity.Normalize(),e.m_linearVelocity.x*=f.b2_maxTranslation*b.inv_dt,e.m_linearVelocity.y*=f.b2_maxTranslation*b.inv_dt),k=b.dt*e.m_angularVelocity,k*k>f.b2_maxRotationSquared&&(0>e.m_angularVelocity?e.m_angularVelocity=-f.b2_maxRotation*b.inv_dt:e.m_angularVelocity=f.b2_maxRotation*b.inv_dt),e.m_sweep.c0.SetV(e.m_sweep.c),e.m_sweep.a0=e.m_sweep.a,e.m_sweep.c.x+=b.dt*e.m_linearVelocity.x,e.m_sweep.c.y+=b.dt*e.m_linearVelocity.y,
e.m_sweep.a+=b.dt*e.m_angularVelocity,e.SynchronizeTransform();for(h=0;h<b.positionIterations;++h){e=c.SolvePositionConstraints(f.b2_contactBaumgarte);for(var m=!0,k=0;k<this.m_jointCount;++k)g=this.m_joints[k],g=g.SolvePositionConstraints(f.b2_contactBaumgarte),m=m&&g;if(e&&m)break}if(this.Report(c.m_constraints),d){d=Number.MAX_VALUE;c=f.b2_linearSleepTolerance*f.b2_linearSleepTolerance;k=f.b2_angularSleepTolerance*f.b2_angularSleepTolerance;for(h=0;h<this.m_bodyCount;++h)e=this.m_bodies[h],e.GetType()!=
t.b2_staticBody&&(0==(e.m_flags&t.e_allowSleepFlag)&&(e.m_sleepTime=0,d=0),0==(e.m_flags&t.e_allowSleepFlag)||e.m_angularVelocity*e.m_angularVelocity>k||a.Dot(e.m_linearVelocity,e.m_linearVelocity)>c?(e.m_sleepTime=0,d=0):(e.m_sleepTime+=b.dt,d=a.Min(d,e.m_sleepTime)));if(d>=f.b2_timeToSleep)for(h=0;h<this.m_bodyCount;++h)e=this.m_bodies[h],e.SetAwake(!1)}};L.prototype.SolveTOI=function(a){var b=0,c=0;this.m_contactSolver.Initialize(a,this.m_contacts,this.m_contactCount,this.m_allocator);for(var d=
this.m_contactSolver,b=0;b<this.m_jointCount;++b)this.m_joints[b].InitVelocityConstraints(a);for(b=0;b<a.velocityIterations;++b){d.SolveVelocityConstraints();for(c=0;c<this.m_jointCount;++c)this.m_joints[c].SolveVelocityConstraints(a)}for(b=0;b<this.m_bodyCount;++b)if(c=this.m_bodies[b],c.GetType()!=t.b2_staticBody){var e=a.dt*c.m_linearVelocity.x,g=a.dt*c.m_linearVelocity.y;e*e+g*g>f.b2_maxTranslationSquared&&(c.m_linearVelocity.Normalize(),c.m_linearVelocity.x*=f.b2_maxTranslation*a.inv_dt,c.m_linearVelocity.y*=
f.b2_maxTranslation*a.inv_dt);e=a.dt*c.m_angularVelocity;e*e>f.b2_maxRotationSquared&&(0>c.m_angularVelocity?c.m_angularVelocity=-f.b2_maxRotation*a.inv_dt:c.m_angularVelocity=f.b2_maxRotation*a.inv_dt);c.m_sweep.c0.SetV(c.m_sweep.c);c.m_sweep.a0=c.m_sweep.a;c.m_sweep.c.x+=a.dt*c.m_linearVelocity.x;c.m_sweep.c.y+=a.dt*c.m_linearVelocity.y;c.m_sweep.a+=a.dt*c.m_angularVelocity;c.SynchronizeTransform()}for(b=0;b<a.positionIterations;++b){e=d.SolvePositionConstraints(0.75);g=!0;for(c=0;c<this.m_jointCount;++c)var h=
this.m_joints[c].SolvePositionConstraints(f.b2_contactBaumgarte),g=g&&h;if(e&&g)break}this.Report(d.m_constraints)};L.prototype.Report=function(a){if(null!=this.m_listener)for(var b=0;b<this.m_contactCount;++b){for(var c=this.m_contacts[b],d=a[b],e=0;e<d.pointCount;++e)L.s_impulse.normalImpulses[e]=d.points[e].normalImpulse,L.s_impulse.tangentImpulses[e]=d.points[e].tangentImpulse;this.m_listener.PostSolve(c,L.s_impulse)}};L.prototype.AddBody=function(a){a.m_islandIndex=this.m_bodyCount;this.m_bodies[this.m_bodyCount++]=
a};L.prototype.AddContact=function(a){this.m_contacts[this.m_contactCount++]=a};L.prototype.AddJoint=function(a){this.m_joints[this.m_jointCount++]=a};Box2D.postDefs.push(function(){Box2D.Dynamics.b2Island.s_impulse=new F});D.b2TimeStep=function(){};D.prototype.Set=function(a){this.dt=a.dt;this.inv_dt=a.inv_dt;this.positionIterations=a.positionIterations;this.velocityIterations=a.velocityIterations;this.warmStarting=a.warmStarting};y.b2World=function(){this.s_stack=new Vector;this.m_contactManager=
new w;this.m_contactSolver=new N;this.m_island=new L};y.prototype.b2World=function(a,b){this.m_controllerList=this.m_jointList=this.m_contactList=this.m_bodyList=this.m_debugDraw=this.m_destructionListener=null;this.m_controllerCount=this.m_jointCount=this.m_contactCount=this.m_bodyCount=0;y.m_warmStarting=!0;y.m_continuousPhysics=!0;this.m_allowSleep=b;a.y=a.y;this.m_gravity=a;this.m_inv_dt0=0;this.m_contactManager.m_world=this;var c=new x;this.m_groundBody=this.CreateBody(c)};y.prototype.SetDestructionListener=
function(a){this.m_destructionListener=a};y.prototype.SetContactFilter=function(a){this.m_contactManager.m_contactFilter=a};y.prototype.SetContactListener=function(a){this.m_contactManager.m_contactListener=a};y.prototype.SetDebugDraw=function(a){this.m_debugDraw=a};y.prototype.SetBroadPhase=function(a){var b=this.m_contactManager.m_broadPhase;this.m_contactManager.m_broadPhase=a;for(var c=this.m_bodyList;c;c=c.m_next)for(var d=c.m_fixtureList;d;d=d.m_next)d.m_proxy=a.CreateProxy(b.GetFatAABB(d.m_proxy),
d)};y.prototype.Validate=function(){this.m_contactManager.m_broadPhase.Validate()};y.prototype.GetProxyCount=function(){return this.m_contactManager.m_broadPhase.GetProxyCount()};y.prototype.CreateBody=function(a){if(1==this.IsLocked())return null;a=new t(a,this);return a.m_prev=null,a.m_next=this.m_bodyList,this.m_bodyList&&(this.m_bodyList.m_prev=a),this.m_bodyList=a,++this.m_bodyCount,a};y.prototype.DestroyBody=function(a){if(1!=this.IsLocked()){for(var b=a.m_jointList;b;){var c=b,b=b.next;this.m_destructionListener&&
this.m_destructionListener.SayGoodbyeJoint(c.joint);this.DestroyJoint(c.joint)}for(b=a.m_controllerList;b;)c=b,b=b.nextController,c.controller.RemoveBody(a);for(b=a.m_contactList;b;)c=b,b=b.next,this.m_contactManager.Destroy(c.contact);a.m_contactList=null;for(b=a.m_fixtureList;b;)c=b,b=b.m_next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeFixture(c),c.DestroyProxy(this.m_contactManager.m_broadPhase),c.Destroy();a.m_fixtureList=null;a.m_fixtureCount=0;a.m_prev&&(a.m_prev.m_next=
a.m_next);a.m_next&&(a.m_next.m_prev=a.m_prev);a==this.m_bodyList&&(this.m_bodyList=a.m_next);--this.m_bodyCount}};y.prototype.CreateJoint=function(a){var b=W.Create(a,null);b.m_prev=null;(b.m_next=this.m_jointList)&&(this.m_jointList.m_prev=b);this.m_jointList=b;++this.m_jointCount;b.m_edgeA.joint=b;b.m_edgeA.other=b.m_bodyB;b.m_edgeA.prev=null;(b.m_edgeA.next=b.m_bodyA.m_jointList)&&(b.m_bodyA.m_jointList.prev=b.m_edgeA);b.m_bodyA.m_jointList=b.m_edgeA;b.m_edgeB.joint=b;b.m_edgeB.other=b.m_bodyA;
b.m_edgeB.prev=null;(b.m_edgeB.next=b.m_bodyB.m_jointList)&&(b.m_bodyB.m_jointList.prev=b.m_edgeB);b.m_bodyB.m_jointList=b.m_edgeB;var c=a.bodyA,d=a.bodyB;if(0==a.collideConnected)for(a=d.GetContactList();a;)a.other==c&&a.contact.FlagForFiltering(),a=a.next;return b};y.prototype.DestroyJoint=function(a){var b=a.m_collideConnected;a.m_prev&&(a.m_prev.m_next=a.m_next);a.m_next&&(a.m_next.m_prev=a.m_prev);a==this.m_jointList&&(this.m_jointList=a.m_next);var c=a.m_bodyA,d=a.m_bodyB;if(c.SetAwake(!0),
d.SetAwake(!0),a.m_edgeA.prev&&(a.m_edgeA.prev.next=a.m_edgeA.next),a.m_edgeA.next&&(a.m_edgeA.next.prev=a.m_edgeA.prev),a.m_edgeA==c.m_jointList&&(c.m_jointList=a.m_edgeA.next),a.m_edgeA.prev=null,a.m_edgeA.next=null,a.m_edgeB.prev&&(a.m_edgeB.prev.next=a.m_edgeB.next),a.m_edgeB.next&&(a.m_edgeB.next.prev=a.m_edgeB.prev),a.m_edgeB==d.m_jointList&&(d.m_jointList=a.m_edgeB.next),a.m_edgeB.prev=null,a.m_edgeB.next=null,W.Destroy(a,null),--this.m_jointCount,0==b)for(a=d.GetContactList();a;)a.other==
c&&a.contact.FlagForFiltering(),a=a.next};y.prototype.AddController=function(a){return a.m_next=this.m_controllerList,a.m_prev=null,this.m_controllerList=a,a.m_world=this,this.m_controllerCount++,a};y.prototype.RemoveController=function(a){a.m_prev&&(a.m_prev.m_next=a.m_next);a.m_next&&(a.m_next.m_prev=a.m_prev);this.m_controllerList==a&&(this.m_controllerList=a.m_next);this.m_controllerCount--};y.prototype.CreateController=function(a){if(a.m_world!=this)throw Error("Controller can only be a member of one world");
return a.m_next=this.m_controllerList,a.m_prev=null,this.m_controllerList&&(this.m_controllerList.m_prev=a),this.m_controllerList=a,++this.m_controllerCount,a.m_world=this,a};y.prototype.DestroyController=function(a){a.Clear();a.m_next&&(a.m_next.m_prev=a.m_prev);a.m_prev&&(a.m_prev.m_next=a.m_next);a==this.m_controllerList&&(this.m_controllerList=a.m_next);--this.m_controllerCount};y.prototype.SetWarmStarting=function(a){y.m_warmStarting=a};y.prototype.SetContinuousPhysics=function(a){y.m_continuousPhysics=
a};y.prototype.GetBodyCount=function(){return this.m_bodyCount};y.prototype.GetJointCount=function(){return this.m_jointCount};y.prototype.GetContactCount=function(){return this.m_contactCount};y.prototype.SetGravity=function(a){this.m_gravity=a};y.prototype.GetGravity=function(){return this.m_gravity};y.prototype.GetGroundBody=function(){return this.m_groundBody};y.prototype.Step=function(a,b,c){void 0===a&&(a=0);void 0===b&&(b=0);void 0===c&&(c=0);this.m_flags&y.e_newFixture&&(this.m_contactManager.FindNewContacts(),
this.m_flags&=~y.e_newFixture);this.m_flags|=y.e_locked;var d=y.s_timestep2;d.dt=a;d.velocityIterations=b;d.positionIterations=c;0<a?d.inv_dt=1/a:d.inv_dt=0;d.dtRatio=this.m_inv_dt0*a;d.warmStarting=y.m_warmStarting;this.m_contactManager.Collide();0<d.dt&&this.Solve(d);y.m_continuousPhysics&&0<d.dt&&this.SolveTOI(d);0<d.dt&&(this.m_inv_dt0=d.inv_dt);this.m_flags&=~y.e_locked};y.prototype.ClearForces=function(){for(var a=this.m_bodyList;a;a=a.m_next)a.m_force.SetZero(),a.m_torque=0};y.prototype.DrawDebugData=
function(){if(null!=this.m_debugDraw){this.m_debugDraw.m_sprite.graphics.clear();var a,b,c,f,h=this.m_debugDraw.GetFlags();f=(new d,new d,new d,new g,new g,[new d,new d,new d,new d]);var k=new e(0,0,0);if(h&B.e_shapeBit)for(a=this.m_bodyList;a;a=a.m_next){f=a.m_xf;for(b=a.GetFixtureList();b;b=b.m_next)c=b.GetShape(),0==a.IsActive()?(k.Set(0.5,0.5,0.3),this.DrawShape(c,f,k)):a.GetType()==t.b2_staticBody?(k.Set(0.5,0.9,0.5),this.DrawShape(c,f,k)):a.GetType()==t.b2_kinematicBody?(k.Set(0.5,0.5,0.9),
this.DrawShape(c,f,k)):0==a.IsAwake()?(k.Set(0.6,0.6,0.6),this.DrawShape(c,f,k)):(k.Set(0.9,0.7,0.7),this.DrawShape(c,f,k))}if(h&B.e_jointBit)for(a=this.m_jointList;a;a=a.m_next)this.DrawJoint(a);if(h&B.e_controllerBit)for(a=this.m_controllerList;a;a=a.m_next)a.Draw(this.m_debugDraw);if(h&B.e_pairBit){k.Set(0.3,0.9,0.9);for(a=this.m_contactManager.m_contactList;a;a=a.GetNext())c=a.GetFixtureA(),b=a.GetFixtureB(),c=c.GetAABB().GetCenter(),b=b.GetAABB().GetCenter(),this.m_debugDraw.DrawSegment(c,b,
k)}if(h&B.e_aabbBit){c=this.m_contactManager.m_broadPhase;f=[new d,new d,new d,new d];for(a=this.m_bodyList;a;a=a.GetNext())if(0!=a.IsActive())for(b=a.GetFixtureList();b;b=b.GetNext()){var m=c.GetFatAABB(b.m_proxy);f[0].Set(m.lowerBound.x,m.lowerBound.y);f[1].Set(m.upperBound.x,m.lowerBound.y);f[2].Set(m.upperBound.x,m.upperBound.y);f[3].Set(m.lowerBound.x,m.upperBound.y);this.m_debugDraw.DrawPolygon(f,4,k)}}if(h&B.e_centerOfMassBit)for(a=this.m_bodyList;a;a=a.m_next)f=y.s_xf,f.R=a.m_xf.R,f.position=
a.GetWorldCenter(),this.m_debugDraw.DrawTransform(f)}};y.prototype.QueryAABB=function(a,b){var c=this.m_contactManager.m_broadPhase;c.Query(function(b){return a(c.GetUserData(b))},b)};y.prototype.QueryShape=function(a,b,d){void 0===d&&(d=null);null==d&&(d=new c,d.SetIdentity());var e=this.m_contactManager.m_broadPhase,f=new g;b.ComputeAABB(f,d);e.Query(function(c){c=e.GetUserData(c)instanceof J?e.GetUserData(c):null;return u.TestOverlap(b,d,c.GetShape(),c.GetBody().GetTransform())?a(c):!0},f)};y.prototype.QueryPoint=
function(a,b){var c=this.m_contactManager.m_broadPhase,d=new g;d.lowerBound.Set(b.x-f.b2_linearSlop,b.y-f.b2_linearSlop);d.upperBound.Set(b.x+f.b2_linearSlop,b.y+f.b2_linearSlop);c.Query(function(d){d=c.GetUserData(d)instanceof J?c.GetUserData(d):null;return d.TestPoint(b)?a(d):!0},d)};y.prototype.RayCast=function(a,b,c){var e=this.m_contactManager.m_broadPhase,f=new n,g=new m(b,c);e.RayCast(function(g,h){var k=e.GetUserData(h),k=k instanceof J?k:null;if(k.RayCast(f,g)){var m=f.fraction,n=new d((1-
m)*b.x+m*c.x,(1-m)*b.y+m*c.y);return a(k,n,f.normal,m)}return g.maxFraction},g)};y.prototype.RayCastOne=function(a,b){var c;return this.RayCast(function(a,b,d,e){return void 0===e&&(e=0),c=a,e},a,b),c};y.prototype.RayCastAll=function(a,b){var c=new Vector;return this.RayCast(function(a,b,d,e){return c[c.length]=a,1},a,b),c};y.prototype.GetBodyList=function(){return this.m_bodyList};y.prototype.GetJointList=function(){return this.m_jointList};y.prototype.GetContactList=function(){return this.m_contactList};
y.prototype.IsLocked=function(){return 0<(this.m_flags&y.e_locked)};y.prototype.Solve=function(a){var b;for(b=this.m_controllerList;b;b=b.m_next)b.Step(a);var c=this.m_island;c.Initialize(this.m_bodyCount,this.m_contactCount,this.m_jointCount,null,this.m_contactManager.m_contactListener,this.m_contactSolver);for(b=this.m_bodyList;b;b=b.m_next)b.m_flags&=~t.e_islandFlag;for(var d=this.m_contactList;d;d=d.m_next)d.m_flags&=~H.e_islandFlag;for(d=this.m_jointList;d;d=d.m_next)d.m_islandFlag=!1;for(var d=
(parseInt(this.m_bodyCount),this.s_stack),e=this.m_bodyList;e;e=e.m_next)if(!(e.m_flags&t.e_islandFlag)&&0!=e.IsAwake()&&0!=e.IsActive()&&e.GetType()!=t.b2_staticBody){c.Clear();var f=0;d[f++]=e;for(e.m_flags|=t.e_islandFlag;0<f;)if(b=d[--f],c.AddBody(b),0==b.IsAwake()&&b.SetAwake(!0),b.GetType()!=t.b2_staticBody){for(var g,h=b.m_contactList;h;h=h.next)h.contact.m_flags&H.e_islandFlag||1!=h.contact.IsSensor()&&0!=h.contact.IsEnabled()&&0!=h.contact.IsTouching()&&(c.AddContact(h.contact),h.contact.m_flags|=
H.e_islandFlag,g=h.other,g.m_flags&t.e_islandFlag||(d[f++]=g,g.m_flags|=t.e_islandFlag));for(h=b.m_jointList;h;h=h.next)1!=h.joint.m_islandFlag&&(g=h.other,0!=g.IsActive()&&(c.AddJoint(h.joint),h.joint.m_islandFlag=!0,g.m_flags&t.e_islandFlag||(d[f++]=g,g.m_flags|=t.e_islandFlag)))}c.Solve(a,this.m_gravity,this.m_allowSleep);for(f=0;f<c.m_bodyCount;++f)b=c.m_bodies[f],b.GetType()==t.b2_staticBody&&(b.m_flags&=~t.e_islandFlag)}for(f=0;f<d.length&&d[f];++f)d[f]=null;for(b=this.m_bodyList;b;b=b.m_next)0!=
b.IsAwake()&&0!=b.IsActive()&&b.GetType()!=t.b2_staticBody&&b.SynchronizeFixtures();this.m_contactManager.FindNewContacts()};y.prototype.SolveTOI=function(a){var b,c,d,e,g,h,k,m=this.m_island;m.Initialize(this.m_bodyCount,f.b2_maxTOIContactsPerIsland,f.b2_maxTOIJointsPerIsland,null,this.m_contactManager.m_contactListener,this.m_contactSolver);var n=y.s_queue;for(b=this.m_bodyList;b;b=b.m_next)b.m_flags&=~t.e_islandFlag,b.m_sweep.t0=0;for(k=this.m_contactList;k;k=k.m_next)k.m_flags&=~(H.e_toiFlag|
H.e_islandFlag);for(k=this.m_jointList;k;k=k.m_next)k.m_islandFlag=!1;for(;;){var p=null,D=1;for(k=this.m_contactList;k;k=k.m_next)if(1!=k.IsSensor()&&0!=k.IsEnabled()&&0!=k.IsContinuous()){h=1;if(k.m_flags&H.e_toiFlag)h=k.m_toi;else{if(c=k.m_fixtureA,d=k.m_fixtureB,e=c.m_body,g=d.m_body,!(e.GetType()==t.b2_dynamicBody&&0!=e.IsAwake()||g.GetType()==t.b2_dynamicBody&&0!=g.IsAwake()))continue;var K=e.m_sweep.t0;e.m_sweep.t0<g.m_sweep.t0?(K=g.m_sweep.t0,e.m_sweep.Advance(K)):g.m_sweep.t0<e.m_sweep.t0&&
(K=e.m_sweep.t0,g.m_sweep.Advance(K));h=k.ComputeTOI(e.m_sweep,g.m_sweep);f.b2Assert(0<=h&&1>=h);0<h&&1>h&&(h=(1-h)*K+h,1<h&&(h=1));k.m_toi=h;k.m_flags|=H.e_toiFlag}Number.MIN_VALUE<h&&D>h&&(p=k,D=h)}if(null==p||1-100*Number.MIN_VALUE<D)break;if(c=p.m_fixtureA,d=p.m_fixtureB,e=c.m_body,g=d.m_body,y.s_backupA.Set(e.m_sweep),y.s_backupB.Set(g.m_sweep),e.Advance(D),g.Advance(D),p.Update(this.m_contactManager.m_contactListener),p.m_flags&=~H.e_toiFlag,1!=p.IsSensor()&&0!=p.IsEnabled()){if(0!=p.IsTouching()){h=
e;h.GetType()!=t.b2_dynamicBody&&(h=g);m.Clear();p=k=0;n[k+p++]=h;for(h.m_flags|=t.e_islandFlag;0<p;)if(b=n[k++],--p,m.AddBody(b),0==b.IsAwake()&&b.SetAwake(!0),b.GetType()==t.b2_dynamicBody){for(h=b.m_contactList;h&&m.m_contactCount!=m.m_contactCapacity;h=h.next)if(!(h.contact.m_flags&H.e_islandFlag)&&1!=h.contact.IsSensor()&&0!=h.contact.IsEnabled()&&0!=h.contact.IsTouching()){m.AddContact(h.contact);h.contact.m_flags|=H.e_islandFlag;var r=h.other;r.m_flags&t.e_islandFlag||(r.GetType()!=t.b2_staticBody&&
(r.Advance(D),r.SetAwake(!0)),n[k+p]=r,++p,r.m_flags|=t.e_islandFlag)}for(h=b.m_jointList;h;h=h.next)m.m_jointCount!=m.m_jointCapacity&&1!=h.joint.m_islandFlag&&(r=h.other,0!=r.IsActive()&&(m.AddJoint(h.joint),h.joint.m_islandFlag=!0,r.m_flags&t.e_islandFlag||(r.GetType()!=t.b2_staticBody&&(r.Advance(D),r.SetAwake(!0)),n[k+p]=r,++p,r.m_flags|=t.e_islandFlag)))}k=y.s_timestep;k.warmStarting=!1;k.dt=(1-D)*a.dt;k.inv_dt=1/k.dt;k.dtRatio=0;k.velocityIterations=a.velocityIterations;k.positionIterations=
a.positionIterations;m.SolveTOI(k);for(D=D=0;D<m.m_bodyCount;++D)if(b=m.m_bodies[D],b.m_flags&=~t.e_islandFlag,0!=b.IsAwake()&&b.GetType()==t.b2_dynamicBody){b.SynchronizeFixtures();for(h=b.m_contactList;h;h=h.next)h.contact.m_flags&=~H.e_toiFlag}for(D=0;D<m.m_contactCount;++D)k=m.m_contacts[D],k.m_flags&=~(H.e_toiFlag|H.e_islandFlag);for(D=0;D<m.m_jointCount;++D)k=m.m_joints[D],k.m_islandFlag=!1;this.m_contactManager.FindNewContacts()}}else e.m_sweep.Set(y.s_backupA),g.m_sweep.Set(y.s_backupB),e.SynchronizeTransform(),
g.SynchronizeTransform()}};y.prototype.DrawJoint=function(a){var b=a.GetBodyA(),c=a.GetBodyB(),d=b.m_xf.position,e=c.m_xf.position,f=a.GetAnchorA(),g=a.GetAnchorB(),h=y.s_jointColor;switch(a.m_type){case W.e_distanceJoint:this.m_debugDraw.DrawSegment(f,g,h);break;case W.e_pulleyJoint:b=a instanceof U?a:null;a=b.GetGroundAnchorA();b=b.GetGroundAnchorB();this.m_debugDraw.DrawSegment(a,f,h);this.m_debugDraw.DrawSegment(b,g,h);this.m_debugDraw.DrawSegment(a,b,h);break;case W.e_mouseJoint:this.m_debugDraw.DrawSegment(f,
g,h);break;default:b!=this.m_groundBody&&this.m_debugDraw.DrawSegment(d,f,h),this.m_debugDraw.DrawSegment(f,g,h),c!=this.m_groundBody&&this.m_debugDraw.DrawSegment(e,g,h)}};y.prototype.DrawShape=function(b,c,d){switch(b.m_type){case u.e_circleShape:var e=b instanceof p?b:null;b=a.MulX(c,e.m_p);this.m_debugDraw.DrawSolidCircle(b,e.m_radius,c.R.col1,d);break;case u.e_polygonShape:e=0;e=b instanceof v?b:null;b=parseInt(e.GetVertexCount());for(var f=e.GetVertices(),g=new Vector(b),e=0;b>e;++e)g[e]=a.MulX(c,
f[e]);this.m_debugDraw.DrawSolidPolygon(g,b,d);break;case u.e_edgeShape:e=b instanceof r?b:null,this.m_debugDraw.DrawSegment(a.MulX(c,e.GetVertex1()),a.MulX(c,e.GetVertex2()),d)}};Box2D.postDefs.push(function(){Box2D.Dynamics.b2World.s_timestep2=new D;Box2D.Dynamics.b2World.s_xf=new c;Box2D.Dynamics.b2World.s_backupA=new b;Box2D.Dynamics.b2World.s_backupB=new b;Box2D.Dynamics.b2World.s_timestep=new D;Box2D.Dynamics.b2World.s_queue=new Vector;Box2D.Dynamics.b2World.s_jointColor=new e(0.5,0.8,0.8);
Box2D.Dynamics.b2World.e_newFixture=1;Box2D.Dynamics.b2World.e_locked=2})})();
(function(){var a=Box2D.Collision.Shapes.b2CircleShape,b=(Box2D.Collision.Shapes.b2EdgeChainDef,Box2D.Collision.Shapes.b2EdgeShape),c=(Box2D.Collision.Shapes.b2MassData,Box2D.Collision.Shapes.b2PolygonShape),d=Box2D.Collision.Shapes.b2Shape,e=Box2D.Dynamics.Contacts.b2CircleContact,f=Box2D.Dynamics.Contacts.b2Contact,g=Box2D.Dynamics.Contacts.b2ContactConstraint,h=Box2D.Dynamics.Contacts.b2ContactConstraintPoint,k=Box2D.Dynamics.Contacts.b2ContactEdge,m=Box2D.Dynamics.Contacts.b2ContactFactory,n=
Box2D.Dynamics.Contacts.b2ContactRegister,p=Box2D.Dynamics.Contacts.b2ContactResult,r=Box2D.Dynamics.Contacts.b2ContactSolver,s=Box2D.Dynamics.Contacts.b2EdgeAndCircleContact,v=Box2D.Dynamics.Contacts.b2NullContact,u=Box2D.Dynamics.Contacts.b2PolyAndCircleContact,t=Box2D.Dynamics.Contacts.b2PolyAndEdgeContact,x=Box2D.Dynamics.Contacts.b2PolygonContact,A=Box2D.Dynamics.Contacts.b2PositionSolverManifold,F=Box2D.Dynamics.b2Body,z=(Box2D.Dynamics.b2BodyDef,Box2D.Dynamics.b2ContactFilter,Box2D.Dynamics.b2ContactImpulse,
Box2D.Dynamics.b2ContactListener,Box2D.Dynamics.b2ContactManager,Box2D.Dynamics.b2DebugDraw,Box2D.Dynamics.b2DestructionListener,Box2D.Dynamics.b2FilterData,Box2D.Dynamics.b2Fixture,Box2D.Dynamics.b2FixtureDef,Box2D.Dynamics.b2Island,Box2D.Dynamics.b2TimeStep),w=(Box2D.Dynamics.b2World,Box2D.Common.b2Color,Box2D.Common.b2internal,Box2D.Common.b2Settings),B=Box2D.Common.Math.b2Mat22,E=(Box2D.Common.Math.b2Mat33,Box2D.Common.Math.b2Math),I=(Box2D.Common.Math.b2Sweep,Box2D.Common.Math.b2Transform,Box2D.Common.Math.b2Vec2),
J=(Box2D.Common.Math.b2Vec3,Box2D.Collision.b2AABB,Box2D.Collision.b2Bound,Box2D.Collision.b2BoundValues,Box2D.Collision.b2Collision),O=Box2D.Collision.b2ContactID,L=(Box2D.Collision.b2ContactPoint,Box2D.Collision.b2Distance,Box2D.Collision.b2DistanceInput,Box2D.Collision.b2DistanceOutput,Box2D.Collision.b2DistanceProxy,Box2D.Collision.b2DynamicTree,Box2D.Collision.b2DynamicTreeBroadPhase,Box2D.Collision.b2DynamicTreeNode,Box2D.Collision.b2DynamicTreePair,Box2D.Collision.b2Manifold),D=(Box2D.Collision.b2ManifoldPoint,
Box2D.Collision.b2Point,Box2D.Collision.b2RayCastInput,Box2D.Collision.b2RayCastOutput,Box2D.Collision.b2Segment,Box2D.Collision.b2SeparationFunction,Box2D.Collision.b2Simplex,Box2D.Collision.b2SimplexCache,Box2D.Collision.b2SimplexVertex,Box2D.Collision.b2TimeOfImpact),y=Box2D.Collision.b2TOIInput,H=Box2D.Collision.b2WorldManifold;Box2D.Collision.ClipVertex;Box2D.Collision.Features;Box2D.Collision.IBroadPhase;Box2D.inherit(e,Box2D.Dynamics.Contacts.b2Contact);e.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;
e.b2CircleContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};e.Create=function(a){return new e};e.Destroy=function(a,b){};e.prototype.Reset=function(a,b){this.__super.Reset.call(this,a,b)};e.prototype.Evaluate=function(){var b=this.m_fixtureA.GetBody(),c=this.m_fixtureB.GetBody();J.CollideCircles(this.m_manifold,this.m_fixtureA.GetShape()instanceof a?this.m_fixtureA.GetShape():null,b.m_xf,this.m_fixtureB.GetShape()instanceof a?this.m_fixtureB.GetShape():null,c.m_xf)};
f.b2Contact=function(){this.m_nodeA=new k;this.m_nodeB=new k;this.m_manifold=new L;this.m_oldManifold=new L};f.prototype.GetManifold=function(){return this.m_manifold};f.prototype.GetWorldManifold=function(a){var b=this.m_fixtureA.GetBody(),c=this.m_fixtureB.GetBody(),d=this.m_fixtureA.GetShape(),e=this.m_fixtureB.GetShape();a.Initialize(this.m_manifold,b.GetTransform(),d.m_radius,c.GetTransform(),e.m_radius)};f.prototype.IsTouching=function(){return(this.m_flags&f.e_touchingFlag)==f.e_touchingFlag};
f.prototype.IsContinuous=function(){return(this.m_flags&f.e_continuousFlag)==f.e_continuousFlag};f.prototype.SetSensor=function(a){a?this.m_flags|=f.e_sensorFlag:this.m_flags&=~f.e_sensorFlag};f.prototype.IsSensor=function(){return(this.m_flags&f.e_sensorFlag)==f.e_sensorFlag};f.prototype.SetEnabled=function(a){a?this.m_flags|=f.e_enabledFlag:this.m_flags&=~f.e_enabledFlag};f.prototype.IsEnabled=function(){return(this.m_flags&f.e_enabledFlag)==f.e_enabledFlag};f.prototype.GetNext=function(){return this.m_next};
f.prototype.GetFixtureA=function(){return this.m_fixtureA};f.prototype.GetFixtureB=function(){return this.m_fixtureB};f.prototype.FlagForFiltering=function(){this.m_flags|=f.e_filterFlag};f.prototype.b2Contact=function(){};f.prototype.Reset=function(a,b){if(void 0===a&&(a=null),void 0===b&&(b=null),this.m_flags=f.e_enabledFlag,!a||!b)return this.m_fixtureA=null,void(this.m_fixtureB=null);(a.IsSensor()||b.IsSensor())&&(this.m_flags|=f.e_sensorFlag);var c=a.GetBody(),d=b.GetBody();(c.GetType()!=F.b2_dynamicBody||
c.IsBullet()||d.GetType()!=F.b2_dynamicBody||d.IsBullet())&&(this.m_flags|=f.e_continuousFlag);this.m_fixtureA=a;this.m_fixtureB=b;this.m_manifold.m_pointCount=0;this.m_next=this.m_prev=null;this.m_nodeA.contact=null;this.m_nodeA.prev=null;this.m_nodeA.next=null;this.m_nodeA.other=null;this.m_nodeB.contact=null;this.m_nodeB.prev=null;this.m_nodeB.next=null;this.m_nodeB.other=null};f.prototype.Update=function(a){var b=this.m_oldManifold;this.m_oldManifold=this.m_manifold;this.m_manifold=b;this.m_flags|=
f.e_enabledFlag;var c=!1,b=(this.m_flags&f.e_touchingFlag)==f.e_touchingFlag,e=this.m_fixtureA.m_body,g=this.m_fixtureB.m_body,h=this.m_fixtureA.m_aabb.TestOverlap(this.m_fixtureB.m_aabb);if(this.m_flags&f.e_sensorFlag)h&&(c=this.m_fixtureA.GetShape(),h=this.m_fixtureB.GetShape(),e=e.GetTransform(),g=g.GetTransform(),c=d.TestOverlap(c,e,h,g)),this.m_manifold.m_pointCount=0;else{if(e.GetType()!=F.b2_dynamicBody||e.IsBullet()||g.GetType()!=F.b2_dynamicBody||g.IsBullet()?this.m_flags|=f.e_continuousFlag:
this.m_flags&=~f.e_continuousFlag,h){this.Evaluate();c=0<this.m_manifold.m_pointCount;for(h=0;h<this.m_manifold.m_pointCount;++h){var k=this.m_manifold.m_points[h];k.m_normalImpulse=0;k.m_tangentImpulse=0;for(var m=k.m_id,n=0;n<this.m_oldManifold.m_pointCount;++n){var p=this.m_oldManifold.m_points[n];if(p.m_id.key==m.key){k.m_normalImpulse=p.m_normalImpulse;k.m_tangentImpulse=p.m_tangentImpulse;break}}}}else this.m_manifold.m_pointCount=0;c!=b&&(e.SetAwake(!0),g.SetAwake(!0))}c?this.m_flags|=f.e_touchingFlag:
this.m_flags&=~f.e_touchingFlag;0==b&&1==c&&a.BeginContact(this);1==b&&0==c&&a.EndContact(this);0==(this.m_flags&f.e_sensorFlag)&&a.PreSolve(this,this.m_oldManifold)};f.prototype.Evaluate=function(){};f.prototype.ComputeTOI=function(a,b){return f.s_input.proxyA.Set(this.m_fixtureA.GetShape()),f.s_input.proxyB.Set(this.m_fixtureB.GetShape()),f.s_input.sweepA=a,f.s_input.sweepB=b,f.s_input.tolerance=w.b2_linearSlop,D.TimeOfImpact(f.s_input)};Box2D.postDefs.push(function(){Box2D.Dynamics.Contacts.b2Contact.e_sensorFlag=
1;Box2D.Dynamics.Contacts.b2Contact.e_continuousFlag=2;Box2D.Dynamics.Contacts.b2Contact.e_islandFlag=4;Box2D.Dynamics.Contacts.b2Contact.e_toiFlag=8;Box2D.Dynamics.Contacts.b2Contact.e_touchingFlag=16;Box2D.Dynamics.Contacts.b2Contact.e_enabledFlag=32;Box2D.Dynamics.Contacts.b2Contact.e_filterFlag=64;Box2D.Dynamics.Contacts.b2Contact.s_input=new y});g.b2ContactConstraint=function(){this.localPlaneNormal=new I;this.localPoint=new I;this.normal=new I;this.normalMass=new B;this.K=new B};g.prototype.b2ContactConstraint=
function(){this.points=new Vector(w.b2_maxManifoldPoints);for(var a=0;a<w.b2_maxManifoldPoints;a++)this.points[a]=new h};h.b2ContactConstraintPoint=function(){this.localPoint=new I;this.rA=new I;this.rB=new I};k.b2ContactEdge=function(){};m.b2ContactFactory=function(){};m.prototype.b2ContactFactory=function(a){this.m_allocator=a;this.InitializeRegisters()};m.prototype.AddType=function(a,b,c,d){void 0===c&&(c=0);void 0===d&&(d=0);this.m_registers[c][d].createFcn=a;this.m_registers[c][d].destroyFcn=
b;this.m_registers[c][d].primary=!0;c!=d&&(this.m_registers[d][c].createFcn=a,this.m_registers[d][c].destroyFcn=b,this.m_registers[d][c].primary=!1)};m.prototype.InitializeRegisters=function(){this.m_registers=new Vector(d.e_shapeTypeCount);for(var a=0;a<d.e_shapeTypeCount;a++){this.m_registers[a]=new Vector(d.e_shapeTypeCount);for(var b=0;b<d.e_shapeTypeCount;b++)this.m_registers[a][b]=new n}this.AddType(e.Create,e.Destroy,d.e_circleShape,d.e_circleShape);this.AddType(u.Create,u.Destroy,d.e_polygonShape,
d.e_circleShape);this.AddType(x.Create,x.Destroy,d.e_polygonShape,d.e_polygonShape);this.AddType(s.Create,s.Destroy,d.e_edgeShape,d.e_circleShape);this.AddType(t.Create,t.Destroy,d.e_polygonShape,d.e_edgeShape)};m.prototype.Create=function(a,b){var c,d=parseInt(a.GetType()),e=parseInt(b.GetType()),d=this.m_registers[d][e];if(d.pool)return c=d.pool,d.pool=c.m_next,d.poolCount--,c.Reset(a,b),c;e=d.createFcn;return null!=e?d.primary?(c=e(this.m_allocator),c.Reset(a,b),c):(c=e(this.m_allocator),c.Reset(b,
a),c):null};m.prototype.Destroy=function(a){0<a.m_manifold.m_pointCount&&(a.m_fixtureA.m_body.SetAwake(!0),a.m_fixtureB.m_body.SetAwake(!0));var b=parseInt(a.m_fixtureA.GetType()),c=parseInt(a.m_fixtureB.GetType()),b=this.m_registers[b][c];b.poolCount++;a.m_next=b.pool;b.pool=a;b=b.destroyFcn;b(a,this.m_allocator)};n.b2ContactRegister=function(){};p.b2ContactResult=function(){this.position=new I;this.normal=new I;this.id=new O};r.b2ContactSolver=function(){this.m_step=new z;this.m_constraints=new Vector};
r.prototype.b2ContactSolver=function(){};r.prototype.Initialize=function(a,b,c,d){void 0===c&&(c=0);var e;this.m_step.Set(a);this.m_allocator=d;a=0;for(this.m_constraintCount=c;this.m_constraints.length<this.m_constraintCount;)this.m_constraints[this.m_constraints.length]=new g;for(a=0;c>a;++a){e=b[a];d=e.m_fixtureA;var f=e.m_fixtureB,h=d.m_shape.m_radius,k=f.m_shape.m_radius,m=d.m_body,n=f.m_body,p=e.GetManifold(),D=w.b2MixFriction(d.GetFriction(),f.GetFriction()),y=w.b2MixRestitution(d.GetRestitution(),
f.GetRestitution()),s=m.m_linearVelocity.x,H=m.m_linearVelocity.y,t=n.m_linearVelocity.x,u=n.m_linearVelocity.y,v=m.m_angularVelocity,x=n.m_angularVelocity;w.b2Assert(0<p.m_pointCount);r.s_worldManifold.Initialize(p,m.m_xf,h,n.m_xf,k);f=r.s_worldManifold.m_normal.x;e=r.s_worldManifold.m_normal.y;d=this.m_constraints[a];d.bodyA=m;d.bodyB=n;d.manifold=p;d.normal.x=f;d.normal.y=e;d.pointCount=p.m_pointCount;d.friction=D;d.restitution=y;d.localPlaneNormal.x=p.m_localPlaneNormal.x;d.localPlaneNormal.y=
p.m_localPlaneNormal.y;d.localPoint.x=p.m_localPoint.x;d.localPoint.y=p.m_localPoint.y;d.radius=h+k;d.type=p.m_type;for(h=0;h<d.pointCount;++h){D=p.m_points[h];k=d.points[h];k.normalImpulse=D.m_normalImpulse;k.tangentImpulse=D.m_tangentImpulse;k.localPoint.SetV(D.m_localPoint);var D=k.rA.x=r.s_worldManifold.m_points[h].x-m.m_sweep.c.x,y=k.rA.y=r.s_worldManifold.m_points[h].y-m.m_sweep.c.y,A=k.rB.x=r.s_worldManifold.m_points[h].x-n.m_sweep.c.x,z=k.rB.y=r.s_worldManifold.m_points[h].y-n.m_sweep.c.y,
B=D*e-y*f,F=A*e-z*f,B=B*B,F=F*F;k.normalMass=1/(m.m_invMass+n.m_invMass+m.m_invI*B+n.m_invI*F);var E=m.m_mass*m.m_invMass+n.m_mass*n.m_invMass,E=E+(m.m_mass*m.m_invI*B+n.m_mass*n.m_invI*F);k.equalizedMass=1/E;F=e;E=-f;B=D*E-y*F;F=A*E-z*F;B*=B;F*=F;k.tangentMass=1/(m.m_invMass+n.m_invMass+m.m_invI*B+n.m_invI*F);k.velocityBias=0;D=d.normal.x*(t+-x*z-s- -v*y)+d.normal.y*(u+x*A-H-v*D);D<-w.b2_velocityThreshold&&(k.velocityBias+=-d.restitution*D)}2==d.pointCount&&(u=d.points[0],t=d.points[1],p=m.m_invMass,
m=m.m_invI,s=n.m_invMass,n=n.m_invI,H=u.rA.x*e-u.rA.y*f,u=u.rB.x*e-u.rB.y*f,v=t.rA.x*e-t.rA.y*f,t=t.rB.x*e-t.rB.y*f,f=p+s+m*H*H+n*u*u,e=p+s+m*v*v+n*t*t,n=p+s+m*H*v+n*u*t,100*(f*e-n*n)>f*f?(d.K.col1.Set(f,n),d.K.col2.Set(n,e),d.K.GetInverse(d.normalMass)):d.pointCount=1)}};r.prototype.InitVelocityConstraints=function(a){for(var b=0;b<this.m_constraintCount;++b){var c=this.m_constraints[b],d=c.bodyA,e=c.bodyB,f=d.m_invMass,g=d.m_invI,h=e.m_invMass,k=e.m_invI,m=c.normal.x,n=c.normal.y,p=n,D=-m,y=0,r=
0;if(a.warmStarting){r=c.pointCount;for(y=0;r>y;++y){var s=c.points[y];s.normalImpulse*=a.dtRatio;s.tangentImpulse*=a.dtRatio;var H=s.normalImpulse*m+s.tangentImpulse*p,t=s.normalImpulse*n+s.tangentImpulse*D;d.m_angularVelocity-=g*(s.rA.x*t-s.rA.y*H);d.m_linearVelocity.x-=f*H;d.m_linearVelocity.y-=f*t;e.m_angularVelocity+=k*(s.rB.x*t-s.rB.y*H);e.m_linearVelocity.x+=h*H;e.m_linearVelocity.y+=h*t}}else{r=c.pointCount;for(y=0;r>y;++y)d=c.points[y],d.normalImpulse=0,d.tangentImpulse=0}}};r.prototype.SolveVelocityConstraints=
function(){for(var a,b,c=0,d=0,e=0,f=0,g=e=e=d=d=0,h=d=d=0,k=d=f=0,m=0,n=0;n<this.m_constraintCount;++n){var f=this.m_constraints[n],p=f.bodyA,D=f.bodyB,y=p.m_angularVelocity,r=D.m_angularVelocity,s=p.m_linearVelocity,H=D.m_linearVelocity,t=p.m_invMass,u=p.m_invI,v=D.m_invMass,w=D.m_invI,k=f.normal.x,x=m=f.normal.y;b=-k;h=f.friction;for(c=0;c<f.pointCount;c++)a=f.points[c],d=H.x-r*a.rB.y-s.x+y*a.rA.y,e=H.y+r*a.rB.x-s.y-y*a.rA.x,d=d*x+e*b,d=a.tangentMass*-d,e=h*a.normalImpulse,e=E.Clamp(a.tangentImpulse+
d,-e,e),d=e-a.tangentImpulse,g=d*x,d*=b,s.x-=t*g,s.y-=t*d,y-=u*(a.rA.x*d-a.rA.y*g),H.x+=v*g,H.y+=v*d,r+=w*(a.rB.x*d-a.rB.y*g),a.tangentImpulse=e;parseInt(f.pointCount);if(1==f.pointCount)a=f.points[0],d=H.x+-r*a.rB.y-s.x- -y*a.rA.y,e=H.y+r*a.rB.x-s.y-y*a.rA.x,f=d*k+e*m,d=-a.normalMass*(f-a.velocityBias),e=a.normalImpulse+d,e=0<e?e:0,d=e-a.normalImpulse,g=d*k,d*=m,s.x-=t*g,s.y-=t*d,y-=u*(a.rA.x*d-a.rA.y*g),H.x+=v*g,H.y+=v*d,r+=w*(a.rB.x*d-a.rB.y*g),a.normalImpulse=e;else{a=f.points[0];var c=f.points[1],
d=a.normalImpulse,h=c.normalImpulse,A=(H.x-r*a.rB.y-s.x+y*a.rA.y)*k+(H.y+r*a.rB.x-s.y-y*a.rA.x)*m,e=(H.x-r*c.rB.y-s.x+y*c.rA.y)*k+(H.y+r*c.rB.x-s.y-y*c.rA.x)*m,g=A-a.velocityBias,z=e-c.velocityBias;b=f.K;g-=b.col1.x*d+b.col2.x*h;for(z-=b.col1.y*d+b.col2.y*h;;){b=f.normalMass;x=-(b.col1.x*g+b.col2.x*z);b=-(b.col1.y*g+b.col2.y*z);if(0<=x&&0<=b){d=x-d;h=b-h;f=d*k;d*=m;k*=h;m*=h;s.x-=t*(f+k);s.y-=t*(d+m);y-=u*(a.rA.x*d-a.rA.y*f+c.rA.x*m-c.rA.y*k);H.x+=v*(f+k);H.y+=v*(d+m);r+=w*(a.rB.x*d-a.rB.y*f+c.rB.x*
m-c.rB.y*k);a.normalImpulse=x;c.normalImpulse=b;break}if(x=-a.normalMass*g,b=0,A=0,e=f.K.col1.y*x+z,0<=x&&0<=e){d=x-d;h=b-h;f=d*k;d*=m;k*=h;m*=h;s.x-=t*(f+k);s.y-=t*(d+m);y-=u*(a.rA.x*d-a.rA.y*f+c.rA.x*m-c.rA.y*k);H.x+=v*(f+k);H.y+=v*(d+m);r+=w*(a.rB.x*d-a.rB.y*f+c.rB.x*m-c.rB.y*k);a.normalImpulse=x;c.normalImpulse=b;break}if(x=0,b=-c.normalMass*z,A=f.K.col2.x*b+g,e=0,0<=b&&0<=A){d=x-d;h=b-h;f=d*k;d*=m;k*=h;m*=h;s.x-=t*(f+k);s.y-=t*(d+m);y-=u*(a.rA.x*d-a.rA.y*f+c.rA.x*m-c.rA.y*k);H.x+=v*(f+k);H.y+=
v*(d+m);r+=w*(a.rB.x*d-a.rB.y*f+c.rB.x*m-c.rB.y*k);a.normalImpulse=x;c.normalImpulse=b;break}if(x=0,b=0,A=g,e=z,0<=A&&0<=e){d=x-d;h=b-h;f=d*k;d*=m;k*=h;m*=h;s.x-=t*(f+k);s.y-=t*(d+m);y-=u*(a.rA.x*d-a.rA.y*f+c.rA.x*m-c.rA.y*k);H.x+=v*(f+k);H.y+=v*(d+m);r+=w*(a.rB.x*d-a.rB.y*f+c.rB.x*m-c.rB.y*k);a.normalImpulse=x;c.normalImpulse=b;break}break}}p.m_angularVelocity=y;D.m_angularVelocity=r}};r.prototype.FinalizeVelocityConstraints=function(){for(var a=0;a<this.m_constraintCount;++a)for(var b=this.m_constraints[a],
c=b.manifold,d=0;d<b.pointCount;++d){var e=c.m_points[d],f=b.points[d];e.m_normalImpulse=f.normalImpulse;e.m_tangentImpulse=f.tangentImpulse}};r.prototype.SolvePositionConstraints=function(a){void 0===a&&(a=0);for(var b=0,c=0;c<this.m_constraintCount;c++){var d=this.m_constraints[c],e=d.bodyA,f=d.bodyB,g=e.m_mass*e.m_invMass,h=e.m_mass*e.m_invI,k=f.m_mass*f.m_invMass,m=f.m_mass*f.m_invI;r.s_psm.Initialize(d);for(var n=r.s_psm.m_normal,p=0;p<d.pointCount;p++){var D=d.points[p],y=r.s_psm.m_points[p],
s=r.s_psm.m_separations[p],H=y.x-e.m_sweep.c.x,t=y.y-e.m_sweep.c.y,u=y.x-f.m_sweep.c.x,y=y.y-f.m_sweep.c.y,b=s>b?b:s,s=E.Clamp(a*(s+w.b2_linearSlop),-w.b2_maxLinearCorrection,0),s=-D.equalizedMass*s,D=s*n.x,s=s*n.y;e.m_sweep.c.x-=g*D;e.m_sweep.c.y-=g*s;e.m_sweep.a-=h*(H*s-t*D);e.SynchronizeTransform();f.m_sweep.c.x+=k*D;f.m_sweep.c.y+=k*s;f.m_sweep.a+=m*(u*s-y*D);f.SynchronizeTransform()}}return b>-1.5*w.b2_linearSlop};Box2D.postDefs.push(function(){Box2D.Dynamics.Contacts.b2ContactSolver.s_worldManifold=
new H;Box2D.Dynamics.Contacts.b2ContactSolver.s_psm=new A});Box2D.inherit(s,Box2D.Dynamics.Contacts.b2Contact);s.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;s.b2EdgeAndCircleContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};s.Create=function(a){return new s};s.Destroy=function(a,b){};s.prototype.Reset=function(a,b){this.__super.Reset.call(this,a,b)};s.prototype.Evaluate=function(){var c=this.m_fixtureA.GetBody(),d=this.m_fixtureB.GetBody();this.b2CollideEdgeAndCircle(this.m_manifold,
this.m_fixtureA.GetShape()instanceof b?this.m_fixtureA.GetShape():null,c.m_xf,this.m_fixtureB.GetShape()instanceof a?this.m_fixtureB.GetShape():null,d.m_xf)};s.prototype.b2CollideEdgeAndCircle=function(a,b,c,d,e){};Box2D.inherit(v,Box2D.Dynamics.Contacts.b2Contact);v.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;v.b2NullContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};v.prototype.b2NullContact=function(){this.__super.b2Contact.call(this)};v.prototype.Evaluate=
function(){};Box2D.inherit(u,Box2D.Dynamics.Contacts.b2Contact);u.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;u.b2PolyAndCircleContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};u.Create=function(a){return new u};u.Destroy=function(a,b){};u.prototype.Reset=function(a,b){this.__super.Reset.call(this,a,b);w.b2Assert(a.GetType()==d.e_polygonShape);w.b2Assert(b.GetType()==d.e_circleShape)};u.prototype.Evaluate=function(){var b=this.m_fixtureA.m_body,
d=this.m_fixtureB.m_body;J.CollidePolygonAndCircle(this.m_manifold,this.m_fixtureA.GetShape()instanceof c?this.m_fixtureA.GetShape():null,b.m_xf,this.m_fixtureB.GetShape()instanceof a?this.m_fixtureB.GetShape():null,d.m_xf)};Box2D.inherit(t,Box2D.Dynamics.Contacts.b2Contact);t.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;t.b2PolyAndEdgeContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};t.Create=function(a){return new t};t.Destroy=function(a,b){};
t.prototype.Reset=function(a,b){this.__super.Reset.call(this,a,b);w.b2Assert(a.GetType()==d.e_polygonShape);w.b2Assert(b.GetType()==d.e_edgeShape)};t.prototype.Evaluate=function(){var a=this.m_fixtureA.GetBody(),d=this.m_fixtureB.GetBody();this.b2CollidePolyAndEdge(this.m_manifold,this.m_fixtureA.GetShape()instanceof c?this.m_fixtureA.GetShape():null,a.m_xf,this.m_fixtureB.GetShape()instanceof b?this.m_fixtureB.GetShape():null,d.m_xf)};t.prototype.b2CollidePolyAndEdge=function(a,b,c,d,e){};Box2D.inherit(x,
Box2D.Dynamics.Contacts.b2Contact);x.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;x.b2PolygonContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};x.Create=function(a){return new x};x.Destroy=function(a,b){};x.prototype.Reset=function(a,b){this.__super.Reset.call(this,a,b)};x.prototype.Evaluate=function(){var a=this.m_fixtureA.GetBody(),b=this.m_fixtureB.GetBody();J.CollidePolygons(this.m_manifold,this.m_fixtureA.GetShape()instanceof c?this.m_fixtureA.GetShape():
null,a.m_xf,this.m_fixtureB.GetShape()instanceof c?this.m_fixtureB.GetShape():null,b.m_xf)};A.b2PositionSolverManifold=function(){};A.prototype.b2PositionSolverManifold=function(){this.m_normal=new I;this.m_separations=new Vector_a2j_Number(w.b2_maxManifoldPoints);this.m_points=new Vector(w.b2_maxManifoldPoints);for(var a=0;a<w.b2_maxManifoldPoints;a++)this.m_points[a]=new I};A.prototype.Initialize=function(a){w.b2Assert(0<a.pointCount);var b,c,d=0,e=0,f=c=0,g=0;switch(a.type){case L.e_circles:b=
a.bodyA.m_xf.R;c=a.localPoint;d=a.bodyA.m_xf.position.x+(b.col1.x*c.x+b.col2.x*c.y);e=a.bodyA.m_xf.position.y+(b.col1.y*c.x+b.col2.y*c.y);b=a.bodyB.m_xf.R;c=a.points[0].localPoint;f=a.bodyB.m_xf.position.x+(b.col1.x*c.x+b.col2.x*c.y);b=a.bodyB.m_xf.position.y+(b.col1.y*c.x+b.col2.y*c.y);c=f-d;var g=b-e,h=c*c+g*g;h>Number.MIN_VALUE*Number.MIN_VALUE?(h=Math.sqrt(h),this.m_normal.x=c/h,this.m_normal.y=g/h):(this.m_normal.x=1,this.m_normal.y=0);this.m_points[0].x=0.5*(d+f);this.m_points[0].y=0.5*(e+b);
this.m_separations[0]=c*this.m_normal.x+g*this.m_normal.y-a.radius;break;case L.e_faceA:b=a.bodyA.m_xf.R;c=a.localPlaneNormal;this.m_normal.x=b.col1.x*c.x+b.col2.x*c.y;this.m_normal.y=b.col1.y*c.x+b.col2.y*c.y;b=a.bodyA.m_xf.R;c=a.localPoint;f=a.bodyA.m_xf.position.x+(b.col1.x*c.x+b.col2.x*c.y);g=a.bodyA.m_xf.position.y+(b.col1.y*c.x+b.col2.y*c.y);b=a.bodyB.m_xf.R;for(d=0;d<a.pointCount;++d)c=a.points[d].localPoint,e=a.bodyB.m_xf.position.x+(b.col1.x*c.x+b.col2.x*c.y),c=a.bodyB.m_xf.position.y+(b.col1.y*
c.x+b.col2.y*c.y),this.m_separations[d]=(e-f)*this.m_normal.x+(c-g)*this.m_normal.y-a.radius,this.m_points[d].x=e,this.m_points[d].y=c;break;case L.e_faceB:b=a.bodyB.m_xf.R;c=a.localPlaneNormal;this.m_normal.x=b.col1.x*c.x+b.col2.x*c.y;this.m_normal.y=b.col1.y*c.x+b.col2.y*c.y;b=a.bodyB.m_xf.R;c=a.localPoint;f=a.bodyB.m_xf.position.x+(b.col1.x*c.x+b.col2.x*c.y);g=a.bodyB.m_xf.position.y+(b.col1.y*c.x+b.col2.y*c.y);b=a.bodyA.m_xf.R;for(d=0;d<a.pointCount;++d)c=a.points[d].localPoint,e=a.bodyA.m_xf.position.x+
(b.col1.x*c.x+b.col2.x*c.y),c=a.bodyA.m_xf.position.y+(b.col1.y*c.x+b.col2.y*c.y),this.m_separations[d]=(e-f)*this.m_normal.x+(c-g)*this.m_normal.y-a.radius,this.m_points[d].Set(e,c);this.m_normal.x*=-1;this.m_normal.y*=-1}};Box2D.postDefs.push(function(){Box2D.Dynamics.Contacts.b2PositionSolverManifold.circlePointA=new I;Box2D.Dynamics.Contacts.b2PositionSolverManifold.circlePointB=new I})})();
(function(){var a=(Box2D.Dynamics.b2Body,Box2D.Dynamics.b2BodyDef,Box2D.Dynamics.b2ContactFilter,Box2D.Dynamics.b2ContactImpulse,Box2D.Dynamics.b2ContactListener,Box2D.Dynamics.b2ContactManager,Box2D.Dynamics.b2DebugDraw,Box2D.Dynamics.b2DestructionListener,Box2D.Dynamics.b2FilterData,Box2D.Dynamics.b2Fixture,Box2D.Dynamics.b2FixtureDef,Box2D.Dynamics.b2Island,Box2D.Dynamics.b2TimeStep,Box2D.Dynamics.b2World,Box2D.Common.Math.b2Mat22),b=(Box2D.Common.Math.b2Mat33,Box2D.Common.Math.b2Math),c=(Box2D.Common.Math.b2Sweep,
Box2D.Common.Math.b2Transform,Box2D.Common.Math.b2Vec2),d=(Box2D.Common.Math.b2Vec3,Box2D.Common.b2Color),e=(Box2D.Common.b2internal,Box2D.Common.b2Settings,Box2D.Collision.Shapes.b2CircleShape,Box2D.Collision.Shapes.b2EdgeChainDef,Box2D.Collision.Shapes.b2EdgeShape,Box2D.Collision.Shapes.b2MassData,Box2D.Collision.Shapes.b2PolygonShape,Box2D.Collision.Shapes.b2Shape,Box2D.Dynamics.Controllers.b2BuoyancyController),f=Box2D.Dynamics.Controllers.b2ConstantAccelController,g=Box2D.Dynamics.Controllers.b2ConstantForceController,
h=Box2D.Dynamics.Controllers.b2Controller,k=Box2D.Dynamics.Controllers.b2ControllerEdge,m=Box2D.Dynamics.Controllers.b2GravityController,n=Box2D.Dynamics.Controllers.b2TensorDampingController;Box2D.inherit(e,Box2D.Dynamics.Controllers.b2Controller);e.prototype.__super=Box2D.Dynamics.Controllers.b2Controller.prototype;e.b2BuoyancyController=function(){Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this,arguments);this.normal=new c(0,-1);this.density=this.offset=0;this.velocity=new c(0,
0);this.linearDrag=2;this.angularDrag=1;this.useDensity=!1;this.useWorldGravity=!0;this.gravity=null};e.prototype.Step=function(a){if(this.m_bodyList){this.useWorldGravity&&(this.gravity=this.GetWorld().GetGravity().Copy());for(a=this.m_bodyList;a;a=a.nextBody){var b=a.body;if(0!=b.IsAwake()){for(var d=new c,e=new c,f=0,g=0,h=b.GetFixtureList();h;h=h.GetNext()){var k=new c,m=h.GetShape().ComputeSubmergedArea(this.normal,this.offset,b.GetTransform(),k),f=f+m;d.x+=m*k.x;d.y+=m*k.y;var n=0,n=(this.useDensity,
1),g=g+m*n;e.x+=m*k.x*n;e.y+=m*k.y*n}if(d.x/=f,d.y/=f,e.x/=g,e.y/=g,!(f<Number.MIN_VALUE))g=this.gravity.GetNegative(),g.Multiply(this.density*f),b.ApplyForce(g,e),e=b.GetLinearVelocityFromWorldPoint(d),e.Subtract(this.velocity),e.Multiply(-this.linearDrag*f),b.ApplyForce(e,d),b.ApplyTorque(-b.GetInertia()/b.GetMass()*f*b.GetAngularVelocity()*this.angularDrag)}}}};e.prototype.Draw=function(a){var b=new c,e=new c;b.x=this.normal.x*this.offset+1E3*this.normal.y;b.y=this.normal.y*this.offset-1E3*this.normal.x;
e.x=this.normal.x*this.offset-1E3*this.normal.y;e.y=this.normal.y*this.offset+1E3*this.normal.x;var f=new d(0,0,1);a.DrawSegment(b,e,f)};Box2D.inherit(f,Box2D.Dynamics.Controllers.b2Controller);f.prototype.__super=Box2D.Dynamics.Controllers.b2Controller.prototype;f.b2ConstantAccelController=function(){Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this,arguments);this.A=new c(0,0)};f.prototype.Step=function(a){a=new c(this.A.x*a.dt,this.A.y*a.dt);for(var b=this.m_bodyList;b;b=b.nextBody){var d=
b.body;d.IsAwake()&&d.SetLinearVelocity(new c(d.GetLinearVelocity().x+a.x,d.GetLinearVelocity().y+a.y))}};Box2D.inherit(g,Box2D.Dynamics.Controllers.b2Controller);g.prototype.__super=Box2D.Dynamics.Controllers.b2Controller.prototype;g.b2ConstantForceController=function(){Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this,arguments);this.F=new c(0,0)};g.prototype.Step=function(a){for(a=this.m_bodyList;a;a=a.nextBody){var b=a.body;b.IsAwake()&&b.ApplyForce(this.F,b.GetWorldCenter())}};
h.b2Controller=function(){};h.prototype.Step=function(a){};h.prototype.Draw=function(a){};h.prototype.AddBody=function(a){var b=new k;b.controller=this;b.body=a;b.nextBody=this.m_bodyList;b.prevBody=null;this.m_bodyList=b;b.nextBody&&(b.nextBody.prevBody=b);this.m_bodyCount++;b.nextController=a.m_controllerList;b.prevController=null;a.m_controllerList=b;b.nextController&&(b.nextController.prevController=b);a.m_controllerCount++};h.prototype.RemoveBody=function(a){for(var b=a.m_controllerList;b&&b.controller!=
this;)b=b.nextController;b.prevBody&&(b.prevBody.nextBody=b.nextBody);b.nextBody&&(b.nextBody.prevBody=b.prevBody);b.nextController&&(b.nextController.prevController=b.prevController);b.prevController&&(b.prevController.nextController=b.nextController);this.m_bodyList==b&&(this.m_bodyList=b.nextBody);a.m_controllerList==b&&(a.m_controllerList=b.nextController);a.m_controllerCount--;this.m_bodyCount--};h.prototype.Clear=function(){for(;this.m_bodyList;)this.RemoveBody(this.m_bodyList.body)};h.prototype.GetNext=
function(){return this.m_next};h.prototype.GetWorld=function(){return this.m_world};h.prototype.GetBodyList=function(){return this.m_bodyList};k.b2ControllerEdge=function(){};Box2D.inherit(m,Box2D.Dynamics.Controllers.b2Controller);m.prototype.__super=Box2D.Dynamics.Controllers.b2Controller.prototype;m.b2GravityController=function(){Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this,arguments);this.G=1;this.invSqr=!0};m.prototype.Step=function(a){var b=a=null,d=null,e=0,f=null,g=null,
h=null,k=0,m=0,n=0,w=null;if(this.invSqr)for(a=this.m_bodyList;a;a=a.nextBody){b=a.body;d=b.GetWorldCenter();e=b.GetMass();for(f=this.m_bodyList;f!=a;f=f.nextBody)g=f.body,h=g.GetWorldCenter(),k=h.x-d.x,m=h.y-d.y,n=k*k+m*m,n<Number.MIN_VALUE||(w=new c(k,m),w.Multiply(this.G/n/Math.sqrt(n)*e*g.GetMass()),b.IsAwake()&&b.ApplyForce(w,d),w.Multiply(-1),g.IsAwake()&&g.ApplyForce(w,h))}else for(a=this.m_bodyList;a;a=a.nextBody){b=a.body;d=b.GetWorldCenter();e=b.GetMass();for(f=this.m_bodyList;f!=a;f=f.nextBody)g=
f.body,h=g.GetWorldCenter(),k=h.x-d.x,m=h.y-d.y,n=k*k+m*m,n<Number.MIN_VALUE||(w=new c(k,m),w.Multiply(this.G/n*e*g.GetMass()),b.IsAwake()&&b.ApplyForce(w,d),w.Multiply(-1),g.IsAwake()&&g.ApplyForce(w,h))}};Box2D.inherit(n,Box2D.Dynamics.Controllers.b2Controller);n.prototype.__super=Box2D.Dynamics.Controllers.b2Controller.prototype;n.b2TensorDampingController=function(){Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this,arguments);this.T=new a;this.maxTimestep=0};n.prototype.SetAxisAligned=
function(a,b){void 0===a&&(a=0);void 0===b&&(b=0);this.T.col1.x=-a;this.T.col1.y=0;this.T.col2.x=0;this.T.col2.y=-b;0<a||0<b?this.maxTimestep=1/Math.max(a,b):this.maxTimestep=0};n.prototype.Step=function(a){a=a.dt;if(!(a<=Number.MIN_VALUE)){a>this.maxTimestep&&0<this.maxTimestep&&(a=this.maxTimestep);for(var d=this.m_bodyList;d;d=d.nextBody){var e=d.body;if(e.IsAwake()){var f=e.GetWorldVector(b.MulMV(this.T,e.GetLocalVector(e.GetLinearVelocity())));e.SetLinearVelocity(new c(e.GetLinearVelocity().x+
f.x*a,e.GetLinearVelocity().y+f.y*a))}}}}})();
(function(){var a=(Box2D.Common.b2Color,Box2D.Common.b2internal,Box2D.Common.b2Settings),b=Box2D.Common.Math.b2Mat22,c=Box2D.Common.Math.b2Mat33,d=Box2D.Common.Math.b2Math,e=(Box2D.Common.Math.b2Sweep,Box2D.Common.Math.b2Transform,Box2D.Common.Math.b2Vec2),f=Box2D.Common.Math.b2Vec3,g=Box2D.Dynamics.Joints.b2DistanceJoint,h=Box2D.Dynamics.Joints.b2DistanceJointDef,k=Box2D.Dynamics.Joints.b2FrictionJoint,m=Box2D.Dynamics.Joints.b2FrictionJointDef,n=Box2D.Dynamics.Joints.b2GearJoint,p=Box2D.Dynamics.Joints.b2GearJointDef,
r=Box2D.Dynamics.Joints.b2Jacobian,s=Box2D.Dynamics.Joints.b2Joint,v=Box2D.Dynamics.Joints.b2JointDef,u=Box2D.Dynamics.Joints.b2JointEdge,t=Box2D.Dynamics.Joints.b2LineJoint,x=Box2D.Dynamics.Joints.b2LineJointDef,A=Box2D.Dynamics.Joints.b2MouseJoint,F=Box2D.Dynamics.Joints.b2MouseJointDef,z=Box2D.Dynamics.Joints.b2PrismaticJoint,w=Box2D.Dynamics.Joints.b2PrismaticJointDef,B=Box2D.Dynamics.Joints.b2PulleyJoint,E=Box2D.Dynamics.Joints.b2PulleyJointDef,I=Box2D.Dynamics.Joints.b2RevoluteJoint,J=Box2D.Dynamics.Joints.b2RevoluteJointDef,
O=Box2D.Dynamics.Joints.b2WeldJoint,L=Box2D.Dynamics.Joints.b2WeldJointDef;Box2D.Dynamics.b2Body;Box2D.Dynamics.b2BodyDef;Box2D.Dynamics.b2ContactFilter;Box2D.Dynamics.b2ContactImpulse;Box2D.Dynamics.b2ContactListener;Box2D.Dynamics.b2ContactManager;Box2D.Dynamics.b2DebugDraw;Box2D.Dynamics.b2DestructionListener;Box2D.Dynamics.b2FilterData;Box2D.Dynamics.b2Fixture;Box2D.Dynamics.b2FixtureDef;Box2D.Dynamics.b2Island;Box2D.Dynamics.b2TimeStep;Box2D.Dynamics.b2World;Box2D.inherit(g,Box2D.Dynamics.Joints.b2Joint);
g.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;g.b2DistanceJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_localAnchor1=new e;this.m_localAnchor2=new e;this.m_u=new e};g.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};g.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};g.prototype.GetReactionForce=function(a){return void 0===a&&(a=0),new e(a*this.m_impulse*this.m_u.x,a*this.m_impulse*
this.m_u.y)};g.prototype.GetReactionTorque=function(a){return 0};g.prototype.GetLength=function(){return this.m_length};g.prototype.SetLength=function(a){void 0===a&&(a=0);this.m_length=a};g.prototype.GetFrequency=function(){return this.m_frequencyHz};g.prototype.SetFrequency=function(a){void 0===a&&(a=0);this.m_frequencyHz=a};g.prototype.GetDampingRatio=function(){return this.m_dampingRatio};g.prototype.SetDampingRatio=function(a){void 0===a&&(a=0);this.m_dampingRatio=a};g.prototype.b2DistanceJoint=
function(a){this.__super.b2Joint.call(this,a);this.m_localAnchor1.SetV(a.localAnchorA);this.m_localAnchor2.SetV(a.localAnchorB);this.m_length=a.length;this.m_frequencyHz=a.frequencyHz;this.m_dampingRatio=a.dampingRatio;this.m_bias=this.m_gamma=this.m_impulse=0};g.prototype.InitVelocityConstraints=function(b){var c,d=0,e=this.m_bodyA,f=this.m_bodyB;c=e.m_xf.R;var g=this.m_localAnchor1.x-e.m_sweep.localCenter.x,h=this.m_localAnchor1.y-e.m_sweep.localCenter.y,d=c.col1.x*g+c.col2.x*h,h=c.col1.y*g+c.col2.y*
h,g=d;c=f.m_xf.R;var k=this.m_localAnchor2.x-f.m_sweep.localCenter.x,m=this.m_localAnchor2.y-f.m_sweep.localCenter.y,d=c.col1.x*k+c.col2.x*m,m=c.col1.y*k+c.col2.y*m,k=d;this.m_u.x=f.m_sweep.c.x+k-e.m_sweep.c.x-g;this.m_u.y=f.m_sweep.c.y+m-e.m_sweep.c.y-h;d=Math.sqrt(this.m_u.x*this.m_u.x+this.m_u.y*this.m_u.y);d>a.b2_linearSlop?this.m_u.Multiply(1/d):this.m_u.SetZero();c=g*this.m_u.y-h*this.m_u.x;var n=k*this.m_u.y-m*this.m_u.x;c=e.m_invMass+e.m_invI*c*c+f.m_invMass+f.m_invI*n*n;if(this.m_mass=0!=
c?1/c:0,0<this.m_frequencyHz){var d=d-this.m_length,n=2*Math.PI*this.m_frequencyHz,p=this.m_mass*n*n;this.m_gamma=b.dt*(2*this.m_mass*this.m_dampingRatio*n+b.dt*p);this.m_gamma=0!=this.m_gamma?1/this.m_gamma:0;this.m_bias=d*b.dt*p*this.m_gamma;this.m_mass=c+this.m_gamma;this.m_mass=0!=this.m_mass?1/this.m_mass:0}b.warmStarting?(this.m_impulse*=b.dtRatio,b=this.m_impulse*this.m_u.x,c=this.m_impulse*this.m_u.y,e.m_linearVelocity.x-=e.m_invMass*b,e.m_linearVelocity.y-=e.m_invMass*c,e.m_angularVelocity-=
e.m_invI*(g*c-h*b),f.m_linearVelocity.x+=f.m_invMass*b,f.m_linearVelocity.y+=f.m_invMass*c,f.m_angularVelocity+=f.m_invI*(k*c-m*b)):this.m_impulse=0};g.prototype.SolveVelocityConstraints=function(a){var b;a=this.m_bodyA;var c=this.m_bodyB;b=a.m_xf.R;var d=this.m_localAnchor1.x-a.m_sweep.localCenter.x,e=this.m_localAnchor1.y-a.m_sweep.localCenter.y,f=b.col1.x*d+b.col2.x*e,e=b.col1.y*d+b.col2.y*e,d=f;b=c.m_xf.R;var g=this.m_localAnchor2.x-c.m_sweep.localCenter.x,h=this.m_localAnchor2.y-c.m_sweep.localCenter.y,
f=b.col1.x*g+b.col2.x*h,h=b.col1.y*g+b.col2.y*h,g=f,f=-this.m_mass*(this.m_u.x*(c.m_linearVelocity.x+-c.m_angularVelocity*h-(a.m_linearVelocity.x+-a.m_angularVelocity*e))+this.m_u.y*(c.m_linearVelocity.y+c.m_angularVelocity*g-(a.m_linearVelocity.y+a.m_angularVelocity*d))+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=f;b=f*this.m_u.x;f*=this.m_u.y;a.m_linearVelocity.x-=a.m_invMass*b;a.m_linearVelocity.y-=a.m_invMass*f;a.m_angularVelocity-=a.m_invI*(d*f-e*b);c.m_linearVelocity.x+=c.m_invMass*
b;c.m_linearVelocity.y+=c.m_invMass*f;c.m_angularVelocity+=c.m_invI*(g*f-h*b)};g.prototype.SolvePositionConstraints=function(b){var c;if(0<this.m_frequencyHz)return!0;b=this.m_bodyA;var e=this.m_bodyB;c=b.m_xf.R;var f=this.m_localAnchor1.x-b.m_sweep.localCenter.x,g=this.m_localAnchor1.y-b.m_sweep.localCenter.y,h=c.col1.x*f+c.col2.x*g,g=c.col1.y*f+c.col2.y*g,f=h;c=e.m_xf.R;var k=this.m_localAnchor2.x-e.m_sweep.localCenter.x,m=this.m_localAnchor2.y-e.m_sweep.localCenter.y,h=c.col1.x*k+c.col2.x*m,m=
c.col1.y*k+c.col2.y*m,k=h,h=e.m_sweep.c.x+k-b.m_sweep.c.x-f,n=e.m_sweep.c.y+m-b.m_sweep.c.y-g;c=Math.sqrt(h*h+n*n);h/=c;n/=c;c-=this.m_length;c=d.Clamp(c,-a.b2_maxLinearCorrection,a.b2_maxLinearCorrection);var p=-this.m_mass*c;this.m_u.Set(h,n);h=p*this.m_u.x;n=p*this.m_u.y;return b.m_sweep.c.x-=b.m_invMass*h,b.m_sweep.c.y-=b.m_invMass*n,b.m_sweep.a-=b.m_invI*(f*n-g*h),e.m_sweep.c.x+=e.m_invMass*h,e.m_sweep.c.y+=e.m_invMass*n,e.m_sweep.a+=e.m_invI*(k*n-m*h),b.SynchronizeTransform(),e.SynchronizeTransform(),
d.Abs(c)<a.b2_linearSlop};Box2D.inherit(h,Box2D.Dynamics.Joints.b2JointDef);h.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;h.b2DistanceJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA=new e;this.localAnchorB=new e};h.prototype.b2DistanceJointDef=function(){this.__super.b2JointDef.call(this);this.type=s.e_distanceJoint;this.length=1;this.dampingRatio=this.frequencyHz=0};h.prototype.Initialize=function(a,b,c,d){this.bodyA=a;this.bodyB=
b;this.localAnchorA.SetV(this.bodyA.GetLocalPoint(c));this.localAnchorB.SetV(this.bodyB.GetLocalPoint(d));a=d.x-c.x;c=d.y-c.y;this.length=Math.sqrt(a*a+c*c);this.dampingRatio=this.frequencyHz=0};Box2D.inherit(k,Box2D.Dynamics.Joints.b2Joint);k.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;k.b2FrictionJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_localAnchorA=new e;this.m_localAnchorB=new e;this.m_linearMass=new b;this.m_linearImpulse=new e};k.prototype.GetAnchorA=
function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)};k.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)};k.prototype.GetReactionForce=function(a){return void 0===a&&(a=0),new e(a*this.m_linearImpulse.x,a*this.m_linearImpulse.y)};k.prototype.GetReactionTorque=function(a){return void 0===a&&(a=0),a*this.m_angularImpulse};k.prototype.SetMaxForce=function(a){void 0===a&&(a=0);this.m_maxForce=a};k.prototype.GetMaxForce=function(){return this.m_maxForce};
k.prototype.SetMaxTorque=function(a){void 0===a&&(a=0);this.m_maxTorque=a};k.prototype.GetMaxTorque=function(){return this.m_maxTorque};k.prototype.b2FrictionJoint=function(a){this.__super.b2Joint.call(this,a);this.m_localAnchorA.SetV(a.localAnchorA);this.m_localAnchorB.SetV(a.localAnchorB);this.m_linearMass.SetZero();this.m_angularMass=0;this.m_linearImpulse.SetZero();this.m_angularImpulse=0;this.m_maxForce=a.maxForce;this.m_maxTorque=a.maxTorque};k.prototype.InitVelocityConstraints=function(a){var c,
d=0,e=this.m_bodyA,f=this.m_bodyB;c=e.m_xf.R;var g=this.m_localAnchorA.x-e.m_sweep.localCenter.x,h=this.m_localAnchorA.y-e.m_sweep.localCenter.y,d=c.col1.x*g+c.col2.x*h,h=c.col1.y*g+c.col2.y*h,g=d;c=f.m_xf.R;var k=this.m_localAnchorB.x-f.m_sweep.localCenter.x,m=this.m_localAnchorB.y-f.m_sweep.localCenter.y,d=c.col1.x*k+c.col2.x*m,m=c.col1.y*k+c.col2.y*m,k=d;c=e.m_invMass;var d=f.m_invMass,n=e.m_invI,p=f.m_invI,s=new b;(s.col1.x=c+d,s.col2.x=0,s.col1.y=0,s.col2.y=c+d,s.col1.x+=n*h*h,s.col2.x+=-n*g*
h,s.col1.y+=-n*g*h,s.col2.y+=n*g*g,s.col1.x+=p*m*m,s.col2.x+=-p*k*m,s.col1.y+=-p*k*m,s.col2.y+=p*k*k,s.GetInverse(this.m_linearMass),this.m_angularMass=n+p,0<this.m_angularMass&&(this.m_angularMass=1/this.m_angularMass),a.warmStarting)?(this.m_linearImpulse.x*=a.dtRatio,this.m_linearImpulse.y*=a.dtRatio,this.m_angularImpulse*=a.dtRatio,a=this.m_linearImpulse,e.m_linearVelocity.x-=c*a.x,e.m_linearVelocity.y-=c*a.y,e.m_angularVelocity-=n*(g*a.y-h*a.x+this.m_angularImpulse),f.m_linearVelocity.x+=d*a.x,
f.m_linearVelocity.y+=d*a.y,f.m_angularVelocity+=p*(k*a.y-m*a.x+this.m_angularImpulse)):(this.m_linearImpulse.SetZero(),this.m_angularImpulse=0)};k.prototype.SolveVelocityConstraints=function(a){var b,c=0,f=this.m_bodyA,g=this.m_bodyB,h=f.m_linearVelocity,k=f.m_angularVelocity,m=g.m_linearVelocity,n=g.m_angularVelocity,p=f.m_invMass,s=g.m_invMass,r=f.m_invI,t=g.m_invI;b=f.m_xf.R;var u=this.m_localAnchorA.x-f.m_sweep.localCenter.x,v=this.m_localAnchorA.y-f.m_sweep.localCenter.y,c=b.col1.x*u+b.col2.x*
v,v=b.col1.y*u+b.col2.y*v,u=c;b=g.m_xf.R;var w=this.m_localAnchorB.x-g.m_sweep.localCenter.x,x=this.m_localAnchorB.y-g.m_sweep.localCenter.y,c=b.col1.x*w+b.col2.x*x,x=b.col1.y*w+b.col2.y*x,w=c;b=0;var c=-this.m_angularMass*(n-k),z=this.m_angularImpulse;b=a.dt*this.m_maxTorque;this.m_angularImpulse=d.Clamp(this.m_angularImpulse+c,-b,b);c=this.m_angularImpulse-z;k-=r*c;n+=t*c;b=d.MulMV(this.m_linearMass,new e(-(m.x-n*x-h.x+k*v),-(m.y+n*w-h.y-k*u)));c=this.m_linearImpulse.Copy();this.m_linearImpulse.Add(b);
b=a.dt*this.m_maxForce;this.m_linearImpulse.LengthSquared()>b*b&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.Multiply(b));b=d.SubtractVV(this.m_linearImpulse,c);h.x-=p*b.x;h.y-=p*b.y;k-=r*(u*b.y-v*b.x);m.x+=s*b.x;m.y+=s*b.y;n+=t*(w*b.y-x*b.x);f.m_angularVelocity=k;g.m_angularVelocity=n};k.prototype.SolvePositionConstraints=function(a){return!0};Box2D.inherit(m,Box2D.Dynamics.Joints.b2JointDef);m.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;m.b2FrictionJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,
arguments);this.localAnchorA=new e;this.localAnchorB=new e};m.prototype.b2FrictionJointDef=function(){this.__super.b2JointDef.call(this);this.type=s.e_frictionJoint;this.maxTorque=this.maxForce=0};m.prototype.Initialize=function(a,b,c){this.bodyA=a;this.bodyB=b;this.localAnchorA.SetV(this.bodyA.GetLocalPoint(c));this.localAnchorB.SetV(this.bodyB.GetLocalPoint(c))};Box2D.inherit(n,Box2D.Dynamics.Joints.b2Joint);n.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;n.b2GearJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,
arguments);this.m_groundAnchor1=new e;this.m_groundAnchor2=new e;this.m_localAnchor1=new e;this.m_localAnchor2=new e;this.m_J=new r};n.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};n.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};n.prototype.GetReactionForce=function(a){return void 0===a&&(a=0),new e(a*this.m_impulse*this.m_J.linearB.x,a*this.m_impulse*this.m_J.linearB.y)};n.prototype.GetReactionTorque=function(a){void 0===
a&&(a=0);var b=this.m_bodyB.m_xf.R,c=this.m_localAnchor1.x-this.m_bodyB.m_sweep.localCenter.x,d=this.m_localAnchor1.y-this.m_bodyB.m_sweep.localCenter.y,e=b.col1.x*c+b.col2.x*d,d=b.col1.y*c+b.col2.y*d;return a*(this.m_impulse*this.m_J.angularB-e*this.m_impulse*this.m_J.linearB.y+d*this.m_impulse*this.m_J.linearB.x)};n.prototype.GetRatio=function(){return this.m_ratio};n.prototype.SetRatio=function(a){void 0===a&&(a=0);this.m_ratio=a};n.prototype.b2GearJoint=function(a){this.__super.b2Joint.call(this,
a);var b=parseInt(a.joint1.m_type),c=parseInt(a.joint2.m_type);this.m_prismatic2=this.m_revolute2=this.m_prismatic1=this.m_revolute1=null;var d=0,e=0;this.m_ground1=a.joint1.GetBodyA();this.m_bodyA=a.joint1.GetBodyB();b==s.e_revoluteJoint?(this.m_revolute1=a.joint1 instanceof I?a.joint1:null,this.m_groundAnchor1.SetV(this.m_revolute1.m_localAnchor1),this.m_localAnchor1.SetV(this.m_revolute1.m_localAnchor2),d=this.m_revolute1.GetJointAngle()):(this.m_prismatic1=a.joint1 instanceof z?a.joint1:null,
this.m_groundAnchor1.SetV(this.m_prismatic1.m_localAnchor1),this.m_localAnchor1.SetV(this.m_prismatic1.m_localAnchor2),d=this.m_prismatic1.GetJointTranslation());this.m_ground2=a.joint2.GetBodyA();this.m_bodyB=a.joint2.GetBodyB();c==s.e_revoluteJoint?(this.m_revolute2=a.joint2 instanceof I?a.joint2:null,this.m_groundAnchor2.SetV(this.m_revolute2.m_localAnchor1),this.m_localAnchor2.SetV(this.m_revolute2.m_localAnchor2),e=this.m_revolute2.GetJointAngle()):(this.m_prismatic2=a.joint2 instanceof z?a.joint2:
null,this.m_groundAnchor2.SetV(this.m_prismatic2.m_localAnchor1),this.m_localAnchor2.SetV(this.m_prismatic2.m_localAnchor2),e=this.m_prismatic2.GetJointTranslation());this.m_ratio=a.ratio;this.m_constant=d+this.m_ratio*e;this.m_impulse=0};n.prototype.InitVelocityConstraints=function(a){var b,c,d=this.m_ground1,e=this.m_ground2,f=this.m_bodyA,g=this.m_bodyB,h=0,k=0,m=0,n=0,p=0,s=0,r=0;this.m_J.SetZero();this.m_revolute1?(this.m_J.angularA=-1,r+=f.m_invI):(b=d.m_xf.R,c=this.m_prismatic1.m_localXAxis1,
h=b.col1.x*c.x+b.col2.x*c.y,k=b.col1.y*c.x+b.col2.y*c.y,b=f.m_xf.R,m=this.m_localAnchor1.x-f.m_sweep.localCenter.x,n=this.m_localAnchor1.y-f.m_sweep.localCenter.y,s=b.col1.x*m+b.col2.x*n,n=b.col1.y*m+b.col2.y*n,m=s,p=m*k-n*h,this.m_J.linearA.Set(-h,-k),this.m_J.angularA=-p,r+=f.m_invMass+f.m_invI*p*p);this.m_revolute2?(this.m_J.angularB=-this.m_ratio,r+=this.m_ratio*this.m_ratio*g.m_invI):(b=e.m_xf.R,c=this.m_prismatic2.m_localXAxis1,h=b.col1.x*c.x+b.col2.x*c.y,k=b.col1.y*c.x+b.col2.y*c.y,b=g.m_xf.R,
m=this.m_localAnchor2.x-g.m_sweep.localCenter.x,n=this.m_localAnchor2.y-g.m_sweep.localCenter.y,s=b.col1.x*m+b.col2.x*n,n=b.col1.y*m+b.col2.y*n,m=s,p=m*k-n*h,this.m_J.linearB.Set(-this.m_ratio*h,-this.m_ratio*k),this.m_J.angularB=-this.m_ratio*p,r+=this.m_ratio*this.m_ratio*(g.m_invMass+g.m_invI*p*p));this.m_mass=0<r?1/r:0;a.warmStarting?(f.m_linearVelocity.x+=f.m_invMass*this.m_impulse*this.m_J.linearA.x,f.m_linearVelocity.y+=f.m_invMass*this.m_impulse*this.m_J.linearA.y,f.m_angularVelocity+=f.m_invI*
this.m_impulse*this.m_J.angularA,g.m_linearVelocity.x+=g.m_invMass*this.m_impulse*this.m_J.linearB.x,g.m_linearVelocity.y+=g.m_invMass*this.m_impulse*this.m_J.linearB.y,g.m_angularVelocity+=g.m_invI*this.m_impulse*this.m_J.angularB):this.m_impulse=0};n.prototype.SolveVelocityConstraints=function(a){a=this.m_bodyA;var b=this.m_bodyB,c=this.m_J.Compute(a.m_linearVelocity,a.m_angularVelocity,b.m_linearVelocity,b.m_angularVelocity),c=-this.m_mass*c;this.m_impulse+=c;a.m_linearVelocity.x+=a.m_invMass*
c*this.m_J.linearA.x;a.m_linearVelocity.y+=a.m_invMass*c*this.m_J.linearA.y;a.m_angularVelocity+=a.m_invI*c*this.m_J.angularA;b.m_linearVelocity.x+=b.m_invMass*c*this.m_J.linearB.x;b.m_linearVelocity.y+=b.m_invMass*c*this.m_J.linearB.y;b.m_angularVelocity+=b.m_invI*c*this.m_J.angularB};n.prototype.SolvePositionConstraints=function(b){b=this.m_bodyA;var c=this.m_bodyB,d=0,e=0,d=this.m_revolute1?this.m_revolute1.GetJointAngle():this.m_prismatic1.GetJointTranslation(),e=this.m_revolute2?this.m_revolute2.GetJointAngle():
this.m_prismatic2.GetJointTranslation(),d=-this.m_mass*(this.m_constant-(d+this.m_ratio*e));return b.m_sweep.c.x+=b.m_invMass*d*this.m_J.linearA.x,b.m_sweep.c.y+=b.m_invMass*d*this.m_J.linearA.y,b.m_sweep.a+=b.m_invI*d*this.m_J.angularA,c.m_sweep.c.x+=c.m_invMass*d*this.m_J.linearB.x,c.m_sweep.c.y+=c.m_invMass*d*this.m_J.linearB.y,c.m_sweep.a+=c.m_invI*d*this.m_J.angularB,b.SynchronizeTransform(),c.SynchronizeTransform(),0<a.b2_linearSlop};Box2D.inherit(p,Box2D.Dynamics.Joints.b2JointDef);p.prototype.__super=
Box2D.Dynamics.Joints.b2JointDef.prototype;p.b2GearJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments)};p.prototype.b2GearJointDef=function(){this.__super.b2JointDef.call(this);this.type=s.e_gearJoint;this.joint2=this.joint1=null;this.ratio=1};r.b2Jacobian=function(){this.linearA=new e;this.linearB=new e};r.prototype.SetZero=function(){this.linearA.SetZero();this.angularA=0;this.linearB.SetZero();this.angularB=0};r.prototype.Set=function(a,b,c,d){void 0===b&&(b=0);
void 0===d&&(d=0);this.linearA.SetV(a);this.angularA=b;this.linearB.SetV(c);this.angularB=d};r.prototype.Compute=function(a,b,c,d){return void 0===b&&(b=0),void 0===d&&(d=0),this.linearA.x*a.x+this.linearA.y*a.y+this.angularA*b+(this.linearB.x*c.x+this.linearB.y*c.y)+this.angularB*d};s.b2Joint=function(){this.m_edgeA=new u;this.m_edgeB=new u;this.m_localCenterA=new e;this.m_localCenterB=new e};s.prototype.GetType=function(){return this.m_type};s.prototype.GetAnchorA=function(){return null};s.prototype.GetAnchorB=
function(){return null};s.prototype.GetReactionForce=function(a){return null};s.prototype.GetReactionTorque=function(a){return 0};s.prototype.GetBodyA=function(){return this.m_bodyA};s.prototype.GetBodyB=function(){return this.m_bodyB};s.prototype.GetNext=function(){return this.m_next};s.prototype.GetUserData=function(){return this.m_userData};s.prototype.SetUserData=function(a){this.m_userData=a};s.prototype.IsActive=function(){return this.m_bodyA.IsActive()&&this.m_bodyB.IsActive()};s.Create=function(a,
b){var c=null;switch(a.type){case s.e_distanceJoint:c=new g(a instanceof h?a:null);break;case s.e_mouseJoint:c=new A(a instanceof F?a:null);break;case s.e_prismaticJoint:c=new z(a instanceof w?a:null);break;case s.e_revoluteJoint:c=new I(a instanceof J?a:null);break;case s.e_pulleyJoint:c=new B(a instanceof E?a:null);break;case s.e_gearJoint:c=new n(a instanceof p?a:null);break;case s.e_lineJoint:c=new t(a instanceof x?a:null);break;case s.e_weldJoint:c=new O(a instanceof L?a:null);break;case s.e_frictionJoint:c=
new k(a instanceof m?a:null)}return c};s.Destroy=function(a,b){};s.prototype.b2Joint=function(b){a.b2Assert(b.bodyA!=b.bodyB);this.m_type=b.type;this.m_next=this.m_prev=null;this.m_bodyA=b.bodyA;this.m_bodyB=b.bodyB;this.m_collideConnected=b.collideConnected;this.m_islandFlag=!1;this.m_userData=b.userData};s.prototype.InitVelocityConstraints=function(a){};s.prototype.SolveVelocityConstraints=function(a){};s.prototype.FinalizeVelocityConstraints=function(){};s.prototype.SolvePositionConstraints=function(a){return!1};
Box2D.postDefs.push(function(){Box2D.Dynamics.Joints.b2Joint.e_unknownJoint=0;Box2D.Dynamics.Joints.b2Joint.e_revoluteJoint=1;Box2D.Dynamics.Joints.b2Joint.e_prismaticJoint=2;Box2D.Dynamics.Joints.b2Joint.e_distanceJoint=3;Box2D.Dynamics.Joints.b2Joint.e_pulleyJoint=4;Box2D.Dynamics.Joints.b2Joint.e_mouseJoint=5;Box2D.Dynamics.Joints.b2Joint.e_gearJoint=6;Box2D.Dynamics.Joints.b2Joint.e_lineJoint=7;Box2D.Dynamics.Joints.b2Joint.e_weldJoint=8;Box2D.Dynamics.Joints.b2Joint.e_frictionJoint=9;Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit=
0;Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit=1;Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit=2;Box2D.Dynamics.Joints.b2Joint.e_equalLimits=3});v.b2JointDef=function(){};v.prototype.b2JointDef=function(){this.type=s.e_unknownJoint;this.bodyB=this.bodyA=this.userData=null;this.collideConnected=!1};u.b2JointEdge=function(){};Box2D.inherit(t,Box2D.Dynamics.Joints.b2Joint);t.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;t.b2LineJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,
arguments);this.m_localAnchor1=new e;this.m_localAnchor2=new e;this.m_localXAxis1=new e;this.m_localYAxis1=new e;this.m_axis=new e;this.m_perp=new e;this.m_K=new b;this.m_impulse=new e};t.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};t.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};t.prototype.GetReactionForce=function(a){return void 0===a&&(a=0),new e(a*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.y)*
this.m_axis.x),a*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.y))};t.prototype.GetReactionTorque=function(a){return void 0===a&&(a=0),a*this.m_impulse.y};t.prototype.GetJointTranslation=function(){var a=this.m_bodyA,b=this.m_bodyB,c=a.GetWorldPoint(this.m_localAnchor1),d=b.GetWorldPoint(this.m_localAnchor2),b=d.x-c.x,c=d.y-c.y,a=a.GetWorldVector(this.m_localXAxis1);return a.x*b+a.y*c};t.prototype.GetJointSpeed=function(){var a,b=this.m_bodyA,c=this.m_bodyB;a=
b.m_xf.R;var d=this.m_localAnchor1.x-b.m_sweep.localCenter.x,e=this.m_localAnchor1.y-b.m_sweep.localCenter.y,f=a.col1.x*d+a.col2.x*e,e=a.col1.y*d+a.col2.y*e,d=f;a=c.m_xf.R;var g=this.m_localAnchor2.x-c.m_sweep.localCenter.x,h=this.m_localAnchor2.y-c.m_sweep.localCenter.y,f=a.col1.x*g+a.col2.x*h,h=a.col1.y*g+a.col2.y*h,g=f;a=c.m_sweep.c.x+g-(b.m_sweep.c.x+d);var f=c.m_sweep.c.y+h-(b.m_sweep.c.y+e),k=b.GetWorldVector(this.m_localXAxis1),m=b.m_linearVelocity,n=c.m_linearVelocity,b=b.m_angularVelocity,
c=c.m_angularVelocity;return a*-b*k.y+f*b*k.x+(k.x*(n.x+-c*h-m.x- -b*e)+k.y*(n.y+c*g-m.y-b*d))};t.prototype.IsLimitEnabled=function(){return this.m_enableLimit};t.prototype.EnableLimit=function(a){this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_enableLimit=a};t.prototype.GetLowerLimit=function(){return this.m_lowerTranslation};t.prototype.GetUpperLimit=function(){return this.m_upperTranslation};t.prototype.SetLimits=function(a,b){void 0===a&&(a=0);void 0===b&&(b=0);this.m_bodyA.SetAwake(!0);
this.m_bodyB.SetAwake(!0);this.m_lowerTranslation=a;this.m_upperTranslation=b};t.prototype.IsMotorEnabled=function(){return this.m_enableMotor};t.prototype.EnableMotor=function(a){this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_enableMotor=a};t.prototype.SetMotorSpeed=function(a){void 0===a&&(a=0);this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_motorSpeed=a};t.prototype.GetMotorSpeed=function(){return this.m_motorSpeed};t.prototype.SetMaxMotorForce=function(a){void 0===a&&(a=
0);this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_maxMotorForce=a};t.prototype.GetMaxMotorForce=function(){return this.m_maxMotorForce};t.prototype.GetMotorForce=function(){return this.m_motorImpulse};t.prototype.b2LineJoint=function(a){this.__super.b2Joint.call(this,a);this.m_localAnchor1.SetV(a.localAnchorA);this.m_localAnchor2.SetV(a.localAnchorB);this.m_localXAxis1.SetV(a.localAxisA);this.m_localYAxis1.x=-this.m_localXAxis1.y;this.m_localYAxis1.y=this.m_localXAxis1.x;this.m_impulse.SetZero();
this.m_motorImpulse=this.m_motorMass=0;this.m_lowerTranslation=a.lowerTranslation;this.m_upperTranslation=a.upperTranslation;this.m_maxMotorForce=a.maxMotorForce;this.m_motorSpeed=a.motorSpeed;this.m_enableLimit=a.enableLimit;this.m_enableMotor=a.enableMotor;this.m_limitState=s.e_inactiveLimit;this.m_axis.SetZero();this.m_perp.SetZero()};t.prototype.InitVelocityConstraints=function(b){var c,e=this.m_bodyA,f=this.m_bodyB,g=0;this.m_localCenterA.SetV(e.GetLocalCenter());this.m_localCenterB.SetV(f.GetLocalCenter());
var h=e.GetTransform();f.GetTransform();c=e.m_xf.R;var k=this.m_localAnchor1.x-this.m_localCenterA.x,m=this.m_localAnchor1.y-this.m_localCenterA.y,g=c.col1.x*k+c.col2.x*m,m=c.col1.y*k+c.col2.y*m,k=g;c=f.m_xf.R;var n=this.m_localAnchor2.x-this.m_localCenterB.x,p=this.m_localAnchor2.y-this.m_localCenterB.y,g=c.col1.x*n+c.col2.x*p,p=c.col1.y*n+c.col2.y*p,n=g;c=f.m_sweep.c.x+n-e.m_sweep.c.x-k;g=f.m_sweep.c.y+p-e.m_sweep.c.y-m;this.m_invMassA=e.m_invMass;this.m_invMassB=f.m_invMass;this.m_invIA=e.m_invI;
this.m_invIB=f.m_invI;this.m_axis.SetV(d.MulMV(h.R,this.m_localXAxis1));this.m_a1=(c+k)*this.m_axis.y-(g+m)*this.m_axis.x;this.m_a2=n*this.m_axis.y-p*this.m_axis.x;this.m_motorMass=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_a1*this.m_a1+this.m_invIB*this.m_a2*this.m_a2;this.m_motorMass=this.m_motorMass>Number.MIN_VALUE?1/this.m_motorMass:0;this.m_perp.SetV(d.MulMV(h.R,this.m_localYAxis1));this.m_s1=(c+k)*this.m_perp.y-(g+m)*this.m_perp.x;this.m_s2=n*this.m_perp.y-p*this.m_perp.x;h=this.m_invMassA;
k=this.m_invMassB;m=this.m_invIA;n=this.m_invIB;(this.m_K.col1.x=h+k+m*this.m_s1*this.m_s1+n*this.m_s2*this.m_s2,this.m_K.col1.y=m*this.m_s1*this.m_a1+n*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=h+k+m*this.m_a1*this.m_a1+n*this.m_a2*this.m_a2,this.m_enableLimit)?(c=this.m_axis.x*c+this.m_axis.y*g,d.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*a.b2_linearSlop?this.m_limitState=s.e_equalLimits:c<=this.m_lowerTranslation?this.m_limitState!=s.e_atLowerLimit&&(this.m_limitState=
s.e_atLowerLimit,this.m_impulse.y=0):c>=this.m_upperTranslation?this.m_limitState!=s.e_atUpperLimit&&(this.m_limitState=s.e_atUpperLimit,this.m_impulse.y=0):(this.m_limitState=s.e_inactiveLimit,this.m_impulse.y=0)):this.m_limitState=s.e_inactiveLimit;(0==this.m_enableMotor&&(this.m_motorImpulse=0),b.warmStarting)?(this.m_impulse.x*=b.dtRatio,this.m_impulse.y*=b.dtRatio,this.m_motorImpulse*=b.dtRatio,b=this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.x,c=this.m_impulse.x*
this.m_perp.y+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.y,g=this.m_impulse.x*this.m_s1+(this.m_motorImpulse+this.m_impulse.y)*this.m_a1,h=this.m_impulse.x*this.m_s2+(this.m_motorImpulse+this.m_impulse.y)*this.m_a2,e.m_linearVelocity.x-=this.m_invMassA*b,e.m_linearVelocity.y-=this.m_invMassA*c,e.m_angularVelocity-=this.m_invIA*g,f.m_linearVelocity.x+=this.m_invMassB*b,f.m_linearVelocity.y+=this.m_invMassB*c,f.m_angularVelocity+=this.m_invIB*h):(this.m_impulse.SetZero(),this.m_motorImpulse=
0)};t.prototype.SolveVelocityConstraints=function(a){var b=this.m_bodyA,c=this.m_bodyB,f=b.m_linearVelocity,g=b.m_angularVelocity,h=c.m_linearVelocity,k=c.m_angularVelocity,m=0,n=0,p=0,r=0;this.m_enableMotor&&this.m_limitState!=s.e_equalLimits&&(r=this.m_motorMass*(this.m_motorSpeed-(this.m_axis.x*(h.x-f.x)+this.m_axis.y*(h.y-f.y)+this.m_a2*k-this.m_a1*g)),m=this.m_motorImpulse,n=a.dt*this.m_maxMotorForce,this.m_motorImpulse=d.Clamp(this.m_motorImpulse+r,-n,n),r=this.m_motorImpulse-m,m=r*this.m_axis.x,
n=r*this.m_axis.y,p=r*this.m_a1,r*=this.m_a2,f.x-=this.m_invMassA*m,f.y-=this.m_invMassA*n,g-=this.m_invIA*p,h.x+=this.m_invMassB*m,h.y+=this.m_invMassB*n,k+=this.m_invIB*r);n=this.m_perp.x*(h.x-f.x)+this.m_perp.y*(h.y-f.y)+this.m_s2*k-this.m_s1*g;this.m_enableLimit&&this.m_limitState!=s.e_inactiveLimit?(p=this.m_axis.x*(h.x-f.x)+this.m_axis.y*(h.y-f.y)+this.m_a2*k-this.m_a1*g,m=this.m_impulse.Copy(),a=this.m_K.Solve(new e,-n,-p),this.m_impulse.Add(a),this.m_limitState==s.e_atLowerLimit?this.m_impulse.y=
d.Max(this.m_impulse.y,0):this.m_limitState==s.e_atUpperLimit&&(this.m_impulse.y=d.Min(this.m_impulse.y,0)),n=-n-(this.m_impulse.y-m.y)*this.m_K.col2.x,p=0,p=0!=this.m_K.col1.x?n/this.m_K.col1.x+m.x:m.x,this.m_impulse.x=p,a.x=this.m_impulse.x-m.x,a.y=this.m_impulse.y-m.y,m=a.x*this.m_perp.x+a.y*this.m_axis.x,n=a.x*this.m_perp.y+a.y*this.m_axis.y,p=a.x*this.m_s1+a.y*this.m_a1,r=a.x*this.m_s2+a.y*this.m_a2):(a=0,a=0!=this.m_K.col1.x?-n/this.m_K.col1.x:0,this.m_impulse.x+=a,m=a*this.m_perp.x,n=a*this.m_perp.y,
p=a*this.m_s1,r=a*this.m_s2);f.x-=this.m_invMassA*m;f.y-=this.m_invMassA*n;g-=this.m_invIA*p;h.x+=this.m_invMassB*m;h.y+=this.m_invMassB*n;k+=this.m_invIB*r;b.m_linearVelocity.SetV(f);b.m_angularVelocity=g;c.m_linearVelocity.SetV(h);c.m_angularVelocity=k};t.prototype.SolvePositionConstraints=function(c){var f;c=this.m_bodyA;var g=this.m_bodyB,h=c.m_sweep.c,k=c.m_sweep.a,m=g.m_sweep.c,n=g.m_sweep.a,p=0,s=0,r=0,t=0,u=f=0,v=0,s=!1,w=0,x=b.FromAngle(k),r=b.FromAngle(n);f=x;var v=this.m_localAnchor1.x-
this.m_localCenterA.x,z=this.m_localAnchor1.y-this.m_localCenterA.y,p=f.col1.x*v+f.col2.x*z,z=f.col1.y*v+f.col2.y*z,v=p;f=r;r=this.m_localAnchor2.x-this.m_localCenterB.x;t=this.m_localAnchor2.y-this.m_localCenterB.y;p=f.col1.x*r+f.col2.x*t;t=f.col1.y*r+f.col2.y*t;r=p;f=m.x+r-h.x-v;p=m.y+t-h.y-z;if(this.m_enableLimit){this.m_axis=d.MulMV(x,this.m_localXAxis1);this.m_a1=(f+v)*this.m_axis.y-(p+z)*this.m_axis.x;this.m_a2=r*this.m_axis.y-t*this.m_axis.x;var A=this.m_axis.x*f+this.m_axis.y*p;d.Abs(this.m_upperTranslation-
this.m_lowerTranslation)<2*a.b2_linearSlop?(w=d.Clamp(A,-a.b2_maxLinearCorrection,a.b2_maxLinearCorrection),u=d.Abs(A),s=!0):A<=this.m_lowerTranslation?(w=d.Clamp(A-this.m_lowerTranslation+a.b2_linearSlop,-a.b2_maxLinearCorrection,0),u=this.m_lowerTranslation-A,s=!0):A>=this.m_upperTranslation&&(w=d.Clamp(A-this.m_upperTranslation+a.b2_linearSlop,0,a.b2_maxLinearCorrection),u=A-this.m_upperTranslation,s=!0)}this.m_perp=d.MulMV(x,this.m_localYAxis1);this.m_s1=(f+v)*this.m_perp.y-(p+z)*this.m_perp.x;
this.m_s2=r*this.m_perp.y-t*this.m_perp.x;x=new e;z=this.m_perp.x*f+this.m_perp.y*p;(u=d.Max(u,d.Abs(z)),v=0,s)?(s=this.m_invMassA,r=this.m_invMassB,t=this.m_invIA,f=this.m_invIB,this.m_K.col1.x=s+r+t*this.m_s1*this.m_s1+f*this.m_s2*this.m_s2,this.m_K.col1.y=t*this.m_s1*this.m_a1+f*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=s+r+t*this.m_a1*this.m_a1+f*this.m_a2*this.m_a2,this.m_K.Solve(x,-z,-w)):(s=this.m_invMassA,r=this.m_invMassB,t=this.m_invIA,f=this.m_invIB,w=s+r+t*this.m_s1*
this.m_s1+f*this.m_s2*this.m_s2,x.x=0!=w?-z/w:0,x.y=0);w=x.x*this.m_perp.x+x.y*this.m_axis.x;s=x.x*this.m_perp.y+x.y*this.m_axis.y;z=x.x*this.m_s1+x.y*this.m_a1;x=x.x*this.m_s2+x.y*this.m_a2;return h.x-=this.m_invMassA*w,h.y-=this.m_invMassA*s,k-=this.m_invIA*z,m.x+=this.m_invMassB*w,m.y+=this.m_invMassB*s,n+=this.m_invIB*x,c.m_sweep.a=k,g.m_sweep.a=n,c.SynchronizeTransform(),g.SynchronizeTransform(),u<=a.b2_linearSlop&&v<=a.b2_angularSlop};Box2D.inherit(x,Box2D.Dynamics.Joints.b2JointDef);x.prototype.__super=
Box2D.Dynamics.Joints.b2JointDef.prototype;x.b2LineJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA=new e;this.localAnchorB=new e;this.localAxisA=new e};x.prototype.b2LineJointDef=function(){this.__super.b2JointDef.call(this);this.type=s.e_lineJoint;this.localAxisA.Set(1,0);this.enableLimit=!1;this.upperTranslation=this.lowerTranslation=0;this.enableMotor=!1;this.motorSpeed=this.maxMotorForce=0};x.prototype.Initialize=function(a,b,c,d){this.bodyA=
a;this.bodyB=b;this.localAnchorA=this.bodyA.GetLocalPoint(c);this.localAnchorB=this.bodyB.GetLocalPoint(c);this.localAxisA=this.bodyA.GetLocalVector(d)};Box2D.inherit(A,Box2D.Dynamics.Joints.b2Joint);A.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;A.b2MouseJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.K=new b;this.K1=new b;this.K2=new b;this.m_localAnchor=new e;this.m_target=new e;this.m_impulse=new e;this.m_mass=new b;this.m_C=new e};A.prototype.GetAnchorA=
function(){return this.m_target};A.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor)};A.prototype.GetReactionForce=function(a){return void 0===a&&(a=0),new e(a*this.m_impulse.x,a*this.m_impulse.y)};A.prototype.GetReactionTorque=function(a){return 0};A.prototype.GetTarget=function(){return this.m_target};A.prototype.SetTarget=function(a){0==this.m_bodyB.IsAwake()&&this.m_bodyB.SetAwake(!0);this.m_target=a};A.prototype.GetMaxForce=function(){return this.m_maxForce};
A.prototype.SetMaxForce=function(a){void 0===a&&(a=0);this.m_maxForce=a};A.prototype.GetFrequency=function(){return this.m_frequencyHz};A.prototype.SetFrequency=function(a){void 0===a&&(a=0);this.m_frequencyHz=a};A.prototype.GetDampingRatio=function(){return this.m_dampingRatio};A.prototype.SetDampingRatio=function(a){void 0===a&&(a=0);this.m_dampingRatio=a};A.prototype.b2MouseJoint=function(a){this.__super.b2Joint.call(this,a);this.m_target.SetV(a.target);var b=this.m_target.x-this.m_bodyB.m_xf.position.x,
c=this.m_target.y-this.m_bodyB.m_xf.position.y,d=this.m_bodyB.m_xf.R;this.m_localAnchor.x=b*d.col1.x+c*d.col1.y;this.m_localAnchor.y=b*d.col2.x+c*d.col2.y;this.m_maxForce=a.maxForce;this.m_impulse.SetZero();this.m_frequencyHz=a.frequencyHz;this.m_dampingRatio=a.dampingRatio;this.m_gamma=this.m_beta=0};A.prototype.InitVelocityConstraints=function(a){var b=this.m_bodyB,c=b.GetMass(),d=2*Math.PI*this.m_frequencyHz,e=c*d*d;this.m_gamma=a.dt*(2*c*this.m_dampingRatio*d+a.dt*e);this.m_gamma=0!=this.m_gamma?
1/this.m_gamma:0;this.m_beta=a.dt*e*this.m_gamma;var e=b.m_xf.R,c=this.m_localAnchor.x-b.m_sweep.localCenter.x,d=this.m_localAnchor.y-b.m_sweep.localCenter.y,f=e.col1.x*c+e.col2.x*d,d=e.col1.y*c+e.col2.y*d,c=f,e=b.m_invMass,f=b.m_invI;this.K1.col1.x=e;this.K1.col2.x=0;this.K1.col1.y=0;this.K1.col2.y=e;this.K2.col1.x=f*d*d;this.K2.col2.x=-f*c*d;this.K2.col1.y=-f*c*d;this.K2.col2.y=f*c*c;this.K.SetM(this.K1);this.K.AddM(this.K2);this.K.col1.x+=this.m_gamma;this.K.col2.y+=this.m_gamma;this.K.GetInverse(this.m_mass);
this.m_C.x=b.m_sweep.c.x+c-this.m_target.x;this.m_C.y=b.m_sweep.c.y+d-this.m_target.y;b.m_angularVelocity*=0.98;this.m_impulse.x*=a.dtRatio;this.m_impulse.y*=a.dtRatio;b.m_linearVelocity.x+=e*this.m_impulse.x;b.m_linearVelocity.y+=e*this.m_impulse.y;b.m_angularVelocity+=f*(c*this.m_impulse.y-d*this.m_impulse.x)};A.prototype.SolveVelocityConstraints=function(a){var b,c=this.m_bodyB,d=0,e=0;b=c.m_xf.R;var f=this.m_localAnchor.x-c.m_sweep.localCenter.x,g=this.m_localAnchor.y-c.m_sweep.localCenter.y,
d=b.col1.x*f+b.col2.x*g,g=b.col1.y*f+b.col2.y*g,f=d,d=c.m_linearVelocity.x+-c.m_angularVelocity*g,h=c.m_linearVelocity.y+c.m_angularVelocity*f;b=this.m_mass;d=d+this.m_beta*this.m_C.x+this.m_gamma*this.m_impulse.x;e=h+this.m_beta*this.m_C.y+this.m_gamma*this.m_impulse.y;h=-(b.col1.x*d+b.col2.x*e);e=-(b.col1.y*d+b.col2.y*e);b=this.m_impulse.x;d=this.m_impulse.y;this.m_impulse.x+=h;this.m_impulse.y+=e;a=a.dt*this.m_maxForce;this.m_impulse.LengthSquared()>a*a&&this.m_impulse.Multiply(a/this.m_impulse.Length());
h=this.m_impulse.x-b;e=this.m_impulse.y-d;c.m_linearVelocity.x+=c.m_invMass*h;c.m_linearVelocity.y+=c.m_invMass*e;c.m_angularVelocity+=c.m_invI*(f*e-g*h)};A.prototype.SolvePositionConstraints=function(a){return!0};Box2D.inherit(F,Box2D.Dynamics.Joints.b2JointDef);F.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;F.b2MouseJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.target=new e};F.prototype.b2MouseJointDef=function(){this.__super.b2JointDef.call(this);
this.type=s.e_mouseJoint;this.maxForce=0;this.frequencyHz=5;this.dampingRatio=0.7};Box2D.inherit(z,Box2D.Dynamics.Joints.b2Joint);z.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;z.b2PrismaticJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_localAnchor1=new e;this.m_localAnchor2=new e;this.m_localXAxis1=new e;this.m_localYAxis1=new e;this.m_axis=new e;this.m_perp=new e;this.m_K=new c;this.m_impulse=new f};z.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};
z.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};z.prototype.GetReactionForce=function(a){return void 0===a&&(a=0),new e(a*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x),a*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y))};z.prototype.GetReactionTorque=function(a){return void 0===a&&(a=0),a*this.m_impulse.y};z.prototype.GetJointTranslation=function(){var a=this.m_bodyA,b=this.m_bodyB,
c=a.GetWorldPoint(this.m_localAnchor1),d=b.GetWorldPoint(this.m_localAnchor2),b=d.x-c.x,c=d.y-c.y,a=a.GetWorldVector(this.m_localXAxis1);return a.x*b+a.y*c};z.prototype.GetJointSpeed=function(){var a,b=this.m_bodyA,c=this.m_bodyB;a=b.m_xf.R;var d=this.m_localAnchor1.x-b.m_sweep.localCenter.x,e=this.m_localAnchor1.y-b.m_sweep.localCenter.y,f=a.col1.x*d+a.col2.x*e,e=a.col1.y*d+a.col2.y*e,d=f;a=c.m_xf.R;var g=this.m_localAnchor2.x-c.m_sweep.localCenter.x,h=this.m_localAnchor2.y-c.m_sweep.localCenter.y,
f=a.col1.x*g+a.col2.x*h,h=a.col1.y*g+a.col2.y*h,g=f;a=c.m_sweep.c.x+g-(b.m_sweep.c.x+d);var f=c.m_sweep.c.y+h-(b.m_sweep.c.y+e),k=b.GetWorldVector(this.m_localXAxis1),m=b.m_linearVelocity,n=c.m_linearVelocity,b=b.m_angularVelocity,c=c.m_angularVelocity;return a*-b*k.y+f*b*k.x+(k.x*(n.x+-c*h-m.x- -b*e)+k.y*(n.y+c*g-m.y-b*d))};z.prototype.IsLimitEnabled=function(){return this.m_enableLimit};z.prototype.EnableLimit=function(a){this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_enableLimit=a};
z.prototype.GetLowerLimit=function(){return this.m_lowerTranslation};z.prototype.GetUpperLimit=function(){return this.m_upperTranslation};z.prototype.SetLimits=function(a,b){void 0===a&&(a=0);void 0===b&&(b=0);this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_lowerTranslation=a;this.m_upperTranslation=b};z.prototype.IsMotorEnabled=function(){return this.m_enableMotor};z.prototype.EnableMotor=function(a){this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_enableMotor=a};z.prototype.SetMotorSpeed=
function(a){void 0===a&&(a=0);this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_motorSpeed=a};z.prototype.GetMotorSpeed=function(){return this.m_motorSpeed};z.prototype.SetMaxMotorForce=function(a){void 0===a&&(a=0);this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_maxMotorForce=a};z.prototype.GetMotorForce=function(){return this.m_motorImpulse};z.prototype.b2PrismaticJoint=function(a){this.__super.b2Joint.call(this,a);this.m_localAnchor1.SetV(a.localAnchorA);this.m_localAnchor2.SetV(a.localAnchorB);
this.m_localXAxis1.SetV(a.localAxisA);this.m_localYAxis1.x=-this.m_localXAxis1.y;this.m_localYAxis1.y=this.m_localXAxis1.x;this.m_refAngle=a.referenceAngle;this.m_impulse.SetZero();this.m_motorImpulse=this.m_motorMass=0;this.m_lowerTranslation=a.lowerTranslation;this.m_upperTranslation=a.upperTranslation;this.m_maxMotorForce=a.maxMotorForce;this.m_motorSpeed=a.motorSpeed;this.m_enableLimit=a.enableLimit;this.m_enableMotor=a.enableMotor;this.m_limitState=s.e_inactiveLimit;this.m_axis.SetZero();this.m_perp.SetZero()};
z.prototype.InitVelocityConstraints=function(b){var c,e=this.m_bodyA,f=this.m_bodyB,g=0;this.m_localCenterA.SetV(e.GetLocalCenter());this.m_localCenterB.SetV(f.GetLocalCenter());var h=e.GetTransform();f.GetTransform();c=e.m_xf.R;var k=this.m_localAnchor1.x-this.m_localCenterA.x,m=this.m_localAnchor1.y-this.m_localCenterA.y,g=c.col1.x*k+c.col2.x*m,m=c.col1.y*k+c.col2.y*m,k=g;c=f.m_xf.R;var n=this.m_localAnchor2.x-this.m_localCenterB.x,p=this.m_localAnchor2.y-this.m_localCenterB.y,g=c.col1.x*n+c.col2.x*
p,p=c.col1.y*n+c.col2.y*p,n=g;c=f.m_sweep.c.x+n-e.m_sweep.c.x-k;g=f.m_sweep.c.y+p-e.m_sweep.c.y-m;this.m_invMassA=e.m_invMass;this.m_invMassB=f.m_invMass;this.m_invIA=e.m_invI;this.m_invIB=f.m_invI;this.m_axis.SetV(d.MulMV(h.R,this.m_localXAxis1));this.m_a1=(c+k)*this.m_axis.y-(g+m)*this.m_axis.x;this.m_a2=n*this.m_axis.y-p*this.m_axis.x;this.m_motorMass=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_a1*this.m_a1+this.m_invIB*this.m_a2*this.m_a2;this.m_motorMass>Number.MIN_VALUE&&(this.m_motorMass=
1/this.m_motorMass);this.m_perp.SetV(d.MulMV(h.R,this.m_localYAxis1));this.m_s1=(c+k)*this.m_perp.y-(g+m)*this.m_perp.x;this.m_s2=n*this.m_perp.y-p*this.m_perp.x;h=this.m_invMassA;k=this.m_invMassB;m=this.m_invIA;n=this.m_invIB;(this.m_K.col1.x=h+k+m*this.m_s1*this.m_s1+n*this.m_s2*this.m_s2,this.m_K.col1.y=m*this.m_s1+n*this.m_s2,this.m_K.col1.z=m*this.m_s1*this.m_a1+n*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=m+n,this.m_K.col2.z=m*this.m_a1+n*this.m_a2,this.m_K.col3.x=
this.m_K.col1.z,this.m_K.col3.y=this.m_K.col2.z,this.m_K.col3.z=h+k+m*this.m_a1*this.m_a1+n*this.m_a2*this.m_a2,this.m_enableLimit)?(c=this.m_axis.x*c+this.m_axis.y*g,d.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*a.b2_linearSlop?this.m_limitState=s.e_equalLimits:c<=this.m_lowerTranslation?this.m_limitState!=s.e_atLowerLimit&&(this.m_limitState=s.e_atLowerLimit,this.m_impulse.z=0):c>=this.m_upperTranslation?this.m_limitState!=s.e_atUpperLimit&&(this.m_limitState=s.e_atUpperLimit,this.m_impulse.z=
0):(this.m_limitState=s.e_inactiveLimit,this.m_impulse.z=0)):this.m_limitState=s.e_inactiveLimit;(0==this.m_enableMotor&&(this.m_motorImpulse=0),b.warmStarting)?(this.m_impulse.x*=b.dtRatio,this.m_impulse.y*=b.dtRatio,this.m_motorImpulse*=b.dtRatio,b=this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x,c=this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y,g=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*
this.m_a1,h=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2,e.m_linearVelocity.x-=this.m_invMassA*b,e.m_linearVelocity.y-=this.m_invMassA*c,e.m_angularVelocity-=this.m_invIA*g,f.m_linearVelocity.x+=this.m_invMassB*b,f.m_linearVelocity.y+=this.m_invMassB*c,f.m_angularVelocity+=this.m_invIB*h):(this.m_impulse.SetZero(),this.m_motorImpulse=0)};z.prototype.SolveVelocityConstraints=function(a){var b=this.m_bodyA,c=this.m_bodyB,g=b.m_linearVelocity,h=b.m_angularVelocity,
k=c.m_linearVelocity,m=c.m_angularVelocity,n=0,p=0,r=0,t=0;this.m_enableMotor&&this.m_limitState!=s.e_equalLimits&&(t=this.m_motorMass*(this.m_motorSpeed-(this.m_axis.x*(k.x-g.x)+this.m_axis.y*(k.y-g.y)+this.m_a2*m-this.m_a1*h)),n=this.m_motorImpulse,a=a.dt*this.m_maxMotorForce,this.m_motorImpulse=d.Clamp(this.m_motorImpulse+t,-a,a),t=this.m_motorImpulse-n,n=t*this.m_axis.x,p=t*this.m_axis.y,r=t*this.m_a1,t*=this.m_a2,g.x-=this.m_invMassA*n,g.y-=this.m_invMassA*p,h-=this.m_invIA*r,k.x+=this.m_invMassB*
n,k.y+=this.m_invMassB*p,m+=this.m_invIB*t);r=this.m_perp.x*(k.x-g.x)+this.m_perp.y*(k.y-g.y)+this.m_s2*m-this.m_s1*h;p=m-h;this.m_enableLimit&&this.m_limitState!=s.e_inactiveLimit?(a=this.m_axis.x*(k.x-g.x)+this.m_axis.y*(k.y-g.y)+this.m_a2*m-this.m_a1*h,n=this.m_impulse.Copy(),a=this.m_K.Solve33(new f,-r,-p,-a),this.m_impulse.Add(a),this.m_limitState==s.e_atLowerLimit?this.m_impulse.z=d.Max(this.m_impulse.z,0):this.m_limitState==s.e_atUpperLimit&&(this.m_impulse.z=d.Min(this.m_impulse.z,0)),r=-r-
(this.m_impulse.z-n.z)*this.m_K.col3.x,p=-p-(this.m_impulse.z-n.z)*this.m_K.col3.y,p=this.m_K.Solve22(new e,r,p),p.x+=n.x,p.y+=n.y,this.m_impulse.x=p.x,this.m_impulse.y=p.y,a.x=this.m_impulse.x-n.x,a.y=this.m_impulse.y-n.y,a.z=this.m_impulse.z-n.z,n=a.x*this.m_perp.x+a.z*this.m_axis.x,p=a.x*this.m_perp.y+a.z*this.m_axis.y,r=a.x*this.m_s1+a.y+a.z*this.m_a1,t=a.x*this.m_s2+a.y+a.z*this.m_a2):(a=this.m_K.Solve22(new e,-r,-p),this.m_impulse.x+=a.x,this.m_impulse.y+=a.y,n=a.x*this.m_perp.x,p=a.x*this.m_perp.y,
r=a.x*this.m_s1+a.y,t=a.x*this.m_s2+a.y);g.x-=this.m_invMassA*n;g.y-=this.m_invMassA*p;h-=this.m_invIA*r;k.x+=this.m_invMassB*n;k.y+=this.m_invMassB*p;m+=this.m_invIB*t;b.m_linearVelocity.SetV(g);b.m_angularVelocity=h;c.m_linearVelocity.SetV(k);c.m_angularVelocity=m};z.prototype.SolvePositionConstraints=function(c){var g;c=this.m_bodyA;var h=this.m_bodyB,k=c.m_sweep.c,m=c.m_sweep.a,n=h.m_sweep.c,p=h.m_sweep.a,s=0,r=0,t=0,u=s=g=0,v=0,r=!1,w=0,x=b.FromAngle(m),z=b.FromAngle(p);g=x;var v=this.m_localAnchor1.x-
this.m_localCenterA.x,A=this.m_localAnchor1.y-this.m_localCenterA.y,s=g.col1.x*v+g.col2.x*A,A=g.col1.y*v+g.col2.y*A,v=s;g=z;z=this.m_localAnchor2.x-this.m_localCenterB.x;t=this.m_localAnchor2.y-this.m_localCenterB.y;s=g.col1.x*z+g.col2.x*t;t=g.col1.y*z+g.col2.y*t;z=s;g=n.x+z-k.x-v;s=n.y+t-k.y-A;if(this.m_enableLimit){this.m_axis=d.MulMV(x,this.m_localXAxis1);this.m_a1=(g+v)*this.m_axis.y-(s+A)*this.m_axis.x;this.m_a2=z*this.m_axis.y-t*this.m_axis.x;var B=this.m_axis.x*g+this.m_axis.y*s;d.Abs(this.m_upperTranslation-
this.m_lowerTranslation)<2*a.b2_linearSlop?(w=d.Clamp(B,-a.b2_maxLinearCorrection,a.b2_maxLinearCorrection),u=d.Abs(B),r=!0):B<=this.m_lowerTranslation?(w=d.Clamp(B-this.m_lowerTranslation+a.b2_linearSlop,-a.b2_maxLinearCorrection,0),u=this.m_lowerTranslation-B,r=!0):B>=this.m_upperTranslation&&(w=d.Clamp(B-this.m_upperTranslation+a.b2_linearSlop,0,a.b2_maxLinearCorrection),u=B-this.m_upperTranslation,r=!0)}this.m_perp=d.MulMV(x,this.m_localYAxis1);this.m_s1=(g+v)*this.m_perp.y-(s+A)*this.m_perp.x;
this.m_s2=z*this.m_perp.y-t*this.m_perp.x;x=new f;A=this.m_perp.x*g+this.m_perp.y*s;z=p-m-this.m_refAngle;(u=d.Max(u,d.Abs(A)),v=d.Abs(z),r)?(r=this.m_invMassA,t=this.m_invMassB,g=this.m_invIA,s=this.m_invIB,this.m_K.col1.x=r+t+g*this.m_s1*this.m_s1+s*this.m_s2*this.m_s2,this.m_K.col1.y=g*this.m_s1+s*this.m_s2,this.m_K.col1.z=g*this.m_s1*this.m_a1+s*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=g+s,this.m_K.col2.z=g*this.m_a1+s*this.m_a2,this.m_K.col3.x=this.m_K.col1.z,this.m_K.col3.y=
this.m_K.col2.z,this.m_K.col3.z=r+t+g*this.m_a1*this.m_a1+s*this.m_a2*this.m_a2,this.m_K.Solve33(x,-A,-z,-w)):(r=this.m_invMassA,t=this.m_invMassB,g=this.m_invIA,s=this.m_invIB,w=g*this.m_s1+s*this.m_s2,B=g+s,this.m_K.col1.Set(r+t+g*this.m_s1*this.m_s1+s*this.m_s2*this.m_s2,w,0),this.m_K.col2.Set(w,B,0),w=this.m_K.Solve22(new e,-A,-z),x.x=w.x,x.y=w.y,x.z=0);w=x.x*this.m_perp.x+x.z*this.m_axis.x;r=x.x*this.m_perp.y+x.z*this.m_axis.y;A=x.x*this.m_s1+x.y+x.z*this.m_a1;x=x.x*this.m_s2+x.y+x.z*this.m_a2;
return k.x-=this.m_invMassA*w,k.y-=this.m_invMassA*r,m-=this.m_invIA*A,n.x+=this.m_invMassB*w,n.y+=this.m_invMassB*r,p+=this.m_invIB*x,c.m_sweep.a=m,h.m_sweep.a=p,c.SynchronizeTransform(),h.SynchronizeTransform(),u<=a.b2_linearSlop&&v<=a.b2_angularSlop};Box2D.inherit(w,Box2D.Dynamics.Joints.b2JointDef);w.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;w.b2PrismaticJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA=new e;this.localAnchorB=
new e;this.localAxisA=new e};w.prototype.b2PrismaticJointDef=function(){this.__super.b2JointDef.call(this);this.type=s.e_prismaticJoint;this.localAxisA.Set(1,0);this.referenceAngle=0;this.enableLimit=!1;this.upperTranslation=this.lowerTranslation=0;this.enableMotor=!1;this.motorSpeed=this.maxMotorForce=0};w.prototype.Initialize=function(a,b,c,d){this.bodyA=a;this.bodyB=b;this.localAnchorA=this.bodyA.GetLocalPoint(c);this.localAnchorB=this.bodyB.GetLocalPoint(c);this.localAxisA=this.bodyA.GetLocalVector(d);
this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()};Box2D.inherit(B,Box2D.Dynamics.Joints.b2Joint);B.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;B.b2PulleyJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_groundAnchor1=new e;this.m_groundAnchor2=new e;this.m_localAnchor1=new e;this.m_localAnchor2=new e;this.m_u1=new e;this.m_u2=new e};B.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};B.prototype.GetAnchorB=
function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};B.prototype.GetReactionForce=function(a){return void 0===a&&(a=0),new e(a*this.m_impulse*this.m_u2.x,a*this.m_impulse*this.m_u2.y)};B.prototype.GetReactionTorque=function(a){return 0};B.prototype.GetGroundAnchorA=function(){var a=this.m_ground.m_xf.position.Copy();return a.Add(this.m_groundAnchor1),a};B.prototype.GetGroundAnchorB=function(){var a=this.m_ground.m_xf.position.Copy();return a.Add(this.m_groundAnchor2),a};B.prototype.GetLength1=
function(){var a=this.m_bodyA.GetWorldPoint(this.m_localAnchor1),b=a.x-(this.m_ground.m_xf.position.x+this.m_groundAnchor1.x),a=a.y-(this.m_ground.m_xf.position.y+this.m_groundAnchor1.y);return Math.sqrt(b*b+a*a)};B.prototype.GetLength2=function(){var a=this.m_bodyB.GetWorldPoint(this.m_localAnchor2),b=a.x-(this.m_ground.m_xf.position.x+this.m_groundAnchor2.x),a=a.y-(this.m_ground.m_xf.position.y+this.m_groundAnchor2.y);return Math.sqrt(b*b+a*a)};B.prototype.GetRatio=function(){return this.m_ratio};
B.prototype.b2PulleyJoint=function(a){this.__super.b2Joint.call(this,a);this.m_ground=this.m_bodyA.m_world.m_groundBody;this.m_groundAnchor1.x=a.groundAnchorA.x-this.m_ground.m_xf.position.x;this.m_groundAnchor1.y=a.groundAnchorA.y-this.m_ground.m_xf.position.y;this.m_groundAnchor2.x=a.groundAnchorB.x-this.m_ground.m_xf.position.x;this.m_groundAnchor2.y=a.groundAnchorB.y-this.m_ground.m_xf.position.y;this.m_localAnchor1.SetV(a.localAnchorA);this.m_localAnchor2.SetV(a.localAnchorB);this.m_ratio=a.ratio;
this.m_constant=a.lengthA+this.m_ratio*a.lengthB;this.m_maxLength1=d.Min(a.maxLengthA,this.m_constant-this.m_ratio*B.b2_minPulleyLength);this.m_maxLength2=d.Min(a.maxLengthB,(this.m_constant-B.b2_minPulleyLength)/this.m_ratio);this.m_limitImpulse2=this.m_limitImpulse1=this.m_impulse=0};B.prototype.InitVelocityConstraints=function(b){var c,d=this.m_bodyA,e=this.m_bodyB;c=d.m_xf.R;var f=this.m_localAnchor1.x-d.m_sweep.localCenter.x,g=this.m_localAnchor1.y-d.m_sweep.localCenter.y,h=c.col1.x*f+c.col2.x*
g,g=c.col1.y*f+c.col2.y*g,f=h;c=e.m_xf.R;var k=this.m_localAnchor2.x-e.m_sweep.localCenter.x,m=this.m_localAnchor2.y-e.m_sweep.localCenter.y,h=c.col1.x*k+c.col2.x*m,m=c.col1.y*k+c.col2.y*m,k=h;c=e.m_sweep.c.x+k;var h=e.m_sweep.c.y+m,n=this.m_ground.m_xf.position.x+this.m_groundAnchor2.x,p=this.m_ground.m_xf.position.y+this.m_groundAnchor2.y;this.m_u1.Set(d.m_sweep.c.x+f-(this.m_ground.m_xf.position.x+this.m_groundAnchor1.x),d.m_sweep.c.y+g-(this.m_ground.m_xf.position.y+this.m_groundAnchor1.y));this.m_u2.Set(c-
n,h-p);c=this.m_u1.Length();h=this.m_u2.Length();c>a.b2_linearSlop?this.m_u1.Multiply(1/c):this.m_u1.SetZero();h>a.b2_linearSlop?this.m_u2.Multiply(1/h):this.m_u2.SetZero();0<this.m_constant-c-this.m_ratio*h?(this.m_state=s.e_inactiveLimit,this.m_impulse=0):this.m_state=s.e_atUpperLimit;c<this.m_maxLength1?(this.m_limitState1=s.e_inactiveLimit,this.m_limitImpulse1=0):this.m_limitState1=s.e_atUpperLimit;h<this.m_maxLength2?(this.m_limitState2=s.e_inactiveLimit,this.m_limitImpulse2=0):this.m_limitState2=
s.e_atUpperLimit;c=f*this.m_u1.y-g*this.m_u1.x;h=k*this.m_u2.y-m*this.m_u2.x;(this.m_limitMass1=d.m_invMass+d.m_invI*c*c,this.m_limitMass2=e.m_invMass+e.m_invI*h*h,this.m_pulleyMass=this.m_limitMass1+this.m_ratio*this.m_ratio*this.m_limitMass2,this.m_limitMass1=1/this.m_limitMass1,this.m_limitMass2=1/this.m_limitMass2,this.m_pulleyMass=1/this.m_pulleyMass,b.warmStarting)?(this.m_impulse*=b.dtRatio,this.m_limitImpulse1*=b.dtRatio,this.m_limitImpulse2*=b.dtRatio,b=(-this.m_impulse-this.m_limitImpulse1)*
this.m_u1.x,c=(-this.m_impulse-this.m_limitImpulse1)*this.m_u1.y,h=(-this.m_ratio*this.m_impulse-this.m_limitImpulse2)*this.m_u2.x,n=(-this.m_ratio*this.m_impulse-this.m_limitImpulse2)*this.m_u2.y,d.m_linearVelocity.x+=d.m_invMass*b,d.m_linearVelocity.y+=d.m_invMass*c,d.m_angularVelocity+=d.m_invI*(f*c-g*b),e.m_linearVelocity.x+=e.m_invMass*h,e.m_linearVelocity.y+=e.m_invMass*n,e.m_angularVelocity+=e.m_invI*(k*n-m*h)):this.m_limitImpulse2=this.m_limitImpulse1=this.m_impulse=0};B.prototype.SolveVelocityConstraints=
function(a){var b;a=this.m_bodyA;var c=this.m_bodyB;b=a.m_xf.R;var e=this.m_localAnchor1.x-a.m_sweep.localCenter.x,f=this.m_localAnchor1.y-a.m_sweep.localCenter.y,g=b.col1.x*e+b.col2.x*f,f=b.col1.y*e+b.col2.y*f,e=g;b=c.m_xf.R;var h=this.m_localAnchor2.x-c.m_sweep.localCenter.x,k=this.m_localAnchor2.y-c.m_sweep.localCenter.y,g=b.col1.x*h+b.col2.x*k,k=b.col1.y*h+b.col2.y*k,h=g,m=g=b=0,n=0,p=0,r=0,t=0,u=0,v=0,w=0,x=0;this.m_state==s.e_atUpperLimit&&(b=a.m_linearVelocity.x+-a.m_angularVelocity*f,g=a.m_linearVelocity.y+
a.m_angularVelocity*e,m=c.m_linearVelocity.x+-c.m_angularVelocity*k,n=c.m_linearVelocity.y+c.m_angularVelocity*h,v=-(this.m_u1.x*b+this.m_u1.y*g)-this.m_ratio*(this.m_u2.x*m+this.m_u2.y*n),w=this.m_pulleyMass*-v,x=this.m_impulse,this.m_impulse=d.Max(0,this.m_impulse+w),w=this.m_impulse-x,p=-w*this.m_u1.x,r=-w*this.m_u1.y,t=-this.m_ratio*w*this.m_u2.x,u=-this.m_ratio*w*this.m_u2.y,a.m_linearVelocity.x+=a.m_invMass*p,a.m_linearVelocity.y+=a.m_invMass*r,a.m_angularVelocity+=a.m_invI*(e*r-f*p),c.m_linearVelocity.x+=
c.m_invMass*t,c.m_linearVelocity.y+=c.m_invMass*u,c.m_angularVelocity+=c.m_invI*(h*u-k*t));this.m_limitState1==s.e_atUpperLimit&&(b=a.m_linearVelocity.x+-a.m_angularVelocity*f,g=a.m_linearVelocity.y+a.m_angularVelocity*e,v=-(this.m_u1.x*b+this.m_u1.y*g),w=-this.m_limitMass1*v,x=this.m_limitImpulse1,this.m_limitImpulse1=d.Max(0,this.m_limitImpulse1+w),w=this.m_limitImpulse1-x,p=-w*this.m_u1.x,r=-w*this.m_u1.y,a.m_linearVelocity.x+=a.m_invMass*p,a.m_linearVelocity.y+=a.m_invMass*r,a.m_angularVelocity+=
a.m_invI*(e*r-f*p));this.m_limitState2==s.e_atUpperLimit&&(m=c.m_linearVelocity.x+-c.m_angularVelocity*k,n=c.m_linearVelocity.y+c.m_angularVelocity*h,v=-(this.m_u2.x*m+this.m_u2.y*n),w=-this.m_limitMass2*v,x=this.m_limitImpulse2,this.m_limitImpulse2=d.Max(0,this.m_limitImpulse2+w),w=this.m_limitImpulse2-x,t=-w*this.m_u2.x,u=-w*this.m_u2.y,c.m_linearVelocity.x+=c.m_invMass*t,c.m_linearVelocity.y+=c.m_invMass*u,c.m_angularVelocity+=c.m_invI*(h*u-k*t))};B.prototype.SolvePositionConstraints=function(b){var c;
b=this.m_bodyA;var e=this.m_bodyB,f=this.m_ground.m_xf.position.x+this.m_groundAnchor1.x,g=this.m_ground.m_xf.position.y+this.m_groundAnchor1.y,h=this.m_ground.m_xf.position.x+this.m_groundAnchor2.x,k=this.m_ground.m_xf.position.y+this.m_groundAnchor2.y,m=0,n=0,p=0,r=0,t=0,u=0,v=0,w=0,x=0,z=0,A=0,B=0,E=0,F=0;return this.m_state==s.e_atUpperLimit&&(c=b.m_xf.R,m=this.m_localAnchor1.x-b.m_sweep.localCenter.x,n=this.m_localAnchor1.y-b.m_sweep.localCenter.y,E=c.col1.x*m+c.col2.x*n,n=c.col1.y*m+c.col2.y*
n,m=E,c=e.m_xf.R,p=this.m_localAnchor2.x-e.m_sweep.localCenter.x,r=this.m_localAnchor2.y-e.m_sweep.localCenter.y,E=c.col1.x*p+c.col2.x*r,r=c.col1.y*p+c.col2.y*r,p=E,t=b.m_sweep.c.x+m,u=b.m_sweep.c.y+n,v=e.m_sweep.c.x+p,w=e.m_sweep.c.y+r,this.m_u1.Set(t-f,u-g),this.m_u2.Set(v-h,w-k),x=this.m_u1.Length(),z=this.m_u2.Length(),x>a.b2_linearSlop?this.m_u1.Multiply(1/x):this.m_u1.SetZero(),z>a.b2_linearSlop?this.m_u2.Multiply(1/z):this.m_u2.SetZero(),A=this.m_constant-x-this.m_ratio*z,F=d.Max(F,-A),A=d.Clamp(A+
a.b2_linearSlop,-a.b2_maxLinearCorrection,0),B=-this.m_pulleyMass*A,t=-B*this.m_u1.x,u=-B*this.m_u1.y,v=-this.m_ratio*B*this.m_u2.x,w=-this.m_ratio*B*this.m_u2.y,b.m_sweep.c.x+=b.m_invMass*t,b.m_sweep.c.y+=b.m_invMass*u,b.m_sweep.a+=b.m_invI*(m*u-n*t),e.m_sweep.c.x+=e.m_invMass*v,e.m_sweep.c.y+=e.m_invMass*w,e.m_sweep.a+=e.m_invI*(p*w-r*v),b.SynchronizeTransform(),e.SynchronizeTransform()),this.m_limitState1==s.e_atUpperLimit&&(c=b.m_xf.R,m=this.m_localAnchor1.x-b.m_sweep.localCenter.x,n=this.m_localAnchor1.y-
b.m_sweep.localCenter.y,E=c.col1.x*m+c.col2.x*n,n=c.col1.y*m+c.col2.y*n,m=E,t=b.m_sweep.c.x+m,u=b.m_sweep.c.y+n,this.m_u1.Set(t-f,u-g),x=this.m_u1.Length(),x>a.b2_linearSlop?(this.m_u1.x*=1/x,this.m_u1.y*=1/x):this.m_u1.SetZero(),A=this.m_maxLength1-x,F=d.Max(F,-A),A=d.Clamp(A+a.b2_linearSlop,-a.b2_maxLinearCorrection,0),B=-this.m_limitMass1*A,t=-B*this.m_u1.x,u=-B*this.m_u1.y,b.m_sweep.c.x+=b.m_invMass*t,b.m_sweep.c.y+=b.m_invMass*u,b.m_sweep.a+=b.m_invI*(m*u-n*t),b.SynchronizeTransform()),this.m_limitState2==
s.e_atUpperLimit&&(c=e.m_xf.R,p=this.m_localAnchor2.x-e.m_sweep.localCenter.x,r=this.m_localAnchor2.y-e.m_sweep.localCenter.y,E=c.col1.x*p+c.col2.x*r,r=c.col1.y*p+c.col2.y*r,p=E,v=e.m_sweep.c.x+p,w=e.m_sweep.c.y+r,this.m_u2.Set(v-h,w-k),z=this.m_u2.Length(),z>a.b2_linearSlop?(this.m_u2.x*=1/z,this.m_u2.y*=1/z):this.m_u2.SetZero(),A=this.m_maxLength2-z,F=d.Max(F,-A),A=d.Clamp(A+a.b2_linearSlop,-a.b2_maxLinearCorrection,0),B=-this.m_limitMass2*A,v=-B*this.m_u2.x,w=-B*this.m_u2.y,e.m_sweep.c.x+=e.m_invMass*
v,e.m_sweep.c.y+=e.m_invMass*w,e.m_sweep.a+=e.m_invI*(p*w-r*v),e.SynchronizeTransform()),F<a.b2_linearSlop};Box2D.postDefs.push(function(){Box2D.Dynamics.Joints.b2PulleyJoint.b2_minPulleyLength=2});Box2D.inherit(E,Box2D.Dynamics.Joints.b2JointDef);E.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;E.b2PulleyJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.groundAnchorA=new e;this.groundAnchorB=new e;this.localAnchorA=new e;this.localAnchorB=new e};
E.prototype.b2PulleyJointDef=function(){this.__super.b2JointDef.call(this);this.type=s.e_pulleyJoint;this.groundAnchorA.Set(-1,1);this.groundAnchorB.Set(1,1);this.localAnchorA.Set(-1,0);this.localAnchorB.Set(1,0);this.maxLengthB=this.lengthB=this.maxLengthA=this.lengthA=0;this.ratio=1;this.collideConnected=!0};E.prototype.Initialize=function(a,b,c,d,e,f,g){void 0===g&&(g=0);this.bodyA=a;this.bodyB=b;this.groundAnchorA.SetV(c);this.groundAnchorB.SetV(d);this.localAnchorA=this.bodyA.GetLocalPoint(e);
this.localAnchorB=this.bodyB.GetLocalPoint(f);a=e.x-c.x;c=e.y-c.y;this.lengthA=Math.sqrt(a*a+c*c);c=f.x-d.x;d=f.y-d.y;this.lengthB=Math.sqrt(c*c+d*d);this.ratio=g;g=this.lengthA+this.ratio*this.lengthB;this.maxLengthA=g-this.ratio*B.b2_minPulleyLength;this.maxLengthB=(g-B.b2_minPulleyLength)/this.ratio};Box2D.inherit(I,Box2D.Dynamics.Joints.b2Joint);I.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;I.b2RevoluteJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);
this.K=new b;this.K1=new b;this.K2=new b;this.K3=new b;this.impulse3=new f;this.impulse2=new e;this.reduced=new e;this.m_localAnchor1=new e;this.m_localAnchor2=new e;this.m_impulse=new f;this.m_mass=new c};I.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};I.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};I.prototype.GetReactionForce=function(a){return void 0===a&&(a=0),new e(a*this.m_impulse.x,a*this.m_impulse.y)};I.prototype.GetReactionTorque=
function(a){return void 0===a&&(a=0),a*this.m_impulse.z};I.prototype.GetJointAngle=function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a-this.m_referenceAngle};I.prototype.GetJointSpeed=function(){return this.m_bodyB.m_angularVelocity-this.m_bodyA.m_angularVelocity};I.prototype.IsLimitEnabled=function(){return this.m_enableLimit};I.prototype.EnableLimit=function(a){this.m_enableLimit=a};I.prototype.GetLowerLimit=function(){return this.m_lowerAngle};I.prototype.GetUpperLimit=function(){return this.m_upperAngle};
I.prototype.SetLimits=function(a,b){void 0===a&&(a=0);void 0===b&&(b=0);this.m_lowerAngle=a;this.m_upperAngle=b};I.prototype.IsMotorEnabled=function(){return this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor};I.prototype.EnableMotor=function(a){this.m_enableMotor=a};I.prototype.SetMotorSpeed=function(a){void 0===a&&(a=0);this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_motorSpeed=a};I.prototype.GetMotorSpeed=function(){return this.m_motorSpeed};I.prototype.SetMaxMotorTorque=
function(a){void 0===a&&(a=0);this.m_maxMotorTorque=a};I.prototype.GetMotorTorque=function(){return this.m_maxMotorTorque};I.prototype.b2RevoluteJoint=function(a){this.__super.b2Joint.call(this,a);this.m_localAnchor1.SetV(a.localAnchorA);this.m_localAnchor2.SetV(a.localAnchorB);this.m_referenceAngle=a.referenceAngle;this.m_impulse.SetZero();this.m_motorImpulse=0;this.m_lowerAngle=a.lowerAngle;this.m_upperAngle=a.upperAngle;this.m_maxMotorTorque=a.maxMotorTorque;this.m_motorSpeed=a.motorSpeed;this.m_enableLimit=
a.enableLimit;this.m_enableMotor=a.enableMotor;this.m_limitState=s.e_inactiveLimit};I.prototype.InitVelocityConstraints=function(b){var c,e=this.m_bodyA,f=this.m_bodyB,g=0;this.m_enableMotor||this.m_enableLimit;c=e.m_xf.R;var h=this.m_localAnchor1.x-e.m_sweep.localCenter.x,k=this.m_localAnchor1.y-e.m_sweep.localCenter.y,g=c.col1.x*h+c.col2.x*k,k=c.col1.y*h+c.col2.y*k,h=g;c=f.m_xf.R;var m=this.m_localAnchor2.x-f.m_sweep.localCenter.x,n=this.m_localAnchor2.y-f.m_sweep.localCenter.y,g=c.col1.x*m+c.col2.x*
n,n=c.col1.y*m+c.col2.y*n,m=g;c=e.m_invMass;var g=f.m_invMass,p=e.m_invI,r=f.m_invI;if(this.m_mass.col1.x=c+g+k*k*p+n*n*r,this.m_mass.col2.x=-k*h*p-n*m*r,this.m_mass.col3.x=-k*p-n*r,this.m_mass.col1.y=this.m_mass.col2.x,this.m_mass.col2.y=c+g+h*h*p+m*m*r,this.m_mass.col3.y=h*p+m*r,this.m_mass.col1.z=this.m_mass.col3.x,this.m_mass.col2.z=this.m_mass.col3.y,this.m_mass.col3.z=p+r,this.m_motorMass=1/(p+r),0==this.m_enableMotor&&(this.m_motorImpulse=0),this.m_enableLimit){var t=f.m_sweep.a-e.m_sweep.a-
this.m_referenceAngle;d.Abs(this.m_upperAngle-this.m_lowerAngle)<2*a.b2_angularSlop?this.m_limitState=s.e_equalLimits:t<=this.m_lowerAngle?(this.m_limitState!=s.e_atLowerLimit&&(this.m_impulse.z=0),this.m_limitState=s.e_atLowerLimit):t>=this.m_upperAngle?(this.m_limitState!=s.e_atUpperLimit&&(this.m_impulse.z=0),this.m_limitState=s.e_atUpperLimit):(this.m_limitState=s.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=s.e_inactiveLimit;b.warmStarting?(this.m_impulse.x*=b.dtRatio,this.m_impulse.y*=
b.dtRatio,this.m_motorImpulse*=b.dtRatio,b=this.m_impulse.x,t=this.m_impulse.y,e.m_linearVelocity.x-=c*b,e.m_linearVelocity.y-=c*t,e.m_angularVelocity-=p*(h*t-k*b+this.m_motorImpulse+this.m_impulse.z),f.m_linearVelocity.x+=g*b,f.m_linearVelocity.y+=g*t,f.m_angularVelocity+=r*(m*t-n*b+this.m_motorImpulse+this.m_impulse.z)):(this.m_impulse.SetZero(),this.m_motorImpulse=0)};I.prototype.SolveVelocityConstraints=function(a){var b=this.m_bodyA,c=this.m_bodyB,e=0,f=0,g=0,h=0,k=0,m=0,n=b.m_linearVelocity,
p=b.m_angularVelocity,r=c.m_linearVelocity,t=c.m_angularVelocity,u=b.m_invMass,v=c.m_invMass,w=b.m_invI,x=c.m_invI;this.m_enableMotor&&this.m_limitState!=s.e_equalLimits&&(g=this.m_motorMass*-(t-p-this.m_motorSpeed),h=this.m_motorImpulse,k=a.dt*this.m_maxMotorTorque,this.m_motorImpulse=d.Clamp(this.m_motorImpulse+g,-k,k),g=this.m_motorImpulse-h,p-=w*g,t+=x*g);this.m_enableLimit&&this.m_limitState!=s.e_inactiveLimit?(a=b.m_xf.R,g=this.m_localAnchor1.x-b.m_sweep.localCenter.x,h=this.m_localAnchor1.y-
b.m_sweep.localCenter.y,e=a.col1.x*g+a.col2.x*h,h=a.col1.y*g+a.col2.y*h,g=e,a=c.m_xf.R,k=this.m_localAnchor2.x-c.m_sweep.localCenter.x,m=this.m_localAnchor2.y-c.m_sweep.localCenter.y,e=a.col1.x*k+a.col2.x*m,m=a.col1.y*k+a.col2.y*m,k=e,a=r.x+-t*m-n.x- -p*h,e=r.y+t*k-n.y-p*g,this.m_mass.Solve33(this.impulse3,-a,-e,-(t-p)),this.m_limitState==s.e_equalLimits?this.m_impulse.Add(this.impulse3):this.m_limitState==s.e_atLowerLimit?(f=this.m_impulse.z+this.impulse3.z,0>f&&(this.m_mass.Solve22(this.reduced,
-a,-e),this.impulse3.x=this.reduced.x,this.impulse3.y=this.reduced.y,this.impulse3.z=-this.m_impulse.z,this.m_impulse.x+=this.reduced.x,this.m_impulse.y+=this.reduced.y,this.m_impulse.z=0)):this.m_limitState==s.e_atUpperLimit&&(f=this.m_impulse.z+this.impulse3.z,0<f&&(this.m_mass.Solve22(this.reduced,-a,-e),this.impulse3.x=this.reduced.x,this.impulse3.y=this.reduced.y,this.impulse3.z=-this.m_impulse.z,this.m_impulse.x+=this.reduced.x,this.m_impulse.y+=this.reduced.y,this.m_impulse.z=0)),n.x-=u*this.impulse3.x,
n.y-=u*this.impulse3.y,p-=w*(g*this.impulse3.y-h*this.impulse3.x+this.impulse3.z),r.x+=v*this.impulse3.x,r.y+=v*this.impulse3.y,t+=x*(k*this.impulse3.y-m*this.impulse3.x+this.impulse3.z)):(a=b.m_xf.R,g=this.m_localAnchor1.x-b.m_sweep.localCenter.x,h=this.m_localAnchor1.y-b.m_sweep.localCenter.y,e=a.col1.x*g+a.col2.x*h,h=a.col1.y*g+a.col2.y*h,g=e,a=c.m_xf.R,k=this.m_localAnchor2.x-c.m_sweep.localCenter.x,m=this.m_localAnchor2.y-c.m_sweep.localCenter.y,e=a.col1.x*k+a.col2.x*m,m=a.col1.y*k+a.col2.y*
m,k=e,this.m_mass.Solve22(this.impulse2,-(r.x+-t*m-n.x- -p*h),-(r.y+t*k-n.y-p*g)),this.m_impulse.x+=this.impulse2.x,this.m_impulse.y+=this.impulse2.y,n.x-=u*this.impulse2.x,n.y-=u*this.impulse2.y,p-=w*(g*this.impulse2.y-h*this.impulse2.x),r.x+=v*this.impulse2.x,r.y+=v*this.impulse2.y,t+=x*(k*this.impulse2.y-m*this.impulse2.x));b.m_linearVelocity.SetV(n);b.m_angularVelocity=p;c.m_linearVelocity.SetV(r);c.m_angularVelocity=t};I.prototype.SolvePositionConstraints=function(b){var c,e=0;b=this.m_bodyA;
var f=this.m_bodyB,g=0,h=0,k=h=0,m=0;if(this.m_enableLimit&&this.m_limitState!=s.e_inactiveLimit){var n=f.m_sweep.a-b.m_sweep.a-this.m_referenceAngle,p=0;this.m_limitState==s.e_equalLimits?(e=d.Clamp(n-this.m_lowerAngle,-a.b2_maxAngularCorrection,a.b2_maxAngularCorrection),p=-this.m_motorMass*e,g=d.Abs(e)):this.m_limitState==s.e_atLowerLimit?(e=n-this.m_lowerAngle,g=-e,e=d.Clamp(e+a.b2_angularSlop,-a.b2_maxAngularCorrection,0),p=-this.m_motorMass*e):this.m_limitState==s.e_atUpperLimit&&(e=n-this.m_upperAngle,
g=e,e=d.Clamp(e-a.b2_angularSlop,0,a.b2_maxAngularCorrection),p=-this.m_motorMass*e);b.m_sweep.a-=b.m_invI*p;f.m_sweep.a+=f.m_invI*p;b.SynchronizeTransform();f.SynchronizeTransform()}c=b.m_xf.R;e=this.m_localAnchor1.x-b.m_sweep.localCenter.x;n=this.m_localAnchor1.y-b.m_sweep.localCenter.y;h=c.col1.x*e+c.col2.x*n;n=c.col1.y*e+c.col2.y*n;e=h;c=f.m_xf.R;var p=this.m_localAnchor2.x-f.m_sweep.localCenter.x,r=this.m_localAnchor2.y-f.m_sweep.localCenter.y,h=c.col1.x*p+c.col2.x*r,r=c.col1.y*p+c.col2.y*r,
p=h;c=f.m_sweep.c.x+p-b.m_sweep.c.x-e;var t=f.m_sweep.c.y+r-b.m_sweep.c.y-n,u=c*c+t*t,h=Math.sqrt(u),v=b.m_invMass,w=f.m_invMass,x=b.m_invI,z=f.m_invI,A=10*a.b2_linearSlop;u>A*A&&(m=1/(v+w),k=m*-c,m*=-t,b.m_sweep.c.x-=0.5*v*k,b.m_sweep.c.y-=0.5*v*m,f.m_sweep.c.x+=0.5*w*k,f.m_sweep.c.y+=0.5*w*m,c=f.m_sweep.c.x+p-b.m_sweep.c.x-e,t=f.m_sweep.c.y+r-b.m_sweep.c.y-n);return this.K1.col1.x=v+w,this.K1.col2.x=0,this.K1.col1.y=0,this.K1.col2.y=v+w,this.K2.col1.x=x*n*n,this.K2.col2.x=-x*e*n,this.K2.col1.y=
-x*e*n,this.K2.col2.y=x*e*e,this.K3.col1.x=z*r*r,this.K3.col2.x=-z*p*r,this.K3.col1.y=-z*p*r,this.K3.col2.y=z*p*p,this.K.SetM(this.K1),this.K.AddM(this.K2),this.K.AddM(this.K3),this.K.Solve(I.tImpulse,-c,-t),k=I.tImpulse.x,m=I.tImpulse.y,b.m_sweep.c.x-=b.m_invMass*k,b.m_sweep.c.y-=b.m_invMass*m,b.m_sweep.a-=b.m_invI*(e*m-n*k),f.m_sweep.c.x+=f.m_invMass*k,f.m_sweep.c.y+=f.m_invMass*m,f.m_sweep.a+=f.m_invI*(p*m-r*k),b.SynchronizeTransform(),f.SynchronizeTransform(),h<=a.b2_linearSlop&&g<=a.b2_angularSlop};
Box2D.postDefs.push(function(){Box2D.Dynamics.Joints.b2RevoluteJoint.tImpulse=new e});Box2D.inherit(J,Box2D.Dynamics.Joints.b2JointDef);J.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;J.b2RevoluteJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA=new e;this.localAnchorB=new e};J.prototype.b2RevoluteJointDef=function(){this.__super.b2JointDef.call(this);this.type=s.e_revoluteJoint;this.localAnchorA.Set(0,0);this.localAnchorB.Set(0,
0);this.motorSpeed=this.maxMotorTorque=this.upperAngle=this.lowerAngle=this.referenceAngle=0;this.enableMotor=this.enableLimit=!1};J.prototype.Initialize=function(a,b,c){this.bodyA=a;this.bodyB=b;this.localAnchorA=this.bodyA.GetLocalPoint(c);this.localAnchorB=this.bodyB.GetLocalPoint(c);this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()};Box2D.inherit(O,Box2D.Dynamics.Joints.b2Joint);O.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;O.b2WeldJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,
arguments);this.m_localAnchorA=new e;this.m_localAnchorB=new e;this.m_impulse=new f;this.m_mass=new c};O.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)};O.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)};O.prototype.GetReactionForce=function(a){return void 0===a&&(a=0),new e(a*this.m_impulse.x,a*this.m_impulse.y)};O.prototype.GetReactionTorque=function(a){return void 0===a&&(a=0),a*this.m_impulse.z};O.prototype.b2WeldJoint=
function(a){this.__super.b2Joint.call(this,a);this.m_localAnchorA.SetV(a.localAnchorA);this.m_localAnchorB.SetV(a.localAnchorB);this.m_referenceAngle=a.referenceAngle;this.m_impulse.SetZero();this.m_mass=new c};O.prototype.InitVelocityConstraints=function(a){var b,c=0,d=this.m_bodyA,e=this.m_bodyB;b=d.m_xf.R;var f=this.m_localAnchorA.x-d.m_sweep.localCenter.x,g=this.m_localAnchorA.y-d.m_sweep.localCenter.y,c=b.col1.x*f+b.col2.x*g,g=b.col1.y*f+b.col2.y*g,f=c;b=e.m_xf.R;var h=this.m_localAnchorB.x-
e.m_sweep.localCenter.x,k=this.m_localAnchorB.y-e.m_sweep.localCenter.y,c=b.col1.x*h+b.col2.x*k,k=b.col1.y*h+b.col2.y*k,h=c;b=d.m_invMass;var c=e.m_invMass,m=d.m_invI,n=e.m_invI;this.m_mass.col1.x=b+c+g*g*m+k*k*n;this.m_mass.col2.x=-g*f*m-k*h*n;this.m_mass.col3.x=-g*m-k*n;this.m_mass.col1.y=this.m_mass.col2.x;this.m_mass.col2.y=b+c+f*f*m+h*h*n;this.m_mass.col3.y=f*m+h*n;this.m_mass.col1.z=this.m_mass.col3.x;this.m_mass.col2.z=this.m_mass.col3.y;this.m_mass.col3.z=m+n;a.warmStarting?(this.m_impulse.x*=
a.dtRatio,this.m_impulse.y*=a.dtRatio,this.m_impulse.z*=a.dtRatio,d.m_linearVelocity.x-=b*this.m_impulse.x,d.m_linearVelocity.y-=b*this.m_impulse.y,d.m_angularVelocity-=m*(f*this.m_impulse.y-g*this.m_impulse.x+this.m_impulse.z),e.m_linearVelocity.x+=c*this.m_impulse.x,e.m_linearVelocity.y+=c*this.m_impulse.y,e.m_angularVelocity+=n*(h*this.m_impulse.y-k*this.m_impulse.x+this.m_impulse.z)):this.m_impulse.SetZero()};O.prototype.SolveVelocityConstraints=function(a){var b,c=0;a=this.m_bodyA;var d=this.m_bodyB,
e=a.m_linearVelocity,g=a.m_angularVelocity,h=d.m_linearVelocity,k=d.m_angularVelocity,m=a.m_invMass,n=d.m_invMass,p=a.m_invI,r=d.m_invI;b=a.m_xf.R;var s=this.m_localAnchorA.x-a.m_sweep.localCenter.x,t=this.m_localAnchorA.y-a.m_sweep.localCenter.y,c=b.col1.x*s+b.col2.x*t,t=b.col1.y*s+b.col2.y*t,s=c;b=d.m_xf.R;var u=this.m_localAnchorB.x-d.m_sweep.localCenter.x,v=this.m_localAnchorB.y-d.m_sweep.localCenter.y,c=b.col1.x*u+b.col2.x*v,v=b.col1.y*u+b.col2.y*v,u=c;b=h.x-k*v-e.x+g*t;var c=h.y+k*u-e.y-g*s,
w=k-g,x=new f;this.m_mass.Solve33(x,-b,-c,-w);this.m_impulse.Add(x);e.x-=m*x.x;e.y-=m*x.y;g-=p*(s*x.y-t*x.x+x.z);h.x+=n*x.x;h.y+=n*x.y;k+=r*(u*x.y-v*x.x+x.z);a.m_angularVelocity=g;d.m_angularVelocity=k};O.prototype.SolvePositionConstraints=function(b){var c,e=0;b=this.m_bodyA;var g=this.m_bodyB;c=b.m_xf.R;var h=this.m_localAnchorA.x-b.m_sweep.localCenter.x,k=this.m_localAnchorA.y-b.m_sweep.localCenter.y,e=c.col1.x*h+c.col2.x*k,k=c.col1.y*h+c.col2.y*k,h=e;c=g.m_xf.R;var m=this.m_localAnchorB.x-g.m_sweep.localCenter.x,
n=this.m_localAnchorB.y-g.m_sweep.localCenter.y,e=c.col1.x*m+c.col2.x*n,n=c.col1.y*m+c.col2.y*n,m=e;c=b.m_invMass;var e=g.m_invMass,p=b.m_invI,r=g.m_invI,s=g.m_sweep.c.x+m-b.m_sweep.c.x-h,t=g.m_sweep.c.y+n-b.m_sweep.c.y-k,u=g.m_sweep.a-b.m_sweep.a-this.m_referenceAngle,v=10*a.b2_linearSlop,w=Math.sqrt(s*s+t*t),x=d.Abs(u);w>v&&(p*=1,r*=1);this.m_mass.col1.x=c+e+k*k*p+n*n*r;this.m_mass.col2.x=-k*h*p-n*m*r;this.m_mass.col3.x=-k*p-n*r;this.m_mass.col1.y=this.m_mass.col2.x;this.m_mass.col2.y=c+e+h*h*p+
m*m*r;this.m_mass.col3.y=h*p+m*r;this.m_mass.col1.z=this.m_mass.col3.x;this.m_mass.col2.z=this.m_mass.col3.y;this.m_mass.col3.z=p+r;v=new f;return this.m_mass.Solve33(v,-s,-t,-u),b.m_sweep.c.x-=c*v.x,b.m_sweep.c.y-=c*v.y,b.m_sweep.a-=p*(h*v.y-k*v.x+v.z),g.m_sweep.c.x+=e*v.x,g.m_sweep.c.y+=e*v.y,g.m_sweep.a+=r*(m*v.y-n*v.x+v.z),b.SynchronizeTransform(),g.SynchronizeTransform(),w<=a.b2_linearSlop&&x<=a.b2_angularSlop};Box2D.inherit(L,Box2D.Dynamics.Joints.b2JointDef);L.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;
L.b2WeldJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA=new e;this.localAnchorB=new e};L.prototype.b2WeldJointDef=function(){this.__super.b2JointDef.call(this);this.type=s.e_weldJoint;this.referenceAngle=0};L.prototype.Initialize=function(a,b,c){this.bodyA=a;this.bodyB=b;this.localAnchorA.SetV(this.bodyA.GetLocalPoint(c));this.localAnchorB.SetV(this.bodyB.GetLocalPoint(c));this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()}})();
(function(){var a=Box2D.Dynamics.b2DebugDraw;a.b2DebugDraw=function(){this.m_xformScale=this.m_fillAlpha=this.m_alpha=this.m_lineThickness=this.m_drawScale=1;var a=this;this.m_sprite={graphics:{clear:function(){a.m_ctx.clearRect(0,0,a.m_ctx.canvas.width,a.m_ctx.canvas.height)}}}};a.prototype._color=function(a,c){return"rgba("+((16711680&a)>>16)+","+((65280&a)>>8)+","+(255&a)+","+c+")"};a.prototype.b2DebugDraw=function(){this.m_drawFlags=0};a.prototype.SetFlags=function(a){void 0===a&&(a=0);this.m_drawFlags=
a};a.prototype.GetFlags=function(){return this.m_drawFlags};a.prototype.AppendFlags=function(a){void 0===a&&(a=0);this.m_drawFlags|=a};a.prototype.ClearFlags=function(a){void 0===a&&(a=0);this.m_drawFlags&=~a};a.prototype.SetSprite=function(a){this.m_ctx=a};a.prototype.GetSprite=function(){return this.m_ctx};a.prototype.SetDrawScale=function(a){void 0===a&&(a=0);this.m_drawScale=a};a.prototype.GetDrawScale=function(){return this.m_drawScale};a.prototype.SetLineThickness=function(a){void 0===a&&(a=
0);this.m_lineThickness=a;this.m_ctx.strokeWidth=a};a.prototype.GetLineThickness=function(){return this.m_lineThickness};a.prototype.SetAlpha=function(a){void 0===a&&(a=0);this.m_alpha=a};a.prototype.GetAlpha=function(){return this.m_alpha};a.prototype.SetFillAlpha=function(a){void 0===a&&(a=0);this.m_fillAlpha=a};a.prototype.GetFillAlpha=function(){return this.m_fillAlpha};a.prototype.SetXFormScale=function(a){void 0===a&&(a=0);this.m_xformScale=a};a.prototype.GetXFormScale=function(){return this.m_xformScale};
a.prototype.DrawPolygon=function(a,c,d){if(c){var e=this.m_ctx,f=this.m_drawScale;e.beginPath();e.strokeStyle=this._color(d.color,this.m_alpha);e.moveTo(a[0].x*f,a[0].y*f);for(d=1;c>d;d++)e.lineTo(a[d].x*f,a[d].y*f);e.lineTo(a[0].x*f,a[0].y*f);e.closePath();e.stroke()}};a.prototype.DrawSolidPolygon=function(a,c,d){if(c){var e=this.m_ctx,f=this.m_drawScale;e.beginPath();e.strokeStyle=this._color(d.color,this.m_alpha);e.fillStyle=this._color(d.color,this.m_fillAlpha);e.moveTo(a[0].x*f,a[0].y*f);for(d=
1;c>d;d++)e.lineTo(a[d].x*f,a[d].y*f);e.lineTo(a[0].x*f,a[0].y*f);e.closePath();e.fill();e.stroke()}};a.prototype.DrawCircle=function(a,c,d){if(c){var e=this.m_ctx,f=this.m_drawScale;e.beginPath();e.strokeStyle=this._color(d.color,this.m_alpha);e.arc(a.x*f,a.y*f,c*f,0,2*Math.PI,!0);e.closePath();e.stroke()}};a.prototype.DrawSolidCircle=function(a,c,d,e){if(c){var f=this.m_ctx,g=this.m_drawScale,h=a.x*g,k=a.y*g;f.moveTo(0,0);f.beginPath();f.strokeStyle=this._color(e.color,this.m_alpha);f.fillStyle=
this._color(e.color,this.m_fillAlpha);f.arc(h,k,c*g,0,2*Math.PI,!0);f.moveTo(h,k);f.lineTo((a.x+d.x*c)*g,(a.y+d.y*c)*g);f.closePath();f.fill();f.stroke()}};a.prototype.DrawSegment=function(a,c,d){var e=this.m_ctx,f=this.m_drawScale;e.strokeStyle=this._color(d.color,this.m_alpha);e.beginPath();e.moveTo(a.x*f,a.y*f);e.lineTo(c.x*f,c.y*f);e.closePath();e.stroke()};a.prototype.DrawTransform=function(a){var c=this.m_ctx,d=this.m_drawScale;c.beginPath();c.strokeStyle=this._color(16711680,this.m_alpha);
c.moveTo(a.position.x*d,a.position.y*d);c.lineTo((a.position.x+this.m_xformScale*a.R.col1.x)*d,(a.position.y+this.m_xformScale*a.R.col1.y)*d);c.strokeStyle=this._color(65280,this.m_alpha);c.moveTo(a.position.x*d,a.position.y*d);c.lineTo((a.position.x+this.m_xformScale*a.R.col2.x)*d,(a.position.y+this.m_xformScale*a.R.col2.y)*d);c.closePath();c.stroke()}})();var i;for(i=0;i<Box2D.postDefs.length;++i)Box2D.postDefs[i]();delete Box2D.postDefs;
"undefined"!=typeof require&&"undefined"!=typeof module&&(module.exports=Box2D);
!function(){Object.create=Object.create||function(a){function b(){}return b.prototype=a,new b};var a;"undefined"==typeof exports?(a={},"object"==typeof window&&(window.cp=a)):a=exports;var b,c,d=function(a,b){if(!a)throw Error("Assertion failed: "+b);},e=function(a,b){!a&&console&&console.warn&&(console.warn("ASSERTION FAILED: "+b),console.trace&&console.trace())},f=function(a,b){return b>a?a:b},g=function(a,b){return a>b?a:b};"object"==typeof window&&-1<window.navigator.userAgent.indexOf("Firefox")?
(b=Math.min,c=Math.max):(b=f,c=g);var h=function(a,b){return b>a?a+" "+b:b+" "+a},k=function(a,b){for(var c=0;c<a.length;c++)if(a[c]===b)return a[c]=a[a.length-1],void a.length--};a.momentForCircle=function(a,b,c,d){return a*(0.5*(b*b+c*c)+y(d))};a.areaForCircle=function(a,b){return Math.PI*Math.abs(a*a-b*b)};a.momentForSegment=function(a,b,c){var d=E(z(b,c),0.5);return a*(G(c,b)/12+y(d))};a.areaForSegment=function(a,b,c){return c*(Math.PI*c+2*C(a,b))};a.momentForPoly=function(a,b,c){for(var d=0,
e=0,f=b.length,g=0;f>g;g+=2)var h=b[g]+c.x,k=b[g+1]+c.y,m=b[(g+2)%f]+c.x,n=b[(g+3)%f]+c.y,p=m*k-n*h,d=d+p*(h*h+k*k+(h*m+k*n)+(m*m+n*n)),e=e+p;return a*d/(6*e)};a.areaForPoly=function(a){for(var b=0,c=0,d=a.length;d>c;c+=2)b+=I(new u(a[c],a[c+1]),new u(a[(c+2)%d],a[(c+3)%d]));return-b/2};a.centroidForPoly=function(a){for(var b=0,c=new u(0,0),d=0,e=a.length;e>d;d+=2)var f=new u(a[d],a[d+1]),g=new u(a[(d+2)%e],a[(d+3)%e]),h=I(f,g),b=b+h,c=z(c,E(z(f,g),h));return E(c,1/(3*b))};a.recenterPoly=function(b){for(var c=
a.centroidForPoly(b),d=0;d<b.length;d+=2)b[d]-=c.x,b[d+1]-=c.y};a.momentForBox=function(a,b,c){return a*(b*b+c*c)/12};a.momentForBox2=function(b,c){var d=c.r-c.l,e=c.t-c.b,f=E([c.l+c.r,c.b+c.t],0.5);return a.momentForBox(b,d,e)+b*y(f)};var m=a.loopIndexes=function(a){var b,c,d,e,f=0,g=0;b=d=a[0];c=e=a[1];for(var h=a.length>>1,k=1;h>k;k++){var m=a[2*k],n=a[2*k+1];b>m||m==b&&c>n?(b=m,c=n,f=k):(m>d||m==d&&n>e)&&(d=m,e=n,g=k)}return[f,g]},n=function(a,b,c){var d=a[2*b];a[2*b]=a[2*c];a[2*c]=d;d=a[2*b+
1];a[2*b+1]=a[2*c+1];a[2*c+1]=d},p=function(a,b,c,d,e,f){if(0===c)return 0;var g=0,h=b;e=w(e,d);f*=A(e);var k=b;for(c=b+c-1;c>=k;){var m=new u(a[2*k],a[2*k+1]),m=I(e,w(m,d));m>f?(m>g&&(g=m,h=k),k++):(n(a,k,c),c--)}return h!=b&&n(a,b,h),k-b},r=function(a,b,c,d,e,f,g,h){if(0>d)return 0;if(0==d)return b[2*h]=f.x,b[2*h+1]=f.y,1;var k=p(b,c,d,e,f,a),m=new u(b[2*c],b[2*c+1]);e=r(a,b,c+1,k-1,e,m,f,h);m=h+e++;b[2*m]=f.x;b[2*m+1]=f.y;d=p(b,c+k,d-k,f,g,a);m=new u(b[2*(c+k)],b[2*(c+k)+1]);return e+r(a,b,c+k+
1,d-1,f,m,g,h+e)};a.convexHull=function(a,b,c){if(b)for(var d=0;d<a.length;d++)b[d]=a[d];else b=a;var f=m(a),d=f[0],f=f[1];if(d==f)return b.length=2,b;n(b,0,d);n(b,1,0==f?d:f);d=new u(b[0],b[1]);f=new u(b[2],b[3]);a=r(c,b,2,(a.length>>1)-2,d,f,d,1)+1;return b.length=2*a,e(Oa(b),"Internal error: cpConvexHull() and cpPolyValidate() did not agree.Please report this error with as much info as you can."),b};var s=function(a,d,e){return b(c(a,d),e)},v=function(a){return c(0,b(a,1))},u=a.Vect=function(a,
b){this.x=a;this.y=b};a.v=function(a,b){return new u(a,b)};var t=a.vzero=new u(0,0),x=a.v.dot=function(a,b){return a.x*b.x+a.y*b.y},A=a.v.len=function(a){return Math.sqrt(x(a,a))},F=a.v.len2=function(a,b){return Math.sqrt(a*a+b*b)},z=(a.v.eql=function(a,b){return a.x===b.x&&a.y===b.y},a.v.add=function(a,b){return new u(a.x+b.x,a.y+b.y)});u.prototype.add=function(a){return this.x+=a.x,this.y+=a.y,this};var w=a.v.sub=function(a,b){return new u(a.x-b.x,a.y-b.y)};u.prototype.sub=function(a){return this.x-=
a.x,this.y-=a.y,this};var B=a.v.neg=function(a){return new u(-a.x,-a.y)};u.prototype.neg=function(){return this.x=-this.x,this.y=-this.y,this};var E=a.v.mult=function(a,b){return new u(a.x*b,a.y*b)};u.prototype.mult=function(a){return this.x*=a,this.y*=a,this};var I=a.v.cross=function(a,b){return a.x*b.y-a.y*b.x},J=a.v.perp=function(a){return new u(-a.y,a.x)},O=(a.v.pvrperp=function(a){return new u(a.y,-a.x)},a.v.project=function(a,b){return E(b,x(a,b)/y(b))});u.prototype.project=function(a){return this.mult(x(this,
a)/y(a)),this};var L=a.v.rotate=function(a,b){return new u(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x)};u.prototype.rotate=function(a){return this.x=this.x*a.x-this.y*a.y,this.y=this.x*a.y+this.y*a.x,this};var D=a.v.unrotate=function(a,b){return new u(a.x*b.x+a.y*b.y,a.y*b.x-a.x*b.y)},y=a.v.lengthsq=function(a){return x(a,a)},H=a.v.lengthsq2=function(a,b){return a*a+b*b},K=a.v.lerp=function(a,b,c){return z(E(a,1-c),E(b,c))},N=a.v.normalize=function(a){return E(a,1/A(a))},W=a.v.normalize_safe=function(a){return 0===
a.x&&0===a.y?t:N(a)},U=a.v.clamp=function(a,b){return x(a,a)>b*b?E(N(a),b):a},C=(a.v.lerpconst=function(a,b,c){return z(a,U(w(b,a),c))},a.v.dist=function(a,b){return A(w(a,b))}),G=a.v.distsq=function(a,b){return y(w(a,b))},T=(a.v.near=function(a,b,c){return G(a,b)<c*c},a.v.slerp=function(a,b,c){var d=Math.acos(x(a,b));if(d){var e=1/Math.sin(d);return z(E(a,Math.sin((1-c)*d)*e),E(b,Math.sin(c*d)*e))}return a}),P=(a.v.slerpconst=function(a,c,d){var e=Math.acos(x(a,c));return T(a,c,b(d,e)/e)},a.v.forangle=
function(a){return new u(Math.cos(a),Math.sin(a))},a.v.toangle=function(a){return Math.atan2(a.y,a.x)},a.v.str=function(a){return"("+a.x.toFixed(3)+", "+a.y.toFixed(3)+")"},0),R=a.BB=function(a,b,c,d){this.l=a;this.b=b;this.r=c;this.t=d;P++};a.bb=function(a,b,c,d){return new R(a,b,c,d)};var M=0,Y=(a.NO_GROUP=0,a.ALL_LAYERS=-1);a.resetShapeIdCounter=function(){M=0};var V=a.Shape=function(a){this.body=a;this.bb_l=this.bb_b=this.bb_r=this.bb_t=0;this.hashid=M++;this.sensor=!1;this.u=this.e=0;this.surface_v=
t;this.group=this.collision_type=0;this.layers=Y;this.space=null;this.collisionCode=this.collisionCode};V.prototype.setElasticity=function(a){this.e=a};V.prototype.setFriction=function(a){this.body.activate();this.u=a};V.prototype.setLayers=function(a){this.body.activate();this.layers=a};V.prototype.setSensor=function(a){this.body.activate();this.sensor=a};V.prototype.setCollisionType=function(a){this.body.activate();this.collision_type=a};V.prototype.getBody=function(){return this.body};V.prototype.active=
function(){return this.body&&-1!==this.body.shapeList.indexOf(this)};V.prototype.setBody=function(a){d(!this.active(),"You cannot change the body on an active shape. You must remove the shape from the space before changing the body.");this.body=a};V.prototype.cacheBB=function(){return this.update(this.body.p,this.body.rot)};V.prototype.update=function(a,b){d(!isNaN(b.x),"Rotation is NaN");d(!isNaN(a.x),"Position is NaN");this.cacheData(a,b)};V.prototype.pointQuery=function(a){a=this.nearestPointQuery(a);
return 0>a.d?a:void 0};V.prototype.getBB=function(){return new R(this.bb_l,this.bb_b,this.bb_r,this.bb_t)};var pa=function(a,b,c){this.shape=a;this.p=b;this.d=c},la=function(a,b,c){this.shape=a;this.t=b;this.n=c};la.prototype.hitPoint=function(a,b){return K(a,b,this.t)};la.prototype.hitDist=function(a,b){return C(a,b)*this.t};var ja=a.CircleShape=function(a,b,c){this.c=this.tc=c;this.r=b;this.type="circle";V.call(this,a)};ja.prototype=Object.create(V.prototype);ja.prototype.cacheData=function(a,b){var c=
this.tc=L(this.c,b).add(a),d=this.r;this.bb_l=c.x-d;this.bb_b=c.y-d;this.bb_r=c.x+d;this.bb_t=c.y+d};ja.prototype.nearestPointQuery=function(a){var b=a.x-this.tc.x,c=a.y-this.tc.y;a=F(b,c);var d=this.r,b=new u(this.tc.x+b*d/a,this.tc.y+c*d/a);return new pa(this,b,a-d)};var Aa=function(a,b,c,d,e,f){d=w(d,b);e=w(e,b);b=x(d,d)-2*x(d,e)+x(e,e);f=-2*x(d,d)+2*x(d,e);c=x(d,d)-c*c;c=f*f-4*b*c;if(0<=c&&(c=(-f-Math.sqrt(c))/(2*b),0<=c&&1>=c))return new la(a,c,N(K(d,e,c)))};ja.prototype.segmentQuery=function(a,
b){return Aa(this,this.tc,this.r,a,b)};var ha=a.SegmentShape=function(a,b,c,d){this.a=b;this.b=c;this.n=J(N(w(c,b)));this.ta=this.tb=this.tn=null;this.r=d;this.b_tangent=this.a_tangent=t;this.type="segment";V.call(this,a)};ha.prototype=Object.create(V.prototype);ha.prototype.cacheData=function(a,b){this.ta=z(a,L(this.a,b));this.tb=z(a,L(this.b,b));this.tn=L(this.n,b);var c,d,e,f;this.ta.x<this.tb.x?(c=this.ta.x,d=this.tb.x):(c=this.tb.x,d=this.ta.x);this.ta.y<this.tb.y?(e=this.ta.y,f=this.tb.y):(e=
this.tb.y,f=this.ta.y);var g=this.r;this.bb_l=c-g;this.bb_b=e-g;this.bb_r=d+g;this.bb_t=f+g};ha.prototype.nearestPointQuery=function(a){var b;b=this.tb;var c=w(this.ta,b),d=v(x(c,w(a,b))/y(c));b=z(b,E(c,d));var c=a.x-b.x,e=a.y-b.y;a=F(c,e);d=this.r;b=a?z(b,E(new u(c,e),d/a)):b;return new pa(this,b,a-d)};ha.prototype.segmentQuery=function(a,b){var c=this.tn,d=x(w(this.ta,a),c),e=this.r,f=0<d?B(c):c,g=w(E(f,e),a),h=z(this.ta,g),k=z(this.tb,g),g=w(b,a);if(0>=I(g,h)*I(g,k)){if(e=d+(0<d?-e:e),d=-e,c=x(g,
c)-e,0>d*c)return new la(this,d/(d-c),f)}else if(0!==e)return f=Aa(this,this.ta,this.r,a,b),c=Aa(this,this.tb,this.r,a,b),f?c&&c.t<f.t?c:f:c};ha.prototype.setNeighbors=function(a,b){this.a_tangent=w(a,this.a);this.b_tangent=w(b,this.b)};ha.prototype.setEndpoints=function(a,b){this.a=a;this.b=b;this.n=J(N(w(b,a)))};var Oa=function(a){for(var b=a.length,c=0;b>c;c+=2){var d=a[(c+2)%b],e=a[(c+3)%b];if(0<(d-a[c])*(a[(c+5)%b]-e)-(e-a[c+1])*(a[(c+4)%b]-d))return!1}return!0},aa=a.PolyShape=function(a,b,c){this.setVerts(b,
c);this.type="poly";V.call(this,a)};aa.prototype=Object.create(V.prototype);var qa=function(a,b){this.n=a;this.d=b};qa.prototype.compare=function(a){return x(this.n,a)-this.d};aa.prototype.setVerts=function(a,b){d(4<=a.length,"Polygons require some verts");d("number"==typeof a[0],"Polygon verticies should be specified in a flattened list (eg [x1,y1,x2,y2,x3,y3,...])");d(Oa(a),"Polygon is concave or has a reversed winding. Consider using cpConvexHull()");var c=a.length,e=c>>1;this.verts=Array(c);this.tVerts=
Array(c);this.planes=Array(e);this.tPlanes=Array(e);for(e=0;c>e;e+=2){var f=a[e]+b.x,g=a[e+1]+b.y,h=N(J(new u(a[(e+2)%c]+b.x-f,a[(e+3)%c]+b.y-g)));this.verts[e]=f;this.verts[e+1]=g;this.planes[e>>1]=new qa(h,h.x*f+h.y*g);this.tPlanes[e>>1]=new qa(new u(0,0),0)}};var ib=(a.BoxShape=function(a,b,c){b/=2;c/=2;return ib(a,new R(-b,-c,b,c))},a.BoxShape2=function(a,b){return new aa(a,[b.l,b.b,b.l,b.t,b.r,b.t,b.r,b.b],t)});aa.prototype.transformVerts=function(a,d){for(var e=this.verts,f=this.tVerts,g=1/
0,h=-(1/0),k=1/0,m=-(1/0),n=0;n<e.length;n+=2){var p=e[n],r=e[n+1],s=a.x+p*d.x-r*d.y,p=a.y+p*d.y+r*d.x;f[n]=s;f[n+1]=p;g=b(g,s);h=c(h,s);k=b(k,p);m=c(m,p)}this.bb_l=g;this.bb_b=k;this.bb_r=h;this.bb_t=m};aa.prototype.transformAxes=function(a,b){for(var c=this.planes,d=this.tPlanes,e=0;e<c.length;e++){var f=L(c[e].n,b);d[e].n=f;d[e].d=x(a,f)+c[e].d}};aa.prototype.cacheData=function(a,b){this.transformAxes(a,b);this.transformVerts(a,b)};aa.prototype.nearestPointQuery=function(a){for(var b=this.tPlanes,
c=this.tVerts,d=c[c.length-2],e=c[c.length-1],f=1/0,g=t,h=!1,k=0;k<b.length;k++){0<b[k].compare(a)&&(h=!0);var m=c[2*k],n=c[2*k+1],p;p=m;var r=n,d=d-p,e=e-r,s=v((d*(a.x-p)+e*(a.y-r))/H(d,e));p=new u(p+d*s,r+e*s);r=C(a,p);f>r&&(f=r,g=p);d=m;e=n}return new pa(this,g,h?f:-f)};aa.prototype.segmentQuery=function(a,b){for(var c=this.tPlanes,d=this.tVerts,e=c.length,f=2*e,g=0;e>g;g++){var h=c[g].n,k=x(a,h);if(!(c[g].d>k)){var m=x(b,h),k=(c[g].d-k)/(m-k);if(!(0>k||1<k)){var m=K(a,b,k),m=-I(h,m),n=-(h.x*d[(2*
g+3)%f]-h.y*d[(2*g+2)%f]);if(m>=-(h.x*d[2*g+1]-h.y*d[2*g])&&n>=m)return new la(this,k,h)}}}};aa.prototype.valueOnAxis=function(a,c){for(var d=this.tVerts,e=a.x*d[0]+a.y*d[1],f=2;f<d.length;f+=2)e=b(e,a.x*d[f]+a.y*d[f+1]);return e-c};aa.prototype.containsVert=function(a,b){for(var c=this.tPlanes,d=0;d<c.length;d++){var e=c[d].n;if(0<e.x*a+e.y*b-c[d].d)return!1}return!0};aa.prototype.containsVertPartial=function(a,b,c){for(var d=this.tPlanes,e=0;e<d.length;e++){var f=d[e].n;if(!(0>x(f,c))&&0<f.x*a+
f.y*b-d[e].d)return!1}return!0};aa.prototype.getNumVerts=function(){return this.verts.length/2};aa.prototype.getVert=function(a){return new u(this.verts[2*a],this.verts[2*a+1])};var S=a.Body=function(a,b){this.p=new u(0,0);this.vx=this.vy=0;this.f=new u(0,0);this.t=this.w=0;this.v_limit=1/0;this.w_limit=1/0;this.w_bias=this.v_biasx=this.v_biasy=0;this.space=null;this.shapeList=[];this.nodeNext=this.nodeRoot=this.constraintList=this.arbiterList=null;this.nodeIdleTime=0;this.setMass(a);this.setMoment(b);
this.rot=new u(0,0);this.setAngle(0)};a.StaticBody=function(){var a=new S(1/0,1/0);return a.nodeIdleTime=1/0,a};var ra=function(a,b){d(a.x==a.x&&a.y==a.y,b)},sa=function(a,b){d(Math.abs(a.x)!==1/0&&Math.abs(a.y)!==1/0,b)};S.prototype.sanityCheck=function(){d(this.m===this.m&&this.m_inv===this.m_inv,"Body's mass is invalid.");d(this.i===this.i&&this.i_inv===this.i_inv,"Body's moment is invalid.");var a=this.p;ra(a,"Body's position is invalid.");sa(a,"Body's position is invalid.");a=this.f;ra(a,"Body's force is invalid.");
sa(a,"Body's force is invalid.");d(this.vx===this.vx&&Math.abs(this.vx)!==1/0,"Body's velocity is invalid.");d(this.vy===this.vy&&Math.abs(this.vy)!==1/0,"Body's velocity is invalid.");d(this.a===this.a&&Math.abs(this.a)!==1/0,"Body's angle is invalid.");d(this.w===this.w&&Math.abs(this.w)!==1/0,"Body's angular velocity is invalid.");d(this.t===this.t&&Math.abs(this.t)!==1/0,"Body's torque is invalid.");a=this.rot;ra(a,"Body's rotation vector is invalid.");sa(a,"Body's rotation vector is invalid.");
d(this.v_limit===this.v_limit,"Body's velocity limit is invalid.");d(this.w_limit===this.w_limit,"Body's angular velocity limit is invalid.")};S.prototype.getPos=function(){return this.p};S.prototype.getVel=function(){return new u(this.vx,this.vy)};S.prototype.getAngVel=function(){return this.w};S.prototype.isSleeping=function(){return null!==this.nodeRoot};S.prototype.isStatic=function(){return this.nodeIdleTime===1/0};S.prototype.isRogue=function(){return null===this.space};S.prototype.setMass=
function(a){d(0<a,"Mass must be positive and non-zero.");this.activate();this.m=a;this.m_inv=1/a};S.prototype.setMoment=function(a){d(0<a,"Moment of Inertia must be positive and non-zero.");this.activate();this.i=a;this.i_inv=1/a};S.prototype.addShape=function(a){this.shapeList.push(a)};S.prototype.removeShape=function(a){k(this.shapeList,a)};var ta=function(a,b,c){return a===c?a.next(b):(a.a===b?a.next_a=ta(a.next_a,b,c):a.next_b=ta(a.next_b,b,c),a)};S.prototype.removeConstraint=function(a){this.constraintList=
ta(this.constraintList,this,a)};S.prototype.setPos=function(b){this.activate();this.sanityCheck();b===t&&(b=a.v(0,0));this.p=b};S.prototype.setVel=function(a){this.activate();this.vx=a.x;this.vy=a.y};S.prototype.setAngVel=function(a){this.activate();this.w=a};S.prototype.setAngleInternal=function(a){d(!isNaN(a),"Internal Error: Attempting to set body's angle to NaN");this.a=a;this.rot.x=Math.cos(a);this.rot.y=Math.sin(a)};S.prototype.setAngle=function(a){this.activate();this.sanityCheck();this.setAngleInternal(a)};
S.prototype.velocity_func=function(a,b,c){var d=this.vx*b+(a.x+this.f.x*this.m_inv)*c;a=this.vy*b+(a.y+this.f.y*this.m_inv)*c;var e=this.v_limit,f=d*d+a*a,e=f>e*e?e/Math.sqrt(f):1;this.vx=d*e;this.vy=a*e;d=this.w_limit;this.w=s(this.w*b+this.t*this.i_inv*c,-d,d);this.sanityCheck()};S.prototype.position_func=function(a){this.p.x+=(this.vx+this.v_biasx)*a;this.p.y+=(this.vy+this.v_biasy)*a;this.setAngleInternal(this.a+(this.w+this.w_bias)*a);this.w_bias=this.v_biasx=this.v_biasy=0;this.sanityCheck()};
S.prototype.resetForces=function(){this.activate();this.f=new u(0,0);this.t=0};S.prototype.applyForce=function(a,b){this.activate();this.f=z(this.f,a);this.t+=I(b,a)};S.prototype.applyImpulse=function(a,b){this.activate();za(this,a.x,a.y,b)};S.prototype.getVelAtPoint=function(a){return z(new u(this.vx,this.vy),E(J(a),this.w))};S.prototype.getVelAtWorldPoint=function(a){return this.getVelAtPoint(w(a,this.p))};S.prototype.getVelAtLocalPoint=function(a){return this.getVelAtPoint(L(a,this.rot))};S.prototype.eachShape=
function(a){for(var b=0,c=this.shapeList.length;c>b;b++)a(this.shapeList[b])};S.prototype.eachConstraint=function(a){for(var b=this.constraintList;b;){var c=b.next(this);a(b);b=c}};S.prototype.eachArbiter=function(a){for(var b=this.arbiterList;b;){var c=b.next(this);b.swappedColl=this===b.body_b;a(b);b=c}};S.prototype.local2World=function(a){return z(this.p,L(a,this.rot))};S.prototype.world2Local=function(a){return D(w(a,this.p),this.rot)};S.prototype.kineticEnergy=function(){var a=this.vx*this.vx+
this.vy*this.vy,b=this.w*this.w;return(a?a*this.m:0)+(b?b*this.i:0)};var Da=a.SpatialIndex=function(a){if(this.staticIndex=a,a){if(a.dynamicIndex)throw Error("This static index is already associated with a dynamic index.");a.dynamicIndex=this}};Da.prototype.collideStatic=function(a,b){if(0<a.count){var c=a.query;this.each(function(a){c(a,new R(a.bb_l,a.bb_b,a.bb_r,a.bb_t),b)})}};var Z=a.BBTree=function(a){Da.call(this,a);this.velocityFunc=null;this.leaves={};this.count=0;this.pooledPairs=this.pooledNodes=
this.root=null;this.stamp=0};Z.prototype=Object.create(Da.prototype);var jb=0,da=function(a,d,e){this.obj=null;this.bb_l=b(d.bb_l,e.bb_l);this.bb_b=b(d.bb_b,e.bb_b);this.bb_r=c(d.bb_r,e.bb_r);this.bb_t=c(d.bb_t,e.bb_t);this.parent=null;this.setA(d);this.setB(e)};Z.prototype.makeNode=function(a,b){var c=this.pooledNodes;return c?(this.pooledNodes=c.parent,c.constructor(this,a,b),c):(jb++,new da(this,a,b))};var Sa=0,fa=function(a,b){this.obj=b;a.getBB(b,this);this.parent=null;this.stamp=1;this.pairs=
null;Sa++};Z.prototype.getBB=function(a,d){var e=this.velocityFunc;if(e){var f=0.1*(a.bb_r-a.bb_l),g=0.1*(a.bb_t-a.bb_b),e=E(e(a),0.1);d.bb_l=a.bb_l+b(-f,e.x);d.bb_b=a.bb_b+b(-g,e.y);d.bb_r=a.bb_r+c(f,e.x);d.bb_t=a.bb_t+c(g,e.y)}else d.bb_l=a.bb_l,d.bb_b=a.bb_b,d.bb_r=a.bb_r,d.bb_t=a.bb_t};Z.prototype.getStamp=function(){var a=this.dynamicIndex;return a&&a.stamp?a.stamp:this.stamp};Z.prototype.incrementStamp=function(){this.dynamicIndex&&this.dynamicIndex.stamp?this.dynamicIndex.stamp++:this.stamp++};
var kb=0,Ea=function(a,b,c,d){this.prevA=null;this.leafA=a;this.nextA=b;this.prevB=null;this.leafB=c;this.nextB=d};Z.prototype.makePair=function(a,b,c,d){var e=this.pooledPairs;return e?(this.pooledPairs=e.prevA,e.prevA=null,e.leafA=a,e.nextA=b,e.prevB=null,e.leafB=c,e.nextB=d,e):(kb++,new Ea(a,b,c,d))};Ea.prototype.recycle=function(a){this.prevA=a.pooledPairs;a.pooledPairs=this};var Ta=function(a,b,c){c&&(c.leafA===b?c.prevA=a:c.prevB=a);a?a.leafA===b?a.nextA=c:a.nextB=c:b.pairs=c};fa.prototype.clearPairs=
function(a){var b,c=this.pairs;for(this.pairs=null;c;)c.leafA===this?(b=c.nextA,Ta(c.prevB,c.leafB,c.nextB)):(b=c.nextB,Ta(c.prevA,c.leafA,c.nextA)),c.recycle(a),c=b};var Pa=function(a,b,c){var d=a.pairs,e=b.pairs;c=c.makePair(a,d,b,e);a.pairs=b.pairs=c;d&&(d.leafA===a?d.prevA=c:d.prevB=c);e&&(e.leafA===b?e.prevA=c:e.prevB=c)};da.prototype.recycle=function(a){this.parent=a.pooledNodes;a.pooledNodes=this};fa.prototype.recycle=function(a){};da.prototype.setA=function(a){this.A=a;a.parent=this};da.prototype.setB=
function(a){this.B=a;a.parent=this};fa.prototype.isLeaf=!0;da.prototype.isLeaf=!1;da.prototype.otherChild=function(a){return this.A==a?this.B:this.A};da.prototype.replaceChild=function(a,d,f){e(a==this.A||a==this.B,"Node is not a child of parent.");this.A==a?(this.A.recycle(f),this.setA(d)):(this.B.recycle(f),this.setB(d));for(a=this;a;a=a.parent)d=a.A,f=a.B,a.bb_l=b(d.bb_l,f.bb_l),a.bb_b=b(d.bb_b,f.bb_b),a.bb_r=c(d.bb_r,f.bb_r),a.bb_t=c(d.bb_t,f.bb_t)};da.prototype.bbArea=fa.prototype.bbArea=function(){return(this.bb_r-
this.bb_l)*(this.bb_t-this.bb_b)};var Ba=function(a,d){return(c(a.bb_r,d.bb_r)-b(a.bb_l,d.bb_l))*(c(a.bb_t,d.bb_t)-b(a.bb_b,d.bb_b))},Qa=function(a,b){return Math.abs(a.bb_l+a.bb_r-b.bb_l-b.bb_r)+Math.abs(a.bb_b+a.bb_t-b.bb_b-b.bb_t)},ma=function(a,d,e){if(null==a)return d;if(a.isLeaf)return e.makeNode(d,a);var f=a.B.bbArea()+Ba(a.A,d),g=a.A.bbArea()+Ba(a.B,d);return f===g&&(f=Qa(a.A,d),g=Qa(a.B,d)),f>g?a.setB(ma(a.B,d,e)):a.setA(ma(a.A,d,e)),a.bb_l=b(a.bb_l,d.bb_l),a.bb_b=b(a.bb_b,d.bb_b),a.bb_r=
c(a.bb_r,d.bb_r),a.bb_t=c(a.bb_t,d.bb_t),a};da.prototype.intersectsBB=fa.prototype.intersectsBB=function(a){return this.bb_l<=a.r&&a.l<=this.bb_r&&this.bb_b<=a.t&&a.b<=this.bb_t};var Ca=function(a,b,c){a.intersectsBB(b)&&(a.isLeaf?c(a.obj):(Ca(a.A,b,c),Ca(a.B,b,c)))},Ra=function(a,d,e){var f=1/(e.x-d.x),g=a.bb_l==d.x?-(1/0):(a.bb_l-d.x)*f,h=a.bb_r==d.x?1/0:(a.bb_r-d.x)*f,f=b(g,h),g=c(g,h),h=1/(e.y-d.y);e=a.bb_b==d.y?-(1/0):(a.bb_b-d.y)*h;d=a.bb_t==d.y?1/0:(a.bb_t-d.y)*h;a=b(e,d);d=c(e,d);return g>=
a&&d>=f&&(f=c(f,a),0<=b(g,d)&&1>=f)?c(f,0):1/0},na=function(a,c,d,e,f){if(a.isLeaf)return f(a.obj);var g=Ra(a.A,c,d),h=Ra(a.B,c,d);return h>g?(e>g&&(e=b(e,na(a.A,c,d,e,f))),e>h&&(e=b(e,na(a.B,c,d,e,f)))):(e>h&&(e=b(e,na(a.B,c,d,e,f))),e>g&&(e=b(e,na(a.A,c,d,e,f)))),e};Z.prototype.subtreeRecycle=function(a){a.isLeaf&&(this.subtreeRecycle(a.A),this.subtreeRecycle(a.B),a.recycle(this))};var Fa=function(a,b,c){if(b==a)return null;var d=b.parent;return d==a?(b=a.otherChild(b),b.parent=a.parent,a.recycle(c),
b):(d.parent.replaceChild(d,d.otherChild(b),c),a)},Ua=function(a,b){return a.bb_l<=b.bb_r&&b.bb_l<=a.bb_r&&a.bb_b<=b.bb_t&&b.bb_b<=a.bb_t};fa.prototype.markLeafQuery=function(a,b,c,d){Ua(a,this)&&(b?Pa(a,this,c):(this.stamp<a.stamp&&Pa(this,a,c),d&&d(a.obj,this.obj)))};da.prototype.markLeafQuery=function(a,b,c,d){Ua(a,this)&&(this.A.markLeafQuery(a,b,c,d),this.B.markLeafQuery(a,b,c,d))};fa.prototype.markSubtree=function(a,b,c){if(this.stamp==a.getStamp()){b&&b.markLeafQuery(this,!1,a,c);for(b=this;b.parent;b=
b.parent)b==b.parent.A?b.parent.B.markLeafQuery(this,!0,a,c):b.parent.A.markLeafQuery(this,!1,a,c)}else for(a=this.pairs;a;)this===a.leafB?(c&&c(a.leafA.obj,this.obj),a=a.nextB):a=a.nextA};da.prototype.markSubtree=function(a,b,c){this.A.markSubtree(a,b,c);this.B.markSubtree(a,b,c)};fa.prototype.containsObj=function(a){return this.bb_l<=a.bb_l&&this.bb_r>=a.bb_r&&this.bb_b<=a.bb_b&&this.bb_t>=a.bb_t};fa.prototype.update=function(a){var b=a.root;return this.containsObj(this.obj)?!1:(a.getBB(this.obj,
this),b=Fa(b,this,a),a.root=ma(b,this,a),this.clearPairs(a),this.stamp=a.getStamp(),!0)};fa.prototype.addPairs=function(a){var b=a.dynamicIndex;b?(a=b.root)&&a.markLeafQuery(this,!0,b,null):this.markSubtree(a,a.staticIndex.root,null)};Z.prototype.insert=function(a,b){var c=new fa(this,a);this.leaves[b]=c;this.root=ma(this.root,c,this);this.count++;c.stamp=this.getStamp();c.addPairs(this);this.incrementStamp()};Z.prototype.remove=function(a,b){var c=this.leaves[b];delete this.leaves[b];this.root=Fa(this.root,
c,this);this.count--;c.clearPairs(this);c.recycle(this)};Z.prototype.contains=function(a,b){return null!=this.leaves[b]};var lb=function(a,b){};Z.prototype.reindexQuery=function(a){if(this.root){var b,c=this.leaves;for(b in c)c[b].update(this);c=(b=this.staticIndex)&&b.root;this.root.markSubtree(this,c,a);b&&!c&&this.collideStatic(this,b,a);this.incrementStamp()}};Z.prototype.reindex=function(){this.reindexQuery(lb)};Z.prototype.reindexObject=function(a,b){var c=this.leaves[b];c&&(c.update(this)&&
c.addPairs(this),this.incrementStamp())};Z.prototype.pointQuery=function(a,b){this.query(new R(a.x,a.y,a.x,a.y),b)};Z.prototype.segmentQuery=function(a,b,c,d){this.root&&na(this.root,a,b,c,d)};Z.prototype.query=function(a,b){this.root&&Ca(this.root,a,b)};Z.prototype.count=function(){return this.count};Z.prototype.each=function(a){for(var b in this.leaves)a(this.leaves[b].obj)};var Ga=function(a,d,e,f){if(1==f)return d[e];if(2==f)return a.makeNode(d[e],d[e+1]);for(var g=d[e],h=g.bb_l,k=g.bb_b,m=g.bb_r,
n=g.bb_t,p=e+f,r=e+1;p>r;r++)g=d[r],h=b(h,g.bb_l),k=b(k,g.bb_b),m=c(m,g.bb_r),n=c(n,g.bb_t);var g=m-h>n-k,s=Array(2*f);if(g)for(r=e;p>r;r++)s[2*r+0]=d[r].bb_l,s[2*r+1]=d[r].bb_r;else for(r=e;p>r;r++)s[2*r+0]=d[r].bb_b,s[2*r+1]=d[r].bb_t;s.sort(function(a,b){return a-b});var t=0.5*(s[f-1]+s[f]),r=h,s=k,u=m,v=n;g?u=h=t:v=k=t;for(var t=p,w=e;t>w;)g=d[w],(c(g.bb_r,m)-b(g.bb_l,h))*(c(g.bb_t,n)-b(g.bb_b,k))<(c(g.bb_r,u)-b(g.bb_l,r))*(c(g.bb_t,v)-b(g.bb_b,s))?(t--,d[w]=d[t],d[t]=g):w++;if(t==f){g=null;for(r=
e;p>r;r++)g=ma(g,d[r],a);return g}return NodeNew(a,Ga(a,d,e,t-e),Ga(a,d,t,p-t))};Z.prototype.optimize=function(){var a=Array(this.count),b=0,c;for(c in this.leaves)a[b++]=this.nodes[c];tree.subtreeRecycle(root);this.root=Ga(tree,a,a.length)};var Ha=function(a,b){!a.isLeaf&&10>=b&&(Ha(a.A,b+1),Ha(a.B,b+1));for(var c="",d=0;b>d;d++)c+=" ";console.log(c+a.bb_b+" "+a.bb_t)};Z.prototype.log=function(){this.root&&Ha(this.root,0)};var ka=a.CollisionHandler=function(){this.a=this.b=0};ka.prototype.begin=
function(a,b){return!0};ka.prototype.preSolve=function(a,b){return!0};ka.prototype.postSolve=function(a,b){};ka.prototype.separate=function(a,b){};var $=function(a,b){this.u=this.e=0;this.surface_vr=t;this.a=a;this.body_a=a.body;this.b=b;this.body_b=b.body;this.contacts=this.thread_b_next=this.thread_b_prev=this.thread_a_next=this.thread_a_prev=null;this.stamp=0;this.handler=null;this.swappedColl=!1;this.state="first coll"};$.prototype.getShapes=function(){return this.swappedColl?[this.b,this.a]:
[this.a,this.b]};$.prototype.totalImpulse=function(){for(var a=this.contacts,b=new u(0,0),c=0,d=a.length;d>c;c++){var e=a[c];b.add(E(e.n,e.jnAcc))}return this.swappedColl?b:b.neg()};$.prototype.totalImpulseWithFriction=function(){for(var a=this.contacts,b=new u(0,0),c=0,d=a.length;d>c;c++){var e=a[c];b.add((new u(e.jnAcc,e.jtAcc)).rotate(e.n))}return this.swappedColl?b:b.neg()};$.prototype.totalKE=function(){for(var a=(1-this.e)/(1+this.e),b=0,c=this.contacts,d=0,e=c.length;e>d;d++)var f=c[d],g=f.jnAcc,
h=f.jtAcc,b=b+(a*g*g/f.nMass+h*h/f.tMass);return b};$.prototype.ignore=function(){this.state="ignore"};$.prototype.getA=function(){return this.swappedColl?this.b:this.a};$.prototype.getB=function(){return this.swappedColl?this.a:this.b};$.prototype.isFirstContact=function(){return"first coll"===this.state};var Va=function(a,b,c){this.point=a;this.normal=b;this.dist=c};$.prototype.getContactPointSet=function(){var a,b=Array(this.contacts.length);for(a=0;a<b.length;a++)b[a]=new Va(this.contacts[a].p,
this.contacts[a].n,this.contacts[a].dist);return b};$.prototype.getNormal=function(a){a=this.contacts[a].n;return this.swappedColl?B(a):a};$.prototype.getPoint=function(a){return this.contacts[a].p};$.prototype.getDepth=function(a){return this.contacts[a].dist};var Ia=function(a,b,c,d){c?c.body_a===b?c.thread_a_next=d:c.thread_b_next=d:b.arbiterList=d;d&&(d.body_a===b?d.thread_a_prev=c:d.thread_b_prev=c)};$.prototype.unthread=function(){Ia(this,this.body_a,this.thread_a_prev,this.thread_a_next);Ia(this,
this.body_b,this.thread_b_prev,this.thread_b_next);this.thread_b_prev=this.thread_b_next=this.thread_a_prev=this.thread_a_next=null};$.prototype.update=function(a,b,c,d){if(this.contacts)for(var e=0;e<this.contacts.length;e++)for(var f=this.contacts[e],g=0;g<a.length;g++){var h=a[g];h.hash===f.hash&&(h.jnAcc=f.jnAcc,h.jtAcc=f.jtAcc)}this.contacts=a;this.handler=b;this.swappedColl=c.collision_type!==b.a;this.e=c.e*d.e;this.u=c.u*d.u;this.surface_vr=w(c.surface_v,d.surface_v);this.a=c;this.body_a=c.body;
this.b=d;this.body_b=d.body;"cached"==this.state&&(this.state="first coll")};$.prototype.preStep=function(a,c,d){for(var e=this.body_a,f=this.body_b,g=0;g<this.contacts.length;g++){var h=this.contacts[g];h.r1=w(h.p,e.p);h.r2=w(h.p,f.p);h.nMass=1/ab(e,f,h.r1,h.r2,h.n);h.tMass=1/ab(e,f,h.r1,h.r2,J(h.n));h.bias=-d*b(0,h.dist+c)/a;h.jBias=0;h.bounce=ya(e,f,h.r1,h.r2,h.n)*this.e}};$.prototype.applyCachedImpulse=function(a){if(!this.isFirstContact())for(var b=this.body_a,c=this.body_b,d=0;d<this.contacts.length;d++){var e=
this.contacts[d],f=e.n.x,g=e.n.y;ca(b,c,e.r1,e.r2,(f*e.jnAcc-g*e.jtAcc)*a,(f*e.jtAcc+g*e.jnAcc)*a)}};var Wa=0,Xa=0;$.prototype.applyImpulse=function(){Wa++;for(var a=this.body_a,b=this.body_b,d=this.surface_vr,e=this.u,f=0;f<this.contacts.length;f++){Xa++;var g=this.contacts[f],h=g.nMass,k=g.n,m=g.r1,n=g.r2,p=b.vx-n.y*b.w-(a.vx-m.y*a.w),r=b.vy+n.x*b.w-(a.vy+m.x*a.w),t=p*k.x+r*k.y,u=(p+d.x)*-k.y+(r+d.y)*k.x,r=g.jBias;g.jBias=c(r+(g.bias-(k.x*(b.v_biasx-n.y*b.w_bias-a.v_biasx+m.y*a.w_bias)+k.y*(n.x*
b.w_bias+b.v_biasy-m.x*a.w_bias-a.v_biasy)))*h,0);p=g.jnAcc;g.jnAcc=c(p+-(g.bounce+t)*h,0);t=e*g.jnAcc;h=g.jtAcc;g.jtAcc=s(h+-u*g.tMass,-t,t);t=k.x*(g.jBias-r);r=k.y*(g.jBias-r);nb(a,-t,-r,m);nb(b,t,r,n);p=g.jnAcc-p;g=g.jtAcc-h;ca(a,b,m,n,k.x*p-k.y*g,k.x*g+k.y*p)}};$.prototype.callSeparate=function(a){a.lookupHandler(this.a.collision_type,this.b.collision_type).separate(this,a)};$.prototype.next=function(a){return this.body_a==a?this.thread_a_next:this.thread_b_next};var Ya=0,ga=function(a,b,c,d){this.p=
a;this.n=b;this.dist=c;this.r1=this.r2=t;this.jnAcc=this.jtAcc=this.jBias=this.nMass=this.tMass=this.bounce=this.bias=0;this.hash=d;Ya++},ba=[],ia=function(a,b,c,d){d=c+d;b=w(b,a);var e=y(b);if(!(e>=d*d))return e=Math.sqrt(e),new ga(z(a,E(b,0.5+(c-0.5*d)/(e?e:1/0))),e?E(b,1/e):new u(1,0),e-d,0)},ua=0,Ja=function(a,b){var c=0,d=a.valueOnAxis(b[0].n,b[0].d);if(0<d)return-1;for(var e=1;e<b.length;e++){var f=a.valueOnAxis(b[e].n,b[e].d);if(0<f)return-1;f>d&&(d=f,c=e)}return ua=d,c},Za=function(a,b,c,
d){for(var e=[],f=a.tVerts,g=0;g<f.length;g+=2){var k=f[g],m=f[g+1];b.containsVert(k,m)&&e.push(new ga(new u(k,m),c,d,h(a.hashid,g>>1)))}f=b.tVerts;for(g=0;g<f.length;g+=2)k=f[g],m=f[g+1],a.containsVert(k,m)&&e.push(new ga(new u(k,m),c,d,h(b.hashid,g>>1)));if(!e.length){e=[];f=a.tVerts;for(g=0;g<f.length;g+=2)k=f[g],m=f[g+1],b.containsVertPartial(k,m,B(c))&&e.push(new ga(new u(k,m),c,d,h(a.hashid,g)));f=b.tVerts;for(g=0;g<f.length;g+=2)k=f[g],m=f[g+1],a.containsVertPartial(k,m,c)&&e.push(new ga(new u(k,
m),c,d,h(b.hashid,g)))}return a=e},Ka=function(a,c,d){var e=x(c,a.ta)-a.r;a=x(c,a.tb)-a.r;return b(e,a)-d},La=function(a,b,c,d,e){for(var f=I(b.tn,b.ta),g=I(b.tn,b.tb),k=E(b.tn,e),m=c.tVerts,n=0;n<m.length;n+=2){var p=m[n],r=m[n+1];if(p*k.x+r*k.y<x(b.tn,b.ta)*e+b.r){var s=b.tn.x*r-b.tn.y*p;f>=s&&s>=g&&a.push(new ga(new u(p,r),k,d,h(c.hashid,n)))}}};ja.prototype.collisionCode=0;ha.prototype.collisionCode=1;aa.prototype.collisionCode=2;ja.prototype.collisionTable=[function(a,b){var c=ia(a.tc,b.tc,a.r,
b.r);return c?[c]:ba},function(a,b){var c=b.ta,d=a.tc,e=w(b.tb,c),f=v(x(e,w(d,c))/y(e)),c=z(c,E(e,f));return(d=ia(d,c,a.r,b.r))?(c=d.n,0===f&&0>x(c,b.a_tangent)||1===f&&0>x(c,b.b_tangent)?ba:[d]):ba},function(a,b){for(var c=b.tPlanes,d=0,e=x(c[0].n,a.tc)-c[0].d-a.r,f=0;f<c.length;f++){var g=x(c[f].n,a.tc)-c[f].d-a.r;if(0<g)return ba;g>e&&(e=g,d=f)}var c=c[d].n,h=b.tVerts,k=h.length,m=d<<1,d=h[m],f=h[m+1],g=h[(m+2)%k],h=h[(m+3)%k],k=c.x*f-c.y*d,m=c.x*h-c.y*g,n=I(c,a.tc);if(m>n){var p=ia(a.tc,new u(g,
h),a.r,0,p);return p?[p]:ba}return k>n?[new ga(w(a.tc,E(c,a.r+e/2)),B(c),e,0)]:(p=ia(a.tc,new u(d,f),a.r,0,p))?[p]:ba}];ha.prototype.collisionTable=[null,function(a,b){return ba},function(a,b){var c=[],d=b.tPlanes,e=d.length,f=x(a.tn,a.ta),g=b.valueOnAxis(a.tn,f)-a.r,f=b.valueOnAxis(B(a.tn),-f)-a.r;if(0<f||0<g)return ba;var k=0,m=Ka(a,d[0].n,d[0].d);if(0<m)return ba;for(var n=0;e>n;n++){var p=Ka(a,d[n].n,d[n].d);if(0<p)return ba;p>m&&(m=p,k=n)}d=B(d[k].n);n=z(a.ta,E(d,a.r));p=z(a.tb,E(d,a.r));if(b.containsVert(n.x,
n.y)&&c.push(new ga(n,d,m,h(a.hashid,0))),b.containsVert(p.x,p.y)&&c.push(new ga(p,d,m,h(a.hashid,1))),(g>=m||f>=m)&&(g>f?La(c,a,b,g,1):La(c,a,b,f,-1)),0===c.length){f=2*k;k=b.tVerts;m=new u(k[f],k[f+1]);if((g=ia(a.ta,m,a.r,0,c))||(g=ia(a.tb,m,a.r,0,c)))return[g];e*=2;e=new u(k[(f+2)%e],k[(f+3)%e]);if((g=ia(a.ta,e,a.r,0,c))||(g=ia(a.tb,e,a.r,0,c)))return[g]}return c}];aa.prototype.collisionTable=[null,null,function(a,b){var c=Ja(b,a.tPlanes);if(-1==c)return ba;var d=ua,e=Ja(a,b.tPlanes);if(-1==e)return ba;
var f=ua;return d>f?Za(a,b,a.tPlanes[c].n,d):Za(a,b,B(b.tPlanes[e].n),f)}];var va=a.collideShapes=function(a,b){return d(a.collisionCode<=b.collisionCode,"Collided shapes must be sorted by type"),a.collisionTable[b.collisionCode](a,b)},Ma=new ka,Q=a.Space=function(){this.curr_dt=this.stamp=0;this.bodies=[];this.rousedBodies=[];this.sleepingComponents=[];this.staticShapes=new Z(null);this.activeShapes=new Z(this.staticShapes);this.arbiters=[];this.contactBuffersHead=null;this.cachedArbiters={};this.constraints=
[];this.locked=0;this.collisionHandlers={};this.defaultHandler=Ma;this.postStepCallbacks=[];this.iterations=10;this.gravity=t;this.damping=1;this.idleSpeedThreshold=0;this.sleepTimeThreshold=1/0;this.collisionSlop=0.1;this.collisionBias=Math.pow(0.9,60);this.collisionPersistence=3;this.enableContactGraph=!1;this.staticBody=new S(1/0,1/0);this.staticBody.nodeIdleTime=1/0;this.collideShapes=this.makeCollideShapes()};Q.prototype.getCurrentTimeStep=function(){return this.curr_dt};Q.prototype.setIterations=
function(a){this.iterations=a};Q.prototype.isLocked=function(){return this.locked};var ea=function(a){d(!a.locked,"This addition/removal cannot be done safely during a call to cpSpaceStep() \r\n or during a query. Put these calls into a post-step callback.")};Q.prototype.addCollisionHandler=function(a,b,c,d,e,f){ea(this);this.removeCollisionHandler(a,b);var g=new ka;g.a=a;g.b=b;c&&(g.begin=c);d&&(g.preSolve=d);e&&(g.postSolve=e);f&&(g.separate=f);this.collisionHandlers[h(a,b)]=g};Q.prototype.removeCollisionHandler=
function(a,b){ea(this);delete this.collisionHandlers[h(a,b)]};Q.prototype.setDefaultCollisionHandler=function(a,b,c,d){ea(this);var e=new ka;a&&(e.begin=a);b&&(e.preSolve=b);c&&(e.postSolve=c);d&&(e.separate=d);this.defaultHandler=e};Q.prototype.lookupHandler=function(a,b){return this.collisionHandlers[h(a,b)]||this.defaultHandler};Q.prototype.addShape=function(a){var b=a.body;return b.isStatic()?this.addStaticShape(a):(d(!a.space,"This shape is already added to a space and cannot be added to another."),
ea(this),b.activate(),b.addShape(a),a.update(b.p,b.rot),this.activeShapes.insert(a,a.hashid),a.space=this,a)};Q.prototype.addStaticShape=function(a){d(!a.space,"This shape is already added to a space and cannot be added to another.");ea(this);var b=a.body;return b.addShape(a),a.update(b.p,b.rot),this.staticShapes.insert(a,a.hashid),a.space=this,a};Q.prototype.addBody=function(a){return d(!a.isStatic(),"Static bodies cannot be added to a space as they are not meant to be simulated."),d(!a.space,"This body is already added to a space and cannot be added to another."),
ea(this),this.bodies.push(a),a.space=this,a};Q.prototype.addConstraint=function(a){d(!a.space,"This shape is already added to a space and cannot be added to another.");ea(this);var b=a.a,c=a.b;return b.activate(),c.activate(),this.constraints.push(a),a.next_a=b.constraintList,b.constraintList=a,a.next_b=c.constraintList,c.constraintList=a,a.space=this,a};Q.prototype.filterArbiters=function(a,b){for(var c in this.cachedArbiters){var d=this.cachedArbiters[c];(a===d.body_a&&(b===d.a||null===b)||a===
d.body_b&&(b===d.b||null===b))&&(b&&"cached"!==d.state&&d.callSeparate(this),d.unthread(),k(this.arbiters,d),delete this.cachedArbiters[c])}};Q.prototype.removeShape=function(a){var b=a.body;b.isStatic()?this.removeStaticShape(a):(d(this.containsShape(a),"Cannot remove a shape that was not added to the space. (Removed twice maybe?)"),ea(this),b.activate(),b.removeShape(a),this.filterArbiters(b,a),this.activeShapes.remove(a,a.hashid),a.space=null)};Q.prototype.removeStaticShape=function(a){d(this.containsShape(a),
"Cannot remove a static or sleeping shape that was not added to the space. (Removed twice maybe?)");ea(this);var b=a.body;b.isStatic()&&b.activateStatic(a);b.removeShape(a);this.filterArbiters(b,a);this.staticShapes.remove(a,a.hashid);a.space=null};Q.prototype.removeBody=function(a){d(this.containsBody(a),"Cannot remove a body that was not added to the space. (Removed twice maybe?)");ea(this);a.activate();k(this.bodies,a);a.space=null};Q.prototype.removeConstraint=function(a){d(this.containsConstraint(a),
"Cannot remove a constraint that was not added to the space. (Removed twice maybe?)");ea(this);a.a.activate();a.b.activate();k(this.constraints,a);a.a.removeConstraint(a);a.b.removeConstraint(a);a.space=null};Q.prototype.containsShape=function(a){return a.space===this};Q.prototype.containsBody=function(a){return a.space==this};Q.prototype.containsConstraint=function(a){return a.space==this};Q.prototype.uncacheArbiter=function(a){delete this.cachedArbiters[h(a.a.hashid,a.b.hashid)];k(this.arbiters,
a)};Q.prototype.eachBody=function(a){this.lock();for(var b=this.bodies,c=0;c<b.length;c++)a(b[c]);b=this.sleepingComponents;for(c=0;c<b.length;c++)for(var d=b[c];d;){var e=d.nodeNext;a(d);d=e}this.unlock(!0)};Q.prototype.eachShape=function(a){this.lock();this.activeShapes.each(a);this.staticShapes.each(a);this.unlock(!0)};Q.prototype.eachConstraint=function(a){this.lock();for(var b=this.constraints,c=0;c<b.length;c++)a(b[c]);this.unlock(!0)};Q.prototype.reindexStatic=function(){d(!this.locked,"You cannot manually reindex objects while the space is locked. Wait until the current query or step is complete.");
this.staticShapes.each(function(a){var b=a.body;a.update(b.p,b.rot)});this.staticShapes.reindex()};Q.prototype.reindexShape=function(a){d(!this.locked,"You cannot manually reindex objects while the space is locked. Wait until the current query or step is complete.");var b=a.body;a.update(b.p,b.rot);this.activeShapes.reindexObject(a,a.hashid);this.staticShapes.reindexObject(a,a.hashid)};Q.prototype.reindexShapesForBody=function(a){for(a=a.shapeList;a;a=a.next)this.reindexShape(a)};Q.prototype.useSpatialHash=
function(a,b){throw Error("Spatial Hash not implemented.");};Q.prototype.activateBody=function(a){if(d(!a.isRogue(),"Internal error: Attempting to activate a rogue body."),this.locked)-1===this.rousedBodies.indexOf(a)&&this.rousedBodies.push(a);else{this.bodies.push(a);for(var b=0;b<a.shapeList.length;b++){var c=a.shapeList[b];this.staticShapes.remove(c,c.hashid);this.activeShapes.insert(c,c.hashid)}for(b=a.arbiterList;b;b=b.next(a))if(c=b.body_a,a===c||c.isStatic()){var c=b.a,e=b.b;this.cachedArbiters[h(c.hashid,
e.hashid)]=b;b.stamp=this.stamp;b.handler=this.lookupHandler(c.collision_type,e.collision_type);this.arbiters.push(b)}for(b=a.constraintList;b;b=b.nodeNext)c=b.a,(a===c||c.isStatic())&&this.constraints.push(b)}};Q.prototype.deactivateBody=function(a){d(!a.isRogue(),"Internal error: Attempting to deactivate a rogue body.");k(this.bodies,a);for(var b=0;b<a.shapeList.length;b++){var c=a.shapeList[b];this.activeShapes.remove(c,c.hashid);this.staticShapes.insert(c,c.hashid)}for(c=a.arbiterList;c;c=c.next(a))b=
c.body_a,(a===b||b.isStatic())&&this.uncacheArbiter(c);for(c=a.constraintList;c;c=c.nodeNext)b=c.a,(a===b||b.isStatic())&&k(this.constraints,c)};S.prototype.activate=function(){if(!this.isRogue()){this.nodeIdleTime=0;var a=this?this.nodeRoot:null;if(a&&a.isSleeping(a)){d(!a.isRogue(),"Internal Error: componentActivate() called on a rogue body.");for(var b=a.space,c=a;c;){var e=c.nodeNext;c.nodeIdleTime=0;c.nodeRoot=null;c.nodeNext=null;b.activateBody(c);c=e}k(b.sleepingComponents,a)}}};S.prototype.activateStatic=
function(a){d(this.isStatic(),"Body.activateStatic() called on a non-static body.");for(var b=this.arbiterList;b;b=b.next(this))a&&a!=b.a&&a!=b.b||(b.body_a==this?b.body_b:b.body_a).activate()};S.prototype.pushArbiter=function(a){e(null===(a.body_a===this?a.thread_a_next:a.thread_b_next),"Internal Error: Dangling contact graph pointers detected. (A)");e(null===(a.body_a===this?a.thread_a_prev:a.thread_b_prev),"Internal Error: Dangling contact graph pointers detected. (B)");var b=this.arbiterList;
e(null===b||null===(b.body_a===this?b.thread_a_prev:b.thread_b_prev),"Internal Error: Dangling contact graph pointers detected. (C)");a.body_a===this?a.thread_a_next=b:a.thread_b_next=b;b&&(b.body_a===this?b.thread_a_prev=a:b.thread_b_prev=a);this.arbiterList=a};var wa=function(a,b){if(!b.isRogue()){var c=b?b.nodeRoot:null;if(null==c){b.nodeRoot=a;b!==a&&(b.nodeNext=a.nodeNext,a.nodeNext=b);for(c=b.arbiterList;c;c=c.next(b))wa(a,b==c.body_a?c.body_b:c.body_a);for(c=b.constraintList;c;c=c.next(b))wa(a,
b==c.a?c.b:c.a)}else e(c===a,"Internal Error: Inconsistency detected in the contact graph.")}};Q.prototype.processComponents=function(a){for(var b=this.sleepTimeThreshold!==1/0,c=this.bodies,d=0;d<c.length;d++){var f=c[d];e(null===f.nodeNext,"Internal Error: Dangling next pointer detected in contact graph.");e(null===f.nodeRoot,"Internal Error: Dangling root pointer detected in contact graph.")}if(b)for(var g=(d=this.idleSpeedThreshold)?d*d:y(this.gravity)*a*a,d=0;d<c.length;d++){var f=c[d],h=g?f.m*
g:0;f.nodeIdleTime=f.kineticEnergy()>h?0:f.nodeIdleTime+a}g=this.arbiters;d=0;for(h=g.length;h>d;d++){var k=g[d],f=k.body_a;a=k.body_b;b&&((a.isRogue()&&!a.isStatic()||f.isSleeping())&&f.activate(),(f.isRogue()&&!f.isStatic()||a.isSleeping())&&a.activate());f.pushArbiter(k);a.pushArbiter(k)}if(b){b=this.constraints;for(d=0;d<b.length;d++)a=b[d],f=a.a,a=a.b,a.isRogue()&&!a.isStatic()&&f.activate(),f.isRogue()&&!f.isStatic()&&a.activate();for(d=0;d<c.length;){f=c[d];if(!(b=null!==(f?f.nodeRoot:null))){wa(f,
f);a:{for(b=f;b;b=b.nodeNext)if(b.nodeIdleTime<this.sleepTimeThreshold){b=!0;break a}b=!1}}if(b)d++,f.nodeRoot=null,f.nodeNext=null;else{this.sleepingComponents.push(f);for(b=f;b;b=b.nodeNext)this.deactivateBody(b)}}}};S.prototype.sleep=function(){this.sleepWithGroup(null)};S.prototype.sleepWithGroup=function(a){d(!this.isStatic()&&!this.isRogue(),"Rogue and static bodies cannot be put to sleep.");var b=this.space;if(d(b,"Cannot put a rogue body to sleep."),d(!b.locked,"Bodies cannot be put to sleep during a query or a call to cpSpaceStep(). Put these calls into a post-step callback."),
d(null===a||a.isSleeping(),"Cannot use a non-sleeping body as a group identifier."),this.isSleeping())return void d((this?this.nodeRoot:null)===(a?a.nodeRoot:null),"The body is already sleeping and it's group cannot be reassigned.");for(var c=0;c<this.shapeList.length;c++)this.shapeList[c].update(this.p,this.rot);(b.deactivateBody(this),a)?(this.nodeRoot=a=a?a.nodeRoot:null,this.nodeNext=a.nodeNext,this.nodeIdleTime=0,a.nodeNext=this):(this.nodeRoot=this,this.nodeNext=null,this.nodeIdleTime=0,b.sleepingComponents.push(this));
k(b.bodies,this)};Q.prototype.activateShapesTouchingShape=function(a){this.sleepTimeThreshold!==1/0&&this.shapeQuery(a,function(a,b){a.body.activate()})};Q.prototype.pointQuery=function(a,b,c,d){var e=function(e){(!e.group||c!==e.group)&&b&e.layers&&e.pointQuery(a)&&d(e)},f=new R(a.x,a.y,a.x,a.y);this.lock();this.activeShapes.query(f,e);this.staticShapes.query(f,e);this.unlock(!0)};Q.prototype.pointQueryFirst=function(a,b,c){var d=null;return this.pointQuery(a,b,c,function(a){a.sensor||(d=a)}),d};
Q.prototype.nearestPointQuery=function(a,b,c,d,e){var f=function(f){if((!f.group||d!==f.group)&&c&f.layers){var g=f.nearestPointQuery(a);g.d<b&&e(f,g.d,g.p)}},g=new R(a.x-b,a.y-b,a.x+b,a.y+b);this.lock();this.activeShapes.query(g,f);this.staticShapes.query(g,f);this.unlock(!0)};Q.prototype.nearestPointQueryNearest=function(a,b,c,d){var e,f=function(f){if((!f.group||d!==f.group)&&c&f.layers&&!f.sensor)f=f.nearestPointQuery(a),f.d<b&&(!e||f.d<e.d)&&(e=f)},g=new R(a.x-b,a.y-b,a.x+b,a.y+b);return this.activeShapes.query(g,
f),this.staticShapes.query(g,f),e};Q.prototype.segmentQuery=function(a,b,c,d,e){var f=function(f){var g;return(!f.group||d!==f.group)&&c&f.layers&&(g=f.segmentQuery(a,b))&&e(f,g.t,g.n),1};this.lock();this.staticShapes.segmentQuery(a,b,1,f);this.activeShapes.segmentQuery(a,b,1,f);this.unlock(!0)};Q.prototype.segmentQueryFirst=function(a,b,c,d){var e=null,f=function(f){var g;return(!f.group||d!==f.group)&&c&f.layers&&!f.sensor&&(g=f.segmentQuery(a,b))&&(null===e||g.t<e.t)&&(e=g),e?e.t:1};return this.staticShapes.segmentQuery(a,
b,1,f),this.activeShapes.segmentQuery(a,b,e?e.t:1,f),e};Q.prototype.bbQuery=function(a,b,c,d){var e=function(e){(!e.group||c!==e.group)&&b&e.layers&&a.l<=e.bb_r&&(e.bb_l<=a.r&&a.b<=e.bb_t&&e.bb_b<=a.t)&&d(e)};this.lock();this.activeShapes.query(a,e);this.staticShapes.query(a,e);this.unlock(!0)};Q.prototype.shapeQuery=function(a,b){var c=a.body;c&&a.update(c.p,c.rot);var c=new R(a.bb_l,a.bb_b,a.bb_r,a.bb_t),d=!1,e=function(c){if((!a.group||a.group!==c.group)&&a.layers&c.layers&&a!==c){var e;if(a.collisionCode<=
c.collisionCode)e=va(a,c);else{e=va(c,a);for(var f=0;f<e.length;f++)e[f].n=B(e[f].n)}if(e.length&&(d=!(a.sensor||c.sensor),b)){for(var g=Array(e.length),f=0;f<e.length;f++)g[f]=new Va(e[f].p,e[f].n,e[f].dist);b(c,g)}}};return this.lock(),this.activeShapes.query(c,e),this.staticShapes.query(c,e),this.unlock(!0),d};Q.prototype.addPostStepCallback=function(a){e(this.locked,"Adding a post-step callback when the space is not locked is unnecessary. Post-step callbacks will not called until the end of the next call to cpSpaceStep() or the next query.");
this.postStepCallbacks.push(a)};Q.prototype.runPostStepCallbacks=function(){for(var a=0;a<this.postStepCallbacks.length;a++)this.postStepCallbacks[a]();this.postStepCallbacks=[]};Q.prototype.lock=function(){this.locked++};Q.prototype.unlock=function(a){if(this.locked--,d(0<=this.locked,"Internal Error: Space lock underflow."),0===this.locked&&a){a=this.rousedBodies;for(var b=0;b<a.length;b++)this.activateBody(a[b]);a.length=0;this.runPostStepCallbacks()}};Q.prototype.makeCollideShapes=function(){var a=
this;return function(b,c){if(b.bb_l<=c.bb_r&&c.bb_l<=b.bb_r&&b.bb_b<=c.bb_t&&c.bb_b<=b.bb_t&&b.body!==c.body&&(!b.group||b.group!==c.group)&&b.layers&c.layers){var d=a.lookupHandler(b.collision_type,c.collision_type),e=b.sensor||c.sensor;if(!e||d!==Ma){if(b.collisionCode>c.collisionCode){var f=b;b=c;c=f}f=va(b,c);if(0!==f.length){var g=h(b.hashid,c.hashid),k=a.cachedArbiters[g];k||(k=a.cachedArbiters[g]=new $(b,c));k.update(f,d,b,c);"first coll"!=k.state||d.begin(k,a)||k.ignore();"ignore"!==k.state&&
d.preSolve(k,a)&&!e?a.arbiters.push(k):(k.contacts=null,"ignore"!==k.state&&(k.state="normal"));k.stamp=a.stamp}}}}};Q.prototype.arbiterSetFilter=function(a){var b=this.stamp-a.stamp,c=a.body_a,d=a.body_b;return(c.isStatic()||c.isSleeping())&&(d.isStatic()||d.isSleeping())?!0:(1<=b&&"cached"!=a.state&&(a.callSeparate(this),a.state="cached"),b>=this.collisionPersistence?(a.contacts=null,!1):!0)};var $a=function(a){var b=a.body;a.update(b.p,b.rot)};Q.prototype.step=function(a){if(0!==a){d(0===t.x&&
0===t.y,"vzero is invalid");this.stamp++;var b=this.curr_dt;this.curr_dt=a;var c,e,f=this.bodies,g=this.constraints,h=this.arbiters;for(c=0;c<h.length;c++){var k=h[c];k.state="normal";k.body_a.isSleeping()||k.body_b.isSleeping()||k.unthread()}h.length=0;this.lock();for(c=0;c<f.length;c++)f[c].position_func(a);this.activeShapes.each($a);this.activeShapes.reindexQuery(this.collideShapes);this.unlock(!1);this.processComponents(a);this.lock();for(e in this.cachedArbiters)this.arbiterSetFilter(this.cachedArbiters[e])||
delete this.cachedArbiters[e];e=this.collisionSlop;k=1-Math.pow(this.collisionBias,a);for(c=0;c<h.length;c++)h[c].preStep(a,e,k);for(c=0;c<g.length;c++)e=g[c],e.preSolve(this),e.preStep(a);e=Math.pow(this.damping,a);k=this.gravity;for(c=0;c<f.length;c++)f[c].velocity_func(k,e,a);a=0===b?0:a/b;for(c=0;c<h.length;c++)h[c].applyCachedImpulse(a);for(c=0;c<g.length;c++)g[c].applyCachedImpulse(a);for(c=0;c<this.iterations;c++){for(a=0;a<h.length;a++)h[a].applyImpulse();for(a=0;a<g.length;a++)g[a].applyImpulse()}for(c=
0;c<g.length;c++)g[c].postSolve(this);for(c=0;c<h.length;c++)h[c].handler.postSolve(h[c],this);this.unlock(!0)}};var xa=function(a,b,c,d){return new u(b.vx+-d.y*b.w-(a.vx+-c.y*a.w),b.vy+d.x*b.w-(a.vy+c.x*a.w))},ya=function(a,b,c,d,e){return(b.vx+-d.y*b.w-(a.vx+-c.y*a.w))*e.x+(b.vy+d.x*b.w-(a.vy+c.x*a.w))*e.y},za=function(a,b,c,d){a.vx+=b*a.m_inv;a.vy+=c*a.m_inv;a.w+=a.i_inv*(d.x*c-d.y*b)},ca=function(a,b,c,d,e,f){za(a,-e,-f,c);za(b,e,f,d)},nb=function(a,b,c,d){a.v_biasx+=b*a.m_inv;a.v_biasy+=c*a.m_inv;
a.w_bias+=a.i_inv*(d.x*c-d.y*b)},ob=function(a,b,c){b=I(b,c);return a.m_inv+a.i_inv*b*b},ab=function(a,b,c,d,f){a=ob(a,c,f)+ob(b,d,f);return e(0!==a,"Unsolvable collision or constraint."),a},pb=function(a,b,c,d,f,g){var h;h=a.m_inv+b.m_inv;var k=a.i_inv,m=c.x*c.x*k;a=-c.x*c.y*k;c=h+c.y*c.y*k;h+=m;k=b.i_inv;b=d.x*d.x*k;m=-d.x*d.y*k;c+=d.y*d.y*k;d=0+a+m;a=0+a+m;h+=b;b=c*h-d*a;e(0!==b,"Unsolvable constraint.");b=1/b;f.x=h*b;f.y=-d*b;g.x=-a*b;g.y=c*b},X=a.Constraint=function(a,b){this.a=a;this.b=b;this.next_b=
this.next_a=this.space=null;this.maxForce=1/0;this.errorBias=Math.pow(0.9,60);this.maxBias=1/0};X.prototype.activateBodies=function(){this.a&&this.a.activate();this.b&&this.b.activate()};X.prototype.preStep=function(a){};X.prototype.applyCachedImpulse=function(a){};X.prototype.applyImpulse=function(){};X.prototype.getImpulse=function(){return 0};X.prototype.preSolve=function(a){};X.prototype.postSolve=function(a){};X.prototype.next=function(a){return this.a===a?this.next_a:this.next_b};var bb=a.PinJoint=
function(a,b,c,d){X.call(this,a,b);this.anchr1=c;this.anchr2=d;a=a?z(a.p,L(c,a.rot)):c;b=b?z(b.p,L(d,b.rot)):d;this.dist=A(w(b,a));e(0<this.dist,"You created a 0 length pin joint. A pivot joint will be much more stable.");this.n=this.r1=this.r2=null;this.bias=this.jnAcc=this.jnMax=this.nMass=0};bb.prototype=Object.create(X.prototype);bb.prototype.preStep=function(a){var b=this.a,c=this.b;this.r1=L(this.anchr1,b.rot);this.r2=L(this.anchr2,c.rot);var d=w(z(c.p,this.r2),z(b.p,this.r1)),e=A(d);this.n=
E(d,1/(e?e:1/0));this.nMass=1/ab(b,c,this.r1,this.r2,this.n);b=this.maxBias;this.bias=s(-(1-Math.pow(this.errorBias,a))*(e-this.dist)/a,-b,b);this.jnMax=this.maxForce*a};bb.prototype.applyCachedImpulse=function(a){a=E(this.n,this.jnAcc*a);ca(this.a,this.b,this.r1,this.r2,a.x,a.y)};bb.prototype.applyImpulse=function(){var a=this.a,b=this.b,c=this.n,d=ya(a,b,this.r1,this.r2,c),d=(this.bias-d)*this.nMass,e=this.jnAcc;this.jnAcc=s(e+d,-this.jnMax,this.jnMax);d=this.jnAcc-e;ca(a,b,this.r1,this.r2,c.x*
d,c.y*d)};bb.prototype.getImpulse=function(){return Math.abs(this.jnAcc)};var cb=a.SlideJoint=function(a,b,c,d,e,f){X.call(this,a,b);this.anchr1=c;this.anchr2=d;this.min=e;this.max=f;this.r1=this.r2=this.n=null;this.bias=this.jnAcc=this.jnMax=this.nMass=0};cb.prototype=Object.create(X.prototype);cb.prototype.preStep=function(a){var b=this.a,c=this.b;this.r1=L(this.anchr1,b.rot);this.r2=L(this.anchr2,c.rot);var d=w(z(c.p,this.r2),z(b.p,this.r1)),e=A(d),f=0;e>this.max?(f=e-this.max,this.n=W(d)):e<this.min?
(f=this.min-e,this.n=B(W(d))):(this.n=t,this.jnAcc=0);this.nMass=1/ab(b,c,this.r1,this.r2,this.n);b=this.maxBias;this.bias=s(-(1-Math.pow(this.errorBias,a))*f/a,-b,b);this.jnMax=this.maxForce*a};cb.prototype.applyCachedImpulse=function(a){a*=this.jnAcc;ca(this.a,this.b,this.r1,this.r2,this.n.x*a,this.n.y*a)};cb.prototype.applyImpulse=function(){if(0!==this.n.x||0!==this.n.y){var a=this.a,b=this.b,c=this.n,d=xa(a,b,this.r1,this.r2),d=x(d,c),d=(this.bias-d)*this.nMass,e=this.jnAcc;this.jnAcc=s(e+d,
-this.jnMax,0);d=this.jnAcc-e;ca(a,b,this.r1,this.r2,c.x*d,c.y*d)}};cb.prototype.getImpulse=function(){return Math.abs(this.jnAcc)};var db=a.PivotJoint=function(a,b,c,d){if(X.call(this,a,b),"undefined"==typeof d)d=c,c=a?a.world2Local(d):d,d=b?b.world2Local(d):d;this.anchr1=c;this.anchr2=d;this.r1=this.r2=t;this.k1=new u(0,0);this.k2=new u(0,0);this.jAcc=t;this.jMaxLen=0;this.bias=t};db.prototype=Object.create(X.prototype);db.prototype.preStep=function(a){var b=this.a,c=this.b;this.r1=L(this.anchr1,
b.rot);this.r2=L(this.anchr2,c.rot);pb(b,c,this.r1,this.r2,this.k1,this.k2);this.jMaxLen=this.maxForce*a;b=w(z(c.p,this.r2),z(b.p,this.r1));this.bias=U(E(b,-(1-Math.pow(this.errorBias,a))/a),this.maxBias)};db.prototype.applyCachedImpulse=function(a){ca(this.a,this.b,this.r1,this.r2,this.jAcc.x*a,this.jAcc.y*a)};db.prototype.applyImpulse=function(){var a=this.a,b=this.b,c=xa(a,b,this.r1,this.r2),c=w(this.bias,c),d=this.k2,c=new u(x(c,this.k1),x(c,d)),d=this.jAcc;this.jAcc=U(z(this.jAcc,c),this.jMaxLen);
ca(a,b,this.r1,this.r2,this.jAcc.x-d.x,this.jAcc.y-d.y)};db.prototype.getImpulse=function(){return A(this.jAcc)};var oa=a.GrooveJoint=function(a,b,c,d,e){X.call(this,a,b);this.grv_a=c;this.grv_b=d;this.grv_n=J(N(w(d,c)));this.anchr2=e;this.grv_tn=null;this.clamp=0;this.r1=this.r2=null;this.k1=new u(0,0);this.k2=new u(0,0);this.jAcc=t;this.jMaxLen=0;this.bias=null};oa.prototype=Object.create(X.prototype);oa.prototype.preStep=function(a){var b=this.a,c=this.b,d=b.local2World(this.grv_a),e=b.local2World(this.grv_b),
f=L(this.grv_n,b.rot),g=x(d,f);this.grv_tn=f;this.r2=L(this.anchr2,c.rot);var h=I(z(c.p,this.r2),f);h<=I(d,f)?(this.clamp=1,this.r1=w(d,b.p)):h>=I(e,f)?(this.clamp=-1,this.r1=w(e,b.p)):(this.clamp=0,this.r1=w(z(E(J(f),-h),E(f,g)),b.p));pb(b,c,this.r1,this.r2,this.k1,this.k2);this.jMaxLen=this.maxForce*a;b=w(z(c.p,this.r2),z(b.p,this.r1));this.bias=U(E(b,-(1-Math.pow(this.errorBias,a))/a),this.maxBias)};oa.prototype.applyCachedImpulse=function(a){ca(this.a,this.b,this.r1,this.r2,this.jAcc.x*a,this.jAcc.y*
a)};oa.prototype.grooveConstrain=function(a){var b=this.grv_tn;a=0<this.clamp*I(a,b)?a:O(a,b);return U(a,this.jMaxLen)};oa.prototype.applyImpulse=function(){var a=this.a,b=this.b,c=xa(a,b,this.r1,this.r2),c=w(this.bias,c),d=this.k2,c=new u(x(c,this.k1),x(c,d)),d=this.jAcc;this.jAcc=this.grooveConstrain(z(d,c));ca(a,b,this.r1,this.r2,this.jAcc.x-d.x,this.jAcc.y-d.y)};oa.prototype.getImpulse=function(){return A(this.jAcc)};oa.prototype.setGrooveA=function(a){this.grv_a=a;this.grv_n=J(N(w(this.grv_b,
a)));this.activateBodies()};oa.prototype.setGrooveB=function(a){this.grv_b=a;this.grv_n=J(N(w(a,this.grv_a)));this.activateBodies()};var qb=function(a,b){return(a.restLength-b)*a.stiffness},eb=a.DampedSpring=function(a,b,c,d,e,f,g){X.call(this,a,b);this.anchr1=c;this.anchr2=d;this.restLength=e;this.stiffness=f;this.damping=g;this.springForceFunc=qb;this.target_vrn=this.v_coef=0;this.r1=this.r2=null;this.nMass=0;this.n=null};eb.prototype=Object.create(X.prototype);eb.prototype.preStep=function(a){var b=
this.a,c=this.b;this.r1=L(this.anchr1,b.rot);this.r2=L(this.anchr2,c.rot);var d=w(z(c.p,this.r2),z(b.p,this.r1)),f=A(d);this.n=E(d,1/(f?f:1/0));d=ab(b,c,this.r1,this.r2,this.n);e(0!==d,"Unsolvable this.");this.nMass=1/d;this.target_vrn=0;this.v_coef=1-Math.exp(-this.damping*a*d);f=this.springForceFunc(this,f);ca(b,c,this.r1,this.r2,this.n.x*f*a,this.n.y*f*a)};eb.prototype.applyCachedImpulse=function(a){};eb.prototype.applyImpulse=function(){var a=this.a,b=this.b,c=ya(a,b,this.r1,this.r2,this.n),d=
(this.target_vrn-c)*this.v_coef;this.target_vrn=c+d;d*=this.nMass;ca(a,b,this.r1,this.r2,this.n.x*d,this.n.y*d)};eb.prototype.getImpulse=function(){return 0};var rb=function(a,b){return(b-a.restAngle)*a.stiffness},mb=a.DampedRotarySpring=function(a,b,c,d,e){X.call(this,a,b);this.restAngle=c;this.stiffness=d;this.damping=e;this.springTorqueFunc=rb;this.iSum=this.w_coef=this.target_wrn=0};mb.prototype=Object.create(X.prototype);mb.prototype.preStep=function(a){var b=this.a,c=this.b,d=b.i_inv+c.i_inv;
e(0!==d,"Unsolvable spring.");this.iSum=1/d;this.w_coef=1-Math.exp(-this.damping*a*d);this.target_wrn=0;a*=this.springTorqueFunc(this,b.a-c.a);b.w-=a*b.i_inv;c.w+=a*c.i_inv};mb.prototype.applyImpulse=function(){var a=this.a,b=this.b,c=a.w-b.w,d=(this.target_wrn-c)*this.w_coef;this.target_wrn=c+d;c=d*this.iSum;a.w+=c*a.i_inv;b.w-=c*b.i_inv};var fb=a.RotaryLimitJoint=function(a,b,c,d){X.call(this,a,b);this.min=c;this.max=d;this.iSum=this.bias=this.jMax=this.jAcc=0};fb.prototype=Object.create(X.prototype);
fb.prototype.preStep=function(a){var b=this.a,c=this.b,d=c.a-b.a,e=0;d>this.max?e=this.max-d:d<this.min&&(e=this.min-d);this.iSum=1/(1/b.i+1/c.i);b=this.maxBias;this.bias=s(-(1-Math.pow(this.errorBias,a))*e/a,-b,b);this.jMax=this.maxForce*a;this.bias||(this.jAcc=0)};fb.prototype.applyCachedImpulse=function(a){var b=this.a,c=this.b;a*=this.jAcc;b.w-=a*b.i_inv;c.w+=a*c.i_inv};fb.prototype.applyImpulse=function(){if(this.bias){var a=this.a,b=this.b,c=-(this.bias+(b.w-a.w))*this.iSum,d=this.jAcc;0>this.bias?
this.jAcc=s(d+c,0,this.jMax):this.jAcc=s(d+c,-this.jMax,0);c=this.jAcc-d;a.w-=c*a.i_inv;b.w+=c*b.i_inv}};fb.prototype.getImpulse=function(){return Math.abs(joint.jAcc)};var gb=a.RatchetJoint=function(a,b,c,d){X.call(this,a,b);this.angle=0;this.phase=c;this.ratchet=d;this.angle=(b?b.a:0)-(a?a.a:0);this.iSum=this.bias=this.jAcc=this.jMax=0};gb.prototype=Object.create(X.prototype);gb.prototype.preStep=function(a){var b=this.a,c=this.b,d=this.phase,e=this.ratchet,f=c.a-b.a,g=this.angle-f,h=0;0<g*e?h=
g:this.angle=Math.floor((f-d)/e)*e+d;this.iSum=1/(b.i_inv+c.i_inv);b=this.maxBias;this.bias=s(-(1-Math.pow(this.errorBias,a))*h/a,-b,b);this.jMax=this.maxForce*a;this.bias||(this.jAcc=0)};gb.prototype.applyCachedImpulse=function(a){var b=this.a,c=this.b;a*=this.jAcc;b.w-=a*b.i_inv;c.w+=a*c.i_inv};gb.prototype.applyImpulse=function(){if(this.bias){var a=this.a,b=this.b,c=this.ratchet,d=-(this.bias+(b.w-a.w))*this.iSum,e=this.jAcc;this.jAcc=s((e+d)*c,0,this.jMax*Math.abs(c))/c;d=this.jAcc-e;a.w-=d*
a.i_inv;b.w+=d*b.i_inv}};gb.prototype.getImpulse=function(a){return Math.abs(a.jAcc)};var Na=a.GearJoint=function(a,b,c,d){X.call(this,a,b);this.phase=c;this.ratio=d;this.ratio_inv=1/d;this.iSum=this.bias=this.jMax=this.jAcc=0};Na.prototype=Object.create(X.prototype);Na.prototype.preStep=function(a){var b=this.a,c=this.b;this.iSum=1/(b.i_inv*this.ratio_inv+this.ratio*c.i_inv);var d=this.maxBias;this.bias=s(-(1-Math.pow(this.errorBias,a))*(c.a*this.ratio-b.a-this.phase)/a,-d,d);this.jMax=this.maxForce*
a};Na.prototype.applyCachedImpulse=function(a){var b=this.a,c=this.b;a*=this.jAcc;b.w-=a*b.i_inv*this.ratio_inv;c.w+=a*c.i_inv};Na.prototype.applyImpulse=function(){var a=this.a,b=this.b,c=(this.bias-(b.w*this.ratio-a.w))*this.iSum,d=this.jAcc;this.jAcc=s(d+c,-this.jMax,this.jMax);c=this.jAcc-d;a.w-=c*a.i_inv*this.ratio_inv;b.w+=c*b.i_inv};Na.prototype.getImpulse=function(){return Math.abs(this.jAcc)};Na.prototype.setRatio=function(a){this.ratio=a;this.ratio_inv=1/a;this.activateBodies()};var hb=
a.SimpleMotor=function(a,b,c){X.call(this,a,b);this.rate=c;this.iSum=this.jMax=this.jAcc=0};hb.prototype=Object.create(X.prototype);hb.prototype.preStep=function(a){this.iSum=1/(this.a.i_inv+this.b.i_inv);this.jMax=this.maxForce*a};hb.prototype.applyCachedImpulse=function(a){var b=this.a,c=this.b;a*=this.jAcc;b.w-=a*b.i_inv;c.w+=a*c.i_inv};hb.prototype.applyImpulse=function(){var a=this.a,b=this.b,c=-(b.w-a.w+this.rate)*this.iSum,d=this.jAcc;this.jAcc=s(d+c,-this.jMax,this.jMax);c=this.jAcc-d;a.w-=
c*a.i_inv;b.w+=c*b.i_inv};hb.prototype.getImpulse=function(){return Math.abs(this.jAcc)}}();var sp=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.Skeleton=cc.Node.extend({_skeleton:null,_rootBone:null,_timeScale:1,_debugSlots:!1,_debugBones:!1,_premultipliedAlpha:!1,_ownsSkeletonData:null,_atlas:null,_blendFunc:null,ctor:function(a,b,c){cc.Node.prototype.ctor.call(this);this._blendFunc={src:cc.BLEND_SRC,dst:cc.BLEND_DST};0===arguments.length?this.init():this.initWithArgs(a,b,c)},_createRenderCmd:function(){return cc._renderType===cc._RENDER_TYPE_CANVAS?new sp.Skeleton.CanvasRenderCmd(this):new sp.Skeleton.WebGLRenderCmd(this)},init:function(){cc.Node.prototype.init.call(this);
this._blendFunc.src=cc.ONE;this._blendFunc.dst=cc.ONE_MINUS_SRC_ALPHA;this.scheduleUpdate()},setDebugSolots:function(a){this._debugSlots=a},setDebugBones:function(a){this._debugBones=a},setDebugSlotsEnabled:function(a){this._debugSlots=a},getDebugSlotsEnabled:function(){return this._debugSlots},setDebugBonesEnabled:function(a){this._debugBones=a},getDebugBonesEnabled:function(){return this._debugBones},setTimeScale:function(a){this._timeScale=a},getTimeScale:function(){return this._timeScale},initWithArgs:function(a,
b,c){if(cc.isString(a)){if(cc.isString(b)){var d=cc.loader.getRes(b);sp._atlasLoader.setAtlasFile(b);b=new spine.Atlas(d,sp._atlasLoader)}c=c||1/cc.director.getContentScaleFactor();d=new spine.AtlasAttachmentLoader(b);d=new spine.SkeletonJson(d);d.scale=c;a=cc.loader.getRes(a);a=d.readSkeletonData(a);b.dispose(d);c=!0}else c=b;this.setSkeletonData(a,c);this.init()},getBoundingBox:function(){for(var a=cc.FLT_MAX,b=cc.FLT_MAX,c=cc.FLT_MIN,d=cc.FLT_MIN,e=this.getScaleX(),f=this.getScaleY(),g=[],h=this._skeleton.slots,
k=sp.VERTEX_INDEX,m=0,n=h.length;n>m;++m){var p=h[m];p.attachment&&p.attachment.type==sp.ATTACHMENT_TYPE.REGION&&(this._computeRegionAttachmentWorldVertices(p.attachment,p.bone.skeleton.x,p.bone.skeleton.y,p.bone,g),a=Math.min(a,g[k.X1]*e,g[k.X4]*e,g[k.X2]*e,g[k.X3]*e),b=Math.min(b,g[k.Y1]*f,g[k.Y4]*f,g[k.Y2]*f,g[k.Y3]*f),c=Math.max(c,g[k.X1]*e,g[k.X4]*e,g[k.X2]*e,g[k.X3]*e),d=Math.max(d,g[k.Y1]*f,g[k.Y4]*f,g[k.Y2]*f,g[k.Y3]*f))}e=this.getPosition();return cc.rect(e.x+a,e.y+b,c-a,d-b)},_computeRegionAttachmentWorldVertices:function(a,
b,c,d,e){a=a.offset;var f=sp.VERTEX_INDEX;b+=d.worldX;c+=d.worldY;e[f.X1]=a[f.X1]*d.m00+a[f.Y1]*d.m01+b;e[f.Y1]=a[f.X1]*d.m10+a[f.Y1]*d.m11+c;e[f.X2]=a[f.X2]*d.m00+a[f.Y2]*d.m01+b;e[f.Y2]=a[f.X2]*d.m10+a[f.Y2]*d.m11+c;e[f.X3]=a[f.X3]*d.m00+a[f.Y3]*d.m01+b;e[f.Y3]=a[f.X3]*d.m10+a[f.Y3]*d.m11+c;e[f.X4]=a[f.X4]*d.m00+a[f.Y4]*d.m01+b;e[f.Y4]=a[f.X4]*d.m10+a[f.Y4]*d.m11+c},updateWorldTransform:function(){this._skeleton.updateWorldTransform()},setToSetupPose:function(){this._skeleton.setToSetupPose()},
setBonesToSetupPose:function(){this._skeleton.setBonesToSetupPose()},setSlotsToSetupPose:function(){this._skeleton.setSlotsToSetupPose()},findBone:function(a){return this._skeleton.findBone(a)},findSlot:function(a){return this._skeleton.findSlot(a)},setSkin:function(a){return this._skeleton.setSkinByName(a)},getAttachment:function(a,b){return this._skeleton.getAttachmentBySlotName(a,b)},setAttachment:function(a,b){this._skeleton.setAttachment(a,b)},setOpacityModifyRGB:function(a){this._premultipliedAlpha=
a},isOpacityModifyRGB:function(){return this._premultipliedAlpha},setSkeletonData:function(a,b){null!=a.width&&null!=a.height&&this.setContentSize(a.width/cc.director.getContentScaleFactor(),a.height/cc.director.getContentScaleFactor());this._skeleton=new spine.Skeleton(a);this._skeleton.updateWorldTransform();this._rootBone=this._skeleton.getRootBone();this._ownsSkeletonData=b;this._renderCmd._createChildFormSkeletonData()},getTextureAtlas:function(a){return a.rendererObject.page.rendererObject},
getBlendFunc:function(){return this._blendFunc},setBlendFunc:function(a,b){var c=this._blendFunc;void 0===b?(c.src=a.src,c.dst=a.dst):(c.src=a,c.dst=b)},update:function(a){this._skeleton.update(a)}});sp.Skeleton.create=function(a,b,c){return new sp.Skeleton(a,b,c)};var spine={radDeg:180/Math.PI,degRad:Math.PI/180,temp:[],Float32Array:"undefined"==typeof Float32Array?Array:Float32Array,Uint16Array:"undefined"==typeof Uint16Array?Array:Uint16Array,BoneData:function(a,b){this.name=a;this.parent=b}};
spine.BoneData.prototype={length:0,x:0,y:0,rotation:0,scaleX:1,scaleY:1,inheritScale:!0,inheritRotation:!0,flipX:!1,flipY:!1};spine.SlotData=function(a,b){this.name=a;this.boneData=b};spine.SlotData.prototype={r:1,g:1,b:1,a:1,attachmentName:null,additiveBlending:!1};spine.IkConstraintData=function(a){this.name=a;this.bones=[]};spine.IkConstraintData.prototype={target:null,bendDirection:1,mix:1};spine.Bone=function(a,b,c){this.data=a;this.skeleton=b;this.parent=c;this.setToSetupPose()};
spine.Bone.yDown=!1;
spine.Bone.prototype={x:0,y:0,rotation:0,rotationIK:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,m00:0,m01:0,worldX:0,m10:0,m11:0,worldY:0,worldRotation:0,worldScaleX:1,worldScaleY:1,worldFlipX:!1,worldFlipY:!1,updateWorldTransform:function(){var a=this.parent;if(a)this.worldX=this.x*a.m00+this.y*a.m01+a.worldX,this.worldY=this.x*a.m10+this.y*a.m11+a.worldY,this.data.inheritScale?(this.worldScaleX=a.worldScaleX*this.scaleX,this.worldScaleY=a.worldScaleY*this.scaleY):(this.worldScaleX=this.scaleX,this.worldScaleY=
this.scaleY),this.worldRotation=this.data.inheritRotation?a.worldRotation+this.rotationIK:this.rotationIK,this.worldFlipX=a.worldFlipX!=this.flipX,this.worldFlipY=a.worldFlipY!=this.flipY;else{var a=this.skeleton.flipX,b=this.skeleton.flipY;this.worldX=a?-this.x:this.x;this.worldY=b!=spine.Bone.yDown?-this.y:this.y;this.worldScaleX=this.scaleX;this.worldScaleY=this.scaleY;this.worldRotation=this.rotationIK;this.worldFlipX=a!=this.flipX;this.worldFlipY=b!=this.flipY}b=this.worldRotation*spine.degRad;
a=Math.cos(b);b=Math.sin(b);this.worldFlipX?(this.m00=-a*this.worldScaleX,this.m01=b*this.worldScaleY):(this.m00=a*this.worldScaleX,this.m01=-b*this.worldScaleY);this.worldFlipY!=spine.Bone.yDown?(this.m10=-b*this.worldScaleX,this.m11=-a*this.worldScaleY):(this.m10=b*this.worldScaleX,this.m11=a*this.worldScaleY)},setToSetupPose:function(){var a=this.data;this.x=a.x;this.y=a.y;this.rotationIK=this.rotation=a.rotation;this.scaleX=a.scaleX;this.scaleY=a.scaleY;this.flipX=a.flipX;this.flipY=a.flipY},
worldToLocal:function(a){var b=a[0]-this.worldX,c=a[1]-this.worldY,d=this.m00,e=this.m10,f=this.m01,g=this.m11;this.worldFlipX!=(this.worldFlipY!=spine.Bone.yDown)&&(d=-d,g=-g);var h=1/(d*g-f*e);a[0]=b*d*h-c*f*h;a[1]=c*g*h-b*e*h},localToWorld:function(a){var b=a[0],c=a[1];a[0]=b*this.m00+c*this.m01+this.worldX;a[1]=b*this.m10+c*this.m11+this.worldY}};spine.Slot=function(a,b){this.data=a;this.bone=b;this.setToSetupPose()};
spine.Slot.prototype={r:1,g:1,b:1,a:1,_attachmentTime:0,attachment:null,attachmentVertices:[],setAttachment:function(a){this.attachment=a;this._attachmentTime=this.bone.skeleton.time;this.attachmentVertices.length=0},setAttachmentTime:function(a){this._attachmentTime=this.bone.skeleton.time-a},getAttachmentTime:function(){return this.bone.skeleton.time-this._attachmentTime},setToSetupPose:function(){var a=this.data;this.r=a.r;this.g=a.g;this.b=a.b;this.a=a.a;for(var b=this.bone.skeleton.data.slots,
c=0,d=b.length;d>c;c++)if(b[c]==a){this.setAttachment(a.attachmentName?this.bone.skeleton.getAttachmentBySlotIndex(c,a.attachmentName):null);break}}};spine.IkConstraint=function(a,b){this.data=a;this.mix=a.mix;this.bendDirection=a.bendDirection;this.bones=[];for(var c=0,d=a.bones.length;d>c;c++)this.bones.push(b.findBone(a.bones[c].name));this.target=b.findBone(a.target.name)};
spine.IkConstraint.prototype={apply:function(){var a=this.target,b=this.bones;switch(b.length){case 1:spine.IkConstraint.apply1(b[0],a.worldX,a.worldY,this.mix);break;case 2:spine.IkConstraint.apply2(b[0],b[1],a.worldX,a.worldY,this.bendDirection,this.mix)}}};
spine.IkConstraint.apply1=function(a,b,c,d){var e=a.data.inheritRotation&&a.parent?a.parent.worldRotation:0,f=a.rotation;b=Math.atan2(c-a.worldY,b-a.worldX)*spine.radDeg;a.worldFlipX!=(a.worldFlipY!=spine.Bone.yDown)&&(b=-b);a.rotationIK=f+(b-e-f)*d};
spine.IkConstraint.apply2=function(a,b,c,d,e,f){var g=b.rotation,h=a.rotation;if(!f)return b.rotationIK=g,void(a.rotationIK=h);var k,m,n=spine.temp,p=a.parent;p?(n[0]=c,n[1]=d,p.worldToLocal(n),c=(n[0]-a.x)*p.worldScaleX,d=(n[1]-a.y)*p.worldScaleY):(c-=a.x,d-=a.y);b.parent==a?(k=b.x,m=b.y):(n[0]=b.x,n[1]=b.y,b.parent.localToWorld(n),a.worldToLocal(n),k=n[0],m=n[1]);k*=a.worldScaleX;n=m*a.worldScaleY;m=Math.atan2(n,k);n=Math.sqrt(k*k+n*n);k=b.data.length*b.worldScaleX;p=2*n*k;if(1E-4>p)return void(b.rotationIK=
g+(Math.atan2(d,c)*spine.radDeg-h-g)*f);p=(c*c+d*d-n*n-k*k)/p;-1>p?p=-1:1<p&&(p=1);e*=Math.acos(p);n+=k*p;k*=Math.sin(e);c=(Math.atan2(d*n-c*k,c*n+d*k)-m)*spine.radDeg-h;180<c?c-=360:-180>c&&(c+=360);a.rotationIK=h+c*f;c=(e+m)*spine.radDeg-g;180<c?c-=360:-180>c&&(c+=360);b.rotationIK=g+(c+a.worldRotation-b.parent.worldRotation)*f};spine.Skin=function(a){this.name=a;this.attachments={}};
spine.Skin.prototype={addAttachment:function(a,b,c){this.attachments[a+":"+b]=c},getAttachment:function(a,b){return this.attachments[a+":"+b]},_attachAll:function(a,b){for(var c in b.attachments){var d=c.indexOf(":"),e=parseInt(c.substring(0,d)),f=c.substring(d+1),d=a.slots[e];d.attachment&&d.attachment.name==f&&(e=this.getAttachment(e,f))&&d.setAttachment(e)}}};spine.Animation=function(a,b,c){this.name=a;this.timelines=b;this.duration=c};
spine.Animation.prototype={apply:function(a,b,c,d,e){d&&0!=this.duration&&(c%=this.duration,b%=this.duration);d=this.timelines;for(var f=0,g=d.length;g>f;f++)d[f].apply(a,b,c,e,1)},mix:function(a,b,c,d,e,f){d&&0!=this.duration&&(c%=this.duration,b%=this.duration);d=this.timelines;for(var g=0,h=d.length;h>g;g++)d[g].apply(a,b,c,e,f)}};
spine.Animation.binarySearch=function(a,b,c){var d=0,e=Math.floor(a.length/c)-2;if(!e)return c;for(var f=e>>>1;;){if(a[(f+1)*c]<=b?d=f+1:e=f,d==e)return(d+1)*c;f=d+e>>>1}};spine.Animation.binarySearch1=function(a,b){var c=0,d=a.length-2;if(!d)return 1;for(var e=d>>>1;;){if(a[e+1]<=b?c=e+1:d=e,c==d)return c+1;e=c+d>>>1}};spine.Animation.linearSearch=function(a,b,c){for(var d=0,e=a.length-c;e>=d;d+=c)if(a[d]>b)return d;return-1};spine.Curves=function(a){this.curves=[]};
spine.Curves.prototype={setLinear:function(a){this.curves[19*a]=0},setStepped:function(a){this.curves[19*a]=1},setCurve:function(a,b,c,d,e){var f=0.1*0.1,g=0.1*f,h=3*0.1,k=3*f,m=6*f,f=6*g,n=2*-b+d,p=2*-c+e;d=3*(b-d)+1;e=3*(c-e)+1;b=b*h+n*k+d*g;c=c*h+p*k+e*g;g=n*m+d*f;m=p*m+e*f;p=d*f;f*=e;a*=19;d=this.curves;d[a++]=2;e=b;h=c;for(k=a+19-1;k>a;a+=2)d[a]=e,d[a+1]=h,b+=g,c+=m,g+=p,m+=f,e+=b,h+=c},getCurvePercent:function(a,b){b=0>b?0:1<b?1:b;var c=this.curves,d=19*a,e=c[d];if(0===e)return b;if(1==e)return 0;
d++;for(var e=0,f=d,g=d+19-1;g>d;d+=2)if(e=c[d],e>=b){var h,k;return d==f?(h=0,k=0):(h=c[d-2],k=c[d-1]),k+(c[d+1]-k)*(b-h)/(e-h)}c=c[d-1];return c+(1-c)*(b-e)/(1-e)}};spine.RotateTimeline=function(a){this.curves=new spine.Curves(a);this.frames=[];this.frames.length=2*a};
spine.RotateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(a,b,c){a*=2;this.frames[a]=b;this.frames[a+1]=c},apply:function(a,b,c,d,e){b=this.frames;if(!(c<b[0])){a=a.bones[this.boneIndex];if(c>=b[b.length-2]){for(b=a.data.rotation+b[b.length-1]-a.rotation;180<b;)b-=360;for(;-180>b;)b+=360;return void(a.rotation+=b*e)}var f=spine.Animation.binarySearch(b,c,2);d=b[f-1];var g=b[f];c=1-(c-g)/(b[f-2]-g);c=this.curves.getCurvePercent(f/2-1,c);for(b=
b[f+1]-d;180<b;)b-=360;for(;-180>b;)b+=360;for(b=a.data.rotation+(d+b*c)-a.rotation;180<b;)b-=360;for(;-180>b;)b+=360;a.rotation+=b*e}}};spine.TranslateTimeline=function(a){this.curves=new spine.Curves(a);this.frames=[];this.frames.length=3*a};
spine.TranslateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(a,b,c,d){a*=3;this.frames[a]=b;this.frames[a+1]=c;this.frames[a+2]=d},apply:function(a,b,c,d,e){b=this.frames;if(!(c<b[0])){a=a.bones[this.boneIndex];if(c>=b[b.length-3])return a.x+=(a.data.x+b[b.length-2]-a.x)*e,void(a.y+=(a.data.y+b[b.length-1]-a.y)*e);d=spine.Animation.binarySearch(b,c,3);var f=b[d-2],g=b[d-1],h=b[d];c=1-(c-h)/(b[d+-3]-h);c=this.curves.getCurvePercent(d/3-1,c);
a.x+=(a.data.x+f+(b[d+1]-f)*c-a.x)*e;a.y+=(a.data.y+g+(b[d+2]-g)*c-a.y)*e}}};spine.ScaleTimeline=function(a){this.curves=new spine.Curves(a);this.frames=[];this.frames.length=3*a};
spine.ScaleTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(a,b,c,d){a*=3;this.frames[a]=b;this.frames[a+1]=c;this.frames[a+2]=d},apply:function(a,b,c,d,e){b=this.frames;if(!(c<b[0])){a=a.bones[this.boneIndex];if(c>=b[b.length-3])return a.scaleX+=(a.data.scaleX*b[b.length-2]-a.scaleX)*e,void(a.scaleY+=(a.data.scaleY*b[b.length-1]-a.scaleY)*e);d=spine.Animation.binarySearch(b,c,3);var f=b[d-2],g=b[d-1],h=b[d];c=1-(c-h)/(b[d+-3]-h);c=this.curves.getCurvePercent(d/
3-1,c);a.scaleX+=(a.data.scaleX*(f+(b[d+1]-f)*c)-a.scaleX)*e;a.scaleY+=(a.data.scaleY*(g+(b[d+2]-g)*c)-a.scaleY)*e}}};spine.ColorTimeline=function(a){this.curves=new spine.Curves(a);this.frames=[];this.frames.length=5*a};
spine.ColorTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length/5},setFrame:function(a,b,c,d,e,f){a*=5;this.frames[a]=b;this.frames[a+1]=c;this.frames[a+2]=d;this.frames[a+3]=e;this.frames[a+4]=f},apply:function(a,b,c,d,e){b=this.frames;if(!(c<b[0])){var f,g;if(c>=b[b.length-5])d=b.length-1,c=b[d-3],f=b[d-2],g=b[d-1],b=b[d];else{d=spine.Animation.binarySearch(b,c,5);var h=b[d-4];f=b[d-3];g=b[d-2];var k=b[d-1],m=b[d],m=1-(c-m)/(b[d-5]-m),m=this.curves.getCurvePercent(d/
5-1,m);c=h+(b[d+1]-h)*m;f+=(b[d+2]-f)*m;g+=(b[d+3]-g)*m;b=k+(b[d+4]-k)*m}a=a.slots[this.slotIndex];1>e?(a.r+=(c-a.r)*e,a.g+=(f-a.g)*e,a.b+=(g-a.b)*e,a.a+=(b-a.a)*e):(a.r=c,a.g=f,a.b=g,a.a=b)}}};spine.AttachmentTimeline=function(a){this.curves=new spine.Curves(a);this.frames=[];this.frames.length=a;this.attachmentNames=[];this.attachmentNames.length=a};
spine.AttachmentTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length},setFrame:function(a,b,c){this.frames[a]=b;this.attachmentNames[a]=c},apply:function(a,b,c,d,e){d=this.frames;if(c<d[0])return void(b>c&&this.apply(a,b,Number.MAX_VALUE,null,0));b>c&&(b=-1);c=c>=d[d.length-1]?d.length-1:spine.Animation.binarySearch1(d,c)-1;d[c]<b||(b=this.attachmentNames[c],a.slots[this.slotIndex].setAttachment(b?a.getAttachmentBySlotIndex(this.slotIndex,b):null))}};
spine.EventTimeline=function(a){this.frames=[];this.frames.length=a;this.events=[];this.events.length=a};
spine.EventTimeline.prototype={getFrameCount:function(){return this.frames.length},setFrame:function(a,b,c){this.frames[a]=b;this.events[a]=c},apply:function(a,b,c,d,e){if(d){var f=this.frames,g=f.length;if(b>c)this.apply(a,b,Number.MAX_VALUE,d,e),b=-1;else if(b>=f[g-1])return;if(!(c<f[0])){if(b<f[0])a=0;else{a=spine.Animation.binarySearch1(f,b);for(b=f[a];0<a&&f[a-1]==b;)a--}for(b=this.events;g>a&&c>=f[a];a++)d.push(b[a])}}}};
spine.DrawOrderTimeline=function(a){this.frames=[];this.frames.length=a;this.drawOrders=[];this.drawOrders.length=a};
spine.DrawOrderTimeline.prototype={getFrameCount:function(){return this.frames.length},setFrame:function(a,b,c){this.frames[a]=b;this.drawOrders[a]=c},apply:function(a,b,c,d,e){b=this.frames;if(!(c<b[0]))if(d=c>=b[b.length-1]?b.length-1:spine.Animation.binarySearch1(b,c)-1,c=a.drawOrder,b=a.slots,d=this.drawOrders[d]){e=0;for(var f=d.length;f>e;e++)c[e]=a.slots[d[e]]}else{e=0;for(f=b.length;f>e;e++)c[e]=b[e]}}};
spine.FfdTimeline=function(a){this.curves=new spine.Curves(a);this.frames=[];this.frames.length=a;this.frameVertices=[];this.frameVertices.length=a};
spine.FfdTimeline.prototype={slotIndex:0,attachment:0,getFrameCount:function(){return this.frames.length},setFrame:function(a,b,c){this.frames[a]=b;this.frameVertices[a]=c},apply:function(a,b,c,d,e){b=a.slots[this.slotIndex];if(b.attachment==this.attachment){var f=this.frames;if(!(c<f[0]))if(d=this.frameVertices,a=d[0].length,b=b.attachmentVertices,b.length!=a&&(e=1),b.length=a,c>=f[f.length-1])if(c=d[f.length-1],1>e)for(d=0;a>d;d++)b[d]+=(c[d]-b[d])*e;else for(d=0;a>d;d++)b[d]=c[d];else{var g=spine.Animation.binarySearch1(f,
c),h=f[g];c=1-(c-h)/(f[g-1]-h);c=this.curves.getCurvePercent(g-1,0>c?0:1<c?1:c);f=d[g-1];g=d[g];if(1>e)for(d=0;a>d;d++)h=f[d],b[d]+=(h+(g[d]-h)*c-b[d])*e;else for(d=0;a>d;d++)h=f[d],b[d]=h+(g[d]-h)*c}}}};spine.IkConstraintTimeline=function(a){this.curves=new spine.Curves(a);this.frames=[];this.frames.length=3*a};
spine.IkConstraintTimeline.prototype={ikConstraintIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(a,b,c,d){a*=3;this.frames[a]=b;this.frames[a+1]=c;this.frames[a+2]=d},apply:function(a,b,c,d,e){b=this.frames;if(!(c<b[0])){a=a.ikConstraints[this.ikConstraintIndex];if(c>=b[b.length-3])return a.mix+=(b[b.length-2]-a.mix)*e,void(a.bendDirection=b[b.length-1]);d=spine.Animation.binarySearch(b,c,3);var f=b[d+-2],g=b[d];c=1-(c-g)/(b[d+-3]-g);c=this.curves.getCurvePercent(d/
3-1,c);a.mix+=(f+(b[d+1]-f)*c-a.mix)*e;a.bendDirection=b[d+-1]}}};spine.FlipXTimeline=function(a){this.curves=new spine.Curves(a);this.frames=[];this.frames.length=2*a};
spine.FlipXTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(a,b,c){a*=2;this.frames[a]=b;this.frames[a+1]=c?1:0},apply:function(a,b,c,d,e){d=this.frames;if(c<d[0])return void(b>c&&this.apply(a,b,Number.MAX_VALUE,null,0));b>c&&(b=-1);c=(c>=d[d.length-2]?d.length:spine.Animation.binarySearch(d,c,2))-2;d[c]<b||(a.bones[this.boneIndex].flipX=0!=d[c+1])}};
spine.FlipYTimeline=function(a){this.curves=new spine.Curves(a);this.frames=[];this.frames.length=2*a};
spine.FlipYTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(a,b,c){a*=2;this.frames[a]=b;this.frames[a+1]=c?1:0},apply:function(a,b,c,d,e){d=this.frames;if(c<d[0])return void(b>c&&this.apply(a,b,Number.MAX_VALUE,null,0));b>c&&(b=-1);c=(c>=d[d.length-2]?d.length:spine.Animation.binarySearch(d,c,2))-2;d[c]<b||(a.bones[this.boneIndex].flipY=0!=d[c+1])}};
spine.SkeletonData=function(){this.bones=[];this.slots=[];this.skins=[];this.events=[];this.animations=[];this.ikConstraints=[]};
spine.SkeletonData.prototype={name:null,defaultSkin:null,width:0,height:0,version:null,hash:null,findBone:function(a){for(var b=this.bones,c=0,d=b.length;d>c;c++)if(b[c].name==a)return b[c];return null},findBoneIndex:function(a){for(var b=this.bones,c=0,d=b.length;d>c;c++)if(b[c].name==a)return c;return-1},findSlot:function(a){for(var b=this.slots,c=0,d=b.length;d>c;c++)if(b[c].name==a)return slot[c];return null},findSlotIndex:function(a){for(var b=this.slots,c=0,d=b.length;d>c;c++)if(b[c].name==
a)return c;return-1},findSkin:function(a){for(var b=this.skins,c=0,d=b.length;d>c;c++)if(b[c].name==a)return b[c];return null},findEvent:function(a){for(var b=this.events,c=0,d=b.length;d>c;c++)if(b[c].name==a)return b[c];return null},findAnimation:function(a){for(var b=this.animations,c=0,d=b.length;d>c;c++)if(b[c].name==a)return b[c];return null},findIkConstraint:function(a){for(var b=this.ikConstraints,c=0,d=b.length;d>c;c++)if(b[c].name==a)return b[c];return null}};
spine.Skeleton=function(a){this.data=a;this.bones=[];for(var b=0,c=a.bones.length;c>b;b++){var d=a.bones[b],e=d.parent?this.bones[a.bones.indexOf(d.parent)]:null;this.bones.push(new spine.Bone(d,this,e))}this.slots=[];this.drawOrder=[];b=0;for(c=a.slots.length;c>b;b++)d=a.slots[b],e=this.bones[a.bones.indexOf(d.boneData)],d=new spine.Slot(d,e),this.slots.push(d),this.drawOrder.push(d);this.ikConstraints=[];b=0;for(c=a.ikConstraints.length;c>b;b++)this.ikConstraints.push(new spine.IkConstraint(a.ikConstraints[b],
this));this.boneCache=[];this.updateCache()};
spine.Skeleton.prototype={x:0,y:0,skin:null,r:1,g:1,b:1,a:1,time:0,flipX:!1,flipY:!1,updateCache:function(){var a=this.ikConstraints,b=a.length,c=b+1,d=this.boneCache;d.length>c&&(d.length=c);for(var e=0,f=d.length;f>e;e++)d[e].length=0;for(;d.length<c;)d[d.length]=[];var c=d[0],g=this.bones,e=0,f=g.length;a:for(;f>e;e++){var h=g[e],k=h;do{for(var m=0;b>m;m++)for(var n=a[m],p=n.bones[0],n=n.bones[n.bones.length-1];;){if(k==n){d[m].push(h);d[m+1].push(h);continue a}if(n==p)break;n=n.parent}k=k.parent}while(k);
c[c.length]=h}},updateWorldTransform:function(){for(var a=this.bones,b=0,c=a.length;c>b;b++){var d=a[b];d.rotationIK=d.rotation}b=0;for(a=this.boneCache.length-1;;){for(var c=this.boneCache[b],d=0,e=c.length;e>d;d++)c[d].updateWorldTransform();if(b==a)break;this.ikConstraints[b].apply();b++}},setToSetupPose:function(){this.setBonesToSetupPose();this.setSlotsToSetupPose()},setBonesToSetupPose:function(){for(var a=this.bones,b=0,c=a.length;c>b;b++)a[b].setToSetupPose();a=this.ikConstraints;b=0;for(c=
a.length;c>b;b++){var d=a[b];d.bendDirection=d.data.bendDirection;d.mix=d.data.mix}},setSlotsToSetupPose:function(){for(var a=this.slots,b=this.drawOrder,c=0,d=a.length;d>c;c++)b[c]=a[c],a[c].setToSetupPose(c)},getRootBone:function(){return this.bones.length?this.bones[0]:null},findBone:function(a){for(var b=this.bones,c=0,d=b.length;d>c;c++)if(b[c].data.name==a)return b[c];return null},findBoneIndex:function(a){for(var b=this.bones,c=0,d=b.length;d>c;c++)if(b[c].data.name==a)return c;return-1},findSlot:function(a){for(var b=
this.slots,c=0,d=b.length;d>c;c++)if(b[c].data.name==a)return b[c];return null},findSlotIndex:function(a){for(var b=this.slots,c=0,d=b.length;d>c;c++)if(b[c].data.name==a)return c;return-1},setSkinByName:function(a){var b=this.data.findSkin(a);if(!b)throw"Skin not found: "+a;this.setSkin(b)},setSkin:function(a){if(a)if(this.skin)a._attachAll(this,this.skin);else for(var b=this.slots,c=0,d=b.length;d>c;c++){var e=b[c],f=e.data.attachmentName;f&&(f=a.getAttachment(c,f))&&e.setAttachment(f)}this.skin=
a},getAttachmentBySlotName:function(a,b){return this.getAttachmentBySlotIndex(this.data.findSlotIndex(a),b)},getAttachmentBySlotIndex:function(a,b){if(this.skin){var c=this.skin.getAttachment(a,b);if(c)return c}return this.data.defaultSkin?this.data.defaultSkin.getAttachment(a,b):null},setAttachment:function(a,b){for(var c=this.slots,d=0,e=c.length;e>d;d++){var f=c[d];if(f.data.name==a){c=null;if(b&&(c=this.getAttachmentBySlotIndex(d,b),!c))throw"Attachment not found: "+b+", for slot: "+a;return void f.setAttachment(c)}}throw"Slot not found: "+
a;},findIkConstraint:function(a){for(var b=this.ikConstraints,c=0,d=b.length;d>c;c++)if(b[c].data.name==a)return b[c];return null},update:function(a){this.time+=a}};spine.EventData=function(a){this.name=a};spine.EventData.prototype={intValue:0,floatValue:0,stringValue:null};spine.Event=function(a){this.data=a};spine.Event.prototype={intValue:0,floatValue:0,stringValue:null};spine.AttachmentType={region:0,boundingbox:1,mesh:2,skinnedmesh:3};
spine.RegionAttachment=function(a){this.name=a;this.offset=[];this.offset.length=8;this.uvs=[];this.uvs.length=8};
spine.RegionAttachment.prototype={type:spine.AttachmentType.region,x:0,y:0,rotation:0,scaleX:1,scaleY:1,width:0,height:0,r:1,g:1,b:1,a:1,path:null,rendererObject:null,regionOffsetX:0,regionOffsetY:0,regionWidth:0,regionHeight:0,regionOriginalWidth:0,regionOriginalHeight:0,setUVs:function(a,b,c,d,e){var f=this.uvs;e?(f[2]=a,f[3]=d,f[4]=a,f[5]=b,f[6]=c,f[7]=b,f[0]=c,f[1]=d):(f[0]=a,f[1]=d,f[2]=a,f[3]=b,f[4]=c,f[5]=b,f[6]=c,f[7]=d)},updateOffset:function(){var a=this.width/this.regionOriginalWidth*this.scaleX,
b=this.height/this.regionOriginalHeight*this.scaleY,c=-this.width/2*this.scaleX+this.regionOffsetX*a,d=-this.height/2*this.scaleY+this.regionOffsetY*b,e=c+this.regionWidth*a,a=d+this.regionHeight*b,b=this.rotation*spine.degRad,f=Math.cos(b),g=Math.sin(b),b=c*f+this.x,c=c*g,h=d*f+this.y,d=d*g,k=e*f+this.x,e=e*g,f=a*f+this.y,a=a*g,g=this.offset;g[0]=b-d;g[1]=h+c;g[2]=b-a;g[3]=f+c;g[4]=k-a;g[5]=f+e;g[6]=k-d;g[7]=h+e},computeVertices:function(a,b,c,d){a+=c.worldX;b+=c.worldY;var e=c.m00,f=c.m01,g=c.m10;
c=c.m11;var h=this.offset;d[0]=h[0]*e+h[1]*f+a;d[1]=h[0]*g+h[1]*c+b;d[2]=h[2]*e+h[3]*f+a;d[3]=h[2]*g+h[3]*c+b;d[4]=h[4]*e+h[5]*f+a;d[5]=h[4]*g+h[5]*c+b;d[6]=h[6]*e+h[7]*f+a;d[7]=h[6]*g+h[7]*c+b}};spine.MeshAttachment=function(a){this.name=a};
spine.MeshAttachment.prototype={type:spine.AttachmentType.mesh,vertices:null,uvs:null,regionUVs:null,triangles:null,hullLength:0,r:1,g:1,b:1,a:1,path:null,rendererObject:null,regionU:0,regionV:0,regionU2:0,regionV2:0,regionRotate:!1,regionOffsetX:0,regionOffsetY:0,regionWidth:0,regionHeight:0,regionOriginalWidth:0,regionOriginalHeight:0,edges:null,width:0,height:0,updateUVs:function(){var a=this.regionU2-this.regionU,b=this.regionV2-this.regionV,c=this.regionUVs.length;if(this.uvs&&this.uvs.length==
c||(this.uvs=new spine.Float32Array(c)),this.regionRotate)for(var d=0;c>d;d+=2)this.uvs[d]=this.regionU+this.regionUVs[d+1]*a,this.uvs[d+1]=this.regionV+b-this.regionUVs[d]*b;else for(d=0;c>d;d+=2)this.uvs[d]=this.regionU+this.regionUVs[d]*a,this.uvs[d+1]=this.regionV+this.regionUVs[d+1]*b},computeWorldVertices:function(a,b,c,d){var e=c.bone;a+=e.worldX;b+=e.worldY;var f=e.m00,g=e.m01,h=e.m10,e=e.m11,k=this.vertices,m=k.length;c.attachmentVertices.length==m&&(k=c.attachmentVertices);for(c=0;m>c;c+=
2){var n=k[c],p=k[c+1];d[c]=n*f+p*g+a;d[c+1]=n*h+p*e+b}}};spine.SkinnedMeshAttachment=function(a){this.name=a};
spine.SkinnedMeshAttachment.prototype={type:spine.AttachmentType.skinnedmesh,bones:null,weights:null,uvs:null,regionUVs:null,triangles:null,hullLength:0,r:1,g:1,b:1,a:1,path:null,rendererObject:null,regionU:0,regionV:0,regionU2:0,regionV2:0,regionRotate:!1,regionOffsetX:0,regionOffsetY:0,regionWidth:0,regionHeight:0,regionOriginalWidth:0,regionOriginalHeight:0,edges:null,width:0,height:0,updateUVs:function(a,b,c,d,e){a=this.regionU2-this.regionU;b=this.regionV2-this.regionV;c=this.regionUVs.length;
if(this.uvs&&this.uvs.length==c||(this.uvs=new spine.Float32Array(c)),this.regionRotate)for(d=0;c>d;d+=2)this.uvs[d]=this.regionU+this.regionUVs[d+1]*a,this.uvs[d+1]=this.regionV+b-this.regionUVs[d]*b;else for(d=0;c>d;d+=2)this.uvs[d]=this.regionU+this.regionUVs[d]*a,this.uvs[d+1]=this.regionV+this.regionUVs[d+1]*b},computeWorldVertices:function(a,b,c,d){var e,f,g,h,k,m,n=c.bone.skeleton.bones,p=this.weights,r=this.bones,s=0,v=0,u=0,t=0,x=r.length;if(c.attachmentVertices.length)for(var A=c.attachmentVertices;x>
v;s+=2){f=e=0;for(c=r[v++]+v;c>v;v++,u+=3,t+=2)g=n[r[v]],h=p[u]+A[t],k=p[u+1]+A[t+1],m=p[u+2],e+=(h*g.m00+k*g.m01+g.worldX)*m,f+=(h*g.m10+k*g.m11+g.worldY)*m;d[s]=e+a;d[s+1]=f+b}else for(;x>v;s+=2){f=e=0;for(c=r[v++]+v;c>v;v++,u+=3)g=n[r[v]],h=p[u],k=p[u+1],m=p[u+2],e+=(h*g.m00+k*g.m01+g.worldX)*m,f+=(h*g.m10+k*g.m11+g.worldY)*m;d[s]=e+a;d[s+1]=f+b}}};spine.BoundingBoxAttachment=function(a){this.name=a;this.vertices=[]};
spine.BoundingBoxAttachment.prototype={type:spine.AttachmentType.boundingbox,computeWorldVertices:function(a,b,c,d){a+=c.worldX;b+=c.worldY;var e=c.m00,f=c.m01,g=c.m10;c=c.m11;for(var h=this.vertices,k=0,m=h.length;m>k;k+=2){var n=h[k],p=h[k+1];d[k]=n*e+p*f+a;d[k+1]=n*g+p*c+b}}};spine.AnimationStateData=function(a){this.skeletonData=a;this.animationToMixTime={}};
spine.AnimationStateData.prototype={defaultMix:0,setMixByName:function(a,b,c){var d=this.skeletonData.findAnimation(a);if(!d)throw"Animation not found: "+a;a=this.skeletonData.findAnimation(b);if(!a)throw"Animation not found: "+b;this.setMix(d,a,c)},setMix:function(a,b,c){this.animationToMixTime[a.name+":"+b.name]=c},getMix:function(a,b){var c=a.name+":"+b.name;return this.animationToMixTime.hasOwnProperty(c)?this.animationToMixTime[c]:this.defaultMix}};spine.TrackEntry=function(){};
spine.TrackEntry.prototype={next:null,previous:null,animation:null,loop:!1,delay:0,time:0,lastTime:-1,endTime:0,timeScale:1,mixTime:0,mixDuration:0,mix:1,onStart:null,onEnd:null,onComplete:null,onEvent:null};spine.AnimationState=function(a){this.data=a;this.tracks=[];this.events=[]};
spine.AnimationState.prototype={onStart:null,onEnd:null,onComplete:null,onEvent:null,timeScale:1,update:function(a){a*=this.timeScale;for(var b=0;b<this.tracks.length;b++){var c=this.tracks[b];if(c){if(c.time+=a*c.timeScale,c.previous){var d=a*c.previous.timeScale;c.previous.time+=d;c.mixTime+=d}(d=c.next)?(d.time=c.lastTime-d.delay,0<=d.time&&this.setCurrent(b,d)):!c.loop&&c.lastTime>=c.endTime&&this.clearTrack(b)}}},apply:function(a){for(var b=0;b<this.tracks.length;b++){var c=this.tracks[b];if(c){this.events.length=
0;var d=c.time,e=c.lastTime,f=c.endTime,g=c.loop;!g&&d>f&&(d=f);var h=c.previous;if(h){var k=h.time;!h.loop&&k>h.endTime&&(k=h.endTime);h.animation.apply(a,k,k,h.loop,null);h=c.mixTime/c.mixDuration*c.mix;1<=h&&(h=1,c.previous=null);c.animation.mix(a,c.lastTime,d,g,this.events,h)}else 1==c.mix?c.animation.apply(a,c.lastTime,d,g,this.events):c.animation.mix(a,c.lastTime,d,g,this.events,c.mix);h=0;for(k=this.events.length;k>h;h++){var m=this.events[h];c.onEvent&&c.onEvent(b,m);this.onEvent&&this.onEvent(b,
m)}if(g?e%f>d%f:f>e&&d>=f)d=Math.floor(d/f),c.onComplete&&c.onComplete(b,d),this.onComplete&&this.onComplete(b,d);c.lastTime=c.time}}},clearTracks:function(){for(var a=0,b=this.tracks.length;b>a;a++)this.clearTrack(a);this.tracks.length=0},clearTrack:function(a){if(!(a>=this.tracks.length)){var b=this.tracks[a];b&&(b.onEnd&&b.onEnd(a),this.onEnd&&this.onEnd(a),this.tracks[a]=null)}},_expandToIndex:function(a){if(a<this.tracks.length)return this.tracks[a];for(;a>=this.tracks.length;)this.tracks.push(null);
return null},setCurrent:function(a,b){var c=this._expandToIndex(a);if(c){var d=c.previous;c.previous=null;c.onEnd&&c.onEnd(a);this.onEnd&&this.onEnd(a);b.mixDuration=this.data.getMix(c.animation,b.animation);0<b.mixDuration&&(b.mixTime=0,d&&0.5>c.mixTime/c.mixDuration?b.previous=d:b.previous=c)}this.tracks[a]=b;b.onStart&&b.onStart(a);this.onStart&&this.onStart(a)},setAnimationByName:function(a,b,c){var d=this.data.skeletonData.findAnimation(b);if(!d)throw"Animation not found: "+b;return this.setAnimation(a,
d,c)},setAnimation:function(a,b,c){var d=new spine.TrackEntry;return d.animation=b,d.loop=c,d.endTime=b.duration,this.setCurrent(a,d),d},addAnimationByName:function(a,b,c,d){var e=this.data.skeletonData.findAnimation(b);if(!e)throw"Animation not found: "+b;return this.addAnimation(a,e,c,d)},addAnimation:function(a,b,c,d){var e=new spine.TrackEntry;e.animation=b;e.loop=c;e.endTime=b.duration;if(c=this._expandToIndex(a)){for(;c.next;)c=c.next;c.next=e}else this.tracks[a]=e;return 0>=d&&(c?d+=c.endTime-
this.data.getMix(c.animation,b):d=0),e.delay=d,e},getCurrent:function(a){return a>=this.tracks.length?null:this.tracks[a]}};spine.SkeletonJson=function(a){this.attachmentLoader=a};
spine.SkeletonJson.prototype={scale:1,readSkeletonData:function(a,b){var c=new spine.SkeletonData;c.name=b;var d=a.skeleton;d&&(c.hash=d.hash,c.version=d.spine,c.width=d.width||0,c.height=d.height||0);for(var e=a.bones,d=0,f=e.length;f>d;d++){var g=e[d],h=null;if(g.parent&&(h=c.findBone(g.parent),!h))throw"Parent bone not found: "+g.parent;h=new spine.BoneData(g.name,h);h.length=(g.length||0)*this.scale;h.x=(g.x||0)*this.scale;h.y=(g.y||0)*this.scale;h.rotation=g.rotation||0;h.scaleX=g.hasOwnProperty("scaleX")?
g.scaleX:1;h.scaleY=g.hasOwnProperty("scaleY")?g.scaleY:1;h.inheritScale=g.hasOwnProperty("inheritScale")?g.inheritScale:!0;h.inheritRotation=g.hasOwnProperty("inheritRotation")?g.inheritRotation:!0;c.bones.push(h)}if(h=a.ik){d=0;for(f=h.length;f>d;d++){for(var g=h[d],k=new spine.IkConstraintData(g.name),e=g.bones,m=0,n=e.length;n>m;m++){var p=c.findBone(e[m]);if(!p)throw"IK bone not found: "+e[m];k.bones.push(p)}if(k.target=c.findBone(g.target),!k.target)throw"Target bone not found: "+g.target;k.bendDirection=
!g.hasOwnProperty("bendPositive")||g.bendPositive?1:-1;k.mix=g.hasOwnProperty("mix")?g.mix:1;c.ikConstraints.push(k)}}e=a.slots;d=0;for(f=e.length;f>d;d++){g=e[d];h=c.findBone(g.bone);if(!h)throw"Slot bone not found: "+g.bone;h=new spine.SlotData(g.name,h);(k=g.color)&&(h.r=this.toColor(k,0),h.g=this.toColor(k,1),h.b=this.toColor(k,2),h.a=this.toColor(k,3));h.attachmentName=g.attachment;h.additiveBlending=g.additive&&"true"==g.additive;c.slots.push(h)}var d=a.skins,r;for(r in d)if(d.hasOwnProperty(r)){var f=
d[r],e=new spine.Skin(r),s;for(s in f)if(f.hasOwnProperty(s)){var h=c.findSlotIndex(s),g=f[s],v;for(v in g)g.hasOwnProperty(v)&&(k=this.readAttachment(e,v,g[v]))&&e.addAttachment(h,v,k)}c.skins.push(e);"default"==e.name&&(c.defaultSkin=e)}r=a.events;for(var u in r)r.hasOwnProperty(u)&&(s=r[u],v=new spine.EventData(u),v.intValue=s["int"]||0,v.floatValue=s["float"]||0,v.stringValue=s.string||null,c.events.push(v));u=a.animations;for(var t in u)u.hasOwnProperty(t)&&this.readAnimation(t,u[t],c);return c},
readAttachment:function(a,b,c){b=c.name||b;var d=spine.AttachmentType[c.type||"region"],e=c.path||b,f=this.scale;if(d==spine.AttachmentType.region){a=this.attachmentLoader.newRegionAttachment(a,b,e);if(!a)return null;a.path=e;a.x=(c.x||0)*f;a.y=(c.y||0)*f;a.scaleX=c.hasOwnProperty("scaleX")?c.scaleX:1;a.scaleY=c.hasOwnProperty("scaleY")?c.scaleY:1;a.rotation=c.rotation||0;a.width=(c.width||0)*f;a.height=(c.height||0)*f;var g=c.color;return g&&(a.r=this.toColor(g,0),a.g=this.toColor(g,1),a.b=this.toColor(g,
2),a.a=this.toColor(g,3)),a.updateOffset(),a}if(d==spine.AttachmentType.mesh)return(a=this.attachmentLoader.newMeshAttachment(a,b,e))?(a.path=e,a.vertices=this.getFloatArray(c,"vertices",f),a.triangles=this.getIntArray(c,"triangles"),a.regionUVs=this.getFloatArray(c,"uvs",1),a.updateUVs(),g=c.color,g&&(a.r=this.toColor(g,0),a.g=this.toColor(g,1),a.b=this.toColor(g,2),a.a=this.toColor(g,3)),a.hullLength=2*(c.hull||0),c.edges&&(a.edges=this.getIntArray(c,"edges")),a.width=(c.width||0)*f,a.height=(c.height||
0)*f,a):null;if(d==spine.AttachmentType.skinnedmesh){a=this.attachmentLoader.newSkinnedMeshAttachment(a,b,e);if(!a)return null;a.path=e;var h=this.getFloatArray(c,"uvs",1),e=this.getFloatArray(c,"vertices",1),k=[],m=[];b=0;for(d=e.length;d>b;){var n=0|e[b++];m[m.length]=n;for(n=b+4*n;n>b;)m[m.length]=e[b],k[k.length]=e[b+1]*f,k[k.length]=e[b+2]*f,k[k.length]=e[b+3],b+=4}return a.bones=m,a.weights=k,a.triangles=this.getIntArray(c,"triangles"),a.regionUVs=h,a.updateUVs(),g=c.color,g&&(a.r=this.toColor(g,
0),a.g=this.toColor(g,1),a.b=this.toColor(g,2),a.a=this.toColor(g,3)),a.hullLength=2*(c.hull||0),c.edges&&(a.edges=this.getIntArray(c,"edges")),a.width=(c.width||0)*f,a.height=(c.height||0)*f,a}if(d==spine.AttachmentType.boundingbox){g=this.attachmentLoader.newBoundingBoxAttachment(a,b);e=c.vertices;b=0;for(d=e.length;d>b;b++)g.vertices.push(e[b]*f);return g}throw"Unknown attachment type: "+d;},readAnimation:function(a,b,c){var d=[],e=0,f=b.slots,g;for(g in f)if(f.hasOwnProperty(g)){var h=f[g],k=
c.findSlotIndex(g),m;for(m in h)if(h.hasOwnProperty(m)){var n=h[m];if("color"==m){var p=new spine.ColorTimeline(n.length);p.slotIndex=k;for(var r=0,s=0,v=n.length;v>s;s++){var u=n[s],t=u.color,x=this.toColor(t,0),A=this.toColor(t,1),F=this.toColor(t,2),t=this.toColor(t,3);p.setFrame(r,u.time,x,A,F,t);this.readCurve(p,r,u);r++}d.push(p);e=Math.max(e,p.frames[5*p.getFrameCount()-5])}else{if("attachment"!=m)throw"Invalid timeline type for a slot: "+m+" ("+g+")";p=new spine.AttachmentTimeline(n.length);
p.slotIndex=k;s=r=0;for(v=n.length;v>s;s++)u=n[s],p.setFrame(r++,u.time,u.name);d.push(p);e=Math.max(e,p.frames[p.getFrameCount()-1])}}}var k=b.bones,z;for(z in k)if(k.hasOwnProperty(z)){h=c.findBoneIndex(z);if(-1==h)throw"Bone not found: "+z;f=k[z];for(m in f)if(f.hasOwnProperty(m))if(n=f[m],"rotate"==m){p=new spine.RotateTimeline(n.length);p.boneIndex=h;s=r=0;for(v=n.length;v>s;s++)u=n[s],p.setFrame(r,u.time,u.angle),this.readCurve(p,r,u),r++;d.push(p);e=Math.max(e,p.frames[2*p.getFrameCount()-
2])}else if("translate"==m||"scale"==m){x=1;"scale"==m?p=new spine.ScaleTimeline(n.length):(p=new spine.TranslateTimeline(n.length),x=this.scale);p.boneIndex=h;s=r=0;for(v=n.length;v>s;s++)u=n[s],A=(u.x||0)*x,p.setFrame(r,u.time,A,(u.y||0)*x),this.readCurve(p,r,u),r++;d.push(p);e=Math.max(e,p.frames[3*p.getFrameCount()-3])}else{if("flipX"!=m&&"flipY"!=m)throw"Invalid timeline type for a bone: "+m+" ("+z+")";p=(A="flipX"==m)?new spine.FlipXTimeline(n.length):new spine.FlipYTimeline(n.length);p.boneIndex=
h;x=A?"x":"y";s=r=0;for(v=n.length;v>s;s++)u=n[s],p.setFrame(r,u.time,u[x]||!1),r++;d.push(p);e=Math.max(e,p.frames[2*p.getFrameCount()-2])}}var k=b.ik,w;for(w in k)if(k.hasOwnProperty(w)){r=c.findIkConstraint(w);n=k[w];p=new spine.IkConstraintTimeline(n.length);p.ikConstraintIndex=c.ikConstraints.indexOf(r);s=r=0;for(v=n.length;v>s;s++)u=n[s],h=u.hasOwnProperty("mix")?u.mix:1,m=!u.hasOwnProperty("bendPositive")||u.bendPositive?1:-1,p.setFrame(r,u.time,h,m),this.readCurve(p,r,u),r++;d.push(p);e=Math.max(e,
p.frames[3*p.frameCount-3])}z=b.ffd;for(var B in z)for(g in f=c.findSkin(B),h=z[B],h){var k=c.findSlotIndex(g),x=h[g],E;for(E in x){n=x[E];p=new spine.FfdTimeline(n.length);A=f.getAttachment(k,E);if(!A)throw"FFD attachment not found: "+E;p.slotIndex=k;p.attachment=A;F=(t=A.type==spine.AttachmentType.mesh)?A.vertices.length:2*(A.weights.length/3);s=r=0;for(v=n.length;v>s;s++){var I,u=n[s];if(u.vertices){var J=u.vertices;I=[];I.length=F;var O=u.offset||0;w=J.length;if(1==this.scale)for(m=0;w>m;m++)I[m+
O]=J[m];else for(m=0;w>m;m++)I[m+O]=J[m]*this.scale;if(t){J=A.vertices;m=0;for(w=I.length;w>m;m++)I[m]+=J[m]}}else t?I=A.vertices:(I=[],I.length=F);p.setFrame(r,u.time,I);this.readCurve(p,r,u);r++}d[d.length]=p;e=Math.max(e,p.frames[p.frameCount-1])}}g=b.drawOrder;if(g||(g=b.draworder),g){p=new spine.DrawOrderTimeline(g.length);n=c.slots.length;s=r=0;for(v=g.length;v>s;s++){B=g[s];E=null;if(B.offsets){E=[];E.length=n;for(m=n-1;0<=m;m--)E[m]=-1;I=B.offsets;u=[];u.length=n-I.length;m=z=h=0;for(w=I.length;w>
m;m++){f=I[m];k=c.findSlotIndex(f.slot);if(-1==k)throw"Slot not found: "+f.slot;for(;h!=k;)u[z++]=h++;E[h+f.offset]=h++}for(;n>h;)u[z++]=h++;for(m=n-1;0<=m;m--)-1==E[m]&&(E[m]=u[--z])}p.setFrame(r++,B.time,E)}d.push(p);e=Math.max(e,p.frames[p.getFrameCount()-1])}if(b=b.events){p=new spine.EventTimeline(b.length);s=r=0;for(v=b.length;v>s;s++){g=b[s];n=c.findEvent(g.name);if(!n)throw"Event not found: "+g.name;B=new spine.Event(n);B.intValue=g.hasOwnProperty("int")?g["int"]:n.intValue;B.floatValue=g.hasOwnProperty("float")?
g["float"]:n.floatValue;B.stringValue=g.hasOwnProperty("string")?g.string:n.stringValue;p.setFrame(r++,g.time,B)}d.push(p);e=Math.max(e,p.frames[p.getFrameCount()-1])}c.animations.push(new spine.Animation(a,d,e))},readCurve:function(a,b,c){(c=c.curve)?"stepped"==c?a.curves.setStepped(b):c instanceof Array&&a.curves.setCurve(b,c[0],c[1],c[2],c[3]):a.curves.setLinear(b)},toColor:function(a,b){if(8!=a.length)throw"Color hexidecimal length must be 8, recieved: "+a;return parseInt(a.substring(2*b,2*b+
2),16)/255},getFloatArray:function(a,b,c){a=a[b];b=new spine.Float32Array(a.length);var d=0,e=a.length;if(1==c)for(;e>d;d++)b[d]=a[d];else for(;e>d;d++)b[d]=a[d]*c;return b},getIntArray:function(a,b){for(var c=a[b],d=new spine.Uint16Array(c.length),e=0,f=c.length;f>e;e++)d[e]=0|c[e];return d}};
spine.Atlas=function(a,b){this.textureLoader=b;this.pages=[];this.regions=[];var c=new spine.AtlasReader(a),d=[];d.length=4;for(var e=null;;){var f=c.readLine();if(null===f)break;if(f=c.trim(f),f.length)if(e){var g=new spine.AtlasRegion;g.name=f;g.page=e;g.rotate="true"==c.readValue();c.readTuple(d);var f=parseInt(d[0]),h=parseInt(d[1]);c.readTuple(d);var k=parseInt(d[0]),m=parseInt(d[1]);g.u=f/e.width;g.v=h/e.height;g.rotate?(g.u2=(f+m)/e.width,g.v2=(h+k)/e.height):(g.u2=(f+k)/e.width,g.v2=(h+m)/
e.height);g.x=f;g.y=h;g.width=Math.abs(k);g.height=Math.abs(m);4==c.readTuple(d)&&(g.splits=[parseInt(d[0]),parseInt(d[1]),parseInt(d[2]),parseInt(d[3])],4==c.readTuple(d)&&(g.pads=[parseInt(d[0]),parseInt(d[1]),parseInt(d[2]),parseInt(d[3])],c.readTuple(d)));g.originalWidth=parseInt(d[0]);g.originalHeight=parseInt(d[1]);c.readTuple(d);g.offsetX=parseInt(d[0]);g.offsetY=parseInt(d[1]);g.index=parseInt(c.readValue());this.regions.push(g)}else e=new spine.AtlasPage,e.name=f,2==c.readTuple(d)&&(e.width=
parseInt(d[0]),e.height=parseInt(d[1]),c.readTuple(d)),e.format=spine.Atlas.Format[d[0]],c.readTuple(d),e.minFilter=spine.Atlas.TextureFilter[d[0]],e.magFilter=spine.Atlas.TextureFilter[d[1]],g=c.readValue(),e.uWrap=spine.Atlas.TextureWrap.clampToEdge,e.vWrap=spine.Atlas.TextureWrap.clampToEdge,"x"==g?e.uWrap=spine.Atlas.TextureWrap.repeat:"y"==g?e.vWrap=spine.Atlas.TextureWrap.repeat:"xy"==g&&(e.uWrap=e.vWrap=spine.Atlas.TextureWrap.repeat),b.load(e,f,this),this.pages.push(e);else e=null}};
spine.Atlas.prototype={findRegion:function(a){for(var b=this.regions,c=0,d=b.length;d>c;c++)if(b[c].name==a)return b[c];return null},dispose:function(){for(var a=this.pages,b=0,c=a.length;c>b;b++)this.textureLoader.unload(a[b].rendererObject)},updateUVs:function(a){for(var b=this.regions,c=0,d=b.length;d>c;c++){var e=b[c];e.page==a&&(e.u=e.x/a.width,e.v=e.y/a.height,e.rotate?(e.u2=(e.x+e.height)/a.width,e.v2=(e.y+e.width)/a.height):(e.u2=(e.x+e.width)/a.width,e.v2=(e.y+e.height)/a.height))}}};
spine.Atlas.Format={alpha:0,intensity:1,luminanceAlpha:2,rgb565:3,rgba4444:4,rgb888:5,rgba8888:6};spine.Atlas.TextureFilter={nearest:0,linear:1,mipMap:2,mipMapNearestNearest:3,mipMapLinearNearest:4,mipMapNearestLinear:5,mipMapLinearLinear:6};spine.Atlas.TextureWrap={mirroredRepeat:0,clampToEdge:1,repeat:2};spine.AtlasPage=function(){};spine.AtlasPage.prototype={name:null,format:null,minFilter:null,magFilter:null,uWrap:null,vWrap:null,rendererObject:null,width:0,height:0};spine.AtlasRegion=function(){};
spine.AtlasRegion.prototype={page:null,name:null,x:0,y:0,width:0,height:0,u:0,v:0,u2:0,v2:0,offsetX:0,offsetY:0,originalWidth:0,originalHeight:0,index:0,rotate:!1,splits:null,pads:null};spine.AtlasReader=function(a){this.lines=a.split(/\r\n|\r|\n/)};
spine.AtlasReader.prototype={index:0,trim:function(a){return a.replace(/^\s+|\s+$/g,"")},readLine:function(){return this.index>=this.lines.length?null:this.lines[this.index++]},readValue:function(){var a=this.readLine(),b=a.indexOf(":");if(-1==b)throw"Invalid line: "+a;return this.trim(a.substring(b+1))},readTuple:function(a){var b=this.readLine(),c=b.indexOf(":");if(-1==c)throw"Invalid line: "+b;for(var d=0,c=c+1;3>d;d++){var e=b.indexOf(",",c);if(-1==e)break;a[d]=this.trim(b.substr(c,e-c));c=e+
1}return a[d]=this.trim(b.substring(c)),d+1}};spine.AtlasAttachmentLoader=function(a){this.atlas=a};
spine.AtlasAttachmentLoader.prototype={newRegionAttachment:function(a,b,c){a=this.atlas.findRegion(c);if(!a)throw"Region not found in atlas: "+c+" (region attachment: "+b+")";b=new spine.RegionAttachment(b);return b.rendererObject=a,b.setUVs(a.u,a.v,a.u2,a.v2,a.rotate),b.regionOffsetX=a.offsetX,b.regionOffsetY=a.offsetY,b.regionWidth=a.width,b.regionHeight=a.height,b.regionOriginalWidth=a.originalWidth,b.regionOriginalHeight=a.originalHeight,b},newMeshAttachment:function(a,b,c){a=this.atlas.findRegion(c);
if(!a)throw"Region not found in atlas: "+c+" (mesh attachment: "+b+")";b=new spine.MeshAttachment(b);return b.rendererObject=a,b.regionU=a.u,b.regionV=a.v,b.regionU2=a.u2,b.regionV2=a.v2,b.regionRotate=a.rotate,b.regionOffsetX=a.offsetX,b.regionOffsetY=a.offsetY,b.regionWidth=a.width,b.regionHeight=a.height,b.regionOriginalWidth=a.originalWidth,b.regionOriginalHeight=a.originalHeight,b},newSkinnedMeshAttachment:function(a,b,c){a=this.atlas.findRegion(c);if(!a)throw"Region not found in atlas: "+c+
" (skinned mesh attachment: "+b+")";b=new spine.SkinnedMeshAttachment(b);return b.rendererObject=a,b.regionU=a.u,b.regionV=a.v,b.regionU2=a.u2,b.regionV2=a.v2,b.regionRotate=a.rotate,b.regionOffsetX=a.offsetX,b.regionOffsetY=a.offsetY,b.regionWidth=a.width,b.regionHeight=a.height,b.regionOriginalWidth=a.originalWidth,b.regionOriginalHeight=a.originalHeight,b},newBoundingBoxAttachment:function(a,b){return new spine.BoundingBoxAttachment(b)}};
spine.SkeletonBounds=function(){this.polygonPool=[];this.polygons=[];this.boundingBoxes=[]};
spine.SkeletonBounds.prototype={minX:0,minY:0,maxX:0,maxY:0,update:function(a,b){for(var c=a.slots,d=c.length,e=a.x,f=a.y,g=this.boundingBoxes,h=this.polygonPool,k=this.polygons,m=g.length=0,n=k.length;n>m;m++)h.push(k[m]);for(m=k.length=0;d>m;m++){var n=c[m],p=n.attachment;if(p.type==spine.AttachmentType.boundingbox){g.push(p);var r,s=h.length;0<s?(r=h[s-1],h.splice(s-1,1)):r=[];k.push(r);r.length=p.vertices.length;p.computeWorldVertices(e,f,n.bone,r)}}b&&this.aabbCompute()},aabbCompute:function(){for(var a=
this.polygons,b=Number.MAX_VALUE,c=Number.MAX_VALUE,d=Number.MIN_VALUE,e=Number.MIN_VALUE,f=0,g=a.length;g>f;f++)for(var h=a[f],k=0,m=h.length;m>k;k+=2)var n=h[k],p=h[k+1],b=Math.min(b,n),c=Math.min(c,p),d=Math.max(d,n),e=Math.max(e,p);this.minX=b;this.minY=c;this.maxX=d;this.maxY=e},aabbContainsPoint:function(a,b){return a>=this.minX&&a<=this.maxX&&b>=this.minY&&b<=this.maxY},aabbIntersectsSegment:function(a,b,c,d){var e=this.minX,f=this.minY,g=this.maxX,h=this.maxY;if(e>=a&&e>=c||f>=b&&f>=d||a>=
g&&c>=g||b>=h&&d>=h)return!1;c=(d-b)/(c-a);d=c*(e-a)+b;if(d>f&&h>d||(d=c*(g-a)+b,d>f&&h>d))return!0;f=(f-b)/c+a;return f>e&&g>f?!0:(f=(h-b)/c+a,f>e&&g>f?!0:!1)},aabbIntersectsSkeleton:function(a){return this.minX<a.maxX&&this.maxX>a.minX&&this.minY<a.maxY&&this.maxY>a.minY},containsPoint:function(a,b){for(var c=this.polygons,d=0,e=c.length;e>d;d++)if(this.polygonContainsPoint(c[d],a,b))return this.boundingBoxes[d];return null},intersectsSegment:function(a,b,c,d){for(var e=this.polygons,f=0,g=e.length;g>
f;f++)if(e[f].intersectsSegment(a,b,c,d))return this.boundingBoxes[f];return null},polygonContainsPoint:function(a,b,c){for(var d=a.length,e=d-2,f=!1,g=0;d>g;g+=2){var h=a[g+1],k=a[e+1];if(c>h&&k>=c||c>k&&h>=c){var m=a[g];m+(c-h)/(k-h)*(a[e]-m)<b&&(f=!f)}e=g}return f},polygonIntersectsSegment:function(a,b,c,d,e){for(var f=a.length,g=b-d,h=c-e,k=b*e-c*d,m=a[f-2],n=a[f-1],p=0;f>p;p+=2){var r=a[p],s=a[p+1],v=m*s-n*r,u=m-r,t=n-s,x=g*t-h*u,u=(k*u-g*v)/x;if((u>=m&&r>=u||u>=r&&m>=u)&&(u>=b&&d>=u||u>=d&&
b>=u))if(m=(k*t-h*v)/x,(m>=n&&s>=m||m>=s&&n>=m)&&(m>=c&&e>=m||m>=e&&c>=m))return!0;m=r;n=s}return!1},getPolygon:function(a){a=this.boundingBoxes.indexOf(a);return-1==a?null:this.polygons[a]},getWidth:function(){return this.maxX-this.minX},getHeight:function(){return this.maxY-this.minY}};sp._atlasPage_createTexture_webGL=function(a,b){var c=cc.textureCache.addImage(b);a.rendererObject=new cc.TextureAtlas(c,128);a.width=c.getPixelsWide();a.height=c.getPixelsHigh()};
sp._atlasPage_createTexture_canvas=function(a,b){a._texture=cc.textureCache.addImage(b)};sp._atlasPage_disposeTexture=function(a){a.rendererObject.release()};sp._atlasLoader={spAtlasFile:null,setAtlasFile:function(a){this.spAtlasFile=a},load:function(a,b,c){b=cc.path.join(cc.path.dirname(this.spAtlasFile),b);cc._renderType===cc._RENDER_TYPE_WEBGL?sp._atlasPage_createTexture_webGL(a,b):sp._atlasPage_createTexture_canvas(a,b)},unload:function(a){}};
sp.ANIMATION_EVENT_TYPE={START:0,END:1,COMPLETE:2,EVENT:3};sp.TrackEntryListeners=function(a,b,c,d){this.startListener=a||null;this.endListener=b||null;this.completeListener=c||null;this.eventListener=d||null};sp.TrackEntryListeners.getListeners=function(a){return a.rendererObject||(a.rendererObject=new sp.TrackEntryListeners,a.listener=sp.trackEntryCallback),a.rendererObject};sp.trackEntryCallback=function(a,b,c,d,e){a.rendererObject.onTrackEntryEvent(b,c,d,e)};
sp.SkeletonAnimation=sp.Skeleton.extend({_state:null,_target:null,_callback:null,_ownsAnimationStateData:!1,_startListener:null,_endListener:null,_completeListener:null,_eventListener:null,init:function(){sp.Skeleton.prototype.init.call(this);this._ownsAnimationStateData=!0;this.setAnimationStateData(new spine.AnimationStateData(this._skeleton.data))},setAnimationStateData:function(a){a=new spine.AnimationState(a);a.rendererObject=this;a.onStart=this._onAnimationStateStart.bind(this);a.onComplete=
this._onAnimationStateComplete.bind(this);a.onEnd=this._onAnimationStateEnd.bind(this);a.onEvent=this._onAnimationStateEvent.bind(this);this._state=a},setMix:function(a,b,c){this._state.data.setMixByName(a,b,c)},setAnimationListener:function(a,b){this._target=a;this._callback=b},setAnimation:function(a,b,c){var d=this._skeleton.data.findAnimation(b);return d?this._state.setAnimation(a,d,c):(cc.log("Spine: Animation not found: "+b),null)},addAnimation:function(a,b,c,d){d=null==d?0:d;var e=this._skeleton.data.findAnimation(b);
return e?this._state.addAnimation(a,e,c,d):(cc.log("Spine: Animation not found:"+b),null)},getCurrent:function(a){return this._state.getCurrent(a)},clearTracks:function(){this._state.clearTracks()},clearTrack:function(a){this._state.clearTrack(a)},update:function(a){this._super(a);a*=this._timeScale;this._state.update(a);this._state.apply(this._skeleton);this._skeleton.updateWorldTransform();this._renderCmd._updateChild()},setStartListener:function(a){this._startListener=a},setEndListener:function(a){this._endListener=
a},setCompleteListener:function(a){this._completeListener=a},setEventListener:function(a){this._eventListener=a},setTrackStartListener:function(a,b){sp.TrackEntryListeners.getListeners(a).startListener=b},setTrackEndListener:function(a,b){sp.TrackEntryListeners.getListeners(a).endListener=b},setTrackCompleteListener:function(a,b){sp.TrackEntryListeners.getListeners(a).completeListener=b},setTrackEventListener:function(a,b){sp.TrackEntryListeners.getListeners(a).eventListener=b},onTrackEntryEvent:function(a,
b,c,d){var e=this._state.getCurrent(a);if(e.rendererObject)switch(e=e.rendererObject,b){case sp.ANIMATION_EVENT_TYPE.START:e.startListener&&e.startListener(a);break;case sp.ANIMATION_EVENT_TYPE.END:e.endListener&&e.endListener(a);break;case sp.ANIMATION_EVENT_TYPE.COMPLETE:e.completeListener&&e.completeListener(a,d);break;case sp.ANIMATION_EVENT_TYPE.EVENT:e.eventListener&&e.eventListener(a,c)}},onAnimationStateEvent:function(a,b,c,d){switch(b){case sp.ANIMATION_EVENT_TYPE.START:this._startListener&&
this._startListener(a);break;case sp.ANIMATION_EVENT_TYPE.END:this._endListener&&this._endListener(a);break;case sp.ANIMATION_EVENT_TYPE.COMPLETE:this._completeListener&&this._completeListener(a,d);break;case sp.ANIMATION_EVENT_TYPE.EVENT:this._eventListener&&this._eventListener(a,c)}},getState:function(){return this._state},_onAnimationStateStart:function(a){this._animationStateCallback(a,sp.ANIMATION_EVENT_TYPE.START,null,0)},_onAnimationStateEnd:function(a){this._animationStateCallback(a,sp.ANIMATION_EVENT_TYPE.END,
null,0)},_onAnimationStateComplete:function(a,b){this._animationStateCallback(a,sp.ANIMATION_EVENT_TYPE.COMPLETE,null,b)},_onAnimationStateEvent:function(a,b){this._animationStateCallback(a,sp.ANIMATION_EVENT_TYPE.EVENT,b,0)},_animationStateCallback:function(a,b,c,d){this.onAnimationStateEvent(a,b,c,d);this._target&&this._callback&&this._callback.call(this._target,this,a,b,c,d)}});sp.SkeletonAnimation.create=function(a,b,c){return new sp.SkeletonAnimation(a,b,c)};
(function(){sp.Skeleton.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a);this._needDraw=!0};var a=sp.Skeleton.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=sp.Skeleton.CanvasRenderCmd;a.rendering=function(a,c,d){var e,f,g,h,k=this._node;a=a||cc._renderContext;var m=k._skeleton,n=m.drawOrder;e=0;for(f=n.length;f>e;e++)g=n[e],h=g._slotNode,h._visible&&h._renderCmd&&g.currentSprite&&(h._renderCmd.transform(this,!0),g.currentSprite._renderCmd.rendering(a,
c,d),h._renderCmd._dirtyFlag=g.currentSprite._renderCmd._dirtyFlag=0);if(k._debugSlots||k._debugBones){a.setTransform(this._worldTransform,c,d);a.setGlobalAlpha(1);var p;a=cc._drawingUtil;if(k._debugSlots){a.setDrawColor(0,0,255,255);a.setLineWidth(1);c=[];e=0;for(f=m.slots.length;f>e;e++)g=m.drawOrder[e],g.attachment&&g.attachment.type==sp.ATTACHMENT_TYPE.REGION&&(p=g.attachment,this._updateRegionAttachmentSlot(p,g,c),a.drawPoly(c,4,!0))}if(k._debugBones){a.setLineWidth(2);a.setDrawColor(255,0,0,
255);e=0;for(f=m.bones.length;f>e;e++)g=m.bones[e],a.drawLine({x:g.worldX,y:g.worldY},{x:g.data.length*g.m00+g.worldX,y:g.data.length*g.m10+g.worldY});a.setPointSize(4);a.setDrawColor(0,0,255,255);e=0;for(f=m.bones.length;f>e;e++)g=m.bones[e],a.drawPoint({x:g.worldX,y:g.worldY}),0===e&&a.setDrawColor(0,255,0,255)}}};a._updateRegionAttachmentSlot=function(a,c,d){if(d){var e={},f=sp.VERTEX_INDEX;c=c.bone;a.computeVertices(c.skeleton.x,c.skeleton.y,c,e);d.length=0;d.push(cc.p(e[f.X1],e[f.Y1]));d.push(cc.p(e[f.X4],
e[f.Y4]));d.push(cc.p(e[f.X3],e[f.Y3]));d.push(cc.p(e[f.X2],e[f.Y2]))}};a._createChildFormSkeletonData=function(){for(var a,c,d=this._node._skeleton,e=0,f=d.slots.length;f>e;e++){var g=d.slots[e],h=g.attachment,k=new cc.Node;g._slotNode=k;h instanceof spine.RegionAttachment?(a=h.rendererObject.name,c=this._createSprite(g,h),g.currentSprite=c,g.currentSpriteName=a,k.addChild(c)):h instanceof spine.MeshAttachment}};a._createSprite=function(a,c){var d=c.rendererObject,e=(d.page._texture,new cc.Rect(d.x,
d.y,d.width,d.height)),f=new cc.Sprite;return f.initWithTexture(d.page._texture,e,d.rotate,!1),f._rect.width=c.width,f._rect.height=c.height,f.setContentSize(c.width,c.height),f.setRotation(-c.rotation),f.setScale(d.width/d.originalWidth*c.scaleX,d.height/d.originalHeight*c.scaleY),a.sprites=a.sprites||{},a.sprites[d.name]=f,f};a._updateChild=function(){var a,c,d,e,f,g,h=this._node._skeleton,k=h.slots;a=0;for(c=k.length;c>a;a++)if(e=k[a],f=e.attachment,g=e._slotNode,f){d=f.type;if(d===spine.AttachmentType.region){if(f.rendererObject&&
(!e.currentSpriteName||e.currentSpriteName!==f.name)){d=f.rendererObject.name;if(void 0!==e.currentSprite&&e.currentSprite.setVisible(!1),e.sprites=e.sprites||{},void 0!==e.sprites[d])e.sprites[d].setVisible(!0);else{var m=this._createSprite(e,f);g.addChild(m)}e.currentSprite=e.sprites[d];e.currentSpriteName=d}m=e.bone;g.setPosition(m.worldX+f.x*m.m00+f.y*m.m01,m.worldY+f.x*m.m10+f.y*m.m11);g.setScale(m.worldScaleX,m.worldScaleY);d=e.currentSprite;d._flippedX=m.worldFlipX;d._flippedY=m.worldFlipY;
d._flippedY||d._flippedX?(g.setRotation(m.worldRotation),d.setRotation(f.rotation)):(g.setRotation(-m.worldRotation),d.setRotation(-f.rotation));d._renderCmd._displayedOpacity=0|255*h.a*e.a;d.setColor(cc.color(0|255*h.r*e.r,0|255*h.g*e.g,0|255*h.b*e.b));d._renderCmd._updateColor()}else if(d!==spine.AttachmentType.skinnedmesh){g.setVisible(!1);continue}g.setVisible(!0)}else g.setVisible(!1)}})();
!function(){sp.Skeleton.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a);this._needDraw=!0;this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR));this._tmpQuad=new cc.V3F_C4B_T2F_Quad};var a=sp.Skeleton.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=sp.Skeleton.WebGLRenderCmd;a.rendering=function(a){var c=this._node,d=this._tmpQuad;this._shaderProgram.use();this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix);
var e=c.getColor();a=c._skeleton;a.r=e.r/255;a.g=e.g/255;a.b=e.b/255;a.a=c.getOpacity()/255;c._premultipliedAlpha&&(a.r*=a.a,a.g*=a.a,a.b*=a.a);var f,g,h,k,m,n=c._blendFunc,e=0;for(m=a.drawOrder.length;m>e;e++)if(k=a.drawOrder[e],k.attachment){switch(h=k.attachment,k.attachment.type){case sp.ATTACHMENT_TYPE.REGION:this._updateRegionAttachmentQuad(h,k,d,c._premultipliedAlpha);break;case sp.ATTACHMENT_TYPE.MESH:this._updateMeshAttachmentQuad(h,k,d,c._premultipliedAlpha);break;case sp.ATTACHMENT_TYPE.SKINNED_MESH:break;
default:continue}h=c.getTextureAtlas(h);k.data.additiveBlending!=f?(g&&(g.drawQuads(),g.removeAllQuads()),f=!f,cc.glBlendFunc(n.src,f?cc.ONE:n.dst)):h!=g&&g&&(g.drawQuads(),g.removeAllQuads());g=h;h=g.getTotalQuads();if(g.getCapacity()==h&&(g.drawQuads(),g.removeAllQuads(),!g.resizeCapacity(2*g.getCapacity())))return;g.updateQuad(d,h)}if(g&&(g.drawQuads(),g.removeAllQuads()),c._debugBones||c._debugSlots){cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);cc.current_stack.stack.push(cc.current_stack.top);cc.current_stack.top=
this._stackMatrix;f=cc._drawingUtil;if(c._debugSlots){f.setDrawColor(0,0,255,255);f.setLineWidth(1);e=0;for(m=a.slots.length;m>e;e++)if(k=a.drawOrder[e],k.attachment&&k.attachment.type==sp.ATTACHMENT_TYPE.REGION)h=k.attachment,this._updateRegionAttachmentQuad(h,k,d),g=[],g.push(cc.p(d.bl.vertices.x,d.bl.vertices.y)),g.push(cc.p(d.br.vertices.x,d.br.vertices.y)),g.push(cc.p(d.tr.vertices.x,d.tr.vertices.y)),g.push(cc.p(d.tl.vertices.x,d.tl.vertices.y)),f.drawPoly(g,4,!0)}if(c._debugBones){f.setLineWidth(2);
f.setDrawColor(255,0,0,255);e=0;for(m=a.bones.length;m>e;e++)k=a.bones[e],c=k.data.length*k.m00+k.worldX,d=k.data.length*k.m10+k.worldY,f.drawLine(cc.p(k.worldX,k.worldY),cc.p(c,d));f.setPointSize(4);f.setDrawColor(0,0,255,255);e=0;for(m=a.bones.length;m>e;e++)k=a.bones[e],f.drawPoint(cc.p(k.worldX,k.worldY)),0==e&&f.setDrawColor(0,255,0,255)}cc.kmGLPopMatrix()}};a._createChildFormSkeletonData=function(){};a._updateChild=function(){};a._updateRegionAttachmentQuad=function(a,c,d,e){var f={};a.computeVertices(c.bone.skeleton.x,
c.bone.skeleton.y,c.bone,f);var g=255*c.bone.skeleton.r*c.r,h=255*c.bone.skeleton.g*c.g,k=255*c.bone.skeleton.b*c.b;c=c.bone.skeleton.a*c.a;e&&(g*=c,h*=c,k*=c);d.bl.colors.r=d.tl.colors.r=d.tr.colors.r=d.br.colors.r=g;d.bl.colors.g=d.tl.colors.g=d.tr.colors.g=d.br.colors.g=h;d.bl.colors.b=d.tl.colors.b=d.tr.colors.b=d.br.colors.b=k;d.bl.colors.a=d.tl.colors.a=d.tr.colors.a=d.br.colors.a=255*c;e=sp.VERTEX_INDEX;d.bl.vertices.x=f[e.X1];d.bl.vertices.y=f[e.Y1];d.tl.vertices.x=f[e.X2];d.tl.vertices.y=
f[e.Y2];d.tr.vertices.x=f[e.X3];d.tr.vertices.y=f[e.Y3];d.br.vertices.x=f[e.X4];d.br.vertices.y=f[e.Y4];d.bl.texCoords.u=a.uvs[e.X1];d.bl.texCoords.v=a.uvs[e.Y1];d.tl.texCoords.u=a.uvs[e.X2];d.tl.texCoords.v=a.uvs[e.Y2];d.tr.texCoords.u=a.uvs[e.X3];d.tr.texCoords.v=a.uvs[e.Y3];d.br.texCoords.u=a.uvs[e.X4];d.br.texCoords.v=a.uvs[e.Y4]};a._updateMeshAttachmentQuad=function(a,c,d,e){var f={};a.computeWorldVertices(c.bone.x,c.bone.y,c,f);var g=255*c.bone.skeleton.r*c.r,h=255*c.bone.skeleton.g*c.g,k=255*
c.bone.skeleton.b*c.b;c=c.bone.skeleton.a*c.a;e&&(g*=c,h*=c,k*=c);d.bl.colors.r=d.tl.colors.r=d.tr.colors.r=d.br.colors.r=g;d.bl.colors.g=d.tl.colors.g=d.tr.colors.g=d.br.colors.g=h;d.bl.colors.b=d.tl.colors.b=d.tr.colors.b=d.br.colors.b=k;d.bl.colors.a=d.tl.colors.a=d.tr.colors.a=d.br.colors.a=255*c;e=sp.VERTEX_INDEX;d.bl.vertices.x=f[e.X1];d.bl.vertices.y=f[e.Y1];d.tl.vertices.x=f[e.X2];d.tl.vertices.y=f[e.Y2];d.tr.vertices.x=f[e.X3];d.tr.vertices.y=f[e.Y3];d.br.vertices.x=f[e.X4];d.br.vertices.y=
f[e.Y4];d.bl.texCoords.u=a.uvs[e.X1];d.bl.texCoords.v=a.uvs[e.Y1];d.tl.texCoords.u=a.uvs[e.X2];d.tl.texCoords.v=a.uvs[e.Y2];d.tr.texCoords.u=a.uvs[e.X3];d.tr.texCoords.v=a.uvs[e.Y3];d.br.texCoords.u=a.uvs[e.X4];d.br.texCoords.v=a.uvs[e.Y4]}}();
!function(){gaf.Sprite.WebGLRenderCmd=function(a){cc.Sprite.WebGLRenderCmd.call(this,a);this._defualtShader=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);this._customShader=gaf._Shaders.Alpha;this._ctxMatrixAppendix=this._ctxMatrixBody=this._tintOffset=this._tintMult=null};var a=gaf.Sprite.WebGLRenderCmd.prototype=Object.create(cc.Sprite.WebGLRenderCmd.prototype);a.constructor=gaf.Sprite.WebGLRenderCmd;a._identityVec=[1,1,1,1];a._zeroVec=[0,0,0,0];a._identityMat=[1,0,0,0,0,1,0,0,0,
0,1,0,0,0,0,1];a._disableCtx=function(){this.setShaderProgram(this._defualtShader)};a._enableCtx=function(){this.setShaderProgram(this._customShader)};a._applyCtxState=function(a){var c=a._cascadeColorMult;this._tintMult=[c.r/255,c.g/255,c.b/255,c.a/255];c=a._cascadeColorOffset;this._tintOffset=[c.r/255,c.g/255,c.b/255,c.a/255];(a=a._filterStack)&&0<a.length&&a[0].type===gaf.EFFECT_COLOR_MATRIX?(a=a[0].colorMatrix,this._ctxMatrixBody=[a.rr,a.rg,a.rb,a.ra,a.gr,a.gg,a.gb,a.ga,a.br,a.bg,a.bb,a.ba,a.ar,
a.ag,a.ab,a.aa],this._ctxMatrixAppendix=[a.r/255,a.g/255,a.b/255,a.a/255]):this._ctxMatrixAppendix=this._ctxMatrixBody=null};a._setUniforms=function(){this._shaderProgram===this._customShader&&(this._shaderProgram.use(),this._shaderProgram.setUniformLocationWith4fv(gaf._Uniforms.ColorTransformMult,this._tintMult,1),this._shaderProgram.setUniformLocationWith4fv(gaf._Uniforms.ColorTransformOffset,this._tintOffset,1),this._ctxMatrixBody&&this._ctxMatrixAppendix?(this._shaderProgram.setUniformLocationWithMatrix4fv(gaf._Uniforms.ColorMatrixBody,
this._ctxMatrixBody,1),this._shaderProgram.setUniformLocationWith4fv(gaf._Uniforms.ColorMatrixAppendix,this._ctxMatrixAppendix,1)):(this._shaderProgram.setUniformLocationWithMatrix4fv(gaf._Uniforms.ColorMatrixBody,this._identityMat,1),this._shaderProgram.setUniformLocationWith4fv(gaf._Uniforms.ColorMatrixAppendix,this._zeroVec,1)))};a.rendering=function(a){this._setUniforms();cc.Sprite.WebGLRenderCmd.prototype.rendering.call(this,a)}}();var res={how_to_play_1:"res/tutorial/howTo_1.png",how_to_play_2:"res/tutorial/howTo_2.png",how_to_play_3:"res/tutorial/howTo_3.png",font_png:"res/font/pjyieldW.png",font_fnt:"res/font/pjyieldW.fnt",scoreFont_png:"res/font/pjyieldW_score.png",scoreFont_fnt:"res/font/pjyieldW_score.fnt",title_png:"res/titleScreen/titleScreen.png",results_png:"res/resultsScreen/resultsScreen.png",player_plist:"res/anim/player.plist",player_png:"res/anim/player.png",amonson_plist:"res/anim/amonson.plist",amonson_png:"res/anim/amonson.png",
enemy_plist:"res/anim/enemy.plist",enemy_png:"res/anim/enemy.png",stromulex_plist:"res/anim/stromulex.plist",stromulex_png:"res/anim/stromulex.png",avere_plist:"res/anim/avere.plist",avere_png:"res/anim/avere.png",blackyard_plist:"res/anim/blackyard.plist",blackyard_png:"res/anim/blackyard.png",grindiok_plist:"res/anim/grindiok.plist",grindiok_png:"res/anim/grindiok.png",ui_plist:"res/ui/ui.plist",ui_png:"res/ui/ui.png",fx_plist:"res/fx/fx1.plist",fx_png:"res/fx/fx1.png",fx2_plist:"res/fx/fx2.plist",
fx2_png:"res/fx/fx2.png",misc_plist:"res/misc/misc.plist",misc_png:"res/misc/misc.png",bg1_png:"res/bg/bg_1.png",bg2_png:"res/bg/bg_2.png",bg3_png:"res/bg/bg_3.png",clockTickL_mp3:"res/sounds/clockTickL.mp3",clockTickH_mp3:"res/sounds/clockTickH.mp3",charge_mp3:"res/sounds/charge.mp3",chargeAttack_mp3:"res/sounds/chargeAttack.mp3",chargeCounter_mp3:"res/sounds/chargeCounter.mp3",click_mp3:"res/sounds/charge.mp3",cardForm_mp3:"res/sounds/cardForm.mp3",enemyDefeat_mp3:"res/sounds/enemyDefeat.mp3",hiroAttack_mp3:"res/sounds/hiroAttack.mp3",
hiroCounter_mp3:"res/sounds/hiroCounter.mp3",avereAttack_mp3:"res/sounds/avereAttack.mp3",castillanAttack_mp3:"res/sounds/castillanAttack.mp3",genericAttack_mp3:"res/sounds/genericAttack.mp3",bgMusic_mp3:"res/sounds/bgMusic.mp3",block_mp3:"res/sounds/block.mp3",countEntrance_mp3:"res/sounds/countdownEntrance.mp3",countExit_mp3:"res/sounds/countdownExit.mp3",versus_mp3:"res/sounds/versus.mp3",charity_mp3:"res/sounds/charity.mp3",hiroEntrance_mp3:"res/sounds/hiroEntrance.mp3",john_mp3:"res/sounds/john.mp3",
max_mp3:"res/sounds/max.mp3",rogerson_mp3:"res/sounds/rogerson.mp3",zabooninin_mp3:"res/sounds/zabooninin.mp3",hit_mp3:"res/sounds/hit.mp3"},g_resources=[];for(i in res)g_resources.push(res[i]);var Preloader=cc.Scene.extend({_interval:null,_label:null,_className:"PreloaderScene",_layerBgBar:null,_layerBar:null,ctor:function(){this._super();cc._loaderImage="data:image/png;base64, "},
init:function(){var a=this,b=cc.color(6,0,68,255),c=cc.color(134,48,148,255),d=a._bgLayer=new cc.LayerColor(cc.color(255,255,255,255));a.addChild(d,0);var e=180;cc._loaderImage&&cc.loader.loadImg(cc._loaderImage,{isCrossOrigin:!1},function(b,c){e=c.height;a._initStage(c,cc.visibleRect.center)});d=a._label=new cc.LabelTTF("LOADING","Arial",25);d.setPosition(cc.pAdd(cc.visibleRect.center,cc.p(0,-e)));d.setColor(cc.color(255,255,255));d.enableShadow(0,-1,255,2);a.addChild(this._label,10);this._layerBgBar=
new cc.LayerColor(b,500,40);this._layerBgBar.setPosition(cc.pAdd(cc.visibleRect.center,cc.p(0,-e)));this._layerBgBar.setAnchorPoint(0.5,0.5);this._layerBgBar.ignoreAnchorPointForPosition(!1);a.addChild(this._layerBgBar,0);this._layerBar=new cc.LayerColor(c,500,40);this._layerBar.setPosition(0,0);this._layerBar.setAnchorPoint(0,0.5);this._layerBgBar.addChild(this._layerBar,0);this._layerBar.setScaleX(0);return!0},_initStage:function(a,b){var c=this._texture2d=new cc.Texture2D;c.initWithElement(a);
c.handleLoadedTexture();c=this._logo=new cc.Sprite(c);c.setScale(cc.contentScaleFactor());c.x=b.x;c.y=b.y;this._bgLayer.addChild(c,10)},onEnter:function(){cc.Node.prototype.onEnter.call(this);this.schedule(this._startLoading,0.3)},onExit:function(){cc.Node.prototype.onExit.call(this);this._label.setString("LOADING")},initWithResources:function(a,b){cc.isString(a)&&(a=[a]);this.resources=a||[];this.cb=b},_startLoading:function(){var a=this;a.unschedule(a._startLoading);cc.loader.load(a.resources,function(b,
c,d){a._layerBar.setScaleX(Math.min(d/c,1));Math.min(100*(d/c)|0,100)},function(){a.cb&&a.cb()})}});Preloader.preload=function(a,b){var c=cc;c.loaderScene||(c.loaderScene=new Preloader,c.loaderScene.init());c.loaderScene.initWithResources(a,b);cc.director.runScene(c.loaderScene);return c.loaderScene};cc.game.onStart=function(){cc.view.adjustViewPort(!0);cc.view.setDesignResolutionSize(GC.SCREEN.SIZE.WIDTH,GC.SCREEN.SIZE.HEIGHT,cc.ResolutionPolicy.SHOW_ALL);cc.view.resizeWithBrowserSize(!0);Preloader.preload(g_resources,function(){var a=new MainMenuScene;cc.director.runScene(new cc.TransitionFade(1,a))},this)};cc.game.run();function reload(){GC.RESTARTING=1;GC.PAUSED&&resume();var a=new GameplayScene;cc.director.runScene(new cc.TransitionMoveInR(0.5,a))}function pause(){GC.PAUSED=1;cc.director.pause()}function resume(){GC.PAUSED=0;cc.director.resume()}function mute(){GC.ENABLE_SFX=0;cc.audioEngine.setMusicVolume(0);cc.audioEngine.setEffectsVolume(0)}function unmute(){GC.ENABLE_SFX=1;cc.audioEngine.setMusicVolume(1);cc.audioEngine.setEffectsVolume(1)}
function submitRank(a){if(a>=GC.CN_RANK.NONE||a<=GC.CN_RANK.OUTSTANDING)location.href="cnwap://userperform:"+a}var mobile=!1;function onMobile(){mobile=!0};var GC=GC||{};GC.DEBUG={SWITCH:0,GOD_MODE:0};GC.PAUSED=0;GC.RESTARTING=0;GC.ENABLE_SFX=1;GC.HOW_TO_PLAY_PAGE={ONE:1,TWO:2,THREE:3,COUNT:3};GC.SCREEN={SIZE:{WIDTH:1366,HEIGHT:768},CENTER:{X:683,Y:384}};GC.GAME_OVER_ASSETS={ENEMIES:{X:335,Y:77},HIGH:{X:320,Y:-134},YOUR:{X:250,Y:-84},REPLAY:{X:250,Y:-250}};GC.SWIPE_THRESHOLD=50;GC.SCORE=0;GC.UNIQUE_SCORE_KEY="cnsuwys_high_score";var Tools=Tools||{};Tools.random=function(a,b){return Math.round(Math.random()*(b-a)+a)};Tools.createAnimation=function(a,b,c,d,e){for(var f=[];c<d;c++){frameName=10>c?a+b+"_00"+c+".png":a+b+"_0"+c+".png";var g=cc.spriteFrameCache.getSpriteFrame(frameName),h=new cc.AnimationFrame;h.initWithSpriteFrame(g,1,null);f.push(h)}a=new cc.Animation(f,e);return new cc.Animate(a)};
Tools.createFramesAnimation=function(a,b,c,d){var e=[];if(c<d)for(;c<=d;c++){var f=cc.spriteFrameCache.getSpriteFrame(a+c+".png");e.push(f)}else for(;c>=d;c--)f=cc.spriteFrameCache.getSpriteFrame(a+c+".png"),e.push(f);return cc.animate(new cc.Animation(e,b))};Tools.circlesIntersect=function(a,b){return cc.pDist(ob1.getPosition(),ob2.getPosition())<a.radius()+b.radius()};Tools.rectsIntersect=function(a,b){var c=a.collideRect(),d=b.collideRect();return cc.rectIntersectsRect(c,d)};
Tools.createCollider=function(a,b,c){a=new cc.DrawNode;var d=cc.p(0,0);b=cc.p(b,c);a.drawRect(d,b,cc.color(255,255,255,64));return a};Tools.createText=function(a,b,c,d,e,f,g){f=new cc.LabelBMFont(f,g);f.setPosition(b,c);f.setScale(d);f.setAnchorPoint(e);a.addChild(f,4);return f};Tools.createSprite=function(a,b,c,d,e,f){b=new cc.Sprite(b);b.setScale(d);b.setAnchorPoint(e);b.setPosition(c);a.addChild(b,f);return b};Tools.getRandomInt=function(a,b){return Math.floor(Math.random()*(b-a+1))+a};
Tools.getRandomIntWithException=function(a){a=a||{};var b=a.exempt||null,c=a.maxNumber||0;a=a.minNumber||0;var d=Math.floor(Math.random()*(c-a+1))+a;if(null!=b){b=b.toString();for(i=0;i<=c;i++)if(-1!=b.search(d))return Tools.getRandomIntWithException({exempt:b,maxNumber:c,minNumber:a})}return d};var LAYER={background:0,foreground:1,player:2,enemy:2,ui:3,progress:4,text:4,button:4,effects:5},ACTIONS=["none","attack","chargeAttack","chargeCounter","counter"],PLAYER_LIFE=[75,240,495,840,1250],PLAYER_BUTTONS=["#ui_btnAtkG.png","#ui_btnChAtk.png","#ui_btnChCtr.png","#ui_btnCtrG.png"],ANIMATIONS={player:{idle:0,attack:0,block:0,charge:0,hit:0},enemy:{attack:0,block:0,charge:0,hit:0}},ENEMY=["PrinceCastillan","Stromulex","Avere","KingBlackyard","Grindiok"],ENEMY_PNG=["castellan.png","stromulex.png",
"avere.png","blackyard.png","grindiok.png"];ENEMY_TAG=["tag_castillan.png","tag_stromulex.png","tag_avere.png","tag_blackyard.png","tag_grindiok.png"];ENEMY_ICON=["ui_iconCastillan.png","ui_iconStromulex.png","ui_iconAvere.png","ui_iconBlackyard.png","ui_iconGrindiok.png"];ENEMY_LIFE=[50,60,70,80,90,200,220,240,260,280,450,480,510,540,570,800,840,880,920,960,1250,1300,1350,1400,1450];ENEMY_DAMAGE=[5,10,15,20,25];POTION=[25,60,105,160,225];POTION_ADD=[10,20,30,40,50];BOONS=["potion","charge","blank"];
POTION_BONUS=[25,30,35];ALIAS={attack:"Atk",counter:"Ctr",chargeAttack:"ChAtk",chargeCounter:"ChCtr"};COLOR={RED:cc.color(255,0,0),GREEN:cc.color(0,255,0),BLUE:cc.color(0,0,255)};GAME={active:0,paused:1,preGame:2};STAGE=TIER=LEVEL=0;GAME_STATUS=PREV_PLAYER_ACTION=void 0;TIMER_SPEED=25;function reset(){STAGE=TIER=LEVEL=0;GAME_STATUS=PREV_PLAYER_ACTION=void 0;TIMER_SPEED=25}
function shake(){g_sharedGameplayLyr.backgroundFactory.blink();g_sharedGameplayLyr.runAction(cc.Spawn.create(cc.Sequence.create(cc.moveBy(0.1,5,5),cc.moveBy(0.1,-5,-5),cc.moveBy(0.1,5,5),cc.moveBy(0.1,-5,-5))));g_sharedHUDLyr.runAction(cc.Sequence.create(cc.moveBy(0.1,10,10),cc.moveBy(0.1,-10,-10),cc.moveBy(0.1,10,10),cc.moveBy(0.1,-10,-10)))}function blink(){g_sharedHUDLyr.whiteOverlay.runAction(cc.sequence(cc.fadeIn(0.1),cc.fadeOut(0.1)))}
function enemyShuffle(){for(var a=[],b={exempt:null,maxNumber:4,minNumber:0},c,d,e=0;e<ENEMY.length;e++)c=Tools.getRandomIntWithException(b),d=ENEMY[c],ENEMY[c]=ENEMY[e],ENEMY[e]=d,d=ENEMY_PNG[c],ENEMY_PNG[c]=ENEMY_PNG[e],ENEMY_PNG[e]=d,d=ENEMY_TAG[c],ENEMY_TAG[c]=ENEMY_TAG[e],ENEMY_TAG[e]=d,d=ENEMY_ICON[c],ENEMY_ICON[c]=ENEMY_ICON[e],ENEMY_ICON[e]=d,a.push(c),b.imExempt=a}function playSoundEffect(a){cc.audioEngine.playEffect(a)};var DraggingListener=cc.EventListener.create({event:cc.EventListener.TOUCH_ONE_BY_ONE,swallowTouches:!0,onTouchBegan:function(a,b){var c=b.getCurrentTarget(),d=c.convertToNodeSpace(a.getLocation()),e=c.getContentSize(),e=cc.rect(0,0,e.width,e.height);return cc.rectContainsPoint(e,d)?(cc.log("sprite began... x \x3d "+d.x+", y \x3d "+d.y),c.opacity=180,!0):!1},onTouchMoved:function(a,b){var c=b.getCurrentTarget(),d=a.getDelta();c.x+=d.x;c.y+=d.y},onTouchEnded:function(a,b){var c=b.getCurrentTarget();
cc.log("sprite onTouchesEnded.. ");c.setOpacity(255)}}),GestureListener=cc.EventListener.create({event:cc.EventListener.TOUCH_ALL_AT_ONCE,swallowTouches:!0,onTouchesBegan:function(a,b){cc.log("Touch Began");var c=a[0].getLocation();self.touchStartPoint={x:c.x,y:c.y};self.touchLastPoint={x:c.x,y:c.y}},onTouchesMoved:function(a,b){cc.log("Touch moving");var c=a[0].getLocation(),d=self.touchStartPoint;c.x<d.x-GC.SWIPE_THRESHOLD&&(c.x>self.touchLastPoint.x?(d=self.touchStartPoint={x:c.x,y:c.y},self.isSwipeLeft=
!1):self.isSwipeLeft=!0);c.x>d.x+GC.SWIPE_THRESHOLD&&(c.x<self.touchLastPoint.x?(self.touchStartPoint={x:c.x,y:c.y},self.isSwipeRight=!1):self.isSwipeRight=!0);c.y<d.y-GC.SWIPE_THRESHOLD&&(c.y>self.touchLastPoint.y?(self.touchStartPoint={x:c.x,y:c.y},self.isSwipeDown=!1):self.isSwipeDown=!0);c.y>d.y+GC.SWIPE_THRESHOLD&&(c.y<self.touchLastPoint.y?(self.touchStartPoint={x:c.x,y:c.y},self.isSwipeUp=!1):self.isSwipeUp=!0);self.touchLastPoint={x:c.x,y:c.y}},onTouchesEnded:function(a,b){cc.log("Touch ended");
b.getCurrentTarget();var c=a[0].getLocation();self.touchStartPoint=null;!self.isSwipeUp&&(!self.isSwipeLeft&&!self.isSwipeRight&&!self.isSwipeDown)&&(c.y>0.25*GC.SCREEN.SIZE.HEIGHT&&c.y<0.75*GC.SCREEN.SIZE.HEIGHT?c.x<0.5*GC.SCREEN.SIZE.WIDTH?self.isTouchLeft=!0:self.isTouchRight=!0:c.y>0.75*GC.SCREEN.SIZE.HEIGHT?self.isTouchUp=!0:self.isTouchDown=!0);self.isSwipeUp=self.isSwipeLeft=self.isSwipeRight=self.isSwipeDown=!1}}),KeyListener=cc.EventListener.create({event:cc.EventListener.TOUCH_ALL_AT_ONCE,
onKeyReleased:function(a,b){a==cc.KEY.r?(cc.log("Reload"),reload()):a==cc.KEY.space?GC.PAUSED?(cc.log("Resume"),resume()):(cc.log("Pause"),pause()):a==cc.KEY.m&&(GC.ENABLE_SFX?(cc.log("Mute"),mute()):(cc.log("Unmute"),unmute()))}}),TapListener=cc.EventListener.create({event:cc.EventListener.TOUCH_ALL_AT_ONCE,onTouchesBegan:function(a,b){var c=b.getCurrentTarget(),d=c.convertToNodeSpace(a[0].getLocation()),c=c.getContentSize(),c=cc.rect(0,0,c.width,c.height);cc.rectContainsPoint(c,d)&&(GAME_STATUS==
GAME.preGame?(cc.audioEngine.setEffectsVolume(0),playSoundEffect(res.clockTickL_mp3),g_sharedMiscFactory.preGameAnimate()):g_sharedGameplayLyr.checkButtonPress(d))}});var BackgroundFactory=cc.Node.extend({background:void 0,bgList:[res.bg1_png,res.bg2_png,res.bg3_png],bgCount:void 0,ctor:function(){this._super();return!0},generateBG:function(){this.bgCount=Tools.getRandomInt(0,this.bgList.length-1);background=sprite=Tools.createSprite(this,this.bgList[0],cc.p(0.5*GC.SCREEN.SIZE.WIDTH,0.5*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);2==this.bgCount?this.bgCount=0:this.bgCount++},switchBG:function(){background.runAction(cc.sequence(cc.fadeOut(0.5),cc.callFunc(function(a){a.setTexture(this.bgList[this.bgCount]);
2==this.bgCount?this.bgCount=0:this.bgCount++},this),cc.fadeIn(0.5)))},blink:function(){background.runAction(cc.sequence(cc.tintTo(0.1,50,50,50),cc.tintTo(0.1,255,255,255)))},destroy:function(){this.cleanup();this.removeFromParent()}});BackgroundFactory.create=function(){var a=new BackgroundFactory;g_sharedGameplayLyr.addChild(a,LAYER.background);return a};var TextFactory=cc.Node.extend({playerLife:void 0,enemyLife:void 0,playerMove:void 0,enemyMove:void 0,potionIndicator:void 0,damage:void 0,damageAlt:void 0,playerCharge:void 0,enemyCharge:void 0,potionBoon:void 0,level:void 0,levelComplete:void 0,timer:void 0,val:void 0,enemyName:void 0,ctor:function(){this._super();this.init();return!0},init:function(){playerLife=Tools.createText(this,0.38*GC.SCREEN.SIZE.WIDTH,0.97*GC.SCREEN.SIZE.HEIGHT,0.7,cc.p(0.5,0.5),"75/75",res.font_fnt);this.playerMove=Tools.createText(this,
0.315*GC.SCREEN.SIZE.WIDTH,0.08*GC.SCREEN.SIZE.HEIGHT,0.65,cc.p(0.5,0.5),"???",res.font_fnt);enemyLife=Tools.createText(this,0.62*GC.SCREEN.SIZE.WIDTH,0.97*GC.SCREEN.SIZE.HEIGHT,0.7,cc.p(0.5,0.5),"50/50",res.font_fnt);this.enemyMove=Tools.createText(this,0.685*GC.SCREEN.SIZE.WIDTH,0.08*GC.SCREEN.SIZE.HEIGHT,0.65,cc.p(0.5,0.5),"thinking...",res.font_fnt);this.damage=Tools.createText(this,0.62*GC.SCREEN.SIZE.WIDTH,0.83*GC.SCREEN.SIZE.HEIGHT,1.3,cc.p(0.5,0.5),"0",res.font_fnt);this.damage.setOpacity(0);
this.damage.setColor(cc.color(250,51,51,255));this.damageAlt=Tools.createText(this,0.62*GC.SCREEN.SIZE.WIDTH,0.83*GC.SCREEN.SIZE.HEIGHT,1.3,cc.p(0.5,0.5),"0",res.font_fnt);this.damageAlt.setOpacity(0);this.damageAlt.setColor(cc.color(250,51,51,255));this.timer=Tools.createText(this,0.501*GC.SCREEN.SIZE.WIDTH,0.043*GC.SCREEN.SIZE.HEIGHT,1.1,cc.p(0.5,0.5),"3",res.font_fnt);this.level=Tools.createText(this,0.5*GC.SCREEN.SIZE.WIDTH,0.823*GC.SCREEN.SIZE.HEIGHT,0.8,cc.p(0.5,0.5),"1",res.font_fnt);this.potionIndicator=
Tools.createText(this,0.15*GC.SCREEN.SIZE.WIDTH,0.3*GC.SCREEN.SIZE.HEIGHT,1,cc.p(0.5,0.5),"+15",res.font_fnt);this.potionIndicator.setOpacity(0);this.potionIndicator.setColor(cc.color(60,194,129,255));this.playerCharge=Tools.createText(this,0.4*GC.SCREEN.SIZE.WIDTH,0.3*GC.SCREEN.SIZE.HEIGHT,1,cc.p(0.5,0.5),"+15",res.font_fnt);this.playerCharge.setOpacity(0);this.playerCharge.setColor(cc.color(67,231,221,255));this.enemyCharge=Tools.createText(this,0.6*GC.SCREEN.SIZE.WIDTH,0.3*GC.SCREEN.SIZE.HEIGHT,
1,cc.p(0.5,0.5),"+15",res.font_fnt);this.enemyCharge.setOpacity(0);this.enemyCharge.setColor(cc.color(67,231,221,255));Tools.createText(this,0.353*GC.SCREEN.SIZE.WIDTH,0.855*GC.SCREEN.SIZE.HEIGHT,0.58,cc.p(0.5,0.5),"Hiro and Amonsun",res.font_fnt);this.enemyName=Tools.createText(this,0.65*GC.SCREEN.SIZE.WIDTH,0.855*GC.SCREEN.SIZE.HEIGHT,0.58,cc.p(0.5,0.5),"Hiro and Amonsun",res.font_fnt)},setPlayerLife:function(a,b){playerLife.setString(a+"/"+b)},setPlayerMove:function(a){this.playerMove.setString(a)},
setEnemyLife:function(a,b){enemyLife.setString(a+"/"+b)},setEnemyMove:function(a){this.enemyMove.setString(a)},setEnemyName:function(a){this.enemyName.setString(a)},setLevel:function(a){this.level.setString(a)},enemyMoveTick:function(){this.enemyMove.runAction(cc.sequence(cc.delayTime(0.8),cc.callFunc(function(){this.setEnemyMove("thinking.")},this),cc.delayTime(0.8),cc.callFunc(function(){this.setEnemyMove("thinking..")},this),cc.delayTime(0.8),cc.callFunc(function(){this.setEnemyMove("thinking...")},
this)))},showDamage:function(a,b){this.damage.setString("-"+a);this.damage.setPosition(b);this.damage.runAction(cc.sequence(cc.spawn(cc.fadeIn(0.3),cc.moveBy(0.3,0,-150)),cc.moveBy(0.2,0,50).easing(cc.easeIn(0.5)),cc.moveBy(0.2,0,-50).easing(cc.easeOut(0.5)),cc.moveBy(0.2,0,15).easing(cc.easeIn(0.5)),cc.moveBy(0.2,0,-15).easing(cc.easeOut(0.5)),cc.fadeOut(0.25)))},showDamageAlt:function(a,b){this.damageAlt.setString("-"+a);this.damageAlt.setPosition(b);this.damageAlt.runAction(cc.sequence(cc.spawn(cc.fadeIn(0.3),
cc.moveBy(0.3,0,-150)),cc.moveBy(0.2,0,50).easing(cc.easeIn(0.5)),cc.moveBy(0.2,0,-50).easing(cc.easeOut(0.5)),cc.moveBy(0.2,0,15).easing(cc.easeIn(0.5)),cc.moveBy(0.2,0,-15).easing(cc.easeOut(0.5)),cc.fadeOut(0.25)))},showPotion:function(a){this.potionIndicator.setString("+"+a+" health");this.potionIndicator.runAction(cc.sequence(cc.spawn(cc.sequence(cc.fadeIn(0.3),cc.fadeOut(0.7)),cc.moveBy(1,0,100).easing(cc.easeIn(0.5))),cc.callFunc(function(a){a.setPosition(cc.p(a.x,0.3*GC.SCREEN.SIZE.HEIGHT))},
this)))},showPlayerCharge:function(a,b){"atk"==b?this.playerCharge.setString("+"+a+" attack"):"ctr"==b?this.playerCharge.setString("+"+a+" counter"):this.playerCharge.setString("+"+a+" Atk/Ctr");this.playerCharge.runAction(cc.sequence(cc.spawn(cc.sequence(cc.fadeIn(0.3),cc.fadeOut(0.7)),cc.moveBy(1,0,100).easing(cc.easeIn(0.5))),cc.callFunc(function(a){a.setPosition(cc.p(a.x,0.3*GC.SCREEN.SIZE.HEIGHT))},this)))},showEnemyCharge:function(a,b){"atk"==b?this.enemyCharge.setString("+"+a+" attack"):this.enemyCharge.setString("+"+
a+" counter");this.enemyCharge.runAction(cc.sequence(cc.spawn(cc.sequence(cc.fadeIn(0.3),cc.fadeOut(0.7)),cc.moveBy(1,0,100).easing(cc.easeIn(0.5))),cc.callFunc(function(a){a.setPosition(cc.p(a.x,0.3*GC.SCREEN.SIZE.HEIGHT))},this)))},setTimer:function(a){0>a&&(a=0);this.timer.setString(a)},timerPulse:function(){this.timer.runAction(cc.repeatForever(cc.sequence(cc.scaleTo(0.1,1.2),cc.scaleTo(0.1,1.1).easing(cc.easeOut(0.5)),cc.delayTime(0.65))))},destroySpecific:function(a){a.cleanup();a.removeFromParent()},
destroy:function(){this.cleanup();this.removeFromParent()}});TextFactory.create=function(){var a=new TextFactory;g_sharedHUDLyr.addChild(a);return a};var UIFactory=cc.SpriteBatchNode.extend({enemyImg:void 0,playerMoveIcon:void 0,playerMoveCharge:void 0,enemyMoveIcon:void 0,enemyMoveCharge:void 0,enemyIcon:void 0,timer:void 0,actionList:[],timerCounter:3,ctor:function(a){this._super(a);return!0},init:function(){this.generateContainers()},generateContainers:function(){var a=Tools.createSprite(this,"#ui_topbar.png",cc.p(0.5*GC.SCREEN.SIZE.WIDTH,0.92*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);Tools.createSprite(this,"#ui_btnHolder.png",cc.p(0.314*GC.SCREEN.SIZE.WIDTH,
0.15*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);Tools.createSprite(this,"#ui_nameContainer.png",cc.p(0.352*GC.SCREEN.SIZE.WIDTH,0.845*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);Tools.createSprite(this,"#ui_levelContainer.png",cc.p(0.5*GC.SCREEN.SIZE.WIDTH,0.81*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);Tools.createSprite(this,"#ui_enemyHolder.png",cc.p(0.685*GC.SCREEN.SIZE.WIDTH,0.152*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);this.enemyIcon=a=Tools.createSprite(this,"#"+ENEMY_ICON[STAGE],cc.p(0.529*
GC.SCREEN.SIZE.WIDTH,0.922*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);this.timer=a=Tools.createSprite(this,"#ui_timerTick_3.png",cc.p(0.5*GC.SCREEN.SIZE.WIDTH,0.05*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);a=new cc.Sprite("#ui_nameContainer.png");a.setAnchorPoint(0.5,0.5);a.setFlippedX(!0);a.setPosition(0.65*GC.SCREEN.SIZE.WIDTH,0.845*GC.SCREEN.SIZE.HEIGHT);this.addChild(a)},changeEnemyIcon:function(){this.enemyIcon.setSpriteFrame(ENEMY_ICON[STAGE])},changeTimer:function(){this.timerCounter--;0<=this.timerCounter&&
(0>=this.timerCounter?playSoundEffect(res.clockTickH_mp3):playSoundEffect(res.clockTickL_mp3),this.timer.setSpriteFrame("ui_timerTick_"+this.timerCounter+".png"))},resetTimer:function(){this.timerCounter=3;this.timer.setSpriteFrame("ui_timerTick_3.png")},destroy:function(){for(;0<this.actionList.length;){var a=this.actionList.pop();a.cleanup();a.removeFromParent()}this.cleanup();this.removeFromParent()}});UIFactory.create=function(a){a=new UIFactory(a);g_sharedGameplayLyr.addChild(a,LAYER.ui);return a};var ButtonFactory=cc.SpriteBatchNode.extend({buttonList:[],ctor:function(a){this._super(a);this.init()},init:function(){this.setAnchorPoint(0,0)},generateButtons:function(){var a=new ButtonObj("#ui_btnAtkG.png",ACTIONS[1]);a.setAnchorPoint(0.5,0.5);a.setPosition(0.199*GC.SCREEN.SIZE.WIDTH,0.198*GC.SCREEN.SIZE.HEIGHT);a.setAnchorPoint(0.5,0.5);a.isActive=!1;this.addChild(a);this.buttonList.push(a);a=new ButtonObj("#ui_btnChAtk.png",ACTIONS[2]);a.setAnchorPoint(0.5,0.5);a.setPosition(0.28*GC.SCREEN.SIZE.WIDTH,
0.153*GC.SCREEN.SIZE.HEIGHT);a.setAnchorPoint(0.5,0.5);this.addChild(a);this.buttonList.push(a);a=new ButtonObj("#ui_btnChCtr.png",ACTIONS[3]);a.setAnchorPoint(0.5,0.5);a.setPosition(0.348*GC.SCREEN.SIZE.WIDTH,0.153*GC.SCREEN.SIZE.HEIGHT);a.setAnchorPoint(0.5,0.5);this.addChild(a);this.buttonList.push(a);a=new ButtonObj("#ui_btnCtrG.png",ACTIONS[4]);a.setAnchorPoint(0.5,0.5);a.setPosition(0.429*GC.SCREEN.SIZE.WIDTH,0.198*GC.SCREEN.SIZE.HEIGHT);a.setAnchorPoint(0.5,0.5);a.isActive=!1;this.addChild(a);
this.buttonList.push(a)},toggleActive:function(a,b){this.buttonList[a].isActive||(this.buttonList[a].setSpriteFrame("ui_btn"+b+"A.png"),this.buttonList[a].runAction(cc.sequence(cc.scaleTo(0.25,1.2).easing(cc.easeIn(0.5)),cc.scaleTo(0.25,1).easing(cc.easeOut(0.5)),cc.callFunc(function(){this.buttonList[a].isActive=!0},this))))},toggleBack:function(a,b){this.buttonList[a].isActive&&(this.buttonList[a].isActive=!1,this.buttonList[a].setSpriteFrame("ui_btn"+b+"G.png"))},toggleOpacity:function(a){for(var b=
0;b<this.buttonList.length;b++)this.buttonList[b].setOpacity(a)},doAction:function(a,b){a.runAction(b)},destroy:function(){if(void 0!=this.buttonList)for(;0<this.buttonList.length;){var a=this.buttonList.pop();a.cleanup();a.removeFromParent()}this.cleanup();this.removeFromParent()}});ButtonFactory.create=function(a){a=new ButtonFactory(a);g_sharedGameplayLyr.addChild(a,LAYER.button);return a};var ButtonObj=cc.Sprite.extend({type:void 0,isActive:void 0,ctor:function(a,b){this._super(a);this.init(b);return!0},init:function(a){this.type=a;this.isActive=!0},isHit:function(a){if(this.isActive&&GAME_STATUS==GAME.active&&!g_sharedGameplayLyr.animRunning&&a.x>this.x-0.5*this.width&&a.x<this.x+0.5*this.width&&a.y>this.y-0.5*this.height&&a.y<this.y+0.5*this.height){this.runAction(cc.sequence(cc.scaleTo(0.1,0.8),cc.scaleTo(0.1,1)));switch(this.type){case "attack":g_sharedGameplayLyr.setPlayerAction("attack");
g_sharedFXFactory2.setGlow(0);break;case "counter":g_sharedGameplayLyr.setPlayerAction("counter");g_sharedFXFactory2.setGlow(3);break;case "chargeAttack":g_sharedGameplayLyr.setPlayerAction("chargeAttack");g_sharedFXFactory2.setGlow(1);break;case "chargeCounter":g_sharedGameplayLyr.setPlayerAction("chargeCounter"),g_sharedFXFactory2.setGlow(2)}return!0}return!1},destroy:function(){this.cleanup();this.removeFromParent()}});var EffectsFactory=cc.SpriteBatchNode.extend({glowList:[],enemyGlowList:[],chargeList:[],currentGlow:void 0,currentEnemyGlow:void 0,ctor:function(a){this._super(a);this.init()},init:function(){this.setAnchorPoint(0,0)},generateGlow:function(){var a=Tools.createSprite(this,"#fx_atk.png",cc.p(0.199*GC.SCREEN.SIZE.WIDTH,0.196*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);a.setOpacity(0);this.glowList.push(a);a=Tools.createSprite(this,"#fx_chAtk.png",cc.p(0.28*GC.SCREEN.SIZE.WIDTH,0.151*GC.SCREEN.SIZE.HEIGHT),
1,cc.p(0.5,0.5),0);a.setOpacity(0);this.glowList.push(a);a=Tools.createSprite(this,"#fx_chCtr.png",cc.p(0.348*GC.SCREEN.SIZE.WIDTH,0.151*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);a.setOpacity(0);this.glowList.push(a);a=Tools.createSprite(this,"#fx_ctr.png",cc.p(0.429*GC.SCREEN.SIZE.WIDTH,0.196*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);a.setOpacity(0);this.glowList.push(a)},generateEnemyGlow:function(){var a=Tools.createSprite(this,"#fx_atk.png",cc.p(0.572*GC.SCREEN.SIZE.WIDTH,0.2*GC.SCREEN.SIZE.HEIGHT),
1,cc.p(0.5,0.5),0);a.setOpacity(0);this.enemyGlowList.push(a);a=Tools.createSprite(this,"#fx_chAtk.png",cc.p(0.652*GC.SCREEN.SIZE.WIDTH,0.153*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);a.setOpacity(0);this.enemyGlowList.push(a);a=Tools.createSprite(this,"#fx_chCtr.png",cc.p(0.719*GC.SCREEN.SIZE.WIDTH,0.153*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);a.setOpacity(0);this.enemyGlowList.push(a);a=Tools.createSprite(this,"#fx_ctr.png",cc.p(0.8*GC.SCREEN.SIZE.WIDTH,0.2*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),
0);a.setOpacity(0);this.enemyGlowList.push(a)},generateCharge:function(){var a=Tools.createSprite(this,"#fx_actionCharge_0.png",cc.p(0.216*GC.SCREEN.SIZE.WIDTH,0.1157*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);a.setOpacity(0);this.chargeList.push(a);a=Tools.createSprite(this,"#fx_actionCharge_0.png",cc.p(0.413*GC.SCREEN.SIZE.WIDTH,0.1157*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);a.setFlippedX(!0);a.setOpacity(0);this.chargeList.push(a);a=Tools.createSprite(this,"#fx_actionCharge_0.png",cc.p(0.585*
GC.SCREEN.SIZE.WIDTH,0.1187*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);a.setOpacity(0);this.chargeList.push(a);a=Tools.createSprite(this,"#fx_actionCharge_0.png",cc.p(0.783*GC.SCREEN.SIZE.WIDTH,0.1187*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);a.setFlippedX(!0);a.setOpacity(0);this.chargeList.push(a)},runCharge:function(a){this.chargeList[a].runAction(cc.sequence(cc.spawn(cc.fadeIn(0.1),Tools.createFramesAnimation("fx_actionCharge_",0.045,0,6)),cc.fadeOut(0.2)))},setGlow:function(a){void 0!=this.currentGlow&&
(this.currentGlow.stopAllActions(),this.currentGlow.setOpacity(0));this.glowList[a].runAction(cc.repeatForever(cc.sequence(cc.fadeIn(0.2),cc.fadeOut(0.2))));this.currentGlow=this.glowList[a]},setEnemyGlow:function(a){var b;switch(a){case "attack":b=this.enemyGlowList[0];break;case "counter":b=this.enemyGlowList[3];break;case "chargeAttack":b=this.enemyGlowList[1];break;case "chargeCounter":b=this.enemyGlowList[2]}void 0!=this.currentEnemyGlow&&(this.currentEnemyGlow.stopAllActions(),this.currentEnemyGlow.setOpacity(0));
b.runAction(cc.repeatForever(cc.sequence(cc.fadeIn(0.2),cc.fadeOut(0.2))));this.currentEnemyGlow=b},resetGlow:function(){for(var a=0;a<this.glowList.length;a++)this.glowList[a].stopAllActions(),this.glowList[a].setOpacity(0)},resetEnemyGlow:function(){for(var a=0;a<this.enemyGlowList.length;a++)this.enemyGlowList[a].stopAllActions(),this.enemyGlowList[a].setOpacity(0)},addChargeEffect:function(a,b){var c=new cc.Sprite("#fx_charge_"+b+"_0.png");c.setPosition(a);this.addChild(c);c.runAction(cc.sequence(Tools.createFramesAnimation("fx_charge_"+
b+"_",0.07,0,13),cc.callFunc(function(a){a.cleanup();a.removeFromParent()},this)))},addHitEffect:function(a){var b=new cc.Sprite("#fx_hit_0.png");b.setPosition(a);this.addChild(b);b.runAction(cc.sequence(Tools.createFramesAnimation("fx_hit_",0.07,0,2),cc.callFunc(function(a){a.cleanup();a.removeFromParent()},this)))},addDeathEffect:function(a){var b=new cc.Sprite("#fx_death_0.png");b.setPosition(a);this.addChild(b);b.runAction(cc.sequence(Tools.createFramesAnimation("fx_death_",0.07,0,20),cc.callFunc(function(a){a.cleanup();
a.removeFromParent()},this)))},destroy:function(){if(null!=this.chargeList)for(;0<this.chargeList.length;){var a=this.chargeList.pop();a.cleanup();a.removeFromParent()}if(null!=this.glowList)for(;0<this.glowList.length;)a=this.glowList.pop(),a.cleanup(),a.removeFromParent();if(null!=this.enemyGlowList)for(;0<this.enemyGlowList.length;)a=this.enemyGlowList.pop(),a.cleanup(),a.removeFromParent();this.cleanup();this.removeFromParent()}});
EffectsFactory.create=function(a,b){var c=new EffectsFactory(a);g_sharedGameplayLyr.addChild(c,b);return c};var MiscFactory=cc.SpriteBatchNode.extend({boxList:[],banner:void 0,tierBanner:void 0,bubble:void 0,tierBubble:void 0,hiro:void 0,tagHiro:void 0,opponent:void 0,tagOpponent:void 0,tagVs:void 0,opponentSprite:void 0,banner_1:void 0,banner_2:void 0,draw_1:void 0,draw_2:void 0,countdown_1:void 0,countdown_2:void 0,countdown_3:void 0,heart:void 0,ctor:function(a){this._super(a)},init:function(){this.banner=new cc.Sprite("#rogerson.png");this.banner.setPosition(1.2*GC.SCREEN.SIZE.WIDTH,150);this.addChild(this.banner);
var a=Tools.createSprite(this,"#bubble0.png",cc.p(0.5*GC.SCREEN.SIZE.WIDTH,0.62*GC.SCREEN.SIZE.HEIGHT),0,cc.p(0.5,0.5),0);this.bubble=a;this.heart=a=Tools.createSprite(this,"#heart.png",cc.p(0.525*GC.SCREEN.SIZE.WIDTH,0.105*GC.SCREEN.SIZE.HEIGHT),0,cc.p(0.5,0.5),2);this.showBanner()},generateContenders:function(){var a=Tools.createSprite(this,"#hiroAmonson.png",cc.p(0.4*-GC.SCREEN.SIZE.WIDTH,0.4*GC.SCREEN.SIZE.HEIGHT),0.9,cc.p(0.5,0.5),0);this.hiro=a;this.opponent=a=Tools.createSprite(this,"#"+ENEMY_PNG[STAGE],
cc.p(1.4*GC.SCREEN.SIZE.WIDTH,0.1*GC.SCREEN.SIZE.HEIGHT),0.9,cc.p(0.5,0),0);this.opponentSprite=ENEMY_PNG[STAGE];this.tagHiro=a=Tools.createSprite(this,"#tag_hiroAmonsun.png",cc.p(0.4*-GC.SCREEN.SIZE.WIDTH,0.167*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),1);this.tagOpponent=a=Tools.createSprite(this,"#"+ENEMY_TAG[STAGE],cc.p(1.4*GC.SCREEN.SIZE.WIDTH,0.145*GC.SCREEN.SIZE.HEIGHT),0.9,cc.p(0.5,0.5),1);a=Tools.createSprite(this,"#border.png",cc.p(0.6*-GC.SCREEN.SIZE.WIDTH,0),1,cc.p(0.5,0),0);a.setScale(1E3,
0.5);this.banner_1=a;a=Tools.createSprite(this,"#border.png",cc.p(1.6*GC.SCREEN.SIZE.WIDTH,0.87*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);a.setScale(1E3,1);this.banner_2=a;this.tagVs=a=Tools.createSprite(this,"#tag_vs.png",cc.p(0.5*GC.SCREEN.SIZE.WIDTH,0.4*GC.SCREEN.SIZE.HEIGHT),0,cc.p(0.5,0.5),0);this.showContender()},generateTierBanner:function(){var a=Tools.createSprite(this,"#john.png",cc.p(0.2*-GC.SCREEN.SIZE.WIDTH,150),1,cc.p(0.5,0.5),0);a.setFlippedX(!0);this.tierBanner=a;this.tierBubble=a=
Tools.createSprite(this,"#bubble1.png",cc.p(0.47*GC.SCREEN.SIZE.WIDTH,0.62*GC.SCREEN.SIZE.HEIGHT),0,cc.p(0.5,0.5),0)},generateDraw:function(){var a=Tools.createSprite(this,"#draw_0.png",cc.p(0.1*GC.SCREEN.SIZE.WIDTH,-0.2*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);this.draw_1=a;this.draw_2=a=Tools.createSprite(this,"#draw_1.png",cc.p(0.9*GC.SCREEN.SIZE.WIDTH,1.2*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0)},generateCountdown:function(){var a=Tools.createSprite(this,"#ready_0.png",cc.p(-0.5*GC.SCREEN.SIZE.WIDTH,
0.7*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);this.countdown_1=a;this.countdown_2=a=Tools.createSprite(this,"#ready_1.png",cc.p(1.5*GC.SCREEN.SIZE.WIDTH,0.5*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0);this.countdown_3=a=Tools.createSprite(this,"#ready_2.png",cc.p(-0.5*GC.SCREEN.SIZE.WIDTH,0.3*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0.5,0.5),0)},generateBoxes:function(){for(var a=0;3>a;a++){var b=new MiscObj("#card_cover.png");b.setAnchorPoint(0.5,0.5);b.setPosition(0.355*GC.SCREEN.SIZE.WIDTH+200*a,0.28*GC.SCREEN.SIZE.HEIGHT);
b.setScale(0);b.setAnchorPoint(0.5,0.5);b.originalPos=b.getPosition();this.addChild(b);this.boxList.push(b)}},showBoxes:function(){for(var a=0;a<this.boxList.length;a++)this.boxList[a].runAction(cc.Sequence.create(cc.delayTime(1),cc.fadeIn(0.01),cc.scaleTo(0.2,-0.9,0.9).easing(cc.easeIn(0.5)),cc.scaleTo(0.2,-0.8,0.8).easing(cc.easeOut(0.5)),cc.rotateBy(0.05,5),cc.rotateBy(0.05,-10),cc.rotateBy(0.05,10),cc.rotateBy(0.05,-10),cc.rotateBy(0.05,10),cc.rotateBy(0.05,-10),cc.rotateBy(0.05,5),cc.delayTime(0.5),
cc.callFunc(function(a){a.isActive=!0},this))),this.boxList[a].type=BOONS[Tools.getRandomInt(0,2)]},hideBoxes:function(){for(var a=0;a<this.boxList.length;a++)this.boxList[a].runAction(cc.Sequence.create(cc.scaleTo(0.2,1.1).easing(cc.easeIn(0.5)),cc.scaleTo(0.2,0).easing(cc.easeOut(0.5)))),this.boxList[a].isActive=!1},showBanner:function(){this.banner.runAction(cc.sequence(cc.moveBy(0.5,-700,0).easing(cc.easeIn(0.5)),cc.moveBy(0.2,50,0).easing(cc.easeOut(0.5))));this.bubble.runAction(cc.sequence(cc.delayTime(0.8),
cc.callFunc(function(){cc.audioEngine.setEffectsVolume(1);playSoundEffect(res.rogerson_mp3)},this),cc.scaleTo(0.3,1.2).easing(cc.easeIn(0.5)),cc.scaleTo(0.2,1),cc.callFunc(function(){GAME_STATUS=GAME.preGame},this)))},preGameAnimate:function(){cc.audioEngine.stopAllEffects();GAME_STATUS=GAME.paused;this.banner.runAction(cc.sequence(cc.moveBy(0.2,-50,0).easing(cc.easeIn(0.5)),cc.moveBy(0.2,700,0).easing(cc.easeOut(0.5)),cc.delayTime(0.3),cc.callFunc(function(){cc.audioEngine.setEffectsVolume(1);g_sharedMiscFactory2.generateCountdown();
this.generateContenders();this.generateDraw()},this),cc.delayTime(6),cc.callFunc(function(){playSoundEffect(res.hiroEntrance_mp3);g_sharedHUDLyr.toggleOverlay(!1);GAME_STATUS=GAME.active;this.generateTierBanner();this.generateBoxes();g_sharedTextFactory.timerPulse();g_sharedGameplayLyr.enemy.doAnimation("dash");g_sharedTextFactory.enemyMoveTick()},this),cc.delayTime(1),cc.callFunc(function(){g_sharedTextFactory.enemyMove.stopAllActions();g_sharedTextFactory.setEnemyMove("???");g_sharedGameplayLyr.enemy.stopAllActions();
g_sharedGameplayLyr.enemy.doAnimation("idle")},this)));this.bubble.runAction(cc.sequence(cc.scaleTo(0.2,1.2).easing(cc.easeOut(0.5)),cc.scaleTo(0.3,0)))},showTierBanner:function(){this.tierBanner.runAction(cc.sequence(cc.delayTime(0.5),cc.moveBy(0.4,550,0).easing(cc.easeIn(0.5)),cc.moveBy(0.2,-50,0).easing(cc.easeOut(0.5)),cc.delayTime(2.8),cc.moveBy(0.2,50,0).easing(cc.easeIn(0.5)),cc.moveBy(0.2,-550,0).easing(cc.easeOut(0.5))));this.tierBubble.runAction(cc.sequence(cc.delayTime(0.5),cc.delayTime(0.8),
cc.callFunc(function(){playSoundEffect(res.hiroEntrance_mp3)},this),cc.scaleTo(0.3,1.2).easing(cc.easeIn(0.5)),cc.scaleTo(0.2,1),cc.delayTime(1.8),cc.scaleTo(0.2,1.2).easing(cc.easeOut(0.5)),cc.scaleTo(0.3,0)))},showContender:function(){this.hiro.runAction(cc.sequence(cc.moveBy(1,0.7*GC.SCREEN.SIZE.WIDTH,0).easing(cc.easeIn(0.1)),cc.delayTime(1.5),cc.moveBy(1,0.7*-GC.SCREEN.SIZE.WIDTH,0).easing(cc.easeOut(0.1)),cc.delayTime(0.5),cc.callFunc(function(a){a.setPosition(cc.p(0.4*-GC.SCREEN.SIZE.WIDTH,
a.y))},this)));this.tagHiro.runAction(cc.sequence(cc.delayTime(0.5),cc.moveBy(1,0.68*GC.SCREEN.SIZE.WIDTH,0).easing(cc.easeIn(0.1)),cc.delayTime(1),cc.moveBy(1,0.68*-GC.SCREEN.SIZE.WIDTH,0).easing(cc.easeOut(0.1)),cc.delayTime(0.5),cc.callFunc(function(a){a.setPosition(cc.p(0.4*-GC.SCREEN.SIZE.WIDTH,a.y))},this)));var a=0.71;if("stromulex.png"==this.opponentSprite||"blackyard.png"==this.opponentSprite)a=0.61;this.opponent.runAction(cc.sequence(cc.moveBy(1,-GC.SCREEN.SIZE.WIDTH*a,0).easing(cc.easeIn(0.1)),
cc.delayTime(1.5),cc.moveBy(1,GC.SCREEN.SIZE.WIDTH*a,0).easing(cc.easeOut(0.1)),cc.delayTime(0.5),cc.callFunc(function(a){a.setPosition(cc.p(1.4*GC.SCREEN.SIZE.WIDTH,a.y))},this)));a=0.73;if("grindiok.png"==this.opponentSprite||"avere.png"==this.opponentSprite)a=0.75;this.tagOpponent.runAction(cc.sequence(cc.delayTime(0.5),cc.moveBy(1,-GC.SCREEN.SIZE.WIDTH*a,0).easing(cc.easeIn(0.1)),cc.delayTime(1),cc.moveBy(1,GC.SCREEN.SIZE.WIDTH*a,0).easing(cc.easeOut(0.1)),cc.delayTime(0.5),cc.callFunc(function(a){a.setPosition(cc.p(0.5*
GC.SCREEN.SIZE.WIDTH,1.4*GC.SCREEN.SIZE.HEIGHT))},this)));this.tagVs.runAction(cc.sequence(cc.delayTime(1.5),cc.scaleTo(0.2,1.5).easing(cc.easeIn(0.5)),cc.scaleTo(0.2,1).easing(cc.easeOut(0.5)),cc.callFunc(function(){playSoundEffect(res.versus_mp3);blink()},this),cc.delayTime(1),cc.scaleTo(0.2,1.5).easing(cc.easeIn(0.5)),cc.scaleTo(0.2,0).easing(cc.easeOut(0.5))));this.banner_1.runAction(cc.sequence(cc.moveBy(0.8,1.1*GC.SCREEN.SIZE.WIDTH,0).easing(cc.easeIn(0.1)),cc.delayTime(1),cc.moveBy(1.3,2*GC.SCREEN.SIZE.WIDTH,
0).easing(cc.easeOut(0.1)),cc.delayTime(0.5),cc.callFunc(function(a){a.setPosition(cc.p(0.8*-GC.SCREEN.SIZE.WIDTH,0))},this)));this.banner_2.runAction(cc.sequence(cc.moveBy(0.8,1.1*-GC.SCREEN.SIZE.WIDTH,0).easing(cc.easeIn(0.1)),cc.delayTime(1),cc.moveBy(1.3,2*-GC.SCREEN.SIZE.WIDTH,0).easing(cc.easeOut(0.1)),cc.delayTime(0.5),cc.callFunc(function(a){a.setPosition(cc.p(1.8*GC.SCREEN.SIZE.WIDTH,0.87*GC.SCREEN.SIZE.HEIGHT))},this)));g_sharedMiscFactory2.runAction(cc.sequence(cc.delayTime(3.5),cc.callFunc(function(){g_sharedMiscFactory2.slideInCountdown()},
this)))},slideInOpponentTag:function(){this.tagOpponent.runAction(cc.sequence(cc.moveBy(0.2,cc.p(0,-625)).easing(cc.easeIn(0.5)),cc.moveBy(0.2,cc.p(0,50)).easing(cc.easeOut(0.5))))},slideOutOpponentTag:function(){this.tagOpponent.runAction(cc.sequence(cc.moveBy(0.2,cc.p(0,-50)).easing(cc.easeIn(0.5)),cc.moveBy(0.2,cc.p(0,625)).easing(cc.easeOut(0.5)),cc.callFunc(function(a){a.setPosition(cc.p(1.4*GC.SCREEN.SIZE.WIDTH,0.145*GC.SCREEN.SIZE.HEIGHT))},this)))},slideInDraw:function(){this.draw_1.runAction(cc.sequence(cc.moveTo(0.5,
0.442*GC.SCREEN.SIZE.WIDTH,0.5*GC.SCREEN.SIZE.HEIGHT).easing(cc.easeIn(0.1)),cc.delayTime(1),cc.moveTo(0.5,0.8*GC.SCREEN.SIZE.WIDTH,1.2*GC.SCREEN.SIZE.HEIGHT).easing(cc.easeOut(0.1)),cc.delayTime(0.5),cc.callFunc(function(a){a.setPosition(cc.p(0.1*GC.SCREEN.SIZE.WIDTH,-0.2*GC.SCREEN.SIZE.HEIGHT))},this)));this.draw_2.runAction(cc.sequence(cc.moveTo(0.5,0.558*GC.SCREEN.SIZE.WIDTH,0.5*GC.SCREEN.SIZE.HEIGHT).easing(cc.easeIn(0.1)),cc.delayTime(1),cc.moveTo(0.5,0.2*GC.SCREEN.SIZE.WIDTH,-0.2*GC.SCREEN.SIZE.HEIGHT).easing(cc.easeOut(0.1)),
cc.delayTime(0.5),cc.callFunc(function(a){a.setPosition(cc.p(0.9*GC.SCREEN.SIZE.WIDTH,1.2*GC.SCREEN.SIZE.HEIGHT))},this)))},slideInCountdown:function(){this.countdown_1.runAction(cc.sequence(cc.moveBy(0.5,1*GC.SCREEN.SIZE.WIDTH,0).easing(cc.easeIn(0.1)),cc.callFunc(function(){playSoundEffect(res.countEntrance_mp3)},this),cc.delayTime(1.8),cc.moveBy(0.5,1*GC.SCREEN.SIZE.WIDTH,0).easing(cc.easeOut(0.1)),cc.delayTime(0.5),cc.callFunc(function(a){a.setPosition(cc.p(-0.5*GC.SCREEN.SIZE.WIDTH,0.7*GC.SCREEN.SIZE.HEIGHT))},
this)));this.countdown_2.runAction(cc.sequence(cc.delayTime(0.5),cc.moveBy(0.5,-1*GC.SCREEN.SIZE.WIDTH,0).easing(cc.easeIn(0.1)),cc.callFunc(function(){playSoundEffect(res.countEntrance_mp3)},this),cc.delayTime(1.3),cc.moveBy(0.5,-1*GC.SCREEN.SIZE.WIDTH,0).easing(cc.easeOut(0.1)),cc.delayTime(0.5),cc.callFunc(function(a){a.setPosition(cc.p(1.5*GC.SCREEN.SIZE.WIDTH,0.5*GC.SCREEN.SIZE.HEIGHT))},this)));this.countdown_3.runAction(cc.sequence(cc.delayTime(1),cc.moveBy(0.5,1*GC.SCREEN.SIZE.WIDTH,0).easing(cc.easeIn(0.1)),
cc.callFunc(function(){playSoundEffect(res.countEntrance_mp3)},this),cc.delayTime(0.8),cc.callFunc(function(){playSoundEffect(res.countExit_mp3)},this),cc.moveBy(0.5,1*GC.SCREEN.SIZE.WIDTH,0).easing(cc.easeOut(0.1)),cc.delayTime(0.5),cc.callFunc(function(a){a.setPosition(cc.p(-0.5*GC.SCREEN.SIZE.WIDTH,0.3*GC.SCREEN.SIZE.HEIGHT))},this)))},showHeart:function(){this.heart.runAction(cc.sequence(cc.spawn(cc.fadeIn(0.2),cc.sequence(cc.scaleTo(0.2,1.1).easing(cc.easeIn(0.5)),cc.scaleTo(0.2,0.7))),cc.delayTime(1.7),
cc.fadeOut(0.2)))},changeContender:function(){this.opponent.setSpriteFrame(ENEMY_PNG[STAGE]);this.tagOpponent.setSpriteFrame(ENEMY_TAG[STAGE]);this.opponentSprite=ENEMY_PNG[STAGE]},destroy:function(){if(void 0!=this.boxList)for(;0<this.boxList.length;){var a=this.boxList.pop();a.cleanup();a.removeFromParent()}this.cleanup();this.removeFromParent()}});MiscFactory.create=function(a){a=new MiscFactory(a);g_sharedHUDLyr.addChild(a,2);return a};var MiscObj=cc.Sprite.extend({type:void 0,isActive:void 0,originalPos:void 0,ctor:function(a){this._super(a);this.init();return!0},init:function(a){this.type=BOONS[Tools.getRandomInt(0,2)];this.isActive=!1},isHit:function(a){return this.isActive&&a.x>this.x-0.5*this.width&&a.x<this.x+0.5*this.width&&a.y>this.y-0.5*this.height&&a.y<this.y+0.5*this.height?(this.isActive=!1,this.stopAllActions(),this.runAction(cc.Sequence.create(cc.spawn(cc.sequence(cc.spawn(cc.scaleTo(0.2,0.8,0.8).easing(cc.easeOut(0.25)),
cc.sequence(cc.delayTime(0.15),cc.callFunc(function(){this.changeCardCover()},this))),cc.spawn(cc.scaleTo(0.2,-0.8,0.8).easing(cc.easeOut(0.25)),cc.sequence(cc.delayTime(0.15),cc.callFunc(function(){this.resetCardCover()},this))),cc.spawn(cc.scaleTo(0.2,0.8,0.8).easing(cc.easeOut(0.25)),cc.sequence(cc.delayTime(0.15),cc.callFunc(function(){this.changeCardCover()},this))),cc.spawn(cc.scaleTo(0.15,-0.8,0.8).easing(cc.easeOut(0.25)),cc.sequence(cc.delayTime(0.1),cc.callFunc(function(){this.resetCardCover()},
this))),cc.spawn(cc.scaleTo(0.15,0.8,0.8).easing(cc.easeOut(0.25)),cc.sequence(cc.delayTime(0.1),cc.callFunc(function(){this.changeCardCover()},this)))),cc.jumpTo(0.5,cc.p(0.5*GC.SCREEN.SIZE.WIDTH,this.y),100,1)),cc.delayTime(0.2),cc.scaleTo(0.3,1.2),cc.callFunc(function(){"potion"==this.type?playSoundEffect(res.charity_mp3):"charge"==this.type?playSoundEffect(res.max_mp3):playSoundEffect(res.zabooninin_mp3);"potion"==this.type&&g_sharedHUDLyr.togglePotion()},this),cc.delayTime(3),cc.moveTo(0.01,
this.originalPos),cc.callFunc(function(){this.resetCardCover()},this))),!0):!1},changeCardCover:function(){switch(this.type){case "potion":this.setSpriteFrame("card_charity.png");break;case "charge":this.setSpriteFrame("card_max.png");break;default:this.setSpriteFrame("card_zabooninin.png")}},resetCardCover:function(){this.setSpriteFrame("card_cover.png")},destroy:function(){this.cleanup();this.removeFromParent()}});var ProgressFactory=cc.Node.extend({lifeBarList:[],playerFillList:[],enemyFillList:[],ctor:function(){this._super();return!0},init:function(){this.generateLifeBar(0.45*GC.SCREEN.SIZE.WIDTH,1,1,1);this.generateLifeBar(0.81*GC.SCREEN.SIZE.WIDTH,0,-1,1);this.generateChargeFill("#ui_chargeFill3.png",cc.p(0.1435*GC.SCREEN.SIZE.WIDTH,0.145*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0,0),cc.p(0,1),this.playerFillList);this.generateChargeFill("#ui_chargeFill3.png",cc.p(0.484*GC.SCREEN.SIZE.WIDTH,0.1445*GC.SCREEN.SIZE.HEIGHT),
-1,cc.p(0,0),cc.p(0,1),this.playerFillList);this.generateChargeFill("#ui_chargeFill3.png",cc.p(0.5145*GC.SCREEN.SIZE.WIDTH,0.145*GC.SCREEN.SIZE.HEIGHT),1,cc.p(0,0),cc.p(0,1),this.enemyFillList);this.generateChargeFill("#ui_chargeFill3.png",cc.p(0.855*GC.SCREEN.SIZE.WIDTH,0.145*GC.SCREEN.SIZE.HEIGHT),-1,cc.p(0,0),cc.p(0,1),this.enemyFillList)},generateLifeBar:function(a,b,c,d){var e=new cc.ProgressTimer(cc.Sprite.create("#ui_fill.png"));e.setType(cc.ProgressTimer.TYPE_BAR);e.setBarChangeRate(cc.p(1,
0));e.setMidpoint(cc.p(d,0));e.setAnchorPoint(b,0);e.setPosition(a,0.905*GC.SCREEN.SIZE.HEIGHT);e.setPercentage(100);e.setScale(c,1);this.addChild(e,LAYER.button);this.lifeBarList.push(e)},updateLifeBar:function(a,b,c){a=cc.ProgressTo.create(0.5,100*(a/b));this.lifeBarList[c].stopAllActions();this.lifeBarList[c].runAction(a)},resetLifeBar:function(a){var b=cc.ProgressTo.create(0.5,100);this.lifeBarList[a].stopAllActions();this.lifeBarList[a].runAction(b)},generateChargeFill:function(a,b,c,d,e,f){a=
new cc.ProgressTimer(cc.Sprite.create(a));a.setType(cc.ProgressTimer.TYPE_BAR);a.setBarChangeRate(e);a.setMidpoint(d);a.setAnchorPoint(0,0);a.setPosition(b);a.setPercentage(0);a.setScale(c,1);this.addChild(a,LAYER.button);f.push(a);return a},updatePlayerChargeFill:function(a,b){cc.ProgressTo.create(0.25,100);var c=cc.ProgressTo.create(0.5,100*(b/3)-1);cc.ProgressTo.create(0.25,0);0==a?(this.playerFillList[0].stopAllActions(),this.playerFillList[0].runAction(cc.sequence(cc.delayTime(0.5),c))):(this.playerFillList[1].stopAllActions(),
this.playerFillList[1].runAction(cc.sequence(cc.delayTime(0.5),c)))},updateEnemyChargeFill:function(a,b){var c=cc.ProgressTo.create(0.5,100*(b/3)-1);0==a?(this.enemyFillList[0].stopAllActions(),this.enemyFillList[0].runAction(cc.sequence(cc.delayTime(0.5),c))):(this.enemyFillList[1].stopAllActions(),this.enemyFillList[1].runAction(cc.sequence(cc.delayTime(0.5),c)))},resetChargeFill:function(a,b){var c=cc.ProgressTo.create(0.25,0);"player"==a?(this.playerFillList[b].stopAllActions(),this.playerFillList[b].runAction(c)):
(this.enemyFillList[b].stopAllActions(),this.enemyFillList[b].runAction(c))},destroy:function(){if(void 0!=this.lifeBarList)for(;0<this.lifeBarList.length;){var a=this.lifeBarList.pop();a.cleanup();a.removeFromParent()}if(void 0!=this.playerFillList)for(;0<this.playerFillList.length;)a=this.playerFillList.pop(),a.cleanup(),a.removeFromParent();if(void 0!=this.enemyFillList)for(;0<this.enemyFillList.length;)a=this.enemyFillList.pop(),a.cleanup(),a.removeFromParent();this.cleanup();this.removeFromParent()}});
ProgressFactory.create=function(){var a=new ProgressFactory;g_sharedGameplayLyr.addChild(a,LAYER.progress);return a};var Amonson=cc.Sprite.extend({originalPos:void 0,idle:void 0,ctor:function(a){this._super(a);this.init();return!0},init:function(){this.setAnchorPoint(0,1);this.setPosition(0.1*GC.SCREEN.SIZE.WIDTH,0.7*GC.SCREEN.SIZE.HEIGHT);this.originalPos=this.getPosition();this.idle=!0;this.scheduleUpdate()},update:function(){this.idle&&(this.idle=!1,this.runAction(cc.repeatForever(ANIM_SEQUENCE.amonson.idle)),this.runAction(cc.repeatForever(cc.sequence(cc.moveTo(1.5,0.1*GC.SCREEN.SIZE.WIDTH,0.7*GC.SCREEN.SIZE.HEIGHT+
50).easing(cc.easeIn(0.8)),cc.moveTo(1.25,0.1*GC.SCREEN.SIZE.WIDTH,0.7*GC.SCREEN.SIZE.HEIGHT)))))},doAnimation:function(a){this.stopAllActions();var b;switch(a){case "attack":b=ANIM_SEQUENCE.amonson.attack;break;case "hit":b=ANIM_SEQUENCE.amonson.hurt;break;case "draw":b=cc.sequence(cc.spawn(ANIM_SEQUENCE.amonson.dAttack,cc.sequence(cc.delayTime(0.5),cc.spawn(ANIM_SEQUENCE.amonson.hurtAlt,cc.moveBy(0.1,0,20),cc.moveBy(0.1,0,-40),cc.moveBy(0.1,0,20)))))}this.runAction(b);this.runAction(cc.sequence(cc.delayTime(3),
cc.callFunc(function(){this.idle=!0;this.stopAllActions()},this)))},toggle:function(){this.stopAllActions();this.runAction(cc.sequence(cc.spawn(cc.moveTo(0.2,150,580),ANIM_SEQUENCE.amonson.block,cc.sequence(cc.callFunc(function(){shake()},this),cc.moveBy(0.1,0,20),cc.moveBy(0.1,0,-40),cc.moveBy(0.1,0,20)),cc.scaleTo(0.2,1.5)),cc.delayTime(1.5),cc.spawn(cc.moveTo(0.3,this.originalPos),ANIM_SEQUENCE.amonson.idle,cc.scaleTo(0.2,1))));this.runAction(cc.sequence(cc.delayTime(1.9),cc.delayTime(0.2),cc.callFunc(function(){this.idle=
!0;this.stopAllActions()},this)))},destroy:function(){this.cleanup();this.removeFromParent()}});Amonson.create=function(a){a=new Amonson(a);g_sharedGameplayLyr.addChild(a,LAYER.player);return a};var Player=cc.Sprite.extend({action:void 0,attackCharge:void 0,counterCharge:void 0,isHit:void 0,bonusCharge:void 0,life:0,chargeBoon:!1,onHitDamage:void 0,ctor:function(a,b){this._super(a);this.init(75);return!0},init:function(a){this.life+=a;this.life>PLAYER_LIFE[TIER]&&(this.life=PLAYER_LIFE[TIER]);this.chargeBoon||(this.counterCharge=this.attackCharge=0);this.bonusCharge=0;this.action="none";this.isHit=!1;this.setPosition(0.28*GC.SCREEN.SIZE.WIDTH,0.45*GC.SCREEN.SIZE.HEIGHT)},resetText:function(){this.chargeBoon?
(g_sharedProgressFactory.updatePlayerChargeFill(0,this.attackCharge),g_sharedProgressFactory.updatePlayerChargeFill(1,this.counterCharge)):(g_sharedProgressFactory.resetChargeFill("player",0),g_sharedProgressFactory.resetChargeFill("player",1));g_sharedGameplayLyr.toggleButton(0,"Atk",this.chargeBoon);g_sharedGameplayLyr.toggleButton(3,"Ctr",this.chargeBoon);g_sharedTextFactory.setPlayerLife(this.life,PLAYER_LIFE[TIER]);g_sharedTextFactory.setPlayerMove("???");g_sharedProgressFactory.updateLifeBar(this.life,
PLAYER_LIFE[TIER],0);PREV_PLAYER_ACTION=void 0;this.chargeBoon=!1;this.stopAllActions();this.runAction(cc.repeatForever(ANIM_SEQUENCE.hiro.idle))},setCurrentAction:function(a){if("attack"==a){if(0<this.attackCharge)return!0}else if("counter"==a){if(0<this.counterCharge)return!0}else if("chargeAttack"==a||"chargeCounter"==a)return!0;return!1},hurt:function(a,b){this.onHitDamage=a;"block"==b?this.doAnimation(b):"void"==b?0<a&&(this.life-=a,0<this.life?this.isHit=!0:this.life=0):0<a&&(this.life-=a,0<
this.life?this.isHit=!0:this.life=0,this.doAnimation(b))},updateAction:function(){switch(this.action){case "attack":this.attackCharge=0;g_sharedProgressFactory.resetChargeFill("player",0);break;case "counter":this.counterCharge=0;g_sharedProgressFactory.resetChargeFill("player",1);break;case "chargeAttack":3>this.attackCharge&&!this.isHit&&(this.attackCharge+=this.bonusCharge+1,3<this.attackCharge&&(this.attackCharge=3),g_sharedGameplayLyr.toggleButton(0,"Atk",!0),g_sharedProgressFactory.updatePlayerChargeFill(0,
this.attackCharge));this.isHit||(playSoundEffect(res.charge_mp3),g_sharedFXFactory2.runCharge(0));break;case "chargeCounter":3>this.counterCharge&&!this.isHit&&(this.counterCharge+=this.bonusCharge+1,3<this.counterCharge&&(this.counterCharge=3),g_sharedGameplayLyr.toggleButton(3,"Ctr",!0),g_sharedProgressFactory.updatePlayerChargeFill(1,this.counterCharge)),this.isHit||(playSoundEffect(res.charge_mp3),g_sharedFXFactory2.runCharge(1))}PREV_PLAYER_ACTION=this.action;this.isHit=!1;this.bonusCharge=0;
this.action="none";g_sharedTextFactory.setPlayerMove("???");this.stopAllActions();this.runAction(cc.repeatForever(ANIM_SEQUENCE.hiro.idle))},doAnimation:function(a){var b;switch(a){case "attack":b=ANIM_SEQUENCE.hiro.attack;break;case "block":b=cc.sequence(cc.spawn(cc.spawn(cc.callFunc(function(){},this),ANIM_SEQUENCE.hiro.block),cc.sequence(cc.delayTime(0.55),cc.callFunc(function(){void 0!=this.onHitDamage&&(shake(),this.life-=this.onHitDamage,0>this.life&&(this.life=0),g_sharedFXFactory2.addHitEffect(this.getPosition()),
g_sharedTextFactory.showDamage(this.onHitDamage,cc.p(this.x+50,this.y+100)),g_sharedTextFactory.setPlayerLife(this.life,PLAYER_LIFE[TIER]),g_sharedProgressFactory.updateLifeBar(this.life,PLAYER_LIFE[TIER],0),this.onHitDamage=void 0)},this))));break;case "chargeAttack":b=ANIM_SEQUENCE.hiro.charge;g_sharedFXFactory.addChargeEffect(cc.p(this.x+25,this.y-30),"atk");g_sharedTextFactory.showPlayerCharge(this.bonusCharge+1,"atk");playSoundEffect(res.chargeAttack_mp3);break;case "chargeCounter":b=ANIM_SEQUENCE.hiro.charge;
g_sharedFXFactory.addChargeEffect(cc.p(this.x+25,this.y-30),"countr");g_sharedTextFactory.showPlayerCharge(this.bonusCharge+1,"ctr");playSoundEffect(res.chargeCounter_mp3);break;case "hit":b=cc.sequence(cc.delayTime(0.55),cc.spawn(cc.callFunc(function(){playSoundEffect(res.hit_mp3)},this),ANIM_SEQUENCE.hiro.hurt,cc.sequence(cc.callFunc(function(){shake()},this),cc.moveBy(0.1,0,20),cc.moveBy(0.1,0,-40),cc.moveBy(0.1,0,20))),cc.callFunc(function(){void 0!=this.onHitDamage&&(g_sharedFXFactory2.addHitEffect(this.getPosition()),
g_sharedTextFactory.setPlayerLife(this.life,PLAYER_LIFE[TIER]),g_sharedProgressFactory.updateLifeBar(this.life,PLAYER_LIFE[TIER],0),g_sharedTextFactory.showDamage(this.onHitDamage,cc.p(this.x-125,this.y+100)),this.onHitDamage=void 0)},this));break;case "draw":b=cc.sequence(cc.spawn(ANIM_SEQUENCE.hiro.dAttack,cc.sequence(cc.delayTime(1),cc.spawn(ANIM_SEQUENCE.hiro.hurt,cc.callFunc(function(){shake()},this),cc.moveBy(0.1,0,20),cc.moveBy(0.1,0,-40),cc.moveBy(0.1,0,20)),cc.callFunc(function(){void 0!=
this.onHitDamage&&(g_sharedFXFactory2.addHitEffect(this.getPosition()),g_sharedTextFactory.setPlayerLife(this.life,PLAYER_LIFE[TIER]),g_sharedProgressFactory.updateLifeBar(this.life,PLAYER_LIFE[TIER],0),g_sharedTextFactory.showDamage(this.onHitDamage,cc.p(this.x-550,this.y+125)),this.onHitDamage=void 0)},this),cc.delayTime(1),ANIM_SEQUENCE.hiro.back)))}this.stopAllActions();this.runAction(b)},gainBoon:function(a,b){switch(a){case "potion":this.life+=b;this.life>PLAYER_LIFE[TIER]&&(this.life=PLAYER_LIFE[TIER]);
g_sharedTextFactory.setPlayerLife(this.life,PLAYER_LIFE[TIER]);g_sharedProgressFactory.updateLifeBar(this.life,PLAYER_LIFE[TIER],0);g_sharedTextFactory.showPotion(b);break;case "charge":this.counterCharge=this.attackCharge=3,this.chargeBoon=!0,g_sharedTextFactory.showPlayerCharge(3,"ac")}},die:function(){playSoundEffect(res.cardForm_mp3);this.stopAllActions();this.runAction(cc.sequence(cc.spawn(cc.fadeOut(0.2),cc.callFunc(function(){g_sharedFXFactory2.addDeathEffect(this.getPosition())},this))))},
destroy:function(){this.cleanup();this.removeFromParent()}});Player.create=function(a){a=new Player(a);g_sharedGameplayLyr.addChild(a,LAYER.player);return a};var Enemy=cc.Sprite.extend({action:void 0,life:void 0,attackCharge:void 0,counterCharge:void 0,isHit:void 0,type:void 0,bonusCharge:void 0,name:void 0,onHitDamage:void 0,ctor:function(a){this._super(a);this.init(50,!0);return!0},init:function(a,b){this.life=a;this.name=ENEMY[STAGE];this.bonusCharge=this.counterCharge=this.attackCharge=0;this.action=ACTIONS[Tools.getRandomInt(2,3)];this.isHit=!1;b&&this.setPosition(1.5*GC.SCREEN.SIZE.WIDTH,0.45*GC.SCREEN.SIZE.HEIGHT)},resetText:function(){this.stopAllActions();
this.runAction(cc.sequence(cc.delayTime(Tools.getRandomInt(1,3)),cc.callFunc(function(){g_sharedTextFactory.enemyMove.stopAllActions();g_sharedTextFactory.setEnemyMove("???")},this)));this.runAction(cc.repeatForever(ANIM_SEQUENCE[this.name].idle));g_sharedTextFactory.setEnemyLife(this.life,ENEMY_LIFE[LEVEL]);g_sharedProgressFactory.resetChargeFill("enemy",0);g_sharedProgressFactory.resetChargeFill("enemy",1);g_sharedTextFactory.setEnemyMove("thinking");g_sharedTextFactory.enemyMoveTick()},setAction:function(a){"attack"==
a?0>=this.attackCharge?this.setAction(ACTIONS[Tools.getRandomInt(2,4)]):this.action=a:"counter"==a?0>=this.counterCharge?this.setAction(ACTIONS[Tools.getRandomInt(1,3)]):0<g_sharedGameplayLyr.getPlayerCharge()?this.action=a:this.setAction(ACTIONS[Tools.getRandomInt(1,3)]):this.action=3==this.attackCharge&&3>this.counterCharge&&"chargeAttack"==a?ACTIONS[3]:3==this.counterCharge&&3>this.attackCharge&&"chargeCounter"==a?ACTIONS[2]:a},hurt:function(a,b){this.onHitDamage=a;GC.SCORE+=a;"block"==b?this.doAnimation(b):
"void"==b?0<a&&(this.life-=a,0<this.life?this.isHit=!0:this.life=0):0<a&&(this.life-=a,0<this.life?this.isHit=!0:this.life=0,this.doAnimation(b))},updateAction:function(){switch(this.action){case "attack":this.attackCharge=0;g_sharedProgressFactory.resetChargeFill("enemy",0);break;case "counter":this.counterCharge=0;g_sharedProgressFactory.resetChargeFill("enemy",1);break;case "chargeAttack":3>this.attackCharge&&!this.isHit&&(this.attackCharge+=this.bonusCharge+1,3<this.attackCharge&&(this.attackCharge=
3),g_sharedProgressFactory.updateEnemyChargeFill(0,this.attackCharge));this.isHit||(playSoundEffect(res.charge_mp3),g_sharedFXFactory2.runCharge(2));break;case "chargeCounter":3>this.counterCharge&&!this.isHit&&(this.counterCharge+=this.bonusCharge+1,3<this.counterCharge&&(this.counterCharge=3),g_sharedProgressFactory.updateEnemyChargeFill(1,this.counterCharge)),this.isHit||(playSoundEffect(res.charge_mp3),g_sharedFXFactory2.runCharge(3))}"counter"==PREV_PLAYER_ACTION&&void 0!=PREV_PLAYER_ACTION?
this.setAction(ACTIONS[1]):this.setAction(ACTIONS[Tools.getRandomInt(1,4)]);g_sharedTextFactory.setEnemyMove("thinking");g_sharedTextFactory.enemyMoveTick();this.runAction(cc.sequence(cc.delayTime(Tools.getRandomInt(1,3)),cc.callFunc(function(){g_sharedTextFactory.enemyMove.stopAllActions();g_sharedTextFactory.setEnemyMove("???")},this)));this.runAction(cc.repeatForever(ANIM_SEQUENCE[this.name].idle));this.isHit=!1;this.bonusCharge=0},doAnimation:function(a){var b;switch(a){case "idle":b=cc.repeatForever(ANIM_SEQUENCE[this.name].idle);
break;case "dash":b=ANIM_SEQUENCE[this.name].dash;break;case "attack":b=ANIM_SEQUENCE[this.name].attack;break;case "block":b=cc.sequence(cc.delayTime(0.55),cc.spawn(cc.callFunc(function(){playSoundEffect(res.block_mp3)},this),ANIM_SEQUENCE[this.name].block),cc.callFunc(function(){void 0!=this.onHitDamage&&(shake(),this.life-=this.onHitDamage,0>this.life&&(this.life=0),g_sharedFXFactory2.addHitEffect(this.getPosition()),g_sharedTextFactory.showDamage(this.onHitDamage,cc.p(this.x+130,this.y+100)),g_sharedTextFactory.setEnemyLife(this.life,
ENEMY_LIFE[LEVEL]),g_sharedProgressFactory.updateLifeBar(this.life,ENEMY_LIFE[LEVEL],1),this.onHitDamage=void 0)},this));break;case "chargeAttack":b=ANIM_SEQUENCE[this.name].charge;g_sharedFXFactory.addChargeEffect(cc.p(this.x-25,this.y-30),"atk");g_sharedTextFactory.showEnemyCharge(this.bonusCharge+1,"atk");playSoundEffect(res.chargeAttack_mp3);break;case "chargeCounter":b=ANIM_SEQUENCE[this.name].charge;g_sharedFXFactory.addChargeEffect(cc.p(this.x-25,this.y-30),"countr");g_sharedTextFactory.showEnemyCharge(this.bonusCharge+
1,"ctr");playSoundEffect(res.chargeCounter_mp3);break;case "hit":b=cc.sequence(cc.delayTime(0.55),cc.spawn(cc.callFunc(function(){playSoundEffect(res.hit_mp3)},this),ANIM_SEQUENCE[this.name].hurt,cc.sequence(cc.callFunc(function(){shake()},this),cc.moveBy(0.1,0,20),cc.moveBy(0.1,0,-40),cc.moveBy(0.1,0,20))),cc.callFunc(function(){void 0!=this.onHitDamage&&(g_sharedFXFactory2.addHitEffect(this.getPosition()),g_sharedTextFactory.showDamage(this.onHitDamage,cc.p(this.x+130,this.y+100)),g_sharedTextFactory.setEnemyLife(this.life,
ENEMY_LIFE[LEVEL]),g_sharedProgressFactory.updateLifeBar(this.life,ENEMY_LIFE[LEVEL],1),this.onHitDamage=void 0)},this));break;case "draw":b=cc.sequence(cc.spawn(ANIM_SEQUENCE[this.name].dAttack,cc.sequence(cc.delayTime(1),cc.spawn(ANIM_SEQUENCE[this.name].hurt,cc.moveBy(0.1,0,20),cc.moveBy(0.1,0,-40),cc.moveBy(0.1,0,20)),cc.callFunc(function(){void 0!=this.onHitDamage&&(g_sharedFXFactory2.addHitEffect(this.getPosition()),g_sharedTextFactory.showDamageAlt(this.onHitDamage,cc.p(this.x+500,this.y+150)),
g_sharedTextFactory.setEnemyLife(this.life,ENEMY_LIFE[LEVEL]),g_sharedProgressFactory.updateLifeBar(this.life,ENEMY_LIFE[LEVEL],1),this.onHitDamage=void 0)},this),cc.delayTime(1),ANIM_SEQUENCE[this.name].back)))}this.stopAllActions();this.runAction(b)},die:function(){this.stopAllActions();playSoundEffect(res.cardForm_mp3);this.runAction(cc.sequence(cc.spawn(cc.fadeOut(0.2),cc.callFunc(function(){g_sharedFXFactory2.addDeathEffect(this.getPosition())},this)),cc.callFunc(function(){this.setPosition(1.5*
GC.SCREEN.SIZE.WIDTH,0.4*GC.SCREEN.SIZE.HEIGHT)},this),cc.fadeIn(0.2)))},destroy:function(){this.cleanup();this.removeFromParent()}});Enemy.create=function(a){a=new Enemy(a);g_sharedGameplayLyr.addChild(a,LAYER.enemy);return a};var MainMenuLayer=cc.Layer.extend({ctor:function(){this._super();this.init();this.loadAssets();this.loadAnimations();return!0},loadAssets:function(){cc.spriteFrameCache.addSpriteFrames(res.ui_plist);cc.spriteFrameCache.addSpriteFrames(res.player_plist);cc.spriteFrameCache.addSpriteFrames(res.amonson_plist);cc.spriteFrameCache.addSpriteFrames(res.enemy_plist);cc.spriteFrameCache.addSpriteFrames(res.fx_plist);cc.spriteFrameCache.addSpriteFrames(res.fx2_plist);cc.spriteFrameCache.addSpriteFrames(res.misc_plist);
cc.spriteFrameCache.addSpriteFrames(res.stromulex_plist);cc.spriteFrameCache.addSpriteFrames(res.avere_plist);cc.spriteFrameCache.addSpriteFrames(res.blackyard_plist);cc.spriteFrameCache.addSpriteFrames(res.grindiok_plist)},loadAnimations:function(){loadHiroActions();loadAmonsonActions();loadCastillanActions();loadStromulexActions();loadAvereActions();loadBlackyardActions();loadGrindiokActions()},init:function(){this._super();cc.spriteFrameCache.addSpriteFrames(res.ui_plist);var a=new cc.Sprite(res.title_png);
a.setPosition(GC.SCREEN.CENTER.X,GC.SCREEN.CENTER.Y);this.addChild(a,0);a=new cc.MenuItemImage("#ui_btnPlay_U.png","#ui_btnPlay_D.png",this.startGame,this);a.anchorX=1;a.anchorY=1;a.x=0;a.y=0;a.setScale(0.8);var b=new cc.MenuItemImage("#ui_btnHowTo_U.png","#ui_btnHowTo_D.png",this.showRules,this);b.anchorX=1;b.anchorY=1;b.x=a.x+45;b.y=-b.getContentSize().height;b.setScale(0.8);a=new cc.Menu(a,b);a.x=0.578*GC.SCREEN.SIZE.WIDTH;a.y=180;this.addChild(a,1);return!0},startGame:function(){var a=new GameplayScene;
cc.director.runScene(new cc.TransitionFade(0.5,a))},showRules:function(){var a=new HowToPlayScene(GC.HOW_TO_PLAY_PAGE.ONE);cc.director.runScene(new cc.TransitionMoveInR(0.5,a))}}),MainMenuScene=cc.Scene.extend({onEnter:function(){this._super();var a=new MainMenuLayer;this.addChild(a)}});var ANIM_SEQUENCE={hiro:{idle:0,attack:0,dAttack:0,hurt:0,block:0,charge:0},amonson:{idle:0,block:0,hurt:0,hurtAlt:0,attack:0},PrinceCastillan:{idle:0,attack:0,dAttack:0,hurt:0,block:0,charge:0},Stromulex:{idle:0,attack:0,dAttack:0,hurt:0,block:0,charge:0},Avere:{idle:0,attack:0,dAttack:0,hurt:0,block:0,charge:0},KingBlackyard:{idle:0,attack:0,dAttack:0,hurt:0,block:0,charge:0},Grindiok:{idle:0,attack:0,dAttack:0,hurt:0,block:0,charge:0}};
function loadHiroActions(){ANIM_SEQUENCE.hiro.idle=Tools.createFramesAnimation("hiro_idle_00",0.06,0,7);ANIM_SEQUENCE.hiro.dAttack=cc.sequence(cc.spawn(cc.fadeOut(0.2),cc.moveBy(0.2,-20,0)),cc.spawn(cc.fadeIn(0.3),Tools.createFramesAnimation("hiro_dash_00",0.06,0,0),cc.moveBy(0.2,500,0),cc.sequence(cc.delayTime(0.02),cc.callFunc(function(){playSoundEffect(res.hiroAttack_mp3)},this),Tools.createFramesAnimation("hiro_attack_00",0.06,0,4))));ANIM_SEQUENCE.hiro.back=cc.spawn(Tools.createFramesAnimation("hiro_back_00",
0.06,0,0),cc.moveBy(0.2,-480,0),cc.sequence(cc.delayTime(0.3),Tools.createFramesAnimation("hiro_idle_00",0.06,0,7)));ANIM_SEQUENCE.hiro.attack=cc.sequence(cc.spawn(cc.fadeOut(0.2),cc.moveBy(0.2,-20,0)),cc.spawn(cc.fadeIn(0.3),Tools.createFramesAnimation("hiro_dash_00",0.06,0,0),cc.moveBy(0.2,400,0)),cc.callFunc(function(){playSoundEffect(res.hiroAttack_mp3)},this),Tools.createFramesAnimation("hiro_attack_00",0.06,0,4),cc.delayTime(0.2),cc.spawn(Tools.createFramesAnimation("hiro_back_00",0.06,0,0),
cc.moveBy(0.2,-380,0),cc.sequence(cc.delayTime(0.3),Tools.createFramesAnimation("hiro_idle_00",0.06,0,7))));ANIM_SEQUENCE.hiro.hurt=Tools.createFramesAnimation("hiro_hit_00",0.04,0,0);ANIM_SEQUENCE.hiro.charge=Tools.createFramesAnimation("hiro_charge_00",0.04,0,0);ANIM_SEQUENCE.hiro.block=cc.sequence(cc.callFunc(function(){playSoundEffect(res.hiroCounter_mp3)},this),cc.spawn(cc.sequence(cc.fadeOut(0.2),cc.fadeIn(0.2)),cc.jumpBy(0.3,cc.p(-200,0),100,1)),cc.delayTime(1.3),cc.spawn(cc.sequence(cc.fadeOut(0.1),
cc.fadeIn(0.1)),cc.jumpBy(0.2,cc.p(200,0),100,1)))}
function loadAmonsonActions(){ANIM_SEQUENCE.amonson.idle=Tools.createFramesAnimation("amon_idle_00",0.06,0,7);ANIM_SEQUENCE.amonson.block=Tools.createFramesAnimation("amon_counter_00",0.06,0,3);ANIM_SEQUENCE.amonson.dAttack=cc.sequence(cc.spawn(cc.fadeOut(0.2),cc.moveBy(0.2,-20,0)),cc.spawn(cc.fadeIn(0.3),Tools.createFramesAnimation("amon_dash_00",0.06,0,0),cc.moveBy(0.2,500,0),cc.sequence(cc.delayTime(0.02),Tools.createFramesAnimation("amon_attack_00",0.06,0,0))));ANIM_SEQUENCE.amonson.back=cc.spawn(Tools.createFramesAnimation("amon_back_00",
0.06,0,0),cc.moveBy(0.2,-480,0),cc.moveTo(0.5,0.1*GC.SCREEN.SIZE.WIDTH,0.7*GC.SCREEN.SIZE.HEIGHT));ANIM_SEQUENCE.amonson.attack=cc.sequence(cc.spawn(cc.fadeOut(0.2),cc.moveBy(0.2,-20,0)),cc.spawn(cc.fadeIn(0.3),Tools.createFramesAnimation("amon_dash_00",0.06,0,0),cc.moveBy(0.2,400,0)),Tools.createFramesAnimation("amon_attack_00",0.06,0,0),cc.delayTime(0.4),cc.spawn(Tools.createFramesAnimation("amon_back_00",0.06,0,0),cc.moveBy(0.2,-380,0),cc.sequence(cc.delayTime(0.3),Tools.createFramesAnimation("amon_idle_00",
0.06,0,7))));ANIM_SEQUENCE.amonson.hurt=cc.sequence(cc.delayTime(0.5),Tools.createFramesAnimation("amon_hit_00",0.04,0,0),cc.delayTime(1),Tools.createFramesAnimation("amon_idle_00",0.06,0,7),cc.moveTo(0.5,0.1*GC.SCREEN.SIZE.WIDTH,0.7*GC.SCREEN.SIZE.HEIGHT));ANIM_SEQUENCE.amonson.hurtAlt=cc.sequence(cc.delayTime(0.5),Tools.createFramesAnimation("amon_hit_00",0.04,0,0),cc.delayTime(0.6),Tools.createFramesAnimation("amon_idle_00",0.06,0,7),cc.moveTo(0.5,0.1*GC.SCREEN.SIZE.WIDTH,0.7*GC.SCREEN.SIZE.HEIGHT))}
function loadCastillanActions(){ANIM_SEQUENCE.PrinceCastillan.dash=cc.spawn(Tools.createFramesAnimation("princeCas_dash_00",0.06,0,0),cc.moveTo(1,0.7*GC.SCREEN.SIZE.WIDTH,0.45*GC.SCREEN.SIZE.HEIGHT));ANIM_SEQUENCE.PrinceCastillan.idle=Tools.createFramesAnimation("princeCas_idle_00",0.08,0,7);ANIM_SEQUENCE.PrinceCastillan.dAttack=cc.sequence(cc.spawn(cc.moveBy(0.2,20,0)),cc.spawn(Tools.createFramesAnimation("princeCas_dash_00",0.06,0,0),cc.moveBy(0.2,-500,0),cc.sequence(cc.delayTime(0.02),cc.callFunc(function(){playSoundEffect(res.castillanAttack_mp3)},
this),Tools.createFramesAnimation("princeCas_attack_00",0.06,0,4))));ANIM_SEQUENCE.PrinceCastillan.back=cc.spawn(Tools.createFramesAnimation("princeCas_back_00",0.06,0,0),cc.moveBy(0.2,480,0),cc.sequence(cc.delayTime(0.3),Tools.createFramesAnimation("princeCas_idle_00",0.08,0,7)));ANIM_SEQUENCE.PrinceCastillan.attack=cc.sequence(cc.spawn(cc.moveBy(0.2,20,0)),cc.spawn(Tools.createFramesAnimation("princeCas_dash_00",0.06,0,0),cc.moveBy(0.2,-400,0)),cc.delayTime(0.2),cc.callFunc(function(){playSoundEffect(res.castillanAttack_mp3)},
this),Tools.createFramesAnimation("princeCas_attack_00",0.06,0,4),cc.delayTime(0.2),cc.spawn(Tools.createFramesAnimation("princeCas_back_00",0.06,0,0),cc.moveBy(0.2,380,0)),cc.delayTime(0.3),Tools.createFramesAnimation("princeCas_idle_00",0.08,0,7));ANIM_SEQUENCE.PrinceCastillan.hurt=Tools.createFramesAnimation("princeCas_hit_00",0.04,0,0);ANIM_SEQUENCE.PrinceCastillan.charge=Tools.createFramesAnimation("princeCas_charge_00",0.04,0,0);ANIM_SEQUENCE.PrinceCastillan.block=Tools.createFramesAnimation("princeCas_counter_00",
0.04,0,3)}
function loadStromulexActions(){ANIM_SEQUENCE.Stromulex.dash=cc.spawn(Tools.createFramesAnimation("stromu_dash_00",0.06,0,0),cc.moveTo(1,0.7*GC.SCREEN.SIZE.WIDTH,0.45*GC.SCREEN.SIZE.HEIGHT));ANIM_SEQUENCE.Stromulex.idle=Tools.createFramesAnimation("stromu_idle_00",0.06,0,7);ANIM_SEQUENCE.Stromulex.dAttack=cc.sequence(cc.spawn(cc.moveBy(0.2,20,0)),cc.spawn(Tools.createFramesAnimation("stromu_dash_00",0.06,0,0),cc.moveBy(0.2,-500,0),cc.sequence(cc.delayTime(0.02),cc.callFunc(function(){playSoundEffect(res.genericAttack_mp3)},this),
Tools.createFramesAnimation("stromu_attack_00",0.06,0,4))));ANIM_SEQUENCE.Stromulex.back=cc.spawn(Tools.createFramesAnimation("stromu_back_00",0.06,0,0),cc.moveBy(0.2,480,0),cc.sequence(cc.delayTime(0.3),Tools.createFramesAnimation("stromu_idle_00",0.06,0,7)));ANIM_SEQUENCE.Stromulex.attack=cc.sequence(cc.spawn(cc.moveBy(0.2,20,0)),cc.spawn(Tools.createFramesAnimation("stromu_dash_00",0.06,0,0),cc.moveBy(0.2,-400,0)),cc.delayTime(0.2),cc.callFunc(function(){playSoundEffect(res.genericAttack_mp3)},
this),Tools.createFramesAnimation("stromu_attack_00",0.06,0,4),cc.delayTime(0.2),cc.spawn(Tools.createFramesAnimation("stromu_back_00",0.06,0,0),cc.moveBy(0.2,380,0)),cc.delayTime(0.3),Tools.createFramesAnimation("stromu_idle_00",0.06,0,7));ANIM_SEQUENCE.Stromulex.hurt=Tools.createFramesAnimation("stromu_hit_00",0.04,0,0);ANIM_SEQUENCE.Stromulex.charge=Tools.createFramesAnimation("stromu_charge_00",0.04,0,0);ANIM_SEQUENCE.Stromulex.block=Tools.createFramesAnimation("stromu_counter_00",0.04,0,3)}
function loadAvereActions(){ANIM_SEQUENCE.Avere.dash=cc.spawn(Tools.createFramesAnimation("avere_dash_00",0.06,0,0),cc.moveTo(1,0.7*GC.SCREEN.SIZE.WIDTH,0.45*GC.SCREEN.SIZE.HEIGHT));ANIM_SEQUENCE.Avere.idle=Tools.createFramesAnimation("avere_idle_00",0.08,0,7);ANIM_SEQUENCE.Avere.dAttack=cc.sequence(cc.spawn(cc.moveBy(0.2,20,0)),cc.spawn(Tools.createFramesAnimation("avere_dash_00",0.06,0,0),cc.moveBy(0.2,-500,0),cc.sequence(cc.delayTime(0.02),cc.callFunc(function(){playSoundEffect(res.avereAttack_mp3)},
this),Tools.createFramesAnimation("avere_attack_00",0.06,0,4))));ANIM_SEQUENCE.Avere.back=cc.spawn(Tools.createFramesAnimation("avere_back_00",0.06,0,0),cc.moveBy(0.2,480,0),cc.sequence(cc.delayTime(0.3),Tools.createFramesAnimation("avere_idle_00",0.08,0,7)));ANIM_SEQUENCE.Avere.attack=cc.sequence(cc.spawn(cc.moveBy(0.2,20,0)),cc.spawn(Tools.createFramesAnimation("avere_dash_00",0.06,0,0),cc.moveBy(0.2,-400,0)),cc.delayTime(0.2),cc.callFunc(function(){playSoundEffect(res.avereAttack_mp3)},this),Tools.createFramesAnimation("avere_attack_00",
0.06,0,4),cc.delayTime(0.2),cc.spawn(Tools.createFramesAnimation("avere_back_00",0.06,0,0),cc.moveBy(0.2,380,0)),cc.delayTime(0.3),Tools.createFramesAnimation("avere_idle_00",0.08,0,7));ANIM_SEQUENCE.Avere.hurt=Tools.createFramesAnimation("avere_hit_00",0.04,0,0);ANIM_SEQUENCE.Avere.charge=Tools.createFramesAnimation("avere_charge_00",0.04,0,0);ANIM_SEQUENCE.Avere.block=Tools.createFramesAnimation("avere_counter_00",0.04,0,3)}
function loadBlackyardActions(){ANIM_SEQUENCE.KingBlackyard.dash=cc.spawn(Tools.createFramesAnimation("blackyard_dash_00",0.06,0,0),cc.moveTo(1,0.7*GC.SCREEN.SIZE.WIDTH,0.45*GC.SCREEN.SIZE.HEIGHT));ANIM_SEQUENCE.KingBlackyard.idle=Tools.createFramesAnimation("blackyard_idle_00",0.06,0,7);ANIM_SEQUENCE.KingBlackyard.dAttack=cc.sequence(cc.spawn(cc.moveBy(0.2,20,0)),cc.spawn(Tools.createFramesAnimation("blackyard_dash_00",0.06,0,0),cc.moveBy(0.2,-500,0),cc.sequence(cc.delayTime(0.02),cc.callFunc(function(){playSoundEffect(res.genericAttack_mp3)},
this),Tools.createFramesAnimation("blackyard_attack_00",0.06,0,4))));ANIM_SEQUENCE.KingBlackyard.back=cc.spawn(Tools.createFramesAnimation("blackyard_back_00",0.06,0,0),cc.moveBy(0.2,480,0),cc.sequence(cc.delayTime(0.3),Tools.createFramesAnimation("blackyard_idle_00",0.06,0,7)));ANIM_SEQUENCE.KingBlackyard.attack=cc.sequence(cc.spawn(cc.moveBy(0.2,20,0)),cc.spawn(Tools.createFramesAnimation("blackyard_dash_00",0.06,0,0),cc.moveBy(0.2,-400,0)),cc.delayTime(0.2),cc.callFunc(function(){playSoundEffect(res.genericAttack_mp3)},
this),Tools.createFramesAnimation("blackyard_attack_00",0.06,0,4),cc.delayTime(0.2),cc.spawn(Tools.createFramesAnimation("blackyard_back_00",0.06,0,0),cc.moveBy(0.2,380,0)),cc.delayTime(0.2),Tools.createFramesAnimation("blackyard_idle_00",0.06,0,7));ANIM_SEQUENCE.KingBlackyard.hurt=Tools.createFramesAnimation("blackyard_hit_00",0.04,0,0);ANIM_SEQUENCE.KingBlackyard.charge=Tools.createFramesAnimation("blackyard_charge_00",0.04,0,0);ANIM_SEQUENCE.KingBlackyard.block=Tools.createFramesAnimation("blackyard_counter_00",
0.04,0,3)}
function loadGrindiokActions(){ANIM_SEQUENCE.Grindiok.dash=cc.spawn(Tools.createFramesAnimation("grin_dash_00",0.06,0,0),cc.moveTo(1,0.7*GC.SCREEN.SIZE.WIDTH,0.45*GC.SCREEN.SIZE.HEIGHT));ANIM_SEQUENCE.Grindiok.idle=Tools.createFramesAnimation("grin_idle_00",0.06,0,7);ANIM_SEQUENCE.Grindiok.dAttack=cc.sequence(cc.spawn(cc.moveBy(0.2,20,0)),cc.spawn(Tools.createFramesAnimation("grin_dash_00",0.06,0,0),cc.moveBy(0.2,-500,0),cc.sequence(cc.delayTime(0.02),cc.callFunc(function(){playSoundEffect(res.genericAttack_mp3)},this),
Tools.createFramesAnimation("grin_attack_00",0.06,0,4))));ANIM_SEQUENCE.Grindiok.back=cc.spawn(Tools.createFramesAnimation("grin_back_00",0.06,0,0),cc.moveBy(0.2,480,0),cc.sequence(cc.delayTime(0.3),Tools.createFramesAnimation("grin_idle_00",0.06,0,7)));ANIM_SEQUENCE.Grindiok.attack=cc.sequence(cc.spawn(cc.moveBy(0.2,20,0)),cc.spawn(Tools.createFramesAnimation("grin_dash_00",0.06,0,0),cc.moveBy(0.2,-400,0)),cc.delayTime(0.2),cc.callFunc(function(){playSoundEffect(res.genericAttack_mp3)},this),Tools.createFramesAnimation("grin_attack_00",
0.06,0,4),cc.delayTime(0.2),cc.spawn(Tools.createFramesAnimation("grin_back_00",0.06,0,0),cc.moveBy(0.2,380,0)),cc.delayTime(0.2),Tools.createFramesAnimation("grin_idle_00",0.06,0,7));ANIM_SEQUENCE.Grindiok.hurt=Tools.createFramesAnimation("grin_hit_00",0.04,0,0);ANIM_SEQUENCE.Grindiok.charge=Tools.createFramesAnimation("grin_charge_00",0.04,0,0);ANIM_SEQUENCE.Grindiok.block=Tools.createFramesAnimation("grin_counter_00",0.04,0,3)};var HowToPlayPageLayer=cc.Layer.extend({ctor:function(a){this._super();a=new cc.Sprite(a==GC.HOW_TO_PLAY_PAGE.ONE?res.how_to_play_1:a==GC.HOW_TO_PLAY_PAGE.TWO?res.how_to_play_2:res.how_to_play_3);a.setPosition(GC.SCREEN.CENTER.X,GC.SCREEN.CENTER.Y);this.addChild(a,0)}}),HowToPlayNavigationLayer=cc.Layer.extend({currentPage:null,ctor:function(a){this._super();this.currentPage=a;var b=new cc.MenuItemImage("#btn_right.png","#btn_right.png",this.goToPrevPage,this);b.setAnchorPoint(0,0.5);b.setScale(0.5,
0.5);b.x=0;var c=new cc.MenuItemImage("#btn_left.png","#btn_left.png",this.goToNextPage,this);c.setAnchorPoint(1,0.5);c.setScale(0.5,0.5);c.x=GC.SCREEN.SIZE.WIDTH;b=a==GC.HOW_TO_PLAY_PAGE.COUNT?new cc.Menu(b):new cc.Menu(b,c);b.setPosition(0,GC.SCREEN.CENTER.Y);this.addChild(b);a==GC.HOW_TO_PLAY_PAGE.THREE&&(a=new cc.MenuItemImage("#ui_btnPlay_U.png","#ui_btnPlay_D.png",this.startGame,this),a.setAnchorPoint(1,0),a.setPosition(GC.SCREEN.SIZE.WIDTH-40,20),a.setScale(0.8),a=new cc.Menu(a),a.x=0,a.y=
0,this.addChild(a))},goToPrevPage:function(){var a;a=this.currentPage==GC.HOW_TO_PLAY_PAGE.ONE?new MainMenuScene:new HowToPlayScene(this.currentPage-1);cc.director.runScene(new cc.TransitionMoveInL(0.5,a))},goToNextPage:function(){var a=new HowToPlayScene(this.currentPage+1);cc.director.runScene(new cc.TransitionMoveInR(0.5,a))},startGame:function(){var a=new GameplayScene;cc.director.runScene(new cc.TransitionFade(0.5,a))}}),HowToPlayScene=cc.Scene.extend({currentPage:null,ctor:function(a){this._super();
this.currentPage=a},onEnter:function(){this._super();var a=new HowToPlayPageLayer(this.currentPage),b=new HowToPlayNavigationLayer(this.currentPage);this.addChild(a);this.addChild(b)}});var g_sharedGameplayLyr,g_sharedProgressFactory,g_sharedUIFactory,g_sharedFXFactory,g_sharedFXFactory2,GameplayLayer=cc.Layer.extend({player:void 0,enemy:void 0,amonson:void 0,buttonFactory:void 0,backgroundFactory:void 0,animRunning:void 0,inputAllow:void 0,potionBoon:void 0,ctor:function(){this._super();this.init()},init:function(){enemyShuffle();g_sharedGameplayLyr=this;this.createPlayers();this.createButtons();this.createUI();this.createBackground();this.createFX();this.animRunning=!1;this.inputAllow=
!0;GAME_STATUS=GAME.paused},createPlayers:function(){this.player=Player.create("#hiro_idle_000.png");this.player.runAction(cc.repeatForever(ANIM_SEQUENCE.hiro.idle));this.amonson=Amonson.create("#amon_idle_000.png");this.enemy=Enemy.create("#hiro_idle_000.png");this.enemy.runAction(cc.repeatForever(ANIM_SEQUENCE[ENEMY[STAGE]].idle))},createButtons:function(){this.buttonFactory=ButtonFactory.create(res.ui_png);this.buttonFactory.setPosition(0,0);this.buttonFactory.generateButtons()},createUI:function(){g_sharedProgressFactory=
ProgressFactory.create();g_sharedProgressFactory.init();g_sharedUIFactory=UIFactory.create(res.ui_png);g_sharedUIFactory.init()},createBackground:function(){this.backgroundFactory=BackgroundFactory.create();this.backgroundFactory.generateBG()},createFX:function(){g_sharedFXFactory=EffectsFactory.create(res.fx_png,2);g_sharedFXFactory2=EffectsFactory.create(res.fx2_png,LAYER.effects);g_sharedFXFactory2.generateGlow();g_sharedFXFactory2.generateEnemyGlow();g_sharedFXFactory2.generateCharge()},toggleButton:function(a,
b,c){c?this.buttonFactory.toggleActive(a,b):this.buttonFactory.toggleBack(a,b)},checkButtonPress:function(a){if(!this.animRunning)for(var b=0;b<this.buttonFactory.buttonList.length&&!this.buttonFactory.buttonList[b].isHit(a);b++);for(var c=g_sharedMiscFactory.boxList,b=0;b<c.length;b++)if(c[b].isHit(a)){for(a=0;a<c.length;a++)a!=b&&c[a].isActive&&(c[a].isActive=!1,c[a].runAction(cc.sequence(cc.delayTime(0.1),cc.fadeOut(0.1))));c=0.5;g_sharedHUDLyr.fadeText(g_sharedHUDLyr.pickRewardText,0.2);0==LEVEL%
5&&0!=LEVEL&&(c=5);this.runAction(cc.sequence(cc.delayTime(3.8),cc.callFunc(function(){g_sharedHUDLyr.slideOut();g_sharedMiscFactory.hideBoxes();0==LEVEL%5&&0!=LEVEL&&(g_sharedMiscFactory.showTierBanner(),STAGE=0)},this),cc.delayTime(c),cc.callFunc(function(){g_sharedTextFactory.setLevel(LEVEL+1);g_sharedMiscFactory.changeContender();g_sharedMiscFactory.showContender();this.backgroundFactory.switchBG();this.enemy.init(ENEMY_LIFE[LEVEL],!0);this.enemy.resetText();g_sharedProgressFactory.resetLifeBar(1);
g_sharedUIFactory.changeEnemyIcon();var a=this.enemy.name;"PrinceCastillan"==a?a="Prince Castillan":"KingBlackyard"==a&&(a="King Blackyard");g_sharedTextFactory.setEnemyName(a)},this),cc.delayTime(6),cc.callFunc(function(){this.player.gainBoon(g_sharedMiscFactory.boxList[b].type,this.potionBoon);g_sharedHUDLyr.toggleOverlay(!1);this.nextLevel()},this)));break}},fight:function(){var a;this.player.action==ACTIONS[0]?(a=ACTIONS[Tools.getRandomInt(1,4)],this.player.setCurrentAction(a)?this.player.action=
a:this.player.action=ACTIONS[0],this.fight()):(a=this.enemy.action,g_sharedTextFactory.timer.stopAllActions(),"chargeAttack"==a?a="Boost attack":"chargeCounter"==a&&(a="Boost counter"),g_sharedTextFactory.setEnemyMove(a),g_sharedFXFactory2.setEnemyGlow(this.enemy.action),this.checkRules())},checkResult:function(){0<this.player.life&&0<this.enemy.life&&(this.player.updateAction(),this.enemy.updateAction(),g_sharedTextFactory.timerPulse());0>=this.player.life?(this.player.die(),this.end()):0>=this.enemy.life&&
this.prepNextLevel()},checkIfDraw:function(a,b){var c=this.enemy.life;return 0>=this.player.life&&0>=c?!0:!1},draw:function(){this.player.doAnimation("draw");this.enemy.doAnimation("draw");this.runAction(cc.sequence(cc.delayTime(3),cc.callFunc(function(){GAME_STATUS=GAME.paused;g_sharedHUDLyr.toggleOverlay(!0);g_sharedMiscFactory.slideInDraw();g_sharedFXFactory2.resetGlow();g_sharedFXFactory2.resetEnemyGlow()},this),cc.delayTime(3.2),cc.callFunc(function(){this.inputAllow=!0;this.animRunning=!1;this.player.init(15);
this.player.resetText();this.enemy.init(15,!1);this.enemy.resetText();g_sharedHUDLyr.toggleOverlay(!1);g_sharedProgressFactory.updateLifeBar(15,ENEMY_LIFE[LEVEL],1);GAME_STATUS=GAME.active;g_sharedTextFactory.timerPulse();g_sharedGameplayLyr.buttonFactory.toggleOpacity(255);g_sharedHUDLyr.timerCounter=4;g_sharedHUDLyr.counter=0;g_sharedTextFactory.setTimer(3);g_sharedUIFactory.resetTimer()},this)))},setPlayerAction:function(a){Tools.getRandomInt(1,3);var b;this.player.setCurrentAction(a)&&this.inputAllow&&
(b=a,"chargeAttack"==b?b="Boost attack":"chargeCounter"==b&&(b="Boost counter"),g_sharedTextFactory.setPlayerMove(b),this.player.action=a)},delayAfterAnim:function(a){this.runAction(cc.sequence(cc.delayTime(a),cc.callFunc(function(){this.animRunning=!1;this.checkResult();this.inputAllow=!0;g_sharedHUDLyr.timerCounter=4;g_sharedHUDLyr.counter=0;g_sharedTextFactory.setTimer(3);g_sharedUIFactory.resetTimer();g_sharedGameplayLyr.buttonFactory.toggleOpacity(255);g_sharedFXFactory2.resetEnemyGlow()},this)))},
checkRules:function(){var a=this.player.attackCharge,b=this.player.counterCharge,c=this.enemy.attackCharge,d=this.enemy.counterCharge,e=2;switch(this.player.action){case "attack":"counter"==this.enemy.action?(this.player.doAnimation("attack"),this.amonson.doAnimation("attack"),this.enemy.hurt(this.computeCounterDamage(a,d,ENEMY_DAMAGE[TIER],ENEMY_DAMAGE[TIER]),"block"),this.runAction(cc.sequence(cc.delayTime(2),cc.callFunc(function(){0<this.enemy.life&&(this.enemy.doAnimation("attack"),this.player.hurt(this.computeAttackDamage(a,
d,ENEMY_DAMAGE[TIER],ENEMY_DAMAGE[TIER]),"hit"),this.amonson.runAction(cc.sequence(cc.delayTime(0.22),cc.callFunc(function(){this.amonson.doAnimation("hit")},this))));this.delayAfterAnim(e)},this)))):"attack"==this.enemy.action?(this.player.hurt(c*ENEMY_DAMAGE[TIER],"void"),this.enemy.hurt(a*ENEMY_DAMAGE[TIER],"void"),this.checkIfDraw(a,c)?this.draw():(this.player.doAnimation("draw"),this.amonson.doAnimation("draw"),this.enemy.doAnimation("draw"),this.runAction(cc.sequence(cc.delayTime(1),cc.callFunc(function(){this.delayAfterAnim(e)},
this))))):(this.player.doAnimation("attack"),this.amonson.doAnimation("attack"),this.enemy.hurt(a*ENEMY_DAMAGE[TIER],"hit"),this.delayAfterAnim(2));this.buttonFactory.toggleBack(0,"Atk");break;case "counter":this.amonson.toggle();this.player.doAnimation("block");if("attack"==this.enemy.action)this.enemy.doAnimation("attack"),this.player.hurt(this.computeCounterDamage(c,b,ENEMY_DAMAGE[TIER],ENEMY_DAMAGE[TIER]),"block"),this.runAction(cc.sequence(cc.delayTime(2),cc.callFunc(function(){e=1.5;0<this.player.life&&
(this.player.doAnimation("attack"),this.enemy.hurt(this.computeAttackDamage(c,b,ENEMY_DAMAGE[TIER],ENEMY_DAMAGE[TIER]),"hit"),this.enemy.isHit=!1);this.delayAfterAnim(e)},this)));else if("counter"==this.enemy.action)this.enemy.doAnimation("block"),this.delayAfterAnim(2);else if("chargeAttack"==this.enemy.action||"chargeCounter"==this.enemy.action)this.enemy.bonusCharge=1,this.enemy.doAnimation(this.enemy.action),this.delayAfterAnim(2);this.buttonFactory.toggleBack(3,"Ctr");break;default:"attack"==
this.enemy.action?(this.enemy.doAnimation("attack"),this.player.hurt(this.enemy.attackCharge*ENEMY_DAMAGE[TIER],"hit"),this.amonson.doAnimation("hit"),this.delayAfterAnim(1.5)):"counter"==this.enemy.action?(this.enemy.doAnimation("block"),this.player.bonusCharge=1,this.player.doAnimation(this.player.action),this.delayAfterAnim(1.5)):(this.player.doAnimation(this.player.action),this.enemy.doAnimation(this.enemy.action),this.delayAfterAnim(1))}},computeAttackDamage:function(a,b,c,d){return a<=b?a*c+
b*d:2*b*d},computeCounterDamage:function(a,b,c,d){var e=0;b<a&&(e=a*c-b*d);return e},getPlayerCharge:function(){return this.player.attackCharge},getEnemyCharge:function(){return this.enemy.attackCharge},prepNextLevel:function(){var a=POTION[TIER];GAME_STATUS=GAME.paused;LEVEL++;STAGE++;this.enemy.die();this.runAction(cc.sequence(cc.delayTime(1.5),cc.callFunc(function(){0==LEVEL%5&&0!=LEVEL?(TIER++,enemyShuffle(),this.player.init(PLAYER_LIFE[TIER]),g_sharedProgressFactory.resetLifeBar(0),g_sharedTextFactory.showPotion("full")):
(3==STAGE&&(a=POTION[TIER]+POTION_ADD[TIER]),this.player.init(a),g_sharedProgressFactory.updateLifeBar(this.player.life,PLAYER_LIFE[TIER],0),g_sharedTextFactory.showPotion(a));g_sharedTextFactory.setPlayerLife(this.player.life,PLAYER_LIFE[TIER])},this),cc.delayTime(1.7),cc.callFunc(function(){this.player.setSpriteFrame("hiro_idle_000.png");this.potionBoon=POTION_BONUS[Tools.getRandomInt(0,POTION_BONUS.length-1)];g_sharedHUDLyr.toggleOverlay(!0);g_sharedHUDLyr.toggleLevelComplete();g_sharedMiscFactory.showBoxes();
playSoundEffect(res.enemyDefeat_mp3)},this)))},nextLevelAnimate:function(){g_sharedHUDLyr.slideOut();g_sharedHUDLyr.toggleOverlay(!1);g_sharedMiscFactory.hideBoxes();this.nextLevel()},nextLevel:function(){g_sharedTextFactory.timerPulse();this.runAction(cc.sequence(cc.delayTime(0.5),cc.callFunc(function(){this.player.resetText();this.enemy.doAnimation("dash")},this),cc.delayTime(1),cc.callFunc(function(){GAME_STATUS=GAME.active;this.enemy.doAnimation("idle")},this)))},destroy:function(){this.player.destroy();
this.enemy.destroy();this.amonson.destroy();this.backgroundFactory.destroy();this.buttonFactory.destroy();g_sharedTextFactory.destroy();g_sharedProgressFactory.destroy();g_sharedFXFactory.destroy();g_sharedFXFactory2.destroy();g_sharedMiscFactory.destroy();g_sharedMiscFactory2.destroy();g_sharedUIFactory.destroy()},end:function(){GAME_STATUS=GAME.paused;this.runAction(cc.sequence(cc.delayTime(1.5),cc.callFunc(function(){var a=new GameOverScene;cc.director.runScene(new cc.TransitionMoveInT(0.5,a))},
this)));this.runAction(cc.sequence(cc.delayTime(1.25),cc.callFunc(function(){this.destroy()},this)))}}),g_sharedHUDLyr,g_sharedTextFactory,g_sharedMiscFactory,g_sharedMiscFactory2,HudLayer=cc.Layer.extend({overlay:void 0,container:void 0,whiteOverlay:void 0,potionBoon:void 0,pickRewardText:void 0,counter:0,timerCounter:4,ctor:function(){this._super();this.init();this.toggleOverlay(!0)},init:function(){g_sharedHUDLyr=this;this.createTextFactory();this.createMiscFactory();var a=new cc.Sprite("#ui_defeatContainer.png");
a.setPosition(0.5*GC.SCREEN.SIZE.WIDTH,1.4*GC.SCREEN.SIZE.HEIGHT);a.setAnchorPoint(0.5,0.5);this.addChild(a,1);this.container=a;overlay=new cc.LayerColor(cc.color(0,0,0,0),GC.SCREEN.SIZE.WIDTH,GC.SCREEN.SIZE.HEIGHT);overlay.setPosition(0,0);overlay.setAnchorPoint(0.5,0.5);this.addChild(overlay);this.whiteOverlay=new cc.LayerColor(cc.color(255,255,255,0),GC.SCREEN.SIZE.WIDTH,GC.SCREEN.SIZE.HEIGHT);this.whiteOverlay.setPosition(0,0);this.whiteOverlay.setAnchorPoint(0.5,0.5);this.addChild(this.whiteOverlay,
5);this.potionBoon=Tools.createText(this,0.485*GC.SCREEN.SIZE.WIDTH,0.115*GC.SCREEN.SIZE.HEIGHT,0.7,cc.p(0.5,0.5),"+35 Health",res.font_fnt);this.potionBoon.setOpacity(0);this.potionBoon.setColor(cc.color(234,71,129,255));this.pickRewardText=Tools.createText(this,0.5*GC.SCREEN.SIZE.WIDTH,0.5*GC.SCREEN.SIZE.HEIGHT,0.9,cc.p(0.5,0.5),"Pick your reward!",res.font_fnt);this.pickRewardText.setOpacity(0);this.scheduleUpdate()},createTextFactory:function(){var a=ENEMY[STAGE];g_sharedTextFactory=TextFactory.create();
"PrinceCastillan"==a?a="Prince Castillan":"KingBlackyard"==a&&(a="King Blackyard");g_sharedTextFactory.setEnemyName(a)},createMiscFactory:function(){g_sharedMiscFactory=MiscFactory.create(res.misc_png);g_sharedMiscFactory.init();g_sharedMiscFactory2=MiscFactory.create(res.ui_png)},update:function(a){GAME_STATUS==GAME.active&&(0<this.timerCounter?g_sharedGameplayLyr.animRunning||(this.timerCounter-=a,g_sharedTextFactory.setTimer(parseInt(this.timerCounter)),this.counter+=a,1<=this.counter&&(g_sharedUIFactory.changeTimer(),
this.counter=0)):(g_sharedGameplayLyr.inputAllow&&(g_sharedGameplayLyr.fight(),g_sharedGameplayLyr.inputAllow=!1,g_sharedGameplayLyr.animRunning=!0,g_sharedGameplayLyr.buttonFactory.toggleOpacity(50),g_sharedFXFactory2.resetGlow()),g_sharedTextFactory.timer.stopAllActions()))},slideOut:function(){this.container.runAction(cc.Sequence.create(cc.moveBy(0.2,cc.p(0,-50)).easing(cc.easeIn(0.5)),cc.moveBy(0.2,cc.p(0,550)).easing(cc.easeOut(0.5))));g_sharedMiscFactory.slideOutOpponentTag()},togglePotion:function(){g_sharedMiscFactory.showHeart();
this.potionBoon.setString("+"+g_sharedGameplayLyr.potionBoon);this.potionBoon.runAction(cc.sequence(cc.spawn(cc.fadeIn(0.2),cc.sequence(cc.scaleTo(0.2,1.1).easing(cc.easeIn(0.5)),cc.scaleTo(0.2,0.7))),cc.delayTime(1.7),cc.fadeOut(0.2)))},toggleOverlay:function(a){a?overlay.runAction(cc.fadeTo(0.2,210)):overlay.runAction(cc.fadeTo(0.2,0))},toggleLevelComplete:function(){this.container.runAction(cc.sequence(cc.moveBy(0.2,cc.p(0,-550)).easing(cc.easeIn(0.5)),cc.moveBy(0.2,cc.p(0,50)).easing(cc.easeOut(0.5))));
this.pickRewardText.runAction(cc.sequence(cc.spawn(cc.fadeIn(0.2),cc.sequence(cc.scaleTo(0.2,1.2).easing(cc.easeIn(0.5)),cc.scaleTo(0.2,0.9)))));g_sharedMiscFactory.slideInOpponentTag()},fadeText:function(a,b){a.runAction(cc.fadeOut(b))}}),GameControlsLayer=cc.Layer.extend({ctor:function(){this._super();this.init()},init:function(){cc.eventManager.addListener(TapListener,this)}}),GameplayScene=cc.Scene.extend({gameplayLayer:null,ctor:function(){this._super()},onEnter:function(){this._super();var a=
this.gameplayLayer=new GameplayLayer,b=new HudLayer,c=new GameControlsLayer;this.addChild(a);this.addChild(b);this.addChild(c)}});var GameOverLayer=cc.Layer.extend({isNewHighScore:null,ctor:function(){this._super();this.init()},init:function(){this._super();var a=new cc.Sprite(res.results_png);a.setPosition(GC.SCREEN.CENTER.X,GC.SCREEN.CENTER.Y);this.addChild(a,0);var b=cc.color(254,206,23),c=cc.color(34,5,124),d=cc.color(254,206,23),a=cc.LabelBMFont.create("999",res.scoreFont_fnt);a.setColor(d);a.setScale(1.2);a.setRotation(-8.8);a.setAnchorPoint(0,0);a.setPosition(GC.SCREEN.CENTER.X+GC.GAME_OVER_ASSETS.ENEMIES.X,GC.SCREEN.CENTER.Y+
GC.GAME_OVER_ASSETS.ENEMIES.Y);this.addChild(a);d=cc.LabelBMFont.create("999",res.scoreFont_fnt);d.setColor(b);d.setScale(1.2);d.setRotation(-8.7);d.setAnchorPoint(0,0);d.setPosition(GC.SCREEN.CENTER.X+GC.GAME_OVER_ASSETS.HIGH.X,GC.SCREEN.CENTER.Y+GC.GAME_OVER_ASSETS.HIGH.Y);this.addChild(d);b=cc.LabelBMFont.create("999",res.scoreFont_fnt);b.setColor(c);b.setScale(1.2);b.setRotation(-8.7);b.setAnchorPoint(0,0);b.setPosition(GC.SCREEN.CENTER.X+GC.GAME_OVER_ASSETS.YOUR.X,GC.SCREEN.CENTER.Y+GC.GAME_OVER_ASSETS.YOUR.Y);
this.addChild(b);c=new cc.Sprite("#ui_newRecord.png");c.x=d.x-80;c.y=0.511*GC.SCREEN.SIZE.HEIGHT;c.setRotation(-8.8);this.addChild(c,0);this.isNewHighScore=!1;a.setString(LEVEL+1);d.setString(this.getHighScore());b.setString(GC.SCORE);c.visible=this.isNewHighScore?!0:!1;"function"==typeof showAd&&showAd();reset();a=new cc.MenuItemImage("#ui_btnPlay_U.png","#ui_btnPlay_D.png",this.replayGame,this);a.setAnchorPoint(1,0);a.setPosition(GC.SCREEN.SIZE.WIDTH-40,20);a.setScale(0.8);a=new cc.Menu(a);a.x=
0;a.y=0;this.addChild(a)},getHighScore:function(){var a=cc.sys.localStorage.getItem(GC.UNIQUE_SCORE_KEY);return GC.SCORE>a||null==a?(cc.sys.localStorage.setItem(GC.UNIQUE_SCORE_KEY,GC.SCORE),null!=a&&(this.isNewHighScore=!0),GC.SCORE):a},replayGame:function(){var a=new GameplayScene;cc.director.runScene(new cc.TransitionFade(0.5,a))}}),GameOverScene=cc.Scene.extend({onEnter:function(){this._super();var a=new GameOverLayer;this.addChild(a)}});